diff options
Diffstat (limited to 'arch/arm/mach-ixp4xx/common.c')
-rw-r--r-- | arch/arm/mach-ixp4xx/common.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index 5327decde5a0..9edaf4734fa8 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c | |||
@@ -81,6 +81,44 @@ void __init ixp4xx_map_io(void) | |||
81 | iotable_init(ixp4xx_io_desc, ARRAY_SIZE(ixp4xx_io_desc)); | 81 | iotable_init(ixp4xx_io_desc, ARRAY_SIZE(ixp4xx_io_desc)); |
82 | } | 82 | } |
83 | 83 | ||
84 | /* | ||
85 | * GPIO-functions | ||
86 | */ | ||
87 | /* | ||
88 | * The following converted to the real HW bits the gpio_line_config | ||
89 | */ | ||
90 | /* GPIO pin types */ | ||
91 | #define IXP4XX_GPIO_OUT 0x1 | ||
92 | #define IXP4XX_GPIO_IN 0x2 | ||
93 | |||
94 | /* GPIO signal types */ | ||
95 | #define IXP4XX_GPIO_LOW 0 | ||
96 | #define IXP4XX_GPIO_HIGH 1 | ||
97 | |||
98 | /* GPIO Clocks */ | ||
99 | #define IXP4XX_GPIO_CLK_0 14 | ||
100 | #define IXP4XX_GPIO_CLK_1 15 | ||
101 | |||
102 | static void gpio_line_config(u8 line, u32 direction) | ||
103 | { | ||
104 | if (direction == IXP4XX_GPIO_IN) | ||
105 | *IXP4XX_GPIO_GPOER |= (1 << line); | ||
106 | else | ||
107 | *IXP4XX_GPIO_GPOER &= ~(1 << line); | ||
108 | } | ||
109 | |||
110 | static void gpio_line_get(u8 line, int *value) | ||
111 | { | ||
112 | *value = (*IXP4XX_GPIO_GPINR >> line) & 0x1; | ||
113 | } | ||
114 | |||
115 | static void gpio_line_set(u8 line, int value) | ||
116 | { | ||
117 | if (value == IXP4XX_GPIO_HIGH) | ||
118 | *IXP4XX_GPIO_GPOUTR |= (1 << line); | ||
119 | else if (value == IXP4XX_GPIO_LOW) | ||
120 | *IXP4XX_GPIO_GPOUTR &= ~(1 << line); | ||
121 | } | ||
84 | 122 | ||
85 | /************************************************************************* | 123 | /************************************************************************* |
86 | * IXP4xx chipset IRQ handling | 124 | * IXP4xx chipset IRQ handling |
@@ -117,17 +155,6 @@ static int ixp4xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) | |||
117 | return -EINVAL; | 155 | return -EINVAL; |
118 | } | 156 | } |
119 | 157 | ||
120 | int irq_to_gpio(unsigned int irq) | ||
121 | { | ||
122 | int gpio = (irq < 32) ? irq2gpio[irq] : -EINVAL; | ||
123 | |||
124 | if (gpio == -1) | ||
125 | return -EINVAL; | ||
126 | |||
127 | return gpio; | ||
128 | } | ||
129 | EXPORT_SYMBOL(irq_to_gpio); | ||
130 | |||
131 | static int ixp4xx_set_irq_type(struct irq_data *d, unsigned int type) | 158 | static int ixp4xx_set_irq_type(struct irq_data *d, unsigned int type) |
132 | { | 159 | { |
133 | int line = irq2gpio[d->irq]; | 160 | int line = irq2gpio[d->irq]; |