Add support for Rpi4b + Cirrus Lochnagar2 and CS47L15
Subsystems (7)
PATCH v2 5/7 ASoC: madera: Allow codecs to be selected from kernel config
In reply to Richard FitzgeraldThe codec Kconfig options were hidden and intended to be selected by the machine driver that requires them. But that means having either a dedicated machine driver or building all codecs.
This patch makes the Kconfig options visible so that they can be selected independently of the machine driver, allowing the codec to be used with simple-card and other machine drivers that are not hardcoded to use a fixed set of codecs.
--- sound/soc/codecs/Kconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/Kconfig +5 -5
@@ -658,23 +658,23 @@ config SND_SOC_CS4349 depends on I2C config SND_SOC_CS47L15 - tristate + tristate "Cirrus Logic CS47L15 CODEC" config SND_SOC_CS47L24 tristate "Cirrus Logic CS47L24 CODEC" depends on MFD_CS47L24 config SND_SOC_CS47L35 - tristate + tristate "Cirrus Logic CS47L35 CODEC" config SND_SOC_CS47L85 - tristate + tristate "Cirrus Logic CS47L85 CODEC" config SND_SOC_CS47L90 - tristate + tristate "Cirrus Logic CS47L90 CODEC" config SND_SOC_CS47L92 - tristate + tristate "Cirrus Logic CS47L92 CODEC" # Cirrus Logic Quad-Channel ADC config SND_SOC_CS53L30
Signature · 1 line
2.20.1
PATCH v2 4/7 ASoC: arizona: Allow codecs to be selected from kernel config
In reply to Richard FitzgeraldThe codec Kconfig options were hidden and intended to be selected by the machine driver that requires them. But that means having either a dedicated machine driver or building all codecs.
This patch makes the Kconfig options visible so that they can be selected independently of the machine driver, allowing the codec to be used with simple-card and other machine drivers that are not hardcoded to use a fixed set of codecs.
--- sound/soc/codecs/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/Kconfig +4 -4
@@ -661,7 +661,7 @@ config SND_SOC_CS47L15 tristate config SND_SOC_CS47L24 - tristate + tristate "Cirrus Logic CS47L24 CODEC" depends on MFD_CS47L24 config SND_SOC_CS47L35
@@ -1484,11 +1484,11 @@ config SND_SOC_WM5100 depends on I2C config SND_SOC_WM5102 - tristate + tristate "Cirrus Logic WM5102 CODEC" depends on MFD_WM5102 config SND_SOC_WM5110 - tristate + tristate "Cirrus Logic WM5110 CODEC" depends on MFD_WM5110 config SND_SOC_WM8350
@@ -1657,7 +1657,7 @@ config SND_SOC_WM8997 depends on MFD_WM8997 config SND_SOC_WM8998 - tristate + tristate "Cirrus Logic WM8998 CODEC" depends on MFD_WM8998 config SND_SOC_WM9081
Signature · 1 line
2.20.1
v2 cover Add support for Rpi4b + Cirrus Lochnagar2 and CS47L15
This set of patches provides support for using the Raspberry Pi 4b with a Cirrus Logic Lochnagar 2 audio development platform plus Cirrus Logic CS47L15 codec.
Patches are needed to audio-graph-card to enable support for setting the component sysclks and plls. The codec sysclks and plls cannot be placed under the clock framwork because they are I2C/SPI-connected peripherals and access to the registers would cause a nested get of the I2C/SPI bus clock. The clock framework does not support this and it would result in a deadlock.
Richard Fitzgerald (7):
of: base: Add of_count_phandle_with_fixed_args()
ASoC: audio-graph-card: Add plls and sysclks DT bindings
ASoC: audio-graph-card: Support setting component plls and sysclks
ASoC: arizona: Allow codecs to be selected from kernel config
ASoC: madera: Allow codecs to be selected from kernel config
ARM: dts: Add dts for RPi4b + Cirrus Logic Lochnagar2 + CS47L15
MAINTAINERS: Add dts for Cirrus Logic Lochnagar on RPi4
.../bindings/sound/audio-graph-card.txt | 44 ++++ MAINTAINERS | 1 + arch/arm/boot/dts/Makefile | 1 + ...bcm2711-rpi4b-cirrus-lochnagar-cs47l15.dts | 166 +++++++++++++++ .../dts/bcm2711-rpi4b-cirrus-lochnagar.dtsi | 201 ++++++++++++++++++ drivers/of/base.c | 73 +++++-- include/linux/of.h | 9 + include/sound/simple_card_utils.h | 24 +++ sound/soc/codecs/Kconfig | 18 +- sound/soc/generic/audio-graph-card.c | 16 +- sound/soc/generic/simple-card-utils.c | 184 ++++++++++++++++ 11 files changed, 703 insertions(+), 34 deletions(-) create mode 100644 arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar-cs47l15.dts create mode 100644 arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar.dtsi
Signature · 1 line
2.20.1
PATCH v2 2/7 ASoC: audio-graph-card: Add plls and sysclks DT bindings
This adds the two new properties 'plls' and 'sysclks' to the dt bindings. These add the ability to set values that will be
passed to snd_soc_component_set_sysclk() and snd_soc_component_set_pll().
--- .../bindings/sound/audio-graph-card.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+)
Documentation/devicetree/bindings/sound/audio-graph-card.txt +44 -0
@@ -32,6 +32,19 @@ Required properties: Optional properties: - pa-gpios: GPIO used to control external amplifier. +- plls: A list of component pll settings that will be applied with + snd_soc_component_set_pll. Each entry is a phandle to the node of the + codec or cpu component, followed by the four arguments id, source, + frequency_in, frequency_out. Multiple entries can have the same phandle + so that several plls can be set in the same component. + +- sysclks: A list of component sysclk settings that will be applied with + snd_soc_component_set_sysclk. Each entry is a phandle to the node of + the codec or cpu component, followed by the four arguments id, source, + frequency, direction. Direction is 0 if the clock is an input, 1 if it + is an output. Multiple entries can have the same phandle so that several + clocks can be set in the same component. + ----------------------- Example: Single DAI case -----------------------
@@ -335,3 +348,34 @@ Example: Multi DAI with DPCM }; }; }; + +----------------------- +Example: Set component sysclks and PLLs +----------------------- + + sound { + compatible = "audio-graph-card"; + + sysclks = < + &cs47l15 1 4 98304000 0 + &cs47l15 8 4 147456000 0 + >; + plls = < + &cs47l15 1 0 24576000 98304000 + >; + + dais = <&cpu_i2s_port>; + }; + + cs47l15: codec@0 { + ... + ports { + #address-cells = <1>; + #size-cells = <0>; + cs47l15_aif1_port: port@0 { + reg = <0>; + cs47l15_aif1: endpoint { + remote-endpoint = <&cpu_i2s_endpoint>; + }; + }; + };
Signature · 1 line
2.20.1
PATCH v2 1/7 of: base: Add of_count_phandle_with_fixed_args()
In reply to Richard FitzgeraldAdd an equivalent of of_count_phandle_with_args() for fixed argument sets, to pair with of_parse_phandle_with_fixed_args().
The existing of_count_phandle_with_args() is modified to be a private function that handles both cases and the public functions are trivial wrappers round that.
--- drivers/of/base.c | 73 +++++++++++++++++++++++++++++++--------------- include/linux/of.h | 9 ++++++ 2 files changed, 59 insertions(+), 23 deletions(-)
drivers/of/base.c +50 -23
@@ -1720,34 +1720,22 @@ int of_parse_phandle_with_fixed_args(const struct device_node *np, }EXPORT_SYMBOL (of_parse_phandle_with_fixed_args); -/** -* of_count_phandle_with_args() - Find the number of phandles references in a property -* @np: pointer to a device tree node containing a list -* @list_name: property name that contains a list -* @cells_name: property name that specifies phandles' arguments count -* -* Returns the number of phandle + argument tuples within a property. It -* is a typical pattern to encode a list of phandle and variable -* arguments into a single property. The number of arguments is encoded -* by a property in the phandle-target node. For example, a gpios -* property would contain a list of GPIO specifies consisting of a -* phandle and 1 or more arguments. The number of arguments are -* determined by the #gpio-cells property in the node pointed to by the -* phandle. -*/ -int of_count_phandle_with_args (const struct device_node *np,const char *list_name, -const char *cells_name) +static int __of_count_phandle_with_args (const struct device_node *np, +const char *list_name, +const char *cells_name, +int cells_count) {struct of_phandle_iterator it;int rc, cur_index =0 ;/* -* If cells_name is NULL we assume a cell count of 0. This makes -* counting the phandles trivial as each 32bit word in the list is a -* phandle and no arguments are to consider. So we don't iterate through -* the list but just use the length to determine the phandle count. +* If cells_count < 0 and cells_name is NULL we assume a cell count +* of 0. A zero cell count makes counting the phandles trivial as each +* 32bit word in the list is a phandle and no arguments are to consider. +* So we don't iterate through the list but just use the length to +* determine the phandle count. */ -if (!cells_name) { +if ((cells_count <0 && !cells_name) || cells_count ==0 ) {const __be32 *list;int size;
@@ -1758,7 +1746,7 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_nareturn size /sizeof (*list); } - rc =of_phandle_iterator_init (&it, np, list_name, cells_name,-1 ); + rc =of_phandle_iterator_init (&it, np, list_name, cells_name, cells_count);if (rc)return rc;
@@ -1770,8 +1758,47 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_nareturn cur_index; } + +/** +* of_count_phandle_with_args() - Find the number of phandles references in a property +* @np: pointer to a device tree node containing a list +* @list_name: property name that contains a list +* @cells_name: property name that specifies phandles' arguments count +* +* Returns the number of phandle + argument tuples within a property. It +* is a typical pattern to encode a list of phandle and variable +* arguments into a single property. The number of arguments is encoded +* by a property in the phandle-target node. For example, a gpios +* property would contain a list of GPIO specifies consisting of a +* phandle and 1 or more arguments. The number of arguments are +* determined by the #gpio-cells property in the node pointed to by the +* phandle. +*/ +int of_count_phandle_with_args (const struct device_node *np,const char *list_name, +const char *cells_name) +{ +return __of_count_phandle_with_args (np, list_name, cells_name,-1 ); +}EXPORT_SYMBOL (of_count_phandle_with_args); +/** +* of_count_phandle_with_fixed_args() - Find the number of phandles references in a property +* @np: pointer to a device tree node containing a list +* @list_name: property name that contains a list +* @cell_count: number of argument cells following the phandle +* +* Returns the number of phandle + argument tuples within a property. It +* is a typical pattern to encode a list of phandle and variable +* arguments into a single property. +*/ +int of_count_phandle_with_fixed_args (const struct device_node *np, +const char *list_name, +int cells_count) +{ +return __of_count_phandle_with_args (np, list_name,NULL , cells_count); +} +EXPORT_SYMBOL (of_count_phandle_with_fixed_args); +/** * __of_add_property - Add a property to a node without lock operations */
include/linux/of.h +9 -0
@@ -377,6 +377,8 @@ extern int of_parse_phandle_with_fixed_args(const struct device_node *np, struct of_phandle_args *out_args);extern int of_count_phandle_with_args (const struct device_node *np,const char *list_name,const char *cells_name); +extern int of_count_phandle_with_fixed_args (const struct device_node *np, +const char *list_name,int cells_count);/* phandle iterator functions */ extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
@@ -886,6 +888,13 @@ static inline int of_count_phandle_with_args(struct device_node *np,return -ENOSYS ; } +static inline int of_count_phandle_with_fixed_args (const struct device_node *np, +const char *list_name, +int cells_count) +{ +return -ENOSYS ; +} + static inline int of_phandle_iterator_init(struct of_phandle_iterator *it, const struct device_node *np, const char *list_name,
Signature · 1 line
2.20.1
PATCH v2 6/7 ARM: dts: Add dts for RPi4b + Cirrus Logic Lochnagar2 + CS47L15
In reply to Richard FitzgeraldThis adds a devicetree configuration for Raspberry Pi 4b connected to Cirrus Logic Lochnagar 2 audio development board and CS47L15 codec.
The common (codec-independent) Lochnagar 2 configuration is separated into a dtsi to simplify re-using it for other codecs.
--- arch/arm/boot/dts/Makefile | 1 + ...bcm2711-rpi4b-cirrus-lochnagar-cs47l15.dts | 166 +++++++++++++++ .../dts/bcm2711-rpi4b-cirrus-lochnagar.dtsi | 201 ++++++++++++++++++ 3 files changed, 368 insertions(+) create mode 100644 arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar-cs47l15.dts create mode 100644 arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar.dtsi
arch/arm/boot/dts/Makefile +1 -0
@@ -92,6 +92,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += \ bcm2837-rpi-3-b-plus.dtb \ bcm2837-rpi-cm3-io3.dtb \ bcm2711-rpi-4-b.dtb \ + bcm2711-rpi4b-cirrus-lochnagar-cs47l15.dtb \ bcm2835-rpi-zero.dtb \ bcm2835-rpi-zero-w.dtb dtb-$(CONFIG_ARCH_BCM_5301X) += \
arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar-cs47l15.dts new file +166 -0
166 lines not on this page · raw message
arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar.dtsi new file +201 -0
201 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 3/7 ASoC: audio-graph-card: Support setting component plls and sysclks
In reply to Richard FitzgeraldSome codecs need plls and/or sysclks to be configured using the snd_soc_component_set_[sysclk|pll] functions. These drivers cannot necessarily be converted to use the clock framework. If the codec is on a I2C/SPI bus, a nested clk_get would be needed to enable the bus clock. But the clock framework does not support nested operations and this would deadlock. So it isn't possible to implement I2C/SPI connected pll/clock hardware through the clock framework.
This patch adds new dt properties that list phandles of components with the pll/sysclk settings to be applied. Multiple settings can be given for the same phandle to allow for components with multiple clocks and plls. The plls and sysclks are enabled when the card bias level moves to STANDBY and disabled when it moves to OFF.
The implementation does not attempt to handle specifying complex clock ordering interdependencies between components. The plls and sysclks are applied to a component as it is passed to the card set_bias_level/ set_bias_level_post callbacks. It follows from this that the order components are configured is the order that they are passed to those callbacks.
--- include/sound/simple_card_utils.h | 24 ++++ sound/soc/generic/audio-graph-card.c | 16 ++- sound/soc/generic/simple-card-utils.c | 184 ++++++++++++++++++++++++++ 3 files changed, 222 insertions(+), 2 deletions(-)
include/sound/simple_card_utils.h +24 -0
@@ -38,6 +38,15 @@ struct asoc_simple_jack {struct snd_soc_jack_gpio gpio; }; +struct asoc_simple_sysclk_pll { +struct device_node *node; +int id; +int source; +unsigned int freq_in; +unsigned int freq_out; +int dir; +}; + struct asoc_simple_priv { struct snd_soc_card snd_card; struct simple_dai_props {
@@ -56,6 +65,11 @@ struct asoc_simple_priv {struct asoc_simple_dai *dais;struct snd_soc_codec_conf *codec_conf;struct gpio_desc *pa_gpio; + +struct asoc_simple_sysclk_pll *sysclks; +int num_sysclks; +struct asoc_simple_sysclk_pll *plls; +int num_plls; };#define simple_priv_to_card (priv) (&(priv)->snd_card)#define simple_priv_to_props (priv, i) ((priv)->dai_props + (i))
@@ -94,6 +108,14 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream);int asoc_simple_hw_params (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params);int asoc_simple_dai_init (struct snd_soc_pcm_runtime *rtd); + +int asoc_simple_set_bias_level (struct snd_soc_card *card, +struct snd_soc_dapm_context *dapm, +enum snd_soc_bias_level level); +int asoc_simple_set_bias_level_post (struct snd_soc_card *card, +struct snd_soc_dapm_context *dapm, +enum snd_soc_bias_level level); +int asoc_simple_be_hw_params_fixup (struct snd_soc_pcm_runtime *rtd,struct snd_pcm_hw_params *params);
@@ -128,6 +150,8 @@ int asoc_simple_parse_widgets(struct snd_soc_card *card, char *prefix);int asoc_simple_parse_pin_switches (struct snd_soc_card *card,char *prefix); +int asoc_simple_parse_sysclks (struct asoc_simple_priv *priv,char *prefix); +int asoc_simple_parse_plls (struct asoc_simple_priv *priv,char *prefix); int asoc_simple_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack,
sound/soc/generic/audio-graph-card.c +14 -2
@@ -509,6 +509,14 @@ static int graph_parse_of(struct asoc_simple_priv *priv)return ret; } + ret =asoc_simple_parse_sysclks (priv,NULL ); +if (ret <0 ) +return ret; + + ret =asoc_simple_parse_plls (priv,NULL ); +if (ret <0 ) +return ret; +return asoc_simple_parse_card_name (card,NULL ); }
@@ -642,6 +650,7 @@ static int graph_probe(struct platform_device *pdev) card->dapm_widgets = graph_dapm_widgets; card->num_dapm_widgets =ARRAY_SIZE (graph_dapm_widgets); card->probe = graph_card_probe; +snd_soc_card_set_drvdata (card, priv);memset (&li,0 ,sizeof (li));graph_get_dais_count (priv, &li);
@@ -666,10 +675,13 @@ static int graph_probe(struct platform_device *pdev) goto err; } -snd_soc_card_set_drvdata (card, priv); -asoc_simple_debug_info (priv); +if (priv->num_sysclks || priv->num_plls) { + card->set_bias_level = asoc_simple_set_bias_level; + card->set_bias_level_post = asoc_simple_set_bias_level_post; + } + ret =devm_snd_soc_register_card (dev, card);if (ret <0 ) goto err;
sound/soc/generic/simple-card-utils.c +184 -0
208 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 7/7 MAINTAINERS: Add dts for Cirrus Logic Lochnagar on RPi4
In reply to Richard FitzgeraldUpdate the Cirrus Logic driver maintainers to include the device tree files for using the Lochnagar with a Raspberry Pi 4.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -4193,6 +4193,7 @@ M: Charles Keepax <[email protected]> M: Richard Fitzgerald <[email protected]> L: [email protected] S: Supported +F: arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar* F: Documentation/devicetree/bindings/clock/cirrus,lochnagar.yaml F: Documentation/devicetree/bindings/hwmon/cirrus,lochnagar.yaml F: Documentation/devicetree/bindings/mfd/cirrus,lochnagar.yaml
Signature · 1 line
2.20.1
Re: [PATCH v2 1/7] of: base: Add of_count_phandle_with_fixed_args()
In reply to Richard FitzgeraldQuoted 7 lines · Richard Fitzgerald
Add an equivalent of
of_count_phandle_with_args()for fixed argument sets, to pair withof_parse_phandle_with_fixed_args().The existing
of_count_phandle_with_args()is modified to be a private function that handles both cases and the public functions are trivial wrappers round that.
Quoted 6 lines
Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/of/base.c | 73 +++++++++++++++++++++++++++++++--------------- include/linux/of.h | 9 ++++++ 2 files changed, 59 insertions(+), 23 deletions(-)
Rob Herring
maintainerRe: [PATCH v2 2/7] ASoC: audio-graph-card: Add plls and sysclks DT bindings
In reply to Richard FitzgeraldQuoted 3 lines · Richard Fitzgerald
This adds the two new properties 'plls' and 'sysclks' to the dt bindings. These add the ability to set values that will be
passed tosnd_soc_component_set_sysclk()andsnd_soc_component_set_pll().
I worry this looks like Linux implementation details leaking into the binding.
Quoted 11 lines
Signed-off-by Richard Fitzgerald <[email protected]>--- .../bindings/sound/audio-graph-card.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+)Documentation/devicetree/bindings/sound/audio-graph-card.txt +0
-0
Documentation/devicetree/bindings/sound/audio-graph-card.txt Required properties: · line 39
Quoted 8 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt +5
-0@@ -32,6 +32,19 @@ Required properties: Optional properties: - pa-gpios: GPIO used to control external amplifier. +- plls: A list of component pll settings that will be applied with + snd_soc_component_set_pll. Each entry is a phandle to the node of the + codec or cpu component, followed by the four arguments id, source, + frequency_in, frequency_out. Multiple entries can have the same phandle + so that several plls can be set in the same component.
Where do the values of id and source come from?
Documentation/devicetree/bindings/sound/audio-graph-card.txt Required properties: · line 46
Quoted 7 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt +7
-0+ +- sysclks: A list of component sysclk settings that will be applied with + snd_soc_component_set_sysclk. Each entry is a phandle to the node of + the codec or cpu component, followed by the four arguments id, source, + frequency, direction. Direction is 0 if the clock is an input, 1 if it + is an output. Multiple entries can have the same phandle so that several + clocks can be set in the same component.
Are these really common properties? They seem kind of Cirrus specific and perhaps should be located in the codec node(s).
Quoted 42 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt +32
-0+ ----------------------- Example: Single DAI case -----------------------@@ -335,3 +348,34 @@ Example: Multi DAI with DPCM }; }; }; + +----------------------- +Example: Set component sysclks and PLLs +----------------------- + + sound { + compatible = "audio-graph-card"; + + sysclks = < + &cs47l15 1 4 98304000 0 + &cs47l15 8 4 147456000 0 + >; + plls = < + &cs47l15 1 0 24576000 98304000 + >; + + dais = <&cpu_i2s_port>; + }; + + cs47l15: codec@0 { + ... + ports { + #address-cells = <1>; + #size-cells = <0>; + cs47l15_aif1_port: port@0 { + reg = <0>; + cs47l15_aif1: endpoint { + remote-endpoint = <&cpu_i2s_endpoint>; + }; + }; + };Signature · 1 line
2.20.1
Mark Brown
maintainerRe: [PATCH v2 2/7] ASoC: audio-graph-card: Add plls and sysclks DT bindings
Quoted 9 lines · Rob Herring
Documentation/devicetree/bindings/sound/audio-graph-card.txt Required properties: · line 39
Quoted 5 lines · Richard Fitzgerald
+- plls: A list of component pll settings that will be applied with
Documentation/devicetree/bindings/sound/audio-graph-card.txt +4
-0+ snd_soc_component_set_pll. Each entry is a phandle to the node of the + codec or cpu component, followed by the four arguments id, source, + frequency_in, frequency_out. Multiple entries can have the same phandle + so that several plls can be set in the same component.Where do the values of id and source come from?
The device bindings will need to define them.
Quoted 9 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt Required properties: · line 46
Quoted 6 lines
+- sysclks: A list of component sysclk settings that will be applied with
Documentation/devicetree/bindings/sound/audio-graph-card.txt +5
-0+ snd_soc_component_set_sysclk. Each entry is a phandle to the node of + the codec or cpu component, followed by the four arguments id, source, + frequency, direction. Direction is 0 if the clock is an input, 1 if it + is an output. Multiple entries can have the same phandle so that several + clocks can be set in the same component.Are these really common properties? They seem kind of Cirrus specific and perhaps should be located in the codec node(s).
It's very common for audio devices to have very flexible clocking, to the exetent this is Linux specific it's issues with the clock API not being able to handle clock controllers on buses that need clock control to access rather than conceptually.
Re: [PATCH v2 2/7] ASoC: audio-graph-card: Add plls and sysclks DT bindings
In reply to Rob HerringQuoted 8 lines · Rob Herring
Quoted 3 lines · Richard Fitzgerald
This adds the two new properties 'plls' and 'sysclks' to the dt bindings. These add the ability to set values that will be
passed tosnd_soc_component_set_sysclk()andsnd_soc_component_set_pll().I worry this looks like Linux implementation details leaking into the binding.
I guess what you mean is referring to a function to explain the cells. I thought it would simplify the description but it yes, it does mean that the binding is tied to details of the kernel APIs. I can rewrite this description to be explicit about the cells instead of being in terms of kernel APIs.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Richard Fitzgerald <[email protected]>--- .../bindings/sound/audio-graph-card.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+)Documentation/devicetree/bindings/sound/audio-graph-card.txt +0
-0@@ -32,6 +32,19 @@ Required properties: Optional properties: - pa-gpios: GPIO used to control external amplifier.
Quoted 8 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt Required properties: · line 39
Quoted 5 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt +5
-0+- plls: A list of component pll settings that will be applied with + snd_soc_component_set_pll. Each entry is a phandle to the node of the + codec or cpu component, followed by the four arguments id, source, + frequency_in, frequency_out. Multiple entries can have the same phandle + so that several plls can be set in the same component.Where do the values of id and source come from?
They are specific to each codec driver, and ultimately depend on the hardware inside the codec. Compare with for example GPIO numbers being specific to hardware. I didn't say that because the description refers to the underlying kernel API, but if I update to not be in terms of an API I'll also add some more info about the fields.
Quoted 11 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt Required properties: · line 46
Quoted 7 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt +7
-0+ +- sysclks: A list of component sysclk settings that will be applied with + snd_soc_component_set_sysclk. Each entry is a phandle to the node of + the codec or cpu component, followed by the four arguments id, source, + frequency, direction. Direction is 0 if the clock is an input, 1 if it + is an output. Multiple entries can have the same phandle so that several + clocks can be set in the same component.Are these really common properties? They seem kind of Cirrus specific and perhaps should be located in the codec node(s).
I'm not sure what about this description makes you think it is Cirrus specific. They are standard ALSA ASoC subsystem APIs. I can find them used in drivers for Analog Devices, Dialog, Realtek and others, and this binding could be used for an audio-graph-card driver using those codecs.
It is the ASoC machine driver (in this case audio-graph-card) that handles this stuff so makes sense for them to be in its node, not the codec driver. The ASoC structure is somewhat complex but in short the codec driver provides an implementation for setting the hardware registers but doesn't know about use-cases or other audio components, so can't decide clocking. The "machine driver" sits above all the audio drivers and has a view of the whole audio subsystem so can decide on use-cases and clocking.
Having said that, we wouldn't need to do this if the kernel clock framework could support clock controllers on I2C/SPI buses. But years have gone by and nobody has managed to fix that yet.
Quoted 42 lines
Quoted 42 lines
Documentation/devicetree/bindings/sound/audio-graph-card.txt +32
-0+ ----------------------- Example: Single DAI case -----------------------@@ -335,3 +348,34 @@ Example: Multi DAI with DPCM }; }; }; + +----------------------- +Example: Set component sysclks and PLLs +----------------------- + + sound { + compatible = "audio-graph-card"; + + sysclks = < + &cs47l15 1 4 98304000 0 + &cs47l15 8 4 147456000 0 + >; + plls = < + &cs47l15 1 0 24576000 98304000 + >; + + dais = <&cpu_i2s_port>; + }; + + cs47l15: codec@0 { + ... + ports { + #address-cells = <1>; + #size-cells = <0>; + cs47l15_aif1_port: port@0 { + reg = <0>; + cs47l15_aif1: endpoint { + remote-endpoint = <&cpu_i2s_endpoint>; + }; + }; + };Signature · 1 line
2.20.1