Skip to content

Commit

Permalink
drivers/pvt: add mr75203 driver pm feature and correct temperature co…
Browse files Browse the repository at this point in the history
…efficient

Convert the register value to degrees centigrade temperature:
T = G + H * (n / cal5 - 0.5) + J * F, for TH1520
G = 42740
H = 220000
J = -160
CAL5 = 4094

Signed-off-by: Xiangyi Zeng <[email protected]>
  • Loading branch information
Xiangyi Zeng committed May 24, 2024
1 parent f33967f commit 32312c6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/riscv/boot/dts/thead/th1520.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,10 @@
reg-names = "common", "ts", "pd", "vm";
clocks = <&aonsys_clk>;
#thermal-sensor-cells = <1>;
moortec,ts-coeff-h = <220000>;
moortec,ts-coeff-g = <42470>;
moortec,ts-coeff-j = <0xFFFFFF60>; // -160
moortec,ts-coeff-cal5 = <4094>;
};

gpio@fffff52000 {
Expand Down
28 changes: 28 additions & 0 deletions drivers/hwmon/mr75203.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,33 @@ static int mr75203_probe(struct platform_device *pdev)
return PTR_ERR_OR_ZERO(hwmon_dev);
}

#ifdef CONFIG_PM
static int mr75203_suspend(struct device *dev)
{
/* nothing to do */
return 0;
}

static int mr75203_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct pvt_device *pvt = platform_get_drvdata(pdev);
pvt_init(pvt);
return 0;
}

static const struct dev_pm_ops mr75203_dev_pm_ops = {
.suspend = mr75203_suspend,
.resume = mr75203_resume,
};
#define MR75203_DEV_PM_OPS (&mr75203_dev_pm_ops)

#else

#define MR75203_DEV_PM_OPS NULL

#endif /* CONFIG_PM */

static const struct of_device_id moortec_pvt_of_match[] = {
{ .compatible = "moortec,mr75203" },
{ }
Expand All @@ -919,6 +946,7 @@ MODULE_DEVICE_TABLE(of, moortec_pvt_of_match);
static struct platform_driver moortec_pvt_driver = {
.driver = {
.name = "moortec-pvt",
.pm = MR75203_DEV_PM_OPS,
.of_match_table = moortec_pvt_of_match,
},
.probe = mr75203_probe,
Expand Down

0 comments on commit 32312c6

Please sign in to comment.