From 961aace07cca37fcc5a5b74b904e950aa74f5832 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=82=B1=E5=BB=BA=E6=96=8C?= Date: Mon, 14 Jan 2013 16:35:58 +0800 Subject: [PATCH] rk610 codec : spk_ctl_io filling in board --- arch/arm/mach-rk30/board-rk30-ds1001b.c | 15 ++++++++ arch/arm/mach-rk30/board-rk30-ds975.c | 16 +++++++++ arch/arm/mach-rk30/board-rk30-sdk.c | 13 +++++++ arch/arm/mach-rk30/board-rk3066b-m701.c | 15 ++++++++ arch/arm/mach-rk30/board-rk3066b-sdk.c | 14 ++++++++ arch/arm/mach-rk30/board-rk3108-tb.c | 15 ++++++++ arch/arm/mach-rk30/board-rk3168-LR097.c | 15 ++++++++ arch/arm/mach-rk30/board-rk3168-ds1006h.c | 15 ++++++++ arch/arm/mach-rk30/board-rk3168-tb.c | 15 ++++++++ arch/arm/plat-rk/include/plat/board.h | 4 +++ sound/soc/codecs/rk610_codec.c | 42 ++++++++++++++++++++--- 11 files changed, 175 insertions(+), 4 deletions(-) mode change 100644 => 100755 arch/arm/mach-rk30/board-rk30-ds1001b.c mode change 100644 => 100755 arch/arm/mach-rk30/board-rk3168-ds1006h.c diff --git a/arch/arm/mach-rk30/board-rk30-ds1001b.c b/arch/arm/mach-rk30/board-rk30-ds1001b.c old mode 100644 new mode 100755 index efcdbb9647d8..6bcb03917cc8 --- a/arch/arm/mach-rk30/board-rk30-ds1001b.c +++ b/arch/arm/mach-rk30/board-rk30-ds1001b.c @@ -1157,6 +1157,20 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = { }; #endif // CONFIG_SDMMC0_RK29 +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN4_PC6, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_SDMMC1_RK29 #define CONFIG_SDMMC1_USE_DMA static int rk29_sdmmc1_cfg_gpio(void) @@ -1383,6 +1397,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk30-ds975.c b/arch/arm/mach-rk30/board-rk30-ds975.c index 6294f41603f3..caff909fdb52 100755 --- a/arch/arm/mach-rk30/board-rk30-ds975.c +++ b/arch/arm/mach-rk30/board-rk30-ds975.c @@ -1522,6 +1522,20 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = { }; #endif // CONFIG_SDMMC0_RK29 +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN4_PC6, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_SDMMC1_RK29 #define CONFIG_SDMMC1_USE_DMA static int rk29_sdmmc1_cfg_gpio(void) @@ -1832,6 +1846,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif @@ -1901,6 +1916,7 @@ static struct i2c_board_info __initdata i2c1_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif }; diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index beb6a3ce237c..4bb16a844de0 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -835,7 +835,19 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { .rk610_power_on_init = rk610_power_on_init, }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN4_PC6, + .io_init = rk610_codec_io_init, +}; +#endif #ifdef CONFIG_ANDROID_TIMED_GPIO static struct timed_gpio timed_gpios[] = { { @@ -1536,6 +1548,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk3066b-m701.c b/arch/arm/mach-rk30/board-rk3066b-m701.c index 21362549a3ba..eee093215a8c 100755 --- a/arch/arm/mach-rk30/board-rk3066b-m701.c +++ b/arch/arm/mach-rk30/board-rk3066b-m701.c @@ -859,6 +859,20 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN2_PA0, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_ANDROID_TIMED_GPIO static struct timed_gpio timed_gpios[] = { { @@ -1528,6 +1542,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk3066b-sdk.c b/arch/arm/mach-rk30/board-rk3066b-sdk.c index e63803a73468..1958324476a9 100755 --- a/arch/arm/mach-rk30/board-rk3066b-sdk.c +++ b/arch/arm/mach-rk30/board-rk3066b-sdk.c @@ -672,6 +672,19 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { .rk610_power_on_init = rk610_power_on_init, }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN2_PA0, + .io_init = rk610_codec_io_init, +}; +#endif #ifdef CONFIG_ANDROID_TIMED_GPIO static struct timed_gpio timed_gpios[] = { @@ -1368,6 +1381,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk3108-tb.c b/arch/arm/mach-rk30/board-rk3108-tb.c index 606c7a60335f..c8e2b82ccf91 100755 --- a/arch/arm/mach-rk30/board-rk3108-tb.c +++ b/arch/arm/mach-rk30/board-rk3108-tb.c @@ -673,6 +673,20 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN4_PC6, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_ANDROID_TIMED_GPIO static struct timed_gpio timed_gpios[] = { { @@ -1319,6 +1333,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk3168-LR097.c b/arch/arm/mach-rk30/board-rk3168-LR097.c index d3157ff6ec1f..ac01662e020b 100755 --- a/arch/arm/mach-rk30/board-rk3168-LR097.c +++ b/arch/arm/mach-rk30/board-rk3168-LR097.c @@ -708,6 +708,20 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN2_PD7, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_ANDROID_TIMED_GPIO static struct timed_gpio timed_gpios[] = { { @@ -1504,6 +1518,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk3168-ds1006h.c b/arch/arm/mach-rk30/board-rk3168-ds1006h.c old mode 100644 new mode 100755 index 421e99cab20e..ba4606e66207 --- a/arch/arm/mach-rk30/board-rk3168-ds1006h.c +++ b/arch/arm/mach-rk30/board-rk3168-ds1006h.c @@ -531,6 +531,20 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN2_PD7, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_ION #define ION_RESERVE_SIZE (80 * SZ_1M) static struct ion_platform_data rk30_ion_pdata = { @@ -1562,6 +1576,7 @@ static struct i2c_board_info __initdata i2c4_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/mach-rk30/board-rk3168-tb.c b/arch/arm/mach-rk30/board-rk3168-tb.c index 08b6bf44103b..8b1fa831c427 100755 --- a/arch/arm/mach-rk30/board-rk3168-tb.c +++ b/arch/arm/mach-rk30/board-rk3168-tb.c @@ -666,6 +666,20 @@ static struct rk610_ctl_platform_data rk610_ctl_pdata = { }; #endif +#ifdef CONFIG_SND_SOC_RK610 +static int rk610_codec_io_init(void) +{ +//if need iomux. +//Must not gpio_request + return 0; +} + +static struct rk610_codec_platform_data rk610_codec_pdata = { + .spk_ctl_io = RK30_PIN4_PC6, + .io_init = rk610_codec_io_init, +}; +#endif + #ifdef CONFIG_ANDROID_TIMED_GPIO static struct timed_gpio timed_gpios[] = { { @@ -1361,6 +1375,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { .type = "rk610_i2c_codec", .addr = 0x60, .flags = 0, + .platform_data = &rk610_codec_pdata, }, #endif #endif diff --git a/arch/arm/plat-rk/include/plat/board.h b/arch/arm/plat-rk/include/plat/board.h index 4da0fe244881..fa62daa1411f 100755 --- a/arch/arm/plat-rk/include/plat/board.h +++ b/arch/arm/plat-rk/include/plat/board.h @@ -440,6 +440,10 @@ struct rt3261_platform_data { unsigned int playback_if2_data_control; }; +struct rk610_codec_platform_data { + unsigned int spk_ctl_io; + int (*io_init)(void); +}; #define BOOT_MODE_NORMAL 0 #define BOOT_MODE_FACTORY2 1 diff --git a/sound/soc/codecs/rk610_codec.c b/sound/soc/codecs/rk610_codec.c index 2f127f6a2316..3f6cd71132a0 100755 --- a/sound/soc/codecs/rk610_codec.c +++ b/sound/soc/codecs/rk610_codec.c @@ -29,6 +29,7 @@ #include #include #include "rk610_codec.h" +#include #define RK610_PROC #ifdef RK610_PROC @@ -42,6 +43,9 @@ //you can look soc-core.c the resume source.s #define RESUME_PROBLEM 0 +//old control method,please filling rk610_codec_platform_data into Board-xx-xx.c +//qjb 2013-01-14 +#if 0 #if defined(CONFIG_MACH_RK3168_DS1006H)|| defined(CONFIG_MACH_RK3168_LR097) #define RK610_SPK_CTRL_PIN RK30_PIN2_PD7 #elif defined(CONFIG_ARCH_RK3066B) @@ -51,6 +55,8 @@ #else #define RK610_SPK_CTRL_PIN RK29_PIN6_PB6 #endif +#endif + //1:set pll from rk610 #define RK610_CTL_PLL 0 @@ -109,6 +115,7 @@ struct rk610_codec_priv { #if RESUME_PROBLEM int rk610_workstatus; #endif + struct rk610_codec_platform_data *pdata; }; void codec_set_spk(bool on) @@ -123,9 +130,9 @@ void codec_set_spk(bool on) rk610_codec->hdmi_ndet = on; if(on) - gpio_set_value(RK610_SPK_CTRL_PIN, GPIO_HIGH); + gpio_set_value(rk610_codec->spk_ctrl_io, GPIO_HIGH); else - gpio_set_value(RK610_SPK_CTRL_PIN, GPIO_LOW); + gpio_set_value(rk610_codec->spk_ctrl_io, GPIO_LOW); } EXPORT_SYMBOL(codec_set_spk); @@ -746,7 +753,10 @@ static int rk610_codec_probe(struct snd_soc_codec *codec) } INIT_DELAYED_WORK(&rk610_codec->rk610_delayed_work, rk610_delayedwork_fun); - + +//old control method,please filling rk610_codec_platform_data into Board-xx-xx.c +//qjb 2013-01-14 +#if 0 #ifdef RK610_SPK_CTRL_PIN rk610_codec->spk_ctrl_io = RK610_SPK_CTRL_PIN; ret = gpio_request(rk610_codec->spk_ctrl_io, "rk610 spk_ctrl"); @@ -759,6 +769,18 @@ static int rk610_codec_probe(struct snd_soc_codec *codec) #else rk610_codec->spk_ctrl_io = 0; #endif +#endif + if(rk610_codec->spk_ctrl_io) + { + ret = gpio_request(rk610_codec->spk_ctrl_io, "rk610 spk_ctrl"); + if (ret){ + printk("rk610_control request gpio fail!\n"); + return ret; + } + gpio_direction_output(rk610_codec->spk_ctrl_io, GPIO_LOW); + gpio_set_value(rk610_codec->spk_ctrl_io, GPIO_LOW); + } + rk610_codec->hdmi_ndet = true; #if RESUME_PROBLEM rk610_codec->rk610_workstatus = SND_SOC_DAPM_STREAM_NOP; @@ -801,12 +823,24 @@ static int rk610_codec_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct rk610_codec_priv *rk610_codec; + struct rk610_codec_platform_data *pdata = i2c->dev.platform_data; int ret; DBG("%s start\n", __FUNCTION__); rk610_codec = kzalloc(sizeof(struct rk610_codec_priv), GFP_KERNEL); if (rk610_codec == NULL) return -ENOMEM; - +//qjb 2013-01-14 + rk610_codec->pdata = pdata; + rk610_codec->spk_ctrl_io = pdata->spk_ctl_io; + if(pdata->io_init){ + ret = pdata->io_init(); + if (ret < 0) { + dev_err(&i2c->dev, "Failed to register codec pdata io_init error: %d\n", ret); + kfree(rk610_codec); + return ret; + } + } + i2c_set_clientdata(i2c, rk610_codec); rk610_codec->control_type = SND_SOC_I2C; -- 2.34.1