Merge "[Bugfix][T106BUG-294]fix GPIO-function code"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/gpio_T106.conf b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/gpio_T106.conf
index 5133ad0..28dfd24 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/gpio_T106.conf
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/gpio_T106.conf
@@ -1,4 +1,4 @@
platform:T106
total:49
-gpio:16,17,18,20,25,26,27,28,29,30,31,32,35,36,37,38,39,40,41,42,45,46,48,52,53,54,64,72,73,74,75,76,77,84,87,88,89,90,91,92,119,120,121,122,123,124,127,128,129,130,131,132,
+gpio:16,17,18,25,26,27,28,29,30,31,32,35,36,37,38,39,40,41,42,45,46,48,52,53,54,66,67,68,69,70,71,84,87,88,89,90,91,92,119,120,121,122,123,124,127,128,129,130,131,132,
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
index b82cb42..ed8ca40 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
@@ -42,14 +42,14 @@
void lynq_response_ok()
{
- char *str = "OK\n";
+ char *str = "OK\r\n";
handle_output(str, strlen(str), Response);
}
void lynq_response_error(int error_code)
{
char str[32] = {0};
- sprintf(str, "+CME ERROR: %d\n", error_code);
+ sprintf(str, "+CME ERROR: %d\r\n", error_code);
handle_output(str, strlen(str), Response);
}
@@ -92,7 +92,7 @@
fp=popen(lynq_adc_dev, "r");
fgets(lynq_adc_buf,sizeof(lynq_adc_buf),fp);
- sprintf(flag,"%s %s", "ADC:", lynq_adc_buf);
+ sprintf(flag,"%s %s\r\n", "+ADC:", lynq_adc_buf);
if(handle_output != NULL)
{
handle_output(flag, strlen(flag), Response);
@@ -159,7 +159,7 @@
}
else
{
- handle_output("input error\r\n", strlen("input error\r\n"), Response);
+ handle_output("+GPIO:input error\r\n", strlen("input error\r\n"), Response);
return -1;
}
}
@@ -175,13 +175,13 @@
if(k >= total_length)
{
bzero(res,64);
- sprintf(res,"GPIO%d input error\r\n",num);
+ sprintf(res,"+GPIO:GPIO%d input error\r\n",num);
handle_output(res, strlen(res), Response);
}
}
if (lynq_gpio_arr == NULL)
{
- handle_output("input all gpio not exist\r\n", strlen("input all gpio not exist\r\n"), Response);
+ handle_output("+GPIO:input all gpio not exist\r\n", strlen("input all gpio not exist\r\n"), Response);
return -1;
}
return size;
@@ -249,21 +249,8 @@
{
int ret;
int value;
- if(test_gpio_handle[50] != NULL)
- {
- ret = sc_gpio_uninit(test_gpio_handle[50]);
- if(ret)
- {
- ALOGE("uninit 50 fail\n");
- return -1;
- }
- }
- test_gpio_handle[50] = sc_gpio_init(50, 0, 0, 0);
- if(test_gpio_handle[50] == NULL)
- {
- ALOGE("init 50 fail\n");
- return -1;
- }
+
+
for(int m = 0; m < total_length; m++)
{
if(test_gpio_handle[lynq_gpio_arr[m]] != NULL)
@@ -285,6 +272,7 @@
ret = sc_gpio_value_get(test_gpio_handle[50], &value);
if(ret)
{
+ ALOGE("RET = %d, value = %d\n",ret,value);
return -1;
}
if(value != status)
@@ -297,13 +285,17 @@
int all_gpio_uninit(int total_length, int lynq_gpio_total_arr[256])
{
int ret;
- ret = sc_gpio_uninit(test_gpio_handle[50]);
- if(ret)
+ if(test_gpio_handle[50] != NULL)
{
- return -1;
- ALOGE("uninit 50 fail\n");
+ ret = sc_gpio_uninit(test_gpio_handle[50]);
+ if(ret)
+ {
+ ALOGE("uninit 50 fail\n");
+ return -1;
+ }
+ test_gpio_handle[50] = NULL;
}
- test_gpio_handle[50] = NULL;
+
for(int m = 0; m < total_length; m++)
{
ret = sc_gpio_uninit(test_gpio_handle[lynq_gpio_total_arr[m]]);
@@ -338,6 +330,12 @@
ALOGE("Don't have this platform gpio configure\n");
return;
}
+ test_gpio_handle[50] = sc_gpio_init(50, 0, 0, 0);
+ ALOGE("50 youm:%p\n",test_gpio_handle[50]);
+ if(test_gpio_handle[50] == NULL)
+ {
+ ALOGE("uninit 50 fail\n");
+ }
ALOGD("start function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
input = input + strlen("gpio");
if((valid_length = lynq_gpio_analysis(input, lynq_gpio_arr, lynq_gpio_total_arr, total_length)) < 0)
@@ -346,7 +344,7 @@
return;
}
ALOGE("The Valid count:%d\n",valid_length);
- for(i=0; i < sizeof(lynq_gpio_arr)/sizeof(int); i++)
+ for(i=0; i < valid_length; i++)
{
for(j=0;j<3;j++)
{
@@ -357,7 +355,7 @@
if (need_int == 1)
{
- ret = set_all_gpio_status_and_check(lynq_gpio_total_arr, 0, total_length);
+ ret = set_all_gpio_status_and_check(lynq_gpio_arr, 0, valid_length);
if (ret == 1)
{
ALOGE("can't pull up or pull down gpio-50\n");
@@ -374,7 +372,7 @@
lynq_response_error(100);
return;
}
- ALOGD("finsh configure function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
+ ALOGD("finsh configure function\n");
}
lynq_gpio_low = 0;
@@ -382,25 +380,26 @@
for(int n=0;n<3;n++)
{
- ret = sc_gpio_value_set(test_gpio_handle[lynq_gpio_arr[1]], 1);
+ ret = sc_gpio_value_set(test_gpio_handle[lynq_gpio_arr[i]], 1);
+ usleep(10000);
ret = sc_gpio_value_get(test_gpio_handle[50], &value);
if(ret)
{
- ALOGD("sc_gpio_value_get");
+ ALOGE("sc_gpio_value_get\n");
}
if(value == 1)
{
- ALOGD("high function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
+ ALOGE("high function is OK,input %d\n",lynq_gpio_arr[i]);
lynq_gpio_high = 1;
lynq_gpio_test_env_error = 0;
break;
}
else
{
- ALOGD("high function %s line %d input %s num %d\n", __FUNCTION__, __LINE__, input,lynq_gpio_arr[i]);
+ ALOGE("high function is Fail, input %d\n",lynq_gpio_arr[i]);
if(i == 0 && j == 0)
{
- lynq_gpio_test_env_error = set_all_gpio_status_and_check(lynq_gpio_total_arr, 1, total_length) == 0 ? 0 : 1;
+ lynq_gpio_test_env_error = set_all_gpio_status_and_check(lynq_gpio_arr, 1, valid_length) == 0 ? 0 : 1;
}
}
}
@@ -409,8 +408,9 @@
ret = sc_gpio_value_set(test_gpio_handle[lynq_gpio_arr[i]], 0);
if(ret)
{
- ALOGD("sc_gpio_value_set gpio%d fail\n",lynq_gpio_arr[i]);
+ ALOGE("sc_gpio_value_set gpio%d fail\n",lynq_gpio_arr[i]);
}
+ usleep(10000);
ret = sc_gpio_value_get(test_gpio_handle[50], &value);
if(ret)
{
@@ -418,22 +418,22 @@
}
if(value == 0)
{
- ALOGD("*low function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
+ ALOGE("low function is OK,input %d\n",lynq_gpio_arr[i]);
lynq_gpio_low = 1;
}
else
{
- ALOGE("low function fail %s line %d input %s num %d\n", __FUNCTION__, __LINE__, input,lynq_gpio_arr[i]);
+ ALOGE("low function is fail,input %d\n",lynq_gpio_arr[i]);
}
bzero(lynq_show_gpio_state, 64);
if((lynq_gpio_low != 1) || (lynq_gpio_high != 1))
{
- ALOGE("fail function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
+ ALOGE("total fail function,input %d\n",lynq_gpio_arr[i]);
}
else
{
- ALOGD("success function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
- sprintf(lynq_show_gpio_state,"gpio%d\n",lynq_gpio_arr[i]);
+ ALOGE("success function,input:%d\n",lynq_gpio_arr[i]);
+ sprintf(lynq_show_gpio_state,"+GPIO:%d\r\n",lynq_gpio_arr[i]);
handle_output(lynq_show_gpio_state, strlen(lynq_show_gpio_state), Response);
break; // do not retry when pass
}
@@ -446,7 +446,7 @@
if (j >= 3 )
{
lynq_gpio_beta_state = 0;
- sprintf(lynq_show_gpio_state,"[gpio%d][result]:FAIL \n",lynq_gpio_arr[i]);
+ sprintf(lynq_show_gpio_state,"+GPIO:%d FAIL\r\n",lynq_gpio_arr[i]);
handle_output(lynq_show_gpio_state, strlen(lynq_show_gpio_state), Response);
}
} // for(i=0; i < sizeof(lynq_gpio_arr)/sizeof(lynq_gpio_arr[0]); i++)
@@ -454,17 +454,17 @@
if(lynq_gpio_test_env_error == 1)
{
ALOGE("tool error\n");
- handle_output("tool error\n", strlen("tool error\n"), Response);
+ handle_output("+GPIO:tool error\r\n", strlen("+GPIO:tool error\r\n"), Response);
}
if(lynq_gpio_beta_state == 1)
{
- ALOGD("total success function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
+ ALOGD("total success function\n");
lynq_response_ok();
}
else
{
- ALOGE("total fail function %s line %d input %s\n", __FUNCTION__, __LINE__, input);
+ ALOGE("total fail function\n");
lynq_response_error(100);
}
ret = all_gpio_uninit(total_length, lynq_gpio_total_arr);
@@ -546,7 +546,7 @@
}
}
- handle_output("can't receive correct data", strlen("can't receive correct data"), Response);
+ handle_output("+RMII:can't receive correct data\r\n", strlen("+RMII:can't receive correct data\r\n"), Response);
return -1;
}
@@ -558,14 +558,14 @@
sprintf(lynq_set_rgmii_arr,"echo 1,0x03,0x8800,0xc834 > /sys/devices/platform/soc/1307000.gmac/mdio_test");
if(system(lynq_set_rgmii_arr))
{
- handle_output("Please checkout network_line", strlen("Please checkout network_line"), Response);
+ handle_output("+RMII:Please checkout network_line\r\n", strlen("+RMII:Please checkout network_line\r\n"), Response);
return -1;
}
bzero(lynq_set_rgmii_arr, 128);
sprintf(lynq_set_rgmii_arr,"echo 1,0x01,0x0,0xa000 > /sys/devices/platform/soc/1307000.gmac/mdio_test");
if(system(lynq_set_rgmii_arr))
{
- handle_output("Please checkout network_line", strlen("Please checkout network_line"), Response);
+ handle_output("+RMII:Please checkout network_line\r\n", strlen("+RMII:Please checkout network_line\r\n"), Response);
return -1;
}
@@ -627,7 +627,6 @@
int raw_socket = -1;
char buf_init[1024];
char buf_recv[1472];
- char flag[256]={0};
struct sockaddr_in ser_addr;
struct sockaddr_in cli_addr;
struct sockaddr_ll raw_addr;
@@ -653,7 +652,7 @@
socketfd = rgmii_socket_init(&ser_addr,ser_ip);
if(socketfd < 0)
{
- handle_output("init_failed", strlen("init_failed"), Response);
+ ALOGE("init_failed\n");
lynq_response_error(2);
return;
}
@@ -661,7 +660,7 @@
raw_socket = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if(raw_socket < 0)
{
- handle_output("raw_socket init_failed", strlen("raw_socket init_failed"), Response);
+ ALOGE("raw_socket init_failed\n");
lynq_response_error(2);
return;
}
@@ -673,7 +672,7 @@
ret = bind(raw_socket, (struct sockaddr*)&raw_addr, sizeof(raw_addr));//bind network interface card
if(ret < 0)
{
- handle_output("bind raw_socket init_failed", strlen("bind raw_socket init_failed"), Response);
+ ALOGE("bind raw_socket init_failed\n");
lynq_response_error(3);
return;
}
@@ -726,8 +725,7 @@
}
else
{
- sprintf(flag,"sent %d, success %d\n", check_count, check_ok_count);
- handle_output(flag, strlen(flag), Response);
+ ALOGE("sent %d, success %d\r\n", check_count, check_ok_count);
lynq_response_error(100);
}
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
index 29f581a..f8adc55 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
@@ -488,7 +488,7 @@
codec_ti3104: ti3104@18 {
compatible = "ti,tlv320aic3104";
reg = <0x18>;
- reset-gpios = <&bgpio 119 GPIO_ACTIVE_HIGH>;/*RST*/
+ //reset-gpios = <&bgpio 119 GPIO_ACTIVE_HIGH>;/*RST*/
ai3x-micbias-vg = <MICBIAS_2_0V>;
clocks = <&clkc CLKOUT2_CLK>;