atom feed26 messages in org.kernel.vger.linux-omap[PATCH 07/13] OMAP: UART: Add sysfs i...
FromSent OnAttachments
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kevin HilmanMay 20, 2009 4:19 pm 
Kim KyuwonMay 21, 2009 4:37 pm 
Kevin HilmanMay 22, 2009 7:54 am 
Kim KyuwonMay 22, 2009 8:50 am 
Kevin HilmanMay 22, 2009 11:15 am 
Kim KyuwonMay 22, 2009 3:59 pm 
Russell King - ARM LinuxMay 22, 2009 4:21 pm 
Kim KyuwonMay 22, 2009 5:47 pm 
Kim KyuwonMay 24, 2009 10:33 pm 
Tony LindgrenMay 26, 2009 4:12 pm 
Russell King - ARM LinuxMay 28, 2009 8:47 am 
Kevin HilmanMay 28, 2009 9:50 am 
Kevin HilmanMay 28, 2009 11:22 am 
Subject:[PATCH 07/13] OMAP: UART: Add sysfs interface for adjusting UART sleep timeout
From:Kevin Hilman (khil@deeprootsystems.com)
Date:May 20, 2009 4:19:07 pm
List:org.kernel.vger.linux-omap

From: Jouni Hogander <joun@nokia.com>

This patch makes it possible to change uart sleep timeout. New sysfs entry is added (/sys/devices/platform/serial8250.<uart>/sleep_timeout) Writing zero will disable the timeout feature and prevent UART clocks from being disabled.

Also default timeout is increased to 5 second to make serial console more usable.

Original patch was written by Tero Kristo.

Cc: Tero Kristo <Tero@nokia.com> Signed-off-by: Jouni Hogander <joun@nokia.com> Signed-off-by: Kevin Hilman <khil@deeprootsystems.com>

--- arch/arm/mach-omap2/serial.c | 55 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index 50bff3d..854ac94 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; @@ -233,7 +233,10 @@ static void omap_uart_block_sleep(struct omap_uart_state
*uart)

omap_uart_smart_idle_enable(uart, 0); uart->can_sleep = 0; - mod_timer(&uart->timer, jiffies + uart->timeout); + if (uart->timeout) + mod_timer(&uart->timer, jiffies + uart->timeout); + else + del_timer(&uart->timer); }

static void omap_uart_allow_sleep(struct omap_uart_state *uart) @@ -338,6 +341,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; @@ -345,7 +350,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); @@ -425,6 +430,39 @@ 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; + if (uart->timeout) + mod_timer(&uart->timer, jiffies + uart->timeout); + else + /* A zero value means disable timeout feature */ + omap_uart_block_sleep(uart); + } + 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 */ @@ -494,6 +532,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);