Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [UOS] sync and refactor ec support for phytium platform#1973

Open
opsiff wants to merge 5 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-10-phytium-pio
Open

[Deepin-Kernel-SIG] [linux 6.6-y] [UOS] sync and refactor ec support for phytium platform#1973
opsiff wants to merge 5 commits into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-10-phytium-pio

Conversation

@opsiff

@opsiff opsiff commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary by Sourcery

Add Phytium ARM64 laptop EC support and platform driver integration, including chassis-type helpers and EC-based power, backlight, hotkey, sensor, and event handling.

New Features:

  • Expose DMI-based chassis type helpers for identifying laptops and all-in-one systems.
  • Introduce a Phytium ARM64 laptop EC platform driver providing backlight, hotkey, lid, gsensor, battery, AC, and power button handling.
  • Add EC IT8528 communication, interrupt handling, and sensor (battery temperature, GPU temperature, CPU/GPU fan) support for Phytium platforms.
  • Enable ARM64 platform driver hierarchy and Phytium-specific platform drivers in the build.

Bug Fixes:

  • Avoid removing ACPI EC handlers on Phytium systems when setup fails, preserving platform-specific EC behavior.

Enhancements:

  • Extend CPU type helpers to include Phytium machine detection for conditional platform logic.

deepin inclusion
category: bugfix

ACPI: EC: remove clean up handlers on probe failure in acpi_ec_setup

Signed-off-by: huangbibo <huangbibo@uniontech.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai

sourcery-ai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a Phytium-specific EC / laptop platform driver for ARM64, including EC command helpers, sensor exposure, power and hotkey handling, and integrates new chassis-type helpers plus a Phytium ACPI EC quirk; wires the new platform directory into the ARM64 drivers tree.

File-Level Changes

Change Details Files
Introduce generic chassis type helpers and use them for Phytium laptop/all-in-one detection and backlight behavior.
  • Add DMI-based chassis type lookup with cached numeric value and export helpers to classify laptop and all-in-one systems
  • Expose new chassis helpers via linux/classtypes.h and include needed types/kstrtox headers
  • Use chassis helpers in the Phytium laptop driver to conditionally manage backlight and suspend/resume behavior
lib/classtypes.c
include/linux/classtypes.h
drivers/platform/arm64/phytium/phyt_laptop.c
Add Phytium EC / laptop platform driver with power, backlight, hotkeys, gsensor, and interrupt handling.
  • Implement a large Phytium laptop platform driver that talks to an IT8528 EC over LPC/GPIO, registering backlight, input, power_supply and hwmon interfaces
  • Handle EC event interrupts via both LPC and GPIO paths, including SCI event queue cleanup and suspend/resume integration
  • Wire up EC-based hotkeys, gsensor events, power button, lid, WiFi, mic mute, airplane mode, and screen lock handling
drivers/platform/arm64/phytium/phyt_laptop.c
drivers/platform/arm64/phytium/ec_it8528.h
drivers/platform/arm64/phytium/ec_it8528.c
drivers/platform/arm64/phytium/ec_sensor.c
Provide EC access helpers for IT8528 and hook EC sensors via hwmon.
  • Add IT8528 EC register definitions and helper APIs for indexed read/write and event handling, including enabling/disabling EC SCI interrupts
  • Implement EC transaction logic with proper IBF/OBF polling and locking, plus LPC interrupt helpers targeting Phytium PIO
  • Expose temperature and fan speed readings via hwmon sysfs attributes backed by EC registers
drivers/platform/arm64/phytium/ec_it8528.h
drivers/platform/arm64/phytium/ec_it8528.c
drivers/platform/arm64/phytium/ec_sensor.c
Wire in Phytium ARM64 platform directory and configuration, and add Phytium machine identifier.
  • Add arm64 platform Makefile and Kconfig entries plus Phytium-specific platform Makefile wiring under drivers/platform
  • Register new Phytium EC and laptop objects under CONFIG_PHYTIUM_EC and CONFIG_PHYTIUM_LAPTOP
  • Add Phytium machine-type helper macro usage in cputypes to support cpu_is_phytium-style checks
drivers/platform/Makefile
drivers/platform/arm64/Makefile
drivers/platform/arm64/phytium/Makefile
drivers/platform/Kconfig
include/linux/cputypes.h
arch/arm64/configs/deepin_arm64_desktop_defconfig
MAINTAINERS
Add Phytium-specific ACPI EC setup quirk to avoid removing handlers on non-Phytium failures.
  • Gate ec_remove_handlers() in acpi_ec_setup() behind an ARCH_PHYTIUM check and a runtime implementor check for ARM_CPU_IMP_PHYTIUM
drivers/acpi/ec.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

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

@opsiff opsiff force-pushed the linux-6.6.y-2026-07-10-phytium-pio branch from 95d6c52 to b5c1f36 Compare July 10, 2026 10:25

@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 found 1 issue, and left some high level feedback:

  • In lib/classtypes.c, get_chassis_types() uses dmi_get_system_info() but the file does not include <linux/dmi.h>, which will break the build on some configs; include the appropriate header explicitly rather than relying on indirect inclusion.
  • In ft_lpc_event_probe() the condition if (!read_cpuid_implementor() == ARM_CPU_IMP_PHYTIUM) is almost certainly wrong due to operator precedence (the ! applies before ==); this should be rewritten as an explicit inequality comparison, e.g. if (read_cpuid_implementor() != ARM_CPU_IMP_PHYTIUM) or by using the new cpu_is_phytium() helper.
  • In ec_sensor.c, the various *_data buffers are allocated with kzalloc() and never freed; consider using devm_kzalloc() (tied to pdev->dev) or passing NULL as the hwmon data pointer to avoid persistent allocations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `lib/classtypes.c`, `get_chassis_types()` uses `dmi_get_system_info()` but the file does not include `<linux/dmi.h>`, which will break the build on some configs; include the appropriate header explicitly rather than relying on indirect inclusion.
- In `ft_lpc_event_probe()` the condition `if (!read_cpuid_implementor() == ARM_CPU_IMP_PHYTIUM)` is almost certainly wrong due to operator precedence (the `!` applies before `==`); this should be rewritten as an explicit inequality comparison, e.g. `if (read_cpuid_implementor() != ARM_CPU_IMP_PHYTIUM)` or by using the new `cpu_is_phytium()` helper.
- In `ec_sensor.c`, the various `*_data` buffers are allocated with `kzalloc()` and never freed; consider using `devm_kzalloc()` (tied to `pdev->dev`) or passing `NULL` as the hwmon data pointer to avoid persistent allocations.

## Individual Comments

### Comment 1
<location path="drivers/platform/arm64/phytium/phyt_laptop.c" line_range="1113-1114" />
<code_context>
+	return sprintf(buf, "%d\n", x_val);
+}
+
+static struct kobj_attribute gsensor_attr =
+	__ATTR(value_x, 0644, gsensor_show, NULL);
+
+static struct attribute *gsensor_attrs[] = {
</code_context>
<issue_to_address>
**issue (bug_risk):** Use read-only sysfs permissions or add a store handler

The attribute is exposed as 0644 but has no store callback, so any write attempts will fail with -EIO. Either change the mode to 0444/S_IRUGO if it’s meant to be read-only, or add a store handler if writes are required.
</issue_to_address>

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.

Comment on lines +1113 to +1114
static struct kobj_attribute gsensor_attr =
__ATTR(value_x, 0644, gsensor_show, NULL);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Use read-only sysfs permissions or add a store handler

The attribute is exposed as 0644 but has no store callback, so any write attempts will fail with -EIO. Either change the mode to 0444/S_IRUGO if it’s meant to be read-only, or add a store handler if writes are required.

@opsiff opsiff force-pushed the linux-6.6.y-2026-07-10-phytium-pio branch 4 times, most recently from 7c21cf2 to 54f03ac Compare July 10, 2026 11:24
opsiff added 4 commits July 10, 2026 19:30
uos inclusion
category: feature

Bring back the IT8528 EC and laptop platform support, switching the EC
transport from the removed Phytium LPC path to the Phytium PIO path.
This provides battery, AC, lid, hotkey, backlight and hwmon support
for Phytium laptop platforms.

based on these commits:
commit 4c3ee4f195ca7 uos: phyt/ec_it8528: replace readb/writeb with inb/outb [T381729]
commit 9953278324c81 uos: phytium/lpc: Calc iobase and offsets in one function [T381729]
commit 7bca99aa60b9b phytium/lpc: Support various lpc address/offset [T366853]
commit ba88c0d55b8f3 uos: phyt: port UOS_PHYTIUM_DESKTOP_SUPPORT to V25 [T366853]

Assisted-by: kimi-cli:kimi-k2.7 code # reformat patch
Signed-off-by: huangbibo <huangbibo@uniontech.com>
Signed-off-by: hmy <huanglin@uniontech.com>
Signed-off-by: wenlunpeng <wenlunpeng@uniontech.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion
category: feature

Refactor the IT8528 EC driver to reduce duplication and boilerplate:

- Replace the six nearly-identical read/write helpers with a single
  it8528_transaction() routine, mirroring the transaction model used by
  drivers/acpi/ec.c.
- Table-drive battery state updates instead of a large switch/case.
- Table-drive EC event dispatch and make the three legacy handlers return
  void, since their return values were never used.
- Remove the unused ft_ec_irq_hanlde() export.

Assisted-by: kimi-cli:kimi-k2.7 code
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
deepin inclusion
category: feature

Simplify probe error handling and remove the last checkpatch warning:

- Make ec_gsonsor_init() take the platform_device and create the gsensor
  sysfs group under &dev->dev.kobj instead of the private devices_kset.
  This eliminates the extern struct kset *devices_kset declaration.
- Switch power_info, backlight and power_supply registrations to devm_*
  variants so most probe resources are auto-released on failure.
- Collapse the long goto chain in ft_lpc_event_probe() to a single
  fail_after_gsensor cleanup path.
- Remove the bogus platform_driver_unregister() call from probe's error
  path.

Assisted-by: kimi-cli:kimi-k2.7 code
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Relocate the Phytium EC/laptop drivers from the vendor-specific
UOS directory tree to drivers/platform/arm64/phytium, following the
upstream convention of architecture-specific platform driver
directories (e.g. drivers/platform/x86, drivers/platform/loongarch).

- Add ARM64_PLATFORM_DEVICES menuconfig under drivers/platform/arm64.
- Drop the UOS_PHYTIUM_DESKTOP_SUPPORT indirection and the drivers/uos/
  tree entirely.
- Update MAINTAINERS and the defconfig accordingly.

Assisted-by: kimi-cli:kimi-k2.7 code
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@opsiff opsiff force-pushed the linux-6.6.y-2026-07-10-phytium-pio branch from 54f03ac to 16e19a7 Compare July 10, 2026 11:30
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.

2 participants