-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Support QSPI Flash driver for Renesas RA6 devices #78959
base: main
Are you sure you want to change the base?
Support QSPI Flash driver for Renesas RA6 devices #78959
Conversation
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
d793e21
to
96a9f25
Compare
enum qspi_flash_ex_op_types { | ||
QSPI_FLASH_EX_OP_RESET = 0, | ||
QSPI_FLASH_EX_OP_EXIT_QPI = 1, | ||
}; |
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.
Please insert blank line.
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 fixed it. Thank you for your comment.
96a9f25
to
92e6654
Compare
92e6654
to
8187848
Compare
reg: | ||
required: true | ||
|
||
size: |
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.
Renesas specific property should have renesas,
prefix.
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.
@soburi : Thank you for your feedback. We decided to keep it as current because I saw that other vendors have similar declaration and as comment in #76134 (comment), we understand that it's still in Renesas specific.
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.
Issue with EX_OP and mostly nits regarding other areas.
|
||
#define QSPI_CMD_RESET_EN (0x66) /* Reset Enable */ | ||
#define QSPI_CMD_RESET_MEM (0x99) /* Reset Memory */ | ||
#define Ex_SPI_CMD_READ_ID (0x9F) /* Extended Spi Read JEDEC ID */ |
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.
Spi->SPI
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.
We fixed it. We changed to use macros in https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/flash/spi_nor.h
#define QSPI_CMD_RESET_EN (0x66) /* Reset Enable */ | ||
#define QSPI_CMD_RESET_MEM (0x99) /* Reset Memory */ | ||
#define Ex_SPI_CMD_READ_ID (0x9F) /* Extended Spi Read JEDEC ID */ | ||
#define QSPI_CMD_READ_ID (0xAF) /* Qpi Read JEDEC ID */ |
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.
Qpi->QSPI
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 isn't typo. We mentioned QPI mode (4-4-4) here.
#define QSPI_CMD_RESET_MEM (0x99) /* Reset Memory */ | ||
#define Ex_SPI_CMD_READ_ID (0x9F) /* Extended Spi Read JEDEC ID */ | ||
#define QSPI_CMD_READ_ID (0xAF) /* Qpi Read JEDEC ID */ | ||
#define QSPI_CMD_READ_SFDP (0x5A) /* Read SFDP */ |
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.
Most of those defines are actually provided here https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/flash/spi_nor.h, I know the naming is SPI_NOR, but adding additional defines only brings new names for functionally the same things.
You could just use the SPI_NOR defines and define these that are not provided by the header.
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.
We changed to use macros in https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/flash/spi_nor.h
@@ -13,6 +13,11 @@ enum ra_ex_ops { | |||
FLASH_RA_EX_OP_WRITE_PROTECT = FLASH_EX_OP_VENDOR_BASE, | |||
}; | |||
|
|||
enum qspi_flash_ex_op_types { | |||
QSPI_FLASH_EX_OP_RESET = 0, |
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.
There is already system wide id for reset
FLASH_EX_OP_RESET = 0
zephyr/include/zephyr/drivers/flash.h
Line 640 in 03959a2
FLASH_EX_OP_RESET = 0, |
and if the meaning is the same, the system wide one should be used.
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.
We fixed it as your advice.
@@ -13,6 +13,11 @@ enum ra_ex_ops { | |||
FLASH_RA_EX_OP_WRITE_PROTECT = FLASH_EX_OP_VENDOR_BASE, | |||
}; | |||
|
|||
enum qspi_flash_ex_op_types { | |||
QSPI_FLASH_EX_OP_RESET = 0, | |||
QSPI_FLASH_EX_OP_EXIT_QPI = 1, |
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 define is in the same range as system wide definition for non-vendor space, and as such is not allowed.
Please refer to
zephyr/include/zephyr/drivers/flash.h
Lines 617 to 631 in 03959a2
/* | |
* Extended operation interface provides flexible way for supporting flash | |
* controller features. Code space is divided equally into Zephyr codes | |
* (MSb == 0) and vendor codes (MSb == 1). This way we can easily add extended | |
* operations to the drivers without cluttering the API or problems with API | |
* incompatibility. Extended operation can be promoted from vendor codes to | |
* Zephyr codes if the feature is available in most flash controllers and | |
* can be represented in the same way. | |
* | |
* It's not forbidden to have operation in Zephyr codes and vendor codes for | |
* the same functionality. In this case, vendor operation could provide more | |
* specific access when abstraction in Zephyr counterpart is insufficient. | |
*/ | |
#define FLASH_EX_OP_VENDOR_BASE 0x8000 | |
#define FLASH_EX_OP_IS_VENDOR(c) ((c) & FLASH_EX_OP_VENDOR_BASE) |
for instruction on how to define vendor specific operation
and to https://github.com/zephyrproject-rtos/zephyr/blob/03959a20f7834ffe50a51df2b2e45ef87d1b610b/include/zephyr/drivers/flash/stm32_flash_api_extensions.h for an example of such definition.
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 think that there is also typo and QPI should be QSPI?
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.
We updated for "QSPI_FLASH_EX_OP_EXIT_QPI" as your advice.
And "QPI" isn't typo. We mentioned QPI mode (4-4-4).
if (!qspi_flash_ra_valid(QSPI_NOR_FLASH_SIZE, offset, len)) { | ||
return -EINVAL; | ||
} | ||
|
||
if (len % QSPI_ERASE_BLK_SZ != 0) { | ||
return -EINVAL; | ||
} |
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.
You probably want to have some logging in at least one of the ifs, otherwise you have the same error returned to user with no way to distinguish problems except for debugging.
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.
We fixed it. We added log to distinguish for errors.
switch (code) { | ||
case QSPI_FLASH_EX_OP_EXIT_QPI: | ||
if (SPI_FLASH_PROTOCOL_QPI != qspi_data->qspi_cfg.spi_protocol) { | ||
err = 0; | ||
break; | ||
} | ||
cmd = QSPI_CMD_EXIT_QPI_MODE; | ||
err = R_QSPI_DirectWrite(&qspi_data->qspi_ctrl, &cmd, ONE_BYTE, false); | ||
if (err != FSP_SUCCESS) { | ||
LOG_ERR("qspi: direct write failed"); | ||
err = -EIO; | ||
} | ||
break; | ||
|
||
case QSPI_FLASH_EX_OP_RESET: | ||
cmd = QSPI_CMD_RESET_EN; | ||
err = R_QSPI_DirectWrite(&qspi_data->qspi_ctrl, &cmd, ONE_BYTE, false); | ||
if (err == FSP_SUCCESS) { | ||
cmd = QSPI_CMD_RESET_MEM; | ||
err = R_QSPI_DirectWrite(&qspi_data->qspi_ctrl, &cmd, ONE_BYTE, false); | ||
if (err != FSP_SUCCESS) { | ||
LOG_ERR("qspi: direct write failed"); | ||
err = -EIO; | ||
} |
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.
You lack here userspace processing, is that desired?
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.
Yes, it is designed without userspace processing.
It is supported to reset QPI mode and memory.
return -EINVAL; | ||
} | ||
|
||
if (!len) { |
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.
Here you fail operation of -EINVAL, even if len == 0 would cause nothing happening at all,
on the other side in qspi_flash_ra_write
you first check len == 0 and bypass any more checks as there is no more work to.
Consider having one flow everywhere, for example checking the len == 0 and just exit as there is no work to do and actually no possibility to failure
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.
We fixed it. We unified one flow for both qspi_flash_ra_write() and qspi_flash_ra_read(): check "len == 0" first and just exit.
There is a lot of QPI in the code, shouldn't that be QSPI? |
8187848
to
f462ce1
Compare
@de-nordic : Thank you so much for your review. We fixed issues which you pointed out. For "QPI" in the code, it isn't typo of "QSPI", this is support for QPI mode (4-4-4). Could you please help us to recheck for the update? Thanks again. |
2698314
to
d1216b4
Compare
Add support for QSPI Flash driver running on Renesas EK_RA6M5, EK_RA6M4, EK_RA6M3 and EK_RA6E2. Signed-off-by: Tri Nguyen <tri.nguyen.wj@bp.renesas.com> Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
Update hal_renesas which support for qspi on RA6 Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
d1216b4
to
fa7f9c5
Compare
Add support for QSPI Flash driver for RA6 devices