gpio-au1000.h 16 KB

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