forked from Minki/linux
5800571960
-----BEGIN PGP SIGNATURE----- iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAlz8fAYeHHRvcnZhbGRz QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiG1asH/3ySguxqtqL1MCBa 4/SZ37PHeWKMerfX6ZyJdgEqK3B+PWlmuLiOMNK5h2bPLzeQQQAmHU/mfKmpXqgB dHwUbG9yNnyUtTfsfRqAnCA6vpuw9Yb1oIzTCVQrgJLSWD0j7scBBvmzYqguOkto ThwigLUq3AILr8EfR4rh+GM+5Dn9OTEFAxwil9fPHQo7QoczwZxpURhScT6Co9TB DqLA3fvXbBvLs/CZy/S5vKM9hKzC+p39ApFTURvFPrelUVnythAM0dPDJg3pIn5u g+/+gDxDFa+7ANxvxO2ng1sJPDqJMeY/xmjJYlYyLpA33B7zLNk2vDHhAP06VTtr XCMhQ9s= =cb80 -----END PGP SIGNATURE----- Merge tag 'v5.2-rc4' into media/master There are some conflicts due to SPDX changes. We also have more patches being merged via media tree touching them. So, let's merge back from upstream and address those. Linux 5.2-rc4 * tag 'v5.2-rc4': (767 commits) Linux 5.2-rc4 MAINTAINERS: Karthikeyan Ramasubramanian is MIA i2c: xiic: Add max_read_len quirk lockref: Limit number of cmpxchg loop retries uaccess: add noop untagged_addr definition x86/insn-eval: Fix use-after-free access to LDT entry kbuild: use more portable 'command -v' for cc-cross-prefix s390/unwind: correct stack switching during unwind block, bfq: add weight symlink to the bfq.weight cgroup parameter cgroup: let a symlink too be created with a cftype file drm/nouveau/secboot/gp10[2467]: support newer FW to fix SEC2 failures on some boards drm/nouveau/secboot: enable loading of versioned LS PMU/SEC2 ACR msgqueue FW drm/nouveau/secboot: split out FW version-specific LS function pointers drm/nouveau/secboot: pass max supported FW version to LS load funcs drm/nouveau/core: support versioned firmware loading drm/nouveau/core: pass subdev into nvkm_firmware_get, rather than device block: free sched's request pool in blk_cleanup_queue pktgen: do not sleep with the thread lock held. net: mvpp2: Use strscpy to handle stat strings net: rds: fix memory leak in rds_ib_flush_mr_pool ... Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
148 lines
3.4 KiB
C
148 lines
3.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2016 MediaTek Inc.
|
|
* Author: Tiffany Lin <tiffany.lin@mediatek.com>
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <soc/mediatek/smi.h>
|
|
|
|
#include "mtk_vcodec_enc_pm.h"
|
|
#include "mtk_vcodec_util.h"
|
|
#include "mtk_vpu.h"
|
|
|
|
|
|
int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
|
|
{
|
|
struct device_node *node;
|
|
struct platform_device *pdev;
|
|
struct mtk_vcodec_pm *pm;
|
|
struct mtk_vcodec_clk *enc_clk;
|
|
struct mtk_vcodec_clk_info *clk_info;
|
|
int ret = 0, i = 0;
|
|
struct device *dev;
|
|
|
|
pdev = mtkdev->plat_dev;
|
|
pm = &mtkdev->pm;
|
|
memset(pm, 0, sizeof(struct mtk_vcodec_pm));
|
|
pm->mtkdev = mtkdev;
|
|
pm->dev = &pdev->dev;
|
|
dev = &pdev->dev;
|
|
enc_clk = &pm->venc_clk;
|
|
|
|
node = of_parse_phandle(dev->of_node, "mediatek,larb", 0);
|
|
if (!node) {
|
|
mtk_v4l2_err("no mediatek,larb found");
|
|
return -ENODEV;
|
|
}
|
|
pdev = of_find_device_by_node(node);
|
|
of_node_put(node);
|
|
if (!pdev) {
|
|
mtk_v4l2_err("no mediatek,larb device found");
|
|
return -ENODEV;
|
|
}
|
|
pm->larbvenc = &pdev->dev;
|
|
|
|
node = of_parse_phandle(dev->of_node, "mediatek,larb", 1);
|
|
if (!node) {
|
|
mtk_v4l2_err("no mediatek,larb found");
|
|
return -ENODEV;
|
|
}
|
|
|
|
pdev = of_find_device_by_node(node);
|
|
of_node_put(node);
|
|
if (!pdev) {
|
|
mtk_v4l2_err("no mediatek,larb device found");
|
|
return -ENODEV;
|
|
}
|
|
|
|
pm->larbvenclt = &pdev->dev;
|
|
pdev = mtkdev->plat_dev;
|
|
pm->dev = &pdev->dev;
|
|
|
|
enc_clk->clk_num = of_property_count_strings(pdev->dev.of_node,
|
|
"clock-names");
|
|
if (enc_clk->clk_num > 0) {
|
|
enc_clk->clk_info = devm_kcalloc(&pdev->dev,
|
|
enc_clk->clk_num, sizeof(*clk_info),
|
|
GFP_KERNEL);
|
|
if (!enc_clk->clk_info)
|
|
return -ENOMEM;
|
|
} else {
|
|
mtk_v4l2_err("Failed to get venc clock count");
|
|
return -EINVAL;
|
|
}
|
|
|
|
for (i = 0; i < enc_clk->clk_num; i++) {
|
|
clk_info = &enc_clk->clk_info[i];
|
|
ret = of_property_read_string_index(pdev->dev.of_node,
|
|
"clock-names", i, &clk_info->clk_name);
|
|
if (ret) {
|
|
mtk_v4l2_err("venc failed to get clk name %d", i);
|
|
return ret;
|
|
}
|
|
clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
|
|
clk_info->clk_name);
|
|
if (IS_ERR(clk_info->vcodec_clk)) {
|
|
mtk_v4l2_err("venc devm_clk_get (%d)%s fail", i,
|
|
clk_info->clk_name);
|
|
return PTR_ERR(clk_info->vcodec_clk);
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void mtk_vcodec_release_enc_pm(struct mtk_vcodec_dev *mtkdev)
|
|
{
|
|
}
|
|
|
|
|
|
void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
|
|
{
|
|
struct mtk_vcodec_clk *enc_clk = &pm->venc_clk;
|
|
int ret, i = 0;
|
|
|
|
for (i = 0; i < enc_clk->clk_num; i++) {
|
|
ret = clk_prepare_enable(enc_clk->clk_info[i].vcodec_clk);
|
|
if (ret) {
|
|
mtk_v4l2_err("venc clk_prepare_enable %d %s fail %d", i,
|
|
enc_clk->clk_info[i].clk_name, ret);
|
|
goto clkerr;
|
|
}
|
|
}
|
|
|
|
ret = mtk_smi_larb_get(pm->larbvenc);
|
|
if (ret) {
|
|
mtk_v4l2_err("mtk_smi_larb_get larb3 fail %d", ret);
|
|
goto larbvencerr;
|
|
}
|
|
ret = mtk_smi_larb_get(pm->larbvenclt);
|
|
if (ret) {
|
|
mtk_v4l2_err("mtk_smi_larb_get larb4 fail %d", ret);
|
|
goto larbvenclterr;
|
|
}
|
|
return;
|
|
|
|
larbvenclterr:
|
|
mtk_smi_larb_put(pm->larbvenc);
|
|
larbvencerr:
|
|
clkerr:
|
|
for (i -= 1; i >= 0; i--)
|
|
clk_disable_unprepare(enc_clk->clk_info[i].vcodec_clk);
|
|
}
|
|
|
|
void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm)
|
|
{
|
|
struct mtk_vcodec_clk *enc_clk = &pm->venc_clk;
|
|
int i = 0;
|
|
|
|
mtk_smi_larb_put(pm->larbvenc);
|
|
mtk_smi_larb_put(pm->larbvenclt);
|
|
for (i = enc_clk->clk_num - 1; i >= 0; i--)
|
|
clk_disable_unprepare(enc_clk->clk_info[i].vcodec_clk);
|
|
}
|