Home | History | Annotate | Line # | Download | only in acpi
acpi_cpu.h revision 1.28.4.1
      1  1.28.4.1  bouyer /* $NetBSD: acpi_cpu.h,v 1.28.4.1 2011/03/05 15:10:16 bouyer Exp $ */
      2       1.1  jruoho 
      3       1.1  jruoho /*-
      4  1.28.4.1  bouyer  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen (at) iki.fi>
      5       1.1  jruoho  * All rights reserved.
      6       1.1  jruoho  *
      7       1.1  jruoho  * Redistribution and use in source and binary forms, with or without
      8       1.1  jruoho  * modification, are permitted provided that the following conditions
      9       1.1  jruoho  * are met:
     10       1.1  jruoho  *
     11       1.1  jruoho  * 1. Redistributions of source code must retain the above copyright
     12       1.1  jruoho  *    notice, this list of conditions and the following disclaimer.
     13       1.1  jruoho  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1  jruoho  *    notice, this list of conditions and the following disclaimer in the
     15       1.1  jruoho  *    documentation and/or other materials provided with the distribution.
     16       1.1  jruoho  *
     17       1.1  jruoho  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     18       1.1  jruoho  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19       1.1  jruoho  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20       1.1  jruoho  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     21       1.1  jruoho  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22       1.1  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23       1.1  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24       1.1  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25       1.1  jruoho  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26       1.1  jruoho  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27       1.1  jruoho  * SUCH DAMAGE.
     28       1.1  jruoho  */
     29       1.1  jruoho 
     30       1.1  jruoho #ifndef _SYS_DEV_ACPI_ACPI_CPU_H
     31       1.1  jruoho #define _SYS_DEV_ACPI_ACPI_CPU_H
     32       1.1  jruoho 
     33       1.1  jruoho /*
     34       1.1  jruoho  * The following _PDC values are based on:
     35       1.1  jruoho  *
     36       1.9  jruoho  * 	Intel Corporation: Intel Processor-Specific ACPI
     37       1.9  jruoho  *	Interface Specification, September 2006, Revision 005.
     38       1.1  jruoho  */
     39       1.1  jruoho #define ACPICPU_PDC_REVID         0x1
     40       1.1  jruoho #define ACPICPU_PDC_SMP           0xA
     41       1.1  jruoho #define ACPICPU_PDC_MSR           0x1
     42       1.1  jruoho 
     43       1.1  jruoho #define ACPICPU_PDC_P_FFH         __BIT(0)	/* SpeedStep MSRs            */
     44       1.1  jruoho #define ACPICPU_PDC_C_C1_HALT     __BIT(1)	/* C1 "I/O then halt"        */
     45       1.1  jruoho #define ACPICPU_PDC_T_FFH         __BIT(2)	/* OnDemand throttling MSRs  */
     46       1.1  jruoho #define ACPICPU_PDC_C_C1PT        __BIT(3)	/* SMP C1, Px, and Tx (same) */
     47       1.1  jruoho #define ACPICPU_PDC_C_C2C3        __BIT(4)	/* SMP C2 and C3 (same)      */
     48       1.1  jruoho #define ACPICPU_PDC_P_SW          __BIT(5)	/* SMP Px (different)        */
     49       1.1  jruoho #define ACPICPU_PDC_C_SW          __BIT(6)	/* SMP Cx (different)        */
     50       1.1  jruoho #define ACPICPU_PDC_T_SW          __BIT(7)	/* SMP Tx (different)        */
     51       1.1  jruoho #define ACPICPU_PDC_C_C1_FFH      __BIT(8)	/* SMP C1 native beyond halt */
     52       1.1  jruoho #define ACPICPU_PDC_C_C2C3_FFH    __BIT(9)	/* SMP C2 and C2 native      */
     53  1.28.4.1  bouyer #define ACPICPU_PDC_P_HWF         __BIT(11)	/* Px hardware feedback      */
     54       1.1  jruoho 
     55       1.6  jruoho #define ACPICPU_PDC_GAS_HW	  __BIT(0)	/* HW-coordinated state      */
     56       1.6  jruoho #define ACPICPU_PDC_GAS_BM	  __BIT(1)	/* Bus master check required */
     57       1.5  jruoho 
     58       1.5  jruoho /*
     59       1.1  jruoho  * Notify values.
     60       1.1  jruoho  */
     61       1.1  jruoho #define ACPICPU_P_NOTIFY	 0x80		/* _PPC */
     62       1.1  jruoho #define ACPICPU_C_NOTIFY	 0x81		/* _CST */
     63       1.1  jruoho #define ACPICPU_T_NOTIFY	 0x82		/* _TPC */
     64       1.1  jruoho 
     65       1.1  jruoho /*
     66  1.28.4.1  bouyer  * Dependency coordination.
     67  1.28.4.1  bouyer  */
     68  1.28.4.1  bouyer #define ACPICPU_DEP_SW_ALL	 0xFC		/* All CPUs must set a state */
     69  1.28.4.1  bouyer #define ACPICPU_DEP_SW_ANY	 0xFD		/* Any CPU can set a state   */
     70  1.28.4.1  bouyer #define ACPICPU_DEP_HW_ALL	 0xFE		/* HW does the coordination  */
     71  1.28.4.1  bouyer 
     72  1.28.4.1  bouyer /*
     73       1.1  jruoho  * C-states.
     74       1.1  jruoho  */
     75       1.1  jruoho #define ACPICPU_C_C2_LATENCY_MAX 100		/* us */
     76       1.1  jruoho #define ACPICPU_C_C3_LATENCY_MAX 1000		/* us */
     77       1.1  jruoho 
     78       1.1  jruoho #define ACPICPU_C_STATE_HALT	 0x01
     79       1.1  jruoho #define ACPICPU_C_STATE_FFH	 0x02
     80       1.1  jruoho #define ACPICPU_C_STATE_SYSIO	 0x03
     81       1.1  jruoho 
     82       1.6  jruoho /*
     83       1.9  jruoho  * P-states.
     84       1.6  jruoho  */
     85      1.13  jruoho #define ACPICPU_P_STATE_MAX	 255		/* Arbitrary upper limit     */
     86       1.9  jruoho #define ACPICPU_P_STATE_RETRY	 100
     87       1.9  jruoho #define ACPICPU_P_STATE_UNKNOWN	 0x0
     88       1.6  jruoho 
     89       1.6  jruoho /*
     90      1.14  jruoho  * T-states.
     91      1.14  jruoho  */
     92      1.14  jruoho #define ACPICPU_T_STATE_MAX	 0x8
     93      1.14  jruoho #define ACPICPU_T_STATE_RETRY	 0xA
     94      1.14  jruoho #define ACPICPU_T_STATE_UNKNOWN	 255
     95      1.14  jruoho 
     96      1.14  jruoho /*
     97       1.6  jruoho  * Flags.
     98       1.6  jruoho  */
     99       1.6  jruoho #define ACPICPU_FLAG_C		 __BIT(0)	/* C-states supported        */
    100       1.6  jruoho #define ACPICPU_FLAG_P		 __BIT(1)	/* P-states supported        */
    101       1.6  jruoho #define ACPICPU_FLAG_T		 __BIT(2)	/* T-states supported        */
    102       1.6  jruoho 
    103      1.15  jruoho #define ACPICPU_FLAG_PIIX4	 __BIT(3)	/* Broken (quirk)	     */
    104      1.15  jruoho 
    105      1.15  jruoho #define ACPICPU_FLAG_C_FFH	 __BIT(4)	/* Native C-states           */
    106      1.15  jruoho #define ACPICPU_FLAG_C_FADT	 __BIT(5)	/* C-states with FADT        */
    107  1.28.4.1  bouyer #define ACPICPU_FLAG_C_DEP	 __BIT(6)	/* C-state CPU coordination  */
    108  1.28.4.1  bouyer #define ACPICPU_FLAG_C_BM	 __BIT(7)	/* Bus master control        */
    109  1.28.4.1  bouyer #define ACPICPU_FLAG_C_BM_STS	 __BIT(8)	/* Bus master check required */
    110  1.28.4.1  bouyer #define ACPICPU_FLAG_C_ARB	 __BIT(9)	/* Bus master arbitration    */
    111  1.28.4.1  bouyer #define ACPICPU_FLAG_C_TSC	 __BIT(10)	/* TSC broken, > C1, Px, Tx  */
    112  1.28.4.1  bouyer #define ACPICPU_FLAG_C_APIC	 __BIT(11)	/* APIC timer broken, > C1   */
    113  1.28.4.1  bouyer #define ACPICPU_FLAG_C_C1E	 __BIT(12)	/* AMD C1E detected	     */
    114  1.28.4.1  bouyer 
    115  1.28.4.1  bouyer #define ACPICPU_FLAG_P_FFH	 __BIT(13)	/* Native P-states           */
    116  1.28.4.1  bouyer #define ACPICPU_FLAG_P_DEP	 __BIT(14)	/* P-state CPU coordination  */
    117  1.28.4.1  bouyer #define ACPICPU_FLAG_P_HWF	 __BIT(15)	/* HW feedback supported     */
    118  1.28.4.1  bouyer #define ACPICPU_FLAG_P_XPSS	 __BIT(16)	/* Microsoft XPSS in use     */
    119  1.28.4.1  bouyer #define ACPICPU_FLAG_P_TURBO	 __BIT(17)	/* Turbo Boost / Turbo Core  */
    120  1.28.4.1  bouyer #define ACPICPU_FLAG_P_FIDVID	 __BIT(18)	/* AMD "FID/VID algorithm"   */
    121  1.28.4.1  bouyer 
    122  1.28.4.1  bouyer #define ACPICPU_FLAG_T_FFH	 __BIT(19)	/* Native throttling         */
    123  1.28.4.1  bouyer #define ACPICPU_FLAG_T_FADT	 __BIT(20)	/* Throttling with FADT      */
    124  1.28.4.1  bouyer #define ACPICPU_FLAG_T_DEP	 __BIT(21)	/* T-state CPU coordination  */
    125       1.9  jruoho 
    126       1.8  jruoho /*
    127       1.8  jruoho  * This is AML_RESOURCE_GENERIC_REGISTER,
    128       1.8  jruoho  * included here separately for convenience.
    129       1.8  jruoho  */
    130       1.8  jruoho struct acpicpu_reg {
    131       1.8  jruoho 	uint8_t			 reg_desc;
    132       1.8  jruoho 	uint16_t		 reg_reslen;
    133       1.8  jruoho 	uint8_t			 reg_spaceid;
    134       1.8  jruoho 	uint8_t			 reg_bitwidth;
    135       1.8  jruoho 	uint8_t			 reg_bitoffset;
    136       1.8  jruoho 	uint8_t			 reg_accesssize;
    137       1.8  jruoho 	uint64_t		 reg_addr;
    138       1.8  jruoho } __packed;
    139       1.8  jruoho 
    140  1.28.4.1  bouyer struct acpicpu_dep {
    141  1.28.4.1  bouyer 	uint32_t		 dep_domain;
    142  1.28.4.1  bouyer 	uint32_t		 dep_type;
    143  1.28.4.1  bouyer 	uint32_t		 dep_ncpus;
    144  1.28.4.1  bouyer 	uint32_t		 dep_index;
    145  1.28.4.1  bouyer };
    146  1.28.4.1  bouyer 
    147       1.1  jruoho struct acpicpu_cstate {
    148      1.12  jruoho 	struct evcnt		 cs_evcnt;
    149      1.12  jruoho 	char			 cs_name[EVCNT_STRING_MAX];
    150       1.1  jruoho 	uint64_t		 cs_addr;
    151      1.16  jruoho 	uint32_t		 cs_power;
    152      1.16  jruoho 	uint32_t		 cs_latency;
    153       1.1  jruoho 	int			 cs_method;
    154       1.5  jruoho 	int			 cs_flags;
    155       1.1  jruoho };
    156       1.1  jruoho 
    157      1.16  jruoho /*
    158      1.16  jruoho  * This structure supports both the conventional _PSS and the
    159      1.16  jruoho  * so-called extended _PSS (XPSS). For the latter, refer to:
    160      1.16  jruoho  *
    161      1.16  jruoho  *	Microsoft Corporation: Extended PSS ACPI
    162      1.16  jruoho  *	Method Specification, April 2, 2007.
    163      1.16  jruoho  */
    164       1.9  jruoho struct acpicpu_pstate {
    165      1.12  jruoho 	struct evcnt		 ps_evcnt;
    166      1.12  jruoho 	char			 ps_name[EVCNT_STRING_MAX];
    167      1.16  jruoho 	uint32_t		 ps_freq;
    168      1.16  jruoho 	uint32_t		 ps_power;
    169      1.16  jruoho 	uint32_t		 ps_latency;
    170      1.16  jruoho 	uint32_t		 ps_latency_bm;
    171      1.16  jruoho 	uint64_t		 ps_control;
    172      1.16  jruoho 	uint64_t		 ps_control_addr;
    173      1.16  jruoho 	uint64_t		 ps_control_mask;
    174      1.16  jruoho 	uint64_t		 ps_status;
    175      1.16  jruoho 	uint64_t		 ps_status_addr;
    176      1.16  jruoho 	uint64_t		 ps_status_mask;
    177      1.16  jruoho 	int			 ps_flags;
    178       1.1  jruoho };
    179       1.1  jruoho 
    180      1.14  jruoho struct acpicpu_tstate {
    181      1.14  jruoho 	struct evcnt		 ts_evcnt;
    182      1.14  jruoho 	char			 ts_name[EVCNT_STRING_MAX];
    183      1.16  jruoho 	uint32_t		 ts_percent;
    184      1.16  jruoho 	uint32_t		 ts_power;
    185      1.16  jruoho 	uint32_t		 ts_latency;
    186      1.14  jruoho 	uint32_t		 ts_control;
    187      1.14  jruoho 	uint32_t		 ts_status;
    188      1.14  jruoho };
    189      1.14  jruoho 
    190       1.1  jruoho struct acpicpu_object {
    191       1.1  jruoho 	uint32_t		 ao_procid;
    192       1.1  jruoho 	uint32_t		 ao_pblklen;
    193       1.1  jruoho 	uint32_t		 ao_pblkaddr;
    194       1.1  jruoho };
    195       1.1  jruoho 
    196       1.1  jruoho struct acpicpu_softc {
    197       1.1  jruoho 	device_t		 sc_dev;
    198  1.28.4.1  bouyer 	struct cpu_info		*sc_ci;
    199       1.1  jruoho 	struct acpi_devnode	*sc_node;
    200       1.7  jruoho 	struct acpicpu_object	 sc_object;
    201       1.8  jruoho 
    202       1.1  jruoho 	struct acpicpu_cstate	 sc_cstate[ACPI_C_STATE_COUNT];
    203  1.28.4.1  bouyer 	struct acpicpu_dep	 sc_cstate_dep;
    204       1.8  jruoho 	uint32_t		 sc_cstate_sleep;
    205       1.8  jruoho 
    206       1.9  jruoho 	struct acpicpu_pstate	*sc_pstate;
    207  1.28.4.1  bouyer 	struct acpicpu_dep	 sc_pstate_dep;
    208       1.9  jruoho 	struct acpicpu_reg	 sc_pstate_control;
    209       1.9  jruoho 	struct acpicpu_reg	 sc_pstate_status;
    210  1.28.4.1  bouyer 	uint64_t		 sc_pstate_aperf;	/* ACPICPU_FLAG_P_HW */
    211  1.28.4.1  bouyer 	uint64_t		 sc_pstate_mperf;	/* ACPICPU_FLAG_P_HW*/
    212       1.9  jruoho 	uint32_t		 sc_pstate_current;
    213       1.9  jruoho 	uint32_t		 sc_pstate_count;
    214       1.9  jruoho 	uint32_t		 sc_pstate_max;
    215      1.18  jruoho 	uint32_t		 sc_pstate_min;
    216       1.9  jruoho 
    217      1.14  jruoho 	struct acpicpu_tstate	*sc_tstate;
    218  1.28.4.1  bouyer 	struct acpicpu_dep	 sc_tstate_dep;
    219      1.14  jruoho 	struct acpicpu_reg	 sc_tstate_control;
    220      1.14  jruoho 	struct acpicpu_reg	 sc_tstate_status;
    221      1.14  jruoho 	uint32_t		 sc_tstate_current;
    222      1.14  jruoho 	uint32_t		 sc_tstate_count;
    223      1.14  jruoho 	uint32_t		 sc_tstate_max;
    224      1.14  jruoho 	uint32_t		 sc_tstate_min;
    225      1.14  jruoho 
    226  1.28.4.1  bouyer 	__cpu_simple_lock_t	 sc_lock;
    227       1.8  jruoho 	kmutex_t		 sc_mtx;
    228       1.1  jruoho 	uint32_t		 sc_cap;
    229  1.28.4.1  bouyer 	uint32_t		 sc_ncpus;
    230       1.1  jruoho 	uint32_t		 sc_flags;
    231       1.7  jruoho 	bool			 sc_cold;
    232       1.1  jruoho };
    233       1.1  jruoho 
    234  1.28.4.1  bouyer void		 acpicpu_cstate_attach(device_t);
    235  1.28.4.1  bouyer int		 acpicpu_cstate_detach(device_t);
    236  1.28.4.1  bouyer void		 acpicpu_cstate_start(device_t);
    237  1.28.4.1  bouyer bool		 acpicpu_cstate_suspend(device_t);
    238  1.28.4.1  bouyer bool		 acpicpu_cstate_resume(device_t);
    239  1.28.4.1  bouyer void		 acpicpu_cstate_callback(void *);
    240  1.28.4.1  bouyer void		 acpicpu_cstate_idle(void);
    241  1.28.4.1  bouyer 
    242  1.28.4.1  bouyer void		 acpicpu_pstate_attach(device_t);
    243  1.28.4.1  bouyer int		 acpicpu_pstate_detach(device_t);
    244  1.28.4.1  bouyer void		 acpicpu_pstate_start(device_t);
    245  1.28.4.1  bouyer bool		 acpicpu_pstate_suspend(device_t);
    246  1.28.4.1  bouyer bool		 acpicpu_pstate_resume(device_t);
    247  1.28.4.1  bouyer void		 acpicpu_pstate_callback(void *);
    248  1.28.4.1  bouyer int		 acpicpu_pstate_get(struct cpu_info *, uint32_t *);
    249  1.28.4.1  bouyer void		 acpicpu_pstate_set(struct cpu_info *, uint32_t);
    250  1.28.4.1  bouyer 
    251  1.28.4.1  bouyer void		 acpicpu_tstate_attach(device_t);
    252  1.28.4.1  bouyer int		 acpicpu_tstate_detach(device_t);
    253  1.28.4.1  bouyer void		 acpicpu_tstate_start(device_t);
    254  1.28.4.1  bouyer bool		 acpicpu_tstate_suspend(device_t);
    255  1.28.4.1  bouyer bool		 acpicpu_tstate_resume(device_t);
    256  1.28.4.1  bouyer void		 acpicpu_tstate_callback(void *);
    257  1.28.4.1  bouyer int		 acpicpu_tstate_get(struct cpu_info *, uint32_t *);
    258  1.28.4.1  bouyer void		 acpicpu_tstate_set(struct cpu_info *, uint32_t);
    259  1.28.4.1  bouyer 
    260  1.28.4.1  bouyer struct cpu_info *acpicpu_md_match(device_t, cfdata_t, void *);
    261  1.28.4.1  bouyer struct cpu_info *acpicpu_md_attach(device_t, device_t, void *);
    262  1.28.4.1  bouyer 
    263  1.28.4.1  bouyer uint32_t	 acpicpu_md_cap(void);
    264  1.28.4.1  bouyer uint32_t	 acpicpu_md_flags(void);
    265  1.28.4.1  bouyer void		 acpicpu_md_quirk_c1e(void);
    266  1.28.4.1  bouyer int		 acpicpu_md_cstate_start(struct acpicpu_softc *);
    267  1.28.4.1  bouyer int		 acpicpu_md_cstate_stop(void);
    268  1.28.4.1  bouyer void		 acpicpu_md_cstate_enter(int, int);
    269  1.28.4.1  bouyer int		 acpicpu_md_pstate_start(struct acpicpu_softc *);
    270  1.28.4.1  bouyer int		 acpicpu_md_pstate_stop(void);
    271  1.28.4.1  bouyer int		 acpicpu_md_pstate_init(struct acpicpu_softc *);
    272  1.28.4.1  bouyer uint8_t		 acpicpu_md_pstate_percent(struct cpu_info *);
    273  1.28.4.1  bouyer int		 acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
    274  1.28.4.1  bouyer int		 acpicpu_md_pstate_set(struct acpicpu_pstate *);
    275  1.28.4.1  bouyer int		 acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);
    276  1.28.4.1  bouyer int		 acpicpu_md_tstate_set(struct acpicpu_tstate *);
    277       1.1  jruoho 
    278       1.1  jruoho #endif	/* !_SYS_DEV_ACPI_ACPI_CPU_H */
    279