gpio-davinci.c 16 KB

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