Blame view

drivers/gpio/gpio-adnp.c 12.1 KB
5e969a401   Thierry Reding   gpio: Add Avionic...
1
2
3
4
5
6
7
  /*
   * Copyright (C) 2011-2012 Avionic Design GmbH
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
0752e169b   Linus Walleij   gpio: adnp: switc...
8
  #include <linux/gpio/driver.h>
5e969a401   Thierry Reding   gpio: Add Avionic...
9
10
  #include <linux/i2c.h>
  #include <linux/interrupt.h>
5e969a401   Thierry Reding   gpio: Add Avionic...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  #include <linux/module.h>
  #include <linux/of_irq.h>
  #include <linux/seq_file.h>
  #include <linux/slab.h>
  
  #define GPIO_DDR(gpio) (0x00 << (gpio)->reg_shift)
  #define GPIO_PLR(gpio) (0x01 << (gpio)->reg_shift)
  #define GPIO_IER(gpio) (0x02 << (gpio)->reg_shift)
  #define GPIO_ISR(gpio) (0x03 << (gpio)->reg_shift)
  #define GPIO_PTR(gpio) (0x04 << (gpio)->reg_shift)
  
  struct adnp {
  	struct i2c_client *client;
  	struct gpio_chip gpio;
  	unsigned int reg_shift;
  
  	struct mutex i2c_lock;
5e969a401   Thierry Reding   gpio: Add Avionic...
28
29
30
31
32
33
34
35
36
  	struct mutex irq_lock;
  
  	u8 *irq_enable;
  	u8 *irq_level;
  	u8 *irq_rise;
  	u8 *irq_fall;
  	u8 *irq_high;
  	u8 *irq_low;
  };
5e969a401   Thierry Reding   gpio: Add Avionic...
37
38
39
40
41
42
  static int adnp_read(struct adnp *adnp, unsigned offset, uint8_t *value)
  {
  	int err;
  
  	err = i2c_smbus_read_byte_data(adnp->client, offset);
  	if (err < 0) {
58383c784   Linus Walleij   gpio: change memb...
43
44
  		dev_err(adnp->gpio.parent, "%s failed: %d
  ",
5e969a401   Thierry Reding   gpio: Add Avionic...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  			"i2c_smbus_read_byte_data()", err);
  		return err;
  	}
  
  	*value = err;
  	return 0;
  }
  
  static int adnp_write(struct adnp *adnp, unsigned offset, uint8_t value)
  {
  	int err;
  
  	err = i2c_smbus_write_byte_data(adnp->client, offset, value);
  	if (err < 0) {
58383c784   Linus Walleij   gpio: change memb...
59
60
  		dev_err(adnp->gpio.parent, "%s failed: %d
  ",
5e969a401   Thierry Reding   gpio: Add Avionic...
61
62
63
64
65
66
67
68
69
  			"i2c_smbus_write_byte_data()", err);
  		return err;
  	}
  
  	return 0;
  }
  
  static int adnp_gpio_get(struct gpio_chip *chip, unsigned offset)
  {
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
70
  	struct adnp *adnp = gpiochip_get_data(chip);
5e969a401   Thierry Reding   gpio: Add Avionic...
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  	unsigned int reg = offset >> adnp->reg_shift;
  	unsigned int pos = offset & 7;
  	u8 value;
  	int err;
  
  	err = adnp_read(adnp, GPIO_PLR(adnp) + reg, &value);
  	if (err < 0)
  		return err;
  
  	return (value & BIT(pos)) ? 1 : 0;
  }
  
  static void __adnp_gpio_set(struct adnp *adnp, unsigned offset, int value)
  {
  	unsigned int reg = offset >> adnp->reg_shift;
  	unsigned int pos = offset & 7;
  	int err;
  	u8 val;
  
  	err = adnp_read(adnp, GPIO_PLR(adnp) + reg, &val);
  	if (err < 0)
  		return;
  
  	if (value)
  		val |= BIT(pos);
  	else
  		val &= ~BIT(pos);
  
  	adnp_write(adnp, GPIO_PLR(adnp) + reg, val);
  }
  
  static void adnp_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  {
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
104
  	struct adnp *adnp = gpiochip_get_data(chip);
5e969a401   Thierry Reding   gpio: Add Avionic...
105
106
107
108
109
110
111
112
  
  	mutex_lock(&adnp->i2c_lock);
  	__adnp_gpio_set(adnp, offset, value);
  	mutex_unlock(&adnp->i2c_lock);
  }
  
  static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  {
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
113
  	struct adnp *adnp = gpiochip_get_data(chip);
5e969a401   Thierry Reding   gpio: Add Avionic...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  	unsigned int reg = offset >> adnp->reg_shift;
  	unsigned int pos = offset & 7;
  	u8 value;
  	int err;
  
  	mutex_lock(&adnp->i2c_lock);
  
  	err = adnp_read(adnp, GPIO_DDR(adnp) + reg, &value);
  	if (err < 0)
  		goto out;
  
  	value &= ~BIT(pos);
  
  	err = adnp_write(adnp, GPIO_DDR(adnp) + reg, value);
  	if (err < 0)
  		goto out;
  
  	err = adnp_read(adnp, GPIO_DDR(adnp) + reg, &value);
  	if (err < 0)
  		goto out;
  
  	if (err & BIT(pos))
  		err = -EACCES;
  
  	err = 0;
  
  out:
  	mutex_unlock(&adnp->i2c_lock);
  	return err;
  }
  
  static int adnp_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
  				      int value)
  {
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
148
  	struct adnp *adnp = gpiochip_get_data(chip);
5e969a401   Thierry Reding   gpio: Add Avionic...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
  	unsigned int reg = offset >> adnp->reg_shift;
  	unsigned int pos = offset & 7;
  	int err;
  	u8 val;
  
  	mutex_lock(&adnp->i2c_lock);
  
  	err = adnp_read(adnp, GPIO_DDR(adnp) + reg, &val);
  	if (err < 0)
  		goto out;
  
  	val |= BIT(pos);
  
  	err = adnp_write(adnp, GPIO_DDR(adnp) + reg, val);
  	if (err < 0)
  		goto out;
  
  	err = adnp_read(adnp, GPIO_DDR(adnp) + reg, &val);
  	if (err < 0)
  		goto out;
  
  	if (!(val & BIT(pos))) {
  		err = -EPERM;
  		goto out;
  	}
  
  	__adnp_gpio_set(adnp, offset, value);
  	err = 0;
  
  out:
  	mutex_unlock(&adnp->i2c_lock);
  	return err;
  }
  
  static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
  {
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
185
  	struct adnp *adnp = gpiochip_get_data(chip);
5e969a401   Thierry Reding   gpio: Add Avionic...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  	unsigned int num_regs = 1 << adnp->reg_shift, i, j;
  	int err;
  
  	for (i = 0; i < num_regs; i++) {
  		u8 ddr, plr, ier, isr;
  
  		mutex_lock(&adnp->i2c_lock);
  
  		err = adnp_read(adnp, GPIO_DDR(adnp) + i, &ddr);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			return;
  		}
  
  		err = adnp_read(adnp, GPIO_PLR(adnp) + i, &plr);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			return;
  		}
  
  		err = adnp_read(adnp, GPIO_IER(adnp) + i, &ier);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			return;
  		}
  
  		err = adnp_read(adnp, GPIO_ISR(adnp) + i, &isr);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			return;
  		}
  
  		mutex_unlock(&adnp->i2c_lock);
  
  		for (j = 0; j < 8; j++) {
  			unsigned int bit = (i << adnp->reg_shift) + j;
  			const char *direction = "input ";
  			const char *level = "low ";
  			const char *interrupt = "disabled";
  			const char *pending = "";
  
  			if (ddr & BIT(j))
  				direction = "output";
  
  			if (plr & BIT(j))
  				level = "high";
  
  			if (ier & BIT(j))
  				interrupt = "enabled ";
  
  			if (isr & BIT(j))
  				pending = "pending";
  
  			seq_printf(s, "%2u: %s %s IRQ %s %s
  ", bit,
  				   direction, level, interrupt, pending);
  		}
  	}
  }
  
  static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios)
  {
  	struct gpio_chip *chip = &adnp->gpio;
0752e169b   Linus Walleij   gpio: adnp: switc...
249
  	int err;
5e969a401   Thierry Reding   gpio: Add Avionic...
250
251
252
253
254
255
256
  
  	adnp->reg_shift = get_count_order(num_gpios) - 3;
  
  	chip->direction_input = adnp_gpio_direction_input;
  	chip->direction_output = adnp_gpio_direction_output;
  	chip->get = adnp_gpio_get;
  	chip->set = adnp_gpio_set;
9fb1f39eb   Linus Walleij   gpio/pinctrl: mak...
257
  	chip->can_sleep = true;
5e969a401   Thierry Reding   gpio: Add Avionic...
258
259
260
261
262
263
264
  
  	if (IS_ENABLED(CONFIG_DEBUG_FS))
  		chip->dbg_show = adnp_gpio_dbg_show;
  
  	chip->base = -1;
  	chip->ngpio = num_gpios;
  	chip->label = adnp->client->name;
58383c784   Linus Walleij   gpio: change memb...
265
266
  	chip->parent = &adnp->client->dev;
  	chip->of_node = chip->parent->of_node;
5e969a401   Thierry Reding   gpio: Add Avionic...
267
  	chip->owner = THIS_MODULE;
daa994bfe   Laxman Dewangan   gpio: adnp: Use d...
268
  	err = devm_gpiochip_add_data(&adnp->client->dev, chip, adnp);
0752e169b   Linus Walleij   gpio: adnp: switc...
269
270
  	if (err)
  		return err;
5e969a401   Thierry Reding   gpio: Add Avionic...
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
  	return 0;
  }
  
  static irqreturn_t adnp_irq(int irq, void *data)
  {
  	struct adnp *adnp = data;
  	unsigned int num_regs, i;
  
  	num_regs = 1 << adnp->reg_shift;
  
  	for (i = 0; i < num_regs; i++) {
  		unsigned int base = i << adnp->reg_shift, bit;
  		u8 changed, level, isr, ier;
  		unsigned long pending;
  		int err;
  
  		mutex_lock(&adnp->i2c_lock);
  
  		err = adnp_read(adnp, GPIO_PLR(adnp) + i, &level);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			continue;
  		}
  
  		err = adnp_read(adnp, GPIO_ISR(adnp) + i, &isr);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			continue;
  		}
  
  		err = adnp_read(adnp, GPIO_IER(adnp) + i, &ier);
  		if (err < 0) {
  			mutex_unlock(&adnp->i2c_lock);
  			continue;
  		}
  
  		mutex_unlock(&adnp->i2c_lock);
  
  		/* determine pins that changed levels */
  		changed = level ^ adnp->irq_level[i];
  
  		/* compute edge-triggered interrupts */
  		pending = changed & ((adnp->irq_fall[i] & ~level) |
  				     (adnp->irq_rise[i] & level));
  
  		/* add in level-triggered interrupts */
  		pending |= (adnp->irq_high[i] & level) |
  			   (adnp->irq_low[i] & ~level);
  
  		/* mask out non-pending and disabled interrupts */
  		pending &= isr & ier;
  
  		for_each_set_bit(bit, &pending, 8) {
472f95b93   Linus Walleij   gpio: adnp: renam...
324
  			unsigned int child_irq;
0752e169b   Linus Walleij   gpio: adnp: switc...
325
326
  			child_irq = irq_find_mapping(adnp->gpio.irqdomain,
  						     base + bit);
472f95b93   Linus Walleij   gpio: adnp: renam...
327
  			handle_nested_irq(child_irq);
5e969a401   Thierry Reding   gpio: Add Avionic...
328
329
330
331
332
  		}
  	}
  
  	return IRQ_HANDLED;
  }
