gpio-davinci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * TI DaVinci GPIO Support
  3. *
  4. * Copyright (c) 2006-2007 David Brownell
  5. * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.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 as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/gpio/driver.h>
  13. #include <linux/errno.h>
  14. #include <linux/kernel.h>
  15. #include <linux/clk.h>
  16. #include <linux/err.h>
  17. #include <linux/io.h>
  18. #include <linux/irq.h>
  19. #include <linux/irqdomain.h>
  20. #include <linux/module.h>
  21. #include <linux/of.h>
  22. #include <linux/of_device.h>
  23. #include <linux/pinctrl/consumer.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/platform_data/gpio-davinci.h>
  26. #include <linux/irqchip/chained_irq.h>
  27. struct davinci_gpio_regs {
  28. u32 dir;
  29. u32 out_data;
  30. u32 set_data;
  31. u32 clr_data;
  32. u32 in_data;
  33. u32 set_rising;
  34. u32 clr_rising;
  35. u32 set_falling;
  36. u32 clr_falling;
  37. u32 intstat;
  38. };
  39. typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
  40. #define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */
  41. #define MAX_LABEL_SIZE 20
  42. static void __iomem *gpio_base;
  43. static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0};
  44. static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
  45. {
  46. struct davinci_gpio_regs __iomem *g;
  47. g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_irq_chip_data(d);
  48. return g;
  49. }
  50. static int davinci_gpio_irq_setup(struct platform_device *pdev);
  51. /*--------------------------------------------------------------------------*/
  52. /* board setup code *MUST* setup pinmux and enable the GPIO clock. */
  53. static inline int __davinci_direction(struct gpio_chip *chip,
  54. unsigned offset, bool out, int value)
  55. {
  56. struct davinci_gpio_controller *d = gpiochip_get_data(chip);
  57. struct davinci_gpio_regs __iomem *g;
  58. unsigned long flags;
  59. u32 temp;
  60. int bank = offset / 32;
  61. u32 mask = __gpio_mask(offset);
  62. g = d->regs[bank];
  63. spin_lock_irqsave(&d->lock, flags);
  64. temp = readl_relaxed(&g->dir);
  65. if (out) {
  66. temp &= ~mask;
  67. writel_relaxed(mask, value ? &g->set_data : &g->clr_data);
  68. } else {
  69. temp |= mask;
  70. }
  71. writel_relaxed(temp, &g->dir);
  72. spin_unlock_irqrestore(&d->lock, flags);
  73. return 0;
  74. }
  75. static int davinci_direction_in(struct gpio_chip *chip, unsigned offset)
  76. {
  77. return __davinci_direction(chip, offset, false, 0);
  78. }
  79. static int
  80. davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
  81. {
  82. return __davinci_direction(chip, offset, true, value);
  83. }
  84. /*
  85. * Read the pin's value (works even if it's set up as output);
  86. * returns zero/nonzero.
  87. *
  88. * Note that changes are synched to the GPIO clock, so reading values back
  89. * right after you've set them may give old values.
  90. */
  91. static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
  92. {
  93. struct davinci_gpio_controller *d = gpiochip_get_data(chip);
  94. struct davinci_gpio_regs __iomem *g;
  95. int bank = offset / 32;
  96. g = d->regs[bank];
  97. return !!(__gpio_mask(offset) & readl_relaxed(&g->in_data));
  98. }
  99. /*
  100. * Assuming the pin is muxed as a gpio output, set its output value.
  101. */
  102. static void
  103. davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  104. {
  105. struct davinci_gpio_controller *d = gpiochip_get_data(chip);
  106. struct davinci_gpio_regs __iomem *g;
  107. int bank = offset / 32;
  108. g = d->regs[bank];
  109. writel_relaxed(__gpio_mask(offset),
  110. value ? &g->set_data : &g->clr_data);
  111. }
  112. static struct davinci_gpio_platform_data *
  113. davinci_gpio_get_pdata(struct platform_device *pdev)
  114. {
  115. struct device_node *dn = pdev->dev.of_node;
  116. struct davinci_gpio_platform_data *pdata;
  117. int ret;
  118. u32 val;
  119. if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
  120. return dev_get_platdata(&pdev->dev);
  121. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  122. if (!pdata)
  123. return NULL;
  124. ret = of_property_read_u32(dn, "ti,ngpio", &val);
  125. if (ret)
  126. goto of_err;
  127. pdata->ngpio = val;
  128. ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val);
  129. if (ret)
  130. goto of_err;
  131. pdata->gpio_unbanked = val;
  132. return pdata;
  133. of_err:
  134. dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
  135. return NULL;
  136. }
  137. static int davinci_gpio_probe(struct platform_device *pdev)
  138. {
  139. static int ctrl_num, bank_base;
  140. int gpio, bank, i, ret = 0;
  141. unsigned int ngpio, nbank, nirq;
  142. struct davinci_gpio_controller *chips;
  143. struct davinci_gpio_platform_data *pdata;
  144. struct device *dev = &pdev->dev;
  145. struct resource *res;
  146. char label[MAX_LABEL_SIZE];
  147. pdata = davinci_gpio_get_pdata(pdev);
  148. if (!pdata) {
  149. dev_err(dev, "No platform data found\n");
  150. return -EINVAL;
  151. }
  152. dev->platform_data = pdata;
  153. /*
  154. * The gpio banks conceptually expose a segmented bitmap,
  155. * and "ngpio" is one more than the largest zero-based
  156. * bit index that's valid.
  157. */
  158. ngpio = pdata->ngpio;
  159. if (ngpio == 0) {
  160. dev_err(dev, "How many GPIOs?\n");
  161. return -EINVAL;
  162. }
  163. if (WARN_ON(ARCH_NR_GPIOS < ngpio))
  164. ngpio = ARCH_NR_GPIOS;
  165. /*
  166. * If there are unbanked interrupts then the number of
  167. * interrupts is equal to number of gpios else all are banked so
  168. * number of interrupts is equal to number of banks(each with 16 gpios)
  169. */
  170. if (pdata->gpio_unbanked)
  171. nirq = pdata->gpio_unbanked;
  172. else
  173. nirq = DIV_ROUND_UP(ngpio, 16);
  174. nbank = DIV_ROUND_UP(ngpio, 32);
  175. chips = devm_kcalloc(dev,
  176. nbank, sizeof(struct davinci_gpio_controller),
  177. GFP_KERNEL);
  178. if (!chips)
  179. return -ENOMEM;
  180. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  181. gpio_base = devm_ioremap_resource(dev, res);
  182. if (IS_ERR(gpio_base))
  183. return PTR_ERR(gpio_base);
  184. for (i = 0; i < nirq; i++) {
  185. chips->irqs[i] = platform_get_irq(pdev, i);
  186. if (chips->irqs[i] < 0) {
  187. if (chips->irqs[i] != -EPROBE_DEFER)
  188. dev_info(dev, "IRQ not populated, err = %d\n",
  189. chips->irqs[i]);
  190. return chips->irqs[i];
  191. }
  192. }
  193. snprintf(label, MAX_LABEL_SIZE, "davinci_gpio.%d", ctrl_num++);
  194. chips->chip.label = devm_kstrdup(dev, label, GFP_KERNEL);
  195. if (!chips->chip.label)
  196. return -ENOMEM;
  197. chips->chip.direction_input = davinci_direction_in;
  198. chips->chip.get = davinci_gpio_get;
  199. chips->chip.direction_output = davinci_direction_out;
  200. chips->chip.set = davinci_gpio_set;
  201. chips->chip.ngpio = ngpio;
  202. chips->chip.base = bank_base;
  203. #ifdef CONFIG_OF_GPIO
  204. chips->chip.of_gpio_n_cells = 2;
  205. chips->chip.parent = dev;
  206. chips->chip.of_node = dev->of_node;
  207. if (of_property_read_bool(dev->of_node, "gpio-ranges")) {
  208. chips->chip.request = gpiochip_generic_request;
  209. chips->chip.free = gpiochip_generic_free;
  210. }
  211. #endif
  212. spin_lock_init(&chips->lock);
  213. bank_base += ngpio;
  214. for (gpio = 0, bank = 0; gpio < ngpio; gpio += 32, bank++)
  215. chips->regs[bank] = gpio_base + offset_array[bank];
  216. ret = devm_gpiochip_add_data(dev, &chips->chip, chips);
  217. if (ret)
  218. goto err;
  219. platform_set_drvdata(pdev, chips);
  220. ret = davinci_gpio_irq_setup(pdev);
  221. if (ret)
  222. goto err;
  223. return 0;
  224. err:
  225. /* Revert the static variable increments */
  226. ctrl_num--;
  227. bank_base -= ngpio;
  228. return ret;
  229. }
  230. /*--------------------------------------------------------------------------*/
  231. /*
  232. * We expect irqs will normally be set up as input pins, but they can also be
  233. * used as output pins ... which is convenient for testing.
  234. *
  235. * NOTE: The first few GPIOs also have direct INTC hookups in addition
  236. * to their GPIOBNK0 irq, with a bit less overhead.
  237. *
  238. * All those INTC hookups (direct, plus several IRQ banks) can also
  239. * serve as EDMA event triggers.
  240. */
  241. static void gpio_irq_disable(struct irq_data *d)
  242. {
  243. struct davinci_gpio_regs __iomem *g = irq2regs(d);
  244. u32 mask = (u32) irq_data_get_irq_handler_data(d);
  245. writel_relaxed(mask, &g->clr_falling);
  246. writel_relaxed(mask, &g->clr_rising);
  247. }
  248. static void gpio_irq_enable(struct irq_data *d)
  249. {
  250. struct davinci_gpio_regs __iomem *g = irq2regs(d);
  251. u32 mask = (u32) irq_data_get_irq_handler_data(d);
  252. unsigned status = irqd_get_trigger_type(d);
  253. status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
  254. if (!status)
  255. status = IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
  256. if (status & IRQ_TYPE_EDGE_FALLING)
  257. writel_relaxed(mask, &g->set_falling);
  258. if (status & IRQ_TYPE_EDGE_RISING)
  259. writel_relaxed(mask, &g->set_rising);
  260. }
  261. static int gpio_irq_type(struct irq_data *d, unsigned trigger)
  262. {
  263. if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
  264. return -EINVAL;
  265. return 0;
  266. }
  267. static struct irq_chip gpio_irqchip = {
  268. .name = "GPIO",
  269. .irq_enable = gpio_irq_enable,
  270. .irq_disable = gpio_irq_disable,
  271. .irq_set_type = gpio_irq_type,
  272. .flags = IRQCHIP_SET_TYPE_MASKED,
  273. };
  274. static void gpio_irq_handler(struct irq_desc *desc)
  275. {
  276. struct davinci_gpio_regs __iomem *g;
  277. u32 mask = 0xffff;
  278. int bank_num;
  279. struct davinci_gpio_controller *d;
  280. struct davinci_gpio_irq_data *irqdata;
  281. irqdata = (struct davinci_gpio_irq_data *)irq_desc_get_handler_data(desc);
  282. bank_num = irqdata->bank_num;
  283. g = irqdata->regs;
  284. d = irqdata->chip;
  285. /* we only care about one bank */
  286. if ((bank_num % 2) == 1)
  287. mask <<= 16;
  288. /* temporarily mask (level sensitive) parent IRQ */
  289. chained_irq_enter(irq_desc_get_chip(desc), desc);
  290. while (1) {
  291. u32 status;
  292. int bit;
  293. irq_hw_number_t hw_irq;
  294. /* ack any irqs */
  295. status = readl_relaxed(&g->intstat) & mask;
  296. if (!status)
  297. break;
  298. writel_relaxed(status, &g->intstat);
  299. /* now demux them to the right lowlevel handler */
  300. while (status) {
  301. bit = __ffs(status);
  302. status &= ~BIT(bit);
  303. /* Max number of gpios per controller is 144 so
  304. * hw_irq will be in [0..143]
  305. */
  306. hw_irq = (bank_num / 2) * 32 + bit;
  307. generic_handle_irq(
  308. irq_find_mapping(d->irq_domain, hw_irq));
  309. }
  310. }
  311. chained_irq_exit(irq_desc_get_chip(desc), desc);
  312. /* now it may re-trigger */
  313. }
  314. static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
  315. {
  316. struct davinci_gpio_controller *d = gpiochip_get_data(chip);
  317. if (d->irq_domain)
  318. return irq_create_mapping(d->irq_domain, offset);
  319. else
  320. return -ENXIO;
  321. }
  322. static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
  323. {
  324. struct davinci_gpio_controller *d = gpiochip_get_data(chip);
  325. /*
  326. * NOTE: we assume for now that only irqs in the first gpio_chip
  327. * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
  328. */
  329. if (offset < d->gpio_unbanked)
  330. return d->irqs[offset];
  331. else
  332. return -ENODEV;
  333. }
  334. static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
  335. {
  336. struct davinci_gpio_controller *d;
  337. struct davinci_gpio_regs __iomem *g;
  338. u32 mask, i;
  339. d = (struct davinci_gpio_controller *)irq_data_get_irq_handler_data(data);
  340. g = (struct davinci_gpio_regs __iomem *)d->regs[0];
  341. for (i = 0; i < MAX_INT_PER_BANK; i++)
  342. if (data->irq == d->irqs[i])
  343. break;
  344. if (i == MAX_INT_PER_BANK)
  345. return -EINVAL;
  346. mask = __gpio_mask(i);
  347. if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
  348. return -EINVAL;
  349. writel_relaxed(mask, (trigger & IRQ_TYPE_EDGE_FALLING)
  350. ? &g->set_falling : &g->clr_falling);
  351. writel_relaxed(mask, (trigger & IRQ_TYPE_EDGE_RISING)
  352. ? &g->set_rising : &g->clr_rising);
  353. return 0;
  354. }
  355. static int
  356. davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq,
  357. irq_hw_number_t hw)
  358. {
  359. struct davinci_gpio_controller *chips =
  360. (struct davinci_gpio_controller *)d->host_data;
  361. struct davinci_gpio_regs __iomem *g = chips->regs[hw / 32];
  362. irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq,
  363. "davinci_gpio");
  364. irq_set_irq_type(irq, IRQ_TYPE_NONE);
  365. irq_set_chip_data(irq, (__force void *)g);
  366. irq_set_handler_data(irq, (void *)__gpio_mask(hw));
  367. return 0;
  368. }
  369. static const struct irq_domain_ops davinci_gpio_irq_ops = {
  370. .map = davinci_gpio_irq_map,
  371. .xlate = irq_domain_xlate_onetwocell,
  372. };
  373. static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
  374. {
  375. static struct irq_chip_type gpio_unbanked;
  376. gpio_unbanked = *irq_data_get_chip_type(irq_get_irq_data(irq));
  377. return &gpio_unbanked.chip;
  378. };
  379. static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
  380. {
  381. static struct irq_chip gpio_unbanked;
  382. gpio_unbanked = *irq_get_chip(irq);
  383. return &gpio_unbanked;
  384. };
  385. static const struct of_device_id davinci_gpio_ids[];
  386. /*
  387. * NOTE: for suspend/resume, probably best to make a platform_device with
  388. * suspend_late/resume_resume calls hooking into results of the set_wake()
  389. * calls ... so if no gpios are wakeup events the clock can be disabled,
  390. * with outputs left at previously set levels, and so that VDD3P3V.IOPWDN0
  391. * (dm6446) can be set appropriately for GPIOV33 pins.
  392. */
  393. static int davinci_gpio_irq_setup(struct platform_device *pdev)
  394. {
  395. unsigned gpio, bank;
  396. int irq;
  397. int ret;
  398. struct clk *clk;
  399. u32 binten = 0;
  400. unsigned ngpio;
  401. struct device *dev = &pdev->dev;
  402. struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
  403. struct davinci_gpio_platform_data *pdata = dev->platform_data;
  404. struct davinci_gpio_regs __iomem *g;
  405. struct irq_domain *irq_domain = NULL;
  406. const struct of_device_id *match;
  407. struct irq_chip *irq_chip;
  408. struct davinci_gpio_irq_data *irqdata;
  409. gpio_get_irq_chip_cb_t gpio_get_irq_chip;
  410. /*
  411. * Use davinci_gpio_get_irq_chip by default to handle non DT cases
  412. */
  413. gpio_get_irq_chip = davinci_gpio_get_irq_chip;
  414. match = of_match_device(of_match_ptr(davinci_gpio_ids),
  415. dev);
  416. if (match)
  417. gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
  418. ngpio = pdata->ngpio;
  419. clk = devm_clk_get(dev, "gpio");
  420. if (IS_ERR(clk)) {
  421. dev_err(dev, "Error %ld getting gpio clock\n", PTR_ERR(clk));
  422. return PTR_ERR(clk);
  423. }
  424. ret = clk_prepare_enable(clk);
  425. if (ret)
  426. return ret;
  427. if (!pdata->gpio_unbanked) {
  428. irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
  429. if (irq < 0) {
  430. dev_err(dev, "Couldn't allocate IRQ numbers\n");
  431. clk_disable_unprepare(clk);
  432. return irq;
  433. }
  434. irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
  435. &davinci_gpio_irq_ops,
  436. chips);
  437. if (!irq_domain) {
  438. dev_err(dev, "Couldn't register an IRQ domain\n");
  439. clk_disable_unprepare(clk);
  440. return -ENODEV;
  441. }
  442. }
  443. /*
  444. * Arrange gpio_to_irq() support, handling either direct IRQs or
  445. * banked IRQs. Having GPIOs in the first GPIO bank use direct
  446. * IRQs, while the others use banked IRQs, would need some setup
  447. * tweaks to recognize hardware which can do that.
  448. */
  449. chips->chip.to_irq = gpio_to_irq_banked;
  450. chips->irq_domain = irq_domain;
  451. /*
  452. * AINTC can handle direct/unbanked IRQs for GPIOs, with the GPIO
  453. * controller only handling trigger modes. We currently assume no
  454. * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs.
  455. */
  456. if (pdata->gpio_unbanked) {
  457. /* pass "bank 0" GPIO IRQs to AINTC */
  458. chips->chip.to_irq = gpio_to_irq_unbanked;
  459. chips->gpio_unbanked = pdata->gpio_unbanked;
  460. binten = GENMASK(pdata->gpio_unbanked / 16, 0);
  461. /* AINTC handles mask/unmask; GPIO handles triggering */
  462. irq = chips->irqs[0];
  463. irq_chip = gpio_get_irq_chip(irq);
  464. irq_chip->name = "GPIO-AINTC";
  465. irq_chip->irq_set_type = gpio_irq_type_unbanked;
  466. /* default trigger: both edges */
  467. g = chips->regs[0];
  468. writel_relaxed(~0, &g->set_falling);
  469. writel_relaxed(~0, &g->set_rising);
  470. /* set the direct IRQs up to use that irqchip */
  471. for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++) {
  472. irq_set_chip(chips->irqs[gpio], irq_chip);
  473. irq_set_handler_data(chips->irqs[gpio], chips);
  474. irq_set_status_flags(chips->irqs[gpio],
  475. IRQ_TYPE_EDGE_BOTH);
  476. }
  477. goto done;
  478. }
  479. /*
  480. * Or, AINTC can handle IRQs for banks of 16 GPIO IRQs, which we
  481. * then chain through our own handler.
  482. */
  483. for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 16) {
  484. /* disabled by default, enabled only as needed
  485. * There are register sets for 32 GPIOs. 2 banks of 16
  486. * GPIOs are covered by each set of registers hence divide by 2
  487. */
  488. g = chips->regs[bank / 2];
  489. writel_relaxed(~0, &g->clr_falling);
  490. writel_relaxed(~0, &g->clr_rising);
  491. /*
  492. * Each chip handles 32 gpios, and each irq bank consists of 16
  493. * gpio irqs. Pass the irq bank's corresponding controller to
  494. * the chained irq handler.
  495. */
  496. irqdata = devm_kzalloc(&pdev->dev,
  497. sizeof(struct
  498. davinci_gpio_irq_data),
  499. GFP_KERNEL);
  500. if (!irqdata) {
  501. clk_disable_unprepare(clk);
  502. return -ENOMEM;
  503. }
  504. irqdata->regs = g;
  505. irqdata->bank_num = bank;
  506. irqdata->chip = chips;
  507. irq_set_chained_handler_and_data(chips->irqs[bank],
  508. gpio_irq_handler, irqdata);
  509. binten |= BIT(bank);
  510. }
  511. done:
  512. /*
  513. * BINTEN -- per-bank interrupt enable. genirq would also let these
  514. * bits be set/cleared dynamically.
  515. */
  516. writel_relaxed(binten, gpio_base + BINTEN);
  517. return 0;
  518. }
  519. static const struct of_device_id davinci_gpio_ids[] = {
  520. { .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip},
  521. { .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip},
  522. { /* sentinel */ },
  523. };
  524. MODULE_DEVICE_TABLE(of, davinci_gpio_ids);
  525. static struct platform_driver davinci_gpio_driver = {
  526. .probe = davinci_gpio_probe,
  527. .driver = {
  528. .name = "davinci_gpio",
  529. .of_match_table = of_match_ptr(davinci_gpio_ids),
  530. },
  531. };
  532. /**
  533. * GPIO driver registration needs to be done before machine_init functions
  534. * access GPIO. Hence davinci_gpio_drv_reg() is a postcore_initcall.
  535. */
  536. static int __init davinci_gpio_drv_reg(void)
  537. {
  538. return platform_driver_register(&davinci_gpio_driver);
  539. }
  540. postcore_initcall(davinci_gpio_drv_reg);