rk30phone : update wm8994 config
author邱建斌 <qjb@rock-chips.com>
Sun, 1 Apr 2012 07:35:12 +0000 (15:35 +0800)
committer邱建斌 <qjb@rock-chips.com>
Sun, 1 Apr 2012 07:35:12 +0000 (15:35 +0800)
arch/arm/configs/rk30_phone_defconfig [changed mode: 0755->0644]
arch/arm/mach-rk30/board-rk30-phone.c
sound/soc/codecs/wm8994.c
sound/soc/rk29/Kconfig
sound/soc/rk29/rk29_wm8994.c

old mode 100755 (executable)
new mode 100644 (file)
index 9170808..0ba39a7
@@ -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
index 2d0bf0e1deca35cb56d0f20eb42923b38d72d717..081364e740776c9ae04817f23d320e336f3e26da 100755 (executable)
 #include <mach/iomux.h>
 #include <linux/mpu.h>
 
+#include <linux/regulator/fixed.h>
+#include <linux/mfd/wm8994/pdata.h>
+#include <linux/regulator/machine.h>
+#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
index 2322ac47b789c36678dce185dd260890905861d6..5121b4341c313a353efd23ac7e3fec40ea5cf9dc 100755 (executable)
@@ -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':
index f46a4d4cd1f0d4a03e7c55c5cd54df468bfd8bc0..5b7508b91456aa130273bff21012cdf845cb5e0c 100755 (executable)
@@ -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
index a43f2637b6460eb278f2439457a44a82fabe43bd..397131b1e49956e8d79ce58d3f4cf04c867130c8 100755 (executable)
@@ -20,7 +20,6 @@
 #include <sound/soc-dapm.h>
 #include <asm/io.h>
 #include <mach/hardware.h>
-#include <mach/rk29_iomap.h>
 #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);