Lines Matching +full:temp +full:- +full:sensor
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
49 #define CONTROL0 0 /* Offset in config->regs[] array */
61 #define CONTROL1 1 /* Offset in config->regs[] array */
66 #define STATUS 2 /* Offset in config->regs[] array */
99 .calib_add = -150000,
116 {"marvell,armada-ap806-thermal", (uintptr_t) &mv_ap806_config},
117 {"marvell,armada-cp110-thermal", (uintptr_t) &mv_cp110_config},
122 SYSCON_READ_4((sc)->syscon, sc->config->regs[reg])
124 SYSCON_WRITE_4((sc)->syscon, sc->config->regs[reg], (val))
130 shift = 31 - index; in sign_extend()
141 while (--timeout > 0) { in mv_thermal_wait_sensor()
143 if ((reg & sc->config->valid_mask) == sc->config->valid_mask) in mv_thermal_wait_sensor()
155 mv_thermal_select_sensor(struct mv_thermal_softc *sc, int sensor) in mv_thermal_select_sensor() argument
159 if (sc->cur_sensor == sensor) in mv_thermal_select_sensor()
167 /* Switch to the selected sensor */ in mv_thermal_select_sensor()
173 /* This reset automatically to the sensor 0 */ in mv_thermal_select_sensor()
175 if (sensor) { in mv_thermal_select_sensor()
176 /* Select external sensor */ in mv_thermal_select_sensor()
179 reg |= (sensor - 1) << CONTROL0_CHANNEL_SHIFT; in mv_thermal_select_sensor()
182 sc->cur_sensor = sensor; in mv_thermal_select_sensor()
193 mv_thermal_read_sensor(struct mv_thermal_softc *sc, int sensor, int *temp) in mv_thermal_read_sensor() argument
198 rv = mv_thermal_select_sensor(sc, sensor); in mv_thermal_read_sensor()
204 if (sc->config->signed_value) in mv_thermal_read_sensor()
205 sample = sign_extend(reg, fls(STATUS_TEMP_MASK) - 1); in mv_thermal_read_sensor()
209 *temp = ((sample * sc->config->calib_mul) - sc->config->calib_add) / in mv_thermal_read_sensor()
210 sc->config->calib_div; in mv_thermal_read_sensor()
220 /* Start the temp capture/conversion */ in ap806_init()
230 /* Since we just started the module wait for the sensor to be ready */ in ap806_init()
259 int sensor = arg2; in mv_thermal_sysctl() local
263 mtx_lock(&(sc)->mtx); in mv_thermal_sysctl()
265 if (mv_thermal_read_sensor(sc, sensor, &val) == 0) { in mv_thermal_sysctl()
269 device_printf(dev, "Timeout waiting for sensor\n"); in mv_thermal_sysctl()
272 mtx_unlock(&(sc)->mtx); in mv_thermal_sysctl()
283 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in mv_thermal_probe()
286 device_set_desc(dev, "Marvell Thermal Sensor Controller"); in mv_thermal_probe()
301 sc->dev = dev; in mv_thermal_attach()
303 sc->config = (struct mv_thermal_config *) in mv_thermal_attach()
304 ofw_bus_search_compatible(dev, compat_data)->ocd_data; in mv_thermal_attach()
306 mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); in mv_thermal_attach()
308 if (SYSCON_GET_HANDLE(sc->dev, &sc->syscon) != 0 || in mv_thermal_attach()
309 sc->syscon == NULL) { in mv_thermal_attach()
314 sc->cur_sensor = -1; in mv_thermal_attach()
315 switch (sc->config->type) { in mv_thermal_attach()
326 /* There is always at least one sensor */ in mv_thermal_attach()
333 for (i = 0; i < sc->config->ncpus; i++) { in mv_thermal_attach()