1a1cb14f5Sbouyer /*	$OpenBSD: gdium_machdep.c,v 1.6 2010/05/08 21:59:56 miod Exp $	*/
2a1cb14f5Sbouyer 
3a1cb14f5Sbouyer /*
4a1cb14f5Sbouyer  * Copyright (c) 2010 Miodrag Vallat.
5a1cb14f5Sbouyer  *
6a1cb14f5Sbouyer  * Permission to use, copy, modify, and distribute this software for any
7a1cb14f5Sbouyer  * purpose with or without fee is hereby granted, provided that the above
8a1cb14f5Sbouyer  * copyright notice and this permission notice appear in all copies.
9a1cb14f5Sbouyer  *
10a1cb14f5Sbouyer  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11a1cb14f5Sbouyer  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12a1cb14f5Sbouyer  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13a1cb14f5Sbouyer  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14a1cb14f5Sbouyer  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15a1cb14f5Sbouyer  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16a1cb14f5Sbouyer  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17a1cb14f5Sbouyer  */
18a1cb14f5Sbouyer 
19a1cb14f5Sbouyer /*
20a1cb14f5Sbouyer  * Gdium Liberty specific code and configuration data.
21a1cb14f5Sbouyer  */
22a1cb14f5Sbouyer 
23a1cb14f5Sbouyer #include <sys/param.h>
24a1cb14f5Sbouyer #include <sys/systm.h>
25a1cb14f5Sbouyer #include <sys/device.h>
26a1cb14f5Sbouyer #include <sys/types.h>
27a1cb14f5Sbouyer 
283e5a2f87Smacallan #include <mips/cpuregs.h>
29a1cb14f5Sbouyer #include <evbmips/loongson/autoconf.h>
30a1cb14f5Sbouyer #include <evbmips/loongson/loongson_intr.h>
31a1cb14f5Sbouyer 
32a1cb14f5Sbouyer #include <dev/pci/pcireg.h>
33a1cb14f5Sbouyer #include <dev/pci/pcivar.h>
34a1cb14f5Sbouyer #include <dev/pci/pcidevs.h>
35a1cb14f5Sbouyer 
36a1cb14f5Sbouyer #include <mips/bonito/bonitoreg.h>
37a1cb14f5Sbouyer #include <mips/bonito/bonitovar.h>
38a1cb14f5Sbouyer 
39275299a6Smacallan #include <dev/wscons/wsconsio.h>
40275299a6Smacallan #include <dev/wscons/wsdisplayvar.h>
41275299a6Smacallan #include <dev/rasops/rasops.h>
42275299a6Smacallan #include <dev/wsfont/wsfont.h>
43275299a6Smacallan #include <dev/wscons/wsdisplay_vconsvar.h>
44275299a6Smacallan 
45a1cb14f5Sbouyer int	gdium_revision = 0;
46275299a6Smacallan static pcireg_t fb_addr = 0;
47a1cb14f5Sbouyer 
48a1cb14f5Sbouyer void	gdium_attach_hook(device_t, device_t, struct pcibus_attach_args *);
495f819ca3Schs void	gdium_device_register(device_t, void *);
50a1cb14f5Sbouyer int	gdium_intr_map(int, int, int, pci_intr_handle_t *);
51a1cb14f5Sbouyer void	gdium_powerdown(void);
52a1cb14f5Sbouyer void	gdium_reset(void);
53a1cb14f5Sbouyer 
54a1cb14f5Sbouyer const struct bonito_config gdium_bonito = {
55a1cb14f5Sbouyer 	.bc_adbase = 11,
56a1cb14f5Sbouyer 
57a1cb14f5Sbouyer 	.bc_gpioIE = LOONGSON_INTRMASK_GPIO,
58a1cb14f5Sbouyer 	.bc_intEdge = LOONGSON_INTRMASK_PCI_SYSERR |
59a1cb14f5Sbouyer 	    LOONGSON_INTRMASK_PCI_PARERR,
60a1cb14f5Sbouyer 	.bc_intSteer = 0,
61a1cb14f5Sbouyer 	.bc_intPol = LOONGSON_INTRMASK_DRAM_PARERR |
62a1cb14f5Sbouyer 	    LOONGSON_INTRMASK_PCI_SYSERR | LOONGSON_INTRMASK_PCI_PARERR,
63a1cb14f5Sbouyer 
64a1cb14f5Sbouyer 	.bc_attach_hook = gdium_attach_hook,
65a1cb14f5Sbouyer };
66a1cb14f5Sbouyer 
67a1cb14f5Sbouyer 
68a1cb14f5Sbouyer const struct platform gdium_platform = {
69a1cb14f5Sbouyer 	.system_type = LOONGSON_GDIUM,
70a1cb14f5Sbouyer 	.vendor = "EMTEC",
71a1cb14f5Sbouyer 	.product = "Gdium",
72a1cb14f5Sbouyer 
73a1cb14f5Sbouyer 	.bonito_config = &gdium_bonito,
74a1cb14f5Sbouyer 	.isa_chipset = NULL,
75a1cb14f5Sbouyer 	.legacy_io_ranges = NULL,
76a1cb14f5Sbouyer 	.bonito_mips_intr = MIPS_INT_MASK_4,
77a1cb14f5Sbouyer 	.isa_mips_intr = 0,
78a1cb14f5Sbouyer 	.isa_intr = NULL,
79a1cb14f5Sbouyer 	.p_pci_intr_map = gdium_intr_map,
80a1cb14f5Sbouyer 	.irq_map = loongson2f_irqmap,
81a1cb14f5Sbouyer 
82a1cb14f5Sbouyer 	.setup = NULL,
83a1cb14f5Sbouyer 	.device_register = gdium_device_register,
84a1cb14f5Sbouyer 
85a1cb14f5Sbouyer 	.powerdown = gdium_powerdown,
86a1cb14f5Sbouyer 	.reset = gdium_reset
87a1cb14f5Sbouyer };
88a1cb14f5Sbouyer 
89275299a6Smacallan static struct vcons_screen gdium_console_screen;
90275299a6Smacallan 
91275299a6Smacallan static struct wsscreen_descr gdium_stdscreen = {
92275299a6Smacallan 	.name = "std",
93275299a6Smacallan };
94275299a6Smacallan 
95a1cb14f5Sbouyer void
gdium_attach_hook(device_t parent,device_t self,struct pcibus_attach_args * pba)96a1cb14f5Sbouyer gdium_attach_hook(device_t parent, device_t self,
97a1cb14f5Sbouyer     struct pcibus_attach_args *pba)
98a1cb14f5Sbouyer {
99a1cb14f5Sbouyer 	pci_chipset_tag_t pc = pba->pba_pc;
100a1cb14f5Sbouyer 	pcireg_t id;
101a1cb14f5Sbouyer 	pcitag_t tag;
102a1cb14f5Sbouyer #ifdef notyet
103a1cb14f5Sbouyer 	int bar;
104a1cb14f5Sbouyer #endif
105a1cb14f5Sbouyer #if 0
106a1cb14f5Sbouyer 	pcireg_t reg;
107a1cb14f5Sbouyer 	int dev, func;
108a1cb14f5Sbouyer #endif
109a1cb14f5Sbouyer 
110a1cb14f5Sbouyer 	if (pba->pba_bus != 0)
111a1cb14f5Sbouyer 		return;
112a1cb14f5Sbouyer 
113a1cb14f5Sbouyer #ifdef notyet
114a1cb14f5Sbouyer 	/*
115a1cb14f5Sbouyer 	 * Clear all BAR of the mini PCI slot; PMON did not initialize
116a1cb14f5Sbouyer 	 * it, and we do not want it to conflict with anything.
117a1cb14f5Sbouyer 	 */
118a1cb14f5Sbouyer 	tag = pci_make_tag(pc, 0, 13, 0);
119a1cb14f5Sbouyer 	for (bar = PCI_MAPREG_START; bar < PCI_MAPREG_END; bar += 4)
120a1cb14f5Sbouyer 		pci_conf_write(pc, tag, bar, 0);
121a1cb14f5Sbouyer #else
122a1cb14f5Sbouyer 	/*
123a1cb14f5Sbouyer 	 * Force a non conflicting BAR for the wireless controller,
124a1cb14f5Sbouyer 	 * until proper resource configuration code is added to
125a1cb14f5Sbouyer 	 * bonito (work in progress).
126a1cb14f5Sbouyer 	 */
127a1cb14f5Sbouyer 	tag = pci_make_tag(pc, 0, 13, 0);
128a1cb14f5Sbouyer 	pci_conf_write(pc, tag, PCI_MAPREG_START, 0x06228000);
129a1cb14f5Sbouyer #endif
130a1cb14f5Sbouyer 
131a1cb14f5Sbouyer 	/*
132a1cb14f5Sbouyer 	 * Figure out which motherboard we are running on.
133a1cb14f5Sbouyer 	 * Might not be good enough...
134a1cb14f5Sbouyer 	 */
135a1cb14f5Sbouyer 	tag = pci_make_tag(pc, 0, 17, 0);
136a1cb14f5Sbouyer 	id = pci_conf_read(pc, tag, PCI_ID_REG);
137a1cb14f5Sbouyer 	if (id == PCI_ID_CODE(PCI_VENDOR_NEC, PCI_PRODUCT_NEC_USB))
138a1cb14f5Sbouyer 		gdium_revision = 1;
139a1cb14f5Sbouyer 
140a1cb14f5Sbouyer #if 0
141a1cb14f5Sbouyer 	/*
142a1cb14f5Sbouyer 	 * Tweak the usb controller capabilities.
143a1cb14f5Sbouyer 	 */
144a1cb14f5Sbouyer 	for (dev = pci_bus_maxdevs(pc, 0); dev >= 0; dev--) {
145a1cb14f5Sbouyer 		tag = pci_make_tag(pc, 0, dev, 0);
146a1cb14f5Sbouyer 		id = pci_conf_read(pc, tag, PCI_ID_REG);
147a1cb14f5Sbouyer 		if (id != PCI_ID_CODE(PCI_VENDOR_NEC, PCI_PRODUCT_NEC_USB))
148a1cb14f5Sbouyer 			continue;
149a1cb14f5Sbouyer 		if (gdium_revision != 0) {
150a1cb14f5Sbouyer 			reg = pci_conf_read(pc, tag, 0xe0);
151a1cb14f5Sbouyer 			/* enable ports 1 and 2 */
152a1cb14f5Sbouyer 			reg |= 0x00000003;
153a1cb14f5Sbouyer 			pci_conf_write(pc, tag, 0xe0, reg);
154a1cb14f5Sbouyer 		} else {
155a1cb14f5Sbouyer 			for (func = 0; func < 2; func++) {
156a1cb14f5Sbouyer 				tag = pci_make_tag(pc, 0, dev, func);
157a1cb14f5Sbouyer 				id = pci_conf_read(pc, tag, PCI_ID_REG);
158a1cb14f5Sbouyer 				if (PCI_VENDOR(id) != PCI_VENDOR_NEC)
159a1cb14f5Sbouyer 					continue;
160a1cb14f5Sbouyer 				if (PCI_PRODUCT(id) != PCI_PRODUCT_NEC_USB &&
161a1cb14f5Sbouyer 				    PCI_PRODUCT(id) != PCI_PRODUCT_NEC_USB2)
162a1cb14f5Sbouyer 					continue;
163a1cb14f5Sbouyer 
164a1cb14f5Sbouyer 				reg = pci_conf_read(pc, tag, 0xe0);
165a1cb14f5Sbouyer 				/* enable ports 1 and 3, disable port 2 */
166a1cb14f5Sbouyer 				reg &= ~0x00000007;
167a1cb14f5Sbouyer 				reg |= 0x00000005;
168a1cb14f5Sbouyer 				pci_conf_write(pc, tag, 0xe0, reg);
169a1cb14f5Sbouyer 				pci_conf_write(pc, tag, 0xe4, 0x00000020);
170a1cb14f5Sbouyer 			}
171a1cb14f5Sbouyer 		}
172a1cb14f5Sbouyer 	}
173a1cb14f5Sbouyer #endif
174a1cb14f5Sbouyer }
175a1cb14f5Sbouyer 
176a1cb14f5Sbouyer int
gdium_intr_map(int dev,int fn,int pin,pci_intr_handle_t * ihp)177a1cb14f5Sbouyer gdium_intr_map(int dev, int fn, int pin, pci_intr_handle_t *ihp)
178a1cb14f5Sbouyer {
179a1cb14f5Sbouyer 	switch (dev) {
180a1cb14f5Sbouyer 	/* mini-PCI slot */
181a1cb14f5Sbouyer 	case 13:	/* C D A B */
182a1cb14f5Sbouyer 		*ihp = BONITO_DIRECT_IRQ(LOONGSON_INTR_PCIA + (pin + 1) % 4);
183a1cb14f5Sbouyer 		return 0;
184a1cb14f5Sbouyer 	/* Frame buffer */
185a1cb14f5Sbouyer 	case 14:
186a1cb14f5Sbouyer 		*ihp = BONITO_DIRECT_IRQ(LOONGSON_INTR_PCIA);
187a1cb14f5Sbouyer 		return 0;
188a1cb14f5Sbouyer 	/* USB */
189a1cb14f5Sbouyer 	case 15:
190a1cb14f5Sbouyer 		if (gdium_revision == 0)
191a1cb14f5Sbouyer 			*ihp = BONITO_DIRECT_IRQ(LOONGSON_INTR_PCIA +
192a1cb14f5Sbouyer 			    (pin - 1));
193a1cb14f5Sbouyer 		else
194a1cb14f5Sbouyer 			*ihp = BONITO_DIRECT_IRQ(LOONGSON_INTR_PCIB);
195a1cb14f5Sbouyer 		return 0;
196a1cb14f5Sbouyer 	/* Ethernet */
197a1cb14f5Sbouyer 	case 16:
198a1cb14f5Sbouyer 		*ihp = BONITO_DIRECT_IRQ(LOONGSON_INTR_PCID);
199a1cb14f5Sbouyer 		return 0;
200a1cb14f5Sbouyer 	/* USB, not present in old motherboard revision */
201a1cb14f5Sbouyer 	case 17:
202a1cb14f5Sbouyer 		if (gdium_revision != 0) {
203a1cb14f5Sbouyer 			*ihp = BONITO_DIRECT_IRQ(LOONGSON_INTR_PCIC);
204a1cb14f5Sbouyer 			return 0;
205a1cb14f5Sbouyer 		} else
206a1cb14f5Sbouyer 			break;
207a1cb14f5Sbouyer 	default:
208a1cb14f5Sbouyer 		break;
209a1cb14f5Sbouyer 	}
210a1cb14f5Sbouyer 
211a1cb14f5Sbouyer 	return 1;
212a1cb14f5Sbouyer }
213a1cb14f5Sbouyer 
214a1cb14f5Sbouyer /*
215a1cb14f5Sbouyer  * Due to PMON limitations on the Gdium Liberty, we do not get boot device
216a1cb14f5Sbouyer  * information from PMON.
217a1cb14f5Sbouyer  *
218a1cb14f5Sbouyer  * Because of this, we always pretend the G-Key port is the boot device.
219a1cb14f5Sbouyer  *
220a1cb14f5Sbouyer  * Note that, unlike on the Lemote machines, other USB devices gets a fixed
221a1cb14f5Sbouyer  * numbering (USB0 and USB1).
222a1cb14f5Sbouyer  */
223a1cb14f5Sbouyer 
224a1cb14f5Sbouyer extern struct cfdriver bonito_cd;
225a1cb14f5Sbouyer extern struct cfdriver pci_cd;
226a1cb14f5Sbouyer extern struct cfdriver ehci_cd;
227a1cb14f5Sbouyer extern struct cfdriver usb_cd;
228a1cb14f5Sbouyer extern struct cfdriver uhub_cd;
229a1cb14f5Sbouyer extern struct cfdriver umass_cd;
230a1cb14f5Sbouyer extern struct cfdriver scsibus_cd;
231a1cb14f5Sbouyer extern struct cfdriver sd_cd;
232a1cb14f5Sbouyer 
233a1cb14f5Sbouyer #include <dev/pci/pcivar.h>
234a1cb14f5Sbouyer #include <dev/usb/usb.h>
235a1cb14f5Sbouyer #include <dev/usb/usbdi.h>
236a1cb14f5Sbouyer 
237a1cb14f5Sbouyer void
gdium_device_register(device_t dev,void * aux)2385f819ca3Schs gdium_device_register(device_t dev, void *aux)
239a1cb14f5Sbouyer {
240275299a6Smacallan 	prop_dictionary_t dict;
241a1cb14f5Sbouyer 	static int gkey_chain_pos = 0;
2425f819ca3Schs 	static device_t lastparent = NULL;
243a1cb14f5Sbouyer 
2441c14ae4eSmacallan 	if (device_is_a(dev, "genfb") || device_is_a(dev, "voyagerfb")) {
2451c14ae4eSmacallan 		dict = device_properties(dev);
2461c14ae4eSmacallan 		/*
2471c14ae4eSmacallan 		 * this is a hack
2481c14ae4eSmacallan 		 * is_console needs to be checked against reality
2491c14ae4eSmacallan 		 */
2501c14ae4eSmacallan 		prop_dictionary_set_bool(dict, "is_console", 1);
2511c14ae4eSmacallan 		prop_dictionary_set_uint32(dict, "width", 1024);
2521c14ae4eSmacallan 		prop_dictionary_set_uint32(dict, "height", 600);
2531c14ae4eSmacallan 		prop_dictionary_set_uint32(dict, "depth", 16);
2541c14ae4eSmacallan 		prop_dictionary_set_uint32(dict, "linebytes", 2048);
2551c14ae4eSmacallan 		if (fb_addr != 0)
2561c14ae4eSmacallan 			prop_dictionary_set_uint32(dict, "address", fb_addr);
2571c14ae4eSmacallan 	}
2585f819ca3Schs 	if (device_parent(dev) != lastparent && gkey_chain_pos != 0)
259a1cb14f5Sbouyer 		return;
260a1cb14f5Sbouyer 
261a1cb14f5Sbouyer 	switch (gkey_chain_pos) {
262a1cb14f5Sbouyer 	case 0:	/* bonito at mainbus */
263a1cb14f5Sbouyer 		if (device_is_a(dev, "bonito"))
264a1cb14f5Sbouyer 			goto advance;
265a1cb14f5Sbouyer 		break;
266a1cb14f5Sbouyer 	case 1:	/* pci at bonito */
267a1cb14f5Sbouyer 		if (device_is_a(dev, "pci"))
268a1cb14f5Sbouyer 			goto advance;
269a1cb14f5Sbouyer 		break;
270a1cb14f5Sbouyer 	case 2:	/* ehci at pci dev 15 */
271a1cb14f5Sbouyer 		if (device_is_a(dev, "ehci")) {
272a1cb14f5Sbouyer 			struct pci_attach_args *paa = aux;
273a1cb14f5Sbouyer 			if (paa->pa_device == 15)
274a1cb14f5Sbouyer 				goto advance;
275a1cb14f5Sbouyer 		}
276a1cb14f5Sbouyer 		break;
277a1cb14f5Sbouyer 	case 3:	/* usb at ehci */
278a1cb14f5Sbouyer 		if (device_is_a(dev, "usb"))
279a1cb14f5Sbouyer 			goto advance;
280a1cb14f5Sbouyer 		break;
281a1cb14f5Sbouyer 	case 4:	/* uhub at usb */
282a1cb14f5Sbouyer 		if (device_is_a(dev, "uhub"))
283a1cb14f5Sbouyer 			goto advance;
284a1cb14f5Sbouyer 		break;
285a1cb14f5Sbouyer 	case 5:	/* umass at uhub port 3 */
286a1cb14f5Sbouyer 		if (device_is_a(dev, "umass")) {
287a1cb14f5Sbouyer 			struct usb_attach_arg *uaa = aux;
288*71112a2eSskrll 			if (uaa->uaa_port == 3)
289a1cb14f5Sbouyer 				goto advance;
290a1cb14f5Sbouyer 		}
291a1cb14f5Sbouyer 		break;
292a1cb14f5Sbouyer 	case 6:	/* scsibus at umass */
293a1cb14f5Sbouyer 		if (device_is_a(dev, "scsibus"))
294a1cb14f5Sbouyer 			goto advance;
295a1cb14f5Sbouyer 		break;
296a1cb14f5Sbouyer 	case 7:	/* sd at scsibus */
297a1cb14f5Sbouyer 		if (booted_device == NULL)
298a1cb14f5Sbouyer 			booted_device = dev;
299a1cb14f5Sbouyer 		break;
300a1cb14f5Sbouyer 	}
301a1cb14f5Sbouyer 
302a1cb14f5Sbouyer 	return;
303a1cb14f5Sbouyer 
304a1cb14f5Sbouyer advance:
305a1cb14f5Sbouyer 	gkey_chain_pos++;
306a1cb14f5Sbouyer 	lastparent = dev;
307a1cb14f5Sbouyer }
308a1cb14f5Sbouyer 
309a1cb14f5Sbouyer void
gdium_powerdown(void)310a8f7e8e4Schristos gdium_powerdown(void)
311a1cb14f5Sbouyer {
312a1cb14f5Sbouyer 	REGVAL(BONITO_GPIODATA) |= 0x00000002;
313a1cb14f5Sbouyer 	REGVAL(BONITO_GPIOIE) &= ~0x00000002;
3146d0d64c5Smacallan 	printf("Powering down...\n");
3156d0d64c5Smacallan 	while(1) delay(1000);
316a1cb14f5Sbouyer }
317a1cb14f5Sbouyer 
318a1cb14f5Sbouyer void
gdium_reset(void)319a8f7e8e4Schristos gdium_reset(void)
320a1cb14f5Sbouyer {
321a1cb14f5Sbouyer 	REGVAL(BONITO_GPIODATA) &= ~0x00000002;
322a1cb14f5Sbouyer 	REGVAL(BONITO_GPIOIE) &= ~0x00000002;
323a1cb14f5Sbouyer }
324275299a6Smacallan 
325275299a6Smacallan /*
326275299a6Smacallan  * Early console code
327275299a6Smacallan  */
328275299a6Smacallan 
329275299a6Smacallan int
gdium_cnattach(bus_space_tag_t memt,bus_space_tag_t iot,pci_chipset_tag_t pc,pcitag_t tag,pcireg_t id)330275299a6Smacallan gdium_cnattach(bus_space_tag_t memt, bus_space_tag_t iot,
331275299a6Smacallan     pci_chipset_tag_t pc, pcitag_t tag, pcireg_t id)
332275299a6Smacallan {
333275299a6Smacallan 	struct rasops_info * const ri = &gdium_console_screen.scr_ri;
334275299a6Smacallan 	long defattr;
335275299a6Smacallan 	pcireg_t reg;
336275299a6Smacallan 
337275299a6Smacallan 
338275299a6Smacallan 	/* filter out unrecognized devices */
339275299a6Smacallan 	switch (id) {
340275299a6Smacallan 	default:
341275299a6Smacallan 		return ENODEV;
342275299a6Smacallan 	case PCI_ID_CODE(PCI_VENDOR_SILMOTION, PCI_PRODUCT_SILMOTION_SM502):
343275299a6Smacallan 		break;
344275299a6Smacallan 	}
345275299a6Smacallan 
346275299a6Smacallan 	wsfont_init();
347275299a6Smacallan 
348275299a6Smacallan 	/* set up rasops */
349275299a6Smacallan 	ri->ri_width = 1024;
350275299a6Smacallan 	ri->ri_height = 600;
351275299a6Smacallan 	ri->ri_depth = 16;
352275299a6Smacallan 	ri->ri_stride = 0x800;
353275299a6Smacallan 
354275299a6Smacallan 	/* read the mapping register for the frame buffer */
355275299a6Smacallan 	reg = pci_conf_read(pc, tag, PCI_MAPREG_START);
356275299a6Smacallan 	fb_addr = reg;
357275299a6Smacallan 
358275299a6Smacallan 	ri->ri_bits = (char *)MIPS_PHYS_TO_KSEG1(BONITO_PCILO_BASE + reg);
359275299a6Smacallan 	ri->ri_flg = RI_CENTER | RI_NO_AUTO;
360275299a6Smacallan 
361275299a6Smacallan 	memset(ri->ri_bits, 0, 0x200000);
362275299a6Smacallan 
363275299a6Smacallan 	/* use as much of the screen as the font permits */
364275299a6Smacallan 	rasops_init(ri, 30, 80);
365275299a6Smacallan 
366275299a6Smacallan 	rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight,
367275299a6Smacallan 	    ri->ri_width / ri->ri_font->fontwidth);
368275299a6Smacallan 
369275299a6Smacallan 	gdium_stdscreen.nrows = ri->ri_rows;
370275299a6Smacallan 	gdium_stdscreen.ncols = ri->ri_cols;
371275299a6Smacallan 	gdium_stdscreen.textops = &ri->ri_ops;
372275299a6Smacallan 	gdium_stdscreen.capabilities = ri->ri_caps;
373275299a6Smacallan 
374275299a6Smacallan 	ri->ri_ops.allocattr(ri, 0, ri->ri_rows - 1, 0, &defattr);
375275299a6Smacallan 
376275299a6Smacallan 	wsdisplay_preattach(&gdium_stdscreen, ri, 0, 0, defattr);
377275299a6Smacallan 
378275299a6Smacallan 	return 0;
379275299a6Smacallan 
380275299a6Smacallan }
381