From patchwork Thu Dec 30 10:21:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12701370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77C05C433EF for ; Thu, 30 Dec 2021 10:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8NdyVyAHe9wp7cWUFQh9D6dR7q+I/ulCRMmbWx11B90=; b=Fxst4BU8I6yL9Z jcyBRPl0stnDP9is1T9oQaVkjjKeEs8jkkearyo/edd4iKzmjsFuzS+3HkyF6SJQrwBFgSpaQ3490 UjInD7OsTfTKMvwLgD2Npb18LpvsR4EtM6MjDKeLEdjvXPoteMEl2kC+OGORKl1ogSHWm0JmiPPPW UdI7rXqweOaHoahK8abscv55n4PZRjFre3tPqFe4Ai+QnB7/IiDaDh+ZfCEsglQWJgRrFzNPyXefB C7Zmj7B3aVTbcZnQonZHpdlk3T5Of6uLnCKC4xFejIPNOoW1K+413WAR+grnh5EyDMS8TQ5SkNr6X Qo0JZtxn0rFJz3XKQEHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZR-004Bfh-HA; Thu, 30 Dec 2021 10:22:05 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZ5-004BXP-A6; Thu, 30 Dec 2021 10:21:44 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Thu, 30 Dec 2021 18:21:40 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Vyacheslav , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V3 1/6] tty: serial: meson: Drop the legacy compatible strings and clock code Date: Thu, 30 Dec 2021 18:21:05 +0800 Message-ID: <20211230102110.3861-2-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211230102110.3861-1-yu.tu@amlogic.com> References: <20211230102110.3861-1-yu.tu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211230_022143_361373_012B460D X-CRM114-Status: GOOD ( 12.49 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org All mainline .dts files have been using the stable UART since Linux 4.16. Drop the legacy compatible strings and related clock code. Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 34 ++------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index d2c08b760f83..c9a37602ffd0 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -625,10 +625,7 @@ meson_serial_early_console_setup(struct earlycon_device *device, const char *opt device->con->write = meson_serial_early_console_write; return 0; } -/* Legacy bindings, should be removed when no more used */ -OF_EARLYCON_DECLARE(meson, "amlogic,meson-uart", - meson_serial_early_console_setup); -/* Stable bindings */ + OF_EARLYCON_DECLARE(meson, "amlogic,meson-ao-uart", meson_serial_early_console_setup); @@ -668,25 +665,6 @@ static inline struct clk *meson_uart_probe_clock(struct device *dev, return clk; } -/* - * This function gets clocks in the legacy non-stable DT bindings. - * This code will be remove once all the platforms switch to the - * new DT bindings. - */ -static int meson_uart_probe_clocks_legacy(struct platform_device *pdev, - struct uart_port *port) -{ - struct clk *clk = NULL; - - clk = meson_uart_probe_clock(&pdev->dev, NULL); - if (IS_ERR(clk)) - return PTR_ERR(clk); - - port->uartclk = clk_get_rate(clk); - - return 0; -} - static int meson_uart_probe_clocks(struct platform_device *pdev, struct uart_port *port) { @@ -750,12 +728,7 @@ static int meson_uart_probe(struct platform_device *pdev) if (!port) return -ENOMEM; - /* Use legacy way until all platforms switch to new bindings */ - if (of_device_is_compatible(pdev->dev.of_node, "amlogic,meson-uart")) - ret = meson_uart_probe_clocks_legacy(pdev, port); - else - ret = meson_uart_probe_clocks(pdev, port); - + ret = meson_uart_probe_clocks(pdev, port); if (ret) return ret; @@ -800,9 +773,6 @@ static int meson_uart_remove(struct platform_device *pdev) } static const struct of_device_id meson_uart_dt_match[] = { - /* Legacy bindings, should be removed when no more used */ - { .compatible = "amlogic,meson-uart" }, - /* Stable bindings */ { .compatible = "amlogic,meson6-uart" }, { .compatible = "amlogic,meson8-uart" }, { .compatible = "amlogic,meson8b-uart" }, From patchwork Thu Dec 30 10:21:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12701371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CBD5C433F5 for ; Thu, 30 Dec 2021 10:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jVz7pfOwzFLIeOm5RjW8n8BsFXF+IO9/7JqxCCR+dxc=; b=ymozOLiu4Kn+Y/ HxG420OI+C5Qj265lDKMFNFPpWITUY1onE+MAjUKlkjoGRwbubUX5yrYQP6Ih+Ou3niGckvpJ2WrJ Zk8V+76SzjWe40XPVeAGUrTmuUufFAIvoYziutxX0PudvPDcZvGFAoldcVIRUJGiwLO46tcyf/+Jt lseKRcQrhB2SnqHtH/FYVRbC3MkvuAskO6GwDSLeHzTD5AP18kV6fQhuCMojlY2Tl8syGsJ2+3noW VxTcBapX3UmRmvdiS/V2asWmEdINc/kZxSt1ZC40as1PlGrB1TdFtWOdmC+aWmv0Mut8Utts8FYqz vVq0rJKM7Jln7qULLW+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZf-004BlK-FG; Thu, 30 Dec 2021 10:22:19 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZ7-004BXP-20; Thu, 30 Dec 2021 10:21:46 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Thu, 30 Dec 2021 18:21:42 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Vyacheslav , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V3 2/6] tty: serial: meson: Request the register region in meson_uart_probe() Date: Thu, 30 Dec 2021 18:21:06 +0800 Message-ID: <20211230102110.3861-3-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211230102110.3861-1-yu.tu@amlogic.com> References: <20211230102110.3861-1-yu.tu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211230_022145_114259_83F855C8 X-CRM114-Status: GOOD ( 10.19 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org This simplifies resetting the UART controller during probe and will make it easier to integrate the common clock code which will require the registers at probe time as well. Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index c9a37602ffd0..99efe62a1507 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -397,24 +397,11 @@ static int meson_uart_verify_port(struct uart_port *port, static void meson_uart_release_port(struct uart_port *port) { - devm_iounmap(port->dev, port->membase); - port->membase = NULL; - devm_release_mem_region(port->dev, port->mapbase, port->mapsize); + /* nothing to do */ } static int meson_uart_request_port(struct uart_port *port) { - if (!devm_request_mem_region(port->dev, port->mapbase, port->mapsize, - dev_name(port->dev))) { - dev_err(port->dev, "Memory region busy\n"); - return -EBUSY; - } - - port->membase = devm_ioremap(port->dev, port->mapbase, - port->mapsize); - if (!port->membase) - return -ENOMEM; - return 0; } @@ -728,6 +715,10 @@ static int meson_uart_probe(struct platform_device *pdev) if (!port) return -ENOMEM; + port->membase = devm_ioremap_resource(&pdev->dev, res_mem); + if (IS_ERR(port->membase)) + return PTR_ERR(port->membase); + ret = meson_uart_probe_clocks(pdev, port); if (ret) return ret; @@ -749,10 +740,7 @@ static int meson_uart_probe(struct platform_device *pdev) platform_set_drvdata(pdev, port); /* reset port before registering (and possibly registering console) */ - if (meson_uart_request_port(port) >= 0) { - meson_uart_reset(port); - meson_uart_release_port(port); - } + meson_uart_reset(port); ret = uart_add_one_port(&meson_uart_driver, port); if (ret) From patchwork Thu Dec 30 10:21:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12701372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D8E3C433EF for ; Thu, 30 Dec 2021 10:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IsiX8UxvmyUdMycsO+LTd6afAhZiIvlsM5Xx2SL6gFI=; b=CD2NyHwZOfgvmd RA2rl8dEEJGXa3+F/ac1KbVoFTP01Z3PZGD+kK6XCqd5nyhgYQF3pb4IBP3nPfpM1I9YqUK5viQX7 0Nc06FgTNGiKZAdDyNUFSHGbkglp7wPRSzOb9l0LrISYFk61Ac9QiqJgFED+BT+bYiPpB6+0Iw7iJ dkeEt6jjTCvSJz61JAGvS3/3Q9O9z/3i1Ls2nqHwcfG3XFo6Gt7Ti0aWCSl0xtlBg55LRenIlnoWz oBk3FLipsVls4R0RhhclcF7mCfYCjXYq5trp3a0vfLyho14p0nFsxBrfw//ri5Xvehg5UOLjYtEMv igKUjZ/O1qN8c7ycoRjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZs-004Bs9-0p; Thu, 30 Dec 2021 10:22:32 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZ8-004BXP-Rt; Thu, 30 Dec 2021 10:21:48 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Thu, 30 Dec 2021 18:21:44 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Vyacheslav , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V3 3/6] dt-bindings: serial: meson: Support S4 SoC uart. Also Drop compatible = amlogic, meson-gx-uart. Date: Thu, 30 Dec 2021 18:21:07 +0800 Message-ID: <20211230102110.3861-4-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211230102110.3861-1-yu.tu@amlogic.com> References: <20211230102110.3861-1-yu.tu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211230_022146_914087_4A1D93D4 X-CRM114-Status: UNSURE ( 6.56 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Deprecated, don't use anymore because compatible = amlogic,meson-gx-uart don't differentiate between GXBB and GXL which have different revisions of the UART IP. So it's split into GXBB and GXL. Signed-off-by: Yu Tu --- .../devicetree/bindings/serial/amlogic,meson-uart.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml index 75ebc9952a99..b03040a83a9f 100644 --- a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml +++ b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml @@ -28,14 +28,20 @@ properties: - amlogic,meson6-uart - amlogic,meson8-uart - amlogic,meson8b-uart - - amlogic,meson-gx-uart + - amlogic,meson-gxbb-uart + - amlogic,meson-gxl-uart + - amlogic,meson-g12a-uart + - amlogic,meson-s4-uart - const: amlogic,meson-ao-uart - description: Everything-Else power domain UART controller enum: - amlogic,meson6-uart - amlogic,meson8-uart - amlogic,meson8b-uart - - amlogic,meson-gx-uart + - amlogic,meson-gxbb-uart + - amlogic,meson-gxl-uart + - amlogic,meson-g12a-uart + - amlogic,meson-s4-uart reg: maxItems: 1 From patchwork Thu Dec 30 10:21:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12701373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DEF9FC433F5 for ; Thu, 30 Dec 2021 10:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lo8B4wgJ4ZlFSfETmVHlrwJnN9sb0llELhdb40gocRE=; b=p8E+0p5fV9BKTU bKtIWILEQyedOkrmBsID+jcwUsXs1zywA0/McFSaLgl9dRt/ZVTc0yiV3cU+KP+KvYjgaBdE9s4Z3 Vhlkhgf5aGxxy1IPt4qexlovN8TnSAUPfKCEtQ/c5ufP+xK4TpEVNL5vDUrZ59SI1ver7BhQjff0Q MNv+9KcYMWqKcuhaZ9BNqxOcCjgbHSbk5iBVXtKxN/dmFYoBRIWDZH9SkyXygRgWbgVEwisMe5Rm/ q5jFlC6DP8AxipDwmwQMOMiMLzHfKlt6umQBrOinr1jcLu2BWsXuTDyEVawn906CY1xLPRfi6oQFb Y/o+6c/4/vwgVFAkAg9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sa8-004C2k-Mp; Thu, 30 Dec 2021 10:22:48 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sZA-004BXP-I2; Thu, 30 Dec 2021 10:21:50 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Thu, 30 Dec 2021 18:21:46 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Vyacheslav , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V3 4/6] tty: serial: meson: The UART baud rate calculation is described using the common clock code. Also added S4 chip uart Compatible. Date: Thu, 30 Dec 2021 18:21:08 +0800 Message-ID: <20211230102110.3861-5-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211230102110.3861-1-yu.tu@amlogic.com> References: <20211230102110.3861-1-yu.tu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211230_022148_635285_9340AB76 X-CRM114-Status: GOOD ( 22.43 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Using the common Clock code to describe the UART baud rate clock makes it easier for the UART driver to be compatible with the baud rate requirements of the UART IP on different meson chips Signed-off-by: Yu Tu --- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/meson_uart.c | 311 ++++++++++++++++++++++++++------ 2 files changed, 257 insertions(+), 55 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 780908d43557..32e238173036 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -198,6 +198,7 @@ config SERIAL_KGDB_NMI config SERIAL_MESON tristate "Meson serial port support" depends on ARCH_MESON + depends on COMMON_CLK select SERIAL_CORE help This enables the driver for the on-chip UARTs of the Amlogic diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 99efe62a1507..07eb1f40aaaa 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -65,9 +66,7 @@ #define AML_UART_RECV_IRQ(c) ((c) & 0xff) /* AML_UART_REG5 bits */ -#define AML_UART_BAUD_MASK 0x7fffff #define AML_UART_BAUD_USE BIT(23) -#define AML_UART_BAUD_XTAL BIT(24) #define AML_UART_PORT_NUM 12 #define AML_UART_PORT_OFFSET 6 @@ -76,6 +75,21 @@ #define AML_UART_POLL_USEC 5 #define AML_UART_TIMEOUT_USEC 10000 +struct meson_uart_data { + struct uart_port port; + struct clk *pclk; + struct clk *baud_clk; + struct clk_divider baud_div; + struct clk_mux use_xtal_mux; + struct clk_mux xtal_clk_sel_mux; + struct clk_mux xtal2_clk_sel_mux; + struct clk_fixed_factor xtal_div2; + struct clk_fixed_factor xtal_div3; + struct clk_fixed_factor clk81_div4; + bool no_clk81_input; + bool has_xtal_clk_sel; +}; + static struct uart_driver meson_uart_driver; static struct uart_port *meson_ports[AML_UART_PORT_NUM]; @@ -270,14 +284,11 @@ static void meson_uart_reset(struct uart_port *port) static int meson_uart_startup(struct uart_port *port) { u32 val; - int ret = 0; + int ret; - val = readl(port->membase + AML_UART_CONTROL); - val |= AML_UART_CLEAR_ERR; - writel(val, port->membase + AML_UART_CONTROL); - val &= ~AML_UART_CLEAR_ERR; - writel(val, port->membase + AML_UART_CONTROL); + meson_uart_reset(port); + val = readl(port->membase + AML_UART_CONTROL); val |= (AML_UART_RX_EN | AML_UART_TX_EN); writel(val, port->membase + AML_UART_CONTROL); @@ -295,19 +306,17 @@ static int meson_uart_startup(struct uart_port *port) static void meson_uart_change_speed(struct uart_port *port, unsigned long baud) { + struct meson_uart_data *private_data = port->private_data; u32 val; while (!meson_uart_tx_empty(port)) cpu_relax(); - if (port->uartclk == 24000000) { - val = ((port->uartclk / 3) / baud) - 1; - val |= AML_UART_BAUD_XTAL; - } else { - val = ((port->uartclk * 10 / (baud * 4) + 5) / 10) - 1; - } + val = readl(port->membase + AML_UART_REG5); val |= AML_UART_BAUD_USE; writel(val, port->membase + AML_UART_REG5); + + clk_set_rate(private_data->baud_clk, baud); } static void meson_uart_set_termios(struct uart_port *port, @@ -397,11 +406,27 @@ static int meson_uart_verify_port(struct uart_port *port, static void meson_uart_release_port(struct uart_port *port) { - /* nothing to do */ + struct meson_uart_data *private_data = port->private_data; + + clk_disable_unprepare(private_data->baud_clk); + clk_disable_unprepare(private_data->pclk); } static int meson_uart_request_port(struct uart_port *port) { + struct meson_uart_data *private_data = port->private_data; + int ret; + + ret = clk_prepare_enable(private_data->pclk); + if (ret) + return ret; + + ret = clk_prepare_enable(private_data->baud_clk); + if (ret) { + clk_disable_unprepare(private_data->pclk); + return ret; + } + return 0; } @@ -629,56 +654,175 @@ static struct uart_driver meson_uart_driver = { .cons = MESON_SERIAL_CONSOLE, }; -static inline struct clk *meson_uart_probe_clock(struct device *dev, - const char *id) +static int meson_uart_register_clk(struct uart_port *port, + const char *name_suffix, + const struct clk_parent_data *parent_data, + unsigned int num_parents, + const struct clk_ops *ops, + struct clk_hw *hw) { - struct clk *clk = NULL; + struct clk_init_data init = { }; + char clk_name[32]; int ret; - clk = devm_clk_get(dev, id); - if (IS_ERR(clk)) - return clk; + snprintf(clk_name, sizeof(clk_name), "%s#%s", dev_name(port->dev), + name_suffix); - ret = clk_prepare_enable(clk); - if (ret) { - dev_err(dev, "couldn't enable clk\n"); - return ERR_PTR(ret); - } + init.name = clk_name; + init.ops = ops; + init.flags = CLK_SET_RATE_PARENT; + init.parent_data = parent_data; + init.num_parents = num_parents; + + hw->init = &init; - devm_add_action_or_reset(dev, - (void(*)(void *))clk_disable_unprepare, - clk); + ret = devm_clk_hw_register(port->dev, hw); + if (ret) + return dev_err_probe(port->dev, ret, + "Failed to register the '%s' clock\n", + clk_name); - return clk; + return ret; } -static int meson_uart_probe_clocks(struct platform_device *pdev, - struct uart_port *port) -{ - struct clk *clk_xtal = NULL; - struct clk *clk_pclk = NULL; - struct clk *clk_baud = NULL; +static int meson_uart_probe_clocks(struct uart_port *port, + bool register_clk81_div4) +{ + struct meson_uart_data *private_data = port->private_data; + struct clk_parent_data use_xtal_mux_parents[2] = { + { .index = -1, }, + { .index = -1, }, + }; + struct clk_parent_data xtal_clk_sel_mux_parents[2] = { }; + struct clk_parent_data xtal2_clk_sel_mux_parents[2] = { }; + struct clk_parent_data xtal_div_parent = { .fw_name = "xtal", }; + struct clk_parent_data clk81_div_parent = { .fw_name = "baud", }; + struct clk_parent_data baud_div_parent = { }; + struct clk *clk_baud, *clk_xtal; + int ret; - clk_pclk = meson_uart_probe_clock(&pdev->dev, "pclk"); - if (IS_ERR(clk_pclk)) - return PTR_ERR(clk_pclk); + private_data->pclk = devm_clk_get(port->dev, "pclk"); + if (IS_ERR(private_data->pclk)) + return dev_err_probe(port->dev, PTR_ERR(private_data->pclk), + "Failed to get the 'pclk' clock\n"); + + clk_baud = devm_clk_get(port->dev, "baud"); + if (IS_ERR(clk_baud)) + return dev_err_probe(port->dev, PTR_ERR(clk_baud), + "Failed to get the 'baud' clock\n"); - clk_xtal = meson_uart_probe_clock(&pdev->dev, "xtal"); + clk_xtal = devm_clk_get(port->dev, "xtal"); if (IS_ERR(clk_xtal)) - return PTR_ERR(clk_xtal); + return dev_err_probe(port->dev, PTR_ERR(clk_xtal), + "Failed to get the 'xtal' clock\n"); + + private_data->xtal_div3.mult = 1; + private_data->xtal_div3.div = 3; + ret = meson_uart_register_clk(port, "xtal_div3", &xtal_div_parent, + 1, &clk_fixed_factor_ops, + &private_data->xtal_div3.hw); + if (ret) + return ret; - clk_baud = meson_uart_probe_clock(&pdev->dev, "baud"); - if (IS_ERR(clk_baud)) - return PTR_ERR(clk_baud); + if (register_clk81_div4) { + private_data->clk81_div4.mult = 1; + private_data->clk81_div4.div = 4; + ret = meson_uart_register_clk(port, "clk81_div4", + &clk81_div_parent, 1, + &clk_fixed_factor_ops, + &private_data->clk81_div4.hw); + if (ret) + return ret; + + use_xtal_mux_parents[0].hw = &private_data->clk81_div4.hw; + } - port->uartclk = clk_get_rate(clk_baud); + if (private_data->has_xtal_clk_sel) { + private_data->xtal_div2.mult = 1; + private_data->xtal_div2.div = 2; + ret = meson_uart_register_clk(port, "xtal_div2", + &xtal_div_parent, 1, + &clk_fixed_factor_ops, + &private_data->xtal_div2.hw); + if (ret) + return ret; + + xtal_clk_sel_mux_parents[0].hw = &private_data->xtal_div3.hw; + xtal_clk_sel_mux_parents[1].fw_name = "xtal"; + + private_data->xtal_clk_sel_mux.reg = port->membase + AML_UART_REG5; + private_data->xtal_clk_sel_mux.mask = 0x1; + private_data->xtal_clk_sel_mux.shift = 26; + private_data->xtal_clk_sel_mux.flags = CLK_MUX_ROUND_CLOSEST; + ret = meson_uart_register_clk(port, "xtal_clk_sel", + xtal_clk_sel_mux_parents, + ARRAY_SIZE(xtal_clk_sel_mux_parents), + &clk_mux_ops, + &private_data->xtal_clk_sel_mux.hw); + if (ret) + return ret; + + xtal2_clk_sel_mux_parents[0].hw = &private_data->xtal_clk_sel_mux.hw; + xtal2_clk_sel_mux_parents[1].hw = &private_data->xtal_div2.hw; + + private_data->xtal2_clk_sel_mux.reg = port->membase + AML_UART_REG5; + private_data->xtal2_clk_sel_mux.mask = 0x1; + private_data->xtal2_clk_sel_mux.shift = 27; + private_data->xtal2_clk_sel_mux.flags = CLK_MUX_ROUND_CLOSEST; + ret = meson_uart_register_clk(port, "xtal2_clk_sel", + xtal2_clk_sel_mux_parents, + ARRAY_SIZE(xtal2_clk_sel_mux_parents), + &clk_mux_ops, + &private_data->xtal2_clk_sel_mux.hw); + if (ret) + return ret; + + use_xtal_mux_parents[1].hw = &private_data->xtal2_clk_sel_mux.hw; + } else { + use_xtal_mux_parents[1].hw = &private_data->xtal_div3.hw; + } + + private_data->use_xtal_mux.reg = port->membase + AML_UART_REG5; + private_data->use_xtal_mux.mask = 0x1; + private_data->use_xtal_mux.shift = 24; + private_data->use_xtal_mux.flags = CLK_MUX_ROUND_CLOSEST; + ret = meson_uart_register_clk(port, "use_xtal", use_xtal_mux_parents, + ARRAY_SIZE(use_xtal_mux_parents), + &clk_mux_ops, + &private_data->use_xtal_mux.hw); + if (ret) + return ret; + + baud_div_parent.hw = &private_data->use_xtal_mux.hw; + + private_data->baud_div.reg = port->membase + AML_UART_REG5; + private_data->baud_div.shift = 0; + private_data->baud_div.width = 23; + private_data->baud_div.flags = CLK_DIVIDER_ROUND_CLOSEST; + ret = meson_uart_register_clk(port, "baud_div", + &baud_div_parent, 1, + &clk_divider_ops, + &private_data->baud_div.hw); + if (ret) + return ret; + + private_data->baud_clk = devm_clk_hw_get_clk(port->dev, + &private_data->baud_div.hw, + "baud_rate"); + if (IS_ERR(private_data->baud_clk)) + return dev_err_probe(port->dev, + PTR_ERR(private_data->baud_clk), + "Failed to request the 'baud_rate' clock\n"); return 0; } static int meson_uart_probe(struct platform_device *pdev) { + struct meson_uart_data *private_data; struct resource *res_mem, *res_irq; + struct clk *clk_baud, *clk_xtal; + bool register_clk81_div4; struct uart_port *port; int ret = 0; int id = -1; @@ -711,18 +855,37 @@ static int meson_uart_probe(struct platform_device *pdev) return -EBUSY; } - port = devm_kzalloc(&pdev->dev, sizeof(struct uart_port), GFP_KERNEL); - if (!port) + private_data = devm_kzalloc(&pdev->dev, sizeof(*private_data), + GFP_KERNEL); + if (!private_data) return -ENOMEM; + if (device_get_match_data(&pdev->dev)) + private_data->has_xtal_clk_sel = true; + + private_data->pclk = devm_clk_get(&pdev->dev, "pclk"); + if (IS_ERR(private_data->pclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(private_data->pclk), + "Failed to get the 'pclk' clock\n"); + + clk_baud = devm_clk_get(&pdev->dev, "baud"); + if (IS_ERR(clk_baud)) + return dev_err_probe(&pdev->dev, PTR_ERR(clk_baud), + "Failed to get the 'baud' clock\n"); + + clk_xtal = devm_clk_get(&pdev->dev, "xtal"); + if (IS_ERR(clk_xtal)) + return dev_err_probe(&pdev->dev, PTR_ERR(clk_xtal), + "Failed to get the 'xtal' clock\n"); + + register_clk81_div4 = clk_get_rate(clk_xtal) != clk_get_rate(clk_baud); + + port = &private_data->port; + port->membase = devm_ioremap_resource(&pdev->dev, res_mem); if (IS_ERR(port->membase)) return PTR_ERR(port->membase); - ret = meson_uart_probe_clocks(pdev, port); - if (ret) - return ret; - port->iotype = UPIO_MEM; port->mapbase = res_mem->start; port->mapsize = resource_size(res_mem); @@ -735,6 +898,12 @@ static int meson_uart_probe(struct platform_device *pdev) port->x_char = 0; port->ops = &meson_uart_ops; port->fifosize = 64; + port->uartclk = clk_get_rate(clk_baud); + port->private_data = private_data; + + ret = meson_uart_probe_clocks(port, register_clk81_div4); + if (ret) + return ret; meson_ports[pdev->id] = port; platform_set_drvdata(pdev, port); @@ -761,10 +930,42 @@ static int meson_uart_remove(struct platform_device *pdev) } static const struct of_device_id meson_uart_dt_match[] = { - { .compatible = "amlogic,meson6-uart" }, - { .compatible = "amlogic,meson8-uart" }, - { .compatible = "amlogic,meson8b-uart" }, - { .compatible = "amlogic,meson-gx-uart" }, + { + .compatible = "amlogic,meson6-uart", + .data = (void *)false, + }, + { + .compatible = "amlogic,meson8-uart", + .data = (void *)false, + }, + { + .compatible = "amlogic,meson8b-uart", + .data = (void *)false, + }, + { + .compatible = "amlogic,meson-gxbb-uart", + .data = (void *)false, + }, + { + .compatible = "amlogic,meson-gxl-uart", + .data = (void *)true, + }, + { + .compatible = "amlogic,meson-g12a-uart", + .data = (void *)true, + }, + { + .compatible = "amlogic,meson-s4-uart", + .data = (void *)true, + }, + /* + * deprecated, don't use anymore because it doesn't differentiate + * between GXBB and GXL which have different revisions of the UART IP. + */ + { + .compatible = "amlogic,meson-gx-uart", + .data = (void *)false, + }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, meson_uart_dt_match); From patchwork Thu Dec 30 10:21:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12701381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5018DC433EF for ; Thu, 30 Dec 2021 10:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fLyTGA4cKEMWzMALEpwZDEAExjjjubJ9iNSlBiK0uq0=; b=VOTXFZ6Zkh7n4c /Vm4HBYJsU63bJRWjK7RYqCl8OC30QGUzMJF7OZxgb2LFPwRqO6Gz6XoWmVr8myPd6uxQHHaMUr82 g9jPf7KeU85zdmrtXx2sKjYsdkZtyNlAqQC9pWuq/V/R4tvWPHsb7pG0ru91/KzQ17bSabEH//Yr9 LeFnw4uPW/BlgPbddJwS7mDjkcNrtW1uZ/FZmNe8n+LJl5DQ8kjftJ7sqC73p5ycph4wM0jiveSZE QxuTSf/cbYPsOqdZ6keC3pl+L0btCO1U7xylBkJJp7U2IG5nZWntoIR+4YThlrZV3QVSLmhB8ArbA iSponjOvsWhEc2KGzIyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sah-004CRK-SK; Thu, 30 Dec 2021 10:23:23 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2saI-004C9L-VH; Thu, 30 Dec 2021 10:23:02 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Thu, 30 Dec 2021 18:22:56 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Vyacheslav , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V3 5/6] tty: serial: meson: meson_uart_shutdown omit clear AML_UART_TX_EN bit Date: Thu, 30 Dec 2021 18:21:09 +0800 Message-ID: <20211230102110.3861-6-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211230102110.3861-1-yu.tu@amlogic.com> References: <20211230102110.3861-1-yu.tu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211230_022259_065213_BDC93AEB X-CRM114-Status: UNSURE ( 7.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org This change is an improvement. The meson_uart_shutdown function should have the opposite operation to the meson_uart_startup function, but the meson_uart_shutdown of AML_UART_TX_EN is logically missing. Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 07eb1f40aaaa..45e41f20cba3 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -140,7 +140,7 @@ static void meson_uart_shutdown(struct uart_port *port) spin_lock_irqsave(&port->lock, flags); val = readl(port->membase + AML_UART_CONTROL); - val &= ~AML_UART_RX_EN; + val &= ~(AML_UART_RX_EN | AML_UART_TX_EN); val &= ~(AML_UART_RX_INT_EN | AML_UART_TX_INT_EN); writel(val, port->membase + AML_UART_CONTROL); From patchwork Thu Dec 30 10:21:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Tu X-Patchwork-Id: 12701382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6E35C433F5 for ; Thu, 30 Dec 2021 10:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IvhXowHxEEd+tVtCQgmqxs9GFkToIKwHejDB52rxdGo=; b=lt1L7Oz1uiPDx+ 4w3ruMFR3kP8DyuvD1g7DGP5Mwenk5PNg82Tj1JtCkDhPcPDIH/fyajBZjCWAsjXg41DUx59lnJgm SwzODWuro+PivIBuYV+9Oy4RgZIGerh0mUK2NlrIxAdtLI11vkbumT0CdDESrITNZUBDw4Es6sQ+m Vz8KofdU7Vrx/jwqy3FZNAYmN3G9dQPvs0yRfQ6G0vnO3axfWhrLV2B5MziGv5pWj8O8R4wnYvW6d htDlZxe+OAthwsmhibmAcEI6o2zJAvUy1yM5oh2MVY1MujB4qjsXkdN/L5K+bt8XKrerz7xN7wX1d k4YOI/RdzkORmYVk224w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2sb1-004Ce7-Dj; Thu, 30 Dec 2021 10:23:43 +0000 Received: from mail-sh.amlogic.com ([58.32.228.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2saN-004C9L-Dp; Thu, 30 Dec 2021 10:23:04 +0000 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Thu, 30 Dec 2021 18:22:56 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Vyacheslav , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V3 6/6] tty: serial: meson: Change request_irq to devm_request_irq and move devm_request_irq to meson_uart_probe() Date: Thu, 30 Dec 2021 18:21:10 +0800 Message-ID: <20211230102110.3861-7-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211230102110.3861-1-yu.tu@amlogic.com> References: <20211230102110.3861-1-yu.tu@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.18.11.248] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211230_022303_518917_E947554D X-CRM114-Status: UNSURE ( 9.94 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Because an interrupt error occurs when the user opens /dev/ttyAML* but don't close it, and then opens the same port again. This problem is encountered in actual projects. Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 45e41f20cba3..0dd3f5b35768 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -135,8 +135,6 @@ static void meson_uart_shutdown(struct uart_port *port) unsigned long flags; u32 val; - free_irq(port->irq, port); - spin_lock_irqsave(&port->lock, flags); val = readl(port->membase + AML_UART_CONTROL); @@ -284,7 +282,6 @@ static void meson_uart_reset(struct uart_port *port) static int meson_uart_startup(struct uart_port *port) { u32 val; - int ret; meson_uart_reset(port); @@ -298,10 +295,7 @@ static int meson_uart_startup(struct uart_port *port) val = (AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(port->fifosize / 2)); writel(val, port->membase + AML_UART_MISC); - ret = request_irq(port->irq, meson_uart_interrupt, 0, - port->name, port); - - return ret; + return 0; } static void meson_uart_change_speed(struct uart_port *port, unsigned long baud) @@ -908,6 +902,14 @@ static int meson_uart_probe(struct platform_device *pdev) meson_ports[pdev->id] = port; platform_set_drvdata(pdev, port); + ret = devm_request_irq(&pdev->dev, port->irq, meson_uart_interrupt, + 0, dev_name(&pdev->dev), port); + if (ret) { + dev_err(&pdev->dev, "failed to request uart irq: %d\n", + ret); + return ret; + } + /* reset port before registering (and possibly registering console) */ meson_uart_reset(port);