X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=arch%2Farm%2Fmach-omap2%2Fserial.c;h=7f9a50da55f5b4cc0d13920a2aa6752574e4532b;hb=22c1c7879d60d1419672ff9f6d162e89fe3cc1a1;hp=b834b7ebde563f697d18ed2225e390982cb5adfa;hpb=14ea37b2911b386c7686a8bad4b77e868c77b875;p=linux-2.6-omap-h63xx.git diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index b834b7ebde5..7f9a50da55f 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -30,7 +30,7 @@ #include "pm.h" #include "prm-regbits-34xx.h" -#define DEFAULT_TIMEOUT (2 * HZ) +#define DEFAULT_TIMEOUT (5 * HZ) struct omap_uart_state { int num; @@ -340,6 +340,8 @@ static irqreturn_t omap_uart_interrupt(int irq, void *dev_id) return IRQ_NONE; } +static u32 sleep_timeout = DEFAULT_TIMEOUT; + static void omap_uart_idle_init(struct omap_uart_state *uart) { u32 v; @@ -347,7 +349,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart) int ret; uart->can_sleep = 0; - uart->timeout = DEFAULT_TIMEOUT; + uart->timeout = sleep_timeout; setup_timer(&uart->timer, omap_uart_idle_timer, (unsigned long) uart); mod_timer(&uart->timer, jiffies + uart->timeout); @@ -427,6 +429,33 @@ static void omap_uart_idle_init(struct omap_uart_state *uart) WARN_ON(ret); } +static ssize_t sleep_timeout_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + return sprintf(buf, "%u\n", sleep_timeout / HZ); +} + +static ssize_t sleep_timeout_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t n) +{ + struct omap_uart_state *uart; + unsigned int value; + + if (sscanf(buf, "%u", &value) != 1) { + printk(KERN_ERR "sleep_timeout_store: Invalid value\n"); + return -EINVAL; + } + sleep_timeout = value * HZ; + list_for_each_entry(uart, &uart_list, node) + uart->timeout = sleep_timeout; + return n; +} + +static struct kobj_attribute sleep_timeout_attr = + __ATTR(sleep_timeout, 0644, sleep_timeout_show, sleep_timeout_store); + #else static inline void omap_uart_idle_init(struct omap_uart_state *uart) {} #endif /* CONFIG_PM */ @@ -496,6 +525,15 @@ static struct platform_device serial_device = { static int __init omap_init(void) { - return platform_device_register(&serial_device); + int ret; + + ret = platform_device_register(&serial_device); + +#ifdef CONFIG_PM + if (!ret) + ret = sysfs_create_file(&serial_device.dev.kobj, + &sleep_timeout_attr.attr); +#endif + return ret; } arch_initcall(omap_init);