stm32f429: pass the device unique ID in DTB
Subsystems (2)
PATCH 1/3 stm32f429: pass the device unique ID in DTB
Read device unique ID and set environment variable "serial#". Value would then be passed to kernel through DTB.
To read ID from DTB, kernel is required to have commit:3f599875e5202986b350618a617527ab441bf206 (ARM: 8355/1: arch: Show the serial number from devicetree in cpuinfo)
This commit is already mainline since v4.1-rc1.
To: Albert Aribaud <[email protected]>
To: Tom Rini <[email protected]>
To: Kamil Lulko <[email protected]>
Cc: u-boot at lists.denx.de
--- arch/arm/include/asm/arch-stm32f4/stm32.h | 10 ++++++++++ board/st/stm32f429-discovery/stm32f429-discovery.c | 19 +++++++++++++++++++ include/configs/stm32f429-discovery.h | 1 + 3 files changed, 30 insertions(+)
arch/arm/include/asm/arch-stm32f4/stm32.h +10 -0
@@ -14,6 +14,7 @@/* * Peripheral memory map */ +#define STM32_SYSMEM_BASE 0x1FFF0000#define STM32_PERIPH_BASE 0x40000000#define STM32_APB1PERIPH_BASE (STM32_PERIPH_BASE + 0x00000000)#define STM32_APB2PERIPH_BASE (STM32_PERIPH_BASE + 0x00010000)
@@ -25,6 +26,12 @@/* * Register maps */ +struct stm32_u_id_regs { +u32 u_id_low; +u32 u_id_mid; +u32 u_id_high; +}; +struct stm32_rcc_regs {u32 cr;/* RCC clock control */ u32 pllcfgr;/* RCC PLL configuration */
@@ -78,6 +85,9 @@ struct stm32_flash_regs {/* * Registers access macros */ +#define STM32_U_ID_BASE (STM32_SYSMEM_BASE + 0x7A10) +#define STM32_U_ID ((struct stm32_u_id_regs *)STM32_U_ID_BASE) +#define STM32_RCC_BASE (STM32_AHB1PERIPH_BASE + 0x3800)#define STM32_RCC ((struct stm32_rcc_regs *)STM32_RCC_BASE)
board/st/stm32f429-discovery/stm32f429-discovery.c +19 -0
@@ -285,3 +285,22 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_MISC_INIT_R +int misc_init_r (void ) +{ +char serialno[25 ]; +uint32_t u_id_low, u_id_mid, u_id_high; + +if (!getenv ("serial#" )) { + u_id_low =readl (&STM32_U_ID ->u_id_low); + u_id_mid =readl (&STM32_U_ID ->u_id_mid); + u_id_high =readl (&STM32_U_ID ->u_id_high); +sprintf (serialno,"%08x%08x%08x" , + u_id_high, u_id_mid, u_id_low); +setenv ("serial#" , serialno); + } + +return 0 ; +} +#endif
include/configs/stm32f429-discovery.h +1 -0
@@ -15,6 +15,7 @@#define CONFIG_OF_LIBFDT #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_MISC_INIT_R #define CONFIG_SYS_FLASH_BASE 0x08000000
Signature · 1 line
2.4.6
PATCH 2/3 stm32f4: add cpu clock option for 180 MHz
While most stm32f4 run at 168 MHz, stm32f429 can work till 180 MHz. Add option to select 180 MHz through macro CONFIG_SYS_CLK_FREQ.
To: Albert Aribaud <[email protected]>
To: Tom Rini <[email protected]>
To: Kamil Lulko <[email protected]>
Cc: u-boot at lists.denx.de
--- arch/arm/cpu/armv7m/stm32f4/clock.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
arch/arm/cpu/armv7m/stm32f4/clock.c +24 -10
@@ -92,7 +92,20 @@ struct pll_psc {#error "CONFIG_STM32_HSE_HZ not defined!"#else #if (CONFIG_STM32_HSE_HZ ==8000000 ) -struct pll_psc pll_psc_168 = { +#if (CONFIG_SYS_CLK_FREQ ==180000000 ) +/* 180 MHz */ +struct pll_psc sys_pll_psc = { + .pll_m =8 , + .pll_n =360 , + .pll_p =2 , + .pll_q =8 , + .ahb_psc =AHB_PSC_1 , + .apb1_psc =APB_PSC_4 , + .apb2_psc =APB_PSC_2 +}; +#else +/* default 168 MHz */ +struct pll_psc sys_pll_psc = { .pll_m =8 , .pll_n =336 , .pll_p = 2,
@@ -101,6 +114,7 @@ struct pll_psc pll_psc_168 = { .apb1_psc = APB_PSC_4, .apb2_psc =APB_PSC_2 }; +#endif #else #error "No PLL/Prescaler configuration for given CONFIG_STM32_HSE_HZ exists"#endif
@@ -122,19 +136,19 @@ int configure_clocks(void)while (!(readl (&STM32_RCC ->cr) &RCC_CR_HSERDY )) ; -/* Enable high performance mode, System frequency up to 168 MHz */ +/* Enable high performance mode, System frequency up to 180 MHz */ setbits_le32 (&STM32_RCC ->apb1enr,RCC_APB1ENR_PWREN );writel (PWR_CR_VOS_SCALE_MODE_1 , &STM32_PWR ->cr);setbits_le32 (&STM32_RCC ->cfgr, (( - pll_psc_168.ahb_psc <<RCC_CFGR_HPRE_SHIFT ) - | (pll_psc_168.apb1_psc <<RCC_CFGR_PPRE1_SHIFT ) - | (pll_psc_168.apb2_psc <<RCC_CFGR_PPRE2_SHIFT ))); - -writel (pll_psc_168.pll_m - | (pll_psc_168.pll_n <<RCC_PLLCFGR_PLLN_SHIFT ) - | (((pll_psc_168.pll_p >>1 ) -1 ) <<RCC_PLLCFGR_PLLP_SHIFT ) - | (pll_psc_168.pll_q <<RCC_PLLCFGR_PLLQ_SHIFT ), + sys_pll_psc.ahb_psc <<RCC_CFGR_HPRE_SHIFT ) + | (sys_pll_psc.apb1_psc <<RCC_CFGR_PPRE1_SHIFT ) + | (sys_pll_psc.apb2_psc <<RCC_CFGR_PPRE2_SHIFT ))); + +writel (sys_pll_psc.pll_m + | (sys_pll_psc.pll_n <<RCC_PLLCFGR_PLLN_SHIFT ) + | (((sys_pll_psc.pll_p >>1 ) -1 ) <<RCC_PLLCFGR_PLLP_SHIFT ) + | (sys_pll_psc.pll_q <<RCC_PLLCFGR_PLLQ_SHIFT ), &STM32_RCC ->pllcfgr);setbits_le32 (&STM32_RCC ->pllcfgr,RCC_PLLCFGR_PLLSRC );
Signature · 1 line
2.4.6
PATCH 2/3 stm32f4: add cpu clock option for 180 MHz
Quoted 8 lines · Antonio Borneo
While most stm32f4 run at 168 MHz, stm32f429 can work till 180 MHz. Add option to select 180 MHz through macro
CONFIG_SYS_CLK_FREQ.Signed-off-by Antonio Borneo <[email protected]>To: Albert Aribaud <[email protected]>
To: Tom Rini <[email protected]>
To: Kamil Lulko <[email protected]>
Cc: u-boot at lists.denx.de
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150728/293b2451/attachment.sig>
PATCH 3/3 stm32f429: use 180 MHz system clock
In reply to Antonio BorneoMainline Linux kernel commit 338a6aaabc02fa63b70441dd0e1b70aea64673c6 (ARM: dts: Introduce STM32F429 MCU) in arch/arm/boot/dts/stm32f429.dtsi requires U-Boot to set system clock to 180 MHz.
To: Albert Aribaud <[email protected]>
To: Tom Rini <[email protected]>
To: Kamil Lulko <[email protected]>
Cc: u-boot at lists.denx.de
--- include/configs/stm32f429-discovery.h | 2 ++ 1 file changed, 2 insertions(+)
include/configs/stm32f429-discovery.h +2 -0
@@ -62,6 +62,8 @@#define CONFIG_STM32_HSE_HZ 8000000 +#define CONFIG_SYS_CLK_FREQ 180000000/* 180 MHz */ +#define CONFIG_SYS_HZ_CLOCK 1000000/* Timer is clocked at 1MHz */ #define CONFIG_CMDLINE_TAG
Signature · 1 line
2.4.6
PATCH 3/3 stm32f429: use 180 MHz system clock
Quoted 10 lines · Antonio Borneo
Mainline Linux kernel commit
338a6aaabc02fa63b70441dd0e1b70aea64673c6(ARM: dts: Introduce STM32F429 MCU) inarch/arm/boot/dts/stm32f429.dtsirequires U-Boot to set system clock to 180 MHz.Signed-off-by Antonio Borneo <[email protected]>To: Albert Aribaud <[email protected]>
To: Tom Rini <[email protected]>
To: Kamil Lulko <[email protected]>
Cc: u-boot at lists.denx.de
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150728/0b5badbb/attachment.sig>
PATCH 1/3 stm32f429: pass the device unique ID in DTB
In reply to Antonio BorneoQuoted 8 lines · Antonio Borneo
Read device unique ID and set environment variable "serial#". Value would then be passed to kernel through DTB.
To read ID from DTB, kernel is required to have commit:
3f599875e5202986b350618a617527ab441bf206(ARM: 8355/1: arch: Show the serial number from devicetree in cpuinfo)
This commit is already mainline since v4.1-rc1.
Quoted 5 lines
Signed-off-by Antonio Borneo <[email protected]>To: Albert Aribaud <[email protected]>
To: Tom Rini <[email protected]>
To: Kamil Lulko <[email protected]>
Cc: u-boot at lists.denx.de
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150728/fc71a09a/attachment.sig>