Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * I2C Link Layer for ST21NFCA HCI based Driver |
| 3 | * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU General Public License, |
| 7 | * version 2, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 19 | |
| 20 | #include <linux/crc-ccitt.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/i2c.h> |
| 23 | #include <linux/gpio.h> |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 24 | #include <linux/gpio/consumer.h> |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 25 | #include <linux/of_irq.h> |
| 26 | #include <linux/of_gpio.h> |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 27 | #include <linux/acpi.h> |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 28 | #include <linux/miscdevice.h> |
| 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/delay.h> |
| 31 | #include <linux/nfc.h> |
| 32 | #include <linux/firmware.h> |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 33 | #include <linux/platform_data/st21nfca.h> |
Johannes Berg | db083bc | 2014-11-19 21:17:22 +0100 | [diff] [blame] | 34 | #include <asm/unaligned.h> |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 35 | |
| 36 | #include <net/nfc/hci.h> |
| 37 | #include <net/nfc/llc.h> |
| 38 | #include <net/nfc/nfc.h> |
| 39 | |
| 40 | #include "st21nfca.h" |
| 41 | |
| 42 | /* |
| 43 | * Every frame starts with ST21NFCA_SOF_EOF and ends with ST21NFCA_SOF_EOF. |
| 44 | * Because ST21NFCA_SOF_EOF is a possible data value, there is a mecanism |
| 45 | * called byte stuffing has been introduced. |
| 46 | * |
| 47 | * if byte == ST21NFCA_SOF_EOF or ST21NFCA_ESCAPE_BYTE_STUFFING |
| 48 | * - insert ST21NFCA_ESCAPE_BYTE_STUFFING (escape byte) |
| 49 | * - xor byte with ST21NFCA_BYTE_STUFFING_MASK |
| 50 | */ |
| 51 | #define ST21NFCA_SOF_EOF 0x7e |
| 52 | #define ST21NFCA_BYTE_STUFFING_MASK 0x20 |
| 53 | #define ST21NFCA_ESCAPE_BYTE_STUFFING 0x7d |
| 54 | |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 55 | /* SOF + 00 */ |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 56 | #define ST21NFCA_FRAME_HEADROOM 2 |
| 57 | |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 58 | /* 2 bytes crc + EOF */ |
| 59 | #define ST21NFCA_FRAME_TAILROOM 3 |
Christophe Ricard | c97ffdb | 2014-04-24 23:19:33 +0200 | [diff] [blame] | 60 | #define IS_START_OF_FRAME(buf) (buf[0] == ST21NFCA_SOF_EOF && \ |
| 61 | buf[1] == 0) |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 62 | |
| 63 | #define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c" |
| 64 | |
Christophe Ricard | 2a19697 | 2016-04-30 09:12:37 +0200 | [diff] [blame] | 65 | #define ST21NFCA_GPIO_NAME_EN "enable" |
Christophe Ricard | 04e99b7 | 2015-12-23 23:45:08 +0100 | [diff] [blame] | 66 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 67 | struct st21nfca_i2c_phy { |
| 68 | struct i2c_client *i2c_dev; |
| 69 | struct nfc_hci_dev *hdev; |
| 70 | |
| 71 | unsigned int gpio_ena; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 72 | unsigned int irq_polarity; |
| 73 | |
Christophe Ricard | 2130fb9 | 2015-01-27 01:18:19 +0100 | [diff] [blame] | 74 | struct st21nfca_se_status se_status; |
| 75 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 76 | struct sk_buff *pending_skb; |
| 77 | int current_read_len; |
| 78 | /* |
| 79 | * crc might have fail because i2c macro |
| 80 | * is disable due to other interface activity |
| 81 | */ |
| 82 | int crc_trials; |
| 83 | |
| 84 | int powered; |
| 85 | int run_mode; |
| 86 | |
| 87 | /* |
| 88 | * < 0 if hardware error occured (e.g. i2c err) |
| 89 | * and prevents normal operation. |
| 90 | */ |
| 91 | int hard_fault; |
Christophe Ricard | a3c5d8f | 2014-04-24 23:19:34 +0200 | [diff] [blame] | 92 | struct mutex phy_lock; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 93 | }; |
Christophe Ricard | 57dc828 | 2015-10-25 22:54:45 +0100 | [diff] [blame] | 94 | |
Christophe Ricard | 0531107 | 2014-05-20 22:21:56 +0200 | [diff] [blame] | 95 | static u8 len_seq[] = { 16, 24, 12, 29 }; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 96 | static u16 wait_tab[] = { 2, 3, 5, 15, 20, 40}; |
| 97 | |
| 98 | #define I2C_DUMP_SKB(info, skb) \ |
| 99 | do { \ |
| 100 | pr_debug("%s:\n", info); \ |
| 101 | print_hex_dump(KERN_DEBUG, "i2c: ", DUMP_PREFIX_OFFSET, \ |
| 102 | 16, 1, (skb)->data, (skb)->len, 0); \ |
| 103 | } while (0) |
| 104 | |
Christophe Ricard | 18d2c62 | 2014-04-01 00:34:07 +0200 | [diff] [blame] | 105 | /* |
| 106 | * In order to get the CLF in a known state we generate an internal reboot |
| 107 | * using a proprietary command. |
| 108 | * Once the reboot is completed, we expect to receive a ST21NFCA_SOF_EOF |
| 109 | * fill buffer. |
| 110 | */ |
| 111 | static int st21nfca_hci_platform_init(struct st21nfca_i2c_phy *phy) |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 112 | { |
Christophe Ricard | c5b0c37 | 2014-04-01 00:34:03 +0200 | [diff] [blame] | 113 | u16 wait_reboot[] = { 50, 300, 1000 }; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 114 | char reboot_cmd[] = { 0x7E, 0x66, 0x48, 0xF6, 0x7E }; |
| 115 | u8 tmp[ST21NFCA_HCI_LLC_MAX_SIZE]; |
| 116 | int i, r = -1; |
| 117 | |
Christophe Ricard | 18d2c62 | 2014-04-01 00:34:07 +0200 | [diff] [blame] | 118 | for (i = 0; i < ARRAY_SIZE(wait_reboot) && r < 0; i++) { |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 119 | r = i2c_master_send(phy->i2c_dev, reboot_cmd, |
| 120 | sizeof(reboot_cmd)); |
Christophe Ricard | 18d2c62 | 2014-04-01 00:34:07 +0200 | [diff] [blame] | 121 | if (r < 0) |
| 122 | msleep(wait_reboot[i]); |
| 123 | } |
| 124 | if (r < 0) |
| 125 | return r; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 126 | |
Christophe Ricard | 18d2c62 | 2014-04-01 00:34:07 +0200 | [diff] [blame] | 127 | /* CLF is spending about 20ms to do an internal reboot */ |
| 128 | msleep(20); |
| 129 | r = -1; |
| 130 | for (i = 0; i < ARRAY_SIZE(wait_reboot) && r < 0; i++) { |
| 131 | r = i2c_master_recv(phy->i2c_dev, tmp, |
| 132 | ST21NFCA_HCI_LLC_MAX_SIZE); |
| 133 | if (r < 0) |
| 134 | msleep(wait_reboot[i]); |
| 135 | } |
| 136 | if (r < 0) |
| 137 | return r; |
| 138 | |
| 139 | for (i = 0; i < ST21NFCA_HCI_LLC_MAX_SIZE && |
| 140 | tmp[i] == ST21NFCA_SOF_EOF; i++) |
| 141 | ; |
| 142 | |
| 143 | if (r != ST21NFCA_HCI_LLC_MAX_SIZE) |
| 144 | return -ENODEV; |
| 145 | |
| 146 | usleep_range(1000, 1500); |
| 147 | return 0; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static int st21nfca_hci_i2c_enable(void *phy_id) |
| 151 | { |
| 152 | struct st21nfca_i2c_phy *phy = phy_id; |
| 153 | |
| 154 | gpio_set_value(phy->gpio_ena, 1); |
| 155 | phy->powered = 1; |
| 156 | phy->run_mode = ST21NFCA_HCI_MODE; |
| 157 | |
| 158 | usleep_range(10000, 15000); |
| 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | static void st21nfca_hci_i2c_disable(void *phy_id) |
| 164 | { |
| 165 | struct st21nfca_i2c_phy *phy = phy_id; |
| 166 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 167 | gpio_set_value(phy->gpio_ena, 0); |
| 168 | |
| 169 | phy->powered = 0; |
| 170 | } |
| 171 | |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 172 | static void st21nfca_hci_add_len_crc(struct sk_buff *skb) |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 173 | { |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 174 | u16 crc; |
| 175 | u8 tmp; |
| 176 | |
| 177 | *skb_push(skb, 1) = 0; |
| 178 | |
| 179 | crc = crc_ccitt(0xffff, skb->data, skb->len); |
| 180 | crc = ~crc; |
| 181 | |
| 182 | tmp = crc & 0x00ff; |
| 183 | *skb_put(skb, 1) = tmp; |
| 184 | |
| 185 | tmp = (crc >> 8) & 0x00ff; |
| 186 | *skb_put(skb, 1) = tmp; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 187 | } |
| 188 | |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 189 | static void st21nfca_hci_remove_len_crc(struct sk_buff *skb) |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 190 | { |
| 191 | skb_pull(skb, ST21NFCA_FRAME_HEADROOM); |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 192 | skb_trim(skb, skb->len - ST21NFCA_FRAME_TAILROOM); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /* |
| 196 | * Writing a frame must not return the number of written bytes. |
| 197 | * It must return either zero for success, or <0 for error. |
| 198 | * In addition, it must not alter the skb |
| 199 | */ |
| 200 | static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb) |
| 201 | { |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 202 | int r = -1, i, j; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 203 | struct st21nfca_i2c_phy *phy = phy_id; |
| 204 | struct i2c_client *client = phy->i2c_dev; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 205 | u8 tmp[ST21NFCA_HCI_LLC_MAX_SIZE * 2]; |
| 206 | |
| 207 | I2C_DUMP_SKB("st21nfca_hci_i2c_write", skb); |
| 208 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 209 | if (phy->hard_fault != 0) |
| 210 | return phy->hard_fault; |
| 211 | |
| 212 | /* |
| 213 | * Compute CRC before byte stuffing computation on frame |
| 214 | * Note st21nfca_hci_add_len_crc is doing a byte stuffing |
| 215 | * on its own value |
| 216 | */ |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 217 | st21nfca_hci_add_len_crc(skb); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 218 | |
| 219 | /* add ST21NFCA_SOF_EOF on tail */ |
| 220 | *skb_put(skb, 1) = ST21NFCA_SOF_EOF; |
| 221 | /* add ST21NFCA_SOF_EOF on head */ |
| 222 | *skb_push(skb, 1) = ST21NFCA_SOF_EOF; |
| 223 | |
| 224 | /* |
| 225 | * Compute byte stuffing |
| 226 | * if byte == ST21NFCA_SOF_EOF or ST21NFCA_ESCAPE_BYTE_STUFFING |
| 227 | * insert ST21NFCA_ESCAPE_BYTE_STUFFING (escape byte) |
| 228 | * xor byte with ST21NFCA_BYTE_STUFFING_MASK |
| 229 | */ |
| 230 | tmp[0] = skb->data[0]; |
| 231 | for (i = 1, j = 1; i < skb->len - 1; i++, j++) { |
| 232 | if (skb->data[i] == ST21NFCA_SOF_EOF |
| 233 | || skb->data[i] == ST21NFCA_ESCAPE_BYTE_STUFFING) { |
| 234 | tmp[j] = ST21NFCA_ESCAPE_BYTE_STUFFING; |
| 235 | j++; |
| 236 | tmp[j] = skb->data[i] ^ ST21NFCA_BYTE_STUFFING_MASK; |
| 237 | } else { |
| 238 | tmp[j] = skb->data[i]; |
| 239 | } |
| 240 | } |
| 241 | tmp[j] = skb->data[i]; |
| 242 | j++; |
| 243 | |
| 244 | /* |
| 245 | * Manage sleep mode |
| 246 | * Try 3 times to send data with delay between each |
| 247 | */ |
Christophe Ricard | a3c5d8f | 2014-04-24 23:19:34 +0200 | [diff] [blame] | 248 | mutex_lock(&phy->phy_lock); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 249 | for (i = 0; i < ARRAY_SIZE(wait_tab) && r < 0; i++) { |
| 250 | r = i2c_master_send(client, tmp, j); |
| 251 | if (r < 0) |
| 252 | msleep(wait_tab[i]); |
| 253 | } |
Christophe Ricard | a3c5d8f | 2014-04-24 23:19:34 +0200 | [diff] [blame] | 254 | mutex_unlock(&phy->phy_lock); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 255 | |
| 256 | if (r >= 0) { |
| 257 | if (r != j) |
| 258 | r = -EREMOTEIO; |
| 259 | else |
| 260 | r = 0; |
| 261 | } |
| 262 | |
Christophe Ricard | e1fb97b | 2014-04-24 23:19:31 +0200 | [diff] [blame] | 263 | st21nfca_hci_remove_len_crc(skb); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 264 | |
| 265 | return r; |
| 266 | } |
| 267 | |
| 268 | static int get_frame_size(u8 *buf, int buflen) |
| 269 | { |
| 270 | int len = 0; |
Christophe Ricard | 3e6df91 | 2014-07-28 18:11:31 +0200 | [diff] [blame] | 271 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 272 | if (buf[len + 1] == ST21NFCA_SOF_EOF) |
| 273 | return 0; |
| 274 | |
| 275 | for (len = 1; len < buflen && buf[len] != ST21NFCA_SOF_EOF; len++) |
| 276 | ; |
| 277 | |
| 278 | return len; |
| 279 | } |
| 280 | |
| 281 | static int check_crc(u8 *buf, int buflen) |
| 282 | { |
| 283 | u16 crc; |
| 284 | |
| 285 | crc = crc_ccitt(0xffff, buf, buflen - 2); |
| 286 | crc = ~crc; |
| 287 | |
| 288 | if (buf[buflen - 2] != (crc & 0xff) || buf[buflen - 1] != (crc >> 8)) { |
| 289 | pr_err(ST21NFCA_HCI_DRIVER_NAME |
| 290 | ": CRC error 0x%x != 0x%x 0x%x\n", crc, buf[buflen - 1], |
| 291 | buf[buflen - 2]); |
| 292 | |
| 293 | pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__); |
| 294 | print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE, |
| 295 | 16, 2, buf, buflen, false); |
| 296 | return -EPERM; |
| 297 | } |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | /* |
| 302 | * Prepare received data for upper layer. |
| 303 | * Received data include byte stuffing, crc and sof/eof |
| 304 | * which is not usable by hci part. |
| 305 | * returns: |
| 306 | * frame size without sof/eof, header and byte stuffing |
| 307 | * -EBADMSG : frame was incorrect and discarded |
| 308 | */ |
| 309 | static int st21nfca_hci_i2c_repack(struct sk_buff *skb) |
| 310 | { |
| 311 | int i, j, r, size; |
Christophe Ricard | 3e6df91 | 2014-07-28 18:11:31 +0200 | [diff] [blame] | 312 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 313 | if (skb->len < 1 || (skb->len > 1 && skb->data[1] != 0)) |
| 314 | return -EBADMSG; |
| 315 | |
| 316 | size = get_frame_size(skb->data, skb->len); |
| 317 | if (size > 0) { |
| 318 | skb_trim(skb, size); |
| 319 | /* remove ST21NFCA byte stuffing for upper layer */ |
| 320 | for (i = 1, j = 0; i < skb->len; i++) { |
Christophe Ricard | 3096e25 | 2014-04-24 23:19:32 +0200 | [diff] [blame] | 321 | if (skb->data[i + j] == |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 322 | (u8) ST21NFCA_ESCAPE_BYTE_STUFFING) { |
Christophe Ricard | 3096e25 | 2014-04-24 23:19:32 +0200 | [diff] [blame] | 323 | skb->data[i] = skb->data[i + j + 1] |
| 324 | | ST21NFCA_BYTE_STUFFING_MASK; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 325 | i++; |
| 326 | j++; |
| 327 | } |
| 328 | skb->data[i] = skb->data[i + j]; |
| 329 | } |
| 330 | /* remove byte stuffing useless byte */ |
| 331 | skb_trim(skb, i - j); |
| 332 | /* remove ST21NFCA_SOF_EOF from head */ |
| 333 | skb_pull(skb, 1); |
| 334 | |
| 335 | r = check_crc(skb->data, skb->len); |
| 336 | if (r != 0) { |
| 337 | i = 0; |
| 338 | return -EBADMSG; |
| 339 | } |
| 340 | |
| 341 | /* remove headbyte */ |
| 342 | skb_pull(skb, 1); |
| 343 | /* remove crc. Byte Stuffing is already removed here */ |
| 344 | skb_trim(skb, skb->len - 2); |
| 345 | return skb->len; |
| 346 | } |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | /* |
| 351 | * Reads an shdlc frame and returns it in a newly allocated sk_buff. Guarantees |
| 352 | * that i2c bus will be flushed and that next read will start on a new frame. |
| 353 | * returned skb contains only LLC header and payload. |
| 354 | * returns: |
| 355 | * frame size : if received frame is complete (find ST21NFCA_SOF_EOF at |
| 356 | * end of read) |
| 357 | * -EAGAIN : if received frame is incomplete (not find ST21NFCA_SOF_EOF |
| 358 | * at end of read) |
| 359 | * -EREMOTEIO : i2c read error (fatal) |
| 360 | * -EBADMSG : frame was incorrect and discarded |
| 361 | * (value returned from st21nfca_hci_i2c_repack) |
| 362 | * -EIO : if no ST21NFCA_SOF_EOF is found after reaching |
| 363 | * the read length end sequence |
| 364 | */ |
| 365 | static int st21nfca_hci_i2c_read(struct st21nfca_i2c_phy *phy, |
| 366 | struct sk_buff *skb) |
| 367 | { |
| 368 | int r, i; |
| 369 | u8 len; |
Christophe Ricard | c97ffdb | 2014-04-24 23:19:33 +0200 | [diff] [blame] | 370 | u8 buf[ST21NFCA_HCI_LLC_MAX_PAYLOAD]; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 371 | struct i2c_client *client = phy->i2c_dev; |
| 372 | |
| 373 | if (phy->current_read_len < ARRAY_SIZE(len_seq)) { |
| 374 | len = len_seq[phy->current_read_len]; |
| 375 | |
| 376 | /* |
| 377 | * Add retry mecanism |
| 378 | * Operation on I2C interface may fail in case of operation on |
| 379 | * RF or SWP interface |
| 380 | */ |
| 381 | r = 0; |
Christophe Ricard | a3c5d8f | 2014-04-24 23:19:34 +0200 | [diff] [blame] | 382 | mutex_lock(&phy->phy_lock); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 383 | for (i = 0; i < ARRAY_SIZE(wait_tab) && r <= 0; i++) { |
Christophe Ricard | c97ffdb | 2014-04-24 23:19:33 +0200 | [diff] [blame] | 384 | r = i2c_master_recv(client, buf, len); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 385 | if (r < 0) |
| 386 | msleep(wait_tab[i]); |
| 387 | } |
Christophe Ricard | a3c5d8f | 2014-04-24 23:19:34 +0200 | [diff] [blame] | 388 | mutex_unlock(&phy->phy_lock); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 389 | |
| 390 | if (r != len) { |
| 391 | phy->current_read_len = 0; |
| 392 | return -EREMOTEIO; |
| 393 | } |
| 394 | |
Christophe Ricard | c97ffdb | 2014-04-24 23:19:33 +0200 | [diff] [blame] | 395 | /* |
| 396 | * The first read sequence does not start with SOF. |
| 397 | * Data is corrupeted so we drop it. |
| 398 | */ |
Christophe Ricard | 8e9466c | 2014-05-20 22:21:55 +0200 | [diff] [blame] | 399 | if (!phy->current_read_len && !IS_START_OF_FRAME(buf)) { |
Christophe Ricard | c97ffdb | 2014-04-24 23:19:33 +0200 | [diff] [blame] | 400 | skb_trim(skb, 0); |
| 401 | phy->current_read_len = 0; |
| 402 | return -EIO; |
Christophe Ricard | 8e9466c | 2014-05-20 22:21:55 +0200 | [diff] [blame] | 403 | } else if (phy->current_read_len && IS_START_OF_FRAME(buf)) { |
Christophe Ricard | c97ffdb | 2014-04-24 23:19:33 +0200 | [diff] [blame] | 404 | /* |
| 405 | * Previous frame transmission was interrupted and |
| 406 | * the frame got repeated. |
| 407 | * Received frame start with ST21NFCA_SOF_EOF + 00. |
| 408 | */ |
| 409 | skb_trim(skb, 0); |
| 410 | phy->current_read_len = 0; |
| 411 | } |
| 412 | |
| 413 | memcpy(skb_put(skb, len), buf, len); |
| 414 | |
| 415 | if (skb->data[skb->len - 1] == ST21NFCA_SOF_EOF) { |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 416 | phy->current_read_len = 0; |
| 417 | return st21nfca_hci_i2c_repack(skb); |
| 418 | } |
| 419 | phy->current_read_len++; |
| 420 | return -EAGAIN; |
| 421 | } |
| 422 | return -EIO; |
| 423 | } |
| 424 | |
| 425 | /* |
| 426 | * Reads an shdlc frame from the chip. This is not as straightforward as it |
| 427 | * seems. The frame format is data-crc, and corruption can occur anywhere |
| 428 | * while transiting on i2c bus, such that we could read an invalid data. |
| 429 | * The tricky case is when we read a corrupted data or crc. We must detect |
| 430 | * this here in order to determine that data can be transmitted to the hci |
| 431 | * core. This is the reason why we check the crc here. |
| 432 | * The CLF will repeat a frame until we send a RR on that frame. |
| 433 | * |
| 434 | * On ST21NFCA, IRQ goes in idle when read starts. As no size information are |
| 435 | * available in the incoming data, other IRQ might come. Every IRQ will trigger |
| 436 | * a read sequence with different length and will fill the current frame. |
| 437 | * The reception is complete once we reach a ST21NFCA_SOF_EOF. |
| 438 | */ |
| 439 | static irqreturn_t st21nfca_hci_irq_thread_fn(int irq, void *phy_id) |
| 440 | { |
| 441 | struct st21nfca_i2c_phy *phy = phy_id; |
| 442 | struct i2c_client *client; |
| 443 | |
| 444 | int r; |
| 445 | |
| 446 | if (!phy || irq != phy->i2c_dev->irq) { |
| 447 | WARN_ON_ONCE(1); |
| 448 | return IRQ_NONE; |
| 449 | } |
| 450 | |
| 451 | client = phy->i2c_dev; |
| 452 | dev_dbg(&client->dev, "IRQ\n"); |
| 453 | |
| 454 | if (phy->hard_fault != 0) |
| 455 | return IRQ_HANDLED; |
| 456 | |
| 457 | r = st21nfca_hci_i2c_read(phy, phy->pending_skb); |
| 458 | if (r == -EREMOTEIO) { |
| 459 | phy->hard_fault = r; |
| 460 | |
| 461 | nfc_hci_recv_frame(phy->hdev, NULL); |
| 462 | |
| 463 | return IRQ_HANDLED; |
| 464 | } else if (r == -EAGAIN || r == -EIO) { |
| 465 | return IRQ_HANDLED; |
| 466 | } else if (r == -EBADMSG && phy->crc_trials < ARRAY_SIZE(wait_tab)) { |
| 467 | /* |
| 468 | * With ST21NFCA, only one interface (I2C, RF or SWP) |
| 469 | * may be active at a time. |
| 470 | * Having incorrect crc is usually due to i2c macrocell |
| 471 | * deactivation in the middle of a transmission. |
| 472 | * It may generate corrupted data on i2c. |
| 473 | * We give sometime to get i2c back. |
| 474 | * The complete frame will be repeated. |
| 475 | */ |
| 476 | msleep(wait_tab[phy->crc_trials]); |
| 477 | phy->crc_trials++; |
| 478 | phy->current_read_len = 0; |
Christophe Ricard | 0c942b0 | 2014-04-24 23:19:35 +0200 | [diff] [blame] | 479 | kfree_skb(phy->pending_skb); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 480 | } else if (r > 0) { |
| 481 | /* |
| 482 | * We succeeded to read data from the CLF and |
| 483 | * data is valid. |
| 484 | * Reset counter. |
| 485 | */ |
| 486 | nfc_hci_recv_frame(phy->hdev, phy->pending_skb); |
| 487 | phy->crc_trials = 0; |
Christophe Ricard | cf57734 | 2014-05-20 22:21:54 +0200 | [diff] [blame] | 488 | } else { |
| 489 | kfree_skb(phy->pending_skb); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL); |
| 493 | if (phy->pending_skb == NULL) { |
| 494 | phy->hard_fault = -ENOMEM; |
| 495 | nfc_hci_recv_frame(phy->hdev, NULL); |
| 496 | } |
| 497 | |
| 498 | return IRQ_HANDLED; |
| 499 | } |
| 500 | |
| 501 | static struct nfc_phy_ops i2c_phy_ops = { |
| 502 | .write = st21nfca_hci_i2c_write, |
| 503 | .enable = st21nfca_hci_i2c_enable, |
| 504 | .disable = st21nfca_hci_i2c_disable, |
| 505 | }; |
| 506 | |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 507 | static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client) |
| 508 | { |
| 509 | struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client); |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 510 | struct gpio_desc *gpiod_ena; |
Christophe Ricard | 070718a | 2016-04-30 09:12:44 +0200 | [diff] [blame] | 511 | struct device *dev = &client->dev; |
Christophe Ricard | bd9d523 | 2016-04-30 09:12:38 +0200 | [diff] [blame] | 512 | u8 tmp; |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 513 | |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 514 | /* Get EN GPIO from ACPI */ |
| 515 | gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 1, |
| 516 | GPIOD_OUT_LOW); |
Christophe Ricard | b58afe6 | 2016-04-30 09:12:34 +0200 | [diff] [blame] | 517 | if (!IS_ERR(gpiod_ena)) { |
| 518 | nfc_err(dev, "Unable to get ENABLE GPIO\n"); |
| 519 | return -ENODEV; |
| 520 | } |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 521 | |
| 522 | phy->gpio_ena = desc_to_gpio(gpiod_ena); |
| 523 | |
| 524 | phy->irq_polarity = irq_get_trigger_type(client->irq); |
| 525 | |
Christophe Ricard | bd9d523 | 2016-04-30 09:12:38 +0200 | [diff] [blame] | 526 | phy->se_status.is_ese_present = false; |
| 527 | phy->se_status.is_uicc_present = false; |
| 528 | |
| 529 | if (device_property_present(dev, "ese-present")) { |
| 530 | device_property_read_u8(dev, "ese-present", &tmp); |
| 531 | phy->se_status.is_ese_present = tmp; |
| 532 | } |
| 533 | |
| 534 | if (device_property_present(dev, "uicc-present")) { |
| 535 | device_property_read_u8(dev, "uicc-present", &tmp); |
| 536 | phy->se_status.is_uicc_present = tmp; |
| 537 | } |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 542 | static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client) |
| 543 | { |
| 544 | struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client); |
| 545 | struct device_node *pp; |
| 546 | int gpio; |
| 547 | int r; |
| 548 | |
| 549 | pp = client->dev.of_node; |
| 550 | if (!pp) |
| 551 | return -ENODEV; |
| 552 | |
| 553 | /* Get GPIO from device tree */ |
| 554 | gpio = of_get_named_gpio(pp, "enable-gpios", 0); |
| 555 | if (gpio < 0) { |
| 556 | nfc_err(&client->dev, "Failed to retrieve enable-gpios from device tree\n"); |
| 557 | return gpio; |
| 558 | } |
| 559 | |
| 560 | /* GPIO request and configuration */ |
Axel Lin | 0be8ce7 | 2014-07-28 18:11:29 +0200 | [diff] [blame] | 561 | r = devm_gpio_request_one(&client->dev, gpio, GPIOF_OUT_INIT_HIGH, |
Christophe Ricard | 04e99b7 | 2015-12-23 23:45:08 +0100 | [diff] [blame] | 562 | ST21NFCA_GPIO_NAME_EN); |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 563 | if (r) { |
| 564 | nfc_err(&client->dev, "Failed to request enable pin\n"); |
Christophe Ricard | 67df3f9 | 2014-12-02 21:27:55 +0100 | [diff] [blame] | 565 | return r; |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 566 | } |
| 567 | |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 568 | phy->gpio_ena = gpio; |
| 569 | |
Christophe Ricard | 40af86a | 2014-11-13 00:30:23 +0100 | [diff] [blame] | 570 | phy->irq_polarity = irq_get_trigger_type(client->irq); |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 571 | |
Christophe Ricard | 2130fb9 | 2015-01-27 01:18:19 +0100 | [diff] [blame] | 572 | phy->se_status.is_ese_present = |
| 573 | of_property_read_bool(pp, "ese-present"); |
| 574 | phy->se_status.is_uicc_present = |
| 575 | of_property_read_bool(pp, "uicc-present"); |
| 576 | |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 577 | return 0; |
| 578 | } |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 579 | |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 580 | static int st21nfca_hci_i2c_request_resources(struct i2c_client *client) |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 581 | { |
| 582 | struct st21nfca_nfc_platform_data *pdata; |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 583 | struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 584 | int r; |
| 585 | |
| 586 | pdata = client->dev.platform_data; |
| 587 | if (pdata == NULL) { |
| 588 | nfc_err(&client->dev, "No platform data\n"); |
| 589 | return -EINVAL; |
| 590 | } |
| 591 | |
| 592 | /* store for later use */ |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 593 | phy->gpio_ena = pdata->gpio_ena; |
| 594 | phy->irq_polarity = pdata->irq_polarity; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 595 | |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 596 | if (phy->gpio_ena > 0) { |
Axel Lin | 0be8ce7 | 2014-07-28 18:11:29 +0200 | [diff] [blame] | 597 | r = devm_gpio_request_one(&client->dev, phy->gpio_ena, |
Christophe Ricard | 04e99b7 | 2015-12-23 23:45:08 +0100 | [diff] [blame] | 598 | GPIOF_OUT_INIT_HIGH, |
| 599 | ST21NFCA_GPIO_NAME_EN); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 600 | if (r) { |
| 601 | pr_err("%s : ena gpio_request failed\n", __FILE__); |
Christophe Ricard | 67df3f9 | 2014-12-02 21:27:55 +0100 | [diff] [blame] | 602 | return r; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 603 | } |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 604 | } |
| 605 | |
Christophe Ricard | 2130fb9 | 2015-01-27 01:18:19 +0100 | [diff] [blame] | 606 | phy->se_status.is_ese_present = pdata->is_ese_present; |
| 607 | phy->se_status.is_uicc_present = pdata->is_uicc_present; |
| 608 | |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 609 | return 0; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | static int st21nfca_hci_i2c_probe(struct i2c_client *client, |
| 613 | const struct i2c_device_id *id) |
| 614 | { |
| 615 | struct st21nfca_i2c_phy *phy; |
| 616 | struct st21nfca_nfc_platform_data *pdata; |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 617 | int r; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 618 | |
| 619 | dev_dbg(&client->dev, "%s\n", __func__); |
| 620 | dev_dbg(&client->dev, "IRQ: %d\n", client->irq); |
| 621 | |
| 622 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
| 623 | nfc_err(&client->dev, "Need I2C_FUNC_I2C\n"); |
| 624 | return -ENODEV; |
| 625 | } |
| 626 | |
| 627 | phy = devm_kzalloc(&client->dev, sizeof(struct st21nfca_i2c_phy), |
| 628 | GFP_KERNEL); |
Christophe Ricard | 2b70283 | 2015-01-25 23:33:27 +0100 | [diff] [blame] | 629 | if (!phy) |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 630 | return -ENOMEM; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 631 | |
| 632 | phy->i2c_dev = client; |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 633 | phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL); |
| 634 | if (phy->pending_skb == NULL) |
| 635 | return -ENOMEM; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 636 | |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 637 | phy->current_read_len = 0; |
| 638 | phy->crc_trials = 0; |
Christophe Ricard | a3c5d8f | 2014-04-24 23:19:34 +0200 | [diff] [blame] | 639 | mutex_init(&phy->phy_lock); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 640 | i2c_set_clientdata(client, phy); |
| 641 | |
| 642 | pdata = client->dev.platform_data; |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 643 | if (!pdata && client->dev.of_node) { |
| 644 | r = st21nfca_hci_i2c_of_request_resources(client); |
| 645 | if (r) { |
| 646 | nfc_err(&client->dev, "No platform data\n"); |
| 647 | return r; |
| 648 | } |
| 649 | } else if (pdata) { |
| 650 | r = st21nfca_hci_i2c_request_resources(client); |
| 651 | if (r) { |
| 652 | nfc_err(&client->dev, "Cannot get platform resources\n"); |
| 653 | return r; |
| 654 | } |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 655 | } else if (ACPI_HANDLE(&client->dev)) { |
| 656 | r = st21nfca_hci_i2c_acpi_request_resources(client); |
| 657 | if (r) { |
| 658 | nfc_err(&client->dev, "Cannot get ACPI data\n"); |
| 659 | return r; |
| 660 | } |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 661 | } else { |
| 662 | nfc_err(&client->dev, "st21nfca platform resources not available\n"); |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 663 | return -ENODEV; |
| 664 | } |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 665 | |
Christophe Ricard | 18d2c62 | 2014-04-01 00:34:07 +0200 | [diff] [blame] | 666 | r = st21nfca_hci_platform_init(phy); |
| 667 | if (r < 0) { |
| 668 | nfc_err(&client->dev, "Unable to reboot st21nfca\n"); |
Christophe Ricard | 67df3f9 | 2014-12-02 21:27:55 +0100 | [diff] [blame] | 669 | return r; |
Christophe Ricard | 18d2c62 | 2014-04-01 00:34:07 +0200 | [diff] [blame] | 670 | } |
| 671 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 672 | r = devm_request_threaded_irq(&client->dev, client->irq, NULL, |
| 673 | st21nfca_hci_irq_thread_fn, |
| 674 | phy->irq_polarity | IRQF_ONESHOT, |
| 675 | ST21NFCA_HCI_DRIVER_NAME, phy); |
| 676 | if (r < 0) { |
| 677 | nfc_err(&client->dev, "Unable to register IRQ handler\n"); |
| 678 | return r; |
| 679 | } |
| 680 | |
Christophe Ricard | 9bac75d | 2014-04-01 00:34:05 +0200 | [diff] [blame] | 681 | return st21nfca_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME, |
Christophe Ricard | 2130fb9 | 2015-01-27 01:18:19 +0100 | [diff] [blame] | 682 | ST21NFCA_FRAME_HEADROOM, |
| 683 | ST21NFCA_FRAME_TAILROOM, |
| 684 | ST21NFCA_HCI_LLC_MAX_PAYLOAD, |
| 685 | &phy->hdev, |
| 686 | &phy->se_status); |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | static int st21nfca_hci_i2c_remove(struct i2c_client *client) |
| 690 | { |
| 691 | struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client); |
| 692 | |
| 693 | dev_dbg(&client->dev, "%s\n", __func__); |
| 694 | |
| 695 | st21nfca_hci_remove(phy->hdev); |
| 696 | |
| 697 | if (phy->powered) |
| 698 | st21nfca_hci_i2c_disable(phy); |
| 699 | |
| 700 | return 0; |
| 701 | } |
| 702 | |
Christophe Ricard | 39db2d2 | 2015-12-23 23:45:06 +0100 | [diff] [blame] | 703 | static struct i2c_device_id st21nfca_hci_i2c_id_table[] = { |
| 704 | {ST21NFCA_HCI_DRIVER_NAME, 0}, |
| 705 | {} |
| 706 | }; |
| 707 | MODULE_DEVICE_TABLE(i2c, st21nfca_hci_i2c_id_table); |
| 708 | |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 709 | static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = { |
| 710 | {"SMO2100", 0}, |
| 711 | {} |
| 712 | }; |
| 713 | MODULE_DEVICE_TABLE(acpi, st21nfca_hci_i2c_acpi_match); |
| 714 | |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 715 | static const struct of_device_id of_st21nfca_i2c_match[] = { |
Christophe Ricard | 6b5fba4 | 2014-12-08 22:08:06 +0100 | [diff] [blame] | 716 | { .compatible = "st,st21nfca-i2c", }, |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 717 | { .compatible = "st,st21nfca_i2c", }, |
| 718 | {} |
| 719 | }; |
Christophe Ricard | 17e40107 | 2014-11-13 00:30:22 +0100 | [diff] [blame] | 720 | MODULE_DEVICE_TABLE(of, of_st21nfca_i2c_match); |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 721 | |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 722 | static struct i2c_driver st21nfca_hci_i2c_driver = { |
| 723 | .driver = { |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 724 | .name = ST21NFCA_HCI_I2C_DRIVER_NAME, |
Christophe Ricard | c44cb2e | 2014-05-13 22:03:39 +0200 | [diff] [blame] | 725 | .of_match_table = of_match_ptr(of_st21nfca_i2c_match), |
Christophe Ricard | dfa8070 | 2015-12-23 23:45:11 +0100 | [diff] [blame] | 726 | .acpi_match_table = ACPI_PTR(st21nfca_hci_i2c_acpi_match), |
Christophe Ricard | fcb45e6 | 2014-04-01 00:34:06 +0200 | [diff] [blame] | 727 | }, |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 728 | .probe = st21nfca_hci_i2c_probe, |
| 729 | .id_table = st21nfca_hci_i2c_id_table, |
| 730 | .remove = st21nfca_hci_i2c_remove, |
| 731 | }; |
Christophe Ricard | 6895730 | 2014-03-25 06:51:47 +0100 | [diff] [blame] | 732 | module_i2c_driver(st21nfca_hci_i2c_driver); |
| 733 | |
| 734 | MODULE_LICENSE("GPL"); |
| 735 | MODULE_DESCRIPTION(DRIVER_DESC); |