[Feature][ZXW-65]merged P49 base code

Change-Id: I3e09c0c3d47483bc645f02310380ecb7fc6f4041
diff --git a/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c b/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
index dffcb04..9808d24 100755
--- a/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
@@ -75,36 +75,38 @@
 (VOID*pCodecContext);extern VOID mmp_AmrEncClose(VOID*pCodecContext);extern 
 UINT8 zDrvEdcp_IsBusy(int EdcpNum);extern SINT32 zDrvVp_AudioDataWrite(const 
 VOID*pBuf,UINT32 uiLen);extern SINT32 zDrvVp_AudioDataOpen(UINT32 audioType,
-UINT32 sampleRate);extern SINT32 zDrvVp_AudioDataClose(void);typedef struct 
-cpko_section{unsigned int cpko_text_start;unsigned int cpko_rodata_start;
-unsigned int __utran_modem_text_start;unsigned int __lte_modem_text_start;
-unsigned int __comm_modem_text_start;unsigned int modem_text_end;unsigned int 
-cpko_data_start;unsigned int cpko_bss_start;unsigned int cpko_text_offset;}
-cpko_section_layout;cpko_section_layout cpko_ps_section;int raise(int signo){
-return(0x11fa+11-0x1205);}extern unsigned int SysEntry(void);static int 
+UINT32 sampleRate);extern SINT32 zDrvVp_AudioDataClose(void);extern SINT32 
+zDrvVp_GetVpLoop_Wrap(VOID);typedef struct cpko_section{unsigned int 
+cpko_text_start;unsigned int cpko_rodata_start;unsigned int 
+__utran_modem_text_start;unsigned int __lte_modem_text_start;unsigned int 
+__comm_modem_text_start;unsigned int modem_text_end;unsigned int cpko_data_start
+;unsigned int cpko_bss_start;unsigned int cpko_text_offset;}cpko_section_layout;
+cpko_section_layout cpko_ps_section;int raise(int signo){return
+(0x588+2748-0x1044);}extern unsigned int SysEntry(void);static int 
 ko_Main_Thread(void*data){struct sched_param param={.sched_priority=
-MAX_USER_RT_PRIO/(0xded+2359-0x1722)-(0x11e3+270-0x12ee)};int ret=
-(0xf8b+2482-0x193d);sched_setscheduler(current,SCHED_FIFO,&param);ret=SysEntry()
-;if(ret!=(0xbd2+2713-0x166b))panic("Main_Thread\n");param.sched_priority=
-MAX_USER_RT_PRIO-(0x755+66-0x769);sched_setscheduler(kthreadd_task,SCHED_FIFO,&
-param);return(0xfd4+33-0xff5);}int zte_modem_ko_start(void){kthread_run(
-ko_Main_Thread,NULL,"\x5a\x54\x45\x4d\x61\x69\x6e\x54\x68\x72\x65\x61\x64");
-return(0x81b+4816-0x1aeb);}static void cpko_sectioninfo_set(void){int ret;struct
- file*fp;mm_segment_t old_fs;loff_t cpko_pos=(0x2024+1215-0x24e3);struct 
+MAX_USER_RT_PRIO/(0x1aa2+478-0x1c7e)-(0xb4b+3818-0x1a32)};int ret=
+(0x985+3929-0x18de);sched_setscheduler(current,SCHED_FIFO,&param);ret=SysEntry()
+;if(ret!=(0xacd+2158-0x133b))panic("Main_Thread\n");param.sched_priority=
+MAX_USER_RT_PRIO-(0x1194+2176-0x19e6);sched_setscheduler(kthreadd_task,
+SCHED_FIFO,&param);return(0x1e56+83-0x1ea9);}int zte_modem_ko_start(void){
+kthread_run(ko_Main_Thread,NULL,
+"\x5a\x54\x45\x4d\x61\x69\x6e\x54\x68\x72\x65\x61\x64");return
+(0x1109+1789-0x1806);}static void cpko_sectioninfo_set(void){int ret;struct file
+*fp;mm_segment_t old_fs;loff_t cpko_pos=(0x16fb+814-0x1a29);struct 
 cpps_globalModem globalVar;fp=filp_open(
 "\x2f\x6c\x69\x62\x2f\x63\x70\x6b\x6f\x2f\x63\x70\x6b\x6f\x5f\x73\x65\x63\x69\x6e\x66\x6f\x2e\x62\x69\x6e"
-,(0x1d5+6034-0x1967),(0x5d9+3622-0x13ff));if(IS_ERR(fp)||fp==NULL)panic(
+,(0x2fa+1778-0x9ec),(0x13ec+700-0x16a8));if(IS_ERR(fp)||fp==NULL)panic(
 "\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");old_fs=
 get_fs();set_fs(KERNEL_DS);ret=vfs_read(fp,(char*)&cpko_ps_section,sizeof(
-cpko_section_layout),&cpko_pos);if(ret<=(0x5a5+4030-0x1563))panic(
+cpko_section_layout),&cpko_pos);if(ret<=(0xd62+2480-0x1712))panic(
 "\x72\x65\x61\x64\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");filp_close(
 fp,NULL);
 #ifdef CONFIG_MODEM_CODE_IS_MAPPING
 fp=filp_open(
 "\x2f\x6c\x69\x62\x2f\x63\x70\x6b\x6f\x2f\x63\x70\x6b\x6f\x2e\x6b\x6f",
-(0x8d3+2653-0x1330),(0xab6+4007-0x1a5d));if(IS_ERR(fp)||fp==NULL)panic(
+(0x172f+1154-0x1bb1),(0xc82+3654-0x1ac8));if(IS_ERR(fp)||fp==NULL)panic(
 "\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");fp->f_ra.
-ra_pages=(0x4b1+8568-0x2629);
+ra_pages=(0xb17+2019-0x12fa);
 #endif
 if(cpko_ps_section.cpko_text_start){globalVar.cpko_text_start=(unsigned long)
 cpko_ps_section.cpko_text_start;globalVar.cpko_rodata_start=(unsigned long)
@@ -124,7 +126,7 @@
 vfree_modem_section(globalVar.cpko_text_start,globalVar.modem_text_end);
 #endif
 }else panic("\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");}static int 
-cpko_start(void){struct cpps_callbacks callback={(0x2ec+4566-0x14c2)};callback.
+cpko_start(void){struct cpps_callbacks callback={(0x800+2644-0x1254)};callback.
 zOss_ResetNVFactory=zOss_ResetNVFactory;callback.zOss_NvramFlush=zOss_NvramFlush
 ;callback.zOss_NvItemWrite=zOss_NvItemWrite;callback.zOss_NvItemWriteFactory=
 zOss_NvItemWriteFactory;callback.zOss_NvItemRead=zOss_NvItemRead;callback.
@@ -169,17 +171,18 @@
 zDrvVp_SetDtmfMute_Wrap;callback.zDrvVp_SetTxVol_Wrap=zDrvVp_SetTxVol_Wrap;
 callback.zDrvVp_GetTxVol_Wrap=zDrvVp_GetTxVol_Wrap;callback.zDrvVp_GetPath_Wrap=
 zDrvVp_GetPath_Wrap;callback.zDrvVp_Loop=zDrvVp_Loop;callback.
-zDrvVp_Soft_Dtmf_Loop=zDrvVp_Soft_Dtmf_Loop;callback.
-zDrvDtmf_Detect_RegCallbacks=zDrvDtmf_Detect_RegCallbacks;callback.
-zDrvVp_SetPath_Wrap=zDrvVp_SetPath_Wrap;callback.zDrvVp_GetPath_Wrap=
-zDrvVp_GetPath_Wrap;callback.halVoice_Open3G=halVoice_Open3G;callback.
-halVoice_Close3G=halVoice_Close3G;callback.zDrvVp_GetSlicFlag=zDrvVp_GetSlicFlag
-;callback.zDrvVp_SetEchoDelay_Wrap=zDrvVp_SetEchoDelay_Wrap;callback.
-zDrvVp_GetEchoDelay_Wrap=zDrvVp_GetEchoDelay_Wrap;callback.
-zDrvVp_SetTxNsMode_Wrap=zDrvVp_SetTxNsMode_Wrap;callback.zDrvVp_GetTxNsMode_Wrap
-=zDrvVp_GetTxNsMode_Wrap;callback.zDrvVp_SetRxNsMode_Wrap=
-zDrvVp_SetRxNsMode_Wrap;callback.zDrvVp_GetRxNsMode_Wrap=zDrvVp_GetRxNsMode_Wrap
-;callback.zDrvVp_SetModuleState_Wrap=zDrvVp_SetModuleState_Wrap;callback.
+zDrvVp_GetVpLoop_Wrap=zDrvVp_GetVpLoop_Wrap;callback.zDrvVp_Soft_Dtmf_Loop=
+zDrvVp_Soft_Dtmf_Loop;callback.zDrvDtmf_Detect_RegCallbacks=
+zDrvDtmf_Detect_RegCallbacks;callback.zDrvVp_SetPath_Wrap=zDrvVp_SetPath_Wrap;
+callback.zDrvVp_GetPath_Wrap=zDrvVp_GetPath_Wrap;callback.halVoice_Open3G=
+halVoice_Open3G;callback.halVoice_Close3G=halVoice_Close3G;callback.
+zDrvVp_GetSlicFlag=zDrvVp_GetSlicFlag;callback.zDrvVp_SetEchoDelay_Wrap=
+zDrvVp_SetEchoDelay_Wrap;callback.zDrvVp_GetEchoDelay_Wrap=
+zDrvVp_GetEchoDelay_Wrap;callback.zDrvVp_SetTxNsMode_Wrap=
+zDrvVp_SetTxNsMode_Wrap;callback.zDrvVp_GetTxNsMode_Wrap=zDrvVp_GetTxNsMode_Wrap
+;callback.zDrvVp_SetRxNsMode_Wrap=zDrvVp_SetRxNsMode_Wrap;callback.
+zDrvVp_GetRxNsMode_Wrap=zDrvVp_GetRxNsMode_Wrap;callback.
+zDrvVp_SetModuleState_Wrap=zDrvVp_SetModuleState_Wrap;callback.
 zDrvVp_GetModuleState_Wrap=zDrvVp_GetModuleState_Wrap;callback.mmp_AmrDecOpen=
 mmp_AmrDecOpen;callback.mmp_AmrEncOpen=mmp_AmrEncOpen;callback.mmp_AmrDecode=
 mmp_AmrDecode;callback.mmp_AmrEncode=mmp_AmrEncode;callback.mmp_AmrDecClose=
@@ -193,5 +196,5 @@
 psm_GetModemSleepFlagStatus=psm_GetModemSleepFlagStatus;
 #endif
 cpps_callbacks_register(&callback);cpko_sectioninfo_set();zte_modem_ko_start();
-return(0x1c55+1612-0x22a1);}static int cpko_stop(void){return(0x193+979-0x566);}
+return(0x990+7510-0x26e6);}static int cpko_stop(void){return(0xe70+451-0x1033);}
 module_init(cpko_start);module_exit(cpko_stop);
diff --git a/ap/os/linux/linux-3.4.x/drivers/cpufreq/cpufreq.c b/ap/os/linux/linux-3.4.x/drivers/cpufreq/cpufreq.c
index cf864ef..811757a 100644
--- a/ap/os/linux/linux-3.4.x/drivers/cpufreq/cpufreq.c
+++ b/ap/os/linux/linux-3.4.x/drivers/cpufreq/cpufreq.c
@@ -1948,3 +1948,61 @@
 	return 0;
 }
 core_initcall(cpufreq_core_init);
