From patchwork Sun Oct 29 21:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13439911 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 D7108C4332F for ; Sun, 29 Oct 2023 21:27: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: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=V5OwnQDtetxnH6CxeJCD0Uzn5qLnFDJ4WVoQr4KWSko=; b=1KIB6gSytHGCVy 5bXdcWsAmu+Msg+V8kWpa497LwdD//BiBll+VznB1s9DCI7ewcCpH4Zvlg1u9DyzUpiRMW2ToyAd7 z+Q7fkKiPdVSslfh+UfPDVV1dAZyb715vND2bxHHn8KTVpFElLhWdDGWrZU5Yurd0Ku+A/sGpTvbw W9KilOeWTujaoK9rjNVw+Cw0EpIwhnAyj9l2+nuUpKyr9pYQ3AVZhb2TWDetwEE1wgVizrokHviAV JYrImW+1PbXWT+RR97tvXE7alcU3rykcPiKD0jul8+wLR9kgHTrZ7Dt9qZI5G3nr6wL+++MYuS4pS C76gJoufa9fWR3Bm3Mjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxDK2-0028cY-2m; Sun, 29 Oct 2023 21:27:50 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxDJy-0028ae-0a; Sun, 29 Oct 2023 21:27:48 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 167795C00E7; Sun, 29 Oct 2023 17:27:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 29 Oct 2023 17:27:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; t=1698614862; x=1698701262; bh=MiMFrY0ycv /v9l0tkVb+XyEailSufLSk/OdS3dctGAk=; b=c3iRw+Pmsqwf7u+J/yJEiWwead cQlCIuPoU35W/2lyt8MOcnGbsZWW7144iApXMlWGzMy5JhC0DLcicR4nPl2QPfUo TPWY7W+zAoDNCTG2BZXJRpOzN0y4l6OJ4pwi2683ujmyQDX+0BJwbvWIIVT2gVPp jc/ZWUU84X1kDWbh48fYVP7Jz9R3WmF0gv1kBJvsLt+elUJUVm0ce3wSdvZlV8OA cmxQtIztCISHCRzu42ZBNzSv4dsEJGhKWR3w/lKrYToThcAShBnUJdpoZftdq93z blrAoyIHzeuzWfLVyltQqWjRRazLsR5bBBES9rtKeUYKysL4ZjbJTfAV/JYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698614862; x=1698701262; bh=MiMFrY0ycv/v9 l0tkVb+XyEailSufLSk/OdS3dctGAk=; b=b0xoGx7LEl9exW66x82K8ONJK/XrK vATlpAvHRg+sG598kRHa1ThK792mWrchqg8I+csuI+DomRCSC21+5/7xZZXZ55Dh 34t6u19IiEzqzc6pktDmc4wSLlm3+g854hCDFEaZZT2facXH8ZHHK39bp4f0/ZNP 1u2n3y3mwgSRsYQFeih7Gy/eCyhb80NkLnB5NRrWb4jFQsKO1cL5X1YsFHcAfqya X/hu5lYw3moHBSAt5cDajVbfnDTi0CmQzhUfbRUKLf09sN6I4Txoeyr9vKttGXbg c1NwKNlAuZg7qx7wtqp99ZuhwbNOhpdNKRz/0jEhJThymEFbm7HSFaFgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleekgddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepkeevlefhjeeuleeltedvjedvfeefteegleehueejffehgffffeekhefh hfekkeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Oct 2023 17:27:39 -0400 (EDT) From: Samuel Holland To: Lee Jones , Pavel Machek , linux-leds@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec Subject: [PATCH v8 0/5] leds: Allwinner A100 LED controller support Date: Sun, 29 Oct 2023 16:26:54 -0500 Message-ID: <20231029212738.7871-1-samuel@sholland.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231029_142746_609083_205E9091 X-CRM114-Status: GOOD ( 17.84 ) 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: , Cc: Philipp Zabel , devicetree@vger.kernel.org, Conor Dooley , Krzysztof Kozlowski , Samuel Holland , Andre Przywara , linux-kernel@vger.kernel.org, Rob Herring , linux-sunxi@lists.linux.dev, John Watts , Guo Ren , Jisheng Zhang , Maksim Kiselev , linux-riscv@lists.infradead.org, Marc Kleine-Budde , Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, Trevor Woerner Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This series adds bindings and a driver for the RGB LED controller found in some Allwinner SoCs, starting with A100. The hardware in the R329 and D1 SoCs appears to be identical. This series was tested on the Nezha board (one onboard LED) and the Dongshan Nezha STU board (with an external strip of 16/32/48 LEDs, also with gaps in the LED addresses). Changes in v8: - Remove redundant "Bindings" from the binding document title - Make the DMA channel optional; the driver now works without DMA - Fix spelling in the Kconfig description - Fix the file header comment style - Wrap to 100 columns instead of 80 - Use GENMASK for register bit fields - Use FIELD_PREP for setting all multiple-bit register fields - Add and use the LEDC_CHANNELS_PER_LED macro - Make length and offset variables unsigned to avoid mixed signedness - Add __counted_by for sun50i_a100_ledc::leds - Move the new/existing xfer logic out of sun50i_a100_ledc_pio_xfer() - Get the FIFO usage from INT_STS instead of assuming it is half full - Make the DMA channel optional; always use PIO if it is unavailable - Set up DMA before triggering the LEDC transfer to avoid underrun - Correctly enable/disable the DRQ for each transfer - Use more descriptive names for variables containing register values - Add blank lines and comments to improve readability - Add a comment explaining the write to the status register - Remove unnecessary debugging prints - Use the more-idiomatic post-increment operator in for loops - Allow gaps in child node 'reg' values (separate max_addr/num_leds) - Use device-managed allocation for the DMA buffer - Unregister LEDs before shutting down the controller to correctly respect LED_RETAIN_AT_SHUTDOWN (or lack thereof) - Use the .remove_new platform driver hook - Collected tags, except Tested-by for the driver due to large changes Changes in v7: - Use DEFINE_SIMPLE_DEV_PM_OPS Changes in v6: - Drop the A100 DMA controller DT node patch, which was merged via a different series Changes in v5: - A100 contains the original implementation, so use that as the base compatible string, and rename the binding to match - Add "unevaluatedProperties: false" to the child multi-led binding - Rename the driver R329 -> A100, since that is the actual original implementation Changes in v4: - Use "default" instead of "maxItems" for timing properties - Depend on LEDS_CLASS_MULTICOLOR Changes in v3: - Removed quotes from enumeration values - Added vendor prefix to timing/format properties - Renamed "format" property to "pixel-format" for clarity - Dropped "vled-supply" as it is unrelated to the controller hardware - Added vendor prefix to timing/format properties - Renamed "format" property to "pixel-format" for clarity - Dropped "vled-supply" as it is unrelated to the controller hardware - Changed "writesl" to "iowrite32_rep" so the driver builds on hppa Changes in v2: - Fixed typo leading to duplicate t1h-ns property - Removed "items" layer in definition of dmas/dma-names - Replaced uint32 type reference with maxItems in timing properties - Renamed from sunxi-ledc to sun50i-r329-ledc - Added missing "static" to functions/globals as reported by 0day bot Samuel Holland (5): dt-bindings: leds: Add Allwinner A100 LED controller leds: sun50i-a100: New driver for the A100 LED controller arm64: dts: allwinner: a100: Add LED controller node riscv: dts: allwinner: d1: Add LED controller node riscv: dts: allwinner: d1: Add RGB LEDs to boards .../leds/allwinner,sun50i-a100-ledc.yaml | 137 +++++ .../arm64/boot/dts/allwinner/sun50i-a100.dtsi | 14 + .../allwinner/sun20i-d1-lichee-rv-dock.dts | 12 + .../boot/dts/allwinner/sun20i-d1-nezha.dts | 13 + arch/riscv/boot/dts/allwinner/sun20i-d1.dtsi | 6 + .../boot/dts/allwinner/sunxi-d1s-t113.dtsi | 15 + drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-sun50i-a100.c | 580 ++++++++++++++++++ 9 files changed, 787 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/allwinner,sun50i-a100-ledc.yaml create mode 100644 drivers/leds/leds-sun50i-a100.c