Lines Matching +full:efuse +full:- +full:settings

1 /*-
175 return ((A83T_TEMP_BASE - (val * A83T_TEMP_MUL)) / A83T_TEMP_DIV); in a83t_to_temp()
207 return ((A64_TEMP_BASE - (val * A64_TEMP_MUL)) / A64_TEMP_DIV); in a64_to_temp()
239 return (H3_TEMP_BASE - ((val * H3_TEMP_MUL) / H3_TEMP_DIV)); in h3_to_temp()
245 return ((H3_TEMP_MINUS - (val * H3_TEMP_DIV)) / H3_TEMP_MUL); in h3_to_reg()
275 tmp = H5_TEMP_BASE - (val * H5_TEMP_MUL); in h5_to_temp()
281 tmp = H5_TEMP_BASE_CPU - (val * H5_TEMP_MUL_CPU); in h5_to_temp()
283 tmp = H5_TEMP_BASE_GPU - (val * H5_TEMP_MUL_GPU); in h5_to_temp()
299 tmp = H5_TEMP_BASE - (val << H5_TEMP_DIV); in h5_to_reg()
303 tmp = H5_TEMP_BASE_CPU - (val << H5_TEMP_DIV); in h5_to_reg()
306 tmp = H5_TEMP_BASE_GPU - (val << H5_TEMP_DIV); in h5_to_reg()
343 { "allwinner,sun8i-a83t-ths", (uintptr_t)&a83t_config },
344 { "allwinner,sun8i-h3-ths", (uintptr_t)&h3_config },
345 { "allwinner,sun50i-a64-ths", (uintptr_t)&a64_config },
346 { "allwinner,sun50i-h5-ths", (uintptr_t)&h5_config },
351 (void *)ofw_bus_search_compatible((d), compat_data)->ocd_data
371 { -1, 0 }
374 #define RD4(sc, reg) bus_read_4((sc)->res[0], (reg))
375 #define WR4(sc, reg, val) bus_write_4((sc)->res[0], (reg), (val))
384 node = ofw_bus_get_node(sc->dev); in aw_thermal_init()
386 device_printf(sc->dev, "calibration nvmem cell is too large\n"); in aw_thermal_init()
391 /* Read calibration settings from EFUSE */ in aw_thermal_init()
393 device_printf(sc->dev, "Cannot read THS efuse\n"); in aw_thermal_init()
397 calib[0] &= sc->conf->calib0_mask; in aw_thermal_init()
398 calib[1] &= sc->conf->calib1_mask; in aw_thermal_init()
400 /* Write calibration settings to thermal controller */ in aw_thermal_init()
408 WR4(sc, THS_CTRL0, sc->conf->adc_acquire_time); in aw_thermal_init()
409 WR4(sc, THS_CTRL2, sc->conf->adc_acquire_time << SENSOR_ACQ1_SHIFT); in aw_thermal_init()
412 WR4(sc, THS_INTC, sc->conf->thermal_per << THS_THERMAL_PER_SHIFT); in aw_thermal_init()
415 WR4(sc, THS_FILTER, sc->conf->filter); in aw_thermal_init()
434 return (sc->conf->to_temp(val, sensor)); in aw_thermal_gettemp()
445 return (sc->conf->to_temp(val, sensor)); in aw_thermal_getshut()
455 val |= (sc->conf->to_reg(temp, sensor) << SHUT_T_HOT_SHIFT); in aw_thermal_setshut()
467 return (sc->conf->to_temp(val, sensor)); in aw_thermal_gethyst()
478 return (sc->conf->to_temp(val, sensor)); in aw_thermal_getalarm()
488 val |= (sc->conf->to_reg(temp, sensor) << ALARM_T_HOT_SHIFT); in aw_thermal_setalarm()
512 if (enable == sc->throttle) in aw_thermal_throttle()
521 error = CPUFREQ_LEVELS(cf_dev, sc->levels, &count); in aw_thermal_throttle()
524 sc->min_freq = sc->levels[count - 1].total_set.freq; in aw_thermal_throttle()
525 error = CPUFREQ_SET(cf_dev, &sc->levels[count - 1], in aw_thermal_throttle()
531 sc->throttle = enable; in aw_thermal_throttle()
552 if (aw_thermal_throttle_enable == 0 || sc->throttle == 0 || in aw_thermal_cf_pre_change()
553 level->total_set.freq == sc->min_freq) in aw_thermal_cf_pre_change()
580 "WARNING - current temperature exceeds safe limits\n"); in aw_thermal_intr()
585 taskqueue_enqueue(taskqueue_thread, &sc->cf_task); in aw_thermal_intr()
610 sc->dev = dev; in aw_thermal_attach()
614 sc->conf = THS_CONF(dev); in aw_thermal_attach()
615 TASK_INIT(&sc->cf_task, 0, aw_thermal_cf_task, sc); in aw_thermal_attach()
617 if (bus_alloc_resources(dev, aw_thermal_spec, sc->res) != 0) { in aw_thermal_attach()
622 if (clk_get_by_ofw_name(dev, 0, "bus", &sc->clk_apb) == 0) { in aw_thermal_attach()
623 error = clk_enable(sc->clk_apb); in aw_thermal_attach()
630 if (clk_get_by_ofw_name(dev, 0, "mod", &sc->clk_ths) == 0) { in aw_thermal_attach()
631 error = clk_set_freq(sc->clk_ths, sc->conf->clk_rate, 0); in aw_thermal_attach()
636 error = clk_enable(sc->clk_ths); in aw_thermal_attach()
646 device_printf(dev, "cannot de-assert reset\n"); in aw_thermal_attach()
651 error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE, in aw_thermal_attach()
658 for (i = 0; i < sc->conf->nsensors; i++) { in aw_thermal_attach()
659 if (sc->conf->sensors[i].init_alarm > 0) in aw_thermal_attach()
661 sc->conf->sensors[i].init_alarm); in aw_thermal_attach()
662 if (sc->conf->sensors[i].init_shut > 0) in aw_thermal_attach()
664 sc->conf->sensors[i].init_shut); in aw_thermal_attach()
670 for (i = 0; i < sc->conf->nsensors; i++) in aw_thermal_attach()
673 OID_AUTO, sc->conf->sensors[i].name, in aw_thermal_attach()
676 sc->conf->sensors[i].desc); in aw_thermal_attach()
679 for (i = 0; i < sc->conf->nsensors; i++) { in aw_thermal_attach()
682 sc->conf->sensors[i].name, in aw_thermal_attach()
688 sc->cf_pre_tag = EVENTHANDLER_REGISTER(cpufreq_pre_change, in aw_thermal_attach()
695 bus_teardown_intr(dev, sc->res[1], ih); in aw_thermal_attach()
698 if (sc->clk_apb != NULL) in aw_thermal_attach()
699 clk_release(sc->clk_apb); in aw_thermal_attach()
700 if (sc->clk_ths != NULL) in aw_thermal_attach()
701 clk_release(sc->clk_ths); in aw_thermal_attach()
702 bus_release_resources(dev, aw_thermal_spec, sc->res); in aw_thermal_attach()