Thomas Gleixner | 46fe777 | 2019-05-31 01:09:57 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 2 | /* |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 3 | * I2C Link Layer for ST NCI NFC controller familly based Driver |
| 4 | * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved. |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 8 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 9 | #include <linux/module.h> |
| 10 | #include <linux/i2c.h> |
Christophe Ricard | ed6a2f3 | 2015-12-23 23:45:09 +0100 | [diff] [blame] | 11 | #include <linux/gpio/consumer.h> |
Christophe Ricard | ed6a2f3 | 2015-12-23 23:45:09 +0100 | [diff] [blame] | 12 | #include <linux/acpi.h> |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/nfc.h> |
Andy Shevchenko | a89e68f | 2017-06-19 13:08:54 +0300 | [diff] [blame] | 16 | #include <linux/of.h> |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 17 | |
Christophe Ricard | e67e7e5 | 2015-10-25 22:54:17 +0100 | [diff] [blame] | 18 | #include "st-nci.h" |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 19 | |
Christophe Ricard | 30458aa | 2015-08-14 22:33:31 +0200 | [diff] [blame] | 20 | #define DRIVER_DESC "NCI NFC driver for ST_NCI" |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 21 | |
| 22 | /* ndlc header */ |
Christophe Ricard | 064d004 | 2015-10-25 22:54:44 +0100 | [diff] [blame] | 23 | #define ST_NCI_FRAME_HEADROOM 1 |
Christophe Ricard | 30458aa | 2015-08-14 22:33:31 +0200 | [diff] [blame] | 24 | #define ST_NCI_FRAME_TAILROOM 0 |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 25 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 26 | #define ST_NCI_I2C_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */ |
| 27 | #define ST_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */ |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 28 | |
Andy Shevchenko | 61a0410 | 2017-06-19 13:08:52 +0300 | [diff] [blame] | 29 | #define ST_NCI_DRIVER_NAME "st_nci" |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 30 | #define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c" |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 31 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 32 | struct st_nci_i2c_phy { |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 33 | struct i2c_client *i2c_dev; |
| 34 | struct llt_ndlc *ndlc; |
| 35 | |
Christophe Ricard | bb2496c | 2015-10-25 22:54:48 +0100 | [diff] [blame] | 36 | bool irq_active; |
| 37 | |
Andy Shevchenko | a89e68f | 2017-06-19 13:08:54 +0300 | [diff] [blame] | 38 | struct gpio_desc *gpiod_reset; |
Christophe Ricard | 3648dc6 | 2015-10-25 22:54:39 +0100 | [diff] [blame] | 39 | |
| 40 | struct st_nci_se_status se_status; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 43 | static int st_nci_i2c_enable(void *phy_id) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 44 | { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 45 | struct st_nci_i2c_phy *phy = phy_id; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 46 | |
Andy Shevchenko | a89e68f | 2017-06-19 13:08:54 +0300 | [diff] [blame] | 47 | gpiod_set_value(phy->gpiod_reset, 0); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 48 | usleep_range(10000, 15000); |
Andy Shevchenko | a89e68f | 2017-06-19 13:08:54 +0300 | [diff] [blame] | 49 | gpiod_set_value(phy->gpiod_reset, 1); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 50 | usleep_range(80000, 85000); |
| 51 | |
Christophe Ricard | bb2496c | 2015-10-25 22:54:48 +0100 | [diff] [blame] | 52 | if (phy->ndlc->powered == 0 && phy->irq_active == 0) { |
Christophe Ricard | 05f0939 | 2015-06-06 13:16:51 +0200 | [diff] [blame] | 53 | enable_irq(phy->i2c_dev->irq); |
Christophe Ricard | bb2496c | 2015-10-25 22:54:48 +0100 | [diff] [blame] | 54 | phy->irq_active = true; |
| 55 | } |
Christophe Ricard | 05f0939 | 2015-06-06 13:16:51 +0200 | [diff] [blame] | 56 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 57 | return 0; |
| 58 | } |
| 59 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 60 | static void st_nci_i2c_disable(void *phy_id) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 61 | { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 62 | struct st_nci_i2c_phy *phy = phy_id; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 63 | |
Christophe Ricard | 05f0939 | 2015-06-06 13:16:51 +0200 | [diff] [blame] | 64 | disable_irq_nosync(phy->i2c_dev->irq); |
Christophe Ricard | bb2496c | 2015-10-25 22:54:48 +0100 | [diff] [blame] | 65 | phy->irq_active = false; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 66 | } |
| 67 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 68 | /* |
| 69 | * Writing a frame must not return the number of written bytes. |
| 70 | * It must return either zero for success, or <0 for error. |
| 71 | * In addition, it must not alter the skb |
| 72 | */ |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 73 | static int st_nci_i2c_write(void *phy_id, struct sk_buff *skb) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 74 | { |
Colin Ian King | 23ec8ea | 2019-07-02 14:16:42 +0100 | [diff] [blame] | 75 | int r; |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 76 | struct st_nci_i2c_phy *phy = phy_id; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 77 | struct i2c_client *client = phy->i2c_dev; |
| 78 | |
Christophe Ricard | 4294e32 | 2014-09-13 10:28:47 +0200 | [diff] [blame] | 79 | if (phy->ndlc->hard_fault != 0) |
| 80 | return phy->ndlc->hard_fault; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 81 | |
| 82 | r = i2c_master_send(client, skb->data, skb->len); |
Christophe Ricard | d4a41d1 | 2015-03-31 08:02:15 +0200 | [diff] [blame] | 83 | if (r < 0) { /* Retry, chip was in standby */ |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 84 | usleep_range(1000, 4000); |
| 85 | r = i2c_master_send(client, skb->data, skb->len); |
| 86 | } |
| 87 | |
| 88 | if (r >= 0) { |
| 89 | if (r != skb->len) |
| 90 | r = -EREMOTEIO; |
| 91 | else |
| 92 | r = 0; |
| 93 | } |
| 94 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 95 | return r; |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | * Reads an ndlc frame and returns it in a newly allocated sk_buff. |
| 100 | * returns: |
Christophe Ricard | e7723b3 | 2015-08-14 22:33:32 +0200 | [diff] [blame] | 101 | * 0 : if received frame is complete |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 102 | * -EREMOTEIO : i2c read error (fatal) |
| 103 | * -EBADMSG : frame was incorrect and discarded |
Christophe Ricard | e7723b3 | 2015-08-14 22:33:32 +0200 | [diff] [blame] | 104 | * -ENOMEM : cannot allocate skb, frame dropped |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 105 | */ |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 106 | static int st_nci_i2c_read(struct st_nci_i2c_phy *phy, |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 107 | struct sk_buff **skb) |
| 108 | { |
| 109 | int r; |
| 110 | u8 len; |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 111 | u8 buf[ST_NCI_I2C_MAX_SIZE]; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 112 | struct i2c_client *client = phy->i2c_dev; |
| 113 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 114 | r = i2c_master_recv(client, buf, ST_NCI_I2C_MIN_SIZE); |
Christophe Ricard | d4a41d1 | 2015-03-31 08:02:15 +0200 | [diff] [blame] | 115 | if (r < 0) { /* Retry, chip was in standby */ |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 116 | usleep_range(1000, 4000); |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 117 | r = i2c_master_recv(client, buf, ST_NCI_I2C_MIN_SIZE); |
Christophe Ricard | ac633ba | 2014-09-03 23:30:26 +0200 | [diff] [blame] | 118 | } |
| 119 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 120 | if (r != ST_NCI_I2C_MIN_SIZE) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 121 | return -EREMOTEIO; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 122 | |
| 123 | len = be16_to_cpu(*(__be16 *) (buf + 2)); |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 124 | if (len > ST_NCI_I2C_MAX_SIZE) { |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 125 | nfc_err(&client->dev, "invalid frame len\n"); |
| 126 | return -EBADMSG; |
| 127 | } |
| 128 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 129 | *skb = alloc_skb(ST_NCI_I2C_MIN_SIZE + len, GFP_KERNEL); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 130 | if (*skb == NULL) |
| 131 | return -ENOMEM; |
| 132 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 133 | skb_reserve(*skb, ST_NCI_I2C_MIN_SIZE); |
| 134 | skb_put(*skb, ST_NCI_I2C_MIN_SIZE); |
| 135 | memcpy((*skb)->data, buf, ST_NCI_I2C_MIN_SIZE); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 136 | |
| 137 | if (!len) |
| 138 | return 0; |
| 139 | |
| 140 | r = i2c_master_recv(client, buf, len); |
| 141 | if (r != len) { |
| 142 | kfree_skb(*skb); |
| 143 | return -EREMOTEIO; |
| 144 | } |
| 145 | |
| 146 | skb_put(*skb, len); |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 147 | memcpy((*skb)->data + ST_NCI_I2C_MIN_SIZE, buf, len); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 148 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * Reads an ndlc frame from the chip. |
| 154 | * |
Christophe Ricard | 30458aa | 2015-08-14 22:33:31 +0200 | [diff] [blame] | 155 | * On ST_NCI, IRQ goes in idle state when read starts. |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 156 | */ |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 157 | static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 158 | { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 159 | struct st_nci_i2c_phy *phy = phy_id; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 160 | struct sk_buff *skb = NULL; |
| 161 | int r; |
| 162 | |
Christophe Ricard | 7274496 | 2015-01-25 23:33:29 +0100 | [diff] [blame] | 163 | if (!phy || !phy->ndlc || irq != phy->i2c_dev->irq) { |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 164 | WARN_ON_ONCE(1); |
| 165 | return IRQ_NONE; |
| 166 | } |
| 167 | |
Christophe Ricard | 4294e32 | 2014-09-13 10:28:47 +0200 | [diff] [blame] | 168 | if (phy->ndlc->hard_fault) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 169 | return IRQ_HANDLED; |
| 170 | |
Christophe Ricard | 183fe2d | 2015-06-06 13:16:50 +0200 | [diff] [blame] | 171 | if (!phy->ndlc->powered) { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 172 | st_nci_i2c_disable(phy); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 173 | return IRQ_HANDLED; |
| 174 | } |
| 175 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 176 | r = st_nci_i2c_read(phy, &skb); |
Christophe Ricard | 4294e32 | 2014-09-13 10:28:47 +0200 | [diff] [blame] | 177 | if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 178 | return IRQ_HANDLED; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 179 | |
| 180 | ndlc_recv(phy->ndlc, skb); |
| 181 | |
| 182 | return IRQ_HANDLED; |
| 183 | } |
| 184 | |
Krzysztof Kozlowski | 7a5e98d | 2021-07-24 23:47:36 +0200 | [diff] [blame] | 185 | static const struct nfc_phy_ops i2c_phy_ops = { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 186 | .write = st_nci_i2c_write, |
| 187 | .enable = st_nci_i2c_enable, |
| 188 | .disable = st_nci_i2c_disable, |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 189 | }; |
| 190 | |
Andy Shevchenko | 85d23e7 | 2017-06-19 13:08:56 +0300 | [diff] [blame] | 191 | static const struct acpi_gpio_params reset_gpios = { 1, 0, false }; |
| 192 | |
| 193 | static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = { |
| 194 | { "reset-gpios", &reset_gpios, 1 }, |
| 195 | {}, |
| 196 | }; |
| 197 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 198 | static int st_nci_i2c_probe(struct i2c_client *client, |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 199 | const struct i2c_device_id *id) |
| 200 | { |
Andy Shevchenko | 75719b2 | 2017-06-19 13:08:55 +0300 | [diff] [blame] | 201 | struct device *dev = &client->dev; |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 202 | struct st_nci_i2c_phy *phy; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 203 | int r; |
| 204 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 205 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
| 206 | nfc_err(&client->dev, "Need I2C_FUNC_I2C\n"); |
| 207 | return -ENODEV; |
| 208 | } |
| 209 | |
Andy Shevchenko | c745120 | 2017-06-19 13:08:57 +0300 | [diff] [blame] | 210 | phy = devm_kzalloc(dev, sizeof(struct st_nci_i2c_phy), GFP_KERNEL); |
Joe Perches | 3590ebc | 2015-04-07 00:17:00 -0700 | [diff] [blame] | 211 | if (!phy) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 212 | return -ENOMEM; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 213 | |
| 214 | phy->i2c_dev = client; |
| 215 | |
| 216 | i2c_set_clientdata(client, phy); |
| 217 | |
Andy Shevchenko | c745120 | 2017-06-19 13:08:57 +0300 | [diff] [blame] | 218 | r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios); |
| 219 | if (r) |
| 220 | dev_dbg(dev, "Unable to add GPIO mapping table\n"); |
| 221 | |
| 222 | /* Get RESET GPIO */ |
| 223 | phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); |
| 224 | if (IS_ERR(phy->gpiod_reset)) { |
| 225 | nfc_err(dev, "Unable to get RESET GPIO\n"); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 226 | return -ENODEV; |
| 227 | } |
| 228 | |
Andy Shevchenko | 75719b2 | 2017-06-19 13:08:55 +0300 | [diff] [blame] | 229 | phy->se_status.is_ese_present = |
| 230 | device_property_read_bool(dev, "ese-present"); |
| 231 | phy->se_status.is_uicc_present = |
| 232 | device_property_read_bool(dev, "uicc-present"); |
| 233 | |
Christophe Ricard | 7274496 | 2015-01-25 23:33:29 +0100 | [diff] [blame] | 234 | r = ndlc_probe(phy, &i2c_phy_ops, &client->dev, |
Christophe Ricard | 30458aa | 2015-08-14 22:33:31 +0200 | [diff] [blame] | 235 | ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM, |
Christophe Ricard | 3648dc6 | 2015-10-25 22:54:39 +0100 | [diff] [blame] | 236 | &phy->ndlc, &phy->se_status); |
Christophe Ricard | 7274496 | 2015-01-25 23:33:29 +0100 | [diff] [blame] | 237 | if (r < 0) { |
| 238 | nfc_err(&client->dev, "Unable to register ndlc layer\n"); |
| 239 | return r; |
| 240 | } |
| 241 | |
Christophe Ricard | bb2496c | 2015-10-25 22:54:48 +0100 | [diff] [blame] | 242 | phy->irq_active = true; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 243 | r = devm_request_threaded_irq(&client->dev, client->irq, NULL, |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 244 | st_nci_irq_thread_fn, |
Andy Shevchenko | 1af9fea | 2017-06-19 13:08:53 +0300 | [diff] [blame] | 245 | IRQF_ONESHOT, |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 246 | ST_NCI_DRIVER_NAME, phy); |
Christophe Ricard | 7274496 | 2015-01-25 23:33:29 +0100 | [diff] [blame] | 247 | if (r < 0) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 248 | nfc_err(&client->dev, "Unable to register IRQ handler\n"); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 249 | |
Christophe Ricard | 7274496 | 2015-01-25 23:33:29 +0100 | [diff] [blame] | 250 | return r; |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 251 | } |
| 252 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 253 | static int st_nci_i2c_remove(struct i2c_client *client) |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 254 | { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 255 | struct st_nci_i2c_phy *phy = i2c_get_clientdata(client); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 256 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 257 | ndlc_remove(phy->ndlc); |
| 258 | |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 259 | return 0; |
| 260 | } |
| 261 | |
Arvind Yadav | 9845530 | 2017-08-21 22:33:59 +0530 | [diff] [blame] | 262 | static const struct i2c_device_id st_nci_i2c_id_table[] = { |
Christophe Ricard | 3252897 | 2015-12-23 23:45:05 +0100 | [diff] [blame] | 263 | {ST_NCI_DRIVER_NAME, 0}, |
| 264 | {} |
| 265 | }; |
| 266 | MODULE_DEVICE_TABLE(i2c, st_nci_i2c_id_table); |
| 267 | |
Krzysztof Kozlowski | 255fcc7 | 2021-05-28 08:41:58 -0400 | [diff] [blame] | 268 | static const struct acpi_device_id st_nci_i2c_acpi_match[] __maybe_unused = { |
Christophe Ricard | ed6a2f3 | 2015-12-23 23:45:09 +0100 | [diff] [blame] | 269 | {"SMO2101"}, |
| 270 | {"SMO2102"}, |
| 271 | {} |
| 272 | }; |
| 273 | MODULE_DEVICE_TABLE(acpi, st_nci_i2c_acpi_match); |
| 274 | |
Krzysztof Kozlowski | 255fcc7 | 2021-05-28 08:41:58 -0400 | [diff] [blame] | 275 | static const struct of_device_id of_st_nci_i2c_match[] __maybe_unused = { |
Christophe Ricard | 1a94cb6 | 2014-12-08 22:08:07 +0100 | [diff] [blame] | 276 | { .compatible = "st,st21nfcb-i2c", }, |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 277 | { .compatible = "st,st21nfcb_i2c", }, |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 278 | { .compatible = "st,st21nfcc-i2c", }, |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 279 | {} |
| 280 | }; |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 281 | MODULE_DEVICE_TABLE(of, of_st_nci_i2c_match); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 282 | |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 283 | static struct i2c_driver st_nci_i2c_driver = { |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 284 | .driver = { |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 285 | .name = ST_NCI_I2C_DRIVER_NAME, |
| 286 | .of_match_table = of_match_ptr(of_st_nci_i2c_match), |
Christophe Ricard | ed6a2f3 | 2015-12-23 23:45:09 +0100 | [diff] [blame] | 287 | .acpi_match_table = ACPI_PTR(st_nci_i2c_acpi_match), |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 288 | }, |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 289 | .probe = st_nci_i2c_probe, |
| 290 | .id_table = st_nci_i2c_id_table, |
| 291 | .remove = st_nci_i2c_remove, |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 292 | }; |
Christophe Ricard | ed06aeef | 2015-06-09 22:26:05 +0200 | [diff] [blame] | 293 | module_i2c_driver(st_nci_i2c_driver); |
Christophe Ricard | 35630df | 2014-05-25 22:35:38 +0200 | [diff] [blame] | 294 | |
| 295 | MODULE_LICENSE("GPL"); |
| 296 | MODULE_DESCRIPTION(DRIVER_DESC); |