7ba7efca1f814e2719c9bd9f1fb9c4b518cdb642
2 * ADM5120 GPIO wrappers for arch-neutral GPIO calls
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
12 #ifndef _ASM_MIPS_MACH_ADM5120_GPIO_H
13 #define _ASM_MIPS_MACH_ADM5120_GPIO_H
15 #define ARCH_NR_GPIOS 64
17 #include <asm-generic/gpio.h>
19 #include <asm/mach-adm5120/adm5120_switch.h>
21 #define ADM5120_GPIO_PIN0 0
22 #define ADM5120_GPIO_PIN1 1
23 #define ADM5120_GPIO_PIN2 2
24 #define ADM5120_GPIO_PIN3 3
25 #define ADM5120_GPIO_PIN4 4
26 #define ADM5120_GPIO_PIN5 5
27 #define ADM5120_GPIO_PIN6 6
28 #define ADM5120_GPIO_PIN7 7
29 #define ADM5120_GPIO_P0L0 8
30 #define ADM5120_GPIO_P0L1 9
31 #define ADM5120_GPIO_P0L2 10
32 #define ADM5120_GPIO_P1L0 11
33 #define ADM5120_GPIO_P1L1 12
34 #define ADM5120_GPIO_P1L2 13
35 #define ADM5120_GPIO_P2L0 14
36 #define ADM5120_GPIO_P2L1 15
37 #define ADM5120_GPIO_P2L2 16
38 #define ADM5120_GPIO_P3L0 17
39 #define ADM5120_GPIO_P3L1 18
40 #define ADM5120_GPIO_P3L2 19
41 #define ADM5120_GPIO_P4L0 20
42 #define ADM5120_GPIO_P4L1 21
43 #define ADM5120_GPIO_P4L2 22
44 #define ADM5120_GPIO_MAX 22
45 #define ADM5120_GPIO_COUNT ADM5120_GPIO_MAX+1
47 #define ADM5120_GPIO_LOW 0
48 #define ADM5120_GPIO_HIGH 1
50 #define ADM5120_GPIO_SWITCH 0x10
51 #define ADM5120_GPIO_FLASH (ADM5120_GPIO_SWITCH | LED_MODE_FLASH)
52 #define ADM5120_GPIO_LINK (ADM5120_GPIO_SWITCH | LED_MODE_LINK)
53 #define ADM5120_GPIO_SPEED (ADM5120_GPIO_SWITCH | LED_MODE_SPEED)
54 #define ADM5120_GPIO_DUPLEX (ADM5120_GPIO_SWITCH | LED_MODE_DUPLEX)
55 #define ADM5120_GPIO_ACT (ADM5120_GPIO_SWITCH | LED_MODE_ACT)
56 #define ADM5120_GPIO_COLL (ADM5120_GPIO_SWITCH | LED_MODE_COLL)
57 #define ADM5120_GPIO_LINK_ACT (ADM5120_GPIO_SWITCH | LED_MODE_LINK_ACT)
58 #define ADM5120_GPIO_DUPLEX_COLL (ADM5120_GPIO_SWITCH | LED_MODE_DUPLEX_COLL)
59 #define ADM5120_GPIO_10M_ACT (ADM5120_GPIO_SWITCH | LED_MODE_10M_ACT)
60 #define ADM5120_GPIO_100M_ACT (ADM5120_GPIO_SWITCH | LED_MODE_100M_ACT)
62 extern int __adm5120_gpio0_get_value(unsigned gpio
);
63 extern void __adm5120_gpio0_set_value(unsigned gpio
, int value
);
64 extern int __adm5120_gpio1_get_value(unsigned gpio
);
65 extern void __adm5120_gpio1_set_value(unsigned gpio
, int value
);
66 extern int adm5120_gpio_to_irq(unsigned gpio
);
67 extern int adm5120_irq_to_gpio(unsigned irq
);
69 static inline int gpio_get_value(unsigned gpio
)
74 case ADM5120_GPIO_PIN0
... ADM5120_GPIO_PIN7
:
75 ret
= __adm5120_gpio0_get_value(gpio
);
77 case ADM5120_GPIO_P0L0
... ADM5120_GPIO_P4L2
:
78 ret
= __adm5120_gpio1_get_value(gpio
- ADM5120_GPIO_P0L0
);
81 ret
= __gpio_get_value(gpio
);
88 static inline void gpio_set_value(unsigned gpio
, int value
)
91 case ADM5120_GPIO_PIN0
... ADM5120_GPIO_PIN7
:
92 __adm5120_gpio0_set_value(gpio
, value
);
94 case ADM5120_GPIO_P0L0
... ADM5120_GPIO_P4L2
:
95 __adm5120_gpio1_set_value(gpio
- ADM5120_GPIO_P0L0
, value
);
98 __gpio_set_value(gpio
, value
);
103 static inline int gpio_to_irq(unsigned gpio
)
105 return adm5120_gpio_to_irq(gpio
);
108 static inline int irq_to_gpio(unsigned irq
)
110 return adm5120_irq_to_gpio(irq
);
113 #define gpio_cansleep __gpio_cansleep
115 #endif /* _ASM_MIPS_MACH_ADM5120_GPIO_H */
This page took 0.048528 seconds and 3 git commands to generate.