Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Initial commit of support for the RaspberryPI (www....



details:   https://anonhg.NetBSD.org/src/rev/387212be504f
branches:  trunk
changeset: 780462:387212be504f
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Jul 26 06:21:57 2012 +0000

description:
Initial commit of support for the RaspberryPI (www.raspberrypi.org)

This is enough for serial console via the gpio header pins and to get to
multiuser.

A huge thank you to Matt Thomas for all his help.

diffstat:

 sys/arch/arm/broadcom/bcm2835_dma.c   |   61 ++
 sys/arch/arm/broadcom/bcm2835_emmc.c  |  130 +++++
 sys/arch/arm/broadcom/bcm2835_intr.c  |  250 ++++++++++
 sys/arch/arm/broadcom/bcm2835_intr.h  |   55 ++
 sys/arch/arm/broadcom/bcm2835_obio.c  |  197 ++++++++
 sys/arch/arm/broadcom/bcm2835_plcom.c |   98 ++++
 sys/arch/arm/broadcom/bcm2835_pm.c    |  125 +++++
 sys/arch/arm/broadcom/bcm2835_pmvar.h |   37 +
 sys/arch/arm/broadcom/bcm2835_space.c |  391 ++++++++++++++++
 sys/arch/arm/broadcom/bcm2835_tmr.c   |  231 +++++++++
 sys/arch/arm/broadcom/bcm2835reg.h    |  115 ++++
 sys/arch/arm/broadcom/bcm2835var.h    |   44 +
 sys/arch/arm/broadcom/bcm_amba.h      |   29 +
 sys/arch/arm/broadcom/files.bcm2835   |   46 +
 sys/arch/evbarm/Makefile              |    4 +-
 sys/arch/evbarm/conf/RPI              |  242 +++++++++
 sys/arch/evbarm/conf/files.rpi        |   13 +
 sys/arch/evbarm/conf/mk.rpi           |   17 +
 sys/arch/evbarm/conf/std.rpi          |   25 +
 sys/arch/evbarm/rpi/genassym.cf       |   36 +
 sys/arch/evbarm/rpi/rpi.h             |   50 ++
 sys/arch/evbarm/rpi/rpi_machdep.c     |  829 ++++++++++++++++++++++++++++++++++
 sys/arch/evbarm/rpi/rpi_start.S       |  329 +++++++++++++
 23 files changed, 3353 insertions(+), 1 deletions(-)

diffs (truncated from 3463 to 300 lines):

diff -r 7e3d505ac2ff -r 387212be504f sys/arch/arm/broadcom/bcm2835_dma.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_dma.c       Thu Jul 26 06:21:57 2012 +0000
@@ -0,0 +1,61 @@
+/*     $NetBSD: bcm2835_dma.c,v 1.1 2012/07/26 06:21:57 skrll Exp $    */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_dma.c,v 1.1 2012/07/26 06:21:57 skrll Exp $");
+
+#define _ARM32_BUS_DMA_PRIVATE
+
+#include <sys/param.h>
+#include <sys/bus.h>
+
+struct arm32_bus_dma_tag bcm2835_bus_dma_tag = {
+       NULL,                   /* _ranges: set by platform specific routine */
+       0,                      /* _nranges */
+
+       NULL,                   /* _cookie */
+
+       _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,
+       NULL,                   /* sync_post */
+
+       _bus_dmamem_alloc,
+       _bus_dmamem_free,
+       _bus_dmamem_map,
+       _bus_dmamem_unmap,
+       _bus_dmamem_mmap,
+};
diff -r 7e3d505ac2ff -r 387212be504f sys/arch/arm/broadcom/bcm2835_emmc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_emmc.c      Thu Jul 26 06:21:57 2012 +0000
@@ -0,0 +1,130 @@
+/*     $NetBSD: bcm2835_emmc.c,v 1.1 2012/07/26 06:21:57 skrll Exp $   */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_emmc.c,v 1.1 2012/07/26 06:21:57 skrll Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+
+#include <arm/broadcom/bcm2835reg.h>
+#include <arm/broadcom/bcm_amba.h>
+
+#include <dev/sdmmc/sdhcreg.h>
+#include <dev/sdmmc/sdhcvar.h>
+#include <dev/sdmmc/sdmmcvar.h>
+
+struct bcmemmc_softc {
+       struct sdhc_softc       sc;
+       device_t                sc_sdmmc;
+
+       bus_space_tag_t         sc_iot;
+       bus_space_handle_t      sc_ioh;
+       struct sdhc_host        *sc_hosts[1];
+       void                    *sc_ih;
+};
+
+static int bcmemmc_match(device_t, struct cfdata *, void *);
+static void bcmemmc_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(bcmemmc, sizeof(struct bcmemmc_softc),
+    bcmemmc_match, bcmemmc_attach, NULL, NULL);
+
+/* ARGSUSED */
+static int
+bcmemmc_match(device_t parent, struct cfdata *match, void *aux)
+{
+       struct amba_attach_args *aaa = aux;
+
+       if (strcmp(aaa->aaa_name, "emmc") != 0)
+               return 0;
+
+       return 1;
+}
+
+/* ARGSUSED */
+static void
+bcmemmc_attach(device_t parent, device_t self, void *aux)
+{
+       struct bcmemmc_softc *sc = device_private(self);
+       struct amba_attach_args *aaa = aux;
+       int error;
+
+       sc->sc.sc_dev = self;
+//     sc->sc.sc_dmat = aaa->amba_dmat;
+       sc->sc.sc_flags = 0;
+//     sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;           /* not available (yet) */
+       sc->sc.sc_flags |= SDHC_FLAG_32BIT_ACCESS;
+       sc->sc.sc_flags |= SDHC_FLAG_HOSTCAPS;
+       sc->sc.sc_caps = SDHC_VOLTAGE_SUPP_3_3V;
+       sc->sc.sc_host = sc->sc_hosts;
+       sc->sc.sc_clkbase = 50000;      /* 50MHz */
+       sc->sc_iot = aaa->aaa_iot;
+
+       error = bus_space_map(sc->sc_iot, aaa->aaa_addr, aaa->aaa_size, 0,
+           &sc->sc_ioh);
+       if (error) {
+               aprint_error_dev(self,
+                   "can't map registers for %s: %d\n", aaa->aaa_name, error);
+               return;
+       }
+
+       aprint_naive(": SDHC controller\n");
+       aprint_normal(": SDHC controller\n");
+
+       sc->sc_ih = bcm2835_intr_establish(aaa->aaa_intr, IPL_SDMMC, sdhc_intr,
+           &sc->sc);
+
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "failed to establish interrupt %d\n",
+                    aaa->aaa_intr);
+               goto fail;
+       }
+       aprint_normal_dev(self, "interrupting on intr %d\n", aaa->aaa_intr);
+
+       error = sdhc_host_found(&sc->sc, sc->sc_iot, sc->sc_ioh,
+           aaa->aaa_size);
+       if (error != 0) {
+               aprint_error_dev(self, "couldn't initialize host, error=%d\n",
+                   error);
+               goto fail;
+       }
+       return;
+
+fail:
+       if (sc->sc_ih) {
+               intr_disestablish(sc->sc_ih);
+               sc->sc_ih = NULL;
+       }
+       bus_space_unmap(sc->sc_iot, sc->sc_ioh, aaa->aaa_size);
+}
diff -r 7e3d505ac2ff -r 387212be504f sys/arch/arm/broadcom/bcm2835_intr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_intr.c      Thu Jul 26 06:21:57 2012 +0000
@@ -0,0 +1,250 @@
+/*     $NetBSD: bcm2835_intr.c,v 1.1 2012/07/26 06:21:57 skrll Exp $   */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.1 2012/07/26 06:21:57 skrll Exp $");
+
+#define _INTR_PRIVATE
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/device.h>
+
+#include <machine/intr.h>
+#include <sys/bus.h>
+
+#include <arm/pic/picvar.h>
+
+#include <arm/broadcom/bcm_amba.h>
+#include <arm/broadcom/bcm2835reg.h>
+
+static void bcm2835_pic_unblock_irqs(struct pic_softc *, size_t, uint32_t);
+static void bcm2835_pic_block_irqs(struct pic_softc *, size_t, uint32_t);
+static int bcm2835_pic_find_pending_irqs(struct pic_softc *);
+static void bcm2835_pic_establish_irq(struct pic_softc *, struct intrsource *);
+static void bcm2835_pic_source_name(struct pic_softc *, int, char *,
+    size_t);
+
+static int  bcm2835_icu_match(device_t, cfdata_t, void *);
+static void bcm2835_icu_attach(device_t, device_t, void *);
+
+static struct pic_ops bcm2835_picops = {
+       .pic_unblock_irqs = bcm2835_pic_unblock_irqs,
+       .pic_block_irqs = bcm2835_pic_block_irqs,
+       .pic_find_pending_irqs = bcm2835_pic_find_pending_irqs,
+       .pic_establish_irq = bcm2835_pic_establish_irq,
+       .pic_source_name = bcm2835_pic_source_name,
+};
+
+struct pic_softc bcm2835_pic = {
+       .pic_ops = &bcm2835_picops,
+       .pic_maxsources = BCM2835_NIRQ,
+       .pic_name = "bcm2835 pic",
+};
+
+struct bcm2835icu_softc {
+       device_t                sc_dev;
+       bus_space_tag_t         sc_iot;
+       bus_space_handle_t      sc_ioh;
+       struct pic_softc        *sc_pic;
+};
+
+struct bcm2835icu_softc *bcmicu_sc;
+       
+#define read_bcm2835reg(o)     \
+       bus_space_read_4(bcmicu_sc->sc_iot, bcmicu_sc->sc_ioh, (o))
+       
+#define write_bcm2835reg(o, v) \
+       bus_space_write_4(bcmicu_sc->sc_iot, bcmicu_sc->sc_ioh, (o), (v))
+
+
+#define bcm2835_barrier() \
+       bus_space_barrier(bcmicu_sc->sc_iot, bcmicu_sc->sc_ioh, 0, \
+           BCM2835_ARMICU_SIZE, BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
+       
+static const char * const bcm2835_sources[BCM2835_NIRQ] = {
+       "(unused  0)",  "(unused  1)",  "(unused  2)",  "timer3",
+       "(unused  4)",  "(unused  5)",  "(unused  6)",  "jpeg",
+       "(unused  8)",  "usb",          "(unused 10)",  "(unused 11)"
+       "(unused 12)",  "(unused 13)",  "(unused 14)",  "(unused 15)"



Home | Main Index | Thread Index | Old Index