Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Shared Transport Line discipline driver Core |
| 3 | * Init Manager module responsible for GPIO control |
| 4 | * and firmware download |
Pavan Savoy | a0cc2f3 | 2010-10-06 12:18:14 -0400 | [diff] [blame] | 5 | * Copyright (C) 2009-2010 Texas Instruments |
| 6 | * Author: Pavan Savoy <pavan_savoy@ti.com> |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #define pr_fmt(fmt) "(stk) :" fmt |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/jiffies.h> |
| 26 | #include <linux/firmware.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/wait.h> |
| 29 | #include <linux/gpio.h> |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 30 | #include <linux/debugfs.h> |
| 31 | #include <linux/seq_file.h> |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 32 | #include <linux/sched.h> |
Randy Dunlap | 773d679 | 2011-04-26 09:18:51 -0700 | [diff] [blame] | 33 | #include <linux/sysfs.h> |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 34 | #include <linux/tty.h> |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 35 | |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 36 | #include <linux/skbuff.h> |
Pavan Savoy | e555867 | 2010-09-30 16:13:30 -0400 | [diff] [blame] | 37 | #include <linux/ti_wilink_st.h> |
Paul Gortmaker | eb12a67 | 2011-07-03 15:14:56 -0400 | [diff] [blame] | 38 | #include <linux/module.h> |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 39 | #include <linux/of.h> |
| 40 | #include <linux/of_device.h> |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 41 | |
Pavan Savoy | dbd3a87 | 2010-08-19 14:08:51 -0400 | [diff] [blame] | 42 | #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */ |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 43 | static struct platform_device *st_kim_devices[MAX_ST_DEVICES]; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 44 | |
| 45 | /**********************************************************************/ |
| 46 | /* internal functions */ |
| 47 | |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 48 | struct ti_st_plat_data *dt_pdata; |
| 49 | static struct ti_st_plat_data *get_platform_data(struct device *dev); |
| 50 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 51 | /** |
Pavan Savoy | dbd3a87 | 2010-08-19 14:08:51 -0400 | [diff] [blame] | 52 | * st_get_plat_device - |
| 53 | * function which returns the reference to the platform device |
| 54 | * requested by id. As of now only 1 such device exists (id=0) |
| 55 | * the context requesting for reference can get the id to be |
| 56 | * requested by a. The protocol driver which is registering or |
| 57 | * b. the tty device which is opened. |
| 58 | */ |
| 59 | static struct platform_device *st_get_plat_device(int id) |
| 60 | { |
| 61 | return st_kim_devices[id]; |
| 62 | } |
| 63 | |
| 64 | /** |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 65 | * validate_firmware_response - |
| 66 | * function to return whether the firmware response was proper |
| 67 | * in case of error don't complete so that waiting for proper |
| 68 | * response times out |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 69 | */ |
Pavan Savoy | 27712b3 | 2012-08-03 14:49:40 -0500 | [diff] [blame] | 70 | static void validate_firmware_response(struct kim_data_s *kim_gdata) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 71 | { |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 72 | struct sk_buff *skb = kim_gdata->rx_skb; |
Pavan Savoy | 8565adb | 2012-08-03 14:49:43 -0500 | [diff] [blame] | 73 | if (!skb) |
| 74 | return; |
| 75 | |
| 76 | /* these magic numbers are the position in the response buffer which |
| 77 | * allows us to distinguish whether the response is for the read |
| 78 | * version info. command |
| 79 | */ |
| 80 | if (skb->data[2] == 0x01 && skb->data[3] == 0x01 && |
| 81 | skb->data[4] == 0x10 && skb->data[5] == 0x00) { |
| 82 | /* fw version response */ |
| 83 | memcpy(kim_gdata->resp_buffer, |
| 84 | kim_gdata->rx_skb->data, |
| 85 | kim_gdata->rx_skb->len); |
| 86 | complete_all(&kim_gdata->kim_rcvd); |
| 87 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
| 88 | kim_gdata->rx_skb = NULL; |
| 89 | kim_gdata->rx_count = 0; |
| 90 | } else if (unlikely(skb->data[5] != 0)) { |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 91 | pr_err("no proper response during fw download"); |
| 92 | pr_err("data6 %x", skb->data[5]); |
Pavan Savoy | 76ff0e6 | 2011-08-10 10:18:36 -0500 | [diff] [blame] | 93 | kfree_skb(skb); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 94 | return; /* keep waiting for the proper response */ |
| 95 | } |
| 96 | /* becos of all the script being downloaded */ |
| 97 | complete_all(&kim_gdata->kim_rcvd); |
| 98 | kfree_skb(skb); |
| 99 | } |
| 100 | |
| 101 | /* check for data len received inside kim_int_recv |
| 102 | * most often hit the last case to update state to waiting for data |
| 103 | */ |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 104 | static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 105 | { |
| 106 | register int room = skb_tailroom(kim_gdata->rx_skb); |
| 107 | |
Pavan Savoy | e6d9e64 | 2010-07-22 05:32:05 -0500 | [diff] [blame] | 108 | pr_debug("len %d room %d", len, room); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 109 | |
| 110 | if (!len) { |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 111 | validate_firmware_response(kim_gdata); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 112 | } else if (len > room) { |
| 113 | /* Received packet's payload length is larger. |
| 114 | * We can't accommodate it in created skb. |
| 115 | */ |
| 116 | pr_err("Data length is too large len %d room %d", len, |
| 117 | room); |
| 118 | kfree_skb(kim_gdata->rx_skb); |
| 119 | } else { |
| 120 | /* Packet header has non-zero payload length and |
| 121 | * we have enough space in created skb. Lets read |
| 122 | * payload data */ |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 123 | kim_gdata->rx_state = ST_W4_DATA; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 124 | kim_gdata->rx_count = len; |
| 125 | return len; |
| 126 | } |
| 127 | |
| 128 | /* Change ST LL state to continue to process next |
| 129 | * packet */ |
| 130 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
| 131 | kim_gdata->rx_skb = NULL; |
| 132 | kim_gdata->rx_count = 0; |
| 133 | |
| 134 | return 0; |
| 135 | } |
| 136 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 137 | /** |
| 138 | * kim_int_recv - receive function called during firmware download |
| 139 | * firmware download responses on different UART drivers |
| 140 | * have been observed to come in bursts of different |
| 141 | * tty_receive and hence the logic |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 142 | */ |
Pavan Savoy | 27712b3 | 2012-08-03 14:49:40 -0500 | [diff] [blame] | 143 | static void kim_int_recv(struct kim_data_s *kim_gdata, |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 144 | const unsigned char *data, long count) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 145 | { |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 146 | const unsigned char *ptr; |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 147 | int len = 0, type = 0; |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 148 | unsigned char *plen; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 149 | |
Pavan Savoy | e6d9e64 | 2010-07-22 05:32:05 -0500 | [diff] [blame] | 150 | pr_debug("%s", __func__); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 151 | /* Decode received bytes here */ |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 152 | ptr = data; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 153 | if (unlikely(ptr == NULL)) { |
| 154 | pr_err(" received null from TTY "); |
| 155 | return; |
| 156 | } |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 157 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 158 | while (count) { |
| 159 | if (kim_gdata->rx_count) { |
| 160 | len = min_t(unsigned int, kim_gdata->rx_count, count); |
| 161 | memcpy(skb_put(kim_gdata->rx_skb, len), ptr, len); |
| 162 | kim_gdata->rx_count -= len; |
| 163 | count -= len; |
| 164 | ptr += len; |
| 165 | |
| 166 | if (kim_gdata->rx_count) |
| 167 | continue; |
| 168 | |
| 169 | /* Check ST RX state machine , where are we? */ |
| 170 | switch (kim_gdata->rx_state) { |
| 171 | /* Waiting for complete packet ? */ |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 172 | case ST_W4_DATA: |
Pavan Savoy | e6d9e64 | 2010-07-22 05:32:05 -0500 | [diff] [blame] | 173 | pr_debug("Complete pkt received"); |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 174 | validate_firmware_response(kim_gdata); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 175 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
| 176 | kim_gdata->rx_skb = NULL; |
| 177 | continue; |
| 178 | /* Waiting for Bluetooth event header ? */ |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 179 | case ST_W4_HEADER: |
| 180 | plen = |
| 181 | (unsigned char *)&kim_gdata->rx_skb->data[1]; |
| 182 | pr_debug("event hdr: plen 0x%02x\n", *plen); |
| 183 | kim_check_data_len(kim_gdata, *plen); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 184 | continue; |
| 185 | } /* end of switch */ |
| 186 | } /* end of if rx_state */ |
| 187 | switch (*ptr) { |
| 188 | /* Bluetooth event packet? */ |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 189 | case 0x04: |
| 190 | kim_gdata->rx_state = ST_W4_HEADER; |
| 191 | kim_gdata->rx_count = 2; |
| 192 | type = *ptr; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 193 | break; |
| 194 | default: |
| 195 | pr_info("unknown packet"); |
| 196 | ptr++; |
| 197 | count--; |
| 198 | continue; |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 199 | } |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 200 | ptr++; |
| 201 | count--; |
| 202 | kim_gdata->rx_skb = |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 203 | alloc_skb(1024+8, GFP_ATOMIC); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 204 | if (!kim_gdata->rx_skb) { |
| 205 | pr_err("can't allocate mem for new packet"); |
| 206 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
| 207 | kim_gdata->rx_count = 0; |
| 208 | return; |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 209 | } |
Pavan Savoy | 5c88b02 | 2011-02-04 02:23:09 -0600 | [diff] [blame] | 210 | skb_reserve(kim_gdata->rx_skb, 8); |
| 211 | kim_gdata->rx_skb->cb[0] = 4; |
| 212 | kim_gdata->rx_skb->cb[1] = 0; |
| 213 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 214 | } |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 215 | return; |
| 216 | } |
| 217 | |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 218 | static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 219 | { |
| 220 | unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0; |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 221 | const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 }; |
Nicholas Mc Guire | 3f46d81 | 2015-01-20 06:27:45 +0100 | [diff] [blame^] | 222 | long timeout; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 223 | |
Pavan Savoy | e6d9e64 | 2010-07-22 05:32:05 -0500 | [diff] [blame] | 224 | pr_debug("%s", __func__); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 225 | |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 226 | reinit_completion(&kim_gdata->kim_rcvd); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 227 | if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { |
| 228 | pr_err("kim: couldn't write 4 bytes"); |
Pavan Savoy | 7044266 | 2011-02-04 02:23:11 -0600 | [diff] [blame] | 229 | return -EIO; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 230 | } |
| 231 | |
Nicholas Mc Guire | 3f46d81 | 2015-01-20 06:27:45 +0100 | [diff] [blame^] | 232 | timeout = wait_for_completion_interruptible_timeout( |
| 233 | &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME)); |
| 234 | if (timeout <= 0) { |
| 235 | pr_err(" waiting for ver info- timed out or received signal"); |
| 236 | return timeout ? -ERESTARTSYS : -ETIMEDOUT; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 237 | } |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 238 | reinit_completion(&kim_gdata->kim_rcvd); |
Pavan Savoy | 8565adb | 2012-08-03 14:49:43 -0500 | [diff] [blame] | 239 | /* the positions 12 & 13 in the response buffer provide with the |
| 240 | * chip, major & minor numbers |
| 241 | */ |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 242 | |
| 243 | version = |
Pavan Savoy | 8565adb | 2012-08-03 14:49:43 -0500 | [diff] [blame] | 244 | MAKEWORD(kim_gdata->resp_buffer[12], |
| 245 | kim_gdata->resp_buffer[13]); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 246 | chip = (version & 0x7C00) >> 10; |
| 247 | min_ver = (version & 0x007F); |
| 248 | maj_ver = (version & 0x0380) >> 7; |
| 249 | |
| 250 | if (version & 0x8000) |
| 251 | maj_ver |= 0x0008; |
| 252 | |
Enric Balletbo i Serra | 4dcc2ab | 2014-07-22 13:08:38 +0200 | [diff] [blame] | 253 | sprintf(bts_scr_name, "ti-connectivity/TIInit_%d.%d.%d.bts", |
| 254 | chip, maj_ver, min_ver); |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 255 | |
| 256 | /* to be accessed later via sysfs entry */ |
| 257 | kim_gdata->version.full = version; |
| 258 | kim_gdata->version.chip = chip; |
| 259 | kim_gdata->version.maj_ver = maj_ver; |
| 260 | kim_gdata->version.min_ver = min_ver; |
| 261 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 262 | pr_info("%s", bts_scr_name); |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 263 | return 0; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 264 | } |
| 265 | |
Pavan Savoy | 27712b3 | 2012-08-03 14:49:40 -0500 | [diff] [blame] | 266 | static void skip_change_remote_baud(unsigned char **ptr, long *len) |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 267 | { |
| 268 | unsigned char *nxt_action, *cur_action; |
| 269 | cur_action = *ptr; |
| 270 | |
| 271 | nxt_action = cur_action + sizeof(struct bts_action) + |
| 272 | ((struct bts_action *) cur_action)->size; |
| 273 | |
| 274 | if (((struct bts_action *) nxt_action)->type != ACTION_WAIT_EVENT) { |
| 275 | pr_err("invalid action after change remote baud command"); |
| 276 | } else { |
| 277 | *ptr = *ptr + sizeof(struct bts_action) + |
Shahar Lev | 9d031d9 | 2011-05-23 11:36:11 +0300 | [diff] [blame] | 278 | ((struct bts_action *)cur_action)->size; |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 279 | *len = *len - (sizeof(struct bts_action) + |
Shahar Lev | 9d031d9 | 2011-05-23 11:36:11 +0300 | [diff] [blame] | 280 | ((struct bts_action *)cur_action)->size); |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 281 | /* warn user on not commenting these in firmware */ |
| 282 | pr_warn("skipping the wait event of change remote baud"); |
| 283 | } |
| 284 | } |
| 285 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 286 | /** |
| 287 | * download_firmware - |
| 288 | * internal function which parses through the .bts firmware |
| 289 | * script file intreprets SEND, DELAY actions only as of now |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 290 | */ |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 291 | static long download_firmware(struct kim_data_s *kim_gdata) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 292 | { |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 293 | long err = 0; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 294 | long len = 0; |
Pavan Savoy | 73f12e8 | 2010-10-12 16:27:38 -0400 | [diff] [blame] | 295 | unsigned char *ptr = NULL; |
| 296 | unsigned char *action_ptr = NULL; |
Enric Balletbo i Serra | 4dcc2ab | 2014-07-22 13:08:38 +0200 | [diff] [blame] | 297 | unsigned char bts_scr_name[40] = { 0 }; /* 40 char long bts scr name? */ |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 298 | int wr_room_space; |
| 299 | int cmd_size; |
| 300 | unsigned long timeout; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 301 | |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 302 | err = read_local_version(kim_gdata, bts_scr_name); |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 303 | if (err != 0) { |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 304 | pr_err("kim: failed to read local ver"); |
| 305 | return err; |
| 306 | } |
| 307 | err = |
| 308 | request_firmware(&kim_gdata->fw_entry, bts_scr_name, |
| 309 | &kim_gdata->kim_pdev->dev); |
| 310 | if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) || |
| 311 | (kim_gdata->fw_entry->size == 0))) { |
| 312 | pr_err(" request_firmware failed(errno %ld) for %s", err, |
| 313 | bts_scr_name); |
Pavan Savoy | 7044266 | 2011-02-04 02:23:11 -0600 | [diff] [blame] | 314 | return -EINVAL; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 315 | } |
| 316 | ptr = (void *)kim_gdata->fw_entry->data; |
| 317 | len = kim_gdata->fw_entry->size; |
| 318 | /* bts_header to remove out magic number and |
| 319 | * version |
| 320 | */ |
| 321 | ptr += sizeof(struct bts_header); |
| 322 | len -= sizeof(struct bts_header); |
| 323 | |
| 324 | while (len > 0 && ptr) { |
Pavan Savoy | e6d9e64 | 2010-07-22 05:32:05 -0500 | [diff] [blame] | 325 | pr_debug(" action size %d, type %d ", |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 326 | ((struct bts_action *)ptr)->size, |
| 327 | ((struct bts_action *)ptr)->type); |
| 328 | |
| 329 | switch (((struct bts_action *)ptr)->type) { |
| 330 | case ACTION_SEND_COMMAND: /* action send */ |
Pavan Savoy | 2f81a02 | 2011-08-10 10:18:34 -0500 | [diff] [blame] | 331 | pr_debug("S"); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 332 | action_ptr = &(((struct bts_action *)ptr)->data[0]); |
| 333 | if (unlikely |
| 334 | (((struct hci_command *)action_ptr)->opcode == |
| 335 | 0xFF36)) { |
| 336 | /* ignore remote change |
| 337 | * baud rate HCI VS command */ |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 338 | pr_warn("change remote baud" |
Pavan Savoy | e6d9e64 | 2010-07-22 05:32:05 -0500 | [diff] [blame] | 339 | " rate command in firmware"); |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 340 | skip_change_remote_baud(&ptr, &len); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 341 | break; |
| 342 | } |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 343 | /* |
| 344 | * Make sure we have enough free space in uart |
| 345 | * tx buffer to write current firmware command |
| 346 | */ |
| 347 | cmd_size = ((struct bts_action *)ptr)->size; |
| 348 | timeout = jiffies + msecs_to_jiffies(CMD_WR_TIME); |
| 349 | do { |
| 350 | wr_room_space = |
| 351 | st_get_uart_wr_room(kim_gdata->core_data); |
| 352 | if (wr_room_space < 0) { |
| 353 | pr_err("Unable to get free " |
| 354 | "space info from uart tx buffer"); |
| 355 | release_firmware(kim_gdata->fw_entry); |
| 356 | return wr_room_space; |
| 357 | } |
| 358 | mdelay(1); /* wait 1ms before checking room */ |
| 359 | } while ((wr_room_space < cmd_size) && |
| 360 | time_before(jiffies, timeout)); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 361 | |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 362 | /* Timeout happened ? */ |
| 363 | if (time_after_eq(jiffies, timeout)) { |
| 364 | pr_err("Timeout while waiting for free " |
| 365 | "free space in uart tx buffer"); |
| 366 | release_firmware(kim_gdata->fw_entry); |
| 367 | return -ETIMEDOUT; |
| 368 | } |
Pavan Savoy | 2f81a02 | 2011-08-10 10:18:34 -0500 | [diff] [blame] | 369 | /* reinit completion before sending for the |
| 370 | * relevant wait |
| 371 | */ |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 372 | reinit_completion(&kim_gdata->kim_rcvd); |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 373 | |
| 374 | /* |
| 375 | * Free space found in uart buffer, call st_int_write |
| 376 | * to send current firmware command to the uart tx |
| 377 | * buffer. |
| 378 | */ |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 379 | err = st_int_write(kim_gdata->core_data, |
| 380 | ((struct bts_action_send *)action_ptr)->data, |
| 381 | ((struct bts_action *)ptr)->size); |
| 382 | if (unlikely(err < 0)) { |
| 383 | release_firmware(kim_gdata->fw_entry); |
Pavan Savoy | 7044266 | 2011-02-04 02:23:11 -0600 | [diff] [blame] | 384 | return err; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 385 | } |
Pavan Savoy | ef04d12 | 2011-02-04 02:23:13 -0600 | [diff] [blame] | 386 | /* |
| 387 | * Check number of bytes written to the uart tx buffer |
| 388 | * and requested command write size |
| 389 | */ |
| 390 | if (err != cmd_size) { |
| 391 | pr_err("Number of bytes written to uart " |
| 392 | "tx buffer are not matching with " |
| 393 | "requested cmd write size"); |
| 394 | release_firmware(kim_gdata->fw_entry); |
| 395 | return -EIO; |
| 396 | } |
| 397 | break; |
| 398 | case ACTION_WAIT_EVENT: /* wait */ |
Pavan Savoy | 2f81a02 | 2011-08-10 10:18:34 -0500 | [diff] [blame] | 399 | pr_debug("W"); |
Nicholas Mc Guire | 3f46d81 | 2015-01-20 06:27:45 +0100 | [diff] [blame^] | 400 | err = wait_for_completion_interruptible_timeout( |
Pavan Savoy | 5370235 | 2012-08-03 14:49:42 -0500 | [diff] [blame] | 401 | &kim_gdata->kim_rcvd, |
Nicholas Mc Guire | 3f46d81 | 2015-01-20 06:27:45 +0100 | [diff] [blame^] | 402 | msecs_to_jiffies(CMD_RESP_TIME)); |
| 403 | if (err <= 0) { |
| 404 | pr_err("response timeout/signaled during fw download "); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 405 | /* timed out */ |
| 406 | release_firmware(kim_gdata->fw_entry); |
Nicholas Mc Guire | 3f46d81 | 2015-01-20 06:27:45 +0100 | [diff] [blame^] | 407 | return err ? -ERESTARTSYS : -ETIMEDOUT; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 408 | } |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 409 | reinit_completion(&kim_gdata->kim_rcvd); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 410 | break; |
| 411 | case ACTION_DELAY: /* sleep */ |
| 412 | pr_info("sleep command in scr"); |
| 413 | action_ptr = &(((struct bts_action *)ptr)->data[0]); |
| 414 | mdelay(((struct bts_action_delay *)action_ptr)->msec); |
| 415 | break; |
| 416 | } |
| 417 | len = |
| 418 | len - (sizeof(struct bts_action) + |
| 419 | ((struct bts_action *)ptr)->size); |
| 420 | ptr = |
| 421 | ptr + sizeof(struct bts_action) + |
| 422 | ((struct bts_action *)ptr)->size; |
| 423 | } |
| 424 | /* fw download complete */ |
| 425 | release_firmware(kim_gdata->fw_entry); |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 426 | return 0; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | /**********************************************************************/ |
| 430 | /* functions called from ST core */ |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 431 | /* called from ST Core, when REG_IN_PROGRESS (registration in progress) |
| 432 | * can be because of |
| 433 | * 1. response to read local version |
| 434 | * 2. during send/recv's of firmware download |
| 435 | */ |
| 436 | void st_kim_recv(void *disc_data, const unsigned char *data, long count) |
| 437 | { |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 438 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; |
| 439 | struct kim_data_s *kim_gdata = st_gdata->kim_data; |
| 440 | |
Pavan Savoy | 8565adb | 2012-08-03 14:49:43 -0500 | [diff] [blame] | 441 | /* proceed to gather all data and distinguish read fw version response |
| 442 | * from other fw responses when data gathering is complete |
| 443 | */ |
| 444 | kim_int_recv(kim_gdata, data, count); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 445 | return; |
| 446 | } |
| 447 | |
| 448 | /* to signal completion of line discipline installation |
| 449 | * called from ST Core, upon tty_open |
| 450 | */ |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 451 | void st_kim_complete(void *kim_data) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 452 | { |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 453 | struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 454 | complete(&kim_gdata->ldisc_installed); |
| 455 | } |
| 456 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 457 | /** |
| 458 | * st_kim_start - called from ST Core upon 1st registration |
| 459 | * This involves toggling the chip enable gpio, reading |
| 460 | * the firmware version from chip, forming the fw file name |
| 461 | * based on the chip version, requesting the fw, parsing it |
| 462 | * and perform download(send/recv). |
| 463 | */ |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 464 | long st_kim_start(void *kim_data) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 465 | { |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 466 | long err = 0; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 467 | long retry = POR_RETRY_COUNT; |
Pavan Savoy | 0d7c5f2 | 2011-08-10 10:18:31 -0500 | [diff] [blame] | 468 | struct ti_st_plat_data *pdata; |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 469 | struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; |
| 470 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 471 | pr_info(" %s", __func__); |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 472 | if (kim_gdata->kim_pdev->dev.of_node) { |
| 473 | pr_debug("use device tree data"); |
| 474 | pdata = dt_pdata; |
| 475 | } else { |
| 476 | pdata = kim_gdata->kim_pdev->dev.platform_data; |
| 477 | } |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 478 | |
| 479 | do { |
Pavan Savoy | 0d7c5f2 | 2011-08-10 10:18:31 -0500 | [diff] [blame] | 480 | /* platform specific enabling code here */ |
| 481 | if (pdata->chip_enable) |
| 482 | pdata->chip_enable(kim_gdata); |
| 483 | |
Luciano Coelho | a7e2ca1 | 2013-01-21 13:12:42 +0200 | [diff] [blame] | 484 | /* Configure BT nShutdown to HIGH state */ |
| 485 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); |
| 486 | mdelay(5); /* FIXME: a proper toggle */ |
| 487 | gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); |
| 488 | mdelay(100); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 489 | /* re-initialize the completion */ |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 490 | reinit_completion(&kim_gdata->ldisc_installed); |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 491 | /* send notification to UIM */ |
| 492 | kim_gdata->ldisc_install = 1; |
| 493 | pr_info("ldisc_install = 1"); |
| 494 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, |
| 495 | NULL, "install"); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 496 | /* wait for ldisc to be installed */ |
Pavan Savoy | 5370235 | 2012-08-03 14:49:42 -0500 | [diff] [blame] | 497 | err = wait_for_completion_interruptible_timeout( |
| 498 | &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 499 | if (!err) { |
| 500 | /* ldisc installation timeout, |
| 501 | * flush uart, power cycle BT_EN */ |
| 502 | pr_err("ldisc installation timeout"); |
| 503 | err = st_kim_stop(kim_gdata); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 504 | continue; |
| 505 | } else { |
| 506 | /* ldisc installed now */ |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 507 | pr_info("line discipline installed"); |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 508 | err = download_firmware(kim_gdata); |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 509 | if (err != 0) { |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 510 | /* ldisc installed but fw download failed, |
| 511 | * flush uart & power cycle BT_EN */ |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 512 | pr_err("download firmware failed"); |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 513 | err = st_kim_stop(kim_gdata); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 514 | continue; |
| 515 | } else { /* on success don't retry */ |
| 516 | break; |
| 517 | } |
| 518 | } |
| 519 | } while (retry--); |
| 520 | return err; |
| 521 | } |
| 522 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 523 | /** |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 524 | * st_kim_stop - stop communication with chip. |
| 525 | * This can be called from ST Core/KIM, on the- |
| 526 | * (a) last un-register when chip need not be powered there-after, |
| 527 | * (b) upon failure to either install ldisc or download firmware. |
| 528 | * The function is responsible to (a) notify UIM about un-installation, |
| 529 | * (b) flush UART if the ldisc was installed. |
Luciano Coelho | a7e2ca1 | 2013-01-21 13:12:42 +0200 | [diff] [blame] | 530 | * (c) reset BT_EN - pull down nshutdown at the end. |
| 531 | * (d) invoke platform's chip disabling routine. |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 532 | */ |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 533 | long st_kim_stop(void *kim_data) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 534 | { |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 535 | long err = 0; |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 536 | struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data; |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 537 | struct ti_st_plat_data *pdata; |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 538 | struct tty_struct *tty = kim_gdata->core_data->tty; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 539 | |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 540 | reinit_completion(&kim_gdata->ldisc_installed); |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 541 | |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 542 | if (kim_gdata->kim_pdev->dev.of_node) { |
| 543 | pr_debug("use device tree data"); |
| 544 | pdata = dt_pdata; |
| 545 | } else |
| 546 | pdata = kim_gdata->kim_pdev->dev.platform_data; |
| 547 | |
| 548 | |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 549 | if (tty) { /* can be called before ldisc is installed */ |
| 550 | /* Flush any pending characters in the driver and discipline. */ |
| 551 | tty_ldisc_flush(tty); |
| 552 | tty_driver_flush_buffer(tty); |
Pavan Savoy | 18ccecf | 2011-12-15 10:38:21 -0600 | [diff] [blame] | 553 | } |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 554 | |
| 555 | /* send uninstall notification to UIM */ |
| 556 | pr_info("ldisc_install = 0"); |
| 557 | kim_gdata->ldisc_install = 0; |
| 558 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install"); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 559 | |
| 560 | /* wait for ldisc to be un-installed */ |
Pavan Savoy | 5370235 | 2012-08-03 14:49:42 -0500 | [diff] [blame] | 561 | err = wait_for_completion_interruptible_timeout( |
| 562 | &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 563 | if (!err) { /* timeout */ |
| 564 | pr_err(" timed out waiting for ldisc to be un-installed"); |
Pavan Savoy | b64365a | 2012-08-03 14:49:41 -0500 | [diff] [blame] | 565 | err = -ETIMEDOUT; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 566 | } |
| 567 | |
Luciano Coelho | a7e2ca1 | 2013-01-21 13:12:42 +0200 | [diff] [blame] | 568 | /* By default configure BT nShutdown to LOW state */ |
| 569 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); |
| 570 | mdelay(1); |
| 571 | gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); |
| 572 | mdelay(1); |
| 573 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); |
| 574 | |
Pavan Savoy | 0d7c5f2 | 2011-08-10 10:18:31 -0500 | [diff] [blame] | 575 | /* platform specific disable */ |
| 576 | if (pdata->chip_disable) |
| 577 | pdata->chip_disable(kim_gdata); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 578 | return err; |
| 579 | } |
| 580 | |
| 581 | /**********************************************************************/ |
| 582 | /* functions called from subsystems */ |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 583 | /* called when debugfs entry is read from */ |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 584 | |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 585 | static int show_version(struct seq_file *s, void *unused) |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 586 | { |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 587 | struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; |
| 588 | seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full, |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 589 | kim_gdata->version.chip, kim_gdata->version.maj_ver, |
| 590 | kim_gdata->version.min_ver); |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 591 | return 0; |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 592 | } |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 593 | |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 594 | static int show_list(struct seq_file *s, void *unused) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 595 | { |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 596 | struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; |
| 597 | kim_st_list_protocols(kim_gdata->core_data, s); |
| 598 | return 0; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 599 | } |
| 600 | |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 601 | static ssize_t show_install(struct device *dev, |
| 602 | struct device_attribute *attr, char *buf) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 603 | { |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 604 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
| 605 | return sprintf(buf, "%d\n", kim_data->ldisc_install); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 606 | } |
| 607 | |
Pavan Savoy | 933aae5 | 2011-12-15 10:38:22 -0600 | [diff] [blame] | 608 | #ifdef DEBUG |
| 609 | static ssize_t store_dev_name(struct device *dev, |
| 610 | struct device_attribute *attr, const char *buf, size_t count) |
| 611 | { |
| 612 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
| 613 | pr_debug("storing dev name >%s<", buf); |
| 614 | strncpy(kim_data->dev_name, buf, count); |
| 615 | pr_debug("stored dev name >%s<", kim_data->dev_name); |
| 616 | return count; |
| 617 | } |
| 618 | |
| 619 | static ssize_t store_baud_rate(struct device *dev, |
| 620 | struct device_attribute *attr, const char *buf, size_t count) |
| 621 | { |
| 622 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
| 623 | pr_debug("storing baud rate >%s<", buf); |
| 624 | sscanf(buf, "%ld", &kim_data->baud_rate); |
| 625 | pr_debug("stored baud rate >%ld<", kim_data->baud_rate); |
| 626 | return count; |
| 627 | } |
| 628 | #endif /* if DEBUG */ |
| 629 | |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 630 | static ssize_t show_dev_name(struct device *dev, |
| 631 | struct device_attribute *attr, char *buf) |
| 632 | { |
| 633 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
| 634 | return sprintf(buf, "%s\n", kim_data->dev_name); |
| 635 | } |
| 636 | |
| 637 | static ssize_t show_baud_rate(struct device *dev, |
| 638 | struct device_attribute *attr, char *buf) |
| 639 | { |
| 640 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
| 641 | return sprintf(buf, "%ld\n", kim_data->baud_rate); |
| 642 | } |
| 643 | |
| 644 | static ssize_t show_flow_cntrl(struct device *dev, |
| 645 | struct device_attribute *attr, char *buf) |
| 646 | { |
| 647 | struct kim_data_s *kim_data = dev_get_drvdata(dev); |
| 648 | return sprintf(buf, "%d\n", kim_data->flow_cntrl); |
| 649 | } |
| 650 | |
| 651 | /* structures specific for sysfs entries */ |
| 652 | static struct kobj_attribute ldisc_install = |
| 653 | __ATTR(install, 0444, (void *)show_install, NULL); |
| 654 | |
| 655 | static struct kobj_attribute uart_dev_name = |
Pavan Savoy | 933aae5 | 2011-12-15 10:38:22 -0600 | [diff] [blame] | 656 | #ifdef DEBUG /* TODO: move this to debug-fs if possible */ |
| 657 | __ATTR(dev_name, 0644, (void *)show_dev_name, (void *)store_dev_name); |
| 658 | #else |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 659 | __ATTR(dev_name, 0444, (void *)show_dev_name, NULL); |
Pavan Savoy | 933aae5 | 2011-12-15 10:38:22 -0600 | [diff] [blame] | 660 | #endif |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 661 | |
| 662 | static struct kobj_attribute uart_baud_rate = |
Pavan Savoy | 933aae5 | 2011-12-15 10:38:22 -0600 | [diff] [blame] | 663 | #ifdef DEBUG /* TODO: move to debugfs */ |
| 664 | __ATTR(baud_rate, 0644, (void *)show_baud_rate, (void *)store_baud_rate); |
| 665 | #else |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 666 | __ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL); |
Pavan Savoy | 933aae5 | 2011-12-15 10:38:22 -0600 | [diff] [blame] | 667 | #endif |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 668 | |
| 669 | static struct kobj_attribute uart_flow_cntrl = |
| 670 | __ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL); |
| 671 | |
| 672 | static struct attribute *uim_attrs[] = { |
| 673 | &ldisc_install.attr, |
| 674 | &uart_dev_name.attr, |
| 675 | &uart_baud_rate.attr, |
| 676 | &uart_flow_cntrl.attr, |
| 677 | NULL, |
| 678 | }; |
| 679 | |
| 680 | static struct attribute_group uim_attr_grp = { |
| 681 | .attrs = uim_attrs, |
| 682 | }; |
| 683 | |
Pavan Savoy | 36b5aee | 2010-07-22 05:32:06 -0500 | [diff] [blame] | 684 | /** |
| 685 | * st_kim_ref - reference the core's data |
| 686 | * This references the per-ST platform device in the arch/xx/ |
| 687 | * board-xx.c file. |
| 688 | * This would enable multiple such platform devices to exist |
| 689 | * on a given platform |
| 690 | */ |
Pavan Savoy | dbd3a87 | 2010-08-19 14:08:51 -0400 | [diff] [blame] | 691 | void st_kim_ref(struct st_data_s **core_data, int id) |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 692 | { |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 693 | struct platform_device *pdev; |
| 694 | struct kim_data_s *kim_gdata; |
| 695 | /* get kim_gdata reference from platform device */ |
Pavan Savoy | dbd3a87 | 2010-08-19 14:08:51 -0400 | [diff] [blame] | 696 | pdev = st_get_plat_device(id); |
Gigi Joseph | 868eba8 | 2015-01-09 03:48:29 +0000 | [diff] [blame] | 697 | if (!pdev) |
| 698 | goto err; |
Jingoo Han | 9093ca8 | 2013-05-23 19:35:23 +0900 | [diff] [blame] | 699 | kim_gdata = platform_get_drvdata(pdev); |
Gigi Joseph | 868eba8 | 2015-01-09 03:48:29 +0000 | [diff] [blame] | 700 | if (!kim_gdata) |
| 701 | goto err; |
| 702 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 703 | *core_data = kim_gdata->core_data; |
Gigi Joseph | 868eba8 | 2015-01-09 03:48:29 +0000 | [diff] [blame] | 704 | return; |
| 705 | err: |
| 706 | *core_data = NULL; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 707 | } |
| 708 | |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 709 | static int kim_version_open(struct inode *i, struct file *f) |
| 710 | { |
| 711 | return single_open(f, show_version, i->i_private); |
| 712 | } |
| 713 | |
| 714 | static int kim_list_open(struct inode *i, struct file *f) |
| 715 | { |
| 716 | return single_open(f, show_list, i->i_private); |
| 717 | } |
| 718 | |
| 719 | static const struct file_operations version_debugfs_fops = { |
| 720 | /* version info */ |
| 721 | .open = kim_version_open, |
| 722 | .read = seq_read, |
| 723 | .llseek = seq_lseek, |
| 724 | .release = single_release, |
| 725 | }; |
| 726 | static const struct file_operations list_debugfs_fops = { |
| 727 | /* protocols info */ |
| 728 | .open = kim_list_open, |
| 729 | .read = seq_read, |
| 730 | .llseek = seq_lseek, |
| 731 | .release = single_release, |
| 732 | }; |
| 733 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 734 | /**********************************************************************/ |
| 735 | /* functions called from platform device driver subsystem |
| 736 | * need to have a relevant platform device entry in the platform's |
| 737 | * board-*.c file |
| 738 | */ |
| 739 | |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 740 | static const struct of_device_id kim_of_match[] = { |
| 741 | { |
| 742 | .compatible = "kim", |
| 743 | }, |
| 744 | {} |
| 745 | }; |
| 746 | MODULE_DEVICE_TABLE(of, kim_of_match); |
| 747 | |
| 748 | static struct ti_st_plat_data *get_platform_data(struct device *dev) |
| 749 | { |
| 750 | struct device_node *np = dev->of_node; |
| 751 | const u32 *dt_property; |
| 752 | int len; |
| 753 | |
| 754 | dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL); |
| 755 | |
| 756 | if (!dt_pdata) |
| 757 | pr_err("Can't allocate device_tree platform data\n"); |
| 758 | |
| 759 | dt_property = of_get_property(np, "dev_name", &len); |
| 760 | if (dt_property) |
| 761 | memcpy(&dt_pdata->dev_name, dt_property, len); |
| 762 | of_property_read_u32(np, "nshutdown_gpio", |
| 763 | (u32 *)&dt_pdata->nshutdown_gpio); |
| 764 | of_property_read_u32(np, "flow_cntrl", (u32 *)&dt_pdata->flow_cntrl); |
| 765 | of_property_read_u32(np, "baud_rate", (u32 *)&dt_pdata->baud_rate); |
| 766 | |
| 767 | return dt_pdata; |
| 768 | } |
| 769 | |
Pavan Savoy | 27712b3 | 2012-08-03 14:49:40 -0500 | [diff] [blame] | 770 | static struct dentry *kim_debugfs_dir; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 771 | static int kim_probe(struct platform_device *pdev) |
| 772 | { |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 773 | struct kim_data_s *kim_gdata; |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 774 | struct ti_st_plat_data *pdata; |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 775 | int err; |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 776 | |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 777 | if (pdev->dev.of_node) |
| 778 | pdata = get_platform_data(&pdev->dev); |
| 779 | else |
| 780 | pdata = pdev->dev.platform_data; |
| 781 | |
| 782 | if (pdata == NULL) { |
| 783 | dev_err(&pdev->dev, "Platform Data is missing\n"); |
| 784 | return -ENXIO; |
| 785 | } |
| 786 | |
Pavan Savoy | dfb7ef7 | 2010-09-10 15:58:55 -0400 | [diff] [blame] | 787 | if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) { |
| 788 | /* multiple devices could exist */ |
| 789 | st_kim_devices[pdev->id] = pdev; |
| 790 | } else { |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 791 | /* platform's sure about existence of 1 device */ |
Pavan Savoy | dfb7ef7 | 2010-09-10 15:58:55 -0400 | [diff] [blame] | 792 | st_kim_devices[0] = pdev; |
| 793 | } |
| 794 | |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 795 | kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC); |
| 796 | if (!kim_gdata) { |
| 797 | pr_err("no mem to allocate"); |
| 798 | return -ENOMEM; |
| 799 | } |
Jingoo Han | 9093ca8 | 2013-05-23 19:35:23 +0900 | [diff] [blame] | 800 | platform_set_drvdata(pdev, kim_gdata); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 801 | |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 802 | err = st_core_init(&kim_gdata->core_data); |
| 803 | if (err != 0) { |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 804 | pr_err(" ST core init failed"); |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 805 | err = -EIO; |
| 806 | goto err_core_init; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 807 | } |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 808 | /* refer to itself */ |
| 809 | kim_gdata->core_data->kim_data = kim_gdata; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 810 | |
Luciano Coelho | a7e2ca1 | 2013-01-21 13:12:42 +0200 | [diff] [blame] | 811 | /* Claim the chip enable nShutdown gpio from the system */ |
| 812 | kim_gdata->nshutdown = pdata->nshutdown_gpio; |
| 813 | err = gpio_request(kim_gdata->nshutdown, "kim"); |
| 814 | if (unlikely(err)) { |
| 815 | pr_err(" gpio %ld request failed ", kim_gdata->nshutdown); |
| 816 | return err; |
| 817 | } |
| 818 | |
| 819 | /* Configure nShutdown GPIO as output=0 */ |
| 820 | err = gpio_direction_output(kim_gdata->nshutdown, 0); |
| 821 | if (unlikely(err)) { |
| 822 | pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown); |
| 823 | return err; |
| 824 | } |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 825 | /* get reference of pdev for request_firmware |
| 826 | */ |
| 827 | kim_gdata->kim_pdev = pdev; |
| 828 | init_completion(&kim_gdata->kim_rcvd); |
| 829 | init_completion(&kim_gdata->ldisc_installed); |
Naveen Jain | b38fc2d | 2010-06-09 03:45:32 -0500 | [diff] [blame] | 830 | |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 831 | err = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp); |
| 832 | if (err) { |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 833 | pr_err("failed to create sysfs entries"); |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 834 | goto err_sysfs_group; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 835 | } |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 836 | |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 837 | /* copying platform data */ |
| 838 | strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN); |
| 839 | kim_gdata->flow_cntrl = pdata->flow_cntrl; |
| 840 | kim_gdata->baud_rate = pdata->baud_rate; |
| 841 | pr_info("sysfs entries created\n"); |
| 842 | |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 843 | kim_debugfs_dir = debugfs_create_dir("ti-st", NULL); |
Robin van der Gracht | 3768528 | 2014-06-16 16:38:56 +0200 | [diff] [blame] | 844 | if (!kim_debugfs_dir) { |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 845 | pr_err(" debugfs entries creation failed "); |
Gigi Joseph | c6ec0fb | 2015-01-09 03:47:51 +0000 | [diff] [blame] | 846 | return 0; |
Naveen Jain | e2a5328 | 2010-06-09 03:45:33 -0500 | [diff] [blame] | 847 | } |
Pavan Savoy | c1afac1 | 2010-07-28 02:25:59 -0500 | [diff] [blame] | 848 | |
| 849 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, |
| 850 | kim_gdata, &version_debugfs_fops); |
| 851 | debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir, |
| 852 | kim_gdata, &list_debugfs_fops); |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 853 | return 0; |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 854 | |
Matthias Kaehlcke | b299738 | 2012-11-22 23:26:14 +0100 | [diff] [blame] | 855 | err_sysfs_group: |
| 856 | st_core_exit(kim_gdata->core_data); |
| 857 | |
| 858 | err_core_init: |
| 859 | kfree(kim_gdata); |
| 860 | |
| 861 | return err; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | static int kim_remove(struct platform_device *pdev) |
| 865 | { |
Luciano Coelho | a7e2ca1 | 2013-01-21 13:12:42 +0200 | [diff] [blame] | 866 | /* free the GPIOs requested */ |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 867 | struct ti_st_plat_data *pdata; |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 868 | struct kim_data_s *kim_gdata; |
| 869 | |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 870 | if (pdev->dev.of_node) { |
| 871 | pr_debug("use device tree data"); |
| 872 | pdata = dt_pdata; |
| 873 | } else { |
| 874 | pdata = pdev->dev.platform_data; |
| 875 | } |
| 876 | |
Jingoo Han | 9093ca8 | 2013-05-23 19:35:23 +0900 | [diff] [blame] | 877 | kim_gdata = platform_get_drvdata(pdev); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 878 | |
Luciano Coelho | a7e2ca1 | 2013-01-21 13:12:42 +0200 | [diff] [blame] | 879 | /* Free the Bluetooth/FM/GPIO |
| 880 | * nShutdown gpio from the system |
| 881 | */ |
| 882 | gpio_free(pdata->nshutdown_gpio); |
| 883 | pr_info("nshutdown GPIO Freed"); |
| 884 | |
Pavan Savoy | 781a739 | 2011-02-04 02:23:15 -0600 | [diff] [blame] | 885 | debugfs_remove_recursive(kim_debugfs_dir); |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 886 | sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); |
Pavan Savoy | 781a739 | 2011-02-04 02:23:15 -0600 | [diff] [blame] | 887 | pr_info("sysfs entries removed"); |
| 888 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 889 | kim_gdata->kim_pdev = NULL; |
| 890 | st_core_exit(kim_gdata->core_data); |
Pavan Savoy | 38d9df4 | 2010-07-08 08:55:17 -0500 | [diff] [blame] | 891 | |
| 892 | kfree(kim_gdata); |
| 893 | kim_gdata = NULL; |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 894 | kfree(dt_pdata); |
| 895 | dt_pdata = NULL; |
| 896 | |
Pavan Savoy | 320920c | 2010-07-14 08:21:12 -0500 | [diff] [blame] | 897 | return 0; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 898 | } |
| 899 | |
Pavan Savoy | 27712b3 | 2012-08-03 14:49:40 -0500 | [diff] [blame] | 900 | static int kim_suspend(struct platform_device *pdev, pm_message_t state) |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 901 | { |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 902 | struct ti_st_plat_data *pdata; |
| 903 | |
| 904 | if (pdev->dev.of_node) { |
| 905 | pr_debug("use device tree data"); |
| 906 | pdata = dt_pdata; |
| 907 | } else { |
| 908 | pdata = pdev->dev.platform_data; |
| 909 | } |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 910 | |
| 911 | if (pdata->suspend) |
| 912 | return pdata->suspend(pdev, state); |
| 913 | |
Gigi Joseph | 4b4aa3a | 2015-01-09 03:46:24 +0000 | [diff] [blame] | 914 | return 0; |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 915 | } |
| 916 | |
Pavan Savoy | 27712b3 | 2012-08-03 14:49:40 -0500 | [diff] [blame] | 917 | static int kim_resume(struct platform_device *pdev) |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 918 | { |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 919 | struct ti_st_plat_data *pdata; |
| 920 | |
| 921 | if (pdev->dev.of_node) { |
| 922 | pr_debug("use device tree data"); |
| 923 | pdata = dt_pdata; |
| 924 | } else { |
| 925 | pdata = pdev->dev.platform_data; |
| 926 | } |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 927 | |
| 928 | if (pdata->resume) |
| 929 | return pdata->resume(pdev); |
| 930 | |
Gigi Joseph | 4b4aa3a | 2015-01-09 03:46:24 +0000 | [diff] [blame] | 931 | return 0; |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 932 | } |
| 933 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 934 | /**********************************************************************/ |
| 935 | /* entry point for ST KIM module, called in from ST Core */ |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 936 | static struct platform_driver kim_platform_driver = { |
| 937 | .probe = kim_probe, |
| 938 | .remove = kim_remove, |
| 939 | .suspend = kim_suspend, |
| 940 | .resume = kim_resume, |
| 941 | .driver = { |
| 942 | .name = "kim", |
Gigi Joseph | 46d0d33 | 2015-01-09 03:45:02 +0000 | [diff] [blame] | 943 | .owner = THIS_MODULE, |
| 944 | .of_match_table = of_match_ptr(kim_of_match), |
Pavan Savoy | ec60d0a | 2011-02-04 02:23:10 -0600 | [diff] [blame] | 945 | }, |
| 946 | }; |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 947 | |
Axel Lin | b00e126 | 2012-01-22 15:33:49 +0800 | [diff] [blame] | 948 | module_platform_driver(kim_platform_driver); |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 949 | |
Pavan Savoy | d0088ce | 2010-04-08 13:16:54 -0500 | [diff] [blame] | 950 | MODULE_AUTHOR("Pavan Savoy <pavan_savoy@ti.com>"); |
| 951 | MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips "); |
| 952 | MODULE_LICENSE("GPL"); |