From: Lucas Tanure <tanureal@opensource.cirrus.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Hans de Goede <hdegoede@redhat.com>,
Mark Gross <markgross@kernel.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Mark Brown <broonie@kernel.org>,
Takashi Iwai <tiwai@suse.com>, Kailang Yang <kailang@realtek.com>,
Shuming Fan <shumingf@realtek.com>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
David Rhodes <david.rhodes@cirrus.com>,
Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Cc: Jeremy Szu <jeremy.szu@canonical.com>,
Hui Wang <hui.wang@canonical.com>,
Werner Sembach <wse@tuxedocomputers.com>,
Chris Chiu <chris.chiu@canonical.com>,
Cameron Berkenpas <cam@neo-zeon.de>, Sami Loone <sami@loone.fi>,
Elia Devito <eliadevito@gmail.com>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Jack Yu <jack.yu@realtek.com>, "Arnd Bergmann" <arnd@arndb.de>,
Lars-Peter Clausen <lars@metafoo.de>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
<alsa-devel@alsa-project.org>, <linux-acpi@vger.kernel.org>,
<patches@opensource.cirrus.com>,
<platform-driver-x86@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
"Lucas Tanure" <tanureal@opensource.cirrus.com>
Subject: [PATCH 01/11] ASoC: cs35l41: Set the max SPI speed for the whole device
Date: Tue, 23 Nov 2021 16:31:39 +0000 [thread overview]
Message-ID: <20211123163149.1530535-2-tanureal@opensource.cirrus.com> (raw)
In-Reply-To: <20211123163149.1530535-1-tanureal@opensource.cirrus.com>
Higher speeds are only supported when PLL is enabled, but
the current driver doesn't enable PLL outside of stream
use cases, so better to set the lowest SPI speed accepted
by the entire device.
Move the current frequency set to the spi sub-driver so
the whole device can benefit from that speed.
spi-max-frequency property could be used, but ACPI systems don't
support it, so by setting it in the spi sub-driver probe
both Device Trees and ACPI systems are supported.
Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
---
sound/soc/codecs/cs35l41-spi.c | 32 +++-----------------------------
sound/soc/codecs/cs35l41.c | 7 -------
sound/soc/codecs/cs35l41.h | 4 +---
3 files changed, 4 insertions(+), 39 deletions(-)
diff --git a/sound/soc/codecs/cs35l41-spi.c b/sound/soc/codecs/cs35l41-spi.c
index 90a921f726c3..3fa99741779a 100644
--- a/sound/soc/codecs/cs35l41-spi.c
+++ b/sound/soc/codecs/cs35l41-spi.c
@@ -42,34 +42,6 @@ static const struct spi_device_id cs35l41_id_spi[] = {
MODULE_DEVICE_TABLE(spi, cs35l41_id_spi);
-static void cs35l41_spi_otp_setup(struct cs35l41_private *cs35l41,
- bool is_pre_setup, unsigned int *freq)
-{
- struct spi_device *spi;
- u32 orig_spi_freq;
-
- spi = to_spi_device(cs35l41->dev);
-
- if (!spi) {
- dev_err(cs35l41->dev, "%s: No SPI device\n", __func__);
- return;
- }
-
- if (is_pre_setup) {
- orig_spi_freq = spi->max_speed_hz;
- if (orig_spi_freq > CS35L41_SPI_MAX_FREQ_OTP) {
- spi->max_speed_hz = CS35L41_SPI_MAX_FREQ_OTP;
- spi_setup(spi);
- }
- *freq = orig_spi_freq;
- } else {
- if (spi->max_speed_hz != *freq) {
- spi->max_speed_hz = *freq;
- spi_setup(spi);
- }
- }
-}
-
static int cs35l41_spi_probe(struct spi_device *spi)
{
const struct regmap_config *regmap_config = &cs35l41_regmap_spi;
@@ -81,6 +53,9 @@ static int cs35l41_spi_probe(struct spi_device *spi)
if (!cs35l41)
return -ENOMEM;
+ spi->max_speed_hz = CS35L41_SPI_MAX_FREQ;
+ spi_setup(spi);
+
spi_set_drvdata(spi, cs35l41);
cs35l41->regmap = devm_regmap_init_spi(spi, regmap_config);
if (IS_ERR(cs35l41->regmap)) {
@@ -91,7 +66,6 @@ static int cs35l41_spi_probe(struct spi_device *spi)
cs35l41->dev = &spi->dev;
cs35l41->irq = spi->irq;
- cs35l41->otp_setup = cs35l41_spi_otp_setup;
return cs35l41_probe(cs35l41, pdata);
}
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index afb07d2991ba..e8e997efaa8b 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -438,7 +438,6 @@ static int cs35l41_otp_unpack(void *data)
const struct cs35l41_otp_packed_element_t *otp_map;
struct cs35l41_private *cs35l41 = data;
int bit_offset, word_offset, ret, i;
- unsigned int orig_spi_freq;
unsigned int bit_sum = 8;
u32 otp_val, otp_id_reg;
u32 *otp_mem;
@@ -462,9 +461,6 @@ static int cs35l41_otp_unpack(void *data)
goto err_otp_unpack;
}
- if (cs35l41->otp_setup)
- cs35l41->otp_setup(cs35l41, true, &orig_spi_freq);
-
ret = regmap_bulk_read(cs35l41->regmap, CS35L41_OTP_MEM0, otp_mem,
CS35L41_OTP_SIZE_WORDS);
if (ret < 0) {
@@ -472,9 +468,6 @@ static int cs35l41_otp_unpack(void *data)
goto err_otp_unpack;
}
- if (cs35l41->otp_setup)
- cs35l41->otp_setup(cs35l41, false, &orig_spi_freq);
-
otp_map = otp_map_match->map;
bit_offset = otp_map_match->bit_offset;
diff --git a/sound/soc/codecs/cs35l41.h b/sound/soc/codecs/cs35l41.h
index eea3b14acb0b..a23eabff074f 100644
--- a/sound/soc/codecs/cs35l41.h
+++ b/sound/soc/codecs/cs35l41.h
@@ -729,7 +729,7 @@
#define CS35L41_FS2_WINDOW_MASK 0x00FFF800
#define CS35L41_FS2_WINDOW_SHIFT 12
-#define CS35L41_SPI_MAX_FREQ_OTP 4000000
+#define CS35L41_SPI_MAX_FREQ 4000000
#define CS35L41_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
#define CS35L41_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
@@ -784,8 +784,6 @@ struct cs35l41_private {
int irq;
/* GPIO for /RST */
struct gpio_desc *reset_gpio;
- void (*otp_setup)(struct cs35l41_private *cs35l41, bool is_pre_setup,
- unsigned int *freq);
};
int cs35l41_probe(struct cs35l41_private *cs35l41,
--
2.34.0
next prev parent reply other threads:[~2021-11-23 16:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 16:31 [PATCH v3 00/11] Add support for Legion 7 16ACHg6 laptop Lucas Tanure
2021-11-23 16:31 ` Lucas Tanure [this message]
2021-11-23 18:02 ` [PATCH 01/11] ASoC: cs35l41: Set the max SPI speed for the whole device Charles Keepax
2021-11-23 16:31 ` [PATCH 02/11] ASoC: cs35l41: Convert tables to shared source code Lucas Tanure
2021-11-23 17:53 ` Mark Brown
2021-11-23 18:05 ` Charles Keepax
2021-11-23 16:31 ` [PATCH 03/11] ASoC: cs35l41: Move regmap config struct to shared code Lucas Tanure
2021-11-23 17:20 ` Mark Brown
2021-11-23 16:31 ` [PATCH 04/11] ASoC: cs35l41: Create function for init array of Supplies Lucas Tanure
2021-11-23 17:58 ` Mark Brown
2021-11-24 13:31 ` Mark Brown
2021-11-23 16:31 ` [PATCH 05/11] ASoC: cs35l41: Move cs35l41_otp_unpack to shared code Lucas Tanure
2021-11-23 16:31 ` [PATCH 06/11] ASoC: cs35l41: Move power initializations to reg_sequence Lucas Tanure
2021-11-23 16:31 ` [PATCH 07/11] ASoC: cs35l41: Create shared function for errata patches Lucas Tanure
2021-11-23 16:31 ` [PATCH 08/11] ASoC: cs35l41: Create shared function for setting channels Lucas Tanure
2021-11-23 16:31 ` [PATCH 09/11] ASoC: cs35l41: Create shared function for boost configuration Lucas Tanure
2021-11-23 16:31 ` [PATCH 10/11] hda: cs35l41: Add support for CS35L41 in HDA systems Lucas Tanure
2021-11-23 16:52 ` Takashi Iwai
2021-11-23 16:59 ` Pierre-Louis Bossart
2021-11-23 17:06 ` tanureal
2021-11-23 17:16 ` Pierre-Louis Bossart
2021-11-23 17:15 ` Mark Brown
2021-11-23 16:31 ` [PATCH 11/11] ACPI / scan: Create platform device for CLSA0100 ACPI nodes Lucas Tanure
2021-11-23 17:05 ` Hans de Goede
2021-11-23 17:11 ` Lucas tanure
2021-11-23 18:35 ` Hans de Goede
2021-11-23 23:01 ` Andy Shevchenko
2021-11-24 17:36 ` (subset) [PATCH v3 00/11] Add support for Legion 7 16ACHg6 laptop Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211123163149.1530535-2-tanureal@opensource.cirrus.com \
--to=tanureal@opensource.cirrus.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=cam@neo-zeon.de \
--cc=chris.chiu@canonical.com \
--cc=david.rhodes@cirrus.com \
--cc=eliadevito@gmail.com \
--cc=hdegoede@redhat.com \
--cc=hui.wang@canonical.com \
--cc=jack.yu@realtek.com \
--cc=jeremy.szu@canonical.com \
--cc=kailang@realtek.com \
--cc=lars@metafoo.de \
--cc=lenb@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sami@loone.fi \
--cc=shumingf@realtek.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
--cc=vitalyr@opensource.cirrus.com \
--cc=wse@tuxedocomputers.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®