@@ -45,8 +45,6 @@ struct cppc_workaround_oem_info {
45
45
u32 oem_revision ;
46
46
};
47
47
48
- static bool apply_hisi_workaround ;
49
-
50
48
static struct cppc_workaround_oem_info wa_info [] = {
51
49
{
52
50
.oem_id = "HISI " ,
@@ -59,50 +57,6 @@ static struct cppc_workaround_oem_info wa_info[] = {
59
57
}
60
58
};
61
59
62
- static unsigned int cppc_cpufreq_perf_to_khz (struct cppc_cpudata * cpu ,
63
- unsigned int perf );
64
-
65
- /*
66
- * HISI platform does not support delivered performance counter and
67
- * reference performance counter. It can calculate the performance using the
68
- * platform specific mechanism. We reuse the desired performance register to
69
- * store the real performance calculated by the platform.
70
- */
71
- static unsigned int hisi_cppc_cpufreq_get_rate (unsigned int cpunum )
72
- {
73
- struct cppc_cpudata * cpudata = all_cpu_data [cpunum ];
74
- u64 desired_perf ;
75
- int ret ;
76
-
77
- ret = cppc_get_desired_perf (cpunum , & desired_perf );
78
- if (ret < 0 )
79
- return - EIO ;
80
-
81
- return cppc_cpufreq_perf_to_khz (cpudata , desired_perf );
82
- }
83
-
84
- static void cppc_check_hisi_workaround (void )
85
- {
86
- struct acpi_table_header * tbl ;
87
- acpi_status status = AE_OK ;
88
- int i ;
89
-
90
- status = acpi_get_table (ACPI_SIG_PCCT , 0 , & tbl );
91
- if (ACPI_FAILURE (status ) || !tbl )
92
- return ;
93
-
94
- for (i = 0 ; i < ARRAY_SIZE (wa_info ); i ++ ) {
95
- if (!memcmp (wa_info [i ].oem_id , tbl -> oem_id , ACPI_OEM_ID_SIZE ) &&
96
- !memcmp (wa_info [i ].oem_table_id , tbl -> oem_table_id , ACPI_OEM_TABLE_ID_SIZE ) &&
97
- wa_info [i ].oem_revision == tbl -> oem_revision ) {
98
- apply_hisi_workaround = true;
99
- break ;
100
- }
101
- }
102
-
103
- acpi_put_table (tbl );
104
- }
105
-
106
60
/* Callback function used to retrieve the max frequency from DMI */
107
61
static void cppc_find_dmi_mhz (const struct dmi_header * dm , void * private )
108
62
{
@@ -402,9 +356,6 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum)
402
356
struct cppc_cpudata * cpu = all_cpu_data [cpunum ];
403
357
int ret ;
404
358
405
- if (apply_hisi_workaround )
406
- return hisi_cppc_cpufreq_get_rate (cpunum );
407
-
408
359
ret = cppc_get_perf_ctrs (cpunum , & fb_ctrs_t0 );
409
360
if (ret )
410
361
return ret ;
@@ -455,6 +406,48 @@ static struct cpufreq_driver cppc_cpufreq_driver = {
455
406
.name = "cppc_cpufreq" ,
456
407
};
457
408
409
+ /*
410
+ * HISI platform does not support delivered performance counter and
411
+ * reference performance counter. It can calculate the performance using the
412
+ * platform specific mechanism. We reuse the desired performance register to
413
+ * store the real performance calculated by the platform.
414
+ */
415
+ static unsigned int hisi_cppc_cpufreq_get_rate (unsigned int cpunum )
416
+ {
417
+ struct cppc_cpudata * cpudata = all_cpu_data [cpunum ];
418
+ u64 desired_perf ;
419
+ int ret ;
420
+
421
+ ret = cppc_get_desired_perf (cpunum , & desired_perf );
422
+ if (ret < 0 )
423
+ return - EIO ;
424
+
425
+ return cppc_cpufreq_perf_to_khz (cpudata , desired_perf );
426
+ }
427
+
428
+ static void cppc_check_hisi_workaround (void )
429
+ {
430
+ struct acpi_table_header * tbl ;
431
+ acpi_status status = AE_OK ;
432
+ int i ;
433
+
434
+ status = acpi_get_table (ACPI_SIG_PCCT , 0 , & tbl );
435
+ if (ACPI_FAILURE (status ) || !tbl )
436
+ return ;
437
+
438
+ for (i = 0 ; i < ARRAY_SIZE (wa_info ); i ++ ) {
439
+ if (!memcmp (wa_info [i ].oem_id , tbl -> oem_id , ACPI_OEM_ID_SIZE ) &&
440
+ !memcmp (wa_info [i ].oem_table_id , tbl -> oem_table_id , ACPI_OEM_TABLE_ID_SIZE ) &&
441
+ wa_info [i ].oem_revision == tbl -> oem_revision ) {
442
+ /* Overwrite the get() callback */
443
+ cppc_cpufreq_driver .get = hisi_cppc_cpufreq_get_rate ;
444
+ break ;
445
+ }
446
+ }
447
+
448
+ acpi_put_table (tbl );
449
+ }
450
+
458
451
static int __init cppc_cpufreq_init (void )
459
452
{
460
453
int i , ret = 0 ;
0 commit comments