[PATCH] ARM: at91/dt: sama5d4: change watchdog compatible

2015-11-04 Thread Wenyou Yang
Change the watchdog compatible to "atmel,sama5d4-wdt" to support
SAMA5D4 watchdog driver.

Signed-off-by: Wenyou Yang 
---

 arch/arm/boot/dts/sama5d4.dtsi |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 15bbaf6..2193637 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -1300,7 +1300,7 @@
};
 
watchdog@fc068640 {
-   compatible = "atmel,at91sam9260-wdt";
+   compatible = "atmel,sama5d4-wdt";
reg = <0xfc068640 0x10>;
clocks = <&clk32k>;
status = "disabled";
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: at91/dt: sama5d2: add watchdog node

2015-11-04 Thread Wenyou Yang
Add watchdog node to support SAMA5D4 watchdog.

Signed-off-by: Wenyou Yang 
---

 arch/arm/boot/dts/at91-sama5d2_xplained.dts |4 
 arch/arm/boot/dts/sama5d2.dtsi  |7 +++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts 
b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index e07c2b2..de3ef02 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -181,6 +181,10 @@
};
};
 
+   watchdog@f8048040 {
+   status = "okay";
+   };
+
uart3: serial@fc008000 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart3_default>;
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index c1f0cba..c29ff70 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -929,6 +929,13 @@
clocks = <&h32ck>;
};
 
+   watchdog@f8048040 {
+   compatible = "atmel,sama5d4-wdt";
+   reg = <0xf8048040 0x10>;
+   interrupts = <4 IRQ_TYPE_LEVEL_HIGH 7>;
+   status = "disabled";
+   };
+
sckc@f8048050 {
compatible = "atmel,at91sam9x5-sckc";
reg = <0xf8048050 0x4>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: dts: at91: sama5d2_xplained: add regulator nodes

2015-10-13 Thread Wenyou Yang
Add regulator nodes of PMIC ACT8945A chip on the board.

Signed-off-by: Wenyou Yang 
---

 arch/arm/boot/dts/at91-sama5d2_xplained.dts |   57 +++
 1 file changed, 57 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts 
b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index dc23979..e07c2b2 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -122,6 +122,63 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c0_default>;
status = "okay";
+
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   active-semi,vsel-high;
+   status = "okay";
+
+   regulators {
+   vdd_1v35_reg: DCDC_REG1 {
+   regulator-name = 
"VDD_1V35";
+   regulator-min-microvolt 
= <135>;
+   regulator-max-microvolt 
= <135>;
+   regulator-always-on;
+   };
+
+   vdd_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"VDD_1V2";
+   regulator-min-microvolt 
= <110>;
+   regulator-max-microvolt 
= <130>;
+   regulator-always-on;
+   };
+
+   vdd_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"VDD_3V3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vdd_fuse_reg: LDO_REG1 {
+   regulator-name = 
"VDD_FUSE";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   regulator-always-on;
+   };
+
+   vdd_3v3_lp_reg: LDO_REG2 {
+   regulator-name = 
"VDD_3V3_LP";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vdd_led_reg: LDO_REG3 {
+   regulator-name = 
"VDD_LED";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vdd_sdhc_1v8_reg: LDO_REG4 {
+   regulator-name = 
"VDD_SDHC_1V8";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   };
+   };
+   };
};
 
uart3: serial@fc008000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] regulator: act8865: add DT binding for property "active-semi,vsel-high"

2015-09-30 Thread Wenyou Yang
Add a DT property "active-semi,vsel-high" to indicate the VSEL pin
is high. If this property is missing, then assume the VSEL pin is
low(0).

Signed-off-by: Wenyou Yang 
---

Changes in v2: None

 .../bindings/regulator/act8865-regulator.txt   |3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
index e91485d..6067d98 100644
--- a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -8,6 +8,8 @@ Required properties:
 Optional properties:
 - system-power-controller: Telling whether or not this pmic is controlling
   the system power. See 
Documentation/devicetree/bindings/power/power-controller.txt .
+- active-semi,vsel-high: Indicates the VSEL pin is high.
+  If this property is missing, assume the VSEL pin is low(0).
 
 Optional input supply properties:
 - for act8600:
@@ -49,6 +51,7 @@ Example:
pmic: act8865@5b {
compatible = "active-semi,act8865";
reg = <0x5b>;
+   active-semi,vsel-high;
status = "disabled";
 
regulators {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] regulator: act8865: support output voltage by VSET2[] bits

2015-09-30 Thread Wenyou Yang
For the step-down DC/DC regulators, the output voltage is
selectable by setting VSEL pin that when VSEL is low, output
voltage is programmed by VSET1[] bits, and when VSEL is high,
output voltage is programmed by VSET2[] bits.

The DT property "active-semi,vsel-high" is used to specify
the VSEL pin at high on the board.

Signed-off-by: Wenyou Yang 
---

Changes in v2:
 - fix missed argument of macro "ACT88xx_REG" for act8865_alt_regulators
   structure variable.
 - set variable "voltage_select" initial value to avoid compile warning.

 drivers/regulator/act8865-regulator.c |   24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
index 896db16..f8d4cd3 100644
--- a/drivers/regulator/act8865-regulator.c
+++ b/drivers/regulator/act8865-regulator.c
@@ -261,6 +261,16 @@ static const struct regulator_desc act8865_regulators[] = {
ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET, "inl67"),
 };
 
+static const struct regulator_desc act8865_alt_regulators[] = {
+   ACT88xx_REG("DCDC_REG1", ACT8865, DCDC1, VSET2, "vp1"),
+   ACT88xx_REG("DCDC_REG2", ACT8865, DCDC2, VSET2, "vp2"),
+   ACT88xx_REG("DCDC_REG3", ACT8865, DCDC3, VSET2, "vp3"),
+   ACT88xx_REG("LDO_REG1", ACT8865, LDO1, VSET, "inl45"),
+   ACT88xx_REG("LDO_REG2", ACT8865, LDO2, VSET, "inl45"),
+   ACT88xx_REG("LDO_REG3", ACT8865, LDO3, VSET, "inl67"),
+   ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET, "inl67"),
+};
+
 #ifdef CONFIG_OF
 static const struct of_device_id act8865_dt_ids[] = {
{ .compatible = "active-semi,act8600", .data = (void *)ACT8600 },
@@ -413,6 +423,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
struct act8865 *act8865;
unsigned long type;
int off_reg, off_mask;
+   int voltage_select = 0;
 
pdata = dev_get_platdata(dev);
 
@@ -424,6 +435,10 @@ static int act8865_pmic_probe(struct i2c_client *client,
return -ENODEV;
 
type = (unsigned long) id->data;
+
+   voltage_select = !!of_get_property(dev->of_node,
+  "active-semi,vsel-high",
+  NULL);
} else {
type = i2c_id->driver_data;
}
@@ -442,8 +457,13 @@ static int act8865_pmic_probe(struct i2c_client *client,
off_mask = ACT8846_OFF_SYSMASK;
break;
case ACT8865:
-   regulators = act8865_regulators;
-   num_regulators = ARRAY_SIZE(act8865_regulators);
+   if (voltage_select) {
+   regulators = act8865_alt_regulators;
+   num_regulators = ARRAY_SIZE(act8865_alt_regulators);
+   } else {
+   regulators = act8865_regulators;
+   num_regulators = ARRAY_SIZE(act8865_regulators);
+   }
off_reg = ACT8865_SYS_CTRL;
off_mask = ACT8865_MSTROFF;
break;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] Add support to make output voltage determined by VSET2[] bits

2015-09-30 Thread Wenyou Yang
The patch is to add support to make the output voltage of ACT8865
DC/DC regulator determined by VSET2[] bits. The DT property
"active-semi,vsel-high" is used to specify the VSEL pin at high
on the board. When the VSEL pin is high, output voltage is programmed
by VSET2[] bits.

Changes in v2:
 - fix missed argument of macro "ACT88xx_REG" for act8865_alt_regulators
   structure variable.
 - set variable "voltage_select" initial value to avoid compile warning.

Wenyou Yang (2):
  regulator: act8865: support output voltage by VSET2[] bits
  regulator: act8865: add DT binding for property
"active-semi,vsel-high"

 .../bindings/regulator/act8865-regulator.txt   |3 +++
 drivers/regulator/act8865-regulator.c  |   24 ++--
 2 files changed, 25 insertions(+), 2 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] regulator: act8865: add DT binding for property "active-semi,vsel-high"

2015-09-29 Thread Wenyou Yang
Add a DT property "active-semi,vsel-high" to indicate the VSEL pin
is high. If this property is missing, then assume the VSEL pin is
low(0).

Signed-off-by: Wenyou Yang 
---

 .../bindings/regulator/act8865-regulator.txt   |3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
index e91485d..6067d98 100644
--- a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -8,6 +8,8 @@ Required properties:
 Optional properties:
 - system-power-controller: Telling whether or not this pmic is controlling
   the system power. See 
Documentation/devicetree/bindings/power/power-controller.txt .
+- active-semi,vsel-high: Indicates the VSEL pin is high.
+  If this property is missing, assume the VSEL pin is low(0).
 
 Optional input supply properties:
 - for act8600:
@@ -49,6 +51,7 @@ Example:
pmic: act8865@5b {
compatible = "active-semi,act8865";
reg = <0x5b>;
+   active-semi,vsel-high;
status = "disabled";
 
regulators {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] regulator: act8865: support output voltage by VSET2[] bits

2015-09-29 Thread Wenyou Yang
For the step-down DC/DC regulators, the output voltage is
selectable by setting VSEL pin that when VSEL is low, output
voltage is programmed by VSET1[] bits, and when VSEL is high,
output voltage is programmed by VSET2[] bits.

The DT property "active-semi,vsel-high" is used to specify
the VSEL pin at high on the board.

Signed-off-by: Wenyou Yang 
---

 drivers/regulator/act8865-regulator.c |   24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
index 896db16..e2b50f3 100644
--- a/drivers/regulator/act8865-regulator.c
+++ b/drivers/regulator/act8865-regulator.c
@@ -261,6 +261,16 @@ static const struct regulator_desc act8865_regulators[] = {
ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET, "inl67"),
 };
 
+static const struct regulator_desc act8865_alt_regulators[] = {
+   ACT88xx_REG("DCDC_REG1", ACT8865, DCDC1, VSET2),
+   ACT88xx_REG("DCDC_REG2", ACT8865, DCDC2, VSET2),
+   ACT88xx_REG("DCDC_REG3", ACT8865, DCDC3, VSET2),
+   ACT88xx_REG("LDO_REG1", ACT8865, LDO1, VSET),
+   ACT88xx_REG("LDO_REG2", ACT8865, LDO2, VSET),
+   ACT88xx_REG("LDO_REG3", ACT8865, LDO3, VSET),
+   ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET),
+};
+
 #ifdef CONFIG_OF
 static const struct of_device_id act8865_dt_ids[] = {
{ .compatible = "active-semi,act8600", .data = (void *)ACT8600 },
@@ -413,6 +423,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
struct act8865 *act8865;
unsigned long type;
int off_reg, off_mask;
+   int voltage_select;
 
pdata = dev_get_platdata(dev);
 
@@ -424,6 +435,10 @@ static int act8865_pmic_probe(struct i2c_client *client,
return -ENODEV;
 
type = (unsigned long) id->data;
+
+   voltage_select = !!of_get_property(dev->of_node,
+  "active-semi,vsel-high",
+  NULL);
} else {
type = i2c_id->driver_data;
}
@@ -442,8 +457,13 @@ static int act8865_pmic_probe(struct i2c_client *client,
off_mask = ACT8846_OFF_SYSMASK;
break;
case ACT8865:
-   regulators = act8865_regulators;
-   num_regulators = ARRAY_SIZE(act8865_regulators);
+   if (voltage_select) {
+   regulators = act8865_alt_regulators;
+   num_regulators = ARRAY_SIZE(act8865_alt_regulators);
+   } else {
+   regulators = act8865_regulators;
+   num_regulators = ARRAY_SIZE(act8865_regulators);
+   }
off_reg = ACT8865_SYS_CTRL;
off_mask = ACT8865_MSTROFF;
break;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] Add support to make output voltage determined by VSET2[] bits

2015-09-29 Thread Wenyou Yang
The patch is to add support to make the output voltage of ACT8865
DC/DC regulator determined by VSET2[] bits. The DT property
"active-semi,vsel-high" is used to specify the VSEL pin at high
on the board. When the VSEL pin is high, output voltage is programmed
by VSET2[] bits.


Wenyou Yang (2):
  regulator: act8865: support output voltage by VSET2[] bits
  regulator: act8865: add DT binding for property
"active-semi,vsel-high"

 .../bindings/regulator/act8865-regulator.txt   |3 +++
 drivers/regulator/act8865-regulator.c  |   24 ++--
 2 files changed, 25 insertions(+), 2 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 2/2] Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog driver

2015-08-06 Thread Wenyou Yang
The compatible "atmel,sama5d4-wdt" supports the SAMA5D4 watchdog driver
and the watchdog's WDT_MR register can be written more than once.

Signed-off-by: Wenyou Yang 
---
 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 
 1 file changed, 35 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
new file mode 100644
index 000..f7cc7c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
@@ -0,0 +1,35 @@
+* Atmel SAMA5D4 Watchdog Timer (WDT) Controller
+
+Required properties:
+- compatible: "atmel,sama5d4-wdt"
+- reg: base physical address and length of memory mapped region.
+
+Optional properties:
+- timeout-sec: watchdog timeout value (in seconds).
+- interrupts: interrupt number to the CPU.
+- atmel,watchdog-type: should be "hardware" or "software".
+   "hardware": enable watchdog fault reset. A watchdog fault triggers
+   watchdog reset.
+   "software": enable watchdog fault interrupt. A watchdog fault asserts
+   watchdog interrupt.
+- atmel,idle-halt: present if you want to stop the watchdog when the CPU is
+  in idle state.
+   CAUTION: This property should be used with care, it actually makes the
+   watchdog not counting when the CPU is in idle state, therefore the
+   watchdog reset time depends on mean CPU usage and will not reset at all
+   if the CPU stop working while it is in idle state, which is probably
+   not what you want.
+- atmel,dbg-halt: present if you want to stop the watchdog when the CPU is
+ in debug state.
+
+Example:
+   watchdog@fc068640 {
+   compatible = "atmel,sama5d4-wdt";
+   reg = <0xfc068640 0x10>;
+   interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>;
+   timeout-sec = <10>;
+   atmel,watchdog-type = "hardware";
+   atmel,dbg-halt;
+   atmel,idle-halt;
+   status = "okay";
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer

2015-08-06 Thread Wenyou Yang
>From SAMA5D4, the watchdog timer is upgrated with a new feature,
which is describled as in the datasheet, "WDT_MR can be written
until a LOCKMR command is issued in WDT_CR".
That is to say, as long as the bootstrap and u-boot don't issue
a LOCKMR command, WDT_MR can be written more than once in the driver.

So the SAMA5D4 watchdog driver's implementation is different from
the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c.
The user application open the device file to enable the watchdog timer
hardware, and close to disable it, and set the watchdog timer timeout
by seting WDV and WDD fields of WDT_MR register, and ping the watchdog
by issuing WDRSTT command to WDT_CR register with hard-coded key.

Signed-off-by: Wenyou Yang 
---
 drivers/watchdog/Kconfig|9 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/at91sam9_wdt.h |2 +
 drivers/watchdog/sama5d4_wdt.c  |  280 +++
 4 files changed, 292 insertions(+)
 create mode 100644 drivers/watchdog/sama5d4_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e5e7c55..47ad39a 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -167,6 +167,15 @@ config AT91SAM9X_WATCHDOG
  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
  reboot your system when the timeout is reached.
 
+config SAMA5D4_WATCHDOG
+   tristate "Atmel SAMA5D4 Watchdog Timer"
+   depends on ARCH_AT91
+   select WATCHDOG_CORE
+   help
+ Atmel SAMA5D4 watchdog timer is embedded into SAMA5D4 chips.
+ Its Watchdog Timer Mode Register can be written more than once.
+ This will reboot your system when the timeout is reached.
+
 config CADENCE_WATCHDOG
tristate "Cadence Watchdog Timer"
select WATCHDOG_CORE
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 5c19294..f24b820 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
 obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
 obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
+obj-$(CONFIG_SAMA5D4_WATCHDOG) += sama5d4_wdt.o
 obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o
 obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
 obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
index c6fbb2e6..b79a83b 100644
--- a/drivers/watchdog/at91sam9_wdt.h
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -22,11 +22,13 @@
 
 #define AT91_WDT_MR0x04/* Watchdog Mode 
Register */
 #defineAT91_WDT_WDV(0xfff << 0)/* 
Counter Value */
+#defineAT91_WDT_SET_WDV(x) ((x) & AT91_WDT_WDV)
 #defineAT91_WDT_WDFIEN (1 << 12)   /* 
Fault Interrupt Enable */
 #defineAT91_WDT_WDRSTEN(1 << 13)   /* 
Reset Processor */
 #defineAT91_WDT_WDRPROC(1 << 14)   /* 
Timer Restart */
 #defineAT91_WDT_WDDIS  (1 << 15)   /* 
Watchdog Disable */
 #defineAT91_WDT_WDD(0xfff << 16)   /* 
Delta Value */
+#defineAT91_WDT_SET_WDD(x) (((x) << 16) & 
AT91_WDT_WDD)
 #defineAT91_WDT_WDDBGHLT   (1 << 28)   /* 
Debug Halt */
 #defineAT91_WDT_WDIDLEHLT  (1 << 29)   /* Idle 
Halt */
 
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
new file mode 100644
index 000..a49634c
--- /dev/null
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -0,0 +1,280 @@
+/*
+ * Driver for Atmel SAMA5D4 Watchdog Timer
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *
+ * Licensed under GPLv2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "at91sam9_wdt.h"
+
+/* minimum and maximum watchdog timeout, in seconds */
+#define MIN_WDT_TIMEOUT1
+#define MAX_WDT_TIMEOUT16
+#define WDT_DEFAULT_TIMEOUTMAX_WDT_TIMEOUT
+
+#define WDT_SEC2TICKS(s)   ((s) ? (((s) << 8) - 1) : 0)
+
+struct sama5d4_wdt {
+   struct watchdog_device  wdd;
+   void __iomem*reg_base;
+   u32 config;
+};
+
+static int wdt_timeout = WDT_DEFAULT_TIMEOUT;
+static bool nowayout = WATCHDOG_NOWAYOUT;
+
+module_param(wdt_timeout, int, 0);
+MODULE_PARM_DESC(wdt_timeout,
+   "Watchdog timeout in seconds. (default = "
+   __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
+
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+   "Watchdog cannot be stopped once started (default="
+   __MODULE_

[PATCH v6 0/2] add a new driver to support SAMA5D4 watchdog timer

2015-08-06 Thread Wenyou Yang
Hello,

Because the watchdog WDT_MR register can be written more than once,
its work mechanism is different from the at91sam9260 watchdog driver.
Open the device file to enable the watchdog hardware, close to disable it,
and ping it from the user space directly to keep it alive.

Changes from v5.0
 1./ Add the commas back in after last member for structure variables,
 sama5d4_wdt_info and sama5d4_wdt_ops.

Changes from v4.0
 1./ Fix interrupt register function flags argument.
 2./ Replace the tabs after #define with spaces.

Changes from v3.0
 1./ Change the driver name to 'sama5d4_wdt' for more acceptable.
 2./ Change the prefix of function name and struct name
 from 'atmel_' to 'sama5d4_', and others.

Changes from v2.0
 1./ Use a specific driver name, at91_sama5d4_wdt.c.
 2./ Remove '-' at the end of macro name and unnecessary check.
 3./ Use alphabetic order for include files.


Wenyou Yang (2):
  drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
  Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog
driver

 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 +++
 drivers/watchdog/Kconfig   |9 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/at91sam9_wdt.h|2 +
 drivers/watchdog/sama5d4_wdt.c |  280 
 5 files changed, 327 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
 create mode 100644 drivers/watchdog/sama5d4_wdt.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer

2015-08-06 Thread Wenyou Yang
>From SAMA5D4, the watchdog timer is upgrated with a new feature,
which is describled as in the datasheet, "WDT_MR can be written
until a LOCKMR command is issued in WDT_CR".
That is to say, as long as the bootstrap and u-boot don't issue
a LOCKMR command, WDT_MR can be written more than once in the driver.

So the SAMA5D4 watchdog driver's implementation is different from
the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c.
The user application open the device file to enable the watchdog timer
hardware, and close to disable it, and set the watchdog timer timeout
by seting WDV and WDD fields of WDT_MR register, and ping the watchdog
by issuing WDRSTT command to WDT_CR register with hard-coded key.

Signed-off-by: Wenyou Yang 
---
 drivers/watchdog/Kconfig|9 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/at91sam9_wdt.h |2 +
 drivers/watchdog/sama5d4_wdt.c  |  280 +++
 4 files changed, 292 insertions(+)
 create mode 100644 drivers/watchdog/sama5d4_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e5e7c55..47ad39a 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -167,6 +167,15 @@ config AT91SAM9X_WATCHDOG
  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
  reboot your system when the timeout is reached.
 
+config SAMA5D4_WATCHDOG
+   tristate "Atmel SAMA5D4 Watchdog Timer"
+   depends on ARCH_AT91
+   select WATCHDOG_CORE
+   help
+ Atmel SAMA5D4 watchdog timer is embedded into SAMA5D4 chips.
+ Its Watchdog Timer Mode Register can be written more than once.
+ This will reboot your system when the timeout is reached.
+
 config CADENCE_WATCHDOG
tristate "Cadence Watchdog Timer"
select WATCHDOG_CORE
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 5c19294..f24b820 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
 obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
 obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
+obj-$(CONFIG_SAMA5D4_WATCHDOG) += sama5d4_wdt.o
 obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o
 obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
 obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
index c6fbb2e6..b79a83b 100644
--- a/drivers/watchdog/at91sam9_wdt.h
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -22,11 +22,13 @@
 
 #define AT91_WDT_MR0x04/* Watchdog Mode 
Register */
 #defineAT91_WDT_WDV(0xfff << 0)/* 
Counter Value */
+#defineAT91_WDT_SET_WDV(x) ((x) & AT91_WDT_WDV)
 #defineAT91_WDT_WDFIEN (1 << 12)   /* 
Fault Interrupt Enable */
 #defineAT91_WDT_WDRSTEN(1 << 13)   /* 
Reset Processor */
 #defineAT91_WDT_WDRPROC(1 << 14)   /* 
Timer Restart */
 #defineAT91_WDT_WDDIS  (1 << 15)   /* 
Watchdog Disable */
 #defineAT91_WDT_WDD(0xfff << 16)   /* 
Delta Value */
+#defineAT91_WDT_SET_WDD(x) (((x) << 16) & 
AT91_WDT_WDD)
 #defineAT91_WDT_WDDBGHLT   (1 << 28)   /* 
Debug Halt */
 #defineAT91_WDT_WDIDLEHLT  (1 << 29)   /* Idle 
Halt */
 
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
new file mode 100644
index 000..a412215
--- /dev/null
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -0,0 +1,280 @@
+/*
+ * Driver for Atmel SAMA5D4 Watchdog Timer
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *
+ * Licensed under GPLv2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "at91sam9_wdt.h"
+
+/* minimum and maximum watchdog timeout, in seconds */
+#define MIN_WDT_TIMEOUT1
+#define MAX_WDT_TIMEOUT16
+#define WDT_DEFAULT_TIMEOUTMAX_WDT_TIMEOUT
+
+#define WDT_SEC2TICKS(s)   ((s) ? (((s) << 8) - 1) : 0)
+
+struct sama5d4_wdt {
+   struct watchdog_device  wdd;
+   void __iomem*reg_base;
+   u32 config;
+};
+
+static int wdt_timeout = WDT_DEFAULT_TIMEOUT;
+static bool nowayout = WATCHDOG_NOWAYOUT;
+
+module_param(wdt_timeout, int, 0);
+MODULE_PARM_DESC(wdt_timeout,
+   "Watchdog timeout in seconds. (default = "
+   __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
+
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+   "Watchdog cannot be stopped once started (default="
+   __MODULE_

[PATCH v5 2/2] Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog driver

2015-08-06 Thread Wenyou Yang
The compatible "atmel,sama5d4-wdt" supports the SAMA5D4 watchdog driver
and the watchdog's WDT_MR register can be written more than once.

Signed-off-by: Wenyou Yang 
---
 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 
 1 file changed, 35 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
new file mode 100644
index 000..f7cc7c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
@@ -0,0 +1,35 @@
+* Atmel SAMA5D4 Watchdog Timer (WDT) Controller
+
+Required properties:
+- compatible: "atmel,sama5d4-wdt"
+- reg: base physical address and length of memory mapped region.
+
+Optional properties:
+- timeout-sec: watchdog timeout value (in seconds).
+- interrupts: interrupt number to the CPU.
+- atmel,watchdog-type: should be "hardware" or "software".
+   "hardware": enable watchdog fault reset. A watchdog fault triggers
+   watchdog reset.
+   "software": enable watchdog fault interrupt. A watchdog fault asserts
+   watchdog interrupt.
+- atmel,idle-halt: present if you want to stop the watchdog when the CPU is
+  in idle state.
+   CAUTION: This property should be used with care, it actually makes the
+   watchdog not counting when the CPU is in idle state, therefore the
+   watchdog reset time depends on mean CPU usage and will not reset at all
+   if the CPU stop working while it is in idle state, which is probably
+   not what you want.
+- atmel,dbg-halt: present if you want to stop the watchdog when the CPU is
+ in debug state.
+
+Example:
+   watchdog@fc068640 {
+   compatible = "atmel,sama5d4-wdt";
+   reg = <0xfc068640 0x10>;
+   interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>;
+   timeout-sec = <10>;
+   atmel,watchdog-type = "hardware";
+   atmel,dbg-halt;
+   atmel,idle-halt;
+   status = "okay";
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 0/2] add a new driver to support SAMA5D4 watchdog timer

2015-08-06 Thread Wenyou Yang
Hello,

Because the watchdog WDT_MR register can be written more than once,
its work mechanism is different from the at91sam9260 watchdog driver.
Open the device file to enable the watchdog hardware, close to disable it,
and ping it from the user space directly to keep it alive.

Changes from v4.0
 1./ Fix interrupt register function flags argument.
 2./ Replace the tabs after #define with spaces.

Changes from v3.0
 1./ Change the driver name to 'sama5d4_wdt' for more acceptable.
 2./ Change the prefix of function name and struct name
 from 'atmel_' to 'sama5d4_', and others.

Changes from v2.0
 1./ Use a specific driver name, at91_sama5d4_wdt.c.
 2./ Remove '-' at the end of macro name and unnecessary check.
 3./ Use alphabetic order for include files.

Wenyou Yang (2):
  drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
  Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog
driver

 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 +++
 drivers/watchdog/Kconfig   |9 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/at91sam9_wdt.h|2 +
 drivers/watchdog/sama5d4_wdt.c |  280 
 5 files changed, 327 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
 create mode 100644 drivers/watchdog/sama5d4_wdt.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer

2015-08-05 Thread Wenyou Yang
>From SAMA5D4, the watchdog timer is upgrated with a new feature,
which is describled as in the datasheet, "WDT_MR can be written
until a LOCKMR command is issued in WDT_CR".
That is to say, as long as the bootstrap and u-boot don't issue
a LOCKMR command, WDT_MR can be written more than once in the driver.

So the SAMA5D4 watchdog driver's implementation is different from
the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c.
The user application open the device file to enable the watchdog timer
hardware, and close to disable it, and set the watchdog timer timeout
by seting WDV and WDD fields of WDT_MR register, and ping the watchdog
by issuing WDRSTT command to WDT_CR register with hard-coded key.

Signed-off-by: Wenyou Yang 
---
 drivers/watchdog/Kconfig|9 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/at91sam9_wdt.h |2 +
 drivers/watchdog/sama5d4_wdt.c  |  279 +++
 4 files changed, 291 insertions(+)
 create mode 100644 drivers/watchdog/sama5d4_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e5e7c55..47ad39a 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -167,6 +167,15 @@ config AT91SAM9X_WATCHDOG
  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
  reboot your system when the timeout is reached.
 
+config SAMA5D4_WATCHDOG
+   tristate "Atmel SAMA5D4 Watchdog Timer"
+   depends on ARCH_AT91
+   select WATCHDOG_CORE
+   help
+ Atmel SAMA5D4 watchdog timer is embedded into SAMA5D4 chips.
+ Its Watchdog Timer Mode Register can be written more than once.
+ This will reboot your system when the timeout is reached.
+
 config CADENCE_WATCHDOG
tristate "Cadence Watchdog Timer"
select WATCHDOG_CORE
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 5c19294..f24b820 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
 obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
 obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
 obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
+obj-$(CONFIG_SAMA5D4_WATCHDOG) += sama5d4_wdt.o
 obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o
 obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
 obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
index c6fbb2e6..b79a83b 100644
--- a/drivers/watchdog/at91sam9_wdt.h
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -22,11 +22,13 @@
 
 #define AT91_WDT_MR0x04/* Watchdog Mode 
Register */
 #defineAT91_WDT_WDV(0xfff << 0)/* 
Counter Value */
+#defineAT91_WDT_SET_WDV(x) ((x) & AT91_WDT_WDV)
 #defineAT91_WDT_WDFIEN (1 << 12)   /* 
Fault Interrupt Enable */
 #defineAT91_WDT_WDRSTEN(1 << 13)   /* 
Reset Processor */
 #defineAT91_WDT_WDRPROC(1 << 14)   /* 
Timer Restart */
 #defineAT91_WDT_WDDIS  (1 << 15)   /* 
Watchdog Disable */
 #defineAT91_WDT_WDD(0xfff << 16)   /* 
Delta Value */
+#defineAT91_WDT_SET_WDD(x) (((x) << 16) & 
AT91_WDT_WDD)
 #defineAT91_WDT_WDDBGHLT   (1 << 28)   /* 
Debug Halt */
 #defineAT91_WDT_WDIDLEHLT  (1 << 29)   /* Idle 
Halt */
 
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
new file mode 100644
index 000..db67c7e
--- /dev/null
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -0,0 +1,279 @@
+/*
+ * Driver for Atmel SAMA5D4 Watchdog Timer
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *
+ * Licensed under GPLv2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "at91sam9_wdt.h"
+
+/* minimum and maximum watchdog timeout, in seconds */
+#defineMIN_WDT_TIMEOUT 1
+#defineMAX_WDT_TIMEOUT 16
+#defineWDT_DEFAULT_TIMEOUT MAX_WDT_TIMEOUT
+
+#defineWDT_SEC2TICKS(s)((s) ? (((s) << 8) - 1) : 0)
+
+struct sama5d4_wdt {
+   struct watchdog_device  wdd;
+   void __iomem*reg_base;
+   u32 config;
+};
+
+static int wdt_timeout = WDT_DEFAULT_TIMEOUT;
+static bool nowayout = WATCHDOG_NOWAYOUT;
+
+module_param(wdt_timeout, int, 0);
+MODULE_PARM_DESC(wdt_timeout,
+   "Watchdog timeout in seconds. (default = "
+   __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
+
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+   "Watchdog cannot be stopped once started (default="
+

[PATCH v4 2/2] Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog driver

2015-08-05 Thread Wenyou Yang
The compatible "atmel,sama5d4-wdt" supports the SAMA5D4 watchdog driver
and the watchdog's WDT_MR register can be written more than once.

Signed-off-by: Wenyou Yang 
---
 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 
 1 file changed, 35 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
new file mode 100644
index 000..f7cc7c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
@@ -0,0 +1,35 @@
+* Atmel SAMA5D4 Watchdog Timer (WDT) Controller
+
+Required properties:
+- compatible: "atmel,sama5d4-wdt"
+- reg: base physical address and length of memory mapped region.
+
+Optional properties:
+- timeout-sec: watchdog timeout value (in seconds).
+- interrupts: interrupt number to the CPU.
+- atmel,watchdog-type: should be "hardware" or "software".
+   "hardware": enable watchdog fault reset. A watchdog fault triggers
+   watchdog reset.
+   "software": enable watchdog fault interrupt. A watchdog fault asserts
+   watchdog interrupt.
+- atmel,idle-halt: present if you want to stop the watchdog when the CPU is
+  in idle state.
+   CAUTION: This property should be used with care, it actually makes the
+   watchdog not counting when the CPU is in idle state, therefore the
+   watchdog reset time depends on mean CPU usage and will not reset at all
+   if the CPU stop working while it is in idle state, which is probably
+   not what you want.
+- atmel,dbg-halt: present if you want to stop the watchdog when the CPU is
+ in debug state.
+
+Example:
+   watchdog@fc068640 {
+   compatible = "atmel,sama5d4-wdt";
+   reg = <0xfc068640 0x10>;
+   interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>;
+   timeout-sec = <10>;
+   atmel,watchdog-type = "hardware";
+   atmel,dbg-halt;
+   atmel,idle-halt;
+   status = "okay";
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/2] add a new driver to support SAMA5D4 watchdog timer

2015-08-05 Thread Wenyou Yang
Hello,

Because the watchdog WDT_MR register can be written more than once,
its work mechanism is different from the at91sam9260 watchdog driver.
Open the device file to enable the watchdog hardware, close to disable it,
and ping it from the user space directly to keep it alive.

Changes from v3.0
 1./ Change the driver name to 'sama5d4_wdt' for more acceptable.
 2./ Change the prefix of function name and struct name
 from 'atmel_' to 'sama5d4_', and others.

Changes from v2.0
 1./ Use a specific driver name, at91_sama5d4_wdt.c.
 2./ Remove '-' at the end of macro name and unnecessary check.
 3./ Use alphabetic order for include files.

Wenyou Yang (2):
  drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
  Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog
driver

 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 +++
 drivers/watchdog/Kconfig   |9 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/at91sam9_wdt.h|2 +
 drivers/watchdog/sama5d4_wdt.c |  279 
 5 files changed, 326 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
 create mode 100644 drivers/watchdog/sama5d4_wdt.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/2] Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog driver

2015-08-05 Thread Wenyou Yang
The compatible "atmel,sama5d4-wdt" supports the SAMA5D4 watchdog driver
and the watchdog's WDT_MR register can be written more than once.

Signed-off-by: Wenyou Yang 
---
 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 
 1 file changed, 35 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
new file mode 100644
index 000..f7cc7c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
@@ -0,0 +1,35 @@
+* Atmel SAMA5D4 Watchdog Timer (WDT) Controller
+
+Required properties:
+- compatible: "atmel,sama5d4-wdt"
+- reg: base physical address and length of memory mapped region.
+
+Optional properties:
+- timeout-sec: watchdog timeout value (in seconds).
+- interrupts: interrupt number to the CPU.
+- atmel,watchdog-type: should be "hardware" or "software".
+   "hardware": enable watchdog fault reset. A watchdog fault triggers
+   watchdog reset.
+   "software": enable watchdog fault interrupt. A watchdog fault asserts
+   watchdog interrupt.
+- atmel,idle-halt: present if you want to stop the watchdog when the CPU is
+  in idle state.
+   CAUTION: This property should be used with care, it actually makes the
+   watchdog not counting when the CPU is in idle state, therefore the
+   watchdog reset time depends on mean CPU usage and will not reset at all
+   if the CPU stop working while it is in idle state, which is probably
+   not what you want.
+- atmel,dbg-halt: present if you want to stop the watchdog when the CPU is
+ in debug state.
+
+Example:
+   watchdog@fc068640 {
+   compatible = "atmel,sama5d4-wdt";
+   reg = <0xfc068640 0x10>;
+   interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>;
+   timeout-sec = <10>;
+   atmel,watchdog-type = "hardware";
+   atmel,dbg-halt;
+   atmel,idle-halt;
+   status = "okay";
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer

2015-08-05 Thread Wenyou Yang
>From SAMA5D4, the watchdog timer is upgrated with a new feature,
which is describled as in the datasheet, "WDT_MR can be written
until a LOCKMR command is issued in WDT_CR".
That is to say, as long as the bootstrap and u-boot don't issue
a LOCKMR command, WDT_MR can be written more than once in the driver.

So the SAMA5D4 watchdog driver's implementation is different from
the at91sam9260 watchdog driver implemented in file at91sam9_wdt.c.
The user application open the device file to enable the watchdog timer
hardware, and close to disable it, and set the watchdog timer timeout
by seting WDV and WDD fields of WDT_MR register, and ping the watchdog
by issuing WDRSTT command to WDT_CR register with hard-coded key.

Signed-off-by: Wenyou Yang 
---
 drivers/watchdog/Kconfig|9 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/at91_sama5d4_wdt.c |  279 +++
 drivers/watchdog/at91sam9_wdt.h |2 +
 4 files changed, 291 insertions(+)
 create mode 100644 drivers/watchdog/at91_sama5d4_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e5e7c55..4ce8346 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -152,6 +152,15 @@ config ARM_SP805_WATCHDOG
  ARM Primecell SP805 Watchdog timer. This will reboot your system when
  the timeout is reached.
 
+config AT91_SAMA5D4_WATCHDOG
+   tristate "Atmel SAMA5D4 Watchdog Timer"
+   depends on ARCH_AT91
+   select WATCHDOG_CORE
+   help
+ Atmel SAMA5D4 watchdog timer is embedded into SAMA5D4 chips.
+ Its Watchdog Timer Mode Register can be written more than once.
+ This will reboot your system when the timeout is reached.
+
 config AT91RM9200_WATCHDOG
tristate "AT91RM9200 watchdog"
depends on SOC_AT91RM9200 && MFD_SYSCON
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 5c19294..c57569c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
 
 # ARM Architecture
 obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o
+obj-$(CONFIG_AT91_SAMA5D4_WATCHDOG) += at91_sama5d4_wdt.o
 obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
 obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o
 obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.o
diff --git a/drivers/watchdog/at91_sama5d4_wdt.c 
b/drivers/watchdog/at91_sama5d4_wdt.c
new file mode 100644
index 000..f2e1995
--- /dev/null
+++ b/drivers/watchdog/at91_sama5d4_wdt.c
@@ -0,0 +1,279 @@
+/*
+ * Driver for Atmel SAMA5D4 Watchdog Timer
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *
+ * Licensed under GPLv2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "at91sam9_wdt.h"
+
+/* minimum and maximum watchdog timeout, in seconds */
+#define MIN_WDT_TIMEOUT1
+#define MAX_WDT_TIMEOUT16
+#define WDT_DEFAULT_TIMEOUTMAX_WDT_TIMEOUT
+
+#define WDT_SEC2TICKS(s)   ((s) ? (((s) << 8) - 1) : 0)
+
+struct atmel_wdt {
+   struct watchdog_device  wdd;
+   void __iomem*reg_base;
+   u32 config;
+};
+
+static int wdt_timeout = WDT_DEFAULT_TIMEOUT;
+static bool nowayout = WATCHDOG_NOWAYOUT;
+
+module_param(wdt_timeout, int, 0);
+MODULE_PARM_DESC(wdt_timeout,
+   "Watchdog wdt_timeout in seconds. (default = "
+   __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
+
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+   "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+#define wdt_read(wdt, field) \
+   readl_relaxed((wdt)->reg_base + (field))
+
+#define wdt_write(wtd, field, val) \
+   writel_relaxed((val), (wdt)->reg_base + (field))
+
+static int atmel_wdt_start(struct watchdog_device *wdd)
+{
+   struct atmel_wdt *wdt = watchdog_get_drvdata(wdd);
+   u32 reg;
+
+   reg = wdt_read(wdt, AT91_WDT_MR);
+   reg &= ~AT91_WDT_WDDIS;
+   wdt_write(wdt, AT91_WDT_MR, reg);
+
+   return 0;
+}
+
+static int atmel_wdt_stop(struct watchdog_device *wdd)
+{
+   struct atmel_wdt *wdt = watchdog_get_drvdata(wdd);
+   u32 reg;
+
+   reg = wdt_read(wdt, AT91_WDT_MR);
+   reg |= AT91_WDT_WDDIS;
+   wdt_write(wdt, AT91_WDT_MR, reg);
+
+   return 0;
+}
+
+static int atmel_wdt_ping(struct watchdog_device *wdd)
+{
+   struct atmel_wdt *wdt = watchdog_get_drvdata(wdd);
+
+   wdt_write(wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
+
+   return 0;
+}
+
+static int atmel_wdt_set_timeout(struct watchdog_device *wdd,
+unsigned int timeout)
+{
+   struct atmel_wdt *wdt = watchdog_get_drvdata(wdd);
+   u32 value = WDT_SEC2TICKS(timeout);
+   u32 reg;
+
+   reg = wdt_read

[PATCH v3 0/2] add a new driver to support SAMA5D4 watchdog timer

2015-08-05 Thread Wenyou Yang
Hello,

Because the watchdog WDT_MR register can be written more than once,
its work mechanism is different from the at91sam9260 watchdog driver.
Open the device file to enable the watchdog hardware, close to disable it,
and ping it from the user space directly to keep it alive.

Thank for Guenter's review, the version 2.0 changes are listed as below.

Changes from v2.0
 1./ Use a specific driver name, at91_sama5d4_wdt.c.
 2./ Remove '-' at the end of macro name and unnecessary check.
 3./ Use alphabetic order for include files.

Wenyou Yang (2):
  drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
  Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog
driver

 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 +++
 drivers/watchdog/Kconfig   |9 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/at91_sama5d4_wdt.c|  279 
 drivers/watchdog/at91sam9_wdt.h|2 +
 5 files changed, 326 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
 create mode 100644 drivers/watchdog/at91_sama5d4_wdt.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog driver

2015-08-04 Thread Wenyou Yang
The compatible "atmel,sama5d4-wdt" supports the SAMA5D4 watchdog driver
and the watchdog's WDT_MR register can be written more than once.

Signed-off-by: Wenyou Yang 
---
 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 
 1 file changed, 35 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
new file mode 100644
index 000..f7cc7c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
@@ -0,0 +1,35 @@
+* Atmel SAMA5D4 Watchdog Timer (WDT) Controller
+
+Required properties:
+- compatible: "atmel,sama5d4-wdt"
+- reg: base physical address and length of memory mapped region.
+
+Optional properties:
+- timeout-sec: watchdog timeout value (in seconds).
+- interrupts: interrupt number to the CPU.
+- atmel,watchdog-type: should be "hardware" or "software".
+   "hardware": enable watchdog fault reset. A watchdog fault triggers
+   watchdog reset.
+   "software": enable watchdog fault interrupt. A watchdog fault asserts
+   watchdog interrupt.
+- atmel,idle-halt: present if you want to stop the watchdog when the CPU is
+  in idle state.
+   CAUTION: This property should be used with care, it actually makes the
+   watchdog not counting when the CPU is in idle state, therefore the
+   watchdog reset time depends on mean CPU usage and will not reset at all
+   if the CPU stop working while it is in idle state, which is probably
+   not what you want.
+- atmel,dbg-halt: present if you want to stop the watchdog when the CPU is
+ in debug state.
+
+Example:
+   watchdog@fc068640 {
+   compatible = "atmel,sama5d4-wdt";
+   reg = <0xfc068640 0x10>;
+   interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>;
+   timeout-sec = <10>;
+   atmel,watchdog-type = "hardware";
+   atmel,dbg-halt;
+   atmel,idle-halt;
+   status = "okay";
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] drivers: watchdog: add a driver to support SAMA5D4 watchdog timer

2015-08-04 Thread Wenyou Yang
>From SAMA5D4, the watchdog timer is upgrated with a new feature,
which is describled as in the datasheet, "WDT_MR can be written
until a LOCKMR command is issued in WDT_CR".
That is to say, as long as the bootstrap and u-boot don't issue
a LOCKMR command, WDT_MR can be written more than once in the driver.

So the SAMA5D4 watchdog driver's implementation is different from
the previous: the user application open the device file to enable
the watchdog timer hardware, and close to disable it, and set the
watchdog timer timeout by seting WDV and WDD fields of WDT_MR register,
and ping the watchdog by issuing WDRSTT command to WDT_CR register
with hard-coded key.

Signed-off-by: Wenyou Yang 
---
 drivers/watchdog/Kconfig|9 ++
 drivers/watchdog/Makefile   |1 +
 drivers/watchdog/at91sam9_wdt.h |4 +
 drivers/watchdog/atmel_wdt.c|  290 +++
 4 files changed, 304 insertions(+)
 create mode 100644 drivers/watchdog/atmel_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e5e7c55..4425813 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -152,6 +152,15 @@ config ARM_SP805_WATCHDOG
  ARM Primecell SP805 Watchdog timer. This will reboot your system when
  the timeout is reached.
 
+config ATMEL_WATCHDOG
+   tristate "Atmel SAMA5D4 Watchdog Timer"
+   depends on ARCH_AT91
+   select WATCHDOG_CORE
+   help
+ Atmel watchdog timer embedded into SAMA5D4 chips. Its Watchdog Timer
+ Mode Register(WDT_MR) can be written more than once.
+ This will reboot your system when the timeout is reached.
+
 config AT91RM9200_WATCHDOG
tristate "AT91RM9200 watchdog"
depends on SOC_AT91RM9200 && MFD_SYSCON
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 5c19294..c24a8fc 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
 
 # ARM Architecture
 obj-$(CONFIG_ARM_SP805_WATCHDOG) += sp805_wdt.o
+obj-$(CONFIG_ATMEL_WATCHDOG) += atmel_wdt.o
 obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
 obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o
 obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.o
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
index c6fbb2e6..79add4f 100644
--- a/drivers/watchdog/at91sam9_wdt.h
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -22,11 +22,15 @@
 
 #define AT91_WDT_MR0x04/* Watchdog Mode 
Register */
 #defineAT91_WDT_WDV(0xfff << 0)/* 
Counter Value */
+#defineAT91_WDT_WDV_MSK(0xfff)
+#defineAT91_WDT_WDV_(x)(((x) & 
AT91_WDT_WDV_MSK) << 0)
 #defineAT91_WDT_WDFIEN (1 << 12)   /* 
Fault Interrupt Enable */
 #defineAT91_WDT_WDRSTEN(1 << 13)   /* 
Reset Processor */
 #defineAT91_WDT_WDRPROC(1 << 14)   /* 
Timer Restart */
 #defineAT91_WDT_WDDIS  (1 << 15)   /* 
Watchdog Disable */
 #defineAT91_WDT_WDD(0xfff << 16)   /* 
Delta Value */
+#defineAT91_WDT_WDD_MSK(0xfff)
+#defineAT91_WDT_WDD_(x)(((x) & 
AT91_WDT_WDD_MSK) << 16)
 #defineAT91_WDT_WDDBGHLT   (1 << 28)   /* 
Debug Halt */
 #defineAT91_WDT_WDIDLEHLT  (1 << 29)   /* Idle 
Halt */
 
diff --git a/drivers/watchdog/atmel_wdt.c b/drivers/watchdog/atmel_wdt.c
new file mode 100644
index 000..e1cdc84
--- /dev/null
+++ b/drivers/watchdog/atmel_wdt.c
@@ -0,0 +1,290 @@
+/*
+ * Driver for Atmel SAMA5D4 Watchdog Timer
+ *
+ * Copyright (C) 2015 Atmel Corporation
+ *
+ * Licensed under GPLv2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "at91sam9_wdt.h"
+
+/* minimum and maximum watchdog timeout, in seconds */
+#define MIN_WDT_TIMEOUT1
+#define MAX_WDT_TIMEOUT16
+#define WDT_DEFAULT_TIMEOUTMAX_WDT_TIMEOUT
+
+#define WDT_MAX_WDV0xFFF
+
+#define WDT_SEC2TICKS(s)   ((s) ? (((s) << 8) - 1) : 0)
+
+struct atmel_wdt {
+   struct watchdog_device  wdd;
+   void __iomem*reg_base;
+   u32 config;
+};
+
+static int wdt_timeout = WDT_DEFAULT_TIMEOUT;
+static bool nowayout = WATCHDOG_NOWAYOUT;
+
+module_param(wdt_timeout, int, 0);
+MODULE_PARM_DESC(wdt_timeout,
+   "Watchdog wdt_timeout in seconds. (default = "
+   __MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
+
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+   "

[PATCH v2 0/2] add a new driver to support SAMA5D4 watchdog timer

2015-08-04 Thread Wenyou Yang
Hello,

Thank for Guenter's advice, add a new driver to support SAMA5D4 watchdog timer.

Because the watchdog WDT_MR register can be written more than once, its work
mechanism is different from the previous one. Open the device file to enable
the watchdog hardware, close to disable it, and ping it from the user space
directly to keep it alive.

Best Regards,
Wenyou Yang

Wenyou Yang (2):
  drivers: watchdog: add a driver to support SAMA5D4 watchdog timer
  Documentation: dt: binding: atmel-sama5d4-wdt: for SAMA5D4 watchdog
driver

 .../bindings/watchdog/atmel-sama5d4-wdt.txt|   35 +++
 drivers/watchdog/Kconfig   |9 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/at91sam9_wdt.h|4 +
 drivers/watchdog/atmel_wdt.c   |  290 
 5 files changed, 339 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
 create mode 100644 drivers/watchdog/atmel_wdt.c

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] Documentation: dt: binding: atmel-wdt: add a new compitable

2015-07-28 Thread Wenyou Yang
Add a new compatible "atmel,sama5d4-wdt" for SAMA5D4,
which suports the new feature, the WDT_MR register can be written more once.

Signed-off-by: Wenyou Yang 
---
 .../devicetree/bindings/watchdog/atmel-wdt.txt |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt
index a4d8697..060c682 100644
--- a/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt
@@ -3,7 +3,9 @@
 ** at91sam9-wdt
 
 Required properties:
-- compatible: must be "atmel,at91sam9260-wdt".
+- compatible : should be one among the following
+   (a) "atmel,at91sam9260-wdt" for AT91SAM9x and SAMA5D3 SoCs
+   (b) "atmel,sama5d4-wdt" for SAMA5D4
 - reg: physical base address of the controller and length of memory mapped
   region.
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] drivers: watchdog: at91sam9_wdt: add new feature support

2015-07-28 Thread Wenyou Yang
In the datasheet, the new feature is describled as
"WDT_MR can be written until a LOCKMR command is issued in WDT_CR".
That is to say, as long as the bootstrap and u-boot don't issue a LOCKMR
command, WDT_MR can be written in kernel.

So the driver can enable/disable the watchdog timer hardware,
set WDV(Watchdog Counter Value) and WDD(Watchdog Delta Value) fields
of WDT_MR register to set the watchdog timer timeout.

The timer is not necessary that regularly sends a keepalive ping to
the watchdog timer hardware.

It is introduced from sama5d4 SoCs.

Signed-off-by: Wenyou Yang 
---
 drivers/watchdog/at91sam9_wdt.c |  255 ---
 drivers/watchdog/at91sam9_wdt.h |4 +
 2 files changed, 190 insertions(+), 69 deletions(-)

diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 1443b3c..6b61084 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -10,9 +10,12 @@
  */
 
 /*
+ * For AT91SAM9x SoCs, the Watchdog Timer has the following constraint.
  * The Watchdog Timer Mode Register can be only written to once. If the
  * timeout need to be set from Linux, be sure that the bootstrap or the
  * bootloader doesn't write to this register.
+ * From SAMA5D4, the Watchdog Timer Mode Register can be written
+ * until a LOCKMR command is issued in WDT_CR.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -80,6 +83,11 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once 
started "
"(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
 #define to_wdt(wdd) container_of(wdd, struct at91wdt, wdd)
+
+struct at91wdt_variant {
+   bool mr_writable;
+};
+
 struct at91wdt {
struct watchdog_device wdd;
void __iomem *base;
@@ -90,6 +98,9 @@ struct at91wdt {
unsigned long heartbeat;/* WDT heartbeat in jiffies */
bool nowayout;
unsigned int irq;
+   bool use_timer;
+   bool enabled;
+   struct at91wdt_variant *drv_data;
 };
 
 /* . */
@@ -133,21 +144,67 @@ static void at91_ping(unsigned long data)
 static int at91_wdt_start(struct watchdog_device *wdd)
 {
struct at91wdt *wdt = to_wdt(wdd);
-   /* calculate when the next userspace timeout will be */
-   wdt->next_heartbeat = jiffies + wdd->timeout * HZ;
+   u32 reg;
+
+   if (wdt->drv_data->mr_writable) {
+   reg = wdt_read(wdt, AT91_WDT_MR);
+   reg &= ~AT91_WDT_WDDIS;
+   wdt_write(wdt, AT91_WDT_MR, reg);
+   } else {
+   /* calculate when the next userspace timeout will be */
+   wdt->next_heartbeat = jiffies + wdd->timeout * HZ;
+   }
+
return 0;
 }
 
 static int at91_wdt_stop(struct watchdog_device *wdd)
 {
-   /* The watchdog timer hardware can not be stopped... */
+   struct at91wdt *wdt = to_wdt(wdd);
+   u32 reg;
+
+   if (wdt->drv_data->mr_writable) {
+   reg = wdt_read(wdt, AT91_WDT_MR);
+   reg |= AT91_WDT_WDDIS;
+   wdt_write(wdt, AT91_WDT_MR, reg);
+   }
+
+   return 0;
+}
+
+static int at91_wdt_ping(struct watchdog_device *wdd)
+{
+   struct at91wdt *wdt = to_wdt(wdd);
+
+   wdt_write(wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
+
return 0;
 }
 
 static int at91_wdt_set_timeout(struct watchdog_device *wdd, unsigned int 
new_timeout)
 {
-   wdd->timeout = new_timeout;
-   return at91_wdt_start(wdd);
+   struct at91wdt *wdt = to_wdt(wdd);
+   u32 reg, timeout;
+
+   if (wdt->drv_data->mr_writable) {
+   timeout = secs_to_ticks(new_timeout);
+   if (timeout > WDT_COUNTER_MAX_TICKS)
+   return -EINVAL;
+
+   reg = wdt_read(wdt, AT91_WDT_MR);
+   reg &= ~AT91_WDT_WDV;
+   reg |= AT91_WDT_WDV_(timeout);
+   reg &= ~AT91_WDT_WDD;
+   reg |= AT91_WDT_WDD_(timeout);
+   wdt_write(wdt, AT91_WDT_MR, reg);
+
+   wdd->timeout = new_timeout;
+
+   return 0;
+   } else {
+   wdd->timeout = new_timeout;
+   return at91_wdt_start(wdd);
+   }
 }
 
 static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
@@ -161,50 +218,65 @@ static int at91_wdt_init(struct platform_device *pdev, 
struct at91wdt *wdt)
unsigned long max_heartbeat;
struct device *dev = &pdev->dev;
 
-   tmp = wdt_read(wdt, AT91_WDT_MR);
-   if ((tmp & mask) != (wdt->mr & mask)) {
-   if (tmp == WDT_MR_RESET) {
-   wdt_write(wdt, AT91_WDT_MR, wdt->mr);
-   tmp = wdt_read(wdt, AT91_WDT_MR);
+   if (wdt->drv_data->mr_writable) {
+   wdt->us

[PATCH 0/2] watchdog: at91sam9_wdt: add new feature support

2015-07-28 Thread Wenyou Yang
Hi Wim,

Atmel Watchdog Timer has a new feature from SAMA5D4, the Watchdog Timer Mode
Register can be written more than once, so the driver can enable/disable
the watchdog timer hardware and set the watchdog timer hardware timeout.

The patch set is to add new feature.

Wenyou Yang (2):
  drivers: watchdog: at91sam9_wdt: add new feature support
  Documentation: dt: binding: atmel-wdt: add a new compitable

 .../devicetree/bindings/watchdog/atmel-wdt.txt |4 +-
 drivers/watchdog/at91sam9_wdt.c|  255 ++--
 drivers/watchdog/at91sam9_wdt.h|4 +
 3 files changed, 193 insertions(+), 70 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: dts: at919260/at91sam9g20: fix SRAM device tree node

2015-03-01 Thread Wenyou Yang
Fix PM does not work on the at91sam9g20ek board
--->8---
at91_pm_sram_init: failed to find sram device!
---<8---

Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/at91sam9260.dtsi |9 +++--
 arch/arm/boot/dts/at91sam9g20.dtsi |9 +
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi 
b/arch/arm/boot/dts/at91sam9260.dtsi
index fff0ee6..d1eb27c 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -69,9 +69,14 @@
};
};
 
-   sram0: sram@002ff000 {
+   sram0: sram@0020 {
compatible = "mmio-sram";
-   reg = <0x002ff000 0x2000>;
+   reg = <0x0020 0x1000>;
+   };
+
+   sram1: sram@0030 {
+   compatible = "mmio-sram";
+   reg = <0x0030 0x1000>;
};
 
ahb {
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi 
b/arch/arm/boot/dts/at91sam9g20.dtsi
index f593016..eb9a62d 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -16,13 +16,14 @@
reg = <0x2000 0x0800>;
};
 
-   sram0: sram@002ff000 {
-   status = "disabled";
+   sram0: sram@0020 {
+   compatible = "mmio-sram";
+   reg = <0x0020 0x4000>;
};
 
-   sram1: sram@002fc000 {
+   sram1: sram@0030 {
compatible = "mmio-sram";
-   reg = <0x002fc000 0x8000>;
+   reg = <0x0030 0x4000>;
};
 
ahb {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2.0] ARM: dts: at91-sama5d3_xplained: add the regulator device node

2014-04-21 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
Hi Nicolas,

This patch is based on the branch: at91-3.16-dt
git://github.com/at91linux/linux-at91.git

Best Regards,
Wenyou Yang

Changelog:
v2.0
 1./ Remove vddana_reg's property: regulator-always-on.

 arch/arm/boot/dts/at91-sama5d3_xplained.dts |   41 +++
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts 
b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
index ce13755..8361617 100644
--- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
@@ -48,6 +48,47 @@
 
i2c1: i2c@f0018000 {
status = "okay";
+
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "okay";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"VCC_1V8";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"VCC_1V2";
+   regulator-min-microvolt 
= <120>;
+   regulator-max-microvolt 
= <120>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"VCC_3V3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG1 {
+   regulator-name = 
"FUSE_2V5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+
+   vddana_reg: LDO_REG2 {
+   regulator-name = 
"VDDANA";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   };
+   };
+   };
};
 
macb0: ethernet@f0028000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: dts: at91-sama5d3_xplained: add the regulator device node

2014-04-20 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/at91-sama5d3_xplained.dts |   42 +++
 1 file changed, 42 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts 
b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
index ce13755..57cdd83 100644
--- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
@@ -48,6 +48,48 @@
 
i2c1: i2c@f0018000 {
status = "okay";
+
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "okay";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"VCC_1V8";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"VCC_1V2";
+   regulator-min-microvolt 
= <120>;
+   regulator-max-microvolt 
= <120>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"VCC_3V3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG1 {
+   regulator-name = 
"FUSE_2V5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+
+   vddana_reg: LDO_REG2 {
+   regulator-name = 
"VDDANA";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+   };
+   };
};
 
macb0: ethernet@f0028000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] spi: atmel: adopt pinctrl support

2014-03-04 Thread Wenyou Yang
Amend the spi atmel pin controller to optionally take a pin control
handle and set the state of the pins to:

- "default" on boot, resume and before performing an spitransfer
- "sleep" on suspend()

This should make it possible to optimize energy usage for the pins
both for the suspend/resume cycle

Signed-off-by: Wenyou Yang 
---
 drivers/spi/spi-atmel.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index b0842f7..54b4436 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 
 /* SPI register offsets */
 #define SPI_CR 0x
@@ -1303,6 +1304,9 @@ static int atmel_spi_probe(struct platform_device *pdev)
struct spi_master   *master;
struct atmel_spi*as;
 
+   /* Select default pin state */
+   pinctrl_pm_select_default_state(&pdev->dev);
+
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs)
return -ENXIO;
@@ -1457,6 +1461,9 @@ static int atmel_spi_suspend(struct device *dev)
struct atmel_spi*as = spi_master_get_devdata(master);
 
clk_disable_unprepare(as->clk);
+
+   pinctrl_pm_select_sleep_state(dev);
+
return 0;
 }
 
@@ -1465,6 +1472,8 @@ static int atmel_spi_resume(struct device *dev)
struct spi_master   *master = dev_get_drvdata(dev);
struct atmel_spi*as = spi_master_get_devdata(master);
 
+   pinctrl_pm_select_default_state(dev);
+
clk_prepare_enable(as->clk);
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ARM: dts: sama5d36ek: add spi pinctrl sleep state

2014-03-04 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/sama5d36ek.dts |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d36ek.dts b/arch/arm/boot/dts/sama5d36ek.dts
index 59576c6..676d121 100644
--- a/arch/arm/boot/dts/sama5d36ek.dts
+++ b/arch/arm/boot/dts/sama5d36ek.dts
@@ -18,6 +18,8 @@
ahb {
apb {
spi0: spi@f0004000 {
+   pinctrl-names = "default", "sleep";
+   pinctrl-1 = <&pinctrl_spi0_sleep>;
status = "okay";
};
 
@@ -44,6 +46,18 @@
macb1: ethernet@f802c000 {
status = "okay";
};
+
+   pinctrl@f200 {
+   spi0 {
+   pinctrl_spi0_sleep: spi0-1 {
+   atmel,pins =
+   ;/* PD12 GPIO Output Low */
+   };
+   };
+
+   };
};
};
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] spi: atmel: adopt pinctrl support

2014-03-04 Thread Wenyou Yang
Hi Mark, 

This patch is to adopt pinctrl support to optimize energy usage for the pins
both for the suspend/resume cycle.

The patch is based on the branch: for-next
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

Best Regards,
Wenyou Yang

Wenyou Yang (2):
  spi: atmel: adopt pinctrl support
  ARM: dts: sama5d36ek: add spi pinctrl sleep state

 arch/arm/boot/dts/sama5d36ek.dts |   14 ++
 drivers/spi/spi-atmel.c  |9 +
 2 files changed, 23 insertions(+)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pinctrl: at91: add the config GPIO_OUTPUT_x

2014-03-04 Thread Wenyou Yang
In order to support the pinctrl sleep state.

Signed-off-by: Wenyou Yang 
---
Hi Linus,

The patch is based on branch: for-next
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Best Regards,
Wenyou Yang

 drivers/pinctrl/pinctrl-at91.c |   31 +++
 include/dt-bindings/pinctrl/at91.h |2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 5d24aae..fc51e59 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -62,6 +62,8 @@ static int gpio_banks;
 #define DEGLITCH   (1 << 2)
 #define PULL_DOWN  (1 << 3)
 #define DIS_SCHMIT (1 << 4)
+#define GPIO_OUTPUT_HIGH   (1 << 5)
+#define GPIO_OUTPUT_LOW(1 << 6)
 #define DEBOUNCE   (1 << 16)
 #define DEBOUNCE_VAL_SHIFT 17
 #define DEBOUNCE_VAL   (0x3fff << DEBOUNCE_VAL_SHIFT)
@@ -152,12 +154,15 @@ struct at91_pinctrl_mux_ops {
void (*set_pulldown)(void __iomem *pio, unsigned mask, bool is_on);
bool (*get_schmitt_trig)(void __iomem *pio, unsigned pin);
void (*disable_schmitt_trig)(void __iomem *pio, unsigned mask);
+   bool (*get_gpio_output)(void __iomem *pio, unsigned mask);
+   void (*set_gpio_output)(void __iomem *pio, unsigned mask, bool is_high);
/* irq */
int (*irq_type)(struct irq_data *d, unsigned type);
 };
 
 static int gpio_irq_type(struct irq_data *d, unsigned type);
 static int alt_gpio_irq_type(struct irq_data *d, unsigned type);
+static void at91_mux_gpio_enable(void __iomem *pio, unsigned mask, bool input);
 
 struct at91_pinctrl {
struct device   *dev;
@@ -472,6 +477,20 @@ static bool at91_mux_pio3_get_schmitt_trig(void __iomem 
*pio, unsigned pin)
return (__raw_readl(pio + PIO_SCHMITT) >> pin) & 0x1;
 }
 
+static bool at91_mux_pio3_get_gpio_output(void __iomem *pio, unsigned pin)
+{
+   return (__raw_readl(pio + PIO_ODSR) >> pin) & 0x1;
+}
+
+static void at91_mux_pio3_set_gpio_output(void __iomem *pio,
+   unsigned mask,
+   bool is_high)
+{
+   at91_mux_gpio_enable(pio, mask, 0);
+   writel_relaxed(mask, pio + (is_high ? PIO_SODR : PIO_CODR));
+}
+
+
 static struct at91_pinctrl_mux_ops at91rm9200_ops = {
.get_periph = at91_mux_get_periph,
.mux_A_periph   = at91_mux_set_A_periph,
@@ -495,6 +514,8 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = {
.set_pulldown   = at91_mux_pio3_set_pulldown,
.get_schmitt_trig = at91_mux_pio3_get_schmitt_trig,
.disable_schmitt_trig = at91_mux_pio3_disable_schmitt_trig,
+   .get_gpio_output = at91_mux_pio3_get_gpio_output,
+   .set_gpio_output = at91_mux_pio3_set_gpio_output,
.irq_type   = alt_gpio_irq_type,
 };
 
@@ -741,6 +762,10 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
*config |= PULL_DOWN;
if (info->ops->get_schmitt_trig && info->ops->get_schmitt_trig(pio, 
pin))
*config |= DIS_SCHMIT;
+   if (info->ops->get_gpio_output) {
+   *config |= info->ops->get_gpio_output(pio, pin) ?
+   GPIO_OUTPUT_HIGH : GPIO_OUTPUT_LOW;
+   }
 
return 0;
 }
@@ -778,6 +803,12 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev,
info->ops->set_pulldown(pio, mask, config & PULL_DOWN);
if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT)
info->ops->disable_schmitt_trig(pio, mask);
+   if (info->ops->set_gpio_output) {
+   if (config & GPIO_OUTPUT_HIGH)
+   info->ops->set_gpio_output(pio, mask, 1);
+   if (config & GPIO_OUTPUT_LOW)
+   info->ops->set_gpio_output(pio, mask, 0);
+   };
 
} /* for each config */
 
diff --git a/include/dt-bindings/pinctrl/at91.h 
b/include/dt-bindings/pinctrl/at91.h
index 0fee6ff..e799268 100644
--- a/include/dt-bindings/pinctrl/at91.h
+++ b/include/dt-bindings/pinctrl/at91.h
@@ -15,6 +15,8 @@
 #define AT91_PINCTRL_DEGLITCH  (1 << 2)
 #define AT91_PINCTRL_PULL_DOWN (1 << 3)
 #define AT91_PINCTRL_DIS_SCHMIT(1 << 4)
+#define AT91_PINCTRL_OUTPUT_HIGH   (1 << 5)
+#define AT91_PINCTRL_OUTPUT_LOW(1 << 6)
 #define AT91_PINCTRL_DEBOUNCE  (1 << 16)
 #define AT91_PINCTRL_DEBOUNCE_VAL(x)   (x << 17)
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 3/3] ARM: dts: sama5d3xcm: add the regulator device node

2013-12-23 Thread Wenyou Yang
Reviwed-by: Mark Brown 
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/sama5d3xcm.dtsi |   46 +
 1 file changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi 
b/arch/arm/boot/dts/sama5d3xcm.dtsi
index 726a0f3..3d4e5c2 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -38,6 +38,52 @@
macb0: ethernet@f0028000 {
phy-mode = "rgmii";
};
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"VCC_1V8";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"VCC_1V2";
+   regulator-min-microvolt 
= <110>;
+   regulator-max-microvolt 
= <130>;
+   
regulator-suspend-mem-microvolt = <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"VCC_3V3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG1 {
+   regulator-name = 
"VDDANA";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG2 {
+   regulator-name = 
"FUSE_2V5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+   };
+   };
+   };
};
 
nand0: nand@6000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 2/3] regulator: act8865: add device tree binding doc

2013-12-23 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 .../bindings/regulator/act8865-regulator.txt   |   60 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 61 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
new file mode 100644
index 000..bef1fbb
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -0,0 +1,60 @@
+ACT8865 regulator
+---
+
+Required properties:
+- compatible: "active-semi,act8865"
+- reg: I2C slave address
+
+Any standard regulator properties can be used to configure the single 
regulator.
+
+The valid names for regulators are:
+   DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4.
+
+Example:
+
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = "VCC_1V8";
+   regulator-min-microvolt = 
<180>;
+   regulator-max-microvolt = 
<180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = "VCC_1V2";
+   regulator-min-microvolt = 
<110>;
+   regulator-max-microvolt = 
<130>;
+   regulator-suspend-mem-microvolt 
= <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = "VCC_3V3";
+   regulator-min-microvolt = 
<330>;
+   regulator-max-microvolt = 
<330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG1 {
+   regulator-name = "VDDANA";
+   regulator-min-microvolt = 
<330>;
+   regulator-max-microvolt = 
<330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG2 {
+   regulator-name = "FUSE_2V5";
+   regulator-min-microvolt = 
<250>;
+   regulator-max-microvolt = 
<250>;
+   };
+   };
+   };
+   };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index edbb8d8..519421f 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -3,6 +3,7 @@ Device tree binding vendor prefix registry.  Keep list in 
alphabetical order.
 This isn't an exhaustive list, but you should add new prefixes to it before
 using them to avoid name-space collisions.
 
+active-semiActive-Semi International Inc
 ad Avionic Design GmbH
 adiAnalog Devices, Inc.
 aeroflexgaislerAeroflex Gaisler AB
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/3] regulator: act8865: add PMIC act8865 driver

2013-12-23 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 drivers/regulator/Kconfig |8 +
 drivers/regulator/Makefile|1 +
 drivers/regulator/act8865-regulator.c |  368 +
 include/linux/regulator/act8865.h |   53 +
 4 files changed, 430 insertions(+)
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 11ee053..dab2e3c 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -70,6 +70,14 @@ config REGULATOR_88PM8607
help
  This driver supports 88PM8607 voltage regulator chips.
 
+config REGULATOR_ACT8865
+   tristate "Active-semi act8865 voltage regulator"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ This driver controls a active-semi act8865 voltage output
+ regulator via I2C bus.
+
 config REGULATOR_AD5398
tristate "Analog Devices AD5398/AD5821 regulators"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 654bd43..979f9dd 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
 obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
+obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
 obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
new file mode 100644
index 000..db048f2
--- /dev/null
+++ b/drivers/regulator/act8865-regulator.c
@@ -0,0 +1,368 @@
+/*
+ * act8865-regulator.c - Voltage regulation for the active-semi ACT8865
+ * http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf
+ *
+ * Copyright (C) 2013 Atmel Corporation
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ACT8865 Global Register Map.
+ */
+#defineACT8865_SYS_MODE0x00
+#defineACT8865_SYS_CTRL0x01
+#defineACT8865_DCDC1_VSET1 0x20
+#defineACT8865_DCDC1_VSET2 0x21
+#defineACT8865_DCDC1_CTRL  0x22
+#defineACT8865_DCDC2_VSET1 0x30
+#defineACT8865_DCDC2_VSET2 0x31
+#defineACT8865_DCDC2_CTRL  0x32
+#defineACT8865_DCDC3_VSET1 0x40
+#defineACT8865_DCDC3_VSET2 0x41
+#defineACT8865_DCDC3_CTRL  0x42
+#defineACT8865_LDO1_VSET   0x50
+#defineACT8865_LDO1_CTRL   0x51
+#defineACT8865_LDO2_VSET   0x54
+#defineACT8865_LDO2_CTRL   0x55
+#defineACT8865_LDO3_VSET   0x60
+#defineACT8865_LDO3_CTRL   0x61
+#defineACT8865_LDO4_VSET   0x64
+#defineACT8865_LDO4_CTRL   0x65
+
+/*
+ * Field Definitions.
+ */
+#defineACT8865_ENA 0x80/* ON - [7] */
+#defineACT8865_VSEL_MASK   0x3F/* VSET - [5:0] */
+
+/*
+ * ACT8865 voltage number
+ */
+#defineACT8865_VOLTAGE_NUM 64
+
+struct act8865 {
+   struct regulator_dev *rdev[ACT8865_REG_NUM];
+   struct regmap *regmap;
+};
+
+static const struct regmap_config act8865_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+static const struct regulator_linear_range act8865_volatge_ranges[] = {
+   REGULATOR_LINEAR_RANGE(60, 0, 23, 25000),
+   REGULATOR_LINEAR_RANGE(120, 24, 47, 5),
+   REGULATOR_LINEAR_RANGE(240, 48, 63, 10),
+};
+
+static struct regulator_ops act8865_ops = {
+   .list_voltage   = regulator_list_voltage_linear_range,
+   .map_voltage= regulator_map_voltage_linear_range,
+   .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_enable = regulator_enable_regmap,
+   .set_suspend_disable= regulator_disable_regmap,
+};
+
+static const struct regula

[PATCH v5 0/3] regulator: act8865: add PMIC driver

2013-12-23 Thread Wenyou Yang
Hi Mark,

Thanks a lot.

Since there is no seperate voltage registers for the suspend operations
in the act8865, so remove this operation. 

The patch set is to add act8865 PMIC driver.

The active-semi act8865 is designed as a PMIC for Atmel sama5d3x and at91sam9 
series.
Its datasheet is available at: 
http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf.

The patches is based on the branch: for-next of git respository, 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
and [PATCH] regulator: read low power states configuration from device tree 
from Vincent Palatin
https://patchwork.kernel.org/patch/2833667/

Thanks.

Best Regards,
Wenyou Yang

v5 changelog:
 1./ Remove .set_suspend_voltage operation.

v4 changelog:
 1./ Using linear ranges with a plural, instead of table.

v3 changelog:
 1./ Add map_voltage() operation which missed.
 2./ Remove regulator_unregister statement which no need.
 3./ Remvoe memset statement.
 4./ Change the device tree regulator-name with the supply name in the 
schematic.
 5./ List all theregulator name in the binding doc.

v2 changelog:
 1./ Using regmap for register I/O instead of i2c function directly.
 2./ Using the helpers provided by the core.
 3./ Remove noisy logging.
 4./ Using the latest regulator register API.
 5./ Using module_i2c_driver helper macro replace module_init and module_exit.
 6./ Remove the vsel-state-low dt property which is not used now.


Wenyou Yang (3):
  regulator: act8865: add PMIC act8865 driver
  regulator: act8865: add device tree binding doc
  ARM: dts: sama5d3xcm: add the regulator device node

 .../bindings/regulator/act8865-regulator.txt   |   60 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 arch/arm/boot/dts/sama5d3xcm.dtsi  |   46 +++
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/act8865-regulator.c  |  368 
 include/linux/regulator/act8865.h  |   53 +++
 7 files changed, 537 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/3] ARM: dts: sama5d3xcm: add the regulator device node

2013-12-22 Thread Wenyou Yang
Reviwed-by: Mark Brown 
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/sama5d3xcm.dtsi |   46 +
 1 file changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi 
b/arch/arm/boot/dts/sama5d3xcm.dtsi
index 726a0f3..4571751 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -38,6 +38,52 @@
macb0: ethernet@f0028000 {
phy-mode = "rgmii";
};
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"VCC_1V8";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"VCC_1V2";
+   regulator-min-microvolt 
= <110>;
+   regulator-max-microvolt 
= <130>;
+   
regulator-suspend-mem-microvolt = <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"VCC_3V3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG1 {
+   regulator-name = 
"VDDANA";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG2 {
+   regulator-name = 
"FUSE_2V5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+   };
+   };
+   };
};
 
nand0: nand@6000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/3] regulator: act8865: add device tree binding doc

2013-12-22 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 .../bindings/regulator/act8865-regulator.txt   |   60 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 61 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
new file mode 100644
index 000..76964fe
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -0,0 +1,60 @@
+ACT8865 regulator
+---
+
+Required properties:
+- compatible: "active-semi,act8865"
+- reg: I2C slave address
+
+Any standard regulator properties can be used to configure the single 
regulator.
+
+The valid names for regulators are:
+   DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4.
+
+Example:
+
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = "VCC_1V8";
+   regulator-min-microvolt = 
<180>;
+   regulator-max-microvolt = 
<180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = "VCC_1V2";
+   regulator-min-microvolt = 
<110>;
+   regulator-max-microvolt = 
<130>;
+   regulator-suspend-mem-microvolt 
= <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = "VCC_3V3";
+   regulator-min-microvolt = 
<330>;
+   regulator-max-microvolt = 
<330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG1 {
+   regulator-name = "VDDANA";
+   regulator-min-microvolt = 
<330>;
+   regulator-max-microvolt = 
<330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG2 {
+   regulator-name = "FUSE_2V5";
+   regulator-min-microvolt = 
<250>;
+   regulator-max-microvolt = 
<250>;
+   };
+   };
+   };
+   };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index edbb8d8..519421f 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -3,6 +3,7 @@ Device tree binding vendor prefix registry.  Keep list in 
alphabetical order.
 This isn't an exhaustive list, but you should add new prefixes to it before
 using them to avoid name-space collisions.
 
+active-semiActive-Semi International Inc
 ad Avionic Design GmbH
 adiAnalog Devices, Inc.
 aeroflexgaislerAeroflex Gaisler AB
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/3] regulator: act8865: add PMIC act8865 driver

2013-12-22 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 drivers/regulator/Kconfig |8 +
 drivers/regulator/Makefile|1 +
 drivers/regulator/act8865-regulator.c |  379 +
 include/linux/regulator/act8865.h |   53 +
 4 files changed, 441 insertions(+)
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 11ee053..597d99c 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -70,6 +70,14 @@ config REGULATOR_88PM8607
help
  This driver supports 88PM8607 voltage regulator chips.
 
+config REGULATOR_ACT8865
+   bool "Active-semi act8865 voltage regulator"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ This driver controls a active-semi act8865 voltage output
+ regulator via I2C bus.
+
 config REGULATOR_AD5398
tristate "Analog Devices AD5398/AD5821 regulators"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 654bd43..979f9dd 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
 obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
+obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
 obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
