Re: [PATCH v5 1/7] sound: codec: wm8731: add rates constraints
2013/7/12 Mark Brown broo...@kernel.org: On Thu, Jul 11, 2013 at 06:15:53PM +0200, Richard Genoud wrote: Please always try to use commit logs that look like normal commit logs for the subsystem. Ok, I'll pay attention to that. switch (freq) { - case 11289600: case 1200: + wm8731-constraints = wm8731_constraints_1200; + break; case 12288000: - case 16934400: case 18432000: - wm8731-sysclk = freq; + wm8731-constraints = wm8731_constraints_12288000_18432000; + break; + case 16934400: + case 11289600: + wm8731-constraints = wm8731_constraints_11289600_16934400; break; default: return -EINVAL; } This isn't going to work with systems which have a variable clock as the input to the CODEC. If it's imposing constraints the driver needs to allow setting the clock to zero as a way of removing constraints (and any existing drivers should be updated to do this if needed). Maybe I'm wrong, but I didn't find any system using variable clock with this codec. The sam9g20ek (soc/atmel/sam9g20_wm8731.c) is not using a crystal, but it's using a fixed clock anyway. But there's soc/pxa/corgi.c and soc/pxa/poodle.c that puzzle me. They seems to use a crystal, but they are setting a different sysclk depending on the rate. That seems wrong, but as I'm a newbie in ASoC... ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v5 2/7] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/12 Mark Brown broo...@kernel.org: On Thu, Jul 11, 2013 at 06:15:54PM +0200, Richard Genoud wrote: From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board ASoC. +sam9x5 pins: + * LOUT + * ROUT + * LHPOUT + * RHPOUT + * LLINEIN + * RLINEIN + * MICIN These aren't pins on the CPU, they're pins on the CODEC, and you should be adding this to the binding document for the CODEC and referring to that rather than having them in each individual binding document. This also helps if any new variants are added (not that this is likely for the WM8731). ok, I'll move that +static struct sam9x5_drvdata sam9x5_priv; Why is this a global static? + ret = snd_soc_register_card(snd_soc_sam9x5); + if (ret) { + dev_err(pdev-dev, + ASoC: Platform device allocation failed\n); + goto out_put_audio; + } + platform_set_drvdata(pdev, snd_soc_sam9x5); It should be being dynamically allocated and retrieved as driver data when needed. ok. Thanks ! -- for me, ck means con kolivas and not calvin klein... does it mean I'm a geek ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 1/7] sound: codec: wm8731: add rates constraints
Depending on the mclk (or crystal) selected, the wm8731 codec have some constraints on its data sampling rates: e.g. with a 12.288MHz or 18.432MHz crystal, the authorized rates are 8KHz, 32KHz, 48KHz and 96KHz. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/codecs/wm8731.c | 57 ++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 5276062..fc031ed 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -45,6 +45,7 @@ static const char *wm8731_supply_names[WM8731_NUM_SUPPLIES] = { struct wm8731_priv { struct regmap *regmap; struct regulator_bulk_data supplies[WM8731_NUM_SUPPLIES]; + const struct snd_pcm_hw_constraint_list *constraints; unsigned int sysclk; int sysclk_type; int playback_fs; @@ -290,6 +291,36 @@ static const struct _coeff_div coeff_div[] = { {1200, 88200, 136, 0xf, 0x1, 0x1}, }; +/* rates constraints */ +static const unsigned int wm8731_rates_1200[] = { + 8000, 32000, 44100, 48000, 96000, 88200, +}; + +static const unsigned int wm8731_rates_12288000_18432000[] = { + 8000, 32000, 48000, 96000, +}; + +static const unsigned int wm8731_rates_11289600_16934400[] = { + 8000, 44100, 88200, +}; + +static const struct snd_pcm_hw_constraint_list wm8731_constraints_1200 = { + .list = wm8731_rates_1200, + .count = ARRAY_SIZE(wm8731_rates_1200), +}; + +static const +struct snd_pcm_hw_constraint_list wm8731_constraints_12288000_18432000 = { + .list = wm8731_rates_12288000_18432000, + .count = ARRAY_SIZE(wm8731_rates_12288000_18432000), +}; + +static const +struct snd_pcm_hw_constraint_list wm8731_constraints_11289600_16934400 = { + .list = wm8731_rates_11289600_16934400, + .count = ARRAY_SIZE(wm8731_rates_11289600_16934400), +}; + static inline int get_coeff(int mclk, int rate) { int i; @@ -362,17 +393,23 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, } switch (freq) { - case 11289600: case 1200: + wm8731-constraints = wm8731_constraints_1200; + break; case 12288000: - case 16934400: case 18432000: - wm8731-sysclk = freq; + wm8731-constraints = wm8731_constraints_12288000_18432000; + break; + case 16934400: + case 11289600: + wm8731-constraints = wm8731_constraints_11289600_16934400; break; default: return -EINVAL; } + wm8731-sysclk = freq; + snd_soc_dapm_sync(codec-dapm); return 0; @@ -475,12 +512,26 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, return 0; } +static int wm8731_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(dai-codec); + + if (wm8731-constraints) + snd_pcm_hw_constraint_list(substream-runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + wm8731-constraints); + + return 0; +} + #define WM8731_RATES SNDRV_PCM_RATE_8000_96000 #define WM8731_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) static const struct snd_soc_dai_ops wm8731_dai_ops = { + .startup= wm8731_startup, .hw_params = wm8731_hw_params, .digital_mute = wm8731_mute, .set_sysclk = wm8731_set_dai_sysclk, -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 0/7] Sound support for at91sam9x5-wm8731 based boards
Hi, This patchset add sound on the at91sam9x5ek board. It's based on Nicolas Ferre's work in the 2.6.39 atmel patch for sam9x5: https://github.com/linux4sam/linux-at91/commit/0aa157c9e71f3abc30fa37eb5c95b392978d It needs Bo Chen's patchset on the generic dmaengine (topic/atmel branch on Mark's sound tree) and the SSC interrupts disabled (cf http://www.spinics.net/lists/arm-kernel/msg256901.html) Outstanding issue: If this machine driver will support more SoCs maybe we should name it differently. It has been tested on at91sam9g35ek, and should work on g15, g25, x25 and x35 also. patches applies on next-20130711 [I let the original signed-off from Nicolas and Uwe in place, I don't know if I should replace them by something like originaly-signed-off-by since the code has been changed.] Changes from v4: * Move the rates constraints into the codec * Hard code the DAI format since it cannot be changed anyway (and remove the DT bindings accordingly) * Add some consistency in the functions naming (sam9x5ek/at91sam9x5ek/sam9x5) * Retrieve the SSC id from the SSC controller phandle * Clarify the atmel-ssc.txt documentation * Develop audio-routing documentation * Tidy up the includes in the machine driver Changes from v3: * Remove the use of macros in device tree documentation. Changes from v2: * Change atmel,sam9x5-audio-wm8731 to atmel,sam9x5-wm8731-audio for consistency with sam9g20 machine driver. * Use the snd_pcm_hw_constraint() API as suggested by Mark and Lars-Peter. * Remove the unnecessary snd_soc_dapm_sync() call as Lars-Peter suggested. * Add documentation for machine driver DT binding. * Update atmel-ssc DT binding documentation. * Add GPL license instead of just the GPL word (hope that's ok !) Changes from v1-RFC: * drop patches on SSC since Bo Chen already did the work * reorder patches to have the machine driver first * drop code already handled by the ASoC framework * drop unneeded SND_ATMEL_SOC_PDC config selection * use static snd_soc_card and snd_soc_dai_link structures. Best regards, Richard. Nicolas Ferre (1): sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards Richard Genoud (6): sound: codec: wm8731: add rates constraints Documentation: DT: update atmel SSC with DMA binding ARM: AT91: DTS: sam9x5: add SSC DMA parameters ARM: AT91: DTS: sam9x5ek: add WM8731 codec ARM: AT91: DTS: sam9x5ek: enable SSC ARM: AT91: DTS: sam9x5ek: add sound configuration .../devicetree/bindings/misc/atmel-ssc.txt | 23 ++- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 41 arch/arm/boot/dts/at91sam9x5.dtsi |3 + arch/arm/boot/dts/at91sam9x5ek.dtsi| 24 +++ sound/soc/atmel/Kconfig| 10 + sound/soc/atmel/Makefile |2 + sound/soc/atmel/sam9x5_wm8731.c| 207 sound/soc/codecs/wm8731.c | 57 +- 8 files changed, 363 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt create mode 100644 sound/soc/atmel/sam9x5_wm8731.c -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 2/7] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. [Richard: this is based on an old patch from Nicolas that I forward ported and reworked to use only device tree] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 41 sound/soc/atmel/Kconfig| 10 + sound/soc/atmel/Makefile |2 + sound/soc/atmel/sam9x5_wm8731.c| 207 4 files changed, 260 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt create mode 100644 sound/soc/atmel/sam9x5_wm8731.c diff --git a/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt new file mode 100644 index 000..630ef8b --- /dev/null +++ b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt @@ -0,0 +1,41 @@ +* Atmel at91sam9x5ek wm8731 audio complex + +Required properties: + - compatible: atmel,sam9x5-wm8731-audio + - atmel,model: The user-visible name of this sound complex. + - atmel,ssc-controller: The phandle of the SSC controller + - atmel,audio-codec: The phandle of the WM8731 audio codec + - atmel,audio-routing: A list of the connections between audio components. +Each entry is a pair of strings, the first being the connection's sink, +the second being the connection's source. + +Available audio endpoints for the audio-routing table: + +Board connectors: + * Headphone Jack + * Line In Jack + +sam9x5 pins: + * LOUT + * ROUT + * LHPOUT + * RHPOUT + * LLINEIN + * RLINEIN + * MICIN + +Example: +sound { + compatible = atmel,sam9x5-wm8731-audio; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; +}; diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 1c0b185..9eb8c49 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -33,6 +33,16 @@ config SND_AT91_SOC_SAM9G20_WM8731 Say Y if you want to add support for SoC audio on WM8731-based AT91sam9g20 evaluation board. +config SND_AT91_SOC_SAM9X5_WM8731 + tristate SoC Audio support for WM8731-based at91sam9x5 board + depends on ATMEL_SSC SND_ATMEL_SOC SOC_AT91SAM9X5 + select SND_ATMEL_SOC_SSC + select SND_ATMEL_SOC_DMA + select SND_SOC_WM8731 + help + Say Y if you want to add support for audio SoC on an + at91sam9x5 based board that is using WM8731 codec. + config SND_AT91_SOC_AFEB9260 tristate SoC Audio support for AFEB9260 board depends on ARCH_AT91 ATMEL_SSC ARCH_AT91 MACH_AFEB9260 SND_ATMEL_SOC diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 41967cc..7784c09 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o +snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o +obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c new file mode 100644 index 000..8ecf29f --- /dev/null +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -0,0 +1,207 @@ +/* + * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards + * that are using WM8731 as codec. + * + * Copyright (C) 2011 Atmel, + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Copyright (C) 2013 Paratronic, + * Richard Genoud richard.gen...@gmail.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ +#include linux/of.h +#include linux/export.h +#include linux/module.h +#include linux/mod_devicetable.h +#include linux/platform_device.h +#include linux/device.h + +#include sound/soc.h +#include sound/soc-dai.h +#include sound/soc-dapm.h + +#include ../codecs/wm8731.h +#include
[PATCH v5 3/7] Documentation: DT: update atmel SSC with DMA binding
As atmel-ssc can be used with DMA, the documentation should be updated. Also, a configuration DMA example is given. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../devicetree/bindings/misc/atmel-ssc.txt | 23 +++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt index 38e51ad..a45ae08 100644 --- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt +++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt @@ -7,9 +7,30 @@ Required properties: - reg: Should contain SSC registers location and length - interrupts: Should contain SSC interrupt -Example: + +Required properties for devices compatible with atmel,at91sam9g45-ssc: +- dmas: DMA specifier, consisting of a phandle to DMA controller node, + the memory interface and SSC DMA channel ID (for tx and rx). + See Documentation/devicetree/bindings/dma/atmel-dma.txt for details. +- dma-names: Must be tx, rx. + +Examples: +- PDC transfer: ssc0: ssc@fffbc000 { compatible = atmel,at91rm9200-ssc; reg = 0xfffbc000 0x4000; interrupts = 14 4 5; }; + +- DMA transfer: +ssc0: ssc@f001 { + compatible = atmel,at91sam9g45-ssc; + reg = 0xf001 0x4000; + interrupts = 28 4 5; + dmas = dma0 1 13, +dma0 1 14; + dma-names = tx, rx; + pinctrl-names = default; + pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; + status = disabled; +}; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 5/7] ARM: AT91: DTS: sam9x5ek: add WM8731 codec
The WM8731 codec on sam9x5ek board is on i2c, address 1A Signed-off-by: Richard Genoud richard.gen...@gmail.com Acked-by: Mark Brown broo...@linaro.org --- arch/arm/boot/dts/at91sam9x5ek.dtsi |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index d107241..e6fb309 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -59,6 +59,11 @@ i2c0: i2c@f801 { status = okay; + + wm8731: wm8731@1a { + compatible = wm8731; + reg = 0x1a; + }; }; pinctrl@f400 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 4/7] ARM: AT91: DTS: sam9x5: add SSC DMA parameters
Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5.dtsi |3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 57d45f5..cf78ac0 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -542,6 +542,9 @@ compatible = atmel,at91sam9g45-ssc; reg = 0xf001 0x4000; interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), + dma0 1 AT91_DMA_CFG_PER_ID(14); + dma-names = tx, rx; pinctrl-names = default; pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; status = disabled; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 6/7] ARM: AT91: DTS: sam9x5ek: enable SSC
Enable the SSC needed for the WM8731 codec Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index e6fb309..f3e83f7 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -95,6 +95,10 @@ watchdog@fe40 { status = okay; }; + + ssc0: ssc@f001 { + status = okay; + }; }; usb0: ohci@0060 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v5 7/7] ARM: AT91: DTS: sam9x5ek: add sound configuration
The sam9x5ek board has 2 jacks: headphone wired on RHPOUT/LHPOUT of the wm8731 line in wired on LLINEIN/RLINEIN of the wm8731 Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi | 15 +++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index f3e83f7..9afe15b 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -113,4 +113,19 @@ status = okay; }; }; + + sound { + compatible = atmel,sam9x5-wm8731-audio; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + }; }; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v4 1/7] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/9 Mark Brown broo...@kernel.org: On Tue, Jul 09, 2013 at 04:25:27PM +0200, Richard Genoud wrote: +/* + * Authorized rates are: + * Rate = MCLK_RATE / (n * 2) + * Where n is in [1..4095] + * (cf register SSC_CMR) + */ +static unsigned int rates[] = { + 8000, + 16000, + 32000, + 48000, + 64000, + 96000, +}; Shouldn't the SSC driver be enforcing this constraint if it comes from the SSC hardware? If the clock is reprogrammable the usual convention for drivers is to not constrain if the clock is set to zero so a machine driver could remove the constraint. Actually, my comment is buggy here (or at least, unrelated to the authorized rates). The MCLK_RATE is the master clock of the wm8731 codec (a 12.288MHz crystal). According to the datasheet of wm8731, when a 12.288 crystal is used, the authorized rates are 8, 32, 48 and 96kHz (I have to remove 16 and 64kHz). So, is this the right place for the rates ? + ret = atmel_ssc_set_audio(0); + if (ret != 0) { + dev_err(pdev-dev, + ASoC: Failed to set SSC 0 for audio: %d\n, ret); + return ret; + } Shouldn't this be a parameter in the DT too? Yes, I'll add that to the DT. + cpu_np = of_parse_phandle(np, atmel,ssc-controller, 0); + if (!cpu_np) { + dev_err(pdev-dev, ssc controller node missing\n); + ret = -EINVAL; + goto out; + } + at91sam9x5ek_dai.cpu_of_node = cpu_np; + at91sam9x5ek_dai.platform_of_node = cpu_np; After all we're looking things up in the DT... + at91sam9x5ek_dai.dai_fmt = snd_soc_of_parse_daifmt(np, atmel,); Is this really something that machines would want to reconfigure? If so why? That's right. There's no point reconfiguring that because I2S is the only possible interface. Thanks for your comments ! Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v4 1/7] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/10 Bo Shen voice.s...@atmel.com: Hi Richard, Hi ! On 7/9/2013 22:25, Richard Genoud wrote: [snip] +#include linux/module.h +#include linux/moduleparam.h +#include linux/kernel.h +#include linux/clk.h +#include linux/timer.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/i2c.h + +#include linux/atmel-ssc.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mach-types.h +#include mach/hardware.h +#include mach/gpio.h + +#include ../codecs/wm8731.h +#include atmel-pcm.h +#include atmel_ssc_dai.h I think some of the header file include is not needed. I keep them as simple as following: ---8--- #include linux/clk.h #include linux/module.h #include linux/of.h #include linux/of_device.h #include linux/pinctrl/consumer.h #include sound/soc.h #include ../codecs/wm8731.h #include atmel_ssc_dai.h ---8--- ooopps ! I forgot to do some cleaning in those after the file rework. Thanks ! +#define MCLK_RATE 12288000 + +#define DRV_NAME sam9x5-snd-wm8731 + +/* + * Authorized rates are: + * Rate = MCLK_RATE / (n * 2) + * Where n is in [1..4095] + * (cf register SSC_CMR) + */ +static unsigned int rates[] = { + 8000, + 16000, + 32000, + 48000, + 64000, + 96000, +}; This is decided by the codec, while not ssc when ssc in slave mode. yes. +static struct snd_pcm_hw_constraint_list hw_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, +}; + [snip] + + at91sam9x5ek_dai.dai_fmt = snd_soc_of_parse_daifmt(np, atmel,); We can put this into at91sam9x5ek_dai directly, not need to parse it then. example as following: ---8--- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM, ---8--- yes, I removed that for the older machine driver, without thinking that much. It's better hardcorded like that. Thanks for your comments ! ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v4 2/7] Documentation: DT: add sam9x5ek-wm8731 machine driver
2013/7/9 Mark Brown broo...@kernel.org: On Tue, Jul 09, 2013 at 04:25:28PM +0200, Richard Genoud wrote: This add the sound DT binding for sam9x5ek-wm8731 machine driver Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 30 Put new binding documents in the same patch that reads them, this makes review easier. ok, I'll squash it with patch 1 + - atmel,audio-routing: A list of the connections between audio components. This needs to be more specific and list the available board specific nodes for routing. For the CODEC you can just refer to the CODEC binding documentation. Ok, I'll do that. + - atmel,format: DAI format. Must be i2s So why not just omit this then? Will be removed. + - atmel,bitclock-master: DAI clock master + - atmel,frame-master: DAI frame master The driver isn't handling these and there's no information on how to set them. They will also go away. Thanks ! ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v4 3/7] Documentation: DT: update atmel SSC with DMA binding
2013/7/9 Mark Brown broo...@kernel.org: On Tue, Jul 09, 2013 at 04:25:29PM +0200, Richard Genoud wrote: - reg: Should contain SSC registers location and length - interrupts: Should contain SSC interrupt +For dma transfer: +- dmas: DMA specifier, consisting of a phandle to DMA controller node, + the memory interface and SSC DMA channel ID (for tx and rx). + See Documentation/devicetree/bindings/dma/atmel-dma.txt for details. +- dma-names: Must be tx, rx. This is added as a required property so... -Example: +Examples: ssc0: ssc@fffbc000 { compatible = atmel,at91rm9200-ssc; reg = 0xfffbc000 0x4000; interrupts = 14 4 5; }; ...this first example is now invalid and should probably just be being extended with the new required properties. Well, I have to rewrite that to make it clearer. The thing is: with atmel,at91rm9200-ssc the SSC doesn't work with DMA. with atmel,at91sam9g45-ssc, the SSC work ONLY with DMA. So the dmas/dma-names properties are only required for g45-ssc, and useless for rm9200-ssc Maybe the best will be to write a paragraph for g45-ssc and another for rm9200-ssc, even if there's some identical lines between them. Thanks ! Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [alsa-devel] [PATCH v2 1/5] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/8 Lars-Peter Clausen l...@metafoo.de: On 07/08/2013 03:29 PM, Richard Genoud wrote: [...] +/* + * Logic for a wm8731 as connected on a at91sam9x5 based board. + */ +static int at91sam9x5ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) +{ [...] + codec_dai-driver-playback.rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; + codec_dai-driver-capture.rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; That's not right. The driver structure is shared between all instances of the codec, a single instance should not modify it. If you need to constrain the list of supported rates use snd_pcm_hw_constraint_list(). Ok, I'll do that. + + /* set the codec system clock for DAC and ADC */ + ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, + MCLK_RATE, SND_SOC_CLOCK_IN); + if (ret 0) { + dev_err(dev, ASoC: Failed to set WM8731 SYSCLK: %d\n, ret); + return ret; + } + + /* signal a DAPM event */ + snd_soc_dapm_sync(dapm); This should not be necessary. ok + return 0; +} Thanks ! -- for me, ck means con kolivas and not calvin klein... does it mean I'm a geek ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v2 1/5] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/8 Mark Brown broo...@kernel.org: On Mon, Jul 08, 2013 at 03:29:49PM +0200, Richard Genoud wrote: + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com The obvious question here is of course if we can use the same driver for both of them. I haven't got a g20 to test that, but that's the goal. For now, g20 is still non-DT, so I think it's best to have a DT-only driver like this one for the 9x5 family (9g15, 9g25, 9x25, 9g35, 9x25). When the g20 will move to DT completely, we can drop sam9g20_wm8731.c and adjust sam9x5_wm8731.c (mainly master clock and widgets it seems) By the way, maybe g45 could use that also (and SAMA5 ?) + codec_dai-driver-playback.rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; + codec_dai-driver-capture.rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; You definitely shouldn't be fiddling with a driver's constant static data. You want to be using snd_pcm_hw_constraint() APIs to set additional constraints intead. Ok, I'll change that. Thanks ! -- for me, ck means con kolivas and not calvin klein... does it mean I'm a geek ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v2 2/5] ARM: AT91: DTS: sam9x5: add SSC DMA parameters
2013/7/8 Mark Brown broo...@kernel.org: On Mon, Jul 08, 2013 at 03:29:50PM +0200, Richard Genoud wrote: Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5.dtsi |3 +++ There was no binding document in your first patch - there should be one for any new DT bindings. The dma binding is documented here Documentation/devicetree/bindings/dma/atmel-dma.txt But you're right, I shoud update Documentation/devicetree/bindings/misc/atmel-ssc.txt. Thanks -- for me, ck means con kolivas and not calvin klein... does it mean I'm a geek ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v2 2/5] ARM: AT91: DTS: sam9x5: add SSC DMA parameters
2013/7/9 Mark Brown broo...@kernel.org: On Tue, Jul 09, 2013 at 10:27:53AM +0200, Richard Genoud wrote: The dma binding is documented here Documentation/devicetree/bindings/dma/atmel-dma.txt But you're right, I shoud update Documentation/devicetree/bindings/misc/atmel-ssc.txt. No, you need to write a binding for this machine driver - the DMA and SSC need to be documented as well but so too does the audio driver that pulls them together with the CODEC. Ok, I understand ! Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v2 1/5] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/9 Mark Brown broo...@kernel.org: On Tue, Jul 09, 2013 at 10:19:45AM +0200, Richard Genoud wrote: 2013/7/8 Mark Brown broo...@kernel.org: The obvious question here is of course if we can use the same driver for both of them. I haven't got a g20 to test that, but that's the goal. I think I do somewhere. For now, g20 is still non-DT, so I think it's best to have a DT-only driver like this one for the 9x5 family (9g15, 9g25, 9x25, 9g35, 9x25). When the g20 will move to DT completely, we can drop sam9g20_wm8731.c and adjust sam9x5_wm8731.c (mainly master clock and widgets it seems) By the way, maybe g45 could use that also (and SAMA5 ?) If this is the goal then this driver needs a more generic name. Hum. I guess we could call it atmel-ssc-sound.c, since the ultimate goal would be to make it codec agnostic, but there's quite some work to achieve that (handle the widgets, mclk and rates by DT). But I really don't know if it's better to keep this name as long as g20 is not supported, and change it after or have a name that is not reflecting what the machine driver is doing right now. Maybe Bo or Nicolas can give their feeling on that (since I'm not Atmel, I don't know every SoC or what their Big Plan is for sound machine drivers) Richard. -- for me, ck means con kolivas and not calvin klein... does it mean I'm a geek ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 0/7] Sound support for at91sam9x5-wm8731 based boards
Hi, This patchset add sound on the at91sam9x5ek board. It's based on Nicolas Ferre's work in the 2.6.39 atmel patch for sam9x5: https://github.com/linux4sam/linux-at91/commit/0aa157c9e71f3abc30fa37eb5c95b392978d It needs Bo Chen's patchset on the generic dmaengine (topic/atmel branch on Mark's sound tree) and the SSC interrupts disabled (cf http://www.spinics.net/lists/arm-kernel/msg256901.html) Outstanding issue: If this machine driver will support more SoCs maybe we should name it differently. It has been tested on at91sam9g35ek, and should work on g15, g25, x25 and x35 also. patches applies on next-20130708 [I let the original signed-off from Nicolas and Uwe in place, I don't know if I should replace them by something like originaly-signed-off-by since the code has been changed.] Changes from v2: * Change atmel,sam9x5-audio-wm8731 to atmel,sam9x5-wm8731-audio for consistency with sam9g20 machine driver. * Use the snd_pcm_hw_constraint() API as suggested by Mark and Lars-Peter. * Remove the unnecessary snd_soc_dapm_sync() call as Lars-Peter suggested. * Add documentation for machine driver DT binding. * Update atmel-ssc DT binding documentation. * Add GPL license instead of just the GPL word (hope that's ok !) Changes from v1-RFC: * drop patches on SSC since Bo Chen already did the work * reorder patches to have the machine driver first * drop code already handled by the ASoC framework * drop unneeded SND_ATMEL_SOC_PDC config selection * use static snd_soc_card and snd_soc_dai_link structures. Best regards, Richard. Nicolas Ferre (1): sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards Richard Genoud (6): Documentation: DT: add sam9x5ek-wm8731 machine driver Documentation: DT: update atmel SSC with DMA binding ARM: AT91: DTS: sam9x5: add SSC DMA parameters ARM: AT91: DTS: sam9x5ek: add WM8731 codec ARM: AT91: DTS: sam9x5ek: add sound configuration ARM: AT91: DTS: sam9x5ek: enable SSC .../devicetree/bindings/misc/atmel-ssc.txt | 24 +- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 30 +++ arch/arm/boot/dts/at91sam9x5.dtsi |3 + arch/arm/boot/dts/at91sam9x5ek.dtsi| 27 +++ sound/soc/atmel/Kconfig| 10 + sound/soc/atmel/Makefile |2 + sound/soc/atmel/sam9x5_wm8731.c| 238 7 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt create mode 100644 sound/soc/atmel/sam9x5_wm8731.c -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 2/7] Documentation: DT: add sam9x5ek-wm8731 machine driver
This add the sound DT binding for sam9x5ek-wm8731 machine driver Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 30 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt diff --git a/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt new file mode 100644 index 000..fd03dfd --- /dev/null +++ b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt @@ -0,0 +1,30 @@ +* Atmel at91sam9x5ek wm8731 audio complex + +Required properties: + - compatible: atmel,at91sam9x5ek-wm8731-audio + - atmel,model: The user-visible name of this sound complex. + - atmel,audio-routing: A list of the connections between audio components. + - atmel,ssc-controller: The phandle of the SSC controller + - atmel,audio-codec: The phandle of the WM8731 audio codec + - atmel,format: DAI format. Must be i2s + - atmel,bitclock-master: DAI clock master + - atmel,frame-master: DAI frame master + +Example: +sound { + compatible = atmel,sam9x5-wm8731-audio; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + atmel,format = i2s; + atmel,bitclock-master; + atmel,frame-master; +}; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 1/7] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. [Richard: this is based on an old patch from Nicolas that I forward ported and reworked to use only device tree] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/Kconfig | 10 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/sam9x5_wm8731.c | 238 +++ 3 files changed, 250 insertions(+) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 1c0b185..9eb8c49 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -33,6 +33,16 @@ config SND_AT91_SOC_SAM9G20_WM8731 Say Y if you want to add support for SoC audio on WM8731-based AT91sam9g20 evaluation board. +config SND_AT91_SOC_SAM9X5_WM8731 + tristate SoC Audio support for WM8731-based at91sam9x5 board + depends on ATMEL_SSC SND_ATMEL_SOC SOC_AT91SAM9X5 + select SND_ATMEL_SOC_SSC + select SND_ATMEL_SOC_DMA + select SND_SOC_WM8731 + help + Say Y if you want to add support for audio SoC on an + at91sam9x5 based board that is using WM8731 codec. + config SND_AT91_SOC_AFEB9260 tristate SoC Audio support for AFEB9260 board depends on ARCH_AT91 ATMEL_SSC ARCH_AT91 MACH_AFEB9260 SND_ATMEL_SOC diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 41967cc..7784c09 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o +snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o +obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c new file mode 100644 index 000..c56e36b --- /dev/null +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -0,0 +1,238 @@ +/* + * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards + * that are using WM8731 as codec. + * + * Copyright (C) 2011 Atmel, + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Copyright (C) 2013 Paratronic, + * Richard Genoud richard.gen...@gmail.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/kernel.h +#include linux/clk.h +#include linux/timer.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/i2c.h + +#include linux/atmel-ssc.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mach-types.h +#include mach/hardware.h +#include mach/gpio.h + +#include ../codecs/wm8731.h +#include atmel-pcm.h +#include atmel_ssc_dai.h + +#define MCLK_RATE 12288000 + +#define DRV_NAME sam9x5-snd-wm8731 + +/* + * Authorized rates are: + * Rate = MCLK_RATE / (n * 2) + * Where n is in [1..4095] + * (cf register SSC_CMR) + */ +static unsigned int rates[] = { + 8000, + 16000, + 32000, + 48000, + 64000, + 96000, +}; + +static struct snd_pcm_hw_constraint_list hw_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, +}; + +/* + * Logic for a wm8731 as connected on a at91sam9x5 based board. + */ +static int at91sam9x5ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai *codec_dai = rtd-codec_dai; + struct device *dev = rtd-dev; + int ret; + + dev_dbg(dev, ASoC: %s called\n, __func__); + + /* set the codec system clock for DAC and ADC */ + ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, +MCLK_RATE, SND_SOC_CLOCK_IN); + if (ret 0) { + dev_err(dev, ASoC: Failed to set WM8731 SYSCLK: %d\n, ret); + return ret; + } + + return 0; +} + +static int sam9x5ek_wm8731_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream-runtime; + + runtime-hw.rate_min = hw_rates.list[0]; + runtime-hw.rate_max = hw_rates.list[hw_rates.count - 1]; + runtime
[PATCH v3 3/7] Documentation: DT: update atmel SSC with DMA binding
As atmel-ssc can be used with DMA, the documentation should be updated. Also, a configuration DMA example is given. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../devicetree/bindings/misc/atmel-ssc.txt | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt index 38e51ad..96958ca 100644 --- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt +++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt @@ -6,10 +6,30 @@ Required properties: - atmel,at91sam9g45-ssc: support dma transfer - reg: Should contain SSC registers location and length - interrupts: Should contain SSC interrupt +For dma transfer: +- dmas: DMA specifier, consisting of a phandle to DMA controller node, + the memory interface and SSC DMA channel ID (for tx and rx). + See Documentation/devicetree/bindings/dma/atmel-dma.txt for details. +- dma-names: Must be tx, rx. -Example: + +Examples: ssc0: ssc@fffbc000 { compatible = atmel,at91rm9200-ssc; reg = 0xfffbc000 0x4000; - interrupts = 14 4 5; + interrupts = 14 IRQ_TYPE_LEVEL_HIGH 5; }; + + +ssc0: ssc@f001 { + compatible = atmel,at91sam9g45-ssc; + reg = 0xf001 0x4000; + interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), +dma0 1 AT91_DMA_CFG_PER_ID(14); + dma-names = tx, rx; + pinctrl-names = default; + pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; + status = disabled; +}; + -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 4/7] ARM: AT91: DTS: sam9x5: add SSC DMA parameters
Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5.dtsi |3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 57d45f5..cf78ac0 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -542,6 +542,9 @@ compatible = atmel,at91sam9g45-ssc; reg = 0xf001 0x4000; interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), + dma0 1 AT91_DMA_CFG_PER_ID(14); + dma-names = tx, rx; pinctrl-names = default; pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; status = disabled; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 5/7] ARM: AT91: DTS: sam9x5ek: add WM8731 codec
The WM8731 codec on sam9x5ek board is on i2c, address 1A Signed-off-by: Richard Genoud richard.gen...@gmail.com Acked-by: Mark Brown broo...@linaro.org --- arch/arm/boot/dts/at91sam9x5ek.dtsi |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index d107241..e6fb309 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -59,6 +59,11 @@ i2c0: i2c@f801 { status = okay; + + wm8731: wm8731@1a { + compatible = wm8731; + reg = 0x1a; + }; }; pinctrl@f400 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 7/7] ARM: AT91: DTS: sam9x5ek: enable SSC
Enable the SSC needed for the WM8731 codec Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index 2bf51cc..0534c58 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -95,6 +95,10 @@ watchdog@fe40 { status = okay; }; + + ssc0: ssc@f001 { + status = okay; + }; }; usb0: ohci@0060 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 6/7] ARM: AT91: DTS: sam9x5ek: add sound configuration
The sam9x5ek board has 2 jacks: headphone wired on RHPOUT/LHPOUT of the wm8731 line in wired on LLINEIN/RLINEIN of the wm8731 Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index e6fb309..2bf51cc 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -109,4 +109,22 @@ status = okay; }; }; + + sound { + compatible = atmel,sam9x5-wm8731-audio; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + atmel,format = i2s; + atmel,bitclock-master; + atmel,frame-master; + }; }; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v3 3/7] Documentation: DT: update atmel SSC with DMA binding
2013/7/9 Richard Genoud richard.gen...@gmail.com: As atmel-ssc can be used with DMA, the documentation should be updated. Also, a configuration DMA example is given. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../devicetree/bindings/misc/atmel-ssc.txt | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt index 38e51ad..96958ca 100644 --- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt +++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt @@ -6,10 +6,30 @@ Required properties: - atmel,at91sam9g45-ssc: support dma transfer - reg: Should contain SSC registers location and length - interrupts: Should contain SSC interrupt +For dma transfer: +- dmas: DMA specifier, consisting of a phandle to DMA controller node, + the memory interface and SSC DMA channel ID (for tx and rx). + See Documentation/devicetree/bindings/dma/atmel-dma.txt for details. +- dma-names: Must be tx, rx. -Example: + +Examples: ssc0: ssc@fffbc000 { compatible = atmel,at91rm9200-ssc; reg = 0xfffbc000 0x4000; - interrupts = 14 4 5; + interrupts = 14 IRQ_TYPE_LEVEL_HIGH 5; maybe I should not use macro in the documentation (not sure if I should or not). }; + + +ssc0: ssc@f001 { + compatible = atmel,at91sam9g45-ssc; + reg = 0xf001 0x4000; + interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), +dma0 1 AT91_DMA_CFG_PER_ID(14); same here + dma-names = tx, rx; + pinctrl-names = default; + pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; + status = disabled; +}; + -- 1.7.10.4 -- for me, ck means con kolivas and not calvin klein... does it mean I'm a geek ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v3 3/7] Documentation: DT: update atmel SSC with DMA binding
2013/7/9 Nicolas Ferre nicolas.fe...@atmel.com: On 09/07/2013 15:19, Richard Genoud : 2013/7/9 Richard Genoud richard.gen...@gmail.com: As atmel-ssc can be used with DMA, the documentation should be updated. Also, a configuration DMA example is given. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../devicetree/bindings/misc/atmel-ssc.txt | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt index 38e51ad..96958ca 100644 --- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt +++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt @@ -6,10 +6,30 @@ Required properties: - atmel,at91sam9g45-ssc: support dma transfer - reg: Should contain SSC registers location and length - interrupts: Should contain SSC interrupt +For dma transfer: +- dmas: DMA specifier, consisting of a phandle to DMA controller node, + the memory interface and SSC DMA channel ID (for tx and rx). + See Documentation/devicetree/bindings/dma/atmel-dma.txt for details. +- dma-names: Must be tx, rx. -Example: + +Examples: ssc0: ssc@fffbc000 { compatible = atmel,at91rm9200-ssc; reg = 0xfffbc000 0x4000; - interrupts = 14 4 5; + interrupts = 14 IRQ_TYPE_LEVEL_HIGH 5; maybe I should not use macro in the documentation (not sure if I should or not). absolutely. ok, thanks, changing that in next version. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 0/7] Sound support for at91sam9x5-wm8731 based boards
[I've just seen that I forgot to cc Uwe to the cover letter, sorry for that.] Hi, This patchset add sound on the at91sam9x5ek board. It's based on Nicolas Ferre's work in the 2.6.39 atmel patch for sam9x5: https://github.com/linux4sam/linux-at91/commit/0aa157c9e71f3abc30fa37eb5c95b392978d It needs Bo Chen's patchset on the generic dmaengine (topic/atmel branch on Mark's sound tree) and the SSC interrupts disabled (cf http://www.spinics.net/lists/arm-kernel/msg256901.html) Outstanding issue: If this machine driver will support more SoCs maybe we should name it differently. It has been tested on at91sam9g35ek, and should work on g15, g25, x25 and x35 also. patches applies on next-20130708 [I let the original signed-off from Nicolas and Uwe in place, I don't know if I should replace them by something like originaly-signed-off-by since the code has been changed.] Changes from v3: * Remove the use of macros in device tree documentation. Changes from v2: * Change atmel,sam9x5-audio-wm8731 to atmel,sam9x5-wm8731-audio for consistency with sam9g20 machine driver. * Use the snd_pcm_hw_constraint() API as suggested by Mark and Lars-Peter. * Remove the unnecessary snd_soc_dapm_sync() call as Lars-Peter suggested. * Add documentation for machine driver DT binding. * Update atmel-ssc DT binding documentation. * Add GPL license instead of just the GPL word (hope that's ok !) Changes from v1-RFC: * drop patches on SSC since Bo Chen already did the work * reorder patches to have the machine driver first * drop code already handled by the ASoC framework * drop unneeded SND_ATMEL_SOC_PDC config selection * use static snd_soc_card and snd_soc_dai_link structures. Best regards, Richard. Nicolas Ferre (1): sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards Richard Genoud (6): Documentation: DT: add sam9x5ek-wm8731 machine driver Documentation: DT: update atmel SSC with DMA binding ARM: AT91: DTS: sam9x5: add SSC DMA parameters ARM: AT91: DTS: sam9x5ek: add WM8731 codec ARM: AT91: DTS: sam9x5ek: add sound configuration ARM: AT91: DTS: sam9x5ek: enable SSC .../devicetree/bindings/misc/atmel-ssc.txt | 20 +- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 30 +++ arch/arm/boot/dts/at91sam9x5.dtsi |3 + arch/arm/boot/dts/at91sam9x5ek.dtsi| 27 +++ sound/soc/atmel/Kconfig| 10 + sound/soc/atmel/Makefile |2 + sound/soc/atmel/sam9x5_wm8731.c| 238 7 files changed, 329 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt create mode 100644 sound/soc/atmel/sam9x5_wm8731.c -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 3/7] Documentation: DT: update atmel SSC with DMA binding
As atmel-ssc can be used with DMA, the documentation should be updated. Also, a configuration DMA example is given. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../devicetree/bindings/misc/atmel-ssc.txt | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt index 38e51ad..7c320da 100644 --- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt +++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt @@ -6,10 +6,28 @@ Required properties: - atmel,at91sam9g45-ssc: support dma transfer - reg: Should contain SSC registers location and length - interrupts: Should contain SSC interrupt +For dma transfer: +- dmas: DMA specifier, consisting of a phandle to DMA controller node, + the memory interface and SSC DMA channel ID (for tx and rx). + See Documentation/devicetree/bindings/dma/atmel-dma.txt for details. +- dma-names: Must be tx, rx. -Example: +Examples: ssc0: ssc@fffbc000 { compatible = atmel,at91rm9200-ssc; reg = 0xfffbc000 0x4000; interrupts = 14 4 5; }; + + +ssc0: ssc@f001 { + compatible = atmel,at91sam9g45-ssc; + reg = 0xf001 0x4000; + interrupts = 28 4 5; + dmas = dma0 1 13, +dma0 1 14; + dma-names = tx, rx; + pinctrl-names = default; + pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; + status = disabled; +}; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 2/7] Documentation: DT: add sam9x5ek-wm8731 machine driver
This add the sound DT binding for sam9x5ek-wm8731 machine driver Signed-off-by: Richard Genoud richard.gen...@gmail.com --- .../bindings/sound/atmel-sam9x5-wm8731-audio.txt | 30 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt diff --git a/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt new file mode 100644 index 000..fd03dfd --- /dev/null +++ b/Documentation/devicetree/bindings/sound/atmel-sam9x5-wm8731-audio.txt @@ -0,0 +1,30 @@ +* Atmel at91sam9x5ek wm8731 audio complex + +Required properties: + - compatible: atmel,at91sam9x5ek-wm8731-audio + - atmel,model: The user-visible name of this sound complex. + - atmel,audio-routing: A list of the connections between audio components. + - atmel,ssc-controller: The phandle of the SSC controller + - atmel,audio-codec: The phandle of the WM8731 audio codec + - atmel,format: DAI format. Must be i2s + - atmel,bitclock-master: DAI clock master + - atmel,frame-master: DAI frame master + +Example: +sound { + compatible = atmel,sam9x5-wm8731-audio; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + atmel,format = i2s; + atmel,bitclock-master; + atmel,frame-master; +}; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 1/7] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. [Richard: this is based on an old patch from Nicolas that I forward ported and reworked to use only device tree] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/Kconfig | 10 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/sam9x5_wm8731.c | 238 +++ 3 files changed, 250 insertions(+) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 1c0b185..9eb8c49 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -33,6 +33,16 @@ config SND_AT91_SOC_SAM9G20_WM8731 Say Y if you want to add support for SoC audio on WM8731-based AT91sam9g20 evaluation board. +config SND_AT91_SOC_SAM9X5_WM8731 + tristate SoC Audio support for WM8731-based at91sam9x5 board + depends on ATMEL_SSC SND_ATMEL_SOC SOC_AT91SAM9X5 + select SND_ATMEL_SOC_SSC + select SND_ATMEL_SOC_DMA + select SND_SOC_WM8731 + help + Say Y if you want to add support for audio SoC on an + at91sam9x5 based board that is using WM8731 codec. + config SND_AT91_SOC_AFEB9260 tristate SoC Audio support for AFEB9260 board depends on ARCH_AT91 ATMEL_SSC ARCH_AT91 MACH_AFEB9260 SND_ATMEL_SOC diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 41967cc..7784c09 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o +snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o +obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c new file mode 100644 index 000..c56e36b --- /dev/null +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -0,0 +1,238 @@ +/* + * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards + * that are using WM8731 as codec. + * + * Copyright (C) 2011 Atmel, + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Copyright (C) 2013 Paratronic, + * Richard Genoud richard.gen...@gmail.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/kernel.h +#include linux/clk.h +#include linux/timer.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/i2c.h + +#include linux/atmel-ssc.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mach-types.h +#include mach/hardware.h +#include mach/gpio.h + +#include ../codecs/wm8731.h +#include atmel-pcm.h +#include atmel_ssc_dai.h + +#define MCLK_RATE 12288000 + +#define DRV_NAME sam9x5-snd-wm8731 + +/* + * Authorized rates are: + * Rate = MCLK_RATE / (n * 2) + * Where n is in [1..4095] + * (cf register SSC_CMR) + */ +static unsigned int rates[] = { + 8000, + 16000, + 32000, + 48000, + 64000, + 96000, +}; + +static struct snd_pcm_hw_constraint_list hw_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, +}; + +/* + * Logic for a wm8731 as connected on a at91sam9x5 based board. + */ +static int at91sam9x5ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai *codec_dai = rtd-codec_dai; + struct device *dev = rtd-dev; + int ret; + + dev_dbg(dev, ASoC: %s called\n, __func__); + + /* set the codec system clock for DAC and ADC */ + ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, +MCLK_RATE, SND_SOC_CLOCK_IN); + if (ret 0) { + dev_err(dev, ASoC: Failed to set WM8731 SYSCLK: %d\n, ret); + return ret; + } + + return 0; +} + +static int sam9x5ek_wm8731_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream-runtime; + + runtime-hw.rate_min = hw_rates.list[0]; + runtime-hw.rate_max = hw_rates.list[hw_rates.count - 1]; + runtime
[PATCH v4 5/7] ARM: AT91: DTS: sam9x5ek: add WM8731 codec
The WM8731 codec on sam9x5ek board is on i2c, address 1A Signed-off-by: Richard Genoud richard.gen...@gmail.com Acked-by: Mark Brown broo...@linaro.org --- arch/arm/boot/dts/at91sam9x5ek.dtsi |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index d107241..e6fb309 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -59,6 +59,11 @@ i2c0: i2c@f801 { status = okay; + + wm8731: wm8731@1a { + compatible = wm8731; + reg = 0x1a; + }; }; pinctrl@f400 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 6/7] ARM: AT91: DTS: sam9x5ek: add sound configuration
The sam9x5ek board has 2 jacks: headphone wired on RHPOUT/LHPOUT of the wm8731 line in wired on LLINEIN/RLINEIN of the wm8731 Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index e6fb309..2bf51cc 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -109,4 +109,22 @@ status = okay; }; }; + + sound { + compatible = atmel,sam9x5-wm8731-audio; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + atmel,format = i2s; + atmel,bitclock-master; + atmel,frame-master; + }; }; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 4/7] ARM: AT91: DTS: sam9x5: add SSC DMA parameters
Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5.dtsi |3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 57d45f5..cf78ac0 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -542,6 +542,9 @@ compatible = atmel,at91sam9g45-ssc; reg = 0xf001 0x4000; interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), + dma0 1 AT91_DMA_CFG_PER_ID(14); + dma-names = tx, rx; pinctrl-names = default; pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; status = disabled; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 7/7] ARM: AT91: DTS: sam9x5ek: enable SSC
Enable the SSC needed for the WM8731 codec Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index 2bf51cc..0534c58 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -95,6 +95,10 @@ watchdog@fe40 { status = okay; }; + + ssc0: ssc@f001 { + status = okay; + }; }; usb0: ohci@0060 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v4 0/7] Sound support for at91sam9x5-wm8731 based boards
2013/7/9 Mark Brown broo...@kernel.org: On Tue, Jul 09, 2013 at 04:25:26PM +0200, Richard Genoud wrote: [I've just seen that I forgot to cc Uwe to the cover letter, sorry for that.] This is the second or third copy of this patch set I've been sent *today*. Worse, everything seems to be being sent in reply to the same thread increasing the nesting substantially. Please slow down, it's flooding my mailbox and discouraging me from looking since it seems likely that there will just be another resend. Sorry Mark, I didn't want to be pushy... I still need to learn what should and what shouldn't be done on a linux-ML Best regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 08/13] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/8 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/5/2013 23:15, Richard Genoud wrote: + card-dev = pdev-dev; + card-owner = THIS_MODULE; + card-dai_link = dai; + card-num_links = 1; + dai-name = WM8731; + dai-stream_name = WM8731 PCM; + dai-codec_dai_name = wm8731-hifi; + dai-init = at91sam9x5ek_wm8731_init; + card-dapm_widgets = at91sam9x5ek_dapm_widgets; + card-num_dapm_widgets = ARRAY_SIZE(at91sam9x5ek_dapm_widgets); Will keep these as snd_soc_card and snd_soc_dai_link structure separately? I don't really understand what you mean here. do you mean that something like that will more explicit ? : + card-dai_link[0].name = WM8731; + card-dai_link[0].stream_name = WM8731 PCM; + card-dai_link[0].codec_dai_name = wm8731-hifi; + card-dai_link[0].init = at91sam9x5ek_wm8731_init; I mean using structure to define snd_soc_card and snd_soc_dai_link, look like: struct snd_soc_dai_link dai_link_name = { .name = xxx, .stream_name = xxx, ... }; struct snd_soc_card card_name = { .name = .ower = THIS_MODULE, .dai_link = dai_link_name, ... }; In this way, I think it will be more clear than put them in code. ok, got it ! Thanks ! Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v2 0/5] Sound support for at91sam9x5-wm8731 based boards
Hi, This patchset add sound on the at91sam9x5ek board. It's based on Nicolas Ferre's work in the 2.6.39 atmel patch for sam9x5: https://github.com/linux4sam/linux-at91/commit/0aa157c9e71f3abc30fa37eb5c95b392978d It needs Bo Chen's patchset on the generic dmaengine (topic/atmel branch on Mark's sound tree) and the SSC interrupts disabled (cf http://www.spinics.net/lists/arm-kernel/msg256901.html) Tested on at91sam9g35ek. patches applies on next-20130708 [I let the original signed-off from Nicolas and Uwe in place, I don't know if I should replace them by something like originaly-signed-off-by since the code has been changed.] [Sorry if it's too late for 3.11] Changes from V1-RFC: * drop patches on SSC since Bo Chen already did the work * reorder patches to have the machine driver first * drop code already handled by the ASoC framework * drop unneeded SND_ATMEL_SOC_PDC config selection * use static snd_soc_card and snd_soc_dai_link structures. Best regards, Richard. Nicolas Ferre (1): sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards Richard Genoud (4): ARM: AT91: DTS: sam9x5: add SSC DMA parameters ARM: AT91: DTS: sam9x5ek: add WM8731 codec ARM: AT91: DTS: sam9x5ek: add sound configuration ARM: AT91: DTS: sam9x5ek: enable SSC arch/arm/boot/dts/at91sam9x5.dtsi |3 + arch/arm/boot/dts/at91sam9x5ek.dtsi | 27 + sound/soc/atmel/Kconfig | 10 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/sam9x5_wm8731.c | 206 +++ 5 files changed, 248 insertions(+) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v2 2/5] ARM: AT91: DTS: sam9x5: add SSC DMA parameters
Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5.dtsi |3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 57d45f5..cf78ac0 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -542,6 +542,9 @@ compatible = atmel,at91sam9g45-ssc; reg = 0xf001 0x4000; interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), + dma0 1 AT91_DMA_CFG_PER_ID(14); + dma-names = tx, rx; pinctrl-names = default; pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; status = disabled; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v2 1/5] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. [Richard: this is based on an old patch from Nicolas that I forward ported and reworked to use only device tree] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/Kconfig | 10 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/sam9x5_wm8731.c | 206 +++ 3 files changed, 218 insertions(+) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 1c0b185..9eb8c49 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -33,6 +33,16 @@ config SND_AT91_SOC_SAM9G20_WM8731 Say Y if you want to add support for SoC audio on WM8731-based AT91sam9g20 evaluation board. +config SND_AT91_SOC_SAM9X5_WM8731 + tristate SoC Audio support for WM8731-based at91sam9x5 board + depends on ATMEL_SSC SND_ATMEL_SOC SOC_AT91SAM9X5 + select SND_ATMEL_SOC_SSC + select SND_ATMEL_SOC_DMA + select SND_SOC_WM8731 + help + Say Y if you want to add support for audio SoC on an + at91sam9x5 based board that is using WM8731 codec. + config SND_AT91_SOC_AFEB9260 tristate SoC Audio support for AFEB9260 board depends on ARCH_AT91 ATMEL_SSC ARCH_AT91 MACH_AFEB9260 SND_ATMEL_SOC diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 41967cc..7784c09 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o +snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o +obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c new file mode 100644 index 000..3e5a9f6 --- /dev/null +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -0,0 +1,206 @@ +/* + * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards + * that are using WM8731 as codec. + * + * Copyright (C) 2011 Atmel, + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com + * + * GPL + */ +#include linux/module.h +#include linux/moduleparam.h +#include linux/kernel.h +#include linux/clk.h +#include linux/timer.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/i2c.h + +#include linux/atmel-ssc.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mach-types.h +#include mach/hardware.h +#include mach/gpio.h + +#include ../codecs/wm8731.h +#include atmel-pcm.h +#include atmel_ssc_dai.h + +#define MCLK_RATE 12288000 + +#define DRV_NAME sam9x5-snd-wm8731 + +/* + * Logic for a wm8731 as connected on a at91sam9x5 based board. + */ +static int at91sam9x5ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd-codec; + struct snd_soc_dai *codec_dai = rtd-codec_dai; + struct snd_soc_dapm_context *dapm = codec-dapm; + struct device *dev = rtd-dev; + int ret; + + dev_dbg(dev, ASoC: %s called\n, __func__); + + codec_dai-driver-playback.rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; + codec_dai-driver-capture.rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; + + /* set the codec system clock for DAC and ADC */ + ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, +MCLK_RATE, SND_SOC_CLOCK_IN); + if (ret 0) { + dev_err(dev, ASoC: Failed to set WM8731 SYSCLK: %d\n, ret); + return ret; + } + + /* signal a DAPM event */ + snd_soc_dapm_sync(dapm); + return 0; +} + +/* + * Audio paths on at91sam9x5ek board: + * + * |A| | | ---R Headphone Jack + * |T| \| WM | ---L--/ + * |9| --- CLK -- | 8751 | --R- Line In Jack + * |1| | | --L--/ + */ +static const struct snd_soc_dapm_widget at91sam9x5ek_dapm_widgets[] = { + SND_SOC_DAPM_HP(Headphone Jack, NULL), + SND_SOC_DAPM_LINE(Line In Jack, NULL), +}; + +static struct snd_soc_dai_link at91sam9x5ek_dai
[PATCH v2 3/5] ARM: AT91: DTS: sam9x5ek: add WM8731 codec
The WM8731 codec on sam9x5ek board is on i2c, address 1A Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index d107241..e6fb309 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -59,6 +59,11 @@ i2c0: i2c@f801 { status = okay; + + wm8731: wm8731@1a { + compatible = wm8731; + reg = 0x1a; + }; }; pinctrl@f400 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v2 5/5] ARM: AT91: DTS: sam9x5ek: enable SSC
Enable the SSC needed for the WM8731 codec Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index bd0f7b8..6684d4b 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -95,6 +95,10 @@ watchdog@fe40 { status = okay; }; + + ssc0: ssc@f001 { + status = okay; + }; }; usb0: ohci@0060 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v2 4/5] ARM: AT91: DTS: sam9x5ek: add sound configuration
The sam9x5ek board has 2 jacks: headphone wired on RHPOUT/LHPOUT of the wm8731 line in wired on LLINEIN/RLINEIN of the wm8731 Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index e6fb309..bd0f7b8 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -109,4 +109,22 @@ status = okay; }; }; + + sound { + compatible = atmel,sam9x5-audio-wm8731; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + atmel,format = i2s; + atmel,bitclock-master; + atmel,frame-master; + }; }; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
2013/7/5 Bo Shen voice.s...@atmel.com: Yes, I aware this issue. Actually the system not hang, the resource all are occupied by the interrupt. This because, we enable the interrupt, when once interrupt occur, I try many methods to clear it, however we can not clear it. So, it generates the interrupt all the time. It seems the system hang. Temp solution: not enable the interrupt. use the following patch to disable the interrupt. ---8--- diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 0ecf356..bb53dea 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -649,7 +649,7 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream, dma_params = ssc_p-dma_params[dir]; ssc_writel(ssc_p-ssc-regs, CR, dma_params-mask-ssc_enable); - ssc_writel(ssc_p-ssc-regs, IER, dma_params-mask-ssc_error); + ssc_writel(ssc_p-ssc-regs, IDR, dma_params-mask-ssc_error); pr_debug(%s enabled SSC_SR=0x%08x\n, dir ? receive : transmit, ---8--- BTW, I am checking this with our IP team, if find the real solution, I will fix it. ok, I'll rebase my patches on that. Thanks ! Best Regards, Richard ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 08/13] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/2 Bo Shen voice.s...@atmel.com: Hi Richard, Will move this patch before 5, 6, 7? yes, you're right. On 7/1/2013 16:39, Richard Genoud wrote: From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. [Richard: this is based on an old patch from Nicolas that I forward ported and reworked to use only device tree] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/Kconfig | 12 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/sam9x5_wm8731.c | 232 +++ 3 files changed, 246 insertions(+) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 3fdd87f..f24d601 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -13,6 +13,7 @@ config SND_ATMEL_SOC_PDC config SND_ATMEL_SOC_DMA tristate depends on SND_ATMEL_SOC + select SND_SOC_DMAENGINE_PCM config SND_ATMEL_SOC_SSC tristate @@ -32,6 +33,17 @@ config SND_AT91_SOC_SAM9G20_WM8731 Say Y if you want to add support for SoC audio on WM8731-based AT91sam9g20 evaluation board. +config SND_AT91_SOC_SAM9X5_WM8731 + tristate SoC Audio support for WM8731-based at91sam9x5 board + depends on ATMEL_SSC SND_ATMEL_SOC SOC_AT91SAM9X5 + select SND_ATMEL_SOC_SSC + select SND_ATMEL_SOC_DMA + select SND_ATMEL_SOC_PDC Not need to select SND_ATMEL_SOC_PDC ok, I'll drop this + select SND_SOC_WM8731 + help + Say Y if you want to add support for audio SoC on an + at91sam9x5 based board that is using WM8731 codec. + config SND_AT91_SOC_AFEB9260 tristate SoC Audio support for AFEB9260 board depends on ARCH_AT91 ATMEL_SSC ARCH_AT91 MACH_AFEB9260 SND_ATMEL_SOC diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 41967cc..7784c09 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o +snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o +obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c new file mode 100644 index 000..83ca457 --- /dev/null +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -0,0 +1,232 @@ +/* + * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards + * that are using WM8731 as codec. + * + * Copyright (C) 2011 Atmel, + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com + * + * GPL + */ +#include linux/module.h +#include linux/moduleparam.h +#include linux/kernel.h +#include linux/clk.h +#include linux/timer.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/i2c.h + +#include linux/atmel-ssc.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mach-types.h +#include mach/hardware.h +#include mach/gpio.h + +#include ../codecs/wm8731.h +#include atmel-pcm.h +#include atmel_ssc_dai.h + +#define MCLK_RATE 12288000 + +#define DRV_NAME sam9x5-snd-wm8731 + +/* + * Audio paths on at91sam9x5ek board: + * + * |A| | | ---R Headphone Jack + * |T| \| WM | ---L--/ + * |9| --- CLK -- | 8751 | --R- Line In Jack + * |1| | | --L--/ + */ +static const struct snd_soc_dapm_widget at91sam9x5ek_dapm_widgets[] = { + SND_SOC_DAPM_HP(Headphone Jack, NULL), + SND_SOC_DAPM_LINE(Line In Jack, NULL), +}; + +/* + * Logic for a wm8731 as connected on a at91sam9x5 based board. + */ +static int at91sam9x5ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd-codec; + struct snd_soc_dai *codec_dai = rtd-codec_dai; + struct snd_soc_dapm_context *dapm = codec-dapm; + struct device *dev = rtd-dev; + int ret; + + dev_dbg(dev, ASoC: at91sam9x5ek_wm8731_init() called\n); + + /* +* remove some not supported rates in relation with clock +* provided to the wm8731 codec +*/ + switch (MCLK_RATE) { + case 12288000: + codec_dai-driver-playback.rates
Re: [RFC PATCH 02/13] misc: atmel_ssc: keep the count of pdev-id
2013/7/2 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/1/2013 16:39, Richard Genoud wrote: With device tree, pdev-id is always -1, so we introduce a local counter. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- drivers/misc/atmel-ssc.c |7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 3afbd82..d1ec5ab 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -173,6 +173,12 @@ out: return err; } +/* counter of ssc devive instances. + * With device tree pdev-id is always -1, so we have to keep the + * count ourselves + */ +static int ssc_device_id; Do we really need this? If Yes, would it better to get from device through of_alias_get_id? you're right, it seems that we don't need that anymore. thanks ! Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 03/13] ARM: at91: DTS: sam9x5: add clock for SSC DT entry
2013/7/2 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/1/2013 16:39, Richard Genoud wrote: Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/mach-at91/at91sam9x5.c |1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c index 2abee66..191eb4b 100644 --- a/arch/arm/mach-at91/at91sam9x5.c +++ b/arch/arm/mach-at91/at91sam9x5.c @@ -233,6 +233,7 @@ static struct clk_lookup periph_clocks_lookups[] = { CLKDEV_CON_DEV_ID(mci_clk, f000c000.mmc, mmc1_clk), CLKDEV_CON_DEV_ID(dma_clk, ec00.dma-controller, dma0_clk), CLKDEV_CON_DEV_ID(dma_clk, ee00.dma-controller, dma1_clk), + CLKDEV_CON_DEV_ID(pclk, at91sam9g45_ssc.0, ssc_clk), Actually, we don't use this anymore. Am I right? correct ! I'll drop it. Thanks, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 08/13] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
2013/7/5 Mark Brown broo...@kernel.org: On Fri, Jul 05, 2013 at 05:15:05PM +0200, Richard Genoud wrote: 2013/7/2 Bo Shen voice.s...@atmel.com: From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. Always CC relevant maintainers and mailing lists on patches... Sorry Mark, I'll double check that on the next version. Thanks ! Best Regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
2013/7/4 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/3/2013 23:51, Richard Genoud wrote: but there's a violent hang (kernel stops, no trace) when I try the record : arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav last thing I see is : dma dma0chan3: atc_control (3) I don't meet this issue. Playback and recording works well on my side on at91sam9g35ek board. I'll try to trace that. I think it's DMA related. the last thing done by the kernel is: i2c i2c-0: i2c_outb: 0x34 A i2c i2c-0: i2c_outb: 0x0c A i2c i2c-0: i2c_outb: 0x5a A meaning: enable power on, LINE IN, ADC, OSC, on the WM8731 so, after that, data is comming from the codec to the SSC and then is handled by the DMA. there must be something nasty on the DMA bus to hang everything like that... Will you try i2c without DMA support to test this issue? Ok, I nailed it ! To be sure we are on the same base, here is what I have done: onto next-20130704: - your 5 patches: ASoC: atmel_ssc_dai: move set dma data to startup callback ASoC: atmel_ssc_dai: add error mask define ASoC: atmel-pcm-dma: move prepare for dma to dai prepare ARM: atmel-ssc: change phybase type to dma_addr_t ASoC: atmel-pcm: use generic dmaengine framework - my patches 4-8: ARM: at91: DTS: sam9x5: add SSC DMA parameters ARM: AT91: DTS: sam9x5ek: add WM8731 codec ARM: AT91: DTS: sam9x5ek: add sound configuration ARM: AT91: DTS: sam9x5ek: enable SSC sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards To be sure that dma-I2c doesn't disturb something, I use i2c gpio bitbang: diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index 6684d4b..53a991e 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -57,15 +57,6 @@ status = okay; }; - i2c0: i2c@f801 { - status = okay; - - wm8731: wm8731@1a { - compatible = wm8731; - reg = 0x1a; - }; - }; - pinctrl@f400 { mmc0 { pinctrl_board_mmc0: mmc0-board { @@ -114,6 +105,15 @@ }; }; + i2c@0 { + status = okay; + + wm8731: wm8731@1a { + compatible = wm8731; + reg = 0x1a; + }; + }; + sound { compatible = atmel,sam9x5-audio-wm8731; with that configuration, it hangs when I do a: arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav Now, if I remove the overrun error on ssc in rx_mask: diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 0ecf356..c04e825 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -83,7 +83,6 @@ static struct atmel_ssc_mask ssc_rx_mask = { .ssc_disable= SSC_BIT(CR_RXDIS), .ssc_endx = SSC_BIT(SR_ENDRX), .ssc_endbuf = SSC_BIT(SR_RXBUFF), - .ssc_error = SSC_BIT(SR_OVRUN), .pdc_enable = ATMEL_PDC_RXTEN, .pdc_disable= ATMEL_PDC_RXTDIS, }; It doesn't hang any more doing a simple record. BUT it still hangs if we do record and play at the same time. Removing the overrun on tx_mask prevent the hang: diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 0ecf356..41e15c2 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -73,7 +73,6 @@ static struct atmel_ssc_mask ssc_tx_mask = { .ssc_disable= SSC_BIT(CR_TXDIS), .ssc_endx = SSC_BIT(SR_ENDTX), .ssc_endbuf = SSC_BIT(SR_TXBUFE), - .ssc_error = SSC_BIT(SR_OVRUN), .pdc_enable = ATMEL_PDC_TXTEN, .pdc_disable= ATMEL_PDC_TXTDIS, }; i.e. when I revert ASoC: atmel_ssc_dai: add error mask define, I don't see any hang. Could you test and confirm that behaviour please ? I attached a the (simple) .config I used for the tests. PS: I hope the patches won't be mangled by gmail... Best regards, Richard. snd_9x5_defconfig Description: Binary data ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
2013/7/2 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/2/2013 16:13, Richard Genoud wrote: Please hold on of this, as to the ASoC dmaengine will deal with this. So, we not need do it manually. Now, I am working on it. And will send out the patch soon after testing OK. Ok, I stay tuned ! I think you can go on working with the two patches I send just now. [1]: ASoC: atmel_ssc_dai: move set dma data to startup callback https://patchwork.kernel.org/patch/2811241/ [2]: ASoC: atmel-pcm: use generic dmaengine framework https://patchwork.kernel.org/patch/2811261/ I use your patches 4 ~ 8 do a quick testing, it works. Please note the name of asound.state under /etc in your rootfs should the same with atmel,model in patch 6. Thanks for testing ! I was just doing the same test, it works with aplay -Dplug:default good_music.wav but there's a violent hang (kernel stops, no trace) when I try the record : arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav last thing I see is : dma dma0chan3: atc_control (3) I'll try to trace that. Best regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
2013/7/3 Richard Genoud richard.gen...@gmail.com: 2013/7/2 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/2/2013 16:13, Richard Genoud wrote: Please hold on of this, as to the ASoC dmaengine will deal with this. So, we not need do it manually. Now, I am working on it. And will send out the patch soon after testing OK. Ok, I stay tuned ! I think you can go on working with the two patches I send just now. [1]: ASoC: atmel_ssc_dai: move set dma data to startup callback https://patchwork.kernel.org/patch/2811241/ [2]: ASoC: atmel-pcm: use generic dmaengine framework https://patchwork.kernel.org/patch/2811261/ I use your patches 4 ~ 8 do a quick testing, it works. Please note the name of asound.state under /etc in your rootfs should the same with atmel,model in patch 6. Thanks for testing ! I was just doing the same test, it works with aplay -Dplug:default good_music.wav but there's a violent hang (kernel stops, no trace) when I try the record : arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav last thing I see is : dma dma0chan3: atc_control (3) I'll try to trace that. I think it's DMA related. the last thing done by the kernel is: i2c i2c-0: i2c_outb: 0x34 A i2c i2c-0: i2c_outb: 0x0c A i2c i2c-0: i2c_outb: 0x5a A meaning: enable power on, LINE IN, ADC, OSC, on the WM8731 so, after that, data is comming from the codec to the SSC and then is handled by the DMA. there must be something nasty on the DMA bus to hang everything like that... Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
2013/7/2 Bo Shen voice.s...@atmel.com: Hi Richard, On 7/1/2013 16:39, Richard Genoud wrote: The ssc device has to fill the at_dma_slave structure with the device tree informations. Doing a of_dma_request_slave_channel()+dma_release_channel() for that seems wrong (or at least not very clean). Please hold on of this, as to the ASoC dmaengine will deal with this. So, we not need do it manually. Now, I am working on it. And will send out the patch soon after testing OK. Ok, I stay tuned ! Thanks ! Best regards, Richard ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
The ssc device has to fill the at_dma_slave structure with the device tree informations. Doing a of_dma_request_slave_channel()+dma_release_channel() for that seems wrong (or at least not very clean). Signed-off-by: Richard Genoud richard.gen...@gmail.com --- drivers/misc/atmel-ssc.c| 56 +++ include/linux/atmel-ssc.h |2 ++ include/linux/platform_data/dma-atmel.h |2 ++ 3 files changed, 60 insertions(+) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index f7b90661..3afbd82 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -19,7 +19,9 @@ #include linux/module.h #include linux/of.h +#include linux/of_dma.h #include linux/pinctrl/consumer.h +#include linux/platform_data/dma-atmel.h /* Serialize access to ssc_list and user count */ static DEFINE_SPINLOCK(user_lock); @@ -127,12 +129,57 @@ static inline const struct atmel_ssc_platform_data * __init platform_get_device_id(pdev)-driver_data; } +static int atmel_ssc_get_dma_data(struct device_node *np, + struct at_dma_slave *sdata) +{ + struct dma_chan *chan; + struct at_dma_slave *rx_data; + int err = -1; + + /* +* FIXME: this is clearly not the right way to do it. +* In order to fill struct at_dma_slave with both rx and tx data, +* we request and release both channels. +* Et voila ! We've got all the whole structure ! +* upside: it works(R) +* downside: feels wrong, dirty, not optimized... +*/ + chan = of_dma_request_slave_channel(np, tx); + if (!chan) + return err; + + if (chan-private) + memcpy(sdata, chan-private, sizeof(*sdata)); + else + goto out; + + dma_release_channel(chan); + + chan = of_dma_request_slave_channel(np, rx); + if (!chan) + goto out; + + if (chan-private) { + rx_data = chan-private; + sdata-cfg = ~(ATC_SRC_PER_MSB(0xff) | ATC_SRC_PER(0xff)); + sdata-cfg |= ATC_GET_SRC_ID(rx_data-cfg); + err = 0; + } + +out: + if (chan) + dma_release_channel(chan); + + return err; +} + static int ssc_probe(struct platform_device *pdev) { struct resource *regs; struct ssc_device *ssc; const struct atmel_ssc_platform_data *plat_dat; struct pinctrl *pinctrl; + struct device_node *of = pdev-dev.of_node; pinctrl = devm_pinctrl_get_select_default(pdev-dev); if (IS_ERR(pinctrl)) { @@ -166,6 +213,15 @@ static int ssc_probe(struct platform_device *pdev) return -ENXIO; } + /* populate platform_data from device tree */ + if (ssc-pdata ssc-pdata-use_dma of) { + if (atmel_ssc_get_dma_data(of, ssc-pdata-dma_slave)) { + dev_err(pdev-dev, could not get DMA\n); + return -EINVAL; + } + } + ssc-pdev-dev.platform_data = ssc-pdata-dma_slave; + /* disable all interrupts */ clk_prepare_enable(ssc-clk); ssc_writel(ssc-regs, IDR, -1); diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h index deb0ae5..80c83ee 100644 --- a/include/linux/atmel-ssc.h +++ b/include/linux/atmel-ssc.h @@ -1,12 +1,14 @@ #ifndef __INCLUDE_ATMEL_SSC_H #define __INCLUDE_ATMEL_SSC_H +#include linux/platform_data/dma-atmel.h #include linux/platform_device.h #include linux/list.h #include linux/io.h struct atmel_ssc_platform_data { int use_dma; + struct at_dma_slave dma_slave; }; struct ssc_device { diff --git a/include/linux/platform_data/dma-atmel.h b/include/linux/platform_data/dma-atmel.h index e95f19c..0d8b9d6 100644 --- a/include/linux/platform_data/dma-atmel.h +++ b/include/linux/platform_data/dma-atmel.h @@ -44,11 +44,13 @@ struct at_dma_slave { #defineATC_SRC_H2SEL_SW(0x0 9) #defineATC_SRC_H2SEL_HW(0x1 9) #defineATC_SRC_PER_MSB(h) (ATC_PER_MSB(h) 10) /* Channel src rq (most significant bits) */ +#define ATC_GET_SRC_ID(h) h) 6) 0x3U) | ((h) 0xFU)) /* Retrieve channel src id */ #defineATC_DST_REP (0x1 12) /* Destination Replay Mod */ #defineATC_DST_H2SEL (0x1 13) /* Destination Handshaking Mod */ #defineATC_DST_H2SEL_SW(0x0 13) #defineATC_DST_H2SEL_HW(0x1 13) #defineATC_DST_PER_MSB(h) (ATC_PER_MSB(h) 14) /* Channel dst rq (most significant bits) */ +#define ATC_GET_DST_ID(h) h) 10) 0x3U) | (((h) 4) 0xFU)) /* Retrieve channel dst id */ #defineATC_SOD (0x1 16) /* Stop On Done */ #defineATC_LOCK_IF (0x1 20) /* Interface Lock */ #define
[RFC PATCH 00/13] audio support for at91sam9x5ek board
Hi, Here is some work I've done to make the sound work on sam9x5ek. It's based on Nicolas Ferre's and Uwe Kleine-König's work. (Atmel patch on 2.6.39 if I recall) I'd like to have some advice, mainly on the 1st patch misc: atmel_ssc: add device tree DMA support. I do not clearly see what is the right way to add DMA DT support for this device, since it doesn't request a channel directly. patches applies on next-20130701 [I let the original signed-off from Nicolas and Uwe in place, I don't know if I should replace them by something like originaly-signed-off-by since the code has been changed.] Best regards, Richard. Nicolas Ferre (3): sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards sound: atmel_ssc_dai: PM: actually stopping clock on suspend/resume sound: wm8731: rework power management Richard Genoud (10): misc: atmel_ssc: add device tree DMA support misc: atmel_ssc: keep the count of pdev-id ARM: at91: DTS: sam9x5: add clock for SSC DT entry ARM: at91: DTS: sam9x5: add SSC DMA parameters ARM: AT91: DTS: sam9x5ek: add WM8731 codec ARM: AT91: DTS: sam9x5ek: add sound configuration ARM: AT91: DTS: sam9x5ek: enable SSC sound: atmel-pcm: don't return ok if pcm-dma is not implemented sound: atmel-pcm-dma: check pointer before dereference sound: codec: wm8371: correct capture line/mic arch/arm/boot/dts/at91sam9x5.dtsi |3 + arch/arm/boot/dts/at91sam9x5ek.dtsi | 27 arch/arm/mach-at91/at91sam9x5.c |1 + drivers/misc/atmel-ssc.c| 63 + include/linux/atmel-ssc.h |2 + include/linux/platform_data/dma-atmel.h |2 + sound/soc/atmel/Kconfig | 12 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/atmel-pcm-dma.c |3 + sound/soc/atmel/atmel-pcm.h |2 +- sound/soc/atmel/atmel_ssc_dai.c | 20 ++- sound/soc/atmel/sam9x5_wm8731.c | 232 +++ sound/soc/codecs/wm8731.c | 10 +- 13 files changed, 368 insertions(+), 11 deletions(-) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 03/13] ARM: at91: DTS: sam9x5: add clock for SSC DT entry
Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/mach-at91/at91sam9x5.c |1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c index 2abee66..191eb4b 100644 --- a/arch/arm/mach-at91/at91sam9x5.c +++ b/arch/arm/mach-at91/at91sam9x5.c @@ -233,6 +233,7 @@ static struct clk_lookup periph_clocks_lookups[] = { CLKDEV_CON_DEV_ID(mci_clk, f000c000.mmc, mmc1_clk), CLKDEV_CON_DEV_ID(dma_clk, ec00.dma-controller, dma0_clk), CLKDEV_CON_DEV_ID(dma_clk, ee00.dma-controller, dma1_clk), + CLKDEV_CON_DEV_ID(pclk, at91sam9g45_ssc.0, ssc_clk), CLKDEV_CON_DEV_ID(pclk, f001.ssc, ssc_clk), CLKDEV_CON_DEV_ID(NULL, f801.i2c, twi0_clk), CLKDEV_CON_DEV_ID(NULL, f8014000.i2c, twi1_clk), -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 04/13] ARM: at91: DTS: sam9x5: add SSC DMA parameters
Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5.dtsi |3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 57d45f5..cf78ac0 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -542,6 +542,9 @@ compatible = atmel,at91sam9g45-ssc; reg = 0xf001 0x4000; interrupts = 28 IRQ_TYPE_LEVEL_HIGH 5; + dmas = dma0 1 AT91_DMA_CFG_PER_ID(13), + dma0 1 AT91_DMA_CFG_PER_ID(14); + dma-names = tx, rx; pinctrl-names = default; pinctrl-0 = pinctrl_ssc0_tx pinctrl_ssc0_rx; status = disabled; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 02/13] misc: atmel_ssc: keep the count of pdev-id
With device tree, pdev-id is always -1, so we introduce a local counter. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- drivers/misc/atmel-ssc.c |7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 3afbd82..d1ec5ab 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -173,6 +173,12 @@ out: return err; } +/* counter of ssc devive instances. + * With device tree pdev-id is always -1, so we have to keep the + * count ourselves + */ +static int ssc_device_id; + static int ssc_probe(struct platform_device *pdev) { struct resource *regs; @@ -235,6 +241,7 @@ static int ssc_probe(struct platform_device *pdev) } spin_lock(user_lock); + pdev-id = ssc_device_id++; list_add_tail(ssc-list, ssc_list); spin_unlock(user_lock); -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 08/13] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
From: Nicolas Ferre nicolas.fe...@atmel.com Description of the Asoc machine driver for an at91sam9x5 based board with a wm8731 audio DAC. Wm8731 is clocked by a crystal and used as a master on the SSC/I2S interface. Its connections are a headphone jack and an Line input jack. [Richard: this is based on an old patch from Nicolas that I forward ported and reworked to use only device tree] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/Kconfig | 12 ++ sound/soc/atmel/Makefile|2 + sound/soc/atmel/sam9x5_wm8731.c | 232 +++ 3 files changed, 246 insertions(+) create mode 100644 sound/soc/atmel/sam9x5_wm8731.c diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index 3fdd87f..f24d601 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -13,6 +13,7 @@ config SND_ATMEL_SOC_PDC config SND_ATMEL_SOC_DMA tristate depends on SND_ATMEL_SOC + select SND_SOC_DMAENGINE_PCM config SND_ATMEL_SOC_SSC tristate @@ -32,6 +33,17 @@ config SND_AT91_SOC_SAM9G20_WM8731 Say Y if you want to add support for SoC audio on WM8731-based AT91sam9g20 evaluation board. +config SND_AT91_SOC_SAM9X5_WM8731 + tristate SoC Audio support for WM8731-based at91sam9x5 board + depends on ATMEL_SSC SND_ATMEL_SOC SOC_AT91SAM9X5 + select SND_ATMEL_SOC_SSC + select SND_ATMEL_SOC_DMA + select SND_ATMEL_SOC_PDC + select SND_SOC_WM8731 + help + Say Y if you want to add support for audio SoC on an + at91sam9x5 based board that is using WM8731 codec. + config SND_AT91_SOC_AFEB9260 tristate SoC Audio support for AFEB9260 board depends on ARCH_AT91 ATMEL_SSC ARCH_AT91 MACH_AFEB9260 SND_ATMEL_SOC diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index 41967cc..7784c09 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile @@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o +snd-soc-sam9x5-wm8731-objs := sam9x5_wm8731.o obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o +obj-$(CONFIG_SND_AT91_SOC_SAM9X5_WM8731) += snd-soc-sam9x5-wm8731.o obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o diff --git a/sound/soc/atmel/sam9x5_wm8731.c b/sound/soc/atmel/sam9x5_wm8731.c new file mode 100644 index 000..83ca457 --- /dev/null +++ b/sound/soc/atmel/sam9x5_wm8731.c @@ -0,0 +1,232 @@ +/* + * sam9x5_wm8731 -- SoC audio for AT91SAM9X5-based boards + * that are using WM8731 as codec. + * + * Copyright (C) 2011 Atmel, + * Nicolas Ferre nicolas.fe...@atmel.com + * + * Based on sam9g20_wm8731.c by: + * Sedji Gaouaou sedji.gaou...@atmel.com + * + * GPL + */ +#include linux/module.h +#include linux/moduleparam.h +#include linux/kernel.h +#include linux/clk.h +#include linux/timer.h +#include linux/interrupt.h +#include linux/platform_device.h +#include linux/i2c.h + +#include linux/atmel-ssc.h + +#include sound/core.h +#include sound/pcm.h +#include sound/pcm_params.h +#include sound/soc.h + +#include asm/mach-types.h +#include mach/hardware.h +#include mach/gpio.h + +#include ../codecs/wm8731.h +#include atmel-pcm.h +#include atmel_ssc_dai.h + +#define MCLK_RATE 12288000 + +#define DRV_NAME sam9x5-snd-wm8731 + +/* + * Audio paths on at91sam9x5ek board: + * + * |A| | | ---R Headphone Jack + * |T| \| WM | ---L--/ + * |9| --- CLK -- | 8751 | --R- Line In Jack + * |1| | | --L--/ + */ +static const struct snd_soc_dapm_widget at91sam9x5ek_dapm_widgets[] = { + SND_SOC_DAPM_HP(Headphone Jack, NULL), + SND_SOC_DAPM_LINE(Line In Jack, NULL), +}; + +/* + * Logic for a wm8731 as connected on a at91sam9x5 based board. + */ +static int at91sam9x5ek_wm8731_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd-codec; + struct snd_soc_dai *codec_dai = rtd-codec_dai; + struct snd_soc_dapm_context *dapm = codec-dapm; + struct device *dev = rtd-dev; + int ret; + + dev_dbg(dev, ASoC: at91sam9x5ek_wm8731_init() called\n); + + /* +* remove some not supported rates in relation with clock +* provided to the wm8731 codec +*/ + switch (MCLK_RATE) { + case 12288000: + codec_dai-driver-playback.rates = SNDRV_PCM_RATE_8000 | +SNDRV_PCM_RATE_32000 | +SNDRV_PCM_RATE_48000 | +SNDRV_PCM_RATE_96000; + codec_dai-driver-capture.rates = SNDRV_PCM_RATE_8000
[RFC PATCH 07/13] ARM: AT91: DTS: sam9x5ek: enable SSC
Enable the SSC needed for the WM8731 codec Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |4 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index 77e4073..4f3584c 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -95,6 +95,10 @@ watchdog@fe40 { status = okay; }; + + ssc0: ssc@f001 { + status = okay; + }; }; usb0: ohci@0060 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 06/13] ARM: AT91: DTS: sam9x5ek: add sound configuration
The sam9x5ek board has 2 jacks: headphone wired on RHPOUT/LHPOUT of the wm8731 line in wired on LLINEIN/RLINEIN of the wm8731 Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index a81a1a6..77e4073 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -109,4 +109,22 @@ status = okay; }; }; + + sound { + compatible = atmel,sam9x5-audio-wm8731; + + atmel,model = wm8731 @ AT91SAM9X5EK; + + atmel,audio-routing = + Headphone Jack, RHPOUT, + Headphone Jack, LHPOUT, + LLINEIN, Line In Jack, + RLINEIN, Line In Jack; + + atmel,ssc-controller = ssc0; + atmel,audio-codec = wm8731; + atmel,format = i2s; + atmel,bitclock-master; + atmel,frame-master; + }; }; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 09/13] sound: atmel-pcm: don't return ok if pcm-dma is not implemented
If DMA is not selected, atmel_pcm_dma_platform_register() should fail. Like that, the driver knows it can't use it. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/atmel-pcm.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 12ae814..c0a01fa 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h @@ -109,7 +109,7 @@ void atmel_pcm_dma_platform_unregister(struct device *dev); #else static inline int atmel_pcm_dma_platform_register(struct device *dev) { - return 0; + return -1; } static inline void atmel_pcm_dma_platform_unregister(struct device *dev) { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 05/13] ARM: AT91: DTS: sam9x5ek: add WM8731 codec
The WM8731 codec on sam9x5ek board is on i2c, address 1A Signed-off-by: Richard Genoud richard.gen...@gmail.com --- arch/arm/boot/dts/at91sam9x5ek.dtsi |5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi index b753855..a81a1a6 100644 --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi @@ -59,6 +59,11 @@ i2c0: i2c@f801 { status = okay; + + wm8731: wm8731@1a { + compatible = wm8731; + reg = 0x1a; + }; }; pinctrl@f400 { -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 10/13] sound: atmel_ssc_dai: PM: actually stopping clock on suspend/resume
From: Nicolas Ferre nicolas.fe...@atmel.com Stop SSC clock on suspend/resume cycle checking if the controller is actually initialized. This will save power while sleeping. Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de --- sound/soc/atmel/atmel_ssc_dai.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index f3fdfa0..14da27a 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -659,12 +659,10 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream, #ifdef CONFIG_PM static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) { - struct atmel_ssc_info *ssc_p; + struct atmel_ssc_info *ssc_p = ssc_info[cpu_dai-id]; if (!cpu_dai-active) - return 0; - - ssc_p = ssc_info[cpu_dai-id]; + goto out; /* Save the status register before disabling transmit and receive */ ssc_p-ssc_state.ssc_sr = ssc_readl(ssc_p-ssc-regs, SR); @@ -680,6 +678,11 @@ static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) ssc_p-ssc_state.ssc_tcmr = ssc_readl(ssc_p-ssc-regs, TCMR); ssc_p-ssc_state.ssc_tfmr = ssc_readl(ssc_p-ssc-regs, TFMR); +out: + if (ssc_p-initialized) { + pr_debug(atmel_ssc_dai: suspend - stop clock\n); + clk_disable(ssc_p-ssc-clk); + } return 0; } @@ -687,14 +690,17 @@ static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai) { - struct atmel_ssc_info *ssc_p; + struct atmel_ssc_info *ssc_p = ssc_info[cpu_dai-id]; u32 cr; + if (ssc_p-initialized) { + pr_debug(atmel_ssc_dai: resume - restart clock\n); + clk_enable(ssc_p-ssc-clk); + } + if (!cpu_dai-active) return 0; - ssc_p = ssc_info[cpu_dai-id]; - /* restore SSC register settings */ ssc_writel(ssc_p-ssc-regs, TFMR, ssc_p-ssc_state.ssc_tfmr); ssc_writel(ssc_p-ssc-regs, TCMR, ssc_p-ssc_state.ssc_tcmr); -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 11/13] sound: atmel-pcm-dma: check pointer before dereference
If platform_data is NULL, filter() is called with a NULL slave parameter. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/atmel/atmel-pcm-dma.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c index 1d38fd0..b20dbba 100644 --- a/sound/soc/atmel/atmel-pcm-dma.c +++ b/sound/soc/atmel/atmel-pcm-dma.c @@ -96,6 +96,9 @@ static bool filter(struct dma_chan *chan, void *slave) { struct at_dma_slave *sl = slave; + if (!sl) + return false; + if (sl-dma_dev == chan-device-dev) { chan-private = sl; return true; -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 13/13] sound: codec: wm8371: correct capture line/mic
With the switch text, we can't enable the line and mic capture in alsamixer. Signed-off-by: Richard Genoud richard.gen...@gmail.com --- sound/soc/codecs/wm8731.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 3cf6b20..dae1403 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -164,10 +164,10 @@ SOC_DOUBLE_R(Master Playback ZC Switch, WM8731_LOUT1V, WM8731_ROUT1V, SOC_DOUBLE_R_TLV(Capture Volume, WM8731_LINVOL, WM8731_RINVOL, 0, 31, 0, in_tlv), -SOC_DOUBLE_R(Line Capture Switch, WM8731_LINVOL, WM8731_RINVOL, 7, 1, 1), +SOC_DOUBLE_R(Line Capture, WM8731_LINVOL, WM8731_RINVOL, 7, 1, 1), SOC_SINGLE_TLV(Mic Boost Volume, WM8731_APANA, 0, 1, 0, mic_tlv), -SOC_SINGLE(Mic Capture Switch, WM8731_APANA, 1, 1, 1), +SOC_SINGLE(Mic Capture, WM8731_APANA, 1, 1, 1), SOC_SINGLE_TLV(Sidetone Playback Volume, WM8731_APANA, 6, 3, 1, sidetone_tlv), -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[RFC PATCH 12/13] sound: wm8731: rework power management
From: Nicolas Ferre nicolas.fe...@atmel.com - preserve crystal oscillator across suspend/resume sequence: enabled by default,it should be kept enabled on resume. - if codec is in active state: set the active bit at resume time. Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de --- sound/soc/codecs/wm8731.c |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 5276062..3cf6b20 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -465,7 +465,9 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, snd_soc_write(codec, WM8731_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8731_PWR, 0x); + snd_soc_write(codec, WM8731_ACTIVE, 0x0); + /* standby: keep crystal oscillator enabled */ + snd_soc_write(codec, WM8731_PWR, 0x00df); regulator_bulk_disable(ARRAY_SIZE(wm8731-supplies), wm8731-supplies); regcache_mark_dirty(wm8731-regmap); @@ -516,6 +518,8 @@ static int wm8731_suspend(struct snd_soc_codec *codec) static int wm8731_resume(struct snd_soc_codec *codec) { wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + if (codec-active) + snd_soc_write(codec, WM8731_ACTIVE, 0x0001); return 0; } -- 1.7.10.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH 1/8] video: atmel_lcdfb: fix platform data struct
2013/5/29 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: On 19:44 Wed 29 May , Richard Genoud wrote: 2013/5/29 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: On 16:36 Wed 29 May , Richard Genoud wrote: 2013/4/11 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: Today we mix pdata and drivers data in the struct atmel_lcdfb_info Fix it and introduce a new struct atmel_lcdfb_pdata for platform data only Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: linux-fb...@vger.kernel.org Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: Andrew Morton a...@linux-foundation.org Cc: Hans-Christian Egtvedt egtv...@samfundet.no --- arch/arm/mach-at91/at91sam9261_devices.c|6 +- arch/arm/mach-at91/at91sam9263_devices.c|6 +- arch/arm/mach-at91/at91sam9g45_devices.c|6 +- arch/arm/mach-at91/at91sam9rl_devices.c |6 +- arch/arm/mach-at91/board-sam9261ek.c|6 +- arch/arm/mach-at91/board-sam9263ek.c|4 +- arch/arm/mach-at91/board-sam9m10g45ek.c |4 +- arch/arm/mach-at91/board-sam9rlek.c |4 +- arch/arm/mach-at91/board.h |4 +- arch/avr32/boards/atngw100/evklcd10x.c |6 +- arch/avr32/boards/atngw100/mrmt.c |4 +- arch/avr32/boards/atstk1000/atstk1000.h |2 +- arch/avr32/boards/atstk1000/setup.c |2 +- arch/avr32/boards/favr-32/setup.c |2 +- arch/avr32/boards/hammerhead/setup.c|2 +- arch/avr32/boards/merisc/display.c |2 +- arch/avr32/boards/mimc200/setup.c |4 +- arch/avr32/mach-at32ap/at32ap700x.c |8 +-- arch/avr32/mach-at32ap/include/mach/board.h |4 +- drivers/video/atmel_lcdfb.c | 104 +-- include/video/atmel_lcdc.h | 24 +-- 21 files changed, 109 insertions(+), 101 deletions(-) [snip] diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index c1a2914..98733cd4 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -20,12 +20,45 @@ #include linux/gfp.h #include linux/module.h #include linux/platform_data/atmel.h +#include video/of_display_timing.h #include mach/cpu.h #include asm/gpio.h #include video/atmel_lcdc.h +struct atmel_lcdfb_config { + bool have_alt_pixclock; + bool have_hozval; + bool have_intensity_bit; +}; + + /* LCD Controller info data structure, stored in device platform_data */ +struct atmel_lcdfb_info { + spinlock_t lock; + struct fb_info *info; + void __iomem*mmio; + int irq_base; + struct work_struct task; + + unsigned intsmem_len; + struct platform_device *pdev; + struct clk *bus_clk; + struct clk *lcdc_clk; + + struct backlight_device *backlight; + u8 bl_power; + boollcdcon_pol_negative; I think lcdcon_pol_negative should be part of pdata, because it really depends on how the PWM is wired on the board. maybe but no one mainline use it on any pdata for non-dt boars so I did not want to expose it Well, at least, I'm using it :) (and I guess that Andreas is using it also, otherwise he wouldn't have introduce it !) yes but pdata is for non-dt boards, for dt you can keep it in struct atmel_lcdfb_info and add a property if non-dt boards want it my answer is I do not care switch to DT ok (I use a full DT board based on sam9g35) so I'll add something like sinfo-lcdcon_pol_negative = of_property_read_bool(display_np, atmel,lcdcon-pwm-pulse-low); in /atmel_lcdfb.c But I thought the goal of this patch was to separate driver data from platform specific data, and IMHO, lcdcon_pol_negative is a specificity of the platform. Best regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH 1/8] video: atmel_lcdfb: fix platform data struct
2013/4/11 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: Today we mix pdata and drivers data in the struct atmel_lcdfb_info Fix it and introduce a new struct atmel_lcdfb_pdata for platform data only Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: linux-fb...@vger.kernel.org Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: Andrew Morton a...@linux-foundation.org Cc: Hans-Christian Egtvedt egtv...@samfundet.no --- arch/arm/mach-at91/at91sam9261_devices.c|6 +- arch/arm/mach-at91/at91sam9263_devices.c|6 +- arch/arm/mach-at91/at91sam9g45_devices.c|6 +- arch/arm/mach-at91/at91sam9rl_devices.c |6 +- arch/arm/mach-at91/board-sam9261ek.c|6 +- arch/arm/mach-at91/board-sam9263ek.c|4 +- arch/arm/mach-at91/board-sam9m10g45ek.c |4 +- arch/arm/mach-at91/board-sam9rlek.c |4 +- arch/arm/mach-at91/board.h |4 +- arch/avr32/boards/atngw100/evklcd10x.c |6 +- arch/avr32/boards/atngw100/mrmt.c |4 +- arch/avr32/boards/atstk1000/atstk1000.h |2 +- arch/avr32/boards/atstk1000/setup.c |2 +- arch/avr32/boards/favr-32/setup.c |2 +- arch/avr32/boards/hammerhead/setup.c|2 +- arch/avr32/boards/merisc/display.c |2 +- arch/avr32/boards/mimc200/setup.c |4 +- arch/avr32/mach-at32ap/at32ap700x.c |8 +-- arch/avr32/mach-at32ap/include/mach/board.h |4 +- drivers/video/atmel_lcdfb.c | 104 +-- include/video/atmel_lcdc.h | 24 +-- 21 files changed, 109 insertions(+), 101 deletions(-) [snip] diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index c1a2914..98733cd4 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -20,12 +20,45 @@ #include linux/gfp.h #include linux/module.h #include linux/platform_data/atmel.h +#include video/of_display_timing.h #include mach/cpu.h #include asm/gpio.h #include video/atmel_lcdc.h +struct atmel_lcdfb_config { + bool have_alt_pixclock; + bool have_hozval; + bool have_intensity_bit; +}; + + /* LCD Controller info data structure, stored in device platform_data */ +struct atmel_lcdfb_info { + spinlock_t lock; + struct fb_info *info; + void __iomem*mmio; + int irq_base; + struct work_struct task; + + unsigned intsmem_len; + struct platform_device *pdev; + struct clk *bus_clk; + struct clk *lcdc_clk; + + struct backlight_device *backlight; + u8 bl_power; + boollcdcon_pol_negative; I think lcdcon_pol_negative should be part of pdata, because it really depends on how the PWM is wired on the board. Regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH 4/8] video: atmel_lcdfb: add device tree suport
2013/4/11 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: get display timings from device tree Use videomode helpers to get display timings and configurations from device tree Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: linux-fb...@vger.kernel.org Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: Andrew Morton a...@linux-foundation.org --- .../devicetree/bindings/video/atmel,lcdc.txt | 75 ++ drivers/video/Kconfig |2 + drivers/video/atmel_lcdfb.c| 244 +--- 3 files changed, 289 insertions(+), 32 deletions(-) create mode 100644 Documentation/devicetree/bindings/video/atmel,lcdc.txt diff --git a/Documentation/devicetree/bindings/video/atmel,lcdc.txt b/Documentation/devicetree/bindings/video/atmel,lcdc.txt new file mode 100644 index 000..1ec175e --- /dev/null +++ b/Documentation/devicetree/bindings/video/atmel,lcdc.txt @@ -0,0 +1,75 @@ +Atmel LCDC Framebuffer +- + +Required properties: +- compatible : + atmel,at91sam9261-lcdc , + atmel,at91sam9263-lcdc , + atmel,at91sam9g10-lcdc , + atmel,at91sam9g45-lcdc , + atmel,at91sam9g45es-lcdc , + atmel,at91sam9rl-lcdc , + atmel,at32ap-lcdc +- reg : Should contain 1 register ranges(address and length) +- interrupts : framebuffer controller interrupt +- display: a phandle pointing to the display node + +Required nodes: +- display: a display node is required to initialize the lcd panel + This should be in the board dts. +- default-mode: a videomode within the display with timing parameters + as specified below. + +Example: + + fb0: fb@0x0050 { + compatible = atmel,at91sam9g45-lcdc; + reg = 0x0050 0x1000; + interrupts = 23 3 0; + pinctrl-names = default; + pinctrl-0 = pinctrl_fb; + display = display0; + status = okay; + #address-cells = 1; + #size-cells = 1; + + }; + +Atmel LCDC Display +- +Required properties (as per of_videomode_helper): + + - atmel,dmacon: dma controler configuration + - atmel,lcdcon2: lcd controler configuration + - atmel,guard-time: lcd guard time (Delay in frame periods) + - bits-per-pixel: lcd panel bit-depth. + +Optional properties (as per of_videomode_helper): + - atmel,lcdcon-backlight: enable backlight + - atmel,lcd-wiring-mode: lcd wiring mode RGB or BRG + - atmel,power-control-gpio: gpio to power on or off the LCD (as many as needed) still on lcdcon_pol_negative, we can add something like that: - atmel,lcdcon-pwm-pulse-low: Output PWM pulses are low level (high level if not set) + +Example: + display0: display { + bits-per-pixel = 32; + atmel,lcdcon-backlight; + atmel,dmacon = 0x1; + atmel,lcdcon2 = 0x80008002; + atmel,guard-time = 9; + atmel,lcd-wiring-mode = 1; + + display-timings { + native-mode = timing0; + timing0: timing0 { + clock-frequency = 900; + hactive = 480; + vactive = 272; + hback-porch = 1; + hfront-porch = 1; + vback-porch = 40; + vfront-porch = 1; + hsync-len = 45; + vsync-len = 1; + }; + }; + }; diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 4c1546f..0687482 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -1018,6 +1018,8 @@ config FB_ATMEL select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select FB_MODE_HELPERS + select OF_VIDEOMODE help This enables support for the AT91/AT32 LCD Controller. diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index f67e226..4a31570 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -20,7 +20,11 @@ #include linux/gfp.h #include linux/module.h #include linux/platform_data/atmel.h +#include linux/of.h +#include linux/of_device.h +#include linux/of_gpio.h #include video/of_display_timing.h +#include video/videomode.h #include mach/cpu.h #include asm/gpio.h @@ -59,6 +63,13 @@ struct atmel_lcdfb_info { struct atmel_lcdfb_config *config; }; +struct atmel_lcdfb_power_ctrl_gpio { + int gpio; + int active_low; + + struct list_head list; +}; + #define lcdc_readl(sinfo, reg)
Re: [PATCH 1/8] video: atmel_lcdfb: fix platform data struct
2013/5/29 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: On 16:36 Wed 29 May , Richard Genoud wrote: 2013/4/11 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: Today we mix pdata and drivers data in the struct atmel_lcdfb_info Fix it and introduce a new struct atmel_lcdfb_pdata for platform data only Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: linux-fb...@vger.kernel.org Cc: Nicolas Ferre nicolas.fe...@atmel.com Cc: Andrew Morton a...@linux-foundation.org Cc: Hans-Christian Egtvedt egtv...@samfundet.no --- arch/arm/mach-at91/at91sam9261_devices.c|6 +- arch/arm/mach-at91/at91sam9263_devices.c|6 +- arch/arm/mach-at91/at91sam9g45_devices.c|6 +- arch/arm/mach-at91/at91sam9rl_devices.c |6 +- arch/arm/mach-at91/board-sam9261ek.c|6 +- arch/arm/mach-at91/board-sam9263ek.c|4 +- arch/arm/mach-at91/board-sam9m10g45ek.c |4 +- arch/arm/mach-at91/board-sam9rlek.c |4 +- arch/arm/mach-at91/board.h |4 +- arch/avr32/boards/atngw100/evklcd10x.c |6 +- arch/avr32/boards/atngw100/mrmt.c |4 +- arch/avr32/boards/atstk1000/atstk1000.h |2 +- arch/avr32/boards/atstk1000/setup.c |2 +- arch/avr32/boards/favr-32/setup.c |2 +- arch/avr32/boards/hammerhead/setup.c|2 +- arch/avr32/boards/merisc/display.c |2 +- arch/avr32/boards/mimc200/setup.c |4 +- arch/avr32/mach-at32ap/at32ap700x.c |8 +-- arch/avr32/mach-at32ap/include/mach/board.h |4 +- drivers/video/atmel_lcdfb.c | 104 +-- include/video/atmel_lcdc.h | 24 +-- 21 files changed, 109 insertions(+), 101 deletions(-) [snip] diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index c1a2914..98733cd4 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -20,12 +20,45 @@ #include linux/gfp.h #include linux/module.h #include linux/platform_data/atmel.h +#include video/of_display_timing.h #include mach/cpu.h #include asm/gpio.h #include video/atmel_lcdc.h +struct atmel_lcdfb_config { + bool have_alt_pixclock; + bool have_hozval; + bool have_intensity_bit; +}; + + /* LCD Controller info data structure, stored in device platform_data */ +struct atmel_lcdfb_info { + spinlock_t lock; + struct fb_info *info; + void __iomem*mmio; + int irq_base; + struct work_struct task; + + unsigned intsmem_len; + struct platform_device *pdev; + struct clk *bus_clk; + struct clk *lcdc_clk; + + struct backlight_device *backlight; + u8 bl_power; + boollcdcon_pol_negative; I think lcdcon_pol_negative should be part of pdata, because it really depends on how the PWM is wired on the board. maybe but no one mainline use it on any pdata for non-dt boars so I did not want to expose it Well, at least, I'm using it :) (and I guess that Andreas is using it also, otherwise he wouldn't have introduce it !) Best regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
fb_monspecs and device tree
Hi ! I've been using the display-timings device tree node (great job !) on a sam9x5 soc. I was wondering if there's a planned support for struct fb_monspecs in device tree, (or if it is irrelevant), if someone is already working on that etc... Regards, Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: fb_monspecs and device tree
2013/5/28 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: On 11:41 Tue 28 May , Richard Genoud wrote: Hi ! I've been using the display-timings device tree node (great job !) on a sam9x5 soc. I was wondering if there's a planned support for struct fb_monspecs in device tree, (or if it is irrelevant), if someone is already working on that etc... I'm working on this but not on fbdev on DRI/KMS so we can have a full support of the overlay co but I'm going to change complely the dt binding with the one present on github beawre the lcdc is already done on fbdev with display-timings but I'll be off the first week on June so wait a few for sam9x5 Best Regards, J. ok, that's good news ! thanks. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH 0/3] ARM: at91: dt: switch to pre-processor
2013/4/24 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: HI, The follow patch series switch the at91 to DT pre-processor So we can use macro for AIC and Pinctrl instead of magic ARM: at91: dt: switch to pre-processor (2013-04-24 22:54:39 +0800) Jean-Christophe PLAGNIOL-VILLARD (3): ARM: at91: dt: add pinctrl pre-processor define ARM: at91: dt: add AIC pre-processor define ARM: at91: dt: switch to pre-processor I can't find your 3rd patch ARM: at91: dt: switch to pre-processor on the lists. This is too much suspens ! Bring it on ! Richard. ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND] ARM: add dtbImage.dt and dtbuImage.dt rules
[add Grant Likely and Rob Herring in To: since this is maybe more OF related than ARM related] This rules are useful for appended device tree conforming to the CONFIG_ARM_APPENDED_DTB kernel option. The rule dtbImage.dt is actually just a: cat zImage dt.dtb dtbImage.dt The dtbuImage.dt makes an uImage out of the dtbImage.dt file. KernelVersion: v3.6-rc5 Signed-off-by: Richard Genoud richard.gen...@gmail.com Tested-by: Gregory CLEMENT gregory.clem...@free-electrons.com --- arch/arm/Makefile | 30 -- arch/arm/boot/Makefile | 11 +++ scripts/Makefile.lib |6 ++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 30eae87..c5f2673 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -278,7 +278,7 @@ archprepare: # Convert bzImage to zImage bzImage: zImage -zImage Image xipImage bootpImage uImage: vmlinux +zImage Image xipImage bootpImage uImage dtbImage.% dtbuImage.% : vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ zinstall uinstall install: vmlinux @@ -300,17 +300,19 @@ i zi:;$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@ define archhelp - echo '* zImage- Compressed kernel image (arch/$(ARCH)/boot/zImage)' - echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' - echo '* xipImage - XIP kernel image, if configured (arch/$(ARCH)/boot/xipImage)' - echo ' uImage- U-Boot wrapped zImage' - echo ' bootpImage- Combined zImage and initial RAM disk' - echo ' (supply initrd image via make variable INITRD=path)' - echo ' dtbs - Build device tree blobs for enabled boards' - echo ' install - Install uncompressed kernel' - echo ' zinstall - Install compressed kernel' - echo ' uinstall - Install U-Boot wrapped compressed kernel' - echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or' - echo ' (distribution) /sbin/$(INSTALLKERNEL) or' - echo ' install to $$(INSTALL_PATH) and run lilo' + echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)' + echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' + echo '* xipImage - XIP kernel image, if configured (arch/$(ARCH)/boot/xipImage)' + echo ' uImage - U-Boot wrapped zImage' + echo ' bootpImage - Combined zImage and initial RAM disk' + echo ' (supply initrd image via make variable INITRD=path)' + echo ' dtbs - Build device tree blobs for enabled boards' + echo ' dtbImage.dt - zImage with an appended device tree blob' + echo ' dtbuImage.dt - uImage with an embedded device tree blob' + echo ' install- Install uncompressed kernel' + echo ' zinstall - Install compressed kernel' + echo ' uinstall - Install U-Boot wrapped compressed kernel' + echo ' Install using (your) ~/bin/$(INSTALLKERNEL) or' + echo ' (distribution) /sbin/$(INSTALLKERNEL) or' + echo ' install to $$(INSTALL_PATH) and run lilo' endef diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile index c877087..35c01a8 100644 --- a/arch/arm/boot/Makefile +++ b/arch/arm/boot/Makefile @@ -98,6 +98,17 @@ $(obj)/bootpImage: $(obj)/bootp/bootp FORCE $(call if_changed,objcopy) @echo ' Kernel: $@ is ready' +# dtbImage.% - a dtbImage is a zImage with an appended device tree blob +$(obj)/dtbImage.%: $(obj)/zImage $(obj)/%.dtb FORCE + $(call if_changed,cat) + @echo ' Kernel: $@ is ready' + +# dtbuImage.% - a dtbuImage is a uImage with an embedded device tree blob +$(obj)/dtbuImage.%: $(obj)/dtbImage.% FORCE + @$(check_for_multiple_loadaddr) + $(call if_changed,uimage) + @echo ' Image $@ is ready' + PHONY += initrd FORCE initrd: @test $(INITRD_PHYS) != || \ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0be6f11..8550466 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -235,6 +235,12 @@ cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \ quiet_cmd_objcopy = OBJCOPY $@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $ $@ +# Cat +# --- + +quiet_cmd_cat = CAT $@ +cmd_cat = (cat $(filter-out FORCE,$^) $@) || (rm -f $@ ; false) + # Gzip # --- -- 1.7.2.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH RESEND] ARM: add dtbImage.dt and dtbuImage.dt rules
2012/9/27 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com: Signed-off-by: Richard Genoud richard.gen...@gmail.com Tested-by: Gregory CLEMENT gregory.clem...@free-electrons.com as discuss with Grant no this is a temporary solution so no Makefile Target so nack hum, it doesn't seems to be temporary on powerpc. cf 25431333813686654907ab987fb5de10c10a16db and ARCH=powerpc make help So what's the problem on arm ? ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH 05/14] ARM: at91: add pinctrl support
2012/8/22 Stephen Warren swar...@wwwdotorg.org: +Required properties for iomux controller: +- compatible: atmel,at91rm9200-pinctrl +- atmel,mux-mask: array of mask (periph per bank) to describe if a pin can be + configured in this periph mode. All the periph and bank need to be describe. Can you please be more elaborate on this mux-mask, like what each bit means and why the bits are arranged like that and what it means on the AT91 platform I was first reading the .dts and was like ?woot? so I go to the bindings doc and I read this and I'm still like ?woot?.. Yes, I'm a little confused what this is, and wouldn't have a clue how to fill it in. With a practical example it's easier to understand. Take a SAM9X5 release manual (here is sam9g35): http://www.atmel.com/Images/doc11053.pdf page 11 (§4.3 package pinout) in the file arch/arm/boot/dts/at91sam9x5.dtsi you've got the the atmel,mux-mask like that: /* periphA periphBperiphC */ 0x 0xffe0399f 0xc01c /* pioA */ 0x0007 0x8000fe3f 0x /* pioB */ 0x8000 0x07c0 0xb83f /* pioC */ 0x003f 0x003f8000 0x /* pioD */ Let's take the PioA - peripheral B: 0xffe0399f From the documentation table 4-3, we can extract the column PIO Periperal B for all signals PA0-PA31: PIO Peripheral B PA0 SPI1_NPCS1 PA1 SPI1_NPCS2 PA2 MCI1_DA1 PA3 MCI1_DA2 PA4 MCI1_DA3 PA5 PA6 PA7 SPI0_NPCS1 PA8 SPI1_NPCS0 PA9 PA10 PA11 MCI1_DA0 PA12 MCI1_CDA PA13 MCI1_CK PA14 PA15 etc... Each time it's possible to mux a pin to the peripheral B function (ie when there's no -) the corresponding bit is set: PIO Peripheral B PA0 SPI1_NPCS1 1 PA1 SPI1_NPCS2 1 PA2 MCI1_DA1 1 PA3 MCI1_DA2 1 PA4 MCI1_DA3 1 PA5 0 PA6 0 PA7 SPI0_NPCS1 1 PA8 SPI1_NPCS0 1 PA9 0 PA10 0 PA11 MCI1_DA0 1 PA12 MCI1_CDA 1 PA13 MCI1_CK 1 PA14 0 PA15 0 = this gives 0x399f Best regards, Richard ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH 02/23] of_spi: add generic binding support to specify cs gpio
From: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com This will allow to use gpio for chip select with no modification in the driver binding When use the cs-gpios, the gpio number will be passed via the cs_gpio field and the number of chip select will automatically increased. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: devicetree-discuss@lists.ozlabs.org Cc: spi-devel-gene...@lists.sourceforge.net --- Documentation/devicetree/bindings/spi/spi-bus.txt |6 ++ drivers/spi/spi.c | 55 +++- include/linux/spi/spi.h |3 + 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt index e782add..c253379 100644 --- a/Documentation/devicetree/bindings/spi/spi-bus.txt +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt @@ -12,6 +12,7 @@ The SPI master node requires the following properties: - #size-cells - should be zero. - compatible - name of SPI bus controller following generic names recommended practice. +- cs-gpios - (optional) gpios chip select. No other properties are required in the SPI bus node. It is assumed that a driver for an SPI bus device will understand that it is an SPI bus. However, the binding does not attempt to define the specific method for @@ -21,6 +22,8 @@ assumption that board specific platform code will be used to manage chip selects. Individual drivers can define additional properties to support describing the chip select layout. +If cs-gpios is used the number of chip select will automatically increased. + SPI slave nodes must be children of the SPI master node and can contain the following properties. - reg - (required) chip select address of device. @@ -34,6 +37,9 @@ contain the following properties. - spi-cs-high - (optional) Empty property indicating device requires chip select active high +If a gpio chipselect is used for the SPI slave the gpio number will be passed +via the controller_data + SPI example for an MPC5200 SPI bus: spi@f00 { #address-cells = 1; diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 84c2861..3fb5b6d 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -30,6 +30,7 @@ #include linux/slab.h #include linux/mod_devicetable.h #include linux/spi/spi.h +#include linux/of_gpio.h #include linux/pm_runtime.h #include linux/export.h #include linux/sched.h @@ -327,6 +328,7 @@ struct spi_device *spi_alloc_device(struct spi_master *master) spi-dev.parent = master-dev; spi-dev.bus = spi_bus_type; spi-dev.release = spidev_release; + spi-cs_gpio = -EINVAL; device_initialize(spi-dev); return spi; } @@ -344,15 +346,16 @@ EXPORT_SYMBOL_GPL(spi_alloc_device); int spi_add_device(struct spi_device *spi) { static DEFINE_MUTEX(spi_add_lock); - struct device *dev = spi-master-dev.parent; + struct spi_master *master = spi-master; + struct device *dev = master-dev.parent; struct device *d; int status; /* Chipselects are numbered 0..max; validate. */ - if (spi-chip_select = spi-master-num_chipselect) { + if (spi-chip_select = master-num_chipselect) { dev_err(dev, cs%d = max %d\n, spi-chip_select, - spi-master-num_chipselect); + master-num_chipselect); return -EINVAL; } @@ -376,6 +379,9 @@ int spi_add_device(struct spi_device *spi) goto done; } + if (master-cs_gpios) + spi-cs_gpio = master-cs_gpios[spi-chip_select]; + /* Drivers may modify this initial i/o setup, but will * normally rely on the device being setup. Devices * using SPI_CS_HIGH can't coexist well otherwise... @@ -946,6 +952,45 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) } EXPORT_SYMBOL_GPL(spi_alloc_master); +#ifdef CONFIG_OF +static int of_spi_register_master(struct spi_master *master) +{ + int nb, i; + int *cs; + struct device_node *np = master-dev.of_node; + + if (!np) + return 0; + + nb = of_gpio_named_count(np, cs-gpios); + + if (nb 1) + return 0; + + cs = devm_kzalloc(master-dev, + sizeof(int) * (master-num_chipselect + nb), + GFP_KERNEL); + master-cs_gpios = cs; + + if (!master-cs_gpios) + return -ENOMEM; + + memset(cs, -EINVAL, master-num_chipselect); + master-num_chipselect += nb; + cs += master-num_chipselect; + + for (i = 0; i nb; i++) + cs[i] = of_get_named_gpio(np, cs-gpios, i); + + return 0; +} +#else +static int of_spi_register_master(struct
[PATCH 08/23] spi/atmel: add DT support
From: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com The atmel_spi use only gpio for chip select. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com Cc: devicetree-discuss@lists.ozlabs.org Cc: spi-devel-gene...@lists.sourceforge.net --- .../devicetree/bindings/spi/spi_atmel.txt |6 + drivers/spi/spi-atmel.c| 21 --- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/spi_atmel.txt diff --git a/Documentation/devicetree/bindings/spi/spi_atmel.txt b/Documentation/devicetree/bindings/spi/spi_atmel.txt new file mode 100644 index 000..7ec3d8d --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi_atmel.txt @@ -0,0 +1,6 @@ +Atmel SPI device + +Required properties: +- compatible : should be atmel,at91rm9200-spi. +- reg: Address and length of the register set for the device +- interrupts: Should contain macb interrupt diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 70f7bfa..ad47b6d 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -19,6 +19,7 @@ #include linux/interrupt.h #include linux/spi/spi.h #include linux/slab.h +#include linux/of.h #include asm/io.h #include mach/board.h @@ -711,7 +712,7 @@ static int atmel_spi_setup(struct spi_device *spi) u32 scbr, csr; unsigned intbits = spi-bits_per_word; unsigned long bus_hz; - unsigned intnpcs_pin; + int npcs_pin; int ret; as = spi_master_get_devdata(spi-master); @@ -783,7 +784,9 @@ static int atmel_spi_setup(struct spi_device *spi) csr |= SPI_BF(DLYBCT, 0); /* chipselect must have been muxed as GPIO (e.g. in board setup) */ - npcs_pin = (unsigned int)spi-controller_data; + if (!gpio_is_valid(spi-cs_gpio)) + spi-cs_gpio = (int)spi-controller_data; + npcs_pin = spi-cs_gpio; asd = spi-controller_state; if (!asd) { asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); @@ -900,7 +903,7 @@ static void atmel_spi_cleanup(struct spi_device *spi) { struct atmel_spi*as = spi_master_get_devdata(spi-master); struct atmel_spi_device *asd = spi-controller_state; - unsignedgpio = (unsigned) spi-controller_data; + unsignedgpio = spi-cs_gpio; if (!asd) return; @@ -950,7 +953,8 @@ static int __devinit atmel_spi_probe(struct platform_device *pdev) master-mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; master-bus_num = pdev-id; - master-num_chipselect = 4; + master-dev.of_node = pdev-dev.of_node; + master-num_chipselect = master-dev.of_node ? 0 : 4; master-setup = atmel_spi_setup; master-transfer = atmel_spi_transfer; master-cleanup = atmel_spi_cleanup; @@ -1079,11 +1083,20 @@ static int atmel_spi_resume(struct platform_device *pdev) #defineatmel_spi_resumeNULL #endif +#if defined(CONFIG_OF) +static const struct of_device_id atmel_spi_dt_ids[] = { + { .compatible = atmel,at91rm9200-spi }, + { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids); +#endif static struct platform_driver atmel_spi_driver = { .driver = { .name = atmel_spi, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(atmel_spi_dt_ids), }, .suspend= atmel_spi_suspend, .resume = atmel_spi_resume, -- 1.7.2.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss