1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_PCI_PWR_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_PCI_PWR_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/epm.h> 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 35*7c478bd9Sstevel@tonic-gate extern "C" { 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate /* 39*7c478bd9Sstevel@tonic-gate * An element of this structure type is allocated for 40*7c478bd9Sstevel@tonic-gate * each PCI child to track power info. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate typedef struct pci_pwr_chld { 43*7c478bd9Sstevel@tonic-gate dev_info_t *dip; /* node this struct represents */ 44*7c478bd9Sstevel@tonic-gate int dev_cap; 45*7c478bd9Sstevel@tonic-gate /* The clock capability the device */ 46*7c478bd9Sstevel@tonic-gate /* reports it can operate. */ 47*7c478bd9Sstevel@tonic-gate int bus_speed; 48*7c478bd9Sstevel@tonic-gate /* the speed of the bus for this */ 49*7c478bd9Sstevel@tonic-gate /* device during E* */ 50*7c478bd9Sstevel@tonic-gate struct pci_pwr_chld *next; /* link to next item on list */ 51*7c478bd9Sstevel@tonic-gate int flags; /* State for entire device */ 52*7c478bd9Sstevel@tonic-gate int *comp_pwr; /* state for each component */ 53*7c478bd9Sstevel@tonic-gate int num_comps; /* size of comp_pwr */ 54*7c478bd9Sstevel@tonic-gate int u01; /* # comps in UNKNOWN, D0, D1 */ 55*7c478bd9Sstevel@tonic-gate } pci_pwr_chld_t; 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * For each PCI nexus instance that is PM capable, it will have 59*7c478bd9Sstevel@tonic-gate * the following structure allocated. 60*7c478bd9Sstevel@tonic-gate */ 61*7c478bd9Sstevel@tonic-gate typedef struct pci_pwr { 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * cpr and power management support: 64*7c478bd9Sstevel@tonic-gate */ 65*7c478bd9Sstevel@tonic-gate kmutex_t pwr_mutex; 66*7c478bd9Sstevel@tonic-gate int current_lvl; /* power level of bus */ 67*7c478bd9Sstevel@tonic-gate dev_info_t *pwr_dip; /* dip of nexus */ 68*7c478bd9Sstevel@tonic-gate pci_pwr_chld_t *pwr_info; /* linked list of children */ 69*7c478bd9Sstevel@tonic-gate int pwr_flags; /* power management flags */ 70*7c478bd9Sstevel@tonic-gate int pwr_fp; /* # requiring full power */ 71*7c478bd9Sstevel@tonic-gate int pwr_uk; /* # at unknown PM state */ 72*7c478bd9Sstevel@tonic-gate int pwr_d0; /* # at d0 PM state */ 73*7c478bd9Sstevel@tonic-gate int pwr_d1; /* # at d1 PM state */ 74*7c478bd9Sstevel@tonic-gate int pwr_d2; /* # at d2 PM state */ 75*7c478bd9Sstevel@tonic-gate int pwr_d3; /* # at d3 PM state */ 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate } pci_pwr_t; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate #define PCI_CLK_SETTLE_TIME 10000 /* settle time before PCI operation */ 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate /* 82*7c478bd9Sstevel@tonic-gate * ret this if unable to det slot speed while in slow mode 83*7c478bd9Sstevel@tonic-gate */ 84*7c478bd9Sstevel@tonic-gate #define INVALID_BUS_SPEED -1 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * XXX Number of components for dip. This needs to be provided by DDI. 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate #define PM_NUMCMPTS(dip) (DEVI(dip)->devi_pm_num_components) 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* 92*7c478bd9Sstevel@tonic-gate * Label for component 0 93*7c478bd9Sstevel@tonic-gate */ 94*7c478bd9Sstevel@tonic-gate #define PCI_PM_COMP_0 0 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * Bus levels returned by pci_pwr_new_lvl(). In addition to 98*7c478bd9Sstevel@tonic-gate * PM_LEVEL_B[0-3], a level is needed for variable clock 99*7c478bd9Sstevel@tonic-gate * mode. These levels MUST correspond to the levels specified 100*7c478bd9Sstevel@tonic-gate * in the pm-components property. 101*7c478bd9Sstevel@tonic-gate */ 102*7c478bd9Sstevel@tonic-gate #define PM_LEVEL_DYN 1 103*7c478bd9Sstevel@tonic-gate #define PM_LEVEL_B3 0 104*7c478bd9Sstevel@tonic-gate #define PM_LEVEL_B2 1 105*7c478bd9Sstevel@tonic-gate #define PM_LEVEL_B1 2 106*7c478bd9Sstevel@tonic-gate #define PM_LEVEL_B0 3 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* 109*7c478bd9Sstevel@tonic-gate * PCI clock speeds for slow mode (expressed in KHz) 110*7c478bd9Sstevel@tonic-gate */ 111*7c478bd9Sstevel@tonic-gate #define PCI_1MHZ 1000 112*7c478bd9Sstevel@tonic-gate #define PCI_4MHZ (4 * PCI_1MHZ) 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* 115*7c478bd9Sstevel@tonic-gate * Bit values for struct pci_pwr.pwr_flags 116*7c478bd9Sstevel@tonic-gate */ 117*7c478bd9Sstevel@tonic-gate #define PCI_PWR_PARKING 0x01 /* Need to re-enable parking */ 118*7c478bd9Sstevel@tonic-gate #define PCI_PWR_SLOW_CAPABLE 0x02 /* HW supports reduced clock speeds */ 119*7c478bd9Sstevel@tonic-gate #define PCI_PWR_B1_CAPABLE 0x04 /* HW supports B1 state */ 120*7c478bd9Sstevel@tonic-gate #define PCI_PWR_B2_CAPABLE 0x08 /* HW supports B2 state */ 121*7c478bd9Sstevel@tonic-gate #define PCI_PWR_B3_CAPABLE 0x10 /* HW supports B3 state */ 122*7c478bd9Sstevel@tonic-gate #define PCI_PWR_COMP_BUSY 0x20 /* component set busy */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * State flags for each device (struct pci_pwr_chld.flags) 126*7c478bd9Sstevel@tonic-gate */ 127*7c478bd9Sstevel@tonic-gate #define PWR_FP_HOLD 0x01 /* pwr_fp counted for this dev */ 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* 130*7c478bd9Sstevel@tonic-gate * Arbitrary level that pci_pwr_chld.comp_pwr is initialized 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate #define PM_LEVEL_NOLEVEL -2 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate #define PM_CAPABLE(pwr_p) (pwr_p != NULL) 135*7c478bd9Sstevel@tonic-gate #define SLOW_CAPABLE(pwr_p) ((pwr_p->pwr_flags &\ 136*7c478bd9Sstevel@tonic-gate PCI_PWR_SLOW_CAPABLE) ==\ 137*7c478bd9Sstevel@tonic-gate PCI_PWR_SLOW_CAPABLE) 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate /* 140*7c478bd9Sstevel@tonic-gate * Binary prop used by suspend/resume if it saved config regs 141*7c478bd9Sstevel@tonic-gate */ 142*7c478bd9Sstevel@tonic-gate #define NEXUS_SAVED "nexus-saved-config-regs" 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate extern void pci_pwr_component_busy(pci_pwr_t *pwr_p); 145*7c478bd9Sstevel@tonic-gate extern void pci_pwr_component_idle(pci_pwr_t *pwr_p); 146*7c478bd9Sstevel@tonic-gate extern int pci_pwr_current_lvl(pci_pwr_t *pwr_p); 147*7c478bd9Sstevel@tonic-gate extern int pci_pwr_new_lvl(pci_pwr_t *pwr_p); 148*7c478bd9Sstevel@tonic-gate extern int pci_pwr_ops(pci_pwr_t *pwr_p, dev_info_t *dip, void *impl_arg, 149*7c478bd9Sstevel@tonic-gate pm_bus_power_op_t op, void *arg, void *result); 150*7c478bd9Sstevel@tonic-gate extern pci_pwr_chld_t *pci_pwr_get_info(pci_pwr_t *pwr_p, dev_info_t *); 151*7c478bd9Sstevel@tonic-gate extern void pci_pwr_create_info(pci_pwr_t *pwr_p, dev_info_t *); 152*7c478bd9Sstevel@tonic-gate extern void pci_pwr_rm_info(pci_pwr_t *pwr_p, dev_info_t *); 153*7c478bd9Sstevel@tonic-gate extern void pci_pwr_add_components(pci_pwr_t *pwr_p, dev_info_t *dip, 154*7c478bd9Sstevel@tonic-gate pci_pwr_chld_t *p); 155*7c478bd9Sstevel@tonic-gate extern void pci_pwr_resume(dev_info_t *dip, pci_pwr_t *pwr_p); 156*7c478bd9Sstevel@tonic-gate extern void pci_pwr_suspend(dev_info_t *dip, pci_pwr_t *pwr_p); 157*7c478bd9Sstevel@tonic-gate extern void pci_pwr_component_busy(pci_pwr_t *p); 158*7c478bd9Sstevel@tonic-gate extern void pci_pwr_component_idle(pci_pwr_t *p); 159*7c478bd9Sstevel@tonic-gate extern void pci_pwr_change(pci_pwr_t *pwr_p, int current, int new); 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 162*7c478bd9Sstevel@tonic-gate } 163*7c478bd9Sstevel@tonic-gate #endif 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate #endif /* _SYS_PCI_PWR_H */ 166