blob: 07692604e119123a1f9b311b2611c5d0103daa78 [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] = "";
27module_param_string(force_device_id, force_device_id, sizeof(force_device_id), 0);
28MODULE_PARM_DESC(force_device_id, "Override detected product");
29
30/*
31 * Get hardware mutex to block firmware from accessing the pld.
32 * It is possible for the firmware may hold the mutex for an extended length of
33 * time. This function will block until access has been granted.
34 */
35static void kempld_get_hardware_mutex(struct kempld_device_data *pld)
36{
37 /* The mutex bit will read 1 until access has been granted */
38 while (ioread8(pld->io_index) & KEMPLD_MUTEX_KEY)
39 msleep(1);
40}
41
42static void kempld_release_hardware_mutex(struct kempld_device_data *pld)
43{
44 /* The harware mutex is released when 1 is written to the mutex bit. */
45 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
46}
47
48static int kempld_get_info_generic(struct kempld_device_data *pld)
49{
50 u16 version;
51 u8 spec;
52
53 kempld_get_mutex(pld);
54
55 version = kempld_read16(pld, KEMPLD_VERSION);
56 spec = kempld_read8(pld, KEMPLD_SPEC);
57 pld->info.buildnr = kempld_read16(pld, KEMPLD_BUILDNR);
58
59 pld->info.minor = KEMPLD_VERSION_GET_MINOR(version);
60 pld->info.major = KEMPLD_VERSION_GET_MAJOR(version);
61 pld->info.number = KEMPLD_VERSION_GET_NUMBER(version);
62 pld->info.type = KEMPLD_VERSION_GET_TYPE(version);
63
64 if (spec == 0xff) {
65 pld->info.spec_minor = 0;
66 pld->info.spec_major = 1;
67 } else {
68 pld->info.spec_minor = KEMPLD_SPEC_GET_MINOR(spec);
69 pld->info.spec_major = KEMPLD_SPEC_GET_MAJOR(spec);
70 }
71
72 if (pld->info.spec_major > 0)
73 pld->feature_mask = kempld_read16(pld, KEMPLD_FEATURE);
74 else
75 pld->feature_mask = 0;
76
77 kempld_release_mutex(pld);
78
79 return 0;
80}
81
82enum kempld_cells {
83 KEMPLD_I2C = 0,
84 KEMPLD_WDT,
85 KEMPLD_GPIO,
86 KEMPLD_UART,
87};
88
89static struct mfd_cell kempld_devs[] = {
90 [KEMPLD_I2C] = {
91 .name = "kempld-i2c",
92 },
93 [KEMPLD_WDT] = {
94 .name = "kempld-wdt",
95 },
96 [KEMPLD_GPIO] = {
97 .name = "kempld-gpio",
98 },
99 [KEMPLD_UART] = {
100 .name = "kempld-uart",
101 },
102};
103
104#define KEMPLD_MAX_DEVS ARRAY_SIZE(kempld_devs)
105
106static int kempld_register_cells_generic(struct kempld_device_data *pld)
107{
108 struct mfd_cell devs[KEMPLD_MAX_DEVS];
109 int i = 0;
110
111 if (pld->feature_mask & KEMPLD_FEATURE_BIT_I2C)
112 devs[i++] = kempld_devs[KEMPLD_I2C];
113
114 if (pld->feature_mask & KEMPLD_FEATURE_BIT_WATCHDOG)
115 devs[i++] = kempld_devs[KEMPLD_WDT];
116
117 if (pld->feature_mask & KEMPLD_FEATURE_BIT_GPIO)
118 devs[i++] = kempld_devs[KEMPLD_GPIO];
119
120 if (pld->feature_mask & KEMPLD_FEATURE_MASK_UART)
121 devs[i++] = kempld_devs[KEMPLD_UART];
122
123 return mfd_add_devices(pld->dev, -1, devs, i, NULL, 0, NULL);
124}
125
126static struct resource kempld_ioresource = {
127 .start = KEMPLD_IOINDEX,
128 .end = KEMPLD_IODATA,
129 .flags = IORESOURCE_IO,
130};
131
132static const struct kempld_platform_data kempld_platform_data_generic = {
133 .pld_clock = KEMPLD_CLK,
134 .ioresource = &kempld_ioresource,
135 .get_hardware_mutex = kempld_get_hardware_mutex,
136 .release_hardware_mutex = kempld_release_hardware_mutex,
137 .get_info = kempld_get_info_generic,
138 .register_cells = kempld_register_cells_generic,
139};
140
141static struct platform_device *kempld_pdev;
142
143static int kempld_create_platform_device(const struct dmi_system_id *id)
144{
145 struct kempld_platform_data *pdata = id->driver_data;
146 int ret;
147
148 kempld_pdev = platform_device_alloc("kempld", -1);
149 if (!kempld_pdev)
150 return -ENOMEM;
151
152 ret = platform_device_add_data(kempld_pdev, pdata, sizeof(*pdata));
153 if (ret)
154 goto err;
155
156 ret = platform_device_add_resources(kempld_pdev, pdata->ioresource, 1);
157 if (ret)
158 goto err;
159
160 ret = platform_device_add(kempld_pdev);
161 if (ret)
162 goto err;
163
164 return 0;
165err:
166 platform_device_put(kempld_pdev);
167 return ret;
168}
169
170/**
171 * kempld_read8 - read 8 bit register
172 * @pld: kempld_device_data structure describing the PLD
173 * @index: register index on the chip
174 *
175 * kempld_get_mutex must be called prior to calling this function.
176 */
177u8 kempld_read8(struct kempld_device_data *pld, u8 index)
178{
179 iowrite8(index, pld->io_index);
180 return ioread8(pld->io_data);
181}
182EXPORT_SYMBOL_GPL(kempld_read8);
183
184/**
185 * kempld_write8 - write 8 bit register
186 * @pld: kempld_device_data structure describing the PLD
187 * @index: register index on the chip
188 * @data: new register value
189 *
190 * kempld_get_mutex must be called prior to calling this function.
191 */
192void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data)
193{
194 iowrite8(index, pld->io_index);
195 iowrite8(data, pld->io_data);
196}
197EXPORT_SYMBOL_GPL(kempld_write8);
198
199/**
200 * kempld_read16 - read 16 bit register
201 * @pld: kempld_device_data structure describing the PLD
202 * @index: register index on the chip
203 *
204 * kempld_get_mutex must be called prior to calling this function.
205 */
206u16 kempld_read16(struct kempld_device_data *pld, u8 index)
207{
208 return kempld_read8(pld, index) | kempld_read8(pld, index + 1) << 8;
209}
210EXPORT_SYMBOL_GPL(kempld_read16);
211
212/**
213 * kempld_write16 - write 16 bit register
214 * @pld: kempld_device_data structure describing the PLD
215 * @index: register index on the chip
216 * @data: new register value
217 *
218 * kempld_get_mutex must be called prior to calling this function.
219 */
220void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data)
221{
222 kempld_write8(pld, index, (u8)data);
223 kempld_write8(pld, index + 1, (u8)(data >> 8));
224}
225EXPORT_SYMBOL_GPL(kempld_write16);
226
227/**
228 * kempld_read32 - read 32 bit register
229 * @pld: kempld_device_data structure describing the PLD
230 * @index: register index on the chip
231 *
232 * kempld_get_mutex must be called prior to calling this function.
233 */
234u32 kempld_read32(struct kempld_device_data *pld, u8 index)
235{
236 return kempld_read16(pld, index) | kempld_read16(pld, index + 2) << 16;
237}
238EXPORT_SYMBOL_GPL(kempld_read32);
239
240/**
241 * kempld_write32 - write 32 bit register
242 * @pld: kempld_device_data structure describing the PLD
243 * @index: register index on the chip
244 * @data: new register value
245 *
246 * kempld_get_mutex must be called prior to calling this function.
247 */
248void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data)
249{
250 kempld_write16(pld, index, (u16)data);
251 kempld_write16(pld, index + 2, (u16)(data >> 16));
252}
253EXPORT_SYMBOL_GPL(kempld_write32);
254
255/**
256 * kempld_get_mutex - acquire PLD mutex
257 * @pld: kempld_device_data structure describing the PLD
258 */
259void kempld_get_mutex(struct kempld_device_data *pld)
260{
Jingoo Han334a41c2013-07-30 17:10:05 +0900261 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700262
263 mutex_lock(&pld->lock);
264 pdata->get_hardware_mutex(pld);
265}
266EXPORT_SYMBOL_GPL(kempld_get_mutex);
267
268/**
269 * kempld_release_mutex - release PLD mutex
270 * @pld: kempld_device_data structure describing the PLD
271 */
272void kempld_release_mutex(struct kempld_device_data *pld)
273{
Jingoo Han334a41c2013-07-30 17:10:05 +0900274 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700275
276 pdata->release_hardware_mutex(pld);
277 mutex_unlock(&pld->lock);
278}
279EXPORT_SYMBOL_GPL(kempld_release_mutex);
280
281/**
282 * kempld_get_info - update device specific information
283 * @pld: kempld_device_data structure describing the PLD
284 *
285 * This function calls the configured board specific kempld_get_info_XXXX
286 * function which is responsible for gathering information about the specific
287 * hardware. The information is then stored within the pld structure.
288 */
289static int kempld_get_info(struct kempld_device_data *pld)
290{
Jingoo Han334a41c2013-07-30 17:10:05 +0900291 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700292
293 return pdata->get_info(pld);
294}
295
296/*
297 * kempld_register_cells - register cell drivers
298 *
299 * This function registers cell drivers for the detected hardware by calling
300 * the configured kempld_register_cells_XXXX function which is responsible
301 * to detect and register the needed cell drivers.
302 */
303static int kempld_register_cells(struct kempld_device_data *pld)
304{
Jingoo Han334a41c2013-07-30 17:10:05 +0900305 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700306
307 return pdata->register_cells(pld);
308}
309
310static int kempld_detect_device(struct kempld_device_data *pld)
311{
312 char *version_type;
313 u8 index_reg;
314 int ret;
315
316 mutex_lock(&pld->lock);
317
318 /* Check for empty IO space */
319 index_reg = ioread8(pld->io_index);
320 if (index_reg == 0xff && ioread8(pld->io_data) == 0xff) {
321 mutex_unlock(&pld->lock);
322 return -ENODEV;
323 }
324
Guenter Roeck204747c2014-03-20 08:12:28 -0700325 /* Release hardware mutex if acquired */
326 if (!(index_reg & KEMPLD_MUTEX_KEY)) {
Kevin Strasser43620a12013-06-23 21:00:03 -0700327 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
Guenter Roeck204747c2014-03-20 08:12:28 -0700328 /* PXT and COMe-cPC2 boards may require a second release */
329 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
330 }
Kevin Strasser43620a12013-06-23 21:00:03 -0700331
332 mutex_unlock(&pld->lock);
333
334 ret = kempld_get_info(pld);
335 if (ret)
336 return ret;
337
338 switch (pld->info.type) {
339 case 0:
340 version_type = "release";
341 break;
342 case 1:
343 version_type = "debug";
344 break;
345 case 2:
346 version_type = "custom";
347 break;
348 default:
349 version_type = "unspecified";
350 }
351
352 dev_info(pld->dev, "Found Kontron PLD %d\n", pld->info.number);
353 dev_info(pld->dev, "%s version %d.%d build %d, specification %d.%d\n",
354 version_type, pld->info.major, pld->info.minor,
355 pld->info.buildnr, pld->info.spec_major,
356 pld->info.spec_minor);
357
358 return kempld_register_cells(pld);
359}
360
361static int kempld_probe(struct platform_device *pdev)
362{
Jingoo Han334a41c2013-07-30 17:10:05 +0900363 struct kempld_platform_data *pdata = dev_get_platdata(&pdev->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700364 struct device *dev = &pdev->dev;
365 struct kempld_device_data *pld;
366 struct resource *ioport;
367 int ret;
368
369 pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
370 if (!pld)
371 return -ENOMEM;
372
373 ioport = platform_get_resource(pdev, IORESOURCE_IO, 0);
374 if (!ioport)
375 return -EINVAL;
376
377 pld->io_base = devm_ioport_map(dev, ioport->start,
378 ioport->end - ioport->start);
379 if (!pld->io_base)
380 return -ENOMEM;
381
382 pld->io_index = pld->io_base;
383 pld->io_data = pld->io_base + 1;
384 pld->pld_clock = pdata->pld_clock;
385 pld->dev = dev;
386
387 mutex_init(&pld->lock);
388 platform_set_drvdata(pdev, pld);
389
390 ret = kempld_detect_device(pld);
391 if (ret)
392 return ret;
393
394 return 0;
395}
396
397static int kempld_remove(struct platform_device *pdev)
398{
399 struct kempld_device_data *pld = platform_get_drvdata(pdev);
Jingoo Han334a41c2013-07-30 17:10:05 +0900400 struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
Kevin Strasser43620a12013-06-23 21:00:03 -0700401
402 mfd_remove_devices(&pdev->dev);
403 pdata->release_hardware_mutex(pld);
404
405 return 0;
406}
407
408static struct platform_driver kempld_driver = {
409 .driver = {
410 .name = "kempld",
411 .owner = THIS_MODULE,
412 },
413 .probe = kempld_probe,
414 .remove = kempld_remove,
415};
416
417static struct dmi_system_id __initdata kempld_dmi_table[] = {
418 {
Michael Brunnerc1d33b12013-08-09 17:33:43 +0200419 .ident = "BHL6",
420 .matches = {
421 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
422 DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"),
423 },
424 .driver_data = (void *)&kempld_platform_data_generic,
425 .callback = kempld_create_platform_device,
426 },
427 {
Kevin Strasser43620a12013-06-23 21:00:03 -0700428 .ident = "CCR2",
429 .matches = {
430 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
431 DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP2"),
432 },
433 .driver_data = (void *)&kempld_platform_data_generic,
434 .callback = kempld_create_platform_device,
435 }, {
436 .ident = "CCR6",
437 .matches = {
438 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
439 DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP6"),
440 },
441 .driver_data = (void *)&kempld_platform_data_generic,
442 .callback = kempld_create_platform_device,
443 }, {
Michael Brunnera3ee7502014-02-24 08:53:46 +0100444 .ident = "CHL6",
445 .matches = {
446 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
447 DMI_MATCH(DMI_BOARD_NAME, "COMe-cHL6"),
448 },
449 .driver_data = (void *)&kempld_platform_data_generic,
450 .callback = kempld_create_platform_device,
451 }, {
Kevin Strasser43620a12013-06-23 21:00:03 -0700452 .ident = "CHR2",
453 .matches = {
454 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
455 DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T2"),
456 },
457 .driver_data = (void *)&kempld_platform_data_generic,
458 .callback = kempld_create_platform_device,
459 }, {
460 .ident = "CHR2",
461 .matches = {
462 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
463 DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T2"),
464 },
465 .driver_data = (void *)&kempld_platform_data_generic,
466 .callback = kempld_create_platform_device,
467 }, {
468 .ident = "CHR2",
469 .matches = {
470 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
471 DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC2"),
472 },
473 .driver_data = (void *)&kempld_platform_data_generic,
474 .callback = kempld_create_platform_device,
475 }, {
476 .ident = "CHR6",
477 .matches = {
478 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
479 DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T6"),
480 },
481 .driver_data = (void *)&kempld_platform_data_generic,
482 .callback = kempld_create_platform_device,
483 }, {
484 .ident = "CHR6",
485 .matches = {
486 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
487 DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T6"),
488 },
489 .driver_data = (void *)&kempld_platform_data_generic,
490 .callback = kempld_create_platform_device,
491 }, {
492 .ident = "CHR6",
493 .matches = {
494 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
495 DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC6"),
496 },
497 .driver_data = (void *)&kempld_platform_data_generic,
498 .callback = kempld_create_platform_device,
499 }, {
500 .ident = "CNTG",
501 .matches = {
502 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
503 DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-PC"),
504 },
505 .driver_data = (void *)&kempld_platform_data_generic,
506 .callback = kempld_create_platform_device,
507 }, {
508 .ident = "CNTG",
509 .matches = {
510 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
511 DMI_MATCH(DMI_BOARD_NAME, "COMe-bPC2"),
512 },
513 .driver_data = (void *)&kempld_platform_data_generic,
514 .callback = kempld_create_platform_device,
515 }, {
516 .ident = "CNTX",
517 .matches = {
518 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
519 DMI_MATCH(DMI_BOARD_NAME, "PXT"),
520 },
521 .driver_data = (void *)&kempld_platform_data_generic,
522 .callback = kempld_create_platform_device,
523 }, {
Michael Brunnera3ee7502014-02-24 08:53:46 +0100524 .ident = "CVV6",
525 .matches = {
526 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
527 DMI_MATCH(DMI_BOARD_NAME, "COMe-cBT"),
528 },
529 .driver_data = (void *)&kempld_platform_data_generic,
530 .callback = kempld_create_platform_device,
531 }, {
Kevin Strasser43620a12013-06-23 21:00:03 -0700532 .ident = "FRI2",
533 .matches = {
534 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
535 DMI_MATCH(DMI_BIOS_VERSION, "FRI2"),
536 },
537 .driver_data = (void *)&kempld_platform_data_generic,
538 .callback = kempld_create_platform_device,
539 }, {
540 .ident = "FRI2",
541 .matches = {
542 DMI_MATCH(DMI_PRODUCT_NAME, "Fish River Island II"),
543 },
544 .driver_data = (void *)&kempld_platform_data_generic,
545 .callback = kempld_create_platform_device,
546 }, {
547 .ident = "MBR1",
548 .matches = {
549 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
550 DMI_MATCH(DMI_BOARD_NAME, "ETX-OH"),
551 },
552 .driver_data = (void *)&kempld_platform_data_generic,
553 .callback = kempld_create_platform_device,
554 }, {
Michael Brunnera3ee7502014-02-24 08:53:46 +0100555 .ident = "MVV1",
556 .matches = {
557 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
558 DMI_MATCH(DMI_BOARD_NAME, "COMe-mBT"),
559 },
560 .driver_data = (void *)&kempld_platform_data_generic,
561 .callback = kempld_create_platform_device,
562 }, {
Kevin Strasser43620a12013-06-23 21:00:03 -0700563 .ident = "NTC1",
564 .matches = {
565 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
566 DMI_MATCH(DMI_BOARD_NAME, "nanoETXexpress-TT"),
567 },
568 .driver_data = (void *)&kempld_platform_data_generic,
569 .callback = kempld_create_platform_device,
570 }, {
571 .ident = "NTC1",
572 .matches = {
573 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
574 DMI_MATCH(DMI_BOARD_NAME, "nETXe-TT"),
575 },
576 .driver_data = (void *)&kempld_platform_data_generic,
577 .callback = kempld_create_platform_device,
578 }, {
579 .ident = "NTC1",
580 .matches = {
581 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
582 DMI_MATCH(DMI_BOARD_NAME, "COMe-mTT"),
583 },
584 .driver_data = (void *)&kempld_platform_data_generic,
585 .callback = kempld_create_platform_device,
586 }, {
587 .ident = "NUP1",
588 .matches = {
589 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
590 DMI_MATCH(DMI_BOARD_NAME, "COMe-mCT"),
591 },
592 .driver_data = (void *)&kempld_platform_data_generic,
593 .callback = kempld_create_platform_device,
594 }, {
595 .ident = "UNP1",
596 .matches = {
597 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
598 DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-DC"),
599 },
600 .driver_data = (void *)&kempld_platform_data_generic,
601 .callback = kempld_create_platform_device,
602 }, {
603 .ident = "UNP1",
604 .matches = {
605 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
606 DMI_MATCH(DMI_BOARD_NAME, "COMe-cDC2"),
607 },
608 .driver_data = (void *)&kempld_platform_data_generic,
609 .callback = kempld_create_platform_device,
610 }, {
611 .ident = "UNTG",
612 .matches = {
613 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
614 DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-PC"),
615 },
616 .driver_data = (void *)&kempld_platform_data_generic,
617 .callback = kempld_create_platform_device,
618 }, {
619 .ident = "UNTG",
620 .matches = {
621 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
622 DMI_MATCH(DMI_BOARD_NAME, "COMe-cPC2"),
623 },
624 .driver_data = (void *)&kempld_platform_data_generic,
625 .callback = kempld_create_platform_device,
626 }, {
627 .ident = "UUP6",
628 .matches = {
629 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
630 DMI_MATCH(DMI_BOARD_NAME, "COMe-cCT6"),
631 },
632 .driver_data = (void *)&kempld_platform_data_generic,
633 .callback = kempld_create_platform_device,
634 },
Michael Brunnerc1d33b12013-08-09 17:33:43 +0200635 {
636 .ident = "UTH6",
637 .matches = {
638 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
639 DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"),
640 },
641 .driver_data = (void *)&kempld_platform_data_generic,
642 .callback = kempld_create_platform_device,
643 },
Kevin Strasser43620a12013-06-23 21:00:03 -0700644 {}
645};
646MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
647
648static int __init kempld_init(void)
649{
650 const struct dmi_system_id *id;
651 int ret;
652
653 if (force_device_id[0]) {
654 for (id = kempld_dmi_table; id->matches[0].slot != DMI_NONE; id++)
655 if (strstr(id->ident, force_device_id))
656 if (id->callback && id->callback(id))
657 break;
658 if (id->matches[0].slot == DMI_NONE)
659 return -ENODEV;
660 } else {
661 if (!dmi_check_system(kempld_dmi_table))
662 return -ENODEV;
663 }
664
665 ret = platform_driver_register(&kempld_driver);
666 if (ret)
667 return ret;
668
669 return 0;
670}
671
672static void __exit kempld_exit(void)
673{
674 if (kempld_pdev)
675 platform_device_unregister(kempld_pdev);
676
677 platform_driver_unregister(&kempld_driver);
678}
679
680module_init(kempld_init);
681module_exit(kempld_exit);
682
683MODULE_DESCRIPTION("KEM PLD Core Driver");
684MODULE_AUTHOR("Michael Brunner <michael.brunner@kontron.com>");
685MODULE_LICENSE("GPL");
686MODULE_ALIAS("platform:kempld-core");