xref: /titanic_52/usr/src/uts/common/sys/sbp2/bus.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_SBP2_BUS_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SBP2_BUS_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Serial Bus Protocol 2 (SBP-2) bus interface
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/sbp2/common.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/note.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate enum {
44*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_REV_1	= 1,
45*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_REV	= SBP2_BUS_REV_1
46*7c478bd9Sstevel@tonic-gate };
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate typedef struct sbp2_bus_buf {
49*7c478bd9Sstevel@tonic-gate 	struct sbp2_bus_buf *bb_next;	/* next in free list */
50*7c478bd9Sstevel@tonic-gate 	void		*bb_hdl;	/* buffer handle */
51*7c478bd9Sstevel@tonic-gate 	void		*bb_sbp2_priv;	/* SBP2 private data */
52*7c478bd9Sstevel@tonic-gate 	size_t		bb_len;		/* buffer length */
53*7c478bd9Sstevel@tonic-gate 	int		bb_flags;	/* flags */
54*7c478bd9Sstevel@tonic-gate 	int		bb_dma_flags;	/* DDI_DMA_* flags */
55*7c478bd9Sstevel@tonic-gate 	caddr_t		bb_kaddr;	/* kernel virtual address */
56*7c478bd9Sstevel@tonic-gate 	uint64_t	bb_paddr;	/* physical address */
57*7c478bd9Sstevel@tonic-gate 	uint64_t	bb_baddr;	/* bus address */
58*7c478bd9Sstevel@tonic-gate 	void		(*bb_rq_cb)(struct sbp2_bus_buf *bb, void *reqh,
59*7c478bd9Sstevel@tonic-gate 			    uint32_t *q);	/* quadlet read callback */
60*7c478bd9Sstevel@tonic-gate 	void		(*bb_rb_cb)(struct sbp2_bus_buf *bb, void *reqh,
61*7c478bd9Sstevel@tonic-gate 			    mblk_t **bpp, size_t len); /* block read callback */
62*7c478bd9Sstevel@tonic-gate 	void		(*bb_wq_cb)(struct sbp2_bus_buf *bb, void *reqh,
63*7c478bd9Sstevel@tonic-gate 			    uint32_t q);	/* quadlet write callback */
64*7c478bd9Sstevel@tonic-gate 	void		(*bb_wb_cb)(struct sbp2_bus_buf *bb, void *reqh,
65*7c478bd9Sstevel@tonic-gate 			    mblk_t **bpp);	/* block write callback */
66*7c478bd9Sstevel@tonic-gate } sbp2_bus_buf_t;
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", sbp2_bus_buf))
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate /* buffer flags */
71*7c478bd9Sstevel@tonic-gate enum {
72*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_DMA	= 0x01,	/* DMA buffer */
73*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_RD		= 0x02,	/* read buffer */
74*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_WR		= 0x04,	/* write buffer */
75*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_POSTED	= 0x08,	/* posted buffer */
76*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_RW		= (SBP2_BUS_BUF_RD | SBP2_BUS_BUF_WR),
77*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_WR_POSTED	= (SBP2_BUS_BUF_WR | SBP2_BUS_BUF_POSTED)
78*7c478bd9Sstevel@tonic-gate };
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate /* buffer request error codes */
81*7c478bd9Sstevel@tonic-gate enum {
82*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_SUCCESS		= 0,
83*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_FAILURE		= -1,	/* unspecified error */
84*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_ELENGTH		= 1,	/* wrong data length */
85*7c478bd9Sstevel@tonic-gate 	SBP2_BUS_BUF_EBUSY		= 2	/* device busy */
86*7c478bd9Sstevel@tonic-gate };
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate typedef struct sbp2_bus {
89*7c478bd9Sstevel@tonic-gate 	int		sb_rev;
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 	/* static parameters */
92*7c478bd9Sstevel@tonic-gate 	uint64_t	sb_csr_base;	/* CSR base address */
93*7c478bd9Sstevel@tonic-gate 	uint64_t	sb_cfgrom_addr;	/* Config ROM address */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 	/* functions */
96*7c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t (*sb_get_iblock_cookie)(void *hdl);
97*7c478bd9Sstevel@tonic-gate 	uint_t		(*sb_get_node_id)(void *hdl);
98*7c478bd9Sstevel@tonic-gate 	int		(*sb_alloc_buf)(void *hdl, sbp2_bus_buf_t *buf);
99*7c478bd9Sstevel@tonic-gate 	void		(*sb_free_buf)(void *hdl, sbp2_bus_buf_t *buf);
100*7c478bd9Sstevel@tonic-gate 	int		(*sb_sync_buf)(void *hdl, sbp2_bus_buf_t *buf,
101*7c478bd9Sstevel@tonic-gate 			    off_t offset, size_t length, int type);
102*7c478bd9Sstevel@tonic-gate 	void		(*sb_buf_rd_done)(void *hdl, sbp2_bus_buf_t *buf,
103*7c478bd9Sstevel@tonic-gate 			    void *reqh, int error);
104*7c478bd9Sstevel@tonic-gate 	void		(*sb_buf_wr_done)(void *hdl, sbp2_bus_buf_t *buf,
105*7c478bd9Sstevel@tonic-gate 			    void *reqh, int error);
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 	int		(*sb_alloc_cmd)(void *hdl, void **cmdp, int flags);
108*7c478bd9Sstevel@tonic-gate 	void		(*sb_free_cmd)(void *hdl, void *cmd);
109*7c478bd9Sstevel@tonic-gate 	int		(*sb_rq)(void *hdl, void *cmd, uint64_t addr,
110*7c478bd9Sstevel@tonic-gate 			    uint32_t *q, int *berr);
111*7c478bd9Sstevel@tonic-gate 	int		(*sb_rb)(void *hdl, void *cmd, uint64_t addr,
112*7c478bd9Sstevel@tonic-gate 			    mblk_t **bpp, int len, int *err);
113*7c478bd9Sstevel@tonic-gate 	int		(*sb_wq)(void *hdl, void *cmd, uint64_t addr,
114*7c478bd9Sstevel@tonic-gate 			    uint32_t q, int *berr);
115*7c478bd9Sstevel@tonic-gate 	int		(*sb_wb)(void *hdl, void *cmd, uint64_t addr,
116*7c478bd9Sstevel@tonic-gate 			    mblk_t *bp, int len, int *berr);
117*7c478bd9Sstevel@tonic-gate } sbp2_bus_t;
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
120*7c478bd9Sstevel@tonic-gate }
121*7c478bd9Sstevel@tonic-gate #endif
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_SBP2_BUS_H */
124