Adding Device Tree support for some RPi audio cards

This commit is contained in:
popcornmix
2015-04-13 18:45:39 +01:00
parent 7c66acaf17
commit 802ce94f95
10 changed files with 279 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
// Definitions for HiFiBerry DAC
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&sound>;
__overlay__ {
compatible = "hifiberry,hifiberry-dac";
i2s-controller = <&i2s>;
status = "okay";
};
};
fragment@1 {
target = <&i2s>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target-path = "/";
__overlay__ {
pcm5102a-codec {
#sound-dai-cells = <0>;
compatible = "ti,pcm5102a";
status = "okay";
};
};
};
};

View File

@@ -0,0 +1,39 @@
// Definitions for HiFiBerry DAC+
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&sound>;
__overlay__ {
compatible = "hifiberry,hifiberry-dacplus";
i2s-controller = <&i2s>;
status = "okay";
};
};
fragment@1 {
target = <&i2s>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pcm5122@4d {
#sound-dai-cells = <0>;
compatible = "ti,pcm5122";
reg = <0x4d>;
status = "okay";
};
};
};
};

View File

@@ -0,0 +1,39 @@
// Definitions for HiFiBerry Digi
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&sound>;
__overlay__ {
compatible = "hifiberry,hifiberry-digi";
i2s-controller = <&i2s>;
status = "okay";
};
};
fragment@1 {
target = <&i2s>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
wm8804@3b {
#sound-dai-cells = <0>;
compatible = "wlf,wm8804";
reg = <0x3b>;
status = "okay";
};
};
};
};

View File

@@ -0,0 +1,39 @@
// Definitions for IQaudIO DAC
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&sound>;
__overlay__ {
compatible = "iqaudio,iqaudio-dac";
i2s-controller = <&i2s>;
status = "okay";
};
};
fragment@1 {
target = <&i2s>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pcm5122@4c {
#sound-dai-cells = <0>;
compatible = "ti,pcm5122";
reg = <0x4c>;
status = "okay";
};
};
};
};

View File

@@ -0,0 +1,39 @@
// Definitions for IQaudIO DAC+
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2708";
fragment@0 {
target = <&sound>;
__overlay__ {
compatible = "iqaudio,iqaudio-dac";
i2s-controller = <&i2s>;
status = "okay";
};
};
fragment@1 {
target = <&i2s>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pcm5122@4c {
#sound-dai-cells = <0>;
compatible = "ti,pcm5122";
reg = <0x4c>;
status = "okay";
};
};
};
};

View File

@@ -72,6 +72,21 @@ static int snd_rpi_hifiberry_dac_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
snd_rpi_hifiberry_dac.dev = &pdev->dev; snd_rpi_hifiberry_dac.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_dac_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpu_dai_name = NULL;
dai->cpu_of_node = i2s_node;
dai->platform_name = NULL;
dai->platform_of_node = i2s_node;
}
}
ret = snd_soc_register_card(&snd_rpi_hifiberry_dac); ret = snd_soc_register_card(&snd_rpi_hifiberry_dac);
if (ret) if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
@@ -84,10 +99,17 @@ static int snd_rpi_hifiberry_dac_remove(struct platform_device *pdev)
return snd_soc_unregister_card(&snd_rpi_hifiberry_dac); return snd_soc_unregister_card(&snd_rpi_hifiberry_dac);
} }
static const struct of_device_id snd_rpi_hifiberry_dac_of_match[] = {
{ .compatible = "hifiberry,hifiberry-dac", },
{},
};
MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dac_of_match);
static struct platform_driver snd_rpi_hifiberry_dac_driver = { static struct platform_driver snd_rpi_hifiberry_dac_driver = {
.driver = { .driver = {
.name = "snd-hifiberry-dac", .name = "snd-hifiberry-dac",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = snd_rpi_hifiberry_dac_of_match,
}, },
.probe = snd_rpi_hifiberry_dac_probe, .probe = snd_rpi_hifiberry_dac_probe,
.remove = snd_rpi_hifiberry_dac_remove, .remove = snd_rpi_hifiberry_dac_remove,

View File

@@ -90,6 +90,21 @@ static int snd_rpi_hifiberry_dacplus_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
snd_rpi_hifiberry_dacplus.dev = &pdev->dev; snd_rpi_hifiberry_dacplus.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_dacplus_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpu_dai_name = NULL;
dai->cpu_of_node = i2s_node;
dai->platform_name = NULL;
dai->platform_of_node = i2s_node;
}
}
ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus); ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);
if (ret) if (ret)
dev_err(&pdev->dev, dev_err(&pdev->dev,
@@ -103,10 +118,17 @@ static int snd_rpi_hifiberry_dacplus_remove(struct platform_device *pdev)
return snd_soc_unregister_card(&snd_rpi_hifiberry_dacplus); return snd_soc_unregister_card(&snd_rpi_hifiberry_dacplus);
} }
static const struct of_device_id snd_rpi_hifiberry_dacplus_of_match[] = {
{ .compatible = "hifiberry,hifiberry-dacplus", },
{},
};
MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dacplus_of_match);
static struct platform_driver snd_rpi_hifiberry_dacplus_driver = { static struct platform_driver snd_rpi_hifiberry_dacplus_driver = {
.driver = { .driver = {
.name = "snd-rpi-hifiberry-dacplus", .name = "snd-rpi-hifiberry-dacplus",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = snd_rpi_hifiberry_dacplus_of_match,
}, },
.probe = snd_rpi_hifiberry_dacplus_probe, .probe = snd_rpi_hifiberry_dacplus_probe,
.remove = snd_rpi_hifiberry_dacplus_remove, .remove = snd_rpi_hifiberry_dacplus_remove,

View File

@@ -125,6 +125,21 @@ static int snd_rpi_hifiberry_digi_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
snd_rpi_hifiberry_digi.dev = &pdev->dev; snd_rpi_hifiberry_digi.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_digi_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpu_dai_name = NULL;
dai->cpu_of_node = i2s_node;
dai->platform_name = NULL;
dai->platform_of_node = i2s_node;
}
}
ret = snd_soc_register_card(&snd_rpi_hifiberry_digi); ret = snd_soc_register_card(&snd_rpi_hifiberry_digi);
if (ret) if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
@@ -137,10 +152,17 @@ static int snd_rpi_hifiberry_digi_remove(struct platform_device *pdev)
return snd_soc_unregister_card(&snd_rpi_hifiberry_digi); return snd_soc_unregister_card(&snd_rpi_hifiberry_digi);
} }
static const struct of_device_id snd_rpi_hifiberry_digi_of_match[] = {
{ .compatible = "hifiberry,hifiberry-digi", },
{},
};
MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_digi_of_match);
static struct platform_driver snd_rpi_hifiberry_digi_driver = { static struct platform_driver snd_rpi_hifiberry_digi_driver = {
.driver = { .driver = {
.name = "snd-hifiberry-digi", .name = "snd-hifiberry-digi",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = snd_rpi_hifiberry_digi_of_match,
}, },
.probe = snd_rpi_hifiberry_digi_probe, .probe = snd_rpi_hifiberry_digi_probe,
.remove = snd_rpi_hifiberry_digi_remove, .remove = snd_rpi_hifiberry_digi_remove,

View File

@@ -82,6 +82,21 @@ static int snd_rpi_iqaudio_dac_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
snd_rpi_iqaudio_dac.dev = &pdev->dev; snd_rpi_iqaudio_dac.dev = &pdev->dev;
if (pdev->dev.of_node) {
struct device_node *i2s_node;
struct snd_soc_dai_link *dai = &snd_rpi_iqaudio_dac_dai[0];
i2s_node = of_parse_phandle(pdev->dev.of_node,
"i2s-controller", 0);
if (i2s_node) {
dai->cpu_dai_name = NULL;
dai->cpu_of_node = i2s_node;
dai->platform_name = NULL;
dai->platform_of_node = i2s_node;
}
}
ret = snd_soc_register_card(&snd_rpi_iqaudio_dac); ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);
if (ret) if (ret)
dev_err(&pdev->dev, dev_err(&pdev->dev,
@@ -99,6 +114,7 @@ static const struct of_device_id iqaudio_of_match[] = {
{ .compatible = "iqaudio,iqaudio-dac", }, { .compatible = "iqaudio,iqaudio-dac", },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, iqaudio_of_match);
static struct platform_driver snd_rpi_iqaudio_dac_driver = { static struct platform_driver snd_rpi_iqaudio_dac_driver = {
.driver = { .driver = {

View File

@@ -47,12 +47,19 @@ static int pcm5102a_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id pcm5102a_of_match[] = {
{ .compatible = "ti,pcm5102a", },
{ }
};
MODULE_DEVICE_TABLE(of, pcm5102a_of_match);
static struct platform_driver pcm5102a_codec_driver = { static struct platform_driver pcm5102a_codec_driver = {
.probe = pcm5102a_probe, .probe = pcm5102a_probe,
.remove = pcm5102a_remove, .remove = pcm5102a_remove,
.driver = { .driver = {
.name = "pcm5102a-codec", .name = "pcm5102a-codec",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = pcm5102a_of_match,
}, },
}; };