Home | History | Annotate | Line # | Download | only in ic
      1  1.9  jdolecek /* $NetBSD: siisatavar.h,v 1.9 2018/10/24 19:38:00 jdolecek Exp $ */
      2  1.1   jnemeth 
      3  1.1   jnemeth /* from ahcisatavar.h */
      4  1.1   jnemeth 
      5  1.1   jnemeth /*
      6  1.1   jnemeth  * Copyright (c) 2006 Manuel Bouyer.
      7  1.1   jnemeth  *
      8  1.1   jnemeth  * Redistribution and use in source and binary forms, with or without
      9  1.1   jnemeth  * modification, are permitted provided that the following conditions
     10  1.1   jnemeth  * are met:
     11  1.1   jnemeth  * 1. Redistributions of source code must retain the above copyright
     12  1.1   jnemeth  *    notice, this list of conditions and the following disclaimer.
     13  1.1   jnemeth  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1   jnemeth  *    notice, this list of conditions and the following disclaimer in the
     15  1.1   jnemeth  *    documentation and/or other materials provided with the distribution.
     16  1.1   jnemeth  *
     17  1.1   jnemeth  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  1.1   jnemeth  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.1   jnemeth  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.1   jnemeth  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  1.1   jnemeth  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  1.1   jnemeth  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  1.1   jnemeth  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  1.1   jnemeth  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  1.1   jnemeth  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26  1.1   jnemeth  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  1.1   jnemeth  *
     28  1.1   jnemeth  */
     29  1.1   jnemeth 
     30  1.1   jnemeth /*-
     31  1.4  jakllsch  * Copyright (c) 2007, 2008, 2009 Jonathan A. Kollasch.
     32  1.1   jnemeth  * All rights reserved.
     33  1.1   jnemeth  *
     34  1.1   jnemeth  * Redistribution and use in source and binary forms, with or without
     35  1.1   jnemeth  * modification, are permitted provided that the following conditions
     36  1.1   jnemeth  * are met:
     37  1.1   jnemeth  * 1. Redistributions of source code must retain the above copyright
     38  1.1   jnemeth  *    notice, this list of conditions and the following disclaimer.
     39  1.1   jnemeth  * 2. Redistributions in binary form must reproduce the above copyright
     40  1.1   jnemeth  *    notice, this list of conditions and the following disclaimer in the
     41  1.1   jnemeth  *    documentation and/or other materials provided with the distribution.
     42  1.1   jnemeth  *
     43  1.1   jnemeth  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     44  1.1   jnemeth  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     45  1.1   jnemeth  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     46  1.1   jnemeth  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     47  1.1   jnemeth  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     48  1.1   jnemeth  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     49  1.1   jnemeth  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     50  1.1   jnemeth  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     51  1.1   jnemeth  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     52  1.1   jnemeth  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     53  1.1   jnemeth  *
     54  1.1   jnemeth  */
     55  1.1   jnemeth 
     56  1.1   jnemeth #ifndef _IC_SIISATAVAR_H_
     57  1.1   jnemeth #define _IC_SIISATAVAR_H_
     58  1.1   jnemeth 
     59  1.1   jnemeth #include <dev/ic/siisatareg.h>
     60  1.1   jnemeth #include <dev/ata/atavar.h>
     61  1.1   jnemeth 
     62  1.1   jnemeth #define DEBUG_INTR   0x01
     63  1.1   jnemeth #define DEBUG_XFERS  0x02
     64  1.1   jnemeth #define DEBUG_FUNCS  0x08
     65  1.1   jnemeth #define DEBUG_PROBE  0x10
     66  1.1   jnemeth #define DEBUG_DETACH 0x20
     67  1.1   jnemeth #define DEBUG_DEBUG 0x80000000
     68  1.1   jnemeth #ifdef SIISATA_DEBUG
     69  1.1   jnemeth extern int siisata_debug_mask;
     70  1.1   jnemeth #define SIISATA_DEBUG_PRINT(args, level) \
     71  1.1   jnemeth 	if (siisata_debug_mask & (level)) \
     72  1.1   jnemeth 		printf args
     73  1.1   jnemeth #else
     74  1.1   jnemeth #define SIISATA_DEBUG_PRINT(args, level)
     75  1.1   jnemeth #endif
     76  1.1   jnemeth 
     77  1.1   jnemeth struct siisata_softc {
     78  1.1   jnemeth 	struct atac_softc sc_atac;
     79  1.1   jnemeth 	bus_space_tag_t sc_grt;
     80  1.1   jnemeth 	bus_space_handle_t sc_grh;
     81  1.3  jakllsch 	bus_size_t sc_grs;
     82  1.1   jnemeth 	bus_space_tag_t sc_prt;
     83  1.1   jnemeth 	bus_space_handle_t sc_prh;
     84  1.3  jakllsch 	bus_size_t sc_prs;
     85  1.1   jnemeth 	bus_dma_tag_t sc_dmat;
     86  1.1   jnemeth 
     87  1.1   jnemeth 	struct ata_channel *sc_chanarray[SIISATA_MAX_PORTS];
     88  1.1   jnemeth 	struct siisata_channel {
     89  1.1   jnemeth 		struct ata_channel ata_channel;
     90  1.1   jnemeth 		bus_space_handle_t sch_scontrol;
     91  1.1   jnemeth 		bus_space_handle_t sch_sstatus;
     92  1.1   jnemeth 		bus_space_handle_t sch_serror;
     93  1.1   jnemeth 
     94  1.6  jakllsch 		bus_dma_segment_t sch_prb_seg;
     95  1.6  jakllsch 		int sch_prb_nseg;
     96  1.6  jakllsch 		bus_dmamap_t sch_prbd;
     97  1.1   jnemeth 		/* command activation PRBs */
     98  1.1   jnemeth 		struct siisata_prb *sch_prb[SIISATA_MAX_SLOTS];
     99  1.1   jnemeth 		bus_addr_t sch_bus_prb[SIISATA_MAX_SLOTS];
    100  1.1   jnemeth 
    101  1.1   jnemeth 		bus_dmamap_t sch_datad[SIISATA_MAX_SLOTS];
    102  1.1   jnemeth 	} sc_channels[SIISATA_MAX_PORTS];
    103  1.1   jnemeth };
    104  1.1   jnemeth 
    105  1.1   jnemeth #define SIISATANAME(sc) (device_xname((sc)->sc_atac.atac_dev))
    106  1.1   jnemeth 
    107  1.1   jnemeth #define GRREAD(sc, reg) bus_space_read_4((sc)->sc_grt, (sc)->sc_grh, (reg))
    108  1.1   jnemeth #define GRWRITE(sc, reg, val) bus_space_write_4((sc)->sc_grt, (sc)->sc_grh, (reg), (val))
    109  1.1   jnemeth #define PRREAD(sc, reg) bus_space_read_4((sc)->sc_prt, (sc)->sc_prh, (reg))
    110  1.1   jnemeth #define PRWRITE(sc, reg, val) bus_space_write_4((sc)->sc_prt, (sc)->sc_prh, (reg), (val))
    111  1.1   jnemeth 
    112  1.1   jnemeth #define SIISATA_PRB_SYNC(sc, schp, slot, op) bus_dmamap_sync((sc)->sc_dmat, \
    113  1.1   jnemeth     (schp)->sch_prbd, slot * SIISATA_CMD_SIZE, SIISATA_CMD_SIZE, (op))
    114  1.1   jnemeth 
    115  1.3  jakllsch void siisata_attach(struct siisata_softc *);
    116  1.3  jakllsch int siisata_detach(struct siisata_softc *, int);
    117  1.9  jdolecek void siisata_childdetached(struct siisata_softc *, device_t);
    118  1.3  jakllsch void siisata_resume(struct siisata_softc *);
    119  1.1   jnemeth int siisata_intr(void *);
    120  1.1   jnemeth 
    121  1.1   jnemeth #endif  /* !_IC_SIISATAVAR_H_ */
    122