From: Andrew Lunn <andrew@lunn.ch>
To: netdev <netdev@vger.kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Christian Marangi <ansuelsmth@gmail.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH RFC net-next 5/8] dsa: Plumb in LED calls needed for hardware offload
Date: Wed, 29 Nov 2023 00:21:32 +0100 [thread overview]
Message-ID: <20231128232135.358638-6-andrew@lunn.ch> (raw)
In-Reply-To: <20231128232135.358638-1-andrew@lunn.ch>
In order to offload blinking of the LED to hardware, additional calls
are needed into the LED driver. Add them to the DSA core abstraction.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
include/net/dsa.h | 6 +++++
net/dsa/dsa.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2e05e4fd0b76..19f1338ac604 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -1249,6 +1249,12 @@ struct dsa_switch_ops {
u8 led, enum led_brightness value);
int (*led_blink_set)(struct dsa_switch *ds, int port, u8 led,
unsigned long *delay_on, unsigned long *delay_off);
+ int (*led_hw_control_is_supported)(struct dsa_switch *ds, int port,
+ u8 led, unsigned long flags);
+ int (*led_hw_control_set)(struct dsa_switch *ds, int port, u8 led,
+ unsigned long flags);
+ int (*led_hw_control_get)(struct dsa_switch *ds, int port, u8 led,
+ unsigned long *flags);
};
#define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes) \
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index b13748f9b519..16e51020bc5e 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -492,6 +492,52 @@ static int dsa_led_blink_set(struct led_classdev *led_cdev,
delay_on, delay_off);
}
+static __maybe_unused int
+dsa_led_hw_control_is_supported(struct led_classdev *led_cdev,
+ unsigned long flags)
+{
+ struct dsa_led *dsa_led = to_dsa_led(led_cdev);
+ struct dsa_port *dp = dsa_led->dp;
+ struct dsa_switch *ds = dp->ds;
+
+ return ds->ops->led_hw_control_is_supported(ds, dp->index,
+ dsa_led->index,
+ flags);
+}
+
+static __maybe_unused int dsa_led_hw_control_set(struct led_classdev *led_cdev,
+ unsigned long flags)
+{
+ struct dsa_led *dsa_led = to_dsa_led(led_cdev);
+ struct dsa_port *dp = dsa_led->dp;
+ struct dsa_switch *ds = dp->ds;
+
+ return ds->ops->led_hw_control_set(ds, dp->index, dsa_led->index,
+ flags);
+}
+
+static __maybe_unused int dsa_led_hw_control_get(struct led_classdev *led_cdev,
+ unsigned long *flags)
+{
+ struct dsa_led *dsa_led = to_dsa_led(led_cdev);
+ struct dsa_port *dp = dsa_led->dp;
+ struct dsa_switch *ds = dp->ds;
+
+ return ds->ops->led_hw_control_get(ds, dp->index, dsa_led->index,
+ flags);
+}
+
+static struct device *
+dsa_led_hw_control_get_device(struct led_classdev *led_cdev)
+{
+ struct dsa_led *dsa_led = to_dsa_led(led_cdev);
+ struct dsa_port *dp = dsa_led->dp;
+
+ if (dp->user)
+ return &dp->user->dev;
+ return NULL;
+}
+
static int dsa_port_led_setup(struct dsa_port *dp,
struct device_node *led)
{
@@ -521,7 +567,16 @@ static int dsa_port_led_setup(struct dsa_port *dp,
cdev->brightness_set_blocking = dsa_led_brightness_set;
if (ds->ops->led_blink_set)
cdev->blink_set = dsa_led_blink_set;
-
+#ifdef CONFIG_LEDS_TRIGGERS
+ if (ds->ops->led_hw_control_is_supported)
+ cdev->hw_control_is_supported = dsa_led_hw_control_is_supported;
+ if (ds->ops->led_hw_control_set)
+ cdev->hw_control_set = dsa_led_hw_control_set;
+ if (ds->ops->led_hw_control_get)
+ cdev->hw_control_get = dsa_led_hw_control_get;
+ cdev->hw_control_trigger = "netdev";
+#endif
+ cdev->hw_control_get_device = dsa_led_hw_control_get_device;
cdev->max_brightness = 1;
init_data.fwnode = of_fwnode_handle(led);
--
2.42.0
next prev parent reply other threads:[~2023-11-28 23:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 23:21 [PATCH RFC net-next 0/8] DSA LED infrastructure, mv88e6xxx and QCA8K Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 1/8] net: dsa: mv88e6xxx: Add helpers for 6352 LED blink and brightness Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 2/8] net: dsa: mv88e6xxx: Tie the low level LED functions to device ops Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 3/8] net: dsa: Plumb LED brightnes and blink into switch API Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 4/8] dsa: Create port LEDs based on DT binding Andrew Lunn
2023-11-29 1:46 ` Christian Marangi
2023-11-29 19:40 ` Simon Horman
2023-11-29 20:07 ` Andrew Lunn
2023-11-28 23:21 ` Andrew Lunn [this message]
2023-11-28 23:21 ` [PATCH RFC net-next 6/8] dsa: mv88e6xxx: Plumb in LED offload functions Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 7/8] arm: boot: dts: mvebu: linksys-mamba: Add Ethernet LEDs Andrew Lunn
2023-11-28 23:21 ` [PATCH RFC net-next 8/8] dsa: qca8k: Use DSA common code for LEDs Andrew Lunn
2023-11-29 1:55 ` Christian Marangi
2023-11-29 2:16 ` Andrew Lunn
2023-11-29 2:23 ` Christian Marangi
2023-11-29 1:57 ` [PATCH RFC net-next 0/8] DSA LED infrastructure, mv88e6xxx and QCA8K Christian Marangi
2023-11-29 12:38 ` Vladimir Oltean
2023-11-29 15:13 ` Andrew Lunn
2023-11-29 15:43 ` Vladimir Oltean
2023-11-29 16:27 ` Andrew Lunn
2023-11-29 16:44 ` Vladimir Oltean
2023-11-29 21:51 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231128232135.358638-6-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=netdev@vger.kernel.org \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).