+
+
+/* only for zx297520v3 */
+static int cpufreq_manual_adjust(unsigned int min_freq, unsigned int max_freq)
+{
+	unsigned int ret;
+	struct cpufreq_policy new_policy;
+	struct cpufreq_policy *data;
+
+	data = cpufreq_cpu_get(0);
+	if (!data)
+		return -EINVAL;
+
+	memcpy(&new_policy, data, sizeof(struct cpufreq_policy));
+
+	new_policy.min = min_freq;
+	new_policy.max = max_freq;
+
+	ret = __cpufreq_set_policy(data, &new_policy);
+	data->user_policy.min = data->min;
+	data->user_policy.max = data->max;
+
+	cpufreq_cpu_put(data);
+
+	return ret;
+}
+
+extern u32 zDrvTsCtrl_DfsEn(void);
+int cpufreq_performance(void)
+{
+	int ret;
+	
+	if (zDrvTsCtrl_DfsEn())
+		return 0;
+
+	ret = cpufreq_manual_adjust(312000, 624000);
+	if (ret)
+		return ret;
+
+	return cpufreq_manual_adjust(624000, 624000);
+}
+
+int cpufreq_powersave(void)
+{
+	int ret;
+
+	ret = cpufreq_manual_adjust(312000, 624000);
+	if (ret)
+		return ret;
+
+	return cpufreq_manual_adjust(312000, 312000);
+}
+
+int cpufreq_normal(void)
+{
+	return cpufreq_manual_adjust(312000, 624000);
+}
+
diff --git a/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-irq.c b/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-irq.c
index 14980d8..1d466ee 100644
--- a/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-irq.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mfd/zx234290-irq.c
@@ -110,7 +110,7 @@
 
 	buck_sts &= ~buck_mask;
 	ldo_sts &= ~ldo_mask;
-
+	buck_sts &=~(1<<ZX234290_LDO_RSTERR_LSH);//clear rst flag
 	if(buck_sts )
 		irq_sts |= (1 << ZX234290_INT_BUCK_FAUL);
 	else
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/core/core.c b/ap/os/linux/linux-3.4.x/drivers/mmc/core/core.c
index a8dd777..35c15c9 100644
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/core/core.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/core/core.c
@@ -35,6 +35,7 @@
 #include <linux/mmc/sd.h>
 #include <mach/zx29_mmc.h>
 #include <mach/highspeed_debug.h>
+#include "../host/zx29_mmc.h"
 
 #include "core.h"
 #include "bus.h"
@@ -44,7 +45,7 @@
 #include "mmc_ops.h"
 #include "sd_ops.h"
 #include "sdio_ops.h"
-#include "../host/dw_mmc.h"
+//#include "../host/dw_mmc.h"
 static struct workqueue_struct *workqueue;
 
 /*
@@ -75,6 +76,10 @@
 /*
  * Internal function. Schedule delayed work in the MMC work queue.
  */
+extern void mmc_spin_lock(struct dw_mci *host);
+extern void mmc_spin_unlock(struct dw_mci *host);
+void mmc_enable_irq(struct mmc_host *mmc,int enable);
+
 static int mmc_schedule_delayed_work(struct delayed_work *work,
 				     unsigned long delay)
 {
@@ -695,6 +700,26 @@
 }
 EXPORT_SYMBOL(mmc_try_claim_host);
 
+
+void mmc_get_host(struct mmc_host *mmc)
+{
+	struct dw_mci_slot *slot = mmc_priv(mmc);
+	struct dw_mci *host = slot->host;
+
+	mmc_spin_lock(host);
+	mmc_enable_irq(mmc,1);
+}
+
+void mmc_put_host(struct mmc_host *mmc)
+{
+	struct dw_mci_slot *slot = mmc_priv(mmc);
+	struct dw_mci *host = slot->host;
+
+	mmc_enable_irq(mmc,0);
+	mmc_spin_unlock(host);
+}
+
+
 /**
  *	mmc_release_host - release a host
  *	@host: mmc host to release
@@ -2068,6 +2093,8 @@
 		container_of(work, struct mmc_host, detect.work);
 	int i;
 	bool extend_wakelock = false;
+	struct dw_mci_slot *slot = mmc_priv(host);
+	struct dw_mci *hw_host = slot->host;
 
 	if (host->rescan_disable)
 		return;
@@ -2113,6 +2140,7 @@
 		goto out;
 
 	mmc_claim_host(host);
+	mmc_spin_lock(hw_host);
 	for (i = 0; i < ARRAY_SIZE(freqs); i++) {
 		if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min))) {
 			extend_wakelock = true;
@@ -2121,6 +2149,7 @@
 		if (freqs[i] <= host->f_min)
 			break;
 	}
+	mmc_spin_unlock(hw_host);
 	mmc_release_host(host);
 
  out:
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
index b674ba8..5d3ef3c 100644
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc-pltfm.c
@@ -285,6 +285,15 @@
 		if(rc)
 			BUG();
 		zx29_gpio_config(ZX29_GPIO_77, GPIO77_SD1_DATA3);
+#ifdef _USE_VEHICLE_DC_REF
+		rc=gpio_request(ZX29_GPIO_85,"emmc_vcc_en");
+		if(rc)
+			printk("mmc: Get emmc VCC en gpio fail\n");
+		
+		zx29_gpio_config(ZX29_GPIO_85, GPIO85_GPIO85);
+		zx29_gpio_output_data(ZX29_GPIO_85,GPIO_HIGH);
+#endif
+		
 	}
 #endif
 	if(host->pdata->quirks & DW_MCI_QUIRK_AUTO_GATE) {
diff --git a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
index 9e3e781..b1a7a72 100644
--- a/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mmc/host/zx29_mmc.c
@@ -163,6 +163,9 @@
 #endif
 #define DW_DMA_DESC_TRANS_LEN    (8192 -16)//(4*1024)   /*define dw idma one desc can config trans-len*/
 
+extern void mmc_get_host(struct mmc_host * host);
+extern void mmc_put_host(struct mmc_host * host);
+
 static void dw_mci_init_dma(struct dw_mci *host);
 static void dw_mci_stop_dma(struct dw_mci *host);
 static inline bool dw_mci_fifo_reset(struct dw_mci *host);
@@ -1884,7 +1887,9 @@
 		list_add_tail(&slot->queue_node, &host->queue);
 	}
 }
-
+#ifdef _USE_VEHICLE_DC	
+volatile int s_request_cnt = 0;
+#endif
 static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 {
 	struct dw_mci_slot *slot = mmc_priv(mmc);
@@ -1897,10 +1902,25 @@
 	 * atomic, otherwise the card could be removed in between and the
 	 * request wouldn't fail until another card was inserted.
 	 */
+#ifdef _USE_VEHICLE_DC	
+	if(host->host_id ==1){
+	if(s_request_cnt ==0)
+		mmc_get_host(slot->mmc);
+	s_request_cnt++;
+	}
+#endif	
 	DW_MCI_SPIN_LOCK_BH(&host->lock);
 
 	if (!test_bit(DW_MMC_CARD_PRESENT, &slot->flags)) {
 		DW_MCI_SPIN_UNLOCK_BH(&host->lock);
+#ifdef _USE_VEHICLE_DC
+		if(host->host_id ==1){
+			s_request_cnt--;
+			if(s_request_cnt ==0)
+				mmc_put_host(slot->mmc);
+		}
+#endif
+	
 		mrq->cmd->error = -ENOMEDIUM;
 		mmc_request_done(mmc, mrq);
 		return;
@@ -2223,6 +2243,12 @@
 		xlog_mmc_log_op(host->host_id, mrq->cmd->opcode, "REQ DONE, list empty",
 						mrq->cmd->error, mrq->cmd->resp[0], (mrq->stop ? mrq->stop->resp[0] : 0));
 		host->state = STATE_IDLE;
+#ifdef _USE_VEHICLE_DC			
+		if(host->host_id ==1){
+			mmc_put_host(prev_mmc);
+			s_request_cnt = 0;
+		}
+#endif		
 	}
 
 	spin_unlock(&host->lock);
@@ -3298,6 +3324,28 @@
 #endif
 	return IRQ_HANDLED;
 }
