Commit 89c248f7 authored by Russell King's avatar Russell King

[ARM] StrongARM SA1111 cleanups

- Add sa1111_{dis,en}able_device()
- Add sa1111_{read,write}l() (always host endian)
parent 5f563f59
......@@ -59,7 +59,7 @@ static int __init adsbitsy_init(void)
/*
* Enable PWM control for LCD
*/
SKPCR |= SKPCR_PWMCLKEN;
sa1111_enable_device(SKPCR_PWMCLKEN);
SKPWM0 = 0x7F; // VEE
SKPEN0 = 1;
SKPWM1 = 0x01; // Backlight
......
......@@ -49,7 +49,7 @@ static int __init graphicsmaster_init(void)
/*
* Enable PWM control for LCD
*/
SKPCR |= SKPCR_PWMCLKEN;
sa1111_enable_device(SKPCR_PWMCLKEN);
SKPWM0 = 0x7F; // VEE
SKPEN0 = 1;
SKPWM1 = 0x01; // Backlight
......
......@@ -304,7 +304,7 @@ sa1111_probe(struct device *parent, unsigned long phys_addr)
/*
* Probe for the chip. Only touch the SBI registers.
*/
id = readl(sa->base + SA1111_SKID);
id = sa1111_readl(sa->base + SA1111_SKID);
if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
printk(KERN_DEBUG "SA1111 not detected: ID = %08lx\n", id);
ret = -ENODEV;
......@@ -372,11 +372,11 @@ void sa1111_wake(void)
/*
* Turn VCO on, and disable PLL Bypass.
*/
r = readl(sa->base + SA1111_SKCR);
r = sa1111_readl(sa->base + SA1111_SKCR);
r &= ~SKCR_VCO_OFF;
writel(r, sa->base + SA1111_SKCR);
sa1111_writel(r, sa->base + SA1111_SKCR);
r |= SKCR_PLL_BYPASS | SKCR_OE_EN;
writel(r, sa->base + SA1111_SKCR);
sa1111_writel(r, sa->base + SA1111_SKCR);
/*
* Wait lock time. SA1111 manual _doesn't_
......@@ -388,7 +388,7 @@ void sa1111_wake(void)
* Enable RCLK. We also ensure that RDYEN is set.
*/
r |= SKCR_RCLKEN | SKCR_RDYEN;
writel(r, sa->base + SA1111_SKCR);
sa1111_writel(r, sa->base + SA1111_SKCR);
/*
* Wait 14 RCLK cycles for the chip to finish coming out
......@@ -399,7 +399,7 @@ void sa1111_wake(void)
/*
* Ensure all clocks are initially off.
*/
writel(0, sa->base + SA1111_SKPCR);
sa1111_writel(0, sa->base + SA1111_SKPCR);
local_irq_restore(flags);
}
......@@ -408,16 +408,18 @@ void sa1111_doze(void)
{
struct sa1111_device *sa = sa1111;
unsigned long flags;
unsigned int val;
local_irq_save(flags);
if (readl(sa->base + SA1111_SKPCR) & SKPCR_UCLKEN) {
if (sa1111_readl(sa->base + SA1111_SKPCR) & SKPCR_UCLKEN) {
local_irq_restore(flags);
printk("SA1111 doze mode refused\n");
return;
}
writel(readl(sa->base + SA1111_SKCR) & ~SKCR_RCLKEN, sa->base + SA1111_SKCR);
val = sa1111_readl(sa->base + SA1111_SKCR);
sa1111_writel(val & ~SKCR_RCLKEN, sa->base + SA1111_SKCR);
local_irq_restore(flags);
}
......@@ -432,9 +434,37 @@ void sa1111_configure_smc(int sdram, unsigned int drac, unsigned int cas_latency
if (cas_latency == 3)
smcr |= SMCR_CLAT;
writel(smcr, sa->base + SA1111_SMCR);
sa1111_writel(smcr, sa->base + SA1111_SMCR);
}
EXPORT_SYMBOL(sa1111_wake);
EXPORT_SYMBOL(sa1111_doze);
void sa1111_enable_device(unsigned int mask)
{
struct sa1111_device *sa = sa1111;
unsigned int val;
preempt_disable();
val = sa1111_readl(sa->base + SA1111_SKPCR);
sa1111_writel(val | mask, sa->base + SA1111_SKPCR);
preempt_enable();
}
void sa1111_disable_device(unsigned int mask)
{
struct sa1111_device *sa = sa1111;
unsigned int val;
preempt_disable();
val = sa1111_readl(sa->base + SA1111_SKPCR);
sa1111_writel(val & ~mask, sa->base + SA1111_SKPCR);
preempt_enable();
}
EXPORT_SYMBOL(sa1111_enable_device);
EXPORT_SYMBOL(sa1111_disable_device);
/* According to the "Intel StrongARM SA-1111 Microprocessor Companion
* Chip Specification Update" (June 2000), erratum #7, there is a
* significant bug in Serial Audio Controller DMA. If the SAC is
......@@ -529,7 +559,7 @@ int sa1111_init(struct device *parent, unsigned long phys, unsigned int irq)
* We only need to turn on DCLK whenever we want to use the
* DMA. It can otherwise be held firmly in the off position.
*/
SKPCR |= SKPCR_DCLKEN;
sa1111_enable_device(SKPCR_DCLKEN);
/*
* Enable the SA1110 memory bus request and grant signals.
......
......@@ -309,7 +309,7 @@ static void system3_lcd_on(void)
PTCTRL0_set( PT_CTRL0_LCD_EN );
/* brightness / contrast */
SKPCR |= SKPCR_PWMCLKEN;
sa1111_enable_device(SKPCR_PWMCLKEN);
PB_DDR = 0xFFFFFFFF;
SKPEN0 = 1;
SKPEN1 = 1;
......@@ -325,7 +325,7 @@ static void system3_lcd_off(void)
PTCTRL0_clear( PT_CTRL0_LCD_EN );
SKPEN0 = 0;
SKPEN1 = 0;
SKPCR &= ~SKPCR_PWMCLKEN;
sa1111_disable_device(SKPCR_PWMCLKEN);
}
/**
......
......@@ -49,6 +49,9 @@
*/
#define __CCREG(x) __REGP(SA1111_VBASE + (x))
#define sa1111_writel(val,addr) ({ *(volatile unsigned int *)(addr) = (val); })
#define sa1111_readl(addr) (*(volatile unsigned int *)(addr))
/*
* System Bus Interface (SBI)
*
......@@ -697,4 +700,10 @@ struct sa1111_device {
extern struct sa1111_device *sa1111;
/*
* These frob the SKPCR register.
*/
void sa1111_enable_device(unsigned int mask);
void sa1111_disable_device(unsigned int mask);
#endif /* _ASM_ARCH_SA1111 */
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