Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1690512rwd; Fri, 9 Jun 2023 00:15:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ647JKaqRN8S+u68sOW9oqC9nFp0uHt727UxtbzXzvBfZvBMMT34SzOaUXmHcPwORZPWxny X-Received: by 2002:a05:6830:1e37:b0:6af:9c49:c66d with SMTP id t23-20020a0568301e3700b006af9c49c66dmr634295otr.18.1686294949625; Fri, 09 Jun 2023 00:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686294949; cv=none; d=google.com; s=arc-20160816; b=kPRCAuxB46b3gJIpYtY0MRnS2dZNQvmoai1P1WFVMAvL0LfNpoLzqsUABwE6IThfxd 6fHXR1kN/350oZRLHDQCGktlBtFfklM7FF+a9JHSU+m53tzSBlJwd96/r/1y4Ahq6/ng q8JR5w2oOE3ob9CqZ/ILjAn1RvMtkC/UgSrr4DYiowAuaDy7PGi7t260Jn2qOR7FzowG 5eCNh4NKFqqLkFBQ35/6zLM5P8mXH5LYb3Zk13VG1NetBddqKSXaQtL18MYRm8Vud7N/ ioUWJPqG9NAVC2+fmlLEqpwLVv8t7Krq+MsBAyrZ0PU6G5A0cDL1zDKklZwHXXr15RYE SK1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=WGkxdFE+1np6HGdAtAfzzRU2W8T+lfVGD7jYkevKfnE=; b=g8+N/yScNFXdhg+v0pdeAU8spD6ph3DBdIgJE386w0u2iNydQB4eepn8BdGPuUnZAf ZjI0xMJxM7mnyZUMbmfCCPXPsFOSfq7rhIhipgcGjfIO065rguga5SO68iiWOAwzCfgb MmNZ/0tAQ/47FDPUCXQjV6FZGT+wjh9rjQyAkp8vPfEny/4BWV39qY88JL7KkyoiuJKF Ga8V38Q8I3xavxccZBZnc3Ip3TdO5IrAGvHB9ofp+DprTMpw6POFgtwB8v5EPvbodxGF 33w0PkCRgO9tahwq26QBuWoHCzn/lB+iRRBufztGD5QAz+h2V0qDqv56x0LgLIdk0yOl z/1g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a636116000000b00543ef0f9818si2282900pgb.737.2023.06.09.00.15.36; Fri, 09 Jun 2023 00:15:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237084AbjFIHLV convert rfc822-to-8bit (ORCPT + 99 others); Fri, 9 Jun 2023 03:11:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjFIHLT (ORCPT ); Fri, 9 Jun 2023 03:11:19 -0400 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 867802718; Fri, 9 Jun 2023 00:11:18 -0700 (PDT) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-565f1145dc8so13012007b3.1; Fri, 09 Jun 2023 00:11:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686294677; x=1688886677; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i4OrpWTk4CwSjK0GHc2r2JMDUni0s50dMtpQAaHpA7g=; b=bPpV1HIOhFUKLAggEplybsd57Oh+F/pfXLxu/oS9tQyHHjT/P8tCnL4HySxc3Clvik g6765Od4KcirIDPSHyfKhA1sErFyhvnhuJVawBbFi/cXXb82l0gLh+UF9iTKoXqqxUb1 bdZZDOjAob2zeGdTDqNHz6SLcYK4829nJXhcXPFrhs1QGMWPJr5TIssfvQZ8TWa7lmGE qvsKa9mfl0wLd6NSfOlcD1mlaPh4ABg4YAETKjLZjtbqfYgGmWClr1HaHF2uIAEjrQYH UWO97AOZgvejXETysFQyklVLXEv1gMqopVD+Ue1mn9Tud0fJXNX67dL4aCNJdD6h5mUt kShA== X-Gm-Message-State: AC+VfDyYT+4/UUBR4uSik3QOoyB3gXA1GKXwRVW4voOZMX6pk9gtEBK+ zjPDz4p3zXYlHYX1X0ePusXTnq966bsbqA== X-Received: by 2002:a0d:db4a:0:b0:56a:3b3e:bc6 with SMTP id d71-20020a0ddb4a000000b0056a3b3e0bc6mr550344ywe.14.1686294677486; Fri, 09 Jun 2023 00:11:17 -0700 (PDT) Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com. [209.85.128.175]) by smtp.gmail.com with ESMTPSA id x142-20020a0dd594000000b00559fb950d9fsm446460ywd.45.2023.06.09.00.11.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 00:11:16 -0700 (PDT) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-565f1145dc8so13011837b3.1; Fri, 09 Jun 2023 00:11:16 -0700 (PDT) X-Received: by 2002:a25:2fd5:0:b0:b9a:7cfe:9bed with SMTP id v204-20020a252fd5000000b00b9a7cfe9bedmr454382ybv.14.1686294676577; Fri, 09 Jun 2023 00:11:16 -0700 (PDT) MIME-Version: 1.0 References: <20230608162130.55015-1-andriy.shevchenko@linux.intel.com> In-Reply-To: <20230608162130.55015-1-andriy.shevchenko@linux.intel.com> From: Geert Uytterhoeven Date: Fri, 9 Jun 2023 09:11:04 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [rfc, rft, PATCH v1 1/1] gpio: aggregator: Introduce delay support for individual output pins To: Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Alexander Stein Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Andy, On Thu, Jun 8, 2023 at 6:23 PM Andy Shevchenko wrote: > 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 signal delay line. Intdoduce support of it. > > Signed-off-by: Andy Shevchenko > --- > > I don't like the idea of gpio-delay or similar. We have already GPIO > aggregator that incorporates the GPIO proxy / forwarder functionality. I think this makes sense. > --- a/drivers/gpio/gpio-aggregator.c > +++ b/drivers/gpio/gpio-aggregator.c > @@ -333,11 +341,28 @@ static int gpio_fwd_get_multiple_locked(struct gpio_chip *chip, > static void gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int value) > { > struct gpiochip_fwd *fwd = gpiochip_get_data(chip); > + const struct gpiochip_fwd_timing *delay_timings; > + struct gpio_desc *desc = fwd->descs[offset]; > + bool is_active_low = gpiod_is_active_low(desc); > + bool ramp_up; > > - if (chip->can_sleep) > - gpiod_set_value_cansleep(fwd->descs[offset], value); > - else > - gpiod_set_value(fwd->descs[offset], value); > + delay_timings = &fwd->delay_timings[offset]; > + ramp_up = (!is_active_low && value) || (is_active_low && !value); > + if (chip->can_sleep) { > + gpiod_set_value_cansleep(desc, value); > + > + if (ramp_up && delay_timings->ramp_up_us) > + fsleep(delay_timings->ramp_up_us); > + if (!ramp_up && delay_timings->ramp_down_us) > + fsleep(delay_timings->ramp_down_us); > + } else { > + gpiod_set_value(desc, value); > + > + if (ramp_up && delay_timings->ramp_up_us) > + udelay(delay_timings->ramp_up_us); > + if (!ramp_up && delay_timings->ramp_down_us) > + udelay(delay_timings->ramp_down_us); I hope no one ever needs to use the values from the example in the bindings enable-gpios = <&enable_delay 0 130000 30000>; on a non-sleepable GPIO. Not only is a looping delay of 130 ms very bad for system responsiveness, such large delays may not even be supported on all systems (e.g. ARM implementation says < 2 ms). So for large values, this should use mdelay(). This also applies to gpio-delay, of course. > + } > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds