Add basic PCI support for amiga port.

Add missing bus_space(9) methods needed for MI PCI.
Add p5pb(4) - Phase5 PCI bridge driver (and the man page).
Add quirks table to zbus(4) - needed for p5pb.
Change approved by phx.
This commit is contained in:
rkujawa 2011-08-04 17:48:50 +00:00
parent 8919910c3e
commit f02273fb5e
16 changed files with 1192 additions and 71 deletions

View File

@ -1,11 +1,11 @@
# from: @(#)Makefile 8.2 (Berkeley) 2/16/94
# $NetBSD: Makefile,v 1.17 2011/01/14 10:25:14 phx Exp $
# $NetBSD: Makefile,v 1.18 2011/08/04 17:48:50 rkujawa Exp $
MAN= afsc.4 ahsc.4 amidisplaycc.4 atzsc.4 autoconf.4 console.4 bah.4 \
bppcsc.4 ed.4 es.4 fdc.4 grf.4 \
grfcl.4 grfcv.4 grfcv3d.4 grfet.4 grfrh.4 grfrt.4 grful.4 \
gtsc.4 intro.4 ite.4 mem.4 mfcs.4 mgnsc.4 qn.4 ser.4 \
wesc.4 zssc.4
gtsc.4 intro.4 ite.4 mem.4 mfcs.4 mgnsc.4 p5pb.4 \
qn.4 ser.4 wesc.4 zssc.4
MLINKS= mem.4 kmem.4
MANSUBDIR=/amiga

View File

@ -0,0 +1,80 @@
.\" $NetBSD: p5pb.4,v 1.1 2011/08/04 17:48:50 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.
.\"
.Dd July 26, 2011
.Dt P5PB 4 amiga
.Os
.Sh NAME
.Nm p5pb
.Nd Phase5 PCI bridge driver
.Sh SYNOPSIS
.Cd "p5pb0 at zbus0"
.Cd "pci* at p5pb?"
.Cd "genfb* at pci?"
.Sh DESCRIPTION
The
.Nm
driver provides support for the PCI bus present on BlizzardVisionPPC and
CyberVisionPPC graphics cards.
.Sh HARDWARE
The
.Nm
driver supports the following hardware:
.Bl -tag -width "BLIZZARDVISIONPPC" -offset indent
.It Em BLIZZARDVISIONPPC
Phase5 BlizzardVisionPPC graphics card.
.El
.Bl -tag -width "BLIZZARDVISIONPPC" -offset indent
.It Em CYBERVISIONPPC
Phase5 CyberVisionPPC graphics card.
.El
.Sh SEE ALSO
.Xr pm2fb 4 ,
.Xr genfb 4 ,
.Xr pci 4
.Sh HISTORY
The
.Nm
device first appeared in
.Nx 6.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Radoslaw Kujawa Aq radoslaw.kujawa@gmail.com .
.Sh BUGS
Current version of this driver depends on PCI bus setup and enumeration
done by the firmware.
.Pp
The driver will not attach at all, if there is no AutoConfig entry
for CVPPC/BVPPC card (Zorro product ID 110). Some firmware revisions
are known not to create this entry.
.Pp
It is not (yet) possible to use the CVPPC/BVPPC as a console.

View File

