From: 邱建斌 Date: Sat, 9 Apr 2011 09:07:26 +0000 (+0800) Subject: rk29: wm8994 pdata修改 X-Git-Tag: firefly_0821_release~10530 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=10ac2d413dd6677f5e03f7963045d24e96c551bc;p=firefly-linux-kernel-4.4.55.git rk29: wm8994 pdata修改 --- diff --git a/arch/arm/mach-rk29/board-rk29-phonesdk.c b/arch/arm/mach-rk29/board-rk29-phonesdk.c index b19cb828799d..ac294b062ff9 100755 --- a/arch/arm/mach-rk29/board-rk29-phonesdk.c +++ b/arch/arm/mach-rk29/board-rk29-phonesdk.c @@ -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) diff --git a/drivers/headset_observe/rk2818_headset.c b/drivers/headset_observe/rk2818_headset.c index f0e7133a8b58..7e6027526afc 100755 --- a/drivers/headset_observe/rk2818_headset.c +++ b/drivers/headset_observe/rk2818_headset.c @@ -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);//设置为下降沿 } diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h old mode 100644 new mode 100755 index 70d6a8687dc5..b0e4235aa4a2 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -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 diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 1aa016dbd1a7..d9e5e7f3ff3a 100755 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -33,7 +33,10 @@ #include "wm8994.h" #include #include -//#include +#include +#include +#include +#include #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); }