Lines Matching refs:kim_gdata

65 static void validate_firmware_response(struct kim_data_s *kim_gdata)  in validate_firmware_response()  argument
67 struct sk_buff *skb = kim_gdata->rx_skb; in validate_firmware_response()
78 memcpy(kim_gdata->resp_buffer, in validate_firmware_response()
79 kim_gdata->rx_skb->data, in validate_firmware_response()
80 kim_gdata->rx_skb->len); in validate_firmware_response()
81 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in validate_firmware_response()
82 kim_gdata->rx_skb = NULL; in validate_firmware_response()
83 kim_gdata->rx_count = 0; in validate_firmware_response()
91 complete_all(&kim_gdata->kim_rcvd); in validate_firmware_response()
98 static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) in kim_check_data_len() argument
100 register int room = skb_tailroom(kim_gdata->rx_skb); in kim_check_data_len()
105 validate_firmware_response(kim_gdata); in kim_check_data_len()
112 kfree_skb(kim_gdata->rx_skb); in kim_check_data_len()
117 kim_gdata->rx_state = ST_W4_DATA; in kim_check_data_len()
118 kim_gdata->rx_count = len; in kim_check_data_len()
124 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in kim_check_data_len()
125 kim_gdata->rx_skb = NULL; in kim_check_data_len()
126 kim_gdata->rx_count = 0; in kim_check_data_len()
137 static void kim_int_recv(struct kim_data_s *kim_gdata, in kim_int_recv() argument
153 if (kim_gdata->rx_count) { in kim_int_recv()
154 len = min_t(unsigned int, kim_gdata->rx_count, count); in kim_int_recv()
155 skb_put_data(kim_gdata->rx_skb, ptr, len); in kim_int_recv()
156 kim_gdata->rx_count -= len; in kim_int_recv()
160 if (kim_gdata->rx_count) in kim_int_recv()
164 switch (kim_gdata->rx_state) { in kim_int_recv()
168 validate_firmware_response(kim_gdata); in kim_int_recv()
169 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in kim_int_recv()
170 kim_gdata->rx_skb = NULL; in kim_int_recv()
175 (unsigned char *)&kim_gdata->rx_skb->data[1]; in kim_int_recv()
177 kim_check_data_len(kim_gdata, *plen); in kim_int_recv()
184 kim_gdata->rx_state = ST_W4_HEADER; in kim_int_recv()
185 kim_gdata->rx_count = 2; in kim_int_recv()
195 kim_gdata->rx_skb = in kim_int_recv()
197 if (!kim_gdata->rx_skb) { in kim_int_recv()
199 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in kim_int_recv()
200 kim_gdata->rx_count = 0; in kim_int_recv()
203 skb_reserve(kim_gdata->rx_skb, 8); in kim_int_recv()
204 kim_gdata->rx_skb->cb[0] = 4; in kim_int_recv()
205 kim_gdata->rx_skb->cb[1] = 0; in kim_int_recv()
211 static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) in read_local_version() argument
219 reinit_completion(&kim_gdata->kim_rcvd); in read_local_version()
220 if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { in read_local_version()
226 &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME)); in read_local_version()
231 reinit_completion(&kim_gdata->kim_rcvd); in read_local_version()
237 MAKEWORD(kim_gdata->resp_buffer[12], in read_local_version()
238 kim_gdata->resp_buffer[13]); in read_local_version()
250 kim_gdata->version.full = version; in read_local_version()
251 kim_gdata->version.chip = chip; in read_local_version()
252 kim_gdata->version.maj_ver = maj_ver; in read_local_version()
253 kim_gdata->version.min_ver = min_ver; in read_local_version()
284 static long download_firmware(struct kim_data_s *kim_gdata) in download_firmware() argument
295 err = read_local_version(kim_gdata, bts_scr_name); in download_firmware()
301 request_firmware(&kim_gdata->fw_entry, bts_scr_name, in download_firmware()
302 &kim_gdata->kim_pdev->dev); in download_firmware()
303 if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) || in download_firmware()
304 (kim_gdata->fw_entry->size == 0))) { in download_firmware()
309 ptr = (void *)kim_gdata->fw_entry->data; in download_firmware()
310 len = kim_gdata->fw_entry->size; in download_firmware()
344 st_get_uart_wr_room(kim_gdata->core_data); in download_firmware()
348 release_firmware(kim_gdata->fw_entry); in download_firmware()
359 release_firmware(kim_gdata->fw_entry); in download_firmware()
365 reinit_completion(&kim_gdata->kim_rcvd); in download_firmware()
372 err = st_int_write(kim_gdata->core_data, in download_firmware()
376 release_firmware(kim_gdata->fw_entry); in download_firmware()
387 release_firmware(kim_gdata->fw_entry); in download_firmware()
394 &kim_gdata->kim_rcvd, in download_firmware()
399 release_firmware(kim_gdata->fw_entry); in download_firmware()
402 reinit_completion(&kim_gdata->kim_rcvd); in download_firmware()
418 release_firmware(kim_gdata->fw_entry); in download_firmware()
432 struct kim_data_s *kim_gdata = st_gdata->kim_data; in st_kim_recv() local
437 kim_int_recv(kim_gdata, data, count); in st_kim_recv()
446 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; in st_kim_complete() local
447 complete(&kim_gdata->ldisc_installed); in st_kim_complete()
462 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; in st_kim_start() local
465 pdata = kim_gdata->kim_pdev->dev.platform_data; in st_kim_start()
470 pdata->chip_enable(kim_gdata); in st_kim_start()
473 gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW); in st_kim_start()
475 gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_HIGH); in st_kim_start()
478 reinit_completion(&kim_gdata->ldisc_installed); in st_kim_start()
480 kim_gdata->ldisc_install = 1; in st_kim_start()
482 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, in st_kim_start()
486 &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); in st_kim_start()
491 err = st_kim_stop(kim_gdata); in st_kim_start()
496 err = download_firmware(kim_gdata); in st_kim_start()
501 err = st_kim_stop(kim_gdata); in st_kim_start()
524 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; in st_kim_stop() local
526 kim_gdata->kim_pdev->dev.platform_data; in st_kim_stop()
527 struct tty_struct *tty = kim_gdata->core_data->tty; in st_kim_stop()
529 reinit_completion(&kim_gdata->ldisc_installed); in st_kim_stop()
539 kim_gdata->ldisc_install = 0; in st_kim_stop()
540 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install"); in st_kim_stop()
544 &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); in st_kim_stop()
551 gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW); in st_kim_stop()
553 gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_HIGH); in st_kim_stop()
555 gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW); in st_kim_stop()
559 pdata->chip_disable(kim_gdata); in st_kim_stop()
569 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; in show_version() local
570 seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full, in show_version()
571 kim_gdata->version.chip, kim_gdata->version.maj_ver, in show_version()
572 kim_gdata->version.min_ver); in show_version()
578 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; in show_list() local
579 kim_st_list_protocols(kim_gdata->core_data, s); in show_list()
676 struct kim_data_s *kim_gdata; in st_kim_ref() local
681 kim_gdata = platform_get_drvdata(pdev); in st_kim_ref()
682 if (!kim_gdata) in st_kim_ref()
685 *core_data = kim_gdata->core_data; in st_kim_ref()
725 struct kim_data_s *kim_gdata; in kim_probe() local
737 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_KERNEL); in kim_probe()
738 if (!kim_gdata) { in kim_probe()
742 platform_set_drvdata(pdev, kim_gdata); in kim_probe()
744 err = st_core_init(&kim_gdata->core_data); in kim_probe()
751 kim_gdata->core_data->kim_data = kim_gdata; in kim_probe()
754 kim_gdata->nshutdown = pdata->nshutdown_gpio; in kim_probe()
755 err = gpio_request(kim_gdata->nshutdown, "kim"); in kim_probe()
757 pr_err(" gpio %d request failed ", kim_gdata->nshutdown); in kim_probe()
762 err = gpio_direction_output(kim_gdata->nshutdown, 0); in kim_probe()
764 pr_err(" unable to configure gpio %d", kim_gdata->nshutdown); in kim_probe()
769 kim_gdata->kim_pdev = pdev; in kim_probe()
770 init_completion(&kim_gdata->kim_rcvd); in kim_probe()
771 init_completion(&kim_gdata->ldisc_installed); in kim_probe()
780 strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN); in kim_probe()
781 kim_gdata->flow_cntrl = pdata->flow_cntrl; in kim_probe()
782 kim_gdata->baud_rate = pdata->baud_rate; in kim_probe()
792 kim_gdata, &version_debugfs_fops); in kim_probe()
794 kim_gdata, &list_debugfs_fops); in kim_probe()
798 st_core_exit(kim_gdata->core_data); in kim_probe()
801 kfree(kim_gdata); in kim_probe()
810 struct kim_data_s *kim_gdata; in kim_remove() local
812 kim_gdata = platform_get_drvdata(pdev); in kim_remove()
824 kim_gdata->kim_pdev = NULL; in kim_remove()
825 st_core_exit(kim_gdata->core_data); in kim_remove()
827 kfree(kim_gdata); in kim_remove()
828 kim_gdata = NULL; in kim_remove()