kempld-core.c 20 KB

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