2 * Copyright (C) 2010,Imagis Technology Co. Ltd. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 #include <linux/mutex.h>
18 #include <linux/i2c.h>
19 #include <linux/delay.h>
20 #include <linux/slab.h>
21 #include <linux/input.h>
22 #include <linux/stat.h>
23 #include <linux/err.h>
26 #include "ist30xxc_update.h"
28 #include "ist30xxc_misc.h"
31 #include "ist30xxc_cmcs.h"
35 static char IsfwUpdate[20] = { 0 };
37 #define FW_DOWNLOADING "Downloading"
38 #define FW_DOWNLOAD_COMPLETE "Complete"
39 #define FW_DOWNLOAD_FAIL "FAIL"
41 #define FACTORY_BUF_SIZE (2048)
45 #define CMD_STATE_WAITING (0)
46 #define CMD_STATE_RUNNING (1)
47 #define CMD_STATE_OK (2)
48 #define CMD_STATE_FAIL (3)
49 #define CMD_STATE_NA (4)
51 #define TSP_NODE_DEBUG (0)
52 #define TSP_CM_DEBUG (0)
54 #define TSP_CH_UNUSED (0)
55 #define TSP_CH_SCREEN (1)
56 #define TSP_CH_GTX (2)
57 #define TSP_CH_KEY (3)
58 #define TSP_CH_UNKNOWN (-1)
60 #define TSP_CMD(name, func) .cmd_name = name, .cmd_func = func
62 struct list_head list;
63 const char * cmd_name;
64 void (*cmd_func)(void *dev_data);
67 u32 ist30xx_get_fw_ver(struct ist30xx_data *data)
72 ret = ist30xx_read_cmd(data, eHCOM_GET_VER_FW, &ver);
74 ist30xx_reset(data, false);
76 tsp_info("%s(), ret=%d\n", __func__, ret);
80 tsp_debug("Reg addr: %x, ver: %x\n", eHCOM_GET_VER_FW, ver);
85 #define KEY_SENSITIVITY_OFFSET 0x10
86 u32 key_sensitivity = 0;
87 int ist30xx_get_key_sensitivity(struct ist30xx_data *data, int id)
89 u32 addr = IST30XX_DA_ADDR(data->tags.algo_base) + KEY_SENSITIVITY_OFFSET;
93 if (unlikely(id >= data->tkey_info.key_num))
96 if (ist30xx_intr_wait(data, 30) < 0)
99 ret = ist30xx_read_cmd(data, addr, &val);
101 ist30xx_reset(data, false);
103 tsp_info("%s(), ret=%d\n", __func__, ret);
107 if ((val & 0xFFF) == 0xFFF)
108 return (key_sensitivity >> (16 * id)) & 0xFFFF;
110 key_sensitivity = val;
112 tsp_debug("Reg addr: %x, val: %8x\n", addr, val);
116 return (int)(val & 0xFFFF);
120 /* Factory CMD function */
121 static void set_default_result(struct sec_factory *sec)
125 memset(sec->cmd_result, 0, ARRAY_SIZE(sec->cmd_result));
126 memcpy(sec->cmd_result, sec->cmd, strlen(sec->cmd));
127 strncat(sec->cmd_result, &delim, CMD_STATE_RUNNING);
130 static void set_cmd_result(struct sec_factory *sec, char *buf, int len)
132 strncat(sec->cmd_result, buf, len);
135 static void not_support_cmd(void *dev_data)
137 char buf[16] = { 0 };
139 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
140 struct sec_factory *sec = (struct sec_factory *)&data->sec;
142 set_default_result(sec);
143 snprintf(buf, sizeof(buf), "%s", "NA");
144 tsp_info("%s(), %s\n", __func__, buf);
146 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
147 sec->cmd_state = CMD_STATE_NA;
148 dev_info(&data->client->dev, "%s: \"%s(%d)\"\n", __func__,
149 buf, strnlen(buf, sizeof(buf)));
153 static void get_chip_vendor(void *dev_data)
155 char buf[16] = { 0 };
157 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
158 struct sec_factory *sec = (struct sec_factory *)&data->sec;
160 set_default_result(sec);
161 snprintf(buf, sizeof(buf), "%s", TSP_CHIP_VENDOR);
162 tsp_info("%s(), %s\n", __func__, buf);
164 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
165 sec->cmd_state = CMD_STATE_OK;
166 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__,
167 buf, strnlen(buf, sizeof(buf)));
170 static void get_chip_name(void *dev_data)
172 char buf[16] = { 0 };
174 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
175 struct sec_factory *sec = (struct sec_factory *)&data->sec;
177 set_default_result(sec);
178 snprintf(buf, sizeof(buf), "%s", TSP_CHIP_NAME);
179 tsp_info("%s(), %s\n", __func__, buf);
181 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
182 sec->cmd_state = CMD_STATE_OK;
183 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__,
184 buf, strnlen(buf, sizeof(buf)));
187 static void get_chip_id(void *dev_data)
189 char buf[16] = { 0 };
191 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
192 struct sec_factory *sec = (struct sec_factory *)&data->sec;
194 set_default_result(sec);
195 snprintf(buf, sizeof(buf), "%#02x", data->chip_id);
196 tsp_info("%s(), %s\n", __func__, buf);
198 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
199 sec->cmd_state = CMD_STATE_OK;
200 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__,
201 buf, strnlen(buf, sizeof(buf)));
203 #include <linux/uaccess.h>
204 #define MAX_FW_PATH 255
205 static void fw_update(void *dev_data)
208 char buf[16] = { 0 };
209 mm_segment_t old_fs = {0};
210 struct file *fp = NULL;
211 long fsize = 0, nread = 0;
213 char fw_path[MAX_FW_PATH+1];
215 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
216 struct sec_factory *sec = (struct sec_factory *)&data->sec;
218 set_default_result(sec);
220 tsp_info("%s(), %d\n", __func__, sec->cmd_param[0]);
222 switch (sec->cmd_param[0]) {
224 sec->cmd_state = CMD_STATE_OK;
225 ret = ist30xx_fw_recovery(data);
227 sec->cmd_state = CMD_STATE_FAIL;
230 sec->cmd_state = CMD_STATE_OK;
234 snprintf(fw_path, MAX_FW_PATH, "/sdcard/%s", IST30XX_FW_NAME);
235 fp = filp_open(fw_path, O_RDONLY, 0);
237 tsp_warn("%s(), file %s open error:%d\n", __func__,
239 sec->cmd_state= CMD_STATE_FAIL;
244 fsize = fp->f_path.dentry->d_inode->i_size;
245 if (fsize != data->fw.buf_size) {
246 tsp_warn("%s(), invalid fw size!!\n", __func__);
247 sec->cmd_state = CMD_STATE_FAIL;
251 fw = kzalloc((size_t)fsize, GFP_KERNEL);
253 tsp_warn("%s(), failed to alloc buffer for fw\n", __func__);
254 sec->cmd_state = CMD_STATE_FAIL;
255 filp_close(fp, NULL);
259 nread = vfs_read(fp, (char __user *)fw, fsize, &fp->f_pos);
260 if (nread != fsize) {
261 tsp_warn("%s(), failed to read fw\n", __func__);
262 sec->cmd_state = CMD_STATE_FAIL;
263 filp_close(fp, NULL);
268 filp_close(fp, current->files);
270 tsp_info("%s(), ums fw is loaded!!\n", __func__);
272 ret = ist30xx_get_update_info(data, fw, fsize);
274 sec->cmd_state = CMD_STATE_FAIL;
277 data->fw.bin.main_ver = ist30xx_parse_ver(data, FLAG_MAIN, fw);
278 data->fw.bin.fw_ver = ist30xx_parse_ver(data, FLAG_FW, fw);
279 data->fw.bin.test_ver = ist30xx_parse_ver(data, FLAG_TEST, fw);
280 data->fw.bin.core_ver = ist30xx_parse_ver(data, FLAG_CORE, fw);
282 mutex_lock(&ist30xx_mutex);
283 ret = ist30xx_fw_update(data, fw, fsize);
285 sec->cmd_state = CMD_STATE_FAIL;
289 mutex_unlock(&ist30xx_mutex);
291 ist30xx_calibrate(data, 1);
295 tsp_warn("%s(), Invalid fw file type!\n", __func__);
299 if (sec->cmd_state == CMD_STATE_OK)
300 snprintf(buf, sizeof(buf), "%s", "OK");
302 snprintf(buf, sizeof(buf), "%s", "NG");
304 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
308 static void get_fw_ver_bin(void *dev_data)
311 char buf[16] = { 0 };
313 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
314 struct sec_factory *sec = (struct sec_factory *)&data->sec;
316 set_default_result(sec);
318 ver = ist30xx_parse_ver(data, FLAG_FW, data->fw.buf);
319 snprintf(buf, sizeof(buf), "IM00%04x", ver);
320 tsp_info("%s(), %s\n", __func__, buf);
322 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
323 sec->cmd_state = CMD_STATE_OK;
324 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__,
325 buf, strnlen(buf, sizeof(buf)));
328 static void get_fw_ver_ic(void *dev_data)
332 char buf[16] = { 0 };
334 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
335 struct sec_factory *sec = (struct sec_factory *)&data->sec;
337 set_default_result(sec);
339 if (data->status.power == 1)
340 ver = ist30xx_get_fw_ver(data);
342 snprintf(buf, sizeof(buf), "IM00%04x", ver & 0xFFFF);
344 if (data->fw.cur.test_ver > 0) {
345 sprintf(msg, "(T%d)", data->fw.cur.test_ver);
349 tsp_info("%s(), %s\n", __func__, buf);
351 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
352 sec->cmd_state = CMD_STATE_OK;
353 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__,
354 buf, strnlen(buf, sizeof(buf)));
357 static void get_threshold(void *dev_data)
361 char buf[16] = { 0 };
364 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
365 struct sec_factory *sec = (struct sec_factory *)&data->sec;
367 ret = ist30xx_read_cmd(data, eHCOM_GET_TOUCH_TH, &val);
369 ist30xx_reset(data, false);
371 tsp_info("%s(), ret=%d\n", __func__, ret);
375 set_default_result(sec);
377 threshold = (int)(val & 0xFFFF);
379 snprintf(buf, sizeof(buf), "%d", threshold);
380 tsp_info("%s(), %s\n", __func__, buf);
382 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
383 sec->cmd_state = CMD_STATE_OK;
384 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__,
385 buf, strnlen(buf, sizeof(buf)));
388 static void get_scr_x_num(void *dev_data)
391 char buf[16] = { 0 };
393 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
394 struct sec_factory *sec = (struct sec_factory *)&data->sec;
396 set_default_result(sec);
398 if (data->tsp_info.dir.swap_xy)
399 val = data->tsp_info.screen.tx;
401 val = data->tsp_info.screen.rx;
404 snprintf(buf, sizeof(buf), "%u", val);
405 sec->cmd_state = CMD_STATE_OK;
406 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
407 strnlen(buf, sizeof(buf)));
409 snprintf(buf, sizeof(buf), "%s", "NG");
410 sec->cmd_state = CMD_STATE_FAIL;
411 dev_info(&data->client->dev,
412 "%s: fail to read num of x (%d).\n", __func__, val);
414 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
415 tsp_info("%s(), %s\n", __func__, buf);
418 static void get_scr_y_num(void *dev_data)
421 char buf[16] = { 0 };
423 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
424 struct sec_factory *sec = (struct sec_factory *)&data->sec;
426 set_default_result(sec);
428 if (data->tsp_info.dir.swap_xy)
429 val = data->tsp_info.screen.rx;
431 val = data->tsp_info.screen.tx;
434 snprintf(buf, sizeof(buf), "%u", val);
435 sec->cmd_state = CMD_STATE_OK;
436 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
437 strnlen(buf, sizeof(buf)));
439 snprintf(buf, sizeof(buf), "%s", "NG");
440 sec->cmd_state = CMD_STATE_FAIL;
441 dev_info(&data->client->dev,
442 "%s: fail to read num of y (%d).\n", __func__, val);
444 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
445 tsp_info("%s(), %s\n", __func__, buf);
448 static void get_all_x_num(void *dev_data)
451 char buf[16] = { 0 };
453 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
454 struct sec_factory *sec = (struct sec_factory *)&data->sec;
456 set_default_result(sec);
458 if (data->tsp_info.dir.swap_xy)
459 val = data->tsp_info.ch_num.tx;
461 val = data->tsp_info.ch_num.rx;
464 snprintf(buf, sizeof(buf), "%u", val);
465 sec->cmd_state = CMD_STATE_OK;
466 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
467 strnlen(buf, sizeof(buf)));
469 snprintf(buf, sizeof(buf), "%s", "NG");
470 sec->cmd_state = CMD_STATE_FAIL;
471 dev_info(&data->client->dev,
472 "%s: fail to read all num of x (%d).\n", __func__, val);
474 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
475 tsp_info("%s(), %s\n", __func__, buf);
478 static void get_all_y_num(void *dev_data)
481 char buf[16] = { 0 };
483 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
484 struct sec_factory *sec = (struct sec_factory *)&data->sec;
486 set_default_result(sec);
488 if (data->tsp_info.dir.swap_xy)
489 val = data->tsp_info.ch_num.rx;
491 val = data->tsp_info.ch_num.tx;
494 snprintf(buf, sizeof(buf), "%u", val);
495 sec->cmd_state = CMD_STATE_OK;
496 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
497 strnlen(buf, sizeof(buf)));
499 snprintf(buf, sizeof(buf), "%s", "NG");
500 sec->cmd_state = CMD_STATE_FAIL;
501 dev_info(&data->client->dev,
502 "%s: fail to read all num of y (%d).\n", __func__, val);
504 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
505 tsp_info("%s(), %s\n", __func__, buf);
508 int check_tsp_channel(void *dev_data, int width, int height)
512 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
513 struct sec_factory *sec = (struct sec_factory *)&data->sec;
515 if ((sec->cmd_param[0] < 0) || (sec->cmd_param[0] >= width) ||
516 (sec->cmd_param[1] < 0) || (sec->cmd_param[1] >= height)) {
517 tsp_info("%s: parameter error: %u,%u\n",
518 __func__, sec->cmd_param[0], sec->cmd_param[1]);
520 node = sec->cmd_param[0] + sec->cmd_param[1] * width;
521 tsp_info("%s: node = %d\n", __func__, node);
527 static u16 node_value[IST30XX_NODE_TOTAL_NUM];
528 void get_raw_array(void *dev_data)
533 const int msg_len = 16;
535 u8 flag = NODE_FLAG_RAW;
537 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
538 struct sec_factory *sec = (struct sec_factory *)&data->sec;
539 TSP_INFO *tsp = &data->tsp_info;
541 set_default_result(sec);
543 mutex_lock(&ist30xx_mutex);
544 ret = ist30xx_read_touch_node(data, flag, &tsp->node);
546 mutex_unlock(&ist30xx_mutex);
547 sec->cmd_state = CMD_STATE_FAIL;
548 tsp_warn("%s(), tsp node read fail!\n", __func__);
551 mutex_unlock(&ist30xx_mutex);
552 ist30xx_parse_touch_node(data, flag, &tsp->node);
554 ret = parse_tsp_node(data, flag, &tsp->node, node_value, false);
556 sec->cmd_state = CMD_STATE_FAIL;
557 tsp_warn("%s(), tsp node parse fail - flag: %d\n", __func__, flag);
561 buf = kmalloc(IST30XX_NODE_TOTAL_NUM * 5, GFP_KERNEL);
562 memset(buf, 0, sizeof(buf));
564 for (i = 0; i < tsp->ch_num.rx * tsp->ch_num.tx; i++) {
566 if ((i % tsp->ch_num.rx) == 0)
567 printk("\n%s %4d: ", IST30XX_DEBUG_TAG, i);
569 printk("%4d ", node_value[i]);
571 count += snprintf(msg, msg_len, "%d,", node_value[i]);
572 strncat(buf, msg, msg_len);
576 tsp_info("%s: %d\n", __func__, count - 1);
577 sec->cmd_state = CMD_STATE_OK;
578 set_cmd_result(sec, buf, count - 1);
579 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf, count);
583 void run_raw_read(void *dev_data)
587 int min_val, max_val;
588 char buf[16] = { 0 };
589 u8 flag = NODE_FLAG_RAW;
591 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
592 struct sec_factory *sec = (struct sec_factory *)&data->sec;
593 TSP_INFO *tsp = &data->tsp_info;
595 set_default_result(sec);
597 ret = ist30xx_read_touch_node(data, flag, &tsp->node);
599 sec->cmd_state = CMD_STATE_FAIL;
600 tsp_warn("%s(), tsp node read fail!\n", __func__);
603 ist30xx_parse_touch_node(data, flag, &tsp->node);
605 ret = parse_tsp_node(data, flag, &tsp->node, node_value, true);
607 sec->cmd_state = CMD_STATE_FAIL;
608 tsp_warn("%s(), tsp node parse fail - flag: %d\n", __func__, flag);
612 min_val = max_val = node_value[0];
613 for (i = 0; i < tsp->screen.rx * tsp->screen.tx; i++) {
615 if ((i % tsp->screen.rx) == 0)
616 printk("\n%s %4d: ", IST30XX_DEBUG_TAG, i);
618 printk("%4d ", node_value[i]);
621 max_val = max(max_val, (int)node_value[i]);
622 min_val = min(min_val, (int)node_value[i]);
625 snprintf(buf, sizeof(buf), "%d,%d", min_val, max_val);
626 tsp_info("%s(), %s\n", __func__, buf);
628 sec->cmd_state = CMD_STATE_OK;
629 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
630 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
631 strnlen(buf, sizeof(buf)));
634 void get_raw_value(void *dev_data)
637 char buf[16] = { 0 };
639 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
640 struct sec_factory *sec = (struct sec_factory *)&data->sec;
641 TSP_INFO *tsp = &data->tsp_info;
643 set_default_result(sec);
645 idx = check_tsp_channel(data, tsp->screen.rx, tsp->screen.tx);
646 if (idx < 0) { // Parameter parsing fail
647 snprintf(buf, sizeof(buf), "%s", "NG");
648 sec->cmd_state = CMD_STATE_FAIL;
650 snprintf(buf, sizeof(buf), "%d", node_value[idx]);
651 sec->cmd_state = CMD_STATE_OK;
654 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
655 tsp_info("%s(), [%d][%d]: %s\n", __func__,
656 sec->cmd_param[0], sec->cmd_param[1], buf);
657 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
658 strnlen(buf, sizeof(buf)));
661 #if IST30XX_CMCS_TEST
662 extern u8 *ts_cmcs_bin;
663 extern u32 ts_cmcs_bin_size;
664 extern CMCS_BIN_INFO *ts_cmcs;
665 extern CMCS_BUF *ts_cmcs_buf;
666 void run_cm_test(void *dev_data)
670 char buf[16] = { 0 };
672 int min_val, max_val;
674 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
675 struct sec_factory *sec = (struct sec_factory *)&data->sec;
676 TSP_INFO *tsp = &data->tsp_info;
678 set_default_result(sec);
680 if ((ts_cmcs_bin == NULL) || (ts_cmcs_bin_size == 0)) {
681 sec->cmd_state = CMD_STATE_FAIL;
682 tsp_warn("%s(), Binary is not correct!\n", __func__);
686 ret = ist30xx_get_cmcs_info(ts_cmcs_bin, ts_cmcs_bin_size);
688 sec->cmd_state = CMD_STATE_FAIL;
689 tsp_warn("%s(), tsp get cmcs infomation fail!\n", __func__);
693 mutex_lock(&ist30xx_mutex);
694 ret = ist30xx_cmcs_test(data, ts_cmcs_bin, ts_cmcs_bin_size);
696 mutex_unlock(&ist30xx_mutex);
697 sec->cmd_state = CMD_STATE_FAIL;
698 tsp_warn("%s(), tsp cmcs test fail!\n", __func__);
701 mutex_unlock(&ist30xx_mutex);
703 min_val = max_val = ts_cmcs_buf->cm[0];
704 for (i = 0; i < tsp->ch_num.tx; i++) {
706 printk("%s", IST30XX_DEBUG_TAG);
708 for (j = 0; j < tsp->ch_num.rx; j++) {
709 idx = (i * tsp->ch_num.rx) + j;
710 type = check_tsp_type(data, i, j);
712 if ((type == TSP_CH_SCREEN) || (type == TSP_CH_GTX)) {
713 max_val = max(max_val, (int)ts_cmcs_buf->cm[idx]);
714 min_val = min(min_val, (int)ts_cmcs_buf->cm[idx]);
717 printk("%5d ", ts_cmcs_buf->cm[idx]);
725 snprintf(buf, sizeof(buf), "%d,%d", min_val, max_val);
726 tsp_info("%s(), %s\n", __func__, buf);
728 sec->cmd_state = CMD_STATE_OK;
729 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
730 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
731 strnlen(buf, sizeof(buf)));
734 void get_cm_value(void *dev_data)
737 char buf[16] = { 0 };
739 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
740 struct sec_factory *sec = (struct sec_factory *)&data->sec;
741 TSP_INFO *tsp = &data->tsp_info;
743 set_default_result(sec);
745 idx = check_tsp_channel(data, tsp->ch_num.rx, tsp->ch_num.tx);
746 if (idx < 0) { // Parameter parsing fail
747 snprintf(buf, sizeof(buf), "%s", "NG");
748 sec->cmd_state = CMD_STATE_FAIL;
750 snprintf(buf, sizeof(buf), "%d", ts_cmcs_buf->cm[idx]);
751 sec->cmd_state = CMD_STATE_OK;
754 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
755 tsp_info("%s(), [%d][%d]: %s\n", __func__,
756 sec->cmd_param[0], sec->cmd_param[1], buf);
757 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
758 strnlen(buf, sizeof(buf)));
761 void run_cmcs_test(void *dev_data)
764 char buf[16] = { 0 };
766 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
767 struct sec_factory *sec = (struct sec_factory *)&data->sec;
769 set_default_result(sec);
771 if ((ts_cmcs_bin == NULL) || (ts_cmcs_bin_size == 0)) {
772 sec->cmd_state = CMD_STATE_FAIL;
773 tsp_warn("%s(), Binary is not correct!\n", __func__);
777 ret = ist30xx_get_cmcs_info(ts_cmcs_bin, ts_cmcs_bin_size);
779 sec->cmd_state = CMD_STATE_FAIL;
780 tsp_warn("%s(), tsp get cmcs infomation fail!\n", __func__);
784 mutex_lock(&ist30xx_mutex);
785 ret = ist30xx_cmcs_test(data, ts_cmcs_bin, ts_cmcs_bin_size);
787 mutex_unlock(&ist30xx_mutex);
788 sec->cmd_state = CMD_STATE_FAIL;
789 tsp_warn("%s(), tsp cmcs test fail!\n", __func__);
792 mutex_unlock(&ist30xx_mutex);
794 snprintf(buf, sizeof(buf), "%s", "OK");
795 tsp_info("%s(), %s\n", __func__, buf);
797 sec->cmd_state = CMD_STATE_OK;
798 set_cmd_result(sec, buf, strnlen(buf, sizeof(buf)));
799 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf,
800 strnlen(buf, sizeof(buf)));
803 void get_cm_array(void *dev_data)
809 const int msg_len = 16;
812 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
813 struct sec_factory *sec = (struct sec_factory *)&data->sec;
814 TSP_INFO *tsp = &data->tsp_info;
816 set_default_result(sec);
818 buf = kmalloc(IST30XX_NODE_TOTAL_NUM * 5, GFP_KERNEL);
819 memset(buf, 0, sizeof(buf));
821 for (i = 0; i < tsp->ch_num.rx * tsp->ch_num.tx; i++) {
823 if ((i % tsp->ch_num.rx) == 0)
824 printk("\n%s %4d: ", IST30XX_DEBUG_TAG, i);
826 printk("%4d ", ts_cmcs_buf->cm[i]);
828 type = check_tsp_type(data, i / tsp->ch_num.rx, i % tsp->ch_num.rx);
829 if ((type == TSP_CH_UNKNOWN) || (type == TSP_CH_UNUSED))
830 count += snprintf(msg, msg_len, "%d,", 0);
832 count += snprintf(msg, msg_len, "%d,", ts_cmcs_buf->cm[i]);
833 strncat(buf, msg, msg_len);
837 tsp_info("%s: %d\n", __func__, count - 1);
838 sec->cmd_state = CMD_STATE_OK;
839 set_cmd_result(sec, buf, count - 1);
840 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf, count);
844 void get_slope0_array(void *dev_data)
849 const int msg_len = 16;
852 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
853 struct sec_factory *sec = (struct sec_factory *)&data->sec;
854 TSP_INFO *tsp = &data->tsp_info;
856 set_default_result(sec);
858 buf = kmalloc(IST30XX_NODE_TOTAL_NUM * 5, GFP_KERNEL);
859 memset(buf, 0, sizeof(buf));
861 for (i = 0; i < tsp->ch_num.rx * tsp->ch_num.tx; i++) {
863 if ((i % tsp->ch_num.rx) == 0)
864 printk("\n%s %4d: ", IST30XX_DEBUG_TAG, i);
866 printk("%4d ", ts_cmcs_buf->slope0[i]);
868 count += snprintf(msg, msg_len, "%d,", ts_cmcs_buf->slope0[i]);
869 strncat(buf, msg, msg_len);
873 tsp_info("%s: %d\n", __func__, count - 1);
874 sec->cmd_state = CMD_STATE_OK;
875 set_cmd_result(sec, buf, count - 1);
876 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf, count);
880 void get_slope1_array(void *dev_data)
885 const int msg_len = 16;
888 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
889 struct sec_factory *sec = (struct sec_factory *)&data->sec;
890 TSP_INFO *tsp = &data->tsp_info;
892 set_default_result(sec);
894 buf = kmalloc(IST30XX_NODE_TOTAL_NUM * 5, GFP_KERNEL);
895 memset(buf, 0, sizeof(buf));
897 for (i = 0; i < tsp->ch_num.rx * tsp->ch_num.tx; i++) {
899 if ((i % tsp->ch_num.rx) == 0)
900 printk("\n%s %4d: ", IST30XX_DEBUG_TAG, i);
902 printk("%4d ", ts_cmcs_buf->slope1[i]);
904 count += snprintf(msg, msg_len, "%d,", ts_cmcs_buf->slope1[i]);
905 strncat(buf, msg, msg_len);
909 tsp_info("%s: %d\n", __func__, count - 1);
910 sec->cmd_state = CMD_STATE_OK;
911 set_cmd_result(sec, buf, count - 1);
912 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf, count);
916 void get_cs_array(void *dev_data)
922 const int msg_len = 16;
925 struct ist30xx_data *data = (struct ist30xx_data *)dev_data;
926 struct sec_factory *sec = (struct sec_factory *)&data->sec;
927 TSP_INFO *tsp = &data->tsp_info;
929 set_default_result(sec);
931 buf = kmalloc(IST30XX_NODE_TOTAL_NUM * 5, GFP_KERNEL);
932 memset(buf, 0, sizeof(buf));
934 for (i = 0; i < tsp->ch_num.rx * tsp->ch_num.tx; i++) {
936 if ((i % tsp->ch_num.rx) == 0)
937 printk("\n%s %4d: ", IST30XX_DEBUG_TAG, i);
939 printk("%4d ", ts_cmcs_buf->cs[i]);
941 type = check_tsp_type(data, i / tsp->ch_num.rx, i % tsp->ch_num.rx);
942 if ((type == TSP_CH_UNKNOWN) || (type == TSP_CH_UNUSED))
943 count += snprintf(msg, msg_len, "%d,", 0);
945 count += snprintf(msg, msg_len, "%d,", ts_cmcs_buf->cs[i]);
946 strncat(buf, msg, msg_len);
950 tsp_info("%s: %d\n", __func__, count - 1);
951 sec->cmd_state = CMD_STATE_OK;
952 set_cmd_result(sec, buf, count - 1);
953 dev_info(&data->client->dev, "%s: %s(%d)\n", __func__, buf, count);
957 /* sysfs: /sys/class/sec/tsp/close_tsp_test */
958 static ssize_t show_close_tsp_test(struct device *dev,
959 struct device_attribute *attr, char *buf)
961 return snprintf(buf, FACTORY_BUF_SIZE, "%u\n", 0);
964 /* sysfs: /sys/class/sec/tsp/cmd */
965 static ssize_t store_cmd(struct device *dev, struct device_attribute
966 *devattr, const char *buf, size_t count)
968 struct ist30xx_data *data = dev_get_drvdata(dev);
969 struct sec_factory *sec = (struct sec_factory *)&data->sec;
970 struct i2c_client *client = data->client;
972 char *cur, *start, *end;
973 char msg[SEC_CMD_STR_LEN] = { 0 };
975 struct tsp_cmd *tsp_cmd_ptr = NULL;
977 bool cmd_found = false;
981 if (sec->cmd_is_running == true) {
982 dev_err(&client->dev, "tsp_cmd: other cmd is running.\n");
983 tsp_err("tsp_cmd: other cmd is running.\n");
988 mutex_lock(&sec->cmd_lock);
989 sec->cmd_is_running = true;
990 mutex_unlock(&sec->cmd_lock);
992 sec->cmd_state = CMD_STATE_RUNNING;
994 for (i = 0; i < ARRAY_SIZE(sec->cmd_param); i++)
995 sec->cmd_param[i] = 0;
998 if (*(buf + len - 1) == '\n')
1000 memset(sec->cmd, 0, ARRAY_SIZE(sec->cmd));
1001 memcpy(sec->cmd, buf, len);
1003 cur = strchr(buf, (int)delim);
1005 memcpy(msg, buf, cur - buf);
1007 memcpy(msg, buf, len);
1009 list_for_each_entry(tsp_cmd_ptr, &sec->cmd_list_head, list) {
1010 if (!strcmp(msg, tsp_cmd_ptr->cmd_name)) {
1016 /* set not_support_cmd */
1018 list_for_each_entry(tsp_cmd_ptr, &sec->cmd_list_head, list) {
1019 if (!strcmp("not_support_cmd", tsp_cmd_ptr->cmd_name))
1024 /* parsing parameters */
1025 if (cur && cmd_found) {
1028 memset(msg, 0, ARRAY_SIZE(msg));
1030 if (*cur == delim || cur - buf == len) {
1032 memcpy(msg, start, end - start);
1033 *(msg + strlen(msg)) = '\0';
1034 ret = kstrtoint(msg, 10, \
1035 sec->cmd_param + param_cnt);
1037 memset(msg, 0, ARRAY_SIZE(msg));
1041 } while (cur - buf <= len);
1043 tsp_info("SEC CMD = %s\n", tsp_cmd_ptr->cmd_name);
1045 for (i = 0; i < param_cnt; i++)
1046 tsp_info("SEC CMD Param %d= %d\n", i, sec->cmd_param[i]);
1048 tsp_cmd_ptr->cmd_func(data);
1054 /* sysfs: /sys/class/sec/tsp/cmd_status */
1055 static ssize_t show_cmd_status(struct device *dev,
1056 struct device_attribute *devattr, char *buf)
1058 struct ist30xx_data *data = dev_get_drvdata(dev);
1059 struct sec_factory *sec = (struct sec_factory *)&data->sec;
1060 char msg[16] = { 0 };
1062 dev_info(&data->client->dev, "tsp cmd: status:%d\n", sec->cmd_state);
1064 if (sec->cmd_state == CMD_STATE_WAITING)
1065 snprintf(msg, sizeof(msg), "WAITING");
1066 else if (sec->cmd_state == CMD_STATE_RUNNING)
1067 snprintf(msg, sizeof(msg), "RUNNING");
1068 else if (sec->cmd_state == CMD_STATE_OK)
1069 snprintf(msg, sizeof(msg), "OK");
1070 else if (sec->cmd_state == CMD_STATE_FAIL)
1071 snprintf(msg, sizeof(msg), "FAIL");
1072 else if (sec->cmd_state == CMD_STATE_NA)
1073 snprintf(msg, sizeof(msg), "NOT_APPLICABLE");
1075 return snprintf(buf, FACTORY_BUF_SIZE, "%s\n", msg);
1078 /* sysfs: /sys/class/sec/tsp/cmd_result */
1079 static ssize_t show_cmd_result(struct device *dev, struct device_attribute
1080 *devattr, char *buf)
1082 struct ist30xx_data *data = dev_get_drvdata(dev);
1083 struct sec_factory *sec = (struct sec_factory *)&data->sec;
1085 dev_info(&data->client->dev, "tsp cmd: result: %s\n", sec->cmd_result);
1087 mutex_lock(&sec->cmd_lock);
1088 sec->cmd_is_running = false;
1089 mutex_unlock(&sec->cmd_lock);
1091 sec->cmd_state = CMD_STATE_WAITING;
1093 return snprintf(buf, FACTORY_BUF_SIZE, "%s\n", sec->cmd_result);
1098 /* sysfs: /sys/class/sec/sec_touchscreen/tsp_firm_version_phone */
1099 static ssize_t phone_firmware_show(struct device *dev,
1100 struct device_attribute *attr, char *buf)
1102 struct ist30xx_data *data = dev_get_drvdata(dev);
1104 u32 ver = ist30xx_parse_ver(data, FLAG_FW, data->fw.buf);
1106 tsp_info("%s(), IM00%04x\n", __func__, ver);
1108 return sprintf(buf, "IM00%04x", ver);
1111 /* sysfs: /sys/class/sec/sec_touchscreen/tsp_firm_version_panel */
1112 static ssize_t part_firmware_show(struct device *dev,
1113 struct device_attribute *attr, char *buf)
1116 struct ist30xx_data *data = dev_get_drvdata(dev);
1118 if (data->status.power == 1)
1119 ver = ist30xx_get_fw_ver(data);
1121 tsp_info("%s(), IM00%04x\n", __func__, ver);
1123 return sprintf(buf, "IM00%04x", ver);
1126 /* sysfs: /sys/class/sec/sec_touchscreen/tsp_threshold */
1127 static ssize_t threshold_firmware_show(struct device *dev,
1128 struct device_attribute *attr, char *buf)
1133 struct ist30xx_data *data = dev_get_drvdata(dev);
1135 ret = ist30xx_read_cmd(data, eHCOM_GET_TOUCH_TH, &val);
1136 if (unlikely(ret)) {
1137 ist30xx_reset(data, false);
1138 ist30xx_start(data);
1139 tsp_info("%s(), ret=%d\n", __func__, ret);
1143 threshold = (int)(val & 0xFFFF);
1145 tsp_info("%s(), %d (ret=%d)\n", __func__, threshold, ret);
1147 return sprintf(buf, "%d", threshold);
1150 /* sysfs: /sys/class/sec/sec_touchscreen/tsp_firm_update */
1151 static ssize_t firmware_update(struct device *dev,
1152 struct device_attribute *attr, char *buf)
1155 struct ist30xx_data *data = dev_get_drvdata(dev);
1157 sprintf(IsfwUpdate, "%s\n", FW_DOWNLOADING);
1158 tsp_info("%s(), %s\n", __func__, IsfwUpdate);
1160 ret = ist30xx_fw_recovery(data);
1161 ret = (ret == 0 ? 1 : -1);
1163 sprintf(IsfwUpdate, "%s\n",
1164 (ret > 0 ? FW_DOWNLOAD_COMPLETE : FW_DOWNLOAD_FAIL));
1165 tsp_info("%s(), %s\n", __func__, IsfwUpdate);
1167 return sprintf(buf, "%d", ret);
1170 /* sysfs: /sys/class/sec/sec_touchscreen/tsp_firm_update_status */
1171 static ssize_t firmware_update_status(struct device *dev,
1172 struct device_attribute *attr, char *buf)
1174 tsp_info("%s(), %s\n", __func__, IsfwUpdate);
1176 return sprintf(buf, "%s\n", IsfwUpdate);
1179 /* sysfs: /sys/class/sec/sec_touchkey/touchkey_menu */
1180 /* sysfs: /sys/class/sec/sec_touchkey/touchkey_recent */
1181 static ssize_t recent_sensitivity_show(struct device *dev,
1182 struct device_attribute *attr, char *buf)
1184 int sensitivity = 0;
1185 struct ist30xx_data *data = dev_get_drvdata(dev);
1187 sensitivity = ist30xx_get_key_sensitivity(data, 0);
1189 tsp_info("%s(), %d\n", __func__, sensitivity);
1191 return sprintf(buf, "%d", sensitivity);
1194 /* sysfs: /sys/class/sec/sec_touchkey/touchkey_back */
1195 static ssize_t back_sensitivity_show(struct device *dev,
1196 struct device_attribute *attr, char *buf)
1198 int sensitivity = 0;
1199 struct ist30xx_data *data = dev_get_drvdata(dev);
1201 sensitivity = ist30xx_get_key_sensitivity(data, 1);
1203 tsp_info("%s(), %d\n", __func__, sensitivity);
1205 return sprintf(buf, "%d", sensitivity);
1208 /* sysfs: /sys/class/sec/sec_touchkey/touchkey_threshold */
1209 static ssize_t touchkey_threshold_show(struct device *dev,
1210 struct device_attribute *attr, char *buf)
1215 struct ist30xx_data *data = dev_get_drvdata(dev);
1217 ret = ist30xx_read_cmd(data, eHCOM_GET_TOUCH_TH, &val);
1218 if (unlikely(ret)) {
1219 ist30xx_reset(data, false);
1220 ist30xx_start(data);
1224 threshold = (int)((val >> 16) & 0xFFFF);
1226 tsp_info("%s(), %d (ret=%d)\n", __func__, threshold, ret);
1228 return sprintf(buf, "%d", threshold);
1231 struct tsp_cmd tsp_cmds[] = {
1232 { TSP_CMD("get_chip_vendor", get_chip_vendor), },
1233 { TSP_CMD("get_chip_name", get_chip_name), },
1234 { TSP_CMD("get_chip_id", get_chip_id), },
1235 { TSP_CMD("fw_update", fw_update), },
1236 { TSP_CMD("get_fw_ver_bin", get_fw_ver_bin), },
1237 { TSP_CMD("get_fw_ver_ic", get_fw_ver_ic), },
1238 { TSP_CMD("get_threshold", get_threshold), },
1239 { TSP_CMD("get_x_num", get_scr_x_num), },
1240 { TSP_CMD("get_y_num", get_scr_y_num), },
1241 { TSP_CMD("get_all_x_num", get_all_x_num), },
1242 { TSP_CMD("get_all_y_num", get_all_y_num), },
1243 { TSP_CMD("run_raw_read", run_raw_read), },
1244 { TSP_CMD("get_raw_value", get_raw_value), },
1245 #if IST30XX_CMCS_TEST
1246 { TSP_CMD("run_cm_test", run_cm_test), },
1247 { TSP_CMD("get_cm_value", get_cm_value), },
1248 #if IST30XX_JIG_MODE
1249 { TSP_CMD("get_raw_array", get_raw_array), },
1250 { TSP_CMD("run_cmcs_test", run_cmcs_test), },
1251 { TSP_CMD("get_cm_array", get_cm_array), },
1252 { TSP_CMD("get_slope0_array",get_slope0_array),},
1253 { TSP_CMD("get_slope1_array",get_slope1_array),},
1254 { TSP_CMD("get_cs_array", get_cs_array), },
1255 { TSP_CMD("get_cs0_array", get_cs_array), },
1256 { TSP_CMD("get_cs1_array", get_cs_array), },
1259 { TSP_CMD("not_support_cmd", not_support_cmd), },
1262 #define SEC_DEFAULT_ATTR (S_IRUGO | S_IWUSR | S_IWOTH | S_IXOTH)
1263 /* sysfs - touchscreen */
1264 static DEVICE_ATTR(tsp_firm_version_phone, SEC_DEFAULT_ATTR,
1265 phone_firmware_show, NULL);
1266 static DEVICE_ATTR(tsp_firm_version_panel, SEC_DEFAULT_ATTR,
1267 part_firmware_show, NULL);
1268 static DEVICE_ATTR(tsp_threshold, SEC_DEFAULT_ATTR,
1269 threshold_firmware_show, NULL);
1270 static DEVICE_ATTR(tsp_firm_update, SEC_DEFAULT_ATTR,
1271 firmware_update, NULL);
1272 static DEVICE_ATTR(tsp_firm_update_status, SEC_DEFAULT_ATTR,
1273 firmware_update_status, NULL);
1275 /* sysfs - touchkey */
1276 static DEVICE_ATTR(touchkey_menu, SEC_DEFAULT_ATTR,
1277 recent_sensitivity_show, NULL);
1278 static DEVICE_ATTR(touchkey_recent, SEC_DEFAULT_ATTR,
1279 recent_sensitivity_show, NULL);
1280 static DEVICE_ATTR(touchkey_back, SEC_DEFAULT_ATTR,
1281 back_sensitivity_show, NULL);
1282 static DEVICE_ATTR(touchkey_threshold, SEC_DEFAULT_ATTR,
1283 touchkey_threshold_show, NULL);
1286 static DEVICE_ATTR(close_tsp_test, S_IRUGO, show_close_tsp_test, NULL);
1287 static DEVICE_ATTR(cmd, S_IWUSR | S_IWGRP, NULL, store_cmd);
1288 static DEVICE_ATTR(cmd_status, S_IRUGO, show_cmd_status, NULL);
1289 static DEVICE_ATTR(cmd_result, S_IRUGO, show_cmd_result, NULL);
1291 static struct attribute *sec_tsp_attributes[] = {
1292 &dev_attr_tsp_firm_version_phone.attr,
1293 &dev_attr_tsp_firm_version_panel.attr,
1294 &dev_attr_tsp_threshold.attr,
1295 &dev_attr_tsp_firm_update.attr,
1296 &dev_attr_tsp_firm_update_status.attr,
1300 static struct attribute *sec_tkey_attributes[] = {
1301 &dev_attr_touchkey_menu.attr,
1302 &dev_attr_touchkey_recent.attr,
1303 &dev_attr_touchkey_back.attr,
1304 &dev_attr_touchkey_threshold.attr,
1308 static struct attribute *sec_touch_facotry_attributes[] = {
1309 &dev_attr_close_tsp_test.attr,
1311 &dev_attr_cmd_status.attr,
1312 &dev_attr_cmd_result.attr,
1316 static struct attribute_group sec_tsp_attr_group = {
1317 .attrs = sec_tsp_attributes,
1320 static struct attribute_group sec_tkey_attr_group = {
1321 .attrs = sec_tkey_attributes,
1324 static struct attribute_group sec_touch_factory_attr_group = {
1325 .attrs = sec_touch_facotry_attributes,
1328 extern struct class *sec_class;
1329 struct device *sec_touchscreen;
1330 struct device *sec_touchkey;
1331 struct device *sec_fac_dev;
1333 int sec_touch_sysfs(struct ist30xx_data *data)
1335 /* /sys/class/sec/sec_touchscreen */
1336 sec_touchscreen = device_create(sec_class, NULL, 1, data,
1338 if (IS_ERR(sec_touchscreen)) {
1339 tsp_err("Failed to create device (%s)!\n", "sec_touchscreen");
1340 goto err_sec_touchscreen;
1342 /* /sys/class/sec/sec_touchscreen/... */
1343 if (sysfs_create_group(&sec_touchscreen->kobj, &sec_tsp_attr_group)) {
1344 tsp_err("Failed to create sysfs group(%s)!\n", "sec_touchscreen");
1345 goto err_sec_touchscreen_attr;
1348 /* /sys/class/sec/sec_touchkey */
1349 sec_touchkey = device_create(sec_class, NULL, 2, data, "sec_touchkey");
1350 if (IS_ERR(sec_touchkey)) {
1351 tsp_err("Failed to create device (%s)!\n", "sec_touchkey");
1352 goto err_sec_touchkey;
1354 /* /sys/class/sec/sec_touchkey/... */
1355 if (sysfs_create_group(&sec_touchkey->kobj, &sec_tkey_attr_group)) {
1356 tsp_err("Failed to create sysfs group(%s)!\n", "sec_touchkey");
1357 goto err_sec_touchkey_attr;
1360 /* /sys/class/sec/tsp */
1361 sec_fac_dev = device_create(sec_class, NULL, 3, data, "tsp");
1362 if (IS_ERR(sec_fac_dev)) {
1363 tsp_err("Failed to create device (%s)!\n", "tsp");
1364 goto err_sec_fac_dev;
1366 /* /sys/class/sec/tsp/... */
1367 if (sysfs_create_group(&sec_fac_dev->kobj, &sec_touch_factory_attr_group)) {
1368 tsp_err("Failed to create sysfs group(%s)!\n", "tsp");
1369 goto err_sec_fac_dev_attr;
1374 err_sec_fac_dev_attr:
1375 device_destroy(sec_class, 3);
1377 err_sec_touchkey_attr:
1378 device_destroy(sec_class, 2);
1380 err_sec_touchscreen_attr:
1381 device_destroy(sec_class, 1);
1382 err_sec_touchscreen:
1386 EXPORT_SYMBOL(sec_touch_sysfs);
1387 int sec_fac_cmd_init(struct ist30xx_data *data)
1390 struct sec_factory *sec = (struct sec_factory *)&data->sec;
1392 INIT_LIST_HEAD(&sec->cmd_list_head);
1393 for (i = 0; i < ARRAY_SIZE(tsp_cmds); i++)
1394 list_add_tail(&tsp_cmds[i].list, &sec->cmd_list_head);
1396 mutex_init(&sec->cmd_lock);
1397 sec->cmd_is_running = false;
1401 EXPORT_SYMBOL(sec_fac_cmd_init);