Skip to content

Added support for Wolfson Audio Card by Element-14 on Raspberry Pi Model B #705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
10 changes: 10 additions & 0 deletions arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ CONFIG_SPI=y
CONFIG_SPI_BCM2708=m
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_ARIZONA=m
CONFIG_W1=m
CONFIG_W1_MASTER_DS2490=m
CONFIG_W1_MASTER_DS2482=m
Expand All @@ -575,6 +576,12 @@ CONFIG_THERMAL=y
CONFIG_THERMAL_BCM2835=y
CONFIG_WATCHDOG=y
CONFIG_BCM2708_WDT=m
CONFIG_MFD_ARIZONA_I2C=m
CONFIG_MFD_ARIZONA_SPI=m
CONFIG_MFD_WM5102=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=m
CONFIG_REGULATOR_ARIZONA=m
CONFIG_MEDIA_SUPPORT=m
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_MEDIA_ANALOG_TV_SUPPORT=y
Expand Down Expand Up @@ -757,6 +764,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
CONFIG_SND_BCM2708_SOC_RPI_DAC=m
CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP=m
CONFIG_SND_SIMPLE_CARD=m
CONFIG_SOUND_PRIME=m
CONFIG_HIDRAW=y
Expand Down Expand Up @@ -970,6 +978,8 @@ CONFIG_LIRC_RPI=m
CONFIG_LIRC_SASEM=m
CONFIG_LIRC_SERIAL=m
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_EXTCON=m
CONFIG_EXTCON_ARIZONA=m
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_EXT4_FS_SECURITY=y
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-bcm2708/armctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int __init armctrl_init(void __iomem * base, unsigned int irq_start,
{
unsigned int irq;

for (irq = 0; irq < NR_IRQS; irq++) {
for (irq = 0; irq < CORE_IRQS; irq++) {
unsigned int data = irq;
if (irq >= INTERRUPT_JPEG && irq <= INTERRUPT_ARASANSDIO)
data = remap_irqs[irq - INTERRUPT_JPEG];
Expand Down
159 changes: 156 additions & 3 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@
#include "armctrl.h"
#include "clock.h"

#include <linux/mfd/arizona/pdata.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/fixed.h>

#ifdef CONFIG_BCM_VC_CMA
#include <linux/broadcom/vc_cma.h>
#endif

#define GPIO_WM5102_IRQ 27
#define GPIO_WM5102_RST 17
#define GPIO_WM5102_LDOEN 22

/* Effectively we have an IOMMU (ARM<->VideoCore map) that is set up to
* give us IO access only to 64Mbytes of physical memory (26 bits). We could
Expand Down Expand Up @@ -587,14 +594,17 @@ static struct spi_board_info bcm2708_spi_devices[] = {
.bus_num = 0,
.chip_select = 0,
.mode = SPI_MODE_0,
}, {
},
#if !defined (CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP_MODULE) && !defined (CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP)
{
.modalias = "spidev",
.max_speed_hz = 500000,
.bus_num = 0,
.chip_select = 1,
.mode = SPI_MODE_0,
}
#endif
#endif
};
#endif

Expand Down Expand Up @@ -645,7 +655,7 @@ static struct platform_device bcm2835_thermal_device = {
.name = "bcm2835_thermal",
};

#ifdef CONFIG_SND_BCM2708_SOC_I2S_MODULE
#if defined(CONFIG_SND_BCM2708_SOC_I2S_MODULE) || defined(CONFIG_SND_BCM2708_SOC_I2S)
static struct resource bcm2708_i2s_resources[] = {
{
.start = I2S_BASE,
Expand All @@ -667,6 +677,138 @@ static struct platform_device bcm2708_i2s_device = {
};
#endif

#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE)
static struct regulator_consumer_supply dc1v8_consumers[] = {
REGULATOR_SUPPLY("LDOVDD", "spi0.1"),
REGULATOR_SUPPLY("AVDD", "spi0.1"),
REGULATOR_SUPPLY("DBVDD1", "spi0.1"),
REGULATOR_SUPPLY("CPVDD", "spi0.1"),
REGULATOR_SUPPLY("DBVDD2", "wm5102-codec"),
REGULATOR_SUPPLY("DBVDD3", "wm5102-codec"),
REGULATOR_SUPPLY("CPVDD", "wm5102-codec"),
REGULATOR_SUPPLY("PVDD", "1-003a"),
REGULATOR_SUPPLY("DVDD", "1-003a"),
};

static struct regulator_init_data dc1v8_data = {
.constraints = {
.always_on = 1,
},
.num_consumer_supplies = ARRAY_SIZE(dc1v8_consumers),
.consumer_supplies = dc1v8_consumers,
};

static struct fixed_voltage_config dc1v8vdd_pdata = {
.supply_name = "DC_1V8",
.microvolts = 1800000,
.init_data = &dc1v8_data,
.gpio = -1,
};

static struct platform_device dc1v8_device = {
.name = "reg-fixed-voltage",
.id = 0,
.dev = {
.platform_data = &dc1v8vdd_pdata,
},
};

static struct regulator_consumer_supply dc5v_consumers[] = {
REGULATOR_SUPPLY("SPKVDDL", "wm5102-codec"),
REGULATOR_SUPPLY("SPKVDDR", "wm5102-codec"),
};

static struct regulator_init_data dc5v_data = {
.constraints = {
.always_on = 1,
},
.num_consumer_supplies = ARRAY_SIZE(dc5v_consumers),
.consumer_supplies = dc5v_consumers,
};

static struct fixed_voltage_config dc5vvdd_pdata = {
.supply_name = "DC_5V",
.microvolts = 5000000,
.init_data = &dc5v_data,
.gpio = -1,
};

static struct platform_device dc5v_device = {
.name = "reg-fixed-voltage",
.id = 1,
.dev = {
.platform_data = &dc5vvdd_pdata,
},
};
#endif

#if defined(CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP_MODULE) || defined(CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP)
#include <linux/mfd/arizona/registers.h>

static struct resource bcm2708_clock_resources[] = {
{
.start = GPIO_BASE,
.end = GPIO_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
{
.start = GPxCLT_BASE,
.end = GPxCLT_BASE + 0x14,
.flags = IORESOURCE_MEM,
}
};

static struct platform_device snd_rpi_wsp_device = {
.name = "snd-rpi-wsp",
.id = 0,
.num_resources = ARRAY_SIZE(bcm2708_clock_resources),
.resource = bcm2708_clock_resources,
};

static struct arizona_micd_config wm5102_micd[] = {
{ 0, 1 << ARIZONA_MICD_BIAS_SRC_SHIFT, 0 },
};

static struct arizona_pdata snd_rpi_wsp_spi_platform_data = {
.reset = GPIO_WM5102_RST,
.ldoena = GPIO_WM5102_LDOEN,
.irq_flags = IRQF_TRIGGER_HIGH,
.gpio_defaults = {
[2] = 0x04, /* OPCLK */
[3] = 0x3d, /* ASYNC OPCLK */
},
.micd_configs = wm5102_micd,
.num_micd_configs = ARRAY_SIZE(wm5102_micd),
.dmic_ref = {
[1] = ARIZONA_DMIC_MICBIAS2,
},
.inmode = {
[1] = ARIZONA_INMODE_DMIC,
[2] = ARIZONA_INMODE_SE,
},
.clk32k_src = ARIZONA_32KZ_NONE,
};

static struct spi_board_info __initdata snd_rpi_wsp_spi_devices[] = {
{
.modalias = "wm5102",
.platform_data = &snd_rpi_wsp_spi_platform_data,
.max_speed_hz = 500000,
.bus_num = 0,
.chip_select = 1,
.mode = SPI_MODE_0,
.irq = GPIO_WM5102_IRQ,
}
};

static struct i2c_board_info __initdata snd_rpi_wsp_i2c_devices[] = {
{
I2C_BOARD_INFO("wm8804", 0x3A),
},
};

#endif

#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC_MODULE)
static struct platform_device snd_hifiberry_dac_device = {
.name = "snd-hifiberry-dac",
Expand Down Expand Up @@ -889,7 +1031,7 @@ void __init bcm2708_init(void)
bcm_register_device(&bcm2835_hwmon_device);
bcm_register_device(&bcm2835_thermal_device);

#ifdef CONFIG_SND_BCM2708_SOC_I2S_MODULE
#if defined(CONFIG_SND_BCM2708_SOC_I2S_MODULE) || defined(CONFIG_SND_BCM2708_SOC_I2S)
bcm_register_device(&bcm2708_i2s_device);
#endif

Expand Down Expand Up @@ -924,6 +1066,17 @@ void __init bcm2708_init(void)
i2c_register_board_info(1, snd_pcm512x_i2c_devices, ARRAY_SIZE(snd_pcm512x_i2c_devices));
#endif

#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE)
bcm_register_device(&dc1v8_device);
bcm_register_device(&dc5v_device);
#endif

#if defined(CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP_MODULE) || defined(CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP)
bcm_register_device(&snd_rpi_wsp_device);
spi_register_board_info(snd_rpi_wsp_spi_devices, ARRAY_SIZE(snd_rpi_wsp_spi_devices));
i2c_register_board_info(1, snd_rpi_wsp_i2c_devices,
ARRAY_SIZE(snd_rpi_wsp_i2c_devices));
#endif

for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
struct amba_device *d = amba_devs[i];
Expand Down
6 changes: 5 additions & 1 deletion arch/arm/mach-bcm2708/include/mach/irqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
#define GPIO_IRQ_START (HARD_IRQS + FIQ_IRQS)
#define GPIO_IRQS (32*5)
#define SPARE_IRQS (64)
#define NR_IRQS (HARD_IRQS+FIQ_IRQS+GPIO_IRQS+SPARE_IRQS)
#define CORE_IRQS (HARD_IRQS+FIQ_IRQS+GPIO_IRQS)

#define BOARD_AUDIO_IRQS 130

#define NR_IRQS (CORE_IRQS+BOARD_AUDIO_IRQS)

#endif /* _BCM2708_IRQS_H_ */
1 change: 1 addition & 0 deletions arch/arm/mach-bcm2708/include/mach/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#define DMA_BASE (BCM2708_PERI_BASE + 0x7000) /* DMA controller */
#define ARM_BASE (BCM2708_PERI_BASE + 0xB000) /* BCM2708 ARM control block */
#define PM_BASE (BCM2708_PERI_BASE + 0x100000) /* Power Management, Reset controller and Watchdog registers */
#define GPxCLT_BASE (BCM2708_PERI_BASE + 0x101070) /* Clock Manager General Purpose Clocks Control */
#define PCM_CLOCK_BASE (BCM2708_PERI_BASE + 0x101098) /* PCM Clock */
#define RNG_BASE (BCM2708_PERI_BASE + 0x104000) /* Hardware RNG */
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO */
Expand Down
2 changes: 1 addition & 1 deletion drivers/dma/bcm2708-dmaengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
void __iomem *chan_base;
int chan_id;

chan_id = bcm_dma_chan_alloc(BCM_DMA_FEATURE_LITE,
chan_id = bcm_dma_chan_alloc(BCM_DMA_FEATURE_FAST,
&chan_base,
&irq);

Expand Down
8 changes: 8 additions & 0 deletions sound/soc/bcm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ config SND_BCM2708_SOC_IQAUDIO_DAC
select SND_SOC_PCM512x
help
Say Y or M if you want to add support for IQaudIO-DAC.

config SND_BCM2708_SOC_RPI_CODEC_WSP
tristate "Support for Wolfson sound pi"
depends on SND_BCM2708_SOC_I2S
select SND_SOC_WM5102
select SND_SOC_WM8804
help
Say Y if you want to add support for Wolfson sound pi
2 changes: 2 additions & 0 deletions sound/soc/bcm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ snd-soc-hifiberry-digi-objs := hifiberry_digi.o
snd-soc-hifiberry-amp-objs := hifiberry_amp.o
snd-soc-rpi-dac-objs := rpi-dac.o
snd-soc-iqaudio-dac-objs := iqaudio-dac.o
snd-soc-rpi-wsp-objs := rpi-wolfson-sound-pi.o

obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) += snd-soc-hifiberry-amp.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_WSP) += snd-soc-rpi-wsp.o
Loading