From 0a6fb5c3c956c14a2dee232154d7d02f5cca01a2 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Wed, 1 Feb 2017 10:48:55 +0200 Subject: [PATCH] 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 Signed-off-by: Laxman Dewangan Reviewed-on: http://git-master/r/1297136 (cherry picked from commit 5438b348e036c31dcf9db0d1364fa6c6ac053428) --- drivers/misc/tegra-cec/tegra_cec.c | 33 +++++++++++++++++++++--------- drivers/misc/tegra-cec/tegra_cec.h | 3 +++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/misc/tegra-cec/tegra_cec.c b/drivers/misc/tegra-cec/tegra_cec.c index a2e5cb7b..79f1268f 100644 --- a/drivers/misc/tegra-cec/tegra_cec.c +++ b/drivers/misc/tegra-cec/tegra_cec.c @@ -31,17 +31,22 @@ #include #include #include +#include #include #include #include #include +#include #include "tegra_cec.h" -#include #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, 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) return -ENOMEM; + cec->soc = of_device_get_match_data(&pdev->dev); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -474,7 +481,7 @@ static int tegra_cec_probe(struct platform_device *pdev) mutex_init(&cec->tx_lock); #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) { dev_err(&pdev->dev, "Fail to unpowergate DISP: %d.\n", ret); goto clk_error; @@ -564,7 +571,7 @@ cec_error: clk_disable(cec->clk); clk_put(cec->clk); #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 clk_error: return ret; @@ -577,7 +584,7 @@ static int tegra_cec_remove(struct platform_device *pdev) clk_disable(cec->clk); clk_put(cec->clk); #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 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); #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 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"); #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 clk_enable(cec->clk); schedule_work(&cec->work); @@ -627,11 +634,17 @@ static int tegra_cec_resume(struct platform_device *pdev) } #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[] = { - { .compatible = "nvidia,tegra114-cec", }, - { .compatible = "nvidia,tegra124-cec", }, - { .compatible = "nvidia,tegra210-cec", }, - { .compatible = "nvidia,tegra186-cec", }, + { .compatible = "nvidia,tegra210-cec", .data = &tegra210_soc_data }, + { .compatible = "nvidia,tegra186-cec", .data = &tegra186_soc_data }, {}, }; diff --git a/drivers/misc/tegra-cec/tegra_cec.h b/drivers/misc/tegra-cec/tegra_cec.h index 12913a25..3f06a81f 100644 --- a/drivers/misc/tegra-cec/tegra_cec.h +++ b/drivers/misc/tegra-cec/tegra_cec.h @@ -24,6 +24,8 @@ #define TEGRA_CEC_FRAME_MAX_LENGTH 16 +struct tegra_cec_soc; + struct tegra_cec { struct device *dev; struct miscdevice misc_dev; @@ -41,6 +43,7 @@ struct tegra_cec { #endif u16 logical_addr; struct work_struct work; + const struct tegra_cec_soc *soc; unsigned int rx_wake; unsigned int tx_wake; u16 rx_buffer;