aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Svoboda <msvoboda@ra.rockwell.com>2007-02-07 02:43:35 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-02-08 09:56:51 -0500
commit32f3f49910c7e228839c1cd144dbed8da342703b (patch)
tree5ec3ad94819aed7ea5a692bd01bea587acb85084
parent45cf5eef4fa8bcd8d3aca3c2a0703d791c9ea56c (diff)
[ARM] 4141/1: consolidate functions that handles gpio in pxa2xx_udc
This patch renames pxa_gpio_set/get functions defined in drivers/usb/gadget/pxa2xx_udc.h to udc_gpio_set/get. These functions are moved from drivers/usb/gadget/pxa2xx_udc.h to include/asm-arm/arch-pxa2xx/udc.h Creates new functions: udc_gpio_to_irq, udc_gpio_init_vbus, udc_gpio_init_pullup in include/asm-arm/arch-pxa2xx/udc.h. These functions are used in drivers/usb/gadget/pxa2xx_udc.c instead of direct low-level (pxa2xx only) functions. Creates all these udc_gpio_* functions in include/asm-arm/arch-ixp4xx/udc.h. This implementation has no real code because ixp4xx doesn't use vbus - only vbus uses all these gpio functions (and because ixp4xx misses any function which converts number of gpio pin into it's irq). This is next step to make pxa2xx_udc fully work on ixp4xx platform. Signed-off-by: Milan Svoboda <msvoboda@ra.rockwell.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c16
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.h15
-rw-r--r--include/asm-arm/arch-ixp4xx/udc.h22
-rw-r--r--include/asm-arm/arch-pxa/udc.h30
4 files changed, 59 insertions, 24 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index b78de9694665..3547f049237e 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -156,7 +156,7 @@ static int is_vbus_present(void)
156 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 156 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
157 157
158 if (mach->gpio_vbus) 158 if (mach->gpio_vbus)
159 return pxa_gpio_get(mach->gpio_vbus); 159 return udc_gpio_get(mach->gpio_vbus);
160 if (mach->udc_is_connected) 160 if (mach->udc_is_connected)
161 return mach->udc_is_connected(); 161 return mach->udc_is_connected();
162 return 1; 162 return 1;
@@ -168,7 +168,7 @@ static void pullup_off(void)
168 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 168 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
169 169
170 if (mach->gpio_pullup) 170 if (mach->gpio_pullup)
171 pxa_gpio_set(mach->gpio_pullup, 0); 171 udc_gpio_set(mach->gpio_pullup, 0);
172 else if (mach->udc_command) 172 else if (mach->udc_command)
173 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 173 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
174} 174}
@@ -178,7 +178,7 @@ static void pullup_on(void)
178 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 178 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
179 179
180 if (mach->gpio_pullup) 180 if (mach->gpio_pullup)
181 pxa_gpio_set(mach->gpio_pullup, 1); 181 udc_gpio_set(mach->gpio_pullup, 1);
182 else if (mach->udc_command) 182 else if (mach->udc_command)
183 mach->udc_command(PXA2XX_UDC_CMD_CONNECT); 183 mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
184} 184}
@@ -1756,7 +1756,7 @@ lubbock_vbus_irq(int irq, void *_dev)
1756static irqreturn_t udc_vbus_irq(int irq, void *_dev) 1756static irqreturn_t udc_vbus_irq(int irq, void *_dev)
1757{ 1757{
1758 struct pxa2xx_udc *dev = _dev; 1758 struct pxa2xx_udc *dev = _dev;
1759 int vbus = pxa_gpio_get(dev->mach->gpio_vbus); 1759 int vbus = udc_gpio_get(dev->mach->gpio_vbus);
1760 1760
1761 pxa2xx_udc_vbus_session(&dev->gadget, vbus); 1761 pxa2xx_udc_vbus_session(&dev->gadget, vbus);
1762 return IRQ_HANDLED; 1762 return IRQ_HANDLED;
@@ -2546,15 +2546,13 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2546 dev->dev = &pdev->dev; 2546 dev->dev = &pdev->dev;
2547 dev->mach = pdev->dev.platform_data; 2547 dev->mach = pdev->dev.platform_data;
2548 if (dev->mach->gpio_vbus) { 2548 if (dev->mach->gpio_vbus) {
2549 vbus_irq = IRQ_GPIO(dev->mach->gpio_vbus & GPIO_MD_MASK_NR); 2549 udc_gpio_init_vbus(dev->mach->gpio_vbus);
2550 pxa_gpio_mode((dev->mach->gpio_vbus & GPIO_MD_MASK_NR) 2550 vbus_irq = udc_gpio_to_irq(dev->mach->gpio_vbus);
2551 | GPIO_IN);
2552 set_irq_type(vbus_irq, IRQT_BOTHEDGE); 2551 set_irq_type(vbus_irq, IRQT_BOTHEDGE);
2553 } else 2552 } else
2554 vbus_irq = 0; 2553 vbus_irq = 0;
2555 if (dev->mach->gpio_pullup) 2554 if (dev->mach->gpio_pullup)
2556 pxa_gpio_mode((dev->mach->gpio_pullup & GPIO_MD_MASK_NR) 2555 udc_gpio_init_pullup(dev->mach->gpio_pullup);
2557 | GPIO_OUT | GPIO_DFLT_LOW);
2558 2556
2559 init_timer(&dev->timer); 2557 init_timer(&dev->timer);
2560 dev->timer.function = udc_watchdog; 2558 dev->timer.function = udc_watchdog;
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h
index 8e598c8bf4e3..773e549aff3f 100644
--- a/drivers/usb/gadget/pxa2xx_udc.h
+++ b/drivers/usb/gadget/pxa2xx_udc.h
@@ -177,21 +177,6 @@ struct pxa2xx_udc {
177 177
178static struct pxa2xx_udc *the_controller; 178static struct pxa2xx_udc *the_controller;
179 179
180static inline int pxa_gpio_get(unsigned gpio)
181{
182 return (GPLR(gpio) & GPIO_bit(gpio)) != 0;
183}
184
185static inline void pxa_gpio_set(unsigned gpio, int is_on)
186{
187 int mask = GPIO_bit(gpio);
188
189 if (is_on)
190 GPSR(gpio) = mask;
191 else
192 GPCR(gpio) = mask;
193}
194
195/*-------------------------------------------------------------------------*/ 180/*-------------------------------------------------------------------------*/
196 181
197/* 182/*
diff --git a/include/asm-arm/arch-ixp4xx/udc.h b/include/asm-arm/arch-ixp4xx/udc.h
index dbdec36ff0d1..79b850a3be47 100644
--- a/include/asm-arm/arch-ixp4xx/udc.h
+++ b/include/asm-arm/arch-ixp4xx/udc.h
@@ -6,3 +6,25 @@
6 6
7extern void ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info); 7extern void ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info);
8 8
9static inline int udc_gpio_to_irq(unsigned gpio)
10{
11 return 0;
12}
13
14static inline void udc_gpio_init_vbus(unsigned gpio)
15{
16}
17
18static inline void udc_gpio_init_pullup(unsigned gpio)
19{
20}
21
22static inline int udc_gpio_get(unsigned gpio)
23{
24 return 0;
25}
26
27static inline void udc_gpio_set(unsigned gpio, int is_on)
28{
29}
30
diff --git a/include/asm-arm/arch-pxa/udc.h b/include/asm-arm/arch-pxa/udc.h
index 646480d37256..8bc6f9c3e3ea 100644
--- a/include/asm-arm/arch-pxa/udc.h
+++ b/include/asm-arm/arch-pxa/udc.h
@@ -9,3 +9,33 @@
9 9
10extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info); 10extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info);
11 11
12static inline int udc_gpio_to_irq(unsigned gpio)
13{
14 return IRQ_GPIO(gpio & GPIO_MD_MASK_NR);
15}
16
17static inline void udc_gpio_init_vbus(unsigned gpio)
18{
19 pxa_gpio_mode((gpio & GPIO_MD_MASK_NR) | GPIO_IN);
20}
21
22static inline void udc_gpio_init_pullup(unsigned gpio)
23{
24 pxa_gpio_mode((gpio & GPIO_MD_MASK_NR) | GPIO_OUT | GPIO_DFLT_LOW);
25}
26
27static inline int udc_gpio_get(unsigned gpio)
28{
29 return (GPLR(gpio) & GPIO_bit(gpio)) != 0;
30}
31
32static inline void udc_gpio_set(unsigned gpio, int is_on)
33{
34 int mask = GPIO_bit(gpio);
35
36 if (is_on)
37 GPSR(gpio) = mask;
38 else
39 GPCR(gpio) = mask;
40}
41