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