@ -1,4 +1,4 @@
/* $NetBSD: amiga_bus_simple_1word.c,v 1.3 2008/04/28 20:23:12 martin Exp $ */
/* $NetBSD: amiga_bus_simple_1word.c,v 1.4 2011/08/04 17:48:50 rkujawa Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -28,11 +28,202 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <machine/cpu.h>
#include <machine/pte.h>
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: amiga_bus_simple_1word.c,v 1.3 2008/04/28 20:23:12 martin Exp $");
__KERNEL_RCSID(1, "$NetBSD: amiga_bus_simple_1word.c,v 1.4 2011/08/04 17:48:50 rkujawa Exp $");
#define AMIGA_SIMPLE_BUS_STRIDE 1 /* 1 byte per word */
#define AMIGA_SIMPLE_BUS_STRIDE 1 /* 1 byte per byte */
#define AMIGA_SIMPLE_BUS_WORD_METHODS
#define AMIGA_SIMPLE_BUS_LONGWORD_METHODS
#include "simple_busfuncs.c"
bsr(oabs(bsr4_swap_), u_int32_t);
bsw(oabs(bsw4_swap_), u_int32_t);
bsrm(oabs(bsrm2_swap_), u_int16_t);
bswm(oabs(bswm2_swap_), u_int16_t);
int oabs(bsm_absolute_)(bus_space_tag_t, bus_addr_t, bus_size_t, int,
bus_space_handle_t *);
/* ARGSUSED */
int
oabs(bsm_absolute_)(tag, address, size, flags, handlep)
bus_space_tag_t tag;
bus_addr_t address;
bus_size_t size;
int flags;
bus_space_handle_t *handlep;
{
uint32_t pa = kvtop((void*) tag->base);
*handlep = tag->base + (address - pa) * AMIGA_SIMPLE_BUS_STRIDE;
return 0;
}
/* ARGSUSED */
u_int32_t
oabs(bsr4_swap_)(handle, offset)
bus_space_handle_t handle;
bus_size_t offset;
{
volatile u_int32_t *p;
u_int32_t x;
p = (volatile u_int32_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
x = *p;
amiga_bus_reorder_protect();
return bswap32(x);
}
/* ARGSUSED */
void
oabs(bsw4_swap_)(handle, offset, value)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
{
volatile u_int32_t *p;
p = (volatile u_int32_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
*p = bswap32( (u_int32_t)value );
amiga_bus_reorder_protect();
}
/* ARGSUSED */
void
oabs(bsrm2_swap_)(bus_space_handle_t handle, bus_size_t offset,
u_int16_t *pointer, bus_size_t count)
{
volatile u_int16_t *p;
p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = bswap16(*p);
amiga_bus_reorder_protect();
--count;
}
}
/* ARGSUSED */
void
oabs(bswm2_swap_)(bus_space_handle_t handle, bus_size_t offset,
const u_int16_t *pointer, bus_size_t count)
{
volatile u_int16_t *p;
p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*p = bswap16(*pointer);
amiga_bus_reorder_protect();
++pointer;
--count;
}
}
const struct amiga_bus_space_methods amiga_bus_stride_1swap_abs = {
oabs(bsm_absolute_),
oabs(bsms_),
oabs(bsu_),
0,
0,
oabs(bsr1_),
oabs(bsw1_),
oabs(bsrm1_),
oabs(bswm1_),
oabs(bsrr1_),
oabs(bswr1_),
oabs(bssr1_),
oabs(bscr1_),
oabs(bsr2_), /* XXX swap? */
oabs(bsw2_), /* XXX swap? */
oabs(bsr2_),
oabs(bsw2_),
oabs(bsrm2_swap_),
oabs(bswm2_swap_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrr2_), /* XXX swap? */
oabs(bswr2_), /* XXX swap? */
oabs(bsrr2_),
oabs(bswr2_),
oabs(bssr2_), /* XXX swap? */
oabs(bscr2_), /* XXX swap? */
oabs(bsr4_swap_),
oabs(bsw4_swap_),
oabs(bsr4_),
oabs(bsw4_),
oabs(bsrm4_), /* XXX swap? */
oabs(bswm4_), /* XXX swap? */
oabs(bsrm4_),
oabs(bswm4_),
oabs(bsrr4_), /* XXX swap? */
oabs(bswr4_), /* XXX swap? */
oabs(bsrr4_),
oabs(bswr4_),
oabs(bssr4_), /* XXX swap? */
oabs(bscr4_) /* XXX swap? */
};
const struct amiga_bus_space_methods amiga_bus_stride_1swap = {
oabs(bsm_),
oabs(bsms_),
oabs(bsu_),
0,
0,
oabs(bsr1_),
oabs(bsw1_),
oabs(bsrm1_),
oabs(bswm1_),
oabs(bsrr1_),
oabs(bswr1_),
oabs(bssr1_),
oabs(bscr1_),
oabs(bsr2_), /* XXX swap? */
oabs(bsw2_), /* XXX swap? */
oabs(bsr2_),
oabs(bsw2_),
oabs(bsrm2_swap_),
oabs(bswm2_swap_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrr2_), /* XXX swap? */
oabs(bswr2_), /* XXX swap? */
oabs(bsrr2_),
oabs(bswr2_),
oabs(bssr2_), /* XXX swap? */
oabs(bscr2_), /* XXX swap? */
oabs(bsr4_swap_),
oabs(bsw4_swap_),
oabs(bsr4_),
oabs(bsw4_),
oabs(bsrm4_), /* XXX swap? */
oabs(bswm4_), /* XXX swap? */
oabs(bsrm4_),
oabs(bswm4_),
oabs(bsrr4_), /* XXX swap? */
oabs(bswr4_), /* XXX swap? */
oabs(bsrr4_),
oabs(bswr4_),
oabs(bssr4_), /* XXX swap? */
oabs(bscr4_) /* XXX swap? */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.107 2011/06/03 00:52:22 matt Exp $ */
/* $NetBSD: autoconf.c,v 1.108 2011/08/04 17:48:50 rkujawa Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.107 2011/06/03 00:52:22 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.108 2011/08/04 17:48:50 rkujawa Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -49,6 +49,9 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.107 2011/06/03 00:52:22 matt Exp $");
#ifdef DRACO
#include <amiga/amiga/drcustom.h>
#endif
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
static void findroot(void);
void mbattach(device_t, device_t, void *);
@ -579,3 +582,56 @@ is_a600()
return (1); /* It's an A600 */
return (0); /* Machine type not set */
}
void
device_register(device_t dev, void *aux)
{
prop_dictionary_t dict, parent_dict;
struct pci_attach_args *pa = aux;
if (device_parent(dev) && device_is_a(device_parent(dev), "pci")) {
dict = device_properties(dev);
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY) {
/* Handle CVPPC/BVPPC card. */
if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_TI)
&& (PCI_PRODUCT(pa->pa_id) ==
PCI_PRODUCT_TI_TVP4020) ) {
/*
* PCI bridge knows the properties,
* PCI device doesn't - let's copy
* them.
*/
parent_dict = device_properties(
device_parent(device_parent(dev)));
prop_dictionary_set(dict, "width",
prop_dictionary_get(parent_dict, "width"));
prop_dictionary_set(dict, "height",
prop_dictionary_get(parent_dict, "height"));
prop_dictionary_set(dict, "depth",
prop_dictionary_get(parent_dict, "depth"));
prop_dictionary_set(dict, "linebytes",
prop_dictionary_get(parent_dict,
"linebytes"));
prop_dictionary_set(dict, "address",
prop_dictionary_get(parent_dict,
"address"));
#if (NGENFB > 0)
prop_dictionary_set(dict, "virtual_address",
prop_dictionary_get(parent_dict,
"virtual_address"));
#endif
}
}
}
}

