From nobody Sat Feb 7 15:29:58 2026 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 9684DEB64D8 for ; Wed, 14 Jun 2023 23:19:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236882AbjFNXTE (ORCPT ); Wed, 14 Jun 2023 19:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbjFNXSZ (ORCPT ); Wed, 14 Jun 2023 19:18:25 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F307271C; Wed, 14 Jun 2023 16:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686784693; x=1718320693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HZHl2n4pQk9SJY0+lqSTvrEjOmrphzRUODe48oQg0/w=; b=BC48ERjpXXAUNTTLtd6W2kFGmDFTukZ4hrdw2BLBCmjlueqJauZFvJUp asSHF3ZYiVw4BrQrZ0cJPtKe1O8XtdAiUYCNHvvrZmRvx5aAaPyyepnU3 0OUk3Fjm4RNGUDRAfHSn6bz8eo/mVqf0tYOjNOL33QeRu0wldNd89UyMc k+/uo1xXRahJZeF7zEnrn+kZ/FRhcuCTalbusDeJmsvSZ9n5nM5ZScXlA OaolWnLxwnKmOU9uWH3i5dNYwc1R3OliETYDQJgx4GYj5FRRlZagbQkkt w7HBKkUo7OzG5DxUpvlaolkynwYF0Wawo7WYas7UlgPS2gdQyIC5rpwf+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="424648059" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="424648059" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 16:14:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="715387936" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="715387936" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 14 Jun 2023 16:14:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DB4E9133; Thu, 15 Jun 2023 02:14:51 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Alexander Stein , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven Subject: [PATCH v2 1/4] gpio: aggregator: Remove CONFIG_OF and of_match_ptr() protections Date: Thu, 15 Jun 2023 02:14:43 +0300 Message-Id: <20230614231446.3687-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> References: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" They stop the driver being used with ACPI PRP0001 and are something I want to avoid being cut and paste into new drivers. Also include mod_devicetable.h as we struct of_device_id is defined in there. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Reviewed-by: Linus Walleij --- drivers/gpio/gpio-aggregator.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index 20a686f12df7..1aa7455672d3 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -500,23 +501,21 @@ static int gpio_aggregator_probe(struct platform_devi= ce *pdev) return 0; } =20 -#ifdef CONFIG_OF static const struct of_device_id gpio_aggregator_dt_ids[] =3D { /* * Add GPIO-operated devices controlled from userspace below, - * or use "driver_override" in sysfs + * or use "driver_override" in sysfs. */ {} }; MODULE_DEVICE_TABLE(of, gpio_aggregator_dt_ids); -#endif =20 static struct platform_driver gpio_aggregator_driver =3D { .probe =3D gpio_aggregator_probe, .driver =3D { .name =3D DRV_NAME, .groups =3D gpio_aggregator_groups, - .of_match_table =3D of_match_ptr(gpio_aggregator_dt_ids), + .of_match_table =3D gpio_aggregator_dt_ids, }, }; =20 --=20 2.40.0.1.gaa8946217a0b From nobody Sat Feb 7 15:29:58 2026 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 B1F05C001B3 for ; Wed, 14 Jun 2023 23:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240388AbjFNXSX (ORCPT ); Wed, 14 Jun 2023 19:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233697AbjFNXSQ (ORCPT ); Wed, 14 Jun 2023 19:18:16 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78F0EAC; Wed, 14 Jun 2023 16:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686784678; x=1718320678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Vuq1lOeFuGO/J19m1cI+coKiG4lvz42SypGElO940fk=; b=IrdoCveJAy1iLer1jbF9uTZd9NS6/Ac8X+dMFilMy79k0brm/ngZI5mi fXpUBJ70jRZRgF86ycqMhrH+S2EukTo1W2tnYIF/dbgCQ9xMfuLaquxeN eCfZrqZzi1EtecLUXc8bnJRQNZPN4n6iveFRBylqOpuy4Q9MoJVrinA8V ZAzABqijX62omuYa2qXnMV8VuxSVdseJZ3FZRZSvBba/95XWAxgxE4ZK6 wNGWOZ6+8QteYDsrYhS4ISPmueXeL9bxVD1hhtGe6h83oj6svT7hWsbz5 tzDKUW39PUbYNuOl3+Iw/DfAwnUo1YjgHbN/tLBBPqVqd9md2LBCtQbal w==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="424648032" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="424648032" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 16:14:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="715387935" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="715387935" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 14 Jun 2023 16:14:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E558F35F; Thu, 15 Jun 2023 02:14:51 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Alexander Stein , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven Subject: [PATCH v2 2/4] gpio: aggregator: Support delay for setting up individual GPIOs Date: Thu, 15 Jun 2023 02:14:44 +0300 Message-Id: <20230614231446.3687-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> References: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In some cases the GPIO may require an additional delay after setting its value. Add support for that into the GPIO forwarder code. This will be fully enabled for use in the following changes. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Reviewed-by: Linus Walleij --- drivers/gpio/gpio-aggregator.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index 1aa7455672d3..a74a8d86caf3 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -240,6 +241,11 @@ static void __exit gpio_aggregator_remove_all(void) * GPIO Forwarder */ =20 +struct gpiochip_fwd_timing { + u32 ramp_up_us; + u32 ramp_down_us; +}; + struct gpiochip_fwd { struct gpio_chip chip; struct gpio_desc **descs; @@ -247,6 +253,7 @@ struct gpiochip_fwd { struct mutex mlock; /* protects tmp[] if can_sleep */ spinlock_t slock; /* protects tmp[] if !can_sleep */ }; + struct gpiochip_fwd_timing *delay_timings; unsigned long tmp[]; /* values and descs for multiple ops */ }; =20 @@ -331,6 +338,28 @@ static int gpio_fwd_get_multiple_locked(struct gpio_ch= ip *chip, return error; } =20 +static void gpio_fwd_delay(struct gpio_chip *chip, unsigned int offset, in= t value) +{ + struct gpiochip_fwd *fwd =3D gpiochip_get_data(chip); + const struct gpiochip_fwd_timing *delay_timings; + struct gpio_desc *desc =3D fwd->descs[offset]; + bool is_active_low =3D gpiod_is_active_low(desc); + u32 delay_us; + + delay_timings =3D &fwd->delay_timings[offset]; + if ((!is_active_low && value) || (is_active_low && !value)) + delay_us =3D delay_timings->ramp_up_us; + else + delay_us =3D delay_timings->ramp_down_us; + if (!delay_us) + return; + + if (chip->can_sleep) + fsleep(delay_us); + else + udelay(delay_us); +} + static void gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int = value) { struct gpiochip_fwd *fwd =3D gpiochip_get_data(chip); @@ -339,6 +368,9 @@ static void gpio_fwd_set(struct gpio_chip *chip, unsign= ed int offset, int value) gpiod_set_value_cansleep(fwd->descs[offset], value); else gpiod_set_value(fwd->descs[offset], value); + + if (fwd->delay_timings) + gpio_fwd_delay(chip, offset, value); } =20 static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long = *mask, --=20 2.40.0.1.gaa8946217a0b From nobody Sat Feb 7 15:29:58 2026 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 C3BF5EB64DC for ; Wed, 14 Jun 2023 23:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237021AbjFNXS2 (ORCPT ); Wed, 14 Jun 2023 19:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236285AbjFNXSQ (ORCPT ); Wed, 14 Jun 2023 19:18:16 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 940AE11C; Wed, 14 Jun 2023 16:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686784682; x=1718320682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oFD2RmHp6VjqlL6UdN87B/4X3j8u5LDczmhuyuUCg2c=; b=Uj3hTEYLHLDZdM7FsOo/XfRF1mYhstRcf8MAX3w1P/EC6n8z2znDPCPl BzRAj9HDoxSzmk/m2AS+7GUTu7vPPrNAdV/qhvOhyKqkcJRVTXvx/aoeM XRtuGvWdZjl7ACy1FC/NYvp/E2nz1pwl0x4KijfOt1qqJ6UtLG60QcJ3y kvHVLJITBkT6UfXBucHkC8lwK22TvBsLMRQvRWTmZfKyL6UyieXMtaAHu MKMNNcxR+tCE7AeOQhZYOqKBhIL7MkLtGVRgAQvOQgVJbe/Glm6ydTA+d G5XzV+VI0g1e2dOwfSyysTUIf9bfgeGb8b8QoF/OmA9pB+HagPExGg4be Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="424648039" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="424648039" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 16:14:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="715387933" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="715387933" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 14 Jun 2023 16:14:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id EB42630C; Thu, 15 Jun 2023 02:14:51 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Alexander Stein , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven Subject: [PATCH v2 3/4] gpio: aggregator: Set up a parser of delay line parameters Date: Thu, 15 Jun 2023 02:14:45 +0300 Message-Id: <20230614231446.3687-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> References: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The aggregator mode can also handle properties of the platform, that do not belong to the GPIO controller itself. One of such a property is a signal delay line. Set up a parser to support it. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Reviewed-by: Linus Walleij --- drivers/gpio/gpio-aggregator.c | 70 +++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index a74a8d86caf3..ed11aa56bc51 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -423,6 +424,51 @@ static int gpio_fwd_to_irq(struct gpio_chip *chip, uns= igned int offset) return gpiod_to_irq(fwd->descs[offset]); } =20 +#ifdef CONFIG_OF_GPIO +static int gpiochip_fwd_delay_of_xlate(struct gpio_chip *chip, + const struct of_phandle_args *gpiospec, + u32 *flags) +{ + struct gpiochip_fwd *fwd =3D gpiochip_get_data(chip); + struct gpiochip_fwd_timing *timings; + u32 line; + + if (gpiospec->args_count !=3D chip->of_gpio_n_cells) + return -EINVAL; + + line =3D gpiospec->args[0]; + if (line >=3D chip->ngpio) + return -EINVAL; + + timings =3D &fwd->delay_timings[line]; + timings->ramp_up_us =3D gpiospec->args[1]; + timings->ramp_down_us =3D gpiospec->args[2]; + + return line; +} + +static int gpiochip_fwd_setup_delay_line(struct device *dev, struct gpio_c= hip *chip, + struct gpiochip_fwd *fwd) +{ + fwd->delay_timings =3D devm_kcalloc(dev, chip->ngpio, + sizeof(*fwd->delay_timings), + GFP_KERNEL); + if (!fwd->delay_timings) + return -ENOMEM; + + chip->of_xlate =3D gpiochip_fwd_delay_of_xlate; + chip->of_gpio_n_cells =3D 3; + + return 0; +} +#else +static int gpiochip_fwd_setup_delay_line(struct device *dev, struct gpio_c= hip *chip, + struct gpiochip_fwd *fwd) +{ + return 0; +} +#endif /* !CONFIG_OF_GPIO */ + /** * gpiochip_fwd_create() - Create a new GPIO forwarder * @dev: Parent device pointer @@ -430,6 +476,7 @@ static int gpio_fwd_to_irq(struct gpio_chip *chip, unsi= gned int offset) * @descs: Array containing the GPIO descriptors to forward to. * This array must contain @ngpios entries, and must not be deallo= cated * before the forwarder has been destroyed again. + * @delay_line: True if the pins have an external delay line. * * This function creates a new gpiochip, which forwards all GPIO operation= s to * the passed GPIO descriptors. @@ -439,7 +486,8 @@ static int gpio_fwd_to_irq(struct gpio_chip *chip, unsi= gned int offset) */ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev, unsigned int ngpios, - struct gpio_desc *descs[]) + struct gpio_desc *descs[], + bool delay_line) { const char *label =3D dev_name(dev); struct gpiochip_fwd *fwd; @@ -492,6 +540,12 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct= device *dev, else spin_lock_init(&fwd->slock); =20 + if (delay_line) { + error =3D gpiochip_fwd_setup_delay_line(dev, chip, fwd); + if (error) + return ERR_PTR(error); + } + error =3D devm_gpiochip_add_data(dev, chip, fwd); if (error) return ERR_PTR(error); @@ -509,6 +563,7 @@ static int gpio_aggregator_probe(struct platform_device= *pdev) struct device *dev =3D &pdev->dev; struct gpio_desc **descs; struct gpiochip_fwd *fwd; + bool delay_line; int i, n; =20 n =3D gpiod_count(dev, NULL); @@ -525,7 +580,9 @@ static int gpio_aggregator_probe(struct platform_device= *pdev) return PTR_ERR(descs[i]); } =20 - fwd =3D gpiochip_fwd_create(dev, n, descs); + delay_line =3D fwnode_device_is_compatible(dev_fwnode(dev), "gpio-delay"); + + fwd =3D gpiochip_fwd_create(dev, n, descs, delay_line); if (IS_ERR(fwd)) return PTR_ERR(fwd); =20 @@ -534,6 +591,15 @@ static int gpio_aggregator_probe(struct platform_devic= e *pdev) } =20 static const struct of_device_id gpio_aggregator_dt_ids[] =3D { + /* + * The GPIO delay provides a way to configure platform specific delays + * for GPIO ramp-up or ramp-down delays. This can serve the following + * purposes: + * - Open-drain output using an RC filter + */ + { + .compatible =3D "gpio-delay", + }, /* * Add GPIO-operated devices controlled from userspace below, * or use "driver_override" in sysfs. --=20 2.40.0.1.gaa8946217a0b From nobody Sat Feb 7 15:29:58 2026 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 756F3EB64D8 for ; Wed, 14 Jun 2023 23:18:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235026AbjFNXSy (ORCPT ); Wed, 14 Jun 2023 19:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238478AbjFNXSV (ORCPT ); Wed, 14 Jun 2023 19:18:21 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415DE26BF; Wed, 14 Jun 2023 16:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686784690; x=1718320690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9F6zH3UDg7TGi4FkoyI+l7N5RQc/2fFZU7O2gZQCqaY=; b=DVr0oNj1csSpIp5vE8S1g3fPsegZAUw7wZazosX7XtJujf1seCYTR0Md 89P6cP9w3WiM7d1zYfRAidTeG8N4RVDkuWpxoHB64zWvo1oj9W+FFa3LP PO+beS7nPc3NDkL1rb0ZTnWwoGJSHpmdFNQVnc1xKhxeBrZ3gl8g2EtpN O37VOnVZ6jv48EAAwjR43XaEgP+y4Vw8LLNDFyEgOXVfIuzgHbk+UjZuL nTHOqZEAs2ChcVd2AXbFO6ESp0vXz6ciH1VmDRpP1rj6q2G+VCZX1b7KS LitdLGPv2vQQsLhlwVH5THAFQge2CMJsB0PQQWr3TztSBfnwDlmDdmpC9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="424648055" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="424648055" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 16:14:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="715387937" X-IronPort-AV: E=Sophos;i="6.00,243,1681196400"; d="scan'208";a="715387937" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 14 Jun 2023 16:14:43 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 018B840D; Thu, 15 Jun 2023 02:14:52 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Alexander Stein , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven Subject: [PATCH v2 4/4] gpio: delay: Remove duplicative functionality Date: Thu, 15 Jun 2023 02:14:46 +0300 Message-Id: <20230614231446.3687-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> References: <20230614231446.3687-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now that GPIO aggregator supports a delay line, drop the duplicative functionality, i.e. the entire gpio-delay driver. Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Reviewed-by: Linus Walleij --- drivers/gpio/Kconfig | 9 --- drivers/gpio/Makefile | 1 - drivers/gpio/gpio-delay.c | 164 -------------------------------------- 3 files changed, 174 deletions(-) delete mode 100644 drivers/gpio/gpio-delay.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 209738ef1446..abaae68c88a4 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1748,15 +1748,6 @@ config GPIO_AGGREGATOR industrial control context, to be operated from userspace using the GPIO chardev interface. =20 -config GPIO_DELAY - tristate "GPIO delay" - depends on OF_GPIO - help - Say yes here to enable the GPIO delay, which provides a way to - configure platform specific delays for GPIO ramp-up or ramp-down - delays. This can serve the following purposes: - - Open-drain output using an RC filter - config GPIO_LATCH tristate "GPIO latch driver" help diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 947c9cf9aba8..7843b16f5d59 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -52,7 +52,6 @@ obj-$(CONFIG_GPIO_DA9052) +=3D gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) +=3D gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) +=3D gpio-davinci.o obj-$(CONFIG_GPIO_DLN2) +=3D gpio-dln2.o -obj-$(CONFIG_GPIO_DELAY) +=3D gpio-delay.o obj-$(CONFIG_GPIO_DWAPB) +=3D gpio-dwapb.o obj-$(CONFIG_GPIO_EIC_SPRD) +=3D gpio-eic-sprd.o obj-$(CONFIG_GPIO_ELKHARTLAKE) +=3D gpio-elkhartlake.o diff --git a/drivers/gpio/gpio-delay.c b/drivers/gpio/gpio-delay.c deleted file mode 100644 index b489b561b225..000000000000 --- a/drivers/gpio/gpio-delay.c +++ /dev/null @@ -1,164 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright 2022 TQ-Systems GmbH - * Author: Alexander Stein - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "gpiolib.h" - -struct gpio_delay_timing { - unsigned long ramp_up_delay_us; - unsigned long ramp_down_delay_us; -}; - -struct gpio_delay_priv { - struct gpio_chip gc; - struct gpio_descs *input_gpio; - struct gpio_delay_timing *delay_timings; -}; - -static int gpio_delay_get_direction(struct gpio_chip *gc, unsigned int off= set) -{ - return GPIO_LINE_DIRECTION_OUT; -} - -static void gpio_delay_set(struct gpio_chip *gc, unsigned int offset, int = val) -{ - struct gpio_delay_priv *priv =3D gpiochip_get_data(gc); - struct gpio_desc *gpio_desc =3D priv->input_gpio->desc[offset]; - const struct gpio_delay_timing *delay_timings; - bool ramp_up; - - gpiod_set_value(gpio_desc, val); - - delay_timings =3D &priv->delay_timings[offset]; - ramp_up =3D (!gpiod_is_active_low(gpio_desc) && val) || - (gpiod_is_active_low(gpio_desc) && !val); - - if (ramp_up && delay_timings->ramp_up_delay_us) - udelay(delay_timings->ramp_up_delay_us); - if (!ramp_up && delay_timings->ramp_down_delay_us) - udelay(delay_timings->ramp_down_delay_us); -} - -static void gpio_delay_set_can_sleep(struct gpio_chip *gc, unsigned int of= fset, int val) -{ - struct gpio_delay_priv *priv =3D gpiochip_get_data(gc); - struct gpio_desc *gpio_desc =3D priv->input_gpio->desc[offset]; - const struct gpio_delay_timing *delay_timings; - bool ramp_up; - - gpiod_set_value_cansleep(gpio_desc, val); - - delay_timings =3D &priv->delay_timings[offset]; - ramp_up =3D (!gpiod_is_active_low(gpio_desc) && val) || - (gpiod_is_active_low(gpio_desc) && !val); - - if (ramp_up && delay_timings->ramp_up_delay_us) - fsleep(delay_timings->ramp_up_delay_us); - if (!ramp_up && delay_timings->ramp_down_delay_us) - fsleep(delay_timings->ramp_down_delay_us); -} - -static int gpio_delay_of_xlate(struct gpio_chip *gc, - const struct of_phandle_args *gpiospec, - u32 *flags) -{ - struct gpio_delay_priv *priv =3D gpiochip_get_data(gc); - struct gpio_delay_timing *timings; - u32 line; - - if (gpiospec->args_count !=3D gc->of_gpio_n_cells) - return -EINVAL; - - line =3D gpiospec->args[0]; - if (line >=3D gc->ngpio) - return -EINVAL; - - timings =3D &priv->delay_timings[line]; - timings->ramp_up_delay_us =3D gpiospec->args[1]; - timings->ramp_down_delay_us =3D gpiospec->args[2]; - - return line; -} - -static bool gpio_delay_can_sleep(const struct gpio_delay_priv *priv) -{ - int i; - - for (i =3D 0; i < priv->input_gpio->ndescs; i++) - if (gpiod_cansleep(priv->input_gpio->desc[i])) - return true; - - return false; -} - -static int gpio_delay_probe(struct platform_device *pdev) -{ - struct gpio_delay_priv *priv; - - priv =3D devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->input_gpio =3D devm_gpiod_get_array(&pdev->dev, NULL, GPIOD_OUT_LOW= ); - if (IS_ERR(priv->input_gpio)) - return dev_err_probe(&pdev->dev, PTR_ERR(priv->input_gpio), - "Failed to get input-gpios"); - - priv->delay_timings =3D devm_kcalloc(&pdev->dev, - priv->input_gpio->ndescs, - sizeof(*priv->delay_timings), - GFP_KERNEL); - if (!priv->delay_timings) - return -ENOMEM; - - if (gpio_delay_can_sleep(priv)) { - priv->gc.can_sleep =3D true; - priv->gc.set =3D gpio_delay_set_can_sleep; - } else { - priv->gc.can_sleep =3D false; - priv->gc.set =3D gpio_delay_set; - } - - priv->gc.get_direction =3D gpio_delay_get_direction; - priv->gc.of_xlate =3D gpio_delay_of_xlate; - priv->gc.of_gpio_n_cells =3D 3; - priv->gc.ngpio =3D priv->input_gpio->ndescs; - priv->gc.owner =3D THIS_MODULE; - priv->gc.base =3D -1; - priv->gc.parent =3D &pdev->dev; - - platform_set_drvdata(pdev, priv); - - return devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv); -} - -static const struct of_device_id gpio_delay_ids[] =3D { - { - .compatible =3D "gpio-delay", - }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, gpio_delay_ids); - -static struct platform_driver gpio_delay_driver =3D { - .driver =3D { - .name =3D "gpio-delay", - .of_match_table =3D gpio_delay_ids, - }, - .probe =3D gpio_delay_probe, -}; -module_platform_driver(gpio_delay_driver); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Alexander Stein "); -MODULE_DESCRIPTION("GPIO delay driver"); --=20 2.40.0.1.gaa8946217a0b