From nobody Mon Apr 13 14:27:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D35BAC4321E for ; Mon, 14 Nov 2022 01:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235658AbiKNBGp (ORCPT ); Sun, 13 Nov 2022 20:06:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235348AbiKNBGm (ORCPT ); Sun, 13 Nov 2022 20:06:42 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C02FAD6; Sun, 13 Nov 2022 17:06:41 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id C21443200913; Sun, 13 Nov 2022 20:06:40 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 13 Nov 2022 20:06:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668388000; x=1668474400; bh=XC XLV1Fn2JMkCGp5d8/IdzhEV6t432NGJWbrn/bcneo=; b=tRPTBauBUAsIYqdjYW OKROEBrCE+vH6zCpWyWO51sN+YE2RyruT1UhJ6U6iEbEBGEri4SN+h3+jhudfsuc A76sWCecjHThMrVq9VhkbshNAn2aiukBhwi6oyB2Vv9dZV4d7a4BjfK1ft2Z1mp5 wXHXvxVLwNa/xeAxk/W2jmrKuphooyKx/RKHFYZiyhgVJ1WQWFz0g7hqlnGXsLwU T9kbkThDwm0VSjrhUYPolPtxWEXfvYhrFksBmCGukiP9upUzYDH0fjzO1CDgmfww aGogmSRcp6cLOSsDiGfuoN0BBJJcOKfRONxfip+VngJaAR4nwzvOmVYlJq7YvEo/ nAYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668388000; x=1668474400; bh=XCXLV1Fn2JMkC Gp5d8/IdzhEV6t432NGJWbrn/bcneo=; b=u6P6XUjEzXL3DoA3oG48AM8GbljQv 2F8Gf56nlZzAobGatmGjOZ2uIzQHuE96mwN1N/Ke/uzF0VOaZRZ4iLxyPOxSPrgb +BfKYe0u19jc/wTMM/q9PW5XW800MUqE4JZhofkmfo4QV7mwbWCKcx+lGntBLUvg 8ICV+bsCZwMC8/+IPHqDtUMaJ4tLN4olqgvSUjmpZZ830uCxX3+K80LLlWTHoxNr 9/cLcWAozjSf2gjtYflWUhalvjJLie22lmx7CCDdCrHe7LzfXXHqak92IMVUMy1L Rrw8g02HWI+K6RAqR/HBCYbOc57fT0SASGJ4AqXEW0ekBGaCBEB9seMEg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdeftdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpefghfevhffgheejhefgkeehueffgeehffejgeehueduueeffffhhfeu iefhueffhfenucffohhmrghinhepuggvvhhitggvthhrvggvrdhorhhgnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhho lhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:06:39 -0500 (EST) From: Samuel Holland To: Pavel Machek , linux-leds@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland , Maxime Ripard , Rob Herring Subject: [PATCH v7 1/5] dt-bindings: leds: Add Allwinner A100 LED controller Date: Sun, 13 Nov 2022 19:06:32 -0600 Message-Id: <20221114010636.33052-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114010636.33052-1-samuel@sholland.org> References: <20221114010636.33052-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The Allwinner A100, R329, and D1 SoCs contain an LED controller designed to drive a series of RGB LED pixels. It supports PIO and DMA transfers, and has configurable timing and pixel format. All three implementations appear to be identical, so use the oldest as the fallback compatible. Acked-by: Maxime Ripard Reviewed-by: Rob Herring Signed-off-by: Samuel Holland --- (no changes since v5) 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 Changes in v4: - Use "default" instead of "maxItems" for timing properties 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 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 .../leds/allwinner,sun50i-a100-ledc.yaml | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/allwinner,sun50i= -a100-ledc.yaml diff --git a/Documentation/devicetree/bindings/leds/allwinner,sun50i-a100-l= edc.yaml b/Documentation/devicetree/bindings/leds/allwinner,sun50i-a100-led= c.yaml new file mode 100644 index 000000000000..fc8ecf6f91e6 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/allwinner,sun50i-a100-ledc.yaml @@ -0,0 +1,139 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/allwinner,sun50i-a100-ledc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner A100 LED Controller Bindings + +maintainers: + - Samuel Holland + +description: + The LED controller found in Allwinner sunxi SoCs uses a one-wire serial + interface to drive up to 1024 RGB LEDs. + +properties: + compatible: + oneOf: + - const: allwinner,sun50i-a100-ledc + - items: + - enum: + - allwinner,sun20i-d1-ledc + - allwinner,sun50i-r329-ledc + - const: allwinner,sun50i-a100-ledc + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Bus clock + - description: Module clock + + clock-names: + items: + - const: bus + - const: mod + + resets: + maxItems: 1 + + dmas: + maxItems: 1 + description: TX DMA channel + + dma-names: + const: tx + + allwinner,pixel-format: + description: Pixel format (subpixel transmission order), default is "g= rb" + enum: + - bgr + - brg + - gbr + - grb + - rbg + - rgb + + allwinner,t0h-ns: + default: 336 + description: Length of high pulse when transmitting a "0" bit + + allwinner,t0l-ns: + default: 840 + description: Length of low pulse when transmitting a "0" bit + + allwinner,t1h-ns: + default: 882 + description: Length of high pulse when transmitting a "1" bit + + allwinner,t1l-ns: + default: 294 + description: Length of low pulse when transmitting a "1" bit + + allwinner,treset-ns: + default: 300000 + description: Minimum delay between transmission frames + +patternProperties: + "^multi-led@[0-9a-f]+$": + type: object + $ref: leds-class-multicolor.yaml# + unevaluatedProperties: false + properties: + reg: + minimum: 0 + maximum: 1023 + description: Index of the LED in the series (must be contiguous) + + required: + - reg + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - dmas + - dma-names + +additionalProperties: false + +examples: + - | + #include + #include + + ledc: led-controller@2008000 { + compatible =3D "allwinner,sun20i-d1-ledc", + "allwinner,sun50i-a100-ledc"; + reg =3D <0x2008000 0x400>; + interrupts =3D <36 IRQ_TYPE_LEVEL_HIGH>; + clocks =3D <&ccu 12>, <&ccu 34>; + clock-names =3D "bus", "mod"; + resets =3D <&ccu 12>; + dmas =3D <&dma 42>; + dma-names =3D "tx"; + #address-cells =3D <1>; + #size-cells =3D <0>; + + multi-led@0 { + reg =3D <0x0>; + color =3D ; + function =3D LED_FUNCTION_INDICATOR; + }; + }; + +... --=20 2.37.3 From nobody Mon Apr 13 14:27:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3AE1C4332F for ; Mon, 14 Nov 2022 01:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235676AbiKNBGt (ORCPT ); Sun, 13 Nov 2022 20:06:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235661AbiKNBGp (ORCPT ); Sun, 13 Nov 2022 20:06:45 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D2DFD06; Sun, 13 Nov 2022 17:06:44 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 2F9E03200916; Sun, 13 Nov 2022 20:06:43 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 13 Nov 2022 20:06:43 -0500 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:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1668388002; x= 1668474402; bh=KEyDRrMakpVf2icFHXyXSm1r1IX7+8lNsM8CGyZPQXU=; b=N KtTNEKVMJqhZtQnnWF8K+iLz7HWD8THl/GLZB+I7jsdpGtX55X18+Mr4N1DlO2Y3 WBdkDbeWbxqFWzcEonN2/+OIuVfJGzFj8CcEkfZj1geLRQWQ+HUq+PvOLPIngHj3 Q5fitkQE47+A7hwXf84X/X9E0vBAn/GwkBiF7gIZxJNG5c164Xv3Us5V7NAvs4// D+aCLfPPuoH8OJu2gB3FHn9llg7DJokZhCHLY9c2Napt+b1nfQYmRF1nZ5gIJCUj fT4KkLXgXIkMxaRpilaJ5oDYm62DNCQmnjcoEJs8evcuA/YlAnXp/vcSwo07dBwK rwXvBnLJ/O9ShkobnzuTA== 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:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1668388002; x= 1668474402; bh=KEyDRrMakpVf2icFHXyXSm1r1IX7+8lNsM8CGyZPQXU=; b=c dFpQscOxavSgFpqc8PgYupu5as/HhAl1odev91W9kUSyiAA4zgPQK8+vIJswmv3d XBaFcbF4qA97H5MTz1X4yyZP27ytQaaOlJ9FA5/Z2ZWF1oLgUSlOszybRKhlBRNs MrNPylCiP/RYWW1BBe5AMyUKRELJYjj9AES+qPgVN8caqdivsSSd+uZyIaEsq6Zx QHxyqEg7NKzcfeN8Zib/lhTRQtJ91reP0nqxT+XEtzi2SizMpe1R9ZfFmKsemAkd 73GX+jmWw7Tzz+OKlTQGhsnsTrBSrr4E4p00YB/KU2Vhvl6J0QY+aSlUjPRx2Ynx VWYJR0/uCowLG9oZFRYOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugddvlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepfeeuveeufeefleehlefhleeglefggfeikeffveetfeevjeeuieet uefgfeeiheelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:06:42 -0500 (EST) From: Samuel Holland To: Pavel Machek , linux-leds@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH v7 2/5] leds: sun50i-a100: New driver for the A100 LED controller Date: Sun, 13 Nov 2022 19:06:33 -0600 Message-Id: <20221114010636.33052-3-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114010636.33052-1-samuel@sholland.org> References: <20221114010636.33052-1-samuel@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some Allwinner sunxi SoCs, starting with the A100, contain an LED controller designed to drive RGB LED pixels. Add a driver for it using the multicolor LED framework, and with LEDs defined in the device tree. Acked-by: Jernej Skrabec Signed-off-by: Samuel Holland --- Changes in v7: - Use DEFINE_SIMPLE_DEV_PM_OPS Changes in v5: - Rename the driver R329 -> A100, since that is the actual original implementation Changes in v4: - Depend on LEDS_CLASS_MULTICOLOR Changes in v3: - 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: - Renamed from sunxi-ledc to sun50i-r329-ledc - Added missing "static" to functions/globals as reported by 0day bot drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-sun50i-a100.c | 555 ++++++++++++++++++++++++++++++++ 3 files changed, 565 insertions(+) create mode 100644 drivers/leds/leds-sun50i-a100.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 499d0f215a8b..4f4c515ed7d7 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -281,6 +281,15 @@ config LEDS_COBALT_RAQ help This option enables support for the Cobalt Raq series LEDs. =20 +config LEDS_SUN50I_A100 + tristate "LED support for Allwinner A100 RGB LED controller" + depends on LEDS_CLASS_MULTICOLOR && OF + depends on ARCH_SUNXI || COMPILE_TEST + help + This option enables support for the RGB LED controller found + in some Allwinner sunxi SoCs, includeing A100, R329, and D1. + It uses a one-wire interface to control up to 1024 LEDs. + config LEDS_SUNFIRE tristate "LED support for SunFire servers." depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 4fd2f92cd198..a6ee3f5cf7be 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -76,6 +76,7 @@ obj-$(CONFIG_LEDS_PWM) +=3D leds-pwm.o obj-$(CONFIG_LEDS_REGULATOR) +=3D leds-regulator.o obj-$(CONFIG_LEDS_S3C24XX) +=3D leds-s3c24xx.o obj-$(CONFIG_LEDS_SC27XX_BLTC) +=3D leds-sc27xx-bltc.o +obj-$(CONFIG_LEDS_SUN50I_A100) +=3D leds-sun50i-a100.o obj-$(CONFIG_LEDS_SUNFIRE) +=3D leds-sunfire.o obj-$(CONFIG_LEDS_SYSCON) +=3D leds-syscon.o obj-$(CONFIG_LEDS_TCA6507) +=3D leds-tca6507.o diff --git a/drivers/leds/leds-sun50i-a100.c b/drivers/leds/leds-sun50i-a10= 0.c new file mode 100644 index 000000000000..30fa9be2cf2d --- /dev/null +++ b/drivers/leds/leds-sun50i-a100.c @@ -0,0 +1,555 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2021-2022 Samuel Holland +// +// Partly based on drivers/leds/leds-turris-omnia.c, which is: +// Copyright (c) 2020 by Marek Beh=C3=BAn +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LEDC_CTRL_REG 0x0000 +#define LEDC_CTRL_REG_DATA_LENGTH (0x1fff << 16) +#define LEDC_CTRL_REG_RGB_MODE (0x7 << 6) +#define LEDC_CTRL_REG_LEDC_EN BIT(0) +#define LEDC_T01_TIMING_CTRL_REG 0x0004 +#define LEDC_T01_TIMING_CTRL_REG_T1H (0x3f << 21) +#define LEDC_T01_TIMING_CTRL_REG_T1L (0x1f << 16) +#define LEDC_T01_TIMING_CTRL_REG_T0H (0x1f << 6) +#define LEDC_T01_TIMING_CTRL_REG_T0L (0x3f << 0) +#define LEDC_RESET_TIMING_CTRL_REG 0x000c +#define LEDC_RESET_TIMING_CTRL_REG_LED_NUM (0x3ff << 0) +#define LEDC_DATA_REG 0x0014 +#define LEDC_DMA_CTRL_REG 0x0018 +#define LEDC_DMA_CTRL_REG_FIFO_TRIG_LEVEL (0x1f << 0) +#define LEDC_INT_CTRL_REG 0x001c +#define LEDC_INT_CTRL_REG_GLOBAL_INT_EN BIT(5) +#define LEDC_INT_CTRL_REG_FIFO_CPUREQ_INT_EN BIT(1) +#define LEDC_INT_CTRL_REG_TRANS_FINISH_INT_EN BIT(0) +#define LEDC_INT_STS_REG 0x0020 +#define LEDC_INT_STS_REG_FIFO_CPUREQ_INT BIT(1) +#define LEDC_INT_STS_REG_TRANS_FINISH_INT BIT(0) + +#define LEDC_FIFO_DEPTH 32 +#define LEDC_MAX_LEDS 1024 + +#define LEDS_TO_BYTES(n) ((n) * sizeof(u32)) + +struct sun50i_a100_ledc_led { + struct led_classdev_mc mc_cdev; + struct mc_subled subled_info[3]; +}; + +#define to_ledc_led(mc) container_of(mc, struct sun50i_a100_ledc_led, mc_c= dev) + +struct sun50i_a100_ledc_timing { + u32 t0h_ns; + u32 t0l_ns; + u32 t1h_ns; + u32 t1l_ns; + u32 treset_ns; +}; + +struct sun50i_a100_ledc { + struct device *dev; + void __iomem *base; + struct clk *bus_clk; + struct clk *mod_clk; + struct reset_control *reset; + + u32 *buffer; + struct dma_chan *dma_chan; + dma_addr_t dma_handle; + int pio_length; + int pio_offset; + + spinlock_t lock; + int next_length; + bool xfer_active; + + u32 format; + struct sun50i_a100_ledc_timing timing; + + int num_leds; + struct sun50i_a100_ledc_led leds[]; +}; + +static int sun50i_a100_ledc_dma_xfer(struct sun50i_a100_ledc *priv, int le= ngth) +{ + struct dma_async_tx_descriptor *desc; + dma_cookie_t cookie; + + desc =3D dmaengine_prep_slave_single(priv->dma_chan, priv->dma_handle, + LEDS_TO_BYTES(length), + DMA_MEM_TO_DEV, 0); + if (!desc) + return -ENOMEM; + + cookie =3D dmaengine_submit(desc); + if (dma_submit_error(cookie)) + return -EIO; + + dma_async_issue_pending(priv->dma_chan); + + return 0; +} + +static void sun50i_a100_ledc_pio_xfer(struct sun50i_a100_ledc *priv, int l= ength) +{ + u32 burst, offset, val; + + if (length) { + /* New transfer (FIFO is empty). */ + offset =3D 0; + burst =3D min(length, LEDC_FIFO_DEPTH); + } else { + /* Existing transfer (FIFO is half-full). */ + length =3D priv->pio_length; + offset =3D priv->pio_offset; + burst =3D min(length, LEDC_FIFO_DEPTH / 2); + } + + iowrite32_rep(priv->base + LEDC_DATA_REG, priv->buffer + offset, burst); + + if (burst < length) { + priv->pio_length =3D length - burst; + priv->pio_offset =3D offset + burst; + + if (!offset) { + val =3D readl(priv->base + LEDC_INT_CTRL_REG); + val |=3D LEDC_INT_CTRL_REG_FIFO_CPUREQ_INT_EN; + writel(val, priv->base + LEDC_INT_CTRL_REG); + } + } else { + /* Disable the request IRQ once all data is written. */ + val =3D readl(priv->base + LEDC_INT_CTRL_REG); + val &=3D ~LEDC_INT_CTRL_REG_FIFO_CPUREQ_INT_EN; + writel(val, priv->base + LEDC_INT_CTRL_REG); + } +} + +static void sun50i_a100_ledc_start_xfer(struct sun50i_a100_ledc *priv, + int length) +{ + u32 val; + + dev_dbg(priv->dev, "Updating %d LEDs\n", length); + + val =3D readl(priv->base + LEDC_CTRL_REG); + val &=3D ~LEDC_CTRL_REG_DATA_LENGTH; + val |=3D length << 16 | LEDC_CTRL_REG_LEDC_EN; + writel(val, priv->base + LEDC_CTRL_REG); + + if (length > LEDC_FIFO_DEPTH) { + int ret =3D sun50i_a100_ledc_dma_xfer(priv, length); + + if (!ret) + return; + + dev_warn(priv->dev, "Failed to set up DMA: %d\n", ret); + } + + sun50i_a100_ledc_pio_xfer(priv, length); +} + +static irqreturn_t sun50i_a100_ledc_irq(int irq, void *dev_id) +{ + struct sun50i_a100_ledc *priv =3D dev_id; + u32 val; + + val =3D readl(priv->base + LEDC_INT_STS_REG); + + if (val & LEDC_INT_STS_REG_TRANS_FINISH_INT) { + int next_length; + + /* Start the next transfer if needed. */ + spin_lock(&priv->lock); + next_length =3D priv->next_length; + if (next_length) + priv->next_length =3D 0; + else + priv->xfer_active =3D false; + spin_unlock(&priv->lock); + + if (next_length) + sun50i_a100_ledc_start_xfer(priv, next_length); + } else if (val & LEDC_INT_STS_REG_FIFO_CPUREQ_INT) { + /* Continue the current transfer. */ + sun50i_a100_ledc_pio_xfer(priv, 0); + } + + writel(val, priv->base + LEDC_INT_STS_REG); + + return IRQ_HANDLED; +} + +static void sun50i_a100_ledc_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct sun50i_a100_ledc *priv =3D dev_get_drvdata(cdev->dev->parent); + struct led_classdev_mc *mc_cdev =3D lcdev_to_mccdev(cdev); + struct sun50i_a100_ledc_led *led =3D to_ledc_led(mc_cdev); + int addr =3D led - priv->leds; + unsigned long flags; + bool xfer_active; + int next_length; + + led_mc_calc_color_components(mc_cdev, brightness); + + priv->buffer[addr] =3D led->subled_info[0].brightness << 16 | + led->subled_info[1].brightness << 8 | + led->subled_info[2].brightness; + + dev_dbg(priv->dev, "LED %d -> #%06x\n", addr, priv->buffer[addr]); + + spin_lock_irqsave(&priv->lock, flags); + next_length =3D max(priv->next_length, addr + 1); + xfer_active =3D priv->xfer_active; + if (xfer_active) + priv->next_length =3D next_length; + else + priv->xfer_active =3D true; + spin_unlock_irqrestore(&priv->lock, flags); + + if (!xfer_active) + sun50i_a100_ledc_start_xfer(priv, next_length); +} + +static const char *const sun50i_a100_ledc_formats[] =3D { + "rgb", + "rbg", + "grb", + "gbr", + "brg", + "bgr", +}; + +static int sun50i_a100_ledc_parse_format(const struct device_node *np, + struct sun50i_a100_ledc *priv) +{ + const char *format =3D "grb"; + u32 i; + + of_property_read_string(np, "allwinner,pixel-format", &format); + + for (i =3D 0; i < ARRAY_SIZE(sun50i_a100_ledc_formats); ++i) { + if (!strcmp(format, sun50i_a100_ledc_formats[i])) { + priv->format =3D i; + return 0; + } + } + + dev_err(priv->dev, "Bad pixel format '%s'\n", format); + + return -EINVAL; +} + +static void sun50i_a100_ledc_set_format(struct sun50i_a100_ledc *priv) +{ + u32 val; + + val =3D readl(priv->base + LEDC_CTRL_REG); + val &=3D ~LEDC_CTRL_REG_RGB_MODE; + val |=3D priv->format << 6; + writel(val, priv->base + LEDC_CTRL_REG); +} + +static const struct sun50i_a100_ledc_timing sun50i_a100_ledc_default_timin= g =3D { + .t0h_ns =3D 336, + .t0l_ns =3D 840, + .t1h_ns =3D 882, + .t1l_ns =3D 294, + .treset_ns =3D 300000, +}; + +static int sun50i_a100_ledc_parse_timing(const struct device_node *np, + struct sun50i_a100_ledc *priv) +{ + struct sun50i_a100_ledc_timing *timing =3D &priv->timing; + + *timing =3D sun50i_a100_ledc_default_timing; + + of_property_read_u32(np, "allwinner,t0h-ns", &timing->t0h_ns); + of_property_read_u32(np, "allwinner,t0l-ns", &timing->t0l_ns); + of_property_read_u32(np, "allwinner,t1h-ns", &timing->t1h_ns); + of_property_read_u32(np, "allwinner,t1l-ns", &timing->t1l_ns); + of_property_read_u32(np, "allwinner,treset-ns", &timing->treset_ns); + + return 0; +} + +static void sun50i_a100_ledc_set_timing(struct sun50i_a100_ledc *priv) +{ + const struct sun50i_a100_ledc_timing *timing =3D &priv->timing; + unsigned long mod_freq =3D clk_get_rate(priv->mod_clk); + u32 cycle_ns =3D NSEC_PER_SEC / mod_freq; + u32 val; + + val =3D (timing->t1h_ns / cycle_ns) << 21 | + (timing->t1l_ns / cycle_ns) << 16 | + (timing->t0h_ns / cycle_ns) << 6 | + (timing->t0l_ns / cycle_ns); + writel(val, priv->base + LEDC_T01_TIMING_CTRL_REG); + + val =3D (timing->treset_ns / cycle_ns) << 16 | + (priv->num_leds - 1); + writel(val, priv->base + LEDC_RESET_TIMING_CTRL_REG); +} + +static int sun50i_a100_ledc_resume(struct device *dev) +{ + struct sun50i_a100_ledc *priv =3D dev_get_drvdata(dev); + u32 val; + int ret; + + ret =3D reset_control_deassert(priv->reset); + if (ret) + return ret; + + ret =3D clk_prepare_enable(priv->bus_clk); + if (ret) + goto err_assert_reset; + + ret =3D clk_prepare_enable(priv->mod_clk); + if (ret) + goto err_disable_bus_clk; + + sun50i_a100_ledc_set_format(priv); + sun50i_a100_ledc_set_timing(priv); + + /* The trigger level must be at least the burst length. */ + val =3D readl(priv->base + LEDC_DMA_CTRL_REG); + val &=3D ~LEDC_DMA_CTRL_REG_FIFO_TRIG_LEVEL; + val |=3D LEDC_FIFO_DEPTH / 2; + writel(val, priv->base + LEDC_DMA_CTRL_REG); + + val =3D LEDC_INT_CTRL_REG_GLOBAL_INT_EN | + LEDC_INT_CTRL_REG_TRANS_FINISH_INT_EN; + writel(val, priv->base + LEDC_INT_CTRL_REG); + + return 0; + +err_disable_bus_clk: + clk_disable_unprepare(priv->bus_clk); +err_assert_reset: + reset_control_assert(priv->reset); + + return ret; +} + +static int sun50i_a100_ledc_suspend(struct device *dev) +{ + struct sun50i_a100_ledc *priv =3D dev_get_drvdata(dev); + + clk_disable_unprepare(priv->mod_clk); + clk_disable_unprepare(priv->bus_clk); + reset_control_assert(priv->reset); + + return 0; +} + +static void sun50i_a100_ledc_dma_cleanup(void *data) +{ + struct sun50i_a100_ledc *priv =3D data; + struct device *dma_dev =3D dmaengine_get_dma_device(priv->dma_chan); + + if (priv->buffer) + dma_free_wc(dma_dev, LEDS_TO_BYTES(priv->num_leds), + priv->buffer, priv->dma_handle); + dma_release_channel(priv->dma_chan); +} + +static int sun50i_a100_ledc_probe(struct platform_device *pdev) +{ + const struct device_node *np =3D pdev->dev.of_node; + struct dma_slave_config dma_cfg =3D {}; + struct led_init_data init_data =3D {}; + struct device *dev =3D &pdev->dev; + struct device_node *child; + struct sun50i_a100_ledc *priv; + struct resource *mem; + int count, irq, ret; + + count =3D of_get_available_child_count(np); + if (!count) + return -ENODEV; + if (count > LEDC_MAX_LEDS) { + dev_err(dev, "Too many LEDs! (max is %d)\n", LEDC_MAX_LEDS); + return -EINVAL; + } + + priv =3D devm_kzalloc(dev, struct_size(priv, leds, count), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev =3D dev; + priv->num_leds =3D count; + spin_lock_init(&priv->lock); + dev_set_drvdata(dev, priv); + + ret =3D sun50i_a100_ledc_parse_format(np, priv); + if (ret) + return ret; + + ret =3D sun50i_a100_ledc_parse_timing(np, priv); + if (ret) + return ret; + + priv->base =3D devm_platform_get_and_ioremap_resource(pdev, 0, &mem); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + priv->bus_clk =3D devm_clk_get(dev, "bus"); + if (IS_ERR(priv->bus_clk)) + return PTR_ERR(priv->bus_clk); + + priv->mod_clk =3D devm_clk_get(dev, "mod"); + if (IS_ERR(priv->mod_clk)) + return PTR_ERR(priv->mod_clk); + + priv->reset =3D devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(priv->reset)) + return PTR_ERR(priv->reset); + + priv->dma_chan =3D dma_request_chan(dev, "tx"); + if (IS_ERR(priv->dma_chan)) + return PTR_ERR(priv->dma_chan); + + ret =3D devm_add_action_or_reset(dev, sun50i_a100_ledc_dma_cleanup, priv); + if (ret) + return ret; + + dma_cfg.dst_addr =3D mem->start + LEDC_DATA_REG; + dma_cfg.dst_addr_width =3D DMA_SLAVE_BUSWIDTH_4_BYTES; + dma_cfg.dst_maxburst =3D LEDC_FIFO_DEPTH / 2; + ret =3D dmaengine_slave_config(priv->dma_chan, &dma_cfg); + if (ret) + return ret; + + priv->buffer =3D dma_alloc_wc(dmaengine_get_dma_device(priv->dma_chan), + LEDS_TO_BYTES(priv->num_leds), + &priv->dma_handle, GFP_KERNEL); + if (!priv->buffer) + return -ENOMEM; + + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + ret =3D devm_request_irq(dev, irq, sun50i_a100_ledc_irq, + 0, dev_name(dev), priv); + if (ret) + return ret; + + ret =3D sun50i_a100_ledc_resume(dev); + if (ret) + return ret; + + for_each_available_child_of_node(np, child) { + struct sun50i_a100_ledc_led *led; + struct led_classdev *cdev; + u32 addr, color; + + ret =3D of_property_read_u32(child, "reg", &addr); + if (ret || addr >=3D count) { + dev_err(dev, "LED 'reg' values must be from 0 to %d\n", + priv->num_leds - 1); + ret =3D -EINVAL; + goto err_put_child; + } + + ret =3D of_property_read_u32(child, "color", &color); + if (ret || color !=3D LED_COLOR_ID_RGB) { + dev_err(dev, "LED 'color' must be LED_COLOR_ID_RGB\n"); + ret =3D -EINVAL; + goto err_put_child; + } + + led =3D &priv->leds[addr]; + + led->subled_info[0].color_index =3D LED_COLOR_ID_RED; + led->subled_info[0].channel =3D 0; + led->subled_info[1].color_index =3D LED_COLOR_ID_GREEN; + led->subled_info[1].channel =3D 1; + led->subled_info[2].color_index =3D LED_COLOR_ID_BLUE; + led->subled_info[2].channel =3D 2; + + led->mc_cdev.num_colors =3D ARRAY_SIZE(led->subled_info); + led->mc_cdev.subled_info =3D led->subled_info; + + cdev =3D &led->mc_cdev.led_cdev; + cdev->max_brightness =3D U8_MAX; + cdev->brightness_set =3D sun50i_a100_ledc_brightness_set; + + init_data.fwnode =3D of_fwnode_handle(child); + + ret =3D devm_led_classdev_multicolor_register_ext(dev, + &led->mc_cdev, + &init_data); + if (ret) { + dev_err(dev, "Failed to register LED %u: %d\n", + addr, ret); + goto err_put_child; + } + } + + dev_info(dev, "Registered %d LEDs\n", priv->num_leds); + + return 0; + +err_put_child: + of_node_put(child); + sun50i_a100_ledc_suspend(&pdev->dev); + + return ret; +} + +static int sun50i_a100_ledc_remove(struct platform_device *pdev) +{ + sun50i_a100_ledc_suspend(&pdev->dev); + + return 0; +} + +static void sun50i_a100_ledc_shutdown(struct platform_device *pdev) +{ + sun50i_a100_ledc_suspend(&pdev->dev); +} + +static const struct of_device_id sun50i_a100_ledc_of_match[] =3D { + { .compatible =3D "allwinner,sun50i-a100-ledc" }, + {} +}; +MODULE_DEVICE_TABLE(of, sun50i_a100_ledc_of_match); + +static DEFINE_SIMPLE_DEV_PM_OPS(sun50i_a100_ledc_pm, + sun50i_a100_ledc_suspend, + sun50i_a100_ledc_resume); + +static struct platform_driver sun50i_a100_ledc_driver =3D { + .probe =3D sun50i_a100_ledc_probe, + .remove =3D sun50i_a100_ledc_remove, + .shutdown =3D sun50i_a100_ledc_shutdown, + .driver =3D { + .name =3D "sun50i-a100-ledc", + .of_match_table =3D sun50i_a100_ledc_of_match, + .pm =3D pm_ptr(&sun50i_a100_ledc_pm), + }, +}; +module_platform_driver(sun50i_a100_ledc_driver); + +MODULE_AUTHOR("Samuel Holland "); +MODULE_DESCRIPTION("Allwinner A100 LED controller driver"); +MODULE_LICENSE("GPL"); --=20 2.37.3 From nobody Mon Apr 13 14:27:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C73B1C433FE for ; Mon, 14 Nov 2022 01:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235670AbiKNBHC (ORCPT ); Sun, 13 Nov 2022 20:07:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235667AbiKNBGr (ORCPT ); Sun, 13 Nov 2022 20:06:47 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68719FAD8; Sun, 13 Nov 2022 17:06:46 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 4729D3200912; Sun, 13 Nov 2022 20:06:45 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 13 Nov 2022 20:06:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668388004; x=1668474404; bh=Qc 3PG8aa4zgdpdjCQqIcsCqe6dSbuvEez+FihmYoP1c=; b=Bddy/2V0+as/Nj6tJX tW2MdNfwnac0c3K7GRShzmhdwSGyGSkjbYiVhjAu8hwdd0NYo4s33zv/XN+tXSXK xyMCYP/9qz2kk1hzGXym57YHrXeKHw3trTfbRtnMm0Vq7lre3KBSWVvKHRKhIT3I FlU9DuL3ZpyXDyOEwWQIMWdqJtsov1EGL9rtVhbrPBAhmREF4IRaAhjyqDgKOKyj oWO2BZS0G2le3YLNgueHoha18hCXYnvWIzmmwN+M14AX3r662uoRbq9A6e7mYDFO JvwEs0/JFF7hDhkf2kzjiI1GvrN9mt9RZkelPxV3d6DIhLV6dpnSJt4V9GEVIUsw xACQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668388004; x=1668474404; bh=Qc3PG8aa4zgdp djCQqIcsCqe6dSbuvEez+FihmYoP1c=; b=WWc0mA2VrLaNW30k0pZTnDnZviBO5 52EuQDaD+SNBXevJYwk6GZR093xoUMKfiK3I88vqVcZvu3v0CPOwc94HtKVcNmXb q+JyN1hLw7zulRgSjFGcPSoG7BuqyGkdHVDf+NmeCtPZyWQVqSx/Nqq49hTnAasB GbtrJI06exKWqDw6z1tGGXkqsEkTM052mFaVuKMQ9xVrEC3MMnWruuCc6xP4u1WE gSmZUSjMnooReHjOfhmEdCsDeTKmtt45furw5FuOb3H4cmJ1zfCtzsJjYf6eCM5s AePiqstzCqIkNbIpfyfJUYrTMjQVgtu71Dc9G+Cdthzwharij5GDiRu9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdeftdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:06:44 -0500 (EST) From: Samuel Holland To: Pavel Machek , linux-leds@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH v7 3/5] arm64: dts: allwinner: a100: Add LED controller node Date: Sun, 13 Nov 2022 19:06:34 -0600 Message-Id: <20221114010636.33052-4-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114010636.33052-1-samuel@sholland.org> References: <20221114010636.33052-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Allwinner A100 contains an LED controller. Add it to the devicetree. Reviewed-by: Jernej Skrabec Signed-off-by: Samuel Holland --- (no changes since v5) Changes in v5: - New patch for v5 arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi b/arch/arm64/bo= ot/dts/allwinner/sun50i-a100.dtsi index 97e3e6907acd..2c90683145f2 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi @@ -273,6 +273,20 @@ i2c3: i2c@5002c00 { #size-cells =3D <0>; }; =20 + ledc: led-controller@5018000 { + compatible =3D "allwinner,sun50i-a100-ledc"; + reg =3D <0x5018000 0x400>; + interrupts =3D ; + clocks =3D <&ccu CLK_BUS_LEDC>, <&ccu CLK_LEDC>; + clock-names =3D "bus", "mod"; + resets =3D <&ccu RST_BUS_LEDC>; + dmas =3D <&dma 42>; + dma-names =3D "tx"; + status =3D "disabled"; + #address-cells =3D <1>; + #size-cells =3D <0>; + }; + ths: thermal-sensor@5070400 { compatible =3D "allwinner,sun50i-a100-ths"; reg =3D <0x05070400 0x100>; --=20 2.37.3 From nobody Mon Apr 13 14:27:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCACDC4332F for ; Mon, 14 Nov 2022 01:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235702AbiKNBHG (ORCPT ); Sun, 13 Nov 2022 20:07:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235675AbiKNBGt (ORCPT ); Sun, 13 Nov 2022 20:06:49 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C7F10FFD; Sun, 13 Nov 2022 17:06:48 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8997B320090D; Sun, 13 Nov 2022 20:06:47 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 13 Nov 2022 20:06:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668388007; x=1668474407; bh=vS E/FlVOFfJV72LzWEyWSXBLqckHW0Cl6cdsoa0yPnI=; b=N/6yUBjEoCfsQvydyJ E09HImpo55+NpHn65p+TPpsUKvPJr2aWsJ6BTBNt0LoEM7ZW/ASAq/c4mkydpWLS hLC8J877P0s50b4+ZFRkmfVDjuY07MOeQxDvyCzV0atTtujMWZc5uiM2SzlGvGwr vCH01Bs6fTWxSfdxwSu64MuKZaro4RKeW5x8dDKDfxbptuiQr3l0NDo7UpykAKJU 4MgXOUPXPgUMyC9yPtNStERK6yiywrF9LsZUwL4vnhborLVcLkmIhKrTv1vc4zi2 a4cQuj700C1RCsyOuHNKmhQx0Zjlzd632Sce53Pkee3dWxvL33RSZMmbFrdO6mDG mgng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668388007; x=1668474407; bh=vSE/FlVOFfJV7 2LzWEyWSXBLqckHW0Cl6cdsoa0yPnI=; b=eIp4LKUZGjUrD9DYFkgLe3BFI+EXA mfnzE4nIrl+3KJWg0FTQ+R42Zcpq2iNPOFyHwL+EWUFHT/uWxKE4/r3N6EcTBE1s RO7NQ+lS20h3pX8EfXkyYlEKssgGKro7Kmc33uSt+/NQSCMTmHaoyW3xLAy+FzTR Vly2WnNguBad2DgtKD8hxSTY8Zk9k7zQFH2PWIIAuU5Ia8/rnOck7Qnn+sE/XAiA QE7zZAxCfNI8CPpYfYP1vQ5/QtglYO7dT1CUE6VbF840PyZNFvccaQzO8IHMA32G kiWd2x86nRw116i/1PHpmW/LIkSaYvHSYpAhtWfMqkCZ+2v5C8Y0G5eYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdeftdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:06:46 -0500 (EST) From: Samuel Holland To: Pavel Machek , linux-leds@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH v7 4/5] riscv: dts: allwinner: d1: Add LED controller node Date: Sun, 13 Nov 2022 19:06:35 -0600 Message-Id: <20221114010636.33052-5-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114010636.33052-1-samuel@sholland.org> References: <20221114010636.33052-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Allwinner D1 contains an LED controller. Add its devicetree node, as well as the pinmux used by the reference board design. Reviewed-by: Jernej Skrabec Signed-off-by: Samuel Holland --- (no changes since v5) Changes in v5: - New patch for v5 arch/riscv/boot/dts/allwinner/sun20i-d1.dtsi | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/riscv/boot/dts/allwinner/sun20i-d1.dtsi b/arch/riscv/boot= /dts/allwinner/sun20i-d1.dtsi index 9a9b3e0fe79d..53b0cb64906f 100644 --- a/arch/riscv/boot/dts/allwinner/sun20i-d1.dtsi +++ b/arch/riscv/boot/dts/allwinner/sun20i-d1.dtsi @@ -115,6 +115,12 @@ lcd_rgb666_pins: lcd-rgb666-pins { function =3D "lcd0"; }; =20 + /omit-if-no-ref/ + ledc_pc0_pin: ledc-pc0-pin { + pins =3D "PC0"; + function =3D "ledc"; + }; + /omit-if-no-ref/ mmc0_pins: mmc0-pins { pins =3D "PF0", "PF1", "PF2", "PF3", "PF4", "PF5"; @@ -178,6 +184,21 @@ ccu: clock-controller@2001000 { #reset-cells =3D <1>; }; =20 + ledc: led-controller@2008000 { + compatible =3D "allwinner,sun20i-d1-ledc", + "allwinner,sun50i-a100-ledc"; + reg =3D <0x2008000 0x400>; + interrupts =3D <36 IRQ_TYPE_LEVEL_HIGH>; + clocks =3D <&ccu CLK_BUS_LEDC>, <&ccu CLK_LEDC>; + clock-names =3D "bus", "mod"; + resets =3D <&ccu RST_BUS_LEDC>; + dmas =3D <&dma 42>; + dma-names =3D "tx"; + status =3D "disabled"; + #address-cells =3D <1>; + #size-cells =3D <0>; + }; + lradc: keys@2009800 { compatible =3D "allwinner,sun20i-d1-lradc", "allwinner,sun50i-r329-lradc"; --=20 2.37.3 From nobody Mon Apr 13 14:27:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99556C433FE for ; Mon, 14 Nov 2022 01:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235743AbiKNBHK (ORCPT ); Sun, 13 Nov 2022 20:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235693AbiKNBG7 (ORCPT ); Sun, 13 Nov 2022 20:06:59 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41D811A30; Sun, 13 Nov 2022 17:06:50 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id A225A32002E8; Sun, 13 Nov 2022 20:06:49 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 13 Nov 2022 20:06:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668388009; x=1668474409; bh=5S hl8P/p16p52VEaYrOLrE4C4Kh9jE5qf4TZfI1iPJA=; b=J/hYq+Q1XLL33aztHV IkwPZbm+eFTuTfQVt0tWim0blUm2Y631DutB07mWSOUW4q8AlLPCyuSD0OZ8HaJ9 BtCYKqN7gLrx95FSvfIyJE4+wo9ZLOMKPiUpq5Km3HyxVwA5FHHlManxRiqFpu7y 0rkIMZXHzSzC0szEHhp7qVN/Wpv5bvB1Qe6mwb+V5i11l48Qr8s1VuZF0BywqZyh Tf2Nv6LTM6iV6scptuLiYx7OwivJUxfj5EiGsheljVqbduiUn7eK2Xyu2tDv0vFI 8Pq2nQKzkHYDVjpkTxp1ctatKVs7tL05VnJnAc6C4XmVSVlCC088EFTQ0W0Dhg99 aLyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668388009; x=1668474409; bh=5Shl8P/p16p52 VEaYrOLrE4C4Kh9jE5qf4TZfI1iPJA=; b=hUKjdFkZYMMP0Dh2cX6N8S1X1N+lq Q5H8n/J0RsBSbY3SW60hPsrgmOcZD6p0b1tICXzpfdfOuogcHiFYa2AIFwGcNY8W 5+ewT6yQApXH0XM9k+VY+yEFahkg3/aY1KWfsVOxbpPsX0Jwn8k/NhHtD5VKE4O1 EeU5Sy+shqxqVbPZ55pHBeHQMtNrZ37VCs4e7rAiA4i8/ExMwEhkjlctCqjnYaG0 6/uf0Jwjdzt80TWLa/fdFwSLBXo4KoD1FAuh8LEP3SdTc/rccBA262wf3wtimmjh JyD+aufeLdeXmPBnBLCEKiNglTJmUQmekjrFd0pRP9TIJYCbRysN4IoiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedugdeftdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Nov 2022 20:06:48 -0500 (EST) From: Samuel Holland To: Pavel Machek , linux-leds@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH v7 5/5] riscv: dts: allwinner: d1: Add RGB LEDs to boards Date: Sun, 13 Nov 2022 19:06:36 -0600 Message-Id: <20221114010636.33052-6-samuel@sholland.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221114010636.33052-1-samuel@sholland.org> References: <20221114010636.33052-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some D1-based boards feature an onboard RGB LED. Enable them. Acked-by: Jernej Skrabec Signed-off-by: Samuel Holland --- (no changes since v5) Changes in v5: - New patch for v5 .../boot/dts/allwinner/sun20i-d1-lichee-rv-dock.dts | 12 ++++++++++++ arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dts | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/riscv/boot/dts/allwinner/sun20i-d1-lichee-rv-dock.dts b/a= rch/riscv/boot/dts/allwinner/sun20i-d1-lichee-rv-dock.dts index ca36a5d75a7f..02d13e987e02 100644 --- a/arch/riscv/boot/dts/allwinner/sun20i-d1-lichee-rv-dock.dts +++ b/arch/riscv/boot/dts/allwinner/sun20i-d1-lichee-rv-dock.dts @@ -25,6 +25,18 @@ &ehci1 { status =3D "okay"; }; =20 +&ledc { + pinctrl-0 =3D <&ledc_pc0_pin>; + pinctrl-names =3D "default"; + status =3D "okay"; + + multi-led@0 { + reg =3D <0x0>; + color =3D ; + function =3D LED_FUNCTION_STATUS; + }; +}; + &lradc { status =3D "okay"; =20 diff --git a/arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dts b/arch/riscv= /boot/dts/allwinner/sun20i-d1-nezha.dts index df865ee15fcf..099075462998 100644 --- a/arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dts +++ b/arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dts @@ -5,6 +5,7 @@ =20 #include #include +#include =20 #include "sun20i-d1.dtsi" #include "sun20i-d1-common-regulators.dtsi" @@ -90,6 +91,18 @@ pcf8574a: gpio@38 { }; }; =20 +&ledc { + pinctrl-0 =3D <&ledc_pc0_pin>; + pinctrl-names =3D "default"; + status =3D "okay"; + + multi-led@0 { + reg =3D <0x0>; + color =3D ; + function =3D LED_FUNCTION_STATUS; + }; +}; + &lradc { status =3D "okay"; =20 --=20 2.37.3