Merge branch 'pm-upstream/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm

This commit is contained in:
Russell King 2009-08-10 15:50:27 +01:00 committed by Russell King
commit 96a4d1e234
9 changed files with 198 additions and 79 deletions

View File

@ -52,6 +52,7 @@
#define OVERO_GPIO_BT_XGATE 15 #define OVERO_GPIO_BT_XGATE 15
#define OVERO_GPIO_W2W_NRESET 16 #define OVERO_GPIO_W2W_NRESET 16
#define OVERO_GPIO_PENDOWN 114
#define OVERO_GPIO_BT_NRESET 164 #define OVERO_GPIO_BT_NRESET 164
#define OVERO_GPIO_USBH_CPEN 168 #define OVERO_GPIO_USBH_CPEN 168
#define OVERO_GPIO_USBH_NRESET 183 #define OVERO_GPIO_USBH_NRESET 183

View File

@ -29,9 +29,9 @@
* These registers appear once per CM module. * These registers appear once per CM module.
*/ */
#define OMAP3430_CM_REVISION OMAP_CM_REGADDR(OCP_MOD, 0x0000) #define OMAP3430_CM_REVISION OMAP34XX_CM_REGADDR(OCP_MOD, 0x0000)
#define OMAP3430_CM_SYSCONFIG OMAP_CM_REGADDR(OCP_MOD, 0x0010) #define OMAP3430_CM_SYSCONFIG OMAP34XX_CM_REGADDR(OCP_MOD, 0x0010)
#define OMAP3430_CM_POLCTRL OMAP_CM_REGADDR(OCP_MOD, 0x009c) #define OMAP3430_CM_POLCTRL OMAP34XX_CM_REGADDR(OCP_MOD, 0x009c)
#define OMAP3_CM_CLKOUT_CTRL_OFFSET 0x0070 #define OMAP3_CM_CLKOUT_CTRL_OFFSET 0x0070
#define OMAP3430_CM_CLKOUT_CTRL OMAP_CM_REGADDR(OMAP3430_CCR_MOD, 0x0070) #define OMAP3430_CM_CLKOUT_CTRL OMAP_CM_REGADDR(OMAP3430_CCR_MOD, 0x0070)

View File

@ -11,9 +11,6 @@
#ifndef __ARCH_ARM_MACH_OMAP2_PM_H #ifndef __ARCH_ARM_MACH_OMAP2_PM_H
#define __ARCH_ARM_MACH_OMAP2_PM_H #define __ARCH_ARM_MACH_OMAP2_PM_H
extern int omap2_pm_init(void);
extern int omap3_pm_init(void);
#ifdef CONFIG_PM_DEBUG #ifdef CONFIG_PM_DEBUG
extern void omap2_pm_dump(int mode, int resume, unsigned int us); extern void omap2_pm_dump(int mode, int resume, unsigned int us);
extern int omap2_pm_debug; extern int omap2_pm_debug;

View File

