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 5*1865Sdilpreet * Common Development and Distribution License (the "License"). 6*1865Sdilpreet * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1865Sdilpreet * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_DB21554_CTRL_H 270Sstevel@tonic-gate #define _SYS_DB21554_CTRL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* definitions for device state */ 360Sstevel@tonic-gate #define DB_SECONDARY_NEXUS 0x80000000 /* secondary towards host */ 370Sstevel@tonic-gate #define DB_PRIMARY_NEXUS 0x40000000 /* primary towards host */ 380Sstevel@tonic-gate #define DB_ATTACHED 0x00000001 /* driver attached */ 390Sstevel@tonic-gate #define DB_SUSPENDED 0x00100000 400Sstevel@tonic-gate #define DB_DEBUG_MODE_ON 0x01000000 410Sstevel@tonic-gate 420Sstevel@tonic-gate #define DB_PCI_CONF_RNUMBER 0 430Sstevel@tonic-gate #define DB_PCI_CONF_OFFSET 0 440Sstevel@tonic-gate #define DB_CSR_MEMBAR_RNUMBER 1 450Sstevel@tonic-gate #define DB_CSR_MEM_OFFSET 0 460Sstevel@tonic-gate #define DB_CSR_SIZE 0x1000 /* 4K CSR space */ 470Sstevel@tonic-gate #define DB_CSR_IOBAR_RNUMBER 2 480Sstevel@tonic-gate #define DB_CSR_IO_OFFSET 0 490Sstevel@tonic-gate #define DB_PCI_TIMEOUT 10000 /* 10 ms */ 500Sstevel@tonic-gate #define DB_PCI_WAIT_MS 0 510Sstevel@tonic-gate #define DB_CONF_FAILURE -1 520Sstevel@tonic-gate 530Sstevel@tonic-gate #define DB_PIF_SECONDARY_TO_HOST 0x80 540Sstevel@tonic-gate #define DB_PIF_PRIMARY_TO_HOST 0x40 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * the following definition is used to save the state of all PCI children 580Sstevel@tonic-gate * under us. 590Sstevel@tonic-gate */ 600Sstevel@tonic-gate typedef struct db_cfg_state { 610Sstevel@tonic-gate dev_info_t *dip; 620Sstevel@tonic-gate uchar_t cache_line_size; 630Sstevel@tonic-gate uchar_t latency_timer; 640Sstevel@tonic-gate uchar_t header_type; 650Sstevel@tonic-gate uchar_t sec_latency_timer; 660Sstevel@tonic-gate ushort_t command; 670Sstevel@tonic-gate ushort_t bridge_control; 680Sstevel@tonic-gate } db_cfg_state_t; 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* the main control structure of our device */ 710Sstevel@tonic-gate typedef struct db_ctrl { 720Sstevel@tonic-gate dev_info_t *dip; 730Sstevel@tonic-gate uint32_t dev_state; /* device state */ 740Sstevel@tonic-gate caddr_t csr_mem; /* pointer to CSR map in memory space */ 750Sstevel@tonic-gate caddr_t csr_io; /* pointer to CSR map in IO space */ 760Sstevel@tonic-gate caddr_t conf_io; /* pointer to Conf indirect map */ 770Sstevel@tonic-gate 780Sstevel@tonic-gate /* our bus range information */ 79*1865Sdilpreet pci_bus_range_t range; 800Sstevel@tonic-gate 810Sstevel@tonic-gate /* any device tuning parameters here. */ 820Sstevel@tonic-gate uint16_t p_command; 830Sstevel@tonic-gate uint16_t s_command; 840Sstevel@tonic-gate int8_t p_latency_timer; 850Sstevel@tonic-gate int8_t p_cache_line_size; 860Sstevel@tonic-gate int8_t s_latency_timer; 870Sstevel@tonic-gate int8_t s_cache_line_size; 880Sstevel@tonic-gate int8_t p_pwrite_threshold; 890Sstevel@tonic-gate int8_t s_pwrite_threshold; 900Sstevel@tonic-gate int8_t p_dread_threshold; 910Sstevel@tonic-gate int8_t s_dread_threshold; 920Sstevel@tonic-gate int8_t delayed_trans_order; 930Sstevel@tonic-gate int8_t serr_fwd_enable; 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* for child initialization */ 960Sstevel@tonic-gate uint8_t latency_timer; 970Sstevel@tonic-gate uint8_t cache_line_size; 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* error holders */ 1000Sstevel@tonic-gate uint32_t db_pci_err_count; /* indirect cycle timeout count */ 1010Sstevel@tonic-gate #ifdef DEBUG 1020Sstevel@tonic-gate uint32_t db_pci_max_wait_count; /* indirect cycle wait count */ 1030Sstevel@tonic-gate #endif 1040Sstevel@tonic-gate /* cpr related. */ 1050Sstevel@tonic-gate uint_t config_state_index; 1060Sstevel@tonic-gate db_cfg_state_t *db_config_state_p; 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* all map handles below */ 1090Sstevel@tonic-gate ddi_acc_handle_t csr_mem_handle; /* CSR memory handle */ 1100Sstevel@tonic-gate ddi_acc_handle_t csr_io_handle; /* CSR IO handle */ 1110Sstevel@tonic-gate ddi_acc_handle_t conf_handle; /* config space handle */ 1120Sstevel@tonic-gate ddi_iblock_cookie_t i_block_cookie; /* interrupt cookie */ 1130Sstevel@tonic-gate kmutex_t db_busown; /* bus config own mutex */ 1140Sstevel@tonic-gate kmutex_t db_mutex; 1150Sstevel@tonic-gate uint_t db_soft_state; 1160Sstevel@tonic-gate #define DB_SOFT_STATE_CLOSED 0x00 1170Sstevel@tonic-gate #define DB_SOFT_STATE_OPEN 0x01 1180Sstevel@tonic-gate #define DB_SOFT_STATE_OPEN_EXCL 0x02 1190Sstevel@tonic-gate int fm_cap; 1200Sstevel@tonic-gate ddi_iblock_cookie_t fm_ibc; 1210Sstevel@tonic-gate }db_ctrl_t; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate typedef struct db_acc_cfg_addr { 1240Sstevel@tonic-gate uchar_t c_busnum; /* bus number */ 1250Sstevel@tonic-gate uchar_t c_devnum; /* device number */ 1260Sstevel@tonic-gate uchar_t c_funcnum; /* function number */ 1270Sstevel@tonic-gate uchar_t c_fill; /* reserve field */ 1280Sstevel@tonic-gate } db_acc_cfg_addr_t; 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate typedef struct db_acc_pvt { 1310Sstevel@tonic-gate db_acc_cfg_addr_t dev_addr; /* pci device address */ 1320Sstevel@tonic-gate uint32_t *addr; /* upstream/downstream config addr */ 1330Sstevel@tonic-gate uint32_t *data; /* upstream/downstream config data */ 1340Sstevel@tonic-gate uint8_t *bus_own; /* reg to check if bus owned */ 1350Sstevel@tonic-gate uint8_t *bus_release; /* reg to check if bus released */ 1360Sstevel@tonic-gate uint8_t mask; /* bitmask for upstream/downstream */ 1370Sstevel@tonic-gate ushort_t access_mode; /* access through IO or Config */ 1380Sstevel@tonic-gate db_ctrl_t *dbp; 1390Sstevel@tonic-gate ddi_acc_handle_t handle; /* handle for bus access DDI calls */ 1400Sstevel@tonic-gate } db_acc_pvt_t; 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate /* We can use the following modes for generating indirect PCI transcations */ 1430Sstevel@tonic-gate #define DB_IO_MAP_DIRECT 1 /* memory mapped IO */ 1440Sstevel@tonic-gate #define DB_IO_MAP_INDIRECT 2 /* indirect map IO */ 1450Sstevel@tonic-gate #define DB_CONF_MAP_INDIRECT_CONF 4 /* access config via config regs */ 1460Sstevel@tonic-gate #define DB_CONF_MAP_INDIRECT_IO 8 /* access config via IO regs */ 1470Sstevel@tonic-gate #define DB_PCI_CONF_CYCLE_TYPE0 0x100 /* type 0 conf cycle */ 1480Sstevel@tonic-gate #define DB_PCI_CONF_CYCLE_TYPE1 0x200 /* type 1 conf cycle */ 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate #ifdef __cplusplus 1510Sstevel@tonic-gate } 1520Sstevel@tonic-gate #endif 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate #endif /* _SYS_DB21554_CTRL_H */ 155