forked from luck/tmp_suning_uos_patched
Merge branches 'thermal-soc-misc' and 'thermal-soc-qoriq' into thermal-soc
This commit is contained in:
commit
6b221b0af7
|
@ -23,6 +23,7 @@ Required properties:
|
|||
Optional property:
|
||||
- little-endian : If present, the TMU registers are little endian. If absent,
|
||||
the default is big endian.
|
||||
- clocks : the clock for clocking the TMU silicon.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
// Copyright 2016 Freescale Semiconductor, Inc.
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/err.h>
|
||||
|
@ -72,6 +73,7 @@ struct qoriq_sensor {
|
|||
|
||||
struct qoriq_tmu_data {
|
||||
struct qoriq_tmu_regs __iomem *regs;
|
||||
struct clk *clk;
|
||||
bool little_endian;
|
||||
struct qoriq_sensor *sensor[SITES_MAX];
|
||||
};
|
||||
|
@ -202,32 +204,39 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
|
|||
|
||||
data->little_endian = of_property_read_bool(np, "little-endian");
|
||||
|
||||
data->regs = of_iomap(np, 0);
|
||||
if (!data->regs) {
|
||||
data->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(data->regs)) {
|
||||
dev_err(&pdev->dev, "Failed to get memory region\n");
|
||||
ret = -ENODEV;
|
||||
goto err_iomap;
|
||||
return PTR_ERR(data->regs);
|
||||
}
|
||||
|
||||
data->clk = devm_clk_get_optional(&pdev->dev, NULL);
|
||||
if (IS_ERR(data->clk))
|
||||
return PTR_ERR(data->clk);
|
||||
|
||||
ret = clk_prepare_enable(data->clk);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to enable clock\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
qoriq_tmu_init_device(data); /* TMU initialization */
|
||||
|
||||
ret = qoriq_tmu_calibration(pdev); /* TMU calibration */
|
||||
if (ret < 0)
|
||||
goto err_tmu;
|
||||
goto err;
|
||||
|
||||
ret = qoriq_tmu_register_tmu_zone(pdev);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "Failed to register sensors\n");
|
||||
ret = -ENODEV;
|
||||
goto err_iomap;
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_tmu:
|
||||
iounmap(data->regs);
|
||||
|
||||
err_iomap:
|
||||
err:
|
||||
clk_disable_unprepare(data->clk);
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
|
||||
return ret;
|
||||
|
@ -240,14 +249,14 @@ static int qoriq_tmu_remove(struct platform_device *pdev)
|
|||
/* Disable monitoring */
|
||||
tmu_write(data, TMR_DISABLE, &data->regs->tmr);
|
||||
|
||||
iounmap(data->regs);
|
||||
clk_disable_unprepare(data->clk);
|
||||
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int qoriq_tmu_suspend(struct device *dev)
|
||||
static int __maybe_unused qoriq_tmu_suspend(struct device *dev)
|
||||
{
|
||||
u32 tmr;
|
||||
struct qoriq_tmu_data *data = dev_get_drvdata(dev);
|
||||
|
@ -257,14 +266,21 @@ static int qoriq_tmu_suspend(struct device *dev)
|
|||
tmr &= ~TMR_ME;
|
||||
tmu_write(data, tmr, &data->regs->tmr);
|
||||
|
||||
clk_disable_unprepare(data->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qoriq_tmu_resume(struct device *dev)
|
||||
static int __maybe_unused qoriq_tmu_resume(struct device *dev)
|
||||
{
|
||||
u32 tmr;
|
||||
int ret;
|
||||
struct qoriq_tmu_data *data = dev_get_drvdata(dev);
|
||||
|
||||
ret = clk_prepare_enable(data->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Enable monitoring */
|
||||
tmr = tmu_read(data, &data->regs->tmr);
|
||||
tmr |= TMR_ME;
|
||||
|
@ -272,7 +288,6 @@ static int qoriq_tmu_resume(struct device *dev)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(qoriq_tmu_pm_ops,
|
||||
qoriq_tmu_suspend, qoriq_tmu_resume);
|
||||
|
|
Loading…
Reference in New Issue
Block a user