Lines Matching +full:thermal +full:- +full:diode

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Windfarm PowerMac thermal control. AD7417 sensors
38 struct wf_ad7417_priv *pv = sr->priv; in wf_ad7417_temp_get()
44 mutex_lock(&pv->lock); in wf_ad7417_temp_get()
48 rc = i2c_master_send(pv->i2c, buf, 1); in wf_ad7417_temp_get()
51 rc = i2c_master_recv(pv->i2c, buf, 2); in wf_ad7417_temp_get()
55 /* Read a a 16-bit signed value */ in wf_ad7417_temp_get()
58 /* Convert 8.8-bit to 16.16 fixed point */ in wf_ad7417_temp_get()
61 mutex_unlock(&pv->lock); in wf_ad7417_temp_get()
65 mutex_unlock(&pv->lock); in wf_ad7417_temp_get()
66 return -1; in wf_ad7417_temp_get()
71 * for the CPU diode which is obtained from the EEPROM).
83 case 1: /* Diode */ in wf_ad7417_adc_convert()
84 *value = (raw * (s32)pv->mpu->mdiode + in wf_ad7417_adc_convert()
85 ((s32)pv->mpu->bdiode << 12)) >> 2; in wf_ad7417_adc_convert()
101 struct wf_ad7417_priv *pv = sr->priv; in wf_ad7417_adc_get()
102 int chan = sr - pv->sensors; in wf_ad7417_adc_get()
108 mutex_lock(&pv->lock); in wf_ad7417_adc_get()
112 buf[1] = (pv->config & 0x1f) | (chan << 5); in wf_ad7417_adc_get()
113 rc = i2c_master_send(pv->i2c, buf, 2); in wf_ad7417_adc_get()
122 rc = i2c_master_send(pv->i2c, buf, 1); in wf_ad7417_adc_get()
127 rc = i2c_master_recv(pv->i2c, buf, 2); in wf_ad7417_adc_get()
131 /* Read a a 16-bit signed value */ in wf_ad7417_adc_get()
135 dev_vdbg(&pv->i2c->dev, "ADC chan %d [%s]" in wf_ad7417_adc_get()
137 chan, sr->name, raw, *value); in wf_ad7417_adc_get()
139 mutex_unlock(&pv->lock); in wf_ad7417_adc_get()
143 dev_dbg(&pv->i2c->dev, in wf_ad7417_adc_get()
148 mutex_unlock(&pv->lock); in wf_ad7417_adc_get()
149 return -1; in wf_ad7417_adc_get()
161 struct wf_ad7417_priv *pv = sr->priv; in wf_ad7417_sensor_release()
163 kfree(sr->name); in wf_ad7417_sensor_release()
164 kref_put(&pv->ref, wf_ad7417_release); in wf_ad7417_sensor_release()
183 pv->sensors[index].name = kasprintf(GFP_KERNEL, "%s-%d", name, pv->cpu); in wf_ad7417_add_sensor()
184 pv->sensors[index].priv = pv; in wf_ad7417_add_sensor()
185 pv->sensors[index].ops = ops; in wf_ad7417_add_sensor()
186 if (!wf_register_sensor(&pv->sensors[index])) in wf_ad7417_add_sensor()
187 kref_get(&pv->ref); in wf_ad7417_add_sensor()
206 i2c_master_send(pv->i2c, buf, 2); in wf_ad7417_init_chip()
210 rc = i2c_master_send(pv->i2c, buf, 1); in wf_ad7417_init_chip()
212 rc = i2c_master_recv(pv->i2c, buf, 1); in wf_ad7417_init_chip()
216 dev_dbg(&pv->i2c->dev, "ADC config reg: %02x\n", in wf_ad7417_init_chip()
223 rc = i2c_master_send(pv->i2c, buf, 2); in wf_ad7417_init_chip()
227 dev_err(&pv->i2c->dev, "Error reading ADC config\n"); in wf_ad7417_init_chip()
229 pv->config = config; in wf_ad7417_init_chip()
239 loc = of_get_property(client->dev.of_node, "hwsensor-location", NULL); in wf_ad7417_probe()
241 dev_warn(&client->dev, "Missing hwsensor-location property!\n"); in wf_ad7417_probe()
242 return -ENXIO; in wf_ad7417_probe()
247 * in the hwsensor-location list in wf_ad7417_probe()
255 return -ENXIO; in wf_ad7417_probe()
259 dev_err(&client->dev, "Failed to retrieve MPU data\n"); in wf_ad7417_probe()
260 return -ENXIO; in wf_ad7417_probe()
265 return -ENODEV; in wf_ad7417_probe()
267 kref_init(&pv->ref); in wf_ad7417_probe()
268 mutex_init(&pv->lock); in wf_ad7417_probe()
269 pv->i2c = client; in wf_ad7417_probe()
270 pv->cpu = cpu_nr; in wf_ad7417_probe()
271 pv->mpu = mpu; in wf_ad7417_probe()
272 dev_set_drvdata(&client->dev, pv); in wf_ad7417_probe()
278 * We cannot rely on Apple device-tree giving us child in wf_ad7417_probe()
282 wf_ad7417_add_sensor(pv, 0, "cpu-amb-temp", &wf_ad7417_temp_ops); in wf_ad7417_probe()
283 wf_ad7417_add_sensor(pv, 1, "cpu-diode-temp", &wf_ad7417_adc_ops); in wf_ad7417_probe()
284 wf_ad7417_add_sensor(pv, 2, "cpu-12v-current", &wf_ad7417_adc_ops); in wf_ad7417_probe()
285 wf_ad7417_add_sensor(pv, 3, "cpu-voltage", &wf_ad7417_adc_ops); in wf_ad7417_probe()
286 wf_ad7417_add_sensor(pv, 4, "cpu-current", &wf_ad7417_adc_ops); in wf_ad7417_probe()
293 struct wf_ad7417_priv *pv = dev_get_drvdata(&client->dev); in wf_ad7417_remove()
297 pv->i2c = NULL; in wf_ad7417_remove()
301 wf_unregister_sensor(&pv->sensors[i]); in wf_ad7417_remove()
303 kref_put(&pv->ref, wf_ad7417_release); in wf_ad7417_remove()
334 return -ENODEV; in wf_ad7417_init()