Lines Matching full:corner
213 struct corner { struct
234 struct corner *corner; argument
243 struct corner *corners;
305 static void cpr_ctl_enable(struct cpr_drv *drv, struct corner *corner) in cpr_ctl_enable() argument
318 corner->save_ctl); in cpr_ctl_enable()
319 cpr_irq_set(drv, corner->save_irq); in cpr_ctl_enable()
321 if (cpr_is_allowed(drv) && corner->max_uV > corner->min_uV) in cpr_ctl_enable()
358 static void cpr_corner_save(struct cpr_drv *drv, struct corner *corner) in cpr_corner_save() argument
360 corner->save_ctl = cpr_read(drv, REG_RBCPR_CTL); in cpr_corner_save()
361 corner->save_irq = cpr_read(drv, REG_RBIF_IRQ_EN(0)); in cpr_corner_save()
364 static void cpr_corner_restore(struct cpr_drv *drv, struct corner *corner) in cpr_corner_restore() argument
367 struct fuse_corner *fuse = corner->fuse_corner; in cpr_corner_restore()
373 gcnt |= fuse->quot - corner->quot_adjust; in cpr_corner_restore()
385 ctl = corner->save_ctl; in cpr_corner_restore()
387 irq = corner->save_irq; in cpr_corner_restore()
412 struct fuse_corner *prev_fuse_corner = drv->corner->fuse_corner; in cpr_pre_voltage()
424 struct fuse_corner *prev_fuse_corner = drv->corner->fuse_corner; in cpr_post_voltage()
432 static int cpr_scale_voltage(struct cpr_drv *drv, struct corner *corner, in cpr_scale_voltage() argument
436 struct fuse_corner *fuse_corner = corner->fuse_corner; in cpr_scale_voltage()
458 return drv->corner ? drv->corner - drv->corners + 1 : 0; in cpr_get_cur_perf_state()
465 struct corner *corner; in cpr_scale() local
475 corner = drv->corner; in cpr_scale()
481 last_uV = corner->last_uV; in cpr_scale()
495 if (last_uV >= corner->max_uV) { in cpr_scale()
515 new_uV = min(new_uV, corner->max_uV); in cpr_scale()
532 if (last_uV <= corner->min_uV) { in cpr_scale()
552 new_uV = max(new_uV, corner->min_uV); in cpr_scale()
559 ret = cpr_scale_voltage(drv, corner, new_uV, dir); in cpr_scale()
564 drv->corner->last_uV = new_uV; in cpr_scale()
636 /* Save register values for the corner */ in cpr_irq_handler()
637 cpr_corner_save(drv, drv->corner); in cpr_irq_handler()
655 if (cpr_is_allowed(drv) && drv->corner) { in cpr_enable()
657 cpr_corner_restore(drv, drv->corner); in cpr_enable()
658 cpr_ctl_enable(drv, drv->corner); in cpr_enable()
684 struct corner *corner; in cpr_config() local
731 corner = &drv->corners[i]; in cpr_config()
732 corner->save_ctl = val; in cpr_config()
733 corner->save_irq = CPR_INT_DEFAULT; in cpr_config()
749 struct corner *corner, *end; in cpr_set_performance_state() local
759 * Determine new corner we're going to. in cpr_set_performance_state()
762 corner = drv->corners + state - 1; in cpr_set_performance_state()
764 if (corner > end || corner < drv->corners) { in cpr_set_performance_state()
770 if (drv->corner > corner) in cpr_set_performance_state()
772 else if (drv->corner < corner) in cpr_set_performance_state()
778 new_uV = corner->last_uV; in cpr_set_performance_state()
780 new_uV = corner->uV; in cpr_set_performance_state()
785 ret = cpr_scale_voltage(drv, corner, new_uV, dir); in cpr_set_performance_state()
791 if (drv->corner != corner) in cpr_set_performance_state()
792 cpr_corner_restore(drv, corner); in cpr_set_performance_state()
793 cpr_ctl_enable(drv, corner); in cpr_set_performance_state()
796 drv->corner = corner; in cpr_set_performance_state()
893 * Allow the highest fuse corner's PVS voltage to in cpr_fuse_corner_init()
894 * define the ceiling voltage for that corner in order in cpr_fuse_corner_init()
918 * Restrict all fuse corner PVS voltages based upon per corner in cpr_fuse_corner_init()
932 "min uV: %d (fuse corner: %d) not supported by regulator\n", in cpr_fuse_corner_init()
942 "max uV: %d (fuse corner: %d) not supported by regulator\n", in cpr_fuse_corner_init()
948 "fuse corner %d: [%d %d %d] RO%hhu quot %d squot %d\n", in cpr_fuse_corner_init()
959 const struct corner *corner) in cpr_calculate_scaling() argument
967 fuse = corner->fuse_corner; in cpr_calculate_scaling()
987 static int cpr_interpolate(const struct corner *corner, int step_volt, in cpr_interpolate() argument
995 fuse = corner->fuse_corner; in cpr_interpolate()
1002 f_diff = fuse->max_freq - corner->freq; in cpr_interpolate()
1009 if (f_high <= f_low || uV_high <= uV_low || f_high <= corner->freq) in cpr_interpolate()
1010 return corner->uV; in cpr_interpolate()
1084 struct corner *corner, *end; in cpr_corner_init() local
1096 corner = drv->corners; in cpr_corner_init()
1097 end = &corner[drv->num_corners - 1]; in cpr_corner_init()
1106 * Store maximum frequency for each fuse corner based on the frequency in cpr_corner_init()
1141 * QUOT(corner_N): quotient read from fuse for fuse corner N in cpr_corner_init()
1142 * QUOT(corner_N-1): quotient read from fuse for fuse corner (N - 1) in cpr_corner_init()
1143 * freq(corner_N): max frequency in MHz supported by fuse corner N in cpr_corner_init()
1144 * freq(corner_N-1): max frequency in MHz supported by fuse corner in cpr_corner_init()
1147 * Then walk through the corners mapped to each fuse corner in cpr_corner_init()
1153 * freq_max: max frequency in MHz supported by the fuse corner in cpr_corner_init()
1154 * freq_corner: frequency in MHz corresponding to the corner in cpr_corner_init()
1168 * corner corner in cpr_corner_init()
1170 * c = corner in cpr_corner_init()
1171 * f = fuse corner in cpr_corner_init()
1174 for (apply_scaling = false, i = 0; corner <= end; corner++, i++) { in cpr_corner_init()
1184 corner->fuse_corner = fuse; in cpr_corner_init()
1185 corner->freq = cdata[i].freq; in cpr_corner_init()
1186 corner->uV = fuse->uV; in cpr_corner_init()
1190 fdata, corner); in cpr_corner_init()
1195 } else if (corner->freq == fuse->max_freq) { in cpr_corner_init()
1196 /* This is a fuse corner; don't scale anything */ in cpr_corner_init()
1201 freq_diff = fuse->max_freq - corner->freq; in cpr_corner_init()
1203 corner->quot_adjust = scaling * freq_diff_mhz / 1000; in cpr_corner_init()
1205 corner->uV = cpr_interpolate(corner, step_volt, fdata); in cpr_corner_init()
1208 corner->max_uV = fuse->max_uV; in cpr_corner_init()
1209 corner->min_uV = fuse->min_uV; in cpr_corner_init()
1210 corner->uV = clamp(corner->uV, corner->min_uV, corner->max_uV); in cpr_corner_init()
1211 corner->last_uV = corner->uV; in cpr_corner_init()
1214 if (desc->reduce_to_corner_uV && corner->uV < corner->max_uV) in cpr_corner_init()
1215 corner->max_uV = corner->uV; in cpr_corner_init()
1216 else if (desc->reduce_to_fuse_uV && fuse->uV < corner->max_uV) in cpr_corner_init()
1217 corner->max_uV = max(corner->min_uV, fuse->uV); in cpr_corner_init()
1219 dev_dbg(drv->dev, "corner %d: [%d %d %d] quot %d\n", i, in cpr_corner_init()
1220 corner->min_uV, corner->uV, corner->max_uV, in cpr_corner_init()
1221 fuse->quot - corner->quot_adjust); in cpr_corner_init()
1302 const struct corner *end; in cpr_find_initial_corner()
1303 struct corner *iter; in cpr_find_initial_corner()
1330 drv->corner = iter; in cpr_find_initial_corner()
1334 drv->corner = iter; in cpr_find_initial_corner()
1337 if (!drv->corner) { in cpr_find_initial_corner()
1338 dev_err(drv->dev, "boot up corner not found\n"); in cpr_find_initial_corner()
1364 /* fuse corner 0 */
1377 /* fuse corner 1 */
1390 /* fuse corner 2 */
1493 * the maximum frequency for each fuse corner, and this is only in cpr_pd_attach_dev()
1496 * frequency associated with each fuse corner. in cpr_pd_attach_dev()
1563 struct corner *corner; in cpr_debug_info_show() local
1565 corner = drv->corner; in cpr_debug_info_show()
1566 fuse_corner = corner->fuse_corner; in cpr_debug_info_show()
1568 seq_printf(s, "corner, current_volt = %d uV\n", in cpr_debug_info_show()
1569 corner->last_uV); in cpr_debug_info_show()