From patchwork Mon May 1 09:05:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 89012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2570626vqo; Mon, 1 May 2023 02:16:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42z8PwR2Xt4QsZQZDwvL4HTjqkrRrcdWECvpnN+9UnN8OIzKR4M2X+ytgNoYvcGkIsEVgu X-Received: by 2002:a05:6a20:e683:b0:f5:398e:b455 with SMTP id mz3-20020a056a20e68300b000f5398eb455mr14645056pzb.48.1682932597190; Mon, 01 May 2023 02:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682932597; cv=none; d=google.com; s=arc-20160816; b=q3lAsBTWvdLyxcHqpMJb0bmxz/fwzb+GBMbJvUQ4fIOI4ysS8auHVCMB/fZqhOrFZI AkcJ8fEGg41tzXPlABvaut/jfRWHQTKtKi5hpAFHJikP9xxcDu//1rr7/05fQZnRxsCw FwNKEuRzFa00rdthhWGKx2LfZqje7397T9Fvlk8dY2qDqzSkSDhZhK8ClgqwdzYA7C47 B8Ct9YIw0NATHrwVt9jvKUK6i0mJBFsPrsmff4pHhLo4vtgdH76iPmACu74t6a83noCU 7eITTYAw9JFSPKVDjAxXtOcSK8Bq8yVE0Owv2+ncvvUOqJYS1PBxeMilVcitoAmBePoe 0GIQ== 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 :dkim-signature; bh=wXdZAJISVYKxbEbdwmpT3boOdl7nZiaSe7tYGc+O75A=; b=UFGJxs9zEeuClk2ZN1V2i7PiPZGDEgCnzEOx2knHUP74PTgIHVa8E/8spl91UF/NMO /StEy1Nubshh+UaX19OMPbZtS5hd2d853bd/aaigd4VxcfA2trLEvEPLJUvu4KbJHw2F xBrb23/NJEeMu+nD1QzVNB+qfR3Sl65+LWN094CH6DyJhWZuZ7iYN7tiRhrA2ZBv9j/a mMInWp5kD4CR0iyIsHliQB+bcSUakiL8kGpnlKGMXhtVtap3Jtrgjv2DkVafPyggFhMr QnLoSe2oGs1Z00Tra6L8/6Cv42zLKAo9u1FgyYptlW8bjoHAYx07h1bppk84TnCXbUml gsrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GUAhLCVq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a63d715000000b0051f71428e9fsi23664491pgg.285.2023.05.01.02.16.22; Mon, 01 May 2023 02:16:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GUAhLCVq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232387AbjEAJFn (ORCPT + 99 others); Mon, 1 May 2023 05:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232272AbjEAJFj (ORCPT ); Mon, 1 May 2023 05:05:39 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19CA11703 for ; Mon, 1 May 2023 02:05:26 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f00d3f98deso21541342e87.0 for ; Mon, 01 May 2023 02:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682931924; x=1685523924; 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=wXdZAJISVYKxbEbdwmpT3boOdl7nZiaSe7tYGc+O75A=; b=GUAhLCVqCZhF4ZWIK/0c6WPHUdtleQRRHmcqnKzgi0OLYiMHOysV+Ad9ZpWVgzbRIi LgHKw2Fql10hxJmqyWJin/W8Dk4L0oys1KF9Fmr9SVnT0k/rTX1uZAY1X18OWpySVl83 iQQDbKcDMu/qF6sBcs7/Tm/DUjSYspFnS0SFD4qVMyb7SSnBPzL60vZ7K+Abwy4kGmgO c1ul50AkmmXg4e92MZ1wfYBsBmvurpDuAcFgSMnGSXCklVkBPmZR75hqskuyO133wbc4 8Nfdml+qqGi6fMLWith90U+MxpUV6qBpipH0vOTlGD++QsF7MTkN7jJXRvukRXqQTQdO NR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682931924; x=1685523924; 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=wXdZAJISVYKxbEbdwmpT3boOdl7nZiaSe7tYGc+O75A=; b=duBJG8yZAHAXYstCMrzCa2+012wu15ppFcagX3WtgRfRtvvEA7/wD+26gaCFcMAvaW 5ethyw6+EEVQ4lTeEmRZr+8Do8okYtMKKopOXyNW2vx9aUJ91Q0zUkmv/v5KBIHKiUn8 l650bLmWwlyi/dEgMyApm8dpKFUIpX/AffJ5de81R7/6oC8gFrP/yQ7SRAnSh4efpPCU 5KfqAvJTU6/qXPwthhU/raOicC0yIaSZRDx/1a9Mr4WMSP7pEZD9ZLiztxhcpgAe9jgC G9vdDS3fY/YOIaBb/xRAubGS6PJca0IgV4Bf3vSsCDG1Pe0he/weJjTfionAVu3aDY7Y av6Q== X-Gm-Message-State: AC+VfDw6XIxLrClDQ8mOWLEz4OzN4xI2qtxbxCEQMhWiVm9kU6JdeDzo D/cqARGchyYGT7EgOjoIKnheLiWrz3rYkhtqyEw= X-Received: by 2002:a2e:9d0b:0:b0:2a8:baea:2554 with SMTP id t11-20020a2e9d0b000000b002a8baea2554mr3729962lji.3.1682931924282; Mon, 01 May 2023 02:05:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 02:05:23 -0700 (PDT) From: Linus Walleij Date: Mon, 01 May 2023 11:05:21 +0200 Subject: [PATCH 1/3] ARM/gpio: Push OMAP2 quirk down into TWL4030 driver MIME-Version: 1.0 Message-Id: <20230430-omap2-pdata-quirks-v1-1-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764682731079078516?= X-GMAIL-MSGID: =?utf-8?q?1764682731079078516?= The TWL4030 GPIO driver has a custom platform data .set_up() callback to call back into the platform and do misc stuff such as hog and export a GPIO for WLAN PWR on a specific OMAP3 board. Avoid all the kludgery in the platform data and the boardfile and just put the quirks right into the driver. Make it conditional on OMAP3. I think the exported GPIO is used by some kind of userspace so ordinary DTS hogs will probably not work. Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij Acked-by: Lee Jones --- arch/arm/mach-omap2/omap_device.c | 1 - arch/arm/mach-omap2/pdata-quirks.c | 41 +----------------------------- drivers/gpio/gpio-twl4030.c | 52 ++++++++++++++++++++++++++------------ include/linux/mfd/twl.h | 3 --- 4 files changed, 37 insertions(+), 60 deletions(-) diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index 4afa2f08e668..fca7869c8075 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c @@ -244,7 +244,6 @@ static int _omap_device_notifier_call(struct notifier_block *nb, case BUS_NOTIFY_ADD_DEVICE: if (pdev->dev.of_node) omap_device_build_from_dt(pdev); - omap_auxdata_legacy_init(dev); fallthrough; default: od = to_omap_device(pdev); diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 04208cc52784..c363ad8d6a06 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -6,6 +6,7 @@ */ #include #include +#include #include #include #include @@ -41,7 +42,6 @@ struct pdata_init { }; static struct of_dev_auxdata omap_auxdata_lookup[]; -static struct twl4030_gpio_platform_data twl_gpio_auxdata; #ifdef CONFIG_MACH_NOKIA_N8X0 static void __init omap2420_n8x0_legacy_init(void) @@ -98,22 +98,6 @@ static struct iommu_platform_data omap3_iommu_isp_pdata = { }; #endif -static int omap3_sbc_t3730_twl_callback(struct device *dev, - unsigned gpio, - unsigned ngpio) -{ - int res; - - res = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH, - "wlan pwr"); - if (res) - return res; - - gpiod_export(gpio_to_desc(gpio), 0); - - return 0; -} - static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name) { int err = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, hub_name); @@ -131,11 +115,6 @@ static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name) msleep(1); } -static void __init omap3_sbc_t3730_twl_init(void) -{ - twl_gpio_auxdata.setup = omap3_sbc_t3730_twl_callback; -} - static void __init omap3_sbc_t3730_legacy_init(void) { omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub"); @@ -393,21 +372,6 @@ static struct ti_prm_platform_data ti_prm_pdata = { .clkdm_lookup = clkdm_lookup, }; -/* - * GPIOs for TWL are initialized by the I2C bus and need custom - * handing until DSS has device tree bindings. - */ -void omap_auxdata_legacy_init(struct device *dev) -{ - if (dev->platform_data) - return; - - if (strcmp("twl4030-gpio", dev_name(dev))) - return; - - dev->platform_data = &twl_gpio_auxdata; -} - #if defined(CONFIG_ARCH_OMAP3) && IS_ENABLED(CONFIG_SND_SOC_OMAP_MCBSP) static struct omap_mcbsp_platform_data mcbsp_pdata; static void __init omap3_mcbsp_init(void) @@ -427,9 +391,6 @@ static struct pdata_init auxdata_quirks[] __initdata = { { "nokia,n800", omap2420_n8x0_legacy_init, }, { "nokia,n810", omap2420_n8x0_legacy_init, }, { "nokia,n810-wimax", omap2420_n8x0_legacy_init, }, -#endif -#ifdef CONFIG_ARCH_OMAP3 - { "compulab,omap3-sbc-t3730", omap3_sbc_t3730_twl_init, }, #endif { /* sentinel */ }, }; diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index c1bb2c3ca6f2..446599ac234a 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c @@ -17,7 +17,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -465,8 +467,7 @@ static int gpio_twl4030_debounce(u32 debounce, u8 mmc_cd) REG_GPIO_DEBEN1, 3); } -static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev, - struct twl4030_gpio_platform_data *pdata) +static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev) { struct twl4030_gpio_platform_data *omap_twl_info; @@ -474,9 +475,6 @@ static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev, if (!omap_twl_info) return NULL; - if (pdata) - *omap_twl_info = *pdata; - omap_twl_info->use_leds = of_property_read_bool(dev->of_node, "ti,use-leds"); @@ -504,9 +502,18 @@ static int gpio_twl4030_remove(struct platform_device *pdev) return 0; } +/* Called from the registered devm action */ +static void gpio_twl4030_power_off_action(void *data) +{ + struct gpio_desc *d = data; + + gpiod_unexport(d); + gpiochip_free_own_desc(d); +} + static int gpio_twl4030_probe(struct platform_device *pdev) { - struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct twl4030_gpio_platform_data *pdata; struct device_node *node = pdev->dev.of_node; struct gpio_twl4030_priv *priv; int ret, irq_base; @@ -546,9 +553,7 @@ static int gpio_twl4030_probe(struct platform_device *pdev) mutex_init(&priv->mutex); - if (node) - pdata = of_gpio_twl4030(&pdev->dev, pdata); - + pdata = of_gpio_twl4030(&pdev->dev); if (pdata == NULL) { dev_err(&pdev->dev, "Platform data is missing\n"); return -ENXIO; @@ -585,17 +590,32 @@ static int gpio_twl4030_probe(struct platform_device *pdev) goto out; } - platform_set_drvdata(pdev, priv); + /* + * Special quirk for the OMAP3 to hog and export a WLAN power + * GPIO. + */ + if (IS_ENABLED(CONFIG_ARCH_OMAP3) && + of_machine_is_compatible("compulab,omap3-sbc-t3730")) { + struct gpio_desc *d; - if (pdata->setup) { - int status; + d = gpiochip_request_own_desc(&priv->gpio_chip, + 2, "wlan pwr", + GPIO_ACTIVE_HIGH, + GPIOD_OUT_HIGH); + if (IS_ERR(d)) + return dev_err_probe(&pdev->dev, PTR_ERR(d), + "unable to hog wlan pwr GPIO\n"); + + gpiod_export(d, 0); + + ret = devm_add_action_or_reset(&pdev->dev, gpio_twl4030_power_off_action, d); + if (ret) + return dev_err_probe(&pdev->dev, ret, + "failed to install power off handler\n"); - status = pdata->setup(&pdev->dev, priv->gpio_chip.base, - TWL4030_GPIO_MAX); - if (status) - dev_dbg(&pdev->dev, "setup --> %d\n", status); } + platform_set_drvdata(pdev, priv); out: return ret; } diff --git a/include/linux/mfd/twl.h b/include/linux/mfd/twl.h index 6e3d99b7a0ee..c062d91a67d9 100644 --- a/include/linux/mfd/twl.h +++ b/include/linux/mfd/twl.h @@ -593,9 +593,6 @@ struct twl4030_gpio_platform_data { */ u32 pullups; u32 pulldowns; - - int (*setup)(struct device *dev, - unsigned gpio, unsigned ngpio); }; struct twl4030_madc_platform_data { 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: 89010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2570575vqo; Mon, 1 May 2023 02:16:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GRMyINZ4L0Rt70gkRSOx+x+n+wdvwUl4jpgnx0ogZmKfyLX9QezTH1ICcTW6EnLfgyJBA X-Received: by 2002:a17:902:ce8d:b0:1aa:d706:e0e5 with SMTP id f13-20020a170902ce8d00b001aad706e0e5mr8147178plg.47.1682932590393; Mon, 01 May 2023 02:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682932590; cv=none; d=google.com; s=arc-20160816; b=r818HSk3SittynFjbS/IYApuuk9242QaimGSJQLemOp/f0MmLi3vxzUONQproaVa1f ED5xvfaoo+0Grwr9lvCUaM9uT883lTp7O3o0tdtCWafBEkoYzKfupWuJm72oCe+SHRkP OIagZyYQsFq6Fe6YM+ccJYrxsi0K0EdViBR5yNb3JwNP+xJNaaGnQIUuZTRkWIPDjghU JQLMdsqPhSO1j7+n3C0aNI8Pi3vu3WjndbePQhbCTreVok4UsDykCaeLk2RZ04ZBi7lc JbGyZ3CR+PJBQhxJIbwqY5tWONsimHLBzz8UXAIwS0B3rxQca9TPSajZ/TFvHa6vq7oZ EXCg== 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 :dkim-signature; bh=SWK3/AsROodb0RDVek27Kktb6s+ppm3PtIa2ZoQnl4g=; b=Sk3+Q/E7NH+ebkvr6Q54YD1PRQj8i31D9WQGahgXHrWRvjCFvjHns9GHz/3Sj3QZRj cmJ58NkXrMvaOeieMYjHcI6JqWpH2EiF0i9lVlemxPKvKNe3+/hR5thUx7h4OGwJghHv Gjj8TcwhYtfmb4NenHVvC9vCAB3uY6G3JmWoCWgPRQ0M6eJpjGkdUab5SWLnfPzxvl/Y jO3SlK2Mjr4YXHAX9OiWEJzZu7HmlVDw65ubr4Ek+miPVfbm2VkUKT+HRANbdfwiU9wo grZ7nvpr9c5I+GhJPYCkVQf3SLcDXOQ5VKLzwhK9RZQoEXmrQ2b2xzq7ATf85ApUhJon 1vhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sV3g+73N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r132-20020a632b8a000000b005285dfe5ba3si16538831pgr.29.2023.05.01.02.16.15; Mon, 01 May 2023 02:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sV3g+73N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232388AbjEAJFq (ORCPT + 99 others); Mon, 1 May 2023 05:05:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbjEAJFl (ORCPT ); Mon, 1 May 2023 05:05:41 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B7AB10F3 for ; Mon, 1 May 2023 02:05:27 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4edb26f762dso2816483e87.3 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=Qc3TkqmuSvejcubYST6U57s7RlSzzsIMK30lFid5HZHGGQVZs9QVq0LCTRUpzToaOL XJCOuKUfCye1JKjEhjMQzRhBUtIMxIj0a3SDm/TGuf19gFavnfg1j6M37bet1jT973vK tW6WjFhfRuFwv2s1cB9mXN4kWSFVyZ9KA0y8k4YLdZrRlhNCZElZ3DCUySM+kp+eOn0y tlEXz+vu/O5Q+qXeV1jS4Qy30QahI9LXZmtbb4nOI0ozu0gipxp3hGlOlOgXwIB3fLbB yevNWoWp0HgwtHxePIZ2XkLA/dIAsULej79j79m+5Lrv15JMXmWf/0MJlO0iGqibRkte d4mw== X-Gm-Message-State: AC+VfDyEFD1vivxEZ3o6vrLxzxIb7KnOYokIWQNpgbQRva8xO2aK9BPx GpzNIt/x6Pnh2bTR4Gj5wANdxg== 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764682723939336718?= X-GMAIL-MSGID: =?utf-8?q?1764682723939336718?= 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(); From patchwork Mon May 1 09:05:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 89011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2570620vqo; Mon, 1 May 2023 02:16:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZgJ361jbOdPfXqhqj3d0Z78vwBOLm9AUkFGFBzcJuQ+we0WyuiUNbdX4Q5B6OQoh35zNd X-Received: by 2002:a17:902:e551:b0:19c:3d78:6a54 with SMTP id n17-20020a170902e55100b0019c3d786a54mr15844248plf.14.1682932595331; Mon, 01 May 2023 02:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682932595; cv=none; d=google.com; s=arc-20160816; b=s6OhC8sZOKOJ7GCXhv9IMvJBCXu+9cYv9a/yMBnEFW+f2e0/KQxmqckpc+GGZyEMtX 3dXE+/e2nhALzX0aqJoFdD1FWj6rUenmy4qE3h0rYyMb00LFeucPV5A2fOLa5Eq7QGy4 dYOVn1QMq6CLDWiQGvU43QpMaH8OF1cMHE1VRWL/IjtdeoUVo/8PqMf26BAHiTcDOoSO wKB1mwlkX449tXMBwGeHSG4k2CLz2V55WA9SPgQdypd3hdiGeMywd9UiQHiU980aroTW 7HWmE15pWSjNCk+CLxUV9okEuo9WVo9djSz2tz9Uev9PO7yCSW4hS/aLN/yuAVoFKzB9 WNUw== 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 :dkim-signature; bh=HQcL6JXC95b5fH8+n8D4snP5Hhmk4OL2MW3VW+pKJ0E=; b=jm9i6K7Kd9FMDOUAsLbxVPoWaqnQfnTqCWaiBpoChZXcZj8/W+pBba5kIQwH8W4a6m 2DvaVo5mFbwijT/SqFMEqtawcChOGuTwCsjm7M5HuJGnMXI1nsAu9oa+F+ZtYlHTllbn QkHEW8rsQaWBNffBDk3pbZg8V2YnXW8u3DgeZV83E6BrcQ3RnVTsiB3T7Xj6zOblCsdw qiwLjzsDVMix1Iq5viu2Ymcgk/leAPmhVf9qV+Hvp5Il9Eht80pd7YxglfcE0shdmT9I nDjd+7PQN9OyXoY1ANSh5eqRrcVtY3wdhmjKTuZ49nw5aEyyzcmCv34WjFXpzVsXq6Qx OSXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ryOVLyaX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be8-20020a170902aa0800b001a6f0e81ec7si13713010plb.237.2023.05.01.02.16.20; Mon, 01 May 2023 02:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ryOVLyaX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232428AbjEAJFv (ORCPT + 99 others); Mon, 1 May 2023 05:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232351AbjEAJFm (ORCPT ); Mon, 1 May 2023 05:05:42 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A53671723 for ; Mon, 1 May 2023 02:05:28 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4efe8b3f3f7so2677072e87.2 for ; Mon, 01 May 2023 02:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682931927; x=1685523927; 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=HQcL6JXC95b5fH8+n8D4snP5Hhmk4OL2MW3VW+pKJ0E=; b=ryOVLyaXPO1JeeCNBToS55jlkVdWfQga1fn6f6J5KLa3q00WDmdYYzsPTn9DQ6kmNG AVLtk/TRhd3Z5K/d80x/Zy+QOUvnhh+LnMwePTkmwtdOzOWwZqxPVMYFxTo0u0cHj+pG ZQKzUIeBbUQQNL7L7M3s1OcyOuQM+lcKKvkc9fA5I8f4yTtf+KSVKvE8EB2JdaqaM9wf sy52vRUHo6d6/HRomTLnJ5TCWBpnqJqwSE8s+pHozwCOwTpSyjX2gR5VfBtV+nOK05xC JysLfxToT2GTYX1aOVewx89219wGbviaT/wvMyUw0L/DhXWZcjnJO6rjO4CF6Vmje1Rg BNOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682931927; x=1685523927; 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=HQcL6JXC95b5fH8+n8D4snP5Hhmk4OL2MW3VW+pKJ0E=; b=fWOdcGrgJU+s2CH8Oqfjr/c0FfCYwF22aOtV71TNYf11c8tc7ih2e3jrPc5eXdX9Eh 08lzjp7Ad97kUYBbTbUeOXvn4inBrT5M0Dw1KbytghDoFOr/kK2jS+kzvKZzJubzr/1F 2bqGBvyXWyUjqbsio5VUgH2TQ5hP4DiJwBTU/Fz85soiGn811P/Z3tCrZQgcpvA3jL1d bU001xQaX5nzZza+Qs2R3SJqcSrlgXR3ribMh2fOWr9FRbrsxojAT5d2up0YhMxiL9ww vXtq3MBAFlLCqikZKx2GzbhzCQJd35Zq5Lm4CfUmOgiHNuYr8szrHz7nODr0OJtBSxsB NTGA== X-Gm-Message-State: AC+VfDzYjT1Lb4YrqaltphnkUyDQZ3LcXHOEGoNrm5lewgTMO0uqk4/H sf11piSOphSBa1ojnu7UahNkng== X-Received: by 2002:ac2:5490:0:b0:4ed:d1d6:c595 with SMTP id t16-20020ac25490000000b004edd1d6c595mr3958731lfk.55.1682931926864; Mon, 01 May 2023 02:05:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 02:05:26 -0700 (PDT) From: Linus Walleij Date: Mon, 01 May 2023 11:05:23 +0200 Subject: [PATCH 3/3] ARM: omap2: Rewrite WLAN quirk to use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230430-omap2-pdata-quirks-v1-3-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764682729274296928?= X-GMAIL-MSGID: =?utf-8?q?1764682729274296928?= The OMAP2 platform data quirk is using the global GPIO numberspace to obtain two WLAN GPIOs to drive power and xcvr reset GPIO lines during start-up. Rewrite the quirk to use a GPIO descriptor table so we avoid using global GPIO numbers. This gets rid of the final dependency on the legacy header from the OMAP2/3 platforms. Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij --- arch/arm/mach-omap2/pdata-quirks.c | 41 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 3264c4e77a8a..c1c0121f478d 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -178,25 +177,41 @@ static void __init am35xx_emac_reset(void) omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */ } -static struct gpio cm_t3517_wlan_gpios[] __initdata = { - { 56, GPIOF_OUT_INIT_HIGH, "wlan pwr" }, - { 4, GPIOF_OUT_INIT_HIGH, "xcvr noe" }, +static struct gpiod_lookup_table cm_t3517_wlan_gpio_table = { + .dev_id = NULL, + .table = { + GPIO_LOOKUP("gpio-48-53", 8, "power", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-0-15", 4, "noe", + GPIO_ACTIVE_HIGH), + { } + }, }; static void __init omap3_sbc_t3517_wifi_init(void) { - int err = gpio_request_array(cm_t3517_wlan_gpios, - ARRAY_SIZE(cm_t3517_wlan_gpios)); - if (err) { - pr_err("SBC-T3517: wl12xx gpios request failed: %d\n", err); - return; - } + struct gpio_desc *d; - gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[0].gpio), 0); - gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[1].gpio), 0); + gpiod_add_lookup_table(&cm_t3517_wlan_gpio_table); + /* This asserts the RESET line (reverse polarity) */ + d = gpiod_get(NULL, "power", GPIOD_OUT_HIGH); + if (IS_ERR(d)) { + pr_err("Unable to get CM T3517 WLAN power GPIO descriptor\n"); + } else { + gpiod_set_consumer_name(d, "wlan pwr"); + gpiod_export(d, 0); + } + + d = gpiod_get(NULL, "noe", GPIOD_OUT_HIGH); + if (IS_ERR(d)) { + pr_err("Unable to get CM T3517 WLAN XCVR NOE GPIO descriptor\n"); + } else { + gpiod_set_consumer_name(d, "xcvr noe"); + gpiod_export(d, 0); + } msleep(100); - gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0); + gpiod_set_value(d, 0); } static struct gpiod_lookup_table omap3_sbc_t3517_usb_gpio_table = {