Message ID | 20221214235438.30271-12-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp43150wrn; Wed, 14 Dec 2022 16:14:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf6bcmJWx2scuDZp96CJuO1xyz+5CZ4tnu5hAF8jzWOiGpsk2NTsq+9/LcWncba4GxmWJSvd X-Received: by 2002:a17:906:274b:b0:7c1:7183:2d32 with SMTP id a11-20020a170906274b00b007c171832d32mr13361123ejd.56.1671063284922; Wed, 14 Dec 2022 16:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671063284; cv=none; d=google.com; s=arc-20160816; b=pBGVh8JDLcdZYBGyPEJHXojCgoIRslwBhbcs4vBrVxCmOBGXWfvgB+QO4sAfFiFEZ3 mTQ0tcVcXxEDT0/XF/cFYZtNrpvQRWoAciNtbR8hJcWUXtjoIpGsQHSBZ3cr2aA0ugYt SplIdMTnIOhQhkI8SGxrDIlsbrbL7lM5XLITLQv+lhJAZmIP/7ZXve/iKPvbuCl5dGLa WZJRnBJ6CzOh+jK3yY69239QzbEbmMsBPkZIeZrEJMcwFeatCHWiyy0+1EANJyO//tMv BTbvS2X/gv6LYtRdOdsSJbilY3a3Hlas5qXdMb89mFnobycgB5Sl+mI0sVXWRpw2j4zm myOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=nUaYB4mYM1gCXOfo+68xcCeBFVZGQ3PaFqb+K6GJCtg=; b=oxtzAZvJlNYYAX/55OkAl2lytyaqefw8uJilA7ZZy9uZyMXOSSnppuPdy9fSJ2FF9Y JiIhI+yYREtYBNi5gBRRW0M/l63f41PtL/G66iUb6/NgqCkwqR8lBHDX7L1jcF1LYfL0 ogQbgEfYk6xOFf6wmQX7JP891PEgmcP56F94UUWl9KLY1avlCioSetOddRXGsD/wxGUz oI3LxTP+xIvSdECNqva3ZJ8T6shW689+SozAWO3YVo+zlxW+IQ1EIg6EtuGR3VpUq6KK m8LupvgvimuConKXy+v+w83PkuhWmaEHjp/CC0d6ZHWrj0Osz+9cJGDlnolkb5zz3AfV y+Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HEkM75Xn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13-20020a1709064fcd00b007acef3bec44si13206999ejw.221.2022.12.14.16.14.21; Wed, 14 Dec 2022 16:14:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HEkM75Xn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230235AbiLOABu (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Wed, 14 Dec 2022 19:01:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbiLOAAj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Dec 2022 19:00:39 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B231C5FB9B; Wed, 14 Dec 2022 15:56:10 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id f18so1459965wrj.5; Wed, 14 Dec 2022 15:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nUaYB4mYM1gCXOfo+68xcCeBFVZGQ3PaFqb+K6GJCtg=; b=HEkM75XnY1gKLBNPSXMywD87ktVghvhjnMNiIPF3v+daRENgBk5tmBqIZfv6NfsAS+ crGaojmo67uH4di/kyoTFvSXE9g2U1/YAXwZri37aUh1CfhmjV+W4BqFWrlYBAEprcMY v56VIwXrcycWiUTbg/yeKA20NNsX3vVVRYq8RO43cx5iSymYBM71JxvYWLX88uRIQ0UP nYee0ET/0g58lSVZK8emyXw3sCx/6MgJywAAa495kgT+NWzNs1N4bXHBrMoBubMJkOwR 9fXtdMTl4p1eWGiRxu5UvAx/I/hJJIjyCIG8G5r5cOMC1zU0FTv/06ugeJJkYa48RMtj d2RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nUaYB4mYM1gCXOfo+68xcCeBFVZGQ3PaFqb+K6GJCtg=; b=M95cUJHDMUMlPXYNtDbwVWwhZhECUZis8mWUmrQnxHEpH6m82obF+/iMOvcU9vI8G9 Jt58BXbA/1jU7ck/kQGCCbjY1khrzJmvCGJkWNrh4JVG18HR1OtbUKGoNbT/RJUGvuB8 oJaliSK1KR5glcKh/VwJvmV+aXGtNaeI96NCCH2pZykSHAyPRJgHOBY7D1XtcOLp+WNo XZZwO1FXnQMby0zcy7vqRYjF2Lzbv51Gk2T1FBV+GfFdhFvSKkeXfdIbMd8EqSapjcr1 8zlsl3xtJhbWVHYaFu9a3wbpVpufa70Mic2f0Um3wkPVzbFBm8UqoYsw6mOwAbof/1FD 68eg== X-Gm-Message-State: ANoB5pmpaiqN30cCWwTSKE5zLhEyEtFGqwMvMCMqKD54TWdsV075uDne Am71nDLF41NOupsyYyD4sc4= X-Received: by 2002:a5d:5b1d:0:b0:24b:b74d:8012 with SMTP id bx29-20020a5d5b1d000000b0024bb74d8012mr6793734wrb.18.1671062125288; Wed, 14 Dec 2022 15:55:25 -0800 (PST) Received: from localhost.localdomain (93-42-71-18.ip85.fastwebnet.it. [93.42.71.18]) by smtp.googlemail.com with ESMTPSA id u2-20020adff882000000b00241d21d4652sm4163549wrp.21.2022.12.14.15.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 15:55:24 -0800 (PST) From: Christian Marangi <ansuelsmth@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vladimir Oltean <olteanv@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Jonathan Corbet <corbet@lwn.net>, Pavel Machek <pavel@ucw.cz>, Christian Marangi <ansuelsmth@gmail.com>, "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>, John Crispin <john@phrozen.org>, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org, Tim Harvey <tharvey@gateworks.com>, Alexander Stein <alexander.stein@ew.tq-group.com>, Rasmus Villemoes <rasmus.villemoes@prevas.dk> Subject: [PATCH v7 11/11] dt-bindings: net: dsa: qca8k: add LEDs definition example Date: Thu, 15 Dec 2022 00:54:38 +0100 Message-Id: <20221214235438.30271-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221214235438.30271-1-ansuelsmth@gmail.com> References: <20221214235438.30271-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752236855017728469?= X-GMAIL-MSGID: =?utf-8?q?1752236855017728469?= |
Series |
Adds support for PHY LEDs with offload triggers
|
|
Commit Message
Christian Marangi
Dec. 14, 2022, 11:54 p.m. UTC
Add LEDs definition example for qca8k using the offload trigger as the
default trigger and add all the supported offload triggers by the
switch.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
.../devicetree/bindings/net/dsa/qca8k.yaml | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
Comments
On Thu, Dec 15, 2022 at 12:54:38AM +0100, Christian Marangi wrote: > Add LEDs definition example for qca8k using the offload trigger as the > default trigger and add all the supported offload triggers by the > switch. > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > --- > .../devicetree/bindings/net/dsa/qca8k.yaml | 24 +++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > index 978162df51f7..4090cf65c41c 100644 > --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > @@ -65,6 +65,8 @@ properties: > internal mdio access is used. > With the legacy mapping the reg corresponding to the internal > mdio is the switch reg with an offset of -1. > + Each phy have at least 3 LEDs connected and can be declared > + using the standard LEDs structure. > > patternProperties: > "^(ethernet-)?ports$": > @@ -202,6 +204,7 @@ examples: > }; > - | > #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/leds/common.h> > > mdio { > #address-cells = <1>; > @@ -284,6 +287,27 @@ examples: > > internal_phy_port1: ethernet-phy@0 { > reg = <0>; > + > + leds { > + #address-cells = <1>; > + #size-cells = <0>; > + > + led@0 { > + reg = <0>; > + color = <LED_COLOR_ID_WHITE>; > + function = LED_FUNCTION_LAN; > + function-enumerator = <1>; > + linux,default-trigger = "netdev"; 'function' should replace this. Don't encourage more users. Also, 'netdev' is not documented which leaves me wondering why there's no warning? Either this patch didn't apply or there's a problem in the schema that's not checking this node. > + }; > + > + led@1 { > + reg = <1>; > + color = <LED_COLOR_ID_AMBER>; > + function = LED_FUNCTION_LAN; > + function-enumerator = <1>; Typo? These are supposed to be unique. Can't you use 'reg' in your case? > + linux,default-trigger = "netdev"; > + }; > + }; > }; > > internal_phy_port2: ethernet-phy@1 { > -- > 2.37.2 > >
On Tue, Dec 20, 2022 at 11:39:58AM -0600, Rob Herring wrote: > On Thu, Dec 15, 2022 at 12:54:38AM +0100, Christian Marangi wrote: > > Add LEDs definition example for qca8k using the offload trigger as the > > default trigger and add all the supported offload triggers by the > > switch. > > > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > > --- > > .../devicetree/bindings/net/dsa/qca8k.yaml | 24 +++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > > index 978162df51f7..4090cf65c41c 100644 > > --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > > +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > > @@ -65,6 +65,8 @@ properties: > > internal mdio access is used. > > With the legacy mapping the reg corresponding to the internal > > mdio is the switch reg with an offset of -1. > > + Each phy have at least 3 LEDs connected and can be declared > > + using the standard LEDs structure. > > > > patternProperties: > > "^(ethernet-)?ports$": > > @@ -202,6 +204,7 @@ examples: > > }; > > - | > > #include <dt-bindings/gpio/gpio.h> > > + #include <dt-bindings/leds/common.h> > > > > mdio { > > #address-cells = <1>; > > @@ -284,6 +287,27 @@ examples: > > > > internal_phy_port1: ethernet-phy@0 { > > reg = <0>; > > + > > + leds { > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + led@0 { > > + reg = <0>; > > + color = <LED_COLOR_ID_WHITE>; > > + function = LED_FUNCTION_LAN; > > + function-enumerator = <1>; > > + linux,default-trigger = "netdev"; > > 'function' should replace this. Don't encourage more users. > > Also, 'netdev' is not documented which leaves me wondering why there's > no warning? Either this patch didn't apply or there's a problem in the > schema that's not checking this node. It is probably the usual limitation that the tools require a compatible, where as the kernel does not. > > + }; > > + > > + led@1 { > > + reg = <1>; > > + color = <LED_COLOR_ID_AMBER>; > > + function = LED_FUNCTION_LAN; > > + function-enumerator = <1>; > > Typo? These are supposed to be unique. Can't you use 'reg' in your case? reg in this context is the address of the PHY on the MDIO bus. This is an Ethernet switch, so has many PHYs, each with its own address. Andrew
On Thu, Dec 15, 2022 at 12:54:38AM +0100, Christian Marangi wrote: > Add LEDs definition example for qca8k using the offload trigger as the > default trigger and add all the supported offload triggers by the > switch. > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> > --- > .../devicetree/bindings/net/dsa/qca8k.yaml | 24 +++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > index 978162df51f7..4090cf65c41c 100644 > --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml > @@ -65,6 +65,8 @@ properties: > internal mdio access is used. > With the legacy mapping the reg corresponding to the internal > mdio is the switch reg with an offset of -1. > + Each phy have at least 3 LEDs connected and can be declared > + using the standard LEDs structure. > > patternProperties: > "^(ethernet-)?ports$": > @@ -202,6 +204,7 @@ examples: > }; > - | > #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/leds/common.h> > > mdio { > #address-cells = <1>; > @@ -284,6 +287,27 @@ examples: > > internal_phy_port1: ethernet-phy@0 { > reg = <0>; > + > + leds { > + #address-cells = <1>; > + #size-cells = <0>; > + > + led@0 { > + reg = <0>; > + color = <LED_COLOR_ID_WHITE>; > + function = LED_FUNCTION_LAN; > + function-enumerator = <1>; > + linux,default-trigger = "netdev"; > + }; > + > + led@1 { > + reg = <1>; > + color = <LED_COLOR_ID_AMBER>; > + function = LED_FUNCTION_LAN; > + function-enumerator = <1>; > + linux,default-trigger = "netdev"; > + }; > + }; > }; I don't see anything here which is specific to the QCA8K. I really hope the same binding should work for any PHY which has LEDs. So please move this into ethernet-phy.yaml. Andrew
> > > + }; > > > + > > > + led@1 { > > > + reg = <1>; > > > + color = <LED_COLOR_ID_AMBER>; > > > + function = LED_FUNCTION_LAN; > > > + function-enumerator = <1>; > > > > Typo? These are supposed to be unique. Can't you use 'reg' in your case? > > reg in this context is the address of the PHY on the MDIO bus. This is > an Ethernet switch, so has many PHYs, each with its own address. Actually, i'm wrong about that. reg in this context is the LED number of the PHY. Typically there are 2 or 3 LEDs per PHY. There is no reason the properties need to be unique. Often the LEDs have 8 or 16 functions, identical for each LED, but with different reset defaults so they show different things. Andrew
On Wed, Dec 21, 2022 at 02:41:50AM +0100, Andrew Lunn wrote: > > > > + }; > > > > + > > > > + led@1 { > > > > + reg = <1>; > > > > + color = <LED_COLOR_ID_AMBER>; > > > > + function = LED_FUNCTION_LAN; > > > > + function-enumerator = <1>; > > > > > > Typo? These are supposed to be unique. Can't you use 'reg' in your case? > > > > reg in this context is the address of the PHY on the MDIO bus. This is > > an Ethernet switch, so has many PHYs, each with its own address. > > Actually, i'm wrong about that. reg in this context is the LED number > of the PHY. Typically there are 2 or 3 LEDs per PHY. > > There is no reason the properties need to be unique. Often the LEDs > have 8 or 16 functions, identical for each LED, but with different > reset defaults so they show different things. > Are we taking about reg or function-enumerator? For reg it's really specific to the driver... My idea was that since a single phy can have multiple leds attached, reg will represent the led number. This is an example of the dt implemented on a real device. mdio { #address-cells = <1>; #size-cells = <0>; phy_port1: phy@0 { reg = <0>; leds { #address-cells = <1>; #size-cells = <0>; lan1_led@0 { reg = <0>; color = <LED_COLOR_ID_WHITE>; function = LED_FUNCTION_LAN; function-enumerator = <1>; linux,default-trigger = "netdev"; }; lan1_led@1 { reg = <1>; color = <LED_COLOR_ID_AMBER>; function = LED_FUNCTION_LAN; function-enumerator = <1>; linux,default-trigger = "netdev"; }; }; }; phy_port2: phy@1 { reg = <1>; leds { #address-cells = <1>; #size-cells = <0>; lan2_led@0 { reg = <0>; color = <LED_COLOR_ID_WHITE>; function = LED_FUNCTION_LAN; function-enumerator = <2>; linux,default-trigger = "netdev"; }; lan2_led@1 { reg = <1>; color = <LED_COLOR_ID_AMBER>; function = LED_FUNCTION_LAN; function-enumerator = <2>; linux,default-trigger = "netdev"; }; }; }; phy_port3: phy@2 { reg = <2>; leds { #address-cells = <1>; #size-cells = <0>; lan3_led@0 { reg = <0>; color = <LED_COLOR_ID_WHITE>; function = LED_FUNCTION_LAN; function-enumerator = <3>; linux,default-trigger = "netdev"; }; lan3_led@1 { reg = <1>; color = <LED_COLOR_ID_AMBER>; function = LED_FUNCTION_LAN; function-enumerator = <3>; linux,default-trigger = "netdev"; }; }; }; In the following implementation. Each port have 2 leds attached (out of 3) one white and one amber. The driver parse the reg and calculate the offset to set the correct option with the regs by also checking the phy number. An alternative way would be set the reg to be the global led number in the switch and deatch the phy from the calculation. Something like port 0 led 0 = reg 0 port 0 led 1 = reg 1 port 1 led 0 = reg 2 port 1 led 1 = reg 3 ... Using the function-enumerator can be problematic since ideally someone would declare a dedicated function for wan led. I'm very open to discuss and improve/fix this!
> An alternative way would be set the reg to be the global led number in > the switch and deatch the phy from the calculation. > > Something like > port 0 led 0 = reg 0 > port 0 led 1 = reg 1 > port 1 led 0 = reg 2 > port 1 led 1 = reg 3 I would not do this. It will make LED controllers embedded in switches different to LEDs controllers embedded in PHYs. Ideally we want them identical. One binding to rule them all. Andrew
On Wed, Dec 21, 2022 at 6:55 AM Christian Marangi <ansuelsmth@gmail.com> wrote: > > On Wed, Dec 21, 2022 at 02:41:50AM +0100, Andrew Lunn wrote: > > > > > + }; > > > > > + > > > > > + led@1 { > > > > > + reg = <1>; > > > > > + color = <LED_COLOR_ID_AMBER>; > > > > > + function = LED_FUNCTION_LAN; > > > > > + function-enumerator = <1>; > > > > > > > > Typo? These are supposed to be unique. Can't you use 'reg' in your case? > > > > > > reg in this context is the address of the PHY on the MDIO bus. This is > > > an Ethernet switch, so has many PHYs, each with its own address. > > > > Actually, i'm wrong about that. reg in this context is the LED number > > of the PHY. Typically there are 2 or 3 LEDs per PHY. > > > > There is no reason the properties need to be unique. Often the LEDs > > have 8 or 16 functions, identical for each LED, but with different > > reset defaults so they show different things. > > > > Are we taking about reg or function-enumerator? > > For reg it's really specific to the driver... My idea was that since a > single phy can have multiple leds attached, reg will represent the led > number. > > This is an example of the dt implemented on a real device. > > mdio { > #address-cells = <1>; > #size-cells = <0>; > > phy_port1: phy@0 { > reg = <0>; > > leds { > #address-cells = <1>; > #size-cells = <0>; > > lan1_led@0 { > reg = <0>; > color = <LED_COLOR_ID_WHITE>; > function = LED_FUNCTION_LAN; > function-enumerator = <1>; > linux,default-trigger = "netdev"; > }; > > lan1_led@1 { > reg = <1>; > color = <LED_COLOR_ID_AMBER>; > function = LED_FUNCTION_LAN; > function-enumerator = <1>; > linux,default-trigger = "netdev"; > }; > }; > }; > > phy_port2: phy@1 { > reg = <1>; > > leds { > #address-cells = <1>; > #size-cells = <0>; > > > lan2_led@0 { > reg = <0>; > color = <LED_COLOR_ID_WHITE>; > function = LED_FUNCTION_LAN; > function-enumerator = <2>; > linux,default-trigger = "netdev"; > }; > > lan2_led@1 { > reg = <1>; > color = <LED_COLOR_ID_AMBER>; > function = LED_FUNCTION_LAN; > function-enumerator = <2>; > linux,default-trigger = "netdev"; > }; > }; > }; > > phy_port3: phy@2 { > reg = <2>; > > leds { > #address-cells = <1>; > #size-cells = <0>; > > lan3_led@0 { > reg = <0>; > color = <LED_COLOR_ID_WHITE>; > function = LED_FUNCTION_LAN; > function-enumerator = <3>; > linux,default-trigger = "netdev"; > }; > > lan3_led@1 { > reg = <1>; > color = <LED_COLOR_ID_AMBER>; > function = LED_FUNCTION_LAN; > function-enumerator = <3>; > linux,default-trigger = "netdev"; > }; > }; > }; > > In the following implementation. Each port have 2 leds attached (out of > 3) one white and one amber. The driver parse the reg and calculate the > offset to set the correct option with the regs by also checking the phy > number. Okay, the full example makes more sense. But I still thought 'function-enumerator' values should be globally unique within a value of 'function'. Maybe Jacek has an opinion on this? You are using it to distinguish phys/ports, but there's already enough information in the DT to do that. You have the parent nodes and I assume you have port numbers under 'ethernet-ports'. For each port, get the phy node and then get the LEDs. > An alternative way would be set the reg to be the global led number in > the switch and deatch the phy from the calculation. > > Something like > port 0 led 0 = reg 0 > port 0 led 1 = reg 1 > port 1 led 0 = reg 2 > port 1 led 1 = reg 3 > ... No. Rob
Hi Christian, On Wed, 2022-12-21 at 13:54 +0100, Christian Marangi wrote: > For reg it's really specific to the driver... My idea was that since a > single phy can have multiple leds attached, reg will represent the led > number. > > This is an example of the dt implemented on a real device. > > mdio { > #address-cells = <1>; > #size-cells = <0>; > > phy_port1: phy@0 { > reg = <0>; > > leds { > #address-cells = <1>; > #size-cells = <0>; [...] > }; > }; [...] > }; > > In the following implementation. Each port have 2 leds attached (out of > 3) one white and one amber. The driver parse the reg and calculate the > offset to set the correct option with the regs by also checking the phy > number. With switch silicon allowing user control of the LEDs, vendors can (and will) use the switch's LED peripheral to drive other LEDs (or worse). E.g. on a Cisco SG220-26 switch, using a Realtek RTL8382 SoC, the LEDs associated with some unused switch ports are used to display a global device status. My concern here is that one would have to specify switch ports, that aren't connected to anything, just to describe those non-ethernet LEDs. Would an alternative with a 'trigger-sources' property pointing to the right phy be an option? The trade-off I see would be that extra port info has to be provided on a separate LED controller, which your example can avoid thanks to the phy's reg property. Building on your example this may become: switch { mdio { #address-cells = <1>; #size-cells = <0>; switch_phy0: phy@0 { reg = <0>; #trigger-source-cells = <1>; }; }; leds { #address-cells = <2>; #size-cells = <0>; /* First port, first LED */ /* Port status, can be offloaded */ led@0.0 { reg = <0 0>; trigger-sources = <&switch_phy0 (NET_LINK | NET_SPEED_1000)>; function = color = <LED_COLOR_ID_WHITE>; function = LED_FUNCTION_LAN; function-enumerator = <1>; linux,default-trigger = "netdev"; }; /* First port, first LED */ /* Port status, can be offloaded */ led@0.1 { reg = <0 1>; trigger-sources = <&switch_phy0 (NET_LINK | NET_SPEED_100 | NET_SPEED_10)>; function = color = <LED_COLOR_ID_AMBER>; function = LED_FUNCTION_LAN; function-enumerator = <1>; linux,default-trigger = "netdev"; }; /* Last port (not used in hardware), first LED */ /* Device status, software controlled */ led@7.0 { reg = <7 0>; function = color = <LED_COLOR_ID_AMBER>; function = LED_FUNCTION_STATUS; linux,default-trigger = "default-on"; }; }; }; To be a bit less verbose, the &switch_mdio node might serve as trigger provider with a single cell, but the above would allow only defined phy-s to be referenced. The trigger-source cells could be used for a more fine grained control of what should be offloaded (link up/down, Rx/Tx activity, link speed, ...). Although this selectivity is most likely runtime configurable, this could serve as a description of static device labeling (e.g. "LINK/ACT 1000"). Switching to the implementation and driver side, the 'trigger-sources' property could be used by the netdev trigger to determine if a status LED can be offloaded. The netdev trigger could just hide the whole hardware/software control aspect then. Much like how the timer trigger always offloads if an implementation is provided, even when offloading is less flexible than the software implementation of the timer trigger. Best, Sander
> > This is an example of the dt implemented on a real device. > > > > mdio { > > #address-cells = <1>; > > #size-cells = <0>; > > > > phy_port1: phy@0 { > > reg = <0>; > > > > leds { > > #address-cells = <1>; > > #size-cells = <0>; > [...] > > }; > > }; > [...] > > }; > > > > In the following implementation. Each port have 2 leds attached (out of > > 3) one white and one amber. The driver parse the reg and calculate the > > offset to set the correct option with the regs by also checking the phy > > number. > > With switch silicon allowing user control of the LEDs, vendors can (and will) > use the switch's LED peripheral to drive other LEDs (or worse). E.g. on a Cisco > SG220-26 switch, using a Realtek RTL8382 SoC, the LEDs associated with some > unused switch ports are used to display a global device status. My concern here > is that one would have to specify switch ports, that aren't connected to > anything, just to describe those non-ethernet LEDs. Note that the binding is adding properties to the PHY nodes, not the switch port nodes. Is this how the RTL8382 works? Marvell Switches have LED registers which are not in the PHY register space. But the point is, the PHYs will probe if listed. They don't have to have a MAC pointing to them with a phandle. So the phydev will exist, and that should be enough to get the LED class device registered. If there is basic on/off support, that should be enough for you to attach the Morse code panic trigger, the heartbeat handler, or any other LED trigger. Andrew
Hi Andrew, On Sun, 2023-01-29 at 23:02 +0100, Andrew Lunn wrote: > > > This is an example of the dt implemented on a real device. > > > > > > mdio { > > > #address-cells = <1>; > > > #size-cells = <0>; > > > > > > phy_port1: phy@0 { > > > reg = <0>; > > > > > > leds { > > > #address-cells = <1>; > > > #size-cells = <0>; > > [...] > > > }; > > > }; > > [...] > > > }; > > > > > > In the following implementation. Each port have 2 leds attached (out of > > > 3) one white and one amber. The driver parse the reg and calculate the > > > offset to set the correct option with the regs by also checking the phy > > > number. > > > > With switch silicon allowing user control of the LEDs, vendors can (and > > will) > > use the switch's LED peripheral to drive other LEDs (or worse). E.g. on a > > Cisco > > SG220-26 switch, using a Realtek RTL8382 SoC, the LEDs associated with some > > unused switch ports are used to display a global device status. My concern > > here > > is that one would have to specify switch ports, that aren't connected to > > anything, just to describe those non-ethernet LEDs. > > Note that the binding is adding properties to the PHY nodes, not the > switch port nodes. Is this how the RTL8382 works? Marvell Switches > have LED registers which are not in the PHY register space. Thanks for the quick clarification. Because you mention this, I realised that the RTL8382's LED controller is actually not in the PHYs. These SoCs use external PHYs, which may have their own, independent, LED controllers. For example the RTL8212D [1]. [1] https://datasheet.lcsc.com/lcsc/2203252253_Realtek-Semicon-RTL8218D-CG_C2901898.pdf > > But the point is, the PHYs will probe if listed. They don't have to > have a MAC pointing to them with a phandle. So the phydev will exist, > and that should be enough to get the LED class device registered. If > there is basic on/off support, that should be enough for you to attach > the Morse code panic trigger, the heartbeat handler, or any other LED > trigger. OK, this makes sense for (external) PHYs which need to be probed anyway to have access to the LEDs. Looking at the RTL8212D's datasheet (Table 11, p. 24), it appears to be possible to assign an LED to any of the eight PHYs. Perhaps to allow more freedom in the board layout. Maybe I'm just not seeing it, but I don't think the example with an 'leds' node under a PHY contains enough information to perform such a non- trivial mapping. On the other hand, I'm not sure where else that info might go. Maybe a 'trigger-sources' property cross-referencing another PHY in the same package? Best, Sander
> Thanks for the quick clarification. Because you mention this, I realised that > the RTL8382's LED controller is actually not in the PHYs. These SoCs use > external PHYs, which may have their own, independent, LED controllers. For > example the RTL8212D [1]. > > [1] > https://datasheet.lcsc.com/lcsc/2203252253_Realtek-Semicon-RTL8218D-CG_C2901898.pdf > > > > > But the point is, the PHYs will probe if listed. They don't have to > > have a MAC pointing to them with a phandle. So the phydev will exist, > > and that should be enough to get the LED class device registered. If > > there is basic on/off support, that should be enough for you to attach > > the Morse code panic trigger, the heartbeat handler, or any other LED > > trigger. > > OK, this makes sense for (external) PHYs which need to be probed anyway to have > access to the LEDs. > > Looking at the RTL8212D's datasheet (Table 11, p. 24), it appears to be possible > to assign an LED to any of the eight PHYs. Perhaps to allow more freedom in the > board layout. Maybe I'm just not seeing it, but I don't think the example with > an 'leds' node under a PHY contains enough information to perform such a non- > trivial mapping. On the other hand, I'm not sure where else that info might go. The binding is defining all the generic properties need for generic PHY LED. For most PHYs, it is probably sufficient. However, there is nothing stopping you from adding PHY specific properties. So for example, for each PHY LED you could have a property which maps it to a LED00-LED35. So propose a binding for the RTL8218D with whatever extra properties you think are needed, and it will be reviewed in the normal way. Andrew
diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml index 978162df51f7..4090cf65c41c 100644 --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml @@ -65,6 +65,8 @@ properties: internal mdio access is used. With the legacy mapping the reg corresponding to the internal mdio is the switch reg with an offset of -1. + Each phy have at least 3 LEDs connected and can be declared + using the standard LEDs structure. patternProperties: "^(ethernet-)?ports$": @@ -202,6 +204,7 @@ examples: }; - | #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/leds/common.h> mdio { #address-cells = <1>; @@ -284,6 +287,27 @@ examples: internal_phy_port1: ethernet-phy@0 { reg = <0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_WHITE>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + linux,default-trigger = "netdev"; + }; + + led@1 { + reg = <1>; + color = <LED_COLOR_ID_AMBER>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + linux,default-trigger = "netdev"; + }; + }; }; internal_phy_port2: ethernet-phy@1 {