gpio-lpc32xx.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /*
  2. * GPIO driver for LPC32xx SoC
  3. *
  4. * Author: Kevin Wells <kevin.wells@nxp.com>
  5. *
  6. * Copyright (C) 2010 NXP Semiconductors
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/io.h>
  21. #include <linux/errno.h>
  22. #include <linux/gpio/driver.h>
  23. #include <linux/of.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/module.h>
  26. #include <mach/hardware.h>
  27. #include <mach/platform.h>
  28. #define LPC32XX_GPIO_P3_INP_STATE _GPREG(0x000)
  29. #define LPC32XX_GPIO_P3_OUTP_SET _GPREG(0x004)
  30. #define LPC32XX_GPIO_P3_OUTP_CLR _GPREG(0x008)
  31. #define LPC32XX_GPIO_P3_OUTP_STATE _GPREG(0x00C)
  32. #define LPC32XX_GPIO_P2_DIR_SET _GPREG(0x010)
  33. #define LPC32XX_GPIO_P2_DIR_CLR _GPREG(0x014)
  34. #define LPC32XX_GPIO_P2_DIR_STATE _GPREG(0x018)
  35. #define LPC32XX_GPIO_P2_INP_STATE _GPREG(0x01C)
  36. #define LPC32XX_GPIO_P2_OUTP_SET _GPREG(0x020)
  37. #define LPC32XX_GPIO_P2_OUTP_CLR _GPREG(0x024)
  38. #define LPC32XX_GPIO_P2_MUX_SET _GPREG(0x028)
  39. #define LPC32XX_GPIO_P2_MUX_CLR _GPREG(0x02C)
  40. #define LPC32XX_GPIO_P2_MUX_STATE _GPREG(0x030)
  41. #define LPC32XX_GPIO_P0_INP_STATE _GPREG(0x040)
  42. #define LPC32XX_GPIO_P0_OUTP_SET _GPREG(0x044)
  43. #define LPC32XX_GPIO_P0_OUTP_CLR _GPREG(0x048)
  44. #define LPC32XX_GPIO_P0_OUTP_STATE _GPREG(0x04C)
  45. #define LPC32XX_GPIO_P0_DIR_SET _GPREG(0x050)
  46. #define LPC32XX_GPIO_P0_DIR_CLR _GPREG(0x054)
  47. #define LPC32XX_GPIO_P0_DIR_STATE _GPREG(0x058)
  48. #define LPC32XX_GPIO_P1_INP_STATE _GPREG(0x060)
  49. #define LPC32XX_GPIO_P1_OUTP_SET _GPREG(0x064)
  50. #define LPC32XX_GPIO_P1_OUTP_CLR _GPREG(0x068)
  51. #define LPC32XX_GPIO_P1_OUTP_STATE _GPREG(0x06C)
  52. #define LPC32XX_GPIO_P1_DIR_SET _GPREG(0x070)
  53. #define LPC32XX_GPIO_P1_DIR_CLR _GPREG(0x074)
  54. #define LPC32XX_GPIO_P1_DIR_STATE _GPREG(0x078)
  55. #define GPIO012_PIN_TO_BIT(x) (1 << (x))
  56. #define GPIO3_PIN_TO_BIT(x) (1 << ((x) + 25))
  57. #define GPO3_PIN_TO_BIT(x) (1 << (x))
  58. #define GPIO012_PIN_IN_SEL(x, y) (((x) >> (y)) & 1)
  59. #define GPIO3_PIN_IN_SHIFT(x) ((x) == 5 ? 24 : 10 + (x))
  60. #define GPIO3_PIN_IN_SEL(x, y) (((x) >> GPIO3_PIN_IN_SHIFT(y)) & 1)
  61. #define GPIO3_PIN5_IN_SEL(x) (((x) >> 24) & 1)
  62. #define GPI3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1)
  63. #define GPO3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1)
  64. #define LPC32XX_GPIO_P0_MAX 8
  65. #define LPC32XX_GPIO_P1_MAX 24
  66. #define LPC32XX_GPIO_P2_MAX 13
  67. #define LPC32XX_GPIO_P3_MAX 6
  68. #define LPC32XX_GPI_P3_MAX 29
  69. #define LPC32XX_GPO_P3_MAX 24
  70. #define LPC32XX_GPIO_P0_GRP 0
  71. #define LPC32XX_GPIO_P1_GRP (LPC32XX_GPIO_P0_GRP + LPC32XX_GPIO_P0_MAX)
  72. #define LPC32XX_GPIO_P2_GRP (LPC32XX_GPIO_P1_GRP + LPC32XX_GPIO_P1_MAX)
  73. #define LPC32XX_GPIO_P3_GRP (LPC32XX_GPIO_P2_GRP + LPC32XX_GPIO_P2_MAX)
  74. #define LPC32XX_GPI_P3_GRP (LPC32XX_GPIO_P3_GRP + LPC32XX_GPIO_P3_MAX)
  75. #define LPC32XX_GPO_P3_GRP (LPC32XX_GPI_P3_GRP + LPC32XX_GPI_P3_MAX)
  76. struct gpio_regs {
  77. void __iomem *inp_state;
  78. void __iomem *outp_state;
  79. void __iomem *outp_set;
  80. void __iomem *outp_clr;
  81. void __iomem *dir_set;
  82. void __iomem *dir_clr;
  83. };
  84. /*
  85. * GPIO names
  86. */
  87. static const char *gpio_p0_names[LPC32XX_GPIO_P0_MAX] = {
  88. "p0.0", "p0.1", "p0.2", "p0.3",
  89. "p0.4", "p0.5", "p0.6", "p0.7"
  90. };
  91. static const char *gpio_p1_names[LPC32XX_GPIO_P1_MAX] = {
  92. "p1.0", "p1.1", "p1.2", "p1.3",
  93. "p1.4", "p1.5", "p1.6", "p1.7",
  94. "p1.8", "p1.9", "p1.10", "p1.11",
  95. "p1.12", "p1.13", "p1.14", "p1.15",
  96. "p1.16", "p1.17", "p1.18", "p1.19",
  97. "p1.20", "p1.21", "p1.22", "p1.23",
  98. };
  99. static const char *gpio_p2_names[LPC32XX_GPIO_P2_MAX] = {
  100. "p2.0", "p2.1", "p2.2", "p2.3",
  101. "p2.4", "p2.5", "p2.6", "p2.7",
  102. "p2.8", "p2.9", "p2.10", "p2.11",
  103. "p2.12"
  104. };
  105. static const char *gpio_p3_names[LPC32XX_GPIO_P3_MAX] = {
  106. "gpio00", "gpio01", "gpio02", "gpio03",
  107. "gpio04", "gpio05"
  108. };
  109. static const char *gpi_p3_names[LPC32XX_GPI_P3_MAX] = {
  110. "gpi00", "gpi01", "gpi02", "gpi03",
  111. "gpi04", "gpi05", "gpi06", "gpi07",
  112. "gpi08", "gpi09", NULL, NULL,
  113. NULL, NULL, NULL, "gpi15",
  114. "gpi16", "gpi17", "gpi18", "gpi19",
  115. "gpi20", "gpi21", "gpi22", "gpi23",
  116. "gpi24", "gpi25", "gpi26", "gpi27",
  117. "gpi28"
  118. };
  119. static const char *gpo_p3_names[LPC32XX_GPO_P3_MAX] = {
  120. "gpo00", "gpo01", "gpo02", "gpo03",
  121. "gpo04", "gpo05", "gpo06", "gpo07",
  122. "gpo08", "gpo09", "gpo10", "gpo11",
  123. "gpo12", "gpo13", "gpo14", "gpo15",
  124. "gpo16", "gpo17", "gpo18", "gpo19",
  125. "gpo20", "gpo21", "gpo22", "gpo23"
  126. };
  127. static struct gpio_regs gpio_grp_regs_p0 = {
  128. .inp_state = LPC32XX_GPIO_P0_INP_STATE,
  129. .outp_set = LPC32XX_GPIO_P0_OUTP_SET,
  130. .outp_clr = LPC32XX_GPIO_P0_OUTP_CLR,
  131. .dir_set = LPC32XX_GPIO_P0_DIR_SET,
  132. .dir_clr = LPC32XX_GPIO_P0_DIR_CLR,
  133. };
  134. static struct gpio_regs gpio_grp_regs_p1 = {
  135. .inp_state = LPC32XX_GPIO_P1_INP_STATE,
  136. .outp_set = LPC32XX_GPIO_P1_OUTP_SET,
  137. .outp_clr = LPC32XX_GPIO_P1_OUTP_CLR,
  138. .dir_set = LPC32XX_GPIO_P1_DIR_SET,
  139. .dir_clr = LPC32XX_GPIO_P1_DIR_CLR,
  140. };
  141. static struct gpio_regs gpio_grp_regs_p2 = {
  142. .inp_state = LPC32XX_GPIO_P2_INP_STATE,
  143. .outp_set = LPC32XX_GPIO_P2_OUTP_SET,
  144. .outp_clr = LPC32XX_GPIO_P2_OUTP_CLR,
  145. .dir_set = LPC32XX_GPIO_P2_DIR_SET,
  146. .dir_clr = LPC32XX_GPIO_P2_DIR_CLR,
  147. };
  148. static struct gpio_regs gpio_grp_regs_p3 = {
  149. .inp_state = LPC32XX_GPIO_P3_INP_STATE,
  150. .outp_state = LPC32XX_GPIO_P3_OUTP_STATE,
  151. .outp_set = LPC32XX_GPIO_P3_OUTP_SET,
  152. .outp_clr = LPC32XX_GPIO_P3_OUTP_CLR,
  153. .dir_set = LPC32XX_GPIO_P2_DIR_SET,
  154. .dir_clr = LPC32XX_GPIO_P2_DIR_CLR,
  155. };
  156. struct lpc32xx_gpio_chip {
  157. struct gpio_chip chip;
  158. struct gpio_regs *gpio_grp;
  159. };
  160. static void __set_gpio_dir_p012(struct lpc32xx_gpio_chip *group,
  161. unsigned pin, int input)
  162. {
  163. if (input)
  164. __raw_writel(GPIO012_PIN_TO_BIT(pin),
  165. group->gpio_grp->dir_clr);
  166. else
  167. __raw_writel(GPIO012_PIN_TO_BIT(pin),
  168. group->gpio_grp->dir_set);
  169. }
  170. static void __set_gpio_dir_p3(struct lpc32xx_gpio_chip *group,
  171. unsigned pin, int input)
  172. {
  173. u32 u = GPIO3_PIN_TO_BIT(pin);
  174. if (input)
  175. __raw_writel(u, group->gpio_grp->dir_clr);
  176. else
  177. __raw_writel(u, group->gpio_grp->dir_set);
  178. }
  179. static void __set_gpio_level_p012(struct lpc32xx_gpio_chip *group,
  180. unsigned pin, int high)
  181. {
  182. if (high)
  183. __raw_writel(GPIO012_PIN_TO_BIT(pin),
  184. group->gpio_grp->outp_set);
  185. else
  186. __raw_writel(GPIO012_PIN_TO_BIT(pin),
  187. group->gpio_grp->outp_clr);
  188. }
  189. static void __set_gpio_level_p3(struct lpc32xx_gpio_chip *group,
  190. unsigned pin, int high)
  191. {
  192. u32 u = GPIO3_PIN_TO_BIT(pin);
  193. if (high)
  194. __raw_writel(u, group->gpio_grp->outp_set);
  195. else
  196. __raw_writel(u, group->gpio_grp->outp_clr);
  197. }
  198. static void __set_gpo_level_p3(struct lpc32xx_gpio_chip *group,
  199. unsigned pin, int high)
  200. {
  201. if (high)
  202. __raw_writel(GPO3_PIN_TO_BIT(pin), group->gpio_grp->outp_set);
  203. else
  204. __raw_writel(GPO3_PIN_TO_BIT(pin), group->gpio_grp->outp_clr);
  205. }
  206. static int __get_gpio_state_p012(struct lpc32xx_gpio_chip *group,
  207. unsigned pin)
  208. {
  209. return GPIO012_PIN_IN_SEL(__raw_readl(group->gpio_grp->inp_state),
  210. pin);
  211. }
  212. static int __get_gpio_state_p3(struct lpc32xx_gpio_chip *group,
  213. unsigned pin)
  214. {
  215. int state = __raw_readl(group->gpio_grp->inp_state);
  216. /*
  217. * P3 GPIO pin input mapping is not contiguous, GPIOP3-0..4 is mapped
  218. * to bits 10..14, while GPIOP3-5 is mapped to bit 24.
  219. */
  220. return GPIO3_PIN_IN_SEL(state, pin);
  221. }
  222. static int __get_gpi_state_p3(struct lpc32xx_gpio_chip *group,
  223. unsigned pin)
  224. {
  225. return GPI3_PIN_IN_SEL(__raw_readl(group->gpio_grp->inp_state), pin);
  226. }
  227. static int __get_gpo_state_p3(struct lpc32xx_gpio_chip *group,
  228. unsigned pin)
  229. {
  230. return GPO3_PIN_IN_SEL(__raw_readl(group->gpio_grp->outp_state), pin);
  231. }
  232. /*
  233. * GPIO primitives.
  234. */
  235. static int lpc32xx_gpio_dir_input_p012(struct gpio_chip *chip,
  236. unsigned pin)
  237. {
  238. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  239. __set_gpio_dir_p012(group, pin, 1);
  240. return 0;
  241. }
  242. static int lpc32xx_gpio_dir_input_p3(struct gpio_chip *chip,
  243. unsigned pin)
  244. {
  245. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  246. __set_gpio_dir_p3(group, pin, 1);
  247. return 0;
  248. }
  249. static int lpc32xx_gpio_dir_in_always(struct gpio_chip *chip,
  250. unsigned pin)
  251. {
  252. return 0;
  253. }
  254. static int lpc32xx_gpio_get_value_p012(struct gpio_chip *chip, unsigned pin)
  255. {
  256. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  257. return !!__get_gpio_state_p012(group, pin);
  258. }
  259. static int lpc32xx_gpio_get_value_p3(struct gpio_chip *chip, unsigned pin)
  260. {
  261. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  262. return !!__get_gpio_state_p3(group, pin);
  263. }
  264. static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin)
  265. {
  266. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  267. return !!__get_gpi_state_p3(group, pin);
  268. }
  269. static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin,
  270. int value)
  271. {
  272. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  273. __set_gpio_level_p012(group, pin, value);
  274. __set_gpio_dir_p012(group, pin, 0);
  275. return 0;
  276. }
  277. static int lpc32xx_gpio_dir_output_p3(struct gpio_chip *chip, unsigned pin,
  278. int value)
  279. {
  280. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  281. __set_gpio_level_p3(group, pin, value);
  282. __set_gpio_dir_p3(group, pin, 0);
  283. return 0;
  284. }
  285. static int lpc32xx_gpio_dir_out_always(struct gpio_chip *chip, unsigned pin,
  286. int value)
  287. {
  288. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  289. __set_gpo_level_p3(group, pin, value);
  290. return 0;
  291. }
  292. static void lpc32xx_gpio_set_value_p012(struct gpio_chip *chip, unsigned pin,
  293. int value)
  294. {
  295. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  296. __set_gpio_level_p012(group, pin, value);
  297. }
  298. static void lpc32xx_gpio_set_value_p3(struct gpio_chip *chip, unsigned pin,
  299. int value)
  300. {
  301. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  302. __set_gpio_level_p3(group, pin, value);
  303. }
  304. static void lpc32xx_gpo_set_value(struct gpio_chip *chip, unsigned pin,
  305. int value)
  306. {
  307. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  308. __set_gpo_level_p3(group, pin, value);
  309. }
  310. static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin)
  311. {
  312. struct lpc32xx_gpio_chip *group = gpiochip_get_data(chip);
  313. return !!__get_gpo_state_p3(group, pin);
  314. }
  315. static int lpc32xx_gpio_request(struct gpio_chip *chip, unsigned pin)
  316. {
  317. if (pin < chip->ngpio)
  318. return 0;
  319. return -EINVAL;
  320. }
  321. static int lpc32xx_gpio_to_irq_p01(struct gpio_chip *chip, unsigned offset)
  322. {
  323. return -ENXIO;
  324. }
  325. static int lpc32xx_gpio_to_irq_gpio_p3(struct gpio_chip *chip, unsigned offset)
  326. {
  327. return -ENXIO;
  328. }
  329. static int lpc32xx_gpio_to_irq_gpi_p3(struct gpio_chip *chip, unsigned offset)
  330. {
  331. return -ENXIO;
  332. }
  333. static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
  334. {
  335. .chip = {
  336. .label = "gpio_p0",
  337. .direction_input = lpc32xx_gpio_dir_input_p012,
  338. .get = lpc32xx_gpio_get_value_p012,
  339. .direction_output = lpc32xx_gpio_dir_output_p012,
  340. .set = lpc32xx_gpio_set_value_p012,
  341. .request = lpc32xx_gpio_request,
  342. .to_irq = lpc32xx_gpio_to_irq_p01,
  343. .base = LPC32XX_GPIO_P0_GRP,
  344. .ngpio = LPC32XX_GPIO_P0_MAX,
  345. .names = gpio_p0_names,
  346. .can_sleep = false,
  347. },
  348. .gpio_grp = &gpio_grp_regs_p0,
  349. },
  350. {
  351. .chip = {
  352. .label = "gpio_p1",
  353. .direction_input = lpc32xx_gpio_dir_input_p012,
  354. .get = lpc32xx_gpio_get_value_p012,
  355. .direction_output = lpc32xx_gpio_dir_output_p012,
  356. .set = lpc32xx_gpio_set_value_p012,
  357. .request = lpc32xx_gpio_request,
  358. .to_irq = lpc32xx_gpio_to_irq_p01,
  359. .base = LPC32XX_GPIO_P1_GRP,
  360. .ngpio = LPC32XX_GPIO_P1_MAX,
  361. .names = gpio_p1_names,
  362. .can_sleep = false,
  363. },
  364. .gpio_grp = &gpio_grp_regs_p1,
  365. },
  366. {
  367. .chip = {
  368. .label = "gpio_p2",
  369. .direction_input = lpc32xx_gpio_dir_input_p012,
  370. .get = lpc32xx_gpio_get_value_p012,
  371. .direction_output = lpc32xx_gpio_dir_output_p012,
  372. .set = lpc32xx_gpio_set_value_p012,
  373. .request = lpc32xx_gpio_request,
  374. .base = LPC32XX_GPIO_P2_GRP,
  375. .ngpio = LPC32XX_GPIO_P2_MAX,
  376. .names = gpio_p2_names,
  377. .can_sleep = false,
  378. },
  379. .gpio_grp = &gpio_grp_regs_p2,
  380. },
  381. {
  382. .chip = {
  383. .label = "gpio_p3",
  384. .direction_input = lpc32xx_gpio_dir_input_p3,
  385. .get = lpc32xx_gpio_get_value_p3,
  386. .direction_output = lpc32xx_gpio_dir_output_p3,
  387. .set = lpc32xx_gpio_set_value_p3,
  388. .request = lpc32xx_gpio_request,
  389. .to_irq = lpc32xx_gpio_to_irq_gpio_p3,
  390. .base = LPC32XX_GPIO_P3_GRP,
  391. .ngpio = LPC32XX_GPIO_P3_MAX,
  392. .names = gpio_p3_names,
  393. .can_sleep = false,
  394. },
  395. .gpio_grp = &gpio_grp_regs_p3,
  396. },
  397. {
  398. .chip = {
  399. .label = "gpi_p3",
  400. .direction_input = lpc32xx_gpio_dir_in_always,
  401. .get = lpc32xx_gpi_get_value,
  402. .request = lpc32xx_gpio_request,
  403. .to_irq = lpc32xx_gpio_to_irq_gpi_p3,
  404. .base = LPC32XX_GPI_P3_GRP,
  405. .ngpio = LPC32XX_GPI_P3_MAX,
  406. .names = gpi_p3_names,
  407. .can_sleep = false,
  408. },
  409. .gpio_grp = &gpio_grp_regs_p3,
  410. },
  411. {
  412. .chip = {
  413. .label = "gpo_p3",
  414. .direction_output = lpc32xx_gpio_dir_out_always,
  415. .set = lpc32xx_gpo_set_value,
  416. .get = lpc32xx_gpo_get_value,
  417. .request = lpc32xx_gpio_request,
  418. .base = LPC32XX_GPO_P3_GRP,
  419. .ngpio = LPC32XX_GPO_P3_MAX,
  420. .names = gpo_p3_names,
  421. .can_sleep = false,
  422. },
  423. .gpio_grp = &gpio_grp_regs_p3,
  424. },
  425. };
  426. static int lpc32xx_of_xlate(struct gpio_chip *gc,
  427. const struct of_phandle_args *gpiospec, u32 *flags)
  428. {
  429. /* Is this the correct bank? */
  430. u32 bank = gpiospec->args[0];
  431. if ((bank >= ARRAY_SIZE(lpc32xx_gpiochip) ||
  432. (gc != &lpc32xx_gpiochip[bank].chip)))
  433. return -EINVAL;
  434. if (flags)
  435. *flags = gpiospec->args[2];
  436. return gpiospec->args[1];
  437. }
  438. static int lpc32xx_gpio_probe(struct platform_device *pdev)
  439. {
  440. int i;
  441. for (i = 0; i < ARRAY_SIZE(lpc32xx_gpiochip); i++) {
  442. if (pdev->dev.of_node) {
  443. lpc32xx_gpiochip[i].chip.of_xlate = lpc32xx_of_xlate;
  444. lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
  445. lpc32xx_gpiochip[i].chip.of_node = pdev->dev.of_node;
  446. }
  447. devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
  448. &lpc32xx_gpiochip[i]);
  449. }
  450. return 0;
  451. }
  452. #ifdef CONFIG_OF
  453. static const struct of_device_id lpc32xx_gpio_of_match[] = {
  454. { .compatible = "nxp,lpc3220-gpio", },
  455. { },
  456. };
  457. #endif
  458. static struct platform_driver lpc32xx_gpio_driver = {
  459. .driver = {
  460. .name = "lpc32xx-gpio",
  461. .of_match_table = of_match_ptr(lpc32xx_gpio_of_match),
  462. },
  463. .probe = lpc32xx_gpio_probe,
  464. };
  465. module_platform_driver(lpc32xx_gpio_driver);