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. /* GPIO1 registers within SYS_ area */
  22. #define SYS_TRIOUTRD 0x100
  23. #define SYS_TRIOUTCLR 0x100
  24. #define SYS_OUTPUTRD 0x108
  25. #define SYS_OUTPUTSET 0x108
  26. #define SYS_OUTPUTCLR 0x10C
  27. #define SYS_PINSTATERD 0x110
  28. #define SYS_PININPUTEN 0x110
  29. /* register offsets within GPIO2 block */
  30. #define GPIO2_DIR 0x00
  31. #define GPIO2_OUTPUT 0x08
  32. #define GPIO2_PINSTATE 0x0C
  33. #define GPIO2_INTENABLE 0x10
  34. #define 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. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
  180. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
  181. unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR;
  182. __raw_writel(mask, base + r);
  183. wmb();
  184. }
  185. static inline int alchemy_gpio1_get_value(int gpio)
  186. {
  187. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
  188. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
  189. return __raw_readl(base + SYS_PINSTATERD) & mask;
  190. }
  191. static inline int alchemy_gpio1_direction_input(int gpio)
  192. {
  193. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
  194. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
  195. __raw_writel(mask, base + SYS_TRIOUTCLR);
  196. wmb();
  197. return 0;
  198. }
  199. static inline int alchemy_gpio1_direction_output(int gpio, int v)
  200. {
  201. /* hardware switches to "output" mode when one of the two
  202. * "set_value" registers is accessed.
  203. */
  204. alchemy_gpio1_set_value(gpio, v);
  205. return 0;
  206. }
  207. static inline int alchemy_gpio1_is_valid(int gpio)
  208. {
  209. return ((gpio >= ALCHEMY_GPIO1_BASE) && (gpio <= ALCHEMY_GPIO1_MAX));
  210. }
  211. static inline int alchemy_gpio1_to_irq(int gpio)
  212. {
  213. switch (alchemy_get_cputype()) {
  214. case ALCHEMY_CPU_AU1000:
  215. return au1000_gpio1_to_irq(gpio);
  216. case ALCHEMY_CPU_AU1100:
  217. return au1100_gpio1_to_irq(gpio);
  218. case ALCHEMY_CPU_AU1500:
  219. return au1500_gpio1_to_irq(gpio);
  220. case ALCHEMY_CPU_AU1550:
  221. return au1550_gpio1_to_irq(gpio);
  222. case ALCHEMY_CPU_AU1200:
  223. return au1200_gpio1_to_irq(gpio);
  224. }
  225. return -ENXIO;
  226. }
  227. /*
  228. * GPIO2 block macros for common linux GPIO functions. The 'gpio'
  229. * parameter must be in range of ALCHEMY_GPIO2_BASE..ALCHEMY_GPIO2_MAX.
  230. */
  231. static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out)
  232. {
  233. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
  234. unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE);
  235. unsigned long d = __raw_readl(base + GPIO2_DIR);
  236. if (to_out)
  237. d |= mask;
  238. else
  239. d &= ~mask;
  240. __raw_writel(d, base + GPIO2_DIR);
  241. wmb();
  242. }
  243. static inline void alchemy_gpio2_set_value(int gpio, int v)
  244. {
  245. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
  246. unsigned long mask;
  247. mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE);
  248. __raw_writel(mask, base + GPIO2_OUTPUT);
  249. wmb();
  250. }
  251. static inline int alchemy_gpio2_get_value(int gpio)
  252. {
  253. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
  254. return __raw_readl(base + GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE));
  255. }
  256. static inline int alchemy_gpio2_direction_input(int gpio)
  257. {
  258. unsigned long flags;
  259. local_irq_save(flags);
  260. __alchemy_gpio2_mod_dir(gpio, 0);
  261. local_irq_restore(flags);
  262. return 0;
  263. }
  264. static inline int alchemy_gpio2_direction_output(int gpio, int v)
  265. {
  266. unsigned long flags;
  267. alchemy_gpio2_set_value(gpio, v);
  268. local_irq_save(flags);
  269. __alchemy_gpio2_mod_dir(gpio, 1);
  270. local_irq_restore(flags);
  271. return 0;
  272. }
  273. static inline int alchemy_gpio2_is_valid(int gpio)
  274. {
  275. return ((gpio >= ALCHEMY_GPIO2_BASE) && (gpio <= ALCHEMY_GPIO2_MAX));
  276. }
  277. static inline int alchemy_gpio2_to_irq(int gpio)
  278. {
  279. switch (alchemy_get_cputype()) {
  280. case ALCHEMY_CPU_AU1000:
  281. return au1000_gpio2_to_irq(gpio);
  282. case ALCHEMY_CPU_AU1100:
  283. return au1100_gpio2_to_irq(gpio);
  284. case ALCHEMY_CPU_AU1500:
  285. return au1500_gpio2_to_irq(gpio);
  286. case ALCHEMY_CPU_AU1550:
  287. return au1550_gpio2_to_irq(gpio);
  288. case ALCHEMY_CPU_AU1200:
  289. return au1200_gpio2_to_irq(gpio);
  290. }
  291. return -ENXIO;
  292. }
  293. /**********************************************************************/
  294. /* GPIO2 shared interrupts and control */
  295. static inline void __alchemy_gpio2_mod_int(int gpio2, int en)
  296. {
  297. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
  298. unsigned long r = __raw_readl(base + GPIO2_INTENABLE);
  299. if (en)
  300. r |= 1 << gpio2;
  301. else
  302. r &= ~(1 << gpio2);
  303. __raw_writel(r, base + GPIO2_INTENABLE);
  304. wmb();
  305. }
  306. /**
  307. * alchemy_gpio2_enable_int - Enable a GPIO2 pins' shared irq contribution.
  308. * @gpio2: The GPIO2 pin to activate (200...215).
  309. *
  310. * GPIO208-215 have one shared interrupt line to the INTC. They are
  311. * and'ed with a per-pin enable bit and finally or'ed together to form
  312. * a single irq request (useful for active-high sources).
  313. * With this function, a pins' individual contribution to the int request
  314. * can be enabled. As with all other GPIO-based interrupts, the INTC
  315. * must be programmed to accept the GPIO208_215 interrupt as well.
  316. *
  317. * NOTE: Calling this macro is only necessary for GPIO208-215; all other
  318. * GPIO2-based interrupts have their own request to the INTC. Please
  319. * consult your Alchemy databook for more information!
  320. *
  321. * NOTE: On the Au1550, GPIOs 201-205 also have a shared interrupt request
  322. * line to the INTC, GPIO201_205. This function can be used for those
  323. * as well.
  324. *
  325. * NOTE: 'gpio2' parameter must be in range of the GPIO2 numberspace
  326. * (200-215 by default). No sanity checks are made,
  327. */
  328. static inline void alchemy_gpio2_enable_int(int gpio2)
  329. {
  330. unsigned long flags;
  331. gpio2 -= ALCHEMY_GPIO2_BASE;
  332. /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
  333. switch (alchemy_get_cputype()) {
  334. case ALCHEMY_CPU_AU1100:
  335. case ALCHEMY_CPU_AU1500:
  336. gpio2 -= 8;
  337. }
  338. local_irq_save(flags);
  339. __alchemy_gpio2_mod_int(gpio2, 1);
  340. local_irq_restore(flags);
  341. }
  342. /**
  343. * alchemy_gpio2_disable_int - Disable a GPIO2 pins' shared irq contribution.
  344. * @gpio2: The GPIO2 pin to activate (200...215).
  345. *
  346. * see function alchemy_gpio2_enable_int() for more information.
  347. */
  348. static inline void alchemy_gpio2_disable_int(int gpio2)
  349. {
  350. unsigned long flags;
  351. gpio2 -= ALCHEMY_GPIO2_BASE;
  352. /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
  353. switch (alchemy_get_cputype()) {
  354. case ALCHEMY_CPU_AU1100:
  355. case ALCHEMY_CPU_AU1500:
  356. gpio2 -= 8;
  357. }
  358. local_irq_save(flags);
  359. __alchemy_gpio2_mod_int(gpio2, 0);
  360. local_irq_restore(flags);
  361. }
  362. /**
  363. * alchemy_gpio2_enable - Activate GPIO2 block.
  364. *
  365. * The GPIO2 block must be enabled excplicitly to work. On systems
  366. * where this isn't done by the bootloader, this macro can be used.
  367. */
  368. static inline void alchemy_gpio2_enable(void)
  369. {
  370. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
  371. __raw_writel(3, base + GPIO2_ENABLE); /* reset, clock enabled */
  372. wmb();
  373. __raw_writel(1, base + GPIO2_ENABLE); /* clock enabled */
  374. wmb();
  375. }
  376. /**
  377. * alchemy_gpio2_disable - disable GPIO2 block.
  378. *
  379. * Disable and put GPIO2 block in low-power mode.
  380. */
  381. static inline void alchemy_gpio2_disable(void)
  382. {
  383. void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
  384. __raw_writel(2, base + GPIO2_ENABLE); /* reset, clock disabled */
  385. wmb();
  386. }
  387. /**********************************************************************/
  388. /* wrappers for on-chip gpios; can be used before gpio chips have been
  389. * registered with gpiolib.
  390. */
  391. static inline int alchemy_gpio_direction_input(int gpio)
  392. {
  393. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  394. alchemy_gpio2_direction_input(gpio) :
  395. alchemy_gpio1_direction_input(gpio);
  396. }
  397. static inline int alchemy_gpio_direction_output(int gpio, int v)
  398. {
  399. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  400. alchemy_gpio2_direction_output(gpio, v) :
  401. alchemy_gpio1_direction_output(gpio, v);
  402. }
  403. static inline int alchemy_gpio_get_value(int gpio)
  404. {
  405. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  406. alchemy_gpio2_get_value(gpio) :
  407. alchemy_gpio1_get_value(gpio);
  408. }
  409. static inline void alchemy_gpio_set_value(int gpio, int v)
  410. {
  411. if (gpio >= ALCHEMY_GPIO2_BASE)
  412. alchemy_gpio2_set_value(gpio, v);
  413. else
  414. alchemy_gpio1_set_value(gpio, v);
  415. }
  416. static inline int alchemy_gpio_is_valid(int gpio)
  417. {
  418. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  419. alchemy_gpio2_is_valid(gpio) :
  420. alchemy_gpio1_is_valid(gpio);
  421. }
  422. static inline int alchemy_gpio_cansleep(int gpio)
  423. {
  424. return 0; /* Alchemy never gets tired */
  425. }
  426. static inline int alchemy_gpio_to_irq(int gpio)
  427. {
  428. return (gpio >= ALCHEMY_GPIO2_BASE) ?
  429. alchemy_gpio2_to_irq(gpio) :
  430. alchemy_gpio1_to_irq(gpio);
  431. }
  432. static inline int alchemy_irq_to_gpio(int irq)
  433. {
  434. switch (alchemy_get_cputype()) {
  435. case ALCHEMY_CPU_AU1000:
  436. return au1000_irq_to_gpio(irq);
  437. case ALCHEMY_CPU_AU1100:
  438. return au1100_irq_to_gpio(irq);
  439. case ALCHEMY_CPU_AU1500:
  440. return au1500_irq_to_gpio(irq);
  441. case ALCHEMY_CPU_AU1550:
  442. return au1550_irq_to_gpio(irq);
  443. case ALCHEMY_CPU_AU1200:
  444. return au1200_irq_to_gpio(irq);
  445. }
  446. return -ENXIO;
  447. }
  448. /**********************************************************************/
  449. /* Linux gpio framework integration.
  450. *
  451. * 4 use cases of Au1000-Au1200 GPIOS:
  452. *(1) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=y:
  453. * Board must register gpiochips.
  454. *(2) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=n:
  455. * 2 (1 for Au1000) gpio_chips are registered.
  456. *
  457. *(3) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=y:
  458. * the boards' gpio.h must provide the linux gpio wrapper functions,
  459. *
  460. *(4) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=n:
  461. * inlinable gpio functions are provided which enable access to the
  462. * Au1000 gpios only by using the numbers straight out of the data-
  463. * sheets.
  464. * Cases 1 and 3 are intended for boards which want to provide their own
  465. * GPIO namespace and -operations (i.e. for example you have 8 GPIOs
  466. * which are in part provided by spare Au1000 GPIO pins and in part by
  467. * an external FPGA but you still want them to be accssible in linux
  468. * as gpio0-7. The board can of course use the alchemy_gpioX_* functions
  469. * as required).
  470. */
  471. #ifndef CONFIG_GPIOLIB
  472. #ifdef CONFIG_ALCHEMY_GPIOINT_AU1000
  473. #ifndef CONFIG_ALCHEMY_GPIO_INDIRECT /* case (4) */
  474. static inline int gpio_direction_input(int gpio)
  475. {
  476. return alchemy_gpio_direction_input(gpio);
  477. }
  478. static inline int gpio_direction_output(int gpio, int v)
  479. {
  480. return alchemy_gpio_direction_output(gpio, v);
  481. }
  482. static inline int gpio_get_value(int gpio)
  483. {
  484. return alchemy_gpio_get_value(gpio);
  485. }
  486. static inline void gpio_set_value(int gpio, int v)
  487. {
  488. alchemy_gpio_set_value(gpio, v);
  489. }
  490. static inline int gpio_get_value_cansleep(unsigned gpio)
  491. {
  492. return gpio_get_value(gpio);
  493. }
  494. static inline void gpio_set_value_cansleep(unsigned gpio, int value)
  495. {
  496. gpio_set_value(gpio, value);
  497. }
  498. static inline int gpio_is_valid(int gpio)
  499. {
  500. return alchemy_gpio_is_valid(gpio);
  501. }
  502. static inline int gpio_cansleep(int gpio)
  503. {
  504. return alchemy_gpio_cansleep(gpio);
  505. }
  506. static inline int gpio_to_irq(int gpio)
  507. {
  508. return alchemy_gpio_to_irq(gpio);
  509. }
  510. static inline int irq_to_gpio(int irq)
  511. {
  512. return alchemy_irq_to_gpio(irq);
  513. }
  514. static inline int gpio_request(unsigned gpio, const char *label)
  515. {
  516. return 0;
  517. }
  518. static inline int gpio_request_one(unsigned gpio,
  519. unsigned long flags, const char *label)
  520. {
  521. return 0;
  522. }
  523. static inline int gpio_request_array(struct gpio *array, size_t num)
  524. {
  525. return 0;
  526. }
  527. static inline void gpio_free(unsigned gpio)
  528. {
  529. }
  530. static inline void gpio_free_array(struct gpio *array, size_t num)
  531. {
  532. }
  533. static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
  534. {
  535. return -ENOSYS;
  536. }
  537. static inline int gpio_export(unsigned gpio, bool direction_may_change)
  538. {
  539. return -ENOSYS;
  540. }
  541. static inline int gpio_export_link(struct device *dev, const char *name,
  542. unsigned gpio)
  543. {
  544. return -ENOSYS;
  545. }
  546. static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
  547. {
  548. return -ENOSYS;
  549. }
  550. static inline void gpio_unexport(unsigned gpio)
  551. {
  552. }
  553. #endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */
  554. #endif /* CONFIG_ALCHEMY_GPIOINT_AU1000 */
  555. #endif /* !CONFIG_GPIOLIB */
  556. #endif /* _ALCHEMY_GPIO_AU1000_H_ */