On some platforms like Allwinner A133 with GE8300 includes reset control from reset control unit. Add reset control optionally from the devicetree. Signed-off-by: Parthiban Nallathambi <parthiban@xxxxxxxxxxx> --- drivers/gpu/drm/imagination/pvr_device.h | 8 ++++++++ drivers/gpu/drm/imagination/pvr_drv.c | 5 +++++ drivers/gpu/drm/imagination/pvr_power.c | 16 +++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/imagination/pvr_device.h index 6d0dfacb677b..21ec7dd64415 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -23,6 +23,7 @@ #include <linux/kernel.h> #include <linux/math.h> #include <linux/mutex.h> +#include <linux/reset.h> #include <linux/spinlock_types.h> #include <linux/timer.h> #include <linux/types.h> @@ -131,6 +132,13 @@ struct pvr_device { */ struct clk *mem_clk; + /** + * @reset: Optional reset control + * + * This may be used on some platforms to reset the GPU module/IP. + */ + struct reset_control *reset; + /** @irq: IRQ number. */ int irq; diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c index fb17196e05f4..d9b918410ea9 100644 --- a/drivers/gpu/drm/imagination/pvr_drv.c +++ b/drivers/gpu/drm/imagination/pvr_drv.c @@ -36,6 +36,7 @@ #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/xarray.h> /** @@ -1427,6 +1428,10 @@ pvr_probe(struct platform_device *plat_dev) pm_runtime_use_autosuspend(&plat_dev->dev); pvr_watchdog_init(pvr_dev); + pvr_dev->reset = devm_reset_control_get_optional_exclusive(&plat_dev->dev, "ahb"); + if (PTR_ERR(pvr_dev->reset) == -EPROBE_DEFER) + return PTR_ERR(pvr_dev->reset); + err = pvr_device_init(pvr_dev); if (err) goto err_watchdog_fini; diff --git a/drivers/gpu/drm/imagination/pvr_power.c b/drivers/gpu/drm/imagination/pvr_power.c index ba7816fd28ec..a24ed85f36c7 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,9 @@ pvr_power_device_suspend(struct device *dev) clk_disable_unprepare(pvr_dev->sys_clk); clk_disable_unprepare(pvr_dev->core_clk); + if (!IS_ERR(pvr_dev->reset)) + reset_control_assert(pvr_dev->reset); + err_drm_dev_exit: drm_dev_exit(idx); @@ -270,9 +274,15 @@ pvr_power_device_resume(struct device *dev) if (!drm_dev_enter(drm_dev, &idx)) return -EIO; + if (!IS_ERR(pvr_dev->reset)) { + err = reset_control_reset(pvr_dev->reset); + if (err) + goto err_drm_dev_exit; + } + err = clk_prepare_enable(pvr_dev->core_clk); if (err) - goto err_drm_dev_exit; + goto err_reset_exit; err = clk_prepare_enable(pvr_dev->sys_clk); if (err) @@ -301,6 +311,10 @@ pvr_power_device_resume(struct device *dev) err_core_clk_disable: clk_disable_unprepare(pvr_dev->core_clk); +err_reset_exit: + if (!IS_ERR(pvr_dev->reset)) + reset_control_assert(pvr_dev->reset); + err_drm_dev_exit: drm_dev_exit(idx); -- 2.39.2