summaryrefslogtreecommitdiff
path: root/sys/arch/beagle/dev
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2011-11-10 19:37:02 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2011-11-10 19:37:02 +0000
commitc5e659b789e1a01f0119342bbab2605804c34b96 (patch)
tree03fa41b0119311fd4c46d8b84e8051866e421d43 /sys/arch/beagle/dev
parentd08102dee5d38b0e6a68ac320575274692cacfde (diff)
Reduce autoconf(4) overuse on beagle
Renamed `ahb' to `omap' and extended it to configure the on-chip devices directly, based a board-specific table instead of trying to maintain addresses, interrupt numbers and such for two OMAP variants in the same config file. This may be an intermediate step, but should provide us some relief already. :) Suggestions from deraadt and drahn; ok drahn@
Diffstat (limited to 'sys/arch/beagle/dev')
-rw-r--r--sys/arch/beagle/dev/ampintc.c54
-rw-r--r--sys/arch/beagle/dev/amptimer.c33
-rw-r--r--sys/arch/beagle/dev/gptimer.c43
-rw-r--r--sys/arch/beagle/dev/intc.c35
-rw-r--r--sys/arch/beagle/dev/omap.c187
-rw-r--r--sys/arch/beagle/dev/omap3.c151
-rw-r--r--sys/arch/beagle/dev/omap4.c111
-rw-r--r--sys/arch/beagle/dev/omap_com.c70
-rw-r--r--sys/arch/beagle/dev/omapvar.h56
-rw-r--r--sys/arch/beagle/dev/omdisplay.c6
-rw-r--r--sys/arch/beagle/dev/omdog.c33
-rw-r--r--sys/arch/beagle/dev/omehci.c43
-rw-r--r--sys/arch/beagle/dev/omgpio.c18
-rw-r--r--sys/arch/beagle/dev/ommmc.c53
-rw-r--r--sys/arch/beagle/dev/omohci.c4
-rw-r--r--sys/arch/beagle/dev/omusbtll.c38
-rw-r--r--sys/arch/beagle/dev/prcm.c37
17 files changed, 627 insertions, 345 deletions
diff --git a/sys/arch/beagle/dev/ampintc.c b/sys/arch/beagle/dev/ampintc.c
index 7b88bf3df1a..cfe18a1afd6 100644
--- a/sys/arch/beagle/dev/ampintc.c
+++ b/sys/arch/beagle/dev/ampintc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ampintc.c,v 1.7 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: ampintc.c,v 1.8 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007,2009,2011 Dale Rahn <drahn@openbsd.org>
*
@@ -28,7 +28,7 @@
#include <sys/evcount.h>
#include <arm/cpufunc.h>
#include <machine/bus.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
/* registers */
#define ICD_DCR 0x000
@@ -153,7 +153,6 @@ struct intrq {
};
-int ampintc_match(struct device *, void *, void *);
void ampintc_attach(struct device *, struct device *, void *);
int ampintc_spllower(int);
void ampintc_splx(int);
@@ -175,40 +174,18 @@ void ampintc_intr_disable(int);
void ampintc_route(int, int , int);
struct cfattach ampintc_ca = {
- sizeof (struct ampintc_softc), ampintc_match, ampintc_attach
+ sizeof (struct ampintc_softc), NULL, ampintc_attach
};
struct cfdriver ampintc_cd = {
NULL, "ampintc", DV_DULL
};
-int ampintc_attached = 0;
-
-int
-ampintc_match(struct device *parent, void *v, void *aux)
-{
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- return 0; /* not ported yet ??? - different */
- case BOARD_ID_OMAP4_PANDA:
- break; /* continue trying */
- default:
- return 0; /* unknown */
- }
- if (ampintc_attached != 0)
- return 0;
-
- /* XXX */
- return (1);
-}
-
-
void
ampintc_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
struct ampintc_softc *sc = (struct ampintc_softc *)self;
+ struct omap_attach_args *oa = args;
int i, nintr;
bus_space_tag_t iot;
bus_space_handle_t d_ioh, p_ioh;
@@ -217,14 +194,21 @@ ampintc_attach(struct device *parent, struct device *self, void *args)
arm_init_smask();
-#define ICD_ADDR 0x48241000
-#define ICP_ADDR 0x48240100
- iot = aa->aa_iot;
- if (bus_space_map(iot, ICD_ADDR, ICD_SIZE, 0, &d_ioh))
- panic("ampintc_attach: bus_space_map failed!");
+ iot = oa->oa_iot;
+
+ printf("ICP addr 0x%x-0x%x\n", oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].addr + oa->oa_dev->mem[0].size);
- if (bus_space_map(iot, ICP_ADDR, ICP_SIZE, 0, &p_ioh))
- panic("ampintc_attach: bus_space_map failed!");
+ printf("ICD addr 0x%x-0x%x\n", oa->oa_dev->mem[1].addr,
+ oa->oa_dev->mem[1].addr + oa->oa_dev->mem[1].size);
+
+ if (bus_space_map(iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &p_ioh))
+ panic("ampintc_attach: ICP bus_space_map failed!");
+
+ if (bus_space_map(iot, oa->oa_dev->mem[1].addr,
+ oa->oa_dev->mem[1].size, 0, &d_ioh))
+ panic("ampintc_attach: ICD bus_space_map failed!");
sc->sc_iot = iot;
sc->sc_d_ioh = d_ioh;
@@ -278,8 +262,6 @@ ampintc_attach(struct device *parent, struct device *self, void *args)
ampintc_setipl(IPL_HIGH); /* XXX ??? */
ampintc_calc_mask();
- ampintc_attached = 1;
-
/* insert self as interrupt handler */
arm_set_intr_handler(ampintc_splraise, ampintc_spllower, ampintc_splx,
ampintc_setipl, ampintc_intr_establish_ext,
diff --git a/sys/arch/beagle/dev/amptimer.c b/sys/arch/beagle/dev/amptimer.c
index ab97b4955e1..cefd16bfdc2 100644
--- a/sys/arch/beagle/dev/amptimer.c
+++ b/sys/arch/beagle/dev/amptimer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amptimer.c,v 1.5 2011/11/10 16:15:24 drahn Exp $ */
+/* $OpenBSD: amptimer.c,v 1.6 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
*
@@ -27,7 +27,7 @@
#include <arm/cpufunc.h>
#include <machine/bus.h>
#include <machine/intr.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
#define GTIMER_CNT_LOW 0x200
#define GTIMER_CNT_HIGH 0x204
@@ -42,8 +42,6 @@
#define GTIMER_CMP_HIGH 0x214
#define GTIMER_AUTOINC 0x218
-#define GTIMER_SIZE 0x300
-
/* XXX - PERIPHCLK */
#define TIMER_FREQUENCY 512 * 1024 * 1024 /* XXX - PERIPHCLK? */
@@ -72,7 +70,6 @@ struct amptimer_softc {
#endif
};
-int amptimer_match(struct device *, void *, void *);
void amptimer_attach(struct device *, struct device *, void *);
uint64_t amptimer_readcnt64(struct amptimer_softc *sc);
int amptimer_intr(void *);
@@ -90,25 +87,13 @@ void *ampintc_intr_establish(int, int, int (*)(void *), void *, char *);
struct cfattach amptimer_ca = {
- sizeof (struct amptimer_softc), amptimer_match, amptimer_attach
+ sizeof (struct amptimer_softc), NULL, amptimer_attach
};
struct cfdriver amptimer_cd = {
NULL, "amptimer", DV_DULL
};
-int
-amptimer_match(struct device *parent, void *v, void *aux)
-{
- switch (board_id) {
- case BOARD_ID_OMAP4_PANDA:
- break; /* continue trying */
- default:
- return 0; /* unknown */
- }
- return (1);
-}
-
uint64_t
amptimer_readcnt64(struct amptimer_softc *sc)
{
@@ -130,12 +115,14 @@ void
amptimer_attach(struct device *parent, struct device *self, void *args)
{
struct amptimer_softc *sc = (struct amptimer_softc *)self;
- struct ahb_attach_args *aa = args;
- bus_space_handle_t ioh;
+ struct omap_attach_args *oa = args;
+ bus_space_handle_t ioh;
+
+ sc->sc_iot = oa->oa_iot;
- sc->sc_iot = aa->aa_iot;
- if (bus_space_map(sc->sc_iot, aa->aa_addr, GTIMER_SIZE, 0, &ioh))
- panic("amptimer_attach: bus_space_map failed!");
+ if (bus_space_map(sc->sc_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &ioh))
+ panic("amptimer_attach: bus_space_map failed!");
sc->sc_ticks_per_second = TIMER_FREQUENCY;
printf(": tick rate %d KHz\n", sc->sc_ticks_per_second /1024);
diff --git a/sys/arch/beagle/dev/gptimer.c b/sys/arch/beagle/dev/gptimer.c
index dfc92824858..60a9a3d201e 100644
--- a/sys/arch/beagle/dev/gptimer.c
+++ b/sys/arch/beagle/dev/gptimer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gptimer.c,v 1.11 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: gptimer.c,v 1.12 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@@ -30,9 +30,9 @@
#include <sys/device.h>
#include <sys/timetc.h>
#include <dev/clock_subr.h>
-#include <beagle/dev/prcmvar.h>
#include <machine/bus.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
+#include <beagle/dev/prcmvar.h>
#include <machine/intr.h>
#include <arm/cpufunc.h>
@@ -94,8 +94,6 @@
#define GP_TSICR_POSTED 0x00000002
#define GP_TSICR_SFT 0x00000001
#define GP_TCAR2 0x044
-#define GP_SIZE 0x100
-
#define TIMER_FREQUENCY 32768 /* 32kHz is used, selectable */
@@ -106,7 +104,6 @@ static struct evcount stat_count;
//static int clk_irq = GPT1_IRQ; /* XXX 37 */
-int gptimer_match(struct device *parent, void *v, void *aux);
void gptimer_attach(struct device *parent, struct device *self, void *args);
int gptimer_intr(void *frame);
void gptimer_wait(int reg);
@@ -133,37 +130,23 @@ u_int32_t ticks_err_sum;
u_int32_t statvar, statmin;
struct cfattach gptimer_ca = {
- sizeof (struct device), gptimer_match, gptimer_attach
+ sizeof (struct device), NULL, gptimer_attach
};
struct cfdriver gptimer_cd = {
NULL, "gptimer", DV_DULL
};
-int
-gptimer_match(struct device *parent, void *v, void *aux)
-{
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- break; /* continue trying */
- case BOARD_ID_OMAP4_PANDA:
- return 0; /* not ported yet ??? - different */
- default:
- return 0; /* unknown */
- }
- return (1);
-}
-
void
gptimer_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
- bus_space_handle_t ioh;
+ struct omap_attach_args *oa = args;
+ bus_space_handle_t ioh;
u_int32_t rev;
- gptimer_iot = aa->aa_iot;
- if (bus_space_map(gptimer_iot, aa->aa_addr, GP_SIZE, 0, &ioh))
+ gptimer_iot = oa->oa_iot;
+ if (bus_space_map(gptimer_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &ioh))
panic("gptimer_attach: bus_space_map failed!");
rev = bus_space_read_4(gptimer_iot, ioh, GP_TIDR);
@@ -171,7 +154,7 @@ gptimer_attach(struct device *parent, struct device *self, void *args)
printf(" rev %d.%d\n", rev >> 4 & 0xf, rev & 0xf);
if (self->dv_unit == 0) {
gptimer_ioh0 = ioh;
- gptimer_irq = aa->aa_intr;
+ gptimer_irq = oa->oa_dev->irq[0];
bus_space_write_4(gptimer_iot, gptimer_ioh0, GP_TCLR, 0);
} else if (self->dv_unit == 1) {
/* start timer because it is used in delay */
@@ -187,10 +170,10 @@ gptimer_attach(struct device *parent, struct device *self, void *args)
gptimer_timecounter.tc_frequency = TIMER_FREQUENCY;
tc_init(&gptimer_timecounter);
}
- else
- panic("attaching too many gptimers at %x", aa->aa_addr);
+ else
+ panic("attaching too many gptimers at 0x%x",
+ oa->oa_dev->mem[0].addr);
-
arm_clock_register(gptimer_cpu_initclocks, gptimer_delay,
gptimer_setstatclockrate);
}
diff --git a/sys/arch/beagle/dev/intc.c b/sys/arch/beagle/dev/intc.c
index 6d6433a5791..9b67d695f93 100644
--- a/sys/arch/beagle/dev/intc.c
+++ b/sys/arch/beagle/dev/intc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intc.c,v 1.9 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: intc.c,v 1.10 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@@ -22,7 +22,7 @@
#include <sys/device.h>
#include <sys/evcount.h>
#include <machine/bus.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
#include "intc.h"
/* registers */
@@ -89,8 +89,6 @@
#define INTC_STD_PRI 32
#define INTC_MAX_PRI 0
-#define INTC_SIZE 0x200
-
#define NIRQ INTC_NUM_IRQ
struct intrhand {
@@ -119,7 +117,6 @@ u_int32_t intc_imask[3][NIPL];
bus_space_tag_t intc_iot;
bus_space_handle_t intc_ioh;
-int intc_match(struct device *, void *, void *);
void intc_attach(struct device *, struct device *, void *);
int intc_spllower(int new);
int intc_splraise(int new);
@@ -127,7 +124,7 @@ void intc_setipl(int new);
void intc_calc_mask(void);
struct cfattach intc_ca = {
- sizeof (struct device), intc_match, intc_attach
+ sizeof (struct device), NULL, intc_attach
};
struct cfdriver intc_cd = {
@@ -136,34 +133,16 @@ struct cfdriver intc_cd = {
int intc_attached = 0;
-int
-intc_match(struct device *parent, void *v, void *aux)
-{
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- break; /* continue trying */
- case BOARD_ID_OMAP4_PANDA:
- return 0; /* not ported yet ??? - different */
- default:
- return 0; /* unknown */
- }
- if (intc_attached != 0)
- return 0;
-
- /* XXX */
- return (1);
-}
-
void
intc_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
+ struct omap_attach_args *oa = args;
int i;
u_int32_t rev;
- intc_iot = aa->aa_iot;
- if (bus_space_map(intc_iot, aa->aa_addr, INTC_SIZE, 0, &intc_ioh))
+ intc_iot = oa->oa_iot;
+ if (bus_space_map(intc_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &intc_ioh))
panic("intc_attach: bus_space_map failed!");
rev = bus_space_read_4(intc_iot, intc_ioh, INTC_REVISION);
diff --git a/sys/arch/beagle/dev/omap.c b/sys/arch/beagle/dev/omap.c
new file mode 100644
index 00000000000..3eb1b2b2172
--- /dev/null
+++ b/sys/arch/beagle/dev/omap.c
@@ -0,0 +1,187 @@
+/* $OpenBSD: omap.c,v 1.1 2011/11/10 19:37:01 uwe Exp $ */
+/*
+ * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/reboot.h>
+#define _ARM32_BUS_DMA_PRIVATE
+#include <machine/bus.h>
+#include <arch/arm/armv7/armv7var.h>
+#include <beagle/dev/omapvar.h>
+
+struct arm32_bus_dma_tag omap_bus_dma_tag = {
+ 0,
+ 0,
+ NULL,
+ _bus_dmamap_create,
+ _bus_dmamap_destroy,
+ _bus_dmamap_load,
+ _bus_dmamap_load_mbuf,
+ _bus_dmamap_load_uio,
+ _bus_dmamap_load_raw,
+ _bus_dmamap_unload,
+ _bus_dmamap_sync,
+ _bus_dmamem_alloc,
+ _bus_dmamem_free,
+ _bus_dmamem_map,
+ _bus_dmamem_unmap,
+ _bus_dmamem_mmap,
+};
+
+struct board_dev {
+ char *name;
+ int unit;
+};
+
+struct board_dev beagleboard_devs[] = {
+ { "prcm", 0 },
+ { "intc", 0 },
+ { "gptimer", 0 },
+ { "gptimer", 1 },
+ { "omgpio", 0 },
+ { "omgpio", 1 },
+ { "omgpio", 2 },
+ { "omgpio", 3 },
+ { "omgpio", 4 },
+ { "omgpio", 5 },
+ { "ommmc", 0 }, /* HSMMC1 */
+ { "com", 2 }, /* UART3 */
+ { NULL, 0 }
+};
+
+struct board_dev pandaboard_devs[] = {
+ { "ampintc", 0 },
+ { "amptimer", 0 },
+ { "omgpio", 0 },
+ { "omgpio", 1 },
+ { "omgpio", 2 },
+ { "omgpio", 3 },
+ { "omgpio", 4 },
+ { "omgpio", 5 },
+ { "ommmc", 0 }, /* HSMMC1 */
+ { "com", 2 }, /* UART3 */
+ { NULL, 0 }
+};
+
+struct board_dev *board_devs;
+
+struct omap_dev *omap_devs = NULL;
+
+struct omap_softc {
+ struct device sc_dv;
+};
+
+int omap_match(struct device *, void *, void *);
+void omap_attach(struct device *, struct device *, void *);
+int omap_submatch(struct device *, void *, void *);
+
+struct cfattach omap_ca = {
+ sizeof(struct omap_softc), omap_match, omap_attach
+};
+
+struct cfdriver omap_cd = {
+ NULL, "omap", DV_DULL
+};
+
+int
+omap_match(struct device *parent, void *cfdata, void *aux)
+{
+ return (1);
+}
+
+void
+omap_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct board_dev *bd;
+
+ switch (board_id) {
+ case BOARD_ID_OMAP3_BEAGLE:
+ printf(": BeagleBoard\n");
+ omap3_init();
+ board_devs = beagleboard_devs;
+ break;
+ case BOARD_ID_OMAP4_PANDA:
+ printf(": PandaBoard\n");
+ omap4_init();
+ board_devs = pandaboard_devs;
+ break;
+ default:
+ printf("\n");
+ panic("%s: board type 0x%x unknown", __func__, board_id);
+ }
+
+ /* Directly configure on-board devices (dev* in config file). */
+ for (bd = board_devs; bd->name != NULL; bd++) {
+ struct omap_dev *od = omap_find_dev(bd->name, bd->unit);
+ struct omap_attach_args oa;
+
+ if (od == NULL)
+ printf("%s: device %s unit %d not found\n",
+ self->dv_xname, bd->name, bd->unit);
+
+ memset(&oa, 0, sizeof(oa));
+ oa.oa_dev = od;
+ oa.oa_iot = &armv7_bs_tag;
+ oa.oa_dmat = &omap_bus_dma_tag;
+
+ if (config_found_sm(self, &oa, NULL, omap_submatch) == NULL)
+ printf("%s: device %s unit %d not configured\n",
+ self->dv_xname, bd->name, bd->unit);
+ }
+}
+
+/*
+ * We do direct configuration of devices on this SoC "bus", so we
+ * never call the child device's match function at all (it can be
+ * NULL in the struct cfattach).
+ */
+int
+omap_submatch(struct device *parent, void *child, void *aux)
+{
+ struct cfdata *cf = child;
+ struct omap_attach_args *oa = aux;
+
+ if (strcmp(cf->cf_driver->cd_name, oa->oa_dev->name) == 0)
+ return (1);
+
+ /* "These are not the droids you are looking for." */
+ return (0);
+}
+
+void
+omap_set_devs(struct omap_dev *devs)
+{
+ omap_devs = devs;
+}
+
+struct omap_dev *
+omap_find_dev(const char *name, int unit)
+{
+ struct omap_dev *od;
+
+ if (omap_devs == NULL)
+ panic("%s: omap_devs == NULL", __func__);
+
+ for (od = omap_devs; od->name != NULL; od++) {
+ if (od->unit == unit && strcmp(od->name, name) == 0)
+ return (od);
+ }
+
+ return (NULL);
+}
diff --git a/sys/arch/beagle/dev/omap3.c b/sys/arch/beagle/dev/omap3.c
new file mode 100644
index 00000000000..e1c05df6f74
--- /dev/null
+++ b/sys/arch/beagle/dev/omap3.c
@@ -0,0 +1,151 @@
+#include <sys/types.h>
+#include <machine/bus.h>
+
+#include <beagle/dev/omapvar.h>
+
+#define PRCM_ADDR 0x48004000
+#define PRCM_SIZE 0x2000
+
+#define INTC_ADDR 0x48200000
+#define INTC_SIZE 0x200
+
+#define GPTIMERx_SIZE 0x100
+#define GPTIMER1_ADDR 0x48318000
+#define GPTIMER1_IRQ 37
+#define GPTIMER2_ADDR 0x49032000
+#define GPTIMER2_IRQ 38
+
+#define WD_ADDR 0x48314000
+#define WD_SIZE 0x80
+
+#define GPIOx_SIZE 0x1000
+#define GPIO1_ADDR 0x48310000
+#define GPIO2_ADDR 0x49050000
+#define GPIO3_ADDR 0x49052000
+#define GPIO4_ADDR 0x49054000
+#define GPIO5_ADDR 0x49056000
+#define GPIO6_ADDR 0x49058000
+
+#define UARTx_SIZE 0x400
+#define UART3_ADDR 0x49020000
+
+#define HSMMCx_SIZE 0x200
+#define HSMMC1_ADDR 0x4809c000
+#define HSMMC1_IRQ 83
+
+#define USBTLL_ADDR 0x48062000
+#define USBTLL_SIZE 0x1000
+
+struct omap_dev omap3_devs[] = {
+
+ /*
+ * Power, Reset and Clock Manager
+ */
+
+ { .name = "prcm",
+ .unit = 0,
+ .mem = { { PRCM_ADDR, PRCM_SIZE } },
+ },
+
+ /*
+ * Interrupt Controller
+ */
+
+ { .name = "intc",
+ .unit = 0,
+ .mem = { { INTC_ADDR, INTC_SIZE } },
+ },
+
+ /*
+ * General Purpose Timers
+ */
+
+ { .name = "gptimer",
+ .unit = 1, /* XXX see gptimer.c */
+ .mem = { { GPTIMER1_ADDR, GPTIMERx_SIZE } },
+ .irq = { GPTIMER1_IRQ }
+ },
+
+ { .name = "gptimer",
+ .unit = 0, /* XXX see gptimer.c */
+ .mem = { { GPTIMER2_ADDR, GPTIMERx_SIZE } },
+ .irq = { GPTIMER2_IRQ }
+ },
+
+ /*
+ * GPIO
+ */
+
+ { .name = "omgpio",
+ .unit = 0,
+ .mem = { { GPIO1_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 1,
+ .mem = { { GPIO2_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 2,
+ .mem = { { GPIO3_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 3,
+ .mem = { { GPIO4_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 4,
+ .mem = { { GPIO5_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 5,
+ .mem = { { GPIO6_ADDR, GPIOx_SIZE } },
+ },
+
+ /*
+ * Watchdog Timer
+ */
+
+ { .name = "omdog",
+ .unit = 0,
+ .mem = { { WD_ADDR, WD_SIZE } }
+ },
+
+ /*
+ * UART
+ */
+
+ { .name = "com",
+ .unit = 2,
+ .mem = { { UART3_ADDR, UARTx_SIZE } }
+ },
+
+ /*
+ * MMC
+ */
+
+ { .name = "ommmc",
+ .unit = 0,
+ .mem = { { HSMMC1_ADDR, HSMMCx_SIZE } },
+ .irq = { HSMMC1_IRQ }
+ },
+
+ /*
+ * USB
+ */
+
+ { .name = "omusbtll",
+ .unit = 0,
+ .mem = { { USBTLL_ADDR, USBTLL_SIZE } },
+ }
+};
+
+void
+omap3_init(void)
+{
+ omap_set_devs(omap3_devs);
+}
diff --git a/sys/arch/beagle/dev/omap4.c b/sys/arch/beagle/dev/omap4.c
new file mode 100644
index 00000000000..7b50e4d6e52
--- /dev/null
+++ b/sys/arch/beagle/dev/omap4.c
@@ -0,0 +1,111 @@
+#include <sys/types.h>
+#include <machine/bus.h>
+
+#include <beagle/dev/omapvar.h>
+
+#define ICP_ADDR 0x48240100
+#define ICP_SIZE 0x100
+#define ICD_ADDR 0x48241000
+#define ICD_SIZE 0x1000
+
+#define GTIMER_ADDR 0x48240000
+#define GTIMER_SIZE 0x300
+
+#define GPIOx_SIZE 0x1000
+#define GPIO1_ADDR 0x4a310000
+#define GPIO2_ADDR 0x48055000
+#define GPIO3_ADDR 0x48057000
+#define GPIO4_ADDR 0x48059000
+#define GPIO5_ADDR 0x4805b000
+#define GPIO6_ADDR 0x4805d000
+
+#define UARTx_SIZE 0x400
+#define UART3_ADDR 0x48020000
+
+#define HSMMCx_SIZE 0x300
+#define HSMMC1_ADDR 0x4809c000
+#define HSMMC1_IRQ 83
+
+struct omap_dev omap4_devs[] = {
+
+ /*
+ * Cortex-A9 Interrupt Controller
+ */
+
+ { .name = "ampintc",
+ .unit = 0,
+ .mem = {
+ { ICP_ADDR, ICD_SIZE },
+ { ICD_ADDR, ICD_SIZE },
+ },
+ },
+
+ /*
+ * Cortex-A9 Global Timer
+ */
+
+ { .name = "amptimer",
+ .unit = 0,
+ .mem = { { GTIMER_ADDR, GTIMER_SIZE } },
+ },
+
+ /*
+ * GPIO
+ */
+
+ { .name = "omgpio",
+ .unit = 0,
+ .mem = { { GPIO1_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 1,
+ .mem = { { GPIO2_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 2,
+ .mem = { { GPIO3_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 3,
+ .mem = { { GPIO4_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 4,
+ .mem = { { GPIO5_ADDR, GPIOx_SIZE } },
+ },
+
+ { .name = "omgpio",
+ .unit = 5,
+ .mem = { { GPIO6_ADDR, GPIOx_SIZE } },
+ },
+
+ /*
+ * UART
+ */
+
+ { .name = "com",
+ .unit = 2,
+ .mem = { { UART3_ADDR, UARTx_SIZE } }
+ },
+
+ /*
+ * MMC
+ */
+
+ { .name = "ommmc",
+ .unit = 0,
+ .mem = { { HSMMC1_ADDR, HSMMCx_SIZE } },
+ .irq = { HSMMC1_IRQ }
+ }
+
+};
+
+void
+omap4_init(void)
+{
+ omap_set_devs(omap4_devs);
+}
diff --git a/sys/arch/beagle/dev/omap_com.c b/sys/arch/beagle/dev/omap_com.c
index e2dcc307a0c..0d1e4f8196c 100644
--- a/sys/arch/beagle/dev/omap_com.c
+++ b/sys/arch/beagle/dev/omap_com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omap_com.c,v 1.8 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: omap_com.c,v 1.9 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
* All rights reserved.
@@ -50,85 +50,39 @@
/* pick up armv7_a4x_bs_tag */
#include <arch/arm/armv7/armv7var.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
#define com_isr 8
#define ISR_RECV (ISR_RXPL | ISR_XMODE | ISR_RCVEIR)
-int omapuart_match(struct device *, void *, void *);
void omapuart_attach(struct device *, struct device *, void *);
int omapuart_activate(struct device *, int);
-struct cfattach com_ahb_ca = {
- sizeof (struct com_softc), omapuart_match, omapuart_attach, NULL,
+struct cfattach com_omap_ca = {
+ sizeof (struct com_softc), NULL, omapuart_attach, NULL,
omapuart_activate
};
-int
-omapuart_match(struct device *parent, void *cf, void *aux)
-{
- struct ahb_attach_args *aa = aux;
- extern uint32_t board_id;
- int rv = 0;
-
- /* XXX */
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- if (aa->aa_addr == 0x4806A000 && aa->aa_intr == 72) {
- rv = 1;
- break;
- }
- if (aa->aa_addr == 0x4806C000 && aa->aa_intr == 73) {
- rv = 1;
- break;
- }
- if (aa->aa_addr == 0x49020000 && aa->aa_intr == 74) {
- rv = 1;
- break;
- }
- break;
- case BOARD_ID_OMAP4_PANDA:
- if (aa->aa_addr == 0x4806A000 && aa->aa_intr == 72) {
- rv = 1;
- break;
- }
- if (aa->aa_addr == 0x4806C000 && aa->aa_intr == 73) {
- rv = 1;
- break;
- }
- if (aa->aa_addr == 0x48020000 && aa->aa_intr == 74) {
- rv = 1;
- break;
- }
- if (aa->aa_addr == 0x4806E000 && aa->aa_intr == 70) {
- rv = 1;
- break;
- }
- break;
- default:
- printf("unknown boardid %d", board_id);
- }
-
- return (rv);
-}
-
void
omapuart_attach(struct device *parent, struct device *self, void *aux)
{
struct com_softc *sc = (struct com_softc *)self;
- struct ahb_attach_args *aa = aux;
+ struct omap_attach_args *oa = aux;
sc->sc_iot = &armv7_a4x_bs_tag; /* XXX: This sucks */
- sc->sc_iobase = aa->aa_addr;
+ sc->sc_iobase = oa->oa_dev->mem[0].addr;
sc->sc_frequency = 48000000;
sc->sc_uarttype = COM_UART_TI16750;
- bus_space_map(sc->sc_iot, sc->sc_iobase, aa->aa_size, 0, &sc->sc_ioh);
+ if (bus_space_map(sc->sc_iot, sc->sc_iobase,
+ oa->oa_dev->mem[0].size, 0, &sc->sc_ioh)) {
+ printf("%s: bus_space_map failed\n", __func__);
+ return;
+ }
com_attach_subr(sc);
- (void)arm_intr_establish(aa->aa_intr, IPL_TTY, comintr,
+ (void)arm_intr_establish(oa->oa_dev->irq[0], IPL_TTY, comintr,
sc, sc->sc_dev.dv_xname);
}
diff --git a/sys/arch/beagle/dev/omapvar.h b/sys/arch/beagle/dev/omapvar.h
new file mode 100644
index 00000000000..9be030434f7
--- /dev/null
+++ b/sys/arch/beagle/dev/omapvar.h
@@ -0,0 +1,56 @@
+/* $OpenBSD: omapvar.h,v 1.1 2011/11/10 19:37:01 uwe Exp $ */
+/*
+ * Copyright (c) 2005,2008 Dale Rahn <drahn@drahn.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Physical memory range for on-chip devices. */
+struct omap_mem {
+ u_int32_t addr; /* physical start address */
+ u_int32_t size; /* size of range in bytes */
+};
+
+#define OMAP_DEV_NMEM 4 /* number of memory ranges */
+#define OMAP_DEV_NIRQ 4 /* number of IRQs per device */
+
+/* Descriptor for all on-chip devices. */
+struct omap_dev {
+ char *name; /* driver name or made up name */
+ int unit; /* driver instance number or -1 */
+ struct omap_mem mem[OMAP_DEV_NMEM]; /* memory ranges */
+ int irq[OMAP_DEV_NIRQ]; /* IRQ number(s) */
+};
+
+/* Passed as third arg to attach functions. */
+struct omap_attach_args {
+ struct omap_dev *oa_dev;
+ bus_space_tag_t oa_iot;
+ bus_dma_tag_t oa_dmat;
+};
+
+void omap_set_devs(struct omap_dev *);
+struct omap_dev *omap_find_dev(const char *, int);
+
+void omap3_init(void);
+void omap4_init(void);
+
+/* XXX */
+void *avic_intr_establish(int irqno, int level, int (*func)(void *),
+ void *arg, char *name);
+
+/* board identification - from uboot */
+#define BOARD_ID_OMAP3_BEAGLE 1546
+#define BOARD_ID_OMAP3_OVERO 1798
+#define BOARD_ID_OMAP4_PANDA 2791
+extern uint32_t board_id;
diff --git a/sys/arch/beagle/dev/omdisplay.c b/sys/arch/beagle/dev/omdisplay.c
index 46754eddbcf..0426dfeec3c 100644
--- a/sys/arch/beagle/dev/omdisplay.c
+++ b/sys/arch/beagle/dev/omdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omdisplay.c,v 1.6 2011/10/24 22:49:07 drahn Exp $ */
+/* $OpenBSD: omdisplay.c,v 1.7 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007 Dale Rahn <drahn@openbsd.org>
*
@@ -24,8 +24,8 @@
#include <sys/conf.h>
#include <sys/uio.h>
#include <machine/bus.h>
-#include <arch/beagle/beagle/ahb.h>
-#include <arch/beagle/dev/omgpiovar.h>
+#include <beagle/dev/omapvar.h>
+#include <beagle/dev/omgpiovar.h>
#include <dev/cons.h>
#include <dev/wscons/wsconsio.h>
diff --git a/sys/arch/beagle/dev/omdog.c b/sys/arch/beagle/dev/omdog.c
index e8409cdaf91..af67391a7e2 100644
--- a/sys/arch/beagle/dev/omdog.c
+++ b/sys/arch/beagle/dev/omdog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omdog.c,v 1.3 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: omdog.c,v 1.4 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@@ -25,8 +25,8 @@
#include <sys/timeout.h>
#include <machine/intr.h>
#include <machine/bus.h>
-#include <arch/beagle/beagle/ahb.h>
-#include <arch/beagle/dev/omgpiovar.h>
+#include <beagle/dev/omapvar.h>
+#include <beagle/dev/omgpiovar.h>
/* registers */
#define WIDR 0x00
@@ -41,7 +41,6 @@
#define WWPS 0x34
#define WWPS_PEND_ALL 0x1f
#define WSPR 0x48
-#define WD_SIZE 0x80
struct omdog_softc {
@@ -57,43 +56,27 @@ struct omdog_softc *omdog_sc;
* to disable the watchdog, write 0xXXXXaaaa then 0xXXXX5555 to WSPR
*/
-
-int omdog_match(struct device *parent, void *v, void *aux);
void omdog_attach(struct device *parent, struct device *self, void *args);
void omdog_wpending(int flags);
struct cfattach omdog_ca = {
- sizeof (struct omdog_softc), omdog_match, omdog_attach
+ sizeof (struct omdog_softc), NULL, omdog_attach
};
struct cfdriver omdog_cd = {
NULL, "omdog", DV_DULL
};
-int
-omdog_match(struct device *parent, void *v, void *aux)
-{
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- break; /* continue trying */
- case BOARD_ID_OMAP4_PANDA:
- return 0; /* not ported yet */
- default:
- return 0; /* unknown */
- }
- return (1);
-}
-
void
omdog_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
+ struct omap_attach_args *oa = args;
struct omdog_softc *sc = (struct omdog_softc *) self;
u_int32_t rev;
- sc->sc_iot = aa->aa_iot;
- if (bus_space_map(sc->sc_iot, aa->aa_addr, WD_SIZE, 0, &sc->sc_ioh))
+ sc->sc_iot = oa->oa_iot;
+ if (bus_space_map(sc->sc_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &sc->sc_ioh))
panic("gptimer_attach: bus_space_map failed!");
rev = bus_space_read_4(sc->sc_iot, sc->sc_ioh, WIDR);
diff --git a/sys/arch/beagle/dev/omehci.c b/sys/arch/beagle/dev/omehci.c
index 13cf9bc9160..107d82a8570 100644
--- a/sys/arch/beagle/dev/omehci.c
+++ b/sys/arch/beagle/dev/omehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omehci.c,v 1.9 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: omehci.c,v 1.10 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -31,7 +31,7 @@
#include <dev/usb/usbdivar.h>
#include <dev/usb/usb_mem.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
#include <beagle/dev/prcmvar.h>
#include <dev/usb/ehcireg.h>
@@ -39,7 +39,6 @@
#define EHCI_HCPCAPBASE 0x48064800
-int omehci_match(struct device *, void *, void *);
void omehci_attach(struct device *, struct device *, void *);
int omehci_detach(struct device *, int);
int omehci_activate(struct device *, int);
@@ -53,50 +52,28 @@ void omehci_enable(struct omehci_softc *);
void omehci_disable(struct omehci_softc *);
struct cfattach omehci_ca = {
- sizeof (struct omehci_softc), omehci_match, omehci_attach,
+ sizeof (struct omehci_softc), NULL, omehci_attach,
omehci_detach, omehci_activate
};
-int
-omehci_match(struct device *parent, void *match, void *aux)
-{
- struct ahb_attach_args *aa = aux;
-
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- break; /* continue trying */
- case BOARD_ID_OMAP4_PANDA:
- return 0; /* not ported yet ??? - different */
- default:
- return 0; /* unknown */
- }
- if (aa->aa_addr != EHCI_HCPCAPBASE)
- return 0;
-
- return (1);
-}
-
void
omehci_attach(struct device *parent, struct device *self, void *aux)
{
struct omehci_softc *sc = (struct omehci_softc *)self;
- struct ahb_attach_args *aa = aux;
+ struct omap_attach_args *oa = aux;
usbd_status r;
char *devname = sc->sc.sc_bus.bdev.dv_xname;
-
- sc->sc.iot = aa->aa_iot;
- sc->sc.sc_bus.dmatag = aa->aa_dmat;
- sc->sc.sc_size = 0;
+ sc->sc.iot = oa->oa_iot;
+ sc->sc.sc_bus.dmatag = oa->oa_dmat;
+ sc->sc.sc_size = oa->oa_dev->mem[0].size;
/* Map I/O space */
- if (bus_space_map(sc->sc.iot, aa->aa_addr, aa->aa_size, 0,
- &sc->sc.ioh)) {
+ if (bus_space_map(sc->sc.iot, oa->oa_dev->mem[0].addr,
+ sc->sc.sc_size, 0, &sc->sc.ioh)) {
printf(": cannot map mem space\n");
return;
}
- sc->sc.sc_size = aa->aa_size;
/* XXX copied from ohci_pci.c. needed? */
bus_space_barrier(sc->sc.iot, sc->sc.ioh, 0, sc->sc.sc_size,
@@ -112,7 +89,7 @@ omehci_attach(struct device *parent, struct device *self, void *aux)
sc->sc.sc_offs = EREAD1(&sc->sc, EHCI_CAPLENGTH);
EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
- sc->sc_ih = arm_intr_establish(aa->aa_intr, IPL_USB,
+ sc->sc_ih = arm_intr_establish(oa->oa_dev->irq[0], IPL_USB,
ehci_intr, &sc->sc, devname);
if (sc->sc_ih == NULL) {
printf(": unable to establish interrupt\n");
diff --git a/sys/arch/beagle/dev/omgpio.c b/sys/arch/beagle/dev/omgpio.c
index 1f55d1fa2bf..827aebc090d 100644
--- a/sys/arch/beagle/dev/omgpio.c
+++ b/sys/arch/beagle/dev/omgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omgpio.c,v 1.7 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: omgpio.c,v 1.8 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@@ -27,9 +27,8 @@
#include <machine/bus.h>
#include <machine/intr.h>
-#include <arch/beagle/beagle/ahb.h>
-#include <arch/beagle/dev/omgpiovar.h>
-#include "omgpio.h"
+#include <beagle/dev/omapvar.h>
+#include <beagle/dev/omgpiovar.h>
/* registers */
@@ -121,19 +120,20 @@ omgpio_match(struct device *parent, void *v, void *aux)
void
omgpio_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
+ struct omap_attach_args *oa = args;
struct omgpio_softc *sc = (struct omgpio_softc *) self;
u_int32_t rev;
- sc->sc_iot = aa->aa_iot;
- if (bus_space_map(sc->sc_iot, aa->aa_addr, GPIO_SIZE, 0, &sc->sc_ioh))
+ sc->sc_iot = oa->oa_iot;
+ if (bus_space_map(sc->sc_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &sc->sc_ioh))
panic("omgpio_attach: bus_space_map failed!");
rev = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_REVISION);
printf(" rev %d.%d\n", rev >> 4 & 0xf, rev & 0xf);
- sc->sc_irq = aa->aa_intr;
+ sc->sc_irq = oa->oa_dev->irq[0];
bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_CLEARIRQENABLE1, ~0);
@@ -318,7 +318,7 @@ omgpio_intr_establish(unsigned int gpio, int level, int spl,
* which is 96 + gpio pin?
*/
- if (GPIO_PIN_TO_INST(gpio) > NOMGPIO)
+ if (GPIO_PIN_TO_INST(gpio) > omgpio_cd.cd_ndevs)
panic("omgpio_intr_establish: bogus irqnumber %d: %s",
gpio, name);
diff --git a/sys/arch/beagle/dev/ommmc.c b/sys/arch/beagle/dev/ommmc.c
index 4993977a370..b7241965189 100644
--- a/sys/arch/beagle/dev/ommmc.c
+++ b/sys/arch/beagle/dev/ommmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ommmc.c,v 1.12 2011/11/10 00:34:20 drahn Exp $ */
+/* $OpenBSD: ommmc.c,v 1.13 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2009 Dale Rahn <drahn@openbsd.org>
@@ -28,11 +28,12 @@
#include <sys/systm.h>
#include <machine/bus.h>
-#include <arch/beagle/dev/prcmvar.h>
-#include <arch/beagle/beagle/ahb.h>
#include <dev/sdmmc/sdmmcchip.h>
#include <dev/sdmmc/sdmmcvar.h>
+#include <beagle/dev/omapvar.h>
+#include <beagle/dev/prcmvar.h>
+
#define MMCHS1_ADDR 0x4809C000
#define MMCHS2_ADDR 0x480B4000
#define MMCHS3_ADDR 0x480AD000
@@ -174,13 +175,12 @@
#define MMCHS_CAPA_MBL_SHIFT 16
#define MMCHS_CAPA_MBL_MASK (3 << MMCHS_CAPA_MBL_SHIFT)
#define MMCHS_CUR_CAPA 0x148
-#define MMCHS_SIZE 0x200
+#define MMCHS_REV 0x1fc
#define SDHC_COMMAND_TIMEOUT hz
#define SDHC_BUFFER_TIMEOUT hz
#define SDHC_TRANSFER_TIMEOUT hz
-int ommmc_match(struct device *parent, void *v, void *aux);
void ommmc_attach(struct device *parent, struct device *self, void *args);
#include <machine/bus.h>
@@ -189,7 +189,6 @@ struct ommmc_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
- int sc_irq;
void *sc_ih; /* Interrupt handler */
u_int sc_flags;
@@ -348,62 +347,38 @@ struct cfdriver ommmc_cd = {
};
struct cfattach ommmc_ca = {
- sizeof(struct ommmc_softc), ommmc_match, ommmc_attach
+ sizeof(struct ommmc_softc), NULL, ommmc_attach
};
-
-int
-ommmc_match(struct device *parent, void *v, void *aux)
-{
- /* XXX */
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- return 1;
- case BOARD_ID_OMAP4_PANDA:
- return 1;
- default:
- return 0; /* unknown */
- }
- return (0);
-}
-
void
ommmc_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
struct ommmc_softc *sc = (struct ommmc_softc *) self;
+ struct omap_attach_args *oa = args;
struct sdmmcbus_attach_args saa;
int baseaddr;
int error = 1;
/* XXX - ICLKEN, FCLKEN? */
- baseaddr = aa->aa_addr;
+ baseaddr = oa->oa_dev->mem[0].addr;
if (board_id == BOARD_ID_OMAP4_PANDA) {
/* omap4430 has mmc registers offset +0x100, but not revision */
baseaddr += 0x100;
}
- sc->sc_iot = aa->aa_iot;
- if (bus_space_map(sc->sc_iot, baseaddr, MMCHS_SIZE, 0, &sc->sc_ioh))
+ sc->sc_iot = oa->oa_iot;
+ if (bus_space_map(sc->sc_iot, baseaddr, oa->oa_dev->mem[0].size,
+ 0, &sc->sc_ioh))
panic("omgpio_attach: bus_space_map failed!");
printf("\n");
- sc->sc_irq = aa->aa_intr;
- if (aa->aa_addr == MMCHS1_ADDR)
- sc->clockbit = PRCM_CLK_EN_MMC1;
- else if (aa->aa_addr == MMCHS2_ADDR)
- sc->clockbit = PRCM_CLK_EN_MMC2;
- else if (aa->aa_addr == MMCHS3_ADDR)
- sc->clockbit = PRCM_CLK_EN_MMC3;
-
/* XXX DMA channels? */
- prcm_enableclock(sc->clockbit);
+ /* FIXME prcm_enableclock(sc->clockbit); */
- sc->sc_ih = arm_intr_establish(sc->sc_irq, IPL_SDMMC, ommmc_intr,
- sc, sc->sc_dev.dv_xname);
+ sc->sc_ih = arm_intr_establish(oa->oa_dev->irq[0], IPL_SDMMC,
+ ommmc_intr, sc, sc->sc_dev.dv_xname);
#if 0
/* XXX - IIRC firmware should set this */
diff --git a/sys/arch/beagle/dev/omohci.c b/sys/arch/beagle/dev/omohci.c
index 482042f4f6c..8fd8dbab0b3 100644
--- a/sys/arch/beagle/dev/omohci.c
+++ b/sys/arch/beagle/dev/omohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omohci.c,v 1.5 2011/10/24 22:49:07 drahn Exp $ */
+/* $OpenBSD: omohci.c,v 1.6 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -32,7 +32,7 @@
#include <dev/usb/ohcireg.h>
#include <dev/usb/ohcivar.h>
-#include <arch/beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
#include <beagle/dev/prcmvar.h>
#define HOSTUEADDR 0x0E0
diff --git a/sys/arch/beagle/dev/omusbtll.c b/sys/arch/beagle/dev/omusbtll.c
index 5442683d0e3..91d96162a4b 100644
--- a/sys/arch/beagle/dev/omusbtll.c
+++ b/sys/arch/beagle/dev/omusbtll.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omusbtll.c,v 1.3 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: omusbtll.c,v 1.4 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2010 Dale Rahn <drahn@openbsd.org>
*
@@ -23,10 +23,8 @@
#include <sys/evcount.h>
#include <machine/bus.h>
#include <machine/intr.h>
-#include <arch/beagle/beagle/ahb.h>
-#include <arch/beagle/dev/prcmvar.h>
-#include "omgpio.h"
-
+#include <beagle/dev/omapvar.h>
+#include <beagle/dev/prcmvar.h>
/* registers */
#define USBTLL_REVISION 0x0000
@@ -86,54 +84,34 @@ ULPI_USB_INT_STATUS_(i) (0x0813 + (0x100 * (i)))
ULPI_USB_INT_LATCH_(i) (0x0814 + (0x100 * (i)))
*/
-
-#define USBTLL_SIZE 0x1000
-
struct omusbtll_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
};
-int omusbtll_match(struct device *parent, void *v, void *aux);
void omusbtll_attach(struct device *parent, struct device *self, void *args);
void omusbtll_init(uint32_t channel_mask);
struct cfattach omusbtll_ca = {
- sizeof (struct omusbtll_softc), omusbtll_match, omusbtll_attach
+ sizeof (struct omusbtll_softc), NULL, omusbtll_attach
};
struct cfdriver omusbtll_cd = {
NULL, "omusbtll", DV_DULL
};
-int
-omusbtll_match(struct device *parent, void *v, void *aux)
-{
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- break; /* continue trying */
- case BOARD_ID_OMAP4_PANDA:
- return 0; /* not ported yet ??? - different */
- default:
- return 0; /* unknown */
- }
- return (1);
-}
-
struct omusbtll_softc *omusbtll_sc;
void
omusbtll_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
struct omusbtll_softc *sc = (struct omusbtll_softc *) self;
+ struct omap_attach_args *oa = args;
u_int32_t rev;
- sc->sc_iot = aa->aa_iot;
- printf("addr %x\n", aa->aa_addr);
- if (bus_space_map(sc->sc_iot, aa->aa_addr, USBTLL_SIZE, 0,
- &sc->sc_ioh)) {
+ sc->sc_iot = oa->oa_iot;
+ if (bus_space_map(sc->sc_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &sc->sc_ioh)) {
printf("omgpio_attach: bus_space_map failed!\n");
return;
}
diff --git a/sys/arch/beagle/dev/prcm.c b/sys/arch/beagle/dev/prcm.c
index fd883a1d2cd..538df01e731 100644
--- a/sys/arch/beagle/dev/prcm.c
+++ b/sys/arch/beagle/dev/prcm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: prcm.c,v 1.8 2011/11/10 00:19:36 matthieu Exp $ */
+/* $OpenBSD: prcm.c,v 1.9 2011/11/10 19:37:01 uwe Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@@ -29,7 +29,7 @@
#include <machine/bus.h>
#include <machine/intr.h>
#include <arm/cpufunc.h>
-#include <beagle/beagle/ahb.h>
+#include <beagle/dev/omapvar.h>
#include <beagle/dev/prcmvar.h>
#define CM_FCLKEN_IVA2 0x0000
@@ -154,59 +154,38 @@ uint32_t prcm_fmask_mask[PRCM_REG_MAX];
uint32_t prcm_imask_addr[PRCM_REG_MAX];
uint32_t prcm_fmask_addr[PRCM_REG_MAX];
-#define PRCM_SIZE 0x2000
-
#define SYS_CLK 13 /* SYS_CLK speed in MHz */
bus_space_tag_t prcm_iot;
bus_space_handle_t prcm_ioh;
-int prcm_attached;
int prcm_match(struct device *, void *, void *);
void prcm_attach(struct device *, struct device *, void *);
int prcm_setup_dpll5(void);
struct cfattach prcm_ca = {
- sizeof (struct device), prcm_match, prcm_attach
+ sizeof (struct device), NULL, prcm_attach
};
struct cfdriver prcm_cd = {
NULL, "prcm", DV_DULL
};
-int
-prcm_match(struct device *parent, void *v, void *aux)
-{
- /* only attach once */
- switch (board_id) {
- case BOARD_ID_OMAP3_BEAGLE:
- case BOARD_ID_OMAP3_OVERO:
- break; /* continue trying */
- case BOARD_ID_OMAP4_PANDA:
- return 0; /* not ported yet */
- default:
- return 0; /* unknown */
- }
- if (prcm_attached != 0)
- return (0);
- return (1);
-}
-
void
prcm_attach(struct device *parent, struct device *self, void *args)
{
- struct ahb_attach_args *aa = args;
- prcm_iot = aa->aa_iot;
+ struct omap_attach_args *oa = args;
u_int32_t reg;
- if (bus_space_map(prcm_iot, aa->aa_addr, PRCM_SIZE, 0, &prcm_ioh))
+ prcm_iot = oa->oa_iot;
+
+ if (bus_space_map(prcm_iot, oa->oa_dev->mem[0].addr,
+ oa->oa_dev->mem[0].size, 0, &prcm_ioh))
panic("prcm_attach: bus_space_map failed!");
reg = bus_space_read_4(prcm_iot, prcm_ioh, PRCM_REVISION);
printf(" rev %d.%d\n", reg >> 4 & 0xf, reg & 0xf);
- prcm_attached = 1;
-
/* Setup the 120MHZ DPLL5 clock, to be used by USB. */
prcm_setup_dpll5();