From dd52f36997c223fb57c75577caead7e9517ca95a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=94=A1=E6=9E=AB?= Date: Tue, 9 Aug 2011 21:42:57 +0800 Subject: [PATCH] newton:update config file,modify cs42l52 --- arch/arm/configs/rk29_newton_defconfig | 11 +- arch/arm/mach-rk29/board-rk29-newton.c | 90 +++++++++---- sound/soc/rk29/rk29_cs42l52.c | 168 +++++++++++-------------- 3 files changed, 145 insertions(+), 124 deletions(-) diff --git a/arch/arm/configs/rk29_newton_defconfig b/arch/arm/configs/rk29_newton_defconfig index 84ac6adc54a3..418ce65e443d 100755 --- a/arch/arm/configs/rk29_newton_defconfig +++ b/arch/arm/configs/rk29_newton_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.32.27 -# Tue Aug 2 19:48:07 2011 +# Tue Aug 9 21:13:28 2011 # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -906,8 +906,9 @@ CONFIG_RK29_NEWTON=y # Motion Sensors Support # # CONFIG_MPU_NONE is not set -# CONFIG_SENSORS_MPU3050 is not set -# CONFIG_SENSORS_MPU6000 is not set +# CONFIG_MPU_SENSORS_MPU3050 is not set +# CONFIG_MPU_SENSORS_MPU6000 is not set +# CONFIG_MPU_SENSORS_TIMERIRQ is not set CONFIG_HAVE_IDE=y # CONFIG_IDE is not set @@ -1081,6 +1082,7 @@ CONFIG_INPUT_TOUCHSCREEN=y # CONFIG_SINTEK_3FA16 is not set # CONFIG_EETI_EGALAX is not set # CONFIG_TOUCHSCREEN_IT7260 is not set +# CONFIG_TOUCHSCREEN_NAS is not set # CONFIG_TOUCHSCREEN_GT801_IIC is not set # CONFIG_TOUCHSCREEN_GT818_IIC is not set # CONFIG_D70_L3188A is not set @@ -1106,7 +1108,7 @@ CONFIG_COMPASS_AK8975=y CONFIG_G_SENSOR_DEVICE=y # CONFIG_GS_MMA7660 is not set CONFIG_GS_MMA8452=y -# CONFIG_GS_L3G4200D is not set +CONFIG_GS_L3G4200D=y # CONFIG_INPUT_JOGBALL is not set # CONFIG_LIGHT_SENSOR_DEVICE is not set @@ -1511,6 +1513,7 @@ CONFIG_DISPLAY_SUPPORT=y # CONFIG_LCD_RGB_TFT480800_25_E is not set # CONFIG_LCD_HSD100PXN is not set # CONFIG_LCD_HSD07PFW1 is not set +# CONFIG_LCD_BYD8688FTGF is not set # CONFIG_LCD_B101AW06 is not set # CONFIG_LCD_LS035Y8DX02A is not set # CONFIG_LCD_CPTCLAA038LA31XE is not set diff --git a/arch/arm/mach-rk29/board-rk29-newton.c b/arch/arm/mach-rk29/board-rk29-newton.c index 16a693c3c2eb..7008086a9f74 100755 --- a/arch/arm/mach-rk29/board-rk29-newton.c +++ b/arch/arm/mach-rk29/board-rk29-newton.c @@ -259,17 +259,6 @@ static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting) printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n "); } } - else - { - ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL); - if(ret != 0) - { - gpio_free(TOUCH_SCREEN_DISPLAY_PIN); - printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n "); - } - gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0); - gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE); - } } if(fb_setting->disp_on_en) @@ -283,17 +272,6 @@ static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting) printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n "); } } - else - { - ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL); - if(ret != 0) - { - gpio_free(TOUCH_SCREEN_STANDBY_PIN); - printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n "); - } - gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0); - gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE); - } } if(FB_LCD_CABC_EN_PIN != INVALID_GPIO) @@ -833,7 +811,55 @@ static struct mma8452_platform_data mma8452_info = { }; #endif - +#if defined (CONFIG_MPU_SENSORS_MPU3050) +/*mpu3050*/ +static struct mpu3050_platform_data mpu3050_data = { + .int_config = 0x10, + //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 }, + //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 }, + //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 }, + .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 }, + .level_shifter = 0, +#if defined (CONFIG_MPU_SENSORS_KXTF9) + .accel = { +#ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE + .get_slave_descr = NULL , +#else + .get_slave_descr = get_accel_slave_descr , +#endif + .adapt_num = 0, // The i2c bus to which the mpu device is + // connected + //.irq = RK29_PIN0_PA3, + .bus = EXT_SLAVE_BUS_SECONDARY, //The secondary I2C of MPU + .address = 0x0f, + //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 }, + //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 }, + //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 }, + .orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 }, + }, +#endif +#if defined (CONFIG_MPU_SENSORS_AK8975) + .compass = { +#ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE + .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/ +#else + .get_slave_descr = get_compass_slave_descr, +#endif + .adapt_num = 0, // The i2c bus to which the compass device is. + // It can be difference with mpu + // connected + //.irq = RK29_PIN0_PA4, + .bus = EXT_SLAVE_BUS_PRIMARY, + .address = 0x0d, + //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 }, + //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 }, + //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 }, + //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 }, + .orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 }, + }, +}; +#endif +#endif #if defined (CONFIG_BATTERY_BQ27510) #define DC_CHECK_PIN RK29_PIN4_PA1 #define LI_LION_BAT_NUM 2 @@ -1066,6 +1092,17 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = { .irq = RK29_PIN0_PA4, }, #endif +/*mpu3050*/ +#if defined (CONFIG_MPU_SENSORS_MPU3050) + { + .type = "mpu3050", + .addr = 0x68, + .flags = 0, + .irq = RK29_PIN5_PA3, + .platform_data = &mpu3050_data, + }, +#endif + #if defined (CONFIG_SND_SOC_CS42L52) { .type = "cs42l52", @@ -1792,6 +1829,10 @@ struct platform_device newton_usb_mass_storage_device = { }, }; #endif +static struct platform_device rk29_cs42l52_device = { + .name = "rk29_cs42l52", + .id = -1, +}; static void __init rk29_board_iomux_init(void) { @@ -1942,6 +1983,9 @@ static struct platform_device *devices[] __initdata = { #ifdef CONFIG_LEDS_NEWTON_PWM &rk29_device_pwm_leds, #endif +#ifdef CONFIG_SND_RK29_SOC_CS42L52 + &rk29_cs42l52_device, +#endif }; /***************************************************************************************** diff --git a/sound/soc/rk29/rk29_cs42l52.c b/sound/soc/rk29/rk29_cs42l52.c index 30884f20e160..ee3d8c2409bf 100755 --- a/sound/soc/rk29/rk29_cs42l52.c +++ b/sound/soc/rk29/rk29_cs42l52.c @@ -25,14 +25,27 @@ #include "rk29_pcm.h" #include "rk29_i2s.h" -#if 0 -#define DBG(x...) printk(KERN_INFO x) -#else -#define DBG(x...) -#endif +#define HW_PARAMS_FLAG_EQVOL_ON 0x21 +#define HW_PARAMS_FLAG_EQVOL_OFF 0x22 +static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { + SND_SOC_DAPM_LINE("Audio Out", NULL), + SND_SOC_DAPM_LINE("Line in", NULL), + SND_SOC_DAPM_MIC("Micn", NULL), + SND_SOC_DAPM_MIC("Micp", NULL), +}; + +static const struct snd_soc_dapm_route audio_map[]= { + + {"Audio Out", NULL, "HPA"}, + {"Audio Out", NULL, "HPB"}, + {"Line in", NULL, "INPUT1A"}, + {"Line in", NULL, "INPUT1B"}, + {"Micn", NULL, "INPUT2A"}, + {"Micp", NULL, "INPUT2B"}, +}; -static int rk29_hw_params(struct snd_pcm_substream *substream, +static int rk29_cs42l52_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -44,43 +57,32 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, struct clk *general_pll; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - /*by Vincent Hsiung for EQ Vol Change*/ - #define HW_PARAMS_FLAG_EQVOL_ON 0x21 - #define HW_PARAMS_FLAG_EQVOL_OFF 0x22 if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF)) { ret = codec_dai->ops->hw_params(substream, params, codec_dai); //by Vincent - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); } else { /* set codec DAI configuration */ #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); #endif #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); #endif if (ret < 0) return ret; /* set cpu DAI configuration */ #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); + ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); #endif #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - + ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); #endif if (ret < 0) return ret; } - DBG("Enter:%s, rate=%d\n",__FUNCTION__,params_rate(params)); switch(params_rate(params)) { case 8000: @@ -96,19 +98,10 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, pll_out = 11289600; break; default: - DBG("Enter:%s, Error rate=%d\n",__FUNCTION__,params_rate(params)); return -EINVAL; break; } - //pll_out = 12000000; - - #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) - pll_out = 11289600; - snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, 0); - snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0); - #endif - #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) general_pll=clk_get(NULL, "general_pll"); if(clk_get_rate(general_pll)>260000000) @@ -128,130 +121,111 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, div_bclk=(pll_out)/params_rate(params)-1; div_mclk=0; } - DBG("func is%s,gpll=%ld,pll_out=%ld,div_mclk=%ld,div_bclk=%ld\n", - __FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk,div_bclk); //snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, 0); snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0); snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk); snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk); - DBG("Enter:%s, LRCK=%d\n",__FUNCTION__,(pll_out/4)/params_rate(params)); #endif return 0; } -static const struct snd_soc_dapm_widget cs42l52_dapm_widgets[] = { - SND_SOC_DAPM_LINE("Audio Out", NULL), - SND_SOC_DAPM_LINE("Line in", NULL), - SND_SOC_DAPM_MIC("Micn", NULL), - SND_SOC_DAPM_MIC("Micp", NULL), -}; - -static const struct snd_soc_dapm_route audio_map[]= { - - {"Audio Out", NULL, "HPA"}, - {"Audio Out", NULL, "HPB"}, - {"Line in", NULL, "INPUT1A"}, - {"Line in", NULL, "INPUT1B"}, - {"Micn", NULL, "INPUT2A"}, - {"Micp", NULL, "INPUT2B"}, -}; - -/* - * Logic for a cs42l52 as connected on a rockchip board. - */ -static int rk29_cs42l52_init(struct snd_soc_codec *codec) +static int rk29_cs42l52_dai_init(struct snd_soc_codec *codec) { struct snd_soc_dai *codec_dai = &codec->dai[0]; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); -#if 0 - /* Add specific widgets */ - snd_soc_dapm_new_controls(codec, cs42l52_dapm_widgets, - ARRAY_SIZE(cs42l52_dapm_widgets)); - - - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - /* Set up specific audio path audio_mapnects */ - snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); -#endif - snd_soc_dapm_nc_pin(codec, "INPUT1A"); snd_soc_dapm_nc_pin(codec, "INPUT2A"); - snd_soc_dapm_nc_pin(codec, "INPUT3A"); snd_soc_dapm_nc_pin(codec, "INPUT4A"); - snd_soc_dapm_nc_pin(codec, "INPUT1B"); snd_soc_dapm_nc_pin(codec, "INPUT2B"); snd_soc_dapm_nc_pin(codec, "INPUT3B"); snd_soc_dapm_nc_pin(codec, "INPUT4B"); snd_soc_dapm_nc_pin(codec, "MICB"); - - snd_soc_dapm_sync(codec); - - return 0; + snd_soc_dapm_sync(codec); + return 0; } -static struct snd_soc_ops rk29_ops = { - .hw_params = rk29_hw_params, +static struct snd_soc_ops rk29_cs42l52_ops = { + .hw_params = rk29_cs42l52_hw_params, }; -static struct snd_soc_dai_link rk29_dai = { +static struct snd_soc_dai_link rk29_cs42l52_dai_link = { .name = "CS42L52", .stream_name = "CS42L52 PCM", .cpu_dai = &rk29_i2s_dai[0], .codec_dai = &soc_cs42l52_dai, - .init = rk29_cs42l52_init, - .ops = &rk29_ops, + .init = rk29_cs42l52_dai_init, + .ops = &rk29_cs42l52_ops, }; -static struct snd_soc_card snd_soc_card_rk29 = { +static struct snd_soc_card snd_soc_card_rk29_cs42l52 = { .name = "RK29_CS42L52", .platform = &rk29_soc_platform, - .dai_link = &rk29_dai, + .dai_link = &rk29_cs42l52_dai_link, .num_links = 1, }; -static struct snd_soc_device rk29_snd_devdata = { - .card = &snd_soc_card_rk29, +static struct snd_soc_device rk29_cs42l52_snd_devdata = { + .card = &snd_soc_card_rk29_cs42l52, .codec_dev = &soc_codec_dev_cs42l52, }; -static struct platform_device *rk29_snd_device; +static struct platform_device *rk29_cs42l52_snd_device; -static int __init audio_card_init(void) +static int rk29_cs42l52_probe(struct platform_device *pdev) { int ret =0; - DBG("Enter::%s----%d\n",__FUNCTION__, __LINE__); - rk29_snd_device = platform_device_alloc("soc-audio", -1); - if (!rk29_snd_device) { - DBG("platform device allocation failed\n"); + printk("RK29 CS42L52 SoC Audio driver\n"); + rk29_cs42l52_snd_device = platform_device_alloc("soc-audio", -1); + if (!rk29_cs42l52_snd_device) { ret = -ENOMEM; + printk("%s:platform device alloc fail\n",__FUNCTION__); return ret; } - platform_set_drvdata(rk29_snd_device, &rk29_snd_devdata); - rk29_snd_devdata.dev = &rk29_snd_device->dev; - ret = platform_device_add(rk29_snd_device); + platform_set_drvdata(rk29_cs42l52_snd_device, &rk29_cs42l52_snd_devdata); + rk29_cs42l52_snd_devdata.dev = &rk29_cs42l52_snd_device->dev; + ret = platform_device_add(rk29_cs42l52_snd_device); if (ret) { - DBG("platform device add failed\n"); - platform_device_put(rk29_snd_device); + platform_device_put(rk29_cs42l52_snd_device); + printk("%s:platform device add fail,ret = %d\n",__FUNCTION__,ret); } return ret; } -static void __exit audio_card_exit(void) +static int rk29_cs42l52_remove(struct platform_device *pdev) +{ + platform_device_unregister(rk29_cs42l52_snd_device); + return 0; +} + +static struct platform_driver rk29_cs42l52_driver = { + .probe = rk29_cs42l52_probe, + .remove = rk29_cs42l52_remove, + .driver = { + .name = "rk29_cs42l52", + .owner = THIS_MODULE, + }, +}; + +static int __init rk29_cs42l52_init(void) { - platform_device_unregister(rk29_snd_device); + return platform_driver_register(&rk29_cs42l52_driver); } -module_init(audio_card_init); -module_exit(audio_card_exit); -/* Module information */ +static void __exit rk29_cs42l52_exit(void) +{ + platform_driver_unregister(&rk29_cs42l52_driver); +} + +module_init(rk29_cs42l52_init); +module_exit(rk29_cs42l52_exit); MODULE_AUTHOR("rockchip"); MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface"); MODULE_LICENSE("GPL"); + -- 2.34.1