Home | History | Annotate | Line # | Download | only in ic
      1  1.3    martin /*	$NetBSD: ns8477reg.h,v 1.3 2008/04/28 20:23:50 martin Exp $	 */
      2  1.1  christos 
      3  1.2  christos /*-
      4  1.2  christos  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.2  christos  * All rights reserved.
      6  1.2  christos  *
      7  1.2  christos  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2  christos  * by Christos Zoulas.
      9  1.1  christos  *
     10  1.1  christos  * Redistribution and use in source and binary forms, with or without
     11  1.1  christos  * modification, are permitted provided that the following conditions
     12  1.1  christos  * are met:
     13  1.1  christos  * 1. Redistributions of source code must retain the above copyright
     14  1.1  christos  *    notice, this list of conditions and the following disclaimer.
     15  1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  christos  *    documentation and/or other materials provided with the distribution.
     18  1.1  christos  *
     19  1.2  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.2  christos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.2  christos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.2  christos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.2  christos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.2  christos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.2  christos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.2  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.2  christos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.2  christos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.2  christos  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  christos  */
     31  1.1  christos 
     32  1.1  christos /*
     33  1.1  christos  * Register descriptions of the National Semiconductor PC8477B
     34  1.1  christos  * floppy controller
     35  1.1  christos  */
     36  1.1  christos 
     37  1.1  christos #define	FDC_SRA	0	/* (R)   Status Register A		*/
     38  1.1  christos 
     39  1.1  christos #define FDC_SRB	1	/* (R)   Status Register B		*/
     40  1.1  christos 
     41  1.1  christos #define FDC_DOR	2	/* (R/W) Digital Output Register	*/
     42  1.1  christos 
     43  1.1  christos # define FDC_DOR_SEL0	0x01	/* Drive Select 0	*/
     44  1.1  christos # define FDC_DOR_SEL1	0x02	/* Drive Select 1	*/
     45  1.1  christos # define FDC_DOR_RESET	0x04	/* Reset Controller	*/
     46  1.1  christos # define FDC_DOR_DMAEN	0x08	/* Dma Enable		*/
     47  1.1  christos # define FDC_DOR_MTR0	0x10	/* Motor Enable 0	*/
     48  1.1  christos # define FDC_DOR_MTR1	0x20	/* Motor Enable 1	*/
     49  1.1  christos # define FDC_DOR_MTR2	0x40	/* Motor Enable 2	*/
     50  1.1  christos # define FDC_DOR_MTR3	0x80	/* Motor Enable 3	*/
     51  1.1  christos # define FDC_DOR_MTR(a)  (1 << (n + 4))
     52  1.1  christos 
     53  1.1  christos #define FDC_TDR	3	/* (R/W) Tape Drive Register		*/
     54  1.1  christos # define FDC_TDR_SEL0	0x01	/* Tape Select 0	*/
     55  1.1  christos # define FDC_TDR_SEL1	0x02	/* Tape Select 1	*/
     56  1.1  christos 
     57  1.1  christos #define FDC_MSR	4	/* (R)   Main Status Register		*/
     58  1.1  christos # define FDC_MSR_BUSY0	0x01	/* Drive 0 Busy		*/
     59  1.1  christos # define FDC_MSR_BUSY1	0x02	/* Drive 1 Busy		*/
     60  1.1  christos # define FDC_MSR_BUSY2	0x04	/* Drive 2 Busy		*/
     61  1.1  christos # define FDC_MSR_BUSY3	0x08	/* Drive 3 Busy		*/
     62  1.1  christos # define FDC_MSR_CMDPRG	0x10	/* Command In Progress	*/
     63  1.1  christos # define FDC_MSR_NONDMA	0x20	/* Non DMA Execution	*/
     64  1.1  christos # define FDC_MSR_DIO	0x40	/* Data I/O Direction	*/
     65  1.1  christos # define FDC_MSR_RQM	0x80	/* Reguest for Master	*/
     66  1.1  christos 
     67  1.1  christos #define FDC_DSR	4	/* (W)   Data Rate Select Register	*/
     68  1.1  christos # define FDC_DSR_DRATE0	0x01	/* Data Rate Select 0	*/
     69  1.1  christos # define FDC_DSR_DRATE1	0x02	/* Data Rate Select 0	*/
     70  1.1  christos /*
     71  1.1  christos  * bit	MFM	FM
     72  1.1  christos  *  00  500Kb/s	250Kb/s
     73  1.1  christos  *  01  300Kb/s	150Kb/s
     74  1.1  christos  *  10  250Kb/s	125Kb/s
     75  1.1  christos  *  11	1Mb/s	illegal
     76  1.1  christos  */
     77  1.1  christos # define FDC_DSR_500KBPS	0x00	/* 500KBPS MFM drive transfer rate */
     78  1.1  christos # define FDC_DSR_300KBPS	0x01	/* 300KBPS MFM drive transfer rate */
     79  1.1  christos # define FDC_DSR_250KBPS	0x02	/* 250KBPS MFM drive transfer rate */
     80  1.1  christos # define FDC_DSR_1MBPS		0x03	/* 1MBPS MFM drive transfer rate */
     81  1.1  christos 
     82  1.1  christos # define FDC_DSR_PREC0	0x04	/* Precompensation bit 0*/
     83  1.1  christos # define FDC_DSR_PREC1	0x08	/* Precompensation bit 1*/
     84  1.1  christos # define FDC_DSR_PREC2	0x10	/* Precompensation bit 2*/
     85  1.1  christos /*
     86  1.1  christos  * bit	Precomp Data Rate
     87  1.1  christos  * 000	default
     88  1.1  christos  * 001   41.7ns	1Mb/s
     89  1.1  christos  * 010	 83.3ns
     90  1.1  christos  * 011	125.0ns 500Kb/s, 300Kb/s, 250Kb/s
     91  1.1  christos  * 100	168.7ns
     92  1.1  christos  * 101	208.3ns
     93  1.1  christos  * 110	208.3ns
     94  1.1  christos  * 111	  0.0ns
     95  1.1  christos  */
     96  1.1  christos # define FDC_DSR_ZERO	0x20	/* Undef; should be 0	*/
     97  1.1  christos # define FDC_DSR_LOWPWR	0x40	/* Low Power Mode	*/
     98  1.1  christos # define FDC_DSR_SWRST	0x80	/* Software Reset	*/
     99  1.1  christos 
    100  1.1  christos #define FDC_FIFO	5	/* (R/W) Data Register (FIFO)		*/
    101  1.1  christos 
    102  1.1  christos /*
    103  1.1  christos  * Commands
    104  1.1  christos  */
    105  1.1  christos #define FDC_CMD_MODE				(0x01)
    106  1.1  christos #define	FDC_CMD_READ_TRACK(mfm)			(0x02|mfm)
    107  1.1  christos #define	FDC_CMD_SPECIFY				(0x03)
    108  1.1  christos #define	FDC_CMD_SENSE_DRIVE_STATUS		(0x04)
    109  1.1  christos #define FDC_CMD_WRITE_DATA(mt,mfm)		(0x05|mt|mfm)
    110  1.1  christos #define FDC_CMD_READ_DATA(mt,mfm,sk)		(0x06|mt|mfm|sk)
    111  1.1  christos #define	FDC_CMD_RECALIBRATE			(0x07)
    112  1.1  christos #define	FDC_CMD_SENSE_INTERRUPT			(0x08)
    113  1.1  christos #define FDC_CMD_WRITE_DEL_DATA(mt,mfm)		(0x09|mt|mfm)
    114  1.1  christos #define	FDC_CMD_READ_ID(mfm)			(0x0a|mfm)
    115  1.1  christos #define FDC_CMD_READ_DEL_DATA(mt,mfm,sk)	(0x0c|mt|mfm|sk)
    116  1.1  christos #define	FDC_CMD_FORMAT_TRACK(mfm)		(0x0d|mfm)
    117  1.1  christos #define FDC_CMD_DUMPREG				(0x0e)
    118  1.1  christos #define FDC_CMD_SEEK				(0x0f)
    119  1.1  christos #define FDC_CMD_VERSION				(0x10)
    120  1.1  christos #define FDC_CMD_SCAN_EQUAL(mt,mfm,sk)		(0x11|mt|mfm|sk)
    121  1.1  christos #define FDC_CMD_PERPENDICULAR			(0x12)
    122  1.1  christos #define FDC_CMD_CONFIGURE			(0x13)
    123  1.1  christos #define FDC_CMD_LOCK(lock)			(0x14|lock)
    124  1.1  christos #define FDC_CMD_VERIFY(mt,mfm,sk)		(0x16|mt|mfm|sk)
    125  1.1  christos #define FDC_CMD_NSC				(0x18)
    126  1.1  christos #define FDC_CMD_SCAN_LO_EQUAL(mt,mfm,sk)	(0x19|mt|mfm|sk)
    127  1.1  christos #define FDC_CMD_SCAN_HI_EQUAL(mt,mfm,sk)	(0x1d|mt|mfm|sk)
    128  1.1  christos #define FDC_CMD_SET_TRACK(wnr)			(0x21|wnr)
    129  1.1  christos #define	FDC_CMD_REL_SEEK(dir)			(0x8f|dir)
    130  1.1  christos 
    131  1.1  christos #define  FDC_CMD_CONFIGURE_FLAGS_POLL	0x10
    132  1.1  christos #define  FDC_CMD_CONFIGURE_FLAGS_FIFO	0x20
    133  1.1  christos #define  FDC_CMD_CONFIGURE_FLAGS_EIS	0x40
    134  1.1  christos #define  FDC_CMD_FLAGS_LOCK		0x80
    135  1.1  christos #define  FDC_CMD_FLAGS_MT		0x80
    136  1.1  christos #define  FDC_CMD_FLAGS_MFM		0x40
    137  1.1  christos #define  FDC_CMD_FLAGS_SK		0x20
    138  1.1  christos #define  FDC_CMD_FLAGS_DIR		0x40
    139  1.1  christos #define  FDC_CMD_FLAGS_WNR		0x40
    140  1.1  christos /*
    141  1.1  christos  * Command Status
    142  1.1  christos  */
    143  1.1  christos /* Status register ST0 */
    144  1.1  christos #define FDC_ST0BITS	"\020\010invld\007abnrml\006seek_cmplt\005drv_chck\004drive_rdy\003top_head\002ds1\001ds0"
    145  1.1  christos # define FDC_ST0_DS0	0x01	/* Drive Select 0	*/
    146  1.1  christos # define FDC_ST0_DS1	0x02	/* Drive Select 1	*/
    147  1.1  christos # define FDC_ST0_HDS	0x04	/* Head select		*/
    148  1.1  christos # define FDC_ST0_ZERO	0x08	/* Undef; should be 0	*/
    149  1.1  christos # define FDC_ST0_EC	0x10	/* Equipment check	*/
    150  1.1  christos # define FDC_ST0_SE	0x20	/* Seek completed	*/
    151  1.1  christos # define FDC_ST0_IC0	0x40	/* Interrupt code 0	*/
    152  1.1  christos # define FDC_ST0_IC1	0x80	/* Interrupt code 1	*/
    153  1.1  christos # define FDC_ST0(a)	(a & ~(FDC_ST0_DS0|FDC_ST0_DS1|FDC_ST0_HDS))
    154  1.1  christos #  define FDC_ST0_NRML 0x00	/* Normal Completion	*/
    155  1.1  christos #  define FDC_ST0_ABNR 0x40	/* Abnormal Termination	*/
    156  1.1  christos #  define FDC_ST0_INVL 0x80	/* Invalid Command	*/
    157  1.1  christos #  define FDC_ST0_CHGD 0xc0	/* Drive status changed	*/
    158  1.1  christos 
    159  1.1  christos /* Status register ST1 */
    160  1.1  christos #define FDC_ST1BITS	"\020\010end_of_cyl\006bad_crc\005data_overrun\003sec_not_fnd\002write_protect\001no_am"
    161  1.1  christos # define FDC_ST1_MA	0x01	/* Missing address mark	*/
    162  1.1  christos # define FDC_ST1_NW	0x02	/* Write Protect	*/
    163  1.1  christos # define FDC_ST1_ND	0x04	/* No Data		*/
    164  1.1  christos # define FDC_ST1_ZERO0	0x08	/* Undef; should be 0	*/
    165  1.1  christos # define FDC_ST1_OR	0x10	/* Overrun error	*/
    166  1.1  christos # define FDC_ST1_CE	0x20	/* CRC error		*/
    167  1.1  christos # define FDC_ST1_ZERO1	0x40	/* Undef; should be 0	*/
    168  1.1  christos # define FDC_ST1_ET	0x80	/* End of Track		*/
    169  1.1  christos 
    170  1.1  christos /* Status register ST2 */
    171  1.1  christos #define FDC_ST2BITS	"\020\007ctrl_mrk\006bad_crc\005wrong_cyl\004scn_eq\003scn_not_fnd\002bad_cyl\001no_dam"
    172  1.1  christos # define FDC_ST2_MD	0x01	/* Missing Address Mark */
    173  1.1  christos # define FDC_ST2_BT	0x02	/* Bad Track		*/
    174  1.1  christos # define FDC_ST2_SNS	0x04	/* Scan Not Satisfied	*/
    175  1.1  christos # define FDC_ST2_SEH	0x08	/* Scan Equal Hit	*/
    176  1.1  christos # define FDC_ST2_WT	0x10	/* Wrong Track		*/
    177  1.1  christos # define FDC_ST2_CD	0x20	/* CRC Error in Data	*/
    178  1.1  christos # define FDC_ST2_CM	0x40	/* Control Mark		*/
    179  1.1  christos # define FDC_ST2_ZERO	0x80	/* Undef; should be 0	*/
    180  1.1  christos 
    181  1.1  christos /* Status register ST3 */
    182  1.1  christos #define FDC_ST3BITS	"\020\010fault\007write_protect\006drdy\005tk0\004two_side\003side_sel\002ds1\001ds0"
    183  1.1  christos # define FDC_ST3_DS0	0x01	/* Drive Select 0	*/
    184  1.1  christos # define FDC_ST3_DS1	0x02	/* Drive Select 1	*/
    185  1.1  christos # define FDC_ST3_HDS	0x04	/* Head Select		*/
    186  1.1  christos # define FDC_ST3_ONE0	0x08	/* Undef; should be 0	*/
    187  1.1  christos # define FDC_ST3_TK0	0x10	/* Track 0		*/
    188  1.1  christos # define FDC_ST3_ONE1	0x20	/* Undef; should be 0	*/
    189  1.1  christos # define FDC_ST3_WP	0x40	/* Write Protect	*/
    190  1.1  christos # define FDC_ST3_ZERO	0x80	/* Undef; should be 0	*/
    191  1.1  christos 
    192  1.1  christos #define FDC_NONE	6	/* (X)   None (Bus TRI-STATE)	*/
    193  1.1  christos 
    194  1.1  christos #define FDC_DIR	7	/* (R)   Digital Input Register		*/
    195  1.1  christos # define FDC_DIR_DSKCHG	0x80	/* Disk Changed		*/
    196  1.1  christos 
    197  1.1  christos #define FDC_CCR	7	/* (W)   Configuration Register		*/
    198  1.1  christos # define FDC_CCR_DRATE0	0x01	/* Data Rate Select 0	*/
    199  1.1  christos # define FDC_CCR_DRATE1	0x02	/* Data Rate Select 0	*/
    200  1.1  christos # define FDC_CCR_ZERO0	0x04	/* Undef; should be 0	*/
    201  1.1  christos # define FDC_CCR_ZERO1	0x08	/* Undef; should be 0	*/
    202  1.1  christos # define FDC_CCR_ZERO2	0x10	/* Undef; should be 0	*/
    203  1.1  christos # define FDC_CCR_ZERO3	0x20	/* Undef; should be 0	*/
    204  1.1  christos # define FDC_CCR_ZERO4	0x40	/* Undef; should be 0	*/
    205  1.1  christos # define FDC_CCR_ZERO5	0x80	/* Undef; should be 0	*/
    206  1.1  christos 
    207  1.1  christos #define FDC_NPORT	8
    208