+void mmc_enable_irq(struct mmc_host *mmc,int enable)
+{
+	struct dw_mci_slot *slot = mmc_priv(mmc);
+	
+#ifdef _USE_VEHICLE_DC
+	if(slot->host->host_id != 1)
+		return;
+	
+	mci_writel(slot->host, DBADDR, (u32)slot->host->sg_dma);
+
+	if((slot == NULL)||(slot->host==NULL)||(slot->host->irq==NULL))
+		return;
+	if(enable){
+		enable_irq(slot->host->irq);
+	}
+	else{
+		disable_irq(slot->host->irq);
+	}
+#endif	
+	return;
+
+}
 
 static void dw_mci_work_routine_card(struct work_struct *work)
 {
@@ -3926,6 +3974,26 @@
 EXPORT_SYMBOL_GPL(zx29_mci_enable_sdio_irq);
 
 #endif
+
+void mmc_spin_lock(struct dw_mci *host)
+{
+	
+#ifdef _USE_VEHICLE_DC
+	if(host->host_id==1)
+		soft_spin_lock(SD1_SFLOCK);
+#endif	
+	return;
+}
+void mmc_spin_unlock(struct dw_mci *host)
+{
+	
+#ifdef _USE_VEHICLE_DC
+	if(host->host_id==1)
+		soft_spin_unlock(SD1_SFLOCK);
+#endif	
+	return;
+}
+
 int dw_mci_probe(struct dw_mci *host)
 {
 	//const struct dw_mci_drv_data *drv_data = host->drv_data;
@@ -3964,6 +4032,8 @@
 
 	spin_lock_init(&host->lock);
 	INIT_LIST_HEAD(&host->queue);
+	
+	mmc_spin_lock(host);
 
 	/*
 	 * Get the host data width - this assumes that HCON has been set with
@@ -4069,6 +4139,10 @@
 	ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags | IRQF_NO_THREAD , "dw-mci", host);
 	if (ret)
 		goto err_workqueue;
+#ifdef _USE_VEHICLE_DC
+	if(host->host_id ==1)
+		disable_irq(host->irq);
+#endif
 
 	//ret = irq_set_irq_wake(host->irq, 1);
 	if (host->quirks & DW_MCI_QUIRK_SDIO) {
@@ -4139,6 +4213,9 @@
 		mci_writel(host, UHS_REG_EXT,clk_phase);
 		printk("%s UHS_REG = 0x%x\n",__func__,mci_readl(host, UHS_REG_EXT));	
 	}
+	
+	mmc_spin_unlock(host);
+	
 	return 0;
 
 err_workqueue:
@@ -4161,7 +4238,8 @@
 err_clk_biu:
 	if (!IS_ERR(host->biu_clk))
 		clk_disable_unprepare(host->biu_clk);
-
+	
+	mmc_spin_unlock(host);
 	return ret;
 }
 EXPORT_SYMBOL(dw_mci_probe);
diff --git a/ap/os/linux/linux-3.4.x/drivers/mtd/nand/nand_ids.c b/ap/os/linux/linux-3.4.x/drivers/mtd/nand/nand_ids.c
index 76aa21c..ca6012e 100755
--- a/ap/os/linux/linux-3.4.x/drivers/mtd/nand/nand_ids.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mtd/nand/nand_ids.c
@@ -44,7 +44,7 @@
 	{"NAND 16MiB 1,8V 8-bit",	0x33, 512, 16, 0x4000, 0},
 	{"NAND 16MiB 3,3V 8-bit",	0x73, 512, 16, 0x4000, 0},
 	{"NAND 16MiB 1,8V 16-bit",	0x43, 512, 16, 0x4000, NAND_BUSWIDTH_16},
-	{"NAND 16MiB 3,3V 16-bit",	0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16},
+	//{"NAND 16MiB 3,3V 16-bit",	0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16},
 
 	//{"NAND 32MiB 1,8V 8-bit",	0x35, 512, 32, 0x4000, 0},
 	{"NAND 32MiB 3,3V 8-bit",	0x75, 512, 32, 0x4000, 0},
@@ -88,7 +88,7 @@
 	{"SPI-NAND 256MiB 1,8V",	0x25, 2048, 256, 0x20000, 0},		//MT29F2G01ABAGDWB
 	{"SPI-NAND 512MiB 1,8V",	0x35, 4096, 512, 0x40000, 0},	
 	{"SPI-NAND 512MiB 1,8V",	0x45, 2048, 512, 0x20000, 0},	//GD5F4GQ6REY2G
-	
+	{"SPI-NAND 512MiB 1,8V",	0x53, 4096, 512, 0x40000, 0},	//XT26Q04D-B
 	/*
 	 * These are the new chips with large page size. The pagesize and the
 	 * erasesize is determined from the extended id bytes
@@ -224,6 +224,7 @@
 	{NAND_MFR_HOSIN, "hosin"},
 	{NAND_MFR_EMST, "emst"},
 	{NAND_MFR_FORESEE, "foresee"},
+	{NAND_MFR_XTX, "xtx"},
 	{0x0, "Unknown"}
 };
 
diff --git a/ap/os/linux/linux-3.4.x/drivers/mtd/nand/spi_nand_devices.c b/ap/os/linux/linux-3.4.x/drivers/mtd/nand/spi_nand_devices.c
index fa0c004..a2eb6b1 100755
--- a/ap/os/linux/linux-3.4.x/drivers/mtd/nand/spi_nand_devices.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mtd/nand/spi_nand_devices.c
@@ -268,6 +268,22 @@
 	}
 }
 
+static void get_xtx_nand_para(uint8_t device_id)
+{
+
+	switch (device_id) {
+	case 0x53:
+		main_size = 4096;
+		spare_size = 256;
+		break;
+	default:
+		printk("Spectra: Unknown xtx NAND (Device ID: 0x%x)."
+				"Will use default parameter values instead.\n",
+				device_id);
+	}
+}
+
+
 void spi_nand_get_param(uint32_t maf_id, uint32_t dev_id)
 {
 	if (maf_id == NAND_MFR_GIGADEVICE) {
@@ -310,6 +326,9 @@
 	else if (maf_id == NAND_MFR_MICRON) {
 		get_micron_nand_para(dev_id);
 	}
+	else if (maf_id == NAND_MFR_XTX) {
+		get_xtx_nand_para(dev_id);
+	}
 	else{
 		printk("Spectra: Unknown manufacturer (ID: 0x%x).", maf_id);
 	}
@@ -390,6 +409,10 @@
 	 .oobfree = {{64,64}}
   };
 
+static struct nand_ecclayout nand_xtx_oob_256= {
+    .eccbytes = 192,
+    .oobfree = {{2,62}}
+};
  
 static void	spi_nand_winbond_init(struct spi_nand_info *spi_nand)
 {
@@ -477,6 +500,7 @@
 			||(g_maf_id == NAND_MFR_FORESEE)
 			||(g_maf_id == NAND_MFR_GIGADEVICE)
 			||(g_maf_id == NAND_MFR_WINBOND)
+			|| (g_maf_id == NAND_MFR_XTX)
 			||(g_maf_id == NAND_MFR_MICRON))
 			return PLX4_MODE;
 		else
@@ -494,6 +518,7 @@
 			||(g_maf_id == NAND_MFR_FORESEE)
 			||(g_maf_id == NAND_MFR_GIGADEVICE)
 			||(g_maf_id == NAND_MFR_WINBOND)
+			|| (g_maf_id == NAND_MFR_XTX)
 			||(g_maf_id == NAND_MFR_MICRON))
 			return RDX4_MODE;
 		else
@@ -622,6 +647,12 @@
 			}
 		}
 		break;
+	case NAND_MFR_XTX:
+		if(mtd->oobsize==256 && mtd->writesize==4096)
+		{
+			chip->ecc.layout =&nand_xtx_oob_256;
+		}
+		break;
 	default:
 		break;
 	}
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/psnet/psnet_io.c b/ap/os/linux/linux-3.4.x/drivers/net/psnet/psnet_io.c
index ca1e0f2..7033685 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/psnet/psnet_io.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/psnet/psnet_io.c
@@ -91,7 +91,7 @@
 	if(likely(g_psnet_ipv6_prefix[cid-1].flag))
 		return;
 
-	if ((pkt[0] & 0xF0) == 0x60 && len >= (sizeof(struct ipv6hdr) + sizeof(struct ra_msg) + sizeof(struct nd_opt_prefix_info))){
+	if (cid > 0 && cid <= DDR_DEV_MAX && (pkt[0] & 0xF0) == 0x60 && len >= (sizeof(struct ipv6hdr) + sizeof(struct ra_msg) + sizeof(struct nd_opt_prefix_info))){
 		struct ipv6hdr *ip6h = (struct ipv6hdr *)pkt;
 		unsigned char nexthdr = ip6h->nexthdr;
 		unsigned char *hp = pkt + sizeof(struct ipv6hdr);
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
index 6237623..09586d0 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800/rwnx_main.c
@@ -5874,6 +5874,7 @@
 {};
 
 uint32_t ldpc_cfg_ram[] = {
+#if 0//def CONFIG_FPGA_VERIFICATION
     0x00363638,
     0x1DF8F834,
     0x1DF8F834,
@@ -6209,6 +6210,343 @@
     0x0213130F,
     0x02131308,
     0x02131308
+#else
+    0x00767679,
+    0x1DF8F870,
+    0x1DF8F870,
+    0x1DF8F870,
+    0x1DF8F870,
+    0x006E6E72,
+    0x1DF8F869,
+    0x1DF8F869,
+    0x1DF8F869,
+    0x1DF8F869,
+    0x0076767B,
+    0x1DF8F870,
+    0x1DF8F870,
+    0x1DF8F870,
+    0x1DF8F870,
+    0x007E7E85,
+    0x1DF4F876,
+    0x1DF4F876,
+    0x1DF4F876,
+    0x1DF8F876,
+    0x0081818A,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x0081818D,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x0081818A,
+    0x1DF8F87B,
+    0x1DF8F87C,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x007E7E40,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x1DF8F87B,
+    0x008B8B92,
+    0x1DF8F887,
+    0x1DF8F889,
+    0x1DF8F887,
+    0x1DF8F887,
+    0x00515155,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F889,
+    0x1DF8F889,
+    0x00515154,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F888,
+    0x1DF8F888,
+    0x004F4F53,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x004F4F53,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x004F4F53,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x004E4E53,
+    0x1DF8F849,
+    0x1DF8F848,
+    0x1DF8F848,
+    0x1DF8F848,
+    0x004D4D52,
+    0x1DF8F847,
+    0x1DF8F847,
+    0x1DF8F847,
+    0x1DF8F847,
+    0x004F4F55,
+    0x1DF8F84B,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x004E4E53,
+    0x1DF8F849,
+    0x1DF8F848,
+    0x1DF8F848,
+    0x1DF8F848,
+    0x0049494D,
+    0x1DF8F844,
+    0x1DF8F844,
+    0x1DF8F844,
+    0x1DF8F844,
+    0x0051518F,
+    0x1DF8F849,
+    0x1DF8F848,
+    0x1DF8F848,
+    0x1DF8F848,
+    0x00424277,
+    0x1DF8F83F,
+    0x1DF8F83C,
+    0x1DF8F83C,
+    0x1DF8F83C,
+    0x00424275,
+    0x1DF8F89E,
+    0x1DF8F83C,
+    0x1DF8F83C,
+    0x1DF8F83C,
+    0x0055555C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x0053535C,
+    0x1DF8F84C,
+    0x1DF8F84B,
+    0x1DF8F84B,
+    0x1DF8F84B,
+    0x00F8F89E,
+    0x1DF8F88C,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x00898940,
+    0x18F8F846,
+    0x18CFF845,
+    0x18CFF844,
+    0x18CFF844,
+    0x0056565F,
+    0x1DF8F84F,
+    0x1DF8F84F,
+    0x1DF8F84F,
+    0x1DF8F84F,
+    0x0055555E,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x0056565F,
+    0x1DF8F84F,
+    0x1DF8F84F,
+    0x1DF8F84F,
+    0x1DF8F84F,
+    0x00555561,
+    0x1DF8F850,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x0053535F,
+    0x1DF8F84D,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x0055555F,
+    0x1DF8F84F,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x005555AA,
+    0x1DF8F854,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x1DF8F84E,
+    0x005959A6,
+    0x1DF8F84D,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x004F4F9B,
+    0x1DF8F84E,
+    0x1DF8F846,
+    0x1DF8F846,
+    0x1DF8F846,
+    0x00F8F8A5,
+    0x1DF8F894,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x009898A4,
+    0x1DF8F84D,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x00464686,
+    0x1DF8F8B3,
+    0x1DF8F83D,
+    0x1DF8F83D,
+    0x1DF8F83D,
+    0x008E8E40,
+    0x1AF8F848,
+    0x1ADFF848,
+    0x1ADFF846,
+    0x1ADFF846,
+    0x007F7F40,
+    0x18D2D275,
+    0x18D2D23A,
+    0x18D2D23A,
+    0x18D2D239,
+    0x00454540,
+    0x0F868664,
+    0x0F86863E,
+    0x0F86863D,
+    0x0F86863D,
+    0x005C5C64,
+    0x1DF8F856,
+    0x1DF8F855,
+    0x1DF8F855,
+    0x1DF8F855,
+    0x005B5B68,
+    0x1DF8F858,
+    0x1DF8F855,
+    0x1DF8F855,
+    0x1DF8F855,
+    0x005A5A64,
+    0x1DF8F855,
+    0x1DF8F854,
+    0x1DF8F854,
+    0x1DF8F854,
+    0x005A5AB5,
+    0x1DF8F85B,
+    0x1DF8F855,
+    0x1DF8F854,
+    0x1DF8F854,
+    0x00F8F8B0,
+    0x1DF8F8A3,
+    0x1DF8F852,
+    0x1DF8F852,
+    0x1DF8F852,
+    0x00A4A4AE,
+    0x1DF8F854,
+    0x1DF8F852,
+    0x1DF8F852,
+    0x1DF8F852,
+    0x009A9A40,
+    0x1DF8F84E,
+    0x1DF8F84D,
+    0x1DF8F84C,
+    0x1DF8F84C,
+    0x009C9C40,
+    0x1DF8F895,
+    0x1DF8F849,
+    0x1DF8F84A,
+    0x1DF8F84A,
+    0x00494940,
+    0x1197976F,
+    0x11979742,
+    0x11979741,
+    0x11979741,
+    0x006E6E74,
+    0x1DF8F869,
+    0x1DF8F869,
+    0x1DF8F869,
+    0x1DF8F869,
+    0x006E6E40,
+    0x1ADEF869,
+    0x1ADEF869,
+    0x1ADEF869,
+    0x1ADEF869,
+    0x00757540,
+    0x0D78F86E,
+    0x0D78F86E,
+    0x0D78F86E,
+    0x0D79F86E,
+    0x00787885,
+    0x1DF8F873,
+    0x1DF8F873,
+    0x1DF8F873,
+    0x1DF8F873,
+    0x00787840,
+    0x1DF8F873,
+    0x1DF8F873,
+    0x1DF8F873,
+    0x1DF8F873,
+    0x00787840,
+    0x0E81F873,
+    0x0E81F873,
+    0x0E81F873,
+    0x0E82F873,
+    0x00404040,
+    0x0E82F873,
+    0x0E82F873,
+    0x0E82F873,
+    0x0E82F873,
+    0x00818140,
+    0x1092F87E,
+    0x1092F87E,
+    0x1092F87E,
+    0x1092F87E,
+    0x00404040,
+    0x1092F87E,
+    0x1092F87E,
+    0x1092F87E,
+    0x1092F87E,
+    0x00737340,
+    0x14B2B26B,
+    0x14B2B235,
+    0x14B2B235,
+    0x14B2B235,
+    0x00404040,
+    0x0E828260,
+    0x0E82823D,
+    0x0E82823C,
+    0x0E82823C,
+    0x00404040,
+    0x0F8B8B66,
+    0x0F8B8B3F,
+    0x0F8B8B3D,
+    0x0F8B8B3D,
+    0x00404040,
+    0x0B68683D,
+    0x0B68681E,
+    0x0B68681E,
+    0x0B68681E,
+    0x00222240,
+    0x06434318,
+    0x06434329,
+    0x06434318,
+    0x06434318,
+    0x00404040,
+    0x129D9D72,
+    0x129D9D43,
+    0x129D9D41,
+    0x129D9D41,
+    0x00404040,
+    0x0D757542,
+    0x0D757520,
+    0x0D757520,
+    0x0D757520,
+    0x00232340,
+    0x084C4C19,
+    0x084C4C2C,
+    0x084C4C19,
+    0x084C4C19
+#endif
 };
 
 uint32_t agc_cfg_ram[] = {
@@ -6825,54 +7163,55 @@
     0x20c0cbbb,
     0x20c0cbd2,
     #else
-    0x00ffc772,
-    0x00ffc780,
-    0x00ffc872,
-    0x00ffc880,
-    0x00ffc970,
-    0x00ffc980,
-    0x00ffc990,
-    0x00ffca80,
-    0x00ffca9a,
-    0x00ffcb90,
-    0x00ffcc95,
-    0x00ffce80,
-    0x00ffcf80,
-    0x00ffcf80,
-    0x00ffcf80,
-    0x00ffcf80,
-    0x00ffc05b,
-    0x00ffc066,
-    0x00ffc070,
-    0x00ffc080,
-    0x00ffc175,
-    0x00ffc185,
-    0x00ffc272,
-    0x00ffc280,
-    0x00ffc290,
-    0x00ffc380,
-    0x00ffc472,
-    0x00ffc483,
-    0x00ffc572,
-    0x00ffc580,
-    0x00ffc590,
-    0x00ffc680,
+    //11b
+    0x00ffd780,
+    0x00ffd872,
+    0x00ffd880,
+    0x00ffd972,
+    0x00ffd980,
+    0x00ffda75,
+    0x00ffda86,
+    0x00ffdb77,
+    0x00ffdb86,
+    0x00ffdc78,
+    0x00ffdc89,
+    0x00ffdd79,
+    0x00ffdd89,
+    0x00ffde83,
+    0x00ffdf79,
+    0x00ffdf8b,
+    0x00ffd072,
+    0x00ffd072,
+    0x00ffd080,
+    0x00ffd172,
+    0x00ffd180,
+    0x00ffd272,
+    0x00ffd280,
+    0x00ffd36d,
+    0x00ffd379,
+    0x00ffd46d,
+    0x00ffd479,
+    0x00ffd572,
+    0x00ffd580,
+    0x00ffd672,
+    0x00ffd680,
+    0x00ffd772,
     0x00ffc87d,
     0x00ffc88b,
     0x00ffc979,
     0x00ffc989,
     0x00ffca7d,
-    0x00ffca8d,
-    0x00ffcb7a,
-    0x00ffcb8a,
-    0x00ffcc7d,
-    0x00ffcc8d,
-    0x00ffcd79,
-    0x00ffcd89,
-    0x00ffce7d,
-    0x00ffce8d,
-    0x00ffcf80,
-    0x00ffcf99,
+    0x00ffca88,
+    0x00ffcc5e,
+    0x00ffcc69,
+    0x00ffcc78,
+    0x00ffcc85,
+    0x00ffcd70,
+    0x00ffcd80,
+    0x00ffce70,
+    0x00ffce80,
+    0x00ffcf7d,
+    0x00ffcf90,
     0x00ffc080,
     0x00ffc090,
     0x00ffc180,
@@ -6880,9 +7219,9 @@
     0x00ffc27b,
     0x00ffc28b,
     0x00ffc37b,
-    0x00ffc38b,
-    0x00ffc480,
-    0x00ffc490,
+    0x00ffc390,
+    0x00ffc485,
+    0x00ffc495,
     0x00ffc579,
     0x00ffc589,
     0x00ffc679,
@@ -6894,17 +7233,17 @@
     0x00ffc979,
     0x00ffc989,
     0x00ffca7d,
-    0x00ffca8d,
-    0x00ffcb7a,
-    0x00ffcb8a,
-    0x00ffcc7d,
-    0x00ffcc8d,
-    0x00ffcd79,
-    0x00ffcd89,
-    0x00ffce7d,
-    0x00ffce8d,
-    0x00ffcf80,
-    0x00ffcf99,
+    0x00ffca88,
+    0x00ffcc5e,
+    0x00ffcc69,
+    0x00ffcc78,
+    0x00ffcc85,
+    0x00ffcd70,
+    0x00ffcd80,
+    0x00ffce70,
+    0x00ffce80,
+    0x00ffcf7d,
+    0x00ffcf90,
     0x00ffc080,
     0x00ffc090,
     0x00ffc180,
@@ -6912,19 +7251,19 @@
     0x00ffc27b,
     0x00ffc28b,
     0x00ffc37b,
-    0x00ffc38b,
-    0x00ffc480,
-    0x00ffc490,
+    0x00ffc390,
+    0x00ffc485,
+    0x00ffc495,
     0x00ffc579,
     0x00ffc589,
     0x00ffc679,
     0x00ffc689,
     0x00ffc780,
-    0x00ffc790
+    0x00ffc790,
     #endif
 };
 
-uint32_t txgain_table[32] =
+u32 wifi_txgain_table_24g_8800dcdw[32] =
 {
     0xA4B22189,
     0x00007825,
@@ -6960,7 +7299,42 @@
     0x00004832
 };
 
-uint32_t rxgain_table_24g_20m[64] = {
+u32 wifi_txgain_table_24g_1_8800dcdw[32] =
+{
+    0x090E2011, //index 0
+    0x00004001,
+    0x090E2015, //index 1
+    0x00004001,
+    0x090E201B, //index 2
+    0x00004001,
+    0x110E2018, //index 3
+    0x00004001,
+    0x110E201E, //index 4
+    0x00004001,
+    0x110E2023, //index 5
+    0x00004001,
+    0x190E2021, //index 6
+    0x00004001,
+    0x190E202B, //index 7
+    0x00004001,
+    0x210E202B, //index 8
+    0x00004001,
+    0x230E2027, //index 9
+    0x00004001,
+    0x230E2031, //index 10
+    0x00004001,
+    0x240E2039, //index 11
+    0x00004001,
+    0x260E2039, //index 12
+    0x00004001,
+    0x2E0E203F, //index 13
+    0x00004001,
+    0x368E203F, //index 14
+    0x00004001,
+    0x3EF2203F, //index 15
+    0x00004001
+};
+u32 wifi_rxgain_table_24g_20m_8800dcdw[64] = {
     0x82f282d1,
     0x9591a324,
     0x80808419,
@@ -6993,28 +7367,28 @@
     0x9595a324,
     0x80808419,
     0x000000f0,
-    0x06f282d2,
-    0x95911124,
+    0x02f282d2,//index 8
+    0x95951124,
     0x80808419,
     0x000000f0,
-    0x06f282f4,
-    0x95911124,
+    0x02f282f4,//index 9
+    0x95951124,
     0x80808419,
     0x000000f0,
-    0x06f282e6,
-    0x9591a324,
-    0x80808419,
-    0x000000f0,
-    0x06f282e6,
+    0x02f282e6,//index 10
     0x9595a324,
     0x80808419,
     0x000000f0,
-    0x06f282e6,
+    0x02f282e6,//index 11
     0x9599a324,
     0x80808419,
     0x000000f0,
-    0x06f282e6,
-    0x959b5924,
+    0x02f282e6,//index 12
+    0x959da324,
+    0x80808419,
+    0x000000f0,
+    0x02f282e6,//index 13
+    0x959f5924,
     0x80808419,
     0x000000f0,
     0x06f282e6,
@@ -7022,14 +7396,14 @@
     0x80808419,
     0x000000f0,
     0x0ef29ae6,
-    0x959f5924,
+    0x959f592c,//////0x959f5924,           //loft [35:34]=3
     0x80808419,
     0x000000f0
 };
 
 
 
-uint32_t rxgain_table_24g_40m[64] = {
+u32 wifi_rxgain_table_24g_40m_8800dcdw[64] = {
     0x83428151,
     0x9631a328,
     0x80808419,
@@ -7062,28 +7436,28 @@
     0x9635a328,
     0x80808419,
     0x000000f0,
-    0x07429952,
-    0x96311128,
+    0x03428152,//index 8
+    0x96351128,
     0x80808419,
     0x000000f0,
-    0x07429974,
-    0x96311128,
+    0x03428174,//index 9
+    0x96351128,
     0x80808419,
     0x000000f0,
-    0x07429966,
-    0x9631a328,
-    0x80808419,
-    0x000000f0,
-    0x07429966,
+    0x03428166,//index 10
     0x9635a328,
     0x80808419,
     0x000000f0,
-    0x07429966,
+    0x03428166,//index 11
     0x9639a328,
     0x80808419,
     0x000000f0,
-    0x07429966,
-    0x963b5928,
+    0x03428166,//index 12
+    0x963da328,
+    0x80808419,
+    0x000000f0,
+    0x03428166,//index 13
+    0x963f5928,
     0x80808419,
     0x000000f0,
     0x07429966,
@@ -7124,7 +7498,7 @@
     {0x0098, 0x445},
     {0x009c, 0x5e332},
     #endif
-    //{0x0090, 0x0013FC00}, //rx_ringbuf_start2
+    {0x0090, 0x0013FC00}, //rx_ringbuf_start2
     #endif
 #ifdef CONFIG_USB_TX_AGGR
     {0x00E8, 0x03021714}, //usb fc params(rx msg fc recover, rx msg fc trigger, wifi fc recover, wifi fc trigger)
@@ -7709,13 +8083,15 @@
 
 
     if (testmode == 0) {
-        if ((ret = rwnx_send_rf_config_req(rwnx_hw, 0,  1, (u8_l *)txgain_table, 128)))
+		if ((ret = rwnx_send_rf_config_req(rwnx_hw, 0,	1, (u8_l *)wifi_txgain_table_24g_8800dcdw, 128)))
             goto err_lmac_reqs;
 
-        if ((ret = rwnx_send_rf_config_req(rwnx_hw, 0,  0, (u8_l *)rxgain_table_24g_20m, 256)))
+        if ((ret = rwnx_send_rf_config_req(rwnx_hw, 16,	1, (u8_l *)wifi_txgain_table_24g_1_8800dcdw, 128)))
+			goto err_lmac_reqs;
+		if ((ret = rwnx_send_rf_config_req(rwnx_hw, 0,	0, (u8_l *)wifi_rxgain_table_24g_20m_8800dcdw, 256)))
             goto err_lmac_reqs;
 
-        if ((ret = rwnx_send_rf_config_req(rwnx_hw, 32,  0, (u8_l *)rxgain_table_24g_40m, 256)))
+		if ((ret = rwnx_send_rf_config_req(rwnx_hw, 32,  0, (u8_l *)wifi_rxgain_table_24g_40m_8800dcdw, 256)))
             goto err_lmac_reqs;
 
         if ((ret = rwnx_send_rf_calib_req(rwnx_hw, &cfm))) {
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es/8192cd_sme.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es/8192cd_sme.c
index 0c22647..510e9d3 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es/8192cd_sme.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/rtl8192cd_92es/8192cd_sme.c
@@ -11560,6 +11560,15 @@
 #ifdef CONFIG_POWER_SAVE
 	rtw_lock_suspend_timeout(priv, 5000);
 #endif
+
+	if (priv->pmib->dot1180211AuthEntry.dot11EnablePSK != 0) {
+		if (OPMODE & WIFI_AP_STATE) {	
+			//Reset 4-WAY STATE for some phones' connection issue
+			if (pstat && pstat->wpa_sta_info)
+				pstat->wpa_sta_info->state = PSK_STATE_IDLE;
+		}
+	}
+
 	txinsn.retry = priv->pmib->dot11OperationEntry.dot11ShortRetryLimit;
 
 	pmib= GET_MIB(priv);
@@ -21277,7 +21286,7 @@
 #endif
 #endif
 
-	DEBUG_INFO("auth alg=%x, seq=%X\n", algorithm, seq);
+	printk(KERN_ERR"[%s,%d][%s] auth alg=%x, seq=%X\n", __FUNCTION__, __LINE__, priv->dev->name, algorithm, seq);
 
 	if (privacy == CONFIG_AUTH_WEP_AUTO &&
 			priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm != _WEP_40_PRIVACY_ &&
@@ -21421,7 +21430,7 @@
 #endif
 
 		// allocate a new one
-		DEBUG_INFO("going to alloc stainfo for sa=%02X%02X%02X%02X%02X%02X\n",  sa[0],sa[1],sa[2],sa[3],sa[4],sa[5]);
+		printk(KERN_ERR"[%s,%d] going to alloc stainfo for sa=%02X%02X%02X%02X%02X%02X\n", __FUNCTION__, __LINE__, sa[0],sa[1],sa[2],sa[3],sa[4],sa[5]);
 		pstat = alloc_stainfo(priv, sa, -1);
 
 		if (pstat == NULL)
@@ -21434,10 +21443,11 @@
 		pstat->auth_seq = 0;	// clear in alloc_stainfo;nctu note
 		pstat->tpcache_mgt = GetTupleCache(pframe);
 	}
-#ifdef CONFIG_IEEE80211W
+#if 0//def CONFIG_IEEE80211W
 	else if (pstat->isPMF)
 	{
 		pstat->auth_seq = seq + 1;
+		printk(KERN_ERR"[%s,%d][%s] auth_seq[%d] for 11w \n", __FUNCTION__, __LINE__, priv->dev->name, pstat->auth_seq);
 #ifdef INCLUDE_WPA_PSK
 		if (timer_pending(&pstat->wpa_sta_info->resendTimer))
 			del_timer(&pstat->wpa_sta_info->resendTimer);
@@ -21447,6 +21457,7 @@
 #endif		
 	else
 	{	// close exist connection.;nctu note
+		printk(KERN_ERR"[%s,%d][%s] close exist connection. \n", __FUNCTION__, __LINE__, priv->dev->name);
 		if (asoc_list_del(priv, pstat))
 		{
 #if defined(CONFIG_RTK_MESH) && defined(MESH_BOOTSEQ_AUTH)
@@ -21468,9 +21479,11 @@
 
 			if (pstat->expire_to > 0)
 			{
+				printk(KERN_ERR"[%s,%d][%s] sta of exist del. \n", __FUNCTION__, __LINE__, priv->dev->name);
 				cnt_assoc_num(priv, pstat, DECREASE, (char *)__FUNCTION__);
 				check_sta_characteristic(priv, pstat, DECREASE);
 			}
+			printk(KERN_ERR"[%s,%d][%s] ---- \n", __FUNCTION__, __LINE__, priv->dev->name);
 		}
 		if (seq==1) {
 #ifdef  SUPPORT_TX_MCAST2UNI
@@ -21785,6 +21798,9 @@
 	else
 #endif
 	pstat->auth_seq = seq + 1;
+
+	printk(KERN_ERR"[%s,%d][%s] auth_seq[%d] for original \n", __FUNCTION__, __LINE__, priv->dev->name, pstat->auth_seq);
+
 #if defined(CONFIG_RTK_MESH) && defined(MESH_BOOTSEQ_AUTH)
 	if ((FALSE == isMeshMP) || ((1 == seq) && (TRUE == isMeshMP)))
 #endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx-cpufreq.c b/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx-cpufreq.c
index 0434bc3..d31584c 100644
--- a/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx-cpufreq.c
+++ b/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx-cpufreq.c
@@ -108,7 +108,7 @@
 
 	mutex_lock(&cpufreq_lock);
 
-	if((pm_get_mask_info()&PM_NO_CPU_FREQ) || cpu_dfs_is_not_allowed||zDrvTsCtrl_DfsEn())
+	if((pm_get_mask_info()&PM_NO_CPU_FREQ) /*|| cpu_dfs_is_not_allowed||zDrvTsCtrl_DfsEn()*/)
 	{
 		ret = -EAGAIN;
 		goto out;
diff --git a/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx29-cpufreq.c b/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx29-cpufreq.c
index 27f947f..3eabcc0 100644
--- a/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx29-cpufreq.c
+++ b/ap/os/linux/linux-3.4.x/drivers/soc/zte/power/zx29-cpufreq.c
@@ -470,6 +470,10 @@
 #endif	
 }
 
+int cpufreq_performance(void);
+int cpufreq_powersave(void);
+int cpufreq_normal(void);
+
 /**
  * set freq according to index of freq_table. 
  * 
@@ -479,12 +483,44 @@
 {
 	int	ret = 0;
 
+#if 0
 	if(!freq_change_enabled_by_startup)
 		return -1;
 
 	if(old_index == new_index)
 		return ret;
+	ret = clk_set_rate(cpu_clk, zx29_freq_table[new_index].frequency * 1000);
+	if (ret) 
+		pm_printk("[CPUFREQ] Failed to set rate %dkHz: ret = %d\n", zx29_freq_table[new_index].frequency, ret);
+	
+	pm_printk("[CPUFREQ] set cpufreq:old index:%d new index:%d \n", old_index, new_index);
+//	printk("[CPUFREQ] set cpufreq:old index:%d new index:%d current_axi_freq(%d)\n", old_index, new_index,get_cur_axi());
+	debug_cpu_clk_info();
 
+	trace_freq_change(old_index,new_index);
+
+#ifdef CONFIG_AXI_FREQ
+	mutex_lock(&axifreq_lock);
+	set_axi_frequency_by_cpu(zx29_freq_table[new_index].frequency);
+	mutex_unlock(&axifreq_lock);	
+#endif
+
+#endif
+
+	return ret;	
+}
+
+int zx29_set_frequency_new(unsigned int old_index,
+				     unsigned int new_index)
+{
+	int	ret = 0;
+
+	if(!freq_change_enabled_by_startup)
+		return -1;
+/*
+	if(old_index == new_index)
+		return ret;
+*/
 	ret = clk_set_rate(cpu_clk, zx29_freq_table[new_index].frequency * 1000);
 	if (ret) 
 		pm_printk("[CPUFREQ] Failed to set rate %dkHz: ret = %d\n", zx29_freq_table[new_index].frequency, ret);
@@ -515,40 +551,11 @@
 
 int zx_set_frequency(unsigned int  freq)
 {
-	int	ret = 0;
-	unsigned int new_index;
-
-	if(pm_get_mask_info()&PM_NO_CPU_FREQ)
-		return 0;
-
-	
-	mutex_lock(&cpufreq_lock);
-	
 	if(freq==624000000) {
-		new_index =L0; 
-		cpu_dfs_is_not_allowed=1;
-		//cpufreq_level = zx29_get_frequency();
+		return cpufreq_performance();
 	} else{
-		new_index =L1; 
-		cpu_dfs_is_not_allowed=0;
+		return cpufreq_normal();
 	}
-
-	ret = clk_set_rate(cpu_clk, zx29_freq_table[new_index].frequency * 1000);
-	if (ret) 
-		pm_printk("[CPUFREQ] Failed to set rate %dkHz: ret = %d\n", zx29_freq_table[new_index].frequency, ret);
-	
-	pm_printk("[CPUFREQ] zx_set_frequency:new index:%d \n", new_index);
-	debug_cpu_clk_info();
-
-	mutex_unlock(&cpufreq_lock);
-
-#ifdef CONFIG_AXI_FREQ
-	mutex_lock(&axifreq_lock);
-	set_axi_frequency_by_cpu(zx29_freq_table[new_index].frequency);
-	mutex_unlock(&axifreq_lock);	
-#endif	
-		
-	return ret;	
 }
 EXPORT_SYMBOL(zx_set_frequency);
 
@@ -575,7 +582,7 @@
 	info->cpu_clk 			= cpu_clk;
 	info->volt_table 		= zx29_volt_table;
 	info->freq_table 		= zx29_freq_table;
-	info->set_freq 			= zx29_set_frequency;
+	info->set_freq 			= zx29_set_frequency_new;
 
 	cpufreq_driver_inited = 1;
 
diff --git a/ap/os/linux/linux-3.4.x/drivers/soc/zte/rpm/at_io.c b/ap/os/linux/linux-3.4.x/drivers/soc/zte/rpm/at_io.c
index 13f1884..8678a6a 100755
--- a/ap/os/linux/linux-3.4.x/drivers/soc/zte/rpm/at_io.c
+++ b/ap/os/linux/linux-3.4.x/drivers/soc/zte/rpm/at_io.c
@@ -442,7 +442,7 @@
 	}
 	if (chID > CHANNEL_NUM || chID == 0)
 	{
-		printk("err chid=%d cmd=%s!\n",ch_ID, data);
+		//printk("err chid=%d cmd=%s!\n",ch_ID, data);
 		return ATIO_SUCCESS;
 	}
 	//µ±Ç°ÎªATͨµÀµÄÊý¾Ý
