vi5: follow RPM framework for suspend and resume

When poweron and poweroff the device, runtime reusme and suspend
callbacks should be called respectively so that the device can prepare
and teardown the runtime environment properly. For example, requesting
proper ICC memory bandwidth requests in resume and suspend cycles.

Bug 4199055

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: I67a77c58b3c05f67caf1fe83bcc0edd1da376768
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2979911
Reviewed-by: Anubhav Rai <arai@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Johnny Liu
2023-09-13 14:27:21 +00:00
committed by mobile promotions
parent 8748d6e9fd
commit 9fa11c36c1

View File

@@ -5,23 +5,25 @@
* Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/ */
#include <linux/syscalls.h> #include <linux/errno.h>
#include <linux/fs.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/fs.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/nvhost.h> #include <linux/nvhost.h>
#include <linux/errno.h> #include <linux/pm_runtime.h>
#include <linux/semaphore.h> #include <linux/semaphore.h>
#include <media/tegra_camera_platform.h> #include <linux/syscalls.h>
#include <media/mc_common.h>
#include <media/tegra-v4l2-camera.h>
#include <media/fusa-capture/capture-vi-channel.h> #include <media/fusa-capture/capture-vi-channel.h>
#include <media/fusa-capture/capture-vi.h> #include <media/fusa-capture/capture-vi.h>
#include <media/mc_common.h>
#include <media/tegra-v4l2-camera.h>
#include <media/tegra_camera_platform.h>
#include <soc/tegra/camrtc-capture.h> #include <soc/tegra/camrtc-capture.h>
#include "vi5_formats.h"
#include "vi5_fops.h"
#include <trace/events/camera_common.h> #include <trace/events/camera_common.h>
#include "vi5_fops.h"
#include "vi5_formats.h"
#define DEFAULT_FRAMERATE 30 #define DEFAULT_FRAMERATE 30
#define BPP_MEM 2 #define BPP_MEM 2
#define VI_CSI_CLK_SCALE 110 #define VI_CSI_CLK_SCALE 110
@@ -998,11 +1000,21 @@ void tegra_vi5_disable(struct tegra_mc_vi *vi)
static int vi5_power_on(struct tegra_channel *chan) static int vi5_power_on(struct tegra_channel *chan)
{ {
int ret = 0; int ret = 0;
struct device *dev;
struct tegra_mc_vi *vi; struct tegra_mc_vi *vi;
struct tegra_csi_device *csi; struct tegra_csi_device *csi;
vi = chan->vi; vi = chan->vi;
csi = vi->csi; csi = vi->csi;
vi5_unit_get_device_handle(vi->ndev, chan->port[0], &dev);
/* Resume VI5 to set ICC bandwidth with maximum value */
if (pm_runtime_enabled(dev)) {
ret = pm_runtime_resume_and_get(dev);
if (ret < 0) {
return ret;
}
}
ret = tegra_vi5_enable(vi); ret = tegra_vi5_enable(vi);
if (ret < 0) if (ret < 0)
@@ -1020,17 +1032,25 @@ static int vi5_power_on(struct tegra_channel *chan)
static void vi5_power_off(struct tegra_channel *chan) static void vi5_power_off(struct tegra_channel *chan)
{ {
int ret = 0; int ret = 0;
struct device *dev;
struct tegra_mc_vi *vi; struct tegra_mc_vi *vi;
struct tegra_csi_device *csi; struct tegra_csi_device *csi;
vi = chan->vi; vi = chan->vi;
csi = vi->csi; csi = vi->csi;
vi5_unit_get_device_handle(vi->ndev, chan->port[0], &dev);
ret = tegra_channel_set_power(chan, 0); ret = tegra_channel_set_power(chan, 0);
if (ret < 0) if (ret < 0)
dev_err(vi->dev, "Failed to power off subdevices\n"); dev_err(vi->dev, "Failed to power off subdevices\n");
tegra_vi5_disable(vi); tegra_vi5_disable(vi);
/* Suspend VI5 to reset ICC bandwidth request */
if (pm_runtime_enabled(dev)) {
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
}
} }
struct tegra_vi_fops vi5_fops = { struct tegra_vi_fops vi5_fops = {