Skip to content

SpacemiT: Add linux-7.0.y "mainline" support#9458

Merged
igorpecovnik merged 6 commits into
armbian:mainfrom
pyavitz:SPACEMIT-004
Mar 2, 2026
Merged

SpacemiT: Add linux-7.0.y "mainline" support#9458
igorpecovnik merged 6 commits into
armbian:mainfrom
pyavitz:SPACEMIT-004

Conversation

@pyavitz
Copy link
Copy Markdown
Collaborator

@pyavitz pyavitz commented Mar 1, 2026

There is a lot here that is still not supported.

Most importantly

  • No SDCARD support
  • No CPU Freq support
  • No SDIO support
  • No HDMI or Audio support
  • Etc ...

https://paste.armbian.com/ecugarozit.yaml

Boot tested on: BPI-F3 and MusePi Pro

Summary by CodeRabbit

  • New Features

    • Added support for three kernel tracks: legacy (6.6), current (6.18) and edge (7.0) across SpacemiT platforms
    • Multi-zone thermal sensor support for K1 SoC
    • MusePi Pro board added with expanded regulators, PCIe and USB topology
    • Per-regulator supply properties for improved board power-tree descriptions
  • Bug Fixes

    • USB PHY disconnect support and regulator voltage/supply fixes
  • Refactor

    • PCIe PHY driver and Kconfig/Makefile entries reorganized into a dedicated driver subfolder

pyavitz added 5 commits March 1, 2026 08:44
Legacy, 6.6.y.
Current, 6.18.y.
Edge, 7.0.y.

Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
BananaPi BPI-F3
SpacemiT MusePi Pro

Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
@github-actions github-actions Bot added size/large PR with 250 lines or more 05 Milestone: Second quarter release labels Mar 1, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8dd4e54 and 501813d.

📒 Files selected for processing (1)
  • config/boards/orangepirv2.wip
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/boards/orangepirv2.wip

📝 Walkthrough

Walkthrough

Adds a "legacy" kernel target and reorganizes spacemit kernel branches (legacy/current/edge); adds many spacemit kernel configs and board DTs; introduces a SpacemiT K1 thermal driver and bindings, regulator and PCIe/PHY updates, USB2 PHY disconnect support, and board/device-tree adjustments.

Changes

