rk610 codec : spk_ctl_io filling in board
author邱建斌 <qjb@rock-chips.com>
Mon, 14 Jan 2013 08:35:58 +0000 (16:35 +0800)
committer邱建斌 <qjb@rock-chips.com>
Mon, 14 Jan 2013 08:35:58 +0000 (16:35 +0800)
arch/arm/mach-rk30/board-rk30-ds1001b.c [changed mode: 0644->0755]
arch/arm/mach-rk30/board-rk30-ds975.c
arch/arm/mach-rk30/board-rk30-sdk.c
arch/arm/mach-rk30/board-rk3066b-m701.c
arch/arm/mach-rk30/board-rk3066b-sdk.c
arch/arm/mach-rk30/board-rk3108-tb.c
arch/arm/mach-rk30/board-rk3168-LR097.c
arch/arm/mach-rk30/board-rk3168-ds1006h.c [changed mode: 0644->0755]
arch/arm/mach-rk30/board-rk3168-tb.c
arch/arm/plat-rk/include/plat/board.h
sound/soc/codecs/rk610_codec.c

old mode 100644 (file)
new mode 100755 (executable)
index efcdbb9..6bcb039
@@ -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
index 6294f41603f362b5c415c6ce692123dacace44c5..caff909fdb5253d7730dd68f2912293a7020637b 100755 (executable)
@@ -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
 };
index beb6a3ce237c3c72f116516043255919907974af..4bb16a844de02dc60b3a7cc743e64076bc14d2c0 100755 (executable)
@@ -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
index 21362549a3ba0078373b5d9acf33bbff3b640011..eee093215a8cd2d007e507c2bbc72cefc6cb2251 100755 (executable)
@@ -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
index e63803a73468fc447627aa923eaecdf15a967f43..1958324476a959035f62b9af9a60164d221c4810 100755 (executable)
@@ -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
index 606c7a60335f7b72076fc3a7d398d8572ccc742d..c8e2b82ccf91777d3700bff230f7cdb6db0ab2f6 100755 (executable)
@@ -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
index d3157ff6ec1fc46744ee5eb58071f96461aac9ae..ac01662e020b96c3af514f1c05a7832e1de5a581 100755 (executable)
@@ -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
old mode 100644 (file)
new mode 100755 (executable)
index 421e99c..ba4606e
@@ -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
index 08b6bf44103bb45f44f2b5169c3e9b7745ada83f..8b1fa831c427eb884614f45c437625203ce68892 100755 (executable)
@@ -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
index 4da0fe24488150bf7ad1fcde9fabd2a2174c5bb5..fa62daa1411f5e2a82c56a35303cea0199b31024 100755 (executable)
@@ -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
index 2f127f6a231665d8ab2cb691d305128609d544aa..3f6cd71132a01521a77887c05bb2dda697f19998 100755 (executable)
@@ -29,6 +29,7 @@
 #include <mach/iomux.h>
 #include <linux/workqueue.h>
 #include "rk610_codec.h"
+#include <mach/board.h>
 
 #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;