All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] BCM6358 LED driver
@ 2015-05-19 17:12 Álvaro Fernández Rojas
  2015-05-19 17:12 ` [PATCH 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Álvaro Fernández Rojas @ 2015-05-19 17:12 UTC (permalink / raw
  To: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee,
	j.anaszewski
  Cc: Álvaro Fernández Rojas

These patches add support and documentation for the BCM6358 LED driver, which is present on BCM6358 and BCM6368.
In these SoCs there are Serial LEDs (LEDs connected to a 74hc controller), which can either be controlled by software (exporting the 74hc as spi-gpio) or hardware using this driver.

Álvaro Fernández Rojas (2):
  leds: add DT binding for BCM6358 LED controller
  leds: add BCM6358 LED driver

 .../devicetree/bindings/leds/leds-bcm6358.txt      | 145 +++++++++++++
 drivers/leds/Kconfig                               |   8 +
 drivers/leds/Makefile                              |   1 +
 drivers/leds/leds-bcm6358.c                        | 241 +++++++++++++++++++++
 4 files changed, 395 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm6358.txt
 create mode 100644 drivers/leds/leds-bcm6358.c

-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] leds: add DT binding for BCM6358 LED controller
  2015-05-19 17:12 [PATCH 0/2] BCM6358 LED driver Álvaro Fernández Rojas
@ 2015-05-19 17:12 ` Álvaro Fernández Rojas
  2015-05-21 11:01   ` Jacek Anaszewski
  2015-05-19 17:12 ` [PATCH 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
  2015-05-21 17:11 ` [PATCH v2 0/2] " Álvaro Fernández Rojas
  2 siblings, 1 reply; 12+ messages in thread
From: Álvaro Fernández Rojas @ 2015-05-19 17:12 UTC (permalink / raw
  To: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee,
	j.anaszewski
  Cc: Álvaro Fernández Rojas

This adds device tree binding documentation for the Broadcom BCM6358 LED controller.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 .../devicetree/bindings/leds/leds-bcm6358.txt      | 145 +++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm6358.txt

diff --git a/Documentation/devicetree/bindings/leds/leds-bcm6358.txt b/Documentation/devicetree/bindings/leds/leds-bcm6358.txt
new file mode 100644
index 0000000..b22a55b
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-bcm6358.txt
@@ -0,0 +1,145 @@
+LEDs connected to Broadcom BCM6358 controller
+
+This controller is present on BCM6358 and BCM6368.
+In these SoCs there are Serial LEDs (LEDs connected to a 74x164 controller),
+which can either be controlled by software (exporting the 74x164 as spi-gpio.
+See Documentation/devicetree/bindings/gpio/gpio-74x164.txt), or
+by hardware using this driver.
+
+Required properties:
+  - compatible : should be "brcm,bcm6358-leds".
+  - #address-cells : must be 1.
+  - #size-cells : must be 0.
+  - reg : BCM6358 LED controller address and size.
+
+Optional properties:
+  - brcm,clk-div : SCK signal divider. Possible values are 1, 2, 4 and 8.
+    Default : 1
+  - brcm,clk-dat-low : Boolean, makes clock and data signals active low.
+    Default : false
+
+Each LED is represented as a sub-node of the brcm,bcm6358-leds device.
+
+LED sub-node required properties:
+  - reg : LED pin number (only LEDs 0 to 31 are valid).
+
+LED sub-node optional properties:
+  - label : see Documentation/devicetree/bindings/leds/common.txt
+  - active-low : Boolean, makes LED active low.
+    Default : false
+  - default-state : see
+    Documentation/devicetree/bindings/leds/leds-gpio.txt
+  - linux,default-trigger : see
+    Documentation/devicetree/bindings/leds/common.txt
+
+Examples:
+Scenario 1 : BCM6358
+	leds0: led-controller@fffe00d0 {
+		compatible = "brcm,bcm6358-leds";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xfffe00d0 0x8>;
+
+		alarm_white {
+			reg = <0>;
+			active-low;
+			label = "white:alarm";
+		};
+		tv_white {
+			reg = <2>;
+			active-low;
+			label = "white:tv";
+		};
+		tel_white {
+			reg = <3>;
+			active-low;
+			label = "white:tel";
+		};
+		adsl_white {
+			reg = <4>;
+			active-low;
+			label = "white:adsl";
+		};
+	};
+
+Scenario 2 : BCM6368
+	leds0: led-controller@100000d0 {
+		compatible = "brcm,bcm6358-leds";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x100000d0 0x8>;
+		brcm,pol-low;
+		brcm,clk-div = <4>;
+
+		power_red {
+			reg = <0>;
+			active-low;
+			label = "red:power";
+		};
+		power_green {
+			reg = <1>;
+			active-low;
+			label = "green:power";
+			default-state = "on";
+		};
+		power_blue {
+			reg = <2>;
+			label = "blue:power";
+		};
+		broadband_red {
+			reg = <3>;
+			active-low;
+			label = "red:broadband";
+		};
+		broadband_green {
+			reg = <4>;
+			label = "green:broadband";
+		};
+		broadband_blue {
+			reg = <5>;
+			active-low;
+			label = "blue:broadband";
+		};
+		wireless_red {
+			reg = <6>;
+			active-low;
+			label = "red:wireless";
+		};
+		wireless_green {
+			reg = <7>;
+			active-low;
+			label = "green:wireless";
+		};
+		wireless_blue {
+			reg = <8>;
+			label = "blue:wireless";
+		};
+		phone_red {
+			reg = <9>;
+			active-low;
+			label = "red:phone";
+		};
+		phone_green {
+			reg = <10>;
+			active-low;
+			label = "green:phone";
+		};
+		phone_blue {
+			reg = <11>;
+			label = "blue:phone";
+		};
+		upgrading_red {
+			reg = <12>;
+			active-low;
+			label = "red:upgrading";
+		};
+		upgrading_green {
+			reg = <13>;
+			active-low;
+			label = "green:upgrading";
+		};
+		upgrading_blue {
+			reg = <14>;
+			label = "blue:upgrading";
+		};
+	};
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] leds: add BCM6358 LED driver
  2015-05-19 17:12 [PATCH 0/2] BCM6358 LED driver Álvaro Fernández Rojas
  2015-05-19 17:12 ` [PATCH 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
@ 2015-05-19 17:12 ` Álvaro Fernández Rojas
  2015-05-21 10:58   ` Jacek Anaszewski
  2015-05-21 17:11 ` [PATCH v2 0/2] " Álvaro Fernández Rojas
  2 siblings, 1 reply; 12+ messages in thread
From: Álvaro Fernández Rojas @ 2015-05-19 17:12 UTC (permalink / raw
  To: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee,
	j.anaszewski
  Cc: Álvaro Fernández Rojas

This adds support for the LED controller on Broadcom's BCM6358.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/leds/Kconfig        |   8 ++
 drivers/leds/Makefile       |   1 +
 drivers/leds/leds-bcm6358.c | 241 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 250 insertions(+)
 create mode 100644 drivers/leds/leds-bcm6358.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index ec26dd1..86de046 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -58,6 +58,14 @@ config LEDS_BCM6328
 	  This option enables support for LEDs connected to the BCM6328
 	  LED HW controller accessed via MMIO registers.
 
+config LEDS_BCM6358
+	tristate "LED Support for Broadcom BCM6358"
+	depends on LEDS_CLASS
+	depends on OF
+	help
+	  This option enables support for LEDs connected to the BCM6358
+	  LED HW controller accessed via MMIO registers.
+
 config LEDS_LM3530
 	tristate "LCD Backlight driver for LM3530"
 	depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index edb3abf..8d6a24a 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
 obj-$(CONFIG_LEDS_AAT1290)		+= leds-aat1290.o
 obj-$(CONFIG_LEDS_BCM6328)		+= leds-bcm6328.o
+obj-$(CONFIG_LEDS_BCM6358)		+= leds-bcm6358.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
new file mode 100644
index 0000000..4a3a6c3
--- /dev/null
+++ b/drivers/leds/leds-bcm6358.c
@@ -0,0 +1,241 @@
+/*
+ * Driver for BCM6358 memory-mapped LEDs, based on leds-syscon.c
+ *
+ * Copyright 2015 Álvaro Fernández Rojas <noltari@gmail.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/spinlock.h>
+
+#define BCM6358_REG_MODE		0x0
+#define BCM6358_REG_CTRL		0x4
+
+#define BCM6358_SLED_CLKDIV_MASK	3
+#define BCM6358_SLED_CLKDIV_1		0
+#define BCM6358_SLED_CLKDIV_2		1
+#define BCM6358_SLED_CLKDIV_4		2
+#define BCM6358_SLED_CLKDIV_8		3
+
+#define BCM6358_SLED_POLARITY		BIT(2)
+#define BCM6358_SLED_BUSY		BIT(3)
+
+#define BCM6358_SLED_MAX_COUNT		32
+#define BCM6358_SLED_WAIT		100
+
+/**
+ * struct bcm6358_led - state container for bcm6358 based LEDs
+ * @cdev: LED class device for this LED
+ * @mem: memory resource
+ * @lock: memory lock
+ * @pin: LED pin number
+ * @active_low: LED is active low
+ */
+struct bcm6358_led {
+	struct led_classdev cdev;
+	void __iomem *mem;
+	spinlock_t *lock;
+	unsigned long pin;
+	bool active_low;
+};
+
+static void bcm6358_led_write(void __iomem *reg, unsigned long data)
+{
+	iowrite32be(data, reg);
+}
+
+static unsigned long bcm6358_led_read(void __iomem *reg)
+{
+	return ioread32be(reg);
+}
+
+static unsigned long bcm6358_led_busy(void __iomem *mem)
+{
+	unsigned long val;
+
+	while ((val = bcm6358_led_read(mem + BCM6358_REG_CTRL)) &
+		BCM6358_SLED_BUSY)
+		udelay(BCM6358_SLED_WAIT);
+
+	return val;
+}
+
+static void bcm6358_led_mode(struct bcm6358_led *led, unsigned long value)
+{
+	unsigned long val;
+
+	bcm6358_led_busy(led->mem);
+
+	val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
+	if ((led->active_low && value == LED_OFF) ||
+	    (!led->active_low && value != LED_OFF))
+		val |= BIT(led->pin);
+	else
+		val &= ~(BIT(led->pin));
+	bcm6358_led_write(led->mem + BCM6358_REG_MODE, val);
+}
+
+static void bcm6358_led_set(struct led_classdev *led_cdev,
+			    enum led_brightness value)
+{
+	struct bcm6358_led *led =
+		container_of(led_cdev, struct bcm6358_led, cdev);
+	unsigned long flags;
+
+	spin_lock_irqsave(led->lock, flags);
+	bcm6358_led_mode(led, value);
+	spin_unlock_irqrestore(led->lock, flags);
+}
+
+static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
+		       void __iomem *mem, spinlock_t *lock)
+{
+	struct bcm6358_led *led;
+	unsigned long flags;
+	const char *state;
+	int rc;
+
+	led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
+	if (!led)
+		return -ENOMEM;
+
+	led->pin = reg;
+	led->mem = mem;
+	led->lock = lock;
+
+	if (of_property_read_bool(nc, "active-low"))
+		led->active_low = true;
+
+	led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name;
+	led->cdev.default_trigger = of_get_property(nc,
+						    "linux,default-trigger",
+						    NULL);
+
+	spin_lock_irqsave(lock, flags);
+	if (!of_property_read_string(nc, "default-state", &state))
+		if (!strcmp(state, "on"))
+			led->cdev.brightness = LED_FULL;
+		else if (!strcmp(state, "keep")) {
+			unsigned long val;
+
+			bcm6358_led_busy(led->mem);
+
+			val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
+			val &= BIT(led->pin);
+			if ((led->active_low && !val) ||
+				(!led->active_low && val))
+				led->cdev.brightness = LED_FULL;
+			else
+				led->cdev.brightness = LED_OFF;
+		} else
+			led->cdev.brightness = LED_OFF;
+	else
+		led->cdev.brightness = LED_OFF;
+	bcm6358_led_mode(led, led->cdev.brightness);
+	spin_unlock_irqrestore(lock, flags);
+
+	led->cdev.brightness_set = bcm6358_led_set;
+
+	rc = led_classdev_register(dev, &led->cdev);
+	if (rc < 0)
+		return rc;
+
+	dev_dbg(dev, "registered LED %s\n", led->cdev.name);
+
+	return 0;
+}
+
+static int bcm6358_leds_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *child;
+	struct resource *mem_r;
+	void __iomem *mem;
+	spinlock_t *lock;
+	unsigned long val;
+	u32 clk_div;
+
+	mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem_r)
+		return -EINVAL;
+
+	mem = devm_ioremap_resource(dev, mem_r);
+	if (IS_ERR(mem))
+		return PTR_ERR(mem);
+
+	lock = devm_kzalloc(dev, sizeof(*lock), GFP_KERNEL);
+	if (!lock)
+		return -ENOMEM;
+
+	spin_lock_init(lock);
+
+	val = bcm6358_led_busy(mem);
+	val &= ~(BCM6358_SLED_POLARITY | BCM6358_SLED_CLKDIV_MASK);
+	if (of_property_read_bool(np, "brcm,clk-dat-low"))
+		val |= BCM6358_SLED_POLARITY;
+	of_property_read_u32(child, "brcm,clk-div", &clk_div);
+	switch (clk_div) {
+	case 8:
+		val |= BCM6358_SLED_CLKDIV_8;
+		break;
+	case 4:
+		val |= BCM6358_SLED_CLKDIV_4;
+		break;
+	case 2:
+		val |= BCM6358_SLED_CLKDIV_2;
+		break;
+	default:
+		val |= BCM6358_SLED_CLKDIV_1;
+		break;
+	}
+	bcm6358_led_write(mem + BCM6358_REG_CTRL, val);
+
+	for_each_available_child_of_node(np, child) {
+		int rc;
+		u32 reg;
+
+		if (of_property_read_u32(child, "reg", &reg))
+			continue;
+
+		if (reg >= BCM6358_SLED_MAX_COUNT) {
+			dev_err(dev, "invalid LED (%u >= %d)\n", reg,
+				BCM6358_SLED_MAX_COUNT);
+			continue;
+		}
+
+		rc = bcm6358_led(dev, child, reg, mem, lock);
+		if (rc < 0)
+			return rc;
+	}
+
+	return 0;
+}
+
+static const struct of_device_id bcm6358_leds_of_match[] = {
+	{ .compatible = "brcm,bcm6358-leds", },
+	{ },
+};
+
+static struct platform_driver bcm6358_leds_driver = {
+	.probe = bcm6358_leds_probe,
+	.driver = {
+		.name = "leds-bcm6358",
+		.of_match_table = bcm6358_leds_of_match,
+	},
+};
+
+module_platform_driver(bcm6358_leds_driver);
+
+MODULE_AUTHOR("Álvaro Fernández Rojas <noltari@gmail.com>");
+MODULE_DESCRIPTION("LED driver for BCM6358 controllers");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:leds-bcm6358");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] leds: add BCM6358 LED driver
  2015-05-19 17:12 ` [PATCH 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
@ 2015-05-21 10:58   ` Jacek Anaszewski
  0 siblings, 0 replies; 12+ messages in thread
From: Jacek Anaszewski @ 2015-05-21 10:58 UTC (permalink / raw
  To: Álvaro Fernández Rojas
  Cc: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee

Hi Alvaro,

Please fix the issues reported by checkpatch --strict.
Besides I have one comment below.

On 05/19/2015 07:12 PM, Álvaro Fernández Rojas wrote:
> This adds support for the LED controller on Broadcom's BCM6358.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>   drivers/leds/Kconfig        |   8 ++
>   drivers/leds/Makefile       |   1 +
>   drivers/leds/leds-bcm6358.c | 241 ++++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 250 insertions(+)
>   create mode 100644 drivers/leds/leds-bcm6358.c
>
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index ec26dd1..86de046 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -58,6 +58,14 @@ config LEDS_BCM6328
>   	  This option enables support for LEDs connected to the BCM6328
>   	  LED HW controller accessed via MMIO registers.
>
> +config LEDS_BCM6358
> +	tristate "LED Support for Broadcom BCM6358"
> +	depends on LEDS_CLASS
> +	depends on OF
> +	help
> +	  This option enables support for LEDs connected to the BCM6358
> +	  LED HW controller accessed via MMIO registers.
> +
>   config LEDS_LM3530
>   	tristate "LCD Backlight driver for LM3530"
>   	depends on LEDS_CLASS
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index edb3abf..8d6a24a 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -9,6 +9,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
>   obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
>   obj-$(CONFIG_LEDS_AAT1290)		+= leds-aat1290.o
>   obj-$(CONFIG_LEDS_BCM6328)		+= leds-bcm6328.o
> +obj-$(CONFIG_LEDS_BCM6358)		+= leds-bcm6358.o
>   obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
>   obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
>   obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
> diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
> new file mode 100644
> index 0000000..4a3a6c3
> --- /dev/null
> +++ b/drivers/leds/leds-bcm6358.c
> @@ -0,0 +1,241 @@
> +/*
> + * Driver for BCM6358 memory-mapped LEDs, based on leds-syscon.c
> + *
> + * Copyright 2015 Álvaro Fernández Rojas <noltari@gmail.com>
> + *
> + * This program is free software; you can redistribute  it and/or modify it
> + * under  the terms of  the GNU General  Public License as published by the
> + * Free Software Foundation;  either version 2 of the  License, or (at your
> + * option) any later version.
> + */
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/leds.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/spinlock.h>
> +
> +#define BCM6358_REG_MODE		0x0
> +#define BCM6358_REG_CTRL		0x4
> +
> +#define BCM6358_SLED_CLKDIV_MASK	3
> +#define BCM6358_SLED_CLKDIV_1		0
> +#define BCM6358_SLED_CLKDIV_2		1
> +#define BCM6358_SLED_CLKDIV_4		2
> +#define BCM6358_SLED_CLKDIV_8		3
> +
> +#define BCM6358_SLED_POLARITY		BIT(2)
> +#define BCM6358_SLED_BUSY		BIT(3)
> +
> +#define BCM6358_SLED_MAX_COUNT		32
> +#define BCM6358_SLED_WAIT		100
> +
> +/**
> + * struct bcm6358_led - state container for bcm6358 based LEDs
> + * @cdev: LED class device for this LED
> + * @mem: memory resource
> + * @lock: memory lock
> + * @pin: LED pin number
> + * @active_low: LED is active low
> + */
> +struct bcm6358_led {
> +	struct led_classdev cdev;
> +	void __iomem *mem;
> +	spinlock_t *lock;
> +	unsigned long pin;
> +	bool active_low;
> +};
> +
> +static void bcm6358_led_write(void __iomem *reg, unsigned long data)
> +{
> +	iowrite32be(data, reg);
> +}
> +
> +static unsigned long bcm6358_led_read(void __iomem *reg)
> +{
> +	return ioread32be(reg);
> +}
> +
> +static unsigned long bcm6358_led_busy(void __iomem *mem)
> +{
> +	unsigned long val;
> +
> +	while ((val = bcm6358_led_read(mem + BCM6358_REG_CTRL)) &
> +		BCM6358_SLED_BUSY)
> +		udelay(BCM6358_SLED_WAIT);
> +
> +	return val;
> +}
> +
> +static void bcm6358_led_mode(struct bcm6358_led *led, unsigned long value)
> +{
> +	unsigned long val;
> +
> +	bcm6358_led_busy(led->mem);
> +
> +	val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
> +	if ((led->active_low && value == LED_OFF) ||
> +	    (!led->active_low && value != LED_OFF))
> +		val |= BIT(led->pin);
> +	else
> +		val &= ~(BIT(led->pin));
> +	bcm6358_led_write(led->mem + BCM6358_REG_MODE, val);
> +}
> +
> +static void bcm6358_led_set(struct led_classdev *led_cdev,
> +			    enum led_brightness value)
> +{
> +	struct bcm6358_led *led =
> +		container_of(led_cdev, struct bcm6358_led, cdev);
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(led->lock, flags);
> +	bcm6358_led_mode(led, value);
> +	spin_unlock_irqrestore(led->lock, flags);
> +}
> +
> +static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
> +		       void __iomem *mem, spinlock_t *lock)
> +{
> +	struct bcm6358_led *led;
> +	unsigned long flags;
> +	const char *state;
> +	int rc;
> +
> +	led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
> +	if (!led)
> +		return -ENOMEM;
> +
> +	led->pin = reg;
> +	led->mem = mem;
> +	led->lock = lock;
> +
> +	if (of_property_read_bool(nc, "active-low"))
> +		led->active_low = true;
> +
> +	led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name;
> +	led->cdev.default_trigger = of_get_property(nc,
> +						    "linux,default-trigger",
> +						    NULL);
> +
> +	spin_lock_irqsave(lock, flags);
> +	if (!of_property_read_string(nc, "default-state", &state))
> +		if (!strcmp(state, "on"))
> +			led->cdev.brightness = LED_FULL;
> +		else if (!strcmp(state, "keep")) {
> +			unsigned long val;
> +
> +			bcm6358_led_busy(led->mem);
> +
> +			val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
> +			val &= BIT(led->pin);
> +			if ((led->active_low && !val) ||
> +				(!led->active_low && val))
> +				led->cdev.brightness = LED_FULL;
> +			else
> +				led->cdev.brightness = LED_OFF;
> +		} else
> +			led->cdev.brightness = LED_OFF;
> +	else
> +		led->cdev.brightness = LED_OFF;
> +	bcm6358_led_mode(led, led->cdev.brightness);
> +	spin_unlock_irqrestore(lock, flags);
> +
> +	led->cdev.brightness_set = bcm6358_led_set;
> +
> +	rc = led_classdev_register(dev, &led->cdev);
> +	if (rc < 0)
> +		return rc;
> +
> +	dev_dbg(dev, "registered LED %s\n", led->cdev.name);
> +
> +	return 0;
> +}
> +
> +static int bcm6358_leds_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *child;
> +	struct resource *mem_r;
> +	void __iomem *mem;
> +	spinlock_t *lock;
> +	unsigned long val;
> +	u32 clk_div;
> +
> +	mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!mem_r)
> +		return -EINVAL;
> +
> +	mem = devm_ioremap_resource(dev, mem_r);
> +	if (IS_ERR(mem))
> +		return PTR_ERR(mem);
> +
> +	lock = devm_kzalloc(dev, sizeof(*lock), GFP_KERNEL);
> +	if (!lock)
> +		return -ENOMEM;
> +
> +	spin_lock_init(lock);
> +
> +	val = bcm6358_led_busy(mem);
> +	val &= ~(BCM6358_SLED_POLARITY | BCM6358_SLED_CLKDIV_MASK);
> +	if (of_property_read_bool(np, "brcm,clk-dat-low"))
> +		val |= BCM6358_SLED_POLARITY;
> +	of_property_read_u32(child, "brcm,clk-div", &clk_div);

child is uninitialized here

> +	switch (clk_div) {
> +	case 8:
> +		val |= BCM6358_SLED_CLKDIV_8;
> +		break;
> +	case 4:
> +		val |= BCM6358_SLED_CLKDIV_4;
> +		break;
> +	case 2:
> +		val |= BCM6358_SLED_CLKDIV_2;
> +		break;
> +	default:
> +		val |= BCM6358_SLED_CLKDIV_1;
> +		break;
> +	}
> +	bcm6358_led_write(mem + BCM6358_REG_CTRL, val);
> +
> +	for_each_available_child_of_node(np, child) {
> +		int rc;
> +		u32 reg;
> +
> +		if (of_property_read_u32(child, "reg", &reg))
> +			continue;
> +
> +		if (reg >= BCM6358_SLED_MAX_COUNT) {
> +			dev_err(dev, "invalid LED (%u >= %d)\n", reg,
> +				BCM6358_SLED_MAX_COUNT);
> +			continue;
> +		}
> +
> +		rc = bcm6358_led(dev, child, reg, mem, lock);
> +		if (rc < 0)
> +			return rc;
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id bcm6358_leds_of_match[] = {
> +	{ .compatible = "brcm,bcm6358-leds", },
> +	{ },
> +};
> +
> +static struct platform_driver bcm6358_leds_driver = {
> +	.probe = bcm6358_leds_probe,
> +	.driver = {
> +		.name = "leds-bcm6358",
> +		.of_match_table = bcm6358_leds_of_match,
> +	},
> +};
> +
> +module_platform_driver(bcm6358_leds_driver);
> +
> +MODULE_AUTHOR("Álvaro Fernández Rojas <noltari@gmail.com>");
> +MODULE_DESCRIPTION("LED driver for BCM6358 controllers");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:leds-bcm6358");
>


-- 
Best Regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] leds: add DT binding for BCM6358 LED controller
  2015-05-19 17:12 ` [PATCH 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
@ 2015-05-21 11:01   ` Jacek Anaszewski
  0 siblings, 0 replies; 12+ messages in thread
From: Jacek Anaszewski @ 2015-05-21 11:01 UTC (permalink / raw
  To: Álvaro Fernández Rojas
  Cc: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee

Hi Alvaro,

On 05/19/2015 07:12 PM, Álvaro Fernández Rojas wrote:
> This adds device tree binding documentation for the Broadcom BCM6358 LED controller.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>   .../devicetree/bindings/leds/leds-bcm6358.txt      | 145 +++++++++++++++++++++
>   1 file changed, 145 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm6358.txt

Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>

-- 
Best Regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 0/2] BCM6358 LED driver
  2015-05-19 17:12 [PATCH 0/2] BCM6358 LED driver Álvaro Fernández Rojas
  2015-05-19 17:12 ` [PATCH 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
  2015-05-19 17:12 ` [PATCH 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
@ 2015-05-21 17:11 ` Álvaro Fernández Rojas
  2015-05-21 17:11   ` [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
  2015-05-21 17:11   ` [PATCH v2 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
  2 siblings, 2 replies; 12+ messages in thread
From: Álvaro Fernández Rojas @ 2015-05-21 17:11 UTC (permalink / raw
  To: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee,
	j.anaszewski
  Cc: Álvaro Fernández Rojas

These patches add support and documentation for the BCM6358 LED driver, which is present on BCM6358 and BCM6368.
In these SoCs there are Serial LEDs (LEDs connected to a 74hc controller), which can either be controlled by software (exporting the 74hc as spi-gpio) or hardware using this driver.

v1->v2: Introduce changes suggested by Jacek.

Álvaro Fernández Rojas (2):
  leds: add DT binding for BCM6358 LED controller
  leds: add BCM6358 LED driver

 .../devicetree/bindings/leds/leds-bcm6358.txt      | 145 ++++++++++++
 drivers/leds/Kconfig                               |   8 +
 drivers/leds/Makefile                              |   1 +
 drivers/leds/leds-bcm6358.c                        | 243 +++++++++++++++++++++
 4 files changed, 397 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm6358.txt
 create mode 100644 drivers/leds/leds-bcm6358.c

-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller
  2015-05-21 17:11 ` [PATCH v2 0/2] " Álvaro Fernández Rojas
@ 2015-05-21 17:11   ` Álvaro Fernández Rojas
  2015-05-22 15:08     ` Jacek Anaszewski
  2015-05-21 17:11   ` [PATCH v2 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
  1 sibling, 1 reply; 12+ messages in thread
From: Álvaro Fernández Rojas @ 2015-05-21 17:11 UTC (permalink / raw
  To: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee,
	j.anaszewski
  Cc: Álvaro Fernández Rojas

This adds device tree binding documentation for the Broadcom BCM6358 LED controller.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: resend, no changes.

 .../devicetree/bindings/leds/leds-bcm6358.txt      | 145 +++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm6358.txt

diff --git a/Documentation/devicetree/bindings/leds/leds-bcm6358.txt b/Documentation/devicetree/bindings/leds/leds-bcm6358.txt
new file mode 100644
index 0000000..b22a55b
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-bcm6358.txt
@@ -0,0 +1,145 @@
+LEDs connected to Broadcom BCM6358 controller
+
+This controller is present on BCM6358 and BCM6368.
+In these SoCs there are Serial LEDs (LEDs connected to a 74x164 controller),
+which can either be controlled by software (exporting the 74x164 as spi-gpio.
+See Documentation/devicetree/bindings/gpio/gpio-74x164.txt), or
+by hardware using this driver.
+
+Required properties:
+  - compatible : should be "brcm,bcm6358-leds".
+  - #address-cells : must be 1.
+  - #size-cells : must be 0.
+  - reg : BCM6358 LED controller address and size.
+
+Optional properties:
+  - brcm,clk-div : SCK signal divider. Possible values are 1, 2, 4 and 8.
+    Default : 1
+  - brcm,clk-dat-low : Boolean, makes clock and data signals active low.
+    Default : false
+
+Each LED is represented as a sub-node of the brcm,bcm6358-leds device.
+
+LED sub-node required properties:
+  - reg : LED pin number (only LEDs 0 to 31 are valid).
+
+LED sub-node optional properties:
+  - label : see Documentation/devicetree/bindings/leds/common.txt
+  - active-low : Boolean, makes LED active low.
+    Default : false
+  - default-state : see
+    Documentation/devicetree/bindings/leds/leds-gpio.txt
+  - linux,default-trigger : see
+    Documentation/devicetree/bindings/leds/common.txt
+
+Examples:
+Scenario 1 : BCM6358
+	leds0: led-controller@fffe00d0 {
+		compatible = "brcm,bcm6358-leds";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xfffe00d0 0x8>;
+
+		alarm_white {
+			reg = <0>;
+			active-low;
+			label = "white:alarm";
+		};
+		tv_white {
+			reg = <2>;
+			active-low;
+			label = "white:tv";
+		};
+		tel_white {
+			reg = <3>;
+			active-low;
+			label = "white:tel";
+		};
+		adsl_white {
+			reg = <4>;
+			active-low;
+			label = "white:adsl";
+		};
+	};
+
+Scenario 2 : BCM6368
+	leds0: led-controller@100000d0 {
+		compatible = "brcm,bcm6358-leds";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0x100000d0 0x8>;
+		brcm,pol-low;
+		brcm,clk-div = <4>;
+
+		power_red {
+			reg = <0>;
+			active-low;
+			label = "red:power";
+		};
+		power_green {
+			reg = <1>;
+			active-low;
+			label = "green:power";
+			default-state = "on";
+		};
+		power_blue {
+			reg = <2>;
+			label = "blue:power";
+		};
+		broadband_red {
+			reg = <3>;
+			active-low;
+			label = "red:broadband";
+		};
+		broadband_green {
+			reg = <4>;
+			label = "green:broadband";
+		};
+		broadband_blue {
+			reg = <5>;
+			active-low;
+			label = "blue:broadband";
+		};
+		wireless_red {
+			reg = <6>;
+			active-low;
+			label = "red:wireless";
+		};
+		wireless_green {
+			reg = <7>;
+			active-low;
+			label = "green:wireless";
+		};
+		wireless_blue {
+			reg = <8>;
+			label = "blue:wireless";
+		};
+		phone_red {
+			reg = <9>;
+			active-low;
+			label = "red:phone";
+		};
+		phone_green {
+			reg = <10>;
+			active-low;
+			label = "green:phone";
+		};
+		phone_blue {
+			reg = <11>;
+			label = "blue:phone";
+		};
+		upgrading_red {
+			reg = <12>;
+			active-low;
+			label = "red:upgrading";
+		};
+		upgrading_green {
+			reg = <13>;
+			active-low;
+			label = "green:upgrading";
+		};
+		upgrading_blue {
+			reg = <14>;
+			label = "blue:upgrading";
+		};
+	};
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] leds: add BCM6358 LED driver
  2015-05-21 17:11 ` [PATCH v2 0/2] " Álvaro Fernández Rojas
  2015-05-21 17:11   ` [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
@ 2015-05-21 17:11   ` Álvaro Fernández Rojas
  2015-05-22 15:10     ` Jacek Anaszewski
  1 sibling, 1 reply; 12+ messages in thread
From: Álvaro Fernández Rojas @ 2015-05-21 17:11 UTC (permalink / raw
  To: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee,
	j.anaszewski
  Cc: Álvaro Fernández Rojas

This adds support for the LED controller on Broadcom's BCM6358.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: introduce changes suggested by Jacek
 - Use correct device_node when getting brcm,clk-div property.
 - Code style fixes suggested by "checkpatch --strict".

 drivers/leds/Kconfig        |   8 ++
 drivers/leds/Makefile       |   1 +
 drivers/leds/leds-bcm6358.c | 243 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 252 insertions(+)
 create mode 100644 drivers/leds/leds-bcm6358.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index ec26dd1..86de046 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -58,6 +58,14 @@ config LEDS_BCM6328
 	  This option enables support for LEDs connected to the BCM6328
 	  LED HW controller accessed via MMIO registers.
 
+config LEDS_BCM6358
+	tristate "LED Support for Broadcom BCM6358"
+	depends on LEDS_CLASS
+	depends on OF
+	help
+	  This option enables support for LEDs connected to the BCM6358
+	  LED HW controller accessed via MMIO registers.
+
 config LEDS_LM3530
 	tristate "LCD Backlight driver for LM3530"
 	depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index edb3abf..8d6a24a 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
 obj-$(CONFIG_LEDS_AAT1290)		+= leds-aat1290.o
 obj-$(CONFIG_LEDS_BCM6328)		+= leds-bcm6328.o
+obj-$(CONFIG_LEDS_BCM6358)		+= leds-bcm6358.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
new file mode 100644
index 0000000..21f9693
--- /dev/null
+++ b/drivers/leds/leds-bcm6358.c
@@ -0,0 +1,243 @@
+/*
+ * Driver for BCM6358 memory-mapped LEDs, based on leds-syscon.c
+ *
+ * Copyright 2015 Álvaro Fernández Rojas <noltari@gmail.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/spinlock.h>
+
+#define BCM6358_REG_MODE		0x0
+#define BCM6358_REG_CTRL		0x4
+
+#define BCM6358_SLED_CLKDIV_MASK	3
+#define BCM6358_SLED_CLKDIV_1		0
+#define BCM6358_SLED_CLKDIV_2		1
+#define BCM6358_SLED_CLKDIV_4		2
+#define BCM6358_SLED_CLKDIV_8		3
+
+#define BCM6358_SLED_POLARITY		BIT(2)
+#define BCM6358_SLED_BUSY		BIT(3)
+
+#define BCM6358_SLED_MAX_COUNT		32
+#define BCM6358_SLED_WAIT		100
+
+/**
+ * struct bcm6358_led - state container for bcm6358 based LEDs
+ * @cdev: LED class device for this LED
+ * @mem: memory resource
+ * @lock: memory lock
+ * @pin: LED pin number
+ * @active_low: LED is active low
+ */
+struct bcm6358_led {
+	struct led_classdev cdev;
+	void __iomem *mem;
+	spinlock_t *lock;
+	unsigned long pin;
+	bool active_low;
+};
+
+static void bcm6358_led_write(void __iomem *reg, unsigned long data)
+{
+	iowrite32be(data, reg);
+}
+
+static unsigned long bcm6358_led_read(void __iomem *reg)
+{
+	return ioread32be(reg);
+}
+
+static unsigned long bcm6358_led_busy(void __iomem *mem)
+{
+	unsigned long val;
+
+	while ((val = bcm6358_led_read(mem + BCM6358_REG_CTRL)) &
+		BCM6358_SLED_BUSY)
+		udelay(BCM6358_SLED_WAIT);
+
+	return val;
+}
+
+static void bcm6358_led_mode(struct bcm6358_led *led, unsigned long value)
+{
+	unsigned long val;
+
+	bcm6358_led_busy(led->mem);
+
+	val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
+	if ((led->active_low && value == LED_OFF) ||
+	    (!led->active_low && value != LED_OFF))
+		val |= BIT(led->pin);
+	else
+		val &= ~(BIT(led->pin));
+	bcm6358_led_write(led->mem + BCM6358_REG_MODE, val);
+}
+
+static void bcm6358_led_set(struct led_classdev *led_cdev,
+			    enum led_brightness value)
+{
+	struct bcm6358_led *led =
+		container_of(led_cdev, struct bcm6358_led, cdev);
+	unsigned long flags;
+
+	spin_lock_irqsave(led->lock, flags);
+	bcm6358_led_mode(led, value);
+	spin_unlock_irqrestore(led->lock, flags);
+}
+
+static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
+		       void __iomem *mem, spinlock_t *lock)
+{
+	struct bcm6358_led *led;
+	unsigned long flags;
+	const char *state;
+	int rc;
+
+	led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
+	if (!led)
+		return -ENOMEM;
+
+	led->pin = reg;
+	led->mem = mem;
+	led->lock = lock;
+
+	if (of_property_read_bool(nc, "active-low"))
+		led->active_low = true;
+
+	led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name;
+	led->cdev.default_trigger = of_get_property(nc,
+						    "linux,default-trigger",
+						    NULL);
+
+	spin_lock_irqsave(lock, flags);
+	if (!of_property_read_string(nc, "default-state", &state)) {
+		if (!strcmp(state, "on")) {
+			led->cdev.brightness = LED_FULL;
+		} else if (!strcmp(state, "keep")) {
+			unsigned long val;
+
+			bcm6358_led_busy(led->mem);
+
+			val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
+			val &= BIT(led->pin);
+			if ((led->active_low && !val) ||
+			    (!led->active_low && val))
+				led->cdev.brightness = LED_FULL;
+			else
+				led->cdev.brightness = LED_OFF;
+		} else {
+			led->cdev.brightness = LED_OFF;
+		}
+	} else {
+		led->cdev.brightness = LED_OFF;
+	}
+	bcm6358_led_mode(led, led->cdev.brightness);
+	spin_unlock_irqrestore(lock, flags);
+
+	led->cdev.brightness_set = bcm6358_led_set;
+
+	rc = led_classdev_register(dev, &led->cdev);
+	if (rc < 0)
+		return rc;
+
+	dev_dbg(dev, "registered LED %s\n", led->cdev.name);
+
+	return 0;
+}
+
+static int bcm6358_leds_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = pdev->dev.of_node;
+	struct device_node *child;
+	struct resource *mem_r;
+	void __iomem *mem;
+	spinlock_t *lock; /* memory lock */
+	unsigned long val;
+	u32 clk_div;
+
+	mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!mem_r)
+		return -EINVAL;
+
+	mem = devm_ioremap_resource(dev, mem_r);
+	if (IS_ERR(mem))
+		return PTR_ERR(mem);
+
+	lock = devm_kzalloc(dev, sizeof(*lock), GFP_KERNEL);
+	if (!lock)
+		return -ENOMEM;
+
+	spin_lock_init(lock);
+
+	val = bcm6358_led_busy(mem);
+	val &= ~(BCM6358_SLED_POLARITY | BCM6358_SLED_CLKDIV_MASK);
+	if (of_property_read_bool(np, "brcm,clk-dat-low"))
+		val |= BCM6358_SLED_POLARITY;
+	of_property_read_u32(np, "brcm,clk-div", &clk_div);
+	switch (clk_div) {
+	case 8:
+		val |= BCM6358_SLED_CLKDIV_8;
+		break;
+	case 4:
+		val |= BCM6358_SLED_CLKDIV_4;
+		break;
+	case 2:
+		val |= BCM6358_SLED_CLKDIV_2;
+		break;
+	default:
+		val |= BCM6358_SLED_CLKDIV_1;
+		break;
+	}
+	bcm6358_led_write(mem + BCM6358_REG_CTRL, val);
+
+	for_each_available_child_of_node(np, child) {
+		int rc;
+		u32 reg;
+
+		if (of_property_read_u32(child, "reg", &reg))
+			continue;
+
+		if (reg >= BCM6358_SLED_MAX_COUNT) {
+			dev_err(dev, "invalid LED (%u >= %d)\n", reg,
+				BCM6358_SLED_MAX_COUNT);
+			continue;
+		}
+
+		rc = bcm6358_led(dev, child, reg, mem, lock);
+		if (rc < 0)
+			return rc;
+	}
+
+	return 0;
+}
+
+static const struct of_device_id bcm6358_leds_of_match[] = {
+	{ .compatible = "brcm,bcm6358-leds", },
+	{ },
+};
+
+static struct platform_driver bcm6358_leds_driver = {
+	.probe = bcm6358_leds_probe,
+	.driver = {
+		.name = "leds-bcm6358",
+		.of_match_table = bcm6358_leds_of_match,
+	},
+};
+
+module_platform_driver(bcm6358_leds_driver);
+
+MODULE_AUTHOR("Álvaro Fernández Rojas <noltari@gmail.com>");
+MODULE_DESCRIPTION("LED driver for BCM6358 controllers");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:leds-bcm6358");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller
  2015-05-21 17:11   ` [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
@ 2015-05-22 15:08     ` Jacek Anaszewski
  2015-05-22 22:32       ` Bryan Wu
  0 siblings, 1 reply; 12+ messages in thread
From: Jacek Anaszewski @ 2015-05-22 15:08 UTC (permalink / raw
  To: Álvaro Fernández Rojas
  Cc: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee

On 05/21/2015 07:11 PM, Álvaro Fernández Rojas wrote:
> This adds device tree binding documentation for the Broadcom BCM6358 LED controller.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>   v2: resend, no changes.
>
>   .../devicetree/bindings/leds/leds-bcm6358.txt      | 145 +++++++++++++++++++++
>   1 file changed, 145 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm6358.txt

Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>

-- 
Best Regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] leds: add BCM6358 LED driver
  2015-05-21 17:11   ` [PATCH v2 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
@ 2015-05-22 15:10     ` Jacek Anaszewski
  2015-05-22 22:34       ` Bryan Wu
  0 siblings, 1 reply; 12+ messages in thread
From: Jacek Anaszewski @ 2015-05-22 15:10 UTC (permalink / raw
  To: Álvaro Fernández Rojas
  Cc: linux-leds, devicetree, cooloney, jogo, f.fainelli, cernekee

Hi Alvaro,

Thanks for the update.

On 05/21/2015 07:11 PM, Álvaro Fernández Rojas wrote:
> This adds support for the LED controller on Broadcom's BCM6358.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>   v2: introduce changes suggested by Jacek
>   - Use correct device_node when getting brcm,clk-div property.
>   - Code style fixes suggested by "checkpatch --strict".
>
>   drivers/leds/Kconfig        |   8 ++
>   drivers/leds/Makefile       |   1 +
>   drivers/leds/leds-bcm6358.c | 243 ++++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 252 insertions(+)
>   create mode 100644 drivers/leds/leds-bcm6358.c

Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>

-- 
Best Regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller
  2015-05-22 15:08     ` Jacek Anaszewski
@ 2015-05-22 22:32       ` Bryan Wu
  0 siblings, 0 replies; 12+ messages in thread
From: Bryan Wu @ 2015-05-22 22:32 UTC (permalink / raw
  To: Jacek Anaszewski
  Cc: Álvaro Fernández Rojas, Linux LED Subsystem,
	devicetree@vger.kernel.org, jogo, Florian Fainelli, cernekee

On Fri, May 22, 2015 at 8:08 AM, Jacek Anaszewski
<j.anaszewski@samsung.com> wrote:
> On 05/21/2015 07:11 PM, Álvaro Fernández Rojas wrote:
>>
>> This adds device tree binding documentation for the Broadcom BCM6358 LED
>> controller.
>>
>> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
>> ---
>>   v2: resend, no changes.
>>
>>   .../devicetree/bindings/leds/leds-bcm6358.txt      | 145
>> +++++++++++++++++++++
>>   1 file changed, 145 insertions(+)
>>   create mode 100644
>> Documentation/devicetree/bindings/leds/leds-bcm6358.txt
>
>
> Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
>

Applied, thanks.
-Bryan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] leds: add BCM6358 LED driver
  2015-05-22 15:10     ` Jacek Anaszewski
@ 2015-05-22 22:34       ` Bryan Wu
  0 siblings, 0 replies; 12+ messages in thread
From: Bryan Wu @ 2015-05-22 22:34 UTC (permalink / raw
  To: Jacek Anaszewski
  Cc: Álvaro Fernández Rojas, Linux LED Subsystem,
	devicetree@vger.kernel.org, jogo, Florian Fainelli, cernekee

On Fri, May 22, 2015 at 8:10 AM, Jacek Anaszewski
<j.anaszewski@samsung.com> wrote:
> Hi Alvaro,
>
> Thanks for the update.
>
> On 05/21/2015 07:11 PM, Álvaro Fernández Rojas wrote:
>>
>> This adds support for the LED controller on Broadcom's BCM6358.
>>
>> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
>> ---
>>   v2: introduce changes suggested by Jacek
>>   - Use correct device_node when getting brcm,clk-div property.
>>   - Code style fixes suggested by "checkpatch --strict".
>>
>>   drivers/leds/Kconfig        |   8 ++
>>   drivers/leds/Makefile       |   1 +
>>   drivers/leds/leds-bcm6358.c | 243
>> ++++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 252 insertions(+)
>>   create mode 100644 drivers/leds/leds-bcm6358.c
>
>
> Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
>
>
Applied, thanks,
-Bryan

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-05-22 22:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-19 17:12 [PATCH 0/2] BCM6358 LED driver Álvaro Fernández Rojas
2015-05-19 17:12 ` [PATCH 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
2015-05-21 11:01   ` Jacek Anaszewski
2015-05-19 17:12 ` [PATCH 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
2015-05-21 10:58   ` Jacek Anaszewski
2015-05-21 17:11 ` [PATCH v2 0/2] " Álvaro Fernández Rojas
2015-05-21 17:11   ` [PATCH v2 1/2] leds: add DT binding for BCM6358 LED controller Álvaro Fernández Rojas
2015-05-22 15:08     ` Jacek Anaszewski
2015-05-22 22:32       ` Bryan Wu
2015-05-21 17:11   ` [PATCH v2 2/2] leds: add BCM6358 LED driver Álvaro Fernández Rojas
2015-05-22 15:10     ` Jacek Anaszewski
2015-05-22 22:34       ` Bryan Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.