Skip to content

Conversation

@GuEe-GUI
Copy link
Contributor

拉取/合并请求描述:(PR description)

[
Part of https://github.com//pull/10320
New BSP for spacemit/k1

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

Signed-off-by: GuEe-GUI <2991707448@qq.com>
@github-actions
Copy link

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:riscv_dm
  • 设置PR number为 \ Set the PR number to:11132
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 riscv_dm 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the riscv_dm branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

Copy link
Contributor

Copilot AI left a 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);
Copy link

Copilot AI Jan 12, 2026

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'。

Suggested change
LOG_E("Powero ff Domain(%d) fail", spd->index);
LOG_E("Power off Domain(%d) fail", spd->index);

Copilot uses AI. Check for mistakes.
}
if (fr & QSPI_FR_AITEF)
{
LOG_E("AHB illegal trancaction error");
Copy link

Copilot AI Jan 12, 2026

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'。

Suggested change
LOG_E("AHB illegal trancaction error");
LOG_E("AHB illegal transaction error");

Copilot uses AI. Check for mistakes.
}
}

/* The soc id is unkown */
Copy link

Copilot AI Jan 12, 2026

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'。

Suggested change
/* The soc id is unkown */
/* The soc id is unknown */

Copilot uses AI. Check for mistakes.
{
for (int i = 0; i < RT_ARRAY_SIZE(spacemit_pmic_pinctrl_params); ++i)
{
if (!rt_strcmp(spacemit_pmic_pinctrl_params[i].propname, "name"))
Copy link

Copilot AI Jan 12, 2026

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 进行比较。

Suggested change
if (!rt_strcmp(spacemit_pmic_pinctrl_params[i].propname, "name"))
if (!rt_strcmp(spacemit_pmic_pinctrl_params[i].propname, name))

Copilot uses AI. Check for mistakes.
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;
Copy link

Copilot AI Jan 12, 2026

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

Suggested change
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;

Copilot uses AI. Check for mistakes.
Comment on lines +976 to +978
if (rt_is_err(spi->clk))
{
err = rt_ptr_err(spi->clk);
Copy link

Copilot AI Jan 12, 2026

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

Suggested change
if (rt_is_err(spi->clk))
{
err = rt_ptr_err(spi->clk);
if (rt_is_err(spi->rstc))
{
err = rt_ptr_err(spi->rstc);

Copilot uses AI. Check for mistakes.
qspi_writel(qspi, QSPI_SMPR_FSPHS_MASK, base + QSPI_SMPR);
}

/* Fix wirte failure issue*/
Copy link

Copilot AI Jan 12, 2026

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'。

Suggested change
/* Fix wirte failure issue*/
/* Fix write failure issue*/

Copilot uses AI. Check for mistakes.
#include <rtthread.h>
#include <rtdevice.h>

#define DBG_TAG "mailbox.rockchip"
Copy link

Copilot AI Jan 12, 2026

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"。

Suggested change
#define DBG_TAG "mailbox.rockchip"
#define DBG_TAG "mailbox.spacemit"

Copilot uses AI. Check for mistakes.
#include <bitmap.h>

#define DBG_TAG "pin.k1"
#define DBG_LVL DBG_LOG
Copy link

Copilot AI Jan 12, 2026

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 中的其他驱动程序保持一致。

Suggested change
#define DBG_LVL DBG_LOG
#define DBG_LVL DBG_INFO

Copilot uses AI. Check for mistakes.
#include <drivers/serial_dm.h>

#include <cpuport.h>
#include "8250/8250.h"
Copy link

Copilot AI Jan 12, 2026

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",这可能不具备可移植性。考虑记录预期的目录结构或使用绝对路径。

Suggested change
#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>

Copilot uses AI. Check for mistakes.
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.

1 participant