Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: at91sam9g20ek-wm8731: convert to dt support

convert at91sam9g20ek with wm8731 to device tree support

Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Bo Shen and committed by
Mark Brown
531f67e4 3310b57d

+119 -5
+26
Documentation/devicetree/bindings/sound/atmel-at91sam9g20ek-wm8731-audio.txt
··· 1 + * Atmel at91sam9g20ek wm8731 audio complex 2 + 3 + Required properties: 4 + - compatible: "atmel,at91sam9g20ek-wm8731-audio" 5 + - atmel,model: The user-visible name of this sound complex. 6 + - atmel,audio-routing: A list of the connections between audio components. 7 + - atmel,ssc-controller: The phandle of the SSC controller 8 + - atmel,audio-codec: The phandle of the WM8731 audio codec 9 + Optional properties: 10 + - pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt 11 + 12 + Example: 13 + sound { 14 + compatible = "atmel,at91sam9g20ek-wm8731-audio"; 15 + pinctrl-names = "default"; 16 + pinctrl-0 = <&pinctrl_pck0_as_mck>; 17 + 18 + atmel,model = "wm8731 @ AT91SAMG20EK"; 19 + 20 + atmel,audio-routing = 21 + "Ext Spk", "LHPOUT", 22 + "Int MIC", "MICIN"; 23 + 24 + atmel,ssc-controller = <&ssc0>; 25 + atmel,audio-codec = <&wm8731>; 26 + };
+31 -1
arch/arm/boot/dts/at91sam9g20ek_common.dtsi
··· 30 30 31 31 ahb { 32 32 apb { 33 + pinctrl@fffff400 { 34 + board { 35 + pinctrl_pck0_as_mck: pck0_as_mck { 36 + atmel,pins = 37 + <2 1 0x2 0x0>; /* PC1 periph B */ 38 + }; 39 + 40 + }; 41 + }; 42 + 33 43 dbgu: serial@fffff200 { 34 44 status = "okay"; 35 45 }; ··· 60 50 usb1: gadget@fffa4000 { 61 51 atmel,vbus-gpio = <&pioC 5 0>; 62 52 status = "okay"; 53 + }; 54 + 55 + ssc0: ssc@fffbc000 { 56 + status = "okay"; 57 + pinctrl-0 = <&pinctrl_ssc0_tx>; 63 58 }; 64 59 }; 65 60 ··· 129 114 reg = <0x50>; 130 115 }; 131 116 132 - wm8731@1b { 117 + wm8731: wm8731@1b { 133 118 compatible = "wm8731"; 134 119 reg = <0x1b>; 135 120 }; ··· 153 138 linux,code = <0x104>; 154 139 gpio-key,wakeup; 155 140 }; 141 + }; 142 + 143 + sound { 144 + compatible = "atmel,at91sam9g20ek-wm8731-audio"; 145 + pinctrl-names = "default"; 146 + pinctrl-0 = <&pinctrl_pck0_as_mck>; 147 + 148 + atmel,model = "wm8731 @ AT91SAMG20EK"; 149 + 150 + atmel,audio-routing = 151 + "Ext Spk", "LHPOUT", 152 + "Int Mic", "MICIN"; 153 + 154 + atmel,ssc-controller = <&ssc0>; 155 + atmel,audio-codec = <&wm8731>; 156 156 }; 157 157 };
+1 -2
sound/soc/atmel/Kconfig
··· 16 16 17 17 config SND_AT91_SOC_SAM9G20_WM8731 18 18 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board" 19 - depends on ATMEL_SSC && ARCH_AT91SAM9G20 && SND_ATMEL_SOC && \ 20 - AT91_PROGRAMMABLE_CLOCKS 19 + depends on ATMEL_SSC && SND_ATMEL_SOC && AT91_PROGRAMMABLE_CLOCKS 21 20 select SND_ATMEL_SOC_SSC 22 21 select SND_SOC_WM8731 23 22 help
+61 -2
sound/soc/atmel/sam9g20_wm8731.c
··· 38 38 #include <linux/platform_device.h> 39 39 #include <linux/i2c.h> 40 40 41 + #include <linux/pinctrl/consumer.h> 42 + 41 43 #include <linux/atmel-ssc.h> 42 44 43 45 #include <sound/core.h> ··· 199 197 200 198 static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) 201 199 { 200 + struct device_node *np = pdev->dev.of_node; 201 + struct device_node *codec_np, *cpu_np; 202 202 struct clk *pllb; 203 203 struct snd_soc_card *card = &snd_soc_at91sam9g20ek; 204 + struct pinctrl *pinctrl; 204 205 int ret; 205 206 206 - if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) 207 - return -ENODEV; 207 + pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 208 + if (IS_ERR(pinctrl)) { 209 + dev_err(&pdev->dev, "Failed to request pinctrl for mck\n"); 210 + return PTR_ERR(pinctrl); 211 + } 212 + 213 + if (!np) { 214 + if (!(machine_is_at91sam9g20ek() || 215 + machine_is_at91sam9g20ek_2mmc())) 216 + return -ENODEV; 217 + } 208 218 209 219 ret = atmel_ssc_set_audio(0); 210 220 if (ret) { ··· 250 236 clk_set_rate(mclk, MCLK_RATE); 251 237 252 238 card->dev = &pdev->dev; 239 + 240 + /* Parse device node info */ 241 + if (np) { 242 + ret = snd_soc_of_parse_card_name(card, "atmel,model"); 243 + if (ret) 244 + goto err; 245 + 246 + ret = snd_soc_of_parse_audio_routing(card, 247 + "atmel,audio-routing"); 248 + if (ret) 249 + goto err; 250 + 251 + /* Parse codec info */ 252 + at91sam9g20ek_dai.codec_name = NULL; 253 + codec_np = of_parse_phandle(np, "atmel,audio-codec", 0); 254 + if (!codec_np) { 255 + dev_err(&pdev->dev, "codec info missing\n"); 256 + return -EINVAL; 257 + } 258 + at91sam9g20ek_dai.codec_of_node = codec_np; 259 + 260 + /* Parse dai and platform info */ 261 + at91sam9g20ek_dai.cpu_dai_name = NULL; 262 + at91sam9g20ek_dai.platform_name = NULL; 263 + cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0); 264 + if (!cpu_np) { 265 + dev_err(&pdev->dev, "dai and pcm info missing\n"); 266 + return -EINVAL; 267 + } 268 + at91sam9g20ek_dai.cpu_of_node = cpu_np; 269 + at91sam9g20ek_dai.platform_of_node = cpu_np; 270 + 271 + of_node_put(codec_np); 272 + of_node_put(cpu_np); 273 + } 274 + 253 275 ret = snd_soc_register_card(card); 254 276 if (ret) { 255 277 printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n"); ··· 313 263 return 0; 314 264 } 315 265 266 + #ifdef CONFIG_OF 267 + static const struct of_device_id at91sam9g20ek_wm8731_dt_ids[] = { 268 + { .compatible = "atmel,at91sam9g20ek-wm8731-audio", }, 269 + { } 270 + }; 271 + MODULE_DEVICE_TABLE(of, at91sam9g20ek_wm8731_dt_ids); 272 + #endif 273 + 316 274 static struct platform_driver at91sam9g20ek_audio_driver = { 317 275 .driver = { 318 276 .name = "at91sam9g20ek-audio", 319 277 .owner = THIS_MODULE, 278 + .of_match_table = of_match_ptr(at91sam9g20ek_wm8731_dt_ids), 320 279 }, 321 280 .probe = at91sam9g20ek_audio_probe, 322 281 .remove = __devexit_p(at91sam9g20ek_audio_remove),