Lines Matching +full:apb +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0-only
18 /* Power Mode: 0->low 1->high */
42 * struct zx2967_thermal_priv - zx2967 thermal sensor private structure
46 * @clk_apb: apb clk structure
47 * @regs: pointer to base address of the thermal sensor
67 if (!priv->tzd) in zx2967_thermal_get_temp()
68 return -EAGAIN; in zx2967_thermal_get_temp()
70 regs = priv->regs; in zx2967_thermal_get_temp()
71 mutex_lock(&priv->lock); in zx2967_thermal_get_temp()
91 dev_err(priv->dev, "Thermal sensor data timeout\n"); in zx2967_thermal_get_temp()
106 *temp = DIV_ROUND_CLOSEST(((s32)val + priv->tzd->tzp->offset) * 1000, in zx2967_thermal_get_temp()
107 priv->tzd->tzp->slope); in zx2967_thermal_get_temp()
110 mutex_unlock(&priv->lock); in zx2967_thermal_get_temp()
124 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in zx2967_thermal_probe()
126 return -ENOMEM; in zx2967_thermal_probe()
129 priv->regs = devm_ioremap_resource(&pdev->dev, res); in zx2967_thermal_probe()
130 if (IS_ERR(priv->regs)) in zx2967_thermal_probe()
131 return PTR_ERR(priv->regs); in zx2967_thermal_probe()
133 priv->clk_topcrm = devm_clk_get(&pdev->dev, "topcrm"); in zx2967_thermal_probe()
134 if (IS_ERR(priv->clk_topcrm)) { in zx2967_thermal_probe()
135 ret = PTR_ERR(priv->clk_topcrm); in zx2967_thermal_probe()
136 dev_err(&pdev->dev, "failed to get topcrm clock: %d\n", ret); in zx2967_thermal_probe()
140 ret = clk_prepare_enable(priv->clk_topcrm); in zx2967_thermal_probe()
142 dev_err(&pdev->dev, "failed to enable topcrm clock: %d\n", in zx2967_thermal_probe()
147 priv->clk_apb = devm_clk_get(&pdev->dev, "apb"); in zx2967_thermal_probe()
148 if (IS_ERR(priv->clk_apb)) { in zx2967_thermal_probe()
149 ret = PTR_ERR(priv->clk_apb); in zx2967_thermal_probe()
150 dev_err(&pdev->dev, "failed to get apb clock: %d\n", ret); in zx2967_thermal_probe()
154 ret = clk_prepare_enable(priv->clk_apb); in zx2967_thermal_probe()
156 dev_err(&pdev->dev, "failed to enable apb clock: %d\n", in zx2967_thermal_probe()
161 mutex_init(&priv->lock); in zx2967_thermal_probe()
162 priv->tzd = thermal_zone_of_sensor_register(&pdev->dev, in zx2967_thermal_probe()
165 if (IS_ERR(priv->tzd)) { in zx2967_thermal_probe()
166 ret = PTR_ERR(priv->tzd); in zx2967_thermal_probe()
167 dev_err(&pdev->dev, "failed to register sensor: %d\n", ret); in zx2967_thermal_probe()
171 if (priv->tzd->tzp->slope == 0) { in zx2967_thermal_probe()
172 thermal_zone_of_sensor_unregister(&pdev->dev, priv->tzd); in zx2967_thermal_probe()
173 dev_err(&pdev->dev, "coefficients of sensor is invalid\n"); in zx2967_thermal_probe()
174 ret = -EINVAL; in zx2967_thermal_probe()
178 priv->dev = &pdev->dev; in zx2967_thermal_probe()
184 clk_disable_unprepare(priv->clk_apb); in zx2967_thermal_probe()
186 clk_disable_unprepare(priv->clk_topcrm); in zx2967_thermal_probe()
194 thermal_zone_of_sensor_unregister(&pdev->dev, priv->tzd); in zx2967_thermal_exit()
195 clk_disable_unprepare(priv->clk_topcrm); in zx2967_thermal_exit()
196 clk_disable_unprepare(priv->clk_apb); in zx2967_thermal_exit()
202 { .compatible = "zte,zx296718-thermal" },
212 if (priv && priv->clk_topcrm) in zx2967_thermal_suspend()
213 clk_disable_unprepare(priv->clk_topcrm); in zx2967_thermal_suspend()
215 if (priv && priv->clk_apb) in zx2967_thermal_suspend()
216 clk_disable_unprepare(priv->clk_apb); in zx2967_thermal_suspend()
226 error = clk_prepare_enable(priv->clk_topcrm); in zx2967_thermal_resume()
230 error = clk_prepare_enable(priv->clk_apb); in zx2967_thermal_resume()
232 clk_disable_unprepare(priv->clk_topcrm); in zx2967_thermal_resume()