From 814b1abb084d6c995db24f7a0ba915392fed7ce4 Mon Sep 17 00:00:00 2001 From: xjy198903 <335266746@qq.com> Date: Mon, 15 Aug 2022 11:21:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=8C=E7=BD=91=E5=8F=A3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?phy8211F=20=E9=A9=B1=E5=8A=A8=20(#6278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update Kconfig 增加RT1170双路网络选项 * Update SConscript 增加RTL8211F驱动选项支持 * Update SConstruct 去掉外设目录 * Add files via upload 增加PHY芯片RTL8211F驱动 * Update drv_rtl8211f.c * format code Co-authored-by: Meco Man <920369182@qq.com> --- bsp/imxrt/imxrt1021-nxp-evk/SConstruct | 3 - .../imxrt1021-nxp-evk/applications/SConscript | 6 +- bsp/imxrt/imxrt1021-nxp-evk/board/Kconfig | 112 ++--- bsp/imxrt/imxrt1021-nxp-evk/board/SConscript | 2 +- bsp/imxrt/imxrt1021-nxp-evk/xip/SConscript | 10 +- .../applications/SConscript | 6 +- .../imxrt1052-atk-commander/board/Kconfig | 10 +- .../applications/SConscript | 6 +- bsp/imxrt/imxrt1052-fire-pro/board/Kconfig | 6 +- bsp/imxrt/imxrt1052-nxp-evk/SConstruct | 3 - .../imxrt1052-nxp-evk/applications/SConscript | 6 +- bsp/imxrt/imxrt1052-nxp-evk/board/Kconfig | 36 +- bsp/imxrt/imxrt1052-nxp-evk/xip/SConscript | 8 +- .../applications/SConscript | 4 +- .../imxrt1052-seeed-ArchMix/board/Kconfig | 8 +- bsp/imxrt/imxrt1060-nxp-evk/SConstruct | 3 - .../imxrt1060-nxp-evk/applications/SConscript | 6 +- bsp/imxrt/imxrt1060-nxp-evk/board/Kconfig | 4 +- bsp/imxrt/imxrt1060-nxp-evk/board/SConscript | 2 +- bsp/imxrt/imxrt1060-nxp-evk/xip/SConscript | 8 +- bsp/imxrt/imxrt1064-nxp-evk/SConstruct | 3 - .../imxrt1064-nxp-evk/applications/SConscript | 4 +- bsp/imxrt/imxrt1064-nxp-evk/board/Kconfig | 26 +- bsp/imxrt/imxrt1064-nxp-evk/board/SConscript | 2 +- bsp/imxrt/imxrt1064-nxp-evk/xip/SConscript | 8 +- bsp/imxrt/imxrt1170-nxp-evk/SConstruct | 3 - .../imxrt1170-nxp-evk/applications/SConscript | 6 +- bsp/imxrt/imxrt1170-nxp-evk/board/Kconfig | 35 +- bsp/imxrt/imxrt1170-nxp-evk/xip/SConscript | 4 +- bsp/imxrt/libraries/Kconfig | 4 +- bsp/imxrt/libraries/MIMXRT1050/SConscript | 4 +- bsp/imxrt/libraries/MIMXRT1060/SConscript | 4 +- bsp/imxrt/libraries/MIMXRT1064/SConscript | 2 +- bsp/imxrt/libraries/MIMXRT1170/SConscript | 10 +- bsp/imxrt/libraries/drivers/SConscript | 18 +- bsp/imxrt/libraries/drivers/drv_ksz8081.c | 4 +- bsp/imxrt/libraries/drivers/drv_rtl8211f.c | 462 ++++++++++++++++++ .../imxrt1050xxx/applications/SConscript | 4 +- .../templates/imxrt1050xxx/board/Kconfig | 6 +- .../imxrt1064xxx/applications/SConscript | 4 +- .../templates/imxrt1064xxx/xip/SConscript | 8 +- 41 files changed, 669 insertions(+), 201 deletions(-) create mode 100644 bsp/imxrt/libraries/drivers/drv_rtl8211f.c diff --git a/bsp/imxrt/imxrt1021-nxp-evk/SConstruct b/bsp/imxrt/imxrt1021-nxp-evk/SConstruct index 8c8f750159..99a27abaf3 100644 --- a/bsp/imxrt/imxrt1021-nxp-evk/SConstruct +++ b/bsp/imxrt/imxrt1021-nxp-evk/SConstruct @@ -66,8 +66,5 @@ objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SCons # include drivers objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'))) -# include peripherals -objs.extend(SConscript(os.path.join(libraries_path_prefix, 'peripherals', 'SConscript'))) - # make a building DoBuilding(TARGET, objs) diff --git a/bsp/imxrt/imxrt1021-nxp-evk/applications/SConscript b/bsp/imxrt/imxrt1021-nxp-evk/applications/SConscript index 2c988286bc..ab2275a135 100644 --- a/bsp/imxrt/imxrt1021-nxp-evk/applications/SConscript +++ b/bsp/imxrt/imxrt1021-nxp-evk/applications/SConscript @@ -6,17 +6,17 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.CROSS_TOOL == 'gcc': CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: if os.path.isfile(os.path.join(cwd, item, 'SConscript')): group = group + SConscript(os.path.join(item, 'SConscript')) - + Return('group') diff --git a/bsp/imxrt/imxrt1021-nxp-evk/board/Kconfig b/bsp/imxrt/imxrt1021-nxp-evk/board/Kconfig index d6a4716862..117f98683b 100644 --- a/bsp/imxrt/imxrt1021-nxp-evk/board/Kconfig +++ b/bsp/imxrt/imxrt1021-nxp-evk/board/Kconfig @@ -3,19 +3,19 @@ menu "Hardware Drivers" config BSP_USING_QSPIFLASH bool default y - + config SOC_IMXRT1021DAG5A - bool + bool select SOC_MIMXRT1020_SERIES - select RT_USING_COMPONENTS_INIT + select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN - select SOC_IMXRT1020_SERIES + select SOC_IMXRT1020_SERIES default y menu "On-chip Peripheral Drivers" - config BSP_USING_DMA + config BSP_USING_DMA bool "Enable DMA" default n @@ -23,7 +23,7 @@ menu "On-chip Peripheral Drivers" bool "Enable GPIO" select RT_USING_PIN default y - + menuconfig BSP_USING_CAN bool "Enable CAN" select RT_USING_CAN @@ -39,7 +39,7 @@ menu "On-chip Peripheral Drivers" bool "Enable UART" select RT_USING_SERIAL default y - + if BSP_USING_LPUART config BSP_USING_LPUART1 bool "Enable LPUART1" @@ -69,19 +69,19 @@ menu "On-chip Peripheral Drivers" int "Set LPUART1 TX DMA channel (0-32)" default 1 endif - menuconfig BSP_USING_HWTIMER - bool "Enable GPT" - default n - select RT_USING_HWTIMER - if BSP_USING_TIM - config BSP_USING_HWTIMER1 - bool "Enable GPT1" - default n + menuconfig BSP_USING_HWTIMER + bool "Enable GPT" + default n + select RT_USING_HWTIMER + if BSP_USING_TIM + config BSP_USING_HWTIMER1 + bool "Enable GPT1" + default n - config BSP_USING_HWTIMER2 - bool "Enable GPT2" - default n - endif + config BSP_USING_HWTIMER2 + bool "Enable GPT2" + default n + endif menuconfig BSP_USING_PWM bool "Enable PWM" default n @@ -138,7 +138,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_ADC1 bool "Enable ADC1" default n - endif + endif config BSP_USING_RTC bool "Enable RTC" select RT_USING_RTC @@ -147,47 +147,47 @@ menu "On-chip Peripheral Drivers" endmenu menu "Onboard Peripheral Drivers" - config BSP_USING_RGB - bool "Enable RGB LED (PWM1_CH3A, PWM4_CH0A and PWM4_CH1A)" - select BSP_USING_PWM1 - select BSP_USING_PWM4 - select BSP_USING_PWM1_CH3 - select BSP_USING_PWM4_CH0 - select BSP_USING_PWM4_CH1 - default n + config BSP_USING_RGB + bool "Enable RGB LED (PWM1_CH3A, PWM4_CH0A and PWM4_CH1A)" + select BSP_USING_PWM1 + select BSP_USING_PWM4 + select BSP_USING_PWM1_CH3 + select BSP_USING_PWM4_CH0 + select BSP_USING_PWM4_CH1 + default n - config BSP_USING_MPU6050 - bool "Enable MPU6050 (I2C1:J11 --> SCL; K11 --> SDA)" - select BSP_USING_I2C1 - select PKG_USING_MPU6XXX - default n + config BSP_USING_MPU6050 + bool "Enable MPU6050 (I2C1:J11 --> SCL; K11 --> SDA)" + select BSP_USING_I2C1 + select PKG_USING_MPU6XXX + default n - menuconfig BSP_USING_AP3216C - bool "Enable AP3216C (I2C1:J11 --> SCL; K11 --> SDA)" - select BSP_USING_I2C1 - select PKG_USING_AP3216C - default n - if BSP_USING_AP3216C - config AP3216C_USING_HW_INT - bool "Enable interrupt" - default n - endif + menuconfig BSP_USING_AP3216C + bool "Enable AP3216C (I2C1:J11 --> SCL; K11 --> SDA)" + select BSP_USING_I2C1 + select PKG_USING_AP3216C + default n + if BSP_USING_AP3216C + config AP3216C_USING_HW_INT + bool "Enable interrupt" + default n + endif - config BSP_USING_EEPROM - bool "Enable I2C EEPROM (I2C1:J11 --> SCL; K11 --> SDA)" - select BSP_USING_I2C1 - select PKG_USING_AT24CXX - default n + config BSP_USING_EEPROM + bool "Enable I2C EEPROM (I2C1:J11 --> SCL; K11 --> SDA)" + select BSP_USING_I2C1 + select PKG_USING_AT24CXX + default n - config BSP_USING_RS232 - bool "Enable RS232" - select BSP_USING_LPUART2 - default n + config BSP_USING_RS232 + bool "Enable RS232" + select BSP_USING_LPUART2 + default n - config BSP_USING_RS485 - bool "Enable RS485" - select BSP_USING_LPUART5 - default n + config BSP_USING_RS485 + bool "Enable RS485" + select BSP_USING_LPUART5 + default n endmenu diff --git a/bsp/imxrt/imxrt1021-nxp-evk/board/SConscript b/bsp/imxrt/imxrt1021-nxp-evk/board/SConscript index 0630500e17..a16c5757ed 100644 --- a/bsp/imxrt/imxrt1021-nxp-evk/board/SConscript +++ b/bsp/imxrt/imxrt1021-nxp-evk/board/SConscript @@ -16,7 +16,7 @@ CPPDEFINES = ['CPU_MIMXRT1021DAG5A', 'ENDIANNESS', 'STD=C99', 'SKIP_SYSCLK_INIT' if rtconfig.CROSS_TOOL == 'keil': CPPDEFINES.append('__FPU_PRESENT=1') - + group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) Return('group') diff --git a/bsp/imxrt/imxrt1021-nxp-evk/xip/SConscript b/bsp/imxrt/imxrt1021-nxp-evk/xip/SConscript index d2e121e013..08fccdc6f4 100644 --- a/bsp/imxrt/imxrt1021-nxp-evk/xip/SConscript +++ b/bsp/imxrt/imxrt1021-nxp-evk/xip/SConscript @@ -13,11 +13,11 @@ if GetDepend('BSP_USING_QSPIFLASH'): LINKFLAGS += '--keep=*(.boot_hdr.dcd_data)' LINKFLAGS += '--keep=*(.boot_hdr.conf)' else: - LINKFLAGS = '' + LINKFLAGS = '' - group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - Return('group') + group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) + Return('group') -if GetDepend('BSP_USING_HYPERFLASH'): +if GetDepend('BSP_USING_HYPERFLASH'): group = [] - Return('group') + Return('group') diff --git a/bsp/imxrt/imxrt1052-atk-commander/applications/SConscript b/bsp/imxrt/imxrt1052-atk-commander/applications/SConscript index 8b955cf5c1..050054c59f 100644 --- a/bsp/imxrt/imxrt1052-atk-commander/applications/SConscript +++ b/bsp/imxrt/imxrt1052-atk-commander/applications/SConscript @@ -6,17 +6,17 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: if os.path.isfile(os.path.join(cwd, item, 'SConscript')): group = group + SConscript(os.path.join(item, 'SConscript')) - + Return('group') diff --git a/bsp/imxrt/imxrt1052-atk-commander/board/Kconfig b/bsp/imxrt/imxrt1052-atk-commander/board/Kconfig index b4beef948d..b7d88da261 100644 --- a/bsp/imxrt/imxrt1052-atk-commander/board/Kconfig +++ b/bsp/imxrt/imxrt1052-atk-commander/board/Kconfig @@ -1,7 +1,7 @@ menu "Hardware Drivers Config" config SOC_IMXRT1052CVL5B - bool + bool select SOC_MIMXRT1050_SERIES select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN @@ -12,7 +12,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_DMA bool "Enable DMA" default n - + config BSP_USING_GPIO bool "Enable GPIO" select RT_USING_PIN @@ -22,7 +22,7 @@ menu "On-chip Peripheral Drivers" bool "Enable UART" select RT_USING_SERIAL default y - + if BSP_USING_LPUART config BSP_USING_LPUART1 bool "Enable LPUART1" @@ -112,14 +112,14 @@ menu "On-chip Peripheral Drivers" endmenu menu "Onboard Peripheral Drivers" - + config BSP_USING_SPI_FLASH bool "Enable SPI FLASH (W25Q256 spi3)" select BSP_USING_SPI3 select RT_USING_SFUD default n - + config BSP_USING_SDRAM bool "Enable SDRAM" default n diff --git a/bsp/imxrt/imxrt1052-fire-pro/applications/SConscript b/bsp/imxrt/imxrt1052-fire-pro/applications/SConscript index 8b955cf5c1..050054c59f 100644 --- a/bsp/imxrt/imxrt1052-fire-pro/applications/SConscript +++ b/bsp/imxrt/imxrt1052-fire-pro/applications/SConscript @@ -6,17 +6,17 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: if os.path.isfile(os.path.join(cwd, item, 'SConscript')): group = group + SConscript(os.path.join(item, 'SConscript')) - + Return('group') diff --git a/bsp/imxrt/imxrt1052-fire-pro/board/Kconfig b/bsp/imxrt/imxrt1052-fire-pro/board/Kconfig index 5ab63d35a9..57d86e953a 100644 --- a/bsp/imxrt/imxrt1052-fire-pro/board/Kconfig +++ b/bsp/imxrt/imxrt1052-fire-pro/board/Kconfig @@ -1,7 +1,7 @@ menu "Hardware Drivers Config" config SOC_IMXRT1052CVL5B - bool + bool select SOC_MIMXRT1050_SERIES select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN @@ -12,7 +12,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_DMA bool "Enable DMA" default n - + config BSP_USING_GPIO bool "Enable GPIO" select RT_USING_PIN @@ -33,7 +33,7 @@ menu "On-chip Peripheral Drivers" bool "Enable UART" select RT_USING_SERIAL default y - + if BSP_USING_LPUART config BSP_USING_LPUART1 bool "Enable LPUART1" diff --git a/bsp/imxrt/imxrt1052-nxp-evk/SConstruct b/bsp/imxrt/imxrt1052-nxp-evk/SConstruct index b2f0587d56..f7eb3c0c5e 100644 --- a/bsp/imxrt/imxrt1052-nxp-evk/SConstruct +++ b/bsp/imxrt/imxrt1052-nxp-evk/SConstruct @@ -67,8 +67,5 @@ objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SCons # include drivers objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'))) -# include peripherals -objs.extend(SConscript(os.path.join(libraries_path_prefix, 'peripherals', 'SConscript'))) - # make a building DoBuilding(TARGET, objs) diff --git a/bsp/imxrt/imxrt1052-nxp-evk/applications/SConscript b/bsp/imxrt/imxrt1052-nxp-evk/applications/SConscript index 8b955cf5c1..050054c59f 100644 --- a/bsp/imxrt/imxrt1052-nxp-evk/applications/SConscript +++ b/bsp/imxrt/imxrt1052-nxp-evk/applications/SConscript @@ -6,17 +6,17 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: if os.path.isfile(os.path.join(cwd, item, 'SConscript')): group = group + SConscript(os.path.join(item, 'SConscript')) - + Return('group') diff --git a/bsp/imxrt/imxrt1052-nxp-evk/board/Kconfig b/bsp/imxrt/imxrt1052-nxp-evk/board/Kconfig index e5ce43afb3..7417c49cdf 100644 --- a/bsp/imxrt/imxrt1052-nxp-evk/board/Kconfig +++ b/bsp/imxrt/imxrt1052-nxp-evk/board/Kconfig @@ -17,7 +17,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_DMA bool "Enable DMA" default n - + config BSP_USING_GPIO bool "Enable GPIO" select RT_USING_PIN @@ -27,7 +27,7 @@ menu "On-chip Peripheral Drivers" bool "Enable UART" select RT_USING_SERIAL default y - + if BSP_USING_LPUART config BSP_USING_LPUART1 bool "Enable LPUART1" @@ -114,19 +114,19 @@ menu "Onboard Peripheral Drivers" default n menuconfig BSP_USING_ETH - bool "Enable Ethernet" - select RT_USING_NETDEV - select RT_USING_LWIP - default n - + bool "Enable Ethernet" + select RT_USING_NETDEV + select RT_USING_LWIP + default n - if BSP_USING_ETH - config BSP_USING_PHY + + if BSP_USING_ETH + config BSP_USING_PHY select RT_USING_PHY - bool "Enable ethernet phy" - default y + bool "Enable ethernet phy" + default y - if BSP_USING_PHY + if BSP_USING_PHY config PHY_DEVICE_ADDRESS int "Specify address of phy device" default 2 @@ -143,7 +143,7 @@ menu "Onboard Peripheral Drivers" config PHY_RESET_PIN int "indicate pin of reset" default 9 - + config FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE bool "Enable the PHY ksz8081 RMII50M mode" depends on PHY_USING_KSZ8081 @@ -151,14 +151,14 @@ menu "Onboard Peripheral Drivers" endif endif - endif - + endif + menuconfig BSP_USING_AUDIO bool "Enable AUDIO (WM8960)" select BSP_USING_I2C1 select RT_USING_AUDIO default n - + if BSP_USING_AUDIO config BSP_USING_AUDIO_PLAY bool "Enable Audio Play" @@ -177,8 +177,8 @@ menu "Onboard Peripheral Drivers" config BSP_AUDIO_USING_DMA bool "Enable AUDIO DMA" default n - endif - endif + endif + endif endmenu menu "Board extended module Drivers" diff --git a/bsp/imxrt/imxrt1052-nxp-evk/xip/SConscript b/bsp/imxrt/imxrt1052-nxp-evk/xip/SConscript index 56df6b3339..3e53fa00b1 100644 --- a/bsp/imxrt/imxrt1052-nxp-evk/xip/SConscript +++ b/bsp/imxrt/imxrt1052-nxp-evk/xip/SConscript @@ -15,9 +15,9 @@ if GetDepend('BSP_USING_HYPERFLASH'): else: LINKFLAGS = '' - group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - Return('group') + group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) + Return('group') -if GetDepend('BSP_USING_QSPIFLASH'): +if GetDepend('BSP_USING_QSPIFLASH'): group = [] - Return('group') + Return('group') diff --git a/bsp/imxrt/imxrt1052-seeed-ArchMix/applications/SConscript b/bsp/imxrt/imxrt1052-seeed-ArchMix/applications/SConscript index 1e36bcdcf4..050054c59f 100644 --- a/bsp/imxrt/imxrt1052-seeed-ArchMix/applications/SConscript +++ b/bsp/imxrt/imxrt1052-seeed-ArchMix/applications/SConscript @@ -6,12 +6,12 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) diff --git a/bsp/imxrt/imxrt1052-seeed-ArchMix/board/Kconfig b/bsp/imxrt/imxrt1052-seeed-ArchMix/board/Kconfig index 2644641ba5..01443a5a77 100644 --- a/bsp/imxrt/imxrt1052-seeed-ArchMix/board/Kconfig +++ b/bsp/imxrt/imxrt1052-seeed-ArchMix/board/Kconfig @@ -1,14 +1,14 @@ menu "Hardware Drivers Config" config SOC_IMXRT1052CVL5B - bool + bool select SOC_MIMXRT1050_SERIES select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN default y menu "Onboard Peripheral Drivers" - + config BSP_USING_SDRAM bool "Enable SDRAM" default n @@ -20,7 +20,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_DMA bool "Enable DMA" default n - + config BSP_USING_GPIO bool "Enable GPIO" select RT_USING_PIN @@ -30,7 +30,7 @@ menu "On-chip Peripheral Drivers" bool "Enable UART" select RT_USING_SERIAL default y - + if BSP_USING_LPUART config BSP_USING_LPUART1 bool "Enable LPUART1" diff --git a/bsp/imxrt/imxrt1060-nxp-evk/SConstruct b/bsp/imxrt/imxrt1060-nxp-evk/SConstruct index a45850ddd7..7bf53a47b0 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/SConstruct +++ b/bsp/imxrt/imxrt1060-nxp-evk/SConstruct @@ -66,8 +66,5 @@ objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SCons # include drivers objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'))) -# include peripherals -objs.extend(SConscript(os.path.join(libraries_path_prefix, 'peripherals', 'SConscript'))) - # make a building DoBuilding(TARGET, objs) diff --git a/bsp/imxrt/imxrt1060-nxp-evk/applications/SConscript b/bsp/imxrt/imxrt1060-nxp-evk/applications/SConscript index 8b955cf5c1..050054c59f 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/applications/SConscript +++ b/bsp/imxrt/imxrt1060-nxp-evk/applications/SConscript @@ -6,17 +6,17 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: if os.path.isfile(os.path.join(cwd, item, 'SConscript')): group = group + SConscript(os.path.join(item, 'SConscript')) - + Return('group') diff --git a/bsp/imxrt/imxrt1060-nxp-evk/board/Kconfig b/bsp/imxrt/imxrt1060-nxp-evk/board/Kconfig index 591a875c4f..16e251a93e 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/board/Kconfig +++ b/bsp/imxrt/imxrt1060-nxp-evk/board/Kconfig @@ -18,7 +18,7 @@ config SOC_MIMXRT1062DVL6A default y menu "Onboard Peripheral Drivers" - + config BSP_USING_SDRAM bool "Enable SDRAM" default n @@ -175,7 +175,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_CACHE bool "Enable CACHE" default n - + endmenu menu "Board extended module Drivers" diff --git a/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript b/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript index 7171ff2a07..4003338493 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript +++ b/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript @@ -21,7 +21,7 @@ CPPDEFINES = ['CPU_MIMXRT1062DVL6A', 'SKIP_SYSCLK_INIT', 'EVK_MCIMXRM', 'FSL_SDK if rtconfig.PLATFORM in ['armcc', 'armclang']: CPPDEFINES.append('__FPU_PRESENT=1') - + group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) Return('group') diff --git a/bsp/imxrt/imxrt1060-nxp-evk/xip/SConscript b/bsp/imxrt/imxrt1060-nxp-evk/xip/SConscript index 8d49bd248d..e68b8522ad 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/xip/SConscript +++ b/bsp/imxrt/imxrt1060-nxp-evk/xip/SConscript @@ -17,9 +17,9 @@ if GetDepend('BSP_USING_4MFLASH'): else: LINKFLAGS = '' - group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - Return('group') + group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) + Return('group') -if GetDepend('BSP_USING_QSPIFLASH'): +if GetDepend('BSP_USING_QSPIFLASH'): group = [] - Return('group') + Return('group') diff --git a/bsp/imxrt/imxrt1064-nxp-evk/SConstruct b/bsp/imxrt/imxrt1064-nxp-evk/SConstruct index 30ea7676b8..6b5bd18f22 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/SConstruct +++ b/bsp/imxrt/imxrt1064-nxp-evk/SConstruct @@ -66,8 +66,5 @@ objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SCons # include drivers objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'))) -# include peripherals -objs.extend(SConscript(os.path.join(libraries_path_prefix, 'peripherals', 'SConscript'))) - # make a building DoBuilding(TARGET, objs) diff --git a/bsp/imxrt/imxrt1064-nxp-evk/applications/SConscript b/bsp/imxrt/imxrt1064-nxp-evk/applications/SConscript index 1e36bcdcf4..050054c59f 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/applications/SConscript +++ b/bsp/imxrt/imxrt1064-nxp-evk/applications/SConscript @@ -6,12 +6,12 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) diff --git a/bsp/imxrt/imxrt1064-nxp-evk/board/Kconfig b/bsp/imxrt/imxrt1064-nxp-evk/board/Kconfig index cd35ef35a3..ef0c5cd4a0 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/board/Kconfig +++ b/bsp/imxrt/imxrt1064-nxp-evk/board/Kconfig @@ -78,7 +78,7 @@ menu "On-chip Peripheral Drivers" config LCD_WIDTH int "width" default 480 - + config LCD_HEIGHT int "height" default 272 @@ -112,24 +112,24 @@ menu "On-chip Peripheral Drivers" endmenu menu "Onboard Peripheral Drivers" - + config BSP_USING_SDRAM bool "Enable SDRAM" default n menuconfig BSP_USING_ETH - bool "Enable Ethernet" - select RT_USING_NETDEV - default n - + bool "Enable Ethernet" + select RT_USING_NETDEV + default n - if BSP_USING_ETH - config BSP_USING_PHY + + if BSP_USING_ETH + config BSP_USING_PHY select RT_USING_PHY - bool "Enable ethernet phy" - default y + bool "Enable ethernet phy" + default y - if BSP_USING_PHY + if BSP_USING_PHY config PHY_DEVICE_ADDRESS int "Specify address of phy device" default 2 @@ -146,7 +146,7 @@ menu "Onboard Peripheral Drivers" config PHY_RESET_PIN int "indicate pin of reset" default 9 - + config FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE bool "Enable the PHY ksz8081 RMII50M mode" depends on PHY_USING_KSZ8081 @@ -154,7 +154,7 @@ menu "Onboard Peripheral Drivers" endif endif - endif + endif endmenu menu "Board extended module Drivers" diff --git a/bsp/imxrt/imxrt1064-nxp-evk/board/SConscript b/bsp/imxrt/imxrt1064-nxp-evk/board/SConscript index d7046f3254..64766406e9 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/board/SConscript +++ b/bsp/imxrt/imxrt1064-nxp-evk/board/SConscript @@ -17,7 +17,7 @@ CPPDEFINES = ['CPU_MIMXRT1064DVL6A', 'SKIP_SYSCLK_INIT', 'EVK_MCIMXRM', 'FSL_SDK if rtconfig.PLATFORM in ['armcc', 'armclang']: CPPDEFINES.append('__FPU_PRESENT=1') - + group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) Return('group') diff --git a/bsp/imxrt/imxrt1064-nxp-evk/xip/SConscript b/bsp/imxrt/imxrt1064-nxp-evk/xip/SConscript index db3794f2de..804f330855 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/xip/SConscript +++ b/bsp/imxrt/imxrt1064-nxp-evk/xip/SConscript @@ -15,9 +15,9 @@ if GetDepend('BSP_USING_4MFLASH'): else: LINKFLAGS = '' - group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - Return('group') + group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) + Return('group') -if GetDepend('BSP_USING_QSPIFLASH'): +if GetDepend('BSP_USING_QSPIFLASH'): group = [] - Return('group') + Return('group') diff --git a/bsp/imxrt/imxrt1170-nxp-evk/SConstruct b/bsp/imxrt/imxrt1170-nxp-evk/SConstruct index 622d3d16f0..c950363404 100644 --- a/bsp/imxrt/imxrt1170-nxp-evk/SConstruct +++ b/bsp/imxrt/imxrt1170-nxp-evk/SConstruct @@ -66,8 +66,5 @@ objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SCons # include drivers objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'))) -# include peripherals -objs.extend(SConscript(os.path.join(libraries_path_prefix, 'peripherals', 'SConscript'))) - # make a building DoBuilding(TARGET, objs) diff --git a/bsp/imxrt/imxrt1170-nxp-evk/applications/SConscript b/bsp/imxrt/imxrt1170-nxp-evk/applications/SConscript index 2c988286bc..ab2275a135 100644 --- a/bsp/imxrt/imxrt1170-nxp-evk/applications/SConscript +++ b/bsp/imxrt/imxrt1170-nxp-evk/applications/SConscript @@ -6,17 +6,17 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.CROSS_TOOL == 'gcc': CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: if os.path.isfile(os.path.join(cwd, item, 'SConscript')): group = group + SConscript(os.path.join(item, 'SConscript')) - + Return('group') diff --git a/bsp/imxrt/imxrt1170-nxp-evk/board/Kconfig b/bsp/imxrt/imxrt1170-nxp-evk/board/Kconfig index 4a7c4985d1..8644fb5e1f 100644 --- a/bsp/imxrt/imxrt1170-nxp-evk/board/Kconfig +++ b/bsp/imxrt/imxrt1170-nxp-evk/board/Kconfig @@ -107,20 +107,20 @@ menu "Onboard Peripheral Drivers" default y if BSP_USING_PHY - config PHY_DEVICE_ADDRESS - int "Specify address of phy device" - default 2 - config PHY_USING_KSZ8081 - bool "i.MX RT1064EVK uses ksz8081 phy" + bool "i.MX RT1176EVK uses ksz8081 phy" default y if PHY_USING_KSZ8081 - config PHY_RESET_PORT + config PHY_KSZ8081_ADDRESS + int "Specify address of phy device" + default 2 + + config PHY_RESET_KSZ8081_PORT int "indicate port of reset" default 6 - config PHY_RESET_PIN + config PHY_RESET_KSZ8081_PIN int "indicate pin of reset" default 12 @@ -129,10 +129,29 @@ menu "Onboard Peripheral Drivers" depends on PHY_USING_KSZ8081 default y endif + endif + if BSP_USING_PHY + config PHY_USING_RTL8211F + bool "i.MX RT1176EVK uses rtl8211f phy" + default y + + if PHY_USING_RTL8211F + config PHY_RTL8211F_ADDRESS + int "Specify address of phy device" + default 1 + + config PHY_RESET_RTL8211F_PORT + int "indicate port of reset" + default 11 + + config PHY_RESET_RTL8211F_PIN + int "indicate pin of reset" + default 14 + + endif endif endif - endmenu menu "Board extended module Drivers" diff --git a/bsp/imxrt/imxrt1170-nxp-evk/xip/SConscript b/bsp/imxrt/imxrt1170-nxp-evk/xip/SConscript index c6e75c661d..65e7fefebc 100644 --- a/bsp/imxrt/imxrt1170-nxp-evk/xip/SConscript +++ b/bsp/imxrt/imxrt1170-nxp-evk/xip/SConscript @@ -16,5 +16,5 @@ if GetDepend('BSP_USING_QSPIFLASH'): else: LINKFLAGS = '' - group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - Return('group') \ No newline at end of file + group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) + Return('group') diff --git a/bsp/imxrt/libraries/Kconfig b/bsp/imxrt/libraries/Kconfig index adcbf26b34..de07c0a64b 100644 --- a/bsp/imxrt/libraries/Kconfig +++ b/bsp/imxrt/libraries/Kconfig @@ -22,8 +22,8 @@ config SOC_IMXRT1064_SERIES bool select ARCH_ARM_CORTEX_M7 select ARCH_ARM_CORTEX_FPU - + config SOC_IMXRT1170_SERIES bool select ARCH_ARM_CORTEX_M7 - select ARCH_ARM_CORTEX_FPU \ No newline at end of file + select ARCH_ARM_CORTEX_FPU diff --git a/bsp/imxrt/libraries/MIMXRT1050/SConscript b/bsp/imxrt/libraries/MIMXRT1050/SConscript index cd7e682947..adf8177948 100644 --- a/bsp/imxrt/libraries/MIMXRT1050/SConscript +++ b/bsp/imxrt/libraries/MIMXRT1050/SConscript @@ -61,7 +61,7 @@ if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_SDIO']): src += ['MIMXRT1052/drivers/fsl_usdhc.c'] - + if GetDepend(['RT_USING_AUDIO']): src += ['MIMXRT1052/drivers/fsl_sai.c'] src += ['MIMXRT1052/drivers/fsl_sai_edma.c'] @@ -75,7 +75,7 @@ if GetDepend(['BSP_USING_DMA']): src += ['MIMXRT1052/drivers/fsl_lpuart_edma.c'] if GetDepend(['BSP_USING_SPI']): src += ['MIMXRT1052/drivers/fsl_lpspi_edma.c'] - + if GetDepend(['BSP_USING_PULSE_ENCODER']): src += ['MIMXRT1052/drivers/fsl_enc.c'] diff --git a/bsp/imxrt/libraries/MIMXRT1060/SConscript b/bsp/imxrt/libraries/MIMXRT1060/SConscript index 84568cbb65..707f78f660 100644 --- a/bsp/imxrt/libraries/MIMXRT1060/SConscript +++ b/bsp/imxrt/libraries/MIMXRT1060/SConscript @@ -74,7 +74,7 @@ if GetDepend(['BSP_USING_ETH']): if GetDepend(['BSP_USING_SDIO']): src += ['MIMXRT1060/drivers/fsl_usdhc.c'] - + if GetDepend(['RT_USING_AUDIO']): src += ['MIMXRT1060/drivers/fsl_sai.c'] src += ['MIMXRT1060/drivers/fsl_sai_edma.c'] @@ -88,7 +88,7 @@ if GetDepend(['BSP_USING_DMA']): src += ['MIMXRT1060/drivers/fsl_lpuart_edma.c'] if GetDepend(['BSP_USING_SPI']): src += ['MIMXRT1060/drivers/fsl_lpspi_edma.c'] - + if GetDepend(['BSP_USING_PULSE_ENCODER']): src += ['MIMXRT1060/drivers/fsl_enc.c'] diff --git a/bsp/imxrt/libraries/MIMXRT1064/SConscript b/bsp/imxrt/libraries/MIMXRT1064/SConscript index be1b31eb08..2217b8c3cb 100644 --- a/bsp/imxrt/libraries/MIMXRT1064/SConscript +++ b/bsp/imxrt/libraries/MIMXRT1064/SConscript @@ -63,7 +63,7 @@ if GetDepend(['RT_USING_AUDIO']): if GetDepend(['BSP_USING_LTDC']): src += ['MIMXRT1064/drivers/'] - + if GetDepend(["BSP_USING_LCD"]): src += ['MIMXRT1064/drivers/fsl_elcdif.c'] diff --git a/bsp/imxrt/libraries/MIMXRT1170/SConscript b/bsp/imxrt/libraries/MIMXRT1170/SConscript index 6a628bae8d..6f5dacb6f6 100644 --- a/bsp/imxrt/libraries/MIMXRT1170/SConscript +++ b/bsp/imxrt/libraries/MIMXRT1170/SConscript @@ -26,20 +26,20 @@ if GetDepend(['BSP_USING_GPIO']): if GetDepend(['BSP_USING_LPUART']): src += ['MIMXRT1176/drivers/fsl_lpuart.c'] - + if GetDepend(['BSP_USING_RTC']): src += ['MIMXRT1176/drivers/fsl_snvs_hp.c'] src += ['MIMXRT1176/drivers/fsl_snvs_lp.c'] - + if GetDepend(['BSP_USING_HWTIMER']) or GetDepend(['BSP_USING_PWM']): src += ['MIMXRT1176/drivers/fsl_gpt.c'] if GetDepend(['BSP_USING_PWM']): - src += ['MIMXRT1176/drivers/fsl_pwm.c'] - + src += ['MIMXRT1176/drivers/fsl_pwm.c'] + if GetDepend(['BSP_USING_SDIO']): src += ['MIMXRT1176/drivers/fsl_usdhc.c'] - + if rtconfig.CROSS_TOOL == 'gcc': group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, ASFLAGS = '$ASFLAGS -D __STARTUP_CLEAR_BSS') else: diff --git a/bsp/imxrt/libraries/drivers/SConscript b/bsp/imxrt/libraries/drivers/SConscript index 60d9654238..cb4be65b6a 100644 --- a/bsp/imxrt/libraries/drivers/SConscript +++ b/bsp/imxrt/libraries/drivers/SConscript @@ -32,13 +32,13 @@ if GetDepend('BSP_USING_PWM'): if GetDepend('BSP_USING_ADC'): src += ['drv_adc.c'] - + if GetDepend('BSP_USING_LPADC'): src += ['drv_lpadc.c'] - + if GetDepend('BSP_USING_CAN'): src += ['drv_can.c'] - + if GetDepend('BSP_USING_SDRAM'): src += ['drv_sdram.c'] @@ -47,19 +47,21 @@ if GetDepend('BSP_USING_LCD'): if GetDepend('BSP_USING_ETH'): src += ['drv_eth.c'] - + if GetDepend('BSP_USING_PHY'): src += ['drv_mdio.c'] if GetDepend('PHY_USING_KSZ8081'): src += ['drv_ksz8081.c'] + if GetDepend('PHY_USING_RTL8211F'): + src += ['drv_rtl8211f.c'] if GetDepend('BSP_USING_AUDIO'): src += ['drv_sai.c'] src += ['bsp_wm8960.c'] - + if GetDepend('BSP_USING_SDIO'): - src += ['drv_sdio.c'] - + src += ['drv_sdio.c'] + if GetDepend('BSP_USING_USB_DEVICE'): src += ['drv_usbd.c'] src += Glob('usb/device/*.c') @@ -67,7 +69,7 @@ if GetDepend('BSP_USING_USB_DEVICE'): if GetDepend('BSP_USING_USB_DEVICE') or GetDepend('RT_USING_USB_HOST'): src += Glob('usb/phy/*.c') CPPDEFINES += ['ENDIANNESS','USE_RTOS'] - + if GetDepend('RT_USING_USB_HOST'): src += ['drv_usbh.c'] src += Glob('usb/host/*.c') diff --git a/bsp/imxrt/libraries/drivers/drv_ksz8081.c b/bsp/imxrt/libraries/drivers/drv_ksz8081.c index f922f5f840..151ef42ab6 100644 --- a/bsp/imxrt/libraries/drivers/drv_ksz8081.c +++ b/bsp/imxrt/libraries/drivers/drv_ksz8081.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -168,7 +168,7 @@ static rt_phy_status rt_phy_init(void *object, rt_uint32_t phy_addr, rt_uint32_t #endif /* FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE */ /* Set the negotiation. */ - result = phy_ksz8081.ops->write(PHY_AUTONEG_ADVERTISE_REG, + result = phy_ksz8081.ops->write(PHY_AUTONEG_ADVERTISE_REG, (PHY_100BASETX_FULLDUPLEX_MASK | PHY_100BASETX_HALFDUPLEX_MASK | PHY_10BASETX_FULLDUPLEX_MASK | PHY_10BASETX_HALFDUPLEX_MASK | 0x1U)); if (PHY_STATUS_OK == result) diff --git a/bsp/imxrt/libraries/drivers/drv_rtl8211f.c b/bsp/imxrt/libraries/drivers/drv_rtl8211f.c new file mode 100644 index 0000000000..d8bb8ff28a --- /dev/null +++ b/bsp/imxrt/libraries/drivers/drv_rtl8211f.c @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2006-2022, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2022-08-15 xjy198903 the first version + */ +#include + +#ifdef PHY_USING_RTL8211F + +#include +#include "drv_gpio.h" +#include "drv_mdio.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +/*! @note The following PHY registers are the IEEE802.3 standard definition, same register and bit field may + have different names in various PHYs, but the feature they represent should be same or very similar. */ + +/*! @brief Defines the IEEE802.3 standard PHY registers. */ +#define PHY_BASICCONTROL_REG 0x00U /*!< The PHY basic control register. */ +#define PHY_BASICSTATUS_REG 0x01U /*!< The PHY basic status register. */ +#define PHY_ID1_REG 0x02U /*!< The PHY ID one register. */ +#define PHY_ID2_REG 0x03U /*!< The PHY ID two register. */ +#define PHY_AUTONEG_ADVERTISE_REG 0x04U /*!< The PHY auto-negotiate advertise register. */ +#define PHY_AUTONEG_LINKPARTNER_REG 0x05U /*!< The PHY auto negotiation link partner ability register. */ +#define PHY_AUTONEG_EXPANSION_REG 0x06U /*!< The PHY auto negotiation expansion register. */ +#define PHY_1000BASET_CONTROL_REG 0x09U /*!< The PHY 1000BASE-T control register. */ +#define PHY_MMD_ACCESS_CONTROL_REG 0x0DU /*!< The PHY MMD access control register. */ +#define PHY_MMD_ACCESS_DATA_REG 0x0EU /*!< The PHY MMD access data register. */ + +/*! @brief Defines the mask flag in basic control register(Address 0x00). */ +#define PHY_BCTL_SPEED1_MASK 0x0040U /*!< The PHY speed bit mask(MSB).*/ +#define PHY_BCTL_ISOLATE_MASK 0x0400U /*!< The PHY isolate mask.*/ +#define PHY_BCTL_DUPLEX_MASK 0x0100U /*!< The PHY duplex bit mask. */ +#define PHY_BCTL_RESTART_AUTONEG_MASK 0x0200U /*!< The PHY restart auto negotiation mask. */ +#define PHY_BCTL_AUTONEG_MASK 0x1000U /*!< The PHY auto negotiation bit mask. */ +#define PHY_BCTL_SPEED0_MASK 0x2000U /*!< The PHY speed bit mask(LSB). */ +#define PHY_BCTL_LOOP_MASK 0x4000U /*!< The PHY loop bit mask. */ +#define PHY_BCTL_RESET_MASK 0x8000U /*!< The PHY reset bit mask. */ + +/*! @brief Defines the mask flag in basic status register(Address 0x01). */ +#define PHY_BSTATUS_LINKSTATUS_MASK 0x0004U /*!< The PHY link status mask. */ +#define PHY_BSTATUS_AUTONEGABLE_MASK 0x0008U /*!< The PHY auto-negotiation ability mask. */ +#define PHY_BSTATUS_SPEEDUPLX_MASK 0x001CU /*!< The PHY speed and duplex mask. */ +#define PHY_BSTATUS_AUTONEGCOMP_MASK 0x0020U /*!< The PHY auto-negotiation complete mask. */ + +/*! @brief Defines the mask flag in PHY auto-negotiation advertise register(Address 0x04). */ +#define PHY_100BaseT4_ABILITY_MASK 0x200U /*!< The PHY have the T4 ability. */ +#define PHY_100BASETX_FULLDUPLEX_MASK 0x100U /*!< The PHY has the 100M full duplex ability.*/ +#define PHY_100BASETX_HALFDUPLEX_MASK 0x080U /*!< The PHY has the 100M full duplex ability.*/ +#define PHY_10BASETX_FULLDUPLEX_MASK 0x040U /*!< The PHY has the 10M full duplex ability.*/ +#define PHY_10BASETX_HALFDUPLEX_MASK 0x020U /*!< The PHY has the 10M full duplex ability.*/ +#define PHY_IEEE802_3_SELECTOR_MASK 0x001U /*!< The message type being sent by Auto-Nego.*/ + +/*! @brief Defines the mask flag in the 1000BASE-T control register(Address 0x09). */ +#define PHY_1000BASET_FULLDUPLEX_MASK 0x200U /*!< The PHY has the 1000M full duplex ability.*/ +#define PHY_1000BASET_HALFDUPLEX_MASK 0x100U /*!< The PHY has the 1000M half duplex ability.*/ + +/*! @brief Defines the PHY RTL8211F vendor defined registers. */ +#define PHY_SPECIFIC_STATUS_REG 0x1AU /*!< The PHY specific status register. */ +#define PHY_PAGE_SELECT_REG 0x1FU /*!< The PHY page select register. */ + +/*! @brief Defines the PHY RTL8211F ID number. */ +#define PHY_CONTROL_ID1 0x001CU /*!< The PHY ID1 . */ + +/*! @brief Defines the mask flag in specific status register. */ +#define PHY_SSTATUS_LINKSTATUS_MASK 0x04U /*!< The PHY link status mask. */ +#define PHY_SSTATUS_LINKSPEED_MASK 0x30U /*!< The PHY link speed mask. */ +#define PHY_SSTATUS_LINKDUPLEX_MASK 0x08U /*!< The PHY link duplex mask. */ +#define PHY_SSTATUS_LINKSPEED_SHIFT 4U /*!< The link speed shift */ + +/*! @brief Defines the PHY RTL8211F extra page and the registers in specified page. */ +#define PHY_PAGE_RGMII_TXRX_DELAY_ADDR 0xD08U /*!< The register page including RGMII TX/RX delay setting. */ +#define PHY_RGMII_TX_DELAY_REG 0x11U /*!< The RGMII TXC delay register. */ +#define PHY_RGMII_RX_DELAY_REG 0x15U /*!< The RGMII RXC delay register. */ +#define PHY_RGMII_TX_DELAY_MASK 0x100U /*!< The RGMII TXC delay mask. */ +#define PHY_RGMII_RX_DELAY_MASK 0x8U /*!< The RGMII RXC delay mask. */ + +/*! @brief MDIO MMD Devices .*/ +#define PHY_MDIO_MMD_PCS 3U +#define PHY_MDIO_MMD_AN 7U + +/*! @brief MDIO MMD Physical Coding layer device registers .*/ +#define PHY_MDIO_PCS_EEE_CAP 0x14U /* EEE capability */ + +/*! @brief MDIO MMD AutoNegotiation device registers .*/ +#define PHY_MDIO_AN_EEE_ADV 0x3CU /* EEE advertisement */ + +/*! @brief MDIO MMD EEE mask flags. (common for adv and cap) */ +#define PHY_MDIO_EEE_100TX 0x2U +#define PHY_MDIO_EEE_1000T 0x4U + +/*! @brief Defines the timeout macro. */ +#define PHY_READID_TIMEOUT_COUNT 1000U + +/* defined the Reset pin, PORT and PIN config by menuconfig */ +#define RESET_PIN GET_PIN(PHY_RESET_RTL8211F_PORT, PHY_RESET_RTL8211F_PIN) + +/*! @brief Defines the PHY MMD data access mode. */ +typedef enum _phy_mmd_access_mode +{ + kPHY_MMDAccessNoPostIncrement = (1U << 14), /*!< ENET PHY MMD access data with no address post increment. */ + kPHY_MMDAccessRdWrPostIncrement = + (2U << 14), /*!< ENET PHY MMD access data with Read/Write address post increment. */ + kPHY_MMDAccessWrPostIncrement = (3U << 14), /*!< ENET PHY MMD access data with Write address post increment. */ +} phy_mmd_access_mode_t; + +/******************************************************************************* + * Prototypes + ******************************************************************************/ + +/******************************************************************************* + * Variables + ******************************************************************************/ + +static struct rt_phy_device phy_rtl8211f; + +/******************************************************************************* + * Code + ******************************************************************************/ + +static inline rt_bool_t read_reg(rt_mdio_t *bus, rt_uint32_t addr, rt_uint32_t reg_id, rt_uint32_t *value) +{ + if (4 != bus->ops->read(bus, addr, reg_id, value, 4)) + { + return RT_FALSE; + } + return RT_TRUE; +} + +static inline rt_bool_t write_reg(rt_mdio_t *bus, rt_uint32_t addr, rt_uint32_t reg_id, rt_uint32_t value) +{ + if (4 != bus->ops->write(bus, addr, reg_id, &value, 4)) + { + return RT_FALSE; + } + return RT_TRUE; +} + +static inline status_t PHY_RTL8211F_MMD_WriteData(uint32_t data) +{ + return phy_rtl8211f.ops->write(PHY_MMD_ACCESS_DATA_REG, data); +} + +static status_t PHY_RTL8211F_MMD_SetDevice(uint8_t device, + uint16_t addr, + phy_mmd_access_mode_t mode) +{ + status_t result = PHY_STATUS_OK; + + /* Set Function mode of address access(b00) and device address. */ + result = phy_rtl8211f.ops->write(PHY_MMD_ACCESS_CONTROL_REG, device); + if (result != PHY_STATUS_OK) + { + return result; + } + + /* Set register address. */ + result = phy_rtl8211f.ops->write(PHY_MMD_ACCESS_DATA_REG, addr); + if (result != PHY_STATUS_OK) + { + return result; + } + + /* Set Function mode of data access(b01~11) and device address. */ + result = phy_rtl8211f.ops->write(PHY_MMD_ACCESS_CONTROL_REG, (uint32_t)mode | (uint32_t)device); + return result; +} + +static status_t PHY_RTL8211F_MMD_Write(uint8_t device, uint16_t addr, uint32_t data) +{ + status_t result = PHY_STATUS_OK; + + result = PHY_RTL8211F_MMD_SetDevice(device, addr, kPHY_MMDAccessNoPostIncrement); + if (result == PHY_STATUS_OK) + { + result = PHY_RTL8211F_MMD_WriteData(data); + } + return result; +} + +static rt_phy_status rt_phy_init(void *object, rt_uint32_t phy_addr, rt_uint32_t src_clock_hz) +{ + rt_bool_t ret; + rt_phy_status result; + rt_uint32_t counter = PHY_READID_TIMEOUT_COUNT; + rt_uint32_t regValue = 0U; + + // reset phy device by gpio + rt_pin_mode(RESET_PIN, PIN_MODE_OUTPUT); + rt_pin_write(RESET_PIN, PIN_LOW); + rt_thread_mdelay(10); + rt_pin_write(RESET_PIN, PIN_HIGH); + rt_thread_mdelay(30); + + rt_mdio_t *mdio_bus = rt_hw_mdio_register(object, "phy_mdio"); + if (RT_NULL == mdio_bus) + { + return PHY_STATUS_FAIL; + } + phy_rtl8211f.bus = mdio_bus; + phy_rtl8211f.addr = phy_addr; + ret = mdio_bus->ops->init(mdio_bus, src_clock_hz); + if (!ret) + { + return PHY_STATUS_FAIL; + } + + /* Check PHY ID. */ + do + { + result = phy_rtl8211f.ops->read(PHY_ID1_REG, ®Value); + if (result != PHY_STATUS_OK) + { + return result; + } + counter--; + } while ((regValue != PHY_CONTROL_ID1) && (counter != 0U)); + + if (counter == 0U) + { + return PHY_STATUS_FAIL; + } + + /* Reset PHY. */ + result = phy_rtl8211f.ops->write(PHY_BASICCONTROL_REG, PHY_BCTL_RESET_MASK); + if (result != PHY_STATUS_OK) + { + return result; + } + + /* The RGMII specifies output TXC/RXC and TXD/RXD without any clock skew. Need to add skew on clock line + to make sure the other side sample right data. This can also be done in PCB traces. */ + result = phy_rtl8211f.ops->write(PHY_PAGE_SELECT_REG, PHY_PAGE_RGMII_TXRX_DELAY_ADDR); + if (PHY_STATUS_OK != result) + { + return result; + } + + /* Set Tx Delay */ + result = phy_rtl8211f.ops->read(PHY_RGMII_TX_DELAY_REG, ®Value); + if (PHY_STATUS_OK == result) + { + regValue |= PHY_RGMII_TX_DELAY_MASK; + result = phy_rtl8211f.ops->write(PHY_RGMII_TX_DELAY_REG, regValue); + if (result != PHY_STATUS_OK) + { + return result; + } + } + else + { + return result; + } + + /* Set Rx Delay */ + result = phy_rtl8211f.ops->read(PHY_RGMII_RX_DELAY_REG, ®Value); + if (PHY_STATUS_OK == result) + { + regValue |= PHY_RGMII_RX_DELAY_MASK; + result = phy_rtl8211f.ops->write(PHY_RGMII_RX_DELAY_REG, regValue); + if (result != PHY_STATUS_OK) + { + return result; + } + } + else + { + return result; + } + + /* Restore to default page 0 */ + result = phy_rtl8211f.ops->write(PHY_PAGE_SELECT_REG, 0x0); + if (result != PHY_STATUS_OK) + { + return result; + } + + // disabled EEE + result = PHY_RTL8211F_MMD_Write(PHY_MDIO_MMD_AN, PHY_MDIO_AN_EEE_ADV, 0); + if (result != PHY_STATUS_OK) + { + return result; + } + + /* Set the auto-negotiation. */ + result = phy_rtl8211f.ops->write(PHY_AUTONEG_ADVERTISE_REG, + PHY_100BASETX_FULLDUPLEX_MASK | PHY_100BASETX_HALFDUPLEX_MASK | PHY_10BASETX_FULLDUPLEX_MASK | + PHY_10BASETX_HALFDUPLEX_MASK | PHY_IEEE802_3_SELECTOR_MASK); + if (result == PHY_STATUS_OK) + { + result = phy_rtl8211f.ops->write(PHY_1000BASET_CONTROL_REG, PHY_1000BASET_FULLDUPLEX_MASK); + if (result == PHY_STATUS_OK) + { + result = phy_rtl8211f.ops->read(PHY_BASICCONTROL_REG, ®Value); + if (result == PHY_STATUS_OK) + { + result = phy_rtl8211f.ops->write(PHY_BASICCONTROL_REG, (regValue | PHY_BCTL_AUTONEG_MASK | PHY_BCTL_RESTART_AUTONEG_MASK)); + } + } + } + + return result; +} + +static rt_phy_status rt_phy_read(rt_uint32_t reg, rt_uint32_t *data) +{ + rt_mdio_t *mdio_bus = phy_rtl8211f.bus; + rt_uint32_t device_id = phy_rtl8211f.addr; + + if (read_reg(mdio_bus, device_id, reg, data)) + { + return PHY_STATUS_OK; + } + return PHY_STATUS_FAIL; +} + +static rt_phy_status rt_phy_write(rt_uint32_t reg, rt_uint32_t data) +{ + rt_mdio_t *mdio_bus = phy_rtl8211f.bus; + rt_uint32_t device_id = phy_rtl8211f.addr; + + if (write_reg(mdio_bus, device_id, reg, data)) + { + return PHY_STATUS_OK; + } + return PHY_STATUS_FAIL; +} + +static rt_phy_status rt_phy_loopback(rt_uint32_t mode, rt_uint32_t speed, rt_bool_t enable) +{ + /* This PHY only supports local loopback. */ + // rt_assert(mode == PHY_LOCAL_LOOP); + + status_t result; + uint32_t regValue; + + /* Set the loop mode. */ + if (enable) + { + if (speed == PHY_SPEED_1000M) + { + regValue = PHY_BCTL_SPEED1_MASK | PHY_BCTL_DUPLEX_MASK | PHY_BCTL_LOOP_MASK; + } + else if (speed == PHY_SPEED_100M) + { + regValue = PHY_BCTL_SPEED0_MASK | PHY_BCTL_DUPLEX_MASK | PHY_BCTL_LOOP_MASK; + } + else + { + regValue = PHY_BCTL_DUPLEX_MASK | PHY_BCTL_LOOP_MASK; + } + result = phy_rtl8211f.ops->write(PHY_BASICCONTROL_REG, regValue); + } + else + { + /* First read the current status in control register. */ + result = phy_rtl8211f.ops->read(PHY_BASICCONTROL_REG, ®Value); + if (result == PHY_STATUS_OK) + { + regValue &= ~PHY_BCTL_LOOP_MASK; + result = phy_rtl8211f.ops->write(PHY_BASICCONTROL_REG, (regValue | PHY_BCTL_RESTART_AUTONEG_MASK)); + } + } + return result; +} + +static rt_phy_status get_link_status(rt_bool_t *status) +{ + // assert(status); + + status_t result; + uint32_t regValue; + + /* Read the basic status register. */ + result = phy_rtl8211f.ops->read(PHY_SPECIFIC_STATUS_REG, ®Value); + if (result == PHY_STATUS_OK) + { + if ((PHY_SSTATUS_LINKSTATUS_MASK & regValue) != 0U) + { + /* Link up. */ + *status = true; + } + else + { + /* Link down. */ + *status = false; + } + } + return result; +} + +static rt_phy_status get_link_speed_duplex(rt_uint32_t *speed, rt_uint32_t *duplex) +{ + // assert(!((speed == NULL) && (duplex == NULL))); + + status_t result; + uint32_t regValue; + + /* Read the status register. */ + result = phy_rtl8211f.ops->read(PHY_SPECIFIC_STATUS_REG, ®Value); + if (result == PHY_STATUS_OK) + { + if (speed != NULL) + { + switch ((regValue & PHY_SSTATUS_LINKSPEED_MASK) >> PHY_SSTATUS_LINKSPEED_SHIFT) + { + case (uint32_t)PHY_SPEED_10M: + *speed = PHY_SPEED_10M; + break; + case (uint32_t)PHY_SPEED_100M: + *speed = PHY_SPEED_100M; + break; + case (uint32_t)PHY_SPEED_1000M: + *speed = PHY_SPEED_1000M; + break; + default: + *speed = PHY_SPEED_10M; + break; + } + } + + if (duplex != NULL) + { + if ((regValue & PHY_SSTATUS_LINKDUPLEX_MASK) != 0U) + { + *duplex = PHY_FULL_DUPLEX; + } + else + { + *duplex = PHY_HALF_DUPLEX; + } + } + } + return result; +} + +static struct rt_phy_ops phy_ops = + { + .init = rt_phy_init, + .read = rt_phy_read, + .write = rt_phy_write, + .loopback = rt_phy_loopback, + .get_link_status = get_link_status, + .get_link_speed_duplex = get_link_speed_duplex, +}; + +static int rt_phy_rtl8211f_register(void) +{ + phy_rtl8211f.ops = &phy_ops; + rt_hw_phy_register(&phy_rtl8211f, "rtl8211f"); + return 1; +} + +INIT_DEVICE_EXPORT(rt_phy_rtl8211f_register); +#endif /* PHY_USING_RTL8211F */ diff --git a/bsp/imxrt/libraries/templates/imxrt1050xxx/applications/SConscript b/bsp/imxrt/libraries/templates/imxrt1050xxx/applications/SConscript index 26c10c855f..9efbc795ab 100644 --- a/bsp/imxrt/libraries/templates/imxrt1050xxx/applications/SConscript +++ b/bsp/imxrt/libraries/templates/imxrt1050xxx/applications/SConscript @@ -5,12 +5,12 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) Return('group') diff --git a/bsp/imxrt/libraries/templates/imxrt1050xxx/board/Kconfig b/bsp/imxrt/libraries/templates/imxrt1050xxx/board/Kconfig index 09e4c4e637..75043b08e1 100644 --- a/bsp/imxrt/libraries/templates/imxrt1050xxx/board/Kconfig +++ b/bsp/imxrt/libraries/templates/imxrt1050xxx/board/Kconfig @@ -1,7 +1,7 @@ menu "Hardware Drivers Config" config SOC_IMXRT1052CVL5B - bool + bool select SOC_MIMXRT1050_SERIES select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN @@ -12,7 +12,7 @@ menu "On-chip Peripheral Drivers" config BSP_USING_DMA bool "Enable DMA" default n - + config BSP_USING_GPIO bool "Enable GPIO" select RT_USING_PIN @@ -22,7 +22,7 @@ menu "On-chip Peripheral Drivers" bool "Enable UART" select RT_USING_SERIAL default y - + if BSP_USING_LPUART config BSP_USING_LPUART1 bool "Enable LPUART1" diff --git a/bsp/imxrt/libraries/templates/imxrt1064xxx/applications/SConscript b/bsp/imxrt/libraries/templates/imxrt1064xxx/applications/SConscript index 26c10c855f..9efbc795ab 100644 --- a/bsp/imxrt/libraries/templates/imxrt1064xxx/applications/SConscript +++ b/bsp/imxrt/libraries/templates/imxrt1064xxx/applications/SConscript @@ -5,12 +5,12 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -# add for startup script +# add for startup script if rtconfig.PLATFORM in ['gcc']: CPPDEFINES = ['__START=entry'] else: CPPDEFINES = [] - + group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) Return('group') diff --git a/bsp/imxrt/libraries/templates/imxrt1064xxx/xip/SConscript b/bsp/imxrt/libraries/templates/imxrt1064xxx/xip/SConscript index db3794f2de..804f330855 100644 --- a/bsp/imxrt/libraries/templates/imxrt1064xxx/xip/SConscript +++ b/bsp/imxrt/libraries/templates/imxrt1064xxx/xip/SConscript @@ -15,9 +15,9 @@ if GetDepend('BSP_USING_4MFLASH'): else: LINKFLAGS = '' - group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) - Return('group') + group = DefineGroup('xip', src, depend = [''], CPPPATH = CPPPATH, LINKFLAGS = LINKFLAGS) + Return('group') -if GetDepend('BSP_USING_QSPIFLASH'): +if GetDepend('BSP_USING_QSPIFLASH'): group = [] - Return('group') + Return('group')