1 /* $NetBSD: sti_sgc.c,v 1.17 2009/05/24 06:53:34 skrll Exp $ */
3 /* $OpenBSD: sti_sgc.c,v 1.21 2003/12/22 23:39:06 mickey Exp $ */
6 * Copyright (c) 2000-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 * These cards has to be known to work so far:
32 * - HPA1991AGrayscale rev 0.02 (705/35) (byte-wide)
33 * - HPA1991AC19 rev 0.02 (715/33) (byte-wide)
34 * - HPA208LC1280 rev 8.04 (712/80) just works
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.17 2009/05/24 06:53:34 skrll Exp $");
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/device.h>
46 #include <machine/bus.h>
47 #include <machine/cpu.h>
48 #include <machine/iomod.h>
49 #include <machine/autoconf.h>
51 #include <dev/wscons/wsdisplayvar.h>
52 #include <dev/wscons/wsconsio.h>
54 #include <dev/ic/stireg.h>
55 #include <dev/ic/stivar.h>
57 #include <hp700/dev/cpudevs.h>
58 #include <hp700/hp700/machdep.h>
60 #define STI_ROMSIZE (sizeof(struct sti_dd) * 4)
61 #define STI_ID_FDDI 0x280b31af /* Medusa FDDI ROM id */
63 /* gecko optional graphics */
64 #define STI_GOPT1_REV 0x17
65 #define STI_GOPT2_REV 0x70
66 #define STI_GOPT3_REV 0xd0
67 #define STI_GOPT4_REV 0x00
68 #define STI_GOPT5_REV 0x20
69 #define STI_GOPT6_REV 0x40
70 #define STI_GOPT7_REV 0x30
73 #define STI_INEG_REV 0x60
74 #define STI_INEG_PROM 0xf0011000
76 int sti_sgc_probe(device_t
, cfdata_t
, void *);
77 void sti_sgc_attach(device_t
, device_t
, void *);
79 CFATTACH_DECL_NEW(sti_gedoens
, sizeof(struct sti_softc
), sti_sgc_probe
, sti_sgc_attach
,
82 paddr_t
sti_sgc_getrom(struct confargs
*);
86 * On some machines it may not be part of the HPA space.
89 sti_sgc_getrom(struct confargs
*ca
)
96 if (ca
->ca_type
.iodc_sv_model
!= HPPA_FIO_GSGC
) {
100 switch (ca
->ca_type
.iodc_revision
) {
108 /* these share the onboard's prom */
109 pagezero_cookie
= hp700_pagezero_map();
110 rom
= PAGE0
->pd_resv2
[1];
111 hp700_pagezero_unmap(pagezero_cookie
);
122 sti_sgc_probe(device_t parent
, cfdata_t cf
, void *aux
)
124 struct confargs
*ca
= aux
;
125 bus_space_handle_t romh
;
129 int rv
= 0, romunmapped
= 0;
131 if (ca
->ca_type
.iodc_type
!= HPPA_TYPE_FIO
)
134 /* these need futher checking for the graphics id */
135 if (ca
->ca_type
.iodc_sv_model
!= HPPA_FIO_GSGC
&&
136 ca
->ca_type
.iodc_sv_model
!= HPPA_FIO_SGC
)
139 rom
= sti_sgc_getrom(ca
);
141 printf ("sti: hpa=%x, rom=%x\n", (uint
)ca
->ca_hpa
, (uint
)rom
);
144 /* if it does not map, probably part of the lasi space */
145 if ((rv
= bus_space_map(ca
->ca_iot
, rom
, STI_ROMSIZE
, 0, &romh
))) {
147 printf ("sti: can't map rom space (%d)\n", rv
);
149 if ((rom
& HPPA_IOBEGIN
) == HPPA_IOBEGIN
) {
153 /* in this case nobody has no freaking idea */
158 devtype
= bus_space_read_1(ca
->ca_iot
, romh
, 3);
161 printf("sti: devtype=%d\n", devtype
);
166 id
= bus_space_read_4(ca
->ca_iot
, romh
, STI_DEV4_DD_GRID
);
167 romend
= bus_space_read_4(ca
->ca_iot
, romh
, STI_DEV4_DD_ROMEND
);
170 id
= (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_GRID
172 (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_GRID
174 (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_GRID
176 (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_GRID
178 romend
= (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_ROMEND
180 (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_ROMEND
182 (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_ROMEND
184 (bus_space_read_1(ca
->ca_iot
, romh
, STI_DEV1_DD_ROMEND
189 printf("sti: unknown type (%x)\n", devtype
);
196 ca
->ca_type
.iodc_sv_model
== HPPA_FIO_SGC
&& id
== STI_ID_FDDI
) {
198 printf("sti: not a graphics device\n");
203 if (ca
->ca_naddrs
>= sizeof(ca
->ca_addrs
) / sizeof(ca
->ca_addrs
[0])) {
204 printf("sti: address list overflow\n");
208 ca
->ca_addrs
[ca
->ca_naddrs
].addr
= rom
;
209 ca
->ca_addrs
[ca
->ca_naddrs
].size
= round_page(romend
);
213 bus_space_unmap(ca
->ca_iot
, romh
, STI_ROMSIZE
);
218 sti_sgc_attach(device_t parent
, device_t self
, void *aux
)
220 struct sti_softc
*sc
= device_private(self
);
221 struct confargs
*ca
= aux
;
227 pagezero_cookie
= hp700_pagezero_map();
229 sc
->memt
= sc
->iot
= ca
->ca_iot
;
230 sc
->base
= ca
->ca_hpa
;
232 /* we stashed rom addr/len into the last slot during probe */
233 rom
= ca
->ca_addrs
[ca
->ca_naddrs
- 1].addr
;
234 romlen
= ca
->ca_addrs
[ca
->ca_naddrs
- 1].size
;
235 if ((rv
= bus_space_map(ca
->ca_iot
, rom
, romlen
, 0, &sc
->romh
))) {
236 if ((rom
& HPPA_IOBEGIN
) == HPPA_IOBEGIN
)
239 aprint_error(": can't map rom space (%d)\n", rv
);
246 * PCXL2: enable accel I/O for this space, see PCX-L2 ERS "ACCEL_IO".
247 * "pcxl2_ers.{ps,pdf}", (section / chapter . rel. page / abs. page)
248 * 8.7.4 / 8-12 / 92, 11.3.14 / 11-14 / 122 and 14.8 / 14-5 / 203.
250 if (strcmp(hppa_cpu_info
->hppa_cpu_info_chip_type
, "PCX-L2") == 0
251 && ca
->ca_hpa
>= PCXL2_ACCEL_IO_START
252 && ca
->ca_hpa
<= PCXL2_ACCEL_IO_END
)
253 eaio_l2(PCXL2_ACCEL_IO_ADDR2MASK(ca
->ca_hpa
));
254 #endif /* HP7300LC_CPU */
256 sc
->sc_devtype
= bus_space_read_1(sc
->iot
, sc
->romh
, 3);
257 if (ca
->ca_hpa
== (hppa_hpa_t
)PAGE0
->mem_cons
.pz_hpa
)
258 sc
->sc_flags
|= STI_CONSOLE
;
259 hp700_pagezero_unmap(pagezero_cookie
);
260 sti_attach_common(sc
);