0752e169b   Linus Walleij   gpio: adnp: switc...
333
  static void adnp_irq_mask(struct irq_data *d)
5e969a401   Thierry Reding   gpio: Add Avionic...
334
  {
0752e169b   Linus Walleij   gpio: adnp: switc...
335
  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
336
  	struct adnp *adnp = gpiochip_get_data(gc);
0752e169b   Linus Walleij   gpio: adnp: switc...
337
338
  	unsigned int reg = d->hwirq >> adnp->reg_shift;
  	unsigned int pos = d->hwirq & 7;
5e969a401   Thierry Reding   gpio: Add Avionic...
339
340
341
  
  	adnp->irq_enable[reg] &= ~BIT(pos);
  }
0752e169b   Linus Walleij   gpio: adnp: switc...
342
  static void adnp_irq_unmask(struct irq_data *d)
5e969a401   Thierry Reding   gpio: Add Avionic...
343
  {
0752e169b   Linus Walleij   gpio: adnp: switc...
344
  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
345
  	struct adnp *adnp = gpiochip_get_data(gc);
0752e169b   Linus Walleij   gpio: adnp: switc...
346
347
  	unsigned int reg = d->hwirq >> adnp->reg_shift;
  	unsigned int pos = d->hwirq & 7;
5e969a401   Thierry Reding   gpio: Add Avionic...
348
349
350
  
  	adnp->irq_enable[reg] |= BIT(pos);
  }
