* [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A [not found] <CGME20250219140249eucas1p1291eb86c932373c847a3314ae54789d5@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski [not found] ` <CGME20250219140250eucas1p2e099f0f15ce0342f816ae15666e3e2f9@eucas1p2.samsung.com> ` (21 more replies) 0 siblings, 22 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The LicheePi 4A board, featuring the T-HEAD TH1520 SoC, includes an Imagination Technologies BXM-4-64 GPU. Initial support for this GPU was provided through a downstream driver [1]. Recently, efforts have been made to upstream support for the Rogue family GPUs, which the BXM-4-64 is part of [2]. While the initial upstream driver focused on the AXE-1-16 GPU, newer patches have introduced support for the BXS-4-64 GPU [3]. The modern upstream drm/imagination driver is expected to support the BXM-4-64 as well [4][5]. As this support is being developed, it's crucial to upstream the necessary glue code including clock and power-domain drivers so they're ready for integration with the drm/imagination driver. Recent Progress: Firmware Improvements: Since August, the vendor has provided updated firmware [6][7] that correctly initiates the firmware for the BXM-4-64. Mesa Driver Testing: The vendor-supplied Mesa driver [8] partially works with Vulkan examples, such as rendering a triangle using Sascha Willems' Vulkan samples [9]. Although the triangle isn't rendered correctly (only the blue background appears), shader job submissions function properly, and IOCTL calls are correctly invoked. For testing, we used the following resources: Kernel Source: Custom kernel with necessary modifications [10]. Mesa Driver: Vendor-provided Mesa implementation [11]. Dependencies: Testing required a functional Display Processing Unit (DPU) and HDMI driver, which are currently not upstreamed. Efforts are underway to upstream the DPU DC8200 driver used in StarFive boards [12], which is the same DPU used on the LicheePi 4A. Once the DPU and HDMI drivers are upstreamed, GPU support can be fully upstream. Testing Status: This series has been tested by performing a probe-only operation, confirming that the firmware begins execution. The probe function initiates firmware execution and waits for the firmware to flip a specific status bit. [ 12.637880] powervr ffef400000.gpu: [drm] loaded firmware powervr/rogue_36.52.104.182_v1.fw [ 12.648979] powervr ffef400000.gpu: [drm] FW version v1.0 (build 6645434 OS) [ 12.678906] [drm] Initialized powervr 1.0.0 for ffef400000.gpu on minor 0 Power Management: Full power management capabilities require implementing the T-HEAD SoC AON protocol messaging via the hardware mailbox. Support for the mailbox was merged in kernel 6.13 [13], and the AON protocol implementation is part of this series, since v2. Therefore this series support full power management capabilities for the GPU driver. Thanks everyone for taking the time to review the last revision ! Your guidance and the direction was very helpful. v5: Reset Changes: - Moved the reset de-assertion from the reset driver to the clock driver. The reset is now only de-asserted once the sys and core clocks have been enabled - Added and exported the GPU_CLKGEN reset, allowing the clock driver to reset the GPU clock circuit Clock Changes: - Introduced a new macro CCU_GATE_CLK_OPS, which allows providing custom clk_ops. In the case of the 'MEM' clock, it provides empty clk_nops. Later, this clock is provided to the GPU node, thereby avoiding any ABI breakage - Used the CCU_GATE_CLK_OPS macro to implement a workaround for de-asserting the clkgen reset only after both core and sys clocks are enabled. This sequence is required to properly initialize the GPU Power-domain/Firmware Changes: - Changed the AON driver to be a set of library functions rather than a standalone driver Imagination Driver Changes: - Moved the recommended 1 microsecond delay after de-asserting GPU reset to the Imagination driver itself - Included the mem clock to preserve the ABI, acknowledging that this clock exists but is not configurable from the SoC - A few remaining conflicts will be resolved after the dt-binding changes mentioned in the review are merged v4: Device Tree Changes: - restructured power device tree bindings by abstracting power-domain IDs from firmware IDs, with the mappings now defined in a dedicated header file - retained existing clock-names in img,powervr-rogue.yaml to maintain ABI compatibility, despite having only one downstream user - enhanced documentation for new Video Output (VO) clock inputs in device tree bindings Reset Driver Changes: - reverted reset-cells configuration to single cell as in v2 - maintained reset definitions in device tree bindings while deferring implementation of watchdog timer (WDT) reset functionality - addressed implementation issues in the DRM/Imagination reset driver Power Domain Changes: - added workaround to disable AUDIO power domain to prevent firmware crashes v3: Device Tree Changes: - consolidated device tree representation by merging aon and power-domain nodes while maintaining separate drivers internally - power-domain driver is now instantiated from within the aon driver - updated img,powervr-rogue.yaml to use allOf and oneOf for better schema organization AP Clock Driver Improvements: - reworked driver to support multiple clock controllers through .compatible and .data instead of using multiple address spaces in dt-binding. This change allows to re-use the driver code for multiple clock controllers Code Quality and Documentation: - fixed optional module dependencies in Kconfig - added kernel-doc comments for all exported functions - implemented th1520_aon_remove() to properly clean up mailbox channel resources - removed unnecessary of.h header in multiple drivers - refactored reset driver to use zero cells v2: Removed AP_SUBSYS clock refactoring commits (1-6): - instead of refactoring, I opted to extend the current driver and its associated device tree node to include support for a second address space. Expanded patchset scope to fully support power management capabilities: - introduced a new firmware driver to manage power-related operations. - rewrote the power-domain driver to function alongside the firmware driver. These nodes in the device tree lack direct address spaces, despite representing HW blocks. Control is achieved via firmware protocol messages transmitted through a mailbox to the E902 core. Implemented a reset controller for the TH1520 SoC: - developed a reset controller driver for the TH1520 to manage reset sequences. - updated the drm/imagination driver to act as a reset controller consumer. While this patchset is focused on the LPI4A board, the reset controller is designed to be useful for other boards, such as the BPI-3F, which also require a reset sequence after power-up. Updated dt-bindings: - added new dt-bindings for power, reset, and firmware nodes. - updated the powervr dt-binding to include reset support and new compatibles. - ran dtbs_check and dt_binding_check to ensure compliance. Addressed code quality: - resolved all checkpatch issues using --strict, except for the call to devm_clk_hw_register_gate_parent_data(). The current implementation remains preferable in this context, and clang-format aligns with this choice. References: [1] Downstream Driver Source: https://gitlab.freedesktop.org/frankbinns/powervr/-/blob/cb1929932095649a24f051b9cfdd2cd2ceab35cb/drivers/gpu/drm/img-rogue/Kconfig [2] Initial Upstream Driver Series: https://lore.kernel.org/all/cover.1700668843.git.donald.robson@imgtec.com/ [3] BXS-4-64 GPU Support Patches: https://lore.kernel.org/all/20241105-sets-bxs-4-64-patch-v1-v1-0-4ed30e865892@imgtec.com/ [4] Firmware Issue Discussion 1: https://gitlab.freedesktop.org/imagination/linux-firmware/-/issues/1 [5] Firmware Issue Discussion 2: https://gitlab.freedesktop.org/imagination/linux-firmware/-/issues/2 [6] Firmware Update Commit 1: https://gitlab.freedesktop.org/imagination/linux-firmware/-/commit/6ac2247e9a1d1837af495fb6d0fbd6f35547c2d1 [7] Firmware Update Commit 2: https://gitlab.freedesktop.org/imagination/linux-firmware/-/commit/efbebc90f25adb2b2e1499e3cc24ea3f3c3e4f4c [8] Vendor-Provided Mesa Driver: https://gitlab.freedesktop.org/imagination/mesa/-/tree/dev/devinfo [9] Sascha Willems' Vulkan Samples: https://github.com/SaschaWillems/Vulkan [10] Test Kernel Source: https://github.com/mwilczy/linux/tree/2_December_reference_linux_kernel_imagination [11] Test Mesa Driver: https://github.com/mwilczy/mesa-reference [12] DPU DC8200 Driver Upstream Attempt: https://lore.kernel.org/all/20241120061848.196754-1-keith.zhao@starfivetech.com/ [13] Pull request kernel 6.13 for mailbox https://lore.kernel.org/all/CABb+yY33qnivK-PzqpSMgmtbFid4nS8wcNvP7wED9DXrYAyLKg@mail.gmail.com/ Michal Wilczynski (21): dt-bindings: clock: thead: Add TH1520 VO clock controller clk: thead: Add clock support for VO subsystem in T-Head TH1520 SoC dt-bindings: firmware: thead,th1520: Add support for firmware node firmware: thead: Add AON firmware protocol driver dt-bindings: power: Add TH1520 SoC power domains pmdomain: thead: Add power-domain driver for TH1520 riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs clk: thead: Add support for custom ops in CCU_GATE_CLK_OPS macro dt-bindings: clock: thead: Add GPU clkgen reset property clk: thead: Add GPU clock gate control with CLKGEN reset support dt-bindings: reset: Add T-HEAD TH1520 SoC Reset Controller reset: thead: Add TH1520 reset controller driver drm/imagination: Add reset controller support for GPU initialization dt-bindings: gpu: Add 'resets' property for GPU initialization dt-bindings: gpu: Add support for T-HEAD TH1520 GPU drm/imagination: Add support for IMG BXM-4-64 GPU drm/imagination: Enable PowerVR driver for RISC-V riscv: dts: thead: Add device tree VO clock controller riscv: dts: thead: Introduce power domain nodes with aon firmware riscv: dts: thead: Introduce reset controller node riscv: dts: thead: Add GPU node to TH1520 device tree .../bindings/clock/thead,th1520-clk-ap.yaml | 33 +- .../bindings/firmware/thead,th1520-aon.yaml | 53 ++++ .../bindings/gpu/img,powervr-rogue.yaml | 42 ++- .../bindings/reset/thead,th1520-reset.yaml | 44 +++ MAINTAINERS | 8 + arch/riscv/Kconfig.socs | 1 + arch/riscv/boot/dts/thead/th1520.dtsi | 36 +++ drivers/clk/thead/clk-th1520-ap.c | 298 ++++++++++++++++-- drivers/firmware/Kconfig | 9 + drivers/firmware/Makefile | 1 + drivers/firmware/thead,th1520-aon.c | 247 +++++++++++++++ drivers/gpu/drm/imagination/Kconfig | 2 +- drivers/gpu/drm/imagination/pvr_device.c | 21 ++ drivers/gpu/drm/imagination/pvr_device.h | 9 + drivers/gpu/drm/imagination/pvr_drv.c | 2 + drivers/gpu/drm/imagination/pvr_power.c | 22 +- drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/thead/Kconfig | 12 + drivers/pmdomain/thead/Makefile | 2 + drivers/pmdomain/thead/th1520-pm-domains.c | 209 ++++++++++++ drivers/reset/Kconfig | 10 + drivers/reset/Makefile | 1 + drivers/reset/reset-th1520.c | 141 +++++++++ .../dt-bindings/clock/thead,th1520-clk-ap.h | 34 ++ .../dt-bindings/power/thead,th1520-power.h | 19 ++ .../dt-bindings/reset/thead,th1520-reset.h | 16 + .../linux/firmware/thead/thead,th1520-aon.h | 200 ++++++++++++ 28 files changed, 1437 insertions(+), 37 deletions(-) create mode 100644 Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml create mode 100644 Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml create mode 100644 drivers/firmware/thead,th1520-aon.c create mode 100644 drivers/pmdomain/thead/Kconfig create mode 100644 drivers/pmdomain/thead/Makefile create mode 100644 drivers/pmdomain/thead/th1520-pm-domains.c create mode 100644 drivers/reset/reset-th1520.c create mode 100644 include/dt-bindings/power/thead,th1520-power.h create mode 100644 include/dt-bindings/reset/thead,th1520-reset.h create mode 100644 include/linux/firmware/thead/thead,th1520-aon.h -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140250eucas1p2e099f0f15ce0342f816ae15666e3e2f9@eucas1p2.samsung.com>]
* [PATCH v5 01/21] dt-bindings: clock: thead: Add TH1520 VO clock controller [not found] ` <CGME20250219140250eucas1p2e099f0f15ce0342f816ae15666e3e2f9@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski, Krzysztof Kozlowski Add device tree bindings for the TH1520 Video Output (VO) subsystem clock controller. The VO sub-system manages clock gates for multimedia components including HDMI, MIPI, and GPU. Document the VIDEO_PLL requirements for the VO clock controller, which receives its input from the AP clock controller. The VIDEO_PLL is a Silicon Creations Sigma-Delta (integer) PLL typically running at 792 MHz with maximum FOUTVCO of 2376 MHz. This binding complements the existing AP sub-system clock controller which manages CPU, DPU, GMAC and TEE PLLs. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- .../bindings/clock/thead,th1520-clk-ap.yaml | 17 ++++++++-- .../dt-bindings/clock/thead,th1520-clk-ap.h | 34 +++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml index 0129bd0ba4b3..9d058c00ab3d 100644 --- a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml +++ b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml @@ -8,7 +8,8 @@ title: T-HEAD TH1520 AP sub-system clock controller description: | The T-HEAD TH1520 AP sub-system clock controller configures the - CPU, DPU, GMAC and TEE PLLs. + CPU, DPU, GMAC and TEE PLLs. Additionally the VO subsystem configures + the clock gates for the HDMI, MIPI and the GPU. SoC reference manual https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf @@ -20,14 +21,24 @@ maintainers: properties: compatible: - const: thead,th1520-clk-ap + enum: + - thead,th1520-clk-ap + - thead,th1520-clk-vo reg: maxItems: 1 clocks: items: - - description: main oscillator (24MHz) + - description: | + One input clock: + - For "thead,th1520-clk-ap": the clock input must be the 24 MHz + main oscillator. + - For "thead,th1520-clk-vo": the clock input must be the VIDEO_PLL, + which is configured by the AP clock controller. According to the + TH1520 manual, VIDEO_PLL is a Silicon Creations Sigma-Delta PLL + (integer PLL) typically running at 792 MHz (FOUTPOSTDIV), with + a maximum FOUTVCO of 2376 MHz. "#clock-cells": const: 1 diff --git a/include/dt-bindings/clock/thead,th1520-clk-ap.h b/include/dt-bindings/clock/thead,th1520-clk-ap.h index a199784b3512..09a9aa7b3ab1 100644 --- a/include/dt-bindings/clock/thead,th1520-clk-ap.h +++ b/include/dt-bindings/clock/thead,th1520-clk-ap.h @@ -93,4 +93,38 @@ #define CLK_SRAM3 83 #define CLK_PLL_GMAC_100M 84 #define CLK_UART_SCLK 85 + +/* VO clocks */ +#define CLK_AXI4_VO_ACLK 0 +#define CLK_GPU_MEM 1 +#define CLK_GPU_CORE 2 +#define CLK_GPU_CFG_ACLK 3 +#define CLK_DPU_PIXELCLK0 4 +#define CLK_DPU_PIXELCLK1 5 +#define CLK_DPU_HCLK 6 +#define CLK_DPU_ACLK 7 +#define CLK_DPU_CCLK 8 +#define CLK_HDMI_SFR 9 +#define CLK_HDMI_PCLK 10 +#define CLK_HDMI_CEC 11 +#define CLK_MIPI_DSI0_PCLK 12 +#define CLK_MIPI_DSI1_PCLK 13 +#define CLK_MIPI_DSI0_CFG 14 +#define CLK_MIPI_DSI1_CFG 15 +#define CLK_MIPI_DSI0_REFCLK 16 +#define CLK_MIPI_DSI1_REFCLK 17 +#define CLK_HDMI_I2S 18 +#define CLK_X2H_DPU1_ACLK 19 +#define CLK_X2H_DPU_ACLK 20 +#define CLK_AXI4_VO_PCLK 21 +#define CLK_IOPMP_VOSYS_DPU_PCLK 22 +#define CLK_IOPMP_VOSYS_DPU1_PCLK 23 +#define CLK_IOPMP_VOSYS_GPU_PCLK 24 +#define CLK_IOPMP_DPU1_ACLK 25 +#define CLK_IOPMP_DPU_ACLK 26 +#define CLK_IOPMP_GPU_ACLK 27 +#define CLK_MIPIDSI0_PIXCLK 28 +#define CLK_MIPIDSI1_PIXCLK 29 +#define CLK_HDMI_PIXCLK 30 + #endif -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140252eucas1p10c718f8e337ab3bf35f4debc56f13f86@eucas1p1.samsung.com>]
* [PATCH v5 02/21] clk: thead: Add clock support for VO subsystem in T-Head TH1520 SoC [not found] ` <CGME20250219140252eucas1p10c718f8e337ab3bf35f4debc56f13f86@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The T-Head TH1520 SoC integrates a variety of clocks for its subsystems, including the Application Processor (AP) and the Video Output (VO) [1]. Up until now, the T-Head clock driver only supported AP clocks. This commit extends the driver to provide clock functionality for the VO subsystem. At this stage, the focus is on implementing the VO clock gates, as these are currently the most relevant and required components for enabling and disabling the VO subsystem functionality. Future enhancements may introduce additional VO-related clocks as necessary. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1] Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- drivers/clk/thead/clk-th1520-ap.c | 197 +++++++++++++++++++++++++----- 1 file changed, 169 insertions(+), 28 deletions(-) diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c index 4c9555fc6184..57972589f120 100644 --- a/drivers/clk/thead/clk-th1520-ap.c +++ b/drivers/clk/thead/clk-th1520-ap.c @@ -847,6 +847,67 @@ static CCU_GATE(CLK_SRAM1, sram1_clk, "sram1", axi_aclk_pd, 0x20c, BIT(3), 0); static CCU_GATE(CLK_SRAM2, sram2_clk, "sram2", axi_aclk_pd, 0x20c, BIT(2), 0); static CCU_GATE(CLK_SRAM3, sram3_clk, "sram3", axi_aclk_pd, 0x20c, BIT(1), 0); +static CCU_GATE(CLK_AXI4_VO_ACLK, axi4_vo_aclk, "axi4-vo-aclk", + video_pll_clk_pd, 0x0, BIT(0), 0); +static CCU_GATE(CLK_GPU_CORE, gpu_core_clk, "gpu-core-clk", video_pll_clk_pd, + 0x0, BIT(3), 0); +static CCU_GATE(CLK_GPU_CFG_ACLK, gpu_cfg_aclk, "gpu-cfg-aclk", + video_pll_clk_pd, 0x0, BIT(4), 0); +static CCU_GATE(CLK_DPU_PIXELCLK0, dpu0_pixelclk, "dpu0-pixelclk", + video_pll_clk_pd, 0x0, BIT(5), 0); +static CCU_GATE(CLK_DPU_PIXELCLK1, dpu1_pixelclk, "dpu1-pixelclk", + video_pll_clk_pd, 0x0, BIT(6), 0); +static CCU_GATE(CLK_DPU_HCLK, dpu_hclk, "dpu-hclk", video_pll_clk_pd, 0x0, + BIT(7), 0); +static CCU_GATE(CLK_DPU_ACLK, dpu_aclk, "dpu-aclk", video_pll_clk_pd, 0x0, + BIT(8), 0); +static CCU_GATE(CLK_DPU_CCLK, dpu_cclk, "dpu-cclk", video_pll_clk_pd, 0x0, + BIT(9), 0); +static CCU_GATE(CLK_HDMI_SFR, hdmi_sfr_clk, "hdmi-sfr-clk", video_pll_clk_pd, + 0x0, BIT(10), 0); +static CCU_GATE(CLK_HDMI_PCLK, hdmi_pclk, "hdmi-pclk", video_pll_clk_pd, 0x0, + BIT(11), 0); +static CCU_GATE(CLK_HDMI_CEC, hdmi_cec_clk, "hdmi-cec-clk", video_pll_clk_pd, + 0x0, BIT(12), 0); +static CCU_GATE(CLK_MIPI_DSI0_PCLK, mipi_dsi0_pclk, "mipi-dsi0-pclk", + video_pll_clk_pd, 0x0, BIT(13), 0); +static CCU_GATE(CLK_MIPI_DSI1_PCLK, mipi_dsi1_pclk, "mipi-dsi1-pclk", + video_pll_clk_pd, 0x0, BIT(14), 0); +static CCU_GATE(CLK_MIPI_DSI0_CFG, mipi_dsi0_cfg_clk, "mipi-dsi0-cfg-clk", + video_pll_clk_pd, 0x0, BIT(15), 0); +static CCU_GATE(CLK_MIPI_DSI1_CFG, mipi_dsi1_cfg_clk, "mipi-dsi1-cfg-clk", + video_pll_clk_pd, 0x0, BIT(16), 0); +static CCU_GATE(CLK_MIPI_DSI0_REFCLK, mipi_dsi0_refclk, "mipi-dsi0-refclk", + video_pll_clk_pd, 0x0, BIT(17), 0); +static CCU_GATE(CLK_MIPI_DSI1_REFCLK, mipi_dsi1_refclk, "mipi-dsi1-refclk", + video_pll_clk_pd, 0x0, BIT(18), 0); +static CCU_GATE(CLK_HDMI_I2S, hdmi_i2s_clk, "hdmi-i2s-clk", video_pll_clk_pd, + 0x0, BIT(19), 0); +static CCU_GATE(CLK_X2H_DPU1_ACLK, x2h_dpu1_aclk, "x2h-dpu1-aclk", + video_pll_clk_pd, 0x0, BIT(20), 0); +static CCU_GATE(CLK_X2H_DPU_ACLK, x2h_dpu_aclk, "x2h-dpu-aclk", + video_pll_clk_pd, 0x0, BIT(21), 0); +static CCU_GATE(CLK_AXI4_VO_PCLK, axi4_vo_pclk, "axi4-vo-pclk", + video_pll_clk_pd, 0x0, BIT(22), 0); +static CCU_GATE(CLK_IOPMP_VOSYS_DPU_PCLK, iopmp_vosys_dpu_pclk, + "iopmp-vosys-dpu-pclk", video_pll_clk_pd, 0x0, BIT(23), 0); +static CCU_GATE(CLK_IOPMP_VOSYS_DPU1_PCLK, iopmp_vosys_dpu1_pclk, + "iopmp-vosys-dpu1-pclk", video_pll_clk_pd, 0x0, BIT(24), 0); +static CCU_GATE(CLK_IOPMP_VOSYS_GPU_PCLK, iopmp_vosys_gpu_pclk, + "iopmp-vosys-gpu-pclk", video_pll_clk_pd, 0x0, BIT(25), 0); +static CCU_GATE(CLK_IOPMP_DPU1_ACLK, iopmp_dpu1_aclk, "iopmp-dpu1-aclk", + video_pll_clk_pd, 0x0, BIT(27), 0); +static CCU_GATE(CLK_IOPMP_DPU_ACLK, iopmp_dpu_aclk, "iopmp-dpu-aclk", + video_pll_clk_pd, 0x0, BIT(28), 0); +static CCU_GATE(CLK_IOPMP_GPU_ACLK, iopmp_gpu_aclk, "iopmp-gpu-aclk", + video_pll_clk_pd, 0x0, BIT(29), 0); +static CCU_GATE(CLK_MIPIDSI0_PIXCLK, mipi_dsi0_pixclk, "mipi-dsi0-pixclk", + video_pll_clk_pd, 0x0, BIT(30), 0); +static CCU_GATE(CLK_MIPIDSI1_PIXCLK, mipi_dsi1_pixclk, "mipi-dsi1-pixclk", + video_pll_clk_pd, 0x0, BIT(31), 0); +static CCU_GATE(CLK_HDMI_PIXCLK, hdmi_pixclk, "hdmi-pixclk", video_pll_clk_pd, + 0x4, BIT(0), 0); + static CLK_FIXED_FACTOR_HW(gmac_pll_clk_100m, "gmac-pll-clk-100m", &gmac_pll_clk.common.hw, 10, 1, 0); @@ -963,7 +1024,38 @@ static struct ccu_common *th1520_gate_clks[] = { &sram3_clk.common, }; -#define NR_CLKS (CLK_UART_SCLK + 1) +static struct ccu_common *th1520_vo_gate_clks[] = { + &axi4_vo_aclk.common, + &gpu_core_clk.common, + &gpu_cfg_aclk.common, + &dpu0_pixelclk.common, + &dpu1_pixelclk.common, + &dpu_hclk.common, + &dpu_aclk.common, + &dpu_cclk.common, + &hdmi_sfr_clk.common, + &hdmi_pclk.common, + &hdmi_cec_clk.common, + &mipi_dsi0_pclk.common, + &mipi_dsi1_pclk.common, + &mipi_dsi0_cfg_clk.common, + &mipi_dsi1_cfg_clk.common, + &mipi_dsi0_refclk.common, + &mipi_dsi1_refclk.common, + &hdmi_i2s_clk.common, + &x2h_dpu1_aclk.common, + &x2h_dpu_aclk.common, + &axi4_vo_pclk.common, + &iopmp_vosys_dpu_pclk.common, + &iopmp_vosys_dpu1_pclk.common, + &iopmp_vosys_gpu_pclk.common, + &iopmp_dpu1_aclk.common, + &iopmp_dpu_aclk.common, + &iopmp_gpu_aclk.common, + &mipi_dsi0_pixclk.common, + &mipi_dsi1_pixclk.common, + &hdmi_pixclk.common +}; static const struct regmap_config th1520_clk_regmap_config = { .reg_bits = 32, @@ -972,8 +1064,44 @@ static const struct regmap_config th1520_clk_regmap_config = { .fast_io = true, }; +struct th1520_plat_data { + struct ccu_common **th1520_pll_clks; + struct ccu_common **th1520_div_clks; + struct ccu_common **th1520_mux_clks; + struct ccu_common **th1520_gate_clks; + + int nr_clks; + int nr_pll_clks; + int nr_div_clks; + int nr_mux_clks; + int nr_gate_clks; +}; + +static const struct th1520_plat_data th1520_ap_platdata = { + .th1520_pll_clks = th1520_pll_clks, + .th1520_div_clks = th1520_div_clks, + .th1520_mux_clks = th1520_mux_clks, + .th1520_gate_clks = th1520_gate_clks, + + .nr_clks = CLK_UART_SCLK + 1, + + .nr_pll_clks = ARRAY_SIZE(th1520_pll_clks), + .nr_div_clks = ARRAY_SIZE(th1520_div_clks), + .nr_mux_clks = ARRAY_SIZE(th1520_mux_clks), + .nr_gate_clks = ARRAY_SIZE(th1520_gate_clks), +}; + +static const struct th1520_plat_data th1520_vo_platdata = { + .th1520_gate_clks = th1520_vo_gate_clks, + + .nr_clks = CLK_HDMI_PIXCLK + 1, + + .nr_gate_clks = ARRAY_SIZE(th1520_vo_gate_clks), +}; + static int th1520_clk_probe(struct platform_device *pdev) { + const struct th1520_plat_data *plat_data; struct device *dev = &pdev->dev; struct clk_hw_onecell_data *priv; @@ -982,11 +1110,17 @@ static int th1520_clk_probe(struct platform_device *pdev) struct clk_hw *hw; int ret, i; - priv = devm_kzalloc(dev, struct_size(priv, hws, NR_CLKS), GFP_KERNEL); + plat_data = device_get_match_data(&pdev->dev); + if (!plat_data) { + dev_err(&pdev->dev, "Error: No device match data found\n"); + return -ENODEV; + } + + priv = devm_kzalloc(dev, struct_size(priv, hws, plat_data->nr_clks), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->num = NR_CLKS; + priv->num = plat_data->nr_clks; base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) @@ -996,35 +1130,35 @@ static int th1520_clk_probe(struct platform_device *pdev) if (IS_ERR(map)) return PTR_ERR(map); - for (i = 0; i < ARRAY_SIZE(th1520_pll_clks); i++) { - struct ccu_pll *cp = hw_to_ccu_pll(&th1520_pll_clks[i]->hw); + for (i = 0; i < plat_data->nr_pll_clks; i++) { + struct ccu_pll *cp = hw_to_ccu_pll(&plat_data->th1520_pll_clks[i]->hw); - th1520_pll_clks[i]->map = map; + plat_data->th1520_pll_clks[i]->map = map; - ret = devm_clk_hw_register(dev, &th1520_pll_clks[i]->hw); + ret = devm_clk_hw_register(dev, &plat_data->th1520_pll_clks[i]->hw); if (ret) return ret; priv->hws[cp->common.clkid] = &cp->common.hw; } - for (i = 0; i < ARRAY_SIZE(th1520_div_clks); i++) { - struct ccu_div *cd = hw_to_ccu_div(&th1520_div_clks[i]->hw); + for (i = 0; i < plat_data->nr_div_clks; i++) { + struct ccu_div *cd = hw_to_ccu_div(&plat_data->th1520_div_clks[i]->hw); - th1520_div_clks[i]->map = map; + plat_data->th1520_div_clks[i]->map = map; - ret = devm_clk_hw_register(dev, &th1520_div_clks[i]->hw); + ret = devm_clk_hw_register(dev, &plat_data->th1520_div_clks[i]->hw); if (ret) return ret; priv->hws[cd->common.clkid] = &cd->common.hw; } - for (i = 0; i < ARRAY_SIZE(th1520_mux_clks); i++) { - struct ccu_mux *cm = hw_to_ccu_mux(&th1520_mux_clks[i]->hw); + for (i = 0; i < plat_data->nr_mux_clks; i++) { + struct ccu_mux *cm = hw_to_ccu_mux(&plat_data->th1520_mux_clks[i]->hw); const struct clk_init_data *init = cm->common.hw.init; - th1520_mux_clks[i]->map = map; + plat_data->th1520_mux_clks[i]->map = map; hw = devm_clk_hw_register_mux_parent_data_table(dev, init->name, init->parent_data, @@ -1040,10 +1174,10 @@ static int th1520_clk_probe(struct platform_device *pdev) priv->hws[cm->common.clkid] = hw; } - for (i = 0; i < ARRAY_SIZE(th1520_gate_clks); i++) { - struct ccu_gate *cg = hw_to_ccu_gate(&th1520_gate_clks[i]->hw); + for (i = 0; i < plat_data->nr_gate_clks; i++) { + struct ccu_gate *cg = hw_to_ccu_gate(&plat_data->th1520_gate_clks[i]->hw); - th1520_gate_clks[i]->map = map; + plat_data->th1520_gate_clks[i]->map = map; hw = devm_clk_hw_register_gate_parent_data(dev, cg->common.hw.init->name, @@ -1057,19 +1191,21 @@ static int th1520_clk_probe(struct platform_device *pdev) priv->hws[cg->common.clkid] = hw; } - ret = devm_clk_hw_register(dev, &osc12m_clk.hw); - if (ret) - return ret; - priv->hws[CLK_OSC12M] = &osc12m_clk.hw; + if (plat_data == &th1520_ap_platdata) { + ret = devm_clk_hw_register(dev, &osc12m_clk.hw); + if (ret) + return ret; + priv->hws[CLK_OSC12M] = &osc12m_clk.hw; - ret = devm_clk_hw_register(dev, &gmac_pll_clk_100m.hw); - if (ret) - return ret; - priv->hws[CLK_PLL_GMAC_100M] = &gmac_pll_clk_100m.hw; + ret = devm_clk_hw_register(dev, &gmac_pll_clk_100m.hw); + if (ret) + return ret; + priv->hws[CLK_PLL_GMAC_100M] = &gmac_pll_clk_100m.hw; - ret = devm_clk_hw_register(dev, &emmc_sdio_ref_clk.hw); - if (ret) - return ret; + ret = devm_clk_hw_register(dev, &emmc_sdio_ref_clk.hw); + if (ret) + return ret; + } ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv); if (ret) @@ -1081,6 +1217,11 @@ static int th1520_clk_probe(struct platform_device *pdev) static const struct of_device_id th1520_clk_match[] = { { .compatible = "thead,th1520-clk-ap", + .data = &th1520_ap_platdata, + }, + { + .compatible = "thead,th1520-clk-vo", + .data = &th1520_vo_platdata, }, { /* sentinel */ }, }; -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140253eucas1p2a137df988b89e84b7e52c45521b5bb06@eucas1p2.samsung.com>]
* [PATCH v5 03/21] dt-bindings: firmware: thead,th1520: Add support for firmware node [not found] ` <CGME20250219140253eucas1p2a137df988b89e84b7e52c45521b5bb06@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski, Krzysztof Kozlowski The kernel communicates with the E902 core through the mailbox transport using AON firmware protocol. Add dt-bindings to document it the dt node. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- .../bindings/firmware/thead,th1520-aon.yaml | 53 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml diff --git a/Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml b/Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml new file mode 100644 index 000000000000..bbc183200400 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/thead,th1520-aon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: T-HEAD TH1520 AON (Always-On) Firmware + +description: | + The Always-On (AON) subsystem in the TH1520 SoC is responsible for managing + low-power states, system wakeup events, and power management tasks. It is + designed to operate independently in a dedicated power domain, allowing it to + remain functional even during the SoC's deep sleep states. + + At the heart of the AON subsystem is the E902, a low-power core that executes + firmware responsible for coordinating tasks such as power domain control, + clock management, and system wakeup signaling. Communication between the main + SoC and the AON subsystem is handled through a mailbox interface, which + enables message-based interactions with the AON firmware. + +maintainers: + - Michal Wilczynski <m.wilczynski@samsung.com> + +properties: + compatible: + const: thead,th1520-aon + + mboxes: + maxItems: 1 + + mbox-names: + items: + - const: aon + + "#power-domain-cells": + const: 1 + +required: + - compatible + - mboxes + - mbox-names + - "#power-domain-cells" + +additionalProperties: false + +examples: + - | + aon: aon { + compatible = "thead,th1520-aon"; + mboxes = <&mbox_910t 1>; + mbox-names = "aon"; + #power-domain-cells = <1>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index efee40ea589f..0934f9791fe9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20413,6 +20413,7 @@ L: linux-riscv@lists.infradead.org S: Maintained T: git https://github.com/pdp7/linux.git F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml +F: Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140254eucas1p23528e98a5279252a1acdd97d0162c26a@eucas1p2.samsung.com>]
* [PATCH v5 04/21] firmware: thead: Add AON firmware protocol driver [not found] ` <CGME20250219140254eucas1p23528e98a5279252a1acdd97d0162c26a@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The T-Head TH1520 SoC uses an E902 co-processor running Always-On (AON) firmware to manage power, clock, and other system resources [1]. This patch introduces a driver implementing the AON firmware protocol, allowing the Linux kernel to communicate with the firmware via mailbox channels. Through an RPC-based interface, the kernel can initiate power state transitions, update resource configurations, and perform other AON-related tasks. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1] Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- MAINTAINERS | 2 + drivers/firmware/Kconfig | 9 + drivers/firmware/Makefile | 1 + drivers/firmware/thead,th1520-aon.c | 247 ++++++++++++++++++ .../linux/firmware/thead/thead,th1520-aon.h | 200 ++++++++++++++ 5 files changed, 459 insertions(+) create mode 100644 drivers/firmware/thead,th1520-aon.c create mode 100644 include/linux/firmware/thead/thead,th1520-aon.h diff --git a/MAINTAINERS b/MAINTAINERS index 0934f9791fe9..3ee5a2f6cdee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20419,10 +20419,12 @@ F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml F: arch/riscv/boot/dts/thead/ F: drivers/clk/thead/clk-th1520-ap.c +F: drivers/firmware/thead,th1520-aon.c F: drivers/mailbox/mailbox-th1520.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c F: drivers/pinctrl/pinctrl-th1520.c F: include/dt-bindings/clock/thead,th1520-clk-ap.h +F: include/linux/firmware/thead/thead,th1520-aon.h RNBD BLOCK DRIVERS M: Md. Haris Iqbal <haris.iqbal@ionos.com> diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 9f35f69e0f9e..52c145097770 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -212,6 +212,15 @@ config SYSFB_SIMPLEFB If unsure, say Y. +config TH1520_AON_PROTOCOL + tristate "Always-On firmware protocol" + depends on ARCH_THEAD || COMPILE_TEST + help + Power, clock, and resource management capabilities on the TH1520 SoC are + managed by the E902 core. Firmware running on this core communicates with + the kernel through the Always-On protocol, using hardware mailbox as a medium. + Say yes if you need such capabilities. + config TI_SCI_PROTOCOL tristate "TI System Control Interface (TISCI) Message Protocol" depends on TI_MESSAGE_MANAGER diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 7a8d486e718f..5db9c042430c 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o obj-$(CONFIG_SYSFB) += sysfb.o obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o +obj-$(CONFIG_TH1520_AON_PROTOCOL) += thead,th1520-aon.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/thead,th1520-aon.c b/drivers/firmware/thead,th1520-aon.c new file mode 100644 index 000000000000..48e1bd986768 --- /dev/null +++ b/drivers/firmware/thead,th1520-aon.c @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Alibaba Group Holding Limited. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Author: Michal Wilczynski <m.wilczynski@samsung.com> + */ + +#include <linux/device.h> +#include <linux/firmware/thead/thead,th1520-aon.h> +#include <linux/mailbox_client.h> +#include <linux/mailbox_controller.h> + +#define MAX_RX_TIMEOUT (msecs_to_jiffies(3000)) +#define MAX_TX_TIMEOUT 500 + +struct th1520_aon_chan { + struct mbox_chan *ch; + struct th1520_aon_rpc_ack_common ack_msg; + struct mbox_client cl; + struct completion done; + + /* make sure only one RPC is performed at a time */ + struct mutex transaction_lock; +}; + +struct th1520_aon_msg_req_set_resource_power_mode { + struct th1520_aon_rpc_msg_hdr hdr; + u16 resource; + u16 mode; + u16 reserved[10]; +} __packed __aligned(1); + +/* + * This type is used to indicate error response for most functions. + */ +enum th1520_aon_error_codes { + LIGHT_AON_ERR_NONE = 0, /* Success */ + LIGHT_AON_ERR_VERSION = 1, /* Incompatible API version */ + LIGHT_AON_ERR_CONFIG = 2, /* Configuration error */ + LIGHT_AON_ERR_PARM = 3, /* Bad parameter */ + LIGHT_AON_ERR_NOACCESS = 4, /* Permission error (no access) */ + LIGHT_AON_ERR_LOCKED = 5, /* Permission error (locked) */ + LIGHT_AON_ERR_UNAVAILABLE = 6, /* Unavailable (out of resources) */ + LIGHT_AON_ERR_NOTFOUND = 7, /* Not found */ + LIGHT_AON_ERR_NOPOWER = 8, /* No power */ + LIGHT_AON_ERR_IPC = 9, /* Generic IPC error */ + LIGHT_AON_ERR_BUSY = 10, /* Resource is currently busy/active */ + LIGHT_AON_ERR_FAIL = 11, /* General I/O failure */ + LIGHT_AON_ERR_LAST +}; + +static int th1520_aon_linux_errmap[LIGHT_AON_ERR_LAST] = { + 0, /* LIGHT_AON_ERR_NONE */ + -EINVAL, /* LIGHT_AON_ERR_VERSION */ + -EINVAL, /* LIGHT_AON_ERR_CONFIG */ + -EINVAL, /* LIGHT_AON_ERR_PARM */ + -EACCES, /* LIGHT_AON_ERR_NOACCESS */ + -EACCES, /* LIGHT_AON_ERR_LOCKED */ + -ERANGE, /* LIGHT_AON_ERR_UNAVAILABLE */ + -EEXIST, /* LIGHT_AON_ERR_NOTFOUND */ + -EPERM, /* LIGHT_AON_ERR_NOPOWER */ + -EPIPE, /* LIGHT_AON_ERR_IPC */ + -EBUSY, /* LIGHT_AON_ERR_BUSY */ + -EIO, /* LIGHT_AON_ERR_FAIL */ +}; + +static inline int th1520_aon_to_linux_errno(int errno) +{ + if (errno >= LIGHT_AON_ERR_NONE && errno < LIGHT_AON_ERR_LAST) + return th1520_aon_linux_errmap[errno]; + + return -EIO; +} + +static void th1520_aon_rx_callback(struct mbox_client *c, void *rx_msg) +{ + struct th1520_aon_chan *aon_chan = + container_of(c, struct th1520_aon_chan, cl); + struct th1520_aon_rpc_msg_hdr *hdr = + (struct th1520_aon_rpc_msg_hdr *)rx_msg; + u8 recv_size = sizeof(struct th1520_aon_rpc_msg_hdr) + hdr->size; + + if (recv_size != sizeof(struct th1520_aon_rpc_ack_common)) { + dev_err(c->dev, "Invalid ack size, not completing\n"); + return; + } + + memcpy(&aon_chan->ack_msg, rx_msg, recv_size); + complete(&aon_chan->done); +} + +/** + * th1520_aon_call_rpc() - Send an RPC request to the TH1520 AON subsystem + * @aon_chan: Pointer to the AON channel structure + * @msg: Pointer to the message (RPC payload) that will be sent + * + * This function sends an RPC message to the TH1520 AON subsystem via mailbox. + * It takes the provided @msg buffer, formats it with version and service flags, + * then blocks until the RPC completes or times out. The completion is signaled + * by the `aon_chan->done` completion, which is waited upon for a duration + * defined by `MAX_RX_TIMEOUT`. + * + * Return: + * * 0 on success + * * -ETIMEDOUT if the RPC call times out + * * A negative error code if the mailbox send fails or if AON responds with + * a non-zero error code (converted via th1520_aon_to_linux_errno()). + */ +int th1520_aon_call_rpc(struct th1520_aon_chan *aon_chan, void *msg) +{ + struct th1520_aon_rpc_msg_hdr *hdr = msg; + int ret; + + mutex_lock(&aon_chan->transaction_lock); + reinit_completion(&aon_chan->done); + + RPC_SET_VER(hdr, TH1520_AON_RPC_VERSION); + RPC_SET_SVC_ID(hdr, hdr->svc); + RPC_SET_SVC_FLAG_MSG_TYPE(hdr, RPC_SVC_MSG_TYPE_DATA); + RPC_SET_SVC_FLAG_ACK_TYPE(hdr, RPC_SVC_MSG_NEED_ACK); + + ret = mbox_send_message(aon_chan->ch, msg); + if (ret < 0) { + dev_err(aon_chan->cl.dev, "RPC send msg failed: %d\n", ret); + goto out; + } + + if (!wait_for_completion_timeout(&aon_chan->done, MAX_RX_TIMEOUT)) { + dev_err(aon_chan->cl.dev, "RPC send msg timeout\n"); + mutex_unlock(&aon_chan->transaction_lock); + return -ETIMEDOUT; + } + + ret = aon_chan->ack_msg.err_code; + +out: + mutex_unlock(&aon_chan->transaction_lock); + + return th1520_aon_to_linux_errno(ret); +} +EXPORT_SYMBOL_GPL(th1520_aon_call_rpc); + +/** + * th1520_aon_power_update() - Change power state of a resource via TH1520 AON + * @aon_chan: Pointer to the AON channel structure + * @rsrc: Resource ID whose power state needs to be updated + * @power_on: Boolean indicating whether the resource should be powered on (true) + * or powered off (false) + * + * This function requests the TH1520 AON subsystem to set the power mode of the + * given resource (@rsrc) to either on or off. It constructs the message in + * `struct th1520_aon_msg_req_set_resource_power_mode` and then invokes + * th1520_aon_call_rpc() to make the request. If the AON call fails, an error + * message is logged along with the specific return code. + * + * Return: + * * 0 on success + * * A negative error code in case of failures (propagated from + * th1520_aon_call_rpc()). + */ +int th1520_aon_power_update(struct th1520_aon_chan *aon_chan, u16 rsrc, + bool power_on) +{ + struct th1520_aon_msg_req_set_resource_power_mode msg = {}; + struct th1520_aon_rpc_msg_hdr *hdr = &msg.hdr; + int ret; + + hdr->svc = TH1520_AON_RPC_SVC_PM; + hdr->func = TH1520_AON_PM_FUNC_SET_RESOURCE_POWER_MODE; + hdr->size = TH1520_AON_RPC_MSG_NUM; + + RPC_SET_BE16(&msg.resource, 0, rsrc); + RPC_SET_BE16(&msg.resource, 2, + (power_on ? TH1520_AON_PM_PW_MODE_ON : + TH1520_AON_PM_PW_MODE_OFF)); + + ret = th1520_aon_call_rpc(aon_chan, &msg); + if (ret) + dev_err(aon_chan->cl.dev, "failed to power %s resource %d ret %d\n", + power_on ? "up" : "off", rsrc, ret); + + return ret; +} +EXPORT_SYMBOL_GPL(th1520_aon_power_update); + +/** + * th1520_aon_init() - Initialize TH1520 AON firmware protocol interface + * @dev: Device pointer for the AON subsystem + * + * This function initializes the TH1520 AON firmware protocol interface by: + * - Allocating and initializing the AON channel structure + * - Setting up the mailbox client + * - Requesting the AON mailbox channel + * - Initializing synchronization primitives + * + * Return: + * * Valid pointer to th1520_aon_chan structure on success + * * ERR_PTR(-ENOMEM) if memory allocation fails + * * ERR_PTR() with other negative error codes from mailbox operations + */ +struct th1520_aon_chan *th1520_aon_init(struct device *dev) +{ + struct th1520_aon_chan *aon_chan; + struct mbox_client *cl; + + aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL); + if (!aon_chan) + return ERR_PTR(-ENOMEM); + + cl = &aon_chan->cl; + cl->dev = dev; + cl->tx_block = true; + cl->tx_tout = MAX_TX_TIMEOUT; + cl->rx_callback = th1520_aon_rx_callback; + + aon_chan->ch = mbox_request_channel_byname(cl, "aon"); + if (IS_ERR(aon_chan->ch)) { + dev_err(dev, "Failed to request aon mbox chan\n"); + kfree(aon_chan); + return ERR_CAST(aon_chan->ch); + } + + mutex_init(&aon_chan->transaction_lock); + init_completion(&aon_chan->done); + + return aon_chan; +} +EXPORT_SYMBOL_GPL(th1520_aon_init); + +/** + * th1520_aon_deinit() - Clean up TH1520 AON firmware protocol interface + * @aon_chan: Pointer to the AON channel structure to clean up + * + * This function cleans up resources allocated by th1520_aon_init(): + * - Frees the mailbox channel + * - Frees the AON channel + */ +void th1520_aon_deinit(struct th1520_aon_chan *aon_chan) +{ + mbox_free_channel(aon_chan->ch); + kfree(aon_chan); +} +EXPORT_SYMBOL_GPL(th1520_aon_deinit); + +MODULE_AUTHOR("Michal Wilczynski <m.wilczynski@samsung.com>"); +MODULE_DESCRIPTION("T-HEAD TH1520 Always-On firmware protocol library"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/thead/thead,th1520-aon.h b/include/linux/firmware/thead/thead,th1520-aon.h new file mode 100644 index 000000000000..dae132b66873 --- /dev/null +++ b/include/linux/firmware/thead/thead,th1520-aon.h @@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2021 Alibaba Group Holding Limited. + */ + +#ifndef _THEAD_AON_H +#define _THEAD_AON_H + +#include <linux/device.h> +#include <linux/types.h> + +#define AON_RPC_MSG_MAGIC (0xef) +#define TH1520_AON_RPC_VERSION 2 +#define TH1520_AON_RPC_MSG_NUM 7 + +struct th1520_aon_chan; + +enum th1520_aon_rpc_svc { + TH1520_AON_RPC_SVC_UNKNOWN = 0, + TH1520_AON_RPC_SVC_PM = 1, + TH1520_AON_RPC_SVC_MISC = 2, + TH1520_AON_RPC_SVC_AVFS = 3, + TH1520_AON_RPC_SVC_SYS = 4, + TH1520_AON_RPC_SVC_WDG = 5, + TH1520_AON_RPC_SVC_LPM = 6, + TH1520_AON_RPC_SVC_MAX = 0x3F, +}; + +enum th1520_aon_misc_func { + TH1520_AON_MISC_FUNC_UNKNOWN = 0, + TH1520_AON_MISC_FUNC_SET_CONTROL = 1, + TH1520_AON_MISC_FUNC_GET_CONTROL = 2, + TH1520_AON_MISC_FUNC_REGDUMP_CFG = 3, +}; + +enum th1520_aon_wdg_func { + TH1520_AON_WDG_FUNC_UNKNOWN = 0, + TH1520_AON_WDG_FUNC_START = 1, + TH1520_AON_WDG_FUNC_STOP = 2, + TH1520_AON_WDG_FUNC_PING = 3, + TH1520_AON_WDG_FUNC_TIMEOUTSET = 4, + TH1520_AON_WDG_FUNC_RESTART = 5, + TH1520_AON_WDG_FUNC_GET_STATE = 6, + TH1520_AON_WDG_FUNC_POWER_OFF = 7, + TH1520_AON_WDG_FUNC_AON_WDT_ON = 8, + TH1520_AON_WDG_FUNC_AON_WDT_OFF = 9, +}; + +enum th1520_aon_sys_func { + TH1520_AON_SYS_FUNC_UNKNOWN = 0, + TH1520_AON_SYS_FUNC_AON_RESERVE_MEM = 1, +}; + +enum th1520_aon_lpm_func { + TH1520_AON_LPM_FUNC_UNKNOWN = 0, + TH1520_AON_LPM_FUNC_REQUIRE_STR = 1, + TH1520_AON_LPM_FUNC_RESUME_STR = 2, + TH1520_AON_LPM_FUNC_REQUIRE_STD = 3, + TH1520_AON_LPM_FUNC_CPUHP = 4, + TH1520_AON_LPM_FUNC_REGDUMP_CFG = 5, +}; + +enum th1520_aon_pm_func { + TH1520_AON_PM_FUNC_UNKNOWN = 0, + TH1520_AON_PM_FUNC_SET_RESOURCE_REGULATOR = 1, + TH1520_AON_PM_FUNC_GET_RESOURCE_REGULATOR = 2, + TH1520_AON_PM_FUNC_SET_RESOURCE_POWER_MODE = 3, + TH1520_AON_PM_FUNC_PWR_SET = 4, + TH1520_AON_PM_FUNC_PWR_GET = 5, + TH1520_AON_PM_FUNC_CHECK_FAULT = 6, + TH1520_AON_PM_FUNC_GET_TEMPERATURE = 7, +}; + +struct th1520_aon_rpc_msg_hdr { + u8 ver; /* version of msg hdr */ + u8 size; /* msg size ,uinit in bytes,the size includes rpc msg header self */ + u8 svc; /* rpc main service id */ + u8 func; /* rpc sub func id of specific service, sent by caller */ +} __packed __aligned(1); + +struct th1520_aon_rpc_ack_common { + struct th1520_aon_rpc_msg_hdr hdr; + u8 err_code; +} __packed __aligned(1); + +#define RPC_SVC_MSG_TYPE_DATA 0 +#define RPC_SVC_MSG_TYPE_ACK 1 +#define RPC_SVC_MSG_NEED_ACK 0 +#define RPC_SVC_MSG_NO_NEED_ACK 1 + +#define RPC_GET_VER(MESG) ((MESG)->ver) +#define RPC_SET_VER(MESG, VER) ((MESG)->ver = (VER)) +#define RPC_GET_SVC_ID(MESG) ((MESG)->svc & 0x3F) +#define RPC_SET_SVC_ID(MESG, ID) ((MESG)->svc |= 0x3F & (ID)) +#define RPC_GET_SVC_FLAG_MSG_TYPE(MESG) (((MESG)->svc & 0x80) >> 7) +#define RPC_SET_SVC_FLAG_MSG_TYPE(MESG, TYPE) ((MESG)->svc |= (TYPE) << 7) +#define RPC_GET_SVC_FLAG_ACK_TYPE(MESG) (((MESG)->svc & 0x40) >> 6) +#define RPC_SET_SVC_FLAG_ACK_TYPE(MESG, ACK) ((MESG)->svc |= (ACK) << 6) + +#define RPC_SET_BE64(MESG, OFFSET, SET_DATA) \ + do { \ + u8 *data = (u8 *)(MESG); \ + u64 _offset = (OFFSET); \ + u64 _set_data = (SET_DATA); \ + data[_offset + 7] = _set_data & 0xFF; \ + data[_offset + 6] = (_set_data & 0xFF00) >> 8; \ + data[_offset + 5] = (_set_data & 0xFF0000) >> 16; \ + data[_offset + 4] = (_set_data & 0xFF000000) >> 24; \ + data[_offset + 3] = (_set_data & 0xFF00000000) >> 32; \ + data[_offset + 2] = (_set_data & 0xFF0000000000) >> 40; \ + data[_offset + 1] = (_set_data & 0xFF000000000000) >> 48; \ + data[_offset + 0] = (_set_data & 0xFF00000000000000) >> 56; \ + } while (0) + +#define RPC_SET_BE32(MESG, OFFSET, SET_DATA) \ + do { \ + u8 *data = (u8 *)(MESG); \ + u64 _offset = (OFFSET); \ + u64 _set_data = (SET_DATA); \ + data[_offset + 3] = (_set_data) & 0xFF; \ + data[_offset + 2] = (_set_data & 0xFF00) >> 8; \ + data[_offset + 1] = (_set_data & 0xFF0000) >> 16; \ + data[_offset + 0] = (_set_data & 0xFF000000) >> 24; \ + } while (0) + +#define RPC_SET_BE16(MESG, OFFSET, SET_DATA) \ + do { \ + u8 *data = (u8 *)(MESG); \ + u64 _offset = (OFFSET); \ + u64 _set_data = (SET_DATA); \ + data[_offset + 1] = (_set_data) & 0xFF; \ + data[_offset + 0] = (_set_data & 0xFF00) >> 8; \ + } while (0) + +#define RPC_SET_U8(MESG, OFFSET, SET_DATA) \ + do { \ + u8 *data = (u8 *)(MESG); \ + data[OFFSET] = (SET_DATA) & 0xFF; \ + } while (0) + +#define RPC_GET_BE64(MESG, OFFSET, PTR) \ + do { \ + u8 *data = (u8 *)(MESG); \ + u64 _offset = (OFFSET); \ + *(u32 *)(PTR) = \ + (data[_offset + 7] | data[_offset + 6] << 8 | \ + data[_offset + 5] << 16 | data[_offset + 4] << 24 | \ + data[_offset + 3] << 32 | data[_offset + 2] << 40 | \ + data[_offset + 1] << 48 | data[_offset + 0] << 56); \ + } while (0) + +#define RPC_GET_BE32(MESG, OFFSET, PTR) \ + do { \ + u8 *data = (u8 *)(MESG); \ + u64 _offset = (OFFSET); \ + *(u32 *)(PTR) = \ + (data[_offset + 3] | data[_offset + 2] << 8 | \ + data[_offset + 1] << 16 | data[_offset + 0] << 24); \ + } while (0) + +#define RPC_GET_BE16(MESG, OFFSET, PTR) \ + do { \ + u8 *data = (u8 *)(MESG); \ + u64 _offset = (OFFSET); \ + *(u16 *)(PTR) = (data[_offset + 1] | data[_offset + 0] << 8); \ + } while (0) + +#define RPC_GET_U8(MESG, OFFSET, PTR) \ + do { \ + u8 *data = (u8 *)(MESG); \ + *(u8 *)(PTR) = (data[OFFSET]); \ + } while (0) + +/* + * Defines for SC PM Power Mode + */ +#define TH1520_AON_PM_PW_MODE_OFF 0 /* Power off */ +#define TH1520_AON_PM_PW_MODE_STBY 1 /* Power in standby */ +#define TH1520_AON_PM_PW_MODE_LP 2 /* Power in low-power */ +#define TH1520_AON_PM_PW_MODE_ON 3 /* Power on */ + +/* + * Defines for AON power islands + */ +#define TH1520_AON_AUDIO_PD 0 +#define TH1520_AON_VDEC_PD 1 +#define TH1520_AON_NPU_PD 2 +#define TH1520_AON_VENC_PD 3 +#define TH1520_AON_GPU_PD 4 +#define TH1520_AON_DSP0_PD 5 +#define TH1520_AON_DSP1_PD 6 + +struct th1520_aon_chan *th1520_aon_init(struct device *dev); +void th1520_aon_deinit(struct th1520_aon_chan *aon_chan); + +int th1520_aon_call_rpc(struct th1520_aon_chan *aon_chan, void *msg); +int th1520_aon_power_update(struct th1520_aon_chan *aon_chan, u16 rsrc, + bool power_on); + +#endif /* _THEAD_AON_H */ -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140256eucas1p13aa7f19867f88185739552f116ef0fc1@eucas1p1.samsung.com>]
* [PATCH v5 05/21] dt-bindings: power: Add TH1520 SoC power domains [not found] ` <CGME20250219140256eucas1p13aa7f19867f88185739552f116ef0fc1@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski, Krzysztof Kozlowski Add power domain ID's for the TH1520 SoC power domains. Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- MAINTAINERS | 1 + .../dt-bindings/power/thead,th1520-power.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 include/dt-bindings/power/thead,th1520-power.h diff --git a/MAINTAINERS b/MAINTAINERS index 3ee5a2f6cdee..781129d60349 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20424,6 +20424,7 @@ F: drivers/mailbox/mailbox-th1520.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c F: drivers/pinctrl/pinctrl-th1520.c F: include/dt-bindings/clock/thead,th1520-clk-ap.h +F: include/dt-bindings/power/thead,th1520-power.h F: include/linux/firmware/thead/thead,th1520-aon.h RNBD BLOCK DRIVERS diff --git a/include/dt-bindings/power/thead,th1520-power.h b/include/dt-bindings/power/thead,th1520-power.h new file mode 100644 index 000000000000..8395bd1459f3 --- /dev/null +++ b/include/dt-bindings/power/thead,th1520-power.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (C) 2022 Alibaba Group Holding Limited. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Author: Michal Wilczynski <m.wilczynski@samsung.com> + */ + +#ifndef __DT_BINDINGS_POWER_TH1520_H +#define __DT_BINDINGS_POWER_TH1520_H + +#define TH1520_AUDIO_PD 0 +#define TH1520_VDEC_PD 1 +#define TH1520_NPU_PD 2 +#define TH1520_VENC_PD 3 +#define TH1520_GPU_PD 4 +#define TH1520_DSP0_PD 5 +#define TH1520_DSP1_PD 6 + +#endif -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140257eucas1p1cc06395993336a6244f6ae0ce2923d71@eucas1p1.samsung.com>]
* [PATCH v5 06/21] pmdomain: thead: Add power-domain driver for TH1520 [not found] ` <CGME20250219140257eucas1p1cc06395993336a6244f6ae0ce2923d71@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The T-Head TH1520 SoC contains multiple power islands that can be programmatically turned on and off using the AON (Always-On) protocol and a hardware mailbox [1]. The relevant mailbox driver has already been merged into the mainline kernel in commit 5d4d263e1c6b ("mailbox: Introduce support for T-head TH1520 Mailbox driver"); Introduce a power-domain driver for the TH1520 SoC, which is using AON firmware protocol to communicate with E902 core through the hardware mailbox. This way it can send power on/off commands to the E902 core. The interaction with AUDIO power island e.g trying to turn it OFF proved to crash the firmware running on the E902 core. Introduce the workaround to disable interacting with the power island. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1] Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- MAINTAINERS | 1 + drivers/pmdomain/Kconfig | 1 + drivers/pmdomain/Makefile | 1 + drivers/pmdomain/thead/Kconfig | 12 ++ drivers/pmdomain/thead/Makefile | 2 + drivers/pmdomain/thead/th1520-pm-domains.c | 209 +++++++++++++++++++++ 6 files changed, 226 insertions(+) create mode 100644 drivers/pmdomain/thead/Kconfig create mode 100644 drivers/pmdomain/thead/Makefile create mode 100644 drivers/pmdomain/thead/th1520-pm-domains.c diff --git a/MAINTAINERS b/MAINTAINERS index 781129d60349..18f0eb293519 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20423,6 +20423,7 @@ F: drivers/firmware/thead,th1520-aon.c F: drivers/mailbox/mailbox-th1520.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c F: drivers/pinctrl/pinctrl-th1520.c +F: drivers/pmdomain/thead/ F: include/dt-bindings/clock/thead,th1520-clk-ap.h F: include/dt-bindings/power/thead,th1520-power.h F: include/linux/firmware/thead/thead,th1520-aon.h diff --git a/drivers/pmdomain/Kconfig b/drivers/pmdomain/Kconfig index 23c64851a5b0..91f04ace35d4 100644 --- a/drivers/pmdomain/Kconfig +++ b/drivers/pmdomain/Kconfig @@ -16,6 +16,7 @@ source "drivers/pmdomain/st/Kconfig" source "drivers/pmdomain/starfive/Kconfig" source "drivers/pmdomain/sunxi/Kconfig" source "drivers/pmdomain/tegra/Kconfig" +source "drivers/pmdomain/thead/Kconfig" source "drivers/pmdomain/ti/Kconfig" source "drivers/pmdomain/xilinx/Kconfig" diff --git a/drivers/pmdomain/Makefile b/drivers/pmdomain/Makefile index a68ece2f4c68..7030f44a49df 100644 --- a/drivers/pmdomain/Makefile +++ b/drivers/pmdomain/Makefile @@ -14,6 +14,7 @@ obj-y += st/ obj-y += starfive/ obj-y += sunxi/ obj-y += tegra/ +obj-y += thead/ obj-y += ti/ obj-y += xilinx/ obj-y += core.o governor.o diff --git a/drivers/pmdomain/thead/Kconfig b/drivers/pmdomain/thead/Kconfig new file mode 100644 index 000000000000..c7a1ac0c61dc --- /dev/null +++ b/drivers/pmdomain/thead/Kconfig @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config TH1520_PM_DOMAINS + tristate "Support TH1520 Power Domains" + depends on TH1520_AON_PROTOCOL || !TH1520_AON_PROTOCOL + select REGMAP_MMIO + help + This driver enables power domain management for the T-HEAD + TH-1520 SoC. On this SoC there are number of power domains, + which can be managed independently. For example GPU, NPU, + and DPU reside in their own power domains which can be + turned on/off. diff --git a/drivers/pmdomain/thead/Makefile b/drivers/pmdomain/thead/Makefile new file mode 100644 index 000000000000..adfdf5479c68 --- /dev/null +++ b/drivers/pmdomain/thead/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_TH1520_PM_DOMAINS) += th1520-pm-domains.o diff --git a/drivers/pmdomain/thead/th1520-pm-domains.c b/drivers/pmdomain/thead/th1520-pm-domains.c new file mode 100644 index 000000000000..7c78cf3955d2 --- /dev/null +++ b/drivers/pmdomain/thead/th1520-pm-domains.c @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Alibaba Group Holding Limited. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Author: Michal Wilczynski <m.wilczynski@samsung.com> + */ + +#include <linux/firmware/thead/thead,th1520-aon.h> +#include <linux/slab.h> +#include <linux/platform_device.h> +#include <linux/pm_domain.h> + +#include <dt-bindings/power/thead,th1520-power.h> + +struct th1520_power_domain { + struct th1520_aon_chan *aon_chan; + struct generic_pm_domain genpd; + u32 rsrc; +}; + +struct th1520_power_info { + const char *name; + u32 rsrc; + bool disabled; +}; + +/* + * The AUDIO power domain is marked as disabled to prevent the driver from + * managing its power state. Direct AON firmware calls to control this power + * island trigger a firmware bug causing system instability. Until this + * firmware issue is resolved, the AUDIO power domain must remain disabled + * to avoid crashes. + */ +static const struct th1520_power_info th1520_pd_ranges[] = { + [TH1520_AUDIO_PD] = {"audio", TH1520_AON_AUDIO_PD, true }, + [TH1520_VDEC_PD] = { "vdec", TH1520_AON_VDEC_PD, false }, + [TH1520_NPU_PD] = { "npu", TH1520_AON_NPU_PD, false }, + [TH1520_VENC_PD] = { "venc", TH1520_AON_VENC_PD, false }, + [TH1520_GPU_PD] = { "gpu", TH1520_AON_GPU_PD, false }, + [TH1520_DSP0_PD] = { "dsp0", TH1520_AON_DSP0_PD, false }, + [TH1520_DSP1_PD] = { "dsp1", TH1520_AON_DSP1_PD, false } +}; + +static inline struct th1520_power_domain * +to_th1520_power_domain(struct generic_pm_domain *genpd) +{ + return container_of(genpd, struct th1520_power_domain, genpd); +} + +static int th1520_pd_power_on(struct generic_pm_domain *domain) +{ + struct th1520_power_domain *pd = to_th1520_power_domain(domain); + + return th1520_aon_power_update(pd->aon_chan, pd->rsrc, true); +} + +static int th1520_pd_power_off(struct generic_pm_domain *domain) +{ + struct th1520_power_domain *pd = to_th1520_power_domain(domain); + + return th1520_aon_power_update(pd->aon_chan, pd->rsrc, false); +} + +static struct generic_pm_domain *th1520_pd_xlate(const struct of_phandle_args *spec, + void *data) +{ + struct generic_pm_domain *domain = ERR_PTR(-ENOENT); + struct genpd_onecell_data *pd_data = data; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(th1520_pd_ranges); i++) { + struct th1520_power_domain *pd; + + if (th1520_pd_ranges[i].disabled) + continue; + + pd = to_th1520_power_domain(pd_data->domains[i]); + if (pd->rsrc == spec->args[0]) { + domain = &pd->genpd; + break; + } + } + + return domain; +} + +static struct th1520_power_domain * +th1520_add_pm_domain(struct device *dev, const struct th1520_power_info *pi) +{ + struct th1520_power_domain *pd; + int ret; + + pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); + if (!pd) + return ERR_PTR(-ENOMEM); + + pd->rsrc = pi->rsrc; + pd->genpd.power_on = th1520_pd_power_on; + pd->genpd.power_off = th1520_pd_power_off; + pd->genpd.name = pi->name; + + ret = pm_genpd_init(&pd->genpd, NULL, true); + if (ret) + return ERR_PTR(ret); + + return pd; +} + +static void th1520_pd_init_all_off(struct generic_pm_domain **domains, + struct device *dev) +{ + int ret; + int i; + + for (i = 0; i < ARRAY_SIZE(th1520_pd_ranges); i++) { + struct th1520_power_domain *pd; + + if (th1520_pd_ranges[i].disabled) + continue; + + pd = to_th1520_power_domain(domains[i]); + + ret = th1520_aon_power_update(pd->aon_chan, pd->rsrc, false); + if (ret) + dev_err(dev, + "Failed to initially power down power domain %s\n", + pd->genpd.name); + } +} + +static int th1520_pd_probe(struct platform_device *pdev) +{ + struct generic_pm_domain **domains; + struct genpd_onecell_data *pd_data; + struct th1520_aon_chan *aon_chan; + struct device *dev = &pdev->dev; + int i; + + aon_chan = th1520_aon_init(dev); + if (IS_ERR(aon_chan)) + return dev_err_probe(dev, PTR_ERR(aon_chan), + "Failed to get AON channel\n"); + + platform_set_drvdata(pdev, aon_chan); + + domains = devm_kcalloc(dev, ARRAY_SIZE(th1520_pd_ranges), + sizeof(*domains), GFP_KERNEL); + if (!domains) + return -ENOMEM; + + pd_data = devm_kzalloc(dev, sizeof(*pd_data), GFP_KERNEL); + if (!pd_data) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(th1520_pd_ranges); i++) { + struct th1520_power_domain *pd; + + if (th1520_pd_ranges[i].disabled) + continue; + + pd = th1520_add_pm_domain(dev, &th1520_pd_ranges[i]); + if (IS_ERR(pd)) + return PTR_ERR(pd); + + pd->aon_chan = aon_chan; + domains[i] = &pd->genpd; + dev_dbg(dev, "added power domain %s\n", pd->genpd.name); + } + + pd_data->domains = domains; + pd_data->num_domains = ARRAY_SIZE(th1520_pd_ranges); + pd_data->xlate = th1520_pd_xlate; + + /* + * Initialize all power domains to off to ensure they start in a + * low-power state. This allows device drivers to manage power + * domains by turning them on or off as needed. + */ + th1520_pd_init_all_off(domains, dev); + + return of_genpd_add_provider_onecell(dev->of_node, pd_data); +} + +static void th1520_pd_remove(struct platform_device *pdev) +{ + struct th1520_aon_chan *aon_chan = platform_get_drvdata(pdev); + + th1520_aon_deinit(aon_chan); +} + +static const struct of_device_id th1520_pd_match[] = { + { .compatible = "thead,th1520-aon" }, + { /* Sentinel */ } +}; +MODULE_DEVICE_TABLE(of, th1520_pd_match); + +static struct platform_driver th1520_pd_driver = { + .driver = { + .name = "th1520-pd", + .of_match_table = th1520_pd_match, + }, + .probe = th1520_pd_probe, + .remove = th1520_pd_remove, +}; +module_platform_driver(th1520_pd_driver); + +MODULE_AUTHOR("Michal Wilczynski <m.wilczynski@samsung.com>"); +MODULE_DESCRIPTION("T-HEAD TH1520 SoC power domain controller"); +MODULE_LICENSE("GPL"); -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140259eucas1p114dbcacffe3b479d15cd800c7efbede2@eucas1p1.samsung.com>]
* [PATCH v5 07/21] riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs [not found] ` <CGME20250219140259eucas1p114dbcacffe3b479d15cd800c7efbede2@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski T-Head SoCs feature separate power domains (power islands) for major components like the GPU, Audio, and NPU. To manage the power states of these components effectively, the kernel requires generic power domain support. This commit enables `CONFIG_PM_GENERIC_DOMAINS` for T-Head SoCs, allowing the power domain driver for these components to be compiled and integrated. This ensures proper power management and energy efficiency on T-Head platforms. By selecting `PM_GENERIC_DOMAINS`, we provide the necessary framework for the power domain drivers to function correctly on RISC-V architecture with T-Head SoCs. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- arch/riscv/Kconfig.socs | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs index 1916cf7ba450..83833ded8908 100644 --- a/arch/riscv/Kconfig.socs +++ b/arch/riscv/Kconfig.socs @@ -53,6 +53,7 @@ config ARCH_THEAD bool "T-HEAD RISC-V SoCs" depends on MMU && !XIP_KERNEL select ERRATA_THEAD + select PM_GENERIC_DOMAINS if PM help This enables support for the RISC-V based T-HEAD SoCs. -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140300eucas1p2d776e747555020fd868cf04e55cd70e1@eucas1p2.samsung.com>]
* [PATCH v5 08/21] clk: thead: Add support for custom ops in CCU_GATE_CLK_OPS macro [not found] ` <CGME20250219140300eucas1p2d776e747555020fd868cf04e55cd70e1@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The IMG Rogue GPU requires three clocks: core, sys, and mem [1]. On the T-HEAD TH1520 SoC, the mem clock gate is marked as "Reserved" in the hardware manual (section 4.4.2.6.1) [2] and cannot be configured. Add a new CCU_GATE_CLK_OPS macro that allows specifying custom clock operations. This enables us to use nop operations for the mem clock, preventing the driver from attempting to enable/disable this reserved clock gate. Link: https://lore.kernel.org/all/2fe3d93f-62ac-4439-ac17-d81137f6410a@imgtec.com [1] Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [2] Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- drivers/clk/thead/clk-th1520-ap.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c index 57972589f120..ea96d007aecd 100644 --- a/drivers/clk/thead/clk-th1520-ap.c +++ b/drivers/clk/thead/clk-th1520-ap.c @@ -89,6 +89,21 @@ struct ccu_pll { } \ } +#define CCU_GATE_CLK_OPS(_clkid, _struct, _name, _parent, _reg, _gate, _flags, \ + _clk_ops) \ + struct ccu_gate _struct = { \ + .enable = _gate, \ + .common = { \ + .clkid = _clkid, \ + .cfg0 = _reg, \ + .hw.init = CLK_HW_INIT_PARENTS_DATA( \ + _name, \ + _parent, \ + &_clk_ops, \ + _flags), \ + } \ + } + static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) { return container_of(hw, struct ccu_common, hw); @@ -847,6 +862,11 @@ static CCU_GATE(CLK_SRAM1, sram1_clk, "sram1", axi_aclk_pd, 0x20c, BIT(3), 0); static CCU_GATE(CLK_SRAM2, sram2_clk, "sram2", axi_aclk_pd, 0x20c, BIT(2), 0); static CCU_GATE(CLK_SRAM3, sram3_clk, "sram3", axi_aclk_pd, 0x20c, BIT(1), 0); +static const struct clk_ops clk_nop_ops = {}; + +static CCU_GATE_CLK_OPS(CLK_GPU_MEM, gpu_mem_clk, "gpu-mem-clk", + video_pll_clk_pd, 0x0, BIT(2), 0, clk_nop_ops); + static CCU_GATE(CLK_AXI4_VO_ACLK, axi4_vo_aclk, "axi4-vo-aclk", video_pll_clk_pd, 0x0, BIT(0), 0); static CCU_GATE(CLK_GPU_CORE, gpu_core_clk, "gpu-core-clk", video_pll_clk_pd, @@ -1205,6 +1225,12 @@ static int th1520_clk_probe(struct platform_device *pdev) ret = devm_clk_hw_register(dev, &emmc_sdio_ref_clk.hw); if (ret) return ret; + } else if (plat_data == &th1520_vo_platdata) { + ret = devm_clk_hw_register(dev, &gpu_mem_clk.common.hw); + if (ret) + return ret; + gpu_mem_clk.common.map = map; + priv->hws[CLK_GPU_MEM] = &gpu_mem_clk.common.hw; } ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv); -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140301eucas1p249b17ca44832eb8caad2e9ad0e4f8639@eucas1p2.samsung.com>]
* [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property [not found] ` <CGME20250219140301eucas1p249b17ca44832eb8caad2e9ad0e4f8639@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 2025-02-21 9:11 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski Add a mandatory reset property for the TH1520 VO clock controller that handles the GPU clocks. This reset line controls the GPU CLKGEN reset, which is required for proper GPU clock operation. The reset property is only required for the "thead,th1520-clk-vo" compatible, as it specifically handles the GPU-related clocks. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- .../bindings/clock/thead,th1520-clk-ap.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml index 9d058c00ab3d..6ea8202718d0 100644 --- a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml +++ b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml @@ -40,6 +40,12 @@ properties: (integer PLL) typically running at 792 MHz (FOUTPOSTDIV), with a maximum FOUTVCO of 2376 MHz. + resets: + maxItems: 1 + description: + Required for "thead,th1520-clk-vo". This reset line controls the + GPU CLKGEN reset which is required for proper GPU clock operation. + "#clock-cells": const: 1 description: @@ -51,6 +57,16 @@ required: - clocks - "#clock-cells" +allOf: + - if: + properties: + compatible: + contains: + const: thead,th1520-clk-vo + then: + required: + - resets + additionalProperties: false examples: -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property 2025-02-19 14:02 ` [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property Michal Wilczynski @ 2025-02-21 9:11 ` Krzysztof Kozlowski 2025-03-03 8:42 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-02-21 9:11 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Wed, Feb 19, 2025 at 03:02:27PM +0100, Michal Wilczynski wrote: > Add a mandatory reset property for the TH1520 VO clock controller that > handles the GPU clocks. This reset line controls the GPU CLKGEN reset, > which is required for proper GPU clock operation. > > The reset property is only required for the "thead,th1520-clk-vo" > compatible, as it specifically handles the GPU-related clocks. > > Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > --- > .../bindings/clock/thead,th1520-clk-ap.yaml | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml > index 9d058c00ab3d..6ea8202718d0 100644 > --- a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml > +++ b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml > @@ -40,6 +40,12 @@ properties: > (integer PLL) typically running at 792 MHz (FOUTPOSTDIV), with > a maximum FOUTVCO of 2376 MHz. > > + resets: > + maxItems: 1 > + description: > + Required for "thead,th1520-clk-vo". This reset line controls the You just added the compatible in other patch, so are you saying you added knowingly incomplete code? No, this must be squashed. > + GPU CLKGEN reset which is required for proper GPU clock operation. > + > "#clock-cells": > const: 1 > description: > @@ -51,6 +57,16 @@ required: > - clocks > - "#clock-cells" > > +allOf: > + - if: > + properties: > + compatible: > + contains: > + const: thead,th1520-clk-vo > + then: > + required: > + - resets else: ? What's there? Also reset or no? Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property 2025-02-21 9:11 ` Krzysztof Kozlowski @ 2025-03-03 8:42 ` Michal Wilczynski 2025-03-03 8:52 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-03-03 8:42 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 2/21/25 10:11, Krzysztof Kozlowski wrote: > On Wed, Feb 19, 2025 at 03:02:27PM +0100, Michal Wilczynski wrote: >> Add a mandatory reset property for the TH1520 VO clock controller that >> handles the GPU clocks. This reset line controls the GPU CLKGEN reset, >> which is required for proper GPU clock operation. >> >> The reset property is only required for the "thead,th1520-clk-vo" >> compatible, as it specifically handles the GPU-related clocks. >> >> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> >> --- >> .../bindings/clock/thead,th1520-clk-ap.yaml | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml >> index 9d058c00ab3d..6ea8202718d0 100644 >> --- a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml >> +++ b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml >> @@ -40,6 +40,12 @@ properties: >> (integer PLL) typically running at 792 MHz (FOUTPOSTDIV), with >> a maximum FOUTVCO of 2376 MHz. >> >> + resets: >> + maxItems: 1 >> + description: >> + Required for "thead,th1520-clk-vo". This reset line controls the > > You just added the compatible in other patch, so are you saying you > added knowingly incomplete code? > > No, this must be squashed. > >> + GPU CLKGEN reset which is required for proper GPU clock operation. >> + >> "#clock-cells": >> const: 1 >> description: >> @@ -51,6 +57,16 @@ required: >> - clocks >> - "#clock-cells" >> >> +allOf: >> + - if: >> + properties: >> + compatible: >> + contains: >> + const: thead,th1520-clk-vo >> + then: >> + required: >> + - resets > > else: > ? What's there? Also reset or no? If the else: case the reset is not required, as it's only required in the th1520clk-vo, so there is no need for else:. > > Best regards, > Krzysztof > > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property 2025-03-03 8:42 ` Michal Wilczynski @ 2025-03-03 8:52 ` Krzysztof Kozlowski 2025-03-03 9:55 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-03-03 8:52 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 03/03/2025 09:42, Michal Wilczynski wrote: >>> +allOf: >>> + - if: >>> + properties: >>> + compatible: >>> + contains: >>> + const: thead,th1520-clk-vo >>> + then: >>> + required: >>> + - resets >> >> else: >> ? What's there? Also reset or no? > > If the else: case the reset is not required, as it's only required in > the th1520clk-vo, so there is no need for else:. That's not the question. I know it is not required, I can read code. What is in the hardware? Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property 2025-03-03 8:52 ` Krzysztof Kozlowski @ 2025-03-03 9:55 ` Michal Wilczynski 2025-03-03 14:07 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-03-03 9:55 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 3/3/25 09:52, Krzysztof Kozlowski wrote: > On 03/03/2025 09:42, Michal Wilczynski wrote: >>>> +allOf: >>>> + - if: >>>> + properties: >>>> + compatible: >>>> + contains: >>>> + const: thead,th1520-clk-vo >>>> + then: >>>> + required: >>>> + - resets >>> >>> else: >>> ? What's there? Also reset or no? >> >> If the else: case the reset is not required, as it's only required in >> the th1520clk-vo, so there is no need for else:. > That's not the question. I know it is not required, I can read code. > What is in the hardware? I noticed the register SW_GMAC1_GRST_N in section 5.4.2.2.66 of the manual (GMAC1_SWRST [2]), which indicates a GMAC1 CLKGEN soft reset. Although this could theoretically reset part of the AP clock, it is not actually used by the AP clock driver or needed for initialization. > > Best regards, > Krzysztof > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property 2025-03-03 9:55 ` Michal Wilczynski @ 2025-03-03 14:07 ` Krzysztof Kozlowski 0 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-03-03 14:07 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 03/03/2025 10:55, Michal Wilczynski wrote: > > > On 3/3/25 09:52, Krzysztof Kozlowski wrote: >> On 03/03/2025 09:42, Michal Wilczynski wrote: >>>>> +allOf: >>>>> + - if: >>>>> + properties: >>>>> + compatible: >>>>> + contains: >>>>> + const: thead,th1520-clk-vo >>>>> + then: >>>>> + required: >>>>> + - resets >>>> >>>> else: >>>> ? What's there? Also reset or no? >>> >>> If the else: case the reset is not required, as it's only required in >>> the th1520clk-vo, so there is no need for else:. >> That's not the question. I know it is not required, I can read code. >> What is in the hardware? > > I noticed the register SW_GMAC1_GRST_N in section 5.4.2.2.66 of the > manual (GMAC1_SWRST [2]), which indicates a GMAC1 CLKGEN soft reset. > Although this could theoretically reset part of the AP clock, it is not > actually used by the AP clock driver or needed for initialization. Thanks, this answers here. Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140302eucas1p24d9900e424b31661217e3c9182105b3a@eucas1p2.samsung.com>]
* [PATCH v5 10/21] clk: thead: Add GPU clock gate control with CLKGEN reset support [not found] ` <CGME20250219140302eucas1p24d9900e424b31661217e3c9182105b3a@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The T-HEAD TH1520 has three GPU clocks: core, cfg, and mem. The mem clock gate is marked as "Reserved" in hardware, while core and cfg are configurable. In order for these clock gates to work properly, the CLKGEN reset must be managed in a specific sequence. Move the CLKGEN reset handling to the clock driver since it's fundamentally a clock-related workaround [1]. This ensures that clk_enabled GPU clocks stay physically enabled without external interference from the reset driver. The reset is now deasserted only when both core and cfg clocks are enabled, and asserted when either of them is disabled. The mem clock is configured to use nop operations since it cannot be controlled. Link: https://lore.kernel.org/all/945fb7e913a9c3dcb40697328b7e9842b75fea5c.camel@pengutronix.de [1] Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- drivers/clk/thead/clk-th1520-ap.c | 87 ++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 6 deletions(-) diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c index ea96d007aecd..1dfcde867233 100644 --- a/drivers/clk/thead/clk-th1520-ap.c +++ b/drivers/clk/thead/clk-th1520-ap.c @@ -12,6 +12,7 @@ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/regmap.h> +#include <linux/reset.h> #define TH1520_PLL_POSTDIV2 GENMASK(26, 24) #define TH1520_PLL_POSTDIV1 GENMASK(22, 20) @@ -862,17 +863,70 @@ static CCU_GATE(CLK_SRAM1, sram1_clk, "sram1", axi_aclk_pd, 0x20c, BIT(3), 0); static CCU_GATE(CLK_SRAM2, sram2_clk, "sram2", axi_aclk_pd, 0x20c, BIT(2), 0); static CCU_GATE(CLK_SRAM3, sram3_clk, "sram3", axi_aclk_pd, 0x20c, BIT(1), 0); +static struct reset_control *gpu_reset; +static DEFINE_SPINLOCK(gpu_reset_lock); /* protect GPU reset sequence */ + +static void ccu_gpu_clk_disable(struct clk_hw *hw); +static int ccu_gpu_clk_enable(struct clk_hw *hw); + +static const struct clk_ops ccu_gate_gpu_ops = { + .disable = ccu_gpu_clk_disable, + .enable = ccu_gpu_clk_enable +}; + static const struct clk_ops clk_nop_ops = {}; static CCU_GATE_CLK_OPS(CLK_GPU_MEM, gpu_mem_clk, "gpu-mem-clk", video_pll_clk_pd, 0x0, BIT(2), 0, clk_nop_ops); +static CCU_GATE_CLK_OPS(CLK_GPU_CORE, gpu_core_clk, "gpu-core-clk", + video_pll_clk_pd, 0x0, BIT(3), 0, ccu_gate_gpu_ops); +static CCU_GATE_CLK_OPS(CLK_GPU_CFG_ACLK, gpu_cfg_aclk, "gpu-cfg-aclk", + video_pll_clk_pd, 0x0, BIT(4), 0, ccu_gate_gpu_ops); + +static void ccu_gpu_clk_disable(struct clk_hw *hw) +{ + struct ccu_gate *cg = hw_to_ccu_gate(hw); + unsigned long flags; + + spin_lock_irqsave(&gpu_reset_lock, flags); + + ccu_disable_helper(&cg->common, cg->enable); + + if ((cg == &gpu_core_clk && + !clk_hw_is_enabled(&gpu_cfg_aclk.common.hw)) || + (cg == &gpu_cfg_aclk && + !clk_hw_is_enabled(&gpu_core_clk.common.hw))) + reset_control_assert(gpu_reset); + + spin_unlock_irqrestore(&gpu_reset_lock, flags); +} + +static int ccu_gpu_clk_enable(struct clk_hw *hw) +{ + struct ccu_gate *cg = hw_to_ccu_gate(hw); + unsigned long flags; + int ret; + + spin_lock_irqsave(&gpu_reset_lock, flags); + + ret = ccu_enable_helper(&cg->common, cg->enable); + if (ret) { + spin_unlock_irqrestore(&gpu_reset_lock, flags); + return ret; + } + + if ((cg == &gpu_core_clk && + clk_hw_is_enabled(&gpu_cfg_aclk.common.hw)) || + (cg == &gpu_cfg_aclk && clk_hw_is_enabled(&gpu_core_clk.common.hw))) + ret = reset_control_deassert(gpu_reset); + + spin_unlock_irqrestore(&gpu_reset_lock, flags); + + return ret; +} static CCU_GATE(CLK_AXI4_VO_ACLK, axi4_vo_aclk, "axi4-vo-aclk", video_pll_clk_pd, 0x0, BIT(0), 0); -static CCU_GATE(CLK_GPU_CORE, gpu_core_clk, "gpu-core-clk", video_pll_clk_pd, - 0x0, BIT(3), 0); -static CCU_GATE(CLK_GPU_CFG_ACLK, gpu_cfg_aclk, "gpu-cfg-aclk", - video_pll_clk_pd, 0x0, BIT(4), 0); static CCU_GATE(CLK_DPU_PIXELCLK0, dpu0_pixelclk, "dpu0-pixelclk", video_pll_clk_pd, 0x0, BIT(5), 0); static CCU_GATE(CLK_DPU_PIXELCLK1, dpu1_pixelclk, "dpu1-pixelclk", @@ -1046,8 +1100,6 @@ static struct ccu_common *th1520_gate_clks[] = { static struct ccu_common *th1520_vo_gate_clks[] = { &axi4_vo_aclk.common, - &gpu_core_clk.common, - &gpu_cfg_aclk.common, &dpu0_pixelclk.common, &dpu1_pixelclk.common, &dpu_hclk.common, @@ -1150,6 +1202,13 @@ static int th1520_clk_probe(struct platform_device *pdev) if (IS_ERR(map)) return PTR_ERR(map); + if (plat_data == &th1520_vo_platdata) { + gpu_reset = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(gpu_reset)) + return dev_err_probe(dev, PTR_ERR(gpu_reset), + "GPU reset is required for VO clock controller\n"); + } + for (i = 0; i < plat_data->nr_pll_clks; i++) { struct ccu_pll *cp = hw_to_ccu_pll(&plat_data->th1520_pll_clks[i]->hw); @@ -1226,11 +1285,27 @@ static int th1520_clk_probe(struct platform_device *pdev) if (ret) return ret; } else if (plat_data == &th1520_vo_platdata) { + /* GPU clocks need to be treated differently, as MEM clock + * is non-configurable, and the reset needs to be de-asserted + * after enabling CORE and CFG clocks. + */ ret = devm_clk_hw_register(dev, &gpu_mem_clk.common.hw); if (ret) return ret; gpu_mem_clk.common.map = map; priv->hws[CLK_GPU_MEM] = &gpu_mem_clk.common.hw; + + ret = devm_clk_hw_register(dev, &gpu_core_clk.common.hw); + if (ret) + return ret; + gpu_core_clk.common.map = map; + priv->hws[CLK_GPU_CORE] = &gpu_core_clk.common.hw; + + ret = devm_clk_hw_register(dev, &gpu_cfg_aclk.common.hw); + if (ret) + return ret; + gpu_cfg_aclk.common.map = map; + priv->hws[CLK_GPU_CFG_ACLK] = &gpu_cfg_aclk.common.hw; } ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv); -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140304eucas1p21c5e28e2497bb4046f8f2a26b4f47299@eucas1p2.samsung.com>]
* [PATCH v5 11/21] dt-bindings: reset: Add T-HEAD TH1520 SoC Reset Controller [not found] ` <CGME20250219140304eucas1p21c5e28e2497bb4046f8f2a26b4f47299@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski, Krzysztof Kozlowski Add a YAML schema for the T-HEAD TH1520 SoC reset controller. This controller manages resets for subsystems such as the GPU within the TH1520 SoC. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- .../bindings/reset/thead,th1520-reset.yaml | 44 +++++++++++++++++++ MAINTAINERS | 2 + .../dt-bindings/reset/thead,th1520-reset.h | 16 +++++++ 3 files changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml create mode 100644 include/dt-bindings/reset/thead,th1520-reset.h diff --git a/Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml b/Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml new file mode 100644 index 000000000000..f2e91d0add7a --- /dev/null +++ b/Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/reset/thead,th1520-reset.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: T-HEAD TH1520 SoC Reset Controller + +description: + The T-HEAD TH1520 reset controller is a hardware block that asserts/deasserts + resets for SoC subsystems. + +maintainers: + - Michal Wilczynski <m.wilczynski@samsung.com> + +properties: + compatible: + enum: + - thead,th1520-reset + + reg: + maxItems: 1 + + "#reset-cells": + const: 1 + +required: + - compatible + - reg + - "#reset-cells" + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + rst: reset-controller@ffef528000 { + compatible = "thead,th1520-reset"; + reg = <0xff 0xef528000 0x0 0x1000>; + #reset-cells = <1>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 18f0eb293519..819686e98214 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20417,6 +20417,7 @@ F: Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml +F: Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml F: arch/riscv/boot/dts/thead/ F: drivers/clk/thead/clk-th1520-ap.c F: drivers/firmware/thead,th1520-aon.c @@ -20426,6 +20427,7 @@ F: drivers/pinctrl/pinctrl-th1520.c F: drivers/pmdomain/thead/ F: include/dt-bindings/clock/thead,th1520-clk-ap.h F: include/dt-bindings/power/thead,th1520-power.h +F: include/dt-bindings/reset/thead,th1520-reset.h F: include/linux/firmware/thead/thead,th1520-aon.h RNBD BLOCK DRIVERS diff --git a/include/dt-bindings/reset/thead,th1520-reset.h b/include/dt-bindings/reset/thead,th1520-reset.h new file mode 100644 index 000000000000..00459f160489 --- /dev/null +++ b/include/dt-bindings/reset/thead,th1520-reset.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Author: Michal Wilczynski <m.wilczynski@samsung.com> + */ + +#ifndef _DT_BINDINGS_TH1520_RESET_H +#define _DT_BINDINGS_TH1520_RESET_H + +#define TH1520_RESET_ID_GPU 0 +#define TH1520_RESET_ID_GPU_CLKGEN 1 +#define TH1520_RESET_ID_NPU 2 +#define TH1520_RESET_ID_WDT0 3 +#define TH1520_RESET_ID_WDT1 4 + +#endif /* _DT_BINDINGS_TH1520_RESET_H */ -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140305eucas1p26317b54727c68cf069458d270e06d962@eucas1p2.samsung.com>]
* [PATCH v5 12/21] reset: thead: Add TH1520 reset controller driver [not found] ` <CGME20250219140305eucas1p26317b54727c68cf069458d270e06d962@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 2025-02-19 15:01 ` Philipp Zabel 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski Add reset controller driver for the T-HEAD TH1520 SoC that manages hardware reset lines for various subsystems. The driver currently implements support for GPU reset control, with infrastructure in place to extend support for NPU and Watchdog Timer resets in future updates. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- MAINTAINERS | 1 + drivers/reset/Kconfig | 10 +++ drivers/reset/Makefile | 1 + drivers/reset/reset-th1520.c | 141 +++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 drivers/reset/reset-th1520.c diff --git a/MAINTAINERS b/MAINTAINERS index 819686e98214..e4a0a83b4c11 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20425,6 +20425,7 @@ F: drivers/mailbox/mailbox-th1520.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c F: drivers/pinctrl/pinctrl-th1520.c F: drivers/pmdomain/thead/ +F: drivers/reset/reset-th1520.c F: include/dt-bindings/clock/thead,th1520-clk-ap.h F: include/dt-bindings/power/thead,th1520-power.h F: include/dt-bindings/reset/thead,th1520-reset.h diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 5b3abb6db248..fa0943c3d1de 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -272,6 +272,16 @@ config RESET_SUNXI help This enables the reset driver for Allwinner SoCs. +config RESET_TH1520 + tristate "T-HEAD 1520 reset controller" + depends on ARCH_THEAD || COMPILE_TEST + select REGMAP_MMIO + help + This driver provides support for the T-HEAD TH1520 SoC reset controller, + which manages hardware reset lines for SoC components such as the GPU. + Enable this option if you need to control hardware resets on TH1520-based + systems. + config RESET_TI_SCI tristate "TI System Control Interface (TI-SCI) reset driver" depends on TI_SCI_PROTOCOL || (COMPILE_TEST && TI_SCI_PROTOCOL=n) diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 677c4d1e2632..d6c2774407ae 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o +obj-$(CONFIG_RESET_TH1520) += reset-th1520.o obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o obj-$(CONFIG_RESET_TI_TPS380X) += reset-tps380x.o diff --git a/drivers/reset/reset-th1520.c b/drivers/reset/reset-th1520.c new file mode 100644 index 000000000000..d6816c86ba95 --- /dev/null +++ b/drivers/reset/reset-th1520.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Author: Michal Wilczynski <m.wilczynski@samsung.com> + */ + +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/reset-controller.h> +#include <linux/regmap.h> + +#include <dt-bindings/reset/thead,th1520-reset.h> + + /* register offset in VOSYS_REGMAP */ +#define TH1520_GPU_RST_CFG 0x0 +#define TH1520_GPU_RST_CFG_MASK GENMASK(1, 0) + +/* register values */ +#define TH1520_GPU_SW_GPU_RST BIT(0) +#define TH1520_GPU_SW_CLKGEN_RST BIT(1) + +struct th1520_reset_priv { + struct reset_controller_dev rcdev; + struct regmap *map; +}; + +struct th1520_reset_map { + u32 bit; + u32 reg; +}; + +static const struct th1520_reset_map th1520_resets[] = { + [TH1520_RESET_ID_GPU] = { + .bit = TH1520_GPU_SW_GPU_RST, + .reg = TH1520_GPU_RST_CFG, + }, + [TH1520_RESET_ID_GPU_CLKGEN] = { + .bit = TH1520_GPU_SW_CLKGEN_RST, + .reg = TH1520_GPU_RST_CFG, + } +}; + +static inline struct th1520_reset_priv * +to_th1520_reset(struct reset_controller_dev *rcdev) +{ + return container_of(rcdev, struct th1520_reset_priv, rcdev); +} + +static int th1520_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct th1520_reset_priv *priv = to_th1520_reset(rcdev); + const struct th1520_reset_map *reset; + + if (id >= ARRAY_SIZE(th1520_resets)) + return -EINVAL; + + reset = &th1520_resets[id]; + + return regmap_update_bits(priv->map, reset->reg, reset->bit, 0); +} + +static int th1520_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct th1520_reset_priv *priv = to_th1520_reset(rcdev); + const struct th1520_reset_map *reset; + + if (id >= ARRAY_SIZE(th1520_resets)) + return -EINVAL; + + reset = &th1520_resets[id]; + + return regmap_update_bits(priv->map, reset->reg, reset->bit, + reset->bit); +} + +static const struct reset_control_ops th1520_reset_ops = { + .assert = th1520_reset_assert, + .deassert = th1520_reset_deassert, +}; + +static const struct regmap_config th1520_reset_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .fast_io = true, +}; + +static int th1520_reset_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct th1520_reset_priv *priv; + void __iomem *base; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + priv->map = devm_regmap_init_mmio(dev, base, + &th1520_reset_regmap_config); + if (IS_ERR(priv->map)) + return PTR_ERR(priv->map); + + /* Initialize GPU resets to asserted state */ + ret = regmap_update_bits(priv->map, TH1520_GPU_RST_CFG, + TH1520_GPU_RST_CFG_MASK, 0); + if (ret) + return ret; + + priv->rcdev.owner = THIS_MODULE; + priv->rcdev.nr_resets = 2; + priv->rcdev.ops = &th1520_reset_ops; + priv->rcdev.of_node = dev->of_node; + + return devm_reset_controller_register(dev, &priv->rcdev); +} + +static const struct of_device_id th1520_reset_match[] = { + { .compatible = "thead,th1520-reset" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, th1520_reset_match); + +static struct platform_driver th1520_reset_driver = { + .driver = { + .name = "th1520-reset", + .of_match_table = th1520_reset_match, + }, + .probe = th1520_reset_probe, +}; +module_platform_driver(th1520_reset_driver); + +MODULE_AUTHOR("Michal Wilczynski <m.wilczynski@samsung.com>"); +MODULE_DESCRIPTION("T-HEAD TH1520 SoC reset controller"); +MODULE_LICENSE("GPL"); -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 12/21] reset: thead: Add TH1520 reset controller driver 2025-02-19 14:02 ` [PATCH v5 12/21] reset: thead: Add TH1520 reset controller driver Michal Wilczynski @ 2025-02-19 15:01 ` Philipp Zabel 2025-02-20 11:59 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Philipp Zabel @ 2025-02-19 15:01 UTC (permalink / raw) To: Michal Wilczynski, mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Mi, 2025-02-19 at 15:02 +0100, Michal Wilczynski wrote: > Add reset controller driver for the T-HEAD TH1520 SoC that manages > hardware reset lines for various subsystems. The driver currently > implements support for GPU reset control, with infrastructure in place > to extend support for NPU and Watchdog Timer resets in future updates. > > Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > --- > MAINTAINERS | 1 + > drivers/reset/Kconfig | 10 +++ > drivers/reset/Makefile | 1 + > drivers/reset/reset-th1520.c | 141 +++++++++++++++++++++++++++++++++++ > 4 files changed, 153 insertions(+) > create mode 100644 drivers/reset/reset-th1520.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 819686e98214..e4a0a83b4c11 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -20425,6 +20425,7 @@ F: drivers/mailbox/mailbox-th1520.c > F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c > F: drivers/pinctrl/pinctrl-th1520.c > F: drivers/pmdomain/thead/ > +F: drivers/reset/reset-th1520.c > F: include/dt-bindings/clock/thead,th1520-clk-ap.h > F: include/dt-bindings/power/thead,th1520-power.h > F: include/dt-bindings/reset/thead,th1520-reset.h > diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig > index 5b3abb6db248..fa0943c3d1de 100644 > --- a/drivers/reset/Kconfig > +++ b/drivers/reset/Kconfig > @@ -272,6 +272,16 @@ config RESET_SUNXI > help > This enables the reset driver for Allwinner SoCs. > > +config RESET_TH1520 > + tristate "T-HEAD 1520 reset controller" > + depends on ARCH_THEAD || COMPILE_TEST > + select REGMAP_MMIO > + help > + This driver provides support for the T-HEAD TH1520 SoC reset controller, > + which manages hardware reset lines for SoC components such as the GPU. > + Enable this option if you need to control hardware resets on TH1520-based > + systems. > + > config RESET_TI_SCI > tristate "TI System Control Interface (TI-SCI) reset driver" > depends on TI_SCI_PROTOCOL || (COMPILE_TEST && TI_SCI_PROTOCOL=n) > diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile > index 677c4d1e2632..d6c2774407ae 100644 > --- a/drivers/reset/Makefile > +++ b/drivers/reset/Makefile > @@ -35,6 +35,7 @@ obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o > obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o > obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o > obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o > +obj-$(CONFIG_RESET_TH1520) += reset-th1520.o > obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o > obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o > obj-$(CONFIG_RESET_TI_TPS380X) += reset-tps380x.o > diff --git a/drivers/reset/reset-th1520.c b/drivers/reset/reset-th1520.c > new file mode 100644 > index 000000000000..d6816c86ba95 > --- /dev/null > +++ b/drivers/reset/reset-th1520.c > @@ -0,0 +1,141 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2024 Samsung Electronics Co., Ltd. > + * Author: Michal Wilczynski <m.wilczynski@samsung.com> > + */ > + > +#include <linux/of.h> > +#include <linux/platform_device.h> > +#include <linux/reset-controller.h> > +#include <linux/regmap.h> > + > +#include <dt-bindings/reset/thead,th1520-reset.h> > + > + /* register offset in VOSYS_REGMAP */ > +#define TH1520_GPU_RST_CFG 0x0 > +#define TH1520_GPU_RST_CFG_MASK GENMASK(1, 0) > + > +/* register values */ > +#define TH1520_GPU_SW_GPU_RST BIT(0) > +#define TH1520_GPU_SW_CLKGEN_RST BIT(1) > + > +struct th1520_reset_priv { > + struct reset_controller_dev rcdev; > + struct regmap *map; > +}; > + > +struct th1520_reset_map { > + u32 bit; > + u32 reg; > +}; > + > +static const struct th1520_reset_map th1520_resets[] = { > + [TH1520_RESET_ID_GPU] = { > + .bit = TH1520_GPU_SW_GPU_RST, > + .reg = TH1520_GPU_RST_CFG, > + }, > + [TH1520_RESET_ID_GPU_CLKGEN] = { > + .bit = TH1520_GPU_SW_CLKGEN_RST, > + .reg = TH1520_GPU_RST_CFG, > + } I expect the NPU and WDT resets will be added to this list later? > +}; > + > +static inline struct th1520_reset_priv * > +to_th1520_reset(struct reset_controller_dev *rcdev) > +{ > + return container_of(rcdev, struct th1520_reset_priv, rcdev); > +} > + > +static int th1520_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct th1520_reset_priv *priv = to_th1520_reset(rcdev); > + const struct th1520_reset_map *reset; > + > + if (id >= ARRAY_SIZE(th1520_resets)) > + return -EINVAL; This check is not necessary. The core will have checked this in of_reset_simple_xlate() before returning the reset control. > + > + reset = &th1520_resets[id]; > + > + return regmap_update_bits(priv->map, reset->reg, reset->bit, 0); > +} > + > +static int th1520_reset_deassert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct th1520_reset_priv *priv = to_th1520_reset(rcdev); > + const struct th1520_reset_map *reset; > + > + if (id >= ARRAY_SIZE(th1520_resets)) > + return -EINVAL; This check is not necessary. > + > + reset = &th1520_resets[id]; > + > + return regmap_update_bits(priv->map, reset->reg, reset->bit, > + reset->bit); > +} > + > +static const struct reset_control_ops th1520_reset_ops = { > + .assert = th1520_reset_assert, > + .deassert = th1520_reset_deassert, > +}; > + > +static const struct regmap_config th1520_reset_regmap_config = { > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > + .fast_io = true, > +}; > + > +static int th1520_reset_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct th1520_reset_priv *priv; > + void __iomem *base; > + int ret; > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(base)) > + return PTR_ERR(base); > + > + priv->map = devm_regmap_init_mmio(dev, base, > + &th1520_reset_regmap_config); > + if (IS_ERR(priv->map)) > + return PTR_ERR(priv->map); > + > + /* Initialize GPU resets to asserted state */ > + ret = regmap_update_bits(priv->map, TH1520_GPU_RST_CFG, > + TH1520_GPU_RST_CFG_MASK, 0); > + if (ret) > + return ret; > + > + priv->rcdev.owner = THIS_MODULE; > + priv->rcdev.nr_resets = 2; Better use ARRAY_SIZE(th1520_resets) here, this will simplify adding further resets in the future. With that, Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> regards Philipp _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 12/21] reset: thead: Add TH1520 reset controller driver 2025-02-19 15:01 ` Philipp Zabel @ 2025-02-20 11:59 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-20 11:59 UTC (permalink / raw) To: Philipp Zabel, mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 2/19/25 16:01, Philipp Zabel wrote: > On Mi, 2025-02-19 at 15:02 +0100, Michal Wilczynski wrote: >> Add reset controller driver for the T-HEAD TH1520 SoC that manages >> hardware reset lines for various subsystems. The driver currently >> implements support for GPU reset control, with infrastructure in place >> to extend support for NPU and Watchdog Timer resets in future updates. >> >> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> >> --- >> MAINTAINERS | 1 + >> drivers/reset/Kconfig | 10 +++ >> drivers/reset/Makefile | 1 + >> drivers/reset/reset-th1520.c | 141 +++++++++++++++++++++++++++++++++++ >> 4 files changed, 153 insertions(+) >> create mode 100644 drivers/reset/reset-th1520.c >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 819686e98214..e4a0a83b4c11 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -20425,6 +20425,7 @@ F: drivers/mailbox/mailbox-th1520.c >> F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c >> F: drivers/pinctrl/pinctrl-th1520.c >> F: drivers/pmdomain/thead/ >> +F: drivers/reset/reset-th1520.c >> F: include/dt-bindings/clock/thead,th1520-clk-ap.h >> F: include/dt-bindings/power/thead,th1520-power.h >> F: include/dt-bindings/reset/thead,th1520-reset.h >> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig >> index 5b3abb6db248..fa0943c3d1de 100644 >> --- a/drivers/reset/Kconfig >> +++ b/drivers/reset/Kconfig >> @@ -272,6 +272,16 @@ config RESET_SUNXI >> help >> This enables the reset driver for Allwinner SoCs. >> >> +config RESET_TH1520 >> + tristate "T-HEAD 1520 reset controller" >> + depends on ARCH_THEAD || COMPILE_TEST >> + select REGMAP_MMIO >> + help >> + This driver provides support for the T-HEAD TH1520 SoC reset controller, >> + which manages hardware reset lines for SoC components such as the GPU. >> + Enable this option if you need to control hardware resets on TH1520-based >> + systems. >> + >> config RESET_TI_SCI >> tristate "TI System Control Interface (TI-SCI) reset driver" >> depends on TI_SCI_PROTOCOL || (COMPILE_TEST && TI_SCI_PROTOCOL=n) >> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile >> index 677c4d1e2632..d6c2774407ae 100644 >> --- a/drivers/reset/Makefile >> +++ b/drivers/reset/Makefile >> @@ -35,6 +35,7 @@ obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o >> obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o >> obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o >> obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o >> +obj-$(CONFIG_RESET_TH1520) += reset-th1520.o >> obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o >> obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o >> obj-$(CONFIG_RESET_TI_TPS380X) += reset-tps380x.o >> diff --git a/drivers/reset/reset-th1520.c b/drivers/reset/reset-th1520.c >> new file mode 100644 >> index 000000000000..d6816c86ba95 >> --- /dev/null >> +++ b/drivers/reset/reset-th1520.c >> @@ -0,0 +1,141 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (c) 2024 Samsung Electronics Co., Ltd. >> + * Author: Michal Wilczynski <m.wilczynski@samsung.com> >> + */ >> + >> +#include <linux/of.h> >> +#include <linux/platform_device.h> >> +#include <linux/reset-controller.h> >> +#include <linux/regmap.h> >> + >> +#include <dt-bindings/reset/thead,th1520-reset.h> >> + >> + /* register offset in VOSYS_REGMAP */ >> +#define TH1520_GPU_RST_CFG 0x0 >> +#define TH1520_GPU_RST_CFG_MASK GENMASK(1, 0) >> + >> +/* register values */ >> +#define TH1520_GPU_SW_GPU_RST BIT(0) >> +#define TH1520_GPU_SW_CLKGEN_RST BIT(1) >> + >> +struct th1520_reset_priv { >> + struct reset_controller_dev rcdev; >> + struct regmap *map; >> +}; >> + >> +struct th1520_reset_map { >> + u32 bit; >> + u32 reg; >> +}; >> + >> +static const struct th1520_reset_map th1520_resets[] = { >> + [TH1520_RESET_ID_GPU] = { >> + .bit = TH1520_GPU_SW_GPU_RST, >> + .reg = TH1520_GPU_RST_CFG, >> + }, >> + [TH1520_RESET_ID_GPU_CLKGEN] = { >> + .bit = TH1520_GPU_SW_CLKGEN_RST, >> + .reg = TH1520_GPU_RST_CFG, >> + } > > I expect the NPU and WDT resets will be added to this list later? Thanks! Yes, the NPU and WDT resets will be added later. For now, we’re hoping to merge the current patchset as it has already grown quite a bit. I'll be back from my time off at the beginning of March and will re-send the series with fixes for any remaining issues. > >> +}; >> + >> +static inline struct th1520_reset_priv * >> +to_th1520_reset(struct reset_controller_dev *rcdev) >> +{ >> + return container_of(rcdev, struct th1520_reset_priv, rcdev); >> +} >> + >> +static int th1520_reset_assert(struct reset_controller_dev *rcdev, >> + unsigned long id) >> +{ >> + struct th1520_reset_priv *priv = to_th1520_reset(rcdev); >> + const struct th1520_reset_map *reset; >> + >> + if (id >= ARRAY_SIZE(th1520_resets)) >> + return -EINVAL; > > This check is not necessary. The core will have checked this in > of_reset_simple_xlate() before returning the reset control. > >> + >> + reset = &th1520_resets[id]; >> + >> + return regmap_update_bits(priv->map, reset->reg, reset->bit, 0); >> +} >> + >> +static int th1520_reset_deassert(struct reset_controller_dev *rcdev, >> + unsigned long id) >> +{ >> + struct th1520_reset_priv *priv = to_th1520_reset(rcdev); >> + const struct th1520_reset_map *reset; >> + >> + if (id >= ARRAY_SIZE(th1520_resets)) >> + return -EINVAL; > > This check is not necessary. > >> + >> + reset = &th1520_resets[id]; >> + >> + return regmap_update_bits(priv->map, reset->reg, reset->bit, >> + reset->bit); >> +} >> + >> +static const struct reset_control_ops th1520_reset_ops = { >> + .assert = th1520_reset_assert, >> + .deassert = th1520_reset_deassert, >> +}; >> + >> +static const struct regmap_config th1520_reset_regmap_config = { >> + .reg_bits = 32, >> + .val_bits = 32, >> + .reg_stride = 4, >> + .fast_io = true, >> +}; >> + >> +static int th1520_reset_probe(struct platform_device *pdev) >> +{ >> + struct device *dev = &pdev->dev; >> + struct th1520_reset_priv *priv; >> + void __iomem *base; >> + int ret; >> + >> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); >> + if (!priv) >> + return -ENOMEM; >> + >> + base = devm_platform_ioremap_resource(pdev, 0); >> + if (IS_ERR(base)) >> + return PTR_ERR(base); >> + >> + priv->map = devm_regmap_init_mmio(dev, base, >> + &th1520_reset_regmap_config); >> + if (IS_ERR(priv->map)) >> + return PTR_ERR(priv->map); >> + >> + /* Initialize GPU resets to asserted state */ >> + ret = regmap_update_bits(priv->map, TH1520_GPU_RST_CFG, >> + TH1520_GPU_RST_CFG_MASK, 0); >> + if (ret) >> + return ret; >> + >> + priv->rcdev.owner = THIS_MODULE; >> + priv->rcdev.nr_resets = 2; > > Better use ARRAY_SIZE(th1520_resets) here, this will simplify adding > further resets in the future. With that, > > Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> > > regards > Philipp > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140306eucas1p19ba425ddb1e499ef1014b1665be9de8e@eucas1p1.samsung.com>]
* [PATCH v5 13/21] drm/imagination: Add reset controller support for GPU initialization [not found] ` <CGME20250219140306eucas1p19ba425ddb1e499ef1014b1665be9de8e@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 2025-04-16 14:25 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski All IMG Rogue GPUs include a reset line that participates in the power-up sequence. On some SoCs (e.g., T-Head TH1520 and Banana Pi BPI-F3), this reset line is exposed and must be driven explicitly to ensure proper initialization. On others, such as the currently supported TI SoC, the reset logic is handled in hardware or firmware without exposing the line directly. In platforms where the reset line is externally accessible, if it is not driven correctly, the GPU may remain in an undefined state, leading to instability or performance issues. This commit adds a dedicated reset controller to the drm/imagination driver. By managing the reset line (where applicable) as part of normal GPU bring-up, the driver ensures reliable initialization across platforms regardless of whether the reset is controlled externally or handled internally. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- drivers/gpu/drm/imagination/pvr_device.c | 21 +++++++++++++++++++++ drivers/gpu/drm/imagination/pvr_device.h | 9 +++++++++ drivers/gpu/drm/imagination/pvr_power.c | 22 +++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c index 1704c0268589..ef73e95157ee 100644 --- a/drivers/gpu/drm/imagination/pvr_device.c +++ b/drivers/gpu/drm/imagination/pvr_device.c @@ -25,6 +25,7 @@ #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/slab.h> #include <linux/stddef.h> #include <linux/types.h> @@ -120,6 +121,21 @@ static int pvr_device_clk_init(struct pvr_device *pvr_dev) return 0; } +static int pvr_device_reset_init(struct pvr_device *pvr_dev) +{ + struct drm_device *drm_dev = from_pvr_device(pvr_dev); + struct reset_control *reset; + + reset = devm_reset_control_get_optional_exclusive(drm_dev->dev, NULL); + if (IS_ERR(reset)) + return dev_err_probe(drm_dev->dev, PTR_ERR(reset), + "failed to get gpu reset line\n"); + + pvr_dev->reset = reset; + + return 0; +} + /** * pvr_device_process_active_queues() - Process all queue related events. * @pvr_dev: PowerVR device to check @@ -509,6 +525,11 @@ pvr_device_init(struct pvr_device *pvr_dev) if (err) return err; + /* Get the reset line for the GPU */ + err = pvr_device_reset_init(pvr_dev); + if (err) + return err; + /* Explicitly power the GPU so we can access control registers before the FW is booted. */ err = pm_runtime_resume_and_get(dev); if (err) diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/imagination/pvr_device.h index 6d0dfacb677b..f6576c08111c 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -131,6 +131,15 @@ struct pvr_device { */ struct clk *mem_clk; + /** + * @reset: Optional reset line. + * + * This may be used on some platforms to provide a reset line that needs to be de-asserted + * after power-up procedure. It would also need to be asserted after the power-down + * procedure. + */ + struct reset_control *reset; + /** @irq: IRQ number. */ int irq; diff --git a/drivers/gpu/drm/imagination/pvr_power.c b/drivers/gpu/drm/imagination/pvr_power.c index ba7816fd28ec..5944645bf1b2 100644 --- a/drivers/gpu/drm/imagination/pvr_power.c +++ b/drivers/gpu/drm/imagination/pvr_power.c @@ -15,6 +15,7 @@ #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/timer.h> #include <linux/types.h> #include <linux/workqueue.h> @@ -252,6 +253,8 @@ pvr_power_device_suspend(struct device *dev) clk_disable_unprepare(pvr_dev->sys_clk); clk_disable_unprepare(pvr_dev->core_clk); + err = reset_control_assert(pvr_dev->reset); + err_drm_dev_exit: drm_dev_exit(idx); @@ -282,16 +285,33 @@ pvr_power_device_resume(struct device *dev) if (err) goto err_sys_clk_disable; + /* + * According to the hardware manual, a delay of at least 32 clock + * cycles is required between de-asserting the clkgen reset and + * de-asserting the GPU reset. Assuming a worst-case scenario with + * a very high GPU clock frequency, a delay of 1 microsecond is + * sufficient to ensure this requirement is met across all + * feasible GPU clock speeds. + */ + udelay(1); + + err = reset_control_deassert(pvr_dev->reset); + if (err) + goto err_mem_clk_disable; + if (pvr_dev->fw_dev.booted) { err = pvr_power_fw_enable(pvr_dev); if (err) - goto err_mem_clk_disable; + goto err_reset_assert; } drm_dev_exit(idx); return 0; +err_reset_assert: + reset_control_assert(pvr_dev->reset); + err_mem_clk_disable: clk_disable_unprepare(pvr_dev->mem_clk); -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 13/21] drm/imagination: Add reset controller support for GPU initialization 2025-02-19 14:02 ` [PATCH v5 13/21] drm/imagination: Add reset controller support for GPU initialization Michal Wilczynski @ 2025-04-16 14:25 ` Michal Wilczynski 2025-04-16 16:53 ` Matt Coster 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-04-16 14:25 UTC (permalink / raw) To: frank.binns, matt.coster Cc: p.zabel, m.szyprowski, linux-clk, conor+dt, devicetree, mripard, linux-kernel, tzimmermann, linux-riscv, airlied, simona, aou, dri-devel, ulf.hansson, linux-pm, jszhang, palmer, guoren, maarten.lankhorst, wefu, paul.walmsley, jassisinghbrar, drew, robh, sboyd, mturquette, krzk+dt On 2/19/25 15:02, Michal Wilczynski wrote: > All IMG Rogue GPUs include a reset line that participates in the > power-up sequence. On some SoCs (e.g., T-Head TH1520 and Banana Pi > BPI-F3), this reset line is exposed and must be driven explicitly to > ensure proper initialization. On others, such as the currently > supported TI SoC, the reset logic is handled in hardware or firmware > without exposing the line directly. In platforms where the reset line is > externally accessible, if it is not driven correctly, the GPU may remain > in an undefined state, leading to instability or performance issues. > > This commit adds a dedicated reset controller to the drm/imagination > driver. By managing the reset line (where applicable) as part of normal > GPU bring-up, the driver ensures reliable initialization across > platforms regardless of whether the reset is controlled externally or > handled internally. > > Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > --- > drivers/gpu/drm/imagination/pvr_device.c | 21 +++++++++++++++++++++ > drivers/gpu/drm/imagination/pvr_device.h | 9 +++++++++ > drivers/gpu/drm/imagination/pvr_power.c | 22 +++++++++++++++++++++- > 3 files changed, 51 insertions(+), 1 deletion(-) > Hi Matt, This commit, along with the corresponding change in the DT bindings, doesn’t appear to conflict with the work you're doing for Rogue series enablement. Would you prefer if I re-send them as a mini-series so you can consider picking them up for the next kernel release? Regards, Michał _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 13/21] drm/imagination: Add reset controller support for GPU initialization 2025-04-16 14:25 ` Michal Wilczynski @ 2025-04-16 16:53 ` Matt Coster 0 siblings, 0 replies; 43+ messages in thread From: Matt Coster @ 2025-04-16 16:53 UTC (permalink / raw) To: Michal Wilczynski Cc: Frank Binns, p.zabel@pengutronix.de, m.szyprowski@samsung.com, linux-clk@vger.kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, mripard@kernel.org, linux-kernel@vger.kernel.org, tzimmermann@suse.de, linux-riscv@lists.infradead.org, airlied@gmail.com, simona@ffwll.ch, aou@eecs.berkeley.edu, dri-devel@lists.freedesktop.org, ulf.hansson@linaro.org, linux-pm@vger.kernel.org, jszhang@kernel.org, palmer@dabbelt.com, guoren@kernel.org, maarten.lankhorst@linux.intel.com, wefu@redhat.com, paul.walmsley@sifive.com, jassisinghbrar@gmail.com, drew@pdp7.com, robh@kernel.org, sboyd@kernel.org, mturquette@baylibre.com, krzk+dt@kernel.org [-- Attachment #1.1.1: Type: text/plain, Size: 1871 bytes --] On 16/04/2025 15:25, Michal Wilczynski wrote: > On 2/19/25 15:02, Michal Wilczynski wrote: >> All IMG Rogue GPUs include a reset line that participates in the >> power-up sequence. On some SoCs (e.g., T-Head TH1520 and Banana Pi >> BPI-F3), this reset line is exposed and must be driven explicitly to >> ensure proper initialization. On others, such as the currently >> supported TI SoC, the reset logic is handled in hardware or firmware >> without exposing the line directly. In platforms where the reset line is >> externally accessible, if it is not driven correctly, the GPU may remain >> in an undefined state, leading to instability or performance issues. >> >> This commit adds a dedicated reset controller to the drm/imagination >> driver. By managing the reset line (where applicable) as part of normal >> GPU bring-up, the driver ensures reliable initialization across >> platforms regardless of whether the reset is controlled externally or >> handled internally. >> >> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> >> --- >> drivers/gpu/drm/imagination/pvr_device.c | 21 +++++++++++++++++++++ >> drivers/gpu/drm/imagination/pvr_device.h | 9 +++++++++ >> drivers/gpu/drm/imagination/pvr_power.c | 22 +++++++++++++++++++++- >> 3 files changed, 51 insertions(+), 1 deletion(-) >> > > Hi Matt, > > This commit, along with the corresponding change in the DT bindings, > doesn’t appear to conflict with the work you're doing for Rogue series > enablement. Agreed, it still applies cleanly on top of drm-misc-next after we landed the BXS series. > > Would you prefer if I re-send them as a mini-series so you can consider > picking them up for the next kernel release? That would be ideal, thank you! Cheers, Matt > > Regards, > Michał -- Matt Coster E: matt.coster@imgtec.com [-- Attachment #1.2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 236 bytes --] [-- Attachment #2: Type: text/plain, Size: 161 bytes --] _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140309eucas1p2701a4b4bacd3be6e9f20d637d3cefa5c@eucas1p2.samsung.com>]
* [PATCH v5 14/21] dt-bindings: gpu: Add 'resets' property for GPU initialization [not found] ` <CGME20250219140309eucas1p2701a4b4bacd3be6e9f20d637d3cefa5c@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski, Krzysztof Kozlowski All IMG Rogue GPUs include a reset line that participates in the power-up sequence. On some SoCs (e.g., T-Head TH1520 and Banana Pi BPI-F3), this reset line is exposed and must be driven explicitly to ensure proper initialization. To support this, add a 'resets' property to the GPU device tree bindings. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml b/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml index 256e252f8087..bb607d4b1e07 100644 --- a/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml +++ b/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml @@ -37,6 +37,9 @@ properties: power-domains: maxItems: 1 + resets: + maxItems: 1 + required: - compatible - reg -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140310eucas1p1297441a3da276569cd86b6b9e4544242@eucas1p1.samsung.com>]
* [PATCH v5 15/21] dt-bindings: gpu: Add support for T-HEAD TH1520 GPU [not found] ` <CGME20250219140310eucas1p1297441a3da276569cd86b6b9e4544242@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 2025-02-21 9:16 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski Add bindings for the PowerVR BXM-4-64 GPU integrated in the T-HEAD TH1520 SoC. Add a dt-bindings example showing the proper usage of the compatible string "thead,th1520-gpu" along with "img,img-bxm". Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- .../bindings/gpu/img,powervr-rogue.yaml | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml b/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml index bb607d4b1e07..2005dcefcaf9 100644 --- a/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml +++ b/Documentation/devicetree/bindings/gpu/img,powervr-rogue.yaml @@ -12,10 +12,15 @@ maintainers: properties: compatible: - items: - - enum: - - ti,am62-gpu - - const: img,img-axe # IMG AXE GPU model/revision is fully discoverable + oneOf: + - items: + - enum: + - ti,am62-gpu + - const: img,img-axe # IMG AXE GPU model/revision is fully discoverable + - items: + - enum: + - thead,th1520-gpu + - const: img,img-bxm reg: maxItems: 1 @@ -60,6 +65,16 @@ allOf: clocks: maxItems: 1 + - if: + properties: + compatible: + contains: + const: thead,th1520-gpu + then: + properties: + clocks: + minItems: 3 + examples: - | #include <dt-bindings/interrupt-controller/irq.h> @@ -74,3 +89,19 @@ examples: interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; power-domains = <&k3_pds 187 TI_SCI_PD_EXCLUSIVE>; }; + + #include <dt-bindings/clock/thead,th1520-clk-ap.h> + #include <dt-bindings/power/thead,th1520-power.h> + #include <dt-bindings/reset/thead,th1520-reset.h> + + gpu: gpu@fff0000 { + compatible = "thead,th1520-gpu", "img,img-bxm"; + reg = <0xfff0000 0x1000>; + interrupt-parent = <&plic>; + interrupts = <102 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk CLK_GPU_CORE>, <&clk CLK_GPU_MEM>, + <&clk CLK_GPU_CFG_ACLK>; + clock-names = "core", "mem", "sys"; + power-domains = <&pd TH1520_GPU_PD>; + resets = <&rst TH1520_RESET_ID_GPU>; + }; -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 15/21] dt-bindings: gpu: Add support for T-HEAD TH1520 GPU 2025-02-19 14:02 ` [PATCH v5 15/21] dt-bindings: gpu: Add support for T-HEAD TH1520 GPU Michal Wilczynski @ 2025-02-21 9:16 ` Krzysztof Kozlowski 0 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-02-21 9:16 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Wed, Feb 19, 2025 at 03:02:33PM +0100, Michal Wilczynski wrote: > reg: > maxItems: 1 > @@ -60,6 +65,16 @@ allOf: > clocks: > maxItems: 1 > > + - if: > + properties: > + compatible: > + contains: > + const: thead,th1520-gpu > + then: > + properties: > + clocks: > + minItems: 3 Missing constraint for clock-names. They *always* go together. Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140311eucas1p24ef4a7a95abdb527c2bd305f3ed51674@eucas1p2.samsung.com>]
* [PATCH v5 16/21] drm/imagination: Add support for IMG BXM-4-64 GPU [not found] ` <CGME20250219140311eucas1p24ef4a7a95abdb527c2bd305f3ed51674@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The IMG BXM-4-64 GPU is integrated into the T-Head TH1520 SoC. This commit adds the compatible string "img,img-bxm" to the device tree match table in the drm/imagination driver, enabling support for this GPU. By including this GPU in the compatible devices list, the driver can initialize and manage the BXM-4-64 GPU on the TH1520 SoC, providing graphics acceleration capabilities upstream. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- drivers/gpu/drm/imagination/pvr_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c index 0639502137b4..2776de095439 100644 --- a/drivers/gpu/drm/imagination/pvr_drv.c +++ b/drivers/gpu/drm/imagination/pvr_drv.c @@ -1474,6 +1474,7 @@ static void pvr_remove(struct platform_device *plat_dev) static const struct of_device_id dt_match[] = { { .compatible = "img,img-axe", .data = NULL }, + { .compatible = "img,img-bxm", .data = NULL }, {} }; MODULE_DEVICE_TABLE(of, dt_match); @@ -1498,3 +1499,4 @@ MODULE_DESCRIPTION(PVR_DRIVER_DESC); MODULE_LICENSE("Dual MIT/GPL"); MODULE_IMPORT_NS("DMA_BUF"); MODULE_FIRMWARE("powervr/rogue_33.15.11.3_v1.fw"); +MODULE_FIRMWARE("powervr/rogue_36.52.104.182_v1.fw"); -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140313eucas1p211517932c3cd45ca8c843840ccd42c1e@eucas1p2.samsung.com>]
* [PATCH v5 17/21] drm/imagination: Enable PowerVR driver for RISC-V [not found] ` <CGME20250219140313eucas1p211517932c3cd45ca8c843840ccd42c1e@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski Several RISC-V boards feature Imagination GPUs that are compatible with the PowerVR driver. An example is the IMG BXM-4-64 GPU on the Lichee Pi 4A board. This commit adjusts the driver's Kconfig dependencies to allow the PowerVR driver to be compiled on the RISC-V architecture. By enabling compilation on RISC-V, we expand support for these GPUs, providing graphics acceleration capabilities and enhancing hardware compatibility on RISC-V platforms. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- drivers/gpu/drm/imagination/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imagination/Kconfig b/drivers/gpu/drm/imagination/Kconfig index 3bfa2ac212dc..5f218896114c 100644 --- a/drivers/gpu/drm/imagination/Kconfig +++ b/drivers/gpu/drm/imagination/Kconfig @@ -3,7 +3,7 @@ config DRM_POWERVR tristate "Imagination Technologies PowerVR (Series 6 and later) & IMG Graphics" - depends on ARM64 + depends on (ARM64 || RISCV) depends on DRM depends on PM select DRM_EXEC -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140314eucas1p146c73e1fdb8b56315672742f8de8c131@eucas1p1.samsung.com>]
* [PATCH v5 18/21] riscv: dts: thead: Add device tree VO clock controller [not found] ` <CGME20250219140314eucas1p146c73e1fdb8b56315672742f8de8c131@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski VO clocks reside in a different address space from the AP clocks on the T-HEAD SoC. Add the device tree node of a clock-controller to handle VO address space as well. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- arch/riscv/boot/dts/thead/th1520.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index 527336417765..197df1f32b25 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -489,6 +489,14 @@ clk: clock-controller@ffef010000 { #clock-cells = <1>; }; + clk_vo: clock-controller@ffef528050 { + compatible = "thead,th1520-clk-vo"; + reg = <0xff 0xef528050 0x0 0xfb0>; + clocks = <&clk CLK_VIDEO_PLL>; + #clock-cells = <1>; + resets = <&rst TH1520_RESET_ID_GPU_CLKGEN>; + }; + dmac0: dma-controller@ffefc00000 { compatible = "snps,axi-dma-1.01a"; reg = <0xff 0xefc00000 0x0 0x1000>; -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140315eucas1p10f08d297580edd114f4c487c1fbffa8d@eucas1p1.samsung.com>]
* [PATCH v5 19/21] riscv: dts: thead: Introduce power domain nodes with aon firmware [not found] ` <CGME20250219140315eucas1p10f08d297580edd114f4c487c1fbffa8d@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 2025-04-15 2:04 ` Drew Fustini 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski The DRM Imagination GPU requires a power-domain driver. In the T-HEAD TH1520 SoC implements power management capabilities through the E902 core, which can be communicated with through the mailbox, using firmware protocol. Add AON node, which servers as a power-domain controller. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- arch/riscv/boot/dts/thead/th1520.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index 197df1f32b25..474f31576a1b 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -6,6 +6,7 @@ #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/clock/thead,th1520-clk-ap.h> +#include <dt-bindings/power/thead,th1520-power.h> / { compatible = "thead,th1520"; @@ -229,6 +230,13 @@ stmmac_axi_config: stmmac-axi-config { snps,blen = <0 0 64 32 0 0 0>; }; + aon: aon { + compatible = "thead,th1520-aon"; + mboxes = <&mbox_910t 1>; + mbox-names = "aon"; + #power-domain-cells = <1>; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&plic>; -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 19/21] riscv: dts: thead: Introduce power domain nodes with aon firmware 2025-02-19 14:02 ` [PATCH v5 19/21] riscv: dts: thead: Introduce power domain nodes with aon firmware Michal Wilczynski @ 2025-04-15 2:04 ` Drew Fustini 2025-04-15 18:48 ` Drew Fustini 0 siblings, 1 reply; 43+ messages in thread From: Drew Fustini @ 2025-04-15 2:04 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Wed, Feb 19, 2025 at 03:02:37PM +0100, Michal Wilczynski wrote: > The DRM Imagination GPU requires a power-domain driver. In the T-HEAD > TH1520 SoC implements power management capabilities through the E902 > core, which can be communicated with through the mailbox, using firmware > protocol. > > Add AON node, which servers as a power-domain controller. > > Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > --- > arch/riscv/boot/dts/thead/th1520.dtsi | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi > index 197df1f32b25..474f31576a1b 100644 > --- a/arch/riscv/boot/dts/thead/th1520.dtsi > +++ b/arch/riscv/boot/dts/thead/th1520.dtsi > @@ -6,6 +6,7 @@ > > #include <dt-bindings/interrupt-controller/irq.h> > #include <dt-bindings/clock/thead,th1520-clk-ap.h> > +#include <dt-bindings/power/thead,th1520-power.h> > > / { > compatible = "thead,th1520"; > @@ -229,6 +230,13 @@ stmmac_axi_config: stmmac-axi-config { > snps,blen = <0 0 64 32 0 0 0>; > }; > > + aon: aon { > + compatible = "thead,th1520-aon"; > + mboxes = <&mbox_910t 1>; > + mbox-names = "aon"; > + #power-domain-cells = <1>; > + }; > + > soc { > compatible = "simple-bus"; > interrupt-parent = <&plic>; > -- > 2.34.1 > Reviewed-by: Drew Fustini <drew@pdp7.com> I tested this on top of 6.15-rc1 and found no issues. -Drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 19/21] riscv: dts: thead: Introduce power domain nodes with aon firmware 2025-04-15 2:04 ` Drew Fustini @ 2025-04-15 18:48 ` Drew Fustini 2025-04-16 11:22 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Drew Fustini @ 2025-04-15 18:48 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Mon, Apr 14, 2025 at 07:04:29PM -0700, Drew Fustini wrote: > On Wed, Feb 19, 2025 at 03:02:37PM +0100, Michal Wilczynski wrote: > > The DRM Imagination GPU requires a power-domain driver. In the T-HEAD > > TH1520 SoC implements power management capabilities through the E902 > > core, which can be communicated with through the mailbox, using firmware > > protocol. > > > > Add AON node, which servers as a power-domain controller. > > > > Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > > --- > > arch/riscv/boot/dts/thead/th1520.dtsi | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi > > index 197df1f32b25..474f31576a1b 100644 > > --- a/arch/riscv/boot/dts/thead/th1520.dtsi > > +++ b/arch/riscv/boot/dts/thead/th1520.dtsi > > @@ -6,6 +6,7 @@ > > > > #include <dt-bindings/interrupt-controller/irq.h> > > #include <dt-bindings/clock/thead,th1520-clk-ap.h> > > +#include <dt-bindings/power/thead,th1520-power.h> > > > > / { > > compatible = "thead,th1520"; > > @@ -229,6 +230,13 @@ stmmac_axi_config: stmmac-axi-config { > > snps,blen = <0 0 64 32 0 0 0>; > > }; > > > > + aon: aon { > > + compatible = "thead,th1520-aon"; > > + mboxes = <&mbox_910t 1>; > > + mbox-names = "aon"; > > + #power-domain-cells = <1>; > > + }; > > + > > soc { > > compatible = "simple-bus"; > > interrupt-parent = <&plic>; > > -- > > 2.34.1 > > > > Reviewed-by: Drew Fustini <drew@pdp7.com> > > I tested this on top of 6.15-rc1 and found no issues. > > -Drew I've applied to thead-dt-for-next: https://github.com/pdp7/linux/commit/2bae46e3de2a64fe3a619d61b16da0c01b8df2a1 Michal - are there any other dts patches that I should consider for 6.16 PR? I would probably send to Arnd around 6.15-rc3 or 6.15-rc4. Thanks, Drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 19/21] riscv: dts: thead: Introduce power domain nodes with aon firmware 2025-04-15 18:48 ` Drew Fustini @ 2025-04-16 11:22 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-04-16 11:22 UTC (permalink / raw) To: Drew Fustini Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 4/15/25 20:48, Drew Fustini wrote: > On Mon, Apr 14, 2025 at 07:04:29PM -0700, Drew Fustini wrote: >> On Wed, Feb 19, 2025 at 03:02:37PM +0100, Michal Wilczynski wrote: >>> The DRM Imagination GPU requires a power-domain driver. In the T-HEAD >>> TH1520 SoC implements power management capabilities through the E902 >>> core, which can be communicated with through the mailbox, using firmware >>> protocol. >>> >>> Add AON node, which servers as a power-domain controller. >>> >>> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> >>> --- >>> arch/riscv/boot/dts/thead/th1520.dtsi | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi >>> index 197df1f32b25..474f31576a1b 100644 >>> --- a/arch/riscv/boot/dts/thead/th1520.dtsi >>> +++ b/arch/riscv/boot/dts/thead/th1520.dtsi >>> @@ -6,6 +6,7 @@ >>> >>> #include <dt-bindings/interrupt-controller/irq.h> >>> #include <dt-bindings/clock/thead,th1520-clk-ap.h> >>> +#include <dt-bindings/power/thead,th1520-power.h> >>> >>> / { >>> compatible = "thead,th1520"; >>> @@ -229,6 +230,13 @@ stmmac_axi_config: stmmac-axi-config { >>> snps,blen = <0 0 64 32 0 0 0>; >>> }; >>> >>> + aon: aon { >>> + compatible = "thead,th1520-aon"; >>> + mboxes = <&mbox_910t 1>; >>> + mbox-names = "aon"; >>> + #power-domain-cells = <1>; >>> + }; >>> + >>> soc { >>> compatible = "simple-bus"; >>> interrupt-parent = <&plic>; >>> -- >>> 2.34.1 >>> >> >> Reviewed-by: Drew Fustini <drew@pdp7.com> >> >> I tested this on top of 6.15-rc1 and found no issues. >> >> -Drew > > I've applied to thead-dt-for-next: > https://protect2.fireeye.com/v1/url?k=2f3b741b-4eb0613b-2f3aff54-74fe485fb347-beeac007773a982c&q=1&e=eb6b4dda-c02a-4e0a-831a-a28d0489f6c3&u=https%3A%2F%2Fgithub.com%2Fpdp7%2Flinux%2Fcommit%2F2bae46e3de2a64fe3a619d61b16da0c01b8df2a1 > > Michal - are there any other dts patches that I should consider for 6.16 > PR? I would probably send to Arnd around 6.15-rc3 or 6.15-rc4. Thanks for the heads-up. I think the reset DT node would be a good candidate for inclusion [1]. Depending on how the clock series evolves, we might also consider this commit without the reset part [2]. Similarly, if the PM series lands in time, we may want to update the aon node to include the reset [3]. To avoid any last-minute issues, I can send a separate DT-only series that includes all relevant patches targeting the next release. Just give me a heads-up a few days before your PR, and I’ll make sure everything is ready. Best regards, Michał [1] - https://lore.kernel.org/all/20250219140239.1378758-21-m.wilczynski@samsung.com/ [2] - https://lore.kernel.org/all/20250219140239.1378758-19-m.wilczynski@samsung.com/ [3] - https://lore.kernel.org/all/20250414-apr_14_for_sending-v2-2-70c5af2af96c@samsung.com/ > > Thanks, > Drew > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140316eucas1p29a76023868946f090f261bf78d5103e3@eucas1p2.samsung.com>]
* [PATCH v5 20/21] riscv: dts: thead: Introduce reset controller node [not found] ` <CGME20250219140316eucas1p29a76023868946f090f261bf78d5103e3@eucas1p2.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 2025-04-19 19:09 ` Drew Fustini 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski T-HEAD TH1520 SoC requires to put the GPU out of the reset state as part of the power-up sequence. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- arch/riscv/boot/dts/thead/th1520.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index 474f31576a1b..6b34aab4b455 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -7,6 +7,7 @@ #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/clock/thead,th1520-clk-ap.h> #include <dt-bindings/power/thead,th1520-power.h> +#include <dt-bindings/reset/thead,th1520-reset.h> / { compatible = "thead,th1520"; @@ -497,6 +498,12 @@ clk: clock-controller@ffef010000 { #clock-cells = <1>; }; + rst: reset-controller@ffef528000 { + compatible = "thead,th1520-reset"; + reg = <0xff 0xef528000 0x0 0x4f>; + #reset-cells = <1>; + }; + clk_vo: clock-controller@ffef528050 { compatible = "thead,th1520-clk-vo"; reg = <0xff 0xef528050 0x0 0xfb0>; -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 20/21] riscv: dts: thead: Introduce reset controller node 2025-02-19 14:02 ` [PATCH v5 20/21] riscv: dts: thead: Introduce reset controller node Michal Wilczynski @ 2025-04-19 19:09 ` Drew Fustini 2025-04-22 7:47 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Drew Fustini @ 2025-04-19 19:09 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Wed, Feb 19, 2025 at 03:02:38PM +0100, Michal Wilczynski wrote: > T-HEAD TH1520 SoC requires to put the GPU out of the reset state as part > of the power-up sequence. > > Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > --- > arch/riscv/boot/dts/thead/th1520.dtsi | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi > index 474f31576a1b..6b34aab4b455 100644 > --- a/arch/riscv/boot/dts/thead/th1520.dtsi > +++ b/arch/riscv/boot/dts/thead/th1520.dtsi > @@ -7,6 +7,7 @@ > #include <dt-bindings/interrupt-controller/irq.h> > #include <dt-bindings/clock/thead,th1520-clk-ap.h> > #include <dt-bindings/power/thead,th1520-power.h> > +#include <dt-bindings/reset/thead,th1520-reset.h> Are you okay if I omit this hunk? My thead-dt-for-next branch is based on 6.15-rc1 but thead,th1520-reset.h only exists in next until the merge window. > > / { > compatible = "thead,th1520"; > @@ -497,6 +498,12 @@ clk: clock-controller@ffef010000 { > #clock-cells = <1>; > }; > > + rst: reset-controller@ffef528000 { > + compatible = "thead,th1520-reset"; > + reg = <0xff 0xef528000 0x0 0x4f>; > + #reset-cells = <1>; > + }; > + > clk_vo: clock-controller@ffef528050 { > compatible = "thead,th1520-clk-vo"; > reg = <0xff 0xef528050 0x0 0xfb0>; > -- > 2.34.1 > With the above caveat: Reviewed-by: Drew Fustini <drew@pdp7.com> -Drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 20/21] riscv: dts: thead: Introduce reset controller node 2025-04-19 19:09 ` Drew Fustini @ 2025-04-22 7:47 ` Michal Wilczynski 2025-04-25 19:16 ` Drew Fustini 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-04-22 7:47 UTC (permalink / raw) To: Drew Fustini Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 4/19/25 21:09, Drew Fustini wrote: > On Wed, Feb 19, 2025 at 03:02:38PM +0100, Michal Wilczynski wrote: >> T-HEAD TH1520 SoC requires to put the GPU out of the reset state as part >> of the power-up sequence. >> >> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> >> --- >> arch/riscv/boot/dts/thead/th1520.dtsi | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi >> index 474f31576a1b..6b34aab4b455 100644 >> --- a/arch/riscv/boot/dts/thead/th1520.dtsi >> +++ b/arch/riscv/boot/dts/thead/th1520.dtsi >> @@ -7,6 +7,7 @@ >> #include <dt-bindings/interrupt-controller/irq.h> >> #include <dt-bindings/clock/thead,th1520-clk-ap.h> >> #include <dt-bindings/power/thead,th1520-power.h> >> +#include <dt-bindings/reset/thead,th1520-reset.h> > > Are you okay if I omit this hunk? My thead-dt-for-next branch is based > on 6.15-rc1 but thead,th1520-reset.h only exists in next until the merge > window. Yeah, I'm not exactly sure how to coordinate such stuff, obviosuly it would be best if this chunk would make it to the 6.16, but if you think it would be problematic then omit it, no problem. I will then update this patch series v3 [1] to gracefully handle lack of reset, as the 6.16 will not contain the required reset line for sure. [1] - https://lore.kernel.org/all/20250414-apr_14_for_sending-v2-2-70c5af2af96c@samsung.com/ > >> >> / { >> compatible = "thead,th1520"; >> @@ -497,6 +498,12 @@ clk: clock-controller@ffef010000 { >> #clock-cells = <1>; >> }; >> >> + rst: reset-controller@ffef528000 { >> + compatible = "thead,th1520-reset"; >> + reg = <0xff 0xef528000 0x0 0x4f>; >> + #reset-cells = <1>; >> + }; >> + >> clk_vo: clock-controller@ffef528050 { >> compatible = "thead,th1520-clk-vo"; >> reg = <0xff 0xef528050 0x0 0xfb0>; >> -- >> 2.34.1 >> > > With the above caveat: > > Reviewed-by: Drew Fustini <drew@pdp7.com> > > > -Drew > Best regards, -- Michal Wilczynski <m.wilczynski@samsung.com> _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 20/21] riscv: dts: thead: Introduce reset controller node 2025-04-22 7:47 ` Michal Wilczynski @ 2025-04-25 19:16 ` Drew Fustini 0 siblings, 0 replies; 43+ messages in thread From: Drew Fustini @ 2025-04-25 19:16 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Tue, Apr 22, 2025 at 09:47:34AM +0200, Michal Wilczynski wrote: > > > On 4/19/25 21:09, Drew Fustini wrote: > > On Wed, Feb 19, 2025 at 03:02:38PM +0100, Michal Wilczynski wrote: > >> T-HEAD TH1520 SoC requires to put the GPU out of the reset state as part > >> of the power-up sequence. > >> > >> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> > >> --- > >> arch/riscv/boot/dts/thead/th1520.dtsi | 7 +++++++ > >> 1 file changed, 7 insertions(+) > >> > >> diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi > >> index 474f31576a1b..6b34aab4b455 100644 > >> --- a/arch/riscv/boot/dts/thead/th1520.dtsi > >> +++ b/arch/riscv/boot/dts/thead/th1520.dtsi > >> @@ -7,6 +7,7 @@ > >> #include <dt-bindings/interrupt-controller/irq.h> > >> #include <dt-bindings/clock/thead,th1520-clk-ap.h> > >> #include <dt-bindings/power/thead,th1520-power.h> > >> +#include <dt-bindings/reset/thead,th1520-reset.h> > > > > Are you okay if I omit this hunk? My thead-dt-for-next branch is based > > on 6.15-rc1 but thead,th1520-reset.h only exists in next until the merge > > window. > > Yeah, I'm not exactly sure how to coordinate such stuff, obviosuly it > would be best if this chunk would make it to the 6.16, but if you think > it would be problematic then omit it, no problem. > > I will then update this patch series v3 [1] to gracefully handle lack of > reset, as the 6.16 will not contain the required reset line for sure. > > [1] - https://lore.kernel.org/all/20250414-apr_14_for_sending-v2-2-70c5af2af96c@samsung.com/ I've applied this patch to my thead-dt-for-next tree: https://github.com/pdp7/linux/commit/1b136de08b5feca37ebdb6d28db3c9c6285aba5a We should be able to test with the driver in next once a new next is published (which I assume will be on Monday in Austrlia). Thanks, Drew _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
[parent not found: <CGME20250219140318eucas1p1db0d55468b1958f9d41963cb789e4f29@eucas1p1.samsung.com>]
* [PATCH v5 21/21] riscv: dts: thead: Add GPU node to TH1520 device tree [not found] ` <CGME20250219140318eucas1p1db0d55468b1958f9d41963cb789e4f29@eucas1p1.samsung.com> @ 2025-02-19 14:02 ` Michal Wilczynski 0 siblings, 0 replies; 43+ messages in thread From: Michal Wilczynski @ 2025-02-19 14:02 UTC (permalink / raw) To: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski Cc: linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm, Michal Wilczynski Add a device tree node for the IMG BXM-4-64 GPU present in the T-HEAD TH1520 SoC used by the Lichee Pi 4A board. This node enables support for the GPU using the drm/imagination driver. By adding this node, the kernel can recognize and initialize the GPU, providing graphics acceleration capabilities on the Lichee Pi 4A and other boards based on the TH1520 SoC. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> --- arch/riscv/boot/dts/thead/th1520.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index 6b34aab4b455..c4fa616efac8 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -498,6 +498,19 @@ clk: clock-controller@ffef010000 { #clock-cells = <1>; }; + gpu: gpu@ffef400000 { + compatible = "thead,th1520-gpu", "img,img-bxm"; + reg = <0xff 0xef400000 0x0 0x100000>; + interrupt-parent = <&plic>; + interrupts = <102 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk_vo CLK_GPU_CORE>, + <&clk_vo CLK_GPU_MEM>, + <&clk_vo CLK_GPU_CFG_ACLK>; + clock-names = "core", "mem", "sys"; + power-domains = <&aon TH1520_GPU_PD>; + resets = <&rst TH1520_RESET_ID_GPU>; + }; + rst: reset-controller@ffef528000 { compatible = "thead,th1520-reset"; reg = <0xff 0xef528000 0x0 0x4f>; -- 2.34.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A 2025-02-19 14:02 ` [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A Michal Wilczynski ` (20 preceding siblings ...) [not found] ` <CGME20250219140318eucas1p1db0d55468b1958f9d41963cb789e4f29@eucas1p1.samsung.com> @ 2025-02-21 9:12 ` Krzysztof Kozlowski 2025-03-03 8:38 ` Michal Wilczynski 21 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-02-21 9:12 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On Wed, Feb 19, 2025 at 03:02:18PM +0100, Michal Wilczynski wrote: > The LicheePi 4A board, featuring the T-HEAD TH1520 SoC, includes an Imagination > Technologies BXM-4-64 GPU. Initial support for this GPU was provided through a > downstream driver [1]. Recently, efforts have been made to upstream support for > the Rogue family GPUs, which the BXM-4-64 is part of [2]. > > While the initial upstream driver focused on the AXE-1-16 GPU, newer patches > have introduced support for the BXS-4-64 GPU [3]. The modern upstream > drm/imagination driver is expected to support the BXM-4-64 as well [4][5]. As > this support is being developed, it's crucial to upstream the necessary glue > code including clock and power-domain drivers so they're ready for integration > with the drm/imagination driver. > This is v5 of big patchset which became huge. I understand you did like that for v1 which was RFC. But it stopped being RFC. Split your patchset, keeping versioning and changelog, per subsystem. Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A 2025-02-21 9:12 ` [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A Krzysztof Kozlowski @ 2025-03-03 8:38 ` Michal Wilczynski 2025-03-03 17:43 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-03-03 8:38 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 2/21/25 10:12, Krzysztof Kozlowski wrote: > On Wed, Feb 19, 2025 at 03:02:18PM +0100, Michal Wilczynski wrote: >> The LicheePi 4A board, featuring the T-HEAD TH1520 SoC, includes an Imagination >> Technologies BXM-4-64 GPU. Initial support for this GPU was provided through a >> downstream driver [1]. Recently, efforts have been made to upstream support for >> the Rogue family GPUs, which the BXM-4-64 is part of [2]. >> >> While the initial upstream driver focused on the AXE-1-16 GPU, newer patches >> have introduced support for the BXS-4-64 GPU [3]. The modern upstream >> drm/imagination driver is expected to support the BXM-4-64 as well [4][5]. As >> this support is being developed, it's crucial to upstream the necessary glue >> code including clock and power-domain drivers so they're ready for integration >> with the drm/imagination driver. >> > > This is v5 of big patchset which became huge. I understand you did like > that for v1 which was RFC. But it stopped being RFC. > > Split your patchset, keeping versioning and changelog, per subsystem. Sorry for the late reply—I didn't have access to email. I agree with your suggestion and will send the clock changes, firmware/power domain, reset, and drm/imagination updates as separate patchsets for merging. > > Best regards, > Krzysztof > > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A 2025-03-03 8:38 ` Michal Wilczynski @ 2025-03-03 17:43 ` Krzysztof Kozlowski 2025-03-04 7:38 ` Michal Wilczynski 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-03-03 17:43 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 03/03/2025 09:38, Michal Wilczynski wrote: > > > On 2/21/25 10:12, Krzysztof Kozlowski wrote: >> On Wed, Feb 19, 2025 at 03:02:18PM +0100, Michal Wilczynski wrote: >>> The LicheePi 4A board, featuring the T-HEAD TH1520 SoC, includes an Imagination >>> Technologies BXM-4-64 GPU. Initial support for this GPU was provided through a >>> downstream driver [1]. Recently, efforts have been made to upstream support for >>> the Rogue family GPUs, which the BXM-4-64 is part of [2]. >>> >>> While the initial upstream driver focused on the AXE-1-16 GPU, newer patches >>> have introduced support for the BXS-4-64 GPU [3]. The modern upstream >>> drm/imagination driver is expected to support the BXM-4-64 as well [4][5]. As >>> this support is being developed, it's crucial to upstream the necessary glue >>> code including clock and power-domain drivers so they're ready for integration >>> with the drm/imagination driver. >>> >> >> This is v5 of big patchset which became huge. I understand you did like >> that for v1 which was RFC. But it stopped being RFC. >> >> Split your patchset, keeping versioning and changelog, per subsystem. > > Sorry for the late reply—I didn't have access to email. I agree with > your suggestion and will send the clock changes, firmware/power domain, > reset, and drm/imagination updates as separate patchsets for merging. How did you implement above comment? You did the split, right? Where is versioning and where are changelogs? Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A 2025-03-03 17:43 ` Krzysztof Kozlowski @ 2025-03-04 7:38 ` Michal Wilczynski 2025-03-04 7:44 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Michal Wilczynski @ 2025-03-04 7:38 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 3/3/25 18:43, Krzysztof Kozlowski wrote: > On 03/03/2025 09:38, Michal Wilczynski wrote: >> >> >> On 2/21/25 10:12, Krzysztof Kozlowski wrote: >>> On Wed, Feb 19, 2025 at 03:02:18PM +0100, Michal Wilczynski wrote: >>>> The LicheePi 4A board, featuring the T-HEAD TH1520 SoC, includes an Imagination >>>> Technologies BXM-4-64 GPU. Initial support for this GPU was provided through a >>>> downstream driver [1]. Recently, efforts have been made to upstream support for >>>> the Rogue family GPUs, which the BXM-4-64 is part of [2]. >>>> >>>> While the initial upstream driver focused on the AXE-1-16 GPU, newer patches >>>> have introduced support for the BXS-4-64 GPU [3]. The modern upstream >>>> drm/imagination driver is expected to support the BXM-4-64 as well [4][5]. As >>>> this support is being developed, it's crucial to upstream the necessary glue >>>> code including clock and power-domain drivers so they're ready for integration >>>> with the drm/imagination driver. >>>> >>> >>> This is v5 of big patchset which became huge. I understand you did like >>> that for v1 which was RFC. But it stopped being RFC. >>> >>> Split your patchset, keeping versioning and changelog, per subsystem. >> >> Sorry for the late reply—I didn't have access to email. I agree with >> your suggestion and will send the clock changes, firmware/power domain, >> reset, and drm/imagination updates as separate patchsets for merging. > > > How did you implement above comment? You did the split, right? Where is > versioning and where are changelogs? So I thought the sub-series should be versioned independently from v1 ? Then linked the previous discussions in the cover letter, without copying them. > > > Best regards, > Krzysztof > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A 2025-03-04 7:38 ` Michal Wilczynski @ 2025-03-04 7:44 ` Krzysztof Kozlowski 0 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-03-04 7:44 UTC (permalink / raw) To: Michal Wilczynski Cc: mturquette, sboyd, robh, krzk+dt, conor+dt, drew, guoren, wefu, jassisinghbrar, paul.walmsley, palmer, aou, frank.binns, matt.coster, maarten.lankhorst, mripard, tzimmermann, airlied, simona, ulf.hansson, jszhang, p.zabel, m.szyprowski, linux-clk, devicetree, linux-kernel, linux-riscv, dri-devel, linux-pm On 04/03/2025 08:38, Michal Wilczynski wrote: > > > On 3/3/25 18:43, Krzysztof Kozlowski wrote: >> On 03/03/2025 09:38, Michal Wilczynski wrote: >>> >>> >>> On 2/21/25 10:12, Krzysztof Kozlowski wrote: >>>> On Wed, Feb 19, 2025 at 03:02:18PM +0100, Michal Wilczynski wrote: >>>>> The LicheePi 4A board, featuring the T-HEAD TH1520 SoC, includes an Imagination >>>>> Technologies BXM-4-64 GPU. Initial support for this GPU was provided through a >>>>> downstream driver [1]. Recently, efforts have been made to upstream support for >>>>> the Rogue family GPUs, which the BXM-4-64 is part of [2]. >>>>> >>>>> While the initial upstream driver focused on the AXE-1-16 GPU, newer patches >>>>> have introduced support for the BXS-4-64 GPU [3]. The modern upstream >>>>> drm/imagination driver is expected to support the BXM-4-64 as well [4][5]. As >>>>> this support is being developed, it's crucial to upstream the necessary glue >>>>> code including clock and power-domain drivers so they're ready for integration >>>>> with the drm/imagination driver. >>>>> >>>> >>>> This is v5 of big patchset which became huge. I understand you did like >>>> that for v1 which was RFC. But it stopped being RFC. >>>> >>>> Split your patchset, keeping versioning and changelog, per subsystem. >>> >>> Sorry for the late reply—I didn't have access to email. I agree with >>> your suggestion and will send the clock changes, firmware/power domain, >>> reset, and drm/imagination updates as separate patchsets for merging. >> >> >> How did you implement above comment? You did the split, right? Where is >> versioning and where are changelogs? > > So I thought the sub-series should be versioned independently from v1 ? Keep the versioning. Keep the changelog. You now versioned your new set independently, so I don't understand your question. > Then linked the previous discussions in the cover letter, without > copying them. Nothing said this is the same patchset. You just mentioned some "bigger series" cover letter. How some other bigger series is anyhow related? And how can I find relevant pieces there? You are supposed to make it easy for reviewers, not difficult. Best regards, Krzysztof _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2025-04-25 19:16 UTC | newest] Thread overview: 43+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CGME20250219140249eucas1p1291eb86c932373c847a3314ae54789d5@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A Michal Wilczynski [not found] ` <CGME20250219140250eucas1p2e099f0f15ce0342f816ae15666e3e2f9@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 01/21] dt-bindings: clock: thead: Add TH1520 VO clock controller Michal Wilczynski [not found] ` <CGME20250219140252eucas1p10c718f8e337ab3bf35f4debc56f13f86@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 02/21] clk: thead: Add clock support for VO subsystem in T-Head TH1520 SoC Michal Wilczynski [not found] ` <CGME20250219140253eucas1p2a137df988b89e84b7e52c45521b5bb06@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 03/21] dt-bindings: firmware: thead,th1520: Add support for firmware node Michal Wilczynski [not found] ` <CGME20250219140254eucas1p23528e98a5279252a1acdd97d0162c26a@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 04/21] firmware: thead: Add AON firmware protocol driver Michal Wilczynski [not found] ` <CGME20250219140256eucas1p13aa7f19867f88185739552f116ef0fc1@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 05/21] dt-bindings: power: Add TH1520 SoC power domains Michal Wilczynski [not found] ` <CGME20250219140257eucas1p1cc06395993336a6244f6ae0ce2923d71@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 06/21] pmdomain: thead: Add power-domain driver for TH1520 Michal Wilczynski [not found] ` <CGME20250219140259eucas1p114dbcacffe3b479d15cd800c7efbede2@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 07/21] riscv: Enable PM_GENERIC_DOMAINS for T-Head SoCs Michal Wilczynski [not found] ` <CGME20250219140300eucas1p2d776e747555020fd868cf04e55cd70e1@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 08/21] clk: thead: Add support for custom ops in CCU_GATE_CLK_OPS macro Michal Wilczynski [not found] ` <CGME20250219140301eucas1p249b17ca44832eb8caad2e9ad0e4f8639@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 09/21] dt-bindings: clock: thead: Add GPU clkgen reset property Michal Wilczynski 2025-02-21 9:11 ` Krzysztof Kozlowski 2025-03-03 8:42 ` Michal Wilczynski 2025-03-03 8:52 ` Krzysztof Kozlowski 2025-03-03 9:55 ` Michal Wilczynski 2025-03-03 14:07 ` Krzysztof Kozlowski [not found] ` <CGME20250219140302eucas1p24d9900e424b31661217e3c9182105b3a@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 10/21] clk: thead: Add GPU clock gate control with CLKGEN reset support Michal Wilczynski [not found] ` <CGME20250219140304eucas1p21c5e28e2497bb4046f8f2a26b4f47299@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 11/21] dt-bindings: reset: Add T-HEAD TH1520 SoC Reset Controller Michal Wilczynski [not found] ` <CGME20250219140305eucas1p26317b54727c68cf069458d270e06d962@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 12/21] reset: thead: Add TH1520 reset controller driver Michal Wilczynski 2025-02-19 15:01 ` Philipp Zabel 2025-02-20 11:59 ` Michal Wilczynski [not found] ` <CGME20250219140306eucas1p19ba425ddb1e499ef1014b1665be9de8e@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 13/21] drm/imagination: Add reset controller support for GPU initialization Michal Wilczynski 2025-04-16 14:25 ` Michal Wilczynski 2025-04-16 16:53 ` Matt Coster [not found] ` <CGME20250219140309eucas1p2701a4b4bacd3be6e9f20d637d3cefa5c@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 14/21] dt-bindings: gpu: Add 'resets' property " Michal Wilczynski [not found] ` <CGME20250219140310eucas1p1297441a3da276569cd86b6b9e4544242@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 15/21] dt-bindings: gpu: Add support for T-HEAD TH1520 GPU Michal Wilczynski 2025-02-21 9:16 ` Krzysztof Kozlowski [not found] ` <CGME20250219140311eucas1p24ef4a7a95abdb527c2bd305f3ed51674@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 16/21] drm/imagination: Add support for IMG BXM-4-64 GPU Michal Wilczynski [not found] ` <CGME20250219140313eucas1p211517932c3cd45ca8c843840ccd42c1e@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 17/21] drm/imagination: Enable PowerVR driver for RISC-V Michal Wilczynski [not found] ` <CGME20250219140314eucas1p146c73e1fdb8b56315672742f8de8c131@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 18/21] riscv: dts: thead: Add device tree VO clock controller Michal Wilczynski [not found] ` <CGME20250219140315eucas1p10f08d297580edd114f4c487c1fbffa8d@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 19/21] riscv: dts: thead: Introduce power domain nodes with aon firmware Michal Wilczynski 2025-04-15 2:04 ` Drew Fustini 2025-04-15 18:48 ` Drew Fustini 2025-04-16 11:22 ` Michal Wilczynski [not found] ` <CGME20250219140316eucas1p29a76023868946f090f261bf78d5103e3@eucas1p2.samsung.com> 2025-02-19 14:02 ` [PATCH v5 20/21] riscv: dts: thead: Introduce reset controller node Michal Wilczynski 2025-04-19 19:09 ` Drew Fustini 2025-04-22 7:47 ` Michal Wilczynski 2025-04-25 19:16 ` Drew Fustini [not found] ` <CGME20250219140318eucas1p1db0d55468b1958f9d41963cb789e4f29@eucas1p1.samsung.com> 2025-02-19 14:02 ` [PATCH v5 21/21] riscv: dts: thead: Add GPU node to TH1520 device tree Michal Wilczynski 2025-02-21 9:12 ` [PATCH v5 00/21] Enable drm/imagination BXM-4-64 Support for LicheePi 4A Krzysztof Kozlowski 2025-03-03 8:38 ` Michal Wilczynski 2025-03-03 17:43 ` Krzysztof Kozlowski 2025-03-04 7:38 ` Michal Wilczynski 2025-03-04 7:44 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).