From patchwork Wed Sep 11 14:27:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13800689 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 2AEA8EE49B8 for ; Wed, 11 Sep 2024 14:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: 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=6/WzskX9Go8nWXOifWB23WvB1MNJZrDHBqH1eKR21ek=; b=E/rdm4nRerCG5E en6btwX/uCAl+hxf6biZKW5sS/+lTHYAfcM+occUstmrlb/qyUi1tMyzYrwXXLnc9kGlKhRF28c07 o+vJnkcQROwcfheFyiXUfBfBlrt609LXei1u+NX64nibDo6TV5DI0vQF4gWG1enYxFXbBFlk3Gf9/ DuOt6g/i+lxv3kxjHDzhO+iOdwHIq6Ahpbeov+Z7KegQxIcOzJqI08fzfPHqhJSB7cqqPZaVaJgo4 8B8cAsdHxK2XjPzj4uy/iOa27klQn8GRx/n3OCERqFJ5wQyh9BrdardfVGPTY38vdPFoYj/TLTwVV Dz9kyMoVthHaaOCR5cCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soOOj-00000009vNs-3myt; Wed, 11 Sep 2024 14:32:45 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soOJt-00000009tpl-3liF for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 14:27:47 +0000 Received: by mail-pj1-x1044.google.com with SMTP id 98e67ed59e1d1-2d8a7c50607so4469522a91.1 for ; Wed, 11 Sep 2024 07:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1726064865; x=1726669665; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=6/WzskX9Go8nWXOifWB23WvB1MNJZrDHBqH1eKR21ek=; b=jr8e7XFiMUHef/j5BCHlI6oRFpbRhQ1fkG1cy1YVjgNCAeAhup4mb2MgnGX+ugmLt5 YJU62Mq/eza1Npfodfcv28s4y0ROLGUV1ompiFBhoLhUK99M4NL92a4/GLfuS8pHpv4n HPo95bHdxPFfRh3oZ9Tr44v5iRCX3Zd+ZBPaBFG9vbwBJDM3jRa970aXNoN8YZoRNPTh kiyaKYovJVx1iWMZt994MVNBGpqgZoVYQMtOMVNVYnRxGzJHLeECfp3FCF32ATSZqL+r NoQdCZ2CzoE6+NbhuHDTSRiHIvgNx8XwYP7u3Sg0TsHlfNhOjJoCjRhBSR1JevcPblGS N3ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726064865; x=1726669665; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6/WzskX9Go8nWXOifWB23WvB1MNJZrDHBqH1eKR21ek=; b=HQVNwQf9Qbq5cM5ex0be6CWDGls7aIMqXe6tS3Q4u/WDT9Gg80YLxt9fSczEUlbSnS of1W0QpK4uRtLeu05cKwduQW9W8VaTl9n2hEkUYAbUrR+URdNzOyAlKU4caUbFVb857R s8p3o3zWnOmIyNARoSndv72JoU566Be46L5bHI8S5OB+pIOLWbArr9xfEBKMD0xGr41T 9N95o0C/SBwyEpqDJYt2a6k+rBq486xzYJTRi8f2aegiqE7v1GDXn9ZC2tNL1VaJVQkh ZrB1pq8xl70MJCdGceVvD6q8U7u9VnAE+WknEns52yX1sk5U7rcl2UMg1+Al2Z6hJa6K gpLA== X-Forwarded-Encrypted: i=1; AJvYcCUApww0zkihpj50dkRLewDCIhPtjZTM0woW164oDM2elP+4pkm1L91qQudFbVHJ4c9WwGXcOdCjBTUEeS7YiM+G@lists.infradead.org X-Gm-Message-State: AOJu0YxrpFaWRAnz5WDnOqY66fmsqM/lLQYNgwVSi6AD7Ws6wg6Fqy8R NqV26adTekPbsa8DdmLfCcTR5/7DQd/HIdoHriuZIUhKFFWhoz66VVSnF5LdFA== X-Google-Smtp-Source: AGHT+IE5BKt2yDajA1Yc3kmCBvgh9rPRVNNylDSz69umvGgfJdK38l9Sjwoe7Yv6xKP5opGpv/aOBg== X-Received: by 2002:a17:90a:510b:b0:2c9:a3ca:cc98 with SMTP id 98e67ed59e1d1-2dad4de137fmr20670675a91.7.1726064864449; Wed, 11 Sep 2024 07:27:44 -0700 (PDT) Received: from [172.16.118.100] ([103.15.228.94]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dadbfe46c9sm10639116a91.11.2024.09.11.07.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 07:27:44 -0700 (PDT) From: Ayush Singh Subject: [PATCH 0/8] Add generic overlay for MikroBUS addon boards Date: Wed, 11 Sep 2024 19:57:17 +0530 Message-Id: <20240911-mikrobus-dt-v1-0-3ded4dc879e7@beagleboard.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAMao4WYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDCyMz3dzM7KL8pNJi3ZQSXVOj1MTExJQUgyTDNCWgjoKi1LTMCrBp0bG 1tQDBRQBAXQAAAA== To: fabien.parent@linaro.org, d-gole@ti.com, lorforlinux@beagleboard.org, jkridner@beagleboard.org, robertcnelson@beagleboard.org, Andrew Davis , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=7197; i=ayush@beagleboard.org; h=from:subject:message-id; bh=XuUJVYFaL7KrJnI1SIfCWtxVEkhCeaGGZWCG4EnXi4A=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBm4ajUEQDU7T96PVlwx8Pj9jyhhfKN/Ay4+kwOx MNUs9SoSX6JAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZuGo1AAKCRAFzvXHieVa dGsvD/0UlJ0UfQxA8ZCx5fm8/039nBk+VNJ0fh5bOpLVq06oTO3kr8fvZrJ7tDdBJ8LmS3QPaPx Pq3SIY+GZ2p2cYzDBPff8hxhyDzcsxtF2LGCIKG+XrLx1YXcyrqn3GnOxulXVhcH+XVKf6O9rcK xYoLUiGCelS528QMcxL2BH6seKuNj7XrYy+g0jze6k1MtfnmaJ1nOq08cw6M+7M6EDkRzE9QHdI 5Qa1eH3iStuTxyxhbwFkPrqQZ9E98+rs/Pkkk6jch0Ao5Yf/CVBJbN8Aeksazsy908tJf2wEmjy aXRHp3IPKlIosFRFlU6rEOSQxN3jgsLVWE0RDCEyxVTLVrE1XqNypdZ9HPQCmP7j9BGALFRofJf EbXdRg/PwBhVqrnTpIfgrE5/Wpo7sz/CJpga/axW93WZvbRRLCCw1cbHIaq4WaRH0yUziQkrrhP Aco4o1OaGdc/jVgBYurwGrTj9RTJI6nyHK0vDDoLkoqTD3+XDtSWpK6WqucuzDzC93iaUDVA7St +fuyckAO4skO+HQ1uzj2110MSNfM6X9i2/P+oEFZCxZOe0mjT/PbbCpbQQA75bt5vp90r2OktuG W4X1Bl15iCoMnvxBDIdKw5BMcmIzw2C4lhiSvxBbyhxsGRM0idCVzIEdNcRDl1RGN1D8fBQjxpz 7wydyANLwKvev6Q== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_072746_093565_4E1032CD X-CRM114-Status: GOOD ( 26.94 ) 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 Hello all, This is an attempt to add MikroBUS addon support using the approach described by Grove connector patch series [0]. The patch series tests out 2 addon boards + pwm and GPIO on the MikroBUS connector. The boards used are GPS3 Click (for UART) [1] and Weather Click (for I2C) [2]. Additionally, I have tested relative GPIO numbering using devicetree nexus nodes [3]. The patch series does not attempt to do any dynamic discovery for 1-wire eeprom MikroBUS addon boards, nor does it provide any sysfs entry for board addition/removal. The connector driver might include them after the basic support is ironed out, but the existing patches for dynamic overlays work fine. The patch series has been tested on BeaglePlay [4]. I will now go over individual parts of the patch series, but for a better picture of the approach, it would be best to checkout [0] first. MikroBUS connector driver ------------------------- Just a stub platform driver for now. Will be extended in the future for dynamic board discovery using 1-wire eeprom present in some MikroBUS addon boards. While it is a stub driver, disabling it will make the GPIO connector nexus node unreachable (any driver attempting to use it will enter differed probing). So it is required. MikroBUS connector Devicetree ------------------------------ The connector devicetree defines the MikroBUS GPIO nexus node. This allows using pin numbering relative to MikroBUS connector pins in the addon boards overlay. Currently, the patch uses a clockwise numbering: 0: PWM 1: INT 2: RX 3: TX 4: SCL 5: SDA 6: MOSI 7: MISO 8: SCK 9: CS 10: RST 11: AN Additionally, in case PWM pin is not using channel 0, a nexus node for pwm should also be used and go in the connector devicetree. MikroBUS connector symbols overlay ---------------------------------- To make an overlay generic we need a standard name scheme which we use across base boards. For the connector pins the pinmux phandle shall be: __mux_ For the parent provider phandle, we use a similar naming scheme: __ For GPIO controller, I am using `MIKROBUS_GPIO` name since with nexus nodes, we do not need to define individual pin gpio controllers. The string symbols can be replaced with phandles once [5] is accepted. That will make connector stacking much simpler. MikroBUS addon board overlay ---------------------------- The patch puts the addon board overlays in their own directory. I am using the following naming scheme for MikroBUS addon boards: -.dtso Mikroe [6] lists this for all boards in their website, but I am not sure if other vendors have a product_id. This naming also makes future dynamic discovery easier, since click id spec [7] contains vendor_id and product_id in the header. Usage ----- So what does this all look like? Let's take an example of a BeaglePlay with one MikroBUS connectors for which we have physically attached a Wather click module to the first connector. Doing ahead of time command-line DT overlay application: ./fdtoverlay \ -o output.dtb \ -i k3-am625-beagleplay.dtb \ k3-am625-beagleplay-mikrobus-connector0.dtbo mikroe-5761.dtbo Open Items ---------- - SPI Support: Currently SPI dt requires `reg` property to specify the chipselect to use. This, makes the SPI device overlay dependent on the SPI controller. Thus for SPI support, we need a way to allow defining SPI chipselect relative to MikroBUS pins, and not the actual device controller. One possible solution is to introduce something like `named-reg` and allow selecting the chipselect by string array. But this probably requires more discussion so I have left out SPI support for now. NOTE: pins other than the CS MikroBUS pin can be used as chipselect. See [8]. - Controller symbol duplication The current symbol scheme has multiple symbols for the same underlying controller (Eg: MIKROBUS_SCL_MUX_I2C_SCL and MIKROBUS_SDA_MUX_I2C_SDA) point to the same i2c controller. I think both of them will always use the same i2c controller, but maybe there are some exceptions? So I have left it as it is for this patch series. The same thing also applies to UART and SPI. NOTE: with the use of nexus node for GPIO, the GPIO controller symbol will be the same for all pins. - Nexus node dt-bindings I am not quite sure how to deal with the nexus node properties (#gpio-cells, gpio-map, gpio-map-mask, gpio-map-pass-thru) since they seem to conflict with upstream gpio schema (gpio-controller is a dependency of #gpio-cells). [0]: https://lore.kernel.org/linux-arm-kernel/20240702164403.29067-1-afd@ti.com/ [1]: https://www.mikroe.com/gps-3-click [2]: https://www.mikroe.com/weather-click [3]: https://devicetree-specification.readthedocs.io/en/v0.3/devicetree-basics.html#nexus-nodes-and-specifier-mapping [4]: https://www.beagleboard.org/boards/beagleplay [5]: https://lore.kernel.org/r/20240902-symbol-phandle-v1-0-683efb2a944b@beagleboard.org [6]: https://www.mikroe.com/ [7]: https://github.com/MikroElektronika/click_id [8]: https://www.mikroe.com/spi-extend-click Signed-off-by: Ayush Singh --- Ayush Singh (7): dt-bindings: connector: Add MikorBUS connector mikrobus: Add mikrobus driver dts: ti: k3-am625-beagleplay: Enable mikroBUS connector dts: ti: beagleplay: Add mikrobus connector symbols addon_boards: Add addon_boards plumbing addon_boards: mikrobus: Add Weather Click addon_boards: mikrobus: Add GPS3 Click Fabien Parent (1): rust: kernel: Add Platform device and driver abstractions .../bindings/connector/mikrobus-connector.yaml | 40 +++ Kbuild | 1 + Kconfig | 2 + MAINTAINERS | 8 + addon_boards/Kconfig | 16 + addon_boards/Makefile | 3 + addon_boards/mikrobus/Makefile | 4 + addon_boards/mikrobus/mikroe-1714.dtso | 28 ++ addon_boards/mikrobus/mikroe-5761-i2c.dtso | 28 ++ arch/arm64/boot/dts/ti/Makefile | 1 + .../k3-am625-beagleplay-mikrobus-connector0.dtso | 49 +++ arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts | 53 ++- drivers/misc/Kconfig | 17 + drivers/misc/Makefile | 1 + drivers/misc/mikrobus.rs | 32 ++ rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 1 + rust/kernel/platform.rs | 380 +++++++++++++++++++++ 18 files changed, 659 insertions(+), 6 deletions(-) --- base-commit: 9aaeb87ce1e966169a57f53a02ba05b30880ffb8 change-id: 20240826-mikrobus-dt-52eaaadd0b1f Best regards,