gpio.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. /*
  2. * linux/arch/arm/mach-at91/gpio.c
  3. *
  4. * Copyright (C) 2005 HP Labs
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/errno.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/irq.h>
  15. #include <linux/debugfs.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/kernel.h>
  18. #include <linux/list.h>
  19. #include <linux/module.h>
  20. #include <linux/io.h>
  21. #include <mach/hardware.h>
  22. #include <mach/at91_pio.h>
  23. #include <mach/gpio.h>
  24. #include <asm/gpio.h>
  25. #include "generic.h"
  26. struct at91_gpio_chip {
  27. struct gpio_chip chip;
  28. struct at91_gpio_chip *next; /* Bank sharing same clock */
  29. struct at91_gpio_bank *bank; /* Bank definition */
  30. void __iomem *regbase; /* Base of register bank */
  31. };
  32. #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
  33. static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);
  34. static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);
  35. static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset);
  36. static int at91_gpiolib_direction_output(struct gpio_chip *chip,
  37. unsigned offset, int val);
  38. static int at91_gpiolib_direction_input(struct gpio_chip *chip,
  39. unsigned offset);
  40. static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset);
  41. #define AT91_GPIO_CHIP(name, base_gpio, nr_gpio) \
  42. { \
  43. .chip = { \
  44. .label = name, \
  45. .request = at91_gpiolib_request, \
  46. .direction_input = at91_gpiolib_direction_input, \
  47. .direction_output = at91_gpiolib_direction_output, \
  48. .get = at91_gpiolib_get, \
  49. .set = at91_gpiolib_set, \
  50. .dbg_show = at91_gpiolib_dbg_show, \
  51. .base = base_gpio, \
  52. .ngpio = nr_gpio, \
  53. }, \
  54. }
  55. static struct at91_gpio_chip gpio_chip[] = {
  56. AT91_GPIO_CHIP("A", 0x00 + PIN_BASE, 32),
  57. AT91_GPIO_CHIP("B", 0x20 + PIN_BASE, 32),
  58. AT91_GPIO_CHIP("C", 0x40 + PIN_BASE, 32),
  59. AT91_GPIO_CHIP("D", 0x60 + PIN_BASE, 32),
  60. AT91_GPIO_CHIP("E", 0x80 + PIN_BASE, 32),
  61. };
  62. static int gpio_banks;
  63. static inline void __iomem *pin_to_controller(unsigned pin)
  64. {
  65. pin -= PIN_BASE;
  66. pin /= 32;
  67. if (likely(pin < gpio_banks))
  68. return gpio_chip[pin].regbase;
  69. return NULL;
  70. }
  71. static inline unsigned pin_to_mask(unsigned pin)
  72. {
  73. pin -= PIN_BASE;
  74. return 1 << (pin % 32);
  75. }
  76. /*--------------------------------------------------------------------------*/
  77. /* Not all hardware capabilities are exposed through these calls; they
  78. * only encapsulate the most common features and modes. (So if you
  79. * want to change signals in groups, do it directly.)
  80. *
  81. * Bootloaders will usually handle some of the pin multiplexing setup.
  82. * The intent is certainly that by the time Linux is fully booted, all
  83. * pins should have been fully initialized. These setup calls should
  84. * only be used by board setup routines, or possibly in driver probe().
  85. *
  86. * For bootloaders doing all that setup, these calls could be inlined
  87. * as NOPs so Linux won't duplicate any setup code
  88. */
  89. /*
  90. * mux the pin to the "GPIO" peripheral role.
  91. */
  92. int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup)
  93. {
  94. void __iomem *pio = pin_to_controller(pin);
  95. unsigned mask = pin_to_mask(pin);
  96. if (!pio)
  97. return -EINVAL;
  98. __raw_writel(mask, pio + PIO_IDR);
  99. __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
  100. __raw_writel(mask, pio + PIO_PER);
  101. return 0;
  102. }
  103. EXPORT_SYMBOL(at91_set_GPIO_periph);
  104. /*
  105. * mux the pin to the "A" internal peripheral role.
  106. */
  107. int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup)
  108. {
  109. void __iomem *pio = pin_to_controller(pin);
  110. unsigned mask = pin_to_mask(pin);
  111. if (!pio)
  112. return -EINVAL;
  113. __raw_writel(mask, pio + PIO_IDR);
  114. __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
  115. __raw_writel(mask, pio + PIO_ASR);
  116. __raw_writel(mask, pio + PIO_PDR);
  117. return 0;
  118. }
  119. EXPORT_SYMBOL(at91_set_A_periph);
  120. /*
  121. * mux the pin to the "B" internal peripheral role.
  122. */
  123. int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup)
  124. {
  125. void __iomem *pio = pin_to_controller(pin);
  126. unsigned mask = pin_to_mask(pin);
  127. if (!pio)
  128. return -EINVAL;
  129. __raw_writel(mask, pio + PIO_IDR);
  130. __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
  131. __raw_writel(mask, pio + PIO_BSR);
  132. __raw_writel(mask, pio + PIO_PDR);
  133. return 0;
  134. }
  135. EXPORT_SYMBOL(at91_set_B_periph);
  136. /*
  137. * mux the pin to the gpio controller (instead of "A" or "B" peripheral), and
  138. * configure it for an input.
  139. */
  140. int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)
  141. {
  142. void __iomem *pio = pin_to_controller(pin);
  143. unsigned mask = pin_to_mask(pin);
  144. if (!pio)
  145. return -EINVAL;
  146. __raw_writel(mask, pio + PIO_IDR);
  147. __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
  148. __raw_writel(mask, pio + PIO_ODR);
  149. __raw_writel(mask, pio + PIO_PER);
  150. return 0;
  151. }
  152. EXPORT_SYMBOL(at91_set_gpio_input);
  153. /*
  154. * mux the pin to the gpio controller (instead of "A" or "B" peripheral),
  155. * and configure it for an output.
  156. */
  157. int __init_or_module at91_set_gpio_output(unsigned pin, int value)
  158. {
  159. void __iomem *pio = pin_to_controller(pin);
  160. unsigned mask = pin_to_mask(pin);
  161. if (!pio)
  162. return -EINVAL;
  163. __raw_writel(mask, pio + PIO_IDR);
  164. __raw_writel(mask, pio + PIO_PUDR);
  165. __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
  166. __raw_writel(mask, pio + PIO_OER);
  167. __raw_writel(mask, pio + PIO_PER);
  168. return 0;
  169. }
  170. EXPORT_SYMBOL(at91_set_gpio_output);
  171. /*
  172. * enable/disable the glitch filter; mostly used with IRQ handling.
  173. */
  174. int __init_or_module at91_set_deglitch(unsigned pin, int is_on)
  175. {
  176. void __iomem *pio = pin_to_controller(pin);
  177. unsigned mask = pin_to_mask(pin);
  178. if (!pio)
  179. return -EINVAL;
  180. __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));
  181. return 0;
  182. }
  183. EXPORT_SYMBOL(at91_set_deglitch);
  184. /*
  185. * enable/disable the multi-driver; This is only valid for output and
  186. * allows the output pin to run as an open collector output.
  187. */
  188. int __init_or_module at91_set_multi_drive(unsigned pin, int is_on)
  189. {
  190. void __iomem *pio = pin_to_controller(pin);
  191. unsigned mask = pin_to_mask(pin);
  192. if (!pio)
  193. return -EINVAL;
  194. __raw_writel(mask, pio + (is_on ? PIO_MDER : PIO_MDDR));
  195. return 0;
  196. }
  197. EXPORT_SYMBOL(at91_set_multi_drive);
  198. /*
  199. * assuming the pin is muxed as a gpio output, set its value.
  200. */
  201. int at91_set_gpio_value(unsigned pin, int value)
  202. {
  203. void __iomem *pio = pin_to_controller(pin);
  204. unsigned mask = pin_to_mask(pin);
  205. if (!pio)
  206. return -EINVAL;
  207. __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
  208. return 0;
  209. }
  210. EXPORT_SYMBOL(at91_set_gpio_value);
  211. /*
  212. * read the pin's value (works even if it's not muxed as a gpio).
  213. */
  214. int at91_get_gpio_value(unsigned pin)
  215. {
  216. void __iomem *pio = pin_to_controller(pin);
  217. unsigned mask = pin_to_mask(pin);
  218. u32 pdsr;
  219. if (!pio)
  220. return -EINVAL;
  221. pdsr = __raw_readl(pio + PIO_PDSR);
  222. return (pdsr & mask) != 0;
  223. }
  224. EXPORT_SYMBOL(at91_get_gpio_value);
  225. /*--------------------------------------------------------------------------*/
  226. #ifdef CONFIG_PM
  227. static u32 wakeups[MAX_GPIO_BANKS];
  228. static u32 backups[MAX_GPIO_BANKS];
  229. static int gpio_irq_set_wake(unsigned pin, unsigned state)
  230. {
  231. unsigned mask = pin_to_mask(pin);
  232. unsigned bank = (pin - PIN_BASE) / 32;
  233. if (unlikely(bank >= MAX_GPIO_BANKS))
  234. return -EINVAL;
  235. if (state)
  236. wakeups[bank] |= mask;
  237. else
  238. wakeups[bank] &= ~mask;
  239. set_irq_wake(gpio_chip[bank].bank->id, state);
  240. return 0;
  241. }
  242. void at91_gpio_suspend(void)
  243. {
  244. int i;
  245. for (i = 0; i < gpio_banks; i++) {
  246. void __iomem *pio = gpio_chip[i].regbase;
  247. backups[i] = __raw_readl(pio + PIO_IMR);
  248. __raw_writel(backups[i], pio + PIO_IDR);
  249. __raw_writel(wakeups[i], pio + PIO_IER);
  250. if (!wakeups[i])
  251. clk_disable(gpio_chip[i].bank->clock);
  252. else {
  253. #ifdef CONFIG_PM_DEBUG
  254. printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]);
  255. #endif
  256. }
  257. }
  258. }
  259. void at91_gpio_resume(void)
  260. {
  261. int i;
  262. for (i = 0; i < gpio_banks; i++) {
  263. void __iomem *pio = gpio_chip[i].regbase;
  264. if (!wakeups[i])
  265. clk_enable(gpio_chip[i].bank->clock);
  266. __raw_writel(wakeups[i], pio + PIO_IDR);
  267. __raw_writel(backups[i], pio + PIO_IER);
  268. }
  269. }
  270. #else
  271. #define gpio_irq_set_wake NULL
  272. #endif
  273. /* Several AIC controller irqs are dispatched through this GPIO handler.
  274. * To use any AT91_PIN_* as an externally triggered IRQ, first call
  275. * at91_set_gpio_input() then maybe enable its glitch filter.
  276. * Then just request_irq() with the pin ID; it works like any ARM IRQ
  277. * handler, though it always triggers on rising and falling edges.
  278. *
  279. * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after
  280. * configuring them with at91_set_a_periph() or at91_set_b_periph().
  281. * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering.
  282. */
  283. static void gpio_irq_mask(unsigned pin)
  284. {
  285. void __iomem *pio = pin_to_controller(pin);
  286. unsigned mask = pin_to_mask(pin);
  287. if (pio)
  288. __raw_writel(mask, pio + PIO_IDR);
  289. }
  290. static void gpio_irq_unmask(unsigned pin)
  291. {
  292. void __iomem *pio = pin_to_controller(pin);
  293. unsigned mask = pin_to_mask(pin);
  294. if (pio)
  295. __raw_writel(mask, pio + PIO_IER);
  296. }
  297. static int gpio_irq_type(unsigned pin, unsigned type)
  298. {
  299. switch (type) {
  300. case IRQ_TYPE_NONE:
  301. case IRQ_TYPE_EDGE_BOTH:
  302. return 0;
  303. default:
  304. return -EINVAL;
  305. }
  306. }
  307. static struct irq_chip gpio_irqchip = {
  308. .name = "GPIO",
  309. .mask = gpio_irq_mask,
  310. .unmask = gpio_irq_unmask,
  311. .set_type = gpio_irq_type,
  312. .set_wake = gpio_irq_set_wake,
  313. };
  314. static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
  315. {
  316. unsigned pin;
  317. struct irq_desc *gpio;
  318. struct at91_gpio_chip *at91_gpio;
  319. void __iomem *pio;
  320. u32 isr;
  321. at91_gpio = get_irq_chip_data(irq);
  322. pio = at91_gpio->regbase;
  323. /* temporarily mask (level sensitive) parent IRQ */
  324. desc->chip->ack(irq);
  325. for (;;) {
  326. /* Reading ISR acks pending (edge triggered) GPIO interrupts.
  327. * When there none are pending, we're finished unless we need
  328. * to process multiple banks (like ID_PIOCDE on sam9263).
  329. */
  330. isr = __raw_readl(pio + PIO_ISR) & __raw_readl(pio + PIO_IMR);
  331. if (!isr) {
  332. if (!at91_gpio->next)
  333. break;
  334. at91_gpio = at91_gpio->next;
  335. pio = at91_gpio->regbase;
  336. continue;
  337. }
  338. pin = at91_gpio->chip.base;
  339. gpio = &irq_desc[pin];
  340. while (isr) {
  341. if (isr & 1) {
  342. if (unlikely(gpio->depth)) {
  343. /*
  344. * The core ARM interrupt handler lazily disables IRQs so
  345. * another IRQ must be generated before it actually gets
  346. * here to be disabled on the GPIO controller.
  347. */
  348. gpio_irq_mask(pin);
  349. }
  350. else
  351. generic_handle_irq(pin);
  352. }
  353. pin++;
  354. gpio++;
  355. isr >>= 1;
  356. }
  357. }
  358. desc->chip->unmask(irq);
  359. /* now it may re-trigger */
  360. }
  361. /*--------------------------------------------------------------------------*/
  362. #ifdef CONFIG_DEBUG_FS
  363. static int at91_gpio_show(struct seq_file *s, void *unused)
  364. {
  365. int bank, j;
  366. /* print heading */
  367. seq_printf(s, "Pin\t");
  368. for (bank = 0; bank < gpio_banks; bank++) {
  369. seq_printf(s, "PIO%c\t", 'A' + bank);
  370. };
  371. seq_printf(s, "\n\n");
  372. /* print pin status */
  373. for (j = 0; j < 32; j++) {
  374. seq_printf(s, "%i:\t", j);
  375. for (bank = 0; bank < gpio_banks; bank++) {
  376. unsigned pin = PIN_BASE + (32 * bank) + j;
  377. void __iomem *pio = pin_to_controller(pin);
  378. unsigned mask = pin_to_mask(pin);
  379. if (__raw_readl(pio + PIO_PSR) & mask)
  380. seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
  381. else
  382. seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A");
  383. seq_printf(s, "\t");
  384. }
  385. seq_printf(s, "\n");
  386. }
  387. return 0;
  388. }
  389. static int at91_gpio_open(struct inode *inode, struct file *file)
  390. {
  391. return single_open(file, at91_gpio_show, NULL);
  392. }
  393. static const struct file_operations at91_gpio_operations = {
  394. .open = at91_gpio_open,
  395. .read = seq_read,
  396. .llseek = seq_lseek,
  397. .release = single_release,
  398. };
  399. static int __init at91_gpio_debugfs_init(void)
  400. {
  401. /* /sys/kernel/debug/at91_gpio */
  402. (void) debugfs_create_file("at91_gpio", S_IFREG | S_IRUGO, NULL, NULL, &at91_gpio_operations);
  403. return 0;
  404. }
  405. postcore_initcall(at91_gpio_debugfs_init);
  406. #endif
  407. /*--------------------------------------------------------------------------*/
  408. /*
  409. * This lock class tells lockdep that GPIO irqs are in a different
  410. * category than their parents, so it won't report false recursion.
  411. */
  412. static struct lock_class_key gpio_lock_class;
  413. /*
  414. * Called from the processor-specific init to enable GPIO interrupt support.
  415. */
  416. void __init at91_gpio_irq_setup(void)
  417. {
  418. unsigned pioc, pin;
  419. struct at91_gpio_chip *this, *prev;
  420. for (pioc = 0, pin = PIN_BASE, this = gpio_chip, prev = NULL;
  421. pioc++ < gpio_banks;
  422. prev = this, this++) {
  423. unsigned id = this->bank->id;
  424. unsigned i;
  425. __raw_writel(~0, this->regbase + PIO_IDR);
  426. for (i = 0, pin = this->chip.base; i < 32; i++, pin++) {
  427. lockdep_set_class(&irq_desc[pin].lock, &gpio_lock_class);
  428. /*
  429. * Can use the "simple" and not "edge" handler since it's
  430. * shorter, and the AIC handles interrupts sanely.
  431. */
  432. set_irq_chip(pin, &gpio_irqchip);
  433. set_irq_handler(pin, handle_simple_irq);
  434. set_irq_flags(pin, IRQF_VALID);
  435. }
  436. /* The toplevel handler handles one bank of GPIOs, except
  437. * AT91SAM9263_ID_PIOCDE handles three... PIOC is first in
  438. * the list, so we only set up that handler.
  439. */
  440. if (prev && prev->next == this)
  441. continue;
  442. set_irq_chip_data(id, this);
  443. set_irq_chained_handler(id, gpio_irq_handler);
  444. }
  445. pr_info("AT91: %d gpio irqs in %d banks\n", pin - PIN_BASE, gpio_banks);
  446. }
  447. /* gpiolib support */
  448. static int at91_gpiolib_direction_input(struct gpio_chip *chip,
  449. unsigned offset)
  450. {
  451. struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
  452. void __iomem *pio = at91_gpio->regbase;
  453. unsigned mask = 1 << offset;
  454. __raw_writel(mask, pio + PIO_ODR);
  455. return 0;
  456. }
  457. static int at91_gpiolib_direction_output(struct gpio_chip *chip,
  458. unsigned offset, int val)
  459. {
  460. struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
  461. void __iomem *pio = at91_gpio->regbase;
  462. unsigned mask = 1 << offset;
  463. __raw_writel(mask, pio + (val ? PIO_SODR : PIO_CODR));
  464. __raw_writel(mask, pio + PIO_OER);
  465. return 0;
  466. }
  467. static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset)
  468. {
  469. struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
  470. void __iomem *pio = at91_gpio->regbase;
  471. unsigned mask = 1 << offset;
  472. u32 pdsr;
  473. pdsr = __raw_readl(pio + PIO_PDSR);
  474. return (pdsr & mask) != 0;
  475. }
  476. static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val)
  477. {
  478. struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
  479. void __iomem *pio = at91_gpio->regbase;
  480. unsigned mask = 1 << offset;
  481. __raw_writel(mask, pio + (val ? PIO_SODR : PIO_CODR));
  482. }
  483. static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset)
  484. {
  485. unsigned pin = chip->base + offset;
  486. void __iomem *pio = pin_to_controller(pin);
  487. unsigned mask = pin_to_mask(pin);
  488. /* Cannot request GPIOs that are in alternate function mode */
  489. if (!(__raw_readl(pio + PIO_PSR) & mask))
  490. return -EPERM;
  491. return 0;
  492. }
  493. static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
  494. {
  495. int i;
  496. for (i = 0; i < chip->ngpio; i++) {
  497. unsigned pin = chip->base + i;
  498. void __iomem *pio = pin_to_controller(pin);
  499. unsigned mask = pin_to_mask(pin);
  500. const char *gpio_label;
  501. gpio_label = gpiochip_is_requested(chip, i);
  502. if (gpio_label) {
  503. seq_printf(s, "[%s] GPIO%s%d: ",
  504. gpio_label, chip->label, i);
  505. if (__raw_readl(pio + PIO_PSR) & mask)
  506. seq_printf(s, "[gpio] %s\n",
  507. at91_get_gpio_value(pin) ?
  508. "set" : "clear");
  509. else
  510. seq_printf(s, "[periph %s]\n",
  511. __raw_readl(pio + PIO_ABSR) &
  512. mask ? "B" : "A");
  513. }
  514. }
  515. }
  516. /*
  517. * Called from the processor-specific init to enable GPIO pin support.
  518. */
  519. void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
  520. {
  521. unsigned i;
  522. struct at91_gpio_chip *at91_gpio, *last = NULL;
  523. BUG_ON(nr_banks > MAX_GPIO_BANKS);
  524. gpio_banks = nr_banks;
  525. for (i = 0; i < nr_banks; i++) {
  526. at91_gpio = &gpio_chip[i];
  527. at91_gpio->bank = &data[i];
  528. at91_gpio->chip.base = PIN_BASE + i * 32;
  529. at91_gpio->regbase = at91_gpio->bank->offset +
  530. (void __iomem *)AT91_VA_BASE_SYS;
  531. /* enable PIO controller's clock */
  532. clk_enable(at91_gpio->bank->clock);
  533. /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */
  534. if (last && last->bank->id == at91_gpio->bank->id)
  535. last->next = at91_gpio;
  536. last = at91_gpio;
  537. gpiochip_add(&at91_gpio->chip);
  538. }
  539. }