Home | History | Annotate | Line # | Download | only in ic
      1  1.6  jdolecek /*	$NetBSD: ninjaata32var.h,v 1.6 2017/10/07 16:05:32 jdolecek Exp $	*/
      2  1.1     itohy 
      3  1.1     itohy /*
      4  1.5     itohy  * Copyright (c) 2006 ITOH Yasufumi.
      5  1.1     itohy  * All rights reserved.
      6  1.1     itohy  *
      7  1.1     itohy  * Redistribution and use in source and binary forms, with or without
      8  1.1     itohy  * modification, are permitted provided that the following conditions
      9  1.1     itohy  * are met:
     10  1.1     itohy  * 1. Redistributions of source code must retain the above copyright
     11  1.1     itohy  *    notice, this list of conditions and the following disclaimer.
     12  1.1     itohy  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1     itohy  *    notice, this list of conditions and the following disclaimer in the
     14  1.1     itohy  *    documentation and/or other materials provided with the distribution.
     15  1.1     itohy  *
     16  1.1     itohy  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS''
     17  1.1     itohy  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     18  1.1     itohy  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1     itohy  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS
     20  1.1     itohy  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1     itohy  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1     itohy  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1     itohy  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1     itohy  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1     itohy  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     26  1.1     itohy  * THE POSSIBILITY OF SUCH DAMAGE.
     27  1.1     itohy  */
     28  1.1     itohy 
     29  1.1     itohy #ifndef _NJATA32VAR_H_
     30  1.1     itohy #define _NJATA32VAR_H_
     31  1.1     itohy 
     32  1.4      cube #define NJATA32NAME(sc)		(device_xname(sc->sc_wdcdev.sc_atac.atac_dev))
     33  1.1     itohy 
     34  1.1     itohy /* ??? */
     35  1.1     itohy #define NJATA32_MAX_XFER	(64 * 1024)
     36  1.1     itohy 
     37  1.1     itohy /*
     38  1.1     itohy  * DMA page
     39  1.1     itohy  */
     40  1.1     itohy /* # device */
     41  1.1     itohy #define NJATA32_NUM_DEV	2
     42  1.1     itohy /* # scatter/gather table entries */
     43  1.1     itohy #define NJATA32_NUM_SG	NJATA32_SGT_MAXENTRY
     44  1.1     itohy 
     45  1.1     itohy struct njata32_dma_page {
     46  1.1     itohy 	/*
     47  1.1     itohy 	 * scatter/gather transfer table
     48  1.1     itohy 	 */
     49  1.1     itohy 	struct njata32_sgtable	dp_sg[NJATA32_NUM_DEV][NJATA32_NUM_SG];
     50  1.1     itohy };
     51  1.1     itohy 
     52  1.1     itohy #define NJATA32_NCHAN	1	/* only one channel */
     53  1.1     itohy 
     54  1.1     itohy struct njata32_softc {
     55  1.1     itohy 	struct wdc_softc	sc_wdcdev;	/* common wdc definitions */
     56  1.1     itohy 
     57  1.1     itohy 	unsigned		sc_flags;
     58  1.1     itohy #define NJATA32_IO_MAPPED		0x00000001
     59  1.1     itohy #define NJATA32_MEM_MAPPED		0x00000002
     60  1.1     itohy #define NJATA32_CMDPG_MAPPED		0x00000004
     61  1.1     itohy 
     62  1.1     itohy 	unsigned		sc_devflags;
     63  1.1     itohy 
     64  1.1     itohy 	/* interrupt handle */
     65  1.1     itohy 	void			*sc_ih;
     66  1.1     itohy 
     67  1.1     itohy 	struct ninjaata32_channel {		/* per-channel data */
     68  1.1     itohy 		struct ata_channel ch_ata_channel; /* generic part */
     69  1.1     itohy 	} sc_ch[NJATA32_NCHAN];
     70  1.1     itohy 
     71  1.1     itohy 	struct ata_channel	*sc_wdc_chanarray[NJATA32_NCHAN];
     72  1.1     itohy 	struct wdc_regs		sc_wdc_regs;
     73  1.1     itohy #define NJATA32_REGT(sc)	(sc)->sc_wdc_regs.cmd_iot
     74  1.1     itohy #define NJATA32_REGH(sc)	(sc)->sc_wdc_regs.cmd_baseioh
     75  1.1     itohy 
     76  1.1     itohy 	/* for DMA */
     77  1.1     itohy 	bus_dma_tag_t		sc_dmat;
     78  1.1     itohy 	struct njata32_dma_page	*sc_sgtpg;	/* scatter/gather table page */
     79  1.1     itohy #if 0
     80  1.1     itohy 	bus_addr_t		sc_sgt_dma;
     81  1.1     itohy #endif
     82  1.1     itohy 	bus_dma_segment_t	sc_sgt_seg;
     83  1.1     itohy 	bus_dmamap_t		sc_dmamap_sgt;
     84  1.1     itohy 	int			sc_sgt_nsegs;
     85  1.1     itohy 
     86  1.1     itohy 	int			sc_piobm_nsegs;
     87  1.1     itohy 
     88  1.1     itohy 	uint8_t			sc_timing_pio;
     89  1.1     itohy #if 0	/* ATA DMA is currently unused */
     90  1.1     itohy 	uint8_t			sc_timing_dma;
     91  1.1     itohy #endif
     92  1.1     itohy 
     93  1.2     itohy 	uint8_t			sc_atawait;
     94  1.1     itohy 
     95  1.1     itohy 	/* per-device structure */
     96  1.1     itohy 	struct njata32_device {
     97  1.1     itohy 		/* DMA resource */
     98  1.1     itohy 		struct njata32_sgtable	*d_sgt;		/* for host */
     99  1.1     itohy 		bus_addr_t		d_sgt_dma;	/* for device */
    100  1.1     itohy 		bus_dmamap_t		d_dmamap_xfer;
    101  1.1     itohy 		unsigned		d_flags;
    102  1.1     itohy #define NJATA32_DEV_DMA_MAPPED		0x0001
    103  1.1     itohy #define NJATA32_DEV_DMA_READ		0x0002
    104  1.1     itohy #define NJATA32_DEV_DMA_ATAPI		0x0004
    105  1.1     itohy #define NJATA32_DEV_XFER_INTR		0x0100	/* only for sc_devflags */
    106  1.1     itohy #define NJATA32_DEV_GOT_XFER_INTR	0x0200	/* only for sc_devflags */
    107  1.1     itohy #define NJATA32_DEV_DMA_STARTED		0x8000	/* for diag */
    108  1.1     itohy 	} sc_dev[NJATA32_NUM_DEV];
    109  1.1     itohy };
    110  1.1     itohy 
    111  1.1     itohy #ifdef _KERNEL
    112  1.1     itohy void	njata32_attach(struct njata32_softc *);
    113  1.1     itohy int	njata32_detach(struct njata32_softc *, int);
    114  1.1     itohy int	njata32_intr(void *);
    115  1.1     itohy #endif
    116  1.1     itohy 
    117  1.1     itohy #endif	/* _NJATA32VAR_H_ */
    118