Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [UOS] i8042: phytium-pio: support PS/2 controller over Phytium PIO#1947

Open
opsiff wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-03-phytium-pio
Open

[Deepin-Kernel-SIG] [linux 6.6.y] [UOS] i8042: phytium-pio: support PS/2 controller over Phytium PIO#1947
opsiff wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-03-phytium-pio

Conversation

@opsiff

@opsiff opsiff commented Jul 3, 2026

Copy link
Copy Markdown
Member

uos inclusion
category: feature

Squashed clean backport of Phytium PIO support for PS/2 keyboard/mouse on D2000/D3000/D3000M desktop platforms.

Original commits:

  • uos: phyt: port phytium lpc & i8042 driver to V25 [T366853]
  • uos: add helper for detecting whether cpu is d3000 [T366853]
  • uos: phyt: delete Kconfig choice for i8042_phyt [T366853]
  • uos: phyt: port UOS_PHYTIUM_DESKTOP_SUPPORT to V25 [T366853]
  • uos: phytium: show cpuname for desktop processors [B305567]
  • arm64: cpuinfo: refactor cputype judge functions [T366853]
  • phytium/lpc: Support various lpc address/offset [T366853]
  • uos: phytium/lpc: Calc iobase and offsets in one function [T381729]
  • uos: i8042-phytio: rewrite i8042 for phytium use pio [T381729]
  • uos: Phytium/pio: Adapt D2000 platforms [T381729]
  • uos: Phytium/pio: Skip using logic_pio on FT2004 [B335177]
  • uos: phytium/pio: Support short addr length of PHYT0007 [B352065]

Key content kept:

  • drivers/bus/phytium_pio.c: dynamic PIO register offsets per CPU model, skip PIO init on FT2004, support short PHYT0007 address length
  • drivers/input/serio/i8042-phytio.h: Logic PIO based i8042 I/O
  • drivers/input/serio/i8042.c: Phytium PIO interrupt clear hook
  • lib/cputypes.c, lib/classtypes.c: Phytium CPU model detection
  • arch/arm64/include/asm/cputype.h: MIDR_PHYTIUM_FT3000 alias
  • arch/arm64/Kconfig.platforms: select ARCH_MIGHT_HAVE_PC_SERIO for ARCH_PHYTIUM

Removed in this minimal version:

  • LPC-based i8042 driver (i8042_phyt.c, SERIO_I8042_PHYT)
  • LPC/EC/laptop/S3/UART-init code under drivers/uos/phyt/
  • Other CPU model detection helpers
  • UOS_PHYTIUM_DESKTOP_SUPPORT and related defconfig options

Tested-by: Wentao Guan guanwentao@uniontech.com #GreatWall T321A D2000

Summary by Sourcery

Add Phytium PIO-based PS/2 (i8042) support on Phytium desktop ARM64 platforms with CPU-model-specific handling.

New Features:

  • Introduce a Phytium PIO-backed i8042 platform implementation to support PS/2 keyboard and mouse via logic PIO on Phytium desktop CPUs.
  • Add generic CPU vendor/model detection helpers and DMI-based CPU name retrieval to classify Phytium D2000, D3000, D3000M, and FT2004 systems.

Enhancements:

  • Extend the Phytium PIO bus driver with CPU-specific interrupt register offsets, ACPI ID variants, and runtime checks to avoid unsupported FT2004 CPUs.
  • Wire Phytium-specific i8042 support into the generic i8042 driver so it uses Phytium PIO IRQs and clears PIO interrupt status efficiently on supported systems.

Build:

  • Link new cputypes and classtypes helper objects into the kernel lib on ARM64 builds.

@sourcery-ai

sourcery-ai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Backport and minimal integration of a Phytium PIO-based PS/2 (i8042) path on ARM64 Phytium desktop CPUs (D2000/D3000/D3000M), including CPU model detection helpers, dynamic PIO register layout handling, and a platform-specific i8042 backend wired through logic PIO, while explicitly excluding older LPC-based and laptop-specific bits.

Sequence diagram for Phytium PIO-backed i8042 interrupt handling

