From patchwork Mon May 1 09:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 679044 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD586C77B73 for ; Mon, 1 May 2023 09:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232208AbjEAJFo (ORCPT ); Mon, 1 May 2023 05:05:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232268AbjEAJFl (ORCPT ); Mon, 1 May 2023 05:05:41 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B97D1709 for ; Mon, 1 May 2023 02:05:27 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4edc7cc6f46so2826023e87.1 for ; Mon, 01 May 2023 02:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682931925; x=1685523925; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SWK3/AsROodb0RDVek27Kktb6s+ppm3PtIa2ZoQnl4g=; b=sV3g+73NYEh5B8/4DU+3wHTeYlQQ+/KGc4ORCezfBE7nh04hw3uwPKmmZ7CI1tbn+A lHm2Ozi21CLsn35z0O+ich/iX6afRbz3J2EkHt3Rfvul2uSsdkA1uLKZEeXmgduIcfjk yuSVIVaWh0qzDjrrtvbBv4GODOj2j38NqAIhkMoKaIaDCQhFn7kHKb8Tm0+7+i22ECsf 340LpvqDEE5mwTdweJmqmf1yHFcO9pKq8keeWu4AWUSsSFnv7ZanuLx+XTqQsHg6Q/nr H+kTfNUSkSFDm/D6m6762I8mDLLom7BFS+Ma+Vm898ilR9JgYkq7mnA2SKpd8+9IWY0A wAdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682931925; x=1685523925; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SWK3/AsROodb0RDVek27Kktb6s+ppm3PtIa2ZoQnl4g=; b=Sx8NOYCF+6Y+qQc8EVCVdsioh1Xk7da7yXEav4ZUcHJ+04ymV/8iWnFDEeVAjZNSbZ jhrTvfWCSdD2mhSIQahWiyMFxJElV0svuX2nZVS6+QVsreMoogwUTDW/bAWMCswIh+F9 ymkXWhsk5Bo0Z4+ESGR6zHrB1pkaPeZZoT5KYs5r0xJgbsc2DFblOzBp/Hzu6oPvxz0C eiWvxmdysyQFo+mpS6XoAOaM48971J/TlConuP83AAY0BAunNKWzcCB4d87DfujQgvrN tVJ8golkam06+XtgVMp4if9oORWEK+l9NVwnWsh2a3Y2f/918mI3/okCmePY/poMnzNU Ju0Q== X-Gm-Message-State: AC+VfDxV7brEOOnYW0n0fM8G4Z2s64yXi48lWl0ShfCcctfacu/Ck2Cj 3y+4PdF73F681YuMaSK79OHepA== X-Google-Smtp-Source: ACHHUZ7Rj4aid8nlRPd+LYmCruDpqgvT0sk/kIQEeiehBTPEfQr67tNgGYb0f37LOnTRBJdTPpKQhg== X-Received: by 2002:ac2:48ad:0:b0:4e8:5e39:6238 with SMTP id u13-20020ac248ad000000b004e85e396238mr3710163lfg.42.1682931925716; Mon, 01 May 2023 02:05:25 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id f21-20020ac251b5000000b004eb554a1711sm4601208lfk.51.2023.05.01.02.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 02:05:24 -0700 (PDT) From: Linus Walleij Date: Mon, 01 May 2023 11:05:22 +0200 Subject: [PATCH 2/3] ARM: omap2: Get USB hub reset GPIO from descriptor MIME-Version: 1.0 Message-Id: <20230430-omap2-pdata-quirks-v1-2-e015f3a3ea46@linaro.org> References: <20230430-omap2-pdata-quirks-v1-0-e015f3a3ea46@linaro.org> In-Reply-To: <20230430-omap2-pdata-quirks-v1-0-e015f3a3ea46@linaro.org> To: Tony Lindgren , Russell King , Bartosz Golaszewski , Lee Jones , Andreas Kemnade Cc: Bartosz Golaszewski , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.1 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This switches the USB hub GPIO reset line handling in the OMAP2 pdata quirks over to using GPIO descriptors to avoid using the global GPIO numberspace. Since the GPIOs are exported and assumedly used by some kind of userspace we cannot simply use hogs in the device tree. Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij --- arch/arm/mach-omap2/pdata-quirks.c | 50 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index c363ad8d6a06..3264c4e77a8a 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -98,31 +98,43 @@ static struct iommu_platform_data omap3_iommu_isp_pdata = { }; #endif -static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name) +static void __init omap3_sbc_t3x_usb_hub_init(char *hub_name, int idx) { - int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name); + struct gpio_desc *d; - if (err) { - pr_err("SBC-T3x: %s reset gpio request failed: %d\n", - hub_name, err); + /* This asserts the RESET line (reverse polarity) */ + d = gpiod_get_index(NULL, "reset", idx, GPIOD_OUT_HIGH); + if (IS_ERR(d)) { + pr_err("Unable to get T3x USB reset GPIO descriptor\n"); return; } - - gpiod_export(gpio_to_desc(gpio), 0); - + gpiod_set_consumer_name(d, hub_name); + gpiod_export(d, 0); udelay(10); - gpio_set_value(gpio, 1); + /* De-assert RESET */ + gpiod_set_value(d, 0); msleep(1); } +static struct gpiod_lookup_table omap3_sbc_t3x_usb_gpio_table = { + .dev_id = NULL, + .table = { + GPIO_LOOKUP_IDX("gpio-160-175", 7, "reset", 0, + GPIO_ACTIVE_LOW), + { } + }, +}; + static void __init omap3_sbc_t3730_legacy_init(void) { - omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub"); + gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table); + omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0); } static void __init omap3_sbc_t3530_legacy_init(void) { - omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub"); + gpiod_add_lookup_table(&omap3_sbc_t3x_usb_gpio_table); + omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 0); } static void __init omap3_evm_legacy_init(void) @@ -187,10 +199,22 @@ static void __init omap3_sbc_t3517_wifi_init(void) gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0); } +static struct gpiod_lookup_table omap3_sbc_t3517_usb_gpio_table = { + .dev_id = NULL, + .table = { + GPIO_LOOKUP_IDX("gpio-144-159", 8, "reset", 0, + GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("gpio-96-111", 2, "reset", 1, + GPIO_ACTIVE_LOW), + { } + }, +}; + static void __init omap3_sbc_t3517_legacy_init(void) { - omap3_sbc_t3x_usb_hub_init(152, "cm-t3517 usb hub"); - omap3_sbc_t3x_usb_hub_init(98, "sb-t35 usb hub"); + gpiod_add_lookup_table(&omap3_sbc_t3517_usb_gpio_table); + omap3_sbc_t3x_usb_hub_init("cm-t3517 usb hub", 0); + omap3_sbc_t3x_usb_hub_init("sb-t35 usb hub", 1); am35xx_emac_reset(); hsmmc2_internal_input_clk(); omap3_sbc_t3517_wifi_init();