ASoC: add driver for Atmel I2S controller
Subsystems (5)
v3 cover ASoC: add driver for Atmel I2S controller
This series of patches adds support to the new Atmel I2S controller embedded on sama5d2 SoCs.
ChangeLog
v2 -> v3
- fix the coding style, add some more comments and add a section dedicated to sama5d2 SoCs in the DT binding documentation as suggested by Mark Brown.
v1 -> v2
- initialize dev->dev before calling dev->caps->mck_init()
Cyrille Pitchen (2):
ASoC: atmel-i2s: add DT bindings for I2S controller
ASoC: atmel-i2s: add driver for the new Atmel I2S controller
.../devicetree/bindings/sound/atmel-i2s.txt | 87 +++ sound/soc/atmel/Kconfig | 9 + sound/soc/atmel/Makefile | 2 + sound/soc/atmel/atmel-i2s.c | 770 +++++++++++++++++++++ 4 files changed, 868 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/atmel-i2s.txt create mode 100644 sound/soc/atmel/atmel-i2s.c
Signature · 1 line
1.8.2.2
PATCH v3 1/2 ASoC: atmel-i2s: add DT bindings for I2S controller
This patch adds DT bindings for the new Atmel I2S controller embedded inside sama5d2x SoCs.
--- .../devicetree/bindings/sound/atmel-i2s.txt | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/atmel-i2s.txt
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +87 -0
@@ -0,0 +1,87 @@ +* Atmel I2S controller + +Required properties: +- compatible: Should be "atmel,sama5d2-i2s". +- reg: Should be the physical base address of the controller and the + length of memory mapped region. +- interrupts: Should contain the interrupt for the controller. +- dmas: Should be a list of pairs of DMA controller phandle and flags. +- dma-names: Should be a list of DMA channel name among "rx", "tx" or + "rx-tx". +- clocks: Should be a list of phandles of clocks used by the controller + (1). +- clock-names: Should be a list matching the clocks phandles list: + - "pclk" (peripheral clock) Required. + - "gclk" (generated clock) Optional (1). + - "aclk" (Audio PLL clock) Optional (1). + +Optional properties: +- pinctrl-0: Should specify pin control groups used for this controller. +- princtrl-names: Should contain only one value - "default". + + +(1) : Only the peripheral clock is required. The generated clock and the Audio + PLL clock are optional and should only be set together. + +Example: + + i2s@f8050000 { + compatible = "atmel,sama5d2-i2s"; + reg = <0xf8050000 0x300>; + interrupts = <54 IRQ_TYPE_LEVEL_HIGH 7>; + dmas = <&dma0 + (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | + AT91_XDMAC_DT_PERID(31))>, + <&dma0 + (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | + AT91_XDMAC_DT_PERID(32))>; + dma-names = "tx", "rx"; + clocks = <&i2s0_clk>, <&i2s0_gclk>, <&audio_pll_pmc>; + clock-names = "pclk", "gclk", "aclk"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2s0_default>; + }; + + +sama5d2 SoCs only: + +When the I2S controller is configured as a master, it generates the master, +bitrate and frame clocks from a PMC input clock. This PMC input clock can be +either the I2S peripheral clock or the I2S generated clock. +The generated clock can reach higher frequencies and is more suited for audio +applications hence should be preferred to the peripheral clock. +The I2SCLKSEL register of the Special Function Register (SFR) is used to select +the relevant PMC input clock: bit0 selects the input clock for I2S controller 0 +whereas bit1 selects the input clock for I2S controller 1. + +Aliases are used in the device-tree to retrieve the index of each I2S controller +so the right bit can be updated in the I2SCLKSEL register. + +Finally, the SFR itself is handled by the generic syscon driver. +Its "compatible" DT property must contain the "atmel,sama5d2-sfr" string so the +I2S controller driver (and likely other drivers) can find the SFR node when +needed. + +aliases { + i2s0 = &i2s0; + i2s1 = &i2s1; +}; + +... + +ahb { + apb { + sfr@f8030000 { + compatible = "atmel,sama5d2-sfr", "syscon"; + reg = <0xf8030000 0x98>; + }; + + i2s0: i2s@f8050000 { + ... + }; + + i2s1: i2s@fc04c000 { + ... + }; + }; +};
Signature · 1 line
1.8.2.2
Rob Herring
maintainerRe: [PATCH v3 1/2] ASoC: atmel-i2s: add DT bindings for I2S controller
Quoted 15 lines · Cyrille Pitchen
This patch adds DT bindings for the new Atmel I2S controller embedded inside sama5d2x SoCs.
Signed-off-by Cyrille Pitchen <[email protected]>--- .../devicetree/bindings/sound/atmel-i2s.txt | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/atmel-i2s.txtDocumentation/devicetree/bindings/sound/atmel-i2s.txt new file +0
-0
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +8
-0@@ -0,0 +1,87 @@ +* Atmel I2S controller + +Required properties: +- compatible: Should be "atmel,sama5d2-i2s". +- reg: Should be the physical base address of the controller and the + length of memory mapped region. +- interrupts: Should contain the interrupt for the controller. +- dmas: Should be a list of pairs of DMA controller phandle and flags.
How many?
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 10
Quoted 2 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +2
-0+- dma-names: Should be a list of DMA channel name among "rx", "tx" or + "rx-tx".
When is rx-tx used? Seems like there may need to be more than 1 compatible string if there is variation here.
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 12
Quoted 2 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +2
-0+- clocks: Should be a list of phandles of clocks used by the controller + (1).
This should be a specific number for each compatible string.
Quoted 24 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +24
-0+- clock-names: Should be a list matching the clocks phandles list: + - "pclk" (peripheral clock) Required. + - "gclk" (generated clock) Optional (1). + - "aclk" (Audio PLL clock) Optional (1). + +Optional properties: +- pinctrl-0: Should specify pin control groups used for this controller. +- princtrl-names: Should contain only one value - "default". + + +(1) : Only the peripheral clock is required. The generated clock and the Audio + PLL clock are optional and should only be set together. + +Example: + + i2s@f8050000 { + compatible = "atmel,sama5d2-i2s"; + reg = <0xf8050000 0x300>; + interrupts = <54 IRQ_TYPE_LEVEL_HIGH 7>; + dmas = <&dma0 + (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | + AT91_XDMAC_DT_PERID(31))>, + <&dma0 + (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 46
Quoted 10 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +10
-0+ AT91_XDMAC_DT_PERID(32))>; + dma-names = "tx", "rx"; + clocks = <&i2s0_clk>, <&i2s0_gclk>, <&audio_pll_pmc>; + clock-names = "pclk", "gclk", "aclk"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2s0_default>; + }; + + +sama5d2 SoCs only:
That's the only SoC documented here...
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 55
Quoted 9 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +9
-0+ +When the I2S controller is configured as a master, it generates the master, +bitrate and frame clocks from a PMC input clock. This PMC input clock can be +either the I2S peripheral clock or the I2S generated clock. +The generated clock can reach higher frequencies and is more suited for audio +applications hence should be preferred to the peripheral clock. +The I2SCLKSEL register of the Special Function Register (SFR) is used to select +the relevant PMC input clock: bit0 selects the input clock for I2S controller 0 +whereas bit1 selects the input clock for I2S controller 1.
This seems like all internal details of the block.
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 58
Quoted 2 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +2
-0+Aliases are used in the device-tree to retrieve the index of each I2S controller +so the right bit can be updated in the I2SCLKSEL register.
I'd prefer aliases not be used for this.
Documentation/devicetree/bindings/sound/atmel-i2s.txt line 63
Quoted 5 lines
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +5
-0+ +Finally, the SFR itself is handled by the generic syscon driver. +Its "compatible" DT property must contain the "atmel,sama5d2-sfr" string so the +I2S controller driver (and likely other drivers) can find the SFR node when +needed.
Typically we would have a phandle to the syscon with a cell to give the bit position.
If this is all just for clock control, then it seems like you need a proper clock driver for this clock control bit.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/2 ASoC: atmel-i2s: add driver for the new Atmel I2S controller
In reply to Cyrille PitchenThis patch adds support for the Atmel I2S controller embedded into sama5d2x SoCs.
--- sound/soc/atmel/Kconfig | 9 + sound/soc/atmel/Makefile | 2 + sound/soc/atmel/atmel-i2s.c | 770 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 781 insertions(+) create mode 100644 sound/soc/atmel/atmel-i2s.c
sound/soc/atmel/Kconfig +9 -0
@@ -78,4 +78,13 @@ config SND_ATMEL_SOC_PDMIC help Say Y if you want to add support for Atmel ASoC driver for boards using PDMIC. + +config SND_ATMEL_SOC_I2S + tristate "Atmel ASoC driver for boards using I2S" + depends on OF && (ARCH_AT91 || COMPILE_TEST) + select SND_SOC_GENERIC_DMAENGINE_PCM + select REGMAP_MMIO + help + Say Y or M if you want to add support for Atmel ASoc driver for boards + using I2S. endif
sound/soc/atmel/Makefile +2 -0
@@ -2,10 +2,12 @@ snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o +snd-soc-atmel-i2s-objs := atmel-i2s.o obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o +obj-$(CONFIG_SND_ATMEL_SOC_I2S) += snd-soc-atmel-i2s.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
sound/soc/atmel/atmel-i2s.c new file +770 -0
770 lines not on this page · raw message
Signature · 1 line
1.8.2.2
Mark Brown
maintainerRe: [PATCH v3 2/2] ASoC: atmel-i2s: add driver for the new Atmel I2S controller
On Wed, Jul 13, 2016 at 12:25:39PM +0200, Cyrille Pitchen wrote:
A few small things but otherwise this looks good:
sound/soc/atmel/atmel-i2s.c line 378
Quoted 3 lines
sound/soc/atmel/atmel-i2s.c new file +3
-0+switch (params_channels (params)) { +case 1 : + mr |= is_playback ?ATMEL_I2SC_MR_TXMONO :ATMEL_I2SC_MR_RXMONO ;
Please write normal if statements, it makes things easier to read.
sound/soc/atmel/atmel-i2s.c line 385
Quoted 7 lines
sound/soc/atmel/atmel-i2s.c new file +7
-0+break ; +case 2 : +break ; +default : +dev_err (dev->dev,"unsupported number of audio channels\n" ); +break ; + }
Why don't we return an error if we don't support the requested number of channels?
sound/soc/atmel/atmel-i2s.c line 685
Quoted 5 lines
sound/soc/atmel/atmel-i2s.c new file +5
-0+ dev->gclk =devm_clk_get (&pdev->dev,"gclk" ); +if (IS_ERR (dev->aclk) &&IS_ERR (dev->gclk)) { +/* Master Mode not supported */ + dev->aclk =NULL ; + dev->gclk =NULL ;
This won't handle probe deferral properly, it'll just ignore the clocks if we get -EPROBE_DEFER. The driver should special case that at least.