1997-01-04 02:30:30 +03:00
|
|
|
/* $NetBSD: podulebus.c,v 1.18 1997/01/03 23:30:30 mark Exp $ */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
/*
|
1996-11-23 06:42:39 +03:00
|
|
|
* Copyright (c) 1994-1996 Mark Brinicombe.
|
1996-02-01 02:24:54 +03:00
|
|
|
* Copyright (c) 1994 Brini.
|
|
|
|
* 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. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Brini.
|
|
|
|
* 4. The name of the company nor the name of the author may be used to
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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.
|
|
|
|
*
|
|
|
|
* RiscBSD kernel project
|
|
|
|
*
|
|
|
|
* podulebus.c
|
|
|
|
*
|
|
|
|
* Podule probe and configuration routines
|
|
|
|
*
|
|
|
|
* Created : 07/11/94
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <machine/io.h>
|
1996-08-21 23:46:47 +04:00
|
|
|
#include <machine/iomd.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
#include <machine/katelib.h>
|
|
|
|
#include <machine/irqhandler.h>
|
|
|
|
#include <arm32/podulebus/podulebus.h>
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
#include <arm32/podulebus/podules.h>
|
|
|
|
#include <arm32/podulebus/podule_data.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
/* Array of podule structures, one per possible podule */
|
|
|
|
|
|
|
|
podule_t podules[MAX_PODULES + MAX_NETSLOTS];
|
|
|
|
irqhandler_t poduleirq;
|
|
|
|
extern u_int actual_mask;
|
|
|
|
extern irqhandler_t *irqhandlers[NIRQS];
|
|
|
|
|
|
|
|
/* Declare prototypes */
|
|
|
|
|
|
|
|
void map_section __P((vm_offset_t, vm_offset_t, vm_offset_t));
|
|
|
|
int poduleirqhandler __P((void));
|
1996-10-15 03:26:48 +04:00
|
|
|
u_int poduleread __P((u_int address, int offset, int slottype));
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* int podulebusmatch(struct device *parent, void *match, void *aux)
|
|
|
|
*
|
|
|
|
* Probe for the podule bus. Currently all this does is return 1 to
|
|
|
|
* indicate that the podule bus was found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
podulebusmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
1996-11-23 06:42:39 +03:00
|
|
|
switch (IOMD_ID) {
|
|
|
|
case RPC600_IOMD_ID:
|
|
|
|
case ARM7500_IOC_ID:
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
return (0);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
1996-04-27 02:32:36 +04:00
|
|
|
podulebusprint(aux, name)
|
1996-02-01 02:24:54 +03:00
|
|
|
void *aux;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *name;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
|
|
|
struct podule_attach_args *pa = aux;
|
|
|
|
|
1996-04-27 02:32:36 +04:00
|
|
|
if (name) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("podule%d: ", pa->pa_podule_number);
|
1996-04-27 02:32:36 +04:00
|
|
|
return(UNCONF);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
1996-04-27 02:32:36 +04:00
|
|
|
if (pa->pa_podule->slottype == SLOT_POD)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(" [ podule %d ]:", pa->pa_podule_number);
|
1996-04-27 02:32:36 +04:00
|
|
|
else if (pa->pa_podule->slottype == SLOT_NET)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(" [ netslot %d ]:", pa->pa_podule_number - MAX_PODULES);
|
1996-04-27 02:32:36 +04:00
|
|
|
else
|
|
|
|
panic("Invalid slot type\n");
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* XXXX print flags */
|
1996-02-01 02:24:54 +03:00
|
|
|
return (QUIET);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-04-27 02:32:36 +04:00
|
|
|
int
|
|
|
|
podulebussubmatch(parent, match, aux)
|
1996-02-01 02:24:54 +03:00
|
|
|
struct device *parent;
|
|
|
|
void *match;
|
1996-04-27 02:32:36 +04:00
|
|
|
void *aux;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
1996-04-27 02:32:36 +04:00
|
|
|
struct cfdata *cf = match;
|
|
|
|
struct podule_attach_args *pa = aux;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Return priority 0 or 1 for wildcarded podule */
|
1996-04-27 02:32:36 +04:00
|
|
|
|
|
|
|
if (cf->cf_loc[0] == -1)
|
|
|
|
return((*cf->cf_attach->ca_match)(parent, match, aux));
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Return higher priority if we match the specific podule */
|
1996-04-27 02:32:36 +04:00
|
|
|
|
|
|
|
else if (cf->cf_loc[0] == pa->pa_podule_number)
|
|
|
|
return((*cf->cf_attach->ca_match)(parent, match, aux) * 8);
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Fail */
|
1996-04-27 02:32:36 +04:00
|
|
|
return(0);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
1996-10-30 03:07:42 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
#if 0
|
1996-02-01 02:24:54 +03:00
|
|
|
void
|
|
|
|
dump_podule(podule)
|
|
|
|
podule_t *podule;
|
|
|
|
{
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("podule%d: ", podule->podulenum);
|
|
|
|
printf("flags0=%02x ", podule->flags0);
|
|
|
|
printf("flags1=%02x ", podule->flags1);
|
|
|
|
printf("reserved=%02x ", podule->reserved);
|
|
|
|
printf("product=%02x ", podule->product);
|
|
|
|
printf("manufacturer=%02x ", podule->manufacturer);
|
|
|
|
printf("country=%02x ", podule->country);
|
|
|
|
printf("irq_addr=%08x ", podule->irq_addr);
|
|
|
|
printf("irq_mask=%02x ", podule->irq_mask);
|
|
|
|
printf("fiq_addr=%08x ", podule->fiq_addr);
|
|
|
|
printf("fiq_mask=%02x ", podule->fiq_mask);
|
|
|
|
printf("fast_base=%08x ", podule->fast_base);
|
|
|
|
printf("medium_base=%08x ", podule->medium_base);
|
|
|
|
printf("slow_base=%08x ", podule->slow_base);
|
|
|
|
printf("sync_base=%08x ", podule->sync_base);
|
|
|
|
printf("mod_base=%08x ", podule->mod_base);
|
|
|
|
printf("easi_base=%08x ", podule->easi_base);
|
|
|
|
printf("attached=%d ", podule->attached);
|
|
|
|
printf("slottype=%d ", podule->slottype);
|
|
|
|
printf("podulenum=%d ", podule->podulenum);
|
1996-11-23 06:42:39 +03:00
|
|
|
printf("description=%s ", podule->description);
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
1996-10-15 03:26:48 +04:00
|
|
|
#endif
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
podulechunkdirectory(podule)
|
|
|
|
podule_t *podule;
|
|
|
|
{
|
|
|
|
u_int address;
|
|
|
|
u_int id;
|
|
|
|
u_int size;
|
|
|
|
u_int addr;
|
|
|
|
int loop;
|
1996-10-15 03:26:48 +04:00
|
|
|
int done_f5;
|
|
|
|
|
|
|
|
done_f5 = 0;
|
1996-02-01 02:24:54 +03:00
|
|
|
address = 0x40;
|
|
|
|
|
|
|
|
do {
|
1996-11-23 06:42:39 +03:00
|
|
|
id = poduleread(podule->sync_base, address, podule->slottype);
|
|
|
|
size = poduleread(podule->sync_base, address + 4, podule->slottype);
|
|
|
|
size |= (poduleread(podule->sync_base, address + 8, podule->slottype) << 8);
|
|
|
|
size |= (poduleread(podule->sync_base, address + 12, podule->slottype) << 16);
|
1996-02-01 02:24:54 +03:00
|
|
|
if (id == 0xf5) {
|
1996-11-23 06:42:39 +03:00
|
|
|
addr = poduleread(podule->sync_base, address + 16, podule->slottype);
|
|
|
|
addr |= (poduleread(podule->sync_base, address + 20, podule->slottype) << 8);
|
|
|
|
addr |= (poduleread(podule->sync_base, address + 24, podule->slottype) << 16);
|
|
|
|
addr |= (poduleread(podule->sync_base, address + 28, podule->slottype) << 24);
|
1996-10-15 03:26:48 +04:00
|
|
|
if (addr < 0x800 && done_f5 == 0) {
|
|
|
|
done_f5 = 1;
|
|
|
|
for (loop = 0; loop < size; ++loop) {
|
|
|
|
if (loop < PODULE_DESCRIPTION_LENGTH) {
|
|
|
|
podule->description[loop] =
|
1996-11-23 06:42:39 +03:00
|
|
|
poduleread(podule->sync_base, (addr + loop)*4, podule->slottype);
|
1996-10-15 03:26:48 +04:00
|
|
|
podule->description[loop + 1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-01-04 02:30:30 +03:00
|
|
|
#ifdef DEBUG_CHUNK_DIR
|
1996-10-15 03:26:48 +04:00
|
|
|
if (id == 0xf5 || id == 0xf1 || id == 0xf2 || id == 0xf3 || id == 0xf4 || id == 0xf6) {
|
1996-11-23 06:42:39 +03:00
|
|
|
addr = poduleread(podule->sync_base, address + 16, podule->slottype);
|
|
|
|
addr |= (poduleread(podule->sync_base, address + 20, podule->slottype) << 8);
|
|
|
|
addr |= (poduleread(podule->sync_base, address + 24, podule->slottype) << 16);
|
|
|
|
addr |= (poduleread(podule->sync_base, address + 28, podule->slottype) << 24);
|
1996-10-15 03:26:48 +04:00
|
|
|
printf("<%04x.%04x.%04x.%04x>", id, address, addr, size);
|
1996-02-01 02:24:54 +03:00
|
|
|
if (addr < 0x800) {
|
1996-10-15 03:26:48 +04:00
|
|
|
for (loop = 0; loop < size; ++loop) {
|
1996-11-23 06:42:39 +03:00
|
|
|
printf("%c", poduleread(podule->sync_base, (addr + loop)*4, podule->slottype));
|
1996-10-15 03:26:48 +04:00
|
|
|
}
|
|
|
|
printf("\\n\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
1996-10-15 03:26:48 +04:00
|
|
|
#endif
|
1996-02-01 02:24:54 +03:00
|
|
|
address += 32;
|
|
|
|
} while (id != 0 && address < 0x800);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
poduleexamine(podule, dev, slottype)
|
|
|
|
podule_t *podule;
|
|
|
|
struct device *dev;
|
|
|
|
int slottype;
|
|
|
|
{
|
|
|
|
struct podule_list *pod_list;
|
|
|
|
struct podule_description *pod_desc;
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Test to see if the podule is present */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
if ((podule->flags0 & 0x02) == 0x00) {
|
|
|
|
podule->slottype = slottype;
|
|
|
|
if (slottype == SLOT_NET)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("netslot%d at %s : ", podule->podulenum - MAX_PODULES,
|
1996-02-01 02:24:54 +03:00
|
|
|
dev->dv_xname);
|
|
|
|
else
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("podule%d at %s : ", podule->podulenum,
|
1996-02-01 02:24:54 +03:00
|
|
|
dev->dv_xname);
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Is it Acorn conformant ? */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
if (podule->flags0 & 0x80)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("Non-Acorn conformant expansion card\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
else {
|
|
|
|
int id;
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Is it a simple podule ? */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
id = (podule->flags0 >> 3) & 0x0f;
|
|
|
|
if (id != 0)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("Simple expansion card <%x>\n", id);
|
1996-02-01 02:24:54 +03:00
|
|
|
else {
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Scan the chunk directory if present for tags we use */
|
|
|
|
if (podule->flags1 & PODULE_FLAGS_CD)
|
|
|
|
podulechunkdirectory(podule);
|
|
|
|
|
|
|
|
/* Do we know this manufacturer ? */
|
1996-02-01 02:24:54 +03:00
|
|
|
pod_list = known_podules;
|
|
|
|
while (pod_list->description) {
|
|
|
|
if (pod_list->manufacturer_id == podule->manufacturer)
|
|
|
|
break;
|
|
|
|
++pod_list;
|
|
|
|
}
|
|
|
|
if (!pod_list->description)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("man=%04x : ", podule->manufacturer);
|
1996-02-01 02:24:54 +03:00
|
|
|
else
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("%10s : ", pod_list->description);
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Do we know this product ? */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
pod_desc = pod_list->products;
|
|
|
|
while (pod_desc->description) {
|
|
|
|
if (pod_desc->product_id == podule->product)
|
|
|
|
break;
|
|
|
|
++pod_desc;
|
|
|
|
}
|
1996-05-16 23:05:35 +04:00
|
|
|
if (!pod_desc->description) {
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("prod=%04x : ", podule->product);
|
1996-10-15 03:26:48 +04:00
|
|
|
printf("%s\n", podule->description);
|
1996-05-16 23:05:35 +04:00
|
|
|
} else
|
1996-10-15 03:26:48 +04:00
|
|
|
printf("%s : %s\n", pod_desc->description, podule->description);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u_int
|
|
|
|
poduleread(address, offset, slottype)
|
|
|
|
u_int address;
|
|
|
|
int offset;
|
|
|
|
int slottype;
|
|
|
|
{
|
1997-01-04 02:30:30 +03:00
|
|
|
static int netslotoffset = -1;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
if (slottype == SLOT_NET) {
|
1997-01-04 02:30:30 +03:00
|
|
|
if (netslotoffset == -1) {
|
|
|
|
netslotoffset = 0;
|
|
|
|
WriteByte(address, 0x00);
|
|
|
|
}
|
1996-02-01 02:24:54 +03:00
|
|
|
offset = offset >> 2;
|
|
|
|
if (offset < netslotoffset) {
|
1997-01-04 02:30:30 +03:00
|
|
|
WriteByte(address, 0);
|
1996-02-01 02:24:54 +03:00
|
|
|
netslotoffset = 0;
|
|
|
|
}
|
|
|
|
while (netslotoffset < offset) {
|
1997-01-04 02:30:30 +03:00
|
|
|
slottype = ReadByte(address);
|
1996-02-01 02:24:54 +03:00
|
|
|
++netslotoffset;
|
|
|
|
}
|
|
|
|
++netslotoffset;
|
|
|
|
return(ReadByte(address));
|
|
|
|
}
|
|
|
|
return(ReadByte(address + offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
podulescan(dev)
|
|
|
|
struct device *dev;
|
|
|
|
{
|
|
|
|
int loop;
|
|
|
|
podule_t *podule;
|
|
|
|
u_char *address;
|
|
|
|
u_int offset = 0;
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Loop round all the podules */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
for (loop = 0; loop < MAX_PODULES; ++loop, offset += SIMPLE_PODULE_SIZE) {
|
|
|
|
podule = &podules[loop];
|
1997-01-04 02:30:30 +03:00
|
|
|
podule->podulenum = loop;
|
1996-02-01 02:24:54 +03:00
|
|
|
podule->attached = 0;
|
|
|
|
podule->slottype = SLOT_NONE;
|
1996-10-30 03:07:42 +03:00
|
|
|
podule->dma_channel = -1;
|
1996-10-15 03:26:48 +04:00
|
|
|
podule->description[0] = 0;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1997-01-04 02:30:30 +03:00
|
|
|
if (loop == 4) offset += PODULE_GAP;
|
|
|
|
address = ((u_char *)SYNC_PODULE_BASE) + offset;
|
|
|
|
|
|
|
|
if ((address[0] & 0x02) == 0x00) {
|
|
|
|
podule->fast_base = FAST_PODULE_BASE + offset;
|
|
|
|
podule->medium_base = MEDIUM_PODULE_BASE + offset;
|
|
|
|
podule->slow_base = SLOW_PODULE_BASE + offset;
|
|
|
|
podule->sync_base = SYNC_PODULE_BASE + offset;
|
|
|
|
podule->mod_base = MOD_PODULE_BASE + offset;
|
|
|
|
podule->easi_base = EASI_BASE + loop * EASI_SIZE;
|
|
|
|
} else {
|
|
|
|
address = ((u_char *)EASI_BASE) + loop * EASI_SIZE;
|
|
|
|
if ((address[0] & 0x02) != 0x00)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
podule->fast_base = 0;
|
|
|
|
podule->medium_base = 0;
|
|
|
|
podule->slow_base = 0;
|
|
|
|
podule->sync_base = 0;
|
|
|
|
podule->mod_base = 0;
|
|
|
|
podule->easi_base = EASI_BASE + loop * EASI_SIZE;
|
|
|
|
}
|
|
|
|
|
1996-10-30 03:07:42 +03:00
|
|
|
/* XXX - Really needs to be linked to a DMA manager */
|
|
|
|
if (IOMD_ID == RPC600_IOMD_ID) {
|
|
|
|
switch (loop) {
|
|
|
|
case 0:
|
|
|
|
podule->dma_channel = 2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
podule->dma_channel = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Get information from the podule header */
|
1996-06-13 01:09:55 +04:00
|
|
|
|
|
|
|
podule->flags0 = address[0];
|
|
|
|
if ((podule->flags0 & 0x78) == 0) {
|
|
|
|
podule->flags1 = address[4];
|
|
|
|
podule->reserved = address[8];
|
|
|
|
podule->product = address[12] + (address[16] << 8);
|
|
|
|
podule->manufacturer = address[20] + (address[24] << 8);
|
|
|
|
podule->country = address[28];
|
|
|
|
if (podule->flags1 & PODULE_FLAGS_IS) {
|
|
|
|
podule->irq_addr = address[52] + (address[56] << 8) + (address[60] << 16);
|
|
|
|
podule->irq_addr += podule->slow_base;
|
|
|
|
podule->irq_mask = address[48];
|
|
|
|
if (podule->irq_mask == 0)
|
|
|
|
podule->irq_mask = 0x01;
|
|
|
|
podule->fiq_addr = address[36] + (address[40] << 8) + (address[44] << 16);
|
|
|
|
podule->fiq_addr += podule->slow_base;
|
|
|
|
podule->fiq_mask = address[32];
|
|
|
|
if (podule->fiq_mask == 0)
|
|
|
|
podule->fiq_mask = 0x04;
|
|
|
|
} else {
|
|
|
|
podule->irq_addr = podule->slow_base;
|
|
|
|
podule->irq_mask = 0x01;
|
|
|
|
podule->fiq_addr = podule->slow_base;
|
|
|
|
podule->fiq_mask = 0x04;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
poduleexamine(podule, dev, SLOT_POD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
netslotscan(dev)
|
|
|
|
struct device *dev;
|
|
|
|
{
|
|
|
|
podule_t *podule;
|
|
|
|
volatile u_char *address;
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Only one netslot atm */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Reset the address counter */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
WriteByte(NETSLOT_BASE, 0x00);
|
|
|
|
|
|
|
|
address = (u_char *)NETSLOT_BASE;
|
|
|
|
|
|
|
|
podule = &podules[MAX_PODULES];
|
|
|
|
|
1996-06-13 01:09:55 +04:00
|
|
|
podule->fast_base = NETSLOT_BASE;
|
|
|
|
podule->medium_base = NETSLOT_BASE;
|
|
|
|
podule->slow_base = NETSLOT_BASE;
|
|
|
|
podule->sync_base = NETSLOT_BASE;
|
|
|
|
podule->mod_base = NETSLOT_BASE;
|
|
|
|
podule->easi_base = 0;
|
|
|
|
podule->attached = 0;
|
|
|
|
podule->slottype = SLOT_NONE;
|
|
|
|
podule->podulenum = MAX_PODULES;
|
1996-10-30 03:07:42 +03:00
|
|
|
podule->dma_channel = -1;
|
1996-10-15 03:26:48 +04:00
|
|
|
podule->description[0] = 0;
|
1996-06-13 01:09:55 +04:00
|
|
|
|
1996-10-30 03:07:42 +03:00
|
|
|
/* XXX - Really needs to be linked to a DMA manager */
|
|
|
|
if (IOMD_ID == RPC600_IOMD_ID)
|
|
|
|
podule->dma_channel = 0;
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Get information from the podule header */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
podule->flags0 = *address;
|
|
|
|
podule->flags1 = *address;
|
|
|
|
podule->reserved = *address;
|
|
|
|
podule->product = *address + (*address << 8);
|
|
|
|
podule->manufacturer = *address + (*address << 8);
|
|
|
|
podule->country = *address;
|
|
|
|
if (podule->flags1 & PODULE_FLAGS_IS) {
|
|
|
|
podule->irq_mask = *address;
|
|
|
|
podule->irq_addr = *address + (*address << 8) + (*address << 16);
|
1996-06-13 01:09:55 +04:00
|
|
|
podule->irq_addr += podule->slow_base;
|
|
|
|
if (podule->irq_mask == 0)
|
|
|
|
podule->irq_mask = 0x01;
|
1996-02-01 02:24:54 +03:00
|
|
|
podule->fiq_mask = *address;
|
|
|
|
podule->fiq_addr = *address + (*address << 8) + (*address << 16);
|
1996-06-13 01:09:55 +04:00
|
|
|
podule->fiq_addr += podule->slow_base;
|
|
|
|
if (podule->fiq_mask == 0)
|
|
|
|
podule->fiq_mask = 0x04;
|
1996-02-01 02:24:54 +03:00
|
|
|
} else {
|
1996-06-13 01:09:55 +04:00
|
|
|
podule->irq_addr = podule->slow_base;
|
|
|
|
podule->irq_mask = 0x01;
|
|
|
|
podule->fiq_addr = podule->slow_base;
|
|
|
|
podule->fiq_mask = 0x04;
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
poduleexamine(podule, dev, SLOT_NET);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* void podulebusattach(struct device *parent, struct device *dev, void *aux)
|
|
|
|
*
|
|
|
|
* Attach podulebus.
|
|
|
|
* This probes all the podules and sets up the podules array with
|
|
|
|
* information found in the podule headers.
|
|
|
|
* After identifing all the podules, all the children of the podulebus
|
|
|
|
* are probed and attached.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
podulebusattach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
int loop;
|
1996-04-27 02:32:36 +04:00
|
|
|
struct podule_attach_args pa;
|
1996-08-21 23:46:47 +04:00
|
|
|
int easi_time;
|
|
|
|
int bit;
|
|
|
|
|
|
|
|
easi_time = ReadByte(IOMD_ECTCR);
|
|
|
|
|
1996-10-13 07:05:43 +04:00
|
|
|
printf(": easi timings=");
|
1996-08-21 23:46:47 +04:00
|
|
|
for (bit = 0x01; bit < 0x100; bit = bit << 1)
|
|
|
|
if (easi_time & bit)
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("C");
|
1996-08-21 23:46:47 +04:00
|
|
|
else
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("A");
|
1996-08-21 23:46:47 +04:00
|
|
|
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Ok we need to map in the podulebus */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Map the FAST and SYNC simple podules */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
map_section(PAGE_DIRS_BASE, SYNC_PODULE_BASE & 0xfff00000,
|
|
|
|
SYNC_PODULE_HW_BASE & 0xfff00000);
|
1996-10-15 03:26:48 +04:00
|
|
|
tlb_flush();
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Now map the EASI space */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
for (loop = 0; loop < MAX_PODULES; ++loop) {
|
|
|
|
int loop1;
|
|
|
|
|
|
|
|
for (loop1 = loop * EASI_SIZE; loop1 < ((loop + 1) * EASI_SIZE); loop1 += (1 << 20))
|
|
|
|
map_section(PAGE_DIRS_BASE, EASI_BASE + loop1, EASI_HW_BASE + loop1);
|
|
|
|
}
|
1996-10-15 03:26:48 +04:00
|
|
|
tlb_flush();
|
1997-01-04 02:30:30 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/*
|
|
|
|
* The MEDIUM and SLOW simple podules and the module space will have been
|
|
|
|
* mapped when the IOMD and COMBO we mapped in for the RPC
|
|
|
|
*/
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Install an podule IRQ handler */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
poduleirq.ih_func = poduleirqhandler;
|
|
|
|
poduleirq.ih_arg = NULL;
|
|
|
|
poduleirq.ih_level = IPL_NONE;
|
1996-04-27 02:32:36 +04:00
|
|
|
poduleirq.ih_name = "podule";
|
1996-03-28 01:07:26 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/*
|
|
|
|
if (irq_claim(IRQ_PODULE, &poduleirq))
|
|
|
|
panic("Cannot claim IRQ %d for podulebus%d\n", IRQ_PODULE, parent->dv_unit);
|
|
|
|
*/
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Find out what hardware is bolted on */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
podulescan(self);
|
|
|
|
netslotscan(self);
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Look for drivers to attach */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-04-27 02:32:36 +04:00
|
|
|
for (loop = 0; loop < MAX_PODULES+MAX_NETSLOTS; ++loop)
|
|
|
|
if (podules[loop].slottype != SLOT_NONE) {
|
|
|
|
pa.pa_podule_number = loop;
|
|
|
|
pa.pa_podule = &podules[loop];
|
|
|
|
config_found_sm(self, &pa, podulebusprint, podulebussubmatch);
|
|
|
|
}
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* int podule_irqhandler(void *arg)
|
|
|
|
*
|
|
|
|
* text irq handler to service expansion card IRQ's
|
|
|
|
*
|
|
|
|
* There is currently a problem here.
|
|
|
|
* The spl_mask may mask out certain expansion card IRQ's e.g. SCSI
|
|
|
|
* but allow others e.g. Ethernet.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
poduleirqhandler()
|
|
|
|
{
|
|
|
|
int loop;
|
|
|
|
irqhandler_t *handler;
|
|
|
|
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("eek ! Unknown podule IRQ received - Blocking all podule interrupts\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
disable_irq(IRQ_PODULE);
|
1996-06-13 01:09:55 +04:00
|
|
|
/* return(1);*/
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Loop round the expansion card handlers */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
for (loop = IRQ_EXPCARD0; loop <= IRQ_EXPCARD7; ++loop) {
|
|
|
|
|
1996-10-15 03:26:48 +04:00
|
|
|
/* Is the IRQ currently allowable */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
if (actual_mask & (1 << loop)) {
|
|
|
|
handler = irqhandlers[loop];
|
|
|
|
|
1996-06-13 01:09:55 +04:00
|
|
|
if (handler && handler->ih_maskaddr) {
|
|
|
|
if (ReadByte(handler->ih_maskaddr) & handler->ih_maskbits)
|
1996-02-01 02:24:54 +03:00
|
|
|
handler->ih_func(handler->ih_arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
1996-03-20 21:46:58 +03:00
|
|
|
struct cfattach podulebus_ca = {
|
1996-03-17 04:16:48 +03:00
|
|
|
sizeof(struct device), podulebusmatch, podulebusattach
|
|
|
|
};
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-03-17 04:16:48 +03:00
|
|
|
struct cfdriver podulebus_cd = {
|
1996-04-27 02:32:36 +04:00
|
|
|
NULL, "podulebus", DV_DULL, 0
|
1996-02-01 02:24:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Useful functions that drivers may share */
|
|
|
|
|
1996-04-27 02:32:36 +04:00
|
|
|
/*
|
|
|
|
* Match a podule structure with the specified parameters
|
|
|
|
* Returns 0 if the match failed
|
1996-10-15 03:26:48 +04:00
|
|
|
* The required_slot is not used at the moment.
|
1996-04-27 02:32:36 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
matchpodule(pa, manufacturer, product, required_slot)
|
|
|
|
struct podule_attach_args *pa;
|
|
|
|
int manufacturer;
|
|
|
|
int product;
|
|
|
|
int required_slot;
|
|
|
|
{
|
|
|
|
if (pa->pa_podule->attached)
|
|
|
|
panic("podulebus: Podule already attached\n");
|
|
|
|
|
|
|
|
if (pa->pa_podule->manufacturer == manufacturer
|
|
|
|
&& pa->pa_podule->product == product)
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
/* End of podulebus.c */
|