Cohort / File(s) Summary
Board kernel target configuration
config/boards/bananapif3.conf, config/boards/musepipro.conf, config/boards/orangepir2s.wip, config/boards/orangepirv2.wip
KERNEL_TARGET values updated to include legacy (e.g., legacy,current,edge or legacy,current). One-line changes adjusting supported kernel targets.
Kernel configuration core
config/kernel/linux-spacemit-current.config, config/kernel/linux-spacemit-edge.config, config/kernel/linux-spacemit-legacy.config
Added a complete legacy defconfig and substantially updated current/edge defconfigs: many CONFIG_* changes enabling drivers, networking, thermal, VM, storage, GPIO, and subsystem options (large diffs across three files).
Source family branch mappings
config/sources/families/spacemit.conf
Reordered Linux BRANCH case labels: introduced legacy (6.6.y), current (6.18.y), and edge (7.0); added per-branch LINUXCONFIG declarations and EXTRAWIFI for edge.
New board DT and regulator node renames
patch/kernel/archive/spacemit-7.0/001-Update-MusePi-Pro-DTS.patch, patch/kernel/archive/spacemit-7.0/005-*.patch
Added k1-musepi-pro.dts (PCIe, regulators, i2c, USB, EEPROM, pinctrl, etc.); renamed regulator node labels in k1-bananapi-f3.dts and k1-milkv-jupiter.dts to regulator-* preferred names.
Thermal sensor driver and bindings
patch/kernel/archive/spacemit-7.0/002-*.patch, arch/riscv/boot/dts/spacemit/k1.dtsi, Documentation/devicetree/bindings/thermal/spacemit,k1-tsensor.yaml, drivers/thermal/spacemit/*
Added SpacemiT K1 thermal sensor driver, device-tree binding YAML, thermal-zones in DTS, hwmon attributes, driver Kconfig/Makefile, and made build integration changes. Multiple new files and large insertions.
Regulator binding & driver updates
patch/kernel/archive/spacemit-7.0/003-*.patch, drivers/regulator/spacemit-p1.c, Documentation/devicetree/bindings/spacemit,p1.yaml, arch/.../k1-bananapi-f3.dts
Updated spacemit-p1 regulator binding and driver to expose per-bank supply properties (vin1..vin6, aldoin, dldoin1/2); adjusted descriptors and DTS examples.
PHY driver relocation and build changes
patch/kernel/archive/spacemit-7.0/004-*.patch, drivers/phy/spacemit/phy-k1-pcie.c, drivers/phy/spacemit/Kconfig, drivers/phy/spacemit/Makefile
Moved PCIe PHY driver into drivers/phy/spacemit/, renamed file to phy-k1-pcie.c, relocated Kconfig and Makefile entries for PHY_SPACEMIT_K1_PCIE.
PHY USB2 disconnect support
patch/kernel/archive/spacemit-7.0/007-*.patch, drivers/phy/spacemit/phy-k1-usb2.c
Added disconnect handling to K1 USB2 PHY: new register bit defs, static disconnect function, and added .disconnect hook to PHY ops.
MFD cell addition
patch/kernel/archive/spacemit-7.0/006-*.patch, drivers/mfd/simple-mfd-i2c.c
Inserted a new spacemit-p1-reboot MFD cell into the spacemit-p1_cells array (first element).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant DTS as Device Tree
participant Driver as k1_tsensor Driver
participant KernelThermal as Linux Thermal Framework
participant HWMON as hwmon sysfs
participant IRQ as IRQ/Subsystem

DTS->>Driver: DT nodes + thermal-zone bindings
Driver->>KernelThermal: register thermal zones & ops
Driver->>HWMON: create hwmon attributes
IRQ->>Driver: sensor interrupt
Driver->>KernelThermal: notify/update temperature
KernelThermal->>HWMON: reflect trip/state changes

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
I nibbled code beneath the tree,
Three kernels now hop with me,
Sensors warm and regulators sing,
PCIe dreams take wing,
Hooray — SpaceMIT springs! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding linux-7.0.y support for the SpacemiT platform, which aligns with the substantial kernel configuration and patches introduced in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Mar 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch (3)

421-448: Clarify interrupt register semantics.

The interrupt enable/mask logic appears inconsistent at first glance:

  • Line 422: Writing 0xffffffff to "disable all interrupts"
  • Line 447: Setting K1_TSENSOR_INT_EN_MASK (bit 0) to "enable thermal interrupt"
  • Line 467: Clearing bits in k1_tsensor_enable_irq() to enable per-sensor interrupts

This suggests bit 0 is a global enable (active-high) while bits 1+ are per-sensor masks (active-high = masked). The register naming INT_EN_REG is potentially misleading since it appears to function as both an enable and mask register. Consider adding a brief comment explaining this dual behavior for future maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`
around lines 421 - 448, The interrupt register K1_TSENSOR_INT_EN_REG is used as
both a global enable (bit 0, K1_TSENSOR_INT_EN_MASK) and per-sensor mask bits
(bits 1+, manipulated in k1_tsensor_enable_irq()), which is confusing given the
name; add a short clarifying comment near the writes that first write 0xffffffff
and later set K1_TSENSOR_INT_EN_MASK (and reference k1_tsensor_enable_irq())
explaining that bit 0 is a global active-high interrupt enable while the upper
bits are per-sensor active-high masks, so code readers understand the dual
semantics.

528-531: Minor cleanup: remove unnecessary cast and use u32 for register values.

  • Line 530: The C-style cast (struct k1_tsensor *) is unnecessary as void * converts implicitly.
  • Line 531: mask and status hold register values and should be u32 for consistency with other register operations in the driver.
♻️ Suggested cleanup
 static irqreturn_t k1_tsensor_irq_thread(int irq, void *data)
 {
-	struct k1_tsensor *ts = (struct k1_tsensor *)data;
-	int mask, status, i;
+	struct k1_tsensor *ts = data;
+	u32 mask, status;
+	int i;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`
around lines 528 - 531, In k1_tsensor_irq_thread, remove the unnecessary C-style
cast on the data argument by assigning data directly to ts (i.e., use "struct
k1_tsensor *ts = data;") and change the types of register-related variables mask
and status from int to u32 to match other register operations in the driver
(keep loop/index variable i as int); update the variable declarations in the
function signature/body accordingly.

581-600: Consider adding error context on probe failures.

The thermal zone registration (line 582) and IRQ request (line 599-600) failures return error codes without descriptive messages, which could make debugging harder during board bring-up. Using dev_err_probe() would provide consistent error reporting.

♻️ Suggested improvement
 		ts->ch[i].tzd = devm_thermal_of_zone_register(dev, i, ts->ch + i, &k1_tsensor_ops);
 		if (IS_ERR(ts->ch[i].tzd))
-			return PTR_ERR(ts->ch[i].tzd);
+			return dev_err_probe(dev, PTR_ERR(ts->ch[i].tzd),
+					     "Failed to register thermal zone %d\n", i);
 ...
 	ret = devm_request_threaded_irq(dev, irq, NULL,
 					k1_tsensor_irq_thread,
 					IRQF_ONESHOT, "k1_tsensor", ts);
 	if (ret < 0)
-		return ret;
+		return dev_err_probe(dev, ret, "Failed to request IRQ\n");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`
around lines 581 - 600, Replace raw error returns on thermal zone registration
and IRQ request with dev_err_probe-style reporting: when IS_ERR(ts->ch[i].tzd)
is true and when devm_thermal_add_hwmon_sysfs() or devm_request_threaded_irq()
fail, call dev_err_probe(dev, err, "...") (or use dev_err_probe with the
returned negative code) to log a descriptive message (e.g., "failed to register
thermal zone %d" or "failed to request IRQ %d") before returning the error;
update the probe path around the checks for ts->ch[i].tzd,
devm_thermal_add_hwmon_sysfs(dev, ts->ch[i].tzd) and
devm_request_threaded_irq(..., k1_tsensor_irq_thread, ...) to use dev_err_probe
for consistent error context and then return the error code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/boards/orangepirv2.wip`:
- Line 6: The KERNEL_TARGET change makes the case "${BRANCH}" in edge) block and
the BCMDHD WiFi enablement dead/orphaned code; either remove that case block
entirely or comment it with a clear explanation that edge support (and
SD/SDIO/BCMDHD) was intentionally dropped for linux-7.0.y, and if retaining it
temporarily, add a TODO linking to the PR explaining why it's unreachable;
update any references to BCMDHD or edge-specific variables to avoid confusion
(search for the case "${BRANCH}" in edge) block and the BCMDHD mention to locate
and edit).

In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`:
- Around line 497-521: k1_tsensor_set_trips must handle the thermal-framework
sentinel values (INT_MIN for "no low", INT_MAX for "no high") before converting
and programming the hardware; update k1_tsensor_set_trips to check for low ==
INT_MIN and high == INT_MAX (use INT_MIN/INT_MAX) and map them to safe hardware
values instead of clamping negatives or allowing overflow: treat INT_MIN low as
"disabled" (set low to 0 or the register's minimum encodable value) and treat
INT_MAX high as the maximum encodable threshold (derive from
K1_TSENSOR_THRSH_HIGH_MASK / FIELD_GET range) before performing the /1000 +
TEMPERATURE_OFFSET conversion and FIELD_PREP into
K1_TSENSOR_THRSH_LOW_MASK/K1_TSENSOR_THRSH_HIGH_MASK; do these checks prior to
dividing or applying FIELD_PREP so no overflow/wrap occurs.

---

Nitpick comments:
In
`@patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch`:
- Around line 421-448: The interrupt register K1_TSENSOR_INT_EN_REG is used as
both a global enable (bit 0, K1_TSENSOR_INT_EN_MASK) and per-sensor mask bits
(bits 1+, manipulated in k1_tsensor_enable_irq()), which is confusing given the
name; add a short clarifying comment near the writes that first write 0xffffffff
and later set K1_TSENSOR_INT_EN_MASK (and reference k1_tsensor_enable_irq())
explaining that bit 0 is a global active-high interrupt enable while the upper
bits are per-sensor active-high masks, so code readers understand the dual
semantics.
- Around line 528-531: In k1_tsensor_irq_thread, remove the unnecessary C-style
cast on the data argument by assigning data directly to ts (i.e., use "struct
k1_tsensor *ts = data;") and change the types of register-related variables mask
and status from int to u32 to match other register operations in the driver
(keep loop/index variable i as int); update the variable declarations in the
function signature/body accordingly.
- Around line 581-600: Replace raw error returns on thermal zone registration
and IRQ request with dev_err_probe-style reporting: when IS_ERR(ts->ch[i].tzd)
is true and when devm_thermal_add_hwmon_sysfs() or devm_request_threaded_irq()
fail, call dev_err_probe(dev, err, "...") (or use dev_err_probe with the
returned negative code) to log a descriptive message (e.g., "failed to register
thermal zone %d" or "failed to request IRQ %d") before returning the error;
update the probe path around the checks for ts->ch[i].tzd,
devm_thermal_add_hwmon_sysfs(dev, ts->ch[i].tzd) and
devm_request_threaded_irq(..., k1_tsensor_irq_thread, ...) to use dev_err_probe
for consistent error context and then return the error code.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between efb4c68 and 8dd4e54.

📒 Files selected for processing (15)
  • config/boards/bananapif3.conf
  • config/boards/musepipro.conf
  • config/boards/orangepir2s.wip
  • config/boards/orangepirv2.wip
  • config/kernel/linux-spacemit-current.config
  • config/kernel/linux-spacemit-edge.config
  • config/kernel/linux-spacemit-legacy.config
  • config/sources/families/spacemit.conf
  • patch/kernel/archive/spacemit-7.0/001-Update-MusePi-Pro-DTS.patch
  • patch/kernel/archive/spacemit-7.0/002-PATCH-v3-0-3-thermal-spacemit-Add-support-for-SpacemiT-K1-SoC-thermal-sensor.patch
  • patch/kernel/archive/spacemit-7.0/003-PATCH-0-4-regulator-spacemit-p1-Fix-voltage-ranges-and-support-board-power-tree.patch
  • patch/kernel/archive/spacemit-7.0/004-PATCH-phy-move-spacemit-pcie-driver-to-its-subfolder.patch
  • patch/kernel/archive/spacemit-7.0/005-PATCH-riscv-dts-spacemit-adapt-regulator-node-name-to-preferred-form.patch
  • patch/kernel/archive/spacemit-7.0/006-PATCH-v5-2-2-mfd-simple-mfd-i2c-add-a-reboot-cell-for-the-SpacemiT-P1-chip.patch
  • patch/kernel/archive/spacemit-7.0/007-PATCH-v3-phy-k1-usb-add-disconnect-function-support.patch

Comment thread config/boards/orangepirv2.wip
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
Copy link
Copy Markdown
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

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

I don't have issues with the change.

@sven-ola I assume you are good too?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

✅ This PR has been reviewed and approved — all set for merge!

@github-actions github-actions Bot added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels Mar 2, 2026
@sven-ola
Copy link
Copy Markdown
Member

sven-ola commented Mar 2, 2026

As it's described by @pyavitz: no SD card support. Thus was not able to boot this kernel on my board (even not from NVME and my eMMC is also not considered). Need to investigate, probably not before thursday...

@igorpecovnik
Copy link
Copy Markdown
Member

igorpecovnik commented Mar 2, 2026

Need to investigate, probably not before thursday...

I think there is no rush with this as linux 7 support is very basic atm. I'll merge this as is later.

Here is more about change current -> legacy

@pyavitz
Copy link
Copy Markdown
Collaborator Author

pyavitz commented Mar 2, 2026

As it's described by @pyavitz: no SD card support. Thus was not able to boot this kernel on my board (even not from NVME and my eMMC is also not considered). Need to investigate, probably not before thursday...

The DTS for those units need some love, much like the MusePi Pro did. That would be my guess as to why they aren't booting.

Maybe something can be found here; https://lore.kernel.org/spacemit

@igorpecovnik igorpecovnik merged commit 8b23c94 into armbian:main Mar 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

3 participants