sequenceDiagram
    participant PS2_Device
    participant i8042 as i8042_interrupt
    participant i8042_phy as i8042_write_lpc_interrupt_clear
    participant PIO as phytium_pio

    PS2_Device->>i8042: hardware IRQ
    i8042->>i8042: spin_lock_irqsave
    i8042->>i8042_phy: i8042_write_lpc_interrupt_clear()
    i8042_phy->>PIO: phytium_pio_get_int_status()
    PIO-->>i8042_phy: int_status
    alt [int_status has I8042_KEY_BIT or I8042_TOUCH_BIT or EC_EVENT_BIT]
        i8042_phy->>PIO: phytium_pio_clear_interrupt(mask)
        PIO-->>i8042_phy: return
        i8042_phy-->>i8042: 0 (handled)
        i8042->>i8042: continue normal i8042_read_status()
    else [no cared bits]
        i8042_phy-->>i8042: 1 (no KBD|TP)
        i8042->>i8042: spin_unlock_irqrestore
        i8042-->>PS2_Device: IRQ not handled (ret = 0)
    end
Loading

File-Level Changes

Change Details Files
Add Phytium CPU vendor/model detection helpers and expose them as generic ARM64 cputype utilities
  • Introduce lib/cputypes.c implementing cpu_match() and helpers for Phytium models (ft2004, D2000, D3000, D3000M) using MIDR, DMI core count, and CPU name
  • Introduce lib/classtypes.c and include/linux/classtypes.h to fetch CPU name from DMI once and export get_cpu_name()
  • Add include/linux/cputypes.h with generic CPU vendor/model bits and per-model cpu_is_* helpers, with ARM64 implementations and stubs for other archs
  • Wire new objects into lib/Makefile so classtypes.o is always built and cputypes.o is built on ARM64
  • Extend arch/arm64/include/asm/cputype.h with MIDR_PHYTIUM_FT3000 alias for existing FTC862 part ID
lib/cputypes.c
lib/classtypes.c
include/linux/cputypes.h
include/linux/classtypes.h
lib/Makefile
arch/arm64/include/asm/cputype.h
Make Phytium PIO driver CPU-model aware with dynamic interrupt register offsets and FT2004 exclusion
  • Include linux/cputypes.h and use cpu_is_ft2004(), cpu_is_ft_d2000(), cpu_is_ft_d3000(), cpu_is_ft_d3000m() in the PIO driver
  • Introduce global phytium_pio_int_state/phytium_pio_clr_int and set them at init time based on CPU model or default to D3000 layout with a notice for unknown models
  • Change interrupt clear/status accesses from fixed constants to per-CPU offsets and add phytium_pio_get_int_status() exported helper
  • During probe, derive effective int_state/clr_int offsets from the ACPI resource size when using shorter PHYT0007 windows, falling back to defaults if device properties are absent, and log chosen offsets
  • Register logic_pio range before assigning global ppio, and add new ACPI ID "LPC0001" to the match table
  • Guard driver init with check_cpu_type() to skip non-Phytium and FT2004 systems
drivers/bus/phytium_pio.c
drivers/bus/phytium_pio.h
Introduce a Phytium PIO-specific i8042 backend using logic PIO and hook it into the i8042 core
  • Add drivers/input/serio/i8042-phytio.h providing a Phytium platform i8042 implementation using logic PIO inb/outb to fixed 0x60/0x64 ports, shared IRQ retrieved from phytium_pio_get_irq(), and reset policy set to I8042_RESET_ALWAYS
  • Implement i8042_write_lpc_interrupt_clear() that reads Phytium PIO interrupt status, clears key/touch/EC bits via phytium_pio_clear_interrupt(), and returns nonzero when no cared bits are set
  • Hook the new backend by including i8042-phytio.h in drivers/input/serio/i8042.h when CONFIG_PHYTIUM_PIO is set
  • Extend i8042_interrupt() to, under CONFIG_PHYTIUM_PIO and on supported CPUs, pre-check Phytium PIO interrupt status and bail out early when no KBD/touchpad interrupts are pending
drivers/input/serio/i8042-phytio.h
drivers/input/serio/i8042.h
drivers/input/serio/i8042.c
Platform integration changes for Phytium PIO-based PS/2 on ARM64
  • Select ARCH_MIGHT_HAVE_PC_SERIO for ARCH_PHYTIUM in arm64 Kconfig to allow PS/2 serio stack on Phytium platforms
  • Add ACPI ID support for PHYT0007 with shorter window and LPC0001 to the Phytium PIO driver, aligning with desktop Phytium systems
