Add dts for Rpi4 + Cirrus Lochnagar and codecs
Subsystems (7)
cover Add dts for Rpi4 + Cirrus Lochnagar and codecs
This set of patches provides support for using the Cirrus Logic Lochnagar audio development platform plus Cirrus Logic Madera/Arizona codecs with the simple-card machine driver and a Raspberry Pi4. The ultimate aim is to provide the dts file but some updates are needed to the simple-card machine driver.
Patches are needed to simple-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: simple-card: Add plls and sysclks DT schema
ASoC: simple-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 Raspberry Pi 4 + Cirrus Logic Lochnagar2
MAINTAINERS: Add dts for Cirrus Logic Lochnagar on RPi4
.../bindings/sound/simple-card.yaml | 56 + MAINTAINERS | 1 + arch/arm/boot/dts/Makefile | 1 + .../dts/bcm2711-rpi4b-cirrus-lochnagar.dts | 1296 +++++++++++++++++ drivers/of/base.c | 42 + include/linux/of.h | 9 + include/sound/simple_card_utils.h | 24 + sound/soc/codecs/Kconfig | 18 +- sound/soc/generic/simple-card-utils.c | 184 +++ sound/soc/generic/simple-card.c | 14 +- 10 files changed, 1635 insertions(+), 10 deletions(-) create mode 100644 arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar.dts
Signature · 1 line
2.20.1
PATCH 1/7 of: base: Add of_count_phandle_with_fixed_args()
Add an equivalent of of_count_phandle_with_args() for fixed argument sets, to pair with of_parse_phandle_with_fixed_args().
--- drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 51 insertions(+)
drivers/of/base.c +42 -0
@@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na }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) +{ +struct of_phandle_iterator it; +int rc, cur_index =0 ; + +if (!cells_count) { +const __be32 *list; +int size; + + list =of_get_property (np, list_name, &size); +if (!list) +return -ENOENT ; + +return size /sizeof (*list); + } + + rc =of_phandle_iterator_init (&it, np, list_name,NULL , cells_count); +if (rc) +return rc; + +while ((rc =of_phandle_iterator_next (&it)) ==0 ) + cur_index +=1 ; + +if (rc != -ENOENT ) +return rc; + +return cur_index; +} +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
Re: [PATCH 1/7] of: base: Add of_count_phandle_with_fixed_args()
Quoted 22 lines · Richard Fitzgerald
Add an equivalent of
of_count_phandle_with_args()for fixed argument sets, to pair withof_parse_phandle_with_fixed_args().Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 51 insertions(+)drivers/of/base.c +4
-0@@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na }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
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1788
Quoted 10 lines
drivers/of/base.c +10
-0+* @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) +{
Looks to me like you can refactor of_count_phandle_with_args to handle both case and then make this and of_count_phandle_with_args simple wrapper functions.
Quoted 61 lines
drivers/of/base.c +28
-0+struct of_phandle_iterator it; +int rc, cur_index =0 ; + +if (!cells_count) { +const __be32 *list; +int size; + + list =of_get_property (np, list_name, &size); +if (!list) +return -ENOENT ; + +return size /sizeof (*list); + } + + rc =of_phandle_iterator_init (&it, np, list_name,NULL , cells_count); +if (rc) +return rc; + +while ((rc =of_phandle_iterator_next (&it)) ==0 ) + cur_index +=1 ; + +if (rc != -ENOENT ) +return rc; + +return cur_index; +} +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
-1@@ -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, --2.20.1
Re: [PATCH 1/7] of: base: Add of_count_phandle_with_fixed_args()
Quoted 30 lines · Rob Herring
Quoted 28 lines · Richard Fitzgerald
Add an equivalent of
of_count_phandle_with_args()for fixed argument sets, to pair withof_parse_phandle_with_fixed_args().Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 51 insertions(+)drivers/of/base.c +10
-0@@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na }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. +*/
Quoted 8 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1788
Quoted 4 lines
drivers/of/base.c +4
-0+int of_count_phandle_with_fixed_args (const struct device_node *np, +const char *list_name, +int cells_count) +{Looks to me like you can refactor
of_count_phandle_with_argsto handle both case and then make this andof_count_phandle_with_argssimple wrapper functions.
Although for just counting the number of phandles each with n arguments that a property contains, isn't that simply a case of dividing the property length by n + 1? The phandles themselves will be validated by any subsequent of_parse_phandle*() call anyway, so there doesn't seem much point in doing more work then necessary here.
Quoted 4 lines
Quoted 4 lines
drivers/of/base.c +4
-0+struct of_phandle_iterator it; +int rc, cur_index =0 ; + +if (!cells_count) {
Quoted 8 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1800
Quoted 8 lines
drivers/of/base.c +8
-0+const __be32 *list; +int size; + + list =of_get_property (np, list_name, &size); +if (!list) +return -ENOENT ; + +return size /sizeof (*list);
Case in point - if it's OK to do exactly that for n == 0, then clearly we're *aren't* fussed about validating anything, so the n > 0 code below is nothing more than a massively expensive way to check for a nonzero remainder :/
Robin.
Quoted 55 lines
Quoted 47 lines
drivers/of/base.c +16
-0+ } + + rc =of_phandle_iterator_init (&it, np, list_name,NULL , cells_count); +if (rc) +return rc; + +while ((rc =of_phandle_iterator_next (&it)) ==0 ) + cur_index +=1 ; + +if (rc != -ENOENT ) +return rc; + +return cur_index; +} +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
-1@@ -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, --Quoted 2 lines
2.20.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/7] of: base: Add of_count_phandle_with_fixed_args()
Quoted 43 lines · Robin Murphy
Quoted 33 lines · Rob Herring
Quoted 31 lines · Richard Fitzgerald
Add an equivalent of
of_count_phandle_with_args()for fixed argument sets, to pair withof_parse_phandle_with_fixed_args().Signed-off-by Richard Fitzgerald <[email protected]>---
drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++include/linux/of.h| 9 +++++++++2 files changed, 51 insertions(+)drivers/of/base.c +0
-0@@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct
device_node*np, const char*list_na
}
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.
+ */Quoted 8 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1788
Quoted 4 lines
drivers/of/base.c +4
-0+int of_count_phandle_with_fixed_args (const struct device_node *np, + const char *list_name, + int cells_count) +{Looks to me like you can refactor
of_count_phandle_with_argsto handle both case and then make this andof_count_phandle_with_argssimple wrapper functions.
Quoted 2 lines
Although for just counting the number of phandles each with n arguments that a property contains, isn't that simply a case of dividing the property length by n + 1? The phandles themselves will be validated by any subsequent of_parse_phandle*() call anyway, so there doesn't seem much point in doing more work then necessary here.
As I'm not a DT expert, I'm reluctant to change existing algorithms that could break everything just for the trivial case of adding a fixed arguments count. I have a re-worked patch as suggested by Rob that re-uses the existing counting function for both cases.
Quoted 78 lines
Quoted 4 lines
Quoted 4 lines
+ struct
of_phandle_iteratorit;
+ int rc,cur_index= 0;
+
+ if (!cells_count) {Quoted 8 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1800
Quoted 8 lines
+ const
__be32*list;
+ int size;drivers/of/base.c +6
-0+ + list = of_get_property(np, list_name, &size); + if (!list) + return -ENOENT; + + return size / sizeof(*list);Case in point - if it's OK to do exactly that for n == 0, then clearly we're *aren't* fussed about validating anything, so the n > 0 code below is nothing more than a massively expensive way to check for a nonzero remainder :/
Robin.
Quoted 61 lines
Quoted 49 lines
+ }
+
+ rc =of_phandle_iterator_init(&it, np, list_name, NULL, cells_count);
+ if (rc)
+ return rc;drivers/of/base.c +11
-0+ + while ((rc = of_phandle_iterator_next(&it)) == 0) + cur_index += 1; + + if (rc != -ENOENT) + return rc; + + return cur_index; +} +EXPORT_SYMBOL (of_count_phandle_with_fixed_args); +/**
*__of_add_property- Add a property to a node without lock operations */include/linux/of.h +2
-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(structof_phandle_iterator*it,include/linux/of.h +7
-0@@ -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; +} +Quoted 6 lines
static inline int of_phandle_iterator_init(struct
of_phandle_iterator*it, const structdevice_node*np, const char*list_name,Signature · 1 line
2.20.1_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/7] of: base: Add of_count_phandle_with_fixed_args()
In reply to Robin MurphyQuoted 56 lines · Robin Murphy
Quoted 30 lines · Rob Herring
Quoted 28 lines · Richard Fitzgerald
Add an equivalent of
of_count_phandle_with_args()for fixed argument sets, to pair withof_parse_phandle_with_fixed_args().Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 51 insertions(+)drivers/of/base.c +10
-0@@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na }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. +*/ Quoted 8 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1788
Quoted 4 lines
drivers/of/base.c +4
-0+int of_count_phandle_with_fixed_args (const struct device_node *np, +const char *list_name, +int cells_count) +{Looks to me like you can refactor
of_count_phandle_with_argsto handle both case and then make this andof_count_phandle_with_argssimple wrapper functions.Although for just counting the number of phandles each with n arguments that a property contains, isn't that simply a case of dividing the property length by n + 1? The phandles themselves will be validated by any subsequent of_parse_phandle*() call anyway, so there doesn't seem much point in doing more work then necessary here.
Quoted 9 lines
Quoted 9 lines
drivers/of/base.c +9
-0+struct of_phandle_iterator it; +int rc, cur_index =0 ; + +if (!cells_count) { +const __be32 *list; +int size; + + list =of_get_property (np, list_name, &size); +if (!list)
Quoted 8 lines
Quoted 3 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1800
Quoted 3 lines
drivers/of/base.c +3
-0+return -ENOENT ; + +return size /sizeof (*list);Case in point - if it's OK to do exactly that for n == 0, then clearly we're *aren't* fussed about validating anything, so the n > 0 code below is nothing more than a massively expensive way to check for a nonzero remainder :/
Indeed. We should just generalize this. It can still be refactored to shared code.
It's probably worthwhile to check for a remainder here IMO.
Rob
Re: [PATCH 1/7] of: base: Add of_count_phandle_with_fixed_args()
Quoted 66 lines · Rob Herring
Quoted 56 lines · Robin Murphy
Quoted 30 lines · Rob Herring
Quoted 28 lines · Richard Fitzgerald
Add an equivalent of
of_count_phandle_with_args()for fixed argument sets, to pair withof_parse_phandle_with_fixed_args().Signed-off-by Richard Fitzgerald <[email protected]>--- drivers/of/base.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 51 insertions(+)drivers/of/base.c +10
-0@@ -1772,6 +1772,48 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na }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. +*/ Quoted 8 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1788
Quoted 4 lines
drivers/of/base.c +4
-0+int of_count_phandle_with_fixed_args (const struct device_node *np, +const char *list_name, +int cells_count) +{Looks to me like you can refactor
of_count_phandle_with_argsto handle both case and then make this andof_count_phandle_with_argssimple wrapper functions.Although for just counting the number of phandles each with n arguments that a property contains, isn't that simply a case of dividing the property length by n + 1? The phandles themselves will be validated by any subsequent of_parse_phandle*() call anyway, so there doesn't seem much point in doing more work then necessary here.
Quoted 9 lines
Quoted 9 lines
drivers/of/base.c +9
-0+struct of_phandle_iterator it; +int rc, cur_index =0 ; + +if (!cells_count) { +const __be32 *list; +int size; + + list =of_get_property (np, list_name, &size); +if (!list)Quoted 8 lines
Quoted 3 lines
drivers/of/base.c int of_count_phandle_with_args(const struct device_node *np, const char *list_na · line 1800
Quoted 3 lines
drivers/of/base.c +3
-0+return -ENOENT ; + +return size /sizeof (*list);Case in point - if it's OK to do exactly that for n == 0, then clearly we're *aren't* fussed about validating anything, so the n > 0 code below is nothing more than a massively expensive way to check for a nonzero remainder :/
Quoted 5 lines
Indeed. We should just generalize this. It can still be refactored to shared code.
It's probably worthwhile to check for a remainder here IMO.
Ok, I looked at the implementation of of_phandle_iterator_next() and it is in fact simply incrementing by 'count' 32-bit words. So as Robin said the count_phandle_with_x_args()functions could simply divide the length by count+1.
However, may I suggest that should be done in a separate patch after my patch to add count_phandle_with_fixed_args()? That way, if replacing the iteration with the simple length divide causes any unforeseen problems the patch can just be reverted.
Quoted 2 lines
Rob
PATCH 2/7 ASoC: simple-card: Add plls and sysclks DT schema
In reply to Richard FitzgeraldThis adds the two new properties 'plls' and 'sysclks' to the dt bindings schema document. 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/simple-card.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+)
Documentation/devicetree/bindings/sound/simple-card.yaml +56 -0
@@ -92,6 +92,25 @@ definitions: description: the widget names for which pin switches must be created. $ref: /schemas/types.yaml#/definitions/string-array + plls: + description: | + 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. + $ref: /schemas/types.yaml#/definitions/phandle-array + + sysclks: + description: | + 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. + $ref: /schemas/types.yaml#/definitions/phandle-array + format: description: audio format. items:
@@ -192,6 +211,10 @@ patternProperties: $ref: "#/definitions/prefix" "^simple-audio-card,pin-switches$": $ref: "#/definitions/pin-switches" + "^simple-audio-card,plls$": + $ref: "#/definitions/plls" + "^simple-audio-card,sysclks$": + $ref: "#/definitions/sysclks" "^simple-audio-card,hp-det-gpio$": maxItems: 1 "^simple-audio-card,mic-det-gpio$":
@@ -489,3 +512,36 @@ examples: }; }; }; + +#-------------------- +# Codec with component PLL and SYSCLK settings +#-------------------- + - | + sound { + compatible = "simple-audio-card"; + + simple-audio-card,plls = < + &cs47l15 1 1 32768 98304000 + >; + + simple-audio-card,sysclks = < + &cs47l15 1 4 98304000 0 + &cs47l15 8 4 147456000 0 + >; + + simple-audio-card,format = "i2s"; + simple-audio-card,bitclock-master = <&cs47l15_codec_dai>; + simple-audio-card,frame-master = <&cs47l15_codec_dai>; + + simple-audio-card,cpu { + sound-dai = <&axi_i2s0 0>; + }; + + cs47l15_codec_dai: simple-audio-card,codec { + sound-dai = <&cs47l15 0>; + + /* Disable dai_set_sysclk() */ + system-clock-frequency = <0>; + mclk-fs = <0>; + }; + };
Signature · 1 line
2.20.1
PATCH 3/7 ASoC: simple-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 bia level moves to STANDBY and disabled when it moved to OFF.
As this is a _simple_ machine driver, the code 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/simple-card-utils.c | 184 ++++++++++++++++++++++++++ sound/soc/generic/simple-card.c | 14 +- 3 files changed, 221 insertions(+), 1 deletion(-)
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/simple-card-utils.c +184 -0
208 lines not on this page · raw message
sound/soc/generic/simple-card.c +13 -1
@@ -475,6 +475,14 @@ static int simple_parse_of(struct asoc_simple_priv *priv) ret =snd_soc_of_parse_aux_devs (card,PREFIX "aux-devs" ); + ret =asoc_simple_parse_sysclks (priv,PREFIX ); +if (ret <0 ) +return ret; + + ret =asoc_simple_parse_plls (priv,PREFIX ); +if (ret <0 ) +return ret; +return ret; }
@@ -604,6 +612,7 @@ static int asoc_simple_probe(struct platform_device *pdev) card->owner =THIS_MODULE ; card->dev = dev; card->probe = simple_soc_probe; +snd_soc_card_set_drvdata (card, priv);memset (&li,0 ,sizeof (li));simple_get_dais_count (priv, &li);
@@ -672,7 +681,10 @@ static int asoc_simple_probe(struct platform_device *pdev) sizeof(*dai_props->codec_dai)); } -snd_soc_card_set_drvdata (card, 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; + }asoc_simple_debug_info (priv);
Signature · 1 line
2.20.1
PATCH 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
kernel test robot
build botRe: [PATCH 4/7] ASoC: arizona: Allow codecs to be selected from kernel config
I love your patch! Perhaps something to improve:
Hi Richard,
I love your patch! Perhaps something to improve:
[auto build test WARNING on asoc/for-next]
[also build test WARNING on robh/for-next sound/for-next v5.9 next-20201013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Richard-Fitzgerald/Add-dts-for-Rpi4-Cirrus-Lochnagar-and-codecs/20201014-225648 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: xtensa-randconfig-s032-20201014 (attached as .config) compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-rc1-dirty
# https://github.com/0day-ci/linux/commit/7ddf8ce197a5426e13fe9422a3ed17f0b02a94df
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Richard-Fitzgerald/Add-dts-for-Rpi4-Cirrus-Lochnagar-and-codecs/20201014-225648 git checkout 7ddf8ce197a5426e13fe9422a3ed17f0b02a94df
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=xtensa
If you fix the issue, kindly add following tag as appropriate
"sparse warnings: (new ones prefixed by >>)"
>> sound/soc/codecs/wm5102.c:687:35: sparse: sparse: cast to restricted __be16
vim +687 sound/soc/codecs/wm5102.c
cc9e92431ee9c7f Charles Keepax 2014-06-06 677
cc9e92431ee9c7f Charles Keepax 2014-06-06 678 static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol,
cc9e92431ee9c7f Charles Keepax 2014-06-06 679 struct snd_ctl_elem_value *ucontrol)
cc9e92431ee9c7f Charles Keepax 2014-06-06 680 {
0fe1daa6663ae94 Kuninori Morimoto 2018-02-13 681 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0fe1daa6663ae94 Kuninori Morimoto 2018-02-13 682 struct arizona *arizona = dev_get_drvdata(component->dev->parent);
cc9e92431ee9c7f Charles Keepax 2014-06-06 683
d74bcaaeb668261 Lars-Peter Clausen 2014-11-09 684 mutex_lock(&arizona->dac_comp_lock);
cc9e92431ee9c7f Charles Keepax 2014-06-06 685 memcpy(&arizona->dac_comp_coeff, ucontrol->value.bytes.data,
cc9e92431ee9c7f Charles Keepax 2014-06-06 686 sizeof(arizona->dac_comp_coeff));
cc9e92431ee9c7f Charles Keepax 2014-06-06 @687 arizona->dac_comp_coeff = be16_to_cpu(arizona->dac_comp_coeff);
d74bcaaeb668261 Lars-Peter Clausen 2014-11-09 688 mutex_unlock(&arizona->dac_comp_lock);
cc9e92431ee9c7f Charles Keepax 2014-06-06 689
cc9e92431ee9c7f Charles Keepax 2014-06-06 690 return 0;
cc9e92431ee9c7f Charles Keepax 2014-06-06 691 }
cc9e92431ee9c7f Charles Keepax 2014-06-06 692 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 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 6/7 ARM: dts: Add dts for Raspberry Pi 4 + Cirrus Logic Lochnagar2
In reply to Richard FitzgeraldThis is based on the default bcm2711-rpi-4-b.dts.
Configurations are provided for Cirrus Logic codecs CS42L92, CS47L15, CS47L24, CS47L35, CS47L90 and WM8998.
For each codec there is a sound node and a codec device node and both default to disabled. Enable the pair for the codec in use.
--- arch/arm/boot/dts/Makefile | 1 + .../dts/bcm2711-rpi4b-cirrus-lochnagar.dts | 1296 +++++++++++++++++ 2 files changed, 1297 insertions(+) create mode 100644 arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar.dts
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.dtb \ bcm2835-rpi-zero.dtb \ bcm2835-rpi-zero-w.dtb dtb-$(CONFIG_ARCH_BCM_5301X) += \
arch/arm/boot/dts/bcm2711-rpi4b-cirrus-lochnagar.dts new file +1296 -0
1,296 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 6/7] ARM: dts: Add dts for Raspberry Pi 4 + Cirrus Logic Lochnagar2
Hi Richard,
your series is very welcome, upstream support for audio codecs on the RPi4 has always been lackluster.
Could you provide more information on the actual products? Are there custom made hats for the RPi4 or this wired into a generic development board.
Quoted 1 line · Richard Fitzgerald
This is based on the default
bcm2711-rpi-4-b.dts.
Note that you could've included bcm2711-rpi-4.dts (as if it was a .dtsi).
Quoted 8 lines
Configurations are provided for Cirrus Logic codecs CS42L92, CS47L15, CS47L24, CS47L35, CS47L90 and WM8998.
For each codec there is a sound node and a codec device node and both default to disabled. Enable the pair for the codec in use.
Signed-off-by Richard Fitzgerald <[email protected]>---
Sadly I don't think creating a new device tree is a good solution here. If we were to do so for every RPi hat/usage it'd become unmanageable very fast. There is a way to maintain this in the open nonetheless. I suggest you build a DT overlay and submit it to https://github.com/raspberrypi/linux, see 'arch/arm/boot/dts/overlays.' The Raspberry Pi engineers have a kernel branch that tracks of the latest kernel release, so once you get the rest of patches sorted out and they are included in a release it'll make sense to do so.
I can't tell for other distros, but opensuse packages overlays, so the effort will ultimately be useful to users.
Regards,
Nicolas
Re: [PATCH 6/7] ARM: dts: Add dts for Raspberry Pi 4 + Cirrus Logic Lochnagar2
Quoted 7 lines · Nicolas Saenz Julienne
Hi Richard,
your series is very welcome, upstream support for audio codecs on the RPi4 has always been lackluster.Could you provide more information on the actual products? Are there custom made hats for the RPi4 or this wired into a generic development board.
Info on the codecs is available from www.cirrus.com.
The Lochnagar audio development board is not a hat, but it can be wired over to the RPi GPIO header. It is not specific to the RPi.
Quoted 5 lines · Richard Fitzgerald
Quoted 1 line
This is based on the default
bcm2711-rpi-4-b.dts.Note that you could've included
bcm2711-rpi-4.dts(as if it was a .dtsi).
Ok, will change.
Quoted 6 lines
Quoted 6 lines
Configurations are provided for Cirrus Logic codecs CS42L92, CS47L15, CS47L24, CS47L35, CS47L90 and WM8998.
For each codec there is a sound node and a codec device node and both default to disabled. Enable the pair for the codec in use.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Richard Fitzgerald <[email protected]>---
Sadly I don't think creating a new device tree is a good solution here. If we were to do so for every RPi hat/usage it'd become unmanageable very fast. There is a way to maintain this in the open nonetheless. I suggest you build a DT overlay and submit it to https://github.com/raspberrypi/linux, see '
arch/arm/boot/dts/overlays.' The Raspberry Pi engineers have a kernel branch
We want something in mainline so that it can be used by people developing on mainline and taken as a starting point for configuring the codecs for other host platforms. The RPi is a convenient platform to use as the base because it is widely available and low-cost.
Quoted 10 lines
that tracks of the latest kernel release, so once you get the rest of patches sorted out and they are included in a release it'll make sense to do so.
I can't tell for other distros, but opensuse packages overlays, so the effort will ultimately be useful to users.
Regards,
Nicolas
Re: [PATCH 6/7] ARM: dts: Add dts for Raspberry Pi 4 + Cirrus Logic Lochnagar2
Quoted 10 lines · Richard Fitzgerald
Quoted 5 lines
Sadly I don't think creating a new device tree is a good solution here. If we were to do so for every RPi hat/usage it'd become unmanageable very fast. There is a way to maintain this in the open nonetheless. I suggest you build a DT overlay and submit it to https://github.com/raspberrypi/linux, see '
arch/arm/boot/dts/overlays.' The Raspberry Pi engineers have a kernel branchWe want something in mainline so that it can be used by people developing on mainline and taken as a starting point for configuring the codecs for other host platforms. The RPi is a convenient platform to use as the base because it is widely available and low-cost.
If what you want to convey is the proper way of configuring your specific device the way to go is writing a devicetree binding. See Documentation/devicetree. It's even possible to validate a given devicetree against the bindings (given they are written in yaml format).
Regards,
Nicolas
Mark Brown
maintainerRe: [PATCH 6/7] ARM: dts: Add dts for Raspberry Pi 4 + Cirrus Logic Lochnagar2
Quoted 11 lines · Nicolas Saenz Julienne
Quoted 4 lines · Richard Fitzgerald
We want something in mainline so that it can be used by people developing on mainline and taken as a starting point for configuring the codecs for other host platforms. The RPi is a convenient platform to use as the base because it is widely available and low-cost.
If what you want to convey is the proper way of configuring your specific device the way to go is writing a devicetree binding. See
Documentation/devicetree. It's even possible to validate a given devicetree against the bindings (given they are written in yaml format).
These devices already have bindings, that doesn't really help with describing how a specific board is wired up.
Re: [PATCH 6/7] ARM: dts: Add dts for Raspberry Pi 4 + Cirrus Logic Lochnagar2
In reply to Nicolas Saenz JulienneQuoted 7 lines · Nicolas Saenz Julienne
Quoted 6 lines · Richard Fitzgerald
Quoted 5 lines
Sadly I don't think creating a new device tree is a good solution here. If we were to do so for every RPi hat/usage it'd become unmanageable very fast. There is a way to maintain this in the open nonetheless. I suggest you build a DT overlay and submit it to https://github.com/raspberrypi/linux, see '
arch/arm/boot/dts/overlays.' The Raspberry Pi engineers have a kernel branch
Quoted 7 lines
Quoted 4 lines
We want something in mainline so that it can be used by people developing on mainline and taken as a starting point for configuring the codecs for other host platforms. The RPi is a convenient platform to use as the base because it is widely available and low-cost.
If what you want to convey is the proper way of configuring your specific device the way to go is writing a devicetree binding. See
If we have a working configuration it is unreasonable not to make this available for people who want to use it or examine it. A working example can be more helpful than a ton of documentation.
It's also worth noting that setting up a working sound system involves configuring multiple drivers (for example you also need a properly configured ASoC machine driver at least) crossing multiple driver bindings. So a complete working example is valuable to see how it fits together.
Quoted 3 lines
Documentation/devicetree. It's even possible to validate a given devicetree against the bindings (given they are written in yaml format).
Validating only checks syntax and bounds. It doesn't prove that it will work.
Quoted 3 lines
Regards,
Nicolas
PATCH 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 .dts for using the Lochnagar with a Raspberry Pi 4.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -4199,6 +4199,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.dts 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
Mark Brown
maintainerQuoted 5 lines · Richard Fitzgerald
This set of patches provides support for using the Cirrus Logic Lochnagar audio development platform plus Cirrus Logic Madera/Arizona codecs with the simple-card machine driver and a Raspberry Pi4. The ultimate aim is to provide the dts file but some updates are needed to the simple-card machine driver.
Why extend simple-card and not the more modern and flexible audio-graph-card?
Quoted 10 lines · Mark Brown
Quoted 5 lines · Richard Fitzgerald
This set of patches provides support for using the Cirrus Logic Lochnagar audio development platform plus Cirrus Logic Madera/Arizona codecs with the simple-card machine driver and a Raspberry Pi4. The ultimate aim is to provide the dts file but some updates are needed to the simple-card machine driver.
Why extend simple-card and not the more modern and flexible audio-graph-card?
I'm struggling to understand how to use audio-graph-card where there are multiple alternative codecs. The host I2S endpoint has to point back to the codec endpoint, like this:
cpu_i2s_ep_cs47l15: endpoint {
remote-endpoint = <&cs47l15_aif1>;
};But obviously that depends on which codec node was enabled. Listing multiple endpoints makes the whole port node disabled if any remote endpoint is in a disabled node. I've tried adding status="disabled" to endpoints or multiple port definitions with status="disabled" but I haven't figured out a solution.
Mark Brown
maintainerQuoted 8 lines · Richard Fitzgerald
Quoted 2 lines · Mark Brown
Why extend simple-card and not the more modern and flexible audio-graph-card?
I'm struggling to understand how to use audio-graph-card where there are multiple alternative codecs. The host I2S endpoint has to point back to the codec endpoint, like this:
OK, this seems like a more urgent problem to address given that the graph card is supposed to be able to support things like TDM. However...
Quoted 9 lines
cpu_i2s_ep_cs47l15: endpoint { remote-endpoint = <&cs47l15_aif1>; };But obviously that depends on which codec node was enabled. Listing multiple endpoints makes the whole port node disabled if any remote endpoint is in a disabled node. I've tried adding status="disabled" to endpoints or multiple port definitions with status="disabled" but I haven't figured out a solution.
...it seems like the issue here is that you're essentially trying to define multiple cards at once in the same overlay. TBH this feels like you want two nested levels of overlay, with the extra layer patching the CODEC compatible. Or if this is mainly as an example for people you could just pick one and use that?
Rob Herring
maintainerQuoted 20 lines · Richard Fitzgerald
Quoted 10 lines · Mark Brown
Quoted 5 lines · Richard Fitzgerald
This set of patches provides support for using the Cirrus Logic Lochnagar audio development platform plus Cirrus Logic Madera/Arizona codecs with the simple-card machine driver and a Raspberry Pi4. The ultimate aim is to provide the dts file but some updates are needed to the simple-card machine driver.
Why extend simple-card and not the more modern and flexible audio-graph-card?
I'm struggling to understand how to use audio-graph-card where there are multiple alternative codecs. The host I2S endpoint has to point back to the codec endpoint, like this:
cpu_i2s_ep_cs47l15: endpoint { remote-endpoint = <&cs47l15_aif1>; };
Quoted 5 lines
But obviously that depends on which codec node was enabled. Listing multiple endpoints makes the whole port node disabled if any remote endpoint is in a disabled node. I've tried adding status="disabled" to endpoints or multiple port definitions with status="disabled" but I haven't figured out a solution.
Multiple endpoints is what you should do. And 'status' goes in the device nodes (not the graph nodes).
Rob