Lines Matching +full:reg +full:- +full:data
77 struct armada_thermal_data *data; member
86 /* Formula coeficients: temp = (b - m * reg) / div */
115 } data; member
119 * struct armada_thermal_sensor - hold the information of one thermal sensor
132 struct armada_thermal_data *data = priv->data; in armadaxp_init() local
133 u32 reg; in armadaxp_init() local
135 regmap_read(priv->syscon, data->syscon_control1_off, ®); in armadaxp_init()
136 reg |= PMU_TDC0_OTF_CAL_MASK; in armadaxp_init()
139 reg &= ~PMU_TDC0_REF_CAL_CNT_MASK; in armadaxp_init()
140 reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS); in armadaxp_init()
143 reg |= PMU_TDC0_SW_RST_MASK; in armadaxp_init()
145 regmap_write(priv->syscon, data->syscon_control1_off, reg); in armadaxp_init()
148 regmap_read(priv->syscon, data->syscon_status_off, ®); in armadaxp_init()
149 reg &= ~PMU_TM_DISABLE_MASK; in armadaxp_init()
150 regmap_write(priv->syscon, data->syscon_status_off, reg); in armadaxp_init()
156 struct armada_thermal_data *data = priv->data; in armada370_init() local
157 u32 reg; in armada370_init() local
159 regmap_read(priv->syscon, data->syscon_control1_off, ®); in armada370_init()
160 reg |= PMU_TDC0_OTF_CAL_MASK; in armada370_init()
163 reg &= ~PMU_TDC0_REF_CAL_CNT_MASK; in armada370_init()
164 reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS); in armada370_init()
167 reg &= ~PMU_TDC0_START_CAL_MASK; in armada370_init()
169 regmap_write(priv->syscon, data->syscon_control1_off, reg); in armada370_init()
177 struct armada_thermal_data *data = priv->data; in armada375_init() local
178 u32 reg; in armada375_init() local
180 regmap_read(priv->syscon, data->syscon_control1_off, ®); in armada375_init()
181 reg &= ~(A375_UNIT_CONTROL_MASK << A375_UNIT_CONTROL_SHIFT); in armada375_init()
182 reg &= ~A375_READOUT_INVERT; in armada375_init()
183 reg &= ~A375_HW_RESETn; in armada375_init()
184 regmap_write(priv->syscon, data->syscon_control1_off, reg); in armada375_init()
188 reg |= A375_HW_RESETn; in armada375_init()
189 regmap_write(priv->syscon, data->syscon_control1_off, reg); in armada375_init()
196 u32 reg; in armada_wait_sensor_validity() local
198 return regmap_read_poll_timeout(priv->syscon, in armada_wait_sensor_validity()
199 priv->data->syscon_status_off, reg, in armada_wait_sensor_validity()
200 reg & priv->data->is_valid_bit, in armada_wait_sensor_validity()
208 struct armada_thermal_data *data = priv->data; in armada380_init() local
209 u32 reg; in armada380_init() local
212 regmap_read(priv->syscon, data->syscon_control1_off, ®); in armada380_init()
213 reg |= CONTROL1_EXT_TSEN_HW_RESETn; in armada380_init()
214 reg &= ~CONTROL1_EXT_TSEN_SW_RESET; in armada380_init()
215 regmap_write(priv->syscon, data->syscon_control1_off, reg); in armada380_init()
218 regmap_read(priv->syscon, data->syscon_control0_off, ®); in armada380_init()
219 reg &= ~CONTROL0_TSEN_TC_TRIM_MASK; in armada380_init()
220 reg |= CONTROL0_TSEN_TC_TRIM_VAL; in armada380_init()
221 regmap_write(priv->syscon, data->syscon_control0_off, reg); in armada380_init()
227 struct armada_thermal_data *data = priv->data; in armada_ap806_init() local
228 u32 reg; in armada_ap806_init() local
230 regmap_read(priv->syscon, data->syscon_control0_off, ®); in armada_ap806_init()
231 reg &= ~CONTROL0_TSEN_RESET; in armada_ap806_init()
232 reg |= CONTROL0_TSEN_START | CONTROL0_TSEN_ENABLE; in armada_ap806_init()
235 reg |= CONTROL0_TSEN_OSR_MAX << CONTROL0_TSEN_OSR_SHIFT; in armada_ap806_init()
238 reg &= ~CONTROL0_TSEN_AVG_BYPASS; in armada_ap806_init()
240 regmap_write(priv->syscon, data->syscon_control0_off, reg); in armada_ap806_init()
246 struct armada_thermal_data *data = priv->data; in armada_cp110_init() local
247 u32 reg; in armada_cp110_init() local
252 regmap_read(priv->syscon, data->syscon_control0_off, ®); in armada_cp110_init()
253 reg |= CONTROL0_TSEN_OSR_MAX << CONTROL0_TSEN_OSR_SHIFT; in armada_cp110_init()
254 regmap_write(priv->syscon, data->syscon_control0_off, reg); in armada_cp110_init()
257 regmap_read(priv->syscon, data->syscon_control1_off, ®); in armada_cp110_init()
258 reg &= ~CONTROL1_TSEN_AVG_MASK << CONTROL1_TSEN_AVG_SHIFT; in armada_cp110_init()
259 reg |= 1 << CONTROL1_TSEN_AVG_SHIFT; in armada_cp110_init()
260 regmap_write(priv->syscon, data->syscon_control1_off, reg); in armada_cp110_init()
265 u32 reg; in armada_is_valid() local
267 if (!priv->data->is_valid_bit) in armada_is_valid()
270 regmap_read(priv->syscon, priv->data->syscon_status_off, ®); in armada_is_valid()
272 return reg & priv->data->is_valid_bit; in armada_is_valid()
278 struct armada_thermal_data *data = priv->data; in armada_select_channel() local
281 if (channel < 0 || channel > priv->data->cpu_nr) in armada_select_channel()
282 return -EINVAL; in armada_select_channel()
284 if (priv->current_channel == channel) in armada_select_channel()
288 regmap_read(priv->syscon, data->syscon_control0_off, &ctrl0); in armada_select_channel()
290 regmap_write(priv->syscon, data->syscon_control0_off, ctrl0); in armada_select_channel()
302 ctrl0 |= (channel - 1) << CONTROL0_TSEN_CHAN_SHIFT; in armada_select_channel()
306 regmap_write(priv->syscon, data->syscon_control0_off, ctrl0); in armada_select_channel()
307 priv->current_channel = channel; in armada_select_channel()
309 /* Re-start the measurements */ in armada_select_channel()
311 regmap_write(priv->syscon, data->syscon_control0_off, ctrl0); in armada_select_channel()
316 * actual data. in armada_select_channel()
319 dev_err(priv->dev, in armada_select_channel()
321 return -EIO; in armada_select_channel()
329 u32 reg, div; in armada_read_sensor() local
332 regmap_read(priv->syscon, priv->data->syscon_status_off, ®); in armada_read_sensor()
333 reg = (reg >> priv->data->temp_shift) & priv->data->temp_mask; in armada_read_sensor()
334 if (priv->data->signed_sample) in armada_read_sensor()
336 sample = sign_extend32(reg, fls(priv->data->temp_mask) - 1); in armada_read_sensor()
338 sample = reg; in armada_read_sensor()
341 b = priv->data->coef_b; in armada_read_sensor()
342 m = priv->data->coef_m; in armada_read_sensor()
343 div = priv->data->coef_div; in armada_read_sensor()
345 if (priv->data->inverted) in armada_read_sensor()
346 *temp = div_s64((m * sample) - b, div); in armada_read_sensor()
348 *temp = div_s64(b - (m * sample), div); in armada_read_sensor()
356 struct armada_thermal_priv *priv = thermal->devdata; in armada_get_temp_legacy()
361 dev_err(priv->dev, in armada_get_temp_legacy()
363 return -EIO; in armada_get_temp_legacy()
379 struct armada_thermal_priv *priv = sensor->priv; in armada_get_temp()
382 mutex_lock(&priv->update_lock); in armada_get_temp()
385 ret = armada_select_channel(priv, sensor->id); in armada_get_temp()
393 mutex_unlock(&priv->update_lock); in armada_get_temp()
457 .coef_b = -150000LL,
484 .compatible = "marvell,armadaxp-thermal",
485 .data = &armadaxp_data,
488 .compatible = "marvell,armada370-thermal",
489 .data = &armada370_data,
492 .compatible = "marvell,armada375-thermal",
493 .data = &armada375_data,
496 .compatible = "marvell,armada380-thermal",
497 .data = &armada380_data,
500 .compatible = "marvell,armada-ap806-thermal",
501 .data = &armada_ap806_data,
504 .compatible = "marvell,armada-cp110-thermal",
505 .data = &armada_cp110_data,
523 struct armada_thermal_data *data = priv->data; in armada_thermal_probe_legacy() local
530 return -EIO; in armada_thermal_probe_legacy()
536 res->start -= data->syscon_status_off; in armada_thermal_probe_legacy()
537 res->end = res->start + max(data->syscon_status_off, in armada_thermal_probe_legacy()
538 max(data->syscon_control0_off, in armada_thermal_probe_legacy()
539 data->syscon_control1_off)) + in armada_thermal_probe_legacy()
540 sizeof(unsigned int) - 1; in armada_thermal_probe_legacy()
542 base = devm_ioremap_resource(&pdev->dev, res); in armada_thermal_probe_legacy()
546 priv->syscon = devm_regmap_init_mmio(&pdev->dev, base, in armada_thermal_probe_legacy()
548 if (IS_ERR(priv->syscon)) in armada_thermal_probe_legacy()
549 return PTR_ERR(priv->syscon); in armada_thermal_probe_legacy()
557 priv->syscon = syscon_node_to_regmap(pdev->dev.parent->of_node); in armada_thermal_probe_syscon()
558 if (IS_ERR(priv->syscon)) in armada_thermal_probe_syscon()
559 return PTR_ERR(priv->syscon); in armada_thermal_probe_syscon()
567 const char *name = dev_name(&pdev->dev); in armada_set_sane_name()
573 * form: f06f8000.system-controller:ap-thermal so stripping in armada_set_sane_name()
584 strncpy(priv->zone_name, name, THERMAL_NAME_LENGTH - 1); in armada_set_sane_name()
585 priv->zone_name[THERMAL_NAME_LENGTH - 1] = '\0'; in armada_set_sane_name()
587 /* Then check there are no '-' or hwmon core will complain */ in armada_set_sane_name()
589 insane_char = strpbrk(priv->zone_name, "-"); in armada_set_sane_name()
605 match = of_match_device(armada_thermal_id_table, &pdev->dev); in armada_thermal_probe()
607 return -ENODEV; in armada_thermal_probe()
609 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in armada_thermal_probe()
611 return -ENOMEM; in armada_thermal_probe()
613 drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); in armada_thermal_probe()
615 return -ENOMEM; in armada_thermal_probe()
617 priv->dev = &pdev->dev; in armada_thermal_probe()
618 priv->data = (struct armada_thermal_data *)match->data; in armada_thermal_probe()
620 mutex_init(&priv->update_lock); in armada_thermal_probe()
634 if (IS_ERR(syscon_node_to_regmap(pdev->dev.parent->of_node))) { in armada_thermal_probe()
642 priv->data->init(pdev, priv); in armada_thermal_probe()
647 tz = thermal_zone_device_register(priv->zone_name, 0, 0, priv, in armada_thermal_probe()
650 dev_err(&pdev->dev, in armada_thermal_probe()
655 drvdata->type = LEGACY; in armada_thermal_probe()
656 drvdata->data.tz = tz; in armada_thermal_probe()
666 priv->current_channel = -1; in armada_thermal_probe()
667 priv->data->init(pdev, priv); in armada_thermal_probe()
668 drvdata->type = SYSCON; in armada_thermal_probe()
669 drvdata->data.priv = priv; in armada_thermal_probe()
676 for (sensor_id = 0; sensor_id <= priv->data->cpu_nr; sensor_id++) { in armada_thermal_probe()
677 sensor = devm_kzalloc(&pdev->dev, in armada_thermal_probe()
681 return -ENOMEM; in armada_thermal_probe()
684 sensor->priv = priv; in armada_thermal_probe()
685 sensor->id = sensor_id; in armada_thermal_probe()
686 tz = devm_thermal_zone_of_sensor_register(&pdev->dev, in armada_thermal_probe()
687 sensor->id, sensor, in armada_thermal_probe()
690 dev_info(&pdev->dev, "Thermal sensor %d unavailable\n", in armada_thermal_probe()
692 devm_kfree(&pdev->dev, sensor); in armada_thermal_probe()
704 if (drvdata->type == LEGACY) in armada_thermal_exit()
705 thermal_zone_device_unregister(drvdata->data.tz); in armada_thermal_exit()
721 MODULE_AUTHOR("Ezequiel Garcia <ezequiel.garcia@free-electrons.com>");