gpio-au1000.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /*
  2. * GPIO functions for Au1000, Au1500, Au1100, Au1550, Au1200
  3. *
  4. * Copyright (c) 2009 Manuel Lauss.
  5. *
  6. * Licensed under the terms outlined in the file COPYING.
  7. */
  8. #ifndef _ALCHEMY_GPIO_AU1000_H_
  9. #define _ALCHEMY_GPIO_AU1000_H_
  10. #include <asm/mach-au1x00/au1000.h>
  11. /* The default GPIO numberspace as documented in the Alchemy manuals.
  12. * GPIO0-31 from GPIO1 block, GPIO200-215 from GPIO2 block.
  13. */
  14. #define ALCHEMY_GPIO1_BASE 0
  15. #define ALCHEMY_GPIO2_BASE 200
  16. #define ALCHEMY_GPIO1_NUM 32
  17. #define ALCHEMY_GPIO2_NUM 16
  18. #define ALCHEMY_GPIO1_MAX (ALCHEMY_GPIO1_BASE + ALCHEMY_GPIO1_NUM - 1)
  19. #define ALCHEMY_GPIO2_MAX (ALCHEMY_GPIO2_BASE + ALCHEMY_GPIO2_NUM - 1)
  20. #define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off))
  21. struct gpio;
  22. static inline int au1000_gpio1_to_irq(int gpio)
  23. {
  24. return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE);
  25. }
  26. static inline int au1000_gpio2_to_irq(int gpio)
  27. {
  28. return -ENXIO;
  29. }
  30. static inline int au1000_irq_to_gpio(int irq)
  31. {
  32. if ((irq >= AU1000_GPIO0_INT) && (irq <= AU1000_GPIO31_INT))
  33. return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO0_INT) + 0;
  34. return -ENXIO;
  35. }
  36. static inline int au1500_gpio1_to_irq(int gpio)
  37. {
  38. gpio -= ALCHEMY_GPIO1_BASE;
  39. switch (gpio) {
  40. case 0 ... 15:
  41. case 20:
  42. case 23 ... 28: return MAKE_IRQ(1, gpio);
  43. }
  44. return -ENXIO;
  45. }
  46. static inline int au1500_gpio2_to_irq(int gpio)
  47. {
  48. gpio -= ALCHEMY_GPIO2_BASE;
  49. switch (gpio) {
  50. case 0 ... 3: return MAKE_IRQ(1, 16 + gpio - 0);
  51. case 4 ... 5: return MAKE_IRQ(1, 21 + gpio - 4);
  52. case 6 ... 7: return MAKE_IRQ(1, 29 + gpio - 6);
  53. }
  54. return -ENXIO;
  55. }
  56. static inline int au1500_irq_to_gpio(int irq)
  57. {
  58. switch (irq) {
  59. case AU1500_GPIO0_INT ... AU1500_GPIO15_INT:
  60. case AU1500_GPIO20_INT:
  61. case AU1500_GPIO23_INT ... AU1500_GPIO28_INT:
  62. return ALCHEMY_GPIO1_BASE + (irq - AU1500_GPIO0_INT) + 0;
  63. case AU1500_GPIO200_INT ... AU1500_GPIO203_INT:
  64. return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO200_INT) + 0;
  65. case AU1500_GPIO204_INT ... AU1500_GPIO205_INT:
  66. return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO204_INT) + 4;
  67. case AU1500_GPIO206_INT ... AU1500_GPIO207_INT:
  68. return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO206_INT) + 6;
  69. case AU1500_GPIO208_215_INT:
  70. return ALCHEMY_GPIO2_BASE + 8;
  71. }
  72. return -ENXIO;
  73. }
  74. static inline int au1100_gpio1_to_irq(int gpio)
  75. {
  76. return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE);
  77. }
  78. static inline int au1100_gpio2_to_irq(int gpio)
  79. {
  80. gpio -= ALCHEMY_GPIO2_BASE;
  81. if ((gpio >= 8) && (gpio <= 15))
  82. return MAKE_IRQ(0, 29); /* shared GPIO208_215 */
  83. return -ENXIO;
  84. }
  85. static inline int au1100_irq_to_gpio(int irq)
  86. {
  87. switch (irq) {
  88. case AU1100_GPIO0_INT ... AU1100_GPIO31_INT:
  89. return ALCHEMY_GPIO1_BASE + (irq - AU1100_GPIO0_INT) + 0;
  90. case AU1100_GPIO208_215_INT:
  91. return ALCHEMY_GPIO2_BASE + 8;
  92. }
  93. return -ENXIO;
  94. }
  95. static inline int au1550_gpio1_to_irq(int gpio)
  96. {
  97. gpio -= ALCHEMY_GPIO1_BASE;
  98. switch (gpio) {
  99. case 0 ... 15:
  100. case 20 ... 28: return MAKE_IRQ(1, gpio);
  101. case 16 ... 17: return MAKE_IRQ(1, 18 + gpio - 16);
  102. }
  103. return -ENXIO;
  104. }
  105. static inline int au1550_gpio2_to_irq(int gpio)
  106. {
  107. gpio -= ALCHEMY_GPIO2_BASE;
  108. switch (gpio) {
  109. case 0: return MAKE_IRQ(1, 16);
  110. case 1 ... 5: return MAKE_IRQ(1, 17); /* shared GPIO201_205 */
  111. case 6 ... 7: return MAKE_IRQ(1, 29 + gpio - 6);
  112. case 8 ... 15: return MAKE_IRQ(1, 31); /* shared GPIO208_215 */
  113. }
  114. return -ENXIO;
  115. }
  116. static inline int au1550_irq_to_gpio(int irq)
  117. {
  118. switch (irq) {
  119. case AU1550_GPIO0_INT ... AU1550_GPIO15_INT:
  120. return ALCHEMY_GPIO1_BASE + (irq - AU1550_GPIO0_INT) + 0;
  121. case AU1550_GPIO200_INT:
  122. case AU1550_GPIO201_205_INT:
  123. return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO200_INT) + 0;
  124. case AU1550_GPIO16_INT ... AU1550_GPIO28_INT:
  125. return ALCHEMY_GPIO1_BASE + (irq - AU1550_GPIO16_INT) + 16;
  126. case AU1550_GPIO206_INT ... AU1550_GPIO208_215_INT:
  127. return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO206_INT) + 6;
  128. }
  129. return -ENXIO;
  130. }
  131. static inline int au1200_gpio1_to_irq(int gpio)
  132. {
  133. return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE);
  134. }
  135. static inline int au1200_gpio2_to_irq(int gpio)
  136. {
  137. gpio -= ALCHEMY_GPIO2_BASE;
  138. switch (gpio) {
  139. case 0 ... 2: return MAKE_IRQ(0, 5 + gpio - 0);
  140. case 3: return MAKE_IRQ(0, 22);
  141. case 4 ... 7: return MAKE_IRQ(0, 24 + gpio - 4);
  142. case 8 ... 15: return MAKE_IRQ(0, 28); /* shared GPIO208_215 */
  143. }
  144. return -ENXIO;
  145. }
  146. static inline int au1200_irq_to_gpio(int irq)
  147. {
  148. switch (irq) {
  149. case AU1200_GPIO0_INT ... AU1200_GPIO31_INT:
  150. return ALCHEMY_GPIO1_BASE + (irq - AU1200_GPIO0_INT) + 0;
  151. case AU1200_GPIO200_INT ... AU1200_GPIO202_INT:
  152. return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO200_INT) + 0;
  153. case AU1200_GPIO203_INT:
  154. return ALCHEMY_GPIO2_BASE + 3;
  155. case AU1200_GPIO204_INT ... AU1200_GPIO208_215_INT:
  156. return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO204_INT) + 4;
  157. }
  158. return -ENXIO;
  159. }
  160. /*
  161. * GPIO1 block macros for common linux gpio functions.
  162. */
  163. static inline void alchemy_gpio1_set_value(int gpio, int v)
  164. {
  165. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
  166. unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR;
  167. au_writel(mask, r);
  168. au_sync();
  169. }
  170. static inline int alchemy_gpio1_get_value(int gpio)
  171. {
  172. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
  173. return au_readl(SYS_PINSTATERD) & mask;
  174. }
  175. static inline int alchemy_gpio1_direction_input(int gpio)
  176. {
  177. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
  178. au_writel(mask, SYS_TRIOUTCLR);
  179. au_sync();
  180. return 0;
  181. }
  182. static inline int alchemy_gpio1_direction_output(int gpio, int v)
  183. {
  184. /* hardware switches to "output" mode when one of the two
  185. * "set_value" registers is accessed.
  186. */
  187. alchemy_gpio1_set_value(gpio, v);
  188. return 0;
  189. }
  190. static inline int alchemy_gpio1_is_valid(int gpio)
  191. {
  192. return ((gpio >= ALCHEMY_GPIO1_BASE) && (gpio <= ALCHEMY_GPIO1_MAX));
  193. }
  194. static inline int alchemy_gpio1_to_irq(int gpio)
  195. {
  196. switch (alchemy_get_cputype()) {
  197. case ALCHEMY_CPU_AU1000:
  198. return au1000_gpio1_to_irq(gpio);
  199. case ALCHEMY_CPU_AU1100:
  200. return au1100_gpio1_to_irq(gpio);
  201. case ALCHEMY_CPU_AU1500:
  202. return au1500_gpio1_to_irq(gpio);
  203. case ALCHEMY_CPU_AU1550:
  204. return au1550_gpio1_to_irq(gpio);
  205. case ALCHEMY_CPU_AU1200:
  206. return au1200_gpio1_to_irq(gpio);
  207. }
  208. return -ENXIO;
  209. }
  210. /*
  211. * GPIO2 block macros for common linux GPIO functions. The 'gpio'
  212. * parameter must be in range of ALCHEMY_GPIO2_BASE..ALCHEMY_GPIO2_MAX.
  213. */
  214. static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out)
  215. {
  216. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE);
  217. unsigned long d = au_readl(GPIO2_DIR);
  218. if (to_out)
  219. d |= mask;
  220. else
  221. d &= ~mask;
  222. au_writel(d, GPIO2_DIR);
  223. au_sync();
  224. }
  225. static inline void alchemy_gpio2_set_value(int gpio, int v)
  226. {
  227. unsigned long mask;
  228. mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE);
  229. au_writel(mask, GPIO2_OUTPUT);
  230. au_sync();
  231. }
  232. static inline int alchemy_gpio2_get_value(int gpio)
  233. {
  234. return au_readl(GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE));
  235. }
  236. static inline int alchemy_gpio2_direction_input(int gpio)
  237. {
  238. unsigned long flags;
  239. local_irq_save(flags);
  240. __alchemy_gpio2_mod_dir(gpio, 0);
  241. local_irq_restore(flags);
  242. return 0;
  243. }
  244. static inline int alchemy_gpio2_direction_output(int gpio, int v)
  245. {
  246. unsigned long flags;
  247. alchemy_gpio2_set_value(gpio, v);
  248. local_irq_save(flags);
  249. __alchemy_gpio2_mod_dir(gpio, 1);
  250. local_irq_restore(flags);
  251. return 0;
  252. }
  253. static inline int alchemy_gpio2_is_valid(int gpio)
  254. {
  255. return ((gpio >= ALCHEMY_GPIO2_BASE) && (gpio <= ALCHEMY_GPIO2_MAX));
  256. }
  257. static inline int alchemy_gpio2_to_irq(int gpio)
  258. {
  259. switch (alchemy_get_cputype()) {
  260. case ALCHEMY_CPU_AU1000:
  261. return au1000_gpio2_to_irq(gpio);
  262. case ALCHEMY_CPU_AU1100:
  263. return au1100_gpio2_to_irq(gpio);
  264. case ALCHEMY_CPU_AU1500:
  265. return au1500_gpio2_to_irq(gpio);
  266. case ALCHEMY_CPU_AU1550:
  267. return au1550_gpio2_to_irq(gpio);
  268. case ALCHEMY_CPU_AU1200:
  269. return au1200_gpio2_to_irq(gpio);
  270. }
  271. return -ENXIO;
  272. }
  273. /**********************************************************************/
  274. /* On Au1000, Au1500 and Au1100 GPIOs won't work as inputs before
  275. * SYS_PININPUTEN is written to at least once. On Au1550/Au1200 this
  276. * register enables use of GPIOs as wake source.
  277. */
  278. static inline void alchemy_gpio1_input_enable(void)
  279. {
  280. au_writel(0, SYS_PININPUTEN); /* the write op is key */
  281. au_sync();
  282. }
  283. /* GPIO2 shared interrupts and control */
  284. static inline void __alchemy_gpio2_mod_int(int gpio2, int en)
  285. {
  286. unsigned long r = au_readl(GPIO2_INTENABLE);
  287. if (en)
  288. r |= 1 << gpio2;
  289. else
  290. r &= ~(1 << gpio2);
  291. au_writel(r, GPIO2_INTENABLE);
  292. au_sync();
  293. }
  294. /**
  295. * alchemy_gpio2_enable_int - Enable a GPIO2 pins' shared irq contribution.
  296. * @gpio2: The GPIO2 pin to activate (200...215).
  297. *
  298. * GPIO208-215 have one shared interrupt line to the INTC. They are
  299. * and'ed with a per-pin enable bit and finally or'ed together to form
  300. * a single irq request (useful for active-high sources).
  301. * With this function, a pins' individual contribution to the int request
  302. * can be enabled. As with all other GPIO-based interrupts, the INTC
  303. * must be programmed to accept the GPIO208_215 interrupt as well.
  304. *
  305. * NOTE: Calling this macro is only necessary for GPIO208-215; all other
  306. * GPIO2-based interrupts have their own request to the INTC. Please
  307. * consult your Alchemy databook for more information!
  308. *
  309. * NOTE: On the Au1550, GPIOs 201-205 also have a shared interrupt request
  310. * line to the INTC, GPIO201_205. This function can be used for those
  311. * as well.
  312. *
  313. * NOTE: 'gpio2' parameter must be in range of the GPIO2 numberspace
  314. * (200-215 by default). No sanity checks are made,
  315. */
  316. static inline void alchemy_gpio2_enable_int(int gpio2)
  317. {
  318. unsigned long flags;
  319. gpio2 -= ALCHEMY_GPIO2_BASE;
  320. /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
  321. switch (alchemy_get_cputype()) {
  322. case ALCHEMY_CPU_AU1100:
  323. case ALCHEMY_CPU_AU1500:
  324. gpio2 -= 8;
  325. }
  326. local_irq_save(flags);
  327. __alchemy_gpio2_mod_int(gpio2, 1);
  328. local_irq_restore(flags);
  329. }
  330. /**
  331. * alchemy_gpio2_disable_int - Disable a GPIO2 pins' shared irq contribution.
  332. * @gpio2: The GPIO2 pin to activate (200...215).
  333. *
  334. * see function alchemy_gpio2_enable_int() for more information.
  335. */
  336. static inline void alchemy_gpio2_disable_int(int gpio2)
  337. {
  338. unsigned long flags;
  339. gpio2 -= ALCHEMY_GPIO2_BASE;
  340. /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
  341. switch (alchemy_get_cputype()) {
  342. case ALCHEMY_CPU_AU1100:
  343. case ALCHEMY_CPU_AU1500:
  344. gpio2 -= 8;
  345. }
  346. local_irq_save(flags);
  347. __alchemy_gpio2_mod_int(gpio2, 0);
  348. local_irq_restore(flags);
  349. }
  350. /**
  351. * alchemy_gpio2_enable - Activate GPIO2 block.
  352. *
  353. * The GPIO2 block must be enabled excplicitly to work. On systems
  354. * where this isn't done by the bootloader, this macro can be used.
  355. */
  356. static inline void alchemy_gpio2_enable(void)
  357. {
  358. au_writel(3, GPIO2_ENABLE); /* reset, clock enabled */
  359. au_sync();
  360. au_writel(1, GPIO2_ENABLE); /* clock enabled */
  361. au_sync();
  362. }
  363. /**
  364. * alchemy_gpio2_disable - disable GPIO2 block.
  365. *
  366. * Disable and put GPIO2 block in low-power mode.
  367. */
  368. static inline void alchemy_gpio2_disable(void)
  369. {
  370. au_writel(2, GPIO2_ENABLE); /* reset, clock disabled */
  371. au_sync();
  372. }
  373. /**********************************************************************/
  374. /* wrappers for on-chip gpios; can be used before gpio chips have been
  375. * registered with gpiolib.
  376. */
  377. static inline int alchemy_gpio_direction_input(int gpio)
  378. {
  379. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  380. alchemy_gpio2_direction_input(gpio) :
  381. alchemy_gpio1_direction_input(gpio);
  382. }
  383. static inline int alchemy_gpio_direction_output(int gpio, int v)
  384. {
  385. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  386. alchemy_gpio2_direction_output(gpio, v) :
  387. alchemy_gpio1_direction_output(gpio, v);
  388. }
  389. static inline int alchemy_gpio_get_value(int gpio)
  390. {
  391. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  392. alchemy_gpio2_get_value(gpio) :
  393. alchemy_gpio1_get_value(gpio);
  394. }
  395. static inline void alchemy_gpio_set_value(int gpio, int v)
  396. {
  397. if (gpio >= ALCHEMY_GPIO2_BASE)
  398. alchemy_gpio2_set_value(gpio, v);
  399. else
  400. alchemy_gpio1_set_value(gpio, v);
  401. }
  402. static inline int alchemy_gpio_is_valid(int gpio)
  403. {
  404. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  405. alchemy_gpio2_is_valid(gpio) :
  406. alchemy_gpio1_is_valid(gpio);
  407. }
  408. static inline int alchemy_gpio_cansleep(int gpio)
  409. {
  410. return 0; /* Alchemy never gets tired */
  411. }
  412. static inline int alchemy_gpio_to_irq(int gpio)
  413. {
  414. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  415. alchemy_gpio2_to_irq(gpio) :
  416. alchemy_gpio1_to_irq(gpio);
  417. }
  418. static inline int alchemy_irq_to_gpio(int irq)
  419. {
  420. switch (alchemy_get_cputype()) {
  421. case ALCHEMY_CPU_AU1000:
  422. return au1000_irq_to_gpio(irq);
  423. case ALCHEMY_CPU_AU1100:
  424. return au1100_irq_to_gpio(irq);
  425. case ALCHEMY_CPU_AU1500:
  426. return au1500_irq_to_gpio(irq);
  427. case ALCHEMY_CPU_AU1550:
  428. return au1550_irq_to_gpio(irq);
  429. case ALCHEMY_CPU_AU1200:
  430. return au1200_irq_to_gpio(irq);
  431. }
  432. return -ENXIO;
  433. }
  434. /**********************************************************************/
  435. /* Linux gpio framework integration.
  436. *
  437. * 4 use cases of Au1000-Au1200 GPIOS:
  438. *(1) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=y:
  439. * Board must register gpiochips.
  440. *(2) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=n:
  441. * 2 (1 for Au1000) gpio_chips are registered.
  442. *
  443. *(3) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=y:
  444. * the boards' gpio.h must provide the linux gpio wrapper functions,
  445. *
  446. *(4) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=n:
  447. * inlinable gpio functions are provided which enable access to the
  448. * Au1000 gpios only by using the numbers straight out of the data-
  449. * sheets.
  450. * Cases 1 and 3 are intended for boards which want to provide their own
  451. * GPIO namespace and -operations (i.e. for example you have 8 GPIOs
  452. * which are in part provided by spare Au1000 GPIO pins and in part by
  453. * an external FPGA but you still want them to be accssible in linux
  454. * as gpio0-7. The board can of course use the alchemy_gpioX_* functions
  455. * as required).
  456. */
  457. #ifndef CONFIG_GPIOLIB
  458. #ifndef CONFIG_ALCHEMY_GPIO_INDIRECT /* case (4) */
  459. static inline int gpio_direction_input(int gpio)
  460. {
  461. return alchemy_gpio_direction_input(gpio);
  462. }
  463. static inline int gpio_direction_output(int gpio, int v)
  464. {
  465. return alchemy_gpio_direction_output(gpio, v);
  466. }
  467. static inline int gpio_get_value(int gpio)
  468. {
  469. return alchemy_gpio_get_value(gpio);
  470. }
  471. static inline void gpio_set_value(int gpio, int v)
  472. {
  473. alchemy_gpio_set_value(gpio, v);
  474. }
  475. static inline int gpio_get_value_cansleep(unsigned gpio)
  476. {
  477. return gpio_get_value(gpio);
  478. }
  479. static inline void gpio_set_value_cansleep(unsigned gpio, int value)
  480. {
  481. gpio_set_value(gpio, value);
  482. }
  483. static inline int gpio_is_valid(int gpio)
  484. {
  485. return alchemy_gpio_is_valid(gpio);
  486. }
  487. static inline int gpio_cansleep(int gpio)
  488. {
  489. return alchemy_gpio_cansleep(gpio);
  490. }
  491. static inline int gpio_to_irq(int gpio)
  492. {
  493. return alchemy_gpio_to_irq(gpio);
  494. }
  495. static inline int irq_to_gpio(int irq)
  496. {
  497. return alchemy_irq_to_gpio(irq);
  498. }
  499. static inline int gpio_request(unsigned gpio, const char *label)
  500. {
  501. return 0;
  502. }
  503. static inline int gpio_request_one(unsigned gpio,
  504. unsigned long flags, const char *label)
  505. {
  506. return 0;
  507. }
  508. static inline int gpio_request_array(struct gpio *array, size_t num)
  509. {
  510. return 0;
  511. }
  512. static inline void gpio_free(unsigned gpio)
  513. {
  514. }
  515. static inline void gpio_free_array(struct gpio *array, size_t num)
  516. {
  517. }
  518. static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
  519. {
  520. return -ENOSYS;
  521. }
  522. static inline int gpio_export(unsigned gpio, bool direction_may_change)
  523. {
  524. return -ENOSYS;
  525. }
  526. static inline int gpio_export_link(struct device *dev, const char *name,
  527. unsigned gpio)
  528. {
  529. return -ENOSYS;
  530. }
  531. static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
  532. {
  533. return -ENOSYS;
  534. }
  535. static inline void gpio_unexport(unsigned gpio)
  536. {
  537. }
  538. #endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */
  539. #else /* CONFIG GPIOLIB */
  540. /* using gpiolib to provide up to 2 gpio_chips for on-chip gpios */
  541. #ifndef CONFIG_ALCHEMY_GPIO_INDIRECT /* case (2) */
  542. /* get everything through gpiolib */
  543. #define gpio_to_irq __gpio_to_irq
  544. #define gpio_get_value __gpio_get_value
  545. #define gpio_set_value __gpio_set_value
  546. #define gpio_cansleep __gpio_cansleep
  547. #define irq_to_gpio alchemy_irq_to_gpio
  548. #include <asm-generic/gpio.h>
  549. #endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */
  550. #endif /* !CONFIG_GPIOLIB */
  551. #endif /* _ALCHEMY_GPIO_AU1000_H_ */