From cc8bde17ce07d57b8cab96b6b627ed5ef5e28951 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=82=B1=E5=BB=BA=E6=96=8C?= Date: Sun, 1 Apr 2012 15:35:12 +0800 Subject: [PATCH] rk30phone : update wm8994 config --- arch/arm/configs/rk30_phone_defconfig | 6 +- arch/arm/mach-rk30/board-rk30-phone.c | 157 +++++++++++++++++++++++++- sound/soc/codecs/wm8994.c | 6 +- sound/soc/rk29/Kconfig | 2 +- sound/soc/rk29/rk29_wm8994.c | 6 +- 5 files changed, 170 insertions(+), 7 deletions(-) mode change 100755 => 100644 arch/arm/configs/rk30_phone_defconfig diff --git a/arch/arm/configs/rk30_phone_defconfig b/arch/arm/configs/rk30_phone_defconfig old mode 100755 new mode 100644 index 9170808a9770..0ba39a748a61 --- a/arch/arm/configs/rk30_phone_defconfig +++ b/arch/arm/configs/rk30_phone_defconfig @@ -260,7 +260,9 @@ CONFIG_SPI=y CONFIG_SPIM_RK29=y CONFIG_SPIM0_RK29=y CONFIG_SPIM1_RK29=y +CONFIG_RK_HEADSET_DET=y CONFIG_GPIO_WM831X=y +CONFIG_GPIO_WM8994=y CONFIG_EXPANDED_GPIO_NUM=0 CONFIG_EXPANDED_GPIO_IRQ_NUM=0 CONFIG_SPI_FPGA_GPIO_NUM=0 @@ -271,8 +273,10 @@ CONFIG_WM831X_POWER=y CONFIG_TEST_POWER=y # CONFIG_HWMON is not set CONFIG_MFD_WM831X_I2C=y +CONFIG_MFD_WM8994=y CONFIG_REGULATOR=y CONFIG_REGULATOR_WM831X=y +CONFIG_REGULATOR_WM8994=y CONFIG_MEDIA_SUPPORT=y CONFIG_VIDEO_DEV=y CONFIG_SOC_CAMERA=y @@ -306,7 +310,7 @@ CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_RK29_SOC=y CONFIG_SND_I2S_DMA_EVENT_STATIC=y -CONFIG_SND_RK29_SOC_RT5631=y +CONFIG_SND_RK29_SOC_WM8994=y CONFIG_SND_RK29_CODEC_SOC_SLAVE=y CONFIG_HID_A4TECH=y CONFIG_HID_ACRUX=y diff --git a/arch/arm/mach-rk30/board-rk30-phone.c b/arch/arm/mach-rk30/board-rk30-phone.c index 2d0bf0e1deca..081364e74077 100755 --- a/arch/arm/mach-rk30/board-rk30-phone.c +++ b/arch/arm/mach-rk30/board-rk30-phone.c @@ -39,6 +39,10 @@ #include #include +#include +#include +#include +#include "../../../drivers/headset_observe/rk_headset.h" #if defined(CONFIG_SPIM_RK29) #include "../../../drivers/spi/rk29_spim.h" @@ -531,6 +535,141 @@ static struct spi_board_info board_spi_devices[] = { #endif }; +/***************************************************************************************** + * wm8994 codec + * author: qjb@rock-chips.com + *****************************************************************************************/ +#if defined(CONFIG_MFD_WM8994) +static struct regulator_consumer_supply wm8994_fixed_voltage0_supplies[] = { + REGULATOR_SUPPLY("DBVDD", "0-001a"), + REGULATOR_SUPPLY("AVDD2", "0-001a"), + REGULATOR_SUPPLY("CPVDD", "0-001a"), +}; + +static struct regulator_consumer_supply wm8994_fixed_voltage1_supplies[] = { + REGULATOR_SUPPLY("SPKVDD1", "0-001a"), + REGULATOR_SUPPLY("SPKVDD2", "0-001a"), +}; + +static struct regulator_init_data wm8994_fixed_voltage0_init_data = { + .constraints = { + .always_on = 1, + }, + .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage0_supplies), + .consumer_supplies = wm8994_fixed_voltage0_supplies, +}; + +static struct regulator_init_data wm8994_fixed_voltage1_init_data = { + .constraints = { + .always_on = 1, + }, + .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage1_supplies), + .consumer_supplies = wm8994_fixed_voltage1_supplies, +}; + +static struct fixed_voltage_config wm8994_fixed_voltage0_config = { + .supply_name = "VCC_1.8V_PDA", + .microvolts = 1800000, + .gpio = -EINVAL, + .init_data = &wm8994_fixed_voltage0_init_data, +}; + +static struct fixed_voltage_config wm8994_fixed_voltage1_config = { + .supply_name = "V_BAT", + .microvolts = 3700000, + .gpio = -EINVAL, + .init_data = &wm8994_fixed_voltage1_init_data, +}; + +static struct platform_device wm8994_fixed_voltage0 = { + .name = "reg-fixed-voltage", + .id = 0, + .dev = { + .platform_data = &wm8994_fixed_voltage0_config, + }, +}; + +static struct platform_device wm8994_fixed_voltage1 = { + .name = "reg-fixed-voltage", + .id = 1, + .dev = { + .platform_data = &wm8994_fixed_voltage1_config, + }, +}; + +static struct regulator_consumer_supply wm8994_avdd1_supply = + REGULATOR_SUPPLY("AVDD1", "0-001a"); + +static struct regulator_consumer_supply wm8994_dcvdd_supply = + REGULATOR_SUPPLY("DCVDD", "0-001a"); + + + +static struct regulator_init_data wm8994_ldo1_data = { + .constraints = { + .name = "AVDD1_3.0V", + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = 1, + .consumer_supplies = &wm8994_avdd1_supply, +}; + +static struct regulator_init_data wm8994_ldo2_data = { + .constraints = { + .name = "DCVDD_1.0V", + }, + .num_consumer_supplies = 1, + .consumer_supplies = &wm8994_dcvdd_supply, +}; + +static struct wm8994_pdata wm8994_platform_data = { +#if defined (CONFIG_GPIO_WM8994) + .gpio_base = WM8994_GPIO_EXPANDER_BASE, + //Fill value to initialize the GPIO +// .gpio_defaults ={}, + /* configure gpio1 function: 0x0001(Logic level input/output) */ +// .gpio_defaults[0] = 0x0001, + /* configure gpio3/4/5/7 function for AIF2 voice */ + .gpio_defaults[2] = 0x2100, + .gpio_defaults[3] = 0x2100, + .gpio_defaults[4] = 0xA100, +// .gpio_defaults[6] = 0x0100, + /* configure gpio8/9/10/11 function for AIF3 BT */ + .gpio_defaults[7] = 0xA100, + .gpio_defaults[8] = 0x2100, + .gpio_defaults[9] = 0x2100, + .gpio_defaults[10] = 0x2100, +#endif + + .ldo[0] = { RK30_PIN6_PB2, NULL, &wm8994_ldo1_data }, /* XM0FRNB_2 */ + .ldo[1] = { 0, NULL, &wm8994_ldo2_data }, + + .micdet_irq = 0, + .irq_base = 0, + + .lineout1_diff = 1, +// .BB_input_diff = 1, +}; +#endif + +#ifdef CONFIG_RK_HEADSET_DET +#define HEADSET_GPIO RK29_PIN4_PD2 +struct rk_headset_pdata rk_headset_info = { + .Headset_gpio = RK30_PIN6_PA1, + .headset_in_type= HEADSET_IN_HIGH, + .Hook_gpio = RK30_PIN1_PB2,//Detection Headset--Must be set + .hook_key_code = KEY_MEDIA, +}; + +struct platform_device rk_device_headset = { + .name = "rk_headsetdet", + .id = 0, + .dev = { + .platform_data = &rk_headset_info, + } +}; +#endif + /*********************************************************** * rk30 backlight @@ -1332,10 +1471,16 @@ static struct platform_device *devices[] __initdata = { #ifdef CONFIG_BT &rk29sdk_rfkill, #endif +#ifdef CONFIG_MFD_WM8994 + &wm8994_fixed_voltage0, + &wm8994_fixed_voltage1, +#endif +#ifdef CONFIG_RK_HEADSET_DET + &rk_device_headset, +#endif #ifdef CONFIG_TDSC8800 &rk29_device_tdsc8800 #endif - }; // i2c @@ -1445,6 +1590,16 @@ static struct i2c_board_info __initdata i2c0_info[] = { }, #endif #endif +#if defined (CONFIG_SND_SOC_WM8994) + { + .type = "wm8994", + .addr = 0x1a, + .flags = 0, + #if defined(CONFIG_MFD_WM8994) + .platform_data = &wm8994_platform_data, + #endif + }, +#endif }; #endif diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 2322ac47b789..5121b4341c31 100755 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -3804,9 +3804,9 @@ static ssize_t wm8994_proc_write(struct file *file, const char __user *buffer, } break; case 'p'://enable pa - gpio_request(RK29_PIN6_PD3, NULL); - gpio_direction_output(RK29_PIN6_PD3,GPIO_HIGH); - gpio_free(RK29_PIN6_PD3); + // gpio_request(RK29_PIN6_PD3, NULL); + // gpio_direction_output(RK29_PIN6_PD3,GPIO_HIGH); + // gpio_free(RK29_PIN6_PD3); break; case 'a': diff --git a/sound/soc/rk29/Kconfig b/sound/soc/rk29/Kconfig index f46a4d4cd1f0..5b7508b91456 100755 --- a/sound/soc/rk29/Kconfig +++ b/sound/soc/rk29/Kconfig @@ -109,7 +109,7 @@ endchoice config SND_RK29_SOC_WM8994 tristate "SoC I2S Audio support for rockchip - WM8994" - depends on SND_RK29_SOC + depends on SND_RK29_SOC && MFD_WM8994 select SND_RK29_SOC_I2S select SND_SOC_WM8994 help diff --git a/sound/soc/rk29/rk29_wm8994.c b/sound/soc/rk29/rk29_wm8994.c index a43f2637b646..397131b1e499 100755 --- a/sound/soc/rk29/rk29_wm8994.c +++ b/sound/soc/rk29/rk29_wm8994.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "../codecs/wm8994.h" #include "rk29_pcm.h" #include "rk29_i2s.h" @@ -93,6 +92,7 @@ static int rk29_aif1_hw_params(struct snd_pcm_substream *substream, } // DBG("Enter:%s, %d, rate=%d,pll_out = %d\n",__FUNCTION__,__LINE__,params_rate(params),pll_out); +#ifdef CONFIG_ARCH_RK29 general_pll=clk_get(NULL, "general_pll"); if(clk_get_rate(general_pll)>260000000) { @@ -110,6 +110,10 @@ static int rk29_aif1_hw_params(struct snd_pcm_substream *substream, div_bclk=(pll_out)/params_rate(params)-1; div_mclk=0; } +#else + div_bclk=(pll_out/4)/params_rate(params)-1; + div_mclk=3; +#endif DBG("func is%s,gpll=%ld,pll_out=%d,div_mclk=%d\n",__FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk); ret = snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0); -- 2.34.1