new file mode 100644
index 000..5e5183c
--- /dev/null
+++ b/drivers/regulator/act8865-regulator.c
@@ -0,0 +1,379 @@
+/*
+ * act8865-regulator.c - Voltage regulation for the active-semi ACT8865
+ * http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf
+ *
+ * Copyright (C) 2013 Atmel Corporation
+ * Wenyou Yang 
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ACT8865 Global Register Map.
+ */
+#defineACT8865_SYS_MODE0x00
+#defineACT8865_SYS_CTRL0x01
+#defineACT8865_DCDC1_VSET1 0x20
+#defineACT8865_DCDC1_VSET2 0x21
+#defineACT8865_DCDC1_CTRL  0x22
+#defineACT8865_DCDC2_VSET1 0x30
+#defineACT8865_DCDC2_VSET2 0x31
+#defineACT8865_DCDC2_CTRL  0x32
+#defineACT8865_DCDC3_VSET1 0x40
+#defineACT8865_DCDC3_VSET2 0x41
+#defineACT8865_DCDC3_CTRL  0x42
+#defineACT8865_LDO1_VSET   0x50
+#defineACT8865_LDO1_CTRL   0x51
+#defineACT8865_LDO2_VSET   0x54
+#defineACT8865_LDO2_CTRL   0x55
+#defineACT8865_LDO3_VSET   0x60
+#defineACT8865_LDO3_CTRL   0x61
+#defineACT8865_LDO4_VSET   0x64
+#defineACT8865_LDO4_CTRL   0x65
+
+/*
+ * Field Definitions.
+ */
+#defineACT8865_ENA 0x80/* ON - [7] */
+#defineACT8865_VSEL_MASK   0x3F/* VSET - [5:0] */
+
+/*
+ * ACT8865 voltage number
+ */
+#defineACT8865_VOLTAGE_NUM 64
+
+struct act8865 {
+   struct regulator_dev *rdev[ACT8865_REG_NUM];
+   struct regmap *regmap;
+};
+
+static const struct regmap_config act8865_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+static const struct regulator_linear_range act8865_volatge_ranges[] = {
+   REGULATOR_LINEAR_RANGE(60, 0, 23, 25000),
+   REGULATOR_LINEAR_RANGE(120, 24, 47, 5),
+   REGULATOR_LINEAR_RANGE(240, 48, 63, 10),
+};
+
+static int act8865_set_suspend_voltage(struct regulator_dev *rdev, int uV)
+{
+   u32 selector;
+
+   selector = regulator_map_voltage_iterate(rdev, uV, uV);
+
+   return regulator_set_voltage_sel_regmap(rdev, selector);
+}
+
+static struct regulator_ops act8865_ops = {
+   .list_voltage   = regulator_list_voltage_linear_range,
+   .map_voltage= regulator_map_voltage_linear_range,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+   .enable = regulator_enable_regm

[PATCH v4 0/3] regulator: act8865: add PMIC driver

2013-12-22 Thread Wenyou Yang
Hi Mark,

Thanks a lot.

As your suggestion, use linear rangers with a plural.

The patch set is to add act8865 PMIC driver.

The active-semi act8865 is designed as a PMIC for Atmel sama5d3x and at91sam9 
series.
Its datasheet is available at: 
http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf.

The patches is based on the branch: for-next of git respository, 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
and [PATCH] regulator: read low power states configuration from device tree 
from Vincent Palatin
https://patchwork.kernel.org/patch/2833667/

Thanks.

Best Regards,
Wenyou Yang

v4 changelog:
 1./ Using linear ranges with a plural, instead of table.

v3 changelog:
 1./ Add map_voltage() operation which missed.
 2./ Remove regulator_unregister statement which no need.
 3./ Remvoe memset statement.
 4./ Change the device tree regulator-name with the supply name in the 
schematic.
 5./ List all theregulator name in the binding doc.

v2 changelog:
 1./ Using regmap for register I/O instead of i2c function directly.
 2./ Using the helpers provided by the core.
 3./ Remove noisy logging.
 4./ Using the latest regulator register API.
 5./ Using module_i2c_driver helper macro replace module_init and module_exit.
 6./ Remove the vsel-state-low dt property which is not used now.


Wenyou Yang (3):
  regulator: act8865: add PMIC act8865 driver
  regulator: act8865: add device tree binding doc
  ARM: dts: sama5d3xcm: add the regulator device node


Wenyou Yang (3):
  regulator: act8865: add PMIC act8865 driver
  regulator: act8865: add device tree binding doc
  ARM: dts: sama5d3xcm: add the regulator device node

 .../bindings/regulator/act8865-regulator.txt   |   60 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 arch/arm/boot/dts/sama5d3xcm.dtsi  |   46 +++
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/act8865-regulator.c  |  379 
 include/linux/regulator/act8865.h  |   53 +++
 7 files changed, 548 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] ARM: dts: sama5d3xcm: add the regulator device node

2013-12-17 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/sama5d3xcm.dtsi |   46 +
 1 file changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi 
b/arch/arm/boot/dts/sama5d3xcm.dtsi
index 726a0f3..4571751 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -38,6 +38,52 @@
macb0: ethernet@f0028000 {
phy-mode = "rgmii";
};
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"VCC_1V8";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"VCC_1V2";
+   regulator-min-microvolt 
= <110>;
+   regulator-max-microvolt 
= <130>;
+   
regulator-suspend-mem-microvolt = <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"VCC_3V3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG1 {
+   regulator-name = 
"VDDANA";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG2 {
+   regulator-name = 
"FUSE_2V5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+   };
+   };
+   };
};
 
nand0: nand@6000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] regulator: act8865: add PMIC act8865 driver

2013-12-17 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 drivers/regulator/Kconfig |8 +
 drivers/regulator/Makefile|1 +
 drivers/regulator/act8865-regulator.c |  381 +
 include/linux/regulator/act8865.h |   53 +
 4 files changed, 443 insertions(+)
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ce785f4..5a8ad84 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -70,6 +70,14 @@ config REGULATOR_88PM8607
help
  This driver supports 88PM8607 voltage regulator chips.
 
+config REGULATOR_ACT8865
+   bool "Active-semi act8865 voltage regulator"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ This driver controls a active-semi act8865 voltage output
+ regulator via I2C bus.
+
 config REGULATOR_AD5398
tristate "Analog Devices AD5398/AD5821 regulators"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 01c597e..3bb3a55 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
 obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
+obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
 obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
new file mode 100644
index 000..bd68b52
--- /dev/null
+++ b/drivers/regulator/act8865-regulator.c
@@ -0,0 +1,381 @@
+/*
+ * act8865-regulator.c - Voltage regulation for the active-semi ACT8865
+ * http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf
+ *
+ * Copyright (C) 2013 Atmel Corporation
+ * Wenyou Yang 
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ACT8865 Global Register Map.
+ */
+#defineACT8865_SYS_MODE0x00
+#defineACT8865_SYS_CTRL0x01
+#defineACT8865_DCDC1_VSET1 0x20
+#defineACT8865_DCDC1_VSET2 0x21
+#defineACT8865_DCDC1_CTRL  0x22
+#defineACT8865_DCDC2_VSET1 0x30
+#defineACT8865_DCDC2_VSET2 0x31
+#defineACT8865_DCDC2_CTRL  0x32
+#defineACT8865_DCDC3_VSET1 0x40
+#defineACT8865_DCDC3_VSET2 0x41
+#defineACT8865_DCDC3_CTRL  0x42
+#defineACT8865_LDO1_VSET   0x50
+#defineACT8865_LDO1_CTRL   0x51
+#defineACT8865_LDO2_VSET   0x54
+#defineACT8865_LDO2_CTRL   0x55
+#defineACT8865_LDO3_VSET   0x60
+#defineACT8865_LDO3_CTRL   0x61
+#defineACT8865_LDO4_VSET   0x64
+#defineACT8865_LDO4_CTRL   0x65
+
+/*
+ * Field Definitions.
+ */
+#defineACT8865_ENA 0x80/* ON - [7] */
+#defineACT8865_VSEL_MASK   0x3F/* VSET - [5:0] */
+
+struct act8865 {
+   struct regulator_dev *rdev[ACT8865_REG_NUM];
+   struct regmap *regmap;
+};
+
+static const struct regmap_config act8865_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+/* ACt8865 voltage table */
+static const unsigned int act8865_voltages_table[] = {
+   60, 625000, 65, 675000,
+   70, 725000, 75, 775000,
+   80, 825000, 85, 875000,
+   90, 925000, 95, 975000,
+   100,1025000,105,1075000,
+   110,1125000,115,1175000,
+   120,125,130,135,
+   140,145,150,155,
+   160,165,170,175,
+   180,185,190,195,
+   200,205,201,215,
+   220,225,230,235,
+   240,250,260,270,
+   280,290,300

[PATCH v3 2/3] regulator: act8865: add device tree binding doc

2013-12-17 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 .../bindings/regulator/act8865-regulator.txt   |   58 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 59 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
new file mode 100644
index 000..bcea8ab
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -0,0 +1,58 @@
+ACT8865 regulator
+---
+
+Required properties:
+- compatible: "active-semi,act8865"
+- reg: I2C slave address
+
+The valid names for regulators are:
+   DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4.
+
+Example:
+
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = "VCC_1V8";
+   regulator-min-microvolt = 
<180>;
+   regulator-max-microvolt = 
<180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = "VCC_1V2";
+   regulator-min-microvolt = 
<110>;
+   regulator-max-microvolt = 
<130>;
+   regulator-suspend-mem-microvolt 
= <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = "VCC_3V3";
+   regulator-min-microvolt = 
<330>;
+   regulator-max-microvolt = 
<330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG1 {
+   regulator-name = "VDDANA";
+   regulator-min-microvolt = 
<330>;
+   regulator-max-microvolt = 
<330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG2 {
+   regulator-name = "FUSE_2V5";
+   regulator-min-microvolt = 
<250>;
+   regulator-max-microvolt = 
<250>;
+   };
+   };
+   };
+   };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index edbb8d8..519421f 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -3,6 +3,7 @@ Device tree binding vendor prefix registry.  Keep list in 
alphabetical order.
 This isn't an exhaustive list, but you should add new prefixes to it before
 using them to avoid name-space collisions.
 
+active-semiActive-Semi International Inc
 ad Avionic Design GmbH
 adiAnalog Devices, Inc.
 aeroflexgaislerAeroflex Gaisler AB
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/3] regulator: act8865: add PMIC driver

2013-12-17 Thread Wenyou Yang
Hi Mark,

Thanks a lot for your direction.

According to your advice, I prepared this version.

The patch set is to add act8865 PMIC driver.

The active-semi act8865 is designed as a PMIC for Atmel sama5d3x and at91sam9 
series.
Its datasheet is available at: 
http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf.

The patches is based on the branch: for-next of git respository, 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
and [PATCH] regulator: read low power states configuration from device tree 
from Vincent Palatin
https://patchwork.kernel.org/patch/2833667/

Thanks.

Best Regards,
Wenyou Yang

v3 changelog:
 1./ Add map_voltage() operation which missed.
 2./ Remove regulator_unregister statement which no need.
 3./ Remvoe memset statement.
 4./ Change the device tree regulator-name with the supply name in the 
schematic.
 5./ List all theregulator name in the binding doc.

v2 changelog:
 1./ Using regmap for register I/O instead of i2c function directly.
 2./ Using the helpers provided by the core.
 3./ Remove noisy logging.
 4./ Using the latest regulator register API.
 5./ Using module_i2c_driver helper macro replace module_init and module_exit.
 6./ Remove the vsel-state-low dt property which is not used now.


Wenyou Yang (3):
  regulator: act8865: add PMIC act8865 driver
  regulator: act8865: add device tree binding doc
  ARM: dts: sama5d3xcm: add the regulator device node

 .../bindings/regulator/act8865-regulator.txt   |   58 +++
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 arch/arm/boot/dts/sama5d3xcm.dtsi  |   46 +++
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/act8865-regulator.c  |  381 
 include/linux/regulator/act8865.h  |   53 +++
 7 files changed, 548 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3 v2] regulator: act8865: add device tree binding doc

2013-12-16 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 .../bindings/regulator/act8865-regulator.txt   |   56 
 1 file changed, 56 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
new file mode 100644
index 000..04fc911
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -0,0 +1,56 @@
+ACT8865 regulator
+---
+
+Required properties:
+- compatible: "active-semi,act8865"
+- reg: I2C slave address
+
+Example:
+
+
+   i2c1: i2c@f0018000 {
+   status = "okay";
+
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = "DCDC_REG1";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = "DCDC_REG2";
+   regulator-min-microvolt = <110>;
+   regulator-max-microvolt = <130>;
+   regulator-suspend-mem-microvolt = 
<115>;
+   regulator-suspend-standby-microvolt = 
<115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = "DCDC_REG3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG4 {
+   regulator-name = "LDO_REG4";
+   regulator-min-microvolt = <250>;
+   regulator-max-microvolt = <250>;
+   };
+
+   vddana_reg: LDO_REG5 {
+   regulator-name = "LDO_REG5";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+   };
+   };
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3 v2] regulator: act8865: add PMIC driver

2013-12-16 Thread Wenyou Yang
Hi Mark,

