From patchwork Tue Jul 17 17:20:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10530275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23BA36020A for ; Tue, 17 Jul 2018 17:37:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A034296C3 for ; Tue, 17 Jul 2018 17:37:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1DEF2976E; Tue, 17 Jul 2018 17:37:19 +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 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 A55B5296C3 for ; Tue, 17 Jul 2018 17:37:19 +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: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:In-Reply-To: References:List-Owner; bh=FP/AklDFap0gQwgZU72f6QlIRu81wya4s2Cqx8EIKUg=; b=LLR o/Ml7aOfhwGunFdIDA7xpwjelq6zlp+GxX4lT/kLwMoZt9T2ZTjinwcE5VWa0x7e7S5vYrrQf2oDp 6rmk6Oa/VQZwbb5gm9xZggEIw8vhsyec4ilQPpVxoCA3cU7I09smYa/I3LbPB6oVi4cA9jfSVwfaw UsllSIwLZ9JqDFWekHEtKI0LtM/nvs89EowJfTgfd2zopkA8rnUQliGeFuLNHF73HaQWTufCcR2Dg wkcb9t0IXMjppY0wNBXBfOd/hAsK1jmbYmeo1dUAuWWNy3+VEwLIDIgumBDwtjFFe1eVSOrROfWpf S3ZV9NP+N2iA9Ud7JakJ7pkMnT0HxTw==; 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 1ffTed-0003fC-EW; Tue, 17 Jul 2018 17:20:51 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffTeN-0003DJ-PC for linux-arm-kernel@lists.infradead.org; Tue, 17 Jul 2018 17:20:37 +0000 Received: by mail-lf0-x244.google.com with SMTP id g6-v6so1400942lfb.11 for ; Tue, 17 Jul 2018 10:20:25 -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; bh=i9wkBg7Hsu4Be5vqekATgyLF7+tVr2R69O6VYweQI5M=; b=LTUp1oDAEF5g4L+LKimE8yYLIpRg/xd/FIPiJoZ/QtKKPulL/MEwdsuE+uYpqc8+Cn CThURZqU5i1VLBvqUhe/XP+ALbJacGhPy6b6T1P34i8XMP3tANm8lm2gdUXorZE2j7zH cnB/SZQT3EpBc6m4j7HnURsUbDgf9aE+8eXvBWKBWEVP+bsQTaNWykTzb+y5bSbqvE6P QwnIztxY8zErTc7zPZrjE46ZwEq/LSlv9DHiRyAJy6VOifdpprMvesnIfFUQ6GOKPArC CUhTjfscdAXcdK0MQ+Xt5MzYZ/Rjr7ywRHqu9UvCzdBb4bq4VkENaK1227Cb/xK7Bs2j v6pQ== 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; bh=i9wkBg7Hsu4Be5vqekATgyLF7+tVr2R69O6VYweQI5M=; b=pjbvKOgtCNm+qPOVmMcuiuIOVRIi6mvLp3/l1kgWYLPyJgOaBUFylZtFg3psWU8PZ7 VyD9LcuFIOj/BSTV49/AKXhPtqwFuvdsj/T3bs7uGBcC4YcQ//7KJ5fzdZ/ZY4tZ3Zv7 e5K1YPf2muFZKlgS6z1F9/Vmy7TixzSiJvdvJxyJR+8Ho9DRSHKo3s/P/rsLHDoX/6BJ AAYGcc4KzkFTi3BY8+XbTXXP/4FNdLVaPO4d5Rbg4qhdetNbL9a5v8hqwt8b7WDfRn+2 S9ZAJuThco4PTtBsAoicbfqOdtFXfGmRmRiZOkMLrWmt8zlZ4jn0xsoKVArOhoOHaefE sUzQ== X-Gm-Message-State: AOUpUlHB8NAMIhLjy4K4kwjE52wY92l0sGTiI9pTZf135v/SKdY89uGY oK0qs+6aETmpyyIIQ78F1Fk= X-Google-Smtp-Source: AAOMgpexACbEhSGbFleJ/AmDqCcZmqpB0OrVU1C+Wkbea9lyMagISJiGS8JhZxZpTicknFQfTUAJ1A== X-Received: by 2002:a19:4b90:: with SMTP id y138-v6mr1772416lfa.118.1531848023784; Tue, 17 Jul 2018 10:20:23 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id j9-v6sm250086ljh.40.2018.07.17.10.20.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 10:20:22 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Subject: [PATCH] ARM: OMAP1: ams-delta: assign MODEM IRQ from GPIO descriptor Date: Tue, 17 Jul 2018 19:20:56 +0200 Message-Id: <20180717172056.18472-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180717_102035_860170_16A94743 X-CRM114-Status: GOOD ( 16.27 ) 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: linux-omap@vger.kernel.org, Janusz Krzysztofik , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Aaro Koskinen 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 In ams_delta_modem_init(), replace request for hardcoded GPIO and assignment of related IRQ number to MODEM platform data with a check for that number having already been assigned. Then, from init_machine, request MODEM IRQ GPIO descriptor by its GPIO chip hardware pin number and assign related IRQ to the MODEM. 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 dd28d2614d7f..9c376ac31e25 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; }