0752e169b   Linus Walleij   gpio: adnp: switc...
351
  static int adnp_irq_set_type(struct irq_data *d, unsigned int type)
5e969a401   Thierry Reding   gpio: Add Avionic...
352
  {
0752e169b   Linus Walleij   gpio: adnp: switc...
353
  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
354
  	struct adnp *adnp = gpiochip_get_data(gc);
0752e169b   Linus Walleij   gpio: adnp: switc...
355
356
  	unsigned int reg = d->hwirq >> adnp->reg_shift;
  	unsigned int pos = d->hwirq & 7;
5e969a401   Thierry Reding   gpio: Add Avionic...
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
  
  	if (type & IRQ_TYPE_EDGE_RISING)
  		adnp->irq_rise[reg] |= BIT(pos);
  	else
  		adnp->irq_rise[reg] &= ~BIT(pos);
  
  	if (type & IRQ_TYPE_EDGE_FALLING)
  		adnp->irq_fall[reg] |= BIT(pos);
  	else
  		adnp->irq_fall[reg] &= ~BIT(pos);
  
  	if (type & IRQ_TYPE_LEVEL_HIGH)
  		adnp->irq_high[reg] |= BIT(pos);
  	else
  		adnp->irq_high[reg] &= ~BIT(pos);
  
  	if (type & IRQ_TYPE_LEVEL_LOW)
  		adnp->irq_low[reg] |= BIT(pos);
  	else
  		adnp->irq_low[reg] &= ~BIT(pos);
  
  	return 0;
  }
