aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ks8695
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@simtec.co.uk>2008-12-13 15:44:12 -0500
committerBen Dooks <ben-linux@fluff.org>2008-12-14 06:34:47 -0500
commit72880ad866c21badace4d8026c1e58f2fde087fb (patch)
tree83a2a5a7f46ef890426ee83c931c14ac325724be /arch/arm/mach-ks8695
parentfbd627100bc4a9ebce8c7617df499ee5db763780 (diff)
[ARM] KS8695: Fixup the KS8695 GPIO to be GPIOLIB
This patch is as small a change as possible to the KS8695 GPIO layer to use GPIOLIB to allow the generic GPIO expanders and the like to be compiled. As a side-effect, we also remove __init_or_module from several functions which could be called by drivers such as i2c-gpio which could plausibly be compiled into a non-modular kernel. Signed-off-by: Daniel Silverstone <dsilvers@simtec.co.uk> Signed-off-by: Vincent Sanders <vince@simtec.co.uk> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/mach-ks8695')
-rw-r--r--arch/arm/mach-ks8695/board-micrel.c3
-rw-r--r--arch/arm/mach-ks8695/gpio.c39
-rw-r--r--arch/arm/mach-ks8695/include/mach/gpio.h45
3 files changed, 44 insertions, 43 deletions
diff --git a/arch/arm/mach-ks8695/board-micrel.c b/arch/arm/mach-ks8695/board-micrel.c
index 0468e93b7d3b..8ceaf5ac6e2c 100644
--- a/arch/arm/mach-ks8695/board-micrel.c
+++ b/arch/arm/mach-ks8695/board-micrel.c
@@ -18,6 +18,7 @@
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/mach/irq.h> 19#include <asm/mach/irq.h>
20 20
21#include <mach/gpio.h>
21#include <mach/devices.h> 22#include <mach/devices.h>
22 23
23#include "generic.h" 24#include "generic.h"
@@ -39,6 +40,8 @@ static void __init micrel_init(void)
39{ 40{
40 printk(KERN_INFO "Micrel KS8695 Development Board initializing\n"); 41 printk(KERN_INFO "Micrel KS8695 Development Board initializing\n");
41 42
43 ks8695_register_gpios();
44
42#ifdef CONFIG_PCI 45#ifdef CONFIG_PCI
43 ks8695_init_pci(&micrel_pci); 46 ks8695_init_pci(&micrel_pci);
44#endif 47#endif
diff --git a/arch/arm/mach-ks8695/gpio.c b/arch/arm/mach-ks8695/gpio.c
index 9aecf0c4b8b1..26d6346f38f1 100644
--- a/arch/arm/mach-ks8695/gpio.c
+++ b/arch/arm/mach-ks8695/gpio.c
@@ -2,6 +2,8 @@
2 * arch/arm/mach-ks8695/gpio.c 2 * arch/arm/mach-ks8695/gpio.c
3 * 3 *
4 * Copyright (C) 2006 Andrew Victor 4 * Copyright (C) 2006 Andrew Victor
5 * Updated to GPIOLIB, Copyright 2008 Simtec Electronics
6 * Daniel Silverstone <dsilvers@simtec.co.uk>
5 * 7 *
6 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -35,7 +37,7 @@
35 * Configure a GPIO line for either GPIO function, or its internal 37 * Configure a GPIO line for either GPIO function, or its internal
36 * function (Interrupt, Timer, etc). 38 * function (Interrupt, Timer, etc).
37 */ 39 */
38static void __init_or_module ks8695_gpio_mode(unsigned int pin, short gpio) 40static void ks8695_gpio_mode(unsigned int pin, short gpio)
39{ 41{
40 unsigned int enable[] = { IOPC_IOEINT0EN, IOPC_IOEINT1EN, IOPC_IOEINT2EN, IOPC_IOEINT3EN, IOPC_IOTIM0EN, IOPC_IOTIM1EN }; 42 unsigned int enable[] = { IOPC_IOEINT0EN, IOPC_IOEINT1EN, IOPC_IOEINT2EN, IOPC_IOEINT3EN, IOPC_IOTIM0EN, IOPC_IOTIM1EN };
41 unsigned long x, flags; 43 unsigned long x, flags;
@@ -61,7 +63,7 @@ static unsigned short gpio_irq[] = { KS8695_IRQ_EXTERN0, KS8695_IRQ_EXTERN1, KS8
61/* 63/*
62 * Configure GPIO pin as external interrupt source. 64 * Configure GPIO pin as external interrupt source.
63 */ 65 */
64int __init_or_module ks8695_gpio_interrupt(unsigned int pin, unsigned int type) 66int ks8695_gpio_interrupt(unsigned int pin, unsigned int type)
65{ 67{
66 unsigned long x, flags; 68 unsigned long x, flags;
67 69
@@ -94,7 +96,7 @@ EXPORT_SYMBOL(ks8695_gpio_interrupt);
94/* 96/*
95 * Configure the GPIO line as an input. 97 * Configure the GPIO line as an input.
96 */ 98 */
97int __init_or_module gpio_direction_input(unsigned int pin) 99static int ks8695_gpio_direction_input(struct gpio_chip *gc, unsigned int pin)
98{ 100{
99 unsigned long x, flags; 101 unsigned long x, flags;
100 102
@@ -115,13 +117,13 @@ int __init_or_module gpio_direction_input(unsigned int pin)
115 117
116 return 0; 118 return 0;
117} 119}
118EXPORT_SYMBOL(gpio_direction_input);
119 120
120 121
121/* 122/*
122 * Configure the GPIO line as an output, with default state. 123 * Configure the GPIO line as an output, with default state.
123 */ 124 */
124int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state) 125static int ks8695_gpio_direction_output(struct gpio_chip *gc,
126 unsigned int pin, int state)
125{ 127{
126 unsigned long x, flags; 128 unsigned long x, flags;
127 129
@@ -150,13 +152,13 @@ int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state)
150 152
151 return 0; 153 return 0;
152} 154}
153EXPORT_SYMBOL(gpio_direction_output);
154 155
155 156
156/* 157/*
157 * Set the state of an output GPIO line. 158 * Set the state of an output GPIO line.
158 */ 159 */
159void gpio_set_value(unsigned int pin, unsigned int state) 160static void ks8695_gpio_set_value(struct gpio_chip *gc,
161 unsigned int pin, int state)
160{ 162{
161 unsigned long x, flags; 163 unsigned long x, flags;
162 164
@@ -175,13 +177,12 @@ void gpio_set_value(unsigned int pin, unsigned int state)
175 177
176 local_irq_restore(flags); 178 local_irq_restore(flags);
177} 179}
178EXPORT_SYMBOL(gpio_set_value);
179 180
180 181
181/* 182/*
182 * Read the state of a GPIO line. 183 * Read the state of a GPIO line.
183 */ 184 */
184int gpio_get_value(unsigned int pin) 185static int ks8695_gpio_get_value(struct gpio_chip *gc, unsigned int pin)
185{ 186{
186 unsigned long x; 187 unsigned long x;
187 188
@@ -191,7 +192,6 @@ int gpio_get_value(unsigned int pin)
191 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD); 192 x = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
192 return (x & IOPD(pin)) != 0; 193 return (x & IOPD(pin)) != 0;
193} 194}
194EXPORT_SYMBOL(gpio_get_value);
195 195
196 196
197/* 197/*
@@ -219,6 +219,25 @@ int irq_to_gpio(unsigned int irq)
219} 219}
220EXPORT_SYMBOL(irq_to_gpio); 220EXPORT_SYMBOL(irq_to_gpio);
221 221
222/* GPIOLIB interface */
223
224static struct gpio_chip ks8695_gpio_chip = {
225 .label = "KS8695",
226 .direction_input = ks8695_gpio_direction_input,
227 .direction_output = ks8695_gpio_direction_output,
228 .get = ks8695_gpio_get_value,
229 .set = ks8695_gpio_set_value,
230 .base = 0,
231 .ngpio = 16,
232 .can_sleep = 0,
233};
234
235/* Register the GPIOs */
236void ks8695_register_gpios(void)
237{
238 if (gpiochip_add(&ks8695_gpio_chip))
239 printk(KERN_ERR "Unable to register core GPIOs\n");
240}
222 241
223/* .... Debug interface ..................................................... */ 242/* .... Debug interface ..................................................... */
224 243
diff --git a/arch/arm/mach-ks8695/include/mach/gpio.h b/arch/arm/mach-ks8695/include/mach/gpio.h
index d4af5c335f16..6379f2fe843d 100644
--- a/arch/arm/mach-ks8695/include/mach/gpio.h
+++ b/arch/arm/mach-ks8695/include/mach/gpio.h
@@ -30,53 +30,32 @@
30#define KS8695_GPIO_14 14 30#define KS8695_GPIO_14 14
31#define KS8695_GPIO_15 15 31#define KS8695_GPIO_15 15
32 32
33
34/* 33/*
35 * Configure GPIO pin as external interrupt source. 34 * Configure GPIO pin as external interrupt source.
36 */ 35 */
37int __init_or_module ks8695_gpio_interrupt(unsigned int pin, unsigned int type); 36extern int ks8695_gpio_interrupt(unsigned int pin, unsigned int type);
38
39/*
40 * Configure the GPIO line as an input.
41 */
42int __init_or_module gpio_direction_input(unsigned int pin);
43
44/*
45 * Configure the GPIO line as an output, with default state.
46 */
47int __init_or_module gpio_direction_output(unsigned int pin, unsigned int state);
48
49/*
50 * Set the state of an output GPIO line.
51 */
52void gpio_set_value(unsigned int pin, unsigned int state);
53
54/*
55 * Read the state of a GPIO line.
56 */
57int gpio_get_value(unsigned int pin);
58 37
59/* 38/*
60 * Map GPIO line to IRQ number. 39 * Map GPIO line to IRQ number.
61 */ 40 */
62int gpio_to_irq(unsigned int pin); 41extern int gpio_to_irq(unsigned int pin);
63 42
64/* 43/*
65 * Map IRQ number to GPIO line. 44 * Map IRQ number to GPIO line.
66 */ 45 */
67int irq_to_gpio(unsigned int irq); 46extern int irq_to_gpio(unsigned int irq);
68
69 47
70#include <asm-generic/gpio.h> 48#include <asm-generic/gpio.h>
71 49
72static inline int gpio_request(unsigned int pin, const char *label) 50/* If it turns out that we need to optimise GPIO access for the
73{ 51 * Micrel's GPIOs, then these can be changed to check their argument
74 return 0; 52 * directly as static inlines. However for now it's probably not
75} 53 * worthwhile.
54 */
55#define gpio_get_value __gpio_get_value
56#define gpio_set_value __gpio_set_value
76 57
77static inline void gpio_free(unsigned int pin) 58/* Register the GPIOs */
78{ 59extern void ks8695_register_gpios(void);
79 might_sleep();
80}
81 60
82#endif 61#endif