2019-06-01 11:08:55 +03:00
/* SPDX-License-Identifier: GPL-2.0-only */
2015-10-02 17:01:19 +03:00
/*
* CPPC ( Collaborative Processor Performance Control ) methods used
* by CPUfreq drivers .
*
* ( C ) Copyright 2014 , 2015 Linaro Ltd .
* Author : Ashwin Chaugule < ashwin . chaugule @ linaro . org >
*/
# ifndef _CPPC_ACPI_H
# define _CPPC_ACPI_H
# include <linux/acpi.h>
# include <linux/types.h>
2016-06-17 00:09:38 +03:00
# include <acpi/pcc.h>
2015-10-02 17:01:19 +03:00
# include <acpi/processor.h>
2018-04-04 21:14:50 +03:00
/* Support CPPCv2 and CPPCv3 */
# define CPPC_V2_REV 2
# define CPPC_V3_REV 3
# define CPPC_V2_NUM_ENT 21
# define CPPC_V3_NUM_ENT 23
2015-10-02 17:01:19 +03:00
2016-08-16 23:39:44 +03:00
# define PCC_CMD_COMPLETE_MASK (1 << 0)
# define PCC_ERROR_MASK (1 << 2)
2018-04-04 21:14:50 +03:00
# define MAX_CPC_REG_ENT 21
2015-10-02 17:01:19 +03:00
/* CPPC specific PCC commands. */
# define CMD_READ 0
# define CMD_WRITE 1
/* Each register has the folowing format. */
struct cpc_reg {
u8 descriptor ;
u16 length ;
u8 space_id ;
u8 bit_width ;
u8 bit_offset ;
u8 access_width ;
u64 __iomem address ;
} __packed ;
/*
* Each entry in the CPC table is either
* of type ACPI_TYPE_BUFFER or
* ACPI_TYPE_INTEGER .
*/
struct cpc_register_resource {
acpi_object_type type ;
2016-08-16 23:39:38 +03:00
u64 __iomem * sys_mem_vaddr ;
2015-10-02 17:01:19 +03:00
union {
struct cpc_reg reg ;
u64 int_value ;
} cpc_entry ;
} ;
/* Container to hold the CPC details for each CPU */
struct cpc_desc {
int num_entries ;
int version ;
int cpu_id ;
2016-08-16 23:39:40 +03:00
int write_cmd_status ;
int write_cmd_id ;
2015-10-02 17:01:19 +03:00
struct cpc_register_resource cpc_regs [ MAX_CPC_REG_ENT ] ;
struct acpi_psd_package domain_info ;
2016-08-16 23:39:42 +03:00
struct kobject kobj ;
2015-10-02 17:01:19 +03:00
} ;
/* These are indexes into the per-cpu cpc_regs[]. Order is important. */
enum cppc_regs {
HIGHEST_PERF ,
NOMINAL_PERF ,
LOW_NON_LINEAR_PERF ,
LOWEST_PERF ,
GUARANTEED_PERF ,
DESIRED_PERF ,
MIN_PERF ,
MAX_PERF ,
PERF_REDUC_TOLERANCE ,
TIME_WINDOW ,
CTR_WRAP_TIME ,
REFERENCE_CTR ,
DELIVERED_CTR ,
PERF_LIMITED ,
ENABLE ,
AUTO_SEL_ENABLE ,
AUTO_ACT_WINDOW ,
ENERGY_PERF ,
REFERENCE_PERF ,
2018-04-04 21:14:50 +03:00
LOWEST_FREQ ,
NOMINAL_FREQ ,
2015-10-02 17:01:19 +03:00
} ;
/*
* Categorization of registers as described
* in the ACPI v .5 .1 spec .
* XXX : Only filling up ones which are used by governors
* today .
*/
struct cppc_perf_caps {
2018-10-15 20:37:19 +03:00
u32 guaranteed_perf ;
2015-10-02 17:01:19 +03:00
u32 highest_perf ;
u32 nominal_perf ;
u32 lowest_perf ;
2017-03-29 22:49:59 +03:00
u32 lowest_nonlinear_perf ;
2018-04-04 21:14:50 +03:00
u32 lowest_freq ;
u32 nominal_freq ;
2015-10-02 17:01:19 +03:00
} ;
struct cppc_perf_ctrls {
u32 max_perf ;
u32 min_perf ;
u32 desired_perf ;
} ;
struct cppc_perf_fb_ctrs {
u64 reference ;
u64 delivered ;
2016-08-16 23:39:42 +03:00
u64 reference_perf ;
2017-03-29 22:50:00 +03:00
u64 wraparound_time ;
2015-10-02 17:01:19 +03:00
} ;
/* Per CPU container for runtime CPPC management. */
2016-09-01 23:37:11 +03:00
struct cppc_cpudata {
2015-10-02 17:01:19 +03:00
int cpu ;
struct cppc_perf_caps perf_caps ;
struct cppc_perf_ctrls perf_ctrls ;
struct cppc_perf_fb_ctrs perf_fb_ctrs ;
struct cpufreq_policy * cur_policy ;
unsigned int shared_type ;
cpumask_var_t shared_cpu_map ;
} ;
2019-02-17 06:54:14 +03:00
extern int cppc_get_desired_perf ( int cpunum , u64 * desired_perf ) ;
2015-10-02 17:01:19 +03:00
extern int cppc_get_perf_ctrs ( int cpu , struct cppc_perf_fb_ctrs * perf_fb_ctrs ) ;
extern int cppc_set_perf ( int cpu , struct cppc_perf_ctrls * perf_ctrls ) ;
extern int cppc_get_perf_caps ( int cpu , struct cppc_perf_caps * caps ) ;
2016-09-01 23:37:11 +03:00
extern int acpi_get_psd_map ( struct cppc_cpudata * * ) ;
2016-08-16 23:39:41 +03:00
extern unsigned int cppc_get_transition_latency ( int cpu ) ;
2018-12-05 02:34:56 +03:00
extern bool cpc_ffh_supported ( void ) ;
extern int cpc_read_ffh ( int cpunum , struct cpc_reg * reg , u64 * val ) ;
extern int cpc_write_ffh ( int cpunum , struct cpc_reg * reg , u64 val ) ;
2015-10-02 17:01:19 +03:00
# endif /* _CPPC_ACPI_H*/