diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-16 18:05:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-16 18:05:40 -0400 |
commit | a5e6b135bdff649e4330f98e2e80dbb1984f7e77 (patch) | |
tree | 475bfb1163c59d1370fd77415255afba768f9520 /drivers/misc | |
parent | 971f115a50afbe409825c9f3399d5a3b9aca4381 (diff) | |
parent | 9d90c8d9cde929cbc575098e825d7c29d9f45054 (diff) |
Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (50 commits)
printk: do not mangle valid userspace syslog prefixes
efivars: Add Documentation
efivars: Expose efivars functionality to external drivers.
efivars: Parameterize operations.
efivars: Split out variable registration
efivars: parameterize efivars
efivars: Make efivars bin_attributes dynamic
efivars: move efivars globals into struct efivars
drivers:misc: ti-st: fix debugging code
kref: Fix typo in kref documentation
UIO: add PRUSS UIO driver support
Fix spelling mistakes in Documentation/zh_CN/SubmittingPatches
firmware: Fix unaligned memory accesses in dmi-sysfs
firmware: Add documentation for /sys/firmware/dmi
firmware: Expose DMI type 15 System Event Log
firmware: Break out system_event_log in dmi-sysfs
firmware: Basic dmi-sysfs support
firmware: Add DMI entry types to the headers
Driver core: convert platform_{get,set}_drvdata to static inline functions
Translate linux-2.6/Documentation/magic-number.txt into Chinese
...
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/Kconfig | 7 | ||||
-rw-r--r-- | drivers/misc/pch_phub.c | 69 | ||||
-rw-r--r-- | drivers/misc/ti-st/st_core.c | 419 | ||||
-rw-r--r-- | drivers/misc/ti-st/st_kim.c | 491 | ||||
-rw-r--r-- | drivers/misc/ti-st/st_ll.c | 10 |
5 files changed, 448 insertions, 548 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index cc8e49db45fe..b7d5ef234ac9 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -441,7 +441,7 @@ config BMP085 | |||
441 | module will be called bmp085. | 441 | module will be called bmp085. |
442 | 442 | ||
443 | config PCH_PHUB | 443 | config PCH_PHUB |
444 | tristate "PCH Packet Hub of Intel Topcliff" | 444 | tristate "PCH Packet Hub of Intel Topcliff / OKI SEMICONDUCTOR ML7213" |
445 | depends on PCI | 445 | depends on PCI |
446 | help | 446 | help |
447 | This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of | 447 | This driver is for PCH(Platform controller Hub) PHUB(Packet Hub) of |
@@ -449,6 +449,11 @@ config PCH_PHUB | |||
449 | processor. The Topcliff has MAC address and Option ROM data in SROM. | 449 | processor. The Topcliff has MAC address and Option ROM data in SROM. |
450 | This driver can access MAC address and Option ROM data in SROM. | 450 | This driver can access MAC address and Option ROM data in SROM. |
451 | 451 | ||
452 | This driver also can be used for OKI SEMICONDUCTOR's ML7213 which is | ||
453 | for IVI(In-Vehicle Infotainment) use. | ||
454 | ML7213 is companion chip for Intel Atom E6xx series. | ||
455 | ML7213 is completely compatible for Intel EG20T PCH. | ||
456 | |||
452 | To compile this driver as a module, choose M here: the module will | 457 | To compile this driver as a module, choose M here: the module will |
453 | be called pch_phub. | 458 | be called pch_phub. |
454 | 459 | ||
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 744b804aca15..98bffc471b17 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. | 2 | * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 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 | 5 | * it under the terms of the GNU General Public License as published by |
@@ -33,7 +33,12 @@ | |||
33 | #define PHUB_TIMEOUT 0x05 /* Time out value for Status Register */ | 33 | #define PHUB_TIMEOUT 0x05 /* Time out value for Status Register */ |
34 | #define PCH_PHUB_ROM_WRITE_ENABLE 0x01 /* Enabling for writing ROM */ | 34 | #define PCH_PHUB_ROM_WRITE_ENABLE 0x01 /* Enabling for writing ROM */ |
35 | #define PCH_PHUB_ROM_WRITE_DISABLE 0x00 /* Disabling for writing ROM */ | 35 | #define PCH_PHUB_ROM_WRITE_DISABLE 0x00 /* Disabling for writing ROM */ |
36 | #define PCH_PHUB_ROM_START_ADDR 0x14 /* ROM data area start address offset */ | 36 | #define PCH_PHUB_MAC_START_ADDR 0x20C /* MAC data area start address offset */ |
37 | #define PCH_PHUB_ROM_START_ADDR_EG20T 0x14 /* ROM data area start address offset | ||
38 | (Intel EG20T PCH)*/ | ||
39 | #define PCH_PHUB_ROM_START_ADDR_ML7213 0x400 /* ROM data area start address | ||
40 | offset(OKI SEMICONDUCTOR ML7213) | ||
41 | */ | ||
37 | 42 | ||
38 | /* MAX number of INT_REDUCE_CONTROL registers */ | 43 | /* MAX number of INT_REDUCE_CONTROL registers */ |
39 | #define MAX_NUM_INT_REDUCE_CONTROL_REG 128 | 44 | #define MAX_NUM_INT_REDUCE_CONTROL_REG 128 |
@@ -42,6 +47,10 @@ | |||
42 | #define CLKCFG_CAN_50MHZ 0x12000000 | 47 | #define CLKCFG_CAN_50MHZ 0x12000000 |
43 | #define CLKCFG_CANCLK_MASK 0xFF000000 | 48 | #define CLKCFG_CANCLK_MASK 0xFF000000 |
44 | 49 | ||
50 | /* Macros for ML7213 */ | ||
51 | #define PCI_VENDOR_ID_ROHM 0x10db | ||
52 | #define PCI_DEVICE_ID_ROHM_ML7213_PHUB 0x801A | ||
53 | |||
45 | /* SROM ACCESS Macro */ | 54 | /* SROM ACCESS Macro */ |
46 | #define PCH_WORD_ADDR_MASK (~((1 << 2) - 1)) | 55 | #define PCH_WORD_ADDR_MASK (~((1 << 2) - 1)) |
47 | 56 | ||
@@ -298,7 +307,7 @@ static void pch_phub_read_serial_rom_val(struct pch_phub_reg *chip, | |||
298 | { | 307 | { |
299 | unsigned int mem_addr; | 308 | unsigned int mem_addr; |
300 | 309 | ||
301 | mem_addr = PCH_PHUB_ROM_START_ADDR + | 310 | mem_addr = PCH_PHUB_ROM_START_ADDR_EG20T + |
302 | pch_phub_mac_offset[offset_address]; | 311 | pch_phub_mac_offset[offset_address]; |
303 | 312 | ||
304 | pch_phub_read_serial_rom(chip, mem_addr, data); | 313 | pch_phub_read_serial_rom(chip, mem_addr, data); |
@@ -315,7 +324,7 @@ static int pch_phub_write_serial_rom_val(struct pch_phub_reg *chip, | |||
315 | int retval; | 324 | int retval; |
316 | unsigned int mem_addr; | 325 | unsigned int mem_addr; |
317 | 326 | ||
318 | mem_addr = PCH_PHUB_ROM_START_ADDR + | 327 | mem_addr = PCH_PHUB_ROM_START_ADDR_EG20T + |
319 | pch_phub_mac_offset[offset_address]; | 328 | pch_phub_mac_offset[offset_address]; |
320 | 329 | ||
321 | retval = pch_phub_write_serial_rom(chip, mem_addr, data); | 330 | retval = pch_phub_write_serial_rom(chip, mem_addr, data); |
@@ -594,23 +603,38 @@ static int __devinit pch_phub_probe(struct pci_dev *pdev, | |||
594 | "pch_phub_extrom_base_address variable is %p\n", __func__, | 603 | "pch_phub_extrom_base_address variable is %p\n", __func__, |
595 | chip->pch_phub_extrom_base_address); | 604 | chip->pch_phub_extrom_base_address); |
596 | 605 | ||
597 | pci_set_drvdata(pdev, chip); | 606 | if (id->driver_data == 1) { |
598 | 607 | retval = sysfs_create_file(&pdev->dev.kobj, | |
599 | retval = sysfs_create_file(&pdev->dev.kobj, &dev_attr_pch_mac.attr); | 608 | &dev_attr_pch_mac.attr); |
600 | if (retval) | 609 | if (retval) |
601 | goto err_sysfs_create; | 610 | goto err_sysfs_create; |
602 | |||
603 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); | ||
604 | if (retval) | ||
605 | goto exit_bin_attr; | ||
606 | |||
607 | pch_phub_read_modify_write_reg(chip, (unsigned int)CLKCFG_REG_OFFSET, | ||
608 | CLKCFG_CAN_50MHZ, CLKCFG_CANCLK_MASK); | ||
609 | 611 | ||
610 | /* set the prefech value */ | 612 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); |
611 | iowrite32(0x000affaa, chip->pch_phub_base_address + 0x14); | 613 | if (retval) |
612 | /* set the interrupt delay value */ | 614 | goto exit_bin_attr; |
613 | iowrite32(0x25, chip->pch_phub_base_address + 0x44); | 615 | |
616 | pch_phub_read_modify_write_reg(chip, | ||
617 | (unsigned int)CLKCFG_REG_OFFSET, | ||
618 | CLKCFG_CAN_50MHZ, | ||
619 | CLKCFG_CANCLK_MASK); | ||
620 | |||
621 | /* set the prefech value */ | ||
622 | iowrite32(0x000affaa, chip->pch_phub_base_address + 0x14); | ||
623 | /* set the interrupt delay value */ | ||
624 | iowrite32(0x25, chip->pch_phub_base_address + 0x44); | ||
625 | } else if (id->driver_data == 2) { | ||
626 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pch_bin_attr); | ||
627 | if (retval) | ||
628 | goto err_sysfs_create; | ||
629 | /* set the prefech value | ||
630 | * Device2(USB OHCI #1/ USB EHCI #1/ USB Device):a | ||
631 | * Device4(SDIO #0,1,2):f | ||
632 | * Device6(SATA 2):f | ||
633 | * Device8(USB OHCI #0/ USB EHCI #0):a | ||
634 | */ | ||
635 | iowrite32(0x000affa0, chip->pch_phub_base_address + 0x14); | ||
636 | } | ||
637 | pci_set_drvdata(pdev, chip); | ||
614 | 638 | ||
615 | return 0; | 639 | return 0; |
616 | exit_bin_attr: | 640 | exit_bin_attr: |
@@ -687,8 +711,9 @@ static int pch_phub_resume(struct pci_dev *pdev) | |||
687 | #endif /* CONFIG_PM */ | 711 | #endif /* CONFIG_PM */ |
688 | 712 | ||
689 | static struct pci_device_id pch_phub_pcidev_id[] = { | 713 | static struct pci_device_id pch_phub_pcidev_id[] = { |
690 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PCH1_PHUB)}, | 714 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB), 1, }, |
691 | {0,} | 715 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ROHM_ML7213_PHUB), 2, }, |
716 | { } | ||
692 | }; | 717 | }; |
693 | 718 | ||
694 | static struct pci_driver pch_phub_driver = { | 719 | static struct pci_driver pch_phub_driver = { |
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index f9aad06d1ae5..486117f72c9f 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c | |||
@@ -25,10 +25,9 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/tty.h> | 26 | #include <linux/tty.h> |
27 | 27 | ||
28 | /* understand BT, FM and GPS for now */ | 28 | #include <linux/seq_file.h> |
29 | #include <net/bluetooth/bluetooth.h> | 29 | #include <linux/skbuff.h> |
30 | #include <net/bluetooth/hci_core.h> | 30 | |
31 | #include <net/bluetooth/hci.h> | ||
32 | #include <linux/ti_wilink_st.h> | 31 | #include <linux/ti_wilink_st.h> |
33 | 32 | ||
34 | /* function pointer pointing to either, | 33 | /* function pointer pointing to either, |
@@ -38,21 +37,38 @@ | |||
38 | void (*st_recv) (void*, const unsigned char*, long); | 37 | void (*st_recv) (void*, const unsigned char*, long); |
39 | 38 | ||
40 | /********************************************************************/ | 39 | /********************************************************************/ |
41 | #if 0 | 40 | static void add_channel_to_table(struct st_data_s *st_gdata, |
42 | /* internal misc functions */ | 41 | struct st_proto_s *new_proto) |
43 | bool is_protocol_list_empty(void) | ||
44 | { | 42 | { |
45 | unsigned char i = 0; | 43 | pr_info("%s: id %d\n", __func__, new_proto->chnl_id); |
46 | pr_debug(" %s ", __func__); | 44 | /* list now has the channel id as index itself */ |
47 | for (i = 0; i < ST_MAX; i++) { | 45 | st_gdata->list[new_proto->chnl_id] = new_proto; |
48 | if (st_gdata->list[i] != NULL) | 46 | } |
49 | return ST_NOTEMPTY; | 47 | |
50 | /* not empty */ | 48 | static void remove_channel_from_table(struct st_data_s *st_gdata, |
49 | struct st_proto_s *proto) | ||
50 | { | ||
51 | pr_info("%s: id %d\n", __func__, proto->chnl_id); | ||
52 | st_gdata->list[proto->chnl_id] = NULL; | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | * called from KIM during firmware download. | ||
57 | * | ||
58 | * This is a wrapper function to tty->ops->write_room. | ||
59 | * It returns number of free space available in | ||
60 | * uart tx buffer. | ||
61 | */ | ||
62 | int st_get_uart_wr_room(struct st_data_s *st_gdata) | ||
63 | { | ||
64 | struct tty_struct *tty; | ||
65 | if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { | ||
66 | pr_err("tty unavailable to perform write"); | ||
67 | return -1; | ||
51 | } | 68 | } |
52 | /* list empty */ | 69 | tty = st_gdata->tty; |
53 | return ST_EMPTY; | 70 | return tty->ops->write_room(tty); |
54 | } | 71 | } |
55 | #endif | ||
56 | 72 | ||
57 | /* can be called in from | 73 | /* can be called in from |
58 | * -- KIM (during fw download) | 74 | * -- KIM (during fw download) |
@@ -67,7 +83,7 @@ int st_int_write(struct st_data_s *st_gdata, | |||
67 | struct tty_struct *tty; | 83 | struct tty_struct *tty; |
68 | if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { | 84 | if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { |
69 | pr_err("tty unavailable to perform write"); | 85 | pr_err("tty unavailable to perform write"); |
70 | return -1; | 86 | return -EINVAL; |
71 | } | 87 | } |
72 | tty = st_gdata->tty; | 88 | tty = st_gdata->tty; |
73 | #ifdef VERBOSE | 89 | #ifdef VERBOSE |
@@ -82,15 +98,15 @@ int st_int_write(struct st_data_s *st_gdata, | |||
82 | * push the skb received to relevant | 98 | * push the skb received to relevant |
83 | * protocol stacks | 99 | * protocol stacks |
84 | */ | 100 | */ |
85 | void st_send_frame(enum proto_type protoid, struct st_data_s *st_gdata) | 101 | void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) |
86 | { | 102 | { |
87 | pr_info(" %s(prot:%d) ", __func__, protoid); | 103 | pr_debug(" %s(prot:%d) ", __func__, chnl_id); |
88 | 104 | ||
89 | if (unlikely | 105 | if (unlikely |
90 | (st_gdata == NULL || st_gdata->rx_skb == NULL | 106 | (st_gdata == NULL || st_gdata->rx_skb == NULL |
91 | || st_gdata->list[protoid] == NULL)) { | 107 | || st_gdata->list[chnl_id] == NULL)) { |
92 | pr_err("protocol %d not registered, no data to send?", | 108 | pr_err("chnl_id %d not registered, no data to send?", |
93 | protoid); | 109 | chnl_id); |
94 | kfree_skb(st_gdata->rx_skb); | 110 | kfree_skb(st_gdata->rx_skb); |
95 | return; | 111 | return; |
96 | } | 112 | } |
@@ -99,17 +115,17 @@ void st_send_frame(enum proto_type protoid, struct st_data_s *st_gdata) | |||
99 | * - should be just skb_queue_tail for the | 115 | * - should be just skb_queue_tail for the |
100 | * protocol stack driver | 116 | * protocol stack driver |
101 | */ | 117 | */ |
102 | if (likely(st_gdata->list[protoid]->recv != NULL)) { | 118 | if (likely(st_gdata->list[chnl_id]->recv != NULL)) { |
103 | if (unlikely | 119 | if (unlikely |
104 | (st_gdata->list[protoid]->recv | 120 | (st_gdata->list[chnl_id]->recv |
105 | (st_gdata->list[protoid]->priv_data, st_gdata->rx_skb) | 121 | (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb) |
106 | != 0)) { | 122 | != 0)) { |
107 | pr_err(" proto stack %d's ->recv failed", protoid); | 123 | pr_err(" proto stack %d's ->recv failed", chnl_id); |
108 | kfree_skb(st_gdata->rx_skb); | 124 | kfree_skb(st_gdata->rx_skb); |
109 | return; | 125 | return; |
110 | } | 126 | } |
111 | } else { | 127 | } else { |
112 | pr_err(" proto stack %d's ->recv null", protoid); | 128 | pr_err(" proto stack %d's ->recv null", chnl_id); |
113 | kfree_skb(st_gdata->rx_skb); | 129 | kfree_skb(st_gdata->rx_skb); |
114 | } | 130 | } |
115 | return; | 131 | return; |
@@ -124,16 +140,22 @@ void st_reg_complete(struct st_data_s *st_gdata, char err) | |||
124 | { | 140 | { |
125 | unsigned char i = 0; | 141 | unsigned char i = 0; |
126 | pr_info(" %s ", __func__); | 142 | pr_info(" %s ", __func__); |
127 | for (i = 0; i < ST_MAX; i++) { | 143 | for (i = 0; i < ST_MAX_CHANNELS; i++) { |
128 | if (likely(st_gdata != NULL && st_gdata->list[i] != NULL && | 144 | if (likely(st_gdata != NULL && st_gdata->list[i] != NULL && |
129 | st_gdata->list[i]->reg_complete_cb != NULL)) | 145 | st_gdata->list[i]->reg_complete_cb != NULL)) { |
130 | st_gdata->list[i]->reg_complete_cb | 146 | st_gdata->list[i]->reg_complete_cb |
131 | (st_gdata->list[i]->priv_data, err); | 147 | (st_gdata->list[i]->priv_data, err); |
148 | pr_info("protocol %d's cb sent %d\n", i, err); | ||
149 | if (err) { /* cleanup registered protocol */ | ||
150 | st_gdata->protos_registered--; | ||
151 | st_gdata->list[i] = NULL; | ||
152 | } | ||
153 | } | ||
132 | } | 154 | } |
133 | } | 155 | } |
134 | 156 | ||
135 | static inline int st_check_data_len(struct st_data_s *st_gdata, | 157 | static inline int st_check_data_len(struct st_data_s *st_gdata, |
136 | int protoid, int len) | 158 | unsigned char chnl_id, int len) |
137 | { | 159 | { |
138 | int room = skb_tailroom(st_gdata->rx_skb); | 160 | int room = skb_tailroom(st_gdata->rx_skb); |
139 | 161 | ||
@@ -144,7 +166,7 @@ static inline int st_check_data_len(struct st_data_s *st_gdata, | |||
144 | * has zero length payload. So, ask ST CORE to | 166 | * has zero length payload. So, ask ST CORE to |
145 | * forward the packet to protocol driver (BT/FM/GPS) | 167 | * forward the packet to protocol driver (BT/FM/GPS) |
146 | */ | 168 | */ |
147 | st_send_frame(protoid, st_gdata); | 169 | st_send_frame(chnl_id, st_gdata); |
148 | 170 | ||
149 | } else if (len > room) { | 171 | } else if (len > room) { |
150 | /* Received packet's payload length is larger. | 172 | /* Received packet's payload length is larger. |
@@ -157,7 +179,7 @@ static inline int st_check_data_len(struct st_data_s *st_gdata, | |||
157 | /* Packet header has non-zero payload length and | 179 | /* Packet header has non-zero payload length and |
158 | * we have enough space in created skb. Lets read | 180 | * we have enough space in created skb. Lets read |
159 | * payload data */ | 181 | * payload data */ |
160 | st_gdata->rx_state = ST_BT_W4_DATA; | 182 | st_gdata->rx_state = ST_W4_DATA; |
161 | st_gdata->rx_count = len; | 183 | st_gdata->rx_count = len; |
162 | return len; | 184 | return len; |
163 | } | 185 | } |
@@ -167,6 +189,7 @@ static inline int st_check_data_len(struct st_data_s *st_gdata, | |||
167 | st_gdata->rx_state = ST_W4_PACKET_TYPE; | 189 | st_gdata->rx_state = ST_W4_PACKET_TYPE; |
168 | st_gdata->rx_skb = NULL; | 190 | st_gdata->rx_skb = NULL; |
169 | st_gdata->rx_count = 0; | 191 | st_gdata->rx_count = 0; |
192 | st_gdata->rx_chnl = 0; | ||
170 | 193 | ||
171 | return 0; | 194 | return 0; |
172 | } | 195 | } |
@@ -208,14 +231,12 @@ void st_int_recv(void *disc_data, | |||
208 | const unsigned char *data, long count) | 231 | const unsigned char *data, long count) |
209 | { | 232 | { |
210 | char *ptr; | 233 | char *ptr; |
211 | struct hci_event_hdr *eh; | 234 | struct st_proto_s *proto; |
212 | struct hci_acl_hdr *ah; | 235 | unsigned short payload_len = 0; |
213 | struct hci_sco_hdr *sh; | 236 | int len = 0, type = 0; |
214 | struct fm_event_hdr *fm; | 237 | unsigned char *plen; |
215 | struct gps_event_hdr *gps; | ||
216 | int len = 0, type = 0, dlen = 0; | ||
217 | static enum proto_type protoid = ST_MAX; | ||
218 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; | 238 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; |
239 | unsigned long flags; | ||
219 | 240 | ||
220 | ptr = (char *)data; | 241 | ptr = (char *)data; |
221 | /* tty_receive sent null ? */ | 242 | /* tty_receive sent null ? */ |
@@ -224,10 +245,11 @@ void st_int_recv(void *disc_data, | |||
224 | return; | 245 | return; |
225 | } | 246 | } |
226 | 247 | ||
227 | pr_info("count %ld rx_state %ld" | 248 | pr_debug("count %ld rx_state %ld" |
228 | "rx_count %ld", count, st_gdata->rx_state, | 249 | "rx_count %ld", count, st_gdata->rx_state, |
229 | st_gdata->rx_count); | 250 | st_gdata->rx_count); |
230 | 251 | ||
252 | spin_lock_irqsave(&st_gdata->lock, flags); | ||
231 | /* Decode received bytes here */ | 253 | /* Decode received bytes here */ |
232 | while (count) { | 254 | while (count) { |
233 | if (st_gdata->rx_count) { | 255 | if (st_gdata->rx_count) { |
@@ -242,64 +264,36 @@ void st_int_recv(void *disc_data, | |||
242 | 264 | ||
243 | /* Check ST RX state machine , where are we? */ | 265 | /* Check ST RX state machine , where are we? */ |
244 | switch (st_gdata->rx_state) { | 266 | switch (st_gdata->rx_state) { |
245 | 267 | /* Waiting for complete packet ? */ | |
246 | /* Waiting for complete packet ? */ | 268 | case ST_W4_DATA: |
247 | case ST_BT_W4_DATA: | ||
248 | pr_debug("Complete pkt received"); | 269 | pr_debug("Complete pkt received"); |
249 | |||
250 | /* Ask ST CORE to forward | 270 | /* Ask ST CORE to forward |
251 | * the packet to protocol driver */ | 271 | * the packet to protocol driver */ |
252 | st_send_frame(protoid, st_gdata); | 272 | st_send_frame(st_gdata->rx_chnl, st_gdata); |
253 | 273 | ||
254 | st_gdata->rx_state = ST_W4_PACKET_TYPE; | 274 | st_gdata->rx_state = ST_W4_PACKET_TYPE; |
255 | st_gdata->rx_skb = NULL; | 275 | st_gdata->rx_skb = NULL; |
256 | protoid = ST_MAX; /* is this required ? */ | ||
257 | continue; | 276 | continue; |
258 | 277 | /* parse the header to know details */ | |
259 | /* Waiting for Bluetooth event header ? */ | 278 | case ST_W4_HEADER: |
260 | case ST_BT_W4_EVENT_HDR: | 279 | proto = st_gdata->list[st_gdata->rx_chnl]; |
261 | eh = (struct hci_event_hdr *)st_gdata->rx_skb-> | 280 | plen = |
262 | data; | 281 | &st_gdata->rx_skb->data |
263 | 282 | [proto->offset_len_in_hdr]; | |
264 | pr_debug("Event header: evt 0x%2.2x" | 283 | pr_debug("plen pointing to %x\n", *plen); |
265 | "plen %d", eh->evt, eh->plen); | 284 | if (proto->len_size == 1)/* 1 byte len field */ |
266 | 285 | payload_len = *(unsigned char *)plen; | |
267 | st_check_data_len(st_gdata, protoid, eh->plen); | 286 | else if (proto->len_size == 2) |
268 | continue; | 287 | payload_len = |
269 | 288 | __le16_to_cpu(*(unsigned short *)plen); | |
270 | /* Waiting for Bluetooth acl header ? */ | 289 | else |
271 | case ST_BT_W4_ACL_HDR: | 290 | pr_info("%s: invalid length " |
272 | ah = (struct hci_acl_hdr *)st_gdata->rx_skb-> | 291 | "for id %d\n", |
273 | data; | 292 | __func__, proto->chnl_id); |
274 | dlen = __le16_to_cpu(ah->dlen); | 293 | st_check_data_len(st_gdata, proto->chnl_id, |
275 | 294 | payload_len); | |
276 | pr_info("ACL header: dlen %d", dlen); | 295 | pr_debug("off %d, pay len %d\n", |
277 | 296 | proto->offset_len_in_hdr, payload_len); | |
278 | st_check_data_len(st_gdata, protoid, dlen); | ||
279 | continue; | ||
280 | |||
281 | /* Waiting for Bluetooth sco header ? */ | ||
282 | case ST_BT_W4_SCO_HDR: | ||
283 | sh = (struct hci_sco_hdr *)st_gdata->rx_skb-> | ||
284 | data; | ||
285 | |||
286 | pr_info("SCO header: dlen %d", sh->dlen); | ||
287 | |||
288 | st_check_data_len(st_gdata, protoid, sh->dlen); | ||
289 | continue; | ||
290 | case ST_FM_W4_EVENT_HDR: | ||
291 | fm = (struct fm_event_hdr *)st_gdata->rx_skb-> | ||
292 | data; | ||
293 | pr_info("FM Header: "); | ||
294 | st_check_data_len(st_gdata, ST_FM, fm->plen); | ||
295 | continue; | ||
296 | /* TODO : Add GPS packet machine logic here */ | ||
297 | case ST_GPS_W4_EVENT_HDR: | ||
298 | /* [0x09 pkt hdr][R/W byte][2 byte len] */ | ||
299 | gps = (struct gps_event_hdr *)st_gdata->rx_skb-> | ||
300 | data; | ||
301 | pr_info("GPS Header: "); | ||
302 | st_check_data_len(st_gdata, ST_GPS, gps->plen); | ||
303 | continue; | 297 | continue; |
304 | } /* end of switch rx_state */ | 298 | } /* end of switch rx_state */ |
305 | } | 299 | } |
@@ -308,123 +302,56 @@ void st_int_recv(void *disc_data, | |||
308 | /* Check first byte of packet and identify module | 302 | /* Check first byte of packet and identify module |
309 | * owner (BT/FM/GPS) */ | 303 | * owner (BT/FM/GPS) */ |
310 | switch (*ptr) { | 304 | switch (*ptr) { |
311 | |||
312 | /* Bluetooth event packet? */ | ||
313 | case HCI_EVENT_PKT: | ||
314 | pr_info("Event packet"); | ||
315 | st_gdata->rx_state = ST_BT_W4_EVENT_HDR; | ||
316 | st_gdata->rx_count = HCI_EVENT_HDR_SIZE; | ||
317 | type = HCI_EVENT_PKT; | ||
318 | protoid = ST_BT; | ||
319 | break; | ||
320 | |||
321 | /* Bluetooth acl packet? */ | ||
322 | case HCI_ACLDATA_PKT: | ||
323 | pr_info("ACL packet"); | ||
324 | st_gdata->rx_state = ST_BT_W4_ACL_HDR; | ||
325 | st_gdata->rx_count = HCI_ACL_HDR_SIZE; | ||
326 | type = HCI_ACLDATA_PKT; | ||
327 | protoid = ST_BT; | ||
328 | break; | ||
329 | |||
330 | /* Bluetooth sco packet? */ | ||
331 | case HCI_SCODATA_PKT: | ||
332 | pr_info("SCO packet"); | ||
333 | st_gdata->rx_state = ST_BT_W4_SCO_HDR; | ||
334 | st_gdata->rx_count = HCI_SCO_HDR_SIZE; | ||
335 | type = HCI_SCODATA_PKT; | ||
336 | protoid = ST_BT; | ||
337 | break; | ||
338 | |||
339 | /* Channel 8(FM) packet? */ | ||
340 | case ST_FM_CH8_PKT: | ||
341 | pr_info("FM CH8 packet"); | ||
342 | type = ST_FM_CH8_PKT; | ||
343 | st_gdata->rx_state = ST_FM_W4_EVENT_HDR; | ||
344 | st_gdata->rx_count = FM_EVENT_HDR_SIZE; | ||
345 | protoid = ST_FM; | ||
346 | break; | ||
347 | |||
348 | /* Channel 9(GPS) packet? */ | ||
349 | case 0x9: /*ST_LL_GPS_CH9_PKT */ | ||
350 | pr_info("GPS CH9 packet"); | ||
351 | type = 0x9; /* ST_LL_GPS_CH9_PKT; */ | ||
352 | protoid = ST_GPS; | ||
353 | st_gdata->rx_state = ST_GPS_W4_EVENT_HDR; | ||
354 | st_gdata->rx_count = 3; /* GPS_EVENT_HDR_SIZE -1*/ | ||
355 | break; | ||
356 | case LL_SLEEP_IND: | 305 | case LL_SLEEP_IND: |
357 | case LL_SLEEP_ACK: | 306 | case LL_SLEEP_ACK: |
358 | case LL_WAKE_UP_IND: | 307 | case LL_WAKE_UP_IND: |
359 | pr_info("PM packet"); | 308 | pr_debug("PM packet"); |
360 | /* this takes appropriate action based on | 309 | /* this takes appropriate action based on |
361 | * sleep state received -- | 310 | * sleep state received -- |
362 | */ | 311 | */ |
363 | st_ll_sleep_state(st_gdata, *ptr); | 312 | st_ll_sleep_state(st_gdata, *ptr); |
313 | /* if WAKEUP_IND collides copy from waitq to txq | ||
314 | * and assume chip awake | ||
315 | */ | ||
316 | spin_unlock_irqrestore(&st_gdata->lock, flags); | ||
317 | if (st_ll_getstate(st_gdata) == ST_LL_AWAKE) | ||
318 | st_wakeup_ack(st_gdata, LL_WAKE_UP_ACK); | ||
319 | spin_lock_irqsave(&st_gdata->lock, flags); | ||
320 | |||
364 | ptr++; | 321 | ptr++; |
365 | count--; | 322 | count--; |
366 | continue; | 323 | continue; |
367 | case LL_WAKE_UP_ACK: | 324 | case LL_WAKE_UP_ACK: |
368 | pr_info("PM packet"); | 325 | pr_debug("PM packet"); |
326 | |||
327 | spin_unlock_irqrestore(&st_gdata->lock, flags); | ||
369 | /* wake up ack received */ | 328 | /* wake up ack received */ |
370 | st_wakeup_ack(st_gdata, *ptr); | 329 | st_wakeup_ack(st_gdata, *ptr); |
330 | spin_lock_irqsave(&st_gdata->lock, flags); | ||
331 | |||
371 | ptr++; | 332 | ptr++; |
372 | count--; | 333 | count--; |
373 | continue; | 334 | continue; |
374 | /* Unknow packet? */ | 335 | /* Unknow packet? */ |
375 | default: | 336 | default: |
376 | pr_err("Unknown packet type %2.2x", (__u8) *ptr); | 337 | type = *ptr; |
377 | ptr++; | 338 | st_gdata->rx_skb = alloc_skb( |
378 | count--; | 339 | st_gdata->list[type]->max_frame_size, |
379 | continue; | 340 | GFP_ATOMIC); |
341 | skb_reserve(st_gdata->rx_skb, | ||
342 | st_gdata->list[type]->reserve); | ||
343 | /* next 2 required for BT only */ | ||
344 | st_gdata->rx_skb->cb[0] = type; /*pkt_type*/ | ||
345 | st_gdata->rx_skb->cb[1] = 0; /*incoming*/ | ||
346 | st_gdata->rx_chnl = *ptr; | ||
347 | st_gdata->rx_state = ST_W4_HEADER; | ||
348 | st_gdata->rx_count = st_gdata->list[type]->hdr_len; | ||
349 | pr_debug("rx_count %ld\n", st_gdata->rx_count); | ||
380 | }; | 350 | }; |
381 | ptr++; | 351 | ptr++; |
382 | count--; | 352 | count--; |
383 | |||
384 | switch (protoid) { | ||
385 | case ST_BT: | ||
386 | /* Allocate new packet to hold received data */ | ||
387 | st_gdata->rx_skb = | ||
388 | bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); | ||
389 | if (!st_gdata->rx_skb) { | ||
390 | pr_err("Can't allocate mem for new packet"); | ||
391 | st_gdata->rx_state = ST_W4_PACKET_TYPE; | ||
392 | st_gdata->rx_count = 0; | ||
393 | return; | ||
394 | } | ||
395 | bt_cb(st_gdata->rx_skb)->pkt_type = type; | ||
396 | break; | ||
397 | case ST_FM: /* for FM */ | ||
398 | st_gdata->rx_skb = | ||
399 | alloc_skb(FM_MAX_FRAME_SIZE, GFP_ATOMIC); | ||
400 | if (!st_gdata->rx_skb) { | ||
401 | pr_err("Can't allocate mem for new packet"); | ||
402 | st_gdata->rx_state = ST_W4_PACKET_TYPE; | ||
403 | st_gdata->rx_count = 0; | ||
404 | return; | ||
405 | } | ||
406 | /* place holder 0x08 */ | ||
407 | skb_reserve(st_gdata->rx_skb, 1); | ||
408 | st_gdata->rx_skb->cb[0] = ST_FM_CH8_PKT; | ||
409 | break; | ||
410 | case ST_GPS: | ||
411 | /* for GPS */ | ||
412 | st_gdata->rx_skb = | ||
413 | alloc_skb(100 /*GPS_MAX_FRAME_SIZE */ , GFP_ATOMIC); | ||
414 | if (!st_gdata->rx_skb) { | ||
415 | pr_err("Can't allocate mem for new packet"); | ||
416 | st_gdata->rx_state = ST_W4_PACKET_TYPE; | ||
417 | st_gdata->rx_count = 0; | ||
418 | return; | ||
419 | } | ||
420 | /* place holder 0x09 */ | ||
421 | skb_reserve(st_gdata->rx_skb, 1); | ||
422 | st_gdata->rx_skb->cb[0] = 0x09; /*ST_GPS_CH9_PKT; */ | ||
423 | break; | ||
424 | case ST_MAX: | ||
425 | break; | ||
426 | } | ||
427 | } | 353 | } |
354 | spin_unlock_irqrestore(&st_gdata->lock, flags); | ||
428 | pr_debug("done %s", __func__); | 355 | pr_debug("done %s", __func__); |
429 | return; | 356 | return; |
430 | } | 357 | } |
@@ -466,7 +393,7 @@ void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb) | |||
466 | 393 | ||
467 | switch (st_ll_getstate(st_gdata)) { | 394 | switch (st_ll_getstate(st_gdata)) { |
468 | case ST_LL_AWAKE: | 395 | case ST_LL_AWAKE: |
469 | pr_info("ST LL is AWAKE, sending normally"); | 396 | pr_debug("ST LL is AWAKE, sending normally"); |
470 | skb_queue_tail(&st_gdata->txq, skb); | 397 | skb_queue_tail(&st_gdata->txq, skb); |
471 | break; | 398 | break; |
472 | case ST_LL_ASLEEP_TO_AWAKE: | 399 | case ST_LL_ASLEEP_TO_AWAKE: |
@@ -506,7 +433,7 @@ void st_tx_wakeup(struct st_data_s *st_data) | |||
506 | pr_debug("%s", __func__); | 433 | pr_debug("%s", __func__); |
507 | /* check for sending & set flag sending here */ | 434 | /* check for sending & set flag sending here */ |
508 | if (test_and_set_bit(ST_TX_SENDING, &st_data->tx_state)) { | 435 | if (test_and_set_bit(ST_TX_SENDING, &st_data->tx_state)) { |
509 | pr_info("ST already sending"); | 436 | pr_debug("ST already sending"); |
510 | /* keep sending */ | 437 | /* keep sending */ |
511 | set_bit(ST_TX_WAKEUP, &st_data->tx_state); | 438 | set_bit(ST_TX_WAKEUP, &st_data->tx_state); |
512 | return; | 439 | return; |
@@ -548,9 +475,9 @@ void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf) | |||
548 | { | 475 | { |
549 | seq_printf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n", | 476 | seq_printf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n", |
550 | st_gdata->protos_registered, | 477 | st_gdata->protos_registered, |
551 | st_gdata->list[ST_BT] != NULL ? 'R' : 'U', | 478 | st_gdata->list[0x04] != NULL ? 'R' : 'U', |
552 | st_gdata->list[ST_FM] != NULL ? 'R' : 'U', | 479 | st_gdata->list[0x08] != NULL ? 'R' : 'U', |
553 | st_gdata->list[ST_GPS] != NULL ? 'R' : 'U'); | 480 | st_gdata->list[0x09] != NULL ? 'R' : 'U'); |
554 | } | 481 | } |
555 | 482 | ||
556 | /********************************************************************/ | 483 | /********************************************************************/ |
@@ -565,20 +492,20 @@ long st_register(struct st_proto_s *new_proto) | |||
565 | unsigned long flags = 0; | 492 | unsigned long flags = 0; |
566 | 493 | ||
567 | st_kim_ref(&st_gdata, 0); | 494 | st_kim_ref(&st_gdata, 0); |
568 | pr_info("%s(%d) ", __func__, new_proto->type); | 495 | pr_info("%s(%d) ", __func__, new_proto->chnl_id); |
569 | if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL | 496 | if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL |
570 | || new_proto->reg_complete_cb == NULL) { | 497 | || new_proto->reg_complete_cb == NULL) { |
571 | pr_err("gdata/new_proto/recv or reg_complete_cb not ready"); | 498 | pr_err("gdata/new_proto/recv or reg_complete_cb not ready"); |
572 | return -1; | 499 | return -EINVAL; |
573 | } | 500 | } |
574 | 501 | ||
575 | if (new_proto->type < ST_BT || new_proto->type >= ST_MAX) { | 502 | if (new_proto->chnl_id >= ST_MAX_CHANNELS) { |
576 | pr_err("protocol %d not supported", new_proto->type); | 503 | pr_err("chnl_id %d not supported", new_proto->chnl_id); |
577 | return -EPROTONOSUPPORT; | 504 | return -EPROTONOSUPPORT; |
578 | } | 505 | } |
579 | 506 | ||
580 | if (st_gdata->list[new_proto->type] != NULL) { | 507 | if (st_gdata->list[new_proto->chnl_id] != NULL) { |
581 | pr_err("protocol %d already registered", new_proto->type); | 508 | pr_err("chnl_id %d already registered", new_proto->chnl_id); |
582 | return -EALREADY; | 509 | return -EALREADY; |
583 | } | 510 | } |
584 | 511 | ||
@@ -586,11 +513,10 @@ long st_register(struct st_proto_s *new_proto) | |||
586 | spin_lock_irqsave(&st_gdata->lock, flags); | 513 | spin_lock_irqsave(&st_gdata->lock, flags); |
587 | 514 | ||
588 | if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) { | 515 | if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) { |
589 | pr_info(" ST_REG_IN_PROGRESS:%d ", new_proto->type); | 516 | pr_info(" ST_REG_IN_PROGRESS:%d ", new_proto->chnl_id); |
590 | /* fw download in progress */ | 517 | /* fw download in progress */ |
591 | st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); | ||
592 | 518 | ||
593 | st_gdata->list[new_proto->type] = new_proto; | 519 | add_channel_to_table(st_gdata, new_proto); |
594 | st_gdata->protos_registered++; | 520 | st_gdata->protos_registered++; |
595 | new_proto->write = st_write; | 521 | new_proto->write = st_write; |
596 | 522 | ||
@@ -598,7 +524,7 @@ long st_register(struct st_proto_s *new_proto) | |||
598 | spin_unlock_irqrestore(&st_gdata->lock, flags); | 524 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
599 | return -EINPROGRESS; | 525 | return -EINPROGRESS; |
600 | } else if (st_gdata->protos_registered == ST_EMPTY) { | 526 | } else if (st_gdata->protos_registered == ST_EMPTY) { |
601 | pr_info(" protocol list empty :%d ", new_proto->type); | 527 | pr_info(" chnl_id list empty :%d ", new_proto->chnl_id); |
602 | set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); | 528 | set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); |
603 | st_recv = st_kim_recv; | 529 | st_recv = st_kim_recv; |
604 | 530 | ||
@@ -616,16 +542,11 @@ long st_register(struct st_proto_s *new_proto) | |||
616 | if ((st_gdata->protos_registered != ST_EMPTY) && | 542 | if ((st_gdata->protos_registered != ST_EMPTY) && |
617 | (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { | 543 | (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { |
618 | pr_err(" KIM failure complete callback "); | 544 | pr_err(" KIM failure complete callback "); |
619 | st_reg_complete(st_gdata, -1); | 545 | st_reg_complete(st_gdata, err); |
620 | } | 546 | } |
621 | 547 | return -EINVAL; | |
622 | return -1; | ||
623 | } | 548 | } |
624 | 549 | ||
625 | /* the protocol might require other gpios to be toggled | ||
626 | */ | ||
627 | st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); | ||
628 | |||
629 | clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); | 550 | clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); |
630 | st_recv = st_int_recv; | 551 | st_recv = st_int_recv; |
631 | 552 | ||
@@ -642,14 +563,14 @@ long st_register(struct st_proto_s *new_proto) | |||
642 | /* check for already registered once more, | 563 | /* check for already registered once more, |
643 | * since the above check is old | 564 | * since the above check is old |
644 | */ | 565 | */ |
645 | if (st_gdata->list[new_proto->type] != NULL) { | 566 | if (st_gdata->list[new_proto->chnl_id] != NULL) { |
646 | pr_err(" proto %d already registered ", | 567 | pr_err(" proto %d already registered ", |
647 | new_proto->type); | 568 | new_proto->chnl_id); |
648 | return -EALREADY; | 569 | return -EALREADY; |
649 | } | 570 | } |
650 | 571 | ||
651 | spin_lock_irqsave(&st_gdata->lock, flags); | 572 | spin_lock_irqsave(&st_gdata->lock, flags); |
652 | st_gdata->list[new_proto->type] = new_proto; | 573 | add_channel_to_table(st_gdata, new_proto); |
653 | st_gdata->protos_registered++; | 574 | st_gdata->protos_registered++; |
654 | new_proto->write = st_write; | 575 | new_proto->write = st_write; |
655 | spin_unlock_irqrestore(&st_gdata->lock, flags); | 576 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
@@ -657,22 +578,7 @@ long st_register(struct st_proto_s *new_proto) | |||
657 | } | 578 | } |
658 | /* if fw is already downloaded & new stack registers protocol */ | 579 | /* if fw is already downloaded & new stack registers protocol */ |
659 | else { | 580 | else { |
660 | switch (new_proto->type) { | 581 | add_channel_to_table(st_gdata, new_proto); |
661 | case ST_BT: | ||
662 | /* do nothing */ | ||
663 | break; | ||
664 | case ST_FM: | ||
665 | case ST_GPS: | ||
666 | st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); | ||
667 | break; | ||
668 | case ST_MAX: | ||
669 | default: | ||
670 | pr_err("%d protocol not supported", | ||
671 | new_proto->type); | ||
672 | spin_unlock_irqrestore(&st_gdata->lock, flags); | ||
673 | return -EPROTONOSUPPORT; | ||
674 | } | ||
675 | st_gdata->list[new_proto->type] = new_proto; | ||
676 | st_gdata->protos_registered++; | 582 | st_gdata->protos_registered++; |
677 | new_proto->write = st_write; | 583 | new_proto->write = st_write; |
678 | 584 | ||
@@ -680,48 +586,42 @@ long st_register(struct st_proto_s *new_proto) | |||
680 | spin_unlock_irqrestore(&st_gdata->lock, flags); | 586 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
681 | return err; | 587 | return err; |
682 | } | 588 | } |
683 | pr_debug("done %s(%d) ", __func__, new_proto->type); | 589 | pr_debug("done %s(%d) ", __func__, new_proto->chnl_id); |
684 | } | 590 | } |
685 | EXPORT_SYMBOL_GPL(st_register); | 591 | EXPORT_SYMBOL_GPL(st_register); |
686 | 592 | ||
687 | /* to unregister a protocol - | 593 | /* to unregister a protocol - |
688 | * to be called from protocol stack driver | 594 | * to be called from protocol stack driver |
689 | */ | 595 | */ |
690 | long st_unregister(enum proto_type type) | 596 | long st_unregister(struct st_proto_s *proto) |
691 | { | 597 | { |
692 | long err = 0; | 598 | long err = 0; |
693 | unsigned long flags = 0; | 599 | unsigned long flags = 0; |
694 | struct st_data_s *st_gdata; | 600 | struct st_data_s *st_gdata; |
695 | 601 | ||
696 | pr_debug("%s: %d ", __func__, type); | 602 | pr_debug("%s: %d ", __func__, proto->chnl_id); |
697 | 603 | ||
698 | st_kim_ref(&st_gdata, 0); | 604 | st_kim_ref(&st_gdata, 0); |
699 | if (type < ST_BT || type >= ST_MAX) { | 605 | if (proto->chnl_id >= ST_MAX_CHANNELS) { |
700 | pr_err(" protocol %d not supported", type); | 606 | pr_err(" chnl_id %d not supported", proto->chnl_id); |
701 | return -EPROTONOSUPPORT; | 607 | return -EPROTONOSUPPORT; |
702 | } | 608 | } |
703 | 609 | ||
704 | spin_lock_irqsave(&st_gdata->lock, flags); | 610 | spin_lock_irqsave(&st_gdata->lock, flags); |
705 | 611 | ||
706 | if (st_gdata->list[type] == NULL) { | 612 | if (st_gdata->list[proto->chnl_id] == NULL) { |
707 | pr_err(" protocol %d not registered", type); | 613 | pr_err(" chnl_id %d not registered", proto->chnl_id); |
708 | spin_unlock_irqrestore(&st_gdata->lock, flags); | 614 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
709 | return -EPROTONOSUPPORT; | 615 | return -EPROTONOSUPPORT; |
710 | } | 616 | } |
711 | 617 | ||
712 | st_gdata->protos_registered--; | 618 | st_gdata->protos_registered--; |
713 | st_gdata->list[type] = NULL; | 619 | remove_channel_from_table(st_gdata, proto); |
714 | |||
715 | /* kim ignores BT in the below function | ||
716 | * and handles the rest, BT is toggled | ||
717 | * only in kim_start and kim_stop | ||
718 | */ | ||
719 | st_kim_chip_toggle(type, KIM_GPIO_INACTIVE); | ||
720 | spin_unlock_irqrestore(&st_gdata->lock, flags); | 620 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
721 | 621 | ||
722 | if ((st_gdata->protos_registered == ST_EMPTY) && | 622 | if ((st_gdata->protos_registered == ST_EMPTY) && |
723 | (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { | 623 | (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { |
724 | pr_info(" all protocols unregistered "); | 624 | pr_info(" all chnl_ids unregistered "); |
725 | 625 | ||
726 | /* stop traffic on tty */ | 626 | /* stop traffic on tty */ |
727 | if (st_gdata->tty) { | 627 | if (st_gdata->tty) { |
@@ -729,7 +629,7 @@ long st_unregister(enum proto_type type) | |||
729 | stop_tty(st_gdata->tty); | 629 | stop_tty(st_gdata->tty); |
730 | } | 630 | } |
731 | 631 | ||
732 | /* all protocols now unregistered */ | 632 | /* all chnl_ids now unregistered */ |
733 | st_kim_stop(st_gdata->kim_data); | 633 | st_kim_stop(st_gdata->kim_data); |
734 | /* disable ST LL */ | 634 | /* disable ST LL */ |
735 | st_ll_disable(st_gdata); | 635 | st_ll_disable(st_gdata); |
@@ -744,37 +644,15 @@ long st_unregister(enum proto_type type) | |||
744 | long st_write(struct sk_buff *skb) | 644 | long st_write(struct sk_buff *skb) |
745 | { | 645 | { |
746 | struct st_data_s *st_gdata; | 646 | struct st_data_s *st_gdata; |
747 | #ifdef DEBUG | ||
748 | enum proto_type protoid = ST_MAX; | ||
749 | #endif | ||
750 | long len; | 647 | long len; |
751 | 648 | ||
752 | st_kim_ref(&st_gdata, 0); | 649 | st_kim_ref(&st_gdata, 0); |
753 | if (unlikely(skb == NULL || st_gdata == NULL | 650 | if (unlikely(skb == NULL || st_gdata == NULL |
754 | || st_gdata->tty == NULL)) { | 651 | || st_gdata->tty == NULL)) { |
755 | pr_err("data/tty unavailable to perform write"); | 652 | pr_err("data/tty unavailable to perform write"); |
756 | return -1; | 653 | return -EINVAL; |
757 | } | 654 | } |
758 | #ifdef DEBUG /* open-up skb to read the 1st byte */ | 655 | |
759 | switch (skb->data[0]) { | ||
760 | case HCI_COMMAND_PKT: | ||
761 | case HCI_ACLDATA_PKT: | ||
762 | case HCI_SCODATA_PKT: | ||
763 | protoid = ST_BT; | ||
764 | break; | ||
765 | case ST_FM_CH8_PKT: | ||
766 | protoid = ST_FM; | ||
767 | break; | ||
768 | case 0x09: | ||
769 | protoid = ST_GPS; | ||
770 | break; | ||
771 | } | ||
772 | if (unlikely(st_gdata->list[protoid] == NULL)) { | ||
773 | pr_err(" protocol %d not registered, and writing? ", | ||
774 | protoid); | ||
775 | return -1; | ||
776 | } | ||
777 | #endif | ||
778 | pr_debug("%d to be written", skb->len); | 656 | pr_debug("%d to be written", skb->len); |
779 | len = skb->len; | 657 | len = skb->len; |
780 | 658 | ||
@@ -824,7 +702,7 @@ static int st_tty_open(struct tty_struct *tty) | |||
824 | 702 | ||
825 | static void st_tty_close(struct tty_struct *tty) | 703 | static void st_tty_close(struct tty_struct *tty) |
826 | { | 704 | { |
827 | unsigned char i = ST_MAX; | 705 | unsigned char i = ST_MAX_CHANNELS; |
828 | unsigned long flags = 0; | 706 | unsigned long flags = 0; |
829 | struct st_data_s *st_gdata = tty->disc_data; | 707 | struct st_data_s *st_gdata = tty->disc_data; |
830 | 708 | ||
@@ -835,7 +713,7 @@ static void st_tty_close(struct tty_struct *tty) | |||
835 | * un-installed for some reason - what should be done ? | 713 | * un-installed for some reason - what should be done ? |
836 | */ | 714 | */ |
837 | spin_lock_irqsave(&st_gdata->lock, flags); | 715 | spin_lock_irqsave(&st_gdata->lock, flags); |
838 | for (i = ST_BT; i < ST_MAX; i++) { | 716 | for (i = ST_BT; i < ST_MAX_CHANNELS; i++) { |
839 | if (st_gdata->list[i] != NULL) | 717 | if (st_gdata->list[i] != NULL) |
840 | pr_err("%d not un-registered", i); | 718 | pr_err("%d not un-registered", i); |
841 | st_gdata->list[i] = NULL; | 719 | st_gdata->list[i] = NULL; |
@@ -869,7 +747,6 @@ static void st_tty_close(struct tty_struct *tty) | |||
869 | static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, | 747 | static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, |
870 | char *tty_flags, int count) | 748 | char *tty_flags, int count) |
871 | { | 749 | { |
872 | |||
873 | #ifdef VERBOSE | 750 | #ifdef VERBOSE |
874 | print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE, | 751 | print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE, |
875 | 16, 1, data, count, 0); | 752 | 16, 1, data, count, 0); |
@@ -960,7 +837,7 @@ int st_core_init(struct st_data_s **core_data) | |||
960 | err = tty_unregister_ldisc(N_TI_WL); | 837 | err = tty_unregister_ldisc(N_TI_WL); |
961 | if (err) | 838 | if (err) |
962 | pr_err("unable to un-register ldisc"); | 839 | pr_err("unable to un-register ldisc"); |
963 | return -1; | 840 | return err; |
964 | } | 841 | } |
965 | *core_data = st_gdata; | 842 | *core_data = st_gdata; |
966 | return 0; | 843 | return 0; |
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c index 73b6c8b0e869..9ee4c788aa69 100644 --- a/drivers/misc/ti-st/st_kim.c +++ b/drivers/misc/ti-st/st_kim.c | |||
@@ -30,50 +30,12 @@ | |||
30 | #include <linux/debugfs.h> | 30 | #include <linux/debugfs.h> |
31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
32 | #include <linux/sched.h> | 32 | #include <linux/sched.h> |
33 | #include <linux/rfkill.h> | 33 | #include <linux/tty.h> |
34 | |||
35 | /* understand BT events for fw response */ | ||
36 | #include <net/bluetooth/bluetooth.h> | ||
37 | #include <net/bluetooth/hci_core.h> | ||
38 | #include <net/bluetooth/hci.h> | ||
39 | 34 | ||
35 | #include <linux/skbuff.h> | ||
40 | #include <linux/ti_wilink_st.h> | 36 | #include <linux/ti_wilink_st.h> |
41 | 37 | ||
42 | 38 | ||
43 | static int kim_probe(struct platform_device *pdev); | ||
44 | static int kim_remove(struct platform_device *pdev); | ||
45 | |||
46 | /* KIM platform device driver structure */ | ||
47 | static struct platform_driver kim_platform_driver = { | ||
48 | .probe = kim_probe, | ||
49 | .remove = kim_remove, | ||
50 | /* TODO: ST driver power management during suspend/resume ? | ||
51 | */ | ||
52 | #if 0 | ||
53 | .suspend = kim_suspend, | ||
54 | .resume = kim_resume, | ||
55 | #endif | ||
56 | .driver = { | ||
57 | .name = "kim", | ||
58 | .owner = THIS_MODULE, | ||
59 | }, | ||
60 | }; | ||
61 | |||
62 | static int kim_toggle_radio(void*, bool); | ||
63 | static const struct rfkill_ops kim_rfkill_ops = { | ||
64 | .set_block = kim_toggle_radio, | ||
65 | }; | ||
66 | |||
67 | /* strings to be used for rfkill entries and by | ||
68 | * ST Core to be used for sysfs debug entry | ||
69 | */ | ||
70 | #define PROTO_ENTRY(type, name) name | ||
71 | const unsigned char *protocol_names[] = { | ||
72 | PROTO_ENTRY(ST_BT, "Bluetooth"), | ||
73 | PROTO_ENTRY(ST_FM, "FM"), | ||
74 | PROTO_ENTRY(ST_GPS, "GPS"), | ||
75 | }; | ||
76 | |||
77 | #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */ | 39 | #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */ |
78 | static struct platform_device *st_kim_devices[MAX_ST_DEVICES]; | 40 | static struct platform_device *st_kim_devices[MAX_ST_DEVICES]; |
79 | 41 | ||
@@ -134,7 +96,7 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) | |||
134 | /* Packet header has non-zero payload length and | 96 | /* Packet header has non-zero payload length and |
135 | * we have enough space in created skb. Lets read | 97 | * we have enough space in created skb. Lets read |
136 | * payload data */ | 98 | * payload data */ |
137 | kim_gdata->rx_state = ST_BT_W4_DATA; | 99 | kim_gdata->rx_state = ST_W4_DATA; |
138 | kim_gdata->rx_count = len; | 100 | kim_gdata->rx_count = len; |
139 | return len; | 101 | return len; |
140 | } | 102 | } |
@@ -158,8 +120,8 @@ void kim_int_recv(struct kim_data_s *kim_gdata, | |||
158 | const unsigned char *data, long count) | 120 | const unsigned char *data, long count) |
159 | { | 121 | { |
160 | const unsigned char *ptr; | 122 | const unsigned char *ptr; |
161 | struct hci_event_hdr *eh; | ||
162 | int len = 0, type = 0; | 123 | int len = 0, type = 0; |
124 | unsigned char *plen; | ||
163 | 125 | ||
164 | pr_debug("%s", __func__); | 126 | pr_debug("%s", __func__); |
165 | /* Decode received bytes here */ | 127 | /* Decode received bytes here */ |
@@ -183,29 +145,27 @@ void kim_int_recv(struct kim_data_s *kim_gdata, | |||
183 | /* Check ST RX state machine , where are we? */ | 145 | /* Check ST RX state machine , where are we? */ |
184 | switch (kim_gdata->rx_state) { | 146 | switch (kim_gdata->rx_state) { |
185 | /* Waiting for complete packet ? */ | 147 | /* Waiting for complete packet ? */ |
186 | case ST_BT_W4_DATA: | 148 | case ST_W4_DATA: |
187 | pr_debug("Complete pkt received"); | 149 | pr_debug("Complete pkt received"); |
188 | validate_firmware_response(kim_gdata); | 150 | validate_firmware_response(kim_gdata); |
189 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; | 151 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
190 | kim_gdata->rx_skb = NULL; | 152 | kim_gdata->rx_skb = NULL; |
191 | continue; | 153 | continue; |
192 | /* Waiting for Bluetooth event header ? */ | 154 | /* Waiting for Bluetooth event header ? */ |
193 | case ST_BT_W4_EVENT_HDR: | 155 | case ST_W4_HEADER: |
194 | eh = (struct hci_event_hdr *)kim_gdata-> | 156 | plen = |
195 | rx_skb->data; | 157 | (unsigned char *)&kim_gdata->rx_skb->data[1]; |
196 | pr_debug("Event header: evt 0x%2.2x" | 158 | pr_debug("event hdr: plen 0x%02x\n", *plen); |
197 | "plen %d", eh->evt, eh->plen); | 159 | kim_check_data_len(kim_gdata, *plen); |
198 | kim_check_data_len(kim_gdata, eh->plen); | ||
199 | continue; | 160 | continue; |
200 | } /* end of switch */ | 161 | } /* end of switch */ |
201 | } /* end of if rx_state */ | 162 | } /* end of if rx_state */ |
202 | switch (*ptr) { | 163 | switch (*ptr) { |
203 | /* Bluetooth event packet? */ | 164 | /* Bluetooth event packet? */ |
204 | case HCI_EVENT_PKT: | 165 | case 0x04: |
205 | pr_info("Event packet"); | 166 | kim_gdata->rx_state = ST_W4_HEADER; |
206 | kim_gdata->rx_state = ST_BT_W4_EVENT_HDR; | 167 | kim_gdata->rx_count = 2; |
207 | kim_gdata->rx_count = HCI_EVENT_HDR_SIZE; | 168 | type = *ptr; |
208 | type = HCI_EVENT_PKT; | ||
209 | break; | 169 | break; |
210 | default: | 170 | default: |
211 | pr_info("unknown packet"); | 171 | pr_info("unknown packet"); |
@@ -216,16 +176,18 @@ void kim_int_recv(struct kim_data_s *kim_gdata, | |||
216 | ptr++; | 176 | ptr++; |
217 | count--; | 177 | count--; |
218 | kim_gdata->rx_skb = | 178 | kim_gdata->rx_skb = |
219 | bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); | 179 | alloc_skb(1024+8, GFP_ATOMIC); |
220 | if (!kim_gdata->rx_skb) { | 180 | if (!kim_gdata->rx_skb) { |
221 | pr_err("can't allocate mem for new packet"); | 181 | pr_err("can't allocate mem for new packet"); |
222 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; | 182 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
223 | kim_gdata->rx_count = 0; | 183 | kim_gdata->rx_count = 0; |
224 | return; | 184 | return; |
225 | } | 185 | } |
226 | bt_cb(kim_gdata->rx_skb)->pkt_type = type; | 186 | skb_reserve(kim_gdata->rx_skb, 8); |
187 | kim_gdata->rx_skb->cb[0] = 4; | ||
188 | kim_gdata->rx_skb->cb[1] = 0; | ||
189 | |||
227 | } | 190 | } |
228 | pr_info("done %s", __func__); | ||
229 | return; | 191 | return; |
230 | } | 192 | } |
231 | 193 | ||
@@ -239,13 +201,13 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) | |||
239 | INIT_COMPLETION(kim_gdata->kim_rcvd); | 201 | INIT_COMPLETION(kim_gdata->kim_rcvd); |
240 | if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { | 202 | if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { |
241 | pr_err("kim: couldn't write 4 bytes"); | 203 | pr_err("kim: couldn't write 4 bytes"); |
242 | return -1; | 204 | return -EIO; |
243 | } | 205 | } |
244 | 206 | ||
245 | if (!wait_for_completion_timeout | 207 | if (!wait_for_completion_timeout |
246 | (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { | 208 | (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { |
247 | pr_err(" waiting for ver info- timed out "); | 209 | pr_err(" waiting for ver info- timed out "); |
248 | return -1; | 210 | return -ETIMEDOUT; |
249 | } | 211 | } |
250 | 212 | ||
251 | version = | 213 | version = |
@@ -270,6 +232,26 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) | |||
270 | return 0; | 232 | return 0; |
271 | } | 233 | } |
272 | 234 | ||
235 | void skip_change_remote_baud(unsigned char **ptr, long *len) | ||
236 | { | ||
237 | unsigned char *nxt_action, *cur_action; | ||
238 | cur_action = *ptr; | ||
239 | |||
240 | nxt_action = cur_action + sizeof(struct bts_action) + | ||
241 | ((struct bts_action *) cur_action)->size; | ||
242 | |||
243 | if (((struct bts_action *) nxt_action)->type != ACTION_WAIT_EVENT) { | ||
244 | pr_err("invalid action after change remote baud command"); | ||
245 | } else { | ||
246 | *ptr = *ptr + sizeof(struct bts_action) + | ||
247 | ((struct bts_action *)nxt_action)->size; | ||
248 | *len = *len - (sizeof(struct bts_action) + | ||
249 | ((struct bts_action *)nxt_action)->size); | ||
250 | /* warn user on not commenting these in firmware */ | ||
251 | pr_warn("skipping the wait event of change remote baud"); | ||
252 | } | ||
253 | } | ||
254 | |||
273 | /** | 255 | /** |
274 | * download_firmware - | 256 | * download_firmware - |
275 | * internal function which parses through the .bts firmware | 257 | * internal function which parses through the .bts firmware |
@@ -282,6 +264,9 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
282 | unsigned char *ptr = NULL; | 264 | unsigned char *ptr = NULL; |
283 | unsigned char *action_ptr = NULL; | 265 | unsigned char *action_ptr = NULL; |
284 | unsigned char bts_scr_name[30] = { 0 }; /* 30 char long bts scr name? */ | 266 | unsigned char bts_scr_name[30] = { 0 }; /* 30 char long bts scr name? */ |
267 | int wr_room_space; | ||
268 | int cmd_size; | ||
269 | unsigned long timeout; | ||
285 | 270 | ||
286 | err = read_local_version(kim_gdata, bts_scr_name); | 271 | err = read_local_version(kim_gdata, bts_scr_name); |
287 | if (err != 0) { | 272 | if (err != 0) { |
@@ -295,7 +280,7 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
295 | (kim_gdata->fw_entry->size == 0))) { | 280 | (kim_gdata->fw_entry->size == 0))) { |
296 | pr_err(" request_firmware failed(errno %ld) for %s", err, | 281 | pr_err(" request_firmware failed(errno %ld) for %s", err, |
297 | bts_scr_name); | 282 | bts_scr_name); |
298 | return -1; | 283 | return -EINVAL; |
299 | } | 284 | } |
300 | ptr = (void *)kim_gdata->fw_entry->data; | 285 | ptr = (void *)kim_gdata->fw_entry->data; |
301 | len = kim_gdata->fw_entry->size; | 286 | len = kim_gdata->fw_entry->size; |
@@ -318,29 +303,72 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
318 | 0xFF36)) { | 303 | 0xFF36)) { |
319 | /* ignore remote change | 304 | /* ignore remote change |
320 | * baud rate HCI VS command */ | 305 | * baud rate HCI VS command */ |
321 | pr_err | 306 | pr_warn("change remote baud" |
322 | (" change remote baud" | ||
323 | " rate command in firmware"); | 307 | " rate command in firmware"); |
308 | skip_change_remote_baud(&ptr, &len); | ||
324 | break; | 309 | break; |
325 | } | 310 | } |
311 | /* | ||
312 | * Make sure we have enough free space in uart | ||
313 | * tx buffer to write current firmware command | ||
314 | */ | ||
315 | cmd_size = ((struct bts_action *)ptr)->size; | ||
316 | timeout = jiffies + msecs_to_jiffies(CMD_WR_TIME); | ||
317 | do { | ||
318 | wr_room_space = | ||
319 | st_get_uart_wr_room(kim_gdata->core_data); | ||
320 | if (wr_room_space < 0) { | ||
321 | pr_err("Unable to get free " | ||
322 | "space info from uart tx buffer"); | ||
323 | release_firmware(kim_gdata->fw_entry); | ||
324 | return wr_room_space; | ||
325 | } | ||
326 | mdelay(1); /* wait 1ms before checking room */ | ||
327 | } while ((wr_room_space < cmd_size) && | ||
328 | time_before(jiffies, timeout)); | ||
329 | |||
330 | /* Timeout happened ? */ | ||
331 | if (time_after_eq(jiffies, timeout)) { | ||
332 | pr_err("Timeout while waiting for free " | ||
333 | "free space in uart tx buffer"); | ||
334 | release_firmware(kim_gdata->fw_entry); | ||
335 | return -ETIMEDOUT; | ||
336 | } | ||
326 | 337 | ||
327 | INIT_COMPLETION(kim_gdata->kim_rcvd); | 338 | /* |
339 | * Free space found in uart buffer, call st_int_write | ||
340 | * to send current firmware command to the uart tx | ||
341 | * buffer. | ||
342 | */ | ||
328 | err = st_int_write(kim_gdata->core_data, | 343 | err = st_int_write(kim_gdata->core_data, |
329 | ((struct bts_action_send *)action_ptr)->data, | 344 | ((struct bts_action_send *)action_ptr)->data, |
330 | ((struct bts_action *)ptr)->size); | 345 | ((struct bts_action *)ptr)->size); |
331 | if (unlikely(err < 0)) { | 346 | if (unlikely(err < 0)) { |
332 | release_firmware(kim_gdata->fw_entry); | 347 | release_firmware(kim_gdata->fw_entry); |
333 | return -1; | 348 | return err; |
334 | } | 349 | } |
350 | /* | ||
351 | * Check number of bytes written to the uart tx buffer | ||
352 | * and requested command write size | ||
353 | */ | ||
354 | if (err != cmd_size) { | ||
355 | pr_err("Number of bytes written to uart " | ||
356 | "tx buffer are not matching with " | ||
357 | "requested cmd write size"); | ||
358 | release_firmware(kim_gdata->fw_entry); | ||
359 | return -EIO; | ||
360 | } | ||
361 | break; | ||
362 | case ACTION_WAIT_EVENT: /* wait */ | ||
335 | if (!wait_for_completion_timeout | 363 | if (!wait_for_completion_timeout |
336 | (&kim_gdata->kim_rcvd, | 364 | (&kim_gdata->kim_rcvd, |
337 | msecs_to_jiffies(CMD_RESP_TIME))) { | 365 | msecs_to_jiffies(CMD_RESP_TIME))) { |
338 | pr_err | 366 | pr_err("response timeout during fw download "); |
339 | (" response timeout during fw download "); | ||
340 | /* timed out */ | 367 | /* timed out */ |
341 | release_firmware(kim_gdata->fw_entry); | 368 | release_firmware(kim_gdata->fw_entry); |
342 | return -1; | 369 | return -ETIMEDOUT; |
343 | } | 370 | } |
371 | INIT_COMPLETION(kim_gdata->kim_rcvd); | ||
344 | break; | 372 | break; |
345 | case ACTION_DELAY: /* sleep */ | 373 | case ACTION_DELAY: /* sleep */ |
346 | pr_info("sleep command in scr"); | 374 | pr_info("sleep command in scr"); |
@@ -362,50 +390,6 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
362 | 390 | ||
363 | /**********************************************************************/ | 391 | /**********************************************************************/ |
364 | /* functions called from ST core */ | 392 | /* functions called from ST core */ |
365 | /* function to toggle the GPIO | ||
366 | * needs to know whether the GPIO is active high or active low | ||
367 | */ | ||
368 | void st_kim_chip_toggle(enum proto_type type, enum kim_gpio_state state) | ||
369 | { | ||
370 | struct platform_device *kim_pdev; | ||
371 | struct kim_data_s *kim_gdata; | ||
372 | pr_info(" %s ", __func__); | ||
373 | |||
374 | kim_pdev = st_get_plat_device(0); | ||
375 | kim_gdata = dev_get_drvdata(&kim_pdev->dev); | ||
376 | |||
377 | if (kim_gdata->gpios[type] == -1) { | ||
378 | pr_info(" gpio not requested for protocol %s", | ||
379 | protocol_names[type]); | ||
380 | return; | ||
381 | } | ||
382 | switch (type) { | ||
383 | case ST_BT: | ||
384 | /*Do Nothing */ | ||
385 | break; | ||
386 | |||
387 | case ST_FM: | ||
388 | if (state == KIM_GPIO_ACTIVE) | ||
389 | gpio_set_value(kim_gdata->gpios[ST_FM], GPIO_LOW); | ||
390 | else | ||
391 | gpio_set_value(kim_gdata->gpios[ST_FM], GPIO_HIGH); | ||
392 | break; | ||
393 | |||
394 | case ST_GPS: | ||
395 | if (state == KIM_GPIO_ACTIVE) | ||
396 | gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_HIGH); | ||
397 | else | ||
398 | gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_LOW); | ||
399 | break; | ||
400 | |||
401 | case ST_MAX: | ||
402 | default: | ||
403 | break; | ||
404 | } | ||
405 | |||
406 | return; | ||
407 | } | ||
408 | |||
409 | /* called from ST Core, when REG_IN_PROGRESS (registration in progress) | 393 | /* called from ST Core, when REG_IN_PROGRESS (registration in progress) |
410 | * can be because of | 394 | * can be because of |
411 | * 1. response to read local version | 395 | * 1. response to read local version |
@@ -416,7 +400,6 @@ void st_kim_recv(void *disc_data, const unsigned char *data, long count) | |||
416 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; | 400 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; |
417 | struct kim_data_s *kim_gdata = st_gdata->kim_data; | 401 | struct kim_data_s *kim_gdata = st_gdata->kim_data; |
418 | 402 | ||
419 | pr_info(" %s ", __func__); | ||
420 | /* copy to local buffer */ | 403 | /* copy to local buffer */ |
421 | if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) { | 404 | if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) { |
422 | /* must be the read_ver_cmd */ | 405 | /* must be the read_ver_cmd */ |
@@ -455,35 +438,28 @@ long st_kim_start(void *kim_data) | |||
455 | pr_info(" %s", __func__); | 438 | pr_info(" %s", __func__); |
456 | 439 | ||
457 | do { | 440 | do { |
458 | /* TODO: this is only because rfkill sub-system | ||
459 | * doesn't send events to user-space if the state | ||
460 | * isn't changed | ||
461 | */ | ||
462 | rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1); | ||
463 | /* Configure BT nShutdown to HIGH state */ | 441 | /* Configure BT nShutdown to HIGH state */ |
464 | gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); | 442 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); |
465 | mdelay(5); /* FIXME: a proper toggle */ | 443 | mdelay(5); /* FIXME: a proper toggle */ |
466 | gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH); | 444 | gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); |
467 | mdelay(100); | 445 | mdelay(100); |
468 | /* re-initialize the completion */ | 446 | /* re-initialize the completion */ |
469 | INIT_COMPLETION(kim_gdata->ldisc_installed); | 447 | INIT_COMPLETION(kim_gdata->ldisc_installed); |
470 | #if 0 /* older way of signalling user-space UIM */ | 448 | /* send notification to UIM */ |
471 | /* send signal to UIM */ | 449 | kim_gdata->ldisc_install = 1; |
472 | err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0); | 450 | pr_info("ldisc_install = 1"); |
473 | if (err != 0) { | 451 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, |
474 | pr_info(" sending SIGUSR2 to uim failed %ld", err); | 452 | NULL, "install"); |
475 | err = -1; | ||
476 | continue; | ||
477 | } | ||
478 | #endif | ||
479 | /* unblock and send event to UIM via /dev/rfkill */ | ||
480 | rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 0); | ||
481 | /* wait for ldisc to be installed */ | 453 | /* wait for ldisc to be installed */ |
482 | err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, | 454 | err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, |
483 | msecs_to_jiffies(LDISC_TIME)); | 455 | msecs_to_jiffies(LDISC_TIME)); |
484 | if (!err) { /* timeout */ | 456 | if (!err) { /* timeout */ |
485 | pr_err("line disc installation timed out "); | 457 | pr_err("line disc installation timed out "); |
486 | err = -1; | 458 | kim_gdata->ldisc_install = 0; |
459 | pr_info("ldisc_install = 0"); | ||
460 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, | ||
461 | NULL, "install"); | ||
462 | err = -ETIMEDOUT; | ||
487 | continue; | 463 | continue; |
488 | } else { | 464 | } else { |
489 | /* ldisc installed now */ | 465 | /* ldisc installed now */ |
@@ -491,6 +467,10 @@ long st_kim_start(void *kim_data) | |||
491 | err = download_firmware(kim_gdata); | 467 | err = download_firmware(kim_gdata); |
492 | if (err != 0) { | 468 | if (err != 0) { |
493 | pr_err("download firmware failed"); | 469 | pr_err("download firmware failed"); |
470 | kim_gdata->ldisc_install = 0; | ||
471 | pr_info("ldisc_install = 0"); | ||
472 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, | ||
473 | NULL, "install"); | ||
494 | continue; | 474 | continue; |
495 | } else { /* on success don't retry */ | 475 | } else { /* on success don't retry */ |
496 | break; | 476 | break; |
@@ -510,31 +490,30 @@ long st_kim_stop(void *kim_data) | |||
510 | struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; | 490 | struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; |
511 | 491 | ||
512 | INIT_COMPLETION(kim_gdata->ldisc_installed); | 492 | INIT_COMPLETION(kim_gdata->ldisc_installed); |
513 | #if 0 /* older way of signalling user-space UIM */ | 493 | |
514 | /* send signal to UIM */ | 494 | /* Flush any pending characters in the driver and discipline. */ |
515 | err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 1); | 495 | tty_ldisc_flush(kim_gdata->core_data->tty); |
516 | if (err != 0) { | 496 | tty_driver_flush_buffer(kim_gdata->core_data->tty); |
517 | pr_err("sending SIGUSR2 to uim failed %ld", err); | 497 | |
518 | return -1; | 498 | /* send uninstall notification to UIM */ |
519 | } | 499 | pr_info("ldisc_install = 0"); |
520 | #endif | 500 | kim_gdata->ldisc_install = 0; |
521 | /* set BT rfkill to be blocked */ | 501 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install"); |
522 | err = rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1); | ||
523 | 502 | ||
524 | /* wait for ldisc to be un-installed */ | 503 | /* wait for ldisc to be un-installed */ |
525 | err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, | 504 | err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, |
526 | msecs_to_jiffies(LDISC_TIME)); | 505 | msecs_to_jiffies(LDISC_TIME)); |
527 | if (!err) { /* timeout */ | 506 | if (!err) { /* timeout */ |
528 | pr_err(" timed out waiting for ldisc to be un-installed"); | 507 | pr_err(" timed out waiting for ldisc to be un-installed"); |
529 | return -1; | 508 | return -ETIMEDOUT; |
530 | } | 509 | } |
531 | 510 | ||
532 | /* By default configure BT nShutdown to LOW state */ | 511 | /* By default configure BT nShutdown to LOW state */ |
533 | gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); | 512 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); |
534 | mdelay(1); | 513 | mdelay(1); |
535 | gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH); | 514 | gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); |
536 | mdelay(1); | 515 | mdelay(1); |
537 | gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); | 516 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); |
538 | return err; | 517 | return err; |
539 | } | 518 | } |
540 | 519 | ||
@@ -558,33 +537,59 @@ static int show_list(struct seq_file *s, void *unused) | |||
558 | return 0; | 537 | return 0; |
559 | } | 538 | } |
560 | 539 | ||
561 | /* function called from rfkill subsystem, when someone from | 540 | static ssize_t show_install(struct device *dev, |
562 | * user space would write 0/1 on the sysfs entry | 541 | struct device_attribute *attr, char *buf) |
563 | * /sys/class/rfkill/rfkill0,1,3/state | ||
564 | */ | ||
565 | static int kim_toggle_radio(void *data, bool blocked) | ||
566 | { | 542 | { |
567 | enum proto_type type = *((enum proto_type *)data); | 543 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
568 | pr_debug(" %s: %d ", __func__, type); | 544 | return sprintf(buf, "%d\n", kim_data->ldisc_install); |
569 | |||
570 | switch (type) { | ||
571 | case ST_BT: | ||
572 | /* do nothing */ | ||
573 | break; | ||
574 | case ST_FM: | ||
575 | case ST_GPS: | ||
576 | if (blocked) | ||
577 | st_kim_chip_toggle(type, KIM_GPIO_INACTIVE); | ||
578 | else | ||
579 | st_kim_chip_toggle(type, KIM_GPIO_ACTIVE); | ||
580 | break; | ||
581 | case ST_MAX: | ||
582 | pr_err(" wrong proto type "); | ||
583 | break; | ||
584 | } | ||
585 | return 0; | ||
586 | } | 545 | } |
587 | 546 | ||
547 | static ssize_t show_dev_name(struct device *dev, | ||
548 | struct device_attribute *attr, char *buf) | ||
549 | { | ||
550 | struct kim_data_s *kim_data = dev_get_drvdata(dev); | ||
551 | return sprintf(buf, "%s\n", kim_data->dev_name); | ||
552 | } | ||
553 | |||
554 | static ssize_t show_baud_rate(struct device *dev, | ||
555 | struct device_attribute *attr, char *buf) | ||
556 | { | ||
557 | struct kim_data_s *kim_data = dev_get_drvdata(dev); | ||
558 | return sprintf(buf, "%ld\n", kim_data->baud_rate); | ||
559 | } | ||
560 | |||
561 | static ssize_t show_flow_cntrl(struct device *dev, | ||
562 | struct device_attribute *attr, char *buf) | ||
563 | { | ||
564 | struct kim_data_s *kim_data = dev_get_drvdata(dev); | ||
565 | return sprintf(buf, "%d\n", kim_data->flow_cntrl); | ||
566 | } | ||
567 | |||
568 | /* structures specific for sysfs entries */ | ||
569 | static struct kobj_attribute ldisc_install = | ||
570 | __ATTR(install, 0444, (void *)show_install, NULL); | ||
571 | |||
572 | static struct kobj_attribute uart_dev_name = | ||
573 | __ATTR(dev_name, 0444, (void *)show_dev_name, NULL); | ||
574 | |||
575 | static struct kobj_attribute uart_baud_rate = | ||
576 | __ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL); | ||
577 | |||
578 | static struct kobj_attribute uart_flow_cntrl = | ||
579 | __ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL); | ||
580 | |||
581 | static struct attribute *uim_attrs[] = { | ||
582 | &ldisc_install.attr, | ||
583 | &uart_dev_name.attr, | ||
584 | &uart_baud_rate.attr, | ||
585 | &uart_flow_cntrl.attr, | ||
586 | NULL, | ||
587 | }; | ||
588 | |||
589 | static struct attribute_group uim_attr_grp = { | ||
590 | .attrs = uim_attrs, | ||
591 | }; | ||
592 | |||
588 | /** | 593 | /** |
589 | * st_kim_ref - reference the core's data | 594 | * st_kim_ref - reference the core's data |
590 | * This references the per-ST platform device in the arch/xx/ | 595 | * This references the per-ST platform device in the arch/xx/ |
@@ -637,9 +642,8 @@ struct dentry *kim_debugfs_dir; | |||
637 | static int kim_probe(struct platform_device *pdev) | 642 | static int kim_probe(struct platform_device *pdev) |
638 | { | 643 | { |
639 | long status; | 644 | long status; |
640 | long proto; | ||
641 | long *gpios = pdev->dev.platform_data; | ||
642 | struct kim_data_s *kim_gdata; | 645 | struct kim_data_s *kim_gdata; |
646 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | ||
643 | 647 | ||
644 | if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) { | 648 | if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) { |
645 | /* multiple devices could exist */ | 649 | /* multiple devices could exist */ |
@@ -659,44 +663,24 @@ static int kim_probe(struct platform_device *pdev) | |||
659 | status = st_core_init(&kim_gdata->core_data); | 663 | status = st_core_init(&kim_gdata->core_data); |
660 | if (status != 0) { | 664 | if (status != 0) { |
661 | pr_err(" ST core init failed"); | 665 | pr_err(" ST core init failed"); |
662 | return -1; | 666 | return -EIO; |
663 | } | 667 | } |
664 | /* refer to itself */ | 668 | /* refer to itself */ |
665 | kim_gdata->core_data->kim_data = kim_gdata; | 669 | kim_gdata->core_data->kim_data = kim_gdata; |
666 | 670 | ||
667 | for (proto = 0; proto < ST_MAX; proto++) { | 671 | /* Claim the chip enable nShutdown gpio from the system */ |
668 | kim_gdata->gpios[proto] = gpios[proto]; | 672 | kim_gdata->nshutdown = pdata->nshutdown_gpio; |
669 | pr_info(" %ld gpio to be requested", gpios[proto]); | 673 | status = gpio_request(kim_gdata->nshutdown, "kim"); |
674 | if (unlikely(status)) { | ||
675 | pr_err(" gpio %ld request failed ", kim_gdata->nshutdown); | ||
676 | return status; | ||
670 | } | 677 | } |
671 | 678 | ||
672 | for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { | 679 | /* Configure nShutdown GPIO as output=0 */ |
673 | /* Claim the Bluetooth/FM/GPIO | 680 | status = gpio_direction_output(kim_gdata->nshutdown, 0); |
674 | * nShutdown gpio from the system | 681 | if (unlikely(status)) { |
675 | */ | 682 | pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown); |
676 | status = gpio_request(gpios[proto], "kim"); | 683 | return status; |
677 | if (unlikely(status)) { | ||
678 | pr_err(" gpio %ld request failed ", gpios[proto]); | ||
679 | proto -= 1; | ||
680 | while (proto >= 0) { | ||
681 | if (gpios[proto] != -1) | ||
682 | gpio_free(gpios[proto]); | ||
683 | } | ||
684 | return status; | ||
685 | } | ||
686 | |||
687 | /* Configure nShutdown GPIO as output=0 */ | ||
688 | status = | ||
689 | gpio_direction_output(gpios[proto], 0); | ||
690 | if (unlikely(status)) { | ||
691 | pr_err(" unable to configure gpio %ld", | ||
692 | gpios[proto]); | ||
693 | proto -= 1; | ||
694 | while (proto >= 0) { | ||
695 | if (gpios[proto] != -1) | ||
696 | gpio_free(gpios[proto]); | ||
697 | } | ||
698 | return status; | ||
699 | } | ||
700 | } | 684 | } |
701 | /* get reference of pdev for request_firmware | 685 | /* get reference of pdev for request_firmware |
702 | */ | 686 | */ |
@@ -704,34 +688,23 @@ static int kim_probe(struct platform_device *pdev) | |||
704 | init_completion(&kim_gdata->kim_rcvd); | 688 | init_completion(&kim_gdata->kim_rcvd); |
705 | init_completion(&kim_gdata->ldisc_installed); | 689 | init_completion(&kim_gdata->ldisc_installed); |
706 | 690 | ||
707 | for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { | 691 | status = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp); |
708 | /* TODO: should all types be rfkill_type_bt ? */ | 692 | if (status) { |
709 | kim_gdata->rf_protos[proto] = proto; | 693 | pr_err("failed to create sysfs entries"); |
710 | kim_gdata->rfkill[proto] = rfkill_alloc(protocol_names[proto], | 694 | return status; |
711 | &pdev->dev, RFKILL_TYPE_BLUETOOTH, | ||
712 | &kim_rfkill_ops, &kim_gdata->rf_protos[proto]); | ||
713 | if (kim_gdata->rfkill[proto] == NULL) { | ||
714 | pr_err("cannot create rfkill entry for gpio %ld", | ||
715 | gpios[proto]); | ||
716 | continue; | ||
717 | } | ||
718 | /* block upon creation */ | ||
719 | rfkill_init_sw_state(kim_gdata->rfkill[proto], 1); | ||
720 | status = rfkill_register(kim_gdata->rfkill[proto]); | ||
721 | if (unlikely(status)) { | ||
722 | pr_err("rfkill registration failed for gpio %ld", | ||
723 | gpios[proto]); | ||
724 | rfkill_unregister(kim_gdata->rfkill[proto]); | ||
725 | continue; | ||
726 | } | ||
727 | pr_info("rfkill entry created for %ld", gpios[proto]); | ||
728 | } | 695 | } |
729 | 696 | ||
697 | /* copying platform data */ | ||
698 | strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN); | ||
699 | kim_gdata->flow_cntrl = pdata->flow_cntrl; | ||
700 | kim_gdata->baud_rate = pdata->baud_rate; | ||
701 | pr_info("sysfs entries created\n"); | ||
702 | |||
730 | kim_debugfs_dir = debugfs_create_dir("ti-st", NULL); | 703 | kim_debugfs_dir = debugfs_create_dir("ti-st", NULL); |
731 | if (IS_ERR(kim_debugfs_dir)) { | 704 | if (IS_ERR(kim_debugfs_dir)) { |
732 | pr_err(" debugfs entries creation failed "); | 705 | pr_err(" debugfs entries creation failed "); |
733 | kim_debugfs_dir = NULL; | 706 | kim_debugfs_dir = NULL; |
734 | return -1; | 707 | return -EIO; |
735 | } | 708 | } |
736 | 709 | ||
737 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, | 710 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, |
@@ -744,25 +717,22 @@ static int kim_probe(struct platform_device *pdev) | |||
744 | 717 | ||
745 | static int kim_remove(struct platform_device *pdev) | 718 | static int kim_remove(struct platform_device *pdev) |
746 | { | 719 | { |
747 | /* free the GPIOs requested | 720 | /* free the GPIOs requested */ |
748 | */ | 721 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; |
749 | long *gpios = pdev->dev.platform_data; | ||
750 | long proto; | ||
751 | struct kim_data_s *kim_gdata; | 722 | struct kim_data_s *kim_gdata; |
752 | 723 | ||
753 | kim_gdata = dev_get_drvdata(&pdev->dev); | 724 | kim_gdata = dev_get_drvdata(&pdev->dev); |
754 | 725 | ||
755 | for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { | 726 | /* Free the Bluetooth/FM/GPIO |
756 | /* Claim the Bluetooth/FM/GPIO | 727 | * nShutdown gpio from the system |
757 | * nShutdown gpio from the system | 728 | */ |
758 | */ | 729 | gpio_free(pdata->nshutdown_gpio); |
759 | gpio_free(gpios[proto]); | 730 | pr_info("nshutdown GPIO Freed"); |
760 | rfkill_unregister(kim_gdata->rfkill[proto]); | 731 | |
761 | rfkill_destroy(kim_gdata->rfkill[proto]); | ||
762 | kim_gdata->rfkill[proto] = NULL; | ||
763 | } | ||
764 | pr_info("kim: GPIO Freed"); | ||
765 | debugfs_remove_recursive(kim_debugfs_dir); | 732 | debugfs_remove_recursive(kim_debugfs_dir); |
733 | sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); | ||
734 | pr_info("sysfs entries removed"); | ||
735 | |||
766 | kim_gdata->kim_pdev = NULL; | 736 | kim_gdata->kim_pdev = NULL; |
767 | st_core_exit(kim_gdata->core_data); | 737 | st_core_exit(kim_gdata->core_data); |
768 | 738 | ||
@@ -771,23 +741,46 @@ static int kim_remove(struct platform_device *pdev) | |||
771 | return 0; | 741 | return 0; |
772 | } | 742 | } |
773 | 743 | ||
744 | int kim_suspend(struct platform_device *pdev, pm_message_t state) | ||
745 | { | ||
746 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | ||
747 | |||
748 | if (pdata->suspend) | ||
749 | return pdata->suspend(pdev, state); | ||
750 | |||
751 | return -EOPNOTSUPP; | ||
752 | } | ||
753 | |||
754 | int kim_resume(struct platform_device *pdev) | ||
755 | { | ||
756 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | ||
757 | |||
758 | if (pdata->resume) | ||
759 | return pdata->resume(pdev); | ||
760 | |||
761 | return -EOPNOTSUPP; | ||
762 | } | ||
763 | |||
774 | /**********************************************************************/ | 764 | /**********************************************************************/ |
775 | /* entry point for ST KIM module, called in from ST Core */ | 765 | /* entry point for ST KIM module, called in from ST Core */ |
766 | static struct platform_driver kim_platform_driver = { | ||
767 | .probe = kim_probe, | ||
768 | .remove = kim_remove, | ||
769 | .suspend = kim_suspend, | ||
770 | .resume = kim_resume, | ||
771 | .driver = { | ||
772 | .name = "kim", | ||
773 | .owner = THIS_MODULE, | ||
774 | }, | ||
775 | }; | ||
776 | 776 | ||
777 | static int __init st_kim_init(void) | 777 | static int __init st_kim_init(void) |
778 | { | 778 | { |
779 | long ret = 0; | 779 | return platform_driver_register(&kim_platform_driver); |
780 | ret = platform_driver_register(&kim_platform_driver); | ||
781 | if (ret != 0) { | ||
782 | pr_err("platform drv registration failed"); | ||
783 | return -1; | ||
784 | } | ||
785 | return 0; | ||
786 | } | 780 | } |
787 | 781 | ||
788 | static void __exit st_kim_deinit(void) | 782 | static void __exit st_kim_deinit(void) |
789 | { | 783 | { |
790 | /* the following returns void */ | ||
791 | platform_driver_unregister(&kim_platform_driver); | 784 | platform_driver_unregister(&kim_platform_driver); |
792 | } | 785 | } |
793 | 786 | ||
diff --git a/drivers/misc/ti-st/st_ll.c b/drivers/misc/ti-st/st_ll.c index 2bda8dea15b0..3f2495138855 100644 --- a/drivers/misc/ti-st/st_ll.c +++ b/drivers/misc/ti-st/st_ll.c | |||
@@ -30,7 +30,7 @@ static void send_ll_cmd(struct st_data_s *st_data, | |||
30 | unsigned char cmd) | 30 | unsigned char cmd) |
31 | { | 31 | { |
32 | 32 | ||
33 | pr_info("%s: writing %x", __func__, cmd); | 33 | pr_debug("%s: writing %x", __func__, cmd); |
34 | st_int_write(st_data, &cmd, 1); | 34 | st_int_write(st_data, &cmd, 1); |
35 | return; | 35 | return; |
36 | } | 36 | } |
@@ -114,23 +114,23 @@ unsigned long st_ll_sleep_state(struct st_data_s *st_data, | |||
114 | { | 114 | { |
115 | switch (cmd) { | 115 | switch (cmd) { |
116 | case LL_SLEEP_IND: /* sleep ind */ | 116 | case LL_SLEEP_IND: /* sleep ind */ |
117 | pr_info("sleep indication recvd"); | 117 | pr_debug("sleep indication recvd"); |
118 | ll_device_want_to_sleep(st_data); | 118 | ll_device_want_to_sleep(st_data); |
119 | break; | 119 | break; |
120 | case LL_SLEEP_ACK: /* sleep ack */ | 120 | case LL_SLEEP_ACK: /* sleep ack */ |
121 | pr_err("sleep ack rcvd: host shouldn't"); | 121 | pr_err("sleep ack rcvd: host shouldn't"); |
122 | break; | 122 | break; |
123 | case LL_WAKE_UP_IND: /* wake ind */ | 123 | case LL_WAKE_UP_IND: /* wake ind */ |
124 | pr_info("wake indication recvd"); | 124 | pr_debug("wake indication recvd"); |
125 | ll_device_want_to_wakeup(st_data); | 125 | ll_device_want_to_wakeup(st_data); |
126 | break; | 126 | break; |
127 | case LL_WAKE_UP_ACK: /* wake ack */ | 127 | case LL_WAKE_UP_ACK: /* wake ack */ |
128 | pr_info("wake ack rcvd"); | 128 | pr_debug("wake ack rcvd"); |
129 | st_data->ll_state = ST_LL_AWAKE; | 129 | st_data->ll_state = ST_LL_AWAKE; |
130 | break; | 130 | break; |
131 | default: | 131 | default: |
132 | pr_err(" unknown input/state "); | 132 | pr_err(" unknown input/state "); |
133 | return -1; | 133 | return -EINVAL; |
134 | } | 134 | } |
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |