]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
rockchip: io-domain: Add support for RK3328
authorJonas Karlman <jonas@kwiboo.se>
Sun, 21 Apr 2024 20:09:03 +0000 (20:09 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Fri, 26 Apr 2024 07:47:05 +0000 (15:47 +0800)
Port the RK3328 part of the Rockchip IO-domain driver from linux.

This differs from linux version in that pmu io iodomain bit is enabled
in the write ops instead of in an init ops as in linux, this way we can
avoid keeping a full state of all supply that have been configured.

Enable by default on all RK3328 boards, skip rk3328-evb because this
target is typically also used on miscellaneous boards and boxes not
fully supported by U-Boot.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
arch/arm/mach-rockchip/rk3328/syscon_rk3328.c
configs/evb-rk3328_defconfig
drivers/misc/Kconfig
drivers/misc/rockchip-io-domain.c

index daf74a0e2d370fca68b4795541cad2d12607b5d3..d2f267e63534dd6a722d525bf81909f7908df397 100644 (file)
@@ -17,4 +17,7 @@ U_BOOT_DRIVER(rockchip_rk3328_grf) = {
        .name = "rockchip_rk3328_grf",
        .id = UCLASS_SYSCON,
        .of_match = rk3328_syscon_ids,
+#if CONFIG_IS_ENABLED(OF_REAL)
+       .bind = dm_scan_fdt_dev,
+#endif
 };
index 75a0e0f286bd23cc826c5df2fb20f9380af26161..53ad6777ec50b4156f4747fe86b0accfb86e14ac 100644 (file)
@@ -57,6 +57,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x800800
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
+# CONFIG_ROCKCHIP_IODOMAIN is not set
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_PHY_MOTORCOMM=y
index 6b06888454f41df4a715575fa457d87386d2c681..6009d55f400eb0ec485c51bb26a693b3af3a5abf 100644 (file)
@@ -104,7 +104,7 @@ config ROCKCHIP_OTP
 config ROCKCHIP_IODOMAIN
        bool "Rockchip IO-domain driver support"
        depends on DM_REGULATOR && ARCH_ROCKCHIP
-       default y if ROCKCHIP_RK3568
+       default y if ROCKCHIP_RK3328 || ROCKCHIP_RK3568
        help
          Enable support for IO-domains in Rockchip SoCs. It is necessary
          for the IO-domain setting of the SoC to match the voltage supplied
index 0ffea32ef07fda5b987e542dab155deeff46f568..04d4d07c4127e685f72d557d5ac1c89bce70f79c 100644 (file)
 #define MAX_VOLTAGE_1_8                1980000
 #define MAX_VOLTAGE_3_3                3600000
 
+#define RK3328_SOC_CON4                        0x410
+#define RK3328_SOC_CON4_VCCIO2         BIT(7)
+#define RK3328_SOC_VCCIO2_SUPPLY_NUM   1
+
 #define RK3399_PMUGRF_CON0             0x180
 #define RK3399_PMUGRF_CON0_VSEL                BIT(8)
 #define RK3399_PMUGRF_VSEL_SUPPLY_NUM  9
@@ -95,6 +99,22 @@ static int rockchip_iodomain_write(struct regmap *grf, uint offset, int idx, int
        return regmap_write(grf, offset, val);
 }
 
+static int rk3328_iodomain_write(struct regmap *grf, uint offset, int idx, int uV)
+{
+       int ret = rockchip_iodomain_write(grf, offset, idx, uV);
+
+       if (!ret && idx == RK3328_SOC_VCCIO2_SUPPLY_NUM) {
+               /*
+                * set vccio2 iodomain to also use this framework
+                * instead of a special gpio.
+                */
+               u32 val = RK3328_SOC_CON4_VCCIO2 | (RK3328_SOC_CON4_VCCIO2 << 16);
+               ret = regmap_write(grf, RK3328_SOC_CON4, val);
+       }
+
+       return ret;
+}
+
 static int rk3399_pmu_iodomain_write(struct regmap *grf, uint offset, int idx, int uV)
 {
        int ret = rockchip_iodomain_write(grf, offset, idx, uV);
@@ -111,6 +131,20 @@ static int rk3399_pmu_iodomain_write(struct regmap *grf, uint offset, int idx, i
        return ret;
 }
 
+static const struct rockchip_iodomain_soc_data soc_data_rk3328 = {
+       .grf_offset = 0x410,
+       .supply_names = {
+               "vccio1-supply",
+               "vccio2-supply",
+               "vccio3-supply",
+               "vccio4-supply",
+               "vccio5-supply",
+               "vccio6-supply",
+               "pmuio-supply",
+       },
+       .write = rk3328_iodomain_write,
+};
+
 static const struct rockchip_iodomain_soc_data soc_data_rk3399 = {
        .grf_offset = 0xe640,
        .supply_names = {
@@ -156,6 +190,10 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3568_pmu = {
 };
 
 static const struct udevice_id rockchip_iodomain_ids[] = {
+       {
+               .compatible = "rockchip,rk3328-io-voltage-domain",
+               .data = (ulong)&soc_data_rk3328,
+       },
        {
                .compatible = "rockchip,rk3399-io-voltage-domain",
                .data = (ulong)&soc_data_rk3399,