From patchwork Mon Apr 17 15:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214241 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 58F51C77B76 for ; Mon, 17 Apr 2023 15:19:39 +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=VX65wKbm1T8XJhplBrHWZSmphFWTxV3SOhvKaTeSsmo=; b=mEw3fsZQkj3nQQ 8YL+vk8H8e0QUMH+QOa7zqroiihLTLueAun0pyqqx63f9hHN8ZRCR1dQt8upkRHA6JQUUEftYL+lI EE3AK4fA+S5s9mPRFSzTDLqKl/sk30vXg8Nd+gjlVQmEgYFIoAPXWpZL+jXobQcv0qDzdqu5LWneM xLk6WFHShlh5iv3L1eoZBzos80U/nqV06JrTvpTe2z1USI6YgdBVooMwzYFG5bJSnkha2lCDrKSzL aXwbpai5eebci1nrGfDG3hhroDnV+iW1setehd1PSp8vXw0IdxQY06/CIf5/0YqaHGPdHXGFJjCm5 BAVxadtlCVv8dPASqOAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQcu-00Gos1-1A; Mon, 17 Apr 2023 15:18:44 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQcr-00Goqz-18 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:18:42 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-2efac435608so1514726f8f.3 for ; Mon, 17 Apr 2023 08:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744717; x=1684336717; 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=k1MW6xivzd352Exo6BdAvt5sq+6GrYH5KFNVqtE0mY4=; b=Z76/rwOAOzlCNPMvtwsPc95hcbuhG7GML/sUigWaLACArj62a9yF7sWrPfhSrSK2En jKiHl2xRx5JVtGPVmB/2wst28I8Sk0dHEkvD6N07F9QVXD0qbmSH2DI9zldH8QzISyo0 CleUj9QyBl5ze+34wyIQZ+95tWZwTUckG95Y9Et3m/5UCo5cagoDPgBOW/ZbCEp8KVEO WC289cFr7Gc2trt/hALwEaQbL9cSjevEkRNi0ykCUrYXyM97mthjBSUCHHzo8EhzVQn/ uY0V1mWmTZWYZZ8/ZRc2NoFev87B9mvN3ytEyhEtup9gOUl1gmtELDh2z3WcvFG2rmFb zfrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744717; x=1684336717; 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=k1MW6xivzd352Exo6BdAvt5sq+6GrYH5KFNVqtE0mY4=; b=lr+hKgigPx7MO17veqNSt0GnHMjONPdHexRpat3+TPkp4cyN2MeugfXFaWhfGvSmNq PGJ4K/LniXa/CcLy/wORZ3LxLdCTlW5LP+DMqkoUiNpiqkWXumAGI5D5ngM8I3tvWh6q G8oy9hIAz9YMZIwJWPv2yIodmOsWjot1Q8xp2x652AKJnfkLiRnWINEmjv/UGKBS/eT7 oWj0JjXoAq999rOvgWsrqYxX3Kn44YcYiW/3jTpSA/HxXtrNOHSlLpaH+9n9Un6v7PWe drCPRaG47ZTz2ImlyRnZxAUSdSGo+cXrKKX2TDRr4W4hpSP1k0bgEaLyDAFM6BRsyhXd to3w== X-Gm-Message-State: AAQBX9cR5gVxnqWDz07xA+H77tiLA0112qlghkEo/X93sULvsTu9FQNL 5R/SMIokiAV2I9aaYMUXPP0= X-Google-Smtp-Source: AKy350YfdukjmZAn6zy7Y3dzj+UEoeFI/PVFj+jnOKCyq4V8KA9k1cD0MZFo0ouLfAB5+j7uo6k0tw== X-Received: by 2002:a5d:6289:0:b0:2f9:357:bb5a with SMTP id k9-20020a5d6289000000b002f90357bb5amr5264134wru.25.1681744716939; Mon, 17 Apr 2023 08:18:36 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:18:22 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Cc: Michal Kubiak Subject: [net-next PATCH v7 01/16] net: dsa: qca8k: move qca8k_port_to_phy() to header Date: Mon, 17 Apr 2023 17:17:23 +0200 Message-Id: <20230417151738.19426-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_081841_388211_C406194C X-CRM114-Status: GOOD ( 13.91 ) 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 Reviewed-by: Florian Fainelli --- 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 62810903f1b3..20acbd0292f1 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 Mon Apr 17 15:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214242 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 4E25EC77B7C for ; Mon, 17 Apr 2023 15:20:21 +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=hRG8os8luSOldYrhtsMB80M8zvkW40gnov3B5r+o1kM=; b=LSto5ZH+5aelOg j436e4L2UTUEpuhiIbDzkDLorE5MBzq8ajk1i8ggGtb74/SbO+Zsln9we4zfd2GwJNxJ8A5jbqEh2 muo7PTlelrTHye2EJaCK9FtGW3AXFuse9AHvBnDuh4OX9fAFJMndP0FXKh30DduRJZ3LzAEL5aSJO ABI5GAM2k/aQrC1RyF/heFvd3iDCmL+qkTXUP/p0HpV64RBLs3feWPiiqcZiYaL/4h9zqO3sXGnL5 iyN0NRoNrm9vUOgsw1Qu7RoXQv+mU4aVhK6kAFYvMd3FQvpLDxuqwR3K2eOTy/S7shZNrUUccGYov y2Kt78R0MOBN+jCGH6wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQdV-00Gp36-0b; Mon, 17 Apr 2023 15:19:21 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQdR-00Gozy-24 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:19:19 +0000 Received: by mail-wm1-x333.google.com with SMTP id eo6-20020a05600c82c600b003ee5157346cso15712188wmb.1 for ; Mon, 17 Apr 2023 08:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744754; x=1684336754; 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=z3lHJDqF6OP6TWvuWg3fPupOz/b881z+2tbQHKKhm9I=; b=Snk3g2gXry6wKQ7leskdLgLc7TDJCzldENsjA1FlB8dykAELy3HkWQYnXvdK9Jnvgf 6iTDw5PFH4nmbaYrI0dXPEs9aNGLOTzp/RQg2me4UKsbBCJyRJIM2bOxPu1x2bSKFv7y I2Kcx3MhvHdkuHPmMX/Ti6c6oHjtlSD+smyiJN6/R4tux+fq4mo9kIJZz5k4mYkAV1qO a6P4aJLrVrie9lbifc9PGeGdfoPQodo92qn0keap0/V3HqRpywW2yhrY3qXnM3ul6ti7 JG0GVLT+2YjxvL/8oVRIYCqCFSwxwCdSeUVpzdIPBJnDW7FZtGcObKYm7ObUD2YdXwwk in3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744754; x=1684336754; 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=z3lHJDqF6OP6TWvuWg3fPupOz/b881z+2tbQHKKhm9I=; b=gxRCsP2W6JX0fT6qeh35TfcJQK7pJNxcIIvaTw/p/i2mFDzeWjY6mr7l/sE0xIYzZq 3VPlYEW7T+5FmE3y7ZlYNp1xfeyHncnheeIzYSi5mpnJYXqe1wUffegctkWLzi6wSD3/ Pgs1k6wJilp9v3bGOvJX+41A2s9PPZnwN7vQSwxW9CCMuf4tR6wf0oGjfZlnbriP+9Pn jhHJ+OHYSR/qglDqn/kwhYzy1Flko4vzFfVBQp0hBVnvGDtPe4bYK/zMOZdp/kl29Eu2 BI2jP+IZ02UHJrsahDe0lpDjBBJakg0HS4u3U65MxW0CzntXvHMHQwtco6WT84EOmBnm ZeOA== X-Gm-Message-State: AAQBX9dXbw+rV+yypfP1e+xDGpdncUNiflNP13L3Co8N3ER3Q24FzhhU xG1Wo5AZ43Wz8D2mtvC5bSc= X-Google-Smtp-Source: AKy350bdnF/lcUBujtCuP7tVrUqqPiZJRK73sGppsCEIxLKiDrswr9DqQDlvrEoLy72/hSv08pcTaw== X-Received: by 2002:a05:600c:1c20:b0:3f1:6fb4:5645 with SMTP id j32-20020a05600c1c2000b003f16fb45645mr5413253wms.1.1681744753548; Mon, 17 Apr 2023 08:19:13 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08: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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 02/16] net: dsa: qca8k: add LEDs basic support Date: Mon, 17 Apr 2023 17:17:24 +0200 Message-Id: <20230417151738.19426-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_081917_681422_22BB0A1C X-CRM114-Status: GOOD ( 33.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 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 and function of the LEDs using standard LEDs api. Each LED always have the device name as prefix. The device name is composed from the mii bus id and the PHY addr resulting in example names like: - qca8k-0.0:00:amber:lan - qca8k-0.0:00:white:lan - qca8k-0.0:01:amber:lan - qca8k-0.0:01:white:lan 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 Reviewed-by: Florian Fainelli --- 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 | 239 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 60 ++++++++ drivers/net/dsa/qca/qca8k_leds.h | 16 +++ 6 files changed, 331 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 20acbd0292f1..6d5ac7588a69 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) @@ -1782,6 +1783,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..0146ee12d34c --- /dev/null +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -0,0 +1,239 @@ +// 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 2 bit (15, 14) 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 (31, 30) 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 = { }; + struct dsa_switch *ds = priv->ds; + 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 most 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.fwnode = led; + init_data.devname_mandatory = true; + init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d", ds->slave_mii_bus->id, + port_num); + if (!init_data.devicename) + return -ENOMEM; + + 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); + + kfree(init_data.devicename); + } + + 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 Mon Apr 17 15:17:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214243 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 6918EC77B76 for ; Mon, 17 Apr 2023 15:20:50 +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=3AE/o+SfwIHg1y7vRCA6zULuGgrpJMeiAzySyzgX64Q=; b=RdBSo6ttYMK+JL +AhnuWM1hE+deZa3rjdkTzUmOYrQUwz9ROH6U12umDkK638xKbfILa0Dbows5EAdBF4Qkklb/JL8j aaugcTaZB1RzKjFEGPZSBCSnKWHXU+UbBxjdUHytBGtOGSYZFZ1Zfw1Eq+zW9TuF5qUW86kgtAkeB 3IexG53z5MtPC55cuJxSwkF6AnZdPJezmKSlAQARdnMfLyAdgQRFRGNzpOSTC5g69a6L0yYJlFL0x sSxWoKZJ1XWyivA85X7NC4IWcRYMufRoDKQidtG4qQukMcatFdTQ/IXd/cGenSzMEOCsC4ZTdTAIX xNAR6o5p6OAB/YwupAWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQe5-00GpEV-1Z; Mon, 17 Apr 2023 15:19:57 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQe2-00GpCt-2P for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:19:56 +0000 Received: by mail-wm1-x331.google.com with SMTP id o6-20020a05600c4fc600b003ef6e6754c5so11886104wmq.5 for ; Mon, 17 Apr 2023 08:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744790; x=1684336790; 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=ePi4CR2T47RYrwRBfSvRAkHXEjaIE7F/c3iGG+RBl5w=; b=X1p9RfbMQaDa0pFdeTw5VL13ToVUD6z3eITOT7ZwMipgfrT34+XGMWmPMZ9lYzR9Ew pj25Krt/L7ZEZGwnpoKAHVM5TUqP3AR5kAbAAKGOz/ysag4CpdhwfgyRnfFCERZutDPT /zUNuhpbYsgobHnjtQiXlgMgAaVuEfPQi6oJvxckViwefQZD0AVZSegjYi1favfkAuD3 Tu3R4tjlsu2ouSFB+PDqAtX61217eMG0Dzjc0rs5/VLu2311JLa5asQxez9EJXlhI2CL 8LkZ2TZR8o08L3p3Q0KxLn+14MzGH/Kui2DE/idLmspQ9QiqbQPn8FRADuXW6ZWBWIJ8 Xb0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744790; x=1684336790; 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=ePi4CR2T47RYrwRBfSvRAkHXEjaIE7F/c3iGG+RBl5w=; b=Ne5ffv3XAAhuV2hhNpEGvJ2/5T1zTqIFofgW2z3mBM9WpEXO2ZGlr9U3+SDR1d1k4Q yHwOWKuM+MZZI34+SpwLPGYr0hyNxd0QjcZgk3R3jE+axvyPw4E5Fs4F+5EsnSxYpQyj /AMNqg06ckZXMcEY3WFvBIIvuGVhU9p5g7ea3qs+nNvrnvXSat1TjP2iMlXtCxwdby00 TN470LfqpGrRAJ8Sb3DycBLPCY+32kMrB1ZLlhXKYwvD8sGnmp7fb6NjWNpETh4CM98l Y52VpDaFzBSkYch2LHt/8HKsFCUK/8J6XkOhx8HrDCTkH6Ot32CY31gwm2qBqFfYz0m/ KuDQ== X-Gm-Message-State: AAQBX9fM+x0o8THMViLcV8bohABPa2RWAF8ZMnVqcNvQbqCk0hRjUwrB rmLDXVBE58h1fhVzWzJiSZg= X-Google-Smtp-Source: AKy350a6Il4UQ79RJ2tdvRO07JYzuuVijegQEFUCQxc1IgCIU7F41z7HR3KWS+jAG9ds+JB1zo4Lgw== X-Received: by 2002:a05:600c:2196:b0:3f1:73c1:d1ad with SMTP id e22-20020a05600c219600b003f173c1d1admr2309302wme.35.1681744790361; Mon, 17 Apr 2023 08:19:50 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:19:27 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 03/16] net: dsa: qca8k: add LEDs blink_set() support Date: Mon, 17 Apr 2023 17:17:25 +0200 Message-Id: <20230417151738.19426-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_081954_781757_768160C0 X-CRM114-Status: GOOD ( 15.41 ) 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 Reviewed-by: Florian Fainelli --- 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 0146ee12d34c..b883692b7d86 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) { @@ -186,6 +223,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.fwnode = led; init_data.devname_mandatory = true; From patchwork Mon Apr 17 15:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214244 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 94F92C77B76 for ; Mon, 17 Apr 2023 15:21:04 +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=mBWxjuXf2EVzLEvX9Zntp6nYLk3cGONudSS8N7Ei5v8=; b=sNflzNw7xnTCAu 5yMqoPLkq49Qb6R+di/YyCJMNPhw+EZMhDIsGIFYrxXM0kizJ1gZAKeyJxC4kkmYlGQJ31KoPb/uP Fio0DOrIj1hxY97sCHbfhoh6o7rp+fPF0875I7ddujFXzxr+YJZJqyHrErIPg96DkFOAVzAVUHv7O k3XSdTVjE97/Jv24BjyvxLT73jM7odFo+nZ667MeNKOhTJay4p6FKilft+wvIiM25hshzYxJ5yQrs B3v36bEy4Iv104TlhNe5hBUjn9u0ytojtM2hbY0OdQbsXYShGb7k29gD/DjkPc/N8W7bCIP4dxGwG ozGJlgpeHyzEvEE5InFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQeL-00GpJy-1m; Mon, 17 Apr 2023 15:20:13 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQeJ-00GpIT-03 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:20:12 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f09a3c8bbbso9814535e9.0 for ; Mon, 17 Apr 2023 08:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744809; x=1684336809; 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=VHm0NEeKo/+Hb6SrTm0b3FIHftdZOu6XAUw1fVTOEDE=; b=f7eiMBl5UAWig4VdU1DlcxCLoj1EfYUVVg7JpiHKaafFUz99uhdi4lT95IhqXM3Zu7 pcxDeQiHnPIcHqMxkJif3yuhy1I/eW6RlwwGQoYThH6bCzNON4/2R3Ql1kfXkEsDCZly tn0w5fq4Cs/l9kXyJAg9uNZioe4p4MwL9PTpyOajFFA/8fR43ivxu8rdhsv+jtZDaVRG MkQvQA57+JCM3wx442ZHowbIBB2NJwT1/W3SaGpGSR54VhQd+AzcfehSreC+S3r14isK WQtAQntwbljPzhBPcun7OvRP0Dl3obXL8cFIT+tMR0aEYtI7LAPX+k5lTdFVmZ30vLPq WQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744809; x=1684336809; 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=VHm0NEeKo/+Hb6SrTm0b3FIHftdZOu6XAUw1fVTOEDE=; b=hwTyZyuPHz7QjVbZPl15zmm8peI2cUwclljj1nGdemIlO518llSXUx9RSiOHP1g8cA Uv7lxGKK1mBZGF+B6GDWCBTdXWJfky2ryM+/1io+wicFLQuKpgegddmu92UbuiQgvkiX Lfq2Lrm86MjrfqlAOmcX+db7RVHAOIlt+RW9PovFFjbgamU/00n7fv7ZEv9Jx61/oSHO iLRWjE+hu5ThVH0aWrN1GVnUPTPuVFrfaKX1QfwB8jNFIbOaYlKQq1WziKMf8i7Zn6KO qS65GyuX5fzOYTxwWKNp3KwCgVtI72WhCarbSmnZEb3jfbuk/Kx14WqXx/VBPW6XRFQ8 ks5w== X-Gm-Message-State: AAQBX9detdxXvp84g2DOP9Swfxm9TJWc5qU7zjYWlwoA22WQ0xV7KduY X7R9+udQP8UL7plVW+CSWmI= X-Google-Smtp-Source: AKy350Yuafm0kp2sjylWkkoW9sS/ZBvqUBWgbUq3h005//0MPbGON/ecb2mOALLbhnFKUajEkyyv2w== X-Received: by 2002:a5d:5409:0:b0:2f8:5d73:dbf0 with SMTP id g9-20020a5d5409000000b002f85d73dbf0mr5806755wrv.27.1681744809066; Mon, 17 Apr 2023 08:20:09 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:20:00 -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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 04/16] leds: Provide stubs for when CLASS_LED & NEW_LEDS are disabled Date: Mon, 17 Apr 2023 17:17:26 +0200 Message-Id: <20230417151738.19426-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082011_055874_6D341874 X-CRM114-Status: GOOD ( 12.88 ) 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 or NEW_LEDS are 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 Reviewed-by: Florian Fainelli --- include/linux/leds.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/leds.h b/include/linux/leds.h index d71201a968b6..aa48e643f655 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_NEW_LEDS) 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 Mon Apr 17 15:17:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214245 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 41B68C77B70 for ; Mon, 17 Apr 2023 15:21: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=Ml2COsfD/CZ139Q+sL6VahiMKYOxt9QUo/SgGSWmeog=; b=OBAsv/5amePpd/ 8g1tmAt6URL+txuiyyRv3VJXF8nTcWQttx96K2ygwvlGp1RooPzflRD7ZDXwU6Sqv35FaJIiYr4sV kQUWCFoZ1VTON3Ok+HYMWTZx5mJh5TppDPRf5trLFhqKTTxcMUCJozXSNbf8CKWXK1QyJd6yXHXjR Bm18EVKzlWIIlvxBXE36SMlNg1NlErGBvxdmAzQ71W6L7/ta5AHPOKoZsVZMUbf+a/PFCVEm6jRoF zZrkN40eIcItJ7swx7rQsdIiIzPNZ2cF9+ne5rCD5hgIUv1hK67kP9oyHqnkA8/ceM9k0RMIu83JW SCKwX2DSiMNDJcPmW2gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQej-00GpU4-1q; Mon, 17 Apr 2023 15:20:37 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQed-00GpQE-1z for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:20:36 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-2f9b9aa9d75so658240f8f.0 for ; Mon, 17 Apr 2023 08:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744829; x=1684336829; 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=II7AVpluR/mcohVGgSi1tMSvxtZUm75jmfq4y6fCXJ4=; b=oToAgzLhWBnsQnWGjJpxLd4WVjBI/fuVUW3fXl5ajmSOWip/2LeVhnCOQODRIGRVNV l4KEdoGZd31Ct6BBGgT6+rhzeBGvXFaE2Ci74Z/rQE30YGdWFxnqCw18Yfi2iS9PvFB8 B/VNeWrDs/QjscHOE2O59WGosYcD2eTiHlUfDuzPtCYVJ5lecklsZuPuSXhwDmfRobkA BcweX5OWCO1WxmIpOnhRkyzmw66IrH9OvkezboRGYHM1n2MXF4ROACcnBLh73rhWIN7S Yow1nRqiQvoEDf1lneXyRvN36b/3XmiRcbUGuw3CwbTDeYQPStwpRhwymKGWWnosnGZM MjNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744829; x=1684336829; 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=II7AVpluR/mcohVGgSi1tMSvxtZUm75jmfq4y6fCXJ4=; b=KirR5DLZWRL226JGIRjBB1iTEiTTHVwre5OX43s0DRNG3KciC6/Gu366P1u4dR6xPw 2Nn0DNy5O1rUUQu8oYUx151X7pGsLBGG7lU1KtrX/jMyEugzBycrM+Cm3vwa8w1c8NHK cr/ek25KZ+fNnxCJlnNYLQhnrH6r+/Nsv3u30UrwVFm7RPldwGa6JgWTt3jVpqjYmAy3 y64A5+PK1vd8RLlYA87j3DpOrHUeCeQinuCwxv/IbkUwBfNODIJ1OA/0vCVqguXV6zDF NWe88qLI5E+3w/uajJzeJz7HF0HMerivg5b6Xrmd5s6oVwEQVny21J7nZL+yeVnlB5m4 1UuA== X-Gm-Message-State: AAQBX9d7KOTu9I+71Mg7hEv7I4ZObwfRT0yojo0AYSU4QBgpgdUM23Rx rqmWkncBiV3K8f71zLNQOgg= X-Google-Smtp-Source: AKy350bftEUxq8re0i0coLroY3HkJGrpY8WK2aL1Sp4V6LgzG4NCsSgJW7zBaeFog6Tm3I6jYmps4Q== X-Received: by 2002:adf:f089:0:b0:2cf:e422:e28c with SMTP id n9-20020adff089000000b002cfe422e28cmr5440702wro.42.1681744828242; Mon, 17 Apr 2023 08:20:28 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:20:18 -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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 05/16] net: phy: Add a binding for PHY LEDs Date: Mon, 17 Apr 2023 17:17:27 +0200 Message-Id: <20230417151738.19426-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082031_654218_9537BF9A X-CRM114-Status: GOOD ( 25.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 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. This allows testing since the LED core might otherwise reject an LED whose brightness cannot be set. Add a dependency on LED_CLASS. It either needs to be built in, or not enabled, since a modular build can result in linker errors. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi Reviewed-by: Florian Fainelli --- drivers/net/phy/Kconfig | 1 + drivers/net/phy/phy_device.c | 76 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 16 ++++++++ 3 files changed, 93 insertions(+) diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 6b9525def973..b8cc49820ced 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -18,6 +18,7 @@ menuconfig PHYLIB depends on NETDEVICES select MDIO_DEVICE select MDIO_DEVRES + depends on LEDS_CLASS || LEDS_CLASS=n help Ethernet controllers are usually attached to PHY devices. This option provides infrastructure for diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 917ba84105fc..61b971251de5 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,74 @@ 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_u8(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); + init_data.devname_mandatory = true; + + 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 +3254,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 2f83cfc206e5..bd6b5e9bb729 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; + u8 index; +}; + /** * struct phy_driver - Driver structure for a particular PHY type * From patchwork Mon Apr 17 15:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214246 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 31D20C77B77 for ; Mon, 17 Apr 2023 15:21:42 +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=726ALjA6eSczZoLwtfFFFdIvutMGyvqENxp/6RWhfmk=; b=KhgDiJw72dme25 XXCi8ZjAFxFMMaGW3QjZZ8ZJ50sIUA3Bvm+8hdzdXWZqvSPJ55+cmCTJWksq6mucI3a2mlFbnrdt1 CIPp8e8RVS5/RtaP5fILh/U7e5JUXVavE2XQrp+hwa5YNBjEOfsRD7zmYcZ41n8xSWYnYMZkw+rV6 WY8LJW1LkNvQkIPwpdncJOUBKJ1UEFvIh3tP4jV4pzAEP5Tsh1u+kar9tYDRv0iJF5xPj4ARuLUC2 os7O3cqHuuIjALo0URpCg5jbEatKs01YBlBxthR9dNFRE4IHWCrXr2O0xOP4nut4nuoSrXUy6i5lI 0c/lZRQcHjbkIGrfHtlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQev-00GpaC-0m; Mon, 17 Apr 2023 15:20:49 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQeq-00GpXe-1E for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:20:47 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f1738d0d4cso5559565e9.1 for ; Mon, 17 Apr 2023 08:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744843; x=1684336843; 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=szf3ygE87xUCju0anF41cpULXxylHL2GWUmuOySoNxI=; b=KkT85xTNMLZ4fOATjcpyY0p2PuhGDZLwQ6JVQr/SfipLOtjHbe3R0m7x6xVvqZa65D Z65TtSWWqVKR9qi+D/7kPzzcqhOLNAKTb/46Kzf8BHGIHX2sJEgU6FOrAxxIdhQx+fwt oKzEtCCtRHcLYcJWicHRl+blapxA3+i0/ghtozb9u6YQgaScnMftcFI8mSj5DYsWDVPJ BWlmGK8a2bAM/d6NFGws/vglEoZ0BG9ru68cR/b3y7yPw/ck/rc3+WkW3B9220tujjbp MUpP6CX7xXCL5w6klPeuxPWPAJxLmEQ9bTotcZ/y2GC2iYDDoH4nUtO+mBH2h80nML4q bEXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744843; x=1684336843; 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=szf3ygE87xUCju0anF41cpULXxylHL2GWUmuOySoNxI=; b=cvWLOYqeLMsOFiFvhzJjZnWwel9NgJYYTgFATcv6cBDcdLx8l3IRd5B3bjkLomK3ym dm6iW43E0veCn2e/z4nXf7gUZUEuhm1H3D1l3R0Lg29N6VNOLPaZw2cwt12gkaFF7EMr gpy6tkobXuRWeROhRpu4jwiza8D8ugNw8CirTHpNUK6jDB6U2ZtA1Q21Ard1YsgFo291 oRCMnqbkcBQEIKOicg887/uphgXgDCRamnFZSHHkASudwPfO7Dgnve/LHqQ+KJE2lfRy RSOVlgExmc3f9MCFre2d8OEnp1Bo71dy6dPLrZgoM4cLKzpYsoHGnfX7aX6EZ/boR3+c gu2A== X-Gm-Message-State: AAQBX9cCg/PQvhhrpM7jamuIchgb9CuJCf46k7tHrB8gXO3sbgF5bb08 ZLYPuY5NJlhjDBOTdEvripI= X-Google-Smtp-Source: AKy350bv+mp8vhueW8qG/FJJJtGId8y20dMrXj2IguoepJG1AKZlE5NzINNm4TBcPD5kwzreHGQ3Ww== X-Received: by 2002:a5d:4208:0:b0:2f1:d17f:cf95 with SMTP id n8-20020a5d4208000000b002f1d17fcf95mr6033958wrq.12.1681744842567; Mon, 17 Apr 2023 08:20:42 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:20:33 -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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 06/16] net: phy: phy_device: Call into the PHY driver to set LED brightness Date: Mon, 17 Apr 2023 17:17:28 +0200 Message-Id: <20230417151738.19426-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082044_435520_71EEBA36 X-CRM114-Status: GOOD ( 19.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Andrew Lunn Linux LEDs can be 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: Florian Fainelli --- drivers/net/phy/phy_device.c | 15 ++++++++++++--- include/linux/phy.h | 13 +++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 61b971251de5..5c1200160c51 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_u8(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 bd6b5e9bb729..f3c7e3c99f24 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; u8 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,15 @@ 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); + + /** + * @led_brightness_set: 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, + u8 index, enum led_brightness value); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) From patchwork Mon Apr 17 15:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214247 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 D0909C77B76 for ; Mon, 17 Apr 2023 15:22:01 +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=eb8053fxGWYYM9/5+0cA7W1wbh6j9optVwCKCWZxR9E=; b=bfpGfG12u7Og5e 4hDMK9ouDZxV+f/bM9PjiHAT0f8x/5ekd4DVPrh7FRkXGrxu3mv6D3hE85XHcMRxnjO2ZlnfJ0LMu V6CRZllfufRbuP/5YBBz8ULSnLtmTA202wH/UMG8dwtnM93L+ErjHSKE7zxlKZFF4MwlnZa7Y3gF3 h3nDdABzfeFoa9tfMEKMMSEEcUAiI9K6rpVy3TTJ0zQBE1oCzv+4lS630YZlDccvdsJWu8aZhJ1j1 A4jdw2azZcU6/65ssbGArq7xL1qSS3vl2Ys9jYjtgKBmKE94prMihsW9RKmAEiegJ3y00FPmIsMBh DEOg5o1PLVp3TB2FSW4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfB-00Gphn-2Y; Mon, 17 Apr 2023 15:21:05 +0000 Received: from mail-wm1-f51.google.com ([209.85.128.51]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQf7-00Gpe0-26 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:04 +0000 Received: by mail-wm1-f51.google.com with SMTP id hg25-20020a05600c539900b003f05a99a841so21225584wmb.3 for ; Mon, 17 Apr 2023 08:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744855; x=1684336855; 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=Y9JlsERZxRAysF1OXmKg0b+HpklwlxOxkniV02+TBEI=; b=LAZZxjJsOwUZ/sE1o8nYTYBulM25lMrgdyvQurhhvYpFH/Ww7bS5AFP0iesQaoR7oS 4tH93IMi/1lGcgy21Bk9BRx5NiHf1oHHXUElb+vcJbyNyQMGmUMomGlM1KgklJcGzGfA W7Vtwp0fNC5Bt5Nl+FrI8RSTKZC+5QmR1GLTwvp9JbFSshS1yXO1NpoJusiW6b9yplAD TNPqMC/Wp/OTw38CdtCkPGorNzi+1jAXNi4nNzd+k1krBmmwzQL4KiuTf3Iud3NaKzEN a/VOc5A2oUWWWXdctaoWfv0vp/MbTqLoQ/qJMfo8npdhQUBUJaVT2IBrUCeICoBAr8G5 Sl6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744855; x=1684336855; 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=Y9JlsERZxRAysF1OXmKg0b+HpklwlxOxkniV02+TBEI=; b=K0MQvVWHMPVf9cJH4WVVMeIPzm/XtE94ZoXYm5CqArtaR0plUeDu0ULsTbsiRjr7ax gtFX+ec22Bwl67/9/PqTcJwr9Rd3yZIWmlI/lo2aMNBioWvxJSIVPlXtEGbLaBteiuse wG4dHKZ22X0lgy2KFNNTLX09lYEyq+3wXy6Qn1czpOGaZt4BUpDRv1mdq1v6/zf5K4/V GysV4MwQLBe8v8PGZAuOWxosSyOsTTqGTd0oluQP379SH0dqlqiqdeg+1sCK43qhGbsT KtRUiyvyAcHArT4bwTflzNsb32Fn2MTJlf3OSMMYJ/vGZ8Vurt63oEvFrQ+3JyOC5NIb zxkQ== X-Gm-Message-State: AAQBX9fu2axG54fMkIyLKSyULYGWLjdj+hn5QgUM61g5oERIKFsQQrpu jtlmzY8tu0IhJFCMctSyfsg= X-Google-Smtp-Source: AKy350YDjkgW5+FGV2rl9VjXreEK2H0WzLXx9qAi/BtaTOcKaFc4PYiWdODow7vRCsJXq529fvGEJg== X-Received: by 2002:a7b:c8c9:0:b0:3f1:727d:77a6 with SMTP id f9-20020a7bc8c9000000b003f1727d77a6mr3916198wml.3.1681744855421; Mon, 17 Apr 2023 08:20:55 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:20: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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 07/16] net: phy: marvell: Add software control of the LEDs Date: Mon, 17 Apr 2023 17:17:29 +0200 Message-Id: <20230417151738.19426-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082101_704697_9E48E843 X-CRM114-Status: GOOD ( 16.23 ) 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 Reviewed-by: Florian Fainelli --- 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 24853e9a889e..8d1eb4c4e1ab 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, + u8 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 Mon Apr 17 15:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214248 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 95270C77B76 for ; Mon, 17 Apr 2023 15:22:08 +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=4+YNsB7/u0IXiBnBzRsEjc9mMLmitO3hQASLcDUl4j4=; b=jRVRF4FSvr3qLs PFBZQLS6xKIJxV4cDG5rzcMPe1gC3+zeVcgUttpuIvmgIGAN4FoT6uX2SlccXehPPzVI1fWJ5VspR ATZoK1/p7p4RKWhy8xv9iwHI7ATZY3MXms4y2xm6MsbBBBP3Mej9k6e3wqBSjcDGrWCoYerw3n1Sc 9MGDamltqUtyXn+YyTC4PSD7lwwBBm/UX+SySWSYT01A71cNNwn2CZqdBSIa3I2PU5H5SFVX5rrl4 xSaUUASCXjV5ja4g0YpFUAbHAQbE7ebtp2jAezeK3LQpCL4o0OaSelOJ/evx3K5/T4JZPMM03kxO0 UP2vpaFjO4CHUV8kEybg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfP-00Gpot-1V; Mon, 17 Apr 2023 15:21:19 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfJ-00Gpki-1P for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:18 +0000 Received: by mail-wm1-x32d.google.com with SMTP id m39-20020a05600c3b2700b003f170e75bd3so1564933wms.1 for ; Mon, 17 Apr 2023 08:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744870; x=1684336870; 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=0YYZ7SwCQ04rm/iigLtXpTTa80qoaqR0QMHYPp6JmVI=; b=OAf/1088HNqJXQAQBMzqSc1ifdu1eQ6Haa3qlu5QKk99xK7o3cV8+mmTw+1uswREy8 crvqfFOU2F4w9oQorogwnEgaVPC1mmvRK5wciua+bJh36hwgCefw5mivrR99KcaI1yJV HW5JqbzE+O8fDDPMugVk+UUrGXR96hSWGfUd8fxr0IWdCJ6DzH479BNU1QMUB9+hQe1S MPNhB3RaKysqR9O6smvjwWZP+TGELyb6AyvPg1YYAxm3NM2EcEBdwCAYYg1DRc1ed/n7 nDHYhZXtWX2Ncg3e4HhaouuhvBiPnyQaugI7uWS0EUJoz3BJ4gy3sKSSpK87UgA51PTH Dl/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744870; x=1684336870; 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=0YYZ7SwCQ04rm/iigLtXpTTa80qoaqR0QMHYPp6JmVI=; b=b21FjD2AzcF5Qea8VXshri8BFQkWt0PC3D+iguKS+5G1dMmaDw64wWSFyREhJsi+Gu c5wzawDpvxJVvujkjeNTFxLHs9C8hnM12eRuDDronQy4jSMzgGdH9tHF/a7wX1l1iguf yXlhWqQGuuZ8du693LRPDHgFu+GUyog6i9HkQTDV1HEJjoqKDs5BMK2X6H1ATzRHL6IM AQM1yWQA7Nvy84vWhhkBrbNSzly8EfVN16WMxQ+4DOjB9oygrkHZK9y4C97fDzepADOd +NzX6Lm7RlGYbI/pO1m3NuHJDw8cn5aOhn7rhBPJ00nk1fGZIg8iqwRN14G2Kx12R6aN Dgtw== X-Gm-Message-State: AAQBX9fr9z5cgSEiTUFbewIUgv1iJ53qJpGNYy4wqL8CRqXzIjq0AGd1 PbXv96PesgmurwKOA7JdOuU= X-Google-Smtp-Source: AKy350bNkYePTpwHhda2y/bA29Ro7+vCA9c1Zxn6kPqkkwZZcHFgHxInUONl7Wn6rc1n6AS7ElEOrw== X-Received: by 2002:a05:600c:ac8:b0:3f1:6fe2:c4b2 with SMTP id c8-20020a05600c0ac800b003f16fe2c4b2mr4085691wmr.23.1681744870027; Mon, 17 Apr 2023 08:21:10 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:03 -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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 08/16] net: phy: phy_device: Call into the PHY driver to set LED blinking Date: Mon, 17 Apr 2023 17:17:30 +0200 Message-Id: <20230417151738.19426-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082113_473701_EB035DF4 X-CRM114-Status: GOOD ( 16.64 ) 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: Florian Fainelli --- drivers/net/phy/phy_device.c | 18 ++++++++++++++++++ include/linux/phy.h | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 5c1200160c51..538523a7cd51 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 f3c7e3c99f24..c5a0dc829714 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1085,6 +1085,18 @@ struct phy_driver { */ int (*led_brightness_set)(struct phy_device *dev, u8 index, enum led_brightness value); + + /** + * @led_blink_set: Set a PHY LED brightness. Index indicates + * which of the PHYs led should be configured to 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, u8 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 Mon Apr 17 15:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214249 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 44513C77B7C for ; Mon, 17 Apr 2023 15:22:11 +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=0Vl7M/B+bL6A4SoWFJ9ribABwGViDHzGVueDgoZQvAo=; b=1ghz1lJDUp6Lyl QJFw1/SamG7HoB7V7xtvH+6LdbVuzUIb8+PFmVMrzRBLgPyZHN0IuHcxtQzYaYmr8qfPRxSLBqjpJ /e69MQ9YTo65MrioCxANlAXIbC+doN6ioT2BayqkILj+8tl4mY3K/OtBFX7bCq0TegbBb0Mk7kNcr JbrE8bMLLep3E9wmqNVUGzsygFVlwWyDIp4C/MPW6fMlQksBI+fna93QQwHBWevHUQzGEcsDRu0qZ TmNknLma6LuZMDw2ofgyUWont80kcHdBTciL8CDfj21CO9JUuQfGzcmekK/Qn3sYQ0tQVt1Xnyayv Fu8XsdFDK/aeLXzoQMeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfT-00Gpr6-2J; Mon, 17 Apr 2023 15:21:23 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfL-00Gpmg-2U for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:18 +0000 Received: by mail-wm1-x334.google.com with SMTP id v10so7367698wmn.5 for ; Mon, 17 Apr 2023 08:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744874; x=1684336874; 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=E1ISj2J2PV03tP4krHTpRHjfXqHsXcJJVLFtazUDZkU=; b=B93Ol3o2J5Ek8f9qxd0WyFR5pu8RcoK4bPoIaVzz5FOjINaPjMdIqbXFz/hDOyjnQR MJEuYDi+D6GP3/bkUGLMAQ7/pvBFY5xCfKj0p8hvE0WdEJff8qg2h7oWbLrK8frRhnuC t6GZAhlfrz0wzhNoJn94qXxc3R0YsqYNiwEpOOd11FLdpWKCUqTx82VjZSpVsrZSIKiO hpmg4bKHhgPr7UI6i+gQS9NfZoHu/0MdCUZnv6VHmQB0uOBv6h4LrMsOhJy7nORod0nd PcOAF9O5iaNOzLzL6vLISO+FtlM1W4r7gEr/oiQ8GFpjMRl50gjBC5hny9DuEGza4Av8 tstg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744874; x=1684336874; 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=E1ISj2J2PV03tP4krHTpRHjfXqHsXcJJVLFtazUDZkU=; b=haUOBsg+18WcmFb6YWl90e9ZChDgNowEU6kkjbCA/5Qb+ziA115PGukzg79H02hJIi 0asU11VCOomUKelcv7lDYce55AxJ+2DOW8FveAocuCE/yObLEkhQ7GCvUnEewiF1tOg/ +P4dSdM3RoUdHzzagpacFptV+tLcBXISOgBtHVf+CWy2EO9rb9owObJqK7pLJ6Z0MFuR aOWwwAT4SMRhx3XiIIdt17LkN1Bxet1ZrtP857QYpIX/YNLoX9kMFXtP6JaBIuo0o5wK 9TIvX7zSm0uMLOHH+KLNo0zFjIxfbEyFFU1A9m9eB8oBoz+FZdyB8h1YCNyDtAoyQq4w o0Dg== X-Gm-Message-State: AAQBX9eA+H0CORWo/oNbt0sqqBukySpXuNsY8rMp77IDJ68BRAskIBLz Syx2TTwVu4dRFSbNjeEntUM= X-Google-Smtp-Source: AKy350aEvCB4SkeGEMEgvBixg+WJApsZ++SBQQbR/m8GUqCbS1JahWn+Vkxap90hMcHbMQihvoCB/A== X-Received: by 2002:a7b:ce10:0:b0:3ed:2606:d236 with SMTP id m16-20020a7bce10000000b003ed2606d236mr11175269wmc.38.1681744874295; Mon, 17 Apr 2023 08:21:14 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:13 -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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 09/16] net: phy: marvell: Implement led_blink_set() Date: Mon, 17 Apr 2023 17:17:31 +0200 Message-Id: <20230417151738.19426-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082115_810086_09A26DBD 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 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: Florian Fainelli --- 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 8d1eb4c4e1ab..cd5d0ed9c5e5 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, u8 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 Mon Apr 17 15:17:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214346 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 5EABEC77B7A for ; Mon, 17 Apr 2023 16:31:05 +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=ckOn2gmNzQIMdbR0ovNuEgKEVr6Y8FlTsBu6OkmL4vo=; b=GXB2McVedZzQYB JvDar/MovwmWgFtlcU7yWd5GnsiT+RjJssXCeaxLoWfwr2hhqbFmIUUN5sEzxZUKInYba981GRArO IRqhG7uBSXgFnZ1Zz5KPOx+8YBDMEfnmtlGS0HJXbWuXOWQUAQ3Ry4Tid3B0mwCj3k7ERGByt0qJO jizfSS4S5qPAArEF5Ejmf0wle9CPiGCqCKU8UIYnDc5RMy9ziamI6qOcHVwQ8Yq0FPxQ38Rz8l4w7 7yWm9NTbVr1Nbb4zR51f0SVp+u1KrB+c+dOPGB2rhT+qyY+x5Wg0vT1+EAALzZFFk/VBZWCO3BEtj pQ7KpLMEI72CdUh49bNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poRkC-00H3wh-0j; Mon, 17 Apr 2023 16:30:20 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfT-00Gpos-0t for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:24 +0000 Received: by mail-wm1-x332.google.com with SMTP id v3so961271wml.0 for ; Mon, 17 Apr 2023 08:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744879; x=1684336879; 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=cMovAHVkjGy+uoUm4sFkhEHcZFqfs7jnbrYZOptwaFE=; b=GEyCjFMs6FDONVol7pOzUDp+XIe04EwVoxuXi0pS0E7bTDjH8aGGxA1Myzn7vGb+UJ V1qlLOh+Bo194NEzxtaZFkoZ0t5HVyAbAcutsaq31GpjfMkzq3bpYEWE7KwxoBDcKQOf nML5RiLR9iODUfE191pPUP+Emj8dBrChuRPXkqjzaY45ZfeeRL5NokjC6ROW3GKDOm7b MXDTbCWSu0FJmPHbBDBBEZIxOwIKJ1kHnbKpu2GXnqL7HNWMPOSBrIdBkHZRMdZFM2/2 TwvBPV3+JY0EA3+MQdIcwsZndaDAqZB/KSAuF0xGPBqX6V3enF/6P9fMyKga5COgsOVn 9A0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744879; x=1684336879; 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=cMovAHVkjGy+uoUm4sFkhEHcZFqfs7jnbrYZOptwaFE=; b=J0Y2SQKkbi8mMpGxSmgUYLsgM7IZChEsP3Vx9CKVfSt6tMMITab8Vxn1TsDpxOLqbA cOAYPLLmmc9Y4+QTHwkUwqUZIWvRimgwhqfDXWRDfvSnEQS0/vR/iNTdGUGiaZ9vQ0qw aW6ff/njer+xT/mmsfm6OIZtprhEAqNwQdt/QhCFGVVLD36d3hsIkIjqXuAwyL1ffsE7 45ucf6bEMntQTvWtPdcbsJUMiiijTHYorwBNX6DmZ9urUjGOoAAhjQhbCYsVpIIJqwR+ m0I46UTM5ei65g/R7MmpvItD8JSK0adeMHn5euHa6LHSHZD537RyO/vu75JB+UQvC8+N Ywbw== X-Gm-Message-State: AAQBX9cGjYUpXjGDIk114Qmq/9U+wQi7JKEOOZbjQ4em1gkVr4kAVtr8 VnH+Bse/sIeWKNLpqcS2BUw= X-Google-Smtp-Source: AKy350ZIJ+TrDF82kD2yC1FZXavbmN7VsLgQmu6R1Y9UZwTNr/oSShLvVRM30x8ovWzrSNBY8bb06w== X-Received: by 2002:a7b:c8c9:0:b0:3f1:727d:77a6 with SMTP id f9-20020a7bc8c9000000b003f1727d77a6mr3917296wml.3.1681744878520; Mon, 17 Apr 2023 08:21:18 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:16 -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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 10/16] dt-bindings: net: ethernet-controller: Document support for LEDs node Date: Mon, 17 Apr 2023 17:17:32 +0200 Message-Id: <20230417151738.19426-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082123_313845_34401111 X-CRM114-Status: GOOD ( 15.06 ) 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 | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index 00be387984ac..ebc2646ab5ff 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -222,6 +222,41 @@ properties: required: - speed + leds: + 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. + + type: object + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led@[a-f0-9]+$': + $ref: /schemas/leds/common.yaml# + + properties: + reg: + maxItems: 1 + description: + This define the LED index in the PHY or the MAC. It's really + driver dependent and required for ports that define multiple + LED for the same port. + + required: + - reg + + unevaluatedProperties: false + + additionalProperties: false + dependencies: pcs-handle-names: [pcs-handle] From patchwork Mon Apr 17 15:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214250 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 DB608C77B76 for ; Mon, 17 Apr 2023 15:22: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=NBS40oya9Vz4Ikd3f3WJjqHNdYgPgDAtYEg/i4Ye5/4=; b=SNcjZZFaH0mgVW Wu5dV4OgmKUMSk9LIXCl8od3kpyw6MyhcIHlVYlXVhME86556vCK0OjjDErlDclJu42tkaHS0TQzj NLbKgUETMhZH1adRwmzwg8ZQPCB3e6FUY3HIFGa+ZaK4t6aTO5R0pgYkiHJYjWU27GXlLdNMNB36Z wT4RODuvhfIfe+kBSdJvrZMSjPgN6Hcitee2Y7H19tNYy+b0LgaMzOWubFlBUmUMpEzzBchW4NczN BMxVUIoVLhzcskS5fpew4GyKXrWIBCKua9sX0WXJXg6EzQCVfBjaV8rTzTKx4DdMVX0zB9kXQyIzq KpEK62FvvyTdVkLv2ydA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfg-00Gpz7-2w; Mon, 17 Apr 2023 15:21:36 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfX-00Gpri-1Y for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:29 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f0aabd1040so44214185e9.1 for ; Mon, 17 Apr 2023 08:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744884; x=1684336884; 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=rV9EcelsXiO5njlxQQAeC/3UMAuEjghxynP/HIeqk7E=; b=Xo1Et9VzokF1Un+UBViXcsNEPqexZ3w1hh+5Ne5SfV/nSjtC0VD80dSqt7r8D6kF01 tlhx2suXoiUoRp3QpQPBAw+u6ZSpF893YWiaMcIASTRxLFaYVJn9TYyYLAozz8127kd7 8dZz4rltnsJncm167nLsmlNOiCAElrM/o8tAJNqRdZ6HbQkxjS7WTvnfDyDN70y0sk7i uMmsOv2tmeAuaUifBkxWvckJ+biyn4S3gAGCT1lpDcb44fVmink6yBF2XzGnuQGFhAwT m+e0OFcfiBGd/RLlpRYMo39eOig1+Wf5mx9Rgc9RoLEuar5g0a1RxlMP3qYdFR4BJUi5 Cmmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744884; x=1684336884; 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=rV9EcelsXiO5njlxQQAeC/3UMAuEjghxynP/HIeqk7E=; b=Y8wPe+OuNTz3klex2SvZNRFK66Co+OAy/tuLaLdnssUuwxaLbEIxIpxoBzvqmRI6gJ /mQX7EfLsVaDBf1eTFiThWfy3CuBY5iVXyijQEC2SLd5Y0+rqql0ynnWiGIMLX4GqdV0 KG8DUJiWEB6yidHzIvinv9fFIhs4YIGCX4wHtTyRIY3U+j6Ie1qsoEssJBDw7EONrme9 eR3O0f/ndLBkgtkclNe1AZjWebVsAFX/56q1Yz7CoXeaBOXO0rV6G+jVdG1ozm/aAuiD Y0gAO9psI6dtAGt3a8W74eRgDv1atWLxPhvyc0hJlRfu1FJdHxO7zE5YTs/8mcJ25R/R fGPw== X-Gm-Message-State: AAQBX9dfiBzXVgMZ+DuMwMaf68n3lkPYNMg3hQi5bwTEN09RLSzz7B0O 96HHavR26L8dsFzpyC4O2us= X-Google-Smtp-Source: AKy350bxMNBPUgNwgAazK2IDboqf6/FlMetlBFozI9HUlvAID5orG7cGpsyH5XC2K1T8JmHvma6H2g== X-Received: by 2002:adf:e702:0:b0:2fb:b869:bc08 with SMTP id c2-20020adfe702000000b002fbb869bc08mr683848wrm.23.1681744883644; Mon, 17 Apr 2023 08:21:23 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:22 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 11/16] dt-bindings: net: dsa: qca8k: add LEDs definition example Date: Mon, 17 Apr 2023 17:17:33 +0200 Message-Id: <20230417151738.19426-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082127_532305_334E1AA6 X-CRM114-Status: GOOD ( 13.52 ) 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 | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/net/dsa/qca8k.yaml b/Documentation/devicetree/bindings/net/dsa/qca8k.yaml index fe9ebe285938..df64eebebe18 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 most 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,25 @@ 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; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@2 { From patchwork Mon Apr 17 15:17:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214251 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 AE2B4C77B76 for ; Mon, 17 Apr 2023 15:22: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=LB1sgYmunWl99gQ6Ba8lBnwyHtCQQtabTJk/WhI/WFs=; b=g6p+kVYE+67eWZ jkEX2/7SY6CnmIbxUQoTDYpkt908W46Zq1YrZvjVmto3cQAuTGL/YeQxPsadD75hx5GAqhi9DZJYD TwspDXfsjHrafB932h58sqUcyWriNSLvLHJzR9rVPw7OUSl6AFetXXJsQM6MUU6u+gBZH8Zw3Kwp8 x06Rs4cFg6pWp6ck/wBuT1jSkMQkOifvOuoMj1zJlcVsE8I3rMD8QjSHTkfLwTpT8A5CkExk9M/1s d1ZuabMuPfUZUxKIL+Rkq4iJ1JLUzwAUBfz3ejYvAambkNwyfzJvbXlA+0oQj1oPBnOGwDw8qO68e 9vpYx8quipaJL8wr0jCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfi-00Gq0P-2j; Mon, 17 Apr 2023 15:21:38 +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 1poQfd-00Gpv9-19 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:34 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-2f46348728eso991860f8f.3 for ; Mon, 17 Apr 2023 08:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744889; x=1684336889; 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=uTKNAaQmPuBEEmm7r0M/hJa5foC7EUK457tHpsrXZIU=; b=Pz1ZG12LAfMDtTVcvyrH73KzKnUfvemue6XOc7e28NCjE+syX1XIim9sSnblhUIm6f JaTXeEhStfPUql4+uio4lJkx7Ft4iVyR1TeaQzwA9iwyq1+EBNzaTgJ9InZ1fY2rfC8i DXHcLrlFtN+h/bNxpvEdaxl6uBvCZKLmMrD5NTT52dExjMz6w90uajm60OSHuegjjGz0 QLNDyfAsRQLjwK2yb5Z1ohuG90csdSkzrXlpobdskkviPEz1fP4JIkd67FugeRJMr+w4 4iGk+Jfvhea1tf2J2rY6l8kOPc0OknFwc64yxh2e1dTjSMwqlU9qd/XXgq/Pn7SFF31L l5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744889; x=1684336889; 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=uTKNAaQmPuBEEmm7r0M/hJa5foC7EUK457tHpsrXZIU=; b=dQGLybk5BSWhoio7+JKcmENRQUtn1NGFH3uew0B4nbtPcxcPE2sAmksiK0hdV7oB7s vX5v5rSmzCu1VxRtrmKB9JRHjmkoHuA1wlPN8EEjsk0hAnxPAvBwdHIFkwuj4PNbYIaU Rv7Q9gJJgcq9+XrlCLx2a40bWVlpB/qOAWY2dhXJRfcClZaG8euex+ngYFTs/hLrh3O8 pXTV21647tpiRpHLM7mWszAUskcW2grvHNno7j8mwdikW9Qi3U22cxRgSem5LkGRkDxO uDRSn3BEVmQ3EA17ibMbe7vTUvyZ2ZJJXnyQtFevHLrw8mAyHyQZvSkXpOFzaMOeurms T6tQ== X-Gm-Message-State: AAQBX9eYfyeWKJuHZG2hCry5ELNozR0pV1lUoc0g2Dm8ARzHyPQ/VlkY ux0PLsej4sfo5+CmZzki+Ks= X-Google-Smtp-Source: AKy350Z1zkLcEctazd0wxeEfObLTI20cnhzReBwbbWQ5c6DqPtLWI6i51ks402Gf4aqHkIzDMBeZbw== X-Received: by 2002:adf:e54e:0:b0:2e4:abb1:3e8b with SMTP id z14-20020adfe54e000000b002e4abb13e8bmr5261848wrm.25.1681744889263; Mon, 17 Apr 2023 08:21:29 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:27 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Jonathan Corbet , 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-doc@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 v7 12/16] ARM: dts: qcom: ipq8064-rb3011: Drop unevaluated properties in switch nodes Date: Mon, 17 Apr 2023 17:17:34 +0200 Message-Id: <20230417151738.19426-13-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082133_392031_EE601C0E X-CRM114-Status: GOOD ( 12.59 ) 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 Reviewed-by: Jonathan McDowell Tested-by: Jonathan McDowell --- 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 Mon Apr 17 15:17:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214348 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 152A5C77B7A for ; Mon, 17 Apr 2023 16:31:17 +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=GDaF/k5MEtFQ7gFj4d0bDKEciTL3UOx44/8Pt29glyU=; b=PRKYouI0MZ/pd6 T3miAeuX0t4ToQqBmBWllUAexubP6zm+0/MVHihR8UG/idaPdcMu/9yopxJrbJ9NlDWyNMETofu9g 5f7ZvIdX+O2TJ2gXd2TzwJ6RJFIaOGU+QBt4SqkWF5QAi50oO15c4EJc1Nlnxtxdbnyx9x50URDE2 djrBZo/YmbXNCF2bRKBVI/ZsiLc+RjICBgsbFgd8RMUbQdYewU7YDeZgIGxJreEONxwz3Fd3bhtEk kSmZ5ltglK17fxfMLecojfRoJuTiPl9+2yu75fLCHNUNLyT4umLpVgzsFs61gB8j8ueCJZRF2uiZs ltfkQnIMmiM50je/wF+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poRkD-00H3wn-0R; Mon, 17 Apr 2023 16:30:21 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQff-00Gpxs-1D for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:36 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f09b9ac51dso44193815e9.0 for ; Mon, 17 Apr 2023 08:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744894; x=1684336894; 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=uo9NeRox2kKaV6EedLI2eZW+lysXw2QxnOyywslULt4=; b=emXly7tMcVulCwtHdgRBKdzlZK74cPjTMaLFLkBeS5R/Ej26fWeR0jwlKJlYtRhduh ULn6NyC1S9BxTPiO8QcFWKgNv2lPmbOzTAyDaTcfBWM8Qcg+vS5KD26itECBt8l1x0xc Agu1iqMmXS1YvM+/xiCG4JlAB023R5TmPTdSl0FrvrmSIdk93toMXZyrTshlfEUT6HZl QR8rCckx/3vdxbGMQby0eSHnEh3Zm/y73xSlGEUd4FKcJP6/ZCwR+Z+f+9oYiC1gX54D 8DDKetmF7uVjnvrAlbGpjM9Jm2eW4RGOJAXQ/+KnOTcPfv1PQvcq61toLN2RjDnXS5Br FEhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744894; x=1684336894; 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=uo9NeRox2kKaV6EedLI2eZW+lysXw2QxnOyywslULt4=; b=DSZGrZkuXu1cOYhvVPwkDdkfY2H4IhivrgPi4Cxgp9X6jpJiyXquraY4S8+iIbZy1s I33P0lojgCZMkY+Cnb1ID9/KKggl1EkOfDN3f8iR8E31CQbS83Tz+tVRo/ls0yC09M5J RFbmd4y+aVn6NoTDa6pkYm+6u/Dn9geFtnVh6eTDKd5lmx9nocEc9SVre3gqHDKlbzne RqmKCRTAi7uBoUna8GHFUD8SIv5b/Nu1Li9xr4ZG/SfMOnd+U9Ctj6nn6KwN7cGFT96a 6f/DtYn4kuXEUuXiyMuh2PdCU5CRTcCMHGgHGw6ekkO+rNPDVuIiH9VWKorDVpW7Mr3Y TCmg== X-Gm-Message-State: AAQBX9dHve2VEGmNufXgkcUXJoGefa0Ol06U2lUgG/6BVR+cMi4rU+UK lsAAWyha7QnnPd2MnC0qhK0= X-Google-Smtp-Source: AKy350ZkN8k4WRz16WTIl1fWsH+BlMhqoCkn8fA0qyImErw0tC1bPi0oEm7HUBt5/Z7wylzg4/LhrQ== X-Received: by 2002:a05:6000:100f:b0:2d9:10e7:57e8 with SMTP id a15-20020a056000100f00b002d910e757e8mr5223990wrx.16.1681744893773; Mon, 17 Apr 2023 08:21:33 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:32 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Jonathan Corbet , 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-doc@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 v7 13/16] ARM: dts: qcom: ipq8064-rb3011: Add Switch LED for each port Date: Mon, 17 Apr 2023 17:17:35 +0200 Message-Id: <20230417151738.19426-14-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082135_415150_78F84548 X-CRM114-Status: GOOD ( 15.47 ) 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 --- 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..4d509876294b 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; + default-state = "keep"; + }; + }; }; port@2 { reg = <2>; label = "sw2"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@3 { reg = <3>; label = "sw3"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@4 { reg = <4>; label = "sw4"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@5 { reg = <5>; label = "sw5"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; }; }; @@ -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; + default-state = "keep"; + }; + }; }; port@2 { reg = <2>; label = "sw7"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@3 { reg = <3>; label = "sw8"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@4 { reg = <4>; label = "sw9"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; port@5 { reg = <5>; label = "sw10"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; }; }; }; From patchwork Mon Apr 17 15:17:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214347 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 66C22C77B7A for ; Mon, 17 Apr 2023 16:31:09 +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=wR+iiRzi/sAQ88mgskdNVxkIXcuTyRFrTS4DepcEkjk=; b=JM29usmuDaD3AB Nw0vTcTkolvjJtoWxt6tsyD0um5Btdhd55g+1bL9VMVCxnjMjl/cSjDwgJ2KQM349Q6i+ZGA2PQqX DrswkJXOKq92YTQWUJTiEo8mz7q0Mwgo62M5WC02l+Nt65Qg4LTNsKNY6xxMMOfQV44SqwVYXZ6sa Zpjh1HeRkZcZZDsRfR/SRdwLHd6RKWDZQdpshUtry+FAXzeYZNfSa4sKR2D+7CNIZNKQ5lnrQ0q1E ACvxMszFDTxeNs04gDefYTScPtnuuAhwVMkmJCeyYXSoEuFWC7EQfHrmQm+dNqea8o5k1zeM9nrm3 ZgkgyOxWN4dsHcuHFTLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poRkE-00H3wx-0A; Mon, 17 Apr 2023 16:30:22 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfk-00Gq1C-1M for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:44 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-2efeb5f8759so989184f8f.3 for ; Mon, 17 Apr 2023 08:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744899; x=1684336899; 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=uJTkEZZQz1Xm9DGAcdJUpopRWa59pUHGOjNQ9ofW+JI=; b=JwvmejdNADdlWH3gz/HGxo/4ta+utT9srnqx+wcn+i9SWy13iXfdE2mS1uFt9bbind oE9yDqjIEqBeh/j5aCqFVDmZUcPXMn8tTzrAElS+jqTXOydzepW8dDX3tQ0f59A5rdi0 FpR3XBLDyOBUBneGa419h8GU3ZTmYTJbspAnM6t7llqvc6mMBV2OCMLLB/xN03NuJtmh ZO00L4LN7ckJd4nSRoniYrePij4aDHAZBEimey1FeGqPgJtxOA09iXYe8pfOkcICFhEX jnzvsWYMmV56/AbLL7j3xCinsmf0+4T3jUKQqLBwmV3Ef39l/87QKpF29zlph77b2++I y46g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744899; x=1684336899; 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=uJTkEZZQz1Xm9DGAcdJUpopRWa59pUHGOjNQ9ofW+JI=; b=OaaIJ0q+nA+IGO81MrefqdK3CKT5OUAHKji+FbtP4pZVdFR+JkX1e/UhOv/3rKgdUh ICLECtF0CPLCRhuDqarvlF8JwKntRfkwOhTrgeVl67itj46aQ7tT2nZtN+d4MpGOZ05Q 2iw38+9o/OtATcMPSs7PXd+9U22DczOKzOEQPC7vt0IOznnLYoLlvdWsN06fvEo6j0XN NeEfAa1669q65kS+TRxh9E9D4MjFzRPUDsUWsDQJoztTRnENeOsPztOWQ6HvLInkbbVh DF4WhOLtJVhoFEh0HVLRdq70Fwt8VHvsSOIJYcaep1xaVIROsqX5oyIUZf61HaIFpXHJ rY9A== X-Gm-Message-State: AAQBX9ea3LagDqPQA+ZWWpsFM850fVQmUYyyAir3H0EpnkhFCOsjyPZR y2aQKLw84rEkQZqXm4KV1pw= X-Google-Smtp-Source: AKy350Z1iK+OSaFxPXE4V00SsLukB621IdcQfbrYZMVMsjihtpFkTemQ9mgTw5xgzHNxbAIPf9drtA== X-Received: by 2002:adf:f089:0:b0:2cf:e422:e28c with SMTP id n9-20020adff089000000b002cfe422e28cmr5443129wro.42.1681744898817; Mon, 17 Apr 2023 08:21:38 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21: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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 14/16] dt-bindings: net: phy: Document support for LEDs node Date: Mon, 17 Apr 2023 17:17:36 +0200 Message-Id: <20230417151738.19426-15-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082140_482099_C69ED665 X-CRM114-Status: GOOD ( 13.96 ) 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 | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml index ac04f8efa35c..4f574532ee13 100644 --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml @@ -197,6 +197,35 @@ 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# + + properties: + reg: + maxItems: 1 + description: + This define the LED index in the PHY or the MAC. It's really + driver dependent and required for ports that define multiple + LED for the same port. + + required: + - reg + + unevaluatedProperties: false + + additionalProperties: false + required: - reg @@ -204,6 +233,8 @@ additionalProperties: true examples: - | + #include + ethernet { #address-cells = <1>; #size-cells = <0>; @@ -219,5 +250,17 @@ 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; + default-state = "keep"; + }; + }; }; }; From patchwork Mon Apr 17 15:17:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214349 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 86FA0C77B7A for ; Mon, 17 Apr 2023 16:31:26 +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=2AbDHwlzwHclkmliOmzzJp+jnsPng9up02KWCPLKgik=; b=FBdTLSXO0d9q7Y 5KP3wzhwdNGpmcEGz3DmMBYEO3CDoA1VXXO+rPKhIQx/pXp7CizmBbU7xkB2yeUsgFyTO9Y5r3gfl 3OXbNzb1skF/jmFsxbqtxCcJQFLj1LQ94onsT2tXJTuuigqG6VIdp5ayW+UxCdaXTrdRswUTJCuNj tvSD/xcrk5cxqijIONKkZEHCS6a7315WQg3U1XRmgSzXhunYLIDI5YRhGo6eAXFgPe3SnagNXaLR4 JetmVFF5Zz3PZLyOm0r6H6A1yqIY63Lh77AZekojcK3pZ9Od7Eapw36H8wT99536xujK+EnxXVBp7 kJ3U1Ws8ewB3X1Pi076g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poRkE-00H3xE-3A; Mon, 17 Apr 2023 16:30:22 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfo-00Gpmg-1S for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:46 +0000 Received: by mail-wm1-x334.google.com with SMTP id v10so7368733wmn.5 for ; Mon, 17 Apr 2023 08:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744904; x=1684336904; 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=LhGkMARR1a9DNNYz4k2QeApxkMgfh0i/guZRUWxeU60=; b=D4QSsQBP+mnP5UtJNy9wwGzv5UTiUqX/kMD5cCgnHxGH7w3WR2mDK73Hq3ieG0j4v7 N7tFh9E/dBzu3hhTT3CuH3IT1ZzxyXd3ZROnbMO/UKRrSxTElOjoLSAbzjwU3bjc7kbZ b1Xc8I+vEgpfJtXxctiCa/0hbvDoOX90GG090xY8VH4o+bHZlNr7sjd2VEqwaZ0mWb0C Qpc1UxIZPVEsfHVvZvGR/l+umqBSmUwZ+OwDeHXbRixLmB5ccC45WI3+sr3ihSnQ9SGs 9xeXc5u8WuJgJ/0Z42JanZJd0v4uuSXGh/oZYHyvIJdh8+CThaXeFcbUS2zSrCxYoAME bAkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744904; x=1684336904; 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=LhGkMARR1a9DNNYz4k2QeApxkMgfh0i/guZRUWxeU60=; b=JlIBMtdLIiYPw+KYAEsrn6uqA2cFEGVa6H+dpisUHwoDPWg0wW40xrXVpjCbMlA8HN 8EKf6b2f3M8HL+pg11knCk73yyfkOPVH0DdnqY1ksEbYxwtomFtkwom7KF+F2G68zzca puQBhf505RO87OziSwui85TV2LNppx1Huukhyia0lHO+G2UnG2mR3ZkZpswN3Y7sIrSV fzhEzN3Ga0jeGTtePUdCgk8YRzkh487ar/wcXnMWiEPZhqcTyMkhCV4ewMIhmwxVSOc7 WWx6rtu6SPQLAUnQEk/W4XFUZL69zQC2U9hQF+znPOEbPoyccdSvRFYRczxf3y8y73py eKdA== X-Gm-Message-State: AAQBX9cFvfYTxVblUAIMFOz/BP/ygKX8HkqfDRcEfl6PEb9o0/RBZe3k f3FhQbqsFEpNFqb13iK//jM= X-Google-Smtp-Source: AKy350aEH12wQLoQ17P4yBixcua0xBsFibbcv+7CC1rPFi+97EIoA2sD6RLp7ulAuzNKvCimm7Uj8Q== X-Received: by 2002:a05:600c:229a:b0:3ee:9909:acc8 with SMTP id 26-20020a05600c229a00b003ee9909acc8mr11277706wmf.32.1681744903477; Mon, 17 Apr 2023 08:21:43 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21: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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 15/16] arm: mvebu: dt: Add PHY LED support for 370-rd WAN port Date: Mon, 17 Apr 2023 17:17:37 +0200 Message-Id: <20230417151738.19426-16-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082144_526053_398CC766 X-CRM114-Status: GOOD ( 13.80 ) 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.y 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/boot/dts/armada-370-rd.dts b/arch/arm/boot/dts/armada-370-rd.dts index be005c9f42ef..2586f32a3e21 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,17 @@ &mdio { pinctrl-names = "default"; phy0: ethernet-phy@0 { reg = <0>; + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; }; switch: switch@10 { From patchwork Mon Apr 17 15:17:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214252 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 18BA0C77B76 for ; Mon, 17 Apr 2023 15:22:51 +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=BzRtzmTVHNVX68RrsN9zAL9dC/sSSoY8OYuLR4bfeI8=; b=fR/uGSYsucCEuN kqgViFJ26nGhMRgVFP8z1X1Erp87SyLU2KzVuoPiswJXrG9L6PxmL5gA1kM87E2p5wFf9S7uJh/yM z/1EE4V3/Yyt/MbS/PMshi7IA8bezmqQ+B4trIo6Zu9gHB2k6O5mp8RXkh3iV6ysB8UNZ3Pnn0Wfp Wxxpuifaj0jfgVSowxh9FDHgjI88ih1TYEvpHPRNhZqx4OeE9melq9I5smXc5b1VktE1sDhxr8PM7 00Uw3Nvtk+Pz2/KAu/WT7HJep67P0te8OVtGIKVUkeDAiuS03+qkcMRxabo13iZM3fbE83H39MLoI 9cKJ/Pmy1hSSQHmCuBIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQg6-00GqGH-1K; Mon, 17 Apr 2023 15:22:02 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfs-00Gq7a-39 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:50 +0000 Received: by mail-wm1-x332.google.com with SMTP id he11-20020a05600c540b00b003ef6d684102so12057697wmb.3 for ; Mon, 17 Apr 2023 08:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744907; x=1684336907; 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=OppusVDPTknxRE+RqoeEhB3WmCzyqWgv0cWY8mHzosw=; b=h6hEuTnPiYwjVilzvawD9txg5cYumU2jRZEeA6dcFsFHY12SyfhRYGAN+S1UpJ4lxK qOM0iTNJBCE/w5l7Y6tQWN6RHt4HFS8pOlR/yxpD15rGjrfoUcolPi9O2Xvao1ny/k3+ c9nclFnknn4VwLTZ0601PDW7GqRc+MiTaETjT8HUxpac7OGmcimHdOrN8NraF5V4yXPC sWxPJc2pDTkifSkEmmxApCpPTZsPqDf5fL86EyutpXsdCY6mVE9t35tCKEdCmo7LQ5NH Ixk2yYGdG2UrIBJKX9xOZerSd2ynErllNKO0PYU5Oqcc1dbSU7Q4YLbXRrL142gsPPXZ fEsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744907; x=1684336907; 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=OppusVDPTknxRE+RqoeEhB3WmCzyqWgv0cWY8mHzosw=; b=fz66KcIjYnU5Ikln3MaabPZvCsnbLdv5RCCJ3/gtCY6AhetiuTgRAVeK3EwCyIGNys gcNOKA3Ip6rzf3p1eeC0/9R2LVkh9FKOVIWk7CO4xu+lcn0QzksPumC3R2T7sTdCo2kE vXTPEfU84O5FaZ0FVzEqws8SQMLeWDaOKeYX5ETJ0k1c8aIIO2HenFOCU+Bw0eHgQV8P kQNQIu+5wjAHjDxF/x7qE2phTuJBJ9KE84Up4ZvBxVcC/J14Bew+QQYmZ3SgAnltOqpV cZ7EE4ZXIkszfr4iOGwjf+Yh40zazCU72mc0KzO24cqKrse0ZO6ZoZ4zBlknKQ3CBMlQ 6bgg== X-Gm-Message-State: AAQBX9dyBkQ7J7rVtg6M911OOT1ZXd7WyndVHqp8FeudBrCvj3q2CKxF 4R4YkhQ1F5N+rd8cuR6ADRw= X-Google-Smtp-Source: AKy350Z6k141t5UQYKP+f7l2sYiLN+AXLz6Ow2fM5djSVBa82EIaIGrUwqCYpmHiVYs8u06xUgL9mQ== X-Received: by 2002:a05:600c:204d:b0:3f1:75a9:5c0d with SMTP id p13-20020a05600c204d00b003f175a95c0dmr1645560wmg.26.1681744907449; Mon, 17 Apr 2023 08:21:47 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21: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 , Jonathan Corbet , 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-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 16/16] Documentation: LEDs: Describe good names for network LEDs Date: Mon, 17 Apr 2023 17:17:38 +0200 Message-Id: <20230417151738.19426-17-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082149_011197_6603F2F6 X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Andrew Lunn Network LEDs can exist in both the MAC and the PHY. Naming is difficult because the netdev name is neither stable or unique, do to commands like ip link set name eth42 dev eth0, and network namesspaces. Give some example names where the MAC and the PHY have unique names based on device tree nodes, or PCI bus addresses. Since the LED can be used for anything which Linux supports for LEDs, avoid using names like activity or link, rather describe the location on the RJ-45, of what the RJ-45 is expected to be used for, WAN/LAN etc. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- Documentation/leds/well-known-leds.txt | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/leds/well-known-leds.txt b/Documentation/leds/well-known-leds.txt index 2160382c86be..e9c30dc75884 100644 --- a/Documentation/leds/well-known-leds.txt +++ b/Documentation/leds/well-known-leds.txt @@ -70,3 +70,33 @@ Good: "platform:*:charging" (allwinner sun50i) * Screen Good: ":backlight" (Motorola Droid 4) + +* Ethernet LEDs + +Currently two types of Network LEDs are support, those controlled by +the PHY and those by the MAC. In theory both can be present at the +same time for one Linux netdev, hence the names need to differ between +MAC and PHY. + +Do not use the netdev name, such as eth0, enp1s0. These are not stable +and are not unique. They also don't differentiate between MAC and PHY. + +** MAC LEDs + +Good: f1070000.ethernet:white:WAN +Good: mdio_mux-0.1:00:green:left +Good: 0000:02:00.0:yellow:top + +The first part must uniquely name the MAC controller. Then follows the +colour. WAN/LAN should be used for a single LED. If there are +multiple LEDs, use left/right, or top/bottom to indicate their +position on the RJ45 socket. + +** PHY LEDs + +Good: f1072004.mdio-mii:00: white:WAN +Good: !mdio-mux!mdio@2!switch@0!mdio:01:green:right +Good: r8169-0-200:00:yellow:bottom + +The first part must uniquely name the PHY. This often means uniquely +identifying the MDIO bus controller, and the address on the bus.