Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp815299rdg; Wed, 11 Oct 2023 06:25:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKq4Dd7g4AlXtiTnKeTGvmgnBFoh7Z62Ic+x9ZxSLeeo7r0Gwx5fPFoF1K5Xqb1p350nZ7 X-Received: by 2002:a05:6358:885:b0:143:9075:6d9c with SMTP id m5-20020a056358088500b0014390756d9cmr21766506rwj.5.1697030734105; Wed, 11 Oct 2023 06:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697030734; cv=none; d=google.com; s=arc-20160816; b=Eq6XSN65Sh1BvS6a4Af01mdT8Z57DTVY35qrIQcIDDLtRRvFyWE8tStYGVxlfeSRLi hDh3AhCCffHvzNc3JbLGNx/5aVMPw4JhJZq76GroOLOqP1lmgFCMVGDaO9IO0p44ImHY 6EpcBe1t680ALdm0wtb14OTzlZ4KZDDkJVK/L5Y/bs/bVo+g4mg/zS8shULA6X5JjHQ1 EPn4+SUECNdmufX6zHs9tlEv1ze0VoYN4MV7j72h0EhJmv+bLyyEogGC1NtLIcD/Ijup E29EmjP9fjLZPCtCFuAKbGZ3pV5Ldpt92lW7DSXvEvQ926Dzo8+4B+QDEuusqzo4wvmU b7jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=Xqz8iFcZyZrkNGC4HnDkeYXGUWx3Py3eSb9ri6Nllj0=; fh=1i6b6fQBnaiq0xRa3ncF4yVLO4LQ/VVJhygl9h24PAo=; b=vhr/qZoADSLShvhLi19CwHT2qfwVbvaZCFGx9xmq5aHTk1EeXlsOE1o/2k23fRO9zg FOm4xmDN12G6fVJx2MhPUnGVTI50Mjk7kQEUzg8T6lD6197n5+8PIXB6meSIDbup9QEe 0zEkk0Ne9XdaNTtVSE1LYgf6bieTSsLY+JcfTaS2/tV1W77vfnMzAywHr7J7+Q/d1ZnW ADVfLtwPn1DeQkLZxERYGAJ5eBOn2KRLjLOw2I2EEpap72M96qt9KKDMDYndUyjxGGC/ Z+JADB1mnB2HnL1fQWL83m6140xDuGd8vjMh14A9tSL5MBEje9WqTV0MUy3bsL3JOopF EQ6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id t11-20020a056a0021cb00b00696f1c14972si12444224pfj.208.2023.10.11.06.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:25:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 238A58079314; Wed, 11 Oct 2023 06:25:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347022AbjJKNYa (ORCPT + 99 others); Wed, 11 Oct 2023 09:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234987AbjJKNYJ (ORCPT ); Wed, 11 Oct 2023 09:24:09 -0400 Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2263490; Wed, 11 Oct 2023 06:24:08 -0700 (PDT) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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_Mihanovi=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-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 11 Oct 2023 06:25:15 -0700 (PDT) X-Spam-Level: ** 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; -- 2.42.0