From patchwork Sun Mar 19 19:18:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180536 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 F0B2AC6FD1F for ; Sun, 19 Mar 2023 19:19:46 +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=xEatw8NiAwRNMq8oXQSjVC04CQb8I2k+PgECquqt7bw=; b=fhLm8Fxot/SYsS Cbgyw5w3Z2q/opA/t5wrgX4QnR0cI33tBQwnMRbT11QPbRmTMJT6NbKaRhF68e1ZTPJKXJ8pIOmMJ c6CXpymGQy0wtcR/gc5GcsFb3lDwVD+d0zLB/gP2Wh49fvuNXzGITIHSHOhLrHIR6vtImMaGGpVeM TqNneKo5rSJoeneMJaukHvOMj/kKvI5PkdDzZYWUXcotRV/hr8vTnw2aDtFnni86seFOG3c4SRUVO UpghInH0uawSCvyaMjhrMR8ni0DW9kZW4+FreX3Dl8ORF8PxN4BmxQNwspISvKmRK90w0bNB3JxS0 PhCLElYIoGdAWXipIz8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYK-007Ec7-0J; Sun, 19 Mar 2023 19:18:48 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYA-007EYk-1b for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:39 +0000 Received: by mail-wr1-x42a.google.com with SMTP id v1so2417506wrv.1 for ; Sun, 19 Mar 2023 12:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253516; 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=GZlbVr+kRuncwwnT6LLkn+z1GbeVbbgNOpIQsx+kap4=; b=kGfhcZ29TV1AFihf/U0KwX6O19Vt2sziL8rPM/vaeQilQmSKIWRZAt2SLxmNjtmO7L i3zK9opWElQcVKvfzD01lD5m5uloElPA2CjfBqTlo6D12B8ABcueS1smdqHEWlLJIrDK e2J+kJIfunRuRasi791pEc//OKALLWO2VtHvgMvAz9dNuHKI6gf04uYtAdDehVqVoGS4 dvfZG6c+Rgk6VsGZ66BrTtJ+S2/kf8uOkAwwD61q9L8cI0Gbdg90qxIrJAE9kNqE6OSq XYT3YSrOtwVu77Xo0l0x7rNvfEnqjlpkKsnUBNM60C/doWjEhn5XFSaElP+GB7TisBtc xSTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253516; 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=GZlbVr+kRuncwwnT6LLkn+z1GbeVbbgNOpIQsx+kap4=; b=TcQj0BMPwDW1M3kZDQJtEfN4PHt9IktUmeoOUSPl0DaocW6iE6IaVaNSoKYiFUJ9bj wjzH3OIuklgxNbCzabeNB7CSOMPjMuqMUA+WQ16esMmOTvS0YWwm8lXhcayYw14uU1/M q/ezxS29HMxTp3PJpGbcGBi55GRKKfT13FJwNIO+C0cH07fxK8x1KSdBKGSWOxQvibz/ JD1Flb1ASE+RgOiTBHcT8mDtBw4F0+ddp1yRjSezOk/rBCHUOC9n2wIMVTO+xsRxTPWv dXTXJtFz3LWzO4TnWKbGaVP6fhL7znl+GkBB1j2PGc6cY52TzTeynKAHv84xAUb47F8F 9BhA== X-Gm-Message-State: AO0yUKU5hP2gRYTqLPfJntvtOaOqAS4d7xf/xLvXzB6YwnIckioapDS6 CGnBhPztRZf/9U37Rg3IZO8= X-Google-Smtp-Source: AK7set8ciMx8i3EllThIErYmn4MqYzNrnB1JWZ6MJqeJ2mbh9EnOe5oCp1IsfnAuKPvWQvcoD6976A== X-Received: by 2002:adf:f2ce:0:b0:2cf:f44e:45e1 with SMTP id d14-20020adff2ce000000b002cff44e45e1mr11248548wrp.19.1679253515935; Sun, 19 Mar 2023 12:18:35 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:35 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 01/15] net: dsa: qca8k: move qca8k_port_to_phy() to header Date: Sun, 19 Mar 2023 20:18:00 +0100 Message-Id: <20230319191814.22067-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121838_534239_3029BDC4 X-CRM114-Status: GOOD ( 14.30 ) 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 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 Reviewed-by: Michal Kubiak --- 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 55df4479ea30..459ea687444a 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -772,21 +772,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 7996975d29d3..dd7deb9095d3 100644 --- a/drivers/net/dsa/qca/qca8k.h +++ b/drivers/net/dsa/qca/qca8k.h @@ -421,6 +421,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 Sun Mar 19 19:18:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180540 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 A1FD5C6FD1F for ; Sun, 19 Mar 2023 19:19: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=XE2H0UKx12oJYLX09GDMwXlHsk0xyGuxhEJcQip5tmw=; b=2PADgOlYx4hndn 8A6NfwEMpevebCF3/m7n7NfZUsZ38I3Wgsm4B79nxQk7j/9b46dcYm7uf113gDusDxyyC9ecPC4AF dyyqtj2uOwBLkuKbvKM1w6ahN0JLdKi4kCmwiIPyGnD0xKqia3IkPJUCleZgPPdqDEjaYyewxd6wm df5jHoKBW0zMRT7rGRtscrPxAhgWrRlxH/azp2qKFCC9q+Y/9B9r3F2/EwBm4zaoLJoKN7DVuFWoQ 7e9Yf0nl/GWxKAHRbxp5L4ykmaf+ccb/aalrv1jZ9jhbW+ckaadZ5rtSl11M9X2D1yz3pCAzXrgGv JzNBe41LV8rf3hay2xsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYL-007EdE-0h; Sun, 19 Mar 2023 19:18:49 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYC-007EYz-0l for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:42 +0000 Received: by mail-wr1-x429.google.com with SMTP id l12so8513404wrm.10 for ; Sun, 19 Mar 2023 12:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253518; 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=7Nu2P3Pq7/oh5WjpvUK4sjLV7li65aeZcPpf8MEXPBY=; b=U1drIBMv6fhHbu4Id6wNUe1HOefGzni6YK/UB3ZTBHCxTRS4TauGcBKGlnXxMMoWor gqjhtncoa4irRLujx7rHPZOYxmgN7+nxW+WLRGqoB88BdlCLBb3EFiGnxyBOdcqrAHik WlXnt8FUQuvjy7doxBAyrarxXEpQXm2Uxq4VHhDPG2hcoLpMWtJDmsZSPTDqBQ0DcHwi omYEJNLMyhEb7An2ffMTiJ7TNdf9oXunc1im49tN1R0zVQvIpK88UILqxq+aNnAar0GU oAWh8Bky+CCUzwLp0mjJ8hinfLyrM3c3omoAn11EJhf7cYUu8m6pYK5GKUnbK2kTjdx7 dPdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253518; 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=7Nu2P3Pq7/oh5WjpvUK4sjLV7li65aeZcPpf8MEXPBY=; b=OsTO/sB3Ctc2JJ+5XZ8JTaspdUgIpF1ZUav+wrpmNMuCe9oiEt0mNtnoh++amZf9Xi PhmNZfTi0I6csdqC6udVSYb57gGeePK/EYv03/djCbxmUcHT7J6iq4uVVCRHU921j0Gx 2e459G8KpGvzKFCwCSqntoY3CWNVMm9RbRaGQpHL+7wmypIObsKT4nFdHZQgqQh4lQS7 iaVNzzPBARTMNsYXvFVoGmsmqSD0ClOJU3rUB2tfyoyQOTjrAmkR1+1Aj+t7A2KgID6j VUfc+UM+5P3JdkFUOfadgyfyMZrTg6mCLWJxFwTEOEaxPnQE2fQI6WJs6eZWwLzCrBEu VQvA== X-Gm-Message-State: AO0yUKV1FxFk7swlsqfl7MSBHM0cDZgPZ35OZhvhU39WzV+tuLDEZ7CU 0degYpMbbmll3GyBaXJag8Q= X-Google-Smtp-Source: AK7set/y2c0lnQqBo9sYMRlO7/XkhCPo5cuOasGa7AjedWMw9JyhJD/tyzXxkcAHfIFSdCt7XPFtfw== X-Received: by 2002:a05:6000:1008:b0:2c5:5349:22c1 with SMTP id a8-20020a056000100800b002c5534922c1mr7217249wrx.5.1679253517530; Sun, 19 Mar 2023 12:18:37 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:37 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 02/15] net: dsa: qca8k: add LEDs basic support Date: Sun, 19 Mar 2023 20:18:01 +0100 Message-Id: <20230319191814.22067-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121840_288212_E4379BE1 X-CRM114-Status: GOOD ( 34.87 ) 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() support. Since these LEDs refelect port status, the default label is set to ":port". DT binding should describe the color, function and number of the leds using standard LEDs api. These LEDs supports only blocking variant of the brightness_set() function since they can sleep during access of the switch leds to set the brightness. While at it add to the qca8k header file each mode defined by the Switch Documentation for future use. Signed-off-by: Christian Marangi --- drivers/net/dsa/qca/Kconfig | 8 ++ drivers/net/dsa/qca/Makefile | 3 + drivers/net/dsa/qca/qca8k-8xxx.c | 5 + drivers/net/dsa/qca/qca8k-leds.c | 232 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 60 ++++++++ drivers/net/dsa/qca/qca8k_leds.h | 16 +++ 6 files changed, 324 insertions(+) create mode 100644 drivers/net/dsa/qca/qca8k-leds.c create mode 100644 drivers/net/dsa/qca/qca8k_leds.h diff --git a/drivers/net/dsa/qca/Kconfig b/drivers/net/dsa/qca/Kconfig index ba339747362c..7a86d6d6a246 100644 --- a/drivers/net/dsa/qca/Kconfig +++ b/drivers/net/dsa/qca/Kconfig @@ -15,3 +15,11 @@ config NET_DSA_QCA8K help This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. + +config NET_DSA_QCA8K_LEDS_SUPPORT + bool "Qualcomm Atheros QCA8K Ethernet switch family LEDs support" + depends on NET_DSA_QCA8K + depends on LEDS_CLASS + help + This enabled support for LEDs present on the Qualcomm Atheros + QCA8K Ethernet switch chips. diff --git a/drivers/net/dsa/qca/Makefile b/drivers/net/dsa/qca/Makefile index 701f1d199e93..ce66b1984e5f 100644 --- a/drivers/net/dsa/qca/Makefile +++ b/drivers/net/dsa/qca/Makefile @@ -2,3 +2,6 @@ obj-$(CONFIG_NET_DSA_AR9331) += ar9331.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o qca8k-y += qca8k-common.o qca8k-8xxx.o +ifdef CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT +qca8k-y += qca8k-leds.o +endif diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c index 459ea687444a..76bffd6d8e23 100644 --- a/drivers/net/dsa/qca/qca8k-8xxx.c +++ b/drivers/net/dsa/qca/qca8k-8xxx.c @@ -22,6 +22,7 @@ #include #include "qca8k.h" +#include "qca8k_leds.h" static void qca8k_split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page) @@ -1783,6 +1784,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..5a29413ba94a --- /dev/null +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -0,0 +1,232 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +#include "qca8k.h" +#include "qca8k_leds.h" + +static int +qca8k_get_enable_led_reg(int port_num, int led_num, struct qca8k_led_pattern_en *reg_info) +{ + switch (port_num) { + case 0: + reg_info->reg = QCA8K_LED_CTRL_REG(led_num); + reg_info->shift = QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT; + break; + case 1: + case 2: + case 3: + /* Port 123 are controlled on a different reg */ + reg_info->reg = QCA8K_LED_CTRL3_REG; + 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_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + val = QCA8K_LED_ALWAYS_OFF; + if (brightness) + val = QCA8K_LED_ALWAYS_ON; + + /* HW regs to control brightness is special and port 1-2-3 + * are placed in a different reg. + * + * To control port 0 brightness: + * - the first 2 bit (1, 0) of: + * - QCA8K_LED_CTRL0_REG for led1 + * - QCA8K_LED_CTRL1_REG for led2 + * - QCA8K_LED_CTRL2_REG for led3 + * + * To control port 4: + * - the 2 bit (17, 16) of: + * - QCA8K_LED_CTRL0_REG for led1 + * - QCA8K_LED_CTRL1_REG for led2 + * - QCA8K_LED_CTRL2_REG for led3 + * + * To control port 1: + * - the 2 bit at (9, 8) of QCA8K_LED_CTRL3_REG are used for led1 + * - the 2 bit at (11, 10) of QCA8K_LED_CTRL3_REG are used for led2 + * - the 2 bit at (13, 12) of QCA8K_LED_CTRL3_REG are used for led3 + * + * To control port 2: + * - the 2 bit at (15, 14) of QCA8K_LED_CTRL3_REG are used for led1 + * - the 2 bit at (17, 16) of QCA8K_LED_CTRL3_REG are used for led2 + * - the 2 bit at (19, 18) of QCA8K_LED_CTRL3_REG are used for led3 + * + * To control port 3: + * - the 2 bit at (21, 20) of QCA8K_LED_CTRL3_REG are used for led1 + * - the 2 bit at (23, 22) of QCA8K_LED_CTRL3_REG are used for led2 + * - the 2 bit at (25, 24) of QCA8K_LED_CTRL3_REG are used for led3 + * + * To abstract this and have less code, we use the port and led numm + * to calculate the shift and the correct reg due to this problem of + * not having a 1:1 map of LED with the regs. + */ + if (led->port_num == 0 || led->port_num == 4) { + mask = QCA8K_LED_PATTERN_EN_MASK; + val <<= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + mask = QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + return regmap_update_bits(priv->regmap, reg_info.reg, + mask << reg_info.shift, + val << reg_info.shift); +} + +static int +qca8k_cled_brightness_set_blocking(struct led_classdev *ldev, + enum led_brightness brightness) +{ + struct qca8k_led *led = container_of(ldev, struct qca8k_led, cdev); + + return qca8k_led_brightness_set(led, brightness); +} + +static enum led_brightness +qca8k_led_brightness_get(struct qca8k_led *led) +{ + struct qca8k_led_pattern_en reg_info; + struct qca8k_priv *priv = led->priv; + u32 val; + int ret; + + qca8k_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + ret = regmap_read(priv->regmap, reg_info.reg, &val); + if (ret) + return 0; + + val >>= reg_info.shift; + + if (led->port_num == 0 || led->port_num == 4) { + val &= QCA8K_LED_PATTERN_EN_MASK; + val >>= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + val &= QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + /* Assume brightness ON only when the LED is set to always ON */ + return val == QCA8K_LED_ALWAYS_ON; +} + +static int +qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int port_num) +{ + struct fwnode_handle *led = NULL, *leds = NULL; + struct led_init_data init_data = { }; + enum led_default_state state; + struct qca8k_led *port_led; + int led_num, led_index; + int ret; + + leds = fwnode_get_named_child_node(port, "leds"); + if (!leds) { + dev_dbg(priv->dev, "No Leds node specified in device tree for port %d!\n", + port_num); + return 0; + } + + fwnode_for_each_child_node(leds, led) { + /* Reg represent the led number of the port. + * Each port can have at least 3 leds attached + * Commonly: + * 1. is gigabit led + * 2. is mbit led + * 3. additional status led + */ + if (fwnode_property_read_u32(led, "reg", &led_num)) + continue; + + if (led_num >= QCA8K_LED_PORT_COUNT) { + dev_warn(priv->dev, "Invalid LED reg %d defined for port %d", + led_num, port_num); + continue; + } + + led_index = QCA8K_LED_PORT_INDEX(port_num, led_num); + + port_led = &priv->ports_led[led_index]; + port_led->port_num = port_num; + port_led->led_num = led_num; + port_led->priv = priv; + + state = led_init_default_state_get(led); + switch (state) { + case LEDS_DEFSTATE_ON: + port_led->cdev.brightness = 1; + qca8k_led_brightness_set(port_led, 1); + break; + case LEDS_DEFSTATE_KEEP: + port_led->cdev.brightness = + qca8k_led_brightness_get(port_led); + break; + default: + port_led->cdev.brightness = 0; + qca8k_led_brightness_set(port_led, 0); + } + + port_led->cdev.max_brightness = 1; + port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + init_data.default_label = ":port"; + init_data.devicename = "qca8k"; + init_data.fwnode = led; + + ret = devm_led_classdev_register_ext(priv->dev, &port_led->cdev, &init_data); + if (ret) + dev_warn(priv->dev, "Failed to init LED %d for port %d", led_num, port_num); + } + + 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!"); + return 0; + } + + fwnode_for_each_child_node(ports, port) { + if (fwnode_property_read_u32(port, "reg", &port_num)) + continue; + + /* Skip checking for CPU port 0 and CPU port 6 as not supported */ + if (port_num == 0 || port_num == 6) + continue; + + /* Each port can have at most 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 dd7deb9095d3..c5cc8a172d65 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,51 @@ #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_PORT_COUNT 3 +#define QCA8K_LED_COUNT ((QCA8K_NUM_PORTS - QCA8K_NUM_CPU_PORTS) * QCA8K_LED_PORT_COUNT) +#define QCA8K_LED_RULE_COUNT 6 +#define QCA8K_LED_RULE_MAX 11 +#define QCA8K_LED_PORT_INDEX(_phy, _led) (((_phy) * QCA8K_LED_PORT_COUNT) + (_led)) + +#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 @@ -382,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; @@ -406,6 +465,7 @@ struct qca8k_priv { struct qca8k_pcs pcs_port_0; struct qca8k_pcs pcs_port_6; const struct qca8k_match_data *info; + struct qca8k_led ports_led[QCA8K_LED_COUNT]; }; struct qca8k_mib_desc { diff --git a/drivers/net/dsa/qca/qca8k_leds.h b/drivers/net/dsa/qca/qca8k_leds.h new file mode 100644 index 000000000000..ab367f05b173 --- /dev/null +++ b/drivers/net/dsa/qca/qca8k_leds.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __QCA8K_LEDS_H +#define __QCA8K_LEDS_H + +/* Leds Support function */ +#ifdef CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT +int qca8k_setup_led_ctrl(struct qca8k_priv *priv); +#else +static inline int qca8k_setup_led_ctrl(struct qca8k_priv *priv) +{ + return 0; +} +#endif + +#endif /* __QCA8K_LEDS_H */ From patchwork Sun Mar 19 19:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180541 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 926AFC6FD1F for ; Sun, 19 Mar 2023 19:19:52 +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=kr4tO2KD6NWpK0jgwcP87TzkZa5TIzhpiBieOaLMIPg=; b=TRK2WbxFUnuZ6/ 3igWI42A5FUs0JnqIjhNxN2cemRXIntIathPdsO/yFvCVFQXEpUogiGewge1AQ3GAvfg+KVsYrHpH Dxe1p7FRkbSkt7d0q38Wj7YZkUh7jW4J59woGCShbg96pcU33UBTOegQce/l6vEO6aMyNla6HdbjT qFcesX6a93zwKBr/wkjmKlvNIVBbM5dmXVq8ZiDZbHLqYcEKaYaY4kKuB+oX57QeqrQU3wZDdnHI4 KJ7Nu7KnTzAM7RvpiGShYuw9cfYLIHdTouSTQ5gU3Ac5Wfx2RKpUZskIBOvfqeuDqjMu3rVh9rq30 ErqfcEKsyeCWxgLxCEKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYM-007Ee3-1H; Sun, 19 Mar 2023 19:18:50 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYD-007EZP-27 for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:42 +0000 Received: by mail-wr1-x42f.google.com with SMTP id m2so8523625wrh.6 for ; Sun, 19 Mar 2023 12:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253519; 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=/fQAP8qao36Gp1ceTdiBEfkcCfyz+YfQuWedgI+BBH4=; b=R5aCMvKEnY1JXb3Bwxg3BhQLkx8pqC3K5PScNmGBJyUAqbUfNPQpPTrRJbjJB0U6Pr Pw5S5VmAv7WokWlVFdjFeYx8oSDMxOlKkOcMpUFDBmlgRtXllba8BHARazAgK/EwRpqZ 3wjIom5VY5+lLBs1S7jU19gQr989J2ofpHC/l0YoIGhRWtA0H2O9dKi0G6UDVDylI3CV btHMDg5D8ZXy2/+HR/sWfhiGvclGQoc7hkFVDoZ6LTVIQUy8ys88GJaE8+o8UqMIR/sA 3c7x5x5WQlb4AEuar1C7xop1+VaAhjL4aE/YJEji3Zn6vxrIWEm0K9b/uBuwqYPVxivP Tg1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253519; 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=/fQAP8qao36Gp1ceTdiBEfkcCfyz+YfQuWedgI+BBH4=; b=an0qyVLxSZ2uZlhvp32A9enhkhfLVMUpDkoHL8wq6bABVajIbWzoErHvyr0yMVivPP V13r8oRwriU0pt3FP9BxTzxk+/HRYaRghgGqXt3GuKgbAJsTf+gkKOcv0IDsKGuYOW9H KYhYVxZ2hieDIqKDgkpjM3gYq983bAcJZnLiaL6S4dIidnyoRe+9vYJXvKyXG2hVvt0R n0tdSl+KpI/e/hJkyMcVisUEezCDATIl6FX7X4Pj5jaYbmyMtg4gvg9ksgvxLZLisx69 gQVnQS7wq0uGa06DJztN/9t8BmaiuA+DQsHlMz+2VkSbIgDKRbqXMM1fgTNlUaZJFYIC fTwQ== X-Gm-Message-State: AO0yUKW5Wk37zuLWfpahy+azbMccLsylD0n1WOQM5aS6KGE3t4KSjSWx Qkatmn72XjFIX6uMIQkMA3Q= X-Google-Smtp-Source: AK7set9ZmcqMrTN/jVWeo4jlMpWW1C1z/Z/5d2YYYd08o3Om+n3rcd2impM/k4yBTXwuStrtbEmAuA== X-Received: by 2002:a05:6000:104c:b0:2d4:a2c5:9f80 with SMTP id c12-20020a056000104c00b002d4a2c59f80mr4021247wrx.23.1679253519007; Sun, 19 Mar 2023 12:18:39 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:38 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 03/15] net: dsa: qca8k: add LEDs blink_set() support Date: Sun, 19 Mar 2023 20:18:02 +0100 Message-Id: <20230319191814.22067-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121841_691465_84055406 X-CRM114-Status: GOOD ( 15.70 ) 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 Acked-by: Pavel Machek --- 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 5a29413ba94a..d0a37660faa2 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -127,6 +127,43 @@ qca8k_led_brightness_get(struct qca8k_led *led) return val == QCA8K_LED_ALWAYS_ON; } +static int +qca8k_cled_blink_set(struct led_classdev *ldev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct qca8k_led *led = container_of(ldev, struct qca8k_led, cdev); + u32 mask, val = QCA8K_LED_ALWAYS_BLINK_4HZ; + struct qca8k_led_pattern_en reg_info; + struct qca8k_priv *priv = led->priv; + + if (*delay_on == 0 && *delay_off == 0) { + *delay_on = 125; + *delay_off = 125; + } + + if (*delay_on != 125 || *delay_off != 125) { + /* The hardware only supports blinking at 4Hz. Fall back + * to software implementation in other cases. + */ + return -EINVAL; + } + + qca8k_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + if (led->port_num == 0 || led->port_num == 4) { + mask = QCA8K_LED_PATTERN_EN_MASK; + val <<= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + mask = QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + regmap_update_bits(priv->regmap, reg_info.reg, mask << reg_info.shift, + val << reg_info.shift); + + return 0; +} + static int qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int port_num) { @@ -185,6 +222,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p port_led->cdev.max_brightness = 1; port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + port_led->cdev.blink_set = qca8k_cled_blink_set; init_data.default_label = ":port"; init_data.devicename = "qca8k"; init_data.fwnode = led; From patchwork Sun Mar 19 19:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180537 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 A1E85C76196 for ; Sun, 19 Mar 2023 19:19:47 +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=5Atmxt3ceJ06qGcATWWf8Udpfr3e6XeWtQpJ6RTsrCo=; b=MHqjTWsshwqkyO dS0to2qAJpQ6AaMqhpNBRigFf65bsQHXuHFnLDt6BAjCNAJEEFtWmpwvkfuO/A10Nt2e6O9iu/mbS 9FWpnZ/UsxCeOS5KBc5inWmNZD1EP8sleL7+JmaYoJx/TpBouXZZSBa3EA2YwJUkRlXbdyaQa01Ui rdqAJWNQPtsQs/bfs9Mekf7Ret8/2KKCoQ63yaSWx5fHhXoCQd93WWapoHI+xScZFMzGi1AzIxKqd 2RKUGtiUa4cetRAxv5EZ+6gfsf0dUCmCvd/K37Ly63NZ49bjw1OhxNtjfUUm2Q/ZTFH5IJZ050El/ XE2RnWtp2LLl0aslQZHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYN-007Eew-2D; Sun, 19 Mar 2023 19:18:51 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYE-007EZl-3D for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:44 +0000 Received: by mail-wr1-x42e.google.com with SMTP id j2so8508793wrh.9 for ; Sun, 19 Mar 2023 12:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253520; 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=GonJ8ooxBIpDwINNR4y8inzQ1f1MzMkTJ7LjdzraRGU=; b=feSVwEzD7l9JYlCYA+zVM5K/7NBQzYbdCA0mwV7qYGCMZbmmsgMmp+oD9hkZND/9B+ KMCrsGuCRx1OE5ZElPdSxd4/YAFAkAv9Rr7cl2W8tgY0IpPgQiip6CRTZd23cKXi8jax zFS09SYUJuPOd0PUr5ZC5k2KPWeO+Md4ZwzYjMxGzbxPs4RlRXGfoJr7/iM0eHx1Oi49 eT7bR/n7MiDDp+DxtPLzU6FgwZWFjyfQV9M08QhsbXeSEJ88yBdfYxGmBz3+s4HlsoPJ Op4w8HmYC75Hnt+P0yu6d7cEwkwVp7CU8SAg+R/Q3DrHqFHESOaIKayUSh6qYLo0viFi 3RIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253520; 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=GonJ8ooxBIpDwINNR4y8inzQ1f1MzMkTJ7LjdzraRGU=; b=BRGX/Ws/REItPOr+B9iVpu9HBHD9dwjYXif0Wgmfzf4d1oDCusug8b86yWT+pC4K7w FRA1ctFHJ4uuyZklW6HK/QuUVOvQKJxUVz7W9Mz0VPWtPadxKgwLuLb63zW9bA8ao6+S BmrdTZb2YOZBgb/A05E7jJ5uyUUVZcBTdIfghWgUaBmUrjiyOT3R3V/6xC5Gj12pqc9K /nnTacWbDcz8DrF5emGRldiaK4uy2AcL52BQ193xtjYR4W28yduvtL+JwrlZcNzNDh0U tiZl9k90hqFkki/MagSOIkqKOdG8XZCifkawcznHz3lsA0aNprOOyjRiNwjqvCUJd5tf glLA== X-Gm-Message-State: AO0yUKWEAEBmTo40WzOh0qsFDNp4/vFss4ZRaArQaw+R7J53wSgdS1PU XM50lKgrU+6himtweMzxakg= X-Google-Smtp-Source: AK7set/qOxMnXBb6bHl21rmH3Hn6LUIeXznITjs5sepPn4279eZZHy92EBFNxNf20nKcTOgrvSwQyQ== X-Received: by 2002:a5d:5189:0:b0:2ce:9f13:a169 with SMTP id k9-20020a5d5189000000b002ce9f13a169mr12080664wrv.64.1679253520415; Sun, 19 Mar 2023 12:18:40 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:40 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 04/15] leds: Provide stubs for when CLASS_LED is disabled Date: Sun, 19 Mar 2023 20:18:03 +0100 Message-Id: <20230319191814.22067-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121843_033449_8B60B414 X-CRM114-Status: GOOD ( 13.51 ) 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 Provide stubs for devm_led_classdev_register_ext() and led_init_default_state_get() so that LED drivers embedded within other drivers such as PHYs and Ethernet switches still build when LEDS_CLASS is disabled. This also helps with Kconfig dependencies, which are somewhat hairy for phylib and mdio and only get worse when adding a dependency on LED_CLASS. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- include/linux/leds.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/leds.h b/include/linux/leds.h index d71201a968b6..f6dec57453da 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -82,7 +82,15 @@ struct led_init_data { bool devname_mandatory; }; +#if IS_ENABLED(CONFIG_LEDS_CLASS) enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode); +#else +static inline enum led_default_state +led_init_default_state_get(struct fwnode_handle *fwnode) +{ + return LEDS_DEFSTATE_OFF; +} +#endif struct led_hw_trigger_type { int dummy; @@ -217,9 +225,19 @@ static inline int led_classdev_register(struct device *parent, return led_classdev_register_ext(parent, led_cdev, NULL); } +#if IS_ENABLED(CONFIG_LEDS_CLASS) int devm_led_classdev_register_ext(struct device *parent, struct led_classdev *led_cdev, struct led_init_data *init_data); +#else +static inline int +devm_led_classdev_register_ext(struct device *parent, + struct led_classdev *led_cdev, + struct led_init_data *init_data) +{ + return 0; +} +#endif static inline int devm_led_classdev_register(struct device *parent, struct led_classdev *led_cdev) From patchwork Sun Mar 19 19:18:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180542 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 3670EC77B61 for ; Sun, 19 Mar 2023 19:19:55 +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=yw8iGPte+rOdlMxz74ZLzcS8tqbYWGzErLsyIR4oXYU=; b=kaoKQewMcLPgeR Rju3FMxsHHCcsYdDp9vIg9pce4mqpTPhrxf07et9xOvYs836Bplf9gCE+V95t1JLBUz+JZqotxKOj Q+PiWi/h8ntVkUHr9stPH6EoBovM+ZZaA546oqnogfaOmHNBs9lmVKJAGGUqFkhdU88ATHpG/Xk5I ryLm2iWUnGz7HuzpHWxP12B6AQ/Gh8+A7R0/6h5EJsi/5VU8Ogov6OkEPOTzDorIoB3IO+eXRvnP3 UYIdRjd8IKtMdqzA9Aa2HYBVoYyMzF2d7ks+HIKlYntWqEKcWq8RyS4GNaEUFdr3GJF8+dbQpJz+I wJQ15wBNHV68ANAxw/Sg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYP-007Eg0-0D; Sun, 19 Mar 2023 19:18:53 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYF-007Ea6-0g for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:44 +0000 Received: by mail-wr1-x42e.google.com with SMTP id l27so200797wrb.2 for ; Sun, 19 Mar 2023 12:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253522; 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=0MakyRcFEWBZQiWEXykX8ky94BsPvBnh7BhgiO6dB5k=; b=ktTQb++or6bxcgenSg9H3uoy0NKlIdMXs5VyshZ2T5aAYD4JsGyFowKAH6XptpbzDa 5mwPrtZByvjEQzuu1a0c/qe4LD0B1dGj6MUrT1vw0v37COG7s6NPM1bqXPCq3NA4V15i 5renmpPDNmI1nPnAJkpkwyLv+tMOxrh3yu26F75vWkt96xMbHYDVSznmXg/bPDBebhUA f0Giu6187l9uRPTizN57xJsBVcxqOoUAfwhGXu3iH6vH8N/q9BEVtw4fMK23T8XPnbzc GVQWILvN8dllu33YCISqbqYeroLHCFSkrUTHcnnd/H8779a9lvqkSIwJOQa7i5QaVKsp RjMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253522; 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=0MakyRcFEWBZQiWEXykX8ky94BsPvBnh7BhgiO6dB5k=; b=4uJ67W+X10Co6A6sVOSEsmwNwDz/QGFraQtBZH+gsn9gFklhyIMl3Ecbe+bGZ4TRMm O6DcsrUxrJeVn6kRcgNW2mE1ZrhKp92ChZxVGOegw7gv7JkLTcWSxc/JIOXbRNIBvqtc ThZTe6KwExAavYVVDvu8RPOQZPci8nLMSTe9eParKuoIE1IMSO0b2gSwSNKAesaPvuUr nQy0CsLwamFbaJrZSiatAUkp4H2Z5lR8zdsrAc10tNkkZjDyNKvtfch///4ylpNHzitF wNhkPRFRswN+w7MTGcHK+/lPlHWrSeiaS8qzUUaZ5D0C37CKL9/juP1VtCyLtSK/1bhQ Aqtg== X-Gm-Message-State: AO0yUKXT/2uFBjo67zzmQsA6p9pKqk6xmrX9pwkRJOojeHqPOrMPDbuz +qXTO9RxXBxH3xHfF/zZz6Y= X-Google-Smtp-Source: AK7set9O+5bZt+xpJcOS4iWaiI2yqHiSnmVceICpt6EYRYsrCRnjbAf1C8+cyOagjusjvV1c1sB2eg== X-Received: by 2002:a5d:6511:0:b0:2d1:6104:76ab with SMTP id x17-20020a5d6511000000b002d1610476abmr9730929wru.2.1679253521860; Sun, 19 Mar 2023 12:18:41 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:41 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 05/15] net: phy: Add a binding for PHY LEDs Date: Sun, 19 Mar 2023 20:18:04 +0100 Message-Id: <20230319191814.22067-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121843_262216_3F4C804F X-CRM114-Status: GOOD ( 23.85 ) 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 Signed-off-by: Christian Marangi Reviewed-by: Michal Kubiak --- drivers/net/phy/phy_device.c | 75 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 16 ++++++++ 2 files changed, 91 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index c0760cbf534b..39af989947f9 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 @@ -674,6 +676,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, device_initialize(&mdiodev->dev); dev->state = PHY_DOWN; + INIT_LIST_HEAD(&dev->leds); mutex_init(&dev->lock); INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); @@ -2988,6 +2991,73 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv) return phydrv->config_intr && phydrv->handle_interrupt; } +/* Dummy implementation until calls into PHY driver are added */ +static int phy_led_set_brightness(struct led_classdev *led_cdev, + enum led_brightness value) +{ + return 0; +} + +static int of_phy_led(struct phy_device *phydev, + struct device_node *led) +{ + struct device *dev = &phydev->mdio.dev; + struct led_init_data init_data = {}; + struct led_classdev *cdev; + struct phy_led *phyled; + int err; + + phyled = devm_kzalloc(dev, sizeof(*phyled), GFP_KERNEL); + if (!phyled) + return -ENOMEM; + + cdev = &phyled->led_cdev; + + err = of_property_read_u32(led, "reg", &phyled->index); + if (err) + return err; + + cdev->brightness_set_blocking = phy_led_set_brightness; + cdev->max_brightness = 1; + init_data.devicename = dev_name(&phydev->mdio.dev); + init_data.fwnode = of_fwnode_handle(led); + + err = devm_led_classdev_register_ext(dev, cdev, &init_data); + if (err) + return err; + + list_add(&phyled->list, &phydev->leds); + + return 0; +} + +static int of_phy_leds(struct phy_device *phydev) +{ + struct device_node *node = phydev->mdio.dev.of_node; + struct device_node *leds, *led; + int err; + + if (!IS_ENABLED(CONFIG_OF_MDIO)) + return 0; + + if (!node) + return 0; + + leds = of_get_child_by_name(node, "leds"); + if (!leds) + return 0; + + for_each_available_child_of_node(leds, led) { + err = of_phy_led(phydev, led); + if (err) { + of_node_put(led); + return err; + } + } + + return 0; +} + /** * fwnode_mdio_find_device - Given a fwnode, find the mdio_device * @fwnode: pointer to the mdio_device's fwnode @@ -3183,6 +3253,11 @@ static int phy_probe(struct device *dev) /* Set the state to READY by default */ phydev->state = PHY_READY; + /* Get the LEDs from the device tree, and instantiate standard + * LEDs for them. + */ + err = of_phy_leds(phydev); + out: /* Re-assert the reset signal on error */ if (err) diff --git a/include/linux/phy.h b/include/linux/phy.h index fefd5091bc24..11fb76a1c507 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -600,6 +601,7 @@ struct macsec_ops; * @phy_num_led_triggers: Number of triggers in @phy_led_triggers * @led_link_trigger: LED trigger for link up/down * @last_triggered: last LED trigger for link speed + * @leds: list of PHY LED structures * @master_slave_set: User requested master/slave configuration * @master_slave_get: Current master/slave advertisement * @master_slave_state: Current master/slave configuration @@ -699,6 +701,7 @@ struct phy_device { struct phy_led_trigger *led_link_trigger; #endif + struct list_head leds; /* * Interrupt number for this PHY @@ -834,6 +837,19 @@ struct phy_plca_status { bool pst; }; +/** + * struct phy_led: An LED driven by the PHY + * + * @list: List of LEDs + * @led_cdev: Standard LED class structure + * @index: Number of the LED + */ +struct phy_led { + struct list_head list; + struct led_classdev led_cdev; + u32 index; +}; + /** * struct phy_driver - Driver structure for a particular PHY type * From patchwork Sun Mar 19 19:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180538 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 9B5A4C7618A for ; Sun, 19 Mar 2023 19:19:47 +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=buiN1QSFbAxxtR2zpFuKJbqmi/f+X3lxCX6uFPKfBnM=; b=tOBTGkeJ4Zxl0F LDxKOgvel2px3mGzXbGhG9UObGKLYyKxZUyD2WzHCAUxfi43RxliG2Uvb8h34o1WUqACKkStlevop TjdrzABe7hCGYhQyGegL+TrJBXRgPlAGXAQ+baaDGK96oJJg04CBq59zazLemy7y5A7vRAZHOxEKQ zXIVprqi2KI5IsvlEMjOfLenN1kMxylSQHrcGQO1CQkny973XFtQZKKQR9f9pThIkAKwvQX0lR1bI C0Frbpsnc/AwRZq/fmeQaG6Lj7eCLzMftWRLfF+HHkfr7HY1vorE3HSSu4bsvGyHqJQ2aiOLCApfl cRZt/YCQ+/XtwiOp4zhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYQ-007Ego-0w; Sun, 19 Mar 2023 19:18:54 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYF-007EZP-2d for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:45 +0000 Received: by mail-wr1-x42f.google.com with SMTP id m2so8523706wrh.6 for ; Sun, 19 Mar 2023 12:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253523; 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=NCx6caR6IZgTqSPdn2HwL+62wmCa1NHNRk8GEDmxS/c=; b=MMxVlZBgzFIcfZOHEwBaQwsI4ky4mTC9a0gj8/TxWSMHVPI9j3Qak2ZLUGvgfSX7Mx Dmr4mHC3hGAvUYAvivjDzt9B4vwWBvnm1ntuGwATuvl2skEjDKX07ttVZCwblzkZrLay OsWlINOoYzymwsYKwyVCbvD/e5P6jBddf6lG4RvBT2fMNMFNLIRYvDfRYCwNbsoOMfWo M/yIzvOJqBWvzngpzBIXELOwq2Ad9F4u+Q1yGDHsyRa1LLdFLE7Jgir4QQTjbSFCo8Qe Osk1yMdVUQYgrW0hnxCkWdK02K9GILrsgyKx1Ctl0tsmkEzRHAFYl9lDRC4IDB6h9vLR 7GvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253523; 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=NCx6caR6IZgTqSPdn2HwL+62wmCa1NHNRk8GEDmxS/c=; b=AnCcTJ5Bv/CwJt+b7Bk9aaVEChl5836jLR/jrqdySQpHEpqRkdThHqpt2bH5kjKIKm Xc601eRvO6TkB4hRDI4RlrzfQSxcNlUX0l6v4Hd/145NATe54fqZPHbNw2HysnIx0qj8 o7iM/czPn/xY0NQQkgn49AIRrOJyzcbM5D0IpU6vpGJSZ2+FEkeYZ2RKi1x0uVF6dUjB TmnVNb+SIj9Erp2UljUm+j9r+eHSeC3rVvkmzVdyezQU9RruR+SRsxOGkQwxJRIAgRjT bSSu0L5CKkCbA0yooOnlHkDZuIuXMXFydwH7Oud3WTyUwKSJkl86LQY3EvSP/tDD7OcY bofQ== X-Gm-Message-State: AO0yUKXNLmlk9MWiS7Kzej0tkS5VOoSgbRL9R7Afqw4PuQSGQQr5FqSJ Vo7del9Pfhb0OLyHuzO5qQk= X-Google-Smtp-Source: AK7set8fsq6zQlxjf9ZFshDSZySkAXi7AJNk/hdFefpQPp7yImbuKtjN2QnYSs99mmKQyNUyTYQYuw== X-Received: by 2002:adf:de90:0:b0:2ce:aed4:7f22 with SMTP id w16-20020adfde90000000b002ceaed47f22mr12428360wrl.50.1679253523176; Sun, 19 Mar 2023 12:18:43 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:42 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 06/15] net: phy: phy_device: Call into the PHY driver to set LED brightness Date: Sun, 19 Mar 2023 20:18:05 +0100 Message-Id: <20230319191814.22067-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121843_866282_B072FCF5 X-CRM114-Status: GOOD ( 19.34 ) 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 Signed-off-by: Christian Marangi Reviewed-by: Michal Kubiak --- drivers/net/phy/phy_device.c | 15 ++++++++++++--- include/linux/phy.h | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 39af989947f9..141d63ef3897 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2991,11 +2991,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, @@ -3012,12 +3019,14 @@ static int of_phy_led(struct phy_device *phydev, return -ENOMEM; cdev = &phyled->led_cdev; + phyled->phydev = phydev; err = of_property_read_u32(led, "reg", &phyled->index); if (err) return err; - cdev->brightness_set_blocking = phy_led_set_brightness; + if (phydev->drv->led_brightness_set) + cdev->brightness_set_blocking = phy_led_set_brightness; cdev->max_brightness = 1; init_data.devicename = dev_name(&phydev->mdio.dev); init_data.fwnode = of_fwnode_handle(led); diff --git a/include/linux/phy.h b/include/linux/phy.h index 11fb76a1c507..2a5ee66b79b0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -841,15 +841,19 @@ struct phy_plca_status { * struct phy_led: An LED driven by the PHY * * @list: List of LEDs + * @phydev: PHY this LED is attached to * @led_cdev: Standard LED class structure * @index: Number of the LED */ struct phy_led { struct list_head list; + struct phy_device *phydev; struct led_classdev led_cdev; u32 index; }; +#define to_phy_led(d) container_of(d, struct phy_led, led_cdev) + /** * struct phy_driver - Driver structure for a particular PHY type * @@ -1072,6 +1076,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 Sun Mar 19 19:18:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180543 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 A7EB5C761A6 for ; Sun, 19 Mar 2023 19:20:27 +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=OGTSFN55MlzMnuzHv5hMbO9V+MFXIjjPZAFMeG3EmKw=; b=O9kRB6oUyAqbCl vdgQzPVwfdwGk7PuJCV5c2vwqeD2d0vCsQSuIHSHHbtZiDxDUOAX8yGBHPIhqxGbc3RwXtp1bO8/p EXKGh85P0H/drY/hOM1duo39ZYgrFLF5y2wcj1lG9SoWMUftpOiyrgQo4jscxwfDTsxDiTzwGVVFd Oizk3jJlz2ox6uAhGOLud/YWWFNYkpektz1BhUsSD7AzxUMGvhi07xExrIpyXaRZXP0hQagDBRBCe 3e+CEAhyDpCCHpzn4mP3YjqUFPrH/q3Q1E3QC/oknmDn1PxbhpmgYYPaU1UYwNy56Ktxfhj9ILuMS Qjo4bhGoaEaaC/xoENjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYv-007EwP-18; Sun, 19 Mar 2023 19:19:25 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYI-007EbI-1s for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:47 +0000 Received: by mail-wr1-x431.google.com with SMTP id r29so8501907wra.13 for ; Sun, 19 Mar 2023 12:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253524; 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=I03i0AWrulDKLnS6IGJCsuyb6CMg/g/eSeO6qoSzm0E=; b=m2G6fqst6xNiEiWCS+uBgPjPLL1mSZwnuXjYkWZ+i4KjUKWHPyYGicNWHls/kU2p5i IB8CX22kumFv8A3gW5TYAWTBJXZou6UoZo2Sa6daICCqwon5sPEjRBGL7FSnLHSNH4gX +wkRf2H0cF1ld5KF8WsyMSd0DciD4JOMwGWoIwwN91BC8nDEFNYMxLwLAZ0mK8b26Dyw w/o1BncYp8LXeOA1EalPvv+NbSLF15LcGfwhfhAixJ1vtDbNWciXVAWIdTdrj0jrT8q2 plXuFNucGlDkfTzXup/fZphh2UIQt20glN2XbGr7RZCv4wxE1odZ5+F+y13ZXKguDRET GZzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253524; 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=I03i0AWrulDKLnS6IGJCsuyb6CMg/g/eSeO6qoSzm0E=; b=oW5uFlEh8eSCcoGUV6/O+K7TBaDFgKq9v6EmTIIvVeLK1/jnwyIE6P6BwwuKvqOgPv 2JFBYB3FWgBhaLBWRbU2NsSkFTBXnSym27tFc81RMNSl9J1xzZ09hufdB6H4PFR1tjCY zBWwJnEXRGGcizPUP9Hws1brxWuvQhWlsASK6n6KQHpQSRdKR2PNBMAyqZYuwrhh9FwW WohjNGpilVJphsffxaz1Bez4rBwXzT81YsbwG9FtrsW/GK3+nujgbIfHiuNTBNZ9r/KO yeUOfo6NMrpqslIdGsed6gLSCab+n1MJwM1UsBW3mf3UEJQrdVAZSQgdxcXR4QfadiHE uaDw== X-Gm-Message-State: AO0yUKVOMHQ6vxOvnLNX3g0FIxG/gyFj5mFv1EXnn3rfIDuZSginHpV8 EQW09o12ECbUIeDTKcFepCE= X-Google-Smtp-Source: AK7set+Zc1D46FmhuQEgMV/0yTk7Po5rFjwesYeQfwuSoEnvmhgc4qCt8ECWJMZYoD9A987DXITjJw== X-Received: by 2002:adf:fbc8:0:b0:2d6:cc82:3c49 with SMTP id d8-20020adffbc8000000b002d6cc823c49mr1042691wrs.13.1679253524565; Sun, 19 Mar 2023 12:18:44 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:44 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 07/15] net: phy: marvell: Add software control of the LEDs Date: Sun, 19 Mar 2023 20:18:06 +0100 Message-Id: <20230319191814.22067-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121846_623495_B7FE3A4D X-CRM114-Status: GOOD ( 16.65 ) 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 Signed-off-by: Christian Marangi Acked-by: Pavel Machek --- 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 63a3644d86c9..5f4caca93983 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -144,11 +144,13 @@ /* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) -/* LED Timer Control Register */ -#define MII_88E1318S_PHY_LED_TCR 0x12 -#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) -#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) -#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) +#define MII_88E1318S_PHY_LED_FUNC 0x10 +#define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) +#define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_TCR 0x12 +#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) +#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) +#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) /* Magic Packet MAC address registers */ #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17 @@ -2832,6 +2834,34 @@ static int marvell_hwmon_probe(struct phy_device *phydev) } #endif +static int m88e1318_led_brightness_set(struct phy_device *phydev, + u32 index, enum led_brightness value) +{ + int reg; + + reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC); + if (reg < 0) + return reg; + + switch (index) { + case 0: + case 1: + case 2: + reg &= ~(0xf << (4 * index)); + if (value == LED_OFF) + reg |= MII_88E1318S_PHY_LED_FUNC_OFF << (4 * index); + else + reg |= MII_88E1318S_PHY_LED_FUNC_ON << (4 * index); + break; + default: + return -EINVAL; + } + + return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC, reg); +} + static int marvell_probe(struct phy_device *phydev) { struct marvell_priv *priv; @@ -3081,6 +3111,7 @@ static struct phy_driver marvell_drivers[] = { .get_sset_count = marvell_get_sset_count, .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1145, @@ -3187,6 +3218,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1540, @@ -3213,6 +3245,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1545, @@ -3239,6 +3272,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E3016, @@ -3380,6 +3414,7 @@ static struct phy_driver marvell_drivers[] = { .get_stats = marvell_get_stats, .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, + .led_brightness_set = m88e1318_led_brightness_set, }, }; From patchwork Sun Mar 19 19:18:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180544 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 EC353C7618A for ; Sun, 19 Mar 2023 19:20:30 +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=+Ytw3ldVSV5JbR0Pj/9xwnynID7utZOOreMX8A5k8WI=; b=wfdK35VG/6kXFE q1M0K4qjopx1bdrR3JzpNBkX3I++1lf8Q8jhVFYFnzW88H+6TucOo05fVeGcujpMecLeO4th7s/ya xlrfiTyVr+lPU0pb0ahgEeo0AG+tWyVcUSQYIeH8qJbrIfsxBHdpkxJU6VQXdfo95cHNE6ay6cm3+ CWH3VmisTBJR0e9Nd5lFcujvGWZnUNKkerzJ5emT7mKQnR5fKbSpTEwoFYMwX3rO1uh05Vf1AX7Qr 2Ib2Jf2V2gjVlLd+TIQg5oF+rdrqTQ3OQl1gC00eU/FA921aaiiBR6wKXkrmcmKfu1oi22sfuZMpE ESbeBtE9kW96roxB7eNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYy-007Exo-0A; Sun, 19 Mar 2023 19:19:28 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYJ-007EbS-0p for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:48 +0000 Received: by mail-wr1-x431.google.com with SMTP id h17so8511447wrt.8 for ; Sun, 19 Mar 2023 12:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253526; 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=ezsnOVpve2+kzTAIvtEvXAR8w742axG9ioJbZmh2wbA=; b=LMbQRhbVQBp13CYGQy9BpUeGJX9d2zPyAyz1L8QWqGqPeHvggoSEo29h5e75Mai5Ru SpX5PtmdoEa55ZkutLVBv0PMtQmAE00Gvn0AbcWGiwfo6fQxgpR2L+Cp3wFxo+pSXwOo A9Iq9g7taZHCLMCBV5ayWuUZU3kB5eQs/Ysk532BdStC//+oi2R6e0a9X8x4NaWlSgX7 cqIZkQmWwLtPU75jHclkspOv21xnRaeA2UYw8ydbS+J3IbV28VWNgMwU/XclCExX5Esf SQkC534aHw9ftO8BJGERz2cxQMrZrnEsux58jk1v8AZFm1MvzjieRk9ytEDqUNpiXigx tV5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253526; 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=ezsnOVpve2+kzTAIvtEvXAR8w742axG9ioJbZmh2wbA=; b=3vmcYeCrZh4Onxpm4zfHbQYYuAoH7i+T6MhO8onzEsm92cZvsK0N7abbHcKBX8P24+ KlNA9euYz/LosfFiUb30s5lOQCLjcmyGiywpqVPP/MEmDhtSWg7aZLhlacdJo7nPe6Xg tx+6SYLoDY9E69vPRcB7TWH4koNzXIrQxucczyczJ0F8Aeu3XwTHRZqr14ZELhzucsUp N7qU7ZbOeLYl1BnYs+2DSUf+9U4Ck0VqTNbJWDiOxPcUWwLa0zW9sV26nSvGdycmgewn rbH6AismjkEPrF1WZXqZwHruGofVHBamoxf+SsCIgvSgI17nAjHq7jIQU7VkQ4U1WVQj dUeA== X-Gm-Message-State: AO0yUKWQyOPkdWs29ncsWxufcU4sxhrSfQejl8TKAni+ADDf9xA4mczq jsbP8MBcsLwtILpqtoDA/BM= X-Google-Smtp-Source: AK7set8CkczEyFzQp8MJp8UlLnRzJgsh6ijwYsaY84PB1rYCQHpfOS6wwImft3lDUdZfZOaEyc+lYg== X-Received: by 2002:a5d:4381:0:b0:2ce:a8e2:f89e with SMTP id i1-20020a5d4381000000b002cea8e2f89emr10826621wrq.46.1679253525922; Sun, 19 Mar 2023 12:18:45 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:45 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 08/15] net: phy: phy_device: Call into the PHY driver to set LED blinking Date: Sun, 19 Mar 2023 20:18:07 +0100 Message-Id: <20230319191814.22067-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121847_309868_58DE5F76 X-CRM114-Status: GOOD ( 17.37 ) 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 Signed-off-by: Christian Marangi Reviewed-by: Pavel Machek --- 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 141d63ef3897..79a52dc3c50a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3005,6 +3005,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) { @@ -3027,6 +3043,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 2a5ee66b79b0..cad757d55ec9 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1083,6 +1083,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 Sun Mar 19 19:18:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180547 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 E9D96C76195 for ; Sun, 19 Mar 2023 19:20: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=xnYRFCva+F0ZfYqj34vKJoMyGTbtZVIWAbUczHVF+oI=; b=3p04OMYptWNoEb O0PhTEpYKPaOjiM+tsTU7Nvfpx72+FrtNrUp4KBJ8m886A0mNEYsQ3NyD8IHggqsC6LEGut+3QSXw 39YmEH+qR7/8qXktdKTfBY3HyYmqbN+FdCoYqoxsOxE/JEFjigjDAoobdYxnrATuJjaytEj0z03pT 2rprFjUby8MDCq6pb/c/oE1K9OKLrOIKsscxTji+jFuoT6YuylKbGVyJf0OlCCWw/XzGLfRuxCJN4 2Zyyqzh4VEXxvALaSCH94H34Nwb1ymHTn20o9iLo0ZrdcdSKV8FqWqU+9UpE6fpyufKy0Tc/AjCj8 L55LDDKsDKo6oD/s/78g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZ4-007F2q-1b; Sun, 19 Mar 2023 19:19:34 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYL-007EcA-2k for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:51 +0000 Received: by mail-wr1-x435.google.com with SMTP id t15so8515919wrz.7 for ; Sun, 19 Mar 2023 12:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253527; 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=sFDnakGrHwc9YezMrBpj3kUh14Ewx9Mr1i8Y8CEIfEg=; b=Y8L+jOt4zV+0JKKDKR40z03wZRfUuaGzlyvhdbtYRcFk6OVRZBDGmbCto3lbxTB6rC UewSv/njrZ3zdBt8qOjV/U+kA6nOR/8mcTcm8Q9AMvKNtjwfZkXjp9gaUIOvFB5IT3eq j+wi7nu3I98FsuQYXwfCAxwU2Cq6t3kRGNdi5d/9iOKxCMdDvdSaWMLcCjyYOF3Rkxg8 77qMHMXb5eS5hB6MmI18j2By4784xuYWEg4QIshPFEWsY/RoQ9unzr7Gyp7oUuQNYQHD S9KGWlgsRvWHLM5HQjW4I9R4PkaV0MRi/RrA35jfJl9XVhNCzsCiUzPhlwdFaK3F/80n Gv3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253527; 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=sFDnakGrHwc9YezMrBpj3kUh14Ewx9Mr1i8Y8CEIfEg=; b=3E+rw23Xd7UWnSxQRFC1+ITN2AVU1zQf8n9MIhnxxNpPU2uyBFcLPEpNlCgyqXq+rW i5JZYJPYQXa2OB/zDdf2qJLTpyGZg9cBLpQ1rxWti1yKGIUkS9xA8DwtA6vEfQBBlIHs eD2Frf2NjahECNYqnsYDa9TGuB4yUuqlMZ336s7117O385dYjfDHrkD75QychInEIFhp EOPIGkVthQ6s9dS/KlVVI7Zk47DDi8YM+AHvUJrnQTAmMnSVsbXIDWuyOhrCXWEgX11s mWY7IBv8MpzyMauR9hWY1K+JcXFL+aStLCCPnZDS1OtCTg3SN5IokKo+j6GAgZfAoopw S6EA== X-Gm-Message-State: AO0yUKUJpuCSnmzeSPPx7pg6IOenrDwWRuOYHNHesjagKJBNuZTTit5G YGKevyh9eWgQnIBO+XmUdrE= X-Google-Smtp-Source: AK7set8xZ8lyD/9/85wUOIGIe+7bOT05rW6mUFgZpNojuichjGSuN7KLJfE+GsEviAdWrdpYML6bNQ== X-Received: by 2002:a5d:4a4c:0:b0:2d0:cf21:a40e with SMTP id v12-20020a5d4a4c000000b002d0cf21a40emr11562615wrs.30.1679253527330; Sun, 19 Mar 2023 12:18:47 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:47 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 09/15] net: phy: marvell: Implement led_blink_set() Date: Sun, 19 Mar 2023 20:18:08 +0100 Message-Id: <20230319191814.22067-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121849_891364_0D5D11A9 X-CRM114-Status: GOOD ( 16.36 ) 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 Signed-off-by: Christian Marangi Reviewed-by: Pavel Machek --- 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 5f4caca93983..c00f67f229f5 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -147,6 +147,8 @@ #define MII_88E1318S_PHY_LED_FUNC 0x10 #define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) #define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_FUNC_HI_Z (0xa) +#define MII_88E1318S_PHY_LED_FUNC_BLINK (0xb) #define MII_88E1318S_PHY_LED_TCR 0x12 #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) @@ -2862,6 +2864,35 @@ static int m88e1318_led_brightness_set(struct phy_device *phydev, MII_88E1318S_PHY_LED_FUNC, reg); } +static int m88e1318_led_blink_set(struct phy_device *phydev, u32 index, + unsigned long *delay_on, + unsigned long *delay_off) +{ + int reg; + + reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC); + if (reg < 0) + return reg; + + switch (index) { + case 0: + case 1: + case 2: + reg &= ~(0xf << (4 * index)); + reg |= MII_88E1318S_PHY_LED_FUNC_BLINK << (4 * index); + /* Reset default is 84ms */ + *delay_on = 84 / 2; + *delay_off = 84 / 2; + break; + default: + return -EINVAL; + } + + return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC, reg); +} + static int marvell_probe(struct phy_device *phydev) { struct marvell_priv *priv; @@ -3112,6 +3143,7 @@ static struct phy_driver marvell_drivers[] = { .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1145, @@ -3219,6 +3251,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1540, @@ -3246,6 +3279,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1545, @@ -3273,6 +3307,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E3016, @@ -3415,6 +3450,7 @@ static struct phy_driver marvell_drivers[] = { .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, }; From patchwork Sun Mar 19 19:18:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180545 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 504C3C7618A for ; Sun, 19 Mar 2023 19:20:34 +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=FXIqBhHfiZfEO92kzmxtSxG54OaekedPBBovGufAJXQ=; b=KeHOB0sPnSKYpN D6uCPthvI8JUFQ0ViCK6mW6SYvvl3CXM+TCbw0BYsiLyi4SCMi26+UFlx9lIvkI4gyzyB2sDPbnvq jbfaI+Hz/6F67SnkhsQ79ty2E+R5pRi0Mqr6kZJAn+bFQ1ik1kmnZKAqkciC7czPqVZxMKIZPxef4 1MJUIoShenb0YvBzJcKr7C7+dCkh0ZDtiCfEvdHkzc3odZ7FgnZAViiP2hgrWsaU8/19y2Xouvhxv 78nrO9wJpAlBkleMIeIp0SAnQkfvxrhchSc27l/lDMqTdnU2ytG99Wset+BBBEww+Jy2YuBk5onu/ 2tBOxaaIh/X13oxgWQIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZ1-007F0L-2C; Sun, 19 Mar 2023 19:19:31 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYL-007EZl-1S for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:50 +0000 Received: by mail-wr1-x42e.google.com with SMTP id j2so8508980wrh.9 for ; Sun, 19 Mar 2023 12:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mZv5FnCiudZKDVGAnq53ZSH02fIH+isgRk91M2T3n+E=; b=PQ9TvN/Z+J6tBc9SVmvrVyMVKxr14rqIr+WZCNIqp4FMAgO+aHt/E+eieG2kqZ3ZZZ 3l/hHKAmrcOpCyIoGf4d7AuZTce+GKMQH9GMzRKXfX5wlnTWKbhuy/w5DRZAlJzl3mcs 2bwc8cjqIq1cpyJzJfETO45WMp6xo0AjXpQdOxcL4f2SGP3YBtOvd2T/duTrwZq+Cq6E vK7174vdHd0cp5NCPOPVItVRDxr8eKA72h4cc5rY7zv3+4jl9SKbS3E7WG3YgU5gLM8r sOuu+RlWU/9fKa6lxeQUff2eyAjtfOZShDY2MWNYubaC63tHHFCwpByd/ZhxY7I1yWJ5 m/ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mZv5FnCiudZKDVGAnq53ZSH02fIH+isgRk91M2T3n+E=; b=SOonuhs9jKbmUqYM65ncsI3ihl/eb31UC1t09LSj7wWFDS4butTU69ZTWBvkU//Qlc dwMtAW4RF5CLQF/F6yRHymECkHloqRwAuDRBlcmEzk4Av3aGI9oH1O1hpHQJWpxxzAPX XcbDTkEVg92xzP2Eh0gq4Je7s9A76N/j5TMJN+ZXCKt8EOpqw79N7PP+fWJDJiA0EXU0 fVFUD5+RVEBsknz37ZI//I1rvJuZIaJMX2cGDr2H852jAWa4QdONEC88K/X5zfs3mYIp bZ6bbrmQedgoyxvCQ2h2xW6nQzl7WO3a8rLfA4hyZFzcBXy4vkniCuxJyMasZcBFlQEf c12Q== X-Gm-Message-State: AO0yUKWr+MTo57WDIEU6gqc+d73o688mbinZN/crBYjQzfR624iqnePn XGo0SDi2K2m2+Ot7gx18nbc= X-Google-Smtp-Source: AK7set8DTz2u6rfaC0QVBQ2AnleUSa3iBD3B8ZpimjH09KMNhfR4snQ8COEkjsrc74q3uNQ/gAdxAw== X-Received: by 2002:adf:dd83:0:b0:2cf:e517:c138 with SMTP id x3-20020adfdd83000000b002cfe517c138mr12463230wrl.66.1679253528712; Sun, 19 Mar 2023 12:18:48 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:48 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 10/15] dt-bindings: net: ethernet-controller: Document support for LEDs node Date: Sun, 19 Mar 2023 20:18:09 +0100 Message-Id: <20230319191814.22067-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121849_510093_1BFD9D2D X-CRM114-Status: GOOD ( 14.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 Document support for LEDs node in ethernet-controller. Ethernet Controller may support different LEDs that can be configured for different operation like blinking on traffic event or port link. Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since ethernet-controller LEDs are controllable by the ethernet controller regs and the possible intergated PHY doesn't have control on them. Signed-off-by: Christian Marangi --- .../bindings/net/ethernet-controller.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index 00be387984ac..a93673592314 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -222,6 +222,27 @@ properties: required: - speed + leds: + type: object + description: + Describes the LEDs associated by Ethernet Controller. + These LEDs are not integrated in the PHY and PHY doesn't have any + control on them. Ethernet Controller regs are used to control + these defined LEDs. + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + + additionalProperties: false + dependencies: pcs-handle-names: [pcs-handle] From patchwork Sun Mar 19 19:18:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13180549 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 40081C6FD1F for ; Sun, 19 Mar 2023 19:20:38 +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=pkbhXzJEDha1tw+9jlX0vBKIPwyvefXc1Dwg4d1yiuY=; b=NYwG1I5v1S6uRA LEAEjaMHx/3c6kVxU5jtgXa6fBHxgW5gMQk6JPDmgGe0hrfGeNBJLIBgvsZ+HwSe5XWq9FASsdNHY xUGjcQ/f6fNPGY03QHhapin7/CkF3wNAwMLaXE8nfBjEDCKOnhggNtZ8trap8ogqKoivD21G9DPxx TOhvg+SB+TJANHVXJQX29lMuBr/NTZCNTVPPy+cUpz+4fKamREjeGJDcMKAye0vMutvgXWsvDaIJg c71pIN0YgO7BpWQYTGKxXCL9g0jJ6aQhB9mq7/FME0hFWbqvQWNrULcNo60YoYsj2QZaNgvvKlVKp U03MwWQAY7yW2Om/cu4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZ6-007F4a-15; Sun, 19 Mar 2023 19:19:36 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYM-007EbS-25 for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:51 +0000 Received: by mail-wr1-x431.google.com with SMTP id h17so8511534wrt.8 for ; Sun, 19 Mar 2023 12:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YxutGMPJva579mmTcYCtLi8ZBTi3DvGd1nN+fb8Tx6U=; b=p3mBsuZvjZMXgwDpGGw/4MbO61frU/GyEoTAu0FDPtAGWvwoeH9eUqr8R8sG3a77nk RuqhxoI6e+Z0Lp2CXWEQvV7EMs90OGkWMFAzDRax0GRDIYKhrx85GsTTZOc/xbAJpa9G QPXiHx4vnsIBU/uqO57dnshQugHdTuKQf0BExYsGCFgDZqCtrNVGPUXSDxJGXXrc73mk opzl52m5u8p1Qp5XC9iaFaoqAdbpQ7OuueNuZP9NTqN8y+hMytTyF2uMfvSqr6eqpWi3 rpJglIxoi2UhURWX8MuXmnj0SkF3hadNXLvCpYmEkQLtXTI4HXEwGodc7+U1rru7+tSA /tBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YxutGMPJva579mmTcYCtLi8ZBTi3DvGd1nN+fb8Tx6U=; b=Kmm31Ir32DwAkOXeooAhxgvQ60g+9ceHeafNY82gNSM7qXrMVf6VgTsHurYeeXfE+P 5i5VbddZbLodC4fvNDz3Hyh2nKZudNdYtL8MnCvdcaPGWn0lkQ/Xncm/1uIlrTeN0H2m wmvA/65ZSJjhiwXVzYY75x67VpX6XadReP/watgOaqfjlrFzVHnyn4AcdgQhm86le9by tKosdfZU8RtpRa/ACZOgZVna4xD1cw5e0Y4ydppy30bjhxQE6LTEqwSHrNJvxnGHvAqU S9BsJaM9xZr2TAsOtRuxZ5Y9L8+GU9oYo7H6gKlPIyddLbvlf68+pf5PIbJLuWSWv5ng LTpg== X-Gm-Message-State: AO0yUKUizhwIsOLPGs6kl/zKCsotM4s/PWiSMyIn/zbg30k7lbS7nBeS U1qzSUWUqd3b81rx3SrGcf4= X-Google-Smtp-Source: AK7set/4ZnF4OzN9iVPJ5qe8XpAvveOG8nFo53xUXQ8NMaEoU+3vSSErDTGBqm0xGmpE3MgweETkRA== X-Received: by 2002:adf:e406:0:b0:2d6:405f:8b16 with SMTP id g6-20020adfe406000000b002d6405f8b16mr2037658wrm.66.1679253530078; Sun, 19 Mar 2023 12:18:50 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:49 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 11/15] dt-bindings: net: dsa: qca8k: add LEDs definition example Date: Sun, 19 Mar 2023 20:18:10 +0100 Message-Id: <20230319191814.22067-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121850_711062_3A5D0CEB X-CRM114-Status: GOOD ( 13.97 ) 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..2e9c14af0223 100644 --- a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml +++ b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml @@ -18,6 +18,8 @@ description: PHY it is connected to. In this config, an internal mdio-bus is registered and the MDIO master is used for communication. Mixed external and internal mdio-bus configurations are not supported by the hardware. + Each phy has at least 3 LEDs connected and can be declared + using the standard LEDs structure. properties: compatible: @@ -117,6 +119,7 @@ unevaluatedProperties: false examples: - | #include + #include mdio { #address-cells = <1>; @@ -226,6 +229,27 @@ examples: label = "lan1"; phy-mode = "internal"; phy-handle = <&internal_phy_port1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; }; port@2 { From patchwork Sun Mar 19 19:18: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: 13180546 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 AD62BC6FD1F for ; Sun, 19 Mar 2023 19:20:34 +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:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RibYFVd7p6yrRMETAjGa2OkIQNLo1riF4UZYrvKDb3s=; b=Dx9m3UXSzI4s3c yp6Pr+Dka3bsqRPjA4GLCsZmGu5HxEc319RoUUdJO7OGVw4hYMmltJLgK+2gPJ6XznbBNYqLzgITd yqd4VrNNwXSCWD8H8HxtlQwrB4ius0/IFyugp5LZRO3uTxlAmz1kOXyR3ItIu7vrJspMTjpM6zWfQ 2EFhix+St6RzfKDF8IjhNO7PAxi8D4TlS+v6SjjXxASGw3LH1gFQP+nLTCHi2Ywqvldx9QfRtJThS HIKWASbWvz4ChP9CxW9EcwpzNEYb0+MCAJeNsYWLtDjwKoATzQndXWQOi7NmGRNYNS7/z+nxFcth4 PAr38I4UjYZBH9K515QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZ8-007F62-0K; Sun, 19 Mar 2023 19:19:38 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYO-007EbI-0R for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:53 +0000 Received: by mail-wr1-x431.google.com with SMTP id r29so8502031wra.13 for ; Sun, 19 Mar 2023 12:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253531; 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=d1ZVZcTj1LPbhIOYtLntFoqX0VTsDE05zKvaqALog6jvGiqCywjPne8LoKvI2qrDAd kCsKwPYoPCLwTHOrpCfHlNJmPYKqiNfPGS7c1bLQ/6s4lPzVL8Pw3skHVQWFXa0Pv061 XiYvFj90z1+4XfvFVTm1jiyPGb2npdlAR5D52cCAxpiYr75unrLycHKDzxlYC5taY+ru nmHF2KoCgHsQ7cGShMge6RRhCb7/LzSpeYxzt5nDxsfTSwMLDPHMsd/aom6lhh6fHZvq 2dlnrYoTFFIW1VmuR4U6JwQ2sg0Zban4OA8FAQAx8H21c0hlml94GpOq34qlFoJaNXuh cCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253531; 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=RrOVTFb3K8cUu19yzlRRcCxlSnWwuZ80WPtYymbualqI5sC0oR0+GYasU5hl886ygZ gsSL4p5dwjkVd6yby2Sf+OLpBFU06C74j25QCvag2eeu+ckhI5wK2ll4ooR7i98TkAqR aY3StiP8S4CQKbQaxRgCqlUhzzzZMqi6tS2f+Bp0SaZ76G9lXudQxIBhx36Ok0uXJ3Jq yt3xI3iO2BKOM5dTx/RkpqDOEeMh8XzNInRSTR+h++CLu3cdpJeSZee/JmH7ZcAP0hTW PqA+/HTtvdkIerzvC7TIXt9mLAJwaI032ht2e+h2WjusbT2K3mtQAJVpKjV/qYaGIzB2 xqrQ== X-Gm-Message-State: AO0yUKWfb8hpPVF6oitIJFFFmcCA//EAjM7pl6daVgTksgaASoj1InyW R8XUikntmM3FpdKHVm3HH0M= X-Google-Smtp-Source: AK7set/3O7C3Es1N1wEdf1ZRK3axSCJX4Dfqg2I56oADb/R8Vu/tWsJomc3xnKQ6cwcdy4GspqURZg== X-Received: by 2002:adf:d0cb:0:b0:2ce:aa69:c9a7 with SMTP id z11-20020adfd0cb000000b002ceaa69c9a7mr11490176wrh.8.1679253531529; Sun, 19 Mar 2023 12:18:51 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:51 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Cc: Jonathan McDowell Subject: [net-next PATCH v5 12/15] arm: qcom: dt: Drop unevaluated properties in switch nodes for rb3011 Date: Sun, 19 Mar 2023 20:18:11 +0100 Message-Id: <20230319191814.22067-13-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121852_186908_4A5B377F X-CRM114-Status: GOOD ( 13.04 ) 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 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 Sun Mar 19 19:18: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: 13180551 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 53063C7618A for ; Sun, 19 Mar 2023 19:20:47 +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:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZGBjCLdYrwKBpQCg90iPLP4roH73zTUBv+Nar0d7Quk=; b=iJgXfDwcdYMR43 FD7+z47NxrlTRps8sJHVF+vSPK8NYauFpld4i2i3ceRhZMWRmz0ZiPvZ8glkkX7VfLab6e9fi0ETU XYakhHLbJtkiFwMauLkkkk0tD4YwYQeuZh0jOs9+gEIxHpZQ7j05rKJhyQXBk9uIiEJWY8Ajzu/PO QZGsnjxEhEeFTYRuN79EwU4jzdhS9OraBRLhNt6bRXZIgaVKGrifxGmXAHszby3VQFXOg/wqWK5X4 sKnip1EJUBWtU6lsTupqDxQEXl1Xf9DPMYLAa6u4BEOU1X6VIeWyTbZrTkUshWCZNv09x6DE5mmqW 13vNbYvC3QydQJpT2sGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZC-007F9p-2q; Sun, 19 Mar 2023 19:19:42 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYR-007EgZ-18 for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:56 +0000 Received: by mail-wr1-x433.google.com with SMTP id v16so8552008wrn.0 for ; Sun, 19 Mar 2023 12:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253533; 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=IEuKXDTAa6hltMwYOaxaLEfjS/L6pjoOh9pQfVsYlDApA/0FvXwqKjj5h6orO7yFrA bjdV/ddoq8pgW0zFsYheecn7U8YVLlqNKWL/Xf1q/r6GWl+iNzShls8AHTs53V0y2WbS L4R/iqB9WlIP0XEieQvAanN6H8jBPkVU+K9mpi/hHjKaY3b9AQaU8spZo1Rh0ohqU94T QY7KCQVKq40jQtbmqCFgKh8pdFTPygVnAydOLAa0qLq2O3XKGkG4igsiVdvnyYrt/ndl aZ2TMGYylTl3HctKc32bQa7yI662/Tut7GFY9FfzMJmAxVZpe/Ah5r1U9hNlwcfcWU1g DShg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253533; 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=vfur5evQhLEorhNOxL9a7ZMvrhcOi/iY2lv6jd41lJJjv9HTmYNAYTiUa7HNO/F1Q7 hbwVeEBr/R++Qb2hrFNjLHeNAdZXONbt7hw9pOcfoBENPu9wOM17FJqGdZzEah7zOHoz MqIshssx5AKKPFtYNkroq9BEwZUVveAIaVG5+omFcJiQzO++Gs2cHAkZm3SFVgVZH7hu rziwbVkZ4wBYvvXpU+PigisbaKrRagWYRJp2BTRosAgCf2L3I8SR/ZKv/+LdibJXcFny ykjMCbsIlTVSKAr//uI8LUMKhs22LmsD9/DPFU5Ze+LeURtp0Z/YgUYpZHSwmwggPin7 zrLg== X-Gm-Message-State: AO0yUKVhp1JdYMnsSpvN9EMfO3azNTrbF+6j9f8YD2w9Rk/nsIwhBjU7 iBpm1w2kwusGvT5N0BpKgPA= X-Google-Smtp-Source: AK7set9EIQRt+Vy8WI+P6a0TnkZWagWQpwPbVaebWx3xDMHd5YbC77qduULziSM514V5eiH6+OfwIA== X-Received: by 2002:a5d:4b0b:0:b0:2d1:9ce9:2b99 with SMTP id v11-20020a5d4b0b000000b002d19ce92b99mr8896950wrq.18.1679253532979; Sun, 19 Mar 2023 12:18:52 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:52 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Cc: Jonathan McDowell Subject: [net-next PATCH v5 13/15] arm: qcom: dt: Add Switch LED for each port for rb3011 Date: Sun, 19 Mar 2023 20:18:12 +0100 Message-Id: <20230319191814.22067-14-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121855_409077_AAED46FB X-CRM114-Status: GOOD ( 15.85 ) 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 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 Reviewed-by: Pavel Machek --- 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 Sun Mar 19 19:18: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: 13180548 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 0ED6CC7618A for ; Sun, 19 Mar 2023 19:20: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=fKxgx1EBy6S9ZHDiqXsyz4JCeHhqg53qN1ni1kAJcfk=; b=OAe7aDroDJxR+0 NbvbzZ7SOLIlTG4SPYI0lWBJqSDmKyaEwuZr/Nc/vBmWcf7UQ+lhEnEFyvDkaPu62Sa+FvmvjzE6j rCSprb+HS0bqh++Vp2/ixOsmzC2lQYNQJf93DuSoMiUGF8gyV4q14yC9mKdbGpfXFKLX8gvvCR9SR fS1zfkStEiG3nEr2qqT2Qr4VPa0+Nkya6St/g5YNqH5Acp4rxKBjKKoSSEOoLea+toKk8XJ15UtEi xbKfyKP6/TQ9/hKjO5/u9C7QrU/uXGdBEF388yWst57GK0uZNEC5BoFB5KJIjGkYJm0na5SHezFtA taqGsmugktv2/gNN9V9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZ9-007F79-1r; Sun, 19 Mar 2023 19:19:39 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYR-007EYk-0n for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:56 +0000 Received: by mail-wr1-x42a.google.com with SMTP id v1so2417869wrv.1 for ; Sun, 19 Mar 2023 12:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253534; 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=Y66KPWA5vwHugBdTXrY7CbixTqvqjjH7vT61EExGPAvQRGNeJNyQoafpa1X3zexgtC SwiR7QybF7NLHUNAGaDn2E3ZT2YRT8vGI3AXgIWL1wnnQDtKUrX5V5ESdNKC1zQOm7r/ 8q5zm9oNoAC+FcUGuaJjsZbWpCC/wzdK0VS6ogdK6CxOSLOqR1P1yEEM6IGB9I/DuEZC gk1h6lf/IljiB3orML6t4l5G5x06pfqdBLq2Dw3f55HkJiIhfBDKEE+gQxwP2HlRhEr4 hNe2uCvwwIo9Pi8FH4a1DZZJQQVbXxvdlFRFlNNuS06pNPhaMITN3QzskZxfhbapK/iJ 0lhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253534; 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=lnVL7rNQvRFv/NcWoYroxWAg5bjMMyTJ4Va2n/lF3UkHzTYVVo9tdAu073UV2JLvD6 LIJWDViNFK4q6FsxGVwTinBWKNmcjhjCkZNAhP3j+EWWBTAw26nb2eagO9vvE6Isr46O 7HmUsObKsU7Qrp2qYJGYLZ6F+mRZWiaTFtLpD9kobSkOPkZ30owtf3+5Jp7C2wrOot/2 Y4xBd8j7s7+fI3CYfR03GbSvHXArfmJbquribOabQC/FT4gX4yRjOMqDeUTlNKYMZsTm KYLCjm+OvvtLg4BJdjylCawqONM7odAQJCchRYJl0eIXh9mBOuZUnfPZ06bfHwWl1SW+ J9VQ== X-Gm-Message-State: AO0yUKWPj+jio0QPEKWizLeuUY+Hzt53Y/pGypnwQpd0Om95h7BBnbtI eRQ0VvzG9LUHsDzoLAPKZQc= X-Google-Smtp-Source: AK7set+g4djahWrxlbAtNWVp0F2JcTlFwac90ayuwSosW7HTFtGReZoUT/EVNakWZkSBm/GoZfBXKA== X-Received: by 2002:a5d:4dd1:0:b0:2ce:a250:df68 with SMTP id f17-20020a5d4dd1000000b002cea250df68mr12280592wru.28.1679253534443; Sun, 19 Mar 2023 12:18:54 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:54 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 14/15] dt-bindings: net: phy: Document support for LEDs node Date: Sun, 19 Mar 2023 20:18:13 +0100 Message-Id: <20230319191814.22067-15-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121855_289963_A5A5446F X-CRM114-Status: GOOD ( 13.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 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 Sun Mar 19 19:18: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: 13180550 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 C3B41C7618A for ; Sun, 19 Mar 2023 19:20: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=0pMUd/uTW/sQpV1b/RbCH5yFTCgd61tHkhwAxREpRKU=; b=T5s9Ymm84BUwYY VgrZPUyrbQVoAHFEHpVdfd2kbPNlyMpqe7EF2MLQQzVr296pJd1zJzjC0rTx3Lb1RqWkl1w0VDMyM i9IfAyGhUZcrnB2HpIF6JT5Q9aWz1N13yKHw9cjFnU4j7jLKF/rcGlhZEhiVXFYehaXN/Pvc67T4J j/y5DBoSZ37d89jmKWUuMW9b917/3WfzByhCs7gU2ZISc4lPiU4ow/wDLbT0fimT9a3uasnTYmMtJ E3E2edYHpyzYWq4j1B0/qrusSuwChA32mUItF55Zcd/nGlvbU6OBRpFbItAaC0ST70sl9DnTEQ9PW v2bdX3xHCf9UxJ8KK+1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdyZF-007FCs-2q; Sun, 19 Mar 2023 19:19:45 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdyYT-007Eid-0T for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 19:18:58 +0000 Received: by mail-wr1-x42a.google.com with SMTP id i9so8531195wrp.3 for ; Sun, 19 Mar 2023 12:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oy4rJp/0zV8uQx96aqdFOna+cm21IPd+B8/oErRDE1c=; b=ITt6syLmwNGy0ZbUxm216tTbp3mY9GEm/3lMvbbE2Rt2AmFNDP+lDlVo9z74NODKkT PFUABL92MyqFqXD0IsdwgSVPYtr+hzSbiu2N45Nr+n8QX8AmyN8POiYqe5G/DajGXsJc 67FzzJrp7CrMFY4Y3HeIEpyujtlfFQpZokxqSIZ0j8ktmSZK1E7YZqfLTa/KyiYMHoCi T4VCPN2ZwK6nDdX3L3rI6l6bJJY4SzMN+vB0EOUrtkw+1Dbccm31xymXbmoBaT0mARDG M0OzS1dz+KV8WVgJiqN4sFnIBVzzEuNQ9Nb7uGwFagkzmu7y1OC0cB+tPyIYFnF2eRVd Ry8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oy4rJp/0zV8uQx96aqdFOna+cm21IPd+B8/oErRDE1c=; b=nCN6u9fWrgz8Lsl//KbW69iIRdbXvNWNLz/8Nyqh0fM6tVmWRmITrgnwak38+34QaC AgdTR6iqz0jgENelKvG6orE8r5SjxGlVJniSkJW5w1+rzXH+WeyAP485mJpRbfqPcfFS ygJY4/obisJhF9bV6TILUf3HI4EgHKkJvO5l08YyLSTLWVxXFw0OHNvQK8Q+Z01KSc/M ibZ6ybNq8alFXp2EdQKORvq6qNPbwUBvB0HQdHqDIqpxlaSqswpuS0r0bvAQperYDw58 ctj8T7WQywZhWTYQK4wpsf01f54Tn3umv685moBULl9fKirUBRVH1WiQPYFCCIHDEKj9 9KPw== X-Gm-Message-State: AO0yUKVWmyLpV9v4gIRon5NukQVjyxlUXzN1Bc972w29SsSYbcqanfGl HBnbj4+60xwvIJmwTWcfs3E= X-Google-Smtp-Source: AK7set9RJTHUU3x+cB1vPG2tx4D/cF6g7trZnQtZGucpSHSmKWi61gPafYkIpRGJ4EUPGiGlo3eKQw== X-Received: by 2002:a5d:4205:0:b0:2cf:fd6:b83f with SMTP id n5-20020a5d4205000000b002cf0fd6b83fmr7367868wrq.8.1679253535952; Sun, 19 Mar 2023 12:18:55 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:55 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 15/15] arm: mvebu: dt: Add PHY LED support for 370-rd WAN port Date: Sun, 19 Mar 2023 20:18:14 +0100 Message-Id: <20230319191814.22067-16-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_121857_182959_554B8C3F X-CRM114-Status: GOOD ( 14.18 ) 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. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- arch/arm/boot/dts/armada-370-rd.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/armada-370-rd.dts b/arch/arm/boot/dts/armada-370-rd.dts index be005c9f42ef..15b36aa34ef4 100644 --- a/arch/arm/boot/dts/armada-370-rd.dts +++ b/arch/arm/boot/dts/armada-370-rd.dts @@ -20,6 +20,7 @@ /dts-v1/; #include #include +#include #include #include "armada-370.dtsi" @@ -135,6 +136,19 @@ &mdio { pinctrl-names = "default"; phy0: ethernet-phy@0 { reg = <0>; + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + label = "WAN"; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + linux,default-trigger = "netdev"; + }; + }; }; switch: switch@10 {