From patchwork Thu Apr 23 08:45:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 6260891 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A5659F313 for ; Thu, 23 Apr 2015 08:49:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E5EF20394 for ; Thu, 23 Apr 2015 08:49:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8FE2920380 for ; Thu, 23 Apr 2015 08:49:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YlCmt-0004YV-F9; Thu, 23 Apr 2015 08:47:11 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YlCm6-00045s-RK for linux-arm-kernel@lists.infradead.org; Thu, 23 Apr 2015 08:46:24 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 82FB914070A; Thu, 23 Apr 2015 08:46:03 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 6D50C14070D; Thu, 23 Apr 2015 08:46:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from blr-ubuntu-34.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: rnayak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id F2AAC140701; Thu, 23 Apr 2015 08:46:00 +0000 (UTC) From: Rajendra Nayak To: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RFC/RFT 3/6] serial: msm: convert driver to use runtime PM apis Date: Thu, 23 Apr 2015 14:15:41 +0530 Message-Id: <1429778744-13352-4-git-send-email-rnayak@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1429778744-13352-1-git-send-email-rnayak@codeaurora.org> References: <1429778744-13352-1-git-send-email-rnayak@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150423_014623_037995_FF226AAB X-CRM114-Status: GOOD ( 18.28 ) X-Spam-Score: -0.0 (/) Cc: Rajendra Nayak , linux-serial@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With platform support now in place to manage clocks from within runtime PM callbacks, get rid of all clock handling from the driver and convert the driver to use runtime PM apis. Signed-off-by: Rajendra Nayak Cc: --- drivers/tty/serial/msm_serial.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index b73889c..eb66502 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -50,11 +51,11 @@ struct msm_port { struct uart_port uart; char name[16]; struct clk *clk; - struct clk *pclk; unsigned int imr; int is_uartdm; unsigned int old_snap_state; bool break_detected; + struct device *dev; }; static inline void wait_for_xmitr(struct uart_port *port) @@ -464,12 +465,11 @@ static int msm_set_baud_rate(struct uart_port *port, unsigned int baud) return baud; } -static void msm_init_clock(struct uart_port *port) +static void msm_init(struct uart_port *port) { struct msm_port *msm_port = UART_TO_MSM(port); - clk_prepare_enable(msm_port->clk); - clk_prepare_enable(msm_port->pclk); + pm_runtime_get_sync(msm_port->dev); msm_serial_set_mnd_regs(port); } @@ -487,7 +487,7 @@ static int msm_startup(struct uart_port *port) if (unlikely(ret)) return ret; - msm_init_clock(port); + msm_init(port); if (likely(port->fifosize > 12)) rfr_level = port->fifosize - 12; @@ -511,7 +511,7 @@ static void msm_shutdown(struct uart_port *port) msm_port->imr = 0; msm_write(port, 0, UART_IMR); /* disable interrupts */ - clk_disable_unprepare(msm_port->clk); + pm_runtime_put_sync(msm_port->dev); free_irq(port->irq, port); } @@ -669,12 +669,10 @@ static void msm_power(struct uart_port *port, unsigned int state, switch (state) { case 0: - clk_prepare_enable(msm_port->clk); - clk_prepare_enable(msm_port->pclk); + pm_runtime_get_sync(msm_port->dev); break; case 3: - clk_disable_unprepare(msm_port->clk); - clk_disable_unprepare(msm_port->pclk); + pm_runtime_put_sync(msm_port->dev); break; default: pr_err("msm_serial: Unknown PM state %d\n", state); @@ -933,7 +931,7 @@ static int __init msm_console_setup(struct console *co, char *options) if (unlikely(!port->membase)) return -ENXIO; - msm_init_clock(port); + msm_init(port); if (options) uart_parse_options(options, &baud, &parity, &bits, &flow); @@ -1057,13 +1055,10 @@ static int msm_serial_probe(struct platform_device *pdev) if (IS_ERR(msm_port->clk)) return PTR_ERR(msm_port->clk); - if (msm_port->is_uartdm) { - msm_port->pclk = devm_clk_get(&pdev->dev, "iface"); - if (IS_ERR(msm_port->pclk)) - return PTR_ERR(msm_port->pclk); - + if (msm_port->is_uartdm) clk_set_rate(msm_port->clk, 1843200); - } + + msm_port->dev = &pdev->dev; port->uartclk = clk_get_rate(msm_port->clk); dev_info(&pdev->dev, "uartclk = %d\n", port->uartclk); @@ -1080,13 +1075,17 @@ static int msm_serial_probe(struct platform_device *pdev) platform_set_drvdata(pdev, port); + pm_runtime_enable(&pdev->dev); + return uart_add_one_port(&msm_uart_driver, port); } static int msm_serial_remove(struct platform_device *pdev) { struct uart_port *port = platform_get_drvdata(pdev); + struct msm_port *msm_port = UART_TO_MSM(port); + pm_runtime_disable(msm_port->dev); uart_remove_one_port(&msm_uart_driver, port); return 0;