ARM: stm32: add network and qspi driver support to stm32f746-disco board
Subsystems (9)
v2 cover ARM: stm32: add network and qspi driver support to stm32f746-disco board
This series adds support for the network and the qspi devices found on the stm32f746 controller and enables those devices on the stm32f746-disco board.
Changes in v2:
- add cleanup patch
- Replaced bit shifts and masks with BIT() and GENMASK() macro
- Moved STM32_SYSCFG_BASE into stm32.h header
- Add Acked-by tag to 'net: phy: add SMSC LAN8742 phy'
- Replaced bit shifts and masks with BIT() and GENMASK() macro
Michael Kurz (7):
ARM: DTS: stm32: add stm32f746-disco device tree files
ARM: stm32: cleanup stm32f7 files
net: stm32: add designware mac glue code for stm32
net: phy: add SMSC LAN8742 phy
ARM: stm32: enable support for smsc phy on stm32f746-disco board
ARM: SPI: stm32: add stm32f746 qspi driver
SPI: add missing flag to micron/stm N25Q128 flash chips
arch/arm/dts/Makefile | 2 + arch/arm/dts/armv7-m.dtsi | 24 + arch/arm/dts/stm32f746-disco.dts | 154 +++ arch/arm/dts/stm32f746.dtsi | 397 +++++++ arch/arm/include/asm/arch-stm32f4/stm32.h | 2 +- arch/arm/include/asm/arch-stm32f7/fmc.h | 7 +- arch/arm/include/asm/arch-stm32f7/gpt.h | 9 +- arch/arm/include/asm/arch-stm32f7/rcc.h | 64 -- arch/arm/include/asm/arch-stm32f7/stm32.h | 119 +- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 10 +- arch/arm/include/asm/arch-stm32f7/syscfg.h | 38 + arch/arm/mach-stm32/stm32f7/clock.c | 236 ++-- arch/arm/mach-stm32/stm32f7/timer.c | 4 +- board/st/stm32f746-disco/stm32f746-disco.c | 126 +- configs/stm32f746-disco_defconfig | 23 +- drivers/mtd/spi/sf_params.c | 4 +- drivers/mtd/stm32_flash.c | 2 +- drivers/net/designware.c | 1 + drivers/net/phy/smsc.c | 12 + drivers/serial/serial_stm32x7.c | 4 +- drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/stm32_qspi.c | 628 ++++++++++ include/configs/stm32f746-disco.h | 10 +- include/dt-bindings/pinctrl/stm32f746-pinfunc.h | 1324 ++++++++++++++++++++++ 25 files changed, 2954 insertions(+), 255 deletions(-) create mode 100644 arch/arm/dts/armv7-m.dtsi create mode 100644 arch/arm/dts/stm32f746-disco.dts create mode 100644 arch/arm/dts/stm32f746.dtsi delete mode 100644 arch/arm/include/asm/arch-stm32f7/rcc.h create mode 100644 arch/arm/include/asm/arch-stm32f7/syscfg.h create mode 100644 drivers/spi/stm32_qspi.c create mode 100644 include/dt-bindings/pinctrl/stm32f746-pinfunc.h
Signature · 1 line
2.1.4
PATCH v2 1/7 ARM: DTS: stm32: add stm32f746-disco device tree files
This patch adds the DTS source files needed for stm32f746-disco board based on the stm32f429/469 files from current linux kernel.
---
Changes in v2: None
arch/arm/dts/Makefile | 2 + arch/arm/dts/armv7-m.dtsi | 24 + arch/arm/dts/stm32f746-disco.dts | 154 +++ arch/arm/dts/stm32f746.dtsi | 397 +++++++ configs/stm32f746-disco_defconfig | 1 + include/dt-bindings/pinctrl/stm32f746-pinfunc.h | 1324 +++++++++++++++++++++++ 6 files changed, 1902 insertions(+) create mode 100644 arch/arm/dts/armv7-m.dtsi create mode 100644 arch/arm/dts/stm32f746-disco.dts create mode 100644 arch/arm/dts/stm32f746.dtsi create mode 100644 include/dt-bindings/pinctrl/stm32f746-pinfunc.h
arch/arm/dts/Makefile +2 -0
@@ -155,6 +155,8 @@ dtb-$(CONFIG_FSL_LSCH2) += fsl-ls1043a-qds-duart.dtb \ dtb-$(CONFIG_ARCH_SNAPDRAGON) += dragonboard410c.dtb +dtb-$(CONFIG_STM32F7) += stm32f746-disco.dtb + dtb-$(CONFIG_MACH_SUN4I) += \ sun4i-a10-a1000.dtb \ sun4i-a10-ba10-tvbox.dtb \
arch/arm/dts/armv7-m.dtsi new file +24 -0
@@ -0,0 +1,24 @@ +#include "skeleton.dtsi" + +/ { + nvic: interrupt-controller at e000e100 { + compatible = "arm,armv7m-nvic"; + interrupt-controller; + #interrupt-cells = <1>; + reg = <0xe000e100 0xc00>; + }; + + systick: timer at e000e010 { + compatible = "arm,armv7m-systick"; + reg = <0xe000e010 0x10>; + status = "disabled"; + }; + + soc { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + interrupt-parent = <&nvic>; + ranges; + }; +};
arch/arm/dts/stm32f746-disco.dts new file +154 -0
154 lines not on this page · raw message
arch/arm/dts/stm32f746.dtsi new file +397 -0
397 lines not on this page · raw message
configs/stm32f746-disco_defconfig +1 -0
@@ -2,6 +2,7 @@ CONFIG_ARM=y CONFIG_STM32=y CONFIG_STM32F7=y CONFIG_TARGET_STM32F746_DISCO=y +CONFIG_DEFAULT_DEVICE_TREE="stm32f746-disco" CONFIG_BOOTDELAY=3 # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set
include/dt-bindings/pinctrl/stm32f746-pinfunc.h new file +1324 -0
1,324 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 1/7 ARM: DTS: stm32: add stm32f746-disco device tree files
Hi Michael,
Quoted 35 lines
-----Original Message-----
From: Michael Kurz [mailto:michi.kurz at gmail.com]
Sent: Friday, November 04, 2016 12:21 PM
To: u-boot at lists.denx.de
Cc: Michael Kurz <[email protected]>; Heiko Schocher <[email protected]>; Simon Glass <[email protected]>; Masahiro Yamada <[email protected]>; York Sun <[email protected]>; Lokesh Vutla <[email protected]>; Ian Campbell <[email protected]>; Hans de Goede <[email protected]>; Albert Aribaud <[email protected]>; Vikas MANOCHA <[email protected]>; Stefan Roese <[email protected]>; Prabhakar Kushwaha <[email protected]>
Subject: [PATCH v2 1/7] ARM: DTS: stm32: add stm32f746-disco device tree filesThis patch adds the DTS source files needed for stm32f746-disco board based on the stm32f429/469 files from current linux kernel.
Signed-off-by Michael Kurz <[email protected]>---
Changes in v2: None
arch/arm/dts/Makefile | 2 + arch/arm/dts/armv7-m.dtsi | 24 + arch/arm/dts/stm32f746-disco.dts | 154 +++ arch/arm/dts/stm32f746.dtsi | 397 +++++++ configs/stm32f746-disco_defconfig | 1 + include/dt-bindings/pinctrl/stm32f746-pinfunc.h | 1324 +++++++++++++++++++++++ 6 files changed, 1902 insertions(+) create mode 100644 arch/arm/dts/armv7-m.dtsi create mode 100644 arch/arm/dts/stm32f746-disco.dts create mode 100644 arch/arm/dts/stm32f746.dtsi create mode 100644 include/dt-bindings/pinctrl/stm32f746-pinfunc.harch/arm/dts/Makefile +0
-0@@ -155,6 +155,8 @@ dtb-$(CONFIG_FSL_LSCH2) += fsl-ls1043a-qds-duart.dtb \
[...]
include/dt-bindings/pinctrl/stm32f746-pinfunc.h
Quoted 10 lines
arch/arm/dts/Makefile +1
-0+CONFIG_DEFAULT_DEVICE_TREE="stm32f746-disco" CONFIG_BOOTDELAY=3 # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not setinclude/dt-bindings/pinctrl/stm32f746-pinfunc.h new file +0
-0@@ -0,0 +1,1324 @@
Split pin control in separate patch.
Otherwise,
include/dt-bindings/pinctrl/stm32f746-pinfunc.h line 5
Quoted 5 lines
include/dt-bindings/pinctrl/stm32f746-pinfunc.h new file +5
-0+#ifndef _DT_BINDINGS_STM32F746_PINFUNC_H +#define _DT_BINDINGS_STM32F746_PINFUNC_H + +#define STM32F746_PA0_FUNC_GPIO 0x0 +#define STM32F746_PA0_FUNC_TIM2_CH1_TIM2_ETR 0x2
[...]
Cheers,
Vikas
PATCH v2 2/7 ARM: stm32: cleanup stm32f7 files
In reply to Michael KurzCleanup stm32f7 files:
- use BIT macro
- use GENMASK macro
- prefix all constants with STM32_
- remove double constants
---
Changes in v2:
- add cleanup patch
arch/arm/include/asm/arch-stm32f4/stm32.h | 2 +- arch/arm/include/asm/arch-stm32f7/fmc.h | 7 +- arch/arm/include/asm/arch-stm32f7/gpt.h | 9 +- arch/arm/include/asm/arch-stm32f7/rcc.h | 64 ------- arch/arm/include/asm/arch-stm32f7/stm32.h | 119 +++++------- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 3 + arch/arm/mach-stm32/stm32f7/clock.c | 227 ++++++++++++++--------- arch/arm/mach-stm32/stm32f7/timer.c | 4 +- board/st/stm32f746-disco/stm32f746-disco.c | 10 +- drivers/mtd/stm32_flash.c | 2 +- drivers/serial/serial_stm32x7.c | 4 +- 11 files changed, 203 insertions(+), 248 deletions(-) delete mode 100644 arch/arm/include/asm/arch-stm32f7/rcc.h
arch/arm/include/asm/arch-stm32f4/stm32.h +1 -1
@@ -102,7 +102,7 @@ struct stm32_pwr_regs {#define STM32_USART3_BASE (STM32_APB1PERIPH_BASE + 0x4800)#define STM32_USART6_BASE (STM32_APB2PERIPH_BASE + 0x1400) -#define FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00) +#define STM32_FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00)static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT ] = { [0 ...3 ] =16 *1024 ,
arch/arm/include/asm/arch-stm32f7/fmc.h +3 -4
@@ -24,7 +24,6 @@ struct stm32_fmc_regs {/* * FMC registers base */ -#define STM32_SDRAM_FMC_BASE 0xA0000140#define STM32_SDRAM_FMC ((struct stm32_fmc_regs *)STM32_SDRAM_FMC_BASE)/* Control register SDCR */
@@ -58,12 +57,12 @@ struct stm32_fmc_regs {#define FMC_SDCMR_MODE_SELFREFRESH 5#define FMC_SDCMR_MODE_POWERDOWN 6 -#define FMC_SDCMR_BANK_1 (1 << 4) -#define FMC_SDCMR_BANK_2 (1 << 3) +#define FMC_SDCMR_BANK_1 BIT(4) +#define FMC_SDCMR_BANK_2 BIT(3)#define FMC_SDCMR_MODE_REGISTER_SHIFT 9 -#define FMC_SDSR_BUSY (1 << 5) +#define FMC_SDSR_BUSY BIT(5)#define FMC_BUSY_WAIT () do { \ __asm__ __volatile__ ("dsb" : : : "memory"); \
arch/arm/include/asm/arch-stm32f7/gpt.h +4 -5
@@ -34,12 +34,11 @@ struct gpt_regs {u32 tim2_5_or; }; -struct gpt_regs *const gpt1_regs_ptr = - (struct gpt_regs *)TIM2_BASE ; +struct gpt_regs *const gpt1_regs_ptr = (struct gpt_regs *)STM32_TIM2_BASE ;/* Timer control1 register */ -#define GPT_CR1_CEN 0x0001 -#define GPT_MODE_AUTO_RELOAD (1 << 7) +#define GPT_CR1_CEN BIT(0) +#define GPT_MODE_AUTO_RELOAD BIT(7)/* Auto reload register for free running config */ #define GPT_FREE_RUNNING 0xFFFFFFFF
@@ -48,6 +47,6 @@ struct gpt_regs *const gpt1_regs_ptr =#define CONFIG_STM32_HZ 1000/* Timer Event Generation registers */ -#define TIM_EGR_UG (1 << 0) +#define TIM_EGR_UG BIT(0)#endif
arch/arm/include/asm/arch-stm32f7/rcc.h deleted +0 -64
64 lines not on this page · raw message
arch/arm/include/asm/arch-stm32f7/stm32.h +42 -77
138 lines not on this page · raw message
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +3 -0
@@ -33,6 +33,9 @@ enum periph_clock {GPIO_I_CLOCK_CFG ,GPIO_J_CLOCK_CFG ,GPIO_K_CLOCK_CFG , +SYSCFG_CLOCK_CFG , +TIMER2_CLOCK_CFG , + FMC_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */
arch/arm/mach-stm32/stm32f7/clock.c +143 -84
284 lines not on this page · raw message
arch/arm/mach-stm32/stm32f7/timer.c +2 -2
@@ -8,8 +8,8 @@#include <common.h> #include <asm/io.h> #include <asm/arch/stm32.h> +#include <asm/arch/stm32_defs.h> #include <asm/arch/gpt.h> -#include <asm/arch/rcc.h> #define READ_TIMER () (readl(&gpt1_regs_ptr->cnt) & GPT_FREE_RUNNING)#define GPT_RESOLUTION (CONFIG_SYS_HZ_CLOCK/CONFIG_STM32_HZ)
@@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;int timer_init (void ) {/* Timer2 clock configuration */ -setbits_le32 (RCC_BASE +RCC_APB1ENR ,RCC_APB1ENR_TIM2EN ); +clock_setup (TIMER2_CLOCK_CFG );/* Stop the timer */ writel (readl (&gpt1_regs_ptr->cr1) & ~GPT_CR1_CEN , &gpt1_regs_ptr->cr1);
board/st/stm32f746-disco/stm32f746-disco.c +2 -8
@@ -10,7 +10,6 @@#include <asm/armv7m.h> #include <asm/arch/stm32.h> #include <asm/arch/gpio.h> -#include <asm/arch/rcc.h> #include <asm/arch/fmc.h> #include <dm/platdata.h> #include <dm/platform_data/serial_stm32x7.h>
@@ -114,11 +113,6 @@ out:return rv; } -/* -* STM32 RCC FMC specific definitions -*/ -#define RCC_ENR_FMC (1 << 0)/* FMC module clock */ -static inline u32 _ns2clk (u32 ns,u32 freq) {u32 tmp = freq/1000000 ;
@@ -176,7 +170,7 @@ int dram_init(void)if (rv)return rv; -setbits_le32 (RCC_BASE +RCC_AHB3ENR ,RCC_ENR_FMC ); +clock_setup (FMC_CLOCK_CFG );/* * Get frequency for NS2CLK calculation.
@@ -273,7 +267,7 @@ out: }static const struct stm32x7_serial_platdata serial_platdata = { - .base = (struct stm32_usart *)USART1_BASE , + .base = (struct stm32_usart *)STM32_USART1_BASE , .clock =CONFIG_SYS_CLK_FREQ , };
drivers/mtd/stm32_flash.c +1 -1
@@ -12,7 +12,7 @@flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS ]; -#define STM32_FLASH ((struct stm32_flash_regs *)FLASH_CNTL_BASE) +#define STM32_FLASH ((struct stm32_flash_regs *)STM32_FLASH_CNTL_BASE)void stm32_flash_latency_cfg (int latency) {
drivers/serial/serial_stm32x7.c +2 -2
@@ -21,9 +21,9 @@ static int stm32_serial_setbrg(struct udevice *dev, int baudrate)struct stm32_usart *const usart = plat->base;u32 clock, int_div, frac_div, tmp; -if (((u32 )usart &STM32_BUS_MASK ) ==APB1_PERIPH_BASE ) +if (((u32 )usart &STM32_BUS_MASK ) ==STM32_APB1_PERIPH_BASE ) clock =clock_get (CLOCK_APB1 ); -else if (((u32 )usart &STM32_BUS_MASK ) ==APB2_PERIPH_BASE ) +else if (((u32 )usart &STM32_BUS_MASK ) ==STM32_APB2_PERIPH_BASE ) clock =clock_get (CLOCK_APB2 );else return -EINVAL ;
Signature · 1 line
2.1.4
PATCH v2 2/7 ARM: stm32: cleanup stm32f7 files
Hi Michael,
Quoted 9 lines
-----Original Message-----
From: Michael Kurz [mailto:michi.kurz at gmail.com]
Sent: Friday, November 04, 2016 12:21 PM
To: u-boot at lists.denx.de
Cc: Michael Kurz <[email protected]>; Kamil Lulko <[email protected]>; Toshifumi NISHINAGA <[email protected]>; Vadzim Dambrouski <[email protected]>; Albert Aribaud <[email protected]>; Vikas MANOCHA <[email protected]>; Simon Glass <[email protected]>
Subject: [PATCH v2 2/7] ARM: stm32: cleanup stm32f7 files
Quoted 4 lines
Cleanup stm32f7 files:
- use BIT macro
- use GENMASK macro
- prefix all constants withSTM32_
Adding no value to add this prefix.
Quoted 35 lines
- remove double constants
Signed-off-by Michael Kurz <[email protected]>---
Changes in v2:
- add cleanup patcharch/arm/include/asm/arch-stm32f4/stm32.h | 2 +- arch/arm/include/asm/arch-stm32f7/fmc.h | 7 +- arch/arm/include/asm/arch-stm32f7/gpt.h | 9 +- arch/arm/include/asm/arch-stm32f7/rcc.h | 64 ------- arch/arm/include/asm/arch-stm32f7/stm32.h | 119 +++++------- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 3 + arch/arm/mach-stm32/stm32f7/clock.c | 227 ++++++++++++++--------- arch/arm/mach-stm32/stm32f7/timer.c | 4 +- board/st/stm32f746-disco/stm32f746-disco.c | 10 +- drivers/mtd/stm32_flash.c | 2 +- drivers/serial/serial_stm32x7.c | 4 +- 11 files changed, 203 insertions(+), 248 deletions(-) delete mode 100644 arch/arm/include/asm/arch-stm32f7/rcc.harch/arm/include/asm/arch-stm32f4/stm32.h +1
-1@@ -102,7 +102,7 @@ struct stm32_pwr_regs {#define STM32_USART3_BASE (STM32_APB1PERIPH_BASE + 0x4800)#define STM32_USART6_BASE (STM32_APB2PERIPH_BASE + 0x1400) -#define FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00) +#define STM32_FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00)static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT ] = { [0 ...3 ] =16 *1024 ,
[...]
arch/arm/include/asm/arch-stm32f4/stm32.h
Quoted 4 lines
arch/arm/include/asm/arch-stm32f4/stm32.h +0
-4-#define RCC_ENR_GPIO_J_EN (1 << 9) -#define RCC_ENR_GPIO_K_EN (1 << 10) - -#endif
Not a good design to delete the reset and clock related stuff contained in one header and moving it to source file/stm32.c
Quoted 149 lines
arch/arm/include/asm/arch-stm32f7/stm32.h +42
-77@@ -9,46 +9,47 @@#define _ASM_ARCH_HARDWARE_H/* STM32F746 */ -#define ITCM_FLASH_BASE 0x00200000UL -#define AXIM_FLASH_BASE 0x08000000UL +#define STM32_ITCM_FLASH_BASE 0x00200000UL +#define STM32_AXIM_FLASH_BASE 0x08000000UL + +#define STM32_ITCM_SRAM_BASE 0x00000000UL +#define STM32_DTCM_SRAM_BASE 0x20000000UL +#define STM32_SRAM1_BASE 0x20010000UL +#define STM32_SRAM2_BASE 0x2004C000UL + +#define STM32_PERIPH_BASE 0x40000000UL + +#define STM32_APB1_PERIPH_BASE (STM32_PERIPH_BASE + 0x00000000) +#define STM32_APB2_PERIPH_BASE (STM32_PERIPH_BASE + 0x00010000) +#define STM32_AHB1_PERIPH_BASE (STM32_PERIPH_BASE + 0x00020000) +#define STM32_AHB2_PERIPH_BASE (STM32_PERIPH_BASE + 0x10000000) +#define STM32_AHB3_PERIPH_BASE (STM32_PERIPH_BASE + 0x20000000) + +#define STM32_TIM2_BASE (STM32_APB1_PERIPH_BASE + 0x0000) +#define STM32_USART2_BASE (STM32_APB1_PERIPH_BASE + 0x4400) +#define STM32_USART3_BASE (STM32_APB1_PERIPH_BASE + 0x4800) +#define STM32_PWR_BASE (STM32_APB1_PERIPH_BASE + 0x7000) + +#define STM32_USART1_BASE (STM32_APB2_PERIPH_BASE + 0x1000) +#define STM32_USART6_BASE (STM32_APB2_PERIPH_BASE + 0x1400) +#define STM32_SYSCFG_BASE (STM32_APB2_PERIPH_BASE + 0x3800) + +#define STM32_GPIOA_BASE (STM32_AHB1_PERIPH_BASE + 0x0000) +#define STM32_GPIOB_BASE (STM32_AHB1_PERIPH_BASE + 0x0400) +#define STM32_GPIOC_BASE (STM32_AHB1_PERIPH_BASE + 0x0800) +#define STM32_GPIOD_BASE (STM32_AHB1_PERIPH_BASE + 0x0C00) +#define STM32_GPIOE_BASE (STM32_AHB1_PERIPH_BASE + 0x1000) +#define STM32_GPIOF_BASE (STM32_AHB1_PERIPH_BASE + 0x1400) +#define STM32_GPIOG_BASE (STM32_AHB1_PERIPH_BASE + 0x1800) +#define STM32_GPIOH_BASE (STM32_AHB1_PERIPH_BASE + 0x1C00) +#define STM32_GPIOI_BASE (STM32_AHB1_PERIPH_BASE + 0x2000) +#define STM32_GPIOJ_BASE (STM32_AHB1_PERIPH_BASE + 0x2400) +#define STM32_GPIOK_BASE (STM32_AHB1_PERIPH_BASE + 0x2800) +#define STM32_RCC_BASE (STM32_AHB1_PERIPH_BASE + 0x3800) +#define STM32_FLASH_CNTL_BASE (STM32_AHB1_PERIPH_BASE + 0x3C00) + +#define STM32_SDRAM_FMC_BASE (STM32_AHB3_PERIPH_BASE + 0x40000140) -#define ITCM_SRAM_BASE 0x00000000UL -#define DTCM_SRAM_BASE 0x20000000UL -#define SRAM1_BASE 0x20010000UL -#define SRAM2_BASE 0x2004C000UL - -#define PERIPH_BASE 0x40000000UL - -#define APB1_PERIPH_BASE (PERIPH_BASE + 0x00000000) -#define APB2_PERIPH_BASE (PERIPH_BASE + 0x00010000) -#define AHB1_PERIPH_BASE (PERIPH_BASE + 0x00020000) -#define AHB2_PERIPH_BASE (PERIPH_BASE + 0x10000000) -#define AHB3_PERIPH_BASE (PERIPH_BASE + 0x20000000) - -#define TIM2_BASE (APB1_PERIPH_BASE + 0x0000) -#define USART2_BASE (APB1_PERIPH_BASE + 0x4400) -#define USART3_BASE (APB1_PERIPH_BASE + 0x4800) -#define PWR_BASE (APB1_PERIPH_BASE + 0x7000) - -#define USART1_BASE (APB2_PERIPH_BASE + 0x1000) -#define USART6_BASE (APB2_PERIPH_BASE + 0x1400) - -#define STM32_GPIOA_BASE (AHB1_PERIPH_BASE + 0x0000) -#define STM32_GPIOB_BASE (AHB1_PERIPH_BASE + 0x0400) -#define STM32_GPIOC_BASE (AHB1_PERIPH_BASE + 0x0800) -#define STM32_GPIOD_BASE (AHB1_PERIPH_BASE + 0x0C00) -#define STM32_GPIOE_BASE (AHB1_PERIPH_BASE + 0x1000) -#define STM32_GPIOF_BASE (AHB1_PERIPH_BASE + 0x1400) -#define STM32_GPIOG_BASE (AHB1_PERIPH_BASE + 0x1800) -#define STM32_GPIOH_BASE (AHB1_PERIPH_BASE + 0x1C00) -#define STM32_GPIOI_BASE (AHB1_PERIPH_BASE + 0x2000) -#define STM32_GPIOJ_BASE (AHB1_PERIPH_BASE + 0x2400) -#define STM32_GPIOK_BASE (AHB1_PERIPH_BASE + 0x2800) -#define RCC_BASE (AHB1_PERIPH_BASE + 0x3800) -#define FLASH_CNTL_BASE (AHB1_PERIPH_BASE + 0x3C00) - - -#define SDRAM_FMC_BASE (AHB3_PERIPH_BASE + 0x4A0000140)static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT ] = { [0 ...3 ] =32 *1024 ,@@ -62,43 +63,7 @@ enum clock { CLOCK_APB1,CLOCK_APB2 }; -#define STM32_BUS_MASK 0xFFFF0000 - -struct stm32_rcc_regs { -u32 cr;/* RCC clock control */ -u32 pllcfgr;/* RCC PLL configuration */ -u32 cfgr;/* RCC clock configuration */ -u32 cir;/* RCC clock interrupt */ -u32 ahb1rstr;/* RCC AHB1 peripheral reset */ -u32 ahb2rstr;/* RCC AHB2 peripheral reset */ -u32 ahb3rstr;/* RCC AHB3 peripheral reset */ -u32 rsv0; -u32 apb1rstr;/* RCC APB1 peripheral reset */ -u32 apb2rstr;/* RCC APB2 peripheral reset */ -u32 rsv1[2 ]; -u32 ahb1enr;/* RCC AHB1 peripheral clock enable */ -u32 ahb2enr;/* RCC AHB2 peripheral clock enable */ -u32 ahb3enr;/* RCC AHB3 peripheral clock enable */ -u32 rsv2; -u32 apb1enr;/* RCC APB1 peripheral clock enable */ -u32 apb2enr;/* RCC APB2 peripheral clock enable */ -u32 rsv3[2 ]; -u32 ahb1lpenr;/* RCC AHB1 periph clk enable in low pwr mode */ -u32 ahb2lpenr;/* RCC AHB2 periph clk enable in low pwr mode */ -u32 ahb3lpenr;/* RCC AHB3 periph clk enable in low pwr mode */ -u32 rsv4; -u32 apb1lpenr;/* RCC APB1 periph clk enable in low pwr mode */ -u32 apb2lpenr;/* RCC APB2 periph clk enable in low pwr mode */ -u32 rsv5[2 ]; -u32 bdcr;/* RCC Backup domain control */ -u32 csr;/* RCC clock control & status */ -u32 rsv6[2 ]; -u32 sscgr;/* RCC spread spectrum clock generation */ -u32 plli2scfgr;/* RCC PLLI2S configuration */ -u32 pllsaicfgr; -u32 dckcfgr; -}; -#define STM32_RCC ((struct stm32_rcc_regs *)RCC_BASE) +#define STM32_BUS_MASK GENMASK(31, 16)struct stm32_pwr_regs {u32 cr1;/* power control register 1 */ @@ -106,7 +71,7 @@ struct stm32_pwr_regs {u32 cr2;/* power control register 2 */ u32 csr2;/* power control/status register 2 */ }; -#define STM32_PWR ((struct stm32_pwr_regs *)PWR_BASE) +#define STM32_PWR ((struct stm32_pwr_regs *)STM32_PWR_BASE)int configure_clocks (void ); unsigned long clock_get(enum clock clck); diff --git a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
b/arch/arm/include/asm/arch-stm32f7/stm32_periph.hindex 38adc4e..9b315a8 100644
arch/arm/include/asm/arch-stm32f7/stm32_periph.h enum periph_clock { · line 38
Quoted 6 lines
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +3
-0@@ -33,6 +33,9 @@ enum periph_clock {GPIO_I_CLOCK_CFG ,GPIO_J_CLOCK_CFG ,GPIO_K_CLOCK_CFG , +SYSCFG_CLOCK_CFG , +TIMER2_CLOCK_CFG , + FMC_CLOCK_CFG,
should be in separate patch.
Quoted 47 lines
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0
-0};#endif /* __ASM_ARM_ARCH_PERIPH_H */ arch/arm/mach-stm32/stm32f7/clock.c +25
-8@@ -7,80 +7,130 @@#include <common.h> #include <asm/io.h> -#include <asm/arch/rcc.h> #include <asm/arch/stm32.h> #include <asm/arch/stm32_periph.h> -#define RCC_CR_HSION (1 << 0) -#define RCC_CR_HSEON (1 << 16) -#define RCC_CR_HSERDY (1 << 17) -#define RCC_CR_HSEBYP (1 << 18) -#define RCC_CR_CSSON (1 << 19) -#define RCC_CR_PLLON (1 << 24) -#define RCC_CR_PLLRDY (1 << 25) +struct stm32_rcc_regs { +u32 cr;/* RCC clock control */ +u32 pllcfgr;/* RCC PLL configuration */ +u32 cfgr;/* RCC clock configuration */ +u32 cir;/* RCC clock interrupt */ +u32 ahb1rstr;/* RCC AHB1 peripheral reset */ +u32 ahb2rstr;/* RCC AHB2 peripheral reset */ +u32 ahb3rstr;/* RCC AHB3 peripheral reset */ +u32 rsv0; +u32 apb1rstr;/* RCC APB1 peripheral reset */ +u32 apb2rstr;/* RCC APB2 peripheral reset */ +u32 rsv1[2 ]; +u32 ahb1enr;/* RCC AHB1 peripheral clock enable */ +u32 ahb2enr;/* RCC AHB2 peripheral clock enable */ +u32 ahb3enr;/* RCC AHB3 peripheral clock enable */ +u32 rsv2; +u32 apb1enr;/* RCC APB1 peripheral clock enable */ +u32 apb2enr;/* RCC APB2 peripheral clock enable */ +u32 rsv3[2 ]; +u32 ahb1lpenr;/* RCC AHB1 periph clk enable in low pwr mode */ +u32 ahb2lpenr;/* RCC AHB2 periph clk enable in low pwr mode */ +u32 ahb3lpenr;/* RCC AHB3 periph clk enable in low pwr mode */ +u32 rsv4; +u32 apb1lpenr;/* RCC APB1 periph clk enable in low pwr mode */ +u32 apb2lpenr;/* RCC APB2 periph clk enable in low pwr mode */
arch/arm/mach-stm32/stm32f7/clock.c line 47
Quoted 10 lines
arch/arm/mach-stm32/stm32f7/clock.c +10
-0+u32 rsv5[2 ]; +u32 bdcr;/* RCC Backup domain control */ +u32 csr;/* RCC clock control & status */ +u32 rsv6[2 ]; +u32 sscgr;/* RCC spread spectrum clock generation */ +u32 plli2scfgr;/* RCC PLLI2S configuration */ +u32 pllsaicfgr;/* PLLSAI configuration */ +u32 dckcfgr1;/* dedicated clocks configuration register 1 */ +u32 dckcfgr2;/* dedicated clocks configuration register 2 */ +};
Don't think its again good idea to move rcc struct from header to source.
arch/arm/mach-stm32/stm32f7/clock.c line 26
Quoted 7 lines
arch/arm/mach-stm32/stm32f7/clock.c +1
-5+#define STM32_RCC ((struct stm32_rcc_regs *)STM32_RCC_BASE) -#define RCC_PLLCFGR_PLLM_MASK 0x3F -#define RCC_PLLCFGR_PLLN_MASK 0x7FC0 -#define RCC_PLLCFGR_PLLP_MASK 0x30000 -#define RCC_PLLCFGR_PLLQ_MASK 0xF000000 -#define RCC_PLLCFGR_PLLSRC (1 << 22)
[...]
Cheers,
Vikas
PATCH v2 2/7 ARM: stm32: cleanup stm32f7 files
On Thu, 24 Nov 2016, Vikas MANOCHA wrote:
Hi Vikas,
Quoted 11 lines
Hi Michael,
Quoted 9 lines
-----Original Message-----
From: Michael Kurz [mailto:michi.kurz at gmail.com]
Sent: Friday, November 04, 2016 12:21 PM
To: u-boot at lists.denx.de
Cc: Michael Kurz <[email protected]>; Kamil Lulko <[email protected]>; Toshifumi NISHINAGA <[email protected]>; Vadzim Dambrouski <[email protected]>; Albert Aribaud <[email protected]>; Vikas MANOCHA <[email protected]>; Simon Glass <[email protected]>
Subject: [PATCH v2 2/7] ARM: stm32: cleanup stm32f7 files
Quoted 7 lines
Quoted 4 lines
Cleanup stm32f7 files:
- use BIT macro
- use GENMASK macro
- prefix all constants withSTM32_Adding no value to add this prefix.
I see your point. I'll remove it in v3.
Quoted 38 lines
Quoted 35 lines
- remove double constants
Signed-off-by Michael Kurz <[email protected]>---
Changes in v2:
- add cleanup patcharch/arm/include/asm/arch-stm32f4/stm32.h | 2 +- arch/arm/include/asm/arch-stm32f7/fmc.h | 7 +- arch/arm/include/asm/arch-stm32f7/gpt.h | 9 +- arch/arm/include/asm/arch-stm32f7/rcc.h | 64 ------- arch/arm/include/asm/arch-stm32f7/stm32.h | 119 +++++------- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 3 + arch/arm/mach-stm32/stm32f7/clock.c | 227 ++++++++++++++--------- arch/arm/mach-stm32/stm32f7/timer.c | 4 +- board/st/stm32f746-disco/stm32f746-disco.c | 10 +- drivers/mtd/stm32_flash.c | 2 +- drivers/serial/serial_stm32x7.c | 4 +- 11 files changed, 203 insertions(+), 248 deletions(-) delete mode 100644 arch/arm/include/asm/arch-stm32f7/rcc.harch/arm/include/asm/arch-stm32f4/stm32.h +1
-1@@ -102,7 +102,7 @@ struct stm32_pwr_regs {#define STM32_USART3_BASE (STM32_APB1PERIPH_BASE + 0x4800)#define STM32_USART6_BASE (STM32_APB2PERIPH_BASE + 0x1400) -#define FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00) +#define STM32_FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00)static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT ] = { [0 ...3 ] =16 *1024 ,[...]
Quoted 7 lines
arch/arm/include/asm/arch-stm32f4/stm32.h
Quoted 4 lines
arch/arm/include/asm/arch-stm32f4/stm32.h +0
-4-#define RCC_ENR_GPIO_J_EN (1 << 9) -#define RCC_ENR_GPIO_K_EN (1 << 10) - -#endif Not a good design to delete the reset and clock related stuff contained in one header and moving it to source
file/stm32.c
I thought I read somewhere in the docs to only add a header file when needed. As the rcc.h header file was only included in the clock.c file I thought it would be the right thing to move it into the source file. I agree to keep it though.
Quoted 142 lines
Quoted 142 lines
arch/arm/include/asm/arch-stm32f7/stm32.h +42
-77@@ -9,46 +9,47 @@#define _ASM_ARCH_HARDWARE_H/* STM32F746 */ -#define ITCM_FLASH_BASE 0x00200000UL -#define AXIM_FLASH_BASE 0x08000000UL +#define STM32_ITCM_FLASH_BASE 0x00200000UL +#define STM32_AXIM_FLASH_BASE 0x08000000UL + +#define STM32_ITCM_SRAM_BASE 0x00000000UL +#define STM32_DTCM_SRAM_BASE 0x20000000UL +#define STM32_SRAM1_BASE 0x20010000UL +#define STM32_SRAM2_BASE 0x2004C000UL + +#define STM32_PERIPH_BASE 0x40000000UL + +#define STM32_APB1_PERIPH_BASE (STM32_PERIPH_BASE + 0x00000000) +#define STM32_APB2_PERIPH_BASE (STM32_PERIPH_BASE + 0x00010000) +#define STM32_AHB1_PERIPH_BASE (STM32_PERIPH_BASE + 0x00020000) +#define STM32_AHB2_PERIPH_BASE (STM32_PERIPH_BASE + 0x10000000) +#define STM32_AHB3_PERIPH_BASE (STM32_PERIPH_BASE + 0x20000000) + +#define STM32_TIM2_BASE (STM32_APB1_PERIPH_BASE + 0x0000) +#define STM32_USART2_BASE (STM32_APB1_PERIPH_BASE + 0x4400) +#define STM32_USART3_BASE (STM32_APB1_PERIPH_BASE + 0x4800) +#define STM32_PWR_BASE (STM32_APB1_PERIPH_BASE + 0x7000) + +#define STM32_USART1_BASE (STM32_APB2_PERIPH_BASE + 0x1000) +#define STM32_USART6_BASE (STM32_APB2_PERIPH_BASE + 0x1400) +#define STM32_SYSCFG_BASE (STM32_APB2_PERIPH_BASE + 0x3800) + +#define STM32_GPIOA_BASE (STM32_AHB1_PERIPH_BASE + 0x0000) +#define STM32_GPIOB_BASE (STM32_AHB1_PERIPH_BASE + 0x0400) +#define STM32_GPIOC_BASE (STM32_AHB1_PERIPH_BASE + 0x0800) +#define STM32_GPIOD_BASE (STM32_AHB1_PERIPH_BASE + 0x0C00) +#define STM32_GPIOE_BASE (STM32_AHB1_PERIPH_BASE + 0x1000) +#define STM32_GPIOF_BASE (STM32_AHB1_PERIPH_BASE + 0x1400) +#define STM32_GPIOG_BASE (STM32_AHB1_PERIPH_BASE + 0x1800) +#define STM32_GPIOH_BASE (STM32_AHB1_PERIPH_BASE + 0x1C00) +#define STM32_GPIOI_BASE (STM32_AHB1_PERIPH_BASE + 0x2000) +#define STM32_GPIOJ_BASE (STM32_AHB1_PERIPH_BASE + 0x2400) +#define STM32_GPIOK_BASE (STM32_AHB1_PERIPH_BASE + 0x2800) +#define STM32_RCC_BASE (STM32_AHB1_PERIPH_BASE + 0x3800) +#define STM32_FLASH_CNTL_BASE (STM32_AHB1_PERIPH_BASE + 0x3C00) + +#define STM32_SDRAM_FMC_BASE (STM32_AHB3_PERIPH_BASE + 0x40000140) -#define ITCM_SRAM_BASE 0x00000000UL -#define DTCM_SRAM_BASE 0x20000000UL -#define SRAM1_BASE 0x20010000UL -#define SRAM2_BASE 0x2004C000UL - -#define PERIPH_BASE 0x40000000UL - -#define APB1_PERIPH_BASE (PERIPH_BASE + 0x00000000) -#define APB2_PERIPH_BASE (PERIPH_BASE + 0x00010000) -#define AHB1_PERIPH_BASE (PERIPH_BASE + 0x00020000) -#define AHB2_PERIPH_BASE (PERIPH_BASE + 0x10000000) -#define AHB3_PERIPH_BASE (PERIPH_BASE + 0x20000000) - -#define TIM2_BASE (APB1_PERIPH_BASE + 0x0000) -#define USART2_BASE (APB1_PERIPH_BASE + 0x4400) -#define USART3_BASE (APB1_PERIPH_BASE + 0x4800) -#define PWR_BASE (APB1_PERIPH_BASE + 0x7000) - -#define USART1_BASE (APB2_PERIPH_BASE + 0x1000) -#define USART6_BASE (APB2_PERIPH_BASE + 0x1400) - -#define STM32_GPIOA_BASE (AHB1_PERIPH_BASE + 0x0000) -#define STM32_GPIOB_BASE (AHB1_PERIPH_BASE + 0x0400) -#define STM32_GPIOC_BASE (AHB1_PERIPH_BASE + 0x0800) -#define STM32_GPIOD_BASE (AHB1_PERIPH_BASE + 0x0C00) -#define STM32_GPIOE_BASE (AHB1_PERIPH_BASE + 0x1000) -#define STM32_GPIOF_BASE (AHB1_PERIPH_BASE + 0x1400) -#define STM32_GPIOG_BASE (AHB1_PERIPH_BASE + 0x1800) -#define STM32_GPIOH_BASE (AHB1_PERIPH_BASE + 0x1C00) -#define STM32_GPIOI_BASE (AHB1_PERIPH_BASE + 0x2000) -#define STM32_GPIOJ_BASE (AHB1_PERIPH_BASE + 0x2400) -#define STM32_GPIOK_BASE (AHB1_PERIPH_BASE + 0x2800) -#define RCC_BASE (AHB1_PERIPH_BASE + 0x3800) -#define FLASH_CNTL_BASE (AHB1_PERIPH_BASE + 0x3C00) - - -#define SDRAM_FMC_BASE (AHB3_PERIPH_BASE + 0x4A0000140)static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT ] = { [0 ...3 ] =32 *1024 ,@@ -62,43 +63,7 @@ enum clock { CLOCK_APB1,CLOCK_APB2 }; -#define STM32_BUS_MASK 0xFFFF0000 - -struct stm32_rcc_regs { -u32 cr;/* RCC clock control */ -u32 pllcfgr;/* RCC PLL configuration */ -u32 cfgr;/* RCC clock configuration */ -u32 cir;/* RCC clock interrupt */ -u32 ahb1rstr;/* RCC AHB1 peripheral reset */ -u32 ahb2rstr;/* RCC AHB2 peripheral reset */ -u32 ahb3rstr;/* RCC AHB3 peripheral reset */ -u32 rsv0; -u32 apb1rstr;/* RCC APB1 peripheral reset */ -u32 apb2rstr;/* RCC APB2 peripheral reset */ -u32 rsv1[2 ]; -u32 ahb1enr;/* RCC AHB1 peripheral clock enable */ -u32 ahb2enr;/* RCC AHB2 peripheral clock enable */ -u32 ahb3enr;/* RCC AHB3 peripheral clock enable */ -u32 rsv2; -u32 apb1enr;/* RCC APB1 peripheral clock enable */ -u32 apb2enr;/* RCC APB2 peripheral clock enable */ -u32 rsv3[2 ]; -u32 ahb1lpenr;/* RCC AHB1 periph clk enable in low pwr mode */ -u32 ahb2lpenr;/* RCC AHB2 periph clk enable in low pwr mode */ -u32 ahb3lpenr;/* RCC AHB3 periph clk enable in low pwr mode */ -u32 rsv4; -u32 apb1lpenr;/* RCC APB1 periph clk enable in low pwr mode */ -u32 apb2lpenr;/* RCC APB2 periph clk enable in low pwr mode */ -u32 rsv5[2 ]; -u32 bdcr;/* RCC Backup domain control */ -u32 csr;/* RCC clock control & status */ -u32 rsv6[2 ]; -u32 sscgr;/* RCC spread spectrum clock generation */ -u32 plli2scfgr;/* RCC PLLI2S configuration */ -u32 pllsaicfgr; -u32 dckcfgr; -}; -#define STM32_RCC ((struct stm32_rcc_regs *)RCC_BASE) +#define STM32_BUS_MASK GENMASK(31, 16)struct stm32_pwr_regs {u32 cr1;/* power control register 1 */ @@ -106,7 +71,7 @@ struct stm32_pwr_regs {u32 cr2;/* power control register 2 */ u32 csr2;/* power control/status register 2 */ }; -#define STM32_PWR ((struct stm32_pwr_regs *)PWR_BASE) +#define STM32_PWR ((struct stm32_pwr_regs *)STM32_PWR_BASE)
Quoted 16 lines
arch/arm/include/asm/arch-stm32f7/stm32_periph.h enum periph_clock { · line 38
Quoted 13 lines
arch/arm/include/asm/arch-stm32f7/stm32.h +0
-0int configure_clocks (void ); unsigned long clock_get(enum clock clck); diff --git a/arch/arm/include/asm/arch-stm32f7/stm32_periph.h
b/arch/arm/include/asm/arch-stm32f7/stm32_periph.hindex 38adc4e..9b315a8 100644arch/arm/include/asm/arch-stm32f7/stm32_periph.h +3
-0@@ -33,6 +33,9 @@ enum periph_clock {GPIO_I_CLOCK_CFG ,GPIO_J_CLOCK_CFG ,GPIO_K_CLOCK_CFG , +SYSCFG_CLOCK_CFG , +TIMER2_CLOCK_CFG , + FMC_CLOCK_CFG,should be in separate patch.
I split this into a separate patch in v3.
Quoted 51 lines
Quoted 51 lines
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +0
-0};#endif /* __ASM_ARM_ARCH_PERIPH_H */ arch/arm/mach-stm32/stm32f7/clock.c +29
-8@@ -7,80 +7,130 @@#include <common.h> #include <asm/io.h> -#include <asm/arch/rcc.h> #include <asm/arch/stm32.h> #include <asm/arch/stm32_periph.h> -#define RCC_CR_HSION (1 << 0) -#define RCC_CR_HSEON (1 << 16) -#define RCC_CR_HSERDY (1 << 17) -#define RCC_CR_HSEBYP (1 << 18) -#define RCC_CR_CSSON (1 << 19) -#define RCC_CR_PLLON (1 << 24) -#define RCC_CR_PLLRDY (1 << 25) +struct stm32_rcc_regs { +u32 cr;/* RCC clock control */ +u32 pllcfgr;/* RCC PLL configuration */ +u32 cfgr;/* RCC clock configuration */ +u32 cir;/* RCC clock interrupt */ +u32 ahb1rstr;/* RCC AHB1 peripheral reset */ +u32 ahb2rstr;/* RCC AHB2 peripheral reset */ +u32 ahb3rstr;/* RCC AHB3 peripheral reset */ +u32 rsv0; +u32 apb1rstr;/* RCC APB1 peripheral reset */ +u32 apb2rstr;/* RCC APB2 peripheral reset */ +u32 rsv1[2 ]; +u32 ahb1enr;/* RCC AHB1 peripheral clock enable */ +u32 ahb2enr;/* RCC AHB2 peripheral clock enable */ +u32 ahb3enr;/* RCC AHB3 peripheral clock enable */ +u32 rsv2; +u32 apb1enr;/* RCC APB1 peripheral clock enable */ +u32 apb2enr;/* RCC APB2 peripheral clock enable */ +u32 rsv3[2 ]; +u32 ahb1lpenr;/* RCC AHB1 periph clk enable in low pwr mode */ +u32 ahb2lpenr;/* RCC AHB2 periph clk enable in low pwr mode */ +u32 ahb3lpenr;/* RCC AHB3 periph clk enable in low pwr mode */ +u32 rsv4; +u32 apb1lpenr;/* RCC APB1 periph clk enable in low pwr mode */ +u32 apb2lpenr;/* RCC APB2 periph clk enable in low pwr mode */ +u32 rsv5[2 ]; +u32 bdcr;/* RCC Backup domain control */ +u32 csr;/* RCC clock control & status */ +u32 rsv6[2 ];
Quoted 9 lines
arch/arm/mach-stm32/stm32f7/clock.c line 47
Quoted 6 lines
arch/arm/mach-stm32/stm32f7/clock.c +6
-0+u32 sscgr;/* RCC spread spectrum clock generation */ +u32 plli2scfgr;/* RCC PLLI2S configuration */ +u32 pllsaicfgr;/* PLLSAI configuration */ +u32 dckcfgr1;/* dedicated clocks configuration register 1 */ +u32 dckcfgr2;/* dedicated clocks configuration register 2 */ +};Don't think its again good idea to move rcc struct from header to source.
I'll keep it in the header in v3.
Quoted 10 lines
Quoted 7 lines
arch/arm/mach-stm32/stm32f7/clock.c +1
-5+#define STM32_RCC ((struct stm32_rcc_regs *)STM32_RCC_BASE) -#define RCC_PLLCFGR_PLLM_MASK 0x3F -#define RCC_PLLCFGR_PLLN_MASK 0x7FC0 -#define RCC_PLLCFGR_PLLP_MASK 0x30000 -#define RCC_PLLCFGR_PLLQ_MASK 0xF000000 -#define RCC_PLLCFGR_PLLSRC (1 << 22)[...]
Quoted 3 lines
Cheers,
Vikas
Thanks for your comments!
Regards,
Michael
PATCH v2 3/7 net: stm32: add designware mac glue code for stm32
In reply to Michael KurzThis patch adds glue code required for enabling the designware mac on stm32f7 devices.
---
Changes in v2:
- Replaced bit shifts and masks with BIT() and GENMASK() macro
- Moved STM32_SYSCFG_BASE into stm32.h header
arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 1 + arch/arm/include/asm/arch-stm32f7/syscfg.h | 38 ++++++++++++++++ arch/arm/mach-stm32/stm32f7/clock.c | 5 +++ board/st/stm32f746-disco/stm32f746-disco.c | 56 ++++++++++++++++++++++++ configs/stm32f746-disco_defconfig | 15 ++++++- drivers/net/designware.c | 1 + include/configs/stm32f746-disco.h | 9 +++- 7 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arch-stm32f7/syscfg.h
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +1 -0
@@ -36,6 +36,7 @@ enum periph_clock {SYSCFG_CLOCK_CFG ,TIMER2_CLOCK_CFG ,FMC_CLOCK_CFG , + STMMAC_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */
arch/arm/include/asm/arch-stm32f7/syscfg.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* (C) Copyright 2016 +* Michael Kurz, michi.kurz at gmail.com. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _STM32_SYSCFG_H +#define _STM32_SYSCFG_H + +struct stm32_syscfg_regs { +u32 memrmp; +u32 pmc; +u32 exticr1; +u32 exticr2; +u32 exticr3; +u32 exticr4; +u32 cmpcr; +}; + +/* +* SYSCFG registers base +*/ +#define STM32_SYSCFG ((struct stm32_syscfg_regs *)STM32_SYSCFG_BASE) + +/* SYSCFG memory remap register */ +#define SYSCFG_MEMRMP_MEM_BOOT BIT(0) +#define SYSCFG_MEMRMP_SWP_FMC BIT(10) + +/* SYSCFG peripheral mode configuration register */ +#define SYSCFG_PMC_ADCXDC2 BIT(16) +#define SYSCFG_PMC_MII_RMII_SEL BIT(23) + +/* Compensation cell control register */ +#define SYSCFG_CMPCR_CMP_PD BIT(0) +#define SYSCFG_CMPCR_READY BIT(8) + +#endif
arch/arm/mach-stm32/stm32f7/clock.c +5 -0
@@ -337,6 +337,11 @@ void clock_setup(int peripheral)case FMC_CLOCK_CFG :setbits_le32 (&STM32_RCC ->ahb3enr,RCC_AHB3ENR_FMC_EN );break ; +case STMMAC_CLOCK_CFG : +setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_EN ); +setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_RX_EN ); +setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_TX_EN ); +break ;default :break ; }
board/st/stm32f746-disco/stm32f746-disco.c +56 -0
74 lines not on this page · raw message
configs/stm32f746-disco_defconfig +14 -1
@@ -12,7 +12,20 @@ CONFIG_AUTOBOOT_KEYED=y CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n" CONFIG_AUTOBOOT_STOP_STR=" " # CONFIG_CMD_IMLS is not set +# CONFIG_CMD_FPGA is not set # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +CONFIG_CMD_MII=y +CONFIG_CMD_PING=y +CONFIG_CMD_SNTP=y +CONFIG_CMD_DNS=y +CONFIG_CMD_LINK_LOCAL=y CONFIG_CMD_TIMER=y -CONFIG_OF_LIBFDT=y +CONFIG_OF_CONTROL=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_NETCONSOLE=y +CONFIG_DM_ETH=y +CONFIG_ETH_DESIGNWARE=y +# CONFIG_SPL_SERIAL_PRESENT is not set +CONFIG_OF_LIBFDT_OVERLAY=y # CONFIG_EFI_LOADER is not set
drivers/net/designware.c +1 -0
@@ -738,6 +738,7 @@ static const struct udevice_id designware_eth_ids[] = { { .compatible = "allwinner,sun7i-a20-gmac" }, { .compatible = "altr,socfpga-stmmac" }, { .compatible = "amlogic,meson6-dwmac" }, + { .compatible = "st,stm32-dwmac" }, { } };
include/configs/stm32f746-disco.h +7 -2
@@ -42,6 +42,11 @@#define CONFIG_STM32_FLASH #define CONFIG_STM32X7_SERIAL +#define CONFIG_DESIGNWARE_ETH +#define CONFIG_DW_GMAC_DEFAULT_DMA_PBL (8) +#define CONFIG_DW_ALTDESCRIPTOR +#define CONFIG_MII +#define CONFIG_STM32_HSE_HZ 25000000#define CONFIG_SYS_CLK_FREQ 200000000/* 200 MHz */ #define CONFIG_SYS_HZ_CLOCK 1000000/* Timer is clocked@1MHz */
@@ -56,8 +61,8 @@ + sizeof(CONFIG_SYS_PROMPT) + 16)#define CONFIG_SYS_MAXARGS 16 -#define CONFIG_SYS_MALLOC_LEN (16 * 1024) -#define CONFIG_STACKSIZE (64 << 10) +#define CONFIG_SYS_MALLOC_LEN (1 * 1024 * 1024) +#define CONFIG_STACKSIZE (256 * 1024)#define CONFIG_BAUDRATE 115200#define CONFIG_BOOTARGS \
Signature · 1 line
2.1.4
PATCH v2 3/7 net: stm32: add designware mac glue code for stm32
Quoted 4 lines · Michael Kurz
This patch adds glue code required for enabling the designware mac on stm32f7 devices.
Signed-off-by Michael Kurz <[email protected]>
PATCH v2 4/7 net: phy: add SMSC LAN8742 phy
In reply to Michael KurzThis patch adds support for SMSC LAN8742 in phylib
---
Changes in v2:
- Add Acked-by tag to 'net: phy: add SMSC LAN8742 phy'
drivers/net/phy/smsc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/phy/smsc.c +12 -0
@@ -82,12 +82,24 @@ static struct phy_driver lan8740_driver = { .startup = &genphy_startup, .shutdown = &genphy_shutdown, }; + +static struct phy_driver lan8742_driver = { + .name ="SMSC LAN8742" , + .uid =0x0007c130 , + .mask =0xffff0 , + .features =PHY_BASIC_FEATURES , + .config = &genphy_config_aneg, + .startup = &genphy_startup, + .shutdown = &genphy_shutdown, +}; +int phy_smsc_init (void ) {phy_register (&lan8710_driver);phy_register (&lan911x_driver);phy_register (&lan8700_driver);phy_register (&lan8740_driver); +phy_register (&lan8742_driver);return 0 ; }
Signature · 1 line
2.1.4
PATCH v2 5/7 ARM: stm32: enable support for smsc phy on stm32f746-disco board
In reply to Michael KurzThis patch enables support for the smsc phy on the stm32f746-disco board.
---
Changes in v2: None
include/configs/stm32f746-disco.h | 1 + 1 file changed, 1 insertion(+)
include/configs/stm32f746-disco.h +1 -0
@@ -46,6 +46,7 @@#define CONFIG_DW_GMAC_DEFAULT_DMA_PBL (8)#define CONFIG_DW_ALTDESCRIPTOR #define CONFIG_MII +#define CONFIG_PHY_SMSC #define CONFIG_STM32_HSE_HZ 25000000#define CONFIG_SYS_CLK_FREQ 200000000/* 200 MHz */
Signature · 1 line
2.1.4
PATCH v2 5/7 ARM: stm32: enable support for smsc phy on stm32f746-disco board
Hi,
Quoted 30 lines
-----Original Message-----
From: Michael Kurz [mailto:michi.kurz at gmail.com]
Sent: Friday, November 04, 2016 12:21 PM
To: u-boot at lists.denx.de
Cc: Michael Kurz <[email protected]>; Albert Aribaud <[email protected]>; Vikas MANOCHA <[email protected]>
Subject: [PATCH v2 5/7] ARM: stm32: enable support for smsc phy on stm32f746-disco boardThis patch enables support for the smsc phy on the stm32f746-disco board.
Signed-off-by Michael Kurz <[email protected]>---
Changes in v2: None
include/configs/stm32f746-disco.h | 1 + 1 file changed, 1 insertion(+)include/configs/stm32f746-disco.h +1
-1@@ -46,6 +46,7 @@#define CONFIG_DW_GMAC_DEFAULT_DMA_PBL (8)#define CONFIG_DW_ALTDESCRIPTOR #define CONFIG_MII +#define CONFIG_PHY_SMSC #define CONFIG_STM32_HSE_HZ 25000000#define CONFIG_SYS_CLK_FREQ 200000000/* 200 MHz */ --
Quoted 1 line
2.1.4
Cheers,
Vikas
PATCH v2 6/7 ARM: SPI: stm32: add stm32f746 qspi driver
In reply to Michael KurzThis patch adds support for the QSPI IP found in stm32f7 devices.
---
This currently hard disables any multi i/o in the device tree, as it is impossible to get this working without interpreting the commands of the spi-flash framework in the xfer function and setting the used i/o lines accordingly.
As i understand a spi-nor framework is currently in the making which addresses these problems. Should i base this driver on the new framework or is it ok in the current form and should later be ported to the new one?
Changes in v2:
- Replaced bit shifts and masks with BIT() and GENMASK() macro
arch/arm/dts/stm32f746-disco.dts | 4 +- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 6 +- arch/arm/mach-stm32/stm32f7/clock.c | 4 + board/st/stm32f746-disco/stm32f746-disco.c | 60 +++ configs/stm32f746-disco_defconfig | 7 + drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/stm32_qspi.c | 628 +++++++++++++++++++++++ 8 files changed, 714 insertions(+), 4 deletions(-) create mode 100644 drivers/spi/stm32_qspi.c
arch/arm/dts/stm32f746-disco.dts +2 -2
@@ -146,8 +146,8 @@ #size-cells = <1>; compatible = "micron,n25q128a13", "spi-flash"; spi-max-frequency = <108000000>; - spi-tx-bus-width = <4>; - spi-rx-bus-width = <4>; + spi-tx-bus-width = <1>; + spi-rx-bus-width = <1>; memory-map = <0x90000000 0x1000000>; reg = <0>; };
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +4 -2
@@ -15,8 +15,9 @@* */ enum periph_id { -UART1_GPIOA_9_10 =0 , -UART2_GPIOD_5_6 , +PERIPH_ID_USART1 =37 , + +PERIPH_ID_QUADSPI =92 , };enum periph_clock {
@@ -37,6 +38,7 @@ enum periph_clock {TIMER2_CLOCK_CFG ,FMC_CLOCK_CFG ,STMMAC_CLOCK_CFG , + QSPI_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */
arch/arm/mach-stm32/stm32f7/clock.c +4 -0
@@ -71,6 +71,7 @@ struct stm32_rcc_regs {* RCC AHB3ENR specific definitions */ #define RCC_AHB3ENR_FMC_EN BIT(0) +#define RCC_AHB3ENR_QSPI_EN BIT(1)/* * RCC APB1ENR specific definitions
@@ -342,6 +343,9 @@ void clock_setup(int peripheral)setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_RX_EN );setbits_le32 (&STM32_RCC ->ahb1enr,RCC_AHB1ENR_ETHMAC_TX_EN );break ; +case QSPI_CLOCK_CFG : +setbits_le32 (&STM32_RCC ->ahb3enr,RCC_AHB3ENR_QSPI_EN ); +break ;default :break ; }
board/st/stm32f746-disco/stm32f746-disco.c +60 -0
72 lines not on this page · raw message
configs/stm32f746-disco_defconfig +7 -0
@@ -12,6 +12,7 @@ CONFIG_AUTOBOOT_KEYED=y CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n" CONFIG_AUTOBOOT_STOP_STR=" " # CONFIG_CMD_IMLS is not set +CONFIG_CMD_SF=y # CONFIG_CMD_FPGA is not set # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_DHCP=y
@@ -24,8 +25,14 @@ CONFIG_CMD_TIMER=y CONFIG_OF_CONTROL=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y +CONFIG_MTD=y +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_STMICRO=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y # CONFIG_SPL_SERIAL_PRESENT is not set +CONFIG_DM_SPI=y +CONFIG_STM32_QSPI=y CONFIG_OF_LIBFDT_OVERLAY=y # CONFIG_EFI_LOADER is not set
drivers/spi/Kconfig +8 -0
@@ -124,6 +124,14 @@ config SANDBOX_SPI }; }; +config STM32_QSPI + bool "STM32F7 QSPI driver" + depends on STM32F7 + help + Enable the STM32F7 Quad-SPI (QSPI) driver. This driver can be + used to access the SPI NOR flash chips on platforms embedding + this ST IP core. + config TEGRA114_SPI bool "nVidia Tegra114 SPI driver" help
drivers/spi/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_ROCKCHIP_SPI) += rk_spi.o obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o obj-$(CONFIG_SH_SPI) += sh_spi.o obj-$(CONFIG_SH_QSPI) += sh_qspi.o +obj-$(CONFIG_STM32_QSPI) += stm32_qspi.o obj-$(CONFIG_TEGRA114_SPI) += tegra114_spi.o obj-$(CONFIG_TEGRA20_SFLASH) += tegra20_sflash.o obj-$(CONFIG_TEGRA20_SLINK) += tegra20_slink.o
drivers/spi/stm32_qspi.c new file +628 -0
628 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 7/7 SPI: add missing flag to micron/stm N25Q128 flash chips
In reply to Michael KurzThis patch adds the missing 4K erase flag to struct spi_flash_params
---
Changes in v2: None
drivers/mtd/spi/sf_params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi/sf_params.c +2 -2
@@ -90,8 +90,8 @@ const struct spi_flash_params spi_flash_params_table[] = { {"N25Q32A", 0x20bb16, 0x0, 64 * 1024, 64, RD_FULL | WR_QPP | SECT_4K}, {"N25Q64", 0x20ba17, 0x0, 64 * 1024, 128, RD_FULL | WR_QPP | SECT_4K}, {"N25Q64A", 0x20bb17, 0x0, 64 * 1024, 128, RD_FULL | WR_QPP | SECT_4K}, - {"N25Q128", 0x20ba18, 0x0, 64 * 1024, 256, RD_FULL | WR_QPP}, - {"N25Q128A", 0x20bb18, 0x0, 64 * 1024, 256, RD_FULL | WR_QPP}, + {"N25Q128", 0x20ba18, 0x0, 64 * 1024, 256, RD_FULL | WR_QPP | SECT_4K}, + {"N25Q128A", 0x20bb18, 0x0, 64 * 1024, 256, RD_FULL | WR_QPP | SECT_4K}, {"N25Q256", 0x20ba19, 0x0, 64 * 1024, 512, RD_FULL | WR_QPP | SECT_4K}, {"N25Q256A", 0x20bb19, 0x0, 64 * 1024, 512, RD_FULL | WR_QPP | SECT_4K}, {"N25Q512", 0x20ba20, 0x0, 64 * 1024, 1024, RD_FULL | WR_QPP | E_FSR | SECT_4K},
Signature · 1 line
2.1.4