Lines Matching refs:kim_gdata
66 void validate_firmware_response(struct kim_data_s *kim_gdata) in validate_firmware_response() argument
68 struct sk_buff *skb = kim_gdata->rx_skb; in validate_firmware_response()
76 complete_all(&kim_gdata->kim_rcvd); in validate_firmware_response()
83 static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) in kim_check_data_len() argument
85 register int room = skb_tailroom(kim_gdata->rx_skb); in kim_check_data_len()
90 validate_firmware_response(kim_gdata); in kim_check_data_len()
97 kfree_skb(kim_gdata->rx_skb); in kim_check_data_len()
102 kim_gdata->rx_state = ST_W4_DATA; in kim_check_data_len()
103 kim_gdata->rx_count = len; in kim_check_data_len()
109 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in kim_check_data_len()
110 kim_gdata->rx_skb = NULL; in kim_check_data_len()
111 kim_gdata->rx_count = 0; in kim_check_data_len()
122 void kim_int_recv(struct kim_data_s *kim_gdata, in kim_int_recv() argument
138 if (kim_gdata->rx_count) { in kim_int_recv()
139 len = min_t(unsigned int, kim_gdata->rx_count, count); in kim_int_recv()
140 memcpy(skb_put(kim_gdata->rx_skb, len), ptr, len); in kim_int_recv()
141 kim_gdata->rx_count -= len; in kim_int_recv()
145 if (kim_gdata->rx_count) in kim_int_recv()
149 switch (kim_gdata->rx_state) { in kim_int_recv()
153 validate_firmware_response(kim_gdata); in kim_int_recv()
154 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in kim_int_recv()
155 kim_gdata->rx_skb = NULL; in kim_int_recv()
160 (unsigned char *)&kim_gdata->rx_skb->data[1]; in kim_int_recv()
162 kim_check_data_len(kim_gdata, *plen); in kim_int_recv()
169 kim_gdata->rx_state = ST_W4_HEADER; in kim_int_recv()
170 kim_gdata->rx_count = 2; in kim_int_recv()
181 kim_gdata->rx_skb = in kim_int_recv()
183 if (!kim_gdata->rx_skb) { in kim_int_recv()
185 kim_gdata->rx_state = ST_W4_PACKET_TYPE; in kim_int_recv()
186 kim_gdata->rx_count = 0; in kim_int_recv()
189 skb_reserve(kim_gdata->rx_skb, 8); in kim_int_recv()
190 kim_gdata->rx_skb->cb[0] = 4; in kim_int_recv()
191 kim_gdata->rx_skb->cb[1] = 0; in kim_int_recv()
197 static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) in read_local_version() argument
204 INIT_COMPLETION(kim_gdata->kim_rcvd); in read_local_version()
205 if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { in read_local_version()
211 (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { in read_local_version()
215 INIT_COMPLETION(kim_gdata->kim_rcvd); in read_local_version()
218 MAKEWORD(kim_gdata->resp_buffer[13], in read_local_version()
219 kim_gdata->resp_buffer[14]); in read_local_version()
230 kim_gdata->version.full = version; in read_local_version()
231 kim_gdata->version.chip = chip; in read_local_version()
232 kim_gdata->version.maj_ver = maj_ver; in read_local_version()
233 kim_gdata->version.min_ver = min_ver; in read_local_version()
264 static long download_firmware(struct kim_data_s *kim_gdata) in download_firmware() argument
275 err = read_local_version(kim_gdata, bts_scr_name); in download_firmware()
281 request_firmware(&kim_gdata->fw_entry, bts_scr_name, in download_firmware()
282 &kim_gdata->kim_pdev->dev); in download_firmware()
283 if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) || in download_firmware()
284 (kim_gdata->fw_entry->size == 0))) { in download_firmware()
289 ptr = (void *)kim_gdata->fw_entry->data; in download_firmware()
290 len = kim_gdata->fw_entry->size; in download_firmware()
324 st_get_uart_wr_room(kim_gdata->core_data); in download_firmware()
328 release_firmware(kim_gdata->fw_entry); in download_firmware()
339 release_firmware(kim_gdata->fw_entry); in download_firmware()
345 INIT_COMPLETION(kim_gdata->kim_rcvd); in download_firmware()
352 err = st_int_write(kim_gdata->core_data, in download_firmware()
356 release_firmware(kim_gdata->fw_entry); in download_firmware()
367 release_firmware(kim_gdata->fw_entry); in download_firmware()
374 (&kim_gdata->kim_rcvd, in download_firmware()
378 release_firmware(kim_gdata->fw_entry); in download_firmware()
381 INIT_COMPLETION(kim_gdata->kim_rcvd); in download_firmware()
397 release_firmware(kim_gdata->fw_entry); in download_firmware()
411 struct kim_data_s *kim_gdata = st_gdata->kim_data; in st_kim_recv() local
416 memcpy(kim_gdata->resp_buffer, data, count); in st_kim_recv()
417 complete_all(&kim_gdata->kim_rcvd); in st_kim_recv()
420 kim_int_recv(kim_gdata, data, count); in st_kim_recv()
431 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; in st_kim_complete() local
432 complete(&kim_gdata->ldisc_installed); in st_kim_complete()
447 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; in st_kim_start() local
450 pdata = kim_gdata->kim_pdev->dev.platform_data; in st_kim_start()
455 pdata->chip_enable(kim_gdata); in st_kim_start()
458 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); in st_kim_start()
460 gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); in st_kim_start()
463 INIT_COMPLETION(kim_gdata->ldisc_installed); in st_kim_start()
465 kim_gdata->ldisc_install = 1; in st_kim_start()
467 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, in st_kim_start()
470 err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, in st_kim_start()
476 err = st_kim_stop(kim_gdata); in st_kim_start()
481 err = download_firmware(kim_gdata); in st_kim_start()
486 err = st_kim_stop(kim_gdata); in st_kim_start()
509 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; in st_kim_stop() local
511 kim_gdata->kim_pdev->dev.platform_data; in st_kim_stop()
512 struct tty_struct *tty = kim_gdata->core_data->tty; in st_kim_stop()
514 INIT_COMPLETION(kim_gdata->ldisc_installed); in st_kim_stop()
525 kim_gdata->ldisc_install = 0; in st_kim_stop()
526 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install"); in st_kim_stop()
529 err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, in st_kim_stop()
537 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); in st_kim_stop()
539 gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); in st_kim_stop()
541 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); in st_kim_stop()
545 pdata->chip_disable(kim_gdata); in st_kim_stop()
555 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; in show_version() local
556 seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full, in show_version()
557 kim_gdata->version.chip, kim_gdata->version.maj_ver, in show_version()
558 kim_gdata->version.min_ver); in show_version()
564 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; in show_list() local
565 kim_st_list_protocols(kim_gdata->core_data, s); in show_list()
662 struct kim_data_s *kim_gdata; in st_kim_ref() local
669 kim_gdata = dev_get_drvdata(&pdev->dev); in st_kim_ref()
670 *core_data = kim_gdata->core_data; in st_kim_ref()
708 struct kim_data_s *kim_gdata; in kim_probe() local
719 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC); in kim_probe()
720 if (!kim_gdata) { in kim_probe()
724 dev_set_drvdata(&pdev->dev, kim_gdata); in kim_probe()
726 status = st_core_init(&kim_gdata->core_data); in kim_probe()
732 kim_gdata->core_data->kim_data = kim_gdata; in kim_probe()
735 kim_gdata->nshutdown = pdata->nshutdown_gpio; in kim_probe()
736 status = gpio_request(kim_gdata->nshutdown, "kim"); in kim_probe()
738 pr_err(" gpio %ld request failed ", kim_gdata->nshutdown); in kim_probe()
743 status = gpio_direction_output(kim_gdata->nshutdown, 0); in kim_probe()
745 pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown); in kim_probe()
750 kim_gdata->kim_pdev = pdev; in kim_probe()
751 init_completion(&kim_gdata->kim_rcvd); in kim_probe()
752 init_completion(&kim_gdata->ldisc_installed); in kim_probe()
761 strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN); in kim_probe()
762 kim_gdata->flow_cntrl = pdata->flow_cntrl; in kim_probe()
763 kim_gdata->baud_rate = pdata->baud_rate; in kim_probe()
774 kim_gdata, &version_debugfs_fops); in kim_probe()
776 kim_gdata, &list_debugfs_fops); in kim_probe()
785 struct kim_data_s *kim_gdata; in kim_remove() local
787 kim_gdata = dev_get_drvdata(&pdev->dev); in kim_remove()
799 kim_gdata->kim_pdev = NULL; in kim_remove()
800 st_core_exit(kim_gdata->core_data); in kim_remove()
802 kfree(kim_gdata); in kim_remove()
803 kim_gdata = NULL; in kim_remove()