0752e169b   Linus Walleij   gpio: adnp: switc...
380
  static void adnp_irq_bus_lock(struct irq_data *d)
5e969a401   Thierry Reding   gpio: Add Avionic...
381
  {
0752e169b   Linus Walleij   gpio: adnp: switc...
382
  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
383
  	struct adnp *adnp = gpiochip_get_data(gc);
5e969a401   Thierry Reding   gpio: Add Avionic...
384
385
386
  
  	mutex_lock(&adnp->irq_lock);
  }
0752e169b   Linus Walleij   gpio: adnp: switc...
387
  static void adnp_irq_bus_unlock(struct irq_data *d)
5e969a401   Thierry Reding   gpio: Add Avionic...
388
  {
0752e169b   Linus Walleij   gpio: adnp: switc...
389
  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
1e69c4fe2   Linus Walleij   gpio: adnp: use g...
390
  	struct adnp *adnp = gpiochip_get_data(gc);
5e969a401   Thierry Reding   gpio: Add Avionic...
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
  	unsigned int num_regs = 1 << adnp->reg_shift, i;
  
  	mutex_lock(&adnp->i2c_lock);
  
  	for (i = 0; i < num_regs; i++)
  		adnp_write(adnp, GPIO_IER(adnp) + i, adnp->irq_enable[i]);
  
  	mutex_unlock(&adnp->i2c_lock);
  	mutex_unlock(&adnp->irq_lock);
  }
  
  static struct irq_chip adnp_irq_chip = {
  	.name = "gpio-adnp",
  	.irq_mask = adnp_irq_mask,
  	.irq_unmask = adnp_irq_unmask,
  	.irq_set_type = adnp_irq_set_type,
  	.irq_bus_lock = adnp_irq_bus_lock,
  	.irq_bus_sync_unlock = adnp_irq_bus_unlock,
5e969a401   Thierry Reding   gpio: Add Avionic...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
  };
  
  static int adnp_irq_setup(struct adnp *adnp)
  {
  	unsigned int num_regs = 1 << adnp->reg_shift, i;
  	struct gpio_chip *chip = &adnp->gpio;
  	int err;
  
  	mutex_init(&adnp->irq_lock);
  
  	/*
  	 * Allocate memory to keep track of the current level and trigger
  	 * modes of the interrupts. To avoid multiple allocations, a single
  	 * large buffer is allocated and pointers are setup to point at the
  	 * corresponding offsets. For consistency, the layout of the buffer
  	 * is chosen to match the register layout of the hardware in that
  	 * each segment contains the corresponding bits for all interrupts.
  	 */
58383c784   Linus Walleij   gpio: change memb...
427
428
  	adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6,
  					GFP_KERNEL);
