From patchwork Fri Feb 15 15:40:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 2148621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 0D251DF24C for ; Fri, 15 Feb 2013 15:43:24 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U6NOW-00023O-59; Fri, 15 Feb 2013 15:40:12 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U6NOS-00022q-UB for linux-arm-kernel@lists.infradead.org; Fri, 15 Feb 2013 15:40:10 +0000 Received: by mail-pa0-f48.google.com with SMTP id hz10so1808716pad.21 for ; Fri, 15 Feb 2013 07:40:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-gm-message-state; bh=2hL9uLR+kPWpC2xoW6D5B5kU/MKuST5PxB8T7nT6JNI=; b=gsslIvSHexuEMsU40cPKJcEhFuKa/Ksc+zxZSzmuDTQYT9ZwdyzbqDPoDBXRNgSOv2 vxjY1NVPko944j9SisAsDT8aZ7J2+IaCOSqpvKxLGIMRC+qiSS96CnS99qvm/1Ft147Y /0h1L7Q6L2/mMjTIuvLyLdkoP8L5hPDggUOUDJDPEvZShYSOR8uYzc3rEhIX9y7GyrKp +FKLRGciOdry+HuuIFBcnWn7Mgn9cmrwr3nYGEzKlfl86kOu7s0TjfpoLeFXrH+saYB8 MxrXFiHHlNVKupTcmFN2aTaPAeNRRt36WBn/tZG6Da3YtlhZ0kQyaJsERwVGZCZqrpB7 CiDQ== X-Received: by 10.68.191.106 with SMTP id gx10mr6831623pbc.151.1360942806450; Fri, 15 Feb 2013 07:40:06 -0800 (PST) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id az3sm5052572pbd.23.2013.02.15.07.40.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 15 Feb 2013 07:40:05 -0800 (PST) From: Kevin Hilman To: Felipe Balbi Subject: Re: [RFC/NOT FOR MERGING 2/3] serial: omap: remove hwmod dependency References: <1360840554-26901-1-git-send-email-balbi@ti.com> <1360840554-26901-2-git-send-email-balbi@ti.com> Date: Fri, 15 Feb 2013 07:40:04 -0800 In-Reply-To: <1360840554-26901-2-git-send-email-balbi@ti.com> (Felipe Balbi's message of "Thu, 14 Feb 2013 13:15:53 +0200") Message-ID: <87obfl60x7.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnQO8ecm3xZFrE8YNqfnUDq+L+K24Ndwvf2kJcQIPYb5DztDFR6xLHlzeF2Alda/LGEMefu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130215_104009_121581_0E15049E X-CRM114-Status: GOOD ( 25.82 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.48 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Tony Lindgren , Linux OMAP Mailing List , Linux ARM Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Felipe Balbi writes: > Currently the omap-serial driver will not > work properly if booted via DT with CPUIDLE > enabled because it depends on function pointers > provided by hwmod to change its own SYSCONFIG > register. > > Remove that relyance on hwmod by moving SYSCONFIG > handling to driver itself. Note that this also > fixes a possible corner case bug where we could > be putting UART in Force Idle mode if we called > omap_serial_enable_wakeup(up, false) after setting > NOIDLE to the idle mode. This is because hwmod > has no protection against that situation. > > NYET-Signed-off-by: Felipe Balbi Here's another approach to getting rid of the sysconfig twiddling in the driver. I wrote this some time ago at my former company ;) but don't think I ever got around to posting it. It doesn't solve the whole problem (e.g. doesn't address the context_loss or enable_wakeup func pointers), but at least gets rid of the need for any SYSCONFIG access in the driver for the idle modes. Needs more thorough testing. Kevin From 3d3956472d2375b5ed939d1d0165e439aa47262f Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Wed, 26 Sep 2012 18:36:43 -0700 Subject: [PATCH] ARM: OMAP2+: serial/hwmod: use SW supported slave idle for all UARTs Due to various errata, we have several hacks involving modifying the slave idle mode of the UARTs at runtime. Since the UART driver has been using the autosuspend feature of runtime PM, each UART is kept in NO_IDLE during activity, and SMART_IDLE during activity. The omap_hwmod layer has the per-device HWMOD_SWSUP_SIDLE flag which will have the exact same behavior, with the benefit of simplifying the device and driver layers. Switch to using hwmod to automatically manage the slave idle mode. This also enables the removal of a couple pdata function pointers from the driver, which facilitates the conversion to device tree. Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c | 3 ++ arch/arm/mach-omap2/omap_hwmod_33xx_data.c | 4 +++ arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 4 +++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 4 +++ arch/arm/mach-omap2/serial.c | 35 ---------------------- arch/arm/plat-omap/include/plat/omap-serial.h | 2 -- drivers/tty/serial/omap-serial.c | 23 -------------- 7 files changed, 15 insertions(+), 60 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c index bd9220e..0d3c1a6 100644 --- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c @@ -509,6 +509,7 @@ struct omap_hwmod omap2xxx_uart1_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; /* UART2 */ @@ -528,6 +529,7 @@ struct omap_hwmod omap2xxx_uart2_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; /* UART3 */ @@ -547,6 +549,7 @@ struct omap_hwmod omap2xxx_uart3_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; /* dss */ diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c index 59d5c1c..1a41f93 100644 --- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c @@ -1903,6 +1903,7 @@ static struct omap_hwmod am33xx_uart1_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; static struct omap_hwmod_irq_info am33xx_uart2_irqs[] = { @@ -1923,6 +1924,7 @@ static struct omap_hwmod am33xx_uart2_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; /* uart3 */ @@ -1950,6 +1952,7 @@ static struct omap_hwmod am33xx_uart3_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; static struct omap_hwmod_irq_info am33xx_uart4_irqs[] = { @@ -1970,6 +1973,7 @@ static struct omap_hwmod am33xx_uart4_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; static struct omap_hwmod_irq_info am33xx_uart5_irqs[] = { diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index f67b7ee..99ada6a 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c @@ -497,6 +497,7 @@ static struct omap_hwmod omap3xxx_uart1_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; /* UART2 */ @@ -515,6 +516,7 @@ static struct omap_hwmod omap3xxx_uart2_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; /* UART3 */ @@ -533,6 +535,7 @@ static struct omap_hwmod omap3xxx_uart3_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; /* UART4 */ @@ -562,6 +565,7 @@ static struct omap_hwmod omap36xx_uart4_hwmod = { }, }, .class = &omap2_uart_class, + .flags = HWMOD_SWSUP_SIDLE, }; static struct omap_hwmod_irq_info am35xx_uart4_mpu_irqs[] = { diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c index 652d028..5373e58 100644 --- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c @@ -3397,6 +3397,7 @@ static struct omap_hwmod omap44xx_uart1_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; /* uart2 */ @@ -3425,6 +3426,7 @@ static struct omap_hwmod omap44xx_uart2_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; /* uart3 */ @@ -3454,6 +3456,7 @@ static struct omap_hwmod omap44xx_uart3_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; /* uart4 */ @@ -3482,6 +3485,7 @@ static struct omap_hwmod omap44xx_uart4_hwmod = { .modulemode = MODULEMODE_SWCTRL, }, }, + .flags = HWMOD_SWSUP_SIDLE, }; /* diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index a507cd6..e9d69a9 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -94,39 +94,6 @@ static void omap_uart_enable_wakeup(struct device *dev, bool enable) else omap_hwmod_disable_wakeup(od->hwmods[0]); } - -/* - * Errata i291: [UART]:Cannot Acknowledge Idle Requests - * in Smartidle Mode When Configured for DMA Operations. - * WA: configure uart in force idle mode. - */ -static void omap_uart_set_noidle(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct omap_device *od = to_omap_device(pdev); - - omap_hwmod_set_slave_idlemode(od->hwmods[0], HWMOD_IDLEMODE_NO); -} - -static void omap_uart_set_smartidle(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct omap_device *od = to_omap_device(pdev); - u8 idlemode; - - if (od->hwmods[0]->class->sysc->idlemodes & SIDLE_SMART_WKUP) - idlemode = HWMOD_IDLEMODE_SMART_WKUP; - else - idlemode = HWMOD_IDLEMODE_SMART; - - omap_hwmod_set_slave_idlemode(od->hwmods[0], idlemode); -} - -#else -static void omap_uart_enable_wakeup(struct device *dev, bool enable) -{} -static void omap_uart_set_noidle(struct device *dev) {} -static void omap_uart_set_smartidle(struct device *dev) {} #endif /* CONFIG_PM */ #ifdef CONFIG_OMAP_MUX @@ -299,8 +266,6 @@ void __init omap_serial_init_port(struct omap_board_data *bdata, omap_up.uartclk = OMAP24XX_BASE_BAUD * 16; omap_up.flags = UPF_BOOT_AUTOCONF; omap_up.get_context_loss_count = omap_pm_get_dev_context_loss_count; - omap_up.set_forceidle = omap_uart_set_smartidle; - omap_up.set_noidle = omap_uart_set_noidle; omap_up.enable_wakeup = omap_uart_enable_wakeup; omap_up.dma_rx_buf_size = info->dma_rx_buf_size; omap_up.dma_rx_timeout = info->dma_rx_timeout; diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h b/arch/arm/plat-omap/include/plat/omap-serial.h index 1957a85..b9a712c 100644 --- a/arch/arm/plat-omap/include/plat/omap-serial.h +++ b/arch/arm/plat-omap/include/plat/omap-serial.h @@ -72,8 +72,6 @@ struct omap_uart_port_info { int DTR_present; int (*get_context_loss_count)(struct device *); - void (*set_forceidle)(struct device *); - void (*set_noidle)(struct device *); void (*enable_wakeup)(struct device *, bool); }; diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 6d3d26a..8e4e39f 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -151,26 +151,6 @@ static int serial_omap_get_context_loss_count(struct uart_omap_port *up) return pdata->get_context_loss_count(up->dev); } -static void serial_omap_set_forceidle(struct uart_omap_port *up) -{ - struct omap_uart_port_info *pdata = up->dev->platform_data; - - if (!pdata || !pdata->set_forceidle) - return; - - pdata->set_forceidle(up->dev); -} - -static void serial_omap_set_noidle(struct uart_omap_port *up) -{ - struct omap_uart_port_info *pdata = up->dev->platform_data; - - if (!pdata || !pdata->set_noidle) - return; - - pdata->set_noidle(up->dev); -} - static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) { struct omap_uart_port_info *pdata = up->dev->platform_data; @@ -229,8 +209,6 @@ static void serial_omap_stop_tx(struct uart_port *port) serial_out(up, UART_IER, up->ier); } - serial_omap_set_forceidle(up); - pm_runtime_mark_last_busy(up->dev); pm_runtime_put_autosuspend(up->dev); } @@ -298,7 +276,6 @@ static void serial_omap_start_tx(struct uart_port *port) pm_runtime_get_sync(up->dev); serial_omap_enable_ier_thri(up); - serial_omap_set_noidle(up); pm_runtime_mark_last_busy(up->dev); pm_runtime_put_autosuspend(up->dev); }