Home | History | Annotate | Line # | Download | only in ic
      1  1.5  jdolecek /*	$NetBSD: mvsatavar.h,v 1.5 2018/10/22 20:13:47 jdolecek Exp $	*/
      2  1.1  kiyohara /*
      3  1.1  kiyohara  * Copyright (c) 2008 KIYOHARA Takashi
      4  1.1  kiyohara  * All rights reserved.
      5  1.1  kiyohara  *
      6  1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
      7  1.1  kiyohara  * modification, are permitted provided that the following conditions
      8  1.1  kiyohara  * are met:
      9  1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
     10  1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
     11  1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
     14  1.1  kiyohara  *
     15  1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  1.1  kiyohara  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17  1.1  kiyohara  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18  1.1  kiyohara  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     19  1.1  kiyohara  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     20  1.1  kiyohara  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21  1.1  kiyohara  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1  kiyohara  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     23  1.1  kiyohara  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     24  1.1  kiyohara  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  kiyohara  * POSSIBILITY OF SUCH DAMAGE.
     26  1.1  kiyohara  */
     27  1.1  kiyohara 
     28  1.1  kiyohara #ifndef _MVSATAVAR_H_
     29  1.1  kiyohara #define _MVSATAVAR_H_
     30  1.1  kiyohara 
     31  1.2  kiyohara struct mvsata_product {
     32  1.2  kiyohara 	int vendor;
     33  1.2  kiyohara 	int model;
     34  1.2  kiyohara 	int hc;
     35  1.2  kiyohara 	int port;
     36  1.2  kiyohara 	int generation;
     37  1.2  kiyohara 	int flags;
     38  1.2  kiyohara };
     39  1.2  kiyohara 
     40  1.1  kiyohara #define MVSATA_EDMAQ_LEN	32	/* keep compatibility to gen1 */
     41  1.1  kiyohara #define MVSATA_EDMAQ_INC(i)	((i) = ((i) + 1) % MVSATA_EDMAQ_LEN)
     42  1.1  kiyohara #define MVSATA_HC_MAX		2
     43  1.1  kiyohara #define MVSATA_PORT_MAX		4
     44  1.1  kiyohara #define MVSATA_CHANNEL_MAX	(MVSATA_HC_MAX * MVSATA_PORT_MAX)
     45  1.1  kiyohara 
     46  1.1  kiyohara 
     47  1.1  kiyohara struct mvsata_port;
     48  1.1  kiyohara 
     49  1.1  kiyohara union mvsata_crqb {
     50  1.1  kiyohara 	struct crqb crqb;
     51  1.1  kiyohara 	struct crqb_gen2e crqb_gen2e;
     52  1.1  kiyohara };
     53  1.1  kiyohara 
     54  1.1  kiyohara struct _fix_phy_param {
     55  1.1  kiyohara 	uint32_t pre_amps;		/* Pre/SignalAmps */
     56  1.1  kiyohara 
     57  1.1  kiyohara 	void (*_fix_phy)(struct mvsata_port *);
     58  1.1  kiyohara };
     59  1.1  kiyohara 
     60  1.3  jdolecek enum mvsata_edmamode {
     61  1.3  jdolecek 	nodma,
     62  1.3  jdolecek 	dma,
     63  1.3  jdolecek 	queued,
     64  1.3  jdolecek 	ncq,
     65  1.3  jdolecek };
     66  1.3  jdolecek 
     67  1.1  kiyohara struct mvsata_port {
     68  1.1  kiyohara 	struct ata_channel port_ata_channel;
     69  1.1  kiyohara 
     70  1.1  kiyohara 	int port;
     71  1.1  kiyohara 	struct mvsata_hc *port_hc;
     72  1.1  kiyohara 
     73  1.3  jdolecek 	enum mvsata_edmamode port_edmamode_negotiated;
     74  1.3  jdolecek 	enum mvsata_edmamode port_edmamode_curr;
     75  1.1  kiyohara 
     76  1.1  kiyohara 	int port_prev_erqqop;		/* previous Req Queue Out-Pointer */
     77  1.1  kiyohara 	bus_dma_tag_t port_dmat;
     78  1.1  kiyohara 	union mvsata_crqb *port_crqb;	/* EDMA Command Request Block */
     79  1.1  kiyohara 	bus_dmamap_t port_crqb_dmamap;
     80  1.1  kiyohara 	struct crpb *port_crpb;		/* EDMA Command Response Block */
     81  1.1  kiyohara 	bus_dmamap_t port_crpb_dmamap;
     82  1.1  kiyohara 	struct eprd *port_eprd;		/* EDMA Phy Region Description Table */
     83  1.1  kiyohara 	bus_dmamap_t port_eprd_dmamap;
     84  1.1  kiyohara 	struct {
     85  1.1  kiyohara 		bus_dmamap_t data_dmamap;	/* DMA data buffer */
     86  1.1  kiyohara 		bus_size_t eprd_offset;		/* offset of ePRD buffer */
     87  1.1  kiyohara 		struct eprd *eprd;		/* ePRD buffer */
     88  1.1  kiyohara 	} port_reqtbl[MVSATA_EDMAQ_LEN];
     89  1.1  kiyohara 
     90  1.1  kiyohara 	bus_space_tag_t port_iot;
     91  1.1  kiyohara 	bus_space_handle_t port_ioh;
     92  1.1  kiyohara 	bus_space_handle_t port_sata_scontrol;	/* SATA Interface control reg */
     93  1.1  kiyohara 	bus_space_handle_t port_sata_serror;	/* SATA Interface error reg */
     94  1.1  kiyohara 	bus_space_handle_t port_sata_sstatus;	/* SATA Interface status reg */
     95  1.1  kiyohara 
     96  1.1  kiyohara 	struct _fix_phy_param _fix_phy_param;
     97  1.1  kiyohara };
     98  1.1  kiyohara 
     99  1.1  kiyohara struct mvsata_hc {
    100  1.1  kiyohara 	int hc;
    101  1.1  kiyohara 	struct mvsata_softc *hc_sc;
    102  1.1  kiyohara 
    103  1.1  kiyohara 	bus_space_tag_t hc_iot;		/* Tag for SATAHC Arbiter */
    104  1.1  kiyohara 	bus_space_handle_t hc_ioh;	/* Handle for SATAHC Arbiter */
    105  1.1  kiyohara 
    106  1.1  kiyohara 	struct mvsata_port *hc_ports[MVSATA_CHANNEL_MAX];
    107  1.1  kiyohara };
    108  1.1  kiyohara 
    109  1.1  kiyohara struct mvsata_softc {
    110  1.1  kiyohara 	struct wdc_softc sc_wdcdev;	/* common wdc definitions */
    111  1.1  kiyohara 
    112  1.1  kiyohara 	int sc_model;
    113  1.1  kiyohara 	int sc_rev;
    114  1.1  kiyohara 	enum {
    115  1.1  kiyohara 		gen_unknown = 0,
    116  1.1  kiyohara 		gen1,
    117  1.1  kiyohara 		gen2,
    118  1.1  kiyohara 		gen2e
    119  1.1  kiyohara 	} sc_gen;			/* Generation for LSI */
    120  1.1  kiyohara 	int sc_hc;			/* number of host controller */
    121  1.1  kiyohara 	int sc_port;			/* number of port/host */
    122  1.1  kiyohara 
    123  1.1  kiyohara 	bus_space_tag_t sc_iot;
    124  1.1  kiyohara 	bus_space_handle_t sc_ioh;
    125  1.1  kiyohara 	bus_dma_tag_t sc_dmat;
    126  1.1  kiyohara 
    127  1.1  kiyohara 	struct wdc_regs *sc_wdc_regs;
    128  1.1  kiyohara 	struct ata_channel *sc_ata_channels[MVSATA_CHANNEL_MAX];
    129  1.1  kiyohara 	struct mvsata_hc sc_hcs[MVSATA_HC_MAX];
    130  1.1  kiyohara 
    131  1.1  kiyohara 	int sc_flags;
    132  1.1  kiyohara #define MVSATA_FLAGS_PCIE	(1 << 0)
    133  1.1  kiyohara 
    134  1.3  jdolecek 	void (*sc_edma_setup_crqb)(struct mvsata_port *, int,
    135  1.3  jdolecek 				   struct ata_xfer *);
    136  1.1  kiyohara 	void (*sc_enable_intr)(struct mvsata_port *, int);
    137  1.1  kiyohara };
    138  1.1  kiyohara 
    139  1.4  jdolecek int mvsata_attach(struct mvsata_softc *, const struct mvsata_product *,
    140  1.1  kiyohara 		  int (*mvsata_sreset)(struct mvsata_softc *),
    141  1.1  kiyohara 		  int (*mvsata_misc_reset)(struct mvsata_softc *), int);
    142  1.1  kiyohara int mvsata_intr(struct mvsata_hc *);
    143  1.1  kiyohara int mvsata_error(struct mvsata_port *);
    144  1.1  kiyohara 
    145  1.1  kiyohara #endif	/* _MVSATAVAR_H_ */
    146