diff --git a/ap/os/linux/linux-3.4.x/drivers/soc/zte/tsc/zx-tsc-strategy.c b/ap/os/linux/linux-3.4.x/drivers/soc/zte/tsc/zx-tsc-strategy.c
index 5d74c58..e44578a 100644
--- a/ap/os/linux/linux-3.4.x/drivers/soc/zte/tsc/zx-tsc-strategy.c
+++ b/ap/os/linux/linux-3.4.x/drivers/soc/zte/tsc/zx-tsc-strategy.c
@@ -163,24 +163,24 @@
    else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_5)

    {

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2, BIT_PROBE_ADC1 ,STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC1 ,STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC1 ,STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC1, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC1, STRTEGY_START);//zDrvPow_SetArmPsCoreFreq(CLK312M);	   

    }

    else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_3)

    {   

 	tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC1, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC1, STRTEGY_START);//zDrvPow_SetArmPsCoreFreq(CLK312M);	   

    }

 	else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_1)

 	{	

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC1, STRTEGY_START);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);	  		

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_START);	  		

 	}   

 	else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_0)

    {

@@ -196,10 +196,10 @@
 	   tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADC1,STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT, BIT_PROBE_ADC1, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2, BIT_PROBE_ADC1, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC1, STRTEGY_STOP);	   	   	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC1, STRTEGY_STOP);	   	   	   

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC1, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_STOP);	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC1, STRTEGY_STOP);	   

 	  tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC1, STRTEGY_STOP);// zDrvPow_SetArmPsCoreFreq(CLK624M);

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_2)

