diff options
Diffstat (limited to 'arch/mips/include/asm/mach-au1x00/gpio-au1000.h')
-rw-r--r-- | arch/mips/include/asm/mach-au1x00/gpio-au1000.h | 122 |
1 files changed, 100 insertions, 22 deletions
diff --git a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h index 62d2f136d941..1f41a522906d 100644 --- a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h +++ b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h | |||
@@ -24,6 +24,23 @@ | |||
24 | 24 | ||
25 | #define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off)) | 25 | #define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off)) |
26 | 26 | ||
27 | /* GPIO1 registers within SYS_ area */ | ||
28 | #define SYS_TRIOUTRD 0x100 | ||
29 | #define SYS_TRIOUTCLR 0x100 | ||
30 | #define SYS_OUTPUTRD 0x108 | ||
31 | #define SYS_OUTPUTSET 0x108 | ||
32 | #define SYS_OUTPUTCLR 0x10C | ||
33 | #define SYS_PINSTATERD 0x110 | ||
34 | #define SYS_PININPUTEN 0x110 | ||
35 | |||
36 | /* register offsets within GPIO2 block */ | ||
37 | #define GPIO2_DIR 0x00 | ||
38 | #define GPIO2_OUTPUT 0x08 | ||
39 | #define GPIO2_PINSTATE 0x0C | ||
40 | #define GPIO2_INTENABLE 0x10 | ||
41 | #define GPIO2_ENABLE 0x14 | ||
42 | |||
43 | struct gpio; | ||
27 | 44 | ||
28 | static inline int au1000_gpio1_to_irq(int gpio) | 45 | static inline int au1000_gpio1_to_irq(int gpio) |
29 | { | 46 | { |
@@ -200,23 +217,26 @@ static inline int au1200_irq_to_gpio(int irq) | |||
200 | */ | 217 | */ |
201 | static inline void alchemy_gpio1_set_value(int gpio, int v) | 218 | static inline void alchemy_gpio1_set_value(int gpio, int v) |
202 | { | 219 | { |
220 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); | ||
203 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); | 221 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); |
204 | unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR; | 222 | unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR; |
205 | au_writel(mask, r); | 223 | __raw_writel(mask, base + r); |
206 | au_sync(); | 224 | wmb(); |
207 | } | 225 | } |
208 | 226 | ||
209 | static inline int alchemy_gpio1_get_value(int gpio) | 227 | static inline int alchemy_gpio1_get_value(int gpio) |
210 | { | 228 | { |
229 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); | ||
211 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); | 230 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); |
212 | return au_readl(SYS_PINSTATERD) & mask; | 231 | return __raw_readl(base + SYS_PINSTATERD) & mask; |
213 | } | 232 | } |
214 | 233 | ||
215 | static inline int alchemy_gpio1_direction_input(int gpio) | 234 | static inline int alchemy_gpio1_direction_input(int gpio) |
216 | { | 235 | { |
236 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); | ||
217 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); | 237 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); |
218 | au_writel(mask, SYS_TRIOUTCLR); | 238 | __raw_writel(mask, base + SYS_TRIOUTCLR); |
219 | au_sync(); | 239 | wmb(); |
220 | return 0; | 240 | return 0; |
221 | } | 241 | } |
222 | 242 | ||
@@ -257,27 +277,31 @@ static inline int alchemy_gpio1_to_irq(int gpio) | |||
257 | */ | 277 | */ |
258 | static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out) | 278 | static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out) |
259 | { | 279 | { |
280 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); | ||
260 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE); | 281 | unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE); |
261 | unsigned long d = au_readl(GPIO2_DIR); | 282 | unsigned long d = __raw_readl(base + GPIO2_DIR); |
283 | |||
262 | if (to_out) | 284 | if (to_out) |
263 | d |= mask; | 285 | d |= mask; |
264 | else | 286 | else |
265 | d &= ~mask; | 287 | d &= ~mask; |
266 | au_writel(d, GPIO2_DIR); | 288 | __raw_writel(d, base + GPIO2_DIR); |
267 | au_sync(); | 289 | wmb(); |
268 | } | 290 | } |
269 | 291 | ||
270 | static inline void alchemy_gpio2_set_value(int gpio, int v) | 292 | static inline void alchemy_gpio2_set_value(int gpio, int v) |
271 | { | 293 | { |
294 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); | ||
272 | unsigned long mask; | 295 | unsigned long mask; |
273 | mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE); | 296 | mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE); |
274 | au_writel(mask, GPIO2_OUTPUT); | 297 | __raw_writel(mask, base + GPIO2_OUTPUT); |
275 | au_sync(); | 298 | wmb(); |
276 | } | 299 | } |
277 | 300 | ||
278 | static inline int alchemy_gpio2_get_value(int gpio) | 301 | static inline int alchemy_gpio2_get_value(int gpio) |
279 | { | 302 | { |
280 | return au_readl(GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE)); | 303 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); |
304 | return __raw_readl(base + GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE)); | ||
281 | } | 305 | } |
282 | 306 | ||
283 | static inline int alchemy_gpio2_direction_input(int gpio) | 307 | static inline int alchemy_gpio2_direction_input(int gpio) |
@@ -329,21 +353,23 @@ static inline int alchemy_gpio2_to_irq(int gpio) | |||
329 | */ | 353 | */ |
330 | static inline void alchemy_gpio1_input_enable(void) | 354 | static inline void alchemy_gpio1_input_enable(void) |
331 | { | 355 | { |
332 | au_writel(0, SYS_PININPUTEN); /* the write op is key */ | 356 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); |
333 | au_sync(); | 357 | __raw_writel(0, base + SYS_PININPUTEN); /* the write op is key */ |
358 | wmb(); | ||
334 | } | 359 | } |
335 | 360 | ||
336 | /* GPIO2 shared interrupts and control */ | 361 | /* GPIO2 shared interrupts and control */ |
337 | 362 | ||
338 | static inline void __alchemy_gpio2_mod_int(int gpio2, int en) | 363 | static inline void __alchemy_gpio2_mod_int(int gpio2, int en) |
339 | { | 364 | { |
340 | unsigned long r = au_readl(GPIO2_INTENABLE); | 365 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); |
366 | unsigned long r = __raw_readl(base + GPIO2_INTENABLE); | ||
341 | if (en) | 367 | if (en) |
342 | r |= 1 << gpio2; | 368 | r |= 1 << gpio2; |
343 | else | 369 | else |
344 | r &= ~(1 << gpio2); | 370 | r &= ~(1 << gpio2); |
345 | au_writel(r, GPIO2_INTENABLE); | 371 | __raw_writel(r, base + GPIO2_INTENABLE); |
346 | au_sync(); | 372 | wmb(); |
347 | } | 373 | } |
348 | 374 | ||
349 | /** | 375 | /** |
@@ -418,10 +444,11 @@ static inline void alchemy_gpio2_disable_int(int gpio2) | |||
418 | */ | 444 | */ |
419 | static inline void alchemy_gpio2_enable(void) | 445 | static inline void alchemy_gpio2_enable(void) |
420 | { | 446 | { |
421 | au_writel(3, GPIO2_ENABLE); /* reset, clock enabled */ | 447 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); |
422 | au_sync(); | 448 | __raw_writel(3, base + GPIO2_ENABLE); /* reset, clock enabled */ |
423 | au_writel(1, GPIO2_ENABLE); /* clock enabled */ | 449 | wmb(); |
424 | au_sync(); | 450 | __raw_writel(1, base + GPIO2_ENABLE); /* clock enabled */ |
451 | wmb(); | ||
425 | } | 452 | } |
426 | 453 | ||
427 | /** | 454 | /** |
@@ -431,8 +458,9 @@ static inline void alchemy_gpio2_enable(void) | |||
431 | */ | 458 | */ |
432 | static inline void alchemy_gpio2_disable(void) | 459 | static inline void alchemy_gpio2_disable(void) |
433 | { | 460 | { |
434 | au_writel(2, GPIO2_ENABLE); /* reset, clock disabled */ | 461 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); |
435 | au_sync(); | 462 | __raw_writel(2, base + GPIO2_ENABLE); /* reset, clock disabled */ |
463 | wmb(); | ||
436 | } | 464 | } |
437 | 465 | ||
438 | /**********************************************************************/ | 466 | /**********************************************************************/ |
@@ -556,6 +584,16 @@ static inline void gpio_set_value(int gpio, int v) | |||
556 | alchemy_gpio_set_value(gpio, v); | 584 | alchemy_gpio_set_value(gpio, v); |
557 | } | 585 | } |
558 | 586 | ||
587 | static inline int gpio_get_value_cansleep(unsigned gpio) | ||
588 | { | ||
589 | return gpio_get_value(gpio); | ||
590 | } | ||
591 | |||
592 | static inline void gpio_set_value_cansleep(unsigned gpio, int value) | ||
593 | { | ||
594 | gpio_set_value(gpio, value); | ||
595 | } | ||
596 | |||
559 | static inline int gpio_is_valid(int gpio) | 597 | static inline int gpio_is_valid(int gpio) |
560 | { | 598 | { |
561 | return alchemy_gpio_is_valid(gpio); | 599 | return alchemy_gpio_is_valid(gpio); |
@@ -581,10 +619,50 @@ static inline int gpio_request(unsigned gpio, const char *label) | |||
581 | return 0; | 619 | return 0; |
582 | } | 620 | } |
583 | 621 | ||
622 | static inline int gpio_request_one(unsigned gpio, | ||
623 | unsigned long flags, const char *label) | ||
624 | { | ||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | static inline int gpio_request_array(struct gpio *array, size_t num) | ||
629 | { | ||
630 | return 0; | ||
631 | } | ||
632 | |||
584 | static inline void gpio_free(unsigned gpio) | 633 | static inline void gpio_free(unsigned gpio) |
585 | { | 634 | { |
586 | } | 635 | } |
587 | 636 | ||
637 | static inline void gpio_free_array(struct gpio *array, size_t num) | ||
638 | { | ||
639 | } | ||
640 | |||
641 | static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) | ||
642 | { | ||
643 | return -ENOSYS; | ||
644 | } | ||
645 | |||
646 | static inline int gpio_export(unsigned gpio, bool direction_may_change) | ||
647 | { | ||
648 | return -ENOSYS; | ||
649 | } | ||
650 | |||
651 | static inline int gpio_export_link(struct device *dev, const char *name, | ||
652 | unsigned gpio) | ||
653 | { | ||
654 | return -ENOSYS; | ||
655 | } | ||
656 | |||
657 | static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) | ||
658 | { | ||
659 | return -ENOSYS; | ||
660 | } | ||
661 | |||
662 | static inline void gpio_unexport(unsigned gpio) | ||
663 | { | ||
664 | } | ||
665 | |||
588 | #endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */ | 666 | #endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */ |
589 | 667 | ||
590 | 668 | ||