Lines Matching +full:thermal +full:- +full:diode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Windfarm PowerMac thermal control. SMU based sensors
82 return -EIO; in smu_read_adc()
95 rc = smu_read_adc(ads->reg, &val); in smu_cputemp_get()
103 scaled = (s64)(((u64)val) * (u64)cpudiode->m_value); in smu_cputemp_get()
105 scaled += ((s64)cpudiode->b_value) << 9; in smu_cputemp_get()
117 rc = smu_read_adc(ads->reg, &val); in smu_cpuamp_get()
125 scaled = (s32)(val * (u32)cpuvcp->curr_scale); in smu_cpuamp_get()
126 scaled += (s32)cpuvcp->curr_offset; in smu_cpuamp_get()
138 rc = smu_read_adc(ads->reg, &val); in smu_cpuvolt_get()
146 scaled = (s32)(val * (u32)cpuvcp->volt_scale); in smu_cpuvolt_get()
147 scaled += (s32)cpuvcp->volt_offset; in smu_cpuvolt_get()
159 rc = smu_read_adc(ads->reg, &val); in smu_slotspow_get()
167 scaled = (s32)(val * (u32)slotspow->pow_scale); in smu_slotspow_get()
168 scaled += (s32)slotspow->pow_offset; in smu_slotspow_get()
211 * properties, while Darwin uses the sensor-id's. in smu_ads_create()
217 if (of_node_is_type(node, "temp-sensor") && in smu_ads_create()
218 !strcmp(l, "CPU T-Diode")) { in smu_ads_create()
219 ads->sens.ops = &smu_cputemp_ops; in smu_ads_create()
220 ads->sens.name = "cpu-temp"; in smu_ads_create()
226 } else if (of_node_is_type(node, "current-sensor") && in smu_ads_create()
228 ads->sens.ops = &smu_cpuamp_ops; in smu_ads_create()
229 ads->sens.name = "cpu-current"; in smu_ads_create()
235 } else if (of_node_is_type(node, "voltage-sensor") && in smu_ads_create()
237 ads->sens.ops = &smu_cpuvolt_ops; in smu_ads_create()
238 ads->sens.name = "cpu-voltage"; in smu_ads_create()
244 } else if (of_node_is_type(node, "power-sensor") && in smu_ads_create()
246 ads->sens.ops = &smu_slotspow_ops; in smu_ads_create()
247 ads->sens.name = "slots-power"; in smu_ads_create()
259 ads->reg = *v; in smu_ads_create()
261 if (wf_register_sensor(&ads->sens)) in smu_ads_create()
289 if (pow->volts) in smu_cpu_power_release()
290 wf_put_sensor(pow->volts); in smu_cpu_power_release()
291 if (pow->amps) in smu_cpu_power_release()
292 wf_put_sensor(pow->amps); in smu_cpu_power_release()
303 rc = pow->amps->ops->get_value(pow->amps, &s); in smu_cpu_power_get()
307 if (pow->fake_volts) { in smu_cpu_power_get()
308 *value = amps * 12 - 0x30000; in smu_cpu_power_get()
312 rc = pow->volts->ops->get_value(pow->volts, &volts); in smu_cpu_power_get()
317 if (!pow->quadratic) { in smu_cpu_power_get()
322 tmpa = ((u64)cpuvcp->power_quads[0]) * tmps; in smu_cpu_power_get()
323 tmpb = ((u64)cpuvcp->power_quads[1]) * ((u64)power); in smu_cpu_power_get()
324 *value = (tmpa >> 28) + (tmpb >> 28) + (cpuvcp->power_quads[2] >> 12); in smu_cpu_power_get()
344 pow->sens.ops = &smu_cpu_power_ops; in smu_cpu_power_create()
345 pow->sens.name = "cpu-power"; in smu_cpu_power_create()
348 pow->volts = volts; in smu_cpu_power_create()
350 pow->amps = amps; in smu_cpu_power_create()
356 pow->fake_volts = 1; in smu_cpu_power_create()
358 pow->fake_volts = 0; in smu_cpu_power_create()
368 pow->quadratic = 1; in smu_cpu_power_create()
371 pow->quadratic = 0; in smu_cpu_power_create()
373 if (wf_register_sensor(&pow->sens)) in smu_cpu_power_create()
390 cpuvcp_version = hdr->version; in smu_fetch_param_partitions()
393 /* Get CPU diode calibration data */ in smu_fetch_param_partitions()
415 return -ENODEV; in smu_sensors_init()
422 return -ENODEV; in smu_sensors_init()
439 list_add(&ads->link, &smu_ads); in smu_sensors_init()
441 if (!strcmp(ads->sens.name, "cpu-voltage")) in smu_sensors_init()
443 else if (!strcmp(ads->sens.name, "cpu-current")) in smu_sensors_init()
451 smu_cpu_power = smu_cpu_power_create(&volt_sensor->sens, in smu_sensors_init()
452 &curr_sensor->sens); in smu_sensors_init()
463 wf_unregister_sensor(&smu_cpu_power->sens); in smu_sensors_exit()
468 list_del(&ads->link); in smu_sensors_exit()
469 wf_unregister_sensor(&ads->sens); in smu_sensors_exit()
478 MODULE_DESCRIPTION("SMU sensor objects for PowerMacs thermal control");