From patchwork Tue Sep 26 15:46:22 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: 13399320 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53E9266BA for ; Tue, 26 Sep 2023 15:46:38 +0000 (UTC) Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1FE10A; Tue, 26 Sep 2023 08:46:35 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 9C32382499; Tue, 26 Sep 2023 17:46:33 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Tue, 26 Sep 2023 17:46:22 +0200 Subject: [PATCH RFC v2 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pxa-gpio-v2-1-984464d165dd@skole.hr> References: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> In-Reply-To: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2753; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=aaS8kMiqneoLRyB8TsJKCzQAPSmGaArXhTx/CbQd1hc=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlEvzWJsUqoFqdA1T7iq2VCheOULkVgSFLrrG/m e2M+Wb3LHyJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRL81gAKCRCaEZ6wQi2W 4RxJD/sFrD6/5F+LgaAMPH2MsypLLSc4yCwc0ouSWJ88N8r+4JoWpaQ7xCK7arUZpleaLdqbAZG 5MOxg49C7aURLPXhtqzhK0GykyxjwqJ2wMpZNuutcZe6n7X4Z+gRvK4eCyLDUug9yMyr1DdJegr XWkEgjl8WKiPC733QJ9hlyMBG5M364V98rbaKrhjebdZ+XENSU+LrZGn/zGRPlBYmtWeWgG2qEt l5Pv3b5N5HSpeFWgkN/Yn3i7MrTKRXMlGpatolnsLay3xkSagiU98S4wMsOSsipeu1a3+BjmZ91 oGTJ9d+DVWg5OMmyDDIYfHeZRONX+PGtiXPsW37XmyNWYRYo8lWTU85BD+2uMZTtVTJ3hBlMctN 5Czzjcy5QOhJUfSXmfZ8bQwezseHYJjyBeUbRk4B6Zei21r1H078MO1VMiZOMa2vFm8UpykYNf2 3Ut4qas+NwCzvBxqGShT/8TWMbRHwLFzee2san42cbxPzCAW+EuKqH/HL8RBWs3xTQd7BGzYJ9T Ta6CU8U66uVX+c57N/gePPWjo3uy/Qe4N1SzFnzeAGxhorqIoZZKcXfc8nL+Tgee0Ezwzfnb+ha IFn/WSXxVtCgRp92KEYkNoWde4IQKoA9pu0gpaWf6katGueFjqz6J6kwXisQL2FRvPXPNGQ0zfG gZU19Lq3Sdvku1Q== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Sharp's Spitz board still uses the legacy GPIO interface for controlling a GPIO pin related to the USB host controller. Convert this function to use the new GPIO descriptor interface. Signed-off-by: Duje Mihanović --- arch/arm/mach-pxa/spitz.c | 13 ++++++------- drivers/usb/host/ohci-pxa27x.c | 7 +++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index cc691b199429..535e2b2e997b 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -649,23 +649,22 @@ static inline void spitz_mmc_init(void) {} * USB Host ******************************************************************************/ #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) +GPIO_LOOKUP_SINGLE(spitz_usb_host_gpio_table, "pxa27x-ohci", "gpio-pxa", + SPITZ_GPIO_USB_HOST, "usb-host", GPIO_ACTIVE_LOW); + static int spitz_ohci_init(struct device *dev) { - int err; - - err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST"); - if (err) - return err; + gpiod_add_lookup_table(&spitz_usb_host_gpio_table); /* Only Port 2 is connected, setup USB Port 2 Output Control Register */ UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; - return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1); + return 0; } static void spitz_ohci_exit(struct device *dev) { - gpio_free(SPITZ_GPIO_USB_HOST); + gpiod_remove_lookup_table(&spitz_usb_host_gpio_table); } static struct pxaohci_platform_data spitz_ohci_platform_data = { diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 357d9aee38a3..b70d452ca7c2 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -121,6 +121,7 @@ struct pxa27x_ohci { void __iomem *mmio_base; struct regulator *vbus[3]; bool vbus_enabled[3]; + struct gpio_desc *usb_host; }; #define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)(hcd_to_ohci(hcd)->priv) @@ -447,6 +448,10 @@ static int ohci_hcd_pxa27x_probe(struct platform_device *pdev) pxa_ohci = to_pxa27x_ohci(hcd); pxa_ohci->clk = usb_clk; pxa_ohci->mmio_base = (void __iomem *)hcd->regs; + pxa_ohci->usb_host = gpiod_get_optional(&pdev->dev, "usb-host", GPIOD_OUT_LOW); + if (IS_ERR(pxa_ohci->usb_host)) + dev_warn(&pdev->dev, "failed to get USB host GPIO with %pe\n", + pxa_ohci->usb_host); for (i = 0; i < 3; ++i) { char name[6]; @@ -512,6 +517,8 @@ static void ohci_hcd_pxa27x_remove(struct platform_device *pdev) for (i = 0; i < 3; ++i) pxa27x_ohci_set_vbus_power(pxa_ohci, i, false); + gpiod_put(pxa_ohci->usb_host); + usb_put_hcd(hcd); } From patchwork Tue Sep 26 15:46:23 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: 13399323 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B789D30CFE for ; Tue, 26 Sep 2023 15:46:48 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6A9110A; Tue, 26 Sep 2023 08:46:46 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 2DF96836CB; Tue, 26 Sep 2023 17:46:34 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Tue, 26 Sep 2023 17:46:23 +0200 Subject: [PATCH RFC v2 2/6] ARM: pxa: Convert Spitz LEDs to GPIO descriptors Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pxa-gpio-v2-2-984464d165dd@skole.hr> References: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> In-Reply-To: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1768; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=02fLXHNo6SZtYq4sldyjzMDb6JVfWPhjgCG5UTkdTdY=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlEvzW18VE2EpVyIF0E+Le+lT4YztgGaTeIG9e5 XYpdqeQTKKJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRL81gAKCRCaEZ6wQi2W 4eyzD/4xj3nCTSW4fc2jM0QoHwNCTTdpBf+wYw23yFkTfriAQuKwDb+yf+S/7VnH9+nPUllfkE2 aR3bYa66FDYKIjn96yijEv76WCzw7WnOPanQmSeM/9zWQqVroR+S0+jFXVfygRmTeW9bxusuy/v 3AWGOz8EWBP8etp2pcvDUHTseRNZNiD2lsKEcWPyRVfs8xn+UtgejBQUVNHIVdhO5do4rA+KK9b uZUg+SfbcvrEHqLgAUY+Jfp35wNCIP8qQIhsqVAqMpQYZt32sRvfL7uY+bf1qO7vrqFQKrp++4A M508QZlkki3Wp2t69uKNiXKMxdNWSt220cHv/pLKOqGbg+bcL4Hg6Ry+EODxN0Wxz6qnTxgd+jg QTPcymSR5N2xjJCDLLsEq9J/asHAZ0C0YQDascD+Z4Ze8qqZbG317GzNvKOhIcCL2FEm1KMpEFP l4NZV/skn71OwWOc7Fs9iYCwXjCS0CFl232XWzYCmQOfSRQk6npNPFaRboP0k9BF6NpLKDwBBc0 rRemoKn9Ld/zFuR5hA/C24fYmXAjik4/nDQCXOJvFA49vza08zZs+BWr8ss3E1E5plOv5y/ZYp1 2+hblsfHVEeLXdnopzs1F3PPhGjkgw4vFH/TXeIRpLZkkkGO4UiY3JIam0SH4rkZKHMuGyuafhH /WVNz3KWoyMz54w== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Sharp's Spitz board still uses the legacy GPIO interface for configuring its two onboard LEDs. Convert them to use the GPIO descriptor interface. Signed-off-by: Duje Mihanović --- arch/arm/mach-pxa/spitz.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 535e2b2e997b..91c4b208973c 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -452,16 +452,25 @@ static inline void spitz_keys_init(void) {} * LEDs ******************************************************************************/ #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) +static struct gpiod_lookup_table spitz_led_gpio_table = { + .dev_id = "leds-gpio", + .table = { + GPIO_LOOKUP("pxa-gpio", SPITZ_GPIO_LED_ORANGE, "led_orange", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("pxa-gpio", SPITZ_GPIO_LED_GREEN, "led_green", + GPIO_ACTIVE_HIGH), + { } + } +}; + static struct gpio_led spitz_gpio_leds[] = { { .name = "spitz:amber:charge", .default_trigger = "sharpsl-charge", - .gpio = SPITZ_GPIO_LED_ORANGE, }, { .name = "spitz:green:hddactivity", .default_trigger = "disk-activity", - .gpio = SPITZ_GPIO_LED_GREEN, }, }; @@ -480,6 +489,11 @@ static struct platform_device spitz_led_device = { static void __init spitz_leds_init(void) { + gpiod_add_lookup_table(&spitz_led_gpio_table); + spitz_gpio_leds[0].gpiod = gpiod_get(&spitz_led_device.dev, + "led_orange", GPIOD_ASIS); + spitz_gpio_leds[1].gpiod = gpiod_get(&spitz_led_device.dev, + "led_green", GPIOD_ASIS); platform_device_register(&spitz_led_device); } #else From patchwork Tue Sep 26 15:46:24 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: 13399321 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98E630CFC for ; Tue, 26 Sep 2023 15:46:38 +0000 (UTC) Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E31A116; Tue, 26 Sep 2023 08:46:36 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id CFA5882471; Tue, 26 Sep 2023 17:46:34 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Tue, 26 Sep 2023 17:46:24 +0200 Subject: [PATCH RFC v2 3/6] ARM: pxa: Convert Spitz CF power control to GPIO descriptors Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pxa-gpio-v2-3-984464d165dd@skole.hr> References: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> In-Reply-To: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2162; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=fHl5iSb/dE+9PwQC8nVVOcMrGaHAC690mEvxtdZMvYU=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlEvzW8p1SpO/LVrhZ4cyOyEsmfBY+BbA8HF5w/ xIAZC61EYWJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRL81gAKCRCaEZ6wQi2W 4Qp5EACNKOhea/Gu/9RKXqniM2l/1tXSAoQTFENWZpL9pxI0tf3YtwigVQvliPGZq5KmhzQ+z82 McRgQkT6ukcEX0V+Vb5DGaiVN+qE+uvEysd/IG1M5GGusAxMLT2yZMtM281IqYvqRSCFcdM96/E rU7mOkk+rtu0kMnKmhXPMhz5jVckiElNbR6c8HX/Hc2ltYfme0TGyxKOsN3CqX3kecym4dja33z yVBWV/2oG56ilZmSSU4QaMRWPi8AA4XrIWQXIyR0dDVGLg3eNHy0zZedGOJPdx4SGOv7Y4wqVw5 /X39MMtb+E75HdxE2SI9eLKDQuubS+SH6H6ytHRBXbKmgIwZPr3cfrQQvfi6+KSxJG6xS2R6brN O0xgsNpY7rjDtuUeAkykVQMr2UAVhz9E98F+P7OXXE/vkl6qpXNfIkxxeKyZaapFrGQaSHTd5DP 44tJSB2LYdaERlJtVSHruMuE04/d1wURuWCZEPEKOozOgIV1Q/qbsX7K+F4Gohti58ytq9eqMw0 czpViWocbw/9nMPfcMe8lstBxgOI0e71Sq82YgqBquZBUrR8YCcSTRhT/sX1YosGVb2sapfs12f iG5YKpHHuEFLuBmrVOO+s5uhCBxeEF222jrY/qvYXZYafLeoUEcEeIEgQ3q9bEGeKz6pc9k8w1u epzqgGNVa7PFBcw== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Sharp's Spitz board still uses the legacy GPIO interface for controlling the power supply to its CF and SD card slots. Convert it to use the GPIO descriptor interface. Signed-off-by: Duje Mihanović Acked-by: Linus Walleij --- arch/arm/mach-pxa/spitz.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 91c4b208973c..616305978727 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -133,6 +133,10 @@ static unsigned long spitz_pin_config[] __initdata = { * Scoop GPIO expander ******************************************************************************/ #if defined(CONFIG_SHARP_SCOOP) || defined(CONFIG_SHARP_SCOOP_MODULE) +GPIO_LOOKUP_SINGLE(spitz_card_pwr_ctrl_gpio_table, "pxa2xx-mci.0", + "sharp-scoop", SPITZ_GPIO_CF_POWER, "cf_power", + GPIO_ACTIVE_HIGH); + /* SCOOP Device #1 */ static struct resource spitz_scoop_1_resources[] = { [0] = { @@ -190,6 +194,7 @@ struct platform_device spitz_scoop_2_device = { static void __init spitz_scoop_init(void) { platform_device_register(&spitz_scoop_1_device); + gpiod_add_lookup_table(&spitz_card_pwr_ctrl_gpio_table); /* Akita doesn't have the second SCOOP chip */ if (!machine_is_akita()) @@ -201,9 +206,18 @@ static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) { unsigned short cpr; unsigned long flags; + struct gpio_desc *cf_power; + + cf_power = gpiod_get(&pxa_device_mci.dev, "cf_power", GPIOD_ASIS); + if (IS_ERR(cf_power)) { + dev_err(&pxa_device_mci.dev, + "failed to get power control GPIO with %ld\n", + PTR_ERR(cf_power)); + return; + } if (new_cpr & 0x7) { - gpio_set_value(SPITZ_GPIO_CF_POWER, 1); + gpiod_direction_output(cf_power, 1); mdelay(5); } @@ -222,8 +236,10 @@ static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) if (!(cpr & 0x7)) { mdelay(1); - gpio_set_value(SPITZ_GPIO_CF_POWER, 0); + gpiod_direction_output(cf_power, 0); } + + gpiod_put(cf_power); } #else From patchwork Tue Sep 26 15:46:25 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: 13399322 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C49830CFB for ; Tue, 26 Sep 2023 15:46:48 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A624FEB; Tue, 26 Sep 2023 08:46:46 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 792648369A; Tue, 26 Sep 2023 17:46:35 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Tue, 26 Sep 2023 17:46:25 +0200 Subject: [PATCH RFC v2 4/6] ARM: pxa: Convert reset driver to GPIO descriptors Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pxa-gpio-v2-4-984464d165dd@skole.hr> References: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> In-Reply-To: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3609; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=AHxB1OpKYRVa4xCGIARryQkz4h6Z/eDJMO/mv2k3OZ4=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlEvzWugFrB9Kmuw2EXyDUX+5J0fCtKGeWNbwrK yhkhbWRbbeJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRL81gAKCRCaEZ6wQi2W 4ZIGD/9xGXp2+i77FgWrIAnEBuV5D7waxV2SRys2Wd+2gaWNjopdSV19fiXlAbTJs/UjxWlglUI tHMutzwABC/prGL/EgSDTUJZCaGAeX/q65mpqB9HXTmEJ3RjvSTbyzeJ6ijvFShHNP4t+eJ6I+y okcrEWlmO/FHVU6GCemaDpkVJq1On7bqfichD5ZUfqV2MhzbixPGWbww7sBXkDn27LPokR2osmY HaTFQuFS1RfbPn7tjVLATZWT1sDhXMH2+TaBp1hE1XJdJgPnR5ytNz0XXdvLLNWeL0bkUFgSMhX /9Z29jfTOy2IkJbGsFtTYexL+ZThMr9wn44RESUTwAsK4SP/9GnVcy5XD8Sv1wvXsEH1oEidcAn ATb9RM1zOARe8fUxaWkzBEFBvPajb8y2JeN8ry1MZb0TVAHFzsXjkoTdVWqJgPjvVENTpsbJTIV CZqUKi8pj7Kv03pVEb3dAyE3hS3jkapsK2qMQV/RD2NXjAajC0tvtkiI7KEpcNyHtUYgkuL8eLs g65eoa+1q9SCely42M15FEU2uaeuIc/zbTSRbB2ksWZGe6AUsZF9sjYCdea+z8d1G48FUBzrnaV taUfpTEgtMAe/iirDKfkVsdY8RcFX/PwhniZH5jpHKhuzEqtkXlFR7uruUieM1NU+1cAwMyNYxO DvORHCX3/s+nQLw== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. Signed-off-by: Duje Mihanović Acked-by: Linus Walleij --- 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..dfcd6c45398d 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 = NULL; -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 generator", 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 616305978727..94bcb187713b 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -1024,9 +1024,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 generator", 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; From patchwork Tue Sep 26 15:46:26 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: 13399319 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6F6B30CFB for ; Tue, 26 Sep 2023 15:46:38 +0000 (UTC) Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CB5C11F; Tue, 26 Sep 2023 08:46:37 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id E0EC982367; Tue, 26 Sep 2023 17:46:35 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Tue, 26 Sep 2023 17:46:26 +0200 Subject: [PATCH RFC v2 5/6] ARM: pxa: Convert Spitz hsync to GPIO descriptors Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pxa-gpio-v2-5-984464d165dd@skole.hr> References: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> In-Reply-To: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1744; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=iDSRsRvbtFOxQFJcaMgRFqBD4OPrnaTiwiEd2g9ViUU=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlEvzWvKOK8Jgrv8cV8mXpPyIo+QydjhrRFeCDN +7WkkTkiXqJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRL81gAKCRCaEZ6wQi2W 4dpyEAChUkA0UQoq4DsrWVZ3WmVhlrOJNsEfCtKC4QnJLAgF/mpUu2DRVgIUDwTq89eEU2+m1/l VTF7nmWilyWNZeqaeGMRvQ9XGkoG9Iah2fCtL2JWAZbY29qdilEli4/YFWpiQOl5TN/ePfsG5dl WugaqopM4eIQtgaG17n9x0VC9M/M4AxD9jaMIsAbzanPKnY8RMIn9956lBz92kK13KVgdFuTX5J uZUbTQbgpUeP4DKJIkQ61DJkwcgN0l4RO3e/SYdzS5/dk0lZN7IYgLCCwHLo/mepyYDOKmBzUOi j/FtoDl0A/bephgd6M6hjovOLLuSyHZVqnuPeYz+Z61vHJ+UB3Lk5OKl5U/PTSR9ueCXwgn0TTx HDTp9qwvO7ivldg/O4zNqYRvBks8DB+Jr7fbVoDuIVJ2qtqlFrCN82bNeMGcfNphPkQXg/9Pe73 /HrRyqe0+Q5/C1xK8/eSSuoZXYF13r/LkbVL1Yle33DX4C/3VtIjoEpxCZG5f89q28WXDpHHze4 suYScWGXap094Jf0ekO8XPUUHAF1fhcYue840XzrC0hJGiSGz3n7fdWz15F+jd4cTbp9maM0EOx PmRpAM8+Pj/d8Pv2r6meeoA6i6LihaiAqFPPncuOAwJRnZseMNvRLKUCGM2foux/FmXeU/eVMhy psZq92FP0XzOeCQ== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Sharp's Spitz still uses the legacy GPIO interface in its wait_for_hsync() function. Convert it to use the GPIO descriptor interface. Signed-off-by: Duje Mihanović --- arch/arm/mach-pxa/spitz.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 94bcb187713b..5c8f497b71ec 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -520,12 +520,14 @@ static inline void spitz_leds_init(void) {} * SSP Devices ******************************************************************************/ #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) +static struct gpio_desc *hsync = NULL; + static void spitz_ads7846_wait_for_hsync(void) { - while (gpio_get_value(SPITZ_GPIO_HSYNC)) + while (gpiod_get_value(hsync)) cpu_relax(); - while (!gpio_get_value(SPITZ_GPIO_HSYNC)) + while (!gpiod_get_value(hsync)) cpu_relax(); } @@ -543,6 +545,8 @@ static struct gpiod_lookup_table spitz_ads7846_gpio_table = { .table = { GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT, "pendown", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_HSYNC, + "hsync", GPIO_ACTIVE_LOW), { } }, }; @@ -622,6 +626,11 @@ static void __init spitz_spi_init(void) gpiod_add_lookup_table(&spitz_ads7846_gpio_table); gpiod_add_lookup_table(&spitz_spi_gpio_table); + hsync = gpiod_get(NULL, "hsync", GPIOD_IN); + if (IS_ERR(hsync)) { + pr_err("Failed to get hsync GPIO: %ld\n", PTR_ERR(hsync)); + return; + } pxa2xx_set_spi_info(2, &spitz_spi_info); spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); } From patchwork Tue Sep 26 15:46:27 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: 13399324 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EB5C30CFF for ; Tue, 26 Sep 2023 15:46:49 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B15126; Tue, 26 Sep 2023 08:46:46 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 7BABD836FC; Tue, 26 Sep 2023 17:46:36 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Tue, 26 Sep 2023 17:46:27 +0200 Subject: [PATCH RFC v2 6/6] ARM: pxa: Convert gumstix Bluetooth to GPIO descriptors Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pxa-gpio-v2-6-984464d165dd@skole.hr> References: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> In-Reply-To: <20230926-pxa-gpio-v2-0-984464d165dd@skole.hr> To: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, =?utf-8?q?Duje_Miha?= =?utf-8?q?novi=C4=87?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2065; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=H9m5GKPOjDqHvnoQunanjp8s8qAFx4LJD9KoCMZ/UEw=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlEvzXcuEUSDa/D4G1iSz3FE96zRXUsszhKfvO/ cfAj0gBIZWJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRL81wAKCRCaEZ6wQi2W 4T5tD/9Sqn/4LVKN8ztfsrZ5hkncZIFXvDxSfs5cOa2nTPv38vr826JczlpZafwRDsS8+m5RD6M pzXm4nww5abZCdDcJTjAOyh+G2Jr0Sukz/NUu3780UqtwoQ+Jdw62DMHDR1a+C5mLROhhpiwF4u 5ZbYAok22ye3Bu4GCTkJYXO88pqUbQz+/7fE/hDRVubiGxgTkkctd7zspd/yc3a9FFGMfqvASoB ZkPrDWyeQLAk8kjERXayQ1lXmkwkCf0XfecgtURaxZ8W9XAkLgZD1hLKoJJE06Ef9P0AlqBKzv/ boRgyucdS8SOG3tyvZa8ZYBNlIp1clSVAAh0yYrxjWluTWIZVVtcPkr3qpPXd1DdZqgvxZKlq4s AWNWUgDIN6KblADH5NVyy7tL+Pt3AtDKM/h75b03cnvrD7r33DG0oymTR4zDJ7WaZMs2mp7eNc1 BuY0jk+gbzDrZf3a355NboaHrrr5LgKV9XVWicQ/Ru/EWi27TIuEn+4chKdAq6v9RAXzREL64EX FKevE9Kkoj2eLNkT/yXAWz7AP7op8fVP/KkyvlG84Fvyn9quSOuYkYclYvzCpj/LljmKvywccGa HL9Oyy5lEqU5oCMNzgE+K+B49J7FNd8aE61WT87uPQWJlpxA5NciewsTw/5M4+83IvI9dcQmUdl oVVYhEoJPJdNUFA== X-Developer-Key: i=duje.mihanovic@skole.hr; a=openpgp; fpr=53DF9D4D9C3FE110FB362D789A119EB0422D96E1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Gumstix still uses the legacy GPIO interface for resetting the Bluetooth device. Convert it to use the GPIO descriptor interface. Signed-off-by: Duje Mihanović --- arch/arm/mach-pxa/gumstix.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c index c9f0f62187bd..14e1b9274d7a 100644 --- a/arch/arm/mach-pxa/gumstix.c +++ b/arch/arm/mach-pxa/gumstix.c @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #include #include @@ -129,6 +129,9 @@ static void gumstix_udc_init(void) #endif #ifdef CONFIG_BT +GPIO_LOOKUP_SINGLE(gumstix_bt_gpio_table, "pxa2xx-uart.1", "pxa-gpio", + GPIO_GUMSTIX_BTRESET, "BTRST", GPIO_ACTIVE_LOW); + /* Normally, the bootloader would have enabled this 32kHz clock but many ** boards still have u-boot 1.1.4 so we check if it has been turned on and ** if not, we turn it on with a warning message. */ @@ -153,24 +156,23 @@ static void gumstix_setup_bt_clock(void) static void __init gumstix_bluetooth_init(void) { - int err; + struct gpio_desc *desc; + + gpiod_add_lookup_table(&gumstix_bt_gpio_table); gumstix_setup_bt_clock(); - err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST"); - if (err) { + desc = gpiod_get(&pxa_device_btuart.dev, "BTRST", GPIOD_OUT_HIGH); + if (IS_ERR(desc)) { pr_err("gumstix: failed request gpio for bluetooth reset\n"); return; } - err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1); - if (err) { - pr_err("gumstix: can't reset bluetooth\n"); - return; - } - gpio_set_value(GPIO_GUMSTIX_BTRESET, 0); + gpiod_set_value(desc, 0); udelay(100); - gpio_set_value(GPIO_GUMSTIX_BTRESET, 1); + gpiod_set_value(desc, 1); + + gpiod_put(desc); } #else static void gumstix_bluetooth_init(void)