5e969a401   Thierry Reding   gpio: Add Avionic...
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
  	if (!adnp->irq_enable)
  		return -ENOMEM;
  
  	adnp->irq_level = adnp->irq_enable + (num_regs * 1);
  	adnp->irq_rise = adnp->irq_enable + (num_regs * 2);
  	adnp->irq_fall = adnp->irq_enable + (num_regs * 3);
  	adnp->irq_high = adnp->irq_enable + (num_regs * 4);
  	adnp->irq_low = adnp->irq_enable + (num_regs * 5);
  
  	for (i = 0; i < num_regs; i++) {
  		/*
  		 * Read the initial level of all pins to allow the emulation
  		 * of edge triggered interrupts.
  		 */
  		err = adnp_read(adnp, GPIO_PLR(adnp) + i, &adnp->irq_level[i]);
  		if (err < 0)
  			return err;
  
  		/* disable all interrupts */
  		err = adnp_write(adnp, GPIO_IER(adnp) + i, 0);
  		if (err < 0)
  			return err;
  
  		adnp->irq_enable[i] = 0x00;
  	}
58383c784   Linus Walleij   gpio: change memb...
454
  	err = devm_request_threaded_irq(chip->parent, adnp->client->irq,
0752e169b   Linus Walleij   gpio: adnp: switc...
455
456
  					NULL, adnp_irq,
  					IRQF_TRIGGER_RISING | IRQF_ONESHOT,
58383c784   Linus Walleij   gpio: change memb...
457
  					dev_name(chip->parent), adnp);
5e969a401   Thierry Reding   gpio: Add Avionic...
458
  	if (err != 0) {
58383c784   Linus Walleij   gpio: change memb...
459
460
  		dev_err(chip->parent, "can't request IRQ#%d: %d
  ",
5e969a401   Thierry Reding   gpio: Add Avionic...
461
  			adnp->client->irq, err);
5b21533b7   Lars Poeschel   gpio: adnp: Fix s...
462
  		return err;
5e969a401   Thierry Reding   gpio: Add Avionic...
463
  	}