View File

@ -0,0 +1,66 @@
/* $NetBSD: bus.c,v 1.1 2011/08/04 17:48:50 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.
*/
/* See simple_busfuncs.c for implementation of bus_space_read/write. */
#include <sys/param.h>
#include <sys/bus.h>
void
bus_space_barrier(bus_space_tag_t space, bus_space_handle_t handle,
bus_size_t offset, bus_size_t length, int flags)
{
/* Only amigappc needs barrier. */
#if defined(__powerpc__)
asm volatile("eieio");
#endif
}
paddr_t
bus_space_mmap(bus_space_tag_t t, bus_addr_t addr, off_t off, int prot,
int flags)
{
#if defined(__m68k__)
return m68k_btop(addr + off);
#else
return -1; /* FIXME */
#endif
}
void *
bus_space_vaddr(bus_space_tag_t space, bus_space_handle_t handle)
{
void* va;
va = (void*) handle;
return va;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: simple_busfuncs.c,v 1.7 2011/07/19 15:55:26 dyoung Exp $ */
/* $NetBSD: simple_busfuncs.c,v 1.8 2011/08/04 17:48:50 rkujawa Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: simple_busfuncs.c,v 1.7 2011/07/19 15:55:26 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: simple_busfuncs.c,v 1.8 2011/08/04 17:48:50 rkujawa Exp $");
/*
* Do NOT use this standalone.
@ -399,6 +399,160 @@ oabs(bscr2_)(handlefrom, from, handleto, to, count)
}
#endif /* AMIGA_SIMPLE_BUS_WORD_METHODS */
#ifdef AMIGA_SIMPLE_BUS_LONGWORD_METHODS
/* longword methods */
bsr (oabs(bsr4_), u_int32_t);
bsw (oabs(bsw4_), u_int32_t);
bsrm(oabs(bsrm4_), u_int32_t);
bswm(oabs(bswm4_), u_int32_t);
bsrm(oabs(bsrr4_), u_int32_t);
bswm(oabs(bswr4_), u_int32_t);
bssr(oabs(bssr4_), u_int32_t);
bscr(oabs(bscr4_), u_int32_t);
u_int32_t
oabs(bsr4_)(handle, offset)
bus_space_handle_t handle;
bus_size_t offset;
{
u_int32_t *p;
u_int32_t x;
p = (u_int32_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
x = *p;
amiga_bus_reorder_protect();
return x;
}
void
oabs(bsw4_)(handle, offset, value)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
{
u_int32_t *p;
p = (u_int32_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
*p = (u_int32_t)value;
amiga_bus_reorder_protect();
}
void
oabs(bsrm4_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
u_int32_t *pointer;
bus_size_t count;
{
volatile u_int32_t *p;
p = (volatile u_int32_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = *p;
amiga_bus_reorder_protect();
--count;
}
}
void
oabs(bswm4_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
const u_int32_t *pointer;
bus_size_t count;
{
volatile u_int32_t *p;
p = (volatile u_int32_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*p = *pointer++;
amiga_bus_reorder_protect();
--count;
}
}
void
oabs(bsrr4_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
u_int32_t *pointer;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*pointer++ = *(volatile u_int32_t *)p;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int32_t);
--count;
}
}
void
oabs(bswr4_)(handle, offset, pointer, count)
bus_space_handle_t handle;
bus_size_t offset;
const u_int32_t *pointer;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int32_t *)p = *pointer++;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int32_t);
--count;
}
}
void
oabs(bssr4_)(handle, offset, value, count)
bus_space_handle_t handle;
bus_size_t offset;
unsigned value;
bus_size_t count;
{
volatile u_int8_t *p;
p = (volatile u_int8_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int32_t *)p = (unsigned)value;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int32_t);
--count;
}
}
void
oabs(bscr4_)(handlefrom, from, handleto, to, count)
bus_space_handle_t handlefrom, handleto;
bus_size_t from, to;
bus_size_t count;
{
volatile u_int8_t *p, *q;
p = (volatile u_int8_t *)(handlefrom + from * AMIGA_SIMPLE_BUS_STRIDE);
q = (volatile u_int8_t *)(handleto + to * AMIGA_SIMPLE_BUS_STRIDE);
while (count > 0) {
*(volatile u_int32_t *)q = *(volatile u_int32_t *)p;
amiga_bus_reorder_protect();
p += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int32_t);
q += AMIGA_SIMPLE_BUS_STRIDE * sizeof(u_int32_t);
--count;
}
}
#endif /* AMIGA_SIMPLE_BUS_LONGWORD_METHODS */
#ifndef AMIGA_SIMPLE_BUS_NO_ARRAY
/* method array */
@ -421,22 +575,42 @@ const struct amiga_bus_space_methods oabs(amiga_bus_stride_) = {
oabs(bscr1_),
#ifdef AMIGA_SIMPLE_BUS_WORD_METHODS
oabs(bsr2_),
oabs(bsw2_),
oabs(bsr2_),
oabs(bsw2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bssr2_),
oabs(bscr2_)
oabs(bsr2_),
oabs(bsw2_),
oabs(bsr2_),
oabs(bsw2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrm2_),
oabs(bswm2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bsrr2_),
oabs(bswr2_),
oabs(bssr2_),
oabs(bscr2_),
#else /* AMIGA_SIMPLE_BUS_WORD_METHODS */
0
0,
#endif /* AMIGA_SIMPLE_BUS_WORD_METHODS */
#ifdef AMIGA_SIMPLE_BUS_LONGWORD_METHODS
oabs(bsr4_),
oabs(bsw4_),
oabs(bsr4_),
oabs(bsw4_),
oabs(bsrm4_),
oabs(bswm4_),
oabs(bsrm4_),
oabs(bswm4_),
oabs(bsrr4_),
oabs(bswr4_),
oabs(bsrr4_),
oabs(bswr4_),
oabs(bssr4_),
oabs(bscr4_)
#else /* AMIGA_SIMPLE_BUS_LONGWORD_METHODS */
0
#endif /* AMIGA_SIMPLE_BUS_LONGWORD_METHODS */
};
#endif

