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

ASoC: omap: rx51: Add DT support

This patch adds device tree support to the Nokia N900 audio driver and
adds documentation for the DT binding.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Sebastian Reichel and committed by
Mark Brown
d052a3d6 f29b5421

+80
+27
Documentation/devicetree/bindings/sound/nokia,rx51.txt
··· 1 + * Nokia N900 audio setup 2 + 3 + Required properties: 4 + - compatible: Should contain "nokia,n900-audio" 5 + - nokia,cpu-dai: phandle for the McBSP node 6 + - nokia,audio-codec: phandles for the main TLV320AIC3X node and the 7 + auxiliary TLV320AIC3X node (in this order) 8 + - nokia,headphone-amplifier: phandle for the TPA6130A2 node 9 + - tvout-selection-gpios: GPIO for tvout selection 10 + - jack-detection-gpios: GPIO for jack detection 11 + - eci-switch-gpios: GPIO for ECI (Enhancement Control Interface) switch 12 + - speaker-amplifier-gpios: GPIO for speaker amplifier 13 + 14 + Example: 15 + 16 + sound { 17 + compatible = "nokia,n900-audio"; 18 + 19 + nokia,cpu-dai = <&mcbsp2>; 20 + nokia,audio-codec = <&tlv320aic3x>, <&tlv320aic3x_aux>; 21 + nokia,headphone-amplifier = <&tpa6130a2>; 22 + 23 + tvout-selection-gpios = <&gpio2 8 GPIO_ACTIVE_HIGH>; /* 40 */ 24 + jack-detection-gpios = <&gpio6 17 GPIO_ACTIVE_HIGH>; /* 177 */ 25 + eci-switch-gpios = <&gpio6 22 GPIO_ACTIVE_HIGH>; /* 182 */ 26 + speaker-amplifier-gpios = <&twl_gpio 7 GPIO_ACTIVE_HIGH>; 27 + };
+53
sound/soc/omap/rx51.c
··· 386 386 static int rx51_soc_probe(struct platform_device *pdev) 387 387 { 388 388 struct rx51_audio_pdata *pdata; 389 + struct device_node *np = pdev->dev.of_node; 389 390 struct snd_soc_card *card = &rx51_sound_card; 390 391 int err; 391 392 ··· 394 393 return -ENODEV; 395 394 396 395 card->dev = &pdev->dev; 396 + 397 + if (np) { 398 + struct device_node *dai_node; 399 + 400 + dai_node = of_parse_phandle(np, "nokia,cpu-dai", 0); 401 + if (!dai_node) { 402 + dev_err(&pdev->dev, "McBSP node is not provided\n"); 403 + return -EINVAL; 404 + } 405 + rx51_dai[0].cpu_dai_name = NULL; 406 + rx51_dai[0].platform_name = NULL; 407 + rx51_dai[0].cpu_of_node = dai_node; 408 + rx51_dai[0].platform_of_node = dai_node; 409 + 410 + dai_node = of_parse_phandle(np, "nokia,audio-codec", 0); 411 + if (!dai_node) { 412 + dev_err(&pdev->dev, "Codec node is not provided\n"); 413 + return -EINVAL; 414 + } 415 + rx51_dai[0].codec_name = NULL; 416 + rx51_dai[0].codec_of_node = dai_node; 417 + 418 + dai_node = of_parse_phandle(np, "nokia,audio-codec", 1); 419 + if (!dai_node) { 420 + dev_err(&pdev->dev, "Auxiliary Codec node is not provided\n"); 421 + return -EINVAL; 422 + } 423 + rx51_aux_dev[0].codec_name = NULL; 424 + rx51_aux_dev[0].codec_of_node = dai_node; 425 + rx51_codec_conf[0].dev_name = NULL; 426 + rx51_codec_conf[0].of_node = dai_node; 427 + 428 + dai_node = of_parse_phandle(np, "nokia,headphone-amplifier", 0); 429 + if (!dai_node) { 430 + dev_err(&pdev->dev, "Headphone amplifier node is not provided\n"); 431 + return -EINVAL; 432 + } 433 + 434 + /* TODO: tpa6130a2a driver supports only a single instance, so 435 + * this driver ignores the headphone-amplifier node for now. 436 + * It's already mandatory in the DT binding to be future proof. 437 + */ 438 + } 397 439 398 440 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 399 441 if (pdata == NULL) { ··· 507 463 return 0; 508 464 } 509 465 466 + #if defined(CONFIG_OF) 467 + static const struct of_device_id rx51_audio_of_match[] = { 468 + { .compatible = "nokia,n900-audio", }, 469 + {}, 470 + }; 471 + MODULE_DEVICE_TABLE(of, rx51_audio_of_match); 472 + #endif 473 + 510 474 static struct platform_driver rx51_soc_driver = { 511 475 .driver = { 512 476 .name = "rx51-audio", 513 477 .owner = THIS_MODULE, 478 + .of_match_table = of_match_ptr(rx51_audio_of_match), 514 479 }, 515 480 .probe = rx51_soc_probe, 516 481 .remove = rx51_soc_remove,