Skip to content

Commit 5964c92

Browse files
committed
Merge tag 'leds-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds
Pull LED updates from Pavel Machek: "This is very quiet release for LEDs, pca963 got blinking support and that's pretty much it" * tag 'leds-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: leds: pca963: fix misleading indentation dt-bindings: leds: Document mmc trigger leds: pca963x: fix blink with hw acceleration
2 parents bd9a3db + 4d16321 commit 5964c92

File tree

2 files changed

+41
-20
lines changed

2 files changed

+41
-20
lines changed

Documentation/devicetree/bindings/leds/common.yaml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,27 @@ properties:
7979
the LED.
8080
$ref: /schemas/types.yaml#/definitions/string
8181

82-
enum:
83-
# LED will act as a back-light, controlled by the framebuffer system
84-
- backlight
85-
# LED will turn on (but for leds-gpio see "default-state" property in
86-
# Documentation/devicetree/bindings/leds/leds-gpio.yaml)
87-
- default-on
88-
# LED "double" flashes at a load average based rate
89-
- heartbeat
90-
# LED indicates disk activity
91-
- disk-activity
92-
# LED indicates IDE disk activity (deprecated), in new implementations
93-
# use "disk-activity"
94-
- ide-disk
95-
# LED flashes at a fixed, configurable rate
96-
- timer
97-
# LED alters the brightness for the specified duration with one software
98-
# timer (requires "led-pattern" property)
99-
- pattern
82+
oneOf:
83+
- enum:
84+
# LED will act as a back-light, controlled by the framebuffer system
85+
- backlight
86+
# LED will turn on (but for leds-gpio see "default-state" property in
87+
# Documentation/devicetree/bindings/leds/leds-gpio.yaml)
88+
- default-on
89+
# LED "double" flashes at a load average based rate
90+
- heartbeat
91+
# LED indicates disk activity
92+
- disk-activity
93+
# LED indicates IDE disk activity (deprecated), in new implementations
94+
# use "disk-activity"
95+
- ide-disk
96+
# LED flashes at a fixed, configurable rate
97+
- timer
98+
# LED alters the brightness for the specified duration with one software
99+
# timer (requires "led-pattern" property)
100+
- pattern
101+
# LED is triggered by SD/MMC activity
102+
- pattern: "^mmc[0-9]+$"
100103

101104
led-pattern:
102105
description: |

drivers/leds/leds-pca963x.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct pca963x_led {
101101
struct pca963x *chip;
102102
struct led_classdev led_cdev;
103103
int led_num; /* 0 .. 15 potentially */
104+
bool blinking;
104105
u8 gdc;
105106
u8 gfrq;
106107
};
@@ -129,12 +130,21 @@ static int pca963x_brightness(struct pca963x_led *led,
129130

130131
switch (brightness) {
131132
case LED_FULL:
132-
val = (ledout & ~mask) | (PCA963X_LED_ON << shift);
133+
if (led->blinking) {
134+
val = (ledout & ~mask) | (PCA963X_LED_GRP_PWM << shift);
135+
ret = i2c_smbus_write_byte_data(client,
136+
PCA963X_PWM_BASE +
137+
led->led_num,
138+
LED_FULL);
139+
} else {
140+
val = (ledout & ~mask) | (PCA963X_LED_ON << shift);
141+
}
133142
ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
134143
break;
135144
case LED_OFF:
136145
val = ledout & ~mask;
137146
ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
147+
led->blinking = false;
138148
break;
139149
default:
140150
ret = i2c_smbus_write_byte_data(client,
@@ -144,7 +154,11 @@ static int pca963x_brightness(struct pca963x_led *led,
144154
if (ret < 0)
145155
return ret;
146156

147-
val = (ledout & ~mask) | (PCA963X_LED_PWM << shift);
157+
if (led->blinking)
158+
val = (ledout & ~mask) | (PCA963X_LED_GRP_PWM << shift);
159+
else
160+
val = (ledout & ~mask) | (PCA963X_LED_PWM << shift);
161+
148162
ret = i2c_smbus_write_byte_data(client, ledout_addr, val);
149163
break;
150164
}
@@ -181,6 +195,7 @@ static void pca963x_blink(struct pca963x_led *led)
181195
}
182196

183197
mutex_unlock(&led->chip->mutex);
198+
led->blinking = true;
184199
}
185200

186201
static int pca963x_power_state(struct pca963x_led *led)
@@ -275,6 +290,8 @@ static int pca963x_blink_set(struct led_classdev *led_cdev,
275290
led->gfrq = gfrq;
276291

277292
pca963x_blink(led);
293+
led->led_cdev.brightness = LED_FULL;
294+
pca963x_led_set(led_cdev, LED_FULL);
278295

279296
*delay_on = time_on;
280297
*delay_off = time_off;
@@ -337,6 +354,7 @@ static int pca963x_register_leds(struct i2c_client *client,
337354
led->led_cdev.brightness_set_blocking = pca963x_led_set;
338355
if (hw_blink)
339356
led->led_cdev.blink_set = pca963x_blink_set;
357+
led->blinking = false;
340358

341359
init_data.fwnode = child;
342360
/* for backwards compatibility */

0 commit comments

Comments
 (0)