wdvar.h revision 1.4
1/*	$NetBSD: wdvar.h,v 1.4 2004/01/03 01:50:53 thorpej Exp $	*/
2
3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * Copyright (c) 2001 Dynarc AB, Sweden. All rights reserved.
6 *
7 * This code is derived from software written by Anders Magnusson,
8 * ragge@ludd.luth.se
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 *    derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _STAND_WDVAR_H
34#define _STAND_WDVAR_H
35
36#include <dev/ic/wdcreg.h>
37#include <dev/ata/atareg.h>
38#include <dev/pci/pciidereg.h>
39
40#include <mips/cpuregs.h>
41
42#include <sys/disklabel.h>
43#include <sys/bootblock.h>
44
45#define WDC_TIMEOUT		2000000
46#define PCIIDE_CHANNEL_NDEV	2
47#define NUNITS			(PCIIDE_CHANNEL_NDEV * PCIIDE_NUM_CHANNELS)
48
49struct wdc_channel {
50	volatile u_int8_t *c_base;
51	volatile u_int16_t *c_data;
52
53	u_int8_t compatchan;
54};
55
56struct wd_softc {
57#define WDF_LBA		0x0001
58#define WDF_LBA48	0x0002
59	u_int16_t sc_flags;
60
61	u_int sc_part;
62	u_int sc_unit;
63
64	u_int64_t sc_capacity;
65
66	struct ataparams sc_params;
67	struct disklabel sc_label;
68	struct wdc_channel sc_channel;
69};
70
71struct wdc_command {
72	u_int8_t drive;		/* drive id */
73
74	u_int8_t r_command;	/* Parameters to upload to registers */
75	u_int8_t r_head;
76	u_int16_t r_cyl;
77	u_int8_t r_sector;
78	u_int8_t r_count;
79	u_int8_t r_precomp;
80
81	u_int16_t bcount;
82	void *data;
83
84	u_int64_t r_blkno;
85};
86
87int	wdc_init		(struct wd_softc*, u_int*);
88int	wdccommand		(struct wd_softc*, struct wdc_command*);
89int	wdccommandext		(struct wd_softc*, struct wdc_command*);
90int	wdc_exec_read		(struct wd_softc*, u_int8_t, daddr_t, void*);
91int	wdc_exec_identify	(struct wd_softc*, void*);
92
93int	pciide_init		(struct wdc_channel*, u_int*);
94
95#endif /* _STAND_WDVAR_H */
96