Skip to content
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 SDHC driver for Renesas RA8 devices #79862

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

khoa-nguyen-18
Copy link
Contributor

@khoa-nguyen-18 khoa-nguyen-18 commented Oct 15, 2024

Add support for SDHC driver running on Renesas RA8

  • boards: renesas: Add support for sdhc
  • drivers: disk: Add support for sdhc driver
  • dts: renesas: Add support for SDHC node.
  • dts: bindings: Add support for sdhc driver.
  • tests: drivers: disk: disk_performance: Add support for RA8.
  • tests: drivers: disk: disk_access: Add support for RA8.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Oct 15, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_renesas DNM This PR should not be merged (Do Not Merge) labels Oct 15, 2024
@thaoluonguw thaoluonguw marked this pull request as ready for review October 15, 2024 12:19
@thaoluonguw thaoluonguw added the platform: Renesas RA Renesas Electronics Corporation, RA label Oct 15, 2024
Copy link
Collaborator

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, but this driver is implementing the disk API directly for an SD host controller. New SD host controllers need to be implemented using the SDHC API: https://docs.zephyrproject.org/latest/hardware/peripherals/sdhc.html.

Take a look at the drivers within drivers/sdhc for some examples of how this would be implemented.

@khoa-nguyen-18 khoa-nguyen-18 force-pushed the support_renesas_ra8_sdmmc branch 2 times, most recently from c1bba4d to d3fed74 Compare October 16, 2024 06:26
@khoa-nguyen-18
Copy link
Contributor Author

Thank you for the contribution, but this driver is implementing the disk API directly for an SD host controller. New SD host controllers need to be implemented using the SDHC API: https://docs.zephyrproject.org/latest/hardware/peripherals/sdhc.html.

Take a look at the drivers within drivers/sdhc for some examples of how this would be implemented.

We noticed a similar implementation for the disk driver on the SDMMC IP in drivers\disk\sdmmc_stm32.c. If we want to support SDMMC, do we have to implement it in drivers/sdhc, instead of drivers/disk?

@danieldegrasse
Copy link
Collaborator

We noticed a similar implementation for the disk driver on the SDMMC IP in drivers\disk\sdmmc_stm32.c. If we want to support SDMMC, do we have to implement it in drivers/sdhc, instead of drivers/disk?

Yes, you do- I'm sorry that the STM32 implementation made things unclear. This implementation is present from before the SDHC layer was introduced, and needs to be transitioned to use the SDHC class instead of the disk driver layer. New implementations should not be based off it

@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch from d3fed74 to 1280afe Compare November 13, 2024 02:55
@khoa-nguyen-18 khoa-nguyen-18 changed the title Support SDMMC driver for Renesas RA8 devices Support SDHC driver for Renesas RA8 devices Nov 13, 2024
@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch 2 times, most recently from d7b2ce3 to 6ca7c1e Compare November 13, 2024 03:14
drivers/sdhc/sdhc_renesas_ra.c Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Outdated Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Outdated Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Outdated Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Show resolved Hide resolved
drivers/sdhc/sdhc_renesas_ra.c Outdated Show resolved Hide resolved
dts/arm/renesas/ra/ra8/ra8x1.dtsi Outdated Show resolved Hide resolved
@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch from 90c0f54 to 36d04d7 Compare November 22, 2024 10:50
@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch 2 times, most recently from 5937771 to bcdb3a1 Compare November 25, 2024 06:55
@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Nov 25, 2024
@quytranpzz
Copy link
Contributor

Rebases to update HAL commit ID

@quytranpzz
Copy link
Contributor

@danieldegrasse : Could you please revisit this PR? Thank you