View File

@ -1,9 +1,9 @@
# $NetBSD: DRACO,v 1.139 2011/07/01 15:46:30 rkujawa Exp $
# $NetBSD: DRACO,v 1.140 2011/08/04 17:48:50 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.80 2011/07/01 13:30:18 rkujawa Exp $
# Created from: # NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 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.139 $"
#ident "GENERIC-$Revision: 1.140 $"
maxusers 8

View File

@ -1,9 +1,9 @@
# $NetBSD: GENERIC,v 1.269 2011/07/01 15:46:30 rkujawa Exp $
# $NetBSD: GENERIC,v 1.270 2011/08/04 17:48:51 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.80 2011/07/01 13:30:18 rkujawa Exp $
# Created from: # NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 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.269 $"
#ident "GENERIC-$Revision: 1.270 $"
maxusers 8
@ -463,6 +463,12 @@ ch* at scsibus? target ? lun ? # scsi autochangers
ss* at scsibus? target ? lun ? # scsi scanner
uk* at scsibus? target ? lun ? # scsi unknown
# PCI bus support
options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
# Bluetooth Controller and Device support
# tested only with btuart on an A1200

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 rkujawa Exp $
# $NetBSD: GENERIC.in,v 1.82 2011/08/04 17:48:51 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.81 $"
#ident "GENERIC-$Revision: 1.82 $"
m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
makeoptions COPTS="-Os"
@ -570,6 +570,12 @@ uk* at scsibus? target ? lun ? # scsi unknown
')m4_dnl
m4_ifdef(`AMIGA_CONFIGURATION', `m4_dnl
# PCI bus support
options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
# Bluetooth Controller and Device support
# tested only with btuart on an A1200

View File

@ -1,9 +1,9 @@
# $NetBSD: INSTALL,v 1.91 2011/07/01 15:46:30 rkujawa Exp $
# $NetBSD: INSTALL,v 1.92 2011/08/04 17:48:51 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.80 2011/07/01 13:30:18 rkujawa Exp $
# Created from: # NetBSD: GENERIC.in,v 1.81 2011/07/01 15:46:30 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.91 $"
#ident "GENERIC-$Revision: 1.92 $"
makeoptions COPTS="-Os"
@ -407,6 +407,12 @@ st* at scsibus? target ? lun ? # scsi tapes
cd* at scsibus? target ? lun ? # scsi cds
ch* at scsibus? target ? lun ? # scsi autochangers
# PCI bus support
options PCIVERBOSE # verbose PCI device autoconfig messages
#options PCI_CONFIG_DUMP
p5pb0 at zbus0 # Phase5 PCI bridge (CVPPC/BVPPC)
pci* at p5pb0
# Bluetooth Controller and Device support
# tested only with btuart on an A1200

View File

@ -1,4 +1,4 @@
# $NetBSD: files.amiga,v 1.145 2011/07/01 13:30:18 rkujawa Exp $
# $NetBSD: files.amiga,v 1.146 2011/08/04 17:48:51 rkujawa Exp $
# maxpartitions must be first item in files.${ARCH}.newconf
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
@ -42,7 +42,6 @@ device cpu
attach cpu at mainbus
# for bus_space
define amibus_bl
file arch/amiga/amiga/amiga_bus_simple_4.c
@ -58,6 +57,8 @@ file arch/amiga/amiga/amiga_bus_simple_16.c amibus_b16
define amibus_b800
file arch/amiga/amiga/amiga_bus_simple_0x800.c amibus_b800
file arch/amiga/amiga/bus.c
# zorro expansion bus.
device zbus {}
attach zbus at mainbus
@ -492,4 +493,15 @@ include "compat/ossaudio/files.ossaudio"
# Bluetooth stack
include "dev/bluetooth/files.bluetooth"
include "arch/amiga/conf/majors.amiga"
# PCI bus
file arch/amiga/pci/p5pb.c pci
device p5pb: pcibus
attach p5pb at zbus
include "dev/i2o/files.i2o"
include "dev/pci/files.pci"
#include "dev/wsfb/files.wsfb"
include "arch/amiga/conf/majors.amiga"

View File

@ -1,4 +1,4 @@
/* $NetBSD: zbus.c,v 1.63 2011/06/03 00:52:22 matt Exp $ */
/* $NetBSD: zbus.c,v 1.64 2011/08/04 17:48:51 rkujawa Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -31,11 +31,12 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.63 2011/06/03 00:52:22 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.64 2011/08/04 17:48:51 rkujawa Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <machine/cpu.h>
#include <machine/pte.h>
@ -55,6 +56,12 @@ struct preconfdata {
void *vaddr;
};
struct quirksdata {
int manid;
int prodid;
uint8_t quirks;
};
vaddr_t ZTWOROMADDR;
vaddr_t ZTWOMEMADDR;
u_int NZTWOMEMPG;
@ -148,6 +155,8 @@ static const struct aconfdata aconftab[] = {
{ "grfcv", 8512, 34}, /* CyberVison 64 */
{ "grfcv3d", 8512, 67}, /* CyberVison 64/3D */
{ "cbiiisc", 8512, 100}, /* Cyberstorm Mk III SCSI */
{ "p5pb", 8512, 101}, /* CyberVisionPPC / BlizzardVisionPPC */
{ "bppcsc", 8512, 110}, /* Blizzard 603e+ SCSI */
/* Hacker Inc. */
{ "mlhsc", 2011, 1 },
/* Resource Management Force */
@ -217,13 +226,36 @@ static struct preconfdata preconftab[] = {
};
static int npreconfent = sizeof(preconftab) / sizeof(struct preconfdata);
/*
* Quirks table.
*/
#define ZORRO_QUIRK_NO_ZBUSMAP 1 /* Don't map VA=PA in zbusattach. */
static struct quirksdata quirkstab[] = {
{8512, 101, ZORRO_QUIRK_NO_ZBUSMAP}
};
static int nquirksent = sizeof(quirkstab) / sizeof(struct quirksdata);
void zbusattach(device_t, device_t, void *);
int zbusprint(void *, const char *);
int zbusmatch(device_t, cfdata_t, void *);
void *zbusmap(void *, u_int);
static const char *aconflookup(int, int);
/*
* given a manufacturer id and product id, find quirks
* for this board.
*/
static uint8_t
quirkslookup(int mid, int pid)
{
const struct quirksdata *qdp, *eqdp;
eqdp = &quirkstab[nquirksent];
for (qdp = quirkstab; qdp < eqdp; qdp++)
if (qdp->manid == mid && qdp->prodid == pid)
return(qdp->quirks);
return(0);
}
/*
* given a manufacturer id and product id, find the name
* that describes this board.
@ -306,10 +338,11 @@ zbusattach(device_t pdp, device_t dp, void *auxp)
if (amiga_realconfig && pcp < epcp && pcp->vaddr)
za.va = pcp->vaddr;
else {
za.va = (void *) (isztwopa(za.pa) ?
__UNVOLATILE(ztwomap(za.pa)) :
zbusmap(za.pa, za.size));
/* ??????? */
if(quirkslookup(za.manid, za.prodid) !=
ZORRO_QUIRK_NO_ZBUSMAP)
za.va = (void *) (isztwopa(za.pa) ?
__UNVOLATILE(ztwomap(za.pa)) :
zbusmap(za.pa, za.size));
/*
* save value if early console init
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.23 2010/02/03 13:56:53 phx Exp $ */
/* $NetBSD: bus.h,v 1.24 2011/08/04 17:48:51 rkujawa Exp $ */
/*
* Copyright (c) 1996 Leo Weppelman. All rights reserved.
@ -125,7 +125,23 @@ struct amiga_bus_space_methods {
bssr(*bssr2, u_int16_t);
bscr(*bscr2, u_int16_t);
/* add 32bit methods here */
/* 32bit methods */
bsr(*bsr4, u_int32_t);
bsw(*bsw4, u_int32_t);
bsr(*bsrs4, u_int32_t);
bsw(*bsws4, u_int32_t);
bsrm(*bsrm4, u_int32_t);
bswm(*bswm4, u_int32_t);
bsrm(*bsrms4, u_int32_t);
bswm(*bswms4, u_int32_t);
bsrm(*bsrr4, u_int32_t);
bswm(*bswr4, u_int32_t);
bsrm(*bsrrs4, u_int32_t);
bswm(*bswrs4, u_int32_t);
bssr(*bssr4, u_int32_t);
bscr(*bscr4, u_int32_t);
};
/*
@ -196,37 +212,33 @@ struct amiga_bus_space_methods {
#define bus_space_set_region_2(t, h, o, v, c) dbss(bssr2, t, h, o, v, c)
#define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c)
/* 4: Fake 32-bit macros */
/* 4: long-wide "functions" */
#define bus_space_read_4(t, h, o) \
(panic("bus_space_read_4 not implemented"), 0)
#define bus_space_read_4(t, h, o) dbsdr(bsr4, t, h, o)
#define bus_space_write_4(t, h, o, v) dbsdw(bsw4, t, h, o, v)
#define bus_space_read_stream_4(t, h, o) dbsdr(bsrs4, t, h, o)
#define bus_space_write_stream_4(t, h, o, v) dbsdw(bsws4, t, h, o, v)
#define bus_space_write_4(t, h, o, v) \
panic("bus_space_write_4 not implemented")
#define bus_space_read_stream_4(t, h, o) \
(panic("bus_space_read_stream_4 not implemented"), 0)
#define bus_space_write_stream_4(t, h, o, v) \
panic("bus_space_read_stream_4 not implemented")
#define bus_space_read_multi_4(t, h, o, p, c) \
panic("bus_space_read_multi_4 not implemented")
#define bus_space_write_multi_4(t, h, o, p, c) \
panic("bus_space_write_multi_4 not implemented")
#define bus_space_read_multi_4(t, h, o, p, c) dbsm(bsrm4, t, h, o, p, c)
#define bus_space_write_multi_4(t, h, o, p, c) dbsm(bswm4, t, h, o, p, c)
#define bus_space_read_multi_stream_4(t, h, o, p, c) \
panic("bus_space_read_multi_stream_4 not implemented")
dbsm(bsrms4, t, h, o, p, c)
#define bus_space_write_multi_stream_4(t, h, o, p, c) \
panic("bus_space_write_multi_stream_4 not implemented")
dbsm(bswms4, t, h, o, p, c)
#define bus_space_read_region_4(t, h, o, p, c) dbsm(bsrr4, t, h, o, p, c)
#define bus_space_write_region_4(t, h, o, p, c) dbsm(bswr4, t, h, o, p, c)
#define bus_space_read_region_stream_4(t, h, o, p, c) \
panic("bus_space_read_region_stream_4 not implemented")
dbsm(bsrrs4, t, h, o, p, c)
#define bus_space_write_region_stream_4(t, h, o, p, c) \
panic("bus_space_write_region_stream_4 not implemented")
dbsm(bswrs4, t, h, o, p, c)
#define bus_space_set_region_4(t, h, o, v, c) dbss(bssr4, t, h, o, v, c)
#define bus_space_copy_region_4(t, h, o, g, q, c) dbss(bscr4, t, h, o, g, q, c)
/*
* Bus read/write barrier methods.
@ -238,8 +250,9 @@ struct amiga_bus_space_methods {
* Note: the 680x0 does not currently require barriers, but we must
* provide the flags to MI code.
*/
#define bus_space_barrier(t, h, o, l, f) \
((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
void bus_space_barrier(bus_space_tag_t space, bus_space_handle_t handle,
bus_size_t offset, bus_size_t length, int flags);
#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
@ -247,13 +260,27 @@ struct amiga_bus_space_methods {
#define __BUS_SPACE_HAS_STREAM_METHODS
paddr_t bus_space_mmap(bus_space_tag_t t, bus_addr_t addr, off_t off, int prot,
int flags);
#define BUS_SPACE_MAP_CACHEABLE 0x01
#define BUS_SPACE_MAP_LINEAR 0x02
#define BUS_SPACE_MAP_PREFETCHABLE 0x04
/* Instruction for enforcing reorder protection. Nothing for 68k. */
#define amiga_bus_reorder_protect()
void * bus_space_vaddr(bus_space_tag_t space, bus_space_handle_t handle);
extern const struct amiga_bus_space_methods amiga_bus_stride_1;
extern const struct amiga_bus_space_methods amiga_bus_stride_1swap;
extern const struct amiga_bus_space_methods amiga_bus_stride_1swap_abs;
extern const struct amiga_bus_space_methods amiga_bus_stride_2;
extern const struct amiga_bus_space_methods amiga_bus_stride_4;
extern const struct amiga_bus_space_methods amiga_bus_stride_4swap;
extern const struct amiga_bus_space_methods amiga_bus_stride_16;
void *zbusmap(void *pa, u_int size);
#endif /* _AMIGA_BUS_H_ */

View File

@ -0,0 +1,112 @@
/* $NetBSD: pci_machdep.h,v 1.1 2011/08/04 17:48:51 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.
*/
#ifndef _AMIGA_PCI_MACHDEP_H_
#define _AMIGA_PCI_MACHDEP_H_
#include <sys/bus.h>
#include <machine/intr.h>
#include <m68k/bus_dma.h>
/*
* Forward declarations.
*/
struct pci_attach_args;
/*
* Types provided to machine-independent PCI code
*/
typedef struct amiga_pci_chipset *pci_chipset_tag_t;
typedef u_long pcitag_t;
typedef u_long pci_intr_handle_t;
/*
* amiga-specific PCI structure and type definitions.
* NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
*/
struct amiga_pci_chipset {
void *pc_conf_v;
void (*pc_attach_hook)(device_t, device_t,
struct pcibus_attach_args *);
int (*pc_bus_maxdevs)(pci_chipset_tag_t, int);
pcitag_t (*pc_make_tag)(pci_chipset_tag_t, int, int, int);
void (*pc_decompose_tag)(pci_chipset_tag_t, pcitag_t, int *,
int *, int *);
pcireg_t(*pc_conf_read)(pci_chipset_tag_t, pcitag_t,
int);
void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int,
pcireg_t);
int (*pc_intr_map)(const struct pci_attach_args *,
pci_intr_handle_t *);
const char *(*pc_intr_string)(pci_chipset_tag_t,
pci_intr_handle_t);
void *(*pc_intr_establish)(pci_chipset_tag_t,
pci_intr_handle_t, int, int (*) (void *), void *);
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;
};
/*
* Functions provided to machine-independent PCI code.
*/
#define pci_attach_hook(p, s, pba) \
(*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
#define pci_bus_maxdevs(c, b) \
(*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
#define pci_make_tag(c, b, d, f) \
(*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
#define pci_decompose_tag(c, t, bp, dp, fp) \
(*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
#define pci_conf_read(c, t, r) \
(*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
#define pci_conf_write(c, t, r, v) \
(*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
#define pci_intr_map(pa, ihp) \
(*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
#define pci_intr_string(c, ih) \
(*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
#define pci_intr_evcnt(c, ih) \
(*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
#define pci_intr_establish(c, ih, l, h, a) \
(*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
#define pci_intr_disestablish(c, iv) \
(*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
#endif

281
sys/arch/amiga/pci/p5pb.c Normal file
View File

@ -0,0 +1,281 @@
/* $NetBSD: p5pb.c,v 1.1 2011/08/04 17:48:51 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.
*/
#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 <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/p5pbreg.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_P5 8512
#define ZORRO_PRODID_BPPC 110 /* BlizzardPPC */
#define ZORRO_PRODID_CSPPC 100 /* CyberStormPPC */
#define ZORRO_PRODID_P5PB 101 /* CVPPC/BVPPC (/G-REX?) */
/* Initial resolution as configured by the firmware */
#define P5GFX_WIDTH 640
#define P5GFX_HEIGHT 480
#define P5GFX_DEPTH 8
#define P5GFX_LINEBYTES 640
struct p5pb_softc {
device_t sc_dev;
struct bus_space_tag pci_conf_area;
struct bus_space_tag pci_mem_area;
struct amiga_pci_chipset apc;
};
static int p5pb_match(struct device *, struct cfdata *, void *);
static void p5pb_attach(struct device *, struct device *, void *);
void p5pb_set_props(struct p5pb_softc *sc);
pcireg_t p5pb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
void p5pb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
int p5pb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno);
int p5pb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, int func, pcireg_t id);
void p5pb_pci_attach_hook (struct device *parent, struct device *self, struct pcibus_attach_args *pba);
pcitag_t p5pb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function);
void p5pb_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp);
CFATTACH_DECL_NEW(p5pb, sizeof(struct p5pb_softc),
p5pb_match, p5pb_attach, NULL, NULL);
static int p5pb_present = 0;
static int
p5pb_match(device_t parent, cfdata_t cf, void *aux)
{
struct zbus_args *zap;
zap = aux;
if (zap->manid != ZORRO_MANID_P5)
return 0;
if (zap->prodid != ZORRO_PRODID_P5PB)
return 0;
#ifdef P5PB_DEBUG
aprint_normal("p5pb matched by Zorro ID %d, %d\n", zap->manid,
zap->prodid);
#endif
if (p5pb_present)
return 0; /* Allow only one. */
#ifdef I_HAVE_P5PB_REALLY
/*
* At least some firmware versions do not create AutoConfig entries for
* CyberVisionPPC/BlizzardVisionPPC (product ID 0101). There's no "nice"
* way to detect the PCI bus in this case. At least check for CSPPC/BPPC.
*/
if (zap->prodid = !(ZORRO_PRODID_BPPC || ZORRO_PRODID_CSPPC)) {
if (!p5pb_present) {
p5pb_present = 1;
return 100; /* XXX: This will break SCSI! */
}
}
#endif
p5pb_present = 1;
return 1;
}
static void
p5pb_attach(device_t parent, device_t self, void *aux)
{
struct p5pb_softc *sc = device_private(self);
struct pcibus_attach_args pba;
pci_chipset_tag_t pc = &sc->apc;
sc->sc_dev = self;
aprint_normal(": Phase5 CVPPC/BVPPC PCI bridge\n");
/* Setup bus space mappings. */
sc->pci_conf_area.base = (bus_addr_t) zbusmap(
(void *) P5BUS_PCI_CONF_BASE, P5BUS_PCI_CONF_SIZE);
sc->pci_conf_area.absm = &amiga_bus_stride_1;
sc->pci_mem_area.base = (bus_addr_t) zbusmap(
(void *) P5BUS_PCI_MEM_BASE, P5BUS_PCI_MEM_SIZE);
sc->pci_mem_area.absm = &amiga_bus_stride_1swap_abs;
#ifdef P5PB_DEBUG
aprint_normal("p5pb mapped %x -> %x, %x -> %x\n",
P5BUS_PCI_CONF_BASE, sc->pci_conf_area.base,
P5BUS_PCI_MEM_BASE, sc->pci_mem_area.base );
#endif
sc->apc.pci_conf_iot = &(sc->pci_conf_area);
if (bus_space_map(sc->apc.pci_conf_iot, OFF_PCI_CONF_DATA,
256, 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 = p5pb_pci_bus_maxdevs;
sc->apc.pc_make_tag = p5pb_pci_make_tag;
sc->apc.pc_decompose_tag = p5pb_pci_decompose_tag;
sc->apc.pc_conf_read = p5pb_pci_conf_read;
sc->apc.pc_conf_write = p5pb_pci_conf_write;
sc->apc.pc_attach_hook = p5pb_pci_attach_hook;
pba.pba_iot = NULL;
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;
pba.pba_bus = 0;
pba.pba_bridgetag = NULL;
p5pb_set_props(sc);
config_found_ia(self, "pcibus", &pba, pcibusprint);
}
/*
* Set properties needed to support fb driver. These are read later during
* autoconfg in device_register().
*/
void
p5pb_set_props(struct p5pb_softc *sc)
{
prop_dictionary_t dict;
device_t dev;
dev = sc->sc_dev;
dict = device_properties(dev);
prop_dictionary_set_uint32(dict, "width", P5GFX_WIDTH);
prop_dictionary_set_uint32(dict, "height", P5GFX_HEIGHT);
prop_dictionary_set_uint8(dict, "depth", P5GFX_DEPTH);
prop_dictionary_set_uint16(dict, "linebytes", P5GFX_LINEBYTES);
prop_dictionary_set_uint64(dict, "address", P5BUS_PCI_MEM_BASE);
#if (NGENFB > 0)
/*
* Framebuffer starts at P5BUS_PCI_MEM_BASE, but genfb needs virtual
* address.
*/
prop_dictionary_set_uint64(dict, "virtual_address",
sc->pci_mem_area.base);
#endif
}
pcireg_t
p5pb_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,
(func<<5) + reg);
#ifdef P5PB_DEBUG
aprint_normal("p5pb 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
p5pb_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,
(func << 5) + reg, val);
#ifdef P5PB_DEBUG
aprint_normal("p5pb 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
p5pb_pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
{
/* Allow only one device. Obvious in case of CVPPC/BVPPC. */
return 1;
}
pcitag_t
p5pb_pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
{
return (bus << 16) | (device << 11) | (function << 8);
}
void
p5pb_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
p5pb_pci_attach_hook(struct device *parent, struct device *self,
struct pcibus_attach_args *pba)
{
}

View File

@ -0,0 +1,71 @@
/* $NetBSD: p5pbreg.h,v 1.1 2011/08/04 17:48:51 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.
*/
/*
* Reverse engineered Phase5 PCI bridge memory map (firmware 44.71):
*
* 0xFFFA0000 - (unknown)
* 0xFFFC0000 - PCI configuration mechanism #1 data, 128KB
* 0xFFFE0000 - PCI configuration mechanism #1 address, 4KB
*
* 0xE0000000 - Permedia RAM on CVPPC/BVPPC (1st aperture), 8MB
* 0xE0800000 - Permedia RAM on CVPPC/BVPPC (2nd aperture), 8MB
* 0xE1000000 - Permedia registers, 128KB
*
* Note: this map may not look the same for every firmware revision.
*
* The bridge is probably capable of DMA and interrupts, but this would
* need further reverse engineering, and is not really needed to drive
* the Permedia 2 chip.
*/
#ifndef _AMIGA_P5PBREG_H_
#define P5BUS_PCI_CONF_BASE 0xFFFA0000
#define P5BUS_PCI_CONF_SIZE 0x00041000
#define P5BUS_PCI_MEM_BASE 0xE0000000
#define P5BUS_PCI_MEM_SIZE 0x01010000 /* actually 0x01020000 */
#define OFF_PCI_CONF_DATA 0x00020000
#define OFF_PCI_CONF_ADDR 0x00040000
#define P5BUS_CONF_ENDIAN 0x0000 /* PCI_CONF_ADDR + offset */
#define P5BUS_CONF_ENDIAN_BIG 0x02 /* to switch into BE mode */
#define P5BUS_CONF_INTR 0x0010 /* ? XXX interrupt enable? */
#define P5BUS_CONF_INTR_INT2 0x01 /* ? XXX INT2? */
/* typical configuration of Permedia 2 on CVPPC/BVPPC */
#define OFF_P2_APERTURE_1 0x0
#define OFF_P2_APERTURE_2 0x00800000
#define OFF_P2_REGS 0x01000000
/* #define OFF_P2_REGS 0x0F000000 */ /* ? alt. Permedia regs */
#endif /* _AMIGA_P5PBREG_H_ */