From patchwork Fri Sep 29 13:13:59 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: 13404236 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 39FC81A58F for ; Fri, 29 Sep 2023 13:15:11 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE7731B0; Fri, 29 Sep 2023 06:15:09 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 2BB078475B; Fri, 29 Sep 2023 15:15:07 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 29 Sep 2023 15:13:59 +0200 Subject: [PATCH RFC v3 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: <20230929-pxa-gpio-v3-1-af8d5e5d1f34@skole.hr> References: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@skole.hr> In-Reply-To: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@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/ZANAwAIAZoRnrBCLZbhAcsmYgBlFs3Xj5wQjN90ornCql3PBgX73OCYrRwlY64sA JgAdNDzRkSJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRbN1wAKCRCaEZ6wQi2W 4UCQD/9PeMpCFeB3z6+1NqdH4dYyQyrN7iGz1UNh3982GFr/W2vEZcum/j1/2eikIo5UNE3MA8S hA6SwiXEHkjc7e5tW2dueGqGLnk5W3jOXYfbuanl+AQj0rqq90b3wyxJIO7kwO6q2kqtFILq2Te hbJz0Q7B4prkPxoBx40cIrJpCpVFkA2cHHNpkqvRfQbVecWzJWqyeHYZ07KSYhF9ubOUZW67DH4 aFmftqZdmXEMeFlXO/ZkGHDxvS5BZ/BE3GVX50wJOab2EK67gAkWIrD+QFPcb1vU5uHCpMX57mX towbsYYAldZC6i7kvGjr0hdoacTS9WbjL76T2t+Cx8l6Oo89mSxocx9bgreaYu9jRP09EL1SmL5 Vjr/HFlI4dsZcl4NO2bCCGc1ZaYBpNn+N2nZ/SklIgNwBBoVFFgiwzQscDb+qnDMFeyo+BcPpAl 1ysir8KsDuST0M+ZfdxfiMn3gr6351+eCH+Bve2l0PIMOSNnYcZEgNpc3n0iI4ijv2iIu23idR3 A9v6lgtLAzRhof0N6w6QaDJr36MsxTd1c7Zm0HhlYCG3+zWYg1gDJYNp7DZOmfrwRsnJzFTGCkK aybLXf6zA/HHILGjioAT21ZdFL5HAV8nCQi3n2idvtVAysqFV7hZfnSKKDwRrJZh4I0EPDwT2ZI Li5nsUHMgv8UH+A== 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ć Reviewed-by: Linus Walleij --- 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 Fri Sep 29 13:14:00 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: 13404237 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 419ED1A593 for ; Fri, 29 Sep 2023 13:15:13 +0000 (UTC) Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE8611AE; Fri, 29 Sep 2023 06:15:09 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 1860A8347F; Fri, 29 Sep 2023 15:15:07 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 29 Sep 2023 15:14:00 +0200 Subject: [PATCH RFC v3 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: <20230929-pxa-gpio-v3-2-af8d5e5d1f34@skole.hr> References: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@skole.hr> In-Reply-To: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@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=1770; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=YWNiyCxNsU8MmTyH6WiBM69WsGVSRGwp1wU7bY9Kw6M=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlFs3X304DDyKC0uR3vS5VnlJD0Kr4pUR83cnSQ +onNw+6IouJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRbN1wAKCRCaEZ6wQi2W 4cz7D/9dlWMHeVtBJISPMPBb2V0Fewc86D8PHtoymudyxNY/zXJorP8gXwAeLzFO5Wq98rmVydH JoJK5cRb80YmAYzv2bpZgngOTq35c0C9NsMMRHADjSdGJRuK2533R9i8vUkeAUnyMPD9FGWagpm b3iAMl5681X2j4N+ViX3U7yiFixVGh0nZ+vIlwr496uZnzORKwmyYHxtlmZQwhKSFeJw206QBny wp1LdI9yrKxUL1WG8Tm2hThodNRRetvVwpPJty3Ws0XrbeeKhKlre3tpES+9ZCSmRSMn3FZT/F1 IPRcKg21Dya5uVmHGy1zMI6LuXgoP/SAJFmwByIQKnX7UMXm4NAQEhsXRdCYJFOHhk9yMwYGkW7 R92Qo+TwviwPxdRrIf3KrUSWcr5BeoE2uQCakkb7y1scyQ1Jdm4yvrgVd/A7tiNMa7n/j9P4uU4 n/wKY3RQbFC3qwQPhZcmc0PGJRUSNBtMBIzY3wzHP4639HvE+sFfDMb8/Eedp+wrhkZndOvTVLd 6k8TGYR5k8OwX5YbVr+fnpp/ldpv/7bwwxeRFVMm2359yd1ycnhtnT5O6//qWw4Tg9EbOXysQdg qcbhwoIrhwWH/+xaIxvRyWdfNUKAK/8DSQG06tv0gtDgnT+D3zVMUP6EwEgzxiDvo4NLgqAULXO Ph/GeU0YokOlDVA== 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..6aa4a3a9f7aa 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_IDX("pxa-gpio", SPITZ_GPIO_LED_ORANGE, NULL, 0, + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("pxa-gpio", SPITZ_GPIO_LED_GREEN, NULL, 1, + 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_index(&spitz_led_device.dev, + NULL, 0, GPIOD_ASIS); + spitz_gpio_leds[1].gpiod = gpiod_get_index(&spitz_led_device.dev, + NULL, 1, GPIOD_ASIS); platform_device_register(&spitz_led_device); } #else From patchwork Fri Sep 29 13:14:01 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: 13404238 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 80E3D1A595 for ; Fri, 29 Sep 2023 13:15:13 +0000 (UTC) Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB58E7; Fri, 29 Sep 2023 06:15:09 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 492B1826A9; Fri, 29 Sep 2023 15:15:08 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 29 Sep 2023 15:14:01 +0200 Subject: [PATCH RFC v3 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: <20230929-pxa-gpio-v3-3-af8d5e5d1f34@skole.hr> References: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@skole.hr> In-Reply-To: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@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=2214; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=Rp/bq67hwkJJrBFGSoz+RTRGHfxFwf+Ynos1++JoSzg=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlFs3XkJZo5x8yVshrw8dgNQ73fJfXKc5u2vtEQ b9DqcIs3TqJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRbN1wAKCRCaEZ6wQi2W 4SHMD/9SnS+b2n0HYmaURspdYBfZY0j5eU5q7O8YCa5odWKNnYkAhJnUOU9fEHGepGyxeFJodV9 6k1wC23nZqV74NSLMaBU2dSfKz7dSMQxeN29EKCulYyvAIeXwiNNBshzbcbonFCXuYDvwrZHnxt MIkn/C4uvAow2GPLhFvkJO81vgfJ1iuXKLz7Vr5QisLmyV+Ru3jyal98sttQe2Cadho6ESF+0Ta jFnPLa/5iFVUnU28pcPzmwRrOmI4bh8M90YGIpVC2jgCzbJBL5Rh0BtgHv0m3I3pH0xi5p1PqJs o3TsIhXrAmeRY1qkEVBJ4JcXq9yFI2nVdZE22bIMXySmvCdK5iVy+wM5Zaf0Qmr9Frb4N0XEt5b /w0mOHsvokEnDKYQc6rHvDiCBbrgLnsCpJJWnZurPCuQadwuAEXrWz4iyHekOa7bHYnWH1WXfwy Zeb5qmHuoOqYdfS4FpHTwgfh5sdU0GMwx31v6wOJY8SfofwHrGtWd8S2ygAcxtR5l9V02Pc7I39 Wt9rmhPLKbyqEJ18+MGtyfIvNstZI/Fe2+N/nlBrvT7ljCp5cEYU2kfkCllmdj4BLEWciwN64AM jrlxb8ZtJ9KfHOzDeuR4nhdexEfeii1tf1slQ9jiYfXnCmbd0trF1iH/d6AJCy3cifB4j0H/EtE iCcsrH6q+rrMUHQ== 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. Acked-by: Linus Walleij Signed-off-by: Duje Mihanović --- 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 6aa4a3a9f7aa..59a4a439e3d2 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 Fri Sep 29 13:14:02 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: 13404241 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 9DE6D1A59A for ; Fri, 29 Sep 2023 13:15:14 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4931F1B4; Fri, 29 Sep 2023 06:15:10 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id D4E488475E; Fri, 29 Sep 2023 15:15:08 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 29 Sep 2023 15:14:02 +0200 Subject: [PATCH RFC v3 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: <20230929-pxa-gpio-v3-4-af8d5e5d1f34@skole.hr> References: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@skole.hr> In-Reply-To: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@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=3654; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=P+Mn+7rnZeSrsHrXwwh73RzIYGjBVvhAgESHp6DzA+A=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlFs3XoAQyb355PIO8PgTe7++rLbalmrVzqHDm8 mkrj5qE87mJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRbN1wAKCRCaEZ6wQi2W 4aqND/9rFsjp6O60B7TMyvYW6Tf2lAPf1RU4Ns043Xeko6Ire3TxG6VnLRVZ4M+TIDLJkvZmvk/ 926OKxCZ3BLSmgvIb5tgXY8eNv8KEARMBPUW1+688Mpg6ffqBqa+P9NFcu66P2jiaaPno6hAdrp 3SqxsXMp9WIL50+5eNx00ZglLGkPcX8sedQEV+YzInL7+SyQGTL1DfArAy1dZBfD0At9r9XBn/Q VJw/EKPPCYaulj49PCHy+h6uz8qBjbb2uTX8u8oioFoFGezNBsc4XiQWzI90EO7Bmnq2phjfvS0 MpwcXb40eS6VqudVDrYWAF7DMuvQdCe5QowJDBnoi/1r4dohgCSyfgv2EjQK8YiI/WP4io4d/s7 NfsY2Cc5E17y0G5e+57ssJjUOUbF3qtyOHNkTGV+2P/jalpxgC0kLhMBM5zYoNXcx3wg4UAkQRV aSrZWMj5lq5RCDrt5rJhjN5J1v+PAke1M4V7J24u5AvEZlVB00Zlh4fNnRu8jADD+9qOk/fSBmo Exw41SSrTaEY2ZXu6Wl6QQqM8fxKipD+rY08k8Q3rr1pNoNR++7WjzGJcXBpZo6mqQlj1rt6njn BmNDzJ2SJz+HZIHuRDQPYKqFPJrQlJXKE4IXoTn1t+YmbmLFoph3MCI34nOwJ473qXYAWvWdvgf DwIMd8Zp/VxVRNg== 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. Acked-by: Linus Walleij 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..2bfa66f99555 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 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 59a4a439e3d2..c789eeaf3c2c 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 Fri Sep 29 13:14:03 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: 13404239 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 E950C1A5A5 for ; Fri, 29 Sep 2023 13:15:14 +0000 (UTC) Received: from mx.skole.hr (mx1.hosting.skole.hr [161.53.165.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75861B5; Fri, 29 Sep 2023 06:15:11 -0700 (PDT) Received: from mx1.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 53D598348A; Fri, 29 Sep 2023 15:15:10 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 29 Sep 2023 15:14:03 +0200 Subject: [PATCH RFC v3 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: <20230929-pxa-gpio-v3-5-af8d5e5d1f34@skole.hr> References: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@skole.hr> In-Reply-To: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@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=1917; i=duje.mihanovic@skole.hr; h=from:subject:message-id; bh=NMVwZ6uSKQb1sBoOjO7it3qE3OIABseOJrIHnJKgy24=; b=owEBbQKS/ZANAwAIAZoRnrBCLZbhAcsmYgBlFs3X897QJzOUWADVn5rHWt6cyl1VYEt1hVHDp jUFeQYRlyKJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRbN1wAKCRCaEZ6wQi2W 4U8uD/9dFJ8dmhfP4EqRksHodrWdwnA2hLySE6WMagwcZgKqbDHUExpZh9hpG8UlqtnKk61Iqa+ wVNRXlqd6xeO/UoF87brssvsOQupZKjaftwsXqlHWkBUxVgDXo894Jqp5yXNyxqORU8em15lrnB wD1t4c+0MGHjKhQP2yeAFPfk57Vaxov0ATbotwG7dNswh/1EgXikHgVRebJuX7C1Bd5095ZHSou v9EV1HvdewXVQMyYgcxBn6yFG3Pr9huhfDn+IGvncSbIMGNDGHQkJ8NrrhfdjO7SVHUCKhr26Oe wBQ/ZUxQ5Oa+abZLWExcTErbXBGUJlI8CgkJfO5CBR8wrQaGLbp6OatL47Ke3mbjrCY7foDYbcG Z//oz8734x17BEFvPJ3Q9BknHg++5Dycc5pVBcyCvLxiBAAAndKo7Sr5jYLLthSUwCcpnla6j1F CmnN8eQPe7+Fi5Ar4qDBRRkhElu0eM6aBOknoOZo4UVprmfE7yoTEHyD8Vyfs37Pfs7cc26lxyh U+dTdCxBuGgwz8a7JfZDhLqg4VpNhRiLSLZ8CVPHJTpU7z1k33Rs1B9eBLm3ojkUttKDZAgnrmi 5B48oJVIVxT+DhOoJRw5zreFKBcW6p36IrJ4ZFflX6Z559CSq4LQbrTTDbvDOU3sveo9bG1j2v4 A1TciqL+9UD/g5w== 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 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index c789eeaf3c2c..25878daec986 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; + 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,8 +626,13 @@ 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); pxa2xx_set_spi_info(2, &spitz_spi_info); - spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); + if (IS_ERR(hsync)) { + pr_err("Failed to get hsync GPIO: %ld\n", PTR_ERR(hsync)); + spi_register_board_info(ARRAY_AND_SIZE(&spitz_spi_devices[1])); + } else + spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); } #else static inline void spitz_spi_init(void) {} From patchwork Fri Sep 29 13:14:04 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: 13404240 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 7ED291A594 for ; Fri, 29 Sep 2023 13:15:13 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05EBA1AB; Fri, 29 Sep 2023 06:15:10 -0700 (PDT) Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 71C4A84758; Fri, 29 Sep 2023 15:15:09 +0200 (CEST) From: =?utf-8?q?Duje_Mihanovi=C4=87?= Date: Fri, 29 Sep 2023 15:14:04 +0200 Subject: [PATCH RFC v3 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: <20230929-pxa-gpio-v3-6-af8d5e5d1f34@skole.hr> References: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@skole.hr> In-Reply-To: <20230929-pxa-gpio-v3-0-af8d5e5d1f34@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/ZANAwAIAZoRnrBCLZbhAcsmYgBlFs3XQsYnvxMh8SEOdWIMlFI/gwqsQo1oFMAKm lHd2NusZbuJAjMEAAEIAB0WIQRT351NnD/hEPs2LXiaEZ6wQi2W4QUCZRbN1wAKCRCaEZ6wQi2W 4bA8EACR7xGZJhaqRGnqJIgWVrBgsRruhMzrzu0NpPcugh54aroe6yB2w3nU0wXPpA10Gdfcrey 1a15ODiJtApvmlnEhX3FfH/ifnmsM1vf2lNV1icIZUi0ytId2w6YSJxZegXEs0lLWecCcXZHli/ z5PlZp/ln3AwtJs5oRseXF0s0GiPDFnZcBKtMluMRV2vTogjJEE8opuw2Upb8e50snjsPw/BaLY wKzWq+ICN8a0dEbFvPVQLZX6NVsW2AjdYbszt98XeQoPIapJuOMgbfzxJ9pS9xG6O11A7DuZQKb UJVkdC054DdcytnfJEZD/frOLmoQkC9KR2/7I3Dlkyn11t866hRB9zHdKks+XZVs1+YMCj0W8dj KaIIJQuse3+VTs7xJzWGwPJlDRCeuT5j/l9s786EOQXS4uAiWUUMKbxUPMcn9mTRfDOpLVhLGkO aBl4LxNmwh5QRh/slaS8gpmstNrG0A5oeqPjL52RnK1HZz7m6JQUiL5L5mcWPhiC2RyRchBOPXn SLxX0S/y/ZQvsocbiOuZulkqG0329Wh9Wbzxi5l9R/Rxv/BIGFfrqB7jb3cRyy891A9U0AVIsBC 95WBkTo9J5SGgE8dE49P2wvFQz90zdxKqfFCoXCIkfEcDOkIb/BrUciT3afDv3SEgl/HesqzLMk ZAlgpNYVDBEU/nA== 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ć Reviewed-by: Linus Walleij --- 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)