Add freescale S/PDIF CPU DAI and machine drivers
Subsystems (5)
v4 cover Add freescale S/PDIF CPU DAI and machine drivers
Changelog:v3->v4:
* Use regmap for CPU DAI driver.
* Use individual clock source for 32KHz, 44KHz, 48KHz playback.
* Determine clock source configuration from 'clocks' entry.
* Added imx53 to compatible list, merged imx6q and imx6dl in the list.
* Improve the algorism of reverse_bits().
* Dropped the unneeded clk_put().v2->v3:
* Removed a wrong tag from the commit of patch-1.v1->v2:
* Dropped one applied patch for spdif dummy codec drivers.
* Use generic DMA DT binding.
* Let spdif controller driver calculate the clock div.
* Added one optional clock source for spdif tx.
* Reivsed documentation accordingly.
Nicolin Chen (2):
ASoC: fsl: Add S/PDIF CPU DAI driver
ASoC: fsl: Add S/PDIF machine driver
.../devicetree/bindings/sound/fsl,spdif.txt | 100 ++ .../devicetree/bindings/sound/imx-audio-spdif.txt | 29 + sound/soc/fsl/Kconfig | 14 + sound/soc/fsl/Makefile | 4 + sound/soc/fsl/fsl_spdif.c | 1350 ++++++++++++++++++++ sound/soc/fsl/fsl_spdif.h | 223 ++++ sound/soc/fsl/imx-spdif.c | 134 ++ 7 files changed, 1854 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/fsl,spdif.txt create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-spdif.txt create mode 100644 sound/soc/fsl/fsl_spdif.c create mode 100644 sound/soc/fsl/fsl_spdif.h create mode 100644 sound/soc/fsl/imx-spdif.c
PATCH v4 1/2 ASoC: fsl: Add S/PDIF CPU DAI driver
This patch add S/PDIF controller driver for Freescale SoC.
--- .../devicetree/bindings/sound/fsl,spdif.txt | 100 ++ sound/soc/fsl/Kconfig | 3 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_spdif.c | 1350 ++++++++++++++++++++ sound/soc/fsl/fsl_spdif.h | 223 ++++ 5 files changed, 1678 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/fsl,spdif.txt create mode 100644 sound/soc/fsl/fsl_spdif.c create mode 100644 sound/soc/fsl/fsl_spdif.h
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +100 -0
@@ -0,0 +1,100 @@ +Freescale Sony/Philips Digital Interface Format (S/PDIF) Controller + +The Freescale S/PDIF audio block is a stereo transceiver that allows the +processor to receive and transmit digital audio via an coaxial cable or +a fibre cable. + +Required properties: + + - compatible : Compatible list, contains "fsl,<chip>-spdif". Using general + "fsl,fsl-spdif" will get the default SoC type -- imx6q-spdif. + + - reg : Offset and length of the register set for the device. + + - interrupts : Contains spdif interrupt. + + - dmas : Generic dma devicetree binding as described in + Documentation/devicetree/bindings/dma/dma.txt. + + - dma-names : Two dmas have to be defined, "tx" and "rx". + + - clocks : Contains an entry for each entry in clock-names. + + - clock-names : Includes the following entries: + name type comments + "core" Required The core clock of spdif controller + "rx" Optional Rx clock source for spdif record. + If absent, will use core clock. + "tx" Optional Tx clock source for spdif playback. + If absent, will use core clock. + "tx-32000" Optional Tx clock source for 32000Hz sample rate + playback. If absent, will use tx clock. + "tx-44100" Optional Tx clock source for 44100Hz sample rate + playback. If absent, will use tx clock. + "tx-48000" Optional Tx clock source for 48000Hz sample rate + playback. If absent, will use tx clock. + + - tx-clksrc-names : The names for all available clock sources for tx, which + is also being listed in SoC reference manual, ClkSrc_Sel bit of SPDIF_SRPC. + And the name list would be different between different SoC. Use 'null' for + those unlisted names, and the max number of tx-clksrc-names should be 8. + + - rx-clksrc-names : The names for all available clock sources for rx, which + is also being listed in SoC reference manual, TxClk_Source bit of SPDIF_STC. + And the name list would be different between different SoC. Use 'null' for + those unlisted names, and the max number of rx-clksrc-names should be 16. + +Optional properties: + + - rx-clksrc-lock: This is a boolean property. If present, ClkSrc_Sel bit + of SPDIF_SRPC would be set a clock source that cares DPLL locked condition. + +Example1: + +spdif: spdif@02004000 { + compatible = "fsl,imx6q-spdif"; + reg = <0x02004000 0x4000>; + interrupts = <0 52 0x04>; + dmas = <&sdma 14 18 0>, + <&sdma 15 18 0>; + dma-names = "rx", "tx"; + + clocks = <&clks 197>; + clock-names = "core"; + rx-clksrc-lock; + rx-clksrc-names = + "lock.ext", "lock.spdif", "lock.asrc", + "lock.spdif_ext", "lock.esai", "ext", + "spdif", "asrc", "spdif_ext", "esai", + "lock.mlb", "lock.mlb_phy", "mlb", + "mlb_phy"; + tx-clksrc-names = + "xtal", "spdif", "asrc", "spdif_ext", + "esai", "ipg", "mlb", "mlb_phy"; + + status = "okay"; +}; + +Example2: + +spdif: spdif@02004000 { + compatible = "fsl,imx6sl-spdif"; + reg = <0x02004000 0x4000>; + interrupts = <0 52 0x04>; + dmas = <&sdma 14 18 0>, + <&sdma 15 18 0>; + dma-names = "rx", "tx"; + + clocks = <&clks 122>; + clock-names = "core"; + rx-clksrc-lock; + rx-clksrc-names = + "lock.xtal", "lock.spdif", "null", "lock.spdif_ext", + "null", "xtal", "spdif", "null", "spdif_ext", "null", + "null", "null", "mlb"; + tx-clksrc-names = + "xtal", "spdif", "null", "spdif_ext", + "null", "ipg"; + + status = "okay"; +};
sound/soc/fsl/Kconfig +3 -0
@@ -1,6 +1,9 @@ config SND_SOC_FSL_SSI tristate +config SND_SOC_FSL_SPDIF + tristate + config SND_SOC_FSL_UTILS tristate
sound/soc/fsl/Makefile +2 -0
@@ -12,9 +12,11 @@ obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o # Freescale PowerPC SSI/DMA Platform Support snd-soc-fsl-ssi-objs := fsl_ssi.o +snd-soc-fsl-spdif-objs := fsl_spdif.o snd-soc-fsl-utils-objs := fsl_utils.o snd-soc-fsl-dma-objs := fsl_dma.o obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o +obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o
sound/soc/fsl/fsl_spdif.c new file +1350 -0
1,350 lines not on this page · raw message
sound/soc/fsl/fsl_spdif.h new file +223 -0
223 lines not on this page · raw message
Signature · 1 line
1.7.1
Fabio Estevam
reviewerRe: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Documentation/devicetree/bindings/sound/fsl,spdif.txt line 9
Quoted 3 lines · Nicolin Chen
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +3
-0+Required properties: + + - compatible : Compatible list, contains "fsl,<chip>-spdif". Using general
Can't we just use "fsl,fsl-spdif" instead?
Review
Quoted 2 lines
(quoted diff) +2
-0+ "fsl,fsl-spdif" will get the default SoC type -- imx6q-spdif. +
I think this is not the usual approach we do with dt.
sound/soc/fsl/fsl_spdif.c line 1327
Quoted 2 lines
sound/soc/fsl/fsl_spdif.c new file +2
-0+static const struct of_device_id fsl_spdif_dt_ids[] = { + { .compatible ="fsl,fsl-spdif" , },
Isn't only the first entry enough here?
Quoted 13 lines
sound/soc/fsl/fsl_spdif.c new file +13
-0+ { .compatible = "fsl,imx6q-spdif", }, + { .compatible = "fsl,imx6sl-spdif", }, + { .compatible = "fsl,imx53-spdif", }, + {} +}; +MODULE_DEVICE_TABLE(of, fsl_spdif_dt_ids); + +static struct platform_driver fsl_spdif_driver = { + .driver = { + .name = "fsl-spdif-dai", + .owner = THIS_MODULE, + .of_match_table = fsl_spdif_dt_ids, + },
sound/soc/fsl/fsl_spdif.c line 1350
Quoted 10 lines
sound/soc/fsl/fsl_spdif.c new file +10
-0+ .probe = fsl_spdif_probe, + .remove = fsl_spdif_remove, +}; + +module_platform_driver (fsl_spdif_driver); + +MODULE_AUTHOR ("Freescale Semiconductor, Inc." ); +MODULE_DESCRIPTION ("Freescale S/PDIF CPU DAI Driver" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:fsl_spdif" );
This MODULE_ALIAS name does not match the name you provided earlier:
.name = "fsl-spdif-dai"
Fabio Estevam
reviewerRe: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 6 lines · Fabio Estevam
Documentation/devicetree/bindings/sound/fsl,spdif.txt line 9
Quoted 3 lines · Nicolin Chen
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +3
-0+Required properties: + + - compatible : Compatible list, contains "fsl,<chip>-spdif". Using generalCan't we just use "fsl,fsl-spdif" instead?
Or maybe "fsl,imx35-spdif", since mx35 was the first imx SoC with this spdif IP block.
Mark Brown
maintainerRe: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
In reply to Fabio EstevamQuoted 6 lines · Fabio Estevam
Documentation/devicetree/bindings/sound/fsl,spdif.txt line 9
Quoted 3 lines · Nicolin Chen
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +2
-0+Required properties: + - compatible : Compatible list, contains "fsl,<chip>-spdif". Using generalCan't we just use "fsl,fsl-spdif" instead?
It's better to list the specific chips in the DT so that we can quirk if we need to later.
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
In reply to Fabio EstevamHi Fabio,
Thank you for the comments.
Quoted 10 lines · Fabio Estevam
Documentation/devicetree/bindings/sound/fsl,spdif.txt line 9
Quoted 3 lines · Nicolin Chen
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +3
-0+Required properties: + + - compatible : Compatible list, contains "fsl,<chip>-spdif". Using generalCan't we just use "fsl,fsl-spdif" instead?
Review
Quoted 2 lines
(quoted diff) +2
-0+ "fsl,fsl-spdif" will get the default SoC type -- imx6q-spdif. +
Quoted 6 lines
I think this is not the usual approach we do with dt.
sound/soc/fsl/fsl_spdif.c line 1327
Quoted 2 lines
sound/soc/fsl/fsl_spdif.c new file +2
-0+static const struct of_device_id fsl_spdif_dt_ids[] = { + { .compatible ="fsl,fsl-spdif" , },Isn't only the first entry enough here?
I just saw Mark's words as well. So I don't need to change this part right? But I'd like to add imx35 on it.
Quoted 4 lines
This
MODULE_ALIASname does not match the name you provided earlier:.name = "fsl-spdif-dai"
I'll fix it in v5.
Best regards,
Nicolin Chen
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
In reply to Fabio EstevamQuoted 8 lines · Fabio Estevam
Documentation/devicetree/bindings/sound/fsl,spdif.txt line 9
Quoted 3 lines · Nicolin Chen
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +3
-0+Required properties: + + - compatible : Compatible list, contains "fsl,<chip>-spdif". Using generalCan't we just use "fsl,fsl-spdif" instead?
Quoted 1 line
+ "fsl,fsl-spdif" will get the default SoC type -- imx6q-spdif.
I do not think we need this general compatible string. Device tree compatible should be specific.
Shawn
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Hi Shwan,
Quoted 2 lines · Shawn Guo
I do not think we need this general compatible string. Device tree compatible should be specific.
So I should just use 'fsl,<chip>-spdif" and list all <chip>-spdif in compatible list?
I added 'fsl,fsl-spdif' just for those not-in-list chips, Vybrid for example. So you think I should add all the possible chips to the list? But what if some chip I don't know right now that also uses this spdif controller? Add them to the list later?
Thank you.
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 6 lines · Nicolin Chen
Hi Shwan,
Quoted 2 lines · Shawn Guo
I do not think we need this general compatible string. Device tree compatible should be specific.
Quoted 7 lines
So I should just use 'fsl,<chip>-spdif" and list all <chip>-spdif in compatible list?
I added 'fsl,fsl-spdif' just for those not-in-list chips, Vybrid for example. So you think I should add all the possible chips to the list? But what if some chip I don't know right now that also uses this spdif controller? Add them to the list later?
We only need to maintain those versions that require different programming model in the list. For example, if S/PDIF on Vybrid is completely compatible with imx6q one and uses the exactly same programming model, we do not need to maintain a compatible string for Vybrid S/PDIF at all. Instead, we only need to have something like below in Vybrid dts file, and S/PDIF driver will just work for it.
compatible = "fsl,vf600-spdif", "fsl,imx6q-spdif";
Shawn
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 10 lines · Shawn Guo
We only need to maintain those versions that require different programming model in the list. For example, if S/PDIF on Vybrid is completely compatible with imx6q one and uses the exactly same programming model, we do not need to maintain a compatible string for Vybrid S/PDIF at all. Instead, we only need to have something like below in Vybrid dts file, and S/PDIF driver will just work for it.
compatible = "fsl,vf600-spdif", "fsl,imx6q-spdif";Shawn
Clear. Thank you for the explain.
Then I think I can merely remain "fsl,imx6q-spdif" here, because all other cases should be completely compatible with this one. They are only different in the clock source names list, which's already being specified in dts file.
Please correct me if you think this still isn't proper.
Best regards,
Nicolin Chen
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 12 lines · Nicolin Chen
Quoted 10 lines · Shawn Guo
We only need to maintain those versions that require different programming model in the list. For example, if S/PDIF on Vybrid is completely compatible with imx6q one and uses the exactly same programming model, we do not need to maintain a compatible string for Vybrid S/PDIF at all. Instead, we only need to have something like below in Vybrid dts file, and S/PDIF driver will just work for it.
compatible = "fsl,vf600-spdif", "fsl,imx6q-spdif";Shawn
Quoted 8 lines
Clear. Thank you for the explain.
Then I think I can merely remain "fsl,imx6q-spdif" here, because all other cases should be completely compatible with this one. They are only different in the clock source names list, which's already being specified in dts file.
Please correct me if you think this still isn't proper.
And we generally prefer to use the soc that firstly integrates the IP to name the compatible. For IMX series, I think imx35 is the one, so we would name it "fsl,imx35-spdif".
Shawn
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 13 lines · Shawn Guo
Quoted 12 lines · Nicolin Chen
Quoted 10 lines · Shawn Guo
We only need to maintain those versions that require different programming model in the list. For example, if S/PDIF on Vybrid is completely compatible with imx6q one and uses the exactly same programming model, we do not need to maintain a compatible string for Vybrid S/PDIF at all. Instead, we only need to have something like below in Vybrid dts file, and S/PDIF driver will just work for it.
compatible = "fsl,vf600-spdif", "fsl,imx6q-spdif";Shawn
Quoted 8 lines
Quoted 8 lines
Clear. Thank you for the explain.
Then I think I can merely remain "fsl,imx6q-spdif" here, because all other cases should be completely compatible with this one. They are only different in the clock source names list, which's already being specified in dts file.
Please correct me if you think this still isn't proper.
If the clock source name list is different, then it needs a different compatible value, so that each compatible value can specify which clock names are required.
Also, the compatible value itself should always include the exact HW that's present (most specific HW version), as well as any other HW it's compatible with.
Quoted 3 lines
And we generally prefer to use the soc that firstly integrates the IP to name the compatible. For IMX series, I think imx35 is the one, so we would name it "fsl,imx35-spdif".
Re: [alsa-devel] [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Hi Stephen,
Quoted 7 lines · Stephen Warren
If the clock source name list is different, then it needs a different compatible value, so that each compatible value can specify which clock names are required.
Also, the compatible value itself should always include the exact HW that's present (most specific HW version), as well as any other HW it's compatible with.
Thank you for the comments. Yes, I did so in v1-v3, but after rethinking about the situation (Actually both the HW version and the clock mux itself are same, just the clock sources connecting to the mux might be different), so I decided to do this by abstracting the driver from those source info and letting DT binding to pass such information. Because I think putting the clock sources into the driver differed by compatible value would make the driver more like SoC-specified, not the ideal way -- SoC-independent, since the clock sources are based on SoC design, not on itself.
Thank you,
Nicolin Chen
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 11 lines · Nicolin Chen
Hi Stephen,
Quoted 7 lines · Stephen Warren
If the clock source name list is different, then it needs a different compatible value, so that each compatible value can specify which clock names are required.
Also, the compatible value itself should always include the exact HW that's present (most specific HW version), as well as any other HW it's compatible with.
Quoted 8 lines
Thank you for the comments. Yes, I did so in v1-v3, but after rethinking about the situation (Actually both the HW version and the clock mux itself are same, just the clock sources connecting to the mux might be different), so I decided to do this by abstracting the driver from those source info and letting DT binding to pass such information. Because I think putting the clock sources into the driver differed by compatible value would make the driver more like SoC-specified, not the ideal way -- SoC-independent, since the clock sources are based on SoC design, not on itself.
+1
It's pretty much the differences at SoC integration level not the IP itself, and it just happens to be handled in a register of the IP.
Shawn
Re: [PATCH v4 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
Quoted 21 lines · Shawn Guo
Quoted 11 lines · Nicolin Chen
Hi Stephen,
Quoted 7 lines · Stephen Warren
If the clock source name list is different, then it needs a different compatible value, so that each compatible value can specify which clock names are required.
Also, the compatible value itself should always include the exact HW that's present (most specific HW version), as well as any other HW it's compatible with.
Quoted 8 lines
Thank you for the comments. Yes, I did so in v1-v3, but after rethinking about the situation (Actually both the HW version and the clock mux itself are same, just the clock sources connecting to the mux might be different), so I decided to do this by abstracting the driver from those source info and letting DT binding to pass such information. Because I think putting the clock sources into the driver differed by compatible value would make the driver more like SoC-specified, not the ideal way -- SoC-independent, since the clock sources are based on SoC design, not on itself.
Quoted 4 lines
+1
It's pretty much the differences at SoC integration level not the IP itself, and it just happens to be handled in a register of the IP.
OK, if the difference are the sources of the clocks and not the set of clocks, then there's no issue. I can't remember what triggered my comments above, but obviously it wasn't clear that this was the case.
PATCH v4 2/2 ASoC: fsl: Add S/PDIF machine driver
In reply to Nicolin ChenAdd S/PDIF machine driver for Freescale i.MX series SoC.
--- .../devicetree/bindings/sound/imx-audio-spdif.txt | 29 +++++ sound/soc/fsl/Kconfig | 11 ++ sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-spdif.c | 134 ++++++++++++++++++++ 4 files changed, 176 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-spdif.txt create mode 100644 sound/soc/fsl/imx-spdif.c
Documentation/devicetree/bindings/sound/imx-audio-spdif.txt new file +29 -0
@@ -0,0 +1,29 @@ +Freescale i.MX audio complex with S/PDIF transceiver + +Required properties: + + - compatible : "fsl,imx-audio-spdif" + + - model : The user-visible name of this sound complex + + - spdif-controller : The phandle of the i.MX S/PDIF controller + + +Optional properties: + + - spdif-transmitter : The phandle of the spdif-transmitter dummy codec + + - spdif-receiver : The phandle of the spdif-receiver dummy codec + +* Note: At least one of these two properties should be set in the DT binding. + + +Example: + +sound-spdif { + compatible = "fsl,imx-audio-spdif"; + model = "imx-spdif"; + spdif-controller = <&spdif>; + spdif-transmitter = <&spdif_tx_codec>; + spdif-receiver = <&spdif_rx_codec>; +};
sound/soc/fsl/Kconfig +11 -0
@@ -195,6 +195,17 @@ config SND_SOC_IMX_SGTL5000 Say Y if you want to add support for SoC audio on an i.MX board with a sgtl5000 codec. +config SND_SOC_IMX_SPDIF + tristate "SoC Audio support for i.MX boards with S/PDIF" + select SND_SOC_IMX_PCM_DMA + select SND_SOC_FSL_SPDIF + select SND_SOC_FSL_UTILS + select SND_SOC_SPDIF + help + SoC Audio support for i.MX boards with S/PDIF + Say Y if you want to add support for SoC audio on an i.MX board with + a S/DPDIF. + config SND_SOC_IMX_MC13783 tristate "SoC Audio support for I.MX boards with mc13783" depends on MFD_MC13783 && ARM
sound/soc/fsl/Makefile +2 -0
@@ -45,6 +45,7 @@ snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o snd-soc-wm1133-ev1-objs := wm1133-ev1.o snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o snd-soc-imx-wm8962-objs := imx-wm8962.o +snd-soc-imx-spdif-objs :=imx-spdif.o snd-soc-imx-mc13783-objs := imx-mc13783.o obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
@@ -53,4 +54,5 @@ obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o +obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
sound/soc/fsl/imx-spdif.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
1.7.1