blob: 9dcc5b4fd9d1065253c9a33a93f142a925548f30 [file] [log] [blame]
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +00001/*
Philipp Zabel240a12d2014-04-03 11:28:10 +02002 * SPI driver for Micrel/Kendin KS8995M and KSZ8864RMN ethernet switches
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +00003 *
4 * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
5 *
6 * This file was based on: drivers/spi/at25.c
7 * Copyright (C) 2006 David Brownell
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
Joe Perches8d242482012-06-09 07:49:07 +000014#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +000016#include <linux/types.h>
17#include <linux/kernel.h>
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +000018#include <linux/module.h>
19#include <linux/delay.h>
20#include <linux/device.h>
Helmut Buchsbaumcd6f2882016-02-09 20:47:15 +010021#include <linux/of.h>
22#include <linux/gpio.h>
23#include <linux/of_gpio.h>
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +000024
25#include <linux/spi/spi.h>
26
27#define DRV_VERSION "0.1.1"
28#define DRV_DESC "Micrel KS8995 Ethernet switch SPI driver"
29
30/* ------------------------------------------------------------------------ */
31
32#define KS8995_REG_ID0 0x00 /* Chip ID0 */
33#define KS8995_REG_ID1 0x01 /* Chip ID1 */
34
35#define KS8995_REG_GC0 0x02 /* Global Control 0 */
36#define KS8995_REG_GC1 0x03 /* Global Control 1 */
37#define KS8995_REG_GC2 0x04 /* Global Control 2 */
38#define KS8995_REG_GC3 0x05 /* Global Control 3 */
39#define KS8995_REG_GC4 0x06 /* Global Control 4 */
40#define KS8995_REG_GC5 0x07 /* Global Control 5 */
41#define KS8995_REG_GC6 0x08 /* Global Control 6 */
42#define KS8995_REG_GC7 0x09 /* Global Control 7 */
43#define KS8995_REG_GC8 0x0a /* Global Control 8 */
44#define KS8995_REG_GC9 0x0b /* Global Control 9 */
45
46#define KS8995_REG_PC(p, r) ((0x10 * p) + r) /* Port Control */
47#define KS8995_REG_PS(p, r) ((0x10 * p) + r + 0xe) /* Port Status */
48
49#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */
50#define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */
51#define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */
52#define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */
53#define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */
54#define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */
55#define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */
56#define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */
57
58#define KS8995_REG_MAC0 0x68 /* MAC address 0 */
59#define KS8995_REG_MAC1 0x69 /* MAC address 1 */
60#define KS8995_REG_MAC2 0x6a /* MAC address 2 */
61#define KS8995_REG_MAC3 0x6b /* MAC address 3 */
62#define KS8995_REG_MAC4 0x6c /* MAC address 4 */
63#define KS8995_REG_MAC5 0x6d /* MAC address 5 */
64
65#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */
66#define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */
67#define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */
68#define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */
69#define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */
70#define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */
71#define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */
72#define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */
73#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */
74#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */
75
Philipp Zabel240a12d2014-04-03 11:28:10 +020076#define KSZ8864_REG_ID1 0xfe /* Chip ID in bit 7 */
77
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +000078#define KS8995_REGS_SIZE 0x80
Philipp Zabel240a12d2014-04-03 11:28:10 +020079#define KSZ8864_REGS_SIZE 0x100
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +000080
81#define ID1_CHIPID_M 0xf
82#define ID1_CHIPID_S 4
83#define ID1_REVISION_M 0x7
84#define ID1_REVISION_S 1
85#define ID1_START_SW 1 /* start the switch */
86
87#define FAMILY_KS8995 0x95
88#define CHIPID_M 0
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +010089#define KS8995_CHIP_ID 0x00
90#define KSZ8864_CHIP_ID 0x01
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +000091
92#define KS8995_CMD_WRITE 0x02U
93#define KS8995_CMD_READ 0x03U
94
95#define KS8995_RESET_DELAY 10 /* usec */
96
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +010097enum ks8995_chip_variant {
98 ks8995,
99 ksz8864,
100 max_variant
101};
102
103struct ks8995_chip_params {
104 char *name;
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100105 int family_id;
106 int chip_id;
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100107 int regs_size;
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100108 int addr_width;
109 int addr_shift;
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100110};
111
112static const struct ks8995_chip_params ks8995_chip[] = {
113 [ks8995] = {
114 .name = "KS8995MA",
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100115 .family_id = FAMILY_KS8995,
116 .chip_id = KS8995_CHIP_ID,
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100117 .regs_size = KS8995_REGS_SIZE,
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100118 .addr_width = 8,
119 .addr_shift = 0,
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100120 },
121 [ksz8864] = {
122 .name = "KSZ8864RMN",
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100123 .family_id = FAMILY_KS8995,
124 .chip_id = KSZ8864_CHIP_ID,
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100125 .regs_size = KSZ8864_REGS_SIZE,
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100126 .addr_width = 8,
127 .addr_shift = 0,
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100128 },
129};
130
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000131struct ks8995_pdata {
Helmut Buchsbaumcd6f2882016-02-09 20:47:15 +0100132 int reset_gpio;
133 enum of_gpio_flags reset_gpio_flags;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000134};
135
136struct ks8995_switch {
137 struct spi_device *spi;
138 struct mutex lock;
139 struct ks8995_pdata *pdata;
Philipp Zabel240a12d2014-04-03 11:28:10 +0200140 struct bin_attribute regs_attr;
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100141 const struct ks8995_chip_params *chip;
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100142 int revision_id;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000143};
144
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100145static const struct spi_device_id ks8995_id[] = {
146 {"ks8995", ks8995},
147 {"ksz8864", ksz8864},
148 { }
149};
150MODULE_DEVICE_TABLE(spi, ks8995_id);
151
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000152static inline u8 get_chip_id(u8 val)
153{
154 return (val >> ID1_CHIPID_S) & ID1_CHIPID_M;
155}
156
157static inline u8 get_chip_rev(u8 val)
158{
159 return (val >> ID1_REVISION_S) & ID1_REVISION_M;
160}
161
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100162/* create_spi_cmd - create a chip specific SPI command header
163 * @ks: pointer to switch instance
164 * @cmd: SPI command for switch
165 * @address: register address for command
166 *
167 * Different chip families use different bit pattern to address the switches
168 * registers:
169 *
170 * KS8995: 8bit command + 8bit address
171 * KSZ8795: 3bit command + 12bit address + 1bit TR (?)
172 */
173static inline __be16 create_spi_cmd(struct ks8995_switch *ks, int cmd,
174 unsigned address)
175{
176 u16 result = cmd;
177
178 /* make room for address (incl. address shift) */
179 result <<= ks->chip->addr_width + ks->chip->addr_shift;
180 /* add address */
181 result |= address << ks->chip->addr_shift;
182 /* SPI protocol needs big endian */
183 return cpu_to_be16(result);
184}
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000185/* ------------------------------------------------------------------------ */
186static int ks8995_read(struct ks8995_switch *ks, char *buf,
187 unsigned offset, size_t count)
188{
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100189 __be16 cmd;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000190 struct spi_transfer t[2];
191 struct spi_message m;
192 int err;
193
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100194 cmd = create_spi_cmd(ks, KS8995_CMD_READ, offset);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000195 spi_message_init(&m);
196
197 memset(&t, 0, sizeof(t));
198
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100199 t[0].tx_buf = &cmd;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000200 t[0].len = sizeof(cmd);
201 spi_message_add_tail(&t[0], &m);
202
203 t[1].rx_buf = buf;
204 t[1].len = count;
205 spi_message_add_tail(&t[1], &m);
206
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000207 mutex_lock(&ks->lock);
208 err = spi_sync(ks->spi, &m);
209 mutex_unlock(&ks->lock);
210
211 return err ? err : count;
212}
213
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000214static int ks8995_write(struct ks8995_switch *ks, char *buf,
215 unsigned offset, size_t count)
216{
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100217 __be16 cmd;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000218 struct spi_transfer t[2];
219 struct spi_message m;
220 int err;
221
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100222 cmd = create_spi_cmd(ks, KS8995_CMD_WRITE, offset);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000223 spi_message_init(&m);
224
225 memset(&t, 0, sizeof(t));
226
Helmut Buchsbaum6665e622016-02-09 20:47:16 +0100227 t[0].tx_buf = &cmd;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000228 t[0].len = sizeof(cmd);
229 spi_message_add_tail(&t[0], &m);
230
231 t[1].tx_buf = buf;
232 t[1].len = count;
233 spi_message_add_tail(&t[1], &m);
234
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000235 mutex_lock(&ks->lock);
236 err = spi_sync(ks->spi, &m);
237 mutex_unlock(&ks->lock);
238
239 return err ? err : count;
240}
241
242static inline int ks8995_read_reg(struct ks8995_switch *ks, u8 addr, u8 *buf)
243{
Florian Fainelli7aff9672013-12-17 21:38:13 -0800244 return ks8995_read(ks, buf, addr, 1) != 1;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000245}
246
247static inline int ks8995_write_reg(struct ks8995_switch *ks, u8 addr, u8 val)
248{
249 char buf = val;
250
Florian Fainelli7aff9672013-12-17 21:38:13 -0800251 return ks8995_write(ks, &buf, addr, 1) != 1;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000252}
253
254/* ------------------------------------------------------------------------ */
255
256static int ks8995_stop(struct ks8995_switch *ks)
257{
258 return ks8995_write_reg(ks, KS8995_REG_ID1, 0);
259}
260
261static int ks8995_start(struct ks8995_switch *ks)
262{
263 return ks8995_write_reg(ks, KS8995_REG_ID1, 1);
264}
265
266static int ks8995_reset(struct ks8995_switch *ks)
267{
268 int err;
269
270 err = ks8995_stop(ks);
271 if (err)
272 return err;
273
274 udelay(KS8995_RESET_DELAY);
275
276 return ks8995_start(ks);
277}
278
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000279static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
280 struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
281{
282 struct device *dev;
283 struct ks8995_switch *ks8995;
284
285 dev = container_of(kobj, struct device, kobj);
286 ks8995 = dev_get_drvdata(dev);
287
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000288 return ks8995_read(ks8995, buf, off, count);
289}
290
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000291static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
292 struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
293{
294 struct device *dev;
295 struct ks8995_switch *ks8995;
296
297 dev = container_of(kobj, struct device, kobj);
298 ks8995 = dev_get_drvdata(dev);
299
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000300 return ks8995_write(ks8995, buf, off, count);
301}
302
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100303/* ks8995_get_revision - get chip revision
304 * @ks: pointer to switch instance
305 *
306 * Verify chip family and id and get chip revision.
307 */
308static int ks8995_get_revision(struct ks8995_switch *ks)
309{
310 int err;
311 u8 id0, id1, ksz8864_id;
312
313 /* read family id */
314 err = ks8995_read_reg(ks, KS8995_REG_ID0, &id0);
315 if (err) {
316 err = -EIO;
317 goto err_out;
318 }
319
320 /* verify family id */
321 if (id0 != ks->chip->family_id) {
322 dev_err(&ks->spi->dev, "chip family id mismatch: expected 0x%02x but 0x%02x read\n",
323 ks->chip->family_id, id0);
324 err = -ENODEV;
325 goto err_out;
326 }
327
328 switch (ks->chip->family_id) {
329 case FAMILY_KS8995:
330 /* try reading chip id at CHIP ID1 */
331 err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1);
332 if (err) {
333 err = -EIO;
334 goto err_out;
335 }
336
337 /* verify chip id */
338 if ((get_chip_id(id1) == CHIPID_M) &&
339 (get_chip_id(id1) == ks->chip->chip_id)) {
340 /* KS8995MA */
341 ks->revision_id = get_chip_rev(id1);
342 } else if (get_chip_id(id1) != CHIPID_M) {
343 /* KSZ8864RMN */
344 err = ks8995_read_reg(ks, KS8995_REG_ID1, &ksz8864_id);
345 if (err) {
346 err = -EIO;
347 goto err_out;
348 }
349
350 if ((ksz8864_id & 0x80) &&
351 (ks->chip->chip_id == KSZ8864_CHIP_ID)) {
352 ks->revision_id = get_chip_rev(id1);
353 }
354
355 } else {
356 dev_err(&ks->spi->dev, "unsupported chip id for KS8995 family: 0x%02x\n",
357 id1);
358 err = -ENODEV;
359 }
360 break;
361 default:
362 dev_err(&ks->spi->dev, "unsupported family id: 0x%02x\n", id0);
363 err = -ENODEV;
364 break;
365 }
366err_out:
367 return err;
368}
369
Helmut Buchsbaumcd6f2882016-02-09 20:47:15 +0100370/* ks8995_parse_dt - setup platform data from devicetree
371 * @ks: pointer to switch instance
372 *
373 * Parses supported DT properties and sets up platform data
374 * accordingly.
375 */
376static void ks8995_parse_dt(struct ks8995_switch *ks)
377{
378 struct device_node *np = ks->spi->dev.of_node;
379 struct ks8995_pdata *pdata = ks->pdata;
380
381 if (!np)
382 return;
383
384 pdata->reset_gpio = of_get_named_gpio_flags(np, "reset-gpios", 0,
385 &pdata->reset_gpio_flags);
386}
387
Philipp Zabel240a12d2014-04-03 11:28:10 +0200388static const struct bin_attribute ks8995_registers_attr = {
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000389 .attr = {
390 .name = "registers",
391 .mode = S_IRUSR | S_IWUSR,
392 },
393 .size = KS8995_REGS_SIZE,
394 .read = ks8995_registers_read,
395 .write = ks8995_registers_write,
396};
397
398/* ------------------------------------------------------------------------ */
Bill Pemberton633d1592012-12-03 09:24:14 -0500399static int ks8995_probe(struct spi_device *spi)
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000400{
Helmut Buchsbaumcd6f2882016-02-09 20:47:15 +0100401 struct ks8995_switch *ks;
402 int err;
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100403 int variant = spi_get_device_id(spi)->driver_data;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000404
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100405 if (variant >= max_variant) {
406 dev_err(&spi->dev, "bad chip variant %d\n", variant);
407 return -ENODEV;
408 }
409
Himangi Saraogib32a8b62014-08-03 13:39:43 +0530410 ks = devm_kzalloc(&spi->dev, sizeof(*ks), GFP_KERNEL);
Joe Perchese68ed8f2013-02-03 17:28:15 +0000411 if (!ks)
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000412 return -ENOMEM;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000413
414 mutex_init(&ks->lock);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000415 ks->spi = spi_dev_get(spi);
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100416 ks->chip = &ks8995_chip[variant];
417
Helmut Buchsbaumcd6f2882016-02-09 20:47:15 +0100418 if (ks->spi->dev.of_node) {
419 ks->pdata = devm_kzalloc(&spi->dev, sizeof(*ks->pdata),
420 GFP_KERNEL);
421 if (!ks->pdata)
422 return -ENOMEM;
423
424 ks->pdata->reset_gpio = -1;
425
426 ks8995_parse_dt(ks);
427 }
428
429 if (!ks->pdata)
430 ks->pdata = spi->dev.platform_data;
431
432 /* de-assert switch reset */
433 if (ks->pdata && gpio_is_valid(ks->pdata->reset_gpio)) {
434 unsigned long flags;
435
436 flags = (ks->pdata->reset_gpio_flags == OF_GPIO_ACTIVE_LOW ?
437 GPIOF_ACTIVE_LOW : 0);
438
439 err = devm_gpio_request_one(&spi->dev,
440 ks->pdata->reset_gpio,
441 flags, "switch-reset");
442 if (err) {
443 dev_err(&spi->dev,
444 "failed to get reset-gpios: %d\n", err);
445 return -EIO;
446 }
447
448 gpiod_set_value(gpio_to_desc(ks->pdata->reset_gpio), 0);
449 }
450
Jingoo Han5d5f1842013-04-05 20:37:07 +0000451 spi_set_drvdata(spi, ks);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000452
453 spi->mode = SPI_MODE_0;
454 spi->bits_per_word = 8;
455 err = spi_setup(spi);
456 if (err) {
457 dev_err(&spi->dev, "spi_setup failed, err=%d\n", err);
Himangi Saraogib32a8b62014-08-03 13:39:43 +0530458 return err;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000459 }
460
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100461 err = ks8995_get_revision(ks);
462 if (err)
Himangi Saraogib32a8b62014-08-03 13:39:43 +0530463 return err;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000464
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100465 ks->regs_attr.size = ks->chip->regs_size;
Philipp Zabel240a12d2014-04-03 11:28:10 +0200466 memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr));
Philipp Zabel240a12d2014-04-03 11:28:10 +0200467
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000468 err = ks8995_reset(ks);
469 if (err)
Himangi Saraogib32a8b62014-08-03 13:39:43 +0530470 return err;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000471
Philipp Zabel240a12d2014-04-03 11:28:10 +0200472 err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000473 if (err) {
474 dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
475 err);
Himangi Saraogib32a8b62014-08-03 13:39:43 +0530476 return err;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000477 }
478
Helmut Buchsbaum484e36f2016-02-09 20:47:14 +0100479 dev_info(&spi->dev, "%s device found, Chip ID:%x, Revision:%x\n",
480 ks->chip->name, ks->chip->chip_id, ks->revision_id);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000481
482 return 0;
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000483}
484
Bill Pemberton633d1592012-12-03 09:24:14 -0500485static int ks8995_remove(struct spi_device *spi)
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000486{
Vladimir Zapolskiy30349bd2014-11-04 01:25:09 +0200487 struct ks8995_switch *ks = spi_get_drvdata(spi);
488
489 sysfs_remove_bin_file(&spi->dev.kobj, &ks->regs_attr);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000490
Helmut Buchsbaumcd6f2882016-02-09 20:47:15 +0100491 /* assert reset */
492 if (ks->pdata && gpio_is_valid(ks->pdata->reset_gpio))
493 gpiod_set_value(gpio_to_desc(ks->pdata->reset_gpio), 1);
494
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000495 return 0;
496}
497
498/* ------------------------------------------------------------------------ */
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000499static struct spi_driver ks8995_driver = {
500 .driver = {
501 .name = "spi-ks8995",
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000502 },
503 .probe = ks8995_probe,
Bill Pemberton633d1592012-12-03 09:24:14 -0500504 .remove = ks8995_remove,
Helmut Buchsbaumaa54c8d2016-02-09 20:47:13 +0100505 .id_table = ks8995_id,
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000506};
507
Sachin Kamat1a9561a2013-05-27 01:51:39 +0000508module_spi_driver(ks8995_driver);
Frederic LAMBERTa8e510f2011-12-18 07:33:41 +0000509
510MODULE_DESCRIPTION(DRV_DESC);
511MODULE_VERSION(DRV_VERSION);
512MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
513MODULE_LICENSE("GPL v2");