Add driver for Prometheus PCI bridge.

Change approved by phx.
This commit is contained in:
rkujawa 2011-09-17 16:55:34 +00:00
parent fb9e5ffdea
commit 7f06d42d8f
9 changed files with 386 additions and 18 deletions

View File

@ -1,9 +1,9 @@
# $NetBSD: DRACO,v 1.140 2011/08/04 17:48:50 rkujawa Exp $
# $NetBSD: DRACO,v 1.141 2011/09/17 16:55:34 rkujawa Exp $
#
# This file was automatically created.
# Changes will be lost when make is run in this directory.
#
# Created from: # NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 rkujawa Exp $
# Created from: # NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
#
##
# GENERIC machine description file
@ -29,7 +29,7 @@ include "arch/amiga/conf/std.amiga"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.140 $"
#ident "GENERIC-$Revision: 1.141 $"
maxusers 8

View File

@ -1,9 +1,9 @@
# $NetBSD: GENERIC,v 1.270 2011/08/04 17:48:51 rkujawa Exp $
# $NetBSD: GENERIC,v 1.271 2011/09/17 16:55:34 rkujawa Exp $
#
# This file was automatically created.
# Changes will be lost when make is run in this directory.
#
# Created from: # NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 rkujawa Exp $
# Created from: # NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
#
##
# GENERIC machine description file
@ -29,7 +29,7 @@ include "arch/amiga/conf/std.amiga"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.270 $"
#ident "GENERIC-$Revision: 1.271 $"
maxusers 8
@ -468,6 +468,10 @@ options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
pci* at mppb?
ne* at pci? # NE2000 Ethernet
# Bluetooth Controller and Device support
# tested only with btuart on an A1200

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
# $NetBSD: GENERIC.in,v 1.83 2011/09/17 16:55:34 rkujawa Exp $
#
##
# GENERIC machine description file
@ -57,7 +57,7 @@ include "arch/amiga/conf/std.amiga"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.82 $"
#ident "GENERIC-$Revision: 1.83 $"
m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
makeoptions COPTS="-Os"
@ -575,6 +575,10 @@ options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
pci* at mppb?
ne* at pci? # NE2000 Ethernet
# Bluetooth Controller and Device support
# tested only with btuart on an A1200

View File

@ -1,9 +1,9 @@
# $NetBSD: INSTALL,v 1.92 2011/08/04 17:48:51 rkujawa Exp $
# $NetBSD: INSTALL,v 1.93 2011/09/17 16:55:34 rkujawa Exp $
#
# This file was automatically created.
# Changes will be lost when make is run in this directory.
#
# Created from: # NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 rkujawa Exp $
# Created from: # NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 rkujawa Exp $
#
##
# GENERIC machine description file
@ -29,7 +29,7 @@ include "arch/amiga/conf/std.amiga"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.92 $"
#ident "GENERIC-$Revision: 1.93 $"
makeoptions COPTS="-Os"
@ -412,6 +412,10 @@ options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
mppb* at zbus0 # Matay Prometheus Zorro-PCI bridge
pci* at mppb?
ne* at pci? # NE2000 Ethernet
# Bluetooth Controller and Device support
# tested only with btuart on an A1200

View File

@ -1,4 +1,4 @@
# $NetBSD: files.amiga,v 1.146 2011/08/04 17:48:51 rkujawa Exp $
# $NetBSD: files.amiga,v 1.147 2011/09/17 16:55:34 rkujawa Exp $
# maxpartitions must be first item in files.${ARCH}.newconf
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
@ -495,10 +495,14 @@ include "dev/bluetooth/files.bluetooth"
# PCI bus
file arch/amiga/pci/p5pb.c pci
file arch/amiga/pci/mppb.c pci
device p5pb: pcibus
attach p5pb at zbus
device mppb: pcibus
attach mppb at zbus
include "dev/i2o/files.i2o"
include "dev/pci/files.pci"
#include "dev/wsfb/files.wsfb"

View File

@ -1,4 +1,4 @@
/* $NetBSD: zbus.c,v 1.64 2011/08/04 17:48:51 rkujawa Exp $ */
/* $NetBSD: zbus.c,v 1.65 2011/09/17 16:55:34 rkujawa Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.64 2011/08/04 17:48:51 rkujawa Exp $");
__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.65 2011/09/17 16:55:34 rkujawa Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -189,7 +189,7 @@ static const struct aconfdata aconftab[] = {
{ "hyper4+", 5001, 6}, /* Hypercom4+ */
{ "hyper3+", 5001, 7}, /* Hypercom3+ */
/* Matay Grzegorz Kraszewski */
{ "Prometheus", 44359, 1} /* Prometheus PCI bridge */
{ "mppb", 44359, 1} /* Prometheus PCI bridge */
};
static int naconfent = sizeof(aconftab) / sizeof(struct aconfdata);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_machdep.h,v 1.1 2011/08/04 17:48:51 rkujawa Exp $ */
/* $NetBSD: pci_machdep.h,v 1.2 2011/09/17 16:55:34 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@ -66,6 +66,9 @@ struct amiga_pci_chipset {
int);
void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int,
pcireg_t);
int (*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
pcireg_t);
void *pc_intr_v;
int (*pc_intr_map)(const struct pci_attach_args *,
pci_intr_handle_t *);
const char *(*pc_intr_string)(pci_chipset_tag_t,
@ -75,8 +78,6 @@ struct amiga_pci_chipset {
void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
void (*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int,
int, int *);
int (*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
pcireg_t);
bus_space_tag_t pci_conf_iot;
bus_space_handle_t pci_conf_ioh;

299
sys/arch/amiga/pci/mppb.c Normal file
View File

@ -0,0 +1,299 @@
/* $NetBSD: mppb.c,v 1.1 2011/09/17 16:55:34 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Radoslaw Kujawa.
*
* 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
/* Matay Prometheus Zorro-PCI bridge driver. */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/extent.h>
#include <sys/kmem.h>
#include <uvm/uvm_extern.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <m68k/bus_dma.h>
#include <amiga/dev/zbusvar.h>
#include <amiga/pci/mppbreg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pciconf.h>
/* Zorro IDs */
#define ZORRO_MANID_MATAY 44359
#define ZORRO_PRODID_PROMETHEUS 1
struct mppb_softc {
device_t sc_dev;
volatile char *ba;
struct bus_space_tag pci_conf_area;
struct bus_space_tag pci_io_area;
struct bus_space_tag pci_mem_area;
struct amiga_pci_chipset apc;
};
static int mppb_match(struct device *, struct cfdata *, void *);
static void mppb_attach(struct device *, struct device *, void *);
pcireg_t mppb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
void mppb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
int mppb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno);
int mppb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev,
int func, pcireg_t id);
void mppb_pci_attach_hook (struct device *parent,
struct device *self, struct pcibus_attach_args *pba);
pcitag_t mppb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device,
int function);
void mppb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag,
int *bp, int *dp, int *fp);
void * mppb_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t
ih, int level, int (*ih_fun)(void *), void *ih_arg);
void mppb_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie);
int mppb_pci_intr_map(const struct pci_attach_args *pa,
pci_intr_handle_t *ihp);
const char * mppb_pci_intr_string(pci_chipset_tag_t pc,
pci_intr_handle_t ih);
const struct evcnt * mppb_pci_intr_evcnt(pci_chipset_tag_t pc,
pci_intr_handle_t ih);
CFATTACH_DECL_NEW(mppb, sizeof(struct mppb_softc),
mppb_match, mppb_attach, NULL, NULL);
static int
mppb_match(device_t parent, cfdata_t cf, void *aux)
{
struct zbus_args *zap;
zap = aux;
if (zap->manid != ZORRO_MANID_MATAY)
return 0;
if (zap->prodid != ZORRO_PRODID_PROMETHEUS)
return 0;
#ifdef MPPB_DEBUG
aprint_normal("mppb matched by Zorro ID %d, %d\n", zap->manid,
zap->prodid);
#endif
return 1;
}
static void
mppb_attach(device_t parent, device_t self, void *aux)
{
struct mppb_softc *sc;
struct pcibus_attach_args pba;
struct zbus_args *zap;
pci_chipset_tag_t pc;
zap = aux;
sc = device_private(self);
pc = &sc->apc;
sc->sc_dev = self;
sc->ba = zap->va;
aprint_normal(": Matay Prometheus PCI bridge\n");
/* Setup bus space mappings. */
sc->pci_conf_area.base = (bus_addr_t) sc->ba + MPPB_CONF_BASE;
sc->pci_conf_area.absm = &amiga_bus_stride_1swap;
sc->pci_mem_area.base = (bus_addr_t) sc->ba + MPPB_MEM_BASE;
sc->pci_mem_area.absm = &amiga_bus_stride_1;
sc->pci_io_area.base = (bus_addr_t) sc->ba + MPPB_IO_BASE;
sc->pci_io_area.absm = &amiga_bus_stride_1;
#ifdef MPPB_DEBUG
aprint_normal("mppb mapped conf %x->%x, mem %x->%x\n, io %x->%x",
(zap->pa) + MPPB_CONF_BASE, sc->pci_conf_area.base,
(zap->pa) + MPPB_MEM_BASE, sc->pci_mem_area.base,
(zap->pa) + MPPB_IO_BASE, sc->pci_io_area.base);
#endif
sc->apc.pci_conf_iot = &(sc->pci_conf_area);
if (bus_space_map(sc->apc.pci_conf_iot, 0, MPPB_CONF_SIZE, 0,
&sc->apc.pci_conf_ioh))
aprint_error_dev(self,
"couldn't map PCI configuration data space\n");
/* Initialize the PCI chipset tag. */
sc->apc.pc_conf_v = (void*) pc;
sc->apc.pc_bus_maxdevs = mppb_pci_bus_maxdevs;
sc->apc.pc_make_tag = mppb_pci_make_tag;
sc->apc.pc_decompose_tag = mppb_pci_decompose_tag;
sc->apc.pc_conf_read = mppb_pci_conf_read;
sc->apc.pc_conf_write = mppb_pci_conf_write;
sc->apc.pc_attach_hook = mppb_pci_attach_hook;
sc->apc.pc_intr_map = mppb_pci_intr_map;
sc->apc.pc_intr_string = mppb_pci_intr_string;
sc->apc.pc_intr_establish = mppb_pci_intr_establish;
sc->apc.pc_intr_disestablish = mppb_pci_intr_disestablish;
/* XXX: pc_conf_interrupt */
pba.pba_iot = &(sc->pci_io_area);
pba.pba_memt = &(sc->pci_mem_area);
pba.pba_dmat = NULL;
pba.pba_dmat64 = NULL;
pba.pba_pc = pc;
pba.pba_flags = PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY;
pba.pba_bus = 0;
pba.pba_bridgetag = NULL;
config_found_ia(self, "pcibus", &pba, pcibusprint);
}
pcireg_t
mppb_pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
{
uint32_t data;
uint32_t bus, dev, func;
pci_decompose_tag(pc, tag, &bus, &dev, &func);
data = bus_space_read_4(pc->pci_conf_iot, pc->pci_conf_ioh,
(MPPB_CONF_STRIDE*dev) + reg);
#ifdef MPPB_DEBUG
aprint_normal("mppb conf read va: %lx, bus: %d, dev: %d, "
"func: %d, reg: %d -r-> data %x\n",
pc->pci_conf_ioh, bus, dev, func, reg, data);
#endif
return data;
}
void
mppb_pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t val)
{
uint32_t bus, dev, func;
pci_decompose_tag(pc, tag, &bus, &dev, &func);
bus_space_write_4(pc->pci_conf_iot, pc->pci_conf_ioh,
(MPPB_CONF_STRIDE*dev) + reg, val);
#ifdef MPPB_DEBUG
aprint_normal("mppb conf write va: %lx, bus: %d, dev: %d, "
"func: %d, reg: %d -w-> data %x\n",
pc->pci_conf_ioh, bus, dev, func, reg, val);
#endif
}
int
mppb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
{
return 4; /* Prometheus has 4 slots */
}
pcitag_t
mppb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
{
return (bus << 16) | (device << 11) | (function << 8);
}
void
mppb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp,
int *dp, int *fp)
{
if (bp != NULL)
*bp = (tag >> 16) & 0xff;
if (dp != NULL)
*dp = (tag >> 11) & 0x1f;
if (fp != NULL)
*fp = (tag >> 8) & 0x07;
}
void
mppb_pci_attach_hook(struct device *parent, struct device *self,
struct pcibus_attach_args *pba)
{
}
void *
mppb_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
int (*ih_fun)(void *), void *ih_arg)
{
struct isr* pci_isr;
pci_isr = kmem_zalloc(sizeof(struct isr), KM_SLEEP);
/* TODO: check for bogus handle */
pci_isr->isr_intr = ih_fun;
pci_isr->isr_arg = ih_arg;
pci_isr->isr_ipl = MPPB_INT;
add_isr(pci_isr);
return pci_isr;
}
void
mppb_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
{
remove_isr(cookie);
kmem_free(cookie, sizeof(struct isr));
}
int
mppb_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
/* TODO: add sanity checking */
*ihp = MPPB_INT;
return 0;
}
const char *
mppb_pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
{
static char str[10];
sprintf(str, "INT%d", (int) ih);
return str;
}
const struct evcnt *
mppb_pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
{
/* TODO: implement */
return NULL;
}

View File

@ -0,0 +1,52 @@
/* $NetBSD: mppbreg.h,v 1.1 2011/09/17 16:55:34 rkujawa Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Radoslaw Kujawa.
*
* 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
/*
* Prometheus PCI spaces. All base addresses are relative to the card's
* address.
*/
#ifndef _AMIGA_MPPBREG_H_
#define MPPB_CONF_BASE 0x000F0000
#define MPPB_CONF_SIZE 0x000060FF
#define MPPB_CONF_STRIDE 0x00002000 /* 0x2000 per slot */
#define MPPB_IO_BASE 0x00000000
#define MPPB_IO_SIZE 0x000EFFFF
#define MPPB_MEM_BASE 0x00100000
#define MPPB_MEM_SIZE 0x1FEFFFFF
/* All PCI interrupt lines are wired to INT2 */
#define MPPB_INT 2
#endif /* _AMIGA_MPPBREG_H_ */