feat(cv181x-sdhci): add SG2002 SD driver#1482
Merged
Merged
Conversation
ZR233
marked this pull request as ready for review
July 3, 2026 01:29
This was referenced Jul 3, 2026
Merged
Contributor
There was a problem hiding this comment.
审查总结
PR 变更内容
本 PR 新增 cv181x-sdhci 驱动 crate,重写 ax-driver/cvsd 以使用新的 SDHCI 后端,并为 sdmmc-protocol 添加 CardInitPreference::SdOnly 选项。
实现逻辑
- 新驱动 crate 正确分离了 CV181x 特定的 syscon/pinmux/PHY 编程与通用 SDHCI 协议处理
- 使用
sdhci-host、sdio-host2和sdmmc-protocol完成协议层,符合 cross-kernel driver 分层 - RDIF FIFO block device 注册使用 IRQ-driven 完成语义,为后续中断驱动完成做好准备
CardInitPreference::SdOnly正确处理 FDTno-mmc场景- 移除对
sg200x-bsp的依赖,解耦架构特定 BSP
验证结果
cargo fmt --check✅cargo clippy -p cv181x-sdhci --all-features -- -D warnings✅cargo clippy -p sdmmc-protocol --all-features -- -D warnings✅cargo clippy -p ax-driver --no-default-features --features cvsd -- -D warnings✅cargo test -p cv181x-sdhci✅ (7 tests)cargo test -p sdmmc-protocol --features sdio✅ (93 tests)cargo test -p ax-driver --no-default-features --features cvsd⚠️ SIGSEGV(已在基线分支复现,非本 PR 引入)
CI 状态
- 成功: 3 (arceos x86_64 run_host, arceos aarch64 run_host, axvisor loongarch64 run_container)
- 跳过: 多个(预期路径过滤行为,PR 仅修改驱动 crate,不影响其他测试矩阵)
- 失败: 0
重复/重叠分析
未发现重叠的 open PR。PR #1451(IRQ runtime 重构)和 PR #1076(自编译)与本 PR 无关。
测试覆盖
- 新增 7 个单元测试覆盖 cv181x-sdhci 的配置规范化、总线宽度限制、电源管理、PHY 初始化和 RDIF FIFO 配置
- sdmmc-protocol 新增
CardInitPreference::SdOnly相关测试 - ax-driver cvsd 测试覆盖 card init 超时检测和 IRQ-driven RDIF FIFO 配置
- 未覆盖实板 smoke,PR body 已说明需要后续在 LicheeRV Nano SG2002 上验证
结论
无阻塞问题。代码质量好,测试覆盖充分,CI 通过。建议批准。
Powered by mimo-v2.5-pro
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
现有
ax-driver/cvsd仍走sg200x-bsp的同步轮询 SD/MMC 实现,无法复用当前 cross-kernel driver 分层、sdmmc-protocol初始化流程和 RDIF block queue,也不利于后续在 SG2002 上接入中断驱动完成语义。修改内容
drivers/blk/cv181x-sdhcino_std 驱动 crate,封装 CV181x/SG2002 SD host 的 core/syscon/pinmux/PHY/power 操作,并委托sdhci-host、sdio-host2和sdmmc-protocol完成 SDHCI 协议处理。ax-driver/cvsd改为基于cv181x-sdhci+sdmmc-protocol+ RDIF FIFO block device 注册,保留原 feature 名和设备名cvsd。sdmmc-protocol增加CardInitPreference::SdOnly,让 FDTno-mmc场景不会在 SD ACMD41 超时后继续 fallback 到 MMC CMD1。ax-driver/cvsd对sg200x-bsp的依赖,新增确定性回归测试覆盖 IRQ-driven RDIF FIFO 配置和 SD-only 初始化路径。方案说明
v1 只实现 FIFO + IRQ-driven completion,不启用 ADMA2,避免先引入 CV181x 128M boundary descriptor 特例。CV181x 相关寄存器和板级时钟/电源/IO pull 设置收敛在 portable driver crate 中,OS 侧只负责 FDT 解析、MMIO 映射、初始化轮询节奏和 RDIF block 注册。
验证
cargo fmtcargo test -p cv181x-sdhcicargo test -p ax-driver --no-default-features --features cvsd cvsd_block_io_uses_irq_driven_sdmmc_rdif_fifo_configcargo test -p sdmmc-protocol --features sdio poll_init_request_sd_only_does_not_fallback_to_cmd1_after_acmd41_timeoutcargo xtask clippy --package cv181x-sdhcicargo xtask clippy --package sdmmc-protocolcargo xtask clippy --package ax-drivercargo xtask starry build --config os/StarryOS/configs/board/licheerv-nano-sg2002.tomlcargo xtask starry build --config os/StarryOS/configs/board/licheerv-nano-sg2002-wifi.toml未覆盖实板 smoke;需要后续在 LicheeRV Nano SG2002 上启动 StarryOS 并做 SD block 读写校验。