rk29: wm8994 pdata修改
author邱建斌 <qjb@rock-chips.com>
Sat, 9 Apr 2011 09:07:26 +0000 (17:07 +0800)
committer邱建斌 <qjb@rock-chips.com>
Sat, 9 Apr 2011 09:07:26 +0000 (17:07 +0800)
arch/arm/mach-rk29/board-rk29-phonesdk.c
drivers/headset_observe/rk2818_headset.c
include/linux/mfd/wm8994/pdata.h [changed mode: 0644->0755]
sound/soc/codecs/wm8994.c

index b19cb828799d60b0aca82fc4a0984dd37a6d2d15..ac294b062ff93515b4df4561fc0aa4d567e70044 100755 (executable)
@@ -1277,7 +1277,7 @@ struct platform_device rk29_device_gps = {
  * wm8994  codec
  * author: qjb@rock-chips.com
  *****************************************************************************************/
-#if defined(CONFIG_MFD_WM8994)
+//#if defined(CONFIG_MFD_WM8994)
 #if defined (CONFIG_REGULATOR_WM8994)
 static struct regulator_consumer_supply wm8994_ldo1_consumers[] = {
        {
@@ -1381,7 +1381,7 @@ struct wm8994_pdata wm8994_platdata = {
        .jd_scthr = 0,
        .jd_thr = 0,
 };
-#endif 
+//#endif 
 
 #ifdef CONFIG_HEADSET_DET
 #define HEADSET_GPIO RK29_PIN4_PD2
@@ -1495,9 +1495,9 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .type                   = "wm8994",
                .addr           = 0x1a,
                .flags                  = 0,
-       #if defined(CONFIG_MFD_WM8994)  
+//     #if defined(CONFIG_MFD_WM8994)  
                .platform_data  = &wm8994_platdata,     
-       #endif  
+//     #endif  
        },
 #endif
 #if defined (CONFIG_BATTERY_STC3100)
index f0e7133a8b585e96bb6bca6be4986f21c8ad13a6..7e6027526afc93d3bffce0b19d61434534cb462c 100755 (executable)
@@ -1,4 +1,4 @@
-/* arch/arm/mach-rockchip/rk28_headset.c
+/* arch/arm/mach-rockchip/rk28_headset.c
  *
  * Copyright (C) 2009 Rockchip Corporation.
  *
@@ -82,7 +82,7 @@ static irqreturn_t headset_interrupt(int irq, void *dev_id)
 static int headset_change_irqtype(unsigned int irq_type)
 {
        int ret = 0;
-       DBG("--------%s----------",__FUNCTION__);
+       DBG("--------%s----------\n",__FUNCTION__);
        free_irq(prk2818_headset_info->irq,NULL);
        
        ret = request_irq(prk2818_headset_info->irq, headset_interrupt, irq_type, NULL, NULL);
@@ -106,7 +106,7 @@ static void headsetobserve_work(struct work_struct *work)
                level = gpio_get_value(prk2818_headset_info->gpio);
                if(level < 0)
                {
-                       printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,prk2818_headset_info->irq,i);
+                       printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,prk2818_headset_info->gpio,i);
                        msleep(1);
                        continue;
                }
@@ -124,13 +124,13 @@ static void headsetobserve_work(struct work_struct *work)
                case HEADSET_IN_HIGH:
                        if(level > 0)
                        {//插入--高电平
-                               DBG("---headset in---\n");
+                               DBG("--- HEADSET_IN_HIGH headset in---\n");
                                Headset_dev.cur_headset_status = BIT_HEADSET;
                                headset_change_irqtype(IRQF_TRIGGER_FALLING);//设置为下降沿
                        }
                        else if(level == 0)
                        {//拔出--低电平
-                               DBG("---headset out---\n");             
+                               DBG("---HEADSET_IN_HIGH headset out---\n");             
                                Headset_dev.cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
                                headset_change_irqtype(IRQF_TRIGGER_RISING);//设置为上升沿
                        }
@@ -138,13 +138,13 @@ static void headsetobserve_work(struct work_struct *work)
                case HEADSET_IN_LOW:
                        if(level == 0)
                        {//插入--低电平
-                               DBG("---headset in---\n");
+                               DBG("---HEADSET_IN_LOW headset in---\n");
                                Headset_dev.cur_headset_status = BIT_HEADSET;
-                               headset_change_irqtype(IRQF_TRIGGER_RISING);///设置为上升沿
+                               headset_change_irqtype(IRQF_TRIGGER_RISING);//设置为上升沿
                        }
                        else if(level > 0)
                        {//拔出--高电平
-                               DBG("---headset out---\n");             
+                               DBG("---HEADSET_IN_LOW headset out---\n");              
                                Headset_dev.cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC);
                                headset_change_irqtype(IRQF_TRIGGER_FALLING);//设置为下降沿
                        }
old mode 100644 (file)
new mode 100755 (executable)
index 70d6a86..b0e4235
@@ -92,6 +92,9 @@ struct wm8994_pdata {
         /* Jack detect threashold levels, see datasheet for values */
         unsigned int jd_scthr:2;
         unsigned int jd_thr:2;
+
+               //rk29-a22¹¦·Åldo  =1ʹÄÜ=0²»Ê¹ÄÜ
+               unsigned int a22_ldo_enable:1;
 };
 
 #endif
index 1aa016dbd1a734b92baca1160d9af5b9334cb6ed..d9e5e7f3ff3a81543a6f4aef86826b2e47e7ff4f 100755 (executable)
 #include "wm8994.h"
 #include <linux/miscdevice.h>
 #include <linux/circ_buf.h>
-//#include <mach/spi_fpga.h>
+#include <linux/mfd/wm8994/core.h>
+#include <linux/mfd/wm8994/registers.h>
+#include <linux/mfd/wm8994/pdata.h>
+#include <linux/mfd/wm8994/gpio.h>
 
 #define WM8994_PROC
 #ifdef WM8994_PROC
@@ -64,6 +67,7 @@
 #define wm8994_mic_VCC 0x0010
 #define WM8994_DELAY 50
 
+static struct snd_soc_codec *wm8994_codec;
 struct i2c_client *wm8994_client;
 bool first_incall = false, isWM8994SetChannel = true, isSetChannelErr = false;
 struct workqueue_struct *wm8994_workqueue;
@@ -195,6 +199,7 @@ struct wm8994_priv {
        struct snd_soc_codec codec;
        struct snd_pcm_hw_constraint_list *sysclk_constraints;
        u16 reg_cache[WM8994_NUM_REG];
+       struct wm8994_pdata *pdata;
 };
 
 bool wm8994_set_status(void)
@@ -2883,11 +2888,7 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol,
        wm8994_check_channel();
 
        isWM8994SetChannel = false;
-#if defined(CONFIG_MACH_A22)
-       gpio_request(RK29_PIN6_PD3, NULL);              //AUDIO_PA_ON    
-       gpio_direction_output(RK29_PIN6_PD3,GPIO_HIGH);                 
-       gpio_free(RK29_PIN6_PD3);
-#endif
+
        return 0;
 }
 /*
@@ -3414,20 +3415,25 @@ static int wm8994_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
        struct snd_soc_codec *codec = socdev->card->codec;
-
+       struct wm8994_priv *wm8994 = codec->private_data;
+       struct wm8994_pdata *pdata = wm8994->pdata;
+       
        isWM8994SetChannel = true;
        wm8994_set_bias_level(codec,SND_SOC_BIAS_OFF);
+       if(pdata ->a22_ldo_enable == 1)
+       {
+               DBG("wm8994 suspend disable a22_ldo\n");
+               gpio_request(RK29_PIN6_PD3, NULL);              //AUDIO_PA_ON    
+               gpio_direction_output(RK29_PIN6_PD3,GPIO_LOW);          
+               gpio_free(RK29_PIN6_PD3);
+       }
+       
        wm8994_write(0x00, 0x00);
-       msleep(50);
 
        gpio_request(WM_EN_PIN, NULL);
        gpio_direction_output(WM_EN_PIN,GPIO_LOW);
        gpio_free(WM_EN_PIN);
-#if defined(CONFIG_MACH_A22)   
-       gpio_request(RK29_PIN6_PD3, NULL);              //AUDIO_PA_ON    
-       gpio_direction_output(RK29_PIN6_PD3,GPIO_LOW);          
-       gpio_free(RK29_PIN6_PD3);
-#endif 
+       
        msleep(50);
 
        return 0;
@@ -3437,6 +3443,8 @@ static int wm8994_resume(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
        struct snd_soc_codec *codec = socdev->card->codec;
+       struct wm8994_priv *wm8994 = codec->private_data;
+       struct wm8994_pdata *pdata = wm8994->pdata;     
        wm8994_codec_fnc_t **wm8994_fnc_ptr = wm8994_codec_sequence;
        unsigned char wm8994_resume_mode = wm8994_current_mode;
        wm8994_current_mode = null;
@@ -3467,16 +3475,17 @@ static int wm8994_resume(struct platform_device *pdev)
        wm8994_check_channel();
 
        isWM8994SetChannel = false;
-#if defined(CONFIG_MACH_A22)   
-       gpio_request(RK29_PIN6_PD3, NULL);              //AUDIO_PA_ON    
-       gpio_direction_output(RK29_PIN6_PD3,GPIO_HIGH);                 
-       gpio_free(RK29_PIN6_PD3);
-#endif 
+       
+       if(pdata ->a22_ldo_enable == 1)
+       {
+               DBG("wm8994_resume enable a22_ldo\n");
+               gpio_request(RK29_PIN6_PD3, NULL);              //AUDIO_PA_ON    
+               gpio_direction_output(RK29_PIN6_PD3,GPIO_HIGH);                 
+               gpio_free(RK29_PIN6_PD3);
+       }
        return 0;
 }
 
-static struct snd_soc_codec *wm8994_codec;
-
 #ifdef WM8994_PROC
 static ssize_t wm8994_proc_write(struct file *file, const char __user *buffer,
                           unsigned long len, void *data)
@@ -3996,7 +4005,6 @@ static int wm8994_proc_init(void){
 }
 
 #endif
-
 static int wm8994_probe(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -4004,7 +4012,8 @@ static int wm8994_probe(struct platform_device *pdev)
        unsigned long wm8994_port = 0;
        int ret = 0;
        char b[20];
-
+       struct wm8994_priv *wm8994;
+       struct wm8994_pdata *pdata;
 #ifdef WM8994_PROC
        wm8994_proc_init();
 #endif
@@ -4016,9 +4025,19 @@ static int wm8994_probe(struct platform_device *pdev)
 
        socdev->card->codec = wm8994_codec;
        codec = wm8994_codec;
-
-//     recorder_and_AP_to_speakers();
-
+       
+       recorder_and_AP_to_speakers();
+       
+       wm8994 = codec->private_data;
+       pdata = wm8994->pdata;
+       if(pdata->a22_ldo_enable == 1)
+       {
+               DBG("enable a22_ldo\n");
+               gpio_request(RK29_PIN6_PD3, NULL);              //AUDIO_PA_ON    
+               gpio_direction_output(RK29_PIN6_PD3,GPIO_HIGH);                 
+               gpio_free(RK29_PIN6_PD3);
+       }
+       
        setup_timer(&wm8994_timer, wm8994_codec_timer, wm8994_port);
        wm8994_timer.expires  = jiffies+500;//=500ms
        add_timer(&wm8994_timer);
@@ -4030,12 +4049,6 @@ static int wm8994_probe(struct platform_device *pdev)
        else
                INIT_WORK(&wm8994_work, wm8994_work_handler);
 
-       if (wm8994_codec == NULL) {
-               dev_err(&pdev->dev, "Codec device not registered\n");
-               return -ENODEV;
-       }
-
-
        /* register pcms */
        ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
        if (ret < 0) {
@@ -4178,7 +4191,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
        codec->control_data = i2c;
 
        codec->dev = &i2c->dev;
-
+       wm8994->pdata = i2c->dev.platform_data;//add
        return wm8994_register(wm8994, SND_SOC_I2C);
 }