@@ -207,7 +207,7 @@
 	   tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADC1,STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT, BIT_PROBE_ADC1, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2 ,BIT_PROBE_ADC1, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 ,BIT_PROBE_ADC1, STRTEGY_STOP);	   	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 ,BIT_PROBE_ADC1, STRTEGY_STOP);	   	   

 	  tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC1, STRTEGY_STOP);// zDrvPow_SetArmPsCoreFreq(CLK624M);

 	}

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_4)

@@ -216,7 +216,7 @@
 	tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADC1,STRTEGY_STOP);

 	tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT,BIT_PROBE_ADC1,STRTEGY_STOP);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2,BIT_PROBE_ADC1,STRTEGY_STOP);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2,BIT_PROBE_ADC1,STRTEGY_STOP);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2,BIT_PROBE_ADC1,STRTEGY_STOP);	   

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_6)

    {

@@ -272,24 +272,24 @@
    else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_5)

    {

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2, BIT_PROBE_ADC2 ,STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC2 ,STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC2 ,STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC2, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC2, STRTEGY_START);//zDrvPow_SetArmPsCoreFreq(CLK312M);	   

    }

    else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_3)

    {   

 	tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC2, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC2, STRTEGY_START);//zDrvPow_SetArmPsCoreFreq(CLK312M);	   

    }

 	else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_1)

 	{	

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC2, STRTEGY_START);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);	  		

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_START);	  		

 	}   

 	else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_0)

    {

@@ -306,10 +306,10 @@
 	  tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADC2,STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT, BIT_PROBE_ADC2, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2, BIT_PROBE_ADC2, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC2, STRTEGY_STOP);	   	   	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADC2, STRTEGY_STOP);	   	   	   

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADC2, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_STOP);	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADC2, STRTEGY_STOP);	   

 	  tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC2, STRTEGY_STOP);// zDrvPow_SetArmPsCoreFreq(CLK624M);

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_2)

