10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*946Smathue * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_UPA64S_VAR_H 280Sstevel@tonic-gate #define _SYS_UPA64S_VAR_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #define HI32(x) ((uint32_t)(((uint64_t)(x)) >> 32)) 37*946Smathue #define LO32(x) ((uint32_t)(uintptr_t)(x)) 380Sstevel@tonic-gate #define UPA64S_PORTS 2 /* number of UPA ports per device */ 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* 410Sstevel@tonic-gate * the following typedef is used to describe the state 420Sstevel@tonic-gate * of a UPA port interrupt. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate typedef enum { INO_FREE = 0, INO_INUSE } ino_state_t; 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* 470Sstevel@tonic-gate * INO related macros: 480Sstevel@tonic-gate */ 490Sstevel@tonic-gate #define UPA64S_MAKE_MONDO(id, ino) ((id) << 6 | (ino)) 500Sstevel@tonic-gate #define UPA64S_MONDO_TO_INO(mondo) ((mondo) & 0x3f) 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* 530Sstevel@tonic-gate * Interrupt Mapping Registers 540Sstevel@tonic-gate */ 550Sstevel@tonic-gate #define IMR_MONDO 0x7ff 560Sstevel@tonic-gate #define IMR_TID_BIT 26 570Sstevel@tonic-gate #define IMR_TID (0x1f << IMR_TID_BIT) 580Sstevel@tonic-gate #define IMR_VALID (1u << 31) 590Sstevel@tonic-gate #define UPA64S_IMR_TO_CPUID(imr) (((imr) & IMR_TID) >> IMR_TID_BIT) 600Sstevel@tonic-gate #define UPA64S_IMR_TO_MONDO(imr) ((imr) & IMR_MONDO) 610Sstevel@tonic-gate #define UPA64S_CPUID_TO_IMR(cpuid) ((cpuid) << IMR_TID_BIT) 620Sstevel@tonic-gate #define UPA64S_GET_MAP_REG(mondo, imr) ((mondo) | (imr) | IMR_VALID) 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * The following structure defines the format of UPA64S addresses. 660Sstevel@tonic-gate * This structure is used to hold UPA64S "reg" property entries. 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate typedef struct upa64s_regspec { 690Sstevel@tonic-gate uint64_t upa64s_phys; 700Sstevel@tonic-gate uint64_t upa64s_size; 710Sstevel@tonic-gate } upa64s_regspec_t; 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * The following structure defines the format of a "ranges" 750Sstevel@tonic-gate * property entry for UPA64S bus node. 760Sstevel@tonic-gate */ 770Sstevel@tonic-gate typedef struct upa64s_ranges { 780Sstevel@tonic-gate uint64_t upa64s_child; 790Sstevel@tonic-gate uint64_t upa64s_parent; 800Sstevel@tonic-gate uint64_t upa64s_size; 810Sstevel@tonic-gate } upa64s_ranges_t; 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * per-upa64s soft state structure: 850Sstevel@tonic-gate */ 860Sstevel@tonic-gate typedef struct upa64s_devstate { 870Sstevel@tonic-gate dev_info_t *dip; /* devinfo structure */ 880Sstevel@tonic-gate uint_t safari_id; /* safari device id */ 890Sstevel@tonic-gate 900Sstevel@tonic-gate ino_state_t ino_state[UPA64S_PORTS]; /* INO state */ 910Sstevel@tonic-gate uint64_t *imr[UPA64S_PORTS]; /* Intr mapping reg; treat */ 920Sstevel@tonic-gate /* as two element array */ 930Sstevel@tonic-gate ddi_acc_handle_t imr_ah[UPA64S_PORTS]; /* Mapping handle */ 940Sstevel@tonic-gate uint64_t imr_data[UPA64S_PORTS]; /* imr save/restore area */ 950Sstevel@tonic-gate 960Sstevel@tonic-gate caddr_t config_base; /* conf base address */ 970Sstevel@tonic-gate uint64_t *upa0_config; /* UPA 0 config */ 980Sstevel@tonic-gate uint64_t *upa1_config; /* UPA 1 config */ 990Sstevel@tonic-gate uint64_t *if_config; /* UPA inteface config */ 1000Sstevel@tonic-gate uint64_t *estar; /* UPA estar control */ 1010Sstevel@tonic-gate ddi_acc_handle_t config_base_ah; /* config acc handle */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate int power_level; /* upa64s' power level */ 1040Sstevel@tonic-gate int saved_power_level; /* power level during suspend */ 1050Sstevel@tonic-gate } upa64s_devstate_t; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* 1080Sstevel@tonic-gate * UPA64S Register Offsets 1090Sstevel@tonic-gate */ 1100Sstevel@tonic-gate #define UPA64S_UPA0_CONFIG_OFFSET 0x00 1110Sstevel@tonic-gate #define UPA64S_UPA1_CONFIG_OFFSET 0x08 1120Sstevel@tonic-gate #define UPA64S_IF_CONFIG_OFFSET 0x10 1130Sstevel@tonic-gate #define UPA64S_ESTAR_OFFSET 0x18 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* 1160Sstevel@tonic-gate * UPA64S Interface Configurations 1170Sstevel@tonic-gate */ 1180Sstevel@tonic-gate #define UPA64S_NOT_POK_RST_L 0x0 1190Sstevel@tonic-gate #define UPA64S_POK_RST_L 0x2 1200Sstevel@tonic-gate #define UPA64S_POK_NOT_RST_L 0x3 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* 1230Sstevel@tonic-gate * UPA64S Energy Star Control Register 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate #define UPA64S_FULL_SPEED 0x01 1260Sstevel@tonic-gate #define UPA64S_1_2_SPEED 0x02 1270Sstevel@tonic-gate #define UPA64S_1_64_SPEED 0x40 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* 1300Sstevel@tonic-gate * Power Management definitions 1310Sstevel@tonic-gate */ 1320Sstevel@tonic-gate #define UPA64S_PM_COMP 0 /* power management component */ 1330Sstevel@tonic-gate #define UPA64S_PM_UNKNOWN -1 /* power unknown */ 1340Sstevel@tonic-gate #define UPA64S_PM_RESET 0 /* power off */ 1350Sstevel@tonic-gate #define UPA64S_PM_NORMOP 1 /* power on */ 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* 1380Sstevel@tonic-gate * upa64s soft state macros: 1390Sstevel@tonic-gate */ 1400Sstevel@tonic-gate #define get_upa64s_soft_state(i) \ 1410Sstevel@tonic-gate ((upa64s_devstate_t *)ddi_get_soft_state(per_upa64s_state, (i))) 1420Sstevel@tonic-gate #define alloc_upa64s_soft_state(i) \ 1430Sstevel@tonic-gate ddi_soft_state_zalloc(per_upa64s_state, (i)) 1440Sstevel@tonic-gate #define free_upa64s_soft_state(i) \ 1450Sstevel@tonic-gate ddi_soft_state_free(per_upa64s_state, (i)) 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* 1480Sstevel@tonic-gate * debugging definitions: 1490Sstevel@tonic-gate */ 1500Sstevel@tonic-gate #if defined(DEBUG) 1510Sstevel@tonic-gate #define D_ATTACH 0x00000001 1520Sstevel@tonic-gate #define D_DETACH 0x00000002 1530Sstevel@tonic-gate #define D_POWER 0x00000004 1540Sstevel@tonic-gate #define D_MAP 0x00000008 1550Sstevel@tonic-gate #define D_CTLOPS 0x00000010 1560Sstevel@tonic-gate #define D_G_ISPEC 0x00000020 1570Sstevel@tonic-gate #define D_A_ISPEC 0x00000040 1580Sstevel@tonic-gate #define D_R_ISPEC 0x00000080 1590Sstevel@tonic-gate #define D_INIT_CLD 0x00400000 1600Sstevel@tonic-gate #define D_RM_CLD 0x00800000 1610Sstevel@tonic-gate #define D_GET_REG 0x01000000 1620Sstevel@tonic-gate #define D_XLATE_REG 0x02000000 1630Sstevel@tonic-gate #define D_INTRDIST 0x04000000 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate #define D_CONT 0x80000000 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate #define DBG(flag, psp, fmt) \ 1680Sstevel@tonic-gate upa64s_debug(flag, psp, fmt, 0, 0, 0, 0, 0); 1690Sstevel@tonic-gate #define DBG1(flag, psp, fmt, a1) \ 1700Sstevel@tonic-gate upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), 0, 0, 0, 0); 1710Sstevel@tonic-gate #define DBG2(flag, psp, fmt, a1, a2) \ 1720Sstevel@tonic-gate upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0); 1730Sstevel@tonic-gate #define DBG3(flag, psp, fmt, a1, a2, a3) \ 1740Sstevel@tonic-gate upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1750Sstevel@tonic-gate (uintptr_t)(a3), 0, 0); 1760Sstevel@tonic-gate #define DBG4(flag, psp, fmt, a1, a2, a3, a4) \ 1770Sstevel@tonic-gate upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1780Sstevel@tonic-gate (uintptr_t)(a3), (uintptr_t)(a4), 0); 1790Sstevel@tonic-gate #define DBG5(flag, psp, fmt, a1, a2, a3, a4, a5) \ 1800Sstevel@tonic-gate upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \ 1810Sstevel@tonic-gate (uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5)); 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate static void upa64s_debug(uint_t, dev_info_t *, char *, uintptr_t, uintptr_t, \ 1840Sstevel@tonic-gate uintptr_t, uintptr_t, uintptr_t); 1850Sstevel@tonic-gate #else 1860Sstevel@tonic-gate #define DBG(flag, psp, fmt) 1870Sstevel@tonic-gate #define DBG1(flag, psp, fmt, a1) 1880Sstevel@tonic-gate #define DBG2(flag, psp, fmt, a1, a2) 1890Sstevel@tonic-gate #define DBG3(flag, psp, fmt, a1, a2, a3) 1900Sstevel@tonic-gate #define DBG4(flag, psp, fmt, a1, a2, a3, a4) 1910Sstevel@tonic-gate #define DBG5(flag, psp, fmt, a1, a2, a3, a4, a5) 1920Sstevel@tonic-gate #define dump_dma_handle(flag, psp, h) 1930Sstevel@tonic-gate #endif 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate #ifdef __cplusplus 1960Sstevel@tonic-gate } 1970Sstevel@tonic-gate #endif 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate #endif /* _SYS_UPA64S_VAR_H */ 200