Lines Matching +full:cpu +full:- +full:nr
1 // SPDX-License-Identifier: GPL-2.0-only
29 int nr; member
60 /* TODO: Add the resulting partition to the device-tree */ in smu_sat_get_sdb_partition()
65 err = i2c_smbus_write_word_data(sat->i2c, 8, id << 8); in smu_sat_get_sdb_partition()
71 err = i2c_smbus_read_word_data(sat->i2c, 9); in smu_sat_get_sdb_partition()
89 err = i2c_smbus_read_i2c_block_data(sat->i2c, 0xa, 4, data); in smu_sat_get_sdb_partition()
119 err = i2c_smbus_read_i2c_block_data(sat->i2c, 0x3f, 16, sat->cache); in wf_sat_read_cache()
122 sat->last_read = jiffies; in wf_sat_read_cache()
129 16, 1, sat->cache, 16, false); in wf_sat_read_cache()
138 struct wf_sat *sat = sens->sat; in wf_sat_sensor_get()
142 if (sat->i2c == NULL) in wf_sat_sensor_get()
143 return -ENODEV; in wf_sat_sensor_get()
145 mutex_lock(&sat->mutex); in wf_sat_sensor_get()
146 if (time_after(jiffies, (sat->last_read + MAX_AGE))) { in wf_sat_sensor_get()
152 i = sens->index * 2; in wf_sat_sensor_get()
153 val = ((sat->cache[i] << 8) + sat->cache[i+1]) << sens->shift; in wf_sat_sensor_get()
154 if (sens->index2 >= 0) { in wf_sat_sensor_get()
155 i = sens->index2 * 2; in wf_sat_sensor_get()
156 /* 4.12 * 8.8 -> 12.20; shift right 4 to get 16.16 */ in wf_sat_sensor_get()
157 val = (val * ((sat->cache[i] << 8) + sat->cache[i+1])) >> 4; in wf_sat_sensor_get()
164 mutex_unlock(&sat->mutex); in wf_sat_sensor_get()
172 if (sat->nr >= 0) in wf_sat_release()
173 sats[sat->nr] = NULL; in wf_sat_release()
180 struct wf_sat *sat = sens->sat; in wf_sat_sensor_release()
183 kref_put(&sat->ref, wf_sat_release); in wf_sat_sensor_release()
195 struct device_node *dev = client->dev.of_node; in wf_sat_probe()
202 int shift, cpu, index; in wf_sat_probe() local
208 return -ENOMEM; in wf_sat_probe()
209 sat->nr = -1; in wf_sat_probe()
210 sat->node = of_node_get(dev); in wf_sat_probe()
211 kref_init(&sat->ref); in wf_sat_probe()
212 mutex_init(&sat->mutex); in wf_sat_probe()
213 sat->i2c = client; in wf_sat_probe()
214 INIT_LIST_HEAD(&sat->sensors); in wf_sat_probe()
217 vsens[0] = vsens[1] = -1; in wf_sat_probe()
218 isens[0] = isens[1] = -1; in wf_sat_probe()
228 index = *reg - 0x30; in wf_sat_probe()
230 /* expect location to be CPU [AB][01] ... */ in wf_sat_probe()
231 if (strncmp(loc, "CPU ", 4) != 0) in wf_sat_probe()
233 chip = loc[4] - 'A'; in wf_sat_probe()
234 core = loc[5] - '0'; in wf_sat_probe()
240 cpu = 2 * chip + core; in wf_sat_probe()
241 if (sat->nr < 0) in wf_sat_probe()
242 sat->nr = chip; in wf_sat_probe()
243 else if (sat->nr != chip) { in wf_sat_probe()
245 "multiple CPU chips on one SAT (%s)\n", loc); in wf_sat_probe()
249 if (of_node_is_type(child, "voltage-sensor")) { in wf_sat_probe()
250 name = "cpu-voltage"; in wf_sat_probe()
253 } else if (of_node_is_type(child, "current-sensor")) { in wf_sat_probe()
254 name = "cpu-current"; in wf_sat_probe()
257 } else if (of_node_is_type(child, "temp-sensor")) { in wf_sat_probe()
258 name = "cpu-temp"; in wf_sat_probe()
263 /* the +16 is enough for "cpu-voltage-n" */ in wf_sat_probe()
267 "%s sensor %d (no memory)\n", name, cpu); in wf_sat_probe()
270 sens->index = index; in wf_sat_probe()
271 sens->index2 = -1; in wf_sat_probe()
272 sens->shift = shift; in wf_sat_probe()
273 sens->sat = sat; in wf_sat_probe()
274 sens->sens.ops = &wf_sat_ops; in wf_sat_probe()
275 sens->sens.name = (char *) (sens + 1); in wf_sat_probe()
276 snprintf((char *)sens->sens.name, 16, "%s-%d", name, cpu); in wf_sat_probe()
278 if (wf_register_sensor(&sens->sens)) in wf_sat_probe()
281 list_add(&sens->link, &sat->sensors); in wf_sat_probe()
282 kref_get(&sat->ref); in wf_sat_probe()
290 cpu = 2 * sat->nr + core; in wf_sat_probe()
294 "sensor %d (no memory)\n", cpu); in wf_sat_probe()
297 sens->index = vsens[core]; in wf_sat_probe()
298 sens->index2 = isens[core]; in wf_sat_probe()
299 sens->shift = 0; in wf_sat_probe()
300 sens->sat = sat; in wf_sat_probe()
301 sens->sens.ops = &wf_sat_ops; in wf_sat_probe()
302 sens->sens.name = (char *) (sens + 1); in wf_sat_probe()
303 snprintf((char *)sens->sens.name, 16, "cpu-power-%d", cpu); in wf_sat_probe()
305 if (wf_register_sensor(&sens->sens)) in wf_sat_probe()
308 list_add(&sens->link, &sat->sensors); in wf_sat_probe()
309 kref_get(&sat->ref); in wf_sat_probe()
313 if (sat->nr >= 0) in wf_sat_probe()
314 sats[sat->nr] = sat; in wf_sat_probe()
325 while(!list_empty(&sat->sensors)) { in wf_sat_remove()
326 sens = list_first_entry(&sat->sensors, in wf_sat_remove()
328 list_del(&sens->link); in wf_sat_remove()
329 wf_unregister_sensor(&sens->sens); in wf_sat_remove()
331 sat->i2c = NULL; in wf_sat_remove()
332 kref_put(&sat->ref, wf_sat_release); in wf_sat_remove()
338 { "MAC,smu-sat", 0 },
344 { .compatible = "smu-sat", },