Thanks a lot for quickly feedbacks. According to your advice, I prepared the 
new version.

The patch set is to add act8865 PMIC driver.

The active-semi act8865 is designed as a PMIC for Atmel sama5d3x and at91sam9 
series.
Its datasheet is available at: 
http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf.

The patches is based on the branch: for-next of git respository, 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
and [PATCH] regulator: read low power states configuration from device tree 
from Vincent Palatin
https://patchwork.kernel.org/patch/2833667/

Thanks.

Best Regards,
Wenyou Yang

v2 changelog:
 1./ Using regmap for register I/O instead of i2c function directly.
 2./ Using the helpers provided by the core.
 3./ Remove noisy logging.
 4./ Using the latest regulator register API.
 5./ Using module_i2c_driver helper macro replace module_init and module_exit.
 6./ Remove the vsel-state-low dt property which is not used now.

Wenyou Yang (3):
  regulator: act8865: add PMIC act8865 driver
  regulator: act8865: add device tree binding doc
  ARM: dts: sama5d3xcm: add the regulator device node

 .../bindings/regulator/act8865-regulator.txt   |   56 +++
 arch/arm/boot/dts/sama5d3xcm.dtsi  |   46 +++
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/act8865-regulator.c  |  381 
 include/linux/regulator/act8865.h  |   55 +++
 6 files changed, 547 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3 v2] regulator: act8865: add PMIC act8865 driver

2013-12-16 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 drivers/regulator/Kconfig |8 +
 drivers/regulator/Makefile|1 +
 drivers/regulator/act8865-regulator.c |  381 +
 include/linux/regulator/act8865.h |   55 +
 4 files changed, 445 insertions(+)
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ce785f4..5a8ad84 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -70,6 +70,14 @@ config REGULATOR_88PM8607
help
  This driver supports 88PM8607 voltage regulator chips.
 
+config REGULATOR_ACT8865
+   bool "Active-semi act8865 voltage regulator"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ This driver controls a active-semi act8865 voltage output
+ regulator via I2C bus.
+
 config REGULATOR_AD5398
tristate "Analog Devices AD5398/AD5821 regulators"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 01c597e..3bb3a55 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
 obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
+obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
 obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
new file mode 100644
index 000..64a739b
--- /dev/null
+++ b/drivers/regulator/act8865-regulator.c
@@ -0,0 +1,381 @@
+/*
+ * act8865-regulator.c - Voltage regulation for the active-semi ACT8865
+ * http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf
+ *
+ * Copyright (C) 2013 Atmel Corporation
+ * Wenyou Yang 
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ACT8865 Global Register Map.
+ */
+#defineACT8865_SYS_MODE0x00
+#define ACT8865_SYS_CTRL   0x01
+#define ACT8865_DCDC1_VSET10x20
+#defineACT8865_DCDC1_VSET2 0x21
+#defineACT8865_DCDC1_CTRL  0x22
+#defineACT8865_DCDC2_VSET1 0x30
+#defineACT8865_DCDC2_VSET2 0x31
+#defineACT8865_DCDC2_CTRL  0x32
+#defineACT8865_DCDC3_VSET1 0x40
+#defineACT8865_DCDC3_VSET2 0x41
+#defineACT8865_DCDC3_CTRL  0x42
+#defineACT8865_LDO1_VSET   0x50
+#defineACT8865_LDO1_CTRL   0x51
+#defineACT8865_LDO2_VSET   0x54
+#defineACT8865_LDO2_CTRL   0x55
+#defineACT8865_LDO3_VSET   0x60
+#defineACT8865_LDO3_CTRL   0x61
+#defineACT8865_LDO4_VSET   0x64
+#defineACT8865_LDO4_CTRL   0x65
+
+/*
+ * Field Definitions.
+ */
+#define ACT8865_ENA0x80  /* ON - [7] */
+#define ACT8865_VSEL_MASK  0x3F  /* VSET - [5:0] */
+
+struct act8865 {
+   struct regulator_dev*rdev[ACT8865_REG_NUM];
+   struct regmap   *regmap;
+};
+
+static const struct regmap_config act8865_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+};
+
+/* ACt8865 voltage table */
+static const u32 act8865_voltages_table[] = {
+   60, 625000, 65, 675000,
+   70, 725000, 75, 775000,
+   80, 825000, 85, 875000,
+   90, 925000, 95, 975000,
+   100,1025000,105,1075000,
+   110,1125000,115,1175000,
+   120,125,130,135,
+   140,145,150,155,
+   160,165,170,175,
+   180,185,190,195,
+   200,205,201,215,
+   220,225,230,235,
+   240,250,260,270,
+   280,290,300,310,
+   320

[PATCH 3/3 v2] ARM: dts: sama5d3xcm: add the regulator device node

2013-12-16 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/sama5d3xcm.dtsi |   46 +
 1 file changed, 46 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi 
b/arch/arm/boot/dts/sama5d3xcm.dtsi
index 726a0f3..634adf5 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -38,6 +38,52 @@
macb0: ethernet@f0028000 {
phy-mode = "rgmii";
};
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"DCDC_REG1";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"DCDC_REG2";
+   regulator-min-microvolt 
= <110>;
+   regulator-max-microvolt 
= <130>;
+   
regulator-suspend-mem-microvolt = <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"DCDC_REG3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG4 {
+   regulator-name = 
"LDO_REG4";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG5 {
+   regulator-name = 
"LDO_REG5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+   };
+   };
+   };
};
 
nand0: nand@6000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] regulator: act8865: add PMIC driver

2013-12-11 Thread Wenyou Yang
Hi Liam and Mark,

The patch set is to add act8865 PMIC driver.

The active-semi act8865 is designed as a PMIC for Atmel sama5d3x and at91sam9 
series.
Its datasheet is available at: 
http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf.

The patches is based on the branch: for-next of git respository, 
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
and [PATCH] regulator: read low power states configuration from device tree 
from Vincent Palatin
https://patchwork.kernel.org/patch/2833667/

Thanks.

Best Regards,
Wenyou Yang

Wenyou Yang (3):
  regulator: act8865: add PMIC(Power Management IC) driver
  regulator: act8865: add device tree binding doc
  ARM: dts: sama5d3xcm: add the regulator device node

 .../bindings/regulator/act8865-regulator.txt   |   58 +++
 arch/arm/boot/dts/sama5d3xcm.dtsi  |   47 ++
 drivers/regulator/Kconfig  |7 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/act8865-regulator.c  |  516 
 include/linux/regulator/act8865.h  |   56 +++
 6 files changed, 685 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ARM: dts: sama5d3xcm: add the regulator device node

2013-12-11 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 arch/arm/boot/dts/sama5d3xcm.dtsi |   47 +
 1 file changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi 
b/arch/arm/boot/dts/sama5d3xcm.dtsi
index 726a0f3..0da005a 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -38,6 +38,53 @@
macb0: ethernet@f0028000 {
phy-mode = "rgmii";
};
+
+   i2c1: i2c@f0018000 {
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   vsel-state-low;
+   status = "disabled";
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = 
"DCDC_REG1";
+   regulator-min-microvolt 
= <180>;
+   regulator-max-microvolt 
= <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = 
"DCDC_REG2";
+   regulator-min-microvolt 
= <110>;
+   regulator-max-microvolt 
= <130>;
+   
regulator-suspend-mem-microvolt = <115>;
+   
regulator-suspend-standby-microvolt = <115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = 
"DCDC_REG3";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG4 {
+   regulator-name = 
"LDO_REG4";
+   regulator-min-microvolt 
= <330>;
+   regulator-max-microvolt 
= <330>;
+   regulator-always-on;
+   };
+
+   vddana_reg: LDO_REG5 {
+   regulator-name = 
"LDO_REG5";
+   regulator-min-microvolt 
= <250>;
+   regulator-max-microvolt 
= <250>;
+   };
+   };
+   };
+   };
};
 
nand0: nand@6000 {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] regulator: act8865: add PMIC(Power Management IC) driver

2013-12-11 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 drivers/regulator/Kconfig |7 +
 drivers/regulator/Makefile|1 +
 drivers/regulator/act8865-regulator.c |  516 +
 include/linux/regulator/act8865.h |   56 
 4 files changed, 580 insertions(+)
 create mode 100644 drivers/regulator/act8865-regulator.c
 create mode 100644 include/linux/regulator/act8865.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ce785f4..e13bcf1 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -577,5 +577,12 @@ config REGULATOR_WM8994
  This driver provides support for the voltage regulators on the
  WM8994 CODEC.
 
+config REGULATOR_ACT8865
+   tristate "Active-semi act8865 voltage regulator"
+   depends on I2C
+   help
+ This driver controls a active-semi act8865 voltage output
+ regulator via I2C bus.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 01c597e..8bc485f 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -78,6 +78,7 @@ obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
 obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
 obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
 obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
+obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
 
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/act8865-regulator.c 
b/drivers/regulator/act8865-regulator.c
new file mode 100644
index 000..d616a28
--- /dev/null
+++ b/drivers/regulator/act8865-regulator.c
@@ -0,0 +1,516 @@
+/*
+ * act8865-regulator.c - Voltage regulation for the active-semi ACT8865
+ * http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf
+ *
+ * Copyright (C) 2013 Atmel Corporation
+ * Wenyou Yang 
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ACT8865 Global Register Map
+ */
+#defineACT8865_SYS_MODE0x00
+#define ACT8865_SYS_CTRL   0x01
+#define ACT8865_REG1_VSET1 0x20
+#defineACT8865_REG1_VSET2  0x21
+#defineACT8865_REG1_CTRL   0x22
+#defineACT8865_REG2_VSET1  0x30
+#defineACT8865_REG2_VSET2  0x31
+#defineACT8865_REG2_CTRL   0x32
+#defineACT8865_REG3_VSET1  0x40
+#defineACT8865_REG3_VSET2  0x41
+#defineACT8865_REG3_CTRL   0x42
+#defineACT8865_REG4_VSET   0x50
+#defineACT8865_REG4_CTRL   0x51
+#defineACT8865_REG5_VSET   0x54
+#defineACT8865_REG5_CTRL   0x55
+#defineACT8865_REG6_VSET   0x60
+#defineACT8865_REG6_CTRL   0x61
+#defineACT8865_REG7_VSET   0x64
+#defineACT8865_REG7_CTRL   0x65
+
+struct act8865_data {
+   u8  vsel_is_low:1;
+   struct i2c_client   *client;
+   struct regulator_dev*rdev[];
+};
+
+/* ACt8865 voltage table */
+static const u32 act8865_voltages_table[] = {
+   60, 625000, 65, 675000,
+   70, 725000, 75, 775000,
+   80, 825000, 85, 875000,
+   90, 925000, 95, 975000,
+   100,1025000,105,1075000,
+   110,1125000,115,1175000,
+   120,125,130,135,
+   140,145,150,155,
+   160,165,170,175,
+   180,185,190,195,
+   200,205,201,215,
+   220,225,230,235,
+   240,250,260,270,
+   280,290,300,310,
+   320,330,340,350,
+   360,370,380,390,
+};
+
+static int act8865_read_reg(struct act8865_data *act8865, u8 reg)
+{
+   int ret = i2c_smbus_read_byte_data(act8865->client, reg);
+   if (ret > 0)
+   ret &= 0xff;
+
+   return ret;
+}
+
+static int act8865_write_reg(struct act8865_data *act8865, u8 reg, u8 value)
+{
+   return i2c_smbus_write_byte_data(act8865

[PATCH 2/3] regulator: act8865: add device tree binding doc

2013-12-11 Thread Wenyou Yang
Signed-off-by: Wenyou Yang 
---
 .../bindings/regulator/act8865-regulator.txt   |   58 
 1 file changed, 58 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/regulator/act8865-regulator.txt

diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt 
b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
new file mode 100644
index 000..e191a92
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -0,0 +1,58 @@
+ACT8865 regulator
+---
+
+Required properties:
+- compatible: "active-semi,act8865"
+- reg: I2C slave address
+- vsel-state-low: Initial state of vsel0 input is low, to select default 
output voltage.
+
+Example:
+
+
+   i2c1: i2c@f0018000 {
+   status = "okay";
+
+   pmic: act8865@5b {
+   compatible = "active-semi,act8865";
+   reg = <0x5b>;
+   vsel-state-low;
+
+   regulators {
+   vcc_1v8_reg: DCDC_REG1 {
+   regulator-name = "DCDC_REG1";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   };
+
+   vcc_1v2_reg: DCDC_REG2 {
+   regulator-name = "DCDC_REG2";
+   regulator-min-microvolt = <110>;
+   regulator-max-microvolt = <130>;
+   regulator-suspend-mem-microvolt = 
<115>;
+   regulator-suspend-standby-microvolt = 
<115>;
+   regulator-always-on;
+   };
+
+   vcc_3v3_reg: DCDC_REG3 {
+   regulator-name = "DCDC_REG3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   vddfuse_reg: LDO_REG4 {
+   regulator-name = "LDO_REG4";
+   regulator-min-microvolt = <250>;
+   regulator-max-microvolt = <250>;
+   };
+
+   vddana_reg: LDO_REG5 {
+   regulator-name = "LDO_REG5";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+   };
+   };
+   };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html