* [PATCH leds 0/8] Turris Omnia LED driver changes
@ 2024-09-02 12:40 Marek Behún
2024-09-02 12:40 ` [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header Marek Behún
` (7 more replies)
0 siblings, 8 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:40 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
Hello Lee,
this series is for 6.12, but it depends on changes that have been
merged to 6.11-rc3. Your for-leds-next branch is based on 6.11-rc1, so
it won't apply there.
This series does two things:
1. It drops the code for executing MCU commands from the LEDs driver and
instead starts using the functions from the turris-omnia-mcu platform
driver. This is so that we don't have the same code at two places.
2. It adds support for the global LED brightness change interrupt to the
LED driver. This interrupt is exposed by the MCU driver. Userspace
can poll for global LED brightness change (triggered by pressing the
front button) by polling the corresponding sysfs file,
/sys/class/leds/<led>/device/brightness, documented in
Documentation/ABI/testing/sysfs-class-led-driver-turris-omnia.
Marek
Marek Behún (8):
turris-omnia-mcu-interface.h: Move command execution function to
global header
leds: turris-omnia: Use command execution functions from the MCU
driver
turris-omnia-mcu-interface.h: Add LED commands related definitions to
global header
leds: turris-omnia: Use global header for MCU command definitions
leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change
platform: cznic: turris-omnia-mcu: Inform about missing LED panel
brightness change interrupt feature
leds: turris-omnia: Inform about missing LED gamma correction feature
in the MCU driver
ARM: dts: turris-omnia: Add global LED brightness change interrupt
.../dts/marvell/armada-385-turris-omnia.dts | 1 +
drivers/leds/leds-turris-omnia.c | 228 +++++++++---------
.../platform/cznic/turris-omnia-mcu-base.c | 3 +
drivers/platform/cznic/turris-omnia-mcu.h | 130 ----------
include/linux/turris-omnia-mcu-interface.h | 147 +++++++++++
5 files changed, 259 insertions(+), 250 deletions(-)
--
2.44.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
@ 2024-09-02 12:40 ` Marek Behún
2024-09-02 12:55 ` Andy Shevchenko
2024-09-02 12:40 ` [PATCH leds 2/8] leds: turris-omnia: Use command execution functions from the MCU driver Marek Behún
` (6 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:40 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
Move the command execution functions from the turris-omnia-mcu platform
driver private header to the global turris-omnia-mcu-interface.h header,
so that they can be used by the LED driver.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
.../platform/cznic/turris-omnia-mcu-base.c | 1 +
drivers/platform/cznic/turris-omnia-mcu.h | 130 -----------------
include/linux/turris-omnia-mcu-interface.h | 135 ++++++++++++++++++
3 files changed, 136 insertions(+), 130 deletions(-)
diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c
index 58f9afae2867..bb871226e357 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-base.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-base.c
@@ -52,6 +52,7 @@ int omnia_cmd_write_read(const struct i2c_client *client,
return 0;
}
+EXPORT_SYMBOL_GPL(omnia_cmd_write_read);
static int omnia_get_version_hash(struct omnia_mcu *mcu, bool bootloader,
char version[static OMNIA_FW_VERSION_HEX_LEN])
diff --git a/drivers/platform/cznic/turris-omnia-mcu.h b/drivers/platform/cznic/turris-omnia-mcu.h
index fed0d357fea3..b36f9626e660 100644
--- a/drivers/platform/cznic/turris-omnia-mcu.h
+++ b/drivers/platform/cznic/turris-omnia-mcu.h
@@ -8,7 +8,6 @@
#ifndef __TURRIS_OMNIA_MCU_H
#define __TURRIS_OMNIA_MCU_H
-#include <linux/bitops.h>
#include <linux/completion.h>
#include <linux/gpio/driver.h>
#include <linux/hw_random.h>
@@ -17,8 +16,6 @@
#include <linux/types.h>
#include <linux/watchdog.h>
#include <linux/workqueue.h>
-#include <asm/byteorder.h>
-#include <asm/unaligned.h>
struct i2c_client;
struct rtc_device;
@@ -63,133 +60,6 @@ struct omnia_mcu {
#endif
};
-int omnia_cmd_write_read(const struct i2c_client *client,
- void *cmd, unsigned int cmd_len,
- void *reply, unsigned int reply_len);
-
-static inline int omnia_cmd_write(const struct i2c_client *client, void *cmd,
- unsigned int len)
-{
- return omnia_cmd_write_read(client, cmd, len, NULL, 0);
-}
-
-static inline int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd,
- u8 val)
-{
- u8 buf[2] = { cmd, val };
-
- return omnia_cmd_write(client, buf, sizeof(buf));
-}
-
-static inline int omnia_cmd_write_u16(const struct i2c_client *client, u8 cmd,
- u16 val)
-{
- u8 buf[3];
-
- buf[0] = cmd;
- put_unaligned_le16(val, &buf[1]);
-
- return omnia_cmd_write(client, buf, sizeof(buf));
-}
-
-static inline int omnia_cmd_write_u32(const struct i2c_client *client, u8 cmd,
- u32 val)
-{
- u8 buf[5];
-
- buf[0] = cmd;
- put_unaligned_le32(val, &buf[1]);
-
- return omnia_cmd_write(client, buf, sizeof(buf));
-}
-
-static inline int omnia_cmd_read(const struct i2c_client *client, u8 cmd,
- void *reply, unsigned int len)
-{
- return omnia_cmd_write_read(client, &cmd, 1, reply, len);
-}
-
-static inline unsigned int
-omnia_compute_reply_length(unsigned long mask, bool interleaved,
- unsigned int offset)
-{
- if (!mask)
- return 0;
-
- return ((__fls(mask) >> 3) << interleaved) + 1 + offset;
-}
-
-/* Returns 0 on success */
-static inline int omnia_cmd_read_bits(const struct i2c_client *client, u8 cmd,
- unsigned long bits, unsigned long *dst)
-{
- __le32 reply;
- int err;
-
- if (!bits) {
- *dst = 0;
- return 0;
- }
-
- err = omnia_cmd_read(client, cmd, &reply,
- omnia_compute_reply_length(bits, false, 0));
- if (err)
- return err;
-
- *dst = le32_to_cpu(reply) & bits;
-
- return 0;
-}
-
-static inline int omnia_cmd_read_bit(const struct i2c_client *client, u8 cmd,
- unsigned long bit)
-{
- unsigned long reply;
- int err;
-
- err = omnia_cmd_read_bits(client, cmd, bit, &reply);
- if (err)
- return err;
-
- return !!reply;
-}
-
-static inline int omnia_cmd_read_u32(const struct i2c_client *client, u8 cmd,
- u32 *dst)
-{
- __le32 reply;
- int err;
-
- err = omnia_cmd_read(client, cmd, &reply, sizeof(reply));
- if (err)
- return err;
-
- *dst = le32_to_cpu(reply);
-
- return 0;
-}
-
-static inline int omnia_cmd_read_u16(const struct i2c_client *client, u8 cmd,
- u16 *dst)
-{
- __le16 reply;
- int err;
-
- err = omnia_cmd_read(client, cmd, &reply, sizeof(reply));
- if (err)
- return err;
-
- *dst = le16_to_cpu(reply);
-
- return 0;
-}
-
-static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd,
- u8 *reply)
-{
- return omnia_cmd_read(client, cmd, reply, sizeof(*reply));
-}
-
#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
extern const u8 omnia_int_to_gpio_idx[32];
extern const struct attribute_group omnia_mcu_gpio_group;
diff --git a/include/linux/turris-omnia-mcu-interface.h b/include/linux/turris-omnia-mcu-interface.h
index 2da8cbeb158a..eab67b81f310 100644
--- a/include/linux/turris-omnia-mcu-interface.h
+++ b/include/linux/turris-omnia-mcu-interface.h
@@ -9,7 +9,11 @@
#define __TURRIS_OMNIA_MCU_INTERFACE_H
#include <linux/bitfield.h>
+#include <linux/bitops.h>
#include <linux/bits.h>
+#include <linux/types.h>
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
enum omnia_commands_e {
OMNIA_CMD_GET_STATUS_WORD = 0x01, /* slave sends status word back */
@@ -246,4 +250,135 @@ enum omnia_cmd_usb_ovc_prot_e {
OMNIA_CMD_xET_USB_OVC_PROT_ENABLE = BIT(4),
};
+/* Command execution functions */
+
+struct i2c_client;
+
+int omnia_cmd_write_read(const struct i2c_client *client,
+ void *cmd, unsigned int cmd_len,
+ void *reply, unsigned int reply_len);
+
+static inline int omnia_cmd_write(const struct i2c_client *client, void *cmd,
+ unsigned int len)
+{
+ return omnia_cmd_write_read(client, cmd, len, NULL, 0);
+}
+
+static inline int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd,
+ u8 val)
+{
+ u8 buf[2] = { cmd, val };
+
+ return omnia_cmd_write(client, buf, sizeof(buf));
+}
+
+static inline int omnia_cmd_write_u16(const struct i2c_client *client, u8 cmd,
+ u16 val)
+{
+ u8 buf[3];
+
+ buf[0] = cmd;
+ put_unaligned_le16(val, &buf[1]);
+
+ return omnia_cmd_write(client, buf, sizeof(buf));
+}
+
+static inline int omnia_cmd_write_u32(const struct i2c_client *client, u8 cmd,
+ u32 val)
+{
+ u8 buf[5];
+
+ buf[0] = cmd;
+ put_unaligned_le32(val, &buf[1]);
+
+ return omnia_cmd_write(client, buf, sizeof(buf));
+}
+
+static inline int omnia_cmd_read(const struct i2c_client *client, u8 cmd,
+ void *reply, unsigned int len)
+{
+ return omnia_cmd_write_read(client, &cmd, 1, reply, len);
+}
+
+static inline unsigned int
+omnia_compute_reply_length(unsigned long mask, bool interleaved,
+ unsigned int offset)
+{
+ if (!mask)
+ return 0;
+
+ return ((__fls(mask) >> 3) << interleaved) + 1 + offset;
+}
+
+/* Returns 0 on success */
+static inline int omnia_cmd_read_bits(const struct i2c_client *client, u8 cmd,
+ unsigned long bits, unsigned long *dst)
+{
+ __le32 reply;
+ int err;
+
+ if (!bits) {
+ *dst = 0;
+ return 0;
+ }
+
+ err = omnia_cmd_read(client, cmd, &reply,
+ omnia_compute_reply_length(bits, false, 0));
+ if (err)
+ return err;
+
+ *dst = le32_to_cpu(reply) & bits;
+
+ return 0;
+}
+
+static inline int omnia_cmd_read_bit(const struct i2c_client *client, u8 cmd,
+ unsigned long bit)
+{
+ unsigned long reply;
+ int err;
+
+ err = omnia_cmd_read_bits(client, cmd, bit, &reply);
+ if (err)
+ return err;
+
+ return !!reply;
+}
+
+static inline int omnia_cmd_read_u32(const struct i2c_client *client, u8 cmd,
+ u32 *dst)
+{
+ __le32 reply;
+ int err;
+
+ err = omnia_cmd_read(client, cmd, &reply, sizeof(reply));
+ if (err)
+ return err;
+
+ *dst = le32_to_cpu(reply);
+
+ return 0;
+}
+
+static inline int omnia_cmd_read_u16(const struct i2c_client *client, u8 cmd,
+ u16 *dst)
+{
+ __le16 reply;
+ int err;
+
+ err = omnia_cmd_read(client, cmd, &reply, sizeof(reply));
+ if (err)
+ return err;
+
+ *dst = le16_to_cpu(reply);
+
+ return 0;
+}
+
+static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd,
+ u8 *reply)
+{
+ return omnia_cmd_read(client, cmd, reply, sizeof(*reply));
+}
+
#endif /* __TURRIS_OMNIA_MCU_INTERFACE_H */
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 2/8] leds: turris-omnia: Use command execution functions from the MCU driver
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
2024-09-02 12:40 ` [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header Marek Behún
@ 2024-09-02 12:40 ` Marek Behún
2024-09-02 12:40 ` [PATCH leds 3/8] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Marek Behún
` (5 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:40 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
Use the MCU command execution functions from the MCU driver instead of
the ad-hoc implementation in the LED driver. This allows as to drop the
LED driver implementation, which is a duplicate.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/leds/leds-turris-omnia.c | 88 ++++++++------------------------
1 file changed, 22 insertions(+), 66 deletions(-)
diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
index 4cff8c4b020c..b9dd971a9e5f 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -2,7 +2,7 @@
/*
* CZ.NIC's Turris Omnia LEDs driver
*
- * 2020, 2023 by Marek Behún <kabel@kernel.org>
+ * 2020, 2023, 2024 by Marek Behún <kabel@kernel.org>
*/
#include <linux/i2c.h>
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/turris-omnia-mcu-interface.h>
#include "leds.h"
#define OMNIA_BOARD_LEDS 12
@@ -57,52 +58,6 @@ struct omnia_leds {
struct omnia_led leds[];
};
-static int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, u8 val)
-{
- u8 buf[2] = { cmd, val };
- int ret;
-
- ret = i2c_master_send(client, buf, sizeof(buf));
-
- return ret < 0 ? ret : 0;
-}
-
-static int omnia_cmd_read_raw(struct i2c_adapter *adapter, u8 addr, u8 cmd,
- void *reply, size_t len)
-{
- struct i2c_msg msgs[2];
- int ret;
-
- msgs[0].addr = addr;
- msgs[0].flags = 0;
- msgs[0].len = 1;
- msgs[0].buf = &cmd;
- msgs[1].addr = addr;
- msgs[1].flags = I2C_M_RD;
- msgs[1].len = len;
- msgs[1].buf = reply;
-
- ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
- if (likely(ret == ARRAY_SIZE(msgs)))
- return 0;
- else if (ret < 0)
- return ret;
- else
- return -EIO;
-}
-
-static int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd)
-{
- u8 reply;
- int err;
-
- err = omnia_cmd_read_raw(client->adapter, client->addr, cmd, &reply, 1);
- if (err)
- return err;
-
- return reply;
-}
-
static int omnia_led_send_color_cmd(const struct i2c_client *client,
struct omnia_led *led)
{
@@ -352,14 +307,14 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
- int ret;
-
- ret = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS);
+ u8 reply;
+ int err;
- if (ret < 0)
- return ret;
+ err = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS, &reply);
+ if (err < 0)
+ return err;
- return sysfs_emit(buf, "%d\n", ret);
+ return sysfs_emit(buf, "%d\n", reply);
}
static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
@@ -386,17 +341,16 @@ static ssize_t gamma_correction_show(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct omnia_leds *leds = i2c_get_clientdata(client);
- int ret;
+ u8 reply = 0;
+ int err;
if (leds->has_gamma_correction) {
- ret = omnia_cmd_read_u8(client, CMD_GET_GAMMA_CORRECTION);
- if (ret < 0)
- return ret;
- } else {
- ret = 0;
+ err = omnia_cmd_read_u8(client, CMD_GET_GAMMA_CORRECTION, &reply);
+ if (err < 0)
+ return err;
}
- return sysfs_emit(buf, "%d\n", !!ret);
+ return sysfs_emit(buf, "%d\n", !!reply);
}
static ssize_t gamma_correction_store(struct device *dev,
@@ -429,24 +383,26 @@ ATTRIBUTE_GROUPS(omnia_led_controller);
static int omnia_mcu_get_features(const struct i2c_client *client)
{
+ struct i2c_client mcu_client = *client;
u16 reply;
int err;
- err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR,
- CMD_GET_STATUS_WORD, &reply, sizeof(reply));
+ /* We have to read features from different I2C address */
+ mcu_client.addr = OMNIA_MCU_I2C_ADDR;
+
+ err = omnia_cmd_read_u16(&mcu_client, CMD_GET_STATUS_WORD, &reply);
if (err)
return err;
/* Check whether MCU firmware supports the CMD_GET_FEAUTRES command */
- if (!(le16_to_cpu(reply) & STS_FEATURES_SUPPORTED))
+ if (!(reply & STS_FEATURES_SUPPORTED))
return 0;
- err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR,
- CMD_GET_FEATURES, &reply, sizeof(reply));
+ err = omnia_cmd_read_u16(&mcu_client, CMD_GET_FEATURES, &reply);
if (err)
return err;
- return le16_to_cpu(reply);
+ return reply;
}
static int omnia_leds_probe(struct i2c_client *client)
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 3/8] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
2024-09-02 12:40 ` [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header Marek Behún
2024-09-02 12:40 ` [PATCH leds 2/8] leds: turris-omnia: Use command execution functions from the MCU driver Marek Behún
@ 2024-09-02 12:40 ` Marek Behún
2024-09-02 12:41 ` [PATCH leds 4/8] leds: turris-omnia: Use global header for MCU command definitions Marek Behún
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:40 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
Add definitions for contents of the OMNIA_CMD_LED_MODE and
OMNIA_CMD_LED_STATE commands to the global turris-omnia-mcu-interface.h
header.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
include/linux/turris-omnia-mcu-interface.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/turris-omnia-mcu-interface.h b/include/linux/turris-omnia-mcu-interface.h
index eab67b81f310..bf5d04e53809 100644
--- a/include/linux/turris-omnia-mcu-interface.h
+++ b/include/linux/turris-omnia-mcu-interface.h
@@ -240,6 +240,18 @@ enum omnia_int_e {
OMNIA_INT_LAN5_LED1 = BIT(31),
};
+enum omnia_cmd_led_mode_e {
+ OMNIA_CMD_LED_MODE_LED_MASK = GENMASK(3, 0),
+#define OMNIA_CMD_LED_MODE_LED(_l) FIELD_PREP(OMNIA_CMD_LED_MODE_LED_MASK, _l)
+ OMNIA_CMD_LED_MODE_USER = BIT(4),
+};
+
+enum omnia_cmd_led_state_e {
+ OMNIA_CMD_LED_STATE_LED_MASK = GENMASK(3, 0),
+#define OMNIA_CMD_LED_STATE_LED(_l) FIELD_PREP(OMNIA_CMD_LED_STATE_LED_MASK, _l)
+ OMNIA_CMD_LED_STATE_ON = BIT(4),
+};
+
enum omnia_cmd_poweroff_e {
OMNIA_CMD_POWER_OFF_POWERON_BUTTON = BIT(0),
OMNIA_CMD_POWER_OFF_MAGIC = 0xdead,
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 4/8] leds: turris-omnia: Use global header for MCU command definitions
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
` (2 preceding siblings ...)
2024-09-02 12:40 ` [PATCH leds 3/8] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Marek Behún
@ 2024-09-02 12:41 ` Marek Behún
2024-09-02 12:41 ` [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Marek Behún
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:41 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
The global turris-omnia-mcu-interface.h header file contains the
definitions for MCU commands. Drop the driver-internal definitions and
use the global ones.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/leds/leds-turris-omnia.c | 78 ++++++++++++--------------------
1 file changed, 28 insertions(+), 50 deletions(-)
diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
index b9dd971a9e5f..14e8fbb5bb69 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -16,30 +16,8 @@
#define OMNIA_BOARD_LEDS 12
#define OMNIA_LED_NUM_CHANNELS 3
-/* MCU controller commands at I2C address 0x2a */
-#define OMNIA_MCU_I2C_ADDR 0x2a
-
-#define CMD_GET_STATUS_WORD 0x01
-#define STS_FEATURES_SUPPORTED BIT(2)
-
-#define CMD_GET_FEATURES 0x10
-#define FEAT_LED_GAMMA_CORRECTION BIT(5)
-
-/* LED controller commands at I2C address 0x2b */
-#define CMD_LED_MODE 0x03
-#define CMD_LED_MODE_LED(l) ((l) & 0x0f)
-#define CMD_LED_MODE_USER 0x10
-
-#define CMD_LED_STATE 0x04
-#define CMD_LED_STATE_LED(l) ((l) & 0x0f)
-#define CMD_LED_STATE_ON 0x10
-
-#define CMD_LED_COLOR 0x05
-#define CMD_LED_SET_BRIGHTNESS 0x07
-#define CMD_LED_GET_BRIGHTNESS 0x08
-
-#define CMD_SET_GAMMA_CORRECTION 0x30
-#define CMD_GET_GAMMA_CORRECTION 0x31
+/* MCU controller I2C address 0x2a, needed for detecting MCU features */
+#define OMNIA_MCU_I2C_ADDR 0x2a
struct omnia_led {
struct led_classdev_mc mc_cdev;
@@ -64,7 +42,7 @@ static int omnia_led_send_color_cmd(const struct i2c_client *client,
char cmd[5];
int ret;
- cmd[0] = CMD_LED_COLOR;
+ cmd[0] = OMNIA_CMD_LED_COLOR;
cmd[1] = led->reg;
cmd[2] = led->subled_info[0].brightness;
cmd[3] = led->subled_info[1].brightness;
@@ -126,12 +104,12 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
* is not being blinked by HW.
*/
if (!err && !led->hwtrig && !brightness != !led->on) {
- u8 state = CMD_LED_STATE_LED(led->reg);
+ u8 state = OMNIA_CMD_LED_STATE_LED(led->reg);
if (brightness)
- state |= CMD_LED_STATE_ON;
+ state |= OMNIA_CMD_LED_STATE_ON;
- err = omnia_cmd_write_u8(leds->client, CMD_LED_STATE, state);
+ err = omnia_cmd_write_u8(leds->client, OMNIA_CMD_LED_STATE, state);
if (!err)
led->on = !!brightness;
}
@@ -166,8 +144,8 @@ static int omnia_hwtrig_activate(struct led_classdev *cdev)
if (!err) {
/* Put the LED into MCU controlled mode */
- err = omnia_cmd_write_u8(leds->client, CMD_LED_MODE,
- CMD_LED_MODE_LED(led->reg));
+ err = omnia_cmd_write_u8(leds->client, OMNIA_CMD_LED_MODE,
+ OMNIA_CMD_LED_MODE_LED(led->reg));
if (!err)
led->hwtrig = true;
}
@@ -188,9 +166,9 @@ static void omnia_hwtrig_deactivate(struct led_classdev *cdev)
led->hwtrig = false;
/* Put the LED into software mode */
- err = omnia_cmd_write_u8(leds->client, CMD_LED_MODE,
- CMD_LED_MODE_LED(led->reg) |
- CMD_LED_MODE_USER);
+ err = omnia_cmd_write_u8(leds->client, OMNIA_CMD_LED_MODE,
+ OMNIA_CMD_LED_MODE_LED(led->reg) |
+ OMNIA_CMD_LED_MODE_USER);
mutex_unlock(&leds->lock);
@@ -257,9 +235,9 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
cdev->default_trigger = omnia_hw_trigger.name;
/* put the LED into software mode */
- ret = omnia_cmd_write_u8(client, CMD_LED_MODE,
- CMD_LED_MODE_LED(led->reg) |
- CMD_LED_MODE_USER);
+ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE,
+ OMNIA_CMD_LED_MODE_LED(led->reg) |
+ OMNIA_CMD_LED_MODE_USER);
if (ret) {
dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np,
ret);
@@ -267,8 +245,8 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
}
/* disable the LED */
- ret = omnia_cmd_write_u8(client, CMD_LED_STATE,
- CMD_LED_STATE_LED(led->reg));
+ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_STATE,
+ OMNIA_CMD_LED_STATE_LED(led->reg));
if (ret) {
dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret);
return ret;
@@ -310,7 +288,7 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
u8 reply;
int err;
- err = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS, &reply);
+ err = omnia_cmd_read_u8(client, OMNIA_CMD_GET_BRIGHTNESS, &reply);
if (err < 0)
return err;
@@ -330,7 +308,7 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
if (brightness > 100)
return -EINVAL;
- err = omnia_cmd_write_u8(client, CMD_LED_SET_BRIGHTNESS, brightness);
+ err = omnia_cmd_write_u8(client, OMNIA_CMD_SET_BRIGHTNESS, brightness);
return err ?: count;
}
@@ -345,7 +323,7 @@ static ssize_t gamma_correction_show(struct device *dev,
int err;
if (leds->has_gamma_correction) {
- err = omnia_cmd_read_u8(client, CMD_GET_GAMMA_CORRECTION, &reply);
+ err = omnia_cmd_read_u8(client, OMNIA_CMD_GET_GAMMA_CORRECTION, &reply);
if (err < 0)
return err;
}
@@ -368,7 +346,7 @@ static ssize_t gamma_correction_store(struct device *dev,
if (kstrtobool(buf, &val) < 0)
return -EINVAL;
- err = omnia_cmd_write_u8(client, CMD_SET_GAMMA_CORRECTION, val);
+ err = omnia_cmd_write_u8(client, OMNIA_CMD_SET_GAMMA_CORRECTION, val);
return err ?: count;
}
@@ -390,15 +368,15 @@ static int omnia_mcu_get_features(const struct i2c_client *client)
/* We have to read features from different I2C address */
mcu_client.addr = OMNIA_MCU_I2C_ADDR;
- err = omnia_cmd_read_u16(&mcu_client, CMD_GET_STATUS_WORD, &reply);
+ err = omnia_cmd_read_u16(&mcu_client, OMNIA_CMD_GET_STATUS_WORD, &reply);
if (err)
return err;
- /* Check whether MCU firmware supports the CMD_GET_FEAUTRES command */
- if (!(reply & STS_FEATURES_SUPPORTED))
+ /* Check whether MCU firmware supports the OMNIA_CMD_GET_FEAUTRES command */
+ if (!(reply & OMNIA_STS_FEATURES_SUPPORTED))
return 0;
- err = omnia_cmd_read_u16(&mcu_client, CMD_GET_FEATURES, &reply);
+ err = omnia_cmd_read_u16(&mcu_client, OMNIA_CMD_GET_FEATURES, &reply);
if (err)
return err;
@@ -436,7 +414,7 @@ static int omnia_leds_probe(struct i2c_client *client)
return ret;
}
- leds->has_gamma_correction = ret & FEAT_LED_GAMMA_CORRECTION;
+ leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION;
if (!leds->has_gamma_correction) {
dev_info(dev,
"Your board's MCU firmware does not support the LED gamma correction feature.\n");
@@ -469,11 +447,11 @@ static void omnia_leds_remove(struct i2c_client *client)
u8 buf[5];
/* put all LEDs into default (HW triggered) mode */
- omnia_cmd_write_u8(client, CMD_LED_MODE,
- CMD_LED_MODE_LED(OMNIA_BOARD_LEDS));
+ omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE,
+ OMNIA_CMD_LED_MODE_LED(OMNIA_BOARD_LEDS));
/* set all LEDs color to [255, 255, 255] */
- buf[0] = CMD_LED_COLOR;
+ buf[0] = OMNIA_CMD_LED_COLOR;
buf[1] = OMNIA_BOARD_LEDS;
buf[2] = 255;
buf[3] = 255;
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
` (3 preceding siblings ...)
2024-09-02 12:41 ` [PATCH leds 4/8] leds: turris-omnia: Use global header for MCU command definitions Marek Behún
@ 2024-09-02 12:41 ` Marek Behún
2024-09-02 13:17 ` Andy Shevchenko
2024-09-02 12:41 ` [PATCH leds 6/8] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Marek Behún
` (2 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:41 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
Recall that on Turris Omnia, the LED controller has a global brightness
property, which allows the user to make the front LED panel dimmer.
There is also a button on the front panel, which by default is
configured so that pressing it changes the global brightness to a lower
value (unless it is at 0%, in which case pressing the button changes the
global brightness to 100%).
Newer versions of the MCU firmware support informing the SOC that the
brightness was changed by button press event via an interrupt.
Now that we have the turris-omnia-mcu driver, which adds support for MCU
interrupts, add the ability to inform the userspace (via a sysfs
notification) that the global brightness was changed.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/leds/leds-turris-omnia.c | 67 ++++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
index 14e8fbb5bb69..bf8635cec72e 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -357,7 +357,57 @@ static struct attribute *omnia_led_controller_attrs[] = {
&dev_attr_gamma_correction.attr,
NULL,
};
-ATTRIBUTE_GROUPS(omnia_led_controller);
+
+static const struct attribute_group omnia_led_controller_group = {
+ .attrs = omnia_led_controller_attrs,
+};
+
+static irqreturn_t omnia_brightness_changed_handler(int irq, void *dev_id)
+{
+ struct kernfs_node *brightness_kn = dev_id;
+
+ sysfs_notify_dirent(brightness_kn);
+
+ return IRQ_HANDLED;
+}
+
+static void brightness_kn_release(struct device *dev, void *res)
+{
+ struct kernfs_node **brightness_kn = res;
+
+ sysfs_put(*brightness_kn);
+}
+
+static int omnia_probe_brightness_interrupt(struct i2c_client *client)
+{
+ struct kernfs_node **brightness_kn;
+ struct device *dev = &client->dev;
+ int ret;
+
+ brightness_kn = devres_alloc(brightness_kn_release,
+ sizeof(*brightness_kn), GFP_KERNEL);
+ if (!brightness_kn)
+ return -ENOMEM;
+
+ *brightness_kn = sysfs_get_dirent(dev->kobj.sd, "brightness");
+ if (!*brightness_kn) {
+ devres_free(brightness_kn);
+ return -EIO;
+ }
+
+ devres_add(dev, brightness_kn);
+
+ ret = devm_request_any_context_irq(dev, client->irq,
+ omnia_brightness_changed_handler,
+ IRQF_ONESHOT, "leds-turris-omnia",
+ *brightness_kn);
+ if (ret < 0) {
+ dev_err(dev, "Cannot request IRQ: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
static int omnia_mcu_get_features(const struct i2c_client *client)
{
@@ -387,6 +437,7 @@ static int omnia_leds_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct device_node *np = dev_of_node(dev);
+ bool has_brightness_interrupt;
struct omnia_leds *leds;
struct omnia_led *led;
int ret, count;
@@ -414,6 +465,8 @@ static int omnia_leds_probe(struct i2c_client *client)
return ret;
}
+ has_brightness_interrupt = ret & OMNIA_FEAT_BRIGHTNESS_INT;
+
leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION;
if (!leds->has_gamma_correction) {
dev_info(dev,
@@ -439,7 +492,16 @@ static int omnia_leds_probe(struct i2c_client *client)
led += ret;
}
- return 0;
+ ret = devm_device_add_group(dev, &omnia_led_controller_group);
+ if (ret < 0) {
+ dev_err(dev, "Cannot add sysfs attribute group: %d\n", ret);
+ return ret;
+ }
+
+ if (has_brightness_interrupt)
+ ret = omnia_probe_brightness_interrupt(client);
+
+ return ret;
}
static void omnia_leds_remove(struct i2c_client *client)
@@ -479,7 +541,6 @@ static struct i2c_driver omnia_leds_driver = {
.driver = {
.name = "leds-turris-omnia",
.of_match_table = of_omnia_leds_match,
- .dev_groups = omnia_led_controller_groups,
},
};
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 6/8] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
` (4 preceding siblings ...)
2024-09-02 12:41 ` [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Marek Behún
@ 2024-09-02 12:41 ` Marek Behún
2024-09-02 12:41 ` [PATCH leds 7/8] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Marek Behún
2024-09-02 12:41 ` [PATCH leds 8/8] ARM: dts: turris-omnia: Add global LED brightness change interrupt Marek Behún
7 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:41 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
When reading MCU firmware features, check also for the LED panel
brightness change interrupt feature, and suggest upgrading the firmware
if it is missing.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/platform/cznic/turris-omnia-mcu-base.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c
index bb871226e357..3bb4a3cfdb29 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-base.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-base.c
@@ -258,6 +258,7 @@ static int omnia_mcu_read_features(struct omnia_mcu *mcu)
_DEF_FEAT(NEW_INT_API, "new interrupt API"),
_DEF_FEAT(POWEROFF_WAKEUP, "poweroff and wakeup"),
_DEF_FEAT(TRNG, "true random number generator"),
+ _DEF_FEAT(BRIGHTNESS_INT, "LED panel brightness change interrupt"),
#undef _DEF_FEAT
};
struct i2c_client *client = mcu->client;
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 7/8] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
` (5 preceding siblings ...)
2024-09-02 12:41 ` [PATCH leds 6/8] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Marek Behún
@ 2024-09-02 12:41 ` Marek Behún
2024-09-02 12:41 ` [PATCH leds 8/8] ARM: dts: turris-omnia: Add global LED brightness change interrupt Marek Behún
7 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:41 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
If the LED gamma correction feature is missing in the MCU firmware,
inform about this in the MCU firmware probe function instead of LED
driver probe function, so that all the feature checks are in one place.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/leds/leds-turris-omnia.c | 9 +--------
drivers/platform/cznic/turris-omnia-mcu-base.c | 1 +
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
index bf8635cec72e..7b5c1484924e 100644
--- a/drivers/leds/leds-turris-omnia.c
+++ b/drivers/leds/leds-turris-omnia.c
@@ -465,15 +465,8 @@ static int omnia_leds_probe(struct i2c_client *client)
return ret;
}
- has_brightness_interrupt = ret & OMNIA_FEAT_BRIGHTNESS_INT;
-
leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION;
- if (!leds->has_gamma_correction) {
- dev_info(dev,
- "Your board's MCU firmware does not support the LED gamma correction feature.\n");
- dev_info(dev,
- "Consider upgrading MCU firmware with the omnia-mcutool utility.\n");
- }
+ has_brightness_interrupt = ret & OMNIA_FEAT_BRIGHTNESS_INT;
mutex_init(&leds->lock);
diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c
index 3bb4a3cfdb29..770e680b96f9 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-base.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-base.c
@@ -259,6 +259,7 @@ static int omnia_mcu_read_features(struct omnia_mcu *mcu)
_DEF_FEAT(POWEROFF_WAKEUP, "poweroff and wakeup"),
_DEF_FEAT(TRNG, "true random number generator"),
_DEF_FEAT(BRIGHTNESS_INT, "LED panel brightness change interrupt"),
+ _DEF_FEAT(LED_GAMMA_CORRECTION, "LED gamma correction"),
#undef _DEF_FEAT
};
struct i2c_client *client = mcu->client;
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH leds 8/8] ARM: dts: turris-omnia: Add global LED brightness change interrupt
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
` (6 preceding siblings ...)
2024-09-02 12:41 ` [PATCH leds 7/8] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Marek Behún
@ 2024-09-02 12:41 ` Marek Behún
7 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:41 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds, Arnd Bergmann, soc, Gregory CLEMENT,
arm, Andy Shevchenko, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth, Marek Behún
When global LED brightness is changed by pressing the front button on
Turris Omnia, the MCU can produce an interrupt to the CPU. Add the
description of this interrupt to the LED controller node.
Signed-off-by: Marek Behún <kabel@kernel.org>
---
arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts b/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts
index 43202890c959..83fe00abd652 100644
--- a/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts
+++ b/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts
@@ -251,6 +251,7 @@ mcu: system-controller@2a {
led-controller@2b {
compatible = "cznic,turris-omnia-leds";
reg = <0x2b>;
+ interrupts-extended = <&mcu 11 IRQ_TYPE_NONE>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
--
2.44.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header
2024-09-02 12:40 ` [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header Marek Behún
@ 2024-09-02 12:55 ` Andy Shevchenko
2024-09-02 12:59 ` Marek Behún
0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2024-09-02 12:55 UTC (permalink / raw)
To: Marek Behún
Cc: Lee Jones, Pavel Machek, linux-leds, Arnd Bergmann, soc,
Gregory CLEMENT, arm, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth
On Mon, Sep 02, 2024 at 02:40:57PM +0200, Marek Behún wrote:
> Move the command execution functions from the turris-omnia-mcu platform
> driver private header to the global turris-omnia-mcu-interface.h header,
> so that they can be used by the LED driver.
...
> #include <linux/bitfield.h>
> +#include <linux/bitops.h>
> #include <linux/bits.h>
You may drop this one now, as guaranteed by bitops.h.
> +#include <linux/types.h>
> +#include <asm/byteorder.h>
> +#include <asm/unaligned.h>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header
2024-09-02 12:55 ` Andy Shevchenko
@ 2024-09-02 12:59 ` Marek Behún
2024-09-02 13:23 ` Andy Shevchenko
0 siblings, 1 reply; 14+ messages in thread
From: Marek Behún @ 2024-09-02 12:59 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Marek Behún, Lee Jones, Pavel Machek, linux-leds,
Arnd Bergmann, soc, Gregory CLEMENT, arm, Hans de Goede,
Ilpo Järvinen, Andrew Lunn, Sebastian Hesselbarth
On Mon, Sep 02, 2024 at 03:55:30PM +0300, Andy Shevchenko wrote:
> On Mon, Sep 02, 2024 at 02:40:57PM +0200, Marek Behún wrote:
> > Move the command execution functions from the turris-omnia-mcu platform
> > driver private header to the global turris-omnia-mcu-interface.h header,
> > so that they can be used by the LED driver.
>
> ...
>
> > #include <linux/bitfield.h>
> > +#include <linux/bitops.h>
>
> > #include <linux/bits.h>
>
> You may drop this one now, as guaranteed by bitops.h.
Hi Andy,
How do I know that including bit.sh won't be ever deleted from
bitops.h?
Is there some database which symbols are supposed to be provided by
which header, and not just randomly included from another header?
Marek
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change
2024-09-02 12:41 ` [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Marek Behún
@ 2024-09-02 13:17 ` Andy Shevchenko
2024-09-02 14:36 ` Marek Behún
0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2024-09-02 13:17 UTC (permalink / raw)
To: Marek Behún, Greg Kroah-Hartman
Cc: Lee Jones, Pavel Machek, linux-leds, Arnd Bergmann, soc,
Gregory CLEMENT, arm, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth
On Mon, Sep 02, 2024 at 02:41:01PM +0200, Marek Behún wrote:
> Recall that on Turris Omnia, the LED controller has a global brightness
> property, which allows the user to make the front LED panel dimmer.
>
> There is also a button on the front panel, which by default is
> configured so that pressing it changes the global brightness to a lower
> value (unless it is at 0%, in which case pressing the button changes the
> global brightness to 100%).
>
> Newer versions of the MCU firmware support informing the SOC that the
> brightness was changed by button press event via an interrupt.
>
> Now that we have the turris-omnia-mcu driver, which adds support for MCU
> interrupts, add the ability to inform the userspace (via a sysfs
> notification) that the global brightness was changed.
...
> + ret = devm_device_add_group(dev, &omnia_led_controller_group);
AFAIU the intention is to remove that API, hence this shall not be used.
Greg?
https://lore.kernel.org/lkml/20221109140711.105222-1-gregkh@linuxfoundation.org/
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header
2024-09-02 12:59 ` Marek Behún
@ 2024-09-02 13:23 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2024-09-02 13:23 UTC (permalink / raw)
To: Marek Behún
Cc: Lee Jones, Pavel Machek, linux-leds, Arnd Bergmann, soc,
Gregory CLEMENT, arm, Hans de Goede, Ilpo Järvinen,
Andrew Lunn, Sebastian Hesselbarth
On Mon, Sep 02, 2024 at 02:59:45PM +0200, Marek Behún wrote:
> On Mon, Sep 02, 2024 at 03:55:30PM +0300, Andy Shevchenko wrote:
> > On Mon, Sep 02, 2024 at 02:40:57PM +0200, Marek Behún wrote:
...
> > > #include <linux/bitfield.h>
> > > +#include <linux/bitops.h>
> >
> > > #include <linux/bits.h>
> >
> > You may drop this one now, as guaranteed by bitops.h.
>
> How do I know that including bit.sh won't be ever deleted from
> bitops.h?
How do I?
Somebody should start writing documentation (and tooling?) for all this
header dependency hell we have in the Linux kernel project.
> Is there some database which symbols are supposed to be provided by
> which header, and not just randomly included from another header?
Bottom line, more explicit inclusions are fine, but here is a proverb:
"make a fool pray to God, he will break his forehead."
Means that either radical approach (none or all) is not good.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change
2024-09-02 13:17 ` Andy Shevchenko
@ 2024-09-02 14:36 ` Marek Behún
0 siblings, 0 replies; 14+ messages in thread
From: Marek Behún @ 2024-09-02 14:36 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Marek Behún, Greg Kroah-Hartman, Lee Jones, Pavel Machek,
linux-leds, Arnd Bergmann, soc, Gregory CLEMENT, arm,
Hans de Goede, Ilpo Järvinen, Andrew Lunn,
Sebastian Hesselbarth
On Mon, Sep 02, 2024 at 04:17:15PM +0300, Andy Shevchenko wrote:
> On Mon, Sep 02, 2024 at 02:41:01PM +0200, Marek Behún wrote:
> > Recall that on Turris Omnia, the LED controller has a global brightness
> > property, which allows the user to make the front LED panel dimmer.
> >
> > There is also a button on the front panel, which by default is
> > configured so that pressing it changes the global brightness to a lower
> > value (unless it is at 0%, in which case pressing the button changes the
> > global brightness to 100%).
> >
> > Newer versions of the MCU firmware support informing the SOC that the
> > brightness was changed by button press event via an interrupt.
> >
> > Now that we have the turris-omnia-mcu driver, which adds support for MCU
> > interrupts, add the ability to inform the userspace (via a sysfs
> > notification) that the global brightness was changed.
>
> ...
>
> > + ret = devm_device_add_group(dev, &omnia_led_controller_group);
>
> AFAIU the intention is to remove that API, hence this shall not be used.
> Greg?
OMG yes this should be with the group .is_visible method.
Sorry.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-09-02 14:37 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-02 12:40 [PATCH leds 0/8] Turris Omnia LED driver changes Marek Behún
2024-09-02 12:40 ` [PATCH leds 1/8] turris-omnia-mcu-interface.h: Move command execution function to global header Marek Behún
2024-09-02 12:55 ` Andy Shevchenko
2024-09-02 12:59 ` Marek Behún
2024-09-02 13:23 ` Andy Shevchenko
2024-09-02 12:40 ` [PATCH leds 2/8] leds: turris-omnia: Use command execution functions from the MCU driver Marek Behún
2024-09-02 12:40 ` [PATCH leds 3/8] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Marek Behún
2024-09-02 12:41 ` [PATCH leds 4/8] leds: turris-omnia: Use global header for MCU command definitions Marek Behún
2024-09-02 12:41 ` [PATCH leds 5/8] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Marek Behún
2024-09-02 13:17 ` Andy Shevchenko
2024-09-02 14:36 ` Marek Behún
2024-09-02 12:41 ` [PATCH leds 6/8] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Marek Behún
2024-09-02 12:41 ` [PATCH leds 7/8] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Marek Behún
2024-09-02 12:41 ` [PATCH leds 8/8] ARM: dts: turris-omnia: Add global LED brightness change interrupt Marek Behún
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox