Commit 86c67ce2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 9875b201 59ea3c9f
Loading
Loading
Loading
Loading
+91 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/leds-aw2013.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: AWINIC AW2013 3-channel LED Driver

maintainers:
  - Nikita Travkin <nikitos.tr@gmail.com>

description: |
  The AW2013 is a 3-channel LED driver with I2C interface. It can control
  LED brightness with PWM output.

properties:
  compatible:
    const: awinic,aw2013

  reg:
    maxItems: 1

  vcc-supply:
    description: Regulator providing power to the "VCC" pin.

  "#address-cells":
    const: 1

  "#size-cells":
    const: 0

patternProperties:
  "^led@[0-2]$":
    type: object
    allOf:
      - $ref: common.yaml#

    properties:
      reg:
        description: Index of the LED.
        minimum: 0
        maximum: 2

required:
  - compatible
  - reg
  - "#address-cells"
  - "#size-cells"

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/leds/common.h>

    i2c0 {
        #address-cells = <1>;
        #size-cells = <0>;

        led-controller@45 {
            compatible = "awinic,aw2013";
            reg = <0x45>;
            #address-cells = <1>;
            #size-cells = <0>;

            vcc-supply = <&pm8916_l17>;

            led@0 {
                reg = <0>;
                led-max-microamp = <5000>;
                function = LED_FUNCTION_INDICATOR;
                color = <LED_COLOR_ID_RED>;
            };

            led@1 {
                reg = <1>;
                led-max-microamp = <5000>;
                function = LED_FUNCTION_INDICATOR;
                color = <LED_COLOR_ID_GREEN>;
            };

            led@2 {
                reg = <2>;
                led-max-microamp = <5000>;
                function = LED_FUNCTION_INDICATOR;
                color = <LED_COLOR_ID_BLUE>;
            };
        };
    };
...
+62 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/leds-sgm3140.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: SGMICRO SGM3140 500mA Buck/Boost Charge Pump LED Driver

maintainers:
  - Luca Weiss <luca@z3ntu.xyz>

description: |
  The SGM3140 is a current-regulated charge pump which can regulate two current
  levels for Flash and Torch modes.

  The data sheet can be found at:
    http://www.sg-micro.com/uploads/soft/20190626/1561535688.pdf

properties:
  compatible:
    const: sgmicro,sgm3140

  enable-gpios:
    maxItems: 1
    description: A connection to the 'EN' pin.

  flash-gpios:
    maxItems: 1
    description: A connection to the 'FLASH' pin.

  vin-supply:
    description: Regulator providing power to the 'VIN' pin.

  led:
    type: object
    allOf:
      - $ref: common.yaml#

required:
  - compatible
  - flash-gpios
  - enable-gpios

additionalProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/leds/common.h>

    led-controller {
        compatible = "sgmicro,sgm3140";
        flash-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
        enable-gpios = <&pio 2 3 GPIO_ACTIVE_HIGH>; /* PC3 */
        vin-supply = <&reg_dcdc1>;

        sgm3140_flash: led {
            function = LED_FUNCTION_FLASH;
            color = <LED_COLOR_ID_WHITE>;
            flash-max-timeout-us = <250000>;
        };
    };
+29 −0
Original line number Diff line number Diff line
@@ -83,6 +83,17 @@ config LEDS_APU
	  To compile this driver as a module, choose M here: the
	  module will be called leds-apu.

config LEDS_ARIEL
	tristate "Dell Wyse 3020 status LED support"
	depends on LEDS_CLASS
	depends on (MACH_MMP3_DT && MFD_ENE_KB3930) || COMPILE_TEST
	help
	  This driver adds support for controlling the front panel status
	  LEDs on Dell Wyse 3020 (Ariel) board via the KB3930 Embedded
	  Controller.

	  Say Y to if your machine is a Dell Wyse 3020 thin client.

config LEDS_AS3645A
	tristate "AS3645A and LM3555 LED flash controllers support"
	depends on I2C && LEDS_CLASS_FLASH
@@ -92,6 +103,16 @@ config LEDS_AS3645A
	  controller. V4L2 flash API is provided as well if
	  CONFIG_V4L2_FLASH_API is enabled.

config LEDS_AW2013
	tristate "LED support for Awinic AW2013"
	depends on LEDS_CLASS && I2C && OF
	help
	  This option enables support for the AW2013 3-channel
	  LED driver.

	  To compile this driver as a module, choose M here: the module
	  will be called leds-aw2013.

config LEDS_BCM6328
	tristate "LED Support for Broadcom BCM6328"
	depends on LEDS_CLASS
@@ -857,6 +878,14 @@ config LEDS_IP30
	  To compile this driver as a module, choose M here: the module
	  will be called leds-ip30.

config LEDS_SGM3140
	tristate "LED support for the SGM3140"
	depends on LEDS_CLASS_FLASH
	depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
	help
	  This option enables support for the SGM3140 500mA Buck/Boost Charge
	  Pump LED Driver.

comment "LED Triggers"
source "drivers/leds/trigger/Kconfig"

+3 −0
Original line number Diff line number Diff line
@@ -12,8 +12,10 @@ obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o
obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
obj-$(CONFIG_LEDS_APU)			+= leds-apu.o
obj-$(CONFIG_LEDS_ARIEL)		+= leds-ariel.o
obj-$(CONFIG_LEDS_AS3645A)		+= leds-as3645a.o
obj-$(CONFIG_LEDS_ASIC3)		+= leds-asic3.o
obj-$(CONFIG_LEDS_AW2013)		+= leds-aw2013.o
obj-$(CONFIG_LEDS_BCM6328)		+= leds-bcm6328.o
obj-$(CONFIG_LEDS_BCM6358)		+= leds-bcm6358.o
obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
@@ -77,6 +79,7 @@ obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
obj-$(CONFIG_LEDS_REGULATOR)		+= leds-regulator.o
obj-$(CONFIG_LEDS_S3C24XX)		+= leds-s3c24xx.o
obj-$(CONFIG_LEDS_SC27XX_BLTC)		+= leds-sc27xx-bltc.o
obj-$(CONFIG_LEDS_SGM3140)		+= leds-sgm3140.o
obj-$(CONFIG_LEDS_SUNFIRE)		+= leds-sunfire.o
obj-$(CONFIG_LEDS_SYSCON)		+= leds-syscon.o
obj-$(CONFIG_LEDS_TCA6507)		+= leds-tca6507.o
+133 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0-or-later
/*
 * Dell Wyse 3020 a.k.a. "Ariel" Embedded Controller LED Driver
 *
 * Copyright (C) 2020 Lubomir Rintel
 */

#include <linux/module.h>
#include <linux/leds.h>
#include <linux/regmap.h>
#include <linux/of_platform.h>

enum ec_index {
	EC_BLUE_LED	= 0x01,
	EC_AMBER_LED	= 0x02,
	EC_GREEN_LED	= 0x03,
};

enum {
	EC_LED_OFF	= 0x00,
	EC_LED_STILL	= 0x01,
	EC_LED_FADE	= 0x02,
	EC_LED_BLINK	= 0x03,
};

struct ariel_led {
	struct regmap *ec_ram;
	enum ec_index ec_index;
	struct led_classdev led_cdev;
};

#define led_cdev_to_ariel_led(c) container_of(c, struct ariel_led, led_cdev)

static enum led_brightness ariel_led_get(struct led_classdev *led_cdev)
{
	struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);
	unsigned int led_status = 0;

	if (regmap_read(led->ec_ram, led->ec_index, &led_status))
		return LED_OFF;

	if (led_status == EC_LED_STILL)
		return LED_FULL;
	else
		return LED_OFF;
}

static void ariel_led_set(struct led_classdev *led_cdev,
			  enum led_brightness brightness)
{
	struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);

	if (brightness == LED_OFF)
		regmap_write(led->ec_ram, led->ec_index, EC_LED_OFF);
	else
		regmap_write(led->ec_ram, led->ec_index, EC_LED_STILL);
}

static int ariel_blink_set(struct led_classdev *led_cdev,
			   unsigned long *delay_on, unsigned long *delay_off)
{
	struct ariel_led *led = led_cdev_to_ariel_led(led_cdev);

	if (*delay_on == 0 && *delay_off == 0)
		return -EINVAL;

	if (*delay_on == 0) {
		regmap_write(led->ec_ram, led->ec_index, EC_LED_OFF);
	} else if (*delay_off == 0) {
		regmap_write(led->ec_ram, led->ec_index, EC_LED_STILL);
	} else {
		*delay_on = 500;
		*delay_off = 500;
		regmap_write(led->ec_ram, led->ec_index, EC_LED_BLINK);
	}

	return 0;
}

#define NLEDS 3

static int ariel_led_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct ariel_led *leds;
	struct regmap *ec_ram;
	int ret;
	int i;

	ec_ram = dev_get_regmap(dev->parent, "ec_ram");
	if (!ec_ram)
		return -ENODEV;

	leds = devm_kcalloc(dev, NLEDS, sizeof(*leds), GFP_KERNEL);
	if (!leds)
		return -ENOMEM;

	leds[0].ec_index = EC_BLUE_LED;
	leds[0].led_cdev.name = "blue:power",
	leds[0].led_cdev.default_trigger = "default-on";

	leds[1].ec_index = EC_AMBER_LED;
	leds[1].led_cdev.name = "amber:status",

	leds[2].ec_index = EC_GREEN_LED;
	leds[2].led_cdev.name = "green:status",
	leds[2].led_cdev.default_trigger = "default-on";

	for (i = 0; i < NLEDS; i++) {
		leds[i].ec_ram = ec_ram;
		leds[i].led_cdev.brightness_get = ariel_led_get;
		leds[i].led_cdev.brightness_set = ariel_led_set;
		leds[i].led_cdev.blink_set = ariel_blink_set;

		ret = devm_led_classdev_register(dev, &leds[i].led_cdev);
		if (ret)
			return ret;
	}

	return 0;
}

static struct platform_driver ariel_led_driver = {
	.probe = ariel_led_probe,
	.driver = {
		.name = "dell-wyse-ariel-led",
	},
};
module_platform_driver(ariel_led_driver);

MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
MODULE_DESCRIPTION("Dell Wyse 3020 Status LEDs Driver");
MODULE_LICENSE("Dual BSD/GPL");
Loading