-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Add minimal support for Microchip SAMA7G54-EK #89145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minimal support for Microchip SAMA7G54-EK #89145
Conversation
Hello @TonyHan11, and thank you very much for your first pull request to the Zephyr project! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds minimal support for the Microchip SAMA7G54-EK board by implementing necessary updates and drivers for USART, pinctrl, MFD (Flexcom), clock control, and the board definition.
- In usart_sam.c, initialization levels and baudrate calculations are updated to support board‐specific clock configurations.
- New drivers are added for pinctrl, flexcom, and clock control modules, along with a new board YAML file for sama7g54_ek.
Reviewed Changes
Copilot reviewed 44 out of 58 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
drivers/serial/usart_sam.c | Updated initialization level macros and baudrate calculation logic. |
drivers/pinctrl/pinctrl_sam_pio4.c | New pin configuration driver for SAM PIO, with potential bit-clear issues. |
drivers/mfd/mfd_mchp_sam_flexcom.c | Added minimal flexcom support using DT properties and logging. |
drivers/clock_control/clock_control_sama7g5_sckc.c | New clock control driver for SCKC manage oscillator selection. |
drivers/clock_control/clock_control_sama7g5_pmc.c | Implements PMC clock control with DT-based configuration. |
boards/microchip/sam/sama7g54_ek/board.yml | Board definition added for SAMA7G54-EK. |
Files not reviewed (14)
- boards/microchip/sam/sama7g54_ek/Kconfig.defconfig: Language not supported
- boards/microchip/sam/sama7g54_ek/Kconfig.sama7g54_ek: Language not supported
- boards/microchip/sam/sama7g54_ek/doc/index.rst: Language not supported
- boards/microchip/sam/sama7g54_ek/sama7g54_ek.dts: Language not supported
- boards/microchip/sam/sama7g54_ek/sama7g54_ek_defconfig: Language not supported
- drivers/clock_control/CMakeLists.txt: Language not supported
- drivers/clock_control/Kconfig.sam: Language not supported
- drivers/mfd/CMakeLists.txt: Language not supported
- drivers/mfd/Kconfig: Language not supported
- drivers/mfd/Kconfig.mchp_sam: Language not supported
- drivers/pinctrl/CMakeLists.txt: Language not supported
- drivers/pinctrl/Kconfig.sam: Language not supported
- drivers/serial/Kconfig.usart_sam: Language not supported
- drivers/timer/CMakeLists.txt: Language not supported
0b28dd6
to
9b8a328
Compare
soc/microchip/sam/Kconfig.defconfig
Outdated
default y | ||
depends on DT_HAS_MICROCHIP_SAMA5D2_FLEXCOM_ENABLED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the underlying driver should select MFD since it requires it, not do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the config here will be removed and add select MFD
in config USART_SAM
. Thanks.
if BOARD_SAMA7G54_EK | ||
|
||
config SYS_CLOCK_HW_CYCLES_PER_SEC | ||
default 10000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to come from dts property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config here will be removed and add CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=10000000
to boards/microchip/sam/sama7g54_ek/sama7g54_ek_defconfig
. Thank you very much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you need to get it from a dts property, if you just move this to a defconfig you're going to get the same nack and comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll try to get it from the DT. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to come from dts property
Hi @nordicjm ,
I haven't found a way to get this config from dts. As it is described in Kernel/Kconfig, this option is set by the SOC's or board's Kconfig file.
Might it is confused with another option.
In the support for other boards SYS_CLOCK_HW_CYCLES_PER_SEC
come from the defconfig too (see grep -Hnr SYS_CLOCK_HW_CYCLES_PER_SEC boards/
).
Thank you for your advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zephyr/soc/atmel/sam/Kconfig.defconfig
Lines 17 to 18 in 4d848eb
config SYS_CLOCK_HW_CYCLES_PER_SEC | |
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nandojve Got it, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert to webp, then put through https://tinypng.com/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks.
|
||
CONFIG_CONSOLE=y | ||
CONFIG_SERIAL=y | ||
# CONFIG_BOOT_BANNER is not set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# CONFIG_BOOT_BANNER is not set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons of do not output the banner are list bellow:
- As
k_calloc()
is used in the clock drivers, the initialize level of clock-controller needs bePOST_KERNEL
- The serial for console used clock-controller for initialize, so the initialize level of it needs to be
POST_KERNEL
too - The banner is designed to be output before
POST_KERNEL
, in this case skip it to avoid the boot stuck due to the serial is not ready then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this does not work then your board/soc/driver setup fails the minimum requirement for zephyr and needs to be reworked to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll remove all the k_calloc()
to make it work.
CONFIG_UART_CONSOLE=y | ||
CONFIG_USART_SAM=y | ||
CONFIG_CLOCK_CONTROL_FIXED_RATE_CLOCK=y | ||
CONFIG_HEAP_MEM_POOL_SIZE=32768 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIG_HEAP_MEM_POOL_SIZE=32768 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In code of clock drivers (soc/microchip/sam/common
), k_calloc()
are used for acquiring memories for struct of clocks. The default value of CONFIG_HEAP_MEM_POOL_SIZE
is 0
and it would cause k_calloc()
fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part that feels wrong, SoC code shouldn't depend on heap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a clock driver should frankly not need malloc at all, I would say something is very wrong with your driver design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @nordic-krch for comment
drivers/serial/usart_sam.c
Outdated
#define DT_DRV_COMPAT atmel_sam_usart | ||
#ifdef CONFIG_DT_HAS_MICROCHIP_AT91SAM9260_USART_ENABLED | ||
#undef DT_DRV_COMPAT | ||
#define DT_DRV_COMPAT microchip_at91sam9260_usart | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename the driver instead? Ping @decsny
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nordicjm What do you mean with rename the driver ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atmel_sam_usart
just seems to be microchip_at91sam9260_usart
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a new driver for usart
to avoid #undef
and #define
. Thank you for your comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more meaning why not just use the existing name? Why does need a new binding and driver name when the driver (and, I assume silicon) is the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver is the same (for USART standalone vs Flexcom (USART/TWI/SPI included) peripheral), actually I used it to handle the initialize level issue. We can use the driver after solving the k_calloc()
issue, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atmel_sam_usart
just seems to bemicrochip_at91sam9260_usart
?
Ahh ok.
What I understood is that maybe we need to support multiple dts bindings here. The MCHP will start to send a lot of new bindings that can be shared between Microchip/Atmel because the driver is the same. I assume this will be something common over the time.
For instance, in the past I fixed the the Ethernet and shared between to complete different series like this:
zephyr/drivers/ethernet/eth_sam_gmac.c
Lines 22 to 26 in 95db3a6
#if defined(CONFIG_SOC_FAMILY_ATMEL_SAM) | |
#define DT_DRV_COMPAT atmel_sam_gmac | |
#else | |
#define DT_DRV_COMPAT atmel_sam0_gmac | |
#endif |
So, the outcome for me is define the acceptable pattern to allow multiple bindings inside the driver.
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
Update west.yml for SAMA7G54 HAL Signed-off-by: Tony Han <tony.han@microchip.com>
0c75ff0
to
b15ce8e
Compare
Product URL: https://www.microchip.com/en-us/product/SAMA7G54 Signed-off-by: Tony Han <tony.han@microchip.com>
Product URL: https://www.microchip.com/en-us/development-tool/ev21h18a Signed-off-by: Tony Han <tony.han@microchip.com>
Add code for sama7g5 Generic Clock, Main Clock, Main System Bus Clock, Peripheral Clock, Programmable Clock and PLL Clock. Signed-off-by: Tony Han <tony.han@microchip.com>
Initialize the configurations for PMC driver. Add implement of the API for PMC clocks. Signed-off-by: Tony Han <tony.han@microchip.com>
Add driver for sama7g5 Slow Clock Controller (SCKC). Signed-off-by: Tony Han <tony.han@microchip.com>
The FLEXCOM offers several serial communication protocols that are managed by the three sub-modules USART, SPI, and TWI (I2C). Signed-off-by: Tony Han <tony.han@microchip.com>
The USART is compatiable with the USART feature in sama7g5's Flexcom. Update serial/usart_sam to support sama7g5. Signed-off-by: Tony Han <tony.han@microchip.com>
Support pull up/down, open drain for sam7g5's PIO. Signed-off-by: Tony Han <tony.han@microchip.com>
Use pit64b0 as systick, make "kernel sleep/uptime" commands work. Signed-off-by: Tony Han <tony.han@microchip.com>
Add the base DTSI file for Microchip sama7g5. Signed-off-by: Tony Han <tony.han@microchip.com>
Introduce sama7g54_ek.dts for sama7g54_ek board. Signed-off-by: Tony Han <tony.han@microchip.com>
b15ce8e
to
0bf699e
Compare
|
@nandojve |
Let's wait a bit for @nordicjm to confirm he's +1 on the additional changes but let's proceed to merge otherwise as he had previously approved |
Hi @TonyHan11! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
Need: zephyrproject-rtos/hal_microchip#27