T108: add gpio factory AT test
Change-Id: Ief06dc240ee8f0fdb77c88403ba69a8d40914de0
diff --git a/mbtk/mbtk_lib/src/mbtk_gpio.c b/mbtk/mbtk_lib/src/mbtk_gpio.c
index de143ba..80cff21 100755
--- a/mbtk/mbtk_lib/src/mbtk_gpio.c
+++ b/mbtk/mbtk_lib/src/mbtk_gpio.c
@@ -36,7 +36,7 @@
static int gpio_debug = 0;
-#if defined(MBTK_PROJECT_L508_X6)
+#if (defined(MBTK_PROJECT_L508_X6) || defined(MBTK_PROJECT_T108))
struct gpio_register_function gpio_func_register[128] = {
{GPIO_FUNC_GPIO_00, 0},
{GPIO_FUNC_GPIO_01, 0},
@@ -74,13 +74,13 @@
{GPIO_FUNC_GPIO_33, 0},
{GPIO_FUNC_GPIO_34, 0},
{GPIO_FUNC_GPIO_35, 0},
- {GPIO_FUNC_GPIO_36, 0},
- {GPIO_FUNC_MMC1_DAT3, 5}, // GPIO_37
- {GPIO_FUNC_MMC1_DAT2, 5}, // GPIO_38
- {GPIO_FUNC_MMC1_DAT1, 5}, // GPIO_39
- {GPIO_FUNC_MMC1_DAT0, 5}, // GPIO_40
- {GPIO_FUNC_MMC1_CMD, 5}, //GPIO_41
- {GPIO_FUNC_MMC1_CLK, 5}, //GPIO_42
+ {GPIO_FUNC_GPIO_36, 0},
+ {GPIO_FUNC_GPIO_37, 0}, // GPIO_37
+ {GPIO_FUNC_GPIO_38, 0}, // GPIO_38
+ {GPIO_FUNC_GPIO_39, 0}, // GPIO_39
+ {GPIO_FUNC_GPIO_40, 0}, // GPIO_40
+ {GPIO_FUNC_GPIO_41, 0}, //GPIO_41
+ {GPIO_FUNC_GPIO_42, 0}, //GPIO_42
{GPIO_FUNC_GPIO_43, 0}, //GPIO_43
{GPIO_FUNC_GPIO_44,0}, //GPIO_44
{GPIO_FUNC_GPIO_45,0}, //GPIO_45
@@ -1426,6 +1426,172 @@
return n;
}
+#elif defined(MBTK_PROJECT_T108)
+int gpio_register_test_out(int port, int value)
+{
+ int ret;
+ int i;
+ int valueh = 0;
+ int valuel = 1;
+
+ //printf("Gpio port [%d] test start!\n", port);
+ ret = gpio_register_set_func_0(port); //设功能为GPIO
+ if(ret){
+ printf("gpio_port can't support!\n");
+ return -1;
+ }
+ gpio_register_set_direction(port, 1); //设方向为输出
+ //ret = gpio_register_get_value(port);
+ //printf("gpio default value is: %d\n", ret);
+
+
+ //[High]
+ for(i = 0; i <= 9; i++){
+ gpio_register_set_value(port, 1);
+ usleep(50);
+ //valueh = gpio_register_get_value(port);
+ //printf("set high? %d\n", valueh);
+ if(1 == valueh){
+ break;
+ }
+ }
+
+ for(i = 0; i <= 35; i++){
+ ret = gpio_register_get_value(118);
+ if(1 == ret){
+ break;
+ }
+ usleep(3000);
+ }
+ printf("******gpio should is high: %d.******\n", ret);
+ if(1 != ret){
+ ret=-1;
+ goto exit;
+ }
+
+ //[Low]
+ usleep(200);
+ for(i = 0; i <= 9; i++){
+ gpio_register_set_value(port, 0); //输出低
+ usleep(50);
+ //valuel = gpio_register_get_value(port);
+ //printf("set low? %d\n", valuel);
+ if(0 == valuel){
+ break;
+ }
+ }
+
+ for(i = 0; i <= 35; i++){
+ ret = gpio_register_get_value(118);
+ if(0 == ret){
+ break;
+ }
+ usleep(3000);
+ }
+ //printf("******gpio should is low: %d.******\n", ret);
+ if(0 != ret){
+ ret=-1;
+ goto exit;
+ }
+
+exit:
+ gpio_register_set_value(port, 0);
+ gpio_register_set_direction(port, 0); //设方向为输入
+ return ret;
+}
+
+int gpio_test_init_test_gpio_mode(void)
+{
+ int test_gpio[] = {
+ 99,
+ 117,
+ 21,22,23,24,44,41,120,
+ 8,127,46,59,58,57,56,55,48,19,34,33,35,36,49,
+ 50,25,28,26,122,20,10,11,
+ 39,40,37,38,
+ 51,52,31,32,
+ };
+
+ int i, j, ret, total, n = 0;
+ total = (sizeof(test_gpio)/sizeof(int));
+ printf("[init]gpio_test_init_test_gpio_mode BEGIN\n");
+
+ /* [1 all gpio set to low] */
+ //system("echo 118 > /sys/class/gpio/unexport");
+ //system("echo 118 > /sys/class/gpio/export");
+ gpio_register_set_func_0(118);
+ gpio_register_set_direction(118, 0);
+ system("echo in > /sys/class/gpio/gpio118/direction");
+
+ for(j = 0; j < 6 ; j++){
+ for(i = 0; i < total; i++){
+ gpio_register_set_func_0(test_gpio[i]);
+ gpio_register_set_direction(test_gpio[i], 1);
+ gpio_register_set_value(test_gpio[i], 0);
+ //ret = gpio_register_get_value(test_gpio[i]);
+ //printf("[init]get gpio%d=%d\n", test_gpio[i], ret);
+ }
+ //system("hwacc w 0xd401e1ac 0x1040"); //52
+
+ for(i = 0; i <= 35; i++){
+ ret = gpio_register_get_value(118);
+ printf("[init]get gpi118=%d\n", ret);
+ usleep(3000);
+ if(0 == (ret)){
+ break;
+ }
+ }
+
+ printf("pre set ADC: %d, times: %d\n",(ret), j);
+ if(0 == (ret)){
+ break;
+ }
+ }
+ if(0 != (ret)){
+ printf("!!!Set all low FAIL, please retest\n");
+ return -1;
+ }
+ return 0;
+}
+
+int mbtk_at_gpio(void* arg)
+{
+
+
+ int test_gpio[] = {
+ 99,
+ 117,
+ 21,22,23,24,44,41,120,
+ 8,127,46,59,58,57,56,55,48,19,34,33,35,36,49,
+ 50,25,28,26,122,20,10,11,
+ 39,40,37,38,
+ 51,52,31,32,
+
+ };
+
+ int i, n = 0, ret, total;
+ int *fail_io = (int *)arg;
+ total = (sizeof(test_gpio)/sizeof(int));
+ printf("T108 Start test gpio V1.0, total gpio=%d\n", total);
+
+ /* [1 all gpio Init] */
+ gpio_test_init_test_gpio_mode();
+
+ /* [2 GPIOTEST] */
+ for(i = 0; i < total; i++){
+ ret = gpio_register_test_out(test_gpio[i], 0);
+ if(-1 == ret){
+ printf("!!!!!!!!!!!!gpio [%d] test failed!!!!!!!!!!!!\n", test_gpio[i]);
+ fail_io[n] = test_gpio[i];
+ n++;
+ }else{
+ //printf("############gpio [%d] test success############\n", test_gpio[i]);
+ }
+ }
+ return n;
+}
+
+
#else
int mbtk_at_gpio(void* arg)