Lines Matching refs:tdev
91 static int uniphier_tm_initialize_sensor(struct uniphier_tm_dev *tdev) in uniphier_tm_initialize_sensor() argument
93 struct regmap *map = tdev->regmap; in uniphier_tm_initialize_sensor()
99 regmap_write_bits(map, tdev->data->block_base + PVTCTLEN, in uniphier_tm_initialize_sensor()
109 ret = regmap_read(map, tdev->data->map_base + TMODCOEF, &val); in uniphier_tm_initialize_sensor()
114 ret = of_property_read_u32_array(tdev->dev->of_node, in uniphier_tm_initialize_sensor()
121 regmap_write(map, tdev->data->tmod_setup_addr, in uniphier_tm_initialize_sensor()
127 regmap_write_bits(map, tdev->data->block_base + PVTCTLMODE, in uniphier_tm_initialize_sensor()
131 regmap_write_bits(map, tdev->data->block_base + EMONREPEAT, in uniphier_tm_initialize_sensor()
136 regmap_write_bits(map, tdev->data->map_base + PVTCTLSEL, in uniphier_tm_initialize_sensor()
142 static void uniphier_tm_set_alert(struct uniphier_tm_dev *tdev, u32 ch, in uniphier_tm_set_alert() argument
145 struct regmap *map = tdev->regmap; in uniphier_tm_set_alert()
148 regmap_write_bits(map, tdev->data->map_base + SETALERT0 + (ch << 2), in uniphier_tm_set_alert()
154 static void uniphier_tm_enable_sensor(struct uniphier_tm_dev *tdev) in uniphier_tm_enable_sensor() argument
156 struct regmap *map = tdev->regmap; in uniphier_tm_enable_sensor()
161 if (tdev->alert_en[i]) in uniphier_tm_enable_sensor()
165 regmap_write_bits(map, tdev->data->map_base + PMALERTINTCTL, in uniphier_tm_enable_sensor()
169 regmap_write_bits(map, tdev->data->block_base + PVTCTLEN, in uniphier_tm_enable_sensor()
175 static void uniphier_tm_disable_sensor(struct uniphier_tm_dev *tdev) in uniphier_tm_disable_sensor() argument
177 struct regmap *map = tdev->regmap; in uniphier_tm_disable_sensor()
180 regmap_write_bits(map, tdev->data->map_base + PMALERTINTCTL, in uniphier_tm_disable_sensor()
184 regmap_write_bits(map, tdev->data->block_base + PVTCTLEN, in uniphier_tm_disable_sensor()
192 struct uniphier_tm_dev *tdev = data; in uniphier_tm_get_temp() local
193 struct regmap *map = tdev->regmap; in uniphier_tm_get_temp()
197 ret = regmap_read(map, tdev->data->map_base + TMOD, &temp); in uniphier_tm_get_temp()
211 static void uniphier_tm_irq_clear(struct uniphier_tm_dev *tdev) in uniphier_tm_irq_clear() argument
222 regmap_write_bits(tdev->regmap, in uniphier_tm_irq_clear()
223 tdev->data->map_base + PMALERTINTCTL, mask, bits); in uniphier_tm_irq_clear()
228 struct uniphier_tm_dev *tdev = _tdev; in uniphier_tm_alarm_irq() local
231 uniphier_tm_irq_clear(tdev); in uniphier_tm_alarm_irq()
238 struct uniphier_tm_dev *tdev = _tdev; in uniphier_tm_alarm_irq_thread() local
240 thermal_zone_device_update(tdev->tz_dev, THERMAL_EVENT_UNSPECIFIED); in uniphier_tm_alarm_irq_thread()
250 struct uniphier_tm_dev *tdev; in uniphier_tm_probe() local
254 tdev = devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL); in uniphier_tm_probe()
255 if (!tdev) in uniphier_tm_probe()
257 tdev->dev = dev; in uniphier_tm_probe()
259 tdev->data = of_device_get_match_data(dev); in uniphier_tm_probe()
260 if (WARN_ON(!tdev->data)) in uniphier_tm_probe()
276 tdev->regmap = regmap; in uniphier_tm_probe()
278 ret = uniphier_tm_initialize_sensor(tdev); in uniphier_tm_probe()
286 0, "thermal", tdev); in uniphier_tm_probe()
290 platform_set_drvdata(pdev, tdev); in uniphier_tm_probe()
292 tdev->tz_dev = devm_thermal_zone_of_sensor_register(dev, 0, tdev, in uniphier_tm_probe()
294 if (IS_ERR(tdev->tz_dev)) { in uniphier_tm_probe()
296 return PTR_ERR(tdev->tz_dev); in uniphier_tm_probe()
300 trips = of_thermal_get_trip_points(tdev->tz_dev); in uniphier_tm_probe()
301 ntrips = of_thermal_get_ntrips(tdev->tz_dev); in uniphier_tm_probe()
312 uniphier_tm_set_alert(tdev, i, trips[i].temperature); in uniphier_tm_probe()
313 tdev->alert_en[i] = true; in uniphier_tm_probe()
321 uniphier_tm_enable_sensor(tdev); in uniphier_tm_probe()
328 struct uniphier_tm_dev *tdev = platform_get_drvdata(pdev); in uniphier_tm_remove() local
331 uniphier_tm_disable_sensor(tdev); in uniphier_tm_remove()