* [PATCH 0/2] Add master clock handling for nau8824
@ 2024-06-26 14:22 Maxim Kochetkov
0 siblings, 0 replies; 8+ messages in thread
From: Maxim Kochetkov @ 2024-06-26 14:22 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, John Hsu
Cc: Maxim Kochetkov, linux-sound, devicetree
nau8824 has external MCLK pin. So add enable/disable external clock
management.
Maxim Kochetkov (2):
ASoC: codecs: nau8824: Add master clock handling
ASoC: dt-bindings: nau8824: Add master clock handling
.../bindings/sound/nuvoton,nau8824.yaml | 8 +++++++
sound/soc/codecs/nau8824.c | 21 +++++++++++++++++--
sound/soc/codecs/nau8824.h | 1 +
3 files changed, 28 insertions(+), 2 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/2] Add master clock handling for nau8824
@ 2024-06-26 14:59 Maxim Kochetkov
2024-06-26 14:59 ` [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling Maxim Kochetkov
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Maxim Kochetkov @ 2024-06-26 14:59 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, John Hsu
Cc: Maxim Kochetkov, linux-sound, devicetree, alsa-devel
nau8824 has external MCLK pin. So add enable/disable external clock
management.
Maxim Kochetkov (2):
ASoC: codecs: nau8824: Add master clock handling
ASoC: dt-bindings: nau8824: Add master clock handling
.../bindings/sound/nuvoton,nau8824.yaml | 8 +++++++
sound/soc/codecs/nau8824.c | 21 +++++++++++++++++--
sound/soc/codecs/nau8824.h | 1 +
3 files changed, 28 insertions(+), 2 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling
2024-06-26 14:59 [PATCH 0/2] Add master clock handling for nau8824 Maxim Kochetkov
@ 2024-06-26 14:59 ` Maxim Kochetkov
2024-06-27 0:44 ` AS50 KCHSU0
2024-06-26 14:59 ` [PATCH 2/2] ASoC: dt-bindings: " Maxim Kochetkov
2024-06-26 15:32 ` [PATCH 0/2] Add master clock handling for nau8824 Mark Brown
2 siblings, 1 reply; 8+ messages in thread
From: Maxim Kochetkov @ 2024-06-26 14:59 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, John Hsu
Cc: Maxim Kochetkov, linux-sound, devicetree, alsa-devel
Use master clock "mclk" if provided through device tree.
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
---
sound/soc/codecs/nau8824.c | 21 +++++++++++++++++++--
sound/soc/codecs/nau8824.h | 1 +
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
index f92b95b21cae..c66b0a5a7448 100644
--- a/sound/soc/codecs/nau8824.c
+++ b/sound/soc/codecs/nau8824.c
@@ -520,8 +520,15 @@ static int system_clock_control(struct snd_soc_dapm_widget *w,
} else {
nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0);
}
+
+ if (!IS_ERR(nau8824->mclk))
+ clk_disable_unprepare(nau8824->mclk);
} else {
dev_dbg(nau8824->dev, "system clock control : POWER ON\n");
+
+ if (!IS_ERR(nau8824->mclk))
+ clk_prepare_enable(nau8824->mclk);
+
/* Check the clock source setting is proper or not
* no matter the source is from FLL or MCLK.
*/
@@ -563,16 +570,22 @@ static int dmic_clock_control(struct snd_soc_dapm_widget *w,
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
int src;
+ unsigned int freq;
+
+ if (!IS_ERR(nau8824->mclk))
+ freq = clk_get_rate(nau8824->mclk);
+ else
+ freq = nau8824->fs * 256;
/* The DMIC clock is gotten from system clock (256fs) divided by
* DMIC_SRC (1, 2, 4, 8, 16, 32). The clock has to be equal or
* less than 3.072 MHz.
*/
for (src = 0; src < 5; src++) {
- if ((0x1 << (8 - src)) * nau8824->fs <= DMIC_CLK)
+ if (freq / (0x1 << src) <= DMIC_CLK)
break;
}
- dev_dbg(nau8824->dev, "dmic src %d for mclk %d\n", src, nau8824->fs * 256);
+ dev_dbg(nau8824->dev, "dmic src %d for mclk %d\n", src, freq);
regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER,
NAU8824_CLK_DMIC_SRC_MASK, (src << NAU8824_CLK_DMIC_SRC_SFT));
@@ -1510,6 +1523,10 @@ static int nau8824_component_probe(struct snd_soc_component *component)
nau8824->dapm = dapm;
+ nau8824->mclk = devm_clk_get(component->dev, "mclk");
+ if (PTR_ERR(nau8824->mclk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
return 0;
}
diff --git a/sound/soc/codecs/nau8824.h b/sound/soc/codecs/nau8824.h
index 5fcfc43dfc85..d8e19515133c 100644
--- a/sound/soc/codecs/nau8824.h
+++ b/sound/soc/codecs/nau8824.h
@@ -434,6 +434,7 @@ struct nau8824 {
struct snd_soc_jack *jack;
struct work_struct jdet_work;
struct semaphore jd_sem;
+ struct clk *mclk;
int fs;
int irq;
int resume_lock;
--
2.45.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] ASoC: dt-bindings: nau8824: Add master clock handling
2024-06-26 14:59 [PATCH 0/2] Add master clock handling for nau8824 Maxim Kochetkov
2024-06-26 14:59 ` [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling Maxim Kochetkov
@ 2024-06-26 14:59 ` Maxim Kochetkov
2024-06-26 15:32 ` [PATCH 0/2] Add master clock handling for nau8824 Mark Brown
2 siblings, 0 replies; 8+ messages in thread
From: Maxim Kochetkov @ 2024-06-26 14:59 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, John Hsu
Cc: Maxim Kochetkov, linux-sound, devicetree, alsa-devel
Use master clock "mclk" if provided through device tree.
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
---
.../devicetree/bindings/sound/nuvoton,nau8824.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/nuvoton,nau8824.yaml b/Documentation/devicetree/bindings/sound/nuvoton,nau8824.yaml
index 3dbf438c3841..232dc16a94a3 100644
--- a/Documentation/devicetree/bindings/sound/nuvoton,nau8824.yaml
+++ b/Documentation/devicetree/bindings/sound/nuvoton,nau8824.yaml
@@ -23,6 +23,14 @@ properties:
'#sound-dai-cells':
const: 0
+ clocks:
+ items:
+ - description: The phandle of the master clock to the CODEC
+
+ clock-names:
+ items:
+ - const: mclk
+
interrupts:
maxItems: 1
--
2.45.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Add master clock handling for nau8824
2024-06-26 14:59 [PATCH 0/2] Add master clock handling for nau8824 Maxim Kochetkov
2024-06-26 14:59 ` [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling Maxim Kochetkov
2024-06-26 14:59 ` [PATCH 2/2] ASoC: dt-bindings: " Maxim Kochetkov
@ 2024-06-26 15:32 ` Mark Brown
2024-06-26 16:01 ` Maxim Kochetkov
2 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2024-06-26 15:32 UTC (permalink / raw)
To: Maxim Kochetkov
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, John Hsu, linux-sound,
devicetree, alsa-devel
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
On Wed, Jun 26, 2024 at 05:59:28PM +0300, Maxim Kochetkov wrote:
> nau8824 has external MCLK pin. So add enable/disable external clock
> management.
You appear to have sent two copies of this series - what's going on
there?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] Add master clock handling for nau8824
2024-06-26 15:32 ` [PATCH 0/2] Add master clock handling for nau8824 Mark Brown
@ 2024-06-26 16:01 ` Maxim Kochetkov
0 siblings, 0 replies; 8+ messages in thread
From: Maxim Kochetkov @ 2024-06-26 16:01 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, John Hsu, linux-sound,
devicetree, alsa-devel
26.06.2024 18:32, Mark Brown wrote:
> On Wed, Jun 26, 2024 at 05:59:28PM +0300, Maxim Kochetkov wrote:
>> nau8824 has external MCLK pin. So add enable/disable external clock
>> management.
>
> You appear to have sent two copies of this series - what's going on
> there?
So sorry about that. It was miss click.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling
2024-06-26 14:59 ` [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling Maxim Kochetkov
@ 2024-06-27 0:44 ` AS50 KCHSU0
2024-06-27 6:15 ` Maxim Kochetkov
0 siblings, 1 reply; 8+ messages in thread
From: AS50 KCHSU0 @ 2024-06-27 0:44 UTC (permalink / raw)
To: Maxim Kochetkov, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, David Lin, Seven Lee,
Wallace Lin
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
alsa-devel@alsa-project.org
On 6/26/2024 10:59 PM, Maxim Kochetkov wrote:
> CAUTION - External Email: Do not click links or open attachments unless you acknowledge the sender and content.
>
>
> Use master clock "mclk" if provided through device tree.
>
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> ---
> sound/soc/codecs/nau8824.c | 21 +++++++++++++++++++--
> sound/soc/codecs/nau8824.h | 1 +
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
> index f92b95b21cae..c66b0a5a7448 100644
> --- a/sound/soc/codecs/nau8824.c
> +++ b/sound/soc/codecs/nau8824.c
> @@ -520,8 +520,15 @@ static int system_clock_control(struct snd_soc_dapm_widget *w,
> } else {
> nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0);
> }
> +
> + if (!IS_ERR(nau8824->mclk))
> + clk_disable_unprepare(nau8824->mclk);
> } else {
> dev_dbg(nau8824->dev, "system clock control : POWER ON\n");
> +
> + if (!IS_ERR(nau8824->mclk))
> + clk_prepare_enable(nau8824->mclk);
> +
> /* Check the clock source setting is proper or not
> * no matter the source is from FLL or MCLK.
> */
> @@ -563,16 +570,22 @@ static int dmic_clock_control(struct snd_soc_dapm_widget *w,
> struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
> struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
> int src;
> + unsigned int freq;
> +
> + if (!IS_ERR(nau8824->mclk))
> + freq = clk_get_rate(nau8824->mclk);
> + else
> + freq = nau8824->fs * 256;
>
> /* The DMIC clock is gotten from system clock (256fs) divided by
> * DMIC_SRC (1, 2, 4, 8, 16, 32). The clock has to be equal or
> * less than 3.072 MHz.
> */
> for (src = 0; src < 5; src++) {
> - if ((0x1 << (8 - src)) * nau8824->fs <= DMIC_CLK)
> + if (freq / (0x1 << src) <= DMIC_CLK)
> break;
> }
> - dev_dbg(nau8824->dev, "dmic src %d for mclk %d\n", src, nau8824->fs * 256);
> + dev_dbg(nau8824->dev, "dmic src %d for mclk %d\n", src, freq);
> regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER,
> NAU8824_CLK_DMIC_SRC_MASK, (src << NAU8824_CLK_DMIC_SRC_SFT));
>
> @@ -1510,6 +1523,10 @@ static int nau8824_component_probe(struct snd_soc_component *component)
>
> nau8824->dapm = dapm;
>
> + nau8824->mclk = devm_clk_get(component->dev, "mclk");
> + if (PTR_ERR(nau8824->mclk) == -EPROBE_DEFER)
> + return -EPROBE_DEFER;
> +
> return 0;
> }
Would it be better to move the retrieval of mclk property to the
function nau8824_read_device_properties? All properties can be read
together.
> diff --git a/sound/soc/codecs/nau8824.h b/sound/soc/codecs/nau8824.h
> index 5fcfc43dfc85..d8e19515133c 100644
> --- a/sound/soc/codecs/nau8824.h
> +++ b/sound/soc/codecs/nau8824.h
> @@ -434,6 +434,7 @@ struct nau8824 {
> struct snd_soc_jack *jack;
> struct work_struct jdet_work;
> struct semaphore jd_sem;
> + struct clk *mclk;
> int fs;
> int irq;
> int resume_lock;
> --
> 2.45.2
>
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling
2024-06-27 0:44 ` AS50 KCHSU0
@ 2024-06-27 6:15 ` Maxim Kochetkov
0 siblings, 0 replies; 8+ messages in thread
From: Maxim Kochetkov @ 2024-06-27 6:15 UTC (permalink / raw)
To: AS50 KCHSU0, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Uwe Kleine-König, Andy Shevchenko, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, David Lin, Seven Lee,
Wallace Lin
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
alsa-devel@alsa-project.org
27.06.2024 03:44, AS50 KCHSU0 wrote:
>>
>> + nau8824->mclk = devm_clk_get(component->dev, "mclk");
>> + if (PTR_ERR(nau8824->mclk) == -EPROBE_DEFER)
>> + return -EPROBE_DEFER;
>> +
>> return 0;
>> }
>
> Would it be better to move the retrieval of mclk property to the
> function nau8824_read_device_properties? All properties can be read
> together.
Sure. I will do it in V2.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-06-27 6:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26 14:59 [PATCH 0/2] Add master clock handling for nau8824 Maxim Kochetkov
2024-06-26 14:59 ` [PATCH 1/2] ASoC: codecs: nau8824: Add master clock handling Maxim Kochetkov
2024-06-27 0:44 ` AS50 KCHSU0
2024-06-27 6:15 ` Maxim Kochetkov
2024-06-26 14:59 ` [PATCH 2/2] ASoC: dt-bindings: " Maxim Kochetkov
2024-06-26 15:32 ` [PATCH 0/2] Add master clock handling for nau8824 Mark Brown
2024-06-26 16:01 ` Maxim Kochetkov
-- strict thread matches above, loose matches on Subject: below --
2024-06-26 14:22 Maxim Kochetkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).