Lines Matching refs:priv
74 #define rcar_priv_to_dev(priv) ((priv)->common->dev) argument
75 #define rcar_has_irq_support(priv) ((priv)->common->base) argument
76 #define rcar_id_to_shift(priv) ((priv)->id * 8) argument
79 # define rcar_force_update_temp(priv) 1 argument
81 # define rcar_force_update_temp(priv) 0 argument
117 static u32 _rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) in _rcar_thermal_read() argument
119 return ioread32(priv->base + reg); in _rcar_thermal_read()
123 static void _rcar_thermal_write(struct rcar_thermal_priv *priv, in _rcar_thermal_write() argument
126 iowrite32(data, priv->base + reg); in _rcar_thermal_write()
130 static void _rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, in _rcar_thermal_bset() argument
135 val = ioread32(priv->base + reg); in _rcar_thermal_bset()
138 iowrite32(val, priv->base + reg); in _rcar_thermal_bset()
144 static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv) in rcar_thermal_update_temp() argument
146 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_update_temp()
151 mutex_lock(&priv->lock); in rcar_thermal_update_temp()
157 rcar_thermal_bset(priv, THSCR, CPCTL, CPCTL); in rcar_thermal_update_temp()
169 new = rcar_thermal_read(priv, THSSR) & CTEMP; in rcar_thermal_update_temp()
185 if (rcar_has_irq_support(priv)) { in rcar_thermal_update_temp()
186 rcar_thermal_write(priv, FILONOFF, 0); in rcar_thermal_update_temp()
189 rcar_thermal_write(priv, POSNEG, 0x1); in rcar_thermal_update_temp()
190 rcar_thermal_write(priv, INTCTRL, (((ctemp - 0) << 8) | in rcar_thermal_update_temp()
194 dev_dbg(dev, "thermal%d %d -> %d\n", priv->id, priv->ctemp, ctemp); in rcar_thermal_update_temp()
196 priv->ctemp = ctemp; in rcar_thermal_update_temp()
199 mutex_unlock(&priv->lock); in rcar_thermal_update_temp()
206 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_get_temp() local
208 if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) in rcar_thermal_get_temp()
209 rcar_thermal_update_temp(priv); in rcar_thermal_get_temp()
211 mutex_lock(&priv->lock); in rcar_thermal_get_temp()
212 *temp = MCELSIUS((priv->ctemp * 5) - 65); in rcar_thermal_get_temp()
213 mutex_unlock(&priv->lock); in rcar_thermal_get_temp()
221 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_get_trip_type() local
222 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_get_trip_type()
240 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_get_trip_temp() local
241 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_get_trip_temp()
259 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_notify() local
260 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_notify()
286 static void _rcar_thermal_irq_ctrl(struct rcar_thermal_priv *priv, int enable) in _rcar_thermal_irq_ctrl() argument
288 struct rcar_thermal_common *common = priv->common; in _rcar_thermal_irq_ctrl()
290 u32 mask = 0x3 << rcar_id_to_shift(priv); /* enable Rising/Falling */ in _rcar_thermal_irq_ctrl()
301 struct rcar_thermal_priv *priv; in rcar_thermal_work() local
304 priv = container_of(work, struct rcar_thermal_priv, work.work); in rcar_thermal_work()
306 rcar_thermal_get_temp(priv->zone, &cctemp); in rcar_thermal_work()
307 rcar_thermal_update_temp(priv); in rcar_thermal_work()
308 rcar_thermal_irq_enable(priv); in rcar_thermal_work()
310 rcar_thermal_get_temp(priv->zone, &nctemp); in rcar_thermal_work()
312 thermal_zone_device_update(priv->zone); in rcar_thermal_work()
315 static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status) in rcar_thermal_had_changed() argument
317 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_had_changed()
319 status = (status >> rcar_id_to_shift(priv)) & 0x3; in rcar_thermal_had_changed()
323 priv->id, in rcar_thermal_had_changed()
334 struct rcar_thermal_priv *priv; in rcar_thermal_irq() local
351 rcar_thermal_for_each_priv(priv, common) { in rcar_thermal_irq()
352 if (rcar_thermal_had_changed(priv, status)) { in rcar_thermal_irq()
353 rcar_thermal_irq_disable(priv); in rcar_thermal_irq()
354 schedule_delayed_work(&priv->work, in rcar_thermal_irq()
368 struct rcar_thermal_priv *priv; in rcar_thermal_probe() local
408 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); in rcar_thermal_probe()
409 if (!priv) { in rcar_thermal_probe()
414 priv->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
415 if (IS_ERR(priv->base)) { in rcar_thermal_probe()
416 ret = PTR_ERR(priv->base); in rcar_thermal_probe()
420 priv->common = common; in rcar_thermal_probe()
421 priv->id = i; in rcar_thermal_probe()
422 mutex_init(&priv->lock); in rcar_thermal_probe()
423 INIT_LIST_HEAD(&priv->list); in rcar_thermal_probe()
424 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); in rcar_thermal_probe()
425 rcar_thermal_update_temp(priv); in rcar_thermal_probe()
427 priv->zone = thermal_zone_device_register("rcar_thermal", in rcar_thermal_probe()
428 1, 0, priv, in rcar_thermal_probe()
431 if (IS_ERR(priv->zone)) { in rcar_thermal_probe()
433 ret = PTR_ERR(priv->zone); in rcar_thermal_probe()
437 if (rcar_has_irq_support(priv)) in rcar_thermal_probe()
438 rcar_thermal_irq_enable(priv); in rcar_thermal_probe()
440 list_move_tail(&priv->list, &common->head); in rcar_thermal_probe()
465 rcar_thermal_for_each_priv(priv, common) { in rcar_thermal_probe()
466 if (rcar_has_irq_support(priv)) in rcar_thermal_probe()
467 rcar_thermal_irq_disable(priv); in rcar_thermal_probe()
468 thermal_zone_device_unregister(priv->zone); in rcar_thermal_probe()
481 struct rcar_thermal_priv *priv; in rcar_thermal_remove() local
483 rcar_thermal_for_each_priv(priv, common) { in rcar_thermal_remove()
484 if (rcar_has_irq_support(priv)) in rcar_thermal_remove()
485 rcar_thermal_irq_disable(priv); in rcar_thermal_remove()
486 thermal_zone_device_unregister(priv->zone); in rcar_thermal_remove()