0752e169b   Linus Walleij   gpio: adnp: switc...
464
465
466
467
468
469
  	err = gpiochip_irqchip_add(chip,
  				   &adnp_irq_chip,
  				   0,
  				   handle_simple_irq,
  				   IRQ_TYPE_NONE);
  	if (err) {
58383c784   Linus Walleij   gpio: change memb...
470
  		dev_err(chip->parent,
0752e169b   Linus Walleij   gpio: adnp: switc...
471
472
473
  			"could not connect irqchip to gpiochip
  ");
  		return err;
5e969a401   Thierry Reding   gpio: Add Avionic...
474
  	}
0752e169b   Linus Walleij   gpio: adnp: switc...
475
  	return 0;
5e969a401   Thierry Reding   gpio: Add Avionic...
476
  }
3836309d9   Bill Pemberton   gpio: remove use ...
477
  static int adnp_i2c_probe(struct i2c_client *client,
5e969a401   Thierry Reding   gpio: Add Avionic...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
  				    const struct i2c_device_id *id)
  {
  	struct device_node *np = client->dev.of_node;
  	struct adnp *adnp;
  	u32 num_gpios;
  	int err;
  
  	err = of_property_read_u32(np, "nr-gpios", &num_gpios);
  	if (err < 0)
  		return err;
  
  	client->irq = irq_of_parse_and_map(np, 0);
  	if (!client->irq)
  		return -EPROBE_DEFER;
  
  	adnp = devm_kzalloc(&client->dev, sizeof(*adnp), GFP_KERNEL);
  	if (!adnp)
  		return -ENOMEM;
  
  	mutex_init(&adnp->i2c_lock);
  	adnp->client = client;
  
  	err = adnp_gpio_setup(adnp, num_gpios);
0752e169b   Linus Walleij   gpio: adnp: switc...
501
  	if (err)
5e969a401   Thierry Reding   gpio: Add Avionic...
502
503
504
505
  		return err;
  
  	if (of_find_property(np, "interrupt-controller", NULL)) {
  		err = adnp_irq_setup(adnp);
0752e169b   Linus Walleij   gpio: adnp: switc...
506
507
  		if (err)
  			return err;
5e969a401   Thierry Reding   gpio: Add Avionic...
508
  	}
5e969a401   Thierry Reding   gpio: Add Avionic...
509
  	i2c_set_clientdata(client, adnp);
5e969a401   Thierry Reding   gpio: Add Avionic...
510

0752e169b   Linus Walleij   gpio: adnp: switc...
511
  	return 0;
5e969a401   Thierry Reding   gpio: Add Avionic...
512
  }
b5ba78de7   Bill Pemberton   gpio: remove use ...
513
  static const struct i2c_device_id adnp_i2c_id[] = {
5e969a401   Thierry Reding   gpio: Add Avionic...
514
515
516
517
  	{ "gpio-adnp" },
  	{ },
  };
  MODULE_DEVICE_TABLE(i2c, adnp_i2c_id);
b5ba78de7   Bill Pemberton   gpio: remove use ...
518
  static const struct of_device_id adnp_of_match[] = {
5e969a401   Thierry Reding   gpio: Add Avionic...
519
520
521
522
523
524
525
526
  	{ .compatible = "ad,gpio-adnp", },
  	{ },
  };
  MODULE_DEVICE_TABLE(of, adnp_of_match);
  
  static struct i2c_driver adnp_i2c_driver = {
  	.driver = {
  		.name = "gpio-adnp",
83924fb30   Sachin Kamat   gpio: adnp: Remov...
527
  		.of_match_table = adnp_of_match,
5e969a401   Thierry Reding   gpio: Add Avionic...
528
529
  	},
  	.probe = adnp_i2c_probe,
5e969a401   Thierry Reding   gpio: Add Avionic...
530
531
532
533
534
535
536
  	.id_table = adnp_i2c_id,
  };
  module_i2c_driver(adnp_i2c_driver);
  
  MODULE_DESCRIPTION("Avionic Design N-bit GPIO expander");
  MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");
  MODULE_LICENSE("GPL");