1 /* $NetBSD: dino.c,v 1.20 2009/12/08 07:32:45 skrll Exp $ */
3 /* $OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $ */
6 * Copyright (c) 2003 Michael Shalayeff
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.20 2009/12/08 07:32:45 skrll Exp $");
34 /* #include "cardbus.h" */
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
39 #include <sys/reboot.h>
40 #include <sys/malloc.h>
41 #include <sys/extent.h>
43 #include <machine/iomod.h>
44 #include <machine/autoconf.h>
45 #include <machine/intr.h>
46 #include <hp700/hp700/intr.h>
48 #include <hppa/include/vmparam.h>
49 #include <hp700/dev/cpudevs.h>
52 #include <dev/cardbus/rbus.h>
55 #include <dev/pci/pcireg.h>
56 #include <dev/pci/pcivar.h>
57 #include <dev/pci/pcidevs.h>
59 #define DINO_MEM_CHUNK 0x800000
62 extern struct extent
*hp700_io_extent
;
65 uint32_t pad0
; /* 0x000 */
66 uint32_t iar0
; /* 0x004 rw intr addr reg 0 */
67 uint32_t iodc
; /* 0x008 rw iodc data/addr */
68 uint32_t irr0
; /* 0x00c r intr req reg 0 */
69 uint32_t iar1
; /* 0x010 rw intr addr reg 1 */
70 uint32_t irr1
; /* 0x014 r intr req reg 1 */
71 uint32_t imr
; /* 0x018 rw intr mask reg */
72 uint32_t ipr
; /* 0x01c rw intr pending reg */
73 uint32_t toc_addr
; /* 0x020 rw TOC addr reg */
74 uint32_t icr
; /* 0x024 rw intr control reg */
75 uint32_t ilr
; /* 0x028 r intr level reg */
76 uint32_t pad1
; /* 0x02c */
77 uint32_t io_command
; /* 0x030 w command register */
78 uint32_t io_status
; /* 0x034 r status register */
79 uint32_t io_control
; /* 0x038 rw control register */
80 uint32_t pad2
; /* 0x03c AUX registers follow */
81 uint32_t io_gsc_err_addr
;/* 0x040 GSC error address */
82 uint32_t io_err_info
; /* 0x044 error info register */
83 uint32_t io_pci_err_addr
;/* 0x048 PCI error address */
84 uint32_t pad3
[4]; /* 0x04c */
85 uint32_t io_fbb_en
; /* 0x05c fast back2back enable reg */
86 uint32_t io_addr_en
; /* 0x060 address enable reg */
87 uint32_t pci_addr
; /* 0x064 PCI conf/io/mem addr reg */
88 uint32_t pci_conf_data
; /* 0x068 PCI conf data reg */
89 uint32_t pci_io_data
; /* 0x06c PCI io data reg */
90 uint32_t pci_mem_data
; /* 0x070 PCI memory data reg */
91 uint32_t pad4
[0x740/4]; /* 0x074 */
92 uint32_t gsc2x_config
; /* 0x7b4 GSC2X config reg */
93 uint32_t pad5
[0x48/4]; /* 0x7b8: BSRS registers follow */
94 uint32_t gmask
; /* 0x800 GSC arbitration mask */
95 uint32_t pamr
; /* 0x804 PCI arbitration mask */
96 uint32_t papr
; /* 0x808 PCI arbitration priority */
97 uint32_t damode
; /* 0x80c PCI arbitration mode */
98 uint32_t pcicmd
; /* 0x810 PCI command register */
99 uint32_t pcists
; /* 0x814 PCI status register */
100 uint32_t pad6
; /* 0x818 */
101 uint32_t mltim
; /* 0x81c PCI master latency timer */
102 uint32_t brdg_feat
; /* 0x820 PCI bridge feature enable */
103 uint32_t pciror
; /* 0x824 PCI read optimization reg */
104 uint32_t pciwor
; /* 0x828 PCI write optimization reg */
105 uint32_t pad7
; /* 0x82c */
106 uint32_t tltim
; /* 0x830 PCI target latency reg */
114 struct hp700_int_reg sc_int_reg
;
115 bus_space_tag_t sc_bt
;
116 bus_space_handle_t sc_bh
;
117 bus_dma_tag_t sc_dmat
;
118 volatile struct dino_regs
*sc_regs
;
120 struct hppa_pci_chipset_tag sc_pc
;
121 struct hppa_bus_space_tag sc_iot
;
122 char sc_ioexname
[20];
123 struct extent
*sc_ioex
;
124 struct hppa_bus_space_tag sc_memt
;
125 int sc_memrefcount
[30];
126 struct hppa_bus_dma_tag sc_dmatag
;
129 int dinomatch(device_t
, struct cfdata
*, void *);
130 void dinoattach(device_t
, device_t
, void *);
131 static void dino_callback(device_t
, struct confargs
*);
133 CFATTACH_DECL_NEW(dino
, sizeof(struct dino_softc
), dinomatch
, dinoattach
, NULL
,
137 void dino_attach_hook(device_t
, device_t
,
138 struct pcibus_attach_args
*);
139 void dino_enable_bus(struct dino_softc
*, int);
140 int dino_maxdevs(void *, int);
141 pcitag_t
dino_make_tag(void *, int, int, int);
142 void dino_decompose_tag(void *, pcitag_t
, int *, int *, int *);
143 pcireg_t
dino_conf_read(void *, pcitag_t
, int);
144 void dino_conf_write(void *, pcitag_t
, int, pcireg_t
);
146 int dino_intr_map(struct pci_attach_args
*, pci_intr_handle_t
*);
147 const char *dino_intr_string(void *, pci_intr_handle_t
);
148 void *dino_intr_establish(void *, pci_intr_handle_t
, int,
149 int (*)(void *), void *);
150 void dino_intr_disestablish(void *, void *);
152 void *dino_alloc_parent(device_t
, struct pci_attach_args
*, int);
154 int dino_iomap(void *, bus_addr_t
, bus_size_t
, int, bus_space_handle_t
*);
155 int dino_memmap(void *, bus_addr_t
, bus_size_t
, int, bus_space_handle_t
*);
156 int dino_subregion(void *, bus_space_handle_t
, bus_size_t
, bus_size_t
,
157 bus_space_handle_t
*);
158 int dino_ioalloc(void *, bus_addr_t
, bus_addr_t
, bus_size_t
,
159 bus_size_t
, bus_size_t
, int, bus_addr_t
*, bus_space_handle_t
*);
160 int dino_memalloc(void *, bus_addr_t
, bus_addr_t
, bus_size_t
, bus_size_t
,
161 bus_size_t
, int, bus_addr_t
*, bus_space_handle_t
*);
162 void dino_unmap(void *, bus_space_handle_t
, bus_size_t
);
163 void dino_free(void *, bus_space_handle_t
, bus_size_t
);
164 void dino_barrier(void *, bus_space_handle_t
, bus_size_t
, bus_size_t
, int);
165 void *dino_vaddr(void *, bus_space_handle_t
);
166 paddr_t
dino_mmap(void *, bus_addr_t
, off_t
, int, int);
168 uint8_t dino_r1(void *, bus_space_handle_t
, bus_size_t
);
169 uint16_t dino_r2(void *, bus_space_handle_t
, bus_size_t
);
170 uint32_t dino_r4(void *, bus_space_handle_t
, bus_size_t
);
171 uint64_t dino_r8(void *, bus_space_handle_t
, bus_size_t
);
172 void dino_w1(void *, bus_space_handle_t
, bus_size_t
, uint8_t);
173 void dino_w2(void *, bus_space_handle_t
, bus_size_t
, uint16_t);
174 void dino_w4(void *, bus_space_handle_t
, bus_size_t
, uint32_t);
175 void dino_w8(void *, bus_space_handle_t
, bus_size_t
, uint64_t);
176 void dino_rm_1(void *, bus_space_handle_t
, bus_size_t
, uint8_t *, bus_size_t
);
177 void dino_rm_2(void *, bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
178 void dino_rm_4(void *, bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
179 void dino_rm_8(void *, bus_space_handle_t
, bus_size_t
, uint64_t *, bus_size_t
);
180 void dino_wm_1(void *, bus_space_handle_t
, bus_size_t
, const uint8_t *,
182 void dino_wm_2(void *, bus_space_handle_t
, bus_size_t
, const uint16_t *,
184 void dino_wm_4(void *, bus_space_handle_t
, bus_size_t
, const uint32_t *,
186 void dino_wm_8(void *, bus_space_handle_t
, bus_size_t
, const uint64_t *,
188 void dino_sm_1(void *, bus_space_handle_t
, bus_size_t
, uint8_t, bus_size_t
);
189 void dino_sm_2(void *, bus_space_handle_t
, bus_size_t
, uint16_t, bus_size_t
);
190 void dino_sm_4(void *, bus_space_handle_t
, bus_size_t
, uint32_t, bus_size_t
);
191 void dino_sm_8(void *, bus_space_handle_t
, bus_size_t
, uint64_t, bus_size_t
);
192 void dino_rrm_2(void *, bus_space_handle_t
, bus_size_t
, uint16_t *,
194 void dino_rrm_4(void *, bus_space_handle_t
, bus_size_t
, uint32_t *,
196 void dino_rrm_8(void *, bus_space_handle_t
, bus_size_t
, uint64_t *,
198 void dino_wrm_2(void *, bus_space_handle_t
, bus_size_t
, const uint16_t *,
200 void dino_wrm_4(void *, bus_space_handle_t
, bus_size_t
, const uint32_t *,
202 void dino_wrm_8(void *, bus_space_handle_t
, bus_size_t
, const uint64_t *,
204 void dino_rr_1(void *, bus_space_handle_t
, bus_size_t
, uint8_t *, bus_size_t
);
205 void dino_rr_2(void *, bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
206 void dino_rr_4(void *, bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
207 void dino_rr_8(void *, bus_space_handle_t
, bus_size_t
, uint64_t *, bus_size_t
);
208 void dino_wr_1(void *, bus_space_handle_t
, bus_size_t
, const uint8_t *,
210 void dino_wr_2(void *, bus_space_handle_t
, bus_size_t
, const uint16_t *,
212 void dino_wr_4(void *, bus_space_handle_t
, bus_size_t
, const uint32_t *,
214 void dino_wr_8(void *, bus_space_handle_t
, bus_size_t
, const uint64_t *,
216 void dino_rrr_2(void *, bus_space_handle_t
, bus_size_t
, uint16_t *,
218 void dino_rrr_4(void *, bus_space_handle_t
, bus_size_t
, uint32_t *,
220 void dino_rrr_8(void *, bus_space_handle_t
, bus_size_t
, uint64_t *,
222 void dino_wrr_2(void *, bus_space_handle_t
, bus_size_t
, const uint16_t *,
224 void dino_wrr_4(void *, bus_space_handle_t
, bus_size_t
, const uint32_t *,
226 void dino_wrr_8(void *, bus_space_handle_t
, bus_size_t
, const uint64_t *,
228 void dino_sr_1(void *, bus_space_handle_t
, bus_size_t
, uint8_t, bus_size_t
);
229 void dino_sr_2(void *, bus_space_handle_t
, bus_size_t
, uint16_t, bus_size_t
);
230 void dino_sr_4(void *, bus_space_handle_t
, bus_size_t
, uint32_t, bus_size_t
);
231 void dino_sr_8(void *, bus_space_handle_t
, bus_size_t
, uint64_t, bus_size_t
);
232 void dino_cp_1(void *, bus_space_handle_t
, bus_size_t
, bus_space_handle_t
,
233 bus_size_t
, bus_size_t
);
234 void dino_cp_2(void *, bus_space_handle_t
, bus_size_t
, bus_space_handle_t
,
235 bus_size_t
, bus_size_t
);
236 void dino_cp_4(void *, bus_space_handle_t
, bus_size_t
, bus_space_handle_t
,
237 bus_size_t
, bus_size_t
);
238 void dino_cp_8(void *, bus_space_handle_t
, bus_size_t
, bus_space_handle_t
,
239 bus_size_t
, bus_size_t
);
240 int dino_dmamap_create(void *, bus_size_t
, int, bus_size_t
, bus_size_t
, int,
242 void dino_dmamap_destroy(void *, bus_dmamap_t
);
243 int dino_dmamap_load(void *, bus_dmamap_t
, void *, bus_size_t
, struct proc
*,
245 int dino_dmamap_load_mbuf(void *, bus_dmamap_t
, struct mbuf
*, int);
246 int dino_dmamap_load_uio(void *, bus_dmamap_t
, struct uio
*, int);
247 int dino_dmamap_load_raw(void *, bus_dmamap_t
, bus_dma_segment_t
*, int,
249 void dino_dmamap_unload(void *, bus_dmamap_t
);
250 void dino_dmamap_sync(void *, bus_dmamap_t
, bus_addr_t
, bus_size_t
, int);
251 int dino_dmamem_alloc(void *, bus_size_t
, bus_size_t
, bus_size_t
,
252 bus_dma_segment_t
*, int, int *, int);
253 void dino_dmamem_free(void *, bus_dma_segment_t
*, int);
254 int dino_dmamem_map(void *, bus_dma_segment_t
*, int, size_t, void **, int);
255 void dino_dmamem_unmap(void *, void *, size_t);
256 paddr_t
dino_dmamem_mmap(void *, bus_dma_segment_t
*, int, off_t
, int, int);
260 dino_attach_hook(device_t parent
, device_t self
,
261 struct pcibus_attach_args
*pba
)
263 struct dino_softc
*sc
= pba
->pba_pc
->_cookie
;
266 * The firmware enables only devices that are needed for booting.
267 * So other devices will fail to map PCI MEM / IO when they attach.
268 * Therefore we recursively walk all buses to simply enable everything.
270 dino_enable_bus(sc
, 0);
274 dino_enable_bus(struct dino_softc
*sc
, int bus
)
282 for (dev
= 0; dev
< 32; dev
++) {
283 tag
= dino_make_tag(sc
, bus
, dev
, 0);
284 if (tag
!= -1 && dino_conf_read(sc
, tag
, 0) != 0xffffffff) {
285 for (func
= 0; func
< 8; func
++) {
286 tag
= dino_make_tag(sc
, bus
, dev
, func
);
287 if (dino_conf_read(sc
, tag
, 0) != 0xffffffff) {
288 data
= dino_conf_read(sc
, tag
,
289 PCI_COMMAND_STATUS_REG
);
290 dino_conf_write(sc
, tag
,
291 PCI_COMMAND_STATUS_REG
,
292 PCI_COMMAND_IO_ENABLE
|
293 PCI_COMMAND_MEM_ENABLE
|
294 PCI_COMMAND_MASTER_ENABLE
| data
);
297 class = dino_conf_read(sc
, tag
, PCI_CLASS_REG
);
298 if (PCI_CLASS(class) == PCI_CLASS_BRIDGE
&&
299 PCI_SUBCLASS(class) == PCI_SUBCLASS_BRIDGE_PCI
)
300 dino_enable_bus(sc
, bus
+ 1);
306 dino_maxdevs(void *v
, int bus
)
312 dino_make_tag(void *v
, int bus
, int dev
, int func
)
314 if (bus
> 255 || dev
> 31 || func
> 7)
315 panic("dino_make_tag: bad request");
317 return (bus
<< 16) | (dev
<< 11) | (func
<< 8);
321 dino_decompose_tag(void *v
, pcitag_t tag
, int *bus
, int *dev
, int *func
)
323 *bus
= (tag
>> 16) & 0xff;
324 *dev
= (tag
>> 11) & 0x1f;
325 *func
= (tag
>> 8) & 0x07;
329 dino_conf_read(void *v
, pcitag_t tag
, int reg
)
331 struct dino_softc
*sc
= v
;
332 volatile struct dino_regs
*r
= sc
->sc_regs
;
336 /* fix arbitration errata by disabling all pci devs on config read */
340 r
->pci_addr
= tag
| reg
;
341 data
= r
->pci_conf_data
;
343 /* restore arbitration */
346 return le32toh(data
);
350 dino_conf_write(void *v
, pcitag_t tag
, int reg
, pcireg_t data
)
352 struct dino_softc
*sc
= v
;
353 volatile struct dino_regs
*r
= sc
->sc_regs
;
357 /* fix arbitration errata by disabling all pci devs on config read */
361 r
->pci_addr
= tag
| reg
;
362 r
->pci_conf_data
= htole32(data
);
364 /* fix coalescing config and io writes by interleaving w/ a read */
365 r
->pci_addr
= tag
| PCI_ID_REG
;
366 data1
= r
->pci_conf_data
;
368 /* restore arbitration */
373 dino_intr_map(struct pci_attach_args
*pa
, pci_intr_handle_t
*ihp
)
375 int line
= pa
->pa_intrline
;
386 dino_intr_string(void *v
, pci_intr_handle_t ih
)
390 snprintf(buf
, 32, "irq %ld", ih
);
398 dino_intr_establish(void *v
, pci_intr_handle_t ih
,
399 int pri
, int (*handler
)(void *), void *arg
)
401 struct dino_softc
*sc
= v
;
403 return hp700_intr_establish(sc
->sc_dv
, pri
, handler
, arg
,
404 &sc
->sc_int_reg
, ih
);
408 dino_intr_disestablish(void *v
, void *cookie
)
410 /* XXX Implement me */
416 dino_alloc_parent(device_t self
, struct pci_attach_args
*pa
, int io
)
418 struct dino_softc
*sc
= pa
->pa_pc
->_cookie
;
430 ex
= hp700_io_extent
;
432 start
= ex
->ex_start
; /* XXX or 0xf0800000? */
433 size
= DINO_MEM_CHUNK
;
436 if (extent_alloc_subregion(ex
, start
, ex
->ex_end
, size
, size
,
437 EX_NOBOUNDARY
, EX_NOWAIT
, &start
))
439 extent_free(ex
, start
, size
, EX_NOWAIT
);
440 return rbus_new_root_share(tag
, ex
, start
, size
, start
);
445 dino_iomap(void *v
, bus_addr_t bpa
, bus_size_t size
,
446 int flags
, bus_space_handle_t
*bshp
)
448 struct dino_softc
*sc
= v
;
451 if (!(flags
& BUS_SPACE_MAP_NOEXTENT
) &&
452 (error
= extent_alloc_region(sc
->sc_ioex
, bpa
, size
, EX_NOWAIT
)))
462 dino_memmap(void *v
, bus_addr_t bpa
, bus_size_t size
,
463 int flags
, bus_space_handle_t
*bshp
)
465 struct dino_softc
*sc
= v
;
466 volatile struct dino_regs
*r
= sc
->sc_regs
;
471 reg
|= 1 << ((bpa
>> 23) & 0x1f);
473 if (reg
& 0x80000001)
474 panic("mapping outside the mem extent range");
476 if ((error
= bus_space_map(sc
->sc_bt
, bpa
, size
, flags
, bshp
)))
478 ++sc
->sc_memrefcount
[((bpa
>> 23) & 0x1f)];
479 /* map into the upper bus space, if not yet mapped this 8M */
480 if (reg
!= r
->io_addr_en
)
486 dino_subregion(void *v
, bus_space_handle_t bsh
, bus_size_t offset
,
487 bus_size_t size
, bus_space_handle_t
*nbshp
)
489 *nbshp
= bsh
+ offset
;
494 dino_ioalloc(void *v
, bus_addr_t rstart
, bus_addr_t rend
, bus_size_t size
,
495 bus_size_t align
, bus_size_t boundary
, int flags
, bus_addr_t
*addrp
,
496 bus_space_handle_t
*bshp
)
498 struct dino_softc
*sc
= v
;
499 struct extent
*ex
= sc
->sc_ioex
;
503 if (rstart
< ex
->ex_start
|| rend
> ex
->ex_end
)
504 panic("dino_ioalloc: bad region start/end");
506 if ((error
= extent_alloc_subregion(ex
, rstart
, rend
, size
,
507 align
, boundary
, EX_NOWAIT
, &bpa
)))
519 dino_memalloc(void *v
, bus_addr_t rstart
, bus_addr_t rend
, bus_size_t size
,
520 bus_size_t align
, bus_size_t boundary
, int flags
, bus_addr_t
*addrp
,
521 bus_space_handle_t
*bshp
)
523 struct dino_softc
*sc
= v
;
524 volatile struct dino_regs
*r
= sc
->sc_regs
;
529 * Allow allocation only when PCI MEM is already mapped.
530 * Needed to avoid allocation of I/O space used by devices that
531 * have no driver in the current kernel.
532 * Dino can map PCI MEM in the range 0xf0800000..0xff800000 only.
535 if (rstart
< 0xf0800000 || rend
>= 0xff800000 || reg
== 0)
537 /* Find used PCI MEM and narrow allocateble region down to it. */
538 for (i
= 1; i
< 31; i
++)
539 if ((reg
& 1 << i
) != 0) {
540 rstart
= 0xf0000000 | i
<< 23;
541 rend
= (0xf0000000 | (i
+ 1) << 23) - 1;
544 if ((error
= bus_space_alloc(sc
->sc_bt
, rstart
, rend
, size
, align
,
545 boundary
, flags
, addrp
, bshp
)))
547 ++sc
->sc_memrefcount
[((*bshp
>> 23) & 0x1f)];
552 dino_unmap(void *v
, bus_space_handle_t bsh
, bus_size_t size
)
554 struct dino_softc
*sc
= v
;
555 volatile struct dino_regs
*r
= sc
->sc_regs
;
557 if (bsh
& 0xf0000000) {
558 bus_space_unmap(sc
->sc_bt
, bsh
, size
);
559 if (--sc
->sc_memrefcount
[((bsh
>> 23) & 0x1f)] == 0)
560 /* Unmap the upper PCI MEM space. */
561 r
->io_addr_en
&= ~(1 << ((bsh
>> 23) & 0x1f));
563 /* XXX gotta follow the BUS_SPACE_MAP_NOEXTENT flag */
564 if (extent_free(sc
->sc_ioex
, bsh
, size
, EX_NOWAIT
))
565 printf("dino_unmap: ps 0x%lx, size 0x%lx\n"
566 "dino_unmap: can't free region\n", bsh
, size
);
571 dino_free(void *v
, bus_space_handle_t bh
, bus_size_t size
)
573 /* should be enough */
574 dino_unmap(v
, bh
, size
);
578 dino_barrier(void *v
, bus_space_handle_t h
, bus_size_t o
, bus_size_t l
, int op
)
584 dino_vaddr(void *v
, bus_space_handle_t h
)
586 struct dino_softc
*sc
= v
;
588 return bus_space_vaddr(sc
->sc_bt
, h
);
592 dino_mmap(void *v
, bus_addr_t addr
, off_t off
, int prot
, int flags
)
598 dino_r1(void *v
, bus_space_handle_t h
, bus_size_t o
)
602 return *(volatile uint8_t *)h
;
604 struct dino_softc
*sc
= v
;
605 volatile struct dino_regs
*r
= sc
->sc_regs
;
608 return *((volatile uint8_t *)&r
->pci_io_data
+ (h
& 3));
613 dino_r2(void *v
, bus_space_handle_t h
, bus_size_t o
)
615 volatile uint16_t *p
;
619 p
= (volatile uint16_t *)h
;
621 struct dino_softc
*sc
= v
;
622 volatile struct dino_regs
*r
= sc
->sc_regs
;
625 p
= (volatile uint16_t *)&r
->pci_io_data
;
633 dino_r4(void *v
, bus_space_handle_t h
, bus_size_t o
)
639 data
= *(volatile uint32_t *)h
;
641 struct dino_softc
*sc
= v
;
642 volatile struct dino_regs
*r
= sc
->sc_regs
;
645 data
= r
->pci_io_data
;
648 return le32toh(data
);
652 dino_r8(void *v
, bus_space_handle_t h
, bus_size_t o
)
658 data
= *(volatile uint64_t *)h
;
660 panic("dino_r8: not implemented");
662 return le64toh(data
);
666 dino_w1(void *v
, bus_space_handle_t h
, bus_size_t o
, uint8_t vv
)
670 *(volatile uint8_t *)h
= vv
;
672 struct dino_softc
*sc
= v
;
673 volatile struct dino_regs
*r
= sc
->sc_regs
;
676 *((volatile uint8_t *)&r
->pci_io_data
+ (h
& 3)) = vv
;
681 dino_w2(void *v
, bus_space_handle_t h
, bus_size_t o
, uint16_t vv
)
683 volatile uint16_t *p
;
687 p
= (volatile uint16_t *)h
;
689 struct dino_softc
*sc
= v
;
690 volatile struct dino_regs
*r
= sc
->sc_regs
;
693 p
= (volatile uint16_t *)&r
->pci_io_data
;
702 dino_w4(void *v
, bus_space_handle_t h
, bus_size_t o
, uint32_t vv
)
707 *(volatile uint32_t *)h
= vv
;
709 struct dino_softc
*sc
= v
;
710 volatile struct dino_regs
*r
= sc
->sc_regs
;
718 dino_w8(void *v
, bus_space_handle_t h
, bus_size_t o
, uint64_t vv
)
722 *(volatile uint64_t *)h
= htole64(vv
);
724 panic("dino_w8: not implemented");
729 dino_rm_1(void *v
, bus_space_handle_t h
, bus_size_t o
, uint8_t *a
, bus_size_t c
)
735 p
= (volatile uint8_t *)h
;
737 struct dino_softc
*sc
= v
;
738 volatile struct dino_regs
*r
= sc
->sc_regs
;
741 p
= (volatile uint8_t *)&r
->pci_io_data
+ (h
& 3);
749 dino_rm_2(void *v
, bus_space_handle_t h
, bus_size_t o
, uint16_t *a
, bus_size_t c
)
751 volatile uint16_t *p
;
755 p
= (volatile uint16_t *)h
;
757 struct dino_softc
*sc
= v
;
758 volatile struct dino_regs
*r
= sc
->sc_regs
;
761 p
= (volatile uint16_t *)&r
->pci_io_data
;
771 dino_rm_4(void *v
, bus_space_handle_t h
, bus_size_t o
, uint32_t *a
, bus_size_t c
)
773 volatile uint32_t *p
;
777 p
= (volatile uint32_t *)h
;
779 struct dino_softc
*sc
= v
;
780 volatile struct dino_regs
*r
= sc
->sc_regs
;
783 p
= (volatile uint32_t *)&r
->pci_io_data
;
791 dino_rm_8(void *v
, bus_space_handle_t h
, bus_size_t o
, uint64_t *a
, bus_size_t c
)
793 panic("dino_rm_8: not implemented");
797 dino_wm_1(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint8_t *a
, bus_size_t c
)
803 p
= (volatile uint8_t *)h
;
805 struct dino_softc
*sc
= v
;
806 volatile struct dino_regs
*r
= sc
->sc_regs
;
809 p
= (volatile uint8_t *)&r
->pci_io_data
+ (h
& 3);
817 dino_wm_2(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint16_t *a
, bus_size_t c
)
819 volatile uint16_t *p
;
823 p
= (volatile uint16_t *)h
;
825 struct dino_softc
*sc
= v
;
826 volatile struct dino_regs
*r
= sc
->sc_regs
;
829 p
= (volatile uint16_t *)&r
->pci_io_data
;
839 dino_wm_4(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint32_t *a
, bus_size_t c
)
841 volatile uint32_t *p
;
845 p
= (volatile uint32_t *)h
;
847 struct dino_softc
*sc
= v
;
848 volatile struct dino_regs
*r
= sc
->sc_regs
;
851 p
= (volatile uint32_t *)&r
->pci_io_data
;
859 dino_wm_8(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint64_t *a
, bus_size_t c
)
861 panic("dino_wm_8: not implemented");
865 dino_sm_1(void *v
, bus_space_handle_t h
, bus_size_t o
, uint8_t vv
, bus_size_t c
)
871 p
= (volatile uint8_t *)h
;
873 struct dino_softc
*sc
= v
;
874 volatile struct dino_regs
*r
= sc
->sc_regs
;
877 p
= (volatile uint8_t *)&r
->pci_io_data
+ (h
& 3);
885 dino_sm_2(void *v
, bus_space_handle_t h
, bus_size_t o
, uint16_t vv
, bus_size_t c
)
887 volatile uint16_t *p
;
891 p
= (volatile uint16_t *)h
;
893 struct dino_softc
*sc
= v
;
894 volatile struct dino_regs
*r
= sc
->sc_regs
;
897 p
= (volatile uint16_t *)&r
->pci_io_data
;
907 dino_sm_4(void *v
, bus_space_handle_t h
, bus_size_t o
, uint32_t vv
, bus_size_t c
)
909 volatile uint32_t *p
;
913 p
= (volatile uint32_t *)h
;
915 struct dino_softc
*sc
= v
;
916 volatile struct dino_regs
*r
= sc
->sc_regs
;
919 p
= (volatile uint32_t *)&r
->pci_io_data
;
927 dino_sm_8(void *v
, bus_space_handle_t h
, bus_size_t o
, uint64_t vv
, bus_size_t c
)
929 panic("dino_sm_8: not implemented");
933 dino_rrm_2(void *v
, bus_space_handle_t h
, bus_size_t o
,
934 uint16_t *a
, bus_size_t c
)
936 volatile uint16_t *p
;
940 p
= (volatile uint16_t *)h
;
942 struct dino_softc
*sc
= v
;
943 volatile struct dino_regs
*r
= sc
->sc_regs
;
946 p
= (volatile uint16_t *)&r
->pci_io_data
;
957 dino_rrm_4(void *v
, bus_space_handle_t h
, bus_size_t o
,
958 uint32_t *a
, bus_size_t c
)
960 volatile uint32_t *p
;
964 p
= (volatile uint32_t *)h
;
966 struct dino_softc
*sc
= v
;
967 volatile struct dino_regs
*r
= sc
->sc_regs
;
970 p
= (volatile uint32_t *)&r
->pci_io_data
;
979 dino_rrm_8(void *v
, bus_space_handle_t h
, bus_size_t o
,
980 uint64_t *a
, bus_size_t c
)
982 panic("dino_rrm_8: not implemented");
986 dino_wrm_2(void *v
, bus_space_handle_t h
, bus_size_t o
,
987 const uint16_t *a
, bus_size_t c
)
989 volatile uint16_t *p
;
993 p
= (volatile uint16_t *)h
;
995 struct dino_softc
*sc
= v
;
996 volatile struct dino_regs
*r
= sc
->sc_regs
;
999 p
= (volatile uint16_t *)&r
->pci_io_data
;
1010 dino_wrm_4(void *v
, bus_space_handle_t h
, bus_size_t o
,
1011 const uint32_t *a
, bus_size_t c
)
1013 volatile uint32_t *p
;
1017 p
= (volatile uint32_t *)h
;
1019 struct dino_softc
*sc
= v
;
1020 volatile struct dino_regs
*r
= sc
->sc_regs
;
1023 p
= (volatile uint32_t *)&r
->pci_io_data
;
1032 dino_wrm_8(void *v
, bus_space_handle_t h
, bus_size_t o
,
1033 const uint64_t *a
, bus_size_t c
)
1035 panic("dino_wrm_8: not implemented");
1039 dino_rr_1(void *v
, bus_space_handle_t h
, bus_size_t o
, uint8_t *a
, bus_size_t c
)
1041 volatile uint8_t *p
;
1044 if (h
& 0xf0000000) {
1045 p
= (volatile uint8_t *)h
;
1049 struct dino_softc
*sc
= v
;
1050 volatile struct dino_regs
*r
= sc
->sc_regs
;
1054 p
= (volatile uint8_t *)&r
->pci_io_data
+ (h
& 3);
1061 dino_rr_2(void *v
, bus_space_handle_t h
, bus_size_t o
, uint16_t *a
, bus_size_t c
)
1063 volatile uint16_t *p
, data
;
1066 if (h
& 0xf0000000) {
1067 p
= (volatile uint16_t *)h
;
1070 *a
++ = le16toh(data
);
1073 struct dino_softc
*sc
= v
;
1074 volatile struct dino_regs
*r
= sc
->sc_regs
;
1076 for (; c
--; h
+= 2) {
1078 p
= (volatile uint16_t *)&r
->pci_io_data
;
1082 *a
++ = le16toh(data
);
1088 dino_rr_4(void *v
, bus_space_handle_t h
, bus_size_t o
, uint32_t *a
, bus_size_t c
)
1090 volatile uint32_t *p
, data
;
1093 if (h
& 0xf0000000) {
1094 p
= (volatile uint32_t *)h
;
1097 *a
++ = le32toh(data
);
1100 struct dino_softc
*sc
= v
;
1101 volatile struct dino_regs
*r
= sc
->sc_regs
;
1103 for (; c
--; h
+= 4) {
1105 data
= r
->pci_io_data
;
1106 *a
++ = le32toh(data
);
1112 dino_rr_8(void *v
, bus_space_handle_t h
, bus_size_t o
, uint64_t *a
, bus_size_t c
)
1114 panic("dino_rr_8: not implemented");
1118 dino_wr_1(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint8_t *a
, bus_size_t c
)
1120 volatile uint8_t *p
;
1123 if (h
& 0xf0000000) {
1124 p
= (volatile uint8_t *)h
;
1128 struct dino_softc
*sc
= v
;
1129 volatile struct dino_regs
*r
= sc
->sc_regs
;
1133 p
= (volatile uint8_t *)&r
->pci_io_data
+ (h
& 3);
1140 dino_wr_2(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint16_t *a
, bus_size_t c
)
1142 volatile uint16_t *p
, data
;
1145 if (h
& 0xf0000000) {
1146 p
= (volatile uint16_t *)h
;
1149 *p
++ = htole16(data
);
1152 struct dino_softc
*sc
= v
;
1153 volatile struct dino_regs
*r
= sc
->sc_regs
;
1155 for (; c
--; h
+= 2) {
1157 p
= (volatile uint16_t *)&r
->pci_io_data
;
1167 dino_wr_4(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint32_t *a
, bus_size_t c
)
1169 volatile uint32_t *p
, data
;
1172 if (h
& 0xf0000000) {
1173 p
= (volatile uint32_t *)h
;
1176 *p
++ = htole32(data
);
1179 struct dino_softc
*sc
= v
;
1180 volatile struct dino_regs
*r
= sc
->sc_regs
;
1182 for (; c
--; h
+= 4) {
1185 r
->pci_io_data
= htole32(data
);
1191 dino_wr_8(void *v
, bus_space_handle_t h
, bus_size_t o
, const uint64_t *a
, bus_size_t c
)
1193 panic("dino_wr_8: not implemented");
1197 dino_rrr_2(void *v
, bus_space_handle_t h
, bus_size_t o
,
1198 uint16_t *a
, bus_size_t c
)
1200 volatile uint16_t *p
;
1204 if (h
& 0xf0000000) {
1205 p
= (volatile uint16_t *)h
;
1209 struct dino_softc
*sc
= v
;
1210 volatile struct dino_regs
*r
= sc
->sc_regs
;
1212 for (; c
--; h
+= 2) {
1214 p
= (volatile uint16_t *)&r
->pci_io_data
;
1223 dino_rrr_4(void *v
, bus_space_handle_t h
, bus_size_t o
,
1224 uint32_t *a
, bus_size_t c
)
1226 volatile uint32_t *p
;
1230 if (h
& 0xf0000000) {
1231 p
= (volatile uint32_t *)h
;
1235 struct dino_softc
*sc
= v
;
1236 volatile struct dino_regs
*r
= sc
->sc_regs
;
1238 for (; c
--; h
+= 4) {
1240 *a
++ = r
->pci_io_data
;
1246 dino_rrr_8(void *v
, bus_space_handle_t h
, bus_size_t o
,
1247 uint64_t *a
, bus_size_t c
)
1249 panic("dino_rrr_8: not implemented");
1253 dino_wrr_2(void *v
, bus_space_handle_t h
, bus_size_t o
,
1254 const uint16_t *a
, bus_size_t c
)
1256 volatile uint16_t *p
;
1260 if (h
& 0xf0000000) {
1261 p
= (volatile uint16_t *)h
;
1265 struct dino_softc
*sc
= v
;
1266 volatile struct dino_regs
*r
= sc
->sc_regs
;
1268 for (; c
--; h
+= 2) {
1270 p
= (volatile uint16_t *)&r
->pci_io_data
;
1279 dino_wrr_4(void *v
, bus_space_handle_t h
, bus_size_t o
,
1280 const uint32_t *a
, bus_size_t c
)
1282 volatile uint32_t *p
;
1286 if (h
& 0xf0000000) {
1287 p
= (volatile uint32_t *)h
;
1291 struct dino_softc
*sc
= v
;
1292 volatile struct dino_regs
*r
= sc
->sc_regs
;
1294 for (; c
--; h
+= 4) {
1296 r
->pci_io_data
= *a
++;
1302 dino_wrr_8(void *v
, bus_space_handle_t h
, bus_size_t o
,
1303 const uint64_t *a
, bus_size_t c
)
1305 panic("dino_wrr_8: not implemented");
1309 dino_sr_1(void *v
, bus_space_handle_t h
, bus_size_t o
, uint8_t vv
, bus_size_t c
)
1311 volatile uint8_t *p
;
1314 if (h
& 0xf0000000) {
1315 p
= (volatile uint8_t *)h
;
1319 struct dino_softc
*sc
= v
;
1320 volatile struct dino_regs
*r
= sc
->sc_regs
;
1324 p
= (volatile uint8_t *)&r
->pci_io_data
+ (h
& 3);
1331 dino_sr_2(void *v
, bus_space_handle_t h
, bus_size_t o
, uint16_t vv
, bus_size_t c
)
1333 volatile uint16_t *p
;
1337 if (h
& 0xf0000000) {
1338 p
= (volatile uint16_t *)h
;
1342 struct dino_softc
*sc
= v
;
1343 volatile struct dino_regs
*r
= sc
->sc_regs
;
1345 for (; c
--; h
+= 2) {
1347 p
= (volatile uint16_t *)&r
->pci_io_data
;
1356 dino_sr_4(void *v
, bus_space_handle_t h
, bus_size_t o
, uint32_t vv
, bus_size_t c
)
1358 volatile uint32_t *p
;
1362 if (h
& 0xf0000000) {
1363 p
= (volatile uint32_t *)h
;
1367 struct dino_softc
*sc
= v
;
1368 volatile struct dino_regs
*r
= sc
->sc_regs
;
1370 for (; c
--; h
+= 4) {
1372 r
->pci_io_data
= vv
;
1378 dino_sr_8(void *v
, bus_space_handle_t h
, bus_size_t o
, uint64_t vv
, bus_size_t c
)
1380 panic("dino_sr_8: not implemented");
1384 dino_cp_1(void *v
, bus_space_handle_t h1
, bus_size_t o1
,
1385 bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
1388 dino_w1(v
, h1
, o1
++, dino_r1(v
, h2
, o2
++));
1392 dino_cp_2(void *v
, bus_space_handle_t h1
, bus_size_t o1
,
1393 bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
1396 dino_w2(v
, h1
, o1
, dino_r2(v
, h2
, o2
));
1403 dino_cp_4(void *v
, bus_space_handle_t h1
, bus_size_t o1
,
1404 bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
1407 dino_w4(v
, h1
, o1
, dino_r4(v
, h2
, o2
));
1414 dino_cp_8(void *v
, bus_space_handle_t h1
, bus_size_t o1
,
1415 bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
1418 dino_w8(v
, h1
, o1
, dino_r8(v
, h2
, o2
));
1425 const struct hppa_bus_space_tag dino_iomemt
= {
1428 NULL
, dino_unmap
, dino_subregion
, NULL
, dino_free
,
1429 dino_barrier
, dino_vaddr
, dino_mmap
,
1430 dino_r1
, dino_r2
, dino_r4
, dino_r8
,
1431 dino_w1
, dino_w2
, dino_w4
, dino_w8
,
1432 dino_rm_1
, dino_rm_2
, dino_rm_4
, dino_rm_8
,
1433 dino_wm_1
, dino_wm_2
, dino_wm_4
, dino_wm_8
,
1434 dino_sm_1
, dino_sm_2
, dino_sm_4
, dino_sm_8
,
1435 dino_rrm_2
, dino_rrm_4
, dino_rrm_8
,
1436 dino_wrm_2
, dino_wrm_4
, dino_wrm_8
,
1437 dino_rr_1
, dino_rr_2
, dino_rr_4
, dino_rr_8
,
1438 dino_wr_1
, dino_wr_2
, dino_wr_4
, dino_wr_8
,
1439 dino_rrr_2
, dino_rrr_4
, dino_rrr_8
,
1440 dino_wrr_2
, dino_wrr_4
, dino_wrr_8
,
1441 dino_sr_1
, dino_sr_2
, dino_sr_4
, dino_sr_8
,
1442 dino_cp_1
, dino_cp_2
, dino_cp_4
, dino_cp_8
1446 dino_dmamap_create(void *v
, bus_size_t size
, int nsegments
,
1447 bus_size_t maxsegsz
, bus_size_t boundary
, int flags
, bus_dmamap_t
*dmamp
)
1449 struct dino_softc
*sc
= v
;
1451 /* TODO check the addresses, boundary, enable dma */
1453 return bus_dmamap_create(sc
->sc_dmat
, size
, nsegments
,
1454 maxsegsz
, boundary
, flags
, dmamp
);
1458 dino_dmamap_destroy(void *v
, bus_dmamap_t map
)
1460 struct dino_softc
*sc
= v
;
1462 bus_dmamap_destroy(sc
->sc_dmat
, map
);
1466 dino_dmamap_load(void *v
, bus_dmamap_t map
, void *addr
, bus_size_t size
,
1467 struct proc
*p
, int flags
)
1469 struct dino_softc
*sc
= v
;
1471 return bus_dmamap_load(sc
->sc_dmat
, map
, addr
, size
, p
, flags
);
1475 dino_dmamap_load_mbuf(void *v
, bus_dmamap_t map
, struct mbuf
*m
, int flags
)
1477 struct dino_softc
*sc
= v
;
1479 return bus_dmamap_load_mbuf(sc
->sc_dmat
, map
, m
, flags
);
1483 dino_dmamap_load_uio(void *v
, bus_dmamap_t map
, struct uio
*uio
, int flags
)
1485 struct dino_softc
*sc
= v
;
1487 return bus_dmamap_load_uio(sc
->sc_dmat
, map
, uio
, flags
);
1491 dino_dmamap_load_raw(void *v
, bus_dmamap_t map
, bus_dma_segment_t
*segs
,
1492 int nsegs
, bus_size_t size
, int flags
)
1494 struct dino_softc
*sc
= v
;
1496 return bus_dmamap_load_raw(sc
->sc_dmat
, map
, segs
, nsegs
, size
, flags
);
1500 dino_dmamap_unload(void *v
, bus_dmamap_t map
)
1502 struct dino_softc
*sc
= v
;
1504 bus_dmamap_unload(sc
->sc_dmat
, map
);
1508 dino_dmamap_sync(void *v
, bus_dmamap_t map
, bus_addr_t off
,
1509 bus_size_t len
, int ops
)
1511 struct dino_softc
*sc
= v
;
1513 return bus_dmamap_sync(sc
->sc_dmat
, map
, off
, len
, ops
);
1517 dino_dmamem_alloc(void *v
, bus_size_t size
, bus_size_t alignment
,
1518 bus_size_t boundary
, bus_dma_segment_t
*segs
,
1519 int nsegs
, int *rsegs
, int flags
)
1521 struct dino_softc
*sc
= v
;
1523 return bus_dmamem_alloc(sc
->sc_dmat
, size
, alignment
, boundary
,
1524 segs
, nsegs
, rsegs
, flags
);
1528 dino_dmamem_free(void *v
, bus_dma_segment_t
*segs
, int nsegs
)
1530 struct dino_softc
*sc
= v
;
1532 bus_dmamem_free(sc
->sc_dmat
, segs
, nsegs
);
1536 dino_dmamem_map(void *v
, bus_dma_segment_t
*segs
, int nsegs
, size_t size
,
1537 void **kvap
, int flags
)
1539 struct dino_softc
*sc
= v
;
1541 return bus_dmamem_map(sc
->sc_dmat
, segs
, nsegs
, size
, kvap
, flags
);
1545 dino_dmamem_unmap(void *v
, void *kva
, size_t size
)
1547 struct dino_softc
*sc
= v
;
1549 bus_dmamem_unmap(sc
->sc_dmat
, kva
, size
);
1553 dino_dmamem_mmap(void *v
, bus_dma_segment_t
*segs
, int nsegs
, off_t off
,
1554 int prot
, int flags
)
1556 struct dino_softc
*sc
= v
;
1558 return bus_dmamem_mmap(sc
->sc_dmat
, segs
, nsegs
, off
, prot
, flags
);
1561 const struct hppa_bus_dma_tag dino_dmat
= {
1563 dino_dmamap_create
, dino_dmamap_destroy
,
1564 dino_dmamap_load
, dino_dmamap_load_mbuf
,
1565 dino_dmamap_load_uio
, dino_dmamap_load_raw
,
1566 dino_dmamap_unload
, dino_dmamap_sync
,
1568 dino_dmamem_alloc
, dino_dmamem_free
, dino_dmamem_map
,
1569 dino_dmamem_unmap
, dino_dmamem_mmap
1572 const struct hppa_pci_chipset_tag dino_pc
= {
1574 dino_attach_hook
, dino_maxdevs
, dino_make_tag
, dino_decompose_tag
,
1575 dino_conf_read
, dino_conf_write
,
1576 dino_intr_map
, dino_intr_string
,
1577 dino_intr_establish
, dino_intr_disestablish
,
1586 dinomatch(device_t parent
, cfdata_t cfdata
, void *aux
)
1588 struct confargs
*ca
= aux
;
1590 /* there will be only one */
1591 if (ca
->ca_type
.iodc_type
!= HPPA_TYPE_BRIDGE
||
1592 ca
->ca_type
.iodc_sv_model
!= HPPA_BRIDGE_DINO
)
1595 /* Make sure we have an IRQ. */
1596 if (ca
->ca_irq
== HP700CF_IRQ_UNDEF
)
1597 ca
->ca_irq
= hp700_intr_allocate_bit(&int_reg_cpu
);
1603 dinoattach(device_t parent
, device_t self
, void *aux
)
1605 struct dino_softc
*sc
= device_private(self
);
1606 struct confargs
*ca
= (struct confargs
*)aux
, nca
;
1607 struct pcibus_attach_args pba
;
1608 volatile struct dino_regs
*r
;
1614 sc
->sc_bt
= ca
->ca_iot
;
1615 sc
->sc_dmat
= ca
->ca_dmatag
;
1617 if (ca
->ca_irq
== HP700CF_IRQ_UNDEF
) {
1618 aprint_error_dev(self
, ": can't allocate IRQ");
1622 if (bus_space_map(sc
->sc_bt
, ca
->ca_hpa
, PAGE_SIZE
, 0, &sc
->sc_bh
)) {
1623 aprint_error(": can't map space\n");
1627 sc
->sc_regs
= r
= (volatile struct dino_regs
*)sc
->sc_bh
;
1628 #ifdef trust_the_firmware_to_proper_initialize_everything
1630 r
->io_control
= 0x80;
1635 r
->gmask
&= ~1; /* allow GSC bus req */
1638 r
->brdg_feat
= 0xc0000000;
1641 snprintf(sc
->sc_ioexname
, sizeof(sc
->sc_ioexname
),
1642 "%s_io", device_xname(self
));
1643 if ((sc
->sc_ioex
= extent_create(sc
->sc_ioexname
, 0, 0xffff,
1644 M_DEVBUF
, NULL
, 0, EX_NOWAIT
| EX_MALLOCOK
)) == NULL
) {
1645 aprint_error(": can't allocate I/O extent map\n");
1646 bus_space_unmap(sc
->sc_bt
, sc
->sc_bh
, PAGE_SIZE
);
1650 /* interrupts guts */
1656 r
->iar0
= cpu_gethpa(0) | (31 - ca
->ca_irq
);
1658 /* Establish the interrupt register. */
1659 hp700_intr_reg_establish(&sc
->sc_int_reg
);
1660 sc
->sc_int_reg
.int_reg_mask
= &r
->imr
;
1661 sc
->sc_int_reg
.int_reg_req
= &r
->irr0
;
1662 sc
->sc_int_reg
.int_reg_level
= &r
->ilr
;
1663 /* Add the I/O interrupt register. */
1664 sc
->sc_int_reg
.int_reg_dev
= device_xname(self
);
1665 sc
->sc_ih
= hp700_intr_establish(sc
->sc_dv
, IPL_NONE
,
1666 NULL
, &sc
->sc_int_reg
, &int_reg_cpu
, ca
->ca_irq
);
1668 /* TODO establish the bus error interrupt */
1672 ver
= (ca
->ca_type
.iodc_model
<< 4) |
1673 (ca
->ca_type
.iodc_revision
>> 4);
1675 case 0x05d: p
= "Dino"; /* j2240 */
1676 case 0x680: p
= "Dino";
1677 switch (data
>> 16) {
1678 case 0x6800: ver
= 0x20; break;
1679 case 0x6801: ver
= 0x21; break;
1680 case 0x6802: ver
= 0x30; break;
1681 case 0x6803: ver
= 0x31; break;
1682 default: ver
= 0x40; break;
1686 case 0x682: p
= "Cujo";
1687 switch (data
>> 16) {
1688 case 0x6820: ver
= 0x10; break;
1689 case 0x6821: ver
= 0x20; break;
1690 default: ver
= 0x30; break;
1694 default: p
= "Mojo";
1695 ver
= (data
>> 16) & 0xff;
1699 aprint_normal(": %s V%d.%d\n", p
, ver
>> 4, ver
& 0xf);
1701 sc
->sc_iot
= dino_iomemt
;
1702 sc
->sc_iot
.hbt_cookie
= sc
;
1703 sc
->sc_iot
.hbt_map
= dino_iomap
;
1704 sc
->sc_iot
.hbt_alloc
= dino_ioalloc
;
1705 sc
->sc_memt
= dino_iomemt
;
1706 sc
->sc_memt
.hbt_cookie
= sc
;
1707 sc
->sc_memt
.hbt_map
= dino_memmap
;
1708 sc
->sc_memt
.hbt_alloc
= dino_memalloc
;
1709 sc
->sc_pc
= dino_pc
;
1710 sc
->sc_pc
._cookie
= sc
;
1711 sc
->sc_dmatag
= dino_dmat
;
1712 sc
->sc_dmatag
._cookie
= sc
;
1714 /* scan for ps2 kbd/ms, serial, and flying toasters */
1718 nca
.ca_nmodules
= MAXMODBUS
;
1719 pdc_scanbus(self
, &nca
, dino_callback
);
1721 memset(&pba
, 0, sizeof(pba
));
1722 pba
.pba_iot
= &sc
->sc_iot
;
1723 pba
.pba_memt
= &sc
->sc_memt
;
1724 pba
.pba_dmat
= &sc
->sc_dmatag
;
1725 pba
.pba_pc
= &sc
->sc_pc
;
1727 pba
.pba_flags
= PCI_FLAGS_IO_ENABLED
| PCI_FLAGS_MEM_ENABLED
;
1728 config_found_ia(self
, "pcibus", &pba
, pcibusprint
);
1732 dino_callback(device_t self
, struct confargs
*ca
)
1735 config_found_sm_loc(self
, "dino", NULL
, ca
, mbprint
, mbsubmatch
);