Skip to content

drivers: sdhc: litex: add support for litesdcard#93816

Open
maass-hamburg wants to merge 2 commits intozephyrproject-rtos:mainfrom
maass-hamburg:litex_litesdcard
Open

drivers: sdhc: litex: add support for litesdcard#93816
maass-hamburg wants to merge 2 commits intozephyrproject-rtos:mainfrom
maass-hamburg:litex_litesdcard

Conversation

@maass-hamburg
Copy link
Member

@maass-hamburg maass-hamburg commented Jul 29, 2025

add support for litesdcard

@maass-hamburg
Copy link
Member Author

rebased because #97444 got merged, now between the other peripherals

if (ret == 0) {
if ((cmd->opcode == SD_APP_SEND_SCR) &&
(cmd->response[0] & SD_R1_APP_CMD)) {
sdhc_litex_check_cmd23_support(dev, data);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also be able to determine CMD23 support by looking at the timing the host selects, if UHS timing is used you can assume CMD23 is possible.

Copy link
Member Author

@maass-hamburg maass-hamburg Nov 18, 2025

Choose a reason for hiding this comment

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

litesdcard doesn't supports uhs (it doesn't support voltage switching), therefore this is the best way for now. Supoort for adding externel level translators (like https://www.ti.com/product/de-de/LSF0108/part-details/LSF0108PWR) might be added later.

static const struct sdhc_litex_config sdhc_litex_config_##n = { \
.irq_config_func = sdhc_litex_irq_config##n, \
.bus_width = (enum sdhc_bus_width)DT_INST_PROP(n, bus_width), \
.phy_card_detect_addr = DT_INST_REG_ADDR_BY_NAME(n, phy_card_detect), \
Copy link
Contributor

Choose a reason for hiding this comment

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

Do all these register offsets differ between each version of the IP? Or could we encode one base address?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's how we do it with all litex peripherals. The order and the position of the registers is not fixed and not considered stable. It can always change. Btw it is open source https://github.com/enjoy-digital/litesdcard and changes can happen anytime. F.e. when a new register is added, the addresses of the other registers can change. We don't want to have to change the driver for that and handle versions for that. Instead the user just has to update the entries in their dts accordingly.

sdhc0: sdhc@e000e800 {
compatible = "litex,litesdcard-sdhc";
interrupt-parent = <&intc0>;
reg = <0xe000e800 0x4>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we can use one base address here. Or are all these register offsets configurable in the RTL?

Copy link
Member Author

Choose a reason for hiding this comment

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

no see other answer

@maass-hamburg
Copy link
Member Author

rebased due to merge conflicts

@maass-hamburg
Copy link
Member Author

@maass-hamburg
Copy link
Member Author

rebased due to a conflict

@maass-hamburg
Copy link
Member Author

rebased due to sdhc api changes, also cleaned up sdhc_litex_get_host_props

@maass-hamburg
Copy link
Member Author

@danieldegrasse please re-review

add litex litesdcard driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
add litesdcard host controller.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
@maass-hamburg
Copy link
Member Author

Changed compatible to match the one in Linux, which is litex,mmc https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/mmc/litex%2Cmmc.yaml

Also now uses events for interrupts

@maass-hamburg
Copy link
Member Author

@tgorochowik @kgugala please take a look too, needs the second approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment