Commit dfb0a0b7 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'leds-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds

Pull LED updates from Pavel Machek:
 "Nothing major here, there are two drivers that need review and did not
  make it into this round"

* tag 'leds-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds:
  leds: pca955x: Allow zero LEDs to be specified
  leds: pca955x: Make the gpiochip always expose all pins
  leds: simatic-ipc-leds: Don't directly deref ioremap_resource() returned ptr
  leds: simatic-ipc-leds: Make simatic_ipc_led_mem_res static
  leds: lm3692x: Return 0 from remove callback
  leds: sgm3140: Add ocs,ocp8110 compatible
  dt-bindings: vendor-prefixes: Add ocs prefix
  dt-bindings: leds: common: fix unit address in max77693 example
parents 7b58b82b e26557a0
......@@ -185,9 +185,11 @@ examples:
};
};
led-controller@0 {
- |
#include <dt-bindings/leds/common.h>
led-controller {
compatible = "maxim,max77693-led";
reg = <0 0x100>;
led {
function = LED_FUNCTION_FLASH;
......@@ -199,6 +201,9 @@ examples:
};
};
- |
#include <dt-bindings/leds/common.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
......
......@@ -876,6 +876,8 @@ patternProperties:
description: NXP Semiconductors
"^oceanic,.*":
description: Oceanic Systems (UK) Ltd.
"^ocs,.*":
description: Orient Chip Technology Co., Ltd.
"^oct,.*":
description: Octavo Systems LLC
"^okaya,.*":
......
......@@ -290,6 +290,7 @@ static int sgm3140_remove(struct platform_device *pdev)
}
static const struct of_device_id sgm3140_dt_match[] = {
{ .compatible = "ocs,ocp8110" },
{ .compatible = "sgmicro,sgm3140" },
{ /* sentinel */ }
};
......
......@@ -494,11 +494,8 @@ static int lm3692x_probe(struct i2c_client *client,
static int lm3692x_remove(struct i2c_client *client)
{
struct lm3692x_led *led = i2c_get_clientdata(client);
int ret;
ret = lm3692x_leds_disable(led);
if (ret)
return ret;
lm3692x_leds_disable(led);
mutex_destroy(&led->lock);
return 0;
......
......@@ -37,6 +37,7 @@
* bits the chip supports.
*/
#include <linux/bitops.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/err.h>
......@@ -118,6 +119,7 @@ struct pca955x {
struct pca955x_led *leds;
struct pca955x_chipdef *chipdef;
struct i2c_client *client;
unsigned long active_pins;
#ifdef CONFIG_LEDS_PCA955X_GPIO
struct gpio_chip gpio;
#endif
......@@ -360,12 +362,15 @@ static int pca955x_read_input(struct i2c_client *client, int n, u8 *val)
static int pca955x_gpio_request_pin(struct gpio_chip *gc, unsigned int offset)
{
struct pca955x *pca955x = gpiochip_get_data(gc);
struct pca955x_led *led = &pca955x->leds[offset];
if (led->type == PCA955X_TYPE_GPIO)
return 0;
return test_and_set_bit(offset, &pca955x->active_pins) ? -EBUSY : 0;
}
return -EBUSY;
static void pca955x_gpio_free_pin(struct gpio_chip *gc, unsigned int offset)
{
struct pca955x *pca955x = gpiochip_get_data(gc);
clear_bit(offset, &pca955x->active_pins);
}
static int pca955x_set_value(struct gpio_chip *gc, unsigned int offset,
......@@ -424,7 +429,7 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
int count;
count = device_get_child_node_count(&client->dev);
if (!count || count > chip->bits)
if (count > chip->bits)
return ERR_PTR(-ENODEV);
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
......@@ -489,7 +494,6 @@ static int pca955x_probe(struct i2c_client *client)
struct i2c_adapter *adapter;
int i, err;
struct pca955x_platform_data *pdata;
int ngpios = 0;
bool set_default_label = false;
bool keep_pwm = false;
char default_label[8];
......@@ -567,9 +571,7 @@ static int pca955x_probe(struct i2c_client *client)
switch (pca955x_led->type) {
case PCA955X_TYPE_NONE:
break;
case PCA955X_TYPE_GPIO:
ngpios++;
break;
case PCA955X_TYPE_LED:
led = &pca955x_led->led_cdev;
......@@ -613,6 +615,8 @@ static int pca955x_probe(struct i2c_client *client)
if (err)
return err;
set_bit(i, &pca955x->active_pins);
/*
* For default-state == "keep", let the core update the
* brightness from the hardware, then check the
......@@ -650,16 +654,16 @@ static int pca955x_probe(struct i2c_client *client)
return err;
#ifdef CONFIG_LEDS_PCA955X_GPIO
if (ngpios) {
pca955x->gpio.label = "gpio-pca955x";
pca955x->gpio.direction_input = pca955x_gpio_direction_input;
pca955x->gpio.direction_output = pca955x_gpio_direction_output;
pca955x->gpio.set = pca955x_gpio_set_value;
pca955x->gpio.get = pca955x_gpio_get_value;
pca955x->gpio.request = pca955x_gpio_request_pin;
pca955x->gpio.free = pca955x_gpio_free_pin;
pca955x->gpio.can_sleep = 1;
pca955x->gpio.base = -1;
pca955x->gpio.ngpio = ngpios;
pca955x->gpio.ngpio = chip->bits;
pca955x->gpio.parent = &client->dev;
pca955x->gpio.owner = THIS_MODULE;
......@@ -674,7 +678,6 @@ static int pca955x_probe(struct i2c_client *client)
dev_info(&client->dev, "gpios %i...%i\n",
pca955x->gpio.base, pca955x->gpio.base +
pca955x->gpio.ngpio - 1);
}
#endif
return 0;
......
......@@ -39,9 +39,9 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = {
};
/* the actual start will be discovered with PCI, 0 is a placeholder */
struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME);
static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME);
static void *simatic_ipc_led_memory;
static void __iomem *simatic_ipc_led_memory;
static struct simatic_ipc_led simatic_ipc_leds_mem[] = {
{0x500 + 0x1A0, "red:" LED_FUNCTION_STATUS "-1"},
......@@ -92,21 +92,22 @@ static void simatic_ipc_led_set_mem(struct led_classdev *led_cd,
enum led_brightness brightness)
{
struct simatic_ipc_led *led = cdev_to_led(led_cd);
void __iomem *reg = simatic_ipc_led_memory + led->value;
u32 val;
u32 *p;
p = simatic_ipc_led_memory + led->value;
*p = (*p & ~1) | (brightness == LED_OFF);
val = readl(reg);
val = (val & ~1) | (brightness == LED_OFF);
writel(val, reg);
}
static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd)
{
struct simatic_ipc_led *led = cdev_to_led(led_cd);
void __iomem *reg = simatic_ipc_led_memory + led->value;
u32 val;
u32 *p;
p = simatic_ipc_led_memory + led->value;
return (*p & 1) ? LED_OFF : led_cd->max_brightness;
val = readl(reg);
return (val & 1) ? LED_OFF : led_cd->max_brightness;
}
static int simatic_ipc_leds_probe(struct platform_device *pdev)
......@@ -116,8 +117,9 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
struct simatic_ipc_led *ipcled;
struct led_classdev *cdev;
struct resource *res;
void __iomem *reg;
int err, type;
u32 *p;
u32 val;
switch (plat->devmode) {
case SIMATIC_IPC_DEVICE_227D:
......@@ -157,11 +159,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev)
return PTR_ERR(simatic_ipc_led_memory);
/* initialize power/watchdog LED */
p = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */
*p = (*p & ~1);
p = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */
*p = (*p | 1);
reg = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */
val = readl(reg);
writel(val & ~1, reg);
reg = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */
val = readl(reg);
writel(val | 1, reg);
break;
default:
return -ENODEV;
......
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