1 /* ////////////////////////////////////////////////////////////////////////// */
3 /* Copyright (c) Atmel Corporation. All rights reserved. */
5 /* Module Name: wilc_spi.c */
8 /* //////////////////////////////////////////////////////////////////////////// */
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/types.h>
15 #include <linux/cdev.h>
16 #include <linux/uaccess.h>
17 #include <linux/device.h>
18 #include <linux/spi/spi.h>
19 #include <linux/of_gpio.h>
21 #include <linux/string.h>
22 #include "wilc_wlan_if.h"
23 #include "wilc_wlan.h"
24 #include "wilc_wfi_netdevice.h"
32 static struct wilc_spi g_spi;
34 static int wilc_spi_read(struct wilc *wilc, u32, u8 *, u32);
35 static int wilc_spi_write(struct wilc *wilc, u32, u8 *, u32);
37 /********************************************
41 ********************************************/
43 static const u8 crc7_syndrome_table[256] = {
44 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
45 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
46 0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
47 0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
48 0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
49 0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
50 0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
51 0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
52 0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
53 0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
54 0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
55 0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
56 0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
57 0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
58 0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
59 0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
60 0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
61 0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
62 0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
63 0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
64 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
65 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
66 0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
67 0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
68 0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
69 0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
70 0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
71 0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
72 0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
73 0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
74 0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
75 0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
78 static u8 crc7_byte(u8 crc, u8 data)
80 return crc7_syndrome_table[(crc << 1) ^ data];
83 static u8 crc7(u8 crc, const u8 *buffer, u32 len)
86 crc = crc7_byte(crc, *buffer++);
90 /********************************************
92 * Spi protocol Function
94 ********************************************/
96 #define CMD_DMA_WRITE 0xc1
97 #define CMD_DMA_READ 0xc2
98 #define CMD_INTERNAL_WRITE 0xc3
99 #define CMD_INTERNAL_READ 0xc4
100 #define CMD_TERMINATE 0xc5
101 #define CMD_REPEAT 0xc6
102 #define CMD_DMA_EXT_WRITE 0xc7
103 #define CMD_DMA_EXT_READ 0xc8
104 #define CMD_SINGLE_WRITE 0xc9
105 #define CMD_SINGLE_READ 0xca
106 #define CMD_RESET 0xcf
113 #define DATA_PKT_SZ_256 256
114 #define DATA_PKT_SZ_512 512
115 #define DATA_PKT_SZ_1K 1024
116 #define DATA_PKT_SZ_4K (4 * 1024)
117 #define DATA_PKT_SZ_8K (8 * 1024)
118 #define DATA_PKT_SZ DATA_PKT_SZ_8K
120 #define USE_SPI_DMA 0
122 static int wilc_bus_probe(struct spi_device *spi)
127 gpio = of_get_gpio(spi->dev.of_node, 0);
131 ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, GPIO_NUM, &wilc_hif_spi);
135 spi_set_drvdata(spi, wilc);
136 wilc->dev = &spi->dev;
141 static int wilc_bus_remove(struct spi_device *spi)
143 wilc_netdev_cleanup(spi_get_drvdata(spi));
147 static const struct of_device_id wilc1000_of_match[] = {
148 { .compatible = "atmel,wilc_spi", },
151 MODULE_DEVICE_TABLE(of, wilc1000_of_match);
153 static struct spi_driver wilc1000_spi_driver = {
156 .of_match_table = wilc1000_of_match,
158 .probe = wilc_bus_probe,
159 .remove = wilc_bus_remove,
161 module_spi_driver(wilc1000_spi_driver);
162 MODULE_LICENSE("GPL");
164 static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len)
166 struct spi_device *spi = to_spi_device(wilc->dev);
168 struct spi_message msg;
171 struct spi_transfer tr = {
176 char *r_buffer = kzalloc(len, GFP_KERNEL);
181 tr.rx_buf = r_buffer;
182 dev_dbg(&spi->dev, "Request writing %d bytes\n", len);
184 memset(&msg, 0, sizeof(msg));
185 spi_message_init(&msg);
187 msg.is_dma_mapped = USE_SPI_DMA;
188 spi_message_add_tail(&tr, &msg);
190 ret = spi_sync(spi, &msg);
192 dev_err(&spi->dev, "SPI transaction failed\n");
197 "can't write data with the following length: %d\n",
200 "FAILED due to NULL buffer or ZERO length check the following length: %d\n",
208 static int wilc_spi_rx(struct wilc *wilc, u8 *rb, u32 rlen)
210 struct spi_device *spi = to_spi_device(wilc->dev);
214 struct spi_message msg;
215 struct spi_transfer tr = {
221 char *t_buffer = kzalloc(rlen, GFP_KERNEL);
226 tr.tx_buf = t_buffer;
228 memset(&msg, 0, sizeof(msg));
229 spi_message_init(&msg);
231 msg.is_dma_mapped = USE_SPI_DMA;
232 spi_message_add_tail(&tr, &msg);
234 ret = spi_sync(spi, &msg);
236 dev_err(&spi->dev, "SPI transaction failed\n");
240 "can't read data with the following length: %u\n",
248 static int wilc_spi_tx_rx(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen)
250 struct spi_device *spi = to_spi_device(wilc->dev);
254 struct spi_message msg;
255 struct spi_transfer tr = {
264 memset(&msg, 0, sizeof(msg));
265 spi_message_init(&msg);
267 msg.is_dma_mapped = USE_SPI_DMA;
269 spi_message_add_tail(&tr, &msg);
270 ret = spi_sync(spi, &msg);
272 dev_err(&spi->dev, "SPI transaction failed\n");
275 "can't read data with the following length: %u\n",
283 static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
286 struct spi_device *spi = to_spi_device(wilc->dev);
296 case CMD_SINGLE_READ: /* single word (4 bytes) read */
297 wb[1] = (u8)(adr >> 16);
298 wb[2] = (u8)(adr >> 8);
303 case CMD_INTERNAL_READ: /* internal register read */
304 wb[1] = (u8)(adr >> 8);
312 case CMD_TERMINATE: /* termination */
319 case CMD_REPEAT: /* repeat */
326 case CMD_RESET: /* reset */
333 case CMD_DMA_WRITE: /* dma write */
334 case CMD_DMA_READ: /* dma read */
335 wb[1] = (u8)(adr >> 16);
336 wb[2] = (u8)(adr >> 8);
338 wb[4] = (u8)(sz >> 8);
343 case CMD_DMA_EXT_WRITE: /* dma extended write */
344 case CMD_DMA_EXT_READ: /* dma extended read */
345 wb[1] = (u8)(adr >> 16);
346 wb[2] = (u8)(adr >> 8);
348 wb[4] = (u8)(sz >> 16);
349 wb[5] = (u8)(sz >> 8);
354 case CMD_INTERNAL_WRITE: /* internal register write */
355 wb[1] = (u8)(adr >> 8);
366 case CMD_SINGLE_WRITE: /* single word write */
367 wb[1] = (u8)(adr >> 16);
368 wb[2] = (u8)(adr >> 8);
386 wb[len - 1] = (crc7(0x7f, (const u8 *)&wb[0], len - 1)) << 1;
390 #define NUM_SKIP_BYTES (1)
391 #define NUM_RSP_BYTES (2)
392 #define NUM_DATA_HDR_BYTES (1)
393 #define NUM_DATA_BYTES (4)
394 #define NUM_CRC_BYTES (2)
395 #define NUM_DUMMY_BYTES (3)
396 if ((cmd == CMD_RESET) ||
397 (cmd == CMD_TERMINATE) ||
398 (cmd == CMD_REPEAT)) {
399 len2 = len + (NUM_SKIP_BYTES + NUM_RSP_BYTES + NUM_DUMMY_BYTES);
400 } else if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)) {
401 if (!g_spi.crc_off) {
402 len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES
403 + NUM_CRC_BYTES + NUM_DUMMY_BYTES);
405 len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES
409 len2 = len + (NUM_RSP_BYTES + NUM_DUMMY_BYTES);
411 #undef NUM_DUMMY_BYTES
413 if (len2 > ARRAY_SIZE(wb)) {
414 dev_err(&spi->dev, "spi buffer size too small (%d) (%zu)\n",
415 len2, ARRAY_SIZE(wb));
419 /* zero spi write buffers. */
420 for (wix = len; wix < len2; wix++)
424 if (wilc_spi_tx_rx(wilc, wb, rb, len2)) {
425 dev_err(&spi->dev, "Failed cmd write, bus error...\n");
431 * Command/Control response
433 if ((cmd == CMD_RESET) ||
434 (cmd == CMD_TERMINATE) ||
435 (cmd == CMD_REPEAT)) {
436 rix++; /* skip 1 byte */
441 /* if(rsp == cmd) break; */
442 /* } while(&rptr[1] <= &rb[len2]); */
446 "Failed cmd response, cmd (%02x), resp (%02x)\n",
457 dev_err(&spi->dev, "Failed cmd state response state (%02x)\n",
463 if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)
464 || (cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) {
466 /* u16 crc1, crc2; */
469 * Data Respnose header
473 /* ensure there is room in buffer later to read data and crc */
480 if (((rsp >> 4) & 0xf) == 0xf)
486 "Error, data read response (%02x)\n", rsp);
491 if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)) {
495 if ((rix + 3) < len2) {
502 "buffer overrun when reading data.\n");
507 if (!g_spi.crc_off) {
511 if ((rix + 1) < len2) {
515 dev_err(&spi->dev, "buffer overrun when reading crc.\n");
520 } else if ((cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) {
523 /* some data may be read in response to dummy bytes. */
524 for (ix = 0; (rix < len2) && (ix < sz); )
532 if (sz <= (DATA_PKT_SZ - ix))
535 nbytes = DATA_PKT_SZ - ix;
540 if (wilc_spi_rx(wilc, &b[ix], nbytes)) {
541 dev_err(&spi->dev, "Failed data block read, bus error...\n");
549 if (!g_spi.crc_off) {
550 if (wilc_spi_rx(wilc, crc, 2)) {
551 dev_err(&spi->dev, "Failed data block crc read, bus error...\n");
562 /* if any data in left unread, then read the rest using normal DMA code.*/
566 if (sz <= DATA_PKT_SZ)
569 nbytes = DATA_PKT_SZ;
572 * read data response only on the next DMA cycles not
573 * the first DMA since data response header is already
574 * handled above for the first DMA.
577 * Data Respnose header
581 if (wilc_spi_rx(wilc, &rsp, 1)) {
582 dev_err(&spi->dev, "Failed data response read, bus error...\n");
586 if (((rsp >> 4) & 0xf) == 0xf)
590 if (result == N_FAIL)
597 if (wilc_spi_rx(wilc, &b[ix], nbytes)) {
598 dev_err(&spi->dev, "Failed data block read, bus error...\n");
606 if (!g_spi.crc_off) {
607 if (wilc_spi_rx(wilc, crc, 2)) {
608 dev_err(&spi->dev, "Failed data block crc read, bus error...\n");
623 static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
625 struct spi_device *spi = to_spi_device(wilc->dev);
628 u8 cmd, order, crc[2] = {0};
636 if (sz <= DATA_PKT_SZ)
639 nbytes = DATA_PKT_SZ;
646 if (sz <= DATA_PKT_SZ)
652 if (sz <= DATA_PKT_SZ)
658 if (wilc_spi_tx(wilc, &cmd, 1)) {
660 "Failed data block cmd write, bus error...\n");
668 if (wilc_spi_tx(wilc, &b[ix], nbytes)) {
670 "Failed data block write, bus error...\n");
678 if (!g_spi.crc_off) {
679 if (wilc_spi_tx(wilc, crc, 2)) {
680 dev_err(&spi->dev, "Failed data block crc write, bus error...\n");
687 * No need to wait for response
697 /********************************************
699 * Spi Internal Read/Write Function
701 ********************************************/
703 static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat)
705 struct spi_device *spi = to_spi_device(wilc->dev);
708 dat = cpu_to_le32(dat);
709 result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4,
712 dev_err(&spi->dev, "Failed internal write cmd...\n");
717 static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data)
719 struct spi_device *spi = to_spi_device(wilc->dev);
722 result = spi_cmd_complete(wilc, CMD_INTERNAL_READ, adr, (u8 *)data, 4,
724 if (result != N_OK) {
725 dev_err(&spi->dev, "Failed internal read cmd...\n");
729 *data = cpu_to_le32(*data);
734 /********************************************
738 ********************************************/
740 static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data)
742 struct spi_device *spi = to_spi_device(wilc->dev);
744 u8 cmd = CMD_SINGLE_WRITE;
747 data = cpu_to_le32(data);
749 /* Clockless register*/
750 cmd = CMD_INTERNAL_WRITE;
754 result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&data, 4, clockless);
756 dev_err(&spi->dev, "Failed cmd, write reg (%08x)...\n", addr);
761 static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
763 struct spi_device *spi = to_spi_device(wilc->dev);
765 u8 cmd = CMD_DMA_EXT_WRITE;
768 * has to be greated than 4
773 result = spi_cmd_complete(wilc, cmd, addr, NULL, size, 0);
774 if (result != N_OK) {
776 "Failed cmd, write block (%08x)...\n", addr);
783 result = spi_data_write(wilc, buf, size);
785 dev_err(&spi->dev, "Failed block data write...\n");
790 static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data)
792 struct spi_device *spi = to_spi_device(wilc->dev);
794 u8 cmd = CMD_SINGLE_READ;
798 /* dev_err(&spi->dev, "***** read addr %d\n\n", addr); */
799 /* Clockless register*/
800 cmd = CMD_INTERNAL_READ;
804 result = spi_cmd_complete(wilc, cmd, addr, (u8 *)data, 4, clockless);
805 if (result != N_OK) {
806 dev_err(&spi->dev, "Failed cmd, read reg (%08x)...\n", addr);
810 *data = cpu_to_le32(*data);
815 static int wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
817 struct spi_device *spi = to_spi_device(wilc->dev);
818 u8 cmd = CMD_DMA_EXT_READ;
824 result = spi_cmd_complete(wilc, cmd, addr, buf, size, 0);
825 if (result != N_OK) {
826 dev_err(&spi->dev, "Failed cmd, read block (%08x)...\n", addr);
833 /********************************************
837 ********************************************/
839 static int _wilc_spi_deinit(struct wilc *wilc)
847 static int wilc_spi_init(struct wilc *wilc, bool resume)
849 struct spi_device *spi = to_spi_device(wilc->dev);
857 if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) {
858 dev_err(&spi->dev, "Fail cmd read chip id...\n");
864 memset(&g_spi, 0, sizeof(struct wilc_spi));
871 /* TODO: We can remove the CRC trials if there is a definite way to reset */
872 /* the SPI to it's initial value. */
873 if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, ®)) {
874 /* Read failed. Try with CRC off. This might happen when module
875 * is removed but chip isn't reset*/
877 dev_err(&spi->dev, "Failed internal read protocol with CRC on, retyring with CRC off...\n");
878 if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, ®)) {
879 /* Reaad failed with both CRC on and off, something went bad */
881 "Failed internal read protocol...\n");
885 if (g_spi.crc_off == 0) {
886 reg &= ~0xc; /* disable crc checking */
889 if (!spi_internal_write(wilc, WILC_SPI_PROTOCOL_OFFSET, reg)) {
890 dev_err(&spi->dev, "[wilc spi %d]: Failed internal write protocol reg...\n", __LINE__);
898 * make sure can read back chip id correctly
900 if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) {
901 dev_err(&spi->dev, "Fail cmd read chip id...\n");
904 /* dev_err(&spi->dev, "chipid (%08x)\n", chipid); */
906 g_spi.has_thrpt_enh = 1;
913 static int wilc_spi_read_size(struct wilc *wilc, u32 *size)
915 struct spi_device *spi = to_spi_device(wilc->dev);
918 if (g_spi.has_thrpt_enh) {
919 ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
921 *size = *size & IRQ_DMA_WD_CNT_MASK;
926 ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE,
930 "Failed read WILC_VMM_TO_HOST_SIZE ...\n");
933 tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
945 static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
947 struct spi_device *spi = to_spi_device(wilc->dev);
950 if (g_spi.has_thrpt_enh) {
951 ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
957 ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE,
961 "Failed read WILC_VMM_TO_HOST_SIZE ...\n");
964 tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
975 wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
976 tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
978 if (g_spi.nint > 5) {
979 wilc_spi_read_reg(wilc, 0x1a94,
981 tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5));
987 unkmown_mask = ~((1ul << g_spi.nint) - 1);
989 if ((tmp >> IRG_FLAGS_OFFSET) & unkmown_mask) {
990 dev_err(&spi->dev, "Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unkmown_mask);
1006 static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
1008 struct spi_device *spi = to_spi_device(wilc->dev);
1011 if (g_spi.has_thrpt_enh) {
1012 ret = spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
1017 flags = val & (BIT(MAX_NUM_INT) - 1);
1022 for (i = 0; i < g_spi.nint; i++) {
1023 /* No matter what you write 1 or 0, it will clear interrupt. */
1025 ret = wilc_spi_write_reg(wilc, 0x10c8 + i * 4, 1);
1032 "Failed wilc_spi_write_reg, set reg %x ...\n",
1036 for (i = g_spi.nint; i < MAX_NUM_INT; i++) {
1039 "Unexpected interrupt cleared %d...\n",
1049 /* select VMM table 0 */
1050 if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
1052 /* select VMM table 1 */
1053 if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
1056 ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL,
1060 "fail write reg vmm_tbl_ctl...\n");
1064 if ((val & EN_VMM) == EN_VMM) {
1066 * enable vmm transfer.
1068 ret = wilc_spi_write_reg(wilc,
1069 WILC_VMM_CORE_CTL, 1);
1071 dev_err(&spi->dev, "fail write reg vmm_core_ctl...\n");
1081 static int wilc_spi_sync_ext(struct wilc *wilc, int nint)
1083 struct spi_device *spi = to_spi_device(wilc->dev);
1087 if (nint > MAX_NUM_INT) {
1088 dev_err(&spi->dev, "Too many interupts (%d)...\n", nint);
1095 * interrupt pin mux select
1097 ret = wilc_spi_read_reg(wilc, WILC_PIN_MUX_0, ®);
1099 dev_err(&spi->dev, "Failed read reg (%08x)...\n",
1104 ret = wilc_spi_write_reg(wilc, WILC_PIN_MUX_0, reg);
1106 dev_err(&spi->dev, "Failed write reg (%08x)...\n",
1114 ret = wilc_spi_read_reg(wilc, WILC_INTR_ENABLE, ®);
1116 dev_err(&spi->dev, "Failed read reg (%08x)...\n",
1121 for (i = 0; (i < 5) && (nint > 0); i++, nint--)
1122 reg |= (BIT((27 + i)));
1124 ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg);
1126 dev_err(&spi->dev, "Failed write reg (%08x)...\n",
1131 ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®);
1133 dev_err(&spi->dev, "Failed read reg (%08x)...\n",
1138 for (i = 0; (i < 3) && (nint > 0); i++, nint--)
1141 ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®);
1143 dev_err(&spi->dev, "Failed write reg (%08x)...\n",
1151 /********************************************
1153 * Global spi HIF function table
1155 ********************************************/
1156 const struct wilc_hif_func wilc_hif_spi = {
1157 .hif_init = wilc_spi_init,
1158 .hif_deinit = _wilc_spi_deinit,
1159 .hif_read_reg = wilc_spi_read_reg,
1160 .hif_write_reg = wilc_spi_write_reg,
1161 .hif_block_rx = wilc_spi_read,
1162 .hif_block_tx = wilc_spi_write,
1163 .hif_read_int = wilc_spi_read_int,
1164 .hif_clear_int_ext = wilc_spi_clear_int_ext,
1165 .hif_read_size = wilc_spi_read_size,
1166 .hif_block_tx_ext = wilc_spi_write,
1167 .hif_block_rx_ext = wilc_spi_read,
1168 .hif_sync_ext = wilc_spi_sync_ext,