net: Add basic LED support for switch/phy
Subsystems (8)
Christian Marangi
maintainerv3 cover net: Add basic LED support for switch/phy
This is a continue of [1]. It was decided to take a more gradual approach to implement LEDs support for switch and phy starting with basic support and then implementing the hw control part when we have all the prereq done.
This series implements only the brightness_set() and blink_set() ops. An example of switch implementation is done with qca8k.
For PHY a more generic approach is used with implementing the LED support in PHY core and with the user (in this case marvell) adding all the required functions.
Currently we set the default-state as "keep" to not change the default configuration of the declared LEDs since almost every switch have a default configuration.
[1] https://lore.kernel.org/lkml/[email protected]/
Changes in new series v3:
- Move QCA8K_LEDS Kconfig option from tristate to bool
- Use new helper led_init_default_state_get for default-state in qca8k
- Drop cled_qca8k_brightness_get() as there isn't a good way to describe the mode the led is currently in
- Rework qca8k_led_brightness_get() to return true only when LED is set to always ON
Changes in new series v2:
- Add LEDs node for rb3011
- Fix rb3011 switch node unevaluated properties while running make dtbs_check
- Fix a copypaste error in qca8k-leds.c for port 4 required shift
- Drop phy-handle usage for qca8k and use qca8k_port_to_phy()
- Add review tag from Andrew
- Add Christian Marangi SOB in each Andrew patch
- Add extra description for dsa-port stressing that PHY have no access and LED are controlled by the related MAC
- Add missing additionalProperties for dsa-port.yaml and ethernet-phy.yaml
Changes from the old v8 series:
- Drop linux,default-trigger set to netdev.
- Dropped every hw control related patch and implement only blink_set and brightness_set
- Add default-state to "keep" for each LED node example
Andrew Lunn (6):
net: phy: Add a binding for PHY LEDs
net: phy: phy_device: Call into the PHY driver to set LED brightness.
net: phy: marvell: Add software control of the LEDs
net: phy: phy_device: Call into the PHY driver to set LED blinking.
net: phy: marvell: Implement led_blink_set()
arm: mvebu: dt: Add PHY LED support for 370-rd WAN port
Christian Marangi (8):
net: dsa: qca8k: move qca8k_port_to_phy() to header
net: dsa: qca8k: add LEDs basic support
net: dsa: qca8k: add LEDs blink_set() support
dt-bindings: net: dsa: dsa-port: Document support for LEDs node
dt-bindings: net: dsa: qca8k: add LEDs definition example
arm: qcom: dt: Drop unevaluated properties in switch nodes for rb3011
arm: qcom: dt: Add Switch LED for each port for rb3011
dt-bindings: net: phy: Document support for LEDs node
.../devicetree/bindings/net/dsa/dsa-port.yaml | 21 ++ .../devicetree/bindings/net/dsa/qca8k.yaml | 24 ++ .../devicetree/bindings/net/ethernet-phy.yaml | 31 +++ arch/arm/boot/dts/armada-370-rd.dts | 14 ++ arch/arm/boot/dts/qcom-ipq8064-rb3011.dts | 124 +++++++++- drivers/net/dsa/qca/Kconfig | 7 + drivers/net/dsa/qca/Makefile | 1 + drivers/net/dsa/qca/qca8k-8xxx.c | 19 +- drivers/net/dsa/qca/qca8k-leds.c | 229 ++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 83 +++++++ drivers/net/phy/marvell.c | 81 ++++++- drivers/net/phy/phy_device.c | 115 +++++++++ include/linux/phy.h | 33 +++ 13 files changed, 758 insertions(+), 24 deletions(-) create mode 100644 drivers/net/dsa/qca/qca8k-leds.c
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 1/14 net: dsa: qca8k: move qca8k_port_to_phy() to header
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.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 15 --------------- drivers/net/dsa/qca/qca8k.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 15 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +0 -15
@@ -716,21 +716,6 @@ qca8k_phy_eth_command(struct qca8k_priv *priv, bool read, int phy,return ret; } -static u32 -qca8k_port_to_phy (int port) -{ -/* From Andrew Lunn: -* Port 0 has no internal phy. -* Port 1 has an internal PHY at MDIO address 0. -* Port 2 has an internal PHY at MDIO address 1. -* ... -* Port 5 has an internal PHY at MDIO address 4. -* Port 6 has no internal PHY. -*/ - -return port -1 ; -} -static int qca8k_mdio_busy_wait (struct mii_bus *bus,u32 reg,u32 mask) {
drivers/net/dsa/qca/qca8k.h +14 -0
@@ -422,6 +422,20 @@ struct qca8k_fdb {u8 mac[6 ]; }; +static inline u32 qca8k_port_to_phy (int port) +{ +/* From Andrew Lunn: +* Port 0 has no internal phy. +* Port 1 has an internal PHY at MDIO address 0. +* Port 2 has an internal PHY at MDIO address 1. +* ... +* Port 5 has an internal PHY at MDIO address 4. +* Port 6 has no internal PHY. +*/ + +return port -1 ; +} +/* Common setup function */ extern const struct qca8k_mib_desc ar8327_mib[];extern const struct regmap_access_table qca8k_readable_table;
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 2/14 net: dsa: qca8k: add LEDs basic support
In reply to Christian MarangiAdd LEDs basic support for qca8k Switch Family by adding basic brightness_set() support.
Since these LEDs refelect port status, the default label is set to ":port". DT binding should describe the color, function and number of the leds using standard LEDs api.
These LEDs supports only blocking variant of the brightness_set() function since they can sleep during access of the switch leds to set the brightness.
While at it add to the qca8k header file each mode defined by the Switch Documentation for future use.
--- drivers/net/dsa/qca/Kconfig | 7 ++ drivers/net/dsa/qca/Makefile | 1 + drivers/net/dsa/qca/qca8k-8xxx.c | 4 + drivers/net/dsa/qca/qca8k-leds.c | 191 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 69 +++++++++++ 5 files changed, 272 insertions(+) create mode 100644 drivers/net/dsa/qca/qca8k-leds.c
drivers/net/dsa/qca/Kconfig +7 -0
@@ -15,3 +15,10 @@ config NET_DSA_QCA8K help This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. + +config NET_DSA_QCA8K_LEDS_SUPPORT + bool "Qualcomm Atheros QCA8K Ethernet switch family LEDs support" + depends on NET_DSA_QCA8K + help + This enabled support for LEDs present on the Qualcomm Atheros + QCA8K Ethernet switch chips.
drivers/net/dsa/qca/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_NET_DSA_AR9331) += ar9331.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o qca8k-y += qca8k-common.o qca8k-8xxx.o +obj-$(CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT) += qca8k-leds.o
drivers/net/dsa/qca/qca8k-8xxx.c +4 -0
@@ -1727,6 +1727,10 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; + ret =qca8k_setup_led_ctrl (priv); +if (ret) +return ret; +qca8k_setup_pcs (priv, &priv->pcs_port_0,0 );qca8k_setup_pcs (priv, &priv->pcs_port_6,6 );
drivers/net/dsa/qca/qca8k-leds.c new file +191 -0
191 lines not on this page · raw message
drivers/net/dsa/qca/qca8k.h +69 -0
97 lines not on this page · raw message
Signature · 1 line
2.39.2
Vladimir Oltean
maintainerRe: [net-next PATCH v3 02/14] net: dsa: qca8k: add LEDs basic support
Quoted 44 lines · Christian Marangi
Add LEDs basic support for qca8k Switch Family by adding basic
brightness_set()support.Since these LEDs refelect port status, the default label is set to ":port". DT binding should describe the color, function and number of the leds using standard LEDs api.
These LEDs supports only blocking variant of the
brightness_set()function since they can sleep during access of the switch leds to set the brightness.While at it add to the qca8k header file each mode defined by the Switch Documentation for future use.
Signed-off-by Christian Marangi <[email protected]>--- drivers/net/dsa/qca/Kconfig | 7 ++ drivers/net/dsa/qca/Makefile | 1 + drivers/net/dsa/qca/qca8k-8xxx.c | 4 + drivers/net/dsa/qca/qca8k-leds.c | 191 +++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 69 +++++++++++ 5 files changed, 272 insertions(+) create mode 100644 drivers/net/dsa/qca/qca8k-leds.cdrivers/net/dsa/qca/Kconfig +7
-0@@ -15,3 +15,10 @@ config NET_DSA_QCA8K help This enables support for the Qualcomm Atheros QCA8K Ethernet switch chips. + +config NET_DSA_QCA8K_LEDS_SUPPORT + bool "Qualcomm Atheros QCA8K Ethernet switch family LEDs support" + depends on NET_DSA_QCA8K + help + This enabled support for LEDs present on the Qualcomm Atheros + QCA8K Ethernet switch chips.drivers/net/dsa/qca/Makefile +0
-0
drivers/net/dsa/qca/Makefile line 5
Quoted 4 lines
drivers/net/dsa/qca/Makefile +1
-0@@ -2,3 +2,4 @@ obj-$(CONFIG_NET_DSA_AR9331) += ar9331.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o qca8k-y += qca8k-common.o qca8k-8xxx.o +obj-$(CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT) += qca8k-leds.o
Isn't this what you want instead?
ifdef CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT
qca8k-y += qca8k-leds.o
endif
you don't want to have to export the qca8k_setup_led_ctrl() symbol... you want it to be part of the same module AFAIU.
drivers/net/dsa/qca/Makefile
Quoted 9 lines
drivers/net/dsa/qca/Makefile +9
-0+/* 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
Could there be just a qca8k-leds.h with the function prototypes exported by qca8k-leds.c?
Christian Marangi
maintainerPATCH v3 3/14 net: dsa: qca8k: add LEDs blink_set() support
In reply to Christian MarangiAdd 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.
--- drivers/net/dsa/qca/qca8k-leds.c | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/net/dsa/qca/qca8k-leds.c +38 -0
@@ -91,6 +91,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) {
@@ -148,6 +185,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p port_led->cdev.max_brightness =1 ; port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + port_led->cdev.blink_set = qca8k_cled_blink_set; init_data.default_label =":port" ; init_data.devicename ="qca8k" ; init_data.fwnode = led;
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 4/14 net: phy: Add a binding for PHY LEDs
In reply to Christian MarangiFrom: Andrew Lunn <[email protected]>
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.
--- drivers/net/phy/phy_device.c | 89 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 16 +++++++ 2 files changed, 105 insertions(+)
drivers/net/phy/phy_device.c +89 -0
@@ -19,10 +19,12 @@#include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h> +#include <linux/list.h> #include <linux/mdio.h> #include <linux/mii.h> #include <linux/mm.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/netdevice.h> #include <linux/phy.h> #include <linux/phy_led_triggers.h>
@@ -658,6 +660,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,device_initialize (&mdiodev->dev); dev->state =PHY_DOWN ; +INIT_LIST_HEAD (&dev->led_list);mutex_init (&dev->lock);INIT_DELAYED_WORK (&dev->state_queue, phy_state_machine);
@@ -2964,6 +2967,85 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)return phydrv->config_intr && phydrv->handle_interrupt; } +/* Dummy implementation until calls into PHY driver are added */ +static int phy_led_set_brightness (struct led_classdev *led_cdev, +enum led_brightness value) +{ +return 0 ; +} + +static int of_phy_led (struct phy_device *phydev, +struct device_node *led) +{ +struct device *dev = &phydev->mdio.dev; +struct led_init_data init_data = {}; +struct led_classdev *cdev; +struct phy_led *phyled; +int err; + + phyled =devm_kzalloc (dev,sizeof (*phyled),GFP_KERNEL ); +if (!phyled) +return -ENOMEM ; + + phyled->phydev = phydev; + cdev = &phyled->led_cdev; +INIT_LIST_HEAD (&phyled->led_list); + + err =of_property_read_u32 (led,"reg" , &phyled->index); +if (err) +return err; + + cdev->brightness_set_blocking = phy_led_set_brightness; + cdev->max_brightness =1 ; + init_data.devicename =dev_name (&phydev->mdio.dev); + init_data.fwnode =of_fwnode_handle (led); + + err =devm_led_classdev_register_ext (dev, cdev, &init_data); +if (err) +return err; + +list_add (&phyled->led_list, &phydev->led_list); + +return 0 ; +} + +static int of_phy_leds (struct phy_device *phydev) +{ +struct device_node *node = phydev->mdio.dev.of_node; +struct device_node *leds, *led; +int err; + +if (!IS_ENABLED (CONFIG_OF_MDIO )) +return 0 ; + +if (!node) +return 0 ; + + leds =of_get_child_by_name (node,"leds" ); +if (!leds) +return 0 ; + +for_each_available_child_of_node (leds, led) { + err =of_phy_led (phydev, led); +if (err) +return err; + } + +return 0 ; +} + +static void phy_leds_remove (struct phy_device *phydev) +{ +struct device *dev = &phydev->mdio.dev; +struct led_classdev *cdev; +struct phy_led *phyled; + +list_for_each_entry (phyled, &phydev->led_list, led_list) { + cdev = &phyled->led_cdev; +devm_led_classdev_unregister (dev, cdev); + } +} +/** * fwnode_mdio_find_device - Given a fwnode, find the mdio_device * @fwnode: pointer to the mdio_device's fwnode
@@ -3142,6 +3224,11 @@ static int phy_probe(struct device *dev)/* Set the state to READY by default */ phydev->state =PHY_READY ; +/* Get the LEDs from the device tree, and instantiate standard +* LEDs for them. +*/ +of_phy_leds (phydev); + out:/* Assert the reset signal */ if (err)
@@ -3156,6 +3243,8 @@ static int phy_remove(struct device *dev) {struct phy_device *phydev =to_phy_device (dev); +phy_leds_remove (phydev); +cancel_delayed_work_sync (&phydev->state_queue);mutex_lock (&phydev->lock);
include/linux/phy.h +16 -0
@@ -14,6 +14,7 @@#include <linux/compiler.h> #include <linux/spinlock.h> #include <linux/ethtool.h> +#include <linux/leds.h> #include <linux/linkmode.h> #include <linux/netlink.h> #include <linux/mdio.h>
@@ -595,6 +596,7 @@ struct macsec_ops;* @phy_num_led_triggers: Number of triggers in @phy_led_triggers * @led_link_trigger: LED trigger for link up/down * @last_triggered: last LED trigger for link speed +* @led_list: list of PHY LED structures * @master_slave_set: User requested master/slave configuration * @master_slave_get: Current master/slave advertisement * @master_slave_state: Current master/slave configuration
@@ -690,6 +692,7 @@ struct phy_device {struct phy_led_trigger *led_link_trigger;#endif +struct list_head led_list;/* * Interrupt number for this PHY
@@ -825,6 +828,19 @@ struct phy_plca_status {bool pst; }; +/* phy_led: An LED driven by the PHY +* +* phydev: Pointer to the PHY this LED belongs to +* led_cdev: Standard LED class structure +* index: Number of the LED +*/ +struct phy_led { +struct list_head led_list; +struct phy_device *phydev; +struct led_classdev led_cdev; +u32 index; +}; +/** * struct phy_driver - Driver structure for a particular PHY type *
Signature · 1 line
2.39.2
Vladimir Oltean
maintainerRe: [net-next PATCH v3 04/14] net: phy: Add a binding for PHY LEDs
Quoted 55 lines · Christian Marangi
From: Andrew Lunn <[email protected]>
Define common binding parsing for all PHY drivers with LEDs using phylib. Parse the DT as part of the
phy_probeand add LEDs to the linux LED class infrastructure. For the moment, provide a dummy brightness function, which will later be replaced with a call into the PHY driver.Signed-off-by Andrew Lunn <[email protected]>Signed-off-by Christian Marangi <[email protected]>--- drivers/net/phy/phy_device.c | 89 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 16 +++++++ 2 files changed, 105 insertions(+)drivers/net/phy/phy_device.c +14
-0@@ -19,10 +19,12 @@#include <linux/interrupt.h> #include <linux/io.h> #include <linux/kernel.h> +#include <linux/list.h> #include <linux/mdio.h> #include <linux/mii.h> #include <linux/mm.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/netdevice.h> #include <linux/phy.h> #include <linux/phy_led_triggers.h> @@ -658,6 +660,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,device_initialize (&mdiodev->dev); dev->state =PHY_DOWN ; +INIT_LIST_HEAD (&dev->led_list);mutex_init (&dev->lock);INIT_DELAYED_WORK (&dev->state_queue, phy_state_machine);@@ -2964,6 +2967,85 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)return phydrv->config_intr && phydrv->handle_interrupt; } +/* Dummy implementation until calls into PHY driver are added */ +static int phy_led_set_brightness (struct led_classdev *led_cdev, +enum led_brightness value) +{ +return 0 ; +} + +static int of_phy_led (struct phy_device *phydev, +struct device_node *led) +{ +struct device *dev = &phydev->mdio.dev;
drivers/net/phy/phy_device.c static bool phy_drv_supports_irq(struct phy_driver *phydrv) · line 2990
Quoted 10 lines
drivers/net/phy/phy_device.c +10
-0+struct led_init_data init_data = {}; +struct led_classdev *cdev; +struct phy_led *phyled; +int err; + + phyled =devm_kzalloc (dev,sizeof (*phyled),GFP_KERNEL ); +if (!phyled) +return -ENOMEM ; + + phyled->phydev = phydev;
hmm.. not used in this patch
drivers/net/phy/phy_device.c static bool phy_drv_supports_irq(struct phy_driver *phydrv) · line 2992
Quoted 2 lines
drivers/net/phy/phy_device.c +2
-0+ cdev = &phyled->led_cdev; +INIT_LIST_HEAD (&phyled->led_list);
I believe list elements don't need INIT_LIST_HEAD(), only the head (phydev->led_list) does?
Quoted 29 lines
drivers/net/phy/phy_device.c +29
-0+ + err =of_property_read_u32 (led,"reg" , &phyled->index); +if (err) +return err; + + cdev->brightness_set_blocking = phy_led_set_brightness; + cdev->max_brightness =1 ; + init_data.devicename =dev_name (&phydev->mdio.dev); + init_data.fwnode =of_fwnode_handle (led); + + err =devm_led_classdev_register_ext (dev, cdev, &init_data); +if (err) +return err; + +list_add (&phyled->led_list, &phydev->led_list); + +return 0 ; +} + +static int of_phy_leds (struct phy_device *phydev) +{ +struct device_node *node = phydev->mdio.dev.of_node; +struct device_node *leds, *led; +int err; + +if (!IS_ENABLED (CONFIG_OF_MDIO )) +return 0 ; + +if (!node)
drivers/net/phy/phy_device.c static bool phy_drv_supports_irq(struct phy_driver *phydrv) · line 3031
Quoted 10 lines
drivers/net/phy/phy_device.c +10
-0+return 0 ; + + leds =of_get_child_by_name (node,"leds" ); +if (!leds) +return 0 ; + +for_each_available_child_of_node (leds, led) { + err =of_phy_led (phydev, led); +if (err) +return err;
Agree with you that devres allows you to write yolo error teardown code.. but of_node_put() after of_get_child_by_name()?
Quoted 4 lines
drivers/net/phy/phy_device.c +4
-0+ } + +return 0 ; +}
drivers/net/phy/phy_device.c static bool phy_drv_supports_irq(struct phy_driver *phydrv) · line 3045
Quoted 10 lines
drivers/net/phy/phy_device.c +10
-0+ +static void phy_leds_remove (struct phy_device *phydev) +{ +struct device *dev = &phydev->mdio.dev; +struct led_classdev *cdev; +struct phy_led *phyled; + +list_for_each_entry (phyled, &phydev->led_list, led_list) { + cdev = &phyled->led_cdev; +devm_led_classdev_unregister (dev, cdev);
is this really needed? shouldn't devres unregister the led classdev after phy_remove() ends, anyway?
Quoted 7 lines
drivers/net/phy/phy_device.c +3
-0+ } +} +/** * fwnode_mdio_find_device - Given a fwnode, find the mdio_device * @fwnode: pointer to the mdio_device's fwnode
drivers/net/phy/phy_device.c static int phy_probe(struct device *dev) · line 3230
Quoted 7 lines
drivers/net/phy/phy_device.c +4
-0@@ -3142,6 +3224,11 @@ static int phy_probe(struct device *dev)/* Set the state to READY by default */ phydev->state =PHY_READY ; +/* Get the LEDs from the device tree, and instantiate standard +* LEDs for them. +*/ +of_phy_leds (phydev);
It would probably be good to treat the error code here, to not create a precedent where invalid bindings (no "reg" for example) were accepted?
Quoted 42 lines
drivers/net/phy/phy_device.c +3
-0+ out:/* Assert the reset signal */ if (err)@@ -3156,6 +3243,8 @@ static int phy_remove(struct device *dev) {struct phy_device *phydev =to_phy_device (dev); +phy_leds_remove (phydev); +cancel_delayed_work_sync (&phydev->state_queue);mutex_lock (&phydev->lock);include/linux/phy.h +3
-0@@ -14,6 +14,7 @@#include <linux/compiler.h> #include <linux/spinlock.h> #include <linux/ethtool.h> +#include <linux/leds.h> #include <linux/linkmode.h> #include <linux/netlink.h> #include <linux/mdio.h> @@ -595,6 +596,7 @@ struct macsec_ops;* @phy_num_led_triggers: Number of triggers in @phy_led_triggers * @led_link_trigger: LED trigger for link up/down * @last_triggered: last LED trigger for link speed +* @led_list: list of PHY LED structures * @master_slave_set: User requested master/slave configuration * @master_slave_get: Current master/slave advertisement * @master_slave_state: Current master/slave configuration @@ -690,6 +692,7 @@ struct phy_device {struct phy_led_trigger *led_link_trigger;#endif +struct list_head led_list;/* * Interrupt number for this PHY
include/linux/phy.h struct phy_plca_status { · line 835
Quoted 8 lines
include/linux/phy.h +5
-0@@ -825,6 +828,19 @@ struct phy_plca_status {bool pst; }; +/* phy_led: An LED driven by the PHY +* +* phydev: Pointer to the PHY this LED belongs to +* led_cdev: Standard LED class structure +* index: Number of the LED
led_list not described in comments
Also, does this deliberately not use the kerneldoc style /**?
Also, small nitpick, feel free to ignore it. Since it's unlikely that a phy_led would be chained onto more than one list, I guess its "led_list" field could be simply named "list", leaving "led_list" only to struct phy_device?
Quoted 14 lines
include/linux/phy.h +8
-0+*/ +struct phy_led { +struct list_head led_list; +struct phy_device *phydev; +struct led_classdev led_cdev; +u32 index; +}; +/** * struct phy_driver - Driver structure for a particular PHY type * Signature · 1 line
2.39.2
no "depends on LEDS_CLASS" in the Kconfig?
kernel test robot
build botRe: [net-next PATCH v3 04/14] net: phy: Add a binding for PHY LEDs
In reply to Christian MarangiI love your patch! Yet something to improve:
Hi Christian,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-dsa-qca8k-move-qca8k_port_to_phy-to-header/20230315-002131 patch link: https://lore.kernel.org/r/20230314101516.20427-5-ansuelsmth%40gmail.com patch subject: [net-next PATCH v3 04/14] net: phy: Add a binding for PHY LEDs config: x86_64-randconfig-a013-20230313 (https://download.01.org/0day-ci/archive/20230316/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d3ed3e0a54a4a40c493b493d6ea2890447ce244a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christian-Marangi/net-dsa-qca8k-move-qca8k_port_to_phy-to-header/20230315-002131 git checkout d3ed3e0a54a4a40c493b493d6ea2890447ce244a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: devm_led_classdev_unregister >>> referenced by phy_device.c:3069 (drivers/net/phy/phy_device.c:3069) >>> drivers/net/phy/phy_device.o:(phy_remove) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Christian Marangi
maintainerPATCH v3 5/14 net: phy: phy_device: Call into the PHY driver to set LED brightness.
In reply to Christian MarangiFrom: Andrew Lunn <[email protected]>
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.
--- drivers/net/phy/phy_device.c | 14 +++++++++++--- include/linux/phy.h | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/net/phy/phy_device.c +11 -3
@@ -2967,11 +2967,18 @@ static bool phy_drv_supports_irq(struct phy_driver *phydrv)return phydrv->config_intr && phydrv->handle_interrupt; } -/* Dummy implementation until calls into PHY driver are added */ static int phy_led_set_brightness (struct led_classdev *led_cdev,enum led_brightness value) { -return 0 ; +struct phy_led *phyled =to_phy_led (led_cdev); +struct phy_device *phydev = phyled->phydev; +int err; + +mutex_lock (&phydev->lock); + err = phydev->drv->led_brightness_set (phydev, phyled->index, value); +mutex_unlock (&phydev->lock); + +return err; } static int of_phy_led(struct phy_device *phydev,
@@ -2995,7 +3002,8 @@ static int of_phy_led(struct phy_device *phydev,if (err)return err; - cdev->brightness_set_blocking = phy_led_set_brightness; +if (phydev->drv->led_brightness_set) + cdev->brightness_set_blocking = phy_led_set_brightness; cdev->max_brightness =1 ; init_data.devicename =dev_name (&phydev->mdio.dev); init_data.fwnode =of_fwnode_handle (led);
include/linux/phy.h +9 -0
@@ -841,6 +841,8 @@ struct phy_led {u32 index; }; +#define to_phy_led (d) container_of(d, struct phy_led, led_cdev) +/** * struct phy_driver - Driver structure for a particular PHY type *
@@ -1063,6 +1065,13 @@ struct phy_driver {/** @get_plca_status: Return the current PLCA status info */ int (*get_plca_status)(struct phy_device *dev,struct phy_plca_status *plca_st); + +/* Set a PHY LED brightness. Index indicates which of the PHYs +* led should be set. Value follows the standard LED class meaning, +* e.g. LED_OFF, LED_HALF, LED_FULL. +*/ +int (*led_brightness_set)(struct phy_device *dev, +u32 index,enum led_brightness value); };#define to_phy_driver (d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv)
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 6/14 net: phy: marvell: Add software control of the LEDs
In reply to Christian MarangiFrom: Andrew Lunn <[email protected]>
Add a brightness function, so the LEDs can be controlled from software using the standard Linux LED infrastructure.
--- drivers/net/phy/marvell.c | 45 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-)
drivers/net/phy/marvell.c +40 -5
@@ -144,11 +144,13 @@/* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) -/* LED Timer Control Register */ -#define MII_88E1318S_PHY_LED_TCR 0x12 -#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) -#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) -#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) +#define MII_88E1318S_PHY_LED_FUNC 0x10 +#define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) +#define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_TCR 0x12 +#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) +#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) +#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)/* Magic Packet MAC address registers */ #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
@@ -2832,6 +2834,34 @@ static int marvell_hwmon_probe(struct phy_device *phydev) }#endif +static int m88e1318_led_brightness_set (struct phy_device *phydev, +u32 index,enum led_brightness value) +{ +u16 reg; + + reg =phy_read_paged (phydev,MII_MARVELL_LED_PAGE , +MII_88E1318S_PHY_LED_FUNC ); +if (reg <0 ) +return reg; + +switch (index) { +case 0 : +case 1 : +case 2 : + reg &= ~(0xf << (4 * index)); +if (value ==LED_OFF ) + reg |=MII_88E1318S_PHY_LED_FUNC_OFF << (4 * index); +else + reg |=MII_88E1318S_PHY_LED_FUNC_ON << (4 * index); +break ; +default : +return -EINVAL ; + } + +return phy_write_paged (phydev,MII_MARVELL_LED_PAGE , +MII_88E1318S_PHY_LED_FUNC , reg); +} +static int marvell_probe (struct phy_device *phydev) {struct marvell_priv *priv;
@@ -3081,6 +3111,7 @@ static struct phy_driver marvell_drivers[] = { .get_sset_count = marvell_get_sset_count, .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1145,
@@ -3187,6 +3218,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1540,
@@ -3213,6 +3245,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1545,
@@ -3239,6 +3272,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E3016,
@@ -3380,6 +3414,7 @@ static struct phy_driver marvell_drivers[] = { .get_stats = marvell_get_stats, .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, + .led_brightness_set = m88e1318_led_brightness_set, }, };
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Vladimir Oltean
maintainerRe: [net-next PATCH v3 06/14] net: phy: marvell: Add software control of the LEDs
Quoted 8 lines · Christian Marangi
From: Andrew Lunn <[email protected]>
Add a brightness function, so the LEDs can be controlled from software using the standard Linux LED infrastructure.
Signed-off-by Andrew Lunn <[email protected]>Signed-off-by Christian Marangi <[email protected]>---
drivers/net/phy/marvell.c static int marvell_hwmon_probe(struct phy_device *phydev) · line 2845
Quoted 9 lines
drivers/net/phy/marvell.c +9
-0+static int m88e1318_led_brightness_set (struct phy_device *phydev, +u32 index,enum led_brightness value) +{ +u16 reg; + + reg =phy_read_paged (phydev,MII_MARVELL_LED_PAGE , +MII_88E1318S_PHY_LED_FUNC ); +if (reg <0 ) +return reg;
"reg" is declared as unsigned, so it's surely positive.
Quoted 18 lines
drivers/net/phy/marvell.c +18
-0+ +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); +}
Andrew Lunn
maintainerRe: [net-next PATCH v3 06/14] net: phy: marvell: Add software control of the LEDs
Quoted 8 lines
drivers/net/phy/marvell.c static int marvell_hwmon_probe(struct phy_device *phydev) · line 2845
Quoted 6 lines
drivers/net/phy/marvell.c +6
-0+u16 reg; + + reg =phy_read_paged (phydev,MII_MARVELL_LED_PAGE , +MII_88E1318S_PHY_LED_FUNC ); +if (reg <0 ) +return reg;"reg" is declared as unsigned, so it's surely positive.
Gerr. That is one of the most common errors in phylib. I should know better :-(
Thanks
Andrew
Christian Marangi
maintainerPATCH v3 7/14 net: phy: phy_device: Call into the PHY driver to set LED blinking.
In reply to Christian MarangiFrom: Andrew Lunn <[email protected]>
Linux LEDs can be requested to perform hardware accelerated blinking. Pass this to the PHY driver, if it implements the op.
--- drivers/net/phy/phy_device.c | 18 ++++++++++++++++++ include/linux/phy.h | 8 ++++++++ 2 files changed, 26 insertions(+)
drivers/net/phy/phy_device.c +18 -0
@@ -2981,6 +2981,22 @@ static int phy_led_set_brightness(struct led_classdev *led_cdev,return err; } +static int phy_led_blink_set (struct led_classdev *led_cdev, +unsigned long *delay_on, +unsigned long *delay_off) +{ +struct phy_led *phyled =to_phy_led (led_cdev); +struct phy_device *phydev = phyled->phydev; +int err; + +mutex_lock (&phydev->lock); + err = phydev->drv->led_blink_set (phydev, phyled->index, + delay_on, delay_off); +mutex_unlock (&phydev->lock); + +return err; +} +static int of_phy_led (struct phy_device *phydev,struct device_node *led) {
@@ -3004,6 +3020,8 @@ static int of_phy_led(struct phy_device *phydev,if (phydev->drv->led_brightness_set) cdev->brightness_set_blocking = phy_led_set_brightness; +if (phydev->drv->led_blink_set) + cdev->blink_set = phy_led_blink_set; cdev->max_brightness =1 ; init_data.devicename =dev_name (&phydev->mdio.dev); init_data.fwnode =of_fwnode_handle (led);
include/linux/phy.h +8 -0
@@ -1072,6 +1072,14 @@ struct phy_driver {*/ int (*led_brightness_set)(struct phy_device *dev,u32 index,enum led_brightness value); +/* Activate hardware accelerated blink, delays are in milliseconds +* and if both are zero then a sensible default should be chosen. +* The call should adjust the timings in that case and if it can't +* match the values specified exactly. +*/ +int (*led_blink_set)(struct phy_device *dev,u32 index, +unsigned long *delay_on, +unsigned long *delay_off); };#define to_phy_driver (d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv)
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Christian Marangi
maintainerPATCH v3 8/14 net: phy: marvell: Implement led_blink_set()
In reply to Christian MarangiFrom: Andrew Lunn <[email protected]>
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.
--- drivers/net/phy/marvell.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/net/phy/marvell.c +36 -0
@@ -147,6 +147,8 @@#define MII_88E1318S_PHY_LED_FUNC 0x10#define MII_88E1318S_PHY_LED_FUNC_OFF (0x8)#define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_FUNC_HI_Z (0xa) +#define MII_88E1318S_PHY_LED_FUNC_BLINK (0xb)#define MII_88E1318S_PHY_LED_TCR 0x12#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
@@ -2862,6 +2864,35 @@ static int m88e1318_led_brightness_set(struct phy_device *phydev, MII_88E1318S_PHY_LED_FUNC, reg); } +static int m88e1318_led_blink_set (struct phy_device *phydev,u32 index, +unsigned long *delay_on, +unsigned long *delay_off) +{ +u16 reg; + + reg =phy_read_paged (phydev,MII_MARVELL_LED_PAGE , +MII_88E1318S_PHY_LED_FUNC ); +if (reg <0 ) +return reg; + +switch (index) { +case 0 : +case 1 : +case 2 : + reg &= ~(0xf << (4 * index)); + reg |=MII_88E1318S_PHY_LED_FUNC_BLINK << (4 * index); +/* Reset default is 84ms */ + *delay_on =84 /2 ; + *delay_off =84 /2 ; +break ; +default : +return -EINVAL ; + } + +return phy_write_paged (phydev,MII_MARVELL_LED_PAGE , +MII_88E1318S_PHY_LED_FUNC , reg); +} +static int marvell_probe (struct phy_device *phydev) {struct marvell_priv *priv;
@@ -3112,6 +3143,7 @@ static struct phy_driver marvell_drivers[] = { .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1145,
@@ -3219,6 +3251,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1540,
@@ -3246,6 +3279,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1545,
@@ -3273,6 +3307,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E3016,
@@ -3415,6 +3450,7 @@ static struct phy_driver marvell_drivers[] = { .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, };
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Vladimir Oltean
maintainerRe: [net-next PATCH v3 08/14] net: phy: marvell: Implement led_blink_set()
drivers/net/phy/marvell.c static int m88e1318_led_brightness_set(struct phy_device *phydev, · line 2871
Quoted 5 lines · Christian Marangi
drivers/net/phy/marvell.c +5
-0+static int m88e1318_led_blink_set (struct phy_device *phydev,u32 index, +unsigned long *delay_on, +unsigned long *delay_off) +{ +u16 reg;
Same problem here.
Quoted 23 lines
drivers/net/phy/marvell.c +23
-0+ + 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); +}
Christian Marangi
maintainerPATCH v3 9/14 dt-bindings: net: dsa: dsa-port: Document support for LEDs node
In reply to Christian MarangiDocument support for LEDs node in dsa port.
Switch may support different LEDs that can be configured for different operation like blinking on traffic event or port link.
Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since dsa-port LEDs are controllable by the switch regs and the possible intergated PHY doesn't have control on them.
--- .../devicetree/bindings/net/dsa/dsa-port.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/net/dsa/dsa-port.yaml +21 -0
@@ -59,6 +59,27 @@ properties: - rtl8_4t - seville + leds: + type: object + description: + Describes the LEDs associated by the Switch Port and controllable + in its MACs. These LEDs are not integrated in the PHY and PHY + doesn't have any control on them. Switch regs are used to control + these Switch Port LEDs. + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + + additionalProperties: false + # CPU and DSA ports must have phylink-compatible link descriptions if: oneOf:
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Vladimir Oltean
maintainerRe: [net-next PATCH v3 09/14] dt-bindings: net: dsa: dsa-port: Document support for LEDs node
Quoted 4 lines · Christian Marangi
Document support for LEDs node in dsa port.
Switch may support different LEDs that can be configured for different operation like blinking on traffic event or port link.
Quoted 8 lines
Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since dsa-port LEDs are controllable by the switch regs and the possible intergated PHY doesn't have control on them.
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/net/dsa/dsa-port.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
Of all schemas, why did you choose dsa-port.yaml? Why not either something hardware specific (qca8k.yaml) or more generic (ethernet-controller.yaml)?
Andrew Lunn
maintainerRe: [net-next PATCH v3 09/14] dt-bindings: net: dsa: dsa-port: Document support for LEDs node
Quoted 9 lines · Vladimir Oltean
Quoted 8 lines · Christian Marangi
Document support for LEDs node in dsa port.
Switch may support different LEDs that can be configured for different operation like blinking on traffic event or port link.Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since dsa-port LEDs are controllable by the switch regs and the possible intergated PHY doesn't have control on them.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/net/dsa/dsa-port.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)Of all schemas, why did you choose
dsa-port.yaml? Why not either something hardware specific (qca8k.yaml) or more generic (ethernet-controller.yaml)?
The binding should be generic. So qca8k.yaml is way to specific. The Marvell switch should re-use it at some point.
Looking at the hierarchy, ethernet-controller.yaml would work since dsa-port includes ethernet-switch-port, which includes ethernet-controller.
These are MAC LEDs, and there is no reason why a standalone MAC in a NIC could not implement such LEDs. So yes, ethernet-controller.yaml.
Is there actually anything above ethernet-controller.yaml? This is about a netdev really, so a wifi MAC, or even a CAN MAC could also use the binding....
Andrew
Christian Marangi
maintainerRe: [net-next PATCH v3 09/14] dt-bindings: net: dsa: dsa-port: Document support for LEDs node
Quoted 25 lines · Andrew Lunn
Quoted 9 lines · Vladimir Oltean
Quoted 8 lines · Christian Marangi
Document support for LEDs node in dsa port.
Switch may support different LEDs that can be configured for different operation like blinking on traffic event or port link.Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since dsa-port LEDs are controllable by the switch regs and the possible intergated PHY doesn't have control on them.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/net/dsa/dsa-port.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)Of all schemas, why did you choose
dsa-port.yaml? Why not either something hardware specific (qca8k.yaml) or more generic (ethernet-controller.yaml)?The binding should be generic. So
qca8k.yamlis way to specific. The Marvell switch should re-use it at some point.Looking at the hierarchy,
ethernet-controller.yamlwould work since dsa-port includes ethernet-switch-port, which includes ethernet-controller.
Quoted 8 lines
These are MAC LEDs, and there is no reason why a standalone MAC in a NIC could not implement such LEDs. So yes,
ethernet-controller.yaml.Is there actually anything above
ethernet-controller.yaml? This is about a netdev really, so a wifi MAC, or even a CAN MAC could also use the binding....
Yes ideally when we manage to do all the things, ath10k would benefits from this since it does have leds that blink on tx/rx traffic and are specially controlled...
Don't think there is something above ethernet-controller tho...
Signature · 1 line
Ansuel
Rob Herring
maintainerRe: [net-next PATCH v3 09/14] dt-bindings: net: dsa: dsa-port: Document support for LEDs node
In reply to Andrew LunnQuoted 25 lines · Andrew Lunn
Quoted 9 lines · Vladimir Oltean
Quoted 8 lines · Christian Marangi
Document support for LEDs node in dsa port.
Switch may support different LEDs that can be configured for different operation like blinking on traffic event or port link.Also add some Documentation to describe the difference of these nodes compared to PHY LEDs, since dsa-port LEDs are controllable by the switch regs and the possible intergated PHY doesn't have control on them.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/net/dsa/dsa-port.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)Of all schemas, why did you choose
dsa-port.yaml? Why not either something hardware specific (qca8k.yaml) or more generic (ethernet-controller.yaml)?The binding should be generic. So
qca8k.yamlis way to specific. The Marvell switch should re-use it at some point.Looking at the hierarchy,
ethernet-controller.yamlwould work since dsa-port includes ethernet-switch-port, which includes ethernet-controller.
Quoted 5 lines
These are MAC LEDs, and there is no reason why a standalone MAC in a NIC could not implement such LEDs. So yes,
ethernet-controller.yaml.Is there actually anything above
ethernet-controller.yaml?
Yes, the one under review[1].
Rob
Christian Marangi
maintainerPATCH v3 10/14 dt-bindings: net: dsa: qca8k: add LEDs definition example
In reply to Christian MarangiAdd LEDs definition example for qca8k Switch Family to describe how they should be defined for a correct usage.
--- .../devicetree/bindings/net/dsa/qca8k.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +24 -0
@@ -18,6 +18,8 @@ description: PHY it is connected to. In this config, an internal mdio-bus is registered and the MDIO master is used for communication. Mixed external and internal mdio-bus configurations are not supported by the hardware. + Each phy have at least 3 LEDs connected and can be declared + using the standard LEDs structure. properties: compatible:
@@ -117,6 +119,7 @@ unevaluatedProperties: false examples: - | #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/leds/common.h> mdio { #address-cells = <1>;
@@ -226,6 +229,27 @@ examples: label = "lan1"; phy-mode = "internal"; phy-handle = <&internal_phy_port1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_WHITE>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = <LED_COLOR_ID_AMBER>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; }; port@2 {
Signature · 1 line
2.39.2
Vladimir Oltean
maintainerRe: [net-next PATCH v3 10/14] dt-bindings: net: dsa: qca8k: add LEDs definition example
Quoted 13 lines · Christian Marangi
Add LEDs definition example for qca8k Switch Family to describe how they should be defined for a correct usage.
Signed-off-by Christian Marangi <[email protected]>--- .../devicetree/bindings/net/dsa/qca8k.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)Documentation/devicetree/bindings/net/dsa/qca8k.yaml +0
-0
Documentation/devicetree/bindings/net/dsa/qca8k.yaml description: · line 21
Quoted 4 lines
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +1
-0@@ -18,6 +18,8 @@ description: PHY it is connected to. In this config, an internal mdio-bus is registered and the MDIO master is used for communication. Mixed external and internal mdio-bus configurations are not supported by the hardware. + Each phy have at least 3 LEDs connected and can be declared
s/have/has/
Quoted 1 line
Documentation/devicetree/bindings/net/dsa/qca8k.yaml +1
-0+ using the standard LEDs structure.
Christian Marangi
maintainerPATCH v3 11/14 arm: qcom: dt: Drop unevaluated properties in switch nodes for rb3011
In reply to Christian MarangiIPQ8064 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.
--- arch/arm/boot/dts/qcom-ipq8064-rb3011.dts | 4 ---- 1 file changed, 4 deletions(-)
arch/arm/boot/dts/qcom-ipq8064-rb3011.dts +0 -4
@@ -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>;
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 12/14 arm: qcom: dt: Add Switch LED for each port for rb3011
In reply to Christian MarangiAdd 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.
--- arch/arm/boot/dts/qcom-ipq8064-rb3011.dts | 120 ++++++++++++++++++++++ 1 file changed, 120 insertions(+)
arch/arm/boot/dts/qcom-ipq8064-rb3011.dts +120 -0
@@ -65,26 +65,86 @@ fixed-link { port@1 { reg = <1>; label = "sw1"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + }; + }; }; port@2 { reg = <2>; label = "sw2"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <2>; + }; + }; }; port@3 { reg = <3>; label = "sw3"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <3>; + }; + }; }; port@4 { reg = <4>; label = "sw4"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <4>; + }; + }; }; port@5 { reg = <5>; label = "sw5"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <5>; + }; + }; }; }; };
@@ -130,26 +190,86 @@ fixed-link { port@1 { reg = <1>; label = "sw6"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <6>; + }; + }; }; port@2 { reg = <2>; label = "sw7"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <7>; + }; + }; }; port@3 { reg = <3>; label = "sw8"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <8>; + }; + }; }; port@4 { reg = <4>; label = "sw9"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <9>; + }; + }; }; port@5 { reg = <5>; label = "sw10"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_GREEN>; + function = LED_FUNCTION_LAN; + function-enumerator = <10>; + }; + }; }; }; };
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 13/14 dt-bindings: net: phy: Document support for LEDs node
In reply to Christian MarangiDocument 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.
--- .../devicetree/bindings/net/ethernet-phy.yaml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/net/ethernet-phy.yaml +31 -0
@@ -197,6 +197,22 @@ properties: PHY's that have configurable TX internal delays. If this property is present then the PHY applies the TX delay. + leds: + type: object + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^led(@[a-f0-9]+)?$': + $ref: /schemas/leds/common.yaml# + + additionalProperties: false + required: - reg
@@ -204,6 +220,8 @@ additionalProperties: true examples: - | + #include <dt-bindings/leds/common.h> + ethernet { #address-cells = <1>; #size-cells = <0>;
@@ -219,5 +237,18 @@ examples: reset-gpios = <&gpio1 4 1>; reset-assert-us = <1000>; reset-deassert-us = <2000>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = <LED_COLOR_ID_WHITE>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; }; };
Signature · 1 line
2.39.2
Christian Marangi
maintainerPATCH v3 14/14 arm: mvebu: dt: Add PHY LED support for 370-rd WAN port
In reply to Christian MarangiFrom: Andrew Lunn <[email protected]>
The WAN port of the 370-RD has a Marvell PHY, with one LED on the front panel. List this LED in the device tree.
Set the LED default state to "keep" to not change any blink rule set by default.
--- arch/arm/boot/dts/armada-370-rd.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/boot/dts/armada-370-rd.dts +14 -0
@@ -20,6 +20,7 @@ /dts-v1/; #include <dt-bindings/input/input.h> #include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/leds/common.h> #include <dt-bindings/gpio/gpio.h> #include "armada-370.dtsi"
@@ -135,6 +136,19 @@ &mdio { pinctrl-names = "default"; phy0: ethernet-phy@0 { reg = <0>; + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + label = "WAN"; + color = <LED_COLOR_ID_WHITE>; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + default-state = "keep"; + }; + }; }; switch: switch@10 {
Signature · 1 line
2.39.2