xref: /onnv-gate/usr/src/uts/sun4/io/px/px_lib.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_PX_LIB_H
28*0Sstevel@tonic-gate #define	_SYS_PX_LIB_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate /*
37*0Sstevel@tonic-gate  * Include all data structures and definitions in this file that are
38*0Sstevel@tonic-gate  * required between the common and hardware specific code.
39*0Sstevel@tonic-gate  */
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #define	DIP_TO_HANDLE(dip)	((px_t *)DIP_TO_STATE(dip))->px_dev_hdl
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate /*
44*0Sstevel@tonic-gate  * The following macros define	the mmu page size and related operations.
45*0Sstevel@tonic-gate  */
46*0Sstevel@tonic-gate #define	MMU_PAGE_SHIFT		13
47*0Sstevel@tonic-gate #define	MMU_PAGE_SIZE		(1 << MMU_PAGE_SHIFT)
48*0Sstevel@tonic-gate #define	MMU_PAGE_MASK		~(MMU_PAGE_SIZE - 1)
49*0Sstevel@tonic-gate #define	MMU_PAGE_OFFSET		(MMU_PAGE_SIZE - 1)
50*0Sstevel@tonic-gate #define	MMU_PTOB(x)		(((uint64_t)(x)) << MMU_PAGE_SHIFT)
51*0Sstevel@tonic-gate #define	MMU_BTOP(x)		((x) >> MMU_PAGE_SHIFT)
52*0Sstevel@tonic-gate #define	MMU_BTOPR(x)		MMU_BTOP((x) + MMU_PAGE_OFFSET)
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /* MMU map flags */
55*0Sstevel@tonic-gate #define	MMU_MAP_MP		0
56*0Sstevel@tonic-gate #define	MMU_MAP_BUF		1
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate typedef struct px px_t;
59*0Sstevel@tonic-gate typedef struct px_common px_common_t;
60*0Sstevel@tonic-gate typedef struct px_msiq px_msiq_t;
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate extern int px_lib_dev_init(dev_info_t *dip, devhandle_t *dev_hdl);
63*0Sstevel@tonic-gate extern int px_lib_dev_fini(dev_info_t *dip);
64*0Sstevel@tonic-gate extern int px_lib_map_vconfig(dev_info_t *dip, ddi_map_req_t *mp,
65*0Sstevel@tonic-gate     pci_config_offset_t off, pci_regspec_t *rp, caddr_t *addrp);
66*0Sstevel@tonic-gate extern int px_lib_intr_devino_to_sysino(dev_info_t *dip, devino_t devino,
67*0Sstevel@tonic-gate     sysino_t *sysino);
68*0Sstevel@tonic-gate extern int px_lib_intr_getvalid(dev_info_t *dip, sysino_t sysino,
69*0Sstevel@tonic-gate     intr_valid_state_t *intr_valid_state);
70*0Sstevel@tonic-gate extern int px_lib_intr_setvalid(dev_info_t *dip, sysino_t sysino,
71*0Sstevel@tonic-gate     intr_valid_state_t intr_valid_state);
72*0Sstevel@tonic-gate extern int px_lib_intr_getstate(dev_info_t *dip, sysino_t sysino,
73*0Sstevel@tonic-gate     intr_state_t *intr_state);
74*0Sstevel@tonic-gate extern int px_lib_intr_setstate(dev_info_t *dip, sysino_t sysino,
75*0Sstevel@tonic-gate     intr_state_t intr_state);
76*0Sstevel@tonic-gate extern int px_lib_intr_gettarget(dev_info_t *dip, sysino_t sysino,
77*0Sstevel@tonic-gate     cpuid_t *cpuid);
78*0Sstevel@tonic-gate extern int px_lib_intr_settarget(dev_info_t *dip, sysino_t sysino,
79*0Sstevel@tonic-gate     cpuid_t cpuid);
80*0Sstevel@tonic-gate extern int px_lib_intr_reset(dev_info_t *dip);
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate extern int px_lib_iommu_map(dev_info_t *dip, tsbid_t tsbid, pages_t pages,
83*0Sstevel@tonic-gate     io_attributes_t io_attributes, void *addr, size_t pfn_index, int flag);
84*0Sstevel@tonic-gate extern int px_lib_iommu_demap(dev_info_t *dip, tsbid_t tsbid, pages_t pages);
85*0Sstevel@tonic-gate extern int px_lib_iommu_getmap(dev_info_t *dip, tsbid_t tsbid,
86*0Sstevel@tonic-gate     io_attributes_t *attributes_p, r_addr_t *r_addr_p);
87*0Sstevel@tonic-gate extern int px_lib_dma_bypass_rngchk(ddi_dma_attr_t *attrp, uint64_t *lo_p,
88*0Sstevel@tonic-gate     uint64_t *hi_p);
89*0Sstevel@tonic-gate extern int px_lib_iommu_getbypass(dev_info_t *dip, r_addr_t ra,
90*0Sstevel@tonic-gate     io_attributes_t io_attributes, io_addr_t *io_addr_p);
91*0Sstevel@tonic-gate extern int px_lib_dma_sync(dev_info_t *dip, dev_info_t *rdip,
92*0Sstevel@tonic-gate     ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate /*
95*0Sstevel@tonic-gate  * MSIQ Functions:
96*0Sstevel@tonic-gate  */
97*0Sstevel@tonic-gate extern int px_lib_msiq_init(dev_info_t *dip);
98*0Sstevel@tonic-gate extern int px_lib_msiq_fini(dev_info_t *dip);
99*0Sstevel@tonic-gate extern int px_lib_msiq_info(dev_info_t *dip, msiqid_t msiq_id,
100*0Sstevel@tonic-gate     r_addr_t *ra_p, uint_t *msiq_rec_cnt_p);
101*0Sstevel@tonic-gate extern int px_lib_msiq_getvalid(dev_info_t *dip, msiqid_t msiq_id,
102*0Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state);
103*0Sstevel@tonic-gate extern int px_lib_msiq_setvalid(dev_info_t *dip, msiqid_t msiq_id,
104*0Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state);
105*0Sstevel@tonic-gate extern int px_lib_msiq_getstate(dev_info_t *dip, msiqid_t msiq_id,
106*0Sstevel@tonic-gate     pci_msiq_state_t *msiq_state);
107*0Sstevel@tonic-gate extern int px_lib_msiq_setstate(dev_info_t *dip, msiqid_t msiq_id,
108*0Sstevel@tonic-gate     pci_msiq_state_t msiq_state);
109*0Sstevel@tonic-gate extern int px_lib_msiq_gethead(dev_info_t *dip, msiqid_t msiq_id,
110*0Sstevel@tonic-gate     msiqhead_t *msiq_head);
111*0Sstevel@tonic-gate extern int px_lib_msiq_sethead(dev_info_t *dip, msiqid_t msiq_id,
112*0Sstevel@tonic-gate     msiqhead_t msiq_head);
113*0Sstevel@tonic-gate extern int px_lib_msiq_gettail(dev_info_t *dip, msiqid_t msiq_id,
114*0Sstevel@tonic-gate     msiqtail_t *msiq_tail);
115*0Sstevel@tonic-gate extern void px_lib_get_msiq_rec(dev_info_t *dip, px_msiq_t *msiq_p,
116*0Sstevel@tonic-gate     msiq_rec_t *msiq_rec_p);
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate /*
119*0Sstevel@tonic-gate  * MSI Functions:
120*0Sstevel@tonic-gate  */
121*0Sstevel@tonic-gate extern int px_lib_msi_init(dev_info_t *dip);
122*0Sstevel@tonic-gate extern int px_lib_msi_getmsiq(dev_info_t *dip, msinum_t msi_num,
123*0Sstevel@tonic-gate     msiqid_t *msiq_id);
124*0Sstevel@tonic-gate extern int px_lib_msi_setmsiq(dev_info_t *dip, msinum_t msi_num,
125*0Sstevel@tonic-gate     msiqid_t msiq_id, msi_type_t msitype);
126*0Sstevel@tonic-gate extern int px_lib_msi_getvalid(dev_info_t *dip, msinum_t msi_num,
127*0Sstevel@tonic-gate     pci_msi_valid_state_t *msi_valid_state);
128*0Sstevel@tonic-gate extern int px_lib_msi_setvalid(dev_info_t *dip, msinum_t msi_num,
129*0Sstevel@tonic-gate     pci_msi_valid_state_t msi_valid_state);
130*0Sstevel@tonic-gate extern int px_lib_msi_getstate(dev_info_t *dip, msinum_t msi_num,
131*0Sstevel@tonic-gate     pci_msi_state_t *msi_state);
132*0Sstevel@tonic-gate extern int px_lib_msi_setstate(dev_info_t *dip, msinum_t msi_num,
133*0Sstevel@tonic-gate     pci_msi_state_t msi_state);
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate /*
136*0Sstevel@tonic-gate  * MSG Functions:
137*0Sstevel@tonic-gate  */
138*0Sstevel@tonic-gate extern int px_lib_msg_getmsiq(dev_info_t *dip, pcie_msg_type_t msg_type,
139*0Sstevel@tonic-gate     msiqid_t *msiq_id);
140*0Sstevel@tonic-gate extern int px_lib_msg_setmsiq(dev_info_t *dip, pcie_msg_type_t msg_type,
141*0Sstevel@tonic-gate     msiqid_t msiq_id);
142*0Sstevel@tonic-gate extern int px_lib_msg_getvalid(dev_info_t *dip, pcie_msg_type_t msg_type,
143*0Sstevel@tonic-gate     pcie_msg_valid_state_t *msg_valid_state);
144*0Sstevel@tonic-gate extern int px_lib_msg_setvalid(dev_info_t *dip, pcie_msg_type_t msg_type,
145*0Sstevel@tonic-gate     pcie_msg_valid_state_t msg_valid_state);
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate /*
148*0Sstevel@tonic-gate  * CPR Suspend/Resume Functions:
149*0Sstevel@tonic-gate  */
150*0Sstevel@tonic-gate extern int px_lib_suspend(dev_info_t *dip);
151*0Sstevel@tonic-gate extern void px_lib_resume(dev_info_t *dip);
152*0Sstevel@tonic-gate 
153*0Sstevel@tonic-gate /*
154*0Sstevel@tonic-gate  * PCI tool Functions:
155*0Sstevel@tonic-gate  */
156*0Sstevel@tonic-gate extern int px_lib_tools_dev_reg_ops(dev_info_t *dip, void *arg,
157*0Sstevel@tonic-gate     int cmd, int mode);
158*0Sstevel@tonic-gate extern int px_lib_tools_bus_reg_ops(dev_info_t *dip, void *arg, int cmd,
159*0Sstevel@tonic-gate     int mode);
160*0Sstevel@tonic-gate extern int px_lib_tools_intr_admn(dev_info_t *dip, void *arg, int cmd,
161*0Sstevel@tonic-gate     int mode);
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate /*
164*0Sstevel@tonic-gate  * PPM interface
165*0Sstevel@tonic-gate  */
166*0Sstevel@tonic-gate extern int px_lib_pmctl(int cmd, px_t *px_p);
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate /*
169*0Sstevel@tonic-gate  * Misc Functions:
170*0Sstevel@tonic-gate  */
171*0Sstevel@tonic-gate extern uint64_t px_lib_get_cb(caddr_t csr);
172*0Sstevel@tonic-gate extern void px_lib_set_cb(caddr_t csr, uint64_t val);
173*0Sstevel@tonic-gate 
174*0Sstevel@tonic-gate /*
175*0Sstevel@tonic-gate  * Peek and poke access ddi_ctlops helper functions
176*0Sstevel@tonic-gate  */
177*0Sstevel@tonic-gate extern int px_lib_ctlops_poke(dev_info_t *dip, dev_info_t *rdip,
178*0Sstevel@tonic-gate     peekpoke_ctlops_t *in_args);
179*0Sstevel@tonic-gate extern int px_lib_ctlops_peek(dev_info_t *dip, dev_info_t *rdip,
180*0Sstevel@tonic-gate     peekpoke_ctlops_t *in_args, void *result);
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate #ifdef	__cplusplus
183*0Sstevel@tonic-gate }
184*0Sstevel@tonic-gate #endif
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate #endif	/* _SYS_PX_LIB_H */
187