misc: tegra-cec: Use per-chip powergate IDs

Powergate identifiers are different on Tegra210 and Tegra186,
so add per-SoC match data to use the correct value on each
SoC.

bug 200257351

Change-Id: I81b938386ab9cbaec735baac44ee74fccf39731c
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/1297136
(cherry picked from commit 5438b348e036c31dcf9db0d1364fa6c6ac053428)
This commit is contained in:
Mikko Perttunen
2017-02-01 10:48:55 +02:00
committed by Prafull Suryawanshi
parent 9807746899
commit 0a6fb5c3c9
2 changed files with 26 additions and 10 deletions

View File

@@ -31,17 +31,22 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/clk/tegra.h> #include <linux/clk/tegra.h>
#include <linux/of.h> #include <linux/of.h>
#include <soc/tegra/tegra_powergate.h>
#include "tegra_cec.h" #include "tegra_cec.h"
#include <linux/tegra-powergate.h>
#include "../../../../display/drivers/video/tegra/dc/dc_priv.h" #include "../../../../display/drivers/video/tegra/dc/dc_priv.h"
struct tegra_cec_soc {
int powergate_id;
};
static ssize_t cec_logical_addr_store(struct device *dev, static ssize_t cec_logical_addr_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count); struct device_attribute *attr, const char *buf, size_t count);
@@ -432,6 +437,8 @@ static int tegra_cec_probe(struct platform_device *pdev)
if (!cec) if (!cec)
return -ENOMEM; return -ENOMEM;
cec->soc = of_device_get_match_data(&pdev->dev);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
@@ -474,7 +481,7 @@ static int tegra_cec_probe(struct platform_device *pdev)
mutex_init(&cec->tx_lock); mutex_init(&cec->tx_lock);
#if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE) #if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE)
ret = tegra_nvdisp_unpowergate_partition(TEGRA_POWERGATE_DISA); ret = tegra_nvdisp_unpowergate_partition(cec->soc->powergate_id);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Fail to unpowergate DISP: %d.\n", ret); dev_err(&pdev->dev, "Fail to unpowergate DISP: %d.\n", ret);
goto clk_error; goto clk_error;
@@ -564,7 +571,7 @@ cec_error:
clk_disable(cec->clk); clk_disable(cec->clk);
clk_put(cec->clk); clk_put(cec->clk);
#if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE) #if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE)
tegra_nvdisp_powergate_partition(TEGRA_POWERGATE_DISA); tegra_nvdisp_powergate_partition(cec->soc->powergate_id);
#endif #endif
clk_error: clk_error:
return ret; return ret;
@@ -577,7 +584,7 @@ static int tegra_cec_remove(struct platform_device *pdev)
clk_disable(cec->clk); clk_disable(cec->clk);
clk_put(cec->clk); clk_put(cec->clk);
#if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE) #if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE)
tegra_nvdisp_powergate_partition(TEGRA_POWERGATE_DISA); tegra_nvdisp_powergate_partition(cec->soc->powergate_id);
#endif #endif
misc_deregister(&cec->misc_dev); misc_deregister(&cec->misc_dev);
@@ -604,7 +611,7 @@ static int tegra_cec_suspend(struct platform_device *pdev, pm_message_t state)
clk_disable(cec->clk); clk_disable(cec->clk);
#if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE) #if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE)
tegra_nvdisp_powergate_partition(TEGRA_POWERGATE_DISA); tegra_nvdisp_powergate_partition(cec->soc->powergate_id);
#endif #endif
dev_notice(&pdev->dev, "suspended\n"); dev_notice(&pdev->dev, "suspended\n");
@@ -618,7 +625,7 @@ static int tegra_cec_resume(struct platform_device *pdev)
dev_notice(&pdev->dev, "Resuming\n"); dev_notice(&pdev->dev, "Resuming\n");
#if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE) #if defined(CONFIG_TEGRA_NVDISPLAY) && defined(CONFIG_TEGRA_POWERGATE)
tegra_nvdisp_unpowergate_partition(TEGRA_POWERGATE_DISA); tegra_nvdisp_unpowergate_partition(cec->soc->powergate_id);
#endif #endif
clk_enable(cec->clk); clk_enable(cec->clk);
schedule_work(&cec->work); schedule_work(&cec->work);
@@ -627,11 +634,17 @@ static int tegra_cec_resume(struct platform_device *pdev)
} }
#endif #endif
static struct tegra_cec_soc tegra210_soc_data = {
.powergate_id = TEGRA210_POWER_DOMAIN_DISA,
};
static struct tegra_cec_soc tegra186_soc_data = {
.powergate_id = TEGRA186_POWER_DOMAIN_DISP,
};
static struct of_device_id tegra_cec_of_match[] = { static struct of_device_id tegra_cec_of_match[] = {
{ .compatible = "nvidia,tegra114-cec", }, { .compatible = "nvidia,tegra210-cec", .data = &tegra210_soc_data },
{ .compatible = "nvidia,tegra124-cec", }, { .compatible = "nvidia,tegra186-cec", .data = &tegra186_soc_data },
{ .compatible = "nvidia,tegra210-cec", },
{ .compatible = "nvidia,tegra186-cec", },
{}, {},
}; };

View File

@@ -24,6 +24,8 @@
#define TEGRA_CEC_FRAME_MAX_LENGTH 16 #define TEGRA_CEC_FRAME_MAX_LENGTH 16
struct tegra_cec_soc;
struct tegra_cec { struct tegra_cec {
struct device *dev; struct device *dev;
struct miscdevice misc_dev; struct miscdevice misc_dev;
@@ -41,6 +43,7 @@ struct tegra_cec {
#endif #endif
u16 logical_addr; u16 logical_addr;
struct work_struct work; struct work_struct work;
const struct tegra_cec_soc *soc;
unsigned int rx_wake; unsigned int rx_wake;
unsigned int tx_wake; unsigned int tx_wake;
u16 rx_buffer; u16 rx_buffer;