[PATCH] backlight: Add TI LMU backlight driver

2017-03-19 Thread Milo Kim
This is consolidated driver which supports backlight devices below.
  LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.

Structure
-
  It consists of two parts - core and data.

  Core part supports features below.
- Backlight subsystem control
- Channel configuration from DT properties
- Light dimming effect control: ramp up and down.
- LMU fault monitor notifier handling
- PWM brightness control

  Data part describes device specific data.
- Register value configuration for each LMU device
  : initialization, channel configuration, control mode, enable and
brightness.
- PWM action configuration
- Light dimming effect table
- Option for LMU fault monitor support

Macros for register data

  All LMU devices have 8-bit based registers. LMU_BL_REG() creates 24-bit
  register value in data part. It consists of address, mask and value.
  On the other hand, register value should be parsed when the driver
  reads/writes data from/to I2C registers. Driver uses LMU_BL_GET_ADDR(),
  LMU_BL_GET_MASK() and LMU_BL_GET_VAL() for this purpose.

Data structure
--
  ti_lmu_bl: Backlight output channel data
  ti_lmu_bl_chip:Backlight device data. One device can have multiple
 backlight channel data.
  ti_lmu_bl_reg: Backlight device register data
  ti_lmu_bl_cfg: Backlight configuration data for each LMU device

Cc: Rob Herring <robh...@kernel.org>
Cc: Sebastian Reichel <s...@kernel.org>
Cc: Tony Lindgren <t...@atomide.com>
Signed-off-by: Milo Kim <milo@ti.com>
---
 .../bindings/leds/backlight/ti-lmu-backlight.txt   |  65 ++
 drivers/video/backlight/Kconfig|   7 +
 drivers/video/backlight/Makefile   |   3 +
 drivers/video/backlight/ti-lmu-backlight-core.c| 655 +
 drivers/video/backlight/ti-lmu-backlight-data.c| 287 +
 include/linux/mfd/ti-lmu-backlight.h   | 290 +
 6 files changed, 1307 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt
 create mode 100644 drivers/video/backlight/ti-lmu-backlight-core.c
 create mode 100644 drivers/video/backlight/ti-lmu-backlight-data.c
 create mode 100644 include/linux/mfd/ti-lmu-backlight.h

diff --git 
a/Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt 
b/Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt
new file mode 100644
index ..c2c35b293716
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt
@@ -0,0 +1,65 @@
+TI LMU backlight device tree bindings
+
+Required property:
+  - compatible: Should be one of:
+"ti,lm3532-backlight"
+"ti,lm3631-backlight"
+"ti,lm3632-backlight"
+"ti,lm3633-backlight"
+"ti,lm3695-backlight"
+"ti,lm3697-backlight"
+
+Optional properties:
+  There are two backlight control mode. One is I2C, the other is PWM mode.
+  Following properties are only specified in PWM mode.
+  Please note that LMU backlight device can have only one PWM channel.
+
+  - pwms: OF device-tree PWM specification.
+  - pwm-names: a list of names for the PWM devices specified in the "pwms"
+   property.
+
+  For the PWM user nodes, please refer to [1].
+
+Child nodes:
+  LMU backlight is represented as sub-nodes of the TI LMU device [2].
+  So, LMU backlight should have more than one backlight child node.
+  Each node exactly matches with backlight control bank configuration.
+  Maximum numbers of child nodes depend on the device.
+  1 = LM3631, LM3632, LM3695
+  2 = LM3633, LM3697
+  3 = LM3532
+
+  Required property of a child node:
+  - led-sources: List of enabled channels from 0 to 2.
+ Please refer to LED binding [3].
+ For output channels, please refer to the datasheets [4].
+
+  Optional properties of a child node:
+  - label: Backlight channel identification.
+   Please refer to LED binding [3].
+  - default-brightness-level: Backlight initial brightness value.
+  Type is . It is set as soon as backlight
+  device is created.
+  0 ~ 2047 = LM3631, LM3632, LM3633, LM3695 and
+ LM3697
+  0 ~ 255  = LM3532
+  - ramp-up-msec, ramp-down-msec: Light dimming effect properties.
+  Type is . Unit is millisecond.
+  0 ~ 65 msec= LM3532
+  0 ~ 4000 msec  = LM3631
+  0 ~ 16000 msec = LM3633 and LM3697
+  - pwm-period: PWM period. Only valid in PWM brightness mode.
+Type is . If this propert

[PATCH] backlight: Add TI LMU backlight driver

2017-03-19 Thread Milo Kim
This is consolidated driver which supports backlight devices below.
  LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.

Structure
-
  It consists of two parts - core and data.

  Core part supports features below.
- Backlight subsystem control
- Channel configuration from DT properties
- Light dimming effect control: ramp up and down.
- LMU fault monitor notifier handling
- PWM brightness control

  Data part describes device specific data.
- Register value configuration for each LMU device
  : initialization, channel configuration, control mode, enable and
brightness.
- PWM action configuration
- Light dimming effect table
- Option for LMU fault monitor support

Macros for register data

  All LMU devices have 8-bit based registers. LMU_BL_REG() creates 24-bit
  register value in data part. It consists of address, mask and value.
  On the other hand, register value should be parsed when the driver
  reads/writes data from/to I2C registers. Driver uses LMU_BL_GET_ADDR(),
  LMU_BL_GET_MASK() and LMU_BL_GET_VAL() for this purpose.

Data structure
--
  ti_lmu_bl: Backlight output channel data
  ti_lmu_bl_chip:Backlight device data. One device can have multiple
 backlight channel data.
  ti_lmu_bl_reg: Backlight device register data
  ti_lmu_bl_cfg: Backlight configuration data for each LMU device

Cc: Rob Herring 
Cc: Sebastian Reichel 
Cc: Tony Lindgren 
Signed-off-by: Milo Kim 
---
 .../bindings/leds/backlight/ti-lmu-backlight.txt   |  65 ++
 drivers/video/backlight/Kconfig|   7 +
 drivers/video/backlight/Makefile   |   3 +
 drivers/video/backlight/ti-lmu-backlight-core.c| 655 +
 drivers/video/backlight/ti-lmu-backlight-data.c| 287 +
 include/linux/mfd/ti-lmu-backlight.h   | 290 +
 6 files changed, 1307 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt
 create mode 100644 drivers/video/backlight/ti-lmu-backlight-core.c
 create mode 100644 drivers/video/backlight/ti-lmu-backlight-data.c
 create mode 100644 include/linux/mfd/ti-lmu-backlight.h

diff --git 
a/Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt 
b/Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt
new file mode 100644
index ..c2c35b293716
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/ti-lmu-backlight.txt
@@ -0,0 +1,65 @@
+TI LMU backlight device tree bindings
+
+Required property:
+  - compatible: Should be one of:
+"ti,lm3532-backlight"
+"ti,lm3631-backlight"
+"ti,lm3632-backlight"
+"ti,lm3633-backlight"
+"ti,lm3695-backlight"
+"ti,lm3697-backlight"
+
+Optional properties:
+  There are two backlight control mode. One is I2C, the other is PWM mode.
+  Following properties are only specified in PWM mode.
+  Please note that LMU backlight device can have only one PWM channel.
+
+  - pwms: OF device-tree PWM specification.
+  - pwm-names: a list of names for the PWM devices specified in the "pwms"
+   property.
+
+  For the PWM user nodes, please refer to [1].
+
+Child nodes:
+  LMU backlight is represented as sub-nodes of the TI LMU device [2].
+  So, LMU backlight should have more than one backlight child node.
+  Each node exactly matches with backlight control bank configuration.
+  Maximum numbers of child nodes depend on the device.
+  1 = LM3631, LM3632, LM3695
+  2 = LM3633, LM3697
+  3 = LM3532
+
+  Required property of a child node:
+  - led-sources: List of enabled channels from 0 to 2.
+ Please refer to LED binding [3].
+ For output channels, please refer to the datasheets [4].
+
+  Optional properties of a child node:
+  - label: Backlight channel identification.
+   Please refer to LED binding [3].
+  - default-brightness-level: Backlight initial brightness value.
+  Type is . It is set as soon as backlight
+  device is created.
+  0 ~ 2047 = LM3631, LM3632, LM3633, LM3695 and
+ LM3697
+  0 ~ 255  = LM3532
+  - ramp-up-msec, ramp-down-msec: Light dimming effect properties.
+  Type is . Unit is millisecond.
+  0 ~ 65 msec= LM3532
+  0 ~ 4000 msec  = LM3631
+  0 ~ 16000 msec = LM3633 and LM3697
+  - pwm-period: PWM period. Only valid in PWM brightness mode.
+Type is . If this property is missing, then control
+mode is set to I2C by default.
+
+Examples: Please 

[PATCH 2/2] regulator: lm363x: Use generic DT property name for external control pins

2017-02-28 Thread Milo Kim
Vpos and Vneg LDOs can be enabled or disabled by external GPIOs.
Use general DT property 'enable-gpios' for this usage.
Two enable pins are differentiable by selecting the index number.

Signed-off-by: Milo Kim <milo@ti.com>
---
 drivers/regulator/lm363x-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/lm363x-regulator.c 
b/drivers/regulator/lm363x-regulator.c
index f53e63301a20..ce5f7d9ad475 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -227,9 +227,9 @@ static int lm363x_regulator_of_get_enable_gpio(struct 
device_node *np, int id)
 */
switch (id) {
case LM3632_LDO_POS:
-   return of_get_named_gpio(np, "ti,lcm-en1-gpio", 0);
+   return of_get_named_gpio(np, "enable-gpios", 0);
case LM3632_LDO_NEG:
-   return of_get_named_gpio(np, "ti,lcm-en2-gpio", 0);
+   return of_get_named_gpio(np, "enable-gpios", 1);
default:
return -EINVAL;
}
-- 
2.11.0



[PATCH 2/2] regulator: lm363x: Use generic DT property name for external control pins

2017-02-28 Thread Milo Kim
Vpos and Vneg LDOs can be enabled or disabled by external GPIOs.
Use general DT property 'enable-gpios' for this usage.
Two enable pins are differentiable by selecting the index number.

Signed-off-by: Milo Kim 
---
 drivers/regulator/lm363x-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/lm363x-regulator.c 
b/drivers/regulator/lm363x-regulator.c
index f53e63301a20..ce5f7d9ad475 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -227,9 +227,9 @@ static int lm363x_regulator_of_get_enable_gpio(struct 
device_node *np, int id)
 */
switch (id) {
case LM3632_LDO_POS:
-   return of_get_named_gpio(np, "ti,lcm-en1-gpio", 0);
+   return of_get_named_gpio(np, "enable-gpios", 0);
case LM3632_LDO_NEG:
-   return of_get_named_gpio(np, "ti,lcm-en2-gpio", 0);
+   return of_get_named_gpio(np, "enable-gpios", 1);
default:
return -EINVAL;
}
-- 
2.11.0



[PATCH 1/2] Documentation: dt-bindings: Use generic property for hardware enable pins

2017-02-28 Thread Milo Kim
With index usages, device specific properties can be replaced with generic
one. Vpos is index 0 and Vneg is index 1.
DT examples are added as well.

Signed-off-by: Milo Kim <milo@ti.com>
---
 .../bindings/regulator/lm363x-regulator.txt| 78 +-
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt 
b/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
index 8f14df9d1205..cc5a6151d85f 100644
--- a/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
@@ -8,8 +8,8 @@ Required property:
 
 Optional properties:
   LM3632 has external enable pins for two LDOs.
-  - ti,lcm-en1-gpio: A GPIO specifier for Vpos control pin.
-  - ti,lcm-en2-gpio: A GPIO specifier for Vneg control pin.
+  - enable-gpios: Two GPIO specifiers for Vpos and Vneg control pins.
+  The first entry is Vpos, the second is Vneg enable pin.
 
 Child nodes:
   LM3631
@@ -30,5 +30,79 @@ Child nodes:
 
 Examples: Please refer to ti-lmu dt-bindings [2].
 
+lm3631@29 {
+   compatible = "ti,lm3631";
+   reg = <0x29>;
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+   regulator-max-microvolt = <635>;
+   regulator-always-on;
+   };
+
+   vcont {
+   regulator-name = "lcd_vcont";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   };
+
+   voref {
+   regulator-name = "lcd_voref";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+
+   vpos {
+   regulator-name = "lcd_vpos";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+
+   vneg {
+   regulator-name = "lcd_vneg";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+   };
+};
+
+lm3632@11 {
+   compatible = "ti,lm3632";
+   reg = <0x11>;
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   /* GPIO1_16 for Vpos, GPIO1_28 is for Vneg */
+   enable-gpios = < 16 GPIO_ACTIVE_HIGH>,
+   < 28 GPIO_ACTIVE_HIGH>;
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+   regulator-max-microvolt = <640>;
+   regulator-always-on;
+   };
+
+   vpos {
+   regulator-name = "lcd_vpos";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+
+   vneg {
+   regulator-name = "lcd_vneg";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+   };
+};
+
 [1] ../regulator/regulator.txt
 [2] ../mfd/ti-lmu.txt
-- 
2.11.0



[PATCH 1/2] Documentation: dt-bindings: Use generic property for hardware enable pins

2017-02-28 Thread Milo Kim
With index usages, device specific properties can be replaced with generic
one. Vpos is index 0 and Vneg is index 1.
DT examples are added as well.

Signed-off-by: Milo Kim 
---
 .../bindings/regulator/lm363x-regulator.txt| 78 +-
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt 
b/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
index 8f14df9d1205..cc5a6151d85f 100644
--- a/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
@@ -8,8 +8,8 @@ Required property:
 
 Optional properties:
   LM3632 has external enable pins for two LDOs.
-  - ti,lcm-en1-gpio: A GPIO specifier for Vpos control pin.
-  - ti,lcm-en2-gpio: A GPIO specifier for Vneg control pin.
+  - enable-gpios: Two GPIO specifiers for Vpos and Vneg control pins.
+  The first entry is Vpos, the second is Vneg enable pin.
 
 Child nodes:
   LM3631
@@ -30,5 +30,79 @@ Child nodes:
 
 Examples: Please refer to ti-lmu dt-bindings [2].
 
+lm3631@29 {
+   compatible = "ti,lm3631";
+   reg = <0x29>;
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+   regulator-max-microvolt = <635>;
+   regulator-always-on;
+   };
+
+   vcont {
+   regulator-name = "lcd_vcont";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   };
+
+   voref {
+   regulator-name = "lcd_voref";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+
+   vpos {
+   regulator-name = "lcd_vpos";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+
+   vneg {
+   regulator-name = "lcd_vneg";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+   };
+};
+
+lm3632@11 {
+   compatible = "ti,lm3632";
+   reg = <0x11>;
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   /* GPIO1_16 for Vpos, GPIO1_28 is for Vneg */
+   enable-gpios = < 16 GPIO_ACTIVE_HIGH>,
+   < 28 GPIO_ACTIVE_HIGH>;
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+   regulator-max-microvolt = <640>;
+   regulator-always-on;
+   };
+
+   vpos {
+   regulator-name = "lcd_vpos";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+
+   vneg {
+   regulator-name = "lcd_vneg";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+   };
+};
+
 [1] ../regulator/regulator.txt
 [2] ../mfd/ti-lmu.txt
-- 
2.11.0



[PATCH 2/2] mfd: add TI LMU driver

2017-02-27 Thread Milo Kim
TI LMU (Lighting Management Unit) driver supports lighting devices below.

  LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.

LMU devices have common features.
  - I2C interface for accessing device registers
  - Hardware enable pin control
  - Backlight brightness control
  - Notifier for hardware fault monitoring
  - Regulators for LCD display bias

It contains fault monitor, backlight, LED and regulator driver.

LMU fault monitor
-
  LM3633 and LM3697 provide hardware monitoring feature.
  It enables open or short circuit detection.
  After monitoring is done, each device should be re-initialized.
  Notifier is used for this case.
  Separate patch for 'ti-lmu-fault-monitor' will be sent later.

Backlight
-
  It's handled by TI LMU backlight consolidated driver and
  chip dependent data. Separate patchset will be sent later.

LED indicator
-
  LM3633 has 6 indicator LEDs. Programmable dimming pattern is also
  supported. Separate patch for 'leds-lm3633' will be sent later.

Regulator
-
  LM3631 has 5 regulators for the display bias.
  LM3632 supports 3 regulators. One consolidated driver enables it.
  The lm363x regulator driver is already upstreamed.

Acked-by: Lee Jones <lee.jo...@linaro.org>
Signed-off-by: Milo Kim <milo@ti.com>
---
 drivers/mfd/Kconfig |  12 ++
 drivers/mfd/Makefile|   2 +
 drivers/mfd/ti-lmu.c| 259 +
 include/linux/mfd/ti-lmu-register.h | 280 
 include/linux/mfd/ti-lmu.h  |  87 +++
 5 files changed, 640 insertions(+)
 create mode 100644 drivers/mfd/ti-lmu.c
 create mode 100644 include/linux/mfd/ti-lmu-register.h
 create mode 100644 include/linux/mfd/ti-lmu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb74d31..75e749c1ff1a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1164,6 +1164,18 @@ config MFD_LP8788
  TI LP8788 PMU supports regulators, battery charger, RTC,
  ADC, backlight driver and current sinks.
 
+config MFD_TI_LMU
+   tristate "TI Lighting Management Unit driver"
+   depends on I2C
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ Say yes here to enable support for TI LMU chips.
+
+ TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.
+ It consists of backlight, LED and regulator driver.
+ It provides consistent device controls for lighting functions.
+
 config MFD_OMAP_USB_HOST
bool "TI OMAP USBHS core and TLL driver"
depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 31ce07611a6f..dac78a0f23a7 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -125,6 +125,8 @@ obj-$(CONFIG_MFD_AXP20X_RSB)+= axp20x-rsb.o
 obj-$(CONFIG_MFD_LP3943)   += lp3943.o
 obj-$(CONFIG_MFD_LP8788)   += lp8788.o lp8788-irq.o
 
+obj-$(CONFIG_MFD_TI_LMU)   += ti-lmu.o
+
 da9055-objs:= da9055-core.o da9055-i2c.o
 obj-$(CONFIG_MFD_DA9055)   += da9055.o
 obj-$(CONFIG_MFD_DA9062)   += da9062-core.o
diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c
new file mode 100644
index ..cfb411cde51c
--- /dev/null
+++ b/drivers/mfd/ti-lmu.c
@@ -0,0 +1,259 @@
+/*
+ * TI LMU (Lighting Management Unit) Core Driver
+ *
+ * Copyright 2017 Texas Instruments
+ *
+ * Author: Milo Kim <milo@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct ti_lmu_data {
+   struct mfd_cell *cells;
+   int num_cells;
+   unsigned int max_register;
+};
+
+static int ti_lmu_enable_hw(struct ti_lmu *lmu, enum ti_lmu_id id)
+{
+   int ret;
+
+   if (gpio_is_valid(lmu->en_gpio)) {
+   ret = devm_gpio_request_one(lmu->dev, lmu->en_gpio,
+   GPIOF_OUT_INIT_HIGH, "lmu_hwen");
+   if (ret) {
+   dev_err(lmu->dev, "Can not request enable GPIO: %d\n",
+   ret);
+   return ret;
+   }
+   }
+
+   /* Delay about 1ms after HW enable pin control */
+   usleep_range(1000, 1500);
+
+   /* LM3631 has additional power up sequence - enable LCD_EN bit. */
+   if (id == LM3631) {
+   return regmap_update_bits(lmu->regmap, LM3631_REG_DEVCTRL,
+ LM3631_LCD_EN_MASK,
+ LM3631_LCD_EN_MASK);
+   }
+
+   return 0;
+}
+
+static void ti_lmu

[PATCH 2/2] mfd: add TI LMU driver

2017-02-27 Thread Milo Kim
TI LMU (Lighting Management Unit) driver supports lighting devices below.

  LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.

LMU devices have common features.
  - I2C interface for accessing device registers
  - Hardware enable pin control
  - Backlight brightness control
  - Notifier for hardware fault monitoring
  - Regulators for LCD display bias

It contains fault monitor, backlight, LED and regulator driver.

LMU fault monitor
-
  LM3633 and LM3697 provide hardware monitoring feature.
  It enables open or short circuit detection.
  After monitoring is done, each device should be re-initialized.
  Notifier is used for this case.
  Separate patch for 'ti-lmu-fault-monitor' will be sent later.

Backlight
-
  It's handled by TI LMU backlight consolidated driver and
  chip dependent data. Separate patchset will be sent later.

LED indicator
-
  LM3633 has 6 indicator LEDs. Programmable dimming pattern is also
  supported. Separate patch for 'leds-lm3633' will be sent later.

Regulator
-
  LM3631 has 5 regulators for the display bias.
  LM3632 supports 3 regulators. One consolidated driver enables it.
  The lm363x regulator driver is already upstreamed.

Acked-by: Lee Jones 
Signed-off-by: Milo Kim 
---
 drivers/mfd/Kconfig |  12 ++
 drivers/mfd/Makefile|   2 +
 drivers/mfd/ti-lmu.c| 259 +
 include/linux/mfd/ti-lmu-register.h | 280 
 include/linux/mfd/ti-lmu.h  |  87 +++
 5 files changed, 640 insertions(+)
 create mode 100644 drivers/mfd/ti-lmu.c
 create mode 100644 include/linux/mfd/ti-lmu-register.h
 create mode 100644 include/linux/mfd/ti-lmu.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb74d31..75e749c1ff1a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1164,6 +1164,18 @@ config MFD_LP8788
  TI LP8788 PMU supports regulators, battery charger, RTC,
  ADC, backlight driver and current sinks.
 
+config MFD_TI_LMU
+   tristate "TI Lighting Management Unit driver"
+   depends on I2C
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ Say yes here to enable support for TI LMU chips.
+
+ TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.
+ It consists of backlight, LED and regulator driver.
+ It provides consistent device controls for lighting functions.
+
 config MFD_OMAP_USB_HOST
bool "TI OMAP USBHS core and TLL driver"
depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 31ce07611a6f..dac78a0f23a7 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -125,6 +125,8 @@ obj-$(CONFIG_MFD_AXP20X_RSB)+= axp20x-rsb.o
 obj-$(CONFIG_MFD_LP3943)   += lp3943.o
 obj-$(CONFIG_MFD_LP8788)   += lp8788.o lp8788-irq.o
 
+obj-$(CONFIG_MFD_TI_LMU)   += ti-lmu.o
+
 da9055-objs:= da9055-core.o da9055-i2c.o
 obj-$(CONFIG_MFD_DA9055)   += da9055.o
 obj-$(CONFIG_MFD_DA9062)   += da9062-core.o
diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c
new file mode 100644
index ..cfb411cde51c
--- /dev/null
+++ b/drivers/mfd/ti-lmu.c
@@ -0,0 +1,259 @@
+/*
+ * TI LMU (Lighting Management Unit) Core Driver
+ *
+ * Copyright 2017 Texas Instruments
+ *
+ * Author: Milo Kim 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct ti_lmu_data {
+   struct mfd_cell *cells;
+   int num_cells;
+   unsigned int max_register;
+};
+
+static int ti_lmu_enable_hw(struct ti_lmu *lmu, enum ti_lmu_id id)
+{
+   int ret;
+
+   if (gpio_is_valid(lmu->en_gpio)) {
+   ret = devm_gpio_request_one(lmu->dev, lmu->en_gpio,
+   GPIOF_OUT_INIT_HIGH, "lmu_hwen");
+   if (ret) {
+   dev_err(lmu->dev, "Can not request enable GPIO: %d\n",
+   ret);
+   return ret;
+   }
+   }
+
+   /* Delay about 1ms after HW enable pin control */
+   usleep_range(1000, 1500);
+
+   /* LM3631 has additional power up sequence - enable LCD_EN bit. */
+   if (id == LM3631) {
+   return regmap_update_bits(lmu->regmap, LM3631_REG_DEVCTRL,
+ LM3631_LCD_EN_MASK,
+ LM3631_LCD_EN_MASK);
+   }
+
+   return 0;
+}
+
+static void ti_lmu_disable_hw(struct ti_lmu *lmu)
+{
+   if (gpio_is_valid(lmu->en_gpio))
+  

[PATCH 1/2] Documentation: dt-bindings: mfd: add TI LMU device binding information

2017-02-27 Thread Milo Kim
This patch describes overall binding for TI LMU MFD devices.

Acked-by: Lee Jones <lee.jo...@linaro.org>
Acked-by: Rob Herring <robh...@kernel.org>
Signed-off-by: Milo Kim <milo@ti.com>
---
 Documentation/devicetree/bindings/mfd/ti-lmu.txt | 243 +++
 1 file changed, 243 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti-lmu.txt

diff --git a/Documentation/devicetree/bindings/mfd/ti-lmu.txt 
b/Documentation/devicetree/bindings/mfd/ti-lmu.txt
new file mode 100644
index ..c885cf89b8ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/ti-lmu.txt
@@ -0,0 +1,243 @@
+TI LMU (Lighting Management Unit) device tree bindings
+
+TI LMU driver supports lighting devices below.
+
+   Name  Child nodes
+  --  -
+  LM3532   Backlight
+  LM3631   Backlight and regulator
+  LM3632   Backlight and regulator
+  LM3633   Backlight, LED and fault monitor
+  LM3695   Backlight
+  LM3697   Backlight and fault monitor
+
+Required properties:
+  - compatible: Should be one of:
+"ti,lm3532"
+"ti,lm3631"
+"ti,lm3632"
+"ti,lm3633"
+"ti,lm3695"
+"ti,lm3697"
+  - reg: I2C slave address.
+ 0x11 for LM3632
+ 0x29 for LM3631
+ 0x36 for LM3633, LM3697
+ 0x38 for LM3532
+ 0x63 for LM3695
+
+Optional property:
+  - enable-gpios: A GPIO specifier for hardware enable pin.
+
+Required node:
+  - backlight: All LMU devices have backlight child nodes.
+   For the properties, please refer to [1].
+
+Optional nodes:
+  - fault-monitor: Hardware fault monitoring driver for LM3633 and LM3697.
+Required properties:
+  - compatible: Should be one of:
+"ti,lm3633-fault-monitor"
+"ti,lm3697-fault-monitor"
+  - leds: LED properties for LM3633. Please refer to [2].
+  - regulators: Regulator properties for LM3631 and LM3632.
+Please refer to [3].
+
+[1] ../leds/backlight/ti-lmu-backlight.txt
+[2] ../leds/leds-lm3633.txt
+[3] ../regulator/lm363x-regulator.txt
+
+lm3532@38 {
+   compatible = "ti,lm3532";
+   reg = <0x38>;
+
+   enable-gpios = < 2 GPIO_ACTIVE_HIGH>;
+
+   backlight {
+   compatible = "ti,lm3532-backlight";
+
+   lcd {
+   led-sources = <0 1 2>;
+   ramp-up-msec = <30>;
+   ramp-down-msec = <0>;
+   };
+   };
+};
+
+lm3631@29 {
+   compatible = "ti,lm3631";
+   reg = <0x29>;
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+   regulator-max-microvolt = <635>;
+   regulator-always-on;
+   };
+
+   vcont {
+   regulator-name = "lcd_vcont";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   };
+
+   voref {
+   regulator-name = "lcd_voref";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+
+   vpos {
+   regulator-name = "lcd_vpos";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+
+   vneg {
+   regulator-name = "lcd_vneg";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+   };
+
+   backlight {
+   compatible = "ti,lm3631-backlight";
+
+   lcd_bl {
+   led-sources = <0 1>;
+   ramp-up-msec = <300>;
+   };
+   };
+};
+
+lm3632@11 {
+   compatible = "ti,lm3632";
+   reg = <0x11>;
+
+   enable-gpios = < 2 GPIO_ACTIVE_HIGH>; /* PC2 */
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   ti,lcm-en1-gpio = < 0 GPIO_ACTIVE_HIGH>; /* PC0 */
+   ti,lcm-en2-gpio = < 1 GPIO_ACTIVE_HIGH>; /* PC1 */
+
+   vboost {
+   regulator-name = "lcd_boost";
+   

[PATCH 1/2] Documentation: dt-bindings: mfd: add TI LMU device binding information

2017-02-27 Thread Milo Kim
This patch describes overall binding for TI LMU MFD devices.

Acked-by: Lee Jones 
Acked-by: Rob Herring 
Signed-off-by: Milo Kim 
---
 Documentation/devicetree/bindings/mfd/ti-lmu.txt | 243 +++
 1 file changed, 243 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti-lmu.txt

diff --git a/Documentation/devicetree/bindings/mfd/ti-lmu.txt 
b/Documentation/devicetree/bindings/mfd/ti-lmu.txt
new file mode 100644
index ..c885cf89b8ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/ti-lmu.txt
@@ -0,0 +1,243 @@
+TI LMU (Lighting Management Unit) device tree bindings
+
+TI LMU driver supports lighting devices below.
+
+   Name  Child nodes
+  --  -
+  LM3532   Backlight
+  LM3631   Backlight and regulator
+  LM3632   Backlight and regulator
+  LM3633   Backlight, LED and fault monitor
+  LM3695   Backlight
+  LM3697   Backlight and fault monitor
+
+Required properties:
+  - compatible: Should be one of:
+"ti,lm3532"
+"ti,lm3631"
+"ti,lm3632"
+"ti,lm3633"
+"ti,lm3695"
+"ti,lm3697"
+  - reg: I2C slave address.
+ 0x11 for LM3632
+ 0x29 for LM3631
+ 0x36 for LM3633, LM3697
+ 0x38 for LM3532
+ 0x63 for LM3695
+
+Optional property:
+  - enable-gpios: A GPIO specifier for hardware enable pin.
+
+Required node:
+  - backlight: All LMU devices have backlight child nodes.
+   For the properties, please refer to [1].
+
+Optional nodes:
+  - fault-monitor: Hardware fault monitoring driver for LM3633 and LM3697.
+Required properties:
+  - compatible: Should be one of:
+"ti,lm3633-fault-monitor"
+"ti,lm3697-fault-monitor"
+  - leds: LED properties for LM3633. Please refer to [2].
+  - regulators: Regulator properties for LM3631 and LM3632.
+Please refer to [3].
+
+[1] ../leds/backlight/ti-lmu-backlight.txt
+[2] ../leds/leds-lm3633.txt
+[3] ../regulator/lm363x-regulator.txt
+
+lm3532@38 {
+   compatible = "ti,lm3532";
+   reg = <0x38>;
+
+   enable-gpios = < 2 GPIO_ACTIVE_HIGH>;
+
+   backlight {
+   compatible = "ti,lm3532-backlight";
+
+   lcd {
+   led-sources = <0 1 2>;
+   ramp-up-msec = <30>;
+   ramp-down-msec = <0>;
+   };
+   };
+};
+
+lm3631@29 {
+   compatible = "ti,lm3631";
+   reg = <0x29>;
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+   regulator-max-microvolt = <635>;
+   regulator-always-on;
+   };
+
+   vcont {
+   regulator-name = "lcd_vcont";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   };
+
+   voref {
+   regulator-name = "lcd_voref";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   };
+
+   vpos {
+   regulator-name = "lcd_vpos";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+
+   vneg {
+   regulator-name = "lcd_vneg";
+   regulator-min-microvolt = <400>;
+   regulator-max-microvolt = <600>;
+   regulator-boot-on;
+   };
+   };
+
+   backlight {
+   compatible = "ti,lm3631-backlight";
+
+   lcd_bl {
+   led-sources = <0 1>;
+   ramp-up-msec = <300>;
+   };
+   };
+};
+
+lm3632@11 {
+   compatible = "ti,lm3632";
+   reg = <0x11>;
+
+   enable-gpios = < 2 GPIO_ACTIVE_HIGH>; /* PC2 */
+
+   regulators {
+   compatible = "ti,lm363x-regulator";
+
+   ti,lcm-en1-gpio = < 0 GPIO_ACTIVE_HIGH>; /* PC0 */
+   ti,lcm-en2-gpio = < 1 GPIO_ACTIVE_HIGH>; /* PC1 */
+
+   vboost {
+   regulator-name = "lcd_boost";
+   regulator-min-microvolt = <450>;
+ 

[PATCH v3 0/2] Support TI LMU devices

2017-02-27 Thread Milo Kim
Back from 2015! TI LMU core driver got acked but few more efforts
were required like backlight, LEDs and others.
Recently, Tony Lindgren has been working on porting mainline Linux on 
Droid 4 xt894. One of LMU devices - LM3532 is used for LCD backlight on 
that device. I hope this patch-set would be helpful.

TI Lighting Management Unit drivers support lighting devices below.

 Enable pin  Backlight  HW fault monitoring  LEDs   Regulators
 --  -  ---    
LM3532   o   o   xx x
LM3631   o   o   xx5 regulators
LM3632   o   o   xx3 regulators
LM3633   o   o   oo x
LM3695   o   o   xx x
LM3697   o   o   ox x

This patch-set includes only MFD part. Other subsystem drivers will be sent
separately.

  ti-lmu-backlight: Backlight subsystem
  ti-lmu-fault-monitor: Misc driver
  leds-lm3633: LED subsystem

Updates from v2:
  Submit acked patches to get merged quickly.

Milo Kim (2):
  Documentation: dt-bindings: mfd: add TI LMU device binding information
  mfd: add TI LMU driver

 Documentation/devicetree/bindings/mfd/ti-lmu.txt | 243 
 drivers/mfd/Kconfig  |  12 +
 drivers/mfd/Makefile |   2 +
 drivers/mfd/ti-lmu.c | 259 +
 include/linux/mfd/ti-lmu-register.h  | 280 +++
 include/linux/mfd/ti-lmu.h   |  87 +++
 6 files changed, 883 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti-lmu.txt
 create mode 100644 drivers/mfd/ti-lmu.c
 create mode 100644 include/linux/mfd/ti-lmu-register.h
 create mode 100644 include/linux/mfd/ti-lmu.h

-- 
2.11.0



[PATCH v3 0/2] Support TI LMU devices

2017-02-27 Thread Milo Kim
Back from 2015! TI LMU core driver got acked but few more efforts
were required like backlight, LEDs and others.
Recently, Tony Lindgren has been working on porting mainline Linux on 
Droid 4 xt894. One of LMU devices - LM3532 is used for LCD backlight on 
that device. I hope this patch-set would be helpful.

TI Lighting Management Unit drivers support lighting devices below.

 Enable pin  Backlight  HW fault monitoring  LEDs   Regulators
 --  -  ---    
LM3532   o   o   xx x
LM3631   o   o   xx5 regulators
LM3632   o   o   xx3 regulators
LM3633   o   o   oo x
LM3695   o   o   xx x
LM3697   o   o   ox x

This patch-set includes only MFD part. Other subsystem drivers will be sent
separately.

  ti-lmu-backlight: Backlight subsystem
  ti-lmu-fault-monitor: Misc driver
  leds-lm3633: LED subsystem

Updates from v2:
  Submit acked patches to get merged quickly.

Milo Kim (2):
  Documentation: dt-bindings: mfd: add TI LMU device binding information
  mfd: add TI LMU driver

 Documentation/devicetree/bindings/mfd/ti-lmu.txt | 243 
 drivers/mfd/Kconfig  |  12 +
 drivers/mfd/Makefile |   2 +
 drivers/mfd/ti-lmu.c | 259 +
 include/linux/mfd/ti-lmu-register.h  | 280 +++
 include/linux/mfd/ti-lmu.h   |  87 +++
 6 files changed, 883 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti-lmu.txt
 create mode 100644 drivers/mfd/ti-lmu.c
 create mode 100644 include/linux/mfd/ti-lmu-register.h
 create mode 100644 include/linux/mfd/ti-lmu.h

-- 
2.11.0



Re: [PATCH resend v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-09 Thread Milo Kim


On 01/10/2017 12:27 PM, Shawn Guo wrote:

On Wed, Jan 04, 2017 at 04:04:36PM +0900, Milo Kim wrote:

Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +

The bindings change should be ideally a separate patch.  But since Rob
seems to be fine with it this time, I just applied the whole series.


Got it. Thanks for taking this.

Best regards,
Milo


Re: [PATCH resend v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-09 Thread Milo Kim


On 01/10/2017 12:27 PM, Shawn Guo wrote:

On Wed, Jan 04, 2017 at 04:04:36PM +0900, Milo Kim wrote:

Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam 
Signed-off-by: Milo Kim 
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +

The bindings change should be ideally a separate patch.  But since Rob
seems to be fine with it this time, I just applied the whole series.


Got it. Thanks for taking this.

Best regards,
Milo


Re: [PATCH v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-03 Thread Milo Kim


On 01/04/2017 01:55 PM, Milo Kim wrote:

Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   | 51 ++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..88c33d827e51 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -227,6 +227,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+poslab  Poslab Technology Co., Ltd.


I should input tab here instead of spaces, so updated single patch was 
just sent. Please refer to the patch named "[PATCH resend v4 2/3] ARM: 
dts: imx6: Support Savageboard dual".


Sorry for the inconvenience.

Best regards,
Milo


Re: [PATCH v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-03 Thread Milo Kim


On 01/04/2017 01:55 PM, Milo Kim wrote:

Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam 
Signed-off-by: Milo Kim 
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   | 51 ++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..88c33d827e51 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -227,6 +227,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+poslab  Poslab Technology Co., Ltd.


I should input tab here instead of spaces, so updated single patch was 
just sent. Please refer to the patch named "[PATCH resend v4 2/3] ARM: 
dts: imx6: Support Savageboard dual".


Sorry for the inconvenience.

Best regards,
Milo


[PATCH resend v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-03 Thread Milo Kim
Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   | 51 ++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..552b63651ab9 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -227,6 +227,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+poslab Poslab Technology Co., Ltd.
 powervrPowerVR (deprecated, use img)
 pulsedlightPulsedLight, Inc
 qcaQualcomm Atheros, Inc.
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb557b6..fb7f904a5235 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -357,6 +357,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-savageboard.dts 
b/arch/arm/boot/dts/imx6dl-savageboard.dts
new file mode 100644
index ..b95469c520a4
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-savageboard.dts
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";
+};
-- 
2.11.0



[PATCH resend v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-03 Thread Milo Kim
Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam 
Signed-off-by: Milo Kim 
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   | 51 ++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..552b63651ab9 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -227,6 +227,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+poslab Poslab Technology Co., Ltd.
 powervrPowerVR (deprecated, use img)
 pulsedlightPulsedLight, Inc
 qcaQualcomm Atheros, Inc.
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb557b6..fb7f904a5235 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -357,6 +357,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-savageboard.dts 
b/arch/arm/boot/dts/imx6dl-savageboard.dts
new file mode 100644
index ..b95469c520a4
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-savageboard.dts
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";
+};
-- 
2.11.0



[PATCH v4 0/3] ARM: dts: imx6: Support Poslab Savageboard dual & quad

2017-01-03 Thread Milo Kim
Poslab Savageboard is the i.MX6 SoC base, but BSP code from the vendor is 
not mainline u-boot and kernel. Personal reason of using this board is 
testing etnaviv user-space driver, so I re-write device tree files based on
mainline kernel for the first step.

This patchset includes common DT file, dual and quad board files.

Supported components are
  - Display: HDMI and LVDS panel
  - eMMC and SD card
  - Ethernet
  - Pinmux configuration
  - SATA: only for Savageboard quad
  - UART1 for debug console
  - USB host

Missing features are
  - Audio (WM8903)
  - USB OTG
  - PMIC WM8326: default settings are used so no issue to bring-up the system
  - MIPI DSI and CSI

Patches are tested on the Savageboard quad but the dual version should work 
because the only difference between dual and quad is SATA support.

More information in http://www.savageboard.org

v4:
  Fix the license text and add the vendor prefix.
  Use generic node name for the backlight panel.
  Sort alphabetically for the pinctrl nodes.
  Remove unnecessary pinmux of HDMI CEC.

v3:
  Specify the dtbs for i.MX6 build.

v2:
  Fix DT node for regulator, phy-reset-gpios and iomuxc node.

Milo Kim (3):
  ARM: dts: imx6: Add Savageboard common file
  ARM: dts: imx6: Support Savageboard dual
  ARM: dts: imx6: Support Savageboard quad

 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   |  51 +
 arch/arm/boot/dts/imx6q-savageboard.dts|  55 +
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 255 +
 5 files changed, 364 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

-- 
2.11.0



[PATCH v4 0/3] ARM: dts: imx6: Support Poslab Savageboard dual & quad

2017-01-03 Thread Milo Kim
Poslab Savageboard is the i.MX6 SoC base, but BSP code from the vendor is 
not mainline u-boot and kernel. Personal reason of using this board is 
testing etnaviv user-space driver, so I re-write device tree files based on
mainline kernel for the first step.

This patchset includes common DT file, dual and quad board files.

Supported components are
  - Display: HDMI and LVDS panel
  - eMMC and SD card
  - Ethernet
  - Pinmux configuration
  - SATA: only for Savageboard quad
  - UART1 for debug console
  - USB host

Missing features are
  - Audio (WM8903)
  - USB OTG
  - PMIC WM8326: default settings are used so no issue to bring-up the system
  - MIPI DSI and CSI

Patches are tested on the Savageboard quad but the dual version should work 
because the only difference between dual and quad is SATA support.

More information in http://www.savageboard.org

v4:
  Fix the license text and add the vendor prefix.
  Use generic node name for the backlight panel.
  Sort alphabetically for the pinctrl nodes.
  Remove unnecessary pinmux of HDMI CEC.

v3:
  Specify the dtbs for i.MX6 build.

v2:
  Fix DT node for regulator, phy-reset-gpios and iomuxc node.

Milo Kim (3):
  ARM: dts: imx6: Add Savageboard common file
  ARM: dts: imx6: Support Savageboard dual
  ARM: dts: imx6: Support Savageboard quad

 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   |  51 +
 arch/arm/boot/dts/imx6q-savageboard.dts|  55 +
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 255 +
 5 files changed, 364 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

-- 
2.11.0



[PATCH v4 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-03 Thread Milo Kim
* Memory
  memblock for DDR3 1GB

* Regulator
  3.3V for panel and backlight.

* Display
  Enable HDMI and LVDS panel. Savageboard supports AVIC TM097TDH02 panel
  which is compatible with Hannstar HSD100PXN1, so reuse it.

* Clock
  The commit d28be499c45e6 ("ARM: dts: imx6qdl-sabresd: Allow HDMI and
  LVDS to work simultaneously") is applied to support LVDS and HDMI output
  at the same time.

* Pinmux
  Support eMMC, ethernet, gpio key for power button, I2C, PWM, SD card 
  and UART.

* Others
  Enable ethernet, UART1 debug, USB host, USDHC3 for microSD card and
  USDHC4 for built-in eMMC storage.

Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 255 +
 1 file changed, 255 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

diff --git a/arch/arm/boot/dts/imx6qdl-savageboard.dtsi 
b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
new file mode 100644
index ..a616e3c400d3
--- /dev/null
+++ b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2017 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+
+   memory@1000 {
+   device_type = "memory";
+   reg = <0x1000 0x4000>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_keys>;
+
+   power {
+   gpios = < 7 GPIO_ACTIVE_LOW>;
+   label = "Power Button";
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+
+   panel {
+   compatible = "avic,tm097tdh02", "hannstar,hsd100pxn1";
+   backlight = <_bl>;
+   power-supply = <_3p3v>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+
+   panel_bl: backlight {
+   compatible = "pwm-backlight";
+   brightness-levels = <0 4 8 16 32 64 128 255>;
+   default-brightness-level = <4>;
+   power-supply = <_3p3v>;
+   pwms = < 0 1>;
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "3P3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+};
+
+ {
+   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
+ < IMX6QDL_CLK_LDB

[PATCH v4 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-03 Thread Milo Kim
* Memory
  memblock for DDR3 1GB

* Regulator
  3.3V for panel and backlight.

* Display
  Enable HDMI and LVDS panel. Savageboard supports AVIC TM097TDH02 panel
  which is compatible with Hannstar HSD100PXN1, so reuse it.

* Clock
  The commit d28be499c45e6 ("ARM: dts: imx6qdl-sabresd: Allow HDMI and
  LVDS to work simultaneously") is applied to support LVDS and HDMI output
  at the same time.

* Pinmux
  Support eMMC, ethernet, gpio key for power button, I2C, PWM, SD card 
  and UART.

* Others
  Enable ethernet, UART1 debug, USB host, USDHC3 for microSD card and
  USDHC4 for built-in eMMC storage.

Reviewed-by: Fabio Estevam 
Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 255 +
 1 file changed, 255 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

diff --git a/arch/arm/boot/dts/imx6qdl-savageboard.dtsi 
b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
new file mode 100644
index ..a616e3c400d3
--- /dev/null
+++ b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2017 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+
+   memory@1000 {
+   device_type = "memory";
+   reg = <0x1000 0x4000>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_keys>;
+
+   power {
+   gpios = < 7 GPIO_ACTIVE_LOW>;
+   label = "Power Button";
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+
+   panel {
+   compatible = "avic,tm097tdh02", "hannstar,hsd100pxn1";
+   backlight = <_bl>;
+   power-supply = <_3p3v>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+
+   panel_bl: backlight {
+   compatible = "pwm-backlight";
+   brightness-levels = <0 4 8 16 32 64 128 255>;
+   default-brightness-level = <4>;
+   power-supply = <_3p3v>;
+   pwms = < 0 1>;
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "3P3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+};
+
+ {
+   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
+ < IMX6QDL_CLK_LDB_DI1_SEL>;
+   assigned-clock-parents = < IMX6QDL_CLK_PLL3_USB_OTG>,

[PATCH v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-03 Thread Milo Kim
Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   | 51 ++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..88c33d827e51 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -227,6 +227,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+poslab  Poslab Technology Co., Ltd.
 powervrPowerVR (deprecated, use img)
 pulsedlightPulsedLight, Inc
 qcaQualcomm Atheros, Inc.
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb557b6..fb7f904a5235 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -357,6 +357,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-savageboard.dts 
b/arch/arm/boot/dts/imx6dl-savageboard.dts
new file mode 100644
index ..b95469c520a4
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-savageboard.dts
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";
+};
-- 
2.11.0



[PATCH v4 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-03 Thread Milo Kim
Common savageboard DT file is used for board support.
Add the vendor name and specify the dtb file for i.MX6Q build.

Reviewed-by: Fabio Estevam 
Signed-off-by: Milo Kim 
---
 .../devicetree/bindings/vendor-prefixes.txt|  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   | 51 ++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 16d3b5e7f5d1..88c33d827e51 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -227,6 +227,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+poslab  Poslab Technology Co., Ltd.
 powervrPowerVR (deprecated, use img)
 pulsedlightPulsedLight, Inc
 qcaQualcomm Atheros, Inc.
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb557b6..fb7f904a5235 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -357,6 +357,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-savageboard.dts 
b/arch/arm/boot/dts/imx6dl-savageboard.dts
new file mode 100644
index ..b95469c520a4
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-savageboard.dts
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";
+};
-- 
2.11.0



[PATCH v4 3/3] ARM: dts: imx6: Support Savageboard quad

2017-01-03 Thread Milo Kim
Use common board file and support SATA interface additionally.
Specify the dtb file for i.MX6 build.

Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/Makefile  |  1 +
 arch/arm/boot/dts/imx6q-savageboard.dts | 55 +
 2 files changed, 56 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index fb7f904a5235..2f21e59adc1e 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -403,6 +403,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6q-sabreauto.dtb \
imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
+   imx6q-savageboard.dtb \
imx6q-sbc6x.dtb \
imx6q-tbs2910.dtb \
imx6q-ts4900.dtb \
diff --git a/arch/arm/boot/dts/imx6q-savageboard.dts 
b/arch/arm/boot/dts/imx6q-savageboard.dts
new file mode 100644
index ..717ac62fc2cf
--- /dev/null
+++ b/arch/arm/boot/dts/imx6q-savageboard.dts
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Quad";
+   compatible = "poslab,imx6q-savageboard", "fsl,imx6q";
+};
+
+ {
+   status = "okay";
+};
-- 
2.11.0



[PATCH v4 3/3] ARM: dts: imx6: Support Savageboard quad

2017-01-03 Thread Milo Kim
Use common board file and support SATA interface additionally.
Specify the dtb file for i.MX6 build.

Reviewed-by: Fabio Estevam 
Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/Makefile  |  1 +
 arch/arm/boot/dts/imx6q-savageboard.dts | 55 +
 2 files changed, 56 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index fb7f904a5235..2f21e59adc1e 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -403,6 +403,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6q-sabreauto.dtb \
imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
+   imx6q-savageboard.dtb \
imx6q-sbc6x.dtb \
imx6q-tbs2910.dtb \
imx6q-ts4900.dtb \
diff --git a/arch/arm/boot/dts/imx6q-savageboard.dts 
b/arch/arm/boot/dts/imx6q-savageboard.dts
new file mode 100644
index ..717ac62fc2cf
--- /dev/null
+++ b/arch/arm/boot/dts/imx6q-savageboard.dts
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file 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.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Quad";
+   compatible = "poslab,imx6q-savageboard", "fsl,imx6q";
+};
+
+ {
+   status = "okay";
+};
-- 
2.11.0



Re: [PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-01 Thread Milo Kim


On 01/02/2017 04:44 PM, Shawn Guo wrote:

On Mon, Jan 02, 2017 at 04:31:07PM +0900, Milo Kim wrote:


On 01/02/2017 03:52 PM, Shawn Guo wrote:

+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";

"avic, tm097tdh02" is an undocumented compatible.



AVIC TM097TDH02 panel is compatible with Hannstar HSD100PXN1, so I
reuse it. It's the same rule as the usage of imx6q I2C controller.

i2c2: i2c@021a4000 {
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
};


Forgot to ask, is the "avic" Shanghai AVIC Optoelectronics Co., Ltd. as
documented in vendor-prefixes.txt?


Yes, right.

Best regards,
Milo


Re: [PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-01 Thread Milo Kim


On 01/02/2017 04:44 PM, Shawn Guo wrote:

On Mon, Jan 02, 2017 at 04:31:07PM +0900, Milo Kim wrote:


On 01/02/2017 03:52 PM, Shawn Guo wrote:

+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";

"avic, tm097tdh02" is an undocumented compatible.



AVIC TM097TDH02 panel is compatible with Hannstar HSD100PXN1, so I
reuse it. It's the same rule as the usage of imx6q I2C controller.

i2c2: i2c@021a4000 {
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
};


Forgot to ask, is the "avic" Shanghai AVIC Optoelectronics Co., Ltd. as
documented in vendor-prefixes.txt?


Yes, right.

Best regards,
Milo


Re: [PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-01 Thread Milo Kim


On 01/02/2017 04:41 PM, Shawn Guo wrote:

On Mon, Jan 02, 2017 at 04:31:07PM +0900, Milo Kim wrote:


On 01/02/2017 03:52 PM, Shawn Guo wrote:

+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";

"avic, tm097tdh02" is an undocumented compatible.



AVIC TM097TDH02 panel is compatible with Hannstar HSD100PXN1, so I
reuse it. It's the same rule as the usage of imx6q I2C controller.

i2c2: i2c@021a4000 {
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
};


Okay.  Drop the space in the middle of the compatible.


Thanks for all your feedback. Please let me submit the v4 later.

Best regards,
Milo


Re: [PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-01 Thread Milo Kim


On 01/02/2017 04:41 PM, Shawn Guo wrote:

On Mon, Jan 02, 2017 at 04:31:07PM +0900, Milo Kim wrote:


On 01/02/2017 03:52 PM, Shawn Guo wrote:

+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";

"avic, tm097tdh02" is an undocumented compatible.



AVIC TM097TDH02 panel is compatible with Hannstar HSD100PXN1, so I
reuse it. It's the same rule as the usage of imx6q I2C controller.

i2c2: i2c@021a4000 {
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
};


Okay.  Drop the space in the middle of the compatible.


Thanks for all your feedback. Please let me submit the v4 later.

Best regards,
Milo


Re: [PATCH v3 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-01 Thread Milo Kim


On 01/02/2017 04:03 PM, Shawn Guo wrote:

+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";

It seems that 'poslab' should be added to
Documentation/devicetree/bindings/vendor-prefixes.txt


Ah, right. Thanks for the review!

Best regards,
Milo


Re: [PATCH v3 2/3] ARM: dts: imx6: Support Savageboard dual

2017-01-01 Thread Milo Kim


On 01/02/2017 04:03 PM, Shawn Guo wrote:

+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";

It seems that 'poslab' should be added to
Documentation/devicetree/bindings/vendor-prefixes.txt


Ah, right. Thanks for the review!

Best regards,
Milo


Re: [PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-01 Thread Milo Kim


On 01/02/2017 03:52 PM, Shawn Guo wrote:

+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";

"avic, tm097tdh02" is an undocumented compatible.



AVIC TM097TDH02 panel is compatible with Hannstar HSD100PXN1, so I reuse 
it. It's the same rule as the usage of imx6q I2C controller.


i2c2: i2c@021a4000 {
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
};


Best regards,
Milo


Re: [PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2017-01-01 Thread Milo Kim


On 01/02/2017 03:52 PM, Shawn Guo wrote:

+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";

"avic, tm097tdh02" is an undocumented compatible.



AVIC TM097TDH02 panel is compatible with Hannstar HSD100PXN1, so I reuse 
it. It's the same rule as the usage of imx6q I2C controller.


i2c2: i2c@021a4000 {
compatible = "fsl,imx6q-i2c", "fsl,imx21-i2c";
};


Best regards,
Milo


Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation

2016-12-17 Thread Milo Kim

Hi Luis,

On 12/17/2016 01:14 AM, Luis R. Rodriguez wrote:

Milo if sysfs is used can't the old userspace be mapped to use the new
sysfs interface through a wrapper of some sort ? What exactly would be
needed to ensure old userspace will not break?


LP5521 and LP5523 have two ways to load hex code from the userspace - 
the sysfs and firmware I/F. So user program supports both interfaces. 
Even if the firmware I/F is not available, user can still run LED effect 
through the sysfs.


However, LP5562 and LP8501 support only single way which is the firmware 
I/F. So user-space program for LP5562/8501 should be modified if lp55xx 
removes the interface. My idea is


  Phase 1)
  - create sysfs in LP5562 and LP8501
  - use new sysfs inside the firmware I/F loading callback
  - mark the firmware callback as a deprecated interface

  Phase 2)
  - remove the firmware I/F after all user program fixes the interface
(but the problem is how can we get to know when this is done?)

> Why has no one cried
> after the v4.0 custom fallback mechanism breaking ?

Well, I don't know the reason exactly but my guess is they maybe still 
using old kernel.


> How wide spread is this custom userspace ?

Device manufactures in Asia & North America requested lp55xx drivers, 
but I don't know how many vendors uses the firmware I/F. Some vendors 
embeds the binary code inside the driver instead of using user-program.


I understood it's a kind of troublesome work in terms of the 
maintenance. Sorry for that. I hope we have a consensus to resolve it.

Thanks!

Best regards,
Milo


Re: [PATCH 5/5] firmware: add DECLARE_FW_CUSTOM_FALLBACK() annotation

2016-12-17 Thread Milo Kim

Hi Luis,

On 12/17/2016 01:14 AM, Luis R. Rodriguez wrote:

Milo if sysfs is used can't the old userspace be mapped to use the new
sysfs interface through a wrapper of some sort ? What exactly would be
needed to ensure old userspace will not break?


LP5521 and LP5523 have two ways to load hex code from the userspace - 
the sysfs and firmware I/F. So user program supports both interfaces. 
Even if the firmware I/F is not available, user can still run LED effect 
through the sysfs.


However, LP5562 and LP8501 support only single way which is the firmware 
I/F. So user-space program for LP5562/8501 should be modified if lp55xx 
removes the interface. My idea is


  Phase 1)
  - create sysfs in LP5562 and LP8501
  - use new sysfs inside the firmware I/F loading callback
  - mark the firmware callback as a deprecated interface

  Phase 2)
  - remove the firmware I/F after all user program fixes the interface
(but the problem is how can we get to know when this is done?)

> Why has no one cried
> after the v4.0 custom fallback mechanism breaking ?

Well, I don't know the reason exactly but my guess is they maybe still 
using old kernel.


> How wide spread is this custom userspace ?

Device manufactures in Asia & North America requested lp55xx drivers, 
but I don't know how many vendors uses the firmware I/F. Some vendors 
embeds the binary code inside the driver instead of using user-program.


I understood it's a kind of troublesome work in terms of the 
maintenance. Sorry for that. I hope we have a consensus to resolve it.

Thanks!

Best regards,
Milo


Re: [PATCH v2 0/8] power: supply: tps65217: Support USB charger feature

2016-12-17 Thread Milo Kim

On 12/18/2016 01:24 AM, Sebastian Reichel wrote:

patches look fine, but these two patches must be reordered to fix
bisectability. Otherwise after patch 1 the thread is not properly
killed during driver removal.


Thanks for your guidelines. The v3 patchset has been sent.

Best regards,
Milo


Re: [PATCH v2 0/8] power: supply: tps65217: Support USB charger feature

2016-12-17 Thread Milo Kim

On 12/18/2016 01:24 AM, Sebastian Reichel wrote:

patches look fine, but these two patches must be reordered to fix
bisectability. Otherwise after patch 1 the thread is not properly
killed during driver removal.


Thanks for your guidelines. The v3 patchset has been sent.

Best regards,
Milo


[PATCH v3 1/7] power: supply: tps65217: Use 'poll_task' on unloading the module

2016-12-17 Thread Milo Kim
Use the task_struct variable for running polling thread. If polling task
is activated, then use it to stop running thread.
This is a preceding step of supporting two interrupts of TPS65217 charger,
so checking single IRQ number is not appropriate when the module is removed.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 9fd019f9b88c..4fe71abe1bd3 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -200,6 +200,7 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
+   struct task_struct *poll_task;
int irq;
int ret;
 
@@ -250,14 +251,16 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
/* Check current state */
tps65217_charger_irq(irq, charger);
} else {
-   charger->poll_task = kthread_run(tps65217_charger_poll_task,
-   charger, "ktps65217charger");
-   if (IS_ERR(charger->poll_task)) {
-   ret = PTR_ERR(charger->poll_task);
+   poll_task = kthread_run(tps65217_charger_poll_task,
+   charger, "ktps65217charger");
+   if (IS_ERR(poll_task)) {
+   ret = PTR_ERR(poll_task);
dev_err(charger->dev,
"Unable to run kthread err %d\n", ret);
return ret;
}
+
+   charger->poll_task = poll_task;
}
 
return 0;
@@ -267,7 +270,7 @@ static int tps65217_charger_remove(struct platform_device 
*pdev)
 {
struct tps65217_charger *charger = platform_get_drvdata(pdev);
 
-   if (charger->irq == -ENXIO)
+   if (charger->poll_task)
kthread_stop(charger->poll_task);
 
return 0;
-- 
2.11.0



[PATCH v3 5/7] power: supply: tps65217: Use generic name for power supply property

2016-12-17 Thread Milo Kim
Replace 'ac_props' with 'charger_props'.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 5daf36192b8c..79afecafd945 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -50,7 +50,7 @@ struct tps65217_charger {
struct task_struct  *poll_task;
 };
 
-static enum power_supply_property tps65217_ac_props[] = {
+static enum power_supply_property tps65217_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };
 
@@ -191,8 +191,8 @@ static const struct power_supply_desc tps65217_charger_desc 
= {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_ac_get_property,
-   .properties = tps65217_ac_props,
-   .num_properties = ARRAY_SIZE(tps65217_ac_props),
+   .properties = tps65217_charger_props,
+   .num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
 
 static int tps65217_charger_probe(struct platform_device *pdev)
-- 
2.11.0



[PATCH v3 1/7] power: supply: tps65217: Use 'poll_task' on unloading the module

2016-12-17 Thread Milo Kim
Use the task_struct variable for running polling thread. If polling task
is activated, then use it to stop running thread.
This is a preceding step of supporting two interrupts of TPS65217 charger,
so checking single IRQ number is not appropriate when the module is removed.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 9fd019f9b88c..4fe71abe1bd3 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -200,6 +200,7 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
+   struct task_struct *poll_task;
int irq;
int ret;
 
@@ -250,14 +251,16 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
/* Check current state */
tps65217_charger_irq(irq, charger);
} else {
-   charger->poll_task = kthread_run(tps65217_charger_poll_task,
-   charger, "ktps65217charger");
-   if (IS_ERR(charger->poll_task)) {
-   ret = PTR_ERR(charger->poll_task);
+   poll_task = kthread_run(tps65217_charger_poll_task,
+   charger, "ktps65217charger");
+   if (IS_ERR(poll_task)) {
+   ret = PTR_ERR(poll_task);
dev_err(charger->dev,
"Unable to run kthread err %d\n", ret);
return ret;
}
+
+   charger->poll_task = poll_task;
}
 
return 0;
@@ -267,7 +270,7 @@ static int tps65217_charger_remove(struct platform_device 
*pdev)
 {
struct tps65217_charger *charger = platform_get_drvdata(pdev);
 
-   if (charger->irq == -ENXIO)
+   if (charger->poll_task)
kthread_stop(charger->poll_task);
 
return 0;
-- 
2.11.0



[PATCH v3 5/7] power: supply: tps65217: Use generic name for power supply property

2016-12-17 Thread Milo Kim
Replace 'ac_props' with 'charger_props'.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 5daf36192b8c..79afecafd945 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -50,7 +50,7 @@ struct tps65217_charger {
struct task_struct  *poll_task;
 };
 
-static enum power_supply_property tps65217_ac_props[] = {
+static enum power_supply_property tps65217_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };
 
@@ -191,8 +191,8 @@ static const struct power_supply_desc tps65217_charger_desc 
= {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_ac_get_property,
-   .properties = tps65217_ac_props,
-   .num_properties = ARRAY_SIZE(tps65217_ac_props),
+   .properties = tps65217_charger_props,
+   .num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
 
 static int tps65217_charger_probe(struct platform_device *pdev)
-- 
2.11.0



[PATCH v3 7/7] power: supply: tps65217: Use generic charger name

2016-12-17 Thread Milo Kim
"tps65217-charger" is more appropriate name because the driver supports
not only AC but also USB charger.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 63c555601674..29b61e81b385 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -188,7 +188,7 @@ static int tps65217_charger_poll_task(void *data)
 }
 
 static const struct power_supply_desc tps65217_charger_desc = {
-   .name   = "tps65217-ac",
+   .name   = "tps65217-charger",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
-- 
2.11.0



[PATCH v3 6/7] power: supply: tps65217: Use generic name for get_property()

2016-12-17 Thread Milo Kim
Rename it as tps65217_charger_get_property().

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 79afecafd945..63c555601674 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -115,9 +115,9 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return 0;
 }
 
-static int tps65217_ac_get_property(struct power_supply *psy,
-   enum power_supply_property psp,
-   union power_supply_propval *val)
+static int tps65217_charger_get_property(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
 {
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
@@ -190,7 +190,7 @@ static int tps65217_charger_poll_task(void *data)
 static const struct power_supply_desc tps65217_charger_desc = {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
-   .get_property   = tps65217_ac_get_property,
+   .get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
.num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
-- 
2.11.0



[PATCH v3 7/7] power: supply: tps65217: Use generic charger name

2016-12-17 Thread Milo Kim
"tps65217-charger" is more appropriate name because the driver supports
not only AC but also USB charger.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 63c555601674..29b61e81b385 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -188,7 +188,7 @@ static int tps65217_charger_poll_task(void *data)
 }
 
 static const struct power_supply_desc tps65217_charger_desc = {
-   .name   = "tps65217-ac",
+   .name   = "tps65217-charger",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
-- 
2.11.0



[PATCH v3 6/7] power: supply: tps65217: Use generic name for get_property()

2016-12-17 Thread Milo Kim
Rename it as tps65217_charger_get_property().

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 79afecafd945..63c555601674 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -115,9 +115,9 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return 0;
 }
 
-static int tps65217_ac_get_property(struct power_supply *psy,
-   enum power_supply_property psp,
-   union power_supply_propval *val)
+static int tps65217_charger_get_property(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
 {
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
@@ -190,7 +190,7 @@ static int tps65217_charger_poll_task(void *data)
 static const struct power_supply_desc tps65217_charger_desc = {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
-   .get_property   = tps65217_ac_get_property,
+   .get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
.num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
-- 
2.11.0



[PATCH v3 4/7] power: supply: tps65217: Use generic name for power supply structure

2016-12-17 Thread Milo Kim
Replace 'ac' of tps65217_charger structure with 'psy'.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 424a6d32bb6c..5daf36192b8c 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -42,7 +42,7 @@
 struct tps65217_charger {
struct tps65217 *tps;
struct device *dev;
-   struct power_supply *ac;
+   struct power_supply *psy;
 
int online;
int prev_online;
@@ -157,7 +157,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
}
 
if (charger->prev_online != charger->online)
-   power_supply_changed(charger->ac);
+   power_supply_changed(charger->psy);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
if (ret < 0) {
@@ -218,12 +218,12 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
cfg.of_node = pdev->dev.of_node;
cfg.drv_data = charger;
 
-   charger->ac = devm_power_supply_register(>dev,
-_charger_desc,
-);
-   if (IS_ERR(charger->ac)) {
+   charger->psy = devm_power_supply_register(>dev,
+ _charger_desc,
+ );
+   if (IS_ERR(charger->psy)) {
dev_err(>dev, "failed: power supply register\n");
-   return PTR_ERR(charger->ac);
+   return PTR_ERR(charger->psy);
}
 
irq[0] = platform_get_irq_byname(pdev, "USB");
-- 
2.11.0



[PATCH v3 0/7] power: supply: tps65217: Support USB charger feature

2016-12-17 Thread Milo Kim
TPS65217 device supports two charger inputs - AC and USB.
Currently, only AC charger is supported. This patch-set adds USB charger 
feature. Tested on Beaglebone black.

Patch 1: Preceding step of the main patch
Patch 2: Main patch
Patch 3 ~ 7: Naming changes for generic power supply class structure

v3:
  Reorder the patches to avoid bisection issue

v2:
  Regenerate the patchset for better code review

Milo Kim (7):
  power: supply: tps65217: Use 'poll_task' on unloading the module
  power: supply: tps65217: Support USB charger interrupt
  power: supply: tps65217: Use generic name for charger online
  power: supply: tps65217: Use generic name for power supply structure
  power: supply: tps65217: Use generic name for power supply property
  power: supply: tps65217: Use generic name for get_property()
  power: supply: tps65217: Use generic charger name

 drivers/power/supply/tps65217_charger.c | 99 ++---
 1 file changed, 53 insertions(+), 46 deletions(-)

-- 
2.11.0



[PATCH v3 3/7] power: supply: tps65217: Use generic name for charger online

2016-12-17 Thread Milo Kim
This driver supports AC and USB chargers. Generic name is preferred.
Replace 'ac_online' with 'online'.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 482ee9f9edff..424a6d32bb6c 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -44,8 +44,8 @@ struct tps65217_charger {
struct device *dev;
struct power_supply *ac;
 
-   int ac_online;
-   int prev_ac_online;
+   int online;
+   int prev_online;
 
struct task_struct  *poll_task;
 };
@@ -95,7 +95,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
int ret;
 
/* charger already enabled */
-   if (charger->ac_online)
+   if (charger->online)
return 0;
 
dev_dbg(charger->dev, "%s: enable charging\n", __func__);
@@ -110,7 +110,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return ret;
}
 
-   charger->ac_online = 1;
+   charger->online = 1;
 
return 0;
 }
@@ -122,7 +122,7 @@ static int tps65217_ac_get_property(struct power_supply 
*psy,
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
if (psp == POWER_SUPPLY_PROP_ONLINE) {
-   val->intval = charger->ac_online;
+   val->intval = charger->online;
return 0;
}
return -EINVAL;
@@ -133,7 +133,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
int ret, val;
struct tps65217_charger *charger = dev;
 
-   charger->prev_ac_online = charger->ac_online;
+   charger->prev_online = charger->online;
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_STATUS, );
if (ret < 0) {
@@ -153,10 +153,10 @@ static irqreturn_t tps65217_charger_irq(int irq, void 
*dev)
return IRQ_HANDLED;
}
} else {
-   charger->ac_online = 0;
+   charger->online = 0;
}
 
-   if (charger->prev_ac_online != charger->ac_online)
+   if (charger->prev_online != charger->online)
power_supply_changed(charger->ac);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
-- 
2.11.0



[PATCH v3 2/7] power: supply: tps65217: Support USB charger interrupt

2016-12-17 Thread Milo Kim
TPS65217 has two charger interrupts - AC and USB power status change.

Interrupt number in the TPS65217 driver data:
  IRQ number is only used on requesting the interrupt, so no need to keep
  it inside the driver data.

Interrupt handler:
  Check not only AC but also USB charger status.
  In both cases, enable charging operation.

Interrupt request:
  If an interrupt number is invalid, then use legacy polling thread.
  Otherwise, create IRQ threads to handle AC and USB charger event.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 52 ++---
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 4fe71abe1bd3..482ee9f9edff 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+#define CHARGER_STATUS_PRESENT (TPS65217_STATUS_ACPWR | TPS65217_STATUS_USBPWR)
+#define NUM_CHARGER_IRQS   2
 #define POLL_INTERVAL  (HZ * 2)
 
 struct tps65217_charger {
@@ -46,8 +48,6 @@ struct tps65217_charger {
int prev_ac_online;
 
struct task_struct  *poll_task;
-
-   int irq;
 };
 
 static enum power_supply_property tps65217_ac_props[] = {
@@ -144,8 +144,8 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
 
dev_dbg(charger->dev, "%s: 0x%x\n", __func__, val);
 
-   /* check for AC status bit */
-   if (val & TPS65217_STATUS_ACPWR) {
+   /* check for charger status bit */
+   if (val & CHARGER_STATUS_PRESENT) {
ret = tps65217_enable_charging(charger);
if (ret) {
dev_err(charger->dev,
@@ -201,8 +201,9 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
struct task_struct *poll_task;
-   int irq;
+   int irq[NUM_CHARGER_IRQS];
int ret;
+   int i;
 
dev_dbg(>dev, "%s\n", __func__);
 
@@ -225,10 +226,8 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return PTR_ERR(charger->ac);
}
 
-   irq = platform_get_irq_byname(pdev, "AC");
-   if (irq < 0)
-   irq = -ENXIO;
-   charger->irq = irq;
+   irq[0] = platform_get_irq_byname(pdev, "USB");
+   irq[1] = platform_get_irq_byname(pdev, "AC");
 
ret = tps65217_config_charger(charger);
if (ret < 0) {
@@ -236,21 +235,8 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return ret;
}
 
-   if (irq != -ENXIO) {
-   ret = devm_request_threaded_irq(>dev, irq, NULL,
-   tps65217_charger_irq,
-   0, "tps65217-charger",
-   charger);
-   if (ret) {
-   dev_err(charger->dev,
-   "Unable to register irq %d err %d\n", irq,
-   ret);
-   return ret;
-   }
-
-   /* Check current state */
-   tps65217_charger_irq(irq, charger);
-   } else {
+   /* Create a polling thread if an interrupt is invalid */
+   if (irq[0] < 0 || irq[1] < 0) {
poll_task = kthread_run(tps65217_charger_poll_task,
charger, "ktps65217charger");
if (IS_ERR(poll_task)) {
@@ -261,6 +247,24 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
}
 
charger->poll_task = poll_task;
+   return 0;
+   }
+
+   /* Create IRQ threads for charger interrupts */
+   for (i = 0; i < NUM_CHARGER_IRQS; i++) {
+   ret = devm_request_threaded_irq(>dev, irq[i], NULL,
+   tps65217_charger_irq,
+   0, "tps65217-charger",
+   charger);
+   if (ret) {
+   dev_err(charger->dev,
+   "Unable to register irq %d err %d\n", irq[i],
+   ret);
+   return ret;
+   }
+
+   /* Check current state */
+   tps65217_charger_irq(-1, charger);
}
 
return 0;
-- 
2.11.0



[PATCH v3 4/7] power: supply: tps65217: Use generic name for power supply structure

2016-12-17 Thread Milo Kim
Replace 'ac' of tps65217_charger structure with 'psy'.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 424a6d32bb6c..5daf36192b8c 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -42,7 +42,7 @@
 struct tps65217_charger {
struct tps65217 *tps;
struct device *dev;
-   struct power_supply *ac;
+   struct power_supply *psy;
 
int online;
int prev_online;
@@ -157,7 +157,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
}
 
if (charger->prev_online != charger->online)
-   power_supply_changed(charger->ac);
+   power_supply_changed(charger->psy);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
if (ret < 0) {
@@ -218,12 +218,12 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
cfg.of_node = pdev->dev.of_node;
cfg.drv_data = charger;
 
-   charger->ac = devm_power_supply_register(>dev,
-_charger_desc,
-);
-   if (IS_ERR(charger->ac)) {
+   charger->psy = devm_power_supply_register(>dev,
+ _charger_desc,
+ );
+   if (IS_ERR(charger->psy)) {
dev_err(>dev, "failed: power supply register\n");
-   return PTR_ERR(charger->ac);
+   return PTR_ERR(charger->psy);
}
 
irq[0] = platform_get_irq_byname(pdev, "USB");
-- 
2.11.0



[PATCH v3 0/7] power: supply: tps65217: Support USB charger feature

2016-12-17 Thread Milo Kim
TPS65217 device supports two charger inputs - AC and USB.
Currently, only AC charger is supported. This patch-set adds USB charger 
feature. Tested on Beaglebone black.

Patch 1: Preceding step of the main patch
Patch 2: Main patch
Patch 3 ~ 7: Naming changes for generic power supply class structure

v3:
  Reorder the patches to avoid bisection issue

v2:
  Regenerate the patchset for better code review

Milo Kim (7):
  power: supply: tps65217: Use 'poll_task' on unloading the module
  power: supply: tps65217: Support USB charger interrupt
  power: supply: tps65217: Use generic name for charger online
  power: supply: tps65217: Use generic name for power supply structure
  power: supply: tps65217: Use generic name for power supply property
  power: supply: tps65217: Use generic name for get_property()
  power: supply: tps65217: Use generic charger name

 drivers/power/supply/tps65217_charger.c | 99 ++---
 1 file changed, 53 insertions(+), 46 deletions(-)

-- 
2.11.0



[PATCH v3 3/7] power: supply: tps65217: Use generic name for charger online

2016-12-17 Thread Milo Kim
This driver supports AC and USB chargers. Generic name is preferred.
Replace 'ac_online' with 'online'.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 482ee9f9edff..424a6d32bb6c 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -44,8 +44,8 @@ struct tps65217_charger {
struct device *dev;
struct power_supply *ac;
 
-   int ac_online;
-   int prev_ac_online;
+   int online;
+   int prev_online;
 
struct task_struct  *poll_task;
 };
@@ -95,7 +95,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
int ret;
 
/* charger already enabled */
-   if (charger->ac_online)
+   if (charger->online)
return 0;
 
dev_dbg(charger->dev, "%s: enable charging\n", __func__);
@@ -110,7 +110,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return ret;
}
 
-   charger->ac_online = 1;
+   charger->online = 1;
 
return 0;
 }
@@ -122,7 +122,7 @@ static int tps65217_ac_get_property(struct power_supply 
*psy,
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
if (psp == POWER_SUPPLY_PROP_ONLINE) {
-   val->intval = charger->ac_online;
+   val->intval = charger->online;
return 0;
}
return -EINVAL;
@@ -133,7 +133,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
int ret, val;
struct tps65217_charger *charger = dev;
 
-   charger->prev_ac_online = charger->ac_online;
+   charger->prev_online = charger->online;
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_STATUS, );
if (ret < 0) {
@@ -153,10 +153,10 @@ static irqreturn_t tps65217_charger_irq(int irq, void 
*dev)
return IRQ_HANDLED;
}
} else {
-   charger->ac_online = 0;
+   charger->online = 0;
}
 
-   if (charger->prev_ac_online != charger->ac_online)
+   if (charger->prev_online != charger->online)
power_supply_changed(charger->ac);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
-- 
2.11.0



[PATCH v3 2/7] power: supply: tps65217: Support USB charger interrupt

2016-12-17 Thread Milo Kim
TPS65217 has two charger interrupts - AC and USB power status change.

Interrupt number in the TPS65217 driver data:
  IRQ number is only used on requesting the interrupt, so no need to keep
  it inside the driver data.

Interrupt handler:
  Check not only AC but also USB charger status.
  In both cases, enable charging operation.

Interrupt request:
  If an interrupt number is invalid, then use legacy polling thread.
  Otherwise, create IRQ threads to handle AC and USB charger event.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 52 ++---
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 4fe71abe1bd3..482ee9f9edff 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+#define CHARGER_STATUS_PRESENT (TPS65217_STATUS_ACPWR | TPS65217_STATUS_USBPWR)
+#define NUM_CHARGER_IRQS   2
 #define POLL_INTERVAL  (HZ * 2)
 
 struct tps65217_charger {
@@ -46,8 +48,6 @@ struct tps65217_charger {
int prev_ac_online;
 
struct task_struct  *poll_task;
-
-   int irq;
 };
 
 static enum power_supply_property tps65217_ac_props[] = {
@@ -144,8 +144,8 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
 
dev_dbg(charger->dev, "%s: 0x%x\n", __func__, val);
 
-   /* check for AC status bit */
-   if (val & TPS65217_STATUS_ACPWR) {
+   /* check for charger status bit */
+   if (val & CHARGER_STATUS_PRESENT) {
ret = tps65217_enable_charging(charger);
if (ret) {
dev_err(charger->dev,
@@ -201,8 +201,9 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
struct task_struct *poll_task;
-   int irq;
+   int irq[NUM_CHARGER_IRQS];
int ret;
+   int i;
 
dev_dbg(>dev, "%s\n", __func__);
 
@@ -225,10 +226,8 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return PTR_ERR(charger->ac);
}
 
-   irq = platform_get_irq_byname(pdev, "AC");
-   if (irq < 0)
-   irq = -ENXIO;
-   charger->irq = irq;
+   irq[0] = platform_get_irq_byname(pdev, "USB");
+   irq[1] = platform_get_irq_byname(pdev, "AC");
 
ret = tps65217_config_charger(charger);
if (ret < 0) {
@@ -236,21 +235,8 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return ret;
}
 
-   if (irq != -ENXIO) {
-   ret = devm_request_threaded_irq(>dev, irq, NULL,
-   tps65217_charger_irq,
-   0, "tps65217-charger",
-   charger);
-   if (ret) {
-   dev_err(charger->dev,
-   "Unable to register irq %d err %d\n", irq,
-   ret);
-   return ret;
-   }
-
-   /* Check current state */
-   tps65217_charger_irq(irq, charger);
-   } else {
+   /* Create a polling thread if an interrupt is invalid */
+   if (irq[0] < 0 || irq[1] < 0) {
poll_task = kthread_run(tps65217_charger_poll_task,
charger, "ktps65217charger");
if (IS_ERR(poll_task)) {
@@ -261,6 +247,24 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
}
 
charger->poll_task = poll_task;
+   return 0;
+   }
+
+   /* Create IRQ threads for charger interrupts */
+   for (i = 0; i < NUM_CHARGER_IRQS; i++) {
+   ret = devm_request_threaded_irq(>dev, irq[i], NULL,
+   tps65217_charger_irq,
+   0, "tps65217-charger",
+   charger);
+   if (ret) {
+   dev_err(charger->dev,
+   "Unable to register irq %d err %d\n", irq[i],
+   ret);
+   return ret;
+   }
+
+   /* Check current state */
+   tps65217_charger_irq(-1, charger);
}
 
return 0;
-- 
2.11.0



Re: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism

2016-12-13 Thread Milo Kim

Hi Jacek,

On 12/13/2016 06:44 PM, Jacek Anaszewski wrote:


Could you please verify if leds-lp55xx-common.c driver
really needs a custom firmware loading fallback mechanism?


Thanks for sharing this. The lp55xx-common uses this mechanism to load 
and run LED effect manually, so this could be a misuse case.

I think the right solution is providing device attributes.

At this moment, four drivers use lp55xx-common code.

- lp5521, lp5523: OK if we do not support FW loading fallback mechanism
- lp5562, lp8501: need to create additional sysfs alternatively.

However, we should be careful because I'm not sure this modification 
will generate the regression (breaking the user-space) or not.


Best regards,
Milo


Re: [PATCH 4/5] firmware: add SmPL report for custom fallback mechanism

2016-12-13 Thread Milo Kim

Hi Jacek,

On 12/13/2016 06:44 PM, Jacek Anaszewski wrote:


Could you please verify if leds-lp55xx-common.c driver
really needs a custom firmware loading fallback mechanism?


Thanks for sharing this. The lp55xx-common uses this mechanism to load 
and run LED effect manually, so this could be a misuse case.

I think the right solution is providing device attributes.

At this moment, four drivers use lp55xx-common code.

- lp5521, lp5523: OK if we do not support FW loading fallback mechanism
- lp5562, lp8501: need to create additional sysfs alternatively.

However, we should be careful because I'm not sure this modification 
will generate the regression (breaking the user-space) or not.


Best regards,
Milo


Re: [PATCH 2/4] dt-bindings: mfd: Remove TPS65217 interrupts

2016-12-12 Thread Milo Kim

On 12/13/2016 02:25 AM, Rob Herring wrote:

On Fri, Dec 09, 2016 at 03:28:31PM +0900, Milo Kim wrote:

Interrupt numbers are from the datasheet, so no need to keep them in
the ABI. Use the number in the DT file.

I don't see the purpose of ripping this out. The headers have always
been for convienence, not whether the values come from the datasheet or
not.


My understanding is it's a same rule as other interrupt controllers.
I'd like to have Arnd's opinion for this.

Best regards,
Milo


Re: [PATCH 2/4] dt-bindings: mfd: Remove TPS65217 interrupts

2016-12-12 Thread Milo Kim

On 12/13/2016 02:25 AM, Rob Herring wrote:

On Fri, Dec 09, 2016 at 03:28:31PM +0900, Milo Kim wrote:

Interrupt numbers are from the datasheet, so no need to keep them in
the ABI. Use the number in the DT file.

I don't see the purpose of ripping this out. The headers have always
been for convienence, not whether the values come from the datasheet or
not.


My understanding is it's a same rule as other interrupt controllers.
I'd like to have Arnd's opinion for this.

Best regards,
Milo


Re: [PATCH] ARM: dts: sun8i: Support DTB build for NanoPi M1

2016-12-12 Thread Milo Kim

On 12/13/2016 12:49 AM, Maxime Ripard wrote:

Hi,

On Fri, Dec 09, 2016 at 10:47:58AM +0900, Milo Kim wrote:

The commit 10efbf5f1633 introduced NanoPi M1 board but it's missing in
Allwinner H3 DTB build.

Signed-off-by: Milo Kim <woogyom@gmail.com>


checkpatch reports an error on this one (commit format), please fix
and resend.


Thanks! I need to run the script automatically prior to sending patches.

Best regards,
Milo


Re: [PATCH] ARM: dts: sun8i: Support DTB build for NanoPi M1

2016-12-12 Thread Milo Kim

On 12/13/2016 12:49 AM, Maxime Ripard wrote:

Hi,

On Fri, Dec 09, 2016 at 10:47:58AM +0900, Milo Kim wrote:

The commit 10efbf5f1633 introduced NanoPi M1 board but it's missing in
Allwinner H3 DTB build.

Signed-off-by: Milo Kim 


checkpatch reports an error on this one (commit format), please fix
and resend.


Thanks! I need to run the script automatically prior to sending patches.

Best regards,
Milo


[PATCH resend] ARM: dts: sun8i: Support DTB build for NanoPi M1

2016-12-12 Thread Milo Kim
The commit 10efbf5f1633 ("ARM: dts: sun8i: Add dts file for NanoPi M1 SBC")
introduced NanoPi M1 board but it's missing in Allwinner H3 DTB build.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb..359041f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -845,6 +845,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
+   sun8i-h3-nanopi-m1.dtb  \
sun8i-h3-nanopi-neo.dtb \
sun8i-h3-orangepi-2.dtb \
sun8i-h3-orangepi-lite.dtb \
-- 
2.9.3



[PATCH resend] ARM: dts: sun8i: Support DTB build for NanoPi M1

2016-12-12 Thread Milo Kim
The commit 10efbf5f1633 ("ARM: dts: sun8i: Add dts file for NanoPi M1 SBC")
introduced NanoPi M1 board but it's missing in Allwinner H3 DTB build.

Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb..359041f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -845,6 +845,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
+   sun8i-h3-nanopi-m1.dtb  \
sun8i-h3-nanopi-neo.dtb \
sun8i-h3-orangepi-2.dtb \
sun8i-h3-orangepi-lite.dtb \
-- 
2.9.3



[PATCH v2 2/8] power: supply: tps65217: Use 'poll_task' on unloading the module

2016-12-08 Thread Milo Kim
TPS65217 has two interrupt numbers so checking single IRQ number is not
appropriate when the module is removed.
Use the task_struct variable for running polling thread. If polling task
is activated, then use it to stop running thread.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 2000e59..55371d6 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -202,6 +202,7 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
+   struct task_struct *poll_task;
int irq[NUM_CHARGER_IRQS];
int ret;
int i;
@@ -238,15 +239,16 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
 
/* Create a polling thread if an interrupt is invalid */
if (irq[0] < 0 || irq[1] < 0) {
-   charger->poll_task = kthread_run(tps65217_charger_poll_task,
-   charger, "ktps65217charger");
-   if (IS_ERR(charger->poll_task)) {
-   ret = PTR_ERR(charger->poll_task);
+   poll_task = kthread_run(tps65217_charger_poll_task,
+   charger, "ktps65217charger");
+   if (IS_ERR(poll_task)) {
+   ret = PTR_ERR(poll_task);
dev_err(charger->dev,
"Unable to run kthread err %d\n", ret);
return ret;
}
 
+   charger->poll_task = poll_task;
return 0;
}
 
@@ -274,7 +276,7 @@ static int tps65217_charger_remove(struct platform_device 
*pdev)
 {
struct tps65217_charger *charger = platform_get_drvdata(pdev);
 
-   if (charger->irq == -ENXIO)
+   if (charger->poll_task)
kthread_stop(charger->poll_task);
 
return 0;
-- 
2.9.3



[PATCH v2 7/8] power: supply: tps65217: Use generic name for get_property()

2016-12-08 Thread Milo Kim
Rename it as tps65217_charger_get_property().

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 79afeca..63c5556 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -115,9 +115,9 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return 0;
 }
 
-static int tps65217_ac_get_property(struct power_supply *psy,
-   enum power_supply_property psp,
-   union power_supply_propval *val)
+static int tps65217_charger_get_property(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
 {
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
@@ -190,7 +190,7 @@ static int tps65217_charger_poll_task(void *data)
 static const struct power_supply_desc tps65217_charger_desc = {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
-   .get_property   = tps65217_ac_get_property,
+   .get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
.num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
-- 
2.9.3



[PATCH v2 5/8] power: supply: tps65217: Use generic name for power supply structure

2016-12-08 Thread Milo Kim
Replace 'ac' of tps65217_charger structure with 'psy'.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 424a6d3..5daf361 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -42,7 +42,7 @@
 struct tps65217_charger {
struct tps65217 *tps;
struct device *dev;
-   struct power_supply *ac;
+   struct power_supply *psy;
 
int online;
int prev_online;
@@ -157,7 +157,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
}
 
if (charger->prev_online != charger->online)
-   power_supply_changed(charger->ac);
+   power_supply_changed(charger->psy);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
if (ret < 0) {
@@ -218,12 +218,12 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
cfg.of_node = pdev->dev.of_node;
cfg.drv_data = charger;
 
-   charger->ac = devm_power_supply_register(>dev,
-_charger_desc,
-);
-   if (IS_ERR(charger->ac)) {
+   charger->psy = devm_power_supply_register(>dev,
+ _charger_desc,
+ );
+   if (IS_ERR(charger->psy)) {
dev_err(>dev, "failed: power supply register\n");
-   return PTR_ERR(charger->ac);
+   return PTR_ERR(charger->psy);
}
 
irq[0] = platform_get_irq_byname(pdev, "USB");
-- 
2.9.3



[PATCH v2 2/8] power: supply: tps65217: Use 'poll_task' on unloading the module

2016-12-08 Thread Milo Kim
TPS65217 has two interrupt numbers so checking single IRQ number is not
appropriate when the module is removed.
Use the task_struct variable for running polling thread. If polling task
is activated, then use it to stop running thread.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 2000e59..55371d6 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -202,6 +202,7 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
+   struct task_struct *poll_task;
int irq[NUM_CHARGER_IRQS];
int ret;
int i;
@@ -238,15 +239,16 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
 
/* Create a polling thread if an interrupt is invalid */
if (irq[0] < 0 || irq[1] < 0) {
-   charger->poll_task = kthread_run(tps65217_charger_poll_task,
-   charger, "ktps65217charger");
-   if (IS_ERR(charger->poll_task)) {
-   ret = PTR_ERR(charger->poll_task);
+   poll_task = kthread_run(tps65217_charger_poll_task,
+   charger, "ktps65217charger");
+   if (IS_ERR(poll_task)) {
+   ret = PTR_ERR(poll_task);
dev_err(charger->dev,
"Unable to run kthread err %d\n", ret);
return ret;
}
 
+   charger->poll_task = poll_task;
return 0;
}
 
@@ -274,7 +276,7 @@ static int tps65217_charger_remove(struct platform_device 
*pdev)
 {
struct tps65217_charger *charger = platform_get_drvdata(pdev);
 
-   if (charger->irq == -ENXIO)
+   if (charger->poll_task)
kthread_stop(charger->poll_task);
 
return 0;
-- 
2.9.3



[PATCH v2 7/8] power: supply: tps65217: Use generic name for get_property()

2016-12-08 Thread Milo Kim
Rename it as tps65217_charger_get_property().

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 79afeca..63c5556 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -115,9 +115,9 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return 0;
 }
 
-static int tps65217_ac_get_property(struct power_supply *psy,
-   enum power_supply_property psp,
-   union power_supply_propval *val)
+static int tps65217_charger_get_property(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
 {
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
@@ -190,7 +190,7 @@ static int tps65217_charger_poll_task(void *data)
 static const struct power_supply_desc tps65217_charger_desc = {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
-   .get_property   = tps65217_ac_get_property,
+   .get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
.num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
-- 
2.9.3



[PATCH v2 5/8] power: supply: tps65217: Use generic name for power supply structure

2016-12-08 Thread Milo Kim
Replace 'ac' of tps65217_charger structure with 'psy'.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 424a6d3..5daf361 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -42,7 +42,7 @@
 struct tps65217_charger {
struct tps65217 *tps;
struct device *dev;
-   struct power_supply *ac;
+   struct power_supply *psy;
 
int online;
int prev_online;
@@ -157,7 +157,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
}
 
if (charger->prev_online != charger->online)
-   power_supply_changed(charger->ac);
+   power_supply_changed(charger->psy);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
if (ret < 0) {
@@ -218,12 +218,12 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
cfg.of_node = pdev->dev.of_node;
cfg.drv_data = charger;
 
-   charger->ac = devm_power_supply_register(>dev,
-_charger_desc,
-);
-   if (IS_ERR(charger->ac)) {
+   charger->psy = devm_power_supply_register(>dev,
+ _charger_desc,
+ );
+   if (IS_ERR(charger->psy)) {
dev_err(>dev, "failed: power supply register\n");
-   return PTR_ERR(charger->ac);
+   return PTR_ERR(charger->psy);
}
 
irq[0] = platform_get_irq_byname(pdev, "USB");
-- 
2.9.3



[PATCH v2 0/8] power: supply: tps65217: Support USB charger feature

2016-12-08 Thread Milo Kim
TPS65217 device supports two charger inputs - AC and USB.
Currently, only AC charger is supported. This patch-set adds USB charger 
feature. Tested on Beaglebone black.

Patch 1: Main patch
Patch 2, 3: Clean up for charger driver data
Patch 4 ~ 8: Naming changes for generic power supply class structure

v2:
  Regenerate the patchset for better code review

Milo Kim (8):
  power: supply: tps65217: Support USB charger interrupt
  power: supply: tps65217: Use 'poll_task' on unloading the module
  power: supply: tps65217: Remove IRQ data from driver data
  power: supply: tps65217: Use generic name for charger online
  power: supply: tps65217: Use generic name for power supply structure
  power: supply: tps65217: Use generic name for power supply property
  power: supply: tps65217: Use generic name for get_property()
  power: supply: tps65217: Use generic charger name

 drivers/power/supply/tps65217_charger.c | 99 ++---
 1 file changed, 53 insertions(+), 46 deletions(-)

-- 
2.9.3



[PATCH v2 8/8] power: supply: tps65217: Use generic charger name

2016-12-08 Thread Milo Kim
"tps65217-charger" is more appropriate name because the driver supports
not only AC but also USB charger.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 63c5556..29b61e8 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -188,7 +188,7 @@ static int tps65217_charger_poll_task(void *data)
 }
 
 static const struct power_supply_desc tps65217_charger_desc = {
-   .name   = "tps65217-ac",
+   .name   = "tps65217-charger",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
-- 
2.9.3



[PATCH v2 0/8] power: supply: tps65217: Support USB charger feature

2016-12-08 Thread Milo Kim
TPS65217 device supports two charger inputs - AC and USB.
Currently, only AC charger is supported. This patch-set adds USB charger 
feature. Tested on Beaglebone black.

Patch 1: Main patch
Patch 2, 3: Clean up for charger driver data
Patch 4 ~ 8: Naming changes for generic power supply class structure

v2:
  Regenerate the patchset for better code review

Milo Kim (8):
  power: supply: tps65217: Support USB charger interrupt
  power: supply: tps65217: Use 'poll_task' on unloading the module
  power: supply: tps65217: Remove IRQ data from driver data
  power: supply: tps65217: Use generic name for charger online
  power: supply: tps65217: Use generic name for power supply structure
  power: supply: tps65217: Use generic name for power supply property
  power: supply: tps65217: Use generic name for get_property()
  power: supply: tps65217: Use generic charger name

 drivers/power/supply/tps65217_charger.c | 99 ++---
 1 file changed, 53 insertions(+), 46 deletions(-)

-- 
2.9.3



[PATCH v2 8/8] power: supply: tps65217: Use generic charger name

2016-12-08 Thread Milo Kim
"tps65217-charger" is more appropriate name because the driver supports
not only AC but also USB charger.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 63c5556..29b61e8 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -188,7 +188,7 @@ static int tps65217_charger_poll_task(void *data)
 }
 
 static const struct power_supply_desc tps65217_charger_desc = {
-   .name   = "tps65217-ac",
+   .name   = "tps65217-charger",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_charger_get_property,
.properties = tps65217_charger_props,
-- 
2.9.3



[PATCH v2 1/8] power: supply: tps65217: Support USB charger interrupt

2016-12-08 Thread Milo Kim
TPS65217 has two charger interrupts - AC or USB power status change.

Interrupt handler:
  Check not only AC but also USB charger status.
  In both cases, enable charging operation.

Interrupt request:
  If an interrupt number is invalid, then use legacy polling thread.
  Otherwise, create IRQ threads to handle AC and USB charger event.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 47 +++--
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 9fd019f..2000e59 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+#define CHARGER_STATUS_PRESENT (TPS65217_STATUS_ACPWR | TPS65217_STATUS_USBPWR)
+#define NUM_CHARGER_IRQS   2
 #define POLL_INTERVAL  (HZ * 2)
 
 struct tps65217_charger {
@@ -144,8 +146,8 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
 
dev_dbg(charger->dev, "%s: 0x%x\n", __func__, val);
 
-   /* check for AC status bit */
-   if (val & TPS65217_STATUS_ACPWR) {
+   /* check for charger status bit */
+   if (val & CHARGER_STATUS_PRESENT) {
ret = tps65217_enable_charging(charger);
if (ret) {
dev_err(charger->dev,
@@ -200,8 +202,9 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
-   int irq;
+   int irq[NUM_CHARGER_IRQS];
int ret;
+   int i;
 
dev_dbg(>dev, "%s\n", __func__);
 
@@ -224,10 +227,8 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return PTR_ERR(charger->ac);
}
 
-   irq = platform_get_irq_byname(pdev, "AC");
-   if (irq < 0)
-   irq = -ENXIO;
-   charger->irq = irq;
+   irq[0] = platform_get_irq_byname(pdev, "USB");
+   irq[1] = platform_get_irq_byname(pdev, "AC");
 
ret = tps65217_config_charger(charger);
if (ret < 0) {
@@ -235,29 +236,35 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return ret;
}
 
-   if (irq != -ENXIO) {
-   ret = devm_request_threaded_irq(>dev, irq, NULL,
+   /* Create a polling thread if an interrupt is invalid */
+   if (irq[0] < 0 || irq[1] < 0) {
+   charger->poll_task = kthread_run(tps65217_charger_poll_task,
+   charger, "ktps65217charger");
+   if (IS_ERR(charger->poll_task)) {
+   ret = PTR_ERR(charger->poll_task);
+   dev_err(charger->dev,
+   "Unable to run kthread err %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+   }
+
+   /* Create IRQ threads for charger interrupts */
+   for (i = 0; i < NUM_CHARGER_IRQS; i++) {
+   ret = devm_request_threaded_irq(>dev, irq[i], NULL,
tps65217_charger_irq,
0, "tps65217-charger",
charger);
if (ret) {
dev_err(charger->dev,
-   "Unable to register irq %d err %d\n", irq,
+   "Unable to register irq %d err %d\n", irq[i],
ret);
return ret;
}
 
/* Check current state */
-   tps65217_charger_irq(irq, charger);
-   } else {
-   charger->poll_task = kthread_run(tps65217_charger_poll_task,
-   charger, "ktps65217charger");
-   if (IS_ERR(charger->poll_task)) {
-   ret = PTR_ERR(charger->poll_task);
-   dev_err(charger->dev,
-   "Unable to run kthread err %d\n", ret);
-   return ret;
-   }
+   tps65217_charger_irq(-1, charger);
}
 
return 0;
-- 
2.9.3



[PATCH v2 4/8] power: supply: tps65217: Use generic name for charger online

2016-12-08 Thread Milo Kim
This driver supports AC and USB chargers. Generic name is preferred.
Replace 'ac_online' with 'online'.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 482ee9f..424a6d3 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -44,8 +44,8 @@ struct tps65217_charger {
struct device *dev;
struct power_supply *ac;
 
-   int ac_online;
-   int prev_ac_online;
+   int online;
+   int prev_online;
 
struct task_struct  *poll_task;
 };
@@ -95,7 +95,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
int ret;
 
/* charger already enabled */
-   if (charger->ac_online)
+   if (charger->online)
return 0;
 
dev_dbg(charger->dev, "%s: enable charging\n", __func__);
@@ -110,7 +110,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return ret;
}
 
-   charger->ac_online = 1;
+   charger->online = 1;
 
return 0;
 }
@@ -122,7 +122,7 @@ static int tps65217_ac_get_property(struct power_supply 
*psy,
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
if (psp == POWER_SUPPLY_PROP_ONLINE) {
-   val->intval = charger->ac_online;
+   val->intval = charger->online;
return 0;
}
return -EINVAL;
@@ -133,7 +133,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
int ret, val;
struct tps65217_charger *charger = dev;
 
-   charger->prev_ac_online = charger->ac_online;
+   charger->prev_online = charger->online;
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_STATUS, );
if (ret < 0) {
@@ -153,10 +153,10 @@ static irqreturn_t tps65217_charger_irq(int irq, void 
*dev)
return IRQ_HANDLED;
}
} else {
-   charger->ac_online = 0;
+   charger->online = 0;
}
 
-   if (charger->prev_ac_online != charger->ac_online)
+   if (charger->prev_online != charger->online)
power_supply_changed(charger->ac);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
-- 
2.9.3



[PATCH v2 3/8] power: supply: tps65217: Remove IRQ data from driver data

2016-12-08 Thread Milo Kim
IRQ number is only used on requesting the interrupt, so no need to keep
it inside the driver data.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 55371d6..482ee9f 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -48,8 +48,6 @@ struct tps65217_charger {
int prev_ac_online;
 
struct task_struct  *poll_task;
-
-   int irq;
 };
 
 static enum power_supply_property tps65217_ac_props[] = {
-- 
2.9.3



[PATCH v2 6/8] power: supply: tps65217: Use generic name for power supply property

2016-12-08 Thread Milo Kim
Replace 'ac_props' with 'charger_props'.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 5daf361..79afeca 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -50,7 +50,7 @@ struct tps65217_charger {
struct task_struct  *poll_task;
 };
 
-static enum power_supply_property tps65217_ac_props[] = {
+static enum power_supply_property tps65217_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };
 
@@ -191,8 +191,8 @@ static const struct power_supply_desc tps65217_charger_desc 
= {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_ac_get_property,
-   .properties = tps65217_ac_props,
-   .num_properties = ARRAY_SIZE(tps65217_ac_props),
+   .properties = tps65217_charger_props,
+   .num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
 
 static int tps65217_charger_probe(struct platform_device *pdev)
-- 
2.9.3



[PATCH v2 1/8] power: supply: tps65217: Support USB charger interrupt

2016-12-08 Thread Milo Kim
TPS65217 has two charger interrupts - AC or USB power status change.

Interrupt handler:
  Check not only AC but also USB charger status.
  In both cases, enable charging operation.

Interrupt request:
  If an interrupt number is invalid, then use legacy polling thread.
  Otherwise, create IRQ threads to handle AC and USB charger event.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 47 +++--
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 9fd019f..2000e59 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+#define CHARGER_STATUS_PRESENT (TPS65217_STATUS_ACPWR | TPS65217_STATUS_USBPWR)
+#define NUM_CHARGER_IRQS   2
 #define POLL_INTERVAL  (HZ * 2)
 
 struct tps65217_charger {
@@ -144,8 +146,8 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
 
dev_dbg(charger->dev, "%s: 0x%x\n", __func__, val);
 
-   /* check for AC status bit */
-   if (val & TPS65217_STATUS_ACPWR) {
+   /* check for charger status bit */
+   if (val & CHARGER_STATUS_PRESENT) {
ret = tps65217_enable_charging(charger);
if (ret) {
dev_err(charger->dev,
@@ -200,8 +202,9 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
-   int irq;
+   int irq[NUM_CHARGER_IRQS];
int ret;
+   int i;
 
dev_dbg(>dev, "%s\n", __func__);
 
@@ -224,10 +227,8 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return PTR_ERR(charger->ac);
}
 
-   irq = platform_get_irq_byname(pdev, "AC");
-   if (irq < 0)
-   irq = -ENXIO;
-   charger->irq = irq;
+   irq[0] = platform_get_irq_byname(pdev, "USB");
+   irq[1] = platform_get_irq_byname(pdev, "AC");
 
ret = tps65217_config_charger(charger);
if (ret < 0) {
@@ -235,29 +236,35 @@ static int tps65217_charger_probe(struct platform_device 
*pdev)
return ret;
}
 
-   if (irq != -ENXIO) {
-   ret = devm_request_threaded_irq(>dev, irq, NULL,
+   /* Create a polling thread if an interrupt is invalid */
+   if (irq[0] < 0 || irq[1] < 0) {
+   charger->poll_task = kthread_run(tps65217_charger_poll_task,
+   charger, "ktps65217charger");
+   if (IS_ERR(charger->poll_task)) {
+   ret = PTR_ERR(charger->poll_task);
+   dev_err(charger->dev,
+   "Unable to run kthread err %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+   }
+
+   /* Create IRQ threads for charger interrupts */
+   for (i = 0; i < NUM_CHARGER_IRQS; i++) {
+   ret = devm_request_threaded_irq(>dev, irq[i], NULL,
tps65217_charger_irq,
0, "tps65217-charger",
charger);
if (ret) {
dev_err(charger->dev,
-   "Unable to register irq %d err %d\n", irq,
+   "Unable to register irq %d err %d\n", irq[i],
ret);
return ret;
}
 
/* Check current state */
-   tps65217_charger_irq(irq, charger);
-   } else {
-   charger->poll_task = kthread_run(tps65217_charger_poll_task,
-   charger, "ktps65217charger");
-   if (IS_ERR(charger->poll_task)) {
-   ret = PTR_ERR(charger->poll_task);
-   dev_err(charger->dev,
-   "Unable to run kthread err %d\n", ret);
-   return ret;
-   }
+   tps65217_charger_irq(-1, charger);
}
 
return 0;
-- 
2.9.3



[PATCH v2 4/8] power: supply: tps65217: Use generic name for charger online

2016-12-08 Thread Milo Kim
This driver supports AC and USB chargers. Generic name is preferred.
Replace 'ac_online' with 'online'.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 482ee9f..424a6d3 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -44,8 +44,8 @@ struct tps65217_charger {
struct device *dev;
struct power_supply *ac;
 
-   int ac_online;
-   int prev_ac_online;
+   int online;
+   int prev_online;
 
struct task_struct  *poll_task;
 };
@@ -95,7 +95,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
int ret;
 
/* charger already enabled */
-   if (charger->ac_online)
+   if (charger->online)
return 0;
 
dev_dbg(charger->dev, "%s: enable charging\n", __func__);
@@ -110,7 +110,7 @@ static int tps65217_enable_charging(struct tps65217_charger 
*charger)
return ret;
}
 
-   charger->ac_online = 1;
+   charger->online = 1;
 
return 0;
 }
@@ -122,7 +122,7 @@ static int tps65217_ac_get_property(struct power_supply 
*psy,
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
 
if (psp == POWER_SUPPLY_PROP_ONLINE) {
-   val->intval = charger->ac_online;
+   val->intval = charger->online;
return 0;
}
return -EINVAL;
@@ -133,7 +133,7 @@ static irqreturn_t tps65217_charger_irq(int irq, void *dev)
int ret, val;
struct tps65217_charger *charger = dev;
 
-   charger->prev_ac_online = charger->ac_online;
+   charger->prev_online = charger->online;
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_STATUS, );
if (ret < 0) {
@@ -153,10 +153,10 @@ static irqreturn_t tps65217_charger_irq(int irq, void 
*dev)
return IRQ_HANDLED;
}
} else {
-   charger->ac_online = 0;
+   charger->online = 0;
}
 
-   if (charger->prev_ac_online != charger->ac_online)
+   if (charger->prev_online != charger->online)
power_supply_changed(charger->ac);
 
ret = tps65217_reg_read(charger->tps, TPS65217_REG_CHGCONFIG0, );
-- 
2.9.3



[PATCH v2 3/8] power: supply: tps65217: Remove IRQ data from driver data

2016-12-08 Thread Milo Kim
IRQ number is only used on requesting the interrupt, so no need to keep
it inside the driver data.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 55371d6..482ee9f 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -48,8 +48,6 @@ struct tps65217_charger {
int prev_ac_online;
 
struct task_struct  *poll_task;
-
-   int irq;
 };
 
 static enum power_supply_property tps65217_ac_props[] = {
-- 
2.9.3



[PATCH v2 6/8] power: supply: tps65217: Use generic name for power supply property

2016-12-08 Thread Milo Kim
Replace 'ac_props' with 'charger_props'.

Signed-off-by: Milo Kim 
---
 drivers/power/supply/tps65217_charger.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/tps65217_charger.c 
b/drivers/power/supply/tps65217_charger.c
index 5daf361..79afeca 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -50,7 +50,7 @@ struct tps65217_charger {
struct task_struct  *poll_task;
 };
 
-static enum power_supply_property tps65217_ac_props[] = {
+static enum power_supply_property tps65217_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };
 
@@ -191,8 +191,8 @@ static const struct power_supply_desc tps65217_charger_desc 
= {
.name   = "tps65217-ac",
.type   = POWER_SUPPLY_TYPE_MAINS,
.get_property   = tps65217_ac_get_property,
-   .properties = tps65217_ac_props,
-   .num_properties = ARRAY_SIZE(tps65217_ac_props),
+   .properties = tps65217_charger_props,
+   .num_properties = ARRAY_SIZE(tps65217_charger_props),
 };
 
 static int tps65217_charger_probe(struct platform_device *pdev)
-- 
2.9.3



[PATCH 4/4] dt-bindings: input: Specify the interrupt number of TPS65217 power button

2016-12-08 Thread Milo Kim
Specify the power button interrupt number which is from the datasheet.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt 
b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
index 3e5b979..8682ab6 100644
--- a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
@@ -8,8 +8,9 @@ This driver provides a simple power button event via an 
Interrupt.
 Required properties:
 - compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton"
 
-Required properties for TPS65218:
+Required properties:
 - interrupts: should be one of the following
+   - <2>: For controllers compatible with tps65217
- <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218
 
 Examples:
@@ -17,6 +18,7 @@ Examples:
  {
tps65217-pwrbutton {
compatible = "ti,tps65217-pwrbutton";
+   interrupts = <2>;
};
 };
 
-- 
2.9.3



[PATCH 3/4] dt-bindings: power/supply: Update TPS65217 properties

2016-12-08 Thread Milo Kim
Add interrupt specifiers for USB and AC charger input. Interrupt numbers
are from the datasheet.
Fix wrong property for compatible string.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 .../devicetree/bindings/power/supply/tps65217_charger.txt  | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt 
b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
index 98d131a..a11072c 100644
--- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
@@ -2,11 +2,16 @@ TPS65217 Charger
 
 Required Properties:
 -compatible: "ti,tps65217-charger"
+-interrupts: TPS65217 interrupt numbers for the AC and USB charger input 
change.
+ Should be <0> for the USB charger and <1> for the AC adapter.
+-interrupt-names: Should be "USB" and "AC"
 
 This node is a subnode of the tps65217 PMIC.
 
 Example:
 
tps65217-charger {
-   compatible = "ti,tps65090-charger";
+   compatible = "ti,tps65217-charger";
+   interrupts = <0>, <1>;
+   interrupt-names = "USB", "AC";
};
-- 
2.9.3



[PATCH 4/4] dt-bindings: input: Specify the interrupt number of TPS65217 power button

2016-12-08 Thread Milo Kim
Specify the power button interrupt number which is from the datasheet.

Signed-off-by: Milo Kim 
---
 Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt 
b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
index 3e5b979..8682ab6 100644
--- a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
+++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
@@ -8,8 +8,9 @@ This driver provides a simple power button event via an 
Interrupt.
 Required properties:
 - compatible: should be "ti,tps65217-pwrbutton" or "ti,tps65218-pwrbutton"
 
-Required properties for TPS65218:
+Required properties:
 - interrupts: should be one of the following
+   - <2>: For controllers compatible with tps65217
- <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218
 
 Examples:
@@ -17,6 +18,7 @@ Examples:
  {
tps65217-pwrbutton {
compatible = "ti,tps65217-pwrbutton";
+   interrupts = <2>;
};
 };
 
-- 
2.9.3



[PATCH 3/4] dt-bindings: power/supply: Update TPS65217 properties

2016-12-08 Thread Milo Kim
Add interrupt specifiers for USB and AC charger input. Interrupt numbers
are from the datasheet.
Fix wrong property for compatible string.

Signed-off-by: Milo Kim 
---
 .../devicetree/bindings/power/supply/tps65217_charger.txt  | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt 
b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
index 98d131a..a11072c 100644
--- a/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
@@ -2,11 +2,16 @@ TPS65217 Charger
 
 Required Properties:
 -compatible: "ti,tps65217-charger"
+-interrupts: TPS65217 interrupt numbers for the AC and USB charger input 
change.
+ Should be <0> for the USB charger and <1> for the AC adapter.
+-interrupt-names: Should be "USB" and "AC"
 
 This node is a subnode of the tps65217 PMIC.
 
 Example:
 
tps65217-charger {
-   compatible = "ti,tps65090-charger";
+   compatible = "ti,tps65217-charger";
+   interrupts = <0>, <1>;
+   interrupt-names = "USB", "AC";
};
-- 
2.9.3



[PATCH 2/4] dt-bindings: mfd: Remove TPS65217 interrupts

2016-12-08 Thread Milo Kim
Interrupt numbers are from the datasheet, so no need to keep them in
the ABI. Use the number in the DT file.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/am335x-bone-common.dtsi |  8 +++-
 include/dt-bindings/mfd/tps65217.h| 26 --
 2 files changed, 3 insertions(+), 31 deletions(-)
 delete mode 100644 include/dt-bindings/mfd/tps65217.h

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi 
b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 14b6269..3e32dd1 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -6,8 +6,6 @@
  * published by the Free Software Foundation.
  */
 
-#include 
-
 / {
cpus {
cpu@0 {
@@ -319,13 +317,13 @@
ti,pmic-shutdown-controller;
 
charger {
-   interrupts = , ;
-   interrupt-names = "AC", "USB";
+   interrupts = <0>, <1>;
+   interrupt-names = "USB", "AC";
status = "okay";
};
 
pwrbutton {
-   interrupts = ;
+   interrupts = <2>;
status = "okay";
};
 
diff --git a/include/dt-bindings/mfd/tps65217.h 
b/include/dt-bindings/mfd/tps65217.h
deleted file mode 100644
index cafb9e6..000
--- a/include/dt-bindings/mfd/tps65217.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This header provides macros for TI TPS65217 DT bindings.
- *
- * Copyright (C) 2016 Texas Instruments
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __DT_BINDINGS_TPS65217_H__
-#define __DT_BINDINGS_TPS65217_H__
-
-#define TPS65217_IRQ_USB   0
-#define TPS65217_IRQ_AC1
-#define TPS65217_IRQ_PB2
-
-#endif
-- 
2.9.3



[PATCH 1/4] ARM: dts: am335x: Fix the interrupt name of TPS65217

2016-12-08 Thread Milo Kim
Use 'interrupt-names' for getting the charger interrupt number.

Fixes: 1934e89a769b ("ARM: dts: am335x: Add the charger interrupt")
Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi 
b/arch/arm/boot/dts/am335x-bone-common.dtsi
index dc561d5..14b6269 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -320,7 +320,7 @@
 
charger {
interrupts = , ;
-   interrupts-names = "AC", "USB";
+   interrupt-names = "AC", "USB";
status = "okay";
};
 
-- 
2.9.3



[PATCH 0/4] dt-bindings: mfd: Update TPS65217 interrupts

2016-12-08 Thread Milo Kim
This patch-set fixes wrong property name and uses TPS65217 HW interrupt 
number from the datasheet instead of the DT ABI. DT bindings are also 
updated.

Milo Kim (4):
  ARM: dts: am335x: Fix the interrupt name of TPS65217
  dt-bindings: mfd: Remove TPS65217 interrupts
  dt-bindings: power/supply: Update TPS65217 properties
  dt-bindings: input: Add interrupt number for TPS65217

 .../bindings/input/tps65218-pwrbutton.txt  |  4 +++-
 .../bindings/power/supply/tps65217_charger.txt |  7 +-
 arch/arm/boot/dts/am335x-bone-common.dtsi  |  8 +++
 include/dt-bindings/mfd/tps65217.h | 26 --
 4 files changed, 12 insertions(+), 33 deletions(-)
 delete mode 100644 include/dt-bindings/mfd/tps65217.h

-- 
2.9.3



[PATCH 2/4] dt-bindings: mfd: Remove TPS65217 interrupts

2016-12-08 Thread Milo Kim
Interrupt numbers are from the datasheet, so no need to keep them in
the ABI. Use the number in the DT file.

Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/am335x-bone-common.dtsi |  8 +++-
 include/dt-bindings/mfd/tps65217.h| 26 --
 2 files changed, 3 insertions(+), 31 deletions(-)
 delete mode 100644 include/dt-bindings/mfd/tps65217.h

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi 
b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 14b6269..3e32dd1 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -6,8 +6,6 @@
  * published by the Free Software Foundation.
  */
 
-#include 
-
 / {
cpus {
cpu@0 {
@@ -319,13 +317,13 @@
ti,pmic-shutdown-controller;
 
charger {
-   interrupts = , ;
-   interrupt-names = "AC", "USB";
+   interrupts = <0>, <1>;
+   interrupt-names = "USB", "AC";
status = "okay";
};
 
pwrbutton {
-   interrupts = ;
+   interrupts = <2>;
status = "okay";
};
 
diff --git a/include/dt-bindings/mfd/tps65217.h 
b/include/dt-bindings/mfd/tps65217.h
deleted file mode 100644
index cafb9e6..000
--- a/include/dt-bindings/mfd/tps65217.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This header provides macros for TI TPS65217 DT bindings.
- *
- * Copyright (C) 2016 Texas Instruments
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __DT_BINDINGS_TPS65217_H__
-#define __DT_BINDINGS_TPS65217_H__
-
-#define TPS65217_IRQ_USB   0
-#define TPS65217_IRQ_AC1
-#define TPS65217_IRQ_PB2
-
-#endif
-- 
2.9.3



[PATCH 1/4] ARM: dts: am335x: Fix the interrupt name of TPS65217

2016-12-08 Thread Milo Kim
Use 'interrupt-names' for getting the charger interrupt number.

Fixes: 1934e89a769b ("ARM: dts: am335x: Add the charger interrupt")
Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/am335x-bone-common.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi 
b/arch/arm/boot/dts/am335x-bone-common.dtsi
index dc561d5..14b6269 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -320,7 +320,7 @@
 
charger {
interrupts = , ;
-   interrupts-names = "AC", "USB";
+   interrupt-names = "AC", "USB";
status = "okay";
};
 
-- 
2.9.3



[PATCH 0/4] dt-bindings: mfd: Update TPS65217 interrupts

2016-12-08 Thread Milo Kim
This patch-set fixes wrong property name and uses TPS65217 HW interrupt 
number from the datasheet instead of the DT ABI. DT bindings are also 
updated.

Milo Kim (4):
  ARM: dts: am335x: Fix the interrupt name of TPS65217
  dt-bindings: mfd: Remove TPS65217 interrupts
  dt-bindings: power/supply: Update TPS65217 properties
  dt-bindings: input: Add interrupt number for TPS65217

 .../bindings/input/tps65218-pwrbutton.txt  |  4 +++-
 .../bindings/power/supply/tps65217_charger.txt |  7 +-
 arch/arm/boot/dts/am335x-bone-common.dtsi  |  8 +++
 include/dt-bindings/mfd/tps65217.h | 26 --
 4 files changed, 12 insertions(+), 33 deletions(-)
 delete mode 100644 include/dt-bindings/mfd/tps65217.h

-- 
2.9.3



[PATCH] ARM: dts: sun8i: Support DTB build for NanoPi M1

2016-12-08 Thread Milo Kim
The commit 10efbf5f1633 introduced NanoPi M1 board but it's missing in
Allwinner H3 DTB build.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb..4cbdf6f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -845,6 +845,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
+   sun8i-h3-nanopi-m1.dtb \
sun8i-h3-nanopi-neo.dtb \
sun8i-h3-orangepi-2.dtb \
sun8i-h3-orangepi-lite.dtb \
-- 
2.9.3



[PATCH] ARM: dts: sun8i: Support DTB build for NanoPi M1

2016-12-08 Thread Milo Kim
The commit 10efbf5f1633 introduced NanoPi M1 board but it's missing in
Allwinner H3 DTB build.

Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index cccdbcb..4cbdf6f 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -845,6 +845,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
+   sun8i-h3-nanopi-m1.dtb \
sun8i-h3-nanopi-neo.dtb \
sun8i-h3-orangepi-2.dtb \
sun8i-h3-orangepi-lite.dtb \
-- 
2.9.3



[PATCH v3 2/3] ARM: dts: imx6: Support Savageboard dual

2016-12-08 Thread Milo Kim
Common savageboard DT file is used for board support.
Specify this dtb file for i.MX6Q build.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/Makefile   |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts | 50 
 2 files changed, 51 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index c558ba7..64660c7 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -348,6 +348,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-savageboard.dts 
b/arch/arm/boot/dts/imx6dl-savageboard.dts
new file mode 100644
index 000..2cac30d
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-savageboard.dts
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";
+};
-- 
2.9.3



[PATCH v3 2/3] ARM: dts: imx6: Support Savageboard dual

2016-12-08 Thread Milo Kim
Common savageboard DT file is used for board support.
Specify this dtb file for i.MX6Q build.

Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/Makefile   |  1 +
 arch/arm/boot/dts/imx6dl-savageboard.dts | 50 
 2 files changed, 51 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index c558ba7..64660c7 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -348,6 +348,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6dl-sabreauto.dtb \
imx6dl-sabrelite.dtb \
imx6dl-sabresd.dtb \
+   imx6dl-savageboard.dtb \
imx6dl-ts4900.dtb \
imx6dl-tx6dl-comtft.dtb \
imx6dl-tx6s-8034.dtb \
diff --git a/arch/arm/boot/dts/imx6dl-savageboard.dts 
b/arch/arm/boot/dts/imx6dl-savageboard.dts
new file mode 100644
index 000..2cac30d
--- /dev/null
+++ b/arch/arm/boot/dts/imx6dl-savageboard.dts
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Dual";
+   compatible = "poslab,imx6dl-savageboard", "fsl,imx6dl";
+};
-- 
2.9.3



[PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2016-12-08 Thread Milo Kim
* Memory
  memblock for DDR3 1GB

* Regulator
  3.3V for panel and backlight.

* Display
  Enable HDMI and LVDS panel. Savageboard supports AVIC TM097TDH02 panel
  which is compatible with Hannstar HSD100PXN1, so reuse it.

* Clock
  The commit d28be499c45e6 is applied to support LVDS and HDMI output
  simultaneously.

* Pinmux
  eMMC, ethernet, HDMI, I2C, power button, PWM, SD card and UART.

* Others
  Enable ethernet, UART1 debug, USB host, USDHC3 for microSD card and
  USDHC4 for built-in eMMC storage.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 262 +
 1 file changed, 262 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

diff --git a/arch/arm/boot/dts/imx6qdl-savageboard.dtsi 
b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
new file mode 100644
index 000..a7a7e1d
--- /dev/null
+++ b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2016 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+
+   memory@1000 {
+   device_type = "memory";
+   reg = <0x1000 0x4000>;
+   };
+
+   backlight: panel_bl {
+   compatible = "pwm-backlight";
+   brightness-levels = <0 4 8 16 32 64 128 255>;
+   default-brightness-level = <4>;
+   power-supply = <_3p3v>;
+   pwms = < 0 1>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_keys>;
+
+   power {
+   gpios = < 7 GPIO_ACTIVE_LOW>;
+   label = "Power Button";
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+
+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";
+   backlight = <>;
+   power-supply = <_3p3v>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "3P3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+};
+
+ {
+   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
+ < IMX6QDL_CLK_LDB_DI1_SEL>;
+   assigned-clock-parents = < IMX6QDL_CLK_PLL3_USB_OTG>,
+< IMX6QDL_CLK_PLL3_USB_OTG>;
+};
+
+ {
+   phy-mode = "rgmii";
+   phy-reset-gpios = < 25 GPIO_ACTIVE_LOW>;
+   pinctrl-name

[PATCH v3 3/3] ARM: dts: imx6: Support Savageboard quad

2016-12-08 Thread Milo Kim
Use common board file and support SATA interface additionally.
Specify this dtb file for i.MX6 build.

Signed-off-by: Milo Kim <woogyom@gmail.com>
---
 arch/arm/boot/dts/Makefile  |  1 +
 arch/arm/boot/dts/imx6q-savageboard.dts | 54 +
 2 files changed, 55 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 64660c7..25b1e19 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -392,6 +392,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6q-sabreauto.dtb \
imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
+   imx6q-savageboard.dtb \
imx6q-sbc6x.dtb \
imx6q-tbs2910.dtb \
imx6q-ts4900.dtb \
diff --git a/arch/arm/boot/dts/imx6q-savageboard.dts 
b/arch/arm/boot/dts/imx6q-savageboard.dts
new file mode 100644
index 000..8d74002
--- /dev/null
+++ b/arch/arm/boot/dts/imx6q-savageboard.dts
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 Milo Kim <woogyom@gmail.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Quad";
+   compatible = "poslab,imx6q-savageboard", "fsl,imx6q";
+};
+
+ {
+   status = "okay";
+};
-- 
2.9.3



[PATCH v3 0/3] ARM: dts: imx6: Support Poslab Savageboard dual & quad

2016-12-08 Thread Milo Kim
Poslab Savageboard is i.MX6 SoC base, but BSP code from the vendor is 
not mainline u-boot and kernel. Personal reason of using this board is 
testing etnaviv user-space driver, so I re-write device tree files based on
mainline kernel for the first step.

This patchset includes common DT file, dual and quad board files.

Supported components are
  - Display: HDMI and LVDS panel
  - eMMC and SD card
  - Ethernet
  - Pinmux configuration
  - SATA: only for Savageboard quad
  - UART1 for debug console
  - USB host

Missing features are
  - Audio (WM8903)
  - USB OTG
  - PMIC WM8326: default settings are used so no issue to bring-up the system
  - MIPI DSI, CSI

Patches are tested on the Savageboard quad but the dual version should work 
because the only difference between dual and quad is SATA support.

More information in http://www.savageboard.org

v3:
  Specify the dtbs for i.MX6 build.

v2:
  Fix DT node for regulator, phy-reset-gpios and iomuxc node.

Milo Kim (3):
  ARM: dts: imx6: Add Savageboard common file
  ARM: dts: imx6: Support Savageboard dual
  ARM: dts: imx6: Support Savageboard quad

 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   |  50 ++
 arch/arm/boot/dts/imx6q-savageboard.dts|  54 ++
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 262 +
 4 files changed, 368 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

-- 
2.9.3



[PATCH v3 1/3] ARM: dts: imx6: Add Savageboard common file

2016-12-08 Thread Milo Kim
* Memory
  memblock for DDR3 1GB

* Regulator
  3.3V for panel and backlight.

* Display
  Enable HDMI and LVDS panel. Savageboard supports AVIC TM097TDH02 panel
  which is compatible with Hannstar HSD100PXN1, so reuse it.

* Clock
  The commit d28be499c45e6 is applied to support LVDS and HDMI output
  simultaneously.

* Pinmux
  eMMC, ethernet, HDMI, I2C, power button, PWM, SD card and UART.

* Others
  Enable ethernet, UART1 debug, USB host, USDHC3 for microSD card and
  USDHC4 for built-in eMMC storage.

Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 262 +
 1 file changed, 262 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

diff --git a/arch/arm/boot/dts/imx6qdl-savageboard.dtsi 
b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
new file mode 100644
index 000..a7a7e1d
--- /dev/null
+++ b/arch/arm/boot/dts/imx6qdl-savageboard.dtsi
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2016 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+/ {
+   chosen {
+   stdout-path = 
+   };
+
+   memory@1000 {
+   device_type = "memory";
+   reg = <0x1000 0x4000>;
+   };
+
+   backlight: panel_bl {
+   compatible = "pwm-backlight";
+   brightness-levels = <0 4 8 16 32 64 128 255>;
+   default-brightness-level = <4>;
+   power-supply = <_3p3v>;
+   pwms = < 0 1>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_keys>;
+
+   power {
+   gpios = < 7 GPIO_ACTIVE_LOW>;
+   label = "Power Button";
+   linux,code = ;
+   wakeup-source;
+   };
+   };
+
+   panel {
+   compatible = "avic, tm097tdh02", "hannstar,hsd100pxn1";
+   backlight = <>;
+   power-supply = <_3p3v>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+
+   reg_3p3v: regulator-3p3v {
+   compatible = "regulator-fixed";
+   regulator-name = "3P3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+};
+
+ {
+   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
+ < IMX6QDL_CLK_LDB_DI1_SEL>;
+   assigned-clock-parents = < IMX6QDL_CLK_PLL3_USB_OTG>,
+< IMX6QDL_CLK_PLL3_USB_OTG>;
+};
+
+ {
+   phy-mode = "rgmii";
+   phy-reset-gpios = < 25 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_enet&g

[PATCH v3 3/3] ARM: dts: imx6: Support Savageboard quad

2016-12-08 Thread Milo Kim
Use common board file and support SATA interface additionally.
Specify this dtb file for i.MX6 build.

Signed-off-by: Milo Kim 
---
 arch/arm/boot/dts/Makefile  |  1 +
 arch/arm/boot/dts/imx6q-savageboard.dts | 54 +
 2 files changed, 55 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 64660c7..25b1e19 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -392,6 +392,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
imx6q-sabreauto.dtb \
imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
+   imx6q-savageboard.dtb \
imx6q-sbc6x.dtb \
imx6q-tbs2910.dtb \
imx6q-ts4900.dtb \
diff --git a/arch/arm/boot/dts/imx6q-savageboard.dts 
b/arch/arm/boot/dts/imx6q-savageboard.dts
new file mode 100644
index 000..8d74002
--- /dev/null
+++ b/arch/arm/boot/dts/imx6q-savageboard.dts
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 Milo Kim 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
+#include "imx6qdl-savageboard.dtsi"
+
+/ {
+   model = "Poslab SavageBoard Quad";
+   compatible = "poslab,imx6q-savageboard", "fsl,imx6q";
+};
+
+ {
+   status = "okay";
+};
-- 
2.9.3



[PATCH v3 0/3] ARM: dts: imx6: Support Poslab Savageboard dual & quad

2016-12-08 Thread Milo Kim
Poslab Savageboard is i.MX6 SoC base, but BSP code from the vendor is 
not mainline u-boot and kernel. Personal reason of using this board is 
testing etnaviv user-space driver, so I re-write device tree files based on
mainline kernel for the first step.

This patchset includes common DT file, dual and quad board files.

Supported components are
  - Display: HDMI and LVDS panel
  - eMMC and SD card
  - Ethernet
  - Pinmux configuration
  - SATA: only for Savageboard quad
  - UART1 for debug console
  - USB host

Missing features are
  - Audio (WM8903)
  - USB OTG
  - PMIC WM8326: default settings are used so no issue to bring-up the system
  - MIPI DSI, CSI

Patches are tested on the Savageboard quad but the dual version should work 
because the only difference between dual and quad is SATA support.

More information in http://www.savageboard.org

v3:
  Specify the dtbs for i.MX6 build.

v2:
  Fix DT node for regulator, phy-reset-gpios and iomuxc node.

Milo Kim (3):
  ARM: dts: imx6: Add Savageboard common file
  ARM: dts: imx6: Support Savageboard dual
  ARM: dts: imx6: Support Savageboard quad

 arch/arm/boot/dts/Makefile |   2 +
 arch/arm/boot/dts/imx6dl-savageboard.dts   |  50 ++
 arch/arm/boot/dts/imx6q-savageboard.dts|  54 ++
 arch/arm/boot/dts/imx6qdl-savageboard.dtsi | 262 +
 4 files changed, 368 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6dl-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6q-savageboard.dts
 create mode 100644 arch/arm/boot/dts/imx6qdl-savageboard.dtsi

-- 
2.9.3



  1   2   3   4   5   6   7   >