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*1295Sdanice * Copyright 2006 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_PCI_PBM_H 280Sstevel@tonic-gate #define _SYS_PCI_PBM_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <sys/dditypes.h> 340Sstevel@tonic-gate #include <sys/ontrap.h> 350Sstevel@tonic-gate #include <sys/callb.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate /* 420Sstevel@tonic-gate * The following structure represents the pci configuration header 430Sstevel@tonic-gate * for a psycho or schizo PBM. 440Sstevel@tonic-gate */ 450Sstevel@tonic-gate typedef struct config_header config_header_t; 460Sstevel@tonic-gate struct config_header { 470Sstevel@tonic-gate volatile uint16_t ch_vendor_id; 480Sstevel@tonic-gate volatile uint16_t ch_device_id; 490Sstevel@tonic-gate volatile uint16_t ch_command_reg; 500Sstevel@tonic-gate volatile uint16_t ch_status_reg; 510Sstevel@tonic-gate volatile uint8_t ch_revision_id_reg; 520Sstevel@tonic-gate volatile uint8_t ch_programming_if_code_reg; 530Sstevel@tonic-gate volatile uint8_t ch_sub_class_reg; 540Sstevel@tonic-gate volatile uint8_t ch_base_class_reg; 550Sstevel@tonic-gate volatile uint8_t ch_cache_line_size_reg; 560Sstevel@tonic-gate volatile uint8_t ch_latency_timer_reg; 570Sstevel@tonic-gate volatile uint8_t ch_header_type_reg; 580Sstevel@tonic-gate }; 590Sstevel@tonic-gate 600Sstevel@tonic-gate typedef enum { PBM_SPEED_33MHZ, PBM_SPEED_66MHZ } pbm_speed_t; 610Sstevel@tonic-gate 620Sstevel@tonic-gate /* 630Sstevel@tonic-gate * Bit fields of ch_status_reg for cmn_err's %b 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate #define PCI_STATUS_BITS "\020\ 660Sstevel@tonic-gate \11signaled-parity-error\ 670Sstevel@tonic-gate \14signaled-target-abort\ 680Sstevel@tonic-gate \15received-target-abort\ 690Sstevel@tonic-gate \16received-master-abort\ 700Sstevel@tonic-gate \17signaled-system-error\ 710Sstevel@tonic-gate \20detected-parity-error" 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * pbm block soft state structure: 750Sstevel@tonic-gate * 760Sstevel@tonic-gate * Each pci node has its own private pbm block structure. 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate struct pbm { 790Sstevel@tonic-gate pci_t *pbm_pci_p; /* link back to pci soft state */ 800Sstevel@tonic-gate pbm_speed_t pbm_speed; /* PCI bus speed (33 or 66 Mhz) */ 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * PBM control and error registers: 840Sstevel@tonic-gate */ 850Sstevel@tonic-gate volatile uint64_t *pbm_ctrl_reg; 860Sstevel@tonic-gate volatile uint64_t *pbm_async_flt_status_reg; 870Sstevel@tonic-gate volatile uint64_t *pbm_async_flt_addr_reg; 880Sstevel@tonic-gate volatile uint64_t *pbm_diag_reg; 890Sstevel@tonic-gate volatile uint64_t *pbm_estar_reg; 900Sstevel@tonic-gate volatile uint64_t *pbm_pcix_err_stat_reg; 910Sstevel@tonic-gate volatile uint64_t *pbm_pci_ped_ctrl; 92*1295Sdanice volatile uint64_t *pbm_upper_retry_counter_reg; /* for xmits */ 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* 950Sstevel@tonic-gate * PCI configuration header block for the PBM: 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate config_header_t *pbm_config_header; 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* 1000Sstevel@tonic-gate * Memory address range on this PBM used to determine DMA on this pbm 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate iopfn_t pbm_base_pfn; 1030Sstevel@tonic-gate iopfn_t pbm_last_pfn; 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * pbm Interrupt Mapping Register save area 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate uint64_t pbm_imr_save; 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* To save CDMA interrupt state across CPR */ 1110Sstevel@tonic-gate uint64_t pbm_cdma_imr_save; 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* 1140Sstevel@tonic-gate * pbm error interrupt priority: 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate ddi_iblock_cookie_t pbm_iblock_cookie; 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* 1190Sstevel@tonic-gate * Consistent Mode DMA Sync 1200Sstevel@tonic-gate */ 1210Sstevel@tonic-gate uint64_t pbm_sync_reg_pa; /* pending reg for xmits/tomatillo */ 1220Sstevel@tonic-gate ib_ino_t pbm_sync_ino; 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate volatile uint32_t pbm_cdma_flag; 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate /* 1270Sstevel@tonic-gate * DMA sync lock to serialize access to sync hardware. 1280Sstevel@tonic-gate * Used for schizo (>= 2.3) and xmits. Tomatillo does not require 1290Sstevel@tonic-gate * serialization. 1300Sstevel@tonic-gate */ 1310Sstevel@tonic-gate kmutex_t pbm_sync_mutex; 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate /* 1340Sstevel@tonic-gate * support for ddi_poke: 1350Sstevel@tonic-gate */ 1360Sstevel@tonic-gate on_trap_data_t *pbm_ontrap_data; 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate kmutex_t pbm_pokefault_mutex; 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* 1410Sstevel@tonic-gate * Support for cautious IO accesses 1420Sstevel@tonic-gate */ 1430Sstevel@tonic-gate ddi_acc_handle_t pbm_excl_handle; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* 1460Sstevel@tonic-gate * Support for PCI bus quiesce/unquiesce 1470Sstevel@tonic-gate */ 1480Sstevel@tonic-gate uint64_t pbm_saved_ctrl_reg; 1490Sstevel@tonic-gate uint_t pbm_quiesce_count; 1500Sstevel@tonic-gate callb_id_t pbm_panic_cb_id; 1510Sstevel@tonic-gate callb_id_t pbm_debug_cb_id; 1520Sstevel@tonic-gate uint64_t pbm_anychild_cfgpa; 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate /* 1550Sstevel@tonic-gate * Sun Fire 15k PIO limiting semaphore 1560Sstevel@tonic-gate */ 1570Sstevel@tonic-gate uint32_t pbm_pio_limit; 1580Sstevel@tonic-gate volatile uint32_t pbm_pio_counter; 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate #define PBM_NAMESTR_BUFLEN 64 1610Sstevel@tonic-gate /* driver name & instance */ 1620Sstevel@tonic-gate char pbm_nameinst_str[PBM_NAMESTR_BUFLEN]; 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* nodename & node_addr */ 1650Sstevel@tonic-gate char *pbm_nameaddr_str; 1660Sstevel@tonic-gate }; 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate /* 1690Sstevel@tonic-gate * forward declarations (object creation and destruction): 1700Sstevel@tonic-gate */ 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate extern void pbm_create(pci_t *pci_p); 1730Sstevel@tonic-gate extern void pbm_destroy(pci_t *pci_p); 1740Sstevel@tonic-gate extern void pbm_configure(pbm_t *pbm_p); 1750Sstevel@tonic-gate extern void pbm_clear_error(pbm_t *pbm_p); 1760Sstevel@tonic-gate extern void pbm_enable_intr(pbm_t *pbm_p); 1770Sstevel@tonic-gate extern void pbm_suspend(pbm_t *pbm_p); 1780Sstevel@tonic-gate extern void pbm_resume(pbm_t *pbm_p); 1790Sstevel@tonic-gate extern void pbm_intr_dist(void *arg); 1800Sstevel@tonic-gate extern int pbm_register_intr(pbm_t *pbm_p); 1810Sstevel@tonic-gate extern int pbm_afsr_report(dev_info_t *dip, uint64_t fme_ena, 1820Sstevel@tonic-gate pbm_errstate_t *pbm_err_p); 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate #ifdef __cplusplus 1850Sstevel@tonic-gate } 1860Sstevel@tonic-gate #endif 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate #endif /* _SYS_PCI_PBM_H */ 189