sti(4) on hp300

KIYOHARA Takashi <[email protected]> Fri, 28 Dec 2012 18:44:38 +0900 (JST)
Newsgroups gmane.os.netbsd.ports.hp700,gmane.os.netbsd.ports.hp300
Message-ID <[email protected]>
----Next_Part(Fri_Dec_28_18_44_38_2012_136)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi! all,


My 425t has a sti(4).  Its works on 6.0 with attached sti_sgc.c and diff.
I can login on ttyE0.  However not support console yet.  X-<

# Sorry, forgot saves /var/run/dmesg.boot...

Thanks,
--
kiyohara

----Next_Part(Fri_Dec_28_18_44_38_2012_136)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="sti_sgc.c-6.0"

/*	$OpenBSD: sti_sgc.c,v 1.14 2007/05/26 00:36:03 krw Exp $	*/

/*
 * Copyright (c) 2005, Miodrag Vallat
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD");

#include <sys/param.h>
#include <sys/device.h>
#include <sys/errno.h>

#include <uvm/uvm_extern.h>

#include <machine/bus.h>

#include <hp300/dev/sgcvar.h>

#include <dev/wscons/wsdisplayvar.h>

#include <dev/ic/stireg.h>
#include <dev/ic/stivar.h>


static int sticonslot;


static int sti_sgc_match(device_t, struct cfdata *, void *);
static void sti_sgc_attach(device_t, device_t, void *);

static int sti_sgc_probe(bus_space_tag_t, int);
static void sti_sgc_end_attach(device_t);

CFATTACH_DECL_NEW(sti_sgc, sizeof(struct sti_softc),
    sti_sgc_match, sti_sgc_attach, NULL, NULL);



static int
sti_sgc_match(device_t parent, struct cfdata *cf, void *aux)
{
	struct sgc_attach_args *saa = aux;

	/*
	 * If we already probed it successfully as a console device, go ahead,
	 * since we will not be able to bus_space_map() again.
	 */
	if (saa->saa_slot == sticonslot)
		return (1);

	return sti_sgc_probe(saa->saa_iot, saa->saa_slot);
}

static void
sti_sgc_attach(device_t parent, device_t self, void *aux)
{
	struct sti_softc *sc = device_private(self);
	struct sgc_attach_args *saa = aux;
	bus_space_tag_t iot = saa->saa_iot;
	bus_space_handle_t ioh, romh;
	bus_addr_t pa = (bus_addr_t)sgc_slottopa(saa->saa_slot);
	u_int romend;
	int i;

	/* XXX: temporalily map before obtain romend. */
#define STI_ROMSIZE_SAFE	(sizeof(struct sti_dd) * 4)
	if (bus_space_map(iot, pa, STI_ROMSIZE_SAFE, 0, &ioh)) {
		aprint_error(": can't map ROM");
		return;
	}
	romend = sti_rom_size(iot, ioh);
	bus_space_unmap(iot, ioh, STI_ROMSIZE_SAFE);

	sc->sc_dev = self;
	sc->sc_enable_rom = NULL;
	sc->sc_disable_rom = NULL;

	if (bus_space_map(iot, pa, romend, 0, &romh)) {
		aprint_error(": can't map ROM(2)");
		return;
	}
	sc->bases[0] = romh;
	for (i = 0; i < STI_REGION_MAX; i++)
		sc->bases[i] = pa;
	if (saa->saa_slot == sticonslot)
		sc->sc_flags |= STI_CONSOLE;
	if (sti_attach_common(sc, iot, iot, romh, STI_CODEBASE_ALT) == 0)
		config_interrupts(self, sti_sgc_end_attach);
}

static int
sti_sgc_probe(bus_space_tag_t iot, int slot)
{
	bus_space_handle_t ioh;
	bus_addr_t pa = (bus_addr_t)sgc_slottopa(slot);
	int devtype;

	if (bus_space_map(iot, pa, PAGE_SIZE, 0, &ioh))
		return 0;
	devtype = bus_space_read_1(iot, ioh, 3);
	bus_space_unmap(iot, ioh, PAGE_SIZE);

	/*
	 * This might not be reliable enough. On the other hand, non-STI
	 * SGC cards will apparently not initialize in an hp300, to the
	 * point of not even answering bus probes (checked with an
	 * Harmony/FDDI SGC card).
	 */
	if (devtype != STI_DEVTYPE1 &&
	    devtype != STI_DEVTYPE4)
		return 0;
	return 1;
}

static void
sti_sgc_end_attach(device_t self)
{
	struct sti_softc *sc = device_private(self);

	sti_end_attach(sc);
}

----Next_Part(Fri_Dec_28_18_44_38_2012_136)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="hp300-sti-6.0.diff"

? dev/sti_sgc.c
Index: conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/conf/GENERIC,v
retrieving revision 1.169
diff -u -r1.169 GENERIC
--- conf/GENERIC	18 Dec 2011 05:49:27 -0000	1.169
+++ conf/GENERIC	28 Dec 2012 00:40:21 -0000
@@ -195,7 +195,7 @@
 
 intio0		at mainbus0		# internal i/o space
 dio0		at mainbus0		# DIO/DIO-II bus
-#sgc0		at mainbus0		# SGC bus
+sgc0		at mainbus0		# SGC bus
 
 # Human Interface Loop devices
 hil0		at intio?		# HIL controller
@@ -241,8 +241,8 @@
 gendiofb*	at dio? scode ?		# dumb framebuffer support for 362/382
 wsdisplay*	at gendiofb?
 
-#sti*		at sgc?	slot ?		# SGC EVRX framebuffers
-#wsdisplay*	at sti?
+sti*		at sgc?	slot ?		# SGC EVRX framebuffers
+wsdisplay*	at sti?
 
 com0		at dio0 scode 9		# DCA serial interfaces
 com*		at dio? scode ?
Index: hp300/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/autoconf.c,v
retrieving revision 1.99.2.1
diff -u -r1.99.2.1 autoconf.c
--- hp300/autoconf.c	8 Aug 2012 15:51:05 -0000	1.99.2.1
+++ hp300/autoconf.c	28 Dec 2012 00:40:23 -0000
@@ -773,6 +773,8 @@
 		return;
 #endif
 
+#if (NDVBOX + NGBOX + NRBOX + NTOPCAT + NDVBOX + NGBOX + NHYPER + NRBOX + \
+     NTOPCAT + NTVRX + NGENDIOFB) > 0
 #ifndef CONSCODE
 	/*
 	 * Look for internal framebuffers.
@@ -828,6 +830,7 @@
 #endif
 
 find_kbd:
+#endif
 
 #if NDNKBD > 0
 	dnkbdcnattach(bst, FRODO_BASE + FRODO_APCI_OFFSET(0))

----Next_Part(Fri_Dec_28_18_44_38_2012_136)----