Skip to content

SPI:phytium:update phytium SPI controller driver support to 6.6.0.4#1685

Open
xiaqian1486 wants to merge 12 commits into
deepin-community:linux-6.6.yfrom
xiaqian1486:spi-6.6.y
Open

SPI:phytium:update phytium SPI controller driver support to 6.6.0.4#1685
xiaqian1486 wants to merge 12 commits into
deepin-community:linux-6.6.yfrom
xiaqian1486:spi-6.6.y

Conversation

@xiaqian1486
Copy link
Copy Markdown

@xiaqian1486 xiaqian1486 commented May 12, 2026

This patches updates the support for phytium SPI controller driver.

  1. Restricted adaptation platform for SPI_V2 driver
  2. Use global cs register to select chip by default
  3. Restricted adaptation platform for SPI driver
  4. Resolve the Resolve the "hung_task" issue during system restart
  5. Optimize the timer processing
  6. Optimize the clearing method of debug-log buffer
  7. Adjust the position of enable interrupts
  8. Refine the timeout value for SPI driver
  9. Add ARCH_PHYTIUM dependency
  10. Add ACPI FixedDMA support for DMA channels
  11. Add support for full-duplex transmission mode
  12. Add support ddr addr 0-45bit
  13. Fixed compile warning issue
  14. Fix CAN device hardware disconnect issue

Summary by Sourcery

Update Phytium SPI controller drivers for newer hardware capabilities, improved transfer modes, and more robust interrupt, DMA, and logging handling.

New Features:

  • Add a generic spi_phytium_xfer helper to support full-duplex-style data transfers when hardware allows.
  • Detect controller full-duplex capability via regfile and configure the SPI master and driver behavior accordingly.
  • Support extended DDR address ranges using a new high-address register in the SPI-V2 driver.
  • Enable DMA usage when ACPI FixedDMA resources are present and request DMA channels via ACPI when appropriate.

Bug Fixes:

  • Adjust SPI command completion handling and timeouts to avoid hangs and improve restart behavior.
  • Fix SPI-V2 NOR interaction checks to validate the associated spimem instance.
  • Guard against using full-duplex transfers when the controller only supports half-duplex mode.
  • Initialize ACPI partition parser child_handle to avoid use of an uninitialized pointer.

Enhancements:

  • Switch SPI-V2 debug-log buffer clearing to memset and use write-combined mapping for improved performance.
  • Base DMA data-path enablement on a controller version register instead of CPU-part detection.
  • Rework DDR base address derivation to handle both legacy and new DDR-high register layouts.
  • Ensure GPIO-based chip select handling uses GPIO descriptors via the SPI master flags.
  • Refine suspend/resume handling of the internal timer in the SPI-V2 driver.
  • Simplify debug-log buffer clearing in error handling paths.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 12, 2026

Reviewer's Guide

Updates the Phytium SPI controller drivers to a newer hardware/firmware spec: tightens timeouts and interrupt handling to fix hung_task issues, adds a new generic full‑duplex transfer path and DDR-high addressing based on a regfile version register, switches DMA and DDR features to be probed from hardware instead of CPU ID, adds ACPI FixedDMA-aware DMA setup, and cleans up debug-log and GPIO/CS handling.

Sequence diagram for updated Phytium SPI V2 full‑duplex transfer and completion

