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; }