Commit 093199df authored by Ian Campbell's avatar Ian Campbell Committed by Russell King

[ARM PATCH] 1934/2: Consolidate code to set CKEN on PXA

Patch from Ian Campbell

I've seen comments several times that various PXA drivers
update CKEN in an unsafe manner. This patch consolidates
this code into a single function pxa_set_cken() and updates
all the in tree drivers to use it.
parent 9b9b86eb
...@@ -58,6 +58,24 @@ void pxa_gpio_mode(int gpio_mode) ...@@ -58,6 +58,24 @@ void pxa_gpio_mode(int gpio_mode)
EXPORT_SYMBOL(pxa_gpio_mode); EXPORT_SYMBOL(pxa_gpio_mode);
/*
* Routine to safely enable or disable a clock in the CKEN
*/
void pxa_set_cken(int clock, int enable)
{
unsigned long flags;
local_irq_save(flags);
if (enable)
CKEN |= clock;
else
CKEN &= ~clock;
local_irq_restore(flags);
}
EXPORT_SYMBOL(pxa_set_cken);
/* /*
* Intel PXA2xx internal register mapping. * Intel PXA2xx internal register mapping.
* *
......
...@@ -571,14 +571,9 @@ serial_pxa_pm(struct uart_port *port, unsigned int state, ...@@ -571,14 +571,9 @@ serial_pxa_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate) unsigned int oldstate)
{ {
struct uart_pxa_port *up = (struct uart_pxa_port *)port; struct uart_pxa_port *up = (struct uart_pxa_port *)port;
if (state) { pxa_set_cken(up->cken, !state);
/* sleep */ if (!state)
CKEN &= ~up->cken;
} else {
/* wake */
CKEN |= up->cken;
udelay(1); udelay(1);
}
} }
static void serial_pxa_release_port(struct uart_port *port) static void serial_pxa_release_port(struct uart_port *port)
......
...@@ -1406,7 +1406,7 @@ static void udc_disable(struct pxa2xx_udc *dev) ...@@ -1406,7 +1406,7 @@ static void udc_disable(struct pxa2xx_udc *dev)
#ifdef CONFIG_ARCH_PXA #ifdef CONFIG_ARCH_PXA
/* Disable clock for USB device */ /* Disable clock for USB device */
CKEN &= ~CKEN11_USB; pxa_set_cken(CKEN11_USB, 0);
#endif #endif
ep0_idle (dev); ep0_idle (dev);
...@@ -1452,7 +1452,7 @@ static void udc_enable (struct pxa2xx_udc *dev) ...@@ -1452,7 +1452,7 @@ static void udc_enable (struct pxa2xx_udc *dev)
#ifdef CONFIG_ARCH_PXA #ifdef CONFIG_ARCH_PXA
/* Enable clock for USB device */ /* Enable clock for USB device */
CKEN |= CKEN11_USB; pxa_set_cken(CKEN11_USB, 1);
#endif #endif
/* try to clear these bits before we enable the udc */ /* try to clear these bits before we enable the udc */
......
...@@ -1237,7 +1237,6 @@ int __init pxafb_probe(struct device *dev) ...@@ -1237,7 +1237,6 @@ int __init pxafb_probe(struct device *dev)
{ {
struct pxafb_info *fbi; struct pxafb_info *fbi;
struct pxafb_mach_info *inf; struct pxafb_mach_info *inf;
unsigned long flags;
int ret; int ret;
dev_dbg(dev, "pxafb_probe\n"); dev_dbg(dev, "pxafb_probe\n");
...@@ -1301,9 +1300,7 @@ int __init pxafb_probe(struct device *dev) ...@@ -1301,9 +1300,7 @@ int __init pxafb_probe(struct device *dev)
goto failed; goto failed;
} }
/* enable LCD controller clock */ /* enable LCD controller clock */
local_irq_save(flags); pxa_set_cken(CKEN16_LCD, 1);
CKEN |= CKEN16_LCD;
local_irq_restore(flags);
ret = request_irq(IRQ_LCD, pxafb_handle_irq, SA_INTERRUPT, "LCD", fbi); ret = request_irq(IRQ_LCD, pxafb_handle_irq, SA_INTERRUPT, "LCD", fbi);
if (ret) { if (ret) {
......
...@@ -82,6 +82,11 @@ typedef struct { volatile u32 offset[4096]; } __regbase; ...@@ -82,6 +82,11 @@ typedef struct { volatile u32 offset[4096]; } __regbase;
*/ */
extern void pxa_gpio_mode( int gpio_mode ); extern void pxa_gpio_mode( int gpio_mode );
/*
* Routine to enable or disable CKEN
*/
extern void pxa_set_cken(int clock, int enable);
/* /*
* return current memory and LCD clock frequency in units of 10kHz * return current memory and LCD clock frequency in units of 10kHz
*/ */
......
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