add glue for igsfb at ofbus

This commit is contained in:
macallan 2006-12-07 03:10:14 +00:00
parent a5acac5748
commit 0e7f627c30
5 changed files with 326 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.shark,v 1.11 2006/09/13 07:14:35 gdamore Exp $
# $NetBSD: files.shark,v 1.12 2006/12/07 03:10:14 macallan Exp $
#
# First try for arm-specific configuration info
#
@ -135,6 +135,10 @@ file arch/shark/shark/pccons.c pc needs-flag
attach vga at ofbus with vga_ofbus
file arch/shark/ofw/vga_ofbus.c vga_ofbus needs-flag
# ofbus CyberPro
attach igsfb at ofbus with igsfb_ofbus
file arch/shark/ofw/igsfb_ofbus.c igsfb_ofbus needs-flag
# Smart Card Reader
device scr: tty
file arch/shark/shark/scr.c scr needs-flag

View File

@ -1,4 +1,4 @@
/* $NetBSD: isa_io.c,v 1.6 2005/12/11 12:19:02 christos Exp $ */
/* $NetBSD: isa_io.c,v 1.7 2006/12/07 03:10:14 macallan Exp $ */
/*
* Copyright 1997
@ -38,13 +38,20 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: isa_io.c,v 1.6 2005/12/11 12:19:02 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: isa_io.c,v 1.7 2006/12/07 03:10:14 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <machine/pio.h>
#include <machine/isa_machdep.h>
#include <machine/ofw.h>
#include "igsfb_ofbus.h"
#if NIGSFB_OFBUS > 0
extern vaddr_t igsfb_mem_vaddr, igsfb_mmio_vaddr;
extern paddr_t igsfb_mem_paddr;
#endif
/* Proto types for all the bus_space structure functions */
@ -78,7 +85,7 @@ struct bus_space isa_io_bs_tag = {
isa_bs_vaddr,
/* mmap bus space for userland */
bs_notimpl_bs_mmap, /* XXX possible even? XXX */
isa_bs_mmap,
/* barrier */
isa_bs_barrier,
@ -159,7 +166,7 @@ struct bus_space isa_mem_bs_tag = {
isa_bs_vaddr,
/* mmap bus space for userland */
bs_notimpl_bs_mmap, /* XXX open for now ... XXX */
isa_bs_mmap,
/* barrier */
isa_bs_barrier,
@ -268,6 +275,35 @@ isa_bs_unmap(t, bsh, size)
/* Nothing to do. */
}
paddr_t
isa_bs_mmap(void *cookie, bus_addr_t addr, off_t off, int prot,
int flags)
{
paddr_t paddr, ret;
#ifdef OFISA_DEBUG
printf("mmap %08x %08x %08x", (uint32_t)cookie, (uint32_t)addr, (uint32_t)off);
#endif
#if NIGSFB_OFBUS > 0
if ((vaddr_t)cookie == igsfb_mem_vaddr) {
paddr = igsfb_mem_paddr;
} else
#endif
paddr = ofw_gettranslation((vaddr_t)cookie);
if (paddr == -1) {
#ifdef OFISA_DEBUG
printf(" no translation\n");
#endif
return -1;
}
ret = paddr + addr + off;
#ifdef OFISA_DEBUG
printf(" -> %08x %08x\n", (uint32_t)paddr, (uint32_t)ret);
#endif
return arm_btop(ret);
}
int
isa_bs_subregion(t, bsh, offset, size, nbshp)
void *t;

View File

@ -0,0 +1,224 @@
/* $NetBSD: igsfb_ofbus.c,v 1.1 2006/12/07 03:10:14 macallan Exp $ */
/*
* Copyright (c) 2006 Michael Lorenz
* All rights reserved.
*
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* 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.
*/
/*
* Integraphics Systems IGA 168x and CyberPro series.
* ofbus attachment for Valeriy E. Ushakov's igsfb driver
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: igsfb_ofbus.c,v 1.1 2006/12/07 03:10:14 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <machine/bus.h>
#include <machine/intr.h>
#include <machine/ofw.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcidevs.h>
#include <dev/isa/isavar.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
#include <dev/rasops/rasops.h>
#include <dev/wscons/wsdisplay_vconsvar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ic/igsfbreg.h>
#include <dev/ic/igsfbvar.h>
#include "igsfb_ofbusvar.h"
static int igsfb_ofbus_is_console(int);
static int igsfb_ofbus_console = 0;
static int igsfb_ofbus_phandle = 0;
static int igsfb_ofbus_match(struct device *, struct cfdata *, void *);
static void igsfb_ofbus_attach(struct device *, struct device *, void *);
static int igsfb_setup_dc(struct igsfb_devconfig *);
CFATTACH_DECL(igsfb_ofbus, sizeof(struct igsfb_softc),
igsfb_ofbus_match, igsfb_ofbus_attach, NULL, NULL);
static const char *compat_strings[] = { "igs,cyperpro2010", 0 };
vaddr_t igsfb_mem_vaddr = 0, igsfb_mmio_vaddr = 0;
paddr_t igsfb_mem_paddr;
struct bus_space igsfb_memt, igsfb_iot;
int
igsfb_ofbus_cnattach(bus_space_tag_t iot, bus_space_tag_t memt)
{
struct igsfb_devconfig *dc;
int ret;
int chosen_phandle, igs_node;
int stdout_ihandle, stdout_phandle;
uint32_t regs[16];
stdout_phandle = 0;
/* first find out if there's a CyberPro at all in this machine */
if ((igs_node = OF_finddevice("/vlbus/display")) == -1)
return ENXIO;
if (of_compatible(igs_node, compat_strings) < 0)
return ENXIO;
/*
* now we know there's a CyberPro in this machine so map it into
* kernel space, even if it's not the console
*/
if (OF_getprop(igs_node, "reg", regs, sizeof(regs)) <= 0)
return ENXIO;
igsfb_mem_paddr = be32toh(regs[13]);
/* 4MB VRAM */
igsfb_mem_vaddr = ofw_map(igsfb_mem_paddr, 0x00400000, 0);
/* MMIO registers */
igsfb_mmio_vaddr = ofw_map(igsfb_mem_paddr + IGS_MEM_MMIO_SELECT,
0x00100000, 0);
memcpy(&igsfb_memt, memt, sizeof(struct bus_space));
igsfb_memt.bs_cookie = (void *)igsfb_mem_vaddr;
memcpy(&igsfb_iot, memt, sizeof(struct bus_space));
igsfb_iot.bs_cookie = (void *)igsfb_mmio_vaddr;
/*
* check if the firmware output device is indeed the CyberPro
*/
if ((chosen_phandle = OF_finddevice("/chosen")) == -1 ||
OF_getprop(chosen_phandle, "stdout", &stdout_ihandle,
sizeof(stdout_ihandle)) != sizeof(stdout_ihandle)) {
return ENXIO;
}
stdout_ihandle = of_decode_int((unsigned char *)&stdout_ihandle);
stdout_phandle = OF_instance_to_package(stdout_ihandle);
if (stdout_phandle != igs_node)
return ENXIO;
/* ok, now setup and attach the console */
dc = &igsfb_console_dc;
ret = igsfb_setup_dc(dc);
if (ret)
return ret;
ret = igsfb_cnattach_subr(dc);
if (ret)
return ret;
igsfb_ofbus_console = 1;
igsfb_ofbus_phandle = stdout_phandle;
return 0;
}
static int
igsfb_setup_dc(struct igsfb_devconfig *dc)
{
int ret;
dc->dc_id = PCI_PRODUCT_INTEGRAPHICS_CYBERPRO2010;
dc->dc_memt = &igsfb_memt;
dc->dc_memaddr = 0;
dc->dc_memsz= 0x00400000;
dc->dc_memflags = PCI_MAPREG_TYPE_MEM;
dc->dc_iot = &igsfb_iot;
dc->dc_iobase = 0;
dc->dc_ioflags = 0;
if (bus_space_map(dc->dc_iot,
dc->dc_iobase + IGS_REG_BASE, IGS_REG_SIZE,
dc->dc_ioflags,
&dc->dc_ioh) != 0)
{
printf("unable to map I/O registers\n");
return 1;
}
ret = igsfb_enable(dc->dc_iot, dc->dc_iobase, dc->dc_ioflags);
if (ret)
return ret;
return 0;
}
static int
igsfb_ofbus_is_console(int phandle)
{
return igsfb_ofbus_console && (phandle == igsfb_ofbus_phandle);
}
static int
igsfb_ofbus_match(struct device *parent, struct cfdata *match, void *aux)
{
struct ofbus_attach_args *oba = aux;
if (of_compatible(oba->oba_phandle, compat_strings) == -1)
return (0);
return 10; /* beat vga etc. */
}
static void
igsfb_ofbus_attach(struct device *parent, struct device *self, void *aux)
{
struct igsfb_softc *sc = (struct igsfb_softc *)self;
struct ofbus_attach_args *oba = aux;
uint32_t regs[16];
int isconsole, ret;
OF_getprop(oba->oba_phandle, "reg", regs, sizeof(regs));
isconsole = 0;
if (igsfb_ofbus_is_console(oba->oba_phandle)) {
sc->sc_dc = &igsfb_console_dc;
isconsole = 1;
} else {
sc->sc_dc = malloc(sizeof(struct igsfb_devconfig),
M_DEVBUF, M_NOWAIT | M_ZERO);
if (sc->sc_dc == NULL)
panic("unable to allocate igsfb_devconfig");
if (OF_getprop(oba->oba_phandle, "reg", regs, sizeof(regs)) <= 0) {
printf("Can't read 'reg' property\n");
return;
}
ret = igsfb_setup_dc(sc->sc_dc);
if (ret)
return;
}
printf(": IGS CyberPro 2010 at 0x%08x\n", (uint32_t)igsfb_mem_paddr);
igsfb_attach_subr(sc, isconsole);
}

View File

@ -0,0 +1,40 @@
/* $NetBSD: igsfb_ofbusvar.h,v 1.1 2006/12/07 03:10:14 macallan Exp $ */
/*
* Copyright (c) 2006 Michael Lorenz
* All rights reserved.
*
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* 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.
*/
/*
* Integraphics Systems IGA 168x and CyberPro series.
* ofbus attachment for Valeriy E. Ushakov's igsfb driver
*/
#ifndef _DEV_OFBUS_IGSFB_PCIVAR_H_
#define _DEV_OFBUS_IGSFB_PCIVAR_H_
extern int
igsfb_ofbus_cnattach(bus_space_tag_t, bus_space_tag_t);
#endif /* _DEV_OFBUS_IGSFB_PCIVAR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: consinit.c,v 1.4 2005/12/11 12:19:05 christos Exp $ */
/* $NetBSD: consinit.c,v 1.5 2006/12/07 03:10:14 macallan Exp $ */
/*
* Copyright (c) 1998
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.4 2005/12/11 12:19:05 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.5 2006/12/07 03:10:14 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -77,6 +77,9 @@ cons_decl(ofcons_)
static struct consdev ofcons = cons_init(ofcons_);
#endif
#include "igsfb_ofbus.h"
#include <shark/ofw/igsfb_ofbusvar.h>
#if (NCOM > 0)
#ifndef CONADDR
#define CONADDR 0x3f8
@ -111,7 +114,16 @@ consinit()
cp = NULL;
if (!comconsole) {
#if (NPC > 0) || (NVGA > 0)
#if (NPC > 0) || (NVGA > 0) || (NIGSFB_OFBUS > 0)
#if (NIGSFB_OFBUS > 0)
if (!igsfb_ofbus_cnattach(&isa_io_bs_tag, &isa_mem_bs_tag)) {
#if (NPCKBC > 0)
pckbc_cnattach(&isa_io_bs_tag, IO_KBD, KBCMDP,
PCKBC_KBD_SLOT);
#endif /* NPCKBC */
return;
}
#endif /* NIGSFB_OFBUS */
#if (NVGA_OFBUS > 0)
if (!vga_ofbus_cnattach(&isa_io_bs_tag, &isa_mem_bs_tag)) {
#if (NPCKBC > 0)