sequenceDiagram
    participant SpiCore as spi_master
    participant PhyDrv as spi_phyt_transfer_one
    participant Xfer as spi_phytium_xfer
    participant Ctlr as spi_phytium_set
    participant Wait as spi_phytium_check_result
    participant IRQ as spi_phyt_irq

    SpiCore->>PhyDrv: spi_phyt_transfer_one(master, spi, transfer, mem)
    PhyDrv->>PhyDrv: set fts->tx, fts->rx, fts->len
    PhyDrv->>PhyDrv: check fts->half_duplex
    alt tx and rx and !half_duplex
        PhyDrv->>Xfer: spi_phytium_xfer(fts, chip_select, bits_per_word, mode, tmode, flags)
        loop chunks
            Xfer->>Ctlr: spi_phytium_set(fts)
            Ctlr->>Wait: spi_phytium_check_result(fts)
            Wait->>Wait: phytium_write_regfile(fts, SPI_REGFILE_AP2RV_INTR_STATE, 0x10)
            Wait->>Wait: wait_for_completion_interruptible_timeout(&fts->cmd_completion, timeout)
        end
    else other paths
        PhyDrv->>PhyDrv: legacy read/write handling
    end

    IRQ-->>Wait: spi_phyt_irq(irq, dev_id)
    IRQ->>IRQ: writel_relaxed(0, RV2AP_INTR_STATE)
    IRQ->>IRQ: writel_relaxed(0x10, RV2AP_INT_CLEAN)
    IRQ->>Wait: complete(&fts->cmd_completion)
Loading

File-Level Changes

Change Details Files
Tighten command completion handling and move interrupt-arm to spi_phytium_check_result to avoid hangs on restart.
  • Reduce default SPI command timeout from 300s to 20s, with a special 200s timeout when flash_erase == 2.
  • Write SPI_REGFILE_AP2RV_INTR_STATE just before waiting, and use wait_for_completion_interruptible_timeout instead of wait_for_completion_timeout.
  • Remove redundant interrupt-state writes from helper functions that now rely on spi_phytium_check_result to arm interrupts centrally.
drivers/spi/spi-phytium-common.c
Introduce a generic full-duplex transfer helper that supports both PIO and DMA based on hardware capability.
  • Add spi_phytium_xfer() which slices transfers into up to 128-byte chunks, chooses between inline buffer copy and DMA (PHYTSPI_MSG_CMD_DATA_XFER vs _DMA_XFER), and manages TX/RX DDR addresses.
  • Update transfer_one() to detect simultaneous TX/RX buffers, enforce half-duplex restriction, and route full-duplex operations through spi_phytium_xfer.
  • Add new PHYTSPI message sub-IDs and the spi_phytium_xfer prototype to the common header, plus a half_duplex flag on the controller struct.
drivers/spi/spi-phytium-common.c
drivers/spi/spi-phytium-v2.c
drivers/spi/spi-phytium.h
Probe hardware capabilities via regfile version and software registers instead of CPU ID, enabling DMA and full/half duplex modes appropriately.
  • Read SPI_REGFILE_VERSION_REG at probe, cache it in fts->regfile_version, and set dma_get_ddrdata based on SPI_REGFILE_VERSION_DMA instead of MIDR_PHYTIUM_FTC872.
  • On host creation, read SPI_REGFILE_SOFTWARE2 & SPI_REGFILE_FULL_DUPLEX to decide if the controller is half-duplex; set master->flags
