arm32 kernel source restructure

- Create an independ IOMD device that can be utilised by all ARM
    architectures that use an IOMD.
  - Configure all IOMD child devices based on the IOMD type and features.
This commit is contained in:
mark 1997-10-14 10:58:48 +00:00
parent a567ef9bf4
commit 59b6709696
4 changed files with 730 additions and 0 deletions

303
sys/arch/arm32/iomd/iomd.c Normal file
View File

@ -0,0 +1,303 @@
/* $NetBSD: iomd.c,v 1.1 1997/10/14 10:58:48 mark Exp $ */
/*
* Copyright (c) 1996-1997 Mark Brinicombe.
* Copyright (c) 1997 Causality Limited
* 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 Mark Brinicombe.
* 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 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 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
*
* iomd.c
*
* Probing and configuration for the IOMD
*
* Created : 10/10/95
*/
#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/bus.h>
#include <machine/cpu.h>
#include <machine/irqhandler.h>
#include <arm32/iomd/iomdreg.h>
#include <arm32/iomd/iomdvar.h>
#include "iomd.h"
#if NIOMD != 1
#error Need one IOMD device configured
#endif
/*
* IOMD device.
*
* This probes and attaches the top level IOMD device.
* It then configures any children of the IOMD device.
*/
/*
* IOMD softc structure.
*
* Contains the device node, bus space tag, handle and address
* and the IOMD id.
*/
struct iomd_softc {
struct device sc_dev; /* device node */
bus_space_tag_t sc_iot; /* bus tag */
bus_space_handle_t sc_ioh; /* bus handle */
int sc_id; /* IOMD id */
};
static int iomdmatch __P((struct device *parent, struct cfdata *cf,
void *aux));
static void iomdattach __P((struct device *parent, struct device *self,
void *aux));
static int iomdprint __P((void *aux, const char *iomdbus));
struct cfattach iomd_ca = {
sizeof(struct iomd_softc), iomdmatch, iomdattach
};
struct cfdriver iomd_cd = {
NULL, "iomd", DV_DULL, 0
};
extern struct bus_space iomd_bs_tag;
/* Declare prototypes */
/*
* int iomdprint(void *aux, const char *name)
*
* print configuration info for children
*/
static int
iomdprint(aux, name)
void *aux;
const char *name;
{
union iomd_attach_args *ia = aux;
return(QUIET);
}
/*
* int iomdmatch(struct device *parent, struct cfdata *cf, void *aux)
*
* Just return ok for this if it is device 0
*/
static int
iomdmatch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
if (cf->cf_unit == 0)
return(1);
return(0);
}
/*
* void iomdattach(struct device *parent, struct device *dev, void *aux)
*
* Map the IOMD and identify it.
* Then configure the child devices based on the IOMD ID.
*/
static void
iomdattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct iomd_softc *sc = (struct iomd_softc *)self;
struct mainbus_attach_args *mb = aux;
int refresh;
#if 0
int dma_time;
int combo_time;
int loop;
#endif
union iomd_attach_args ia;
bus_space_tag_t iot;
bus_space_handle_t ioh;
iot = sc->sc_iot = &iomd_bs_tag;
/* Map the IOMD */
if (bus_space_map(iot, IOMD_BASE, IOMD_SIZE, 0, &ioh))
panic("%s: Cannot map registers\n", self->dv_xname);
sc->sc_ioh = ioh;
/* Get the ID */
sc->sc_id = bus_space_read_1(iot, ioh, IOMD_ID0)
| (bus_space_read_1(iot, ioh, IOMD_ID1) << 8);
printf(": ");
/* Identify it and get the DRAM refresh rate */
switch (sc->sc_id) {
case ARM7500_IOC_ID:
printf("ARM7500 IOMD ");
refresh = bus_space_read_1(iot, ioh, IOMD_REFCR) & 0x0f;
break;
case ARM7500FE_IOC_ID:
printf("ARM7500FE IOMD ");
refresh = bus_space_read_1(iot, ioh, IOMD_REFCR) & 0x0f;
break;
case RPC600_IOMD_ID:
printf("RPC IOMD ");
refresh = bus_space_read_1(iot, ioh, IOMD_VREFCR) & 0x09;
break;
default:
printf("Unknown IOMD ID=%04x ", sc->sc_id);
refresh = -1;
break;
}
printf("\n");
/* Report the DRAM refresh rate */
printf("%s: ", self->dv_xname);
printf("DRAM refresh=");
switch (refresh) {
case 0x0:
printf("off");
break;
case 0x1:
printf("16us");
break;
case 0x2:
printf("32us");
break;
case 0x4:
printf("64us");
break;
case 0x8:
printf("128us");
break;
default:
printf("unknown [%02x]", refresh);
break;
}
#if 0
/*
* No point in reporting this as it may get changed when devices are
* attached
*/
dma_time = ReadByte(IOMD_DMATCR);
printf(", dma cycle types=");
for (loop = 0; loop < 4; ++loop,dma_time = dma_time >> 2)
printf("%c", 'A' + (dma_time & 3));
combo_time = ReadByte(IOMD_IOTCR);
printf(", combo cycle type=%c", 'A' + ((combo_time >> 2) & 3));
#endif
printf("\n");
/* Set up the external DMA channels */
/* XXX - this should be machine dependant not IOMD dependant */
switch (sc->sc_id) {
case ARM7500_IOC_ID:
case ARM7500FE_IOC_ID:
break;
case RPC600_IOMD_ID:
/* DMA channels 2 & 3 are external */
bus_space_write_1(iot, ioh, IOMD_DMAEXT, 0x0c);
break;
}
/* Configure the child devices */
/* Attach clock device */
ia.ia_clk.ca_name = "clk";
ia.ia_clk.ca_iot = iot;
ia.ia_clk.ca_ioh = ioh;
config_found(self, &ia, iomdprint);
/* Attach kbd device */
if (bus_space_subregion(iot, ioh, IOMD_KBDDAT, 8, &ia.ia_kbd.ka_ioh))
panic("%s: Cannot map kbd registers\n", self->dv_xname);
ia.ia_kbd.ka_name = "kbd";
ia.ia_kbd.ka_iot = iot;
ia.ia_kbd.ka_rxirq = IRQ_KBDRX;
ia.ia_kbd.ka_txirq = IRQ_KBDTX;
config_found(self, &ia, iomdprint);
/* Attach iic device */
if (bus_space_subregion(iot, ioh, IOMD_IOCR, 4, &ia.ia_iic.ia_ioh))
panic("%s: Cannot map iic registers\n", self->dv_xname);
ia.ia_iic.ia_name = "iic";
ia.ia_iic.ia_iot = iot;
ia.ia_iic.ia_irq = -1;
config_found(self, &ia, iomdprint);
switch (sc->sc_id) {
case ARM7500_IOC_ID:
case ARM7500FE_IOC_ID:
/* Attach pms device */
if (bus_space_subregion(iot, ioh, IOMD_MSDATA, 8, &ia.ia_pms.pa_ioh))
panic("%s: Cannot map pms registers\n", self->dv_xname);
ia.ia_pms.pa_name = "pms";
ia.ia_pms.pa_iot = iot;
ia.ia_pms.pa_irq = -1;
config_found(self, &ia, iomdprint);
break;
case RPC600_IOMD_ID:
/* Attach qms device */
if (bus_space_subregion(iot, ioh, IOMD_MOUSEX, 8, &ia.ia_qms.qa_ioh))
panic("%s: Cannot map qms registers\n", self->dv_xname);
if (bus_space_map(iot, IO_MOUSE_BUTTONS, 4, 0, &ia.ia_qms.qa_ioh_but))
panic("%s: Cannot map registers\n", self->dv_xname);
ia.ia_qms.qa_name = "qms";
ia.ia_qms.qa_iot = iot;
ia.ia_qms.qa_irq = IRQ_VSYNC;
config_found(self, &ia, iomdprint);
break;
}
}
/* End of iomd.c */

View File

@ -0,0 +1,199 @@
/* $NetBSD: iomd_io.c,v 1.1 1997/10/14 10:58:50 mark Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe.
* Copyright (c) 1997 Causality Limited.
* 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 Mark Brinicombe.
* 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 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 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.
*/
/*
* bus_space I/O functions for iomd
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
/* Proto types for all the bus_space structure functions */
bs_protos(iomd);
bs_protos(bs_notimpl);
/* Declare the iomd bus space tag */
struct bus_space iomd_bs_tag = {
/* cookie */
NULL,
/* mapping/unmapping */
iomd_map,
iomd_unmap,
iomd_subregion,
/* allocation/deallocation */
iomd_alloc,
iomd_free,
/* barrier */
iomd_barrier,
/* read (single) */
iomd_r_1,
iomd_r_2,
iomd_r_4,
bs_notimpl_r_8,
/* read multiple */
bs_notimpl_rm_1,
iomd_rm_2,
bs_notimpl_rm_4,
bs_notimpl_rm_8,
/* read region */
bs_notimpl_rr_1,
bs_notimpl_rr_2,
bs_notimpl_rr_4,
bs_notimpl_rr_8,
/* write (single) */
iomd_w_1,
iomd_w_2,
iomd_w_4,
bs_notimpl_w_8,
/* write multiple */
bs_notimpl_wm_1,
iomd_wm_2,
bs_notimpl_wm_4,
bs_notimpl_wm_8,
/* write region */
bs_notimpl_wr_1,
bs_notimpl_wr_2,
bs_notimpl_wr_4,
bs_notimpl_wr_8,
/* set multiple */
bs_notimpl_sm_1,
bs_notimpl_sm_2,
bs_notimpl_sm_4,
bs_notimpl_sm_8,
/* set region */
bs_notimpl_sr_1,
bs_notimpl_sr_2,
bs_notimpl_sr_4,
bs_notimpl_sr_8,
/* copy */
bs_notimpl_c_1,
bs_notimpl_c_2,
bs_notimpl_c_4,
bs_notimpl_c_8,
};
/* bus space functions */
int
iomd_map(t, bpa, size, cacheable, bshp)
void *t;
bus_addr_t bpa;
bus_size_t size;
int cacheable;
bus_space_handle_t *bshp;
{
/*
* Temporary implementation as all I/O is already mapped etc.
*
* Eventually this function will do the mapping check for multiple maps
*/
*bshp = bpa;
return(0);
}
int
iomd_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
bpap, bshp)
void *t;
bus_addr_t rstart, rend;
bus_size_t size, alignment, boundary;
int cacheable;
bus_addr_t *bpap;
bus_space_handle_t *bshp;
{
panic("iomd_alloc(): Help!\n");
}
void
iomd_unmap(t, bsh, size)
void *t;
bus_space_handle_t bsh;
bus_size_t size;
{
/*
* Temporary implementation
*/
}
void
iomd_free(t, bsh, size)
void *t;
bus_space_handle_t bsh;
bus_size_t size;
{
panic("iomd_free(): Help!\n");
/* iomd_unmap() does all that we need to do. */
/* iomd_unmap(t, bsh, size);*/
}
int
iomd_subregion(t, bsh, offset, size, nbshp)
void *t;
bus_space_handle_t bsh;
bus_size_t offset, size;
bus_space_handle_t *nbshp;
{
*nbshp = bsh + (offset << 2);
return (0);
}
void
iomd_barrier(t, bsh, offset, len, flags)
void *t;
bus_space_handle_t bsh;
bus_size_t offset, len;
int flags;
{
}
/* End of iomd_io.c */

