Home | History | Annotate | Line # | Download | only in ic
mvsatavar.h revision 1.2.48.3
      1  1.2.48.3  jdolecek /*	$NetBSD: mvsatavar.h,v 1.2.48.3 2017/08/01 22:02:32 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.2.48.2  jdolecek enum mvsata_edmamode {
     61  1.2.48.2  jdolecek 	nodma,
     62  1.2.48.2  jdolecek 	dma,
     63  1.2.48.2  jdolecek 	queued,
     64  1.2.48.2  jdolecek 	ncq,
     65  1.2.48.2  jdolecek };
     66  1.2.48.2  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.2.48.2  jdolecek 	enum mvsata_edmamode port_edmamode_negotiated;
     74  1.2.48.2  jdolecek 	enum mvsata_edmamode port_edmamode_curr;
     75       1.1  kiyohara 
     76  1.2.48.3  jdolecek 	volatile uint32_t port_quetagidx;	/* Host Queue Tag valid */
     77       1.1  kiyohara 
     78       1.1  kiyohara 	int port_prev_erqqop;		/* previous Req Queue Out-Pointer */
     79       1.1  kiyohara 	bus_dma_tag_t port_dmat;
     80       1.1  kiyohara 	union mvsata_crqb *port_crqb;	/* EDMA Command Request Block */
     81       1.1  kiyohara 	bus_dmamap_t port_crqb_dmamap;
     82       1.1  kiyohara 	struct crpb *port_crpb;		/* EDMA Command Response Block */
     83       1.1  kiyohara 	bus_dmamap_t port_crpb_dmamap;
     84       1.1  kiyohara 	struct eprd *port_eprd;		/* EDMA Phy Region Description Table */
     85       1.1  kiyohara 	bus_dmamap_t port_eprd_dmamap;
     86       1.1  kiyohara 	struct {
     87       1.1  kiyohara 		bus_dmamap_t data_dmamap;	/* DMA data buffer */
     88       1.1  kiyohara 		bus_size_t eprd_offset;		/* offset of ePRD buffer */
     89       1.1  kiyohara 		struct eprd *eprd;		/* ePRD buffer */
     90       1.1  kiyohara 	} port_reqtbl[MVSATA_EDMAQ_LEN];
     91       1.1  kiyohara 
     92       1.1  kiyohara 	bus_space_tag_t port_iot;
     93       1.1  kiyohara 	bus_space_handle_t port_ioh;
     94       1.1  kiyohara 	bus_space_handle_t port_sata_scontrol;	/* SATA Interface control reg */
     95       1.1  kiyohara 	bus_space_handle_t port_sata_serror;	/* SATA Interface error reg */
     96       1.1  kiyohara 	bus_space_handle_t port_sata_sstatus;	/* SATA Interface status reg */
     97       1.1  kiyohara 
     98       1.1  kiyohara 	struct _fix_phy_param _fix_phy_param;
     99       1.1  kiyohara };
    100       1.1  kiyohara 
    101       1.1  kiyohara struct mvsata_hc {
    102       1.1  kiyohara 	int hc;
    103       1.1  kiyohara 	struct mvsata_softc *hc_sc;
    104       1.1  kiyohara 
    105       1.1  kiyohara 	bus_space_tag_t hc_iot;		/* Tag for SATAHC Arbiter */
    106       1.1  kiyohara 	bus_space_handle_t hc_ioh;	/* Handle for SATAHC Arbiter */
    107       1.1  kiyohara 
    108       1.1  kiyohara 	struct mvsata_port *hc_ports[MVSATA_CHANNEL_MAX];
    109       1.1  kiyohara };
    110       1.1  kiyohara 
    111       1.1  kiyohara struct mvsata_softc {
    112       1.1  kiyohara 	struct wdc_softc sc_wdcdev;	/* common wdc definitions */
    113       1.1  kiyohara 
    114       1.1  kiyohara 	int sc_model;
    115       1.1  kiyohara 	int sc_rev;
    116       1.1  kiyohara 	enum {
    117       1.1  kiyohara 		gen_unknown = 0,
    118       1.1  kiyohara 		gen1,
    119       1.1  kiyohara 		gen2,
    120       1.1  kiyohara 		gen2e
    121       1.1  kiyohara 	} sc_gen;			/* Generation for LSI */
    122       1.1  kiyohara 	int sc_hc;			/* number of host controller */
    123       1.1  kiyohara 	int sc_port;			/* number of port/host */
    124       1.1  kiyohara 
    125       1.1  kiyohara 	bus_space_tag_t sc_iot;
    126       1.1  kiyohara 	bus_space_handle_t sc_ioh;
    127       1.1  kiyohara 	bus_dma_tag_t sc_dmat;
    128       1.1  kiyohara 
    129       1.1  kiyohara 	struct wdc_regs *sc_wdc_regs;
    130       1.1  kiyohara 	struct ata_channel *sc_ata_channels[MVSATA_CHANNEL_MAX];
    131       1.1  kiyohara 	struct mvsata_hc sc_hcs[MVSATA_HC_MAX];
    132       1.1  kiyohara 
    133       1.1  kiyohara 	int sc_flags;
    134       1.1  kiyohara #define MVSATA_FLAGS_PCIE	(1 << 0)
    135       1.1  kiyohara 
    136  1.2.48.1  jdolecek 	void (*sc_edma_setup_crqb)(struct mvsata_port *, int,
    137  1.2.48.1  jdolecek 				   struct ata_xfer *);
    138       1.1  kiyohara 	void (*sc_enable_intr)(struct mvsata_port *, int);
    139       1.1  kiyohara };
    140       1.1  kiyohara 
    141       1.2  kiyohara int mvsata_attach(struct mvsata_softc *, struct mvsata_product *,
    142       1.1  kiyohara 		  int (*mvsata_sreset)(struct mvsata_softc *),
    143       1.1  kiyohara 		  int (*mvsata_misc_reset)(struct mvsata_softc *), int);
    144       1.1  kiyohara int mvsata_intr(struct mvsata_hc *);
    145       1.1  kiyohara int mvsata_error(struct mvsata_port *);
    146       1.1  kiyohara 
    147       1.1  kiyohara #endif	/* _MVSATAVAR_H_ */
    148