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 2000-2001, 2003 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_HPC3130_DAK_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_HPC3130_DAK_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include <sys/i2c/clients/i2c_client.h> 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate /* masks */ 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #define HPC3130_PROTECT_ON 0x01 /* (R/W) protection enable mechanism */ 43*7c478bd9Sstevel@tonic-gate #define HPC3130_SYSM66STAT 0x02 /* (R) indicates bus runs at 66Mhz */ 44*7c478bd9Sstevel@tonic-gate #define HPC3130_SEQUENCING 0x0c /* (R/W) hotplug sequencing mode */ 45*7c478bd9Sstevel@tonic-gate #define HPC3130_MANUAL_SEQ 0x00 /* controle with idividual register calls */ 46*7c478bd9Sstevel@tonic-gate #define HPC3130_AUTO1_SEQ 0x04 /* enable CBT before disable RST# */ 47*7c478bd9Sstevel@tonic-gate #define HPC3130_AUTO2_SEQ 0x08 /* enable CBT after disable RST# */ 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #define HPC3130_GCR 0x00 50*7c478bd9Sstevel@tonic-gate #define HPC3130_STATUS 0x01 51*7c478bd9Sstevel@tonic-gate #define HPC3130_CONTROL 0x02 52*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTEN 0x03 53*7c478bd9Sstevel@tonic-gate #define HPC3130_EVENT_STATUS 0x06 54*7c478bd9Sstevel@tonic-gate #define HPC3130_INTERRUPT 0x07 55*7c478bd9Sstevel@tonic-gate #define HPC3130_NO_REGISTER 0xff 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * masks 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate #define HPC3130_PRSNT1 0x01 /* (R) Logic level of PRSNT1# signal */ 61*7c478bd9Sstevel@tonic-gate #define HPC3130_PRSNT2 0x02 /* (R) Logic level of PRSNT2# signal */ 62*7c478bd9Sstevel@tonic-gate #define HPC3130_DETECT0 0x04 /* (R) Logic level of DETECT0# signal */ 63*7c478bd9Sstevel@tonic-gate #define HPC3130_DETECT1 0x08 /* (R) Logic level of DETECT1# signal */ 64*7c478bd9Sstevel@tonic-gate #define HPC3130_PWRFAULT 0x10 /* (R) Logic level of PWRFAULT# signal */ 65*7c478bd9Sstevel@tonic-gate #define HPC3130_PWRGOOD 0x20 /* (R) Logic level of PWRGOOD# signal */ 66*7c478bd9Sstevel@tonic-gate #define HPC3130_M66EN 0x40 /* (R) Logic level of M66EN terminal */ 67*7c478bd9Sstevel@tonic-gate #define HPC3130_BUSON 0x80 /* (R) Logic level of BUSON# signal */ 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate /* 71*7c478bd9Sstevel@tonic-gate * more masks 72*7c478bd9Sstevel@tonic-gate */ 73*7c478bd9Sstevel@tonic-gate /* (R/W) Logical level of SLOTRST# (used to reset a slot) */ 74*7c478bd9Sstevel@tonic-gate #define HPC3130_SLOTRST 0x01 75*7c478bd9Sstevel@tonic-gate /* (R/W) Logical level of CLKON# (used to control clock signal) */ 76*7c478bd9Sstevel@tonic-gate #define HPC3130_CLKON 0x02 77*7c478bd9Sstevel@tonic-gate /* (R/W) Logical level of REQ64ON# signal */ 78*7c478bd9Sstevel@tonic-gate #define HPC3130_REQ64 0x04 79*7c478bd9Sstevel@tonic-gate /* (R/W) Logical level of SLOTREQ64# signal */ 80*7c478bd9Sstevel@tonic-gate #define HPC3130_SLOTREQ64 0x08 81*7c478bd9Sstevel@tonic-gate /* (R/W) Bus control (for auto sequence level==1?disconnect:connect */ 82*7c478bd9Sstevel@tonic-gate #define HPC3130_BUS_CTL 0x10 83*7c478bd9Sstevel@tonic-gate /* (R/W) Logical level of power control on the slot */ 84*7c478bd9Sstevel@tonic-gate #define HPC3130_SLTPWRCTL 0x20 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN0 0x00 88*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN1 0x01 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate #define HPC3130_LED_FAULT HPC3130_ATTN1 91*7c478bd9Sstevel@tonic-gate #define HPC3130_LED_OK2REM HPC3130_ATTN0 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN_MASK(led) (3<<(HPC3130_ATTN_SHIFT(led))) /* 3 or c */ 94*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN_SHIFT(led) (led<<1) /* 0 or 2 */ 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN_OFF 0x00 97*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN_SLO 0x01 /* not used by Daktari */ 98*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN_FST 0x02 99*7c478bd9Sstevel@tonic-gate #define HPC3130_ATTN_ON 0x03 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate /* 102*7c478bd9Sstevel@tonic-gate * These two macros map between the Hot Plug Services LED constants 103*7c478bd9Sstevel@tonic-gate * (cf. uts/common/sys/hotplug/hpctrl.h) and the values used by the 104*7c478bd9Sstevel@tonic-gate * HPC3130 hardware. 105*7c478bd9Sstevel@tonic-gate */ 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate static char hpc3130_to_hpc_led_map[] = { 108*7c478bd9Sstevel@tonic-gate HPC_LED_OFF, HPC_LED_BLINK, HPC_LED_BLINK, HPC_LED_ON 109*7c478bd9Sstevel@tonic-gate }; 110*7c478bd9Sstevel@tonic-gate static char hpc3130_from_hpc_led_map[] = { 111*7c478bd9Sstevel@tonic-gate HPC3130_ATTN_OFF, HPC3130_ATTN_ON, HPC3130_ATTN_FST 112*7c478bd9Sstevel@tonic-gate }; 113*7c478bd9Sstevel@tonic-gate #define HPC3130_TO_HPC_LED(val) (hpc3130_to_hpc_led_map[val]) 114*7c478bd9Sstevel@tonic-gate #define HPC3130_FROM_HPC_LED(val) (hpc3130_from_hpc_led_map[val]) 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #define HPC3130_MAX_SLOT 0x4 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate #define HPC3130_TABLE_COLUMNS 3 /* number of colums in slot-table property */ 119*7c478bd9Sstevel@tonic-gate #define HPC3130_DEBOUNCE_COUNT 2 /* consecutive equal readings == debounced */ 120*7c478bd9Sstevel@tonic-gate #define HPC3130_DEBOUNCE_LIMIT 1000 /* hard upper limit on debouce code */ 121*7c478bd9Sstevel@tonic-gate #define HPC3130_POWER_TRIES 3 /* Try this may times to connect/disconnect */ 122*7c478bd9Sstevel@tonic-gate #define HPC3130_ADEQUATE_PAUSE 25000 /* usec delay for connect sequence */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate /* 125*7c478bd9Sstevel@tonic-gate * This structure defines an element of the controller's 126*7c478bd9Sstevel@tonic-gate * slot table array 127*7c478bd9Sstevel@tonic-gate */ 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate typedef struct hpc3130_slot_table_entry hpc3130_slot_table_entry_t; 130*7c478bd9Sstevel@tonic-gate typedef struct hpc3130_callback_arg hpc3130_callback_arg_t; 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate struct hpc3130_callback_arg { 133*7c478bd9Sstevel@tonic-gate caddr_t handle; 134*7c478bd9Sstevel@tonic-gate caddr_t statep; 135*7c478bd9Sstevel@tonic-gate uint8_t offset; 136*7c478bd9Sstevel@tonic-gate }; 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate struct hpc3130_slot_table_entry { 139*7c478bd9Sstevel@tonic-gate hpc_slot_info_t hpc3130_slot_info; 140*7c478bd9Sstevel@tonic-gate hpc_slot_t hpc3130_slot_handle; 141*7c478bd9Sstevel@tonic-gate char nexus[MAXNAMELEN]; 142*7c478bd9Sstevel@tonic-gate hpc3130_callback_arg_t callback_info; 143*7c478bd9Sstevel@tonic-gate }; 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate /* 146*7c478bd9Sstevel@tonic-gate * The soft state structure 147*7c478bd9Sstevel@tonic-gate */ 148*7c478bd9Sstevel@tonic-gate struct hpc3130_unit { 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate dev_info_t *dip; 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate hpc_slot_ops_t *hpc3130_slot_ops; 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * the following fields hold the value of the "slot-table" 156*7c478bd9Sstevel@tonic-gate * property for this controller 157*7c478bd9Sstevel@tonic-gate */ 158*7c478bd9Sstevel@tonic-gate caddr_t hpc3130_slot_table_data; 159*7c478bd9Sstevel@tonic-gate int hpc3130_slot_table_size; 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate /* 162*7c478bd9Sstevel@tonic-gate * the following fields represent the array of hot-plug 163*7c478bd9Sstevel@tonic-gate * slots derived from the "slot-table" property 164*7c478bd9Sstevel@tonic-gate */ 165*7c478bd9Sstevel@tonic-gate hpc3130_slot_table_entry_t *hpc3130_slot_table; 166*7c478bd9Sstevel@tonic-gate int hpc3130_slot_table_length; 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate /* 169*7c478bd9Sstevel@tonic-gate * Mutex associated with this structure 170*7c478bd9Sstevel@tonic-gate */ 171*7c478bd9Sstevel@tonic-gate kmutex_t hpc3130_mutex; 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* 174*7c478bd9Sstevel@tonic-gate * Trap interrupt cookie 175*7c478bd9Sstevel@tonic-gate */ 176*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t ic_trap_cookie; 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate /* 179*7c478bd9Sstevel@tonic-gate * Open flag 180*7c478bd9Sstevel@tonic-gate */ 181*7c478bd9Sstevel@tonic-gate int hpc3130_oflag; 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate /* 184*7c478bd9Sstevel@tonic-gate * An integer field describing the type 185*7c478bd9Sstevel@tonic-gate * of slots (PCI/SBD). 186*7c478bd9Sstevel@tonic-gate */ 187*7c478bd9Sstevel@tonic-gate hpc3130_slot_type_t slots_are; 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate /* 190*7c478bd9Sstevel@tonic-gate * A place to put the name of this driver 191*7c478bd9Sstevel@tonic-gate * What gets put here is "hpc3130n" - where 192*7c478bd9Sstevel@tonic-gate * n is the instance number. 193*7c478bd9Sstevel@tonic-gate */ 194*7c478bd9Sstevel@tonic-gate char hpc3130_name[16]; 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate /* 197*7c478bd9Sstevel@tonic-gate * The handle within the I2C nexus that this instance 198*7c478bd9Sstevel@tonic-gate * represents. 199*7c478bd9Sstevel@tonic-gate */ 200*7c478bd9Sstevel@tonic-gate i2c_client_hdl_t hpc3130_hdl; 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate /* 203*7c478bd9Sstevel@tonic-gate * condition variable used to throttle power OK signal 204*7c478bd9Sstevel@tonic-gate */ 205*7c478bd9Sstevel@tonic-gate kcondvar_t hpc3130_cond; 206*7c478bd9Sstevel@tonic-gate 207*7c478bd9Sstevel@tonic-gate /* 208*7c478bd9Sstevel@tonic-gate * Present vector - if B_TRUE there is a card in the corresponding 209*7c478bd9Sstevel@tonic-gate * slot. 210*7c478bd9Sstevel@tonic-gate */ 211*7c478bd9Sstevel@tonic-gate boolean_t present[HPC3130_MAX_SLOT]; 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * Power vector - if B_TRUE, then power is applied to the slot 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate boolean_t power[HPC3130_MAX_SLOT]; 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate /* 219*7c478bd9Sstevel@tonic-gate * Enable vector - if B_TRUE the slot is enabled. 220*7c478bd9Sstevel@tonic-gate */ 221*7c478bd9Sstevel@tonic-gate boolean_t enabled[HPC3130_MAX_SLOT]; 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate /* 224*7c478bd9Sstevel@tonic-gate * LED state indicators. 225*7c478bd9Sstevel@tonic-gate */ 226*7c478bd9Sstevel@tonic-gate char fault_led[HPC3130_MAX_SLOT]; 227*7c478bd9Sstevel@tonic-gate char ok2rem_led[HPC3130_MAX_SLOT]; 228*7c478bd9Sstevel@tonic-gate 229*7c478bd9Sstevel@tonic-gate /* For poll(9e)/ioctl(HPC3130_GET_SOFT_EVENT */ 230*7c478bd9Sstevel@tonic-gate uint_t events[HPC3130_MAX_SLOT]; 231*7c478bd9Sstevel@tonic-gate pollhead_t pollhead[HPC3130_MAX_SLOT]; 232*7c478bd9Sstevel@tonic-gate }; 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate typedef struct hpc3130_unit hpc3130_unit_t; 235*7c478bd9Sstevel@tonic-gate 236*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 239*7c478bd9Sstevel@tonic-gate } 240*7c478bd9Sstevel@tonic-gate #endif 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate #endif /* _SYS_HPC3130_DAK_H */ 243