// SPDX-License-Identifier: GPL-2.0 or MIT /* Copyright 2018 Marty E. Plummer <[email protected]> */ /* Copyright 2019 Linaro, Ltd., Rob Herring <[email protected]> */ /* Copyright 2019 Collabora ltd. */ #include <linux/bitfield.h> #include <linux/bitmap.h> #include <linux/delay.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/iopoll.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <drm/drm_drv.h> #include <drm/drm_managed.h> #include "panthor_device.h" #include "panthor_gpu.h" #include "panthor_regs.h" /** * struct panthor_gpu - GPU block management data. */ struct panthor_gpu { … }; /** * struct panthor_model - GPU model description */ struct panthor_model { … }; /** * GPU_MODEL() - Define a GPU model. A GPU product can be uniquely identified * by a combination of the major architecture version and the major product * version. * @_name: Name for the GPU model. * @_arch_major: Architecture major. * @_product_major: Product major. */ #define GPU_MODEL(_name, _arch_major, _product_major) … static const struct panthor_model gpu_models[] = …; #define GPU_INTERRUPTS_MASK … static void panthor_gpu_init_info(struct panthor_device *ptdev) { … } static void panthor_gpu_irq_handler(struct panthor_device *ptdev, u32 status) { … } PANTHOR_IRQ_HANDLER(gpu, GPU, panthor_gpu_irq_handler); /** * panthor_gpu_unplug() - Called when the GPU is unplugged. * @ptdev: Device to unplug. */ void panthor_gpu_unplug(struct panthor_device *ptdev) { … } /** * panthor_gpu_init() - Initialize the GPU block * @ptdev: Device. * * Return: 0 on success, a negative error code otherwise. */ int panthor_gpu_init(struct panthor_device *ptdev) { … } /** * panthor_gpu_block_power_off() - Power-off a specific block of the GPU * @ptdev: Device. * @blk_name: Block name. * @pwroff_reg: Power-off register for this block. * @pwrtrans_reg: Power transition register for this block. * @mask: Sub-elements to power-off. * @timeout_us: Timeout in microseconds. * * Return: 0 on success, a negative error code otherwise. */ int panthor_gpu_block_power_off(struct panthor_device *ptdev, const char *blk_name, u32 pwroff_reg, u32 pwrtrans_reg, u64 mask, u32 timeout_us) { … } /** * panthor_gpu_block_power_on() - Power-on a specific block of the GPU * @ptdev: Device. * @blk_name: Block name. * @pwron_reg: Power-on register for this block. * @pwrtrans_reg: Power transition register for this block. * @rdy_reg: Power transition ready register. * @mask: Sub-elements to power-on. * @timeout_us: Timeout in microseconds. * * Return: 0 on success, a negative error code otherwise. */ int panthor_gpu_block_power_on(struct panthor_device *ptdev, const char *blk_name, u32 pwron_reg, u32 pwrtrans_reg, u32 rdy_reg, u64 mask, u32 timeout_us) { … } /** * panthor_gpu_l2_power_on() - Power-on the L2-cache * @ptdev: Device. * * Return: 0 on success, a negative error code otherwise. */ int panthor_gpu_l2_power_on(struct panthor_device *ptdev) { … } /** * panthor_gpu_flush_caches() - Flush caches * @ptdev: Device. * @l2: L2 flush type. * @lsc: LSC flush type. * @other: Other flush type. * * Return: 0 on success, a negative error code otherwise. */ int panthor_gpu_flush_caches(struct panthor_device *ptdev, u32 l2, u32 lsc, u32 other) { … } /** * panthor_gpu_soft_reset() - Issue a soft-reset * @ptdev: Device. * * Return: 0 on success, a negative error code otherwise. */ int panthor_gpu_soft_reset(struct panthor_device *ptdev) { … } /** * panthor_gpu_suspend() - Suspend the GPU block. * @ptdev: Device. * * Suspend the GPU irq. This should be called last in the suspend procedure, * after all other blocks have been suspented. */ void panthor_gpu_suspend(struct panthor_device *ptdev) { … } /** * panthor_gpu_resume() - Resume the GPU block. * @ptdev: Device. * * Resume the IRQ handler and power-on the L2-cache. * The FW takes care of powering the other blocks. */ void panthor_gpu_resume(struct panthor_device *ptdev) { … }