@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch from bcdb3a1 to 8b4e25b Compare December 3, 2024 09:57
@zephyrbot zephyrbot added the DNM This PR should not be merged (Do Not Merge) label Dec 3, 2024
@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch from 8b4e25b to 5d0f524 Compare December 3, 2024 10:02
@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Dec 3, 2024
@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch from 5d0f524 to ba362f9 Compare December 3, 2024 10:22
danieldegrasse
danieldegrasse previously approved these changes Dec 3, 2024
Copy link
Collaborator

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all your work here!

<RA_PSEL(RA_PSEL_SDHI, 4, 3)>,
<RA_PSEL(RA_PSEL_SDHI, 4, 4)>,
<RA_PSEL(RA_PSEL_SDHI, 4, 5)>,
<RA_PSEL(RA_PSEL_SDHI, 7, 0)>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quytranpzz This pin is conflicting with the spi0_default node

Comment on lines 165 to 180
&sdhc1 {
compatible = "renesas,ra-sdhc";
interrupt-names = "accs", "card", "dma-req";
interrupts = <60 12>, <61 12>, <62 12>;
pinctrl-0 = <&sdhc1_default>;
pinctrl-names = "default";
status = "okay";
sdmmc {
compatible = "zephyr,sdmmc-disk";
disk-name = "SD";
status = "okay";
};
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaoluonguw , @KhiemNguyenT , @soburi , the EK_RA8M1 and EK_RA8D1 doesn't support SD slot default on board but require external board, should we set its status as "okay" in board.dts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the sdhc support with the status "okay" into app overlay for EK_RA8M1 and EK_RA8D1 because it requires external hardware and avoids some pins conflicts as above, keeps only for MCK-RA8T1
@KhiemNguyenT @thaoluonguw @soburi @duynguyenxa: please take a look. Thank you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danieldegrasse : sorry for inconvenience but could you please take another look? The driver implementation is unchanged, but the DTS support for the EK-RA8D1 and EK-RA8M1 boards has been updated as above discussed. Thank you

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand right, an external board is required for support here, which contains an SD card slot? A few questions:

  • Is this external board standardized between multiple EVKs? That is, can it be reused on multiple Renesas EVKs?
  • Is this board a product that can be purchased, or a custom rework to connect an SD card?

If the board is a product that can be purchased and is reusable across multiple boards, then I would suggest defining the board as a shield, so that it can be reused across multiple Renesas EVKs. You'll need to define a standard node name for the SDHC controller that exposes the pins the shield connects to- maybe something like renesas_ext_sdhc? See here for an example of this with NXP EVKs for an LCD interface:

@@ -10,3 +10,4 @@ toolchain:
supported:
- gpio
- uart
- sdhc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quytranpzz : Is it necessary to support as default?

select USE_RA_FSP_DTC
select PINCTRL
help
Enables Renesas Host controller driver
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be "Enable Renesas SD Host controller driver"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I updated it.

Comment on lines 11 to 15
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/irq.h>
#include <soc.h>
#include <zephyr/drivers/pinctrl.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated include <zephyr/drivers/pinctrl.h>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it, thanks

This is initial commit to support SDHC driver on Renesas RA8
with r_sdhi modules

Signed-off-by: Tran Van Quy <[email protected]>
Add node on RA8 dts to support sdhc as channel 0 and channel 1

Signed-off-by: Tran Van Quy <[email protected]>
Add board support for SDHC driver on EK-RA8M1, EK-RA8D1 and MCK-RA8T1

Signed-off-by: Tran Van Quy <[email protected]>
Add sdhc property in tests/disk to support SDHC on RA8 boards

Signed-off-by: Tran Van Quy <[email protected]>
Add overlay property node to support samples/fs/fs_sample on RA8 boards

Signed-off-by: Quy Tran <[email protected]>
Add overlay property node and configs to support tests/subsys/fs/ext2,
tests/fs/fat_fs_api and tests/subsys/sd on RA8 boards

Signed-off-by: Quy Tran <[email protected]>
@quytranpzz quytranpzz force-pushed the support_renesas_ra8_sdmmc branch from 968b50d to dc724ce Compare December 10, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants