Skip to content

Commit 86c67ce

Browse files
committed
Merge tag 'leds-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds
Pull LED updates from Pavel Machek: "New drivers: aw2013, sgm3140, some fixes Nothing much to see here, next release should be more interesting" * tag 'leds-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: leds: add aw2013 driver dt-bindings: leds: Add binding for aw2013 leds: trigger: remove redundant assignment to variable ret leds: netxbig: Convert to use GPIO descriptors leds: add sgm3140 driver dt-bindings: leds: Add binding for sgm3140 leds: ariel: Add driver for status LEDs on Dell Wyse 3020 leds: pwm: check result of led_pwm_set() in led_pwm_add() leds: tlc591xxt: hide error on EPROBE_DEFER leds: tca6507: Include the right header leds: lt3593: Drop surplus include leds: lp3952: Include the right header leds: lm355x: Drop surplus include
2 parents 9875b20 + 59ea3c9 commit 86c67ce

File tree

15 files changed

+1173
-80
lines changed

15 files changed

+1173
-80
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/leds/leds-aw2013.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: AWINIC AW2013 3-channel LED Driver
8+
9+
maintainers:
10+
- Nikita Travkin <[email protected]>
11+
12+
description: |
13+
The AW2013 is a 3-channel LED driver with I2C interface. It can control
14+
LED brightness with PWM output.
15+
16+
properties:
17+
compatible:
18+
const: awinic,aw2013
19+
20+
reg:
21+
maxItems: 1
22+
23+
vcc-supply:
24+
description: Regulator providing power to the "VCC" pin.
25+
26+
"#address-cells":
27+
const: 1
28+
29+
"#size-cells":
30+
const: 0
31+
32+
patternProperties:
33+
"^led@[0-2]$":
34+
type: object
35+
allOf:
36+
- $ref: common.yaml#
37+
38+
properties:
39+
reg:
40+
description: Index of the LED.
41+
minimum: 0
42+
maximum: 2
43+
44+
required:
45+
- compatible
46+
- reg
47+
- "#address-cells"
48+
- "#size-cells"
49+
50+
additionalProperties: false
51+
52+
examples:
53+
- |
54+
#include <dt-bindings/gpio/gpio.h>
55+
#include <dt-bindings/leds/common.h>
56+
57+
i2c0 {
58+
#address-cells = <1>;
59+
#size-cells = <0>;
60+
61+
led-controller@45 {
62+
compatible = "awinic,aw2013";
63+
reg = <0x45>;
64+
#address-cells = <1>;
65+
#size-cells = <0>;
66+
67+
vcc-supply = <&pm8916_l17>;
68+
69+
led@0 {
70+
reg = <0>;
71+
led-max-microamp = <5000>;
72+
function = LED_FUNCTION_INDICATOR;
73+
color = <LED_COLOR_ID_RED>;
74+
};
75+
76+
led@1 {
77+
reg = <1>;
78+
led-max-microamp = <5000>;
79+
function = LED_FUNCTION_INDICATOR;
80+
color = <LED_COLOR_ID_GREEN>;
81+
};
82+
83+
led@2 {
84+
reg = <2>;
85+
led-max-microamp = <5000>;
86+
function = LED_FUNCTION_INDICATOR;
87+
color = <LED_COLOR_ID_BLUE>;
88+
};
89+
};
90+
};
91+
...
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/leds/leds-sgm3140.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: SGMICRO SGM3140 500mA Buck/Boost Charge Pump LED Driver
8+
9+
maintainers:
10+
- Luca Weiss <[email protected]>
11+
12+
description: |
13+
The SGM3140 is a current-regulated charge pump which can regulate two current
14+
levels for Flash and Torch modes.
15+
16+
The data sheet can be found at:
17+
http://www.sg-micro.com/uploads/soft/20190626/1561535688.pdf
18+
19+
properties:
20+
compatible:
21+
const: sgmicro,sgm3140
22+
23+
enable-gpios:
24+
maxItems: 1
25+
description: A connection to the 'EN' pin.
26+
27+
flash-gpios:
28+
maxItems: 1
29+
description: A connection to the 'FLASH' pin.
30+
31+
vin-supply:
32+
description: Regulator providing power to the 'VIN' pin.
33+
34+
led:
35+
type: object
36+
allOf:
37+
- $ref: common.yaml#
38+
39+
required:
40+
- compatible
41+
- flash-gpios
42+
- enable-gpios
43+
44+
additionalProperties: false
45+
46+
examples:
47+
- |
48+
#include <dt-bindings/gpio/gpio.h>
49+
#include <dt-bindings/leds/common.h>
50+
51+
led-controller {
52+
compatible = "sgmicro,sgm3140";
53+
flash-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
54+
enable-gpios = <&pio 2 3 GPIO_ACTIVE_HIGH>; /* PC3 */
55+
vin-supply = <&reg_dcdc1>;
56+
57+
sgm3140_flash: led {
58+
function = LED_FUNCTION_FLASH;
59+
color = <LED_COLOR_ID_WHITE>;
60+
flash-max-timeout-us = <250000>;
61+
};
62+
};

drivers/leds/Kconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ config LEDS_APU
8383
To compile this driver as a module, choose M here: the
8484
module will be called leds-apu.
8585

86+
config LEDS_ARIEL
87+
tristate "Dell Wyse 3020 status LED support"
88+
depends on LEDS_CLASS
89+
depends on (MACH_MMP3_DT && MFD_ENE_KB3930) || COMPILE_TEST
90+
help
91+
This driver adds support for controlling the front panel status
92+
LEDs on Dell Wyse 3020 (Ariel) board via the KB3930 Embedded
93+
Controller.
94+
95+
Say Y to if your machine is a Dell Wyse 3020 thin client.
96+
8697
config LEDS_AS3645A
8798
tristate "AS3645A and LM3555 LED flash controllers support"
8899
depends on I2C && LEDS_CLASS_FLASH
@@ -92,6 +103,16 @@ config LEDS_AS3645A
92103
controller. V4L2 flash API is provided as well if
93104
CONFIG_V4L2_FLASH_API is enabled.
94105

106+
config LEDS_AW2013
107+
tristate "LED support for Awinic AW2013"
108+
depends on LEDS_CLASS && I2C && OF
109+
help
110+
This option enables support for the AW2013 3-channel
111+
LED driver.
112+
113+
To compile this driver as a module, choose M here: the module
114+
will be called leds-aw2013.
115+
95116
config LEDS_BCM6328
96117
tristate "LED Support for Broadcom BCM6328"
97118
depends on LEDS_CLASS
@@ -857,6 +878,14 @@ config LEDS_IP30
857878
To compile this driver as a module, choose M here: the module
858879
will be called leds-ip30.
859880

881+
config LEDS_SGM3140
882+
tristate "LED support for the SGM3140"
883+
depends on LEDS_CLASS_FLASH
884+
depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
885+
help
886+
This option enables support for the SGM3140 500mA Buck/Boost Charge
887+
Pump LED Driver.
888+
860889
comment "LED Triggers"
861890
source "drivers/leds/trigger/Kconfig"
862891

drivers/leds/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o
1212
obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
1313
obj-$(CONFIG_LEDS_AN30259A) += leds-an30259a.o
1414
obj-$(CONFIG_LEDS_APU) += leds-apu.o
15+
obj-$(CONFIG_LEDS_ARIEL) += leds-ariel.o
1516
obj-$(CONFIG_LEDS_AS3645A) += leds-as3645a.o
1617
obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
18+
obj-$(CONFIG_LEDS_AW2013) += leds-aw2013.o
1719
obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o
1820
obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o
1921
obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
@@ -77,6 +79,7 @@ obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
7779
obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o
7880
obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
7981
obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o
82+
obj-$(CONFIG_LEDS_SGM3140) += leds-sgm3140.o
8083
obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o
8184
obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
8285
obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o

drivers/leds/leds-ariel.c

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-or-later
2+
/*
3+
* Dell Wyse 3020 a.k.a. "Ariel" Embedded Controller LED Driver
4+
*
5+
* Copyright (C) 2020 Lubomir Rintel
6+
*/
7+
8+
#include <linux/module.h>
9+
#include <linux/leds.h>
10+
#include <linux/regmap.h>
11+
#include <linux/of_platform.h>
12+
13+
enum ec_index {
14+
EC_BLUE_LED = 0x01,
15+
EC_AMBER_LED = 0x02,
16+
EC_GREEN_LED = 0x03,
17+
};
18+
19+
enum {
20+
EC_LED_OFF = 0x00,
21+
EC_LED_STILL = 0x01,
22+
EC_LED_FADE = 0x02,
23+
EC_LED_BLINK = 0x03,
24+
};
25+
26+
struct ariel_led {
27+
struct regmap *ec_ram;
28+
enum ec_index ec_index;
29+
struct led_classdev led_cdev;
30+
};
31+
32+
#define led_cdev_to_ariel_led(c) container_of(c, struct ariel_led, led_cdev)
33+
34+
static enum led_brightness ariel_led_get(struct led_classdev *led_cdev)
35+
{
36+
struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);
37+
unsigned int led_status = 0;
38+
39+
if (regmap_read(led->ec_ram, led->ec_index, &led_status))
40+
return LED_OFF;
41+
42+
if (led_status == EC_LED_STILL)
43+
return LED_FULL;
44+
else
45+
return LED_OFF;
46+
}
47+
48+
static void ariel_led_set(struct led_classdev *led_cdev,
49+
enum led_brightness brightness)
50+
{
51+
struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);
52+
53+
if (brightness == LED_OFF)
54+
regmap_write(led->ec_ram, led->ec_index, EC_LED_OFF);
55+
else
56+
regmap_write(led->ec_ram, led->ec_index, EC_LED_STILL);
57+
}
58+
59+
static int ariel_blink_set(struct led_classdev *led_cdev,
60+
unsigned long *delay_on, unsigned long *delay_off)
61+
{
62+
struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);
63+
64+
if (*delay_on == 0 && *delay_off == 0)
65+
return -EINVAL;
66+
67+
if (*delay_on == 0) {
68+
regmap_write(led->ec_ram, led->ec_index, EC_LED_OFF);
69+
} else if (*delay_off == 0) {
70+
regmap_write(led->ec_ram, led->ec_index, EC_LED_STILL);
71+
} else {
72+
*delay_on = 500;
73+
*delay_off = 500;
74+
regmap_write(led->ec_ram, led->ec_index, EC_LED_BLINK);
75+
}
76+
77+
return 0;
78+
}
79+
80+
#define NLEDS 3
81+
82+
static int ariel_led_probe(struct platform_device *pdev)
83+
{
84+
struct device *dev = &pdev->dev;
85+
struct ariel_led *leds;
86+
struct regmap *ec_ram;
87+
int ret;
88+
int i;
89+
90+
ec_ram = dev_get_regmap(dev->parent, "ec_ram");
91+
if (!ec_ram)
92+
return -ENODEV;
93+
94+
leds = devm_kcalloc(dev, NLEDS, sizeof(*leds), GFP_KERNEL);
95+
if (!leds)
96+
return -ENOMEM;
97+
98+
leds[0].ec_index = EC_BLUE_LED;
99+
leds[0].led_cdev.name = "blue:power",
100+
leds[0].led_cdev.default_trigger = "default-on";
101+
102+
leds[1].ec_index = EC_AMBER_LED;
103+
leds[1].led_cdev.name = "amber:status",
104+
105+
leds[2].ec_index = EC_GREEN_LED;
106+
leds[2].led_cdev.name = "green:status",
107+
leds[2].led_cdev.default_trigger = "default-on";
108+
109+
for (i = 0; i < NLEDS; i++) {
110+
leds[i].ec_ram = ec_ram;
111+
leds[i].led_cdev.brightness_get = ariel_led_get;
112+
leds[i].led_cdev.brightness_set = ariel_led_set;
113+
leds[i].led_cdev.blink_set = ariel_blink_set;
114+
115+
ret = devm_led_classdev_register(dev, &leds[i].led_cdev);
116+
if (ret)
117+
return ret;
118+
}
119+
120+
return 0;
121+
}
122+
123+
static struct platform_driver ariel_led_driver = {
124+
.probe = ariel_led_probe,
125+
.driver = {
126+
.name = "dell-wyse-ariel-led",
127+
},
128+
};
129+
module_platform_driver(ariel_led_driver);
130+
131+
MODULE_AUTHOR("Lubomir Rintel <[email protected]>");
132+
MODULE_DESCRIPTION("Dell Wyse 3020 Status LEDs Driver");
133+
MODULE_LICENSE("Dual BSD/GPL");

0 commit comments

Comments
 (0)