arch/arm64/Kconfig.platforms
drivers/bus/phytium_pio.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot deepin-ci-robot requested review from myml and shy129 July 3, 2026 14:09
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The new classtypes.c helper is built unconditionally and includes <asm/dmi.h>, which may not exist or behave consistently on all architectures; consider either restricting its build to the same architectures that provide that header (e.g. CONFIG_ARM64) or adding appropriate ifdefs around the asm/dmi.h usage.
  • The phytium_pio driver relies on global, non-static state (ppio, phytium_pio_int_state, phytium_pio_clr_int) and assumes a single instance; if multiple PIO devices or re-probe/remove scenarios are possible, it would be safer to tie this state to the device instance and avoid exporting driver-global mutable symbols.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new classtypes.c helper is built unconditionally and includes <asm/dmi.h>, which may not exist or behave consistently on all architectures; consider either restricting its build to the same architectures that provide that header (e.g. CONFIG_ARM64) or adding appropriate ifdefs around the asm/dmi.h usage.
- The phytium_pio driver relies on global, non-static state (ppio, phytium_pio_int_state, phytium_pio_clr_int) and assumes a single instance; if multiple PIO devices or re-probe/remove scenarios are possible, it would be safer to tie this state to the device instance and avoid exporting driver-global mutable symbols.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@opsiff opsiff force-pushed the linux-6.6.y-2026-07-03-phytium-pio branch from eebce3e to d3e1cfd Compare July 3, 2026 14:35
uos inclusion
category: feature

Squashed clean backport of Phytium PIO support for PS/2 keyboard/mouse on
D2000/D3000/D3000M desktop platforms.

Original commits:
- uos: phyt: port phytium lpc & i8042 driver to V25 [T366853]
- uos: add helper for detecting whether cpu is d3000 [T366853]
- uos: phyt: delete Kconfig choice for i8042_phyt [T366853]
- uos: phyt: port UOS_PHYTIUM_DESKTOP_SUPPORT to V25 [T366853]
- uos: phytium: show cpuname for desktop processors [B305567]
- arm64: cpuinfo: refactor cputype judge functions [T366853]
- phytium/lpc: Support various lpc address/offset [T366853]
- uos: phytium/lpc: Calc iobase and offsets in one function [T381729]
- uos: i8042-phytio: rewrite i8042 for phytium use pio [T381729]
- uos: Phytium/pio: Adapt D2000 platforms [T381729]
- uos: Phytium/pio: Skip using logic_pio on FT2004 [B335177]
- uos: phytium/pio: Support short addr length of PHYT0007 [B352065]

Key content kept:
- drivers/bus/phytium_pio.c: dynamic PIO register offsets per CPU model,
  skip PIO init on FT2004, support short PHYT0007 address length
- drivers/input/serio/i8042-phytio.h: Logic PIO based i8042 I/O
- drivers/input/serio/i8042.c: Phytium PIO interrupt clear hook
- lib/cputypes.c, lib/classtypes.c: Phytium CPU model detection
- arch/arm64/include/asm/cputype.h: MIDR_PHYTIUM_FT3000 alias
- arch/arm64/Kconfig.platforms:
  select ARCH_MIGHT_HAVE_PC_SERIO for ARCH_PHYTIUM

Removed in this minimal version:
- LPC-based i8042 driver (i8042_phyt.c, SERIO_I8042_PHYT)
- LPC/EC/laptop/S3/UART-init code under drivers/uos/phyt/
- Other CPU model detection helpers
- UOS_PHYTIUM_DESKTOP_SUPPORT and related defconfig options

Signed-off-by: huangbibo <huangbibo@uniontech.com>
Signed-off-by: hmy <huanglin@uniontech.com>
Signed-off-by: wenlunpeng <wenlunpeng@uniontech.com>
Tested-by: Wentao Guan <guanwentao@uniontech.com> #GreatWall T321A D2000
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@opsiff opsiff force-pushed the linux-6.6.y-2026-07-03-phytium-pio branch from d3e1cfd to 60172a8 Compare July 3, 2026 14:43
Comment thread lib/Makefile Outdated
once.o refcount.o rcuref.o usercopy.o errseq.o bucket_locks.o \
generic-radix-tree.o
generic-radix-tree.o classtypes.o
obj-$(CONFIG_ARM64) += cputypes.o

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

看起来针对飞腾特判的部分稍作改动可以放进arch/arm64/lib,而其它部分可以保留在这里

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

看起来针对飞腾特判的部分稍作改动可以放进arch/arm64/lib,而其它部分可以保留在这里

把classtypes.o 也放到cputypes.o这边了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants