From patchwork Thu Oct 5 02:58:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Akashi X-Patchwork-Id: 14946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp331277vqb; Thu, 5 Oct 2023 07:19:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOel6eo+BX4d4SQEEEqKdTWJxRWudKmWUeSL9gvWNDIFXg8vipGVsiPoBPXzUs80D1qtCW X-Received: by 2002:a05:6358:4408:b0:134:c37f:4b64 with SMTP id z8-20020a056358440800b00134c37f4b64mr5500287rwc.30.1696515574370; Thu, 05 Oct 2023 07:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696515574; cv=none; d=google.com; s=arc-20160816; b=mfpXGZFDd13MzMoZFbFN9pVUzlaKj4VBS+uuA5utShvWLOEfkYMoWZkVWkO174Nr3t W5/UfmG6nMRV0yGWpet7shYjuOKBf/x7QhPLevhMYLrcWkz1FaABG1g6ZtgkKjIIkHK/ wv82L8N/vS4Mdux3obWny1vRr9KH6QWd/kZvf6kFkgs2h//0ckiqKH/Pf1lLMQK5+BkU d/tg3ZFyFB+e1ByM0g9HPYLN3nVK89SQJ+VGHq5ccovTIGHR6jo0bC8S2Z9DnPiPK6OT xD4J5dH61w5DZc6/rWL0ogAcJBN5lSUlP6Ne0vstGuTPqd43Q7V++v9+czcAGWQIAYDO trRQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Ids3/+45hUvtPMVAGYEAW18IR7eG26OSuvk1q0KIeuI=; fh=5LIWo2D/PeZk6SC/rjjkha3vijtdzmZAJYKHEnFRQDY=; b=GKrqRSvZEsVTAzBWrKLqHscy5QKtEsBFJ8zZtWvd2xkE+f5ONvogj18Ky820MlOdlf bynnqL1j1/V0hRxCelVXJ1wdKH0G2V3WKo1q7e7MMOQwgWQMBR+i+KH45k2MgE0PXWtD TTT9yQqv+2UoGd0AFpVOnqniDe8hHXHGm+DI6ETCU/rV1mTDJAMrIz/Ud7+V7pfMIqM/ qITNIpjVqZMQ8RwMx05PlIcdP2W9300BpJ4jaVDbvmBxt1AsssWzXQwNMbSEmWkbQvE7 /gzVeX7GYs3YAaMWYGLScaPUUlGuLujytmedKBX7wOkAZ16PyqdtTCNA30yu24Yg2aOW V5Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FGMGqy6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id d3-20020a633603000000b00581d45a5accsi1517742pga.838.2023.10.05.07.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:19:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FGMGqy6N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 739F1810CA84; Thu, 5 Oct 2023 07:19:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233783AbjJEOSo (ORCPT + 19 others); Thu, 5 Oct 2023 10:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244432AbjJENxl (ORCPT ); Thu, 5 Oct 2023 09:53:41 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 107B2139 for ; Wed, 4 Oct 2023 19:59:16 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-690f2719ab2so92056b3a.0 for ; Wed, 04 Oct 2023 19:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696474755; x=1697079555; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ids3/+45hUvtPMVAGYEAW18IR7eG26OSuvk1q0KIeuI=; b=FGMGqy6NdreEQmknJnTxdfzb0g7+R+QZ5XXvrcschnSESAUJkX0aQRSl3gb8wuJfJj uxm6N9mGTpvXb4QH/5JaK1FWkBiyhRp5oOUR+51TjHDxy+9S0xRwccVLfLuPLCc0A2oc /MKDOrmBx3amZtSWFZds+tpLV1BM+Iqmu5e2euCYLNSVxhP6xm9WbykXc4QIJcLqlECX NBTQ5E6HmpAjYDNxtQ9KqNiYj9VV6mzorahh8ih8tnjAKusLG5jBOs+Kj/OY8SeoUyP/ 6R2fjghUlJlNMtFeh27+Wi9+jnvKDzUnH7J2LQaHIFcay96/njsWCWjL8PfcZFFAsw9Z Yo8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696474755; x=1697079555; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ids3/+45hUvtPMVAGYEAW18IR7eG26OSuvk1q0KIeuI=; b=Hc+pW++HP8X91UJix3F0UoRRJkkHs5qLH+6rRgfDxkpF5hTuNTQNnuOFN79kGUGVI5 vX5eG5AVe+QzjcQcdW81RtVB8UjjJmrcb1Ryu6KkwLbbDNJ3jPlM6/0ES96PCQncWpP3 P0K959UGfA2q7NpumFm6iEwRP+YYUxqxYdMEVz52hncrX50tz0DckiaWovdts0LWhoQw 9Kx9hX8GGCGWF7rEaHOngBkZPDYn6m7NxgyO3MWFn2MckR9ktZfMb2ZrrCLu1NT+i9SO kHsSr1TWj2QSY4qSLgs2+O+mj/84EilHb5/kGfKdPQQxWrCbNaOyjvfiwFAdMNY2S2wf gA9A== X-Gm-Message-State: AOJu0Yxj0biFBe9LODTHtrX6ev8LZkR5kO/BCtNkRZY5jcznpnDsi/ih WrYmLXraAy0JB6TP5MQtRv5jqvmloC+lQsMM/+VfWw== X-Received: by 2002:a05:6a21:a587:b0:163:c167:964a with SMTP id gd7-20020a056a21a58700b00163c167964amr4845452pzc.1.1696474755450; Wed, 04 Oct 2023 19:59:15 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:a16d:fce2:497:afb7]) by smtp.gmail.com with ESMTPSA id b18-20020a637152000000b005782ad723casm269265pgn.27.2023.10.04.19.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 19:59:15 -0700 (PDT) From: AKASHI Takahiro To: sudeep.holla@arm.com, cristian.marussi@arm.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linus.walleij@linaro.org Cc: Oleksii_Moisieiev@epam.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, AKASHI Takahiro Subject: [RFC v2 0/5] gpio: add pinctrl based generic gpio driver Date: Thu, 5 Oct 2023 11:58:38 +0900 Message-Id: <20231005025843.508689-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:19:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778925515156415749 X-GMAIL-MSGID: 1778925515156415749 This is a revised version of my previous RFC[1]. Although I modified the commits to make them look SCMI-independent, they are still posted as RFC because I have never tested them on real hardware. (background) I'm currently working on implementing SCMI pinctrl/gpio drivers on U-Boot[2]. Although the pinctrl driver for the kernel[3] was submitted by EPAM, it doesn't contain the gpio driver and I believe that we should discuss a couple of points on the kernel side to finalize my design for U-Boot. So this RFC is intended for reviews, especially to raise some issues. 1) how to obtain a value on an input pin All the existing gpio drivers are set to obtain a value on an input pin by accessing the hardware directly. In SCMI case, however, this is just impossible in its nature and must be supported via a protocol using "Input-value" configuration type. (See the spec[4], table-23.) The current pinconf framework is missing the feature (the pinconf parameter and a helper function). See patch#1, #2 and #3. Please note that there is an issue around the pin configuration in EPAM's current pinctrl driver as I commented[5]. 2) DT bindings I would like to propose a generic binding for pinctrl based gpio driver. This allows a "consumer" driver to handle gpio pins like as other normal gpio controllers support. (patch#5) 3) generic GPIO driver Based on (2), I tried to prototype a generic driver in patch#4. Thanks to a set of existing pinctrl_gpio helper functions, except (1), It seems that the driver can be implemented not relying on pin controller specific code, at least for SCMI pinctrl. I will appreciate any comments. -Takahiro Akashi [1] https://lkml.iu.edu//hypermail/linux/kernel/2310.0/00362.html [2] https://lists.denx.de/pipermail/u-boot/2023-September/529765.html [3] https://lkml.iu.edu/hypermail/linux/kernel/2308.1/01082.html [4] https://developer.arm.com/documentation/den0056/ [5] https://lkml.iu.edu/hypermail/linux/kernel/2308.2/07483.html AKASHI Takahiro (5): pinctrl: define PIN_CONFIG_INPUT pinctrl: always export pin_config_get_for_pin() pinctrl: add pinctrl_gpio_get_config() gpio: add pinctrl based generic gpio driver dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver .../bindings/gpio/pin-control-gpio.yaml | 55 ++++++ drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-by-pinctrl.c | 165 ++++++++++++++++++ drivers/pinctrl/core.c | 19 ++ drivers/pinctrl/pinconf.h | 10 +- include/linux/pinctrl/consumer.h | 8 + include/linux/pinctrl/pinconf-generic.h | 5 + 8 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml create mode 100644 drivers/gpio/gpio-by-pinctrl.c