From patchwork Wed Oct 11 13:23:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Duje_Mihanovi=C4=87?= X-Patchwork-Id: 13417377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16731CD6E67 for ; Wed, 11 Oct 2023 13:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BZj4bTBfsBl+eI0azi5V1TFUCKruKHhp2vCJyIE7BPk=; b=SPi7LCzmQl8rbr fJvS3kI87VYvvsZyJqd7SbSv72oGhDr6mdCCo1JxrxlsHSizNo2CHn+bnfbqJQxSpAlR4BheXIfG5 fBF2GjMkD6pyOsjmZ9yxSFKb18UH6XIl++CY5jZOfEuqSN1Ci3kdPvymT4WQbVJ2Qmube50vEZYjq XaOeyMwwB8MQ4EK9N8l3/PFlAuWTNJZgLeBHQ5960LycMbSykHAV+NcyoCrdJMk4QE+XfNhUNImkk BcKRgqxvL6G5iCSgfcVs5DWIJNbSdicNhe7Nrxx/2kFm3xZO8/0wgxFvDyOtgkdgrxAS8xDSsVgr8 hFGx8dPNgxuiAb7h17JA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqZCB-00FxgO-00; Wed, 11 Oct 2023 13:24:15 +0000 Received: from mx1.hosting.skole.hr ([161.53.165.185] helo=mx.skole.hr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqZC7-00Fxen-1s for linux-arm-kernel@lists.infradead.org; Wed, 11 Oct 2023 13:24:13 +0000 Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id BB0B683D95; Wed, 11 Oct 2023 15:24:06 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Wed, 11 Oct 2023 15:23:48 +0200 Subject: [PATCH RFT v8 4/6] ARM: pxa: Convert reset driver to GPIO descriptors MIME-Version: 1.0 Message-Id: <20231011-pxa-gpio-v8-4-eed08a0fcac8@skole.hr> References: <20231011-pxa-gpio-v8-0-eed08a0fcac8@skole.hr> In-Reply-To: <20231011-pxa-gpio-v8-0-eed08a0fcac8@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Dmitry Torokhov , Mark Brown Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, linux-input@vger.kernel.org, linux-spi@vger.kernel.org, =?utf-8?q?Duje_Mih?= =?utf-8?q?anovi=C4=87?= , Bartosz Golaszewski X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3701; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=fiTAkhx/392g7RKt0TzxS8LYK9aSUcvD4v5HvOhokVU=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlJqHo5nattoNOlB3XygeTijL6yvVuXLvMIDa/N d0laJ14PBmJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZSah6AAKCRCaEZ6wQi2W 4RAVD/9/YTdtpNkyV48JiHRA1s3T8GEl85ehHNU+1KfUTmt0+fP38r/WTocoVPjJWIQ7cjyz9c5 WRagQSF/zGyTL8NfDUdiLAltJCFjYSlqb/yWCw6z/dICXYWS/8DxBs6MnOyzSEvFP+1BTClEXq2 5SfVGEdiJO+SIhG2eQfQF6NCmWQ3Y38KE6WxnwEqHrP8R+mBiSz/T8H9fy6e11wR1UgzVLXXSFe ELv9hgwo29yzgeNYSyfX32KaytGdmrCr2y99/3a0xS4dVSIVtePcCV64EKKQsz8RH+J6d8u+lxy QZC1iyU6jgH8h9gg2HqGr5h7olOGLC61VSAnzXSXTEIQdDvmFLwbMsFhlbbYCDe0CjVtx6Y23KQ edFl/syYKw7Fn68xPuKfZQxv3oH3WKcNRqKcKvskB2S7/U6LP3w4iFlQ+gOa1ouUnOWrjcOpNp8 rGLmgvgVMuerqfU98cB+QjP5/QCct8zeis6MhbMx/QimYx3yO8Alvf96R+C+V/BSM5aKkXTf/S9 ZIvcJiQ8SAu27lY3AqGy6hF6se5gIJyzE+ohAYwlYI/4sdjbKsNegTbQfnWvroS7ek59K+SLA/C 5zhVt358n4UAj5ON6OOFdOAKAu8OMO33MFQgvgGKJxMKNf6CglbjArkekZoo6Cov/XoFVpjz8RO yK6/mNCHyafi+Rw== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231011_062411_796162_D062F702 X-CRM114-Status: GOOD ( 15.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PXA reset driver still uses the legacy GPIO interface for configuring and asserting the reset pin. Convert it to use the GPIO descriptor interface. Acked-by: Linus Walleij Reviewed-by: Bartosz Golaszewski Signed-off-by: Duje Mihanović --- arch/arm/mach-pxa/reset.c | 39 +++++++++++++-------------------------- arch/arm/mach-pxa/reset.h | 3 +-- arch/arm/mach-pxa/spitz.c | 6 +++++- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c index 27293549f8ad..08bc104b9411 100644 --- a/arch/arm/mach-pxa/reset.c +++ b/arch/arm/mach-pxa/reset.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -14,33 +14,20 @@ static void do_hw_reset(void); -static int reset_gpio = -1; +static struct gpio_desc *reset_gpio; -int init_gpio_reset(int gpio, int output, int level) +int init_gpio_reset(int output, int level) { - int rc; - - rc = gpio_request(gpio, "reset generator"); - if (rc) { - printk(KERN_ERR "Can't request reset_gpio\n"); - goto out; + reset_gpio = gpiod_get(NULL, "reset", GPIOD_ASIS); + if (IS_ERR(reset_gpio)) { + pr_err("Can't request reset_gpio: %pe\n", reset_gpio); + return PTR_ERR(reset_gpio); } if (output) - rc = gpio_direction_output(gpio, level); + return gpiod_direction_output(reset_gpio, level); else - rc = gpio_direction_input(gpio); - if (rc) { - printk(KERN_ERR "Can't configure reset_gpio\n"); - gpio_free(gpio); - goto out; - } - -out: - if (!rc) - reset_gpio = gpio; - - return rc; + return gpiod_direction_input(reset_gpio); } /* @@ -50,16 +37,16 @@ int init_gpio_reset(int gpio, int output, int level) */ static void do_gpio_reset(void) { - BUG_ON(reset_gpio == -1); + BUG_ON(IS_ERR(reset_gpio)); /* drive it low */ - gpio_direction_output(reset_gpio, 0); + gpiod_direction_output(reset_gpio, 0); mdelay(2); /* rising edge or drive high */ - gpio_set_value(reset_gpio, 1); + gpiod_set_value(reset_gpio, 1); mdelay(2); /* falling edge */ - gpio_set_value(reset_gpio, 0); + gpiod_set_value(reset_gpio, 0); /* give it some time */ mdelay(10); diff --git a/arch/arm/mach-pxa/reset.h b/arch/arm/mach-pxa/reset.h index 963dd190bc13..5864f61a0e94 100644 --- a/arch/arm/mach-pxa/reset.h +++ b/arch/arm/mach-pxa/reset.h @@ -13,10 +13,9 @@ extern void pxa_register_wdt(unsigned int reset_status); /** * init_gpio_reset() - register GPIO as reset generator - * @gpio: gpio nr * @output: set gpio as output instead of input during normal work * @level: output level */ -extern int init_gpio_reset(int gpio, int output, int level); +extern int init_gpio_reset(int output, int level); #endif /* __ASM_ARCH_RESET_H */ diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index b72c2916426a..acb2b5495dbe 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -1020,9 +1020,13 @@ static void spitz_restart(enum reboot_mode mode, const char *cmd) spitz_poweroff(); } +GPIO_LOOKUP_SINGLE(spitz_reset_gpio_table, NULL, "pxa-gpio", + SPITZ_GPIO_ON_RESET, "reset", GPIO_ACTIVE_HIGH); + static void __init spitz_init(void) { - init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0); + gpiod_add_lookup_table(&spitz_reset_gpio_table); + init_gpio_reset(1, 0); pm_power_off = spitz_poweroff; PMCR = 0x00;