@ -470,7 +470,7 @@ static void __init prcm_setup_regs(void)
WKUP_MOD, PM_WKEN); WKUP_MOD, PM_WKEN);
} }
int __init omap2_pm_init(void) static int __init omap2_pm_init(void)
{ {
u32 l; u32 l;

View File

@ -39,7 +39,9 @@
struct power_state { struct power_state {
struct powerdomain *pwrdm; struct powerdomain *pwrdm;
u32 next_state; u32 next_state;
#ifdef CONFIG_SUSPEND
u32 saved_state; u32 saved_state;
#endif
struct list_head node; struct list_head node;
}; };
@ -293,6 +295,9 @@ static void omap3_pm_idle(void)
local_irq_enable(); local_irq_enable();
} }
#ifdef CONFIG_SUSPEND
static suspend_state_t suspend_state;
static int omap3_pm_prepare(void) static int omap3_pm_prepare(void)
{ {
disable_hlt(); disable_hlt();
@ -321,7 +326,6 @@ static int omap3_pm_suspend(void)
restore: restore:
/* Restore next_pwrsts */ /* Restore next_pwrsts */
list_for_each_entry(pwrst, &pwrst_list, node) { list_for_each_entry(pwrst, &pwrst_list, node) {
set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
state = pwrdm_read_prev_pwrst(pwrst->pwrdm); state = pwrdm_read_prev_pwrst(pwrst->pwrdm);
if (state > pwrst->next_state) { if (state > pwrst->next_state) {
printk(KERN_INFO "Powerdomain (%s) didn't enter " printk(KERN_INFO "Powerdomain (%s) didn't enter "
@ -329,6 +333,7 @@ static int omap3_pm_suspend(void)
pwrst->pwrdm->name, pwrst->next_state); pwrst->pwrdm->name, pwrst->next_state);
ret = -1; ret = -1;
} }
set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
} }
if (ret) if (ret)
printk(KERN_ERR "Could not enter target state in pm_suspend\n"); printk(KERN_ERR "Could not enter target state in pm_suspend\n");
@ -339,11 +344,11 @@ static int omap3_pm_suspend(void)
return ret; return ret;
} }
static int omap3_pm_enter(suspend_state_t state) static int omap3_pm_enter(suspend_state_t unused)
{ {
int ret = 0; int ret = 0;
switch (state) { switch (suspend_state) {
case PM_SUSPEND_STANDBY: case PM_SUSPEND_STANDBY:
case PM_SUSPEND_MEM: case PM_SUSPEND_MEM:
ret = omap3_pm_suspend(); ret = omap3_pm_suspend();
@ -360,12 +365,30 @@ static void omap3_pm_finish(void)
enable_hlt(); enable_hlt();
} }
/* Hooks to enable / disable UART interrupts during suspend */
static int omap3_pm_begin(suspend_state_t state)
{
suspend_state = state;
omap_uart_enable_irqs(0);
return 0;
}
static void omap3_pm_end(void)
{
suspend_state = PM_SUSPEND_ON;
omap_uart_enable_irqs(1);
return;
}
static struct platform_suspend_ops omap_pm_ops = { static struct platform_suspend_ops omap_pm_ops = {
.begin = omap3_pm_begin,
.end = omap3_pm_end,
.prepare = omap3_pm_prepare, .prepare = omap3_pm_prepare,
.enter = omap3_pm_enter, .enter = omap3_pm_enter,
.finish = omap3_pm_finish, .finish = omap3_pm_finish,
.valid = suspend_valid_only_mem, .valid = suspend_valid_only_mem,
}; };
#endif /* CONFIG_SUSPEND */
/** /**
@ -613,6 +636,24 @@ static void __init prcm_setup_regs(void)
/* Clear any pending PRCM interrupts */ /* Clear any pending PRCM interrupts */
prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
/* Don't attach IVA interrupts */
prm_write_mod_reg(0, WKUP_MOD, OMAP3430_PM_IVAGRPSEL);
prm_write_mod_reg(0, CORE_MOD, OMAP3430_PM_IVAGRPSEL1);
prm_write_mod_reg(0, CORE_MOD, OMAP3430ES2_PM_IVAGRPSEL3);
prm_write_mod_reg(0, OMAP3430_PER_MOD, OMAP3430_PM_IVAGRPSEL);
/* Clear any pending 'reset' flags */
prm_write_mod_reg(0xffffffff, MPU_MOD, RM_RSTST);
prm_write_mod_reg(0xffffffff, CORE_MOD, RM_RSTST);
prm_write_mod_reg(0xffffffff, OMAP3430_PER_MOD, RM_RSTST);
prm_write_mod_reg(0xffffffff, OMAP3430_EMU_MOD, RM_RSTST);
prm_write_mod_reg(0xffffffff, OMAP3430_NEON_MOD, RM_RSTST);
prm_write_mod_reg(0xffffffff, OMAP3430_DSS_MOD, RM_RSTST);
prm_write_mod_reg(0xffffffff, OMAP3430ES2_USBHOST_MOD, RM_RSTST);
/* Clear any pending PRCM interrupts */
prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
omap3_iva_idle(); omap3_iva_idle();
omap3_d2d_idle(); omap3_d2d_idle();
} }
@ -652,7 +693,7 @@ static int __init clkdms_setup(struct clockdomain *clkdm)
return 0; return 0;
} }
int __init omap3_pm_init(void) static int __init omap3_pm_init(void)
{ {
struct power_state *pwrst, *tmp; struct power_state *pwrst, *tmp;
int ret; int ret;
@ -692,7 +733,9 @@ int __init omap3_pm_init(void)
_omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend, _omap_sram_idle = omap_sram_push(omap34xx_cpu_suspend,
omap34xx_cpu_suspend_sz); omap34xx_cpu_suspend_sz);
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops); suspend_set_ops(&omap_pm_ops);
#endif /* CONFIG_SUSPEND */
pm_idle = omap3_pm_idle; pm_idle = omap3_pm_idle;

