Merge "[Feature][T106]version update to T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11"
diff --git a/ap/app/zte_comm/at_ctl/src/atctrl/at_portmng.c b/ap/app/zte_comm/at_ctl/src/atctrl/at_portmng.c
index 6074897..36f368b 100755
--- a/ap/app/zte_comm/at_ctl/src/atctrl/at_portmng.c
+++ b/ap/app/zte_comm/at_ctl/src/atctrl/at_portmng.c
@@ -118,14 +118,21 @@
if(FD_FAR_PS[ilde_idx] >= 0)
{
node = add_new_channel(FD_FAR_PS[ilde_idx],FAR_PS);
- if(0 == at_strncmp(name, "/dev/rpmsg35", strlen(name)) ||
- 0 == at_strncmp(name, "/dev/rpmsg37", strlen(name)) ||
- 0 == at_strncmp(name, "/dev/rpmsg38", strlen(name)) ||
- 0 == at_strncmp(name, "/dev/rpmsg39", strlen(name))) {
- node->attribution |= 1<<CH_AUTOIND;
- }
- //if(node != NULL &&(strstr(name, "/dev/ttyGS0") != NULL || strstr(name, "/dev/ttyGS1") != NULL))
- node->reserved = 0;//×÷ΪԤÁôͨµÀ£¬ÔÚÇëÇóÃüÁîÑ¡Ôñfarpsʱºò£¬»áÑ¡Ôñ·¢ËÍ
+ if(node != NULL) {
+ if(0 == at_strncmp(name, "/dev/rpmsg35", strlen(name)) ||
+ 0 == at_strncmp(name, "/dev/rpmsg37", strlen(name)) ||
+ 0 == at_strncmp(name, "/dev/rpmsg38", strlen(name)) ||
+ 0 == at_strncmp(name, "/dev/rpmsg39", strlen(name))) {
+ node->attribution |= 1<<CH_AUTOIND;
+ }
+ //if(node != NULL &&(strstr(name, "/dev/ttyGS0") != NULL || strstr(name, "/dev/ttyGS1") != NULL))
+ if((0 == at_strncmp(name, "/dev/rpmsg36", strlen(name)) || 0 == at_strncmp(name, "/dev/rpmsg37", strlen(name)))) {
+ node->reserved = 0;
+ }
+ else {
+ node->reserved = 1;
+ }
+ }
memcpy(g_farps_port_info[ilde_idx].name,name,strlen(name));
g_farps_port_info[ilde_idx].fd = FD_FAR_PS[ilde_idx];
g_farps_port_info[ilde_idx].state = 1;
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
index b1d4c23..2b6874b 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
@@ -159,7 +159,7 @@
timeOut.tv_usec = 0;
if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0)
{
- RLOGD("__FUNCTION__ %s time out setting failed %s\n", __FUNCTION__, strerror(errno));
+ RLOGE("__FUNCTION__ %s time out setting failed %s\n", __FUNCTION__, strerror(errno));
/*set uci*/
/*socket abnormal*/
lynq_set_section("sdk_ready", "3");
@@ -193,7 +193,7 @@
RLOGD("send_num %d\n", send_num);
if(send_num == 0)
{
- RLOGD("__FUNCTION__ %s Close to end %s\n", __FUNCTION__, strerror(errno));
+ RLOGE("__FUNCTION__ %s Close to end %s\n", __FUNCTION__, strerror(errno));
//unknow
lynq_set_section("sdk_ready", "4");
pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
@@ -201,7 +201,7 @@
}
if(send_num < 0)
{
- RLOGD("__FUNCTION__ %s sendto error %s\n", __FUNCTION__, strerror(errno));
+ RLOGE("__FUNCTION__ %s sendto error %s\n", __FUNCTION__, strerror(errno));
//unknow
lynq_set_section("sdk_ready", "4");
pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
@@ -213,15 +213,14 @@
RLOGD("recv_num %d\n", recv_num);
if(recv_num == 0)
{
- RLOGD("__FUNCTION__ %s Close to end\n", __FUNCTION__);
+ RLOGE("__FUNCTION__ %s Close to end\n", __FUNCTION__);
//unknow
lynq_set_section("sdk_ready", "4");
pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
- continue;;
+ continue;
}
if(recv_num == -1 && errno == EAGAIN)
{
- RLOGD("__FUNCTION__ %srecvfrom fail because timeout\n", __FUNCTION__);
/*set uci*/
#ifdef MOBILETEK_TARGET_PLATFORM_T800
if(!get_md_sta())
@@ -254,20 +253,24 @@
#ifdef MOBILETEK_TARGET_PLATFORM_T106
if(!t106_check_service("lynq-ril-service"))//not find,must be socket error
{
- //unknow error
+ RLOGE("lynq-ril-service no exist\n");
lynq_set_section("sdk_ready", "4");
}
+ else
+ {
+ RLOGE("__FUNCTION__ %s recvfrom fail because timeout\n", __FUNCTION__);
+ lynq_set_section("sdk_ready", "3");
+ }
#endif
pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
- continue;;
+ continue;
}
if(recv_num < 0)
{
- RLOGD("__FUNCTION__ %srecvfrom fail %s\n", __FUNCTION__, strerror(errno));
- //unknow
+ RLOGE("__FUNCTION__ %s sendto error %s\n", __FUNCTION__, strerror(errno));
lynq_set_section("sdk_ready", "4");
pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
- continue;;
+ continue;
}
Parcel p;
p.setData((uint8_t *)res_data,sizeof(char)*recv_num);
@@ -283,15 +286,17 @@
/*judge the res_error*/
if(!res_error)
{
-
lynq_set_section("sdk_ready", "0");
+ RLOGE("sdk_ready = 0\n");
}
else
{
//Md configurations are inconsistent with AP configurations
+ RLOGE("__FUNCTION__ %s res_error %d\n", __FUNCTION__, res_error);
lynq_set_section("sdk_ready", "2");
+ pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
+ continue;
}
- RLOGD("__FUNCTION__ %s res_error %d\n", __FUNCTION__, res_error);
/*judge the res_error*/
pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);
sleep(TIMER);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
index 73f176e..776cace 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
@@ -398,7 +398,7 @@
int qser_Gnss_download_tle()
{
- int ret;
+ int ret = -1;
if(!inited)
{
ALOGE("has not been initiated\n");
@@ -408,12 +408,14 @@
ret = hd_gnss_download_tle(login_information_t->host, login_information_t->id, login_information_t->password);
if(ret < 0)
{
+ ALOGE("download fail,ret = %d\n",ret);
return -1;
}
#elif defined(HX_GNSS)
ret = mopen_gnss_download_tle();
if(ret < 0)
{
+ ALOGE("download fail,ret = %d\n",ret);
return -1;
}
#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index caf1a36..084dbae 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -1583,16 +1583,17 @@
int hd_gnss_download_tle(char *host, char *id, char *password)
{
//id and pw are currently not being used for future access to self built servers
+ int ret;
const char default_host[] = "http://uagnss.allystar.com/ephemeris/HD_GPS.hdb?compid=yikecs1&token=Z38w5urAuawubTxi";
if(host == NULL)
{
- hd_gnss_http_requst(default_host);
+ ret = hd_gnss_http_requst(default_host);
}
else
{
- hd_gnss_http_requst(host);
+ ret = hd_gnss_http_requst(host);
}
- return 0;
+ return ret;
}
/**
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
index 60629b6..b29437a 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
@@ -124,6 +124,7 @@
bool queued;
atomic_t count;
};
+#define UART_DEBUG_RECORDER_BYTE 0
#define UART_DMA_CYCLE_RX_CONFIG_COUNT 5
struct zx29_dma_cycle_data{
int id;
@@ -140,8 +141,13 @@
int cnt_th;
struct zx29_sgbuf sgbuf[UART_DMA_CYCLE_RX_CONFIG_COUNT];
dma_channel_def rxdef[UART_DMA_CYCLE_RX_CONFIG_COUNT];
+ bool enter_throttle;
+ bool from_unthrottle;
+ bool used;
+ unsigned int cnt_throttle;
+ unsigned int cnt_unthrottle;
};
-struct zx29_dma_cycle_data uart_dma_cycle[5];
+struct zx29_dma_cycle_data uart_dma_cycle[6];
#endif
@@ -279,27 +285,29 @@
unsigned int ris;
}uart_static;
#define STATIC_UART_ID 0
-uart_static g_uart_static[256] = {0};
-int g_uart_static_cnt = 0;
-void test_uart_static(int uart_id, char *buf, int cnt, int steps)
+#define UART_STATIC_COUNT 512
+#define UART_STATIC_NUM 4
+uart_static g_uart_static[UART_STATIC_NUM][UART_STATIC_COUNT] = {0};
+int g_uart_static_cnt[UART_STATIC_NUM] = {0};
+void test_uart_static(int uart_id, char *buf, unsigned int cnt, int steps)
{
- if(uart_id != STATIC_UART_ID)
- return;
+ //if(uart_id != STATIC_UART_ID)
+ // return;
if(buf){
if(cnt >= 16){
- strncpy(g_uart_static[g_uart_static_cnt].head, buf, 16);
+ memcpy(g_uart_static[uart_id][g_uart_static_cnt[uart_id]].head, buf, 16);
}else{
- memcpy(g_uart_static[g_uart_static_cnt].head, buf, cnt);
+ memcpy(g_uart_static[uart_id][g_uart_static_cnt[uart_id]].head, buf, cnt);
}
}
- g_uart_static[g_uart_static_cnt].cnt = cnt;
- g_uart_static[g_uart_static_cnt].s_time = local_clock();
- g_uart_static[g_uart_static_cnt].func_step = steps;
- g_uart_static[g_uart_static_cnt].fr = UART_GET_FR(&zx29_uart_ports[uart_id].port);
- g_uart_static[g_uart_static_cnt].ris = UART_GET_RIS(&zx29_uart_ports[uart_id].port);
+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].cnt = cnt;
+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].s_time = local_clock();
+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].func_step = steps;
+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].fr = UART_GET_FR(&zx29_uart_ports[uart_id].port);
+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].ris = UART_GET_RIS(&zx29_uart_ports[uart_id].port);
- if(++g_uart_static_cnt >= 256)
- g_uart_static_cnt = 0;
+ if(++g_uart_static_cnt[uart_id] >= UART_STATIC_COUNT)
+ g_uart_static_cnt[uart_id] = 0;
}
@@ -975,6 +983,19 @@
}
#if CONFIG_SERIAL_ZX29_DMA
+#if UART_DEBUG_RECORDER_BYTE
+#define UART_DRIVER_DEBUG_COUNT (4*1024*1024)
+u32 cnt_uart_driver_debug = 0;
+u8 uart_driver_debug[UART_DRIVER_DEBUG_COUNT]={};
+void uart_debug(char *debug_buf, u32 count){
+ if(cnt_uart_driver_debug > (UART_DRIVER_DEBUG_COUNT-1)){
+ cnt_uart_driver_debug = 0;
+ }else{
+ memcpy(uart_driver_debug+cnt_uart_driver_debug,debug_buf,count);
+ cnt_uart_driver_debug = cnt_uart_driver_debug+count;
+ }
+}
+#endif
int dma_complete_thread_use_dma_cyclic(void *ptr)
{
unsigned long flags;
@@ -986,8 +1007,14 @@
int uart_id = zup->port.line;
while(down_interruptible(&zup->sema_cyclic) == 0)
{
+ if(uart_dma_cycle[zup->port.line].cnt_callback > 0)
+ uart_id = zup->port.line;
+ else if(uart_dma_cycle[zup->port.line+3].cnt_callback > 0)
+ uart_id = zup->port.line + 3;
+
if(zup->port_close || !uart_dma_cycle[uart_id].sgbuf[uart_dma_cycle[uart_id].flg_enter_th].dma_addr)
break;
+
spin_lock_irqsave(&zup->port.lock, flags);
uart_dma_cycle[uart_id].cnt_th_total++;
uart_dma_cycle[uart_id].cnt_th++;
@@ -1005,6 +1032,10 @@
spin_unlock_irqrestore(&zup->port.lock, flags);
dma_count = tty_insert_flip_string(&zup->port.state->port,
zup->sg2tty->buf, pending);
+ test_uart_static(zup->port.line, zup->sg2tty->buf, uart_dma_cycle[zup->port.line].used, 27);
+#if UART_DEBUG_RECORDER_BYTE
+ uart_debug(zup->sg2tty->buf, pending);
+#endif
tty_flip_buffer_push(&zup->port.state->port);
spin_lock_irqsave(&zup->port.lock, flags);
dma_sync_sg_for_device(dev, &zup->sg2tty->sg, 1, DMA_FROM_DEVICE);
@@ -1591,6 +1622,10 @@
printk("[%s][%d]\n",__func__,__LINE__);
return -EIO;
}
+
+ if(uart_dma_cycle[zup->port.line].used)
+ uart_id = uart_id + 3;
+
dmaengine_slave_config(rxchan, (struct dma_slave_config*)&uart_dma_cycle[uart_id].rxdef);
desc = rxchan->device->device_prep_dma_cyclic(rxchan,NULL,(ZX29_DMA_BUFFER_SIZE *5) , ZX29_DMA_BUFFER_SIZE,0,0);
if (!desc) {
@@ -1607,6 +1642,14 @@
zup->dmacr |= UART_RXDMAE;
UART_PUT_DMACR(&zup->port, zup->dmacr);
uart_dma_cycle[uart_id].flg_enter_th = 0;
+ if(uart_dma_cycle[zup->port.line].used){
+ uart_dma_cycle[zup->port.line].used = false;
+ uart_dma_cycle[zup->port.line+3].used = true;
+ }else{
+ uart_dma_cycle[zup->port.line].used = true;
+ uart_dma_cycle[zup->port.line+3].used = false;
+ }
+
zup->dmarx.running = true;
zup->dmarx.used = true;
zup->imr &= ~(UART_RXIM | UART_RTIM);
@@ -1692,6 +1735,8 @@
unsigned int ris_status;
int uart_id = zup->port.line;
spin_lock_irqsave(&zup->port.lock, flags);
+ if(!uart_dma_cycle[zup->port.line].used)
+ uart_id = uart_id + 3;
uart_dma_cycle[uart_id].cnt_callback_total++;
uart_dma_cycle[uart_id].cnt_callback++;
ris_status = UART_GET_RIS(&zup->port);
@@ -2050,6 +2095,9 @@
dma_count = tty_insert_flip_string(&zup->port.state->port,
sgbuf->buf, pending);
test_uart_static(zup->port.line, sgbuf->buf, pending, 6);
+#if UART_DEBUG_RECORDER_BYTE
+ uart_debug(sgbuf->buf, pending);
+#endif
spin_lock_irqsave(&zup->port.lock, *flags);
dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
zup->port.icount.rx += dma_count;
@@ -2061,6 +2109,10 @@
spin_unlock_irqrestore(&zup->port.lock, *flags);
fifo_count = tty_insert_flip_string(&zup->port.state->port,
fifo_buf, fifo_len);
+ test_uart_static(zup->port.line, fifo_buf, fifo_len, 50);
+#if UART_DEBUG_RECORDER_BYTE
+ uart_debug(fifo_buf, fifo_len);
+#endif
fifo_buf[0] = '\0';
fifo_buf[1] = '\0';
fifo_buf[2] = '\0';
@@ -2070,6 +2122,7 @@
if(((pending) && (pending != 4096)) || (fifo_len > 0)){
spin_unlock(&zup->port.lock);
tty_flip_buffer_push(&zup->port.state->port);
+ test_uart_static(zup->port.line, NULL, (fifo_count+dma_count), 51);
spin_lock(&zup->port.lock);
}
}
@@ -2647,40 +2700,53 @@
unsigned long flags;
struct zx29_sgbuf *sgbuf = NULL;
int uart_id = zup->port.line;
+
+
if(!zx29_dma_rx_running(zup))
return HRTIMER_NORESTART;
- if(uart_dma_cycle[uart_id].cnt_callback > 0){
+ raw_spin_lock_irqsave(&zup->port.lock, flags);
+
+ if((uart_dma_cycle[zup->port.line].cnt_callback > 0) || (uart_dma_cycle[zup->port.line+3].cnt_callback > 0)){
+ test_uart_static(zup->port.line, NULL, uart_dma_cycle[zup->port.line].used, 46);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
return HRTIMER_NORESTART;
}
- spin_lock_irqsave(&zup->port.lock, flags);
+ if(!uart_dma_cycle[zup->port.line].used)
+ uart_id = uart_id + 3;
+
sgbuf = &uart_dma_cycle[uart_id].sgbuf[uart_dma_cycle[uart_id].flg_enter_th];
if(zup->port_close || (sgbuf == NULL)){
- spin_unlock_irqrestore(&zup->port.lock, flags);
- return HRTIMER_RESTART;
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
+ return HRTIMER_NORESTART;
}
if(zup->sema_cyclic.count > 0){
printk("uart has th not deal.\n");
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ //test_uart_static(zup->port.line, NULL, uart_id, 11);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
+ hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
return HRTIMER_RESTART;
}
+
if((zup->sg2tty)){//dma not complete now, later check again
printk("dmath_cyclic not end.\n");
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
test_uart_static(zup->port.line, NULL, 0, 14);
hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
return HRTIMER_RESTART;
}
- if(zup->enter_suspend){
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ if(zup->enter_suspend || uart_dma_cycle[uart_id].enter_throttle){
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
test_uart_static(zup->port.line, NULL, 0, 15);
hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
return HRTIMER_RESTART;
}
dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
pending = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
- if(((pending == zup->pre_pending) && pending) || uart_dma_cycle[uart_id].from_resume){
+ if(((pending == zup->pre_pending) && pending) || uart_dma_cycle[uart_id].from_resume
+ || uart_dma_cycle[uart_id].from_unthrottle){
uart_dma_cycle[uart_id].from_resume = 0;
+ uart_dma_cycle[uart_id].from_unthrottle = false;
#if 0
if(uart_dma_cycle[uart_id].flg_enter_th == 0)
uart_dma_cycle[uart_id].flg_enter_to = 4;
@@ -2723,24 +2789,28 @@
zup->dmacr &= ~UART_RXDMAE;
UART_PUT_DMACR(&zup->port,zup->dmacr);
dmaengine_terminate_all(rxchan);
- test_uart_static(zup->port.line, NULL, 0, 60);
zup->dmarx.running = false;
zup->dmarx.used = false;
+ tmp_len = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
+ if(tmp_len != pending){
+ pending = tmp_len;
+ //test_uart_static(zup->port.line, NULL, tmp_len, 48);
+ }
wmb();
int i = 0;
for(i= 0;i < 3;i++){
fr = UART_GET_FR(&zup->port);
if((fr & UART_FR_RXFE) == 0){
- g_fifo_residue_buf[uart_id][i] = UART_GET_CHAR(&zup->port) | UART_DUMMY_DR_RX;
- g_fifo_residue_all[uart_id][g_fifo_cnt[uart_id]++] = g_fifo_residue_buf[uart_id][i];
- if(g_fifo_cnt[uart_id] >= 20) g_fifo_cnt[uart_id] = 0;
+ g_fifo_residue_buf[zup->port.line][i] = UART_GET_CHAR(&zup->port) | UART_DUMMY_DR_RX;
+ g_fifo_residue_all[zup->port.line][g_fifo_cnt[zup->port.line]++] = g_fifo_residue_buf[zup->port.line][i];
+ if(g_fifo_cnt[zup->port.line] >= 20) g_fifo_cnt[zup->port.line] = 0;
}
else
break;
}
if(i){
- g_fifo_residue_all[uart_id][g_fifo_cnt[uart_id]++]=i;
- if(g_fifo_cnt[uart_id] >= 20) g_fifo_cnt[uart_id] = 0;
+ g_fifo_residue_all[zup->port.line][g_fifo_cnt[zup->port.line]++]=i;
+ if(g_fifo_cnt[zup->port.line] >= 20) g_fifo_cnt[zup->port.line] = 0;
}
if (zx29_dma_rx_trigger_dma_use_dma_cyclic(zup)) {
printk("rx_dma_chars RXDMA start fail\n");
@@ -2748,20 +2818,21 @@
UART_PUT_IMSC(&zup->port,zup->imr);
}else{
hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
+ test_uart_static(zup->port.line, NULL, (pending+i), 49);
zup->pre_pending = 0;
zup->dmarx.used = true;
zup->work_state = true;
}
if((pending && (pending != 4096)) || (i > 0)){
- zx29_uart_deal_dma_fifo_rx_chars_cyclic(zup, pending, sgbuf, &flags, g_fifo_residue_buf[uart_id],i);
+ zx29_uart_deal_dma_fifo_rx_chars_cyclic(zup, pending, sgbuf, &flags, g_fifo_residue_buf[zup->port.line],i);
}
uart_dma_cycle[uart_id].cnt_th = 0;
uart_dma_cycle[uart_id].cnt_callback=0;
deal_end:
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
return HRTIMER_RESTART;
}else{
- spin_unlock_irqrestore(&zup->port.lock, flags);
+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
zup->pre_pending = pending;
hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
test_uart_static(zup->port.line, NULL, zup->pre_pending, 22);
@@ -3005,14 +3076,34 @@
}
return -1;
}
+
+ ret = zx29_sgbuf_init(zup->dmarx.chan, &uart_dma_cycle[uart_id+3].sgbuf[i],DMA_FROM_DEVICE);
+ if(ret){
+ printk( "init uart_dma_cycle sgbuf failed,uart: %d,ret:%d\n", (zup->port.line+3), ret);
+ for(j=0;j<i;j++){
+ zx29_sgbuf_free(zup->dmarx.chan, &uart_dma_cycle[uart_id+3].sgbuf[j],DMA_FROM_DEVICE);
+ }
+ return -1;
+ }
}
for(i=0;i<UART_DMA_CYCLE_RX_CONFIG_COUNT;i++){
- if(zup->port.line == UART0)
+ if(zup->port.line == UART0){
uart_dma_cycle[uart_id].rxdef[i].src_addr = ZX_UART0_BASE+zx29_UART_DR;
- else if(zup->port.line == UART1)
+ uart_dma_cycle[uart_id].used = false;
+ uart_dma_cycle[uart_id+3].rxdef[i].src_addr = ZX_UART0_BASE+zx29_UART_DR;
+ uart_dma_cycle[uart_id+3].used = false;
+ }
+ else if(zup->port.line == UART1){
uart_dma_cycle[uart_id].rxdef[i].src_addr = ZX_UART1_BASE+zx29_UART_DR;
- else{
+ uart_dma_cycle[uart_id].used = false;
+ uart_dma_cycle[uart_id+3].rxdef[i].src_addr = ZX_UART1_BASE+zx29_UART_DR;
+ uart_dma_cycle[uart_id+3].used = false;
+ }
+ else if(zup->port.line == UART2){
uart_dma_cycle[uart_id].rxdef[i].src_addr = ZX_UART2_BASE+zx29_UART_DR;
+ uart_dma_cycle[uart_id].used = false;
+ uart_dma_cycle[uart_id+3].rxdef[i].src_addr = ZX_UART2_BASE+zx29_UART_DR;
+ uart_dma_cycle[uart_id+3].used = false;
}
uart_dma_cycle[uart_id].rxdef[i].dest_addr = (unsigned int)(uart_dma_cycle[uart_id].sgbuf[i].dma_addr);
uart_dma_cycle[uart_id].rxdef[i].dma_control.tran_mode = TRAN_PERI_TO_MEM;
@@ -3022,7 +3113,18 @@
uart_dma_cycle[uart_id].rxdef[i].dma_control.dest_burst_size = DMA_BURST_SIZE_8BIT;
uart_dma_cycle[uart_id].rxdef[i].dma_control.dest_burst_len = DMA_BURST_LEN_4;
uart_dma_cycle[uart_id].rxdef[i].dma_control.irq_mode = DMA_ALL_IRQ_ENABLE;
- uart_dma_cycle[uart_id].rxdef[i].link_addr = 1;
+ uart_dma_cycle[uart_id].rxdef[i].link_addr = 1;
+
+ uart_dma_cycle[uart_id+3].rxdef[i].dest_addr = (unsigned int)(uart_dma_cycle[uart_id+3].sgbuf[i].dma_addr);
+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.tran_mode = TRAN_PERI_TO_MEM;
+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.src_burst_len = DMA_BURST_LEN_4;
+ uart_dma_cycle[uart_id+3].rxdef[i].count = ZX29_DMA_BUFFER_SIZE;
+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.src_burst_size = DMA_BURST_SIZE_8BIT;
+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.dest_burst_size = DMA_BURST_SIZE_8BIT;
+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.dest_burst_len = DMA_BURST_LEN_4;
+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.irq_mode = DMA_ALL_IRQ_ENABLE;
+ uart_dma_cycle[uart_id+3].rxdef[i].link_addr = 1;
+
}
return 0;
}
@@ -3032,8 +3134,10 @@
int uart_id = zup->port.line;
for(i=0;i<UART_DMA_CYCLE_RX_CONFIG_COUNT;i++){
zx29_sgbuf_free(zup->dmarx.chan, &uart_dma_cycle[uart_id].sgbuf[i],DMA_FROM_DEVICE);
+ zx29_sgbuf_free(zup->dmarx.chan, &uart_dma_cycle[uart_id+3].sgbuf[i],DMA_FROM_DEVICE);
}
memset(uart_dma_cycle[uart_id].rxdef, 0, sizeof(uart_dma_cycle[uart_id].rxdef));
+ memset(uart_dma_cycle[uart_id+3].rxdef, 0, sizeof(uart_dma_cycle[uart_id+3].rxdef));
}
static void uart_dma_startup(struct zx29_uart_port *zup)
{
@@ -3461,6 +3565,9 @@
//struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
#if CONFIG_SERIAL_ZX29_DMA
zup->port_close = true;
+ if(zup->uart_power_mode)
+ up(&zup->sema_cyclic);
+ else
up(&zup->sema);
#endif
int ret;
@@ -3762,11 +3869,25 @@
UART_PUT_CHAR(port, ch);
}
#endif /* CONFIG_CONSOLE_POLL */
+extern int tty_buffer_space_avail(struct tty_port *port);
static void zx29_uart_throttle_rx(struct uart_port *port)
{
+ test_uart_static(port->line, NULL, 0, 80);
unsigned long flags;
+ int uart_id = port->line;
+
struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
+ spin_lock_irqsave(&port->lock, flags);
+ if(!uart_dma_cycle[port->line].used)
+ uart_id = uart_id + 3;
+ if(!tty_buffer_space_avail(&port->state->port)){
+ zx29_dma_stop(DMA_CH_UART0_RX);
+ uart_dma_cycle[uart_id].enter_throttle = true;
+ uart_dma_cycle[uart_id].cnt_throttle++;
+ }
+ spin_unlock_irqrestore(&port->lock, flags);
+ #if 0
while(zx29_dma_get_transfer_num(rx_id) != 4096)
msleep(1);
spin_lock_irqsave(&port->lock, flags);
@@ -3775,24 +3896,35 @@
zx29_dma_stop(rx_id);
zup->dmarx.running = false;
zup->dmarx.used = false;
+ uart_dma_cycle[port->line].enter_throttle = true;
spin_unlock_irqrestore(&port->lock, flags);
+ #endif
}
static void zx29_uart_unthrottle_rx(struct uart_port *port)
{
+ test_uart_static(port->line, NULL, 0, 81);
struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
unsigned long flags;
+ int uart_id = port->line;
spin_lock_irqsave(&port->lock, flags);
- if (zx29_dma_rx_trigger_dma(zup)) {
+ if(!uart_dma_cycle[port->line].used)
+ uart_id = uart_id + 3;
+ uart_dma_cycle[uart_id].enter_throttle = false;
+ uart_dma_cycle[uart_id].from_unthrottle = true;
+ uart_dma_cycle[uart_id].cnt_unthrottle++;
+ #if 0
+ if (zx29_dma_rx_trigger_dma_use_dma_cyclic(zup)) {
printk("rx_dma_chars RXDMA start fail\n");
zup->imr |= (UART_RTIM|UART_RXIM);
UART_PUT_IMSC(&zup->port,zup->imr);
}else{
- uart_mod_timer(zup, &flags);
+ hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
zup->pre_pending = 0;
zup->dmarx.used = true;
zup->work_state = true;
UART_PUT_ICR(&zup->port,(UART_RTIS|UART_RXIS));
}
+ #endif
spin_unlock_irqrestore(&port->lock, flags);
}
@@ -3839,9 +3971,7 @@
unsigned int offset=(unsigned int)(pdev->id);
struct device_node *np = pdev->dev.of_node;
unsigned int baud, ibrd, fbrd;
- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 start*/
- unsigned int max_bus_clk;
- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 end*/
+
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
//struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -3865,12 +3995,6 @@
printk("failed to get zx29_port->wclk: %d\n", ret);
return ret;
}
- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 start*/
- if(0 == pdev->id || 2 == pdev->id){
- device_property_read_u32(&pdev->dev, "uart-max-bus-freq", &max_bus_clk);
- clk_set_rate(zx29_port->wclk, max_bus_clk);
- }
- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 end*/
if(offset == 0){
clk_set_rate(zx29_port->wclk, 104 * 1000000);
}
@@ -3900,11 +4024,6 @@
//here is temple def
if(port->uartclk == 0){
printk("---zx29_init_ports, uartclk hard set to 26M\n");
- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 start*/
- if(0 == pdev->id || 2 == pdev->id)
- port->uartclk = 104000000;
- else
- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 end*/
port->uartclk = 26000000;
}
printk("---zx29_init_ports, line:%d, irq:%d, membase:%08x, uartclk:%d\n", port->line, port->irq, port->membase, port->uartclk);
@@ -4196,6 +4315,8 @@
if (!zup)
return -EINVAL;
int uart_id = zup->port.line;
+ if(!uart_dma_cycle[zup->port.line].used)
+ uart_id = uart_id + 3;
if(zup->port.line == UART1)
return 0;
#if 1