From patchwork Fri Mar 17 02:31:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178416 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 416D1C7618E for ; Fri, 17 Mar 2023 02:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbjCQCdh (ORCPT ); Thu, 16 Mar 2023 22:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjCQCd2 (ORCPT ); Thu, 16 Mar 2023 22:33:28 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35EA82C64F; Thu, 16 Mar 2023 19:33:23 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id c8-20020a05600c0ac800b003ed2f97a63eso4282955wmr.3; Thu, 16 Mar 2023 19:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020401; 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=ymG14CaAzsom/NpfgXxdIjVcFWXkyKWBzQS1t9W8TsU=; b=ZnLfPimuNMRCq+vueikd9c51+25vJac2ZxxU7UyB76QTmrEIwo4rN+PyOOWNsvEoaj Jpk2GQC59J0kpQPcP4jlt+pBegpHzcQs6kh34OmzoU3nzzmauNRSFH96dVwUqrKqwO1J DR3CoZhP+vfNFcJET39aGxyGhiakx+KWxKqc+BVFrSlps7tyjCZJ+aMqv/hESueQcCW5 86DbqSuK0vu9AGUfCmv2UZkJQhivnD5SN5YoBUBk0UK0W4waKdMM4f7UdCROArjIZPZR e9u9xV6K7b65yrY8SOtrKbAfXKCOwPdLSi/d8lpeL9OBJrxV1MZTaeL5iHskCQsBiGVy BOzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020401; 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=ymG14CaAzsom/NpfgXxdIjVcFWXkyKWBzQS1t9W8TsU=; b=F2cWIHXnky7rCW0qrIA59K+xbvZO2DJldf62Cf2VNibUxOm1fcUB1/UAoE//cYLB65 geJu5yxUTp9IcAaqY8QgQNPHQKyjkxMYbcU9BI3J8I1CiVIGEq+4QGqwJY3UTDc2wMbU f7OmEze//EvcDm1g+7i3l8xxGFzPEHMZPCeeQlt1v1LC9GjIk4j6Ka9QAiRbKa1TDtPx CRMVRf9M1up1y60eL+vQOZW/0hM9d5aA/6hud85WTVy4yKN+uHItggCanJ4nB6IEGNIO tDzmOiJ37DDah/qhU2aEdWWMYqkjO/4/7+5JTMPbot7fwImdf9KlpBNWnZEIpOWhXFis JBFA== X-Gm-Message-State: AO0yUKVQy3ggl8TY3G4qaoyxMpRqH4FPUUWRu28bZJ148gHOHZlWOfVB JNnUZr7C83FuQlykoB80Aoc= X-Google-Smtp-Source: AK7set90zN/Pajq1elk40QOIzkhud0Nl/bWmI2MgiOSNGVnEUw+fEjcL397+mkdD/mEEhTY3UR+VpQ== X-Received: by 2002:a05:600c:5487:b0:3ed:418a:ec06 with SMTP id iv7-20020a05600c548700b003ed418aec06mr5342265wmb.28.1679020401323; Thu, 16 Mar 2023 19:33:21 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:21 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 01/14] net: dsa: qca8k: move qca8k_port_to_phy() to header Date: Fri, 17 Mar 2023 03:31:12 +0100 Message-Id: <20230317023125.486-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move qca8k_port_to_phy() to qca8k header as it's useful for future reference in Switch LEDs module since the same logic is applied to get the right index of the switch port. Make it inline as it's simple function that just decrease the port. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/dsa/qca/qca8k-8xxx.c | 15 --------------- drivers/net/dsa/qca/qca8k.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 2f224b166bbb..8dfc5db84700 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -716,21 +716,6 @@ qca8k_phy_eth_command(struct qca8k_priv *priv, bool read, int phy, return ret; } -static u32 -qca8k_port_to_phy(int port) -{ - /* From Andrew Lunn: - * Port 0 has no internal phy. - * Port 1 has an internal PHY at MDIO address 0. - * Port 2 has an internal PHY at MDIO address 1. - * ... - * Port 5 has an internal PHY at MDIO address 4. - * Port 6 has no internal PHY. - */ - - return port - 1; -} - static int qca8k_mdio_busy_wait(struct mii_bus *bus, u32 reg, u32 mask) { diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h index 03514f7a20be..4e48e4dd8b0f 100644 --- a/drivers/net/dsa/qca/qca8k.h +++ b/drivers/net/dsa/qca/qca8k.h @@ -422,6 +422,20 @@ struct qca8k_fdb { u8 mac[6]; }; +static inline u32 qca8k_port_to_phy(int port) +{ + /* From Andrew Lunn: + * Port 0 has no internal phy. + * Port 1 has an internal PHY at MDIO address 0. + * Port 2 has an internal PHY at MDIO address 1. + * ... + * Port 5 has an internal PHY at MDIO address 4. + * Port 6 has no internal PHY. + */ + + return port - 1; +} + /* Common setup function */ extern const struct qca8k_mib_desc ar8327_mib[]; extern const struct regmap_access_table qca8k_readable_table; From patchwork Fri Mar 17 02:31:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178414 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 F10A4C7619A for ; Fri, 17 Mar 2023 02:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbjCQCd2 (ORCPT ); Thu, 16 Mar 2023 22:33:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjCQCd1 (ORCPT ); Thu, 16 Mar 2023 22:33:27 -0400 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 6BD963431F; Thu, 16 Mar 2023 19:33:24 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t15so3183670wrz.7; Thu, 16 Mar 2023 19:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020403; 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=M0xMG6givT4f8o19qLRLHBsIA04l82xMiUCl6G/kflM=; b=bC458e1qURaA/VvgQSyeR3vF4HY/Sfu1FxSQrDTbzxwq22Cn9VYYfa6a42a+nxsP/s 3VwRmJtv7i4YKf+S5ynI2BwRU1V/0cKM0QL4pnG9mR347ZvfyB2ripPu6x+xUIWOLXhy 6grH2/vlIpGtJwRCbq8Pwe0MO0yU1TdlnKPIUsdrHiiwff9TlF8AsMyhwW1bwcq/3B+w OIcgw33UgUX16fDzV6ev1GwWnmz+oj1t3HnckDJePbgS0tjZ51kDbhzPswt/EUcuYhBb n8uCGWFW2ZOs9rlq5IUbroOQSOHs6lvkLPYvuWEuDAW3XoTHkWOrzsPlZd71NQVfeIRK iPmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020403; 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=M0xMG6givT4f8o19qLRLHBsIA04l82xMiUCl6G/kflM=; b=GK+g2Bk0CauqsFMl/JKe61ynA6PLGTpe73uKszcql4Wf4oAQeoYCsVEurq/Ms/LGe3 rXwQ7KXnJwhy6bKO/ivZVFkQRmNnnOT6sj4wuTSeQSJdsnc+cyTeFjYwAql34sa9EVWo mIGOr1mLucouQ5C6YgezU70mkKtVYEQsrGsCwYKCbNrqFYTNRGz65X4MePCFQ2CFRmEs UTjzVfFreac8ZePUl47dXyta+WGvsAysKr9BtfdcRr3iXG2Z2Fcp5vQ7vcwiO5RExcCU VKypE8vHqySfDQIn1hjXQcs2u76IMY7zawha6D7S2buVWzgTzzszz0gWc8I7oJDcG54L JvbQ== X-Gm-Message-State: AO0yUKXoomNlP0N+h9AfpLYRazpeDx4YbbPzM9fjYb1dCanm/IoRENY+ M57mBcmLDVRrVY95NG7WkhY= X-Google-Smtp-Source: AK7set8ZbNBToPqvDWCqlU/JVpiCaBQgtHdWfdloThZthfJBHOeUq4FOU1LNL0wgcmdIoNXe7bxM5g== X-Received: by 2002:adf:f150:0:b0:2c9:70a4:4f94 with SMTP id y16-20020adff150000000b002c970a44f94mr6479728wro.18.1679020402653; Thu, 16 Mar 2023 19:33:22 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:22 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 02/14] net: dsa: qca8k: add LEDs basic support Date: Fri, 17 Mar 2023 03:31:13 +0100 Message-Id: <20230317023125.486-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add LEDs basic support for qca8k Switch Family by adding basic brightness_set() support. Since these LEDs refelect port status, the default label is set to ":port". DT binding should describe the color, function and number of the leds using standard LEDs api. These LEDs supports only blocking variant of the brightness_set() function since they can sleep during access of the switch leds to set the brightness. While at it add to the qca8k header file each mode defined by the Switch Documentation for future use. Signed-off-by: Christian Marangi --- drivers/net/dsa/qca/Kconfig | 8 ++ drivers/net/dsa/qca/Makefile | 3 + drivers/net/dsa/qca/qca8k-8xxx.c | 5 + drivers/net/dsa/qca/qca8k-leds.c | 192 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 59 ++++++++++ drivers/net/dsa/qca/qca8k_leds.h | 16 +++ 6 files changed, 283 insertions(+) create mode 100644 drivers/net/dsa/qca/qca8k-leds.c create mode 100644 drivers/net/dsa/qca/qca8k_leds.h diff --git a/drivers/net/dsa/qca/Kconfig b/drivers/net/dsa/qca/Kconfig index ba339747362c..7a86d6d6a246 100644 --- a/drivers/net/dsa/qca/Kconfig +++ b/drivers/net/dsa/qca/Kconfig @@ -15,3 +15,11 @@ config NET_DSA_QCA8K help This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. + +config NET_DSA_QCA8K_LEDS_SUPPORT + bool "Qualcomm Atheros QCA8K Ethernet switch family LEDs support" + depends on NET_DSA_QCA8K + depends on LEDS_CLASS + help + This enabled support for LEDs present on the Qualcomm Atheros + QCA8K Ethernet switch chips. diff --git a/drivers/net/dsa/qca/Makefile b/drivers/net/dsa/qca/Makefile index 701f1d199e93..ce66b1984e5f 100644 --- a/drivers/net/dsa/qca/Makefile +++ b/drivers/net/dsa/qca/Makefile @@ -2,3 +2,6 @@ obj-$(CONFIG_NET_DSA_AR9331) += ar9331.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o qca8k-y += qca8k-common.o qca8k-8xxx.o +ifdef CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT +qca8k-y += qca8k-leds.o +endif diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 8dfc5db84700..5decf6fe3832 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -22,6 +22,7 @@ #include #include "qca8k.h" +#include "qca8k_leds.h" static void qca8k_split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page) @@ -1727,6 +1728,10 @@ qca8k_setup(struct dsa_switch *ds) if (ret) return ret; + ret = qca8k_setup_led_ctrl(priv); + if (ret) + return ret; + qca8k_setup_pcs(priv, &priv->pcs_port_0, 0); qca8k_setup_pcs(priv, &priv->pcs_port_6, 6); diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c new file mode 100644 index 000000000000..adbe7f6e2994 --- /dev/null +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -0,0 +1,192 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +#include "qca8k.h" +#include "qca8k_leds.h" + +static int +qca8k_get_enable_led_reg(int port_num, int led_num, struct qca8k_led_pattern_en *reg_info) +{ + switch (port_num) { + case 0: + reg_info->reg = QCA8K_LED_CTRL_REG(led_num); + reg_info->shift = QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT; + break; + case 1: + case 2: + case 3: + /* Port 123 are controlled on a different reg */ + reg_info->reg = QCA8K_LED_CTRL_REG(3); + reg_info->shift = QCA8K_LED_PHY123_PATTERN_EN_SHIFT(port_num, led_num); + break; + case 4: + reg_info->reg = QCA8K_LED_CTRL_REG(led_num); + reg_info->shift = QCA8K_LED_PHY4_CONTROL_RULE_SHIFT; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int +qca8k_led_brightness_set(struct qca8k_led *led, + enum led_brightness brightness) +{ + struct qca8k_led_pattern_en reg_info; + struct qca8k_priv *priv = led->priv; + u32 mask, val = QCA8K_LED_ALWAYS_OFF; + + qca8k_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + if (brightness) + val = QCA8K_LED_ALWAYS_ON; + + if (led->port_num == 0 || led->port_num == 4) { + mask = QCA8K_LED_PATTERN_EN_MASK; + val <<= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + mask = QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + return regmap_update_bits(priv->regmap, reg_info.reg, + mask << reg_info.shift, + val << reg_info.shift); +} + +static int +qca8k_cled_brightness_set_blocking(struct led_classdev *ldev, + enum led_brightness brightness) +{ + struct qca8k_led *led = container_of(ldev, struct qca8k_led, cdev); + + return qca8k_led_brightness_set(led, brightness); +} + +static enum led_brightness +qca8k_led_brightness_get(struct qca8k_led *led) +{ + struct qca8k_led_pattern_en reg_info; + struct qca8k_priv *priv = led->priv; + u32 val; + int ret; + + qca8k_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + ret = regmap_read(priv->regmap, reg_info.reg, &val); + if (ret) + return 0; + + val >>= reg_info.shift; + + if (led->port_num == 0 || led->port_num == 4) { + val &= QCA8K_LED_PATTERN_EN_MASK; + val >>= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + val &= QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + /* Assume brightness ON only when the LED is set to always ON */ + return val == QCA8K_LED_ALWAYS_ON; +} + +static int +qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int port_num) +{ + struct fwnode_handle *led = NULL, *leds = NULL; + struct led_init_data init_data = { }; + enum led_default_state state; + struct qca8k_led *port_led; + int led_num, port_index; + int ret; + + leds = fwnode_get_named_child_node(port, "leds"); + if (!leds) { + dev_dbg(priv->dev, "No Leds node specified in device tree for port %d!\n", + port_num); + return 0; + } + + fwnode_for_each_child_node(leds, led) { + /* Reg represent the led number of the port. + * Each port can have at least 3 leds attached + * Commonly: + * 1. is gigabit led + * 2. is mbit led + * 3. additional status led + */ + if (fwnode_property_read_u32(led, "reg", &led_num)) + continue; + + if (led_num >= QCA8K_LED_PORT_COUNT) { + dev_warn(priv->dev, "Invalid LED reg defined %d", port_num); + continue; + } + + port_index = 3 * port_num + led_num; + + port_led = &priv->ports_led[port_index]; + port_led->port_num = port_num; + port_led->led_num = led_num; + port_led->priv = priv; + + state = led_init_default_state_get(led); + switch (state) { + case LEDS_DEFSTATE_ON: + port_led->cdev.brightness = 1; + qca8k_led_brightness_set(port_led, 1); + break; + case LEDS_DEFSTATE_KEEP: + port_led->cdev.brightness = + qca8k_led_brightness_get(port_led); + break; + default: + port_led->cdev.brightness = 0; + qca8k_led_brightness_set(port_led, 0); + } + + port_led->cdev.max_brightness = 1; + port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + init_data.default_label = ":port"; + init_data.devicename = "qca8k"; + init_data.fwnode = led; + + ret = devm_led_classdev_register_ext(priv->dev, &port_led->cdev, &init_data); + if (ret) + dev_warn(priv->dev, "Failed to int led"); + } + + return 0; +} + +int +qca8k_setup_led_ctrl(struct qca8k_priv *priv) +{ + struct fwnode_handle *ports, *port; + int port_num; + int ret; + + ports = device_get_named_child_node(priv->dev, "ports"); + if (!ports) { + dev_info(priv->dev, "No ports node specified in device tree!\n"); + return 0; + } + + fwnode_for_each_child_node(ports, port) { + if (fwnode_property_read_u32(port, "reg", &port_num)) + continue; + + /* Each port can have at least 3 different leds attached. + * Switch port starts from 0 to 6, but port 0 and 6 are CPU + * port. The port index needs to be decreased by one to identify + * the correct port for LED setup. + */ + ret = qca8k_parse_port_leds(priv, port, qca8k_port_to_phy(port_num)); + if (ret) + return ret; + } + + return 0; +} diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h index 4e48e4dd8b0f..3c3c072fa9c2 100644 --- a/drivers/net/dsa/qca/qca8k.h +++ b/drivers/net/dsa/qca/qca8k.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #define QCA8K_ETHERNET_MDIO_PRIORITY 7 @@ -85,6 +86,50 @@ #define QCA8K_MDIO_MASTER_DATA(x) FIELD_PREP(QCA8K_MDIO_MASTER_DATA_MASK, x) #define QCA8K_MDIO_MASTER_MAX_PORTS 5 #define QCA8K_MDIO_MASTER_MAX_REG 32 + +/* LED control register */ +#define QCA8K_LED_COUNT 15 +#define QCA8K_LED_PORT_COUNT 3 +#define QCA8K_LED_RULE_COUNT 6 +#define QCA8K_LED_RULE_MAX 11 + +#define QCA8K_LED_PHY123_PATTERN_EN_SHIFT(_phy, _led) ((((_phy) - 1) * 6) + 8 + (2 * (_led))) +#define QCA8K_LED_PHY123_PATTERN_EN_MASK GENMASK(1, 0) + +#define QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT 0 +#define QCA8K_LED_PHY4_CONTROL_RULE_SHIFT 16 + +#define QCA8K_LED_CTRL_REG(_i) (0x050 + (_i) * 4) +#define QCA8K_LED_CTRL0_REG 0x50 +#define QCA8K_LED_CTRL1_REG 0x54 +#define QCA8K_LED_CTRL2_REG 0x58 +#define QCA8K_LED_CTRL3_REG 0x5C +#define QCA8K_LED_CTRL_SHIFT(_i) (((_i) % 2) * 16) +#define QCA8K_LED_CTRL_MASK GENMASK(15, 0) +#define QCA8K_LED_RULE_MASK GENMASK(13, 0) +#define QCA8K_LED_BLINK_FREQ_MASK GENMASK(1, 0) +#define QCA8K_LED_BLINK_FREQ_SHITF 0 +#define QCA8K_LED_BLINK_2HZ 0 +#define QCA8K_LED_BLINK_4HZ 1 +#define QCA8K_LED_BLINK_8HZ 2 +#define QCA8K_LED_BLINK_AUTO 3 +#define QCA8K_LED_LINKUP_OVER_MASK BIT(2) +#define QCA8K_LED_TX_BLINK_MASK BIT(4) +#define QCA8K_LED_RX_BLINK_MASK BIT(5) +#define QCA8K_LED_COL_BLINK_MASK BIT(7) +#define QCA8K_LED_LINK_10M_EN_MASK BIT(8) +#define QCA8K_LED_LINK_100M_EN_MASK BIT(9) +#define QCA8K_LED_LINK_1000M_EN_MASK BIT(10) +#define QCA8K_LED_POWER_ON_LIGHT_MASK BIT(11) +#define QCA8K_LED_HALF_DUPLEX_MASK BIT(12) +#define QCA8K_LED_FULL_DUPLEX_MASK BIT(13) +#define QCA8K_LED_PATTERN_EN_MASK GENMASK(15, 14) +#define QCA8K_LED_PATTERN_EN_SHIFT 14 +#define QCA8K_LED_ALWAYS_OFF 0 +#define QCA8K_LED_ALWAYS_BLINK_4HZ 1 +#define QCA8K_LED_ALWAYS_ON 2 +#define QCA8K_LED_RULE_CONTROLLED 3 + #define QCA8K_GOL_MAC_ADDR0 0x60 #define QCA8K_GOL_MAC_ADDR1 0x64 #define QCA8K_MAX_FRAME_SIZE 0x78 @@ -383,6 +428,19 @@ struct qca8k_pcs { int port; }; +struct qca8k_led_pattern_en { + u32 reg; + u8 shift; +}; + +struct qca8k_led { + u8 port_num; + u8 led_num; + u16 old_rule; + struct qca8k_priv *priv; + struct led_classdev cdev; +}; + struct qca8k_priv { u8 switch_id; u8 switch_revision; @@ -407,6 +465,7 @@ struct qca8k_priv { struct qca8k_pcs pcs_port_0; struct qca8k_pcs pcs_port_6; const struct qca8k_match_data *info; + struct qca8k_led ports_led[QCA8K_LED_COUNT]; }; struct qca8k_mib_desc { diff --git a/drivers/net/dsa/qca/qca8k_leds.h b/drivers/net/dsa/qca/qca8k_leds.h new file mode 100644 index 000000000000..ab367f05b173 --- /dev/null +++ b/drivers/net/dsa/qca/qca8k_leds.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __QCA8K_LEDS_H +#define __QCA8K_LEDS_H + +/* Leds Support function */ +#ifdef CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT +int qca8k_setup_led_ctrl(struct qca8k_priv *priv); +#else +static inline int qca8k_setup_led_ctrl(struct qca8k_priv *priv) +{ + return 0; +} +#endif + +#endif /* __QCA8K_LEDS_H */ From patchwork Fri Mar 17 02:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178415 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 5A1AAC74A5B for ; Fri, 17 Mar 2023 02:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjCQCda (ORCPT ); Thu, 16 Mar 2023 22:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjCQCd1 (ORCPT ); Thu, 16 Mar 2023 22:33:27 -0400 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 B28E32E0C0; Thu, 16 Mar 2023 19:33:25 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id m2so3186805wrh.6; Thu, 16 Mar 2023 19:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020404; 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=afDlpxoJaGOlge6oF8HK8w7bmxxAcRYUXmg7BTlAgHY=; b=FKAuylYM2ILHFDRqDE7mBB8P8EzedX9Ga+jNpeK44hfNSKZUjsOqRsShUjLMHTJi1C tfHNagocmUOHYAq22hcqMXbJOM+MNzCn0T07uZWFKVhEWBNBmzpaeUHKYJZeOQet+XqP pUFC1pjHzLjBoPs6SJ9plyBgOu0va1ObyPpfkSwAus+cXoJjJUfilUJq4eBEfd41sRDu nMQEZibL8MipUEeU1igSeqx8uIEk864xehzTp9paNjBPTRIZWh8VdH/kE5WecR7cv7ti 4O+QtNtXRoD+P+qwiemcebIaASbVDVMXncGibDYJyPQ9P6BCr3JPgFAy1KM8BP11I6eL iytQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020404; 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=afDlpxoJaGOlge6oF8HK8w7bmxxAcRYUXmg7BTlAgHY=; b=gY5TIFpwVW0+zLM+DmVUffnA8VP28OvPQWTHczPMyaVkYHl0ysTFRijzu/9GneAXqv vEN4ZlODarCSHe1aQHawW6CBHdeV7GP8qkj+TIyEzvV8zI8OueG2K36cRD9pQG/h1Ast BjnraeUoL85rVxqDUu3h12AeYy2QqWstf2zqjkMYKcFhhCjnbq1DOl0H89KOFJ9/vJP8 nTsA6Doh50fRY4tB5K/0oH5WJL5YGGDqIN9o60rnM/Fhmg9srxCOWp1E0E9IxMhn+O/x ViLZVIN8F+XlNGUh/Ia2jeR0tUh4thWe5XH6WUStQ+Pb7eXSkgYIW6uUUbye3RqRk9lc EMPQ== X-Gm-Message-State: AO0yUKU1tDQ5ZecNU2SjTaHGYziOFFM+6I4VcXPVC0ePHjrarU/NWFea GU5pG5BUZLT14l96C5SWcvs= X-Google-Smtp-Source: AK7set9mFPMbMd5WaGmqDANXaolgXA1OYSJ3oPPBsUn8RnG51iWyXsK58GjgEWxKEdrMi/cJTSLDfA== X-Received: by 2002:a5d:5003:0:b0:2cf:3396:9126 with SMTP id e3-20020a5d5003000000b002cf33969126mr6507894wrt.10.1679020403968; Thu, 16 Mar 2023 19:33:23 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:23 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 03/14] net: dsa: qca8k: add LEDs blink_set() support Date: Fri, 17 Mar 2023 03:31:14 +0100 Message-Id: <20230317023125.486-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add LEDs blink_set() support to qca8k Switch Family. These LEDs support hw accellerated blinking at a fixed rate of 4Hz. Reject any other value since not supported by the LEDs switch. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/dsa/qca/qca8k-leds.c | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c index adbe7f6e2994..c229575c7e8c 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -92,6 +92,43 @@ qca8k_led_brightness_get(struct qca8k_led *led) return val == QCA8K_LED_ALWAYS_ON; } +static int +qca8k_cled_blink_set(struct led_classdev *ldev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct qca8k_led *led = container_of(ldev, struct qca8k_led, cdev); + u32 mask, val = QCA8K_LED_ALWAYS_BLINK_4HZ; + struct qca8k_led_pattern_en reg_info; + struct qca8k_priv *priv = led->priv; + + if (*delay_on == 0 && *delay_off == 0) { + *delay_on = 125; + *delay_off = 125; + } + + if (*delay_on != 125 || *delay_off != 125) { + /* The hardware only supports blinking at 4Hz. Fall back + * to software implementation in other cases. + */ + return -EINVAL; + } + + qca8k_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + if (led->port_num == 0 || led->port_num == 4) { + mask = QCA8K_LED_PATTERN_EN_MASK; + val <<= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + mask = QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + regmap_update_bits(priv->regmap, reg_info.reg, mask << reg_info.shift, + val << reg_info.shift); + + return 0; +} + static int qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int port_num) { @@ -149,6 +186,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p port_led->cdev.max_brightness = 1; port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + port_led->cdev.blink_set = qca8k_cled_blink_set; init_data.default_label = ":port"; init_data.devicename = "qca8k"; init_data.fwnode = led; From patchwork Fri Mar 17 02:31:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178417 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 9ADCCC6FD1F for ; Fri, 17 Mar 2023 02:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbjCQCdi (ORCPT ); Thu, 16 Mar 2023 22:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbjCQCda (ORCPT ); Thu, 16 Mar 2023 22:33:30 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42FBC3B87F; Thu, 16 Mar 2023 19:33:27 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id j42-20020a05600c1c2a00b003ed363619ddso2707955wms.1; Thu, 16 Mar 2023 19:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020405; 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=VM3DoNMLu3F/k6wPO3qYiXVgdAsBr9H+lF3WwRw8JHY=; b=GI3I0nTOe0aBeLI0l3/lUpIAY7Pet947XD0nFynMbOz6OX8jfYop8gvJZHiLq1O3Xo rcHANTn9UTVOALoTXuXcKBprhvxFjsmTK3W72xmyTFGPfERQj6rg2Fz7N1I3iCG8a30e Gyz0o2jBWMN4XUnPY0qsSFkk8CogUxAZsdiIrl9ObI0TVov2j2i6l37Ftwtnjdl2s9ei 6n/MEl+U4oEGOoygSea+KB9B9/7ccQYCNDBI5eXRQLyi1nPxMZ3voYJLEJnyrszEXhFX fHmHGKqsc4SM8MJo2Eu659xoog8RDZ+D5EuQ8mW+nSqjIORg/cbzza7H+xNx3Z0R+GR8 KcTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020405; 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=VM3DoNMLu3F/k6wPO3qYiXVgdAsBr9H+lF3WwRw8JHY=; b=zVN5eh/GBboxcAoVfgZXCMPC0B1aTjPUug9af4qI76fsbSVZg2yiIhsYZOqF7G6oBc BUXdwGDByD8l60ALgbPQfueRWSMEgCL/MCI+uOO8U160ntaWvRocvkreL4MUK5Ui/iZO 1oLCOaKRIiQa2VpLUG5DL5pv0fz30qIggLhAJXxQAMxpx21jraFR7NlapO+LxLWkuv7a 4Fw3atNv6NwKWgx5pqppchvU77jCSlQNVsoroiJ5ah/EI0wRWKYSfj/tgkOoaOngs00Q RROWig2zgg0ZdXqegCJTWebPr/O18Nx/RM0++MiF6Ks8MBe4Ck/7bAJftwEoWV1iMztN KPeg== X-Gm-Message-State: AO0yUKV0YTY8wsdXlNLIqsBPBR6E/NZkG5XKDAbzMIK808A+MAOv2ChA eiWAhk8RLlRTTH9wr7xjB74= X-Google-Smtp-Source: AK7set8En2UX5kQiJ8dea62WOoksLYAyaSxUNMq66Q16vu1obaE5O124QZhmeoMBq8MFnUSQ1UeOsw== X-Received: by 2002:a1c:f701:0:b0:3ed:809b:79ac with SMTP id v1-20020a1cf701000000b003ed809b79acmr405573wmh.19.1679020405234; Thu, 16 Mar 2023 19:33:25 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:24 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 04/14] net: phy: Add a binding for PHY LEDs Date: Fri, 17 Mar 2023 03:31:15 +0100 Message-Id: <20230317023125.486-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Andrew Lunn Define common binding parsing for all PHY drivers with LEDs using phylib. Parse the DT as part of the phy_probe and add LEDs to the linux LED class infrastructure. For the moment, provide a dummy brightness function, which will later be replaced with a call into the PHY driver. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- drivers/net/phy/Kconfig | 1 + drivers/net/phy/phy_device.c | 75 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 16 ++++++++ 3 files changed, 92 insertions(+) diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index f5df2edc94a5..666efa6b1c8e 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -16,6 +16,7 @@ config PHYLINK menuconfig PHYLIB tristate "PHY Device support and infrastructure" depends on NETDEVICES + depends on LEDS_CLASS select MDIO_DEVICE select MDIO_DEVRES help diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9ba8f973f26f..ee800f93c8c3 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -19,10 +19,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -658,6 +660,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, device_initialize(&mdiodev->dev); dev->state = PHY_DOWN; + INIT_LIST_HEAD(&dev->leds); mutex_init(&dev->lock); INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); @@ -2964,6 +2967,73 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->handle_interrupt; } +/* Dummy implementation until calls into PHY driver are added */ +static int phy_led_set_brightness(struct led_classdev *led_cdev, + enum led_brightness value) +{ + return 0; +} + +static int of_phy_led(struct phy_device *phydev, + struct device_node *led) +{ + struct device *dev = &phydev->mdio.dev; + struct led_init_data init_data = {}; + struct led_classdev *cdev; + struct phy_led *phyled; + int err; + + phyled = devm_kzalloc(dev, sizeof(*phyled), GFP_KERNEL); + if (!phyled) + return -ENOMEM; + + cdev = &phyled->led_cdev; + + err = of_property_read_u32(led, "reg", &phyled->index); + if (err) + return err; + + cdev->brightness_set_blocking = phy_led_set_brightness; + cdev->max_brightness = 1; + init_data.devicename = dev_name(&phydev->mdio.dev); + init_data.fwnode = of_fwnode_handle(led); + + err = devm_led_classdev_register_ext(dev, cdev, &init_data); + if (err) + return err; + + list_add(&phyled->list, &phydev->leds); + + return 0; +} + +static int of_phy_leds(struct phy_device *phydev) +{ + struct device_node *node = phydev->mdio.dev.of_node; + struct device_node *leds, *led; + int err; + + if (!IS_ENABLED(CONFIG_OF_MDIO)) + return 0; + + if (!node) + return 0; + + leds = of_get_child_by_name(node, "leds"); + if (!leds) + return 0; + + for_each_available_child_of_node(leds, led) { + err = of_phy_led(phydev, led); + if (err) { + of_node_put(led); + return err; + } + } + + return 0; +} + /** * fwnode_mdio_find_device - Given a fwnode, find the mdio_device * @fwnode: pointer to the mdio_device's fwnode @@ -3142,6 +3212,11 @@ static int phy_probe(struct device *dev) /* Set the state to READY by default */ phydev->state = PHY_READY; + /* Get the LEDs from the device tree, and instantiate standard + * LEDs for them. + */ + err = of_phy_leds(phydev); + out: /* Assert the reset signal */ if (err) diff --git a/include/linux/phy.h b/include/linux/phy.h index fbeba4fee8d4..88a77ff60be9 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -595,6 +596,7 @@ struct macsec_ops; * @phy_num_led_triggers: Number of triggers in @phy_led_triggers * @led_link_trigger: LED trigger for link up/down * @last_triggered: last LED trigger for link speed + * @leds: list of PHY LED structures * @master_slave_set: User requested master/slave configuration * @master_slave_get: Current master/slave advertisement * @master_slave_state: Current master/slave configuration @@ -690,6 +692,7 @@ struct phy_device { struct phy_led_trigger *led_link_trigger; #endif + struct list_head leds; /* * Interrupt number for this PHY @@ -825,6 +828,19 @@ struct phy_plca_status { bool pst; }; +/** + * struct phy_led: An LED driven by the PHY + * + * @list: List of LEDs + * @led_cdev: Standard LED class structure + * @index: Number of the LED + */ +struct phy_led { + struct list_head list; + struct led_classdev led_cdev; + u32 index; +}; + /** * struct phy_driver - Driver structure for a particular PHY type * From patchwork Fri Mar 17 02:31:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178419 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 66B76C77B62 for ; Fri, 17 Mar 2023 02:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbjCQCdn (ORCPT ); Thu, 16 Mar 2023 22:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbjCQCdg (ORCPT ); Thu, 16 Mar 2023 22:33:36 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5506F10407; Thu, 16 Mar 2023 19:33:28 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id o7so3191160wrg.5; Thu, 16 Mar 2023 19:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020406; 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=VMcNLbmNu1IC9Ea6lnqltnBFoBgoPx4QsFmf6AH28VU=; b=bPAzEkLkh2idGz96hGdIeQqeotS/uUEVkZssv/m3V2O5F8nb5Nq+D3Z6yNxGly88B/ 6+otGpsasteHFvS0Ggmjf5pgW7et/WdxQkU4oZwmFS3rI4bPGX1Cv6+2c9HU0/B6/zVL DwckB4/YaGXXcb8PICGs7dhI/D7oUbxDopvRzCdgXHVaMtgojrYiWa/+cfBGmChOKHcx hsOQMTQK4UoGOWwPIFyz2P/YjRRXvWBVYYwAclAc71Uh92pCTB/NXCZ8Bg2UG7Nh1aBj LtpcBNSYded+jUB7S+5eJaUWRndfIbzt5IqgMCsiBDFmwqBDSFuG1mzPbscOcDc+Kdrn EQCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020406; 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=VMcNLbmNu1IC9Ea6lnqltnBFoBgoPx4QsFmf6AH28VU=; b=dA0Ry8rv5DXh9wg1O79AVPFCLJolVZhSwUWvNBF1OpVQEv0lB7cZgItL23ls/sQW/X 1LviPlwUX7FCT8n6MuLzKqYTEeNwflY5qDcOtCdSI4+XrLdXwmdzwENpUZRwt6dklm8q n6Wej/u0kFZSbgmNezsPtKnT00xj+8+G16l4H4QGBhJFJaZkcculQF9jakTRHqxENEaM prVPYoUOlxB2DBRV8c21PSRVrzJQGcY4EUWp4wwCmFpL0Psa+3cFRpilhxJ77KEmAUIj WoCN9k7ZG//k3PCMrjH+rWPjkjjPff5Wjdg799LbAf5lLmsZn5Y6h+GByeGgjrpnuGOM f7oA== X-Gm-Message-State: AO0yUKV9iExaw5SLhJUPWu1TmNTVKhMjrj3DXihSTNxh4n0KPh75eMjp zt4qTfS47V2W2F6kDock9Ic= X-Google-Smtp-Source: AK7set+q59W1RYMtv95UcF4w09yWKGPNVs1o2aEKUlyf/F/of1Qg64wMr9s8S44seQ4ZfsblZIUPAg== X-Received: by 2002:adf:e8cd:0:b0:2ce:a85b:17b with SMTP id k13-20020adfe8cd000000b002cea85b017bmr5490389wrn.61.1679020406514; Thu, 16 Mar 2023 19:33:26 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:26 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 05/14] net: phy: phy_device: Call into the PHY driver to set LED brightness Date: Fri, 17 Mar 2023 03:31:16 +0100 Message-Id: <20230317023125.486-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Andrew Lunn Linux LEDs can be software controlled via the brightness file in /sys. LED drivers need to implement a brightness_set function which the core will call. Implement an intermediary in phy_device, which will call into the phy driver if it implements the necessary function. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- drivers/net/phy/phy_device.c | 15 ++++++++++++--- include/linux/phy.h | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index ee800f93c8c3..c7312a9e820d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2967,11 +2967,18 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->handle_interrupt; } -/* Dummy implementation until calls into PHY driver are added */ static int phy_led_set_brightness(struct led_classdev *led_cdev, enum led_brightness value) { - return 0; + struct phy_led *phyled = to_phy_led(led_cdev); + struct phy_device *phydev = phyled->phydev; + int err; + + mutex_lock(&phydev->lock); + err = phydev->drv->led_brightness_set(phydev, phyled->index, value); + mutex_unlock(&phydev->lock); + + return err; } static int of_phy_led(struct phy_device *phydev, @@ -2988,12 +2995,14 @@ static int of_phy_led(struct phy_device *phydev, return -ENOMEM; cdev = &phyled->led_cdev; + phyled->phydev = phydev; err = of_property_read_u32(led, "reg", &phyled->index); if (err) return err; - cdev->brightness_set_blocking = phy_led_set_brightness; + if (phydev->drv->led_brightness_set) + cdev->brightness_set_blocking = phy_led_set_brightness; cdev->max_brightness = 1; init_data.devicename = dev_name(&phydev->mdio.dev); init_data.fwnode = of_fwnode_handle(led); diff --git a/include/linux/phy.h b/include/linux/phy.h index 88a77ff60be9..94fd21d5e145 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -832,15 +832,19 @@ struct phy_plca_status { * struct phy_led: An LED driven by the PHY * * @list: List of LEDs + * @phydev: PHY this LED is attached to * @led_cdev: Standard LED class structure * @index: Number of the LED */ struct phy_led { struct list_head list; + struct phy_device *phydev; struct led_classdev led_cdev; u32 index; }; +#define to_phy_led(d) container_of(d, struct phy_led, led_cdev) + /** * struct phy_driver - Driver structure for a particular PHY type * @@ -1063,6 +1067,13 @@ struct phy_driver { /** @get_plca_status: Return the current PLCA status info */ int (*get_plca_status)(struct phy_device *dev, struct phy_plca_status *plca_st); + + /* Set a PHY LED brightness. Index indicates which of the PHYs + * led should be set. Value follows the standard LED class meaning, + * e.g. LED_OFF, LED_HALF, LED_FULL. + */ + int (*led_brightness_set)(struct phy_device *dev, + u32 index, enum led_brightness value); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) From patchwork Fri Mar 17 02:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178420 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 0C654C74A5B for ; Fri, 17 Mar 2023 02:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbjCQCdm (ORCPT ); Thu, 16 Mar 2023 22:33:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbjCQCdh (ORCPT ); Thu, 16 Mar 2023 22:33:37 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0DBC6A2F1; Thu, 16 Mar 2023 19:33:29 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id h17so3181040wrt.8; Thu, 16 Mar 2023 19:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020408; 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=aWZQzx1QVjFR7PtxmwDYhslTiYmGtSqjdVyVCfsWuRM=; b=Hea5y6uv72ob2BxPMzKr5SLIt3lH3fGM6CC/7dTHPf2KLuWsDLdzFt7TR6nEUVBA6D MdDPFJ2D+Oh6kBt0nmWs5QPfLllSgq00jjVFVxeksZ5RgD7SwGOxH5Sn/WlwKdKm3Ukh LePp9CPLcNFUhIsDXKQOs4XQVUotb9TRjuoIfXC91sejGqHm0QBZTNYRDdTTB56hrT4X AEWXBbelwr1nHm+eDTEOOy1GfgxmYmOIrbWDO4j5I0H18FXIq6q2n5JhO791S7htKvPp MZ5dIvtAhzfYFOwUxibnCQ+wAdlNcULHWSEwHtdM/gL/MYB1UNvqzgVKzkBpawdeL29G dKQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020408; 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=aWZQzx1QVjFR7PtxmwDYhslTiYmGtSqjdVyVCfsWuRM=; b=E12LNEnAQUloyzOjNAi6J4bXD9QspPEZreZlhsnppDjxy4QJe5u27jKDAsH3cHgmOM XOuX1oVItd+v/53ZHz53wx5hiUESnDqE2jFDu5cGajVJeuxhmR3LYFOz+TtNECIILxU4 Wqr5han8aWzgXNIdkNqd2eCs9tYoZhvE4T0VcA/Gwb7lJAaCvEexHAXYVhHSjF7BSx15 LiAFIIApiszGrH3FsiYVoSecPridv+EiNfudxwMfzujtLsozVGaxPt3mXZTzixZ96qL1 LExQRpv1+YOocQ08Kt6qIcPVmX8d4jb7njIi+aF/y8reLDOmHj36OdraaABO66pB+c5l 9t3w== X-Gm-Message-State: AO0yUKW6HTZh7ac0gnuiM2C2Q3A9TUe00SLpotRqMi9NiMJ2KMO4pYyj AybLQ2YluyRkLs9NdG08mDE= X-Google-Smtp-Source: AK7set8hwZlt3nygFc6PWKNG0m1p9SxA7X9BdPr5ECilPi56l1NlR2CxpxO7b/eeTn+XQngOiFmmXw== X-Received: by 2002:a5d:6304:0:b0:2cf:e67d:d046 with SMTP id i4-20020a5d6304000000b002cfe67dd046mr5698138wru.28.1679020407803; Thu, 16 Mar 2023 19:33:27 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:27 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 06/14] net: phy: marvell: Add software control of the LEDs Date: Fri, 17 Mar 2023 03:31:17 +0100 Message-Id: <20230317023125.486-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Andrew Lunn Add a brightness function, so the LEDs can be controlled from software using the standard Linux LED infrastructure. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- drivers/net/phy/marvell.c | 45 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 0d706ee266af..cadf9da13b82 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -144,11 +144,13 @@ /* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) -/* LED Timer Control Register */ -#define MII_88E1318S_PHY_LED_TCR 0x12 -#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) -#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) -#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) +#define MII_88E1318S_PHY_LED_FUNC 0x10 +#define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) +#define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_TCR 0x12 +#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) +#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) +#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) /* Magic Packet MAC address registers */ #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17 @@ -2832,6 +2834,34 @@ static int marvell_hwmon_probe(struct phy_device *phydev) } #endif +static int m88e1318_led_brightness_set(struct phy_device *phydev, + u32 index, enum led_brightness value) +{ + int reg; + + reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC); + if (reg < 0) + return reg; + + switch (index) { + case 0: + case 1: + case 2: + reg &= ~(0xf << (4 * index)); + if (value == LED_OFF) + reg |= MII_88E1318S_PHY_LED_FUNC_OFF << (4 * index); + else + reg |= MII_88E1318S_PHY_LED_FUNC_ON << (4 * index); + break; + default: + return -EINVAL; + } + + return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC, reg); +} + static int marvell_probe(struct phy_device *phydev) { struct marvell_priv *priv; @@ -3081,6 +3111,7 @@ static struct phy_driver marvell_drivers[] = { .get_sset_count = marvell_get_sset_count, .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1145, @@ -3187,6 +3218,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1540, @@ -3213,6 +3245,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1545, @@ -3239,6 +3272,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E3016, @@ -3380,6 +3414,7 @@ static struct phy_driver marvell_drivers[] = { .get_stats = marvell_get_stats, .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, + .led_brightness_set = m88e1318_led_brightness_set, }, }; From patchwork Fri Mar 17 02:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178418 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 C31A7C7619A for ; Fri, 17 Mar 2023 02:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbjCQCdk (ORCPT ); Thu, 16 Mar 2023 22:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjCQCdh (ORCPT ); Thu, 16 Mar 2023 22:33:37 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6CCF6BDD1; Thu, 16 Mar 2023 19:33:30 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id q16so3199344wrw.2; Thu, 16 Mar 2023 19:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020409; 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=5HAlDMClSna0/uEvZR0Ovj6OmaH2Z8PGvM5wxNKi3Tc=; b=nKQ0XdS4521tYgbCKplAGUd7qQrJrc3wFKD3qy2l6gz1CG38r6JayUzjqLhnnaAu6s tQ6KBRxgmywpSHZJdn6SFVQgJQaVSCDUKGcPenmGgoX93il8SIU4Y83deG7oIs8EuQkc nbEFXbs+gW4mTzvOijBzMnB20X22z760q4qacbhvaBHDlatKVj/baXJAebc156c7BeD6 /h4U3zeA2VlEWZoMYlr2L6C9K/Tl33kL0i5OCVfxHQZd7ZKvC3sdofLxoZc+MelV2f/R CVT/qSb+f2uYMCDOwGw9cQza7JvX7i/wyo1IlGzbSOuBusu/lvS9pWscUci1Rfbp9G+L ilgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020409; 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=5HAlDMClSna0/uEvZR0Ovj6OmaH2Z8PGvM5wxNKi3Tc=; b=SlK9tgmuy9pogumxu3iDtQOWkOZqTypPjKOnOpu3Lj2/2K0Y/ijwkXcCI9TzM/uolV maa7pct78fwVdotCDTmGtzlwXZid7BG3Gm4I5aZ7SgfQaOJSo761IOVHyRnS3Euc3oRh EtEP59pgpLRnIf2NliRzlHZ/5Dbv+PfNuMQoV52EUDggi3wG5DFbrvUMzG93p2CUoESB wCnJchoAV9DvY/Yik6Lg/SChbwZ5zNdvsve9/Elh1AFn6MOuHPg7DlEHzDwf8ll0dlau PX+I0FUcjmZA7zSS/u99jJYIdPtJDY3SCoH+4ZZaGx6aOEtVmOzNf6v+zTUEYXWMMNQH h7Kg== X-Gm-Message-State: AO0yUKWWpnDAF7gCFkEULpARgXhyDvUyuPRs5AkYJX2l/yOwcRCmktA/ YQKmHblEZpUuSFczntC+ONg= X-Google-Smtp-Source: AK7set9B3AAouz73aYp6/ftKargRjZfg3mnSZKfhSWrSgE8yC9KYbmaJIr7p8NbWM6Alz+wU7c8UrA== X-Received: by 2002:a5d:5249:0:b0:2bf:bf05:85ac with SMTP id k9-20020a5d5249000000b002bfbf0585acmr971817wrc.23.1679020409058; Thu, 16 Mar 2023 19:33:29 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:28 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 07/14] net: phy: phy_device: Call into the PHY driver to set LED blinking Date: Fri, 17 Mar 2023 03:31:18 +0100 Message-Id: <20230317023125.486-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Andrew Lunn Linux LEDs can be requested to perform hardware accelerated blinking. Pass this to the PHY driver, if it implements the op. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- drivers/net/phy/phy_device.c | 18 ++++++++++++++++++ include/linux/phy.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index c7312a9e820d..b4be02a21bb8 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2981,6 +2981,22 @@ static int phy_led_set_brightness(struct led_classdev *led_cdev, return err; } +static int phy_led_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct phy_led *phyled = to_phy_led(led_cdev); + struct phy_device *phydev = phyled->phydev; + int err; + + mutex_lock(&phydev->lock); + err = phydev->drv->led_blink_set(phydev, phyled->index, + delay_on, delay_off); + mutex_unlock(&phydev->lock); + + return err; +} + static int of_phy_led(struct phy_device *phydev, struct device_node *led) { @@ -3003,6 +3019,8 @@ static int of_phy_led(struct phy_device *phydev, if (phydev->drv->led_brightness_set) cdev->brightness_set_blocking = phy_led_set_brightness; + if (phydev->drv->led_blink_set) + cdev->blink_set = phy_led_blink_set; cdev->max_brightness = 1; init_data.devicename = dev_name(&phydev->mdio.dev); init_data.fwnode = of_fwnode_handle(led); diff --git a/include/linux/phy.h b/include/linux/phy.h index 94fd21d5e145..58cb44960573 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1074,6 +1074,14 @@ struct phy_driver { */ int (*led_brightness_set)(struct phy_device *dev, u32 index, enum led_brightness value); + /* Activate hardware accelerated blink, delays are in milliseconds + * and if both are zero then a sensible default should be chosen. + * The call should adjust the timings in that case and if it can't + * match the values specified exactly. + */ + int (*led_blink_set)(struct phy_device *dev, u32 index, + unsigned long *delay_on, + unsigned long *delay_off); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) From patchwork Fri Mar 17 02:31:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178423 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 369F2C7618E for ; Fri, 17 Mar 2023 02:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbjCQCeH (ORCPT ); Thu, 16 Mar 2023 22:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjCQCdl (ORCPT ); Thu, 16 Mar 2023 22:33:41 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B379E6E83; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o7so3191234wrg.5; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020410; 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=EAIyowZ09FXZUmzLZp+e5DauphCJoO6duVGhgX3FJVo=; b=WmTIDck6RfM6KIxwjL+6WbrVKpHsyN/oiYJ6CrLgqmzPgKKyo/U6AMZ3/6XSd0VjUh mvYHtD6mBFd0PgdTDdFG3ltEgyVyYUinJ3Wx9axdB9xaSGJvLhWcMFTs49N3CR2lIfeZ Q9B17hiLUJJiOlltnC7FACFsDLW7VIt4fR2fFeSKtE8rJnB81Riz0p3aqWqBWrBLNQ+8 SiwqcwLE3wCXAHspGgtjwASeDGs5UHO713KMmI3b2J+1jsgPeAI5YKq7VEuBG2w66g9j k+9V1d7kpj6CS8D+aIg5CynIok22SI/EAXXgP9CR9WoWQXrYRxri0BxWv9O8rMjHUi5Y 27KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020410; 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=EAIyowZ09FXZUmzLZp+e5DauphCJoO6duVGhgX3FJVo=; b=WYS+39facGA9HYRh0Kx40wLtZPLML4QGBbQwPWAH4pCVlAj/t3UOBe9C91Q8+SrSk6 pizJqSb6t8SjNxTbIV8Y8lnx9LUH/5BBomHUVoyzL0FmdJ783vHP158aO223fFAM7zKF /QMcxNBcN6xklxsQNNpzwblUNNF1kOyNRvPP18S20UNT6VGZs/6iEjFpZfI2sx7vu7CD Cwd8BvZXcmSTJbj9mQjc5qiuOd6xUSB9j7/28pecnLT99cF5vCzzDfHUP2J19x/XyCQO ZOdHmPaVvHUcmE/VEQT+TBZS+7Qe5pD0PZPkC3YfDn+Ln4GRNN0pCSp3j5Ci86aYfULC Eufg== X-Gm-Message-State: AO0yUKUu0nJNo9/hAerdpoogA2d0C6UIv9MnStTkhlJUYTgAWKCW9nD0 Ifhtr6pqXEVgshMQkOpXrUU= X-Google-Smtp-Source: AK7set9An/RnMF2bxwqBBST/FXNnWn65rXRDqvSwgdOgJVCcwLeom+PFgH2uSJ3CcNP12q1jTNS6xw== X-Received: by 2002:a5d:6084:0:b0:2ce:9e0a:10ae with SMTP id w4-20020a5d6084000000b002ce9e0a10aemr5657138wrt.53.1679020410340; Thu, 16 Mar 2023 19:33:30 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:30 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 08/14] net: phy: marvell: Implement led_blink_set() Date: Fri, 17 Mar 2023 03:31:19 +0100 Message-Id: <20230317023125.486-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Andrew Lunn The Marvell PHY can blink the LEDs, simple on/off. All LEDs blink at the same rate, and the reset default is 84ms per blink, which is around 12Hz. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- drivers/net/phy/marvell.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index cadf9da13b82..c86283a4c0a9 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -147,6 +147,8 @@ #define MII_88E1318S_PHY_LED_FUNC 0x10 #define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) #define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_FUNC_HI_Z (0xa) +#define MII_88E1318S_PHY_LED_FUNC_BLINK (0xb) #define MII_88E1318S_PHY_LED_TCR 0x12 #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) @@ -2862,6 +2864,35 @@ static int m88e1318_led_brightness_set(struct phy_device *phydev, MII_88E1318S_PHY_LED_FUNC, reg); } +static int m88e1318_led_blink_set(struct phy_device *phydev, u32 index, + unsigned long *delay_on, + unsigned long *delay_off) +{ + int reg; + + reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC); + if (reg < 0) + return reg; + + switch (index) { + case 0: + case 1: + case 2: + reg &= ~(0xf << (4 * index)); + reg |= MII_88E1318S_PHY_LED_FUNC_BLINK << (4 * index); + /* Reset default is 84ms */ + *delay_on = 84 / 2; + *delay_off = 84 / 2; + break; + default: + return -EINVAL; + } + + return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC, reg); +} + static int marvell_probe(struct phy_device *phydev) { struct marvell_priv *priv; @@ -3112,6 +3143,7 @@ static struct phy_driver marvell_drivers[] = { .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1145, @@ -3219,6 +3251,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1540, @@ -3246,6 +3279,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1545, @@ -3273,6 +3307,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E3016, @@ -3415,6 +3450,7 @@ static struct phy_driver marvell_drivers[] = { .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, }; From patchwork Fri Mar 17 02:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178422 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 BB384C7618B for ; Fri, 17 Mar 2023 02:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjCQCeG (ORCPT ); Thu, 16 Mar 2023 22:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbjCQCdm (ORCPT ); Thu, 16 Mar 2023 22:33:42 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72DDBB328A; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id p4so3182125wre.11; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020412; 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=mZv5FnCiudZKDVGAnq53ZSH02fIH+isgRk91M2T3n+E=; b=RTp0mEPG1x3QJnyW+mXKNUnNncVZBTlmPW9XN1NL6oKJ2YK/P6EiNv4TetcqzBuVrt aVAXC6nHT/OwmIgPFOyOz2Hl3f4MCFJwpWxFWOArr4Ha0f12Lhm/31IP0ssyeFXLBtcx rImaOYJtfuOw8QzUq5GfxJ1TIcG/0k8I5pkpAAoJb/czmE/QTnPEajyVU+gqkPrngOLL B/WBB1Ex04tUUBPXlAvQC76DuOyJkYx+RS67GJ7TI4APDMTp/1sc9cKINbCAKxKL0qEu qeOvFFIOiAESrufZCaThJe+6Guj1JTaWwOn4IFTkMVRIehW6NQu+hAEHU+UIpr4rh07B aFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020412; 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=mZv5FnCiudZKDVGAnq53ZSH02fIH+isgRk91M2T3n+E=; b=w/Ol2ZXOs/QCshLBg8/XSsoVYQvF8lxqTQ3IYtNXzHugjWMQNFKU+k5G6ZAfihIf4N Q3/xm47uxleD8Kih7T8ZKCDCxvwGa3nZeicliM6FIgDpmsG8/KiEg/YBGBlk/7zWFfcn e4UnNuDv9eA+3MNRf5MrwAuwig/szZs6+teRUT8r8RIqd7cSnZdEPATKDYFkVNIYre0s MXT/4SIOGR9cEBPr7HyHyi2m4ZSgV8SRkZcV2jbPH2H6Zf0DhbE34W/3CZMW+YHa/yGN MhEPQ7NZbzLPfVsg671G5scpP9tyzMeluvzrNgnstQrOAZCsCe+HYcwJL41dpuJwYqWB HY5g== X-Gm-Message-State: AO0yUKXGPOyQfB7i30dFzUixDZRnZSG20JIO+dRizr+ZjOYkKbTp9rI4 HkjYOBERNrzH1mBTj8S6rXM= X-Google-Smtp-Source: AK7set//rwtVf+fHh7PC4t8hAhqjPN3KDY+OjIA+hirS0GP2IXeP8gw4kQ9vCI9DHQ2uVrUDV/zasw== X-Received: by 2002:adf:ee52:0:b0:2ce:a938:ecc9 with SMTP id w18-20020adfee52000000b002cea938ecc9mr6245320wro.69.1679020411651; Thu, 16 Mar 2023 19:33:31 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:31 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 09/14] dt-bindings: net: ethernet-controller: Document support for LEDs node Date: Fri, 17 Mar 2023 03:31:20 +0100 Message-Id: <20230317023125.486-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Document support for LEDs node in ethernet-controller. Ethernet Controller may support different LEDs that can be configured for different operation like blinking on traffic event or port link. Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since ethernet-controller LEDs are controllable by the ethernet controller regs and the possible intergated PHY doesn't have control on them. Signed-off-by: Christian Marangi --- .../bindings/net/ethernet-controller.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index 00be387984ac..a93673592314 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -222,6 +222,27 @@ properties: required: - speed + leds: + type: object + description: + Describes the LEDs associated by Ethernet Controller. + These LEDs are not integrated in the PHY and PHY doesn't have any + control on them. Ethernet Controller regs are used to control + these defined LEDs. + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + + additionalProperties: false + dependencies: pcs-handle-names: [pcs-handle] From patchwork Fri Mar 17 02:31:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178421 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 EC81BC74A5B for ; Fri, 17 Mar 2023 02:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbjCQCeB (ORCPT ); Thu, 16 Mar 2023 22:34:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjCQCdm (ORCPT ); Thu, 16 Mar 2023 22:33:42 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC2AD503; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id r18so3199936wrx.1; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020413; 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=YxutGMPJva579mmTcYCtLi8ZBTi3DvGd1nN+fb8Tx6U=; b=nDOcGQfTe+PWjvaki2Z3MC2j4Gqvodmqm+7lZRZfBxswVyOOJ2Qy3b92wZjiy2VYGa gtSBY5HVAYVJi3CdnEbkzurM4dpeyOSGV2SSw9WoAPzkS8HnBMtYRXjHLxnM66NrDbNi 3dD+IBQ1Bhp5EQAllKXtrSMI2EHiXXeBlcV9LzOdMrnj2acEkrnKOM/8AwPdXi3FhPWN sGsfjFpLDRnwjdntBMHxxfK0uale20WI1u0bO8rqvHjYeEV81P5byxamqURLHGCwXN1u vV3yMuRujrFvsGqUhTcJ9/jWbnhmxzU2C5AsReTXFZuayWEQR/XMsMIgCiMHdnxOXbey 7Xhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020413; 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=YxutGMPJva579mmTcYCtLi8ZBTi3DvGd1nN+fb8Tx6U=; b=1q7S2XSZdd8A3tPmazgqLTCrz0h2jeCgIsORnc4Vglmb5D1jbHTC3obdJaUu7nyDR4 Cw9xT+szb/662dSAdtPm+8aP0jF46od/pThTXPMeHFlzbSyX9fkvgIIijcr16HskrrQA zjLoezWv1OKDoQMkVqUAERQYQ9mUXmjKsWqay31g1thbPNcjB/0vrA2Q/Md27ef27yUp lCEhrhi46F0bGUaxOTFqEAZ+zX193q1IHn2b85R8w4v5HgQ8LAbzKbTDv4aXqkB/cYzW UGceQocfIAkLfz5Rt59iHF4YSqvDqZOys7BZ0diIcgHpbvzCqwRYAUPFAuQxwlPjVndq FhpQ== X-Gm-Message-State: AO0yUKVTkbADeGbX6RhKyd8oSGrJnllzEPQyx6bA+d6t13lJMXUvSg7j VVspVMKu9Q9e/GGcXvLbqRw= X-Google-Smtp-Source: AK7set/lmxlmdee0c0/2GIyKWe6wn5BrqjcQ6Fkwm0eCSjWuwFM/o7NEv9Aae6aB4mW37+nisd/UFw== X-Received: by 2002:a5d:510d:0:b0:2c5:540b:886c with SMTP id s13-20020a5d510d000000b002c5540b886cmr1086733wrt.31.1679020413009; Thu, 16 Mar 2023 19:33:33 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:32 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 10/14] dt-bindings: net: dsa: qca8k: add LEDs definition example Date: Fri, 17 Mar 2023 03:31:21 +0100 Message-Id: <20230317023125.486-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add LEDs definition example for qca8k Switch Family to describe how they should be defined for a correct usage. Signed-off-by: Christian Marangi --- .../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 389892592aac..2e9c14af0223 100644 --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml @@ -18,6 +18,8 @@ description: PHY it is connected to. In this config, an internal mdio-bus is registered and the MDIO master is used for communication. Mixed external and internal mdio-bus configurations are not supported by the hardware. + Each phy has at least 3 LEDs connected and can be declared + using the standard LEDs structure. properties: compatible: @@ -117,6 +119,7 @@ unevaluatedProperties: false examples: - | #include + #include mdio { #address-cells = <1>; @@ -226,6 +229,27 @@ examples: label = "lan1"; phy-mode = "internal"; phy-handle = <&internal_phy_port1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; }; port@2 { From patchwork Fri Mar 17 02:31:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178424 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 843C3C74A5B for ; Fri, 17 Mar 2023 02:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbjCQCeL (ORCPT ); Thu, 16 Mar 2023 22:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbjCQCd4 (ORCPT ); Thu, 16 Mar 2023 22:33:56 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FD84B5FD3; Thu, 16 Mar 2023 19:33:36 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so4274481wmb.5; Thu, 16 Mar 2023 19:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y2fNz2U3Pb1myw1nW6JzmHX3WnYBSrD+c2lY+3aHW8M=; b=MvAPnp/x+3dMsvqIme9hGfx9GPOwYDjvy8ULFwF3i0oLJvBJU+A1zIKILf+YJ4XXHT Y8ZKl12i0S4zR5V/gxxmVWtEZclaGFU0a7rjZopfgg8s3ScN74UXXMi7aNKb1/RnASL1 VkYE2z+7jNDDGAPEpMEMMKO3N26Skm+QUWiEOXzXExbEF1HiCa/92f1OIAa/Y50pk2pM yjPclHyazOaxbhMeR0cpaNnmQirvDukmpaXkxbZ2XM5R6QuncXVRAxwiDsyjeaK6wppC krJGkwGWxn5SjhBpvWqHcoXE2S2gmmxlwUyYvTCSSkiG3lci42ojwgr0LmW1RMQzuKRb OMXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y2fNz2U3Pb1myw1nW6JzmHX3WnYBSrD+c2lY+3aHW8M=; b=oGQUgJbljQSz4GgcrpykIFXd62s3eZqcgRtSFoD6eB7GoHviDBh5uNoG9VPKDkNxle R0+7uYB0J4X0rYEqOhyO8p/LkCisVQs5Q/LAHa+CYEKAJAt07z6EbvxYqWY4O9ZW38Zk YyiFVE32V76Smhp4TuZwfYqXducsxMDgxAKU09IOHluJM7cJi2l83f9+o78DnXvo/r03 Ya6FnNA7z2ljxddgiQfdG3U8uQQAEmK5Dsljxz0uboWLZbORvmVUYzA/Siywv84cbRQ4 F3i6Y+Z1KTIR+DtkLN7+QfxjZ58I1017LGOM39YAd12jvDTXcYWZb4+2gj0X9MOG5y+L Oh8w== X-Gm-Message-State: AO0yUKXYZdjfin3vJtjGYdUgUAuh7zjbY+DMGZmvaCn1lKEa0eG0GQ/F ohY//njFOAm9iIoXyXFozl0= X-Google-Smtp-Source: AK7set9NVXvJxrdQHvGCR6rIaEr1kTfeoZr8ogQyqlxsK4KW9JwQSINmWoPljf8J0n1ShQDa7dj3RQ== X-Received: by 2002:a05:600c:3514:b0:3e2:6c6:31a6 with SMTP id h20-20020a05600c351400b003e206c631a6mr22785631wmq.9.1679020414336; Thu, 16 Mar 2023 19:33:34 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:34 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Cc: Jonathan McDowell Subject: [net-next PATCH v4 11/14] arm: qcom: dt: Drop unevaluated properties in switch nodes for rb3011 Date: Fri, 17 Mar 2023 03:31:22 +0100 Message-Id: <20230317023125.486-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org IPQ8064 MikroTik RB3011UiAS-RM DT have currently unevaluted properties in the 2 switch nodes. The bindings #address-cells and #size-cells are redundant and cause warning for 'Unevaluated properties are not allowed'. Drop these bindings to mute these warning as they should not be there from the start. Cc: Jonathan McDowell Signed-off-by: Christian Marangi --- arch/arm/boot/dts/qcom-ipq8064-rb3011.dts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts b/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts index f908889c4f95..47a5d1849c72 100644 --- a/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts +++ b/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts @@ -38,8 +38,6 @@ mdio0: mdio-0 { switch0: switch@10 { compatible = "qca,qca8337"; - #address-cells = <1>; - #size-cells = <0>; dsa,member = <0 0>; @@ -105,8 +103,6 @@ mdio1: mdio-1 { switch1: switch@14 { compatible = "qca,qca8337"; - #address-cells = <1>; - #size-cells = <0>; dsa,member = <1 0>; From patchwork Fri Mar 17 02:31:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178425 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 90B63C7618E for ; Fri, 17 Mar 2023 02:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbjCQCeM (ORCPT ); Thu, 16 Mar 2023 22:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbjCQCd6 (ORCPT ); Thu, 16 Mar 2023 22:33:58 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6886E76049; Thu, 16 Mar 2023 19:33:37 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id p16so2459524wmq.5; Thu, 16 Mar 2023 19:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4yEvSncVqO5CEElyQ6q0WPYP3z8pHrofnI3Ooo06uR0=; b=nITNr7nLrqTYxWL4bn+CtPurpHoc8uOjmWFHoXcjWDzjRK4fS9Y4P23E3xF4gXbUfP KpVaQwvuhjx4mzn1d09NeYAzyrdEVO4uGFdpAYiV9YuaQwxNfvOiVk9KNbm795kd9r/B HiyZwJNLM+MITtsYOGYUrZtBLfCl9JdMss5hA2s6OmQO097WVFXXZRb8licVShLhKLyZ krqCgtkmLS8VQLjo+ZUI38OvmHdDtPXV5uTbB35gt1DPcaj8/u1Mg2Fd/+OX9pyTBmb5 ibT6P1xkuWKausYDgQ2gVxq3I+1D1US56ryQl1oGERS3yRzp73aCkad6tkeFz6qW5ZyC +lDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4yEvSncVqO5CEElyQ6q0WPYP3z8pHrofnI3Ooo06uR0=; b=YxoeMlN6E58cvW1s7SKKOytrSORK1OUz89L8N1zySMuPE4EyGpOFu98IhpXPtTnDyV iMJA3QiGeUs85XW1QaNiJGegwAjbZexcENHL8EGN+Lrq/3iO9FSEuB39YbPmrPP0xBMv PAjWZ6xGNcC+Y4eXg4e9oJ7pC4+T4aypZpfVbI8uZQcP2fiSa5oZX9b3JRZGPwbF09rb 14YuMN6+fTIauk9nEFjLcOK/VMGc6IxfKG7Zp11iYbMfp1zYBd/tYjsPhrluAEx/+GOS EVZcDnn/VKYzIijJAoW6SMX2lVT3nSqZ66kbRqsMzNg78wdkhJVJF6drhZVHnMwV96zn FIew== X-Gm-Message-State: AO0yUKVITQnGqmyalG5y7upsjMHOgoKI3sYu/X6XjtrXB0A9g/qBgVG8 vFqvbDtwL5kVzTxKKC3jYys= X-Google-Smtp-Source: AK7set+TV3X+/9ZMMNIHAk9vRTQoNHzhcsG6yri6suzQjhKXYo+mQdrkSu1NqHBDoHdDgogb1rCE/Q== X-Received: by 2002:a05:600c:34c1:b0:3eb:383c:1876 with SMTP id d1-20020a05600c34c100b003eb383c1876mr23460133wmq.6.1679020415624; Thu, 16 Mar 2023 19:33:35 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:35 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Cc: Jonathan McDowell Subject: [net-next PATCH v4 12/14] arm: qcom: dt: Add Switch LED for each port for rb3011 Date: Fri, 17 Mar 2023 03:31:23 +0100 Message-Id: <20230317023125.486-13-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add Switch LED for each port for MikroTik RB3011UiAS-RM. MikroTik RB3011UiAS-RM is a 10 port device with 2 qca8337 switch chips connected. It was discovered that in the hardware design all 3 Switch LED trace of the related port is connected to the same LED. This was discovered by setting to 'always on' the related led in the switch regs and noticing that all 3 LED for the specific port (for example for port 1) cause the connected LED for port 1 to turn on. As an extra test we tried enabling 2 different LED for the port resulting in the LED turned off only if every led in the reg was off. Aside from this funny and strange hardware implementation, the device itself have one green LED for each port, resulting in 10 green LED one for each of the 10 supported port. Cc: Jonathan McDowell Signed-off-by: Christian Marangi --- arch/arm/boot/dts/qcom-ipq8064-rb3011.dts | 120 ++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts b/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts index 47a5d1849c72..472b5a2912a1 100644 --- a/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts +++ b/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts @@ -65,26 +65,86 @@ fixed-link { port@1 { reg = <1>; label = "sw1"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + }; + }; }; port@2 { reg = <2>; label = "sw2"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <2>; + }; + }; }; port@3 { reg = <3>; label = "sw3"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <3>; + }; + }; }; port@4 { reg = <4>; label = "sw4"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <4>; + }; + }; }; port@5 { reg = <5>; label = "sw5"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <5>; + }; + }; }; }; }; @@ -130,26 +190,86 @@ fixed-link { port@1 { reg = <1>; label = "sw6"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <6>; + }; + }; }; port@2 { reg = <2>; label = "sw7"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <7>; + }; + }; }; port@3 { reg = <3>; label = "sw8"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <8>; + }; + }; }; port@4 { reg = <4>; label = "sw9"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <9>; + }; + }; }; port@5 { reg = <5>; label = "sw10"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <10>; + }; + }; }; }; }; From patchwork Fri Mar 17 02:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178426 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 3DF2AC7618B for ; Fri, 17 Mar 2023 02:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbjCQCeT (ORCPT ); Thu, 16 Mar 2023 22:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjCQCeB (ORCPT ); Thu, 16 Mar 2023 22:34:01 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF7B61732; Thu, 16 Mar 2023 19:33:37 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id o7so3191348wrg.5; Thu, 16 Mar 2023 19:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020417; 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=NdFLu8rYGgfYob/UUJ7xHBPYmBqXvfPClb24ZxTT2Ls=; b=DutLKUovGo5Smee1OxymH+55w+jweIRW6b8/LTpEqvWGEybiYS1/mq7Uhli8Ckl++x h3SNVQw0nglbYfDxSz1basFNpUIZKemuqyxkuGJQiK3vkVxCsbyt7VZcyFDeKiCUJ1Df k8H/tCpTwfqPf8ib877IwGVmDQbMx7hiQjimW5bMfaJF1Buna93ft10bQPtK59YzDmcs ONaiS7H/9xJGD3jKeWYfYJAHXKhb8foSZkTvfkZcOnwJ01LY+g+VAFqCbLtSZW0gfLRs +T5raXr2+YgW3O3I/i5zNXrpEU+AFmTmm3wj4VrngFKCG37BTJxlmq+cnkGPOfzuwogJ a5eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020417; 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=NdFLu8rYGgfYob/UUJ7xHBPYmBqXvfPClb24ZxTT2Ls=; b=H7zWvxrEL+qLBPe7c8PkxndGHJWnoFNTOVEho/lIelsXEntJdLBrb8Mz+Z2IoF+Y1R ZIDdLdxhn80C4y6TctCOI6LyjYEVdb2RYFkK07U34D7H8zMwnpRxmcEQ2jgUyyGhld1p +w0niPsH0MdLDW36IVW6LTGZQ7K6dNHlyC2wK87PiYM4WIqYNcejfeJ/U8e8+Yqj6ZV/ z+slK7qU6zNyw8uWrQ622q868m29NHSm+wwDlx1qVKZSoAkeSuGOoNqj3aZuwZf5eJ78 hWGXCP+Grsyoyq8I2UkHBv8XEphznYJpP0tX6KBABACPJudty6DSOYqQYdf/LeJHZeCN h70Q== X-Gm-Message-State: AO0yUKW7h5Tka4Yklw/x8JX2uwvKgs/r3v3IfuFO4DsHmtym+bqsJk0j J3LWemZFGzpputqyS5pUGPM= X-Google-Smtp-Source: AK7set9V/3xd8DaULwMWrn7GwNk0kslsUji6r7WhiD/CIbzOoiS/nUbqUuVhyYnTubPVK3JR1op2rg== X-Received: by 2002:adf:d845:0:b0:2cf:e132:bfbb with SMTP id k5-20020adfd845000000b002cfe132bfbbmr5896016wrl.38.1679020417006; Thu, 16 Mar 2023 19:33:37 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:36 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 13/14] dt-bindings: net: phy: Document support for LEDs node Date: Fri, 17 Mar 2023 03:31:24 +0100 Message-Id: <20230317023125.486-14-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Document support for LEDs node in phy and add an example for it. PHY LED will have to match led pattern and should be treated as a generic led. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- .../devicetree/bindings/net/ethernet-phy.yaml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml index 1327b81f15a2..84e15cee27c7 100644 --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml @@ -197,6 +197,22 @@ properties: PHY's that have configurable TX internal delays. If this property is present then the PHY applies the TX delay. + leds: + type: object + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + + additionalProperties: false + required: - reg @@ -204,6 +220,8 @@ additionalProperties: true examples: - | + #include + ethernet { #address-cells = <1>; #size-cells = <0>; @@ -219,5 +237,18 @@ examples: reset-gpios = <&gpio1 4 1>; reset-assert-us = <1000>; reset-deassert-us = <2000>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; }; }; From patchwork Fri Mar 17 02:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13178427 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 22632C6FD1F for ; Fri, 17 Mar 2023 02:34:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbjCQCeZ (ORCPT ); Thu, 16 Mar 2023 22:34:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbjCQCeL (ORCPT ); Thu, 16 Mar 2023 22:34:11 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8EF48A4E; Thu, 16 Mar 2023 19:33:42 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id w11so1410295wmo.2; Thu, 16 Mar 2023 19:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020418; 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=oy4rJp/0zV8uQx96aqdFOna+cm21IPd+B8/oErRDE1c=; b=DiYT5S/jOvNwe4CzhjdiIkvIKBggeGR7CexVNd4rd/sjT5lAPS1XWF1W+7fLOFMLc9 +M+nVvH/VqGoT3HRVUevSaiDK++YKjOvPsz8umYJfLqED/NO2vBkV/scUd1luER6cra4 MU9TLGEoBzC2egkV45V3/dkoR/6reCXuIEI/4Onu6ISM86v2ODghCyVpzQR3QShPKWAL 9jZ7MIgNa9bnV7GstyBvBvcr169haI0sCUfFl73RZ7foJuE+TayH+Tf6hYDaMGLkB/kS fhVvp3xBGubVX6uhvop1IHbnljGIKuh1xuXwPSH1/oNVSjdbVXXZJzhlDpDrUqMIbqpC kXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020418; 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=oy4rJp/0zV8uQx96aqdFOna+cm21IPd+B8/oErRDE1c=; b=rPGCMwC5lEyATn2XIj9TYWwccH0ijOOKbKu505DFQ/yntSXE6LIM+EsgjTXDIXWnox 9cLKLknfWu6BSGE2ITyTfOhv9M70nO/2ZvtwMRzfH9vIMtt3xV+KEZYpVQRw7MusGQMM ssK3BE95Wo+oBu6l6dEdmH4FBvVpGcLlC9scX4+3XFLpHY9qRL2QjNqdXI2rG6ZSRox2 Y0iW5oBHh17kNGyYokI3ow/r8/awDBnZEXsXuvVGT8/VlxGPqNO2PwngLQkxwgpoAnvK kZ/h+gPd4Kotz6NPaetljhabqCjm8XnFJ5HFWGkGVy6KVlkGr88N5SJxgiI7kPzRp2Rv 3btQ== X-Gm-Message-State: AO0yUKXldj1G0urmL+gT+amy9DmOIpf1b1/2Er6nlJS/QRdIop5mG1Vd 81TqJpwJiEqY863/WopY24o= X-Google-Smtp-Source: AK7set/vLpvKe0YMV6V4xFFxWeIDZxral5oel3M8ZEVRVHfcThgwCE2w0hq0lN0ZZ/FAMivfH7aOVw== X-Received: by 2002:a1c:7215:0:b0:3ed:5d41:f9a7 with SMTP id n21-20020a1c7215000000b003ed5d41f9a7mr3675091wmc.2.1679020418287; Thu, 16 Mar 2023 19:33:38 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:38 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v4 14/14] arm: mvebu: dt: Add PHY LED support for 370-rd WAN port Date: Fri, 17 Mar 2023 03:31:25 +0100 Message-Id: <20230317023125.486-15-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Andrew Lunn The WAN port of the 370-RD has a Marvell PHY, with one LED on the front panel. List this LED in the device tree. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- arch/arm/boot/dts/armada-370-rd.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/armada-370-rd.dts b/arch/arm/boot/dts/armada-370-rd.dts index be005c9f42ef..15b36aa34ef4 100644 --- a/arch/arm/boot/dts/armada-370-rd.dts +++ b/arch/arm/boot/dts/armada-370-rd.dts @@ -20,6 +20,7 @@ /dts-v1/; #include #include +#include #include #include "armada-370.dtsi" @@ -135,6 +136,19 @@ &mdio { pinctrl-names = "default"; phy0: ethernet-phy@0 { reg = <0>; + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + label = "WAN"; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + linux,default-trigger = "netdev"; + }; + }; }; switch: switch@10 {