kempld-core.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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 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. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  251. return pdata->get_info(pld);
  252. }
  253. /*
  254. * kempld_register_cells - register cell drivers
  255. *
  256. * This function registers cell drivers for the detected hardware by calling
  257. * the configured kempld_register_cells_XXXX function which is responsible
  258. * to detect and register the needed cell drivers.
  259. */
  260. static int kempld_register_cells(struct kempld_device_data *pld)
  261. {
  262. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  263. return pdata->register_cells(pld);
  264. }
  265. static int kempld_detect_device(struct kempld_device_data *pld)
  266. {
  267. char *version_type;
  268. u8 index_reg;
  269. int ret;
  270. mutex_lock(&pld->lock);
  271. /* Check for empty IO space */
  272. index_reg = ioread8(pld->io_index);
  273. if (index_reg == 0xff && ioread8(pld->io_data) == 0xff) {
  274. mutex_unlock(&pld->lock);
  275. return -ENODEV;
  276. }
  277. /* Release hardware mutex if aquired */
  278. if (!(index_reg & KEMPLD_MUTEX_KEY))
  279. iowrite8(KEMPLD_MUTEX_KEY, pld->io_index);
  280. mutex_unlock(&pld->lock);
  281. ret = kempld_get_info(pld);
  282. if (ret)
  283. return ret;
  284. switch (pld->info.type) {
  285. case 0:
  286. version_type = "release";
  287. break;
  288. case 1:
  289. version_type = "debug";
  290. break;
  291. case 2:
  292. version_type = "custom";
  293. break;
  294. default:
  295. version_type = "unspecified";
  296. }
  297. dev_info(pld->dev, "Found Kontron PLD %d\n", pld->info.number);
  298. dev_info(pld->dev, "%s version %d.%d build %d, specification %d.%d\n",
  299. version_type, pld->info.major, pld->info.minor,
  300. pld->info.buildnr, pld->info.spec_major,
  301. pld->info.spec_minor);
  302. return kempld_register_cells(pld);
  303. }
  304. static int kempld_probe(struct platform_device *pdev)
  305. {
  306. struct kempld_platform_data *pdata = dev_get_platdata(&pdev->dev);
  307. struct device *dev = &pdev->dev;
  308. struct kempld_device_data *pld;
  309. struct resource *ioport;
  310. int ret;
  311. pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
  312. if (!pld)
  313. return -ENOMEM;
  314. ioport = platform_get_resource(pdev, IORESOURCE_IO, 0);
  315. if (!ioport)
  316. return -EINVAL;
  317. pld->io_base = devm_ioport_map(dev, ioport->start,
  318. ioport->end - ioport->start);
  319. if (!pld->io_base)
  320. return -ENOMEM;
  321. pld->io_index = pld->io_base;
  322. pld->io_data = pld->io_base + 1;
  323. pld->pld_clock = pdata->pld_clock;
  324. pld->dev = dev;
  325. mutex_init(&pld->lock);
  326. platform_set_drvdata(pdev, pld);
  327. ret = kempld_detect_device(pld);
  328. if (ret)
  329. return ret;
  330. return 0;
  331. }
  332. static int kempld_remove(struct platform_device *pdev)
  333. {
  334. struct kempld_device_data *pld = platform_get_drvdata(pdev);
  335. struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
  336. mfd_remove_devices(&pdev->dev);
  337. pdata->release_hardware_mutex(pld);
  338. return 0;
  339. }
  340. static struct platform_driver kempld_driver = {
  341. .driver = {
  342. .name = "kempld",
  343. .owner = THIS_MODULE,
  344. },
  345. .probe = kempld_probe,
  346. .remove = kempld_remove,
  347. };
  348. static struct dmi_system_id __initdata kempld_dmi_table[] = {
  349. {
  350. .ident = "BHL6",
  351. .matches = {
  352. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  353. DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"),
  354. },
  355. .driver_data = (void *)&kempld_platform_data_generic,
  356. .callback = kempld_create_platform_device,
  357. },
  358. {
  359. .ident = "CCR2",
  360. .matches = {
  361. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  362. DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP2"),
  363. },
  364. .driver_data = (void *)&kempld_platform_data_generic,
  365. .callback = kempld_create_platform_device,
  366. }, {
  367. .ident = "CCR6",
  368. .matches = {
  369. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  370. DMI_MATCH(DMI_BOARD_NAME, "COMe-bIP6"),
  371. },
  372. .driver_data = (void *)&kempld_platform_data_generic,
  373. .callback = kempld_create_platform_device,
  374. }, {
  375. .ident = "CHR2",
  376. .matches = {
  377. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  378. DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T2"),
  379. },
  380. .driver_data = (void *)&kempld_platform_data_generic,
  381. .callback = kempld_create_platform_device,
  382. }, {
  383. .ident = "CHR2",
  384. .matches = {
  385. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  386. DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T2"),
  387. },
  388. .driver_data = (void *)&kempld_platform_data_generic,
  389. .callback = kempld_create_platform_device,
  390. }, {
  391. .ident = "CHR2",
  392. .matches = {
  393. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  394. DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC2"),
  395. },
  396. .driver_data = (void *)&kempld_platform_data_generic,
  397. .callback = kempld_create_platform_device,
  398. }, {
  399. .ident = "CHR6",
  400. .matches = {
  401. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  402. DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-SC T6"),
  403. },
  404. .driver_data = (void *)&kempld_platform_data_generic,
  405. .callback = kempld_create_platform_device,
  406. }, {
  407. .ident = "CHR6",
  408. .matches = {
  409. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  410. DMI_MATCH(DMI_BOARD_NAME, "ETXe-SC T6"),
  411. },
  412. .driver_data = (void *)&kempld_platform_data_generic,
  413. .callback = kempld_create_platform_device,
  414. }, {
  415. .ident = "CHR6",
  416. .matches = {
  417. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  418. DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC6"),
  419. },
  420. .driver_data = (void *)&kempld_platform_data_generic,
  421. .callback = kempld_create_platform_device,
  422. }, {
  423. .ident = "CNTG",
  424. .matches = {
  425. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  426. DMI_MATCH(DMI_BOARD_NAME, "ETXexpress-PC"),
  427. },
  428. .driver_data = (void *)&kempld_platform_data_generic,
  429. .callback = kempld_create_platform_device,
  430. }, {
  431. .ident = "CNTG",
  432. .matches = {
  433. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  434. DMI_MATCH(DMI_BOARD_NAME, "COMe-bPC2"),
  435. },
  436. .driver_data = (void *)&kempld_platform_data_generic,
  437. .callback = kempld_create_platform_device,
  438. }, {
  439. .ident = "CNTX",
  440. .matches = {
  441. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  442. DMI_MATCH(DMI_BOARD_NAME, "PXT"),
  443. },
  444. .driver_data = (void *)&kempld_platform_data_generic,
  445. .callback = kempld_create_platform_device,
  446. }, {
  447. .ident = "FRI2",
  448. .matches = {
  449. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  450. DMI_MATCH(DMI_BIOS_VERSION, "FRI2"),
  451. },
  452. .driver_data = (void *)&kempld_platform_data_generic,
  453. .callback = kempld_create_platform_device,
  454. }, {
  455. .ident = "FRI2",
  456. .matches = {
  457. DMI_MATCH(DMI_PRODUCT_NAME, "Fish River Island II"),
  458. },
  459. .driver_data = (void *)&kempld_platform_data_generic,
  460. .callback = kempld_create_platform_device,
  461. }, {
  462. .ident = "MBR1",
  463. .matches = {
  464. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  465. DMI_MATCH(DMI_BOARD_NAME, "ETX-OH"),
  466. },
  467. .driver_data = (void *)&kempld_platform_data_generic,
  468. .callback = kempld_create_platform_device,
  469. }, {
  470. .ident = "NTC1",
  471. .matches = {
  472. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  473. DMI_MATCH(DMI_BOARD_NAME, "nanoETXexpress-TT"),
  474. },
  475. .driver_data = (void *)&kempld_platform_data_generic,
  476. .callback = kempld_create_platform_device,
  477. }, {
  478. .ident = "NTC1",
  479. .matches = {
  480. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  481. DMI_MATCH(DMI_BOARD_NAME, "nETXe-TT"),
  482. },
  483. .driver_data = (void *)&kempld_platform_data_generic,
  484. .callback = kempld_create_platform_device,
  485. }, {
  486. .ident = "NTC1",
  487. .matches = {
  488. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  489. DMI_MATCH(DMI_BOARD_NAME, "COMe-mTT"),
  490. },
  491. .driver_data = (void *)&kempld_platform_data_generic,
  492. .callback = kempld_create_platform_device,
  493. }, {
  494. .ident = "NUP1",
  495. .matches = {
  496. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  497. DMI_MATCH(DMI_BOARD_NAME, "COMe-mCT"),
  498. },
  499. .driver_data = (void *)&kempld_platform_data_generic,
  500. .callback = kempld_create_platform_device,
  501. }, {
  502. .ident = "UNP1",
  503. .matches = {
  504. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  505. DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-DC"),
  506. },
  507. .driver_data = (void *)&kempld_platform_data_generic,
  508. .callback = kempld_create_platform_device,
  509. }, {
  510. .ident = "UNP1",
  511. .matches = {
  512. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  513. DMI_MATCH(DMI_BOARD_NAME, "COMe-cDC2"),
  514. },
  515. .driver_data = (void *)&kempld_platform_data_generic,
  516. .callback = kempld_create_platform_device,
  517. }, {
  518. .ident = "UNTG",
  519. .matches = {
  520. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  521. DMI_MATCH(DMI_BOARD_NAME, "microETXexpress-PC"),
  522. },
  523. .driver_data = (void *)&kempld_platform_data_generic,
  524. .callback = kempld_create_platform_device,
  525. }, {
  526. .ident = "UNTG",
  527. .matches = {
  528. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  529. DMI_MATCH(DMI_BOARD_NAME, "COMe-cPC2"),
  530. },
  531. .driver_data = (void *)&kempld_platform_data_generic,
  532. .callback = kempld_create_platform_device,
  533. }, {
  534. .ident = "UUP6",
  535. .matches = {
  536. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  537. DMI_MATCH(DMI_BOARD_NAME, "COMe-cCT6"),
  538. },
  539. .driver_data = (void *)&kempld_platform_data_generic,
  540. .callback = kempld_create_platform_device,
  541. },
  542. {
  543. .ident = "UTH6",
  544. .matches = {
  545. DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
  546. DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"),
  547. },
  548. .driver_data = (void *)&kempld_platform_data_generic,
  549. .callback = kempld_create_platform_device,
  550. },
  551. {}
  552. };
  553. MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
  554. static int __init kempld_init(void)
  555. {
  556. const struct dmi_system_id *id;
  557. int ret;
  558. if (force_device_id[0]) {
  559. for (id = kempld_dmi_table; id->matches[0].slot != DMI_NONE; id++)
  560. if (strstr(id->ident, force_device_id))
  561. if (id->callback && id->callback(id))
  562. break;
  563. if (id->matches[0].slot == DMI_NONE)
  564. return -ENODEV;
  565. } else {
  566. if (!dmi_check_system(kempld_dmi_table))
  567. return -ENODEV;
  568. }
  569. ret = platform_driver_register(&kempld_driver);
  570. if (ret)
  571. return ret;
  572. return 0;
  573. }
  574. static void __exit kempld_exit(void)
  575. {
  576. if (kempld_pdev)
  577. platform_device_unregister(kempld_pdev);
  578. platform_driver_unregister(&kempld_driver);
  579. }
  580. module_init(kempld_init);
  581. module_exit(kempld_exit);
  582. MODULE_DESCRIPTION("KEM PLD Core Driver");
  583. MODULE_AUTHOR("Michael Brunner <michael.brunner@kontron.com>");
  584. MODULE_LICENSE("GPL");
  585. MODULE_ALIAS("platform:kempld-core");