-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[bsp][spacemit/k1] first version #11132
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: GuEe-GUI <[email protected]>
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
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.
Pull request overview
This PR introduces the first version of a new Board Support Package (BSP) for the Spacemit K1 platform to RT-Thread. The changes add comprehensive driver support across multiple hardware subsystems including SPI, GPIO, power management, reset control, and various peripheral devices.
Changes:
- New BSP infrastructure for Spacemit K1 platform
- Driver implementations for SPI/QSPI, GPIO, thermal, serial, RTC, reset controller, regulators, PWM, power management, pinctrl, mailbox, and input devices
- Multi-Function Device (MFD) support for Spacemit PMIC
- SoC-specific support including remote processor, TCM memory, and SoC information
Reviewed changes
Copilot reviewed 96 out of 162 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| bsp/spacemit/dm/thermal/* | Thermal management driver for K1X |
| bsp/spacemit/dm/spi/* | SPI and QSPI controller drivers |
| bsp/spacemit/dm/soc/* | SoC info, IPI, TCM, and remote processor support |
| bsp/spacemit/dm/serial/* | PXA UART driver with DMA support |
| bsp/spacemit/dm/rtc/* | Spacemit PMIC RTC driver |
| bsp/spacemit/dm/reset/* | K1X reset controller driver |
| bsp/spacemit/dm/regulator/* | PMIC power regulator driver |
| bsp/spacemit/dm/pwm/* | PXA PWM driver |
| bsp/spacemit/dm/power/* | Reboot mode handler |
| bsp/spacemit/dm/pmdomain/* | Power domain controller |
| bsp/spacemit/dm/pinctrl/* | PMIC pinctrl driver |
| bsp/spacemit/dm/pin/* | K1X GPIO driver |
| bsp/spacemit/dm/mfd/* | Spacemit PMIC MFD driver |
| bsp/spacemit/dm/mailbox/* | K1X mailbox driver |
| bsp/spacemit/dm/input/* | PMIC power key input driver |
| bsp/spacemit/dm/include/* | TCM memory allocation header |
|
|
||
| if (loop < 0) | ||
| { | ||
| LOG_E("Powero ff Domain(%d) fail", spd->index); |
Copilot
AI
Jan 12, 2026
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.
Corrected spelling of 'Powero ff' to 'Power off' in error message. / 将错误消息中的 'Powero ff' 拼写更正为 'Power off'。
| LOG_E("Powero ff Domain(%d) fail", spd->index); | |
| LOG_E("Power off Domain(%d) fail", spd->index); |
| } | ||
| if (fr & QSPI_FR_AITEF) | ||
| { | ||
| LOG_E("AHB illegal trancaction error"); |
Copilot
AI
Jan 12, 2026
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.
Corrected spelling of 'trancaction' to 'transaction' in error message. / 将错误消息中的 'trancaction' 拼写更正为 'transaction'。
| LOG_E("AHB illegal trancaction error"); | |
| LOG_E("AHB illegal transaction error"); |
| } | ||
| } | ||
|
|
||
| /* The soc id is unkown */ |
Copilot
AI
Jan 12, 2026
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.
Corrected spelling of 'unkown' to 'unknown' in comment. / 将注释中的 'unkown' 拼写更正为 'unknown'。
| /* The soc id is unkown */ | |
| /* The soc id is unknown */ |
| { | ||
| for (int i = 0; i < RT_ARRAY_SIZE(spacemit_pmic_pinctrl_params); ++i) | ||
| { | ||
| if (!rt_strcmp(spacemit_pmic_pinctrl_params[i].propname, "name")) |
Copilot
AI
Jan 12, 2026
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.
String comparison compares against literal "name" instead of the variable name, which will never match the intended property names. Should compare spacemit_pmic_pinctrl_params[i].propname against the parameter name. / 字符串比较使用了字面量 "name" 而不是变量 name,这将永远无法匹配预期的属性名称。应该将 spacemit_pmic_pinctrl_params[i].propname 与参数 name 进行比较。
| if (!rt_strcmp(spacemit_pmic_pinctrl_params[i].propname, "name")) | |
| if (!rt_strcmp(spacemit_pmic_pinctrl_params[i].propname, name)) |
| if (pc->quirks & RT_BIT(QUIRK_HAS_PWM_DCR_FD)) | ||
| { | ||
| pc->dcr_fd = rt_dm_dev_prop_read_bool(dev, "k1x,pwm-disable-fd") ? 0 : 1; | ||
| pc->dcr_fd = rt_dm_dev_prop_read_bool(dev, "rcpu-pwm") ? 1 : 0; |
Copilot
AI
Jan 12, 2026
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 line overwrites the pc->dcr_fd value that was just set on line 242. The second assignment should likely be setting pc->rcpu_pwm instead of pc->dcr_fd again. / 这一行覆盖了刚在第 242 行设置的 pc->dcr_fd 值。第二次赋值应该设置 pc->rcpu_pwm 而不是再次设置 pc->dcr_fd。
| pc->dcr_fd = rt_dm_dev_prop_read_bool(dev, "rcpu-pwm") ? 1 : 0; | |
| pc->rcpu_pwm = rt_dm_dev_prop_read_bool(dev, "rcpu-pwm") ? 1 : 0; |
| if (rt_is_err(spi->clk)) | ||
| { | ||
| err = rt_ptr_err(spi->clk); |
Copilot
AI
Jan 12, 2026
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.
Error check uses spi->clk but should check spi->rstc after the reset control assignment on line 975. / 错误检查使用了 spi->clk 但应该在第 975 行的复位控制赋值后检查 spi->rstc。
| if (rt_is_err(spi->clk)) | |
| { | |
| err = rt_ptr_err(spi->clk); | |
| if (rt_is_err(spi->rstc)) | |
| { | |
| err = rt_ptr_err(spi->rstc); |
| qspi_writel(qspi, QSPI_SMPR_FSPHS_MASK, base + QSPI_SMPR); | ||
| } | ||
|
|
||
| /* Fix wirte failure issue*/ |
Copilot
AI
Jan 12, 2026
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.
Corrected spelling of 'wirte' to 'write' in comment. / 将注释中的 'wirte' 拼写更正为 'write'。
| /* Fix wirte failure issue*/ | |
| /* Fix write failure issue*/ |
| #include <rtthread.h> | ||
| #include <rtdevice.h> | ||
|
|
||
| #define DBG_TAG "mailbox.rockchip" |
Copilot
AI
Jan 12, 2026
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.
Debug tag incorrectly says "mailbox.rockchip" but this is Spacemit K1X mailbox driver, not Rockchip. Should be "mailbox.spacemit" or "mailbox.k1x". / 调试标签错误地写为 "mailbox.rockchip",但这是 Spacemit K1X 邮箱驱动程序,而不是 Rockchip。应该是 "mailbox.spacemit" 或 "mailbox.k1x"。
| #define DBG_TAG "mailbox.rockchip" | |
| #define DBG_TAG "mailbox.spacemit" |
| #include <bitmap.h> | ||
|
|
||
| #define DBG_TAG "pin.k1" | ||
| #define DBG_LVL DBG_LOG |
Copilot
AI
Jan 12, 2026
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.
Debug level is set to DBG_LOG which is unusual for production code. Consider using DBG_INFO or DBG_WARNING for consistency with other drivers in this BSP. / 调试级别设置为 DBG_LOG,这在生产代码中并不常见。考虑使用 DBG_INFO 或 DBG_WARNING 以与此 BSP 中的其他驱动程序保持一致。
| #define DBG_LVL DBG_LOG | |
| #define DBG_LVL DBG_INFO |
| #include <drivers/serial_dm.h> | ||
|
|
||
| #include <cpuport.h> | ||
| #include "8250/8250.h" |
Copilot
AI
Jan 12, 2026
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.
Include path uses relative path "8250/8250.h" which may not be portable. Consider documenting the expected directory structure or using absolute paths. / 包含路径使用相对路径 "8250/8250.h",这可能不具备可移植性。考虑记录预期的目录结构或使用绝对路径。
| #include "8250/8250.h" | |
| /* The 8250 core header is expected to be available via the include path as 8250/8250.h. */ | |
| #include <8250/8250.h> |
拉取/合并请求描述:(PR description)
[
Part of https://github.com//pull/10320
New BSP for
spacemit/k1]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up