Lines Matching refs:data

99 static int query_current_values_with_pending_wait(struct powernow_k8_data *data)  in query_current_values_with_pending_wait()  argument
112 data->currvid = hi & MSR_S_HI_CURRENT_VID; in query_current_values_with_pending_wait()
113 data->currfid = lo & MSR_S_LO_CURRENT_FID; in query_current_values_with_pending_wait()
119 static void count_off_irt(struct powernow_k8_data *data) in count_off_irt() argument
121 udelay((1 << data->irt) * 10); in count_off_irt()
125 static void count_off_vst(struct powernow_k8_data *data) in count_off_vst() argument
127 udelay(data->vstable * VST_UNITS_20US); in count_off_vst()
146 static int write_new_fid(struct powernow_k8_data *data, u32 fid) in write_new_fid() argument
149 u32 savevid = data->currvid; in write_new_fid()
152 if ((fid & INVALID_FID_MASK) || (data->currvid & INVALID_VID_MASK)) { in write_new_fid()
158 lo |= (data->currvid << MSR_C_LO_VID_SHIFT); in write_new_fid()
162 fid, lo, data->plllock * PLL_LOCK_CONVERSION); in write_new_fid()
165 wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); in write_new_fid()
170 } while (query_current_values_with_pending_wait(data)); in write_new_fid()
172 count_off_irt(data); in write_new_fid()
174 if (savevid != data->currvid) { in write_new_fid()
176 savevid, data->currvid); in write_new_fid()
180 if (fid != data->currfid) { in write_new_fid()
182 data->currfid); in write_new_fid()
190 static int write_new_vid(struct powernow_k8_data *data, u32 vid) in write_new_vid() argument
193 u32 savefid = data->currfid; in write_new_vid()
196 if ((data->currfid & INVALID_FID_MASK) || (vid & INVALID_VID_MASK)) { in write_new_vid()
201 lo = data->currfid; in write_new_vid()
214 } while (query_current_values_with_pending_wait(data)); in write_new_vid()
216 if (savefid != data->currfid) { in write_new_vid()
218 savefid, data->currfid); in write_new_vid()
222 if (vid != data->currvid) { in write_new_vid()
224 vid, data->currvid); in write_new_vid()
236 static int decrease_vid_code_by_step(struct powernow_k8_data *data, in decrease_vid_code_by_step() argument
239 if ((data->currvid - reqvid) > step) in decrease_vid_code_by_step()
240 reqvid = data->currvid - step; in decrease_vid_code_by_step()
242 if (write_new_vid(data, reqvid)) in decrease_vid_code_by_step()
245 count_off_vst(data); in decrease_vid_code_by_step()
251 static int transition_fid_vid(struct powernow_k8_data *data, in transition_fid_vid() argument
254 if (core_voltage_pre_transition(data, reqvid, reqfid)) in transition_fid_vid()
257 if (core_frequency_transition(data, reqfid)) in transition_fid_vid()
260 if (core_voltage_post_transition(data, reqvid)) in transition_fid_vid()
263 if (query_current_values_with_pending_wait(data)) in transition_fid_vid()
266 if ((reqfid != data->currfid) || (reqvid != data->currvid)) { in transition_fid_vid()
269 reqfid, reqvid, data->currfid, data->currvid); in transition_fid_vid()
274 smp_processor_id(), data->currfid, data->currvid); in transition_fid_vid()
280 static int core_voltage_pre_transition(struct powernow_k8_data *data, in core_voltage_pre_transition() argument
283 u32 rvosteps = data->rvo; in core_voltage_pre_transition()
284 u32 savefid = data->currfid; in core_voltage_pre_transition()
289 data->currfid, data->currvid, reqvid, data->rvo); in core_voltage_pre_transition()
300 while (data->currvid > reqvid) { in core_voltage_pre_transition()
302 data->currvid, reqvid); in core_voltage_pre_transition()
303 if (decrease_vid_code_by_step(data, reqvid, data->vidmvs)) in core_voltage_pre_transition()
308 ((rvomult * data->rvo + data->currvid) > reqvid)) { in core_voltage_pre_transition()
309 if (data->currvid == maxvid) { in core_voltage_pre_transition()
313 data->currvid - 1); in core_voltage_pre_transition()
314 if (decrease_vid_code_by_step(data, data->currvid-1, 1)) in core_voltage_pre_transition()
320 if (query_current_values_with_pending_wait(data)) in core_voltage_pre_transition()
323 if (savefid != data->currfid) { in core_voltage_pre_transition()
324 pr_err("ph1 err, currfid changed 0x%x\n", data->currfid); in core_voltage_pre_transition()
329 data->currfid, data->currvid); in core_voltage_pre_transition()
335 static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) in core_frequency_transition() argument
338 u32 fid_interval, savevid = data->currvid; in core_frequency_transition()
340 if (data->currfid == reqfid) { in core_frequency_transition()
341 pr_err("ph2 null fid transition 0x%x\n", data->currfid); in core_frequency_transition()
347 data->currfid, data->currvid, reqfid); in core_frequency_transition()
350 vcocurrfid = convert_fid_to_vco_fid(data->currfid); in core_frequency_transition()
354 if ((reqfid <= LO_FID_TABLE_TOP) && (data->currfid <= LO_FID_TABLE_TOP)) in core_frequency_transition()
358 (data->currfid & 1) ? (fid_interval = 1) : (fid_interval = 2); in core_frequency_transition()
360 if (reqfid > data->currfid) { in core_frequency_transition()
361 if (data->currfid > LO_FID_TABLE_TOP) { in core_frequency_transition()
362 if (write_new_fid(data, in core_frequency_transition()
363 data->currfid + fid_interval)) in core_frequency_transition()
367 (data, in core_frequency_transition()
368 2 + convert_fid_to_vco_fid(data->currfid))) in core_frequency_transition()
372 if (write_new_fid(data, data->currfid - fid_interval)) in core_frequency_transition()
376 vcocurrfid = convert_fid_to_vco_fid(data->currfid); in core_frequency_transition()
381 if (write_new_fid(data, reqfid)) in core_frequency_transition()
384 if (query_current_values_with_pending_wait(data)) in core_frequency_transition()
387 if (data->currfid != reqfid) { in core_frequency_transition()
389 data->currfid, reqfid); in core_frequency_transition()
393 if (savevid != data->currvid) { in core_frequency_transition()
395 savevid, data->currvid); in core_frequency_transition()
400 data->currfid, data->currvid); in core_frequency_transition()
406 static int core_voltage_post_transition(struct powernow_k8_data *data, in core_voltage_post_transition() argument
409 u32 savefid = data->currfid; in core_voltage_post_transition()
414 data->currfid, data->currvid); in core_voltage_post_transition()
416 if (reqvid != data->currvid) { in core_voltage_post_transition()
417 if (write_new_vid(data, reqvid)) in core_voltage_post_transition()
420 if (savefid != data->currfid) { in core_voltage_post_transition()
422 savefid, data->currfid); in core_voltage_post_transition()
426 if (data->currvid != reqvid) { in core_voltage_post_transition()
428 reqvid, data->currvid); in core_voltage_post_transition()
433 if (query_current_values_with_pending_wait(data)) in core_voltage_post_transition()
436 if (savereqvid != data->currvid) { in core_voltage_post_transition()
437 pr_debug("ph3 failed, currvid 0x%x\n", data->currvid); in core_voltage_post_transition()
441 if (savefid != data->currfid) { in core_voltage_post_transition()
443 data->currfid); in core_voltage_post_transition()
448 data->currfid, data->currvid); in core_voltage_post_transition()
492 static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, in check_pst_table() argument
498 for (j = 0; j < data->numps; j++) { in check_pst_table()
504 if (pst[j].vid < data->rvo) { in check_pst_table()
509 if (pst[j].vid < maxvid + data->rvo) { in check_pst_table()
543 static void print_basics(struct powernow_k8_data *data) in print_basics() argument
546 for (j = 0; j < data->numps; j++) { in print_basics()
547 if (data->powernow_table[j].frequency != in print_basics()
550 data->powernow_table[j].driver_data & 0xff, in print_basics()
551 data->powernow_table[j].frequency/1000, in print_basics()
552 data->powernow_table[j].driver_data >> 8); in print_basics()
555 if (data->batps) in print_basics()
556 pr_info("Only %d pstates on battery\n", data->batps); in print_basics()
559 static int fill_powernow_table(struct powernow_k8_data *data, in fill_powernow_table() argument
565 if (data->batps) { in fill_powernow_table()
568 data->batps); in fill_powernow_table()
569 data->numps = data->batps; in fill_powernow_table()
572 for (j = 1; j < data->numps; j++) { in fill_powernow_table()
579 if (data->numps < 2) { in fill_powernow_table()
584 if (check_pst_table(data, pst, maxvid)) in fill_powernow_table()
588 * (data->numps + 1)), GFP_KERNEL); in fill_powernow_table()
592 for (j = 0; j < data->numps; j++) { in fill_powernow_table()
599 powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; in fill_powernow_table()
600 powernow_table[data->numps].driver_data = 0; in fill_powernow_table()
602 if (query_current_values_with_pending_wait(data)) { in fill_powernow_table()
607 pr_debug("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid); in fill_powernow_table()
608 data->powernow_table = powernow_table; in fill_powernow_table()
609 if (cpumask_first(topology_core_cpumask(data->cpu)) == data->cpu) in fill_powernow_table()
610 print_basics(data); in fill_powernow_table()
612 for (j = 0; j < data->numps; j++) in fill_powernow_table()
613 if ((pst[j].fid == data->currfid) && in fill_powernow_table()
614 (pst[j].vid == data->currvid)) in fill_powernow_table()
622 static int find_psb_table(struct powernow_k8_data *data) in find_psb_table() argument
653 data->vstable = psb->vstable; in find_psb_table()
655 data->vstable); in find_psb_table()
658 data->rvo = psb->flags2 & 3; in find_psb_table()
659 data->irt = ((psb->flags2) >> 2) & 3; in find_psb_table()
661 data->vidmvs = 1 << mvs; in find_psb_table()
662 data->batps = ((psb->flags2) >> 6) & 3; in find_psb_table()
664 pr_debug("ramp voltage offset: %d\n", data->rvo); in find_psb_table()
665 pr_debug("isochronous relief time: %d\n", data->irt); in find_psb_table()
666 pr_debug("maximum voltage step: %d - 0x%x\n", mvs, data->vidmvs); in find_psb_table()
682 data->plllock = psb->plllocktime; in find_psb_table()
688 data->numps = psb->numps; in find_psb_table()
689 pr_debug("numpstates: 0x%x\n", data->numps); in find_psb_table()
690 return fill_powernow_table(data, in find_psb_table()
709 static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, in powernow_k8_acpi_pst_values() argument
714 if (!data->acpi_data.state_count) in powernow_k8_acpi_pst_values()
717 control = data->acpi_data.states[index].control; in powernow_k8_acpi_pst_values()
718 data->irt = (control >> IRT_SHIFT) & IRT_MASK; in powernow_k8_acpi_pst_values()
719 data->rvo = (control >> RVO_SHIFT) & RVO_MASK; in powernow_k8_acpi_pst_values()
720 data->exttype = (control >> EXT_TYPE_SHIFT) & EXT_TYPE_MASK; in powernow_k8_acpi_pst_values()
721 data->plllock = (control >> PLL_L_SHIFT) & PLL_L_MASK; in powernow_k8_acpi_pst_values()
722 data->vidmvs = 1 << ((control >> MVS_SHIFT) & MVS_MASK); in powernow_k8_acpi_pst_values()
723 data->vstable = (control >> VST_SHIFT) & VST_MASK; in powernow_k8_acpi_pst_values()
726 static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) in powernow_k8_cpu_init_acpi() argument
732 if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { in powernow_k8_cpu_init_acpi()
738 if (data->acpi_data.state_count <= 1) { in powernow_k8_cpu_init_acpi()
743 control = data->acpi_data.control_register.space_id; in powernow_k8_cpu_init_acpi()
744 status = data->acpi_data.status_register.space_id; in powernow_k8_cpu_init_acpi()
755 * (data->acpi_data.state_count + 1)), GFP_KERNEL); in powernow_k8_cpu_init_acpi()
760 data->numps = data->acpi_data.state_count; in powernow_k8_cpu_init_acpi()
761 powernow_k8_acpi_pst_values(data, 0); in powernow_k8_cpu_init_acpi()
763 ret_val = fill_powernow_table_fidvid(data, powernow_table); in powernow_k8_cpu_init_acpi()
767 powernow_table[data->acpi_data.state_count].frequency = in powernow_k8_cpu_init_acpi()
769 data->powernow_table = powernow_table; in powernow_k8_cpu_init_acpi()
771 if (cpumask_first(topology_core_cpumask(data->cpu)) == data->cpu) in powernow_k8_cpu_init_acpi()
772 print_basics(data); in powernow_k8_cpu_init_acpi()
777 if (!zalloc_cpumask_var(&data->acpi_data.shared_cpu_map, GFP_KERNEL)) { in powernow_k8_cpu_init_acpi()
789 acpi_processor_unregister_performance(data->cpu); in powernow_k8_cpu_init_acpi()
793 data->acpi_data.state_count = 0; in powernow_k8_cpu_init_acpi()
798 static int fill_powernow_table_fidvid(struct powernow_k8_data *data, in fill_powernow_table_fidvid() argument
803 for (i = 0; i < data->acpi_data.state_count; i++) { in fill_powernow_table_fidvid()
809 if (data->exttype) { in fill_powernow_table_fidvid()
810 status = data->acpi_data.states[i].status; in fill_powernow_table_fidvid()
814 control = data->acpi_data.states[i].control; in fill_powernow_table_fidvid()
842 if (freq != (data->acpi_data.states[i].core_frequency * 1000)) { in fill_powernow_table_fidvid()
845 (data->acpi_data.states[i].core_frequency in fill_powernow_table_fidvid()
854 static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) in powernow_k8_cpu_exit_acpi() argument
856 if (data->acpi_data.state_count) in powernow_k8_cpu_exit_acpi()
857 acpi_processor_unregister_performance(data->cpu); in powernow_k8_cpu_exit_acpi()
858 free_cpumask_var(data->acpi_data.shared_cpu_map); in powernow_k8_cpu_exit_acpi()
861 static int get_transition_latency(struct powernow_k8_data *data) in get_transition_latency() argument
865 for (i = 0; i < data->acpi_data.state_count; i++) { in get_transition_latency()
866 int cur_latency = data->acpi_data.states[i].transition_latency in get_transition_latency()
867 + data->acpi_data.states[i].bus_master_latency; in get_transition_latency()
880 static int transition_frequency_fidvid(struct powernow_k8_data *data, in transition_frequency_fidvid() argument
896 fid = data->powernow_table[index].driver_data & 0xFF; in transition_frequency_fidvid()
897 vid = (data->powernow_table[index].driver_data & 0xFF00) >> 8; in transition_frequency_fidvid()
901 if (query_current_values_with_pending_wait(data)) in transition_frequency_fidvid()
904 if ((data->currvid == vid) && (data->currfid == fid)) { in transition_frequency_fidvid()
912 freqs.old = find_khz_freq_from_fid(data->currfid); in transition_frequency_fidvid()
916 res = transition_fid_vid(data, fid, vid); in transition_frequency_fidvid()
932 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); in powernowk8_target_fn() local
937 if (!data) in powernowk8_target_fn()
940 checkfid = data->currfid; in powernowk8_target_fn()
941 checkvid = data->currvid; in powernowk8_target_fn()
949 pol->cpu, data->powernow_table[newstate].frequency, pol->min, in powernowk8_target_fn()
952 if (query_current_values_with_pending_wait(data)) in powernowk8_target_fn()
956 data->currfid, data->currvid); in powernowk8_target_fn()
958 if ((checkvid != data->currvid) || in powernowk8_target_fn()
959 (checkfid != data->currfid)) { in powernowk8_target_fn()
961 checkfid, data->currfid, in powernowk8_target_fn()
962 checkvid, data->currvid); in powernowk8_target_fn()
967 powernow_k8_acpi_pst_values(data, newstate); in powernowk8_target_fn()
969 ret = transition_frequency_fidvid(data, newstate, pol); in powernowk8_target_fn()
978 pol->cur = find_khz_freq_from_fid(data->currfid); in powernowk8_target_fn()
992 struct powernow_k8_data *data; member
1006 if (query_current_values_with_pending_wait(init_on_cpu->data)) { in powernowk8_cpu_init_on_cpu()
1024 struct powernow_k8_data *data; in powernowk8_cpu_init() local
1032 data = kzalloc(sizeof(*data), GFP_KERNEL); in powernowk8_cpu_init()
1033 if (!data) in powernowk8_cpu_init()
1036 data->cpu = pol->cpu; in powernowk8_cpu_init()
1038 if (powernow_k8_cpu_init_acpi(data)) { in powernowk8_cpu_init()
1051 rc = find_psb_table(data); in powernowk8_cpu_init()
1058 ((data->rvo + 8) * data->vstable * VST_UNITS_20US) + in powernowk8_cpu_init()
1059 ((1 << data->irt) * 30)) * 1000; in powernowk8_cpu_init()
1061 pol->cpuinfo.transition_latency = get_transition_latency(data); in powernowk8_cpu_init()
1064 init_on_cpu.data = data; in powernowk8_cpu_init()
1065 smp_call_function_single(data->cpu, powernowk8_cpu_init_on_cpu, in powernowk8_cpu_init()
1072 data->available_cores = pol->cpus; in powernowk8_cpu_init()
1073 pol->freq_table = data->powernow_table; in powernowk8_cpu_init()
1076 data->currfid, data->currvid); in powernowk8_cpu_init()
1080 per_cpu(powernow_data, cpu) = data; in powernowk8_cpu_init()
1085 powernow_k8_cpu_exit_acpi(data); in powernowk8_cpu_init()
1088 kfree(data); in powernowk8_cpu_init()
1094 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); in powernowk8_cpu_exit() local
1097 if (!data) in powernowk8_cpu_exit()
1100 powernow_k8_cpu_exit_acpi(data); in powernowk8_cpu_exit()
1102 kfree(data->powernow_table); in powernowk8_cpu_exit()
1103 kfree(data); in powernowk8_cpu_exit()
1113 struct powernow_k8_data *data = __this_cpu_read(powernow_data); in query_values_on_cpu() local
1115 *err = query_current_values_with_pending_wait(data); in query_values_on_cpu()
1120 struct powernow_k8_data *data = per_cpu(powernow_data, cpu); in powernowk8_get() local
1124 if (!data) in powernowk8_get()
1131 khz = find_khz_freq_from_fid(data->currfid); in powernowk8_get()