rt3261: add headset detect and codec_en control pin.
author宋秀杰 <sxj@rock-chips.com>
Fri, 27 Jul 2012 07:06:42 +0000 (15:06 +0800)
committer宋秀杰 <sxj@rock-chips.com>
Fri, 27 Jul 2012 07:06:42 +0000 (15:06 +0800)
arch/arm/mach-rk30/board-rk30-phonepad.c
arch/arm/mach-rk30/include/mach/board.h
sound/soc/codecs/rt3261.c
sound/soc/codecs/rt3261.h

index 460168f4620d1bad042d2b113fc4359dd603d414..be6fdac5682748dae5117fa59e764edf6040bf22 100755 (executable)
@@ -45,6 +45,7 @@
 #include <linux/rfkill-rk.h>
 #include <linux/sensor-dev.h>
 #include <linux/mfd/tps65910.h>
+#include "../../../drivers/headset_observe/rk_headset.h"
 
 #if defined(CONFIG_HDMI_RK30)
        #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
@@ -597,6 +598,40 @@ static struct goodix_i2c_rmi_platform_data ts82x_pdata = {
 };
 #endif
 
+#if defined (CONFIG_RK_HEADSET_DET) || defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
+
+static int rk_headset_io_init(int gpio, char *iomux_name, int iomux_mode)
+{
+               int ret;
+               ret = gpio_request(gpio, NULL);
+               if(ret) 
+                       return ret;
+
+               rk30_mux_api_set(iomux_name, iomux_mode);
+               gpio_pull_updown(gpio, PullDisable);
+               gpio_direction_input(gpio);
+               return 0;
+};
+
+struct rk_headset_pdata rk_headset_info = {
+               .Headset_gpio           = RK30_PIN0_PC7,
+               .headset_in_type = HEADSET_IN_HIGH,
+               .Hook_adc_chn = 2,
+               .hook_key_code = KEY_MEDIA,
+               .headset_gpio_info = {GPIO0C7_TRACECTL_SMCADDR3_NAME, GPIO0C_GPIO0C7},
+               .headset_io_init = rk_headset_io_init,
+};
+
+struct platform_device rk_device_headset = {
+               .name   = "rk_headsetdet",
+               .id     = 0,
+               .dev    = {
+                           .platform_data = &rk_headset_info,
+               }
+};
+#endif
+
+
 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
 #define TOUCH_PWR_PIN    INVALID_GPIO
@@ -748,6 +783,24 @@ static struct platform_device rk29_device_backlight = {
 
 #endif
 
+#ifdef CONFIG_SND_SOC_RT3261
+
+static int rt3261_io_init(int gpio, char *iomux_name, int iomux_mode)
+{
+       gpio_request(gpio,NULL);
+       rk30_mux_api_set(iomux_name, iomux_mode);
+       gpio_direction_output(gpio,1);
+       
+};
+
+static struct rt3261_platform_data rt3261_info = {
+       .codec_en_gpio                  = RK30_PIN4_PD7,
+       .codec_en_gpio_info             = {GPIO4D7_SMCDATA15_TRACEDATA15_NAME,GPIO4D_GPIO4D7},
+       .io_init                                = rt3261_io_init,
+};
+
+#endif
+
 #ifdef CONFIG_RK29_SUPPORT_MODEM
 
 #define RK30_MODEM_POWER        RK30_PIN4_PD1
@@ -1574,6 +1627,9 @@ static struct platform_device *devices[] __initdata = {
 #if defined(CONFIG_SEW868)
        &rk30_device_sew868,
 #endif
+#if defined (CONFIG_RK_HEADSET_DET) ||  defined (CONFIG_RK_HEADSET_IRQ_HOOK_ADC_DET)
+       &rk_device_headset,
+#endif
 #ifdef CONFIG_BATTERY_RK30_ADC
        &rk30_device_adc_battery,
 #endif
@@ -1653,6 +1709,7 @@ static struct i2c_board_info __initdata i2c0_info[] = {
                 .type                   = "rt3261",
                 .addr                   = 0x1c,
                 .flags                  = 0,
+                               .platform_data          = &rt3261_info,
         },
 #endif
 
index f4f1c358352d15e1daac1c139ef6f6bb79785807..0db8c627c18a7d5af8b3610816cde1b04ed69d51 100755 (executable)
@@ -62,6 +62,17 @@ struct ft5x0x_platform_data{
 };
 #endif
 
+struct codec_io_info{
+       char    iomux_name[50];
+       int             iomux_mode;     
+};
+
+struct rt3261_platform_data{
+       unsigned int codec_en_gpio;
+       struct codec_io_info codec_en_gpio_info;
+       int (*io_init)(int, char *, int);
+};
+
 extern struct rk29_sdmmc_platform_data default_sdmmc0_data;
 extern struct rk29_sdmmc_platform_data default_sdmmc1_data;
 
index a172c67c1f68128d3a4e6104b9b755f96b683d2a..ff82ae6380c760f9e9055bad5725a5c50254f4e1 100644 (file)
@@ -24,7 +24,7 @@
 #include <sound/soc-dapm.h>
 #include <sound/initval.h>
 #include <sound/tlv.h>
-
+#include <mach/board.h>
 
 #define RT3261_PROC
 #ifdef RT3261_PROC
@@ -2932,11 +2932,18 @@ static int __devinit rt3261_i2c_probe(struct i2c_client *i2c,
 {
        struct rt3261_priv *rt3261;
        int ret;
+       struct rt3261_platform_data *pdata = pdata = i2c->dev.platform_data;
 
        rt3261 = kzalloc(sizeof(struct rt3261_priv), GFP_KERNEL);
        if (NULL == rt3261)
                return -ENOMEM;
 
+       rt3261->codec_en_gpio = pdata->codec_en_gpio;
+       rt3261->io_init = pdata->io_init;
+
+       if(rt3261->io_init)
+               rt3261->io_init(pdata->codec_en_gpio, pdata->codec_en_gpio_info.iomux_name, pdata->codec_en_gpio_info.iomux_mode);
+
        i2c_set_clientdata(i2c, rt3261);
        DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
        ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt3261,
index 06e9bad722602d095dfd1224b00a4a3a3f8f52b4..8f9741869838d1e3b5084a57993baaa1a795c7bd 100644 (file)
@@ -2140,6 +2140,9 @@ struct rt3261_priv {
        int dsp_sw; /* expected parameter setting */
        bool dsp_play_pass;
        bool dsp_rec_pass;
+
+       unsigned int codec_en_gpio;
+       int (*io_init)(int gpio, char *iomux_name, int iomux_mode);
 };
 
 int rt3261_conn_mux_path(struct snd_soc_codec *codec,