From patchwork Tue Jan 28 19:47:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 860546 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF9471DC99A for ; Tue, 28 Jan 2025 19:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738093712; cv=none; b=u1oKW7XBOvxjZ2c3BUwPQEskaVeKgfZGrMxQpxcK4vmiGEtiypTGidKiglnmN/rMYCgZznzOAQ+6JcFhbyYTMBu/XLRwE9k/yhQkFG5eGtjpHf/xdz1T8xcU9ZnY9M8a7NfyjN27gXyk5J+YjfQJo07/TEtY8IUu6x1dktsx34I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738093712; c=relaxed/simple; bh=2Dg64NTSmju9eWMPAB9dv8s5fVHDVopRGyJlLHfMPBM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: References; b=I5eS2XrPsn7oMQpeUO8duJoHrM13ovSAK1RlU+jJpAlb2knLXM2U9upopJJYtb/jiFG1e2LtG4bC2v3X2d801Ya92mvANNZa9c6flEIz+ESsPTl50uRNs3/dPvoJNBNvm7uNzGIrKs6aSrD1xFnByppwp7yFYxDWl3Ey40QY6BY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=LT4fN1iv; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="LT4fN1iv" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20250128194826euoutp01e057bfb7fce4b542043e6e08a7377a13~e8wRxzpzd1604516045euoutp01G for ; Tue, 28 Jan 2025 19:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20250128194826euoutp01e057bfb7fce4b542043e6e08a7377a13~e8wRxzpzd1604516045euoutp01G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1738093706; bh=s/hyfsEwpR29IPjuiFCyTz5t3HRX/rxTk0xz9W711jk=; h=From:To:Cc:Subject:Date:References:From; b=LT4fN1ivovINeh9u7I22ZxtIHqoa6JOibGx1wn43pQXIAWVoOuc3bviaCtIbbHo4o tAEFT2loVPIqJR5lrX1ex5M3Pke7ZlDDo0ljnihvIsYMrUruSiDGHGGnJakAK8qHeb X6QI+jSSczclr6XiyV3bHqb7iaupKFU5df9IHQV0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20250128194825eucas1p119cdd8e992c752e8f845f5f7bc07aed2~e8wRBT5yF1601016010eucas1p1p; Tue, 28 Jan 2025 19:48:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 12.A2.20397.98439976; Tue, 28 Jan 2025 19:48:25 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20250128194825eucas1p14e2cb0a85c397dea297e9c4177cf1585~e8wQTzaUd1601016010eucas1p1o; Tue, 28 Jan 2025 19:48:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20250128194825eusmtrp2296fffeca071a7830da2a0579f3f404e~e8wQSJcPh3008430084eusmtrp2S; Tue, 28 Jan 2025 19:48:25 +0000 (GMT) X-AuditID: cbfec7f5-ed1d670000004fad-c5-679934896cfd Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DD.D0.19920.88439976; Tue, 28 Jan 2025 19:48:24 +0000 (GMT) Received: from AMDC4942.home (unknown [106.210.136.40]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250128194823eusmtip13617432e5af4c1ed0ace393230a7687b~e8wO8qR6a0291602916eusmtip1X; Tue, 28 Jan 2025 19:48:23 +0000 (GMT) From: Michal Wilczynski To: mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, drew@pdp7.com, guoren@kernel.org, wefu@redhat.com, jassisinghbrar@gmail.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, frank.binns@imgtec.com, matt.coster@imgtec.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, ulf.hansson@linaro.org, jszhang@kernel.org, p.zabel@pengutronix.de, m.szyprowski@samsung.com Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-pm@vger.kernel.org, Michal Wilczynski Subject: [PATCH v4 00/18] Enable drm/imagination BXM-4-64 Support for LicheePi 4A Date: Tue, 28 Jan 2025 20:47:58 +0100 Message-Id: <20250128194816.2185326-1-m.wilczynski@samsung.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker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VE5ml RJPzgaktryTe0MzA1NDEzNLA1NLMWEmc1+3y+TQhgfTEktTs1NSC1CKYPiYOTqkGpo3WN2ac e8g1fU1CeTeDm8fsvek82yJWLD7wS9A5pJShdPYxNukZwozfjt+tbGty/frQ+a9n0/XQkj8P +Vad/NTlWfFx3+072etqvaJZJ4TuDWn9v/b2ufPH/HZ5PDzbzrKA8XeM2j1FQS4rjj1Pf23a ue1rm5fql6K1Ua8sA0vk9i0T4lzZpRG+9lrOpOga9v1Lmnbx/DrxxkimVCRkev1Uj0sX5mz5 LML2wMfMWTIz0G9ic8DnKG2Z+9PNfnJsybBQy5m82vLhkpDs7X7bJ+ZPr3K6PfHOlAlXXIVD 9821uGsjIv9z0Z8pnt9OeRo/aXlt3rH439l+keeKql1/zswJSEoPVUyYqbhHX651zk4lluKM REMt5qLiRAAZmCYCtQMAAA== X-CMS-MailID: 20250128194825eucas1p14e2cb0a85c397dea297e9c4177cf1585 X-Msg-Generator: CA X-RootMTR: 20250128194825eucas1p14e2cb0a85c397dea297e9c4177cf1585 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20250128194825eucas1p14e2cb0a85c397dea297e9c4177cf1585 References: 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. Since this patchset is slowly getting closer to being ready I'm dropping the RFC prefix with the v4. 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 (18): 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 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 | 17 +- .../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 | 34 +++ drivers/clk/thead/clk-th1520-ap.c | 197 +++++++++++-- drivers/firmware/Kconfig | 9 + drivers/firmware/Makefile | 1 + drivers/firmware/thead,th1520-aon.c | 268 ++++++++++++++++++ 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 | 1 + drivers/gpu/drm/imagination/pvr_power.c | 12 +- 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 | 193 +++++++++++++ drivers/reset/Kconfig | 10 + drivers/reset/Makefile | 1 + drivers/reset/reset-th1520.c | 178 ++++++++++++ .../dt-bindings/clock/thead,th1520-clk-ap.h | 33 +++ .../dt-bindings/power/thead,th1520-power.h | 19 ++ .../dt-bindings/reset/thead,th1520-reset.h | 15 + .../linux/firmware/thead/thead,th1520-aon.h | 197 +++++++++++++ 28 files changed, 1344 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 Reviewed-by: Krzysztof Kozlowski Reviewed-by: Krzysztof Kozlowski