From patchwork Sun Sep 9 23:44:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10593467 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 D99616CB for ; Sun, 9 Sep 2018 23:44:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C833128FF3 for ; Sun, 9 Sep 2018 23:44:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB94829003; Sun, 9 Sep 2018 23:44:08 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 2827D28FF3 for ; Sun, 9 Sep 2018 23:44:08 +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=mQ1aALR9uE9OmCD2rx96fw/QIuOF5rgnLid9s4XGS4s=; b=ryfp48IxDElULTZZ1QUekeh9h6 85FHE8wQnEpfkz+A59xiL9fEbdXyNkNNElJGoOwI4j14mbOrR5/xXWanT5iA+F7pM6n8X2HAV8EvC eXOBt31BQs7T2mxmNNPd/PscgQZpzW8OtuQ1wkPcmmDsEU6JMLoMcPMLxhw7rmocNgRwSRGtk+K6n mGOYuH05I/wvknkaeb/7jU5qmIQyu7zvgdTfMVYXWx89Oo7kUvizY0vBxqD9TJZCKJdEBlxsggV9r qYZzARkP100zhyh5zurpJlvaEoisO4XSy80VSWjZ9zwjkTSo175IxthYNQoWNWaXnvoRXTM2Z6wQL OD25tOGQ==; 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 1fz9N1-0001zu-VA; Sun, 09 Sep 2018 23:44:00 +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 1fz9MU-0001m6-Kr for linux-arm-kernel@lists.infradead.org; Sun, 09 Sep 2018 23:43:28 +0000 Received: by mail-lf1-x144.google.com with SMTP id c29-v6so16031222lfj.1 for ; Sun, 09 Sep 2018 16:43:16 -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=YK+Ty9TBR/rg1v0LhEVO8ANe8m53hJSFnx1eji2QoP8=; b=EN53iw0PmnRGJba9NmXxUq6PMSwOXj0JiGLHfTrvYUar0p+fI/8APzRLOV5GCt5/94 AtkZ5Xb4OlYo7y0duCiIXvBKoeCzq5KgPBDJQQfabh7gCMONmUt52HMBLKwvPoklQ4EK DtHuCFT/8xNkfoEXYDtxT82vi7QGW7haBiBQc1gxBcvyqdT1rsHPwiFAACFwWIC6dOZf ftP7MC68XpcMscwVsorQpOWrogmZlTMmHrHW2S0zIY9qmCQPy9eS5TdNSnzl8oZ+XJXW QOA0IuIaECETLCl53X+jiAdYBOH+Dvry6cHuB5D/PnsNUPfHtTiDEhWiTGGKsmdkRt8l sTwA== 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=YK+Ty9TBR/rg1v0LhEVO8ANe8m53hJSFnx1eji2QoP8=; b=k9rPeTMxeldDTFtrzcojYGOF37tRy/NIh59Gg3ACujlM12KhSz2MaeoevX2x6Jpg/w wGbKOyROVRjL4ScfaiDrU2DIRB0kwPim6bMnFbGMuFwjthQzbX9AhfqiiLxlJcZSN0S+ sZ4+7AsHbgKTXDYGetoSNen2x+xeaayeLMmOWSmcMnrMm5+05Z28B7+wMrhqM484dhGH eOyLeNn9mDXjBPX8iYgKiQBhDefH325m8N3e/XX9VovbooameyXXb6W7kiUZtF9P0hwB 1qT8Cg2TmutIuKg8RODiTPa6CExmmTrt7Q3zuS71xWrKFYpbxKhnOVV0gpRh0sYME/jk dO3w== X-Gm-Message-State: APzg51BlKHxw/JD6Y0Ajm0Z5AajHCsjL1AoD7qncP2GSPH1w9SUKiwdb +/CrBhFJt5j0bJJhBvnBVtc= X-Google-Smtp-Source: ANB0VdZ4IFreTKtsWL0qZC/V1VJy38kZeAfN62FdlPzCgzLonaO72dEafv2Mu4fwRz4MHi1HyRuFnw== X-Received: by 2002:a19:18d8:: with SMTP id 85-v6mr11225159lfy.133.1536536595002; Sun, 09 Sep 2018 16:43:15 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h4-v6sm2355373lfj.69.2018.09.09.16.43.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:43:14 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH v2 1/3] ARM: OMAP1: ams-delta: assign MODEM IRQ from GPIO descriptor Date: Mon, 10 Sep 2018 01:44:17 +0200 Message-Id: <20180909234419.31261-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180909234419.31261-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> <20180909234419.31261-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180909_164326_679394_B8262B6C X-CRM114-Status: GOOD ( 18.34 ) 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 , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, 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 | 47 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 34cb63ff45b3..2b90b543c030 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; } @@ -898,7 +922,6 @@ static int __init late_init(void) unregister: platform_device_unregister(&ams_delta_modem_device); - gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); return err; } From patchwork Sun Sep 9 23:44:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10593469 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 754ED921 for ; Sun, 9 Sep 2018 23:44:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62A1628FF3 for ; Sun, 9 Sep 2018 23:44:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56C3029003; Sun, 9 Sep 2018 23:44:59 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 7756F28FFB for ; Sun, 9 Sep 2018 23:44:58 +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=3SOYG8DUMmVx5LH8VbBXzuUzV2CsshS8N8tsIs7XHu4=; b=rsHBepYiWJjH2jiyXjcHA5yMgr jIqFDe6ms5HnLYcmeb+Co0WsDZdqSC/YiXoT0UQsihWkaAuwueRrUaDUkCH8R2te5fR153ij+xLHm dpUwo5QVTT11ff1aHH5tWRWmCCC+DS9rh8v209TAha425GW3mlbOeCl2RH2qpjArKZqQcTl59jECd bwRR+fcFvfmk+9GiW1Xa279W3GoRN9vn/X5Sb35CklGG+WwKk/2ypLksWHk+xtBYHpDbWw8Jnnsjg M+EWizW/s9vYODTaP58P0dSE6MON9EId2aOpbaEdhMk7EuXvEf9r9O4T621cT1bnbTZMwzFF4P6ds hAIOs3vA==; 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 1fz9Nh-0002Gs-S7; Sun, 09 Sep 2018 23:44:41 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fz9MV-0001m7-VG for linux-arm-kernel@lists.infradead.org; Sun, 09 Sep 2018 23:43:29 +0000 Received: by mail-lj1-x243.google.com with SMTP id p10-v6so16349244ljg.2 for ; Sun, 09 Sep 2018 16:43:17 -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=0Jh2T4iNgwJkzbvYAP63yn/Klla1LAuUcrQl1eNDtKo=; b=fSvL+MHdDopIcAtJTsFUbCGpd79ybzPlrf/+6ukC0NXCk9MJfZE6ZcEklkautwye1R sQJ9aQhK6N4ggC1gbUeZmYelhGhZp1pmH7XUta9c96MSiipNL2GiZpEF58yeBjzkx6h3 zpe91afZSOt8OJ8QEIGlGAz3DNBWtCVW1kkqGGEOkecGPQmuq8h1Kb0RNxXM3r67pF4A F9rcq1LZWKBMpS2EIY4lAjDDqyMFt2BwlwLa3YA/DAf1MjgEBpUedL9bEKD+uQUKere7 Q0R84tWC7+1onJUM3oqNGlU4NmVVX4ARwn+ZLp6Qb75uiicgLHbZbUyCJvDmWUJhu9zU dH5w== 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=0Jh2T4iNgwJkzbvYAP63yn/Klla1LAuUcrQl1eNDtKo=; b=CfD2krIAdDKitz8TMa9bE6HEmoIoNT0IqiBSRcV7BHU/YJBYH/Rl68ez3ADZRczSLz zAT36xykdWkRJB1+YbnaMERpZyyw2lUYZ5pt6tpJTUuWSUAcKszuzfSxFxk4tbgstT6Y ZE85Nf52fas8o8OBX+NPjVEo7ajhS7ZkPpfuri2lRxlfYGRY+WJq4opEoPnQoJU761ah AupcmEVzk/f94PCdy20JqbbnsbKGPFFhiEU3zBFla4vSi8I7fJttP5v+AQcvZRSRjBKI f/t3g7zpL8DmbT/yeZThZlAHUrz7q1b6aWL0Zgmzhz5G+XR5UuURur0fD842ZOxXORmk Opsw== X-Gm-Message-State: APzg51B7YPENw7hAoJbG2ltoQaIP/8k2B6tUA8ag6XRa0MKJqAlWT0ZY NLSWB3eFDSDi8gpJIE4b/k0= X-Google-Smtp-Source: ANB0Vda7y/CFc5qx88krJLRihPzdJ32RlhbKxSOS5lhoCsv29MijUVvAUfQWkEgk41bnz+IFFAeXIw== X-Received: by 2002:a2e:8147:: with SMTP id t7-v6mr11423379ljg.32.1536536596141; Sun, 09 Sep 2018 16:43:16 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h4-v6sm2355373lfj.69.2018.09.09.16.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:43:15 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH v2 2/3] ARM: OMAP1: ams-delta: initialize latch2 pins to safe values Date: Mon, 10 Sep 2018 01:44:18 +0200 Message-Id: <20180909234419.31261-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180909234419.31261-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> <20180909234419.31261-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180909_164328_001880_BFA36374 X-CRM114-Status: GOOD ( 21.72 ) 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 , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, 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 2b90b543c030..1d451142248c 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 Sun Sep 9 23:44:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10593471 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 C700414DB for ; Sun, 9 Sep 2018 23:45:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3AB428FF3 for ; Sun, 9 Sep 2018 23:45:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A429929003; Sun, 9 Sep 2018 23:45:54 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 14E1228FF3 for ; Sun, 9 Sep 2018 23:45:54 +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=C1DYIpjkglprFlJqlGD9JOMEpVzeWFp+QPSGHjHrxAs=; b=advAIRCkOztG2KdNVWZqasItJj uk1EhYhB9mSZpc/jdYK5BcLM1uVipM3d8TiGUQuV3KL6arz4PEkFYjsvRr2DtTfgkGphHJfTXgvZI PZQYeuUKGiSP4D4xWhRufUDuN/O01Xn2apANenIydKuL/5T+oF6KQzlWXGqvvsNL9FGZ7MllzVHev 9AxERHicbPNAlFQ6zHtP71DDfuWvg7CPNcqOxHfkcmIHFvazUmQ7idRISVl/MsnsstRlfpxgS/SJI +/dob1xZeT/z6qc7dMBWydQZ7y84o4C03N571lUMle9Oi2mtkhlwfPJSFXTl6yZSimYqUFZajjO8s 3NZ3y3ZQ==; 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 1fz9Og-0004Ey-EN; Sun, 09 Sep 2018 23:45:42 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fz9MW-0001m8-VZ for linux-arm-kernel@lists.infradead.org; Sun, 09 Sep 2018 23:43:30 +0000 Received: by mail-lj1-x244.google.com with SMTP id f1-v6so16312092ljc.9 for ; Sun, 09 Sep 2018 16:43:18 -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=M/QBgS5czV0iRAtflFDT2zvaSpvt1iMlKHvBYDahNH0=; b=BK2PipI63jK7bS8duqrxQsgUHGioMSIyS5BZ8q/FtzxBqKAzTQPvA4fibDXK3RAXm0 kdGJRtV/g5EO5ghMNB2VciyH765nIMOZYu936OMMptNgnWc96jJJc4Y3tt4s+qtA8yOp pfuI0Gl9T/bIikxE9K6BuXk8Y0ipRdSo6WT9qorVXH/hWFY2cfvYSNDrX4Evu0XFQje3 OUcdWzQYC0M5AdqkLxpVHls/XKGBxc3t8GpGuMaDWt/4NxwBPXbm/Pb2jNFfHQh/a7/f zVCe+5UZRlcGg8hRjI76+Ig81ROc0/tA8NZwwXL2V1cw+3s0GB5Qs880PRpEWDXjuvW1 bfBA== 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=M/QBgS5czV0iRAtflFDT2zvaSpvt1iMlKHvBYDahNH0=; b=exN+/Ak+2h2DjCf3cDuoTNY9fhd2IwH1rwMEbop+t3BBrrl2yaTvtpVfY10JV3fPCG 7L241mIlTFgLvA31g/mEw/tLQZkEUDQX6sLMtWK+bKWr5JRIretE52GpXTGdp7Ij6IrN wfuUBdkSLKUTURAREHvZnlqxioLN3UdxIMy+ohW5SH94sLtaDHEO9FTuZ7BY5AobR170 zqZYoM8iWV5zWjDKT2Gk2w/4GjRhuEnj1M2XLbBz/QjXEZ5UwU19OTACaotcCIVH+NuK nd04IetBnj7G7vQITsC/pALfnqWlwk70Ua++Rsz71FrkqJRv0e7001sU205uU2IyjuUo MV5A== X-Gm-Message-State: APzg51Cg7R5fP3Y7o3h3ry2Sq8AMu6RvoxYNV9ua8Ca830wRMU3NvXep WWjFwItvED5odBQn61PwI5M= X-Google-Smtp-Source: ANB0VdY3f3wsbkPs3gtwWf8Md/cAGRxnWXEJm8I/n4LqgKo1aIoA6FcNO92NYvaicD02CVItQbaibg== X-Received: by 2002:a2e:6a04:: with SMTP id f4-v6mr11225686ljc.109.1536536597340; Sun, 09 Sep 2018 16:43:17 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h4-v6sm2355373lfj.69.2018.09.09.16.43.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:43:16 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH v2 3/3] ARM: OMAP1: ams-delta: register MODEM device earlier Date: Mon, 10 Sep 2018 01:44:19 +0200 Message-Id: <20180909234419.31261-4-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180909234419.31261-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> <20180909234419.31261-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180909_164329_037631_1372D609 X-CRM114-Status: GOOD ( 18.32 ) 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 , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, 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 conflict in 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 1d451142248c..667c3c1f05f5 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.