From patchwork Mon Aug 20 18:13:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10570597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8442C921 for ; Mon, 20 Aug 2018 18:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7467B28CEC for ; Mon, 20 Aug 2018 18:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6689D28DF4; Mon, 20 Aug 2018 18:13:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,HK_RANDOM_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0C09128CEC for ; Mon, 20 Aug 2018 18:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fRrYP6bJ5WMdDDDO22LpwbXJ/6a9hMhrl5jTtgZa3P4=; b=LLTCmVDMI55MRuK+0KnqBspZKz UJOlKRPA0mcYjvjlKI+w/h0r/l4OZ6+IFbhh/SgE+hRY5Ra4BRE60PxvFNFVYM9rYgqDytAtZE2Vs YUnVU4oEHQpKFWDgZx6gfBIlZmfFE1olSb3ewNvxLX9CJDjU0vR4LfIgvLx5dpuDY5bfkIoqD5Ybw 92bW+NEYgmlpaEhc2+j6RLCZabP55f0s+lDeqQAEcaWA5BPNzsY6bz/DSonL/zd5Cp79HGNHo/l7G g2WnKtTc7EtH2GQCOb48vv7XLpDmIHqgLUn+viuNkUTUN70Wu8qwkfUeR357WUOpMSOBaOgDe2LbG B+pPenlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1frofo-0007VD-G1; Mon, 20 Aug 2018 18:13:04 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1frofZ-0007Cv-G1 for linux-arm-kernel@lists.infradead.org; Mon, 20 Aug 2018 18:12:51 +0000 Received: by mail-lf1-x144.google.com with SMTP id f135-v6so11590275lfg.10 for ; Mon, 20 Aug 2018 11:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gfupvttg31c1aYTw/7RZmPdZ03ABXSWuZu+liq+qhKI=; b=rhQd+HDk2S+4SX7FJNRZaYhS5JapSnAZNfVkJChLnHKatb4BohrGxJWH+Q4jdcHIoJ iv0OF/KvhAWEMNm1cnnQYdohnRqJ4uv73/7ZGRd7Av+hobJHody6jctCaJ8PTyMJrII7 X9wGulDH1bKBMXVOCn+WBBU+uTNz5dSHAsin7SgdC/XYmf9rG0bI9BdtiBOg7R6Rg1mG aCK5/BPs1Tu97yVGIf4OntqEcXFfvy7E7YdOgzIe69e985f53tYPWqNzRMIm9iwZxkRt Pa5GZ3EZMQr05kT8gYZpPaXxK1kb76hmzinDwJQCCPZ18Eli+8UzWP6fB3lmAw+SM4Kq u5Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gfupvttg31c1aYTw/7RZmPdZ03ABXSWuZu+liq+qhKI=; b=T39orTlLeRKzJGP/lc6NknD7hCFPlIpQnwRUF6ceb578PNZYgTHE0F6/u1mr+7OhSQ hPGIj+7MnLsndAIGFnHH5JJ/dP6d/VClcbGCj3TCiyjFHPNV+jHVNclceWttPNGkaChj HDkrKIlFmZbKTPfcsyGqGOgU4kRb/0+AsaU9GMAgQzunKNnEcLfsZPCO78TV0uPGmMsB y8nOFyKB0iq93HHtnk29lyVef3kRixNvWY2zaAX43Ornx9W3RMtnRZOebieSwzznxcLC XWDIyhiLdJsneGlz5uvKUVF0E1+nTposJmN+DYH1uIDtv+NenVja8esR5agUwxPCZ4oc RVtA== X-Gm-Message-State: AOUpUlHvsix3Q9xNq92M5f20B4Qv+cdOr91snwNB0i8JGFgE4zUjWArU u9eTkj7BtWYnuKtVOG1ZVAM= X-Google-Smtp-Source: AA+uWPz5SzY8Uj9T3YclS1cXRXYP1mhXxSq2/wEgCcvh4lMH276VbwBSkOZJG4QJmjcmqyhr08f4YQ== X-Received: by 2002:a19:93d6:: with SMTP id w83-v6mr5260470lfk.63.1534788757432; Mon, 20 Aug 2018 11:12:37 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id g16-v6sm379918lfb.5.2018.08.20.11.12.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 11:12:36 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH 1/3] ARM: OMAP1: ams-delta: assign MODEM IRQ from GPIO descriptor Date: Mon, 20 Aug 2018 20:13:31 +0200 Message-Id: <20180820181333.2527-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180820181333.2527-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180820_111249_542695_0CA1929B X-CRM114-Status: GOOD ( 18.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aaro Koskinen , Greg Kroah-Hartman , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Don't request MODEM IRQ GPIO by its global number in ams_delta_modem_init(). Instead, obtain its GPIO descriptor and assign related IRQ to the MODEM. Do that from omap_gpio_deps_init(), where the chip is already looked up. Then, in ams_delta_modem_init(), just check for the IRQ number having been already assigned. Signed-off-by: Janusz Krzysztofik Reviewed-by: Linus Walleij --- arch/arm/mach-omap1/board-ams-delta.c | 46 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 34cb63ff45b3..b3fe515b6f49 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -630,6 +630,28 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = { {}, }; +static struct plat_serial8250_port ams_delta_modem_ports[]; + +/* + * Obtain MODEM IRQ GPIO descriptor using its hardware pin + * number and assign related IRQ number to the MODEM port. + * Keep the GPIO descriptor open so nobody steps in. + */ +static void __init modem_assign_irq(struct gpio_chip *chip) +{ + struct gpio_desc *gpiod; + + gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ, + "modem_irq"); + if (IS_ERR(gpiod)) { + pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__, + PTR_ERR(gpiod)); + } else { + gpiod_direction_input(gpiod); + ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod); + } +} + /* * The purpose of this function is to take care of proper initialization of * devices and data structures which depend on GPIO lines provided by OMAP GPIO @@ -649,7 +671,13 @@ static void __init omap_gpio_deps_init(void) return; } + /* + * Start with FIQ initialization as it may have to request + * and release successfully each OMAP GPIO pin in turn. + */ ams_delta_init_fiq(chip, &ams_delta_serio_device); + + modem_assign_irq(chip); } static void __init ams_delta_init(void) @@ -844,20 +872,18 @@ static int __init modem_nreset_init(void) } +/* + * This function expects MODEM IRQ number already assigned to the port + * and fails if it's not. + */ static int __init ams_delta_modem_init(void) { int err; - omap_cfg_reg(M14_1510_GPIO2); - ams_delta_modem_ports[0].irq = - gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); + if (ams_delta_modem_ports[0].irq < 0) + return ams_delta_modem_ports[0].irq; - err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); - if (err) { - pr_err("Couldn't request gpio pin for modem\n"); - return err; - } - gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); + omap_cfg_reg(M14_1510_GPIO2); /* Initialize the modem_nreset regulator consumer before use */ modem_priv.regulator = ERR_PTR(-ENODEV); @@ -866,8 +892,6 @@ static int __init ams_delta_modem_init(void) AMS_DELTA_LATCH2_MODEM_CODEC); err = platform_device_register(&ams_delta_modem_device); - if (err) - gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); return err; } From patchwork Mon Aug 20 18:13:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10570599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 892E814E1 for ; Mon, 20 Aug 2018 18:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 795DF28CEC for ; Mon, 20 Aug 2018 18:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CB0528DF4; Mon, 20 Aug 2018 18:13:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,HK_RANDOM_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0642728CEC for ; Mon, 20 Aug 2018 18:13:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/5RmTwMV7kdGrniymj6L3SgvfJ7R6+HXYKmSx3D9T/g=; b=o2iFiY519+37fhwbSs+FHSPRbG sAs+99BYp1IeNoAwNbOS9oIlhAcbahTuntToYoaKcJBXBH+hcySoDywsvMdDelmhWswEP9qFqig+f tblKkZ6C+zbRF7cSNNM0u8cS/WHlm8qRuOG0bwILBRbwhhRMc5dJhV+0Y3jZQ94pBVs3MyUj+5aAc CAcFOFz62iIRepn8RrgZpQNcp+r3vzBnwS5tA63z3QY4/y4stPcxfLnWhYtsAox46lxw/SstzU5cg AKpntHWUwNqzSC0O0E8hIaFA4EqE2iTZLF1DLwcO8Z6onlYD3/nS6gGAiD8Rpq899YIGIbQ6KzCrf SsH0DRPw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1frofx-0007gj-Gw; Mon, 20 Aug 2018 18:13:13 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1frofa-0007DG-Lq for linux-arm-kernel@lists.infradead.org; Mon, 20 Aug 2018 18:12:55 +0000 Received: by mail-lj1-x241.google.com with SMTP id p6-v6so12310060ljc.5 for ; Mon, 20 Aug 2018 11:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7H4vp0EsPAd2Ofq3+tQ1pqiYwK34bXGlpOIDdMOQ8EE=; b=bnKEazNSGuBhuivNFwYWFiISSKTJbVSAkOQ8VzMUdUYzEwGe9zG5S23gIRS0I2N2fe 7wKjpiXOjPlyYgLx93Knj93yvV68pW1afqHzHxv8/C7g8CiMqCYqLVoEDbGGQ4v4yVrS f3imuhowG2u7FYD/7P3mAz24bcp6nTXMZhutgdxgoANsSt0eonNRTZf4cj893POHtVav lpcwCfRlo3AnGWVzHYnuYseIfWVmGrN+8khZu4meMxOoKPRqmdWOm6+7zPGkaovETDyI 6gLUW361Us1jf5Y+pFAXRwj7ktokLHwbyvjAXQI+5p727WxievIFW6Nk6hPVnJ3L9Dn+ uDow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7H4vp0EsPAd2Ofq3+tQ1pqiYwK34bXGlpOIDdMOQ8EE=; b=Jm5WFJPfyW2IKvpPVdQHNDdZ8t9cmM/jpX9v18iWWVVUGkavPnzyHn7l3ZiER04Nub hQrT8YB2jeN8sXwbxQ/hTnwOx6JW9T/VC585M2ukkZA87tgBpFxdFsw4iqoH6WYQGZQy n9hg+EVaGgAZ9g5/PdyymH+KryH8xTSW37xfZIwxvmWZit1Hnd059eajyYvnkMEO7W/m /Tf7k+t5Esgjv2KgHzPM+CMu22An1PtmN2EeN3Zzxv63F3RQE+CRvU1Xgap+O/Ju32MG ssiEmONuGTlZKQ/oOt3raAP/g8baW36HDdhFXCAM00TD5HH2ezGvWz+3+9/7Etkm6721 68Qw== X-Gm-Message-State: AOUpUlFS86eToWmK4xVid54Ljy1f2COUPTzk7lmWyelURmKTTsE3PKkj TKi3Uyyi/B7hTnU1hnBiEZc= X-Google-Smtp-Source: AA+uWPznbBPNlimjuQ8SI4V8hIfheWIEq0pv/knHCsU6bTeq2Of1UtSnHYIgo2Z1Bs0p0nbe0cpqOQ== X-Received: by 2002:a2e:7406:: with SMTP id p6-v6mr17448106ljc.5.1534788758629; Mon, 20 Aug 2018 11:12:38 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id g16-v6sm379918lfb.5.2018.08.20.11.12.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 11:12:38 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH 2/3] ARM: OMAP1: ams-delta: initialize latch2 pins to safe values Date: Mon, 20 Aug 2018 20:13:32 +0200 Message-Id: <20180820181333.2527-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180820181333.2527-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180820_111250_834016_F9DE2AFC X-CRM114-Status: GOOD ( 21.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aaro Koskinen , Greg Kroah-Hartman , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Latch2 pins control a number of on-board devices, namely LCD, NAND, MODEM and CODEC. Those pins used to be initialized with safe values from init_machine before that operation was: 1) moved to late_initcall in preparation for conversion of latch2 to GPIO device - see commit f7519d8c8290 ("ARM: OMAP1: ams-delta: register latch dependent devices later"), 2) replaced with non-atomic initialization performed by means of gpio_request_array() - see commit 937eb4bb0058 ("ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio"), 3) made completely asynchronous by delegation of GPIO request operations performed on subsets of pins to respective device drivers in subsequent commits. One visible negative result of that disintegration was corrupt keyboard data reported by serio driver, recently fixed by commit 41f8fee385a0 ("ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin"). Moreover, initialization of LATCH2_PIN_MODEM_CODEC still performed with ams_delta_latch2_write() wrapper from late_init() is now done on not requested GPIO pin. Reintroduce atomic initialization of latch2 pins at machine_init to prevent from random values potentially corrupting NAND data or maybe even destroing other hardware. Also take care of MODEM/CODEC related pins so MODEM device probe succeeds even if latch2 GPIO device or dependent regulator is not ready and CODEC can be reached over the MODEM even if audio driver doesn't take control over LATCH2_PIN_MODEM_CODEC. Once done, remove the no longer needed GPIO based implementation of ams_delta_latch_write() and its frontend macro. Signed-off-by: Janusz Krzysztofik Reviewed-by: Linus Walleij --- arch/arm/mach-omap1/board-ams-delta.c | 52 +++++++++++++++++++++++------------ arch/arm/mach-omap1/board-ams-delta.h | 7 ----- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index b3fe515b6f49..c865c6921af8 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -321,20 +321,6 @@ struct modem_private_data { static struct modem_private_data modem_priv; -void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value) -{ - int bit = 0; - u16 bitpos = 1 << bit; - - for (; bit < ngpio; bit++, bitpos = bitpos << 1) { - if (!(mask & bitpos)) - continue; - else - gpio_set_value(base + bit, (value & bitpos) != 0); - } -} -EXPORT_SYMBOL(ams_delta_latch_write); - static struct resource ams_delta_nand_resources[] = { [0] = { .start = OMAP1_MPUIO_BASE, @@ -680,6 +666,40 @@ static void __init omap_gpio_deps_init(void) modem_assign_irq(chip); } +/* + * Initialize latch2 pins with values which are safe for dependent on-board + * devices or useful for their successull initialization even before GPIO + * driver takes control over the latch pins: + * - LATCH2_PIN_LCD_VBLEN = 0 + * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its + * driver takes control over it. + * - LATCH2_PIN_NAND_NCE = 0 + * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write- + * protected before its driver takes + * control over it. + * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio + * driver takes control over it. + * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first + * byte of data received from attached + * keyboard when serio device is probed; + * the pin is also hogged low by the latch2 + * GPIO driver as soon as it is ready. + * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for + * its successful probe even before a + * regulator it depends on, which in turn + * takes control over the pin, is set up. + * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port + * to the MODEM so the CODEC is under + * control even if audio driver doesn't + * take it over. + */ +static void __init ams_delta_latch2_init(void) +{ + u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC; + + __raw_writew(latch2, LATCH2_VIRT); +} + static void __init ams_delta_init(void) { /* mux pins for uarts */ @@ -701,6 +721,7 @@ static void __init ams_delta_init(void) omap_cfg_reg(J18_1610_CAM_D7); omap_gpio_deps_init(); + ams_delta_latch2_init(); gpiod_add_hogs(ams_delta_gpio_hogs); omap_serial_init(); @@ -888,9 +909,6 @@ static int __init ams_delta_modem_init(void) /* Initialize the modem_nreset regulator consumer before use */ modem_priv.regulator = ERR_PTR(-ENODEV); - ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, - AMS_DELTA_LATCH2_MODEM_CODEC); - err = platform_device_register(&ams_delta_modem_device); return err; diff --git a/arch/arm/mach-omap1/board-ams-delta.h b/arch/arm/mach-omap1/board-ams-delta.h index 1fbada29431a..a74a306d7e77 100644 --- a/arch/arm/mach-omap1/board-ams-delta.h +++ b/arch/arm/mach-omap1/board-ams-delta.h @@ -59,13 +59,6 @@ #define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN #define AMS_DELTA_LATCH2_NGPIO 16 -#ifndef __ASSEMBLY__ -void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value); -#define ams_delta_latch2_write(mask, value) \ - ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \ - AMS_DELTA_LATCH2_NGPIO, (mask), (value)) -#endif - #endif /* CONFIG_MACH_AMS_DELTA */ #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */ From patchwork Mon Aug 20 18:13:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10570601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2A2514E1 for ; Mon, 20 Aug 2018 18:13:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A039729081 for ; Mon, 20 Aug 2018 18:13:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92B712912E; Mon, 20 Aug 2018 18:13:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,HK_RANDOM_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3199C29081 for ; Mon, 20 Aug 2018 18:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=u4RXh6T5RT5oAKGPI7DINBMEOBpd+l3y1DjoVCxdIgU=; b=jewCchz/lQjwkFV4E9CT+pP2e0 BgIT/yR9qLs0sox+qq6JTit8HzhdFd0WLNdeJGHQUYUsp/oYy4cLRQ+nUgLPpmnBIQYslsZ1byHQN h5mxtVm0s9hvS5bwGi57eNeBQRkrSE4CnH0LQuLZabEC8ITTiQIdmWgsG56hkNDzrhnUz0x15GESl UOxZ6M/w9tuZrPBJTBYtWzvgHHoc49jPeHoAPlfmVXLpz5aI9/fmmgMufbs7+iRQcDfZl+YxzkHq4 7vx7e6upWaXTUqz4tSc2Bkn5m9B5ZX8fQG6lxcG/r6TuL52nxiICE1bgcvnns8MzJSxkwSk5d4FWM 1KLyfbWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1frog9-0007xH-Dp; Mon, 20 Aug 2018 18:13:25 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1frofb-0007Dg-Lr for linux-arm-kernel@lists.infradead.org; Mon, 20 Aug 2018 18:12:59 +0000 Received: by mail-lf1-x142.google.com with SMTP id y200-v6so11589438lfd.7 for ; Mon, 20 Aug 2018 11:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3dosDfoX2lLtKRM7stKlq06j/xqPONJf6rhUbBAZA3A=; b=lYt7kJySiIkQG5dCEZZYyHekHe1WO3mA42KOewv7dTKhwxPZZV9YL129N8DbJTEn2y IAXptQODRZ9bNzaoreSBu5Q0MWCgb+DA771iZTtiaNNXBKixt3yWs8WSx5CZ6OwgUne1 MJHFcaeYt28Jmm/0fXRcj5iiVqqQyMwdZheHeQ0rpXKMj3aWmlop88lKYExjVaC9iCZ9 gCYc9DXOMj/mpht1B5ZC3m3TlEti9qEZX4t9uhfIyZkAiXJL0dCzMTDEfrSUTw7qa/kT ZbK4zPosEultQpbvhOaILKOhfeqXKpC3gO5dMqIuWBvQmsfTpt0yM12fcHUuZsxLO7k+ w3eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3dosDfoX2lLtKRM7stKlq06j/xqPONJf6rhUbBAZA3A=; b=Wbdd/jemeP98rB9dBZCDoBavgiAUsJjh6o2PSAKX3J8yMPhUkmHh9JmjkP8MDNCemb 5yoIb8Ljqvua3pK/psPh5YgU+fv30ySEVOhqGVeGAHHBH/c6DZB8Q7PaW/ycPBak03vs Zqzzyc9x2wkU71uO/gvsCmWjnE18eEtPMwNyEv60Olsa6Nz4t5584jap5VSp4tTBQ/Fg 1N4bIJVKXLX9kO+JVhrrABsJiCsG2HEoJ7XM2dDwFd5yZf00hIpAQFka2jo/cBJ/oV9s RyyBEHCsBGZr8wtCY2IxyjloLLKIgZ5/yGFrpDsuT1Ko4FKaituFXMwGlXENF8s9H4sP 9I6Q== X-Gm-Message-State: AOUpUlHxgC+gjvz/nCnFqC2ccdciXmbANZY+3Mfla6dlTnb9K4BFkWAP mSBHL3P6V2WVgngxHJrh1Jg= X-Google-Smtp-Source: AA+uWPwCCKr9vbqiCyZ0TV8HrKGZRAnyXByKBh8OBSxL82xY1pf4MTmwnQnBvqdjc9BdAvug9zVXmg== X-Received: by 2002:a19:5353:: with SMTP id h80-v6mr15760581lfb.9.1534788759832; Mon, 20 Aug 2018 11:12:39 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id g16-v6sm379918lfb.5.2018.08.20.11.12.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 11:12:39 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH 3/3] ARM: OMAP1: ams-delta: register MODEM device earlier Date: Mon, 20 Aug 2018 20:13:33 +0200 Message-Id: <20180820181333.2527-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180820181333.2527-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180820_111251_963873_75DE51D5 X-CRM114-Status: GOOD ( 17.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aaro Koskinen , Greg Kroah-Hartman , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Amstrad Delta MODEM device used to be initialized at arch_initcall before it was once moved to late_initcall by commit f7519d8c8290 ("ARM: OMAP1: ams-delta: register latch dependent devices later"). The purpose of that change was to postpone initialization of devices which depended on latch2 pins until latch2 converted to GPIO device was ready. After recent fixes to GPIO handling, it was possible to moove registration of most of those device back to where they were before. The same can be safely done with the MODEM device as initialization of GPIO pins it depends on was moved to machine_init by preceding patch. Move registration of the MODEM device to arch_initcall_sync, not to arch_initcall, so it is never exposed to potential conflictinh registration order hazard against OMAP serial ports. Signed-off-by: Janusz Krzysztofik Reviewed-by: Linus Walleij --- arch/arm/mach-omap1/board-ams-delta.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index c865c6921af8..a98783f98f3a 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -896,11 +896,28 @@ static int __init modem_nreset_init(void) /* * This function expects MODEM IRQ number already assigned to the port * and fails if it's not. + * The MODEM device requires its RESET# pin kept high during probe. + * That requirement can be fulfilled in several ways: + * - with a descriptor of already functional modem_nreset regulator + * assigned to the MODEM private data, + * - with the regulator not yet controlled by modem_pm function but + * already enabled by default on probe, + * - before the modem_nreset regulator is probed, with the pin already + * set high explicitly. + * The last one is already guaranteed by ams_delta_latch2_init() called + * from machine_init. + * In order to avoid taking over ttyS0 device slot, the MODEM device + * should be registered after OMAP serial ports. Since those ports + * are registered at arch_initcall, this function can be called safely + * at arch_initcall_sync earliest. */ static int __init ams_delta_modem_init(void) { int err; + if (!machine_is_ams_delta()) + return -ENODEV; + if (ams_delta_modem_ports[0].irq < 0) return ams_delta_modem_ports[0].irq; @@ -913,6 +930,7 @@ static int __init ams_delta_modem_init(void) return err; } +arch_initcall_sync(ams_delta_modem_init); static int __init late_init(void) { @@ -922,10 +940,6 @@ static int __init late_init(void) if (err) return err; - err = ams_delta_modem_init(); - if (err) - return err; - /* * Once the modem device is registered, the modem_nreset * regulator can be requested on behalf of that device.