View File

@ -0,0 +1,109 @@
/* $NetBSD: iomd_io_asm.S,v 1.1 1997/10/14 10:58:50 mark Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe.
* Copyright (c) 1997 Causality Limited.
* 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 Mark Brinicombe.
* 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 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 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.
*/
/*
* bus_space I/O functions for iomd
*/
sp .req r13
lr .req r14
pc .req r15
.text
/*
* read single
*/
.global _iomd_r_1
_iomd_r_1:
ldrb r0, [r1, r2, lsl #2]
mov pc, lr
.global _iomd_r_2
_iomd_r_2:
ldr r0, [r1, r2, lsl #2]
bic r0, r0, #0xff000000
bic r0, r0, #0x00ff0000
mov pc, lr
.global _iomd_r_4
_iomd_r_4:
ldr r0, [r1, r2, lsl #2]
mov pc, lr
/*
* write single
*/
.global _iomd_w_1
_iomd_w_1:
strb r3, [r1, r2, lsl #2]
mov pc, lr
.global _iomd_w_2
_iomd_w_2:
mov r3, r3, lsl #16
orr r3, r3, r3, lsr #16
str r3, [r1, r2, lsl #2]
mov pc, lr
.global _iomd_w_4
_iomd_w_4:
str r3, [r1, r2, lsl #2]
mov pc, lr
/*
* read multiple
*/
.global _iomd_rm_2
_iomd_rm_2:
add r0, r1, r2, lsl #2
mov r1, r3
ldr r2, [sp, #0]
b _insw16
/*
* write multiple
*/
.global _iomd_wm_2
_iomd_wm_2:
add r0, r1, r2, lsl #2
mov r1, r3
ldr r2, [sp, #0]
b _outsw16

View File

@ -0,0 +1,119 @@
/* $NetBSD: iomdvar.h,v 1.1 1997/10/14 10:58:51 mark Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe.
* Copyright (c) 1997 Causality Limited
* 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 Mark Brinicombe
* 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 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 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
*
* iomd_bus.h
*
* Created : 02/02/97
*/
#include <machine/bus.h>
/*
* Attach args for iomd_clock device
*/
struct clk_attach_args {
const char *ca_name; /* device name*/
bus_space_tag_t ca_iot; /* Bus tag */
bus_space_handle_t ca_ioh; /* Bus handle */
int ca_irq; /* IRQ number */
};
/*
* Attach args for iomd device
*/
/*
* Attach args for qms device
*/
struct qms_attach_args {
const char *qa_name; /* device name*/
bus_space_tag_t qa_iot; /* Bus tag */
bus_space_handle_t qa_ioh; /* Bus handle */
bus_space_handle_t qa_ioh_but; /* Bus handle */
int qa_irq; /* IRQ number */
};
/*
* Attach args for pms device
*/
struct pms_attach_args {
const char *pa_name; /* device name*/
bus_space_tag_t pa_iot; /* Bus tag */
bus_space_handle_t pa_ioh; /* Bus handle */
int pa_irq; /* IRQ number */
};
/*
* Attach args for kbd device
*/
struct kbd_attach_args {
const char *ka_name; /* device name*/
bus_space_tag_t ka_iot; /* Bus tag */
bus_space_handle_t ka_ioh; /* Bus handle */
int ka_rxirq; /* IRQ number */
int ka_txirq; /* IRQ number */
};
/*
* Attach args for iic device
*/
struct iic_attach_args {
const char *ia_name; /* device name */
bus_space_tag_t ia_iot; /* Bus tag */
bus_space_handle_t ia_ioh; /* Bus handle */
int ia_irq; /* IRQ number */
};
/*
* NOTE: All these attach structures and a const char *name as the
* first field for identification.
*/
union iomd_attach_args {
struct kbd_attach_args ia_kbd;
struct pms_attach_args ia_pms;
struct qms_attach_args ia_qms;
struct iic_attach_args ia_iic;
struct clk_attach_args ia_clk;
};
/* End of iomdvar.h */