Home | History | Annotate | Line # | Download | only in ic
mpt.h revision 1.6.38.2
      1  1.6.38.2  tron /*	$NetBSD: mpt.h,v 1.6.38.2 2007/07/27 13:06:52 tron Exp $	*/
      2  1.6.38.2  tron 
      3  1.6.38.2  tron /*
      4  1.6.38.2  tron  * Copyright (c) 2000, 2001 by Greg Ansley
      5  1.6.38.2  tron  *
      6  1.6.38.2  tron  * Redistribution and use in source and binary forms, with or without
      7  1.6.38.2  tron  * modification, are permitted provided that the following conditions
      8  1.6.38.2  tron  * are met:
      9  1.6.38.2  tron  * 1. Redistributions of source code must retain the above copyright
     10  1.6.38.2  tron  *    notice immediately at the beginning of the file, without modification,
     11  1.6.38.2  tron  *    this list of conditions, and the following disclaimer.
     12  1.6.38.2  tron  * 2. The name of the author may not be used to endorse or promote products
     13  1.6.38.2  tron  *    derived from this software without specific prior written permission.
     14  1.6.38.2  tron  *
     15  1.6.38.2  tron  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  1.6.38.2  tron  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  1.6.38.2  tron  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  1.6.38.2  tron  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     19  1.6.38.2  tron  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.6.38.2  tron  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  1.6.38.2  tron  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.6.38.2  tron  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.6.38.2  tron  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.6.38.2  tron  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.6.38.2  tron  * SUCH DAMAGE.
     26  1.6.38.2  tron  */
     27  1.6.38.2  tron /*
     28  1.6.38.2  tron  * Additional Copyright (c) 2002 by Matthew Jacob under same license.
     29  1.6.38.2  tron  */
     30  1.6.38.2  tron 
     31  1.6.38.2  tron /*
     32  1.6.38.2  tron  * mpt.h:
     33  1.6.38.2  tron  *
     34  1.6.38.2  tron  * Generic definitions for LSI Fusion adapters.
     35  1.6.38.2  tron  *
     36  1.6.38.2  tron  * Adapted from the FreeBSD "mpt" driver by Jason R. Thorpe for
     37  1.6.38.2  tron  * Wasabi Systems, Inc.
     38  1.6.38.2  tron  */
     39  1.6.38.2  tron 
     40  1.6.38.2  tron #ifndef _DEV_IC_MPT_H_
     41  1.6.38.2  tron #define	_DEV_IC_MPT_H_
     42  1.6.38.2  tron 
     43  1.6.38.2  tron #include <dev/ic/mpt_netbsd.h>
     44  1.6.38.2  tron 
     45  1.6.38.2  tron #define MPT_OK (0)
     46  1.6.38.2  tron #define MPT_FAIL (0x10000)
     47  1.6.38.2  tron 
     48  1.6.38.2  tron /* Register Offset to chip registers */
     49  1.6.38.2  tron #define MPT_OFFSET_DOORBELL     0x00
     50  1.6.38.2  tron #define MPT_OFFSET_SEQUENCE     0x04
     51  1.6.38.2  tron #define MPT_OFFSET_DIAGNOSTIC   0x08
     52  1.6.38.2  tron #define MPT_OFFSET_TEST         0x0C
     53  1.6.38.2  tron #define MPT_OFFSET_INTR_STATUS  0x30
     54  1.6.38.2  tron #define MPT_OFFSET_INTR_MASK    0x34
     55  1.6.38.2  tron #define MPT_OFFSET_REQUEST_Q    0x40
     56  1.6.38.2  tron #define MPT_OFFSET_REPLY_Q      0x44
     57  1.6.38.2  tron #define MPT_OFFSET_HOST_INDEX   0x50
     58  1.6.38.2  tron #define MPT_OFFSET_FUBAR        0x90
     59  1.6.38.2  tron 
     60  1.6.38.2  tron #define MPT_DIAG_SEQUENCE_1     0x04
     61  1.6.38.2  tron #define MPT_DIAG_SEQUENCE_2     0x0b
     62  1.6.38.2  tron #define MPT_DIAG_SEQUENCE_3     0x02
     63  1.6.38.2  tron #define MPT_DIAG_SEQUENCE_4     0x07
     64  1.6.38.2  tron #define MPT_DIAG_SEQUENCE_5     0x0d
     65  1.6.38.2  tron 
     66  1.6.38.2  tron /* Bit Maps for DOORBELL register */
     67  1.6.38.2  tron enum DB_STATE_BITS {
     68  1.6.38.2  tron 	MPT_DB_STATE_RESET   =    0x00000000,
     69  1.6.38.2  tron 	MPT_DB_STATE_READY   =    0x10000000,
     70  1.6.38.2  tron 	MPT_DB_STATE_RUNNING =    0x20000000,
     71  1.6.38.2  tron 	MPT_DB_STATE_FAULT   =    0x40000000,
     72  1.6.38.2  tron 	MPT_DB_STATE_MASK    =    0xf0000000
     73  1.6.38.2  tron };
     74  1.6.38.2  tron 
     75  1.6.38.2  tron #define MPT_STATE(v) ((enum DB_STATE_BITS)((v) & MPT_DB_STATE_MASK))
     76  1.6.38.2  tron 
     77  1.6.38.2  tron #define MPT_DB_LENGTH_SHIFT (16)
     78  1.6.38.2  tron #define MPT_DB_DATA_MASK (0xffff)
     79  1.6.38.2  tron 
     80  1.6.38.2  tron #define MPT_DB_DB_USED            0x08000000
     81  1.6.38.2  tron #define MPT_DB_IS_IN_USE(v) (((v) & MPT_DB_DB_USED) != 0)
     82  1.6.38.2  tron 
     83  1.6.38.2  tron /*
     84  1.6.38.2  tron  * "Whom" initializor values
     85  1.6.38.2  tron  */
     86  1.6.38.2  tron #define	MPT_DB_INIT_NOONE       0x00
     87  1.6.38.2  tron #define	MPT_DB_INIT_BIOS        0x01
     88  1.6.38.2  tron #define	MPT_DB_INIT_ROMBIOS     0x02
     89  1.6.38.2  tron #define	MPT_DB_INIT_PCIPEER     0x03
     90  1.6.38.2  tron #define	MPT_DB_INIT_HOST        0x04
     91  1.6.38.2  tron #define	MPT_DB_INIT_MANUFACTURE 0x05
     92  1.6.38.2  tron 
     93  1.6.38.2  tron #define MPT_WHO(v)	\
     94  1.6.38.2  tron 	((v & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT)
     95  1.6.38.2  tron 
     96  1.6.38.2  tron /* Function Maps for DOORBELL register */
     97  1.6.38.2  tron enum DB_FUNCTION_BITS {
     98  1.6.38.2  tron 	MPT_FUNC_IOC_RESET    =    0x40000000,
     99  1.6.38.2  tron 	MPT_FUNC_UNIT_RESET   =    0x41000000,
    100  1.6.38.2  tron 	MPT_FUNC_HANDSHAKE    =    0x42000000,
    101  1.6.38.2  tron 	MPT_FUNC_REPLY_REMOVE =    0x43000000,
    102  1.6.38.2  tron 	MPT_FUNC_MASK         =    0xff000000
    103  1.6.38.2  tron };
    104  1.6.38.2  tron 
    105  1.6.38.2  tron /* Function Maps for INTERRUPT request register */
    106  1.6.38.2  tron enum _MPT_INTR_REQ_BITS {
    107  1.6.38.2  tron 	MPT_INTR_DB_BUSY      =    0x80000000,
    108  1.6.38.2  tron 	MPT_INTR_REPLY_READY  =    0x00000008,
    109  1.6.38.2  tron 	MPT_INTR_DB_READY     =    0x00000001
    110  1.6.38.2  tron };
    111  1.6.38.2  tron 
    112  1.6.38.2  tron #define MPT_DB_IS_BUSY(v) (((v) & MPT_INTR_DB_BUSY) != 0)
    113  1.6.38.2  tron #define MPT_DB_INTR(v)    (((v) & MPT_INTR_DB_READY) != 0)
    114  1.6.38.2  tron #define MPT_REPLY_INTR(v) (((v) & MPT_INTR_REPLY_READY) != 0)
    115  1.6.38.2  tron 
    116  1.6.38.2  tron /* Function Maps for INTERRUPT make register */
    117  1.6.38.2  tron enum _MPT_INTR_MASK_BITS {
    118  1.6.38.2  tron 	MPT_INTR_REPLY_MASK   =    0x00000008,
    119  1.6.38.2  tron 	MPT_INTR_DB_MASK      =    0x00000001
    120  1.6.38.2  tron };
    121  1.6.38.2  tron 
    122  1.6.38.2  tron /* Function Maps for DIAGNOSTIC make register */
    123  1.6.38.2  tron enum _MPT_DIAG_BITS {
    124  1.6.38.2  tron 	MPT_DIAG_ENABLED      =    0x00000080,
    125  1.6.38.2  tron 	MPT_DIAG_FLASHBAD     =    0x00000040,
    126  1.6.38.2  tron 	MPT_DIAG_RESET_HIST   =    0x00000020,
    127  1.6.38.2  tron 	MPT_DIAG_TTLI         =    0x00000008,
    128  1.6.38.2  tron 	MPT_DIAG_RESET_IOC    =    0x00000004,
    129  1.6.38.2  tron 	MPT_DIAG_ARM_DISABLE  =    0x00000002,
    130  1.6.38.2  tron 	MPT_DIAG_DME          =    0x00000001
    131  1.6.38.2  tron };
    132  1.6.38.2  tron 
    133  1.6.38.2  tron /* Magic addresses in diagnostic memory space */
    134  1.6.38.2  tron #define MPT_DIAG_IOP_BASE        (0x00000000)
    135  1.6.38.2  tron #define MPT_DIAG_IOP_SIZE                      (0x00002000)
    136  1.6.38.2  tron #define MPT_DIAG_GPIO            (0x00030010)
    137  1.6.38.2  tron #define MPT_DIAG_IOPQ_REG_BASE0  (0x00050004)
    138  1.6.38.2  tron #define MPT_DIAG_IOPQ_REG_BASE1  (0x00051004)
    139  1.6.38.2  tron #define MPT_DIAG_MEM_CFG_BASE    (0x00040000)
    140  1.6.38.2  tron #define MPT_DIAG_CTX0_BASE       (0x000E0000)
    141  1.6.38.2  tron #define MPT_DIAG_CTX0_SIZE                     (0x00002000)
    142  1.6.38.2  tron #define MPT_DIAG_CTX1_BASE       (0x001E0000)
    143  1.6.38.2  tron #define MPT_DIAG_CTX1_SIZE                     (0x00002000)
    144  1.6.38.2  tron #define MPT_DIAG_FLASH_BASE      (0x00800000)
    145  1.6.38.2  tron #define MPT_DIAG_RAM_BASE        (0x01000000)
    146  1.6.38.2  tron #define MPT_DIAG_RAM_SIZE                      (0x00400000)
    147  1.6.38.2  tron 
    148  1.6.38.2  tron /* GPIO bit assignments */
    149  1.6.38.2  tron #define MPT_DIAG_GPIO_SCL	(0x00010000)
    150  1.6.38.2  tron #define MPT_DIAG_GPIO_SDA_OUT	(0x00008000)
    151  1.6.38.2  tron #define MPT_DIAG_GPIO_SDA_IN	(0x00004000)
    152  1.6.38.2  tron 
    153  1.6.38.2  tron #define MPT_REPLY_EMPTY   (0xffffffff)    /* Reply Queue Empty Symbol */
    154  1.6.38.2  tron #define MPT_CONTEXT_REPLY (0x80000000)
    155  1.6.38.2  tron #define MPT_CONTEXT_MASK  (~0xE0000000)
    156  1.6.38.2  tron 
    157  1.6.38.2  tron #ifdef _KERNEL
    158  1.6.38.2  tron int mpt_soft_reset(mpt_softc_t *);
    159  1.6.38.2  tron void mpt_hard_reset(mpt_softc_t *);
    160  1.6.38.2  tron int mpt_recv_handshake_reply(mpt_softc_t *, size_t, void *);
    161  1.6.38.2  tron 
    162  1.6.38.2  tron void mpt_send_cmd(mpt_softc_t *, request_t *);
    163  1.6.38.2  tron void mpt_free_reply(mpt_softc_t *, u_int32_t);
    164  1.6.38.2  tron void mpt_enable_ints(mpt_softc_t *);
    165  1.6.38.2  tron void mpt_disable_ints(mpt_softc_t *);
    166  1.6.38.2  tron u_int32_t mpt_pop_reply_queue(mpt_softc_t *);
    167  1.6.38.2  tron int mpt_hw_init(mpt_softc_t *);
    168  1.6.38.2  tron int mpt_init(mpt_softc_t *, u_int32_t);
    169  1.6.38.2  tron int mpt_reset(mpt_softc_t *);
    170  1.6.38.2  tron int mpt_send_handshake_cmd(mpt_softc_t *, size_t, void *);
    171  1.6.38.2  tron request_t * mpt_get_request(mpt_softc_t *);
    172  1.6.38.2  tron void mpt_free_request(mpt_softc_t *, request_t *);
    173  1.6.38.2  tron int mpt_intr(void *);
    174  1.6.38.2  tron void mpt_check_doorbell(mpt_softc_t *);
    175  1.6.38.2  tron 
    176  1.6.38.2  tron int mpt_read_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *);
    177  1.6.38.2  tron int mpt_write_cfg_page(mpt_softc_t *, int, fCONFIG_PAGE_HEADER *);
    178  1.6.38.2  tron 
    179  1.6.38.2  tron /* mpt_debug.c functions */
    180  1.6.38.2  tron void mpt_print_reply(void *);
    181  1.6.38.2  tron void mpt_print_db(u_int32_t);
    182  1.6.38.2  tron void mpt_print_config_reply(void *);
    183  1.6.38.2  tron char *mpt_ioc_diag(u_int32_t);
    184  1.6.38.2  tron const char *mpt_req_state(enum mpt_req_state);
    185  1.6.38.2  tron void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *);
    186  1.6.38.2  tron void mpt_print_config_request(void *);
    187  1.6.38.2  tron void mpt_print_request(void *);
    188  1.6.38.2  tron #endif /* _KERNEL */
    189  1.6.38.2  tron 
    190  1.6.38.2  tron #endif /* _DEV_IC_MPT_H_ */
    191