summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/sys/pci/pci_pbm.h
blob: 4b2ee0bf433165328d50811f7187b86daad9f955 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_PCI_PBM_H
#define	_SYS_PCI_PBM_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <sys/types.h>
#include <sys/dditypes.h>
#include <sys/ontrap.h>
#include <sys/callb.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The following structure represents the pci configuration header
 * for a psycho or schizo PBM.
 */
typedef struct config_header config_header_t;
struct config_header {
	volatile uint16_t ch_vendor_id;
	volatile uint16_t ch_device_id;
	volatile uint16_t ch_command_reg;
	volatile uint16_t ch_status_reg;
	volatile uint8_t ch_revision_id_reg;
	volatile uint8_t ch_programming_if_code_reg;
	volatile uint8_t ch_sub_class_reg;
	volatile uint8_t ch_base_class_reg;
	volatile uint8_t ch_cache_line_size_reg;
	volatile uint8_t ch_latency_timer_reg;
	volatile uint8_t ch_header_type_reg;
};

typedef enum { PBM_SPEED_33MHZ, PBM_SPEED_66MHZ } pbm_speed_t;

/*
 * Bit fields of ch_status_reg for cmn_err's %b
 */
#define	PCI_STATUS_BITS "\020\
\11signaled-parity-error\
\14signaled-target-abort\
\15received-target-abort\
\16received-master-abort\
\17signaled-system-error\
\20detected-parity-error"

/*
 * pbm block soft state structure:
 *
 * Each pci node has its own private pbm block structure.
 */
struct pbm {
	pci_t *pbm_pci_p;	/* link back to pci soft state */
	pbm_speed_t pbm_speed;	/* PCI bus speed (33 or 66 Mhz) */

	/*
	 * PBM control and error registers:
	 */
	volatile uint64_t *pbm_ctrl_reg;
	volatile uint64_t *pbm_async_flt_status_reg;
	volatile uint64_t *pbm_async_flt_addr_reg;
	volatile uint64_t *pbm_diag_reg;
	volatile uint64_t *pbm_estar_reg;
	volatile uint64_t *pbm_pcix_err_stat_reg;
	volatile uint64_t *pbm_pci_ped_ctrl;
	volatile uint64_t *pbm_upper_retry_counter_reg; /* for xmits */

	/*
	 * PCI configuration header block for the PBM:
	 */
	config_header_t *pbm_config_header;

	/*
	 * Memory address range on this PBM used to determine DMA on this pbm
	 */
	iopfn_t pbm_base_pfn;
	iopfn_t pbm_last_pfn;

	/*
	 * pbm Interrupt Mapping Register save area
	 */
	uint64_t pbm_imr_save;

	/* To save CDMA interrupt state across CPR */
	uint64_t pbm_cdma_imr_save;

	/*
	 * pbm error interrupt priority:
	 */
	ddi_iblock_cookie_t pbm_iblock_cookie;

	/*
	 * Consistent Mode DMA Sync
	 */
	uint64_t pbm_sync_reg_pa;	/* pending reg for xmits/tomatillo */
	ib_ino_t pbm_sync_ino;

	volatile uint32_t pbm_cdma_flag;

	/*
	 * DMA sync lock to serialize access to sync hardware.
	 * Used for schizo (>= 2.3) and xmits. Tomatillo does not require
	 * serialization.
	 */
	kmutex_t pbm_sync_mutex;

	/*
	 * support for ddi_poke:
	 */
	on_trap_data_t *pbm_ontrap_data;

	kmutex_t pbm_pokefault_mutex;

	/*
	 * Support for cautious IO accesses
	 */
	ddi_acc_handle_t pbm_excl_handle;

	/*
	 * Support for PCI bus quiesce/unquiesce
	 */
	uint64_t pbm_saved_ctrl_reg;
	uint_t pbm_quiesce_count;
	callb_id_t pbm_panic_cb_id;
	callb_id_t pbm_debug_cb_id;
	uint64_t pbm_anychild_cfgpa;

	/*
	 * Sun Fire 15k PIO limiting semaphore
	 */
	uint32_t pbm_pio_limit;
	volatile uint32_t pbm_pio_counter;

#define	PBM_NAMESTR_BUFLEN 	64
	/* driver name & instance */
	char pbm_nameinst_str[PBM_NAMESTR_BUFLEN];

	/* nodename & node_addr */
	char *pbm_nameaddr_str;
};

/*
 * forward declarations (object creation and destruction):
 */

extern void pbm_create(pci_t *pci_p);
extern void pbm_destroy(pci_t *pci_p);
extern void pbm_configure(pbm_t *pbm_p);
extern void pbm_clear_error(pbm_t *pbm_p);
extern void pbm_enable_intr(pbm_t *pbm_p);
extern void pbm_suspend(pbm_t *pbm_p);
extern void pbm_resume(pbm_t *pbm_p);
extern void pbm_intr_dist(void *arg);
extern int pbm_register_intr(pbm_t *pbm_p);
extern int pbm_afsr_report(dev_info_t *dip, uint64_t fme_ena,
		pbm_errstate_t *pbm_err_p);

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_PCI_PBM_H */