@@ -317,7 +317,7 @@
 	   tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADC2,STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT, BIT_PROBE_ADC2, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2 ,BIT_PROBE_ADC2, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 ,BIT_PROBE_ADC2, STRTEGY_STOP);	   	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 ,BIT_PROBE_ADC2, STRTEGY_STOP);	   	   

 	  tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADC2, STRTEGY_STOP);// zDrvPow_SetArmPsCoreFreq(CLK624M);

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_4)

@@ -325,7 +325,7 @@
 	tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADC2,STRTEGY_STOP);

 	tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT,BIT_PROBE_ADC2,STRTEGY_STOP);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2,BIT_PROBE_ADC2,STRTEGY_STOP);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2,BIT_PROBE_ADC2,STRTEGY_STOP);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2,BIT_PROBE_ADC2,STRTEGY_STOP);	   

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_6)

    {

@@ -381,24 +381,24 @@
    else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_5)

    {

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2, BIT_PROBE_ADCRF ,STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADCRF ,STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADCRF ,STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADCRF, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADCRF, STRTEGY_START);//zDrvPow_SetArmPsCoreFreq(CLK312M);	   

    }

    else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_3)

    {   

 	tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADCRF, STRTEGY_START);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);	   

 	tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADCRF, STRTEGY_START);//zDrvPow_SetArmPsCoreFreq(CLK312M);	   

    }

 	else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_1)

 	{	

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADCRF, STRTEGY_START);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);	  		

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_START);	  		

 	}   

 	else if(temperature>=TsNvData.Threshods[probe_num].THROSHOLD_0)

    {

@@ -415,10 +415,10 @@
 	   tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADCRF,STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT, BIT_PROBE_ADCRF, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2, BIT_PROBE_ADCRF, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADCRF, STRTEGY_STOP);	   	   	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2, BIT_PROBE_ADCRF, STRTEGY_STOP);	   	   	   

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_RATE, BIT_PROBE_ADCRF, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_STOP);	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_DOWNRATE2, BIT_PROBE_ADCRF, STRTEGY_STOP);	   

 	  tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADCRF, STRTEGY_STOP);// zDrvPow_SetArmPsCoreFreq(CLK624M);

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_2)

@@ -426,7 +426,7 @@
 	   tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADCRF,STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT, BIT_PROBE_ADCRF, STRTEGY_STOP);

 	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2 ,BIT_PROBE_ADCRF, STRTEGY_STOP);

-	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 ,BIT_PROBE_ADCRF, STRTEGY_STOP);	   	   

+//	   tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 ,BIT_PROBE_ADCRF, STRTEGY_STOP);	   	   

 	  tsctrl_set_strategy2Iram(TSCTRL_DFS, BIT_PROBE_ADCRF, STRTEGY_STOP);// zDrvPow_SetArmPsCoreFreq(CLK624M);

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_4)

@@ -434,7 +434,7 @@
   	tsctrl_set_strategy2Iram(TSCTRL_SHUTDOWN,BIT_PROBE_ADCRF,STRTEGY_STOP); 

 	tsctrl_set_strategy2Iram(TSCTRL_PS_ANYRESIDENT,BIT_PROBE_ADCRF,STRTEGY_STOP);

 	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2,BIT_PROBE_ADCRF,STRTEGY_STOP);

-	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2,BIT_PROBE_ADCRF,STRTEGY_STOP);	   

+//	tsctrl_set_strategy2Iram(TSCTRL_LIMIT_W_UPTRANSIMITPOWER2,BIT_PROBE_ADCRF,STRTEGY_STOP);	   

    }

    else if(temperature<TsNvData.Threshods[probe_num].THROSHOLD_6)

    {

@@ -526,7 +526,6 @@
 

 }

 

-

 /*******************************************************************************

  * Function: tsc_RefStrategyDispatch

  * Description:

@@ -539,6 +538,37 @@
 

  * Others:	//not use

 ********************************************************************************/

+static void tsctrl_print_temp(void)

+{

+		if(g_adc1_flag==1){

+			sc_debug_info_record(MODULE_ID_AP_TSC, "temp1:%d\n", zx_read_reg(TSCTRL_TEMPADC1) );

+			printk( "temp1:%d\n", zx_read_reg(TSCTRL_TEMPADC1));

+		}

+		if(g_adc2_flag==1){

+			sc_debug_info_record(MODULE_ID_AP_TSC, "temp2:%d\n", zx_read_reg(TSCTRL_TEMPADC2) );

+			printk( "temp2:%d\n", zx_read_reg(TSCTRL_TEMPADC2));

+		}

+		if(g_adc3_flag==1){

+			sc_debug_info_record(MODULE_ID_AP_TSC, "tempRf:%d\n", zx_read_reg(TSCTRL_TEMPADCRF) );

+			printk( "tempRf:%d\n", zx_read_reg(TSCTRL_TEMPADCRF));

+		}

+}

+/*******************************************************************************

+ * Function: tsctrl_set_strategy

+ * Description:

+ * Parameters:

+ *   Input: 

+ *			

+

+ *   Output: N/A

+ * Returns: N/A

+

+ * Others:	//not use

+********************************************************************************/

+int cpufreq_performance(void);

+int cpufreq_powersave(void);

+int cpufreq_normal(void);

