From 1c2bd5e953dfe80c28a952619cf97afcff5494aa Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 3 Nov 2023 18:19:41 +0100 Subject: [PATCH] plat-stm32mp1: scmi_server: expose IOD regulators Replaces stubs with recently introduced IO domain regulators in SCMI server. Signed-off-by: Etienne Carriere --- core/arch/arm/plat-stm32mp1/scmi_server.c | 93 ++++++----------------- 1 file changed, 24 insertions(+), 69 deletions(-) diff --git a/core/arch/arm/plat-stm32mp1/scmi_server.c b/core/arch/arm/plat-stm32mp1/scmi_server.c index 857809e774c..3e1b9178013 100644 --- a/core/arch/arm/plat-stm32mp1/scmi_server.c +++ b/core/arch/arm/plat-stm32mp1/scmi_server.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -63,8 +64,7 @@ enum voltd_device { VOLTD_PWR, VOLTD_PMIC, VOLTD_VREFBUF, - /* Stub regulator until regulator framework is merged */ - VOLTD_STUB, + VOLTD_IO, }; /* @@ -205,18 +205,16 @@ static struct stm32_scmi_rd stm32_scmi_reset_domain[] = { #define PWR_REG18_NAME_ID "1" #define PWR_USB33_NAME_ID "2" -#define STUB_SDMMC1_IO_NAME_ID "sdmmc1" -#define STUB_SDMMC2_IO_NAME_ID "sdmmc2" +#define SDMMC1_IO_NAME_ID "sdmmc1" +#define SDMMC2_IO_NAME_ID "sdmmc2" #ifdef CFG_STM32MP13 struct stm32_scmi_voltd scmi_voltage_domain[] = { VOLTD_CELL(VOLTD_SCMI_REG11, VOLTD_PWR, PWR_REG11_NAME_ID, "reg11"), VOLTD_CELL(VOLTD_SCMI_REG18, VOLTD_PWR, PWR_REG18_NAME_ID, "reg18"), VOLTD_CELL(VOLTD_SCMI_USB33, VOLTD_PWR, PWR_USB33_NAME_ID, "usb33"), - VOLTD_CELL(VOLTD_SCMI_SDMMC1_IO, VOLTD_STUB, STUB_SDMMC1_IO_NAME_ID, - "sdmmc1"), - VOLTD_CELL(VOLTD_SCMI_SDMMC2_IO, VOLTD_STUB, STUB_SDMMC2_IO_NAME_ID, - "sdmmc2"), + VOLTD_CELL(VOLTD_SCMI_SDMMC1_IO, VOLTD_IO, SDMMC1_IO_NAME_ID, "sdmmc1"), + VOLTD_CELL(VOLTD_SCMI_SDMMC2_IO, VOLTD_IO, SDMMC2_IO_NAME_ID, "sdmmc2"), VOLTD_CELL(VOLTD_SCMI_VREFBUF, VOLTD_VREFBUF, "vrefbuf", "vrefbuf"), VOLTD_CELL(VOLTD_SCMI_STPMIC1_BUCK1, VOLTD_PMIC, "buck1", "buck1"), VOLTD_CELL(VOLTD_SCMI_STPMIC1_BUCK2, VOLTD_PMIC, "buck2", "buck2"), @@ -636,33 +634,6 @@ static enum pwr_regulator pwr_scmi_to_regu_id(struct stm32_scmi_voltd *voltd) panic(); } -static long stub_get_level_uv(struct stm32_scmi_voltd *voltd) -{ - if (!strcmp(voltd->priv_id, STUB_SDMMC1_IO_NAME_ID) || - !strcmp(voltd->priv_id, STUB_SDMMC2_IO_NAME_ID)) - return 3300000; - - panic(); -} - -static int32_t stub_describe_levels(struct stm32_scmi_voltd *voltd __unused, - size_t start_index, long *microvolt, - size_t *nb_elts) -{ - if (start_index) - return SCMI_INVALID_PARAMETERS; - - if (!microvolt || !*nb_elts) { - *nb_elts = 1; - return SCMI_SUCCESS; - } - - microvolt[0] = stub_get_level_uv(voltd); - *nb_elts = 1; - - return SCMI_SUCCESS; -} - int32_t plat_scmi_voltd_levels_array(unsigned int channel_id, unsigned int scmi_id, size_t start_index, long *levels, size_t *nb_elts) @@ -724,13 +695,7 @@ int32_t plat_scmi_voltd_levels_array(unsigned int channel_id, return SCMI_SUCCESS; } - switch (voltd->priv_dev) { - case VOLTD_STUB: - return stub_describe_levels(voltd, start_index, levels, - nb_elts); - default: - return SCMI_DENIED; - } + return SCMI_DENIED; } int32_t plat_scmi_voltd_levels_by_step(unsigned int channel_id, @@ -802,13 +767,7 @@ int32_t plat_scmi_voltd_get_level(unsigned int channel_id, unsigned int scmi_id, return SCMI_SUCCESS; } - switch (voltd->priv_dev) { - case VOLTD_STUB: - *level_uv = stub_get_level_uv(voltd); - return SCMI_SUCCESS; - default: - return SCMI_DENIED; - } + return SCMI_DENIED; } int32_t plat_scmi_voltd_set_level(unsigned int channel_id, unsigned int scmi_id, @@ -832,12 +791,7 @@ int32_t plat_scmi_voltd_set_level(unsigned int channel_id, unsigned int scmi_id, return SCMI_SUCCESS; } - switch (voltd->priv_dev) { - case VOLTD_STUB: - return SCMI_SUCCESS; - default: - return SCMI_DENIED; - } + return SCMI_DENIED; } int32_t plat_scmi_voltd_get_config(unsigned int channel_id, @@ -857,13 +811,7 @@ int32_t plat_scmi_voltd_get_config(unsigned int channel_id, return SCMI_SUCCESS; } - switch (voltd->priv_dev) { - case VOLTD_STUB: - *config = SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_ON; - return SCMI_SUCCESS; - default: - return SCMI_DENIED; - } + return SCMI_DENIED; } int32_t plat_scmi_voltd_set_config(unsigned int channel_id, @@ -897,17 +845,13 @@ int32_t plat_scmi_voltd_set_config(unsigned int channel_id, return SCMI_SUCCESS; } - switch (voltd->priv_dev) { - case VOLTD_STUB: - return SCMI_SUCCESS; - default: - return SCMI_DENIED; - } + return SCMI_DENIED; } static void get_voltd_regulator(struct stm32_scmi_voltd *voltd) { enum pwr_regulator regu_id = PWR_REGU_COUNT; + enum iod_regulator_id __maybe_unused iod_regu_id = IOD_REGU_COUNT; switch (voltd->priv_dev) { case VOLTD_PWR: @@ -920,8 +864,19 @@ static void get_voltd_regulator(struct stm32_scmi_voltd *voltd) case VOLTD_VREFBUF: voltd->regulator = stm32_vrefbuf_regulator(); break; - case VOLTD_STUB: +#ifdef CFG_STM32MP13 + case VOLTD_IO: + if (!strcmp(voltd->priv_id, SDMMC1_IO_NAME_ID)) + iod_regu_id = IOD_SDMMC1; + else if (!strcmp(voltd->priv_id, SDMMC2_IO_NAME_ID)) + iod_regu_id = IOD_SDMMC2; + else + break; + + voltd->regulator = stm32mp1_iod_regulator_by_index(iod_regu_id); break; +#endif /*CFG_STM32MP13*/ + default: break; }