[PATCH v2 16/16] board: k1: enable pmic in spl
Raymond Mao
raymondmaoca at gmail.com
Tue Feb 10 16:14:59 CET 2026
From: Raymond Mao <raymond.mao at riscstar.com>
Add Spacemit P1 SoC support in SPL. And set the default voltage
for BUCKs and LDOs.
Signed-off-by: Raymond Mao <raymond.mao at riscstar.com>
Signed-off-by: Guodong Xu <guodong.xu at riscstar.com>
---
arch/riscv/dts/k1-spl.dts | 128 +++++++++++++++++++++++++++++++---
board/spacemit/k1/MAINTAINERS | 7 +-
board/spacemit/k1/spl.c | 82 +++++++++++++++++++---
configs/spacemit_k1_defconfig | 9 +++
4 files changed, 203 insertions(+), 23 deletions(-)
diff --git a/arch/riscv/dts/k1-spl.dts b/arch/riscv/dts/k1-spl.dts
index e118767e6db..6f9407aada6 100644
--- a/arch/riscv/dts/k1-spl.dts
+++ b/arch/riscv/dts/k1-spl.dts
@@ -99,17 +99,6 @@
};
};
- i2c at d401d800 { /* i2c8 */
- status = "okay";
- bootph-pre-ram;
- pmic at 41 {
- compatible = "pmic";
- reg = <0x41>;
- status = "okay";
- bootph-pre-ram;
- };
- };
-
reset-controller at d4050000 {
status = "okay";
bootph-pre-ram;
@@ -120,3 +109,120 @@
status = "okay";
bootph-pre-ram;
};
+
+&i2c8 {
+ status = "okay";
+ bootph-pre-ram;
+ pmic at 41 {
+ compatible = "spacemit,p1";
+ reg = <0x41>;
+ status = "okay";
+ bootph-pre-ram;
+
+ regulators {
+ buck1 {
+ regulator-name = "vdd_core";
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3450000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ bootph-pre-ram;
+ };
+
+ buck2 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3450000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck3_1v8: buck3 {
+ regulator-name = "vdd_1v8";
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ bootph-pre-ram;
+ };
+
+ buck4 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck5 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3450000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck6 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3450000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ aldo1 {
+ regulator-name = "vdd_1v8_mmc";
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ regulator-boot-on;
+ bootph-pre-ram;
+ };
+
+ aldo2 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ aldo3 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ aldo4 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo1 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo2 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo3 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo4 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo5 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo6 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+
+ dldo7 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ };
+ };
+ };
+};
diff --git a/board/spacemit/k1/MAINTAINERS b/board/spacemit/k1/MAINTAINERS
index bd476c32719..f550745afea 100644
--- a/board/spacemit/k1/MAINTAINERS
+++ b/board/spacemit/k1/MAINTAINERS
@@ -1,6 +1,11 @@
BananaPi F3
M: Huan Zhou <pericycle.cc@@gmail.com>
+M: Guodong Xu <guodong.xu at riscstar.com>
+L: u-boot-spacemit at groups.io
S: Maintained
F: board/spacemit/k1/
-F: configs/k1_defconfig
+F: configs/spacemit_k1_defconfig
F: doc/board/spacemit/bananapi-f3.rst
+F: drivers/i2c/k1_i2c.c
+F: drivers/power/pmic/pmic_spacemit_p1.c
+F: drivers/power/regulator/spacemit_p1_regulator.c
diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
index 95b61f5aa90..5af804f0409 100644
--- a/board/spacemit/k1/spl.c
+++ b/board/spacemit/k1/spl.c
@@ -10,11 +10,13 @@
#include <clk-uclass.h>
#include <cpu_func.h>
#include <configs/k1.h>
+#include <cpu_func.h>
#include <dm/device.h>
#include <dm/uclass.h>
#include <i2c.h>
#include <linux/delay.h>
#include <log.h>
+#include <power/regulator.h>
#include <spl.h>
#include <tlv_eeprom.h>
#include "tlv_codes.h"
@@ -146,6 +148,73 @@ void serial_early_init(void)
panic("Serial uclass init failed: %d\n", ret);
}
+static void set_vdd_core(void)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = regulator_get_by_platname("vdd_core", &dev);
+ if (ret)
+ panic("Fail to detect vdd_core (%d)\n", ret);
+ ret = regulator_set_enable(dev, true);
+ if (ret)
+ log_warning("Fail to enable vdd_core (%d)\n", ret);
+ ret = regulator_get_value(dev);
+ if (ret < 0)
+ log_warning("Fail to read vdd_core (%d)\n", ret);
+ log_info("vdd_core, value:%d\n", ret);
+}
+
+static void set_vdd_1v8(void)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = regulator_get_by_platname("vdd_1v8", &dev);
+ if (ret)
+ panic("Fail to detect vdd_1v8 (%d)\n", ret);
+ ret = regulator_set_value(dev, 1800000);
+ if (ret)
+ log_warning("Fail to set vdd_1v8 as 1800000 (%d)\n", ret);
+ ret = regulator_set_enable(dev, true);
+ if (ret)
+ log_warning("Fail to enable vdd_1v8 (%d)\n", ret);
+ ret = regulator_get_value(dev);
+ if (ret < 0)
+ log_warning("Fail to read vdd_1v8 (%d)\n", ret);
+ log_info("vdd_1v8, value:%d\n", ret);
+}
+
+static void set_vdd_mmc(void)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = regulator_get_by_platname("vdd_1v8_mmc", &dev);
+ if (ret)
+ panic("Fail to detect vdd_1v8_mmc (%d)\n", ret);
+ ret = regulator_set_enable(dev, true);
+ if (ret)
+ log_warning("Fail to enable vdd_1v8_mmc (%d)\n", ret);
+ ret = regulator_get_value(dev);
+ if (ret < 0)
+ log_warning("Fail to read vdd_1v8_mmc (%d)\n", ret);
+ log_info("vdd_1v8_mmc, value:%d\n", ret);
+}
+
+void pmic_init(void)
+{
+ struct udevice *pmic_dev;
+ int ret;
+
+ ret = uclass_get_device(UCLASS_PMIC, 0, &pmic_dev);
+ if (ret)
+ panic("Fail to detect PMIC (%d)\n", ret);
+ set_vdd_core();
+ set_vdd_1v8();
+ set_vdd_mmc();
+}
+
/* Set default value for DDR chips */
static void ddr_cfg_init(struct ddr_cfg *cfg)
{
@@ -263,6 +332,8 @@ void board_init_f(ulong dummy)
log_info("Fail to detect board:%d\n", ret);
else
log_info("Get board name:%s\n", (char *)i2c_buf);
+ pmic_init();
+
ddr_early_init();
}
@@ -271,17 +342,6 @@ u32 spl_boot_device(void)
return BOOT_DEVICE_NOR;
}
-void pmic_init(void)
-{
- struct udevice *pmic_dev = NULL;
- int ret;
-
- ret = uclass_get_device(UCLASS_PMIC, 0, &pmic_dev);
- if (ret)
- panic("Fail to detect PMIC:%d\n", ret);
-}
-
void spl_board_init(void)
{
- pmic_init();
}
diff --git a/configs/spacemit_k1_defconfig b/configs/spacemit_k1_defconfig
index 65e8143a0bd..33efd204e3a 100644
--- a/configs/spacemit_k1_defconfig
+++ b/configs/spacemit_k1_defconfig
@@ -65,3 +65,12 @@ CONFIG_SPL_I2C_EEPROM=y
CONFIG_CMD_TLV_EEPROM=y
CONFIG_SPL_CMD_TLV_EEPROM=y
CONFIG_LOG=y
+CONFIG_SPL_POWER=y
+CONFIG_DM_PMIC=y
+CONFIG_SPL_DM_PMIC=y
+CONFIG_PMIC_SPACEMIT_P1=y
+CONFIG_SPL_PMIC_SPACEMIT_P1=y
+CONFIG_DM_REGULATOR=y
+CONFIG_SPL_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_SPACEMIT_P1=y
+CONFIG_SPL_DM_REGULATOR_SPACEMIT_P1=y
--
2.25.1
More information about the U-Boot
mailing list