= SPI_CONTROLLER_HALF_DUPLEX and fts->half_duplex accordingly, otherwise allow full duplex.
  • Expose new regfile version and software register offsets/bitfields in spi-phytium.h.
  • Update DDR debug-log address handling for extended address width and optimize log buffer clearing/mapping.
    • When SPI_REGFILE_VERSION_DDR is set, compute DDR log base from SPI_REGFILE_DEBUG plus a high address from SPI_REGFILE_DDR_HIGH_REG; otherwise keep the old shifted-address scheme.
    • Map the log buffer using devm_ioremap_wc instead of devm_ioremap for write-combining access.
    • Replace manual byte-wise loops zeroing the log buffer with memset() in both error handler and HW init.
    drivers/spi/spi-phytium-v2.c
    drivers/spi/spi-phytium.h
    Refine controller registration, GPIO/CS, and timer handling for better integration and power management.
    • Enable master->use_gpio_descriptors so the core uses gpiod; remove platform-specific manual CS GPIO discovery from the V2 platform probe.
    • Set default global_cs to 1 for the non-V2 platform driver so chip select defaults to the global CS register unless overridden by DT/ACPI.
    • Delete the SPI watchdog timer on suspend and re-arm it shortly after resume to avoid stray callbacks across low-power transitions.
    drivers/spi/spi-phytium-plat-v2.c
    drivers/spi/spi-phytium-v2.c
    drivers/spi/spi-phytium-plat.c
    Add ACPI FixedDMA-aware DMA setup and minor ACPI-related robustness fixes.
    • Introduce phytium_acpi_has_FixedDMA() to scan ACPI _CRS for a FixedDMA resource and use it, together with DT properties, to decide if DMA should be enabled for the legacy SPI driver.
    • In the DMA backend, request channels using acpi_dma_request_slave_chan_by_index when an ACPI companion is present, falling back to dma_request_chan otherwise.
    • Initialize child_handle to NULL in ACPI partition parser to avoid potential use of an uninitialized pointer.
    drivers/spi/spi-phytium-plat.c
    drivers/spi/spi-phytium-dma.c
    drivers/mtd/parsers/acpipart_core.c
    Miscellaneous cleanups, version bumps, and small logic fixes.
    • Bump the V2 and legacy SPI driver versions (1.0.8→1.0.15 and 1.0.0→1.0.2).
    • Ensure spi_phyt_transfer_one() only associates spi_nor when mem && mem->spi == spi and guards NOR-specific path with non-NULL checks.
    • Adjust IRQ handler to clear RV2AP interrupt state before completing the command completion, reducing race potential.
    • Fix minor typos and header ordering, and add missing ACPI headers required by the new ACPI DMA path.
    drivers/spi/spi-phytium-plat-v2.c
    drivers/spi/spi-phytium-v2.c
    drivers/spi/spi-phytium-dma.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 avenger-285714 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 @xiaqian1486. Thanks for your PR. 😃

    @deepin-ci-robot
    Copy link
    Copy Markdown

    Hi @xiaqian1486. 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 spi_phytium_xfer(), the length calculation and buffer progression look wrong for full‑duplex: you compute len using (rx_end - rx) twice, never reference tx_end, never advance fts->tx, and never use the local data pointer, so the TX side will not progress correctly across chunks.
    • The use of wait_for_completion_interruptible_timeout() in spi_phytium_check_result() changes semantics compared to wait_for_completion_timeout(), but the return value is still treated as an unsigned timeout count; a signal interruption (negative return) will be misinterpreted as a large nonzero timeout and skip the error path—consider handling negative returns explicitly.
    • SPI_REGFILE_DDR_HIGH_REG is defined twice in spi-phytium.h (before and after the DEBUG register block), which is redundant and may confuse future maintainers; it would be better to keep a single definition in one place.
    Prompt for AI Agents
    Please address the comments from this code review:
    
    ## Overall Comments
    - In spi_phytium_xfer(), the length calculation and buffer progression look wrong for full‑duplex: you compute len using (rx_end - rx) twice, never reference tx_end, never advance fts->tx, and never use the local `data` pointer, so the TX side will not progress correctly across chunks.
    - The use of wait_for_completion_interruptible_timeout() in spi_phytium_check_result() changes semantics compared to wait_for_completion_timeout(), but the return value is still treated as an unsigned timeout count; a signal interruption (negative return) will be misinterpreted as a large nonzero timeout and skip the error path—consider handling negative returns explicitly.
    - SPI_REGFILE_DDR_HIGH_REG is defined twice in spi-phytium.h (before and after the DEBUG register block), which is redundant and may confuse future maintainers; it would be better to keep a single definition in one place.

    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.

    Copy link
    Copy Markdown

    Copilot AI left a comment

    Choose a reason for hiding this comment

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

    Pull request overview

    This PR updates the Phytium SPI controller drivers to a newer upstream version, adding new hardware capability detection (version/DDRx/full-duplex), improving restart/timeout handling, and extending DMA enablement (including ACPI FixedDMA).

    Changes:

    • Add regfile feature/version bits, DDR-high address support, and full-/half-duplex capability handling for SPI-V2.
    • Rework command completion signaling/timeouts and optimize debug-log buffer clearing/mapping.
    • Enable DMA on ACPI FixedDMA platforms and adjust Kconfig dependencies to restrict builds to ARCH_PHYTIUM.

    Reviewed changes

    Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.

    Show a summary per file
    File Description
    drivers/spi/spi-phytium.h Adds regfile offsets/version bits and new transfer sub-commands.
    drivers/spi/spi-phytium-common.c Adjusts completion/timeout signaling and adds a new full-duplex xfer helper.
    drivers/spi/spi-phytium-v2.c Updates interrupt completion ordering, full-duplex gating, DDR-high log mapping, and timer suspend/resume.
    drivers/spi/spi-phytium-plat.c Adds ACPI FixedDMA detection and changes DMA enablement logic; defaults global CS on.
    drivers/spi/spi-phytium-plat-v2.c Switches DMA capability detection to regfile version bits.
    drivers/spi/spi-phytium-dma.c Requests DMA channels via ACPI FixedDMA when present.
    drivers/spi/Kconfig Restricts Phytium SPI configs to ARCH_PHYTIUM and tightens PCI dependency.
    drivers/mtd/parsers/acpipart_core.c Initializes child_handle to avoid use of an uninitialized pointer.
    drivers/spi/spi-phytium-v2.c.orig Patch artifact file added (should be removed).
    drivers/spi/spi-phytium-v2.c.rej Patch artifact file added (should be removed).
    drivers/spi/Kconfig.orig Patch artifact file added (should be removed).
    drivers/spi/Kconfig.rej Patch artifact file added (should be removed).
    Comments suppressed due to low confidence (2)

    drivers/spi/spi-phytium-common.c:125

    • wait_for_completion_interruptible_timeout() returns a signed long (0 on timeout, <0 on signal). Storing it in an unsigned long long and only checking == 0 will mis-handle negative returns (they become large positive values), potentially treating an interrupted wait as success. Use a signed type (e.g., long timeleft) and handle timeleft < 0 explicitly.
    	unsigned long long ms = 20000;
    	struct msg *msg = (struct msg *)fts->tx_shmem_addr;
    
    	if (fts->flash_erase == 2)
    		ms = 200000;
    
    	reinit_completion(&fts->cmd_completion);
    	phytium_write_regfile(fts, SPI_REGFILE_AP2RV_INTR_STATE, 0x10);
    	ms = wait_for_completion_interruptible_timeout(&fts->cmd_completion, msecs_to_jiffies(ms));
    
    	if (ms == 0) {
    		dev_err(&fts->master->dev, "SPI controller timed out\n");
    		return -1;
    

    drivers/mtd/parsers/acpipart_core.c:37

    • child_handle is now initialized (good), but the subsequent device_get_next_child_node(dev, child_handle); call ignores the returned fwnode, leaving child_handle as NULL. If this is meant to probe for a 'partitions' child, assign the return value to child_handle (and drop the reference when done), otherwise the dedicated-subnode detection will never work.
    	struct fwnode_handle *child_handle = NULL;
    	bool dedicated = true;
    	struct device *dev;
    
    	dev = &master->dev;
    	adev = ACPI_COMPANION(&master->dev);
    
    	if (!master->parent) {/*master*/
    		device_get_next_child_node(dev, child_handle);
    		if (!child_handle) {
    			pr_debug("%s: 'partitions' subnode not found on %pOF. Trying to parse direct subnodes as partitions.\n",
    

    💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

    Comment thread drivers/spi/spi-phytium.h
    Comment on lines +61 to +76
    #define SPI_REGFILE_SIZE (0x48)
    #define SPI_REGFILE_DDR_HIGH_REG (0x4c)

    #define SPI_REGFILE_SOFTWARE2 (0x54)
    #define SPI_REGFILE_FULL_DUPLEX BIT(9)

    #define SPI_REGFILE_DEBUG (0x58)
    #define SPI_REGFILE_DEBUG_VAL BIT(0)
    #define SPI_REGFILE_ALIVE_VAL BIT(1)
    #define SPI_REGFILE_HEARTBIT_VAL BIT(2)
    #define SPI_REGFILE_HAVE_LOG BIT(3)
    #define SPI_REGFILE_SIZE_MASK GENMASK(7, 4)
    #define SPI_REGFILE_ADDR_MASK GENMASK(27, 8)

    #define SPI_REGFILE_DDR_HIGH_REG (0x4c)
    #define SPI_REGFILE_VERSION_REG (0x700)
    Comment on lines 136 to 142
    /* check is use dma transfer */
    if ((device_property_read_string_array(&pdev->dev, "dma-names",
    NULL, 0) > 0) &&
    device_property_present(&pdev->dev, "dmas")) {
    NULL, 0 > 0) &&
    device_property_present(&pdev->dev, "dmas")) ||
    (has_acpi_companion(&pdev->dev) &&
    phytium_acpi_has_FixedDMA(dev))) {
    fts->dma_en = true;
    Comment on lines +464 to +470
    do {
    if (fts->dma_get_ddrdata)
    len = min_t(u32, (u32)(fts->rx_end - fts->rx),
    (u32)(fts->rx_end - fts->rx));
    else
    len = min_t(u32, (u32)(fts->rx_end - fts->rx), 128);

    Comment on lines +492 to +518
    fts->msg->cmd_subid = PHYTSPI_MSG_CMD_DATA_XFER;
    memcpy_byte((void *)smem_tx, fts->tx, len);
    *(u64 *)&fts->msg->data[0] = sizeof(struct msg);
    *(u64 *)&fts->msg->data[8] = sizeof(struct msg) + 128;
    }

    *(u32 *)&fts->msg->data[16] = len;
    fts->msg->data[20] = cs;
    fts->msg->data[21] = dfs;
    fts->msg->data[22] = mode;
    fts->msg->data[23] = tmode;
    if (first == 1)
    fts->msg->data[24] = 1;
    else
    fts->msg->data[24] = flags;
    fts->msg->data[24] = first;
    ret = spi_phytium_set(fts);
    if (ret) {
    dev_err(&fts->master->dev, "AP <-> RV interaction failed\n");
    return ret;
    }
    if (len <= 16 || !fts->dma_get_ddrdata)
    memcpy_byte(fts->rx, (void *)smem_rx, len);

    fts->rx += len;
    first = 0;
    } while (fts->rx_end > fts->rx);
    fts->msg->data[24] = 1;
    else
    fts->msg->data[24] = flags;
    fts->msg->data[24] = first;
    static void spi_phyt_hw_init(struct device *dev, struct phytium_spi *fts)
    {
    u32 reg, i;
    u32 reg, i, reg_ddr_high;
    Comment thread drivers/spi/spi-phytium-v2.c.orig Outdated
    Comment on lines +1 to +5
    // SPDX-License-Identifier: GPL-2.0
    /*
    * Phytium SPI core controller driver.
    *
    * Copyright (c) 2023-2024, Phytium Technology Co., Ltd..
    Comment thread drivers/spi/spi-phytium-v2.c.rej Outdated
    Comment on lines +1 to +15
    --- drivers/spi/spi-phytium-v2.c
    +++ drivers/spi/spi-phytium-v2.c
    @@ -137,10 +137,10 @@ static int spi_phyt_transfer_one(struct spi_master *master,
    struct phytium_spi *fts = spi_master_get_devdata(master);
    struct chip_data *chip = spi_get_ctldata(spi);
    struct spi_mem *mem = spi_get_drvdata(spi);
    - struct spi_nor *nor;
    + struct spi_nor *nor = NULL;
    int ret;

    - if (mem)
    + if (mem && (mem->spi == spi))
    nor = spi_mem_get_drvdata(mem);

    fts->tx = (void *)transfer->tx_buf;
    Comment thread drivers/spi/Kconfig.orig Outdated
    Comment on lines +792 to +800
    config SPI_PHYTIUM
    tristate
    depends on ARCH_PHYTIUM

    config SPI_PHYTIUM_PLAT
    tristate "Phytium SPI controller platform support"
    depends on ARCH_PHYTIUM || COMPILE_TEST
    select SPI_PHYTIUM
    help
    Comment thread drivers/spi/Kconfig.rej Outdated
    Comment on lines +1 to +19
    --- drivers/spi/Kconfig
    +++ drivers/spi/Kconfig
    @@ -771,6 +771,7 @@ config SPI_PHYTIUM

    config SPI_PHYTIUM_PLAT
    tristate "Phytium SPI controller platform support"
    + depends on ARCH_PHYTIUM
    select SPI_PHYTIUM
    help
    This selects a platform driver for Phytium SPI controller.
    @@ -780,7 +781,7 @@ config SPI_PHYTIUM_PLAT

    config SPI_PHYTIUM_PCI
    tristate "Phytium SPI controller PCI support"
    - depends on PCI
    + depends on PCI && ARCH_PHYTIUM
    select SPI_PHYTIUM
    help
    This selects a PCI driver for Phytium SPI controller.
    This driver is exclusively for the PHYTIUM platform and is not
    compatible with other SoCs. This restriction prevents errors
    on unsupported platform.
    
    Mainline: Open-Source
    Signed-off-by:Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    The driver uses global-cs register(0x100) for chip selection by
    default. Slove the problem of not being able to read the device
    ID when using the internal chip selection register(0x10).
    
    Mainline: Open-Source
    Signed-off-by:Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    …tem restart
    
    Change the wait_for_completion_timeout function to the
    wait_for_completion_interruptable_timeout function. To Slove
    the issue of the "hung_task" during system restart, which will lead
    to system crash occasionally.
    
    Mainline: Open-Source
    Signed-off-by:Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    When the SPI device wakes up from sleep mode, it may hang up or timeout
    at extremely low probability. So We delete the timer during hibernation
    and restore it upon waking up.
    
    Mainline: Open-Source
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    Replace the original loop assignment with the more standard and
    efficient memset function to achieve the clearing operation of
    the debug-log buffer.
    
    Mainline: Open-Source
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    If the SPI interrupt is enabled before the waiting period is
    over, it will cause the SPI controller to timeout at low probability.
    
    Mainline: Open-Source
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    The time required for most requests is less than 1 second. Only
    the erase-chip takes a longer time, which will take several minutes.
    Therefore, it is not appropriate to use a uniform maxmum duration
    as the timeout period.
    
    Mainline: Open-Source
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    Enable DMA when the SPI controller is described by ACPI using FixedDMA.
    The driver now detects the ACPI firmware path, acquires RX/TX channels
    by index, and arms the DMA path accordingly, while preserving the
    existing Device Tree behavior. This prevents unintended fallback to PIO
    on ACPI platforms.
    
    Mainline: Open-Source
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: zhuling <zhuling2709@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    In order to accommodate devices such as spidev and tpm that
    support full-duplex transmission, full-duplex support has been
    added to the spi-v2 driver.
    
    Mainline: NA
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Min <pengmin1540@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    Determine whether to enable DMA andwhether it is compatible with
    32-bit and 45-bit physical memory addresses by reading the regfile
    version register added to the spi-v2 driver.
    
    Mainline: NA
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Yao <pengyao2712@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    The warning message 'child_handle is uninitialied' will occur
    when compiled, owing to uninitialized value for the child_handle
    parameter.
    
    Mainline: NA
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Yao <pengyao2712@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    This patch addresses two issues with Phytium SPI-V2 CAN device
    handling:
    
    1. Add hardware connection validation before accessing SPI device
    driver data. When CAN device is described in DTS but not physically
    connected, prevent crashes by checking spi_device validity before
    obtaining spi_mem drv data.
    
    2. Enable GPIO-based chip select simulation in SPI subsystem.
    Implement GPIO CS control by extracting GPIO chip select description
    from DTS/ACPI configuration and managing GPIO CS state within the
    SPI subsystem stack.
    
    3.The cs-gpios control is placed in the SPI subsystem,Due to
    code redundancy,the phytium controller driver code cs-gpios
    has been removed.
    
    This ensures proper handling of disconnected CAN devices and provides
    flexible chip select control for SPI-based CAN implementations.
    
    Mainline: NA
    Signed-off-by: Xia Qian <xiaqian1486@phytium.com.cn>
    Signed-off-by: Peng Yao <pengyao2712@phytium.com.cn>
    Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
    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.

    3 participants