* [PATCH 0/2] Add LED mode behavior/select properties and handle @ 2020-12-09 14:04 Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 1/2] net: phy: micrel: add LED control on KSZ9131 Ivan Mikhaylov ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Ivan Mikhaylov @ 2020-12-09 14:04 UTC (permalink / raw) To: David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King Cc: Ivan Mikhaylov, netdev, devicetree, linux-kernel In KSZ9131 PHY it is possible to control LEDs blink behavior via LED mode behavior and select registers. Add DTS properties plus handles of them inside micrel PHY driver. I've some concerns about passing raw register values into LED mode select and behavior. It can be passed via array like in microchip driver(Documentation/devicetree/bindings/net/microchip,lan78xx.txt). There is the problem in this particular driver - there is a lot of other PHYs and led mode behavior/select states may intersect, that's the reason why I did it this way. Is there any good ways to make it look more properly? Ivan Mikhaylov (2): net: phy: micrel: add LED control on KSZ9131 dt-bindings: net: phy: micrel: add LED mode behavior and select properties .../devicetree/bindings/net/micrel.txt | 7 ++ drivers/net/phy/micrel.c | 69 ++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) -- 2.21.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] net: phy: micrel: add LED control on KSZ9131 2020-12-09 14:04 [PATCH 0/2] Add LED mode behavior/select properties and handle Ivan Mikhaylov @ 2020-12-09 14:05 ` Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 2/2] dt-bindings: net: phy: micrel: add LED mode behavior and select properties Ivan Mikhaylov ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Ivan Mikhaylov @ 2020-12-09 14:05 UTC (permalink / raw) To: David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King Cc: Ivan Mikhaylov, netdev, devicetree, linux-kernel Add the possibility to read the LED configuration via DTS properties from KSZ9131 PHY node. Add the new proprties and handle for them: micrel,led-mode-behavior micrel,led-mode-select Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com> --- drivers/net/phy/micrel.c | 69 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 3fe552675dd2..117f3a3b9dd6 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -71,6 +71,11 @@ #define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105 #define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106 +/* KSZ9131 LED registers */ +#define MII_KSZPHY_LED_MODE_SELECT 0x16 +#define MII_KSZPHY_LED_BEHAVIOR 0x17 +#define MII_KSZPHY_LED_MODE 0x1a + #define PS_TO_REG 200 struct kszphy_hw_stat { @@ -86,6 +91,8 @@ static struct kszphy_hw_stat kszphy_hw_stats[] = { struct kszphy_type { u32 led_mode_reg; + u32 led_mode_behavior_reg; + u32 led_mode_select_reg; u16 interrupt_level_mask; bool has_broadcast_disable; bool has_nand_tree_disable; @@ -95,6 +102,8 @@ struct kszphy_type { struct kszphy_priv { const struct kszphy_type *type; int led_mode; + int led_mode_behavior; + int led_mode_select; bool rmii_ref_clk_sel; bool rmii_ref_clk_sel_val; u64 stats[ARRAY_SIZE(kszphy_hw_stats)]; @@ -131,6 +140,13 @@ static const struct kszphy_type ksz9021_type = { .interrupt_level_mask = BIT(14), }; +static const struct kszphy_type ksz9131_type = { + .led_mode_reg = MII_KSZPHY_LED_MODE, + .led_mode_behavior_reg = MII_KSZPHY_LED_BEHAVIOR, + .led_mode_select_reg = MII_KSZPHY_LED_MODE_SELECT, + .interrupt_level_mask = BIT(14), +}; + static int kszphy_extended_write(struct phy_device *phydev, u32 regnum, u16 val) { @@ -204,6 +220,7 @@ static int kszphy_setup_led(struct phy_device *phydev, u32 reg, int val) switch (reg) { case MII_KSZPHY_CTRL_1: + case MII_KSZPHY_LED_MODE: shift = 14; break; case MII_KSZPHY_CTRL_2: @@ -286,6 +303,26 @@ static int kszphy_config_reset(struct phy_device *phydev) if (priv->led_mode >= 0) kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); + if (priv->led_mode_behavior >= 0) { + ret = phy_write(phydev, priv->type->led_mode_behavior_reg, + priv->led_mode_behavior); + if (ret) { + phydev_err(phydev, + "failed to set led mode behavior reg\n"); + return ret; + } + } + + if (priv->led_mode_select >= 0) { + ret = phy_write(phydev, priv->type->led_mode_select_reg, + priv->led_mode_select); + if (ret) { + phydev_err(phydev, + "failed to set led mode select reg\n"); + return ret; + } + } + return 0; } @@ -1122,6 +1159,36 @@ static int kszphy_probe(struct phy_device *phydev) priv->led_mode = -1; } + if (type->led_mode_behavior_reg) { + ret = of_property_read_u32(np, "micrel,led-mode-behavior", + &priv->led_mode_behavior); + if (!ret) { + ret = phy_write(phydev, type->led_mode_behavior_reg, + priv->led_mode_behavior); + if (ret) + phydev_err(phydev, + "invalid led mode behavior: 0x%x\n", + priv->led_mode_behavior); + } + } else { + priv->led_mode_behavior = -1; + } + + if (type->led_mode_select_reg) { + ret = of_property_read_u32(np, "micrel,led-mode-select", + &priv->led_mode_select); + if (!ret) { + ret = phy_write(phydev, type->led_mode_select_reg, + priv->led_mode_select); + if (ret) + phydev_err(phydev, + "invalid led mode select: 0x%x\n", + priv->led_mode_select); + } + } else { + priv->led_mode_select = -1; + } + clk = devm_clk_get(&phydev->mdio.dev, "rmii-ref"); /* NOTE: clk may be NULL if building without CONFIG_HAVE_CLK */ if (!IS_ERR_OR_NULL(clk)) { @@ -1319,7 +1386,7 @@ static struct phy_driver ksphy_driver[] = { .phy_id_mask = MICREL_PHY_ID_MASK, .name = "Microchip KSZ9131 Gigabit PHY", /* PHY_GBIT_FEATURES */ - .driver_data = &ksz9021_type, + .driver_data = &ksz9131_type, .probe = kszphy_probe, .config_init = ksz9131_config_init, .read_status = genphy_read_status, -- 2.21.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] dt-bindings: net: phy: micrel: add LED mode behavior and select properties 2020-12-09 14:04 [PATCH 0/2] Add LED mode behavior/select properties and handle Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 1/2] net: phy: micrel: add LED control on KSZ9131 Ivan Mikhaylov @ 2020-12-09 14:05 ` Ivan Mikhaylov 2020-12-09 23:05 ` [PATCH 0/2] Add LED mode behavior/select properties and handle Andrew Lunn 2020-12-16 22:41 ` Pavel Machek 3 siblings, 0 replies; 9+ messages in thread From: Ivan Mikhaylov @ 2020-12-09 14:05 UTC (permalink / raw) To: David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King Cc: Ivan Mikhaylov, netdev, devicetree, linux-kernel Add LED mode behavior and LED mode select properties which can be used in KSZ9131 PHY. Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com> --- Documentation/devicetree/bindings/net/micrel.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/net/micrel.txt b/Documentation/devicetree/bindings/net/micrel.txt index 8d157f0295a5..3022c979287a 100644 --- a/Documentation/devicetree/bindings/net/micrel.txt +++ b/Documentation/devicetree/bindings/net/micrel.txt @@ -16,9 +16,16 @@ Optional properties: KSZ8051: register 0x1f, bits 5..4 KSZ8081: register 0x1f, bits 5..4 KSZ8091: register 0x1f, bits 5..4 + KSZ9131: register 0x1a, bit 14 See the respective PHY datasheet for the mode values. + - micrel,led-mode-select + See the respective PHY datasheet for the mode select values. + + - micrel,led-mode-behavior + See the respective PHY datasheet for the mode behavior values. + - micrel,rmii-reference-clock-select-25-mhz: RMII Reference Clock Select bit selects 25 MHz mode -- 2.21.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] Add LED mode behavior/select properties and handle 2020-12-09 14:04 [PATCH 0/2] Add LED mode behavior/select properties and handle Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 1/2] net: phy: micrel: add LED control on KSZ9131 Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 2/2] dt-bindings: net: phy: micrel: add LED mode behavior and select properties Ivan Mikhaylov @ 2020-12-09 23:05 ` Andrew Lunn 2020-12-16 22:41 ` Pavel Machek 3 siblings, 0 replies; 9+ messages in thread From: Andrew Lunn @ 2020-12-09 23:05 UTC (permalink / raw) To: Ivan Mikhaylov Cc: David S . Miller, Jakub Kicinski, Rob Herring, Florian Fainelli, Heiner Kallweit, Russell King, netdev, devicetree, linux-kernel On Wed, Dec 09, 2020 at 05:04:59PM +0300, Ivan Mikhaylov wrote: > In KSZ9131 PHY it is possible to control LEDs blink behavior via > LED mode behavior and select registers. Add DTS properties plus handles > of them inside micrel PHY driver. > > I've some concerns about passing raw register values into LED mode > select and behavior. There was been some work done allowing PHY LEDs to be controlled just like other LEDs in Linux. That is how this should be done. Please go look back in the netdev and LED mailing list archives, and join that work. Andrew ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] Add LED mode behavior/select properties and handle 2020-12-09 14:04 [PATCH 0/2] Add LED mode behavior/select properties and handle Ivan Mikhaylov ` (2 preceding siblings ...) 2020-12-09 23:05 ` [PATCH 0/2] Add LED mode behavior/select properties and handle Andrew Lunn @ 2020-12-16 22:41 ` Pavel Machek 2024-11-12 8:10 ` Alexander Wilhelm 2024-11-12 8:19 ` Alexander Wilhelm 3 siblings, 2 replies; 9+ messages in thread From: Pavel Machek @ 2020-12-16 22:41 UTC (permalink / raw) To: Ivan Mikhaylov, marek.behun, linux-leds Cc: David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King, netdev, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 998 bytes --] Hi! > In KSZ9131 PHY it is possible to control LEDs blink behavior via > LED mode behavior and select registers. Add DTS properties plus handles > of them inside micrel PHY driver. > > I've some concerns about passing raw register values into LED mode > select and behavior. It can be passed via array like in microchip > driver(Documentation/devicetree/bindings/net/microchip,lan78xx.txt). > There is the problem in this particular driver - there is a lot of other PHYs > and led mode behavior/select states may intersect, that's the reason why > I did it this way. Is there any good ways to make it look more > properly? Lets... not do this? We have a LED subsystem which should probably control the LEDs... so user can specify behaviours at run-time, instead of them being hard-coded in the device tree. Plus, LED subsystem will use same interface for networks LEDs as for ... other LEDs. Best regards, Pavel -- http://www.livejournal.com/~pavelmachek [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] Add LED mode behavior/select properties and handle 2020-12-16 22:41 ` Pavel Machek @ 2024-11-12 8:10 ` Alexander Wilhelm 2024-11-12 8:19 ` Alexander Wilhelm 1 sibling, 0 replies; 9+ messages in thread From: Alexander Wilhelm @ 2024-11-12 8:10 UTC (permalink / raw) To: pavel Cc: andrew, davem, devicetree, f.fainelli, hkallweit1, i.mikhaylov, kuba, linux-kernel, linux-leds, linux, marek.behun, netdev, robh+dt ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] Add LED mode behavior/select properties and handle 2020-12-16 22:41 ` Pavel Machek 2024-11-12 8:10 ` Alexander Wilhelm @ 2024-11-12 8:19 ` Alexander Wilhelm 2024-11-12 8:49 ` Marek Behún 1 sibling, 1 reply; 9+ messages in thread From: Alexander Wilhelm @ 2024-11-12 8:19 UTC (permalink / raw) To: Pavel Machek Cc: Ivan Mikhaylov, marek.behun, linux-leds, David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King, netdev, devicetree, linux-kernel Am Wed, Dec 16, 2020 at 11:41:19PM +0100 schrieb Pavel Machek: > Hi! > > > In KSZ9131 PHY it is possible to control LEDs blink behavior via > > LED mode behavior and select registers. Add DTS properties plus handles > > of them inside micrel PHY driver. > > > > I've some concerns about passing raw register values into LED mode > > select and behavior. It can be passed via array like in microchip > > driver(Documentation/devicetree/bindings/net/microchip,lan78xx.txt). > > There is the problem in this particular driver - there is a lot of other PHYs > > and led mode behavior/select states may intersect, that's the reason why > > I did it this way. Is there any good ways to make it look more > > properly? > > Lets... not do this? > > We have a LED subsystem which should probably control the LEDs... so > user can specify behaviours at run-time, instead of them being > hard-coded in the device tree. > > Plus, LED subsystem will use same interface for networks LEDs as for > ... other LEDs. Hi Pavel, I would also like to control the LEDs via subsystem interface, but how I can configure those to be visible in 'sys/class/leds'? My LEDs are connected directly to KSZ9131RNX phy device and not to any of GPIO available on the CPU. Am I missing some DTS entries therefore? Best regards Alexander Wilhelm > > Best regards, > Pavel > -- > http://www.livejournal.com/~pavelmachek ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] Add LED mode behavior/select properties and handle 2024-11-12 8:19 ` Alexander Wilhelm @ 2024-11-12 8:49 ` Marek Behún 2024-11-12 9:10 ` Alexander Wilhelm 0 siblings, 1 reply; 9+ messages in thread From: Marek Behún @ 2024-11-12 8:49 UTC (permalink / raw) To: Alexander Wilhelm Cc: Pavel Machek, Ivan Mikhaylov, linux-leds, David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King, netdev, devicetree, linux-kernel On Tue, Nov 12, 2024 at 09:19:59AM +0100, Alexander Wilhelm wrote: > Am Wed, Dec 16, 2020 at 11:41:19PM +0100 schrieb Pavel Machek: > > Hi! > > > > > In KSZ9131 PHY it is possible to control LEDs blink behavior via > > > LED mode behavior and select registers. Add DTS properties plus handles > > > of them inside micrel PHY driver. > > > > > > I've some concerns about passing raw register values into LED mode > > > select and behavior. It can be passed via array like in microchip > > > driver(Documentation/devicetree/bindings/net/microchip,lan78xx.txt). > > > There is the problem in this particular driver - there is a lot of other PHYs > > > and led mode behavior/select states may intersect, that's the reason why > > > I did it this way. Is there any good ways to make it look more > > > properly? > > > > Lets... not do this? > > > > We have a LED subsystem which should probably control the LEDs... so > > user can specify behaviours at run-time, instead of them being > > hard-coded in the device tree. > > > > Plus, LED subsystem will use same interface for networks LEDs as for > > ... other LEDs. > > Hi Pavel, > > I would also like to control the LEDs via subsystem interface, but how I can > configure those to be visible in 'sys/class/leds'? My LEDs are connected > directly to KSZ9131RNX phy device and not to any of GPIO available on the CPU. > Am I missing some DTS entries therefore? The KSZ9131RNX driver needs to implement some LED methods, like .led_brightness_set(), .led_blink_set(), .led_hw_is_supported(), .led_hw_control_set(), .led_hw_control_get(). Look for example at marvell.c driver, or broadcom.c. Regarding DTS, look at linux/arch/arm/boot/dts/marvell/armada-370-rd.dts. The ethernet-phy@0 node has leds subnode, describing the LEDs. Marek ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] Add LED mode behavior/select properties and handle 2024-11-12 8:49 ` Marek Behún @ 2024-11-12 9:10 ` Alexander Wilhelm 0 siblings, 0 replies; 9+ messages in thread From: Alexander Wilhelm @ 2024-11-12 9:10 UTC (permalink / raw) To: Marek Behún Cc: Pavel Machek, Ivan Mikhaylov, linux-leds, David S . Miller, Jakub Kicinski, Rob Herring, Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King, netdev, devicetree, linux-kernel Am Tue, Nov 12, 2024 at 09:49:03AM +0100 schrieb Marek Behún: > On Tue, Nov 12, 2024 at 09:19:59AM +0100, Alexander Wilhelm wrote: > > Am Wed, Dec 16, 2020 at 11:41:19PM +0100 schrieb Pavel Machek: > > > Hi! > > > > > > > In KSZ9131 PHY it is possible to control LEDs blink behavior via > > > > LED mode behavior and select registers. Add DTS properties plus handles > > > > of them inside micrel PHY driver. > > > > > > > > I've some concerns about passing raw register values into LED mode > > > > select and behavior. It can be passed via array like in microchip > > > > driver(Documentation/devicetree/bindings/net/microchip,lan78xx.txt). > > > > There is the problem in this particular driver - there is a lot of other PHYs > > > > and led mode behavior/select states may intersect, that's the reason why > > > > I did it this way. Is there any good ways to make it look more > > > > properly? > > > > > > Lets... not do this? > > > > > > We have a LED subsystem which should probably control the LEDs... so > > > user can specify behaviours at run-time, instead of them being > > > hard-coded in the device tree. > > > > > > Plus, LED subsystem will use same interface for networks LEDs as for > > > ... other LEDs. > > > > Hi Pavel, > > > > I would also like to control the LEDs via subsystem interface, but how I can > > configure those to be visible in 'sys/class/leds'? My LEDs are connected > > directly to KSZ9131RNX phy device and not to any of GPIO available on the CPU. > > Am I missing some DTS entries therefore? > > The KSZ9131RNX driver needs to implement some LED methods, like > .led_brightness_set(), .led_blink_set(), .led_hw_is_supported(), > .led_hw_control_set(), .led_hw_control_get(). > > Look for example at marvell.c driver, or broadcom.c. > > Regarding DTS, look at linux/arch/arm/boot/dts/marvell/armada-370-rd.dts. > The ethernet-phy@0 node has leds subnode, describing the LEDs. > > Marek Hi Marek, thank you a lot. I think I got the main idea how the LED interface intended to work. The current linux master does not implement those callbacks for the micrel phy. I will look into implementing these functions if I am given enough time to do so. Best regards Alexander Wilhelm ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-12 9:11 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-12-09 14:04 [PATCH 0/2] Add LED mode behavior/select properties and handle Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 1/2] net: phy: micrel: add LED control on KSZ9131 Ivan Mikhaylov 2020-12-09 14:05 ` [PATCH 2/2] dt-bindings: net: phy: micrel: add LED mode behavior and select properties Ivan Mikhaylov 2020-12-09 23:05 ` [PATCH 0/2] Add LED mode behavior/select properties and handle Andrew Lunn 2020-12-16 22:41 ` Pavel Machek 2024-11-12 8:10 ` Alexander Wilhelm 2024-11-12 8:19 ` Alexander Wilhelm 2024-11-12 8:49 ` Marek Behún 2024-11-12 9:10 ` Alexander Wilhelm
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).