Commit 32f3f499 authored by Milan Svoboda's avatar Milan Svoboda Committed by Russell King

[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: default avatarMilan Svoboda <msvoboda@ra.rockwell.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 45cf5eef
...@@ -156,7 +156,7 @@ static int is_vbus_present(void) ...@@ -156,7 +156,7 @@ static int is_vbus_present(void)
struct pxa2xx_udc_mach_info *mach = the_controller->mach; struct pxa2xx_udc_mach_info *mach = the_controller->mach;
if (mach->gpio_vbus) if (mach->gpio_vbus)
return pxa_gpio_get(mach->gpio_vbus); return udc_gpio_get(mach->gpio_vbus);
if (mach->udc_is_connected) if (mach->udc_is_connected)
return mach->udc_is_connected(); return mach->udc_is_connected();
return 1; return 1;
...@@ -168,7 +168,7 @@ static void pullup_off(void) ...@@ -168,7 +168,7 @@ static void pullup_off(void)
struct pxa2xx_udc_mach_info *mach = the_controller->mach; struct pxa2xx_udc_mach_info *mach = the_controller->mach;
if (mach->gpio_pullup) if (mach->gpio_pullup)
pxa_gpio_set(mach->gpio_pullup, 0); udc_gpio_set(mach->gpio_pullup, 0);
else if (mach->udc_command) else if (mach->udc_command)
mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
} }
...@@ -178,7 +178,7 @@ static void pullup_on(void) ...@@ -178,7 +178,7 @@ static void pullup_on(void)
struct pxa2xx_udc_mach_info *mach = the_controller->mach; struct pxa2xx_udc_mach_info *mach = the_controller->mach;
if (mach->gpio_pullup) if (mach->gpio_pullup)
pxa_gpio_set(mach->gpio_pullup, 1); udc_gpio_set(mach->gpio_pullup, 1);
else if (mach->udc_command) else if (mach->udc_command)
mach->udc_command(PXA2XX_UDC_CMD_CONNECT); mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
} }
...@@ -1756,7 +1756,7 @@ lubbock_vbus_irq(int irq, void *_dev) ...@@ -1756,7 +1756,7 @@ lubbock_vbus_irq(int irq, void *_dev)
static irqreturn_t udc_vbus_irq(int irq, void *_dev) static irqreturn_t udc_vbus_irq(int irq, void *_dev)
{ {
struct pxa2xx_udc *dev = _dev; struct pxa2xx_udc *dev = _dev;
int vbus = pxa_gpio_get(dev->mach->gpio_vbus); int vbus = udc_gpio_get(dev->mach->gpio_vbus);
pxa2xx_udc_vbus_session(&dev->gadget, vbus); pxa2xx_udc_vbus_session(&dev->gadget, vbus);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -2546,15 +2546,13 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) ...@@ -2546,15 +2546,13 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->mach = pdev->dev.platform_data; dev->mach = pdev->dev.platform_data;
if (dev->mach->gpio_vbus) { if (dev->mach->gpio_vbus) {
vbus_irq = IRQ_GPIO(dev->mach->gpio_vbus & GPIO_MD_MASK_NR); udc_gpio_init_vbus(dev->mach->gpio_vbus);
pxa_gpio_mode((dev->mach->gpio_vbus & GPIO_MD_MASK_NR) vbus_irq = udc_gpio_to_irq(dev->mach->gpio_vbus);
| GPIO_IN);
set_irq_type(vbus_irq, IRQT_BOTHEDGE); set_irq_type(vbus_irq, IRQT_BOTHEDGE);
} else } else
vbus_irq = 0; vbus_irq = 0;
if (dev->mach->gpio_pullup) if (dev->mach->gpio_pullup)
pxa_gpio_mode((dev->mach->gpio_pullup & GPIO_MD_MASK_NR) udc_gpio_init_pullup(dev->mach->gpio_pullup);
| GPIO_OUT | GPIO_DFLT_LOW);
init_timer(&dev->timer); init_timer(&dev->timer);
dev->timer.function = udc_watchdog; dev->timer.function = udc_watchdog;
......
...@@ -177,21 +177,6 @@ struct pxa2xx_udc { ...@@ -177,21 +177,6 @@ struct pxa2xx_udc {
static struct pxa2xx_udc *the_controller; static struct pxa2xx_udc *the_controller;
static inline int pxa_gpio_get(unsigned gpio)
{
return (GPLR(gpio) & GPIO_bit(gpio)) != 0;
}
static inline void pxa_gpio_set(unsigned gpio, int is_on)
{
int mask = GPIO_bit(gpio);
if (is_on)
GPSR(gpio) = mask;
else
GPCR(gpio) = mask;
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
......
...@@ -6,3 +6,25 @@ ...@@ -6,3 +6,25 @@
extern void ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info); extern void ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info);
static inline int udc_gpio_to_irq(unsigned gpio)
{
return 0;
}
static inline void udc_gpio_init_vbus(unsigned gpio)
{
}
static inline void udc_gpio_init_pullup(unsigned gpio)
{
}
static inline int udc_gpio_get(unsigned gpio)
{
return 0;
}
static inline void udc_gpio_set(unsigned gpio, int is_on)
{
}
...@@ -9,3 +9,33 @@ ...@@ -9,3 +9,33 @@
extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info); extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info);
static inline int udc_gpio_to_irq(unsigned gpio)
{
return IRQ_GPIO(gpio & GPIO_MD_MASK_NR);
}
static inline void udc_gpio_init_vbus(unsigned gpio)
{
pxa_gpio_mode((gpio & GPIO_MD_MASK_NR) | GPIO_IN);
}
static inline void udc_gpio_init_pullup(unsigned gpio)
{
pxa_gpio_mode((gpio & GPIO_MD_MASK_NR) | GPIO_OUT | GPIO_DFLT_LOW);
}
static inline int udc_gpio_get(unsigned gpio)
{
return (GPLR(gpio) & GPIO_bit(gpio)) != 0;
}
static inline void udc_gpio_set(unsigned gpio, int is_on)
{
int mask = GPIO_bit(gpio);
if (is_on)
GPSR(gpio) = mask;
else
GPCR(gpio) = mask;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment