Re: [PATCH v2 2/2] mfd: rk808: Add restart functionality

2018-03-13 Thread Joseph Chen

Hi, Daniel:

    I discussed with my colleagues, we agree with your idear to make 
PMIC restart as a option and controlled by a new DTS property.



在 2018/3/13 17:48, Daniel Schultz 写道:

Hi,

I can add a DTS property to enable the PMIC restart functions? So this 
feature can be used if its desired.


My problem with the CRU reset is a strange behaviour in the ROM code. 
During a reset from MMC1 (eMMC), the ROM tries to load the SPL from 
MMC0 (SD).


Daniel


On 03/13/2018 04:32 AM, Joseph Chen wrote:

Hi, Daniel:

        On Rockchip platforms, we always use CRU to restart system. 
From your patch, I think you would like to support restart by CRU or 
PMIC, right ?


        I think restart by PMIC is not accepted, because PMIC restart 
means all regualtors are reset (voltage drops to 0mv and then power 
on again), including vdd_arm, vdd_logic, vcc_ddr, etc. This is like a 
cold boot for machine.


       We use CRU reset, because we want to keep status of last log, 
GRF, CRU or other registers, but PMIC restart can make them lost.



在 2018/3/12 22:10, Lee Jones 写道:

Rockchip guys,

I'd really appreciate your input on these two patches please.

Please provide Reviewed-by/Tested-by tags.

On Wed, 07 Mar 2018, Daniel Schultz wrote:
When using Rockchip SoCs with rk805/808/818 PMICs, restarts are 
realized by

setting the reset registers in the "Clock and Reset Unit".

Since all three shutdown functions have almost the same code, all 
logic

from the shutdown functions can be refactored to a new function
"rk808_update_bits", which can update a register by a given address 
and

bitmask.

After that, notifier blocks and the restart functions were added to 
the

driver. Like the shutdown function, the restart is bound to the
"rockchip,system-power-controller" device tree property and can easily
revoked to the software restart by removing the property.

Signed-off-by: Daniel Schultz <d.schu...@phytec.de>
---
Changes:
v2: Re-submit with recipients from Rockchip.

  drivers/mfd/rk808.c   | 97 
++-

  include/linux/mfd/rk808.h |  1 +
  2 files changed, 63 insertions(+), 35 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index d138721..2c68f8c 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
+#include 
    struct rk808_reg_data {
  int addr;
@@ -369,59 +370,73 @@ static const struct regmap_irq_chip 
rk818_irq_chip = {

    static struct i2c_client *rk808_i2c_client;
  -static void rk805_device_shutdown(void)
+static void rk808_update_bits(unsigned int reg, unsigned int 
bit_mask)

  {
  int ret;
  struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
    if (!rk808) {
  dev_warn(_i2c_client->dev,
- "have no rk805, so do nothing here\n");
+ "have no %s, so do nothing here\n",
+ rk808->regmap_irq_chip->name);
  return;
  }
    ret = regmap_update_bits(rk808->regmap,
- RK805_DEV_CTRL_REG,
- DEV_OFF, DEV_OFF);
+ reg,
+ bit_mask, bit_mask);
  if (ret)
-    dev_err(_i2c_client->dev, "power off error!\n");
+    dev_err(_i2c_client->dev, "can't write to DEVCTRL: 
%x!\n",

+    ret);
  }
  -static void rk808_device_shutdown(void)
+static void rk805_device_shutdown(void)
  {
-    int ret;
-    struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
-
-    if (!rk808) {
-    dev_warn(_i2c_client->dev,
- "have no rk808, so do nothing here\n");
-    return;
-    }
+    rk808_update_bits(RK805_DEV_CTRL_REG, DEV_OFF);
+}
+static int rk805_restart_notify(struct notifier_block *this,
+   unsigned long mode, void *cmd)
+{
+    rk808_update_bits(RK805_DEV_CTRL_REG, DEV_OFF_RST);
+    return NOTIFY_DONE;
+}
  -    ret = regmap_update_bits(rk808->regmap,
- RK808_DEVCTRL_REG,
- DEV_OFF_RST, DEV_OFF_RST);
-    if (ret)
-    dev_err(_i2c_client->dev, "power off error!\n");
+static void rk808_device_shutdown(void)
+{
+    rk808_update_bits(RK808_DEVCTRL_REG, DEV_OFF_RST);
+}
+static int rk808_restart_notify(struct notifier_block *this,
+   unsigned long mode, void *cmd)
+{
+    rk808_update_bits(RK808_DEVCTRL_REG, DEV_OFF);
+    return NOTIFY_DONE;
  }
    static void rk818_device_shutdown(void)
  {
-    int ret;
-    struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+    rk808_update_bits(RK818_DEVCTRL_REG, DEV_OFF_RST);
+}
+static int rk818_restart_notify(struct notifier_block *this,
+   unsigned long mode, void *cmd)
+{
+    rk808_update_bits(RK818_DEVCTRL_REG, DEV_OFF);
+    return NOTIFY_DONE;
+}
  -    if (!rk808) {
-    dev_warn(_i2c_client->dev,
- "have no

Re: [PATCH v2 2/2] mfd: rk808: Add restart functionality

2018-03-13 Thread Joseph Chen

Hi, Daniel:

    I discussed with my colleagues, we agree with your idear to make 
PMIC restart as a option and controlled by a new DTS property.



在 2018/3/13 17:48, Daniel Schultz 写道:

Hi,

I can add a DTS property to enable the PMIC restart functions? So this 
feature can be used if its desired.


My problem with the CRU reset is a strange behaviour in the ROM code. 
During a reset from MMC1 (eMMC), the ROM tries to load the SPL from 
MMC0 (SD).


Daniel


On 03/13/2018 04:32 AM, Joseph Chen wrote:

Hi, Daniel:

        On Rockchip platforms, we always use CRU to restart system. 
From your patch, I think you would like to support restart by CRU or 
PMIC, right ?


        I think restart by PMIC is not accepted, because PMIC restart 
means all regualtors are reset (voltage drops to 0mv and then power 
on again), including vdd_arm, vdd_logic, vcc_ddr, etc. This is like a 
cold boot for machine.


       We use CRU reset, because we want to keep status of last log, 
GRF, CRU or other registers, but PMIC restart can make them lost.



在 2018/3/12 22:10, Lee Jones 写道:

Rockchip guys,

I'd really appreciate your input on these two patches please.

Please provide Reviewed-by/Tested-by tags.

On Wed, 07 Mar 2018, Daniel Schultz wrote:
When using Rockchip SoCs with rk805/808/818 PMICs, restarts are 
realized by

setting the reset registers in the "Clock and Reset Unit".

Since all three shutdown functions have almost the same code, all 
logic

from the shutdown functions can be refactored to a new function
"rk808_update_bits", which can update a register by a given address 
and

bitmask.

After that, notifier blocks and the restart functions were added to 
the

driver. Like the shutdown function, the restart is bound to the
"rockchip,system-power-controller" device tree property and can easily
revoked to the software restart by removing the property.

Signed-off-by: Daniel Schultz 
---
Changes:
v2: Re-submit with recipients from Rockchip.

  drivers/mfd/rk808.c   | 97 
++-

  include/linux/mfd/rk808.h |  1 +
  2 files changed, 63 insertions(+), 35 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index d138721..2c68f8c 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -27,6 +27,7 @@
  #include 
  #include 
  #include 
+#include 
    struct rk808_reg_data {
  int addr;
@@ -369,59 +370,73 @@ static const struct regmap_irq_chip 
rk818_irq_chip = {

    static struct i2c_client *rk808_i2c_client;
  -static void rk805_device_shutdown(void)
+static void rk808_update_bits(unsigned int reg, unsigned int 
bit_mask)

  {
  int ret;
  struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
    if (!rk808) {
  dev_warn(_i2c_client->dev,
- "have no rk805, so do nothing here\n");
+ "have no %s, so do nothing here\n",
+ rk808->regmap_irq_chip->name);
  return;
  }
    ret = regmap_update_bits(rk808->regmap,
- RK805_DEV_CTRL_REG,
- DEV_OFF, DEV_OFF);
+ reg,
+ bit_mask, bit_mask);
  if (ret)
-    dev_err(_i2c_client->dev, "power off error!\n");
+    dev_err(_i2c_client->dev, "can't write to DEVCTRL: 
%x!\n",

+    ret);
  }
  -static void rk808_device_shutdown(void)
+static void rk805_device_shutdown(void)
  {
-    int ret;
-    struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
-
-    if (!rk808) {
-    dev_warn(_i2c_client->dev,
- "have no rk808, so do nothing here\n");
-    return;
-    }
+    rk808_update_bits(RK805_DEV_CTRL_REG, DEV_OFF);
+}
+static int rk805_restart_notify(struct notifier_block *this,
+   unsigned long mode, void *cmd)
+{
+    rk808_update_bits(RK805_DEV_CTRL_REG, DEV_OFF_RST);
+    return NOTIFY_DONE;
+}
  -    ret = regmap_update_bits(rk808->regmap,
- RK808_DEVCTRL_REG,
- DEV_OFF_RST, DEV_OFF_RST);
-    if (ret)
-    dev_err(_i2c_client->dev, "power off error!\n");
+static void rk808_device_shutdown(void)
+{
+    rk808_update_bits(RK808_DEVCTRL_REG, DEV_OFF_RST);
+}
+static int rk808_restart_notify(struct notifier_block *this,
+   unsigned long mode, void *cmd)
+{
+    rk808_update_bits(RK808_DEVCTRL_REG, DEV_OFF);
+    return NOTIFY_DONE;
  }
    static void rk818_device_shutdown(void)
  {
-    int ret;
-    struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+    rk808_update_bits(RK818_DEVCTRL_REG, DEV_OFF_RST);
+}
+static int rk818_restart_notify(struct notifier_block *this,
+   unsigned long mode, void *cmd)
+{
+    rk808_update_bits(RK818_DEVCTRL_REG, DEV_OFF);
+    return NOTIFY_DONE;
+}
  -    if (!rk808) {
-    dev_warn(_i2c_client->dev,
- "have no rk818, so do nothing here\n");
-   

Re: [PATCH v2 2/2] mfd: rk808: Add restart functionality

2018-03-12 Thread Joseph Chen
et = regmap_update_bits(rk808->regmap,

-RK818_DEVCTRL_REG,
-DEV_OFF_RST, DEV_OFF_RST);
-   if (ret)
-   dev_err(_i2c_client->dev, "power off error!\n");
-}
+static struct notifier_block rk808_restart_handler = {
+   .notifier_call = rk808_restart_notify,
+   .priority = 196,
+};
+
+static struct notifier_block rk818_restart_handler = {
+   .notifier_call = rk818_restart_notify,
+   .priority = 196,
+};
  
  static const struct of_device_id rk808_of_match[] = {

{ .compatible = "rockchip,rk805" },
@@ -476,6 +491,7 @@ static int rk808_probe(struct i2c_client *client,
cells = rk805s;
nr_cells = ARRAY_SIZE(rk805s);
pm_pwroff_fn = rk805_device_shutdown;
+   rk808->nb = _restart_handler;
break;
case RK808_ID:
rk808->regmap_cfg = _regmap_config;
@@ -485,6 +501,7 @@ static int rk808_probe(struct i2c_client *client,
cells = rk808s;
nr_cells = ARRAY_SIZE(rk808s);
pm_pwroff_fn = rk808_device_shutdown;
+   rk808->nb = _restart_handler;
break;
case RK818_ID:
rk808->regmap_cfg = _regmap_config;
@@ -494,6 +511,7 @@ static int rk808_probe(struct i2c_client *client,
cells = rk818s;
nr_cells = ARRAY_SIZE(rk818s);
pm_pwroff_fn = rk818_device_shutdown;
+   rk808->nb = _restart_handler;
break;
default:
dev_err(>dev, "Unsupported RK8XX ID %lu\n",
@@ -546,11 +564,18 @@ static int rk808_probe(struct i2c_client *client,
  
  	pm_off = of_property_read_bool(np,

"rockchip,system-power-controller");
-   if (pm_off && !pm_power_off) {
+   if (pm_off) {
rk808_i2c_client = client;
-   pm_power_off = pm_pwroff_fn;
+   if (!pm_power_off)
+   pm_power_off = pm_pwroff_fn;
+   if (rk808->nb) {
+   ret = register_restart_handler(rk808->nb);
+   if (ret)
+   dev_err(>dev,
+   "cannot register restart handler, %d\n",
+   ret);
+   }
}
-
return 0;
  
  err_irq:

@@ -564,6 +589,8 @@ static int rk808_remove(struct i2c_client *client)
  
  	regmap_del_irq_chip(client->irq, rk808->irq_data);

pm_power_off = NULL;
+   if (rk808->nb)
+   unregister_restart_handler(rk808->nb);
  
  	return 0;

  }
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 338e0f6..9c26ca2 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -453,5 +453,6 @@ struct rk808 {
longvariant;
const struct regmap_config  *regmap_cfg;
const struct regmap_irq_chip*regmap_irq_chip;
+   struct notifier_block   *nb;
  };
  #endif /* __LINUX_REGULATOR_RK808_H */


--
Best Regards

陈健洪 (Joseph Chen)
E-mail:che...@rock-chips.com
福州瑞芯微电子股份有限公司
Fuzhou Rockchip Electronics Co.Ltd
福建省福州市铜盘路软件大道89号软件园A区21号楼 (350003)
No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
TEL:0591-83991906/07-8573




Re: [PATCH v2 2/2] mfd: rk808: Add restart functionality

2018-03-12 Thread Joseph Chen
map,

-RK818_DEVCTRL_REG,
-DEV_OFF_RST, DEV_OFF_RST);
-   if (ret)
-   dev_err(_i2c_client->dev, "power off error!\n");
-}
+static struct notifier_block rk808_restart_handler = {
+   .notifier_call = rk808_restart_notify,
+   .priority = 196,
+};
+
+static struct notifier_block rk818_restart_handler = {
+   .notifier_call = rk818_restart_notify,
+   .priority = 196,
+};
  
  static const struct of_device_id rk808_of_match[] = {

{ .compatible = "rockchip,rk805" },
@@ -476,6 +491,7 @@ static int rk808_probe(struct i2c_client *client,
cells = rk805s;
nr_cells = ARRAY_SIZE(rk805s);
pm_pwroff_fn = rk805_device_shutdown;
+   rk808->nb = _restart_handler;
break;
case RK808_ID:
rk808->regmap_cfg = _regmap_config;
@@ -485,6 +501,7 @@ static int rk808_probe(struct i2c_client *client,
cells = rk808s;
nr_cells = ARRAY_SIZE(rk808s);
pm_pwroff_fn = rk808_device_shutdown;
+   rk808->nb = _restart_handler;
break;
case RK818_ID:
rk808->regmap_cfg = _regmap_config;
@@ -494,6 +511,7 @@ static int rk808_probe(struct i2c_client *client,
cells = rk818s;
nr_cells = ARRAY_SIZE(rk818s);
pm_pwroff_fn = rk818_device_shutdown;
+   rk808->nb = _restart_handler;
break;
default:
dev_err(>dev, "Unsupported RK8XX ID %lu\n",
@@ -546,11 +564,18 @@ static int rk808_probe(struct i2c_client *client,
  
  	pm_off = of_property_read_bool(np,

"rockchip,system-power-controller");
-   if (pm_off && !pm_power_off) {
+   if (pm_off) {
rk808_i2c_client = client;
-   pm_power_off = pm_pwroff_fn;
+   if (!pm_power_off)
+   pm_power_off = pm_pwroff_fn;
+   if (rk808->nb) {
+   ret = register_restart_handler(rk808->nb);
+   if (ret)
+   dev_err(>dev,
+   "cannot register restart handler, %d\n",
+   ret);
+   }
}
-
return 0;
  
  err_irq:

@@ -564,6 +589,8 @@ static int rk808_remove(struct i2c_client *client)
  
  	regmap_del_irq_chip(client->irq, rk808->irq_data);

pm_power_off = NULL;
+   if (rk808->nb)
+   unregister_restart_handler(rk808->nb);
  
  	return 0;

  }
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 338e0f6..9c26ca2 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -453,5 +453,6 @@ struct rk808 {
longvariant;
const struct regmap_config  *regmap_cfg;
const struct regmap_irq_chip*regmap_irq_chip;
+   struct notifier_block   *nb;
  };
  #endif /* __LINUX_REGULATOR_RK808_H */


--
Best Regards

陈健洪 (Joseph Chen)
E-mail:che...@rock-chips.com
福州瑞芯微电子股份有限公司
Fuzhou Rockchip Electronics Co.Ltd
福建省福州市铜盘路软件大道89号软件园A区21号楼 (350003)
No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
TEL:0591-83991906/07-8573




[RESEND v9 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




[RESEND v9 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




[RESEND v9 11/12] mfd: rk808: Add RK805 power key support

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index c803d2d..216fbf6 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[RESEND v9 11/12] mfd: rk808: Add RK805 power key support

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index c803d2d..216fbf6 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[RESEND v9 09/12] Input: Add power key driver for Rockchip RK805 PMIC

2017-08-15 Thread Joseph Chen
This driver provides a input driver for the power
key on the Rockchip RK805 PMIC.

Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/input/misc/Kconfig|   6 +++
 drivers/input/misc/Makefile   |   1 +
 drivers/input/misc/rk805-pwrkey.c | 111 ++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/input/misc/rk805-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c522..72dc4f5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -571,6 +571,12 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_RK805_PWRKEY
+   tristate "Rockchip RK805 PMIC power key support"
+   depends on MFD_RK808
+   help
+ Select this option to enable power key driver for RK805.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate "Rotary encoders connected to GPIO pins"
depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f..c27052a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)  += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
+obj-$(CONFIG_INPUT_RK805_PWRKEY)   += rk805-pwrkey.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
 obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)   += soc_button_array.o
diff --git a/drivers/input/misc/rk805-pwrkey.c 
b/drivers/input/misc/rk805-pwrkey.c
new file mode 100644
index 000..e0fc66e
--- /dev/null
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -0,0 +1,111 @@
+/*
+ * Rockchip RK805 PMIC Power Key driver
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen <che...@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 1);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 0);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static int rk805_pwrkey_probe(struct platform_device *pdev)
+{
+   struct input_dev *pwr;
+   int fall_irq, rise_irq;
+   int err;
+
+   pwr = devm_input_allocate_device(>dev);
+   if (!pwr) {
+   dev_err(>dev, "Can't allocate power button\n");
+   return -ENOMEM;
+   }
+
+   pwr->name = "rk805 pwrkey";
+   pwr->phys = "rk805_pwrkey/input0";
+   pwr->dev.parent = >dev;
+   input_set_capability(pwr, EV_KEY, KEY_POWER);
+
+   fall_irq = platform_get_irq(pdev, 0);
+   if (fall_irq < 0) {
+   dev_err(>dev, "Can't get fall irq: %d\n", fall_irq);
+   return fall_irq;
+   }
+
+   rise_irq = platform_get_irq(pdev, 1);
+   if (rise_irq < 0) {
+   dev_err(>dev, "Can't get rise irq: %d\n", rise_irq);
+   return rise_irq;
+   }
+
+   err = devm_request_any_context_irq(>dev, fall_irq,
+  pwrkey_fall_irq,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "rk805_pwrkey_fall", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register fall irq: %d\n", err);
+   return err;
+   }
+
+   err = devm_request_any_context_irq(>dev, rise_irq,
+  pwrkey_rise_irq,
+  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+  "rk805_pwrkey_rise", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register rise irq: %d\n", err);
+   return err;
+   }
+
+   err = input_register_device(pwr);
+   if (err) {
+   dev_err(>dev, "Can't register power button: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, pwr);
+   device_init_wakeup(>dev, true);
+
+   return 0;
+}
+
+static struct platform_d

[RESEND v9 09/12] Input: Add power key driver for Rockchip RK805 PMIC

2017-08-15 Thread Joseph Chen
This driver provides a input driver for the power
key on the Rockchip RK805 PMIC.

Signed-off-by: Joseph Chen 
---
 drivers/input/misc/Kconfig|   6 +++
 drivers/input/misc/Makefile   |   1 +
 drivers/input/misc/rk805-pwrkey.c | 111 ++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/input/misc/rk805-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c522..72dc4f5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -571,6 +571,12 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_RK805_PWRKEY
+   tristate "Rockchip RK805 PMIC power key support"
+   depends on MFD_RK808
+   help
+ Select this option to enable power key driver for RK805.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate "Rotary encoders connected to GPIO pins"
depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f..c27052a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)  += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
+obj-$(CONFIG_INPUT_RK805_PWRKEY)   += rk805-pwrkey.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
 obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)   += soc_button_array.o
diff --git a/drivers/input/misc/rk805-pwrkey.c 
b/drivers/input/misc/rk805-pwrkey.c
new file mode 100644
index 000..e0fc66e
--- /dev/null
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -0,0 +1,111 @@
+/*
+ * Rockchip RK805 PMIC Power Key driver
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 1);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 0);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static int rk805_pwrkey_probe(struct platform_device *pdev)
+{
+   struct input_dev *pwr;
+   int fall_irq, rise_irq;
+   int err;
+
+   pwr = devm_input_allocate_device(>dev);
+   if (!pwr) {
+   dev_err(>dev, "Can't allocate power button\n");
+   return -ENOMEM;
+   }
+
+   pwr->name = "rk805 pwrkey";
+   pwr->phys = "rk805_pwrkey/input0";
+   pwr->dev.parent = >dev;
+   input_set_capability(pwr, EV_KEY, KEY_POWER);
+
+   fall_irq = platform_get_irq(pdev, 0);
+   if (fall_irq < 0) {
+   dev_err(>dev, "Can't get fall irq: %d\n", fall_irq);
+   return fall_irq;
+   }
+
+   rise_irq = platform_get_irq(pdev, 1);
+   if (rise_irq < 0) {
+   dev_err(>dev, "Can't get rise irq: %d\n", rise_irq);
+   return rise_irq;
+   }
+
+   err = devm_request_any_context_irq(>dev, fall_irq,
+  pwrkey_fall_irq,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "rk805_pwrkey_fall", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register fall irq: %d\n", err);
+   return err;
+   }
+
+   err = devm_request_any_context_irq(>dev, rise_irq,
+  pwrkey_rise_irq,
+  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+  "rk805_pwrkey_rise", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register rise irq: %d\n", err);
+   return err;
+   }
+
+   err = input_register_device(pwr);
+   if (err) {
+   dev_err(>dev, "Can't register power button: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, pwr);
+   device_init_wakeup(>dev, true);
+
+   return 0;
+}
+
+static struct platform_driver rk805_pwrkey_driver = {
+   .probe

[RESEND v9 10/12] mfd: rk808: Add RK805 pinctrl support

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 18329c8..c803d2d 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[RESEND v9 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

2017-08-15 Thread Joseph Chen
RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.

This driver is also designed for other Rockchip PMICs to expend.
Different PMIC maybe have different pin features, for example,
RK816 has one pin which can be used for TS or GPIO(input/out).
The mainly difference between PMICs pins are pinmux, direction
and output value, that is 'struct rk805_pin_config'.

Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
---
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/Makefile|   1 +
 drivers/pinctrl/pinctrl-rk805.c | 493 
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 8f8c2af..c33098f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -285,6 +285,15 @@ config PINCTRL_ZYNQ
help
  This selects the pinctrl driver for Xilinx Zynq.
 
+config PINCTRL_RK805
+   tristate "Pinctrl and GPIO driver for RK805 PMIC"
+   depends on MFD_RK808
+   select GPIOLIB
+   select PINMUX
+   select GENERIC_PINCONF
+   help
+ This selects the pinctrl driver for RK805.
+
 source "drivers/pinctrl/aspeed/Kconfig"
 source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a251f43..7485af3 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PINCTRL_LPC18XX) += pinctrl-lpc18xx.o
 obj-$(CONFIG_PINCTRL_TB10X)+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST)   += pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
+obj-$(CONFIG_PINCTRL_RK805)+= pinctrl-rk805.o
 
 obj-$(CONFIG_ARCH_ASPEED)  += aspeed/
 obj-y  += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000..b0bfd30
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
+/*
+ * Pinctrl driver for Rockchip RK805 PMIC
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen <che...@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Based on the pinctrl-as3722 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "pinconf.h"
+#include "pinctrl-utils.h"
+
+struct rk805_pin_function {
+   const char *name;
+   const char *const *groups;
+   unsigned int ngroups;
+   int mux_option;
+};
+
+struct rk805_pin_group {
+   const char *name;
+   const unsigned int pins[1];
+   unsigned int npins;
+};
+
+/*
+ * @reg: gpio setting register;
+ * @fun_mask: functions select mask value, when set is gpio;
+ * @dir_mask: input or output mask value, when set is output, otherwise input;
+ * @val_mask: gpio set value, when set is level high, otherwise low;
+ *
+ * Different PMIC has different pin features, belowing 3 mask members are not
+ * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
+ * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
+ * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
+ * necessary.
+ */
+struct rk805_pin_config {
+   u8 reg;
+   u8 fun_msk;
+   u8 dir_msk;
+   u8 val_msk;
+};
+
+struct rk805_pctrl_info {
+   struct rk808 *rk808;
+   struct device *dev;
+   struct pinctrl_dev *pctl;
+   struct gpio_chip gpio_chip;
+   struct pinctrl_desc pinctrl_desc;
+   const struct rk805_pin_function *functions;
+   unsigned int num_functions;
+   const struct rk805_pin_group *groups;
+   int num_pin_groups;
+   const struct pinctrl_pin_desc *pins;
+   unsigned int num_pins;
+   struct rk805_pin_config *pin_cfg;
+};
+
+enum rk805_pinmux_option {
+   RK805_PINMUX_GPIO,
+};
+
+enum {
+   RK805_GPIO0,
+   RK805_GPIO1,
+};
+
+static const char *const rk805_gpio_groups[] = {
+   "gpio0",
+   "gpio1",
+};
+
+/* RK805: 2 output only GPIOs */
+static const struct pinctrl_pin_desc rk805_pins_desc[] = {
+   PINCTRL_PIN(RK805_GPIO0, "gpio0"),
+   PINCTRL_PIN(RK805_GPIO1, "gpio1"),
+};
+
+static const struct rk805_pin_function rk805_pin_functions[] = {
+   {
+   .name = "gpio",
+   .groups = rk805_gpio_groups,
+   .ngroups = ARRAY_SIZE(r

[RESEND v9 10/12] mfd: rk808: Add RK805 pinctrl support

2017-08-15 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 18329c8..c803d2d 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[RESEND v9 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

2017-08-15 Thread Joseph Chen
RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.

This driver is also designed for other Rockchip PMICs to expend.
Different PMIC maybe have different pin features, for example,
RK816 has one pin which can be used for TS or GPIO(input/out).
The mainly difference between PMICs pins are pinmux, direction
and output value, that is 'struct rk805_pin_config'.

Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/Makefile|   1 +
 drivers/pinctrl/pinctrl-rk805.c | 493 
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 8f8c2af..c33098f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -285,6 +285,15 @@ config PINCTRL_ZYNQ
help
  This selects the pinctrl driver for Xilinx Zynq.
 
+config PINCTRL_RK805
+   tristate "Pinctrl and GPIO driver for RK805 PMIC"
+   depends on MFD_RK808
+   select GPIOLIB
+   select PINMUX
+   select GENERIC_PINCONF
+   help
+ This selects the pinctrl driver for RK805.
+
 source "drivers/pinctrl/aspeed/Kconfig"
 source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a251f43..7485af3 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PINCTRL_LPC18XX) += pinctrl-lpc18xx.o
 obj-$(CONFIG_PINCTRL_TB10X)+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST)   += pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
+obj-$(CONFIG_PINCTRL_RK805)+= pinctrl-rk805.o
 
 obj-$(CONFIG_ARCH_ASPEED)  += aspeed/
 obj-y  += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000..b0bfd30
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
+/*
+ * Pinctrl driver for Rockchip RK805 PMIC
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Based on the pinctrl-as3722 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "pinconf.h"
+#include "pinctrl-utils.h"
+
+struct rk805_pin_function {
+   const char *name;
+   const char *const *groups;
+   unsigned int ngroups;
+   int mux_option;
+};
+
+struct rk805_pin_group {
+   const char *name;
+   const unsigned int pins[1];
+   unsigned int npins;
+};
+
+/*
+ * @reg: gpio setting register;
+ * @fun_mask: functions select mask value, when set is gpio;
+ * @dir_mask: input or output mask value, when set is output, otherwise input;
+ * @val_mask: gpio set value, when set is level high, otherwise low;
+ *
+ * Different PMIC has different pin features, belowing 3 mask members are not
+ * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
+ * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
+ * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
+ * necessary.
+ */
+struct rk805_pin_config {
+   u8 reg;
+   u8 fun_msk;
+   u8 dir_msk;
+   u8 val_msk;
+};
+
+struct rk805_pctrl_info {
+   struct rk808 *rk808;
+   struct device *dev;
+   struct pinctrl_dev *pctl;
+   struct gpio_chip gpio_chip;
+   struct pinctrl_desc pinctrl_desc;
+   const struct rk805_pin_function *functions;
+   unsigned int num_functions;
+   const struct rk805_pin_group *groups;
+   int num_pin_groups;
+   const struct pinctrl_pin_desc *pins;
+   unsigned int num_pins;
+   struct rk805_pin_config *pin_cfg;
+};
+
+enum rk805_pinmux_option {
+   RK805_PINMUX_GPIO,
+};
+
+enum {
+   RK805_GPIO0,
+   RK805_GPIO1,
+};
+
+static const char *const rk805_gpio_groups[] = {
+   "gpio0",
+   "gpio1",
+};
+
+/* RK805: 2 output only GPIOs */
+static const struct pinctrl_pin_desc rk805_pins_desc[] = {
+   PINCTRL_PIN(RK805_GPIO0, "gpio0"),
+   PINCTRL_PIN(RK805_GPIO1, "gpio1"),
+};
+
+static const struct rk805_pin_function rk805_pin_functions[] = {
+   {
+   .name = "gpio",
+   .groups = rk805_gpio_groups,
+   .ngroups = ARRAY_SIZE(rk805_gpio_groups),
+   .mux_option = RK805_PINMUX_GPIO,
+   },
+};
+
+static const struct

[RESEND v9 06/12] rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the rtc driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/rtc/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5dc673d..47d6a8d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -352,11 +352,11 @@ config RTC_DRV_MAX77686
  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-   tristate "Rockchip RK808/RK818 RTC"
+   tristate "Rockchip RK805/RK808/RK818 RTC"
depends on MFD_RK808
help
  If you say yes here you will get support for the
- RTC of RK808 and RK818 PMIC.
+ RTC of RK805, RK808 and RK818 PMIC.
 
  This driver can also be built as a module. If so, the module
  will be called rk808-rtc.
-- 
1.9.1




[RESEND v9 06/12] rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the rtc driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/rtc/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5dc673d..47d6a8d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -352,11 +352,11 @@ config RTC_DRV_MAX77686
  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-   tristate "Rockchip RK808/RK818 RTC"
+   tristate "Rockchip RK805/RK808/RK818 RTC"
depends on MFD_RK808
help
  If you say yes here you will get support for the
- RTC of RK808 and RK818 PMIC.
+ RTC of RK805, RK808 and RK818 PMIC.
 
  This driver can also be built as a module. If so, the module
  will be called rk808-rtc.
-- 
1.9.1




[RESEND v9 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[RESEND v9 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[RESEND v9 07/12] mfd: dt-bindings: Add RK805 device tree bindings document

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Add device tree bindings documentation for Rockchip's RK805 PMIC.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Rob Herring <r...@kernel.org>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt 
b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8..91b6522 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
 RK8XX Power Management Integrated Circuit
 
 The rk8xx family current members:
+rk805
 rk808
 rk818
 
 Required properties:
-- compatible: "rockchip,rk808", "rockchip,rk818"
+- compatible: "rockchip,rk805"
+- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
 - rockchip,system-power-controller: Telling whether or not this pmic is 
controlling
   the system power.
 
+Optional RK805 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc6-supply:  The input supply for LDO_REG3
+
 Optional RK808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
/* standard regulator bindings here */
};
 
+Following regulators of the RK805 PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK805 datasheet.
+
+   - DCDC_REGn
+   - valid values for n are 1 to 4.
+   - LDO_REGn
+   - valid values for n are 1 to 3
+
 Following regulators of the RK808 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK808 datasheet.
-- 
1.9.1




[RESEND v9 07/12] mfd: dt-bindings: Add RK805 device tree bindings document

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

Add device tree bindings documentation for Rockchip's RK805 PMIC.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-by: Rob Herring 
Acked-for-MFD-by: Lee Jones 
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt 
b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8..91b6522 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
 RK8XX Power Management Integrated Circuit
 
 The rk8xx family current members:
+rk805
 rk808
 rk818
 
 Required properties:
-- compatible: "rockchip,rk808", "rockchip,rk818"
+- compatible: "rockchip,rk805"
+- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
 - rockchip,system-power-controller: Telling whether or not this pmic is 
controlling
   the system power.
 
+Optional RK805 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc6-supply:  The input supply for LDO_REG3
+
 Optional RK808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
/* standard regulator bindings here */
};
 
+Following regulators of the RK805 PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK805 datasheet.
+
+   - DCDC_REGn
+   - valid values for n are 1 to 4.
+   - LDO_REGn
+   - valid values for n are 1 to 3
+
 Following regulators of the RK808 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK808 datasheet.
-- 
1.9.1




[RESEND v9 04/12] mfd: rk808: Add RK805 support

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK805 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clocking

Both RK808 and RK805 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/rk808.c | 108 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb..b410a34 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -892,13 +892,13 @@ config MFD_RC5T583
  different functionality of the device.
 
 config MFD_RK808
-   tristate "Rockchip RK808/RK818 Power Management Chip"
+   tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
depends on I2C && OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
help
- If you say yes here you get support for the RK808 and RK818
+ If you say yes here you get support for the RK805, RK808 and RK818
  Power Management chips.
  This driver provides common support for accessing the device
  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 8e60eba..18329c8 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.volatile_reg = rk808_is_volatile_reg,
 };
 
+static const struct regmap_config rk805_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = RK805_OFF_SOURCE_REG,
+   .cache_type = REGCACHE_RBTREE,
+   .volatile_reg = rk808_is_volatile_reg,
+};
+
 static const struct regmap_config rk808_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -86,6 +94,16 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static const struct mfd_cell rk805s[] = {
+   { .name = "rk808-clkout", },
+   { .name = "rk808-regulator", },
+   {
+   .name = "rk808-rtc",
+   .num_resources = ARRAY_SIZE(rtc_resources),
+   .resources = _resources[0],
+   },
+};
+
 static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -106,6 +124,20 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
},
 };
 
+static const struct rk808_reg_data rk805_pre_init_reg[] = {
+   {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK3_ILMAX_3000MA},
+   {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK4_ILMAX_3500MA},
+   {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
+   {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
+   {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
+};
+
 static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
@@ -135,6 +167,41 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
VB_LO_SEL_3500MV },
 };
 
+static const struct regmap_irq rk805_irqs[] = {
+   [RK805_IRQ_PWRON_RISE] = {
+   .mask = RK805_IRQ_PWRON_RISE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_VB_LOW] = {
+   .mask = RK805_IRQ_VB_LOW_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON] = {
+   .mask = RK805_IRQ_PWRON_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_LP] = {
+   .mask = RK805_IRQ_PWRON_LP_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_HOTDIE] = {
+   .mask = RK805_IRQ_HOTDIE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_ALARM] = {
+   .mask = RK805_IRQ_RTC_ALARM_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_PERIOD] = {
+   .mask = RK805_IRQ_RTC_PERIOD_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_FALL] = {
+   .mask = RK805_IRQ_PWRON_FALL_MSK,
+   .reg_offset = 0,
+   },
+

[RESEND v9 04/12] mfd: rk808: Add RK805 support

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

The RK805 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clocking

Both RK808 and RK805 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/rk808.c | 108 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb..b410a34 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -892,13 +892,13 @@ config MFD_RC5T583
  different functionality of the device.
 
 config MFD_RK808
-   tristate "Rockchip RK808/RK818 Power Management Chip"
+   tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
depends on I2C && OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
help
- If you say yes here you get support for the RK808 and RK818
+ If you say yes here you get support for the RK805, RK808 and RK818
  Power Management chips.
  This driver provides common support for accessing the device
  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 8e60eba..18329c8 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.volatile_reg = rk808_is_volatile_reg,
 };
 
+static const struct regmap_config rk805_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = RK805_OFF_SOURCE_REG,
+   .cache_type = REGCACHE_RBTREE,
+   .volatile_reg = rk808_is_volatile_reg,
+};
+
 static const struct regmap_config rk808_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -86,6 +94,16 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static const struct mfd_cell rk805s[] = {
+   { .name = "rk808-clkout", },
+   { .name = "rk808-regulator", },
+   {
+   .name = "rk808-rtc",
+   .num_resources = ARRAY_SIZE(rtc_resources),
+   .resources = _resources[0],
+   },
+};
+
 static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -106,6 +124,20 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
},
 };
 
+static const struct rk808_reg_data rk805_pre_init_reg[] = {
+   {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK3_ILMAX_3000MA},
+   {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK4_ILMAX_3500MA},
+   {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
+   {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
+   {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
+};
+
 static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
@@ -135,6 +167,41 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
VB_LO_SEL_3500MV },
 };
 
+static const struct regmap_irq rk805_irqs[] = {
+   [RK805_IRQ_PWRON_RISE] = {
+   .mask = RK805_IRQ_PWRON_RISE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_VB_LOW] = {
+   .mask = RK805_IRQ_VB_LOW_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON] = {
+   .mask = RK805_IRQ_PWRON_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_LP] = {
+   .mask = RK805_IRQ_PWRON_LP_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_HOTDIE] = {
+   .mask = RK805_IRQ_HOTDIE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_ALARM] = {
+   .mask = RK805_IRQ_RTC_ALARM_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_PERIOD] = {
+   .mask = RK805_IRQ_RTC_PERIOD_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_FALL] = {
+   .mask = RK805_IRQ_PWRON_FALL_MSK,
+   .reg_offset = 0,
+   },
+};
+
 static const struct regmap_irq rk808_irqs[] = {
/* INT_STS */
[RK808_IRQ_VOUT_LO] = {
@@ -247,6 +314

[RESEND v9 03/12] regulator: rk808: Add regulator driver for RK805

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Add support for the rk805 regulator. The regulator module consists
of 4 DCDCs, 3 LDOs.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Mark Brown <broo...@kernel.org>
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 130 
 2 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb2..285e280 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -650,11 +650,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK808 and RK818.
+ PMIC RK805,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index fb44d52..128c81e 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
+#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
+   _vmask, _ereg, _emask, _etime)  \
+   [_id] = {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),  \
+   .enable_mask= (_emask), \
+   .enable_time= (_etime), \
+   .ops= _reg_ops,   \
+   }
+
 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _etime)  \
[_id] = {   \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct 
regulator_dev *rdev, int uv)
  sel);
 }
 
+static int rk805_set_suspend_enable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ rdev->desc->enable_mask);
+}
+
+static int rk805_set_suspend_disable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ 0);
+}
+
 static int rk808_set_suspend_enable(struct regulator_dev *rdev)
 {
unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev 
*rdev)
  rdev->desc->enable_mask);
 }
 
+static struct regulator_ops rk805_reg_ops = {
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+  

[RESEND v9 03/12] regulator: rk808: Add regulator driver for RK805

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

Add support for the rk805 regulator. The regulator module consists
of 4 DCDCs, 3 LDOs.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-by: Mark Brown 
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 130 
 2 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb2..285e280 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -650,11 +650,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK808 and RK818.
+ PMIC RK805,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index fb44d52..128c81e 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
+#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
+   _vmask, _ereg, _emask, _etime)  \
+   [_id] = {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),  \
+   .enable_mask= (_emask), \
+   .enable_time= (_etime), \
+   .ops= _reg_ops,   \
+   }
+
 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _etime)  \
[_id] = {   \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct 
regulator_dev *rdev, int uv)
  sel);
 }
 
+static int rk805_set_suspend_enable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ rdev->desc->enable_mask);
+}
+
+static int rk805_set_suspend_disable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ 0);
+}
+
 static int rk808_set_suspend_enable(struct regulator_dev *rdev)
 {
unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev 
*rdev)
  rdev->desc->enable_mask);
 }
 
+static struct regulator_ops rk805_reg_ops = {
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+   .set_suspend_voltage= rk808_set_suspend_vol

[RESEND v9 02/12] mfd: rk808: add rk805 regs addr and ID

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 include/linux/mfd/rk808.h | 120 ++
 1 file changed, 120 insertions(+)

diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 54feb14..d315659 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
 #define RK818_USB_ILMIN_2000MA 0x7
 #define RK818_USB_CHG_SD_VSEL_MASK 0x70
 
+/* RK805 */
+enum rk805_reg {
+   RK805_ID_DCDC1,
+   RK805_ID_DCDC2,
+   RK805_ID_DCDC3,
+   RK805_ID_DCDC4,
+   RK805_ID_LDO1,
+   RK805_ID_LDO2,
+   RK805_ID_LDO3,
+};
+
+/* CONFIG REGISTER */
+#define RK805_VB_MON_REG   0x21
+#define RK805_THERMAL_REG  0x22
+
+/* POWER CHANNELS ENABLE REGISTER */
+#define RK805_DCDC_EN_REG  0x23
+#define RK805_SLP_DCDC_EN_REG  0x25
+#define RK805_SLP_LDO_EN_REG   0x26
+#define RK805_LDO_EN_REG   0x27
+
+/* BUCK AND LDO CONFIG REGISTER */
+#define RK805_BUCK_LDO_SLP_LP_EN_REG   0x2A
+#define RK805_BUCK1_CONFIG_REG 0x2E
+#define RK805_BUCK1_ON_VSEL_REG0x2F
+#define RK805_BUCK1_SLP_VSEL_REG   0x30
+#define RK805_BUCK2_CONFIG_REG 0x32
+#define RK805_BUCK2_ON_VSEL_REG0x33
+#define RK805_BUCK2_SLP_VSEL_REG   0x34
+#define RK805_BUCK3_CONFIG_REG 0x36
+#define RK805_BUCK4_CONFIG_REG 0x37
+#define RK805_BUCK4_ON_VSEL_REG0x38
+#define RK805_BUCK4_SLP_VSEL_REG   0x39
+#define RK805_LDO1_ON_VSEL_REG 0x3B
+#define RK805_LDO1_SLP_VSEL_REG0x3C
+#define RK805_LDO2_ON_VSEL_REG 0x3D
+#define RK805_LDO2_SLP_VSEL_REG0x3E
+#define RK805_LDO3_ON_VSEL_REG 0x3F
+#define RK805_LDO3_SLP_VSEL_REG0x40
+
+/* INTERRUPT REGISTER */
+#define RK805_PWRON_LP_INT_TIME_REG0x47
+#define RK805_PWRON_DB_REG 0x48
+#define RK805_DEV_CTRL_REG 0x4B
+#define RK805_INT_STS_REG  0x4C
+#define RK805_INT_STS_MSK_REG  0x4D
+#define RK805_GPIO_IO_POL_REG  0x50
+#define RK805_OUT_REG  0x52
+#define RK805_ON_SOURCE_REG0xAE
+#define RK805_OFF_SOURCE_REG   0xAF
+
+#define RK805_NUM_REGULATORS   7
+
+#define RK805_PWRON_FALL_RISE_INT_EN   0x0
+#define RK805_PWRON_FALL_RISE_INT_MSK  0x81
+
+/* RK805 IRQ Definitions */
+#define RK805_IRQ_PWRON_RISE   0
+#define RK805_IRQ_VB_LOW   1
+#define RK805_IRQ_PWRON2
+#define RK805_IRQ_PWRON_LP 3
+#define RK805_IRQ_HOTDIE   4
+#define RK805_IRQ_RTC_ALARM5
+#define RK805_IRQ_RTC_PERIOD   6
+#define RK805_IRQ_PWRON_FALL   7
+
+#define RK805_IRQ_PWRON_RISE_MSK   BIT(0)
+#define RK805_IRQ_VB_LOW_MSK   BIT(1)
+#define RK805_IRQ_PWRON_MSKBIT(2)
+#define RK805_IRQ_PWRON_LP_MSK BIT(3)
+#define RK805_IRQ_HOTDIE_MSK   BIT(4)
+#define RK805_IRQ_RTC_ALARM_MSKBIT(5)
+#define RK805_IRQ_RTC_PERIOD_MSK   BIT(6)
+#define RK805_IRQ_PWRON_FALL_MSK   BIT(7)
+
+#define RK805_PWR_RISE_INT_STATUS  BIT(0)
+#define RK805_VB_LOW_INT_STATUSBIT(1)
+#define RK805_PWRON_INT_STATUS BIT(2)
+#define RK805_PWRON_LP_INT_STATUS  BIT(3)
+#define RK805_HOTDIE_INT_STATUSBIT(4)
+#define RK805_ALARM_INT_STATUS BIT(5)
+#define RK805_PERIOD_INT_STATUSBIT(6)
+#define RK805_PWR_FALL_INT_STATUS  BIT(7)
+
+#define RK805_BUCK1_2_ILMAX_MASK   (3 << 6)
+#define RK805_BUCK3_4_ILMAX_MASK(3 << 3)
+#define RK805_RTC_PERIOD_INT_MASK  (1 << 6)
+#define RK805_RTC_ALARM_INT_MASK   (1 << 5)
+#define RK805_INT_ALARM_EN (1 << 3)
+#define RK805_INT_TIMER_EN (1 << 2)
+
 /* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO  0
 #define RK808_IRQ_VB_LO1
@@ -298,7 +389,14 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define TEMP115C   0x0c
+#define TEMP_HOTDIE_MSK0x0c
+#define SLP_SD_MSK (0x3 << 2)
+#define SHUTDOWN_FUN   (0x2 << 2)
+#define SLEEP_FUN  (0x1 << 2)
 #define RK8XX_ID_MSK   0xfff0
+#define FPWM_MODE  BIT(7)
+
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
@@ -322,6 +420,28 @@ enum {
 };
 
 enum {
+   RK805_BUCK1_2_ILMAX_2500MA,
+   RK805_BUCK1_2_ILMAX_3000MA,
+   RK805_BUCK1_2_ILMAX_3500MA,
+   RK805_BUCK1_2_ILMAX_4000MA,
+};
+
+enum {
+   RK805_BUCK3_ILMAX_1500MA,
+   RK805_BUCK3_ILMAX_2000MA,
+

[RESEND v9 00/12] rk808: Add RK805 support

2017-08-15 Thread Joseph Chen
change in RESEND v9:
None changes, add Lee Jones and other related email address.

change in v9:
PATCH V9 1/12: (1) fix spelling issue: s/Chip/chip/
   (2) apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 2/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 3/12: None
PATCH V9 4/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 5/12: None
PATCH V9 6/12: None
PATCH V9 7/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 8/12: apply tag: Acked-by: Linus Walleij <linus.wall...@linaro.org>
PATCH V9 9/12: None (Actually, something directly updated by Dmitry Torokhov 
and applied on PATCH V7.
   Link: 
https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next
PATCH V9 10/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 11/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 12/12: None

change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 2/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 3/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 4/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 5/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 6/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 7/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij <linus.wall...@linaro.org>   
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 
<linus.wall...@linaro.org>

change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown <broo...@kernel.org>
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring <r...@kernel.org>
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl

[RESEND v9 01/12] mfd: rk808: fix up the chip id get failed

2017-08-15 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..8e60eba 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* Read chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[RESEND v9 02/12] mfd: rk808: add rk805 regs addr and ID

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 include/linux/mfd/rk808.h | 120 ++
 1 file changed, 120 insertions(+)

diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 54feb14..d315659 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
 #define RK818_USB_ILMIN_2000MA 0x7
 #define RK818_USB_CHG_SD_VSEL_MASK 0x70
 
+/* RK805 */
+enum rk805_reg {
+   RK805_ID_DCDC1,
+   RK805_ID_DCDC2,
+   RK805_ID_DCDC3,
+   RK805_ID_DCDC4,
+   RK805_ID_LDO1,
+   RK805_ID_LDO2,
+   RK805_ID_LDO3,
+};
+
+/* CONFIG REGISTER */
+#define RK805_VB_MON_REG   0x21
+#define RK805_THERMAL_REG  0x22
+
+/* POWER CHANNELS ENABLE REGISTER */
+#define RK805_DCDC_EN_REG  0x23
+#define RK805_SLP_DCDC_EN_REG  0x25
+#define RK805_SLP_LDO_EN_REG   0x26
+#define RK805_LDO_EN_REG   0x27
+
+/* BUCK AND LDO CONFIG REGISTER */
+#define RK805_BUCK_LDO_SLP_LP_EN_REG   0x2A
+#define RK805_BUCK1_CONFIG_REG 0x2E
+#define RK805_BUCK1_ON_VSEL_REG0x2F
+#define RK805_BUCK1_SLP_VSEL_REG   0x30
+#define RK805_BUCK2_CONFIG_REG 0x32
+#define RK805_BUCK2_ON_VSEL_REG0x33
+#define RK805_BUCK2_SLP_VSEL_REG   0x34
+#define RK805_BUCK3_CONFIG_REG 0x36
+#define RK805_BUCK4_CONFIG_REG 0x37
+#define RK805_BUCK4_ON_VSEL_REG0x38
+#define RK805_BUCK4_SLP_VSEL_REG   0x39
+#define RK805_LDO1_ON_VSEL_REG 0x3B
+#define RK805_LDO1_SLP_VSEL_REG0x3C
+#define RK805_LDO2_ON_VSEL_REG 0x3D
+#define RK805_LDO2_SLP_VSEL_REG0x3E
+#define RK805_LDO3_ON_VSEL_REG 0x3F
+#define RK805_LDO3_SLP_VSEL_REG0x40
+
+/* INTERRUPT REGISTER */
+#define RK805_PWRON_LP_INT_TIME_REG0x47
+#define RK805_PWRON_DB_REG 0x48
+#define RK805_DEV_CTRL_REG 0x4B
+#define RK805_INT_STS_REG  0x4C
+#define RK805_INT_STS_MSK_REG  0x4D
+#define RK805_GPIO_IO_POL_REG  0x50
+#define RK805_OUT_REG  0x52
+#define RK805_ON_SOURCE_REG0xAE
+#define RK805_OFF_SOURCE_REG   0xAF
+
+#define RK805_NUM_REGULATORS   7
+
+#define RK805_PWRON_FALL_RISE_INT_EN   0x0
+#define RK805_PWRON_FALL_RISE_INT_MSK  0x81
+
+/* RK805 IRQ Definitions */
+#define RK805_IRQ_PWRON_RISE   0
+#define RK805_IRQ_VB_LOW   1
+#define RK805_IRQ_PWRON2
+#define RK805_IRQ_PWRON_LP 3
+#define RK805_IRQ_HOTDIE   4
+#define RK805_IRQ_RTC_ALARM5
+#define RK805_IRQ_RTC_PERIOD   6
+#define RK805_IRQ_PWRON_FALL   7
+
+#define RK805_IRQ_PWRON_RISE_MSK   BIT(0)
+#define RK805_IRQ_VB_LOW_MSK   BIT(1)
+#define RK805_IRQ_PWRON_MSKBIT(2)
+#define RK805_IRQ_PWRON_LP_MSK BIT(3)
+#define RK805_IRQ_HOTDIE_MSK   BIT(4)
+#define RK805_IRQ_RTC_ALARM_MSKBIT(5)
+#define RK805_IRQ_RTC_PERIOD_MSK   BIT(6)
+#define RK805_IRQ_PWRON_FALL_MSK   BIT(7)
+
+#define RK805_PWR_RISE_INT_STATUS  BIT(0)
+#define RK805_VB_LOW_INT_STATUSBIT(1)
+#define RK805_PWRON_INT_STATUS BIT(2)
+#define RK805_PWRON_LP_INT_STATUS  BIT(3)
+#define RK805_HOTDIE_INT_STATUSBIT(4)
+#define RK805_ALARM_INT_STATUS BIT(5)
+#define RK805_PERIOD_INT_STATUSBIT(6)
+#define RK805_PWR_FALL_INT_STATUS  BIT(7)
+
+#define RK805_BUCK1_2_ILMAX_MASK   (3 << 6)
+#define RK805_BUCK3_4_ILMAX_MASK(3 << 3)
+#define RK805_RTC_PERIOD_INT_MASK  (1 << 6)
+#define RK805_RTC_ALARM_INT_MASK   (1 << 5)
+#define RK805_INT_ALARM_EN (1 << 3)
+#define RK805_INT_TIMER_EN (1 << 2)
+
 /* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO  0
 #define RK808_IRQ_VB_LO1
@@ -298,7 +389,14 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define TEMP115C   0x0c
+#define TEMP_HOTDIE_MSK0x0c
+#define SLP_SD_MSK (0x3 << 2)
+#define SHUTDOWN_FUN   (0x2 << 2)
+#define SLEEP_FUN  (0x1 << 2)
 #define RK8XX_ID_MSK   0xfff0
+#define FPWM_MODE  BIT(7)
+
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
@@ -322,6 +420,28 @@ enum {
 };
 
 enum {
+   RK805_BUCK1_2_ILMAX_2500MA,
+   RK805_BUCK1_2_ILMAX_3000MA,
+   RK805_BUCK1_2_ILMAX_3500MA,
+   RK805_BUCK1_2_ILMAX_4000MA,
+};
+
+enum {
+   RK805_BUCK3_ILMAX_1500MA,
+   RK805_BUCK3_ILMAX_2000MA,
+   RK805_BUCK3_ILMAX_2500MA,
+   RK805_BUCK3_ILMAX_3000MA,
+};
+
+enum {
+   RK805_BUCK4_ILMAX_2000MA,
+   RK80

[RESEND v9 00/12] rk808: Add RK805 support

2017-08-15 Thread Joseph Chen
change in RESEND v9:
None changes, add Lee Jones and other related email address.

change in v9:
PATCH V9 1/12: (1) fix spelling issue: s/Chip/chip/
   (2) apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 2/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 3/12: None
PATCH V9 4/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 5/12: None
PATCH V9 6/12: None
PATCH V9 7/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 8/12: apply tag: Acked-by: Linus Walleij 
PATCH V9 9/12: None (Actually, something directly updated by Dmitry Torokhov 
and applied on PATCH V7.
   Link: 
https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next
PATCH V9 10/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 11/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 12/12: None

change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen 
PATCH V8 2/12: add: Signed-off-by: Joseph Chen 
PATCH V8 3/12: add: Signed-off-by: Joseph Chen 
PATCH V8 4/12: add: Signed-off-by: Joseph Chen 
PATCH V8 5/12: add: Signed-off-by: Joseph Chen 
PATCH V8 6/12: add: Signed-off-by: Joseph Chen 
PATCH V8 7/12: add: Signed-off-by: Joseph Chen 
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 


change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown 
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring 
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-
 drivers/input/misc/Kconfig |   6 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/rk805-pwrkey.c  | 111 +
 drivers/mfd/Kconfig|   4 +-
 drivers/mfd/rk808.c| 147 +-
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/Makefile   |   1 

[RESEND v9 01/12] mfd: rk808: fix up the chip id get failed

2017-08-15 Thread Joseph Chen
From: Elaine Zhang 

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..8e60eba 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* Read chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v9 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-09 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




[PATCH v9 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-09 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




[PATCH v9 09/12] Input: Add power key driver for Rockchip RK805 PMIC

2017-08-09 Thread Joseph Chen
This driver provides a input driver for the power
key on the Rockchip RK805 PMIC.

Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/input/misc/Kconfig|   6 +++
 drivers/input/misc/Makefile   |   1 +
 drivers/input/misc/rk805-pwrkey.c | 111 ++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/input/misc/rk805-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c522..72dc4f5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -571,6 +571,12 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_RK805_PWRKEY
+   tristate "Rockchip RK805 PMIC power key support"
+   depends on MFD_RK808
+   help
+ Select this option to enable power key driver for RK805.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate "Rotary encoders connected to GPIO pins"
depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f..c27052a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)  += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
+obj-$(CONFIG_INPUT_RK805_PWRKEY)   += rk805-pwrkey.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
 obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)   += soc_button_array.o
diff --git a/drivers/input/misc/rk805-pwrkey.c 
b/drivers/input/misc/rk805-pwrkey.c
new file mode 100644
index 000..e0fc66e
--- /dev/null
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -0,0 +1,111 @@
+/*
+ * Rockchip RK805 PMIC Power Key driver
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen <che...@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 1);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 0);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static int rk805_pwrkey_probe(struct platform_device *pdev)
+{
+   struct input_dev *pwr;
+   int fall_irq, rise_irq;
+   int err;
+
+   pwr = devm_input_allocate_device(>dev);
+   if (!pwr) {
+   dev_err(>dev, "Can't allocate power button\n");
+   return -ENOMEM;
+   }
+
+   pwr->name = "rk805 pwrkey";
+   pwr->phys = "rk805_pwrkey/input0";
+   pwr->dev.parent = >dev;
+   input_set_capability(pwr, EV_KEY, KEY_POWER);
+
+   fall_irq = platform_get_irq(pdev, 0);
+   if (fall_irq < 0) {
+   dev_err(>dev, "Can't get fall irq: %d\n", fall_irq);
+   return fall_irq;
+   }
+
+   rise_irq = platform_get_irq(pdev, 1);
+   if (rise_irq < 0) {
+   dev_err(>dev, "Can't get rise irq: %d\n", rise_irq);
+   return rise_irq;
+   }
+
+   err = devm_request_any_context_irq(>dev, fall_irq,
+  pwrkey_fall_irq,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "rk805_pwrkey_fall", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register fall irq: %d\n", err);
+   return err;
+   }
+
+   err = devm_request_any_context_irq(>dev, rise_irq,
+  pwrkey_rise_irq,
+  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+  "rk805_pwrkey_rise", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register rise irq: %d\n", err);
+   return err;
+   }
+
+   err = input_register_device(pwr);
+   if (err) {
+   dev_err(>dev, "Can't register power button: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, pwr);
+   device_init_wakeup(>dev, true);
+
+   return 0;
+}
+
+static struct platform_d

[PATCH v9 06/12] rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the rtc driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/rtc/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5dc673d..47d6a8d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -352,11 +352,11 @@ config RTC_DRV_MAX77686
  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-   tristate "Rockchip RK808/RK818 RTC"
+   tristate "Rockchip RK805/RK808/RK818 RTC"
depends on MFD_RK808
help
  If you say yes here you will get support for the
- RTC of RK808 and RK818 PMIC.
+ RTC of RK805, RK808 and RK818 PMIC.
 
  This driver can also be built as a module. If so, the module
  will be called rk808-rtc.
-- 
1.9.1




[PATCH v9 11/12] mfd: rk808: Add RK805 power key support

2017-08-09 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index c803d2d..216fbf6 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[PATCH v9 09/12] Input: Add power key driver for Rockchip RK805 PMIC

2017-08-09 Thread Joseph Chen
This driver provides a input driver for the power
key on the Rockchip RK805 PMIC.

Signed-off-by: Joseph Chen 
---
 drivers/input/misc/Kconfig|   6 +++
 drivers/input/misc/Makefile   |   1 +
 drivers/input/misc/rk805-pwrkey.c | 111 ++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/input/misc/rk805-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c522..72dc4f5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -571,6 +571,12 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_RK805_PWRKEY
+   tristate "Rockchip RK805 PMIC power key support"
+   depends on MFD_RK808
+   help
+ Select this option to enable power key driver for RK805.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate "Rotary encoders connected to GPIO pins"
depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f..c27052a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)  += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
+obj-$(CONFIG_INPUT_RK805_PWRKEY)   += rk805-pwrkey.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
 obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)   += soc_button_array.o
diff --git a/drivers/input/misc/rk805-pwrkey.c 
b/drivers/input/misc/rk805-pwrkey.c
new file mode 100644
index 000..e0fc66e
--- /dev/null
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -0,0 +1,111 @@
+/*
+ * Rockchip RK805 PMIC Power Key driver
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 1);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 0);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static int rk805_pwrkey_probe(struct platform_device *pdev)
+{
+   struct input_dev *pwr;
+   int fall_irq, rise_irq;
+   int err;
+
+   pwr = devm_input_allocate_device(>dev);
+   if (!pwr) {
+   dev_err(>dev, "Can't allocate power button\n");
+   return -ENOMEM;
+   }
+
+   pwr->name = "rk805 pwrkey";
+   pwr->phys = "rk805_pwrkey/input0";
+   pwr->dev.parent = >dev;
+   input_set_capability(pwr, EV_KEY, KEY_POWER);
+
+   fall_irq = platform_get_irq(pdev, 0);
+   if (fall_irq < 0) {
+   dev_err(>dev, "Can't get fall irq: %d\n", fall_irq);
+   return fall_irq;
+   }
+
+   rise_irq = platform_get_irq(pdev, 1);
+   if (rise_irq < 0) {
+   dev_err(>dev, "Can't get rise irq: %d\n", rise_irq);
+   return rise_irq;
+   }
+
+   err = devm_request_any_context_irq(>dev, fall_irq,
+  pwrkey_fall_irq,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "rk805_pwrkey_fall", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register fall irq: %d\n", err);
+   return err;
+   }
+
+   err = devm_request_any_context_irq(>dev, rise_irq,
+  pwrkey_rise_irq,
+  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+  "rk805_pwrkey_rise", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register rise irq: %d\n", err);
+   return err;
+   }
+
+   err = input_register_device(pwr);
+   if (err) {
+   dev_err(>dev, "Can't register power button: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, pwr);
+   device_init_wakeup(>dev, true);
+
+   return 0;
+}
+
+static struct platform_driver rk805_pwrkey_driver = {
+   .probe

[PATCH v9 06/12] rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the rtc driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/rtc/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5dc673d..47d6a8d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -352,11 +352,11 @@ config RTC_DRV_MAX77686
  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-   tristate "Rockchip RK808/RK818 RTC"
+   tristate "Rockchip RK805/RK808/RK818 RTC"
depends on MFD_RK808
help
  If you say yes here you will get support for the
- RTC of RK808 and RK818 PMIC.
+ RTC of RK805, RK808 and RK818 PMIC.
 
  This driver can also be built as a module. If so, the module
  will be called rk808-rtc.
-- 
1.9.1




[PATCH v9 11/12] mfd: rk808: Add RK805 power key support

2017-08-09 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index c803d2d..216fbf6 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[PATCH v9 10/12] mfd: rk808: Add RK805 pinctrl support

2017-08-09 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 18329c8..c803d2d 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[PATCH v9 10/12] mfd: rk808: Add RK805 pinctrl support

2017-08-09 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 18329c8..c803d2d 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[PATCH v9 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

2017-08-09 Thread Joseph Chen
RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.

This driver is also designed for other Rockchip PMICs to expend.
Different PMIC maybe have different pin features, for example,
RK816 has one pin which can be used for TS or GPIO(input/out).
The mainly difference between PMICs pins are pinmux, direction
and output value, that is 'struct rk805_pin_config'.

Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
---
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/Makefile|   1 +
 drivers/pinctrl/pinctrl-rk805.c | 493 
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 8f8c2af..c33098f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -285,6 +285,15 @@ config PINCTRL_ZYNQ
help
  This selects the pinctrl driver for Xilinx Zynq.
 
+config PINCTRL_RK805
+   tristate "Pinctrl and GPIO driver for RK805 PMIC"
+   depends on MFD_RK808
+   select GPIOLIB
+   select PINMUX
+   select GENERIC_PINCONF
+   help
+ This selects the pinctrl driver for RK805.
+
 source "drivers/pinctrl/aspeed/Kconfig"
 source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a251f43..7485af3 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PINCTRL_LPC18XX) += pinctrl-lpc18xx.o
 obj-$(CONFIG_PINCTRL_TB10X)+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST)   += pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
+obj-$(CONFIG_PINCTRL_RK805)+= pinctrl-rk805.o
 
 obj-$(CONFIG_ARCH_ASPEED)  += aspeed/
 obj-y  += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000..b0bfd30
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
+/*
+ * Pinctrl driver for Rockchip RK805 PMIC
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen <che...@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Based on the pinctrl-as3722 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "pinconf.h"
+#include "pinctrl-utils.h"
+
+struct rk805_pin_function {
+   const char *name;
+   const char *const *groups;
+   unsigned int ngroups;
+   int mux_option;
+};
+
+struct rk805_pin_group {
+   const char *name;
+   const unsigned int pins[1];
+   unsigned int npins;
+};
+
+/*
+ * @reg: gpio setting register;
+ * @fun_mask: functions select mask value, when set is gpio;
+ * @dir_mask: input or output mask value, when set is output, otherwise input;
+ * @val_mask: gpio set value, when set is level high, otherwise low;
+ *
+ * Different PMIC has different pin features, belowing 3 mask members are not
+ * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
+ * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
+ * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
+ * necessary.
+ */
+struct rk805_pin_config {
+   u8 reg;
+   u8 fun_msk;
+   u8 dir_msk;
+   u8 val_msk;
+};
+
+struct rk805_pctrl_info {
+   struct rk808 *rk808;
+   struct device *dev;
+   struct pinctrl_dev *pctl;
+   struct gpio_chip gpio_chip;
+   struct pinctrl_desc pinctrl_desc;
+   const struct rk805_pin_function *functions;
+   unsigned int num_functions;
+   const struct rk805_pin_group *groups;
+   int num_pin_groups;
+   const struct pinctrl_pin_desc *pins;
+   unsigned int num_pins;
+   struct rk805_pin_config *pin_cfg;
+};
+
+enum rk805_pinmux_option {
+   RK805_PINMUX_GPIO,
+};
+
+enum {
+   RK805_GPIO0,
+   RK805_GPIO1,
+};
+
+static const char *const rk805_gpio_groups[] = {
+   "gpio0",
+   "gpio1",
+};
+
+/* RK805: 2 output only GPIOs */
+static const struct pinctrl_pin_desc rk805_pins_desc[] = {
+   PINCTRL_PIN(RK805_GPIO0, "gpio0"),
+   PINCTRL_PIN(RK805_GPIO1, "gpio1"),
+};
+
+static const struct rk805_pin_function rk805_pin_functions[] = {
+   {
+   .name = "gpio",
+   .groups = rk805_gpio_groups,
+   .ngroups = ARRAY_SIZE(r

[PATCH v9 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

2017-08-09 Thread Joseph Chen
RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.

This driver is also designed for other Rockchip PMICs to expend.
Different PMIC maybe have different pin features, for example,
RK816 has one pin which can be used for TS or GPIO(input/out).
The mainly difference between PMICs pins are pinmux, direction
and output value, that is 'struct rk805_pin_config'.

Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/Makefile|   1 +
 drivers/pinctrl/pinctrl-rk805.c | 493 
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 8f8c2af..c33098f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -285,6 +285,15 @@ config PINCTRL_ZYNQ
help
  This selects the pinctrl driver for Xilinx Zynq.
 
+config PINCTRL_RK805
+   tristate "Pinctrl and GPIO driver for RK805 PMIC"
+   depends on MFD_RK808
+   select GPIOLIB
+   select PINMUX
+   select GENERIC_PINCONF
+   help
+ This selects the pinctrl driver for RK805.
+
 source "drivers/pinctrl/aspeed/Kconfig"
 source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a251f43..7485af3 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PINCTRL_LPC18XX) += pinctrl-lpc18xx.o
 obj-$(CONFIG_PINCTRL_TB10X)+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST)   += pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
+obj-$(CONFIG_PINCTRL_RK805)+= pinctrl-rk805.o
 
 obj-$(CONFIG_ARCH_ASPEED)  += aspeed/
 obj-y  += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000..b0bfd30
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
+/*
+ * Pinctrl driver for Rockchip RK805 PMIC
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Based on the pinctrl-as3722 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "pinconf.h"
+#include "pinctrl-utils.h"
+
+struct rk805_pin_function {
+   const char *name;
+   const char *const *groups;
+   unsigned int ngroups;
+   int mux_option;
+};
+
+struct rk805_pin_group {
+   const char *name;
+   const unsigned int pins[1];
+   unsigned int npins;
+};
+
+/*
+ * @reg: gpio setting register;
+ * @fun_mask: functions select mask value, when set is gpio;
+ * @dir_mask: input or output mask value, when set is output, otherwise input;
+ * @val_mask: gpio set value, when set is level high, otherwise low;
+ *
+ * Different PMIC has different pin features, belowing 3 mask members are not
+ * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
+ * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
+ * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
+ * necessary.
+ */
+struct rk805_pin_config {
+   u8 reg;
+   u8 fun_msk;
+   u8 dir_msk;
+   u8 val_msk;
+};
+
+struct rk805_pctrl_info {
+   struct rk808 *rk808;
+   struct device *dev;
+   struct pinctrl_dev *pctl;
+   struct gpio_chip gpio_chip;
+   struct pinctrl_desc pinctrl_desc;
+   const struct rk805_pin_function *functions;
+   unsigned int num_functions;
+   const struct rk805_pin_group *groups;
+   int num_pin_groups;
+   const struct pinctrl_pin_desc *pins;
+   unsigned int num_pins;
+   struct rk805_pin_config *pin_cfg;
+};
+
+enum rk805_pinmux_option {
+   RK805_PINMUX_GPIO,
+};
+
+enum {
+   RK805_GPIO0,
+   RK805_GPIO1,
+};
+
+static const char *const rk805_gpio_groups[] = {
+   "gpio0",
+   "gpio1",
+};
+
+/* RK805: 2 output only GPIOs */
+static const struct pinctrl_pin_desc rk805_pins_desc[] = {
+   PINCTRL_PIN(RK805_GPIO0, "gpio0"),
+   PINCTRL_PIN(RK805_GPIO1, "gpio1"),
+};
+
+static const struct rk805_pin_function rk805_pin_functions[] = {
+   {
+   .name = "gpio",
+   .groups = rk805_gpio_groups,
+   .ngroups = ARRAY_SIZE(rk805_gpio_groups),
+   .mux_option = RK805_PINMUX_GPIO,
+   },
+};
+
+static const struct

[PATCH v9 07/12] mfd: dt-bindings: Add RK805 device tree bindings document

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Add device tree bindings documentation for Rockchip's RK805 PMIC.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Rob Herring <r...@kernel.org>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt 
b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8..91b6522 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
 RK8XX Power Management Integrated Circuit
 
 The rk8xx family current members:
+rk805
 rk808
 rk818
 
 Required properties:
-- compatible: "rockchip,rk808", "rockchip,rk818"
+- compatible: "rockchip,rk805"
+- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
 - rockchip,system-power-controller: Telling whether or not this pmic is 
controlling
   the system power.
 
+Optional RK805 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc6-supply:  The input supply for LDO_REG3
+
 Optional RK808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
/* standard regulator bindings here */
};
 
+Following regulators of the RK805 PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK805 datasheet.
+
+   - DCDC_REGn
+   - valid values for n are 1 to 4.
+   - LDO_REGn
+   - valid values for n are 1 to 3
+
 Following regulators of the RK808 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK808 datasheet.
-- 
1.9.1




[PATCH v9 07/12] mfd: dt-bindings: Add RK805 device tree bindings document

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

Add device tree bindings documentation for Rockchip's RK805 PMIC.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-by: Rob Herring 
Acked-for-MFD-by: Lee Jones 
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt 
b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8..91b6522 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
 RK8XX Power Management Integrated Circuit
 
 The rk8xx family current members:
+rk805
 rk808
 rk818
 
 Required properties:
-- compatible: "rockchip,rk808", "rockchip,rk818"
+- compatible: "rockchip,rk805"
+- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
 - rockchip,system-power-controller: Telling whether or not this pmic is 
controlling
   the system power.
 
+Optional RK805 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc6-supply:  The input supply for LDO_REG3
+
 Optional RK808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
/* standard regulator bindings here */
};
 
+Following regulators of the RK805 PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK805 datasheet.
+
+   - DCDC_REGn
+   - valid values for n are 1 to 4.
+   - LDO_REGn
+   - valid values for n are 1 to 3
+
 Following regulators of the RK808 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK808 datasheet.
-- 
1.9.1




[PATCH v9 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[PATCH v9 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[PATCH v9 03/12] regulator: rk808: Add regulator driver for RK805

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Add support for the rk805 regulator. The regulator module consists
of 4 DCDCs, 3 LDOs.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Mark Brown <broo...@kernel.org>
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 130 
 2 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb2..285e280 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -650,11 +650,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK808 and RK818.
+ PMIC RK805,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index fb44d52..128c81e 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
+#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
+   _vmask, _ereg, _emask, _etime)  \
+   [_id] = {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),  \
+   .enable_mask= (_emask), \
+   .enable_time= (_etime), \
+   .ops= _reg_ops,   \
+   }
+
 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _etime)  \
[_id] = {   \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct 
regulator_dev *rdev, int uv)
  sel);
 }
 
+static int rk805_set_suspend_enable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ rdev->desc->enable_mask);
+}
+
+static int rk805_set_suspend_disable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ 0);
+}
+
 static int rk808_set_suspend_enable(struct regulator_dev *rdev)
 {
unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev 
*rdev)
  rdev->desc->enable_mask);
 }
 
+static struct regulator_ops rk805_reg_ops = {
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+  

[PATCH v9 03/12] regulator: rk808: Add regulator driver for RK805

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

Add support for the rk805 regulator. The regulator module consists
of 4 DCDCs, 3 LDOs.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-by: Mark Brown 
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 130 
 2 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb2..285e280 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -650,11 +650,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK808 and RK818.
+ PMIC RK805,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index fb44d52..128c81e 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
+#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
+   _vmask, _ereg, _emask, _etime)  \
+   [_id] = {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),  \
+   .enable_mask= (_emask), \
+   .enable_time= (_etime), \
+   .ops= _reg_ops,   \
+   }
+
 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _etime)  \
[_id] = {   \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct 
regulator_dev *rdev, int uv)
  sel);
 }
 
+static int rk805_set_suspend_enable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ rdev->desc->enable_mask);
+}
+
+static int rk805_set_suspend_disable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ 0);
+}
+
 static int rk808_set_suspend_enable(struct regulator_dev *rdev)
 {
unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev 
*rdev)
  rdev->desc->enable_mask);
 }
 
+static struct regulator_ops rk805_reg_ops = {
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+   .set_suspend_voltage= rk808_set_suspend_vol

[PATCH v9 00/12] rk808: Add RK805 support

2017-08-09 Thread Joseph Chen
change in v9:
PATCH V9 1/12: (1) fix spelling issue: s/Chip/chip/
   (2) apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 2/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 3/12: None
PATCH V9 4/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 5/12: None
PATCH V9 6/12: None
PATCH V9 7/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 8/12: apply tag: Acked-by: Linus Walleij <linus.wall...@linaro.org>
PATCH V9 9/12: None (Actually, something directly updated by Dmitry Torokhov 
and applied on PATCH V7.
   Link: 
https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next
PATCH V9 10/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 11/12: apply tag: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 12/12: None

change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 2/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 3/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 4/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 5/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 6/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 7/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij <linus.wall...@linaro.org>   
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 
<linus.wall...@linaro.org>

change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown <broo...@kernel.org>
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring <r...@kernel.org>
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-

[PATCH v9 02/12] mfd: rk808: add rk805 regs addr and ID

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 include/linux/mfd/rk808.h | 120 ++
 1 file changed, 120 insertions(+)

diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 54feb14..d315659 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
 #define RK818_USB_ILMIN_2000MA 0x7
 #define RK818_USB_CHG_SD_VSEL_MASK 0x70
 
+/* RK805 */
+enum rk805_reg {
+   RK805_ID_DCDC1,
+   RK805_ID_DCDC2,
+   RK805_ID_DCDC3,
+   RK805_ID_DCDC4,
+   RK805_ID_LDO1,
+   RK805_ID_LDO2,
+   RK805_ID_LDO3,
+};
+
+/* CONFIG REGISTER */
+#define RK805_VB_MON_REG   0x21
+#define RK805_THERMAL_REG  0x22
+
+/* POWER CHANNELS ENABLE REGISTER */
+#define RK805_DCDC_EN_REG  0x23
+#define RK805_SLP_DCDC_EN_REG  0x25
+#define RK805_SLP_LDO_EN_REG   0x26
+#define RK805_LDO_EN_REG   0x27
+
+/* BUCK AND LDO CONFIG REGISTER */
+#define RK805_BUCK_LDO_SLP_LP_EN_REG   0x2A
+#define RK805_BUCK1_CONFIG_REG 0x2E
+#define RK805_BUCK1_ON_VSEL_REG0x2F
+#define RK805_BUCK1_SLP_VSEL_REG   0x30
+#define RK805_BUCK2_CONFIG_REG 0x32
+#define RK805_BUCK2_ON_VSEL_REG0x33
+#define RK805_BUCK2_SLP_VSEL_REG   0x34
+#define RK805_BUCK3_CONFIG_REG 0x36
+#define RK805_BUCK4_CONFIG_REG 0x37
+#define RK805_BUCK4_ON_VSEL_REG0x38
+#define RK805_BUCK4_SLP_VSEL_REG   0x39
+#define RK805_LDO1_ON_VSEL_REG 0x3B
+#define RK805_LDO1_SLP_VSEL_REG0x3C
+#define RK805_LDO2_ON_VSEL_REG 0x3D
+#define RK805_LDO2_SLP_VSEL_REG0x3E
+#define RK805_LDO3_ON_VSEL_REG 0x3F
+#define RK805_LDO3_SLP_VSEL_REG0x40
+
+/* INTERRUPT REGISTER */
+#define RK805_PWRON_LP_INT_TIME_REG0x47
+#define RK805_PWRON_DB_REG 0x48
+#define RK805_DEV_CTRL_REG 0x4B
+#define RK805_INT_STS_REG  0x4C
+#define RK805_INT_STS_MSK_REG  0x4D
+#define RK805_GPIO_IO_POL_REG  0x50
+#define RK805_OUT_REG  0x52
+#define RK805_ON_SOURCE_REG0xAE
+#define RK805_OFF_SOURCE_REG   0xAF
+
+#define RK805_NUM_REGULATORS   7
+
+#define RK805_PWRON_FALL_RISE_INT_EN   0x0
+#define RK805_PWRON_FALL_RISE_INT_MSK  0x81
+
+/* RK805 IRQ Definitions */
+#define RK805_IRQ_PWRON_RISE   0
+#define RK805_IRQ_VB_LOW   1
+#define RK805_IRQ_PWRON2
+#define RK805_IRQ_PWRON_LP 3
+#define RK805_IRQ_HOTDIE   4
+#define RK805_IRQ_RTC_ALARM5
+#define RK805_IRQ_RTC_PERIOD   6
+#define RK805_IRQ_PWRON_FALL   7
+
+#define RK805_IRQ_PWRON_RISE_MSK   BIT(0)
+#define RK805_IRQ_VB_LOW_MSK   BIT(1)
+#define RK805_IRQ_PWRON_MSKBIT(2)
+#define RK805_IRQ_PWRON_LP_MSK BIT(3)
+#define RK805_IRQ_HOTDIE_MSK   BIT(4)
+#define RK805_IRQ_RTC_ALARM_MSKBIT(5)
+#define RK805_IRQ_RTC_PERIOD_MSK   BIT(6)
+#define RK805_IRQ_PWRON_FALL_MSK   BIT(7)
+
+#define RK805_PWR_RISE_INT_STATUS  BIT(0)
+#define RK805_VB_LOW_INT_STATUSBIT(1)
+#define RK805_PWRON_INT_STATUS BIT(2)
+#define RK805_PWRON_LP_INT_STATUS  BIT(3)
+#define RK805_HOTDIE_INT_STATUSBIT(4)
+#define RK805_ALARM_INT_STATUS BIT(5)
+#define RK805_PERIOD_INT_STATUSBIT(6)
+#define RK805_PWR_FALL_INT_STATUS  BIT(7)
+
+#define RK805_BUCK1_2_ILMAX_MASK   (3 << 6)
+#define RK805_BUCK3_4_ILMAX_MASK(3 << 3)
+#define RK805_RTC_PERIOD_INT_MASK  (1 << 6)
+#define RK805_RTC_ALARM_INT_MASK   (1 << 5)
+#define RK805_INT_ALARM_EN (1 << 3)
+#define RK805_INT_TIMER_EN (1 << 2)
+
 /* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO  0
 #define RK808_IRQ_VB_LO1
@@ -298,7 +389,14 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define TEMP115C   0x0c
+#define TEMP_HOTDIE_MSK0x0c
+#define SLP_SD_MSK (0x3 << 2)
+#define SHUTDOWN_FUN   (0x2 << 2)
+#define SLEEP_FUN  (0x1 << 2)
 #define RK8XX_ID_MSK   0xfff0
+#define FPWM_MODE  BIT(7)
+
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
@@ -322,6 +420,28 @@ enum {
 };
 
 enum {
+   RK805_BUCK1_2_ILMAX_2500MA,
+   RK805_BUCK1_2_ILMAX_3000MA,
+   RK805_BUCK1_2_ILMAX_3500MA,
+   RK805_BUCK1_2_ILMAX_4000MA,
+};
+
+enum {
+   RK805_BUCK3_ILMAX_1500MA,
+   RK805_BUCK3_ILMAX_2000MA,
+

[PATCH v9 00/12] rk808: Add RK805 support

2017-08-09 Thread Joseph Chen
change in v9:
PATCH V9 1/12: (1) fix spelling issue: s/Chip/chip/
   (2) apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 2/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 3/12: None
PATCH V9 4/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 5/12: None
PATCH V9 6/12: None
PATCH V9 7/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 8/12: apply tag: Acked-by: Linus Walleij 
PATCH V9 9/12: None (Actually, something directly updated by Dmitry Torokhov 
and applied on PATCH V7.
   Link: 
https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/?h=next
PATCH V9 10/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 11/12: apply tag: Acked-for-MFD-by: Lee Jones 
PATCH V9 12/12: None

change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen 
PATCH V8 2/12: add: Signed-off-by: Joseph Chen 
PATCH V8 3/12: add: Signed-off-by: Joseph Chen 
PATCH V8 4/12: add: Signed-off-by: Joseph Chen 
PATCH V8 5/12: add: Signed-off-by: Joseph Chen 
PATCH V8 6/12: add: Signed-off-by: Joseph Chen 
PATCH V8 7/12: add: Signed-off-by: Joseph Chen 
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 


change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown 
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring 
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-
 drivers/input/misc/Kconfig |   6 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/rk805-pwrkey.c  | 111 +
 drivers/mfd/Kconfig|   4 +-
 drivers/mfd/rk808.c| 147 +-
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/pinctrl-rk805.c| 493 

[PATCH v9 02/12] mfd: rk808: add rk805 regs addr and ID

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 include/linux/mfd/rk808.h | 120 ++
 1 file changed, 120 insertions(+)

diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 54feb14..d315659 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
 #define RK818_USB_ILMIN_2000MA 0x7
 #define RK818_USB_CHG_SD_VSEL_MASK 0x70
 
+/* RK805 */
+enum rk805_reg {
+   RK805_ID_DCDC1,
+   RK805_ID_DCDC2,
+   RK805_ID_DCDC3,
+   RK805_ID_DCDC4,
+   RK805_ID_LDO1,
+   RK805_ID_LDO2,
+   RK805_ID_LDO3,
+};
+
+/* CONFIG REGISTER */
+#define RK805_VB_MON_REG   0x21
+#define RK805_THERMAL_REG  0x22
+
+/* POWER CHANNELS ENABLE REGISTER */
+#define RK805_DCDC_EN_REG  0x23
+#define RK805_SLP_DCDC_EN_REG  0x25
+#define RK805_SLP_LDO_EN_REG   0x26
+#define RK805_LDO_EN_REG   0x27
+
+/* BUCK AND LDO CONFIG REGISTER */
+#define RK805_BUCK_LDO_SLP_LP_EN_REG   0x2A
+#define RK805_BUCK1_CONFIG_REG 0x2E
+#define RK805_BUCK1_ON_VSEL_REG0x2F
+#define RK805_BUCK1_SLP_VSEL_REG   0x30
+#define RK805_BUCK2_CONFIG_REG 0x32
+#define RK805_BUCK2_ON_VSEL_REG0x33
+#define RK805_BUCK2_SLP_VSEL_REG   0x34
+#define RK805_BUCK3_CONFIG_REG 0x36
+#define RK805_BUCK4_CONFIG_REG 0x37
+#define RK805_BUCK4_ON_VSEL_REG0x38
+#define RK805_BUCK4_SLP_VSEL_REG   0x39
+#define RK805_LDO1_ON_VSEL_REG 0x3B
+#define RK805_LDO1_SLP_VSEL_REG0x3C
+#define RK805_LDO2_ON_VSEL_REG 0x3D
+#define RK805_LDO2_SLP_VSEL_REG0x3E
+#define RK805_LDO3_ON_VSEL_REG 0x3F
+#define RK805_LDO3_SLP_VSEL_REG0x40
+
+/* INTERRUPT REGISTER */
+#define RK805_PWRON_LP_INT_TIME_REG0x47
+#define RK805_PWRON_DB_REG 0x48
+#define RK805_DEV_CTRL_REG 0x4B
+#define RK805_INT_STS_REG  0x4C
+#define RK805_INT_STS_MSK_REG  0x4D
+#define RK805_GPIO_IO_POL_REG  0x50
+#define RK805_OUT_REG  0x52
+#define RK805_ON_SOURCE_REG0xAE
+#define RK805_OFF_SOURCE_REG   0xAF
+
+#define RK805_NUM_REGULATORS   7
+
+#define RK805_PWRON_FALL_RISE_INT_EN   0x0
+#define RK805_PWRON_FALL_RISE_INT_MSK  0x81
+
+/* RK805 IRQ Definitions */
+#define RK805_IRQ_PWRON_RISE   0
+#define RK805_IRQ_VB_LOW   1
+#define RK805_IRQ_PWRON2
+#define RK805_IRQ_PWRON_LP 3
+#define RK805_IRQ_HOTDIE   4
+#define RK805_IRQ_RTC_ALARM5
+#define RK805_IRQ_RTC_PERIOD   6
+#define RK805_IRQ_PWRON_FALL   7
+
+#define RK805_IRQ_PWRON_RISE_MSK   BIT(0)
+#define RK805_IRQ_VB_LOW_MSK   BIT(1)
+#define RK805_IRQ_PWRON_MSKBIT(2)
+#define RK805_IRQ_PWRON_LP_MSK BIT(3)
+#define RK805_IRQ_HOTDIE_MSK   BIT(4)
+#define RK805_IRQ_RTC_ALARM_MSKBIT(5)
+#define RK805_IRQ_RTC_PERIOD_MSK   BIT(6)
+#define RK805_IRQ_PWRON_FALL_MSK   BIT(7)
+
+#define RK805_PWR_RISE_INT_STATUS  BIT(0)
+#define RK805_VB_LOW_INT_STATUSBIT(1)
+#define RK805_PWRON_INT_STATUS BIT(2)
+#define RK805_PWRON_LP_INT_STATUS  BIT(3)
+#define RK805_HOTDIE_INT_STATUSBIT(4)
+#define RK805_ALARM_INT_STATUS BIT(5)
+#define RK805_PERIOD_INT_STATUSBIT(6)
+#define RK805_PWR_FALL_INT_STATUS  BIT(7)
+
+#define RK805_BUCK1_2_ILMAX_MASK   (3 << 6)
+#define RK805_BUCK3_4_ILMAX_MASK(3 << 3)
+#define RK805_RTC_PERIOD_INT_MASK  (1 << 6)
+#define RK805_RTC_ALARM_INT_MASK   (1 << 5)
+#define RK805_INT_ALARM_EN (1 << 3)
+#define RK805_INT_TIMER_EN (1 << 2)
+
 /* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO  0
 #define RK808_IRQ_VB_LO1
@@ -298,7 +389,14 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define TEMP115C   0x0c
+#define TEMP_HOTDIE_MSK0x0c
+#define SLP_SD_MSK (0x3 << 2)
+#define SHUTDOWN_FUN   (0x2 << 2)
+#define SLEEP_FUN  (0x1 << 2)
 #define RK8XX_ID_MSK   0xfff0
+#define FPWM_MODE  BIT(7)
+
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
@@ -322,6 +420,28 @@ enum {
 };
 
 enum {
+   RK805_BUCK1_2_ILMAX_2500MA,
+   RK805_BUCK1_2_ILMAX_3000MA,
+   RK805_BUCK1_2_ILMAX_3500MA,
+   RK805_BUCK1_2_ILMAX_4000MA,
+};
+
+enum {
+   RK805_BUCK3_ILMAX_1500MA,
+   RK805_BUCK3_ILMAX_2000MA,
+   RK805_BUCK3_ILMAX_2500MA,
+   RK805_BUCK3_ILMAX_3000MA,
+};
+
+enum {
+   RK805_BUCK4_ILMAX_2000MA,
+   RK80

[PATCH v9 01/12] mfd: rk808: fix up the chip id get failed

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..8e60eba 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* Read chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v9 01/12] mfd: rk808: fix up the chip id get failed

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..8e60eba 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* Read chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v9 04/12] mfd: rk808: Add RK805 support

2017-08-09 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK805 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clocking

Both RK808 and RK805 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/rk808.c | 108 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb..b410a34 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -892,13 +892,13 @@ config MFD_RC5T583
  different functionality of the device.
 
 config MFD_RK808
-   tristate "Rockchip RK808/RK818 Power Management Chip"
+   tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
depends on I2C && OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
help
- If you say yes here you get support for the RK808 and RK818
+ If you say yes here you get support for the RK805, RK808 and RK818
  Power Management chips.
  This driver provides common support for accessing the device
  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 8e60eba..18329c8 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.volatile_reg = rk808_is_volatile_reg,
 };
 
+static const struct regmap_config rk805_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = RK805_OFF_SOURCE_REG,
+   .cache_type = REGCACHE_RBTREE,
+   .volatile_reg = rk808_is_volatile_reg,
+};
+
 static const struct regmap_config rk808_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -86,6 +94,16 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static const struct mfd_cell rk805s[] = {
+   { .name = "rk808-clkout", },
+   { .name = "rk808-regulator", },
+   {
+   .name = "rk808-rtc",
+   .num_resources = ARRAY_SIZE(rtc_resources),
+   .resources = _resources[0],
+   },
+};
+
 static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -106,6 +124,20 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
},
 };
 
+static const struct rk808_reg_data rk805_pre_init_reg[] = {
+   {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK3_ILMAX_3000MA},
+   {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK4_ILMAX_3500MA},
+   {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
+   {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
+   {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
+};
+
 static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
@@ -135,6 +167,41 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
VB_LO_SEL_3500MV },
 };
 
+static const struct regmap_irq rk805_irqs[] = {
+   [RK805_IRQ_PWRON_RISE] = {
+   .mask = RK805_IRQ_PWRON_RISE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_VB_LOW] = {
+   .mask = RK805_IRQ_VB_LOW_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON] = {
+   .mask = RK805_IRQ_PWRON_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_LP] = {
+   .mask = RK805_IRQ_PWRON_LP_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_HOTDIE] = {
+   .mask = RK805_IRQ_HOTDIE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_ALARM] = {
+   .mask = RK805_IRQ_RTC_ALARM_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_PERIOD] = {
+   .mask = RK805_IRQ_RTC_PERIOD_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_FALL] = {
+   .mask = RK805_IRQ_PWRON_FALL_MSK,
+   .reg_offset = 0,
+   },
+

[PATCH v9 04/12] mfd: rk808: Add RK805 support

2017-08-09 Thread Joseph Chen
From: Elaine Zhang 

The RK805 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clocking

Both RK808 and RK805 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/rk808.c | 108 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb..b410a34 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -892,13 +892,13 @@ config MFD_RC5T583
  different functionality of the device.
 
 config MFD_RK808
-   tristate "Rockchip RK808/RK818 Power Management Chip"
+   tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
depends on I2C && OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
help
- If you say yes here you get support for the RK808 and RK818
+ If you say yes here you get support for the RK805, RK808 and RK818
  Power Management chips.
  This driver provides common support for accessing the device
  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 8e60eba..18329c8 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.volatile_reg = rk808_is_volatile_reg,
 };
 
+static const struct regmap_config rk805_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = RK805_OFF_SOURCE_REG,
+   .cache_type = REGCACHE_RBTREE,
+   .volatile_reg = rk808_is_volatile_reg,
+};
+
 static const struct regmap_config rk808_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -86,6 +94,16 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static const struct mfd_cell rk805s[] = {
+   { .name = "rk808-clkout", },
+   { .name = "rk808-regulator", },
+   {
+   .name = "rk808-rtc",
+   .num_resources = ARRAY_SIZE(rtc_resources),
+   .resources = _resources[0],
+   },
+};
+
 static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -106,6 +124,20 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
},
 };
 
+static const struct rk808_reg_data rk805_pre_init_reg[] = {
+   {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK3_ILMAX_3000MA},
+   {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK4_ILMAX_3500MA},
+   {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
+   {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
+   {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
+};
+
 static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
@@ -135,6 +167,41 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
VB_LO_SEL_3500MV },
 };
 
+static const struct regmap_irq rk805_irqs[] = {
+   [RK805_IRQ_PWRON_RISE] = {
+   .mask = RK805_IRQ_PWRON_RISE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_VB_LOW] = {
+   .mask = RK805_IRQ_VB_LOW_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON] = {
+   .mask = RK805_IRQ_PWRON_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_LP] = {
+   .mask = RK805_IRQ_PWRON_LP_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_HOTDIE] = {
+   .mask = RK805_IRQ_HOTDIE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_ALARM] = {
+   .mask = RK805_IRQ_RTC_ALARM_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_PERIOD] = {
+   .mask = RK805_IRQ_RTC_PERIOD_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_FALL] = {
+   .mask = RK805_IRQ_PWRON_FALL_MSK,
+   .reg_offset = 0,
+   },
+};
+
 static const struct regmap_irq rk808_irqs[] = {
/* INT_STS */
[RK808_IRQ_VOUT_LO] = {
@@ -247,6 +314

Re: [PATCH v9 00/12] rk808: Add RK805 support

2017-08-09 Thread Joseph Chen



在 2017/8/9 17:35, Heiko Stuebner 写道:

Hi Joseph,

Am Mittwoch, 9. August 2017, 10:10:41 CEST schrieb Joseph Chen:

change in v9:
PATCH V9 1/12:  (1) fix spelling issue: s/Chip/chip/
(2) add: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 2/12 ~ 12/12: they are applied and no changes, so I don't resend them.

I don't know Lee's workflow, but I'm not sure that is actually true.

I.e. he added "for his own reference" Acked-for-MFD-by: tags to the
patches, but did not apply them (and therefore you cannot find them on [0])

So I'd think you might need to send everything again?


Heiko

[0] 
https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/log/?h=for-mfd-next



Ok, I think it's my misunderstanding, I will send everything later.:-)

--
Best Regards
--------
陈健洪 (Joseph Chen)
E-mail:che...@rock-chips.com
福州瑞芯微电子股份有限公司
Fuzhou Rockchip Electronics Co.Ltd
福建省福州市铜盘路软件大道89号软件园A区21号楼 (350003)
No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
TEL:0591-83991906/07-8573




Re: [PATCH v9 00/12] rk808: Add RK805 support

2017-08-09 Thread Joseph Chen



在 2017/8/9 17:35, Heiko Stuebner 写道:

Hi Joseph,

Am Mittwoch, 9. August 2017, 10:10:41 CEST schrieb Joseph Chen:

change in v9:
PATCH V9 1/12:  (1) fix spelling issue: s/Chip/chip/
(2) add: Acked-for-MFD-by: Lee Jones 
PATCH V9 2/12 ~ 12/12: they are applied and no changes, so I don't resend them.

I don't know Lee's workflow, but I'm not sure that is actually true.

I.e. he added "for his own reference" Acked-for-MFD-by: tags to the
patches, but did not apply them (and therefore you cannot find them on [0])

So I'd think you might need to send everything again?


Heiko

[0] 
https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/log/?h=for-mfd-next



Ok, I think it's my misunderstanding, I will send everything later.:-)

--
Best Regards

陈健洪 (Joseph Chen)
E-mail:che...@rock-chips.com
福州瑞芯微电子股份有限公司
Fuzhou Rockchip Electronics Co.Ltd
福建省福州市铜盘路软件大道89号软件园A区21号楼 (350003)
No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
TEL:0591-83991906/07-8573




[PATCH v9 00/12] rk808: Add RK805 support

2017-08-08 Thread Joseph Chen
change in v9:
PATCH V9 1/12:  (1) fix spelling issue: s/Chip/chip/
(2) add: Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
PATCH V9 2/12 ~ 12/12: they are applied and no changes, so I don't resend them.

change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 2/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 3/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 4/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 5/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 6/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 7/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij <linus.wall...@linaro.org>   
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 
<linus.wall...@linaro.org>

change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown <broo...@kernel.org>
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring <r...@kernel.org>
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-
 drivers/input/misc/Kconfig |   6 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/rk805-pwrkey.c  | 111 +
 drivers/mfd/Kconfig|   4 +-
 drivers/mfd/rk808.c| 147 +-
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/pinctrl-rk805.c| 493 +
 drivers/regulator/Kconfig  |   4 +-
 drivers/regulator/rk808-regulator.c| 130 ++
 drivers/rtc/Kconfig|   4 +-
 incl

[PATCH v9 01/12] mfd: rk808: fix up the chip id get failed

2017-08-08 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-for-MFD-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..8e60eba 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* Read chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v9 00/12] rk808: Add RK805 support

2017-08-08 Thread Joseph Chen
change in v9:
PATCH V9 1/12:  (1) fix spelling issue: s/Chip/chip/
(2) add: Acked-for-MFD-by: Lee Jones 
PATCH V9 2/12 ~ 12/12: they are applied and no changes, so I don't resend them.

change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen 
PATCH V8 2/12: add: Signed-off-by: Joseph Chen 
PATCH V8 3/12: add: Signed-off-by: Joseph Chen 
PATCH V8 4/12: add: Signed-off-by: Joseph Chen 
PATCH V8 5/12: add: Signed-off-by: Joseph Chen 
PATCH V8 6/12: add: Signed-off-by: Joseph Chen 
PATCH V8 7/12: add: Signed-off-by: Joseph Chen 
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 


change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown 
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring 
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-
 drivers/input/misc/Kconfig |   6 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/rk805-pwrkey.c  | 111 +
 drivers/mfd/Kconfig|   4 +-
 drivers/mfd/rk808.c| 147 +-
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/pinctrl-rk805.c| 493 +
 drivers/regulator/Kconfig  |   4 +-
 drivers/regulator/rk808-regulator.c| 130 ++
 drivers/rtc/Kconfig|   4 +-
 include/linux/mfd/rk808.h  | 121 +
 15 files changed, 1105 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
 create mode 100644 drivers/input/misc/rk805-pwrkey.c
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

-- 
1.9.1




[PATCH v9 01/12] mfd: rk808: fix up the chip id get failed

2017-08-08 Thread Joseph Chen
From: Elaine Zhang 

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-for-MFD-by: Lee Jones 
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..8e60eba 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* Read chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v2] Add rk805 node for rk3328-evb.dts

2017-08-08 Thread Joseph Chen
change in v2:
add some sort of commit message. 

Joseph Chen (1):
  arm64: dts: rockchip: add rk805 node for rk3328-evb

 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 137 
 1 file changed, 137 insertions(+)

-- 
1.9.1




[PATCH v2] Add rk805 node for rk3328-evb.dts

2017-08-08 Thread Joseph Chen
change in v2:
add some sort of commit message. 

Joseph Chen (1):
  arm64: dts: rockchip: add rk805 node for rk3328-evb

 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 137 
 1 file changed, 137 insertions(+)

-- 
1.9.1




[PATCH v2] arm64: dts: rockchip: add rk805 node for rk3328-evb

2017-08-08 Thread Joseph Chen
RK805 consists of 4 DCDCs, 3 LDOs. It's different from RK808
and RK818 that there are 2 output only GPIOs, we should add
properties "gpio-controller" and "gpio-cells = <2>".

Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 137 
 1 file changed, 137 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
index cf27239..e8705fd 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
@@ -50,8 +50,145 @@
chosen {
stdout-path = "serial2:150n8";
};
+
+   dc_12v: dc-12v {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc_sys: vcc-sys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
 };
 
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+
+   rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   reg = <0x18>;
+   interrupt-parent = <>;
+   interrupts = <6 IRQ_TYPE_LEVEL_LOW>;
+   #clock-cells = <1>;
+   clock-output-names = "xin32k", "rk805-clkout2";
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>;
+   rockchip,system-power-controller;
+   wakeup-source;
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   vcc1-supply = <_sys>;
+   vcc2-supply = <_sys>;
+   vcc3-supply = <_sys>;
+   vcc4-supply = <_sys>;
+   vcc5-supply = <_io>;
+   vcc6-supply = <_io>;
+
+   regulators {
+   vdd_logic: DCDC_REG1 {
+   regulator-name = "vdd_logic";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <100>;
+   };
+   };
+
+   vdd_arm: DCDC_REG2 {
+   regulator-name = "vdd_arm";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <95>;
+   };
+   };
+
+   vcc_ddr: DCDC_REG3 {
+   regulator-name = "vcc_ddr";
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   vcc_io: DCDC_REG4 {
+   regulator-name = "vcc_io";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <330>;
+   };
+   };
+
+   vcc_18: LDO_REG1 {
+   regulator-name = "vcc_18";
+   regulator-min-microvolt = <180>;
+   

[PATCH v2] arm64: dts: rockchip: add rk805 node for rk3328-evb

2017-08-08 Thread Joseph Chen
RK805 consists of 4 DCDCs, 3 LDOs. It's different from RK808
and RK818 that there are 2 output only GPIOs, we should add
properties "gpio-controller" and "gpio-cells = <2>".

Signed-off-by: Joseph Chen 
---
 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 137 
 1 file changed, 137 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
index cf27239..e8705fd 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
@@ -50,8 +50,145 @@
chosen {
stdout-path = "serial2:150n8";
};
+
+   dc_12v: dc-12v {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc_sys: vcc-sys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
 };
 
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+
+   rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   reg = <0x18>;
+   interrupt-parent = <>;
+   interrupts = <6 IRQ_TYPE_LEVEL_LOW>;
+   #clock-cells = <1>;
+   clock-output-names = "xin32k", "rk805-clkout2";
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>;
+   rockchip,system-power-controller;
+   wakeup-source;
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   vcc1-supply = <_sys>;
+   vcc2-supply = <_sys>;
+   vcc3-supply = <_sys>;
+   vcc4-supply = <_sys>;
+   vcc5-supply = <_io>;
+   vcc6-supply = <_io>;
+
+   regulators {
+   vdd_logic: DCDC_REG1 {
+   regulator-name = "vdd_logic";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <100>;
+   };
+   };
+
+   vdd_arm: DCDC_REG2 {
+   regulator-name = "vdd_arm";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <95>;
+   };
+   };
+
+   vcc_ddr: DCDC_REG3 {
+   regulator-name = "vcc_ddr";
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   vcc_io: DCDC_REG4 {
+   regulator-name = "vcc_io";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <330>;
+   };
+   };
+
+   vcc_18: LDO_REG1 {
+   regulator-name = "vcc_18";
+   regulator-min-microvolt = <180>;
+ 

[PATCH v1] arm64: dts: rockchip: add rk805 node for rk3328-evb

2017-08-08 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 137 
 1 file changed, 137 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
index cf27239..e8705fd 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
@@ -50,8 +50,145 @@
chosen {
stdout-path = "serial2:150n8";
};
+
+   dc_12v: dc-12v {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc_sys: vcc-sys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
 };
 
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+
+   rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   reg = <0x18>;
+   interrupt-parent = <>;
+   interrupts = <6 IRQ_TYPE_LEVEL_LOW>;
+   #clock-cells = <1>;
+   clock-output-names = "xin32k", "rk805-clkout2";
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>;
+   rockchip,system-power-controller;
+   wakeup-source;
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   vcc1-supply = <_sys>;
+   vcc2-supply = <_sys>;
+   vcc3-supply = <_sys>;
+   vcc4-supply = <_sys>;
+   vcc5-supply = <_io>;
+   vcc6-supply = <_io>;
+
+   regulators {
+   vdd_logic: DCDC_REG1 {
+   regulator-name = "vdd_logic";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <100>;
+   };
+   };
+
+   vdd_arm: DCDC_REG2 {
+   regulator-name = "vdd_arm";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <95>;
+   };
+   };
+
+   vcc_ddr: DCDC_REG3 {
+   regulator-name = "vcc_ddr";
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   vcc_io: DCDC_REG4 {
+   regulator-name = "vcc_io";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <330>;
+   };
+   };
+
+   vcc_18: LDO_REG1 {
+   regulator-name = "vcc_18";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-boot-on;
+   regulator-always-on;
+   regul

[PATCH v1] arm64: dts: rockchip: add rk805 node for rk3328-evb

2017-08-08 Thread Joseph Chen
Signed-off-by: Joseph Chen 
---
 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 137 
 1 file changed, 137 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
index cf27239..e8705fd 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
@@ -50,8 +50,145 @@
chosen {
stdout-path = "serial2:150n8";
};
+
+   dc_12v: dc-12v {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc_sys: vcc-sys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_12v>;
+   };
 };
 
  {
status = "okay";
 };
+
+ {
+   status = "okay";
+
+   rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   reg = <0x18>;
+   interrupt-parent = <>;
+   interrupts = <6 IRQ_TYPE_LEVEL_LOW>;
+   #clock-cells = <1>;
+   clock-output-names = "xin32k", "rk805-clkout2";
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>;
+   rockchip,system-power-controller;
+   wakeup-source;
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   vcc1-supply = <_sys>;
+   vcc2-supply = <_sys>;
+   vcc3-supply = <_sys>;
+   vcc4-supply = <_sys>;
+   vcc5-supply = <_io>;
+   vcc6-supply = <_io>;
+
+   regulators {
+   vdd_logic: DCDC_REG1 {
+   regulator-name = "vdd_logic";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <100>;
+   };
+   };
+
+   vdd_arm: DCDC_REG2 {
+   regulator-name = "vdd_arm";
+   regulator-min-microvolt = <712500>;
+   regulator-max-microvolt = <145>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <95>;
+   };
+   };
+
+   vcc_ddr: DCDC_REG3 {
+   regulator-name = "vcc_ddr";
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   };
+   };
+
+   vcc_io: DCDC_REG4 {
+   regulator-name = "vcc_io";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulator-on-in-suspend;
+   regulator-suspend-microvolt = <330>;
+   };
+   };
+
+   vcc_18: LDO_REG1 {
+   regulator-name = "vcc_18";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-state-mem {
+   regulat

[PATCH v8 09/12] Input: Add power key driver for Rockchip RK805 PMIC

2017-08-03 Thread Joseph Chen
This driver provides a input driver for the power
key on the Rockchip RK805 PMIC.

Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/input/misc/Kconfig|   6 +++
 drivers/input/misc/Makefile   |   1 +
 drivers/input/misc/rk805-pwrkey.c | 111 ++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/input/misc/rk805-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c522..72dc4f5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -571,6 +571,12 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_RK805_PWRKEY
+   tristate "Rockchip RK805 PMIC power key support"
+   depends on MFD_RK808
+   help
+ Select this option to enable power key driver for RK805.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate "Rotary encoders connected to GPIO pins"
depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f..c27052a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)  += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
+obj-$(CONFIG_INPUT_RK805_PWRKEY)   += rk805-pwrkey.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
 obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)   += soc_button_array.o
diff --git a/drivers/input/misc/rk805-pwrkey.c 
b/drivers/input/misc/rk805-pwrkey.c
new file mode 100644
index 000..e0fc66e
--- /dev/null
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -0,0 +1,111 @@
+/*
+ * Rockchip RK805 PMIC Power Key driver
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen <che...@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 1);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 0);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static int rk805_pwrkey_probe(struct platform_device *pdev)
+{
+   struct input_dev *pwr;
+   int fall_irq, rise_irq;
+   int err;
+
+   pwr = devm_input_allocate_device(>dev);
+   if (!pwr) {
+   dev_err(>dev, "Can't allocate power button\n");
+   return -ENOMEM;
+   }
+
+   pwr->name = "rk805 pwrkey";
+   pwr->phys = "rk805_pwrkey/input0";
+   pwr->dev.parent = >dev;
+   input_set_capability(pwr, EV_KEY, KEY_POWER);
+
+   fall_irq = platform_get_irq(pdev, 0);
+   if (fall_irq < 0) {
+   dev_err(>dev, "Can't get fall irq: %d\n", fall_irq);
+   return fall_irq;
+   }
+
+   rise_irq = platform_get_irq(pdev, 1);
+   if (rise_irq < 0) {
+   dev_err(>dev, "Can't get rise irq: %d\n", rise_irq);
+   return rise_irq;
+   }
+
+   err = devm_request_any_context_irq(>dev, fall_irq,
+  pwrkey_fall_irq,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "rk805_pwrkey_fall", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register fall irq: %d\n", err);
+   return err;
+   }
+
+   err = devm_request_any_context_irq(>dev, rise_irq,
+  pwrkey_rise_irq,
+  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+  "rk805_pwrkey_rise", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register rise irq: %d\n", err);
+   return err;
+   }
+
+   err = input_register_device(pwr);
+   if (err) {
+   dev_err(>dev, "Can't register power button: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, pwr);
+   device_init_wakeup(>dev, true);
+
+   return 0;
+}
+
+static struct platform_d

[PATCH v8 09/12] Input: Add power key driver for Rockchip RK805 PMIC

2017-08-03 Thread Joseph Chen
This driver provides a input driver for the power
key on the Rockchip RK805 PMIC.

Signed-off-by: Joseph Chen 
---
 drivers/input/misc/Kconfig|   6 +++
 drivers/input/misc/Makefile   |   1 +
 drivers/input/misc/rk805-pwrkey.c | 111 ++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/input/misc/rk805-pwrkey.c

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5b6c522..72dc4f5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -571,6 +571,12 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
+config INPUT_RK805_PWRKEY
+   tristate "Rockchip RK805 PMIC power key support"
+   depends on MFD_RK808
+   help
+ Select this option to enable power key driver for RK805.
+
 config INPUT_GPIO_ROTARY_ENCODER
tristate "Rotary encoders connected to GPIO pins"
depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b10523f..c27052a 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)  += regulator-haptic.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
 obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
+obj-$(CONFIG_INPUT_RK805_PWRKEY)   += rk805-pwrkey.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)  += sirfsoc-onkey.o
 obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY)   += soc_button_array.o
diff --git a/drivers/input/misc/rk805-pwrkey.c 
b/drivers/input/misc/rk805-pwrkey.c
new file mode 100644
index 000..e0fc66e
--- /dev/null
+++ b/drivers/input/misc/rk805-pwrkey.c
@@ -0,0 +1,111 @@
+/*
+ * Rockchip RK805 PMIC Power Key driver
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 1);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t pwrkey_rise_irq(int irq, void *_pwr)
+{
+   struct input_dev *pwr = _pwr;
+
+   input_report_key(pwr, KEY_POWER, 0);
+   input_sync(pwr);
+
+   return IRQ_HANDLED;
+}
+
+static int rk805_pwrkey_probe(struct platform_device *pdev)
+{
+   struct input_dev *pwr;
+   int fall_irq, rise_irq;
+   int err;
+
+   pwr = devm_input_allocate_device(>dev);
+   if (!pwr) {
+   dev_err(>dev, "Can't allocate power button\n");
+   return -ENOMEM;
+   }
+
+   pwr->name = "rk805 pwrkey";
+   pwr->phys = "rk805_pwrkey/input0";
+   pwr->dev.parent = >dev;
+   input_set_capability(pwr, EV_KEY, KEY_POWER);
+
+   fall_irq = platform_get_irq(pdev, 0);
+   if (fall_irq < 0) {
+   dev_err(>dev, "Can't get fall irq: %d\n", fall_irq);
+   return fall_irq;
+   }
+
+   rise_irq = platform_get_irq(pdev, 1);
+   if (rise_irq < 0) {
+   dev_err(>dev, "Can't get rise irq: %d\n", rise_irq);
+   return rise_irq;
+   }
+
+   err = devm_request_any_context_irq(>dev, fall_irq,
+  pwrkey_fall_irq,
+  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+  "rk805_pwrkey_fall", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register fall irq: %d\n", err);
+   return err;
+   }
+
+   err = devm_request_any_context_irq(>dev, rise_irq,
+  pwrkey_rise_irq,
+  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+  "rk805_pwrkey_rise", pwr);
+   if (err < 0) {
+   dev_err(>dev, "Can't register rise irq: %d\n", err);
+   return err;
+   }
+
+   err = input_register_device(pwr);
+   if (err) {
+   dev_err(>dev, "Can't register power button: %d\n", err);
+   return err;
+   }
+
+   platform_set_drvdata(pdev, pwr);
+   device_init_wakeup(>dev, true);
+
+   return 0;
+}
+
+static struct platform_driver rk805_pwrkey_driver = {
+   .probe

[PATCH v8 11/12] mfd: rk808: Add RK805 power key support

2017-08-03 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index db90471..6d9f96b 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[PATCH v8 11/12] mfd: rk808: Add RK805 power key support

2017-08-03 Thread Joseph Chen
Signed-off-by: Joseph Chen 
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index db90471..6d9f96b 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




[PATCH v8 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-03 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




[PATCH v8 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-08-03 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..eee3dc2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high;
+   };
+   };
+};
-- 
1.9.1




[PATCH v8 06/12] rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the rtc driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/rtc/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5dc673d..47d6a8d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -352,11 +352,11 @@ config RTC_DRV_MAX77686
  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-   tristate "Rockchip RK808/RK818 RTC"
+   tristate "Rockchip RK805/RK808/RK818 RTC"
depends on MFD_RK808
help
  If you say yes here you will get support for the
- RTC of RK808 and RK818 PMIC.
+ RTC of RK805, RK808 and RK818 PMIC.
 
  This driver can also be built as a module. If so, the module
  will be called rk808-rtc.
-- 
1.9.1




[PATCH v8 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[PATCH v8 06/12] rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the rtc driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/rtc/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5dc673d..47d6a8d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -352,11 +352,11 @@ config RTC_DRV_MAX77686
  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-   tristate "Rockchip RK808/RK818 RTC"
+   tristate "Rockchip RK805/RK808/RK818 RTC"
depends on MFD_RK808
help
  If you say yes here you will get support for the
- RTC of RK808 and RK818 PMIC.
+ RTC of RK805, RK808 and RK818 PMIC.
 
  This driver can also be built as a module. If so, the module
  will be called rk808-rtc.
-- 
1.9.1




[PATCH v8 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[PATCH v8 10/12] mfd: rk808: Add RK805 pinctrl support

2017-08-03 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Linus Walleij <linus.wall...@linaro.org>
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 7276555..db90471 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[PATCH v8 07/12] mfd: dt-bindings: Add RK805 device tree bindings document

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Add device tree bindings documentation for Rockchip's RK805 PMIC.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Rob Herring <r...@kernel.org>
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt 
b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8..91b6522 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
 RK8XX Power Management Integrated Circuit
 
 The rk8xx family current members:
+rk805
 rk808
 rk818
 
 Required properties:
-- compatible: "rockchip,rk808", "rockchip,rk818"
+- compatible: "rockchip,rk805"
+- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
 - rockchip,system-power-controller: Telling whether or not this pmic is 
controlling
   the system power.
 
+Optional RK805 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc6-supply:  The input supply for LDO_REG3
+
 Optional RK808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
/* standard regulator bindings here */
};
 
+Following regulators of the RK805 PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK805 datasheet.
+
+   - DCDC_REGn
+   - valid values for n are 1 to 4.
+   - LDO_REGn
+   - valid values for n are 1 to 3
+
 Following regulators of the RK808 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK808 datasheet.
-- 
1.9.1




[PATCH v8 10/12] mfd: rk808: Add RK805 pinctrl support

2017-08-03 Thread Joseph Chen
Signed-off-by: Joseph Chen 
Acked-by: Linus Walleij 
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 7276555..db90471 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[PATCH v8 07/12] mfd: dt-bindings: Add RK805 device tree bindings document

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

Add device tree bindings documentation for Rockchip's RK805 PMIC.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/mfd/rk808.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/rk808.txt 
b/Documentation/devicetree/bindings/mfd/rk808.txt
index 9636ae8..91b6522 100644
--- a/Documentation/devicetree/bindings/mfd/rk808.txt
+++ b/Documentation/devicetree/bindings/mfd/rk808.txt
@@ -1,11 +1,14 @@
 RK8XX Power Management Integrated Circuit
 
 The rk8xx family current members:
+rk805
 rk808
 rk818
 
 Required properties:
-- compatible: "rockchip,rk808", "rockchip,rk818"
+- compatible: "rockchip,rk805"
+- compatible: "rockchip,rk808"
+- compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupt-parent: The parent interrupt controller.
 - interrupts: the interrupt outputs of the controller.
@@ -18,6 +21,14 @@ Optional properties:
 - rockchip,system-power-controller: Telling whether or not this pmic is 
controlling
   the system power.
 
+Optional RK805 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1 and LDO_REG2
+- vcc6-supply:  The input supply for LDO_REG3
+
 Optional RK808 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -56,6 +67,15 @@ by a child node of the 'regulators' node.
/* standard regulator bindings here */
};
 
+Following regulators of the RK805 PMIC regulators are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK805 datasheet.
+
+   - DCDC_REGn
+   - valid values for n are 1 to 4.
+   - LDO_REGn
+   - valid values for n are 1 to 3
+
 Following regulators of the RK808 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK808 datasheet.
-- 
1.9.1




[PATCH v8 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

2017-08-03 Thread Joseph Chen
RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.

This driver is also designed for other Rockchip PMICs to expend.
Different PMIC maybe have different pin features, for example,
RK816 has one pin which can be used for TS or GPIO(input/out).
The mainly difference between PMICs pins are pinmux, direction
and output value, that is 'struct rk805_pin_config'.

Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/Makefile|   1 +
 drivers/pinctrl/pinctrl-rk805.c | 493 
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 8f8c2af..c33098f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -285,6 +285,15 @@ config PINCTRL_ZYNQ
help
  This selects the pinctrl driver for Xilinx Zynq.
 
+config PINCTRL_RK805
+   tristate "Pinctrl and GPIO driver for RK805 PMIC"
+   depends on MFD_RK808
+   select GPIOLIB
+   select PINMUX
+   select GENERIC_PINCONF
+   help
+ This selects the pinctrl driver for RK805.
+
 source "drivers/pinctrl/aspeed/Kconfig"
 source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a251f43..7485af3 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PINCTRL_LPC18XX) += pinctrl-lpc18xx.o
 obj-$(CONFIG_PINCTRL_TB10X)+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST)   += pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
+obj-$(CONFIG_PINCTRL_RK805)+= pinctrl-rk805.o
 
 obj-$(CONFIG_ARCH_ASPEED)  += aspeed/
 obj-y  += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000..b0bfd30
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
+/*
+ * Pinctrl driver for Rockchip RK805 PMIC
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen <che...@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Based on the pinctrl-as3722 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "pinconf.h"
+#include "pinctrl-utils.h"
+
+struct rk805_pin_function {
+   const char *name;
+   const char *const *groups;
+   unsigned int ngroups;
+   int mux_option;
+};
+
+struct rk805_pin_group {
+   const char *name;
+   const unsigned int pins[1];
+   unsigned int npins;
+};
+
+/*
+ * @reg: gpio setting register;
+ * @fun_mask: functions select mask value, when set is gpio;
+ * @dir_mask: input or output mask value, when set is output, otherwise input;
+ * @val_mask: gpio set value, when set is level high, otherwise low;
+ *
+ * Different PMIC has different pin features, belowing 3 mask members are not
+ * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
+ * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
+ * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
+ * necessary.
+ */
+struct rk805_pin_config {
+   u8 reg;
+   u8 fun_msk;
+   u8 dir_msk;
+   u8 val_msk;
+};
+
+struct rk805_pctrl_info {
+   struct rk808 *rk808;
+   struct device *dev;
+   struct pinctrl_dev *pctl;
+   struct gpio_chip gpio_chip;
+   struct pinctrl_desc pinctrl_desc;
+   const struct rk805_pin_function *functions;
+   unsigned int num_functions;
+   const struct rk805_pin_group *groups;
+   int num_pin_groups;
+   const struct pinctrl_pin_desc *pins;
+   unsigned int num_pins;
+   struct rk805_pin_config *pin_cfg;
+};
+
+enum rk805_pinmux_option {
+   RK805_PINMUX_GPIO,
+};
+
+enum {
+   RK805_GPIO0,
+   RK805_GPIO1,
+};
+
+static const char *const rk805_gpio_groups[] = {
+   "gpio0",
+   "gpio1",
+};
+
+/* RK805: 2 output only GPIOs */
+static const struct pinctrl_pin_desc rk805_pins_desc[] = {
+   PINCTRL_PIN(RK805_GPIO0, "gpio0"),
+   PINCTRL_PIN(RK805_GPIO1, "gpio1"),
+};
+
+static const struct rk805_pin_function rk805_pin_functions[] = {
+   {
+   .name = "gpio",
+   .groups = rk805_gpio_groups,
+   .ngroups = ARRAY_SIZE(rk805_gpio_groups),
+   .mux_option = RK805_PINMUX_GPIO,
+   }

[PATCH v8 08/12] pinctrl: Add pinctrl driver for the RK805 PMIC

2017-08-03 Thread Joseph Chen
RK805 is one of Rockchip PMICs family, it has 2 output only GPIOs.

This driver is also designed for other Rockchip PMICs to expend.
Different PMIC maybe have different pin features, for example,
RK816 has one pin which can be used for TS or GPIO(input/out).
The mainly difference between PMICs pins are pinmux, direction
and output value, that is 'struct rk805_pin_config'.

Signed-off-by: Joseph Chen 
---
 drivers/pinctrl/Kconfig |   9 +
 drivers/pinctrl/Makefile|   1 +
 drivers/pinctrl/pinctrl-rk805.c | 493 
 3 files changed, 503 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 8f8c2af..c33098f 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -285,6 +285,15 @@ config PINCTRL_ZYNQ
help
  This selects the pinctrl driver for Xilinx Zynq.
 
+config PINCTRL_RK805
+   tristate "Pinctrl and GPIO driver for RK805 PMIC"
+   depends on MFD_RK808
+   select GPIOLIB
+   select PINMUX
+   select GENERIC_PINCONF
+   help
+ This selects the pinctrl driver for RK805.
+
 source "drivers/pinctrl/aspeed/Kconfig"
 source "drivers/pinctrl/bcm/Kconfig"
 source "drivers/pinctrl/berlin/Kconfig"
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index a251f43..7485af3 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PINCTRL_LPC18XX) += pinctrl-lpc18xx.o
 obj-$(CONFIG_PINCTRL_TB10X)+= pinctrl-tb10x.o
 obj-$(CONFIG_PINCTRL_ST)   += pinctrl-st.o
 obj-$(CONFIG_PINCTRL_ZYNQ) += pinctrl-zynq.o
+obj-$(CONFIG_PINCTRL_RK805)+= pinctrl-rk805.o
 
 obj-$(CONFIG_ARCH_ASPEED)  += aspeed/
 obj-y  += bcm/
diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
new file mode 100644
index 000..b0bfd30
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -0,0 +1,493 @@
+/*
+ * Pinctrl driver for Rockchip RK805 PMIC
+ *
+ * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * Author: Joseph Chen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under  the terms of the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Based on the pinctrl-as3722 driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "pinconf.h"
+#include "pinctrl-utils.h"
+
+struct rk805_pin_function {
+   const char *name;
+   const char *const *groups;
+   unsigned int ngroups;
+   int mux_option;
+};
+
+struct rk805_pin_group {
+   const char *name;
+   const unsigned int pins[1];
+   unsigned int npins;
+};
+
+/*
+ * @reg: gpio setting register;
+ * @fun_mask: functions select mask value, when set is gpio;
+ * @dir_mask: input or output mask value, when set is output, otherwise input;
+ * @val_mask: gpio set value, when set is level high, otherwise low;
+ *
+ * Different PMIC has different pin features, belowing 3 mask members are not
+ * all necessary for every PMIC. For example, RK805 has 2 pins that can be used
+ * as output only GPIOs, so func_mask and dir_mask are not needed. RK816 has 1
+ * pin that can be used as TS/GPIO, so fun_mask, dir_mask and val_mask are all
+ * necessary.
+ */
+struct rk805_pin_config {
+   u8 reg;
+   u8 fun_msk;
+   u8 dir_msk;
+   u8 val_msk;
+};
+
+struct rk805_pctrl_info {
+   struct rk808 *rk808;
+   struct device *dev;
+   struct pinctrl_dev *pctl;
+   struct gpio_chip gpio_chip;
+   struct pinctrl_desc pinctrl_desc;
+   const struct rk805_pin_function *functions;
+   unsigned int num_functions;
+   const struct rk805_pin_group *groups;
+   int num_pin_groups;
+   const struct pinctrl_pin_desc *pins;
+   unsigned int num_pins;
+   struct rk805_pin_config *pin_cfg;
+};
+
+enum rk805_pinmux_option {
+   RK805_PINMUX_GPIO,
+};
+
+enum {
+   RK805_GPIO0,
+   RK805_GPIO1,
+};
+
+static const char *const rk805_gpio_groups[] = {
+   "gpio0",
+   "gpio1",
+};
+
+/* RK805: 2 output only GPIOs */
+static const struct pinctrl_pin_desc rk805_pins_desc[] = {
+   PINCTRL_PIN(RK805_GPIO0, "gpio0"),
+   PINCTRL_PIN(RK805_GPIO1, "gpio1"),
+};
+
+static const struct rk805_pin_function rk805_pin_functions[] = {
+   {
+   .name = "gpio",
+   .groups = rk805_gpio_groups,
+   .ngroups = ARRAY_SIZE(rk805_gpio_groups),
+   .mux_option = RK805_PINMUX_GPIO,
+   },
+};
+
+static const struct rk805_pin_group rk805_pin_gro

[PATCH v8 01/12] mfd: rk808: fix up the chip id get failed

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..3334a2a 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* read Chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v8 01/12] mfd: rk808: fix up the chip id get failed

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

the rk8xx chip id is:
((MSB << 8) | LSB) & 0xfff0

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/mfd/rk808.c   | 21 +++--
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index fd087cb..3334a2a 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -325,7 +325,7 @@ static int rk808_probe(struct i2c_client *client,
void (*pm_pwroff_fn)(void);
int nr_pre_init_regs;
int nr_cells;
-   int pm_off = 0;
+   int pm_off = 0, msb, lsb;
int ret;
int i;
 
@@ -333,14 +333,23 @@ static int rk808_probe(struct i2c_client *client,
if (!rk808)
return -ENOMEM;
 
-   rk808->variant = i2c_smbus_read_word_data(client, RK808_ID_MSB);
-   if (rk808->variant < 0) {
-   dev_err(>dev, "Failed to read the chip id at 0x%02x\n",
+   /* read Chip variant */
+   msb = i2c_smbus_read_byte_data(client, RK808_ID_MSB);
+   if (msb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
RK808_ID_MSB);
-   return rk808->variant;
+   return msb;
}
 
-   dev_dbg(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
+   lsb = i2c_smbus_read_byte_data(client, RK808_ID_LSB);
+   if (lsb < 0) {
+   dev_err(>dev, "failed to read the chip id at 0x%x\n",
+   RK808_ID_LSB);
+   return lsb;
+   }
+
+   rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
+   dev_info(>dev, "Chip id: 0x%x\n", (unsigned int)rk808->variant);
 
switch (rk808->variant) {
case RK808_ID:
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 83701ef..54feb14 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -298,6 +298,7 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define RK8XX_ID_MSK   0xfff0
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
-- 
1.9.1




[PATCH v8 03/12] regulator: rk808: Add regulator driver for RK805

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Add support for the rk805 regulator. The regulator module consists
of 4 DCDCs, 3 LDOs.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
Acked-by: Mark Brown <broo...@kernel.org>
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 130 
 2 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb2..285e280 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -650,11 +650,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK808 and RK818.
+ PMIC RK805,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index fb44d52..128c81e 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
+#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
+   _vmask, _ereg, _emask, _etime)  \
+   [_id] = {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),  \
+   .enable_mask= (_emask), \
+   .enable_time= (_etime), \
+   .ops= _reg_ops,   \
+   }
+
 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _etime)  \
[_id] = {   \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct 
regulator_dev *rdev, int uv)
  sel);
 }
 
+static int rk805_set_suspend_enable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ rdev->desc->enable_mask);
+}
+
+static int rk805_set_suspend_disable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ 0);
+}
+
 static int rk808_set_suspend_enable(struct regulator_dev *rdev)
 {
unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev 
*rdev)
  rdev->desc->enable_mask);
 }
 
+static struct regulator_ops rk805_reg_ops = {
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+  

[PATCH v8 03/12] regulator: rk808: Add regulator driver for RK805

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

Add support for the rk805 regulator. The regulator module consists
of 4 DCDCs, 3 LDOs.

The output voltages are configurable and are meant to supply power
to the main processor and other components.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
Acked-by: Mark Brown 
---
 drivers/regulator/Kconfig   |   4 +-
 drivers/regulator/rk808-regulator.c | 130 
 2 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb2..285e280 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -650,11 +650,11 @@ config REGULATOR_RC5T583
  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-   tristate "Rockchip RK808/RK818 Power regulators"
+   tristate "Rockchip RK805/RK808/RK818 Power regulators"
depends on MFD_RK808
help
  Select this option to enable the power regulator of ROCKCHIP
- PMIC RK808 and RK818.
+ PMIC RK805,RK808 and RK818.
  This driver supports the control of different power rails of device
  through regulator interface. The device supports multiple DCDC/LDO
  outputs which can be controlled by i2c communication.
diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index fb44d52..128c81e 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -65,6 +65,27 @@
 /* max steps for increase voltage of Buck1/2, equal 100mv*/
 #define MAX_STEPS_ONE_TIME 8
 
+#define RK805_DESC(_id, _match, _supply, _min, _max, _step, _vreg,  \
+   _vmask, _ereg, _emask, _etime)  \
+   [_id] = {   \
+   .name   = (_match), \
+   .supply_name= (_supply),\
+   .of_match   = of_match_ptr(_match), \
+   .regulators_node = of_match_ptr("regulators"),  \
+   .type   = REGULATOR_VOLTAGE,\
+   .id = (_id),\
+   .n_voltages = (((_max) - (_min)) / (_step) + 1),\
+   .owner  = THIS_MODULE,  \
+   .min_uV = (_min) * 1000,\
+   .uV_step= (_step) * 1000,   \
+   .vsel_reg   = (_vreg),  \
+   .vsel_mask  = (_vmask), \
+   .enable_reg = (_ereg),  \
+   .enable_mask= (_emask), \
+   .enable_time= (_etime), \
+   .ops= _reg_ops,   \
+   }
+
 #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \
_vmask, _ereg, _emask, _etime)  \
[_id] = {   \
@@ -298,6 +319,28 @@ static int rk808_set_suspend_voltage_range(struct 
regulator_dev *rdev, int uv)
  sel);
 }
 
+static int rk805_set_suspend_enable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ rdev->desc->enable_mask);
+}
+
+static int rk805_set_suspend_disable(struct regulator_dev *rdev)
+{
+   unsigned int reg;
+
+   reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET;
+
+   return regmap_update_bits(rdev->regmap, reg,
+ rdev->desc->enable_mask,
+ 0);
+}
+
 static int rk808_set_suspend_enable(struct regulator_dev *rdev)
 {
unsigned int reg;
@@ -320,6 +363,27 @@ static int rk808_set_suspend_disable(struct regulator_dev 
*rdev)
  rdev->desc->enable_mask);
 }
 
+static struct regulator_ops rk805_reg_ops = {
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+   .set_suspend_voltage= rk808_set_suspend_vol

[PATCH v8 04/12] mfd: rk808: Add RK805 support

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

The RK805 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clocking

Both RK808 and RK805 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/rk808.c | 108 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb..b410a34 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -892,13 +892,13 @@ config MFD_RC5T583
  different functionality of the device.
 
 config MFD_RK808
-   tristate "Rockchip RK808/RK818 Power Management Chip"
+   tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
depends on I2C && OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
help
- If you say yes here you get support for the RK808 and RK818
+ If you say yes here you get support for the RK805, RK808 and RK818
  Power Management chips.
  This driver provides common support for accessing the device
  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 3334a2a..7276555 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.volatile_reg = rk808_is_volatile_reg,
 };
 
+static const struct regmap_config rk805_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = RK805_OFF_SOURCE_REG,
+   .cache_type = REGCACHE_RBTREE,
+   .volatile_reg = rk808_is_volatile_reg,
+};
+
 static const struct regmap_config rk808_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -86,6 +94,16 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static const struct mfd_cell rk805s[] = {
+   { .name = "rk808-clkout", },
+   { .name = "rk808-regulator", },
+   {
+   .name = "rk808-rtc",
+   .num_resources = ARRAY_SIZE(rtc_resources),
+   .resources = _resources[0],
+   },
+};
+
 static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -106,6 +124,20 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
},
 };
 
+static const struct rk808_reg_data rk805_pre_init_reg[] = {
+   {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK3_ILMAX_3000MA},
+   {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK4_ILMAX_3500MA},
+   {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
+   {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
+   {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
+};
+
 static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
@@ -135,6 +167,41 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
VB_LO_SEL_3500MV },
 };
 
+static const struct regmap_irq rk805_irqs[] = {
+   [RK805_IRQ_PWRON_RISE] = {
+   .mask = RK805_IRQ_PWRON_RISE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_VB_LOW] = {
+   .mask = RK805_IRQ_VB_LOW_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON] = {
+   .mask = RK805_IRQ_PWRON_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_LP] = {
+   .mask = RK805_IRQ_PWRON_LP_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_HOTDIE] = {
+   .mask = RK805_IRQ_HOTDIE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_ALARM] = {
+   .mask = RK805_IRQ_RTC_ALARM_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_PERIOD] = {
+   .mask = RK805_IRQ_RTC_PERIOD_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_FALL] = {
+   .mask = RK805_IRQ_PWRON_FALL_MSK,
+   .reg_offset = 0,
+   },
+};
+
 static const struct regmap_irq rk808_irqs[] = {
/* I

[PATCH v8 04/12] mfd: rk808: Add RK805 support

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

The RK805 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:

- Regulators
- RTC
- Clocking

Both RK808 and RK805 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/rk808.c | 108 
 2 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 55ecdfb..b410a34 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -892,13 +892,13 @@ config MFD_RC5T583
  different functionality of the device.
 
 config MFD_RK808
-   tristate "Rockchip RK808/RK818 Power Management Chip"
+   tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
depends on I2C && OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
help
- If you say yes here you get support for the RK808 and RK818
+ If you say yes here you get support for the RK805, RK808 and RK818
  Power Management chips.
  This driver provides common support for accessing the device
  through I2C interface. The device supports multiple sub-devices
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 3334a2a..7276555 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -70,6 +70,14 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.volatile_reg = rk808_is_volatile_reg,
 };
 
+static const struct regmap_config rk805_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = RK805_OFF_SOURCE_REG,
+   .cache_type = REGCACHE_RBTREE,
+   .volatile_reg = rk808_is_volatile_reg,
+};
+
 static const struct regmap_config rk808_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -86,6 +94,16 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static const struct mfd_cell rk805s[] = {
+   { .name = "rk808-clkout", },
+   { .name = "rk808-regulator", },
+   {
+   .name = "rk808-rtc",
+   .num_resources = ARRAY_SIZE(rtc_resources),
+   .resources = _resources[0],
+   },
+};
+
 static const struct mfd_cell rk808s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -106,6 +124,20 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
},
 };
 
+static const struct rk808_reg_data rk805_pre_init_reg[] = {
+   {RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK2_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
+RK805_BUCK1_2_ILMAX_4000MA},
+   {RK805_BUCK3_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK3_ILMAX_3000MA},
+   {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
+RK805_BUCK4_ILMAX_3500MA},
+   {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
+   {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
+   {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
+};
+
 static const struct rk808_reg_data rk808_pre_init_reg[] = {
{ RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_150MA },
{ RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK,  BUCK_ILMIN_200MA },
@@ -135,6 +167,41 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
VB_LO_SEL_3500MV },
 };
 
+static const struct regmap_irq rk805_irqs[] = {
+   [RK805_IRQ_PWRON_RISE] = {
+   .mask = RK805_IRQ_PWRON_RISE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_VB_LOW] = {
+   .mask = RK805_IRQ_VB_LOW_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON] = {
+   .mask = RK805_IRQ_PWRON_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_LP] = {
+   .mask = RK805_IRQ_PWRON_LP_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_HOTDIE] = {
+   .mask = RK805_IRQ_HOTDIE_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_ALARM] = {
+   .mask = RK805_IRQ_RTC_ALARM_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_RTC_PERIOD] = {
+   .mask = RK805_IRQ_RTC_PERIOD_MSK,
+   .reg_offset = 0,
+   },
+   [RK805_IRQ_PWRON_FALL] = {
+   .mask = RK805_IRQ_PWRON_FALL_MSK,
+   .reg_offset = 0,
+   },
+};
+
 static const struct regmap_irq rk808_irqs[] = {
/* INT_STS */
[RK808_IRQ_VOUT_LO] = {
@@ -247,6 +314,17 @@ static bool rk808_is_volat

[PATCH v8 02/12] mfd: rk808: add rk805 regs addr and ID

2017-08-03 Thread Joseph Chen
From: Elaine Zhang <zhangq...@rock-chips.com>

Signed-off-by: Elaine Zhang <zhangq...@rock-chips.com>
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 include/linux/mfd/rk808.h | 120 ++
 1 file changed, 120 insertions(+)

diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 54feb14..d315659 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
 #define RK818_USB_ILMIN_2000MA 0x7
 #define RK818_USB_CHG_SD_VSEL_MASK 0x70
 
+/* RK805 */
+enum rk805_reg {
+   RK805_ID_DCDC1,
+   RK805_ID_DCDC2,
+   RK805_ID_DCDC3,
+   RK805_ID_DCDC4,
+   RK805_ID_LDO1,
+   RK805_ID_LDO2,
+   RK805_ID_LDO3,
+};
+
+/* CONFIG REGISTER */
+#define RK805_VB_MON_REG   0x21
+#define RK805_THERMAL_REG  0x22
+
+/* POWER CHANNELS ENABLE REGISTER */
+#define RK805_DCDC_EN_REG  0x23
+#define RK805_SLP_DCDC_EN_REG  0x25
+#define RK805_SLP_LDO_EN_REG   0x26
+#define RK805_LDO_EN_REG   0x27
+
+/* BUCK AND LDO CONFIG REGISTER */
+#define RK805_BUCK_LDO_SLP_LP_EN_REG   0x2A
+#define RK805_BUCK1_CONFIG_REG 0x2E
+#define RK805_BUCK1_ON_VSEL_REG0x2F
+#define RK805_BUCK1_SLP_VSEL_REG   0x30
+#define RK805_BUCK2_CONFIG_REG 0x32
+#define RK805_BUCK2_ON_VSEL_REG0x33
+#define RK805_BUCK2_SLP_VSEL_REG   0x34
+#define RK805_BUCK3_CONFIG_REG 0x36
+#define RK805_BUCK4_CONFIG_REG 0x37
+#define RK805_BUCK4_ON_VSEL_REG0x38
+#define RK805_BUCK4_SLP_VSEL_REG   0x39
+#define RK805_LDO1_ON_VSEL_REG 0x3B
+#define RK805_LDO1_SLP_VSEL_REG0x3C
+#define RK805_LDO2_ON_VSEL_REG 0x3D
+#define RK805_LDO2_SLP_VSEL_REG0x3E
+#define RK805_LDO3_ON_VSEL_REG 0x3F
+#define RK805_LDO3_SLP_VSEL_REG0x40
+
+/* INTERRUPT REGISTER */
+#define RK805_PWRON_LP_INT_TIME_REG0x47
+#define RK805_PWRON_DB_REG 0x48
+#define RK805_DEV_CTRL_REG 0x4B
+#define RK805_INT_STS_REG  0x4C
+#define RK805_INT_STS_MSK_REG  0x4D
+#define RK805_GPIO_IO_POL_REG  0x50
+#define RK805_OUT_REG  0x52
+#define RK805_ON_SOURCE_REG0xAE
+#define RK805_OFF_SOURCE_REG   0xAF
+
+#define RK805_NUM_REGULATORS   7
+
+#define RK805_PWRON_FALL_RISE_INT_EN   0x0
+#define RK805_PWRON_FALL_RISE_INT_MSK  0x81
+
+/* RK805 IRQ Definitions */
+#define RK805_IRQ_PWRON_RISE   0
+#define RK805_IRQ_VB_LOW   1
+#define RK805_IRQ_PWRON2
+#define RK805_IRQ_PWRON_LP 3
+#define RK805_IRQ_HOTDIE   4
+#define RK805_IRQ_RTC_ALARM5
+#define RK805_IRQ_RTC_PERIOD   6
+#define RK805_IRQ_PWRON_FALL   7
+
+#define RK805_IRQ_PWRON_RISE_MSK   BIT(0)
+#define RK805_IRQ_VB_LOW_MSK   BIT(1)
+#define RK805_IRQ_PWRON_MSKBIT(2)
+#define RK805_IRQ_PWRON_LP_MSK BIT(3)
+#define RK805_IRQ_HOTDIE_MSK   BIT(4)
+#define RK805_IRQ_RTC_ALARM_MSKBIT(5)
+#define RK805_IRQ_RTC_PERIOD_MSK   BIT(6)
+#define RK805_IRQ_PWRON_FALL_MSK   BIT(7)
+
+#define RK805_PWR_RISE_INT_STATUS  BIT(0)
+#define RK805_VB_LOW_INT_STATUSBIT(1)
+#define RK805_PWRON_INT_STATUS BIT(2)
+#define RK805_PWRON_LP_INT_STATUS  BIT(3)
+#define RK805_HOTDIE_INT_STATUSBIT(4)
+#define RK805_ALARM_INT_STATUS BIT(5)
+#define RK805_PERIOD_INT_STATUSBIT(6)
+#define RK805_PWR_FALL_INT_STATUS  BIT(7)
+
+#define RK805_BUCK1_2_ILMAX_MASK   (3 << 6)
+#define RK805_BUCK3_4_ILMAX_MASK(3 << 3)
+#define RK805_RTC_PERIOD_INT_MASK  (1 << 6)
+#define RK805_RTC_ALARM_INT_MASK   (1 << 5)
+#define RK805_INT_ALARM_EN (1 << 3)
+#define RK805_INT_TIMER_EN (1 << 2)
+
 /* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO  0
 #define RK808_IRQ_VB_LO1
@@ -298,7 +389,14 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define TEMP115C   0x0c
+#define TEMP_HOTDIE_MSK0x0c
+#define SLP_SD_MSK (0x3 << 2)
+#define SHUTDOWN_FUN   (0x2 << 2)
+#define SLEEP_FUN  (0x1 << 2)
 #define RK8XX_ID_MSK   0xfff0
+#define FPWM_MODE  BIT(7)
+
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
@@ -322,6 +420,28 @@ enum {
 };
 
 enum {
+   RK805_BUCK1_2_ILMAX_2500MA,
+   RK805_BUCK1_2_ILMAX_3000MA,
+   RK805_BUCK1_2_ILMAX_3500MA,
+   RK805_BUCK1_2_ILMAX_4000MA,
+};
+
+enum {
+   RK805_BUCK3_ILMAX_1500MA,
+   RK805_BUCK3_ILMAX_2000MA,
+   RK805_BUCK3_ILMAX_2500MA,
+   

[PATCH v8 02/12] mfd: rk808: add rk805 regs addr and ID

2017-08-03 Thread Joseph Chen
From: Elaine Zhang 

Signed-off-by: Elaine Zhang 
Signed-off-by: Joseph Chen 
---
 include/linux/mfd/rk808.h | 120 ++
 1 file changed, 120 insertions(+)

diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 54feb14..d315659 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -206,6 +206,97 @@ enum rk818_reg {
 #define RK818_USB_ILMIN_2000MA 0x7
 #define RK818_USB_CHG_SD_VSEL_MASK 0x70
 
+/* RK805 */
+enum rk805_reg {
+   RK805_ID_DCDC1,
+   RK805_ID_DCDC2,
+   RK805_ID_DCDC3,
+   RK805_ID_DCDC4,
+   RK805_ID_LDO1,
+   RK805_ID_LDO2,
+   RK805_ID_LDO3,
+};
+
+/* CONFIG REGISTER */
+#define RK805_VB_MON_REG   0x21
+#define RK805_THERMAL_REG  0x22
+
+/* POWER CHANNELS ENABLE REGISTER */
+#define RK805_DCDC_EN_REG  0x23
+#define RK805_SLP_DCDC_EN_REG  0x25
+#define RK805_SLP_LDO_EN_REG   0x26
+#define RK805_LDO_EN_REG   0x27
+
+/* BUCK AND LDO CONFIG REGISTER */
+#define RK805_BUCK_LDO_SLP_LP_EN_REG   0x2A
+#define RK805_BUCK1_CONFIG_REG 0x2E
+#define RK805_BUCK1_ON_VSEL_REG0x2F
+#define RK805_BUCK1_SLP_VSEL_REG   0x30
+#define RK805_BUCK2_CONFIG_REG 0x32
+#define RK805_BUCK2_ON_VSEL_REG0x33
+#define RK805_BUCK2_SLP_VSEL_REG   0x34
+#define RK805_BUCK3_CONFIG_REG 0x36
+#define RK805_BUCK4_CONFIG_REG 0x37
+#define RK805_BUCK4_ON_VSEL_REG0x38
+#define RK805_BUCK4_SLP_VSEL_REG   0x39
+#define RK805_LDO1_ON_VSEL_REG 0x3B
+#define RK805_LDO1_SLP_VSEL_REG0x3C
+#define RK805_LDO2_ON_VSEL_REG 0x3D
+#define RK805_LDO2_SLP_VSEL_REG0x3E
+#define RK805_LDO3_ON_VSEL_REG 0x3F
+#define RK805_LDO3_SLP_VSEL_REG0x40
+
+/* INTERRUPT REGISTER */
+#define RK805_PWRON_LP_INT_TIME_REG0x47
+#define RK805_PWRON_DB_REG 0x48
+#define RK805_DEV_CTRL_REG 0x4B
+#define RK805_INT_STS_REG  0x4C
+#define RK805_INT_STS_MSK_REG  0x4D
+#define RK805_GPIO_IO_POL_REG  0x50
+#define RK805_OUT_REG  0x52
+#define RK805_ON_SOURCE_REG0xAE
+#define RK805_OFF_SOURCE_REG   0xAF
+
+#define RK805_NUM_REGULATORS   7
+
+#define RK805_PWRON_FALL_RISE_INT_EN   0x0
+#define RK805_PWRON_FALL_RISE_INT_MSK  0x81
+
+/* RK805 IRQ Definitions */
+#define RK805_IRQ_PWRON_RISE   0
+#define RK805_IRQ_VB_LOW   1
+#define RK805_IRQ_PWRON2
+#define RK805_IRQ_PWRON_LP 3
+#define RK805_IRQ_HOTDIE   4
+#define RK805_IRQ_RTC_ALARM5
+#define RK805_IRQ_RTC_PERIOD   6
+#define RK805_IRQ_PWRON_FALL   7
+
+#define RK805_IRQ_PWRON_RISE_MSK   BIT(0)
+#define RK805_IRQ_VB_LOW_MSK   BIT(1)
+#define RK805_IRQ_PWRON_MSKBIT(2)
+#define RK805_IRQ_PWRON_LP_MSK BIT(3)
+#define RK805_IRQ_HOTDIE_MSK   BIT(4)
+#define RK805_IRQ_RTC_ALARM_MSKBIT(5)
+#define RK805_IRQ_RTC_PERIOD_MSK   BIT(6)
+#define RK805_IRQ_PWRON_FALL_MSK   BIT(7)
+
+#define RK805_PWR_RISE_INT_STATUS  BIT(0)
+#define RK805_VB_LOW_INT_STATUSBIT(1)
+#define RK805_PWRON_INT_STATUS BIT(2)
+#define RK805_PWRON_LP_INT_STATUS  BIT(3)
+#define RK805_HOTDIE_INT_STATUSBIT(4)
+#define RK805_ALARM_INT_STATUS BIT(5)
+#define RK805_PERIOD_INT_STATUSBIT(6)
+#define RK805_PWR_FALL_INT_STATUS  BIT(7)
+
+#define RK805_BUCK1_2_ILMAX_MASK   (3 << 6)
+#define RK805_BUCK3_4_ILMAX_MASK(3 << 3)
+#define RK805_RTC_PERIOD_INT_MASK  (1 << 6)
+#define RK805_RTC_ALARM_INT_MASK   (1 << 5)
+#define RK805_INT_ALARM_EN (1 << 3)
+#define RK805_INT_TIMER_EN (1 << 2)
+
 /* RK808 IRQ Definitions */
 #define RK808_IRQ_VOUT_LO  0
 #define RK808_IRQ_VB_LO1
@@ -298,7 +389,14 @@ enum rk818_reg {
 #define VOUT_LO_INTBIT(0)
 #define CLK32KOUT2_EN  BIT(0)
 
+#define TEMP115C   0x0c
+#define TEMP_HOTDIE_MSK0x0c
+#define SLP_SD_MSK (0x3 << 2)
+#define SHUTDOWN_FUN   (0x2 << 2)
+#define SLEEP_FUN  (0x1 << 2)
 #define RK8XX_ID_MSK   0xfff0
+#define FPWM_MODE  BIT(7)
+
 enum {
BUCK_ILMIN_50MA,
BUCK_ILMIN_100MA,
@@ -322,6 +420,28 @@ enum {
 };
 
 enum {
+   RK805_BUCK1_2_ILMAX_2500MA,
+   RK805_BUCK1_2_ILMAX_3000MA,
+   RK805_BUCK1_2_ILMAX_3500MA,
+   RK805_BUCK1_2_ILMAX_4000MA,
+};
+
+enum {
+   RK805_BUCK3_ILMAX_1500MA,
+   RK805_BUCK3_ILMAX_2000MA,
+   RK805_BUCK3_ILMAX_2500MA,
+   RK805_BUCK3_ILMAX_3000MA,
+};
+
+enum {
+   RK805_BUCK4_ILMAX_2000MA,
+   RK80

[PATCH v8 00/12] rk808: Add RK805 support

2017-08-03 Thread Joseph Chen
change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 2/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 3/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 4/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 5/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 6/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 7/12: add: Signed-off-by: Joseph Chen <che...@rock-chips.com>
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij <linus.wall...@linaro.org>   
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 
<linus.wall...@linaro.org>

change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown <broo...@kernel.org>
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring <r...@kernel.org>
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-
 drivers/input/misc/Kconfig |   6 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/rk805-pwrkey.c  | 111 +
 drivers/mfd/Kconfig|   4 +-
 drivers/mfd/rk808.c| 147 +-
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/pinctrl-rk805.c| 493 +
 drivers/regulator/Kconfig  |   4 +-
 drivers/regulator/rk808-regulator.c| 130 ++
 drivers/rtc/Kconfig|   4 +-
 include/linux/mfd/rk808.h  | 121 +
 15 files changed, 1105 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
 create mode 100644 drivers/input/misc/rk805-pwrkey.c
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

-- 
1.9.1




[PATCH v8 00/12] rk808: Add RK805 support

2017-08-03 Thread Joseph Chen
change in v8:
PATCH V8 1/12: add: Signed-off-by: Joseph Chen 
PATCH V8 2/12: add: Signed-off-by: Joseph Chen 
PATCH V8 3/12: add: Signed-off-by: Joseph Chen 
PATCH V8 4/12: add: Signed-off-by: Joseph Chen 
PATCH V8 5/12: add: Signed-off-by: Joseph Chen 
PATCH V8 6/12: add: Signed-off-by: Joseph Chen 
PATCH V8 7/12: add: Signed-off-by: Joseph Chen 
PATCH V8 8/12: (1) Kconfig: update coding style
   (2) pinctrl-rk805.c: using #include 
   (3) pinctrl-rk805.c: inline data and open code it; remove 
FUNCTION_GROUP and PINGROUP macros definition 
PATCH V8 9/12: NO change in V8
PATCH V8 10/12: apply tag: Acked-by: Linus Walleij
PATCH V8 11/12: NO change in V8
PATCH V8 12/12: (1) using semicolon after "output-high"
(2) apply tag: Acked-by: Linus Walleij 


change in v7:
PATCH V7 1/12: NO change in V7
PATCH V7 2/12: NO change in V7
PATCH V7 3/12: fix missing: Acked-by: Mark Brown 
PATCH V7 4/12: NO change in V7
PATCH V7 5/12: NO change in V7
PATCH V7 6/12: NO change in V7
PATCH V7 7/12: fix missing: Acked-by: Rob Herring 
PATCH V7 8/12: abandon drivers/gpio/gpio-rk805.c and add 
drivers/pinctrl/pinctrl-rk805.c
PATCH V7 9/12: reset author and signed off with my english name
   reset MODULE_AUTHOR() with my english name
   replace devm_request_threaded_irq() with 
devm_request_any_context_irq()
PATCH V7 10/12: replace 'gpio-rk805' with 'pinctrl-rk805' in struct mfd_cell 
rk805s[]
PATCH V7 11/12: NO change in V7
PATCH V7 12/12: dt-bindings: abandon gpio-rk805.txt and add pinctrl-rk805.txt

change in v6:
patch1~7 no changed in V6.
add patch 8~12 for gpio and powerkey func for rk805.

change in v5:
PATCH V5 1/7: NO change in V5
PATCH V5 2/7: fix the rk805 reg addr in numerical order
PATCH V5 3/7: NO change in V5
PATCH V5 4/7: fix up the rk805_device_shutdown func
PATCH V5 5/7: NO change in V5
PATCH V5 6/7: NO change in V5
PATCH V5 7/7: fix up the description of the rk805

change in v4:
PATCH V4 1/7: NO change in V4
PATCH V4 2/7: rename the commit message
PATCH V4 3/7: NO change in V4
PATCH V4 4/7: Split this patch up into subsystems patch 5/7 6/7
PATCH V4 5/7: new added
PATCH V4 6/7: new added
PATCH V4 7/7: NO change in V4


change in V3:
PATCH V3 1/5: NO change in V3
PATCH V3 2/5: add rk805 RTC INT MASK define
PATCH V3 3/5: RK805 set suspend enable and disable is different from rk808
  use rk805_regs_ops and rk805_switch_ops
PATCH V3 4/5: fix up the shutdown func
  use pm_shutdown_prepare_fn to prepare shutdown
  and pm_pwroff_fn pull down gpio to shut down rk805
  it will update in the future(after rk808 support gpio func)
PATCH V3 5/5: NO change in V3

change in V2:
PATCH V2 1/5: NO change in V2
PATCH V2 2/5: add rk805 BUCK ILMAX define
PATCH V2 3/5: NO change in V2
PATCH V2 4/5: setting RK805 BUCK ILMAX in pre init
PATCH V2 5/5: Add RK805 device tree bindings document

Elaine Zhang (7):
  mfd: rk808: fix up the chip id get failed
  mfd: rk808: add rk805 regs addr and ID
  regulator: rk808: Add regulator driver for RK805
  mfd: rk808: Add RK805 support
  clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808
  rtc: Kconfig: Name RK805 in Kconfig for RTC_DRV_RK808
  mfd: dt-bindings: Add RK805 device tree bindings document

Joseph Chen (5):
  pinctrl: Add pinctrl driver for the RK805 PMIC
  Input: Add power key driver for Rockchip RK805 PMIC
  mfd: rk808: Add RK805 pinctrl support
  mfd: rk808: Add RK805 power key support
  pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

 Documentation/devicetree/bindings/mfd/rk808.txt|  22 +-
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  |  63 +++
 drivers/clk/Kconfig|   4 +-
 drivers/input/misc/Kconfig |   6 +
 drivers/input/misc/Makefile|   1 +
 drivers/input/misc/rk805-pwrkey.c  | 111 +
 drivers/mfd/Kconfig|   4 +-
 drivers/mfd/rk808.c| 147 +-
 drivers/pinctrl/Kconfig|   9 +
 drivers/pinctrl/Makefile   |   1 +
 drivers/pinctrl/pinctrl-rk805.c| 493 +
 drivers/regulator/Kconfig  |   4 +-
 drivers/regulator/rk808-regulator.c| 130 ++
 drivers/rtc/Kconfig|   4 +-
 include/linux/mfd/rk808.h  | 121 +
 15 files changed, 1105 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
 create mode 100644 drivers/input/misc/rk805-pwrkey.c
 create mode 100644 drivers/pinctrl/pinctrl-rk805.c

-- 
1.9.1




[PATCH v7 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-07-21 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[PATCH v7 05/12] clk: Kconfig: Name RK805 in Kconfig for COMMON_CLK_RK808

2017-07-21 Thread Joseph Chen
From: Elaine Zhang 

The RK808 and RK805 PMICs are using a similar register map.
We can reuse the clk driver for the RK805 PMIC. So let's add
the RK805 in the Kconfig description.

Signed-off-by: Elaine Zhang 
---
 drivers/clk/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 9356ab4..7ca8f02 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -39,10 +39,10 @@ config COMMON_CLK_MAX77686
  clock.
 
 config COMMON_CLK_RK808
-   tristate "Clock driver for RK808/RK818"
+   tristate "Clock driver for RK805/RK808/RK818"
depends on MFD_RK808
---help---
- This driver supports RK808 and RK818 crystal oscillator clock. These
+ This driver supports RK805, RK808 and RK818 crystal oscillator clock. 
These
  multi-function devices have two fixed-rate oscillators,
  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
  by control register.
-- 
1.9.1




[PATCH v7 10/12] mfd: rk808: Add RK805 pinctrl support

2017-07-21 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 7276555..db90471 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[PATCH v7 10/12] mfd: rk808: Add RK805 pinctrl support

2017-07-21 Thread Joseph Chen
Signed-off-by: Joseph Chen 
---
 drivers/mfd/rk808.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 7276555..db90471 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -97,6 +97,7 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
+   { .name = "rk805-pinctrl", },
{
.name = "rk808-rtc",
.num_resources = ARRAY_SIZE(rtc_resources),
-- 
1.9.1




[PATCH v7 12/12] pinctrl: dt-bindings: add bindings for Rockchip RK805 PMIC

2017-07-21 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 .../devicetree/bindings/pinctrl/pinctrl-rk805.txt  | 63 ++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
new file mode 100644
index 000..367ddf9
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
@@ -0,0 +1,63 @@
+Pincontrol driver for RK805 Power management IC.
+
+RK805 has 2 pins which can be configured as GPIO output only.
+
+Please refer file 
+for details of the common pinctrl bindings used by client devices,
+including the meaning of the phrase "pin configuration node".
+
+Optional Pinmux properties:
+--
+Following properties are required if default setting of pins are required
+at boot.
+- pinctrl-names: A pinctrl state named per .
+- pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
+   .
+
+The pin configurations are defined as child of the pinctrl states node. Each
+sub-node have following properties:
+
+Required properties:
+--
+- #gpio-cells: Should be two. The first cell is the pin number and the
+  second is the GPIO flags.
+
+- gpio-controller: Marks the device node as a GPIO controller.
+
+- pins: List of pins. Valid values of pins properties are: gpio0, gpio1.
+
+First 2 properties must be added in the RK805 PMIC node, documented in
+Documentation/devicetree/bindings/mfd/rk808.txt
+
+Optional properties:
+---
+Following are optional properties defined as pinmux DT binding document
+. Absence of properties will leave the configuration
+on default.
+   function,
+   output-low,
+   output-high.
+
+Valid values for function properties are: gpio.
+
+Theres is also not customised properties for any GPIO.
+
+Example:
+
+rk805: rk805@18 {
+   compatible = "rockchip,rk805";
+   ...
+   gpio-controller;
+   #gpio-cells = <2>;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_int_l>, <_default>;
+
+   rk805_default: pinmux {
+   gpio01 {
+   pins = "gpio0", "gpio1";
+   function = "gpio";
+   output-high.
+   };
+   };
+};
-- 
1.9.1




[PATCH v7 11/12] mfd: rk808: Add RK805 power key support

2017-07-21 Thread Joseph Chen
Signed-off-by: Joseph Chen <che...@rock-chips.com>
---
 drivers/mfd/rk808.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index db90471..6d9f96b 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -94,6 +94,19 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
}
 };
 
+static struct resource rk805_key_resources[] = {
+   {
+   .start  = RK805_IRQ_PWRON_FALL,
+   .end= RK805_IRQ_PWRON_FALL,
+   .flags  = IORESOURCE_IRQ,
+   },
+   {
+   .start  = RK805_IRQ_PWRON_RISE,
+   .end= RK805_IRQ_PWRON_RISE,
+   .flags  = IORESOURCE_IRQ,
+   }
+};
+
 static const struct mfd_cell rk805s[] = {
{ .name = "rk808-clkout", },
{ .name = "rk808-regulator", },
@@ -103,6 +116,10 @@ static bool rk808_is_volatile_reg(struct device *dev, 
unsigned int reg)
.num_resources = ARRAY_SIZE(rtc_resources),
.resources = _resources[0],
},
+   {   .name = "rk805-pwrkey",
+   .num_resources = ARRAY_SIZE(rk805_key_resources),
+   .resources = _key_resources[0],
+   },
 };
 
 static const struct mfd_cell rk808s[] = {
-- 
1.9.1




  1   2   >