xref: /illumos-gate/usr/src/uts/sun4u/sys/pci/pci_pbm.h (revision 810a4a70)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*810a4a70Sdanice  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_PCI_PBM_H
287c478bd9Sstevel@tonic-gate #define	_SYS_PCI_PBM_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
347c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
357c478bd9Sstevel@tonic-gate #include <sys/callb.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * The following structure represents the pci configuration header
437c478bd9Sstevel@tonic-gate  * for a psycho or schizo PBM.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate typedef struct config_header config_header_t;
467c478bd9Sstevel@tonic-gate struct config_header {
477c478bd9Sstevel@tonic-gate 	volatile uint16_t ch_vendor_id;
487c478bd9Sstevel@tonic-gate 	volatile uint16_t ch_device_id;
497c478bd9Sstevel@tonic-gate 	volatile uint16_t ch_command_reg;
507c478bd9Sstevel@tonic-gate 	volatile uint16_t ch_status_reg;
517c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_revision_id_reg;
527c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_programming_if_code_reg;
537c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_sub_class_reg;
547c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_base_class_reg;
557c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_cache_line_size_reg;
567c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_latency_timer_reg;
577c478bd9Sstevel@tonic-gate 	volatile uint8_t ch_header_type_reg;
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate typedef enum { PBM_SPEED_33MHZ, PBM_SPEED_66MHZ } pbm_speed_t;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Bit fields of ch_status_reg for cmn_err's %b
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define	PCI_STATUS_BITS "\020\
667c478bd9Sstevel@tonic-gate \11signaled-parity-error\
677c478bd9Sstevel@tonic-gate \14signaled-target-abort\
687c478bd9Sstevel@tonic-gate \15received-target-abort\
697c478bd9Sstevel@tonic-gate \16received-master-abort\
707c478bd9Sstevel@tonic-gate \17signaled-system-error\
717c478bd9Sstevel@tonic-gate \20detected-parity-error"
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * pbm block soft state structure:
757c478bd9Sstevel@tonic-gate  *
767c478bd9Sstevel@tonic-gate  * Each pci node has its own private pbm block structure.
777c478bd9Sstevel@tonic-gate  */
787c478bd9Sstevel@tonic-gate struct pbm {
797c478bd9Sstevel@tonic-gate 	pci_t *pbm_pci_p;	/* link back to pci soft state */
807c478bd9Sstevel@tonic-gate 	pbm_speed_t pbm_speed;	/* PCI bus speed (33 or 66 Mhz) */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 	/*
837c478bd9Sstevel@tonic-gate 	 * PBM control and error registers:
847c478bd9Sstevel@tonic-gate 	 */
857c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_ctrl_reg;
867c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_async_flt_status_reg;
877c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_async_flt_addr_reg;
887c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_diag_reg;
897c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_estar_reg;
907c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_pcix_err_stat_reg;
917c478bd9Sstevel@tonic-gate 	volatile uint64_t *pbm_pci_ped_ctrl;
92*810a4a70Sdanice 	volatile uint64_t *pbm_upper_retry_counter_reg; /* for xmits */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 	/*
957c478bd9Sstevel@tonic-gate 	 * PCI configuration header block for the PBM:
967c478bd9Sstevel@tonic-gate 	 */
977c478bd9Sstevel@tonic-gate 	config_header_t *pbm_config_header;
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	/*
1007c478bd9Sstevel@tonic-gate 	 * Memory address range on this PBM used to determine DMA on this pbm
1017c478bd9Sstevel@tonic-gate 	 */
1027c478bd9Sstevel@tonic-gate 	iopfn_t pbm_base_pfn;
1037c478bd9Sstevel@tonic-gate 	iopfn_t pbm_last_pfn;
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	/*
1067c478bd9Sstevel@tonic-gate 	 * pbm Interrupt Mapping Register save area
1077c478bd9Sstevel@tonic-gate 	 */
1087c478bd9Sstevel@tonic-gate 	uint64_t pbm_imr_save;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 	/* To save CDMA interrupt state across CPR */
1117c478bd9Sstevel@tonic-gate 	uint64_t pbm_cdma_imr_save;
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate 	/*
1147c478bd9Sstevel@tonic-gate 	 * pbm error interrupt priority:
1157c478bd9Sstevel@tonic-gate 	 */
1167c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t pbm_iblock_cookie;
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 	/*
1197c478bd9Sstevel@tonic-gate 	 * Consistent Mode DMA Sync
1207c478bd9Sstevel@tonic-gate 	 */
1217c478bd9Sstevel@tonic-gate 	uint64_t pbm_sync_reg_pa;	/* pending reg for xmits/tomatillo */
1227c478bd9Sstevel@tonic-gate 	ib_ino_t pbm_sync_ino;
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	volatile uint32_t pbm_cdma_flag;
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 	/*
1277c478bd9Sstevel@tonic-gate 	 * DMA sync lock to serialize access to sync hardware.
1287c478bd9Sstevel@tonic-gate 	 * Used for schizo (>= 2.3) and xmits. Tomatillo does not require
1297c478bd9Sstevel@tonic-gate 	 * serialization.
1307c478bd9Sstevel@tonic-gate 	 */
1317c478bd9Sstevel@tonic-gate 	kmutex_t pbm_sync_mutex;
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	/*
1347c478bd9Sstevel@tonic-gate 	 * support for ddi_poke:
1357c478bd9Sstevel@tonic-gate 	 */
1367c478bd9Sstevel@tonic-gate 	on_trap_data_t *pbm_ontrap_data;
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 	kmutex_t pbm_pokefault_mutex;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	/*
1417c478bd9Sstevel@tonic-gate 	 * Support for cautious IO accesses
1427c478bd9Sstevel@tonic-gate 	 */
1437c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t pbm_excl_handle;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	/*
1467c478bd9Sstevel@tonic-gate 	 * Support for PCI bus quiesce/unquiesce
1477c478bd9Sstevel@tonic-gate 	 */
1487c478bd9Sstevel@tonic-gate 	uint64_t pbm_saved_ctrl_reg;
1497c478bd9Sstevel@tonic-gate 	uint_t pbm_quiesce_count;
1507c478bd9Sstevel@tonic-gate 	callb_id_t pbm_panic_cb_id;
1517c478bd9Sstevel@tonic-gate 	callb_id_t pbm_debug_cb_id;
1527c478bd9Sstevel@tonic-gate 	uint64_t pbm_anychild_cfgpa;
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	/*
1557c478bd9Sstevel@tonic-gate 	 * Sun Fire 15k PIO limiting semaphore
1567c478bd9Sstevel@tonic-gate 	 */
1577c478bd9Sstevel@tonic-gate 	uint32_t pbm_pio_limit;
1587c478bd9Sstevel@tonic-gate 	volatile uint32_t pbm_pio_counter;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate #define	PBM_NAMESTR_BUFLEN 	64
1617c478bd9Sstevel@tonic-gate 	/* driver name & instance */
1627c478bd9Sstevel@tonic-gate 	char pbm_nameinst_str[PBM_NAMESTR_BUFLEN];
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 	/* nodename & node_addr */
1657c478bd9Sstevel@tonic-gate 	char *pbm_nameaddr_str;
1667c478bd9Sstevel@tonic-gate };
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate  * forward declarations (object creation and destruction):
1707c478bd9Sstevel@tonic-gate  */
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate extern void pbm_create(pci_t *pci_p);
1737c478bd9Sstevel@tonic-gate extern void pbm_destroy(pci_t *pci_p);
1747c478bd9Sstevel@tonic-gate extern void pbm_configure(pbm_t *pbm_p);
1757c478bd9Sstevel@tonic-gate extern void pbm_clear_error(pbm_t *pbm_p);
1767c478bd9Sstevel@tonic-gate extern void pbm_enable_intr(pbm_t *pbm_p);
1777c478bd9Sstevel@tonic-gate extern void pbm_suspend(pbm_t *pbm_p);
1787c478bd9Sstevel@tonic-gate extern void pbm_resume(pbm_t *pbm_p);
1797c478bd9Sstevel@tonic-gate extern void pbm_intr_dist(void *arg);
1807c478bd9Sstevel@tonic-gate extern int pbm_register_intr(pbm_t *pbm_p);
1817c478bd9Sstevel@tonic-gate extern int pbm_afsr_report(dev_info_t *dip, uint64_t fme_ena,
1827c478bd9Sstevel@tonic-gate 		pbm_errstate_t *pbm_err_p);
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1857c478bd9Sstevel@tonic-gate }
1867c478bd9Sstevel@tonic-gate #endif
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate #endif	/* _SYS_PCI_PBM_H */
189