From patchwork Fri Dec 15 14:38:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494542 X-Patchwork-Delegate: mail@conchuod.ie 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 20616C46CC6 for ; Fri, 15 Dec 2023 14:39:27 +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:References:In-Reply-To: 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: List-Owner; bh=AufKvvjDle37g4JMcR5pducS09pQbbYBOg105IFM67Q=; b=RrrIGEiHAjLc47 ihYwZANJ/WiabMfVruseOr2rcqWfV9/QaNGxafrRaYl1iaMkzc+tkbSFg22f0Mm+nwEBCowoEqoBG f3qONcwIDWEHW7t99kpfv8qzTVCzlqxJkWQO8maUheJ/W0JrQKQc0PtV2/UynU+j+BtERzFWlO+2r 9R0tN2pstPvDLlWEEy9Lbhogpyrg4hQI4Xko/Gz4/MaKFd7AIiOD9cr8UxO+pvrEkV33tzksHNhWW knNMjL72kxE2QI6AkgJIFOoSQT8wzhGcW45M1Jn8lY7W1xey92C9/RRiinCB4RGv/lQTuIBaZLPSh eJgwpFKQ7ryn+uAmmGgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LU-003aES-19; Fri, 15 Dec 2023 14:39:20 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LO-003aBh-1N for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:16 +0000 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id B47833F2C3 for ; Fri, 15 Dec 2023 14:39:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651151; bh=DP/Du3U6CUcJgvW/RY0Kd++wZRLCP6RkWeO4awpzGL4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mtSOTMnEZbZm2HdUhiG+KoQq4gaTT2JNNoO2b0WzKGTAh4azqudL9jhbnfUTgPhze HWGkCmbLcVYRgeOt57x5sADSImhr0UBEGeloiE+lD7amgAgxc4IyKGB8xSDhS9NJJF HM2KcANzHE5vo3XK/2vghB6VC9X6vuFtpPQNCtjdECYhMsoGLAD3BNpFwdE5tI15nV pjdh4OW2K0qkh8JRaqrjDmAbJks7Ys/JgFTF4w1sMgWTT3bBtFa+wVbUk/B6Y+ZUfq dv6x7GRM2psMTqPlNWLMI/oMNJHZXM1Nnp2Rye47cMQBFsJLxaU6zcqt6SBQSQ3hc8 +t1MdYGNhen4w== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a00dd93a5f9so45206366b.1 for ; Fri, 15 Dec 2023 06:39:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651151; x=1703255951; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DP/Du3U6CUcJgvW/RY0Kd++wZRLCP6RkWeO4awpzGL4=; b=ZA3rn4V0W0R0XVGzrLg9qTsPvtQ4es344METo39wQZjnZz7uQUlIuep42LSjTdLmSG YyHBC9JsnoQKQNqDUfA8ScDHV4gSXpJn4JeAbZ/l/G1//w5WwLxfSrFuFFNXkvLjB0HO C6W41XJWqF3s4cNntyueOnpacoYFzJMln981pa+RXC67SS/oTe2yMcpz4AKydGuoxGuC ZfFVRzMYiyVRUUpFredE5QYkw33GMdgEkBBkLGHnEHucaYARht/L9dctkFP5R75+MzLo aE274d4iddMWWUcUFxxoEcmGMckaehVaiRARkW7U0kO9LO+I3/UnnxLGj3EsNMweaPVM wO4Q== X-Gm-Message-State: AOJu0YyR8N3b+oMpZ4wb91qsvQiACVwoq+vlY9yl4oeFo3h7c7mghufN fEa/NVXgtE7ReeAx3AOyx15DZKvs+hQIBWErFbEDbOSycdJHUfbFzg0Q5FJiPSa7du4ExyqudVa rZ4n0LWrKfAzT0Bzx0vX8dM4Q8o06hj/HpHxSA9VRSeBFZA== X-Received: by 2002:a17:906:11cb:b0:a1f:69bb:1172 with SMTP id o11-20020a17090611cb00b00a1f69bb1172mr3074861eja.24.1702651151345; Fri, 15 Dec 2023 06:39:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTffL/doR/ETAy/wrSMpH3RUmFY43A+OIfIwmHqAuJ/qR9YE82r4WDCo8NkupJsSz0cvddfw== X-Received: by 2002:a17:906:11cb:b0:a1f:69bb:1172 with SMTP id o11-20020a17090611cb00b00a1f69bb1172mr3074850eja.24.1702651151022; Fri, 15 Dec 2023 06:39:11 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:09 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 1/8] dt-bindings: pinctrl: Add thead,th1520-pinctrl bindings Date: Fri, 15 Dec 2023 15:38:59 +0100 Message-Id: <20231215143906.3651122-2-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063914_628938_DDBBEA07 X-CRM114-Status: GOOD ( 19.94 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add bindings for the pin controllers on the T-Head TH1520 RISC-V SoC. Signed-off-by: Emil Renner Berthing --- .../pinctrl/thead,th1520-pinctrl.yaml | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml new file mode 100644 index 000000000000..1b1b446cd498 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml @@ -0,0 +1,156 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/thead,th1520-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: T-Head TH1520 SoC pin controller + +maintainers: + - Emil Renner Berthing + +description: | + Pinmux and pinconf controller in the T-Head TH1520 RISC-V SoC. + + The TH1520 has 3 groups of pads each controlled from different memory ranges. + Confusingly the memory ranges are named + PADCTRL_AOSYS -> PAD Group 1 + PADCTRL1_APSYS -> PAD Group 2 + PADCTRL0_APSYS -> PAD Group 3 + + Each pad can be muxed individually to up to 5 different functions. For most + pads only a few of those 5 configurations are valid though, and a few pads in + group 1 does not support muxing at all. + + Pinconf is fairly regular except for a few pads in group 1 that either can't + be configured or has some special functions. The rest have configurable drive + strength, input enable, schmitt trigger, slew rate, pull-up and pull-down in + addition to a special strong pull up. + + Certain pads in group 1 can be muxed to AUDIO_PA0 - AUDIO_PA30 functions and + are then meant to be used by the audio co-processor. Each such pad can then + be further muxed to either audio GPIO or one of 4 functions such as UART, I2C + and I2S. If the audio pad is muxed to one of the 4 functions then pinconf is + also configured in different registers. All of this is done from a different + AUDIO_IOCTRL memory range and is left to the audio co-processor for now. + +properties: + compatible: + enum: + - thead,th1520-group1-pinctrl + - thead,th1520-group2-pinctrl + - thead,th1520-group3-pinctrl + + reg: + maxItems: 1 + +patternProperties: + '-[0-9]+$': + type: object + patternProperties: + '-pins$': + type: object + $ref: /schemas/pinctrl/pincfg-node.yaml + description: + A pinctrl node should contain at least one subnode describing one + or more pads and their associated pinmux and pinconf settings. + + properties: + pins: + $ref: /schemas/types.yaml#/definitions/string-array + description: List of pads that properties in the node apply to. + + function: + $ref: /schemas/types.yaml#/definitions/string + enum: [ "0", "1", "2", "3", "4", "5" ] + description: The mux function to select for the given pins. + + bias-disable: true + + bias-pull-up: + type: boolean + + bias-pull-down: + type: boolean + + drive-strength: + enum: [ 1, 2, 3, 5, 7, 8, 10, 12, 13, 15, 16, 18, 20, 21, 23, 25 ] + + input-enable: true + + input-disable: true + + input-schmitt-enable: true + + input-schmitt-disable: true + + slew-rate: + maximum: 1 + + thead,strong-pull-up: + oneOf: + - type: boolean + - $ref: /schemas/types.yaml#/definitions/uint32 + enum: [ 0, 2100 ] + description: Enable or disable strong 2.1kOhm pull-up. + + required: + - pins + + additionalProperties: false + + additionalProperties: false + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + padctrl0_apsys: pinctrl@ec007000 { + compatible = "thead,th1520-group3-pinctrl"; + reg = <0xec007000 0x1000>; + + uart0_pins: uart0-0 { + tx-pins { + pins = "UART0_TXD"; + function = "0"; + bias-disable; + drive-strength = <3>; + input-disable; + input-schmitt-disable; + slew-rate = <0>; + }; + + rx-pins { + pins = "UART0_RXD"; + function = "0"; + bias-disable; + drive-strength = <1>; + input-enable; + input-schmitt-enable; + slew-rate = <0>; + }; + }; + }; + + padctrl1_apsys: pinctrl@e7f3c000 { + compatible = "thead,th1520-group2-pinctrl"; + reg = <0xe7f3c000 0x1000>; + + i2c5_pins: i2c5-0 { + i2c-pins { + pins = "QSPI1_CSN0", /* I2C5_SCL */ + "QSPI1_D0_MOSI"; /* I2C5_SDA */ + function = "2"; + bias-disable; + drive-strength = <7>; + input-enable; + input-schmitt-enable; + slew-rate = <0>; + thead,strong-pull-up; + }; + }; + }; From patchwork Fri Dec 15 14:39:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494548 X-Patchwork-Delegate: mail@conchuod.ie 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 062A7C46CA2 for ; Fri, 15 Dec 2023 14:39:32 +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:References:In-Reply-To: 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: List-Owner; bh=3M32NRJIkbNIopt0Dz2tAdqPDKtsLltdkCyT6OQ0omY=; b=PpSFva8o5AM8OJ CurRM9rH9swUq0ZnVPoLlWHrNXNfOLHuGOBXIvkSgcuyd6+Kd5f19PBwpv7AUuW/Hv9uVNlLV9QD6 ex56SdjSlQFhuZTPvwdD1zMY+Ip4/WCxz6CV3AsdrQ93gHjihlzWkIYvkrti/+UXTngodkZThUCCf DfpJEO6cndujLVcoX+XTf7umLWIf2shMJyqlvJtottAFENBo6758u5U8rKRzKp26qLJx4UQGfbQCH sb9e+DFUWU5jR5BMufcjCnHKmQhkmuYhEmCNLs/lwwGRc3EefWZ3H+T9pLk2oOgwejcYy5qz66wr7 UVfx/IarwHYb4Uizxy1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9La-003aHW-11; Fri, 15 Dec 2023 14:39:26 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LR-003aCN-0d for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:21 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id BEE6C3F2C7 for ; Fri, 15 Dec 2023 14:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651153; bh=IHuqmfxM1RFpCOZW24V35T5fbhzgoWm8g1Op0X+S1yg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QUFaiYJzkgcnzVGuP9e4gYxbuhxJh9WphRvQf5NLyxKH/hqZPPtt6816jVAHRP9kp 1T0O3bUeM2i0Iw2mAYmk89ncRbsvDvH17xfYKYU3vQT4STa5jpnIvKbUXsQCvfmxy3 MRsf3gg/NF1yApgn2daEgtbibmHlisjiOlPbl+wI0dT3VWG9+Hkiu1GeTH896ue09q D9mLB0NW64cLTAjKsdkDdGunW+Wi40XjwlycKzjCm/nOeePcCrq8Sv/KYFmnBV//VV Pw8C+VVasLch6WP3R1BkoLlJtfAIEDDCBAG6432/GGRzctO0Jd5jD3t8/peMweIplf +nmoujergcxWw== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9fd0a58549bso81171466b.0 for ; Fri, 15 Dec 2023 06:39:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651153; x=1703255953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IHuqmfxM1RFpCOZW24V35T5fbhzgoWm8g1Op0X+S1yg=; b=h9DELS2j0dv0q69bH4HwnUgT5FnpdF+qMwuvZ5Y9XPBzLUa6j34szuL3RkSmf9vx+n TfjKU89ut36RT0WWpRPXBPMVsyKGLruN3gaF/IWkL8Gc++ZneZF8YFhpN2fkF4k6daPB 2EGhAErX7AwXNtA+j3ZxQBqqLQ4bRuIOqiRan4T8Y8dhclF8g+QvKX1OS0Wmu5QDUYPs 1UXNRdFFKo83L+IC3RCYjQbQO6QH9F63TBBauV3ORIEGnR0G8haRW3tfh4CE9VhdcW7o OZnKpHq46vmqxlNeZ3KRyNOmiGhBT2bXk25C4fWyCD2U0rK+gdebMgu+lDOCIhyTNt2U amsw== X-Gm-Message-State: AOJu0YwfRT8x7tpl3guN0wpPIddAs8YrA/GcR6h89jIoPYUu95A6mMUa qwZdMI6lU0fZv+qYTkqZn800KXrTZRQ2Dknqnpe+NlNBTQ2Oh2tpShmSR2VJpUH+t03VtRy4svS I5psvdBBUmH5zz0G7Hk/UeO8bni0Yl0jStwRYxnXHQCuGRw== X-Received: by 2002:a17:907:8d8:b0:a1c:7c86:8b79 with SMTP id zu24-20020a17090708d800b00a1c7c868b79mr10066221ejb.26.1702651152862; Fri, 15 Dec 2023 06:39:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3zTYDv+66M/LZryqCshtP3OrfgZ6oU5BL8s79PsMbVrdmlrszwnbKEB/UZm+iY7SbNJB2Hw== X-Received: by 2002:a17:907:8d8:b0:a1c:7c86:8b79 with SMTP id zu24-20020a17090708d800b00a1c7c868b79mr10066211ejb.26.1702651152425; Fri, 15 Dec 2023 06:39:12 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:11 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 2/8] pinctrl: Add driver for the T-Head TH1520 SoC Date: Fri, 15 Dec 2023 15:39:00 +0100 Message-Id: <20231215143906.3651122-3-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063917_505398_FACB24B3 X-CRM114-Status: GOOD ( 20.76 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add pinctrl driver for the T-Head TH1520 RISC-V SoC. Signed-off-by: Emil Renner Berthing --- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 9 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-th1520.c | 796 +++++++++++++++++++++++++++++++ 4 files changed, 807 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-th1520.c diff --git a/MAINTAINERS b/MAINTAINERS index e2c6187a3ac8..7420914c2d77 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18616,6 +18616,7 @@ M: Fu Wei L: linux-riscv@lists.infradead.org S: Maintained F: arch/riscv/boot/dts/thead/ +F: drivers/pinctrl/pinctrl-th1520.c RNBD BLOCK DRIVERS M: Md. Haris Iqbal diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 1de4e1edede0..44426fe0f848 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -469,6 +469,15 @@ config PINCTRL_TB10X depends on OF && ARC_PLAT_TB10X select GPIOLIB +config PINCTRL_TH1520 + tristate "Pinctrl driver for the T-Head TH1520 SoC" + depends on ARCH_THEAD || COMPILE_TEST + select GENERIC_PINMUX_FUNCTIONS + select GENERIC_PINCONF + select PINMUX + help + This selects the pinctrl driver for T-Head TH1520 RISC-V SoC. + config PINCTRL_ZYNQ bool "Pinctrl driver for Xilinx Zynq" depends on ARCH_ZYNQ diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index 37575deb7a69..74350d667add 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -48,6 +48,7 @@ obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o obj-$(CONFIG_PINCTRL_STMFX) += pinctrl-stmfx.o obj-$(CONFIG_PINCTRL_SX150X) += pinctrl-sx150x.o obj-$(CONFIG_PINCTRL_TB10X) += pinctrl-tb10x.o +obj-$(CONFIG_PINCTRL_TH1520) += pinctrl-th1520.o obj-$(CONFIG_PINCTRL_ZYNQMP) += pinctrl-zynqmp.o obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c new file mode 100644 index 000000000000..1efb6ec268e6 --- /dev/null +++ b/drivers/pinctrl/pinctrl-th1520.c @@ -0,0 +1,796 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Pinctrl driver for the T-Head TH1520 SoC + * + * Copyright (C) 2023 Emil Renner Berthing + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "core.h" +#include "pinmux.h" +#include "pinconf.h" + +#define TH1520_PADCFG_IE BIT(9) +#define TH1520_PADCFG_SL BIT(8) +#define TH1520_PADCFG_ST BIT(7) +#define TH1520_PADCFG_SPU BIT(6) +#define TH1520_PADCFG_PS BIT(5) +#define TH1520_PADCFG_PE BIT(4) +#define TH1520_PADCFG_DS GENMASK(3, 0) + +#define TH1520_PULL_DOWN_OHM 44000 /* typ. 44kOhm */ +#define TH1520_PULL_UP_OHM 48000 /* typ. 48kOhm */ +#define TH1520_PULL_STRONG_OHM 2100 /* typ. 2.1kOhm */ + +#define TH1520_FLAG_NO_PADCFG BIT(0) +#define TH1520_FLAG_NO_MUXCFG BIT(1) + +struct th1520_padgroup { + const char *name; + const struct pinctrl_pin_desc *pins; + unsigned int npins; +}; + +struct th1520_pinctrl { + struct pinctrl_desc desc; + struct mutex mutex; /* serialize adding functions */ + raw_spinlock_t lock; /* serialize register access */ + void __iomem *base; + struct pinctrl_dev *pctl; +}; + +static void __iomem *th1520_padcfg(struct th1520_pinctrl *thp, + unsigned int pin) +{ + return thp->base + 4 * (pin / 2); +} + +static unsigned int th1520_padcfg_shift(unsigned int pin) +{ + return 16 * (pin & 0x1U); +} + +static void __iomem *th1520_muxcfg(struct th1520_pinctrl *thp, + unsigned int pin) +{ + return thp->base + 0x400 + 4 * (pin / 8); +} + +static unsigned int th1520_muxcfg_shift(unsigned int pin) +{ + return 4 * (pin & 0x7U); +} + +static const struct pinctrl_pin_desc th1520_group1_pins[] = { + { .number = 0, .name = "OSC_CLK_IN", /* TODO: handle special pad config */ + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + { .number = 1, .name = "OSC_CLK_OUT", + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + { .number = 2, .name = "SYS_RST_N", + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + { .number = 3, .name = "RTC_CLK_IN", /* TODO: handle special pad config */ + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + { .number = 4, .name = "RTC_CLK_OUT", + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + /* + * skip number 5 so we can calculate register + * offsets and shifts from the pin number + */ + { .number = 6, .name = "TEST_MODE", + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + { .number = 7, .name = "DEBUG_MODE", + .drv_data = (void *)TH1520_FLAG_NO_PADCFG }, + { .number = 8, .name = "POR_SEL", + .drv_data = (void *)(TH1520_FLAG_NO_PADCFG | TH1520_FLAG_NO_MUXCFG) }, + PINCTRL_PIN(9, "I2C_AON_SCL"), + PINCTRL_PIN(10, "I2C_AON_SDA"), + PINCTRL_PIN(11, "CPU_JTG_TCLK"), + PINCTRL_PIN(12, "CPU_JTG_TMS"), + PINCTRL_PIN(13, "CPU_JTG_TDI"), + PINCTRL_PIN(14, "CPU_JTG_TDO"), + PINCTRL_PIN(15, "CPU_JTG_TRST"), + PINCTRL_PIN(16, "AOGPIO_7"), + PINCTRL_PIN(17, "AOGPIO_8"), + PINCTRL_PIN(18, "AOGPIO_9"), + PINCTRL_PIN(19, "AOGPIO_10"), + PINCTRL_PIN(20, "AOGPIO_11"), + PINCTRL_PIN(21, "AOGPIO_12"), + PINCTRL_PIN(22, "AOGPIO_13"), + PINCTRL_PIN(23, "AOGPIO_14"), + PINCTRL_PIN(24, "AOGPIO_15"), + PINCTRL_PIN(25, "AUDIO_PA0"), + PINCTRL_PIN(26, "AUDIO_PA1"), + PINCTRL_PIN(27, "AUDIO_PA2"), + PINCTRL_PIN(28, "AUDIO_PA3"), + PINCTRL_PIN(29, "AUDIO_PA4"), + PINCTRL_PIN(30, "AUDIO_PA5"), + PINCTRL_PIN(31, "AUDIO_PA6"), + PINCTRL_PIN(32, "AUDIO_PA7"), + PINCTRL_PIN(33, "AUDIO_PA8"), + PINCTRL_PIN(34, "AUDIO_PA9"), + PINCTRL_PIN(35, "AUDIO_PA10"), + PINCTRL_PIN(36, "AUDIO_PA11"), + PINCTRL_PIN(37, "AUDIO_PA12"), + PINCTRL_PIN(38, "AUDIO_PA13"), + PINCTRL_PIN(39, "AUDIO_PA14"), + PINCTRL_PIN(40, "AUDIO_PA15"), + PINCTRL_PIN(41, "AUDIO_PA16"), + PINCTRL_PIN(42, "AUDIO_PA17"), + PINCTRL_PIN(43, "AUDIO_PA27"), + PINCTRL_PIN(44, "AUDIO_PA28"), + PINCTRL_PIN(45, "AUDIO_PA29"), + PINCTRL_PIN(46, "AUDIO_PA30"), +}; + +static const struct th1520_padgroup th1520_group1 = { + .name = "th1520-group1", + .pins = th1520_group1_pins, + .npins = ARRAY_SIZE(th1520_group1_pins), +}; + +static const struct pinctrl_pin_desc th1520_group2_pins[] = { + PINCTRL_PIN(0, "QSPI1_SCLK"), + PINCTRL_PIN(1, "QSPI1_CSN0"), + PINCTRL_PIN(2, "QSPI1_D0_MOSI"), + PINCTRL_PIN(3, "QSPI1_D1_MISO"), + PINCTRL_PIN(4, "QSPI1_D2_WP"), + PINCTRL_PIN(5, "QSPI1_D3_HOLD"), + PINCTRL_PIN(6, "I2C0_SCL"), + PINCTRL_PIN(7, "I2C0_SDA"), + PINCTRL_PIN(8, "I2C1_SCL"), + PINCTRL_PIN(9, "I2C1_SDA"), + PINCTRL_PIN(10, "UART1_TXD"), + PINCTRL_PIN(11, "UART1_RXD"), + PINCTRL_PIN(12, "UART4_TXD"), + PINCTRL_PIN(13, "UART4_RXD"), + PINCTRL_PIN(14, "UART4_CTSN"), + PINCTRL_PIN(15, "UART4_RTSN"), + PINCTRL_PIN(16, "UART3_TXD"), + PINCTRL_PIN(17, "UART3_RXD"), + PINCTRL_PIN(18, "GPIO0_18"), + PINCTRL_PIN(19, "GPIO0_19"), + PINCTRL_PIN(20, "GPIO0_20"), + PINCTRL_PIN(21, "GPIO0_21"), + PINCTRL_PIN(22, "GPIO0_22"), + PINCTRL_PIN(23, "GPIO0_23"), + PINCTRL_PIN(24, "GPIO0_24"), + PINCTRL_PIN(25, "GPIO0_25"), + PINCTRL_PIN(26, "GPIO0_26"), + PINCTRL_PIN(27, "GPIO0_27"), + PINCTRL_PIN(28, "GPIO0_28"), + PINCTRL_PIN(29, "GPIO0_29"), + PINCTRL_PIN(30, "GPIO0_30"), + PINCTRL_PIN(31, "GPIO0_31"), + PINCTRL_PIN(32, "GPIO1_0"), + PINCTRL_PIN(33, "GPIO1_1"), + PINCTRL_PIN(34, "GPIO1_2"), + PINCTRL_PIN(35, "GPIO1_3"), + PINCTRL_PIN(36, "GPIO1_4"), + PINCTRL_PIN(37, "GPIO1_5"), + PINCTRL_PIN(38, "GPIO1_6"), + PINCTRL_PIN(39, "GPIO1_7"), + PINCTRL_PIN(40, "GPIO1_8"), + PINCTRL_PIN(41, "GPIO1_9"), + PINCTRL_PIN(42, "GPIO1_10"), + PINCTRL_PIN(43, "GPIO1_11"), + PINCTRL_PIN(44, "GPIO1_12"), + PINCTRL_PIN(45, "GPIO1_13"), + PINCTRL_PIN(46, "GPIO1_14"), + PINCTRL_PIN(47, "GPIO1_15"), + PINCTRL_PIN(48, "GPIO1_16"), + PINCTRL_PIN(49, "CLK_OUT_0"), + PINCTRL_PIN(50, "CLK_OUT_1"), + PINCTRL_PIN(51, "CLK_OUT_2"), + PINCTRL_PIN(52, "CLK_OUT_3"), + PINCTRL_PIN(53, "GPIO1_21"), + PINCTRL_PIN(54, "GPIO1_22"), + PINCTRL_PIN(55, "GPIO1_23"), + PINCTRL_PIN(56, "GPIO1_24"), + PINCTRL_PIN(57, "GPIO1_25"), + PINCTRL_PIN(58, "GPIO1_26"), + PINCTRL_PIN(59, "GPIO1_27"), + PINCTRL_PIN(60, "GPIO1_28"), + PINCTRL_PIN(61, "GPIO1_29"), + PINCTRL_PIN(62, "GPIO1_30"), +}; + +static const struct th1520_padgroup th1520_group2 = { + .name = "th1520-group2", + .pins = th1520_group2_pins, + .npins = ARRAY_SIZE(th1520_group2_pins), +}; + +static const struct pinctrl_pin_desc th1520_group3_pins[] = { + PINCTRL_PIN(0, "UART0_TXD"), + PINCTRL_PIN(1, "UART0_RXD"), + PINCTRL_PIN(2, "QSPI0_SCLK"), + PINCTRL_PIN(3, "QSPI0_CSN0"), + PINCTRL_PIN(4, "QSPI0_CSN1"), + PINCTRL_PIN(5, "QSPI0_D0_MOSI"), + PINCTRL_PIN(6, "QSPI0_D1_MISO"), + PINCTRL_PIN(7, "QSPI0_D2_WP"), + PINCTRL_PIN(8, "QSPI1_D3_HOLD"), + PINCTRL_PIN(9, "I2C2_SCL"), + PINCTRL_PIN(10, "I2C2_SDA"), + PINCTRL_PIN(11, "I2C3_SCL"), + PINCTRL_PIN(12, "I2C3_SDA"), + PINCTRL_PIN(13, "GPIO2_13"), + PINCTRL_PIN(14, "SPI_SCLK"), + PINCTRL_PIN(15, "SPI_CSN"), + PINCTRL_PIN(16, "SPI_MOSI"), + PINCTRL_PIN(17, "SPI_MISO"), + PINCTRL_PIN(18, "GPIO2_18"), + PINCTRL_PIN(19, "GPIO2_19"), + PINCTRL_PIN(20, "GPIO2_20"), + PINCTRL_PIN(21, "GPIO2_21"), + PINCTRL_PIN(22, "GPIO2_22"), + PINCTRL_PIN(23, "GPIO2_23"), + PINCTRL_PIN(24, "GPIO2_24"), + PINCTRL_PIN(25, "GPIO2_25"), + PINCTRL_PIN(26, "SDIO0_WPRTN"), + PINCTRL_PIN(27, "SDIO0_DETN"), + PINCTRL_PIN(28, "SDIO1_WPRTN"), + PINCTRL_PIN(29, "SDIO1_DETN"), + PINCTRL_PIN(30, "GPIO2_30"), + PINCTRL_PIN(31, "GPIO2_31"), + PINCTRL_PIN(32, "GPIO3_0"), + PINCTRL_PIN(33, "GPIO3_1"), + PINCTRL_PIN(34, "GPIO3_2"), + PINCTRL_PIN(35, "GPIO3_3"), + PINCTRL_PIN(36, "HDMI_SCL"), + PINCTRL_PIN(37, "HDMI_SDA"), + PINCTRL_PIN(38, "HDMI_CEC"), + PINCTRL_PIN(39, "GMAC0_TX_CLK"), + PINCTRL_PIN(40, "GMAC0_RX_CLK"), + PINCTRL_PIN(41, "GMAC0_TXEN"), + PINCTRL_PIN(42, "GMAC0_TXD0"), + PINCTRL_PIN(43, "GMAC0_TXD1"), + PINCTRL_PIN(44, "GMAC0_TXD2"), + PINCTRL_PIN(45, "GMAC0_TXD3"), + PINCTRL_PIN(46, "GMAC0_RXDV"), + PINCTRL_PIN(47, "GMAC0_RXD0"), + PINCTRL_PIN(48, "GMAC0_RXD1"), + PINCTRL_PIN(49, "GMAC0_RXD2"), + PINCTRL_PIN(50, "GMAC0_RXD3"), + PINCTRL_PIN(51, "GMAC0_MDC"), + PINCTRL_PIN(52, "GMAC0_MDIO"), + PINCTRL_PIN(53, "GMAC0_COL"), + PINCTRL_PIN(54, "GMAC0_CRS"), +}; + +static const struct th1520_padgroup th1520_group3 = { + .name = "th1520-group3", + .pins = th1520_group3_pins, + .npins = ARRAY_SIZE(th1520_group3_pins), +}; + +static int th1520_pinctrl_get_groups_count(struct pinctrl_dev *pctldev) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + + return thp->desc.npins; +} + +static const char *th1520_pinctrl_get_group_name(struct pinctrl_dev *pctldev, + unsigned int gsel) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + + return thp->desc.pins[gsel].name; +} + +static int th1520_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, + unsigned int gsel, + const unsigned int **pins, + unsigned int *npins) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + + *pins = &thp->desc.pins[gsel].number; + *npins = 1; + return 0; +} + +#ifdef CONFIG_DEBUG_FS +static void th1520_pin_dbg_show(struct pinctrl_dev *pctldev, + struct seq_file *s, unsigned int pin) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + void __iomem *padcfg = th1520_padcfg(thp, pin); + void __iomem *muxcfg = th1520_muxcfg(thp, pin); + unsigned long flags; + u32 pad; + u32 mux; + + raw_spin_lock_irqsave(&thp->lock, flags); + pad = readl_relaxed(padcfg); + mux = readl_relaxed(muxcfg); + raw_spin_unlock_irqrestore(&thp->lock, flags); + + seq_printf(s, "[PADCFG_%03u:0x%x=0x%07x MUXCFG_%03u:0x%x=0x%08x]", + 1 + pin / 2, 0x000 + 4 * (pin / 2), pad, + 1 + pin / 8, 0x400 + 4 * (pin / 8), mux); +} +#else +#define th1520_pin_dbg_show NULL +#endif + +static void th1520_pinctrl_dt_free_map(struct pinctrl_dev *pctldev, + struct pinctrl_map *map, unsigned int nmaps) +{ + unsigned long *seen = NULL; + unsigned int i; + + for (i = 0; i < nmaps; i++) { + if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN && + map[i].data.configs.configs != seen) { + seen = map[i].data.configs.configs; + kfree(seen); + } + } + + kfree(map); +} + +static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, + struct device_node *np, + struct pinctrl_map **maps, + unsigned int *num_maps) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + struct device_node *child; + struct pinctrl_map *map; + unsigned long *configs; + unsigned int nconfigs; + unsigned int nmaps; + int ret; + + nmaps = 0; + for_each_available_child_of_node(np, child) { + int npins = of_property_count_strings(child, "pins"); + + if (npins <= 0) { + of_node_put(child); + return dev_err_probe(thp->pctl->dev, -EINVAL, + "no pins selected for %pOFn.%pOFn\n", + np, child); + } + nmaps += npins; + if (of_property_present(child, "function")) + nmaps += npins; + } + + map = kcalloc(nmaps, sizeof(*map), GFP_KERNEL); + if (!map) + return -ENOMEM; + + nmaps = 0; + mutex_lock(&thp->mutex); + for_each_available_child_of_node(np, child) { + unsigned int rollback = nmaps; + struct property *prop; + const char *funcname; + const char **pgnames; + const char *pinname; + uintptr_t muxdata; + int npins; + + ret = pinconf_generic_parse_dt_config(child, pctldev, &configs, &nconfigs); + if (ret) { + dev_err(thp->pctl->dev, "error parsing pin config of group %pOFn.%pOFn\n", + np, child); + goto put_child; + } + + if (!of_property_read_string(child, "function", &funcname)) { + if (funcname[0] < '0' || funcname[0] > '5' || funcname[1]) { + ret = -EINVAL; + dev_err(thp->pctl->dev, "%pOFn.%pOFn: invalid function '%s'\n", + np, child, funcname); + goto free_configs; + } + + muxdata = funcname[0] - '0'; + funcname = devm_kasprintf(thp->pctl->dev, GFP_KERNEL, "%pOFn.%pOFn", + np, child); + if (!funcname) { + ret = -ENOMEM; + goto free_configs; + } + + npins = of_property_count_strings(child, "pins"); + pgnames = devm_kcalloc(thp->pctl->dev, npins, sizeof(*pgnames), GFP_KERNEL); + if (!pgnames) { + ret = -ENOMEM; + goto free_configs; + } + } else { + funcname = NULL; + } + + npins = 0; + of_property_for_each_string(child, "pins", prop, pinname) { + unsigned int i; + + for (i = 0; i < thp->desc.npins; i++) { + if (!strcmp(pinname, thp->desc.pins[i].name)) + break; + } + if (i == thp->desc.npins) { + nmaps = rollback; + dev_err(thp->pctl->dev, "%pOFn.%pOFn: unknown pin '%s'\n", + np, child, pinname); + goto free_configs; + } + + if (nconfigs) { + map[nmaps].type = PIN_MAP_TYPE_CONFIGS_PIN; + map[nmaps].data.configs.group_or_pin = thp->desc.pins[i].name; + map[nmaps].data.configs.configs = configs; + map[nmaps].data.configs.num_configs = nconfigs; + nmaps += 1; + } + if (funcname) { + pgnames[npins++] = thp->desc.pins[i].name; + map[nmaps].type = PIN_MAP_TYPE_MUX_GROUP; + map[nmaps].data.mux.function = funcname; + map[nmaps].data.mux.group = thp->desc.pins[i].name; + nmaps += 1; + } + } + + if (funcname) { + ret = pinmux_generic_add_function(pctldev, funcname, pgnames, + npins, (void *)muxdata); + if (ret < 0) { + dev_err(thp->pctl->dev, "error adding function %s\n", funcname); + goto put_child; + } + } + } + + *maps = map; + *num_maps = nmaps; + mutex_unlock(&thp->mutex); + return 0; + +free_configs: + kfree(configs); +put_child: + of_node_put(child); + th1520_pinctrl_dt_free_map(pctldev, map, nmaps); + mutex_unlock(&thp->mutex); + return ret; +} + +static const struct pinctrl_ops th1520_pinctrl_ops = { + .get_groups_count = th1520_pinctrl_get_groups_count, + .get_group_name = th1520_pinctrl_get_group_name, + .get_group_pins = th1520_pinctrl_get_group_pins, + .pin_dbg_show = th1520_pin_dbg_show, + .dt_node_to_map = th1520_pinctrl_dt_node_to_map, + .dt_free_map = th1520_pinctrl_dt_free_map, +}; + +static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev, + unsigned int fsel, unsigned int gsel) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel); + unsigned int pin = thp->desc.pins[gsel].number; + void __iomem *muxcfg = th1520_muxcfg(thp, pin); + unsigned int shift = th1520_muxcfg_shift(pin); + unsigned long flags; + u32 mask; + u32 value; + + if (!func || (uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_FLAG_NO_MUXCFG) + return -EINVAL; + + mask = 0xfU << shift; + value = ((uintptr_t)func->data & 0xfU) << shift; + + raw_spin_lock_irqsave(&thp->lock, flags); + value |= readl_relaxed(muxcfg) & ~mask; + writel_relaxed(value, muxcfg); + raw_spin_unlock_irqrestore(&thp->lock, flags); + + return 0; +} + +static const struct pinmux_ops th1520_pinmux_ops = { + .get_functions_count = pinmux_generic_get_function_count, + .get_function_name = pinmux_generic_get_function_name, + .get_function_groups = pinmux_generic_get_function_groups, + .set_mux = th1520_pinmux_set_mux, + .strict = true, +}; + +static const u8 th1520_drive_strength_in_mA[16] = { + 1, 2, 3, 5, 7, 8, 10, 12, 13, 15, 16, 18, 20, 21, 23, 25, +}; + +static u16 th1520_drive_strength_from_mA(u32 arg) +{ + u16 v; + + for (v = 0; v < ARRAY_SIZE(th1520_drive_strength_in_mA) - 1; v++) { + if (arg <= th1520_drive_strength_in_mA[v]) + break; + } + + return v; +} + +static int th1520_padcfg_rmw(struct th1520_pinctrl *thp, unsigned int pin, + u16 _mask, u16 _value) +{ + void __iomem *padcfg = th1520_padcfg(thp, pin); + unsigned int shift = th1520_padcfg_shift(pin); + u32 mask = (u32)_mask << shift; + u32 value = (u32)_value << shift; + unsigned long flags; + + raw_spin_lock_irqsave(&thp->lock, flags); + value |= readl_relaxed(padcfg) & ~mask; + writel_relaxed(value, padcfg); + raw_spin_unlock_irqrestore(&thp->lock, flags); + return 0; +} + +#define PIN_CONFIG_THEAD_STRONG_PULL_UP (PIN_CONFIG_END + 1) +static const struct pinconf_generic_params th1520_pinconf_custom_params[] = { + { "thead,strong-pull-up", PIN_CONFIG_THEAD_STRONG_PULL_UP, 1 }, +}; + +#ifdef CONFIG_DEBUG_FS +static const struct pin_config_item th1520_pinconf_custom_conf_items[] = { + PCONFDUMP(PIN_CONFIG_THEAD_STRONG_PULL_UP, "input bias strong pull-up", "ohms", true), +}; +static_assert(ARRAY_SIZE(th1520_pinconf_custom_conf_items) == + ARRAY_SIZE(th1520_pinconf_custom_params)); +#else +#define th1520_pinconf_custom_conf_items NULL +#endif + +static int th1520_pinconf_get(struct pinctrl_dev *pctldev, + unsigned int pin, unsigned long *config) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + const struct pin_desc *desc = pin_desc_get(pctldev, pin); + bool enabled; + int param; + u32 value; + u32 arg; + + if ((uintptr_t)desc->drv_data & TH1520_FLAG_NO_PADCFG) + return -ENOTSUPP; + + value = readl_relaxed(th1520_padcfg(thp, pin)); + value = (value >> th1520_padcfg_shift(pin)) & 0x3ffU; + + param = pinconf_to_config_param(*config); + switch (param) { + case PIN_CONFIG_BIAS_DISABLE: + enabled = !(value & TH1520_PADCFG_PE); + arg = 0; + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + enabled = (value & (TH1520_PADCFG_PE | TH1520_PADCFG_PS)) == + TH1520_PADCFG_PE; + arg = enabled ? TH1520_PULL_DOWN_OHM : 0; + break; + case PIN_CONFIG_BIAS_PULL_UP: + enabled = (value & (TH1520_PADCFG_PE | TH1520_PADCFG_PS)) == + (TH1520_PADCFG_PE | TH1520_PADCFG_PS); + arg = enabled ? TH1520_PULL_UP_OHM : 0; + break; + case PIN_CONFIG_DRIVE_STRENGTH: + enabled = true; + arg = th1520_drive_strength_in_mA[value & TH1520_PADCFG_DS]; + break; + case PIN_CONFIG_INPUT_ENABLE: + enabled = value & TH1520_PADCFG_IE; + arg = enabled; + break; + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + enabled = value & TH1520_PADCFG_ST; + arg = enabled; + break; + case PIN_CONFIG_SLEW_RATE: + enabled = value & TH1520_PADCFG_SL; + arg = enabled; + break; + case PIN_CONFIG_THEAD_STRONG_PULL_UP: + enabled = value & TH1520_PADCFG_SPU; + arg = enabled ? TH1520_PULL_STRONG_OHM : 0; + break; + default: + return -ENOTSUPP; + } + + *config = pinconf_to_config_packed(param, arg); + return enabled ? 0 : -EINVAL; +} + +static int th1520_pinconf_group_get(struct pinctrl_dev *pctldev, + unsigned int gsel, unsigned long *config) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + unsigned int pin = thp->desc.pins[gsel].number; + + return th1520_pinconf_get(pctldev, pin, config); +} + +static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, + unsigned long *configs, unsigned int num_configs) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + unsigned int i; + u16 mask = 0; + u16 value = 0; + + for (i = 0; i < num_configs; i++) { + int param = pinconf_to_config_param(configs[i]); + u32 arg = pinconf_to_config_argument(configs[i]); + + switch (param) { + case PIN_CONFIG_BIAS_DISABLE: + mask |= TH1520_PADCFG_PE; + value &= ~TH1520_PADCFG_PE; + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + if (arg == 0) + return -ENOTSUPP; + mask |= TH1520_PADCFG_PS; + value &= ~TH1520_PADCFG_PS; + break; + case PIN_CONFIG_BIAS_PULL_UP: + if (arg == 0) + return -ENOTSUPP; + mask |= TH1520_PADCFG_PS; + value |= TH1520_PADCFG_PS; + break; + case PIN_CONFIG_DRIVE_STRENGTH: + mask |= TH1520_PADCFG_DS; + value = (value & ~TH1520_PADCFG_DS) | + th1520_drive_strength_from_mA(arg); + break; + case PIN_CONFIG_INPUT_ENABLE: + mask |= TH1520_PADCFG_IE; + if (arg) + value |= TH1520_PADCFG_IE; + else + value &= ~TH1520_PADCFG_IE; + break; + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + mask |= TH1520_PADCFG_ST; + if (arg) + value |= TH1520_PADCFG_ST; + else + value &= ~TH1520_PADCFG_ST; + break; + case PIN_CONFIG_SLEW_RATE: + mask |= TH1520_PADCFG_SL; + if (arg) + value |= TH1520_PADCFG_SL; + else + value &= ~TH1520_PADCFG_SL; + break; + case PIN_CONFIG_THEAD_STRONG_PULL_UP: + mask |= TH1520_PADCFG_SPU; + if (arg) + value |= TH1520_PADCFG_SPU; + else + value &= ~TH1520_PADCFG_SPU; + break; + default: + return -ENOTSUPP; + } + } + + return th1520_padcfg_rmw(thp, pin, mask, value); +} + +static int th1520_pinconf_group_set(struct pinctrl_dev *pctldev, + unsigned int gsel, + unsigned long *configs, + unsigned int num_configs) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + unsigned int pin = thp->desc.pins[gsel].number; + + return th1520_pinconf_set(pctldev, pin, configs, num_configs); +} + +#ifdef CONFIG_DEBUG_FS +static void th1520_pinconf_dbg_show(struct pinctrl_dev *pctldev, + struct seq_file *s, unsigned int pin) +{ + struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); + u32 value = readl_relaxed(th1520_padcfg(thp, pin)); + + value = (value >> th1520_padcfg_shift(pin)) & 0x3ffU; + + seq_printf(s, " [0x%03x]", value); +} +#else +#define th1520_pinconf_dbg_show NULL +#endif + +static const struct pinconf_ops th1520_pinconf_ops = { + .pin_config_get = th1520_pinconf_get, + .pin_config_group_get = th1520_pinconf_group_get, + .pin_config_set = th1520_pinconf_set, + .pin_config_group_set = th1520_pinconf_group_set, + .pin_config_dbg_show = th1520_pinconf_dbg_show, + .is_generic = true, +}; + +static int th1520_pinctrl_probe(struct platform_device *pdev) +{ + const struct th1520_padgroup *group = device_get_match_data(&pdev->dev); + struct th1520_pinctrl *thp; + int ret; + + thp = devm_kzalloc(&pdev->dev, sizeof(*thp), GFP_KERNEL); + if (!thp) + return -ENOMEM; + + thp->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(thp->base)) + return PTR_ERR(thp->base); + + thp->desc.name = group->name; + thp->desc.pins = group->pins; + thp->desc.npins = group->npins; + thp->desc.pctlops = &th1520_pinctrl_ops; + thp->desc.pmxops = &th1520_pinmux_ops; + thp->desc.confops = &th1520_pinconf_ops; + thp->desc.owner = THIS_MODULE; + thp->desc.num_custom_params = ARRAY_SIZE(th1520_pinconf_custom_params); + thp->desc.custom_params = th1520_pinconf_custom_params; + thp->desc.custom_conf_items = th1520_pinconf_custom_conf_items; + mutex_init(&thp->mutex); + raw_spin_lock_init(&thp->lock); + + ret = devm_pinctrl_register_and_init(&pdev->dev, &thp->desc, thp, &thp->pctl); + if (ret) + return dev_err_probe(&pdev->dev, ret, "could not register pinctrl driver\n"); + + return pinctrl_enable(thp->pctl); +} + +static const struct of_device_id th1520_pinctrl_of_match[] = { + { .compatible = "thead,th1520-group1-pinctrl", .data = &th1520_group1 }, + { .compatible = "thead,th1520-group2-pinctrl", .data = &th1520_group2 }, + { .compatible = "thead,th1520-group3-pinctrl", .data = &th1520_group3 }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, th1520_pinctrl_of_match); + +static struct platform_driver th1520_pinctrl_driver = { + .probe = th1520_pinctrl_probe, + .driver = { + .name = "pinctrl-th1520", + .of_match_table = th1520_pinctrl_of_match, + }, +}; +module_platform_driver(th1520_pinctrl_driver); + +MODULE_DESCRIPTION("Pinctrl driver for the T-Head TH1520 SoC"); +MODULE_AUTHOR("Emil Renner Berthing "); +MODULE_LICENSE("GPL"); From patchwork Fri Dec 15 14:39:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494540 X-Patchwork-Delegate: mail@conchuod.ie 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 C83DEC41535 for ; Fri, 15 Dec 2023 14:39:26 +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:References:In-Reply-To: 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: List-Owner; bh=NbpVUnZsmSYlGbTcEWMSZ636GNDAyvweks45iCA7Zgg=; b=z6se/zeG+rkmA6 VRwTOAYyxkfCTBTz40WaSiMLWICFKVqsq7guhHj/YJQWPP0m6JRePI6KS5Lkg+nRMw7K3aHcfmD59 pUyzBBi8Fvf0oG2L3xAiBwgGPbarYpjCNicl+/T6suid6tikDswI0ljrAvhS754/1ndQjYS+U9lXp +8W9LhjLCm6D0+LZuqfJ6lJVCXOJ+Xmfku76Mu7BPWvho8MxkDAd924Rd9/En6YdXDKax+tIOKSrA CM/DFDB4kOqqGs9mmDKl+gJ0SKzMv5ErEvFSRlIsDTVO/eAZ1YqTIWtURu6KC+TkJeNArEmlzyhKx mYLGlgerZKfBgGe0Pkbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LV-003aEv-00; Fri, 15 Dec 2023 14:39:21 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LR-003aCO-0d for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:18 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 645F53F2CC for ; Fri, 15 Dec 2023 14:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651154; bh=RobAsopvkyaJG4ZlGH6Q+ihyPFqhE+HxeBCHD/K5fRk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JveIQFn2hQtiyEGthTh3fz27PLBh02oceELhU88h2YjgRTXCJYOY0JUZ+vYeU3i3W d8ToUf4a3ADU9cvRYxnL7sp7OnVFU+kdzfBlHhAXj/cLKY+DhCgEklXlR5MiWV1IQG K4OTjk1gGeDQNunql/fABmy0Pt9168sPtJz8DnDnLSium2duC9Ysvaz62cTPyo3uNw qRoCmrbIQLAeRFfO0WNhWAZVi7u1RsihmSVxcBNt8p4vCHJilN+ACd0DdzB/LUd/GQ 6wBgNRZ090lYheME1O2MGw6c089o0Cz3wcVzR3C5k9dcd26eJTENBpHPvZFZLb4Kwe ywC/z0ICQJ51Q== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a1d0182f0e5so29055966b.0 for ; Fri, 15 Dec 2023 06:39:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651153; x=1703255953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RobAsopvkyaJG4ZlGH6Q+ihyPFqhE+HxeBCHD/K5fRk=; b=PB3i1k9iKbygB8DdjzGFA2Hlt9Giy5VgaC0o7eQdOSmD2x7jqk7uhgIBALcQQg6D1H p407ao1x/6esUcnOjqBuRmkM9ywH8X36wVh3ZlioJnwshnoigxiGIoY3lmpgqw2vY6tI sFANA6fvzCOZWD+FyCz/u0VzhvhNHglwzi7XGQpk3UzDsifrPfiVFYTfOTDJDY5sCqNU xihYBmroLs4EhlA3sGeMiekQUUNW4OssuA3odiPT9APa8m4k+jdpRYvift26P42GdBiJ lo+l+e1Qwd1DTNf06HqdrKiAdoJs0vXiVK73HApvDBwpWqwVshuPhjzFBMAcYIzoGjPs W17Q== X-Gm-Message-State: AOJu0YzULv1TKMAQ8iPkKoBUHjUL75S1pZ+ZXILg3emFwPD3KZ1eb34R Yw3Fex7vNDzH/ve3MyCHk2yF5jZhJU8EkqgPmV6gqEaRXHcuoqTBJjbenZzqd5oFUR8Q+9F9fAV MpRypqFCIlisCU+EywBrhgchrj1MOhlStAznSgx1a4vzpjg== X-Received: by 2002:a17:907:9714:b0:a04:bc39:c1c7 with SMTP id jg20-20020a170907971400b00a04bc39c1c7mr8341366ejc.36.1702651153752; Fri, 15 Dec 2023 06:39:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMJ/XNk1OcnlxBlTONG8qxR+NbDMfjb9FP+RE/bMN9YTONgYiMhiDoaYwky2i3vk37hslVhA== X-Received: by 2002:a17:907:9714:b0:a04:bc39:c1c7 with SMTP id jg20-20020a170907971400b00a04bc39c1c7mr8341347ejc.36.1702651153594; Fri, 15 Dec 2023 06:39:13 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:13 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 3/8] riscv: dts: thead: Add TH1520 pin control nodes Date: Fri, 15 Dec 2023 15:39:01 +0100 Message-Id: <20231215143906.3651122-4-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063917_364398_5DBAD9C8 X-CRM114-Status: UNSURE ( 9.55 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add nodes for pin controllers on the T-Head TH1520 RISC-V SoC. Signed-off-by: Emil Renner Berthing --- arch/riscv/boot/dts/thead/th1520.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index ba4d2c673ac8..397d5c71bd3d 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -242,6 +242,11 @@ portd: gpio-controller@0 { }; }; + padctrl1_apsys: pinctrl@ffe7f3c000 { + compatible = "thead,th1520-group2-pinctrl"; + reg = <0xff 0xe7f3c000 0x0 0x1000>; + }; + gpio0: gpio@ffec005000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xec005000 0x0 0x1000>; @@ -278,6 +283,11 @@ portb: gpio-controller@0 { }; }; + padctrl0_apsys: pinctrl@ffec007000 { + compatible = "thead,th1520-group3-pinctrl"; + reg = <0xff 0xec007000 0x0 0x1000>; + }; + uart2: serial@ffec010000 { compatible = "snps,dw-apb-uart"; reg = <0xff 0xec010000 0x0 0x4000>; @@ -414,6 +424,11 @@ porte: gpio-controller@0 { }; }; + padctrl_aosys: pinctrl@fffff4a000 { + compatible = "thead,th1520-group1-pinctrl"; + reg = <0xff 0xfff4a000 0x0 0x2000>; + }; + ao_gpio1: gpio@fffff52000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xfff52000 0x0 0x1000>; From patchwork Fri Dec 15 14:39:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494543 X-Patchwork-Delegate: mail@conchuod.ie 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 1C2E1C46CA2 for ; Fri, 15 Dec 2023 14:39:27 +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:References:In-Reply-To: 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: List-Owner; bh=za9gmJOlGEdIVPmW5RzsI8eaiUK+0N637WNz+9ZMx2s=; b=Q5kMqlztUlAMcR vFsaZ1af78VptjXTEjpADHUeSmaAn0Zymq/my7bIZZi4HeeZO8qvT/XP9E+rHX34jfPbAKHqRpC3d uOh/mm6SSD750TElEeAuIQO0TbhF+pSLPLwIaRpvM1egikQJ8oqxyqXNL+h061PnZDas1r0j0gFTb o/3wp6X7xP9WJu8FSQrdYHSU30JTuFu7Y2dl0bYeK1VhbaC1JwEIUaiyablQant4K8YobcAsmHSCM 90o/ca9nk8TIKlzf9QfSgtgSK+RNrfex0uGSAaTCmeTw24PnNkoaiBQ8GDkJqiJiyjycN1dOiRJOk BmOxUJ1FzwZNQCmqyG1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LV-003aFh-2H; Fri, 15 Dec 2023 14:39:21 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LR-003aCP-0d for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:18 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 644533F2D5 for ; Fri, 15 Dec 2023 14:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651155; bh=5d0QhzVl7C6w8MyPA6on/NHcmfCtxfOh1Mcdqcw1JG8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bYyoIIIowGXb8//aNctKmzMiKCGa/JuSam238X5sqVLTTfamCwaOp7byQroAeLf2R MkGlJ1IidyBUf0UKL/XL7gLyGGutEzIjB0ko1xeZiAXQx33oBqUs5rR27H8tyN8doy S56IVYdK5c3wnNaOjB0LcJXycO+UoG0vZ1Fzj3pLP0xHCmq0mBaX2F3D0CQjs6C43O 3caJXM2Lf1rt2UZHjwgsajr48phtYwpKLhZjWSqaWc1/rW6iNpWNCdK9y2TtTXgLLj sTbi/lhNSnPO3P6PNXoDdIxyoz6pdF8CcLgyTb95wYQ7kUwH1Bb06/6zXKQ4MmSWDK aMxKWbDOXELwg== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a1da829c653so44935266b.3 for ; Fri, 15 Dec 2023 06:39:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651155; x=1703255955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5d0QhzVl7C6w8MyPA6on/NHcmfCtxfOh1Mcdqcw1JG8=; b=hzx5+9JfyJ+ZsNV/mRoZY4czdwHD4dI5pguitmtOmgjR+dIky+xddTtVSBF2HhBZ0x H7fg4YCUN3fmimLKNLUno9S0jbI3U89xGbfGQuY0rahsz1mQINEBSVa4niU2WtExeJ9V 35UpL/P6GojLpf60KjkVxVbJcKSDEgIZsQjeYglOupwF7XaywlG/uIbqFTZnKMvJKt9f deEnQV43wWQkeJyvTPNNv66hFVNRp0r0znUAR05HHnU2ZCajGmOEVvvQ7rz2JusvytFG fj0QZRLg3hm0H3kY51cKgt5V08a4qyYnl9JpvXfG8LsFHcH3Sja2C/mmUGBTMEWQxKMp u4xw== X-Gm-Message-State: AOJu0YwS8IMJyPjowx56raONeBbIKPt6OULNfW4xaRgVn4iL3ORrZWUr 34Hmw4Lf3B6+8LixDRiL92/Fb2P3iC090hphPsSqd3EOZm2BSehLFCzzpQcHjs8MoyHpkF7kRyU uU0i2tYRYG8K4v2xr8c1ASX6toKajAXBYp0Xrl2H3v1fbFg== X-Received: by 2002:a17:907:e88:b0:a1c:ad6e:f27b with SMTP id ho8-20020a1709070e8800b00a1cad6ef27bmr3397169ejc.78.1702651154973; Fri, 15 Dec 2023 06:39:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhb7PhCXQlTmlO8Dr2ltcQSzgklP4jZY0/NHHCOpfEFcHKcRabJYeTEWK6MtrnQyFAiYLIWg== X-Received: by 2002:a17:907:e88:b0:a1c:ad6e:f27b with SMTP id ho8-20020a1709070e8800b00a1cad6ef27bmr3397152ejc.78.1702651154724; Fri, 15 Dec 2023 06:39:14 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:14 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 4/8] dt-bindings: gpio: dwapb: allow gpio-ranges Date: Fri, 15 Dec 2023 15:39:02 +0100 Message-Id: <20231215143906.3651122-5-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063917_373660_BC19A8A5 X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Allow the generic gpio-ranges property so GPIOs can be mapped to their corresponding pin. This way control of GPIO on pins that are already used by other peripherals can be denied and basic pinconf can be done on pin controllers that support it. Signed-off-by: Emil Renner Berthing Acked-by: Rob Herring --- Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml b/Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml index eefe7b345286..ab2afc0e4153 100644 --- a/Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml +++ b/Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml @@ -65,6 +65,8 @@ patternProperties: minItems: 1 maxItems: 32 + gpio-ranges: true + ngpios: default: 32 minimum: 1 From patchwork Fri Dec 15 14:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494544 X-Patchwork-Delegate: mail@conchuod.ie 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 74DD3C46CC5 for ; Fri, 15 Dec 2023 14:39:31 +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:References:In-Reply-To: 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: List-Owner; bh=dbqC12bFJi2nRycKfjBLI9acyVam98XAuC3AKGtIM5g=; b=zVOEXh4kqmFVgD 7OLuqgRn8DzJKfcVf1MKl20zsNso50n4jG2C7oxkZ8QhSPnARuoRytfEHFNC6kuAI0IU1w26q1gF3 axnhkhW4fT6Lafl1hEdUO0OPd6405Gk6HO00C9dpjslYAdm/aWuJD5fftTlNZ8vTjHClNrOjF6VLU 9TvZFDm0+LwwlGQ5OBZXAK+jvsnqeryFTMHA+P9L71HM/QSQJWL0DTBHsuHeqqb5mvIVxMGNnxEf2 pY6sMXSS1izU3jpFMOx1ZWW8bmLwZmDL+i6fXVf0jb/43Wq9xmiifPdCeK7NuwZ9Pcnom/Vr6/ryO iN4TYYVFC/+eN1k9fABQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LY-003aGk-2H; Fri, 15 Dec 2023 14:39:24 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LR-003aCc-2x for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:20 +0000 Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C3BFF3F2CA for ; Fri, 15 Dec 2023 14:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651156; bh=zIhpWVKJJnmCyP1zy08oHrKsokOM6OlCzyTjReVqd1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DnITNOLBnM4zNlO3vbwslNLpaQ05huDLxOxHEaQR+epSeIDnDCX0u463UfjC+3LPE VcjZNDSOqHH/oLUZMr/pkiaHREYADO1acsXeIcRejMO0JhXEhm/8EgbFiasfIiugAl VODp9kWrH0LuCQPiknq8Cupa9rPPkf3+hf597m6jxrvGTjlqXjIenqAvPZCTJYVkOa MF/eOxA5wt2ZetwF+nF2cOBzoN0I7/IsVwTONjLo3GHwZXtHq6/qdn8QeopAw8nhtW 77wvczW1WgfUFDS4qB4c2mbOsPXoqh1wmzMHstwkhD/AyFNpPuYSPsQUDi7RxzCK+K 51feozP62IZIA== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-50becd7229aso587188e87.3 for ; Fri, 15 Dec 2023 06:39:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651156; x=1703255956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zIhpWVKJJnmCyP1zy08oHrKsokOM6OlCzyTjReVqd1E=; b=qZDAhkMtTCPOj50b2SRHQzajQkAiG6Qdf/jc63B/oWy+aG95eE0RX7b3AIP1Qr+EiR CRbLNd38rLeWVDJSVT5Aedtojp58Fl8NMZ57irq/yFyc/jsAE4YsdoUhjhLU8k+0Z9sR +D0/c1zRSuZStciiNMlgYkyC00grs4Mj+QQ4t1l7s8zJakcfdCUrwktGPv9Rs+dUMAmU Guy0AfPIDYNzWxcQ/TQEm1CDVFObqcJTw6mOHl83IJkuR+G8LpmVasSryuN3IuFYkuAo sKG8LDiSVY1MwzfbworJBuYExX7Qq09l3oljaoRjjxm9akUWnDBgzpQe5YjX+nIINCqr /Cbg== X-Gm-Message-State: AOJu0Yw2rJZ/4NhvGZ4b48krWTyFtjY6SFmFq+ZivD+MkMgw8se1hMMz x/BsEfHd0X4AE/Dc2xXyzeKwNTOeWEdYSBnLwE/Dy7x1cxoy4bLksvS40ppct8/hKyTRE+DFJpF jJux63mQ+IxMlYIMt9spRj423aMYLV2vUIH4knYQJ5Ckg5A== X-Received: by 2002:ac2:562c:0:b0:508:11c3:c8ca with SMTP id b12-20020ac2562c000000b0050811c3c8camr5154674lff.7.1702651156260; Fri, 15 Dec 2023 06:39:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7Vuhei34AU13Jnm38bp/hQV39eU5/IVQg8JqEo+wN89ajcH21veCiM3jRU6Sxf9xyyOAt1Q== X-Received: by 2002:ac2:562c:0:b0:508:11c3:c8ca with SMTP id b12-20020ac2562c000000b0050811c3c8camr5154659lff.7.1702651155941; Fri, 15 Dec 2023 06:39:15 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:15 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 5/8] riscv: dts: thead: Add TH1520 GPIO ranges Date: Fri, 15 Dec 2023 15:39:03 +0100 Message-Id: <20231215143906.3651122-6-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063918_094976_72781E99 X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add gpio-ranges properties to the TH1520 device tree, so user space can change basic pinconf settings for GPIOs and are not allowed to use pads already used by other functions. Adjust number of GPIOs available for the different controllers. Signed-off-by: Emil Renner Berthing --- arch/riscv/boot/dts/thead/th1520.dtsi | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index 397d5c71bd3d..d5e2378a1afa 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -217,6 +217,7 @@ portc: gpio-controller@0 { gpio-controller; #gpio-cells = <2>; ngpios = <32>; + gpio-ranges = <&padctrl0_apsys 0 0 32>; reg = <0>; interrupt-controller; #interrupt-cells = <2>; @@ -234,7 +235,8 @@ portd: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; - ngpios = <32>; + ngpios = <23>; + gpio-ranges = <&padctrl0_apsys 0 32 23>; reg = <0>; interrupt-controller; #interrupt-cells = <2>; @@ -258,6 +260,7 @@ porta: gpio-controller@0 { gpio-controller; #gpio-cells = <2>; ngpios = <32>; + gpio-ranges = <&padctrl1_apsys 0 0 32>; reg = <0>; interrupt-controller; #interrupt-cells = <2>; @@ -275,7 +278,8 @@ portb: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; - ngpios = <32>; + ngpios = <31>; + gpio-ranges = <&padctrl1_apsys 0 32 31>; reg = <0>; interrupt-controller; #interrupt-cells = <2>; @@ -416,7 +420,8 @@ porte: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; - ngpios = <32>; + ngpios = <16>; + gpio-ranges = <&padctrl_aosys 0 9 16>; reg = <0>; interrupt-controller; #interrupt-cells = <2>; @@ -439,7 +444,8 @@ portf: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; - ngpios = <32>; + ngpios = <23>; + gpio-ranges = <&padctrl_aosys 0 25 22>, <&padctrl_aosys 22 7 1>; reg = <0>; interrupt-controller; #interrupt-cells = <2>; From patchwork Fri Dec 15 14:39:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494545 X-Patchwork-Delegate: mail@conchuod.ie 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 20FAAC35274 for ; Fri, 15 Dec 2023 14:39:31 +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:References:In-Reply-To: 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: List-Owner; bh=nvyX0l6U8K5FOZA014IAn/x24iuIR/9dMoE7EZQS9pE=; b=SZ/Szmth5K95vh Iy22vBIbNnyO19Q0F7TaTtEM50K6h9NDGRIZjORDfcb/RJq/awn3pJBhktoSHSymD1uUrB3vh2ak/ ERXaEz64cQ6F8HGPGAowo4pVfU1NqaQj2Jeg7GSxcV/0do2/2BsoZ0vCAm+SGpcx2paRm5HR41gJy m2/jscbhp/kip4U/N7ybR8pBo+Tb2D3Dh6FVGwCy6DtGx2AYz0C2o1L1MJxyt3lhdlP1Po74zeBzb p0pl3F8f+CgAUGOm3zlIuJT4YkvBJyZq6ouo7M8pYV8O1qxDVCMdjKrP5YaE8G3HG56VfQCHXIBQG apRNudAdbFV1bFlbkDrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LZ-003aH1-0r; Fri, 15 Dec 2023 14:39:25 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LT-003aDZ-18 for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:21 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 308423F2BB for ; Fri, 15 Dec 2023 14:39:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651158; bh=Ybq5UjTeoIDvQGsMjYKQSlN8FhlG+exm++rGqALpbk8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kwcVmKtKgGrQzD50R4KeZeC02oSkbdTKWzAKXHCMM02XTTU5/B1RTajhr0Cy6vEZ2 isDz2HqM8D9aGcKHSBzVOvgG+wXDlPCH51s2j4A058LFmOINbJg1Nf2QnSZsLWQS+O agICxlcZxP1FCu+DZBoE08Ytk9D78MT/ubKhn7HNorcOdePH5FDHy60t2XITHxxrkP 9i2W+QeRX7kM/4mNuiFghxE5LdY/hqhyHA+m/aLsE3lok99b/kC4R0N9GgxPSlIRAs +kaYa7Quz+HH1N7MUEwB/e71ff4BzVBO3YFBvvjw3aFmztmiNRWJEdSHPxqoT7Ntkc uvS0bvJzZcwfA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a1e88d2d7faso44313066b.1 for ; Fri, 15 Dec 2023 06:39:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651157; x=1703255957; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ybq5UjTeoIDvQGsMjYKQSlN8FhlG+exm++rGqALpbk8=; b=inh9rHLzq3/SrNSBD7bIc+yCqU7gtFsmDMcVxexj3J2Ba1X+5fc/+QJoBTE5SSAJ3l yrsFopjObG/qxmmW0nIQaPqNTAacerptgn7d+4LpQGA24LVKZActfWh7rA/fxZWFiH0i lveRnakwJOhR80RHCFr2ADkLQWQNuVf/QhuJXcrQb3clOsO49X9c8Y7hj8IxM28tpuJi elWKqhR2BSW4xGl2oiH3f9A7JJFkTTSChcGTpnO6hBysMjRT2vkcuB++rPo1stbD20eF 4syF0rRWbLrn4N07VRJ8hK6HeA5Sz6DeiSuA28fQnK78SQtp0F/zbjQ05OChVzM/61YN UNEw== X-Gm-Message-State: AOJu0YwK6IMe+n3Jnz+KPRItZHG2VJoEUQc7TuL64+qoOeiueWt73rM7 39ArDj+8hOUZcWaS0pnGEiRgrwjJKyMNQNrFO1oKNtW6TCUaMKA9/BiBgQnXGjTVXL6CQgeVi1y ubQKG4I6wuT8KfhvRbzWivOchhdFEDbIZC0RCndirwhykJQ== X-Received: by 2002:a17:906:530b:b0:a22:f068:7f6f with SMTP id h11-20020a170906530b00b00a22f0687f6fmr2487186ejo.103.1702651157466; Fri, 15 Dec 2023 06:39:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlQI/l2ZAFLp1q43IDXNIJcNIW2onNCcYx/a2Yji69pawtw9Ir+cUHT9Sd1e0dwlnqyRXDFQ== X-Received: by 2002:a17:906:530b:b0:a22:f068:7f6f with SMTP id h11-20020a170906530b00b00a22f0687f6fmr2487171ejo.103.1702651157255; Fri, 15 Dec 2023 06:39:17 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:16 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 6/8] riscv: dts: thead: Adjust TH1520 GPIO labels Date: Fri, 15 Dec 2023 15:39:04 +0100 Message-Id: <20231215143906.3651122-7-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063919_528245_721B9426 X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Adjust labels for the TH1520 GPIO controllers such that GPIOs can be referenced by the names used by the documentation. Eg. GPIO0_X -> <&gpio0 X Y> GPIO1_X -> <&gpio1 X Y> GPIO2_X -> <&gpio2 X Y> GPIO3_X -> <&gpio3 X Y> GPIO4_X -> <&gpio4 X Y> AOGPIO_X -> <&aogpio X Y> Remove labels for the parent GPIO devices that shouldn't need to be referenced. Signed-off-by: Emil Renner Berthing --- .../boot/dts/thead/th1520-beaglev-ahead.dts | 2 ++ .../boot/dts/thead/th1520-lichee-pi-4a.dts | 2 ++ arch/riscv/boot/dts/thead/th1520.dtsi | 24 +++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts index 70e8042c8304..91ba96588ae8 100644 --- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts +++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts @@ -17,6 +17,8 @@ aliases { gpio1 = &gpio1; gpio2 = &gpio2; gpio3 = &gpio3; + gpio4 = &gpio4; + gpio5 = &aogpio; serial0 = &uart0; serial1 = &uart1; serial2 = &uart2; diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts index 9a3884a73e13..0ae2c20d5641 100644 --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts @@ -14,6 +14,8 @@ aliases { gpio1 = &gpio1; gpio2 = &gpio2; gpio3 = &gpio3; + gpio4 = &gpio4; + gpio5 = &aogpio; serial0 = &uart0; serial1 = &uart1; serial2 = &uart2; diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index d5e2378a1afa..17ca214b5a97 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -206,13 +206,13 @@ uart3: serial@ffe7f04000 { status = "disabled"; }; - gpio2: gpio@ffe7f34000 { + gpio@ffe7f34000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xe7f34000 0x0 0x1000>; #address-cells = <1>; #size-cells = <0>; - portc: gpio-controller@0 { + gpio2: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; @@ -225,13 +225,13 @@ portc: gpio-controller@0 { }; }; - gpio3: gpio@ffe7f38000 { + gpio@ffe7f38000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xe7f38000 0x0 0x1000>; #address-cells = <1>; #size-cells = <0>; - portd: gpio-controller@0 { + gpio3: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; @@ -249,13 +249,13 @@ padctrl1_apsys: pinctrl@ffe7f3c000 { reg = <0xff 0xe7f3c000 0x0 0x1000>; }; - gpio0: gpio@ffec005000 { + gpio@ffec005000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xec005000 0x0 0x1000>; #address-cells = <1>; #size-cells = <0>; - porta: gpio-controller@0 { + gpio0: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; @@ -268,13 +268,13 @@ porta: gpio-controller@0 { }; }; - gpio1: gpio@ffec006000 { + gpio@ffec006000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xec006000 0x0 0x1000>; #address-cells = <1>; #size-cells = <0>; - portb: gpio-controller@0 { + gpio1: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; @@ -410,13 +410,13 @@ timer7: timer@ffffc3303c { status = "disabled"; }; - ao_gpio0: gpio@fffff41000 { + gpio@fffff41000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xfff41000 0x0 0x1000>; #address-cells = <1>; #size-cells = <0>; - porte: gpio-controller@0 { + aogpio: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; @@ -434,13 +434,13 @@ padctrl_aosys: pinctrl@fffff4a000 { reg = <0xff 0xfff4a000 0x0 0x2000>; }; - ao_gpio1: gpio@fffff52000 { + gpio@fffff52000 { compatible = "snps,dw-apb-gpio"; reg = <0xff 0xfff52000 0x0 0x1000>; #address-cells = <1>; #size-cells = <0>; - portf: gpio-controller@0 { + gpio4: gpio-controller@0 { compatible = "snps,dw-apb-gpio-port"; gpio-controller; #gpio-cells = <2>; From patchwork Fri Dec 15 14:39:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494546 X-Patchwork-Delegate: mail@conchuod.ie 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 490CAC41535 for ; Fri, 15 Dec 2023 14:39:32 +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:References:In-Reply-To: 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: List-Owner; bh=9+mpj9CqFB1Uhi6+vClIchz5KOkwNeH/ZVxuxbz/Kdw=; b=UipKTOMgetsaI8 TwqEO50kgzVuOPEMpDFLEy2dMHVsplSvxtjRuhx97RxZdvEMsRwIEfjGPBrxGxSxuWkYJGyLOn53Z qEG7ehlxMjLTzjT2ajhgfdxyKfZC5wA7Tsm9G2Rm+2pSONbL/OLg+PkDY9DwxeFJ4/uJitaAqgN00 waXxmh6Bsqal5TXnOHU+mZphS4gcrz+05e3hfu8WYA9G/7Acr7lq6/S2+8M1+JPWOuCUthaOXruZ6 V1ZkpWOufJrCoJMa4Exz/4lsr18Wvt+27w910JnGz7VJhqNKVnjUqanxWZSMfMv4Cwj32nRqHxPGv i1Qhh7s2WOJjasNMinmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9Lb-003aHv-05; Fri, 15 Dec 2023 14:39:27 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LU-003aEL-1J for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:21 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4500C3F741 for ; Fri, 15 Dec 2023 14:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651159; bh=KeS7bAuIUzMlkgCBNZb8n3wxD/29BdX0GI6KJUISBPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DLmBUzEX56c4nbV41rCjeOg9seAuRSulSXrZVTuAhhu4/opVy8UX4F112GJ4X3BcH nd++gmjjKhQL0+i3eAmu+ipWNfnL5hRnWrWjSLmdMHa2jbc3Pzx2Z3QphWtO4InsaQ 0VSL0LRowDFbx/FNSQ09wHUCFU2bJQm5YClovdkwIni22i5bcpgh6o2UDIINk0SQUK T3PJsMdxoF8Ipm+BLjKcUTHofAfncwBmZeSLW70TfQiDbJ1wPf8K5WKgDRGk7KCCmZ i41ST37NR/3vEmyKMYsqe+olqTyAgSYVqk8Qh0wrDv5MnTzhm0z4H9g8xU3NDWfJf8 Z+V/50rl0tTqQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a1d72320a33so42976566b.2 for ; Fri, 15 Dec 2023 06:39:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651158; x=1703255958; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KeS7bAuIUzMlkgCBNZb8n3wxD/29BdX0GI6KJUISBPU=; b=idhLJKZMoUqSztKEVJIPq9MUu95TUhHQJtpHI0s7/M47/IN8Ilk3dfczUWb2FLTTFJ gNkg9yVG6mYyduGgAnT9/Fp1YTKeoEpiJTd0WRcwa5+1qjSVe6o/53Kt6t25jdtNLWKV 8ouTir5DE4DXbt2LNlYYAg03kUkhDH9EXnDw7y91ucbmlhb4H8+1P/veilf3Xdz2RTGT lJXNBF6geMdbkBBscljrWk8l798iGxa5MIzkY+F63P2IgyUNqnt5L1Q47OWnTwle2lwz 9doAyQyT/xU88MtcSslxw3mcuUn7ddjPAZQnZr7j9LQUMWsDGmVP/s7Sup7wPrFbFpQd /08A== X-Gm-Message-State: AOJu0Yw8oDiEahpghItduLg8w6EqvSStGs4FZxYlnaXNqEQJ2EHUr+Yq EN/T3zdCLpRqBnGM+yJGqWAcNkMnhHS5k6E1xbfOXxefqciUmv7NIb4Er3gO5Jb0CTcwZZh4sit KGUIKw16RynBAM2Q9vTBbbv8hc7r5I8/ReW+nDn6esA9jlw== X-Received: by 2002:a17:907:9815:b0:a1e:5ea5:c5db with SMTP id ji21-20020a170907981500b00a1e5ea5c5dbmr7355308ejc.83.1702651158519; Fri, 15 Dec 2023 06:39:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYp9pwfbZkq5mfgtJhASrZeR58D28PvdjDO0/bhC5ViEz08OWOBS4jzY7w2oHtlQRgSLS9Lw== X-Received: by 2002:a17:907:9815:b0:a1e:5ea5:c5db with SMTP id ji21-20020a170907981500b00a1e5ea5c5dbmr7355304ejc.83.1702651158328; Fri, 15 Dec 2023 06:39:18 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:17 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 7/8] riscv: dts: thead: Add TH1520 pinctrl settings for UART0 Date: Fri, 15 Dec 2023 15:39:05 +0100 Message-Id: <20231215143906.3651122-8-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063920_625731_D759A100 X-CRM114-Status: GOOD ( 10.75 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add pinctrl settings for UART0 used as the default debug console on both the Lichee Pi 4A and BeagleV Ahead boards. Signed-off-by: Emil Renner Berthing --- .../boot/dts/thead/th1520-beaglev-ahead.dts | 26 +++++++++++++++++++ .../boot/dts/thead/th1520-lichee-pi-4a.dts | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts index 91ba96588ae8..54d86aab6656 100644 --- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts +++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts @@ -58,6 +58,32 @@ &dmac0 { status = "okay"; }; +&padctrl0_apsys { + uart0_pins: uart0-0 { + tx-pins { + pins = "UART0_TXD"; + function = "0"; + bias-disable; + drive-strength = <3>; + input-disable; + input-schmitt-disable; + slew-rate = <0>; + }; + + rx-pins { + pins = "UART0_RXD"; + function = "0"; + bias-disable; + drive-strength = <1>; + input-enable; + input-schmitt-enable; + slew-rate = <0>; + }; + }; +}; + &uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins>; status = "okay"; }; diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts index 0ae2c20d5641..260aa5e0769f 100644 --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts @@ -29,6 +29,32 @@ chosen { }; }; +&padctrl0_apsys { + uart0_pins: uart0-0 { + tx-pins { + pins = "UART0_TXD"; + function = "0"; + bias-disable; + drive-strength = <3>; + input-disable; + input-schmitt-disable; + slew-rate = <0>; + }; + + rx-pins { + pins = "UART0_RXD"; + function = "0"; + bias-disable; + drive-strength = <1>; + input-enable; + input-schmitt-enable; + slew-rate = <0>; + }; + }; +}; + &uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_pins>; status = "okay"; }; From patchwork Fri Dec 15 14:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13494547 X-Patchwork-Delegate: mail@conchuod.ie 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 1020AC46CC6 for ; Fri, 15 Dec 2023 14:39:33 +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:References:In-Reply-To: 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: List-Owner; bh=xtISpwUDzkTDOyqrrbElLqNIyEunarHom1pZ3zqoh6w=; b=ZqxL0JPqVU5Z0N tqrScgHaNdtobTEYtlG8bpBsQE3O6e0Kn5n/gM1y2dqWkRWG8jbj7EUafZIIgjsR+Yi+p9ale4f/2 agQN7Sy+VhB0LPW9HueMN517fsRi+cYRE+i+H+AFcldc0oq/O39+/5GxbwOByqDJy4+BZtkLwtFte Kc96ye+6GuZUa0URJME5aZRZDYUl6ZoD85VCy6IbQ7qMZYp8kSeblAoeFFtnPxBd5yVi/DF9eTq7q qbE4taM43XbtN9jGLMxYfztIFCTdOMe/3ElLsidijnF1niPL0M8QQ4VXZgNdHo0QfGlkzjwvVelLd Oa5iO5dA8t7LJwOQZf3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rE9Lb-003aId-2D; Fri, 15 Dec 2023 14:39:27 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rE9LV-003aEV-1K for linux-riscv@lists.infradead.org; Fri, 15 Dec 2023 14:39:23 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 27A783F749 for ; Fri, 15 Dec 2023 14:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1702651160; bh=sqnkwNJyx4Y3XZP1ctBo+dwvCXDcRgLVJAObMWMc4no=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rgEU2+8bHiexwoF/wJDklvHF2ff54gxNGsk3RG68+R/ZrFXJMG1wTv/e2IWFTbTmc pSuEHLWnRgZdLK162TWxS1zGk0As1mgqQtin7FhPnqtILZ3Hhbep5ddZe2zqxs0qDH J0oxZ26l1ZClvVt74ZXKdo6tu/LrWdpJJRTvuGoGuXLhEQwgBH+wQDDoWsmEiQUu/k GUOVaiNa8R2gPsUFIXxkoLlgxZ48/XXbaXZzpkm+tmFIU3Ekxm9sUFt4AVTwNBylNX N0cncReRWnOu/9366sm/oQ5ZRwdULliSOlwMWky/pPQfB0+v5OQFsXSpc6ZcnQEyQ5 LQuaKuOTjVkXA== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a19c5cbbe86so46677366b.1 for ; Fri, 15 Dec 2023 06:39:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702651159; x=1703255959; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sqnkwNJyx4Y3XZP1ctBo+dwvCXDcRgLVJAObMWMc4no=; b=Z4mJ3xTnQNsXFTyoC+OV7zLFwIgCHSiBr2P4LhupjsskcSY8Sex5B+sI47sWgzS3qy h3VZiFEFBqDVGrkYy+CJQcK8RYrfEg5S9ribJltxJ/zQq9bAO3OsoU/OxuES26J+YI3D awvX/JDQ04R1gzhlm7bb50rV/lL3Ytr1fPmZJNj1Nbcid8pHspCj+XamBVmKvOc874Ws r8lNgdtoEQxXsgYiwmP2srqEcEUrM+PjW9lF6S/4UVmlnN5EekARJL3b7p3AUZVqyIX+ w0afpFZb1CCTIobTejANeJyWYAnxbWNq7WKOTMZmwLI1zI1SCSrQNglKRDYI3ZmxEQB0 m9pg== X-Gm-Message-State: AOJu0YwLbdBZISD+ir3d0lxRBg1kQyHYmxMuQKdXOuZHK68lZwdQP+8k 9faAUfZ5RPpJgiTcrkEe3l4DlQuBrghgtip9D0dkhyIQm27jxqzpLiSOcw+2LyTZFkNPFu0otp3 kLGpeTPVJlOErXjbqD2DTDiZOgDSj0bFsynVWoMOc55wMeA== X-Received: by 2002:a17:906:2082:b0:a23:105c:4c58 with SMTP id 2-20020a170906208200b00a23105c4c58mr840399ejq.101.1702651159552; Fri, 15 Dec 2023 06:39:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdZavjGi1n85oMXyfE7FfrDma/NmyRnykjf5VznoZdUOncAJuIX1TOejqRPUe7VuV7Judxgw== X-Received: by 2002:a17:906:2082:b0:a23:105c:4c58 with SMTP id 2-20020a170906208200b00a23105c4c58mr840384ejq.101.1702651159359; Fri, 15 Dec 2023 06:39:19 -0800 (PST) Received: from stitch.. ([152.115.213.158]) by smtp.gmail.com with ESMTPSA id tm6-20020a170907c38600b00a1db955c809sm10789122ejc.73.2023.12.15.06.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:39:18 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jisheng Zhang , Guo Ren , Fu Wei , Paul Walmsley , Palmer Dabbelt Subject: [PATCH v1 8/8] riscv: dtb: thead: Add BeagleV Ahead LEDs Date: Fri, 15 Dec 2023 15:39:06 +0100 Message-Id: <20231215143906.3651122-9-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> References: <20231215143906.3651122-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231215_063921_586827_81F2047F X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add nodes for the 5 user controllable LEDs on the BeagleV Ahead board. Signed-off-by: Emil Renner Berthing --- .../boot/dts/thead/th1520-beaglev-ahead.dts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts index 54d86aab6656..35585eff6ab3 100644 --- a/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts +++ b/arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dts @@ -7,6 +7,8 @@ /dts-v1/; #include "th1520.dtsi" +#include +#include / { model = "BeagleV Ahead"; @@ -34,7 +36,42 @@ chosen { memory@0 { device_type = "memory"; reg = <0x0 0x00000000 0x1 0x00000000>; + }; + leds { + pinctrl-names = "default"; + pinctrl-0 = <&led_pins>; + compatible = "gpio-leds"; + + led-1 { + gpios = <&gpio4 8 GPIO_ACTIVE_LOW>; + color = ; + label = "led1"; + }; + + led-2 { + gpios = <&gpio4 9 GPIO_ACTIVE_LOW>; + color = ; + label = "led2"; + }; + + led-3 { + gpios = <&gpio4 10 GPIO_ACTIVE_LOW>; + color = ; + label = "led3"; + }; + + led-4 { + gpios = <&gpio4 11 GPIO_ACTIVE_LOW>; + color = ; + label = "led4"; + }; + + led-5 { + gpios = <&gpio4 12 GPIO_ACTIVE_LOW>; + color = ; + label = "led5"; + }; }; }; @@ -58,6 +95,24 @@ &dmac0 { status = "okay"; }; +&padctrl_aosys { + led_pins: led-0 { + led-pins { + pins = "AUDIO_PA8", /* GPIO4_8 */ + "AUDIO_PA9", /* GPIO4_9 */ + "AUDIO_PA10", /* GPIO4_10 */ + "AUDIO_PA11", /* GPIO4_11 */ + "AUDIO_PA12"; /* GPIO4_12 */ + function = "3"; + bias-disable; + drive-strength = <3>; + input-disable; + input-schmitt-disable; + slew-rate = <0>; + }; + }; +}; + &padctrl0_apsys { uart0_pins: uart0-0 { tx-pins {