Skip to content

Commit

Permalink
plat-stm32mp1: scmi_server: expose IOD regulators
Browse files Browse the repository at this point in the history
Replaces stubs with recently introduced IO domain regulators
in SCMI server.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
etienne-lms committed Nov 3, 2023
1 parent 152edb1 commit 1c2bd5e
Showing 1 changed file with 24 additions and 69 deletions.
93 changes: 24 additions & 69 deletions core/arch/arm/plat-stm32mp1/scmi_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <drivers/stm32_vrefbuf.h>
#include <drivers/stm32mp1_pmic.h>
#include <drivers/stm32mp1_pwr.h>
#include <drivers/stm32mp1_regulator_iod.h>
#include <drivers/stpmic1.h>
#include <drivers/stpmic1_regulator.h>
#include <drivers/stm32mp_dt_bindings.h>
Expand Down Expand Up @@ -63,8 +64,7 @@ enum voltd_device {
VOLTD_PWR,
VOLTD_PMIC,
VOLTD_VREFBUF,
/* Stub regulator until regulator framework is merged */
VOLTD_STUB,
VOLTD_IO,
};

/*
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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;
}
Expand Down

0 comments on commit 1c2bd5e

Please sign in to comment.