Lines Matching refs:corner
212 struct corner { struct
233 struct corner *corner; argument
242 struct corner *corners;
304 static void cpr_ctl_enable(struct cpr_drv *drv, struct corner *corner) in cpr_ctl_enable() argument
317 corner->save_ctl); in cpr_ctl_enable()
318 cpr_irq_set(drv, corner->save_irq); in cpr_ctl_enable()
320 if (cpr_is_allowed(drv) && corner->max_uV > corner->min_uV) in cpr_ctl_enable()
357 static void cpr_corner_save(struct cpr_drv *drv, struct corner *corner) in cpr_corner_save() argument
359 corner->save_ctl = cpr_read(drv, REG_RBCPR_CTL); in cpr_corner_save()
360 corner->save_irq = cpr_read(drv, REG_RBIF_IRQ_EN(0)); in cpr_corner_save()
363 static void cpr_corner_restore(struct cpr_drv *drv, struct corner *corner) in cpr_corner_restore() argument
366 struct fuse_corner *fuse = corner->fuse_corner; in cpr_corner_restore()
372 gcnt |= fuse->quot - corner->quot_adjust; in cpr_corner_restore()
384 ctl = corner->save_ctl; in cpr_corner_restore()
386 irq = corner->save_irq; in cpr_corner_restore()
411 struct fuse_corner *prev_fuse_corner = drv->corner->fuse_corner; in cpr_pre_voltage()
423 struct fuse_corner *prev_fuse_corner = drv->corner->fuse_corner; in cpr_post_voltage()
431 static int cpr_scale_voltage(struct cpr_drv *drv, struct corner *corner, in cpr_scale_voltage() argument
435 struct fuse_corner *fuse_corner = corner->fuse_corner; in cpr_scale_voltage()
457 return drv->corner ? drv->corner - drv->corners + 1 : 0; in cpr_get_cur_perf_state()
464 struct corner *corner; in cpr_scale() local
474 corner = drv->corner; in cpr_scale()
480 last_uV = corner->last_uV; in cpr_scale()
494 if (last_uV >= corner->max_uV) { in cpr_scale()
514 new_uV = min(new_uV, corner->max_uV); in cpr_scale()
531 if (last_uV <= corner->min_uV) { in cpr_scale()
551 new_uV = max(new_uV, corner->min_uV); in cpr_scale()
558 ret = cpr_scale_voltage(drv, corner, new_uV, dir); in cpr_scale()
563 drv->corner->last_uV = new_uV; in cpr_scale()
636 cpr_corner_save(drv, drv->corner); in cpr_irq_handler()
654 if (cpr_is_allowed(drv) && drv->corner) { in cpr_enable()
656 cpr_corner_restore(drv, drv->corner); in cpr_enable()
657 cpr_ctl_enable(drv, drv->corner); in cpr_enable()
683 struct corner *corner; in cpr_config() local
730 corner = &drv->corners[i]; in cpr_config()
731 corner->save_ctl = val; in cpr_config()
732 corner->save_irq = CPR_INT_DEFAULT; in cpr_config()
748 struct corner *corner, *end; in cpr_set_performance_state() local
761 corner = drv->corners + state - 1; in cpr_set_performance_state()
763 if (corner > end || corner < drv->corners) { in cpr_set_performance_state()
769 if (drv->corner > corner) in cpr_set_performance_state()
771 else if (drv->corner < corner) in cpr_set_performance_state()
777 new_uV = corner->last_uV; in cpr_set_performance_state()
779 new_uV = corner->uV; in cpr_set_performance_state()
784 ret = cpr_scale_voltage(drv, corner, new_uV, dir); in cpr_set_performance_state()
790 if (drv->corner != corner) in cpr_set_performance_state()
791 cpr_corner_restore(drv, corner); in cpr_set_performance_state()
792 cpr_ctl_enable(drv, corner); in cpr_set_performance_state()
795 drv->corner = corner; in cpr_set_performance_state()
958 const struct corner *corner) in cpr_calculate_scaling() argument
966 fuse = corner->fuse_corner; in cpr_calculate_scaling()
986 static int cpr_interpolate(const struct corner *corner, int step_volt, in cpr_interpolate() argument
994 fuse = corner->fuse_corner; in cpr_interpolate()
1001 f_diff = fuse->max_freq - corner->freq; in cpr_interpolate()
1008 if (f_high <= f_low || uV_high <= uV_low || f_high <= corner->freq) in cpr_interpolate()
1009 return corner->uV; in cpr_interpolate()
1083 struct corner *corner, *end; in cpr_corner_init() local
1095 corner = drv->corners; in cpr_corner_init()
1096 end = &corner[drv->num_corners - 1]; in cpr_corner_init()
1173 for (apply_scaling = false, i = 0; corner <= end; corner++, i++) { in cpr_corner_init()
1183 corner->fuse_corner = fuse; in cpr_corner_init()
1184 corner->freq = cdata[i].freq; in cpr_corner_init()
1185 corner->uV = fuse->uV; in cpr_corner_init()
1189 fdata, corner); in cpr_corner_init()
1194 } else if (corner->freq == fuse->max_freq) { in cpr_corner_init()
1200 freq_diff = fuse->max_freq - corner->freq; in cpr_corner_init()
1202 corner->quot_adjust = scaling * freq_diff_mhz / 1000; in cpr_corner_init()
1204 corner->uV = cpr_interpolate(corner, step_volt, fdata); in cpr_corner_init()
1207 corner->max_uV = fuse->max_uV; in cpr_corner_init()
1208 corner->min_uV = fuse->min_uV; in cpr_corner_init()
1209 corner->uV = clamp(corner->uV, corner->min_uV, corner->max_uV); in cpr_corner_init()
1210 corner->last_uV = corner->uV; in cpr_corner_init()
1213 if (desc->reduce_to_corner_uV && corner->uV < corner->max_uV) in cpr_corner_init()
1214 corner->max_uV = corner->uV; in cpr_corner_init()
1215 else if (desc->reduce_to_fuse_uV && fuse->uV < corner->max_uV) in cpr_corner_init()
1216 corner->max_uV = max(corner->min_uV, fuse->uV); in cpr_corner_init()
1219 corner->min_uV, corner->uV, corner->max_uV, in cpr_corner_init()
1220 fuse->quot - corner->quot_adjust); in cpr_corner_init()
1301 const struct corner *end; in cpr_find_initial_corner()
1302 struct corner *iter; in cpr_find_initial_corner()
1329 drv->corner = iter; in cpr_find_initial_corner()
1333 drv->corner = iter; in cpr_find_initial_corner()
1336 if (!drv->corner) { in cpr_find_initial_corner()
1562 struct corner *corner; in cpr_debug_info_show() local
1564 corner = drv->corner; in cpr_debug_info_show()
1565 fuse_corner = corner->fuse_corner; in cpr_debug_info_show()
1568 corner->last_uV); in cpr_debug_info_show()