From 97fb7f745717fc7b0981ea5a3375576ff267ae68 Mon Sep 17 00:00:00 2001 From: zwp Date: Tue, 6 Sep 2011 19:45:22 -0700 Subject: [PATCH 1/9] TCL_Phonepad:modify ddr frequence to 456MHz. --- arch/arm/configs/rk29_phonepadsdk_defconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/configs/rk29_phonepadsdk_defconfig b/arch/arm/configs/rk29_phonepadsdk_defconfig index eee1a810eb38..6540cf440bd4 100644 --- a/arch/arm/configs/rk29_phonepadsdk_defconfig +++ b/arch/arm/configs/rk29_phonepadsdk_defconfig @@ -230,8 +230,9 @@ CONFIG_MACH_RK29_PHONEPADSDK=y # CONFIG_DDR_TYPE_DDR3_2133N is not set CONFIG_DDR_TYPE_DDR3_DEFAULT=y CONFIG_RK29_MEM_SIZE_M=512 -CONFIG_DDR_SDRAM_FREQ=400 -CONFIG_DDR_FREQ=y +CONFIG_DDR_SDRAM_FREQ=456 +# CONFIG_DDR_RECONFIG is not set +CONFIG_WIFI_CONTROL_FUNC=y # # RK29 VPU (Video Processing Unit) support From 7ca158d2bb524990d3ebe874cc023ea8cb7d452c Mon Sep 17 00:00:00 2001 From: wlq Date: Thu, 8 Sep 2011 14:20:04 +0800 Subject: [PATCH 2/9] phone-pad:add ThinkWill MI900 product ID --- drivers/usb/serial/option.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index a7ab681063aa..c7bc9be950d2 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -373,6 +373,7 @@ static int option_resume(struct usb_serial *serial); /* Thinkwill products */ #define THINKWILL_VENDOR_ID 0x19f5 #define THINKWILL_PRODUCT_ID 0x9909 +#define THINKWILL_MI900_PRODUCT_ID 0x9013 /* Cinterion (formerly Siemens) products */ #define SIEMENS_VENDOR_ID 0x0681 @@ -412,6 +413,9 @@ static int option_resume(struct usb_serial *serial); static struct usb_device_id option_ids[] = { { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, { USB_DEVICE(THINKWILL_VENDOR_ID,THINKWILL_PRODUCT_ID)}, + + { USB_DEVICE(THINKWILL_VENDOR_ID,THINKWILL_MI900_PRODUCT_ID)}, + { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) }, From bc338b1f0d8e9605610022ae715408b5f9425431 Mon Sep 17 00:00:00 2001 From: zwp Date: Thu, 15 Sep 2011 01:45:28 -0700 Subject: [PATCH 3/9] tcl-phone-pad:improve tp performance. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决手指从触屏的边缘开始滑动时,可能出现触屏不响应的情况。 --- drivers/input/touchscreen/ft5x0x_i2c_ts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 drivers/input/touchscreen/ft5x0x_i2c_ts.h diff --git a/drivers/input/touchscreen/ft5x0x_i2c_ts.h b/drivers/input/touchscreen/ft5x0x_i2c_ts.h old mode 100644 new mode 100755 index 10eb263cb55d..3b034d8d2129 --- a/drivers/input/touchscreen/ft5x0x_i2c_ts.h +++ b/drivers/input/touchscreen/ft5x0x_i2c_ts.h @@ -13,8 +13,8 @@ #define CFG_NUMOFKEYS 0x4 //number of touch keys #ifdef CONFIG_FTS_CUSTOME_ENV -#define SCREEN_MAX_X 1024 -#define SCREEN_MAX_Y 600 +#define SCREEN_MAX_X 1044//1024 +#define SCREEN_MAX_Y 620//600 #else #define SCREEN_MAX_X 800 #define SCREEN_MAX_Y 480 From da43c90c56c920a19693a1928130d7267c86ed04 Mon Sep 17 00:00:00 2001 From: zwp Date: Mon, 19 Sep 2011 00:02:04 -0700 Subject: [PATCH 4/9] TCL_Phone_pad:modify tp i2c err when device going to earlysuspend. --- arch/arm/mach-rk29/board-rk29phonepadsdk.c | 9 +- arch/arm/mach-rk29/include/mach/board.h | 4 + drivers/input/touchscreen/ft5x0x_i2c_ts.c | 97 ++++++++++++++++++++-- drivers/input/touchscreen/ft5x0x_i2c_ts.h | 6 -- 4 files changed, 101 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-rk29/board-rk29phonepadsdk.c b/arch/arm/mach-rk29/board-rk29phonepadsdk.c index 02e654ffb9a2..aab2422074bc 100755 --- a/arch/arm/mach-rk29/board-rk29phonepadsdk.c +++ b/arch/arm/mach-rk29/board-rk29phonepadsdk.c @@ -608,7 +608,10 @@ int laibao_init_platform_hw(void) struct laibao_platform_data laibao_info = { .model= 1003, .init_platform_hw= laibao_init_platform_hw, - + .lcd_disp_on_pin = RK29_PIN6_PD0, + .disp_on_value = GPIO_HIGH, + .lcd_cs_pin = RK29_PIN6_PD1, + .lcd_cs_value = GPIO_HIGH, }; #endif @@ -1364,7 +1367,7 @@ static int rk29_backlight_pwm_suspend(void) return -1; } gpio_direction_output(PWM_GPIO, GPIO_LOW); - #ifdef LCD_DISP_ON_PIN + #if 0//def LCD_DISP_ON_PIN gpio_direction_output(BL_EN_PIN, 0); gpio_set_value(BL_EN_PIN, !BL_EN_VALUE); #endif @@ -1376,7 +1379,7 @@ static int rk29_backlight_pwm_resume(void) gpio_free(PWM_GPIO); rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE); - #ifdef LCD_DISP_ON_PIN + #if 0//def LCD_DISP_ON_PIN msleep(30); gpio_direction_output(BL_EN_PIN, 1); gpio_set_value(BL_EN_PIN, BL_EN_VALUE); diff --git a/arch/arm/mach-rk29/include/mach/board.h b/arch/arm/mach-rk29/include/mach/board.h index c97306d4af19..e9745576374e 100644 --- a/arch/arm/mach-rk29/include/mach/board.h +++ b/arch/arm/mach-rk29/include/mach/board.h @@ -306,6 +306,10 @@ struct laibao_platform_data { int (*laibao_platform_sleep)(void); int (*laibao_platform_wakeup)(void); void (*exit_platform_hw)(void); + int lcd_disp_on_pin; + int disp_on_value; + int lcd_cs_pin; + int lcd_cs_value; }; struct akm8975_platform_data { diff --git a/drivers/input/touchscreen/ft5x0x_i2c_ts.c b/drivers/input/touchscreen/ft5x0x_i2c_ts.c index 3b5ca652c035..8723ccf3a889 100755 --- a/drivers/input/touchscreen/ft5x0x_i2c_ts.c +++ b/drivers/input/touchscreen/ft5x0x_i2c_ts.c @@ -30,6 +30,17 @@ #include #include #include +#include + +struct FTS_TS_DATA_T { + struct i2c_client *client; + struct input_dev *input_dev; + struct FTS_TS_EVENT_T event; + struct work_struct pen_event_work; + struct workqueue_struct *ts_workqueue; + struct early_suspend early_suspend; +}; + /* -------------- global variable definition -----------*/ static struct i2c_client *this_client; static REPORT_FINGER_INFO_T _st_finger_infos[CFG_MAX_POINT_NUM]; @@ -54,6 +65,13 @@ char *tsp_keyname[CFG_NUMOFKEYS] ={ static bool tsp_keystatus[CFG_NUMOFKEYS]; + +#ifdef CONFIG_HAS_EARLYSUSPEND +static void ft5x0x_ts_early_suspend(struct early_suspend *h); +static void ft5x0x_ts_late_resume(struct early_suspend *h); +#endif + + /*********************************************************************** [function]: callback: read data from ctpm by i2c interface; @@ -234,7 +252,7 @@ static int fts_i2c_rxdata(u8 *rxdata, int length) ret = i2c_transfer(this_client->adapter, &msg, 1); if (ret < 0) - pr_err("msg %s i2c write error: %d\n", __func__, ret); + pr_err("msg %s line:%d i2c write error: %d\n", __func__, __LINE__,ret); msg.addr = this_client->addr; msg.flags = I2C_M_RD; @@ -242,7 +260,7 @@ static int fts_i2c_rxdata(u8 *rxdata, int length) msg.buf = rxdata; ret = i2c_transfer(this_client->adapter, &msg, 1); if (ret < 0) - pr_err("msg %s i2c write error: %d\n", __func__, ret); + pr_err("msg %s line:%d i2c write error: %d\n", __func__,__LINE__, ret); return ret; } @@ -423,11 +441,9 @@ int fts_read_data(void) _st_finger_infos[id].ui2_id = size; _si_touch_num ++; } - else - /*bad event, ignore*/ + else /*bad event, ignore*/ continue; - if ( (touch_event==1) ) { // printk("[TSP]id=%d up\n", id); @@ -436,7 +452,6 @@ int fts_read_data(void) for( i= 0; iinput_dev, ABS_MT_TRACKING_ID, _st_finger_infos[i].ui2_id); input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, _st_finger_infos[i].u2_pressure); input_report_abs(data->input_dev, ABS_MT_POSITION_X, SCREEN_MAX_X - _st_finger_infos[i].i2_x); @@ -796,6 +811,66 @@ unsigned char fts_ctpm_get_upg_ver(void) } +void ft5x0x_ts_set_standby(struct i2c_client *client, int enable) +{ + struct laibao_platform_data *mach_info = client->dev.platform_data; + unsigned display_on = mach_info->lcd_disp_on_pin; + unsigned lcd_cs = mach_info->lcd_cs_pin; + + int display_on_pol = mach_info->disp_on_value; + int lcd_cs_pol = mach_info->lcd_cs_value; + + printk("%s : %s, enable = %d", __FILE__, __FUNCTION__,enable); + if(display_on != INVALID_GPIO) + { + gpio_direction_output(display_on, 0); + gpio_set_value(display_on, enable ? display_on_pol : !display_on_pol); + } + if(lcd_cs != INVALID_GPIO) + { + gpio_direction_output(lcd_cs, 0); + gpio_set_value(lcd_cs, enable ? lcd_cs_pol : !lcd_cs_pol); + } +} + +#ifdef CONFIG_HAS_EARLYSUSPEND +static void ft5x0x_ts_early_suspend(struct early_suspend *h) +{ + struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client); + + + printk("enter ft5x0x_ts_early_suspend\n"); + + disable_irq_nosync(this_client->irq); + + cancel_work_sync(&data->pen_event_work); + + ft5x0x_ts_set_standby(this_client,0); + + return; +} +static void ft5x0x_ts_late_resume(struct early_suspend *h) +{ + struct FTS_TS_DATA_T *data = i2c_get_clientdata(this_client); + + ft5x0x_ts_set_standby(this_client,1); + + if(!work_pending(&data->pen_event_work)){ + PREPARE_WORK(&data->pen_event_work, fts_work_func); + queue_work(data->ts_workqueue, &data->pen_event_work); + } + else + enable_irq(this_client->irq); + + printk("ft5x0x_ts_late_resume finish\n"); + + return ; +} +#else +#define egalax_i2c_suspend NULL +#define egalax_i2c_resume NULL +#endif + static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -826,6 +901,7 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i } this_client = client; + ft5x0x_ts->client = client; i2c_set_clientdata(client, ft5x0x_ts); INIT_WORK(&ft5x0x_ts->pen_event_work, fts_work_func); @@ -944,6 +1020,15 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i goto exit_input_register_device_failed; } + +#ifdef CONFIG_HAS_EARLYSUSPEND + ft5x0x_ts->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1; + ft5x0x_ts->early_suspend.suspend = ft5x0x_ts_early_suspend; + ft5x0x_ts->early_suspend.resume = ft5x0x_ts_late_resume; + register_early_suspend(&ft5x0x_ts->early_suspend); +#endif + + enable_irq(_sui_irq_num); printk("[TSP] file(%s), function (%s), -- end\n", __FILE__, __FUNCTION__); return 0; diff --git a/drivers/input/touchscreen/ft5x0x_i2c_ts.h b/drivers/input/touchscreen/ft5x0x_i2c_ts.h index 3b034d8d2129..d61f7a88c2d8 100755 --- a/drivers/input/touchscreen/ft5x0x_i2c_ts.h +++ b/drivers/input/touchscreen/ft5x0x_i2c_ts.h @@ -80,12 +80,6 @@ typedef enum u8 touch_point; }; -struct FTS_TS_DATA_T { - struct input_dev *input_dev; - struct FTS_TS_EVENT_T event; - struct work_struct pen_event_work; - struct workqueue_struct *ts_workqueue; -}; From e43fd37e2d32fd399805c992234e3f869eba09d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E5=B9=B3?= Date: Tue, 20 Sep 2011 16:49:47 +0800 Subject: [PATCH 5/9] phone-pad:modify wm8994 to satisfy phone pad product. --- arch/arm/mach-rk29/board-rk29-a22.c | 6 +- arch/arm/mach-rk29/board-rk29-phonesdk.c | 8 +- arch/arm/mach-rk29/board-rk29phonepadsdk.c | 108 +--- include/linux/mfd/wm8994/pdata.h | 9 +- sound/soc/codecs/wm8994.c | 641 ++++++++++++++++++++- 5 files changed, 640 insertions(+), 132 deletions(-) diff --git a/arch/arm/mach-rk29/board-rk29-a22.c b/arch/arm/mach-rk29/board-rk29-a22.c index 599ce5865cc1..8b3e12b71103 100755 --- a/arch/arm/mach-rk29/board-rk29-a22.c +++ b/arch/arm/mach-rk29/board-rk29-a22.c @@ -1440,7 +1440,11 @@ struct platform_device rk29_device_gps = { *****************************************************************************************/ struct wm8994_pdata wm8994_platdata = { .BB_input_diff = 0, - .phone_pad = 0, + .BB_class = NO_PCM_BB, + + .no_earpiece = 0, + .sp_hp_same_channel = 0, + .PA_control_pin = RK29_PIN6_PD3, .Power_EN_Pin = RK29_PIN5_PA1, diff --git a/arch/arm/mach-rk29/board-rk29-phonesdk.c b/arch/arm/mach-rk29/board-rk29-phonesdk.c index 47e0c7603bcb..5f8ee2921096 100755 --- a/arch/arm/mach-rk29/board-rk29-phonesdk.c +++ b/arch/arm/mach-rk29/board-rk29-phonesdk.c @@ -1513,9 +1513,13 @@ struct platform_device rk29_device_gps = { * author: qjb@rock-chips.com *****************************************************************************************/ struct wm8994_pdata wm8994_platdata = { - .BB_input_diff = 0, - .phone_pad = 0, + .BB_input_diff = 0, + .BB_class = NO_PCM_BB, + + .no_earpiece = 0, + .sp_hp_same_channel = 0, + .PA_control_pin = 0, .Power_EN_Pin = RK29_PIN5_PA1, diff --git a/arch/arm/mach-rk29/board-rk29phonepadsdk.c b/arch/arm/mach-rk29/board-rk29phonepadsdk.c index aab2422074bc..2f343f320a01 100755 --- a/arch/arm/mach-rk29/board-rk29phonepadsdk.c +++ b/arch/arm/mach-rk29/board-rk29phonepadsdk.c @@ -384,7 +384,7 @@ static struct android_pmem_platform_data android_pmem_pdata = { .name = "pmem", .start = PMEM_UI_BASE, .size = PMEM_UI_SIZE, - .no_allocator = 1, + .no_allocator = 0, .cached = 1, }; @@ -722,112 +722,12 @@ struct bq27510_platform_data bq27510_info = { * wm8994 codec * author: qjb@rock-chips.com *****************************************************************************************/ -//#if defined(CONFIG_MFD_WM8994) -#if defined (CONFIG_REGULATOR_WM8994) -static struct regulator_consumer_supply wm8994_ldo1_consumers[] = { - { - .supply = "DBVDD", - }, - { - .supply = "AVDD1", - }, - { - .supply = "CPVDD", - }, - { - .supply = "SPKVDD1", - } -}; -static struct regulator_consumer_supply wm8994_ldo2_consumers[] = { - { - .supply = "DCVDD", - }, - { - .supply = "AVDD2", - }, - { - .supply = "SPKVDD2", - } -}; -struct regulator_init_data regulator_init_data_ldo1 = { - .constraints = { - .name = "wm8994-ldo1", - .min_uA = 00000, - .max_uA = 18000, - .always_on = true, - .apply_uV = true, - .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT, - }, - .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo1_consumers), - .consumer_supplies = wm8994_ldo1_consumers, -}; -struct regulator_init_data regulator_init_data_ldo2 = { - .constraints = { - .name = "wm8994-ldo2", - .min_uA = 00000, - .max_uA = 18000, - .always_on = true, - .apply_uV = true, - .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT, - }, - .num_consumer_supplies = ARRAY_SIZE(wm8994_ldo2_consumers), - .consumer_supplies = wm8994_ldo2_consumers, -}; -#endif -struct wm8994_drc_cfg wm8994_drc_cfg_pdata = { - .name = "wm8994_DRC", - .regs = {0,0,0,0,0}, -}; - -struct wm8994_retune_mobile_cfg wm8994_retune_mobile_cfg_pdata = { - .name = "wm8994_EQ", - .rate = 0, - .regs = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, -}; - struct wm8994_pdata wm8994_platdata = { -#if defined (CONFIG_GPIO_WM8994) - .gpio_base = WM8994_GPIO_EXPANDER_BASE, - //Fill value to initialize the GPIO - .gpio_defaults ={}, -#endif - //enable=0 disable ldo -#if defined (CONFIG_REGULATOR_WM8994) - .ldo = { - { - .enable = 0, - //RK29_PIN5_PA1 - .supply = NULL, - .init_data = ®ulator_init_data_ldo1, - }, - { - .enable = 0, - .supply = NULL, - .init_data = ®ulator_init_data_ldo2, - } - }, -#endif - //DRC 0--use default - .num_drc_cfgs = 0, - .drc_cfgs = &wm8994_drc_cfg_pdata, - //EQ 0--use default - .num_retune_mobile_cfgs = 0, - .retune_mobile_cfgs = &wm8994_retune_mobile_cfg_pdata, - - .lineout1_diff = 1, - .lineout2_diff = 1, - - .lineout1fb = 1, - .lineout2fb = 1, - - .micbias1_lvl = 1, - .micbias2_lvl = 1, - - .jd_scthr = 0, - .jd_thr = 0, + .no_earpiece = 1, + .sp_hp_same_channel = 1, .BB_input_diff = 1, - .phone_pad = 1, + .BB_class = PCM_BB, .PA_control_pin = RK29_PIN6_PB6, .Power_EN_Pin = RK29_PIN5_PA1, diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h index 11412bed2583..f63b990b366e 100644 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -59,6 +59,9 @@ struct wm8994_retune_mobile_cfg { u16 regs[WM8994_EQ_REGS]; }; +#define PCM_BB 1 +#define NO_PCM_BB 0 + struct wm8994_pdata { int gpio_base; @@ -94,16 +97,20 @@ struct wm8994_pdata { unsigned int jd_thr:2; //for phonepad - unsigned int phone_pad:1; // =0 is not phone_pad, =1 is phone_pad + unsigned int no_earpiece:1; // =1 don't have a earpiece, =0 has a earpiece + unsigned int sp_hp_same_channel:1; //BB input can be differential or single ended unsigned int BB_input_diff:1; // =0 single ended =1 differential + unsigned int BB_class:1;//PCM_BB= 1 NO_PCM_BB=0 //If an external amplifier speakers wm8994 enable>0 disable=0 unsigned int PA_control_pin; //wm8994 LDO1_ENA and LDO2_ENA unsigned int Power_EN_Pin; + char PowerEN_iomux_name[50]; + int PowerEN_iomux_mode; //volume int speaker_incall_vol; //max = 6, min = -21 diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 8d2bf2c325ac..65892019b8df 100755 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -51,13 +51,11 @@ char debug_write_read = 0; /* If digital BB is used,open this define. Define what kind of digital BB is used. */ -//#define PCM_BB -#ifdef PCM_BB #define TD688_MODE //#define MU301_MODE //#define CHONGY_MODE //#define THINKWILL_M800_MODE -#endif //PCM_BB + #if 1 #define DBG(x...) printk(KERN_INFO x) @@ -124,6 +122,11 @@ unsigned short BT_vol_table[16] ={0x01DB,0x01DC,0x01DD,0x01DE,0x01DF,0x01E0, 0x01E1,0x01E2,0x01E3,0x01E4,0x01E5,0x01E6, 0x01E7,0x01E8,0x01E9,0x01EA}; +void (*handsetMIC_to_baseband_to_headset)(void); +void (*mainMIC_to_baseband_to_headset)(void); +void (*mainMIC_to_baseband_to_earpiece)(void); +void (*mainMIC_to_baseband_to_speakers)(void); +void (*BT_baseband)(void); /* codec private data */ struct wm8994_priv { @@ -989,8 +992,8 @@ void AP_to_speakers(void) wm8994_write(0x01, 0x3033); } -#ifndef PCM_BB -void handsetMIC_to_baseband_to_headset(void) + +void handsetMIC_to_BB_to_headset(void) {// struct wm8994_priv *wm8994 = wm8994_codec->private_data; struct wm8994_pdata *pdata = wm8994->pdata; @@ -1044,7 +1047,7 @@ void handsetMIC_to_baseband_to_headset(void) wm8994_set_level_volume(); } -void mainMIC_to_baseband_to_headset(void) +void mainMIC_to_BB_to_headset(void) {// struct wm8994_priv *wm8994 = wm8994_codec->private_data; struct wm8994_pdata *pdata = wm8994->pdata; @@ -1099,7 +1102,7 @@ void mainMIC_to_baseband_to_headset(void) wm8994_set_level_volume(); } -void mainMIC_to_baseband_to_earpiece(void) +void mainMIC_to_BB_to_earpiece(void) {// DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1138,7 +1141,7 @@ void mainMIC_to_baseband_to_earpiece(void) wm8994_set_level_volume(); } -void mainMIC_to_baseband_to_speakers(void) +void mainMIC_to_BB_to_speakers(void) {// DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1187,7 +1190,7 @@ void mainMIC_to_baseband_to_speakers(void) wm8994_set_level_volume(); } -void BT_baseband(void) +void BT_BB(void) {// struct wm8994_priv *wm8994 = wm8994_codec->private_data; DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1322,9 +1325,9 @@ void BT_baseband(void) wm8994_write(0x04, 0x3303); wm8994_write(0x05, 0x3303); } -#else //PCM_BB + /******************PCM BB BEGIN*****************/ -void handsetMIC_to_baseband_to_headset(void) //pcmbaseband +void handsetMIC_to_PCMBB_to_headset(void) //pcmbaseband { DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1332,7 +1335,125 @@ void handsetMIC_to_baseband_to_headset(void) //pcmbaseband wm8994_current_mode=wm8994_handsetMIC_to_baseband_to_headset; wm8994_reset(); msleep(50); +#if 1 + wm8994_write(0x01, 0x0003|wm8994_mic_VCC); //0x0013); + mdelay(50); + + //GPIO configuration + wm8994_write(0x0700, 0xA101); + wm8994_write(0x39, 0x006C); + + //VMID and BIAS + wm8994_write(0x01, 0x0023|wm8994_mic_VCC); //0x0013); + wm8994_write(0x200, 0x0000); + mdelay(50); + wm8994_write(0x200, 0x0001); + + wm8994_write(0x220, 0x0000); + wm8994_write(0x221, 0x0700); //MCLK=12MHz //FLL1 CONTRLO(2) + wm8994_write(0x222, 0xB51E); //0x3126); //FLL1 CONTRLO(3) + wm8994_write(0x223, 0x0100); //FLL1 CONTRLO(4) + wm8994_write(0x220, 0x0004); //FLL1 CONTRLO(1) + //mdelay(50); + mdelay(10); + wm8994_write(0x220, 0x0005); //FLL1 CONTRLO(1) + mdelay(5); + + wm8994_write(0x200, 0x0010); + wm8994_write(0x208, 0x0008); + wm8994_write(0x208, 0x000A); + wm8994_write(0x210, 0x0083); + wm8994_write(0x302, 0x3000); + wm8994_write(0x302, 0x7000); + wm8994_write(0x303, 0x0040); + wm8994_write(0x304, 0x0040); + wm8994_write(0x305, 0x0040); + wm8994_write(0x300, 0x4010); + wm8994_write(0x200, 0x0011); + + //wm8994_write(0x01, 0x3003|wm8994_mic_VCC); + wm8994_write(0x01, 0x0803|wm8994_mic_VCC); + wm8994_write(0x02, 0x0110); + wm8994_write(0x03, 0x00F0); ///0x0330); + wm8994_write(0x04, 0x3003); + wm8994_write(0x05, 0x3003); + wm8994_write(0x1A, 0x0119);//0x015F); + wm8994_write(0x1F, 0x0000); + //wm8994_write(0x22, 0x0000); + //wm8994_write(0x23, 0x0100); ///0x0000); + //wm8994_write(0x25, 0x0152); + wm8994_write(0x28, 0x0003); + wm8994_write(0x2A, 0x0030); + wm8994_write(0x2D, 0x0001); + wm8994_write(0x2E, 0x0001); + wm8994_write(0x33, 0x0018); + //wm8994_write(0x36, 0x000C); //MIXOUTL_TO_SPKMIXL MIXOUTR_TO_SPKMIXR + wm8994_write(0x200, 0x0011); //AIF1 CLOCKING(1) + wm8994_write(0x204, 0x0011); //AIF2 CLOCKING(1) + wm8994_write(0x208, 0x000E);//0x000E); //CLOCKING(1) + wm8994_write(0x520, 0x0000); //AIF2 DAC FILTERS(1) + wm8994_write(0x601, 0x0004); //AIF2DACL_DAC1L + wm8994_write(0x602, 0x0004); //AIF2DACR_DAC1R + + wm8994_write(0x610, 0x01C0); //DAC1 Left Volume bit0~7 + wm8994_write(0x611, 0x01C0); //DAC1 Right Volume bit0~7 + wm8994_write(0x612, 0x01C0); //DAC2 Left Volume bit0~7 + wm8994_write(0x613, 0x01C0); //DAC2 Right Volume bit0~7 + + wm8994_write(0x702, 0xC100); //GPIO3 + wm8994_write(0x703, 0xC100); //GPIO4 + wm8994_write(0x704, 0xC100); //GPIO5 + wm8994_write(0x706, 0x4100); //GPIO7 + wm8994_write(0x204, 0x0011); //AIF2 MCLK=FLL1 + wm8994_write(0x211, 0x0009); //LRCK=8KHz, Rate=MCLK/1536 + #ifdef TD688_MODE + wm8994_write(0x310, 0xc108); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef CHONGY_MODE + wm8994_write(0x310, 0xc018); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef MU301_MODE + wm8994_write(0x310, 0xc118); ///0x4118); ///interface dsp mode 16bit + wm8994_write(0x241, 0x2f04); + wm8994_write(0x242, 0x0000); + wm8994_write(0x243, 0x0300); + wm8994_write(0x240, 0x0004); + mdelay(40); + wm8994_write(0x240, 0x0005); + wm8994_write(0x204, 0x0019); + wm8994_write(0x211, 0x0003); + wm8994_write(0x244, 0x0c83); + wm8994_write(0x620, 0x0000); + #endif + #ifdef THINKWILL_M800_MODE + //wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + #endif + wm8994_write(0x310, 0x4118); + wm8994_write(0x311, 0x0000); + wm8994_write(0x313, 0x0060); //AIF2BCLK + wm8994_write(0x314, 0x0020); //AIF2ADCLRCK + wm8994_write(0x315, 0x0020); //AIF2DACLRCLK + + wm8994_write(0x603, 0x0180); //Rev.D ADCL SideTone + wm8994_write(0x604, 0x0020); ///0x0010); //ADC2_TO_DAC2L + wm8994_write(0x605, 0x0020); //0x0010); //ADC2_TO_DAC2R + wm8994_write(0x621, 0x0000); ///0x0001); + //wm8994_write(0x317, 0x0003); + //wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER + //For handset + wm8994_write(0x01, 0x0B33);//0x3833); // + wm8994_write(0x1C, 0x01F9); + wm8994_write(0x1D, 0x01F9); + wm8994_write(0x4C, 0x9F25); + wm8994_write(0x60, 0x00EE); + + wm8994_write(0x422, 0x0000); ////AIF2 un-mute as master + wm8994_set_level_volume(); + //wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol); +#endif + +#if 0 wm8994_write(0x01, 0x0003|wm8994_mic_VCC); msleep(50); wm8994_write(0x221, 0x0700); @@ -1403,11 +1524,216 @@ void handsetMIC_to_baseband_to_headset(void) //pcmbaseband wm8994_write(0x621, 0x0000); //0x0001); ///0x0000); wm8994_write(0x317, 0x0003); wm8994_write(0x312, 0x0000); /// as slave ///0x4000); //AIF2 SET AS MASTER - +#endif } -void mainMIC_to_baseband_to_earpiece(void) //pcmbaseband +void mainMIC_to_PCMBB_to_headset(void) +{ + DBG("%s::%d\n",__FUNCTION__,__LINE__); + + if(wm8994_current_mode==wm8994_mainMIC_to_baseband_to_earpiece)return; + wm8994_current_mode=wm8994_mainMIC_to_baseband_to_earpiece; + wm8994_reset(); + msleep(50); + +#if 1 + wm8994_write(0x01, 0x0003|wm8994_mic_VCC); //0x0013); + mdelay(50); + + //GPIO configuration + wm8994_write(0x0700, 0xA101); + wm8994_write(0x39, 0x006C); + + //VMID and BIAS + wm8994_write(0x01, 0x0023|wm8994_mic_VCC); //0x0013); + wm8994_write(0x200, 0x0000); + mdelay(50); + wm8994_write(0x200, 0x0001); + + wm8994_write(0x220, 0x0000); + wm8994_write(0x221, 0x0700); //MCLK=12MHz //FLL1 CONTRLO(2) + wm8994_write(0x222, 0xB51E); //0x3126); //FLL1 CONTRLO(3) + wm8994_write(0x223, 0x0100); //FLL1 CONTRLO(4) + wm8994_write(0x220, 0x0004); //FLL1 CONTRLO(1) + //mdelay(50); + mdelay(10); + wm8994_write(0x220, 0x0005); //FLL1 CONTRLO(1) + mdelay(5); + + wm8994_write(0x200, 0x0010); + wm8994_write(0x208, 0x0008); + wm8994_write(0x208, 0x000A); + wm8994_write(0x210, 0x0083); + wm8994_write(0x302, 0x3000); + wm8994_write(0x302, 0x7000); + wm8994_write(0x303, 0x0040); + wm8994_write(0x304, 0x0040); + wm8994_write(0x305, 0x0040); + wm8994_write(0x300, 0x4010); + wm8994_write(0x200, 0x0011); + + //wm8994_write(0x01, 0x3003|wm8994_mic_VCC); + wm8994_write(0x01, 0x0803|wm8994_mic_VCC); + wm8994_write(0x02, 0x0110); + wm8994_write(0x03, 0x00F0); ///0x0330); + wm8994_write(0x04, 0x3003); + wm8994_write(0x05, 0x3003); + wm8994_write(0x1A, 0x015F); + wm8994_write(0x1F, 0x0000); + //wm8994_write(0x22, 0x0000); + //wm8994_write(0x23, 0x0100); ///0x0000); + //wm8994_write(0x25, 0x0152); + wm8994_write(0x28, 0x0003); + wm8994_write(0x2A, 0x0030); + wm8994_write(0x2D, 0x0001); + wm8994_write(0x2E, 0x0001); + wm8994_write(0x33, 0x0018); + //wm8994_write(0x36, 0x000C); //MIXOUTL_TO_SPKMIXL MIXOUTR_TO_SPKMIXR + wm8994_write(0x200, 0x0011); //AIF1 CLOCKING(1) + wm8994_write(0x204, 0x0011); //AIF2 CLOCKING(1) + wm8994_write(0x208, 0x000E); //CLOCKING(1) + wm8994_write(0x520, 0x0000); //AIF2 DAC FILTERS(1) + wm8994_write(0x601, 0x0004); //AIF2DACL_DAC1L + wm8994_write(0x602, 0x0004); //AIF2DACR_DAC1R + + wm8994_write(0x610, 0x01C0); //DAC1 Left Volume bit0~7 + wm8994_write(0x611, 0x01C0); //DAC1 Right Volume bit0~7 + wm8994_write(0x612, 0x01C0); //DAC2 Left Volume bit0~7 + wm8994_write(0x613, 0x01C0); //DAC2 Right Volume bit0~7 + + wm8994_write(0x702, 0xC100); //GPIO3 + wm8994_write(0x703, 0xC100); //GPIO4 + wm8994_write(0x704, 0xC100); //GPIO5 + wm8994_write(0x706, 0x4100); //GPIO7 + wm8994_write(0x204, 0x0011); //AIF2 MCLK=FLL1 + wm8994_write(0x211, 0x0009); //LRCK=8KHz, Rate=MCLK/1536 + #ifdef TD688_MODE + wm8994_write(0x310, 0xc108); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef CHONGY_MODE + wm8994_write(0x310, 0xc018); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef MU301_MODE + wm8994_write(0x310, 0xc118); ///0x4118); ///interface dsp mode 16bit + wm8994_write(0x241, 0x2f04); + wm8994_write(0x242, 0x0000); + wm8994_write(0x243, 0x0300); + wm8994_write(0x240, 0x0004); + mdelay(40); + wm8994_write(0x240, 0x0005); + wm8994_write(0x204, 0x0019); + wm8994_write(0x211, 0x0003); + wm8994_write(0x244, 0x0c83); + wm8994_write(0x620, 0x0000); + #endif + #ifdef THINKWILL_M800_MODE + //wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + #endif + wm8994_write(0x310, 0x4118); + wm8994_write(0x311, 0x0000); + wm8994_write(0x313, 0x0060); //AIF2BCLK + wm8994_write(0x314, 0x0020); //AIF2ADCLRCK + wm8994_write(0x315, 0x0020); //AIF2DACLRCLK + + wm8994_write(0x603, 0x0180); //Rev.D ADCL SideTone + wm8994_write(0x604, 0x0020); ///0x0010); //ADC2_TO_DAC2L + wm8994_write(0x605, 0x0020); //0x0010); //ADC2_TO_DAC2R + wm8994_write(0x621, 0x0000); ///0x0001); + //wm8994_write(0x317, 0x0003); + //wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER + + //For handset + wm8994_write(0x01, 0x0B33);//0x3833); // + wm8994_write(0x1C, 0x01F9); + wm8994_write(0x1D, 0x01F9); + wm8994_write(0x4C, 0x9F25); + wm8994_write(0x60, 0x00EE); + + wm8994_write(0x422, 0x0000); ////AIF2 un-mute as master + + //wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER + wm8994_set_level_volume(); + //wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol); +#endif + +#if 0 + wm8994_write(0x01, 0x0003|wm8994_mic_VCC); + msleep(50); + wm8994_write(0x221, 0x0700); //MCLK=12MHz + wm8994_write(0x222, 0x3127); + wm8994_write(0x223, 0x0100); + wm8994_write(0x220, 0x0004); + msleep(50); + wm8994_write(0x220, 0x0005); + + wm8994_write(0x01, 0x0803|wm8994_mic_VCC); ///0x0813); + wm8994_write(0x02, 0x0240); ///0x0110); + wm8994_write(0x03, 0x00F0); + wm8994_write(0x04, 0x3003); + wm8994_write(0x05, 0x3003); + wm8994_write(0x18, 0x011F); + wm8994_write(0x1F, 0x0000); + wm8994_write(0x28, 0x0030); ///0x0003); + wm8994_write(0x29, 0x0020); + wm8994_write(0x2D, 0x0001); + wm8994_write(0x2E, 0x0001); + wm8994_write(0x33, 0x0018); + wm8994_write(0x200, 0x0001); + wm8994_write(0x204, 0x0001); + wm8994_write(0x208, 0x0007); + wm8994_write(0x520, 0x0000); + wm8994_write(0x601, 0x0004); + wm8994_write(0x602, 0x0004); + + wm8994_write(0x610, 0x01C0); //DAC1 Left Volume bit0~7 + wm8994_write(0x611, 0x01C0); //DAC1 Right Volume bit0~7 + wm8994_write(0x612, 0x01C0); //DAC2 Left Volume bit0~7 + wm8994_write(0x613, 0x01C0); //DAC2 Right Volume bit0~7 + + wm8994_write(0x702, 0xC100); + wm8994_write(0x703, 0xC100); + wm8994_write(0x704, 0xC100); + wm8994_write(0x706, 0x4100); + wm8994_write(0x204, 0x0011); //AIF2 MCLK=FLL1 + wm8994_write(0x211, 0x0009); //LRCK=8KHz, Rate=MCLK/1536 + #ifdef TD688_MODE + wm8994_write(0x310, 0x4108); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef CHONGY_MODE + wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef MU301_MODE + wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + wm8994_write(0x241, 0x2f04); + wm8994_write(0x242, 0x0000); + wm8994_write(0x243, 0x0300); + wm8994_write(0x240, 0x0004); + msleep(40); + wm8994_write(0x240, 0x0005); + wm8994_write(0x204, 0x0019); + wm8994_write(0x211, 0x0003); + wm8994_write(0x244, 0x0c83); + wm8994_write(0x620, 0x0000); + #endif + #ifdef THINKWILL_M800_MODE + wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + #endif + wm8994_write(0x313, 0x00F0); + wm8994_write(0x314, 0x0020); + wm8994_write(0x315, 0x0020); + + wm8994_write(0x603, 0x018C); //Rev.D ADCL SideTone + wm8994_write(0x604, 0x0010); + wm8994_write(0x605, 0x0010); + wm8994_write(0x621, 0x0000); ///0x0001); + wm8994_write(0x317, 0x0003); + wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER +#endif + +} + +void mainMIC_to_PCMBB_to_earpiece(void) //pcmbaseband { DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1491,7 +1817,7 @@ void mainMIC_to_baseband_to_earpiece(void) //pcmbaseband } -void mainMIC_to_baseband_to_speakers(void) //pcmbaseband +void mainMIC_to_PCMBB_to_speakers(void) //pcmbaseband { DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1500,6 +1826,127 @@ void mainMIC_to_baseband_to_speakers(void) //pcmbaseband wm8994_reset(); msleep(50); +#if 1 + wm8994_write(0x01, 0x0003|wm8994_mic_VCC); //0x0013); + mdelay(50); + + //GPIO configuration + wm8994_write(0x0700, 0xA101); + wm8994_write(0x39, 0x006C); + + //VMID and BIAS + wm8994_write(0x01, 0x0023|wm8994_mic_VCC); //0x0013); + wm8994_write(0x200, 0x0000); + mdelay(50); + wm8994_write(0x200, 0x0001); + + wm8994_write(0x220, 0x0000); + wm8994_write(0x221, 0x0700); //MCLK=12MHz //FLL1 CONTRLO(2) + wm8994_write(0x222, 0xB51E); //0x3126); //FLL1 CONTRLO(3) + wm8994_write(0x223, 0x0100); //FLL1 CONTRLO(4) + wm8994_write(0x220, 0x0004); //FLL1 CONTRLO(1) + //mdelay(50); + mdelay(10); + wm8994_write(0x220, 0x0005); //FLL1 CONTRLO(1) + mdelay(5); + + wm8994_write(0x200, 0x0010); + wm8994_write(0x208, 0x0008); + wm8994_write(0x208, 0x000A); + wm8994_write(0x210, 0x0083); + wm8994_write(0x302, 0x3000); + wm8994_write(0x302, 0x7000); + wm8994_write(0x303, 0x0040); + wm8994_write(0x304, 0x0040); + wm8994_write(0x305, 0x0040); + wm8994_write(0x300, 0x4010); + wm8994_write(0x200, 0x0011); + + //wm8994_write(0x01, 0x3003|wm8994_mic_VCC); + wm8994_write(0x01, 0x0803|wm8994_mic_VCC); + wm8994_write(0x02, 0x0110); + wm8994_write(0x03, 0x00F0); ///0x0330); + wm8994_write(0x04, 0x3003); + wm8994_write(0x05, 0x3003); + wm8994_write(0x1A, 0x0119);//0x015F); + wm8994_write(0x1F, 0x0000); + //wm8994_write(0x22, 0x0000); + //wm8994_write(0x23, 0x0100); ///0x0000); + //wm8994_write(0x25, 0x0152); + wm8994_write(0x28, 0x0003); + wm8994_write(0x2A, 0x0030); + wm8994_write(0x2D, 0x0001); + wm8994_write(0x2E, 0x0001); + wm8994_write(0x33, 0x0018); + //wm8994_write(0x36, 0x000C); //MIXOUTL_TO_SPKMIXL MIXOUTR_TO_SPKMIXR + wm8994_write(0x200, 0x0011); //AIF1 CLOCKING(1) + wm8994_write(0x204, 0x0011); //AIF2 CLOCKING(1) + wm8994_write(0x208, 0x000E);//0x000E); //CLOCKING(1) + wm8994_write(0x520, 0x0000); //AIF2 DAC FILTERS(1) + wm8994_write(0x601, 0x0004); //AIF2DACL_DAC1L + wm8994_write(0x602, 0x0004); //AIF2DACR_DAC1R + + wm8994_write(0x610, 0x01C0); //DAC1 Left Volume bit0~7 + wm8994_write(0x611, 0x01C0); //DAC1 Right Volume bit0~7 + wm8994_write(0x612, 0x01C0); //DAC2 Left Volume bit0~7 + wm8994_write(0x613, 0x01C0); //DAC2 Right Volume bit0~7 + + wm8994_write(0x702, 0xC100); //GPIO3 + wm8994_write(0x703, 0xC100); //GPIO4 + wm8994_write(0x704, 0xC100); //GPIO5 + wm8994_write(0x706, 0x4100); //GPIO7 + wm8994_write(0x204, 0x0011); //AIF2 MCLK=FLL1 + wm8994_write(0x211, 0x0009); //LRCK=8KHz, Rate=MCLK/1536 + #ifdef TD688_MODE + wm8994_write(0x310, 0xc108); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef CHONGY_MODE + wm8994_write(0x310, 0xc018); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef MU301_MODE + wm8994_write(0x310, 0xc118); ///0x4118); ///interface dsp mode 16bit + wm8994_write(0x241, 0x2f04); + wm8994_write(0x242, 0x0000); + wm8994_write(0x243, 0x0300); + wm8994_write(0x240, 0x0004); + mdelay(40); + wm8994_write(0x240, 0x0005); + wm8994_write(0x204, 0x0019); + wm8994_write(0x211, 0x0003); + wm8994_write(0x244, 0x0c83); + wm8994_write(0x620, 0x0000); + #endif + #ifdef THINKWILL_M800_MODE + //wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + #endif + wm8994_write(0x310, 0x4118); + wm8994_write(0x311, 0x0000); + wm8994_write(0x313, 0x0060); //AIF2BCLK + wm8994_write(0x314, 0x0020); //AIF2ADCLRCK + wm8994_write(0x315, 0x0020); //AIF2DACLRCLK + + wm8994_write(0x603, 0x0180); //Rev.D ADCL SideTone + wm8994_write(0x604, 0x0020); ///0x0010); //ADC2_TO_DAC2L + wm8994_write(0x605, 0x0020); //0x0010); //ADC2_TO_DAC2R + wm8994_write(0x621, 0x0000); ///0x0001); + //wm8994_write(0x317, 0x0003); + //wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER + + //For Speaker + wm8994_write(0x01, 0x3833); // + wm8994_write(0x03, 0x03F0); + wm8994_write(0x22, 0x0000); + wm8994_write(0x23, 0x0000); + wm8994_write(0x25, 0x017F); //+12DB 0x15B:4DB + //wm8994_write(0x25, 0x015B); + wm8994_write(0x36, 0x000C); + + wm8994_write(0x422, 0x0000); ////AIF2 un-mute as master + wm8994_set_level_volume(); + //wm8994_set_volume(wm8994_current_mode,call_vol,call_maxvol); +#endif + +#if 0 wm8994_write(0x01, 0x0003|wm8994_mic_VCC); //0x0013); msleep(50); wm8994_write(0x221, 0x0700); //MCLK=12MHz //FLL1 CONTRLO(2) @@ -1573,11 +2020,11 @@ void mainMIC_to_baseband_to_speakers(void) //pcmbaseband wm8994_write(0x621, 0x0000); ///0x0001); wm8994_write(0x317, 0x0003); wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER - +#endif } -void BT_baseband(void) //pcmbaseband +void BT_PCMBB(void) //pcmbaseband { DBG("%s::%d\n",__FUNCTION__,__LINE__); @@ -1586,6 +2033,131 @@ void BT_baseband(void) //pcmbaseband wm8994_reset(); msleep(50); +#if 1 + wm8994_write(0x01, 0x0003|wm8994_mic_VCC); //0x0013); + mdelay(50); + + //GPIO configuration + wm8994_write(0x0700, 0xA101); + wm8994_write(0x39, 0x006C); + + //VMID and BIAS + wm8994_write(0x01, 0x0023|wm8994_mic_VCC); //0x0013); + wm8994_write(0x200, 0x0000); + mdelay(50); + wm8994_write(0x200, 0x0001); + + wm8994_write(0x220, 0x0000); + wm8994_write(0x221, 0x0700); //MCLK=12MHz //FLL1 CONTRLO(2) + wm8994_write(0x222, 0x3126); //FLL1 CONTRLO(3) + wm8994_write(0x223, 0x0100); //FLL1 CONTRLO(4) + wm8994_write(0x220, 0x0004); //FLL1 CONTRLO(1) + //mdelay(50); + mdelay(10); + wm8994_write(0x220, 0x0005); //FLL1 CONTRLO(1) + mdelay(5); + + wm8994_write(0x200, 0x0010); + wm8994_write(0x208, 0x0008); + wm8994_write(0x208, 0x000A); + wm8994_write(0x210, 0x0083); + wm8994_write(0x302, 0x3000); + wm8994_write(0x302, 0x7000); + wm8994_write(0x303, 0x0040); + wm8994_write(0x304, 0x0040); + wm8994_write(0x305, 0x0040); + wm8994_write(0x300, 0x4010); + wm8994_write(0x200, 0x0011); + + //wm8994_write(0x01, 0x3003|wm8994_mic_VCC); + wm8994_write(0x01, 0x0803|wm8994_mic_VCC); + wm8994_write(0x02, 0x0110); + wm8994_write(0x03, 0x00F0); ///0x0330); + wm8994_write(0x04, 0x3003); + wm8994_write(0x05, 0x3003); + wm8994_write(0x1A, 0x015F);//0x014B); + wm8994_write(0x1F, 0x0000); + //wm8994_write(0x22, 0x0000); + //wm8994_write(0x23, 0x0100); ///0x0000); + //wm8994_write(0x25, 0x0152); + wm8994_write(0x28, 0x0003); + wm8994_write(0x2A, 0x0030); + wm8994_write(0x2D, 0x0001); + wm8994_write(0x2E, 0x0001); + wm8994_write(0x33, 0x0018); + //wm8994_write(0x36, 0x000C); //MIXOUTL_TO_SPKMIXL MIXOUTR_TO_SPKMIXR + wm8994_write(0x200, 0x0011); //AIF1 CLOCKING(1) + wm8994_write(0x204, 0x0011); //AIF2 CLOCKING(1) + wm8994_write(0x208, 0x0007);//0x0007); //CLOCKING(1) + wm8994_write(0x520, 0x0000); //AIF2 DAC FILTERS(1) + wm8994_write(0x601, 0x0004); //AIF2DACL_DAC1L + wm8994_write(0x602, 0x0004); //AIF2DACR_DAC1R + + wm8994_write(0x610, 0x01C0); //DAC1 Left Volume bit0~7 + wm8994_write(0x611, 0x01C0); //DAC1 Right Volume bit0~7 + wm8994_write(0x612, 0x01C0); //DAC2 Left Volume bit0~7 + wm8994_write(0x613, 0x01C0); //DAC2 Right Volume bit0~7 + + wm8994_write(0x702, 0xC100); //GPIO3 + wm8994_write(0x703, 0xC100); //GPIO4 + wm8994_write(0x704, 0xC100); //GPIO5 + wm8994_write(0x706, 0x4100); //GPIO7 + + wm8994_write(0x707, 0xA100); + wm8994_write(0x708, 0xA100); + wm8994_write(0x709, 0xA100); + wm8994_write(0x70A, 0xA100); + wm8994_write(0x06, 0x0014); + + wm8994_write(0x204, 0x0011); //AIF2 MCLK=FLL1 + wm8994_write(0x211, 0x0009); //LRCK=8KHz, Rate=MCLK/1536 + #ifdef TD688_MODE + wm8994_write(0x310, 0xc108); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef CHONGY_MODE + wm8994_write(0x310, 0xc018); ///0x4118); ///interface dsp mode 16bit + #endif + #ifdef MU301_MODE + wm8994_write(0x310, 0xc118); ///0x4118); ///interface dsp mode 16bit + wm8994_write(0x241, 0x2f04); + wm8994_write(0x242, 0x0000); + wm8994_write(0x243, 0x0300); + wm8994_write(0x240, 0x0004); + mdelay(40); + wm8994_write(0x240, 0x0005); + wm8994_write(0x204, 0x0019); + wm8994_write(0x211, 0x0003); + wm8994_write(0x244, 0x0c83); + wm8994_write(0x620, 0x0000); + #endif + #ifdef THINKWILL_M800_MODE + //wm8994_write(0x310, 0x4118); ///0x4118); ///interface dsp mode 16bit + #endif + wm8994_write(0x310, 0x4118); + wm8994_write(0x311, 0x0000); + wm8994_write(0x313, 0x0060); //AIF2BCLK + wm8994_write(0x314, 0x0020); //AIF2ADCLRCK + wm8994_write(0x315, 0x0020); //AIF2DACLRCLK + + wm8994_write(0x603, 0x0180); //Rev.D ADCL SideTone + wm8994_write(0x604, 0x0020); ///0x0010); //ADC2_TO_DAC2L + wm8994_write(0x605, 0x0020); //0x0010); //ADC2_TO_DAC2R + wm8994_write(0x621, 0x0000); ///0x0001); + //wm8994_write(0x317, 0x0003); + //wm8994_write(0x312, 0x0000); //AIF2 SET AS MASTER + +/* //For Speaker + wm8994_write(0x01, 0x3833); // + wm8994_write(0x03, 0x03F0); + wm8994_write(0x22, 0x0000); + wm8994_write(0x23, 0x0000); + //wm8994_write(0x25, 0x017F); //+12DB 0x15B:4DB + wm8994_write(0x36, 0x000C); +*/ + wm8994_write(0x422, 0x0000); ////AIF2 un-mute as master +#endif + +#if 0 wm8994_write(0x01 ,0x0003); msleep (50); @@ -1657,9 +2229,8 @@ void BT_baseband(void) //pcmbaseband wm8994_write(0x4C ,0x9F25); wm8994_write(0x60 ,0x00EE); ///////////end HP test - +#endif } -#endif //PCM_BB #define SOC_DOUBLE_SWITCH_WM8994CODEC(xname, route) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ @@ -1711,13 +2282,13 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, case SPEAKER_NORMAL: //AP-> 8994Codec -> Speaker case SPEAKER_RINGTONE: case EARPIECE_RINGTONE: - if(pdata->phone_pad == 1) + if(pdata->sp_hp_same_channel == 1) AP_to_headset(); else AP_to_speakers(); break; case SPEAKER_INCALL: //BB-> 8994Codec -> Speaker - if(pdata->phone_pad == 1) + if(pdata->sp_hp_same_channel == 1) mainMIC_to_baseband_to_headset(); else mainMIC_to_baseband_to_speakers(); @@ -1734,8 +2305,12 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, mainMIC_to_baseband_to_headset(); break; case EARPIECE_INCALL: //BB-> 8994Codec -> EARPIECE - if(pdata->phone_pad == 1) - mainMIC_to_baseband_to_headset(); + if(pdata->no_earpiece == 1){ + if(pdata->sp_hp_same_channel == 1) + mainMIC_to_baseband_to_headset(); + else + mainMIC_to_baseband_to_speakers(); + } else mainMIC_to_baseband_to_earpiece(); break; @@ -1747,7 +2322,7 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, AP_to_headset(); break; default: - if(pdata->phone_pad == 1) + if(pdata->sp_hp_same_channel == 1) AP_to_headset(); else AP_to_speakers(); @@ -1805,7 +2380,7 @@ int snd_soc_put_route(struct snd_kcontrol *kcontrol, PA_ctrl(GPIO_HIGH); break; case EARPIECE_INCALL: - if(pdata->phone_pad == 1) + if(pdata->no_earpiece == 1) { msleep(50); PA_ctrl(GPIO_HIGH); @@ -2409,6 +2984,7 @@ static int wm8994_probe(struct platform_device *pdev) wm8994 = codec->private_data; pdata = wm8994->pdata; //disable power_EN + rk29_mux_api_set(pdata->PowerEN_iomux_name, pdata->PowerEN_iomux_mode); gpio_request(pdata->Power_EN_Pin, NULL); gpio_direction_output(pdata->Power_EN_Pin,GPIO_LOW); gpio_free(pdata->Power_EN_Pin); @@ -2429,6 +3005,23 @@ static int wm8994_probe(struct platform_device *pdev) goto card_err; } + if(pdata->BB_class == PCM_BB) + { + handsetMIC_to_baseband_to_headset = &handsetMIC_to_PCMBB_to_headset; + mainMIC_to_baseband_to_headset = &mainMIC_to_PCMBB_to_headset; + mainMIC_to_baseband_to_earpiece = &mainMIC_to_PCMBB_to_earpiece; + mainMIC_to_baseband_to_speakers = &mainMIC_to_PCMBB_to_speakers; + BT_baseband = &BT_PCMBB; + } + else + { + handsetMIC_to_baseband_to_headset = &handsetMIC_to_BB_to_headset; + mainMIC_to_baseband_to_headset = &mainMIC_to_BB_to_headset; + mainMIC_to_baseband_to_earpiece = &mainMIC_to_BB_to_earpiece; + mainMIC_to_baseband_to_speakers = &mainMIC_to_BB_to_speakers; + BT_baseband = &BT_BB; + } + PA_ctrl(GPIO_LOW); //enable power_EN msleep(50); From 5d6771f4c2262c17a7670b06a27e5ee1dbbcfa73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E5=B9=B3?= Date: Tue, 20 Sep 2011 16:52:10 +0800 Subject: [PATCH 6/9] phone-pad:add mw100 modem support. --- drivers/misc/Kconfig | 4 +- drivers/misc/MW100.c | 274 ++++++++++++++++++++++++++++++++++++++++++ drivers/misc/Makefile | 1 + 3 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/MW100.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 0d3ad52ea80d..b5fefd612ee0 100755 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -299,7 +299,9 @@ config FM580X config MU509 bool "MU509 modem control driver" default n - +config MW100 + bool "MW100 modem control driver" + default n config RK29_NEWTON bool "RK29_NEWTON misc driver" default n diff --git a/drivers/misc/MW100.c b/drivers/misc/MW100.c new file mode 100644 index 000000000000..98b2c6859fde --- /dev/null +++ b/drivers/misc/MW100.c @@ -0,0 +1,274 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +//#define DEBUG +#ifdef DEBUG +#define MODEMDBG(x...) printk(x) +#else +#define MODEMDBG(fmt,argss...) +#endif + +#define MW100IO 0XA1 +#define MW_IOCTL_RESET _IO(MW100IO,0X01) + +#define SLEEP 1 +#define READY 0 +#define MU509_RESET 0x01 +static struct wake_lock modem_wakelock; +#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +//#define IRQ_BB_WAKEUP_AP_TRIGGER IRQF_TRIGGER_RISING +struct rk29_mu509_data *gpdata = NULL; +static int bp_wakeup_ap_irq = 0; + + +static void ap_wakeup_bp(struct platform_device *pdev, int wake) +{ + struct rk29_mu509_data *pdata = pdev->dev.platform_data; + MODEMDBG("ap_wakeup_bp\n"); + + gpio_set_value(pdata->ap_wakeup_bp, wake); + +} +extern void rk28_send_wakeup_key(void); + +static void do_wakeup(struct work_struct *work) +{ + MODEMDBG("%s[%d]: %s\n", __FILE__, __LINE__, __FUNCTION__); + rk28_send_wakeup_key(); + enable_irq(bp_wakeup_ap_irq); +} + +static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup); +static irqreturn_t detect_irq_handler(int irq, void *dev_id) +{ + disable_irq_nosync( irq); + printk("%s[%d]: %s\n", __FILE__, __LINE__, __FUNCTION__); + schedule_delayed_work(&wakeup_work, HZ / 10); + + return IRQ_HANDLED; +} +int modem_poweron_off(int on_off) +{ + struct rk29_mu509_data *pdata = gpdata; + if(on_off) + { + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); +/* + gpio_set_value(pdata->bp_power, GPIO_LOW); + msleep(1000); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + msleep(700); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); +*/ + } + else + { + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); +/* + gpio_set_value(pdata->bp_power, GPIO_LOW); + mdelay(2500); + gpio_set_value(pdata->bp_power, GPIO_HIGH); +*/ + } + return 0; +} +static int mu509_open(struct inode *inode, struct file *file) +{ + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); + //modem_poweron_off(1); + return 0; +} + +static int mu509_release(struct inode *inode, struct file *file) +{ + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); + //modem_poweron_off(0); + return 0; +} + +static int mu509_ioctl(struct inode *inode,struct file *file, unsigned int cmd, unsigned long arg) +{ + struct rk29_mu509_data *pdata = gpdata; + switch(cmd) + { + case MW_IOCTL_RESET: + printk("%s::%d--bruins--ioctl mw100 reset\n",__func__,__LINE__); + gpio_direction_output(pdata->bp_reset,GPIO_LOW); + mdelay(120); + gpio_set_value(pdata->bp_reset, GPIO_HIGH); + + break; + default: + break; + } + return 0; +} + +static struct file_operations mu509_fops = { + .owner = THIS_MODULE, + .open = mu509_open, + .release = mu509_release, + .ioctl = mu509_ioctl +}; + +static struct miscdevice mu509_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = "mw100", + .fops = &mu509_fops +}; + +static int mu509_probe(struct platform_device *pdev) +{ + struct rk29_mu509_data *pdata = gpdata = pdev->dev.platform_data; + struct modem_dev *mu509_data = NULL; + int result, irq = 0; + + gpio_request(pdata->bp_power,"bp_power"); + gpio_request(pdata->bp_reset,"bp_reset"); + gpio_request(pdata->bp_wakeup_ap,"bp_wakeup_ap"); + gpio_request(pdata->ap_wakeup_bp,"ap_wakeup_bp"); + + rk29_mux_api_set(GPIO6C76_CPUTRACEDATA76_NAME, GPIO4H_GPIO6C76); + + gpio_direction_output(pdata->bp_reset,GPIO_LOW); + mdelay(120); + gpio_set_value(pdata->bp_reset, GPIO_HIGH); + + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); + gpio_direction_output(pdata->ap_wakeup_bp,GPIO_HIGH); + + gpio_set_value(pdata->bp_power, GPIO_HIGH); + gpio_direction_output(pdata->bp_power,GPIO_HIGH); + mdelay(120); + gpio_set_value(pdata->bp_power, GPIO_LOW); + gpio_direction_output(pdata->bp_power,GPIO_LOW); + + + // +/* gpio_set_value(pdata->bp_reset, GPIO_LOW); + gpio_direction_output(pdata->bp_reset,GPIO_LOW); + mdelay(120); + gpio_set_value(pdata->bp_reset, GPIO_HIGH); + gpio_direction_output(pdata->bp_reset,GPIO_HIGH); +*/ + mu509_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL); + if(mu509_data == NULL){ + printk("failed to request mu509_data\n"); + goto err2; + } + platform_set_drvdata(pdev, mu509_data); + + gpio_direction_input(pdata->bp_wakeup_ap); + irq = gpio_to_irq(pdata->bp_wakeup_ap); + if(irq < 0){ + gpio_free(pdata->bp_wakeup_ap); + printk("failed to request bp_wakeup_ap\n"); + } + + bp_wakeup_ap_irq = irq; + + result = request_irq(irq, detect_irq_handler, IRQ_BB_WAKEUP_AP_TRIGGER, "bp_wakeup_ap", NULL); + if (result < 0) { + printk("%s: request_irq(%d) failed\n", __func__, irq); + gpio_free(pdata->bp_wakeup_ap); + goto err0; + } + + enable_irq_wake(bp_wakeup_ap_irq); + + result = misc_register(&mu509_misc); + if(result){ + MODEMDBG("misc_register err\n"); + } + return result; +err0: + gpio_free(pdata->bp_wakeup_ap); +err1: + gpio_free(pdata->ap_wakeup_bp); +err2: + kfree(mu509_data); + return 0; +} + +int mu509_suspend(struct platform_device *pdev) +{ + + struct rk29_mu509_data *pdata = pdev->dev.platform_data; + MODEMDBG("%s::%d--\n",__func__,__LINE__); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_LOW); + return 0; +} + +int mu509_resume(struct platform_device *pdev) +{ + struct rk29_mu509_data *pdata = pdev->dev.platform_data; + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); + gpio_set_value(pdata->ap_wakeup_bp, GPIO_HIGH); + return 0; +} + +void mu509_shutdown(struct platform_device *pdev, pm_message_t state) +{ + struct rk29_mu509_data *pdata = pdev->dev.platform_data; + struct modem_dev *mu509_data = platform_get_drvdata(pdev); + + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); + gpio_set_value(pdata->bp_power, GPIO_HIGH); + mdelay(2010); + + gpio_free(pdata->bp_power); + gpio_free(pdata->bp_reset); + gpio_free(pdata->ap_wakeup_bp); + gpio_free(pdata->bp_wakeup_ap); + kfree(mu509_data); +} + +static struct platform_driver mu509_driver = { + .probe = mu509_probe, + .shutdown = mu509_shutdown, + .suspend = mu509_suspend, + .resume = mu509_resume, + .driver = { + .name = "MW100", + .owner = THIS_MODULE, + }, +}; + +static int __init mu509_init(void) +{ + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); + return platform_driver_register(&mu509_driver); +} + +static void __exit mu509_exit(void) +{ + MODEMDBG("%s::%d--bruins--\n",__func__,__LINE__); + platform_driver_unregister(&mu509_driver); +} + +module_init(mu509_init); + +module_exit(mu509_exit); diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index c3dc3cf11ce2..6d98f4888a68 100755 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_APANIC) += apanic.o obj-$(CONFIG_MTK23D) += mtk23d.o obj-$(CONFIG_FM580X) += fm580x.o obj-$(CONFIG_MU509) += mu509.o +obj-$(CONFIG_MW100) += MW100.o obj-$(CONFIG_STE) += ste.o obj-$(CONFIG_RK29_SUPPORT_MODEM) += rk29_modem/ obj-$(CONFIG_GPS_GNS7560) += gps/ From 5cce5b4334cb5c8b4c78913776a71a1fcbe25b93 Mon Sep 17 00:00:00 2001 From: huangdesheng Date: Wed, 21 Sep 2011 15:08:34 +0800 Subject: [PATCH 7/9] add compose_layer_count in fb --- drivers/video/rk29_fb.c | 10 +++++++++- include/linux/fb.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/video/rk29_fb.c b/drivers/video/rk29_fb.c index 7eff5a019a7e..497bed843afb 100755 --- a/drivers/video/rk29_fb.c +++ b/drivers/video/rk29_fb.c @@ -272,7 +272,7 @@ static u32 last_yuv_phy[2] = {0,0}; #endif int fb0_first_buff_bits = 32; int fb0_second_buff_bits = 32; - +int fb_compose_layer_count = 0; static BLOCKING_NOTIFIER_HEAD(rk29fb_notifier_list); int rk29fb_register_notifier(struct notifier_block *nb) { @@ -1735,6 +1735,14 @@ static int fb0_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { return fb0_first_buff_bits; } + case FBIOSET_COMPOSE_LAYER_COUNTS: + fb_compose_layer_count = arg; + break; + + case FBIOGET_COMPOSE_LAYER_COUNTS: + + return fb_compose_layer_count; + case FBIOPUT_FBPHYADD: return info->fix.smem_start; case FBIOGET_OVERLAY_STATE: diff --git a/include/linux/fb.h b/include/linux/fb.h index 4463d75862ea..c3a17a72f8b6 100755 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -49,6 +49,8 @@ struct dentry; #define FBIOGET_SCREEN_STATE 0X4620 #define FBIOGET_16OR32 0X4621 #define FBIOGET_IDLEFBUff_16OR32 0X4622 +#define FBIOSET_COMPOSE_LAYER_COUNTS 0X4623 +#define FBIOGET_COMPOSE_LAYER_COUNTS 0X4624 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ #define FB_TYPE_PLANES 1 /* Non interleaved planes */ From 879db17051889289577ca2e673d79db208c78ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E5=B9=B3?= Date: Thu, 22 Sep 2011 12:47:28 +0800 Subject: [PATCH 8/9] phone-pad: ui pmem should be no_allocator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上次的提交误操作修改了no_allocator的值,这里将其还原 --- arch/arm/mach-rk29/board-rk29phonepadsdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-rk29/board-rk29phonepadsdk.c b/arch/arm/mach-rk29/board-rk29phonepadsdk.c index 2f343f320a01..2d8f49ed3a2c 100755 --- a/arch/arm/mach-rk29/board-rk29phonepadsdk.c +++ b/arch/arm/mach-rk29/board-rk29phonepadsdk.c @@ -384,7 +384,7 @@ static struct android_pmem_platform_data android_pmem_pdata = { .name = "pmem", .start = PMEM_UI_BASE, .size = PMEM_UI_SIZE, - .no_allocator = 0, + .no_allocator = 1, .cached = 1, }; From a9b0ef73b211797cd888b5445c3b962320bdf02e Mon Sep 17 00:00:00 2001 From: xbw Date: Thu, 22 Sep 2011 13:18:17 +0800 Subject: [PATCH 9/9] add the function of write-protec for sdmmc after you select the option --- arch/arm/mach-rk29/board-rk29-ddr3sdk.c | 33 ++++++++++++++++++++++++ arch/arm/mach-rk29/include/mach/board.h | 1 + drivers/mmc/host/Kconfig | 13 ++++++++++ drivers/mmc/host/rk29_sdmmc.c | 34 ++++++++++++++++++++++--- 4 files changed, 77 insertions(+), 4 deletions(-) mode change 100644 => 100755 arch/arm/mach-rk29/include/mach/board.h mode change 100644 => 100755 drivers/mmc/host/Kconfig diff --git a/arch/arm/mach-rk29/board-rk29-ddr3sdk.c b/arch/arm/mach-rk29/board-rk29-ddr3sdk.c index 7e8c3ce90ed8..a739fefdf1ec 100755 --- a/arch/arm/mach-rk29/board-rk29-ddr3sdk.c +++ b/arch/arm/mach-rk29/board-rk29-ddr3sdk.c @@ -1823,6 +1823,15 @@ static struct platform_device rk29_device_pwm_regulator = { #endif +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) +#define SDMMC0_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin. +#endif + + +#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) +#define SDMMC1_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin. +#endif + /***************************************************************************************** * SDMMC devices *****************************************************************************************/ @@ -1851,6 +1860,12 @@ static int rk29_sdmmc0_cfg_gpio(void) #else gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW); #endif + +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) + gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp"); + gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN); +#endif + return 0; } @@ -1869,6 +1884,12 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = { #endif .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO .enable_sd_wakeup = 0, + +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) + .write_prt = SDMMC0_WRITE_PROTECT_PIN, +#else + .write_prt = INVALID_GPIO, +#endif }; #endif #ifdef CONFIG_SDMMC1_RK29 @@ -1882,6 +1903,11 @@ static int rk29_sdmmc1_cfg_gpio(void) rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2); rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3); //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N); + +#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp"); + gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN); +#endif return 0; } @@ -1912,6 +1938,13 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = { #if 0 .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N, #endif + +#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + .write_prt = SDMMC1_WRITE_PROTECT_PIN, +#else + .write_prt = INVALID_GPIO, +#endif + }; #endif diff --git a/arch/arm/mach-rk29/include/mach/board.h b/arch/arm/mach-rk29/include/mach/board.h old mode 100644 new mode 100755 index c97306d4af19..c5c222428923 --- a/arch/arm/mach-rk29/include/mach/board.h +++ b/arch/arm/mach-rk29/include/mach/board.h @@ -143,6 +143,7 @@ struct rk29_sdmmc_platform_data { int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id); int detect_irq; int enable_sd_wakeup; + int write_prt; }; struct rk29_i2c_platform_data { int bus_num; diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig old mode 100644 new mode 100755 index c5886cdd7201..85df780a5e0a --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -24,6 +24,13 @@ if SDMMC_RK29 depends on ARCH_RK29 help This supports the use of the SDMMC0 controller on Rk29 processors. + + config SDMMC0_RK29_WRITE_PROTECT + bool "Write-protect for SDMMC0" + depends on SDMMC0_RK29 + help + You will add the feature of write-protect for sdmmc-card if you say Yes. + Please note that this feature requires hardware support. # config EMMC_RK29 # tristate "RK29 EMMC controller support(sdmmc)" # default y @@ -36,6 +43,12 @@ if SDMMC_RK29 depends on ARCH_RK29 help This supports the use of the SDMMC1 controller on Rk29 processors. + config SDMMC1_RK29_WRITE_PROTECT + bool "Write-protect for SDMMC1" + depends on SDMMC1_RK29 + help + You will add the feature of write-protect for sdio-card if you say Yes. + Please note that this feature requires hardware support. endif config MMC_ARMMMCI diff --git a/drivers/mmc/host/rk29_sdmmc.c b/drivers/mmc/host/rk29_sdmmc.c index c9ed1c8522cb..488149d41ba4 100755 --- a/drivers/mmc/host/rk29_sdmmc.c +++ b/drivers/mmc/host/rk29_sdmmc.c @@ -61,7 +61,7 @@ int debug_level = 7; #define xbwprintk(n, arg...) #endif -#define RK29_SDMMC_ERROR_FLAGS (SDMMC_INT_FRUN /*| SDMMC_INT_RTO*/ | SDMMC_INT_HLE ) +#define RK29_SDMMC_ERROR_FLAGS (SDMMC_INT_FRUN | SDMMC_INT_HLE ) #define RK29_SDMMC_INTMASK_USEDMA (SDMMC_INT_CMD_DONE | SDMMC_INT_DTO | RK29_SDMMC_ERROR_FLAGS | SDMMC_INT_CD) #define RK29_SDMMC_INTMASK_USEIO (SDMMC_INT_CMD_DONE | SDMMC_INT_DTO | RK29_SDMMC_ERROR_FLAGS | SDMMC_INT_CD| SDMMC_INT_TXDR | SDMMC_INT_RXDR ) @@ -72,7 +72,7 @@ int debug_level = 7; #define RK29_SDMMC_WAIT_DTO_INTERNVAL 1500 //The time interval from the CMD_DONE_INT to DTO_INT #define RK29_SDMMC_REMOVAL_DELAY 2000 //The time interval from the CD_INT to detect_timer react. -#define RK29_SDMMC_VERSION "Ver.2.07 The last modify date is 2011-09-09,modifyed by XBW." +#define RK29_SDMMC_VERSION "Ver.2.08 The last modify date is 2011-09-21,modifyed by XBW." #define RK29_CTRL_SDMMC_ID 0 //mainly used by SDMMC #define RK29_CTRL_SDIO1_ID 1 //mainly used by sdio-wifi @@ -197,10 +197,16 @@ struct rk29_sdmmc { unsigned int oldstatus; unsigned int complete_done; unsigned int retryfunc; + #ifdef CONFIG_PM int gpio_irq; int gpio_det; #endif + +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + int write_protect; +#endif + }; @@ -2074,10 +2080,26 @@ out: static int rk29_sdmmc_get_ro(struct mmc_host *mmc) { - struct rk29_sdmmc *host = mmc_priv(mmc); + struct rk29_sdmmc *host = mmc_priv(mmc); + +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + int ret; + + if(INVALID_GPIO == host->write_protect) + ret = 0;//no write-protect + else + ret = gpio_get_value(host->write_protect)?1:0; + + xbwprintk(7,"%s..%d.. write_prt_pin=%d, get_ro=%d ===xbw[%s]===\n",\ + __FUNCTION__, __LINE__,host->write_protect, ret, host->dma_name); + + return ret; + +#else u32 wrtprt = rk29_sdmmc_read(host->regs, SDMMC_WRTPRT); - + return (wrtprt & SDMMC_WRITE_PROTECT)?1:0; +#endif } @@ -3027,6 +3049,10 @@ static int rk29_sdmmc_probe(struct platform_device *pdev) host->dma_addr = regs->start + SDMMC_DATA; } +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + host->write_protect = pdata->write_prt; +#endif + rk29_sdmmc_hw_init(host); ret = request_irq(irq, rk29_sdmmc_interrupt, 0, dev_name(&pdev->dev), host);