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