ARM: stm32: add network and qspi driver support to stm32f746-disco board
Subsystems (9)
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.
Michael Kurz (7):
ARM: DTS: stm32: add stm32f746-disco device tree 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
ARM: stm32: fix comment in stm32f7 header file
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-stm32f7/rcc.h | 15 +- arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 8 +- arch/arm/include/asm/arch-stm32f7/syscfg.h | 39 + arch/arm/mach-stm32/stm32f7/clock.c | 12 + board/st/stm32f746-disco/stm32f746-disco.c | 116 ++ configs/stm32f746-disco_defconfig | 23 +- drivers/mtd/spi/sf_params.c | 4 +- drivers/net/designware.c | 1 + drivers/net/phy/smsc.c | 12 + drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/stm32_qspi.c | 629 ++++++++++ include/configs/stm32f746-disco.h | 10 +- include/dt-bindings/pinctrl/stm32f746-pinfunc.h | 1324 ++++++++++++++++++++++ 18 files changed, 2771 insertions(+), 8 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 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 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.
---
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 2/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.
---
arch/arm/include/asm/arch-stm32f7/rcc.h | 8 ++++ arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 2 + arch/arm/include/asm/arch-stm32f7/syscfg.h | 39 +++++++++++++++++ arch/arm/mach-stm32/stm32f7/clock.c | 9 ++++ board/st/stm32f746-disco/stm32f746-disco.c | 56 ++++++++++++++++++++++++ configs/stm32f746-disco_defconfig | 15 ++++++- drivers/net/designware.c | 1 + include/configs/stm32f746-disco.h | 9 +++- 8 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arch-stm32f7/syscfg.h
arch/arm/include/asm/arch-stm32f7/rcc.h +8 -0
@@ -61,4 +61,12 @@#define RCC_ENR_GPIO_J_EN (1 << 9)#define RCC_ENR_GPIO_K_EN (1 << 10) +/* +* RCC STMMAC specific definitions +*/ +#define RCC_ENR_ETHMAC_EN (1 << 25) +#define RCC_ENR_ETHMAC_TX_EN (1 << 26) +#define RCC_ENR_ETHMAC_RX_EN (1 << 27) +#define RCC_ENR_ETHMAC_PTP_EN (1 << 28) +#endif
arch/arm/include/asm/arch-stm32f7/stm32_periph.h +2 -0
@@ -33,6 +33,8 @@ enum periph_clock {GPIO_I_CLOCK_CFG ,GPIO_J_CLOCK_CFG ,GPIO_K_CLOCK_CFG , +SYSCFG_CLOCK_CFG , + STMMAC_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */
arch/arm/include/asm/arch-stm32f7/syscfg.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* (C) Copyright 2016 +* Michael Kurz, [email protected]. +* +* 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_BASE 0x40013800 +#define STM32_SYSCFG ((struct stm32_syscfg_regs *)STM32_SYSCFG_BASE) + +/* SYSCFG memory remap register */ +#define SYSCFG_MEMRMP_MEM_BOOT (1 << 0) +#define SYSCFG_MEMRMP_SWP_FMC (1 << 10) + +/* SYSCFG peripheral mode configuration register */ +#define SYSCFG_PMC_ADCXDC2 (1 << 16) +#define SYSCFG_PMC_MII_RMII_SEL (1 << 23) + +/* Compensation cell control register */ +#define SYSCFG_CMPCR_CMP_PD (1 << 0) +#define SYSCFG_CMPCR_READY (1 << 8) + +#endif
arch/arm/mach-stm32/stm32f7/clock.c +9 -0
@@ -49,6 +49,7 @@#define RCC_CFGR_PPRE2_SHIFT 13#define RCC_APB1ENR_PWREN (1 << 28) +#define RCC_APB2ENR_SYSCFGEN (1 << 14)/* * RCC USART specific definitions
@@ -278,6 +279,14 @@ void clock_setup(int peripheral)case GPIO_K_CLOCK_CFG :setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_GPIO_K_EN );break ; +case SYSCFG_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_APB2ENR ,RCC_APB2ENR_SYSCFGEN ); +break ; +case STMMAC_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_EN ); +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_RX_EN ); +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_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 3/7 net: phy: add SMSC LAN8742 phy
In reply to Michael KurzThis patch adds support for SMSC LAN8742 in phylib
---
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 4/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.
---
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 5/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?
arch/arm/dts/stm32f746-disco.dts | 4 +- arch/arm/include/asm/arch-stm32f7/rcc.h | 5 + arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 6 +- arch/arm/mach-stm32/stm32f7/clock.c | 3 + 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 | 629 +++++++++++++++++++++++ 9 files changed, 719 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/rcc.h +5 -0
@@ -69,4 +69,9 @@#define RCC_ENR_ETHMAC_RX_EN (1 << 27)#define RCC_ENR_ETHMAC_PTP_EN (1 << 28) +/* +* RCC QSPI specific definitions +*/ +#define RCC_ENR_QSPI_EN (1 << 1) +#endif
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 {
@@ -35,6 +36,7 @@ enum periph_clock {GPIO_K_CLOCK_CFG ,SYSCFG_CLOCK_CFG ,STMMAC_CLOCK_CFG , + QSPI_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */
arch/arm/mach-stm32/stm32f7/clock.c +3 -0
@@ -287,6 +287,9 @@ void clock_setup(int peripheral)setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_RX_EN );setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_TX_EN );break ; +case QSPI_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_AHB3ENR ,RCC_ENR_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 +629 -0
629 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 6/7 ARM: stm32: fix comment in stm32f7 header file
In reply to Michael KurzThis patch fixes a comment typo in stm32f7 rcc.h header
---
arch/arm/include/asm/arch-stm32f7/rcc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/arch-stm32f7/rcc.h +1 -1
@@ -22,7 +22,7 @@#define RCC_AHB3ENR 0x38/* AHB3 peripheral clock enable */ #define RCC_APB1ENR 0x40/* APB1 peripheral clock enable */ #define RCC_APB2ENR 0x44/* APB2 peripheral clock enable */ -#define RCC_AHB1LPENR 0x50/* periph clk enable in low pwr mode */ +#define RCC_AHB1LPENR 0x50/* AHB1 periph clk enable in low pwr mode */ #define RCC_AHB2LPENR 0x54/* AHB2 periph clk enable in low pwr mode */ #define RCC_AHB3LPENR 0x58/* AHB3 periph clk enable in low pwr mode */ #define RCC_APB1LPENR 0x60/* APB1 periph clk enable in low pwr mode */
Signature · 1 line
2.1.4
PATCH 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
---
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
PATCH 2/7 net: stm32: add designware mac glue code for stm32
In reply to Michael KurzQuoted 22 lines · Michael Kurz
This patch adds glue code required for enabling the designware mac on stm32f7 devices.
Signed-off-by Michael Kurz <[email protected]>---
arch/arm/include/asm/arch-stm32f7/rcc.h | 8 ++++ arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 2 + arch/arm/include/asm/arch-stm32f7/syscfg.h | 39 +++++++++++++++++ arch/arm/mach-stm32/stm32f7/clock.c | 9 ++++ board/st/stm32f746-disco/stm32f746-disco.c | 56 ++++++++++++++++++++++++ configs/stm32f746-disco_defconfig | 15 ++++++- drivers/net/designware.c | 1 + include/configs/stm32f746-disco.h | 9 +++- 8 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arch-stm32f7/syscfg.harch/arm/include/asm/arch-stm32f7/rcc.h +0
-0
arch/arm/include/asm/arch-stm32f7/rcc.h line 62
Quoted 2 lines
arch/arm/include/asm/arch-stm32f7/rcc.h +0
-0@@ -61,4 +61,12 @@#define RCC_ENR_GPIO_J_EN (1 << 9)#define RCC_ENR_GPIO_K_EN (1 << 10)
Please use the BIT() macro throughout for these constants.
Quoted 43 lines
arch/arm/include/asm/arch-stm32f7/rcc.h +8
-0+/* +* RCC STMMAC specific definitions +*/ +#define RCC_ENR_ETHMAC_EN (1 << 25) +#define RCC_ENR_ETHMAC_TX_EN (1 << 26) +#define RCC_ENR_ETHMAC_RX_EN (1 << 27) +#define RCC_ENR_ETHMAC_PTP_EN (1 << 28) +#endif arch/arm/include/asm/arch-stm32f7/stm32_periph.h +2
-0@@ -33,6 +33,8 @@ enum periph_clock {GPIO_I_CLOCK_CFG ,GPIO_J_CLOCK_CFG ,GPIO_K_CLOCK_CFG , +SYSCFG_CLOCK_CFG , + STMMAC_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */ arch/arm/include/asm/arch-stm32f7/syscfg.h new file +14
-0@@ -0,0 +1,39 @@ +/* +* (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;
arch/arm/include/asm/arch-stm32f7/syscfg.h line 24
Quoted 10 lines
arch/arm/include/asm/arch-stm32f7/syscfg.h new file +10
-0+u32 exticr2; +u32 exticr3; +u32 exticr4; +u32 cmpcr; +}; + +/* +* SYSCFG registers base +*/ +#define STM32_SYSCFG_BASE 0x40013800
Maybe this should come from the config?
Quoted 195 lines
arch/arm/include/asm/arch-stm32f7/syscfg.h new file +15
-0+#define STM32_SYSCFG ((struct stm32_syscfg_regs *)STM32_SYSCFG_BASE) + +/* SYSCFG memory remap register */ +#define SYSCFG_MEMRMP_MEM_BOOT (1 << 0) +#define SYSCFG_MEMRMP_SWP_FMC (1 << 10) + +/* SYSCFG peripheral mode configuration register */ +#define SYSCFG_PMC_ADCXDC2 (1 << 16) +#define SYSCFG_PMC_MII_RMII_SEL (1 << 23) + +/* Compensation cell control register */ +#define SYSCFG_CMPCR_CMP_PD (1 << 0) +#define SYSCFG_CMPCR_READY (1 << 8) + +#endif arch/arm/mach-stm32/stm32f7/clock.c +9
-0@@ -49,6 +49,7 @@#define RCC_CFGR_PPRE2_SHIFT 13#define RCC_APB1ENR_PWREN (1 << 28) +#define RCC_APB2ENR_SYSCFGEN (1 << 14)/* * RCC USART specific definitions @@ -278,6 +279,14 @@ void clock_setup(int peripheral)case GPIO_K_CLOCK_CFG :setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_GPIO_K_EN );break ; +case SYSCFG_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_APB2ENR ,RCC_APB2ENR_SYSCFGEN ); +break ; +case STMMAC_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_EN ); +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_RX_EN ); +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_TX_EN ); +break ;default :break ; }board/st/stm32f746-disco/stm32f746-disco.c +56
-0@@ -16,6 +16,7 @@#include <dm/platform_data/serial_stm32x7.h> #include <asm/arch/stm32_periph.h> #include <asm/arch/stm32_defs.h> +#include <asm/arch/syscfg.h> DECLARE_GLOBAL_DATA_PTR ;@@ -282,6 +283,55 @@ U_BOOT_DEVICE(stm32x7_serials) = { .platdata = &serial_platdata, }; +#ifdef CONFIG_ETH_DESIGNWARE +const struct stm32_gpio_ctl gpio_ctl_eth = { + .mode =STM32_GPIO_MODE_AF , + .otype =STM32_GPIO_OTYPE_PP , + .speed =STM32_GPIO_SPEED_100M , + .pupd =STM32_GPIO_PUPD_NO , + .af =STM32_GPIO_AF11 +}; + +static const struct stm32_gpio_dsc eth_gpio[] = { + {STM32_GPIO_PORT_A ,STM32_GPIO_PIN_1 },/* ETH_RMII_REF_CLK */ + {STM32_GPIO_PORT_A ,STM32_GPIO_PIN_2 },/* ETH_MDIO */ + {STM32_GPIO_PORT_A ,STM32_GPIO_PIN_7 },/* ETH_RMII_CRS_DV */ + + {STM32_GPIO_PORT_C ,STM32_GPIO_PIN_1 },/* ETH_MDC */ + {STM32_GPIO_PORT_C ,STM32_GPIO_PIN_4 },/* ETH_RMII_RXD0 */ + {STM32_GPIO_PORT_C ,STM32_GPIO_PIN_5 },/* ETH_RMII_RXD1 */ + + {STM32_GPIO_PORT_G ,STM32_GPIO_PIN_11 },/* ETH_RMII_TX_EN */ + {STM32_GPIO_PORT_G ,STM32_GPIO_PIN_13 },/* ETH_RMII_TXD0 */ + {STM32_GPIO_PORT_G ,STM32_GPIO_PIN_14 },/* ETH_RMII_TXD1 */ +}; + +static int stmmac_setup (void ) +{ +int res =0 ; +int i; + +clock_setup (SYSCFG_CLOCK_CFG ); + +/* Set >RMII mode */ +STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; + +clock_setup (GPIO_A_CLOCK_CFG ); +clock_setup (GPIO_C_CLOCK_CFG ); +clock_setup (GPIO_G_CLOCK_CFG ); + +for (i =0 ; i <ARRAY_SIZE (eth_gpio); i++) { + res =stm32_gpio_config (ð_gpio[i], &gpio_ctl_eth); +if (res) +return res; + } + +clock_setup (STMMAC_CLOCK_CFG ); + +return 0 ; +} +#endif +u32 get_board_rev (void ) {return 0 ;@@ -296,6 +346,12 @@ int board_early_init_f(void)if (res)return res; +#ifdef CONFIG_ETH_DESIGNWARE + res =stmmac_setup (); +if (res) +return res; +#endif +return 0 ; }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 setdrivers/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
-3@@ -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 at 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 \ --2.1.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 3/7 net: phy: add SMSC LAN8742 phy
In reply to Michael KurzQuoted 3 lines · Michael Kurz
This patch adds support for SMSC LAN8742 in phylib
Signed-off-by Michael Kurz <[email protected]>
PATCH 2/7 net: stm32: add designware mac glue code for stm32
In reply to Joe HershbergerQuoted 18 lines · Joe Hershberger
Quoted 17 lines · Michael Kurz
This patch adds glue code required for enabling the designware mac on stm32f7 devices.
Signed-off-by Michael Kurz <[email protected]>---
arch/arm/include/asm/arch-stm32f7/rcc.h | 8 ++++ arch/arm/include/asm/arch-stm32f7/stm32_periph.h | 2 + arch/arm/include/asm/arch-stm32f7/syscfg.h | 39 +++++++++++++++++ arch/arm/mach-stm32/stm32f7/clock.c | 9 ++++ board/st/stm32f746-disco/stm32f746-disco.c | 56 ++++++++++++++++++++++++ configs/stm32f746-disco_defconfig | 15 ++++++- drivers/net/designware.c | 1 + include/configs/stm32f746-disco.h | 9 +++- 8 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arch-stm32f7/syscfg.h
Quoted 9 lines
arch/arm/include/asm/arch-stm32f7/rcc.h line 62
Quoted 7 lines
arch/arm/include/asm/arch-stm32f7/rcc.h +0
-0@@ -61,4 +61,12 @@#define RCC_ENR_GPIO_J_EN (1 << 9)#define RCC_ENR_GPIO_K_EN (1 << 10)Please use the
BIT()macro throughout for these constants.
Will do and resubmit as v2.
Quoted 48 lines
Quoted 48 lines
arch/arm/include/asm/arch-stm32f7/rcc.h +8
-0+/* +* RCC STMMAC specific definitions +*/ +#define RCC_ENR_ETHMAC_EN (1 << 25) +#define RCC_ENR_ETHMAC_TX_EN (1 << 26) +#define RCC_ENR_ETHMAC_RX_EN (1 << 27) +#define RCC_ENR_ETHMAC_PTP_EN (1 << 28) +#endif arch/arm/include/asm/arch-stm32f7/stm32_periph.h +2
-0@@ -33,6 +33,8 @@ enum periph_clock {GPIO_I_CLOCK_CFG ,GPIO_J_CLOCK_CFG ,GPIO_K_CLOCK_CFG , +SYSCFG_CLOCK_CFG , + STMMAC_CLOCK_CFG, };#endif /* __ASM_ARM_ARCH_PERIPH_H */ arch/arm/include/asm/arch-stm32f7/syscfg.h new file +18
-0@@ -0,0 +1,39 @@ +/* +* (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;
Quoted 9 lines
arch/arm/include/asm/arch-stm32f7/syscfg.h line 24
Quoted 6 lines
arch/arm/include/asm/arch-stm32f7/syscfg.h new file +6
-0+}; + +/* +* SYSCFG registers base +*/ +#define STM32_SYSCFG_BASE 0x40013800Maybe this should come from the config?
I'll move it to the config for now. Ideally this would come from the device tree. But that's for a future patch.
Quoted 196 lines
Quoted 195 lines
arch/arm/include/asm/arch-stm32f7/syscfg.h new file +15
-0+#define STM32_SYSCFG ((struct stm32_syscfg_regs *)STM32_SYSCFG_BASE) + +/* SYSCFG memory remap register */ +#define SYSCFG_MEMRMP_MEM_BOOT (1 << 0) +#define SYSCFG_MEMRMP_SWP_FMC (1 << 10) + +/* SYSCFG peripheral mode configuration register */ +#define SYSCFG_PMC_ADCXDC2 (1 << 16) +#define SYSCFG_PMC_MII_RMII_SEL (1 << 23) + +/* Compensation cell control register */ +#define SYSCFG_CMPCR_CMP_PD (1 << 0) +#define SYSCFG_CMPCR_READY (1 << 8) + +#endif arch/arm/mach-stm32/stm32f7/clock.c +9
-0@@ -49,6 +49,7 @@#define RCC_CFGR_PPRE2_SHIFT 13#define RCC_APB1ENR_PWREN (1 << 28) +#define RCC_APB2ENR_SYSCFGEN (1 << 14)/* * RCC USART specific definitions @@ -278,6 +279,14 @@ void clock_setup(int peripheral)case GPIO_K_CLOCK_CFG :setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_GPIO_K_EN );break ; +case SYSCFG_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_APB2ENR ,RCC_APB2ENR_SYSCFGEN ); +break ; +case STMMAC_CLOCK_CFG : +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_EN ); +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_RX_EN ); +setbits_le32 (RCC_BASE +RCC_AHB1ENR ,RCC_ENR_ETHMAC_TX_EN ); +break ;default :break ; }board/st/stm32f746-disco/stm32f746-disco.c +56
-0@@ -16,6 +16,7 @@#include <dm/platform_data/serial_stm32x7.h> #include <asm/arch/stm32_periph.h> #include <asm/arch/stm32_defs.h> +#include <asm/arch/syscfg.h> DECLARE_GLOBAL_DATA_PTR ;@@ -282,6 +283,55 @@ U_BOOT_DEVICE(stm32x7_serials) = { .platdata = &serial_platdata, }; +#ifdef CONFIG_ETH_DESIGNWARE +const struct stm32_gpio_ctl gpio_ctl_eth = { + .mode =STM32_GPIO_MODE_AF , + .otype =STM32_GPIO_OTYPE_PP , + .speed =STM32_GPIO_SPEED_100M , + .pupd =STM32_GPIO_PUPD_NO , + .af =STM32_GPIO_AF11 +}; + +static const struct stm32_gpio_dsc eth_gpio[] = { + {STM32_GPIO_PORT_A ,STM32_GPIO_PIN_1 },/* ETH_RMII_REF_CLK */ + {STM32_GPIO_PORT_A ,STM32_GPIO_PIN_2 },/* ETH_MDIO */ + {STM32_GPIO_PORT_A ,STM32_GPIO_PIN_7 },/* ETH_RMII_CRS_DV */ + + {STM32_GPIO_PORT_C ,STM32_GPIO_PIN_1 },/* ETH_MDC */ + {STM32_GPIO_PORT_C ,STM32_GPIO_PIN_4 },/* ETH_RMII_RXD0 */ + {STM32_GPIO_PORT_C ,STM32_GPIO_PIN_5 },/* ETH_RMII_RXD1 */ + + {STM32_GPIO_PORT_G ,STM32_GPIO_PIN_11 },/* ETH_RMII_TX_EN */ + {STM32_GPIO_PORT_G ,STM32_GPIO_PIN_13 },/* ETH_RMII_TXD0 */ + {STM32_GPIO_PORT_G ,STM32_GPIO_PIN_14 },/* ETH_RMII_TXD1 */ +}; + +static int stmmac_setup (void ) +{ +int res =0 ; +int i; + +clock_setup (SYSCFG_CLOCK_CFG ); + +/* Set >RMII mode */ +STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ; + +clock_setup (GPIO_A_CLOCK_CFG ); +clock_setup (GPIO_C_CLOCK_CFG ); +clock_setup (GPIO_G_CLOCK_CFG ); + +for (i =0 ; i <ARRAY_SIZE (eth_gpio); i++) { + res =stm32_gpio_config (ð_gpio[i], &gpio_ctl_eth); +if (res) +return res; + } + +clock_setup (STMMAC_CLOCK_CFG ); + +return 0 ; +} +#endif +u32 get_board_rev (void ) {return 0 ;@@ -296,6 +346,12 @@ int board_early_init_f(void)if (res)return res; +#ifdef CONFIG_ETH_DESIGNWARE + res =stmmac_setup (); +if (res) +return res; +#endif +return 0 ; }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 setdrivers/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
-3@@ -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 at 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 \ --2.1.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot