@@ -579,6 +579,19 @@ static int register_pcc_channel(int pcc_subspace_idx)
579579 return 0 ;
580580}
581581
582+ /**
583+ * cpc_ffh_supported() - check if FFH reading supported
584+ *
585+ * Check if the architecture has support for functional fixed hardware
586+ * read/write capability.
587+ *
588+ * Return: true for supported, false for not supported
589+ */
590+ bool __weak cpc_ffh_supported (void )
591+ {
592+ return false;
593+ }
594+
582595/*
583596 * An example CPC table looks like the following.
584597 *
@@ -728,9 +741,11 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
728741 cpc_ptr -> cpc_regs [i - 2 ].sys_mem_vaddr = addr ;
729742 }
730743 } else {
731- /* Support only PCC and SYS MEM type regs */
732- pr_debug ("Unsupported register type: %d\n" , gas_t -> space_id );
733- goto out_free ;
744+ if (gas_t -> space_id != ACPI_ADR_SPACE_FIXED_HARDWARE || !cpc_ffh_supported ()) {
745+ /* Support only PCC ,SYS MEM and FFH type regs */
746+ pr_debug ("Unsupported register type: %d\n" , gas_t -> space_id );
747+ goto out_free ;
748+ }
734749 }
735750
736751 cpc_ptr -> cpc_regs [i - 2 ].type = ACPI_TYPE_BUFFER ;
@@ -819,13 +834,43 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr)
819834}
820835EXPORT_SYMBOL_GPL (acpi_cppc_processor_exit );
821836
837+ /**
838+ * cpc_read_ffh() - Read FFH register
839+ * @cpunum: cpu number to read
840+ * @reg: cppc register information
841+ * @val: place holder for return value
842+ *
843+ * Read bit_width bits from a specified address and bit_offset
844+ *
845+ * Return: 0 for success and error code
846+ */
847+ int __weak cpc_read_ffh (int cpunum , struct cpc_reg * reg , u64 * val )
848+ {
849+ return - ENOTSUPP ;
850+ }
851+
852+ /**
853+ * cpc_write_ffh() - Write FFH register
854+ * @cpunum: cpu number to write
855+ * @reg: cppc register information
856+ * @val: value to write
857+ *
858+ * Write value of bit_width bits to a specified address and bit_offset
859+ *
860+ * Return: 0 for success and error code
861+ */
862+ int __weak cpc_write_ffh (int cpunum , struct cpc_reg * reg , u64 val )
863+ {
864+ return - ENOTSUPP ;
865+ }
866+
822867/*
823868 * Since cpc_read and cpc_write are called while holding pcc_lock, it should be
824869 * as fast as possible. We have already mapped the PCC subspace during init, so
825870 * we can directly write to it.
826871 */
827872
828- static int cpc_read (struct cpc_register_resource * reg_res , u64 * val )
873+ static int cpc_read (int cpu , struct cpc_register_resource * reg_res , u64 * val )
829874{
830875 int ret_val = 0 ;
831876 void __iomem * vaddr = 0 ;
@@ -841,6 +886,8 @@ static int cpc_read(struct cpc_register_resource *reg_res, u64 *val)
841886 vaddr = GET_PCC_VADDR (reg -> address );
842887 else if (reg -> space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY )
843888 vaddr = reg_res -> sys_mem_vaddr ;
889+ else if (reg -> space_id == ACPI_ADR_SPACE_FIXED_HARDWARE )
890+ return cpc_read_ffh (cpu , reg , val );
844891 else
845892 return acpi_os_read_memory ((acpi_physical_address )reg -> address ,
846893 val , reg -> bit_width );
@@ -867,7 +914,7 @@ static int cpc_read(struct cpc_register_resource *reg_res, u64 *val)
867914 return ret_val ;
868915}
869916
870- static int cpc_write (struct cpc_register_resource * reg_res , u64 val )
917+ static int cpc_write (int cpu , struct cpc_register_resource * reg_res , u64 val )
871918{
872919 int ret_val = 0 ;
873920 void __iomem * vaddr = 0 ;
@@ -877,6 +924,8 @@ static int cpc_write(struct cpc_register_resource *reg_res, u64 val)
877924 vaddr = GET_PCC_VADDR (reg -> address );
878925 else if (reg -> space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY )
879926 vaddr = reg_res -> sys_mem_vaddr ;
927+ else if (reg -> space_id == ACPI_ADR_SPACE_FIXED_HARDWARE )
928+ return cpc_write_ffh (cpu , reg , val );
880929 else
881930 return acpi_os_write_memory ((acpi_physical_address )reg -> address ,
882931 val , reg -> bit_width );
@@ -941,13 +990,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
941990 }
942991 }
943992
944- cpc_read (highest_reg , & high );
993+ cpc_read (cpunum , highest_reg , & high );
945994 perf_caps -> highest_perf = high ;
946995
947- cpc_read (lowest_reg , & low );
996+ cpc_read (cpunum , lowest_reg , & low );
948997 perf_caps -> lowest_perf = low ;
949998
950- cpc_read (nom_perf , & nom );
999+ cpc_read (cpunum , nom_perf , & nom );
9511000 perf_caps -> nominal_perf = nom ;
9521001
9531002 if (!high || !low || !nom )
@@ -1004,9 +1053,9 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
10041053 }
10051054 }
10061055
1007- cpc_read (delivered_reg , & delivered );
1008- cpc_read (reference_reg , & reference );
1009- cpc_read (ref_perf_reg , & ref_perf );
1056+ cpc_read (cpunum , delivered_reg , & delivered );
1057+ cpc_read (cpunum , reference_reg , & reference );
1058+ cpc_read (cpunum , ref_perf_reg , & ref_perf );
10101059
10111060 /*
10121061 * Per spec, if ctr_wrap_time optional register is unsupported, then the
@@ -1015,7 +1064,7 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
10151064 */
10161065 ctr_wrap_time = (u64 )(~((u64 )0 ));
10171066 if (CPC_SUPPORTED (ctr_wrap_reg ))
1018- cpc_read (ctr_wrap_reg , & ctr_wrap_time );
1067+ cpc_read (cpunum , ctr_wrap_reg , & ctr_wrap_time );
10191068
10201069 if (!delivered || !reference || !ref_perf ) {
10211070 ret = - EFAULT ;
@@ -1082,7 +1131,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
10821131 * Skip writing MIN/MAX until Linux knows how to come up with
10831132 * useful values.
10841133 */
1085- cpc_write (desired_reg , perf_ctrls -> desired_perf );
1134+ cpc_write (cpu , desired_reg , perf_ctrls -> desired_perf );
10861135
10871136 if (CPC_IN_PCC (desired_reg ))
10881137 up_read (& pcc_data .pcc_lock ); /* END Phase-I */
0 commit comments