Skip to content

SMART AM40 improve#9735

Merged
igorpecovnik merged 2 commits intoarmbian:mainfrom
retro98boy:smart-am40-improve
May 1, 2026
Merged

SMART AM40 improve#9735
igorpecovnik merged 2 commits intoarmbian:mainfrom
retro98boy:smart-am40-improve

Conversation

@retro98boy
Copy link
Copy Markdown
Contributor

@retro98boy retro98boy commented Apr 28, 2026

Description

Optimizing SMART AM40 DTS

  • Change the rk808 alias from rtc99 to rtc1. rk808 RTC does not have actual functionality, so avoid letting it register as /dev/rtc0, because most kernel configurations restore time from /dev/rtc0 at boot. Registering the useless rk808 as rtc1 is better (as seen in most SBC DTS implementations); rtc99 is too large.

  • Change the naming of some nodes from specific IC models to IC types. This better conforms to Linux DTS naming conventions.

  • Add I2C speed configurations for the HDMI DDC, matching the implementation of other RK3399-based devices.

  • Adjust the PCIe to 2 lanes, as the M.2 Key-E slot hardware limit is 2 lanes.

  • Update DP HPD GPIO to active-high. The HPD pin goes high when HDMI is connected and low when disconnected. The previous incorrect description did not break HDMI (Type-C DP Alt Mode) because the Type-C Virtual PD extcon driver used gpiod_get_raw_value instead of gpiod_get_value, causing it to ignore the GPIO_ACTIVE_XXX flags defined in the DTS.

Optimizing Type-C Virtual PD Extcon Driver

  • Change the det-gpio request flag from GPIOD_ASIS to GPIOD_IN, as this pin is strictly an input.

  • Switch from gpiod_get_raw_value to gpiod_get_value for reading det-gpio. This allows the driver to support devices with active-low HPD logic purely via DTS declarations without requiring driver code modifications.

  • Update the driver patches for kernel versions 6.12, 6.18, and 7.0, as they can share the same patch file. The version 6.6 patch has been removed after confirming no DTS relies on it for that specific kernel.

How Has This Been Tested?

  • Build the 6.18 image for SMART AM40 and verified successful booting from an SD card. Following initial validation, the 7.0 kernel .deb packages were installed and tested after a reboot.

  • Build and test the NORCO EMB-3531 image to verify display functionality, as it also need the Type-C Virtual PD extcon driver.

Checklist:

  • I have performed a self-review of my own code
  • My changes generate no new warnings

Summary by CodeRabbit

  • New Features

    • Added virtual USB Type-C Power Delivery / Alt Mode support (virtual PD extcon)
  • Bug Fixes

    • Corrected RTC alias naming
    • Fixed USB‑C detection GPIO polarity and updated DisplayPort hot‑plug detect behavior
  • Improvements

    • Reduced PCIe link width from 4 to 2 lanes
    • Tuned I2C bus timing
    • Standardized Ethernet PHY device naming

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 912a452b-a17f-4f52-8b34-51464f48c30a

📥 Commits

Reviewing files that changed from the base of the PR and between 738a579 and 4faf0b2.

📒 Files selected for processing (5)
  • patch/kernel/archive/rockchip64-6.12/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-6.18/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-dt-doc.patch
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-7.0/general-add-miniDP-virtual-extcon.patch
💤 Files with no reviewable changes (2)
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-dt-doc.patch
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-virtual-extcon.patch
🚧 Files skipped from review as they are similar to previous changes (1)
  • patch/kernel/archive/rockchip64-6.18/general-add-miniDP-virtual-extcon.patch

📝 Walkthrough

Walkthrough

Remaps the RK3399 RTC alias to rtc1, inverts a USB‑C extcon detection GPIO polarity, renames the Ethernet PHY node, tunes I2C/PCIe/DP pinctrl settings across DTS files, adds an optional Virtual Type‑C PD extcon driver (new Kconfig + platform driver) for newer kernels, and removes that driver/docs for 6.6.

Changes

Cohort / File(s) Summary
Device Tree (multiple kernels & U‑Boot)
patch/kernel/archive/rockchip64-6.12/dt/rk3399-am40.dts, patch/kernel/archive/rockchip64-6.18/dt/rk3399-am40.dts, patch/kernel/archive/rockchip64-7.0/dt/rk3399-am40.dts, patch/u-boot/v2026.01/board_smart-am40/add-board-smart-am40.patch
DTS edits: aliases changed to expose rk808 as rtc1 (removed rtc99), det-gpios polarity set to active‑high, MDIO PHY node renamed to ethernet-phy@0 (keeps rtl8211f label), &i2c3 SCL rise/fall ns added, &pcie0 lane count reduced 4→2, DP HPD pinctrl switched to pcfg_input_enable.
New Extcon Driver additions
patch/kernel/archive/rockchip64-6.12/general-add-miniDP-virtual-extcon.patch, patch/kernel/archive/rockchip64-6.18/general-add-miniDP-virtual-extcon.patch, patch/kernel/archive/rockchip64-7.0/general-add-miniDP-virtual-extcon.patch
Adds EXTCON_USBC_VIRTUAL_PD Kconfig, wires extcon-usbc-virtual-pd.c into drivers/extcon/Makefile and registers a platform driver. Driver exposes EXTCON_USB/EXTCON_USB_HOST/EXTCON_DISP_DP, reads vpd-data-role and booleans, requests det as GPIOD_IN, reads via gpiod_get_value(), uses IRQ + delayed work to update extcon states and properties. Patch metadata normalized.
Removed (6.6) — driver & DT binding docs
patch/kernel/archive/rockchip64-6.6/general-add-miniDP-virtual-extcon.patch, patch/kernel/archive/rockchip64-6.6/general-add-miniDP-dt-doc.patch
Removes previously proposed extcon driver patch and associated Device Tree binding documentation for kernel 6.6 (large deletion of prior additions).

Sequence Diagram(s)

sequenceDiagram
    participant DT as Device Tree
    participant Driver as VPD Platform Driver
    participant GPIO as GPIO Controller
    participant IRQ as IRQ Subsystem
    participant ExtCon as Extcon Core

    DT->>Driver: Probe (det-gpios, vpd-data-role, booleans)
    Driver->>GPIO: devm_gpiod_get(..., GPIOD_IN)
    GPIO-->>Driver: GPIO descriptor
    Driver->>IRQ: request threaded IRQ for det GPIO
    IRQ-->>Driver: IRQ invoked on state change
    Driver->>Driver: schedule_delayed_work
    Driver->>GPIO: gpiod_get_value(det)
    GPIO-->>Driver: value (0/1)
    Driver->>ExtCon: set EXTCON states (USB / USB_HOST / DISP_DP) and properties (polarity, superspeed)
    ExtCon-->>ExtCon: notify userspace / subsystem
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
Hop, hop — DTs rearranged, rtc1 now sings,
GPIO flips, extcon wakes, IRQs on wings.
I2C ticks, PCIe pares lanes two by two,
PHY renamed, DP listens — all anew.
A rabbit cheers the board: a tidy, clever spring!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "SMART AM40 improve" is vague and generic, using non-descriptive terms that do not clearly convey the specific changes made in the changeset. Revise the title to be more specific and descriptive. Examples: "SMART AM40: Fix RTC alias, PCIe lanes, and DP GPIO polarity" or "Add Virtual PD extcon driver and improve AM40 DTS configuration"
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 05 Milestone: Second quarter release size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Apr 28, 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
patch/kernel/archive/rockchip64-7.0/general-add-miniDP-virtual-extcon.patch (1)

244-255: ⚠️ Potential issue | 🟠 Major

Enforce the det-gpios binding requirement in code.

Line 244 uses devm_gpiod_get_optional(), but the device tree binding explicitly marks det-gpios as required. Line 251 then calls gpiod_to_irq() unconditionally without checking if vpd->det_gpio is NULL. All in-tree nodes already provide det-gpios, so change to devm_gpiod_get() to match the binding contract, or add a null check and early return after line 244. Apply the same fix to the 6.18 and 6.12 copies.

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

In `@patch/kernel/archive/rockchip64-7.0/general-add-miniDP-virtual-extcon.patch`
around lines 244 - 255, The code incorrectly uses devm_gpiod_get_optional() to
obtain vpd->det_gpio despite the device-tree binding marking det-gpios as
required, then calls gpiod_to_irq() unconditionally; replace
devm_gpiod_get_optional() with devm_gpiod_get() when populating vpd->det_gpio
(or alternatively add an explicit NULL check and early return if vpd->det_gpio
is NULL) so that gpiod_to_irq(vpd->det_gpio) is only called with a valid GPIO;
apply the same change to the 6.18 and 6.12 backported copies to keep bindings
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@patch/kernel/archive/rockchip64-7.0/general-add-miniDP-virtual-extcon.patch`:
- Around line 244-255: The code incorrectly uses devm_gpiod_get_optional() to
obtain vpd->det_gpio despite the device-tree binding marking det-gpios as
required, then calls gpiod_to_irq() unconditionally; replace
devm_gpiod_get_optional() with devm_gpiod_get() when populating vpd->det_gpio
(or alternatively add an explicit NULL check and early return if vpd->det_gpio
is NULL) so that gpiod_to_irq(vpd->det_gpio) is only called with a valid GPIO;
apply the same change to the 6.18 and 6.12 backported copies to keep bindings
consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e5fd9d8-2ef4-48ae-bd7e-9a3e33bef959

📥 Commits

Reviewing files that changed from the base of the PR and between 73a3e49 and 738a579.

📒 Files selected for processing (9)
  • patch/kernel/archive/rockchip64-6.12/dt/rk3399-am40.dts
  • patch/kernel/archive/rockchip64-6.12/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-6.18/dt/rk3399-am40.dts
  • patch/kernel/archive/rockchip64-6.18/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-dt-doc.patch
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-7.0/dt/rk3399-am40.dts
  • patch/kernel/archive/rockchip64-7.0/general-add-miniDP-virtual-extcon.patch
  • patch/u-boot/v2026.01/board_smart-am40/add-board-smart-am40.patch
💤 Files with no reviewable changes (2)
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-virtual-extcon.patch
  • patch/kernel/archive/rockchip64-6.6/general-add-miniDP-dt-doc.patch

@retro98boy
Copy link
Copy Markdown
Contributor Author

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
🤖 Prompt for all review comments with AI agents
ℹ️ Review info

Fixed

@github-actions github-actions Bot added the Ready to merge Reviewed, tested and ready for merge label May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

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

@github-actions github-actions Bot removed the Needs review Seeking for review label May 1, 2026
@igorpecovnik igorpecovnik merged commit 5c9eb46 into armbian:main May 1, 2026
11 checks passed
@retro98boy retro98boy deleted the smart-am40-improve branch May 2, 2026 02:00
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.

2 participants