Commit fea17683 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'leds-next-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds

Pull LED updates from Lee Jones:
 "Core Frameworks:
   - New trigger for Input Events
   - New led_mc_set_brightness() call to adapt colour/brightness for
     mutli-colour LEDs
   - New lled_mc_trigger_event() call to call the above based on given
     trigger conditions
   - New led_get_color_name() call, a wrapper around the existing
     led_colors[] array
   - A new flag to avoid automatic renaming of LED devices

  New Drivers:
   - Silergy SY7802 Flash LED Controller
   - Texas Instruments LP5569 LED Controller
   - ChromeOS EC LED Controller

  New Device Support:
   - KTD202{6,7} support for Kinetic KTD2026/7 LEDs

  Fix-ups:
   - Replace ACPI/DT firmware helpers with agnostic variants
   - Make use of resource managed devm_* API calls
   - Device Tree binding adaptions/conversions/creation
   - Constify/staticise applicable data structures
   - Trivial; spelling, whitespace, coding-style adaptions
   - Drop i2c_device_id::driver_data where the value is unused
   - Utilise centrally provided helpers and macros to aid simplicity and
     avoid duplication
   - Use generic platform device properties instead of OF/ACPI specific
     ones
   - Consolidate/de-duplicate various functionality
   - Remove superfluous/duplicated/unused sections
   - Make use of the new *_scoped() guard APIs
   - Improve/simplify error handling

  Bug Fixes:
   - Flush pending brightness changes before activating the trigger
   - Repair incorrect device naming preventing matches
   - Prevent memory leaks by correctly free resources during error
     handling routines
   - Repair locking issue causing circular dependency splats and
     lock-ups
   - Unregister sysfs entries before deactivating triggers to prevent
     use-after issues
   - Supply a bunch of MODULE_DESCRIPTIONs to silence modpost warnings
   - Use correct return codes expected by the callers
   - Omit set_brightness() error message for a LEDs that support only HW
     triggers"

* tag 'leds-next-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: (65 commits)
  leds: leds-lp5569: Enable chip after chip configuration
  leds: leds-lp5569: Better handle enabling clock internal setting
  leds: leds-lp5569: Fix typo in driver name
  leds: flash: leds-qcom-flash: Test the correct variable in init
  leds: leds-lp55xx: Convert mutex lock/unlock to guard API
  leds: leds-lp5523: Convert to sysfs_emit API
  leds: leds-lp5569: Convert to sysfs_emit API
  Revert "leds: led-core: Fix refcount leak in of_led_get()"
  leds: leds-lp5569: Add support for Texas Instruments LP5569
  leds: leds-lp55xx: Drop deprecated defines
  leds: leds-lp55xx: Support ENGINE program up to 128 bytes
  leds: leds-lp55xx: Generalize sysfs master_fader
  leds: leds-lp55xx: Generalize sysfs engine_leds
  leds: leds-lp55xx: Generalize sysfs engine_load and engine_mode
  leds: leds-lp55xx: Generalize stop_engine function
  leds: leds-lp55xx: Generalize turn_off_channels function
  leds: leds-lp55xx: Generalize set_led_current function
  leds: leds-lp55xx: Generalize multicolor_brightness function
  leds: leds-lp55xx: Generalize led_brightness function
  leds: leds-lp55xx: Generalize firmware_loaded function
  ...
parents e0d97b04 b0eed397
...@@ -28,6 +28,7 @@ properties: ...@@ -28,6 +28,7 @@ properties:
- national,lp5523 - national,lp5523
- ti,lp55231 - ti,lp55231
- ti,lp5562 - ti,lp5562
- ti,lp5569
- ti,lp8501 - ti,lp8501
reg: reg:
...@@ -151,6 +152,16 @@ patternProperties: ...@@ -151,6 +152,16 @@ patternProperties:
$ref: /schemas/types.yaml#/definitions/string $ref: /schemas/types.yaml#/definitions/string
description: name of channel description: name of channel
if:
not:
properties:
compatible:
contains:
const: ti,lp8501
then:
properties:
pwr-sel: false
required: required:
- compatible - compatible
- reg - reg
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/silergy,sy7802.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Silergy SY7802 1800mA Boost Charge Pump LED Driver
maintainers:
- André Apitzsch <git@apitzsch.eu>
description: |
The SY7802 is a current-regulated charge pump which can regulate two current
levels for Flash and Torch modes.
The SY7802 is a high-current synchronous boost converter with 2-channel
high side current sources. Each channel is able to deliver 900mA current.
properties:
compatible:
enum:
- silergy,sy7802
reg:
maxItems: 1
enable-gpios:
maxItems: 1
description: A connection to the 'EN' pin.
flash-gpios:
maxItems: 1
description: A connection to the 'FLEN' pin.
vin-supply:
description: Regulator providing power to the 'VIN' pin.
"#address-cells":
const: 1
"#size-cells":
const: 0
patternProperties:
"^led@[0-1]$":
type: object
$ref: common.yaml#
unevaluatedProperties: false
properties:
reg:
description: Index of the LED.
minimum: 0
maximum: 1
led-sources:
minItems: 1
maxItems: 2
items:
minimum: 0
maximum: 1
required:
- reg
- led-sources
required:
- compatible
- reg
- "#address-cells"
- "#size-cells"
- enable-gpios
additionalProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
flash-led-controller@53 {
compatible = "silergy,sy7802";
reg = <0x53>;
#address-cells = <1>;
#size-cells = <0>;
enable-gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>;
led@0 {
reg = <0>;
function = LED_FUNCTION_FLASH;
color = <LED_COLOR_ID_WHITE>;
led-sources = <0>, <1>;
};
};
};
...@@ -7,7 +7,7 @@ The leds-blinkm driver supports the devices of the BlinkM family. ...@@ -7,7 +7,7 @@ The leds-blinkm driver supports the devices of the BlinkM family.
They are RGB-LED modules driven by a (AT)tiny microcontroller and They are RGB-LED modules driven by a (AT)tiny microcontroller and
communicate through I2C. The default address of these modules is communicate through I2C. The default address of these modules is
0x09 but this can be changed through a command. By this you could 0x09 but this can be changed through a command. By this you could
dasy-chain up to 127 BlinkMs on an I2C bus. daisy-chain up to 127 BlinkMs on an I2C bus.
The device accepts RGB and HSB color values through separate commands. The device accepts RGB and HSB color values through separate commands.
Also you can store blinking sequences as "scripts" in Also you can store blinking sequences as "scripts" in
......
...@@ -12598,7 +12598,7 @@ M: Pavel Machek <pavel@ucw.cz> ...@@ -12598,7 +12598,7 @@ M: Pavel Machek <pavel@ucw.cz>
M: Lee Jones <lee@kernel.org> M: Lee Jones <lee@kernel.org>
L: linux-leds@vger.kernel.org L: linux-leds@vger.kernel.org
S: Maintained S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git
F: Documentation/devicetree/bindings/leds/ F: Documentation/devicetree/bindings/leds/
F: Documentation/leds/ F: Documentation/leds/
F: drivers/leds/ F: drivers/leds/
......
...@@ -429,7 +429,7 @@ config LEDS_LP50XX ...@@ -429,7 +429,7 @@ config LEDS_LP50XX
module will be called leds-lp50xx. module will be called leds-lp50xx.
config LEDS_LP55XX_COMMON config LEDS_LP55XX_COMMON
tristate "Common Driver for TI/National LP5521/5523/55231/5562/8501" tristate "Common Driver for TI/National LP5521/5523/55231/5562/5569/8501"
depends on LEDS_CLASS depends on LEDS_CLASS
depends on LEDS_CLASS_MULTICOLOR depends on LEDS_CLASS_MULTICOLOR
depends on OF depends on OF
...@@ -437,8 +437,8 @@ config LEDS_LP55XX_COMMON ...@@ -437,8 +437,8 @@ config LEDS_LP55XX_COMMON
select FW_LOADER select FW_LOADER
select FW_LOADER_USER_HELPER select FW_LOADER_USER_HELPER
help help
This option supports common operations for LP5521/5523/55231/5562/8501 This option supports common operations for LP5521/5523/55231/5562/5569/
devices. 8501 devices.
config LEDS_LP5521 config LEDS_LP5521
tristate "LED Support for N.S. LP5521 LED driver chip" tristate "LED Support for N.S. LP5521 LED driver chip"
...@@ -471,6 +471,16 @@ config LEDS_LP5562 ...@@ -471,6 +471,16 @@ config LEDS_LP5562
Driver provides direct control via LED class and interface for Driver provides direct control via LED class and interface for
programming the engines. programming the engines.
config LEDS_LP5569
tristate "LED Support for TI LP5569 LED driver chip"
depends on LEDS_CLASS && I2C
depends on LEDS_LP55XX_COMMON
help
If you say yes here you get support for TI LP5569 LED driver.
It is 9 channels chip with programmable engines.
Driver provides direct control via LED class and interface for
programming the engines.
config LEDS_LP8501 config LEDS_LP8501
tristate "LED Support for TI LP8501 LED driver chip" tristate "LED Support for TI LP8501 LED driver chip"
depends on LEDS_CLASS && I2C depends on LEDS_CLASS && I2C
...@@ -884,7 +894,6 @@ config LEDS_SPI_BYTE ...@@ -884,7 +894,6 @@ config LEDS_SPI_BYTE
tristate "LED support for SPI LED controller with a single byte" tristate "LED support for SPI LED controller with a single byte"
depends on LEDS_CLASS depends on LEDS_CLASS
depends on SPI depends on SPI
depends on OF
help help
This option enables support for LED controller which use a single byte This option enables support for LED controller which use a single byte
for controlling the brightness. Currently the following controller is for controlling the brightness. Currently the following controller is
......
...@@ -52,6 +52,7 @@ obj-$(CONFIG_LEDS_LP50XX) += leds-lp50xx.o ...@@ -52,6 +52,7 @@ obj-$(CONFIG_LEDS_LP50XX) += leds-lp50xx.o
obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o
obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o
obj-$(CONFIG_LEDS_LP5562) += leds-lp5562.o obj-$(CONFIG_LEDS_LP5562) += leds-lp5562.o
obj-$(CONFIG_LEDS_LP5569) += leds-lp5569.o
obj-$(CONFIG_LEDS_LP55XX_COMMON) += leds-lp55xx-common.o obj-$(CONFIG_LEDS_LP55XX_COMMON) += leds-lp55xx-common.o
obj-$(CONFIG_LEDS_LP8501) += leds-lp8501.o obj-$(CONFIG_LEDS_LP8501) += leds-lp8501.o
obj-$(CONFIG_LEDS_LP8788) += leds-lp8788.o obj-$(CONFIG_LEDS_LP8788) += leds-lp8788.o
......
...@@ -303,5 +303,6 @@ static struct platform_driver bcm63138_leds_driver = { ...@@ -303,5 +303,6 @@ static struct platform_driver bcm63138_leds_driver = {
module_platform_driver(bcm63138_leds_driver); module_platform_driver(bcm63138_leds_driver);
MODULE_AUTHOR("Rafał Miłecki"); MODULE_AUTHOR("Rafał Miłecki");
MODULE_DESCRIPTION("Broadcom BCM63138 SoC LED driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(of, bcm63138_leds_of_match_table); MODULE_DEVICE_TABLE(of, bcm63138_leds_of_match_table);
...@@ -121,4 +121,15 @@ config LEDS_SGM3140 ...@@ -121,4 +121,15 @@ config LEDS_SGM3140
This option enables support for the SGM3140 500mA Buck/Boost Charge This option enables support for the SGM3140 500mA Buck/Boost Charge
Pump LED Driver. Pump LED Driver.
config LEDS_SY7802
tristate "LED support for the Silergy SY7802"
depends on I2C && OF
depends on GPIOLIB
select REGMAP_I2C
help
This option enables support for the SY7802 flash LED controller.
SY7802 includes torch and flash functions with programmable current.
This driver can be built as a module, it will be called "leds-sy7802".
endif # LEDS_CLASS_FLASH endif # LEDS_CLASS_FLASH
...@@ -11,3 +11,4 @@ obj-$(CONFIG_LEDS_QCOM_FLASH) += leds-qcom-flash.o ...@@ -11,3 +11,4 @@ obj-$(CONFIG_LEDS_QCOM_FLASH) += leds-qcom-flash.o
obj-$(CONFIG_LEDS_RT4505) += leds-rt4505.o obj-$(CONFIG_LEDS_RT4505) += leds-rt4505.o
obj-$(CONFIG_LEDS_RT8515) += leds-rt8515.o obj-$(CONFIG_LEDS_RT8515) += leds-rt8515.o
obj-$(CONFIG_LEDS_SGM3140) += leds-sgm3140.o obj-$(CONFIG_LEDS_SGM3140) += leds-sgm3140.o
obj-$(CONFIG_LEDS_SY7802) += leds-sy7802.o
...@@ -743,8 +743,8 @@ static void as3645a_remove(struct i2c_client *client) ...@@ -743,8 +743,8 @@ static void as3645a_remove(struct i2c_client *client)
} }
static const struct i2c_device_id as3645a_id_table[] = { static const struct i2c_device_id as3645a_id_table[] = {
{ AS_NAME, 0 }, { AS_NAME },
{ }, { }
}; };
MODULE_DEVICE_TABLE(i2c, as3645a_id_table); MODULE_DEVICE_TABLE(i2c, as3645a_id_table);
......
...@@ -643,14 +643,17 @@ static int mt6360_init_isnk_properties(struct mt6360_led *led, ...@@ -643,14 +643,17 @@ static int mt6360_init_isnk_properties(struct mt6360_led *led,
ret = fwnode_property_read_u32(child, "reg", &reg); ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret || reg > MT6360_LED_ISNK3 || if (ret || reg > MT6360_LED_ISNK3 ||
priv->leds_active & BIT(reg)) priv->leds_active & BIT(reg)) {
fwnode_handle_put(child);
return -EINVAL; return -EINVAL;
}
ret = fwnode_property_read_u32(child, "color", &color); ret = fwnode_property_read_u32(child, "color", &color);
if (ret) { if (ret) {
dev_err(priv->dev, dev_err(priv->dev,
"led %d, no color specified\n", "led %d, no color specified\n",
led->led_no); led->led_no);
fwnode_handle_put(child);
return ret; return ret;
} }
......
...@@ -505,6 +505,7 @@ qcom_flash_v4l2_init(struct device *dev, struct qcom_flash_led *led, struct fwno ...@@ -505,6 +505,7 @@ qcom_flash_v4l2_init(struct device *dev, struct qcom_flash_led *led, struct fwno
struct qcom_flash_data *flash_data = led->flash_data; struct qcom_flash_data *flash_data = led->flash_data;
struct v4l2_flash_config v4l2_cfg = { 0 }; struct v4l2_flash_config v4l2_cfg = { 0 };
struct led_flash_setting *intensity = &v4l2_cfg.intensity; struct led_flash_setting *intensity = &v4l2_cfg.intensity;
struct v4l2_flash *v4l2_flash;
if (!(led->flash.led_cdev.flags & LED_DEV_CAP_FLASH)) if (!(led->flash.led_cdev.flags & LED_DEV_CAP_FLASH))
return 0; return 0;
...@@ -523,9 +524,12 @@ qcom_flash_v4l2_init(struct device *dev, struct qcom_flash_led *led, struct fwno ...@@ -523,9 +524,12 @@ qcom_flash_v4l2_init(struct device *dev, struct qcom_flash_led *led, struct fwno
LED_FAULT_OVER_TEMPERATURE | LED_FAULT_OVER_TEMPERATURE |
LED_FAULT_TIMEOUT; LED_FAULT_TIMEOUT;
flash_data->v4l2_flash[flash_data->leds_count] = v4l2_flash = v4l2_flash_init(dev, fwnode, &led->flash, &qcom_v4l2_flash_ops, &v4l2_cfg);
v4l2_flash_init(dev, fwnode, &led->flash, &qcom_v4l2_flash_ops, &v4l2_cfg); if (IS_ERR(v4l2_flash))
return PTR_ERR_OR_ZERO(flash_data->v4l2_flash); return PTR_ERR(v4l2_flash);
flash_data->v4l2_flash[flash_data->leds_count] = v4l2_flash;
return 0;
} }
# else # else
static int static int
......
...@@ -426,4 +426,5 @@ static struct i2c_driver rt4505_driver = { ...@@ -426,4 +426,5 @@ static struct i2c_driver rt4505_driver = {
module_i2c_driver(rt4505_driver); module_i2c_driver(rt4505_driver);
MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>"); MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>");
MODULE_DESCRIPTION("Richtek RT4505 LED driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
This diff is collapsed.
...@@ -134,6 +134,7 @@ int led_classdev_multicolor_register_ext(struct device *parent, ...@@ -134,6 +134,7 @@ int led_classdev_multicolor_register_ext(struct device *parent,
return -EINVAL; return -EINVAL;
led_cdev = &mcled_cdev->led_cdev; led_cdev = &mcled_cdev->led_cdev;
led_cdev->flags |= LED_MULTI_COLOR;
mcled_cdev->led_cdev.groups = led_multicolor_groups; mcled_cdev->led_cdev.groups = led_multicolor_groups;
return led_classdev_register_ext(parent, led_cdev, init_data); return led_classdev_register_ext(parent, led_cdev, init_data);
......
...@@ -258,7 +258,6 @@ struct led_classdev *of_led_get(struct device_node *np, int index) ...@@ -258,7 +258,6 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
led_dev = class_find_device_by_of_node(&leds_class, led_node); led_dev = class_find_device_by_of_node(&leds_class, led_node);
of_node_put(led_node); of_node_put(led_node);
put_device(led_dev);
return led_module_get(led_dev); return led_module_get(led_dev);
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/led-class-multicolor.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -121,15 +122,22 @@ static void led_timer_function(struct timer_list *t) ...@@ -121,15 +122,22 @@ static void led_timer_function(struct timer_list *t)
static void set_brightness_delayed_set_brightness(struct led_classdev *led_cdev, static void set_brightness_delayed_set_brightness(struct led_classdev *led_cdev,
unsigned int value) unsigned int value)
{ {
int ret = 0; int ret;
ret = __led_set_brightness(led_cdev, value); ret = __led_set_brightness(led_cdev, value);
if (ret == -ENOTSUPP) if (ret == -ENOTSUPP) {
ret = __led_set_brightness_blocking(led_cdev, value); ret = __led_set_brightness_blocking(led_cdev, value);
if (ret < 0 && if (ret == -ENOTSUPP)
/* LED HW might have been unplugged, therefore don't warn */ /* No back-end support to set a fixed brightness value */
!(ret == -ENODEV && (led_cdev->flags & LED_UNREGISTERING) && return;
(led_cdev->flags & LED_HW_PLUGGABLE))) }
/* LED HW might have been unplugged, therefore don't warn */
if (ret == -ENODEV && led_cdev->flags & LED_UNREGISTERING &&
led_cdev->flags & LED_HW_PLUGGABLE)
return;
if (ret < 0)
dev_err(led_cdev->dev, dev_err(led_cdev->dev,
"Setting an LED's brightness failed (%d)\n", ret); "Setting an LED's brightness failed (%d)\n", ret);
} }
...@@ -361,6 +369,36 @@ int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value) ...@@ -361,6 +369,36 @@ int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value)
} }
EXPORT_SYMBOL_GPL(led_set_brightness_sync); EXPORT_SYMBOL_GPL(led_set_brightness_sync);
/*
* This is a led-core function because just like led_set_brightness()
* it is used in the kernel by e.g. triggers.
*/
void led_mc_set_brightness(struct led_classdev *led_cdev,
unsigned int *intensity_value, unsigned int num_colors,
unsigned int brightness)
{
struct led_classdev_mc *mcled_cdev;
unsigned int i;
if (!(led_cdev->flags & LED_MULTI_COLOR)) {
dev_err_once(led_cdev->dev, "error not a multi-color LED\n");
return;
}
mcled_cdev = lcdev_to_mccdev(led_cdev);
if (num_colors != mcled_cdev->num_colors) {
dev_err_once(led_cdev->dev, "error num_colors mismatch %u != %u\n",
num_colors, mcled_cdev->num_colors);
return;
}
for (i = 0; i < mcled_cdev->num_colors; i++)
mcled_cdev->subled_info[i].intensity = intensity_value[i];
led_set_brightness(led_cdev, brightness);
}
EXPORT_SYMBOL_GPL(led_mc_set_brightness);
int led_update_brightness(struct led_classdev *led_cdev) int led_update_brightness(struct led_classdev *led_cdev)
{ {
int ret; int ret;
......
...@@ -179,9 +179,9 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) ...@@ -179,9 +179,9 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
cancel_work_sync(&led_cdev->set_brightness_work); cancel_work_sync(&led_cdev->set_brightness_work);
led_stop_software_blink(led_cdev); led_stop_software_blink(led_cdev);
device_remove_groups(led_cdev->dev, led_cdev->trigger->groups);
if (led_cdev->trigger->deactivate) if (led_cdev->trigger->deactivate)
led_cdev->trigger->deactivate(led_cdev); led_cdev->trigger->deactivate(led_cdev);
device_remove_groups(led_cdev->dev, led_cdev->trigger->groups);
led_cdev->trigger = NULL; led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL; led_cdev->trigger_data = NULL;
led_cdev->activated = false; led_cdev->activated = false;
...@@ -194,6 +194,19 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) ...@@ -194,6 +194,19 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
spin_unlock(&trig->leddev_list_lock); spin_unlock(&trig->leddev_list_lock);
led_cdev->trigger = trig; led_cdev->trigger = trig;
/*
* Some activate() calls use led_trigger_event() to initialize
* the brightness of the LED for which the trigger is being set.
* Ensure the led_cdev is visible on trig->led_cdevs for this.
*/
synchronize_rcu();
/*
* If "set brightness to 0" is pending in workqueue,
* we don't want that to be reordered after ->activate()
*/
flush_work(&led_cdev->set_brightness_work);
ret = 0; ret = 0;
if (trig->activate) if (trig->activate)
ret = trig->activate(led_cdev); ret = trig->activate(led_cdev);
...@@ -396,6 +409,26 @@ void led_trigger_event(struct led_trigger *trig, ...@@ -396,6 +409,26 @@ void led_trigger_event(struct led_trigger *trig,
} }
EXPORT_SYMBOL_GPL(led_trigger_event); EXPORT_SYMBOL_GPL(led_trigger_event);
void led_mc_trigger_event(struct led_trigger *trig,
unsigned int *intensity_value, unsigned int num_colors,
enum led_brightness brightness)
{
struct led_classdev *led_cdev;
if (!trig)
return;
rcu_read_lock();
list_for_each_entry_rcu(led_cdev, &trig->led_cdevs, trig_list) {
if (!(led_cdev->flags & LED_MULTI_COLOR))
continue;
led_mc_set_brightness(led_cdev, intensity_value, num_colors, brightness);
}
rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(led_mc_trigger_event);
static void led_trigger_blink_setup(struct led_trigger *trig, static void led_trigger_blink_setup(struct led_trigger *trig,
unsigned long delay_on, unsigned long delay_on,
unsigned long delay_off, unsigned long delay_off,
......
...@@ -331,8 +331,8 @@ static const struct of_device_id an30259a_match_table[] = { ...@@ -331,8 +331,8 @@ static const struct of_device_id an30259a_match_table[] = {
MODULE_DEVICE_TABLE(of, an30259a_match_table); MODULE_DEVICE_TABLE(of, an30259a_match_table);
static const struct i2c_device_id an30259a_id[] = { static const struct i2c_device_id an30259a_id[] = {
{ "an30259a", 0 }, { "an30259a" },
{ /* sentinel */ }, { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(i2c, an30259a_id); MODULE_DEVICE_TABLE(i2c, an30259a_id);
......
...@@ -776,7 +776,7 @@ static int bd2802_resume(struct device *dev) ...@@ -776,7 +776,7 @@ static int bd2802_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(bd2802_pm, bd2802_suspend, bd2802_resume); static SIMPLE_DEV_PM_OPS(bd2802_pm, bd2802_suspend, bd2802_resume);
static const struct i2c_device_id bd2802_id[] = { static const struct i2c_device_id bd2802_id[] = {
{ "BD2802", 0 }, { "BD2802" },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, bd2802_id); MODULE_DEVICE_TABLE(i2c, bd2802_id);
......
...@@ -718,7 +718,7 @@ static void blinkm_remove(struct i2c_client *client) ...@@ -718,7 +718,7 @@ static void blinkm_remove(struct i2c_client *client)
} }
static const struct i2c_device_id blinkm_id[] = { static const struct i2c_device_id blinkm_id[] = {
{"blinkm", 0}, { "blinkm" },
{} {}
}; };
......
...@@ -140,7 +140,7 @@ static const struct reg_default is31fl3190_reg_defaults[] = { ...@@ -140,7 +140,7 @@ static const struct reg_default is31fl3190_reg_defaults[] = {
{ IS31FL3190_PWM(2), 0x00 }, { IS31FL3190_PWM(2), 0x00 },
}; };
static struct regmap_config is31fl3190_regmap_config = { static const struct regmap_config is31fl3190_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
.max_register = IS31FL3190_RESET, .max_register = IS31FL3190_RESET,
...@@ -178,7 +178,7 @@ static const struct reg_default is31fl3196_reg_defaults[] = { ...@@ -178,7 +178,7 @@ static const struct reg_default is31fl3196_reg_defaults[] = {
{ IS31FL3196_PWM(8), 0x00 }, { IS31FL3196_PWM(8), 0x00 },
}; };
static struct regmap_config is31fl3196_regmap_config = { static const struct regmap_config is31fl3196_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
.max_register = IS31FL3196_REG_CNT, .max_register = IS31FL3196_REG_CNT,
......
...@@ -478,7 +478,7 @@ static void lm3530_remove(struct i2c_client *client) ...@@ -478,7 +478,7 @@ static void lm3530_remove(struct i2c_client *client)
} }
static const struct i2c_device_id lm3530_id[] = { static const struct i2c_device_id lm3530_id[] = {
{LM3530_NAME, 0}, { LM3530_NAME },
{} {}
}; };
MODULE_DEVICE_TABLE(i2c, lm3530_id); MODULE_DEVICE_TABLE(i2c, lm3530_id);
......
...@@ -726,7 +726,7 @@ static const struct of_device_id of_lm3532_leds_match[] = { ...@@ -726,7 +726,7 @@ static const struct of_device_id of_lm3532_leds_match[] = {
MODULE_DEVICE_TABLE(of, of_lm3532_leds_match); MODULE_DEVICE_TABLE(of, of_lm3532_leds_match);
static const struct i2c_device_id lm3532_id[] = { static const struct i2c_device_id lm3532_id[] = {
{LM3532_NAME, 0}, { LM3532_NAME },
{} {}
}; };
MODULE_DEVICE_TABLE(i2c, lm3532_id); MODULE_DEVICE_TABLE(i2c, lm3532_id);
......
...@@ -390,7 +390,7 @@ static void lm3642_remove(struct i2c_client *client) ...@@ -390,7 +390,7 @@ static void lm3642_remove(struct i2c_client *client)
} }
static const struct i2c_device_id lm3642_id[] = { static const struct i2c_device_id lm3642_id[] = {
{LM3642_NAME, 0}, { LM3642_NAME },
{} {}
}; };
......
...@@ -360,7 +360,7 @@ static void lm3697_remove(struct i2c_client *client) ...@@ -360,7 +360,7 @@ static void lm3697_remove(struct i2c_client *client)
} }
static const struct i2c_device_id lm3697_id[] = { static const struct i2c_device_id lm3697_id[] = {
{ "lm3697", 0 }, { "lm3697" },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, lm3697_id); MODULE_DEVICE_TABLE(i2c, lm3697_id);
......
...@@ -417,7 +417,7 @@ static void lp3944_remove(struct i2c_client *client) ...@@ -417,7 +417,7 @@ static void lp3944_remove(struct i2c_client *client)
/* lp3944 i2c driver struct */ /* lp3944 i2c driver struct */
static const struct i2c_device_id lp3944_id[] = { static const struct i2c_device_id lp3944_id[] = {
{"lp3944", 0}, { "lp3944" },
{} {}
}; };
......
...@@ -266,7 +266,7 @@ static int lp3952_probe(struct i2c_client *client) ...@@ -266,7 +266,7 @@ static int lp3952_probe(struct i2c_client *client)
} }
static const struct i2c_device_id lp3952_id[] = { static const struct i2c_device_id lp3952_id[] = {
{LP3952_NAME, 0}, { LP3952_NAME },
{} {}
}; };
MODULE_DEVICE_TABLE(i2c, lp3952_id); MODULE_DEVICE_TABLE(i2c, lp3952_id);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/led-class-multicolor.h> #include <linux/led-class-multicolor.h>
#define LP55xx_BYTES_PER_PAGE 32 /* bytes */
enum lp55xx_engine_index { enum lp55xx_engine_index {
LP55XX_ENGINE_INVALID, LP55XX_ENGINE_INVALID,
LP55XX_ENGINE_1, LP55XX_ENGINE_1,
...@@ -35,45 +37,62 @@ enum lp55xx_engine_mode { ...@@ -35,45 +37,62 @@ enum lp55xx_engine_mode {
#define LP55XX_DEV_ATTR_WO(name, store) \ #define LP55XX_DEV_ATTR_WO(name, store) \
DEVICE_ATTR(name, S_IWUSR, NULL, store) DEVICE_ATTR(name, S_IWUSR, NULL, store)
#define show_mode(nr) \ #define LP55XX_DEV_ATTR_ENGINE_MODE(nr) \
static ssize_t show_engine##nr##_mode(struct device *dev, \ static ssize_t show_engine##nr##_mode(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
return show_engine_mode(dev, attr, buf, nr); \ return lp55xx_show_engine_mode(dev, attr, buf, nr); \
} } \
#define store_mode(nr) \
static ssize_t store_engine##nr##_mode(struct device *dev, \ static ssize_t store_engine##nr##_mode(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
const char *buf, size_t len) \ const char *buf, size_t len) \
{ \ { \
return store_engine_mode(dev, attr, buf, len, nr); \ return lp55xx_store_engine_mode(dev, attr, buf, len, nr); \
} } \
static LP55XX_DEV_ATTR_RW(engine##nr##_mode, show_engine##nr##_mode, \
store_engine##nr##_mode)
#define show_leds(nr) \ #define LP55XX_DEV_ATTR_ENGINE_LEDS(nr) \
static ssize_t show_engine##nr##_leds(struct device *dev, \ static ssize_t show_engine##nr##_leds(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
return show_engine_leds(dev, attr, buf, nr); \ return lp55xx_show_engine_leds(dev, attr, buf, nr); \
} } \
static ssize_t store_engine##nr##_leds(struct device *dev, \
#define store_leds(nr) \ struct device_attribute *attr, \
static ssize_t store_engine##nr##_leds(struct device *dev, \ const char *buf, size_t len) \
struct device_attribute *attr, \ { \
const char *buf, size_t len) \ return lp55xx_store_engine_leds(dev, attr, buf, len, nr); \
{ \ } \
return store_engine_leds(dev, attr, buf, len, nr); \ static LP55XX_DEV_ATTR_RW(engine##nr##_leds, show_engine##nr##_leds, \
} store_engine##nr##_leds)
#define store_load(nr) \ #define LP55XX_DEV_ATTR_ENGINE_LOAD(nr) \
static ssize_t store_engine##nr##_load(struct device *dev, \ static ssize_t store_engine##nr##_load(struct device *dev, \
struct device_attribute *attr, \
const char *buf, size_t len) \
{ \
return lp55xx_store_engine_load(dev, attr, buf, len, nr); \
} \
static LP55XX_DEV_ATTR_WO(engine##nr##_load, store_engine##nr##_load)
#define LP55XX_DEV_ATTR_MASTER_FADER(nr) \
static ssize_t show_master_fader##nr(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
const char *buf, size_t len) \ char *buf) \
{ \ { \
return store_engine_load(dev, attr, buf, len, nr); \ return lp55xx_show_master_fader(dev, attr, buf, nr); \
} } \
static ssize_t store_master_fader##nr(struct device *dev, \
struct device_attribute *attr, \
const char *buf, size_t len) \
{ \
return lp55xx_store_master_fader(dev, attr, buf, len, nr); \
} \
static LP55XX_DEV_ATTR_RW(master_fader##nr, show_master_fader##nr, \
store_master_fader##nr)
struct lp55xx_led; struct lp55xx_led;
struct lp55xx_chip; struct lp55xx_chip;
...@@ -81,17 +100,31 @@ struct lp55xx_chip; ...@@ -81,17 +100,31 @@ struct lp55xx_chip;
/* /*
* struct lp55xx_reg * struct lp55xx_reg
* @addr : Register address * @addr : Register address
* @val : Register value * @val : Register value (can also used as mask or shift)
*/ */
struct lp55xx_reg { struct lp55xx_reg {
u8 addr; u8 addr;
u8 val; union {
u8 val;
u8 mask;
u8 shift;
};
}; };
/* /*
* struct lp55xx_device_config * struct lp55xx_device_config
* @reg_op_mode : Chip specific OP MODE reg addr
* @engine_busy : Chip specific engine busy
* (if not supported 153 us sleep)
* @reset : Chip specific reset command * @reset : Chip specific reset command
* @enable : Chip specific enable command * @enable : Chip specific enable command
* @prog_mem_base : Chip specific base reg address for chip SMEM programming
* @reg_led_pwm_base : Chip specific base reg address for LED PWM conf
* @reg_led_current_base : Chip specific base reg address for LED current conf
* @reg_master_fader_base : Chip specific base reg address for master fader base
* @reg_led_ctrl_base : Chip specific base reg address for LED ctrl base
* @pages_per_engine : Assigned pages for each engine
* (if not set chip doesn't support pages)
* @max_channel : Maximum number of channels * @max_channel : Maximum number of channels
* @post_init_device : Chip specific initialization code * @post_init_device : Chip specific initialization code
* @brightness_fn : Brightness function * @brightness_fn : Brightness function
...@@ -102,8 +135,17 @@ struct lp55xx_reg { ...@@ -102,8 +135,17 @@ struct lp55xx_reg {
* @dev_attr_group : Device specific attributes * @dev_attr_group : Device specific attributes
*/ */
struct lp55xx_device_config { struct lp55xx_device_config {
const struct lp55xx_reg reg_op_mode; /* addr, shift */
const struct lp55xx_reg reg_exec; /* addr, shift */
const struct lp55xx_reg engine_busy; /* addr, mask */
const struct lp55xx_reg reset; const struct lp55xx_reg reset;
const struct lp55xx_reg enable; const struct lp55xx_reg enable;
const struct lp55xx_reg prog_mem_base;
const struct lp55xx_reg reg_led_pwm_base;
const struct lp55xx_reg reg_led_current_base;
const struct lp55xx_reg reg_master_fader_base;
const struct lp55xx_reg reg_led_ctrl_base;
const int pages_per_engine;
const int max_channel; const int max_channel;
/* define if the device has specific initialization process */ /* define if the device has specific initialization process */
...@@ -155,7 +197,7 @@ struct lp55xx_chip { ...@@ -155,7 +197,7 @@ struct lp55xx_chip {
struct lp55xx_platform_data *pdata; struct lp55xx_platform_data *pdata;
struct mutex lock; /* lock for user-space interface */ struct mutex lock; /* lock for user-space interface */
int num_leds; int num_leds;
struct lp55xx_device_config *cfg; const struct lp55xx_device_config *cfg;
enum lp55xx_engine_index engine_idx; enum lp55xx_engine_index engine_idx;
struct lp55xx_engine engines[LP55XX_ENGINE_MAX]; struct lp55xx_engine engines[LP55XX_ENGINE_MAX];
const struct firmware *fw; const struct firmware *fw;
...@@ -191,21 +233,50 @@ extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, ...@@ -191,21 +233,50 @@ extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg,
/* external clock detection */ /* external clock detection */
extern bool lp55xx_is_extclk_used(struct lp55xx_chip *chip); extern bool lp55xx_is_extclk_used(struct lp55xx_chip *chip);
/* common device init/deinit functions */ /* common chip functions */
extern int lp55xx_init_device(struct lp55xx_chip *chip); extern void lp55xx_stop_all_engine(struct lp55xx_chip *chip);
extern void lp55xx_deinit_device(struct lp55xx_chip *chip); extern void lp55xx_load_engine(struct lp55xx_chip *chip);
extern int lp55xx_run_engine_common(struct lp55xx_chip *chip);
/* common LED class device functions */ extern int lp55xx_update_program_memory(struct lp55xx_chip *chip,
extern int lp55xx_register_leds(struct lp55xx_led *led, const u8 *data, size_t size);
struct lp55xx_chip *chip); extern void lp55xx_firmware_loaded_cb(struct lp55xx_chip *chip);
extern int lp55xx_led_brightness(struct lp55xx_led *led);
extern int lp55xx_multicolor_brightness(struct lp55xx_led *led);
extern void lp55xx_set_led_current(struct lp55xx_led *led, u8 led_current);
extern void lp55xx_turn_off_channels(struct lp55xx_chip *chip);
extern void lp55xx_stop_engine(struct lp55xx_chip *chip);
/* common device attributes functions */ /* common probe/remove function */
extern int lp55xx_register_sysfs(struct lp55xx_chip *chip); extern int lp55xx_probe(struct i2c_client *client);
extern void lp55xx_unregister_sysfs(struct lp55xx_chip *chip); extern void lp55xx_remove(struct i2c_client *client);
/* common device tree population function */ /* common sysfs function */
extern struct lp55xx_platform_data extern ssize_t lp55xx_show_engine_mode(struct device *dev,
*lp55xx_of_populate_pdata(struct device *dev, struct device_node *np, struct device_attribute *attr,
struct lp55xx_chip *chip); char *buf, int nr);
extern ssize_t lp55xx_store_engine_mode(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len, int nr);
extern ssize_t lp55xx_store_engine_load(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len, int nr);
extern ssize_t lp55xx_show_engine_leds(struct device *dev,
struct device_attribute *attr,
char *buf, int nr);
extern ssize_t lp55xx_store_engine_leds(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len, int nr);
extern ssize_t lp55xx_show_master_fader(struct device *dev,
struct device_attribute *attr,
char *buf, int nr);
extern ssize_t lp55xx_store_master_fader(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len, int nr);
extern ssize_t lp55xx_show_master_fader_leds(struct device *dev,
struct device_attribute *attr,
char *buf);
extern ssize_t lp55xx_store_master_fader_leds(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len);
#endif /* _LEDS_LP55XX_COMMON_H */ #endif /* _LEDS_LP55XX_COMMON_H */
...@@ -20,27 +20,14 @@ ...@@ -20,27 +20,14 @@
#include "leds-lp55xx-common.h" #include "leds-lp55xx-common.h"
#define LP8501_PROGRAM_LENGTH 32 #define LP8501_PAGES_PER_ENGINE 1
#define LP8501_MAX_LEDS 9 #define LP8501_MAX_LEDS 9
/* Registers */ /* Registers */
#define LP8501_REG_ENABLE 0x00 #define LP8501_REG_ENABLE 0x00
#define LP8501_ENABLE BIT(6) #define LP8501_ENABLE BIT(6)
#define LP8501_EXEC_M 0x3F
#define LP8501_EXEC_ENG1_M 0x30
#define LP8501_EXEC_ENG2_M 0x0C
#define LP8501_EXEC_ENG3_M 0x03
#define LP8501_RUN_ENG1 0x20
#define LP8501_RUN_ENG2 0x08
#define LP8501_RUN_ENG3 0x02
#define LP8501_REG_OP_MODE 0x01 #define LP8501_REG_OP_MODE 0x01
#define LP8501_MODE_ENG1_M 0x30
#define LP8501_MODE_ENG2_M 0x0C
#define LP8501_MODE_ENG3_M 0x03
#define LP8501_LOAD_ENG1 0x10
#define LP8501_LOAD_ENG2 0x04
#define LP8501_LOAD_ENG3 0x01
#define LP8501_REG_PWR_CONFIG 0x05 #define LP8501_REG_PWR_CONFIG 0x05
#define LP8501_PWR_CONFIG_M 0x03 #define LP8501_PWR_CONFIG_M 0x03
...@@ -58,35 +45,14 @@ ...@@ -58,35 +45,14 @@
#define LP8501_INT_CLK BIT(0) #define LP8501_INT_CLK BIT(0)
#define LP8501_DEFAULT_CFG (LP8501_PWM_PSAVE | LP8501_AUTO_INC | LP8501_PWR_SAVE) #define LP8501_DEFAULT_CFG (LP8501_PWM_PSAVE | LP8501_AUTO_INC | LP8501_PWR_SAVE)
#define LP8501_REG_STATUS 0x3A
#define LP8501_ENGINE_BUSY BIT(4)
#define LP8501_REG_RESET 0x3D #define LP8501_REG_RESET 0x3D
#define LP8501_RESET 0xFF #define LP8501_RESET 0xFF
#define LP8501_REG_PROG_PAGE_SEL 0x4F
#define LP8501_PAGE_ENG1 0
#define LP8501_PAGE_ENG2 1
#define LP8501_PAGE_ENG3 2
#define LP8501_REG_PROG_MEM 0x50 #define LP8501_REG_PROG_MEM 0x50
#define LP8501_ENG1_IS_LOADING(mode) \
((mode & LP8501_MODE_ENG1_M) == LP8501_LOAD_ENG1)
#define LP8501_ENG2_IS_LOADING(mode) \
((mode & LP8501_MODE_ENG2_M) == LP8501_LOAD_ENG2)
#define LP8501_ENG3_IS_LOADING(mode) \
((mode & LP8501_MODE_ENG3_M) == LP8501_LOAD_ENG3)
static inline void lp8501_wait_opmode_done(void)
{
usleep_range(1000, 2000);
}
static void lp8501_set_led_current(struct lp55xx_led *led, u8 led_current)
{
led->led_current = led_current;
lp55xx_write(led->chip, LP8501_REG_LED_CURRENT_BASE + led->chan_nr,
led_current);
}
static int lp8501_post_init_device(struct lp55xx_chip *chip) static int lp8501_post_init_device(struct lp55xx_chip *chip)
{ {
int ret; int ret;
...@@ -113,178 +79,30 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip) ...@@ -113,178 +79,30 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip)
LP8501_PWR_CONFIG_M, chip->pdata->pwr_sel); LP8501_PWR_CONFIG_M, chip->pdata->pwr_sel);
} }
static void lp8501_load_engine(struct lp55xx_chip *chip)
{
enum lp55xx_engine_index idx = chip->engine_idx;
static const u8 mask[] = {
[LP55XX_ENGINE_1] = LP8501_MODE_ENG1_M,
[LP55XX_ENGINE_2] = LP8501_MODE_ENG2_M,
[LP55XX_ENGINE_3] = LP8501_MODE_ENG3_M,
};
static const u8 val[] = {
[LP55XX_ENGINE_1] = LP8501_LOAD_ENG1,
[LP55XX_ENGINE_2] = LP8501_LOAD_ENG2,
[LP55XX_ENGINE_3] = LP8501_LOAD_ENG3,
};
static const u8 page_sel[] = {
[LP55XX_ENGINE_1] = LP8501_PAGE_ENG1,
[LP55XX_ENGINE_2] = LP8501_PAGE_ENG2,
[LP55XX_ENGINE_3] = LP8501_PAGE_ENG3,
};
lp55xx_update_bits(chip, LP8501_REG_OP_MODE, mask[idx], val[idx]);
lp8501_wait_opmode_done();
lp55xx_write(chip, LP8501_REG_PROG_PAGE_SEL, page_sel[idx]);
}
static void lp8501_stop_engine(struct lp55xx_chip *chip)
{
lp55xx_write(chip, LP8501_REG_OP_MODE, 0);
lp8501_wait_opmode_done();
}
static void lp8501_turn_off_channels(struct lp55xx_chip *chip)
{
int i;
for (i = 0; i < LP8501_MAX_LEDS; i++)
lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + i, 0);
}
static void lp8501_run_engine(struct lp55xx_chip *chip, bool start) static void lp8501_run_engine(struct lp55xx_chip *chip, bool start)
{ {
int ret;
u8 mode;
u8 exec;
/* stop engine */ /* stop engine */
if (!start) { if (!start) {
lp8501_stop_engine(chip); lp55xx_stop_all_engine(chip);
lp8501_turn_off_channels(chip); lp55xx_turn_off_channels(chip);
return;
}
/*
* To run the engine,
* operation mode and enable register should updated at the same time
*/
ret = lp55xx_read(chip, LP8501_REG_OP_MODE, &mode);
if (ret)
return;
ret = lp55xx_read(chip, LP8501_REG_ENABLE, &exec);
if (ret)
return;
/* change operation mode to RUN only when each engine is loading */
if (LP8501_ENG1_IS_LOADING(mode)) {
mode = (mode & ~LP8501_MODE_ENG1_M) | LP8501_RUN_ENG1;
exec = (exec & ~LP8501_EXEC_ENG1_M) | LP8501_RUN_ENG1;
}
if (LP8501_ENG2_IS_LOADING(mode)) {
mode = (mode & ~LP8501_MODE_ENG2_M) | LP8501_RUN_ENG2;
exec = (exec & ~LP8501_EXEC_ENG2_M) | LP8501_RUN_ENG2;
}
if (LP8501_ENG3_IS_LOADING(mode)) {
mode = (mode & ~LP8501_MODE_ENG3_M) | LP8501_RUN_ENG3;
exec = (exec & ~LP8501_EXEC_ENG3_M) | LP8501_RUN_ENG3;
}
lp55xx_write(chip, LP8501_REG_OP_MODE, mode);
lp8501_wait_opmode_done();
lp55xx_update_bits(chip, LP8501_REG_ENABLE, LP8501_EXEC_M, exec);
}
static int lp8501_update_program_memory(struct lp55xx_chip *chip,
const u8 *data, size_t size)
{
u8 pattern[LP8501_PROGRAM_LENGTH] = {0};
unsigned cmd;
char c[3];
int update_size;
int nrchars;
int offset = 0;
int ret;
int i;
/* clear program memory before updating */
for (i = 0; i < LP8501_PROGRAM_LENGTH; i++)
lp55xx_write(chip, LP8501_REG_PROG_MEM + i, 0);
i = 0;
while ((offset < size - 1) && (i < LP8501_PROGRAM_LENGTH)) {
/* separate sscanfs because length is working only for %s */
ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
if (ret != 1)
goto err;
ret = sscanf(c, "%2x", &cmd);
if (ret != 1)
goto err;
pattern[i] = (u8)cmd;
offset += nrchars;
i++;
}
/* Each instruction is 16bit long. Check that length is even */
if (i % 2)
goto err;
update_size = i;
for (i = 0; i < update_size; i++)
lp55xx_write(chip, LP8501_REG_PROG_MEM + i, pattern[i]);
return 0;
err:
dev_err(&chip->cl->dev, "wrong pattern format\n");
return -EINVAL;
}
static void lp8501_firmware_loaded(struct lp55xx_chip *chip)
{
const struct firmware *fw = chip->fw;
if (fw->size > LP8501_PROGRAM_LENGTH) {
dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n",
fw->size);
return; return;
} }
/* lp55xx_run_engine_common(chip);
* Program memory sequence
* 1) set engine mode to "LOAD"
* 2) write firmware data into program memory
*/
lp8501_load_engine(chip);
lp8501_update_program_memory(chip, fw->data, fw->size);
}
static int lp8501_led_brightness(struct lp55xx_led *led)
{
struct lp55xx_chip *chip = led->chip;
int ret;
mutex_lock(&chip->lock);
ret = lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + led->chan_nr,
led->brightness);
mutex_unlock(&chip->lock);
return ret;
} }
/* Chip specific configurations */ /* Chip specific configurations */
static struct lp55xx_device_config lp8501_cfg = { static struct lp55xx_device_config lp8501_cfg = {
.reg_op_mode = {
.addr = LP8501_REG_OP_MODE,
},
.reg_exec = {
.addr = LP8501_REG_ENABLE,
},
.engine_busy = {
.addr = LP8501_REG_STATUS,
.mask = LP8501_ENGINE_BUSY,
},
.reset = { .reset = {
.addr = LP8501_REG_RESET, .addr = LP8501_REG_RESET,
.val = LP8501_RESET, .val = LP8501_RESET,
...@@ -293,95 +111,32 @@ static struct lp55xx_device_config lp8501_cfg = { ...@@ -293,95 +111,32 @@ static struct lp55xx_device_config lp8501_cfg = {
.addr = LP8501_REG_ENABLE, .addr = LP8501_REG_ENABLE,
.val = LP8501_ENABLE, .val = LP8501_ENABLE,
}, },
.prog_mem_base = {
.addr = LP8501_REG_PROG_MEM,
},
.reg_led_pwm_base = {
.addr = LP8501_REG_LED_PWM_BASE,
},
.reg_led_current_base = {
.addr = LP8501_REG_LED_CURRENT_BASE,
},
.pages_per_engine = LP8501_PAGES_PER_ENGINE,
.max_channel = LP8501_MAX_LEDS, .max_channel = LP8501_MAX_LEDS,
.post_init_device = lp8501_post_init_device, .post_init_device = lp8501_post_init_device,
.brightness_fn = lp8501_led_brightness, .brightness_fn = lp55xx_led_brightness,
.set_led_current = lp8501_set_led_current, .set_led_current = lp55xx_set_led_current,
.firmware_cb = lp8501_firmware_loaded, .firmware_cb = lp55xx_firmware_loaded_cb,
.run_engine = lp8501_run_engine, .run_engine = lp8501_run_engine,
}; };
static int lp8501_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
int ret;
struct lp55xx_chip *chip;
struct lp55xx_led *led;
struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
struct device_node *np = dev_of_node(&client->dev);
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
chip->cfg = &lp8501_cfg;
if (!pdata) {
if (np) {
pdata = lp55xx_of_populate_pdata(&client->dev, np,
chip);
if (IS_ERR(pdata))
return PTR_ERR(pdata);
} else {
dev_err(&client->dev, "no platform data\n");
return -EINVAL;
}
}
led = devm_kcalloc(&client->dev,
pdata->num_channels, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;
chip->cl = client;
chip->pdata = pdata;
mutex_init(&chip->lock);
i2c_set_clientdata(client, led);
ret = lp55xx_init_device(chip);
if (ret)
goto err_init;
dev_info(&client->dev, "%s Programmable led chip found\n", id->name);
ret = lp55xx_register_leds(led, chip);
if (ret)
goto err_out;
ret = lp55xx_register_sysfs(chip);
if (ret) {
dev_err(&client->dev, "registering sysfs failed\n");
goto err_out;
}
return 0;
err_out:
lp55xx_deinit_device(chip);
err_init:
return ret;
}
static void lp8501_remove(struct i2c_client *client)
{
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
lp8501_stop_engine(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_deinit_device(chip);
}
static const struct i2c_device_id lp8501_id[] = { static const struct i2c_device_id lp8501_id[] = {
{ "lp8501", 0 }, { "lp8501", .driver_data = (kernel_ulong_t)&lp8501_cfg, },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, lp8501_id); MODULE_DEVICE_TABLE(i2c, lp8501_id);
static const struct of_device_id of_lp8501_leds_match[] = { static const struct of_device_id of_lp8501_leds_match[] = {
{ .compatible = "ti,lp8501", }, { .compatible = "ti,lp8501", .data = &lp8501_cfg, },
{}, {},
}; };
...@@ -392,8 +147,8 @@ static struct i2c_driver lp8501_driver = { ...@@ -392,8 +147,8 @@ static struct i2c_driver lp8501_driver = {
.name = "lp8501", .name = "lp8501",
.of_match_table = of_lp8501_leds_match, .of_match_table = of_lp8501_leds_match,
}, },
.probe = lp8501_probe, .probe = lp55xx_probe,
.remove = lp8501_remove, .remove = lp55xx_remove,
.id_table = lp8501_id, .id_table = lp8501_id,
}; };
......
...@@ -459,7 +459,7 @@ static void lp8860_remove(struct i2c_client *client) ...@@ -459,7 +459,7 @@ static void lp8860_remove(struct i2c_client *client)
} }
static const struct i2c_device_id lp8860_id[] = { static const struct i2c_device_id lp8860_id[] = {
{ "lp8860", 0 }, { "lp8860" },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, lp8860_id); MODULE_DEVICE_TABLE(i2c, lp8860_id);
......
This diff is collapsed.
...@@ -246,29 +246,25 @@ static int powernv_led_classdev(struct platform_device *pdev, ...@@ -246,29 +246,25 @@ static int powernv_led_classdev(struct platform_device *pdev,
const char *cur = NULL; const char *cur = NULL;
int rc = -1; int rc = -1;
struct property *p; struct property *p;
struct device_node *np;
struct powernv_led_data *powernv_led; struct powernv_led_data *powernv_led;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
for_each_available_child_of_node(led_node, np) { for_each_available_child_of_node_scoped(led_node, np) {
p = of_find_property(np, "led-types", NULL); p = of_find_property(np, "led-types", NULL);
while ((cur = of_prop_next_string(p, cur)) != NULL) { while ((cur = of_prop_next_string(p, cur)) != NULL) {
powernv_led = devm_kzalloc(dev, sizeof(*powernv_led), powernv_led = devm_kzalloc(dev, sizeof(*powernv_led),
GFP_KERNEL); GFP_KERNEL);
if (!powernv_led) { if (!powernv_led)
of_node_put(np);
return -ENOMEM; return -ENOMEM;
}
powernv_led->common = powernv_led_common; powernv_led->common = powernv_led_common;
powernv_led->loc_code = (char *)np->name; powernv_led->loc_code = (char *)np->name;
rc = powernv_led_create(dev, powernv_led, cur); rc = powernv_led_create(dev, powernv_led, cur);
if (rc) { if (rc)
of_node_put(np);
return rc; return rc;
}
} /* while end */ } /* while end */
} }
...@@ -278,12 +274,11 @@ static int powernv_led_classdev(struct platform_device *pdev, ...@@ -278,12 +274,11 @@ static int powernv_led_classdev(struct platform_device *pdev,
/* Platform driver probe */ /* Platform driver probe */
static int powernv_led_probe(struct platform_device *pdev) static int powernv_led_probe(struct platform_device *pdev)
{ {
struct device_node *led_node;
struct powernv_led_common *powernv_led_common; struct powernv_led_common *powernv_led_common;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int rc; struct device_node *led_node
__free(device_node) = of_find_node_by_path("/ibm,opal/leds");
led_node = of_find_node_by_path("/ibm,opal/leds");
if (!led_node) { if (!led_node) {
dev_err(dev, "%s: LED parent device node not found\n", dev_err(dev, "%s: LED parent device node not found\n",
__func__); __func__);
...@@ -292,20 +287,15 @@ static int powernv_led_probe(struct platform_device *pdev) ...@@ -292,20 +287,15 @@ static int powernv_led_probe(struct platform_device *pdev)
powernv_led_common = devm_kzalloc(dev, sizeof(*powernv_led_common), powernv_led_common = devm_kzalloc(dev, sizeof(*powernv_led_common),
GFP_KERNEL); GFP_KERNEL);
if (!powernv_led_common) { if (!powernv_led_common)
rc = -ENOMEM; return -ENOMEM;
goto out;
}
mutex_init(&powernv_led_common->lock); mutex_init(&powernv_led_common->lock);
powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX); powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX);
platform_set_drvdata(pdev, powernv_led_common); platform_set_drvdata(pdev, powernv_led_common);
rc = powernv_led_classdev(pdev, led_node, powernv_led_common); return powernv_led_classdev(pdev, led_node, powernv_led_common);
out:
of_node_put(led_node);
return rc;
} }
/* Platform driver remove */ /* Platform driver remove */
......
This diff is collapsed.
...@@ -356,8 +356,10 @@ static int ich7_lpc_probe(struct pci_dev *dev, ...@@ -356,8 +356,10 @@ static int ich7_lpc_probe(struct pci_dev *dev,
nas_gpio_pci_dev = dev; nas_gpio_pci_dev = dev;
status = pci_read_config_dword(dev, PMBASE, &g_pm_io_base); status = pci_read_config_dword(dev, PMBASE, &g_pm_io_base);
if (status) if (status) {
status = pcibios_err_to_errno(status);
goto out; goto out;
}
g_pm_io_base &= 0x00000ff80; g_pm_io_base &= 0x00000ff80;
status = pci_read_config_dword(dev, GPIO_CTRL, &gc); status = pci_read_config_dword(dev, GPIO_CTRL, &gc);
...@@ -369,8 +371,9 @@ static int ich7_lpc_probe(struct pci_dev *dev, ...@@ -369,8 +371,9 @@ static int ich7_lpc_probe(struct pci_dev *dev,
} }
status = pci_read_config_dword(dev, GPIO_BASE, &nas_gpio_io_base); status = pci_read_config_dword(dev, GPIO_BASE, &nas_gpio_io_base);
if (0 > status) { if (status) {
dev_info(&dev->dev, "Unable to read GPIOBASE.\n"); dev_info(&dev->dev, "Unable to read GPIOBASE.\n");
status = pcibios_err_to_errno(status);
goto out; goto out;
} }
dev_dbg(&dev->dev, ": GPIOBASE = 0x%08x\n", nas_gpio_io_base); dev_dbg(&dev->dev, ": GPIOBASE = 0x%08x\n", nas_gpio_io_base);
......
This diff is collapsed.
...@@ -534,7 +534,7 @@ static const struct of_device_id of_omnia_leds_match[] = { ...@@ -534,7 +534,7 @@ static const struct of_device_id of_omnia_leds_match[] = {
}; };
static const struct i2c_device_id omnia_id[] = { static const struct i2c_device_id omnia_id[] = {
{ "omnia", 0 }, { "omnia" },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, omnia_id); MODULE_DEVICE_TABLE(i2c, omnia_id);
......
...@@ -17,7 +17,6 @@ config LEDS_GROUP_MULTICOLOR ...@@ -17,7 +17,6 @@ config LEDS_GROUP_MULTICOLOR
config LEDS_KTD202X config LEDS_KTD202X
tristate "LED support for KTD202x Chips" tristate "LED support for KTD202x Chips"
depends on I2C depends on I2C
depends on OF
select REGMAP_I2C select REGMAP_I2C
help help
This option enables support for the Kinetic KTD2026/KTD2027 This option enables support for the Kinetic KTD2026/KTD2027
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,3 +15,4 @@ obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o ...@@ -15,3 +15,4 @@ obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o
obj-$(CONFIG_LEDS_TRIGGER_INPUT_EVENTS) += ledtrig-input-events.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment