Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4185115imm; Mon, 20 Aug 2018 11:15:00 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyysW6dGiMqXYHyGEtwXGLRH27WfuG/zsqwtPd90GniKYfENJByy5wqqSy9YC4bj/fxgdp1 X-Received: by 2002:a63:88c8:: with SMTP id l191-v6mr12575329pgd.340.1534788900606; Mon, 20 Aug 2018 11:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534788900; cv=none; d=google.com; s=arc-20160816; b=SRrb+l9mG+rvV+B+ovaYMx/Yq2/ywxBlNZ1UEulNNNsXIDy0PVoT+dfn5aYxEujR1A Fo/10xjPIZtscFh+EvOLl+rT3lPGEw7efeO0AHNt5l0iAm39FYMi4YyBRlMTxK4wUDxa R8Jdjegy3uUrGrxvFTIGgf7dMobxlmQqQXiteO2bjBAK/KkaWfwZkgNVuPOYWa8wjiP0 LgRYLrTXK4OZVpGRo5Xhw4vthNnQD3zCFquc14INK1nXSAc4ZySkXoXaUk39gKfKLNpK omonfaNbYQ2PxWZoxXybQndB8dhfGIybuQQ/IzjPVBNw8Ha/cGxH/ErE0218BNUQHgeG WYNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gfupvttg31c1aYTw/7RZmPdZ03ABXSWuZu+liq+qhKI=; b=zKwlYSc4Me0SAEFwD0gK8be1CuLgEELWFXWnX8GwuyqN2c98+gIXJOwoU7UpsS/pG0 h8hoPzAtYmAaTlYLKCfFHi/UjmR4IrWlgNJQCJhVa3zco0hvHvPRtIUruAwoqLzPF1D4 JU5Bc06TGmVl/JKE3ZkP8oGFRLj2pnsiyG3v8CD7VHinw6kyCFty5YP9Tpw8disGgX85 N6H9Wwhn+7/FMIcWXnUjVwi0cXlQ/GbmOla8r3SHQ91Y04oJe25rDYdXVzKbqPDvAldI 27PJyfeHoc6R+opxBXG9ql/rhqVg5T+2YqJ+OYjCk4fBKwGGmk5lQTZ49Y72FUf9WrK7 g01g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rhQd+HDk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si9773278pgg.341.2018.08.20.11.14.45; Mon, 20 Aug 2018 11:15:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rhQd+HDk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbeHTV3V (ORCPT + 99 others); Mon, 20 Aug 2018 17:29:21 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44349 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbeHTV3T (ORCPT ); Mon, 20 Aug 2018 17:29:19 -0400 Received: by mail-lf1-f66.google.com with SMTP id g6-v6so11601186lfb.11; Mon, 20 Aug 2018 11:12:38 -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=oCZwDA9dScRL5Gan2ZC9mKy2zE7LAIHZJH9g5+78rm9yzEPKpIl7MqD3ndO5aByn3O dTbnj4yQxd04696brY0Vf6q6sGa+/UTzbpLYvSjEFVj5udUvgCNFSOqP4yQMa8503U/P NDuNkDElv9mw/vq8jORomYtjXCHVov4Y5nJpJRcy6E5xbCE2o3sSkgWyLwSZF6v0POYN s1YbZmxic4icobM1QvP7KucyPOaWKMh/51jsgQ8j0HQ9bZxohiMEwV4c2+L9syZJWoO6 Sw2+zgdFf25WBIJHsljHwmmFCIIesemLMDjn2g/elstBPGV2CVKpwD9HAjxItTHSaQ/D cmoQ== X-Gm-Message-State: AOUpUlFFd6+i3pykMJIXXCjYBkYhL/sby2a4vIsPmUNv1hxco1fEQLPb O6nUBaKP6QKMmd4p02ofI9c= 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 Cc: Aaro Koskinen , Linus Walleij , Greg Kroah-Hartman , Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-serial@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.16.4