summaryrefslogtreecommitdiff
path: root/drivers/power/pmic
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/pmic')
-rw-r--r--drivers/power/pmic/Kconfig9
-rw-r--r--drivers/power/pmic/Makefile1
-rw-r--r--drivers/power/pmic/max8907.c94
-rw-r--r--drivers/power/pmic/rk8xx.c2
4 files changed, 105 insertions, 1 deletions
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index 5a61cd45b8c..ec7ccc3a63f 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -184,6 +184,15 @@ config SPL_DM_PMIC_PFUZE100
This config enables implementation of driver-model pmic uclass features
for PMIC PFUZE100 in SPL. The driver implements read/write operations.
+config DM_PMIC_MAX8907
+ bool "Enable Driver Model for PMIC MAX8907"
+ ---help---
+ This config enables implementation of driver-model pmic uclass features
+ for PMIC MAX8907. The driver implements read/write operations.
+ This is a Power Management IC with a decent set of peripherals from which
+ 3 DC-to-DC Step-Down (SD) Regulators, 20 Low-Dropout Linear (LDO) Regulators,
+ Real-Time Clock (RTC) and more with I2C Compatible Interface.
+
config DM_PMIC_MAX77663
bool "Enable Driver Model for PMIC MAX77663"
---help---
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 2210b1a64ae..6bebffb05a6 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_$(PHASE_)DM_PMIC) += pmic-uclass.o
obj-$(CONFIG_$(PHASE_)DM_PMIC_FAN53555) += fan53555.o
obj-$(CONFIG_$(PHASE_)DM_PMIC_DA9063) += da9063.o
obj-$(CONFIG_$(PHASE_)DM_PMIC_MAX77663) += max77663.o
+obj-$(CONFIG_$(PHASE_)DM_PMIC_MAX8907) += max8907.o
obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o
obj-$(CONFIG_DM_PMIC_MAX8998) += max8998.o
obj-$(CONFIG_DM_PMIC_MC34708) += mc34708.o
diff --git a/drivers/power/pmic/max8907.c b/drivers/power/pmic/max8907.c
new file mode 100644
index 00000000000..a7ef70177de
--- /dev/null
+++ b/drivers/power/pmic/max8907.c
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright(C) 2024 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <dm.h>
+#include <dm/lists.h>
+#include <power/pmic.h>
+#include <power/max8907.h>
+
+static const struct pmic_child_info pmic_children_info[] = {
+ { .prefix = "ldo", .driver = MAX8907_LDO_DRIVER },
+ { .prefix = "sd", .driver = MAX8907_SD_DRIVER },
+ { },
+};
+
+static int max8907_write(struct udevice *dev, uint reg, const uint8_t *buff, int len)
+{
+ int ret;
+
+ ret = dm_i2c_write(dev, reg, buff, len);
+ if (ret) {
+ log_debug("%s: write error to device: %p register: %#x!\n",
+ __func__, dev, reg);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int max8907_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+ int ret;
+
+ ret = dm_i2c_read(dev, reg, buff, len);
+ if (ret) {
+ log_debug("%s: read error from device: %p register: %#x!\n",
+ __func__, dev, reg);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int max8907_bind(struct udevice *dev)
+{
+ ofnode regulators_node;
+ int children, ret;
+
+ if (IS_ENABLED(CONFIG_SYSRESET_MAX8907) &&
+ dev_read_bool(dev, "maxim,system-power-controller")) {
+ ret = device_bind_driver_to_node(dev, MAX8907_RST_DRIVER,
+ "sysreset", dev_ofnode(dev),
+ NULL);
+ if (ret) {
+ log_debug("%s: cannot bind SYSRESET (ret = %d)\n",
+ __func__, ret);
+ return ret;
+ }
+ }
+
+ regulators_node = dev_read_subnode(dev, "regulators");
+ if (!ofnode_valid(regulators_node)) {
+ log_err("%s regulators subnode not found!\n", dev->name);
+ return -ENXIO;
+ }
+
+ log_debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
+
+ children = pmic_bind_children(dev, regulators_node, pmic_children_info);
+ if (!children)
+ log_err("%s - no child found\n", dev->name);
+
+ /* Always return success for this device */
+ return 0;
+}
+
+static struct dm_pmic_ops max8907_ops = {
+ .read = max8907_read,
+ .write = max8907_write,
+};
+
+static const struct udevice_id max8907_ids[] = {
+ { .compatible = "maxim,max8907" },
+ { }
+};
+
+U_BOOT_DRIVER(pmic_max8907) = {
+ .name = "max8907_pmic",
+ .id = UCLASS_PMIC,
+ .of_match = max8907_ids,
+ .bind = max8907_bind,
+ .ops = &max8907_ops,
+};
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index a14555cf472..3bc696d4caa 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -91,7 +91,7 @@ void rk8xx_off_for_plugin(struct udevice *dev)
static struct reg_data rk806_init_reg[] = {
/* RST_FUN */
- { RK806_REG_SYS_CFG3, GENMASK(7, 6), BIT(7)},
+ { RK806_REG_SYS_CFG3, BIT(7), GENMASK(7, 6)},
};
static struct reg_data rk817_init_reg[] = {