mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
Merge tag 'u-boot-stm32-20250611' of https://source.denx.de/u-boot/custodians/u-boot-stm into next
CI: https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/26607 - Add clock and reset drivers support for STM32MP25 - Add STM32H747-Discovery board support - Add tamp_nvram driver - Add SPL support and clock tree init to STM32MP13 RCC driver - Add STM32MP13xx ram support - Add support for STM32 Image V2.0 for STM32MP13xx - Fix SYSRAM size on STM32MP13xx - Fix DBGMCU macro on STM32MP13xx - Auto-detect ROM API table on STM32MP15xx
This commit is contained in:
@@ -718,7 +718,7 @@ F: drivers/power/regulator/stm32-vrefbuf.c
|
||||
F: drivers/power/regulator/stpmic1.c
|
||||
F: drivers/ram/stm32mp1/
|
||||
F: drivers/remoteproc/stm32_copro.c
|
||||
F: drivers/reset/stm32-reset.c
|
||||
F: drivers/reset/stm32/
|
||||
F: drivers/rng/optee_rng.c
|
||||
F: drivers/rng/stm32_rng.c
|
||||
F: drivers/rtc/stm32_rtc.c
|
||||
@@ -731,6 +731,7 @@ F: include/dt-bindings/clock/stm32fx-clock.h
|
||||
F: include/dt-bindings/clock/stm32mp*
|
||||
F: include/dt-bindings/pinctrl/stm32-pinfunc.h
|
||||
F: include/dt-bindings/reset/stm32mp*
|
||||
F: include/stm32-reset-core.h
|
||||
F: include/stm32_rcc.h
|
||||
F: tools/logos/st.bmp
|
||||
F: tools/stm32image.c
|
||||
|
||||
@@ -36,7 +36,8 @@ config ARMV7_SECURE_BASE
|
||||
hex "Base address for secure mode memory"
|
||||
depends on HAS_ARMV7_SECURE_BASE
|
||||
default 0xfff00000 if TEGRA124
|
||||
default 0x2ffc0000 if ARCH_STM32MP
|
||||
default 0x2ffe0000 if STM32MP13X
|
||||
default 0x2ffc0000 if STM32MP15X
|
||||
default 0x2f000000 if ARCH_MX7ULP
|
||||
default 0x10010000 if ARCH_LS1021A
|
||||
default 0x00900000 if ARCH_MX7
|
||||
|
||||
104
arch/arm/dts/stm32h747i-disco-u-boot.dtsi
Normal file
104
arch/arm/dts/stm32h747i-disco-u-boot.dtsi
Normal file
@@ -0,0 +1,104 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2025 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
*/
|
||||
|
||||
#include <stm32h7-u-boot.dtsi>
|
||||
|
||||
&fmc {
|
||||
|
||||
/*
|
||||
* Memory configuration from sdram datasheet IS42S32800G-6BLI
|
||||
* first bank is bank@0
|
||||
* second bank is bank@1
|
||||
*/
|
||||
bank1: bank@1 {
|
||||
st,sdram-control = /bits/ 8 <NO_COL_9
|
||||
NO_ROW_12
|
||||
MWIDTH_32
|
||||
BANKS_4
|
||||
CAS_2
|
||||
SDCLK_3
|
||||
RD_BURST_EN
|
||||
RD_PIPE_DL_0>;
|
||||
st,sdram-timing = /bits/ 8 <TMRD_1
|
||||
TXSR_1
|
||||
TRAS_1
|
||||
TRC_6
|
||||
TRP_2
|
||||
TWR_1
|
||||
TRCD_1>;
|
||||
st,sdram-refcount = <1539>;
|
||||
};
|
||||
};
|
||||
|
||||
&pinctrl {
|
||||
fmc_pins: fmc@0 {
|
||||
pins {
|
||||
pinmux = <STM32_PINMUX('D', 0, AF12)>,
|
||||
<STM32_PINMUX('D', 1, AF12)>,
|
||||
<STM32_PINMUX('D', 8, AF12)>,
|
||||
<STM32_PINMUX('D', 9, AF12)>,
|
||||
<STM32_PINMUX('D',10, AF12)>,
|
||||
<STM32_PINMUX('D',14, AF12)>,
|
||||
<STM32_PINMUX('D',15, AF12)>,
|
||||
|
||||
<STM32_PINMUX('E', 0, AF12)>,
|
||||
<STM32_PINMUX('E', 1, AF12)>,
|
||||
<STM32_PINMUX('E', 7, AF12)>,
|
||||
<STM32_PINMUX('E', 8, AF12)>,
|
||||
<STM32_PINMUX('E', 9, AF12)>,
|
||||
<STM32_PINMUX('E',10, AF12)>,
|
||||
<STM32_PINMUX('E',11, AF12)>,
|
||||
<STM32_PINMUX('E',12, AF12)>,
|
||||
<STM32_PINMUX('E',13, AF12)>,
|
||||
<STM32_PINMUX('E',14, AF12)>,
|
||||
<STM32_PINMUX('E',15, AF12)>,
|
||||
|
||||
<STM32_PINMUX('F', 0, AF12)>,
|
||||
<STM32_PINMUX('F', 1, AF12)>,
|
||||
<STM32_PINMUX('F', 2, AF12)>,
|
||||
<STM32_PINMUX('F', 3, AF12)>,
|
||||
<STM32_PINMUX('F', 4, AF12)>,
|
||||
<STM32_PINMUX('F', 5, AF12)>,
|
||||
<STM32_PINMUX('F',11, AF12)>,
|
||||
<STM32_PINMUX('F',12, AF12)>,
|
||||
<STM32_PINMUX('F',13, AF12)>,
|
||||
<STM32_PINMUX('F',14, AF12)>,
|
||||
<STM32_PINMUX('F',15, AF12)>,
|
||||
|
||||
<STM32_PINMUX('G', 0, AF12)>,
|
||||
<STM32_PINMUX('G', 1, AF12)>,
|
||||
<STM32_PINMUX('G', 2, AF12)>,
|
||||
<STM32_PINMUX('G', 4, AF12)>,
|
||||
<STM32_PINMUX('G', 5, AF12)>,
|
||||
<STM32_PINMUX('G', 8, AF12)>,
|
||||
<STM32_PINMUX('G',15, AF12)>,
|
||||
|
||||
<STM32_PINMUX('H', 5, AF12)>,
|
||||
<STM32_PINMUX('H', 6, AF12)>,
|
||||
<STM32_PINMUX('H', 7, AF12)>,
|
||||
<STM32_PINMUX('H', 8, AF12)>,
|
||||
<STM32_PINMUX('H', 9, AF12)>,
|
||||
<STM32_PINMUX('H',10, AF12)>,
|
||||
<STM32_PINMUX('H',11, AF12)>,
|
||||
<STM32_PINMUX('H',12, AF12)>,
|
||||
<STM32_PINMUX('H',13, AF12)>,
|
||||
<STM32_PINMUX('H',14, AF12)>,
|
||||
<STM32_PINMUX('H',15, AF12)>,
|
||||
|
||||
<STM32_PINMUX('I', 0, AF12)>,
|
||||
<STM32_PINMUX('I', 1, AF12)>,
|
||||
<STM32_PINMUX('I', 2, AF12)>,
|
||||
<STM32_PINMUX('I', 3, AF12)>,
|
||||
<STM32_PINMUX('I', 4, AF12)>,
|
||||
<STM32_PINMUX('I', 5, AF12)>,
|
||||
<STM32_PINMUX('I', 6, AF12)>,
|
||||
<STM32_PINMUX('I', 7, AF12)>,
|
||||
<STM32_PINMUX('I', 9, AF12)>,
|
||||
<STM32_PINMUX('I',10, AF12)>;
|
||||
|
||||
slew-rate = <3>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -25,6 +25,10 @@
|
||||
optee {
|
||||
bootph-all;
|
||||
};
|
||||
|
||||
scmi {
|
||||
bootph-all;
|
||||
};
|
||||
};
|
||||
|
||||
/* need PSCI for sysreset during board_f */
|
||||
@@ -93,6 +97,10 @@
|
||||
bootph-all;
|
||||
};
|
||||
|
||||
&rcc {
|
||||
bootph-all;
|
||||
};
|
||||
|
||||
&rifsc {
|
||||
bootph-all;
|
||||
};
|
||||
|
||||
@@ -10,84 +10,10 @@
|
||||
u-boot,boot-led = "led-blue";
|
||||
u-boot,mmc-env-partition = "u-boot-env";
|
||||
};
|
||||
|
||||
clocks {
|
||||
ck_flexgen_08: ck-flexgen-08 {
|
||||
#clock-cells = <0>;
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <64000000>;
|
||||
};
|
||||
|
||||
ck_flexgen_51: ck-flexgen-51 {
|
||||
#clock-cells = <0>;
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <200000000>;
|
||||
};
|
||||
|
||||
ck_icn_ls_mcu: ck-icn-ls-mcu {
|
||||
#clock-cells = <0>;
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <200000000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&gpioa {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpiob {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpioc {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpiod {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpioe {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpiof {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpiog {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpioh {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpioi {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpioj {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpiok {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&gpioz {
|
||||
clocks = <&ck_icn_ls_mcu>;
|
||||
};
|
||||
|
||||
&sdmmc1 {
|
||||
clocks = <&ck_flexgen_51>;
|
||||
/delete-property/resets;
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
bootph-all;
|
||||
clocks = <&ck_flexgen_08>;
|
||||
};
|
||||
|
||||
&usart2_pins_a {
|
||||
|
||||
@@ -6,11 +6,15 @@ config TARGET_STM32H743_DISCO
|
||||
config TARGET_STM32H743_EVAL
|
||||
bool "STM32H743 Evaluation board"
|
||||
|
||||
config TARGET_STM32H747_DISCO
|
||||
bool "STM32H747 Discovery board"
|
||||
|
||||
config TARGET_STM32H750_ART_PI
|
||||
bool "STM32H750 ART Pi board"
|
||||
|
||||
source "board/st/stm32h743-eval/Kconfig"
|
||||
source "board/st/stm32h743-disco/Kconfig"
|
||||
source "board/st/stm32h747-disco/Kconfig"
|
||||
source "board/st/stm32h750-art-pi/Kconfig"
|
||||
|
||||
endif
|
||||
|
||||
@@ -139,6 +139,15 @@ config STM32_ECDSA_VERIFY
|
||||
ROM API provided on STM32MP.
|
||||
The ROM API is only available during SPL for now.
|
||||
|
||||
config STM32MP_TAMP_NVMEM
|
||||
bool "STM32 TAMP backup registers via NVMEM API"
|
||||
select NVMEM
|
||||
default y
|
||||
help
|
||||
Say y to enable the uclass driver for TAMP Backup registers using the
|
||||
NVMEM API. It allows to access to boot mode or others shared information
|
||||
between software components/execution levels.
|
||||
|
||||
config CMD_STM32KEY
|
||||
bool "command stm32key to fuse public key hash"
|
||||
depends on CMDLINE
|
||||
|
||||
@@ -13,6 +13,8 @@ obj-$(CONFIG_STM32MP13X) += stm32mp1/
|
||||
obj-$(CONFIG_STM32MP25X) += stm32mp2/
|
||||
|
||||
obj-$(CONFIG_MFD_STM32_TIMERS) += timers.o
|
||||
obj-$(CONFIG_STM32MP_TAMP_NVMEM) += tamp_nvram.o
|
||||
|
||||
obj-$(CONFIG_STM32_ECDSA_VERIFY) += ecdsa_romapi.o
|
||||
ifndef CONFIG_XPL_BUILD
|
||||
obj-y += cmd_stm32prog/
|
||||
|
||||
@@ -78,9 +78,7 @@ enum forced_boot_mode {
|
||||
#define STM32_RCC_BASE 0x50000000
|
||||
#define STM32_PWR_BASE 0x50001000
|
||||
#define STM32_SYSCFG_BASE 0x50020000
|
||||
#ifdef CONFIG_STM32MP15X
|
||||
#define STM32_DBGMCU_BASE 0x50081000
|
||||
#endif
|
||||
#define STM32_FMC2_BASE 0x58002000
|
||||
#define STM32_IWDG2_BASE 0x5A002000
|
||||
#define STM32_DDRCTRL_BASE 0x5A003000
|
||||
@@ -110,6 +108,11 @@ enum forced_boot_mode {
|
||||
#define STM32_SDMMC2_BASE 0x58007000
|
||||
#define STM32_SDMMC3_BASE 0x48004000
|
||||
|
||||
#ifdef CONFIG_STM32MP13X
|
||||
#define STM32_SYSRAM_BASE 0x2FFE0000
|
||||
#define STM32_SYSRAM_SIZE SZ_128K
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32MP15X
|
||||
#define STM32_SYSRAM_BASE 0x2FFC0000
|
||||
#define STM32_SYSRAM_SIZE SZ_256K
|
||||
|
||||
@@ -330,8 +330,7 @@ static uintptr_t nt_fw_dtb __section(".data");
|
||||
void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2,
|
||||
unsigned long r3)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_STM32_ECDSA_VERIFY))
|
||||
rom_api_table = r0;
|
||||
rom_api_table = r0;
|
||||
|
||||
if (IS_ENABLED(CONFIG_TFABOOT))
|
||||
nt_fw_dtb = r2;
|
||||
|
||||
@@ -64,10 +64,9 @@
|
||||
* - boot instance = bit 31:16
|
||||
* - boot device = bit 15:0
|
||||
*/
|
||||
#define BOOTROM_PARAM_ADDR 0x2FFC0078
|
||||
#define BOOTROM_MODE_MASK GENMASK(15, 0)
|
||||
#define BOOTROM_MODE_SHIFT 0
|
||||
#define BOOTROM_INSTANCE_MASK GENMASK(31, 16)
|
||||
#define BOOTROM_INSTANCE_MASK GENMASK(31, 16)
|
||||
#define BOOTROM_INSTANCE_SHIFT 16
|
||||
|
||||
/* Device Part Number (RPN) = OTP_DATA1 lower 8 bits */
|
||||
@@ -189,7 +188,7 @@ void spl_board_init(void)
|
||||
static void update_bootmode(void)
|
||||
{
|
||||
u32 boot_mode;
|
||||
u32 bootrom_itf = readl(BOOTROM_PARAM_ADDR);
|
||||
u32 bootrom_itf = readl(get_stm32mp_rom_api_table());
|
||||
u32 bootrom_device, bootrom_instance;
|
||||
|
||||
/* enable TAMP clock = RTCAPBEN */
|
||||
|
||||
666
arch/arm/mach-stm32mp/tamp_nvram.c
Normal file
666
arch/arm/mach-stm32mp/tamp_nvram.c
Normal file
@@ -0,0 +1,666 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
|
||||
/*
|
||||
* Copyright (C) 2025, STMicroelectronics - All Rights Reserved
|
||||
*/
|
||||
#define LOG_CATEGORY UCLASS_MISC
|
||||
|
||||
#include <clk.h>
|
||||
#include <dm.h>
|
||||
#include <log.h>
|
||||
#include <misc.h>
|
||||
#include <regmap.h>
|
||||
#include <tee.h>
|
||||
#include <asm/io.h>
|
||||
#include <dm/device.h>
|
||||
#include <dm/device_compat.h>
|
||||
#include <dm/devres.h>
|
||||
|
||||
#define RIF_CID1 0x1
|
||||
#define CURRENT_CID RIF_CID1
|
||||
#define NB_ZONES_STM32MP1 3
|
||||
#define NB_ZONES_STM32MP2 7
|
||||
|
||||
#define _TAMP_SECCFGR 0x20U
|
||||
#define _TAMP_BKPRIFR(x) (0x70U + 0x4U * ((x) - 1))
|
||||
#define _TAMP_RXCIDCFGR(x) (0x80U + 0x4U * ((x)))
|
||||
|
||||
#define BKPREG_PROTECTION_ZONE_1 0
|
||||
#define BKPREG_PROTECTION_ZONE_2 1
|
||||
#define BKPREG_PROTECTION_ZONE_3 2
|
||||
|
||||
#define BKPREG_PROTECTION_ZONE_1_RIF1 0
|
||||
#define BKPREG_PROTECTION_ZONE_1_RIF2 1
|
||||
#define BKPREG_PROTECTION_ZONE_2_RIF1 2
|
||||
#define BKPREG_PROTECTION_ZONE_2_RIF2 3
|
||||
#define BKPREG_PROTECTION_ZONE_3_RIF1 4
|
||||
#define BKPREG_PROTECTION_ZONE_3_RIF0 5
|
||||
#define BKPREG_PROTECTION_ZONE_3_RIF2 6
|
||||
#define NB_COMPARTMENT_STM32MP2 3
|
||||
|
||||
enum stm32_tamp_bkpreg_access {
|
||||
BKP_READ_WRITE,
|
||||
BKP_READ,
|
||||
BKP_NO
|
||||
};
|
||||
|
||||
struct stm32_tamp_nvram_plat {
|
||||
void __iomem *base;
|
||||
void __iomem *parent_base;
|
||||
fdt_size_t size;
|
||||
fdt_size_t parent_size;
|
||||
unsigned int nb_total_regs;
|
||||
};
|
||||
|
||||
struct stm32_tamp_nvram_priv {
|
||||
int *idx_bkpreg_zones_end;
|
||||
struct regmap *config_regmap;
|
||||
struct regmap *bkpregs_regmap;
|
||||
const enum stm32_tamp_bkpreg_access *bkpreg_access;
|
||||
};
|
||||
|
||||
struct stm32_tamp_nvram_drvdata {
|
||||
const unsigned int nb_zones;
|
||||
const struct reg_field *reg_fields;
|
||||
const enum stm32_tamp_bkpreg_access *(*get_access)(struct udevice *dev);
|
||||
};
|
||||
|
||||
static const struct reg_field stm32mp1_tamp_nvram_zone_cfg_fields[NB_ZONES_STM32MP1 - 1] = {
|
||||
[BKPREG_PROTECTION_ZONE_1] = REG_FIELD(_TAMP_SECCFGR, 0, 7),
|
||||
[BKPREG_PROTECTION_ZONE_2] = REG_FIELD(_TAMP_SECCFGR, 16, 23),
|
||||
};
|
||||
|
||||
static const struct reg_field stm32mp2_tamp_nvram_zone_cfg_fields[NB_ZONES_STM32MP2 - 1] = {
|
||||
[BKPREG_PROTECTION_ZONE_1_RIF1] = REG_FIELD(_TAMP_BKPRIFR(1), 0, 7),
|
||||
[BKPREG_PROTECTION_ZONE_1_RIF2] = REG_FIELD(_TAMP_SECCFGR, 0, 7),
|
||||
[BKPREG_PROTECTION_ZONE_2_RIF1] = REG_FIELD(_TAMP_BKPRIFR(2), 0, 7),
|
||||
[BKPREG_PROTECTION_ZONE_2_RIF2] = REG_FIELD(_TAMP_SECCFGR, 16, 23),
|
||||
[BKPREG_PROTECTION_ZONE_3_RIF1] = REG_FIELD(_TAMP_BKPRIFR(3), 0, 7),
|
||||
[BKPREG_PROTECTION_ZONE_3_RIF0] = REG_FIELD(_TAMP_BKPRIFR(3), 16, 23),
|
||||
};
|
||||
|
||||
static const struct reg_field stm32mp2_tamp_nvram_rxcidcfg_cfen_fields[NB_COMPARTMENT_STM32MP2] = {
|
||||
REG_FIELD(_TAMP_RXCIDCFGR(0), 0, 0),
|
||||
REG_FIELD(_TAMP_RXCIDCFGR(1), 0, 0),
|
||||
REG_FIELD(_TAMP_RXCIDCFGR(2), 0, 0),
|
||||
};
|
||||
|
||||
static const struct reg_field stm32mp2_tamp_nvram_rxcidcfg_fields[NB_COMPARTMENT_STM32MP2] = {
|
||||
REG_FIELD(_TAMP_RXCIDCFGR(0), 4, 6),
|
||||
REG_FIELD(_TAMP_RXCIDCFGR(1), 4, 6),
|
||||
REG_FIELD(_TAMP_RXCIDCFGR(2), 4, 6),
|
||||
};
|
||||
|
||||
static const enum stm32_tamp_bkpreg_access stm32mp1_tamp_bkpreg_access[NB_ZONES_STM32MP1] = {
|
||||
[BKPREG_PROTECTION_ZONE_1] = BKP_NO,
|
||||
[BKPREG_PROTECTION_ZONE_2] = BKP_READ,
|
||||
[BKPREG_PROTECTION_ZONE_3] = BKP_READ_WRITE,
|
||||
};
|
||||
|
||||
static const enum stm32_tamp_bkpreg_access *stm32mp1_tamp_get_access_rights(struct udevice *dev)
|
||||
{
|
||||
return stm32mp1_tamp_bkpreg_access;
|
||||
}
|
||||
|
||||
static int stm32mp2_tamp_is_compartment_isolation_enabled(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
int nb_compartment_enabled = 0;
|
||||
u32 cfen;
|
||||
struct regmap_field *cfen_field;
|
||||
|
||||
for (int i = 0; i < NB_COMPARTMENT_STM32MP2; i++) {
|
||||
cfen_field = devm_regmap_field_alloc(dev,
|
||||
priv->config_regmap,
|
||||
stm32mp2_tamp_nvram_rxcidcfg_cfen_fields[i]);
|
||||
if (IS_ERR_OR_NULL(cfen_field)) {
|
||||
dev_err(dev, "Can't allocate field for reading configuration\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (regmap_field_read(cfen_field, &cfen) != 0) {
|
||||
dev_err(dev, "Can't read field for registers zones\n");
|
||||
devm_regmap_field_free(dev, cfen_field);
|
||||
return -EINVAL;
|
||||
}
|
||||
nb_compartment_enabled += cfen;
|
||||
devm_regmap_field_free(dev, cfen_field);
|
||||
}
|
||||
|
||||
if (nb_compartment_enabled == 0)
|
||||
return 0;
|
||||
else if (nb_compartment_enabled == NB_COMPARTMENT_STM32MP2)
|
||||
return 1;
|
||||
else
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static bool *stm32mp2_tamp_get_compartment_owner(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
struct regmap_field *cid_field;
|
||||
u32 cid_per_zone;
|
||||
int isolation_enabled;
|
||||
bool *compartment_owner;
|
||||
|
||||
isolation_enabled = stm32mp2_tamp_is_compartment_isolation_enabled(dev);
|
||||
if (isolation_enabled < 0)
|
||||
return NULL;
|
||||
|
||||
compartment_owner = devm_kcalloc(dev,
|
||||
NB_COMPARTMENT_STM32MP2,
|
||||
sizeof(*compartment_owner),
|
||||
GFP_KERNEL);
|
||||
if (!compartment_owner)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
for (int i = 0; i < NB_COMPARTMENT_STM32MP2; i++) {
|
||||
if (isolation_enabled) {
|
||||
cid_field = devm_regmap_field_alloc(dev,
|
||||
priv->config_regmap,
|
||||
stm32mp2_tamp_nvram_rxcidcfg_fields[i]
|
||||
);
|
||||
|
||||
if (regmap_field_read(cid_field, &cid_per_zone) != 0) {
|
||||
dev_err(dev, "Can't read field for registers zones\n");
|
||||
devm_regmap_field_free(dev, cid_field);
|
||||
devm_kfree(dev, compartment_owner);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
if (cid_per_zone == CURRENT_CID)
|
||||
compartment_owner[i] = true;
|
||||
else
|
||||
compartment_owner[i] = false;
|
||||
|
||||
devm_regmap_field_free(dev, cid_field);
|
||||
} else {
|
||||
compartment_owner[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return compartment_owner;
|
||||
}
|
||||
|
||||
static const enum stm32_tamp_bkpreg_access *stm32mp2_tamp_get_access_rights(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_drvdata *drvdata =
|
||||
(struct stm32_tamp_nvram_drvdata *)dev_get_driver_data(dev);
|
||||
unsigned int nb_zones = drvdata->nb_zones;
|
||||
bool *compartment_owner;
|
||||
enum stm32_tamp_bkpreg_access *bkpreg_access;
|
||||
|
||||
compartment_owner = stm32mp2_tamp_get_compartment_owner(dev);
|
||||
if (IS_ERR(compartment_owner))
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
bkpreg_access = devm_kcalloc(dev,
|
||||
NB_ZONES_STM32MP2,
|
||||
sizeof(*bkpreg_access),
|
||||
GFP_KERNEL);
|
||||
|
||||
for (int protection_zone_idx = 0; protection_zone_idx < nb_zones;
|
||||
protection_zone_idx++) {
|
||||
switch (protection_zone_idx) {
|
||||
case BKPREG_PROTECTION_ZONE_1_RIF1:
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
case BKPREG_PROTECTION_ZONE_1_RIF2:
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
case BKPREG_PROTECTION_ZONE_2_RIF1:
|
||||
if (compartment_owner[1] || compartment_owner[2])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ;
|
||||
else
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
case BKPREG_PROTECTION_ZONE_2_RIF2:
|
||||
if (compartment_owner[1] || compartment_owner[2])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ;
|
||||
else
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
case BKPREG_PROTECTION_ZONE_3_RIF1:
|
||||
if (compartment_owner[1])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ_WRITE;
|
||||
else if (compartment_owner[0] || compartment_owner[2])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ;
|
||||
else
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
case BKPREG_PROTECTION_ZONE_3_RIF0:
|
||||
if (compartment_owner[0])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ_WRITE;
|
||||
else if (compartment_owner[1] || compartment_owner[2])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ;
|
||||
else
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
case BKPREG_PROTECTION_ZONE_3_RIF2:
|
||||
if (compartment_owner[2])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ_WRITE;
|
||||
else if (compartment_owner[0] || compartment_owner[1])
|
||||
bkpreg_access[protection_zone_idx] = BKP_READ;
|
||||
else
|
||||
bkpreg_access[protection_zone_idx] = BKP_NO;
|
||||
break;
|
||||
default:
|
||||
devm_kfree(dev, bkpreg_access);
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
}
|
||||
|
||||
return bkpreg_access;
|
||||
}
|
||||
|
||||
static const struct stm32_tamp_nvram_drvdata stm32mp1_tamp_nvram = {
|
||||
.nb_zones = NB_ZONES_STM32MP1,
|
||||
.reg_fields = stm32mp1_tamp_nvram_zone_cfg_fields,
|
||||
.get_access = stm32mp1_tamp_get_access_rights,
|
||||
};
|
||||
|
||||
static const struct stm32_tamp_nvram_drvdata stm32mp2_tamp_nvram = {
|
||||
.nb_zones = NB_ZONES_STM32MP2,
|
||||
.reg_fields = stm32mp2_tamp_nvram_zone_cfg_fields,
|
||||
.get_access = stm32mp2_tamp_get_access_rights,
|
||||
};
|
||||
|
||||
static int stm32_tamp_nvram_bkpreg_get_zone_idx(struct udevice *dev, int reg)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
struct stm32_tamp_nvram_drvdata *drvdata =
|
||||
(struct stm32_tamp_nvram_drvdata *)dev_get_driver_data(dev);
|
||||
int *idx_bkpreg_zones_end = priv->idx_bkpreg_zones_end;
|
||||
int nb_zones = drvdata->nb_zones;
|
||||
int protection_zone_idx;
|
||||
|
||||
if (reg < 0)
|
||||
return -1; // negative reg is the boundary of an empty zone
|
||||
|
||||
for (protection_zone_idx = 0; protection_zone_idx < nb_zones; protection_zone_idx++) {
|
||||
if (reg <= idx_bkpreg_zones_end[protection_zone_idx])
|
||||
break;
|
||||
}
|
||||
|
||||
if (protection_zone_idx >= nb_zones)
|
||||
return -1; // the reg is not a part of any zone
|
||||
|
||||
return protection_zone_idx;
|
||||
}
|
||||
|
||||
static bool stm32_tamp_nvram_rights(struct udevice *dev, int reg, bool read_only)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
int protection_zone_idx = stm32_tamp_nvram_bkpreg_get_zone_idx(dev, reg);
|
||||
|
||||
if (protection_zone_idx < 0)
|
||||
return false;
|
||||
|
||||
switch (priv->bkpreg_access[protection_zone_idx]) {
|
||||
case BKP_READ_WRITE:
|
||||
return true;
|
||||
case BKP_READ:
|
||||
return read_only;
|
||||
case BKP_NO:
|
||||
return false;
|
||||
default:
|
||||
dev_err(dev, "Can't get access rights for the zone\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_write_byte(struct udevice *dev, u32 offset, u8 byte)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
int offset_aligned = ALIGN_DOWN(offset, sizeof(u32));
|
||||
int byte_in_word = offset - offset_aligned;
|
||||
u32 read_value, to_be_writen_value;
|
||||
u32 reg_idx = offset_aligned / sizeof(u32);
|
||||
|
||||
if (!stm32_tamp_nvram_rights(dev, reg_idx, false))
|
||||
return -EIO;
|
||||
|
||||
regmap_read(priv->bkpregs_regmap, offset_aligned, &read_value);
|
||||
to_be_writen_value = read_value & ~(0xFFUL << byte_in_word * 8);
|
||||
to_be_writen_value |= (u32)byte << (byte_in_word * 8);
|
||||
|
||||
return regmap_write(priv->bkpregs_regmap, offset_aligned, to_be_writen_value);
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_read_byte(struct udevice *dev, unsigned int offset, u8 *byte)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
int offset_aligned = ALIGN_DOWN(offset, sizeof(u32));
|
||||
int byte_in_word = offset - offset_aligned;
|
||||
u32 read_value;
|
||||
u32 reg_idx = offset_aligned / sizeof(u32);
|
||||
|
||||
if (!stm32_tamp_nvram_rights(dev, reg_idx, true))
|
||||
return -EIO;
|
||||
|
||||
regmap_read(priv->bkpregs_regmap, offset_aligned, &read_value);
|
||||
*byte = (read_value >> (byte_in_word * 8)) & 0xFF;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_read(struct udevice *dev, int offset, void *buf, int size)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
u8 byte;
|
||||
u8 *buf_u8 = buf;
|
||||
u32 temp_u32;
|
||||
int i, ret;
|
||||
int total = offset + size;
|
||||
u32 reg_idx;
|
||||
|
||||
i = offset;
|
||||
while (i < total) {
|
||||
reg_idx = i / sizeof(u32);
|
||||
if (i + sizeof(u32) <= total && IS_ALIGNED(i, sizeof(u32))) {
|
||||
if (!stm32_tamp_nvram_rights(dev, reg_idx, true)) {
|
||||
dev_dbg(dev, "Backup register %u is not allowed to be read\n",
|
||||
reg_idx);
|
||||
temp_u32 = 0;
|
||||
} else {
|
||||
regmap_read(priv->bkpregs_regmap, i, &temp_u32);
|
||||
}
|
||||
memcpy(buf_u8, &temp_u32, sizeof(u32));
|
||||
buf_u8 += sizeof(u32);
|
||||
i += sizeof(u32);
|
||||
} else {
|
||||
ret = stm32_tamp_nvram_read_byte(dev, i, &byte);
|
||||
if (ret != 0) {
|
||||
dev_dbg(dev, "Backup register %u is not allowed to be read\n",
|
||||
reg_idx);
|
||||
byte = 0;
|
||||
}
|
||||
*buf_u8 = byte;
|
||||
i++;
|
||||
buf_u8++;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_write(struct udevice *dev, int offset, const void *buf, int size)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
u8 *buf_u8 = (u8 *)buf;
|
||||
u32 temp_u32;
|
||||
size_t total = offset + size;
|
||||
int i, ret;
|
||||
u32 reg_idx;
|
||||
|
||||
i = offset;
|
||||
while (i < total) {
|
||||
reg_idx = i / sizeof(u32);
|
||||
if (i + sizeof(u32) <= total && IS_ALIGNED(i, sizeof(u32))) {
|
||||
if (stm32_tamp_nvram_rights(dev, reg_idx, false)) {
|
||||
memcpy(&temp_u32, buf_u8, sizeof(u32));
|
||||
regmap_write(priv->bkpregs_regmap, i, temp_u32);
|
||||
} else {
|
||||
dev_dbg(dev, "Backup register %u is not allowed to be written",
|
||||
reg_idx);
|
||||
}
|
||||
buf_u8 += sizeof(u32);
|
||||
i += sizeof(u32);
|
||||
} else {
|
||||
ret = stm32_tamp_nvram_write_byte(dev, i, *buf_u8);
|
||||
if (ret != 0)
|
||||
dev_dbg(dev, "Backup register %u is not allowed to be written",
|
||||
reg_idx);
|
||||
i++;
|
||||
buf_u8++;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static const struct misc_ops stm32_tamp_nvram_ops = {
|
||||
.read = stm32_tamp_nvram_read,
|
||||
.write = stm32_tamp_nvram_write,
|
||||
};
|
||||
|
||||
static u32 *stm32_tamp_nvram_get_backup_zones(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_plat *plat = dev_get_plat(dev);
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
const struct stm32_tamp_nvram_drvdata *drvdata =
|
||||
(struct stm32_tamp_nvram_drvdata *)dev_get_driver_data(dev);
|
||||
int nb_zones = drvdata->nb_zones;
|
||||
int zone_idx;
|
||||
int *idx_bkpreg_zones_end;
|
||||
struct regmap *tamp_regmap = priv->config_regmap;
|
||||
u32 offset_field;
|
||||
|
||||
idx_bkpreg_zones_end = devm_kcalloc(dev,
|
||||
sizeof(*idx_bkpreg_zones_end),
|
||||
nb_zones,
|
||||
GFP_KERNEL);
|
||||
if (IS_ERR_OR_NULL(idx_bkpreg_zones_end)) {
|
||||
dev_err(dev, "Can't allocate registers zones\n");
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
//Get the n-1 frontiers of zone within the tamp configuration registers
|
||||
for (zone_idx = 0; zone_idx < nb_zones - 1; zone_idx++) {
|
||||
const struct reg_field reg_field = drvdata->reg_fields[zone_idx];
|
||||
struct regmap_field *field = devm_regmap_field_alloc(dev,
|
||||
tamp_regmap,
|
||||
reg_field);
|
||||
|
||||
if (IS_ERR_OR_NULL(field)) {
|
||||
dev_err(dev, "Can't allocate registers zones\n");
|
||||
devm_kfree(dev, idx_bkpreg_zones_end);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
if (regmap_field_read(field, &offset_field) != 0) {
|
||||
dev_err(dev, "Can't read field for registers zones\n");
|
||||
devm_kfree(dev, idx_bkpreg_zones_end);
|
||||
return ERR_PTR(-EIO);
|
||||
}
|
||||
|
||||
idx_bkpreg_zones_end[zone_idx] = offset_field - 1;
|
||||
}
|
||||
|
||||
//The last zone end is defined by the number of registers in TAMP
|
||||
idx_bkpreg_zones_end[zone_idx] = plat->nb_total_regs - 1;
|
||||
|
||||
return idx_bkpreg_zones_end;
|
||||
}
|
||||
|
||||
static void stm32_tamp_nvram_print_zones(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
int *zones_end = priv->idx_bkpreg_zones_end;
|
||||
|
||||
if (device_is_compatible(dev, "st,stm32mp25-tamp-nvram")) {
|
||||
dev_dbg(dev,
|
||||
"\n"
|
||||
"Zone 1-RIF1 %3d - %3d %c%c\n"
|
||||
"Zone 1-RIF2 %3d - %3d %c%c\n"
|
||||
"Zone 2-RIF1 %3d - %3d %c%c\n"
|
||||
"Zone 2-RIF2 %3d - %3d %c%c\n"
|
||||
"Zone 3-RIF1 %3d - %3d %c%c\n"
|
||||
"Zone 3-RIF0 %3d - %3d %c%c\n"
|
||||
"Zone 3-RIF2 %3d - %3d %c%c\n",
|
||||
0, zones_end[BKPREG_PROTECTION_ZONE_1_RIF1],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_1_RIF1],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_1_RIF1],
|
||||
false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_1_RIF1] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_1_RIF2],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_1_RIF2],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_1_RIF2],
|
||||
false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_1_RIF2] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_2_RIF1],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_2_RIF1],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_2_RIF1],
|
||||
false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_2_RIF1] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_2_RIF2],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_2_RIF2],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_2_RIF2],
|
||||
false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_2_RIF2] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_3_RIF1],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3_RIF1],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3_RIF1],
|
||||
false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_3_RIF1] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_3_RIF0],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3_RIF0],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3_RIF0],
|
||||
false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_3_RIF0] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_3_RIF2],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3_RIF2],
|
||||
true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3_RIF2],
|
||||
false) ?
|
||||
'W' :
|
||||
'-');
|
||||
} else if (device_is_compatible(dev, "st,stm32mp15-tamp-nvram")) {
|
||||
dev_dbg(dev,
|
||||
"\n"
|
||||
"Zone 1 %3d - %3d %c%c\n"
|
||||
"Zone 2 %3d - %3d %c%c\n"
|
||||
"Zone 3 %3d - %3d %c%c\n",
|
||||
0, zones_end[BKPREG_PROTECTION_ZONE_1],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_1], true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_1], false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_1] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_2],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_2], true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_2], false) ?
|
||||
'W' :
|
||||
'-',
|
||||
zones_end[BKPREG_PROTECTION_ZONE_2] + 1,
|
||||
zones_end[BKPREG_PROTECTION_ZONE_3],
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3], true) ?
|
||||
'R' :
|
||||
'-',
|
||||
stm32_tamp_nvram_rights(dev, zones_end[BKPREG_PROTECTION_ZONE_3], false) ?
|
||||
'W' :
|
||||
'-');
|
||||
}
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_of_to_plat(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_plat *plat = dev_get_plat(dev);
|
||||
fdt_addr_t addr = dev_read_addr_size_index(dev, 0, &plat->size);
|
||||
fdt_addr_t parent_addr = dev_read_addr_size_index(dev->parent, 0, &plat->parent_size);
|
||||
|
||||
if (addr == FDT_ADDR_T_NONE)
|
||||
return -EINVAL;
|
||||
plat->base = (void __iomem *)addr;
|
||||
|
||||
if (parent_addr == FDT_ADDR_T_NONE)
|
||||
return -EINVAL;
|
||||
plat->parent_base = (void __iomem *)parent_addr;
|
||||
|
||||
if (plat->size == FDT_ADDR_T_NONE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
plat->nb_total_regs = plat->size / sizeof(uint32_t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_probe(struct udevice *dev)
|
||||
{
|
||||
struct stm32_tamp_nvram_plat *plat = dev_get_plat(dev);
|
||||
struct stm32_tamp_nvram_priv *priv = dev_get_priv(dev);
|
||||
struct regmap_config config_regmap;
|
||||
struct regmap_config bckreg_regmap;
|
||||
const struct stm32_tamp_nvram_drvdata *drvdata =
|
||||
(struct stm32_tamp_nvram_drvdata *)dev_get_driver_data(dev);
|
||||
|
||||
config_regmap.r_start = (ulong)(plat->parent_base);
|
||||
config_regmap.r_size = plat->parent_size;
|
||||
config_regmap.reg_offset_shift = 0;
|
||||
config_regmap.width = REGMAP_SIZE_32;
|
||||
priv->config_regmap = devm_regmap_init(dev, NULL, NULL, &config_regmap);
|
||||
|
||||
bckreg_regmap.r_start = (ulong)(plat->base);
|
||||
bckreg_regmap.r_size = plat->size;
|
||||
bckreg_regmap.reg_offset_shift = 0;
|
||||
bckreg_regmap.width = REGMAP_SIZE_32;
|
||||
priv->bkpregs_regmap = devm_regmap_init(dev, NULL, NULL, &bckreg_regmap);
|
||||
|
||||
priv->idx_bkpreg_zones_end = stm32_tamp_nvram_get_backup_zones(dev);
|
||||
if (IS_ERR_OR_NULL(priv->idx_bkpreg_zones_end)) {
|
||||
dev_err(dev, "Failed to get the backup zone from tamp regs\n\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
priv->bkpreg_access = drvdata->get_access(dev);
|
||||
stm32_tamp_nvram_print_zones(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32_tamp_nvram_remove(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct udevice_id stm32_tamp_nvram_ids[] = {
|
||||
{ .compatible = "st,stm32mp15-tamp-nvram", .data = (ulong)&stm32mp1_tamp_nvram },
|
||||
{ .compatible = "st,stm32mp25-tamp-nvram", .data = (ulong)&stm32mp2_tamp_nvram },
|
||||
{},
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(stm32_tamp_nvram) = {
|
||||
.name = "stm32_tamp_nvram",
|
||||
.id = UCLASS_MISC,
|
||||
.of_match = stm32_tamp_nvram_ids,
|
||||
.priv_auto = sizeof(struct stm32_tamp_nvram_priv),
|
||||
.plat_auto = sizeof(struct stm32_tamp_nvram_plat),
|
||||
.ops = &stm32_tamp_nvram_ops,
|
||||
.of_to_plat = of_match_ptr(stm32_tamp_nvram_of_to_plat),
|
||||
.probe = stm32_tamp_nvram_probe,
|
||||
.remove = stm32_tamp_nvram_remove,
|
||||
};
|
||||
15
board/st/stm32h747-disco/Kconfig
Normal file
15
board/st/stm32h747-disco/Kconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
if TARGET_STM32H747_DISCO
|
||||
|
||||
config SYS_BOARD
|
||||
default "stm32h747-disco"
|
||||
|
||||
config SYS_VENDOR
|
||||
default "st"
|
||||
|
||||
config SYS_SOC
|
||||
default "stm32h7"
|
||||
|
||||
config SYS_CONFIG_NAME
|
||||
default "stm32h747-disco"
|
||||
|
||||
endif
|
||||
7
board/st/stm32h747-disco/MAINTAINERS
Normal file
7
board/st/stm32h747-disco/MAINTAINERS
Normal file
@@ -0,0 +1,7 @@
|
||||
STM32H747 DISCOVERY BOARD
|
||||
M: Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
S: Maintained
|
||||
F: board/st/stm32h747-disco
|
||||
F: include/configs/stm32h747-disco.h
|
||||
F: configs/stm32h747-disco_defconfig
|
||||
F: arch/arm/dts/stm32h747*
|
||||
6
board/st/stm32h747-disco/Makefile
Normal file
6
board/st/stm32h747-disco/Makefile
Normal file
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Copyright (c) 2025 Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
#
|
||||
|
||||
obj-y := stm32h747-disco.o
|
||||
42
board/st/stm32h747-disco/stm32h747-disco.c
Normal file
42
board/st/stm32h747-disco/stm32h747-disco.c
Normal file
@@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* stm32h747i-disco support
|
||||
*
|
||||
* Copyright (C) 2025 Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <init.h>
|
||||
#include <log.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
int dram_init(void)
|
||||
{
|
||||
struct udevice *dev;
|
||||
int ret;
|
||||
|
||||
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
|
||||
if (ret) {
|
||||
debug("DRAM init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (fdtdec_setup_mem_size_base() != 0)
|
||||
ret = -EINVAL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dram_init_banksize(void)
|
||||
{
|
||||
fdtdec_setup_memory_banksize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -184,6 +184,7 @@ static const table_entry_t uimage_type[] = {
|
||||
{ IH_TYPE_RENESAS_SPKG, "spkgimage", "Renesas SPKG Image" },
|
||||
{ IH_TYPE_STARFIVE_SPL, "sfspl", "StarFive SPL Image" },
|
||||
{ IH_TYPE_TFA_BL31, "tfa-bl31", "TFA BL31 Image", },
|
||||
{ IH_TYPE_STM32IMAGE_V2, "stm32imagev2", "STMicroelectronics STM32 Image V2.0" },
|
||||
{ -1, "", "", },
|
||||
};
|
||||
|
||||
|
||||
35
configs/stm32h747-disco_defconfig
Normal file
35
configs/stm32h747-disco_defconfig
Normal file
@@ -0,0 +1,35 @@
|
||||
CONFIG_ARM=y
|
||||
CONFIG_ARCH_STM32=y
|
||||
CONFIG_TEXT_BASE=0x08000000
|
||||
CONFIG_SYS_MALLOC_LEN=0x100000
|
||||
CONFIG_NR_DRAM_BANKS=1
|
||||
CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
|
||||
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x24040000
|
||||
CONFIG_ENV_SIZE=0x2000
|
||||
CONFIG_DEFAULT_DEVICE_TREE="st/stm32h747i-disco"
|
||||
CONFIG_OF_LIBFDT_OVERLAY=y
|
||||
CONFIG_SYS_LOAD_ADDR=0xd0400000
|
||||
CONFIG_STM32H7=y
|
||||
CONFIG_TARGET_STM32H747_DISCO=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BOOTDELAY=3
|
||||
CONFIG_AUTOBOOT_KEYED=y
|
||||
CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n"
|
||||
CONFIG_AUTOBOOT_STOP_STR=" "
|
||||
CONFIG_DEFAULT_FDT_FILE="stm32h747i-disco"
|
||||
CONFIG_SYS_CBSIZE=256
|
||||
CONFIG_SYS_PBSIZE=282
|
||||
# CONFIG_DISPLAY_CPUINFO is not set
|
||||
CONFIG_SYS_PROMPT="U-Boot > "
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MMC=y
|
||||
# CONFIG_CMD_SETEXPR is not set
|
||||
CONFIG_CMD_CACHE=y
|
||||
CONFIG_CMD_TIMER=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_OF_CONTROL=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_NO_NET=y
|
||||
CONFIG_STM32_SDMMC2=y
|
||||
# CONFIG_PINCTRL_FULL is not set
|
||||
@@ -1,7 +1,7 @@
|
||||
CONFIG_ARM=y
|
||||
CONFIG_ARCH_STM32MP=y
|
||||
CONFIG_TFABOOT=y
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x180000
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x210000
|
||||
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc0400000
|
||||
CONFIG_ENV_OFFSET=0x900000
|
||||
CONFIG_DEFAULT_DEVICE_TREE="st/stm32mp135f-dk"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
CONFIG_ARM=y
|
||||
CONFIG_ARCH_STM32MP=y
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x400000
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x600000
|
||||
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x90000000
|
||||
CONFIG_ENV_OFFSET=0x900000
|
||||
CONFIG_ENV_SECT_SIZE=0x40000
|
||||
|
||||
@@ -10,6 +10,16 @@ config CLK
|
||||
feed into other clocks in a tree structure, with multiplexers to
|
||||
choose the source for each clock.
|
||||
|
||||
config CLK_AUTO_ID
|
||||
bool "Enable support of an unique clock id with several provider"
|
||||
depends on CLK
|
||||
help
|
||||
Add the uclass sequence number of clock provider in the 8 higher bits
|
||||
of the clk id to guaranty an unique clock identifier in clk uclass
|
||||
when several clock providers are present on the device and when
|
||||
default xlate are used.
|
||||
This feature limit each identifier for each clock providers (24 bits).
|
||||
|
||||
config SPL_CLK
|
||||
bool "Enable clock support in SPL"
|
||||
depends on CLK && SPL && SPL_DM
|
||||
@@ -182,6 +192,7 @@ config CLK_SCMI
|
||||
bool "Enable SCMI clock driver"
|
||||
depends on CLK
|
||||
depends on SCMI_FIRMWARE
|
||||
select CLK_AUTO_ID if CLK_CCF
|
||||
help
|
||||
Enable this option if you want to support clock devices exposed
|
||||
by a SCMI agent based on SCMI clock protocol communication
|
||||
|
||||
@@ -34,6 +34,11 @@ struct clk *dev_get_clk_ptr(struct udevice *dev)
|
||||
return (struct clk *)dev_get_uclass_priv(dev);
|
||||
}
|
||||
|
||||
ulong clk_get_id(const struct clk *clk)
|
||||
{
|
||||
return (ulong)(clk->id & CLK_ID_MSK);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||
int clk_get_by_phandle(struct udevice *dev, const struct phandle_1_arg *cells,
|
||||
struct clk *clk)
|
||||
@@ -43,7 +48,7 @@ int clk_get_by_phandle(struct udevice *dev, const struct phandle_1_arg *cells,
|
||||
ret = device_get_by_ofplat_idx(cells->idx, &clk->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
clk->id = cells->arg[0];
|
||||
clk->id = CLK_ID(dev, cells->arg[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -61,7 +66,7 @@ static int clk_of_xlate_default(struct clk *clk,
|
||||
}
|
||||
|
||||
if (args->args_count)
|
||||
clk->id = args->args[0];
|
||||
clk->id = CLK_ID(clk->dev, args->args[0]);
|
||||
else
|
||||
clk->id = 0;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev,
|
||||
dev_set_uclass_priv(dev, clk);
|
||||
|
||||
clk->dev = dev;
|
||||
clk->id = CLK_ID(dev, 0);
|
||||
clk->enable_count = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,24 +13,26 @@
|
||||
static ulong sandbox_clk_get_rate(struct clk *clk)
|
||||
{
|
||||
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
|
||||
ulong id = clk_get_id(clk);
|
||||
|
||||
if (!priv->probed)
|
||||
return -ENODEV;
|
||||
|
||||
if (clk->id >= SANDBOX_CLK_ID_COUNT)
|
||||
if (id >= SANDBOX_CLK_ID_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
return priv->rate[clk->id];
|
||||
return priv->rate[id];
|
||||
}
|
||||
|
||||
static ulong sandbox_clk_round_rate(struct clk *clk, ulong rate)
|
||||
{
|
||||
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
|
||||
ulong id = clk_get_id(clk);
|
||||
|
||||
if (!priv->probed)
|
||||
return -ENODEV;
|
||||
|
||||
if (clk->id >= SANDBOX_CLK_ID_COUNT)
|
||||
if (id >= SANDBOX_CLK_ID_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
if (!rate)
|
||||
@@ -43,18 +45,19 @@ static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate)
|
||||
{
|
||||
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
|
||||
ulong old_rate;
|
||||
ulong id = clk_get_id(clk);
|
||||
|
||||
if (!priv->probed)
|
||||
return -ENODEV;
|
||||
|
||||
if (clk->id >= SANDBOX_CLK_ID_COUNT)
|
||||
if (id >= SANDBOX_CLK_ID_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
if (!rate)
|
||||
return -EINVAL;
|
||||
|
||||
old_rate = priv->rate[clk->id];
|
||||
priv->rate[clk->id] = rate;
|
||||
old_rate = priv->rate[id];
|
||||
priv->rate[id] = rate;
|
||||
|
||||
return old_rate;
|
||||
}
|
||||
@@ -62,14 +65,15 @@ static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate)
|
||||
static int sandbox_clk_enable(struct clk *clk)
|
||||
{
|
||||
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
|
||||
ulong id = clk_get_id(clk);
|
||||
|
||||
if (!priv->probed)
|
||||
return -ENODEV;
|
||||
|
||||
if (clk->id >= SANDBOX_CLK_ID_COUNT)
|
||||
if (id >= SANDBOX_CLK_ID_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
priv->enabled[clk->id] = true;
|
||||
priv->enabled[id] = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -77,14 +81,15 @@ static int sandbox_clk_enable(struct clk *clk)
|
||||
static int sandbox_clk_disable(struct clk *clk)
|
||||
{
|
||||
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
|
||||
ulong id = clk_get_id(clk);
|
||||
|
||||
if (!priv->probed)
|
||||
return -ENODEV;
|
||||
|
||||
if (clk->id >= SANDBOX_CLK_ID_COUNT)
|
||||
if (id >= SANDBOX_CLK_ID_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
priv->enabled[clk->id] = false;
|
||||
priv->enabled[id] = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -92,11 +97,12 @@ static int sandbox_clk_disable(struct clk *clk)
|
||||
static int sandbox_clk_request(struct clk *clk)
|
||||
{
|
||||
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
|
||||
ulong id = clk_get_id(clk);
|
||||
|
||||
if (clk->id >= SANDBOX_CLK_ID_COUNT)
|
||||
if (id >= SANDBOX_CLK_ID_COUNT)
|
||||
return -EINVAL;
|
||||
|
||||
priv->requested[clk->id] = true;
|
||||
priv->requested[id] = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,47 +235,47 @@ static int sandbox_clk_ccf_probe(struct udevice *dev)
|
||||
void *base = NULL;
|
||||
u32 reg;
|
||||
|
||||
clk_dm(SANDBOX_CLK_PLL3,
|
||||
sandbox_clk_pllv3(SANDBOX_PLLV3_USB, "pll3_usb_otg", "osc",
|
||||
base + 0x10, 0x3));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_PLL3,
|
||||
sandbox_clk_pllv3(SANDBOX_PLLV3_USB, "pll3_usb_otg", "osc",
|
||||
base + 0x10, 0x3));
|
||||
|
||||
clk_dm(SANDBOX_CLK_PLL3_60M,
|
||||
sandbox_clk_fixed_factor("pll3_60m", "pll3_usb_otg", 1, 8));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_PLL3_60M,
|
||||
sandbox_clk_fixed_factor("pll3_60m", "pll3_usb_otg", 1, 8));
|
||||
|
||||
clk_dm(SANDBOX_CLK_PLL3_80M,
|
||||
sandbox_clk_fixed_factor("pll3_80m", "pll3_usb_otg", 1, 6));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_PLL3_80M,
|
||||
sandbox_clk_fixed_factor("pll3_80m", "pll3_usb_otg", 1, 6));
|
||||
|
||||
/* The HW adds +1 to the divider value (2+1) is the divider */
|
||||
reg = (2 << 19);
|
||||
clk_dm(SANDBOX_CLK_ECSPI_ROOT,
|
||||
sandbox_clk_divider("ecspi_root", "pll3_60m", ®, 19, 6));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_ECSPI_ROOT,
|
||||
sandbox_clk_divider("ecspi_root", "pll3_60m", ®, 19, 6));
|
||||
|
||||
reg = 0;
|
||||
clk_dm(SANDBOX_CLK_ECSPI0,
|
||||
sandbox_clk_gate("ecspi0", "ecspi_root", ®, 0, 0));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_ECSPI0,
|
||||
sandbox_clk_gate("ecspi0", "ecspi_root", ®, 0, 0));
|
||||
|
||||
clk_dm(SANDBOX_CLK_ECSPI1,
|
||||
sandbox_clk_gate2("ecspi1", "ecspi_root", base + 0x6c, 0));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_ECSPI1,
|
||||
sandbox_clk_gate2("ecspi1", "ecspi_root", base + 0x6c, 0));
|
||||
|
||||
/* Select 'pll3_60m' */
|
||||
reg = 0;
|
||||
clk_dm(SANDBOX_CLK_USDHC1_SEL,
|
||||
sandbox_clk_mux("usdhc1_sel", ®, 16, 1, usdhc_sels,
|
||||
ARRAY_SIZE(usdhc_sels)));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_USDHC1_SEL,
|
||||
sandbox_clk_mux("usdhc1_sel", ®, 16, 1, usdhc_sels,
|
||||
ARRAY_SIZE(usdhc_sels)));
|
||||
|
||||
/* Select 'pll3_80m' */
|
||||
reg = BIT(17);
|
||||
clk_dm(SANDBOX_CLK_USDHC2_SEL,
|
||||
sandbox_clk_mux("usdhc2_sel", ®, 17, 1, usdhc_sels,
|
||||
ARRAY_SIZE(usdhc_sels)));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_USDHC2_SEL,
|
||||
sandbox_clk_mux("usdhc2_sel", ®, 17, 1, usdhc_sels,
|
||||
ARRAY_SIZE(usdhc_sels)));
|
||||
|
||||
reg = BIT(28) | BIT(24) | BIT(16);
|
||||
clk_dm(SANDBOX_CLK_I2C,
|
||||
sandbox_clk_composite("i2c", i2c_sels, ARRAY_SIZE(i2c_sels),
|
||||
®, CLK_SET_RATE_UNGATE));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_I2C,
|
||||
sandbox_clk_composite("i2c", i2c_sels, ARRAY_SIZE(i2c_sels),
|
||||
®, CLK_SET_RATE_UNGATE));
|
||||
|
||||
clk_dm(SANDBOX_CLK_I2C_ROOT,
|
||||
sandbox_clk_gate2("i2c_root", "i2c", base + 0x7c, 0));
|
||||
dev_clk_dm(dev, SANDBOX_CLK_I2C_ROOT,
|
||||
sandbox_clk_gate2("i2c_root", "i2c", base + 0x7c, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -84,26 +84,47 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks)
|
||||
static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name,
|
||||
u32 *attr)
|
||||
{
|
||||
struct scmi_clock_priv *priv = dev_get_priv(dev);
|
||||
struct scmi_clk_attribute_in in = {
|
||||
.clock_id = clkid,
|
||||
};
|
||||
struct scmi_clk_attribute_out out;
|
||||
struct scmi_msg msg = {
|
||||
.protocol_id = SCMI_PROTOCOL_ID_CLOCK,
|
||||
.message_id = SCMI_CLOCK_ATTRIBUTES,
|
||||
.in_msg = (u8 *)&in,
|
||||
.in_msg_sz = sizeof(in),
|
||||
.out_msg = (u8 *)&out,
|
||||
.out_msg_sz = sizeof(out),
|
||||
};
|
||||
int ret;
|
||||
|
||||
ret = devm_scmi_process_msg(dev, &msg);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (priv->version >= 0x20000) {
|
||||
struct scmi_clk_attribute_out_v2 out;
|
||||
struct scmi_msg msg = {
|
||||
.protocol_id = SCMI_PROTOCOL_ID_CLOCK,
|
||||
.message_id = SCMI_CLOCK_ATTRIBUTES,
|
||||
.in_msg = (u8 *)&in,
|
||||
.in_msg_sz = sizeof(in),
|
||||
.out_msg = (u8 *)&out,
|
||||
.out_msg_sz = sizeof(out),
|
||||
};
|
||||
|
||||
*name = strdup(out.clock_name);
|
||||
*attr = out.attributes;
|
||||
ret = devm_scmi_process_msg(dev, &msg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*name = strdup(out.clock_name);
|
||||
*attr = out.attributes;
|
||||
} else {
|
||||
struct scmi_clk_attribute_out out;
|
||||
struct scmi_msg msg = {
|
||||
.protocol_id = SCMI_PROTOCOL_ID_CLOCK,
|
||||
.message_id = SCMI_CLOCK_ATTRIBUTES,
|
||||
.in_msg = (u8 *)&in,
|
||||
.in_msg_sz = sizeof(in),
|
||||
.out_msg = (u8 *)&out,
|
||||
.out_msg_sz = sizeof(out),
|
||||
};
|
||||
|
||||
ret = devm_scmi_process_msg(dev, &msg);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*name = strdup(out.clock_name);
|
||||
*attr = out.attributes;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -111,7 +132,7 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name,
|
||||
static int scmi_clk_gate(struct clk *clk, int enable)
|
||||
{
|
||||
struct scmi_clk_state_in in = {
|
||||
.clock_id = clk->id,
|
||||
.clock_id = clk_get_id(clk),
|
||||
.attributes = enable,
|
||||
};
|
||||
struct scmi_clk_state_out out;
|
||||
@@ -176,7 +197,7 @@ static int scmi_clk_disable(struct clk *clk)
|
||||
static ulong scmi_clk_get_rate(struct clk *clk)
|
||||
{
|
||||
struct scmi_clk_rate_get_in in = {
|
||||
.clock_id = clk->id,
|
||||
.clock_id = clk_get_id(clk),
|
||||
};
|
||||
struct scmi_clk_rate_get_out out;
|
||||
struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
|
||||
@@ -198,7 +219,7 @@ static ulong scmi_clk_get_rate(struct clk *clk)
|
||||
static ulong __scmi_clk_set_rate(struct clk *clk, ulong rate)
|
||||
{
|
||||
struct scmi_clk_rate_set_in in = {
|
||||
.clock_id = clk->id,
|
||||
.clock_id = clk_get_id(clk),
|
||||
.flags = SCMI_CLK_RATE_ROUND_CLOSEST,
|
||||
.rate_lsb = (u32)rate,
|
||||
.rate_msb = (u32)((u64)rate >> 32),
|
||||
@@ -257,6 +278,9 @@ static int scmi_clk_probe(struct udevice *dev)
|
||||
if (!CONFIG_IS_ENABLED(CLK_CCF))
|
||||
return 0;
|
||||
|
||||
ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK,
|
||||
&priv->version);
|
||||
|
||||
/* register CCF children: CLK UCLASS, no probed again */
|
||||
if (device_get_uclass_id(dev->parent) == UCLASS_CLK)
|
||||
return 0;
|
||||
@@ -289,7 +313,7 @@ static int scmi_clk_probe(struct udevice *dev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
clk_dm(i, &clk_scmi->clk);
|
||||
dev_clk_dm(dev, i, &clk_scmi->clk);
|
||||
|
||||
if (CLK_HAS_RESTRICTIONS(attributes)) {
|
||||
u32 perm;
|
||||
|
||||
@@ -36,3 +36,12 @@ config CLK_STM32MP13
|
||||
help
|
||||
Enable the STM32 clock (RCC) driver. Enable support for
|
||||
manipulating STM32MP13's on-SoC clocks.
|
||||
|
||||
config CLK_STM32MP25
|
||||
bool "Enable RCC clock driver for STM32MP25"
|
||||
depends on ARCH_STM32MP && CLK
|
||||
default y if STM32MP25X
|
||||
select CLK_STM32_CORE
|
||||
help
|
||||
Enable the STM32 clock (RCC) driver. Enable support for
|
||||
manipulating STM32MP25's on-SoC clocks.
|
||||
|
||||
@@ -7,3 +7,4 @@ obj-$(CONFIG_CLK_STM32F) += clk-stm32f.o
|
||||
obj-$(CONFIG_CLK_STM32H7) += clk-stm32h7.o
|
||||
obj-$(CONFIG_CLK_STM32MP1) += clk-stm32mp1.o
|
||||
obj-$(CONFIG_CLK_STM32MP13) += clk-stm32mp13.o
|
||||
obj-$(CONFIG_CLK_STM32MP25) += clk-stm32mp25.o
|
||||
|
||||
@@ -41,12 +41,13 @@ int stm32_rcc_init(struct udevice *dev,
|
||||
const struct clock_config *cfg = &data->tab_clocks[i];
|
||||
struct clk *clk = ERR_PTR(-ENOENT);
|
||||
|
||||
if (data->check_security && data->check_security(priv->base, cfg))
|
||||
if (data->check_security && data->check_security(dev, priv->base, cfg))
|
||||
continue;
|
||||
|
||||
if (cfg->setup) {
|
||||
clk = cfg->setup(dev, cfg);
|
||||
clk->id = cfg->id;
|
||||
/* set identifier of clock provider*/
|
||||
dev_clk_dm(dev, cfg->id, clk);
|
||||
} else {
|
||||
dev_err(dev, "failed to register clock %s\n", cfg->name);
|
||||
return -ENOENT;
|
||||
@@ -69,11 +70,71 @@ ulong clk_stm32_get_rate_by_name(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct clk_ops *clk_dev_ops(struct udevice *dev)
|
||||
{
|
||||
return (const struct clk_ops *)dev->driver->ops;
|
||||
}
|
||||
|
||||
static int stm32_clk_endisable(struct clk *clk, bool enable)
|
||||
{
|
||||
const struct clk_ops *ops;
|
||||
struct clk *c = NULL;
|
||||
|
||||
if (!clk->id || clk_get_by_id(clk->id, &c))
|
||||
return -ENOENT;
|
||||
|
||||
ops = clk_dev_ops(c->dev);
|
||||
if (!ops->enable || !ops->disable)
|
||||
return 0;
|
||||
|
||||
return enable ? ops->enable(c) : ops->disable(c);
|
||||
}
|
||||
|
||||
static int stm32_clk_enable(struct clk *clk)
|
||||
{
|
||||
return stm32_clk_endisable(clk, true);
|
||||
}
|
||||
|
||||
static int stm32_clk_disable(struct clk *clk)
|
||||
{
|
||||
return stm32_clk_endisable(clk, false);
|
||||
}
|
||||
|
||||
static ulong stm32_clk_get_rate(struct clk *clk)
|
||||
{
|
||||
const struct clk_ops *ops;
|
||||
struct clk *c = NULL;
|
||||
|
||||
if (!clk->id || clk_get_by_id(clk->id, &c))
|
||||
return -ENOENT;
|
||||
|
||||
ops = clk_dev_ops(c->dev);
|
||||
if (!ops->get_rate)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->get_rate(c);
|
||||
}
|
||||
|
||||
static ulong stm32_clk_set_rate(struct clk *clk, unsigned long clk_rate)
|
||||
{
|
||||
const struct clk_ops *ops;
|
||||
struct clk *c = NULL;
|
||||
|
||||
if (!clk->id || clk_get_by_id(clk->id, &c))
|
||||
return -ENOENT;
|
||||
|
||||
ops = clk_dev_ops(c->dev);
|
||||
if (!ops->set_rate)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->set_rate(c, clk_rate);
|
||||
}
|
||||
|
||||
const struct clk_ops stm32_clk_ops = {
|
||||
.enable = ccf_clk_enable,
|
||||
.disable = ccf_clk_disable,
|
||||
.get_rate = ccf_clk_get_rate,
|
||||
.set_rate = ccf_clk_set_rate,
|
||||
.enable = stm32_clk_enable,
|
||||
.disable = stm32_clk_disable,
|
||||
.get_rate = stm32_clk_get_rate,
|
||||
.set_rate = stm32_clk_set_rate,
|
||||
};
|
||||
|
||||
#define RCC_MP_ENCLRR_OFFSET 4
|
||||
|
||||
@@ -127,7 +127,7 @@ struct stm32_clock_match_data {
|
||||
unsigned int num_clocks;
|
||||
const struct clock_config *tab_clocks;
|
||||
const struct clk_stm32_clock_data *clock_data;
|
||||
int (*check_security)(void __iomem *base,
|
||||
int (*check_security)(struct udevice *dev, void __iomem *base,
|
||||
const struct clock_config *cfg);
|
||||
};
|
||||
|
||||
@@ -144,6 +144,7 @@ struct stm32mp_rcc_priv {
|
||||
void __iomem *base;
|
||||
u8 *gate_cpt;
|
||||
const struct clk_stm32_clock_data *data;
|
||||
struct clk osc_clk[6];
|
||||
};
|
||||
|
||||
int stm32_rcc_init(struct udevice *dev,
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
#define QSPISRC_PER_CK 3
|
||||
|
||||
#define PWR_CR3 0x0c
|
||||
#define PWR_CR3_LDOEN BIT(1)
|
||||
#define PWR_CR3_SCUEN BIT(2)
|
||||
#define PWR_D3CR 0x18
|
||||
#define PWR_D3CR_VOS_MASK GENMASK(15, 14)
|
||||
@@ -375,7 +376,11 @@ int configure_clocks(struct udevice *dev)
|
||||
clrsetbits_le32(pwr_base + PWR_D3CR, PWR_D3CR_VOS_MASK,
|
||||
VOS_SCALE_1 << PWR_D3CR_VOS_SHIFT);
|
||||
/* Lock supply configuration update */
|
||||
#if IS_ENABLED(CONFIG_TARGET_STM32H747_DISCO)
|
||||
clrbits_le32(pwr_base + PWR_CR3, PWR_CR3_LDOEN);
|
||||
#else
|
||||
clrbits_le32(pwr_base + PWR_CR3, PWR_CR3_SCUEN);
|
||||
#endif
|
||||
while (!(readl(pwr_base + PWR_D3CR) & PWR_D3CR_VOSREADY))
|
||||
;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
782
drivers/clk/stm32/clk-stm32mp25.c
Normal file
782
drivers/clk/stm32/clk-stm32mp25.c
Normal file
@@ -0,0 +1,782 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
|
||||
/*
|
||||
* Copyright (C) 2022, STMicroelectronics - All Rights Reserved
|
||||
*/
|
||||
|
||||
#include <clk-uclass.h>
|
||||
#include <dm.h>
|
||||
#include <dt-bindings/clock/st,stm32mp25-rcc.h>
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/io.h>
|
||||
#include <mach/rif.h>
|
||||
|
||||
#include "clk-stm32-core.h"
|
||||
#include "stm32mp25_rcc.h"
|
||||
|
||||
/* Clock security definition */
|
||||
#define SECF_NONE -1
|
||||
|
||||
#define RCC_REG_SIZE 32
|
||||
#define RCC_SECCFGR(x) (((x) / RCC_REG_SIZE) * 0x4 + RCC_SECCFGR0)
|
||||
#define RCC_CIDCFGR(x) ((x) * 0x8 + RCC_R0CIDCFGR)
|
||||
#define RCC_SEMCR(x) ((x) * 0x8 + RCC_R0SEMCR)
|
||||
#define RCC_CID1 1
|
||||
|
||||
/* Register: RIFSC_CIDCFGR */
|
||||
#define RCC_CIDCFGR_CFEN BIT(0)
|
||||
#define RCC_CIDCFGR_SEM_EN BIT(1)
|
||||
#define RCC_CIDCFGR_SEMWLC1_EN BIT(17)
|
||||
#define RCC_CIDCFGR_SCID_MASK GENMASK(6, 4)
|
||||
|
||||
/* Register: RIFSC_SEMCR */
|
||||
#define RCC_SEMCR_SEMCID_MASK GENMASK(6, 4)
|
||||
|
||||
#define STM32MP25_RIFRCC_DBG_ID 73
|
||||
#define STM32MP25_RIFRCC_IS2M_ID 107
|
||||
#define STM32MP25_RIFRCC_MCO1_ID 108
|
||||
#define STM32MP25_RIFRCC_MCO2_ID 109
|
||||
#define STM32MP25_RIFRCC_OSPI1_ID 110
|
||||
#define STM32MP25_RIFRCC_OSPI2_ID 111
|
||||
|
||||
#define SEC_RIFSC_FLAG BIT(31)
|
||||
#define SEC_RIFRCC(_id) (STM32MP25_RIFRCC_##_id##_ID)
|
||||
#define SEC_RIFSC(_id) ((_id) | SEC_RIFSC_FLAG)
|
||||
|
||||
static const char * const adc12_src[] = {
|
||||
"ck_flexgen_46", "ck_icn_ls_mcu"
|
||||
};
|
||||
|
||||
static const char * const adc3_src[] = {
|
||||
"ck_flexgen_47", "ck_icn_ls_mcu", "ck_flexgen_46"
|
||||
};
|
||||
|
||||
static const char * const usb2phy1_src[] = {
|
||||
"ck_flexgen_57", "hse_div2_ck"
|
||||
};
|
||||
|
||||
static const char * const usb2phy2_src[] = {
|
||||
"ck_flexgen_58", "hse_div2_ck"
|
||||
};
|
||||
|
||||
static const char * const usb3pciphy_src[] = {
|
||||
"ck_flexgen_34", "hse_div2_ck"
|
||||
};
|
||||
|
||||
static const char * const dsiblane_src[] = {
|
||||
"txbyteclk", "ck_ker_ltdc"
|
||||
};
|
||||
|
||||
static const char * const dsiphy_src[] = {
|
||||
"ck_flexgen_28", "hse_ck"
|
||||
};
|
||||
|
||||
static const char * const lvdsphy_src[] = {
|
||||
"ck_flexgen_32", "hse_ck"
|
||||
};
|
||||
|
||||
static const char * const dts_src[] = {
|
||||
"hsi_ck", "hse_ck", "msi_ck"
|
||||
};
|
||||
|
||||
static const char * const mco1_src[] = {
|
||||
"ck_flexgen_61", "ck_obs0"
|
||||
};
|
||||
|
||||
static const char * const mco2_src[] = {
|
||||
"ck_flexgen_62", "ck_obs1"
|
||||
};
|
||||
|
||||
enum enum_mux_cfg {
|
||||
MUX_MCO1,
|
||||
MUX_MCO2,
|
||||
MUX_ADC12,
|
||||
MUX_ADC3,
|
||||
MUX_USB2PHY1,
|
||||
MUX_USB2PHY2,
|
||||
MUX_USB3PCIEPHY,
|
||||
MUX_DSIBLANE,
|
||||
MUX_DSIPHY,
|
||||
MUX_LVDSPHY,
|
||||
MUX_DTS,
|
||||
MUX_NB
|
||||
};
|
||||
|
||||
#define MUX_CFG(id, src, _offset, _shift, _witdh)[id] = {\
|
||||
.num_parents = ARRAY_SIZE(src),\
|
||||
.parent_names = src,\
|
||||
.reg_off = (_offset),\
|
||||
.shift = (_shift),\
|
||||
.width = (_witdh),\
|
||||
}
|
||||
|
||||
static const struct stm32_mux_cfg stm32mp25_muxes[MUX_NB] = {
|
||||
MUX_CFG(MUX_ADC12, adc12_src, RCC_ADC12CFGR, 12, 1),
|
||||
MUX_CFG(MUX_ADC3, adc3_src, RCC_ADC3CFGR, 12, 2),
|
||||
MUX_CFG(MUX_DSIBLANE, dsiblane_src, RCC_DSICFGR, 12, 1),
|
||||
MUX_CFG(MUX_DSIPHY, dsiphy_src, RCC_DSICFGR, 15, 1),
|
||||
MUX_CFG(MUX_DTS, dts_src, RCC_DTSCFGR, 12, 2),
|
||||
MUX_CFG(MUX_MCO1, mco1_src, RCC_MCO1CFGR, 0, 1),
|
||||
MUX_CFG(MUX_MCO2, mco2_src, RCC_MCO2CFGR, 0, 1),
|
||||
MUX_CFG(MUX_LVDSPHY, lvdsphy_src, RCC_LVDSCFGR, 15, 1),
|
||||
MUX_CFG(MUX_USB2PHY1, usb2phy1_src, RCC_USB2PHY1CFGR, 15, 1),
|
||||
MUX_CFG(MUX_USB2PHY2, usb2phy2_src, RCC_USB2PHY2CFGR, 15, 1),
|
||||
MUX_CFG(MUX_USB3PCIEPHY, usb3pciphy_src, RCC_USB3PCIEPHYCFGR, 15, 1),
|
||||
};
|
||||
|
||||
enum enum_gate_cfg {
|
||||
GATE_ADC12,
|
||||
GATE_ADC3,
|
||||
GATE_ADF1,
|
||||
GATE_CCI,
|
||||
GATE_CRC,
|
||||
GATE_CRYP1,
|
||||
GATE_CRYP2,
|
||||
GATE_CSI,
|
||||
GATE_DBG,
|
||||
GATE_DCMIPP,
|
||||
GATE_DSI,
|
||||
GATE_DTS,
|
||||
GATE_ETH1,
|
||||
GATE_ETH1MAC,
|
||||
GATE_ETH1RX,
|
||||
GATE_ETH1STP,
|
||||
GATE_ETH1TX,
|
||||
GATE_ETH2,
|
||||
GATE_ETH2MAC,
|
||||
GATE_ETH2RX,
|
||||
GATE_ETH2STP,
|
||||
GATE_ETH2TX,
|
||||
GATE_ETHSW,
|
||||
GATE_ETHSWMAC,
|
||||
GATE_ETHSWREF,
|
||||
GATE_ETR,
|
||||
GATE_FDCAN,
|
||||
GATE_GPU,
|
||||
GATE_HASH,
|
||||
GATE_HDP,
|
||||
GATE_I2C1,
|
||||
GATE_I2C2,
|
||||
GATE_I2C3,
|
||||
GATE_I2C4,
|
||||
GATE_I2C5,
|
||||
GATE_I2C6,
|
||||
GATE_I2C7,
|
||||
GATE_I2C8,
|
||||
GATE_I3C1,
|
||||
GATE_I3C2,
|
||||
GATE_I3C3,
|
||||
GATE_I3C4,
|
||||
GATE_IS2M,
|
||||
GATE_IWDG1,
|
||||
GATE_IWDG2,
|
||||
GATE_IWDG3,
|
||||
GATE_IWDG4,
|
||||
GATE_IWDG5,
|
||||
GATE_LPTIM1,
|
||||
GATE_LPTIM2,
|
||||
GATE_LPTIM3,
|
||||
GATE_LPTIM4,
|
||||
GATE_LPTIM5,
|
||||
GATE_LPUART1,
|
||||
GATE_LTDC,
|
||||
GATE_LVDS,
|
||||
GATE_MCO1,
|
||||
GATE_MCO2,
|
||||
GATE_MDF1,
|
||||
GATE_OSPI1,
|
||||
GATE_OSPI2,
|
||||
GATE_OSPIIOM,
|
||||
GATE_PCIE,
|
||||
GATE_PKA,
|
||||
GATE_RNG,
|
||||
GATE_SAES,
|
||||
GATE_SAI1,
|
||||
GATE_SAI2,
|
||||
GATE_SAI3,
|
||||
GATE_SAI4,
|
||||
GATE_SDMMC1,
|
||||
GATE_SDMMC2,
|
||||
GATE_SDMMC3,
|
||||
GATE_SERC,
|
||||
GATE_SPDIFRX,
|
||||
GATE_SPI1,
|
||||
GATE_SPI2,
|
||||
GATE_SPI3,
|
||||
GATE_SPI4,
|
||||
GATE_SPI5,
|
||||
GATE_SPI6,
|
||||
GATE_SPI7,
|
||||
GATE_SPI8,
|
||||
GATE_STGEN,
|
||||
GATE_STM500,
|
||||
GATE_TIM1,
|
||||
GATE_TIM2,
|
||||
GATE_TIM3,
|
||||
GATE_TIM4,
|
||||
GATE_TIM5,
|
||||
GATE_TIM6,
|
||||
GATE_TIM7,
|
||||
GATE_TIM8,
|
||||
GATE_TIM10,
|
||||
GATE_TIM11,
|
||||
GATE_TIM12,
|
||||
GATE_TIM13,
|
||||
GATE_TIM14,
|
||||
GATE_TIM15,
|
||||
GATE_TIM16,
|
||||
GATE_TIM17,
|
||||
GATE_TIM20,
|
||||
GATE_TRACE,
|
||||
GATE_UART4,
|
||||
GATE_UART5,
|
||||
GATE_UART7,
|
||||
GATE_UART8,
|
||||
GATE_UART9,
|
||||
GATE_USART1,
|
||||
GATE_USART2,
|
||||
GATE_USART3,
|
||||
GATE_USART6,
|
||||
GATE_USBH,
|
||||
GATE_USB2PHY1,
|
||||
GATE_USB2PHY2,
|
||||
GATE_USB3DR,
|
||||
GATE_USB3PCIEPHY,
|
||||
GATE_USBTC,
|
||||
GATE_VDEC,
|
||||
GATE_VENC,
|
||||
GATE_VREF,
|
||||
GATE_WWDG1,
|
||||
GATE_WWDG2,
|
||||
GATE_NB
|
||||
};
|
||||
|
||||
#define GATE_CFG(id, _offset, _bit_idx, _offset_clr)[id] = {\
|
||||
.reg_off = (_offset),\
|
||||
.bit_idx = (_bit_idx),\
|
||||
.set_clr = (_offset_clr),\
|
||||
}
|
||||
|
||||
static const struct stm32_gate_cfg stm32mp25_gates[GATE_NB] = {
|
||||
GATE_CFG(GATE_MCO1, RCC_MCO1CFGR, 8, 0),
|
||||
GATE_CFG(GATE_MCO2, RCC_MCO2CFGR, 8, 0),
|
||||
GATE_CFG(GATE_OSPI1, RCC_OSPI1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_OSPI2, RCC_OSPI2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_DBG, RCC_DBGCFGR, 8, 0),
|
||||
GATE_CFG(GATE_TRACE, RCC_DBGCFGR, 9, 0),
|
||||
GATE_CFG(GATE_STM500, RCC_STM500CFGR, 1, 0),
|
||||
GATE_CFG(GATE_ETR, RCC_ETRCFGR, 1, 0),
|
||||
GATE_CFG(GATE_IS2M, RCC_IS2MCFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM1, RCC_TIM1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM2, RCC_TIM2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM3, RCC_TIM3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM4, RCC_TIM4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM5, RCC_TIM5CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM6, RCC_TIM6CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM7, RCC_TIM7CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM8, RCC_TIM8CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM10, RCC_TIM10CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM11, RCC_TIM11CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM12, RCC_TIM12CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM13, RCC_TIM13CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM14, RCC_TIM14CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM15, RCC_TIM15CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM16, RCC_TIM16CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM17, RCC_TIM17CFGR, 1, 0),
|
||||
GATE_CFG(GATE_TIM20, RCC_TIM20CFGR, 1, 0),
|
||||
GATE_CFG(GATE_LPTIM1, RCC_LPTIM1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_LPTIM2, RCC_LPTIM2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_LPTIM3, RCC_LPTIM3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_LPTIM4, RCC_LPTIM4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_LPTIM5, RCC_LPTIM5CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI1, RCC_SPI1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI2, RCC_SPI2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI3, RCC_SPI3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI4, RCC_SPI4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI5, RCC_SPI5CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI6, RCC_SPI6CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI7, RCC_SPI7CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPI8, RCC_SPI8CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SPDIFRX, RCC_SPDIFRXCFGR, 1, 0),
|
||||
GATE_CFG(GATE_USART1, RCC_USART1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_USART2, RCC_USART2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_USART3, RCC_USART3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_UART4, RCC_UART4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_UART5, RCC_UART5CFGR, 1, 0),
|
||||
GATE_CFG(GATE_USART6, RCC_USART6CFGR, 1, 0),
|
||||
GATE_CFG(GATE_UART7, RCC_UART7CFGR, 1, 0),
|
||||
GATE_CFG(GATE_UART8, RCC_UART8CFGR, 1, 0),
|
||||
GATE_CFG(GATE_UART9, RCC_UART9CFGR, 1, 0),
|
||||
GATE_CFG(GATE_LPUART1, RCC_LPUART1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C1, RCC_I2C1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C2, RCC_I2C2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C3, RCC_I2C3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C4, RCC_I2C4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C5, RCC_I2C5CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C6, RCC_I2C6CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C7, RCC_I2C7CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I2C8, RCC_I2C8CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SAI1, RCC_SAI1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SAI2, RCC_SAI2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SAI3, RCC_SAI3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SAI4, RCC_SAI4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_MDF1, RCC_MDF1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_ADF1, RCC_ADF1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_FDCAN, RCC_FDCANCFGR, 1, 0),
|
||||
GATE_CFG(GATE_HDP, RCC_HDPCFGR, 1, 0),
|
||||
GATE_CFG(GATE_ADC12, RCC_ADC12CFGR, 1, 0),
|
||||
GATE_CFG(GATE_ADC3, RCC_ADC3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_ETH1MAC, RCC_ETH1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_ETH1STP, RCC_ETH1CFGR, 4, 0),
|
||||
GATE_CFG(GATE_ETH1, RCC_ETH1CFGR, 5, 0),
|
||||
GATE_CFG(GATE_ETH1TX, RCC_ETH1CFGR, 8, 0),
|
||||
GATE_CFG(GATE_ETH1RX, RCC_ETH1CFGR, 10, 0),
|
||||
GATE_CFG(GATE_ETH2MAC, RCC_ETH2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_ETH2STP, RCC_ETH2CFGR, 4, 0),
|
||||
GATE_CFG(GATE_ETH2, RCC_ETH2CFGR, 5, 0),
|
||||
GATE_CFG(GATE_ETH2TX, RCC_ETH2CFGR, 8, 0),
|
||||
GATE_CFG(GATE_ETH2RX, RCC_ETH2CFGR, 10, 0),
|
||||
GATE_CFG(GATE_USBH, RCC_USBHCFGR, 1, 0),
|
||||
GATE_CFG(GATE_USB2PHY1, RCC_USB2PHY1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_USB2PHY2, RCC_USB2PHY2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_USB3DR, RCC_USB3DRCFGR, 1, 0),
|
||||
GATE_CFG(GATE_USB3PCIEPHY, RCC_USB3PCIEPHYCFGR, 1, 0),
|
||||
GATE_CFG(GATE_PCIE, RCC_PCIECFGR, 1, 0),
|
||||
GATE_CFG(GATE_USBTC, RCC_UCPDCFGR, 1, 0),
|
||||
GATE_CFG(GATE_ETHSWMAC, RCC_ETHSWCFGR, 1, 0),
|
||||
GATE_CFG(GATE_ETHSW, RCC_ETHSWCFGR, 5, 0),
|
||||
GATE_CFG(GATE_ETHSWREF, RCC_ETHSWCFGR, 21, 0),
|
||||
GATE_CFG(GATE_STGEN, RCC_STGENCFGR, 1, 0),
|
||||
GATE_CFG(GATE_SDMMC1, RCC_SDMMC1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SDMMC2, RCC_SDMMC2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_SDMMC3, RCC_SDMMC3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_GPU, RCC_GPUCFGR, 1, 0),
|
||||
GATE_CFG(GATE_LTDC, RCC_LTDCCFGR, 1, 0),
|
||||
GATE_CFG(GATE_DSI, RCC_DSICFGR, 1, 0),
|
||||
GATE_CFG(GATE_LVDS, RCC_LVDSCFGR, 1, 0),
|
||||
GATE_CFG(GATE_CSI, RCC_CSICFGR, 1, 0),
|
||||
GATE_CFG(GATE_DCMIPP, RCC_DCMIPPCFGR, 1, 0),
|
||||
GATE_CFG(GATE_CCI, RCC_CCICFGR, 1, 0),
|
||||
GATE_CFG(GATE_VDEC, RCC_VDECCFGR, 1, 0),
|
||||
GATE_CFG(GATE_VENC, RCC_VENCCFGR, 1, 0),
|
||||
GATE_CFG(GATE_RNG, RCC_RNGCFGR, 1, 0),
|
||||
GATE_CFG(GATE_PKA, RCC_PKACFGR, 1, 0),
|
||||
GATE_CFG(GATE_SAES, RCC_SAESCFGR, 1, 0),
|
||||
GATE_CFG(GATE_HASH, RCC_HASHCFGR, 1, 0),
|
||||
GATE_CFG(GATE_CRYP1, RCC_CRYP1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_CRYP2, RCC_CRYP2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_IWDG1, RCC_IWDG1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_IWDG2, RCC_IWDG2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_IWDG3, RCC_IWDG3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_IWDG4, RCC_IWDG4CFGR, 1, 0),
|
||||
GATE_CFG(GATE_IWDG5, RCC_IWDG5CFGR, 1, 0),
|
||||
GATE_CFG(GATE_WWDG1, RCC_WWDG1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_WWDG2, RCC_WWDG2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_VREF, RCC_VREFCFGR, 1, 0),
|
||||
GATE_CFG(GATE_DTS, RCC_DTSCFGR, 1, 0),
|
||||
GATE_CFG(GATE_CRC, RCC_CRCCFGR, 1, 0),
|
||||
GATE_CFG(GATE_SERC, RCC_SERCCFGR, 1, 0),
|
||||
GATE_CFG(GATE_OSPIIOM, RCC_OSPIIOMCFGR, 1, 0),
|
||||
GATE_CFG(GATE_I3C1, RCC_I3C1CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I3C2, RCC_I3C2CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I3C3, RCC_I3C3CFGR, 1, 0),
|
||||
GATE_CFG(GATE_I3C4, RCC_I3C4CFGR, 1, 0),
|
||||
};
|
||||
|
||||
static int stm32_rcc_get_access(struct udevice *dev, u32 index)
|
||||
{
|
||||
fdt_addr_t rcc_base = dev_read_addr(dev->parent);
|
||||
u32 seccfgr, cidcfgr, semcr;
|
||||
int bit, cid;
|
||||
|
||||
bit = index % RCC_REG_SIZE;
|
||||
|
||||
seccfgr = readl(rcc_base + RCC_SECCFGR(index));
|
||||
if (seccfgr & BIT(bit))
|
||||
return -EACCES;
|
||||
|
||||
cidcfgr = readl(rcc_base + RCC_CIDCFGR(index));
|
||||
if (!(cidcfgr & RCC_CIDCFGR_CFEN))
|
||||
/* CID filtering is turned off: access granted */
|
||||
return 0;
|
||||
|
||||
if (!(cidcfgr & RCC_CIDCFGR_SEM_EN)) {
|
||||
/* Static CID mode */
|
||||
cid = FIELD_GET(RCC_CIDCFGR_SCID_MASK, cidcfgr);
|
||||
if (cid != RCC_CID1)
|
||||
return -EACCES;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Pass-list with semaphore mode */
|
||||
if (!(cidcfgr & RCC_CIDCFGR_SEMWLC1_EN))
|
||||
return -EACCES;
|
||||
|
||||
semcr = readl(rcc_base + RCC_SEMCR(index));
|
||||
|
||||
cid = FIELD_GET(RCC_SEMCR_SEMCID_MASK, semcr);
|
||||
if (cid != RCC_CID1)
|
||||
return -EACCES;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32mp25_check_security(struct udevice *dev, void __iomem *base,
|
||||
const struct clock_config *cfg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (cfg->sec_id != SECF_NONE) {
|
||||
u32 index = (u32)cfg->sec_id;
|
||||
|
||||
if (index & SEC_RIFSC_FLAG)
|
||||
ret = stm32_rifsc_check_access_by_id(dev_ofnode(dev),
|
||||
index & ~SEC_RIFSC_FLAG);
|
||||
else
|
||||
ret = stm32_rcc_get_access(dev, index);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#define STM32_COMPOSITE_NODIV(_id, _name, _flags, _sec_id, _gate_id, _mux_id)\
|
||||
STM32_COMPOSITE(_id, _name, _flags, _sec_id, _gate_id, _mux_id, NO_STM32_DIV)
|
||||
|
||||
static const struct clock_config stm32mp25_clock_cfg[] = {
|
||||
/* ADC */
|
||||
STM32_GATE(CK_BUS_ADC12, "ck_icn_p_adc12", "ck_icn_ls_mcu", 0, GATE_ADC12,
|
||||
SEC_RIFSC(58)),
|
||||
STM32_COMPOSITE_NODIV(CK_KER_ADC12, "ck_ker_adc12", 0, SEC_RIFSC(58),
|
||||
GATE_ADC12, MUX_ADC12),
|
||||
STM32_GATE(CK_BUS_ADC3, "ck_icn_p_adc3", "ck_icn_ls_mcu", 0, GATE_ADC3, SEC_RIFSC(59)),
|
||||
STM32_COMPOSITE_NODIV(CK_KER_ADC3, "ck_ker_adc3", 0, SEC_RIFSC(59), GATE_ADC3, MUX_ADC3),
|
||||
|
||||
/* ADF */
|
||||
STM32_GATE(CK_BUS_ADF1, "ck_icn_p_adf1", "ck_icn_ls_mcu", 0, GATE_ADF1, SEC_RIFSC(55)),
|
||||
STM32_GATE(CK_KER_ADF1, "ck_ker_adf1", "ck_flexgen_42", 0, GATE_ADF1, SEC_RIFSC(55)),
|
||||
|
||||
/* Camera */
|
||||
/* DCMI */
|
||||
STM32_GATE(CK_BUS_CCI, "ck_icn_p_cci", "ck_icn_ls_mcu", 0, GATE_CCI, SEC_RIFSC(88)),
|
||||
|
||||
/* CSI-HOST */
|
||||
STM32_GATE(CK_BUS_CSI, "ck_icn_p_csi", "ck_icn_apb4", 0, GATE_CSI, SEC_RIFSC(86)),
|
||||
STM32_GATE(CK_KER_CSI, "ck_ker_csi", "ck_flexgen_29", 0, GATE_CSI, SEC_RIFSC(86)),
|
||||
STM32_GATE(CK_KER_CSITXESC, "ck_ker_csitxesc", "ck_flexgen_30", 0, GATE_CSI,
|
||||
SEC_RIFSC(86)),
|
||||
|
||||
/* CSI-PHY */
|
||||
STM32_GATE(CK_KER_CSIPHY, "ck_ker_csiphy", "ck_flexgen_31", 0, GATE_CSI,
|
||||
SEC_RIFSC(86)),
|
||||
|
||||
/* DCMIPP */
|
||||
STM32_GATE(CK_BUS_DCMIPP, "ck_icn_p_dcmipp", "ck_icn_apb4", 0, GATE_DCMIPP,
|
||||
SEC_RIFSC(87)),
|
||||
|
||||
/* CRC */
|
||||
STM32_GATE(CK_BUS_CRC, "ck_icn_p_crc", "ck_icn_ls_mcu", 0, GATE_CRC, SEC_RIFSC(109)),
|
||||
|
||||
/* CRYP */
|
||||
STM32_GATE(CK_BUS_CRYP1, "ck_icn_p_cryp1", "ck_icn_ls_mcu", 0, GATE_CRYP1,
|
||||
SEC_RIFSC(96)),
|
||||
STM32_GATE(CK_BUS_CRYP2, "ck_icn_p_cryp2", "ck_icn_ls_mcu", 0, GATE_CRYP2,
|
||||
SEC_RIFSC(97)),
|
||||
|
||||
/* DBG & TRACE*/
|
||||
/* Trace and debug clocks are managed by SCMI */
|
||||
|
||||
/* Display subsystem */
|
||||
/* LTDC */
|
||||
STM32_GATE(CK_BUS_LTDC, "ck_icn_p_ltdc", "ck_icn_apb4", 0, GATE_LTDC, SEC_RIFSC(80)),
|
||||
STM32_GATE(CK_KER_LTDC, "ck_ker_ltdc", "ck_flexgen_27", CLK_SET_RATE_PARENT, GATE_LTDC,
|
||||
SEC_RIFSC(80)),
|
||||
|
||||
/* DSI */
|
||||
STM32_GATE(CK_BUS_DSI, "ck_icn_p_dsi", "ck_icn_apb4", 0, GATE_DSI, SEC_RIFSC(81)),
|
||||
STM32_COMPOSITE_NODIV(CK_KER_DSIBLANE, "clk_lanebyte", 0, SEC_RIFSC(81),
|
||||
GATE_DSI, MUX_DSIBLANE),
|
||||
|
||||
/* LVDS */
|
||||
STM32_GATE(CK_BUS_LVDS, "ck_icn_p_lvds", "ck_icn_apb4", 0, GATE_LVDS, SEC_RIFSC(84)),
|
||||
|
||||
/* DSI PHY */
|
||||
STM32_COMPOSITE_NODIV(CK_KER_DSIPHY, "ck_ker_dsiphy", 0, SEC_RIFSC(81),
|
||||
GATE_DSI, MUX_DSIPHY),
|
||||
|
||||
/* LVDS PHY */
|
||||
STM32_COMPOSITE_NODIV(CK_KER_LVDSPHY, "ck_ker_lvdsphy", 0, SEC_RIFSC(84),
|
||||
GATE_LVDS, MUX_LVDSPHY),
|
||||
|
||||
/* DTS */
|
||||
STM32_COMPOSITE_NODIV(CK_KER_DTS, "ck_ker_dts", 0, SEC_RIFSC(107), GATE_DTS, MUX_DTS),
|
||||
|
||||
/* ETHERNET */
|
||||
STM32_GATE(CK_BUS_ETH1, "ck_icn_p_eth1", "ck_icn_ls_mcu", 0, GATE_ETH1, SEC_RIFSC(60)),
|
||||
STM32_GATE(CK_ETH1_STP, "ck_ker_eth1stp", "ck_icn_ls_mcu", 0, GATE_ETH1STP,
|
||||
SEC_RIFSC(60)),
|
||||
STM32_GATE(CK_KER_ETH1, "ck_ker_eth1", "ck_flexgen_54", 0, GATE_ETH1, SEC_RIFSC(60)),
|
||||
STM32_GATE(CK_KER_ETH1, "ck_ker_eth1ptp", "ck_flexgen_56", 0, GATE_ETH1, SEC_RIFSC(60)),
|
||||
STM32_GATE(CK_ETH1_MAC, "ck_ker_eth1mac", "ck_icn_ls_mcu", 0, GATE_ETH1MAC,
|
||||
SEC_RIFSC(60)),
|
||||
STM32_GATE(CK_ETH1_TX, "ck_ker_eth1tx", "ck_icn_ls_mcu", 0, GATE_ETH1TX, SEC_RIFSC(60)),
|
||||
STM32_GATE(CK_ETH1_RX, "ck_ker_eth1rx", "ck_icn_ls_mcu", 0, GATE_ETH1RX, SEC_RIFSC(60)),
|
||||
|
||||
STM32_GATE(CK_BUS_ETH2, "ck_icn_p_eth2", "ck_icn_ls_mcu", 0, GATE_ETH2, SEC_RIFSC(61)),
|
||||
STM32_GATE(CK_ETH2_STP, "ck_ker_eth2stp", "ck_icn_ls_mcu", 0, GATE_ETH2STP,
|
||||
SEC_RIFSC(61)),
|
||||
STM32_GATE(CK_KER_ETH2, "ck_ker_eth2", "ck_flexgen_54", 0, GATE_ETH2, SEC_RIFSC(61)),
|
||||
STM32_GATE(CK_KER_ETH2, "ck_ker_eth2ptp", "ck_flexgen_56", 0, GATE_ETH2, SEC_RIFSC(61)),
|
||||
STM32_GATE(CK_ETH2_MAC, "ck_ker_eth2mac", "ck_icn_ls_mcu", 0, GATE_ETH2MAC,
|
||||
SEC_RIFSC(61)),
|
||||
STM32_GATE(CK_ETH2_TX, "ck_ker_eth2tx", "ck_icn_ls_mcu", 0, GATE_ETH2TX, SEC_RIFSC(61)),
|
||||
STM32_GATE(CK_ETH2_RX, "ck_ker_eth2rx", "ck_icn_ls_mcu", 0, GATE_ETH2RX, SEC_RIFSC(61)),
|
||||
|
||||
STM32_GATE(CK_BUS_ETHSW, "ck_icn_p_ethsw", "ck_icn_ls_mcu", 0, GATE_ETHSWMAC,
|
||||
SEC_RIFSC(70)),
|
||||
STM32_GATE(CK_KER_ETHSW, "ck_ker_ethsw", "ck_flexgen_54", 0, GATE_ETHSW,
|
||||
SEC_RIFSC(70)),
|
||||
STM32_GATE(CK_KER_ETHSWREF, "ck_ker_ethswref", "ck_flexgen_60", 0, GATE_ETHSWREF,
|
||||
SEC_RIFSC(70)),
|
||||
|
||||
/* FDCAN */
|
||||
STM32_GATE(CK_BUS_FDCAN, "ck_icn_p_fdcan", "ck_icn_apb2", 0, GATE_FDCAN, SEC_RIFSC(56)),
|
||||
STM32_GATE(CK_KER_FDCAN, "ck_ker_fdcan", "ck_flexgen_26", 0, GATE_FDCAN, SEC_RIFSC(56)),
|
||||
|
||||
/* GPU */
|
||||
STM32_GATE(CK_BUS_GPU, "ck_icn_m_gpu", "ck_flexgen_59", 0, GATE_GPU, SEC_RIFSC(79)),
|
||||
STM32_GATE(CK_KER_GPU, "ck_ker_gpu", "ck_pll3", 0, GATE_GPU, SEC_RIFSC(79)),
|
||||
|
||||
/* HASH */
|
||||
STM32_GATE(CK_BUS_HASH, "ck_icn_p_hash", "ck_icn_ls_mcu", 0, GATE_HASH, SEC_RIFSC(95)),
|
||||
|
||||
/* HDP */
|
||||
STM32_GATE(CK_BUS_HDP, "ck_icn_p_hdp", "ck_icn_apb3", 0, GATE_HDP, SEC_RIFSC(57)),
|
||||
|
||||
/* I2C */
|
||||
STM32_GATE(CK_KER_I2C1, "ck_ker_i2c1", "ck_flexgen_12", 0, GATE_I2C1, SEC_RIFSC(41)),
|
||||
STM32_GATE(CK_KER_I2C2, "ck_ker_i2c2", "ck_flexgen_12", 0, GATE_I2C2, SEC_RIFSC(42)),
|
||||
STM32_GATE(CK_KER_I2C3, "ck_ker_i2c3", "ck_flexgen_13", 0, GATE_I2C3, SEC_RIFSC(43)),
|
||||
STM32_GATE(CK_KER_I2C5, "ck_ker_i2c5", "ck_flexgen_13", 0, GATE_I2C5, SEC_RIFSC(45)),
|
||||
STM32_GATE(CK_KER_I2C4, "ck_ker_i2c4", "ck_flexgen_14", 0, GATE_I2C4, SEC_RIFSC(44)),
|
||||
STM32_GATE(CK_KER_I2C6, "ck_ker_i2c6", "ck_flexgen_14", 0, GATE_I2C6, SEC_RIFSC(46)),
|
||||
STM32_GATE(CK_KER_I2C7, "ck_ker_i2c7", "ck_flexgen_15", 0, GATE_I2C7, SEC_RIFSC(47)),
|
||||
STM32_GATE(CK_KER_I2C8, "ck_ker_i2c8", "ck_flexgen_38", 0, GATE_I2C8, SEC_RIFSC(48)),
|
||||
|
||||
/* I3C */
|
||||
STM32_GATE(CK_KER_I3C1, "ck_ker_i3c1", "ck_flexgen_12", 0, GATE_I3C1, SEC_RIFSC(114)),
|
||||
STM32_GATE(CK_KER_I3C2, "ck_ker_i3c2", "ck_flexgen_12", 0, GATE_I3C2, SEC_RIFSC(115)),
|
||||
STM32_GATE(CK_KER_I3C3, "ck_ker_i3c3", "ck_flexgen_13", 0, GATE_I3C3, SEC_RIFSC(116)),
|
||||
STM32_GATE(CK_KER_I3C4, "ck_ker_i3c4", "ck_flexgen_36", 0, GATE_I3C4, SEC_RIFSC(117)),
|
||||
|
||||
/* I2S */
|
||||
STM32_GATE(CK_BUS_IS2M, "ck_icn_p_is2m", "ck_icn_apb3", 0, GATE_IS2M, SEC_RIFRCC(IS2M)),
|
||||
|
||||
/* IWDG */
|
||||
STM32_GATE(CK_BUS_IWDG1, "ck_icn_p_iwdg1", "ck_icn_apb3", 0, GATE_IWDG1, SEC_RIFSC(98)),
|
||||
STM32_GATE(CK_BUS_IWDG2, "ck_icn_p_iwdg2", "ck_icn_apb3", 0, GATE_IWDG2, SEC_RIFSC(99)),
|
||||
STM32_GATE(CK_BUS_IWDG3, "ck_icn_p_iwdg3", "ck_icn_apb3", 0, GATE_IWDG3, SEC_RIFSC(100)),
|
||||
STM32_GATE(CK_BUS_IWDG4, "ck_icn_p_iwdg4", "ck_icn_apb3", 0, GATE_IWDG4, SEC_RIFSC(101)),
|
||||
STM32_GATE(CK_BUS_IWDG5, "ck_icn_p_iwdg5", "ck_icn_ls_mcu", 0, GATE_IWDG5,
|
||||
SEC_RIFSC(102)),
|
||||
|
||||
/* LPTIM */
|
||||
STM32_GATE(CK_KER_LPTIM1, "ck_ker_lptim1", "ck_flexgen_07", 0, GATE_LPTIM1,
|
||||
SEC_RIFSC(17)),
|
||||
STM32_GATE(CK_KER_LPTIM2, "ck_ker_lptim2", "ck_flexgen_07", 0, GATE_LPTIM2,
|
||||
SEC_RIFSC(18)),
|
||||
STM32_GATE(CK_KER_LPTIM3, "ck_ker_lptim3", "ck_flexgen_40", 0, GATE_LPTIM3,
|
||||
SEC_RIFSC(19)),
|
||||
STM32_GATE(CK_KER_LPTIM4, "ck_ker_lptim4", "ck_flexgen_41", 0, GATE_LPTIM4,
|
||||
SEC_RIFSC(20)),
|
||||
STM32_GATE(CK_KER_LPTIM5, "ck_ker_lptim5", "ck_flexgen_41", 0, GATE_LPTIM5,
|
||||
SEC_RIFSC(21)),
|
||||
|
||||
/* LPUART */
|
||||
STM32_GATE(CK_KER_LPUART1, "ck_ker_lpuart1", "ck_flexgen_39", 0, GATE_LPUART1,
|
||||
SEC_RIFSC(40)),
|
||||
|
||||
/* MCO1 & MCO2 */
|
||||
STM32_COMPOSITE_NODIV(CK_MCO1, "ck_mco1", 0, SEC_RIFRCC(MCO1), GATE_MCO1, MUX_MCO1),
|
||||
STM32_COMPOSITE_NODIV(CK_MCO2, "ck_mco2", 0, SEC_RIFRCC(MCO2), GATE_MCO2, MUX_MCO2),
|
||||
|
||||
/* MDF */
|
||||
STM32_GATE(CK_KER_MDF1, "ck_ker_mdf1", "ck_flexgen_23", 0, GATE_MDF1, SEC_RIFSC(54)),
|
||||
|
||||
/* OCTOSPI */
|
||||
STM32_GATE(CK_BUS_OSPIIOM, "ck_icn_p_ospiiom", "ck_icn_ls_mcu", 0, GATE_OSPIIOM,
|
||||
SEC_RIFSC(111)),
|
||||
|
||||
/* PCIE */
|
||||
STM32_GATE(CK_BUS_PCIE, "ck_icn_p_pcie", "ck_icn_ls_mcu", 0, GATE_PCIE, SEC_RIFSC(68)),
|
||||
|
||||
/* PKA */
|
||||
STM32_GATE(CK_BUS_PKA, "ck_icn_p_pka", "ck_icn_ls_mcu", 0, GATE_PKA, SEC_RIFSC(93)),
|
||||
|
||||
/* RNG */
|
||||
STM32_GATE(CK_BUS_RNG, "ck_icn_p_rng", "ck_icn_ls_mcu", CLK_IGNORE_UNUSED, GATE_RNG,
|
||||
SEC_RIFSC(92)),
|
||||
|
||||
/* SAES */
|
||||
STM32_GATE(CK_BUS_SAES, "ck_icn_p_saes", "ck_icn_ls_mcu", 0, GATE_SAES, SEC_RIFSC(94)),
|
||||
|
||||
/* SAI [1..4] */
|
||||
STM32_GATE(CK_BUS_SAI1, "ck_icn_p_sai1", "ck_icn_apb2", 0, GATE_SAI1, SEC_RIFSC(49)),
|
||||
STM32_GATE(CK_BUS_SAI2, "ck_icn_p_sai2", "ck_icn_apb2", 0, GATE_SAI2, SEC_RIFSC(50)),
|
||||
STM32_GATE(CK_BUS_SAI3, "ck_icn_p_sai3", "ck_icn_apb2", 0, GATE_SAI3, SEC_RIFSC(51)),
|
||||
STM32_GATE(CK_BUS_SAI4, "ck_icn_p_sai4", "ck_icn_apb2", 0, GATE_SAI4, SEC_RIFSC(52)),
|
||||
STM32_GATE(CK_KER_SAI1, "ck_ker_sai1", "ck_flexgen_23", 0, GATE_SAI1, SEC_RIFSC(49)),
|
||||
STM32_GATE(CK_KER_SAI2, "ck_ker_sai2", "ck_flexgen_24", 0, GATE_SAI2, SEC_RIFSC(50)),
|
||||
STM32_GATE(CK_KER_SAI3, "ck_ker_sai3", "ck_flexgen_25", 0, GATE_SAI3, SEC_RIFSC(51)),
|
||||
STM32_GATE(CK_KER_SAI4, "ck_ker_sai4", "ck_flexgen_25", 0, GATE_SAI4, SEC_RIFSC(52)),
|
||||
|
||||
/* SDMMC */
|
||||
STM32_GATE(CK_KER_SDMMC1, "ck_ker_sdmmc1", "ck_flexgen_51", 0, GATE_SDMMC1,
|
||||
SEC_RIFSC(76)),
|
||||
STM32_GATE(CK_KER_SDMMC2, "ck_ker_sdmmc2", "ck_flexgen_52", 0, GATE_SDMMC2,
|
||||
SEC_RIFSC(77)),
|
||||
STM32_GATE(CK_KER_SDMMC3, "ck_ker_sdmmc3", "ck_flexgen_53", 0, GATE_SDMMC3,
|
||||
SEC_RIFSC(78)),
|
||||
|
||||
/* SERC */
|
||||
STM32_GATE(CK_BUS_SERC, "ck_icn_p_serc", "ck_icn_apb3", 0, GATE_SERC, SEC_RIFSC(110)),
|
||||
|
||||
/* SPDIF */
|
||||
STM32_GATE(CK_KER_SPDIFRX, "ck_ker_spdifrx", "ck_flexgen_11", 0, GATE_SPDIFRX,
|
||||
SEC_RIFSC(30)),
|
||||
|
||||
/* SPI */
|
||||
STM32_GATE(CK_KER_SPI1, "ck_ker_spi1", "ck_flexgen_16", 0, GATE_SPI1, SEC_RIFSC(22)),
|
||||
STM32_GATE(CK_KER_SPI2, "ck_ker_spi2", "ck_flexgen_10", 0, GATE_SPI2, SEC_RIFSC(23)),
|
||||
STM32_GATE(CK_KER_SPI3, "ck_ker_spi3", "ck_flexgen_10", 0, GATE_SPI3, SEC_RIFSC(24)),
|
||||
STM32_GATE(CK_KER_SPI4, "ck_ker_spi4", "ck_flexgen_17", 0, GATE_SPI4, SEC_RIFSC(25)),
|
||||
STM32_GATE(CK_KER_SPI5, "ck_ker_spi5", "ck_flexgen_17", 0, GATE_SPI5, SEC_RIFSC(26)),
|
||||
STM32_GATE(CK_KER_SPI6, "ck_ker_spi6", "ck_flexgen_18", 0, GATE_SPI6, SEC_RIFSC(27)),
|
||||
STM32_GATE(CK_KER_SPI7, "ck_ker_spi7", "ck_flexgen_18", 0, GATE_SPI7, SEC_RIFSC(28)),
|
||||
STM32_GATE(CK_KER_SPI8, "ck_ker_spi8", "ck_flexgen_37", 0, GATE_SPI8, SEC_RIFSC(29)),
|
||||
|
||||
/* STGEN */
|
||||
STM32_GATE(CK_KER_STGEN, "ck_ker_stgen", "ck_flexgen_33", CLK_IGNORE_UNUSED, GATE_STGEN,
|
||||
SEC_RIFSC(73)),
|
||||
|
||||
/* Timers */
|
||||
STM32_GATE(CK_KER_TIM2, "ck_ker_tim2", "timg1_ck", 0, GATE_TIM2, SEC_RIFSC(1)),
|
||||
STM32_GATE(CK_KER_TIM3, "ck_ker_tim3", "timg1_ck", 0, GATE_TIM3, SEC_RIFSC(2)),
|
||||
STM32_GATE(CK_KER_TIM4, "ck_ker_tim4", "timg1_ck", 0, GATE_TIM4, SEC_RIFSC(3)),
|
||||
STM32_GATE(CK_KER_TIM5, "ck_ker_tim5", "timg1_ck", 0, GATE_TIM5, SEC_RIFSC(4)),
|
||||
STM32_GATE(CK_KER_TIM6, "ck_ker_tim6", "timg1_ck", 0, GATE_TIM6, SEC_RIFSC(5)),
|
||||
STM32_GATE(CK_KER_TIM7, "ck_ker_tim7", "timg1_ck", 0, GATE_TIM7, SEC_RIFSC(6)),
|
||||
STM32_GATE(CK_KER_TIM10, "ck_ker_tim10", "timg1_ck", 0, GATE_TIM10, SEC_RIFSC(8)),
|
||||
STM32_GATE(CK_KER_TIM11, "ck_ker_tim11", "timg1_ck", 0, GATE_TIM11, SEC_RIFSC(9)),
|
||||
STM32_GATE(CK_KER_TIM12, "ck_ker_tim12", "timg1_ck", 0, GATE_TIM12, SEC_RIFSC(10)),
|
||||
STM32_GATE(CK_KER_TIM13, "ck_ker_tim13", "timg1_ck", 0, GATE_TIM13, SEC_RIFSC(11)),
|
||||
STM32_GATE(CK_KER_TIM14, "ck_ker_tim14", "timg1_ck", 0, GATE_TIM14, SEC_RIFSC(12)),
|
||||
|
||||
STM32_GATE(CK_KER_TIM1, "ck_ker_tim1", "timg2_ck", 0, GATE_TIM1, SEC_RIFSC(0)),
|
||||
STM32_GATE(CK_KER_TIM8, "ck_ker_tim8", "timg2_ck", 0, GATE_TIM8, SEC_RIFSC(7)),
|
||||
STM32_GATE(CK_KER_TIM15, "ck_ker_tim15", "timg2_ck", 0, GATE_TIM15, SEC_RIFSC(13)),
|
||||
STM32_GATE(CK_KER_TIM16, "ck_ker_tim16", "timg2_ck", 0, GATE_TIM16, SEC_RIFSC(14)),
|
||||
STM32_GATE(CK_KER_TIM17, "ck_ker_tim17", "timg2_ck", 0, GATE_TIM17, SEC_RIFSC(15)),
|
||||
STM32_GATE(CK_KER_TIM20, "ck_ker_tim20", "timg2_ck", 0, GATE_TIM20, SEC_RIFSC(20)),
|
||||
|
||||
/* UART/USART */
|
||||
STM32_GATE(CK_KER_USART2, "ck_ker_usart2", "ck_flexgen_08", 0, GATE_USART2,
|
||||
SEC_RIFSC(32)),
|
||||
STM32_GATE(CK_KER_UART4, "ck_ker_uart4", "ck_flexgen_08", 0, GATE_UART4,
|
||||
SEC_RIFSC(34)),
|
||||
STM32_GATE(CK_KER_USART3, "ck_ker_usart3", "ck_flexgen_09", 0, GATE_USART3,
|
||||
SEC_RIFSC(33)),
|
||||
STM32_GATE(CK_KER_UART5, "ck_ker_uart5", "ck_flexgen_09", 0, GATE_UART5,
|
||||
SEC_RIFSC(35)),
|
||||
STM32_GATE(CK_KER_USART1, "ck_ker_usart1", "ck_flexgen_19", 0, GATE_USART1,
|
||||
SEC_RIFSC(31)),
|
||||
STM32_GATE(CK_KER_USART6, "ck_ker_usart6", "ck_flexgen_20", 0, GATE_USART6,
|
||||
SEC_RIFSC(36)),
|
||||
STM32_GATE(CK_KER_UART7, "ck_ker_uart7", "ck_flexgen_21", 0, GATE_UART7,
|
||||
SEC_RIFSC(37)),
|
||||
STM32_GATE(CK_KER_UART8, "ck_ker_uart8", "ck_flexgen_21", 0, GATE_UART8,
|
||||
SEC_RIFSC(38)),
|
||||
STM32_GATE(CK_KER_UART9, "ck_ker_uart9", "ck_flexgen_22", 0, GATE_UART9,
|
||||
SEC_RIFSC(39)),
|
||||
|
||||
/* USB2PHY1 */
|
||||
STM32_COMPOSITE_NODIV(CK_KER_USB2PHY1, "ck_ker_usb2phy1", 0, SEC_RIFSC(63),
|
||||
GATE_USB2PHY1, MUX_USB2PHY1),
|
||||
|
||||
/* USBH */
|
||||
STM32_GATE(CK_BUS_USB2OHCI, "ck_icn_m_usb2ohci", "ck_icn_hsl", 0, GATE_USBH,
|
||||
SEC_RIFSC(63)),
|
||||
STM32_GATE(CK_BUS_USB2EHCI, "ck_icn_m_usb2ehci", "ck_icn_hsl", 0, GATE_USBH,
|
||||
SEC_RIFSC(63)),
|
||||
|
||||
/* USB2PHY2 */
|
||||
STM32_COMPOSITE_NODIV(CK_KER_USB2PHY2EN, "ck_ker_usb2phy2_en", 0, SEC_RIFSC(66),
|
||||
GATE_USB2PHY2, MUX_USB2PHY2),
|
||||
|
||||
/* USB3 PCIe COMBOPHY */
|
||||
STM32_GATE(CK_BUS_USB3PCIEPHY, "ck_icn_p_usb3pciephy", "ck_icn_apb4", 0, GATE_USB3PCIEPHY,
|
||||
SEC_RIFSC(67)),
|
||||
|
||||
STM32_COMPOSITE_NODIV(CK_KER_USB3PCIEPHY, "ck_ker_usb3pciephy", 0, SEC_RIFSC(67),
|
||||
GATE_USB3PCIEPHY, MUX_USB3PCIEPHY),
|
||||
|
||||
/* USB3 DRD */
|
||||
STM32_GATE(CK_BUS_USB3DR, "ck_icn_m_usb3dr", "ck_icn_hsl", 0, GATE_USB3DR,
|
||||
SEC_RIFSC(66)),
|
||||
STM32_GATE(CK_KER_USB2PHY2, "ck_ker_usb2phy2", "ck_flexgen_58", 0, GATE_USB3DR,
|
||||
SEC_RIFSC(66)),
|
||||
|
||||
/* UCPD */
|
||||
STM32_GATE(CK_BUS_USBTC, "ck_icn_p_usbtc", "ck_flexgen_35", 0, GATE_USBTC,
|
||||
SEC_RIFSC(69)),
|
||||
STM32_GATE(CK_KER_USBTC, "ck_ker_usbtc", "ck_flexgen_35", 0, GATE_USBTC,
|
||||
SEC_RIFSC(69)),
|
||||
|
||||
/* VDEC / VENC */
|
||||
STM32_GATE(CK_BUS_VDEC, "ck_icn_p_vdec", "ck_icn_apb4", 0, GATE_VDEC, SEC_RIFSC(89)),
|
||||
STM32_GATE(CK_BUS_VENC, "ck_icn_p_venc", "ck_icn_apb4", 0, GATE_VENC, SEC_RIFSC(90)),
|
||||
|
||||
/* VREF */
|
||||
STM32_GATE(CK_BUS_VREF, "ck_icn_p_vref", "ck_icn_apb3", 0, RCC_VREFCFGR,
|
||||
SEC_RIFSC(106)),
|
||||
|
||||
/* WWDG */
|
||||
STM32_GATE(CK_BUS_WWDG1, "ck_icn_p_wwdg1", "ck_icn_apb3", 0, GATE_WWDG1,
|
||||
SEC_RIFSC(103)),
|
||||
STM32_GATE(CK_BUS_WWDG2, "ck_icn_p_wwdg2", "ck_icn_ls_mcu", 0, GATE_WWDG2,
|
||||
SEC_RIFSC(104)),
|
||||
};
|
||||
|
||||
static const struct stm32_clock_match_data stm32mp25_data = {
|
||||
.tab_clocks = stm32mp25_clock_cfg,
|
||||
.num_clocks = ARRAY_SIZE(stm32mp25_clock_cfg),
|
||||
.clock_data = &(const struct clk_stm32_clock_data) {
|
||||
.num_gates = ARRAY_SIZE(stm32mp25_gates),
|
||||
.gates = stm32mp25_gates,
|
||||
.muxes = stm32mp25_muxes,
|
||||
},
|
||||
.check_security = stm32mp25_check_security,
|
||||
|
||||
};
|
||||
|
||||
static int stm32mp25_clk_probe(struct udevice *dev)
|
||||
{
|
||||
fdt_addr_t base = dev_read_addr(dev->parent);
|
||||
struct udevice *scmi;
|
||||
|
||||
if (base == FDT_ADDR_T_NONE)
|
||||
return -EINVAL;
|
||||
|
||||
/* force SCMI probe to register all SCMI clocks */
|
||||
uclass_get_device_by_driver(UCLASS_CLK, DM_DRIVER_GET(scmi_clock), &scmi);
|
||||
|
||||
stm32_rcc_init(dev, &stm32mp25_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(stm32mp25_clock) = {
|
||||
.name = "stm32mp25_clk",
|
||||
.id = UCLASS_CLK,
|
||||
.ops = &stm32_clk_ops,
|
||||
.priv_auto = sizeof(struct stm32mp_rcc_priv),
|
||||
.probe = stm32mp25_clk_probe,
|
||||
};
|
||||
@@ -285,4 +285,97 @@
|
||||
#define RCC_AHB6SECSR_ETH2MACSECF 30
|
||||
#define RCC_AHB6SECSR_ETH2STPSECF 31
|
||||
|
||||
/* Fields of RCC_BDCR register */
|
||||
#define RCC_BDCR_LSEON BIT(0)
|
||||
#define RCC_BDCR_LSEBYP BIT(1)
|
||||
#define RCC_BDCR_LSERDY BIT(2)
|
||||
#define RCC_BDCR_DIGBYP BIT(3)
|
||||
#define RCC_BDCR_LSEDRV_MASK GENMASK(5, 4)
|
||||
#define RCC_BDCR_LSEDRV_SHIFT 4
|
||||
#define RCC_BDCR_LSECSSON BIT(8)
|
||||
#define RCC_BDCR_RTCCKEN BIT(20)
|
||||
#define RCC_BDCR_RTCSRC_MASK GENMASK(17, 16)
|
||||
#define RCC_BDCR_RTCSRC_SHIFT 16
|
||||
|
||||
/* Fields of RCC_RDLSICR register */
|
||||
#define RCC_RDLSICR_LSION BIT(0)
|
||||
#define RCC_RDLSICR_LSIRDY BIT(1)
|
||||
|
||||
/* used for ALL PLLNCR registers */
|
||||
#define RCC_PLLNCR_PLLON BIT(0)
|
||||
#define RCC_PLLNCR_PLLRDY BIT(1)
|
||||
#define RCC_PLLNCR_SSCG_CTRL BIT(2)
|
||||
#define RCC_PLLNCR_DIVPEN BIT(4)
|
||||
#define RCC_PLLNCR_DIVQEN BIT(5)
|
||||
#define RCC_PLLNCR_DIVREN BIT(6)
|
||||
#define RCC_PLLNCR_DIVEN_SHIFT 4
|
||||
|
||||
/* used for ALL PLLNCFGR1 registers */
|
||||
#define RCC_PLLNCFGR1_DIVM_SHIFT 16
|
||||
#define RCC_PLLNCFGR1_DIVM_MASK GENMASK(21, 16)
|
||||
#define RCC_PLLNCFGR1_DIVN_SHIFT 0
|
||||
#define RCC_PLLNCFGR1_DIVN_MASK GENMASK(8, 0)
|
||||
/* only for PLL3 and PLL4 */
|
||||
#define RCC_PLLNCFGR1_IFRGE_SHIFT 24
|
||||
#define RCC_PLLNCFGR1_IFRGE_MASK GENMASK(25, 24)
|
||||
|
||||
/* used for ALL PLLNCFGR2 registers , using stm32mp1_div_id */
|
||||
#define RCC_PLLNCFGR2_SHIFT(div_id) ((div_id) * 8)
|
||||
#define RCC_PLLNCFGR2_DIVX_MASK GENMASK(6, 0)
|
||||
#define RCC_PLLNCFGR2_DIVP_SHIFT RCC_PLLNCFGR2_SHIFT(_DIV_P)
|
||||
#define RCC_PLLNCFGR2_DIVP_MASK GENMASK(6, 0)
|
||||
#define RCC_PLLNCFGR2_DIVQ_SHIFT RCC_PLLNCFGR2_SHIFT(_DIV_Q)
|
||||
#define RCC_PLLNCFGR2_DIVQ_MASK GENMASK(14, 8)
|
||||
#define RCC_PLLNCFGR2_DIVR_SHIFT RCC_PLLNCFGR2_SHIFT(_DIV_R)
|
||||
#define RCC_PLLNCFGR2_DIVR_MASK GENMASK(22, 16)
|
||||
|
||||
/* used for ALL PLLNFRACR registers */
|
||||
#define RCC_PLLNFRACR_FRACV_SHIFT 3
|
||||
#define RCC_PLLNFRACR_FRACV_MASK GENMASK(15, 3)
|
||||
#define RCC_PLLNFRACR_FRACLE BIT(16)
|
||||
|
||||
/* used for ALL PLLNCSGR registers */
|
||||
#define RCC_PLLNCSGR_INC_STEP_SHIFT 16
|
||||
#define RCC_PLLNCSGR_INC_STEP_MASK GENMASK(30, 16)
|
||||
#define RCC_PLLNCSGR_MOD_PER_SHIFT 0
|
||||
#define RCC_PLLNCSGR_MOD_PER_MASK GENMASK(12, 0)
|
||||
#define RCC_PLLNCSGR_SSCG_MODE_SHIFT 15
|
||||
#define RCC_PLLNCSGR_SSCG_MODE_MASK BIT(15)
|
||||
|
||||
/* used for RCC_OCENSETR and RCC_OCENCLRR registers */
|
||||
#define RCC_OCENR_HSION BIT(0)
|
||||
#define RCC_OCENR_CSION BIT(4)
|
||||
#define RCC_OCENR_DIGBYP BIT(7)
|
||||
#define RCC_OCENR_HSEON BIT(8)
|
||||
#define RCC_OCENR_HSEBYP BIT(10)
|
||||
#define RCC_OCENR_HSECSSON BIT(11)
|
||||
|
||||
/* Fields of RCC_OCRDYR register */
|
||||
#define RCC_OCRDYR_HSIRDY BIT(0)
|
||||
#define RCC_OCRDYR_HSIDIVRDY BIT(2)
|
||||
#define RCC_OCRDYR_CSIRDY BIT(4)
|
||||
#define RCC_OCRDYR_HSERDY BIT(8)
|
||||
|
||||
/* Fields of DDRITFCR register */
|
||||
#define RCC_DDRITFCR_DDRCKMOD_MASK GENMASK(22, 20)
|
||||
#define RCC_DDRITFCR_DDRCKMOD_SHIFT 20
|
||||
#define RCC_DDRITFCR_DDRCKMOD_SSR 0
|
||||
|
||||
/* Fields of RCC_HSICFGR register */
|
||||
#define RCC_HSICFGR_HSIDIV_MASK GENMASK(1, 0)
|
||||
|
||||
/* used for MCO related operations */
|
||||
#define RCC_MCOCFG_MCOON BIT(12)
|
||||
#define RCC_MCOCFG_MCODIV_MASK GENMASK(7, 4)
|
||||
#define RCC_MCOCFG_MCODIV_SHIFT 4
|
||||
#define RCC_MCOCFG_MCOSRC_MASK GENMASK(2, 0)
|
||||
|
||||
/* used for most of SELR register */
|
||||
#define RCC_SELR_SRC_MASK GENMASK(2, 0)
|
||||
#define RCC_SELR_SRCRDY BIT(31)
|
||||
|
||||
/* used for most of DIVR register : max div for RTC */
|
||||
#define RCC_DIVR_DIV_MASK GENMASK(5, 0)
|
||||
#define RCC_DIVR_DIVRDY BIT(31)
|
||||
|
||||
#endif /* STM32MP13_RCC_H */
|
||||
|
||||
@@ -14,47 +14,56 @@
|
||||
#include <dm/device_compat.h>
|
||||
#include <dm/lists.h>
|
||||
|
||||
struct stm32_rcc_clk stm32_rcc_clk_f42x = {
|
||||
.drv_name = "stm32fx_rcc_clock",
|
||||
static const struct stm32_rcc stm32_rcc_f42x = {
|
||||
.drv_name_clk = "stm32fx_rcc_clock",
|
||||
.drv_name_rst = "stm32_rcc_reset",
|
||||
.soc = STM32F42X,
|
||||
};
|
||||
|
||||
struct stm32_rcc_clk stm32_rcc_clk_f469 = {
|
||||
.drv_name = "stm32fx_rcc_clock",
|
||||
static const struct stm32_rcc stm32_rcc_f469 = {
|
||||
.drv_name_clk = "stm32fx_rcc_clock",
|
||||
.drv_name_rst = "stm32_rcc_reset",
|
||||
.soc = STM32F469,
|
||||
};
|
||||
|
||||
struct stm32_rcc_clk stm32_rcc_clk_f7 = {
|
||||
.drv_name = "stm32fx_rcc_clock",
|
||||
static const struct stm32_rcc stm32_rcc_f7 = {
|
||||
.drv_name_clk = "stm32fx_rcc_clock",
|
||||
.drv_name_rst = "stm32_rcc_reset",
|
||||
.soc = STM32F7,
|
||||
};
|
||||
|
||||
struct stm32_rcc_clk stm32_rcc_clk_h7 = {
|
||||
.drv_name = "stm32h7_rcc_clock",
|
||||
static const struct stm32_rcc stm32_rcc_h7 = {
|
||||
.drv_name_clk = "stm32h7_rcc_clock",
|
||||
.drv_name_rst = "stm32_rcc_reset",
|
||||
};
|
||||
|
||||
struct stm32_rcc_clk stm32_rcc_clk_mp1 = {
|
||||
.drv_name = "stm32mp1_clk",
|
||||
.soc = STM32MP1,
|
||||
static const struct stm32_rcc stm32_rcc_mp15 = {
|
||||
.drv_name_clk = "stm32mp1_clk",
|
||||
.drv_name_rst = "stm32mp1_reset",
|
||||
};
|
||||
|
||||
struct stm32_rcc_clk stm32_rcc_clk_mp13 = {
|
||||
.drv_name = "stm32mp13_clk",
|
||||
.soc = STM32MP1,
|
||||
static const struct stm32_rcc stm32_rcc_mp13 = {
|
||||
.drv_name_clk = "stm32mp13_clk",
|
||||
.drv_name_rst = "stm32mp1_reset",
|
||||
};
|
||||
|
||||
static const struct stm32_rcc stm32_rcc_mp25 = {
|
||||
.drv_name_clk = "stm32mp25_clk",
|
||||
.drv_name_rst = "stm32mp25_reset",
|
||||
};
|
||||
|
||||
static int stm32_rcc_bind(struct udevice *dev)
|
||||
{
|
||||
struct udevice *child;
|
||||
struct driver *drv;
|
||||
struct stm32_rcc_clk *rcc_clk =
|
||||
(struct stm32_rcc_clk *)dev_get_driver_data(dev);
|
||||
struct stm32_rcc *rcc_clk =
|
||||
(struct stm32_rcc *)dev_get_driver_data(dev);
|
||||
int ret;
|
||||
|
||||
dev_dbg(dev, "RCC bind\n");
|
||||
drv = lists_driver_lookup_name(rcc_clk->drv_name);
|
||||
drv = lists_driver_lookup_name(rcc_clk->drv_name_clk);
|
||||
if (!drv) {
|
||||
dev_err(dev, "Cannot find driver '%s'\n", rcc_clk->drv_name);
|
||||
dev_err(dev, "Cannot find driver '%s'\n", rcc_clk->drv_name_clk);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
@@ -65,25 +74,24 @@ static int stm32_rcc_bind(struct udevice *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
drv = lists_driver_lookup_name("stm32_rcc_reset");
|
||||
drv = lists_driver_lookup_name(rcc_clk->drv_name_rst);
|
||||
if (!drv) {
|
||||
dev_err(dev, "Cannot find driver stm32_rcc_reset'\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return device_bind_with_driver_data(dev, drv, dev->name,
|
||||
rcc_clk->soc,
|
||||
dev_ofnode(dev), &child);
|
||||
return device_bind(dev, drv, dev->name, NULL, dev_ofnode(dev), &child);
|
||||
}
|
||||
|
||||
static const struct udevice_id stm32_rcc_ids[] = {
|
||||
{.compatible = "st,stm32f42xx-rcc", .data = (ulong)&stm32_rcc_clk_f42x },
|
||||
{.compatible = "st,stm32f469-rcc", .data = (ulong)&stm32_rcc_clk_f469 },
|
||||
{.compatible = "st,stm32f746-rcc", .data = (ulong)&stm32_rcc_clk_f7 },
|
||||
{.compatible = "st,stm32h743-rcc", .data = (ulong)&stm32_rcc_clk_h7 },
|
||||
{.compatible = "st,stm32mp1-rcc", .data = (ulong)&stm32_rcc_clk_mp1 },
|
||||
{.compatible = "st,stm32mp1-rcc-secure", .data = (ulong)&stm32_rcc_clk_mp1 },
|
||||
{.compatible = "st,stm32mp13-rcc", .data = (ulong)&stm32_rcc_clk_mp13 },
|
||||
{.compatible = "st,stm32f42xx-rcc", .data = (ulong)&stm32_rcc_f42x },
|
||||
{.compatible = "st,stm32f469-rcc", .data = (ulong)&stm32_rcc_f469 },
|
||||
{.compatible = "st,stm32f746-rcc", .data = (ulong)&stm32_rcc_f7 },
|
||||
{.compatible = "st,stm32h743-rcc", .data = (ulong)&stm32_rcc_h7 },
|
||||
{.compatible = "st,stm32mp1-rcc", .data = (ulong)&stm32_rcc_mp15 },
|
||||
{.compatible = "st,stm32mp1-rcc-secure", .data = (ulong)&stm32_rcc_mp15 },
|
||||
{.compatible = "st,stm32mp13-rcc", .data = (ulong)&stm32_rcc_mp13 },
|
||||
{.compatible = "st,stm32mp25-rcc", .data = (ulong)&stm32_rcc_mp25 },
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#include <syscon.h>
|
||||
#include <usb.h>
|
||||
#include <asm/io.h>
|
||||
#include <dm/device.h>
|
||||
#include <dm/device_compat.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/lists.h>
|
||||
#include <dm/of_access.h>
|
||||
#include <linux/bitfield.h>
|
||||
@@ -633,6 +635,7 @@ U_BOOT_DRIVER(stm32_usb_phyc) = {
|
||||
|
||||
struct stm32_usbphyc_clk {
|
||||
bool enable;
|
||||
struct clk clkp;
|
||||
};
|
||||
|
||||
static ulong stm32_usbphyc_clk48_get_rate(struct clk *clk)
|
||||
@@ -687,9 +690,25 @@ const struct clk_ops usbphyc_clk48_ops = {
|
||||
.disable = stm32_usbphyc_clk48_disable,
|
||||
};
|
||||
|
||||
int usbphyc_clk48_probe(struct udevice *dev)
|
||||
{
|
||||
struct stm32_usbphyc_clk *priv = dev_get_priv(dev);
|
||||
|
||||
/* prepare clkp to correctly register clock with CCF */
|
||||
priv->clkp.dev = dev;
|
||||
priv->clkp.id = CLK_ID(dev, 0);
|
||||
|
||||
/* Store back pointer to clk from udevice */
|
||||
/* FIXME: This is not allowed...should be allocated by driver model */
|
||||
dev_set_uclass_priv(dev, &priv->clkp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(stm32_usb_phyc_clk) = {
|
||||
.name = "stm32-usbphyc-clk",
|
||||
.id = UCLASS_CLK,
|
||||
.ops = &usbphyc_clk48_ops,
|
||||
.probe = &usbphyc_clk48_probe,
|
||||
.priv_auto = sizeof(struct stm32_usbphyc_clk),
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <timer.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/arch/ddr.h>
|
||||
#include <dm/device.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/iopoll.h>
|
||||
@@ -19,7 +20,8 @@
|
||||
#include "stm32mp1_ddr.h"
|
||||
#include "stm32mp1_ddr_regs.h"
|
||||
|
||||
#define RCC_DDRITFCR 0xD8
|
||||
#define RCC_DDRITFCR_STM32MP13xx 0x5c0
|
||||
#define RCC_DDRITFCR_STM32MP15xx 0xd8
|
||||
|
||||
#define RCC_DDRITFCR_DDRCAPBRST (BIT(14))
|
||||
#define RCC_DDRITFCR_DDRCAXIRST (BIT(15))
|
||||
@@ -66,9 +68,19 @@ struct reg_desc {
|
||||
#define DDRCTL_REG_REG_SIZE 25 /* st,ctl-reg */
|
||||
#define DDRCTL_REG_TIMING_SIZE 12 /* st,ctl-timing */
|
||||
#define DDRCTL_REG_MAP_SIZE 9 /* st,ctl-map */
|
||||
#define DDRCTL_REG_PERF_SIZE 17 /* st,ctl-perf */
|
||||
|
||||
#define DDRPHY_REG_REG_SIZE 11 /* st,phy-reg */
|
||||
#define DDRCTL_REG_PERF_SIZE_STM32MP13xx 11 /* st,ctl-perf */
|
||||
#define DDRCTL_REG_PERF_SIZE_STM32MP15xx 17 /* st,ctl-perf */
|
||||
#define DDRCTL_REG_PERF_SIZE \
|
||||
(IS_ENABLED(CONFIG_STM32MP15X) ? DDRCTL_REG_PERF_SIZE_STM32MP15xx : \
|
||||
DDRCTL_REG_PERF_SIZE_STM32MP13xx)
|
||||
|
||||
#define DDRPHY_REG_REG_SIZE_STM32MP13xx 9 /* st,phy-reg */
|
||||
#define DDRPHY_REG_REG_SIZE_STM32MP15xx 11 /* st,phy-reg */
|
||||
#define DDRPHY_REG_REG_SIZE \
|
||||
(IS_ENABLED(CONFIG_STM32MP15X) ? DDRPHY_REG_REG_SIZE_STM32MP15xx : \
|
||||
DDRPHY_REG_REG_SIZE_STM32MP13xx)
|
||||
|
||||
#define DDRPHY_REG_TIMING_SIZE 10 /* st,phy-timing */
|
||||
|
||||
#define DDRCTL_REG_REG(x) DDRCTL_REG(x, stm32mp1_ddrctrl_reg)
|
||||
@@ -142,12 +154,14 @@ static const struct reg_desc ddr_perf[DDRCTL_REG_PERF_SIZE] = {
|
||||
DDRCTL_REG_PERF(pcfgqos1_0),
|
||||
DDRCTL_REG_PERF(pcfgwqos0_0),
|
||||
DDRCTL_REG_PERF(pcfgwqos1_0),
|
||||
#if IS_ENABLED(CONFIG_STM32MP15X)
|
||||
DDRCTL_REG_PERF(pcfgr_1),
|
||||
DDRCTL_REG_PERF(pcfgw_1),
|
||||
DDRCTL_REG_PERF(pcfgqos0_1),
|
||||
DDRCTL_REG_PERF(pcfgqos1_1),
|
||||
DDRCTL_REG_PERF(pcfgwqos0_1),
|
||||
DDRCTL_REG_PERF(pcfgwqos1_1),
|
||||
#endif
|
||||
};
|
||||
|
||||
#define DDRPHY_REG_REG(x) DDRPHY_REG(x, stm32mp1_ddrphy_reg)
|
||||
@@ -161,8 +175,10 @@ static const struct reg_desc ddrphy_reg[DDRPHY_REG_REG_SIZE] = {
|
||||
DDRPHY_REG_REG(zq0cr1),
|
||||
DDRPHY_REG_REG(dx0gcr),
|
||||
DDRPHY_REG_REG(dx1gcr),
|
||||
#if IS_ENABLED(CONFIG_STM32MP15X)
|
||||
DDRPHY_REG_REG(dx2gcr),
|
||||
DDRPHY_REG_REG(dx3gcr),
|
||||
#endif
|
||||
};
|
||||
|
||||
#define DDRPHY_REG_TIMING(x) DDRPHY_REG(x, stm32mp1_ddrphy_timing)
|
||||
@@ -211,6 +227,7 @@ static const struct reg_desc ddrphy_dyn[] = {
|
||||
DDRPHY_REG_DYN(dx1dllcr),
|
||||
DDRPHY_REG_DYN(dx1dqtr),
|
||||
DDRPHY_REG_DYN(dx1dqstr),
|
||||
#if IS_ENABLED(CONFIG_STM32MP15X)
|
||||
DDRPHY_REG_DYN(dx2gsr0),
|
||||
DDRPHY_REG_DYN(dx2gsr1),
|
||||
DDRPHY_REG_DYN(dx2dllcr),
|
||||
@@ -221,6 +238,7 @@ static const struct reg_desc ddrphy_dyn[] = {
|
||||
DDRPHY_REG_DYN(dx3dllcr),
|
||||
DDRPHY_REG_DYN(dx3dqtr),
|
||||
DDRPHY_REG_DYN(dx3dqstr),
|
||||
#endif
|
||||
};
|
||||
|
||||
#define DDRPHY_REG_DYN_SIZE ARRAY_SIZE(ddrphy_dyn)
|
||||
@@ -287,6 +305,24 @@ const char *base_name[] = {
|
||||
[DDRPHY_BASE] = "phy",
|
||||
};
|
||||
|
||||
bool is_stm32mp13_ddrc(const struct ddr_info *priv)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_STM32MP13X) && !IS_ENABLED(CONFIG_STM32MP15X))
|
||||
return true; /* STM32MP13xx only build */
|
||||
else if (!IS_ENABLED(CONFIG_STM32MP13X) && IS_ENABLED(CONFIG_STM32MP15X))
|
||||
return false; /* STM32MP15xx only build */
|
||||
|
||||
/* Combined STM32MP13xx and STM32MP15xx build */
|
||||
return device_is_compatible(priv->dev, "st,stm32mp13-ddr");
|
||||
}
|
||||
|
||||
static u32 get_rcc_ddritfcr(const struct ddr_info *priv)
|
||||
{
|
||||
return priv->rcc + (is_stm32mp13_ddrc(priv) ?
|
||||
RCC_DDRITFCR_STM32MP13xx :
|
||||
RCC_DDRITFCR_STM32MP15xx);
|
||||
}
|
||||
|
||||
static u32 get_base_addr(const struct ddr_info *priv, enum base_type base)
|
||||
{
|
||||
if (base == DDRPHY_BASE)
|
||||
@@ -295,6 +331,21 @@ static u32 get_base_addr(const struct ddr_info *priv, enum base_type base)
|
||||
return (u32)priv->ctl;
|
||||
}
|
||||
|
||||
static u32 get_type_size(const struct ddr_info *priv, enum reg_type type)
|
||||
{
|
||||
bool is_mp13 = is_stm32mp13_ddrc(priv);
|
||||
|
||||
if (type == REG_PERF)
|
||||
return is_mp13 ? DDRCTL_REG_PERF_SIZE_STM32MP13xx :
|
||||
DDRCTL_REG_PERF_SIZE_STM32MP15xx;
|
||||
else if (type == REGPHY_REG)
|
||||
return is_mp13 ? DDRPHY_REG_REG_SIZE_STM32MP13xx :
|
||||
DDRPHY_REG_REG_SIZE_STM32MP15xx;
|
||||
|
||||
/* Everything else is the default size */
|
||||
return ddr_registers[type].size;
|
||||
}
|
||||
|
||||
static void set_reg(const struct ddr_info *priv,
|
||||
enum reg_type type,
|
||||
const void *param)
|
||||
@@ -304,9 +355,10 @@ static void set_reg(const struct ddr_info *priv,
|
||||
enum base_type base = ddr_registers[type].base;
|
||||
u32 base_addr = get_base_addr(priv, base);
|
||||
const struct reg_desc *desc = ddr_registers[type].desc;
|
||||
u32 size = get_type_size(priv, type);
|
||||
|
||||
log_debug("init %s\n", ddr_registers[type].name);
|
||||
for (i = 0; i < ddr_registers[type].size; i++) {
|
||||
for (i = 0; i < size; i++) {
|
||||
ptr = (unsigned int *)(base_addr + desc[i].offset);
|
||||
if (desc[i].par_offset == INVALID_OFFSET) {
|
||||
log_err("invalid parameter offset for %s", desc[i].name);
|
||||
@@ -656,12 +708,13 @@ static void stm32mp1_refresh_restore(struct stm32mp1_ddrctl *ctl,
|
||||
static void stm32mp1_asr_enable(struct ddr_info *priv, const u32 pwrctl)
|
||||
{
|
||||
struct stm32mp1_ddrctl *ctl = priv->ctl;
|
||||
u32 rcc_ddritfcr = get_rcc_ddritfcr(priv);
|
||||
|
||||
/* SSR is the best we can do. */
|
||||
if (!(pwrctl & DDRCTRL_PWRCTL_EN_DFI_DRAM_CLK_DISABLE))
|
||||
return;
|
||||
|
||||
clrsetbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCKMOD_MASK,
|
||||
clrsetbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCKMOD_MASK,
|
||||
RCC_DDRITFCR_DDRCKMOD_ASR);
|
||||
|
||||
start_sw_done(ctl);
|
||||
@@ -691,6 +744,7 @@ __maybe_unused
|
||||
void stm32mp1_ddr_init(struct ddr_info *priv,
|
||||
const struct stm32mp1_ddr_config *config)
|
||||
{
|
||||
u32 rcc_ddritfcr = get_rcc_ddritfcr(priv);
|
||||
u32 pir;
|
||||
int ret = -EINVAL;
|
||||
char bus_width;
|
||||
@@ -732,12 +786,12 @@ start:
|
||||
* 1.1 RESETS: presetn, core_ddrc_rstn, aresetn
|
||||
*/
|
||||
/* Assert All DDR part */
|
||||
setbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCAPBRST);
|
||||
setbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCAXIRST);
|
||||
setbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCORERST);
|
||||
setbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DPHYAPBRST);
|
||||
setbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DPHYRST);
|
||||
setbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DPHYCTLRST);
|
||||
setbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCAPBRST);
|
||||
setbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCAXIRST);
|
||||
setbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCORERST);
|
||||
setbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DPHYAPBRST);
|
||||
setbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DPHYRST);
|
||||
setbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DPHYCTLRST);
|
||||
|
||||
/* 1.2. start CLOCK */
|
||||
if (stm32mp1_ddr_clk_enable(priv, config->info.speed))
|
||||
@@ -746,12 +800,12 @@ start:
|
||||
|
||||
/* 1.3. deassert reset */
|
||||
/* de-assert PHY rstn and ctl_rstn via DPHYRST and DPHYCTLRST */
|
||||
clrbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DPHYRST);
|
||||
clrbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DPHYCTLRST);
|
||||
clrbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DPHYRST);
|
||||
clrbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DPHYCTLRST);
|
||||
/* De-assert presetn once the clocks are active
|
||||
* and stable via DDRCAPBRST bit
|
||||
*/
|
||||
clrbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCAPBRST);
|
||||
clrbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCAPBRST);
|
||||
|
||||
/* 1.4. wait 128 cycles to permit initialization of end logic */
|
||||
udelay(2);
|
||||
@@ -781,9 +835,9 @@ start:
|
||||
goto start;
|
||||
|
||||
/* 2. deassert reset signal core_ddrc_rstn, aresetn and presetn */
|
||||
clrbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCORERST);
|
||||
clrbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DDRCAXIRST);
|
||||
clrbits_le32(priv->rcc + RCC_DDRITFCR, RCC_DDRITFCR_DPHYAPBRST);
|
||||
clrbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCORERST);
|
||||
clrbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DDRCAXIRST);
|
||||
clrbits_le32(rcc_ddritfcr, RCC_DDRITFCR_DPHYAPBRST);
|
||||
|
||||
/* 3. start PHY init by accessing relevant PUBL registers
|
||||
* (DXGCR, DCR, PTR*, MR*, DTPR*)
|
||||
@@ -854,9 +908,12 @@ start:
|
||||
/* Enable auto-self-refresh, which saves a bit of power at runtime. */
|
||||
stm32mp1_asr_enable(priv, config->c_reg.pwrctl);
|
||||
|
||||
/* enable uMCTL2 AXI port 0 and 1 */
|
||||
/* enable uMCTL2 AXI port 0 */
|
||||
setbits_le32(&priv->ctl->pctrl_0, DDRCTRL_PCTRL_N_PORT_EN);
|
||||
setbits_le32(&priv->ctl->pctrl_1, DDRCTRL_PCTRL_N_PORT_EN);
|
||||
|
||||
/* enable uMCTL2 AXI port 1 only on STM32MP15xx with 32bit DRAM bus */
|
||||
if (!is_stm32mp13_ddrc(priv))
|
||||
setbits_le32(&priv->ctl->pctrl_1, DDRCTRL_PCTRL_N_PORT_EN);
|
||||
|
||||
if (INTERACTIVE(STEP_DDR_READY))
|
||||
goto start;
|
||||
|
||||
@@ -105,12 +105,14 @@ struct stm32mp1_ddrctrl_perf {
|
||||
u32 pcfgqos1_0;
|
||||
u32 pcfgwqos0_0;
|
||||
u32 pcfgwqos1_0;
|
||||
#if IS_ENABLED(CONFIG_STM32MP15X)
|
||||
u32 pcfgr_1;
|
||||
u32 pcfgw_1;
|
||||
u32 pcfgqos0_1;
|
||||
u32 pcfgqos1_1;
|
||||
u32 pcfgwqos0_1;
|
||||
u32 pcfgwqos1_1;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32mp1_ddrphy_reg {
|
||||
@@ -123,8 +125,10 @@ struct stm32mp1_ddrphy_reg {
|
||||
u32 zq0cr1;
|
||||
u32 dx0gcr;
|
||||
u32 dx1gcr;
|
||||
#if IS_ENABLED(CONFIG_STM32MP15X)
|
||||
u32 dx2gcr;
|
||||
u32 dx3gcr;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stm32mp1_ddrphy_timing {
|
||||
@@ -181,4 +185,6 @@ bool stm32mp1_ddr_interactive(
|
||||
enum stm32mp1_ddr_interact_step step,
|
||||
const struct stm32mp1_ddr_config *config);
|
||||
|
||||
bool is_stm32mp13_ddrc(const struct ddr_info *priv);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,7 @@ static const char *const clkname[] = {
|
||||
|
||||
int stm32mp1_ddr_clk_enable(struct ddr_info *priv, uint32_t mem_speed)
|
||||
{
|
||||
bool is_mp13 = is_stm32mp13_ddrc(priv);
|
||||
unsigned long ddrphy_clk;
|
||||
unsigned long ddr_clk;
|
||||
struct clk clk;
|
||||
@@ -40,6 +41,10 @@ int stm32mp1_ddr_clk_enable(struct ddr_info *priv, uint32_t mem_speed)
|
||||
unsigned int idx;
|
||||
|
||||
for (idx = 0; idx < ARRAY_SIZE(clkname); idx++) {
|
||||
/* DDRC2 clock are available only on STM32MP15xx */
|
||||
if (is_mp13 && !strcmp(clkname[idx], "ddrc2"))
|
||||
continue;
|
||||
|
||||
ret = clk_get_by_name(priv->dev, clkname[idx], &clk);
|
||||
|
||||
if (!ret)
|
||||
|
||||
@@ -28,13 +28,6 @@ config STI_RESET
|
||||
Say Y if you want to control reset signals provided by system config
|
||||
block.
|
||||
|
||||
config STM32_RESET
|
||||
bool "Enable the STM32 reset"
|
||||
depends on ARCH_STM32 || ARCH_STM32MP
|
||||
help
|
||||
Support for reset controllers on STMicroelectronics STM32 family SoCs.
|
||||
This reset driver is compatible with STM32 F4/F7 and H7 SoCs.
|
||||
|
||||
config TEGRA_CAR_RESET
|
||||
bool "Enable Tegra CAR-based reset driver"
|
||||
depends on TEGRA_CAR
|
||||
@@ -258,4 +251,6 @@ config RESET_SPACEMIT_K1
|
||||
help
|
||||
Support for SPACEMIT's K1 Reset system. Basic Assert/Deassert
|
||||
is supported.
|
||||
|
||||
source "drivers/reset/stm32/Kconfig"
|
||||
endmenu
|
||||
|
||||
@@ -7,7 +7,6 @@ obj-$(CONFIG_DM_RESET) += reset-uclass.o
|
||||
obj-$(CONFIG_SANDBOX_MBOX) += sandbox-reset.o
|
||||
obj-$(CONFIG_SANDBOX_MBOX) += sandbox-reset-test.o
|
||||
obj-$(CONFIG_STI_RESET) += sti-reset.o
|
||||
obj-$(CONFIG_STM32_RESET) += stm32-reset.o
|
||||
obj-$(CONFIG_TEGRA_CAR_RESET) += tegra-car-reset.o
|
||||
obj-$(CONFIG_TEGRA186_RESET) += tegra186-reset.o
|
||||
obj-$(CONFIG_RESET_AIROHA) += reset-airoha.o
|
||||
@@ -36,3 +35,6 @@ obj-$(CONFIG_RESET_AT91) += reset-at91.o
|
||||
obj-$(CONFIG_$(PHASE_)RESET_JH7110) += reset-jh7110.o
|
||||
obj-$(CONFIG_RESET_RZG2L_USBPHY_CTRL) += reset-rzg2l-usbphy-ctrl.o
|
||||
obj-$(CONFIG_RESET_SPACEMIT_K1) += reset-spacemit-k1.o
|
||||
|
||||
obj-$(CONFIG_ARCH_STM32) += stm32/
|
||||
obj-$(CONFIG_ARCH_STM32MP) += stm32/
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_RESET
|
||||
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <log.h>
|
||||
#include <malloc.h>
|
||||
#include <reset-uclass.h>
|
||||
#include <stm32_rcc.h>
|
||||
#include <asm/io.h>
|
||||
#include <dm/device_compat.h>
|
||||
#include <linux/bitops.h>
|
||||
|
||||
/* offset of register without set/clear management */
|
||||
#define RCC_MP_GCR_OFFSET 0x10C
|
||||
|
||||
/* reset clear offset for STM32MP RCC */
|
||||
#define RCC_CL 0x4
|
||||
|
||||
struct stm32_reset_priv {
|
||||
fdt_addr_t base;
|
||||
};
|
||||
|
||||
static int stm32_reset_assert(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
||||
int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
|
||||
int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
|
||||
|
||||
dev_dbg(reset_ctl->dev, "reset id = %ld bank = %d offset = %d)\n",
|
||||
reset_ctl->id, bank, offset);
|
||||
|
||||
if (dev_get_driver_data(reset_ctl->dev) == STM32MP1)
|
||||
if (bank != RCC_MP_GCR_OFFSET)
|
||||
/* reset assert is done in rcc set register */
|
||||
writel(BIT(offset), priv->base + bank);
|
||||
else
|
||||
clrbits_le32(priv->base + bank, BIT(offset));
|
||||
else
|
||||
setbits_le32(priv->base + bank, BIT(offset));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32_reset_deassert(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
||||
int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
|
||||
int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
|
||||
|
||||
dev_dbg(reset_ctl->dev, "reset id = %ld bank = %d offset = %d)\n",
|
||||
reset_ctl->id, bank, offset);
|
||||
|
||||
if (dev_get_driver_data(reset_ctl->dev) == STM32MP1)
|
||||
if (bank != RCC_MP_GCR_OFFSET)
|
||||
/* reset deassert is done in rcc clr register */
|
||||
writel(BIT(offset), priv->base + bank + RCC_CL);
|
||||
else
|
||||
setbits_le32(priv->base + bank, BIT(offset));
|
||||
else
|
||||
clrbits_le32(priv->base + bank, BIT(offset));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct reset_ops stm32_reset_ops = {
|
||||
.rst_assert = stm32_reset_assert,
|
||||
.rst_deassert = stm32_reset_deassert,
|
||||
};
|
||||
|
||||
static int stm32_reset_probe(struct udevice *dev)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(dev);
|
||||
|
||||
priv->base = dev_read_addr(dev);
|
||||
if (priv->base == FDT_ADDR_T_NONE) {
|
||||
/* for MFD, get address of parent */
|
||||
priv->base = dev_read_addr(dev->parent);
|
||||
if (priv->base == FDT_ADDR_T_NONE)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(stm32_rcc_reset) = {
|
||||
.name = "stm32_rcc_reset",
|
||||
.id = UCLASS_RESET,
|
||||
.probe = stm32_reset_probe,
|
||||
.priv_auto = sizeof(struct stm32_reset_priv),
|
||||
.ops = &stm32_reset_ops,
|
||||
};
|
||||
23
drivers/reset/stm32/Kconfig
Normal file
23
drivers/reset/stm32/Kconfig
Normal file
@@ -0,0 +1,23 @@
|
||||
config RESET_STM32
|
||||
bool "Enable the STM32 reset"
|
||||
depends on ARCH_STM32
|
||||
default y
|
||||
help
|
||||
Support for reset controllers on STMicroelectronics STM32 family SoCs.
|
||||
This reset driver is compatible with STM32 F4/F7 and H7 SoCs.
|
||||
|
||||
config RESET_STM32MP1
|
||||
bool "Enable the STM32MP1 reset"
|
||||
depends on STM32MP13X || STM32MP15X
|
||||
default y
|
||||
help
|
||||
Support for reset controllers on STMicroelectronics STM32MP1 family SoCs.
|
||||
This reset driver is compatible with STM32MP13 and STM32MP15 SoCs.
|
||||
|
||||
config RESET_STM32MP25
|
||||
bool "Enable the STM32MP25 reset"
|
||||
depends on STM32MP25X
|
||||
default y
|
||||
help
|
||||
Support for reset controllers on STMicroelectronics STM32MP2 family SoCs.
|
||||
This reset driver is compatible with STM32MP25 SoCs.
|
||||
9
drivers/reset/stm32/Makefile
Normal file
9
drivers/reset/stm32/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Copyright (C) 2024, STMicroelectronics - All Rights Reserved
|
||||
|
||||
obj-y += stm32-reset-core.o
|
||||
|
||||
obj-$(CONFIG_RESET_STM32) += stm32-reset.o
|
||||
obj-$(CONFIG_RESET_STM32MP1) += stm32-reset-mp1.o
|
||||
obj-$(CONFIG_RESET_STM32MP25) += stm32-reset-mp25.o
|
||||
92
drivers/reset/stm32/stm32-reset-core.c
Normal file
92
drivers/reset/stm32/stm32-reset-core.c
Normal file
@@ -0,0 +1,92 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
|
||||
/*
|
||||
* Copyright (C) 2024, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Gabriel Fernandez, <gabriel.fernandez@foss.st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <reset-uclass.h>
|
||||
#include <stm32-reset-core.h>
|
||||
#include <stm32_rcc.h>
|
||||
#include <dm/device_compat.h>
|
||||
#include <linux/iopoll.h>
|
||||
|
||||
static int stm32_reset_update(struct reset_ctl *reset_ctl, bool status)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
||||
const struct stm32_reset_data *data = priv->data;
|
||||
const struct stm32_reset_cfg *ptr_line;
|
||||
fdt_addr_t addr;
|
||||
|
||||
assert(priv->data->get_reset_line);
|
||||
|
||||
ptr_line = priv->data->get_reset_line(reset_ctl);
|
||||
if (!ptr_line)
|
||||
return -EPERM;
|
||||
|
||||
addr = priv->base + ptr_line->offset;
|
||||
|
||||
dev_dbg(reset_ctl->dev, "reset id=%ld offset=0x%x bit=%d status=%d\n",
|
||||
reset_ctl->id, ptr_line->offset, ptr_line->bit_idx, status);
|
||||
|
||||
status = ptr_line->inverted ^ status;
|
||||
|
||||
if (ptr_line->set_clr) {
|
||||
if (!status)
|
||||
addr += data->clear_offset;
|
||||
|
||||
writel(BIT(ptr_line->bit_idx), addr);
|
||||
|
||||
} else {
|
||||
if (status)
|
||||
setbits_le32(addr, BIT(ptr_line->bit_idx));
|
||||
else
|
||||
clrbits_le32(addr, BIT(ptr_line->bit_idx));
|
||||
}
|
||||
|
||||
/* Check deassert */
|
||||
if (!status) {
|
||||
u32 reg;
|
||||
|
||||
return readl_poll_timeout(addr, reg,
|
||||
!(reg & BIT(ptr_line->bit_idx)),
|
||||
data->reset_us);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32_reset_assert(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
return stm32_reset_update(reset_ctl, true);
|
||||
}
|
||||
|
||||
static int stm32_reset_deassert(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
return stm32_reset_update(reset_ctl, false);
|
||||
}
|
||||
|
||||
const struct reset_ops stm32_reset_ops = {
|
||||
.rst_assert = stm32_reset_assert,
|
||||
.rst_deassert = stm32_reset_deassert,
|
||||
};
|
||||
|
||||
int stm32_reset_core_probe(struct udevice *dev,
|
||||
const struct stm32_reset_data *data)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(dev);
|
||||
|
||||
priv->base = dev_read_addr(dev);
|
||||
if (priv->base == FDT_ADDR_T_NONE) {
|
||||
/* for MFD, get address of parent */
|
||||
priv->base = dev_read_addr(dev->parent);
|
||||
if (priv->base == FDT_ADDR_T_NONE)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
priv->data = data;
|
||||
|
||||
assert(priv->data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
31
drivers/reset/stm32/stm32-reset-core.h
Normal file
31
drivers/reset/stm32/stm32-reset-core.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C) 2025, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Gabriel Fernandez, <gabriel.fernandez@foss.st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#include <reset-uclass.h>
|
||||
|
||||
struct stm32_reset_cfg {
|
||||
u16 offset;
|
||||
u8 bit_idx;
|
||||
bool set_clr;
|
||||
bool inverted;
|
||||
};
|
||||
|
||||
struct stm32_reset_data {
|
||||
const struct stm32_reset_cfg * (*get_reset_line)(struct reset_ctl *reset_ctl);
|
||||
u32 clear_offset;
|
||||
u32 reset_us;
|
||||
};
|
||||
|
||||
struct stm32_reset_priv {
|
||||
fdt_addr_t base;
|
||||
struct stm32_reset_cfg reset_line;
|
||||
const struct stm32_reset_data *data;
|
||||
};
|
||||
|
||||
extern const struct reset_ops stm32_reset_ops;
|
||||
|
||||
int stm32_reset_core_probe(struct udevice *dev,
|
||||
const struct stm32_reset_data *data);
|
||||
55
drivers/reset/stm32/stm32-reset-mp1.c
Normal file
55
drivers/reset/stm32/stm32-reset-mp1.c
Normal file
@@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
|
||||
/*
|
||||
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <stm32-reset-core.h>
|
||||
|
||||
/* Reset clear offset for STM32MP RCC */
|
||||
#define RCC_CLR_OFFSET 0x4
|
||||
|
||||
/* Offset of register without set/clear management */
|
||||
#define RCC_MP_GCR_OFFSET 0x10C
|
||||
|
||||
/* Timeout for deassert */
|
||||
#define STM32_DEASSERT_TIMEOUT_US 10000
|
||||
|
||||
static const struct stm32_reset_cfg *stm32_get_reset_line(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
||||
struct stm32_reset_cfg *ptr_line = &priv->reset_line;
|
||||
int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
|
||||
int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
|
||||
|
||||
ptr_line->offset = bank;
|
||||
ptr_line->bit_idx = offset;
|
||||
ptr_line->set_clr = true;
|
||||
|
||||
if (ptr_line->offset == RCC_MP_GCR_OFFSET) {
|
||||
ptr_line->set_clr = false;
|
||||
ptr_line->inverted = true;
|
||||
}
|
||||
|
||||
return ptr_line;
|
||||
}
|
||||
|
||||
static const struct stm32_reset_data stm32mp1_reset_data = {
|
||||
.get_reset_line = stm32_get_reset_line,
|
||||
.clear_offset = RCC_CLR_OFFSET,
|
||||
.reset_us = STM32_DEASSERT_TIMEOUT_US,
|
||||
};
|
||||
|
||||
static int stm32_reset_probe(struct udevice *dev)
|
||||
{
|
||||
return stm32_reset_core_probe(dev, &stm32mp1_reset_data);
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(stm32mp25_rcc_reset) = {
|
||||
.name = "stm32mp1_reset",
|
||||
.id = UCLASS_RESET,
|
||||
.probe = stm32_reset_probe,
|
||||
.priv_auto = sizeof(struct stm32_reset_priv),
|
||||
.ops = &stm32_reset_ops,
|
||||
};
|
||||
159
drivers/reset/stm32/stm32-reset-mp25.c
Normal file
159
drivers/reset/stm32/stm32-reset-mp25.c
Normal file
@@ -0,0 +1,159 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
|
||||
/*
|
||||
* Copyright (C) 2024, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Gabriel Fernandez, <gabriel.fernandez@foss.st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <stm32-reset-core.h>
|
||||
#include <stm32mp25_rcc.h>
|
||||
#include <dt-bindings/reset/st,stm32mp25-rcc.h>
|
||||
|
||||
/* Reset clear offset for STM32MP RCC */
|
||||
#define RCC_CLR_OFFSET 0x4
|
||||
|
||||
/* Timeout for deassert */
|
||||
#define STM32_DEASSERT_TIMEOUT_US 10000
|
||||
|
||||
#define RESET(id, _offset, _bit_idx, _set_clr) \
|
||||
[id] = &(struct stm32_reset_cfg){ \
|
||||
.offset = (_offset), \
|
||||
.bit_idx = (_bit_idx), \
|
||||
.set_clr = (_set_clr), \
|
||||
}
|
||||
|
||||
static const struct stm32_reset_cfg *stm32mp25_reset[STM32MP25_LAST_RESET] = {
|
||||
RESET(TIM1_R, RCC_TIM1CFGR, 0, 0),
|
||||
RESET(TIM2_R, RCC_TIM2CFGR, 0, 0),
|
||||
RESET(TIM3_R, RCC_TIM3CFGR, 0, 0),
|
||||
RESET(TIM4_R, RCC_TIM4CFGR, 0, 0),
|
||||
RESET(TIM5_R, RCC_TIM5CFGR, 0, 0),
|
||||
RESET(TIM6_R, RCC_TIM6CFGR, 0, 0),
|
||||
RESET(TIM7_R, RCC_TIM7CFGR, 0, 0),
|
||||
RESET(TIM8_R, RCC_TIM8CFGR, 0, 0),
|
||||
RESET(TIM10_R, RCC_TIM10CFGR, 0, 0),
|
||||
RESET(TIM11_R, RCC_TIM11CFGR, 0, 0),
|
||||
RESET(TIM12_R, RCC_TIM12CFGR, 0, 0),
|
||||
RESET(TIM13_R, RCC_TIM13CFGR, 0, 0),
|
||||
RESET(TIM14_R, RCC_TIM14CFGR, 0, 0),
|
||||
RESET(TIM15_R, RCC_TIM15CFGR, 0, 0),
|
||||
RESET(TIM16_R, RCC_TIM16CFGR, 0, 0),
|
||||
RESET(TIM17_R, RCC_TIM17CFGR, 0, 0),
|
||||
RESET(TIM20_R, RCC_TIM20CFGR, 0, 0),
|
||||
RESET(LPTIM1_R, RCC_LPTIM1CFGR, 0, 0),
|
||||
RESET(LPTIM2_R, RCC_LPTIM2CFGR, 0, 0),
|
||||
RESET(LPTIM3_R, RCC_LPTIM3CFGR, 0, 0),
|
||||
RESET(LPTIM4_R, RCC_LPTIM4CFGR, 0, 0),
|
||||
RESET(LPTIM5_R, RCC_LPTIM5CFGR, 0, 0),
|
||||
RESET(SPI1_R, RCC_SPI1CFGR, 0, 0),
|
||||
RESET(SPI2_R, RCC_SPI2CFGR, 0, 0),
|
||||
RESET(SPI3_R, RCC_SPI3CFGR, 0, 0),
|
||||
RESET(SPI4_R, RCC_SPI4CFGR, 0, 0),
|
||||
RESET(SPI5_R, RCC_SPI5CFGR, 0, 0),
|
||||
RESET(SPI6_R, RCC_SPI6CFGR, 0, 0),
|
||||
RESET(SPI7_R, RCC_SPI7CFGR, 0, 0),
|
||||
RESET(SPI8_R, RCC_SPI8CFGR, 0, 0),
|
||||
RESET(SPDIFRX_R, RCC_SPDIFRXCFGR, 0, 0),
|
||||
RESET(USART1_R, RCC_USART1CFGR, 0, 0),
|
||||
RESET(USART2_R, RCC_USART2CFGR, 0, 0),
|
||||
RESET(USART3_R, RCC_USART3CFGR, 0, 0),
|
||||
RESET(UART4_R, RCC_UART4CFGR, 0, 0),
|
||||
RESET(UART5_R, RCC_UART5CFGR, 0, 0),
|
||||
RESET(USART6_R, RCC_USART6CFGR, 0, 0),
|
||||
RESET(UART7_R, RCC_UART7CFGR, 0, 0),
|
||||
RESET(UART8_R, RCC_UART8CFGR, 0, 0),
|
||||
RESET(UART9_R, RCC_UART9CFGR, 0, 0),
|
||||
RESET(LPUART1_R, RCC_LPUART1CFGR, 0, 0),
|
||||
RESET(IS2M_R, RCC_IS2MCFGR, 0, 0),
|
||||
RESET(I2C1_R, RCC_I2C1CFGR, 0, 0),
|
||||
RESET(I2C2_R, RCC_I2C2CFGR, 0, 0),
|
||||
RESET(I2C3_R, RCC_I2C3CFGR, 0, 0),
|
||||
RESET(I2C4_R, RCC_I2C4CFGR, 0, 0),
|
||||
RESET(I2C5_R, RCC_I2C5CFGR, 0, 0),
|
||||
RESET(I2C6_R, RCC_I2C6CFGR, 0, 0),
|
||||
RESET(I2C7_R, RCC_I2C7CFGR, 0, 0),
|
||||
RESET(I2C8_R, RCC_I2C8CFGR, 0, 0),
|
||||
RESET(SAI1_R, RCC_SAI1CFGR, 0, 0),
|
||||
RESET(SAI2_R, RCC_SAI2CFGR, 0, 0),
|
||||
RESET(SAI3_R, RCC_SAI3CFGR, 0, 0),
|
||||
RESET(SAI4_R, RCC_SAI4CFGR, 0, 0),
|
||||
RESET(MDF1_R, RCC_MDF1CFGR, 0, 0),
|
||||
RESET(MDF2_R, RCC_ADF1CFGR, 0, 0),
|
||||
RESET(FDCAN_R, RCC_FDCANCFGR, 0, 0),
|
||||
RESET(HDP_R, RCC_HDPCFGR, 0, 0),
|
||||
RESET(ADC12_R, RCC_ADC12CFGR, 0, 0),
|
||||
RESET(ADC3_R, RCC_ADC3CFGR, 0, 0),
|
||||
RESET(ETH1_R, RCC_ETH1CFGR, 0, 0),
|
||||
RESET(ETH2_R, RCC_ETH2CFGR, 0, 0),
|
||||
RESET(USBH_R, RCC_USBHCFGR, 0, 0),
|
||||
RESET(USB2PHY1_R, RCC_USB2PHY1CFGR, 0, 0),
|
||||
RESET(USB2PHY2_R, RCC_USB2PHY2CFGR, 0, 0),
|
||||
RESET(USB3DR_R, RCC_USB3DRCFGR, 0, 0),
|
||||
RESET(USB3PCIEPHY_R, RCC_USB3PCIEPHYCFGR, 0, 0),
|
||||
RESET(USBTC_R, RCC_UCPDCFGR, 0, 0),
|
||||
RESET(ETHSW_R, RCC_ETHSWCFGR, 0, 0),
|
||||
RESET(SDMMC1_R, RCC_SDMMC1CFGR, 0, 0),
|
||||
RESET(SDMMC1DLL_R, RCC_SDMMC1CFGR, 16, 0),
|
||||
RESET(SDMMC2_R, RCC_SDMMC2CFGR, 0, 0),
|
||||
RESET(SDMMC2DLL_R, RCC_SDMMC2CFGR, 16, 0),
|
||||
RESET(SDMMC3_R, RCC_SDMMC3CFGR, 0, 0),
|
||||
RESET(SDMMC3DLL_R, RCC_SDMMC3CFGR, 16, 0),
|
||||
RESET(GPU_R, RCC_GPUCFGR, 0, 0),
|
||||
RESET(LTDC_R, RCC_LTDCCFGR, 0, 0),
|
||||
RESET(DSI_R, RCC_DSICFGR, 0, 0),
|
||||
RESET(LVDS_R, RCC_LVDSCFGR, 0, 0),
|
||||
RESET(CSI_R, RCC_CSICFGR, 0, 0),
|
||||
RESET(DCMIPP_R, RCC_DCMIPPCFGR, 0, 0),
|
||||
RESET(CCI_R, RCC_CCICFGR, 0, 0),
|
||||
RESET(VDEC_R, RCC_VDECCFGR, 0, 0),
|
||||
RESET(VENC_R, RCC_VENCCFGR, 0, 0),
|
||||
RESET(WWDG1_R, RCC_WWDG1CFGR, 0, 0),
|
||||
RESET(WWDG2_R, RCC_WWDG2CFGR, 0, 0),
|
||||
RESET(VREF_R, RCC_VREFCFGR, 0, 0),
|
||||
RESET(DTS_R, RCC_DTSCFGR, 0, 0),
|
||||
RESET(CRC_R, RCC_CRCCFGR, 0, 0),
|
||||
RESET(SERC_R, RCC_SERCCFGR, 0, 0),
|
||||
RESET(OSPIIOM_R, RCC_OSPIIOMCFGR, 0, 0),
|
||||
RESET(I3C1_R, RCC_I3C1CFGR, 0, 0),
|
||||
RESET(I3C2_R, RCC_I3C2CFGR, 0, 0),
|
||||
RESET(I3C3_R, RCC_I3C3CFGR, 0, 0),
|
||||
RESET(I3C4_R, RCC_I3C4CFGR, 0, 0),
|
||||
RESET(IWDG2_KER_R, RCC_IWDGC1CFGSETR, 18, 1),
|
||||
RESET(IWDG4_KER_R, RCC_IWDGC2CFGSETR, 18, 1),
|
||||
RESET(RNG_R, RCC_RNGCFGR, 0, 0),
|
||||
RESET(PKA_R, RCC_PKACFGR, 0, 0),
|
||||
RESET(SAES_R, RCC_SAESCFGR, 0, 0),
|
||||
RESET(HASH_R, RCC_HASHCFGR, 0, 0),
|
||||
RESET(CRYP1_R, RCC_CRYP1CFGR, 0, 0),
|
||||
RESET(CRYP2_R, RCC_CRYP2CFGR, 0, 0),
|
||||
RESET(PCIE_R, RCC_PCIECFGR, 0, 0),
|
||||
};
|
||||
|
||||
static const struct stm32_reset_cfg *stm32_get_reset_line(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
unsigned long id = reset_ctl->id;
|
||||
|
||||
if (id < STM32MP25_LAST_RESET)
|
||||
return stm32mp25_reset[id];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct stm32_reset_data stm32mp25_reset_data = {
|
||||
.get_reset_line = stm32_get_reset_line,
|
||||
.clear_offset = RCC_CLR_OFFSET,
|
||||
.reset_us = STM32_DEASSERT_TIMEOUT_US,
|
||||
};
|
||||
|
||||
static int stm32_reset_probe(struct udevice *dev)
|
||||
{
|
||||
return stm32_reset_core_probe(dev, &stm32mp25_reset_data);
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(stm32mp25_rcc_reset) = {
|
||||
.name = "stm32mp25_reset",
|
||||
.id = UCLASS_RESET,
|
||||
.probe = stm32_reset_probe,
|
||||
.priv_auto = sizeof(struct stm32_reset_priv),
|
||||
.ops = &stm32_reset_ops,
|
||||
};
|
||||
43
drivers/reset/stm32/stm32-reset.c
Normal file
43
drivers/reset/stm32/stm32-reset.c
Normal file
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
|
||||
/*
|
||||
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
||||
* Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <stm32-reset-core.h>
|
||||
|
||||
/* Timeout for deassert */
|
||||
#define STM32_DEASSERT_TIMEOUT_US 10000
|
||||
|
||||
static const struct stm32_reset_cfg *stm32_get_reset_line(struct reset_ctl *reset_ctl)
|
||||
{
|
||||
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
||||
struct stm32_reset_cfg *ptr_line = &priv->reset_line;
|
||||
int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
|
||||
int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
|
||||
|
||||
ptr_line->offset = bank;
|
||||
ptr_line->bit_idx = offset;
|
||||
ptr_line->set_clr = true;
|
||||
|
||||
return ptr_line;
|
||||
}
|
||||
|
||||
static const struct stm32_reset_data stm32_reset_data = {
|
||||
.get_reset_line = stm32_get_reset_line,
|
||||
.reset_us = STM32_DEASSERT_TIMEOUT_US,
|
||||
};
|
||||
|
||||
static int stm32_reset_probe(struct udevice *dev)
|
||||
{
|
||||
return stm32_reset_core_probe(dev, &stm32_reset_data);
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(stm32_rcc_reset) = {
|
||||
.name = "stm32_rcc_reset",
|
||||
.id = UCLASS_RESET,
|
||||
.probe = stm32_reset_probe,
|
||||
.priv_auto = sizeof(struct stm32_reset_priv),
|
||||
.ops = &stm32_reset_ops,
|
||||
};
|
||||
@@ -42,6 +42,10 @@ properties:
|
||||
- st,stm32h743i-disco
|
||||
- st,stm32h743i-eval
|
||||
- const: st,stm32h743
|
||||
- items:
|
||||
- enum:
|
||||
- st,stm32h747i-disco
|
||||
- const: st,stm32h747
|
||||
- items:
|
||||
- enum:
|
||||
- st,stm32h750i-art-pi
|
||||
|
||||
@@ -126,8 +126,8 @@
|
||||
#define ADC3_CK 128
|
||||
#define DSI_CK 129
|
||||
#define LTDC_CK 130
|
||||
#define USART8_CK 131
|
||||
#define USART7_CK 132
|
||||
#define UART8_CK 131
|
||||
#define UART7_CK 132
|
||||
#define HDMICEC_CK 133
|
||||
#define I2C3_CK 134
|
||||
#define I2C2_CK 135
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
};
|
||||
};
|
||||
|
||||
uart4_pins: uart4-0 {
|
||||
uart4_pins_a: uart4-0 {
|
||||
pins1 {
|
||||
pinmux = <STM32_PINMUX('A', 0, AF8)>; /* UART4_TX */
|
||||
bias-disable;
|
||||
@@ -211,7 +211,20 @@
|
||||
};
|
||||
};
|
||||
|
||||
usart1_pins: usart1-0 {
|
||||
uart8_pins_a: uart8-0 {
|
||||
pins1 {
|
||||
pinmux = <STM32_PINMUX('J', 8, AF8)>; /* UART8_TX */
|
||||
bias-disable;
|
||||
drive-push-pull;
|
||||
slew-rate = <0>;
|
||||
};
|
||||
pins2 {
|
||||
pinmux = <STM32_PINMUX('J', 9, AF8)>; /* UART8_RX */
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
usart1_pins_a: usart1-0 {
|
||||
pins1 {
|
||||
pinmux = <STM32_PINMUX('B', 14, AF4)>; /* USART1_TX */
|
||||
bias-disable;
|
||||
@@ -224,7 +237,20 @@
|
||||
};
|
||||
};
|
||||
|
||||
usart2_pins: usart2-0 {
|
||||
usart1_pins_b: usart1-1 {
|
||||
pins1 {
|
||||
pinmux = <STM32_PINMUX('A', 9, AF7)>; /* USART1_TX */
|
||||
bias-disable;
|
||||
drive-push-pull;
|
||||
slew-rate = <0>;
|
||||
};
|
||||
pins2 {
|
||||
pinmux = <STM32_PINMUX('A', 10, AF7)>; /* USART1_RX */
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
usart2_pins_a: usart2-0 {
|
||||
pins1 {
|
||||
pinmux = <STM32_PINMUX('D', 5, AF7)>; /* USART2_TX */
|
||||
bias-disable;
|
||||
@@ -237,7 +263,7 @@
|
||||
};
|
||||
};
|
||||
|
||||
usart3_pins: usart3-0 {
|
||||
usart3_pins_a: usart3-0 {
|
||||
pins1 {
|
||||
pinmux = <STM32_PINMUX('B', 10, AF7)>, /* USART3_TX */
|
||||
<STM32_PINMUX('D', 12, AF7)>; /* USART3_RTS_DE */
|
||||
|
||||
@@ -211,6 +211,14 @@
|
||||
};
|
||||
};
|
||||
|
||||
uart8: serial@40007c00 {
|
||||
compatible = "st,stm32h7-uart";
|
||||
reg = <0x40007c00 0x400>;
|
||||
interrupts = <83>;
|
||||
status = "disabled";
|
||||
clocks = <&rcc UART8_CK>;
|
||||
};
|
||||
|
||||
usart1: serial@40011000 {
|
||||
compatible = "st,stm32h7-uart";
|
||||
reg = <0x40011000 0x400>;
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_pins>;
|
||||
pinctrl-0 = <&usart2_pins_a>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_pins>;
|
||||
pinctrl-0 = <&usart1_pins_a>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
136
dts/upstream/src/arm/st/stm32h747i-disco.dts
Normal file
136
dts/upstream/src/arm/st/stm32h747i-disco.dts
Normal file
@@ -0,0 +1,136 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2025 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include "stm32h743.dtsi"
|
||||
#include "stm32h7-pinctrl.dtsi"
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/input/input.h>
|
||||
|
||||
/ {
|
||||
model = "STMicroelectronics STM32H747i-Discovery board";
|
||||
compatible = "st,stm32h747i-disco", "st,stm32h747";
|
||||
|
||||
chosen {
|
||||
bootargs = "root=/dev/ram";
|
||||
stdout-path = "serial0:115200n8";
|
||||
};
|
||||
|
||||
memory@d0000000 {
|
||||
device_type = "memory";
|
||||
reg = <0xd0000000 0x2000000>;
|
||||
};
|
||||
|
||||
aliases {
|
||||
serial0 = &usart1;
|
||||
serial1 = &uart8;
|
||||
};
|
||||
|
||||
v3v3: regulator-v3v3 {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "v3v3";
|
||||
regulator-min-microvolt = <3300000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
led-green {
|
||||
gpios = <&gpioi 12 GPIO_ACTIVE_LOW>;
|
||||
linux,default-trigger = "heartbeat";
|
||||
};
|
||||
led-orange {
|
||||
gpios = <&gpioi 13 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
led-red {
|
||||
gpios = <&gpioi 14 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
led-blue {
|
||||
gpios = <&gpioi 15 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio-keys {
|
||||
compatible = "gpio-keys";
|
||||
autorepeat;
|
||||
button-0 {
|
||||
label = "User";
|
||||
linux,code = <KEY_WAKEUP>;
|
||||
gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
button-1 {
|
||||
label = "JoySel";
|
||||
linux,code = <KEY_ENTER>;
|
||||
gpios = <&gpiok 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
button-2 {
|
||||
label = "JoyDown";
|
||||
linux,code = <KEY_DOWN>;
|
||||
gpios = <&gpiok 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
button-3 {
|
||||
label = "JoyUp";
|
||||
linux,code = <KEY_UP>;
|
||||
gpios = <&gpiok 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
button-4 {
|
||||
label = "JoyLeft";
|
||||
linux,code = <KEY_LEFT>;
|
||||
gpios = <&gpiok 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
button-5 {
|
||||
label = "JoyRight";
|
||||
linux,code = <KEY_RIGHT>;
|
||||
gpios = <&gpiok 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&clk_hse {
|
||||
clock-frequency = <25000000>;
|
||||
};
|
||||
|
||||
&mac {
|
||||
status = "disabled";
|
||||
pinctrl-0 = <ðernet_rmii>;
|
||||
pinctrl-names = "default";
|
||||
phy-mode = "rmii";
|
||||
phy-handle = <&phy0>;
|
||||
|
||||
mdio0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&sdmmc1 {
|
||||
pinctrl-names = "default", "opendrain", "sleep";
|
||||
pinctrl-0 = <&sdmmc1_b4_pins_a>;
|
||||
pinctrl-1 = <&sdmmc1_b4_od_pins_a>;
|
||||
pinctrl-2 = <&sdmmc1_b4_sleep_pins_a>;
|
||||
cd-gpios = <&gpioi 8 GPIO_ACTIVE_LOW>;
|
||||
broken-cd;
|
||||
st,neg-edge;
|
||||
bus-width = <4>;
|
||||
vmmc-supply = <&v3v3>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
pinctrl-0 = <&usart1_pins_b>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&uart8 {
|
||||
pinctrl-0 = <&uart8_pins_a>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
@@ -197,14 +197,14 @@
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
pinctrl-0 = <&usart2_pins>;
|
||||
pinctrl-0 = <&usart2_pins_a>;
|
||||
pinctrl-names = "default";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&usart3 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&usart3_pins>;
|
||||
pinctrl-0 = <&usart3_pins_a>;
|
||||
dmas = <&dmamux1 45 0x400 0x05>,
|
||||
<&dmamux1 46 0x400 0x05>;
|
||||
dma-names = "rx", "tx";
|
||||
@@ -221,7 +221,7 @@
|
||||
};
|
||||
|
||||
&uart4 {
|
||||
pinctrl-0 = <&uart4_pins>;
|
||||
pinctrl-0 = <&uart4_pins_a>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -13,6 +13,15 @@
|
||||
#include <linux/errno.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#ifdef CONFIG_CLK_AUTO_ID
|
||||
#define CLK_ID_SZ 24
|
||||
#define CLK_ID_MSK GENMASK(23, 0)
|
||||
#define CLK_ID(dev, id) (((dev_seq(dev) + 1) << CLK_ID_SZ) | ((id) & CLK_ID_MSK))
|
||||
#else
|
||||
#define CLK_ID_MSK (~0UL)
|
||||
#define CLK_ID(dev, id) id
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DOC: Overview
|
||||
*
|
||||
@@ -570,6 +579,16 @@ int clk_get_by_id(ulong id, struct clk **clkp);
|
||||
*/
|
||||
bool clk_dev_binded(struct clk *clk);
|
||||
|
||||
/**
|
||||
* clk_get_id - get clk id
|
||||
*
|
||||
* @clk: A clock struct
|
||||
*
|
||||
* Return: the clock identifier as it is defined by the clock provider in
|
||||
* device tree or in platdata
|
||||
*/
|
||||
ulong clk_get_id(const struct clk *clk);
|
||||
|
||||
#else /* CONFIG_IS_ENABLED(CLK) */
|
||||
|
||||
static inline int clk_request(struct udevice *dev, struct clk *clk)
|
||||
@@ -641,6 +660,11 @@ static inline bool clk_dev_binded(struct clk *clk)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline ulong clk_get_id(const struct clk *clk)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_IS_ENABLED(CLK) */
|
||||
|
||||
/**
|
||||
|
||||
32
include/configs/stm32h747-disco.h
Normal file
32
include/configs/stm32h747-disco.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2025 Dario Binacchi <dario.binacchi@amarulasolutions.com>
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
#include <config.h>
|
||||
#include <linux/sizes.h>
|
||||
|
||||
/* For booting Linux, use the first 16MB of memory */
|
||||
#define CFG_SYS_BOOTMAPSZ SZ_16M
|
||||
|
||||
#define CFG_SYS_FLASH_BASE 0x08000000
|
||||
|
||||
#define CFG_SYS_HZ_CLOCK 1000000
|
||||
|
||||
#define BOOT_TARGET_DEVICES(func) \
|
||||
func(MMC, mmc, 0)
|
||||
|
||||
#include <config_distro_bootcmd.h>
|
||||
#define CFG_EXTRA_ENV_SETTINGS \
|
||||
"kernel_addr_r=0xD0008000\0" \
|
||||
"fdtfile=stm32h747i-disco.dtb\0" \
|
||||
"fdt_addr_r=0xD0408000\0" \
|
||||
"scriptaddr=0xD0418000\0" \
|
||||
"pxefile_addr_r=0xD0428000\0" \
|
||||
"ramdisk_addr_r=0xD0438000\0" \
|
||||
BOOTENV
|
||||
|
||||
#endif /* __CONFIG_H */
|
||||
399
include/dt-bindings/clock/stm32mp13-clksrc.h
Normal file
399
include/dt-bindings/clock/stm32mp13-clksrc.h
Normal file
@@ -0,0 +1,399 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C) 2018, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DT_BINDINGS_CLOCK_STM32MP13_CLKSRC_H_
|
||||
#define _DT_BINDINGS_CLOCK_STM32MP13_CLKSRC_H_
|
||||
|
||||
/* PLL output is enable when x=1, with x=p,q or r */
|
||||
#define PQR(p, q, r) (((p) & 1) | (((q) & 1) << 1) | (((r) & 1) << 2))
|
||||
|
||||
/* st,clksrc: mandatory clock source */
|
||||
|
||||
#define CMD_DIV 0
|
||||
#define CMD_MUX 1
|
||||
#define CMD_CLK 2
|
||||
#define CMD_RESERVED1 3
|
||||
|
||||
#define CMD_SHIFT 26
|
||||
#define CMD_MASK 0xFC000000
|
||||
#define CMD_DATA_MASK 0x03FFFFFF
|
||||
|
||||
#define DIV_ID_SHIFT 8
|
||||
#define DIV_ID_MASK 0x0000FF00
|
||||
|
||||
#define DIV_DIVN_SHIFT 0
|
||||
#define DIV_DIVN_MASK 0x000000FF
|
||||
|
||||
#define MUX_ID_SHIFT 4
|
||||
#define MUX_ID_MASK 0x00000FF0
|
||||
|
||||
#define MUX_SEL_SHIFT 0
|
||||
#define MUX_SEL_MASK 0x0000000F
|
||||
|
||||
#define CLK_ID_MASK GENMASK_32(19, 11)
|
||||
#define CLK_ID_SHIFT 11
|
||||
#define CLK_ON_MASK 0x00000400
|
||||
#define CLK_ON_SHIFT 10
|
||||
#define CLK_DIV_MASK GENMASK_32(9, 4)
|
||||
#define CLK_DIV_SHIFT 4
|
||||
#define CLK_SEL_MASK GENMASK_32(3, 0)
|
||||
#define CLK_SEL_SHIFT 0
|
||||
|
||||
#define DIV_PLL1DIVP 0
|
||||
#define DIV_PLL2DIVP 1
|
||||
#define DIV_PLL2DIVQ 2
|
||||
#define DIV_PLL2DIVR 3
|
||||
#define DIV_PLL3DIVP 4
|
||||
#define DIV_PLL3DIVQ 5
|
||||
#define DIV_PLL3DIVR 6
|
||||
#define DIV_PLL4DIVP 7
|
||||
#define DIV_PLL4DIVQ 8
|
||||
#define DIV_PLL4DIVR 9
|
||||
#define DIV_MPU 10
|
||||
#define DIV_AXI 11
|
||||
#define DIV_MLAHB 12
|
||||
#define DIV_APB1 13
|
||||
#define DIV_APB2 14
|
||||
#define DIV_APB3 15
|
||||
#define DIV_APB4 16
|
||||
#define DIV_APB5 17
|
||||
#define DIV_APB6 18
|
||||
#define DIV_RTC 19
|
||||
#define DIV_MCO1 20
|
||||
#define DIV_MCO2 21
|
||||
#define DIV_HSI 22
|
||||
#define DIV_TRACE 23
|
||||
#define DIV_ETH1PTP 24
|
||||
#define DIV_ETH2PTP 25
|
||||
#define DIV_MAX 26
|
||||
|
||||
#define DIV(div_id, div) ((CMD_DIV << CMD_SHIFT) |\
|
||||
((div_id) << DIV_ID_SHIFT |\
|
||||
(div)))
|
||||
|
||||
#define CLKSRC(mux_id, sel) ((CMD_MUX << CMD_SHIFT) |\
|
||||
((mux_id) << MUX_ID_SHIFT |\
|
||||
(sel)))
|
||||
|
||||
/* MCO output is enable */
|
||||
#define MCO_SRC(mco_id, sel) ((CMD_CLK << CMD_SHIFT) |\
|
||||
(((mco_id) << CLK_ID_SHIFT) |\
|
||||
(sel)) | CLK_ON_MASK)
|
||||
|
||||
#define MCO_DISABLED(mco_id) ((CMD_CLK << CMD_SHIFT) |\
|
||||
((mco_id) << CLK_ID_SHIFT))
|
||||
|
||||
/* CLK output is enable */
|
||||
#define CLK_SRC(clk_id, sel) ((CMD_CLK << CMD_SHIFT) |\
|
||||
(((clk_id) << CLK_ID_SHIFT) |\
|
||||
(sel)) | CLK_ON_MASK)
|
||||
|
||||
#define CLK_DISABLED(clk_id) ((CMD_CLK << CMD_SHIFT) |\
|
||||
((clk_id) << CLK_ID_SHIFT))
|
||||
|
||||
#define MUX_MPU 0
|
||||
#define MUX_AXI 1
|
||||
#define MUX_MLAHB 2
|
||||
#define MUX_PLL12 3
|
||||
#define MUX_PLL3 4
|
||||
#define MUX_PLL4 5
|
||||
#define MUX_RTC 6
|
||||
#define MUX_MCO1 7
|
||||
#define MUX_MCO2 8
|
||||
#define MUX_CKPER 9
|
||||
#define MUX_KERNEL_BEGIN 10
|
||||
#define MUX_ADC1 10
|
||||
#define MUX_ADC2 11
|
||||
#define MUX_DCMIPP 12
|
||||
#define MUX_ETH1 13
|
||||
#define MUX_ETH2 14
|
||||
#define MUX_FDCAN 15
|
||||
#define MUX_FMC 16
|
||||
#define MUX_I2C12 17
|
||||
#define MUX_I2C3 18
|
||||
#define MUX_I2C4 19
|
||||
#define MUX_I2C5 20
|
||||
#define MUX_LPTIM1 21
|
||||
#define MUX_LPTIM2 22
|
||||
#define MUX_LPTIM3 23
|
||||
#define MUX_LPTIM45 24
|
||||
#define MUX_QSPI 25
|
||||
#define MUX_RNG1 26
|
||||
#define MUX_SAES 27
|
||||
#define MUX_SAI1 28
|
||||
#define MUX_SAI2 29
|
||||
#define MUX_SDMMC1 30
|
||||
#define MUX_SDMMC2 31
|
||||
#define MUX_SPDIF 32
|
||||
#define MUX_SPI1 33
|
||||
#define MUX_SPI23 34
|
||||
#define MUX_SPI4 35
|
||||
#define MUX_SPI5 36
|
||||
#define MUX_STGEN 37
|
||||
#define MUX_UART1 38
|
||||
#define MUX_UART2 39
|
||||
#define MUX_UART35 40
|
||||
#define MUX_UART4 41
|
||||
#define MUX_UART6 42
|
||||
#define MUX_UART78 43
|
||||
#define MUX_USBO 44
|
||||
#define MUX_USBPHY 45
|
||||
#define MUX_MAX 46
|
||||
|
||||
#define CLK_MPU_HSI CLKSRC(MUX_MPU, 0)
|
||||
#define CLK_MPU_HSE CLKSRC(MUX_MPU, 1)
|
||||
#define CLK_MPU_PLL1P CLKSRC(MUX_MPU, 2)
|
||||
#define CLK_MPU_PLL1P_DIV CLKSRC(MUX_MPU, 3)
|
||||
|
||||
#define CLK_AXI_HSI CLKSRC(MUX_AXI, 0)
|
||||
#define CLK_AXI_HSE CLKSRC(MUX_AXI, 1)
|
||||
#define CLK_AXI_PLL2P CLKSRC(MUX_AXI, 2)
|
||||
|
||||
#define CLK_MLAHBS_HSI CLKSRC(MUX_MLAHB, 0)
|
||||
#define CLK_MLAHBS_HSE CLKSRC(MUX_MLAHB, 1)
|
||||
#define CLK_MLAHBS_CSI CLKSRC(MUX_MLAHB, 2)
|
||||
#define CLK_MLAHBS_PLL3 CLKSRC(MUX_MLAHB, 3)
|
||||
|
||||
#define CLK_PLL12_HSI CLKSRC(MUX_PLL12, 0)
|
||||
#define CLK_PLL12_HSE CLKSRC(MUX_PLL12, 1)
|
||||
|
||||
#define CLK_PLL3_HSI CLKSRC(MUX_PLL3, 0)
|
||||
#define CLK_PLL3_HSE CLKSRC(MUX_PLL3, 1)
|
||||
#define CLK_PLL3_CSI CLKSRC(MUX_PLL3, 2)
|
||||
|
||||
#define CLK_PLL4_HSI CLKSRC(MUX_PLL4, 0)
|
||||
#define CLK_PLL4_HSE CLKSRC(MUX_PLL4, 1)
|
||||
#define CLK_PLL4_CSI CLKSRC(MUX_PLL4, 2)
|
||||
|
||||
#define CLK_RTC_DISABLED CLK_DISABLED(RTC)
|
||||
#define CLK_RTC_LSE CLK_SRC(RTC, 1)
|
||||
#define CLK_RTC_LSI CLK_SRC(RTC, 2)
|
||||
#define CLK_RTC_HSE CLK_SRC(RTC, 3)
|
||||
|
||||
#define CLK_MCO1_HSI CLK_SRC(CK_MCO1, 0)
|
||||
#define CLK_MCO1_HSE CLK_SRC(CK_MCO1, 1)
|
||||
#define CLK_MCO1_CSI CLK_SRC(CK_MCO1, 2)
|
||||
#define CLK_MCO1_LSI CLK_SRC(CK_MCO1, 3)
|
||||
#define CLK_MCO1_LSE CLK_SRC(CK_MCO1, 4)
|
||||
#define CLK_MCO1_DISABLED CLK_DISABLED(CK_MCO1)
|
||||
|
||||
#define CLK_MCO2_MPU CLK_SRC(CK_MCO2, 0)
|
||||
#define CLK_MCO2_AXI CLK_SRC(CK_MCO2, 1)
|
||||
#define CLK_MCO2_MLAHB CLK_SRC(CK_MCO2, 2)
|
||||
#define CLK_MCO2_PLL4 CLK_SRC(CK_MCO2, 3)
|
||||
#define CLK_MCO2_HSE CLK_SRC(CK_MCO2, 4)
|
||||
#define CLK_MCO2_HSI CLK_SRC(CK_MCO2, 5)
|
||||
#define CLK_MCO2_DISABLED CLK_DISABLED(CK_MCO2)
|
||||
|
||||
#define CLK_CKPER_HSI CLKSRC(MUX_CKPER, 0)
|
||||
#define CLK_CKPER_CSI CLKSRC(MUX_CKPER, 1)
|
||||
#define CLK_CKPER_HSE CLKSRC(MUX_CKPER, 2)
|
||||
#define CLK_CKPER_DISABLED CLKSRC(MUX_CKPER, 3)
|
||||
|
||||
#define CLK_I2C12_PCLK1 CLKSRC(MUX_I2C12, 0)
|
||||
#define CLK_I2C12_PLL4R CLKSRC(MUX_I2C12, 1)
|
||||
#define CLK_I2C12_HSI CLKSRC(MUX_I2C12, 2)
|
||||
#define CLK_I2C12_CSI CLKSRC(MUX_I2C12, 3)
|
||||
|
||||
#define CLK_I2C3_PCLK6 CLKSRC(MUX_I2C3, 0)
|
||||
#define CLK_I2C3_PLL4R CLKSRC(MUX_I2C3, 1)
|
||||
#define CLK_I2C3_HSI CLKSRC(MUX_I2C3, 2)
|
||||
#define CLK_I2C3_CSI CLKSRC(MUX_I2C3, 3)
|
||||
|
||||
#define CLK_I2C4_PCLK6 CLKSRC(MUX_I2C4, 0)
|
||||
#define CLK_I2C4_PLL4R CLKSRC(MUX_I2C4, 1)
|
||||
#define CLK_I2C4_HSI CLKSRC(MUX_I2C4, 2)
|
||||
#define CLK_I2C4_CSI CLKSRC(MUX_I2C4, 3)
|
||||
|
||||
#define CLK_I2C5_PCLK6 CLKSRC(MUX_I2C5, 0)
|
||||
#define CLK_I2C5_PLL4R CLKSRC(MUX_I2C5, 1)
|
||||
#define CLK_I2C5_HSI CLKSRC(MUX_I2C5, 2)
|
||||
#define CLK_I2C5_CSI CLKSRC(MUX_I2C5, 3)
|
||||
|
||||
#define CLK_SPI1_PLL4P CLKSRC(MUX_SPI1, 0)
|
||||
#define CLK_SPI1_PLL3Q CLKSRC(MUX_SPI1, 1)
|
||||
#define CLK_SPI1_I2SCKIN CLKSRC(MUX_SPI1, 2)
|
||||
#define CLK_SPI1_CKPER CLKSRC(MUX_SPI1, 3)
|
||||
#define CLK_SPI1_PLL3R CLKSRC(MUX_SPI1, 4)
|
||||
|
||||
#define CLK_SPI23_PLL4P CLKSRC(MUX_SPI23, 0)
|
||||
#define CLK_SPI23_PLL3Q CLKSRC(MUX_SPI23, 1)
|
||||
#define CLK_SPI23_I2SCKIN CLKSRC(MUX_SPI23, 2)
|
||||
#define CLK_SPI23_CKPER CLKSRC(MUX_SPI23, 3)
|
||||
#define CLK_SPI23_PLL3R CLKSRC(MUX_SPI23, 4)
|
||||
|
||||
#define CLK_SPI4_PCLK6 CLKSRC(MUX_SPI4, 0)
|
||||
#define CLK_SPI4_PLL4Q CLKSRC(MUX_SPI4, 1)
|
||||
#define CLK_SPI4_HSI CLKSRC(MUX_SPI4, 2)
|
||||
#define CLK_SPI4_CSI CLKSRC(MUX_SPI4, 3)
|
||||
#define CLK_SPI4_HSE CLKSRC(MUX_SPI4, 4)
|
||||
#define CLK_SPI4_I2SCKIN CLKSRC(MUX_SPI4, 5)
|
||||
|
||||
#define CLK_SPI5_PCLK6 CLKSRC(MUX_SPI5, 0)
|
||||
#define CLK_SPI5_PLL4Q CLKSRC(MUX_SPI5, 1)
|
||||
#define CLK_SPI5_HSI CLKSRC(MUX_SPI5, 2)
|
||||
#define CLK_SPI5_CSI CLKSRC(MUX_SPI5, 3)
|
||||
#define CLK_SPI5_HSE CLKSRC(MUX_SPI5, 4)
|
||||
|
||||
#define CLK_UART1_PCLK6 CLKSRC(MUX_UART1, 0)
|
||||
#define CLK_UART1_PLL3Q CLKSRC(MUX_UART1, 1)
|
||||
#define CLK_UART1_HSI CLKSRC(MUX_UART1, 2)
|
||||
#define CLK_UART1_CSI CLKSRC(MUX_UART1, 3)
|
||||
#define CLK_UART1_PLL4Q CLKSRC(MUX_UART1, 4)
|
||||
#define CLK_UART1_HSE CLKSRC(MUX_UART1, 5)
|
||||
|
||||
#define CLK_UART2_PCLK6 CLKSRC(MUX_UART2, 0)
|
||||
#define CLK_UART2_PLL3Q CLKSRC(MUX_UART2, 1)
|
||||
#define CLK_UART2_HSI CLKSRC(MUX_UART2, 2)
|
||||
#define CLK_UART2_CSI CLKSRC(MUX_UART2, 3)
|
||||
#define CLK_UART2_PLL4Q CLKSRC(MUX_UART2, 4)
|
||||
#define CLK_UART2_HSE CLKSRC(MUX_UART2, 5)
|
||||
|
||||
#define CLK_UART35_PCLK1 CLKSRC(MUX_UART35, 0)
|
||||
#define CLK_UART35_PLL4Q CLKSRC(MUX_UART35, 1)
|
||||
#define CLK_UART35_HSI CLKSRC(MUX_UART35, 2)
|
||||
#define CLK_UART35_CSI CLKSRC(MUX_UART35, 3)
|
||||
#define CLK_UART35_HSE CLKSRC(MUX_UART35, 4)
|
||||
|
||||
#define CLK_UART4_PCLK1 CLKSRC(MUX_UART4, 0)
|
||||
#define CLK_UART4_PLL4Q CLKSRC(MUX_UART4, 1)
|
||||
#define CLK_UART4_HSI CLKSRC(MUX_UART4, 2)
|
||||
#define CLK_UART4_CSI CLKSRC(MUX_UART4, 3)
|
||||
#define CLK_UART4_HSE CLKSRC(MUX_UART4, 4)
|
||||
|
||||
#define CLK_UART6_PCLK2 CLKSRC(MUX_UART6, 0)
|
||||
#define CLK_UART6_PLL4Q CLKSRC(MUX_UART6, 1)
|
||||
#define CLK_UART6_HSI CLKSRC(MUX_UART6, 2)
|
||||
#define CLK_UART6_CSI CLKSRC(MUX_UART6, 3)
|
||||
#define CLK_UART6_HSE CLKSRC(MUX_UART6, 4)
|
||||
|
||||
#define CLK_UART78_PCLK1 CLKSRC(MUX_UART78, 0)
|
||||
#define CLK_UART78_PLL4Q CLKSRC(MUX_UART78, 1)
|
||||
#define CLK_UART78_HSI CLKSRC(MUX_UART78, 2)
|
||||
#define CLK_UART78_CSI CLKSRC(MUX_UART78, 3)
|
||||
#define CLK_UART78_HSE CLKSRC(MUX_UART78, 4)
|
||||
|
||||
#define CLK_LPTIM1_PCLK1 CLKSRC(MUX_LPTIM1, 0)
|
||||
#define CLK_LPTIM1_PLL4P CLKSRC(MUX_LPTIM1, 1)
|
||||
#define CLK_LPTIM1_PLL3Q CLKSRC(MUX_LPTIM1, 2)
|
||||
#define CLK_LPTIM1_LSE CLKSRC(MUX_LPTIM1, 3)
|
||||
#define CLK_LPTIM1_LSI CLKSRC(MUX_LPTIM1, 4)
|
||||
#define CLK_LPTIM1_CKPER CLKSRC(MUX_LPTIM1, 5)
|
||||
|
||||
#define CLK_LPTIM2_PCLK3 CLKSRC(MUX_LPTIM2, 0)
|
||||
#define CLK_LPTIM2_PLL4Q CLKSRC(MUX_LPTIM2, 1)
|
||||
#define CLK_LPTIM2_CKPER CLKSRC(MUX_LPTIM2, 2)
|
||||
#define CLK_LPTIM2_LSE CLKSRC(MUX_LPTIM2, 3)
|
||||
#define CLK_LPTIM2_LSI CLKSRC(MUX_LPTIM2, 4)
|
||||
|
||||
#define CLK_LPTIM3_PCLK3 CLKSRC(MUX_LPTIM3, 0)
|
||||
#define CLK_LPTIM3_PLL4Q CLKSRC(MUX_LPTIM3, 1)
|
||||
#define CLK_LPTIM3_CKPER CLKSRC(MUX_LPTIM3, 2)
|
||||
#define CLK_LPTIM3_LSE CLKSRC(MUX_LPTIM3, 3)
|
||||
#define CLK_LPTIM3_LSI CLKSRC(MUX_LPTIM3, 4)
|
||||
|
||||
#define CLK_LPTIM45_PCLK3 CLKSRC(MUX_LPTIM45, 0)
|
||||
#define CLK_LPTIM45_PLL4P CLKSRC(MUX_LPTIM45, 1)
|
||||
#define CLK_LPTIM45_PLL3Q CLKSRC(MUX_LPTIM45, 2)
|
||||
#define CLK_LPTIM45_LSE CLKSRC(MUX_LPTIM45, 3)
|
||||
#define CLK_LPTIM45_LSI CLKSRC(MUX_LPTIM45, 4)
|
||||
#define CLK_LPTIM45_CKPER CLKSRC(MUX_LPTIM45, 5)
|
||||
|
||||
#define CLK_SAI1_PLL4Q CLKSRC(MUX_SAI1, 0)
|
||||
#define CLK_SAI1_PLL3Q CLKSRC(MUX_SAI1, 1)
|
||||
#define CLK_SAI1_I2SCKIN CLKSRC(MUX_SAI1, 2)
|
||||
#define CLK_SAI1_CKPER CLKSRC(MUX_SAI1, 3)
|
||||
#define CLK_SAI1_PLL3R CLKSRC(MUX_SAI1, 4)
|
||||
|
||||
#define CLK_SAI2_PLL4Q CLKSRC(MUX_SAI2, 0)
|
||||
#define CLK_SAI2_PLL3Q CLKSRC(MUX_SAI2, 1)
|
||||
#define CLK_SAI2_I2SCKIN CLKSRC(MUX_SAI2, 2)
|
||||
#define CLK_SAI2_CKPER CLKSRC(MUX_SAI2, 3)
|
||||
#define CLK_SAI2_SPDIF CLKSRC(MUX_SAI2, 4)
|
||||
#define CLK_SAI2_PLL3R CLKSRC(MUX_SAI2, 5)
|
||||
|
||||
#define CLK_FDCAN_HSE CLKSRC(MUX_FDCAN, 0)
|
||||
#define CLK_FDCAN_PLL3Q CLKSRC(MUX_FDCAN, 1)
|
||||
#define CLK_FDCAN_PLL4Q CLKSRC(MUX_FDCAN, 2)
|
||||
#define CLK_FDCAN_PLL4R CLKSRC(MUX_FDCAN, 3)
|
||||
|
||||
#define CLK_SPDIF_PLL4P CLKSRC(MUX_SPDIF, 0)
|
||||
#define CLK_SPDIF_PLL3Q CLKSRC(MUX_SPDIF, 1)
|
||||
#define CLK_SPDIF_HSI CLKSRC(MUX_SPDIF, 2)
|
||||
|
||||
#define CLK_ADC1_PLL4R CLKSRC(MUX_ADC1, 0)
|
||||
#define CLK_ADC1_CKPER CLKSRC(MUX_ADC1, 1)
|
||||
#define CLK_ADC1_PLL3Q CLKSRC(MUX_ADC1, 2)
|
||||
|
||||
#define CLK_ADC2_PLL4R CLKSRC(MUX_ADC2, 0)
|
||||
#define CLK_ADC2_CKPER CLKSRC(MUX_ADC2, 1)
|
||||
#define CLK_ADC2_PLL3Q CLKSRC(MUX_ADC2, 2)
|
||||
|
||||
#define CLK_SDMMC1_HCLK6 CLKSRC(MUX_SDMMC1, 0)
|
||||
#define CLK_SDMMC1_PLL3R CLKSRC(MUX_SDMMC1, 1)
|
||||
#define CLK_SDMMC1_PLL4P CLKSRC(MUX_SDMMC1, 2)
|
||||
#define CLK_SDMMC1_HSI CLKSRC(MUX_SDMMC1, 3)
|
||||
|
||||
#define CLK_SDMMC2_HCLK6 CLKSRC(MUX_SDMMC2, 0)
|
||||
#define CLK_SDMMC2_PLL3R CLKSRC(MUX_SDMMC2, 1)
|
||||
#define CLK_SDMMC2_PLL4P CLKSRC(MUX_SDMMC2, 2)
|
||||
#define CLK_SDMMC2_HSI CLKSRC(MUX_SDMMC2, 3)
|
||||
|
||||
#define CLK_ETH1_PLL4P CLKSRC(MUX_ETH1, 0)
|
||||
#define CLK_ETH1_PLL3Q CLKSRC(MUX_ETH1, 1)
|
||||
|
||||
#define CLK_ETH2_PLL4P CLKSRC(MUX_ETH2, 0)
|
||||
#define CLK_ETH2_PLL3Q CLKSRC(MUX_ETH2, 1)
|
||||
|
||||
#define CLK_USBPHY_HSE CLKSRC(MUX_USBPHY, 0)
|
||||
#define CLK_USBPHY_PLL4R CLKSRC(MUX_USBPHY, 1)
|
||||
#define CLK_USBPHY_HSE_DIV2 CLKSRC(MUX_USBPHY, 2)
|
||||
|
||||
#define CLK_USBO_PLL4R CLKSRC(MUX_USBO, 0)
|
||||
#define CLK_USBO_USBPHY CLKSRC(MUX_USBO, 1)
|
||||
|
||||
#define CLK_QSPI_ACLK CLKSRC(MUX_QSPI, 0)
|
||||
#define CLK_QSPI_PLL3R CLKSRC(MUX_QSPI, 1)
|
||||
#define CLK_QSPI_PLL4P CLKSRC(MUX_QSPI, 2)
|
||||
#define CLK_QSPI_CKPER CLKSRC(MUX_QSPI, 3)
|
||||
|
||||
#define CLK_FMC_ACLK CLKSRC(MUX_FMC, 0)
|
||||
#define CLK_FMC_PLL3R CLKSRC(MUX_FMC, 1)
|
||||
#define CLK_FMC_PLL4P CLKSRC(MUX_FMC, 2)
|
||||
#define CLK_FMC_CKPER CLKSRC(MUX_FMC, 3)
|
||||
|
||||
#define CLK_RNG1_CSI CLKSRC(MUX_RNG1, 0)
|
||||
#define CLK_RNG1_PLL4R CLKSRC(MUX_RNG1, 1)
|
||||
/* WARNING: POSITION 2 OF RNG1 MUX IS RESERVED */
|
||||
#define CLK_RNG1_LSI CLKSRC(MUX_RNG1, 3)
|
||||
|
||||
#define CLK_STGEN_HSI CLKSRC(MUX_STGEN, 0)
|
||||
#define CLK_STGEN_HSE CLKSRC(MUX_STGEN, 1)
|
||||
|
||||
#define CLK_DCMIPP_ACLK CLKSRC(MUX_DCMIPP, 0)
|
||||
#define CLK_DCMIPP_PLL2Q CLKSRC(MUX_DCMIPP, 1)
|
||||
#define CLK_DCMIPP_PLL4P CLKSRC(MUX_DCMIPP, 2)
|
||||
#define CLK_DCMIPP_CKPER CLKSRC(MUX_DCMIPP, 3)
|
||||
|
||||
#define CLK_SAES_AXI CLKSRC(MUX_SAES, 0)
|
||||
#define CLK_SAES_CKPER CLKSRC(MUX_SAES, 1)
|
||||
#define CLK_SAES_PLL4R CLKSRC(MUX_SAES, 2)
|
||||
#define CLK_SAES_LSI CLKSRC(MUX_SAES, 3)
|
||||
|
||||
/* PLL output is enable when x=1, with x=p,q or r */
|
||||
#define PQR(p, q, r) (((p) & 1) | (((q) & 1) << 1) | (((r) & 1) << 2))
|
||||
|
||||
/* define for st,pll /csg */
|
||||
#define SSCG_MODE_CENTER_SPREAD 0
|
||||
#define SSCG_MODE_DOWN_SPREAD 1
|
||||
|
||||
/* define for st,drive */
|
||||
#define LSEDRV_LOWEST 0
|
||||
#define LSEDRV_MEDIUM_LOW 1
|
||||
#define LSEDRV_MEDIUM_HIGH 2
|
||||
#define LSEDRV_HIGHEST 3
|
||||
|
||||
#endif
|
||||
@@ -233,6 +233,7 @@ enum image_type_t {
|
||||
IH_TYPE_RENESAS_SPKG, /* Renesas SPKG image */
|
||||
IH_TYPE_STARFIVE_SPL, /* StarFive SPL image */
|
||||
IH_TYPE_TFA_BL31, /* TFA BL31 image */
|
||||
IH_TYPE_STM32IMAGE_V2, /* STMicroelectronics STM32 Image V2.0 */
|
||||
|
||||
IH_TYPE_COUNT, /* Number of image types */
|
||||
};
|
||||
|
||||
@@ -15,10 +15,17 @@
|
||||
|
||||
struct udevice;
|
||||
|
||||
/* update clock ID for the dev = clock provider, compatible with CLK_AUTO_ID */
|
||||
static inline void dev_clk_dm(const struct udevice *dev, ulong id, struct clk *clk)
|
||||
{
|
||||
if (!IS_ERR(clk))
|
||||
clk->id = CLK_ID(dev, id);
|
||||
}
|
||||
|
||||
static inline void clk_dm(ulong id, struct clk *clk)
|
||||
{
|
||||
if (!IS_ERR(clk))
|
||||
clk->id = id;
|
||||
clk->id = CLK_ID(clk->dev, id);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -782,6 +782,21 @@ struct scmi_clk_attribute_out {
|
||||
char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct scmi_clk_get_nb_out_v2 - Response payload for SCMI_CLOCK_ATTRIBUTES command
|
||||
* Clock management Protocol 2.0
|
||||
* @status: SCMI command status
|
||||
* @attributes: clock attributes
|
||||
* @clock_name: name of the clock
|
||||
* @clock_enable_delay: delay incurred by the platform to enable the clock
|
||||
*/
|
||||
struct scmi_clk_attribute_out_v2 {
|
||||
s32 status;
|
||||
u32 attributes;
|
||||
char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
|
||||
u32 clock_enable_delay;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
|
||||
* @clock_id: SCMI clock ID
|
||||
|
||||
@@ -39,11 +39,11 @@ struct stm32_clk_info {
|
||||
bool v2;
|
||||
};
|
||||
|
||||
/* platdata used for clk-stm32f.c driver */
|
||||
enum soc_family {
|
||||
STM32F42X,
|
||||
STM32F469,
|
||||
STM32F7,
|
||||
STM32MP1,
|
||||
};
|
||||
|
||||
enum apb {
|
||||
@@ -51,8 +51,9 @@ enum apb {
|
||||
APB2,
|
||||
};
|
||||
|
||||
struct stm32_rcc_clk {
|
||||
char *drv_name;
|
||||
struct stm32_rcc {
|
||||
char *drv_name_clk;
|
||||
char *drv_name_rst;
|
||||
enum soc_family soc;
|
||||
};
|
||||
|
||||
|
||||
712
include/stm32mp25_rcc.h
Normal file
712
include/stm32mp25_rcc.h
Normal file
@@ -0,0 +1,712 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C STMicroelectronics 2019 - All Rights Reserved
|
||||
* Author: Gabriel Fernandez <gabriel.fernandez@st.com> for STMicroelectronics.
|
||||
*/
|
||||
|
||||
#ifndef STM32MP25_RCC_H
|
||||
#define STM32MP25_RCC_H
|
||||
|
||||
#define RCC_SECCFGR0 0x0
|
||||
#define RCC_SECCFGR1 0x4
|
||||
#define RCC_SECCFGR2 0x8
|
||||
#define RCC_SECCFGR3 0xC
|
||||
#define RCC_PRIVCFGR0 0x10
|
||||
#define RCC_PRIVCFGR1 0x14
|
||||
#define RCC_PRIVCFGR2 0x18
|
||||
#define RCC_PRIVCFGR3 0x1C
|
||||
#define RCC_RCFGLOCKR0 0x20
|
||||
#define RCC_RCFGLOCKR1 0x24
|
||||
#define RCC_RCFGLOCKR2 0x28
|
||||
#define RCC_RCFGLOCKR3 0x2C
|
||||
#define RCC_R0CIDCFGR 0x30
|
||||
#define RCC_R0SEMCR 0x34
|
||||
#define RCC_R1CIDCFGR 0x38
|
||||
#define RCC_R1SEMCR 0x3C
|
||||
#define RCC_R2CIDCFGR 0x40
|
||||
#define RCC_R2SEMCR 0x44
|
||||
#define RCC_R3CIDCFGR 0x48
|
||||
#define RCC_R3SEMCR 0x4C
|
||||
#define RCC_R4CIDCFGR 0x50
|
||||
#define RCC_R4SEMCR 0x54
|
||||
#define RCC_R5CIDCFGR 0x58
|
||||
#define RCC_R5SEMCR 0x5C
|
||||
#define RCC_R6CIDCFGR 0x60
|
||||
#define RCC_R6SEMCR 0x64
|
||||
#define RCC_R7CIDCFGR 0x68
|
||||
#define RCC_R7SEMCR 0x6C
|
||||
#define RCC_R8CIDCFGR 0x70
|
||||
#define RCC_R8SEMCR 0x74
|
||||
#define RCC_R9CIDCFGR 0x78
|
||||
#define RCC_R9SEMCR 0x7C
|
||||
#define RCC_R10CIDCFGR 0x80
|
||||
#define RCC_R10SEMCR 0x84
|
||||
#define RCC_R11CIDCFGR 0x88
|
||||
#define RCC_R11SEMCR 0x8C
|
||||
#define RCC_R12CIDCFGR 0x90
|
||||
#define RCC_R12SEMCR 0x94
|
||||
#define RCC_R13CIDCFGR 0x98
|
||||
#define RCC_R13SEMCR 0x9C
|
||||
#define RCC_R14CIDCFGR 0xA0
|
||||
#define RCC_R14SEMCR 0xA4
|
||||
#define RCC_R15CIDCFGR 0xA8
|
||||
#define RCC_R15SEMCR 0xAC
|
||||
#define RCC_R16CIDCFGR 0xB0
|
||||
#define RCC_R16SEMCR 0xB4
|
||||
#define RCC_R17CIDCFGR 0xB8
|
||||
#define RCC_R17SEMCR 0xBC
|
||||
#define RCC_R18CIDCFGR 0xC0
|
||||
#define RCC_R18SEMCR 0xC4
|
||||
#define RCC_R19CIDCFGR 0xC8
|
||||
#define RCC_R19SEMCR 0xCC
|
||||
#define RCC_R20CIDCFGR 0xD0
|
||||
#define RCC_R20SEMCR 0xD4
|
||||
#define RCC_R21CIDCFGR 0xD8
|
||||
#define RCC_R21SEMCR 0xDC
|
||||
#define RCC_R22CIDCFGR 0xE0
|
||||
#define RCC_R22SEMCR 0xE4
|
||||
#define RCC_R23CIDCFGR 0xE8
|
||||
#define RCC_R23SEMCR 0xEC
|
||||
#define RCC_R24CIDCFGR 0xF0
|
||||
#define RCC_R24SEMCR 0xF4
|
||||
#define RCC_R25CIDCFGR 0xF8
|
||||
#define RCC_R25SEMCR 0xFC
|
||||
#define RCC_R26CIDCFGR 0x100
|
||||
#define RCC_R26SEMCR 0x104
|
||||
#define RCC_R27CIDCFGR 0x108
|
||||
#define RCC_R27SEMCR 0x10C
|
||||
#define RCC_R28CIDCFGR 0x110
|
||||
#define RCC_R28SEMCR 0x114
|
||||
#define RCC_R29CIDCFGR 0x118
|
||||
#define RCC_R29SEMCR 0x11C
|
||||
#define RCC_R30CIDCFGR 0x120
|
||||
#define RCC_R30SEMCR 0x124
|
||||
#define RCC_R31CIDCFGR 0x128
|
||||
#define RCC_R31SEMCR 0x12C
|
||||
#define RCC_R32CIDCFGR 0x130
|
||||
#define RCC_R32SEMCR 0x134
|
||||
#define RCC_R33CIDCFGR 0x138
|
||||
#define RCC_R33SEMCR 0x13C
|
||||
#define RCC_R34CIDCFGR 0x140
|
||||
#define RCC_R34SEMCR 0x144
|
||||
#define RCC_R35CIDCFGR 0x148
|
||||
#define RCC_R35SEMCR 0x14C
|
||||
#define RCC_R36CIDCFGR 0x150
|
||||
#define RCC_R36SEMCR 0x154
|
||||
#define RCC_R37CIDCFGR 0x158
|
||||
#define RCC_R37SEMCR 0x15C
|
||||
#define RCC_R38CIDCFGR 0x160
|
||||
#define RCC_R38SEMCR 0x164
|
||||
#define RCC_R39CIDCFGR 0x168
|
||||
#define RCC_R39SEMCR 0x16C
|
||||
#define RCC_R40CIDCFGR 0x170
|
||||
#define RCC_R40SEMCR 0x174
|
||||
#define RCC_R41CIDCFGR 0x178
|
||||
#define RCC_R41SEMCR 0x17C
|
||||
#define RCC_R42CIDCFGR 0x180
|
||||
#define RCC_R42SEMCR 0x184
|
||||
#define RCC_R43CIDCFGR 0x188
|
||||
#define RCC_R43SEMCR 0x18C
|
||||
#define RCC_R44CIDCFGR 0x190
|
||||
#define RCC_R44SEMCR 0x194
|
||||
#define RCC_R45CIDCFGR 0x198
|
||||
#define RCC_R45SEMCR 0x19C
|
||||
#define RCC_R46CIDCFGR 0x1A0
|
||||
#define RCC_R46SEMCR 0x1A4
|
||||
#define RCC_R47CIDCFGR 0x1A8
|
||||
#define RCC_R47SEMCR 0x1AC
|
||||
#define RCC_R48CIDCFGR 0x1B0
|
||||
#define RCC_R48SEMCR 0x1B4
|
||||
#define RCC_R49CIDCFGR 0x1B8
|
||||
#define RCC_R49SEMCR 0x1BC
|
||||
#define RCC_R50CIDCFGR 0x1C0
|
||||
#define RCC_R50SEMCR 0x1C4
|
||||
#define RCC_R51CIDCFGR 0x1C8
|
||||
#define RCC_R51SEMCR 0x1CC
|
||||
#define RCC_R52CIDCFGR 0x1D0
|
||||
#define RCC_R52SEMCR 0x1D4
|
||||
#define RCC_R53CIDCFGR 0x1D8
|
||||
#define RCC_R53SEMCR 0x1DC
|
||||
#define RCC_R54CIDCFGR 0x1E0
|
||||
#define RCC_R54SEMCR 0x1E4
|
||||
#define RCC_R55CIDCFGR 0x1E8
|
||||
#define RCC_R55SEMCR 0x1EC
|
||||
#define RCC_R56CIDCFGR 0x1F0
|
||||
#define RCC_R56SEMCR 0x1F4
|
||||
#define RCC_R57CIDCFGR 0x1F8
|
||||
#define RCC_R57SEMCR 0x1FC
|
||||
#define RCC_R58CIDCFGR 0x200
|
||||
#define RCC_R58SEMCR 0x204
|
||||
#define RCC_R59CIDCFGR 0x208
|
||||
#define RCC_R59SEMCR 0x20C
|
||||
#define RCC_R60CIDCFGR 0x210
|
||||
#define RCC_R60SEMCR 0x214
|
||||
#define RCC_R61CIDCFGR 0x218
|
||||
#define RCC_R61SEMCR 0x21C
|
||||
#define RCC_R62CIDCFGR 0x220
|
||||
#define RCC_R62SEMCR 0x224
|
||||
#define RCC_R63CIDCFGR 0x228
|
||||
#define RCC_R63SEMCR 0x22C
|
||||
#define RCC_R64CIDCFGR 0x230
|
||||
#define RCC_R64SEMCR 0x234
|
||||
#define RCC_R65CIDCFGR 0x238
|
||||
#define RCC_R65SEMCR 0x23C
|
||||
#define RCC_R66CIDCFGR 0x240
|
||||
#define RCC_R66SEMCR 0x244
|
||||
#define RCC_R67CIDCFGR 0x248
|
||||
#define RCC_R67SEMCR 0x24C
|
||||
#define RCC_R68CIDCFGR 0x250
|
||||
#define RCC_R68SEMCR 0x254
|
||||
#define RCC_R69CIDCFGR 0x258
|
||||
#define RCC_R69SEMCR 0x25C
|
||||
#define RCC_R70CIDCFGR 0x260
|
||||
#define RCC_R70SEMCR 0x264
|
||||
#define RCC_R71CIDCFGR 0x268
|
||||
#define RCC_R71SEMCR 0x26C
|
||||
#define RCC_R72CIDCFGR 0x270
|
||||
#define RCC_R72SEMCR 0x274
|
||||
#define RCC_R73CIDCFGR 0x278
|
||||
#define RCC_R73SEMCR 0x27C
|
||||
#define RCC_R74CIDCFGR 0x280
|
||||
#define RCC_R74SEMCR 0x284
|
||||
#define RCC_R75CIDCFGR 0x288
|
||||
#define RCC_R75SEMCR 0x28C
|
||||
#define RCC_R76CIDCFGR 0x290
|
||||
#define RCC_R76SEMCR 0x294
|
||||
#define RCC_R77CIDCFGR 0x298
|
||||
#define RCC_R77SEMCR 0x29C
|
||||
#define RCC_R78CIDCFGR 0x2A0
|
||||
#define RCC_R78SEMCR 0x2A4
|
||||
#define RCC_R79CIDCFGR 0x2A8
|
||||
#define RCC_R79SEMCR 0x2AC
|
||||
#define RCC_R80CIDCFGR 0x2B0
|
||||
#define RCC_R80SEMCR 0x2B4
|
||||
#define RCC_R81CIDCFGR 0x2B8
|
||||
#define RCC_R81SEMCR 0x2BC
|
||||
#define RCC_R82CIDCFGR 0x2C0
|
||||
#define RCC_R82SEMCR 0x2C4
|
||||
#define RCC_R83CIDCFGR 0x2C8
|
||||
#define RCC_R83SEMCR 0x2CC
|
||||
#define RCC_R84CIDCFGR 0x2D0
|
||||
#define RCC_R84SEMCR 0x2D4
|
||||
#define RCC_R85CIDCFGR 0x2D8
|
||||
#define RCC_R85SEMCR 0x2DC
|
||||
#define RCC_R86CIDCFGR 0x2E0
|
||||
#define RCC_R86SEMCR 0x2E4
|
||||
#define RCC_R87CIDCFGR 0x2E8
|
||||
#define RCC_R87SEMCR 0x2EC
|
||||
#define RCC_R88CIDCFGR 0x2F0
|
||||
#define RCC_R88SEMCR 0x2F4
|
||||
#define RCC_R89CIDCFGR 0x2F8
|
||||
#define RCC_R89SEMCR 0x2FC
|
||||
#define RCC_R90CIDCFGR 0x300
|
||||
#define RCC_R90SEMCR 0x304
|
||||
#define RCC_R91CIDCFGR 0x308
|
||||
#define RCC_R91SEMCR 0x30C
|
||||
#define RCC_R92CIDCFGR 0x310
|
||||
#define RCC_R92SEMCR 0x314
|
||||
#define RCC_R93CIDCFGR 0x318
|
||||
#define RCC_R93SEMCR 0x31C
|
||||
#define RCC_R94CIDCFGR 0x320
|
||||
#define RCC_R94SEMCR 0x324
|
||||
#define RCC_R95CIDCFGR 0x328
|
||||
#define RCC_R95SEMCR 0x32C
|
||||
#define RCC_R96CIDCFGR 0x330
|
||||
#define RCC_R96SEMCR 0x334
|
||||
#define RCC_R97CIDCFGR 0x338
|
||||
#define RCC_R97SEMCR 0x33C
|
||||
#define RCC_R98CIDCFGR 0x340
|
||||
#define RCC_R98SEMCR 0x344
|
||||
#define RCC_R99CIDCFGR 0x348
|
||||
#define RCC_R99SEMCR 0x34C
|
||||
#define RCC_R100CIDCFGR 0x350
|
||||
#define RCC_R100SEMCR 0x354
|
||||
#define RCC_R101CIDCFGR 0x358
|
||||
#define RCC_R101SEMCR 0x35C
|
||||
#define RCC_R102CIDCFGR 0x360
|
||||
#define RCC_R102SEMCR 0x364
|
||||
#define RCC_R103CIDCFGR 0x368
|
||||
#define RCC_R103SEMCR 0x36C
|
||||
#define RCC_R104CIDCFGR 0x370
|
||||
#define RCC_R104SEMCR 0x374
|
||||
#define RCC_R105CIDCFGR 0x378
|
||||
#define RCC_R105SEMCR 0x37C
|
||||
#define RCC_R106CIDCFGR 0x380
|
||||
#define RCC_R106SEMCR 0x384
|
||||
#define RCC_R107CIDCFGR 0x388
|
||||
#define RCC_R107SEMCR 0x38C
|
||||
#define RCC_R108CIDCFGR 0x390
|
||||
#define RCC_R108SEMCR 0x394
|
||||
#define RCC_R109CIDCFGR 0x398
|
||||
#define RCC_R109SEMCR 0x39C
|
||||
#define RCC_R110CIDCFGR 0x3A0
|
||||
#define RCC_R110SEMCR 0x3A4
|
||||
#define RCC_R111CIDCFGR 0x3A8
|
||||
#define RCC_R111SEMCR 0x3AC
|
||||
#define RCC_R112CIDCFGR 0x3B0
|
||||
#define RCC_R112SEMCR 0x3B4
|
||||
#define RCC_R113CIDCFGR 0x3B8
|
||||
#define RCC_R113SEMCR 0x3BC
|
||||
#define RCC_GRSTCSETR 0x400
|
||||
#define RCC_C1RSTCSETR 0x404
|
||||
#define RCC_C1P1RSTCSETR 0x408
|
||||
#define RCC_C2RSTCSETR 0x40C
|
||||
#define RCC_HWRSTSCLRR 0x410
|
||||
#define RCC_C1HWRSTSCLRR 0x414
|
||||
#define RCC_C2HWRSTSCLRR 0x418
|
||||
#define RCC_C1BOOTRSTSSETR 0x41C
|
||||
#define RCC_C1BOOTRSTSCLRR 0x420
|
||||
#define RCC_C2BOOTRSTSSETR 0x424
|
||||
#define RCC_C2BOOTRSTSCLRR 0x428
|
||||
#define RCC_C1SREQSETR 0x42C
|
||||
#define RCC_C1SREQCLRR 0x430
|
||||
#define RCC_CPUBOOTCR 0x434
|
||||
#define RCC_STBYBOOTCR 0x438
|
||||
#define RCC_LEGBOOTCR 0x43C
|
||||
#define RCC_BDCR 0x440
|
||||
#define RCC_D3DCR 0x444
|
||||
#define RCC_D3DSR 0x448
|
||||
#define RCC_RDCR 0x44C
|
||||
#define RCC_C1MSRDCR 0x450
|
||||
#define RCC_PWRLPDLYCR 0x454
|
||||
#define RCC_C1CIESETR 0x458
|
||||
#define RCC_C1CIFCLRR 0x45C
|
||||
#define RCC_C2CIESETR 0x460
|
||||
#define RCC_C2CIFCLRR 0x464
|
||||
#define RCC_IWDGC1FZSETR 0x468
|
||||
#define RCC_IWDGC1FZCLRR 0x46C
|
||||
#define RCC_IWDGC1CFGSETR 0x470
|
||||
#define RCC_IWDGC1CFGCLRR 0x474
|
||||
#define RCC_IWDGC2FZSETR 0x478
|
||||
#define RCC_IWDGC2FZCLRR 0x47C
|
||||
#define RCC_IWDGC2CFGSETR 0x480
|
||||
#define RCC_IWDGC2CFGCLRR 0x484
|
||||
#define RCC_IWDGC3CFGSETR 0x488
|
||||
#define RCC_IWDGC3CFGCLRR 0x48C
|
||||
#define RCC_C3CFGR 0x490
|
||||
#define RCC_MCO1CFGR 0x494
|
||||
#define RCC_MCO2CFGR 0x498
|
||||
#define RCC_OCENSETR 0x49C
|
||||
#define RCC_OCENCLRR 0x4A0
|
||||
#define RCC_OCRDYR 0x4A4
|
||||
#define RCC_HSICFGR 0x4A8
|
||||
#define RCC_MSICFGR 0x4AC
|
||||
#define RCC_RTCDIVR 0x4B0
|
||||
#define RCC_APB1DIVR 0x4B4
|
||||
#define RCC_APB2DIVR 0x4B8
|
||||
#define RCC_APB3DIVR 0x4BC
|
||||
#define RCC_APB4DIVR 0x4C0
|
||||
#define RCC_APBDBGDIVR 0x4C4
|
||||
#define RCC_TIMG1PRER 0x4C8
|
||||
#define RCC_TIMG2PRER 0x4CC
|
||||
#define RCC_LSMCUDIVR 0x4D0
|
||||
#define RCC_DDRCPCFGR 0x4D4
|
||||
#define RCC_DDRCAPBCFGR 0x4D8
|
||||
#define RCC_DDRPHYCAPBCFGR 0x4DC
|
||||
#define RCC_DDRPHYCCFGR 0x4E0
|
||||
#define RCC_DDRCFGR 0x4E4
|
||||
#define RCC_DDRITFCFGR 0x4E8
|
||||
#define RCC_SYSRAMCFGR 0x4F0
|
||||
#define RCC_VDERAMCFGR 0x4F4
|
||||
#define RCC_SRAM1CFGR 0x4F8
|
||||
#define RCC_SRAM2CFGR 0x4FC
|
||||
#define RCC_RETRAMCFGR 0x500
|
||||
#define RCC_BKPSRAMCFGR 0x504
|
||||
#define RCC_LPSRAM1CFGR 0x508
|
||||
#define RCC_LPSRAM2CFGR 0x50C
|
||||
#define RCC_LPSRAM3CFGR 0x510
|
||||
#define RCC_OSPI1CFGR 0x514
|
||||
#define RCC_OSPI2CFGR 0x518
|
||||
#define RCC_FMCCFGR 0x51C
|
||||
#define RCC_DBGCFGR 0x520
|
||||
#define RCC_STM500CFGR 0x524
|
||||
#define RCC_ETRCFGR 0x528
|
||||
#define RCC_GPIOACFGR 0x52C
|
||||
#define RCC_GPIOBCFGR 0x530
|
||||
#define RCC_GPIOCCFGR 0x534
|
||||
#define RCC_GPIODCFGR 0x538
|
||||
#define RCC_GPIOECFGR 0x53C
|
||||
#define RCC_GPIOFCFGR 0x540
|
||||
#define RCC_GPIOGCFGR 0x544
|
||||
#define RCC_GPIOHCFGR 0x548
|
||||
#define RCC_GPIOICFGR 0x54C
|
||||
#define RCC_GPIOJCFGR 0x550
|
||||
#define RCC_GPIOKCFGR 0x554
|
||||
#define RCC_GPIOZCFGR 0x558
|
||||
#define RCC_HPDMA1CFGR 0x55C
|
||||
#define RCC_HPDMA2CFGR 0x560
|
||||
#define RCC_HPDMA3CFGR 0x564
|
||||
#define RCC_LPDMACFGR 0x568
|
||||
#define RCC_HSEMCFGR 0x56C
|
||||
#define RCC_IPCC1CFGR 0x570
|
||||
#define RCC_IPCC2CFGR 0x574
|
||||
#define RCC_RTCCFGR 0x578
|
||||
#define RCC_SYSCPU1CFGR 0x580
|
||||
#define RCC_BSECCFGR 0x584
|
||||
#define RCC_IS2MCFGR 0x58C
|
||||
#define RCC_PLL2CFGR1 0x590
|
||||
#define RCC_PLL2CFGR2 0x594
|
||||
#define RCC_PLL2CFGR3 0x598
|
||||
#define RCC_PLL2CFGR4 0x59C
|
||||
#define RCC_PLL2CFGR5 0x5A0
|
||||
#define RCC_PLL2CFGR6 0x5A8
|
||||
#define RCC_PLL2CFGR7 0x5AC
|
||||
#define RCC_PLL3CFGR1 0x5B8
|
||||
#define RCC_PLL3CFGR2 0x5BC
|
||||
#define RCC_PLL3CFGR3 0x5C0
|
||||
#define RCC_PLL3CFGR4 0x5C4
|
||||
#define RCC_PLL3CFGR5 0x5C8
|
||||
#define RCC_PLL3CFGR6 0x5D0
|
||||
#define RCC_PLL3CFGR7 0x5D4
|
||||
#define RCC_HSIFMONCR 0x5E0
|
||||
#define RCC_HSIFVALR 0x5E4
|
||||
#define RCC_TIM1CFGR 0x700
|
||||
#define RCC_TIM2CFGR 0x704
|
||||
#define RCC_TIM3CFGR 0x708
|
||||
#define RCC_TIM4CFGR 0x70C
|
||||
#define RCC_TIM5CFGR 0x710
|
||||
#define RCC_TIM6CFGR 0x714
|
||||
#define RCC_TIM7CFGR 0x718
|
||||
#define RCC_TIM8CFGR 0x71C
|
||||
#define RCC_TIM10CFGR 0x720
|
||||
#define RCC_TIM11CFGR 0x724
|
||||
#define RCC_TIM12CFGR 0x728
|
||||
#define RCC_TIM13CFGR 0x72C
|
||||
#define RCC_TIM14CFGR 0x730
|
||||
#define RCC_TIM15CFGR 0x734
|
||||
#define RCC_TIM16CFGR 0x738
|
||||
#define RCC_TIM17CFGR 0x73C
|
||||
#define RCC_TIM20CFGR 0x740
|
||||
#define RCC_LPTIM1CFGR 0x744
|
||||
#define RCC_LPTIM2CFGR 0x748
|
||||
#define RCC_LPTIM3CFGR 0x74C
|
||||
#define RCC_LPTIM4CFGR 0x750
|
||||
#define RCC_LPTIM5CFGR 0x754
|
||||
#define RCC_SPI1CFGR 0x758
|
||||
#define RCC_SPI2CFGR 0x75C
|
||||
#define RCC_SPI3CFGR 0x760
|
||||
#define RCC_SPI4CFGR 0x764
|
||||
#define RCC_SPI5CFGR 0x768
|
||||
#define RCC_SPI6CFGR 0x76C
|
||||
#define RCC_SPI7CFGR 0x770
|
||||
#define RCC_SPI8CFGR 0x774
|
||||
#define RCC_SPDIFRXCFGR 0x778
|
||||
#define RCC_USART1CFGR 0x77C
|
||||
#define RCC_USART2CFGR 0x780
|
||||
#define RCC_USART3CFGR 0x784
|
||||
#define RCC_UART4CFGR 0x788
|
||||
#define RCC_UART5CFGR 0x78C
|
||||
#define RCC_USART6CFGR 0x790
|
||||
#define RCC_UART7CFGR 0x794
|
||||
#define RCC_UART8CFGR 0x798
|
||||
#define RCC_UART9CFGR 0x79C
|
||||
#define RCC_LPUART1CFGR 0x7A0
|
||||
#define RCC_I2C1CFGR 0x7A4
|
||||
#define RCC_I2C2CFGR 0x7A8
|
||||
#define RCC_I2C3CFGR 0x7AC
|
||||
#define RCC_I2C4CFGR 0x7B0
|
||||
#define RCC_I2C5CFGR 0x7B4
|
||||
#define RCC_I2C6CFGR 0x7B8
|
||||
#define RCC_I2C7CFGR 0x7BC
|
||||
#define RCC_I2C8CFGR 0x7C0
|
||||
#define RCC_SAI1CFGR 0x7C4
|
||||
#define RCC_SAI2CFGR 0x7C8
|
||||
#define RCC_SAI3CFGR 0x7CC
|
||||
#define RCC_SAI4CFGR 0x7D0
|
||||
#define RCC_MDF1CFGR 0x7D8
|
||||
#define RCC_ADF1CFGR 0x7DC
|
||||
#define RCC_FDCANCFGR 0x7E0
|
||||
#define RCC_HDPCFGR 0x7E4
|
||||
#define RCC_ADC12CFGR 0x7E8
|
||||
#define RCC_ADC3CFGR 0x7EC
|
||||
#define RCC_ETH1CFGR 0x7F0
|
||||
#define RCC_ETH2CFGR 0x7F4
|
||||
#define RCC_USBHCFGR 0x7FC
|
||||
#define RCC_USB2PHY1CFGR 0x800
|
||||
#define RCC_USB2PHY2CFGR 0x804
|
||||
#define RCC_USB3DRCFGR 0x808
|
||||
#define RCC_USB3PCIEPHYCFGR 0x80C
|
||||
#define RCC_PCIECFGR 0x810
|
||||
#define RCC_UCPDCFGR 0x814
|
||||
#define RCC_ETHSWCFGR 0x818
|
||||
#define RCC_ETHSWACMCFGR 0x81C
|
||||
#define RCC_ETHSWACMMSGCFGR 0x820
|
||||
#define RCC_STGENCFGR 0x824
|
||||
#define RCC_SDMMC1CFGR 0x830
|
||||
#define RCC_SDMMC2CFGR 0x834
|
||||
#define RCC_SDMMC3CFGR 0x838
|
||||
#define RCC_GPUCFGR 0x83C
|
||||
#define RCC_LTDCCFGR 0x840
|
||||
#define RCC_DSICFGR 0x844
|
||||
#define RCC_LVDSCFGR 0x850
|
||||
#define RCC_CSICFGR 0x858
|
||||
#define RCC_DCMIPPCFGR 0x85C
|
||||
#define RCC_CCICFGR 0x860
|
||||
#define RCC_VDECCFGR 0x864
|
||||
#define RCC_VENCCFGR 0x868
|
||||
#define RCC_RNGCFGR 0x870
|
||||
#define RCC_PKACFGR 0x874
|
||||
#define RCC_SAESCFGR 0x878
|
||||
#define RCC_HASHCFGR 0x87C
|
||||
#define RCC_CRYP1CFGR 0x880
|
||||
#define RCC_CRYP2CFGR 0x884
|
||||
#define RCC_IWDG1CFGR 0x888
|
||||
#define RCC_IWDG2CFGR 0x88C
|
||||
#define RCC_IWDG3CFGR 0x890
|
||||
#define RCC_IWDG4CFGR 0x894
|
||||
#define RCC_IWDG5CFGR 0x898
|
||||
#define RCC_WWDG1CFGR 0x89C
|
||||
#define RCC_WWDG2CFGR 0x8A0
|
||||
#define RCC_VREFCFGR 0x8A8
|
||||
#define RCC_DTSCFGR 0x8AC
|
||||
#define RCC_CRCCFGR 0x8B4
|
||||
#define RCC_SERCCFGR 0x8B8
|
||||
#define RCC_OSPIIOMCFGR 0x8BC
|
||||
#define RCC_GICV2MCFGR 0x8C0
|
||||
#define RCC_I3C1CFGR 0x8C8
|
||||
#define RCC_I3C2CFGR 0x8CC
|
||||
#define RCC_I3C3CFGR 0x8D0
|
||||
#define RCC_I3C4CFGR 0x8D4
|
||||
#define RCC_MUXSELCFGR 0x1000
|
||||
#define RCC_XBAR0CFGR 0x1018
|
||||
#define RCC_XBAR1CFGR 0x101C
|
||||
#define RCC_XBAR2CFGR 0x1020
|
||||
#define RCC_XBAR3CFGR 0x1024
|
||||
#define RCC_XBAR4CFGR 0x1028
|
||||
#define RCC_XBAR5CFGR 0x102C
|
||||
#define RCC_XBAR6CFGR 0x1030
|
||||
#define RCC_XBAR7CFGR 0x1034
|
||||
#define RCC_XBAR8CFGR 0x1038
|
||||
#define RCC_XBAR9CFGR 0x103C
|
||||
#define RCC_XBAR10CFGR 0x1040
|
||||
#define RCC_XBAR11CFGR 0x1044
|
||||
#define RCC_XBAR12CFGR 0x1048
|
||||
#define RCC_XBAR13CFGR 0x104C
|
||||
#define RCC_XBAR14CFGR 0x1050
|
||||
#define RCC_XBAR15CFGR 0x1054
|
||||
#define RCC_XBAR16CFGR 0x1058
|
||||
#define RCC_XBAR17CFGR 0x105C
|
||||
#define RCC_XBAR18CFGR 0x1060
|
||||
#define RCC_XBAR19CFGR 0x1064
|
||||
#define RCC_XBAR20CFGR 0x1068
|
||||
#define RCC_XBAR21CFGR 0x106C
|
||||
#define RCC_XBAR22CFGR 0x1070
|
||||
#define RCC_XBAR23CFGR 0x1074
|
||||
#define RCC_XBAR24CFGR 0x1078
|
||||
#define RCC_XBAR25CFGR 0x107C
|
||||
#define RCC_XBAR26CFGR 0x1080
|
||||
#define RCC_XBAR27CFGR 0x1084
|
||||
#define RCC_XBAR28CFGR 0x1088
|
||||
#define RCC_XBAR29CFGR 0x108C
|
||||
#define RCC_XBAR30CFGR 0x1090
|
||||
#define RCC_XBAR31CFGR 0x1094
|
||||
#define RCC_XBAR32CFGR 0x1098
|
||||
#define RCC_XBAR33CFGR 0x109C
|
||||
#define RCC_XBAR34CFGR 0x10A0
|
||||
#define RCC_XBAR35CFGR 0x10A4
|
||||
#define RCC_XBAR36CFGR 0x10A8
|
||||
#define RCC_XBAR37CFGR 0x10AC
|
||||
#define RCC_XBAR38CFGR 0x10B0
|
||||
#define RCC_XBAR39CFGR 0x10B4
|
||||
#define RCC_XBAR40CFGR 0x10B8
|
||||
#define RCC_XBAR41CFGR 0x10BC
|
||||
#define RCC_XBAR42CFGR 0x10C0
|
||||
#define RCC_XBAR43CFGR 0x10C4
|
||||
#define RCC_XBAR44CFGR 0x10C8
|
||||
#define RCC_XBAR45CFGR 0x10CC
|
||||
#define RCC_XBAR46CFGR 0x10D0
|
||||
#define RCC_XBAR47CFGR 0x10D4
|
||||
#define RCC_XBAR48CFGR 0x10D8
|
||||
#define RCC_XBAR49CFGR 0x10DC
|
||||
#define RCC_XBAR50CFGR 0x10E0
|
||||
#define RCC_XBAR51CFGR 0x10E4
|
||||
#define RCC_XBAR52CFGR 0x10E8
|
||||
#define RCC_XBAR53CFGR 0x10EC
|
||||
#define RCC_XBAR54CFGR 0x10F0
|
||||
#define RCC_XBAR55CFGR 0x10F4
|
||||
#define RCC_XBAR56CFGR 0x10F8
|
||||
#define RCC_XBAR57CFGR 0x10FC
|
||||
#define RCC_XBAR58CFGR 0x1100
|
||||
#define RCC_XBAR59CFGR 0x1104
|
||||
#define RCC_XBAR60CFGR 0x1108
|
||||
#define RCC_XBAR61CFGR 0x110C
|
||||
#define RCC_XBAR62CFGR 0x1110
|
||||
#define RCC_XBAR63CFGR 0x1114
|
||||
#define RCC_PREDIV0CFGR 0x1118
|
||||
#define RCC_PREDIV1CFGR 0x111C
|
||||
#define RCC_PREDIV2CFGR 0x1120
|
||||
#define RCC_PREDIV3CFGR 0x1124
|
||||
#define RCC_PREDIV4CFGR 0x1128
|
||||
#define RCC_PREDIV5CFGR 0x112C
|
||||
#define RCC_PREDIV6CFGR 0x1130
|
||||
#define RCC_PREDIV7CFGR 0x1134
|
||||
#define RCC_PREDIV8CFGR 0x1138
|
||||
#define RCC_PREDIV9CFGR 0x113C
|
||||
#define RCC_PREDIV10CFGR 0x1140
|
||||
#define RCC_PREDIV11CFGR 0x1144
|
||||
#define RCC_PREDIV12CFGR 0x1148
|
||||
#define RCC_PREDIV13CFGR 0x114C
|
||||
#define RCC_PREDIV14CFGR 0x1150
|
||||
#define RCC_PREDIV15CFGR 0x1154
|
||||
#define RCC_PREDIV16CFGR 0x1158
|
||||
#define RCC_PREDIV17CFGR 0x115C
|
||||
#define RCC_PREDIV18CFGR 0x1160
|
||||
#define RCC_PREDIV19CFGR 0x1164
|
||||
#define RCC_PREDIV20CFGR 0x1168
|
||||
#define RCC_PREDIV21CFGR 0x116C
|
||||
#define RCC_PREDIV22CFGR 0x1170
|
||||
#define RCC_PREDIV23CFGR 0x1174
|
||||
#define RCC_PREDIV24CFGR 0x1178
|
||||
#define RCC_PREDIV25CFGR 0x117C
|
||||
#define RCC_PREDIV26CFGR 0x1180
|
||||
#define RCC_PREDIV27CFGR 0x1184
|
||||
#define RCC_PREDIV28CFGR 0x1188
|
||||
#define RCC_PREDIV29CFGR 0x118C
|
||||
#define RCC_PREDIV30CFGR 0x1190
|
||||
#define RCC_PREDIV31CFGR 0x1194
|
||||
#define RCC_PREDIV32CFGR 0x1198
|
||||
#define RCC_PREDIV33CFGR 0x119C
|
||||
#define RCC_PREDIV34CFGR 0x11A0
|
||||
#define RCC_PREDIV35CFGR 0x11A4
|
||||
#define RCC_PREDIV36CFGR 0x11A8
|
||||
#define RCC_PREDIV37CFGR 0x11AC
|
||||
#define RCC_PREDIV38CFGR 0x11B0
|
||||
#define RCC_PREDIV39CFGR 0x11B4
|
||||
#define RCC_PREDIV40CFGR 0x11B8
|
||||
#define RCC_PREDIV41CFGR 0x11BC
|
||||
#define RCC_PREDIV42CFGR 0x11C0
|
||||
#define RCC_PREDIV43CFGR 0x11C4
|
||||
#define RCC_PREDIV44CFGR 0x11C8
|
||||
#define RCC_PREDIV45CFGR 0x11CC
|
||||
#define RCC_PREDIV46CFGR 0x11D0
|
||||
#define RCC_PREDIV47CFGR 0x11D4
|
||||
#define RCC_PREDIV48CFGR 0x11D8
|
||||
#define RCC_PREDIV49CFGR 0x11DC
|
||||
#define RCC_PREDIV50CFGR 0x11E0
|
||||
#define RCC_PREDIV51CFGR 0x11E4
|
||||
#define RCC_PREDIV52CFGR 0x11E8
|
||||
#define RCC_PREDIV53CFGR 0x11EC
|
||||
#define RCC_PREDIV54CFGR 0x11F0
|
||||
#define RCC_PREDIV55CFGR 0x11F4
|
||||
#define RCC_PREDIV56CFGR 0x11F8
|
||||
#define RCC_PREDIV57CFGR 0x11FC
|
||||
#define RCC_PREDIV58CFGR 0x1200
|
||||
#define RCC_PREDIV59CFGR 0x1204
|
||||
#define RCC_PREDIV60CFGR 0x1208
|
||||
#define RCC_PREDIV61CFGR 0x120C
|
||||
#define RCC_PREDIV62CFGR 0x1210
|
||||
#define RCC_PREDIV63CFGR 0x1214
|
||||
#define RCC_PREDIVSR1 0x1218
|
||||
#define RCC_PREDIVSR2 0x121C
|
||||
#define RCC_FINDIV0CFGR 0x1224
|
||||
#define RCC_FINDIV1CFGR 0x1228
|
||||
#define RCC_FINDIV2CFGR 0x122C
|
||||
#define RCC_FINDIV3CFGR 0x1230
|
||||
#define RCC_FINDIV4CFGR 0x1234
|
||||
#define RCC_FINDIV5CFGR 0x1238
|
||||
#define RCC_FINDIV6CFGR 0x123C
|
||||
#define RCC_FINDIV7CFGR 0x1240
|
||||
#define RCC_FINDIV8CFGR 0x1244
|
||||
#define RCC_FINDIV9CFGR 0x1248
|
||||
#define RCC_FINDIV10CFGR 0x124C
|
||||
#define RCC_FINDIV11CFGR 0x1250
|
||||
#define RCC_FINDIV12CFGR 0x1254
|
||||
#define RCC_FINDIV13CFGR 0x1258
|
||||
#define RCC_FINDIV14CFGR 0x125C
|
||||
#define RCC_FINDIV15CFGR 0x1260
|
||||
#define RCC_FINDIV16CFGR 0x1264
|
||||
#define RCC_FINDIV17CFGR 0x1268
|
||||
#define RCC_FINDIV18CFGR 0x126C
|
||||
#define RCC_FINDIV19CFGR 0x1270
|
||||
#define RCC_FINDIV20CFGR 0x1274
|
||||
#define RCC_FINDIV21CFGR 0x1278
|
||||
#define RCC_FINDIV22CFGR 0x127C
|
||||
#define RCC_FINDIV23CFGR 0x1280
|
||||
#define RCC_FINDIV24CFGR 0x1284
|
||||
#define RCC_FINDIV25CFGR 0x1288
|
||||
#define RCC_FINDIV26CFGR 0x128C
|
||||
#define RCC_FINDIV27CFGR 0x1290
|
||||
#define RCC_FINDIV28CFGR 0x1294
|
||||
#define RCC_FINDIV29CFGR 0x1298
|
||||
#define RCC_FINDIV30CFGR 0x129C
|
||||
#define RCC_FINDIV31CFGR 0x12A0
|
||||
#define RCC_FINDIV32CFGR 0x12A4
|
||||
#define RCC_FINDIV33CFGR 0x12A8
|
||||
#define RCC_FINDIV34CFGR 0x12AC
|
||||
#define RCC_FINDIV35CFGR 0x12B0
|
||||
#define RCC_FINDIV36CFGR 0x12B4
|
||||
#define RCC_FINDIV37CFGR 0x12B8
|
||||
#define RCC_FINDIV38CFGR 0x12BC
|
||||
#define RCC_FINDIV39CFGR 0x12C0
|
||||
#define RCC_FINDIV40CFGR 0x12C4
|
||||
#define RCC_FINDIV41CFGR 0x12C8
|
||||
#define RCC_FINDIV42CFGR 0x12CC
|
||||
#define RCC_FINDIV43CFGR 0x12D0
|
||||
#define RCC_FINDIV44CFGR 0x12D4
|
||||
#define RCC_FINDIV45CFGR 0x12D8
|
||||
#define RCC_FINDIV46CFGR 0x12DC
|
||||
#define RCC_FINDIV47CFGR 0x12E0
|
||||
#define RCC_FINDIV48CFGR 0x12E4
|
||||
#define RCC_FINDIV49CFGR 0x12E8
|
||||
#define RCC_FINDIV50CFGR 0x12EC
|
||||
#define RCC_FINDIV51CFGR 0x12F0
|
||||
#define RCC_FINDIV52CFGR 0x12F4
|
||||
#define RCC_FINDIV53CFGR 0x12F8
|
||||
#define RCC_FINDIV54CFGR 0x12FC
|
||||
#define RCC_FINDIV55CFGR 0x1300
|
||||
#define RCC_FINDIV56CFGR 0x1304
|
||||
#define RCC_FINDIV57CFGR 0x1308
|
||||
#define RCC_FINDIV58CFGR 0x130C
|
||||
#define RCC_FINDIV59CFGR 0x1310
|
||||
#define RCC_FINDIV60CFGR 0x1314
|
||||
#define RCC_FINDIV61CFGR 0x1318
|
||||
#define RCC_FINDIV62CFGR 0x131C
|
||||
#define RCC_FINDIV63CFGR 0x1320
|
||||
#define RCC_FINDIVSR1 0x1324
|
||||
#define RCC_FINDIVSR2 0x1328
|
||||
#define RCC_FCALCOBS0CFGR 0x1340
|
||||
#define RCC_FCALCOBS1CFGR 0x1344
|
||||
#define RCC_FCALCREFCFGR 0x1348
|
||||
#define RCC_FCALCCR1 0x134C
|
||||
#define RCC_FCALCCR2 0x1354
|
||||
#define RCC_FCALCSR 0x1358
|
||||
#define RCC_PLL4CFGR1 0x1360
|
||||
#define RCC_PLL4CFGR2 0x1364
|
||||
#define RCC_PLL4CFGR3 0x1368
|
||||
#define RCC_PLL4CFGR4 0x136C
|
||||
#define RCC_PLL4CFGR5 0x1370
|
||||
#define RCC_PLL4CFGR6 0x1378
|
||||
#define RCC_PLL4CFGR7 0x137C
|
||||
#define RCC_PLL5CFGR1 0x1388
|
||||
#define RCC_PLL5CFGR2 0x138C
|
||||
#define RCC_PLL5CFGR3 0x1390
|
||||
#define RCC_PLL5CFGR4 0x1394
|
||||
#define RCC_PLL5CFGR5 0x1398
|
||||
#define RCC_PLL5CFGR6 0x13A0
|
||||
#define RCC_PLL5CFGR7 0x13A4
|
||||
#define RCC_PLL6CFGR1 0x13B0
|
||||
#define RCC_PLL6CFGR2 0x13B4
|
||||
#define RCC_PLL6CFGR3 0x13B8
|
||||
#define RCC_PLL6CFGR4 0x13BC
|
||||
#define RCC_PLL6CFGR5 0x13C0
|
||||
#define RCC_PLL6CFGR6 0x13C8
|
||||
#define RCC_PLL6CFGR7 0x13CC
|
||||
#define RCC_PLL7CFGR1 0x13D8
|
||||
#define RCC_PLL7CFGR2 0x13DC
|
||||
#define RCC_PLL7CFGR3 0x13E0
|
||||
#define RCC_PLL7CFGR4 0x13E4
|
||||
#define RCC_PLL7CFGR5 0x13E8
|
||||
#define RCC_PLL7CFGR6 0x13F0
|
||||
#define RCC_PLL7CFGR7 0x13F4
|
||||
#define RCC_PLL8CFGR1 0x1400
|
||||
#define RCC_PLL8CFGR2 0x1404
|
||||
#define RCC_PLL8CFGR3 0x1408
|
||||
#define RCC_PLL8CFGR4 0x140C
|
||||
#define RCC_PLL8CFGR5 0x1410
|
||||
#define RCC_PLL8CFGR6 0x1418
|
||||
#define RCC_PLL8CFGR7 0x141C
|
||||
#define RCC_VERR 0xFFF4
|
||||
#define RCC_IDR 0xFFF8
|
||||
#define RCC_SIDR 0xFFFC
|
||||
|
||||
#endif /* STM32MP25_RCC_H */
|
||||
@@ -32,13 +32,13 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", &test_dev));
|
||||
|
||||
/* Test for clk_get_by_id() */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_ECSPI_ROOT), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("ecspi_root", clk->dev->name);
|
||||
ut_asserteq(CLK_SET_RATE_PARENT, clk->flags);
|
||||
|
||||
/* Test for clk_get_parent_rate() */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_ECSPI1, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_ECSPI1), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("ecspi1", clk->dev->name);
|
||||
ut_asserteq(CLK_SET_RATE_PARENT, clk->flags);
|
||||
@@ -47,7 +47,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ut_asserteq(rate, 20000000);
|
||||
|
||||
/* test the gate of CCF */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_ECSPI0, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_ECSPI0), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("ecspi0", clk->dev->name);
|
||||
ut_asserteq(CLK_SET_RATE_PARENT, clk->flags);
|
||||
@@ -56,7 +56,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ut_asserteq(rate, 20000000);
|
||||
|
||||
/* Test the mux of CCF */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_USDHC1_SEL, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_USDHC1_SEL), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("usdhc1_sel", clk->dev->name);
|
||||
ut_asserteq(CLK_SET_RATE_NO_REPARENT, clk->flags);
|
||||
@@ -70,7 +70,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
rate = clk_get_rate(clk);
|
||||
ut_asserteq(rate, 60000000);
|
||||
|
||||
ret = clk_get_by_id(SANDBOX_CLK_PLL3_80M, &pclk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_PLL3_80M), &pclk);
|
||||
ut_assertok(ret);
|
||||
|
||||
ret = clk_set_parent(clk, pclk);
|
||||
@@ -79,7 +79,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
rate = clk_get_rate(clk);
|
||||
ut_asserteq(rate, 80000000);
|
||||
|
||||
ret = clk_get_by_id(SANDBOX_CLK_USDHC2_SEL, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_USDHC2_SEL), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("usdhc2_sel", clk->dev->name);
|
||||
ut_asserteq(CLK_SET_RATE_NO_REPARENT, clk->flags);
|
||||
@@ -97,7 +97,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
rate = clk_get_rate(clk);
|
||||
ut_asserteq(rate, 80000000);
|
||||
|
||||
ret = clk_get_by_id(SANDBOX_CLK_PLL3_60M, &pclk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_PLL3_60M), &pclk);
|
||||
ut_assertok(ret);
|
||||
|
||||
ret = clk_set_parent(clk, pclk);
|
||||
@@ -107,7 +107,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ut_asserteq(rate, 60000000);
|
||||
|
||||
/* Test the composite of CCF */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_I2C, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("i2c", clk->dev->name);
|
||||
ut_asserteq(CLK_SET_RATE_UNGATE, clk->flags);
|
||||
@@ -124,12 +124,12 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ret = clk_get_by_index(test_dev, SANDBOX_CLK_TEST_ID_I2C_ROOT, &clk_ccf);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("clk-ccf", clk_ccf.dev->name);
|
||||
ut_asserteq(clk_ccf.id, SANDBOX_CLK_I2C_ROOT);
|
||||
ut_asserteq(clk_ccf.id, CLK_ID(clk_ccf.dev, SANDBOX_CLK_I2C_ROOT));
|
||||
|
||||
ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C_ROOT), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("i2c_root", clk->dev->name);
|
||||
ut_asserteq(clk->id, SANDBOX_CLK_I2C_ROOT);
|
||||
ut_asserteq(clk_get_id(clk), SANDBOX_CLK_I2C_ROOT);
|
||||
|
||||
ret = clk_enable(&clk_ccf);
|
||||
ut_assertok(ret);
|
||||
@@ -137,7 +137,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ret = sandbox_clk_enable_count(clk);
|
||||
ut_asserteq(ret, 1);
|
||||
|
||||
ret = clk_get_by_id(SANDBOX_CLK_I2C, &pclk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C), &pclk);
|
||||
ut_assertok(ret);
|
||||
|
||||
ret = sandbox_clk_enable_count(pclk);
|
||||
@@ -153,7 +153,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ut_asserteq(ret, 0);
|
||||
|
||||
/* Test clock re-parenting. */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_USDHC1_SEL, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_USDHC1_SEL), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("usdhc1_sel", clk->dev->name);
|
||||
|
||||
@@ -167,7 +167,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
clkid = SANDBOX_CLK_PLL3_60M;
|
||||
}
|
||||
|
||||
ret = clk_get_by_id(clkid, &pclk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, clkid), &pclk);
|
||||
ut_assertok(ret);
|
||||
ret = clk_set_parent(clk, pclk);
|
||||
ut_assertok(ret);
|
||||
@@ -176,7 +176,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
|
||||
ut_asserteq_str(clkname, pclk->dev->name);
|
||||
|
||||
/* Test disabling critical clock. */
|
||||
ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
|
||||
ret = clk_get_by_id(CLK_ID(dev, SANDBOX_CLK_I2C_ROOT), &clk);
|
||||
ut_assertok(ret);
|
||||
ut_asserteq_str("i2c_root", clk->dev->name);
|
||||
|
||||
|
||||
@@ -8,58 +8,74 @@
|
||||
|
||||
/* magic ='S' 'T' 'M' 0x32 */
|
||||
#define HEADER_MAGIC be32_to_cpu(0x53544D32)
|
||||
#define VER_MAJOR_IDX 2
|
||||
#define VER_MINOR_IDX 1
|
||||
#define VER_VARIANT_IDX 0
|
||||
#define VER_MAJOR 2
|
||||
#define VER_MINOR 1
|
||||
#define VER_VARIANT 0
|
||||
#define HEADER_VERSION_V1 0x1
|
||||
#define HEADER_VERSION_V2 0x2
|
||||
/* default option : bit0 => no signature */
|
||||
#define HEADER_DEFAULT_OPTION (cpu_to_le32(0x00000001))
|
||||
/* default binary type for U-Boot */
|
||||
#define HEADER_TYPE_UBOOT (cpu_to_le32(0x00000000))
|
||||
#define PADDING_HEADER_MAGIC (cpu_to_le32(0xFFFF5453))
|
||||
#define PADDING_HEADER_FLAG (1ULL << 31)
|
||||
#define PADDING_HEADER_LENGTH 0x180
|
||||
|
||||
struct stm32_header {
|
||||
struct stm32_header_v1 {
|
||||
uint32_t magic_number;
|
||||
uint32_t image_signature[64 / 4];
|
||||
uint8_t image_signature[64];
|
||||
uint32_t image_checksum;
|
||||
uint8_t header_version[4];
|
||||
uint8_t header_version[4];
|
||||
uint32_t image_length;
|
||||
uint32_t image_entry_point;
|
||||
uint32_t reserved1;
|
||||
uint32_t load_address;
|
||||
uint32_t reserved2;
|
||||
uint32_t version_number;
|
||||
/* V1.0 specific content */
|
||||
uint32_t option_flags;
|
||||
uint32_t ecdsa_algorithm;
|
||||
uint32_t ecdsa_public_key[64 / 4];
|
||||
uint32_t padding[83 / 4];
|
||||
uint32_t binary_type;
|
||||
uint8_t ecdsa_public_key[64];
|
||||
uint8_t padding[83];
|
||||
uint8_t binary_type;
|
||||
};
|
||||
|
||||
static struct stm32_header stm32image_header;
|
||||
struct stm32_header_v2 {
|
||||
uint32_t magic_number;
|
||||
uint8_t image_signature[64];
|
||||
uint32_t image_checksum;
|
||||
uint8_t header_version[4];
|
||||
uint32_t image_length;
|
||||
uint32_t image_entry_point;
|
||||
uint32_t reserved1;
|
||||
uint32_t load_address;
|
||||
uint32_t reserved2;
|
||||
uint32_t version_number;
|
||||
/* V2.0 specific content */
|
||||
uint32_t extension_flags;
|
||||
uint32_t extension_headers_length;
|
||||
uint32_t binary_type;
|
||||
uint8_t padding[16];
|
||||
uint32_t extension_header_type;
|
||||
uint32_t extension_header_length;
|
||||
uint8_t extension_padding[376];
|
||||
};
|
||||
|
||||
static void stm32image_default_header(struct stm32_header *ptr)
|
||||
{
|
||||
if (!ptr)
|
||||
return;
|
||||
static struct stm32_header_v1 stm32image_header_v1;
|
||||
static struct stm32_header_v2 stm32image_header_v2;
|
||||
|
||||
ptr->magic_number = HEADER_MAGIC;
|
||||
ptr->header_version[VER_MAJOR_IDX] = HEADER_VERSION_V1;
|
||||
ptr->option_flags = HEADER_DEFAULT_OPTION;
|
||||
ptr->ecdsa_algorithm = cpu_to_le32(1);
|
||||
ptr->binary_type = HEADER_TYPE_UBOOT;
|
||||
}
|
||||
|
||||
static uint32_t stm32image_checksum(void *start, uint32_t len)
|
||||
static uint32_t stm32image_checksum(void *start, uint32_t len,
|
||||
uint32_t header_size)
|
||||
{
|
||||
uint32_t csum = 0;
|
||||
uint32_t hdr_len = sizeof(struct stm32_header);
|
||||
uint8_t *p;
|
||||
|
||||
if (len < hdr_len)
|
||||
if (len < header_size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = start + hdr_len;
|
||||
len -= hdr_len;
|
||||
p = (unsigned char *)start + header_size;
|
||||
len -= header_size;
|
||||
|
||||
while (len > 0) {
|
||||
csum += *p;
|
||||
@@ -70,24 +86,53 @@ static uint32_t stm32image_checksum(void *start, uint32_t len)
|
||||
return csum;
|
||||
}
|
||||
|
||||
static int stm32image_check_image_types(uint8_t type)
|
||||
static int stm32image_check_image_types_v1(uint8_t type)
|
||||
{
|
||||
if (type == IH_TYPE_STM32IMAGE)
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static int stm32image_verify_header(unsigned char *ptr, int image_size,
|
||||
struct image_tool_params *params)
|
||||
static int stm32image_check_image_types_v2(uint8_t type)
|
||||
{
|
||||
struct stm32_header *stm32hdr = (struct stm32_header *)ptr;
|
||||
if (type == IH_TYPE_STM32IMAGE_V2)
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static int stm32image_verify_header_v1(unsigned char *ptr, int image_size,
|
||||
struct image_tool_params *params)
|
||||
{
|
||||
struct stm32_header_v1 *stm32hdr = (struct stm32_header_v1 *)ptr;
|
||||
int i;
|
||||
|
||||
if (image_size < sizeof(struct stm32_header))
|
||||
if (image_size < sizeof(struct stm32_header_v1))
|
||||
return -1;
|
||||
if (stm32hdr->magic_number != HEADER_MAGIC)
|
||||
return -1;
|
||||
if (stm32hdr->header_version[VER_MAJOR_IDX] != HEADER_VERSION_V1)
|
||||
if (stm32hdr->header_version[VER_MAJOR] != HEADER_VERSION_V1)
|
||||
return -1;
|
||||
if (stm32hdr->reserved1 || stm32hdr->reserved2)
|
||||
return -1;
|
||||
for (i = 0; i < (sizeof(stm32hdr->padding) / 4); i++) {
|
||||
if (stm32hdr->padding[i] != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stm32image_verify_header_v2(unsigned char *ptr, int image_size,
|
||||
struct image_tool_params *params)
|
||||
{
|
||||
struct stm32_header_v2 *stm32hdr = (struct stm32_header_v2 *)ptr;
|
||||
int i;
|
||||
|
||||
if (image_size < sizeof(struct stm32_header_v2))
|
||||
return -1;
|
||||
if (stm32hdr->magic_number != HEADER_MAGIC)
|
||||
return -1;
|
||||
if (stm32hdr->header_version[VER_MAJOR] != HEADER_VERSION_V2)
|
||||
return -1;
|
||||
if (stm32hdr->reserved1 || stm32hdr->reserved2)
|
||||
return -1;
|
||||
@@ -101,38 +146,85 @@ static int stm32image_verify_header(unsigned char *ptr, int image_size,
|
||||
|
||||
static void stm32image_print_header(const void *ptr, struct image_tool_params *params)
|
||||
{
|
||||
struct stm32_header *stm32hdr = (struct stm32_header *)ptr;
|
||||
struct stm32_header_v1 *stm32hdr_v1 = (struct stm32_header_v1 *)ptr;
|
||||
struct stm32_header_v2 *stm32hdr_v2 = (struct stm32_header_v2 *)ptr;
|
||||
|
||||
printf("Image Type : STMicroelectronics STM32 V%d.%d\n",
|
||||
stm32hdr->header_version[VER_MAJOR_IDX],
|
||||
stm32hdr->header_version[VER_MINOR_IDX]);
|
||||
stm32hdr_v1->header_version[VER_MAJOR],
|
||||
stm32hdr_v1->header_version[VER_MINOR]);
|
||||
printf("Image Size : %lu bytes\n",
|
||||
(unsigned long)le32_to_cpu(stm32hdr->image_length));
|
||||
(unsigned long)le32_to_cpu(stm32hdr_v1->image_length));
|
||||
printf("Image Load : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr->load_address));
|
||||
le32_to_cpu(stm32hdr_v1->load_address));
|
||||
printf("Entry Point : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr->image_entry_point));
|
||||
le32_to_cpu(stm32hdr_v1->image_entry_point));
|
||||
printf("Checksum : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr->image_checksum));
|
||||
printf("Option : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr->option_flags));
|
||||
printf("BinaryType : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr->binary_type));
|
||||
le32_to_cpu(stm32hdr_v1->image_checksum));
|
||||
switch (stm32hdr_v1->header_version[VER_MAJOR]) {
|
||||
case HEADER_VERSION_V1:
|
||||
printf("Option : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr_v1->option_flags));
|
||||
printf("BinaryType : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr_v1->binary_type));
|
||||
break;
|
||||
|
||||
case HEADER_VERSION_V2:
|
||||
printf("Extension : 0x%08x\n",
|
||||
le32_to_cpu(stm32hdr_v2->extension_flags));
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Incorrect header version\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void stm32image_set_header(void *ptr, struct stat *sbuf, int ifd,
|
||||
struct image_tool_params *params)
|
||||
static void stm32image_set_header_v1(void *ptr, struct stat *sbuf, int ifd,
|
||||
struct image_tool_params *params)
|
||||
{
|
||||
struct stm32_header *stm32hdr = (struct stm32_header *)ptr;
|
||||
struct stm32_header_v1 *stm32hdr = (struct stm32_header_v1 *)ptr;
|
||||
|
||||
stm32image_default_header(stm32hdr);
|
||||
stm32hdr->magic_number = HEADER_MAGIC;
|
||||
stm32hdr->version_number = cpu_to_le32(0);
|
||||
|
||||
stm32hdr->header_version[VER_MAJOR] = HEADER_VERSION_V1;
|
||||
stm32hdr->option_flags = HEADER_DEFAULT_OPTION;
|
||||
stm32hdr->ecdsa_algorithm = cpu_to_le32(1);
|
||||
stm32hdr->binary_type = HEADER_TYPE_UBOOT;
|
||||
|
||||
stm32hdr->load_address = cpu_to_le32(params->addr);
|
||||
stm32hdr->image_entry_point = cpu_to_le32(params->ep);
|
||||
stm32hdr->image_length = cpu_to_le32((uint32_t)sbuf->st_size -
|
||||
sizeof(struct stm32_header));
|
||||
sizeof(*stm32hdr));
|
||||
stm32hdr->image_checksum =
|
||||
cpu_to_le32(stm32image_checksum(ptr, sbuf->st_size));
|
||||
cpu_to_le32(stm32image_checksum(ptr, sbuf->st_size,
|
||||
sizeof(*stm32hdr)));
|
||||
}
|
||||
|
||||
static void stm32image_set_header_v2(void *ptr, struct stat *sbuf, int ifd,
|
||||
struct image_tool_params *params)
|
||||
{
|
||||
struct stm32_header_v2 *stm32hdr = (struct stm32_header_v2 *)ptr;
|
||||
|
||||
stm32hdr->magic_number = HEADER_MAGIC;
|
||||
stm32hdr->version_number = cpu_to_le32(0);
|
||||
|
||||
stm32hdr->header_version[VER_MAJOR] = HEADER_VERSION_V2;
|
||||
stm32hdr->extension_flags =
|
||||
cpu_to_le32(PADDING_HEADER_FLAG);
|
||||
stm32hdr->extension_headers_length =
|
||||
cpu_to_le32(PADDING_HEADER_LENGTH);
|
||||
stm32hdr->extension_header_type =
|
||||
cpu_to_le32(PADDING_HEADER_MAGIC);
|
||||
stm32hdr->extension_header_length =
|
||||
cpu_to_le32(PADDING_HEADER_LENGTH);
|
||||
|
||||
stm32hdr->load_address = cpu_to_le32(params->addr);
|
||||
stm32hdr->image_entry_point = cpu_to_le32(params->ep);
|
||||
stm32hdr->image_length = cpu_to_le32((uint32_t)sbuf->st_size -
|
||||
sizeof(*stm32hdr));
|
||||
stm32hdr->image_checksum =
|
||||
cpu_to_le32(stm32image_checksum(ptr, sbuf->st_size,
|
||||
sizeof(*stm32hdr)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -141,14 +233,29 @@ static void stm32image_set_header(void *ptr, struct stat *sbuf, int ifd,
|
||||
U_BOOT_IMAGE_TYPE(
|
||||
stm32image,
|
||||
"STMicroelectronics STM32MP Image support",
|
||||
sizeof(struct stm32_header),
|
||||
(void *)&stm32image_header,
|
||||
sizeof(struct stm32_header_v1),
|
||||
(void *)&stm32image_header_v1,
|
||||
NULL,
|
||||
stm32image_verify_header,
|
||||
stm32image_verify_header_v1,
|
||||
stm32image_print_header,
|
||||
stm32image_set_header,
|
||||
stm32image_set_header_v1,
|
||||
NULL,
|
||||
stm32image_check_image_types,
|
||||
stm32image_check_image_types_v1,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
U_BOOT_IMAGE_TYPE(
|
||||
stm32imagev2,
|
||||
"STMicroelectronics STM32MP Image V2.0 support",
|
||||
sizeof(struct stm32_header_v2),
|
||||
(void *)&stm32image_header_v2,
|
||||
NULL,
|
||||
stm32image_verify_header_v2,
|
||||
stm32image_print_header,
|
||||
stm32image_set_header_v2,
|
||||
NULL,
|
||||
stm32image_check_image_types_v2,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user