Skip to content

Commit

Permalink
kestrel/leds/trigger: implement led trigger driver for group pwm
Browse files Browse the repository at this point in the history
pca9633 i2c leds driver supports group pwm which currently not utilized
by leds-pca963x driver.
This patch exposes various registers values via sysfs to user and can be
used to achieve group blinking and dimming.

Signed-off-by: Amitesh Singh <[email protected]>
  • Loading branch information
amiteshsingh-cpi committed May 29, 2023
1 parent 05292f1 commit 36234f4
Show file tree
Hide file tree
Showing 5 changed files with 533 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/leds/leds-pca963x.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/i2c-pca963x.h>

/* LED select registers determine the source that drives LED outputs */
#define PCA963X_LED_OFF 0x0 /* LED driver off */
Expand Down Expand Up @@ -371,6 +372,14 @@ static const struct of_device_id of_pca963x_match[] = {
};
MODULE_DEVICE_TABLE(of, of_pca963x_match);

static struct i2c_client *g_client;

struct i2c_client *i2c_get_pca963x_device(void)
{
return g_client;
}
EXPORT_SYMBOL_GPL(i2c_get_pca963x_device);

static int pca963x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
Expand Down Expand Up @@ -398,6 +407,8 @@ static int pca963x_probe(struct i2c_client *client,
chip->chipdef = chipdef;
chip->client = client;

g_client = client;

/* Turn off LEDs by default*/
for (i = 0; i < chipdef->n_leds / 4; i++)
i2c_smbus_write_byte_data(client, chipdef->ledout_base + i, 0x00);
Expand Down
8 changes: 8 additions & 0 deletions drivers/leds/trigger/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ config LEDS_TRIGGER_TIMER

If unsure, say Y.

config LEDS_TRIGGER_GRPPWM
tristate "LED Group PWM trigger"
help
This allows LEDs to be controlled by group pwm feature,
supported by pca9633 i2c driver

if unsure, say Y.

config LEDS_TRIGGER_ONESHOT
tristate "LED One-shot Trigger"
help
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/trigger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
obj-$(CONFIG_LEDS_TRIGGER_AUDIO) += ledtrig-audio.o
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o
obj-$(CONFIG_LEDS_TRIGGER_GRPPWM) += ledtrig-grppwm.o
Loading

0 comments on commit 36234f4

Please sign in to comment.