Skip to contentSkip to conversation

leds: tps68470: LED driver for TPS68470

PATCH Superseded Kate Hsuan 1 participant 4 messages Jan 19, 2023

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kate Hsuan

author
#0 lore raw

cover leds: tps68470: LED driver for TPS68470

This work allows user to control the indicator and flash LEDs though sysfs in user space. TPS68470 is a part of INT3470 and provides GPIO, LED, and power controls.

To allow the user to control these two LEDs, two masks for the ILEDCTL, called TPS68470_ILEDCTL_ENA and TPS68470_ILEDCTL_ENA and a two bits mask, called TPS68470_ILEDCTL_CTRLB are defined and are used to enable/disable the LEDs and set the power status, respectively.

The LED driver called leds-tps68470 provides the sysfs interface and the register configuration implementation. For the indicator LED, only TPS68470_ILEDCTL_ENA needs to be set to turn on/off the LED. For the flash LED, TPS68470 provides 4 levels of power settings. After enabling the TPS68470_ILEDCTL_ENB, the power level should also be set. The strategy is

Brightness | Power
=======================

LED_OFF     |   -
LED_ON      |   4mA
LED_HALF    |   8mA
LED_FULL    |   16mA

Moreover, the user and application can set the brightness through sysfs, /sys/class/leds/tps68470-ileda and /sys/class/leds/tps68470-iledb

Kate Hsuan (3):
platform: x86: int3472: Add MFD cell for tps68470 LED
include: mfd: tps68470: Add masks for LEDA and LEDB
leds: tps68470: Add LED control for tps68470

 drivers/leds/Kconfig                          |  12 ++
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-tps68470.c                  | 170 ++++++++++++++++++
 drivers/platform/x86/intel/int3472/tps68470.c |   3 +-
 include/linux/mfd/tps68470.h                  |   5 +
 5 files changed, 190 insertions(+), 1 deletion(-)
 create mode 100644 drivers/leds/leds-tps68470.c
Signature · 1 line
2.39.0
author
#1 lore raw

PATCH 1/3 platform: x86: int3472: Add MFD cell for tps68470 LED

Add MFD cell for tps68470-led.

---
 drivers/platform/x86/intel/int3472/tps68470.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/int3472/tps68470.c +2 -1
index 5b8d1a9620a5..9dceb6507a01 100644
@@ -17,7 +17,7 @@
 #define DESIGNED_FOR_CHROMEOS		1
 #define DESIGNED_FOR_WINDOWS		2
 
-#define TPS68470_WIN_MFD_CELL_COUNT	3
+#define TPS68470_WIN_MFD_CELL_COUNT	4
 
 static const struct mfd_cell tps68470_cros[] = {
 	{ .name = "tps68470-gpio" },
@@ -194,6 +194,7 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client)
 		cells[1].platform_data = (void *)board_data->tps68470_regulator_pdata;
 		cells[1].pdata_size = sizeof(struct tps68470_regulator_platform_data);
 		cells[2].name = "tps68470-gpio";
+		cells[3].name = "tps68470-led";
 
 		for (i = 0; i < board_data->n_gpiod_lookups; i++)
 			gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
Signature · 1 line
2.39.0
author
#2 lore raw

PATCH 2/3 include: mfd: tps68470: Add masks for LEDA and LEDB

In reply to Kate Hsuan

Add flags for both LEDA(TPS68470_ILEDCTL_ENA), LEDB (TPS68470_ILEDCTL_ENB), and current control mask for LEDB (TPS68470_ILEDCTL_CTRLB)

---
 include/linux/mfd/tps68470.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/mfd/tps68470.h +5 -0
index 7807fa329db0..2d2abb25b944 100644
@@ -34,6 +34,7 @@
 #define TPS68470_REG_SGPO		0x22
 #define TPS68470_REG_GPDI		0x26
 #define TPS68470_REG_GPDO		0x27
+#define TPS68470_REG_ILEDCTL		0x28
 #define TPS68470_REG_VCMVAL		0x3C
 #define TPS68470_REG_VAUX1VAL		0x3D
 #define TPS68470_REG_VAUX2VAL		0x3E
@@ -94,4 +95,8 @@
 #define TPS68470_GPIO_MODE_OUT_CMOS	2
 #define TPS68470_GPIO_MODE_OUT_ODRAIN	3
 
+#define TPS68470_ILEDCTL_ENA		BIT(2)
+#define TPS68470_ILEDCTL_ENB		BIT(6)
+#define TPS68470_ILEDCTL_CTRLB		GENMASK(5, 4)
+
 #endif /* __LINUX_MFD_TPS68470_H */
Signature · 1 line
2.39.0
author
#3 lore raw

PATCH 3/3 leds: tps68470: Add LED control for tps68470

In reply to Kate Hsuan

There are two LED controllers, LEDA indicator LED and LEDB flash LED for tps68470. LEDA can be enabled by setting TPS68470_ILEDCTL_ENA. Moreover, tps68470 provides 4 levels of power status for LEDB, so after setting TPS68470_ILEDCTL_ENB, the current status field (TPS68470_ILEDCTL_CTRLB) should also be set according to the brightness value from user space. These two LEDs can be controlled through the LED class of sysfs (tps68470-leda and tps68470-ledb).

---
 drivers/leds/Kconfig         |  12 +++
 drivers/leds/Makefile        |   1 +
 drivers/leds/leds-tps68470.c | 170 +++++++++++++++++++++++++++++++++++
 3 files changed, 183 insertions(+)
 create mode 100644 drivers/leds/leds-tps68470.c
drivers/leds/Kconfig +12 -0
index 499d0f215a8b..453404cb1329 100644
@@ -846,6 +846,18 @@ config LEDS_TPS6105X
 	  It is a single boost converter primarily for white LEDs and
 	  audio amplifiers.
 
+config LEDS_TPS68470
+	tristate "LED support for TI TPS68470"
+	depends on LEDS_CLASS
+	depends on INTEL_SKL_INT3472
+	help
+	  This driver supports TPS68470 PMIC with LED chip.
+	  It provide two LED controllers, including an indicator LED
+	  and a flash LED.
+
+	  To compile this driver as a module, choose M and it will be
+	  called leds-tps68470
+
 config LEDS_IP30
 	tristate "LED support for SGI Octane machines"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4fd2f92cd198..0a2ec01e27d9 100644
@@ -86,6 +86,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA)		+= leds-turris-omnia.o
 obj-$(CONFIG_LEDS_WM831X_STATUS)	+= leds-wm831x-status.o
 obj-$(CONFIG_LEDS_WM8350)		+= leds-wm8350.o
 obj-$(CONFIG_LEDS_WRAP)			+= leds-wrap.o
+obj-$(CONFIG_LEDS_TPS68470)		+= leds-tps68470.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_CR0014114)		+= leds-cr0014114.o
drivers/leds/leds-tps68470.c new file +170 -0

170 lines not on this page · raw message

Signature · 1 line
2.39.0