View File

@ -54,6 +54,7 @@ struct omap_uart_state {
struct plat_serial8250_port *p; struct plat_serial8250_port *p;
struct list_head node; struct list_head node;
struct platform_device pdev;
#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
int context_valid; int context_valid;
@ -68,10 +69,9 @@ struct omap_uart_state {
#endif #endif
}; };
static struct omap_uart_state omap_uart[OMAP_MAX_NR_PORTS];
static LIST_HEAD(uart_list); static LIST_HEAD(uart_list);
static struct plat_serial8250_port serial_platform_data[] = { static struct plat_serial8250_port serial_platform_data0[] = {
{ {
.membase = IO_ADDRESS(OMAP_UART1_BASE), .membase = IO_ADDRESS(OMAP_UART1_BASE),
.mapbase = OMAP_UART1_BASE, .mapbase = OMAP_UART1_BASE,
@ -81,6 +81,12 @@ static struct plat_serial8250_port serial_platform_data[] = {
.regshift = 2, .regshift = 2,
.uartclk = OMAP24XX_BASE_BAUD * 16, .uartclk = OMAP24XX_BASE_BAUD * 16,
}, { }, {
.flags = 0
}
};
static struct plat_serial8250_port serial_platform_data1[] = {
{
.membase = IO_ADDRESS(OMAP_UART2_BASE), .membase = IO_ADDRESS(OMAP_UART2_BASE),
.mapbase = OMAP_UART2_BASE, .mapbase = OMAP_UART2_BASE,
.irq = 73, .irq = 73,
@ -89,6 +95,12 @@ static struct plat_serial8250_port serial_platform_data[] = {
.regshift = 2, .regshift = 2,
.uartclk = OMAP24XX_BASE_BAUD * 16, .uartclk = OMAP24XX_BASE_BAUD * 16,
}, { }, {
.flags = 0
}
};
static struct plat_serial8250_port serial_platform_data2[] = {
{
.membase = IO_ADDRESS(OMAP_UART3_BASE), .membase = IO_ADDRESS(OMAP_UART3_BASE),
.mapbase = OMAP_UART3_BASE, .mapbase = OMAP_UART3_BASE,
.irq = 74, .irq = 74,
@ -217,6 +229,40 @@ static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
clk_disable(uart->fck); clk_disable(uart->fck);
} }
static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
{
/* Set wake-enable bit */
if (uart->wk_en && uart->wk_mask) {
u32 v = __raw_readl(uart->wk_en);
v |= uart->wk_mask;
__raw_writel(v, uart->wk_en);
}
/* Ensure IOPAD wake-enables are set */
if (cpu_is_omap34xx() && uart->padconf) {
u16 v = omap_ctrl_readw(uart->padconf);
v |= OMAP3_PADCONF_WAKEUPENABLE0;
omap_ctrl_writew(v, uart->padconf);
}
}
static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
{
/* Clear wake-enable bit */
if (uart->wk_en && uart->wk_mask) {
u32 v = __raw_readl(uart->wk_en);
v &= ~uart->wk_mask;
__raw_writel(v, uart->wk_en);
}
/* Ensure IOPAD wake-enables are cleared */
if (cpu_is_omap34xx() && uart->padconf) {
u16 v = omap_ctrl_readw(uart->padconf);
v &= ~OMAP3_PADCONF_WAKEUPENABLE0;
omap_ctrl_writew(v, uart->padconf);
}
}
static void omap_uart_smart_idle_enable(struct omap_uart_state *uart, static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
int enable) int enable)
{ {
@ -246,6 +292,11 @@ static void omap_uart_block_sleep(struct omap_uart_state *uart)
static void omap_uart_allow_sleep(struct omap_uart_state *uart) static void omap_uart_allow_sleep(struct omap_uart_state *uart)
{ {
if (device_may_wakeup(&uart->pdev.dev))
omap_uart_enable_wakeup(uart);
else
omap_uart_disable_wakeup(uart);
if (!uart->clocked) if (!uart->clocked)
return; return;
@ -292,7 +343,6 @@ void omap_uart_resume_idle(int num)
/* Check for normal UART wakeup */ /* Check for normal UART wakeup */
if (__raw_readl(uart->wk_st) & uart->wk_mask) if (__raw_readl(uart->wk_st) & uart->wk_mask)
omap_uart_block_sleep(uart); omap_uart_block_sleep(uart);
return; return;
} }
} }
@ -346,16 +396,13 @@ static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
return IRQ_NONE; return IRQ_NONE;
} }
static u32 sleep_timeout = DEFAULT_TIMEOUT;
static void omap_uart_idle_init(struct omap_uart_state *uart) static void omap_uart_idle_init(struct omap_uart_state *uart)
{ {
u32 v;
struct plat_serial8250_port *p = uart->p; struct plat_serial8250_port *p = uart->p;
int ret; int ret;
uart->can_sleep = 0; uart->can_sleep = 0;
uart->timeout = sleep_timeout; uart->timeout = DEFAULT_TIMEOUT;
setup_timer(&uart->timer, omap_uart_idle_timer, setup_timer(&uart->timer, omap_uart_idle_timer,
(unsigned long) uart); (unsigned long) uart);
mod_timer(&uart->timer, jiffies + uart->timeout); mod_timer(&uart->timer, jiffies + uart->timeout);
@ -413,76 +460,101 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
uart->padconf = 0; uart->padconf = 0;
} }
/* Set wake-enable bit */
if (uart->wk_en && uart->wk_mask) {
v = __raw_readl(uart->wk_en);
v |= uart->wk_mask;
__raw_writel(v, uart->wk_en);
}
/* Ensure IOPAD wake-enables are set */
if (cpu_is_omap34xx() && uart->padconf) {
u16 v;
v = omap_ctrl_readw(uart->padconf);
v |= OMAP3_PADCONF_WAKEUPENABLE0;
omap_ctrl_writew(v, uart->padconf);
}
p->flags |= UPF_SHARE_IRQ; p->flags |= UPF_SHARE_IRQ;
ret = request_irq(p->irq, omap_uart_interrupt, IRQF_SHARED, ret = request_irq(p->irq, omap_uart_interrupt, IRQF_SHARED,
"serial idle", (void *)uart); "serial idle", (void *)uart);
WARN_ON(ret); WARN_ON(ret);
} }
static ssize_t sleep_timeout_show(struct kobject *kobj, void omap_uart_enable_irqs(int enable)
struct kobj_attribute *attr,
char *buf)
{ {
return sprintf(buf, "%u\n", sleep_timeout / HZ); int ret;
struct omap_uart_state *uart;
list_for_each_entry(uart, &uart_list, node) {
if (enable)
ret = request_irq(uart->p->irq, omap_uart_interrupt,
IRQF_SHARED, "serial idle", (void *)uart);
else
free_irq(uart->p->irq, (void *)uart);
}
} }
static ssize_t sleep_timeout_store(struct kobject *kobj, static ssize_t sleep_timeout_show(struct device *dev,
struct kobj_attribute *attr, struct device_attribute *attr,
char *buf)
{
struct platform_device *pdev = container_of(dev,
struct platform_device, dev);
struct omap_uart_state *uart = container_of(pdev,
struct omap_uart_state, pdev);
return sprintf(buf, "%u\n", uart->timeout / HZ);
}
static ssize_t sleep_timeout_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t n) const char *buf, size_t n)
{ {
struct omap_uart_state *uart; struct platform_device *pdev = container_of(dev,
struct platform_device, dev);
struct omap_uart_state *uart = container_of(pdev,
struct omap_uart_state, pdev);
unsigned int value; unsigned int value;
if (sscanf(buf, "%u", &value) != 1) { if (sscanf(buf, "%u", &value) != 1) {
printk(KERN_ERR "sleep_timeout_store: Invalid value\n"); printk(KERN_ERR "sleep_timeout_store: Invalid value\n");
return -EINVAL; return -EINVAL;
} }
sleep_timeout = value * HZ;
list_for_each_entry(uart, &uart_list, node) { uart->timeout = value * HZ;
uart->timeout = sleep_timeout; if (uart->timeout)
if (uart->timeout) mod_timer(&uart->timer, jiffies + uart->timeout);
mod_timer(&uart->timer, jiffies + uart->timeout); else
else /* A zero value means disable timeout feature */
/* A zero value means disable timeout feature */ omap_uart_block_sleep(uart);
omap_uart_block_sleep(uart);
}
return n; return n;
} }
static struct kobj_attribute sleep_timeout_attr = DEVICE_ATTR(sleep_timeout, 0644, sleep_timeout_show, sleep_timeout_store);
__ATTR(sleep_timeout, 0644, sleep_timeout_show, sleep_timeout_store); #define DEV_CREATE_FILE(dev, attr) WARN_ON(device_create_file(dev, attr))
#else #else
static inline void omap_uart_idle_init(struct omap_uart_state *uart) {} static inline void omap_uart_idle_init(struct omap_uart_state *uart) {}
#define DEV_CREATE_FILE(dev, attr)
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
static struct platform_device serial_device = { static struct omap_uart_state omap_uart[OMAP_MAX_NR_PORTS] = {
.name = "serial8250", {
.id = PLAT8250_DEV_PLATFORM, .pdev = {
.dev = { .name = "serial8250",
.platform_data = serial_platform_data, .id = PLAT8250_DEV_PLATFORM,
.dev = {
.platform_data = serial_platform_data0,
},
},
}, {
.pdev = {
.name = "serial8250",
.id = PLAT8250_DEV_PLATFORM1,
.dev = {
.platform_data = serial_platform_data1,
},
},
}, {
.pdev = {
.name = "serial8250",
.id = PLAT8250_DEV_PLATFORM2,
.dev = {
.platform_data = serial_platform_data2,
},
},
}, },
}; };
void __init omap_serial_init(void) void __init omap_serial_init(void)
{ {
int i, err; int i;
const struct omap_uart_config *info; const struct omap_uart_config *info;
char name[16]; char name[16];
@ -496,14 +568,12 @@ void __init omap_serial_init(void)
if (info == NULL) if (info == NULL)
return; return;
if (cpu_is_omap44xx()) {
for (i = 0; i < OMAP_MAX_NR_PORTS; i++)
serial_platform_data[i].irq += 32;
}
for (i = 0; i < OMAP_MAX_NR_PORTS; i++) { for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
struct plat_serial8250_port *p = serial_platform_data + i;
struct omap_uart_state *uart = &omap_uart[i]; struct omap_uart_state *uart = &omap_uart[i];
struct platform_device *pdev = &uart->pdev;
struct device *dev = &pdev->dev;
struct plat_serial8250_port *p = dev->platform_data;
if (!(info->enabled_uarts & (1 << i))) { if (!(info->enabled_uarts & (1 << i))) {
p->membase = NULL; p->membase = NULL;
@ -531,20 +601,21 @@ void __init omap_serial_init(void)
uart->num = i; uart->num = i;
p->private_data = uart; p->private_data = uart;
uart->p = p; uart->p = p;
list_add(&uart->node, &uart_list); list_add_tail(&uart->node, &uart_list);
if (cpu_is_omap44xx())
p->irq += 32;
omap_uart_enable_clocks(uart); omap_uart_enable_clocks(uart);
omap_uart_reset(uart); omap_uart_reset(uart);
omap_uart_idle_init(uart); omap_uart_idle_init(uart);
if (WARN_ON(platform_device_register(pdev)))
continue;
if ((cpu_is_omap34xx() && uart->padconf) ||
(uart->wk_en && uart->wk_mask)) {
device_init_wakeup(dev, true);
DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout);
}
} }
err = platform_device_register(&serial_device);
#ifdef CONFIG_PM
if (!err)
err = sysfs_create_file(&serial_device.dev.kobj,
&sleep_timeout_attr.attr);
#endif
} }

View File

@ -78,10 +78,10 @@ static int omap_target(struct cpufreq_policy *policy,
/* Ensure desired rate is within allowed range. Some govenors /* Ensure desired rate is within allowed range. Some govenors
* (ondemand) will just pass target_freq=0 to get the minimum. */ * (ondemand) will just pass target_freq=0 to get the minimum. */
if (target_freq < policy->cpuinfo.min_freq) if (target_freq < policy->min)
target_freq = policy->cpuinfo.min_freq; target_freq = policy->min;
if (target_freq > policy->cpuinfo.max_freq) if (target_freq > policy->max)
target_freq = policy->cpuinfo.max_freq; target_freq = policy->max;
freqs.old = omap_getspeed(0); freqs.old = omap_getspeed(0);
freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000; freqs.new = clk_round_rate(mpu_clk, target_freq * 1000) / 1000;

View File

@ -1234,6 +1234,7 @@ static void gpio_mask_irq(unsigned int irq)
struct gpio_bank *bank = get_irq_chip_data(irq); struct gpio_bank *bank = get_irq_chip_data(irq);
_set_gpio_irqenable(bank, gpio, 0); _set_gpio_irqenable(bank, gpio, 0);
_set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE);
} }
static void gpio_unmask_irq(unsigned int irq) static void gpio_unmask_irq(unsigned int irq)
@ -1241,6 +1242,11 @@ static void gpio_unmask_irq(unsigned int irq)
unsigned int gpio = irq - IH_GPIO_BASE; unsigned int gpio = irq - IH_GPIO_BASE;
struct gpio_bank *bank = get_irq_chip_data(irq); struct gpio_bank *bank = get_irq_chip_data(irq);
unsigned int irq_mask = 1 << get_gpio_index(gpio); unsigned int irq_mask = 1 << get_gpio_index(gpio);
struct irq_desc *desc = irq_to_desc(irq);
u32 trigger = desc->status & IRQ_TYPE_SENSE_MASK;
if (trigger)
_set_gpio_triggering(bank, get_gpio_index(gpio), trigger);
/* For level-triggered GPIOs, the clearing must be done after /* For level-triggered GPIOs, the clearing must be done after
* the HW source is cleared, thus after the handler has run */ * the HW source is cleared, thus after the handler has run */

View File

@ -59,6 +59,7 @@ extern void omap_uart_check_wakeup(void);
extern void omap_uart_prepare_suspend(void); extern void omap_uart_prepare_suspend(void);
extern void omap_uart_prepare_idle(int num); extern void omap_uart_prepare_idle(int num);
extern void omap_uart_resume_idle(int num); extern void omap_uart_resume_idle(int num);
extern void omap_uart_enable_irqs(int enable);
#endif #endif
#endif #endif