Skip to content

Commit f51bc3c

Browse files
bastien-curutchetlag-linaro
authored andcommitted
leds: pca9532: Explicitly disable hardware blink when PWM1 is unavailable
When a LED is used to drive a beeper, it uses PWM1. This can cause conflicts if an other LED want to use PWM1 for blinking. Disable use of hardware for blinking when one or more LEDs are used to drive beepers. Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com> Link: https://lore.kernel.org/r/20240617143910.154546-4-bastien.curutchet@bootlin.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 48ca7f3 commit f51bc3c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/leds/leds-pca9532.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct pca9532_data {
5353
#define PCA9532_PWM_ID_1 1
5454
u8 pwm[2];
5555
u8 psc[2];
56+
bool hw_blink;
5657
};
5758

5859
static int pca9532_probe(struct i2c_client *client);
@@ -238,8 +239,13 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
238239
unsigned long *delay_on, unsigned long *delay_off)
239240
{
240241
struct pca9532_led *led = ldev_to_led(led_cdev);
242+
struct i2c_client *client = led->client;
243+
struct pca9532_data *data = i2c_get_clientdata(client);
241244
int err;
242245

246+
if (!data->hw_blink)
247+
return -EINVAL;
248+
243249
if (*delay_on == 0 && *delay_off == 0) {
244250
/* led subsystem ask us for a blink rate */
245251
*delay_on = 1000;
@@ -395,6 +401,7 @@ static int pca9532_configure(struct i2c_client *client,
395401
data->psc[i]);
396402
}
397403

404+
data->hw_blink = true;
398405
for (i = 0; i < data->chip_info->num_leds; i++) {
399406
struct pca9532_led *led = &data->leds[i];
400407
struct pca9532_led *pled = &pdata->leds[i];
@@ -429,6 +436,8 @@ static int pca9532_configure(struct i2c_client *client,
429436
pca9532_setled(led);
430437
break;
431438
case PCA9532_TYPE_N2100_BEEP:
439+
/* PWM1 is reserved for beeper so blink will not use hardware */
440+
data->hw_blink = false;
432441
BUG_ON(data->idev);
433442
led->state = PCA9532_PWM1;
434443
pca9532_setled(led);

0 commit comments

Comments
 (0)