Commit 07e6bf3
committed
drivers: spi: spi_infineon_pdl: add device_deinit hook
Add an ifx_cat1_spi_deinit() implementation and register it via
SPI_DEVICE_DT_INST_DEINIT_DEFINE so device_deinit(dev) succeeds on the
Infineon PSE84 / CAT1 SCB SPI driver. Without this hook the upstream
tests/drivers/spi/spi_loopback test_spi_deinit case returns -ENOTSUP and
skips.
The deinit:
- returns -EBUSY while a transfer is still in flight, to avoid tearing
down the SCB block in the middle of a transaction. The busy check is
consolidated into ifx_cat1_spi_is_busy(), which reports busy while the
SPI context still holds outstanding tx/rx buffers
(spi_context_tx_on()/spi_context_rx_on()), while Cy_SCB_SPI_IsBusBusy()
is active, or while an async transfer is still pending. The large-chunk
DMA path drives the transfer purely through the DMA channels without
setting data->pending, and Cy_SCB_SPI_IsBusBusy() can read idle between
FIFO-paced DMA bursts, so the SPI context buffer state is used as the
authoritative in-flight indicator that covers both the FIFO and DMA
paths for synchronous and asynchronous transfers,
- unregisters the deep-sleep SysPm callback (only when CONFIG_PM=y),
- disables the SCB IRQ,
- disables and deinits the SCB SPI block via PDL
(Cy_SCB_SPI_Disable / Cy_SCB_SPI_DeInit),
- stops the rx and tx DMA channels, mirroring ifx_cat1_spi_release()
(only when CONFIG_SPI_INFINEON_DMA=y).
The deinit function and its reference in the device definition are
guarded by CONFIG_DEVICE_DEINIT_SUPPORT, matching the pattern used by
drivers/spi/spi_nrfx_spim.c and drivers/spi/spi_bflb.c.
Also drop the unused dma_configured field from struct ifx_cat1_spi_data:
it was never read and never set to true anywhere in the driver.
Verified on kit_pse84_eval/pse846gps2dbzc4a/m55:
- [spi_loopback.test_spi_deinit] PASS
- [spi_loopback.test_spi_deinit_busy] PASS (device_deinit() returns
-EBUSY while an 8192-byte DMA transfer is in flight, then succeeds
and re-inits once the bus is idle)
Assisted-by: GitHub Copilot (Claude)
Signed-off-by: Bill Waters <bill.waters@infineon.com>1 parent be39a96 commit 07e6bf3
1 file changed
Lines changed: 70 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
| |||
593 | 592 | | |
594 | 593 | | |
595 | 594 | | |
596 | | - | |
597 | | - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
598 | 601 | | |
599 | 602 | | |
600 | 603 | | |
| |||
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
611 | 672 | | |
612 | 673 | | |
613 | 674 | | |
| |||
815 | 876 | | |
816 | 877 | | |
817 | 878 | | |
818 | | - | |
819 | | - | |
820 | | - | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
821 | 885 | | |
822 | 886 | | |
823 | 887 | | |
| |||
901 | 965 | | |
902 | 966 | | |
903 | 967 | | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | 968 | | |
913 | 969 | | |
914 | 970 | | |
| |||
0 commit comments