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()
205 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_get_temp() local
207 if (!rcar_has_irq_support(priv) || rcar_force_update_temp(priv)) in rcar_thermal_get_temp()
208 rcar_thermal_update_temp(priv); in rcar_thermal_get_temp()
210 mutex_lock(&priv->lock); in rcar_thermal_get_temp()
211 *temp = MCELSIUS((priv->ctemp * 5) - 65); in rcar_thermal_get_temp()
212 mutex_unlock(&priv->lock); in rcar_thermal_get_temp()
220 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_get_trip_type() local
221 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_get_trip_type()
239 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_get_trip_temp() local
240 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_get_trip_temp()
258 struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); in rcar_thermal_notify() local
259 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_notify()
285 static void _rcar_thermal_irq_ctrl(struct rcar_thermal_priv *priv, int enable) in _rcar_thermal_irq_ctrl() argument
287 struct rcar_thermal_common *common = priv->common; in _rcar_thermal_irq_ctrl()
289 u32 mask = 0x3 << rcar_id_to_shift(priv); /* enable Rising/Falling */ in _rcar_thermal_irq_ctrl()
300 struct rcar_thermal_priv *priv; in rcar_thermal_work() local
303 priv = container_of(work, struct rcar_thermal_priv, work.work); in rcar_thermal_work()
305 rcar_thermal_get_temp(priv->zone, &cctemp); in rcar_thermal_work()
306 rcar_thermal_update_temp(priv); in rcar_thermal_work()
307 rcar_thermal_irq_enable(priv); in rcar_thermal_work()
309 rcar_thermal_get_temp(priv->zone, &nctemp); in rcar_thermal_work()
311 thermal_zone_device_update(priv->zone); in rcar_thermal_work()
314 static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status) in rcar_thermal_had_changed() argument
316 struct device *dev = rcar_priv_to_dev(priv); in rcar_thermal_had_changed()
318 status = (status >> rcar_id_to_shift(priv)) & 0x3; in rcar_thermal_had_changed()
322 priv->id, in rcar_thermal_had_changed()
333 struct rcar_thermal_priv *priv; in rcar_thermal_irq() local
350 rcar_thermal_for_each_priv(priv, common) { in rcar_thermal_irq()
351 if (rcar_thermal_had_changed(priv, status)) { in rcar_thermal_irq()
352 rcar_thermal_irq_disable(priv); in rcar_thermal_irq()
353 schedule_delayed_work(&priv->work, in rcar_thermal_irq()
368 struct rcar_thermal_priv *priv; in rcar_thermal_remove() local
370 rcar_thermal_for_each_priv(priv, common) { in rcar_thermal_remove()
371 if (rcar_has_irq_support(priv)) in rcar_thermal_remove()
372 rcar_thermal_irq_disable(priv); in rcar_thermal_remove()
373 thermal_zone_device_unregister(priv->zone); in rcar_thermal_remove()
385 struct rcar_thermal_priv *priv; in rcar_thermal_probe() local
427 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); in rcar_thermal_probe()
428 if (!priv) { in rcar_thermal_probe()
433 priv->base = devm_ioremap_resource(dev, res); in rcar_thermal_probe()
434 if (IS_ERR(priv->base)) { in rcar_thermal_probe()
435 ret = PTR_ERR(priv->base); in rcar_thermal_probe()
439 priv->common = common; in rcar_thermal_probe()
440 priv->id = i; in rcar_thermal_probe()
441 mutex_init(&priv->lock); in rcar_thermal_probe()
442 INIT_LIST_HEAD(&priv->list); in rcar_thermal_probe()
443 INIT_DELAYED_WORK(&priv->work, rcar_thermal_work); in rcar_thermal_probe()
444 rcar_thermal_update_temp(priv); in rcar_thermal_probe()
446 priv->zone = thermal_zone_device_register("rcar_thermal", in rcar_thermal_probe()
447 1, 0, priv, in rcar_thermal_probe()
450 if (IS_ERR(priv->zone)) { in rcar_thermal_probe()
452 ret = PTR_ERR(priv->zone); in rcar_thermal_probe()
456 if (rcar_has_irq_support(priv)) in rcar_thermal_probe()
457 rcar_thermal_irq_enable(priv); in rcar_thermal_probe()
459 list_move_tail(&priv->list, &common->head); in rcar_thermal_probe()