* [PATCH v2 0/4] Add reset support to HiFive Unmatched
@ 2021-09-24 8:42 Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 1/4] dt-bindings: power: Add da9063 PMIC device bindings Alexandre Ghiti
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2021-09-24 8:42 UTC (permalink / raw)
To: Paul Walmsley, Pragnesh Patel, Green Wan, Jaehoon Chung,
Heinrich Schuchardt, u-boot
Cc: Alexandre Ghiti
As there is no GPIO to reset the HiFive Unmatched board, we must directly
ask the da9063 PMIC for a reset: this small patchset adds the corresponding
sysreset driver and enables it for this board.
As the probing of this new device depends on a device-tree node, this
series also adds the device tree bindings documentation for the da9063
device.
Changes in v2:
- Add device tree probing as suggested by Heinrich
- Rebased onto master
Alexandre Ghiti (4):
dt-bindings: power: Add da9063 PMIC device bindings
dt-bindings: power: Add new da9063 sysreset subdevice bindings
drivers: pmic: Add sysreset driver for da9063 PMIC
riscv: Enable da9063 sysreset driver on HiFive Unmatched
arch/riscv/dts/hifive-unmatched-a00.dts | 4 ++
configs/sifive_unmatched_defconfig | 2 +
doc/device-tree-bindings/power/da9063.txt | 68 +++++++++++++++++++++++
drivers/power/pmic/da9063.c | 51 ++++++++++++++++-
include/power/da9063_pmic.h | 1 +
5 files changed, 125 insertions(+), 1 deletion(-)
create mode 100644 doc/device-tree-bindings/power/da9063.txt
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/4] dt-bindings: power: Add da9063 PMIC device bindings
2021-09-24 8:42 [PATCH v2 0/4] Add reset support to HiFive Unmatched Alexandre Ghiti
@ 2021-09-24 8:42 ` Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 2/4] dt-bindings: power: Add new da9063 sysreset subdevice bindings Alexandre Ghiti
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2021-09-24 8:42 UTC (permalink / raw)
To: Paul Walmsley, Pragnesh Patel, Green Wan, Jaehoon Chung,
Heinrich Schuchardt, u-boot
Cc: Alexandre Ghiti
This new device tree binding documentation is largely inspired by the
Linux Kernel same document, minus the unimplemented devices and properties.
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
---
doc/device-tree-bindings/power/da9063.txt | 62 +++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 doc/device-tree-bindings/power/da9063.txt
diff --git a/doc/device-tree-bindings/power/da9063.txt b/doc/device-tree-bindings/power/da9063.txt
new file mode 100644
index 0000000000..30873ca360
--- /dev/null
+++ b/doc/device-tree-bindings/power/da9063.txt
@@ -0,0 +1,62 @@
+* Dialog DA9063/DA9063L Power Management Integrated Circuit (PMIC)
+
+DA9063 consists of the following sub-devices (I2C Only):
+
+Device Supply Names Description
+------ ------------ -----------
+da9063-regulator : : LDOs & BUCKs
+
+======
+
+Required properties:
+
+- compatible : Should be "dlg,da9063" or "dlg,da9063l"
+- reg : Specifies the I2C slave address (this defaults to 0x58 but it can be
+ modified to match the chip's OTP settings).
+
+Sub-nodes:
+
+- regulators : This node defines the settings for the LDOs and BUCKs.
+ The DA9063(L) regulators are bound using their names listed below:
+
+ bcore1 : BUCK CORE1
+ bcore2 : BUCK CORE2
+ bpro : BUCK PRO
+ bmem : BUCK MEM
+ bio : BUCK IO
+ bperi : BUCK PERI
+ ldo1 : LDO_1 (DA9063 only)
+ ldo2 : LDO_2 (DA9063 only)
+ ldo3 : LDO_3
+ ldo4 : LDO_4 (DA9063 only)
+ ldo5 : LDO_5 (DA9063 only)
+ ldo6 : LDO_6 (DA9063 only)
+ ldo7 : LDO_7
+ ldo8 : LDO_8
+ ldo9 : LDO_9
+ ldo10 : LDO_10 (DA9063 only)
+ ldo11 : LDO_11
+
+Example:
+
+ pmic0: da9063@58 {
+ compatible = "dlg,da9063"
+ reg = <0x58>;
+
+ regulators {
+ DA9063_BCORE1: bcore1 {
+ regulator-name = "BCORE1";
+ regulator-min-microvolt = <300000>;
+ regulator-max-microvolt = <1570000>;
+ regulator-min-microamp = <500000>;
+ regulator-max-microamp = <2000000>;
+ regulator-boot-on;
+ };
+ DA9063_LDO11: ldo11 {
+ regulator-name = "LDO_11";
+ regulator-min-microvolt = <900000>;
+ regulator-max-microvolt = <3600000>;
+ regulator-boot-on;
+ };
+ };
+ };
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/4] dt-bindings: power: Add new da9063 sysreset subdevice bindings
2021-09-24 8:42 [PATCH v2 0/4] Add reset support to HiFive Unmatched Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 1/4] dt-bindings: power: Add da9063 PMIC device bindings Alexandre Ghiti
@ 2021-09-24 8:42 ` Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 3/4] drivers: pmic: Add sysreset driver for da9063 PMIC Alexandre Ghiti
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2021-09-24 8:42 UTC (permalink / raw)
To: Paul Walmsley, Pragnesh Patel, Green Wan, Jaehoon Chung,
Heinrich Schuchardt, u-boot
Cc: Alexandre Ghiti
The sysreset driver for the da9063 will need some new bindings: add
them now to the device documentation.
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
---
doc/device-tree-bindings/power/da9063.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/doc/device-tree-bindings/power/da9063.txt b/doc/device-tree-bindings/power/da9063.txt
index 30873ca360..29e8e44be4 100644
--- a/doc/device-tree-bindings/power/da9063.txt
+++ b/doc/device-tree-bindings/power/da9063.txt
@@ -5,6 +5,7 @@ DA9063 consists of the following sub-devices (I2C Only):
Device Supply Names Description
------ ------------ -----------
da9063-regulator : : LDOs & BUCKs
+da9063-reset : : Reset
======
@@ -37,12 +38,17 @@ Sub-nodes:
ldo10 : LDO_10 (DA9063 only)
ldo11 : LDO_11
+- reset : This node defines the reset settings controlled by the device.
+
Example:
pmic0: da9063@58 {
compatible = "dlg,da9063"
reg = <0x58>;
+ reset {
+ };
+
regulators {
DA9063_BCORE1: bcore1 {
regulator-name = "BCORE1";
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/4] drivers: pmic: Add sysreset driver for da9063 PMIC
2021-09-24 8:42 [PATCH v2 0/4] Add reset support to HiFive Unmatched Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 1/4] dt-bindings: power: Add da9063 PMIC device bindings Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 2/4] dt-bindings: power: Add new da9063 sysreset subdevice bindings Alexandre Ghiti
@ 2021-09-24 8:42 ` Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 4/4] riscv: Enable da9063 sysreset driver on HiFive Unmatched Alexandre Ghiti
2021-10-04 11:08 ` [PATCH v2 0/4] Add reset support to " Alexandre Ghiti
4 siblings, 0 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2021-09-24 8:42 UTC (permalink / raw)
To: Paul Walmsley, Pragnesh Patel, Green Wan, Jaehoon Chung,
Heinrich Schuchardt, u-boot
Cc: Alexandre Ghiti
Some da9063 chips can't use the watchdog as a restart means since the OTP
does not set the AUTOBOOT bit [1]. So we need a new reset driver that
implements a small i2c sequence that will allow to reset the boards that
have this chip.
[1] https://www.dialog-semiconductor.com/products/pmics?post_id=10052#tab-support_tab_content
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
---
drivers/power/pmic/da9063.c | 51 ++++++++++++++++++++++++++++++++++++-
include/power/da9063_pmic.h | 1 +
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pmic/da9063.c b/drivers/power/pmic/da9063.c
index 25101d18f7..eb470e4255 100644
--- a/drivers/power/pmic/da9063.c
+++ b/drivers/power/pmic/da9063.c
@@ -10,6 +10,8 @@
#include <dm.h>
#include <i2c.h>
#include <log.h>
+#include <sysreset.h>
+#include <dm/lists.h>
#include <power/pmic.h>
#include <power/regulator.h>
#include <power/da9063_pmic.h>
@@ -85,8 +87,9 @@ static int da9063_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
static int da9063_bind(struct udevice *dev)
{
- ofnode regulators_node;
+ ofnode regulators_node, reset_node;
int children;
+ int ret;
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
@@ -101,6 +104,17 @@ static int da9063_bind(struct udevice *dev)
if (!children)
debug("%s: %s - no child found\n", __func__, dev->name);
+ if (CONFIG_IS_ENABLED(SYSRESET)) {
+ reset_node = dev_read_subnode(dev, "reset");
+ if (ofnode_valid(reset_node)) {
+ ret = device_bind_driver(dev, DA9063_SYSRESET_DRIVER,
+ DA9063_SYSRESET_DRIVER, NULL);
+ if (ret)
+ pr_err("%s: %s - failed to bind sysreset driver\n",
+ __func__, dev->name);
+ }
+ }
+
/* Always return success for this device */
return 0;
}
@@ -129,3 +143,38 @@ U_BOOT_DRIVER(pmic_da9063) = {
.probe = da9063_probe,
.ops = &da9063_ops,
};
+
+static int da9063_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+ struct udevice *pmic_dev = dev->parent;
+ uint ret;
+
+ if (type != SYSRESET_WARM && type != SYSRESET_COLD)
+ return -EPROTONOSUPPORT;
+
+ ret = pmic_reg_write(pmic_dev, DA9063_REG_PAGE_CON, 0x00);
+ if (ret < 0)
+ return ret;
+
+ /* Sets the WAKE_UP bit */
+ ret = pmic_reg_write(pmic_dev, DA9063_REG_CONTROL_F, 0x04);
+ if (ret < 0)
+ return ret;
+
+ /* Powerdown! */
+ ret = pmic_reg_write(pmic_dev, DA9063_REG_CONTROL_A, 0x68);
+ if (ret < 0)
+ return ret;
+
+ return -EINPROGRESS;
+}
+
+static struct sysreset_ops da9063_sysreset_ops = {
+ .request = da9063_sysreset_request,
+};
+
+U_BOOT_DRIVER(da9063_sysreset) = {
+ .name = DA9063_SYSRESET_DRIVER,
+ .id = UCLASS_SYSRESET,
+ .ops = &da9063_sysreset_ops,
+};
diff --git a/include/power/da9063_pmic.h b/include/power/da9063_pmic.h
index 273a07ef41..1c676c242a 100644
--- a/include/power/da9063_pmic.h
+++ b/include/power/da9063_pmic.h
@@ -304,6 +304,7 @@
/* Drivers name */
#define DA9063_LDO_DRIVER "da9063_ldo"
#define DA9063_BUCK_DRIVER "da9063_buck"
+#define DA9063_SYSRESET_DRIVER "da9063_sysreset"
/* Regulator modes */
enum {
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/4] riscv: Enable da9063 sysreset driver on HiFive Unmatched
2021-09-24 8:42 [PATCH v2 0/4] Add reset support to HiFive Unmatched Alexandre Ghiti
` (2 preceding siblings ...)
2021-09-24 8:42 ` [PATCH v2 3/4] drivers: pmic: Add sysreset driver for da9063 PMIC Alexandre Ghiti
@ 2021-09-24 8:42 ` Alexandre Ghiti
2021-10-04 11:08 ` [PATCH v2 0/4] Add reset support to " Alexandre Ghiti
4 siblings, 0 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2021-09-24 8:42 UTC (permalink / raw)
To: Paul Walmsley, Pragnesh Patel, Green Wan, Jaehoon Chung,
Heinrich Schuchardt, u-boot
Cc: Alexandre Ghiti
The Unmatched board comes with the da9063 PMIC that is used to reset the
board: add this driver in its config and a corresponding entry to its
device-tree.
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
---
arch/riscv/dts/hifive-unmatched-a00.dts | 4 ++++
configs/sifive_unmatched_defconfig | 2 ++
2 files changed, 6 insertions(+)
diff --git a/arch/riscv/dts/hifive-unmatched-a00.dts b/arch/riscv/dts/hifive-unmatched-a00.dts
index b44e8c160d..9c30a5c938 100644
--- a/arch/riscv/dts/hifive-unmatched-a00.dts
+++ b/arch/riscv/dts/hifive-unmatched-a00.dts
@@ -76,6 +76,10 @@
interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
interrupt-controller;
+ reset {
+ compatible = "dlg,da9063-reset";
+ };
+
regulators {
vdd_bcore1: bcore1 {
regulator-min-microvolt = <1050000>;
diff --git a/configs/sifive_unmatched_defconfig b/configs/sifive_unmatched_defconfig
index 38b7acd536..a4bcf0fae6 100644
--- a/configs/sifive_unmatched_defconfig
+++ b/configs/sifive_unmatched_defconfig
@@ -37,3 +37,5 @@ CONFIG_DM_RESET=y
CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_XHCI_PCI=y
+CONFIG_DM_PMIC=y
+CONFIG_DM_PMIC_DA9063=y
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/4] Add reset support to HiFive Unmatched
2021-09-24 8:42 [PATCH v2 0/4] Add reset support to HiFive Unmatched Alexandre Ghiti
` (3 preceding siblings ...)
2021-09-24 8:42 ` [PATCH v2 4/4] riscv: Enable da9063 sysreset driver on HiFive Unmatched Alexandre Ghiti
@ 2021-10-04 11:08 ` Alexandre Ghiti
4 siblings, 0 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2021-10-04 11:08 UTC (permalink / raw)
To: Paul Walmsley, Pragnesh Patel, Green Wan, Jaehoon Chung,
Heinrich Schuchardt, u-boot
On Fri, Sep 24, 2021 at 10:42 AM Alexandre Ghiti
<alexandre.ghiti@canonical.com> wrote:
>
> As there is no GPIO to reset the HiFive Unmatched board, we must directly
> ask the da9063 PMIC for a reset: this small patchset adds the corresponding
> sysreset driver and enables it for this board.
>
> As the probing of this new device depends on a device-tree node, this
> series also adds the device tree bindings documentation for the da9063
> device.
>
> Changes in v2:
> - Add device tree probing as suggested by Heinrich
> - Rebased onto master
>
> Alexandre Ghiti (4):
> dt-bindings: power: Add da9063 PMIC device bindings
> dt-bindings: power: Add new da9063 sysreset subdevice bindings
> drivers: pmic: Add sysreset driver for da9063 PMIC
> riscv: Enable da9063 sysreset driver on HiFive Unmatched
>
> arch/riscv/dts/hifive-unmatched-a00.dts | 4 ++
> configs/sifive_unmatched_defconfig | 2 +
> doc/device-tree-bindings/power/da9063.txt | 68 +++++++++++++++++++++++
> drivers/power/pmic/da9063.c | 51 ++++++++++++++++-
> include/power/da9063_pmic.h | 1 +
> 5 files changed, 125 insertions(+), 1 deletion(-)
> create mode 100644 doc/device-tree-bindings/power/da9063.txt
>
> --
> 2.30.2
>
The i2c sequence proposed here should not work according to Adam in
this thread: https://patchwork.kernel.org/project/linux-riscv/patch/20210921053356.1705833-1-alexandre.ghiti@canonical.com/.
According to Adam, the sequence he proposed should be SiFive Unmatched
board-specific, as this is not something other boards could use.
I'll be back with a v3, you can drop this.
Thanks,
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-04 11:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 8:42 [PATCH v2 0/4] Add reset support to HiFive Unmatched Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 1/4] dt-bindings: power: Add da9063 PMIC device bindings Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 2/4] dt-bindings: power: Add new da9063 sysreset subdevice bindings Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 3/4] drivers: pmic: Add sysreset driver for da9063 PMIC Alexandre Ghiti
2021-09-24 8:42 ` [PATCH v2 4/4] riscv: Enable da9063 sysreset driver on HiFive Unmatched Alexandre Ghiti
2021-10-04 11:08 ` [PATCH v2 0/4] Add reset support to " Alexandre Ghiti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).