kempld-core.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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. 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. return kempld_detect_device(pld);
  397. }
  398. static int kempld_remove(struct platform_device *pdev)
  399. {
  400. struct kempld_device_data *pld = platform_get_drvdata(pdev);
  401. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  402. sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
  403. mfd_remove_devices(&pdev->dev);
  404. pdata->release_hardware_mutex(pld);
  405. return 0;
  406. }
  407. static struct platform_driver kempld_driver = {
  408. .driver = {
  409. .name = "kempld",
  410. },
  411. .probe = kempld_probe,
  412. .remove = kempld_remove,
  413. };
  414. static struct dmi_system_id kempld_dmi_table[] __initdata = {
  415. {
  416. .ident = "BBL6",
  417. .matches = {
  418. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  419. DMI_MATCH(DMI_BOARD_NAME, "COMe-bBL6"),
  420. },
  421. .driver_data = (void *)&kempld_platform_data_generic,
  422. .callback = kempld_create_platform_device,
  423. }, {
  424. .ident = "BHL6",
  425. .matches = {
  426. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  427. DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"),
  428. },
  429. .driver_data = (void *)&kempld_platform_data_generic,
  430. .callback = kempld_create_platform_device,
  431. }, {
  432. .ident = "CBL6",
  433. .matches = {
  434. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  435. DMI_MATCH(DMI_BOARD_NAME, "COMe-cBL6"),
  436. },
  437. .driver_data = (void *)&kempld_platform_data_generic,
  438. .callback = kempld_create_platform_device,
  439. }, {
  440. .ident = "CBW6",
  441. .matches = {
  442. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  443. DMI_MATCH(DMI_BOARD_NAME, "COMe-cBW6"),
  444. },
  445. .driver_data = (void *)&kempld_platform_data_generic,
  446. .callback = kempld_create_platform_device,
  447. }, {
  448. .ident = "CCR2",
  449. .matches = {
  450. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  451. DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP2"),
  452. },
  453. .driver_data = (void *)&kempld_platform_data_generic,
  454. .callback = kempld_create_platform_device,
  455. }, {
  456. .ident = "CCR6",
  457. .matches = {
  458. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  459. DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP6"),
  460. },
  461. .driver_data = (void *)&kempld_platform_data_generic,
  462. .callback = kempld_create_platform_device,
  463. }, {
  464. .ident = "CHL6",
  465. .matches = {
  466. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  467. DMI_MATCH(DMI_BOARD_NAME, "COMe-cHL6"),
  468. },
  469. .driver_data = (void *)&kempld_platform_data_generic,
  470. .callback = kempld_create_platform_device,
  471. }, {
  472. .ident = "CHR2",
  473. .matches = {
  474. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  475. DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T2"),
  476. },
  477. .driver_data = (void *)&kempld_platform_data_generic,
  478. .callback = kempld_create_platform_device,
  479. }, {
  480. .ident = "CHR2",
  481. .matches = {
  482. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  483. DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T2"),
  484. },
  485. .driver_data = (void *)&kempld_platform_data_generic,
  486. .callback = kempld_create_platform_device,
  487. }, {
  488. .ident = "CHR2",
  489. .matches = {
  490. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  491. DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC2"),
  492. },
  493. .driver_data = (void *)&kempld_platform_data_generic,
  494. .callback = kempld_create_platform_device,
  495. }, {
  496. .ident = "CHR6",
  497. .matches = {
  498. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  499. DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T6"),
  500. },
  501. .driver_data = (void *)&kempld_platform_data_generic,
  502. .callback = kempld_create_platform_device,
  503. }, {
  504. .ident = "CHR6",
  505. .matches = {
  506. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  507. DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T6"),
  508. },
  509. .driver_data = (void *)&kempld_platform_data_generic,
  510. .callback = kempld_create_platform_device,
  511. }, {
  512. .ident = "CHR6",
  513. .matches = {
  514. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  515. DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC6"),
  516. },
  517. .driver_data = (void *)&kempld_platform_data_generic,
  518. .callback = kempld_create_platform_device,
  519. }, {
  520. .ident = "CNTG",
  521. .matches = {
  522. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  523. DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-PC"),
  524. },
  525. .driver_data = (void *)&kempld_platform_data_generic,
  526. .callback = kempld_create_platform_device,
  527. }, {
  528. .ident = "CNTG",
  529. .matches = {
  530. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  531. DMI_MATCH(DMI_BOARD_NAME, "COMe-bPC2"),
  532. },
  533. .driver_data = (void *)&kempld_platform_data_generic,
  534. .callback = kempld_create_platform_device,
  535. }, {
  536. .ident = "CNTX",
  537. .matches = {
  538. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  539. DMI_MATCH(DMI_BOARD_NAME, "PXT"),
  540. },
  541. .driver_data = (void *)&kempld_platform_data_generic,
  542. .callback = kempld_create_platform_device,
  543. }, {
  544. .ident = "CSL6",
  545. .matches = {
  546. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  547. DMI_MATCH(DMI_BOARD_NAME, "COMe-cSL6"),
  548. },
  549. .driver_data = (void *)&kempld_platform_data_generic,
  550. .callback = kempld_create_platform_device,
  551. }, {
  552. .ident = "CVV6",
  553. .matches = {
  554. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  555. DMI_MATCH(DMI_BOARD_NAME, "COMe-cBT"),
  556. },
  557. .driver_data = (void *)&kempld_platform_data_generic,
  558. .callback = kempld_create_platform_device,
  559. }, {
  560. .ident = "FRI2",
  561. .matches = {
  562. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  563. DMI_MATCH(DMI_BIOS_VERSION, "FRI2"),
  564. },
  565. .driver_data = (void *)&kempld_platform_data_generic,
  566. .callback = kempld_create_platform_device,
  567. }, {
  568. .ident = "FRI2",
  569. .matches = {
  570. DMI_MATCH(DMI_PRODUCT_NAME, "Fish River Island II"),
  571. },
  572. .driver_data = (void *)&kempld_platform_data_generic,
  573. .callback = kempld_create_platform_device,
  574. }, {
  575. .ident = "MAL1",
  576. .matches = {
  577. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  578. DMI_MATCH(DMI_BOARD_NAME, "COMe-mAL10"),
  579. },
  580. .driver_data = (void *)&kempld_platform_data_generic,
  581. .callback = kempld_create_platform_device,
  582. }, {
  583. .ident = "MBR1",
  584. .matches = {
  585. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  586. DMI_MATCH(DMI_BOARD_NAME, "ETX-OH"),
  587. },
  588. .driver_data = (void *)&kempld_platform_data_generic,
  589. .callback = kempld_create_platform_device,
  590. }, {
  591. .ident = "MVV1",
  592. .matches = {
  593. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  594. DMI_MATCH(DMI_BOARD_NAME, "COMe-mBT"),
  595. },
  596. .driver_data = (void *)&kempld_platform_data_generic,
  597. .callback = kempld_create_platform_device,
  598. }, {
  599. .ident = "NTC1",
  600. .matches = {
  601. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  602. DMI_MATCH(DMI_BOARD_NAME, "nanoETXexpress-TT"),
  603. },
  604. .driver_data = (void *)&kempld_platform_data_generic,
  605. .callback = kempld_create_platform_device,
  606. }, {
  607. .ident = "NTC1",
  608. .matches = {
  609. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  610. DMI_MATCH(DMI_BOARD_NAME, "nETXe-TT"),
  611. },
  612. .driver_data = (void *)&kempld_platform_data_generic,
  613. .callback = kempld_create_platform_device,
  614. }, {
  615. .ident = "NTC1",
  616. .matches = {
  617. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  618. DMI_MATCH(DMI_BOARD_NAME, "COMe-mTT"),
  619. },
  620. .driver_data = (void *)&kempld_platform_data_generic,
  621. .callback = kempld_create_platform_device,
  622. }, {
  623. .ident = "NUP1",
  624. .matches = {
  625. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  626. DMI_MATCH(DMI_BOARD_NAME, "COMe-mCT"),
  627. },
  628. .driver_data = (void *)&kempld_platform_data_generic,
  629. .callback = kempld_create_platform_device,
  630. }, {
  631. .ident = "UNP1",
  632. .matches = {
  633. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  634. DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-DC"),
  635. },
  636. .driver_data = (void *)&kempld_platform_data_generic,
  637. .callback = kempld_create_platform_device,
  638. }, {
  639. .ident = "UNP1",
  640. .matches = {
  641. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  642. DMI_MATCH(DMI_BOARD_NAME, "COMe-cDC2"),
  643. },
  644. .driver_data = (void *)&kempld_platform_data_generic,
  645. .callback = kempld_create_platform_device,
  646. }, {
  647. .ident = "UNTG",
  648. .matches = {
  649. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  650. DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-PC"),
  651. },
  652. .driver_data = (void *)&kempld_platform_data_generic,
  653. .callback = kempld_create_platform_device,
  654. }, {
  655. .ident = "UNTG",
  656. .matches = {
  657. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  658. DMI_MATCH(DMI_BOARD_NAME, "COMe-cPC2"),
  659. },
  660. .driver_data = (void *)&kempld_platform_data_generic,
  661. .callback = kempld_create_platform_device,
  662. }, {
  663. .ident = "UUP6",
  664. .matches = {
  665. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  666. DMI_MATCH(DMI_BOARD_NAME, "COMe-cCT6"),
  667. },
  668. .driver_data = (void *)&kempld_platform_data_generic,
  669. .callback = kempld_create_platform_device,
  670. },
  671. {
  672. .ident = "UTH6",
  673. .matches = {
  674. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  675. DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"),
  676. },
  677. .driver_data = (void *)&kempld_platform_data_generic,
  678. .callback = kempld_create_platform_device,
  679. },
  680. {}
  681. };
  682. MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
  683. static int __init kempld_init(void)
  684. {
  685. const struct dmi_system_id *id;
  686. if (force_device_id[0]) {
  687. for (id = kempld_dmi_table;
  688. id->matches[0].slot != DMI_NONE; id++)
  689. if (strstr(id->ident, force_device_id))
  690. if (id->callback && !id->callback(id))
  691. break;
  692. if (id->matches[0].slot == DMI_NONE)
  693. return -ENODEV;
  694. } else {
  695. if (!dmi_check_system(kempld_dmi_table))
  696. return -ENODEV;
  697. }
  698. return platform_driver_register(&kempld_driver);
  699. }
  700. static void __exit kempld_exit(void)
  701. {
  702. if (kempld_pdev)
  703. platform_device_unregister(kempld_pdev);
  704. platform_driver_unregister(&kempld_driver);
  705. }
  706. module_init(kempld_init);
  707. module_exit(kempld_exit);
  708. MODULE_DESCRIPTION("KEM PLD Core Driver");
  709. MODULE_AUTHOR("Michael Brunner <michael.brunner@kontron.com>");
  710. MODULE_LICENSE("GPL");
  711. MODULE_ALIAS("platform:kempld-core");