Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp326042rwd; Wed, 14 Jun 2023 16:55:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rwWZVxM+AqTNRQ7eS4cF32wCMU6lz9fG2lBnbzZIilnXpYoHipQ/UVvO+qVONKLTELkXh X-Received: by 2002:a19:f20d:0:b0:4f6:116d:6d26 with SMTP id q13-20020a19f20d000000b004f6116d6d26mr8989068lfh.42.1686786941523; Wed, 14 Jun 2023 16:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686786941; cv=none; d=google.com; s=arc-20160816; b=RKgtEfXZ+oz8pzHS2PwAeqqw6Am6iQvBgVZo3jgBSHW9PrhgSveyxIQa3iDZ/1zWaM dgaOYdNcJsxtxFjAEokJlbK5b6I1wG9kDP5jPt+eIawailhjfuUNtvx+T8aSfU6hxQER UPzTK9Ku0nAbT5+PNxOmKr+F+t80UdTmDaFunhu4W1Pp/nyYbyMlhpGT5haLDXae4Gsu lhIxFMeQKPPxjRTpOjNKzGce49SmjcmfW6BwBbwIIDA21pKiXdzknlzE+cFzHgbz4ifg ggwlyJUZRVdOSdkF152Rb0gkx1t4uMdO1rNwDs2ONxtjbaZ7l4gQ7GhEOWsEFERzDwCb OzFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UvQVrWNPJA8wmIS0zOikRdWy1MpZgKmtENpn1iCbmsk=; b=wX4JSrpQFkWhQ683VSzoVeOreN1SPyI3qYDrg344pnfV4dl59ZeS1nScPlH/KqtOOp IsTYohAg5wWuusQDjOpSVx8eZJ8wLtMARUPnsmmTEqkW2sSQiKUaLcUr7RLLz5UpaLru n1tUABNIWHfQ51fZsBWg1+lhxD/biHKOML11bvPWaqo9gUKkSOBAPgIvJbytycvkjWvY FRq5h5/Mkwdxntx/SDS8Zx8IlB9u7RXFRPdhTyrFU3ZHbAk1luk1dho+Tu1MTB5YLOxK 93YCDvVDqRirXTML/1vL64QbHycqZeL6Wu6XFu8k0LFB7fZ9eZJcqXKDp/iWhO4t8TGG 1vrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DVr0oNj1; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a05640210d200b00514a6ae120csi9817884edu.9.2023.06.14.16.55.16; Wed, 14 Jun 2023 16:55:41 -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=@intel.com header.s=Intel header.b=DVr0oNj1; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbjFNXSm (ORCPT + 99 others); Wed, 14 Jun 2023 19:18:42 -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: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Now that GPIO aggregator supports a delay line, drop the duplicative functionality, i.e. the entire gpio-delay driver. Signed-off-by: Andy Shevchenko --- 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. -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) += gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o -obj-$(CONFIG_GPIO_DELAY) += gpio-delay.o obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o obj-$(CONFIG_GPIO_ELKHARTLAKE) += 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 offset) -{ - return GPIO_LINE_DIRECTION_OUT; -} - -static void gpio_delay_set(struct gpio_chip *gc, unsigned int offset, int val) -{ - struct gpio_delay_priv *priv = gpiochip_get_data(gc); - struct gpio_desc *gpio_desc = priv->input_gpio->desc[offset]; - const struct gpio_delay_timing *delay_timings; - bool ramp_up; - - gpiod_set_value(gpio_desc, val); - - delay_timings = &priv->delay_timings[offset]; - ramp_up = (!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 offset, int val) -{ - struct gpio_delay_priv *priv = gpiochip_get_data(gc); - struct gpio_desc *gpio_desc = priv->input_gpio->desc[offset]; - const struct gpio_delay_timing *delay_timings; - bool ramp_up; - - gpiod_set_value_cansleep(gpio_desc, val); - - delay_timings = &priv->delay_timings[offset]; - ramp_up = (!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 = gpiochip_get_data(gc); - struct gpio_delay_timing *timings; - u32 line; - - if (gpiospec->args_count != gc->of_gpio_n_cells) - return -EINVAL; - - line = gpiospec->args[0]; - if (line >= gc->ngpio) - return -EINVAL; - - timings = &priv->delay_timings[line]; - timings->ramp_up_delay_us = gpiospec->args[1]; - timings->ramp_down_delay_us = gpiospec->args[2]; - - return line; -} - -static bool gpio_delay_can_sleep(const struct gpio_delay_priv *priv) -{ - int i; - - for (i = 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 = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->input_gpio = 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 = 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 = true; - priv->gc.set = gpio_delay_set_can_sleep; - } else { - priv->gc.can_sleep = false; - priv->gc.set = gpio_delay_set; - } - - priv->gc.get_direction = gpio_delay_get_direction; - priv->gc.of_xlate = gpio_delay_of_xlate; - priv->gc.of_gpio_n_cells = 3; - priv->gc.ngpio = priv->input_gpio->ndescs; - priv->gc.owner = THIS_MODULE; - priv->gc.base = -1; - priv->gc.parent = &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[] = { - { - .compatible = "gpio-delay", - }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, gpio_delay_ids); - -static struct platform_driver gpio_delay_driver = { - .driver = { - .name = "gpio-delay", - .of_match_table = gpio_delay_ids, - }, - .probe = gpio_delay_probe, -}; -module_platform_driver(gpio_delay_driver); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Alexander Stein "); -MODULE_DESCRIPTION("GPIO delay driver"); -- 2.40.0.1.gaa8946217a0b