Re: [U-Boot] [PATCH V2 1/8] led: add initial support for bcm6858

2019-03-29 Thread Daniel Schwierzeck


Am 22.03.19 um 17:02 schrieb Philippe Reynes:
> The driver add the support of the led IP on bcm6858.
> This led IP can drive up to 32 leds, and can handle
> blinking.
> 
> Signed-off-by: Philippe Reynes 
> ---
> Changelog:
> v2:
> - use const for array bcm6858_flash_rate (thanks Daniel)
> - use int for array bcm6858_flash_rate (thanks Daniel)
> 
>  doc/device-tree-bindings/leds/leds-bcm6858.txt |  51 +
>  drivers/led/Kconfig|   7 +
>  drivers/led/Makefile   |   1 +
>  drivers/led/led_bcm6858.c  | 250 
> +
>  4 files changed, 309 insertions(+)
>  create mode 100644 doc/device-tree-bindings/leds/leds-bcm6858.txt
>  create mode 100644 drivers/led/led_bcm6858.c
> 

Reviewed-by: Daniel Schwierzeck 
-- 
- Daniel
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 1/8] led: add initial support for bcm6858

2019-03-22 Thread Philippe Reynes
The driver add the support of the led IP on bcm6858.
This led IP can drive up to 32 leds, and can handle
blinking.

Signed-off-by: Philippe Reynes 
---
Changelog:
v2:
- use const for array bcm6858_flash_rate (thanks Daniel)
- use int for array bcm6858_flash_rate (thanks Daniel)

 doc/device-tree-bindings/leds/leds-bcm6858.txt |  51 +
 drivers/led/Kconfig|   7 +
 drivers/led/Makefile   |   1 +
 drivers/led/led_bcm6858.c  | 250 +
 4 files changed, 309 insertions(+)
 create mode 100644 doc/device-tree-bindings/leds/leds-bcm6858.txt
 create mode 100644 drivers/led/led_bcm6858.c

diff --git a/doc/device-tree-bindings/leds/leds-bcm6858.txt 
b/doc/device-tree-bindings/leds/leds-bcm6858.txt
new file mode 100644
index 000..ea2fe23
--- /dev/null
+++ b/doc/device-tree-bindings/leds/leds-bcm6858.txt
@@ -0,0 +1,51 @@
+LEDs connected to Broadcom BCM6858 controller
+
+This controller is present on BCM6858, BCM6328, BCM6362 and BCM63268.
+In these SoCs it's possible to control LEDs both as GPIOs or by hardware.
+
+Required properties:
+  - compatible : should be "brcm,bcm6858-leds".
+  - #address-cells : must be 1.
+  - #size-cells : must be 0.
+  - reg : BCM6858 LED controller address and size.
+
+Optional properties:
+  - brcm,serial-led-msb-first : Boolean, msb data come out first on serial 
data pin
+Default : false
+  - brcm,serial-led-en-pol : Boolean, serial led polarity (true => active high)
+Default : false
+  - brcm,serial-led-clk-pol : Boolean, serial clock polarity (true => active 
high)
+Default : false
+  - brcm,serial-led-data-ppol : Boolean, serial data polarity (true => active 
high)
+Default : false
+  - brcm,serial-shift-inv : Boolean, led test mode
+Default : false
+
+Each LED is represented as a sub-node of the brcm,bcm6858-leds device.
+
+LED sub-node required properties:
+  - reg : LED pin number (only LEDs 0 to 32 are valid).
+
+LED sub-node optional properties:
+  - label : see Documentation/devicetree/bindings/leds/common.txt
+  - active-low : Boolean, makes LED active low.
+Default : false
+
+Examples:
+BCM6328 with 2 GPIO LEDs
+   leds0: led-controller@ff800800 {
+   compatible = "brcm,bcm6858-leds";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0x0 0xff800800 0x0 0xe4>;
+
+   led@2 {
+   reg = <2>;
+   label = "green:inet";
+   };
+
+   led@5 {
+   reg = <5>;
+   label = "red:alarm";
+   };
+   };
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 5da5c4a..4c8582d 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -28,6 +28,13 @@ config LED_BCM6358
  LED HW controller accessed via MMIO registers.
  HW has no blinking capabilities and up to 32 LEDs can be controlled.
 
+config LED_BCM6858
+   bool "LED Support for BCM6858"
+   depends on LED && ARCH_BCM6858
+   help
+ This option enables support for LEDs connected to the BCM6858
+ HW has blinking capabilities and up to 32 LEDs can be controlled.
+
 config LED_BLINK
bool "Support LED blinking"
depends on LED
diff --git a/drivers/led/Makefile b/drivers/led/Makefile
index 160a8f3..3654dd3 100644
--- a/drivers/led/Makefile
+++ b/drivers/led/Makefile
@@ -6,4 +6,5 @@
 obj-y += led-uclass.o
 obj-$(CONFIG_LED_BCM6328) += led_bcm6328.o
 obj-$(CONFIG_LED_BCM6358) += led_bcm6358.o
+obj-$(CONFIG_LED_BCM6858) += led_bcm6858.o
 obj-$(CONFIG_$(SPL_)LED_GPIO) += led_gpio.o
diff --git a/drivers/led/led_bcm6858.c b/drivers/led/led_bcm6858.c
new file mode 100644
index 000..27a76fc
--- /dev/null
+++ b/drivers/led/led_bcm6858.c
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Philippe Reynes 
+ *
+ * based on:
+ * drivers/led/led_bcm6328.c
+ * drivers/led/led_bcm6358.c
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define LEDS_MAX   32
+#define LEDS_WAIT  100
+
+/* LED Mode register */
+#define LED_MODE_REG   0x0
+#define LED_MODE_OFF   0
+#define LED_MODE_ON1
+#define LED_MODE_MASK  1
+
+/* LED Controller Global settings register */
+#define LED_CTRL_REG   0x00
+#define LED_CTRL_MASK  0x1f
+#define LED_CTRL_LED_TEST_MODE BIT(0)
+#define LED_CTRL_SERIAL_LED_DATA_PPOL  BIT(1)
+#define LED_CTRL_SERIAL_LED_CLK_POLBIT(2)
+#define LED_CTRL_SERIAL_LED_EN_POL BIT(3)
+#define LED_CTRL_SERIAL_LED_MSB_FIRST  BIT(4)
+
+/* LED Controller IP LED source select register */
+#define LED_HW_LED_EN_REG  0x08
+/* LED Flash control register0 */
+#define LED_FLASH_RATE_CONTROL_REG00x10
+/* Soft LED input register */
+#define LED_SW_LED_IP_REG  0xb8
+/* Soft LED input polarity register