Lines Matching refs:spz
58 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_power_uw() local
62 if (!spz->info->powercap_monitoring) in scmi_powercap_get_power_uw()
65 ret = powercap_ops->measurements_get(spz->ph, spz->info->id, &avg_power, in scmi_powercap_get_power_uw()
71 if (spz->info->powercap_scale_mw) in scmi_powercap_get_power_uw()
79 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_zone_enable_set() local
81 return powercap_ops->cap_enable_set(spz->ph, spz->info->id, mode); in scmi_powercap_zone_enable_set()
86 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_zone_enable_get() local
88 return powercap_ops->cap_enable_get(spz->ph, spz->info->id, mode); in scmi_powercap_zone_enable_get()
99 static void scmi_powercap_normalize_cap(const struct scmi_powercap_zone *spz, in scmi_powercap_normalize_cap() argument
102 bool scale_mw = spz->info->powercap_scale_mw; in scmi_powercap_normalize_cap()
111 *norm = clamp_t(u32, val, spz->info->min_power_cap, in scmi_powercap_normalize_cap()
112 spz->info->max_power_cap); in scmi_powercap_normalize_cap()
113 *norm = rounddown(*norm, spz->info->power_cap_step); in scmi_powercap_normalize_cap()
117 dev_dbg(spz->dev, in scmi_powercap_normalize_cap()
119 spz->info->name, power_limit_uw, val); in scmi_powercap_normalize_cap()
125 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_set_power_limit_uw() local
128 if (!spz->info->powercap_cap_config) in scmi_powercap_set_power_limit_uw()
131 scmi_powercap_normalize_cap(spz, power_uw, &norm_power); in scmi_powercap_set_power_limit_uw()
133 return powercap_ops->cap_set(spz->ph, spz->info->id, norm_power, false); in scmi_powercap_set_power_limit_uw()
139 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_power_limit_uw() local
143 ret = powercap_ops->cap_get(spz->ph, spz->info->id, &power); in scmi_powercap_get_power_limit_uw()
148 if (spz->info->powercap_scale_mw) in scmi_powercap_get_power_limit_uw()
154 static void scmi_powercap_normalize_time(const struct scmi_powercap_zone *spz, in scmi_powercap_normalize_time() argument
162 *norm = clamp_t(u32, time_us, spz->info->min_pai, spz->info->max_pai); in scmi_powercap_normalize_time()
163 *norm = rounddown(*norm, spz->info->pai_step); in scmi_powercap_normalize_time()
166 dev_dbg(spz->dev, in scmi_powercap_normalize_time()
168 spz->info->name, time_us, *norm); in scmi_powercap_normalize_time()
174 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_set_time_window_us() local
177 if (!spz->info->powercap_pai_config) in scmi_powercap_set_time_window_us()
180 scmi_powercap_normalize_time(spz, time_window_us, &norm_pai); in scmi_powercap_set_time_window_us()
182 return powercap_ops->pai_set(spz->ph, spz->info->id, norm_pai); in scmi_powercap_set_time_window_us()
188 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_time_window_us() local
192 ret = powercap_ops->pai_get(spz->ph, spz->info->id, &pai); in scmi_powercap_get_time_window_us()
204 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_max_power_uw() local
206 *max_power_uw = spz->info->max_power_cap; in scmi_powercap_get_max_power_uw()
207 if (spz->info->powercap_scale_mw) in scmi_powercap_get_max_power_uw()
216 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_min_power_uw() local
218 *min_power_uw = spz->info->min_power_cap; in scmi_powercap_get_min_power_uw()
219 if (spz->info->powercap_scale_mw) in scmi_powercap_get_min_power_uw()
228 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_max_time_window_us() local
230 *time_window_us = spz->info->max_pai; in scmi_powercap_get_max_time_window_us()
238 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz); in scmi_powercap_get_min_time_window_us() local
240 *time_window_us = (u64)spz->info->min_pai; in scmi_powercap_get_min_time_window_us()
269 struct scmi_powercap_zone *spz; in scmi_powercap_unregister_all_zones() local
271 list_for_each_entry(spz, &pr->registered_zones[i], node) in scmi_powercap_unregister_all_zones()
273 &spz->zone); in scmi_powercap_unregister_all_zones()
279 scmi_powercap_get_zone_height(struct scmi_powercap_zone *spz) in scmi_powercap_get_zone_height() argument
281 if (spz->info->parent_id == SCMI_POWERCAP_ROOT_ZONE_ID) in scmi_powercap_get_zone_height()
284 return spz->spzones[spz->info->parent_id].height + 1; in scmi_powercap_get_zone_height()
288 scmi_powercap_get_parent_zone(struct scmi_powercap_zone *spz) in scmi_powercap_get_parent_zone() argument
290 if (spz->info->parent_id == SCMI_POWERCAP_ROOT_ZONE_ID) in scmi_powercap_get_parent_zone()
293 return &spz->spzones[spz->info->parent_id]; in scmi_powercap_get_parent_zone()
297 struct scmi_powercap_zone *spz, in scmi_powercap_register_zone() argument
303 if (spz->invalid) { in scmi_powercap_register_zone()
304 list_del(&spz->node); in scmi_powercap_register_zone()
308 z = powercap_register_zone(&spz->zone, scmi_top_pcntrl, spz->info->name, in scmi_powercap_register_zone()
312 spz->height = scmi_powercap_get_zone_height(spz); in scmi_powercap_register_zone()
313 spz->registered = true; in scmi_powercap_register_zone()
314 list_move(&spz->node, &pr->registered_zones[spz->height]); in scmi_powercap_register_zone()
315 dev_dbg(spz->dev, "Registered node %s - parent %s - height:%d\n", in scmi_powercap_register_zone()
316 spz->info->name, parent ? parent->info->name : "ROOT", in scmi_powercap_register_zone()
317 spz->height); in scmi_powercap_register_zone()
319 list_del(&spz->node); in scmi_powercap_register_zone()
321 dev_err(spz->dev, in scmi_powercap_register_zone()
323 spz->info->name, in scmi_powercap_register_zone()
325 spz->height, ret); in scmi_powercap_register_zone()
371 struct scmi_powercap_zone *spz, **zones_stack; in scmi_zones_register() local
373 zones_stack = kcalloc(pr->num_zones, sizeof(spz), GFP_KERNEL); in scmi_zones_register()
377 spz = list_first_entry_or_null(&pr->scmi_zones, in scmi_zones_register()
379 while (spz) { in scmi_zones_register()
382 parent = scmi_powercap_get_parent_zone(spz); in scmi_zones_register()
384 zones_stack[sp++] = spz; in scmi_zones_register()
385 spz = parent; in scmi_zones_register()
387 ret = scmi_powercap_register_zone(pr, spz, parent); in scmi_zones_register()
403 spz = zones_stack[--sp]; in scmi_zones_register()
405 spz = list_first_entry_or_null(&pr->scmi_zones, in scmi_zones_register()
422 struct scmi_powercap_zone *spz; in scmi_powercap_probe() local
460 for (i = 0, spz = pr->spzones; i < pr->num_zones; i++, spz++) { in scmi_powercap_probe()
466 spz->info = powercap_ops->info_get(ph, i); in scmi_powercap_probe()
468 spz->dev = dev; in scmi_powercap_probe()
469 spz->ph = ph; in scmi_powercap_probe()
470 spz->spzones = pr->spzones; in scmi_powercap_probe()
471 INIT_LIST_HEAD(&spz->node); in scmi_powercap_probe()
474 list_add_tail(&spz->node, &pr->scmi_zones); in scmi_powercap_probe()
480 if (!spz->info->powercap_scale_uw && in scmi_powercap_probe()
481 !spz->info->powercap_scale_mw) { in scmi_powercap_probe()
484 spz->info->name); in scmi_powercap_probe()
485 spz->invalid = true; in scmi_powercap_probe()