Commit 3f9c9784 authored by Yann Gautier's avatar Yann Gautier
Browse files

stm32mp1: make functions and macros more common



Mainly remove suffix 1 from prefix stm32mp1 in several macros and functions
that can be used in drivers shared by different platforms.

Change-Id: I2295c44f5b1edac7e80a93c0e8dfd671b36e88e7
Signed-off-by: default avatarYann Gautier <yann.gautier@st.com>
Signed-off-by: default avatarEtienne Carriere <etienne.carriere@st.com>
parent c9d75b3c
/* /*
* Copyright (C) 2018, STMicroelectronics - All Rights Reserved * Copyright (C) 2018-2019, STMicroelectronics - All Rights Reserved
* *
* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
*/ */
...@@ -777,7 +777,7 @@ static unsigned long stm32mp1_clk_get(struct stm32mp1_clk_priv *priv, int p) ...@@ -777,7 +777,7 @@ static unsigned long stm32mp1_clk_get(struct stm32mp1_clk_priv *priv, int p)
return clock; return clock;
} }
bool stm32mp1_clk_is_enabled(unsigned long id) bool stm32mp_clk_is_enabled(unsigned long id)
{ {
struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data; struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data;
const struct stm32mp1_clk_gate *gate = priv->data->gate; const struct stm32mp1_clk_gate *gate = priv->data->gate;
...@@ -791,7 +791,7 @@ bool stm32mp1_clk_is_enabled(unsigned long id) ...@@ -791,7 +791,7 @@ bool stm32mp1_clk_is_enabled(unsigned long id)
BIT(gate[i].bit)) != 0U); BIT(gate[i].bit)) != 0U);
} }
int stm32mp1_clk_enable(unsigned long id) int stm32mp_clk_enable(unsigned long id)
{ {
struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data; struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data;
const struct stm32mp1_clk_gate *gate = priv->data->gate; const struct stm32mp1_clk_gate *gate = priv->data->gate;
...@@ -810,7 +810,7 @@ int stm32mp1_clk_enable(unsigned long id) ...@@ -810,7 +810,7 @@ int stm32mp1_clk_enable(unsigned long id)
return 0; return 0;
} }
int stm32mp1_clk_disable(unsigned long id) int stm32mp_clk_disable(unsigned long id)
{ {
struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data; struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data;
const struct stm32mp1_clk_gate *gate = priv->data->gate; const struct stm32mp1_clk_gate *gate = priv->data->gate;
...@@ -831,7 +831,7 @@ int stm32mp1_clk_disable(unsigned long id) ...@@ -831,7 +831,7 @@ int stm32mp1_clk_disable(unsigned long id)
return 0; return 0;
} }
unsigned long stm32mp1_clk_get_rate(unsigned long id) unsigned long stm32mp_clk_get_rate(unsigned long id)
{ {
struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data; struct stm32mp1_clk_priv *priv = &stm32mp1_clk_priv_data;
int p = stm32mp1_clk_get_parent(priv, id); int p = stm32mp1_clk_get_parent(priv, id);
......
...@@ -639,7 +639,7 @@ static void stm32mp1_ddr3_dll_off(struct ddr_info *priv) ...@@ -639,7 +639,7 @@ static void stm32mp1_ddr3_dll_off(struct ddr_info *priv)
*/ */
/* Change Bypass Mode Frequency Range */ /* Change Bypass Mode Frequency Range */
if (stm32mp1_clk_get_rate(DDRPHYC) < 100000000U) { if (stm32mp_clk_get_rate(DDRPHYC) < 100000000U) {
mmio_clrbits_32((uintptr_t)&priv->phy->dllgcr, mmio_clrbits_32((uintptr_t)&priv->phy->dllgcr,
DDRPHYC_DLLGCR_BPS200); DDRPHYC_DLLGCR_BPS200);
} else { } else {
......
...@@ -31,7 +31,7 @@ int stm32mp1_ddr_clk_enable(struct ddr_info *priv, uint32_t mem_speed) ...@@ -31,7 +31,7 @@ int stm32mp1_ddr_clk_enable(struct ddr_info *priv, uint32_t mem_speed)
ddr_enable_clock(); ddr_enable_clock();
ddrphy_clk = stm32mp1_clk_get_rate(DDRPHYC); ddrphy_clk = stm32mp_clk_get_rate(DDRPHYC);
VERBOSE("DDR: mem_speed (%d kHz), RCC %ld kHz\n", VERBOSE("DDR: mem_speed (%d kHz), RCC %ld kHz\n",
mem_speed, ddrphy_clk / 1000U); mem_speed, ddrphy_clk / 1000U);
...@@ -65,10 +65,10 @@ static uint32_t ddr_test_data_bus(void) ...@@ -65,10 +65,10 @@ static uint32_t ddr_test_data_bus(void)
uint32_t pattern; uint32_t pattern;
for (pattern = 1U; pattern != 0U; pattern <<= 1) { for (pattern = 1U; pattern != 0U; pattern <<= 1) {
mmio_write_32(STM32MP1_DDR_BASE, pattern); mmio_write_32(STM32MP_DDR_BASE, pattern);
if (mmio_read_32(STM32MP1_DDR_BASE) != pattern) { if (mmio_read_32(STM32MP_DDR_BASE) != pattern) {
return (uint32_t)STM32MP1_DDR_BASE; return (uint32_t)STM32MP_DDR_BASE;
} }
} }
...@@ -92,44 +92,44 @@ static uint32_t ddr_test_addr_bus(void) ...@@ -92,44 +92,44 @@ static uint32_t ddr_test_addr_bus(void)
/* Write the default pattern at each of the power-of-two offsets. */ /* Write the default pattern at each of the power-of-two offsets. */
for (offset = sizeof(uint32_t); (offset & addressmask) != 0U; for (offset = sizeof(uint32_t); (offset & addressmask) != 0U;
offset <<= 1) { offset <<= 1) {
mmio_write_32(STM32MP1_DDR_BASE + (uint32_t)offset, mmio_write_32(STM32MP_DDR_BASE + (uint32_t)offset,
DDR_PATTERN); DDR_PATTERN);
} }
/* Check for address bits stuck high. */ /* Check for address bits stuck high. */
mmio_write_32(STM32MP1_DDR_BASE + (uint32_t)testoffset, mmio_write_32(STM32MP_DDR_BASE + (uint32_t)testoffset,
DDR_ANTIPATTERN); DDR_ANTIPATTERN);
for (offset = sizeof(uint32_t); (offset & addressmask) != 0U; for (offset = sizeof(uint32_t); (offset & addressmask) != 0U;
offset <<= 1) { offset <<= 1) {
if (mmio_read_32(STM32MP1_DDR_BASE + (uint32_t)offset) != if (mmio_read_32(STM32MP_DDR_BASE + (uint32_t)offset) !=
DDR_PATTERN) { DDR_PATTERN) {
return (uint32_t)(STM32MP1_DDR_BASE + offset); return (uint32_t)(STM32MP_DDR_BASE + offset);
} }
} }
mmio_write_32(STM32MP1_DDR_BASE + (uint32_t)testoffset, DDR_PATTERN); mmio_write_32(STM32MP_DDR_BASE + (uint32_t)testoffset, DDR_PATTERN);
/* Check for address bits stuck low or shorted. */ /* Check for address bits stuck low or shorted. */
for (testoffset = sizeof(uint32_t); (testoffset & addressmask) != 0U; for (testoffset = sizeof(uint32_t); (testoffset & addressmask) != 0U;
testoffset <<= 1) { testoffset <<= 1) {
mmio_write_32(STM32MP1_DDR_BASE + (uint32_t)testoffset, mmio_write_32(STM32MP_DDR_BASE + (uint32_t)testoffset,
DDR_ANTIPATTERN); DDR_ANTIPATTERN);
if (mmio_read_32(STM32MP1_DDR_BASE) != DDR_PATTERN) { if (mmio_read_32(STM32MP_DDR_BASE) != DDR_PATTERN) {
return STM32MP1_DDR_BASE; return STM32MP_DDR_BASE;
} }
for (offset = sizeof(uint32_t); (offset & addressmask) != 0U; for (offset = sizeof(uint32_t); (offset & addressmask) != 0U;
offset <<= 1) { offset <<= 1) {
if ((mmio_read_32(STM32MP1_DDR_BASE + if ((mmio_read_32(STM32MP_DDR_BASE +
(uint32_t)offset) != DDR_PATTERN) && (uint32_t)offset) != DDR_PATTERN) &&
(offset != testoffset)) { (offset != testoffset)) {
return (uint32_t)(STM32MP1_DDR_BASE + offset); return (uint32_t)(STM32MP_DDR_BASE + offset);
} }
} }
mmio_write_32(STM32MP1_DDR_BASE + (uint32_t)testoffset, mmio_write_32(STM32MP_DDR_BASE + (uint32_t)testoffset,
DDR_PATTERN); DDR_PATTERN);
} }
...@@ -147,13 +147,13 @@ static uint32_t ddr_check_size(void) ...@@ -147,13 +147,13 @@ static uint32_t ddr_check_size(void)
{ {
uint32_t offset = sizeof(uint32_t); uint32_t offset = sizeof(uint32_t);
mmio_write_32(STM32MP1_DDR_BASE, DDR_PATTERN); mmio_write_32(STM32MP_DDR_BASE, DDR_PATTERN);
while (offset < STM32MP1_DDR_MAX_SIZE) { while (offset < STM32MP_DDR_MAX_SIZE) {
mmio_write_32(STM32MP1_DDR_BASE + offset, DDR_ANTIPATTERN); mmio_write_32(STM32MP_DDR_BASE + offset, DDR_ANTIPATTERN);
dsb(); dsb();
if (mmio_read_32(STM32MP1_DDR_BASE) != DDR_PATTERN) { if (mmio_read_32(STM32MP_DDR_BASE) != DDR_PATTERN) {
break; break;
} }
...@@ -240,15 +240,15 @@ static int stm32mp1_ddr_setup(void) ...@@ -240,15 +240,15 @@ static int stm32mp1_ddr_setup(void)
} }
} }
if (!stm32mp1_clk_is_enabled(RTCAPB)) { if (!stm32mp_clk_is_enabled(RTCAPB)) {
tamp_clk_off = 1; tamp_clk_off = 1;
if (stm32mp1_clk_enable(RTCAPB) != 0) { if (stm32mp_clk_enable(RTCAPB) != 0) {
return -EINVAL; return -EINVAL;
} }
} }
if (tamp_clk_off != 0U) { if (tamp_clk_off != 0U) {
if (stm32mp1_clk_disable(RTCAPB) != 0) { if (stm32mp_clk_disable(RTCAPB) != 0) {
return -EINVAL; return -EINVAL;
} }
} }
...@@ -306,7 +306,7 @@ int stm32mp1_ddr_probe(void) ...@@ -306,7 +306,7 @@ int stm32mp1_ddr_probe(void)
priv->pwr = PWR_BASE; priv->pwr = PWR_BASE;
priv->rcc = RCC_BASE; priv->rcc = RCC_BASE;
priv->info.base = STM32MP1_DDR_BASE; priv->info.base = STM32MP_DDR_BASE;
priv->info.size = 0; priv->info.size = 0;
return stm32mp1_ddr_setup(); return stm32mp1_ddr_setup();
......
...@@ -208,7 +208,7 @@ void set_gpio(uint32_t bank, uint32_t pin, uint32_t mode, uint32_t speed, ...@@ -208,7 +208,7 @@ void set_gpio(uint32_t bank, uint32_t pin, uint32_t mode, uint32_t speed,
assert(pin <= GPIO_PIN_MAX); assert(pin <= GPIO_PIN_MAX);
stm32mp1_clk_enable(clock); stm32mp_clk_enable(clock);
mmio_clrbits_32(base + GPIO_MODE_OFFSET, mmio_clrbits_32(base + GPIO_MODE_OFFSET,
((uint32_t)GPIO_MODE_MASK << (pin << 1))); ((uint32_t)GPIO_MODE_MASK << (pin << 1)));
...@@ -254,7 +254,7 @@ void set_gpio(uint32_t bank, uint32_t pin, uint32_t mode, uint32_t speed, ...@@ -254,7 +254,7 @@ void set_gpio(uint32_t bank, uint32_t pin, uint32_t mode, uint32_t speed,
VERBOSE("GPIO %u mode alternate high to 0x%x\n", bank, VERBOSE("GPIO %u mode alternate high to 0x%x\n", bank,
mmio_read_32(base + GPIO_AFRH_OFFSET)); mmio_read_32(base + GPIO_AFRH_OFFSET));
stm32mp1_clk_disable(clock); stm32mp_clk_disable(clock);
} }
void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure) void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure)
...@@ -264,7 +264,7 @@ void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure) ...@@ -264,7 +264,7 @@ void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure)
assert(pin <= GPIO_PIN_MAX); assert(pin <= GPIO_PIN_MAX);
stm32mp1_clk_enable(clock); stm32mp_clk_enable(clock);
if (secure) { if (secure) {
mmio_setbits_32(base + GPIO_SECR_OFFSET, BIT(pin)); mmio_setbits_32(base + GPIO_SECR_OFFSET, BIT(pin));
...@@ -272,5 +272,5 @@ void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure) ...@@ -272,5 +272,5 @@ void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure)
mmio_clrbits_32(base + GPIO_SECR_OFFSET, BIT(pin)); mmio_clrbits_32(base + GPIO_SECR_OFFSET, BIT(pin));
} }
stm32mp1_clk_disable(clock); stm32mp_clk_disable(clock);
} }
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
#include <drivers/mmc.h> #include <drivers/mmc.h>
#include <drivers/st/stm32_gpio.h> #include <drivers/st/stm32_gpio.h>
#include <drivers/st/stm32_sdmmc2.h> #include <drivers/st/stm32_sdmmc2.h>
#include <drivers/st/stm32mp_reset.h>
#include <drivers/st/stm32mp1_clk.h> #include <drivers/st/stm32mp1_clk.h>
#include <drivers/st/stm32mp1_rcc.h> #include <drivers/st/stm32mp1_rcc.h>
#include <drivers/st/stm32mp1_reset.h>
#include <dt-bindings/clock/stm32mp1-clks.h> #include <dt-bindings/clock/stm32mp1-clks.h>
#include <dt-bindings/reset/stm32mp1-resets.h> #include <dt-bindings/reset/stm32mp1-resets.h>
#include <lib/mmio.h> #include <lib/mmio.h>
...@@ -159,7 +159,7 @@ static void stm32_sdmmc2_init(void) ...@@ -159,7 +159,7 @@ static void stm32_sdmmc2_init(void)
uintptr_t base = sdmmc2_params.reg_base; uintptr_t base = sdmmc2_params.reg_base;
clock_div = div_round_up(sdmmc2_params.clk_rate, clock_div = div_round_up(sdmmc2_params.clk_rate,
STM32MP1_MMC_INIT_FREQ * 2); STM32MP_MMC_INIT_FREQ * 2);
mmio_write_32(base + SDMMC_CLKCR, SDMMC_CLKCR_HWFC_EN | clock_div | mmio_write_32(base + SDMMC_CLKCR, SDMMC_CLKCR_HWFC_EN | clock_div |
sdmmc2_params.negedge | sdmmc2_params.negedge |
...@@ -429,15 +429,15 @@ static int stm32_sdmmc2_set_ios(unsigned int clk, unsigned int width) ...@@ -429,15 +429,15 @@ static int stm32_sdmmc2_set_ios(unsigned int clk, unsigned int width)
if (sdmmc2_params.device_info->mmc_dev_type == MMC_IS_EMMC) { if (sdmmc2_params.device_info->mmc_dev_type == MMC_IS_EMMC) {
if (max_bus_freq >= 52000000U) { if (max_bus_freq >= 52000000U) {
max_freq = STM32MP1_EMMC_HIGH_SPEED_MAX_FREQ; max_freq = STM32MP_EMMC_HIGH_SPEED_MAX_FREQ;
} else { } else {
max_freq = STM32MP1_EMMC_NORMAL_SPEED_MAX_FREQ; max_freq = STM32MP_EMMC_NORMAL_SPEED_MAX_FREQ;
} }
} else { } else {
if (max_bus_freq >= 50000000U) { if (max_bus_freq >= 50000000U) {
max_freq = STM32MP1_SD_HIGH_SPEED_MAX_FREQ; max_freq = STM32MP_SD_HIGH_SPEED_MAX_FREQ;
} else { } else {
max_freq = STM32MP1_SD_NORMAL_SPEED_MAX_FREQ; max_freq = STM32MP_SD_NORMAL_SPEED_MAX_FREQ;
} }
} }
...@@ -720,19 +720,19 @@ int stm32_sdmmc2_mmc_init(struct stm32_sdmmc2_params *params) ...@@ -720,19 +720,19 @@ int stm32_sdmmc2_mmc_init(struct stm32_sdmmc2_params *params)
return -ENOMEM; return -ENOMEM;
} }
ret = stm32mp1_clk_enable(sdmmc2_params.clock_id); ret = stm32mp_clk_enable(sdmmc2_params.clock_id);
if (ret != 0) { if (ret != 0) {
ERROR("%s: clock %d failed\n", __func__, ERROR("%s: clock %d failed\n", __func__,
sdmmc2_params.clock_id); sdmmc2_params.clock_id);
return ret; return ret;
} }
stm32mp1_reset_assert(sdmmc2_params.reset_id); stm32mp_reset_assert(sdmmc2_params.reset_id);
udelay(2); udelay(2);
stm32mp1_reset_deassert(sdmmc2_params.reset_id); stm32mp_reset_deassert(sdmmc2_params.reset_id);
mdelay(1); mdelay(1);
sdmmc2_params.clk_rate = stm32mp1_clk_get_rate(sdmmc2_params.clock_id); sdmmc2_params.clk_rate = stm32mp_clk_get_rate(sdmmc2_params.clock_id);
return mmc_init(&stm32_sdmmc2_ops, sdmmc2_params.clk_rate, return mmc_init(&stm32_sdmmc2_ops, sdmmc2_params.clk_rate,
sdmmc2_params.bus_width, sdmmc2_params.flags, sdmmc2_params.bus_width, sdmmc2_params.flags,
......
...@@ -167,7 +167,7 @@ void initialize_pmic_i2c(void) ...@@ -167,7 +167,7 @@ void initialize_pmic_i2c(void)
panic(); panic();
} }
if (stm32mp1_clk_enable((uint32_t)i2c_info.clock) < 0) { if (stm32mp_clk_enable((uint32_t)i2c_info.clock) < 0) {
ERROR("I2C clock enable failed\n"); ERROR("I2C clock enable failed\n");
panic(); panic();
} }
......
/* /*
* Copyright (c) 2018, STMicroelectronics - All Rights Reserved * Copyright (c) 2018-2019, STMicroelectronics - All Rights Reserved
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
#include <common/bl_common.h> #include <common/bl_common.h>
#include <common/debug.h> #include <common/debug.h>
#include <drivers/st/stm32mp_reset.h>
#include <drivers/st/stm32mp1_rcc.h> #include <drivers/st/stm32mp1_rcc.h>
#include <drivers/st/stm32mp1_reset.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/utils_def.h> #include <lib/utils_def.h>
#define RST_CLR_OFFSET 4U #define RST_CLR_OFFSET 4U
void stm32mp1_reset_assert(uint32_t id) void stm32mp_reset_assert(uint32_t id)
{ {
uint32_t offset = (id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t); uint32_t offset = (id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t);
uint32_t bit = id % (uint32_t)__LONG_BIT; uint32_t bit = id % (uint32_t)__LONG_BIT;
...@@ -28,7 +28,7 @@ void stm32mp1_reset_assert(uint32_t id) ...@@ -28,7 +28,7 @@ void stm32mp1_reset_assert(uint32_t id)
} }
} }
void stm32mp1_reset_deassert(uint32_t id) void stm32mp_reset_deassert(uint32_t id)
{ {
uint32_t offset = ((id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t)) + uint32_t offset = ((id / (uint32_t)__LONG_BIT) * sizeof(uintptr_t)) +
RST_CLR_OFFSET; RST_CLR_OFFSET;
......
/* /*
* Copyright (c) 2018, STMicroelectronics - All Rights Reserved * Copyright (c) 2018-2019, STMicroelectronics - All Rights Reserved
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -7,16 +7,10 @@ ...@@ -7,16 +7,10 @@
#ifndef STM32MP1_CLK_H #ifndef STM32MP1_CLK_H
#define STM32MP1_CLK_H #define STM32MP1_CLK_H
#include <stdbool.h>
#include <arch_helpers.h> #include <arch_helpers.h>
int stm32mp1_clk_probe(void); int stm32mp1_clk_probe(void);
int stm32mp1_clk_init(void); int stm32mp1_clk_init(void);
bool stm32mp1_clk_is_enabled(unsigned long id);
int stm32mp1_clk_enable(unsigned long id);
int stm32mp1_clk_disable(unsigned long id);
unsigned long stm32mp1_clk_get_rate(unsigned long id);
void stm32mp1_stgen_increment(unsigned long long offset_in_ms); void stm32mp1_stgen_increment(unsigned long long offset_in_ms);
static inline uint32_t get_timer(uint32_t base) static inline uint32_t get_timer(uint32_t base)
......
/*
* Copyright (c) 2018, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef STM32MP1_RESET_H
#define STM32MP1_RESET_H
#include <stdint.h>
void stm32mp1_reset_assert(uint32_t reset_id);
void stm32mp1_reset_deassert(uint32_t reset_id);
#endif /* STM32MP1_RESET_H */
/*
* Copyright (c) 2018-2019, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef STM32MP_RESET_H
#define STM32MP_RESET_H
#include <stdint.h>
void stm32mp_reset_assert(uint32_t reset_id);
void stm32mp_reset_deassert(uint32_t reset_id);
#endif /* STM32MP_RESET_H */
...@@ -57,12 +57,12 @@ static const io_dev_connector_t *mmc_dev_con; ...@@ -57,12 +57,12 @@ static const io_dev_connector_t *mmc_dev_con;
static const io_block_spec_t bl32_block_spec = { static const io_block_spec_t bl32_block_spec = {
.offset = BL32_BASE, .offset = BL32_BASE,
.length = STM32MP1_BL32_SIZE .length = STM32MP_BL32_SIZE
}; };
static const io_block_spec_t bl2_block_spec = { static const io_block_spec_t bl2_block_spec = {
.offset = BL2_BASE, .offset = BL2_BASE,
.length = STM32MP1_BL2_SIZE, .length = STM32MP_BL2_SIZE,
}; };
static const struct stm32image_part_info bl33_partition_spec = { static const struct stm32image_part_info bl33_partition_spec = {
...@@ -163,7 +163,7 @@ static void print_boot_device(boot_api_context_t *boot_context) ...@@ -163,7 +163,7 @@ static void print_boot_device(boot_api_context_t *boot_context)
} }
} }
void stm32mp1_io_setup(void) void stm32mp_io_setup(void)
{ {
int io_result __unused; int io_result __unused;
uint8_t idx; uint8_t idx;
...@@ -173,7 +173,7 @@ void stm32mp1_io_setup(void) ...@@ -173,7 +173,7 @@ void stm32mp1_io_setup(void)
uintptr_t mmc_default_instance; uintptr_t mmc_default_instance;
const partition_entry_t *entry; const partition_entry_t *entry;
boot_api_context_t *boot_context = boot_api_context_t *boot_context =
(boot_api_context_t *)stm32mp1_get_boot_ctx_address(); (boot_api_context_t *)stm32mp_get_boot_ctx_address();
print_boot_device(boot_context); print_boot_device(boot_context);
...@@ -200,21 +200,21 @@ void stm32mp1_io_setup(void) ...@@ -200,21 +200,21 @@ void stm32mp1_io_setup(void)
if (boot_context->boot_interface_selected == if (boot_context->boot_interface_selected ==
BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC) { BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC) {
device_info.mmc_dev_type = MMC_IS_EMMC; device_info.mmc_dev_type = MMC_IS_EMMC;
mmc_default_instance = STM32MP1_SDMMC2_BASE; mmc_default_instance = STM32MP_SDMMC2_BASE;
} else { } else {
device_info.mmc_dev_type = MMC_IS_SD; device_info.mmc_dev_type = MMC_IS_SD;
mmc_default_instance = STM32MP1_SDMMC1_BASE; mmc_default_instance = STM32MP_SDMMC1_BASE;
} }
switch (boot_context->boot_interface_instance) { switch (boot_context->boot_interface_instance) {
case 1: case 1:
params.reg_base = STM32MP1_SDMMC1_BASE; params.reg_base = STM32MP_SDMMC1_BASE;
break; break;
case 2: case 2:
params.reg_base = STM32MP1_SDMMC2_BASE; params.reg_base = STM32MP_SDMMC2_BASE;
break; break;
case 3: case 3:
params.reg_base = STM32MP1_SDMMC3_BASE; params.reg_base = STM32MP_SDMMC3_BASE;
break; break;
default: default:
WARN("SDMMC instance not found, using default\n"); WARN("SDMMC instance not found, using default\n");
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
#ifndef STM32MP_COMMON_H #ifndef STM32MP_COMMON_H
#define STM32MP_COMMON_H #define STM32MP_COMMON_H
#include <stdbool.h>
/* Functions to save and get boot context address given by ROM code */ /* Functions to save and get boot context address given by ROM code */
void stm32mp1_save_boot_ctx_address(uintptr_t address); void stm32mp_save_boot_ctx_address(uintptr_t address);
uintptr_t stm32mp1_get_boot_ctx_address(void); uintptr_t stm32mp_get_boot_ctx_address(void);
/* /*
* Platform util functions for the GPIO driver * Platform util functions for the GPIO driver
...@@ -28,7 +30,16 @@ uintptr_t stm32_get_gpio_bank_base(unsigned int bank); ...@@ -28,7 +30,16 @@ uintptr_t stm32_get_gpio_bank_base(unsigned int bank);
unsigned long stm32_get_gpio_bank_clock(unsigned int bank); unsigned long stm32_get_gpio_bank_clock(unsigned int bank);
uint32_t stm32_get_gpio_bank_offset(unsigned int bank); uint32_t stm32_get_gpio_bank_offset(unsigned int bank);
/*
* Util for clock gating and to get clock rate for stm32 and platform drivers
* @id: Target clock ID, ID used in clock DT bindings
*/
bool stm32mp_clk_is_enabled(unsigned long id);
int stm32mp_clk_enable(unsigned long id);
int stm32mp_clk_disable(unsigned long id);
unsigned long stm32mp_clk_get_rate(unsigned long id);
/* Initialise the IO layer and register platform IO devices */ /* Initialise the IO layer and register platform IO devices */
void stm32mp1_io_setup(void); void stm32mp_io_setup(void);
#endif /* STM32MP_COMMON_H */ #endif /* STM32MP_COMMON_H */
...@@ -25,12 +25,12 @@ unsigned int plat_get_syscnt_freq2(void) ...@@ -25,12 +25,12 @@ unsigned int plat_get_syscnt_freq2(void)
static uintptr_t boot_ctx_address; static uintptr_t boot_ctx_address;
void stm32mp1_save_boot_ctx_address(uintptr_t address) void stm32mp_save_boot_ctx_address(uintptr_t address)
{ {
boot_ctx_address = address; boot_ctx_address = address;
} }
uintptr_t stm32mp1_get_boot_ctx_address(void) uintptr_t stm32mp_get_boot_ctx_address(void)
{ {
return boot_ctx_address; return boot_ctx_address;
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
static int fdt_checked; static int fdt_checked;
static void *fdt = (void *)(uintptr_t)STM32MP1_DTB_BASE; static void *fdt = (void *)(uintptr_t)STM32MP_DTB_BASE;
/******************************************************************************* /*******************************************************************************
* This function checks device tree file with its header. * This function checks device tree file with its header.
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
#include <drivers/generic_delay_timer.h> #include <drivers/generic_delay_timer.h>
#include <drivers/st/stm32_console.h> #include <drivers/st/stm32_console.h>
#include <drivers/st/stm32mp_pmic.h> #include <drivers/st/stm32mp_pmic.h>
#include <drivers/st/stm32mp_reset.h>
#include <drivers/st/stm32mp1_clk.h> #include <drivers/st/stm32mp1_clk.h>
#include <drivers/st/stm32mp1_pwr.h> #include <drivers/st/stm32mp1_pwr.h>
#include <drivers/st/stm32mp1_ram.h> #include <drivers/st/stm32mp1_ram.h>
#include <drivers/st/stm32mp1_rcc.h> #include <drivers/st/stm32mp1_rcc.h>
#include <drivers/st/stm32mp1_reset.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/xlat_tables/xlat_tables_v2.h> #include <lib/xlat_tables/xlat_tables_v2.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
...@@ -120,7 +120,7 @@ void bl2_el3_early_platform_setup(u_register_t arg0, ...@@ -120,7 +120,7 @@ void bl2_el3_early_platform_setup(u_register_t arg0,
u_register_t arg2 __unused, u_register_t arg2 __unused,
u_register_t arg3 __unused) u_register_t arg3 __unused)
{ {
stm32mp1_save_boot_ctx_address(arg0); stm32mp_save_boot_ctx_address(arg0);
} }
void bl2_platform_setup(void) void bl2_platform_setup(void)
...@@ -146,7 +146,7 @@ void bl2_el3_plat_arch_setup(void) ...@@ -146,7 +146,7 @@ void bl2_el3_plat_arch_setup(void)
struct dt_node_info dt_uart_info; struct dt_node_info dt_uart_info;
const char *board_model; const char *board_model;
boot_api_context_t *boot_context = boot_api_context_t *boot_context =
(boot_api_context_t *)stm32mp1_get_boot_ctx_address(); (boot_api_context_t *)stm32mp_get_boot_ctx_address();
uint32_t clk_rate; uint32_t clk_rate;
mmap_add_region(BL_CODE_BASE, BL_CODE_BASE, mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
...@@ -159,9 +159,9 @@ void bl2_el3_plat_arch_setup(void) ...@@ -159,9 +159,9 @@ void bl2_el3_plat_arch_setup(void)
MT_MEMORY | MT_RO | MT_SECURE); MT_MEMORY | MT_RO | MT_SECURE);
/* Map non secure DDR for BL33 load and DDR training area restore */ /* Map non secure DDR for BL33 load and DDR training area restore */
mmap_add_region(STM32MP1_DDR_BASE, mmap_add_region(STM32MP_DDR_BASE,
STM32MP1_DDR_BASE, STM32MP_DDR_BASE,
STM32MP1_DDR_MAX_SIZE, STM32MP_DDR_MAX_SIZE,
MT_MEMORY | MT_RW | MT_NS); MT_MEMORY | MT_RW | MT_NS);
/* Prevent corruption of preloaded Device Tree */ /* Prevent corruption of preloaded Device Tree */
...@@ -221,19 +221,19 @@ void bl2_el3_plat_arch_setup(void) ...@@ -221,19 +221,19 @@ void bl2_el3_plat_arch_setup(void)
goto skip_console_init; goto skip_console_init;
} }
if (stm32mp1_clk_enable((unsigned long)dt_uart_info.clock) != 0) { if (stm32mp_clk_enable((unsigned long)dt_uart_info.clock) != 0) {
goto skip_console_init; goto skip_console_init;
} }
stm32mp1_reset_assert((uint32_t)dt_uart_info.reset); stm32mp_reset_assert((uint32_t)dt_uart_info.reset);
udelay(2); udelay(2);
stm32mp1_reset_deassert((uint32_t)dt_uart_info.reset); stm32mp_reset_deassert((uint32_t)dt_uart_info.reset);
mdelay(1); mdelay(1);
clk_rate = stm32mp1_clk_get_rate((unsigned long)dt_uart_info.clock); clk_rate = stm32mp_clk_get_rate((unsigned long)dt_uart_info.clock);
if (console_stm32_register(dt_uart_info.base, clk_rate, if (console_stm32_register(dt_uart_info.base, clk_rate,
STM32MP1_UART_BAUDRATE, &console) == 0) { STM32MP_UART_BAUDRATE, &console) == 0) {
panic(); panic();
} }
...@@ -254,5 +254,5 @@ skip_console_init: ...@@ -254,5 +254,5 @@ skip_console_init:
print_reset_reason(); print_reset_reason();
stm32mp1_io_setup(); stm32mp_io_setup();
} }
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#define BL33_IMAGE_NAME "ssbl" #define BL33_IMAGE_NAME "ssbl"
#define BL33_BINARY_TYPE U(0x0) #define BL33_BINARY_TYPE U(0x0)
#define STM32MP1_PRIMARY_CPU U(0x0) #define STM32MP_PRIMARY_CPU U(0x0)
#define STM32MP1_SECONDARY_CPU U(0x1) #define STM32MP_SECONDARY_CPU U(0x1)
#define PLATFORM_CLUSTER_COUNT ULL(1) #define PLATFORM_CLUSTER_COUNT ULL(1)
#define PLATFORM_CLUSTER0_CORE_COUNT U(2) #define PLATFORM_CLUSTER0_CORE_COUNT U(2)
...@@ -50,33 +50,33 @@ ...@@ -50,33 +50,33 @@
* Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug
* size plus a little space for growth. * size plus a little space for growth.
*/ */
#define BL2_BASE STM32MP1_BL2_BASE #define BL2_BASE STM32MP_BL2_BASE
#define BL2_LIMIT (STM32MP1_BL2_BASE + \ #define BL2_LIMIT (STM32MP_BL2_BASE + \
STM32MP1_BL2_SIZE) STM32MP_BL2_SIZE)
/******************************************************************************* /*******************************************************************************
* BL32 specific defines. * BL32 specific defines.
******************************************************************************/ ******************************************************************************/
#define BL32_BASE STM32MP1_BL32_BASE #define BL32_BASE STM32MP_BL32_BASE
#define BL32_LIMIT (STM32MP1_BL32_BASE + \ #define BL32_LIMIT (STM32MP_BL32_BASE + \
STM32MP1_BL32_SIZE) STM32MP_BL32_SIZE)
/******************************************************************************* /*******************************************************************************
* BL33 specific defines. * BL33 specific defines.
******************************************************************************/ ******************************************************************************/
#define BL33_BASE STM32MP1_BL33_BASE #define BL33_BASE STM32MP_BL33_BASE
/* /*
* Load address of BL33 for this platform port * Load address of BL33 for this platform port
*/ */
#define PLAT_STM32MP1_NS_IMAGE_OFFSET BL33_BASE #define PLAT_STM32MP_NS_IMAGE_OFFSET BL33_BASE
/******************************************************************************* /*******************************************************************************
* DTB specific defines. * DTB specific defines.
******************************************************************************/ ******************************************************************************/
#define DTB_BASE STM32MP1_DTB_BASE #define DTB_BASE STM32MP_DTB_BASE
#define DTB_LIMIT (STM32MP1_DTB_BASE + \ #define DTB_LIMIT (STM32MP_DTB_BASE + \
STM32MP1_DTB_SIZE) STM32MP_DTB_SIZE)
/******************************************************************************* /*******************************************************************************
* Platform specific page table and MMU setup constants * Platform specific page table and MMU setup constants
......
/* /*
* Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -50,7 +50,7 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = { ...@@ -50,7 +50,7 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = {
VERSION_2, entry_point_info_t, VERSION_2, entry_point_info_t,
NON_SECURE | EXECUTABLE), NON_SECURE | EXECUTABLE),
.ep_info.pc = PLAT_STM32MP1_NS_IMAGE_OFFSET, .ep_info.pc = PLAT_STM32MP_NS_IMAGE_OFFSET,
.ep_info.spsr = SPSR_MODE32(MODE32_svc, SPSR_T_ARM, .ep_info.spsr = SPSR_MODE32(MODE32_svc, SPSR_T_ARM,
SPSR_E_LITTLE, SPSR_E_LITTLE,
DISABLE_ALL_EXCEPTIONS), DISABLE_ALL_EXCEPTIONS),
...@@ -58,9 +58,9 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = { ...@@ -58,9 +58,9 @@ static bl_mem_params_node_t bl2_mem_params_descs[] = {
SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
VERSION_2, image_info_t, 0), VERSION_2, image_info_t, 0),
.image_info.image_base = PLAT_STM32MP1_NS_IMAGE_OFFSET, .image_info.image_base = PLAT_STM32MP_NS_IMAGE_OFFSET,
.image_info.image_max_size = STM32MP1_DDR_MAX_SIZE - .image_info.image_max_size = STM32MP_DDR_MAX_SIZE -
(PLAT_STM32MP1_NS_IMAGE_OFFSET - STM32MP1_DDR_BASE), (PLAT_STM32MP_NS_IMAGE_OFFSET - STM32MP_DDR_BASE),
.next_handoff_image_id = INVALID_IMAGE_ID, .next_handoff_image_id = INVALID_IMAGE_ID,
} }
......
...@@ -123,7 +123,7 @@ void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -123,7 +123,7 @@ void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1,
if ((result > 0) && (dt_uart_info.status != 0U)) { if ((result > 0) && (dt_uart_info.status != 0U)) {
if (console_stm32_register(dt_uart_info.base, 0, if (console_stm32_register(dt_uart_info.base, 0,
STM32MP1_UART_BAUDRATE, &console) == STM32MP_UART_BAUDRATE, &console) ==
0) { 0) {
panic(); panic();
} }
......
/* /*
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -17,7 +17,7 @@ ENTRY(__BL2_IMAGE_START__) ...@@ -17,7 +17,7 @@ ENTRY(__BL2_IMAGE_START__)
MEMORY { MEMORY {
HEADER (rw) : ORIGIN = 0x00000000, LENGTH = 0x3000 HEADER (rw) : ORIGIN = 0x00000000, LENGTH = 0x3000
RAM (rwx) : ORIGIN = STM32MP1_BINARY_BASE, LENGTH = STM32MP1_BINARY_SIZE RAM (rwx) : ORIGIN = STM32MP_BINARY_BASE, LENGTH = STM32MP_BINARY_SIZE
} }
SECTIONS SECTIONS
...@@ -32,7 +32,7 @@ SECTIONS ...@@ -32,7 +32,7 @@ SECTIONS
__HEADER_END__ = .; __HEADER_END__ = .;
} >HEADER } >HEADER
. = STM32MP1_BINARY_BASE; . = STM32MP_BINARY_BASE;
.data . : { .data . : {
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
__DATA_START__ = .; __DATA_START__ = .;
...@@ -43,7 +43,7 @@ SECTIONS ...@@ -43,7 +43,7 @@ SECTIONS
* The strongest and only alignment contraint is MMU 4K page. * The strongest and only alignment contraint is MMU 4K page.
* Indeed as images below will be removed, 4K pages will be re-used. * Indeed as images below will be removed, 4K pages will be re-used.
*/ */
. = ( STM32MP1_DTB_BASE - STM32MP1_BINARY_BASE ); . = ( STM32MP_DTB_BASE - STM32MP_BINARY_BASE );
__DTB_IMAGE_START__ = .; __DTB_IMAGE_START__ = .;
*(.dtb_image*) *(.dtb_image*)
__DTB_IMAGE_END__ = .; __DTB_IMAGE_END__ = .;
...@@ -53,7 +53,7 @@ SECTIONS ...@@ -53,7 +53,7 @@ SECTIONS
* The strongest and only alignment contraint is MMU 4K page. * The strongest and only alignment contraint is MMU 4K page.
* Indeed as images below will be removed, 4K pages will be re-used. * Indeed as images below will be removed, 4K pages will be re-used.
*/ */
. = ( STM32MP1_BL2_BASE - STM32MP1_BINARY_BASE ); . = ( STM32MP_BL2_BASE - STM32MP_BINARY_BASE );
__BL2_IMAGE_START__ = .; __BL2_IMAGE_START__ = .;
*(.bl2_image*) *(.bl2_image*)
__BL2_IMAGE_END__ = .; __BL2_IMAGE_END__ = .;
...@@ -63,7 +63,7 @@ SECTIONS ...@@ -63,7 +63,7 @@ SECTIONS
* The strongest and only alignment constraint is 8 words to simplify * The strongest and only alignment constraint is 8 words to simplify
* memraise8 assembly code. * memraise8 assembly code.
*/ */
. = ( STM32MP1_BL32_BASE - STM32MP1_BINARY_BASE ); . = ( STM32MP_BL32_BASE - STM32MP_BINARY_BASE );
__BL32_IMAGE_START__ = .; __BL32_IMAGE_START__ = .;
*(.bl32_image*) *(.bl32_image*)
__BL32_IMAGE_END__ = .; __BL32_IMAGE_END__ = .;
......
/* /*
* Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -23,9 +23,9 @@ int stm32_save_boot_interface(uint32_t interface, uint32_t instance) ...@@ -23,9 +23,9 @@ int stm32_save_boot_interface(uint32_t interface, uint32_t instance)
uint32_t tamp_clk_off = 0; uint32_t tamp_clk_off = 0;
uint32_t bkpr_itf_idx = tamp_bkpr(TAMP_BOOT_ITF_BACKUP_REG_ID); uint32_t bkpr_itf_idx = tamp_bkpr(TAMP_BOOT_ITF_BACKUP_REG_ID);
if (!stm32mp1_clk_is_enabled(RTCAPB)) { if (!stm32mp_clk_is_enabled(RTCAPB)) {
tamp_clk_off = 1; tamp_clk_off = 1;
if (stm32mp1_clk_enable(RTCAPB) != 0) { if (stm32mp_clk_enable(RTCAPB) != 0) {
return -EINVAL; return -EINVAL;
} }
} }
...@@ -36,7 +36,7 @@ int stm32_save_boot_interface(uint32_t interface, uint32_t instance) ...@@ -36,7 +36,7 @@ int stm32_save_boot_interface(uint32_t interface, uint32_t instance)
TAMP_BOOT_ITF_SHIFT); TAMP_BOOT_ITF_SHIFT);
if (tamp_clk_off != 0U) { if (tamp_clk_off != 0U) {
if (stm32mp1_clk_disable(RTCAPB) != 0) { if (stm32mp_clk_disable(RTCAPB) != 0) {
return -EINVAL; return -EINVAL;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment