core.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * --------------------------------------------------------------------
  4. * Driver for ST NFC Transceiver ST95HF
  5. * --------------------------------------------------------------------
  6. * Copyright (C) 2015 STMicroelectronics Pvt. Ltd. All rights reserved.
  7. */
  8. #include <linux/err.h>
  9. #include <linux/gpio/consumer.h>
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/irq.h>
  13. #include <linux/module.h>
  14. #include <linux/netdevice.h>
  15. #include <linux/nfc.h>
  16. #include <linux/of.h>
  17. #include <linux/property.h>
  18. #include <linux/regulator/consumer.h>
  19. #include <linux/wait.h>
  20. #include <net/nfc/digital.h>
  21. #include <net/nfc/nfc.h>
  22. #include "spi.h"
  23. /* supported protocols */
  24. #define ST95HF_SUPPORTED_PROT (NFC_PROTO_ISO14443_MASK | \
  25. NFC_PROTO_ISO14443_B_MASK | \
  26. NFC_PROTO_ISO15693_MASK)
  27. /* driver capabilities */
  28. #define ST95HF_CAPABILITIES NFC_DIGITAL_DRV_CAPS_IN_CRC
  29. /* Command Send Interface */
  30. /* ST95HF_COMMAND_SEND CMD Ids */
  31. #define ECHO_CMD 0x55
  32. #define WRITE_REGISTER_CMD 0x9
  33. #define PROTOCOL_SELECT_CMD 0x2
  34. #define SEND_RECEIVE_CMD 0x4
  35. /* Select protocol codes */
  36. #define ISO15693_PROTOCOL_CODE 0x1
  37. #define ISO14443A_PROTOCOL_CODE 0x2
  38. #define ISO14443B_PROTOCOL_CODE 0x3
  39. /*
  40. * head room len is 3
  41. * 1 byte for control byte
  42. * 1 byte for cmd
  43. * 1 byte for size
  44. */
  45. #define ST95HF_HEADROOM_LEN 3
  46. /*
  47. * tailroom is 1 for ISO14443A
  48. * and 0 for ISO14443B/ISO15693,
  49. * hence the max value 1 should be
  50. * taken.
  51. */
  52. #define ST95HF_TAILROOM_LEN 1
  53. /* Command Response interface */
  54. #define MAX_RESPONSE_BUFFER_SIZE 280
  55. #define ECHORESPONSE 0x55
  56. #define ST95HF_ERR_MASK 0xF
  57. #define ST95HF_TIMEOUT_ERROR 0x87
  58. #define ST95HF_NFCA_CRC_ERR_MASK 0x20
  59. #define ST95HF_NFCB_CRC_ERR_MASK 0x01
  60. /* ST95HF transmission flag values */
  61. #define TRFLAG_NFCA_SHORT_FRAME 0x07
  62. #define TRFLAG_NFCA_STD_FRAME 0x08
  63. #define TRFLAG_NFCA_STD_FRAME_CRC 0x28
  64. /* Misc defs */
  65. #define HIGH 1
  66. #define LOW 0
  67. #define ISO14443A_RATS_REQ 0xE0
  68. #define RATS_TB1_PRESENT_MASK 0x20
  69. #define RATS_TA1_PRESENT_MASK 0x10
  70. #define TB1_FWI_MASK 0xF0
  71. #define WTX_REQ_FROM_TAG 0xF2
  72. #define MAX_CMD_LEN 0x7
  73. #define MAX_CMD_PARAMS 4
  74. struct cmd {
  75. int cmd_len;
  76. unsigned char cmd_id;
  77. unsigned char no_cmd_params;
  78. unsigned char cmd_params[MAX_CMD_PARAMS];
  79. enum req_type req;
  80. };
  81. struct param_list {
  82. int param_offset;
  83. int new_param_val;
  84. };
  85. /*
  86. * List of top-level cmds to be used internally by the driver.
  87. * All these commands are build on top of ST95HF basic commands
  88. * such as SEND_RECEIVE_CMD, PROTOCOL_SELECT_CMD, etc.
  89. * These top level cmds are used internally while implementing various ops of
  90. * digital layer/driver probe or extending the digital framework layer for
  91. * features that are not yet implemented there, for example, WTX cmd handling.
  92. */
  93. enum st95hf_cmd_list {
  94. CMD_ECHO,
  95. CMD_ISO14443A_CONFIG,
  96. CMD_ISO14443A_DEMOGAIN,
  97. CMD_ISO14443B_DEMOGAIN,
  98. CMD_ISO14443A_PROTOCOL_SELECT,
  99. CMD_ISO14443B_PROTOCOL_SELECT,
  100. CMD_WTX_RESPONSE,
  101. CMD_FIELD_OFF,
  102. CMD_ISO15693_PROTOCOL_SELECT,
  103. };
  104. static const struct cmd cmd_array[] = {
  105. [CMD_ECHO] = {
  106. .cmd_len = 0x2,
  107. .cmd_id = ECHO_CMD,
  108. .no_cmd_params = 0,
  109. .req = SYNC,
  110. },
  111. [CMD_ISO14443A_CONFIG] = {
  112. .cmd_len = 0x7,
  113. .cmd_id = WRITE_REGISTER_CMD,
  114. .no_cmd_params = 0x4,
  115. .cmd_params = {0x3A, 0x00, 0x5A, 0x04},
  116. .req = SYNC,
  117. },
  118. [CMD_ISO14443A_DEMOGAIN] = {
  119. .cmd_len = 0x7,
  120. .cmd_id = WRITE_REGISTER_CMD,
  121. .no_cmd_params = 0x4,
  122. .cmd_params = {0x68, 0x01, 0x01, 0xDF},
  123. .req = SYNC,
  124. },
  125. [CMD_ISO14443B_DEMOGAIN] = {
  126. .cmd_len = 0x7,
  127. .cmd_id = WRITE_REGISTER_CMD,
  128. .no_cmd_params = 0x4,
  129. .cmd_params = {0x68, 0x01, 0x01, 0x51},
  130. .req = SYNC,
  131. },
  132. [CMD_ISO14443A_PROTOCOL_SELECT] = {
  133. .cmd_len = 0x7,
  134. .cmd_id = PROTOCOL_SELECT_CMD,
  135. .no_cmd_params = 0x4,
  136. .cmd_params = {ISO14443A_PROTOCOL_CODE, 0x00, 0x01, 0xA0},
  137. .req = SYNC,
  138. },
  139. [CMD_ISO14443B_PROTOCOL_SELECT] = {
  140. .cmd_len = 0x7,
  141. .cmd_id = PROTOCOL_SELECT_CMD,
  142. .no_cmd_params = 0x4,
  143. .cmd_params = {ISO14443B_PROTOCOL_CODE, 0x01, 0x03, 0xFF},
  144. .req = SYNC,
  145. },
  146. [CMD_WTX_RESPONSE] = {
  147. .cmd_len = 0x6,
  148. .cmd_id = SEND_RECEIVE_CMD,
  149. .no_cmd_params = 0x3,
  150. .cmd_params = {0xF2, 0x00, TRFLAG_NFCA_STD_FRAME_CRC},
  151. .req = ASYNC,
  152. },
  153. [CMD_FIELD_OFF] = {
  154. .cmd_len = 0x5,
  155. .cmd_id = PROTOCOL_SELECT_CMD,
  156. .no_cmd_params = 0x2,
  157. .cmd_params = {0x0, 0x0},
  158. .req = SYNC,
  159. },
  160. [CMD_ISO15693_PROTOCOL_SELECT] = {
  161. .cmd_len = 0x5,
  162. .cmd_id = PROTOCOL_SELECT_CMD,
  163. .no_cmd_params = 0x2,
  164. .cmd_params = {ISO15693_PROTOCOL_CODE, 0x0D},
  165. .req = SYNC,
  166. },
  167. };
  168. /* st95_digital_cmd_complete_arg stores client context */
  169. struct st95_digital_cmd_complete_arg {
  170. struct sk_buff *skb_resp;
  171. nfc_digital_cmd_complete_t complete_cb;
  172. void *cb_usrarg;
  173. bool rats;
  174. };
  175. /*
  176. * structure containing ST95HF driver specific data.
  177. * @spicontext: structure containing information required
  178. * for spi communication between st95hf and host.
  179. * @ddev: nfc digital device object.
  180. * @nfcdev: nfc device object.
  181. * @enable_gpiod: gpio used to enable st95hf transceiver.
  182. * @complete_cb_arg: structure to store various context information
  183. * that is passed from nfc requesting thread to the threaded ISR.
  184. * @st95hf_supply: regulator "consumer" for NFC device.
  185. * @sendrcv_trflag: last byte of frame send by sendrecv command
  186. * of st95hf. This byte contains transmission flag info.
  187. * @exchange_lock: semaphore used for signaling the st95hf_remove
  188. * function that the last outstanding async nfc request is finished.
  189. * @rm_lock: mutex for ensuring safe access of nfc digital object
  190. * from threaded ISR. Usage of this mutex avoids any race between
  191. * deletion of the object from st95hf_remove() and its access from
  192. * the threaded ISR.
  193. * @nfcdev_free: flag to have the state of nfc device object.
  194. * [alive | died]
  195. * @current_protocol: current nfc protocol.
  196. * @current_rf_tech: current rf technology.
  197. * @fwi: frame waiting index, received in reply of RATS according to
  198. * digital protocol.
  199. */
  200. struct st95hf_context {
  201. struct st95hf_spi_context spicontext;
  202. struct nfc_digital_dev *ddev;
  203. struct nfc_dev *nfcdev;
  204. struct gpio_desc *enable_gpiod;
  205. struct st95_digital_cmd_complete_arg complete_cb_arg;
  206. struct regulator *st95hf_supply;
  207. unsigned char sendrcv_trflag;
  208. struct semaphore exchange_lock;
  209. struct mutex rm_lock;
  210. bool nfcdev_free;
  211. u8 current_protocol;
  212. u8 current_rf_tech;
  213. int fwi;
  214. };
  215. /*
  216. * st95hf_send_recv_cmd() is for sending commands to ST95HF
  217. * that are described in the cmd_array[]. It can optionally
  218. * receive the response if the cmd request is of type
  219. * SYNC. For that to happen caller must pass true to recv_res.
  220. * For ASYNC request, recv_res is ignored and the
  221. * function will never try to receive the response on behalf
  222. * of the caller.
  223. */
  224. static int st95hf_send_recv_cmd(struct st95hf_context *st95context,
  225. enum st95hf_cmd_list cmd,
  226. int no_modif,
  227. struct param_list *list_array,
  228. bool recv_res)
  229. {
  230. unsigned char spi_cmd_buffer[MAX_CMD_LEN];
  231. int i, ret;
  232. struct device *dev = &st95context->spicontext.spidev->dev;
  233. if (cmd_array[cmd].cmd_len > MAX_CMD_LEN)
  234. return -EINVAL;
  235. if (cmd_array[cmd].no_cmd_params < no_modif)
  236. return -EINVAL;
  237. if (no_modif && !list_array)
  238. return -EINVAL;
  239. spi_cmd_buffer[0] = ST95HF_COMMAND_SEND;
  240. spi_cmd_buffer[1] = cmd_array[cmd].cmd_id;
  241. spi_cmd_buffer[2] = cmd_array[cmd].no_cmd_params;
  242. memcpy(&spi_cmd_buffer[3], cmd_array[cmd].cmd_params,
  243. spi_cmd_buffer[2]);
  244. for (i = 0; i < no_modif; i++) {
  245. if (list_array[i].param_offset >= cmd_array[cmd].no_cmd_params)
  246. return -EINVAL;
  247. spi_cmd_buffer[3 + list_array[i].param_offset] =
  248. list_array[i].new_param_val;
  249. }
  250. ret = st95hf_spi_send(&st95context->spicontext,
  251. spi_cmd_buffer,
  252. cmd_array[cmd].cmd_len,
  253. cmd_array[cmd].req);
  254. if (ret) {
  255. dev_err(dev, "st95hf_spi_send failed with error %d\n", ret);
  256. return ret;
  257. }
  258. if (cmd_array[cmd].req == SYNC && recv_res) {
  259. unsigned char st95hf_response_arr[2];
  260. ret = st95hf_spi_recv_response(&st95context->spicontext,
  261. st95hf_response_arr);
  262. if (ret < 0) {
  263. dev_err(dev, "spi error from st95hf_spi_recv_response(), err = 0x%x\n",
  264. ret);
  265. return ret;
  266. }
  267. if (st95hf_response_arr[0]) {
  268. dev_err(dev, "st95hf error from st95hf_spi_recv_response(), err = 0x%x\n",
  269. st95hf_response_arr[0]);
  270. return -EIO;
  271. }
  272. }
  273. return 0;
  274. }
  275. static int st95hf_echo_command(struct st95hf_context *st95context)
  276. {
  277. int result = 0;
  278. unsigned char echo_response;
  279. result = st95hf_send_recv_cmd(st95context, CMD_ECHO, 0, NULL, false);
  280. if (result)
  281. return result;
  282. /* If control reached here, response can be taken */
  283. result = st95hf_spi_recv_echo_res(&st95context->spicontext,
  284. &echo_response);
  285. if (result) {
  286. dev_err(&st95context->spicontext.spidev->dev,
  287. "err: echo response receive error = 0x%x\n", result);
  288. return result;
  289. }
  290. if (echo_response == ECHORESPONSE)
  291. return 0;
  292. dev_err(&st95context->spicontext.spidev->dev, "err: echo res is 0x%x\n",
  293. echo_response);
  294. return -EIO;
  295. }
  296. static int secondary_configuration_type4a(struct st95hf_context *stcontext)
  297. {
  298. int result = 0;
  299. struct device *dev = &stcontext->nfcdev->dev;
  300. /* 14443A config setting after select protocol */
  301. result = st95hf_send_recv_cmd(stcontext,
  302. CMD_ISO14443A_CONFIG,
  303. 0,
  304. NULL,
  305. true);
  306. if (result) {
  307. dev_err(dev, "type a config cmd, err = 0x%x\n", result);
  308. return result;
  309. }
  310. /* 14443A demo gain setting */
  311. result = st95hf_send_recv_cmd(stcontext,
  312. CMD_ISO14443A_DEMOGAIN,
  313. 0,
  314. NULL,
  315. true);
  316. if (result)
  317. dev_err(dev, "type a demogain cmd, err = 0x%x\n", result);
  318. return result;
  319. }
  320. static int secondary_configuration_type4b(struct st95hf_context *stcontext)
  321. {
  322. int result = 0;
  323. struct device *dev = &stcontext->nfcdev->dev;
  324. result = st95hf_send_recv_cmd(stcontext,
  325. CMD_ISO14443B_DEMOGAIN,
  326. 0,
  327. NULL,
  328. true);
  329. if (result)
  330. dev_err(dev, "type b demogain cmd, err = 0x%x\n", result);
  331. return result;
  332. }
  333. static int st95hf_select_protocol(struct st95hf_context *stcontext, int type)
  334. {
  335. int result = 0;
  336. struct device *dev;
  337. dev = &stcontext->nfcdev->dev;
  338. switch (type) {
  339. case NFC_DIGITAL_RF_TECH_106A:
  340. stcontext->current_rf_tech = NFC_DIGITAL_RF_TECH_106A;
  341. result = st95hf_send_recv_cmd(stcontext,
  342. CMD_ISO14443A_PROTOCOL_SELECT,
  343. 0,
  344. NULL,
  345. true);
  346. if (result) {
  347. dev_err(dev, "protocol sel, err = 0x%x\n",
  348. result);
  349. return result;
  350. }
  351. /* secondary config. for 14443Type 4A after protocol select */
  352. result = secondary_configuration_type4a(stcontext);
  353. if (result) {
  354. dev_err(dev, "type a secondary config, err = 0x%x\n",
  355. result);
  356. return result;
  357. }
  358. break;
  359. case NFC_DIGITAL_RF_TECH_106B:
  360. stcontext->current_rf_tech = NFC_DIGITAL_RF_TECH_106B;
  361. result = st95hf_send_recv_cmd(stcontext,
  362. CMD_ISO14443B_PROTOCOL_SELECT,
  363. 0,
  364. NULL,
  365. true);
  366. if (result) {
  367. dev_err(dev, "protocol sel send, err = 0x%x\n",
  368. result);
  369. return result;
  370. }
  371. /*
  372. * delay of 5-6 ms is required after select protocol
  373. * command in case of ISO14443 Type B
  374. */
  375. usleep_range(50000, 60000);
  376. /* secondary config. for 14443Type 4B after protocol select */
  377. result = secondary_configuration_type4b(stcontext);
  378. if (result) {
  379. dev_err(dev, "type b secondary config, err = 0x%x\n",
  380. result);
  381. return result;
  382. }
  383. break;
  384. case NFC_DIGITAL_RF_TECH_ISO15693:
  385. stcontext->current_rf_tech = NFC_DIGITAL_RF_TECH_ISO15693;
  386. result = st95hf_send_recv_cmd(stcontext,
  387. CMD_ISO15693_PROTOCOL_SELECT,
  388. 0,
  389. NULL,
  390. true);
  391. if (result) {
  392. dev_err(dev, "protocol sel send, err = 0x%x\n",
  393. result);
  394. return result;
  395. }
  396. break;
  397. default:
  398. return -EINVAL;
  399. }
  400. return 0;
  401. }
  402. static void st95hf_send_st95enable_negativepulse(struct st95hf_context *st95con)
  403. {
  404. /* First make irq_in pin high */
  405. gpiod_set_value(st95con->enable_gpiod, HIGH);
  406. /* wait for 1 milisecond */
  407. usleep_range(1000, 2000);
  408. /* Make irq_in pin low */
  409. gpiod_set_value(st95con->enable_gpiod, LOW);
  410. /* wait for minimum interrupt pulse to make st95 active */
  411. usleep_range(1000, 2000);
  412. /* At end make it high */
  413. gpiod_set_value(st95con->enable_gpiod, HIGH);
  414. }
  415. /*
  416. * Send a reset sequence over SPI bus (Reset command + wait 3ms +
  417. * negative pulse on st95hf enable gpio
  418. */
  419. static int st95hf_send_spi_reset_sequence(struct st95hf_context *st95context)
  420. {
  421. int result = 0;
  422. unsigned char reset_cmd = ST95HF_COMMAND_RESET;
  423. result = st95hf_spi_send(&st95context->spicontext,
  424. &reset_cmd,
  425. ST95HF_RESET_CMD_LEN,
  426. ASYNC);
  427. if (result) {
  428. dev_err(&st95context->spicontext.spidev->dev,
  429. "spi reset sequence cmd error = %d", result);
  430. return result;
  431. }
  432. /* wait for 3 milisecond to complete the controller reset process */
  433. usleep_range(3000, 4000);
  434. /* send negative pulse to make st95hf active */
  435. st95hf_send_st95enable_negativepulse(st95context);
  436. /* wait for 10 milisecond : HFO setup time */
  437. usleep_range(10000, 20000);
  438. return result;
  439. }
  440. static int st95hf_por_sequence(struct st95hf_context *st95context)
  441. {
  442. int nth_attempt = 1;
  443. int result;
  444. st95hf_send_st95enable_negativepulse(st95context);
  445. usleep_range(5000, 6000);
  446. do {
  447. /* send an ECHO command and checks ST95HF response */
  448. result = st95hf_echo_command(st95context);
  449. dev_dbg(&st95context->spicontext.spidev->dev,
  450. "response from echo function = 0x%x, attempt = %d\n",
  451. result, nth_attempt);
  452. if (!result)
  453. return 0;
  454. /* send an pulse on IRQ in case of the chip is on sleep state */
  455. if (nth_attempt == 2)
  456. st95hf_send_st95enable_negativepulse(st95context);
  457. else
  458. st95hf_send_spi_reset_sequence(st95context);
  459. /* delay of 50 milisecond */
  460. usleep_range(50000, 51000);
  461. } while (nth_attempt++ < 3);
  462. return -ETIMEDOUT;
  463. }
  464. static int iso14443_config_fdt(struct st95hf_context *st95context, int wtxm)
  465. {
  466. int result = 0;
  467. struct device *dev = &st95context->spicontext.spidev->dev;
  468. struct nfc_digital_dev *nfcddev = st95context->ddev;
  469. unsigned char pp_typeb;
  470. struct param_list new_params[2];
  471. pp_typeb = cmd_array[CMD_ISO14443B_PROTOCOL_SELECT].cmd_params[2];
  472. if (nfcddev->curr_protocol == NFC_PROTO_ISO14443 &&
  473. st95context->fwi < 4)
  474. st95context->fwi = 4;
  475. new_params[0].param_offset = 2;
  476. if (nfcddev->curr_protocol == NFC_PROTO_ISO14443)
  477. new_params[0].new_param_val = st95context->fwi;
  478. else if (nfcddev->curr_protocol == NFC_PROTO_ISO14443_B)
  479. new_params[0].new_param_val = pp_typeb;
  480. new_params[1].param_offset = 3;
  481. new_params[1].new_param_val = wtxm;
  482. switch (nfcddev->curr_protocol) {
  483. case NFC_PROTO_ISO14443:
  484. result = st95hf_send_recv_cmd(st95context,
  485. CMD_ISO14443A_PROTOCOL_SELECT,
  486. 2,
  487. new_params,
  488. true);
  489. if (result) {
  490. dev_err(dev, "WTX type a sel proto, err = 0x%x\n",
  491. result);
  492. return result;
  493. }
  494. /* secondary config. for 14443Type 4A after protocol select */
  495. result = secondary_configuration_type4a(st95context);
  496. if (result) {
  497. dev_err(dev, "WTX type a second. config, err = 0x%x\n",
  498. result);
  499. return result;
  500. }
  501. break;
  502. case NFC_PROTO_ISO14443_B:
  503. result = st95hf_send_recv_cmd(st95context,
  504. CMD_ISO14443B_PROTOCOL_SELECT,
  505. 2,
  506. new_params,
  507. true);
  508. if (result) {
  509. dev_err(dev, "WTX type b sel proto, err = 0x%x\n",
  510. result);
  511. return result;
  512. }
  513. /* secondary config. for 14443Type 4B after protocol select */
  514. result = secondary_configuration_type4b(st95context);
  515. if (result) {
  516. dev_err(dev, "WTX type b second. config, err = 0x%x\n",
  517. result);
  518. return result;
  519. }
  520. break;
  521. default:
  522. return -EINVAL;
  523. }
  524. return 0;
  525. }
  526. static int st95hf_handle_wtx(struct st95hf_context *stcontext,
  527. bool new_wtx,
  528. int wtx_val)
  529. {
  530. int result = 0;
  531. unsigned char val_mm = 0;
  532. struct param_list new_params[1];
  533. struct nfc_digital_dev *nfcddev = stcontext->ddev;
  534. struct device *dev = &stcontext->nfcdev->dev;
  535. if (new_wtx) {
  536. result = iso14443_config_fdt(stcontext, wtx_val & 0x3f);
  537. if (result) {
  538. dev_err(dev, "Config. setting error on WTX req, err = 0x%x\n",
  539. result);
  540. return result;
  541. }
  542. /* Send response of wtx with ASYNC as no response expected */
  543. new_params[0].param_offset = 1;
  544. new_params[0].new_param_val = wtx_val;
  545. result = st95hf_send_recv_cmd(stcontext,
  546. CMD_WTX_RESPONSE,
  547. 1,
  548. new_params,
  549. false);
  550. if (result)
  551. dev_err(dev, "WTX response send, err = 0x%x\n", result);
  552. return result;
  553. }
  554. /* if no new wtx, cofigure with default values */
  555. if (nfcddev->curr_protocol == NFC_PROTO_ISO14443)
  556. val_mm = cmd_array[CMD_ISO14443A_PROTOCOL_SELECT].cmd_params[3];
  557. else if (nfcddev->curr_protocol == NFC_PROTO_ISO14443_B)
  558. val_mm = cmd_array[CMD_ISO14443B_PROTOCOL_SELECT].cmd_params[3];
  559. result = iso14443_config_fdt(stcontext, val_mm);
  560. if (result)
  561. dev_err(dev, "Default config. setting error after WTX processing, err = 0x%x\n",
  562. result);
  563. return result;
  564. }
  565. static int st95hf_error_handling(struct st95hf_context *stcontext,
  566. struct sk_buff *skb_resp,
  567. int res_len)
  568. {
  569. int result = 0;
  570. unsigned char error_byte;
  571. struct device *dev = &stcontext->nfcdev->dev;
  572. /* First check ST95HF specific error */
  573. if (skb_resp->data[0] & ST95HF_ERR_MASK) {
  574. if (skb_resp->data[0] == ST95HF_TIMEOUT_ERROR)
  575. result = -ETIMEDOUT;
  576. else
  577. result = -EIO;
  578. return result;
  579. }
  580. /* Check for CRC err only if CRC is present in the tag response */
  581. switch (stcontext->current_rf_tech) {
  582. case NFC_DIGITAL_RF_TECH_106A:
  583. if (stcontext->sendrcv_trflag == TRFLAG_NFCA_STD_FRAME_CRC) {
  584. error_byte = skb_resp->data[res_len - 3];
  585. if (error_byte & ST95HF_NFCA_CRC_ERR_MASK) {
  586. /* CRC error occurred */
  587. dev_err(dev, "CRC error, byte received = 0x%x\n",
  588. error_byte);
  589. result = -EIO;
  590. }
  591. }
  592. break;
  593. case NFC_DIGITAL_RF_TECH_106B:
  594. case NFC_DIGITAL_RF_TECH_ISO15693:
  595. error_byte = skb_resp->data[res_len - 1];
  596. if (error_byte & ST95HF_NFCB_CRC_ERR_MASK) {
  597. /* CRC error occurred */
  598. dev_err(dev, "CRC error, byte received = 0x%x\n",
  599. error_byte);
  600. result = -EIO;
  601. }
  602. break;
  603. }
  604. return result;
  605. }
  606. static int st95hf_response_handler(struct st95hf_context *stcontext,
  607. struct sk_buff *skb_resp,
  608. int res_len)
  609. {
  610. int result = 0;
  611. int skb_len;
  612. unsigned char val_mm;
  613. struct nfc_digital_dev *nfcddev = stcontext->ddev;
  614. struct device *dev = &stcontext->nfcdev->dev;
  615. struct st95_digital_cmd_complete_arg *cb_arg;
  616. cb_arg = &stcontext->complete_cb_arg;
  617. /* Process the response */
  618. skb_put(skb_resp, res_len);
  619. /* Remove st95 header */
  620. skb_pull(skb_resp, 2);
  621. skb_len = skb_resp->len;
  622. /* check if it is case of RATS request reply & FWI is present */
  623. if (nfcddev->curr_protocol == NFC_PROTO_ISO14443 && cb_arg->rats &&
  624. (skb_resp->data[1] & RATS_TB1_PRESENT_MASK)) {
  625. if (skb_resp->data[1] & RATS_TA1_PRESENT_MASK)
  626. stcontext->fwi =
  627. (skb_resp->data[3] & TB1_FWI_MASK) >> 4;
  628. else
  629. stcontext->fwi =
  630. (skb_resp->data[2] & TB1_FWI_MASK) >> 4;
  631. val_mm = cmd_array[CMD_ISO14443A_PROTOCOL_SELECT].cmd_params[3];
  632. result = iso14443_config_fdt(stcontext, val_mm);
  633. if (result) {
  634. dev_err(dev, "error in config_fdt to handle fwi of ATS, error=%d\n",
  635. result);
  636. return result;
  637. }
  638. }
  639. cb_arg->rats = false;
  640. /* Remove CRC bytes only if received frames data has an eod (CRC) */
  641. switch (stcontext->current_rf_tech) {
  642. case NFC_DIGITAL_RF_TECH_106A:
  643. if (stcontext->sendrcv_trflag == TRFLAG_NFCA_STD_FRAME_CRC)
  644. skb_trim(skb_resp, (skb_len - 5));
  645. else
  646. skb_trim(skb_resp, (skb_len - 3));
  647. break;
  648. case NFC_DIGITAL_RF_TECH_106B:
  649. case NFC_DIGITAL_RF_TECH_ISO15693:
  650. skb_trim(skb_resp, (skb_len - 3));
  651. break;
  652. }
  653. return result;
  654. }
  655. static irqreturn_t st95hf_irq_handler(int irq, void *st95hfcontext)
  656. {
  657. struct st95hf_context *stcontext =
  658. (struct st95hf_context *)st95hfcontext;
  659. if (stcontext->spicontext.req_issync) {
  660. complete(&stcontext->spicontext.done);
  661. stcontext->spicontext.req_issync = false;
  662. return IRQ_HANDLED;
  663. }
  664. return IRQ_WAKE_THREAD;
  665. }
  666. static irqreturn_t st95hf_irq_thread_handler(int irq, void *st95hfcontext)
  667. {
  668. int result = 0;
  669. int res_len;
  670. static bool wtx;
  671. struct device *spidevice;
  672. struct sk_buff *skb_resp;
  673. struct st95hf_context *stcontext =
  674. (struct st95hf_context *)st95hfcontext;
  675. struct st95_digital_cmd_complete_arg *cb_arg;
  676. spidevice = &stcontext->spicontext.spidev->dev;
  677. /*
  678. * check semaphore, if not down() already, then we don't
  679. * know in which context the ISR is called and surely it
  680. * will be a bug. Note that down() of the semaphore is done
  681. * in the corresponding st95hf_in_send_cmd() and then
  682. * only this ISR should be called. ISR will up() the
  683. * semaphore before leaving. Hence when the ISR is called
  684. * the correct behaviour is down_trylock() should always
  685. * return 1 (indicating semaphore cant be taken and hence no
  686. * change in semaphore count).
  687. * If not, then we up() the semaphore and crash on
  688. * a BUG() !
  689. */
  690. if (!down_trylock(&stcontext->exchange_lock)) {
  691. up(&stcontext->exchange_lock);
  692. WARN(1, "unknown context in ST95HF ISR");
  693. return IRQ_NONE;
  694. }
  695. cb_arg = &stcontext->complete_cb_arg;
  696. skb_resp = cb_arg->skb_resp;
  697. mutex_lock(&stcontext->rm_lock);
  698. res_len = st95hf_spi_recv_response(&stcontext->spicontext,
  699. skb_resp->data);
  700. if (res_len < 0) {
  701. dev_err(spidevice, "TISR spi response err = 0x%x\n", res_len);
  702. result = res_len;
  703. goto end;
  704. }
  705. /* if stcontext->nfcdev_free is true, it means remove already ran */
  706. if (stcontext->nfcdev_free) {
  707. result = -ENODEV;
  708. goto end;
  709. }
  710. if (skb_resp->data[2] == WTX_REQ_FROM_TAG) {
  711. /* Request for new FWT from tag */
  712. result = st95hf_handle_wtx(stcontext, true, skb_resp->data[3]);
  713. if (result)
  714. goto end;
  715. wtx = true;
  716. mutex_unlock(&stcontext->rm_lock);
  717. return IRQ_HANDLED;
  718. }
  719. result = st95hf_error_handling(stcontext, skb_resp, res_len);
  720. if (result)
  721. goto end;
  722. result = st95hf_response_handler(stcontext, skb_resp, res_len);
  723. if (result)
  724. goto end;
  725. /*
  726. * If select protocol is done on wtx req. do select protocol
  727. * again with default values
  728. */
  729. if (wtx) {
  730. wtx = false;
  731. result = st95hf_handle_wtx(stcontext, false, 0);
  732. if (result)
  733. goto end;
  734. }
  735. /* call digital layer callback */
  736. cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp);
  737. /* up the semaphore before returning */
  738. up(&stcontext->exchange_lock);
  739. mutex_unlock(&stcontext->rm_lock);
  740. return IRQ_HANDLED;
  741. end:
  742. kfree_skb(skb_resp);
  743. wtx = false;
  744. cb_arg->rats = false;
  745. skb_resp = ERR_PTR(result);
  746. /* call of callback with error */
  747. cb_arg->complete_cb(stcontext->ddev, cb_arg->cb_usrarg, skb_resp);
  748. /* up the semaphore before returning */
  749. up(&stcontext->exchange_lock);
  750. mutex_unlock(&stcontext->rm_lock);
  751. return IRQ_HANDLED;
  752. }
  753. /* NFC ops functions definition */
  754. static int st95hf_in_configure_hw(struct nfc_digital_dev *ddev,
  755. int type,
  756. int param)
  757. {
  758. struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev);
  759. if (type == NFC_DIGITAL_CONFIG_RF_TECH)
  760. return st95hf_select_protocol(stcontext, param);
  761. if (type == NFC_DIGITAL_CONFIG_FRAMING) {
  762. switch (param) {
  763. case NFC_DIGITAL_FRAMING_NFCA_SHORT:
  764. stcontext->sendrcv_trflag = TRFLAG_NFCA_SHORT_FRAME;
  765. break;
  766. case NFC_DIGITAL_FRAMING_NFCA_STANDARD:
  767. stcontext->sendrcv_trflag = TRFLAG_NFCA_STD_FRAME;
  768. break;
  769. case NFC_DIGITAL_FRAMING_NFCA_T4T:
  770. case NFC_DIGITAL_FRAMING_NFCA_NFC_DEP:
  771. case NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A:
  772. stcontext->sendrcv_trflag = TRFLAG_NFCA_STD_FRAME_CRC;
  773. break;
  774. case NFC_DIGITAL_FRAMING_NFCB:
  775. case NFC_DIGITAL_FRAMING_ISO15693_INVENTORY:
  776. case NFC_DIGITAL_FRAMING_ISO15693_T5T:
  777. break;
  778. }
  779. }
  780. return 0;
  781. }
  782. static int rf_off(struct st95hf_context *stcontext)
  783. {
  784. int rc;
  785. struct device *dev;
  786. dev = &stcontext->nfcdev->dev;
  787. rc = st95hf_send_recv_cmd(stcontext, CMD_FIELD_OFF, 0, NULL, true);
  788. if (rc)
  789. dev_err(dev, "protocol sel send field off, err = 0x%x\n", rc);
  790. return rc;
  791. }
  792. static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev,
  793. struct sk_buff *skb,
  794. u16 timeout,
  795. nfc_digital_cmd_complete_t cb,
  796. void *arg)
  797. {
  798. struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev);
  799. int rc;
  800. struct sk_buff *skb_resp;
  801. int len_data_to_tag = 0;
  802. skb_resp = nfc_alloc_recv_skb(MAX_RESPONSE_BUFFER_SIZE, GFP_KERNEL);
  803. if (!skb_resp)
  804. return -ENOMEM;
  805. switch (stcontext->current_rf_tech) {
  806. case NFC_DIGITAL_RF_TECH_106A:
  807. len_data_to_tag = skb->len + 1;
  808. skb_put_u8(skb, stcontext->sendrcv_trflag);
  809. break;
  810. case NFC_DIGITAL_RF_TECH_106B:
  811. case NFC_DIGITAL_RF_TECH_ISO15693:
  812. len_data_to_tag = skb->len;
  813. break;
  814. default:
  815. rc = -EINVAL;
  816. goto free_skb_resp;
  817. }
  818. skb_push(skb, 3);
  819. skb->data[0] = ST95HF_COMMAND_SEND;
  820. skb->data[1] = SEND_RECEIVE_CMD;
  821. skb->data[2] = len_data_to_tag;
  822. stcontext->complete_cb_arg.skb_resp = skb_resp;
  823. stcontext->complete_cb_arg.cb_usrarg = arg;
  824. stcontext->complete_cb_arg.complete_cb = cb;
  825. if ((skb->data[3] == ISO14443A_RATS_REQ) &&
  826. ddev->curr_protocol == NFC_PROTO_ISO14443)
  827. stcontext->complete_cb_arg.rats = true;
  828. /*
  829. * down the semaphore to indicate to remove func that an
  830. * ISR is pending, note that it will not block here in any case.
  831. * If found blocked, it is a BUG!
  832. */
  833. rc = down_killable(&stcontext->exchange_lock);
  834. if (rc) {
  835. WARN(1, "Semaphore is not found up in st95hf_in_send_cmd\n");
  836. goto free_skb_resp;
  837. }
  838. rc = st95hf_spi_send(&stcontext->spicontext, skb->data,
  839. skb->len,
  840. ASYNC);
  841. if (rc) {
  842. dev_err(&stcontext->nfcdev->dev,
  843. "Error %d trying to perform data_exchange", rc);
  844. /* up the semaphore since ISR will never come in this case */
  845. up(&stcontext->exchange_lock);
  846. goto free_skb_resp;
  847. }
  848. kfree_skb(skb);
  849. return rc;
  850. free_skb_resp:
  851. kfree_skb(skb_resp);
  852. return rc;
  853. }
  854. /* p2p will be supported in a later release ! */
  855. static int st95hf_tg_configure_hw(struct nfc_digital_dev *ddev,
  856. int type,
  857. int param)
  858. {
  859. return 0;
  860. }
  861. static int st95hf_tg_send_cmd(struct nfc_digital_dev *ddev,
  862. struct sk_buff *skb,
  863. u16 timeout,
  864. nfc_digital_cmd_complete_t cb,
  865. void *arg)
  866. {
  867. return 0;
  868. }
  869. static int st95hf_tg_listen(struct nfc_digital_dev *ddev,
  870. u16 timeout,
  871. nfc_digital_cmd_complete_t cb,
  872. void *arg)
  873. {
  874. return 0;
  875. }
  876. static int st95hf_tg_get_rf_tech(struct nfc_digital_dev *ddev, u8 *rf_tech)
  877. {
  878. return 0;
  879. }
  880. static int st95hf_switch_rf(struct nfc_digital_dev *ddev, bool on)
  881. {
  882. u8 rf_tech;
  883. struct st95hf_context *stcontext = nfc_digital_get_drvdata(ddev);
  884. rf_tech = ddev->curr_rf_tech;
  885. if (on)
  886. /* switch on RF field */
  887. return st95hf_select_protocol(stcontext, rf_tech);
  888. /* switch OFF RF field */
  889. return rf_off(stcontext);
  890. }
  891. /* TODO st95hf_abort_cmd */
  892. static void st95hf_abort_cmd(struct nfc_digital_dev *ddev)
  893. {
  894. }
  895. static const struct nfc_digital_ops st95hf_nfc_digital_ops = {
  896. .in_configure_hw = st95hf_in_configure_hw,
  897. .in_send_cmd = st95hf_in_send_cmd,
  898. .tg_listen = st95hf_tg_listen,
  899. .tg_configure_hw = st95hf_tg_configure_hw,
  900. .tg_send_cmd = st95hf_tg_send_cmd,
  901. .tg_get_rf_tech = st95hf_tg_get_rf_tech,
  902. .switch_rf = st95hf_switch_rf,
  903. .abort_cmd = st95hf_abort_cmd,
  904. };
  905. static const struct spi_device_id st95hf_id[] = {
  906. { "st95hf", 0 },
  907. {}
  908. };
  909. MODULE_DEVICE_TABLE(spi, st95hf_id);
  910. static const struct of_device_id st95hf_spi_of_match[] __maybe_unused = {
  911. { .compatible = "st,st95hf" },
  912. {},
  913. };
  914. MODULE_DEVICE_TABLE(of, st95hf_spi_of_match);
  915. static int st95hf_probe(struct spi_device *nfc_spi_dev)
  916. {
  917. struct device *dev = &nfc_spi_dev->dev;
  918. int ret;
  919. struct st95hf_context *st95context;
  920. struct st95hf_spi_context *spicontext;
  921. nfc_info(&nfc_spi_dev->dev, "ST95HF driver probe called.\n");
  922. st95context = devm_kzalloc(&nfc_spi_dev->dev,
  923. sizeof(struct st95hf_context),
  924. GFP_KERNEL);
  925. if (!st95context)
  926. return -ENOMEM;
  927. spicontext = &st95context->spicontext;
  928. spicontext->spidev = nfc_spi_dev;
  929. st95context->fwi =
  930. cmd_array[CMD_ISO14443A_PROTOCOL_SELECT].cmd_params[2];
  931. if (device_property_present(&nfc_spi_dev->dev, "st95hfvin")) {
  932. st95context->st95hf_supply =
  933. devm_regulator_get(&nfc_spi_dev->dev,
  934. "st95hfvin");
  935. if (IS_ERR(st95context->st95hf_supply)) {
  936. dev_err(&nfc_spi_dev->dev, "failed to acquire regulator\n");
  937. return PTR_ERR(st95context->st95hf_supply);
  938. }
  939. ret = regulator_enable(st95context->st95hf_supply);
  940. if (ret) {
  941. dev_err(&nfc_spi_dev->dev, "failed to enable regulator\n");
  942. return ret;
  943. }
  944. }
  945. init_completion(&spicontext->done);
  946. mutex_init(&spicontext->spi_lock);
  947. /*
  948. * Store spicontext in spi device object for using it in
  949. * remove function
  950. */
  951. dev_set_drvdata(&nfc_spi_dev->dev, spicontext);
  952. st95context->enable_gpiod = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
  953. if (IS_ERR(st95context->enable_gpiod)) {
  954. ret = PTR_ERR(st95context->enable_gpiod);
  955. dev_err(&nfc_spi_dev->dev, "No valid enable gpio\n");
  956. goto err_disable_regulator;
  957. }
  958. ret = gpiod_set_consumer_name(st95context->enable_gpiod, "enable_gpio");
  959. if (ret)
  960. goto err_disable_regulator;
  961. if (nfc_spi_dev->irq > 0) {
  962. if (devm_request_threaded_irq(&nfc_spi_dev->dev,
  963. nfc_spi_dev->irq,
  964. st95hf_irq_handler,
  965. st95hf_irq_thread_handler,
  966. IRQF_TRIGGER_FALLING,
  967. "st95hf",
  968. (void *)st95context) < 0) {
  969. dev_err(&nfc_spi_dev->dev, "err: irq request for st95hf is failed\n");
  970. ret = -EINVAL;
  971. goto err_disable_regulator;
  972. }
  973. } else {
  974. dev_err(&nfc_spi_dev->dev, "not a valid IRQ associated with ST95HF\n");
  975. ret = -EINVAL;
  976. goto err_disable_regulator;
  977. }
  978. /*
  979. * First reset SPI to handle warm reset of the system.
  980. * It will put the ST95HF device in Power ON state
  981. * which make the state of device identical to state
  982. * at the time of cold reset of the system.
  983. */
  984. ret = st95hf_send_spi_reset_sequence(st95context);
  985. if (ret) {
  986. dev_err(&nfc_spi_dev->dev, "err: spi_reset_sequence failed\n");
  987. goto err_disable_regulator;
  988. }
  989. /* call PowerOnReset sequence of ST95hf to activate it */
  990. ret = st95hf_por_sequence(st95context);
  991. if (ret) {
  992. dev_err(&nfc_spi_dev->dev, "err: por seq failed for st95hf\n");
  993. goto err_disable_regulator;
  994. }
  995. /* create NFC dev object and register with NFC Subsystem */
  996. st95context->ddev = nfc_digital_allocate_device(&st95hf_nfc_digital_ops,
  997. ST95HF_SUPPORTED_PROT,
  998. ST95HF_CAPABILITIES,
  999. ST95HF_HEADROOM_LEN,
  1000. ST95HF_TAILROOM_LEN);
  1001. if (!st95context->ddev) {
  1002. ret = -ENOMEM;
  1003. goto err_disable_regulator;
  1004. }
  1005. st95context->nfcdev = st95context->ddev->nfc_dev;
  1006. nfc_digital_set_parent_dev(st95context->ddev, &nfc_spi_dev->dev);
  1007. ret = nfc_digital_register_device(st95context->ddev);
  1008. if (ret) {
  1009. dev_err(&st95context->nfcdev->dev, "st95hf registration failed\n");
  1010. goto err_free_digital_device;
  1011. }
  1012. /* store st95context in nfc device object */
  1013. nfc_digital_set_drvdata(st95context->ddev, st95context);
  1014. sema_init(&st95context->exchange_lock, 1);
  1015. mutex_init(&st95context->rm_lock);
  1016. return ret;
  1017. err_free_digital_device:
  1018. nfc_digital_free_device(st95context->ddev);
  1019. err_disable_regulator:
  1020. if (st95context->st95hf_supply)
  1021. regulator_disable(st95context->st95hf_supply);
  1022. return ret;
  1023. }
  1024. static void st95hf_remove(struct spi_device *nfc_spi_dev)
  1025. {
  1026. int result = 0;
  1027. unsigned char reset_cmd = ST95HF_COMMAND_RESET;
  1028. struct st95hf_spi_context *spictx = dev_get_drvdata(&nfc_spi_dev->dev);
  1029. struct st95hf_context *stcontext = container_of(spictx,
  1030. struct st95hf_context,
  1031. spicontext);
  1032. mutex_lock(&stcontext->rm_lock);
  1033. nfc_digital_unregister_device(stcontext->ddev);
  1034. nfc_digital_free_device(stcontext->ddev);
  1035. stcontext->nfcdev_free = true;
  1036. mutex_unlock(&stcontext->rm_lock);
  1037. /* if last in_send_cmd's ISR is pending, wait for it to finish */
  1038. result = down_killable(&stcontext->exchange_lock);
  1039. if (result == -EINTR)
  1040. dev_err(&spictx->spidev->dev, "sleep for semaphore interrupted by signal\n");
  1041. /* next reset the ST95HF controller */
  1042. result = st95hf_spi_send(&stcontext->spicontext,
  1043. &reset_cmd,
  1044. ST95HF_RESET_CMD_LEN,
  1045. ASYNC);
  1046. if (result)
  1047. dev_err(&spictx->spidev->dev,
  1048. "ST95HF reset failed in remove() err = %d\n", result);
  1049. /* wait for 3 ms to complete the controller reset process */
  1050. usleep_range(3000, 4000);
  1051. /* disable regulator */
  1052. if (stcontext->st95hf_supply)
  1053. regulator_disable(stcontext->st95hf_supply);
  1054. }
  1055. /* Register as SPI protocol driver */
  1056. static struct spi_driver st95hf_driver = {
  1057. .driver = {
  1058. .name = "st95hf",
  1059. .of_match_table = of_match_ptr(st95hf_spi_of_match),
  1060. },
  1061. .id_table = st95hf_id,
  1062. .probe = st95hf_probe,
  1063. .remove = st95hf_remove,
  1064. };
  1065. module_spi_driver(st95hf_driver);
  1066. MODULE_AUTHOR("Shikha Singh <shikha.singh@st.com>");
  1067. MODULE_DESCRIPTION("ST NFC Transceiver ST95HF driver");
  1068. MODULE_LICENSE("GPL v2");