globals.h revision 1.6.2.3 1 1.6.2.2 rmind /* $NetBSD: globals.h,v 1.6.2.3 2011/04/21 01:41:22 rmind Exp $ */
2 1.6.2.2 rmind
3 1.6.2.2 rmind #ifdef DEBUG
4 1.6.2.2 rmind #define DPRINTF(x) printf x
5 1.6.2.2 rmind #else
6 1.6.2.2 rmind #define DPRINTF(x)
7 1.6.2.2 rmind #endif
8 1.6.2.2 rmind
9 1.6.2.2 rmind /* clock feed */
10 1.6.2.2 rmind #ifndef EXT_CLK_FREQ
11 1.6.2.2 rmind #define EXT_CLK_FREQ 33333333 /* external clock (PCI clock) */
12 1.6.2.2 rmind #endif
13 1.6.2.2 rmind
14 1.6.2.2 rmind /* brd type */
15 1.6.2.2 rmind extern int brdtype;
16 1.6.2.2 rmind #define BRD_SANDPOINTX2 2
17 1.6.2.2 rmind #define BRD_SANDPOINTX3 3
18 1.6.2.2 rmind #define BRD_ENCOREPP1 10
19 1.6.2.2 rmind #define BRD_KUROBOX 100
20 1.6.2.3 rmind #define BRD_QNAPTS 101
21 1.6.2.2 rmind #define BRD_SYNOLOGY 102
22 1.6.2.2 rmind #define BRD_STORCENTER 103
23 1.6.2.2 rmind #define BRD_DLINKDSM 104
24 1.6.2.2 rmind #define BRD_NH230NAS 105
25 1.6.2.2 rmind #define BRD_UNKNOWN -1
26 1.6.2.2 rmind
27 1.6.2.2 rmind struct brdprop {
28 1.6.2.2 rmind const char *family;
29 1.6.2.2 rmind const char *verbose;
30 1.6.2.2 rmind int brdtype;
31 1.6.2.2 rmind uint32_t extclk;
32 1.6.2.2 rmind char *consname;
33 1.6.2.2 rmind int consport;
34 1.6.2.2 rmind int consspeed;
35 1.6.2.2 rmind void (*setup)(struct brdprop *);
36 1.6.2.2 rmind void (*brdfix)(struct brdprop *);
37 1.6.2.2 rmind void (*pcifix)(struct brdprop *);
38 1.6.2.2 rmind void (*reset)(void);
39 1.6.2.2 rmind };
40 1.6.2.2 rmind
41 1.6.2.2 rmind extern uint32_t cpuclock, busclock;
42 1.6.2.2 rmind
43 1.6.2.2 rmind /* board specific support code */
44 1.6.2.2 rmind struct brdprop *brd_lookup(int);
45 1.6.2.3 rmind int tstchar(void);
46 1.6.2.2 rmind unsigned mpc107memsize(void);
47 1.6.2.2 rmind void read_mac_from_flash(uint8_t *);
48 1.6.2.2 rmind
49 1.6.2.2 rmind /* PPC processor ctl */
50 1.6.2.2 rmind void __syncicache(void *, size_t);
51 1.6.2.2 rmind
52 1.6.2.2 rmind /* byte swap access */
53 1.6.2.2 rmind void out16rb(unsigned, unsigned);
54 1.6.2.2 rmind void out32rb(unsigned, unsigned);
55 1.6.2.2 rmind unsigned in16rb(unsigned);
56 1.6.2.2 rmind unsigned in32rb(unsigned);
57 1.6.2.2 rmind void iohtole16(unsigned, unsigned);
58 1.6.2.2 rmind void iohtole32(unsigned, unsigned);
59 1.6.2.2 rmind unsigned iole32toh(unsigned);
60 1.6.2.2 rmind unsigned iole16toh(unsigned);
61 1.6.2.2 rmind
62 1.6.2.2 rmind /* far call would never return */
63 1.6.2.2 rmind void run(void *, void *, void *, void *, void *);
64 1.6.2.2 rmind
65 1.6.2.2 rmind /* micro second precision delay */
66 1.6.2.2 rmind void delay(unsigned);
67 1.6.2.2 rmind
68 1.6.2.2 rmind /* PCI stuff */
69 1.6.2.2 rmind struct pcidev {
70 1.6.2.2 rmind unsigned bdf; /* bus.dev.func */
71 1.6.2.2 rmind unsigned pvd; /* device ID */
72 1.6.2.2 rmind void *drv; /* driver */
73 1.6.2.2 rmind };
74 1.6.2.2 rmind void pcisetup(void);
75 1.6.2.2 rmind void pcifixup(void);
76 1.6.2.2 rmind unsigned pcimaketag(int, int, int);
77 1.6.2.2 rmind void pcidecomposetag(unsigned, int *, int *, int *);
78 1.6.2.2 rmind int pcifinddev(unsigned, unsigned, unsigned *);
79 1.6.2.2 rmind int pcilookup(unsigned, struct pcidev *, int);
80 1.6.2.2 rmind unsigned pcicfgread(unsigned, int);
81 1.6.2.2 rmind void pcicfgwrite(unsigned, int, unsigned);
82 1.6.2.2 rmind
83 1.6.2.2 rmind #define PCI_ID_REG 0x00
84 1.6.2.2 rmind #define PCI_VENDOR(id) ((id) & 0xffff)
85 1.6.2.2 rmind #define PCI_PRODUCT(id) (((id) >> 16) & 0xffff)
86 1.6.2.2 rmind #define PCI_VENDOR_INVALID 0xffff
87 1.6.2.2 rmind #define PCI_DEVICE(v,p) ((v) | ((p) << 16))
88 1.6.2.3 rmind #define PCI_COMMAND_STATUS_REG 0x04
89 1.6.2.2 rmind #define PCI_CLASS_REG 0x08
90 1.6.2.3 rmind #define PCI_CLASS(v) (((v) >> 16) & 0xffff)
91 1.6.2.3 rmind #define PCI_SUBCLASS(v) (((v) >> 16) & 0xff)
92 1.6.2.3 rmind #define PCI_INTERFACE(v) (((v) & 0xff00) >> 8)
93 1.6.2.3 rmind #define PCI_REVISION(v) ((v) & 0xff)
94 1.6.2.2 rmind #define PCI_CLASS_PPB 0x0604
95 1.6.2.2 rmind #define PCI_CLASS_ETH 0x0200
96 1.6.2.3 rmind #define PCI_CLASS_SCSI 0x0100
97 1.6.2.2 rmind #define PCI_CLASS_IDE 0x0101
98 1.6.2.2 rmind #define PCI_CLASS_RAID 0x0104
99 1.6.2.2 rmind #define PCI_CLASS_SATA 0x0106
100 1.6.2.2 rmind #define PCI_CLASS_MISCSTORAGE 0x0180
101 1.6.2.2 rmind #define PCI_CLASS_USB 0x0c03
102 1.6.2.2 rmind #define PCI_BHLC_REG 0x0c
103 1.6.2.2 rmind #define PCI_HDRTYPE_TYPE(r) (((r) >> 16) & 0x7f)
104 1.6.2.2 rmind #define PCI_HDRTYPE_MULTIFN(r) ((r) & (0x80 << 16))
105 1.6.2.2 rmind
106 1.6.2.2 rmind /*
107 1.6.2.2 rmind * "Map B" layout
108 1.6.2.2 rmind *
109 1.6.2.2 rmind * practice direct mode configuration scheme with CONFIG_ADDR
110 1.6.2.2 rmind * (0xfec0'0000) and CONFIG_DATA (0xfee0'0000).
111 1.6.2.2 rmind */
112 1.6.2.2 rmind #define PCI_MEMBASE 0x80000000 /* PCI memory space */
113 1.6.2.2 rmind #define PCI_MEMLIMIT 0xfbffffff /* EUMB is next to this */
114 1.6.2.2 rmind #define PCI_IOBASE 0x00001000 /* reserves room for southbridge */
115 1.6.2.2 rmind #define PCI_IOLIMIT 0x000fffff
116 1.6.2.2 rmind #define PCI_XIOBASE 0xfe000000 /* ISA/PCI io space */
117 1.6.2.2 rmind #define CONFIG_ADDR 0xfec00000
118 1.6.2.2 rmind #define CONFIG_DATA 0xfee00000
119 1.6.2.2 rmind
120 1.6.2.2 rmind /* cache ops */
121 1.6.2.2 rmind void _wb(uint32_t, uint32_t);
122 1.6.2.2 rmind void _wbinv(uint32_t, uint32_t);
123 1.6.2.2 rmind void _inv(uint32_t, uint32_t);
124 1.6.2.2 rmind
125 1.6.2.3 rmind /* parsing */
126 1.6.2.3 rmind uint32_t read_hex(const char *);
127 1.6.2.3 rmind
128 1.6.2.2 rmind /* heap */
129 1.6.2.2 rmind void *allocaligned(size_t, size_t);
130 1.6.2.2 rmind
131 1.6.2.2 rmind /* NIF support */
132 1.6.2.2 rmind int net_open(struct open_file *, ...);
133 1.6.2.2 rmind int net_close(struct open_file *);
134 1.6.2.2 rmind int net_strategy(void *, int, daddr_t, size_t, void *, size_t *);
135 1.6.2.2 rmind
136 1.6.2.2 rmind int netif_init(void *);
137 1.6.2.3 rmind void netif_shutdown_all(void);
138 1.6.2.2 rmind int netif_open(void *);
139 1.6.2.2 rmind int netif_close(int);
140 1.6.2.2 rmind
141 1.6.2.2 rmind #define NIF_DECL(xxx) \
142 1.6.2.2 rmind int xxx ## _match(unsigned, void *); \
143 1.6.2.2 rmind void * xxx ## _init(unsigned, void *); \
144 1.6.2.2 rmind int xxx ## _send(void *, char *, unsigned); \
145 1.6.2.3 rmind int xxx ## _recv(void *, char *, unsigned, unsigned); \
146 1.6.2.3 rmind void xxx ## _shutdown(void *)
147 1.6.2.2 rmind
148 1.6.2.2 rmind NIF_DECL(fxp);
149 1.6.2.2 rmind NIF_DECL(tlp);
150 1.6.2.2 rmind NIF_DECL(rge);
151 1.6.2.2 rmind NIF_DECL(skg);
152 1.6.2.3 rmind NIF_DECL(stg);
153 1.6.2.2 rmind
154 1.6.2.2 rmind /* DSK support */
155 1.6.2.2 rmind int dskdv_init(void *);
156 1.6.2.2 rmind
157 1.6.2.2 rmind int dsk_open(struct open_file *, ...);
158 1.6.2.2 rmind int dsk_close(struct open_file *);
159 1.6.2.2 rmind int dsk_strategy(void *, int, daddr_t, size_t, void *, size_t *);
160 1.6.2.2 rmind struct fs_ops *dsk_fsops(struct open_file *);
161 1.6.2.2 rmind
162 1.6.2.3 rmind #define DSK_DECL(xxx) \
163 1.6.2.3 rmind int xxx ## _match(unsigned, void *); \
164 1.6.2.3 rmind void * xxx ## _init(unsigned, void *)
165 1.6.2.3 rmind
166 1.6.2.3 rmind DSK_DECL(pciide);
167 1.6.2.3 rmind DSK_DECL(siisata);
168 1.6.2.3 rmind
169 1.6.2.2 rmind /* status */
170 1.6.2.2 rmind #define ATA_STS_BUSY 0x80
171 1.6.2.2 rmind #define ATA_STS_DRDY 0x40
172 1.6.2.2 rmind #define ATA_STS_ERR 0x01
173 1.6.2.2 rmind /* command */
174 1.6.2.2 rmind #define ATA_CMD_IDENT 0xec
175 1.6.2.2 rmind #define ATA_CMD_READ 0x20
176 1.6.2.2 rmind #define ATA_CMD_READ_EXT 0x24
177 1.6.2.2 rmind #define ATA_CMD_SETF 0xef
178 1.6.2.2 rmind /* device */
179 1.6.2.2 rmind #define ATA_DEV_LBA 0xe0
180 1.6.2.2 rmind #define ATA_DEV_OBS 0x90
181 1.6.2.2 rmind /* control */
182 1.6.2.2 rmind #define ATA_DREQ 0x08
183 1.6.2.2 rmind #define ATA_SRST 0x04
184 1.6.2.2 rmind
185 1.6.2.2 rmind #define ATA_XFER 0x03
186 1.6.2.2 rmind #define XFER_PIO4 0x0c
187 1.6.2.2 rmind #define XFER_PIO0 0x08
188 1.6.2.2 rmind
189 1.6.2.2 rmind struct dvata_chan {
190 1.6.2.2 rmind uint32_t cmd, ctl, alt, dma;
191 1.6.2.2 rmind };
192 1.6.2.2 rmind #define _DAT 0 /* RW */
193 1.6.2.2 rmind #define _ERR 1 /* R */
194 1.6.2.2 rmind #define _FEA 1 /* W */
195 1.6.2.2 rmind #define _NSECT 2 /* RW */
196 1.6.2.2 rmind #define _LBAL 3 /* RW */
197 1.6.2.2 rmind #define _LBAM 4 /* RW */
198 1.6.2.2 rmind #define _LBAH 5 /* RW */
199 1.6.2.2 rmind #define _DEV 6 /* W */
200 1.6.2.2 rmind #define _STS 7 /* R */
201 1.6.2.2 rmind #define _CMD 7 /* W */
202 1.6.2.2 rmind
203 1.6.2.2 rmind struct dkdev_ata {
204 1.6.2.2 rmind unsigned tag;
205 1.6.2.2 rmind uint32_t bar[6];
206 1.6.2.2 rmind struct dvata_chan chan[4];
207 1.6.2.2 rmind int presense[4];
208 1.6.2.2 rmind char *iobuf;
209 1.6.2.2 rmind };
210 1.6.2.2 rmind
211 1.6.2.2 rmind struct disk {
212 1.6.2.2 rmind char xname[8];
213 1.6.2.2 rmind void *dvops;
214 1.6.2.2 rmind unsigned unittag;
215 1.6.2.2 rmind uint16_t ident[128];
216 1.6.2.2 rmind uint64_t nsect;
217 1.6.2.2 rmind uint64_t first;
218 1.6.2.2 rmind void *dlabel;
219 1.6.2.2 rmind int part;
220 1.6.2.2 rmind void *fsops;
221 1.6.2.2 rmind int (*lba_read)(struct disk *, int64_t, int, void *);
222 1.6.2.2 rmind };
223 1.6.2.2 rmind
224 1.6.2.2 rmind int spinwait_unbusy(struct dkdev_ata *, int, int, const char **);
225 1.6.2.2 rmind int perform_atareset(struct dkdev_ata *, int);
226 1.6.2.2 rmind int satapresense(struct dkdev_ata *, int);
227