drivers: flash: Addition of MCHP g3 driver#109747
Conversation
sr-mchp
commented
May 25, 2026
- Addition of device tree nodes for supporting flash peripheral for PIC32CZ_CA series of devices.
- Flash G3 driver implementation.
- Update to the board metadata to list flash partitions and sections to support pic32cz_ca80 and pic32cz_ca90 series of boards.
- Addition of board overlay files to enable flash tests.
4d35b74 to
68a62f2
Compare
68a62f2 to
3460766
Compare
nandojve
left a comment
There was a problem hiding this comment.
Overall seems fine.
I only recommend you do another pass and separate distinct logical blocks to make a easy reading.
| soc { | ||
| flash0: flash@8000000 { | ||
| reg = <0x08000000 DT_SIZE_M(1)>; | ||
| nvmctrl: nvmctrl@44002000 { |
There was a problem hiding this comment.
Hi,
Fix all the commit messages:
brief: 52 chars
description: <=72
dts: arm: microchip: NVMCTRL/Flash G3 driver
Added device tree nodes and binding files for supporting NVMCTRL and
Flash peripherals for PIC32CZ_CA series of devices.
| static inline const struct flash_config *get_flash_config(const struct device *dev) | ||
| { | ||
| if (dev->ops.init != NULL) { | ||
| #if MCHP_CHOSEN_FLASH_COVERS_ALL |
There was a problem hiding this comment.
There is ways in zephyr to check if the app chose a bootloader.
Could that works here? Is there other use cases that are not only a special bootloader usecase?
| } | ||
| k_sem_take(&data->mutex_lock, K_FOREVER); | ||
| (void)memcpy(data_buff, (uint32_t *)(config->base_addr + offset), no_of_bytes); | ||
| k_sem_give(&data->mutex_lock); |
There was a problem hiding this comment.
Is easy to read when you separate these two distinct logical blocks.
}
+
k_sem_take(&data->mutex_lock, K_FOREVER);
(void)memcpy(data_buff, (uint32_t *)(config->base_addr + offset), no_of_bytes);
k_sem_give(&data->mutex_lock);I mean, the below is not tight with the previous operation.
You could apply this in other places to make this distinction.
| #define FLASH_MCHP_G3_CONFIG_PAGE_LAYOUT(n) | ||
| #endif /* CONFIG_FLASH_PAGE_LAYOUT */ | ||
|
|
||
| #define MCHP_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
There was a problem hiding this comment.
In zephyr we define many util functions in include/sys/. I recommend a visit there to check the options.
zephyr/include/zephyr/sys/util.h
Line 391 in cdb5827
| - pic32cz_ca80_cult | ||
| - pic32cz_ca90_cult |
There was a problem hiding this comment.
The main goal is make sure that NVMCTRL_G3 is tested. No need to add 2 devices that share the same driver.
sunil-abraham
left a comment
There was a problem hiding this comment.
Driver modification needed from an architectural perspective.
| /* App build: zephyr,flash (flash1) covers all partitions. | ||
| * Redirect to the child device (same as old sanitize_dev). | ||
| */ | ||
| const struct device *chosen = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash)); |
There was a problem hiding this comment.
Using DT_CHOSEN(zephyr_flash) inside a flash driver does not make architectural sense. Please refactor the code.
|
|
||
| return (const struct flash_config *)chosen->config; | ||
| #else | ||
| /* MCUboot build: zephyr,flash (flash0/BFM) is too small. |
There was a problem hiding this comment.
Driver should not depend on the application using it. Please modify the design.
3460766 to
13d3b6d
Compare
Devicetree & binding files for NVMCTRL PIC32CZ_CA series of devices Signed-off-by: Shankar Ramasamy <shankar.ramasamy@microchip.com>
13d3b6d to
53f4fb2
Compare
NVMCTRL G3 driver implementation to support PIC32CZ_CA device series Signed-off-by: Shankar Ramasamy <shankar.ramasamy@microchip.com>
Add Flash partitions and board metadata for pic32cz_ca80/90_cult boards Signed-off-by: Shankar Ramasamy <shankar.ramasamy@microchip.com>
Add board support files for pic32cz_ca80_cult to enable Flash test cases Signed-off-by: Shankar Ramasamy <shankar.ramasamy@microchip.com>
53f4fb2 to
db58da7
Compare
|
|
|
||
| config FLASH_MCHP_NVMCTRL_G1 | ||
| bool "Microchip G1 Flash Driver for NVMCTRL" | ||
| bool |
| space, not just at aligned addresses. | ||
|
|
||
| config FLASH_MCHP_NVMCTRL_G3 | ||
| bool |
|
|
||
| LOG_MODULE_REGISTER(flash_mchp_nvmctrl_g3); | ||
|
|
||
| #define SOC_NV_FLASH_NODE DT_NODELABEL(flash0) |
There was a problem hiding this comment.
shouldn't be using node labels inside driver, use instance macros.
| } | ||
| static struct nvmctrl_data nvmctrl_g3_data; | ||
| static const struct nvmctrl_config nvmctrl_g3_config = { | ||
| .clock_dev = DEVICE_DT_GET(DT_NODELABEL(clock)), |
There was a problem hiding this comment.
what clock is that? this is not properly structured.
There was a problem hiding this comment.
In general you shouldn't rely on node labels in drivers, they can be changed easily.
| soc { | ||
| flash0: flash@8000000 { | ||
| reg = <0x08000000 DT_SIZE_M(1)>; | ||
| nvmctrl: nvmctrl@44002000 { |
There was a problem hiding this comment.
| nvmctrl: nvmctrl@44002000 { | |
| nvmctrl: flash-comtroller@44002000 { |
apply for all occurrences
There was a problem hiding this comment.
Why does this header exist!?
| */ | ||
|
|
||
| /** | ||
| * @file mchp_nvmctrl_g3.h |
There was a problem hiding this comment.
missing API versioning
https://docs.zephyrproject.org/latest/contribute/style/doxygen.html#api-versioning
| extra_args: | ||
| - DTC_OVERLAY_FILE="./boards/${BOARD}_andestech_qspi_nor_xip.overlay" | ||
| - CONF_FILE="./prj.conf ./boards/${BOARD}_andestech_qspi_nor_xip.conf" | ||
| drivers.flash.common.mchp_pic32: |
There was a problem hiding this comment.
why is a new test scenario needed since it's not applying any special config.
drivers.flash.common.default does it.
| - frdm_imxrt1186/mimxrt1186/cm7 | ||
| integration_platforms: | ||
| - nrf9160dk/nrf9160 | ||
| drivers.flash.erase_blocks: |
There was a problem hiding this comment.
| drivers.flash.erase_blocks: |
| dt_label_compat_enabled("slot1_partition", "zephyr,mapped-partition")) | ||
| integration_platforms: | ||
| - imx95_evk/mimx9596/m7 | ||
| drivers.flash.interface_test: |
There was a problem hiding this comment.
| drivers.flash.interface_test: |


