Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
status = "okay";
};

&audio {
status = "okay";
};

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/bcm2708-rpi-b.dts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
status = "okay";
};

&audio {
status = "okay";
};

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/bcm2708-rpi-cm.dtsi
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
status = "okay";
};

&audio {
status = "okay";
};

/ {
__overrides__ {
act_led_gpio = <&act_led>,"gpios:4";
Expand Down
7 changes: 7 additions & 0 deletions arch/arm/boot/dts/bcm2708_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
/ {
interrupt-parent = <&intc>;

/* Onboard audio */
audio: audio {
compatible = "brcm,bcm2835-audio";
brcm,pwm-channels = <8>;
status = "disabled";
};

soc: soc {
compatible = "simple-bus";
#address-cells = <1>;
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/bcm2709-rpi-2-b.dts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
status = "okay";
};

&audio {
status = "okay";
};

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/boot/dts/bcm2835-rpi.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
linux,default-trigger = "heartbeat";
};
};

/* Onboard audio */
audio: audio {
compatible = "brcm,bcm2835-audio";
brcm,pwm-channels = <8>;
};
};

&gpio {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ void __init bcm2708_init(void)
#endif
bcm2708_init_led();
for (i = 0; i < ARRAY_SIZE(bcm2708_alsa_devices); i++)
bcm_register_device(&bcm2708_alsa_devices[i]);
bcm_register_device_dt(&bcm2708_alsa_devices[i]);

bcm_register_device_dt(&bcm2708_spi_device);

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-bcm2709/bcm2709.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ void __init bcm2709_init(void)
#endif
bcm2709_init_led();
for (i = 0; i < ARRAY_SIZE(bcm2708_alsa_devices); i++)
bcm_register_device(&bcm2708_alsa_devices[i]);
bcm_register_device_dt(&bcm2708_alsa_devices[i]);

bcm_register_device_dt(&bcm2708_spi_device);

Expand Down
3 changes: 2 additions & 1 deletion sound/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ config SND_PXA2XX_AC97

config SND_BCM2835
tristate "BCM2835 ALSA driver"
depends on (ARCH_BCM2708 || ARCH_BCM2709) && BCM2708_VCHIQ && SND
depends on (ARCH_BCM2708 || ARCH_BCM2709 || ARCH_BCM2835) \
&& BCM2708_VCHIQ && SND
select SND_PCM
help
Say Y or M if you want to support BCM2835 Alsa pcm card driver
Expand Down
91 changes: 91 additions & 0 deletions sound/arm/bcm2835.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/of.h>

#include "bcm2835.h"

Expand Down Expand Up @@ -81,13 +82,96 @@ static int snd_bcm2835_create(struct snd_card *card,
return 0;
}

static int snd_bcm2835_alsa_probe_dt(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
bcm2835_chip_t *chip;
struct snd_card *card;
u32 numchans;
int err, i;

err = of_property_read_u32(dev->of_node, "brcm,pwm-channels",
&numchans);
if (err) {
dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'");
return err;
}

if (numchans == 0 || numchans > MAX_SUBSTREAMS) {
numchans = MAX_SUBSTREAMS;
dev_warn(dev, "Illegal 'brcm,pwm-channels' value, will use %u\n",
numchans);
}

err = snd_card_new(NULL, -1, NULL, THIS_MODULE, 0, &card);
if (err) {
dev_err(dev, "Failed to create soundcard structure\n");
return err;
}

snd_card_set_dev(card, dev);
strcpy(card->driver, "bcm2835");
strcpy(card->shortname, "bcm2835 ALSA");
sprintf(card->longname, "%s", card->shortname);

err = snd_bcm2835_create(card, pdev, &chip);
if (err < 0) {
dev_err(dev, "Failed to create bcm2835 chip\n");
goto err_free;
}

err = snd_bcm2835_new_pcm(chip);
if (err < 0) {
dev_err(dev, "Failed to create new bcm2835 pcm device\n");
goto err_free;
}

err = snd_bcm2835_new_spdif_pcm(chip);
if (err < 0) {
dev_err(dev, "Failed to create new bcm2835 spdif pcm device\n");
goto err_free;
}

err = snd_bcm2835_new_ctl(chip);
if (err < 0) {
dev_err(dev, "Failed to create new bcm2835 ctl\n");
goto err_free;
}

for (i = 0; i < numchans; i++) {
chip->avail_substreams |= (1 << i);
chip->pdev[i] = pdev;
}

err = snd_card_register(card);
if (err) {
dev_err(dev, "Failed to register bcm2835 ALSA card \n");
goto err_free;
}

g_card = card;
g_chip = chip;
platform_set_drvdata(pdev, card);
audio_info("bcm2835 ALSA card created with %u channels\n", numchans);

return 0;

err_free:
snd_card_free(card);

return err;
}

static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
{
static int dev;
bcm2835_chip_t *chip;
struct snd_card *card;
int err;

if (pdev->dev.of_node)
return snd_bcm2835_alsa_probe_dt(pdev);

if (dev >= MAX_SUBSTREAMS)
return -ENODEV;

Expand Down Expand Up @@ -224,6 +308,12 @@ static int snd_bcm2835_alsa_resume(struct platform_device *pdev)

#endif

static const struct of_device_id snd_bcm2835_of_match_table[] = {
{ .compatible = "brcm,bcm2835-audio", },
{},
};
MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table);

static struct platform_driver bcm2835_alsa0_driver = {
.probe = snd_bcm2835_alsa_probe,
.remove = snd_bcm2835_alsa_remove,
Expand All @@ -234,6 +324,7 @@ static struct platform_driver bcm2835_alsa0_driver = {
.driver = {
.name = "bcm2835_AUD0",
.owner = THIS_MODULE,
.of_match_table = snd_bcm2835_of_match_table,
},
};

Expand Down