gpio-lpc32xx.c 14 KB

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