blob: bd2696136eeecf684d08fa7ee70f9d92383a96fb [file] [log] [blame]
Kevin Strasser43620a12013-06-23 21:00:03 -07001/*
2 * Kontron PLD MFD core driver
3 *
4 * Copyright (c) 2010-2013 Kontron Europe GmbH
5 * Author: Michael Brunner <michael.brunner@kontron.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License 2 as published
9 * by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/platform_device.h>
18#include <linux/mfd/core.h>
19#include <linux/mfd/kempld.h>
20#include <linux/module.h>
21#include <linux/dmi.h>
22#include <linux/io.h>
23#include <linux/delay.h>
24
25#define MAX_ID_LEN 4
26static char force_device_id[MAX_ID_LEN + 1] = "";
Lee Jones9ef4e932014-07-21 16:47:51 +010027module_param_string(force_device_id, force_device_id,
28 sizeof(force_device_id), 0);
Kevin Strasser43620a12013-06-23 21:00:03 -070029MODULE_PARM_DESC(force_device_id, "Override detected product");
30
31/*
32 * Get hardware mutex to block firmware from accessing the pld.
33 * It is possible for the firmware may hold the mutex for an extended length of
34 * time. This function will block until access has been granted.
35 */
36static void kempld_get_hardware_mutex(struct kempld_device_data *pld)
37{
38 /* The mutex bit will read 1 until access has been granted */
39 while (ioread8(pld->io_index) & KEMPLD_MUTEX_KEY)
Lee Jones9ef4e932014-07-21 16:47:51 +010040 usleep_range(1000, 3000);
Kevin Strasser43620a12013-06-23 21:00:03 -070041}
42
43static void kempld_release_hardware_mutex(struct kempld_device_data *pld)
44{
45 /* The harware mutex is released when 1 is written to the mutex bit. */
46 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
47}
48
49static int kempld_get_info_generic(struct kempld_device_data *pld)
50{
51 u16 version;
52 u8 spec;
53
54 kempld_get_mutex(pld);
55
56 version = kempld_read16(pld, KEMPLD_VERSION);
57 spec = kempld_read8(pld, KEMPLD_SPEC);
58 pld->info.buildnr = kempld_read16(pld, KEMPLD_BUILDNR);
59
60 pld->info.minor = KEMPLD_VERSION_GET_MINOR(version);
61 pld->info.major = KEMPLD_VERSION_GET_MAJOR(version);
62 pld->info.number = KEMPLD_VERSION_GET_NUMBER(version);
63 pld->info.type = KEMPLD_VERSION_GET_TYPE(version);
64
65 if (spec == 0xff) {
66 pld->info.spec_minor = 0;
67 pld->info.spec_major = 1;
68 } else {
69 pld->info.spec_minor = KEMPLD_SPEC_GET_MINOR(spec);
70 pld->info.spec_major = KEMPLD_SPEC_GET_MAJOR(spec);
71 }
72
73 if (pld->info.spec_major > 0)
74 pld->feature_mask = kempld_read16(pld, KEMPLD_FEATURE);
75 else
76 pld->feature_mask = 0;
77
78 kempld_release_mutex(pld);
79
80 return 0;
81}
82
83enum kempld_cells {
84 KEMPLD_I2C = 0,
85 KEMPLD_WDT,
86 KEMPLD_GPIO,
87 KEMPLD_UART,
88};
89
Krzysztof Kozlowskibd6d35a62014-05-13 12:58:42 +020090static const struct mfd_cell kempld_devs[] = {
Kevin Strasser43620a12013-06-23 21:00:03 -070091 [KEMPLD_I2C] = {
92 .name = "kempld-i2c",
93 },
94 [KEMPLD_WDT] = {
95 .name = "kempld-wdt",
96 },
97 [KEMPLD_GPIO] = {
98 .name = "kempld-gpio",
99 },
100 [KEMPLD_UART] = {
101 .name = "kempld-uart",
102 },
103};
104
105#define KEMPLD_MAX_DEVS ARRAY_SIZE(kempld_devs)
106
107static int kempld_register_cells_generic(struct kempld_device_data *pld)
108{
109 struct mfd_cell devs[KEMPLD_MAX_DEVS];
110 int i = 0;
111
112 if (pld->feature_mask & KEMPLD_FEATURE_BIT_I2C)
113 devs[i++] = kempld_devs[KEMPLD_I2C];
114
115 if (pld->feature_mask & KEMPLD_FEATURE_BIT_WATCHDOG)
116 devs[i++] = kempld_devs[KEMPLD_WDT];
117
118 if (pld->feature_mask & KEMPLD_FEATURE_BIT_GPIO)
119 devs[i++] = kempld_devs[KEMPLD_GPIO];
120
121 if (pld->feature_mask & KEMPLD_FEATURE_MASK_UART)
122 devs[i++] = kempld_devs[KEMPLD_UART];
123
124 return mfd_add_devices(pld->dev, -1, devs, i, NULL, 0, NULL);
125}
126
127static struct resource kempld_ioresource = {
128 .start = KEMPLD_IOINDEX,
129 .end = KEMPLD_IODATA,
130 .flags = IORESOURCE_IO,
131};
132
133static const struct kempld_platform_data kempld_platform_data_generic = {
134 .pld_clock = KEMPLD_CLK,
135 .ioresource = &kempld_ioresource,
136 .get_hardware_mutex = kempld_get_hardware_mutex,
137 .release_hardware_mutex = kempld_release_hardware_mutex,
138 .get_info = kempld_get_info_generic,
139 .register_cells = kempld_register_cells_generic,
140};
141
142static struct platform_device *kempld_pdev;
143
144static int kempld_create_platform_device(const struct dmi_system_id *id)
145{
146 struct kempld_platform_data *pdata = id->driver_data;
147 int ret;
148
149 kempld_pdev = platform_device_alloc("kempld", -1);
150 if (!kempld_pdev)
151 return -ENOMEM;
152
153 ret = platform_device_add_data(kempld_pdev, pdata, sizeof(*pdata));
154 if (ret)
155 goto err;
156
157 ret = platform_device_add_resources(kempld_pdev, pdata->ioresource, 1);
158 if (ret)
159 goto err;
160
161 ret = platform_device_add(kempld_pdev);
162 if (ret)
163 goto err;
164
165 return 0;
166err:
167 platform_device_put(kempld_pdev);
168 return ret;
169}
170
171/**
172 * kempld_read8 - read 8 bit register
173 * @pld: kempld_device_data structure describing the PLD
174 * @index: register index on the chip
175 *
176 * kempld_get_mutex must be called prior to calling this function.
177 */
178u8 kempld_read8(struct kempld_device_data *pld, u8 index)
179{
180 iowrite8(index, pld->io_index);
181 return ioread8(pld->io_data);
182}
183EXPORT_SYMBOL_GPL(kempld_read8);
184
185/**
186 * kempld_write8 - write 8 bit register
187 * @pld: kempld_device_data structure describing the PLD
188 * @index: register index on the chip
189 * @data: new register value
190 *
191 * kempld_get_mutex must be called prior to calling this function.
192 */
193void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data)
194{
195 iowrite8(index, pld->io_index);
196 iowrite8(data, pld->io_data);
197}
198EXPORT_SYMBOL_GPL(kempld_write8);
199
200/**
201 * kempld_read16 - read 16 bit register
202 * @pld: kempld_device_data structure describing the PLD
203 * @index: register index on the chip
204 *
205 * kempld_get_mutex must be called prior to calling this function.
206 */
207u16 kempld_read16(struct kempld_device_data *pld, u8 index)
208{
209 return kempld_read8(pld, index) | kempld_read8(pld, index + 1) << 8;
210}
211EXPORT_SYMBOL_GPL(kempld_read16);
212
213/**
214 * kempld_write16 - write 16 bit register
215 * @pld: kempld_device_data structure describing the PLD
216 * @index: register index on the chip
217 * @data: new register value
218 *
219 * kempld_get_mutex must be called prior to calling this function.
220 */
221void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data)
222{
223 kempld_write8(pld, index, (u8)data);
224 kempld_write8(pld, index + 1, (u8)(data >> 8));
225}
226EXPORT_SYMBOL_GPL(kempld_write16);
227
228/**
229 * kempld_read32 - read 32 bit register
230 * @pld: kempld_device_data structure describing the PLD
231 * @index: register index on the chip
232 *
233 * kempld_get_mutex must be called prior to calling this function.
234 */
235u32 kempld_read32(struct kempld_device_data *pld, u8 index)
236{
237 return kempld_read16(pld, index) | kempld_read16(pld, index + 2) << 16;
238}
239EXPORT_SYMBOL_GPL(kempld_read32);
240
241/**
242 * kempld_write32 - write 32 bit register
243 * @pld: kempld_device_data structure describing the PLD
244 * @index: register index on the chip
245 * @data: new register value
246 *
247 * kempld_get_mutex must be called prior to calling this function.
248 */
249void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data)
250{
251 kempld_write16(pld, index, (u16)data);
252 kempld_write16(pld, index + 2, (u16)(data >> 16));
253}
254EXPORT_SYMBOL_GPL(kempld_write32);
255
256/**
257 * kempld_get_mutex - acquire PLD mutex
258 * @pld: kempld_device_data structure describing the PLD
259 */
260void kempld_get_mutex(struct kempld_device_data *pld)
261{
Jingoo Han334a41c2013-07-30 17:10:05 +0900262 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700263
264 mutex_lock(&pld->lock);
265 pdata->get_hardware_mutex(pld);
266}
267EXPORT_SYMBOL_GPL(kempld_get_mutex);
268
269/**
270 * kempld_release_mutex - release PLD mutex
271 * @pld: kempld_device_data structure describing the PLD
272 */
273void kempld_release_mutex(struct kempld_device_data *pld)
274{
Jingoo Han334a41c2013-07-30 17:10:05 +0900275 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700276
277 pdata->release_hardware_mutex(pld);
278 mutex_unlock(&pld->lock);
279}
280EXPORT_SYMBOL_GPL(kempld_release_mutex);
281
282/**
283 * kempld_get_info - update device specific information
284 * @pld: kempld_device_data structure describing the PLD
285 *
286 * This function calls the configured board specific kempld_get_info_XXXX
287 * function which is responsible for gathering information about the specific
288 * hardware. The information is then stored within the pld structure.
289 */
290static int kempld_get_info(struct kempld_device_data *pld)
291{
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200292 int ret;
Jingoo Han334a41c2013-07-30 17:10:05 +0900293 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200294 char major, minor;
Kevin Strasser43620a12013-06-23 21:00:03 -0700295
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200296 ret = pdata->get_info(pld);
297 if (ret)
298 return ret;
299
300 /* The Kontron PLD firmware version string has the following format:
301 * Pwxy.zzzz
302 * P: Fixed
303 * w: PLD number - 1 hex digit
304 * x: Major version - 1 alphanumerical digit (0-9A-V)
305 * y: Minor version - 1 alphanumerical digit (0-9A-V)
306 * zzzz: Build number - 4 zero padded hex digits */
307
308 if (pld->info.major < 10)
309 major = pld->info.major + '0';
310 else
311 major = (pld->info.major - 10) + 'A';
312 if (pld->info.minor < 10)
313 minor = pld->info.minor + '0';
314 else
315 minor = (pld->info.minor - 10) + 'A';
316
317 ret = scnprintf(pld->info.version, sizeof(pld->info.version),
318 "P%X%c%c.%04X", pld->info.number, major, minor,
319 pld->info.buildnr);
320 if (ret < 0)
321 return ret;
322
323 return 0;
Kevin Strasser43620a12013-06-23 21:00:03 -0700324}
325
326/*
327 * kempld_register_cells - register cell drivers
328 *
329 * This function registers cell drivers for the detected hardware by calling
330 * the configured kempld_register_cells_XXXX function which is responsible
331 * to detect and register the needed cell drivers.
332 */
333static int kempld_register_cells(struct kempld_device_data *pld)
334{
Jingoo Han334a41c2013-07-30 17:10:05 +0900335 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700336
337 return pdata->register_cells(pld);
338}
339
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200340static const char *kempld_get_type_string(struct kempld_device_data *pld)
341{
342 const char *version_type;
343
344 switch (pld->info.type) {
345 case 0:
346 version_type = "release";
347 break;
348 case 1:
349 version_type = "debug";
350 break;
351 case 2:
352 version_type = "custom";
353 break;
354 default:
355 version_type = "unspecified";
356 break;
357 }
358
359 return version_type;
360}
361
362static ssize_t kempld_version_show(struct device *dev,
363 struct device_attribute *attr, char *buf)
364{
365 struct kempld_device_data *pld = dev_get_drvdata(dev);
366
367 return scnprintf(buf, PAGE_SIZE, "%s\n", pld->info.version);
368}
369
370static ssize_t kempld_specification_show(struct device *dev,
371 struct device_attribute *attr, char *buf)
372{
373 struct kempld_device_data *pld = dev_get_drvdata(dev);
374
375 return scnprintf(buf, PAGE_SIZE, "%d.%d\n", pld->info.spec_major,
376 pld->info.spec_minor);
377}
378
379static ssize_t kempld_type_show(struct device *dev,
380 struct device_attribute *attr, char *buf)
381{
382 struct kempld_device_data *pld = dev_get_drvdata(dev);
383
384 return scnprintf(buf, PAGE_SIZE, "%s\n", kempld_get_type_string(pld));
385}
386
387static DEVICE_ATTR(pld_version, S_IRUGO, kempld_version_show, NULL);
388static DEVICE_ATTR(pld_specification, S_IRUGO, kempld_specification_show,
389 NULL);
390static DEVICE_ATTR(pld_type, S_IRUGO, kempld_type_show, NULL);
391
392static struct attribute *pld_attributes[] = {
393 &dev_attr_pld_version.attr,
394 &dev_attr_pld_specification.attr,
395 &dev_attr_pld_type.attr,
396 NULL
397};
398
399static const struct attribute_group pld_attr_group = {
400 .attrs = pld_attributes,
401};
402
Kevin Strasser43620a12013-06-23 21:00:03 -0700403static int kempld_detect_device(struct kempld_device_data *pld)
404{
Kevin Strasser43620a12013-06-23 21:00:03 -0700405 u8 index_reg;
406 int ret;
407
408 mutex_lock(&pld->lock);
409
410 /* Check for empty IO space */
411 index_reg = ioread8(pld->io_index);
412 if (index_reg == 0xff && ioread8(pld->io_data) == 0xff) {
413 mutex_unlock(&pld->lock);
414 return -ENODEV;
415 }
416
Guenter Roeck204747c2014-03-20 08:12:28 -0700417 /* Release hardware mutex if acquired */
418 if (!(index_reg & KEMPLD_MUTEX_KEY)) {
Kevin Strasser43620a12013-06-23 21:00:03 -0700419 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
Guenter Roeck204747c2014-03-20 08:12:28 -0700420 /* PXT and COMe-cPC2 boards may require a second release */
421 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
422 }
Kevin Strasser43620a12013-06-23 21:00:03 -0700423
424 mutex_unlock(&pld->lock);
425
426 ret = kempld_get_info(pld);
427 if (ret)
428 return ret;
429
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200430 dev_info(pld->dev, "Found Kontron PLD - %s (%s), spec %d.%d\n",
431 pld->info.version, kempld_get_type_string(pld),
432 pld->info.spec_major, pld->info.spec_minor);
Kevin Strasser43620a12013-06-23 21:00:03 -0700433
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200434 ret = sysfs_create_group(&pld->dev->kobj, &pld_attr_group);
435 if (ret)
436 return ret;
Kevin Strasser43620a12013-06-23 21:00:03 -0700437
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200438 ret = kempld_register_cells(pld);
439 if (ret)
440 sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
441
442 return ret;
Kevin Strasser43620a12013-06-23 21:00:03 -0700443}
444
445static int kempld_probe(struct platform_device *pdev)
446{
Jingoo Han334a41c2013-07-30 17:10:05 +0900447 struct kempld_platform_data *pdata = dev_get_platdata(&pdev->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700448 struct device *dev = &pdev->dev;
449 struct kempld_device_data *pld;
450 struct resource *ioport;
451 int ret;
452
453 pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
454 if (!pld)
455 return -ENOMEM;
456
457 ioport = platform_get_resource(pdev, IORESOURCE_IO, 0);
458 if (!ioport)
459 return -EINVAL;
460
461 pld->io_base = devm_ioport_map(dev, ioport->start,
462 ioport->end - ioport->start);
463 if (!pld->io_base)
464 return -ENOMEM;
465
466 pld->io_index = pld->io_base;
467 pld->io_data = pld->io_base + 1;
468 pld->pld_clock = pdata->pld_clock;
469 pld->dev = dev;
470
471 mutex_init(&pld->lock);
472 platform_set_drvdata(pdev, pld);
473
474 ret = kempld_detect_device(pld);
475 if (ret)
476 return ret;
477
478 return 0;
479}
480
481static int kempld_remove(struct platform_device *pdev)
482{
483 struct kempld_device_data *pld = platform_get_drvdata(pdev);
Jingoo Han334a41c2013-07-30 17:10:05 +0900484 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700485
Michael Brunner58a9e5b2014-04-08 08:21:06 +0200486 sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
487
Kevin Strasser43620a12013-06-23 21:00:03 -0700488 mfd_remove_devices(&pdev->dev);
489 pdata->release_hardware_mutex(pld);
490
491 return 0;
492}
493
494static struct platform_driver kempld_driver = {
495 .driver = {
496 .name = "kempld",
497 .owner = THIS_MODULE,
498 },
499 .probe = kempld_probe,
500 .remove = kempld_remove,
501};
502
Lee Jones9ef4e932014-07-21 16:47:51 +0100503static struct dmi_system_id kempld_dmi_table[] __initdata = {
Kevin Strasser43620a12013-06-23 21:00:03 -0700504 {
Michael Brunnerc1d33b12013-08-09 17:33:43 +0200505 .ident = "BHL6",
506 .matches = {
507 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
508 DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"),
509 },
510 .driver_data = (void *)&kempld_platform_data_generic,
511 .callback = kempld_create_platform_device,
512 },
513 {
Kevin Strasser43620a12013-06-23 21:00:03 -0700514 .ident = "CCR2",
515 .matches = {
516 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
517 DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP2"),
518 },
519 .driver_data = (void *)&kempld_platform_data_generic,
520 .callback = kempld_create_platform_device,
521 }, {
522 .ident = "CCR6",
523 .matches = {
524 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
525 DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP6"),
526 },
527 .driver_data = (void *)&kempld_platform_data_generic,
528 .callback = kempld_create_platform_device,
529 }, {
Michael Brunnera3ee7502014-02-24 08:53:46 +0100530 .ident = "CHL6",
531 .matches = {
532 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
533 DMI_MATCH(DMI_BOARD_NAME, "COMe-cHL6"),
534 },
535 .driver_data = (void *)&kempld_platform_data_generic,
536 .callback = kempld_create_platform_device,
537 }, {
Kevin Strasser43620a12013-06-23 21:00:03 -0700538 .ident = "CHR2",
539 .matches = {
540 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
541 DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T2"),
542 },
543 .driver_data = (void *)&kempld_platform_data_generic,
544 .callback = kempld_create_platform_device,
545 }, {
546 .ident = "CHR2",
547 .matches = {
548 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
549 DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T2"),
550 },
551 .driver_data = (void *)&kempld_platform_data_generic,
552 .callback = kempld_create_platform_device,
553 }, {
554 .ident = "CHR2",
555 .matches = {
556 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
557 DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC2"),
558 },
559 .driver_data = (void *)&kempld_platform_data_generic,
560 .callback = kempld_create_platform_device,
561 }, {
562 .ident = "CHR6",
563 .matches = {
564 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
565 DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T6"),
566 },
567 .driver_data = (void *)&kempld_platform_data_generic,
568 .callback = kempld_create_platform_device,
569 }, {
570 .ident = "CHR6",
571 .matches = {
572 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
573 DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T6"),
574 },
575 .driver_data = (void *)&kempld_platform_data_generic,
576 .callback = kempld_create_platform_device,
577 }, {
578 .ident = "CHR6",
579 .matches = {
580 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
581 DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC6"),
582 },
583 .driver_data = (void *)&kempld_platform_data_generic,
584 .callback = kempld_create_platform_device,
585 }, {
586 .ident = "CNTG",
587 .matches = {
588 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
589 DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-PC"),
590 },
591 .driver_data = (void *)&kempld_platform_data_generic,
592 .callback = kempld_create_platform_device,
593 }, {
594 .ident = "CNTG",
595 .matches = {
596 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
597 DMI_MATCH(DMI_BOARD_NAME, "COMe-bPC2"),
598 },
599 .driver_data = (void *)&kempld_platform_data_generic,
600 .callback = kempld_create_platform_device,
601 }, {
602 .ident = "CNTX",
603 .matches = {
604 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
605 DMI_MATCH(DMI_BOARD_NAME, "PXT"),
606 },
607 .driver_data = (void *)&kempld_platform_data_generic,
608 .callback = kempld_create_platform_device,
609 }, {
Michael Brunnera3ee7502014-02-24 08:53:46 +0100610 .ident = "CVV6",
611 .matches = {
612 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
613 DMI_MATCH(DMI_BOARD_NAME, "COMe-cBT"),
614 },
615 .driver_data = (void *)&kempld_platform_data_generic,
616 .callback = kempld_create_platform_device,
617 }, {
Kevin Strasser43620a12013-06-23 21:00:03 -0700618 .ident = "FRI2",
619 .matches = {
620 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
621 DMI_MATCH(DMI_BIOS_VERSION, "FRI2"),
622 },
623 .driver_data = (void *)&kempld_platform_data_generic,
624 .callback = kempld_create_platform_device,
625 }, {
626 .ident = "FRI2",
627 .matches = {
628 DMI_MATCH(DMI_PRODUCT_NAME, "Fish River Island II"),
629 },
630 .driver_data = (void *)&kempld_platform_data_generic,
631 .callback = kempld_create_platform_device,
632 }, {
633 .ident = "MBR1",
634 .matches = {
635 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
636 DMI_MATCH(DMI_BOARD_NAME, "ETX-OH"),
637 },
638 .driver_data = (void *)&kempld_platform_data_generic,
639 .callback = kempld_create_platform_device,
640 }, {
Michael Brunnera3ee7502014-02-24 08:53:46 +0100641 .ident = "MVV1",
642 .matches = {
643 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
644 DMI_MATCH(DMI_BOARD_NAME, "COMe-mBT"),
645 },
646 .driver_data = (void *)&kempld_platform_data_generic,
647 .callback = kempld_create_platform_device,
648 }, {
Kevin Strasser43620a12013-06-23 21:00:03 -0700649 .ident = "NTC1",
650 .matches = {
651 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
652 DMI_MATCH(DMI_BOARD_NAME, "nanoETXexpress-TT"),
653 },
654 .driver_data = (void *)&kempld_platform_data_generic,
655 .callback = kempld_create_platform_device,
656 }, {
657 .ident = "NTC1",
658 .matches = {
659 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
660 DMI_MATCH(DMI_BOARD_NAME, "nETXe-TT"),
661 },
662 .driver_data = (void *)&kempld_platform_data_generic,
663 .callback = kempld_create_platform_device,
664 }, {
665 .ident = "NTC1",
666 .matches = {
667 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
668 DMI_MATCH(DMI_BOARD_NAME, "COMe-mTT"),
669 },
670 .driver_data = (void *)&kempld_platform_data_generic,
671 .callback = kempld_create_platform_device,
672 }, {
673 .ident = "NUP1",
674 .matches = {
675 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
676 DMI_MATCH(DMI_BOARD_NAME, "COMe-mCT"),
677 },
678 .driver_data = (void *)&kempld_platform_data_generic,
679 .callback = kempld_create_platform_device,
680 }, {
681 .ident = "UNP1",
682 .matches = {
683 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
684 DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-DC"),
685 },
686 .driver_data = (void *)&kempld_platform_data_generic,
687 .callback = kempld_create_platform_device,
688 }, {
689 .ident = "UNP1",
690 .matches = {
691 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
692 DMI_MATCH(DMI_BOARD_NAME, "COMe-cDC2"),
693 },
694 .driver_data = (void *)&kempld_platform_data_generic,
695 .callback = kempld_create_platform_device,
696 }, {
697 .ident = "UNTG",
698 .matches = {
699 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
700 DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-PC"),
701 },
702 .driver_data = (void *)&kempld_platform_data_generic,
703 .callback = kempld_create_platform_device,
704 }, {
705 .ident = "UNTG",
706 .matches = {
707 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
708 DMI_MATCH(DMI_BOARD_NAME, "COMe-cPC2"),
709 },
710 .driver_data = (void *)&kempld_platform_data_generic,
711 .callback = kempld_create_platform_device,
712 }, {
713 .ident = "UUP6",
714 .matches = {
715 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
716 DMI_MATCH(DMI_BOARD_NAME, "COMe-cCT6"),
717 },
718 .driver_data = (void *)&kempld_platform_data_generic,
719 .callback = kempld_create_platform_device,
720 },
Michael Brunnerc1d33b12013-08-09 17:33:43 +0200721 {
722 .ident = "UTH6",
723 .matches = {
724 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
725 DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"),
726 },
727 .driver_data = (void *)&kempld_platform_data_generic,
728 .callback = kempld_create_platform_device,
729 },
Kevin Strasser43620a12013-06-23 21:00:03 -0700730 {}
731};
732MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
733
734static int __init kempld_init(void)
735{
736 const struct dmi_system_id *id;
737 int ret;
738
739 if (force_device_id[0]) {
Lee Jones9ef4e932014-07-21 16:47:51 +0100740 for (id = kempld_dmi_table;
741 id->matches[0].slot != DMI_NONE; id++)
Kevin Strasser43620a12013-06-23 21:00:03 -0700742 if (strstr(id->ident, force_device_id))
743 if (id->callback && id->callback(id))
744 break;
745 if (id->matches[0].slot == DMI_NONE)
746 return -ENODEV;
747 } else {
748 if (!dmi_check_system(kempld_dmi_table))
749 return -ENODEV;
750 }
751
752 ret = platform_driver_register(&kempld_driver);
753 if (ret)
754 return ret;
755
756 return 0;
757}
758
759static void __exit kempld_exit(void)
760{
761 if (kempld_pdev)
762 platform_device_unregister(kempld_pdev);
763
764 platform_driver_unregister(&kempld_driver);
765}
766
767module_init(kempld_init);
768module_exit(kempld_exit);
769
770MODULE_DESCRIPTION("KEM PLD Core Driver");
771MODULE_AUTHOR("Michael Brunner <michael.brunner@kontron.com>");
772MODULE_LICENSE("GPL");
773MODULE_ALIAS("platform:kempld-core");