From patchwork Tue Mar 7 17:00:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99BC8C6FA99 for ; Tue, 7 Mar 2023 22:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nO5BCCjIbsgX0KeKqYdVdW9+F9swzvE8qhd/7Zq6DqM=; b=qpjSSLf01rDPGM GyN8tKAOdqZH6SWd88rjISmPIwsePSP5IPbVFy4X+dT+zbViSM4PnJQjaGj3JH7BtI+0tx77RWqco zn5l80U2cLFG14UdtJY/SoOu0rXWyc4Cm/460Xvthc0b5FhTIUBHc35ngv20LnwUZZH8eonpzDOcZ 51psIVrXTRpZbDN0a+DQ4zwfZ7NtdXGBZ8oE/FXvQKf8GmVeRyhtrqLwFeMpDLA6lBTJdPjBKRyTE GgYOfQuexm2GR4I+bZ65V7qgOFwMvwIG2Ll7XCPtvA139ObEzze0geeEvD8p3nAnA/XHIWHpYJDHB G790tcxHZow5xDBcNm1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsP-002gvR-0v; Tue, 07 Mar 2023 22:33:45 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfs9-002gmL-Vh for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:32 +0000 Received: by mail-wm1-x32f.google.com with SMTP id az36so8766437wmb.1 for ; Tue, 07 Mar 2023 14:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228406; 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=nVXKxnReQgPI3C/jIyb6z2NVvBlHhqj0bEwSbcfsghs=; b=RaxWiIOHxZebMVCLGR+GuuFFArgIY82I+OQ/wWtyEP65+Qt0tyciLkob+xPQQxhYD2 TC+psndP/yVGutDKerURA9noK2LLTo1Gk7oUq7SCtkvqqxdkmBbxj1Mafw1DHPLblY1X avH0XfDyItrukDftj1WCH1z64DhHY+XbZueIcOeaUbAQl9YLfpo0hj7zc8eBS7106cyS x46XhgR2FCs4Rc3CdUPlWJsIoHxy40DKuuI2Bj6Lf6pKEu+z22oIt6EqsW58TDtDE+Cz Y/FZPoYp2Aa5ZjXQOsQLNbS9QUfFSVkHmbUUaRQniBZj+ovo6HktxDI4QKrACp4K90wo BVWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228406; 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=nVXKxnReQgPI3C/jIyb6z2NVvBlHhqj0bEwSbcfsghs=; b=e299ou4KbSjtIp4UG4VpG2VBUHwmVt0qBQdOxHaVD4mgjz9g5lFTJ61mhgyjY/2om9 b02Wx4979f39ilFEw107TWvY3t6FcPWQCP4FwLRlRjrT8VgBgB0dJhZFnA/8VPnvPcgh nwJosvKIFB5XgXlJXTqfAi432T2qgl375Gm//RjwU9YgzK0L/l4t8uEDOXO3RfBCGiFF 8tuK1vmBitX7RqhDkTIjDQFrjnZpnTgPkcDzcrqec2rc448acOTNBdyPVNk18fCXcr1a zHSoFqaxBwaZWpT92IBCgJVkzb3ghmJ6LNtFo6FuoD9agL0fJ682K/smFq5AJCBOI4Tg 3tAg== X-Gm-Message-State: AO0yUKWpu7PDQsIGR7Arba+kV6NGHxOmhlYlTTNEDH7oHTBIlH6xD9nl +H8/3Cz/Hz2OaHGW2nYoh2c= X-Google-Smtp-Source: AK7set+H7QJwNE6fGG4ie4Kw9Z1BFBv0ltB3tYRdKsTci5ZpCxtDdG5zPJn5Zpd0BdkD8POOdC9pYw== X-Received: by 2002:a05:600c:1c20:b0:3dc:5b88:e6dd with SMTP id j32-20020a05600c1c2000b003dc5b88e6ddmr15313681wms.10.1678228405863; Tue, 07 Mar 2023 14:33:25 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:25 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 01/11] net: dsa: qca8k: add LEDs basic support Date: Tue, 7 Mar 2023 18:00:36 +0100 Message-Id: <20230307170046.28917-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143330_050988_5A46F680 X-CRM114-Status: GOOD ( 29.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 | 200 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 69 +++++++++++ 5 files changed, 281 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 2f224b166bbb..76fb062bef84 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -1742,6 +1742,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..079f1b423f9a --- /dev/null +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -0,0 +1,200 @@ +// 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_PHY0123_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) { + struct fwnode_handle *phy_node, *reg_port_node = port; + + phy_node = fwnode_find_reference(port, "phy-handle", 0); + if (!IS_ERR(phy_node)) + reg_port_node = phy_node; + + if (fwnode_property_read_u32(reg_port_node, "reg", &port_num)) + continue; + + /* Each port can have at least 3 different leds attached */ + ret = qca8k_parse_port_leds(priv, port, 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 03514f7a20be..001b9daaec20 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 { @@ -512,4 +571,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 Tue Mar 7 17:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC44FC6FA99 for ; Tue, 7 Mar 2023 22:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iRGRcV4+jwfu7ajVbPzRAJauOxWhrtYbdAXDVb1Sfc0=; b=wCXhzunrr7OrM0 4XTN1Ju0y1d/uFj1uW2LDbJsRdJ0uvdkc8Tyu8lNEHXI1KD4N7OOIX0pPVHCdfVi7n1LYccxY3bI+ osZ5tQCZhzpQ6rkH+e64Sj87IC79nvz1xpMj6a21vmnw0NkTqOdPxnLEndUgrQxu7DtH+BaMf7mTP BqBslUKcsoeWwauk2Q4AGWHE9pB+UKehNwURUjHNuQfp8uLl7VKVpNji5HDlctxQ7L0BOIwTh4ZBv ASSJZEUUfa7KGwW1jgDG8CD3x3vcMvwrwZ7QjjG/Ad2xaWK5XFmB3rXIZCLDE78VcdF7YWKxYuDzo 5LIKcT5NyC26LzZb+5IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsv-002h8i-8L; Tue, 07 Mar 2023 22:34:17 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsB-002gmV-92 for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:36 +0000 Received: by mail-wm1-x330.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so96550wms.2 for ; Tue, 07 Mar 2023 14:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228407; 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=nDSS3ewB7gG1U+v8T7rnOXrGZSm+UO+B7Lfb/7bhXAg=; b=blz3/ELBOXjUrdpi07dtGFW6XFc748WAF+shCc4Fr8mm44kTCg6M/mJ3MTyY+QY6Xj HUFb89ZpGWr8FXC5jEvTsI3N/N3+bXy09ur7qmeKjP0idN9vd/Kb7N69FcJyeQF6fZvK K5fLOK9MSyCRDeFCnT3bLQ+J5CKFi8x6vv9Efp8dvBjgmBSsm/xP30sLXQ6vGVRBZnDL +DA1xIh+PIHUtWm5Ya4XQHrHo0mvCl98DdXUAW0FnuJSO4Cw/5xyI1AKNZOKf7o+KPOk zsO+0Wn57TIU2rFc5uM1hm6S6CTyvhn5aceIC6o8l/eTkYnB8gESS8Q5jzv6ZuG3RaKy 2Lfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228407; 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=nDSS3ewB7gG1U+v8T7rnOXrGZSm+UO+B7Lfb/7bhXAg=; b=uSwEHR/xkAx+ySL8LUJz0qZdkoPEC7fDJ7cTxtoufLKixBms7LhzwAM0OyKeB3+U5f hSMb66POIXhYu0ZYQ6oV4p9rgMLjRKZ2TffljZnI3+CgX5Qop3gwz6vUBRtoDedOGxVq FCYQ6BPZ82aVXsNt0rmpFI5CkP7b8JRRyU6xjzqdoRuuEDIEuJdTqkMPGDYSFr1PidAr PGvvXtherylbzSmC+hFGcnS3JgSuhxkMLPwL6wmjlsa8qrUkggu0eSR+GsNvLabmtENt Ws9vY0+WM5QZgd+g4fGcbV+2ZeOxxW7Z0cWWCKT0Rd7NnSbuCRC/oCMWXZjDQcvF7rs6 FyTw== X-Gm-Message-State: AO0yUKUm3Y9sbbYs+0Yibeu+An8vjJU6Kp8b3HlkdMxQusfqdpg9/SQw QSC8QT5BpnWAG6kOhur8XlI= X-Google-Smtp-Source: AK7set/RMdqTxdOk4/p5y0aZH3QBbMwhSDw9pPagi1QOQdzjMzgGd2yZuM7LJ8k8DM9k9S+APgYOhA== X-Received: by 2002:a05:600c:354e:b0:3eb:38e6:f652 with SMTP id i14-20020a05600c354e00b003eb38e6f652mr13920493wmq.13.1678228407200; Tue, 07 Mar 2023 14:33:27 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:26 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 02/11] net: dsa: qca8k: add LEDs blink_set() support Date: Tue, 7 Mar 2023 18:00:37 +0100 Message-Id: <20230307170046.28917-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143331_341193_0A1A64CA X-CRM114-Status: GOOD ( 15.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 079f1b423f9a..821ffa1f5b5d 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 Tue Mar 7 17:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B15EBC6FA99 for ; Tue, 7 Mar 2023 22:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I3/YCh8FvwuUQUdHiFuT1eFPd9aYYnfoA492mY1f0OE=; b=Cf+7MLCD6hyNAQ QoMjesbuKy737EyQjUqpnut8ck7h3jkVf/8+ZnGNjZKiBKSXoiD2lBdhE9EHHyFswzkEbT0/Qsf8U kr2nRPGCuVOqE4DrQlL2UXVSwU7wTZieUqrGYgwiE+eKOeuAaVAmHVz8iMldD1ygQ5lmGsJEATiiD 5OpWw5WbeU8Bz96J49p/IEymNQ3YKPEg6OprYeQuqI1Lwk+H9CarRltTsNx0gunS0TwGwfJAh3SS4 dgcvPLls3FRLmEy2QevfLELT4zCKI4y1X6fay98jGpcJ3yFlRC0J/P3ANc3FAL4bo2FteHjCfzVUu oJcAQk/ga+ATTGMj1FxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsn-002h5s-Db; Tue, 07 Mar 2023 22:34:09 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsC-002gmh-By for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:35 +0000 Received: by mail-wm1-x334.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so88682wmq.1 for ; Tue, 07 Mar 2023 14:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228408; 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=PNA75+ffAuv7QuOxp1Cc8LTrOxCzACAVhyEOObz9ATQ=; b=Ous/JScFrx1dSu9x6+tQiT/MLYKi3xMjoh/2zzApSkvb/hTI3pwPN0Iv5VWQ/6kcLz uw/bNtz9yrxt1Dm+77uj2Hij9B9Ilt/yncfd0KzeZmFqicT+I+Oml35h10/7rs+QtTig f1znzcLnWi71teXhkEEhYaezDTos9OtE3JkbwXxBofL00/PYxjuyWOn2c2Pi0IEylKPd CGjZaa0YCGiRVy/XrsSuX3hua0ywvkQMwFYfI9y1+I9JrcgqXZhfAnm2xp5WmjPfHO9e BMj9jwEDNbPTctxTPqcfYdQRl3W3HIRXf1oDa045h9Vs81BlCdE1nQKH8V92P9TblByl /SQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228408; 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=PNA75+ffAuv7QuOxp1Cc8LTrOxCzACAVhyEOObz9ATQ=; b=Hf++rO1XqRgTTwJPisYAMWPimE3XLodMg+Dz3JMsUv2jchWdPije7bQPQIm2vgYc39 IURaUKfuSWDT8OgR6jW5s/P//kUN3ptylscGi+BgZMwyY1I6cjyIbuZ2SgUBBPzUd1e5 l3Het06ZvDCDydMPgQM/4ffRAZQ81J3KA4kyB+eUGKY+E68Jl7BIk5iNQFamtp94auWt vGAGFN4SkaaZU/WTnccNNvsIj6O+JfZMMjX0Qh62UVCeeQHKIi2Rfb2/4hcsECellVQT 3w7nitKZ+ANLnFIVe2WkBXyMQWNUuZ4wIrL3xTu7uPv68Ha3u0bgDNNHKkN89dyBGiRE aJGQ== X-Gm-Message-State: AO0yUKVYuurlV0RqPxKOcDaO07LyEOzQFqOThInaRMgTVyy/zlLS49hl B8dwSkMUZMHfmO4jElbFWpEEEkPX+g0= X-Google-Smtp-Source: AK7set9RLmmfjOKKC2D+hLDppQ5/16MJZhaGu25c4q4km1PSZeLZ3CPqlu+9ygLhvoGX1Olx6hwHgw== X-Received: by 2002:a05:600c:a09:b0:3ea:c100:e974 with SMTP id z9-20020a05600c0a0900b003eac100e974mr15119103wmp.26.1678228408515; Tue, 07 Mar 2023 14:33:28 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:28 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 03/11] net: phy: Add a binding for PHY LEDs Date: Tue, 7 Mar 2023 18:00:38 +0100 Message-Id: <20230307170046.28917-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143332_434830_D8468B32 X-CRM114-Status: GOOD ( 22.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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 Tue Mar 7 17:00:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E0B3C6FA99 for ; Tue, 7 Mar 2023 22:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gjI0vTnWq5Qx1zJory79QAy66x6xtAeJtdjN0NSuHrk=; b=LHpxozyItzRuAq /N5O0rhH+5QGK7dnKUCpbE//SrRi+UwqmWr0zziuO/5aMXDyJhwa2ID9W2gVAm7QLfrH9Dq4XbVTk t5kz+pI3fqk5zrPHY/9DgZuIed+TY4+QVLYX1T6DViTETCe/X0yVqSJMGbTne6QxNIXM12BhA1Czf 4HIoW+g4uMsVmAmItHOXyPJUm5qjTnrnuzwAPE7V4qeskTaUn7ZWsbKafKoLWzkHcJoGaaBGyj18k RDlqlIk8651yTw+sd0T0kuWGubz0A7Q+qP7dZoN7JYqNP06CLJTwOd8ZuUmkQjzqNdrfp+zNi1qiP ZxK348pb6MdUjS49DPGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsW-002gxG-Ud; Tue, 07 Mar 2023 22:33:53 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsB-002gnY-8u for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:34 +0000 Received: by mail-wm1-x32e.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso86522wmi.4 for ; Tue, 07 Mar 2023 14:33:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228410; 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=WKaejEkwd7x7h0zVDdJBQrWswFotreBUxLmSKtjxwLI=; b=di+9QEKVE16tj01XPCZMIyCFK7Anfrsm/6mIfACWi15xdVPAF2EGAhvTM9IdRpw9ci te1m+VbZXvxI4235YjygsOcjBJuyKGGKx2eMeTbCKaJhDh/d1jw87//ALmRbSqc5q2+F /9BvcJ4xRtTxjluUvFuoii/kKcUDAdPC750MkMuhCnr5Hziu0aCaJLPfXt5zcddcdzmf chBhXASMkrZZJL1XjDH2a774Mw2lzvULIg7EYshR1e9fRj9OX8jNkayWjihhhg6NdGpX yrMAq3QlBZaT0X3dHMfeipe5Y/mBJeBV8pAwjfUMi9Ohak7kxOPbCqCY5qFLyWHR9Imy IAhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228410; 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=WKaejEkwd7x7h0zVDdJBQrWswFotreBUxLmSKtjxwLI=; b=bWdyg99oijxvnaXwZIdSSPYQ2Nou1CJgXer50TznJEy7WT/soC0VYLmSG8rAkcw34p QRKkdvSfSSP3JgJDYccix/3kjasx2QLkY9bOVFpIJh5mOfjxdgaAZijyqWFGnvbVJmog k78lQxEggIBVG+MwfYG61SuMsqxErkHwOPrN409CBfcndJ4TdMEsYoZ2VDsDGu8wHE6B 3cCxrQXXdxIxdThrRTUghxfzJViQVx2Q4hxn67CJhIjsaSNUvQfDvSjsF4ECaJb2rUPJ snyjKPZK5I9r9Ke3v/IRm4pwEHYZrBW4Rr6Gtl+xhfU2UUGIhjtX9E+6O2cLHR0JN8eZ GXKg== X-Gm-Message-State: AO0yUKXpTB5PwHu334WkablzOq+gkxrXcsRRbozyvwf/ETqJLl/UpBDP P7Kmup1eUDsXKjK9dL+bARc= X-Google-Smtp-Source: AK7set+X1R7wL4H+5FLmHv81NW3Frc4k/b4zPNyfVIi5ntM6gTNEfdWfJjKyJXPWyS8i48ZaQdOk/g== X-Received: by 2002:a05:600c:4ec6:b0:3e2:147f:ac16 with SMTP id g6-20020a05600c4ec600b003e2147fac16mr14763611wmq.10.1678228409772; Tue, 07 Mar 2023 14:33:29 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:29 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 04/11] net: phy: phy_device: Call into the PHY driver to set LED brightness. Date: Tue, 7 Mar 2023 18:00:39 +0100 Message-Id: <20230307170046.28917-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143331_341130_10159B14 X-CRM114-Status: GOOD ( 18.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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 Tue Mar 7 17:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7EC90C678D5 for ; Tue, 7 Mar 2023 22:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a8pBTlga7sL3Ec7/2+gdP64XDHg7ztwKq2eniPiE9+o=; b=s2fNyx19mNnzJV jsckrFimpdHWhU6+WOzz/bk0iMzarTxPwmvc4SSchAKPRVL5IeiMkUDq9Nbe0/F772INNP7eippPq fVV6Oo+WykwieNx2kIKVdDUyci2+m0Kyad9c6uJmXuUgmfZ6SHu4m3HM3BoOwuY+CZ/Mk+4c3/ceS GuLhbisbUQIg8vontTjvmo2RVPvXCayna7gusPVMPdhehrQtl/uwXRY08zXb/c7q9sehRmnnXtX17 4ZioYCrLVp0+8xpIzi9ySHBy4Zt8WoJ/fZNDXfWT1VfTSyqieCA78LASZEk1KEUKxHKsqTdEbNSrq kVfMNBqUUeL6ENuzQ9BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZftF-002hJu-MW; Tue, 07 Mar 2023 22:34:37 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsE-002goc-RE for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:38 +0000 Received: by mail-wm1-x332.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so96612wms.2 for ; Tue, 07 Mar 2023 14:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228411; 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=YjQ9zUptjAK9h5PeGCnuwsF6N6MpAnfvAgnGqTv2rz4=; b=GkLKswhEJ9JuupGG6E3ZcmL7Zm/7UGS+ozpbz8erPkYNUz6oOWiB54xmyleejG5j02 Mptq4VsYzAZzm3aGEHga9EJtlkULAs6Ek49Q0YkaJ/rIupmaSL3+N7mjiUAY8tTWIxAQ QMr4a8L/5lJGvOPJPuB5FyLRpNCkFB8gaYrKVP7gyH73H1WdiTyVJlEkcNzf0EUIzNi1 1skSrABkofuK7Vw8xeVL7jJY5TS1x0ebU0KpRNrjL1l9sTKwhEMUKtHRqm5JYNGJkOOB FLAVUn6Lk6ylJZ9VaOKW4TH2swOLEZ6RimgLk52jdEb6KbDxfmeYZC3DkZ1t9PFBH0Oa 0SXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228411; 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=YjQ9zUptjAK9h5PeGCnuwsF6N6MpAnfvAgnGqTv2rz4=; b=KZrmz6vi+fABe0pPYGzHqXzPArXcgApqxEcFfIn4DL0cu5tkT8bUZsZGhCLIAunQJA rIzs2Z4BjAMjY3nCra4xrtR/BSZjyNMaOKmWyeXEZCUhIh3hxNzD3Ey6VKOg81hSnclB 7lUq6RZWgQv9Clp4ehqybwXvd2AH5qQ0SYPiF+G3I3ZBSZUgGuZEkzQZ8lFjE4Id9rmx a5J2FaLeaFtykPJwiTTz4wn6D3kBisLnM6PK9SaGpQxxGA1uHaETSI1UHzWPXbhACU6L PSEdSYbgXtA5wzmx/PwKk2bF6m4yAWLC3axPdoQgEZoIhVbt4W+i1kKuUC1SS3Jm11b/ TeMw== X-Gm-Message-State: AO0yUKX6V9wyUpRhPs79SpoQ2tGPj1izis0+Gsux9LRRJyv4PLV3/Bfs G+hjfPUnRbcQBvzndBcVeoQ= X-Google-Smtp-Source: AK7set9l0qDHMnv3eD+X7VfkfGOlqB4qKtpI1Na/Z2zrCkh0ePpNtbjGoHUxOy77dtVVhiZw8WwgUA== X-Received: by 2002:a05:600c:a48:b0:3da:acb1:2f09 with SMTP id c8-20020a05600c0a4800b003daacb12f09mr14888815wmq.19.1678228410991; Tue, 07 Mar 2023 14:33:30 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:30 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 05/11] net: phy: marvell: Add software control of the LEDs Date: Tue, 7 Mar 2023 18:00:40 +0100 Message-Id: <20230307170046.28917-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143334_921228_46ED2EF3 X-CRM114-Status: GOOD ( 16.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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 Tue Mar 7 17:00:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B30FC678D5 for ; Tue, 7 Mar 2023 22:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N4LB4Rtt+1iE6fTOUETkRuyXShVoTNB+wQEukr8tdAc=; b=2Buxf1nPUz/6Nz gFs2avnMUHJhsutHXdIMO0DlM+Bpb8LFNkt0nWL8u6e9p5TaJiMUAHonSToNZDViu4SAqnEQDgKF6 t5iMnazek50ykvWN9EW2nDKRXlgjDunyGHprEX+gDCyzneF5a3fTojfpgikwNSk7mv/e87w6sNUmR azlgIfJdeZi0u1F9CyRJr+INOw80Wdmh8/Bew4yU52oeCs4dS1quIFEh267x0cL6paEFVGPyQUxYq uo+8YSTOi6JT9QK1oyW3A9b0aLW+mTRmi1Fsipc7AY9CZbsI5+KuR053+/+OXxId5LuOaXWWUA+rE hejQYmm+PnwbHRmTmRUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsf-002h1S-Ad; Tue, 07 Mar 2023 22:34:01 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsD-002gpS-Ov for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:35 +0000 Received: by mail-wm1-x32f.google.com with SMTP id m25-20020a7bcb99000000b003e7842b75f2so85205wmi.3 for ; Tue, 07 Mar 2023 14:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228412; 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=gFKfyegjpAF6RoRRpVAGQR9empILN5kAdm3BJUNpaCg=; b=OGx0YwG2swcAIAnRSezmOEktltT4pyXlqAQVZzO0srWnoD9MU8CV+V5a8eG06lFMZH hc2X/JqbmpuDT363nP+d1w6jpjNWUsquAtRUCAmj6dwSd5k9r/wiMzybfvLiHPk6bCDM jT4kGExubAq8c+23XTyKYB+j2bJ5Picl2zHlb11xU2rtZBh6ai1IlcKwmdi/qOT99IKk 817yXxA013zL0FHereOgrheqMuOr/PipPswHWBOvavzLUr+7bM5F5sQeJGoKWkY1X+ca G7QI3g4o4aqlvNehyZx9AL/iZBefsI9a8gbVE40YapR8vxH/gLx6tckPBYjq3YDNGerI 5m9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228412; 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=gFKfyegjpAF6RoRRpVAGQR9empILN5kAdm3BJUNpaCg=; b=M9+ltBrGdwGXJTUEax8QuONzx6t3uSwBmc56J5PVTvxL1V230jx2KdqbERyVXaI3cW Qs47nSc3FJTk+yrUElZeUFZz5vpjNMxBvqqqDOjYxLS4yzXOHWDSt1yvWWGJba2uQi46 pHrbCev2kEB8E/h0PVsEK/S2oGQEhdej5JkIn1lanH7cUR3+bV3vap0N+hTsnXag4F4g 6fJv4AN6xxxTq+YfE7G8dG5KjOLfss/iu4XbukxquzWqict9Iy5AVwVur0xxXQRva0FQ GS44dSuhfBKrJVMcRjbnPeQHOmrotkDuC5s6kFvklcXp74Xoi1cx3e1/b2iqyz/6U/lb WHMg== X-Gm-Message-State: AO0yUKXp6eYdtlqIOZkOewQhF6nNC/i8fQSLwtUDbSV85JYupzGkT80Q iMJC8s2ND55PS5mfaMIbuys= X-Google-Smtp-Source: AK7set/dV5nZ+FNI2b7VXbj45v+N2uFo+8OdCBTd8TWevumfE0EUKAdS4gIC3ZFzOO/T1LNL/84COA== X-Received: by 2002:a05:600c:a0b:b0:3ea:fca4:8c48 with SMTP id z11-20020a05600c0a0b00b003eafca48c48mr13505083wmp.23.1678228412313; Tue, 07 Mar 2023 14:33:32 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:31 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 06/11] net: phy: phy_device: Call into the PHY driver to set LED blinking. Date: Tue, 7 Mar 2023 18:00:41 +0100 Message-Id: <20230307170046.28917-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143333_835268_61E45B8E X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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 Tue Mar 7 17:00:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA758C6FA99 for ; Tue, 7 Mar 2023 22:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GOnO/MTJZv0mXkTC/1cCqNuNFYOU0xx05auMae9ax90=; b=JR2+QBWEbwv+oc dHNOaCZ4jfse6O7DytX1hZqSpdK5g/mVfb8KM6JPEj0mg/qUGyCoikV50MDDH37LuRCNPhN9aYsAC SpNI2kndHiELyZ7LjlBtTjIOnTAn11mAfZz0wBw1v0aaAyOPJ7Q8t8dmuxoN8AOdogf8WW1T74fdR o7VnbD4FTOJCRuHiBnIuqTTpvjF2uPZgFwPbN+D0GdM3y00OhOwbMmnmclIey/+cazGLTGV4b541N dndGl6cIdZ3UFTO7FfJfkOTsd4sggJmvxvC+iXGNI9jHa5OdZ+zRRS0+EQoYec6Gc9luM0QtgPWZZ 5OehOwQB/nU9I/Gvv+zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfto-002hda-7S; Tue, 07 Mar 2023 22:35:12 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsJ-002gqG-43 for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:40 +0000 Received: by mail-wm1-x329.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso114552wmb.0 for ; Tue, 07 Mar 2023 14:33:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228414; 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=DtgsVIE8/r/u/FOFl3VwbasZiOSZ2CLInrLaIK3WMmg=; b=iVDt98pbmXd3eMwwYRCK3CvogbBXGTgRDbyFDl+2FLPPKNkNML1w+vuxmmkp+HPk6Y QGTRm6Ectf0ewJgfpNouJXdD3gDvPfuac2PljVF8OVaukK5irObEFIMSVAsM6rAWxdNK JJ/t+9SW4KlSaTkXhNT95LhZW6E8izylTDILKBLNlwxFOQ+FloSFiLyZH9i6oJQ11qGK rkSPBA2Qobs7SoDnfH+GZ83CABU8qHX/3VrnYUU1gmNMuHv+in27KBuZuccJ7M0kvFde r702WMN1joiuPLHAI8utejeeUgZEpe3t8IFxmBjlA73vTPKMh2Zqp9+hGQfupKjm/APp ygcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228414; 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=DtgsVIE8/r/u/FOFl3VwbasZiOSZ2CLInrLaIK3WMmg=; b=u2T4Qob0K0r2y8L7gn95yS5nihm4RijoXKUyGZjatRNj53/dPdm9n3dMAz+t9k63XA Yd45oWeGrV5DEmeN0Vz3kKoSYzMfGDzFJuiEkcDYmJ2FOVYn5OvCTJWz3rv6R6G9cpVZ TnIVB2BFRqqs+I0rR2fDtX1wxTI2JGLxKo4tbLU4Z6mvxo88OMPkW+xoHlVe62+rhRwR bUihcxfB5uqj0OzsDzPHRBnMoS/bIGPgh/iBY5vGjQ0uA0thPkf6JArxhYuBSIkPkqKG 9ZetWGc7P+8V+M2UWKTPimWjPGzIjvhYb3yNe1RPqExhE/5GZy4Iv5682wKtSlZkXoQr Jzzw== X-Gm-Message-State: AO0yUKWmxT3MwybDSjesPCVuHY+TuhRPSk3gHr1z0aYW8gRWI73KdXnE phX9ZF4jxv4hb77E/j4WUOg= X-Google-Smtp-Source: AK7set8P7t6kpUcxeJrplX3CptVfnEYQjz1vmuqiJilS11ababOC1f5ZfYQ4RtW+UbLV6bmwOKaGzQ== X-Received: by 2002:a05:600c:1546:b0:3eb:2f06:c989 with SMTP id f6-20020a05600c154600b003eb2f06c989mr14515076wmg.22.1678228413591; Tue, 07 Mar 2023 14:33:33 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:33 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 07/11] net: phy: marvell: Implement led_blink_set() Date: Tue, 7 Mar 2023 18:00:42 +0100 Message-Id: <20230307170046.28917-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143339_193221_9DA84BAB X-CRM114-Status: GOOD ( 16.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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 Tue Mar 7 17:00:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C288BC742A7 for ; Tue, 7 Mar 2023 22:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dndKhf8XaCALflirh5EzIQJvcr3BossPqhkdIdcxSM4=; b=TounA5mDLrkopY JOOcnOW1wYRBzfBoV8ZMN8OlM599ACLtf/b69ZLsM5VnLobW7IoTG/Hqb4/91Bc0LMj2tH1OTK4th mBEDC0lkTHdYcE4/AuHjy6d+Gq8T4BUQJBTITi0F8qh3qLxnC0oFzQ5wqv6vXterwjrYLO6eZOdq2 bTVAouLRLTxntjVrh3rju8B6c5OkcZ2JS8yjBPDi8lIFyT6oW4Y9J2b5Scb3H/GAq/9ifBkMcpG7e vHlMbzeNfQB/QeplP2Iyn1IQToMbp+TV1RDXOIlZLG/clMRV+RCDf170epxx7M8ylxaCF/hqYhfl0 uBBpEnGb3/CsEBlpIe6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZftR-002hQQ-Ex; Tue, 07 Mar 2023 22:34:50 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsG-002grB-UP for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:38 +0000 Received: by mail-wr1-x42c.google.com with SMTP id bx12so13629965wrb.11 for ; Tue, 07 Mar 2023 14:33:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228415; 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=UQIxIQuz0qPop1m1y23AzYKP3fZZBi9ehi2OyfR3U2Q=; b=cwcFaL0DuRkZrkzWch+9kpLs9Wii5t1UBkhgiD976XDnd47PibX6P7HJsDNWhXQsAC yK4CJfDw2KR/e437kocckaAIzfj9Ahv14eVJ4UPd+TDydp/KPkT6s8g9jzO9nNh9zm+D T9mqGjK4siRrXX0ATVbAuDnQ4H7aPHmErXadXCgiWcCU7y25EMeDgFrAnhAsZ8StsyDn e5tHs/beIz2yXZ+BKseSarX41+9wVQ3yVRUjNpTwauMDqRhG3wo1gUPpzrMqRYAZcaCB 8R2V0JQ9XIbKVx20qF+iGRTbZD5hxhAeKxO70O23L66l5dTMjzipRCCCnS/InsBkyPse HRbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228415; 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=UQIxIQuz0qPop1m1y23AzYKP3fZZBi9ehi2OyfR3U2Q=; b=WHg2CiakQcjiNIj8RpNWa9OuUB452RiovrhF4XdX2RXNagwvpuv7DvEo6IURcbzmyk Yhz3cF9gJBz+vvQGTMvCJn3kY51Df1tnpg4SZmcpxWrxWzgQHSqAWscLXpC6yua/1TLm XMIqGmv+npHN0nkykgXsdGJiAinfdLTdgN9kxhM/54IUH4YhAui7hquenutx1HTfGVw7 vHcBVVL8FQk28iyR2nBgG+/TdATpjVSUiS4dbHJh9VX1rV7/jSDmmv2UOu52B0tZj7w3 Oj/1JbAmW/296GI0q+nkMWco6M3slp3FPx4aSFLiaIz8aIogxM1TjFrJO2K5Fi99wgoZ nG8g== X-Gm-Message-State: AO0yUKUws1xVNgxzooVncovxAlqT8S1LNYmyokM38+LM6t76SMiJMDSW Ll8wjY5D2KSApLXxz/wcgYs= X-Google-Smtp-Source: AK7set8Wl4lcBFilSaNGdtaALA6G8nL1wzO5CN2w3YjhPhV1YzjrNrqemmLvOfIeYIGIGEPNl2oS1g== X-Received: by 2002:adf:e68e:0:b0:2ce:35d9:76ea with SMTP id r14-20020adfe68e000000b002ce35d976eamr9590187wrm.54.1678228414791; Tue, 07 Mar 2023 14:33:34 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:34 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 08/11] dt-bindings: net: dsa: dsa-port: Document support for LEDs node Date: Tue, 7 Mar 2023 18:00:43 +0100 Message-Id: <20230307170046.28917-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143337_013864_53667487 X-CRM114-Status: GOOD ( 11.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Signed-off-by: Christian Marangi --- Documentation/devicetree/bindings/net/dsa/dsa-port.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml index 480120469953..f813e1f64f75 100644 --- a/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml +++ b/Documentation/devicetree/bindings/net/dsa/dsa-port.yaml @@ -59,6 +59,13 @@ properties: - rtl8_4t - seville + leds: + type: object + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + # CPU and DSA ports must have phylink-compatible link descriptions if: oneOf: From patchwork Tue Mar 7 17:00:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A385C678D5 for ; Tue, 7 Mar 2023 22:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U2Zt/wUPGKj60y6TtpSnQ8AfBlrioPjQcAyHlylECFE=; b=w+vofR9751rcxK YIANfcULwjnwWphqbeuvKOm24O4VdXVnRZ303XxXOui4+6trnXL53skEn/qvONVHs6mksAYOSu6Z5 mnFTjcwSKBXgjMDBumSKc5LkVXEyqF3GlZkqsYMH7Yu6Vdt1mw1yrfV3KMeRwBqWBeIZ+qsp45aR7 gvY5mHSYwy0ILh4oYlJ6gtttzWngOQ9GnXlHpEyZACG69bZPhjyGm/phdGIVkAtVVJlrh3YCL7Z7m UER8Qq1e/r3FNmTny19Z4+OSXPNsAjJgSjOKOd/0vlqOwvzh8/+6NyhHLK6ugXr2z+Wb9xgny+hNA VMB4j8dUOraYJlqxKobw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZft3-002hCh-RV; Tue, 07 Mar 2023 22:34:25 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsG-002gm9-LN for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:38 +0000 Received: by mail-wm1-x32e.google.com with SMTP id c18so8758837wmr.3 for ; Tue, 07 Mar 2023 14:33:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228416; 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=WDoaAo6JIUdl2kw+jFWE8rMH0sejm6rC1azuVDxCr7JZJh+7YHIGproCgk3ja9SsG8 ahK/Z9tGQ0hexAtbKI8a2mIcpca1UlAe6E3GWIc5+HIKMds9jsQGnSJDLvHG0Da/HLVs 3r43uj8OwxIV80rQYuayBkTjeZoPyE1jycr/p12/fS8dQfVrKQObz5V5jEKGHiv36wU5 9OnWJtGNlS1+NqUJArkJHVP+vdCFbttDjbF7RgAyUvVqy10g0i7DL7NytX6fXq4mzxmw /Jir8tDLcLDkMsC7PHJvb3CA7b6+r20eWcos5CIaR7/MhYtwlOK3idxCVcXwWvAX2XCe bJhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228416; 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=j9Zh29NirZ278O/qUHxUNtsk/etccbu685dUUlBCsI4UquYqN48OuWZtNvz0r21DN4 2fJSKGTe16womiq+eTxwhaWOg7bPQnxg5iRYfYuA7Fdbj10E9YK1DeZ+xKqx10TNi4gs h+vVQWQHlPlYx6GnkYfzRz4zsQBO0Ycf9xMvbOLI3lI+iMicXUU3MJcrkDkcZR1PTWLv pBJkzUPoCkAd9uludVlWHFrny45Bo5n7+H9dHmkYFgK9SprtcvuVZdWQ2i/ZDnc7ru39 S9xDja+X3w3jd3wFR/Kse/fQGYK3jMCfFNKRTgap8iYNnUbZcM6B48EA79sFJyTA19Tk 3mpQ== X-Gm-Message-State: AO0yUKUPfv04iw1OsdmkZE0Uj1qH1XJfel2ovL51du3B22hivn4TX2wv 7SProhmgPduv6NqV/jB4tAE= X-Google-Smtp-Source: AK7set9EOVxcyvegEO7ejYzIPAKVwZEurXyg6nlBBeD5DcYnJSdy+NEcRP8/INlTGVJM9bCUJkXtug== X-Received: by 2002:a05:600c:198e:b0:3eb:2b79:a40 with SMTP id t14-20020a05600c198e00b003eb2b790a40mr13176424wmq.20.1678228415951; Tue, 07 Mar 2023 14:33:35 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:35 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 09/11] dt-bindings: net: dsa: qca8k: add LEDs definition example Date: Tue, 7 Mar 2023 18:00:44 +0100 Message-Id: <20230307170046.28917-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143336_733029_70ECAD9F X-CRM114-Status: GOOD ( 13.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Tue Mar 7 17:00:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 744FEC678D5 for ; Tue, 7 Mar 2023 22:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2fbOWHiageHQLVnmE+eLvsu7EuXqPvfeKTp62fVlvQA=; b=2ULdX6ZL83Kwak idUzV0b/ojM6nTvMAm58f4E/p8hK1TQWImLxkS+DRNQQ+cJNTDh4SxDB0PXAmn/+4VN2Keol3cCFe siQbXqF4lpLtd4TrXGbFydQ56HyOd24cZdqYw75cCkJD8Ez+Anall/r5ySWBQw979EBgRizaT5dp0 DcgmJtLao5DQgXHB4H+TfqTVWYwWbAZLvYSr3lHyXJxts4E4Htu3GUTZIQ6R8j2tcY97osvtgsgWu qocvzWZAvP0Bzfvxxewq3k5nqYBVx08ysFENsTIVyobmWyPAqC8UxOaLCjloCFR2lEtDUDyHUl4rp x0L2V0jWwXLikK/IL/Gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZftb-002hWS-NS; Tue, 07 Mar 2023 22:34:59 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsH-002gmh-U2 for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:39 +0000 Received: by mail-wm1-x334.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so88827wmq.1 for ; Tue, 07 Mar 2023 14:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228417; 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=mgeBlw3VjdW/ldP+cajTBrUisBQA46tb0yJFn1SOwVk=; b=fitLZbSPSJM75E9+zI7CdJ7TUfah6PtmiyFM5bzoV6sl7dCbP274l7oarusXWlTqUY YEp9EXKKOzyQgmX7aZ0L4NpsrwPklYjGsiGedsZbvFz550iw9lBr3AfB7dY+xh39hKbu ke37ECxuqyxp5o6QeFFVbY7zdd7cSxVm55IhSiwRj0wihkDpLU2BrKReBA9YjZ6CwbyS SR9W5JElaNYn5JJ8X2U0yshj8b/nKSSnBmDdrcXlnb4JlsPnDTE235oqbxgVaCo6q/lz GYjB/I+uM/A8O+z1zdYKgrHiFPuu9MXCkANG3sqwrJ3ASstOL3rmaUOeMsFkeSNwXrw1 RjAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228417; 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=mgeBlw3VjdW/ldP+cajTBrUisBQA46tb0yJFn1SOwVk=; b=ISR6aWuTZB91zrdqV3rWzVRQWn+li9qFixkjafGs0rZkbFA3NA3S+2fCJ/rlPZEGSV pnbZRxEdbIrmtUWxDKIyjW7Js6ZxY1LgtIBTLLb1kzIbnMNWsaljXTZrx4P5/Pp7PDUU ZrQjgnDJfsvIqC4EVIGRxQ8JXgUBX20Qg/Iz8ZxYoAzH1hqcKY0bEmdAlThrusyltZBC 98hWsHwDuLyW7KLBSCLCZLScDx1D2ubwM2/gdnV5PMxRu3fIooDDx+Gei3IssDjBG8Le zjfeah+mLEHixOfiSoO3AyC6/eHS9K2BHHEFTdemDreNyZWv/JmLHxQ0auXfGhH9KTkZ bIXw== X-Gm-Message-State: AO0yUKW1wtqxgw/AGqkZZzJF/pB1ieJqqYirBZhbOY3lwXVXoaFzga1g kR0MlZWeVqlsz1f2mfv/CVZ9sovcdns= X-Google-Smtp-Source: AK7set+d0cJ+BvJcd//rk9RtVWY2LDBHuVBYbi3zKsAXhcdNZJ+R5K6OG0r3lX/vDFrVVxmJcPt5eA== X-Received: by 2002:a05:600c:4750:b0:3eb:395b:8b62 with SMTP id w16-20020a05600c475000b003eb395b8b62mr14710572wmo.39.1678228417182; Tue, 07 Mar 2023 14:33:37 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:36 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 10/11] dt-bindings: net: phy: Document support for LEDs node Date: Tue, 7 Mar 2023 18:00:45 +0100 Message-Id: <20230307170046.28917-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143338_010003_5F41F926 X-CRM114-Status: GOOD ( 13.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml index 1327b81f15a2..0ec8ef6b0d8a 100644 --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml @@ -197,6 +197,13 @@ properties: PHY's that have configurable TX internal delays. If this property is present then the PHY applies the TX delay. + leds: + type: object + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + required: - reg @@ -204,6 +211,8 @@ additionalProperties: true examples: - | + #include + ethernet { #address-cells = <1>; #size-cells = <0>; @@ -219,5 +228,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 Tue Mar 7 17:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0773C6FA99 for ; Tue, 7 Mar 2023 22:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QN2hky1R2kD2Yh8ATObBNR5lS+SG3LaRj8xfOHSHJVY=; b=MKRO5HXB2nSAG0 RV6HJ+j9pE/CkpMMFCrLaJjLebsj29mvX+cghT7/huwdnS1pml8syCi6bExlDKzTg/mrNlSEuVoKk sS8L5nR6fDxiCS4ALBK7K6+Bdd0048xthEnshOZ87h1Wdnxobs7480/h31NrBkWWhR71nYkXr4XeM yJMtPMmxXmxvgezvsF+V3lMCHbIHwTFOfSFAbyPhnWoxRScoLpnzn7s1+7UhmfnKORH556W8/Vepz +Hfcg64qASPg63HBLlZ+71s67M9o44dPQq60tG+0SNMkcrkjLxo+wLJiirev8FXz9dJBwOFfGUc1x /XZevuH9j1fc/TwKXZPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfu1-002hlt-Sc; Tue, 07 Mar 2023 22:35:26 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZftC-002hH7-Ow for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:34:36 +0000 Received: by mail-wm1-x32d.google.com with SMTP id d41-20020a05600c4c2900b003e9e066550fso84175wmp.4 for ; Tue, 07 Mar 2023 14:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228471; 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=bmWCwUNdPhKNN9p+nZQXhBFaHDLu+KgOmPb24fbdtT0mjRUG1KrEYzNhG67eD3YIMH /cwjoZaxdjSmPGdNDHV/Ty5YXutJ/Z6U0jwovIhA+QwS0TNDBbtc4dOulwXkQV/pMIWo BA9j6RNiSm+ZHaPe/YXNdki+nqv8nbR16iX7Z0Rv3u3wpA/T9AG/tCpyZDMwY21VaFbf phHxbG/u4fqzHz2CE/3+zZgmMr3qrJHV4w3CMd2two27XYe1aGM4wsVluuBhVx33WiI2 phMKoNiN6HSr/0H5lX5zB91Qup2Y/fubRWzJah0w65AXTTF4e+jB3hKE8Ly/72IYVXi7 zA1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228471; 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=yvEhid6Pd0wBMnyVjPtcPAADC4bm7ntBNuqEIIpKqrruCEk0A/D7fgp6ZAJjI5VS6S Ue0tWcRX3mIHhdUfboaZFnx/rpnVxFI8VuL4xLneuxS8feQzPpeEGeT/Hp16jwzkQQhN epKZY9lHztNQ9J6lsc5toPCJIPvylKRV5ZwE89suDMtpNTOZ7obplYeDpjDeeSVlCFBa vxYxfom8bjqQnGaVHHk4nE/JBMQPFjFCG2Xl9u0czRL5vDR9k0M9O17bo71VdPHMkD/M UkGl4N6qlViwx7JkT0b0MruPONnyIEOcF4nfu09wmL6hLiMTp5D9YgE7RqEiJcApb294 s1tg== X-Gm-Message-State: AO0yUKXBSJa/8BgotvWH4FzNGTx3nHZb9zgXWHpPQjaoc3rzI84CISuI 7ZoP3QY+njxCS/PP9yXhdho= X-Google-Smtp-Source: AK7set97ILq+tPtPnouKud8rXPxJOPNvTRK+NaUnkpwLzM9tqFszkITYpw1Y2fNyPsx/kSnTlPE3rw== X-Received: by 2002:a05:600c:5491:b0:3eb:5739:7591 with SMTP id iv17-20020a05600c549100b003eb57397591mr14801310wmb.23.1678228470804; Tue, 07 Mar 2023 14:34:30 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:34:30 -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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 11/11] arm: mvebu: dt: Add PHY LED support for 370-rd WAN port Date: Tue, 7 Mar 2023 18:00:46 +0100 Message-Id: <20230307170046.28917-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143434_861254_0EE0FD19 X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 {