+

 static void tsctrl_set_strategy(void)

 {

 	u32 i=0;

@@ -562,6 +592,7 @@
 			if(any_resident_flag){

 				tsctrl_callback_dispatch(PS_STRATEGY_ANYRESIDENT,false); /*È¥ÈÎÒâפÁô,Ò²¾ÍÊÇÕý³£×¤Áô*/

 				tsc_set_reg_bits(TSCTRL_PS,BIT_PS_ANYRESIDENT,BITS_FOR_PSIRAM,false);

+				tsctrl_print_temp();

 				sc_debug_info_record(MODULE_ID_AP_TSC, "AnyResident stop\n");

 				tsc_print_log("AnyResident  stop!\n");

 				any_resident_flag=0;

@@ -570,6 +601,7 @@
 			if(!any_resident_flag){

 				tsctrl_callback_dispatch(PS_STRATEGY_ANYRESIDENT,true);/*ÈÎÒâפÁô*/

 				tsc_set_reg_bits(TSCTRL_PS,BIT_PS_ANYRESIDENT,BITS_FOR_PSIRAM,true);

+				tsctrl_print_temp();

 				sc_debug_info_record(MODULE_ID_AP_TSC, "AnyResident start!\n");

 				tsc_print_log("AnyResident  start!\n");

 				any_resident_flag=1;

@@ -610,6 +642,7 @@
 				if(ps_rate_flag!=0){

 					tsctrl_callback_dispatch(PS_STRATEGY_RATE,STRTEGY_STOP);//STOP		

 					tsc_set_reg_bits(TSCTRL_PS,BIT_PS_RATE,BITS_FOR_PSIRAM,STRTEGY_STOP);

+					tsctrl_print_temp();

 					sc_debug_info_record(MODULE_ID_AP_TSC, "ps modem rate limit  stop!\n");

 					tsc_print_log("ps modem rate limit  stop!\n");

 					ps_rate_flag=0;

@@ -620,6 +653,7 @@
 				if(ps_rate_flag!=1){

 					tsctrl_callback_dispatch(PS_STRATEGY_RATE,STRTEGY_START);//START		

 					tsc_set_reg_bits(TSCTRL_PS,BIT_PS_RATE,BITS_FOR_PSIRAM,STRTEGY_START);

+					tsctrl_print_temp();

 					sc_debug_info_record(MODULE_ID_AP_TSC, "ps modem rate limit  start!\n");

 					tsc_print_log("ps modem rate limit  start!\n");

 					ps_rate_flag=1;

@@ -628,6 +662,7 @@
 				if(ps_rate_flag!=2){

 					tsctrl_callback_dispatch(PS_STRATEGY_RATE,STRTEGY_HOLD);//HOLD			

 					tsc_set_reg_bits(TSCTRL_PS,BIT_PS_RATE,BITS_FOR_PSIRAM,STRTEGY_HOLD);

+					tsctrl_print_temp();

 					sc_debug_info_record(MODULE_ID_AP_TSC, "ps modem rate limit  hold!\n");

 					tsc_print_log("ps modem rate limit  hold!\n");

 					ps_rate_flag=2;

@@ -639,6 +674,7 @@
 				if(tsc_read_reg(TSCTRL_LIMIT_LTE_DOWNRATE1+i*0x4)==0){

 					if(g_phy_Strategy[i].flag !=0) {

 						tsc_set_reg_bits(TSCTRL_PHY,(BIT_LIMIT_LTE_DOWNRATE1+i),BITS_FOR_PHYIRAM,STRTEGY_STOP);

+						tsctrl_print_temp();

 						sc_debug_info_record(MODULE_ID_AP_TSC, "%s stop\n", g_phy_Strategy[i].name );

 						tsc_print_log("%s stop\n", g_phy_Strategy[i].name);

 						g_phy_Strategy[i].flag=0;

@@ -647,6 +683,7 @@
 					if(g_phy_Strategy[i].flag!=1) {

 				

 						tsc_set_reg_bits(TSCTRL_PHY,(BIT_LIMIT_LTE_DOWNRATE1+i),BITS_FOR_PHYIRAM,STRTEGY_START);

+						tsctrl_print_temp();

 						sc_debug_info_record(MODULE_ID_AP_TSC, "%s start\n", g_phy_Strategy[i].name );

 						tsc_print_log("%s start\n", g_phy_Strategy[i].name);

 						g_phy_Strategy[i].flag=1;

@@ -662,6 +699,7 @@
 				if(tsc_read_reg(TSCTRL_LIMIT_LTE_DOWNRATE1+i*0x4)==0){

 					if(g_phy_Strategy[i].flag !=0) {

 						tsc_set_reg_bits(TSCTRL_PHY,(BIT_LIMIT_LTE_DOWNRATE1+i),BITS_FOR_PHYIRAM,STRTEGY_STOP);

+						tsctrl_print_temp();

 						sc_debug_info_record(MODULE_ID_AP_TSC, "%s stop\n", g_phy_Strategy[i].name );

 						tsc_print_log("%s stop\n", g_phy_Strategy[i].name);

 						g_phy_Strategy[i].flag=0;						

@@ -669,6 +707,7 @@
 				}else{

 					if(g_phy_Strategy[i].flag !=1) {

 						tsc_set_reg_bits(TSCTRL_PHY,(BIT_LIMIT_LTE_DOWNRATE1+i),BITS_FOR_PHYIRAM,STRTEGY_START);

+						tsctrl_print_temp();

 						sc_debug_info_record(MODULE_ID_AP_TSC, "%s start\n", g_phy_Strategy[i].name );

 						tsc_print_log("%s start\n", g_phy_Strategy[i].name);

 						g_phy_Strategy[i].flag=1;

@@ -687,10 +726,12 @@
 			if(tsc_read_reg(TSCTRL_DFS)==0){

 				if(ps_freq_flag){

 					//tsc_print_log("CPU_FREQ0:zx_getspeed(0)=%d\n",zx_getspeed(0));

-					if(zx_getspeed(0) != 624000 )

-						zx29_set_frequency(1,0); //zDrvPow_SetArmPsCoreFreq(CLK624M);

+//					if(zx_getspeed(0) != 624000 )

+//						zx29_set_frequency(1,0); //zDrvPow_SetArmPsCoreFreq(CLK624M);

+					cpufreq_normal();

 						

 					tsc_set_reg_bits(TSCTRL_PS,BIT_PS_FREQ, BITS_FOR_PSIRAM,STRTEGY_STOP);

+					tsctrl_print_temp();

 					sc_debug_info_record(MODULE_ID_AP_TSC, "ps freq 624M start\n" );

 					tsc_print_log("ps freq 624M start\n");

 					ps_freq_flag=0;

@@ -698,8 +739,10 @@
 			}else{

 				if(!ps_freq_flag){

 					//tsc_print_log("CPU_FREQ1:zx_getspeed(0)=%d\n",zx_getspeed(0));	

-					zx29_set_frequency(0,1); //zDrvPow_SetArmPsCoreFreq(CLK312M);

+					//zx29_set_frequency(0,1); //zDrvPow_SetArmPsCoreFreq(CLK312M);

+					cpufreq_powersave();

 					tsc_set_reg_bits(TSCTRL_PS,BIT_PS_FREQ, BITS_FOR_PSIRAM,STRTEGY_START);					

+					tsctrl_print_temp();

 					sc_debug_info_record(MODULE_ID_AP_TSC, "ps freq 312M start\n" );

 					tsc_print_log("ps freq 312M start\n");

 					ps_freq_flag=1;

diff --git a/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c b/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c
index efe89a3..eed941f 100755
--- a/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c
+++ b/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c
@@ -136,6 +136,7 @@
 unsigned char uart_port_autobaud_gtflag = 0 ;
 unsigned char uart_port_autobaud_suflag = 0 ;
 unsigned char g_console_open_flag = 1;
+int g_uart_overrun = 0;
 
 
 unsigned char  UART_AT_send_ok[UART_AT_SENDOK_NUM] = 
@@ -1448,6 +1449,22 @@
 	struct zx29_sgbuf *sgbuf = zup->curr_sg;
 
 	size_t pending;
+	uint32_t ris_status;
+	ris_status = UART_GET_RIS(&zup->port);		
+	if(ris_status & (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS)){
+		if(ris_status & UART_OEIS){ 			   
+			zup->port.icount.overrun++;
+			g_uart_overrun = 4;
+			test_uart_static(NULL, 0, 20, zup->port.line);	
+		}
+		if(ris_status & UART_BEIS)			 
+			zup->port.icount.brk++; 
+		if(ris_status & UART_PEIS)				  
+			zup->port.icount.parity++;			   
+		if(ris_status & UART_FEIS)			  
+			zup->port.icount.frame++;
+		UART_PUT_ICR(&zup->port, (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS));
+	}
 
 	dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
 	zx29_dma_stop(rx_id);
@@ -2092,6 +2109,8 @@
 		if(ris_status & (UART_OEIS | UART_BEIS | UART_PEIS | UART_FEIS)){
 			if(ris_status & UART_OEIS){ 			   
 				zup->port.icount.overrun++;
+				g_uart_overrun = 1;
+				test_uart_static(NULL, 0, 19,zup->port.line);
 				//if(!uart_console(&zup->port))
 					//BUG_ON(1);
 			}
@@ -2110,9 +2129,17 @@
 		zx29_dma_stop(rx_id);
 		zup->dmarx.running = false;
 		zup->dmarx.used = false;
-		int i;
+
+		tmp_len = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
 		
+		if(tmp_len != pending){
+			pending = tmp_len;
+		}
 		
+		dmarx->use_buf_b = !dmarx->use_buf_b;
+		wmb();
+		if(zup->uart_power_mode){
+			int i;
 		for(i= 0;i < 3;i++){
 			fr = UART_GET_FR(&zup->port);
 			if((fr & UART_FR_RXFE) == 0){
@@ -2129,16 +2156,9 @@
 		}
 
 		//zup->sg2tty = sgbuf;
-		tmp_len = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
 		
-		if(tmp_len != pending){
-			pending = tmp_len;
-		}
 		
-		dmarx->use_buf_b = !dmarx->use_buf_b;
-		wmb();
 		//when app ctrl sleep ,always start dma receive
-		if(zup->uart_power_mode){
 			if(zup->sleep_state == 0){
 				//now start dma again
 				if (zx29_dma_rx_trigger_dma(zup)) {
@@ -2153,7 +2173,7 @@
 				}
 				
 				if(pending || (i > 0)){
-					test_uart_static(zup->port.line, NULL, 0, 13);
+					test_uart_static(NULL, 0, 13,zup->port.line);
 					zx29_uart_deal_dma_fifo_rx_chars(zup, pending, sgbuf, &flags, g_fifo_residue_buf,i);
 				}						
 			}
@@ -2231,11 +2251,12 @@
 	struct uart_port *port = dev_id;
 	struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
 	unsigned long flags;
-	unsigned int status, pass_counter = 256;
+	unsigned int status,ris, pass_counter = 256;
 	int handled = 0;
 
 	raw_spin_lock_irqsave(&zup->port.lock, flags);
 	status = UART_GET_MIS(port) & zup->imr;
+	ris = UART_GET_RIS(port);
 	if (status) {
 		do {
 			UART_PUT_ICR(port,(status & ~(UART_TXIS|UART_RTIS|UART_RXIS)));
@@ -2248,6 +2269,11 @@
 #endif
 				if (status & (UART_RXIS)){
 #if CONFIG_SERIAL_ZX29_DMA
+					if(ris & UART_OEIS){ 			   
+						zup->port.icount.overrun++;
+						g_uart_overrun = 8;
+						test_uart_static(NULL, 0, 21, zup->port.line);	
+					}
 					if (zx29_dma_rx_used(zup)){
 						UART_PUT_ICR(port,UART_RXIS);
 						if(!(zup->imr & UART_RTIM)){
diff --git a/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c b/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c
index 6d887bf..a771aa7 100644
--- a/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c
+++ b/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c
@@ -1043,11 +1043,18 @@
 /*GPIOºÍÍⲿÖжϺŸù¾ÝÏîĿʵ¼ÊÇé¿öÐÞ¸Ä
  *´Ë´¦Îª²Î¿¼´úÂë
  */
+ #ifdef _USE_VEHICLE_DC_REF
+#define USB_GPIO ZX29_GPIO_54
+#define USB_GPIO_FUNC_GPIO GPIO54_GPIO54
+#define USB_GPIO_FUNC_EXT_INT GPIO54_EXT_INT7
+#define USB_DT_INT  PCU_EX7_INT
+ 
+ #else
 #define USB_GPIO ZX29_GPIO_52
 #define USB_GPIO_FUNC_GPIO GPIO52_GPIO52
 #define USB_GPIO_FUNC_EXT_INT GPIO52_EXT_INT5
 #define USB_DT_INT  PCU_EX5_INT
-
+#endif
 int Usb_Detect_Val(void)
 {
     int value;
@@ -1085,10 +1092,33 @@
 	//5.23
 	zx29_gpio_config(USB_GPIO,USB_GPIO_FUNC_GPIO);
 	gpio_direction_input(USB_GPIO);
-	msleep(5);
+	msleep(500);
 	value = gpio_get_value(USB_GPIO);
-	printk("%s,value:%d\n", __func__,value);
+	printk("%s,value:%d, usb_plugin:%d\n", __func__,value, usb_plugin);
 	zx29_gpio_config(USB_GPIO,USB_GPIO_FUNC_EXT_INT);
+
+#ifdef _USE_VEHICLE_DC_REF
+	if(value == 1)
+	{
+	
+	  zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_FALLING);
+	  pcu_int_clear(USB_DT_INT); 
+	  if(usb_plugin == 0){
+	  	dwc_otg_usb_chg_detect(); //plug in;
+	  	usb_plugin = 1;
+	  }	
+	}
+	else
+	{
+	  zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_RISING);
+	  pcu_int_clear(USB_DT_INT);
+	  if(usb_plugin == 1){
+	 	 dwc_otg_disconnect();
+	  	dwc_otg_usb_chg_remove(); //not plug in;
+	  	usb_plugin = 0;
+	  }
+	}
+#else
 	
 	if(value == 1)
 	{
@@ -1109,7 +1139,8 @@
 	  	usb_plugin = 1;
 	  }
 	}
-	printk(KERN_INFO"%s,value:%d,end\n", __func__,value);
+#endif	
+	printk(KERN_INFO"%s,value:%d,usb_plugin:%d, end\n", __func__,value, usb_plugin);
     USBSTACK_DBG("%s,value:%d", __func__,value);
 	return IRQ_HANDLED;
 }
@@ -1127,6 +1158,7 @@
 	int value2 = 0;
 	
 	printk("-----------Usb_Detect_Irq_probe\n");
+
 	dwc_chg_Regcallback(usb_detect_typedet);
 
 	ret = gpio_request(USB_GPIO, "usb");
@@ -1141,7 +1173,20 @@
 	printk(KERN_INFO "%s,value:%d, irq_num:%d\n",__func__,value, usb_detect_irq);
 	
     zx29_gpio_config(USB_GPIO,USB_GPIO_FUNC_EXT_INT);
-#if 1	
+ #ifdef _USE_VEHICLE_DC_REF
+ 	if(value == 1)
+	{
+	  dwc_otg_usb_chg_detect(); //plug in;
+	  usb_plugin = 1;
+	  zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_FALLING);
+	}
+	else
+	{
+	  usb_plugin = 0;
+	  zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_RISING);
+	}
+ #else
+ 
 	if(value == 1)
 	{
 	  usb_plugin = 0;
@@ -1158,7 +1203,7 @@
 	ret = request_threaded_irq(usb_detect_irq, Usb_Detect_Irq_Handler,Usb_Detect_Irq_Thread,IRQF_ONESHOT,
                 "usb", _dev);
 
-	printk(KERN_INFO "%s,ret:%d\n",__func__,ret);
+	printk(KERN_INFO "%s,ret:%d, usb_plugin:%d\n",__func__,ret, usb_plugin);
    	if (ret)
     {   
 	   printk(KERN_INFO"cannot request Usb_Detect_Irq\n");
diff --git a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c
index 4a2e122..a5fa3db 100755
--- a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c
+++ b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c
@@ -3106,12 +3106,16 @@
 			t_resp->cmd = USB_RPMSG_GET_USB_SPEED;
 
 			struct usb_gadget		*gadget = cdev->gadget;
-		    if(NULL == cdev)
-		    {
+			if(NULL == cdev)
+			{
 				printk("android_set_rpmsg_resp, gadget is NULL\n");
 				sprintf(t_resp->param, "%s\n",  "invalid state");
-		        return ;
-		    }			
+			    return ;
+			}
+			
+			if(!_android_dev->enabled)	{
+				gadget->speed = 0;
+			}
 			sprintf(t_resp->param, "%s\n", usb_speed_string(gadget->speed));
 			
 			break;
@@ -3121,10 +3125,10 @@
 			spin_lock_irqsave(&cdev->lock, flags);
 			if (cdev->config)
 				sprintf(t_resp->param, "%s\n", "CONFIGURED"); 
-			else if (_android_dev->connected)
-				sprintf(t_resp->param, "%s\n",  "CONNECTED");
+			else if (!_android_dev->enabled)
+				sprintf(t_resp->param, "%s\n",  "DISCONNECTED");
 			else
-				sprintf(t_resp->param, "%s\n",  "unknown state");
+				sprintf(t_resp->param, "%s\n",  "CONNECTED");
 				
 			spin_unlock_irqrestore(&cdev->lock, flags);			
 			
diff --git a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/u_serial.c b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/u_serial.c
index b2ab988..461af0a 100644
--- a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/u_serial.c
+++ b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/u_serial.c
@@ -509,11 +509,10 @@
 				}while(port->port_usb->suspend_state==1);
          	   spin_lock(&port->port_lock);
             }
+#endif
 		}	
 		//if (port->port_usb&&port->port_usb->suspend_state == 0)
-#else
-		}else
-#endif
+
 #endif
 		{
 #ifdef CONFIG_PM		
diff --git a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c
index 8805fa9..7e53a63 100755
--- a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c
+++ b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c
@@ -26,9 +26,7 @@
 int zDrvNand_WriteBootflag( int flag );

 #endif

 extern int detected_charger(void);

-//xf.li@20230614 add for adb offline start

 int get_usb_enum_mode(void);

-//xf.li@20230614 add for adb offline end

 #ifdef _USE_VEHICLE_DC

 extern int usb_server_init(void);

 

@@ -523,6 +521,7 @@
 {

 	usb_notify_up(USB_RAMDUMP_TRIGGER, NULL);	

 }

+

 ssize_t kobj_usb_show(struct kobject *kobject,struct attribute *attr,char *buf)

 {

 	int dc=0;

@@ -566,9 +565,7 @@
 	  }else if(!strcmp(attr->name, USB_ADB_AGENT)){

 #ifdef _USE_VEHICLE_DC

 			  adb_agent_state = adb_rpmsg_agent_state();

-//xf.li@20230614 add for adb offline start

-	  		  sprintf(buf, "%u, %s\n",adb_agent_state,( (adb_agent_state == 0) ? "AP" : "CAP"));

-//xf.li@20230614 add for adb offline end

+	  		 sprintf(buf, "%u, %s\n",adb_agent_state,( (adb_agent_state == 0) ? "AP" : "CAP"));

 #endif			 

 	  } 	  

 

@@ -579,9 +576,7 @@
 ssize_t kobj_usb_store(struct kobject *kobject,struct attribute *attr, const char *buf,size_t size)

 {

 	unsigned int value = 0;

-//xf.li@20230614 add for adb offline start

 	int cur_usbmode = 0;

-//xf.li@20230614 add for adb offline end

 	

 	value = simple_strtoul(buf, NULL, 10);

 	if(!strcmp(attr->name,CHARGER_PLUG_NAME)){

@@ -619,19 +614,17 @@
 	}else if(!strcmp(attr->name,USB_GPIO_DETECT_ENABLE)){

 		usb_gpio_detect_enable =value;

 	}else if(!strcmp(attr->name,USB_ADB_AGENT)){

-		adb_agent_state =value;

-//xf.li@20230614 add for adb offline start

 #ifdef _USE_VEHICLE_DC

 		cur_usbmode = get_usb_enum_mode();

 		adb_agent_state =value;

 		if(cur_usbmode == 0){

 			adb_enable_rpmsg_agent(adb_agent_state);

+			

 		}else{

 			printk("---none adb, switch is forbidern\n");

 		}

-//xf.li@20230614 add for adb offline end

 #endif

-	}

+	  }	

 	

 	return size;

 }

@@ -966,14 +959,13 @@
 EXPORT_SYMBOL_GPL(usb_dbg_showLog);

 

 #ifdef _USE_VEHICLE_DC

-//xf.li@20230614 add for adb offline start

 int usb_get_adb_agent(void)

 {

 	return adb_agent_state;

 }

-

 EXPORT_SYMBOL_GPL(usb_get_adb_agent);

-//xf.li@20230614 add for adb offline end

+

+

 void usb_set_rpmsg_resp(int type, char*resp)

 {

 

@@ -1001,10 +993,9 @@
 EXPORT_SYMBOL_GPL(usb_set_rpmsg_resp);

 

 void usb_parse_cap_notify(int type)

-{

-//xf.li@20230614 add for adb offline start

+{	

 	int cur_usbmode = 0;

-//xf.li@20230614 add for adb offline end

+	

 	if(type >= USB_RPMSG_NOTIFY_MAX){

 		printk("usb_parse_cap_notify fail, invalid type:%d\n", type);

 		return ;

@@ -1070,8 +1061,7 @@
 			schedule_work(&switch_usbmode);

 			

 			break;

-		

-//xf.li@20230614 add for adb offline start

+

 		case USB_RPMSG_FORCE_RNDIS:

 		case USB_RPMSG_FORCE_ECM:

 			cur_usbmode = get_usb_enum_mode();	

@@ -1083,12 +1073,13 @@
 			printk("cur_usbmode: %s\n", ( (cur_usbmode == 0) ?  "debug": "user"));

 			if(cur_usbmode == 0){

 				switch_mode = USB_SWITCH_DEBUG;

+				

 			}else if( cur_usbmode == 1){

 				switch_mode = USB_SWITCH_USER;

+				

 			}

 			schedule_work(&switch_usbmode);

-			break;	

-//xf.li@20230614 add for adb offline end

+			break;		

 		case USB_RPMSG_OPEN_DL:

 			usb_record_dbginfo(USB_OPEN_DL, 0, 0);

 #ifndef CONFIG_SYSTEM_RECOVERY

diff --git a/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c b/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c
index de12136..ebf9ea2 100644
--- a/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c
+++ b/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c
@@ -16,6 +16,7 @@
 #include <linux/cp_types.h>

 #include "NvParam_drv.h"

 #include "pub_debug_info.h"

+#include <linux/uaccess.h>

 

 #define WDT_DEFAULT 	(30)

 #define WDT_INT_TIME 	(5)

@@ -382,7 +383,8 @@
 	

 	unsigned int ret = 0;

 	unsigned int temp;

-

+	bool flag;

+	

 	struct soft_wdt_file_private *priv = file->private_data;

 

 	switch(cmd)

@@ -393,53 +395,87 @@
 				printk(KERN_ERR"[zx soft wdt]: wrong internal val (val must >= %d)!\n", WDT_SLEEP_TIME);

 				return -ENXIO;

 			}

-			priv->interval = arg;

+			ret = copy_from_user(&temp, (unsigned int*)arg, sizeof(unsigned int));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);	

+

+			priv->interval = temp;

+			//priv->interval = arg;

+			printk("priv->interval :%d\n", priv->interval );

+		

 			break;

 

 		case ZX_WDT_SET_WAKEUP:

-			priv->wakeup = (bool)arg;

+			ret = copy_from_user(&flag, (bool*)arg, sizeof(bool));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);				

+			priv->wakeup = flag;

 			break;

 

 		case ZX_WDT_FEED_DOG:

 			priv->handle_timeout_cnt = 0;

 			priv->handle_timeout = priv->interval + zx_wdt_get_global_cnt();

+			printk("feed priv->handle_timeout :%d\n", priv->handle_timeout );

+			

 			break;

 

 		case ZX_WDT_SET_AP_SWITCH:

-			zx_wdt_enbale((bool)arg);

+			ret = copy_from_user(&flag, (bool*)arg, sizeof(bool));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);					

+			zx_wdt_enbale(flag);

 			break;

 

 		case ZX_WDT_GET_HANDLE_TIMEOUT:

 			temp = priv->handle_timeout;

-			*(unsigned int *)arg = temp;

+			ret = copy_to_user((void *)arg, &temp, sizeof(unsigned int));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);	

+			//*(unsigned int *)arg = temp;			

+			printk("get priv->handle_timeout :%d\n", temp);

+			

 			break;

 

 		case ZX_WDT_GET_GLOBAL_CNT:

 			temp = zx_wdt_get_global_cnt();

-			*(unsigned int *)arg = temp;

+			ret = copy_to_user((void *)arg, &temp, sizeof(unsigned int));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);		

+			printk("priv->global_cnt :%d\n", temp );

+			

 			break;

 

 		case ZX_WDT_GET_AP_TIMEOUT:

 			temp = zx_wdt_get_time_out();

-			*(unsigned int *)arg = temp;

+			ret = copy_to_user((void *)arg, &temp, sizeof(unsigned int));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);				

 			break;

 		case ZX_WDT_SET_NV:		

 #ifdef CONFIG_PREEMPT_RT_FULL

 #ifndef CONFIG_ARCH_ZX297520V3_CAP

-			ret = zx_wdt_set_nv((bool)arg);

+			ret = copy_from_user(&flag, (bool*)arg, sizeof(bool));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);	

+			ret = zx_wdt_set_nv(flag);

 #endif

 #endif

 			break;

 		case ZX_WDT_GET_NV:

 #ifdef CONFIG_PREEMPT_RT_FULL

 #ifndef CONFIG_ARCH_ZX297520V3_CAP

-			temp = zx_wdt_get_wdtnv_for_ctrm();

-			*(bool *)arg = (bool)temp;

+			flag= zx_wdt_get_wdtnv_for_ctrm();

+			ret = copy_to_user((void *)arg, &flag, sizeof(bool));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);	

 #endif

 #endif

 			break;

 		case ZX_WDT_SET_CHECK:

-			priv->is_check = (bool)arg;

+			ret = copy_from_user(&flag, (bool*)arg, sizeof(bool));

+			if(ret)

+				printk("%s: copy user failed\n",__func__);				

+			priv->is_check = flag;

 			break;

 

 		default: