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: AKASHI Takahiro X-Patchwork-Id: 13409719 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85122E936ED for ; Thu, 5 Oct 2023 02:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IFWObsYaFwoD6lyhTV9FxphoEwVCO9mEBd6CB9hHiUI=; b=rocKThc/AbRkLy 17wmkgeVSEwxO158lm4RTjx6GgN4WLl/m8fwgIpdEIAkE+nGRpYRpz80bd9ZvjzfgR08XVWzXU+qR ClLtJanLO8epP5WcO+039HbG9f/scP8/tybVoavGJ/qBonJrSM8MyOHN58lvqaQZzKepiLW6Joi8V TuA6JHEPqfEXWmAiqbPcGROAMbs46x78QXfwQ4taoOpE1w1Yqym+GAqyEBbHSbAJZOTD8Net6wyqO QX8QyQ0il0YDlVWTtkVar10XYWtDak5A1UoXN1NPcQjVXomXIfP6axLqsChnzC3k6Gxrw6FJSzjca YIy0SlqXyN+OGyX6jgPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoEa9-001GnX-2n; Thu, 05 Oct 2023 02:59:21 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoEa5-001GlT-0g for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 02:59:20 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-690f2719ab2so92054b3a.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=lists.infradead.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=WoK8N0wScmNmmg9EQOkabcclB07BXRpj8dqRxCr93a3kQRu6RhATh3PkrqZvR7/CId KhkZXJJ0/aCqFGLk7mBNBff/N4XmADx4j8oWg++VvrokqrJWomZg9aaH1fJpHJOHihyI QnIdLXA5YjosVxDRUZHkAdMT2rtd8O+ji534arv+hpXtOdA6rQ7bIVUugCNWIGUcsyDZ edgyu5JJUHyFCl2tIZxMJXWs84/37vUofRa8DljSqiMhY8WNZkVJgW+R/4AVb7LUYJo6 uJlQzbIvs27kBmlkl3ZsTo2HPkEwp6GPNXwkfoQlzJlUuvyWDsTjGR1k8swKFJzyVCtl pwAg== 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=jQzh+IwzGAdBMgHqFbo05eLv8tIfd2uu0BX9r9PwaXFOyMR+30KZcadsDlqPSPWg8Y 6VwJG21bMgNHzOd8Do+svIXTY5QgID5w5aZ0VETKHmah7AF8fH+kC4PtSrSQpPQqFwbo QEcZ7Ak2Lz/j2S0K6oLjKdsdch5xVesiXYi6GLOtjKPDVn9nnzdPERwD/S2Ddp3PfTFz OZNSD0epxT64BMUD1VSKb+iZ9FlriMoe7L6Nd/o3tIyEUU8R/uFw4ET3T1+gIzT0MnaW UjADkRUTHPCBQCOe0R+iYzxglSfWb7yke+80AUANQ6fPlwoIiXcuBADWXy06deoQEEI1 xS3A== X-Gm-Message-State: AOJu0Yw4QP+yy/fi0Lu8bIsq+iayVuE/g8GCHMDmceM6D1W6K7eZ3dSw IUh/KjDvostqecbXM0U/2DRQXg== X-Google-Smtp-Source: AGHT+IHhyPq2bAIXq1Er7nrpaR11YBXxhlcU8ii3pCisXRHmjRUTM4omwHgQA+YxqvflG1dDFWM5wA== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231004_195917_303983_3D49DB86 X-CRM114-Status: GOOD ( 19.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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