xref: /openbmc/linux/drivers/nfc/fdp/i2c.c (revision 634fef61)
1a06347c0SRobert Dolca /* -------------------------------------------------------------------------
2a06347c0SRobert Dolca  * Copyright (C) 2014-2016, Intel Corporation
3a06347c0SRobert Dolca  *
4a06347c0SRobert Dolca  *  This program is free software; you can redistribute it and/or modify
5a06347c0SRobert Dolca  *  it under the terms of the GNU General Public License as published by
6a06347c0SRobert Dolca  *  the Free Software Foundation; either version 2 of the License, or
7a06347c0SRobert Dolca  *  (at your option) any later version.
8a06347c0SRobert Dolca  *
9a06347c0SRobert Dolca  *  This program is distributed in the hope that it will be useful,
10a06347c0SRobert Dolca  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11a06347c0SRobert Dolca  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12a06347c0SRobert Dolca  *  GNU General Public License for more details.
13a06347c0SRobert Dolca  * -------------------------------------------------------------------------
14a06347c0SRobert Dolca  */
15a06347c0SRobert Dolca 
16a06347c0SRobert Dolca #include <linux/module.h>
17a06347c0SRobert Dolca #include <linux/acpi.h>
18a06347c0SRobert Dolca #include <linux/i2c.h>
19a06347c0SRobert Dolca #include <linux/interrupt.h>
20a06347c0SRobert Dolca #include <linux/nfc.h>
21a06347c0SRobert Dolca #include <linux/delay.h>
22a06347c0SRobert Dolca #include <linux/gpio/consumer.h>
23a06347c0SRobert Dolca #include <net/nfc/nfc.h>
24a06347c0SRobert Dolca #include <net/nfc/nci_core.h>
25a06347c0SRobert Dolca 
26a06347c0SRobert Dolca #include "fdp.h"
27a06347c0SRobert Dolca 
28a06347c0SRobert Dolca #define FDP_I2C_DRIVER_NAME	"fdp_nci_i2c"
29a06347c0SRobert Dolca 
30a06347c0SRobert Dolca #define FDP_DP_POWER_GPIO_NAME	"power"
31a06347c0SRobert Dolca #define FDP_DP_CLOCK_TYPE_NAME	"clock-type"
32a06347c0SRobert Dolca #define FDP_DP_CLOCK_FREQ_NAME	"clock-freq"
33a06347c0SRobert Dolca #define FDP_DP_FW_VSC_CFG_NAME	"fw-vsc-cfg"
34a06347c0SRobert Dolca 
35a06347c0SRobert Dolca #define FDP_FRAME_HEADROOM	2
36a06347c0SRobert Dolca #define FDP_FRAME_TAILROOM	1
37a06347c0SRobert Dolca 
38a06347c0SRobert Dolca #define FDP_NCI_I2C_MIN_PAYLOAD	5
39a06347c0SRobert Dolca #define FDP_NCI_I2C_MAX_PAYLOAD	261
40a06347c0SRobert Dolca 
41a06347c0SRobert Dolca #define FDP_POWER_OFF		0
42a06347c0SRobert Dolca #define FDP_POWER_ON		1
43a06347c0SRobert Dolca 
44a06347c0SRobert Dolca #define fdp_nci_i2c_dump_skb(dev, prefix, skb)				\
45a06347c0SRobert Dolca 	print_hex_dump(KERN_DEBUG, prefix": ", DUMP_PREFIX_OFFSET,	\
46a06347c0SRobert Dolca 		       16, 1, (skb)->data, (skb)->len, 0)
47a06347c0SRobert Dolca 
48a06347c0SRobert Dolca static void fdp_nci_i2c_reset(struct fdp_i2c_phy *phy)
49a06347c0SRobert Dolca {
50a06347c0SRobert Dolca 	/* Reset RST/WakeUP for at least 100 micro-second */
51a06347c0SRobert Dolca 	gpiod_set_value_cansleep(phy->power_gpio, FDP_POWER_OFF);
52a06347c0SRobert Dolca 	usleep_range(1000, 4000);
53a06347c0SRobert Dolca 	gpiod_set_value_cansleep(phy->power_gpio, FDP_POWER_ON);
54a06347c0SRobert Dolca 	usleep_range(10000, 14000);
55a06347c0SRobert Dolca }
56a06347c0SRobert Dolca 
57a06347c0SRobert Dolca static int fdp_nci_i2c_enable(void *phy_id)
58a06347c0SRobert Dolca {
59a06347c0SRobert Dolca 	struct fdp_i2c_phy *phy = phy_id;
60a06347c0SRobert Dolca 
61a06347c0SRobert Dolca 	dev_dbg(&phy->i2c_dev->dev, "%s\n", __func__);
62a06347c0SRobert Dolca 	fdp_nci_i2c_reset(phy);
63a06347c0SRobert Dolca 
64a06347c0SRobert Dolca 	return 0;
65a06347c0SRobert Dolca }
66a06347c0SRobert Dolca 
67a06347c0SRobert Dolca static void fdp_nci_i2c_disable(void *phy_id)
68a06347c0SRobert Dolca {
69a06347c0SRobert Dolca 	struct fdp_i2c_phy *phy = phy_id;
70a06347c0SRobert Dolca 
71a06347c0SRobert Dolca 	dev_dbg(&phy->i2c_dev->dev, "%s\n", __func__);
72a06347c0SRobert Dolca 	fdp_nci_i2c_reset(phy);
73a06347c0SRobert Dolca }
74a06347c0SRobert Dolca 
75a06347c0SRobert Dolca static void fdp_nci_i2c_add_len_lrc(struct sk_buff *skb)
76a06347c0SRobert Dolca {
77a06347c0SRobert Dolca 	u8 lrc = 0;
78a06347c0SRobert Dolca 	u16 len, i;
79a06347c0SRobert Dolca 
80a06347c0SRobert Dolca 	/* Add length header */
81a06347c0SRobert Dolca 	len = skb->len;
82d58ff351SJohannes Berg 	*(u8 *)skb_push(skb, 1) = len & 0xff;
83d58ff351SJohannes Berg 	*(u8 *)skb_push(skb, 1) = len >> 8;
84a06347c0SRobert Dolca 
85a06347c0SRobert Dolca 	/* Compute and add lrc */
86a06347c0SRobert Dolca 	for (i = 0; i < len + 2; i++)
87a06347c0SRobert Dolca 		lrc ^= skb->data[i];
88a06347c0SRobert Dolca 
89634fef61SJohannes Berg 	skb_put_u8(skb, lrc);
90a06347c0SRobert Dolca }
91a06347c0SRobert Dolca 
92a06347c0SRobert Dolca static void fdp_nci_i2c_remove_len_lrc(struct sk_buff *skb)
93a06347c0SRobert Dolca {
94a06347c0SRobert Dolca 	skb_pull(skb, FDP_FRAME_HEADROOM);
95a06347c0SRobert Dolca 	skb_trim(skb, skb->len - FDP_FRAME_TAILROOM);
96a06347c0SRobert Dolca }
97a06347c0SRobert Dolca 
98a06347c0SRobert Dolca static int fdp_nci_i2c_write(void *phy_id, struct sk_buff *skb)
99a06347c0SRobert Dolca {
100a06347c0SRobert Dolca 	struct fdp_i2c_phy *phy = phy_id;
101a06347c0SRobert Dolca 	struct i2c_client *client = phy->i2c_dev;
102a06347c0SRobert Dolca 	int r;
103a06347c0SRobert Dolca 
104a06347c0SRobert Dolca 	if (phy->hard_fault != 0)
105a06347c0SRobert Dolca 		return phy->hard_fault;
106a06347c0SRobert Dolca 
107a06347c0SRobert Dolca 	fdp_nci_i2c_add_len_lrc(skb);
108a06347c0SRobert Dolca 	fdp_nci_i2c_dump_skb(&client->dev, "fdp_wr", skb);
109a06347c0SRobert Dolca 
110a06347c0SRobert Dolca 	r = i2c_master_send(client, skb->data, skb->len);
111a06347c0SRobert Dolca 	if (r == -EREMOTEIO) {  /* Retry, chip was in standby */
112a06347c0SRobert Dolca 		usleep_range(1000, 4000);
113a06347c0SRobert Dolca 		r = i2c_master_send(client, skb->data, skb->len);
114a06347c0SRobert Dolca 	}
115a06347c0SRobert Dolca 
116a06347c0SRobert Dolca 	if (r < 0 || r != skb->len)
117a06347c0SRobert Dolca 		dev_dbg(&client->dev, "%s: error err=%d len=%d\n",
118a06347c0SRobert Dolca 			__func__, r, skb->len);
119a06347c0SRobert Dolca 
120a06347c0SRobert Dolca 	if (r >= 0) {
121a06347c0SRobert Dolca 		if (r != skb->len) {
122a06347c0SRobert Dolca 			phy->hard_fault = r;
123a06347c0SRobert Dolca 			r = -EREMOTEIO;
124a06347c0SRobert Dolca 		} else {
125a06347c0SRobert Dolca 			r = 0;
126a06347c0SRobert Dolca 		}
127a06347c0SRobert Dolca 	}
128a06347c0SRobert Dolca 
129a06347c0SRobert Dolca 	fdp_nci_i2c_remove_len_lrc(skb);
130a06347c0SRobert Dolca 
131a06347c0SRobert Dolca 	return r;
132a06347c0SRobert Dolca }
133a06347c0SRobert Dolca 
134a06347c0SRobert Dolca static struct nfc_phy_ops i2c_phy_ops = {
135a06347c0SRobert Dolca 	.write = fdp_nci_i2c_write,
136a06347c0SRobert Dolca 	.enable = fdp_nci_i2c_enable,
137a06347c0SRobert Dolca 	.disable = fdp_nci_i2c_disable,
138a06347c0SRobert Dolca };
139a06347c0SRobert Dolca 
140a06347c0SRobert Dolca static int fdp_nci_i2c_read(struct fdp_i2c_phy *phy, struct sk_buff **skb)
141a06347c0SRobert Dolca {
142a06347c0SRobert Dolca 	int r, len;
143a06347c0SRobert Dolca 	u8 tmp[FDP_NCI_I2C_MAX_PAYLOAD], lrc, k;
144a06347c0SRobert Dolca 	u16 i;
145a06347c0SRobert Dolca 	struct i2c_client *client = phy->i2c_dev;
146a06347c0SRobert Dolca 
147a06347c0SRobert Dolca 	*skb = NULL;
148a06347c0SRobert Dolca 
149a06347c0SRobert Dolca 	/* Read the length packet and the data packet */
150a06347c0SRobert Dolca 	for (k = 0; k < 2; k++) {
151a06347c0SRobert Dolca 
152a06347c0SRobert Dolca 		len = phy->next_read_size;
153a06347c0SRobert Dolca 
154a06347c0SRobert Dolca 		r = i2c_master_recv(client, tmp, len);
155a06347c0SRobert Dolca 		if (r != len) {
156a06347c0SRobert Dolca 			dev_dbg(&client->dev, "%s: i2c recv err: %d\n",
157a06347c0SRobert Dolca 				__func__, r);
158a06347c0SRobert Dolca 			goto flush;
159a06347c0SRobert Dolca 		}
160a06347c0SRobert Dolca 
161a06347c0SRobert Dolca 		/* Check packet integruty */
162a06347c0SRobert Dolca 		for (lrc = i = 0; i < r; i++)
163a06347c0SRobert Dolca 			lrc ^= tmp[i];
164a06347c0SRobert Dolca 
165a06347c0SRobert Dolca 		/*
166a06347c0SRobert Dolca 		 * LRC check failed. This may due to transmission error or
167a06347c0SRobert Dolca 		 * desynchronization between driver and FDP. Drop the paquet
168a06347c0SRobert Dolca 		 * and force resynchronization
169a06347c0SRobert Dolca 		 */
170a06347c0SRobert Dolca 		if (lrc) {
171a06347c0SRobert Dolca 			dev_dbg(&client->dev, "%s: corrupted packet\n",
172a06347c0SRobert Dolca 				__func__);
173a06347c0SRobert Dolca 			phy->next_read_size = 5;
174a06347c0SRobert Dolca 			goto flush;
175a06347c0SRobert Dolca 		}
176a06347c0SRobert Dolca 
177a06347c0SRobert Dolca 		/* Packet that contains a length */
178a06347c0SRobert Dolca 		if (tmp[0] == 0 && tmp[1] == 0) {
179a06347c0SRobert Dolca 			phy->next_read_size = (tmp[2] << 8) + tmp[3] + 3;
180a06347c0SRobert Dolca 		} else {
181a06347c0SRobert Dolca 			phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
182a06347c0SRobert Dolca 
183a06347c0SRobert Dolca 			*skb = alloc_skb(len, GFP_KERNEL);
184a06347c0SRobert Dolca 			if (*skb == NULL) {
185a06347c0SRobert Dolca 				r = -ENOMEM;
186a06347c0SRobert Dolca 				goto flush;
187a06347c0SRobert Dolca 			}
188a06347c0SRobert Dolca 
18959ae1d12SJohannes Berg 			skb_put_data(*skb, tmp, len);
190a06347c0SRobert Dolca 			fdp_nci_i2c_dump_skb(&client->dev, "fdp_rd", *skb);
191a06347c0SRobert Dolca 
192a06347c0SRobert Dolca 			fdp_nci_i2c_remove_len_lrc(*skb);
193a06347c0SRobert Dolca 		}
194a06347c0SRobert Dolca 	}
195a06347c0SRobert Dolca 
196a06347c0SRobert Dolca 	return 0;
197a06347c0SRobert Dolca 
198a06347c0SRobert Dolca flush:
199a06347c0SRobert Dolca 	/* Flush the remaining data */
200a06347c0SRobert Dolca 	if (i2c_master_recv(client, tmp, sizeof(tmp)) < 0)
201a06347c0SRobert Dolca 		r = -EREMOTEIO;
202a06347c0SRobert Dolca 
203a06347c0SRobert Dolca 	return r;
204a06347c0SRobert Dolca }
205a06347c0SRobert Dolca 
206a06347c0SRobert Dolca static irqreturn_t fdp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
207a06347c0SRobert Dolca {
208a06347c0SRobert Dolca 	struct fdp_i2c_phy *phy = phy_id;
209a06347c0SRobert Dolca 	struct i2c_client *client;
210a06347c0SRobert Dolca 	struct sk_buff *skb;
211a06347c0SRobert Dolca 	int r;
212a06347c0SRobert Dolca 
213a06347c0SRobert Dolca 	if (!phy || irq != phy->i2c_dev->irq) {
214a06347c0SRobert Dolca 		WARN_ON_ONCE(1);
215a06347c0SRobert Dolca 		return IRQ_NONE;
216a06347c0SRobert Dolca 	}
217a06347c0SRobert Dolca 
218b6355fb3SSudip Mukherjee 	client = phy->i2c_dev;
219b6355fb3SSudip Mukherjee 	dev_dbg(&client->dev, "%s\n", __func__);
220b6355fb3SSudip Mukherjee 
221a06347c0SRobert Dolca 	r = fdp_nci_i2c_read(phy, &skb);
222a06347c0SRobert Dolca 
223a06347c0SRobert Dolca 	if (r == -EREMOTEIO)
224a06347c0SRobert Dolca 		return IRQ_HANDLED;
225a06347c0SRobert Dolca 	else if (r == -ENOMEM || r == -EBADMSG)
226a06347c0SRobert Dolca 		return IRQ_HANDLED;
227a06347c0SRobert Dolca 
228a06347c0SRobert Dolca 	if (skb != NULL)
229a06347c0SRobert Dolca 		fdp_nci_recv_frame(phy->ndev, skb);
230a06347c0SRobert Dolca 
231a06347c0SRobert Dolca 	return IRQ_HANDLED;
232a06347c0SRobert Dolca }
233a06347c0SRobert Dolca 
234a06347c0SRobert Dolca static void fdp_nci_i2c_read_device_properties(struct device *dev,
235a06347c0SRobert Dolca 					       u8 *clock_type, u32 *clock_freq,
236a06347c0SRobert Dolca 					       u8 **fw_vsc_cfg)
237a06347c0SRobert Dolca {
238a06347c0SRobert Dolca 	int r;
239a06347c0SRobert Dolca 	u8 len;
240a06347c0SRobert Dolca 
241a06347c0SRobert Dolca 	r = device_property_read_u8(dev, FDP_DP_CLOCK_TYPE_NAME, clock_type);
242a06347c0SRobert Dolca 	if (r) {
243a06347c0SRobert Dolca 		dev_dbg(dev, "Using default clock type");
244a06347c0SRobert Dolca 		*clock_type = 0;
245a06347c0SRobert Dolca 	}
246a06347c0SRobert Dolca 
247a06347c0SRobert Dolca 	r = device_property_read_u32(dev, FDP_DP_CLOCK_FREQ_NAME, clock_freq);
248a06347c0SRobert Dolca 	if (r) {
249a06347c0SRobert Dolca 		dev_dbg(dev, "Using default clock frequency\n");
250a06347c0SRobert Dolca 		*clock_freq = 26000;
251a06347c0SRobert Dolca 	}
252a06347c0SRobert Dolca 
253a06347c0SRobert Dolca 	if (device_property_present(dev, FDP_DP_FW_VSC_CFG_NAME)) {
254a06347c0SRobert Dolca 		r = device_property_read_u8(dev, FDP_DP_FW_VSC_CFG_NAME,
255a06347c0SRobert Dolca 					    &len);
256a06347c0SRobert Dolca 
257a06347c0SRobert Dolca 		if (r || len <= 0)
258a06347c0SRobert Dolca 			goto vsc_read_err;
259a06347c0SRobert Dolca 
260a06347c0SRobert Dolca 		/* Add 1 to the length to inclue the length byte itself */
261a06347c0SRobert Dolca 		len++;
262a06347c0SRobert Dolca 
263a06347c0SRobert Dolca 		*fw_vsc_cfg = devm_kmalloc(dev,
264a06347c0SRobert Dolca 					   len * sizeof(**fw_vsc_cfg),
265a06347c0SRobert Dolca 					   GFP_KERNEL);
266a06347c0SRobert Dolca 
267a06347c0SRobert Dolca 		r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
268a06347c0SRobert Dolca 						  *fw_vsc_cfg, len);
269a06347c0SRobert Dolca 
270a06347c0SRobert Dolca 		if (r) {
271a06347c0SRobert Dolca 			devm_kfree(dev, fw_vsc_cfg);
272a06347c0SRobert Dolca 			goto vsc_read_err;
273a06347c0SRobert Dolca 		}
274a06347c0SRobert Dolca 	} else {
275a06347c0SRobert Dolca vsc_read_err:
276a06347c0SRobert Dolca 		dev_dbg(dev, "FW vendor specific commands not present\n");
277a06347c0SRobert Dolca 		*fw_vsc_cfg = NULL;
278a06347c0SRobert Dolca 	}
279a06347c0SRobert Dolca 
280a06347c0SRobert Dolca 	dev_dbg(dev, "Clock type: %d, clock frequency: %d, VSC: %s",
281a06347c0SRobert Dolca 		*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
282a06347c0SRobert Dolca }
283a06347c0SRobert Dolca 
284a06347c0SRobert Dolca static int fdp_nci_i2c_probe(struct i2c_client *client,
285a06347c0SRobert Dolca 			     const struct i2c_device_id *id)
286a06347c0SRobert Dolca {
287a06347c0SRobert Dolca 	struct fdp_i2c_phy *phy;
288a06347c0SRobert Dolca 	struct device *dev = &client->dev;
289a06347c0SRobert Dolca 	u8 *fw_vsc_cfg;
290a06347c0SRobert Dolca 	u8 clock_type;
291a06347c0SRobert Dolca 	u32 clock_freq;
292a06347c0SRobert Dolca 	int r = 0;
293a06347c0SRobert Dolca 
294a06347c0SRobert Dolca 	dev_dbg(dev, "%s\n", __func__);
295a06347c0SRobert Dolca 
296a06347c0SRobert Dolca 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
297a06347c0SRobert Dolca 		nfc_err(dev, "No I2C_FUNC_I2C support\n");
298a06347c0SRobert Dolca 		return -ENODEV;
299a06347c0SRobert Dolca 	}
300a06347c0SRobert Dolca 
3010b0a264dSChristophe Ricard 	/* Checking if we have an irq */
3020b0a264dSChristophe Ricard 	if (client->irq <= 0) {
3030b0a264dSChristophe Ricard 		nfc_err(dev, "IRQ not present\n");
3040b0a264dSChristophe Ricard 		return -ENODEV;
3050b0a264dSChristophe Ricard 	}
3060b0a264dSChristophe Ricard 
307a06347c0SRobert Dolca 	phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy),
308a06347c0SRobert Dolca 			   GFP_KERNEL);
309a06347c0SRobert Dolca 	if (!phy)
310a06347c0SRobert Dolca 		return -ENOMEM;
311a06347c0SRobert Dolca 
312a06347c0SRobert Dolca 	phy->i2c_dev = client;
313a06347c0SRobert Dolca 	phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
314a06347c0SRobert Dolca 	i2c_set_clientdata(client, phy);
315a06347c0SRobert Dolca 
316a06347c0SRobert Dolca 	r = request_threaded_irq(client->irq, NULL, fdp_nci_i2c_irq_thread_fn,
317a06347c0SRobert Dolca 				 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
318a06347c0SRobert Dolca 				 FDP_I2C_DRIVER_NAME, phy);
319a06347c0SRobert Dolca 
320a06347c0SRobert Dolca 	if (r < 0) {
321a06347c0SRobert Dolca 		nfc_err(&client->dev, "Unable to register IRQ handler\n");
322a06347c0SRobert Dolca 		return r;
323a06347c0SRobert Dolca 	}
324a06347c0SRobert Dolca 
325a06347c0SRobert Dolca 	/* Requesting the power gpio */
326a06347c0SRobert Dolca 	phy->power_gpio = devm_gpiod_get(dev, FDP_DP_POWER_GPIO_NAME,
327a06347c0SRobert Dolca 					 GPIOD_OUT_LOW);
328a06347c0SRobert Dolca 
329a06347c0SRobert Dolca 	if (IS_ERR(phy->power_gpio)) {
330a06347c0SRobert Dolca 		nfc_err(dev, "Power GPIO request failed\n");
331a06347c0SRobert Dolca 		return PTR_ERR(phy->power_gpio);
332a06347c0SRobert Dolca 	}
333a06347c0SRobert Dolca 
334a06347c0SRobert Dolca 	/* read device properties to get the clock and production settings */
335a06347c0SRobert Dolca 	fdp_nci_i2c_read_device_properties(dev, &clock_type, &clock_freq,
336a06347c0SRobert Dolca 					   &fw_vsc_cfg);
337a06347c0SRobert Dolca 
338a06347c0SRobert Dolca 	/* Call the NFC specific probe function */
339a06347c0SRobert Dolca 	r = fdp_nci_probe(phy, &i2c_phy_ops, &phy->ndev,
340a06347c0SRobert Dolca 			  FDP_FRAME_HEADROOM, FDP_FRAME_TAILROOM,
341a06347c0SRobert Dolca 			  clock_type, clock_freq, fw_vsc_cfg);
342a06347c0SRobert Dolca 	if (r < 0) {
343a06347c0SRobert Dolca 		nfc_err(dev, "NCI probing error\n");
344a06347c0SRobert Dolca 		return r;
345a06347c0SRobert Dolca 	}
346a06347c0SRobert Dolca 
347a06347c0SRobert Dolca 	dev_dbg(dev, "I2C driver loaded\n");
348a06347c0SRobert Dolca 	return 0;
349a06347c0SRobert Dolca }
350a06347c0SRobert Dolca 
351a06347c0SRobert Dolca static int fdp_nci_i2c_remove(struct i2c_client *client)
352a06347c0SRobert Dolca {
353a06347c0SRobert Dolca 	struct fdp_i2c_phy *phy = i2c_get_clientdata(client);
354a06347c0SRobert Dolca 
355a06347c0SRobert Dolca 	dev_dbg(&client->dev, "%s\n", __func__);
356a06347c0SRobert Dolca 
357a06347c0SRobert Dolca 	fdp_nci_remove(phy->ndev);
358a06347c0SRobert Dolca 	fdp_nci_i2c_disable(phy);
359a06347c0SRobert Dolca 
360a06347c0SRobert Dolca 	return 0;
361a06347c0SRobert Dolca }
362a06347c0SRobert Dolca 
363a06347c0SRobert Dolca static struct i2c_device_id fdp_nci_i2c_id_table[] = {
364a06347c0SRobert Dolca 	{"int339a", 0},
365a06347c0SRobert Dolca 	{}
366a06347c0SRobert Dolca };
367a06347c0SRobert Dolca MODULE_DEVICE_TABLE(i2c, fdp_nci_i2c_id_table);
368a06347c0SRobert Dolca 
369a06347c0SRobert Dolca static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = {
370a06347c0SRobert Dolca 	{"INT339A", 0},
371a06347c0SRobert Dolca 	{}
372a06347c0SRobert Dolca };
373a06347c0SRobert Dolca MODULE_DEVICE_TABLE(acpi, fdp_nci_i2c_acpi_match);
374a06347c0SRobert Dolca 
375a06347c0SRobert Dolca static struct i2c_driver fdp_nci_i2c_driver = {
376a06347c0SRobert Dolca 	.driver = {
377a06347c0SRobert Dolca 		   .name = FDP_I2C_DRIVER_NAME,
378a06347c0SRobert Dolca 		   .acpi_match_table = ACPI_PTR(fdp_nci_i2c_acpi_match),
379a06347c0SRobert Dolca 		  },
380a06347c0SRobert Dolca 	.id_table = fdp_nci_i2c_id_table,
381a06347c0SRobert Dolca 	.probe = fdp_nci_i2c_probe,
382a06347c0SRobert Dolca 	.remove = fdp_nci_i2c_remove,
383a06347c0SRobert Dolca };
384a06347c0SRobert Dolca module_i2c_driver(fdp_nci_i2c_driver);
385a06347c0SRobert Dolca 
386a06347c0SRobert Dolca MODULE_LICENSE("GPL");
387a06347c0SRobert Dolca MODULE_DESCRIPTION("I2C driver for Intel Fields Peak NFC controller");
388a06347c0SRobert Dolca MODULE_AUTHOR("Robert Dolca <robert.dolca@intel.com>");
389