Lines Matching defs:sfctemp

51 struct sfctemp {
62 static void sfctemp_power_up(struct sfctemp *sfctemp)
65 writel(SFCTEMP_PD, sfctemp->regs);
68 writel(0, sfctemp->regs);
73 writel(SFCTEMP_RSTN, sfctemp->regs);
77 static void sfctemp_power_down(struct sfctemp *sfctemp)
79 writel(SFCTEMP_PD, sfctemp->regs);
82 static void sfctemp_run(struct sfctemp *sfctemp)
84 writel(SFCTEMP_RSTN | SFCTEMP_RUN, sfctemp->regs);
88 static void sfctemp_stop(struct sfctemp *sfctemp)
90 writel(SFCTEMP_RSTN, sfctemp->regs);
93 static int sfctemp_enable(struct sfctemp *sfctemp)
97 mutex_lock(&sfctemp->lock);
98 if (sfctemp->enabled)
101 ret = clk_prepare_enable(sfctemp->clk_bus);
104 ret = reset_control_deassert(sfctemp->rst_bus);
108 ret = clk_prepare_enable(sfctemp->clk_sense);
111 ret = reset_control_deassert(sfctemp->rst_sense);
115 sfctemp_power_up(sfctemp);
116 sfctemp_run(sfctemp);
117 sfctemp->enabled = true;
119 mutex_unlock(&sfctemp->lock);
123 clk_disable_unprepare(sfctemp->clk_sense);
125 reset_control_assert(sfctemp->rst_bus);
127 clk_disable_unprepare(sfctemp->clk_bus);
129 mutex_unlock(&sfctemp->lock);
133 static int sfctemp_disable(struct sfctemp *sfctemp)
135 mutex_lock(&sfctemp->lock);
136 if (!sfctemp->enabled)
139 sfctemp_stop(sfctemp);
140 sfctemp_power_down(sfctemp);
141 reset_control_assert(sfctemp->rst_sense);
142 clk_disable_unprepare(sfctemp->clk_sense);
143 reset_control_assert(sfctemp->rst_bus);
144 clk_disable_unprepare(sfctemp->clk_bus);
145 sfctemp->enabled = false;
147 mutex_unlock(&sfctemp->lock);
156 static int sfctemp_convert(struct sfctemp *sfctemp, long *val)
160 mutex_lock(&sfctemp->lock);
161 if (!sfctemp->enabled) {
167 *val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS)
172 mutex_unlock(&sfctemp->lock);
197 struct sfctemp *sfctemp = dev_get_drvdata(dev);
203 *val = sfctemp->enabled;
206 return sfctemp_convert(sfctemp, val);
218 struct sfctemp *sfctemp = dev_get_drvdata(dev);
225 return sfctemp_disable(sfctemp);
227 return sfctemp_enable(sfctemp);
258 struct sfctemp *sfctemp;
261 sfctemp = devm_kzalloc(dev, sizeof(*sfctemp), GFP_KERNEL);
262 if (!sfctemp)
265 dev_set_drvdata(dev, sfctemp);
266 mutex_init(&sfctemp->lock);
268 sfctemp->regs = devm_platform_ioremap_resource(pdev, 0);
269 if (IS_ERR(sfctemp->regs))
270 return PTR_ERR(sfctemp->regs);
272 sfctemp->clk_sense = devm_clk_get(dev, "sense");
273 if (IS_ERR(sfctemp->clk_sense))
274 return dev_err_probe(dev, PTR_ERR(sfctemp->clk_sense),
277 sfctemp->clk_bus = devm_clk_get(dev, "bus");
278 if (IS_ERR(sfctemp->clk_bus))
279 return dev_err_probe(dev, PTR_ERR(sfctemp->clk_bus),
282 sfctemp->rst_sense = devm_reset_control_get_exclusive(dev, "sense");
283 if (IS_ERR(sfctemp->rst_sense))
284 return dev_err_probe(dev, PTR_ERR(sfctemp->rst_sense),
287 sfctemp->rst_bus = devm_reset_control_get_exclusive(dev, "bus");
288 if (IS_ERR(sfctemp->rst_bus))
289 return dev_err_probe(dev, PTR_ERR(sfctemp->rst_bus),
292 ret = reset_control_assert(sfctemp->rst_sense);
296 ret = reset_control_assert(sfctemp->rst_bus);
300 ret = devm_add_action(dev, sfctemp_disable_action, sfctemp);
304 ret = sfctemp_enable(sfctemp);
308 hwmon_dev = devm_hwmon_device_register_with_info(dev, "sfctemp", sfctemp,
323 .name = "sfctemp",