Skip to content

[linux-6.6.y] pinctrl/zhaoxin: kh50000: add multi‑socket support#1694

Open
leoliu-oc wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
leoliu-oc:linux-6.6.y-135-pinctrl-mult-socket
Open

[linux-6.6.y] pinctrl/zhaoxin: kh50000: add multi‑socket support#1694
leoliu-oc wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
leoliu-oc:linux-6.6.y-135-pinctrl-mult-socket

Conversation

@leoliu-oc
Copy link
Copy Markdown
Contributor

@leoliu-oc leoliu-oc commented May 12, 2026

  • Introduce socket‑aware pin definition macros for multi‑socket platforms
  • Split global pin table into per‑socket pin tables with UID soc_data
  • Use UID‑based probe to match multi‑socket instances
  • Dynamically acquire PMIO IO resource instead of hard‑coding address
  • Fix PMIO offset for multi‑socket compatibility

Summary by Sourcery

Add multi-socket support to the Zhaoxin KH50000 pin controller and fix its PMIO handling.

New Features:

  • Introduce per-socket pin descriptions and UID-tagged SoC data entries to support multiple KH50000 sockets via UID-based probing.

Bug Fixes:

  • Correct PMIO base and register offsets by acquiring the IO resource dynamically instead of using hard-coded values.

* Introduce socket‑aware pin definition macros for multi‑socket platforms
* Split global pin table into per‑socket pin tables with UID soc_data
* Use UID‑based probe to match multi‑socket instances
* Dynamically acquire PMIO IO resource instead of hard‑coding address
* Fix PMIO offset for multi‑socket compatibility

Signed-off-by: LeoLiu-oc <leoliu-oc@zhaoxin.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 12, 2026

Reviewer's Guide

Refactors the KH50000 pinctrl driver to be socket-aware for multi-socket platforms by introducing socket-parameterized pin descriptors and per-socket SoC data, switches probe to UID-based matching, and replaces hard-coded PMIO addresses and offsets with dynamically acquired IO resources suitable for multiple sockets.

Sequence diagram for KH50000 probe with UID and dynamic PMIO

sequenceDiagram
    participant ACPI
    participant kh50000_pinctrl_driver
    participant zhaoxin_pinctrl_probe_by_uid
    participant kh50000_gpio_init
    participant platform_get_resource
    participant request_region

    ACPI->>kh50000_pinctrl_driver: match kh50000_pinctrl_acpi_match
    kh50000_pinctrl_driver->>zhaoxin_pinctrl_probe_by_uid: probe
    zhaoxin_pinctrl_probe_by_uid->>zhaoxin_pinctrl_probe_by_uid: select kh50000_soc_data by uid
    zhaoxin_pinctrl_probe_by_uid->>kh50000_gpio_init: private_init(pctrl)
    kh50000_gpio_init->>platform_get_resource: platform_get_resource(pdev, IORESOURCE_IO, 0)
    platform_get_resource-->>kh50000_gpio_init: res_pmio
    kh50000_gpio_init->>request_region: request_region(res_pmio.start, resource_size(res_pmio), pdev.name)
    request_region-->>kh50000_gpio_init: region acquired
    kh50000_gpio_init->>kh50000_gpio_init: set pmio_base, pmio_rx90, pmio_rx8c
    kh50000_gpio_init-->>zhaoxin_pinctrl_probe_by_uid: return
    zhaoxin_pinctrl_probe_by_uid-->>kh50000_pinctrl_driver: probe complete
Loading

File-Level Changes

Change Details Files
Make pin definitions socket-aware and split monolithic pin table into per-socket tables.
  • Introduce SOCKET_PINCTRL_PIN and KH50000_SOCKET_PINS macros to generate socket-suffixed pin names and indices for a given socket ID.
  • Replace the single kh50000_pins[] array with four per-socket arrays kh50000_pins_0[].._3[] using the socket-aware macro.
  • Ensure each socket shares the same pin index layout while having distinct names via UID suffixes.
drivers/pinctrl/zhaoxin/pinctrl-kh50000.c
drivers/pinctrl/zhaoxin/pinctrl-zhaoxin.h
Add per-socket SoC data structures and switch to UID-based probing for multi-socket instances.
  • Replace the single kh50000_soc_data struct with four socket_N_soc_data instances, each carrying a unique uid string ("0".."3") and referencing its corresponding per-socket pin table.
  • Aggregate the per-socket SoC data into a kh50000_soc_data[] pointer array terminated by NULL for lookup by UID.
  • Change the platform driver probe callback from zhaoxin_pinctrl_probe_by_hid to zhaoxin_pinctrl_probe_by_uid to select the correct socket instance based on ACPI UID.
  • Update the ACPI match table to reference the new SoC data array instead of a single SoC data struct.
drivers/pinctrl/zhaoxin/pinctrl-kh50000.c
Rework PMIO initialization to use a dynamically requested IO resource with corrected offsets.
  • Replace hard-coded PMIO base address and offsets (0x800, 0x90, 0x8c) with retrieval of an IORESOURCE_IO resource via platform_get_resource.
  • Add a request_region call on the PMIO IO range and error handling for missing resources or failed reservations.
  • Set pctrl->pmio_base from the resource start and adjust pmio_rx90 and pmio_rx8c offsets to 4 and 0 respectively for multi-socket compatibility.
  • Retain the existing private init behavior (zx_pad_write16(0xF8, 0x7F) and log message) after resource acquisition.
drivers/pinctrl/zhaoxin/pinctrl-kh50000.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 assign opsiff for approval. 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

@deepin-ci-robot
Copy link
Copy Markdown

Hi @leoliu-oc. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

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:

  • In kh50000_gpio_init(), the request_region() call should be paired with a corresponding release_region() in the driver’s remove/shutdown path to avoid leaking IO port regions when devices are unbound or probed multiple times.
  • The four socket_X_soc_data structs are identical except for uid and pins; consider introducing a helper macro or initializer to reduce duplication and make it easier to add or remove sockets consistently.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `kh50000_gpio_init()`, the `request_region()` call should be paired with a corresponding `release_region()` in the driver’s remove/shutdown path to avoid leaking IO port regions when devices are unbound or probed multiple times.
- The four `socket_X_soc_data` structs are identical except for `uid` and `pins`; consider introducing a helper macro or initializer to reduce duplication and make it easier to add or remove sockets consistently.

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.

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.

2 participants