[PATCH 15/16] leds: add LM3633 driver

2015-11-01 Thread Milo Kim
LM3633 LED driver supports generic LED functions and pattern generation.
Pattern is generated through the sysfs. ABI documentation is also added.

Device creation from device tree

  LED channel name, LED string usage and max current settings are
  configured inside the DT.

LED dimming pattern generation
--
  LM3633 supports programmable dimming pattern generator.
  To enable it, three attributes are used.
  'pattern_times', 'pattern_levels' and 'run_pattern'.
  Sysfs ABI describes it.

LMU HWMON event handling

  As soon as LMU HWMON operation is done, LMU HWMON driver sends the event,
  'LMU_EVENT_HWMON_DONE'. Then, LM3633 device should be reinitialized
  because the device was reset by LMU HWMON driver.
  lm3633_led_hwmon_notifier() handles this event.

Data structure
--
  ti_lmu_led_chip:  LED device data.
  ti_lmu_led:   LED output channel data.
One LED device can have multiple LED channels.

Cc: Jacek Anaszewski 
Cc: linux-l...@vger.kernel.org
Cc: Lee Jones 
Cc: devicet...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Milo Kim 
---
 Documentation/ABI/testing/sysfs-class-led-lm3633 |  60 ++
 drivers/leds/Kconfig |  10 +
 drivers/leds/Makefile|   1 +
 drivers/leds/leds-lm3633.c   | 749 +++
 4 files changed, 820 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-lm3633
 create mode 100644 drivers/leds/leds-lm3633.c

diff --git a/Documentation/ABI/testing/sysfs-class-led-lm3633 
b/Documentation/ABI/testing/sysfs-class-led-lm3633
new file mode 100644
index 000..c1d8759
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-led-lm3633
@@ -0,0 +1,60 @@
+LM3633 LED driver generates programmable pattern via the sysfs.
+
+LED Pattern Generator Structure
+
+(3)
+  (a) --->  ___
+   /   \
+  (2) / \ (4)
+  (b) > _/   \_  ...
+   (1)   (5)
+
+ |<-   period   -> |
+
+What:  /sys/class/leds//pattern_times
+Date:  Oct 2015
+KernelVersion: 4.3
+Contact:   Milo Kim 
+Description:   read/write
+Set pattern time dimension. There are five arguments.
+  (1) startup delay
+  (2) rising dimming time
+  (3) how much time stays at high level
+  (4) falling dimming time
+  (5) how much time stays at low level
+Ranges are
+  (1), (3), (5): 0 ~ 1. Unit is millisecond.
+  (2), (4): 0 ~ 16000. Unit is millisecond.
+
+Example:
+No delay, rising 200ms, high 300ms, falling 100ms, low 400ms.
+echo "0 200 300 100 400" > /sys/class/leds//pattern_times
+
+cat /sys/class/leds//pattern_times
+delay: 0, rise: 200, high: 300, fall: 100, low: 400
+
+What:  /sys/class/leds//pattern_levels
+Date:  Oct 2015
+KernelVersion: 4.3
+Contact:   Milo Kim 
+Description:   read/write
+Set pattern level(brightness). There are two arguments.
+  (a) Low brightness level
+  (b) High brightness level
+Ranges are from 0 to 255.
+
+Example:
+Low level is 0, high level is 255.
+echo "0 255" > /sys/class/leds//pattern_levels
+
+cat /sys/class/leds//pattern_levels
+low brightness: 0, high brightness: 255
+
+What:  /sys/class/leds//run_pattern
+Date:  Oct 2015
+KernelVersion: 4.3
+Contact:   Milo Kim 
+Description:   write only
+After 'pattern_times' and 'pattern_levels' are updated,
+run the pattern by writing 1 to 'run_pattern'.
+To stop running pattern, writes 0 to 'run_pattern'.
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 42990f2..bc41a0e 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -88,6 +88,16 @@ config LEDS_LM3533
  hardware-accelerated blinking with maximum on and off periods of 9.8
  and 77 seconds respectively.
 
+config LEDS_LM3633
+   tristate "LED support for the TI LM3633 LMU"
+   depends on LEDS_CLASS
+   depends on MFD_TI_LMU
+   help
+ This option enables support for the LEDs on the LM3633.
+ LM3633 has 6 low voltage indicator LEDs.
+ All low voltage current sinks can have a programmable pattern
+ modulated onto LED output strings.
+
 config LEDS_LM3642
tristate "LED support for LM3642 Chip"
depends on LEDS_CLASS && I2C
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 

[PATCH 15/16] leds: add LM3633 driver

2015-11-01 Thread Milo Kim
LM3633 LED driver supports generic LED functions and pattern generation.
Pattern is generated through the sysfs. ABI documentation is also added.

Device creation from device tree

  LED channel name, LED string usage and max current settings are
  configured inside the DT.

LED dimming pattern generation
--
  LM3633 supports programmable dimming pattern generator.
  To enable it, three attributes are used.
  'pattern_times', 'pattern_levels' and 'run_pattern'.
  Sysfs ABI describes it.

LMU HWMON event handling

  As soon as LMU HWMON operation is done, LMU HWMON driver sends the event,
  'LMU_EVENT_HWMON_DONE'. Then, LM3633 device should be reinitialized
  because the device was reset by LMU HWMON driver.
  lm3633_led_hwmon_notifier() handles this event.

Data structure
--
  ti_lmu_led_chip:  LED device data.
  ti_lmu_led:   LED output channel data.
One LED device can have multiple LED channels.

Cc: Jacek Anaszewski 
Cc: linux-l...@vger.kernel.org
Cc: Lee Jones 
Cc: devicet...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Milo Kim 
---
 Documentation/ABI/testing/sysfs-class-led-lm3633 |  60 ++
 drivers/leds/Kconfig |  10 +
 drivers/leds/Makefile|   1 +
 drivers/leds/leds-lm3633.c   | 749 +++
 4 files changed, 820 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-lm3633
 create mode 100644 drivers/leds/leds-lm3633.c

diff --git a/Documentation/ABI/testing/sysfs-class-led-lm3633 
b/Documentation/ABI/testing/sysfs-class-led-lm3633
new file mode 100644
index 000..c1d8759
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-led-lm3633
@@ -0,0 +1,60 @@
+LM3633 LED driver generates programmable pattern via the sysfs.
+
+LED Pattern Generator Structure
+
+(3)
+  (a) --->  ___
+   /   \
+  (2) / \ (4)
+  (b) > _/   \_  ...
+   (1)   (5)
+
+ |<-   period   -> |
+
+What:  /sys/class/leds//pattern_times
+Date:  Oct 2015
+KernelVersion: 4.3
+Contact:   Milo Kim 
+Description:   read/write
+Set pattern time dimension. There are five arguments.
+  (1) startup delay
+  (2) rising dimming time
+  (3) how much time stays at high level
+  (4) falling dimming time
+  (5) how much time stays at low level
+Ranges are
+  (1), (3), (5): 0 ~ 1. Unit is millisecond.
+  (2), (4): 0 ~ 16000. Unit is millisecond.
+
+Example:
+No delay, rising 200ms, high 300ms, falling 100ms, low 400ms.
+echo "0 200 300 100 400" > /sys/class/leds//pattern_times
+
+cat /sys/class/leds//pattern_times
+delay: 0, rise: 200, high: 300, fall: 100, low: 400
+
+What:  /sys/class/leds//pattern_levels
+Date:  Oct 2015
+KernelVersion: 4.3
+Contact:   Milo Kim 
+Description:   read/write
+Set pattern level(brightness). There are two arguments.
+  (a) Low brightness level
+  (b) High brightness level
+Ranges are from 0 to 255.
+
+Example:
+Low level is 0, high level is 255.
+echo "0 255" > /sys/class/leds//pattern_levels
+
+cat /sys/class/leds//pattern_levels
+low brightness: 0, high brightness: 255
+
+What:  /sys/class/leds//run_pattern
+Date:  Oct 2015
+KernelVersion: 4.3
+Contact:   Milo Kim 
+Description:   write only
+After 'pattern_times' and 'pattern_levels' are updated,
+run the pattern by writing 1 to 'run_pattern'.
+To stop running pattern, writes 0 to 'run_pattern'.
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 42990f2..bc41a0e 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -88,6 +88,16 @@ config LEDS_LM3533
  hardware-accelerated blinking with maximum on and off periods of 9.8
  and 77 seconds respectively.
 
+config LEDS_LM3633
+   tristate "LED support for the TI LM3633 LMU"
+   depends on LEDS_CLASS
+   depends on MFD_TI_LMU
+   help
+ This option enables support for the LEDs on the LM3633.
+ LM3633 has 6 low voltage indicator LEDs.
+ All low voltage current sinks can have a programmable pattern
+ modulated onto LED output strings.
+
 config LEDS_LM3642
tristate "LED support for LM3642