2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2010, LSI Corp.
6 * Author : Manjunath Ranganathaiah
7 * Support: freebsdraid@lsi.com
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
19 * 3. Neither the name of the <ORGANIZATION> nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
39 /* #define TWS_DEBUG on */
41 void tws_trace(const char *file, const char *fun, int linenum,
42 struct tws_softc *sc, char *desc, u_int64_t val1, u_int64_t val2);
43 void tws_log(struct tws_softc *sc, int index);
44 u_int32_t tws_read_reg(struct tws_softc *sc,
45 int offset, int size);
46 void tws_write_reg(struct tws_softc *sc, int offset,
47 u_int32_t value, int size);
49 u_int16_t tws_swap16(u_int16_t val);
50 u_int32_t tws_swap32(u_int32_t val);
51 u_int64_t tws_swap64(u_int64_t val);
53 void tws_init_qs(struct tws_softc *sc);
55 /* ----------------- trace ----------------- */
57 #define TWS_TRACE_ON on /* Alawys on - use wisely to trace errors */
60 #define TWS_TRACE_DEBUG_ON on
63 #ifdef TWS_TRACE_DEBUG_ON
64 #define TWS_TRACE_DEBUG(sc, desc, val1, val2) \
65 tws_trace(__FILE__, __func__, __LINE__, sc, desc, \
66 (u_int64_t)val1, (u_int64_t)val2)
68 #define TWS_TRACE_DEBUG(sc, desc, val1, val2)
72 #define TWS_TRACE(sc, desc, val1, val2) \
73 tws_trace(__FILE__, __func__, __LINE__, sc, desc, \
74 (u_int64_t)val1, (u_int64_t)val2)
76 #define TWS_TRACE(sc, desc, val1, val2)
79 /* ---------------- logging ---------------- */
81 /* ---------------- logging ---------------- */
95 TWS_CTLR_INIT_FAILURE,
109 u_int32_t error_code;
115 /* ----------- q services ------------- */
118 #define TWS_PENDING_Q 1
120 #define TWS_COMPLETE_Q 3
122 /* req return codes */
123 #define TWS_REQ_RET_SUBMIT_SUCCESS 0
124 #define TWS_REQ_RET_PEND_NOMFA 1
125 #define TWS_REQ_RET_RESET 2
126 #define TWS_REQ_RET_INVALID 0xdead
128 /* ------------------------ */
129 #include <sys/clock.h>
130 #define TWS_LOCAL_TIME (time_second - utc_offset())