From 0e58cc42410dedab43ccf58572e05d72e1a2ca1d Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 22 Nov 2010 17:44:53 +0800 Subject: [PATCH] Add rk29 rk1000 codec and i2s --- arch/arm/mach-rk29/Makefile | 1 + arch/arm/mach-rk29/board-rk29sdk.c | 13 +++++ arch/arm/mach-rk29/devices.h | 6 +++ arch/arm/mach-rk29/include/mach/board.h | 6 +++ arch/arm/mach-rk29/rk29-audio.c | 68 +++++++++++++++++++++++++ sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/codecs/rk1000_codec.c | 9 ++-- 8 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 arch/arm/mach-rk29/rk29-audio.c diff --git a/arch/arm/mach-rk29/Makefile b/arch/arm/mach-rk29/Makefile index df59ba3d11af..18e5948018f4 100644 --- a/arch/arm/mach-rk29/Makefile +++ b/arch/arm/mach-rk29/Makefile @@ -1,3 +1,4 @@ obj-y += timer.o io.o devices.o iomux.o clock.o rk29-pl330.o dma.o gpio.o +obj-$(CONFIG_SND_RK29_SOC_I2S) += rk29-audio.o obj-$(CONFIG_RK29_VPU) += vpu.o obj-$(CONFIG_MACH_RK29SDK) += board-rk29sdk.o board-rk29sdk-key.o diff --git a/arch/arm/mach-rk29/board-rk29sdk.c b/arch/arm/mach-rk29/board-rk29sdk.c index 1ff06bb853ff..6d446c4ad8f2 100755 --- a/arch/arm/mach-rk29/board-rk29sdk.c +++ b/arch/arm/mach-rk29/board-rk29sdk.c @@ -410,6 +410,13 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = { .flags = 0, }, #endif +#if defined (CONFIG_SND_SOC_RK1000) + { + .type = "rk1000_i2c_codec", + .addr = 0x60, + .flags = 0, + }, +#endif #if defined (CONFIG_BATTERY_STC3100) { .type = "stc3100-battery", @@ -663,6 +670,12 @@ static struct platform_device *devices[] __initdata = { #ifdef CONFIG_I2C3_RK29 &rk29_device_i2c3, #endif + +#ifdef CONFIG_SND_RK29_SOC_I2S + &rk29_device_iis_2ch, + //&rk29_device_iis_8ch, +#endif + #ifdef CONFIG_KEYS_RK29 &rk29_device_keys, #endif diff --git a/arch/arm/mach-rk29/devices.h b/arch/arm/mach-rk29/devices.h index d202ce311b50..41e15afdeec2 100755 --- a/arch/arm/mach-rk29/devices.h +++ b/arch/arm/mach-rk29/devices.h @@ -17,14 +17,20 @@ #define __ARCH_ARM_MACH_RK29_DEVICES_H extern struct rk29_nand_platform_data rk29_nand_data; + extern struct rk29_i2c_platform_data default_i2c0_data; extern struct rk29_i2c_platform_data default_i2c1_data; extern struct rk29_i2c_platform_data default_i2c2_data; extern struct rk29_i2c_platform_data default_i2c3_data; + extern struct platform_device rk29_device_i2c0; extern struct platform_device rk29_device_i2c1; extern struct platform_device rk29_device_i2c2; extern struct platform_device rk29_device_i2c3; + +extern struct platform_device rk29_device_iis_2ch; +extern struct platform_device rk29_device_iis_8ch; + extern struct platform_device rk29_device_uart0; extern struct platform_device rk29_device_uart1; extern struct platform_device rk29_device_uart2; diff --git a/arch/arm/mach-rk29/include/mach/board.h b/arch/arm/mach-rk29/include/mach/board.h index 17dbf18b01ab..31031a0c2a7c 100755 --- a/arch/arm/mach-rk29/include/mach/board.h +++ b/arch/arm/mach-rk29/include/mach/board.h @@ -100,6 +100,12 @@ struct rk29_i2c_platform_data { int (*io_deinit)(void); }; +/*i2s*/ +struct rk29_i2s_platform_data { + int (*io_init)(void); + int (*io_deinit)(void); +}; + void __init rk29_map_common_io(void); void __init rk29_clock_init(void); diff --git a/arch/arm/mach-rk29/rk29-audio.c b/arch/arm/mach-rk29/rk29-audio.c new file mode 100644 index 000000000000..7238538bb1e9 --- /dev/null +++ b/arch/arm/mach-rk29/rk29-audio.c @@ -0,0 +1,68 @@ + +#include +#include +#include + +#include +#include +#include + +static struct resource rk29_iis_2ch_resource[] = { + [0] = { + .start = RK29_I2S_2CH_PHYS, + .end = RK29_I2S_2CH_PHYS + RK29_I2S_2CH_SIZE, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = DMACH_I2S_2CH_TX, + .end = DMACH_I2S_2CH_TX, + .flags = IORESOURCE_DMA, + }, + [2] = { + .start = DMACH_I2S_2CH_RX, + .end = DMACH_I2S_2CH_RX, + .flags = IORESOURCE_DMA, + }, + [3] = { + .start = IRQ_I2S_2CH, + .end = IRQ_I2S_2CH, + .flags = IORESOURCE_IRQ, + }, +}; + +struct platform_device rk29_device_iis_2ch = { + .name = "rk29-i2s", + .id = 0, + .num_resources = ARRAY_SIZE(rk29_iis_2ch_resource), + .resource = rk29_iis_2ch_resource, +}; + +static struct resource rk29_iis_8ch_resource[] = { + [0] = { + .start = RK29_I2S_8CH_PHYS, + .end = RK29_I2S_8CH_PHYS + RK29_I2S_8CH_SIZE, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = DMACH_I2S_8CH_TX, + .end = DMACH_I2S_8CH_TX, + .flags = IORESOURCE_DMA, + }, + [2] = { + .start = DMACH_I2S_8CH_RX, + .end = DMACH_I2S_8CH_RX, + .flags = IORESOURCE_DMA, + }, + [3] = { + .start = IRQ_I2S_8CH, + .end = IRQ_I2S_8CH, + .flags = IORESOURCE_IRQ, + }, +}; + +struct platform_device rk29_device_iis_8ch = { + .name = "rk29-i2s", + .id = 1, + .num_resources = ARRAY_SIZE(rk29_iis_8ch_resource), + .resource = rk29_iis_8ch_resource, +}; diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 36258a0b546b..40b0f7beab08 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -37,6 +37,7 @@ source "sound/soc/s6000/Kconfig" source "sound/soc/sh/Kconfig" source "sound/soc/txx9/Kconfig" source "sound/soc/rk2818/Kconfig" +source "sound/soc/rk29/Kconfig" # Supported codecs source "sound/soc/codecs/Kconfig" diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 6adaa55b42e9..ffa30c5832ae 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_SND_SOC) += s6000/ obj-$(CONFIG_SND_SOC) += sh/ obj-$(CONFIG_SND_SOC) += txx9/ obj-$(CONFIG_SND_SOC) += rk2818/ +obj-$(CONFIG_SND_SOC) += rk29/ diff --git a/sound/soc/codecs/rk1000_codec.c b/sound/soc/codecs/rk1000_codec.c index dac31cadcd1a..7d0736c78b76 100644 --- a/sound/soc/codecs/rk1000_codec.c +++ b/sound/soc/codecs/rk1000_codec.c @@ -131,10 +131,13 @@ static int rk1000_codec_write(struct snd_soc_codec *codec, unsigned int reg, rk1000_codec_write_reg_cache (codec, reg, value); i2c = (struct i2c_client *)codec->control_data; i2c->addr = (i2c->addr & 0x60)|reg; - if (codec->hw_write(codec->control_data, data, 1) == 2) + if (codec->hw_write(codec->control_data, data, 1) == 2){ + DBG("================%s Run OK================\n",__FUNCTION__,__LINE__); return 0; - else + }else{ + DBG("================%s Run EIO================\n",__FUNCTION__,__LINE__); return -EIO; + } } static const struct snd_kcontrol_new rk1000_codec_snd_controls[] = { @@ -803,7 +806,7 @@ static int rk1000_codec_register(struct rk1000_codec_priv *rk1000_codec, //goto err; //} -#if 1 +#if 0 //fzf rk2818 is SPK_CTL gpio_request(RK2818_PIN_PF7, "rk1000_codec"); rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL_NAME, IOMUXA_GPIO1_A3B7); gpio_direction_output(RK2818_PIN_PF7,GPIO_HIGH); -- 2.34.1