i2c.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  18. #include <linux/crc-ccitt.h>
  19. #include <linux/module.h>
  20. #include <linux/i2c.h>
  21. #include <linux/gpio/consumer.h>
  22. #include <linux/of_irq.h>
  23. #include <linux/of_gpio.h>
  24. #include <linux/acpi.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/delay.h>
  27. #include <linux/nfc.h>
  28. #include <linux/firmware.h>
  29. #include <asm/unaligned.h>
  30. #include <net/nfc/hci.h>
  31. #include <net/nfc/llc.h>
  32. #include <net/nfc/nfc.h>
  33. #include "st21nfca.h"
  34. /*
  35. * Every frame starts with ST21NFCA_SOF_EOF and ends with ST21NFCA_SOF_EOF.
  36. * Because ST21NFCA_SOF_EOF is a possible data value, there is a mecanism
  37. * called byte stuffing has been introduced.
  38. *
  39. * if byte == ST21NFCA_SOF_EOF or ST21NFCA_ESCAPE_BYTE_STUFFING
  40. * - insert ST21NFCA_ESCAPE_BYTE_STUFFING (escape byte)
  41. * - xor byte with ST21NFCA_BYTE_STUFFING_MASK
  42. */
  43. #define ST21NFCA_SOF_EOF 0x7e
  44. #define ST21NFCA_BYTE_STUFFING_MASK 0x20
  45. #define ST21NFCA_ESCAPE_BYTE_STUFFING 0x7d
  46. /* SOF + 00 */
  47. #define ST21NFCA_FRAME_HEADROOM 2
  48. /* 2 bytes crc + EOF */
  49. #define ST21NFCA_FRAME_TAILROOM 3
  50. #define IS_START_OF_FRAME(buf) (buf[0] == ST21NFCA_SOF_EOF && \
  51. buf[1] == 0)
  52. #define ST21NFCA_HCI_DRIVER_NAME "st21nfca_hci"
  53. #define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c"
  54. struct st21nfca_i2c_phy {
  55. struct i2c_client *i2c_dev;
  56. struct nfc_hci_dev *hdev;
  57. struct gpio_desc *gpiod_ena;
  58. struct st21nfca_se_status se_status;
  59. struct sk_buff *pending_skb;
  60. int current_read_len;
  61. /*
  62. * crc might have fail because i2c macro
  63. * is disable due to other interface activity
  64. */
  65. int crc_trials;
  66. int powered;
  67. int run_mode;
  68. /*
  69. * < 0 if hardware error occured (e.g. i2c err)
  70. * and prevents normal operation.
  71. */
  72. int hard_fault;
  73. struct mutex phy_lock;
  74. };
  75. static u8 len_seq[] = { 16, 24, 12, 29 };
  76. static u16 wait_tab[] = { 2, 3, 5, 15, 20, 40};
  77. #define I2C_DUMP_SKB(info, skb) \
  78. do { \
  79. pr_debug("%s:\n", info); \
  80. print_hex_dump(KERN_DEBUG, "i2c: ", DUMP_PREFIX_OFFSET, \
  81. 16, 1, (skb)->data, (skb)->len, 0); \
  82. } while (0)
  83. /*
  84. * In order to get the CLF in a known state we generate an internal reboot
  85. * using a proprietary command.
  86. * Once the reboot is completed, we expect to receive a ST21NFCA_SOF_EOF
  87. * fill buffer.
  88. */
  89. static int st21nfca_hci_platform_init(struct st21nfca_i2c_phy *phy)
  90. {
  91. u16 wait_reboot[] = { 50, 300, 1000 };
  92. char reboot_cmd[] = { 0x7E, 0x66, 0x48, 0xF6, 0x7E };
  93. u8 tmp[ST21NFCA_HCI_LLC_MAX_SIZE];
  94. int i, r = -1;
  95. for (i = 0; i < ARRAY_SIZE(wait_reboot) && r < 0; i++) {
  96. r = i2c_master_send(phy->i2c_dev, reboot_cmd,
  97. sizeof(reboot_cmd));
  98. if (r < 0)
  99. msleep(wait_reboot[i]);
  100. }
  101. if (r < 0)
  102. return r;
  103. /* CLF is spending about 20ms to do an internal reboot */
  104. msleep(20);
  105. r = -1;
  106. for (i = 0; i < ARRAY_SIZE(wait_reboot) && r < 0; i++) {
  107. r = i2c_master_recv(phy->i2c_dev, tmp,
  108. ST21NFCA_HCI_LLC_MAX_SIZE);
  109. if (r < 0)
  110. msleep(wait_reboot[i]);
  111. }
  112. if (r < 0)
  113. return r;
  114. for (i = 0; i < ST21NFCA_HCI_LLC_MAX_SIZE &&
  115. tmp[i] == ST21NFCA_SOF_EOF; i++)
  116. ;
  117. if (r != ST21NFCA_HCI_LLC_MAX_SIZE)
  118. return -ENODEV;
  119. usleep_range(1000, 1500);
  120. return 0;
  121. }
  122. static int st21nfca_hci_i2c_enable(void *phy_id)
  123. {
  124. struct st21nfca_i2c_phy *phy = phy_id;
  125. gpiod_set_value(phy->gpiod_ena, 1);
  126. phy->powered = 1;
  127. phy->run_mode = ST21NFCA_HCI_MODE;
  128. usleep_range(10000, 15000);
  129. return 0;
  130. }
  131. static void st21nfca_hci_i2c_disable(void *phy_id)
  132. {
  133. struct st21nfca_i2c_phy *phy = phy_id;
  134. gpiod_set_value(phy->gpiod_ena, 0);
  135. phy->powered = 0;
  136. }
  137. static void st21nfca_hci_add_len_crc(struct sk_buff *skb)
  138. {
  139. u16 crc;
  140. u8 tmp;
  141. *(u8 *)skb_push(skb, 1) = 0;
  142. crc = crc_ccitt(0xffff, skb->data, skb->len);
  143. crc = ~crc;
  144. tmp = crc & 0x00ff;
  145. skb_put_u8(skb, tmp);
  146. tmp = (crc >> 8) & 0x00ff;
  147. skb_put_u8(skb, tmp);
  148. }
  149. static void st21nfca_hci_remove_len_crc(struct sk_buff *skb)
  150. {
  151. skb_pull(skb, ST21NFCA_FRAME_HEADROOM);
  152. skb_trim(skb, skb->len - ST21NFCA_FRAME_TAILROOM);
  153. }
  154. /*
  155. * Writing a frame must not return the number of written bytes.
  156. * It must return either zero for success, or <0 for error.
  157. * In addition, it must not alter the skb
  158. */
  159. static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb)
  160. {
  161. int r = -1, i, j;
  162. struct st21nfca_i2c_phy *phy = phy_id;
  163. struct i2c_client *client = phy->i2c_dev;
  164. u8 tmp[ST21NFCA_HCI_LLC_MAX_SIZE * 2];
  165. I2C_DUMP_SKB("st21nfca_hci_i2c_write", skb);
  166. if (phy->hard_fault != 0)
  167. return phy->hard_fault;
  168. /*
  169. * Compute CRC before byte stuffing computation on frame
  170. * Note st21nfca_hci_add_len_crc is doing a byte stuffing
  171. * on its own value
  172. */
  173. st21nfca_hci_add_len_crc(skb);
  174. /* add ST21NFCA_SOF_EOF on tail */
  175. skb_put_u8(skb, ST21NFCA_SOF_EOF);
  176. /* add ST21NFCA_SOF_EOF on head */
  177. *(u8 *)skb_push(skb, 1) = ST21NFCA_SOF_EOF;
  178. /*
  179. * Compute byte stuffing
  180. * if byte == ST21NFCA_SOF_EOF or ST21NFCA_ESCAPE_BYTE_STUFFING
  181. * insert ST21NFCA_ESCAPE_BYTE_STUFFING (escape byte)
  182. * xor byte with ST21NFCA_BYTE_STUFFING_MASK
  183. */
  184. tmp[0] = skb->data[0];
  185. for (i = 1, j = 1; i < skb->len - 1; i++, j++) {
  186. if (skb->data[i] == ST21NFCA_SOF_EOF
  187. || skb->data[i] == ST21NFCA_ESCAPE_BYTE_STUFFING) {
  188. tmp[j] = ST21NFCA_ESCAPE_BYTE_STUFFING;
  189. j++;
  190. tmp[j] = skb->data[i] ^ ST21NFCA_BYTE_STUFFING_MASK;
  191. } else {
  192. tmp[j] = skb->data[i];
  193. }
  194. }
  195. tmp[j] = skb->data[i];
  196. j++;
  197. /*
  198. * Manage sleep mode
  199. * Try 3 times to send data with delay between each
  200. */
  201. mutex_lock(&phy->phy_lock);
  202. for (i = 0; i < ARRAY_SIZE(wait_tab) && r < 0; i++) {
  203. r = i2c_master_send(client, tmp, j);
  204. if (r < 0)
  205. msleep(wait_tab[i]);
  206. }
  207. mutex_unlock(&phy->phy_lock);
  208. if (r >= 0) {
  209. if (r != j)
  210. r = -EREMOTEIO;
  211. else
  212. r = 0;
  213. }
  214. st21nfca_hci_remove_len_crc(skb);
  215. return r;
  216. }
  217. static int get_frame_size(u8 *buf, int buflen)
  218. {
  219. int len = 0;
  220. if (buf[len + 1] == ST21NFCA_SOF_EOF)
  221. return 0;
  222. for (len = 1; len < buflen && buf[len] != ST21NFCA_SOF_EOF; len++)
  223. ;
  224. return len;
  225. }
  226. static int check_crc(u8 *buf, int buflen)
  227. {
  228. u16 crc;
  229. crc = crc_ccitt(0xffff, buf, buflen - 2);
  230. crc = ~crc;
  231. if (buf[buflen - 2] != (crc & 0xff) || buf[buflen - 1] != (crc >> 8)) {
  232. pr_err(ST21NFCA_HCI_DRIVER_NAME
  233. ": CRC error 0x%x != 0x%x 0x%x\n", crc, buf[buflen - 1],
  234. buf[buflen - 2]);
  235. pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__);
  236. print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE,
  237. 16, 2, buf, buflen, false);
  238. return -EPERM;
  239. }
  240. return 0;
  241. }
  242. /*
  243. * Prepare received data for upper layer.
  244. * Received data include byte stuffing, crc and sof/eof
  245. * which is not usable by hci part.
  246. * returns:
  247. * frame size without sof/eof, header and byte stuffing
  248. * -EBADMSG : frame was incorrect and discarded
  249. */
  250. static int st21nfca_hci_i2c_repack(struct sk_buff *skb)
  251. {
  252. int i, j, r, size;
  253. if (skb->len < 1 || (skb->len > 1 && skb->data[1] != 0))
  254. return -EBADMSG;
  255. size = get_frame_size(skb->data, skb->len);
  256. if (size > 0) {
  257. skb_trim(skb, size);
  258. /* remove ST21NFCA byte stuffing for upper layer */
  259. for (i = 1, j = 0; i < skb->len; i++) {
  260. if (skb->data[i + j] ==
  261. (u8) ST21NFCA_ESCAPE_BYTE_STUFFING) {
  262. skb->data[i] = skb->data[i + j + 1]
  263. | ST21NFCA_BYTE_STUFFING_MASK;
  264. i++;
  265. j++;
  266. }
  267. skb->data[i] = skb->data[i + j];
  268. }
  269. /* remove byte stuffing useless byte */
  270. skb_trim(skb, i - j);
  271. /* remove ST21NFCA_SOF_EOF from head */
  272. skb_pull(skb, 1);
  273. r = check_crc(skb->data, skb->len);
  274. if (r != 0) {
  275. i = 0;
  276. return -EBADMSG;
  277. }
  278. /* remove headbyte */
  279. skb_pull(skb, 1);
  280. /* remove crc. Byte Stuffing is already removed here */
  281. skb_trim(skb, skb->len - 2);
  282. return skb->len;
  283. }
  284. return 0;
  285. }
  286. /*
  287. * Reads an shdlc frame and returns it in a newly allocated sk_buff. Guarantees
  288. * that i2c bus will be flushed and that next read will start on a new frame.
  289. * returned skb contains only LLC header and payload.
  290. * returns:
  291. * frame size : if received frame is complete (find ST21NFCA_SOF_EOF at
  292. * end of read)
  293. * -EAGAIN : if received frame is incomplete (not find ST21NFCA_SOF_EOF
  294. * at end of read)
  295. * -EREMOTEIO : i2c read error (fatal)
  296. * -EBADMSG : frame was incorrect and discarded
  297. * (value returned from st21nfca_hci_i2c_repack)
  298. * -EIO : if no ST21NFCA_SOF_EOF is found after reaching
  299. * the read length end sequence
  300. */
  301. static int st21nfca_hci_i2c_read(struct st21nfca_i2c_phy *phy,
  302. struct sk_buff *skb)
  303. {
  304. int r, i;
  305. u8 len;
  306. u8 buf[ST21NFCA_HCI_LLC_MAX_PAYLOAD];
  307. struct i2c_client *client = phy->i2c_dev;
  308. if (phy->current_read_len < ARRAY_SIZE(len_seq)) {
  309. len = len_seq[phy->current_read_len];
  310. /*
  311. * Add retry mecanism
  312. * Operation on I2C interface may fail in case of operation on
  313. * RF or SWP interface
  314. */
  315. r = 0;
  316. mutex_lock(&phy->phy_lock);
  317. for (i = 0; i < ARRAY_SIZE(wait_tab) && r <= 0; i++) {
  318. r = i2c_master_recv(client, buf, len);
  319. if (r < 0)
  320. msleep(wait_tab[i]);
  321. }
  322. mutex_unlock(&phy->phy_lock);
  323. if (r != len) {
  324. phy->current_read_len = 0;
  325. return -EREMOTEIO;
  326. }
  327. /*
  328. * The first read sequence does not start with SOF.
  329. * Data is corrupeted so we drop it.
  330. */
  331. if (!phy->current_read_len && !IS_START_OF_FRAME(buf)) {
  332. skb_trim(skb, 0);
  333. phy->current_read_len = 0;
  334. return -EIO;
  335. } else if (phy->current_read_len && IS_START_OF_FRAME(buf)) {
  336. /*
  337. * Previous frame transmission was interrupted and
  338. * the frame got repeated.
  339. * Received frame start with ST21NFCA_SOF_EOF + 00.
  340. */
  341. skb_trim(skb, 0);
  342. phy->current_read_len = 0;
  343. }
  344. skb_put_data(skb, buf, len);
  345. if (skb->data[skb->len - 1] == ST21NFCA_SOF_EOF) {
  346. phy->current_read_len = 0;
  347. return st21nfca_hci_i2c_repack(skb);
  348. }
  349. phy->current_read_len++;
  350. return -EAGAIN;
  351. }
  352. return -EIO;
  353. }
  354. /*
  355. * Reads an shdlc frame from the chip. This is not as straightforward as it
  356. * seems. The frame format is data-crc, and corruption can occur anywhere
  357. * while transiting on i2c bus, such that we could read an invalid data.
  358. * The tricky case is when we read a corrupted data or crc. We must detect
  359. * this here in order to determine that data can be transmitted to the hci
  360. * core. This is the reason why we check the crc here.
  361. * The CLF will repeat a frame until we send a RR on that frame.
  362. *
  363. * On ST21NFCA, IRQ goes in idle when read starts. As no size information are
  364. * available in the incoming data, other IRQ might come. Every IRQ will trigger
  365. * a read sequence with different length and will fill the current frame.
  366. * The reception is complete once we reach a ST21NFCA_SOF_EOF.
  367. */
  368. static irqreturn_t st21nfca_hci_irq_thread_fn(int irq, void *phy_id)
  369. {
  370. struct st21nfca_i2c_phy *phy = phy_id;
  371. struct i2c_client *client;
  372. int r;
  373. if (!phy || irq != phy->i2c_dev->irq) {
  374. WARN_ON_ONCE(1);
  375. return IRQ_NONE;
  376. }
  377. client = phy->i2c_dev;
  378. dev_dbg(&client->dev, "IRQ\n");
  379. if (phy->hard_fault != 0)
  380. return IRQ_HANDLED;
  381. r = st21nfca_hci_i2c_read(phy, phy->pending_skb);
  382. if (r == -EREMOTEIO) {
  383. phy->hard_fault = r;
  384. nfc_hci_recv_frame(phy->hdev, NULL);
  385. return IRQ_HANDLED;
  386. } else if (r == -EAGAIN || r == -EIO) {
  387. return IRQ_HANDLED;
  388. } else if (r == -EBADMSG && phy->crc_trials < ARRAY_SIZE(wait_tab)) {
  389. /*
  390. * With ST21NFCA, only one interface (I2C, RF or SWP)
  391. * may be active at a time.
  392. * Having incorrect crc is usually due to i2c macrocell
  393. * deactivation in the middle of a transmission.
  394. * It may generate corrupted data on i2c.
  395. * We give sometime to get i2c back.
  396. * The complete frame will be repeated.
  397. */
  398. msleep(wait_tab[phy->crc_trials]);
  399. phy->crc_trials++;
  400. phy->current_read_len = 0;
  401. kfree_skb(phy->pending_skb);
  402. } else if (r > 0) {
  403. /*
  404. * We succeeded to read data from the CLF and
  405. * data is valid.
  406. * Reset counter.
  407. */
  408. nfc_hci_recv_frame(phy->hdev, phy->pending_skb);
  409. phy->crc_trials = 0;
  410. } else {
  411. kfree_skb(phy->pending_skb);
  412. }
  413. phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL);
  414. if (phy->pending_skb == NULL) {
  415. phy->hard_fault = -ENOMEM;
  416. nfc_hci_recv_frame(phy->hdev, NULL);
  417. }
  418. return IRQ_HANDLED;
  419. }
  420. static struct nfc_phy_ops i2c_phy_ops = {
  421. .write = st21nfca_hci_i2c_write,
  422. .enable = st21nfca_hci_i2c_enable,
  423. .disable = st21nfca_hci_i2c_disable,
  424. };
  425. static const struct acpi_gpio_params enable_gpios = { 1, 0, false };
  426. static const struct acpi_gpio_mapping acpi_st21nfca_gpios[] = {
  427. { "enable-gpios", &enable_gpios, 1 },
  428. {},
  429. };
  430. static int st21nfca_hci_i2c_probe(struct i2c_client *client,
  431. const struct i2c_device_id *id)
  432. {
  433. struct device *dev = &client->dev;
  434. struct st21nfca_i2c_phy *phy;
  435. int r;
  436. dev_dbg(&client->dev, "%s\n", __func__);
  437. dev_dbg(&client->dev, "IRQ: %d\n", client->irq);
  438. if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
  439. nfc_err(&client->dev, "Need I2C_FUNC_I2C\n");
  440. return -ENODEV;
  441. }
  442. phy = devm_kzalloc(&client->dev, sizeof(struct st21nfca_i2c_phy),
  443. GFP_KERNEL);
  444. if (!phy)
  445. return -ENOMEM;
  446. phy->i2c_dev = client;
  447. phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL);
  448. if (phy->pending_skb == NULL)
  449. return -ENOMEM;
  450. phy->current_read_len = 0;
  451. phy->crc_trials = 0;
  452. mutex_init(&phy->phy_lock);
  453. i2c_set_clientdata(client, phy);
  454. r = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
  455. if (r)
  456. dev_dbg(dev, "Unable to add GPIO mapping table\n");
  457. /* Get EN GPIO from resource provider */
  458. phy->gpiod_ena = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
  459. if (IS_ERR(phy->gpiod_ena)) {
  460. nfc_err(dev, "Unable to get ENABLE GPIO\n");
  461. return PTR_ERR(phy->gpiod_ena);
  462. }
  463. phy->se_status.is_ese_present =
  464. device_property_read_bool(&client->dev, "ese-present");
  465. phy->se_status.is_uicc_present =
  466. device_property_read_bool(&client->dev, "uicc-present");
  467. r = st21nfca_hci_platform_init(phy);
  468. if (r < 0) {
  469. nfc_err(&client->dev, "Unable to reboot st21nfca\n");
  470. return r;
  471. }
  472. r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
  473. st21nfca_hci_irq_thread_fn,
  474. IRQF_ONESHOT,
  475. ST21NFCA_HCI_DRIVER_NAME, phy);
  476. if (r < 0) {
  477. nfc_err(&client->dev, "Unable to register IRQ handler\n");
  478. return r;
  479. }
  480. return st21nfca_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
  481. ST21NFCA_FRAME_HEADROOM,
  482. ST21NFCA_FRAME_TAILROOM,
  483. ST21NFCA_HCI_LLC_MAX_PAYLOAD,
  484. &phy->hdev,
  485. &phy->se_status);
  486. }
  487. static int st21nfca_hci_i2c_remove(struct i2c_client *client)
  488. {
  489. struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
  490. dev_dbg(&client->dev, "%s\n", __func__);
  491. st21nfca_hci_remove(phy->hdev);
  492. if (phy->powered)
  493. st21nfca_hci_i2c_disable(phy);
  494. return 0;
  495. }
  496. static const struct i2c_device_id st21nfca_hci_i2c_id_table[] = {
  497. {ST21NFCA_HCI_DRIVER_NAME, 0},
  498. {}
  499. };
  500. MODULE_DEVICE_TABLE(i2c, st21nfca_hci_i2c_id_table);
  501. static const struct acpi_device_id st21nfca_hci_i2c_acpi_match[] = {
  502. {"SMO2100", 0},
  503. {}
  504. };
  505. MODULE_DEVICE_TABLE(acpi, st21nfca_hci_i2c_acpi_match);
  506. static const struct of_device_id of_st21nfca_i2c_match[] = {
  507. { .compatible = "st,st21nfca-i2c", },
  508. { .compatible = "st,st21nfca_i2c", },
  509. {}
  510. };
  511. MODULE_DEVICE_TABLE(of, of_st21nfca_i2c_match);
  512. static struct i2c_driver st21nfca_hci_i2c_driver = {
  513. .driver = {
  514. .name = ST21NFCA_HCI_I2C_DRIVER_NAME,
  515. .of_match_table = of_match_ptr(of_st21nfca_i2c_match),
  516. .acpi_match_table = ACPI_PTR(st21nfca_hci_i2c_acpi_match),
  517. },
  518. .probe = st21nfca_hci_i2c_probe,
  519. .id_table = st21nfca_hci_i2c_id_table,
  520. .remove = st21nfca_hci_i2c_remove,
  521. };
  522. module_i2c_driver(st21nfca_hci_i2c_driver);
  523. MODULE_LICENSE("GPL");
  524. MODULE_DESCRIPTION(DRIVER_DESC);