From 5204a362b8c80049e5242d92994637b3bac94d14 Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Sun, 6 Oct 2024 14:59:54 +0300 Subject: power: regulator: max9807: add regulator support Added a new regulator driver for the MAXIM MAX8907 PMIC, providing essential regulator functionalities and incorporated the necessary binding framework within the core PMIC driver. Tested-by: Ion Agorria Signed-off-by: Svyatoslav Ryhel --- include/power/max8907.h | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 include/power/max8907.h (limited to 'include') diff --git a/include/power/max8907.h b/include/power/max8907.h new file mode 100644 index 00000000000..a19b25f44c0 --- /dev/null +++ b/include/power/max8907.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright(C) 2024 Svyatoslav Ryhel + */ + +#ifndef _MAX8907_H_ +#define _MAX8907_H_ + +#define MAX8907_LDO_NUM 20 +#define MAX8907_SD_NUM 3 + +/* Drivers name */ +#define MAX8907_LDO_DRIVER "max8907_ldo" +#define MAX8907_SD_DRIVER "max8907_sd" + +/* MAX8907 register map */ +#define MAX8907_REG_SDCTL1 0x04 +#define MAX8907_REG_SDCTL2 0x07 +#define MAX8907_REG_SDCTL3 0x0A + +#define MAX8907_REG_LDOCTL16 0x10 +#define MAX8907_REG_LDOCTL17 0x14 +#define MAX8907_REG_LDOCTL1 0x18 +#define MAX8907_REG_LDOCTL2 0x1C +#define MAX8907_REG_LDOCTL3 0x20 +#define MAX8907_REG_LDOCTL4 0x24 +#define MAX8907_REG_LDOCTL5 0x28 +#define MAX8907_REG_LDOCTL6 0x2C +#define MAX8907_REG_LDOCTL7 0x30 +#define MAX8907_REG_LDOCTL8 0x34 +#define MAX8907_REG_LDOCTL9 0x38 +#define MAX8907_REG_LDOCTL10 0x3C +#define MAX8907_REG_LDOCTL11 0x40 +#define MAX8907_REG_LDOCTL12 0x44 +#define MAX8907_REG_LDOCTL13 0x48 +#define MAX8907_REG_LDOCTL14 0x4C +#define MAX8907_REG_LDOCTL15 0x50 +#define MAX8907_REG_LDOCTL19 0x5C +#define MAX8907_REG_LDOCTL18 0x72 +#define MAX8907_REG_LDOCTL20 0x9C + +/* MAX8907 configuration values */ +#define MAX8907_CTL 0 +#define MAX8907_SEQCNT 1 +#define MAX8907_VOUT 2 + +/* mask bit fields */ +#define MAX8907_MASK_LDO_SEQ 0x1C +#define MAX8907_MASK_LDO_EN 0x01 + +/* Step-Down (SD) Regulator calculations */ +#define SD1_VOLT_MAX 2225000 +#define SD1_VOLT_MIN 650000 +#define SD1_VOLT_STEP 25000 + +#define SD2_VOLT_MAX 1425000 +#define SD2_VOLT_MIN 637500 +#define SD2_VOLT_STEP 12500 + +#define SD3_VOLT_MAX 3900000 +#define SD3_VOLT_MIN 750000 +#define SD3_VOLT_STEP 50000 + +/* Low-Dropout Linear (LDO) Regulator calculations */ +#define LDO_750_VOLT_MAX 3900000 +#define LDO_750_VOLT_MIN 750000 +#define LDO_750_VOLT_STEP 50000 + +#define LDO_650_VOLT_MAX 2225000 +#define LDO_650_VOLT_MIN 650000 +#define LDO_650_VOLT_STEP 25000 + +#endif /* _MAX8907_H_ */ -- cgit v1.3.1 From 5f3588a94d219818c1b3a2dac4d063f77f48a5ef Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Sun, 6 Oct 2024 16:51:21 +0300 Subject: sysreset: implement MAX9807 sysreset functions MAX8907 PMIC has embedded poweroff function used by some device to initiane device power off. Implement it as optional sysreset driver guarded by kconfig option and system-power-controller device tree property. Tested-by: Ion Agorria Signed-off-by: Svyatoslav Ryhel --- drivers/power/pmic/max8907.c | 14 +++++++++++++- drivers/sysreset/Kconfig | 7 +++++++ drivers/sysreset/Makefile | 1 + drivers/sysreset/sysreset_max8907.c | 37 +++++++++++++++++++++++++++++++++++++ include/power/max8907.h | 4 ++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 drivers/sysreset/sysreset_max8907.c (limited to 'include') diff --git a/drivers/power/pmic/max8907.c b/drivers/power/pmic/max8907.c index 5d35957bf40..a7ef70177de 100644 --- a/drivers/power/pmic/max8907.c +++ b/drivers/power/pmic/max8907.c @@ -45,7 +45,19 @@ static int max8907_read(struct udevice *dev, uint reg, uint8_t *buff, int len) static int max8907_bind(struct udevice *dev) { ofnode regulators_node; - int children; + 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)) { diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig index 4972905482a..aa83073c96a 100644 --- a/drivers/sysreset/Kconfig +++ b/drivers/sysreset/Kconfig @@ -131,6 +131,13 @@ config SYSRESET_MAX77663 help Enable system power management functions found in MAX77663 PMIC. +config SYSRESET_MAX8907 + bool "Enable support for MAX8907 PMIC System Reset" + depends on DM_PMIC_MAX8907 + select SYSRESET_CMD_POWEROFF if CMD_POWEROFF + help + Enable system power management functions found in MAX8907 PMIC. + config SYSRESET_MICROBLAZE bool "Enable support for Microblaze soft reset" depends on MICROBLAZE diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile index ded91a4d325..f5c78b25896 100644 --- a/drivers/sysreset/Makefile +++ b/drivers/sysreset/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_SYSRESET_CV1800B) += sysreset_cv1800b.o obj-$(CONFIG_$(PHASE_)POWEROFF_GPIO) += poweroff_gpio.o obj-$(CONFIG_$(PHASE_)SYSRESET_GPIO) += sysreset_gpio.o obj-$(CONFIG_$(PHASE_)SYSRESET_MAX77663) += sysreset_max77663.o +obj-$(CONFIG_$(PHASE_)SYSRESET_MAX8907) += sysreset_max8907.o obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o diff --git a/drivers/sysreset/sysreset_max8907.c b/drivers/sysreset/sysreset_max8907.c new file mode 100644 index 00000000000..6f62af9bffe --- /dev/null +++ b/drivers/sysreset/sysreset_max8907.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright(C) 2024 Svyatoslav Ryhel + */ + +#include +#include +#include +#include +#include +#include + +static int max8907_sysreset_request(struct udevice *dev, enum sysreset_t type) +{ + switch (type) { + case SYSRESET_POWER: + case SYSRESET_POWER_OFF: + /* MAX8907: PWR_OFF > RESET_CNFG */ + pmic_clrsetbits(dev->parent, MAX8907_REG_RESET_CNFG, + MASK_POWER_OFF, MASK_POWER_OFF); + break; + default: + return -EPROTONOSUPPORT; + } + + return -EINPROGRESS; +} + +static struct sysreset_ops max8907_sysreset = { + .request = max8907_sysreset_request, +}; + +U_BOOT_DRIVER(sysreset_max8907) = { + .id = UCLASS_SYSRESET, + .name = MAX8907_RST_DRIVER, + .ops = &max8907_sysreset, +}; diff --git a/include/power/max8907.h b/include/power/max8907.h index a19b25f44c0..a6e558e582c 100644 --- a/include/power/max8907.h +++ b/include/power/max8907.h @@ -12,6 +12,7 @@ /* Drivers name */ #define MAX8907_LDO_DRIVER "max8907_ldo" #define MAX8907_SD_DRIVER "max8907_sd" +#define MAX8907_RST_DRIVER "max8907_rst" /* MAX8907 register map */ #define MAX8907_REG_SDCTL1 0x04 @@ -39,6 +40,9 @@ #define MAX8907_REG_LDOCTL18 0x72 #define MAX8907_REG_LDOCTL20 0x9C +#define MAX8907_REG_RESET_CNFG 0x0F +#define MASK_POWER_OFF BIT(6) + /* MAX8907 configuration values */ #define MAX8907_CTL 0 #define MAX8907_SEQCNT 1 -- cgit v1.3.1 From 94b395cc2db0160a079b208d9cc49485f2b943b1 Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Tue, 15 Apr 2025 11:54:55 +0300 Subject: ARM: tegra: add PRAM Kconfig option Wrap CFG_PRAM with Kconfig option. Signed-off-by: Svyatoslav Ryhel --- arch/arm/mach-tegra/Kconfig | 14 ++++++++++++++ include/configs/tegra.h | 4 ++++ 2 files changed, 18 insertions(+) (limited to 'include') diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index 4690dcb3ea6..67bd2398bfd 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig @@ -198,6 +198,20 @@ source "arch/arm/mach-tegra/tegra124/Kconfig" source "arch/arm/mach-tegra/tegra210/Kconfig" source "arch/arm/mach-tegra/tegra186/Kconfig" +config TEGRA_PRAM + select TEGRA_SUPPORT_NON_SECURE if TEGRA114 || TEGRA124 + bool "Support reservation of the protected RAM" + help + This option indicates the presence of a region of protected RAM. + +config TEGRA_PRAM_SIZE + hex "Size of pRAM region" + depends on TEGRA_PRAM + default 0x1000 + help + Size in kB of carevout which will be reserved as protected RAM starting + from the top of the RAM. + config TEGRA_SPI def_bool y depends on TEGRA20_SFLASH || TEGRA20_SLINK || TEGRA114_SPI diff --git a/include/configs/tegra.h b/include/configs/tegra.h index 77bc38930d2..5db3129fade 100644 --- a/include/configs/tegra.h +++ b/include/configs/tegra.h @@ -29,6 +29,10 @@ #include "tegra210-common.h" #endif +#ifdef CONFIG_TEGRA_PRAM + #define CFG_PRAM CONFIG_TEGRA_PRAM_SIZE +#endif + #include "tegra-common-post.h" #endif /* __CONFIG_H */ -- cgit v1.3.1 From 718740855325c3366ea95e420bf8b32f47b0aa9f Mon Sep 17 00:00:00 2001 From: Svyatoslav Ryhel Date: Tue, 15 Apr 2025 11:55:28 +0300 Subject: ARM: tegra: convert boards to use TEGRA_PRAM Switch boards that use CFG_PRAM to TEGRA_PRAM. Signed-off-by: Svyatoslav Ryhel --- board/asus/transformer-t114/Kconfig | 6 +++++- board/nvidia/tegratab/Kconfig | 6 +++++- board/xiaomi/mocha/Kconfig | 6 +++++- doc/board/asus/transformer_t114.rst | 2 +- doc/board/nvidia/tegratab.rst | 2 +- doc/board/xiaomi/mocha.rst | 2 +- include/configs/mocha.h | 19 ------------------- include/configs/tegratab.h | 19 ------------------- include/configs/transformer-t114.h | 19 ------------------- 9 files changed, 18 insertions(+), 63 deletions(-) delete mode 100644 include/configs/mocha.h delete mode 100644 include/configs/tegratab.h delete mode 100644 include/configs/transformer-t114.h (limited to 'include') diff --git a/board/asus/transformer-t114/Kconfig b/board/asus/transformer-t114/Kconfig index 2560c35846e..2d7630422de 100644 --- a/board/asus/transformer-t114/Kconfig +++ b/board/asus/transformer-t114/Kconfig @@ -7,10 +7,14 @@ config SYS_VENDOR default "asus" config SYS_CONFIG_NAME - default "transformer-t114" + default "tegra" config TEGRA_BOARD_STRING string "Default Tegra board name" default "ASUS Transformer T114" +config TEGRA_PRAM_SIZE + depends on TEGRA_PRAM + default 0x20000 + endif diff --git a/board/nvidia/tegratab/Kconfig b/board/nvidia/tegratab/Kconfig index 8bd7cfd87b8..25468bb57f5 100644 --- a/board/nvidia/tegratab/Kconfig +++ b/board/nvidia/tegratab/Kconfig @@ -7,10 +7,14 @@ config SYS_VENDOR default "nvidia" config SYS_CONFIG_NAME - default "tegratab" + default "tegra" config TEGRA_BOARD_STRING string "Default Tegra board name" default "NVIDIA TegraTab" +config TEGRA_PRAM_SIZE + depends on TEGRA_PRAM + default 0x21c00 + endif diff --git a/board/xiaomi/mocha/Kconfig b/board/xiaomi/mocha/Kconfig index bb53cc56161..3e1e076986c 100644 --- a/board/xiaomi/mocha/Kconfig +++ b/board/xiaomi/mocha/Kconfig @@ -7,10 +7,14 @@ config SYS_VENDOR default "xiaomi" config SYS_CONFIG_NAME - default "mocha" + default "tegra" config TEGRA_BOARD_STRING string "Default Tegra board name" default "Xiaomi Mocha" +config TEGRA_PRAM_SIZE + depends on TEGRA_PRAM + default 0x38400 + endif diff --git a/doc/board/asus/transformer_t114.rst b/doc/board/asus/transformer_t114.rst index 3e42b5dd9a3..29094eeeaf4 100644 --- a/doc/board/asus/transformer_t114.rst +++ b/doc/board/asus/transformer_t114.rst @@ -36,7 +36,7 @@ To build U-Boot without SPL adjust tf701t_defconfig: CONFIG_TEXT_BASE=0x80A00000 CONFIG_SKIP_LOWLEVEL_INIT=y # CONFIG_OF_BOARD_SETUP is not set - CONFIG_TEGRA_SUPPORT_NON_SECURE=y + CONFIG_TEGRA_PRAM=y After the build succeeds, you will obtain the final ``u-boot-dtb.bin`` file, ready for booting with fastboot boot or which can be further processed into diff --git a/doc/board/nvidia/tegratab.rst b/doc/board/nvidia/tegratab.rst index c6d97ce3828..65150fc7fbf 100644 --- a/doc/board/nvidia/tegratab.rst +++ b/doc/board/nvidia/tegratab.rst @@ -36,7 +36,7 @@ To build U-Boot without SPL adjust tegratab_defconfig: CONFIG_TEXT_BASE=0x80A00000 CONFIG_SKIP_LOWLEVEL_INIT=y # CONFIG_OF_BOARD_SETUP is not set - CONFIG_TEGRA_SUPPORT_NON_SECURE=y + CONFIG_TEGRA_PRAM=y After the build succeeds, you will obtain the final ``u-boot-dtb.bin`` file, ready for booting with fastboot boot or which can be further processed into diff --git a/doc/board/xiaomi/mocha.rst b/doc/board/xiaomi/mocha.rst index be3e333127b..230081e3287 100644 --- a/doc/board/xiaomi/mocha.rst +++ b/doc/board/xiaomi/mocha.rst @@ -105,7 +105,7 @@ To build U-Boot without SPL suitable for chainloading adjust mocha_defconfig: CONFIG_TEXT_BASE=0x80A00000 CONFIG_SKIP_LOWLEVEL_INIT=y # CONFIG_OF_BOARD_SETUP is not set - CONFIG_TEGRA_SUPPORT_NON_SECURE=y + CONFIG_TEGRA_PRAM=y After the build succeeds, you will obtain the final ``u-boot-dtb.bin`` file, ready for booting using vendor bootloader's fastboot or which can be diff --git a/include/configs/mocha.h b/include/configs/mocha.h deleted file mode 100644 index 7255f31baec..00000000000 --- a/include/configs/mocha.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved. - * - * Copyright (c) 2024, Svyatoslav Ryhel - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#include "tegra124-common.h" - -#ifdef CONFIG_TEGRA_SUPPORT_NON_SECURE - #define CFG_PRAM 0x38400 /* 225 MB */ -#endif - -#include "tegra-common-post.h" - -#endif /* __CONFIG_H */ diff --git a/include/configs/tegratab.h b/include/configs/tegratab.h deleted file mode 100644 index afab01ec09c..00000000000 --- a/include/configs/tegratab.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved. - * - * Copyright (c) 2023, Svyatoslav Ryhel - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#include "tegra114-common.h" - -#ifdef CONFIG_TEGRA_SUPPORT_NON_SECURE - #define CFG_PRAM 0x21c00 /* 135 MB */ -#endif - -#include "tegra-common-post.h" - -#endif /* __CONFIG_H */ diff --git a/include/configs/transformer-t114.h b/include/configs/transformer-t114.h deleted file mode 100644 index 2fbf3417691..00000000000 --- a/include/configs/transformer-t114.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2010-2013, NVIDIA CORPORATION. All rights reserved. - * - * Copyright (c) 2023, Svyatoslav Ryhel - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#include "tegra114-common.h" - -#ifdef CONFIG_TEGRA_SUPPORT_NON_SECURE - #define CFG_PRAM 0x20000 /* 128 MB */ -#endif - -#include "tegra-common-post.h" - -#endif /* __CONFIG_H */ -- cgit v1.3.1