From patchwork Thu Mar 9 22:35:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 661337 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 A8A2BC74A5B for ; Thu, 9 Mar 2023 22:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjCIWiC (ORCPT ); Thu, 9 Mar 2023 17:38:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbjCIWiB (ORCPT ); Thu, 9 Mar 2023 17:38:01 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCFA27A84; Thu, 9 Mar 2023 14:37:59 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so4765614wms.2; Thu, 09 Mar 2023 14:37:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401478; 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=76LV00udkXPQUwmYWl6PMAZgt1+JmaJY28CfXEIfxZA=; b=kGmrRGymM4KXv3p2daK6qNA4CyjMECD39z2HhDe0pT7ZEek364CCVqdK+HgebbR3dV ISnvWARvuOTIyQNnslRwauZjxVg10QJFNfnZhnLLkbJ6b9BHrTG+lKRxlHN2SIws9ZZf H9fvOwlf43/Vtja+WL+PfrX9PThWjAu3H4BXXtjTLtBM1m8N4XvDYFKrDhXf3Jj2N+3j VppzFhHXUx39g9BXVmliwyz4EujqWhRDv1k9LwgasM4ZFzq3ScpBu513mI9xiW411MVY KFSXf7MxNJwwKtuZtZjd1cAeJGJA85tEpLspSJ490jXw9n6cHCwpaMywLIPAu7jdZ0Ij t9+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401478; 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=76LV00udkXPQUwmYWl6PMAZgt1+JmaJY28CfXEIfxZA=; b=L6C/v3aQPyzALM/Iu+4OKavvU+8pxwmRKDXNnTzV7VY6vL6VwIuJXUrCjerpZCRfyp gFXH/+H0sZwbNz8hA8dCCwSKOFTvsKCvynutg3yCEja7IDI8RC62d46OdVX0cPce4+sr eOI7lADWwiSly0QX3poWO8cSBUZHA+FPrceqJ9kvp4NqkOniELPf1OQegJWHZsc+0gDk q0T3giJ/dyWGWx+RGupK1ijfuVjOoO25B3IHbCRRXyDrZ6uenzu+nKT/P8qr9BjaGvVc AcGkt649SFAc8exZAnC+uo64+1pS8moJvsnsLBD3ZjhwXofkuRtQywXVjv9cjAwChiKH er3w== X-Gm-Message-State: AO0yUKWU+z9UkuS7Xm/7GIxAvvH4XRMZeIPMJONscfE9RbxzAUFu0x02 L3dRn8Mj6mxxvK8vKhM8xcMWB9KkEkA= X-Google-Smtp-Source: AK7set8JVwiOkfqLtU4wZgr4GnlFSjgxwHxCtSXt+MOW7NV3SQg1oWLTsIOhL2hlU1AkKo44Z9o14g== X-Received: by 2002:a05:600c:3ca7:b0:3da:2ba4:b97 with SMTP id bg39-20020a05600c3ca700b003da2ba40b97mr120602wmb.19.1678401478052; Thu, 09 Mar 2023 14:37:58 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:37:57 -0800 (PST) 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 v2 01/14] net: dsa: qca8k: move qca8k_port_to_phy() to header Date: Thu, 9 Mar 2023 23:35:11 +0100 Message-Id: <20230309223524.23364-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 Thu Mar 9 22:35: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: 661336 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 36773C64EC4 for ; Thu, 9 Mar 2023 22:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbjCIWiK (ORCPT ); Thu, 9 Mar 2023 17:38:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbjCIWiE (ORCPT ); Thu, 9 Mar 2023 17:38:04 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 575D8E04A; Thu, 9 Mar 2023 14:38:01 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id az36so2260695wmb.1; Thu, 09 Mar 2023 14:38:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401480; 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=R5QIXccLdikooU31j6nPRcsueMUDtDT9gBbA9i0LLOw=; b=hyiqtzUHkKxK5qITEC2ExCwbO7etmiwEJRdZv/bDnD4lDt7DcGMPy1+riGhcyYQoKW s9D1GTuANvS5wP6cW0cemOmA03pN2DCFwQAAQdMcdIstSLfsbmmo6hVWMyJhuoljsIdY rElcbjIFyhBTi+4vWOtmJq5bvl9FZEX2BFEVDSGmkVe/afQMu3jcdNsEFxLBYA5Cq06H vbDH6EAIou+zyfSX8k8uVeFnlToEYs2FrIvBkhwxOMGTmhSwqQUDyEdEgfq7Qw9k36qC l/Kbqa44Y250pBck8UTPr3cr6yXgeZZyWVGU/JCwTPPTTxHDctDkoJfeneHJaZPbfEjQ Z/Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401480; 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=R5QIXccLdikooU31j6nPRcsueMUDtDT9gBbA9i0LLOw=; b=isoc2QQ+t4jKZDPCh0Nq/GRQIg3w2GhOEzHy0QhweqohHpxvQeL6UW2razToIHhp3B KiUEtOtsTVdZmftTWbhgdPvnrW6yv0uu35NmVTeVlWteAzP5N1eukZb75Wt8MbmVQi8B /vFeAv1y6S4tEQiZhVeYxzPHOfDdRjfIF+moexV8xgcANuepUeuB1ZL//9abuI7aOHH1 clOaK/34YLkTUpCCJnHy8f0Xj22qYl3qLE6f9FlMR6AXyQlZ4jwhnXf9hpui2EJ36SiR iN9sbyLUedoI4ZSHCcvYfX/mt+L9yWMSmtbi9XHiuRBBl7IHcmbjBcaeG3Q54bIW+HJv DiFg== X-Gm-Message-State: AO0yUKUu3XW78alXwbRU4G86lC01BoBG6TKr1GJsm6IGFsaw7XJOeLLY KbLOzKcmwbY53KKQaYT0Tvs= X-Google-Smtp-Source: AK7set9pXgrXzyocUt3lH/KcvxRN+a0Mj4VnKztqTI4wOEIddln0TDHObVZSm8TiWhoASFZjvbVJBA== X-Received: by 2002:a05:600c:4746:b0:3dc:58a2:3900 with SMTP id w6-20020a05600c474600b003dc58a23900mr682560wmo.29.1678401479592; Thu, 09 Mar 2023 14:37:59 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:37:59 -0800 (PST) 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 v2 02/14] net: dsa: qca8k: add LEDs basic support Date: Thu, 9 Mar 2023 23:35:12 +0100 Message-Id: <20230309223524.23364-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add LEDs basic support for qca8k Switch Family by adding basic brightness_set() and brightness_get() 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 | 7 ++ drivers/net/dsa/qca/Makefile | 1 + drivers/net/dsa/qca/qca8k-8xxx.c | 4 + drivers/net/dsa/qca/qca8k-leds.c | 198 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 69 +++++++++++ 5 files changed, 279 insertions(+) create mode 100644 drivers/net/dsa/qca/qca8k-leds.c diff --git a/drivers/net/dsa/qca/Kconfig b/drivers/net/dsa/qca/Kconfig index ba339747362c..dab648f88391 100644 --- a/drivers/net/dsa/qca/Kconfig +++ b/drivers/net/dsa/qca/Kconfig @@ -15,3 +15,10 @@ config NET_DSA_QCA8K help This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. + +config NET_DSA_QCA8K_LEDS_SUPPORT + tristate "Qualcomm Atheros QCA8K Ethernet switch family LEDs support" + depends on NET_DSA_QCA8K + 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..330ae389e489 100644 --- a/drivers/net/dsa/qca/Makefile +++ b/drivers/net/dsa/qca/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_NET_DSA_AR9331) += ar9331.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o qca8k-y += qca8k-common.o qca8k-8xxx.o +obj-$(CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT) += qca8k-leds.o diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 8dfc5db84700..fe68ac7e4030 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -1727,6 +1727,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..7ae2ea082aae --- /dev/null +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +#include "qca8k.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; + } + + return val > 0 ? 1 : 0; +} + +static enum led_brightness +qca8k_cled_brightness_get(struct led_classdev *ldev) +{ + struct qca8k_led *led = container_of(ldev, struct qca8k_led, cdev); + + return qca8k_led_brightness_get(led); +} + +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 = { }; + struct qca8k_led *port_led; + int led_num, port_index; + const char *state; + 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; + + ret = fwnode_property_read_string(led, "default-state", &state); + if (!ret) { + if (!strcmp(state, "on")) { + port_led->cdev.brightness = 1; + qca8k_led_brightness_set(port_led, 1); + } else if (!strcmp(state, "off")) { + port_led->cdev.brightness = 0; + qca8k_led_brightness_set(port_led, 0); + } else if (!strcmp(state, "keep")) { + port_led->cdev.brightness = + qca8k_led_brightness_get(port_led); + } + } + + port_led->cdev.max_brightness = 1; + port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + port_led->cdev.brightness_get = qca8k_cled_brightness_get; + 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..25fab385f0f7 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 { @@ -526,4 +585,14 @@ int qca8k_port_lag_join(struct dsa_switch *ds, int port, struct dsa_lag lag, int qca8k_port_lag_leave(struct dsa_switch *ds, int port, struct dsa_lag lag); +/* 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_H */ From patchwork Thu Mar 9 22:35: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: 661966 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 CE8D0C6FD1F for ; Thu, 9 Mar 2023 22:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231410AbjCIWiK (ORCPT ); Thu, 9 Mar 2023 17:38:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbjCIWiE (ORCPT ); Thu, 9 Mar 2023 17:38:04 -0500 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 C12A81913D; Thu, 9 Mar 2023 14:38:02 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso4792713wmb.0; Thu, 09 Mar 2023 14:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401481; 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=jAjYaCokdDFeoHBYZ8ajEHyinrj2ay5j+y5y2pyEMkc=; b=DirXdVf5HBsEqP0FuGmWmFyGILlI68FKvJs+WbmYdTMj7rBphcg5E+Js76FQF1gUvb 3md+bEy9mi1Y90r1AWW7kvFU1Sixd0spfyHx8GPIG4OyAZzIs1j2n7rQc8qB8g//bO7w wzcebbNtq0XnDQgIA/mE4x8YUyBa2odPk2sv4tFY5VwdpFTI9XeUN8cWtVuhgog28LvS LCiuBLPF984KdIKG+IrrXPkJxHWAShwTN/Zz0vuIFIYWw55WrbIKWGu0Mu3sxJlm4nLC dhfrUHJGta0K0B+Yrw+r2BRAxL/eeBMycB2kyFT8RapdCLkTY6KsFbFxO7Ytjd+HMr/z PxWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401481; 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=jAjYaCokdDFeoHBYZ8ajEHyinrj2ay5j+y5y2pyEMkc=; b=iWGta3DBc5fIpBcmPeNQ2dsu938DKN12L07bflPaImz69FtnVlnLqDC1uPNyV/D2Hl ykJT0EfNu/mb10LFp5EQkMM6fujTpzNOOWYd/MMfsHQlW2egF+GkrEZyDfDc7NBo950o DxoMTuP4Xm86GapGxfQLAmEw7nUoXLSjj4hxkareF5Z1G7k2Ut06rpEiJDbJBV07gSGu rEVKxfHoXYElRN0M6WvcDcafT4Oe3fCb2c+TfmfbOvE/ySBeWPk03ZroYtuDgqNakYet y5e+oksuPL4sTz/EdYtoAP4HmVqz3sv9dRxefeJiMq5OfOnJ4kaa4W3SD+S9o7w9tMiQ 3dYg== X-Gm-Message-State: AO0yUKW2iwOr7g+UkupD/2UdzKCUoFpD7dVqYz5VHmJzu0Yht2iuMvne 0Pj5e0gMPW6Tnptejaf2kqc= X-Google-Smtp-Source: AK7set8B6B4IHkmMi9Kt2of4xqwy/XP6aBgiq1LT9tStWRvZb5Tsu0Dn84Waf2UQyEWVDGHPKTq5YA== X-Received: by 2002:a05:600c:1553:b0:3d9:f769:2115 with SMTP id f19-20020a05600c155300b003d9f7692115mr752038wmg.26.1678401481047; Thu, 09 Mar 2023 14:38:01 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:00 -0800 (PST) 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 v2 03/14] net: dsa: qca8k: add LEDs blink_set() support Date: Thu, 9 Mar 2023 23:35:13 +0100 Message-Id: <20230309223524.23364-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 7ae2ea082aae..df7106d498db 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -98,6 +98,43 @@ qca8k_cled_brightness_get(struct led_classdev *ldev) return qca8k_led_brightness_get(led); } +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) { @@ -155,6 +192,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.brightness_get = qca8k_cled_brightness_get; + port_led->cdev.blink_set = qca8k_cled_blink_set; init_data.default_label = ":port"; init_data.devicename = "qca8k"; init_data.fwnode = led; From patchwork Thu Mar 9 22:35: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: 661965 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 33A99C64EC4 for ; Thu, 9 Mar 2023 22:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231449AbjCIWiZ (ORCPT ); Thu, 9 Mar 2023 17:38:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbjCIWiG (ORCPT ); Thu, 9 Mar 2023 17:38:06 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3E51EBCF; Thu, 9 Mar 2023 14:38:04 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id k37so2272155wms.0; Thu, 09 Mar 2023 14:38:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401482; 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=qIIOBe7NJABZRFq7ORmufJwFdwVU7XOjO161+6pddBo=; b=Masif1S0fO/HzOLeFOFiB9wUaUzXk71R88G2gPdZjJOK5uH7CWdu2lBiNDXnyYp6zF n7t04tdzPXMANF8t5p84W2pDfBQ2cp72X675hEbOWpVJgmhDeGEIBnvNXowmvt67F6h0 hybKlXa6QDci/obN006XsN6Hzzu2yMQ4NP1kRZusuXpu8YXRSNHM3O6BEO3dc7KAxVdw McBM9zkQtrGpPI1MeiZWhQ00w3M+uggIZRENPh/RHFIwYiow9lY69eakYR2DYR3YPWi6 mFBZS98oPPz2Gj9JnHv2k4IOcQN8Z8aUQ3ibxasgWPDItTWmTDLvyUUOZxmFhxAoWeue Ri+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401482; 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=qIIOBe7NJABZRFq7ORmufJwFdwVU7XOjO161+6pddBo=; b=3NNfRL00EYiIUaziTZJuABEKle0j+887UmK8iUNqk7s0Yw2lYHSaVeNmzxI6+wetj2 f+EmbjmfwhSI7fouO6NYJdCwI0OMFlOMAKHkK3suytqAKwCeNscunl6Tl1w42KItrN3L jt6rpDSJIiPSb/RL1C7Ar3TPR/rT3BRRQyAOSK8DU5Lx24jrCeMdRxzGWaHNYL2xILbw excj5gt52X/QOS1/TFo0Js+M4Vwhy9uwPaazOp7crznXtBCgJeulXTdgzr7hhYRDh1DP phZP20eDi3CoajtyVV2YSSmdnE4Mit56bQXvyzs6PIJff1Y19n2ZsCA1K4CxvgWq4yBt ofKA== X-Gm-Message-State: AO0yUKXwlammP1besmYQVrJ03qHEX6GXPUCEmYhhkby3Y7pcrZGhc4Vj 6KqQzLcyMUTl4NSgknpCi8E5+tetbAE= X-Google-Smtp-Source: AK7set+N4R2+01z1KbaHdN1M9tD7U5yAg6dKml60CuDgMfBht104JcXqKrgXqU3A8xPp93h4w6z0kA== X-Received: by 2002:a05:600c:1d84:b0:3eb:2de8:b72a with SMTP id p4-20020a05600c1d8400b003eb2de8b72amr769570wms.7.1678401482398; Thu, 09 Mar 2023 14:38:02 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:02 -0800 (PST) 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 v2 04/14] net: phy: Add a binding for PHY LEDs Date: Thu, 9 Mar 2023 23:35:14 +0100 Message-Id: <20230309223524.23364-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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/phy_device.c | 89 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 16 +++++++ 2 files changed, 105 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9ba8f973f26f..8acade42615c 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->led_list); mutex_init(&dev->lock); INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); @@ -2964,6 +2967,85 @@ 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; + + phyled->phydev = phydev; + cdev = &phyled->led_cdev; + INIT_LIST_HEAD(&phyled->led_list); + + 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->led_list, &phydev->led_list); + + 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) + return err; + } + + return 0; +} + +static void phy_leds_remove(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + struct led_classdev *cdev; + struct phy_led *phyled; + + list_for_each_entry(phyled, &phydev->led_list, led_list) { + cdev = &phyled->led_cdev; + devm_led_classdev_unregister(dev, cdev); + } +} + /** * fwnode_mdio_find_device - Given a fwnode, find the mdio_device * @fwnode: pointer to the mdio_device's fwnode @@ -3142,6 +3224,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. + */ + of_phy_leds(phydev); + out: /* Assert the reset signal */ if (err) @@ -3156,6 +3243,8 @@ static int phy_remove(struct device *dev) { struct phy_device *phydev = to_phy_device(dev); + phy_leds_remove(phydev); + cancel_delayed_work_sync(&phydev->state_queue); mutex_lock(&phydev->lock); diff --git a/include/linux/phy.h b/include/linux/phy.h index fbeba4fee8d4..1b1efe120f0f 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 + * @led_list: 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 led_list; /* * Interrupt number for this PHY @@ -825,6 +828,19 @@ struct phy_plca_status { bool pst; }; +/* phy_led: An LED driven by the PHY + * + * phydev: Pointer to the PHY this LED belongs to + * led_cdev: Standard LED class structure + * index: Number of the LED + */ +struct phy_led { + struct list_head led_list; + struct phy_device *phydev; + struct led_classdev led_cdev; + u32 index; +}; + /** * struct phy_driver - Driver structure for a particular PHY type * From patchwork Thu Mar 9 22:35: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: 661335 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 A8267C74A5B for ; Thu, 9 Mar 2023 22:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbjCIWi1 (ORCPT ); Thu, 9 Mar 2023 17:38:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231355AbjCIWiJ (ORCPT ); Thu, 9 Mar 2023 17:38:09 -0500 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 BCFB821A28; Thu, 9 Mar 2023 14:38:05 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso4760621wmi.4; Thu, 09 Mar 2023 14:38:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401484; 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=tDRoLkLZ4ceS0IqWkmGrgNhXPijtgv6U26EGp7OciKo=; b=kJWeoVWro/WHEmM9GBnZFxWYJc70QnoBY+rdDq2a8KBy6TjLM8yjHHkgdk5dMJqHJ1 lD/CpHUPZddFSS+GgBAGOVZTTfhgOv80gAtBr9XHwH0UZ8zgHRFfH+BR3zZnxjT65wId oK2jgzZknCXw0sjnSs30GeLudFDz754/kfq1fCO/vO3F52JlUiR92aZd94IPImPiO4Zu WgtZMqu/k/ME5NVMUBeXB5+rRW6WmaOmC9xjYTaN5S/ApsnDNsUlt+OJccsIf41yywrf B927tJsAcnFWZrTYPwvQpEsvnxxJk7ihKeFObQ5H1CTptC3meSWJUb1yWOjRsn80d9Cl OzPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401484; 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=tDRoLkLZ4ceS0IqWkmGrgNhXPijtgv6U26EGp7OciKo=; b=hxfO5jkirNgLBW3llTZWXy1WiRX0q5HFuNs1QgmTo6pB8e/jsGuD8CHF0NrsXxRBaY WvoPhjSoL+9+vRsx/ufQRRD9hkAkOr8/gTR7dery7RUzPliEXAIAHjkWBZAjukJNABur QtYVlfar8kSr+d9h/nRH7sfjcdTCw2Ti1CVxZ7NXMPACanEKgqT3sn+TeR6mxchj+3+o FdyUg1iDhV3IvPyhsGVAYmueIZajL/qG7ByzV0LCRojTAa6GvTXtOjXyFa+Dx3vwDbaI +qrfr9x3V2efz8lA67RbILbBsCZTu9sQmcO/c/uXSthjY0kSm/ZbF8soc0gmVAsfD8de SwkQ== X-Gm-Message-State: AO0yUKXhkGimwLfZmkwoiZDaMlNBu93/s+6xLgT9dKuiXUYjOiObpfNp bUCDnu3XDhSXzBHsYRtKBVnFkI8GtbA= X-Google-Smtp-Source: AK7set+apqoa0KPiDsZ/+wQr+J2aA/U4dxCr+v2C+6auaXVj3NgBz8cH2c+K2x2II47e9c+SN6G8CA== X-Received: by 2002:a05:600c:3d88:b0:3eb:33fb:9dcf with SMTP id bi8-20020a05600c3d8800b003eb33fb9dcfmr732506wmb.5.1678401483775; Thu, 09 Mar 2023 14:38:03 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:03 -0800 (PST) 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 v2 05/14] net: phy: phy_device: Call into the PHY driver to set LED brightness. Date: Thu, 9 Mar 2023 23:35:15 +0100 Message-Id: <20230309223524.23364-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 | 14 +++++++++++--- include/linux/phy.h | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8acade42615c..e4df4fcb6b05 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, @@ -2995,7 +3002,8 @@ static int of_phy_led(struct phy_device *phydev, 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 1b1efe120f0f..83d3ed7485e0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -841,6 +841,8 @@ struct phy_led { 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 +1065,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 Thu Mar 9 22:35: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: 661964 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 3E52FC76186 for ; Thu, 9 Mar 2023 22:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231485AbjCIWi2 (ORCPT ); Thu, 9 Mar 2023 17:38:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbjCIWiK (ORCPT ); Thu, 9 Mar 2023 17:38:10 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A66427495; Thu, 9 Mar 2023 14:38:07 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so2289937wmq.1; Thu, 09 Mar 2023 14:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401485; 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=bhHnF/S3YeXHYbPEZLJBWZo9IBQDiim5+f+K7WIjxP8=; b=Msbj9ENRk06fMPzEMv/Wyoa2FJc/S+oOh/LmsG4hUtjKlf3tgzGDGpNHL9v/H1oVke oVTXl1/sQNv1+SFz47L2EYMQJE4xMg/KVcQir4WZ0gselZs4+ktgDidvhi26KDOzUZBV ihgd6Gtn94F+ZkRo56y8cYXkO8JqkJ6GCJyYCchVkYorFCVmh5Xnv/DhgVNz7FIsWdcx vtjyOcaWyD0C5wD1s+TorbFKzIIB5HCxkl5BP+Hlic/yvtb6N8pY/rFYHW9AI2wzOiC0 Z4seoOMt1hW521xuqEtcTx4l37NArk7vNV6tQe+hCUa29dlZLh8PywA0392zn7BGtclV poKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401485; 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=bhHnF/S3YeXHYbPEZLJBWZo9IBQDiim5+f+K7WIjxP8=; b=K0RAau43CxxQwCzmjz4efsmlQYNhsgi52PxMuOtg2GXHTtOThzoACpttf4HcVxHYPq G/9+RPsb9YP261Vl4wVS6g6MCfBGONNzehjJBKmrDZYM9zOvvSdpO2OBdoIt5IHNF5p8 vAlYIavQmgah4wM1HO8mazCzO6Ol67npy9bSY9fOnHaDEVwQTVzPrkfwmMyS5wERCW2J A5/9g4BQClHoqhuc1EvKUQb4An3IVciWP/Z1kqRgIYY90sIBNpEZehUCbweHQZBnwzs7 +y2w13K0DCIvxVGEMWBxZ4ZBrRpjf921GlqjiWLnTi2GgUtWw2qt4okH3w0JdXF2n3u+ OpHw== X-Gm-Message-State: AO0yUKVsBXFvkAWnm7P8X32Q7dviIcjmvemMz7LGdivgpFhPt29SDTPN 3zW3KRHmKRjklfs5OjUc/uo= X-Google-Smtp-Source: AK7set8XsL7qtevZUUbzCHXNxGEpFR6ME/zORtJrWOEIfQUUpgm88TC+GMn+HvGN2ywVUomqw1lubA== X-Received: by 2002:a05:600c:3585:b0:3eb:2b88:5af1 with SMTP id p5-20020a05600c358500b003eb2b885af1mr763836wmq.18.1678401485180; Thu, 09 Mar 2023 14:38:05 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:04 -0800 (PST) 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 v2 06/14] net: phy: marvell: Add software control of the LEDs Date: Thu, 9 Mar 2023 23:35:16 +0100 Message-Id: <20230309223524.23364-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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..e44a4a26346a 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) +{ + u16 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 Thu Mar 9 22:35: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: 661334 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 20189C64EC4 for ; Thu, 9 Mar 2023 22:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231501AbjCIWil (ORCPT ); Thu, 9 Mar 2023 17:38:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjCIWiY (ORCPT ); Thu, 9 Mar 2023 17:38:24 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76347E04A; Thu, 9 Mar 2023 14:38:08 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso4760681wmi.4; Thu, 09 Mar 2023 14:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401487; 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=cWl8tt6nddXYjDq6pzISEdAAK++EcnsjtXcgJ1R08pw=; b=JTu31Ve2uMOa0DO/Q88ivYP2vPQ4zDyJxtst3rMTz0vTYDCwb9tkhwc2CjoySBigGN 0vJy4MWyg/xSOXAdfCqXTDS0Uns/1cgJRiQleHi6NLW44vTRpCo7nAyk93QzwEznOCMX +5eYVjVRsYK6DoVRUPtvB15+8Ib9RETLrPmHbWIF+3O1xc69Fw7ZGLuT/U+kTehkOSHz mYojPGpg9Z8rmdjwgyGAmcvf8CLA2iYNTratgfT23fJGVMWTERPuHCNRol65R7C1H112 WLTotJZ15QqpY106x/SeZezoOqnvR8XcbhC+ye7UMfHhUKVwyNlJBtzNBU1pmqna8XZD W/xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401487; 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=cWl8tt6nddXYjDq6pzISEdAAK++EcnsjtXcgJ1R08pw=; b=rw+s+6AasXDDW3XTbs/OvSt733Z1WDhrPu8F7cZvjTSHI5bE83J7j9WDCjsv8eC+fT UIElrnApOFEJtwTSk3voiXBNe/zAmTFPlAl1dyg5FoKQH1E82daOS7rPJ8MoJfCBELMb if7X+xLQTbPemAG9aji1tiG5I4kC38/qylLkb6BgAZcc0morqYysW4oyyogz/Y20dG9E ljPzXzXh39pLbrv8n1n3X4hIQH7gJuCEWpBc25v/F1KqLiOqk8trjCjnUx1s1c4OulCY VIaJgfTVjFXdzf3dl/CAof2cYmVrbOX0dzYqaQgo+KjweSEHIyzIiVZG7u5y3ZEgD4Xb yI7w== X-Gm-Message-State: AO0yUKU0QUtVHB6tt7P3PwnG7TRZtVnut4xtKmd8b/vfk8os/Jwn58PH AMdA/x+j7JPox538daoQkt8= X-Google-Smtp-Source: AK7set/s6/9QBTqK5hPpMNLlD1UzOJgGbcqX5V3wcYLCfxKxUP8bPaYfzxUK3pfdSIyvkumKCx5ifA== X-Received: by 2002:a7b:c403:0:b0:3e2:669:757 with SMTP id k3-20020a7bc403000000b003e206690757mr144905wmi.10.1678401486594; Thu, 09 Mar 2023 14:38:06 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:06 -0800 (PST) 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 v2 07/14] net: phy: phy_device: Call into the PHY driver to set LED blinking. Date: Thu, 9 Mar 2023 23:35:17 +0100 Message-Id: <20230309223524.23364-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 e4df4fcb6b05..ae8ec721353d 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) { @@ -3004,6 +3020,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 83d3ed7485e0..b1ac3c8a97e6 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1072,6 +1072,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 Thu Mar 9 22:35: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: 661333 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 A01B5C6FD1F for ; Thu, 9 Mar 2023 22:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231585AbjCIWj0 (ORCPT ); Thu, 9 Mar 2023 17:39:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbjCIWii (ORCPT ); Thu, 9 Mar 2023 17:38:38 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBDA125E2F; Thu, 9 Mar 2023 14:38:09 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id p26so2248240wmc.4; Thu, 09 Mar 2023 14:38:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401488; 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=mcPDqv1MH0gdrEhrxsDvDnbiYWzw+6vrk0oNxbr+mS0=; b=UZZU3U5y9JkKuLbM1R9BY5P+i6lbdy/dbuK9ew8mtnHOjDhbcDjmjizbQsucNbtmOl af8PMhIyIYtDkggtZ6yFvCSGku+48/nryi2ftj2gM//t6x+CqsVrSfuo9CZWOra7+tj+ +7pNt/jsNzmlremUoIWJOflc48XvjRGdChiI7SPm3uC3t5t704+4zZSlp3oaX6tGWIIM NsosEEJF+PdQ3UwJFYNK+pZnmbJfNjBtilfZJWY/mhdinIGquMz/EzWiVs0u51VtZBAl 8EQIXKohawbcseSjNlMG6+SxUIq1B8E4/13wuZsBnyjIQ/wJQBtrPPV/sKE9t6O/zIuD yfiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401488; 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=mcPDqv1MH0gdrEhrxsDvDnbiYWzw+6vrk0oNxbr+mS0=; b=PORl4ZB/YYnh+ndUt8RM/qdkZIHanLB8Fe6RovLep71vcIWdU58ad4r6If5kLV+k8Z m13QVAA1ynqxV3wyYgxwK8364clqVq5+BUSQJIOm1fY8NT0rmNDK/8kPLxU/Q+L4yff1 OJfKBWDYMlAcqFT3JmyEkZFAhfgD49EfMjCQhjE0Q/f5g4OkxXyQi9Bn+UmCxLzxZ8SZ tGPVBlbWG3BhQsjAB1SUTk855C35Z6Txi4TZj9kOLHgCzLHwS7tllmjGqf4beS6QmbOR mSw/5OoVljV2cIMaEWlokyKeHKjBH/C8jhZR+Y06ySQSoO326bIII/jMSUWwZbvO6Ogh RuPA== X-Gm-Message-State: AO0yUKX2+TX/47fCuOSudNBlTwcn1/CmvpBLyoIAppyiz3DuX1+K9RDe eZrv6ijphFUQ0c7CbvU3ARkNgDzTw68= X-Google-Smtp-Source: AK7set9A7zKd48nHwv6s4DUd1u00FZyoLcpBm5Jom/HGD/NZ+m4GJtvaGv16KZ3XzMONRsSWqvtyGQ== X-Received: by 2002:a05:600c:4592:b0:3e2:201a:5bcc with SMTP id r18-20020a05600c459200b003e2201a5bccmr720942wmo.33.1678401488038; Thu, 09 Mar 2023 14:38:08 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:07 -0800 (PST) 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 v2 08/14] net: phy: marvell: Implement led_blink_set() Date: Thu, 9 Mar 2023 23:35:18 +0100 Message-Id: <20230309223524.23364-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 e44a4a26346a..3252b15266e2 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) +{ + u16 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 Thu Mar 9 22:35: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: 661962 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 53DE2C74A44 for ; Thu, 9 Mar 2023 22:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbjCIWjb (ORCPT ); Thu, 9 Mar 2023 17:39:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbjCIWi4 (ORCPT ); Thu, 9 Mar 2023 17:38:56 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D24C5D880; Thu, 9 Mar 2023 14:38:11 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id l7-20020a05600c1d0700b003eb5e6d906bso2248645wms.5; Thu, 09 Mar 2023 14:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401489; 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=WgoBUd5mOfOzbUIgE9ennXfu8Bk6ZG8n46SEtwJM8yA=; b=H+NsYENR+8EzbAxFKg+zIE/cBeVSmrDAAzXByhMLc8G2et1gp51FNU0M66oY4Rb+0c f7TB14Z6bW/0FhzqUOlPJnDoSBcGUOgIdolmunAjYFtmcQ1MlFfIqxIf3avdkA7IbRJZ Llzz+Se3pMWOF+i24TcNidZ4QBnJc25hrrBbrkfHKjRnh1aexUealsE/XtsmfGoBeX1q /bEoWAt0z1cHWdD5GUNojHoR2OG4P+byRrLt+FfPMKg9sV+xIgcPqmRQINdhT4Os3KeC XazOQ0Mvfaljp/ahmfO7IeN4mA15gpqKEcjqG7hb6vGm7bCOKeQib1FD3RIsbbeDLb7V ZTjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401489; 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=WgoBUd5mOfOzbUIgE9ennXfu8Bk6ZG8n46SEtwJM8yA=; b=wUYzShfb9FWa0kfH7Vr9tCB4vRwA8naHzA9QR9CISqn0NHilKKaKctGkbnkb2JC2yG f0z0MTXl/6ldyCEGkWOVHY84IYgrfV7szo2BIvZcc8Wfx6Fc0pZgjiBuDDyuFq81rc8a mLt0IFaOAVldEbN0CvhpU26yMQwO2BO2UK/vBzYGr7pnzoim7EWx5loW4QpuXLYpqx65 Sbeba5CyXGkyS965d7kcdjVDa806LmsPltWi9gBwAAiaXeGGJ42QX5MpeJj2kxz98gBH cod6vWaMwMAH3A9S1MbsypWJhCKVqXFYjsFRLXlw5nEpX7XPOXJKdxSDsxSgVy0rLEML +prQ== X-Gm-Message-State: AO0yUKX0xAdRvo+S6YQZIRnNse0i9dUnonl1Ol0JG7rQFxBj0XtmwFHQ 75qakF4SFOi0VWYU2JkLWbU= X-Google-Smtp-Source: AK7set/xkJYrlukP7VDZms/s2HBBUZPEGkDWRfMfDWH8VQaTTTwHp82KiOOoKZQUXJb+Z/YqGSPV4Q== X-Received: by 2002:a1c:e913:0:b0:3eb:3912:5ae9 with SMTP id q19-20020a1ce913000000b003eb39125ae9mr689396wmc.24.1678401489517; Thu, 09 Mar 2023 14:38:09 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:09 -0800 (PST) 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 v2 09/14] dt-bindings: net: dsa: dsa-port: Document support for LEDs node Date: Thu, 9 Mar 2023 23:35:19 +0100 Message-Id: <20230309223524.23364-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Document support for LEDs node in dsa port. Switch 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 dsa-port LEDs are controllable by the switch regs and the possible intergated PHY doesn't have control on them. Signed-off-by: Christian Marangi --- .../devicetree/bindings/net/dsa/dsa-port.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml index 480120469953..1bf4151e5155 100644 --- a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml +++ b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml @@ -59,6 +59,27 @@ properties: - rtl8_4t - seville + leds: + type: object + description: + Describes the LEDs associated by the Switch Port and controllable + in its MACs. These LEDs are not integrated in the PHY and PHY + doesn't have any control on them. Switch regs are used to control + these Switch Port LEDs. + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + + additionalProperties: false + # CPU and DSA ports must have phylink-compatible link descriptions if: oneOf: From patchwork Thu Mar 9 22:35: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: 661963 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 8C26AC64EC4 for ; Thu, 9 Mar 2023 22:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbjCIWjZ (ORCPT ); Thu, 9 Mar 2023 17:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231473AbjCIWi0 (ORCPT ); Thu, 9 Mar 2023 17:38:26 -0500 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 CCB535B40F; Thu, 9 Mar 2023 14:38:11 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso4792936wmb.0; Thu, 09 Mar 2023 14:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401491; 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=1wDcE5BTiRUWu5IpXdTXJGaa7mTD/67d24QZlEDxG4g=; b=nMUIAGY+Atog3NJeC0iVwCtwZ33VBxWlZDHiK1JCXPVAiMdBEifjkqmkHuLqpTWJze e/eyPzJmD4oJOhYkbmaXxO1B7VIY/4TlYQAsB3JSappMsobKhYB7DS1rhIkIGt0aLQom FVrcGC2oCc9Y8jodqa1FIiG6EHfvLPikewd4ZbA97akUmh+vBQJyuFiGGEntB+AKJkHl QMqy9Kvr5fwp3TicpklUCBp08NKSDB+ojKvwzTDt/ZU/9hXUPCAltM4kVcx6ftzSpDuH +bKya8uyLA6uEtTwr0UaT2dhuruKV1CL4Jdsg6ePqdegEqICWxdw5x6o8FpVlL7VKHze 5T9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401491; 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=1wDcE5BTiRUWu5IpXdTXJGaa7mTD/67d24QZlEDxG4g=; b=qtXtHmt08cm4nHVcSWMsRp644uhyvXdhC38CmzjNh+1AEYrakUbm5wCmvHx2404WjT crWwLNK90yFEsj3LninxjP2HW5BiyeOOe0y4yDiv8vDN/0LmS7+/5nfNfVeMFCze66JF jye5IUhKB/56Bbxl3FTTtVMpfbNp54Wt5szinw0k3+JoA8R5PAjvQTYlN/4RAF8IGXl+ 4+I25/QazOKVJKVXktAzJ+z8N1R+uW9cWoQYmM6tjY9WsQm64Wh+bbCmQrR1FauZjJ/M 9dHbWopWX6PQU5eq4C+rZbrgRWB6fr1RiTmpXHcgj5CMbt+Vdy5Pq+pWs6RP+k+K/hlg d5zw== X-Gm-Message-State: AO0yUKVPUatrUTllT483HXSd4hQdliF9E0mS5+rPgi7lmnRn5d8AKfdy IxdUc07sgKinbv42IF8p7ps= X-Google-Smtp-Source: AK7set9TlH5oqA5OMR062s7UBWc+YVnkZxNVsmcE0XNDXGzBJ3XRSGtvJ1Uzt17x8oFzG/u9Sy5sFw== X-Received: by 2002:a05:600c:1d88:b0:3e0:17d:aeaf with SMTP id p8-20020a05600c1d8800b003e0017daeafmr845627wms.7.1678401490932; Thu, 09 Mar 2023 14:38:10 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:10 -0800 (PST) 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 v2 10/14] dt-bindings: net: dsa: qca8k: add LEDs definition example Date: Thu, 9 Mar 2023 23:35:20 +0100 Message-Id: <20230309223524.23364-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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..866b3cc73216 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 have 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 Thu Mar 9 22:35: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: 661332 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 60629C74A4B for ; Thu, 9 Mar 2023 22:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231765AbjCIWkA (ORCPT ); Thu, 9 Mar 2023 17:40:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbjCIWjX (ORCPT ); Thu, 9 Mar 2023 17:39:23 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634EFF4D91; Thu, 9 Mar 2023 14:38:14 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id j19-20020a05600c191300b003eb3e1eb0caso4765769wmq.1; Thu, 09 Mar 2023 14:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401493; 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=VMC1fBG5a3K5yvny/yfu3vMpe9zjjlud0NIygPwpOwT+VmqcbqoYNNCZxsIPj/Nkuq jDubkkDElPJNacWO6eQo1YxK8ryxwUlumbImj/ewzzLtsH21D1JQQvlNtzDyykixSXvz VK0bWIJ4nGy52WHPf2xccFng1l8E3ro6+469igHmB3pLmFce92kjl9gWcp1LfuvXXwEe vMEOXCYzGomnd+SLjdXS109KmDr7J6TAjcmjoRvobRWlQo8BbcpdPAK7H26VtO7hps9r RNrhz15q+v9p5mpE8Lj4XPTHHz9I1x9wA8fcXsIvvxoETMv70L2PjDZfhpn7ET4UTBt8 Y+bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401493; 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=4o/3tnwfNXveZkbj2NZ+FxxuZD7wrmA/rUQ+xJyQdHykNDLvNli5y9QgDwY4WR4HbF nQQJYZT0PiR+0xV1Pbc5RkoF8KkQjXUW7lUGyGrvBlAiLpgQeMwua5IaUehdR76g1eg6 olauaG01CIZWjFcxBbXxgc+K7TdFjxXh23HL+fvZpK0qI3Ch7qlcV8l2jsTg7TsiSCAi yx96FDKs1EUYf0lR4ugaOgJ7RQ8SgHmjS2SRxSvgUv/ZtZDuOt+V0rxztYBrmq7LbxL+ SuPrgfG05w/iBQoS6ZKf6hx6O6qpsN5d32dQTGsvOnUQmGYL2/7cmleaKTpnFf/L+XPJ NQrg== X-Gm-Message-State: AO0yUKVtJ34QeZyQ5UiE2RhmklA53aWCPhElmBo7QHxGNK6M9wW9u3e2 G8it9N+s2UOgKR0QTBRV2LNTd83uX8s= X-Google-Smtp-Source: AK7set/hspK7iiGUhSEhbZ7lBCAIa01AEehft+SmrwN5cdKBZQ33aj/4jlkrWC+H2tLRXXaVLFFptg== X-Received: by 2002:a05:600c:b8e:b0:3e0:98c:dd93 with SMTP id fl14-20020a05600c0b8e00b003e0098cdd93mr707470wmb.29.1678401492562; Thu, 09 Mar 2023 14:38:12 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:12 -0800 (PST) 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 v2 11/14] arm: qcom: dt: Drop unevaluated properties in switch nodes for rb3011 Date: Thu, 9 Mar 2023 23:35:21 +0100 Message-Id: <20230309223524.23364-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 Thu Mar 9 22:35: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: 661960 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 67136C61DA4 for ; Thu, 9 Mar 2023 22:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbjCIWjt (ORCPT ); Thu, 9 Mar 2023 17:39:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbjCIWjJ (ORCPT ); Thu, 9 Mar 2023 17:39:09 -0500 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 61B6029175; Thu, 9 Mar 2023 14:38:14 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso4760839wmi.4; Thu, 09 Mar 2023 14:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401494; 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=AlBX5JNqNXAA55d3QNsdibcq4SPn1jBTkVAfacjnB4w4Ii8+3mcse308G5N5GI6pFn 9f2UiyqJkbwAyvmIZzeh+1+TELyESzYdb+/qTUmaXeyGR46rjDEfNaKXUAqufwBow76r T4ZsBIwKn6VQxDcaYsqof/HYSMf/+b8BoDGQDUSTiYlNuUa0TIs+mJWJHdrpAqVZvYuE 9EaGXdX7d5DMgvH57SEPQfv5FBR/BZlj7p+hNChe7qmyos5swlOkrH2JmNvvrmeqcZTa o+0dp+4Z99vBqmvHzy63tHn+nBh5wRvFuB8iOc5HWRmYC5re0V3Ct7zdR1xk1e0J8O4m i8qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401494; 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=jYmrwqL0GN2K+mLRfs0yL3YVCz86seWX/4ONG/imvJm9jy5Gc6s2e7fe724yixfvax /wCE/GwFi84LSyd0VobgTxzOgecIFZlrACIdjdVUnWe1uErnjiXkifL4sCJbUWo66tV1 w2KahbsY654LWHek8nMhmSTN+1d96tcUSqkNfldKd/WIurrBNXtNX+Am0GresfE9a/07 X6ODNerJTdku2SeXyLAZEtrkdD2bPWeslkxA6elAkeWgO4nkTYf6hU2ld74QS8WYNRjt VzHQzUieI/ilS+947ZuxDaYb3qdmdNoU1s5ZwCyS9Tc9Up0IRJ8mWbsySBCy5TwFNIkJ pzNQ== X-Gm-Message-State: AO0yUKXkfn8TUeyJINqPXdxqyxKGE00yhz/xDhftBf/O2HSu/P5K0S+c tzesy7x7P5QV9hF2waHVFpM= X-Google-Smtp-Source: AK7set8DC+6YofnzPHF+djxl1OgmMSssYJQWpUXjr0wXeQzYITJwA9+xjTK+yR4KPYwb7ScFAtimqQ== X-Received: by 2002:a05:600c:a41:b0:3eb:9822:f0 with SMTP id c1-20020a05600c0a4100b003eb982200f0mr665189wmq.30.1678401494076; Thu, 09 Mar 2023 14:38:14 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:13 -0800 (PST) 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 v2 12/14] arm: qcom: dt: Add Switch LED for each port for rb3011 Date: Thu, 9 Mar 2023 23:35:22 +0100 Message-Id: <20230309223524.23364-13-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 Thu Mar 9 22:35: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: 661331 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 257B7C74A4B for ; Thu, 9 Mar 2023 22:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231796AbjCIWkD (ORCPT ); Thu, 9 Mar 2023 17:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231469AbjCIWjX (ORCPT ); Thu, 9 Mar 2023 17:39:23 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EDDA102853; Thu, 9 Mar 2023 14:38:16 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso4760873wmi.4; Thu, 09 Mar 2023 14:38:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401495; 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=LY12PGb5U36RAyvwk4Ct7zflsozHYkIIlhvHkrKH2nJqMc1/DGhRpL+DhwyM44V+ww /gxLhY7o/Mmfcod8SAxZ56oZwzZdMte9cHXeNJUUbPOEv3u5tIfk5hz1dnOUgWv+bZ/1 b+bebnttbuJXDFVwlTCZ9SReSjjc6Pn8cFCPBdAtHvZvX089U7xuIVxybi76pvJdIlHQ 7w8ldSpPJqyiEGfaQEZ+HVN6uegxguD+uII7ppHbWZMYC3rCbjr/HsOEUr4RV548SaoR 0FYIodjRM1LKZ0jqO9wT/XxZtJVVRnv/F1zsxgSN3S2Sj+6YuXysyf7xe+2aCSBOxBwc w6eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401495; 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=p8AoyjJjnesfazuBszubweOhzspMrwYYn3Dl2dB6rqsdxeJETKLAHeXO2RJs+/PTjH SmFgmdMlsmAY5N1/nsfIlKy/4WP8RdY6D2qm8hRUcDK/fJyB/iayjfMOJSe85Wk76yiE hbgc/V/hJrrL8VIgNbBvZGDre8hBMUBjcoktGXYqXW4Jz8m6LhpJflHGXmGwT+v2+A2a 6xaCAxAf5E/0RvfahPslSfTLngb2Jb0WEp/y25IeTFEJKW45dyrt7RJ1JPUnKcH/DMX4 u45LACWIk/Qw4evNlo39aBPgfWzyAPAA8IsXSWCXnBwY/wKD9TJjTTNdXDlkQI9AFMx7 t+3w== X-Gm-Message-State: AO0yUKXuWLlfNwv4AEia1ZE9KVeu4VcASs3ygx3OwHaC2iOxNqLWUadF WzlCweyhug4XO6l9j0+S7Y4= X-Google-Smtp-Source: AK7set+2vOeNQz9KeLlNl7u5v25/ZpT4RBWDkuAWaG0mXnir/bYVDydsGHDBeUQlRnwL6szv3lP6Tw== X-Received: by 2002:a05:600c:35cd:b0:3e9:f4c2:b604 with SMTP id r13-20020a05600c35cd00b003e9f4c2b604mr702682wmq.24.1678401495464; Thu, 09 Mar 2023 14:38:15 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:15 -0800 (PST) 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 v2 13/14] dt-bindings: net: phy: Document support for LEDs node Date: Thu, 9 Mar 2023 23:35:23 +0100 Message-Id: <20230309223524.23364-14-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 Thu Mar 9 22:35: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: 661961 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 D967DC76186 for ; Thu, 9 Mar 2023 22:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbjCIWkC (ORCPT ); Thu, 9 Mar 2023 17:40:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbjCIWj0 (ORCPT ); Thu, 9 Mar 2023 17:39:26 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C76B26CC5; Thu, 9 Mar 2023 14:38:20 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id j3so2257134wms.2; Thu, 09 Mar 2023 14:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401497; 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=hKTAoz/5c2gh8Y+1xcGszVL+VPGe5qIqtDhWxElzHg8=; b=Lz9RBu9CNknt0QOl1Aljn3cwAQU50LY+AV7pSEK2Fj8y3Hddbp4bpOTZi5rdS139F9 8ptUcoz9oF26o4TdIU880734mFr6D//0Pup+yhl4sl+qWhzxl1EQsry/0hWIrecGVCYX irkJVeam6BQf1XKfDhMOAItTSlHyiuUnGkQIZ69rZJp9rLO7ToxONC/5gBKjkgcQYWSn aEgSeFeD1BuSXWBATUry4dvmFsB+d+jTHeR+0pf9nT6vw1LcZ1N5nbxeVBRBAl57csCT E61stkETe6G9jYvNriFX3ip8Yen/ibpiuilcO10mTst/5qyra0K1kpwYzwAC22YbidoR 1EsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401497; 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=hKTAoz/5c2gh8Y+1xcGszVL+VPGe5qIqtDhWxElzHg8=; b=kEcujqqqkijUj054l9C65d3BYTAubaAtZqRFgtOeHs3QyUtz5aqXWNTmkiydFMo2SC CwAbtBQjt8WIpVNvZs6mViXyjFz8bPMkE8YfoIm6NvHek3wU1AD8V/NVGYCLn/UWi7YS J6sEHzkqyK1Vl9qKc1ifxaLgVkc5AGiTnhOw4kFmo9PFjCLT/G/RTr7Z42eSOxrEWExk n8phLQAXr7IEWxX5MLKJ//TM2Pvqv83gN07TkAsloVCi4pISdcO0JU+RnnGRRCyB2b+Y l+VnLkus75FalDRthkJDC0bIGpMw9LowcM8Eu20qj0JoA10Kd2I5jXWdaHIhylLKpF2P MJGg== X-Gm-Message-State: AO0yUKW49xoQZ9bEjANu8wxWWFCoOoKX2l44u8mqpJFZ5YqZ5DwS/tbh 2CyXWVafnruB4ogXDbm1jYM= X-Google-Smtp-Source: AK7set9nJyc40zKBJjx/+yRO/PvBUSMQMAtbQH41bk/GikMpPlZvCnoCom8HjfPdmlaTb9H2ybUlWQ== X-Received: by 2002:a05:600c:3c8f:b0:3ea:bc08:b63e with SMTP id bg15-20020a05600c3c8f00b003eabc08b63emr808544wmb.2.1678401496818; Thu, 09 Mar 2023 14:38:16 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:16 -0800 (PST) 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 v2 14/14] arm: mvebu: dt: Add PHY LED support for 370-rd WAN port Date: Thu, 9 Mar 2023 23:35:24 +0100 Message-Id: <20230309223524.23364-15-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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. Set the LED default state to "keep" to not change any blink rule set by default. 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..ccd4699b219f 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>; + default-state = "keep"; + }; + }; }; switch: switch@10 {