kempld-core.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  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,
  26. sizeof(force_device_id), 0);
  27. MODULE_PARM_DESC(force_device_id, "Override detected product");
  28. /*
  29. * Get hardware mutex to block firmware from accessing the pld.
  30. * It is possible for the firmware may hold the mutex for an extended length of
  31. * time. This function will block until access has been granted.
  32. */
  33. static void kempld_get_hardware_mutex(struct kempld_device_data *pld)
  34. {
  35. /* The mutex bit will read 1 until access has been granted */
  36. while (ioread8(pld->io_index) & KEMPLD_MUTEX_KEY)
  37. usleep_range(1000, 3000);
  38. }
  39. static void kempld_release_hardware_mutex(struct kempld_device_data *pld)
  40. {
  41. /* The harware mutex is released when 1 is written to the mutex bit. */
  42. iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
  43. }
  44. static int kempld_get_info_generic(struct kempld_device_data *pld)
  45. {
  46. u16 version;
  47. u8 spec;
  48. kempld_get_mutex(pld);
  49. version = kempld_read16(pld, KEMPLD_VERSION);
  50. spec = kempld_read8(pld, KEMPLD_SPEC);
  51. pld->info.buildnr = kempld_read16(pld, KEMPLD_BUILDNR);
  52. pld->info.minor = KEMPLD_VERSION_GET_MINOR(version);
  53. pld->info.major = KEMPLD_VERSION_GET_MAJOR(version);
  54. pld->info.number = KEMPLD_VERSION_GET_NUMBER(version);
  55. pld->info.type = KEMPLD_VERSION_GET_TYPE(version);
  56. if (spec == 0xff) {
  57. pld->info.spec_minor = 0;
  58. pld->info.spec_major = 1;
  59. } else {
  60. pld->info.spec_minor = KEMPLD_SPEC_GET_MINOR(spec);
  61. pld->info.spec_major = KEMPLD_SPEC_GET_MAJOR(spec);
  62. }
  63. if (pld->info.spec_major > 0)
  64. pld->feature_mask = kempld_read16(pld, KEMPLD_FEATURE);
  65. else
  66. pld->feature_mask = 0;
  67. kempld_release_mutex(pld);
  68. return 0;
  69. }
  70. enum kempld_cells {
  71. KEMPLD_I2C = 0,
  72. KEMPLD_WDT,
  73. KEMPLD_GPIO,
  74. KEMPLD_UART,
  75. };
  76. static const struct mfd_cell kempld_devs[] = {
  77. [KEMPLD_I2C] = {
  78. .name = "kempld-i2c",
  79. },
  80. [KEMPLD_WDT] = {
  81. .name = "kempld-wdt",
  82. },
  83. [KEMPLD_GPIO] = {
  84. .name = "kempld-gpio",
  85. },
  86. [KEMPLD_UART] = {
  87. .name = "kempld-uart",
  88. },
  89. };
  90. #define KEMPLD_MAX_DEVS ARRAY_SIZE(kempld_devs)
  91. static int kempld_register_cells_generic(struct kempld_device_data *pld)
  92. {
  93. struct mfd_cell devs[KEMPLD_MAX_DEVS];
  94. int i = 0;
  95. if (pld->feature_mask & KEMPLD_FEATURE_BIT_I2C)
  96. devs[i++] = kempld_devs[KEMPLD_I2C];
  97. if (pld->feature_mask & KEMPLD_FEATURE_BIT_WATCHDOG)
  98. devs[i++] = kempld_devs[KEMPLD_WDT];
  99. if (pld->feature_mask & KEMPLD_FEATURE_BIT_GPIO)
  100. devs[i++] = kempld_devs[KEMPLD_GPIO];
  101. if (pld->feature_mask & KEMPLD_FEATURE_MASK_UART)
  102. devs[i++] = kempld_devs[KEMPLD_UART];
  103. return mfd_add_devices(pld->dev, -1, devs, i, NULL, 0, NULL);
  104. }
  105. static struct resource kempld_ioresource = {
  106. .start = KEMPLD_IOINDEX,
  107. .end = KEMPLD_IODATA,
  108. .flags = IORESOURCE_IO,
  109. };
  110. static const struct kempld_platform_data kempld_platform_data_generic = {
  111. .pld_clock = KEMPLD_CLK,
  112. .ioresource = &kempld_ioresource,
  113. .get_hardware_mutex = kempld_get_hardware_mutex,
  114. .release_hardware_mutex = kempld_release_hardware_mutex,
  115. .get_info = kempld_get_info_generic,
  116. .register_cells = kempld_register_cells_generic,
  117. };
  118. static struct platform_device *kempld_pdev;
  119. static int kempld_create_platform_device(const struct dmi_system_id *id)
  120. {
  121. struct kempld_platform_data *pdata = id->driver_data;
  122. int ret;
  123. kempld_pdev = platform_device_alloc("kempld", -1);
  124. if (!kempld_pdev)
  125. return -ENOMEM;
  126. ret = platform_device_add_data(kempld_pdev, pdata, sizeof(*pdata));
  127. if (ret)
  128. goto err;
  129. ret = platform_device_add_resources(kempld_pdev, pdata->ioresource, 1);
  130. if (ret)
  131. goto err;
  132. ret = platform_device_add(kempld_pdev);
  133. if (ret)
  134. goto err;
  135. return 0;
  136. err:
  137. platform_device_put(kempld_pdev);
  138. return ret;
  139. }
  140. /**
  141. * kempld_read8 - read 8 bit register
  142. * @pld: kempld_device_data structure describing the PLD
  143. * @index: register index on the chip
  144. *
  145. * kempld_get_mutex must be called prior to calling this function.
  146. */
  147. u8 kempld_read8(struct kempld_device_data *pld, u8 index)
  148. {
  149. iowrite8(index, pld->io_index);
  150. return ioread8(pld->io_data);
  151. }
  152. EXPORT_SYMBOL_GPL(kempld_read8);
  153. /**
  154. * kempld_write8 - write 8 bit register
  155. * @pld: kempld_device_data structure describing the PLD
  156. * @index: register index on the chip
  157. * @data: new register value
  158. *
  159. * kempld_get_mutex must be called prior to calling this function.
  160. */
  161. void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data)
  162. {
  163. iowrite8(index, pld->io_index);
  164. iowrite8(data, pld->io_data);
  165. }
  166. EXPORT_SYMBOL_GPL(kempld_write8);
  167. /**
  168. * kempld_read16 - read 16 bit register
  169. * @pld: kempld_device_data structure describing the PLD
  170. * @index: register index on the chip
  171. *
  172. * kempld_get_mutex must be called prior to calling this function.
  173. */
  174. u16 kempld_read16(struct kempld_device_data *pld, u8 index)
  175. {
  176. return kempld_read8(pld, index) | kempld_read8(pld, index + 1) << 8;
  177. }
  178. EXPORT_SYMBOL_GPL(kempld_read16);
  179. /**
  180. * kempld_write16 - write 16 bit register
  181. * @pld: kempld_device_data structure describing the PLD
  182. * @index: register index on the chip
  183. * @data: new register value
  184. *
  185. * kempld_get_mutex must be called prior to calling this function.
  186. */
  187. void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data)
  188. {
  189. kempld_write8(pld, index, (u8)data);
  190. kempld_write8(pld, index + 1, (u8)(data >> 8));
  191. }
  192. EXPORT_SYMBOL_GPL(kempld_write16);
  193. /**
  194. * kempld_read32 - read 32 bit register
  195. * @pld: kempld_device_data structure describing the PLD
  196. * @index: register index on the chip
  197. *
  198. * kempld_get_mutex must be called prior to calling this function.
  199. */
  200. u32 kempld_read32(struct kempld_device_data *pld, u8 index)
  201. {
  202. return kempld_read16(pld, index) | kempld_read16(pld, index + 2) << 16;
  203. }
  204. EXPORT_SYMBOL_GPL(kempld_read32);
  205. /**
  206. * kempld_write32 - write 32 bit register
  207. * @pld: kempld_device_data structure describing the PLD
  208. * @index: register index on the chip
  209. * @data: new register value
  210. *
  211. * kempld_get_mutex must be called prior to calling this function.
  212. */
  213. void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data)
  214. {
  215. kempld_write16(pld, index, (u16)data);
  216. kempld_write16(pld, index + 2, (u16)(data >> 16));
  217. }
  218. EXPORT_SYMBOL_GPL(kempld_write32);
  219. /**
  220. * kempld_get_mutex - acquire PLD mutex
  221. * @pld: kempld_device_data structure describing the PLD
  222. */
  223. void kempld_get_mutex(struct kempld_device_data *pld)
  224. {
  225. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  226. mutex_lock(&pld->lock);
  227. pdata->get_hardware_mutex(pld);
  228. }
  229. EXPORT_SYMBOL_GPL(kempld_get_mutex);
  230. /**
  231. * kempld_release_mutex - release PLD mutex
  232. * @pld: kempld_device_data structure describing the PLD
  233. */
  234. void kempld_release_mutex(struct kempld_device_data *pld)
  235. {
  236. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  237. pdata->release_hardware_mutex(pld);
  238. mutex_unlock(&pld->lock);
  239. }
  240. EXPORT_SYMBOL_GPL(kempld_release_mutex);
  241. /**
  242. * kempld_get_info - update device specific information
  243. * @pld: kempld_device_data structure describing the PLD
  244. *
  245. * This function calls the configured board specific kempld_get_info_XXXX
  246. * function which is responsible for gathering information about the specific
  247. * hardware. The information is then stored within the pld structure.
  248. */
  249. static int kempld_get_info(struct kempld_device_data *pld)
  250. {
  251. int ret;
  252. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  253. char major, minor;
  254. ret = pdata->get_info(pld);
  255. if (ret)
  256. return ret;
  257. /* The Kontron PLD firmware version string has the following format:
  258. * Pwxy.zzzz
  259. * P: Fixed
  260. * w: PLD number - 1 hex digit
  261. * x: Major version - 1 alphanumerical digit (0-9A-V)
  262. * y: Minor version - 1 alphanumerical digit (0-9A-V)
  263. * zzzz: Build number - 4 zero padded hex digits */
  264. if (pld->info.major < 10)
  265. major = pld->info.major + '0';
  266. else
  267. major = (pld->info.major - 10) + 'A';
  268. if (pld->info.minor < 10)
  269. minor = pld->info.minor + '0';
  270. else
  271. minor = (pld->info.minor - 10) + 'A';
  272. ret = scnprintf(pld->info.version, sizeof(pld->info.version),
  273. "P%X%c%c.%04X", pld->info.number, major, minor,
  274. pld->info.buildnr);
  275. if (ret < 0)
  276. return ret;
  277. return 0;
  278. }
  279. /*
  280. * kempld_register_cells - register cell drivers
  281. *
  282. * This function registers cell drivers for the detected hardware by calling
  283. * the configured kempld_register_cells_XXXX function which is responsible
  284. * to detect and register the needed cell drivers.
  285. */
  286. static int kempld_register_cells(struct kempld_device_data *pld)
  287. {
  288. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  289. return pdata->register_cells(pld);
  290. }
  291. static const char *kempld_get_type_string(struct kempld_device_data *pld)
  292. {
  293. const char *version_type;
  294. switch (pld->info.type) {
  295. case 0:
  296. version_type = "release";
  297. break;
  298. case 1:
  299. version_type = "debug";
  300. break;
  301. case 2:
  302. version_type = "custom";
  303. break;
  304. default:
  305. version_type = "unspecified";
  306. break;
  307. }
  308. return version_type;
  309. }
  310. static ssize_t kempld_version_show(struct device *dev,
  311. struct device_attribute *attr, char *buf)
  312. {
  313. struct kempld_device_data *pld = dev_get_drvdata(dev);
  314. return scnprintf(buf, PAGE_SIZE, "%s\n", pld->info.version);
  315. }
  316. static ssize_t kempld_specification_show(struct device *dev,
  317. struct device_attribute *attr, char *buf)
  318. {
  319. struct kempld_device_data *pld = dev_get_drvdata(dev);
  320. return scnprintf(buf, PAGE_SIZE, "%d.%d\n", pld->info.spec_major,
  321. pld->info.spec_minor);
  322. }
  323. static ssize_t kempld_type_show(struct device *dev,
  324. struct device_attribute *attr, char *buf)
  325. {
  326. struct kempld_device_data *pld = dev_get_drvdata(dev);
  327. return scnprintf(buf, PAGE_SIZE, "%s\n", kempld_get_type_string(pld));
  328. }
  329. static DEVICE_ATTR(pld_version, S_IRUGO, kempld_version_show, NULL);
  330. static DEVICE_ATTR(pld_specification, S_IRUGO, kempld_specification_show,
  331. NULL);
  332. static DEVICE_ATTR(pld_type, S_IRUGO, kempld_type_show, NULL);
  333. static struct attribute *pld_attributes[] = {
  334. &dev_attr_pld_version.attr,
  335. &dev_attr_pld_specification.attr,
  336. &dev_attr_pld_type.attr,
  337. NULL
  338. };
  339. static const struct attribute_group pld_attr_group = {
  340. .attrs = pld_attributes,
  341. };
  342. static int kempld_detect_device(struct kempld_device_data *pld)
  343. {
  344. u8 index_reg;
  345. int ret;
  346. mutex_lock(&pld->lock);
  347. /* Check for empty IO space */
  348. index_reg = ioread8(pld->io_index);
  349. if (index_reg == 0xff && ioread8(pld->io_data) == 0xff) {
  350. mutex_unlock(&pld->lock);
  351. return -ENODEV;
  352. }
  353. /* Release hardware mutex if acquired */
  354. if (!(index_reg & KEMPLD_MUTEX_KEY)) {
  355. iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
  356. /* PXT and COMe-cPC2 boards may require a second release */
  357. iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
  358. }
  359. mutex_unlock(&pld->lock);
  360. ret = kempld_get_info(pld);
  361. if (ret)
  362. return ret;
  363. dev_info(pld->dev, "Found Kontron PLD - %s (%s), spec %d.%d\n",
  364. pld->info.version, kempld_get_type_string(pld),
  365. pld->info.spec_major, pld->info.spec_minor);
  366. ret = sysfs_create_group(&pld->dev->kobj, &pld_attr_group);
  367. if (ret)
  368. return ret;
  369. ret = kempld_register_cells(pld);
  370. if (ret)
  371. sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
  372. return ret;
  373. }
  374. static int kempld_probe(struct platform_device *pdev)
  375. {
  376. struct kempld_platform_data *pdata = dev_get_platdata(&pdev->dev);
  377. struct device *dev = &pdev->dev;
  378. struct kempld_device_data *pld;
  379. struct resource *ioport;
  380. int ret;
  381. pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
  382. if (!pld)
  383. return -ENOMEM;
  384. ioport = platform_get_resource(pdev, IORESOURCE_IO, 0);
  385. if (!ioport)
  386. return -EINVAL;
  387. pld->io_base = devm_ioport_map(dev, ioport->start,
  388. ioport->end - ioport->start);
  389. if (!pld->io_base)
  390. return -ENOMEM;
  391. pld->io_index = pld->io_base;
  392. pld->io_data = pld->io_base + 1;
  393. pld->pld_clock = pdata->pld_clock;
  394. pld->dev = dev;
  395. mutex_init(&pld->lock);
  396. platform_set_drvdata(pdev, pld);
  397. ret = kempld_detect_device(pld);
  398. if (ret)
  399. return ret;
  400. return 0;
  401. }
  402. static int kempld_remove(struct platform_device *pdev)
  403. {
  404. struct kempld_device_data *pld = platform_get_drvdata(pdev);
  405. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  406. sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
  407. mfd_remove_devices(&pdev->dev);
  408. pdata->release_hardware_mutex(pld);
  409. return 0;
  410. }
  411. static struct platform_driver kempld_driver = {
  412. .driver = {
  413. .name = "kempld",
  414. },
  415. .probe = kempld_probe,
  416. .remove = kempld_remove,
  417. };
  418. static struct dmi_system_id kempld_dmi_table[] __initdata = {
  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;
  654. 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. ret = platform_driver_register(&kempld_driver);
  665. if (ret)
  666. return ret;
  667. return 0;
  668. }
  669. static void __exit kempld_exit(void)
  670. {
  671. if (kempld_pdev)
  672. platform_device_unregister(kempld_pdev);
  673. platform_driver_unregister(&kempld_driver);
  674. }
  675. module_init(kempld_init);
  676. module_exit(kempld_exit);
  677. MODULE_DESCRIPTION("KEM PLD Core Driver");
  678. MODULE_AUTHOR("Michael Brunner <michael.brunner@kontron.com>");
  679. MODULE_LICENSE("GPL");
  680. MODULE_ALIAS("platform:kempld-core");