Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Very very very prelimnary support for cubieboard 1 ...
details: https://anonhg.NetBSD.org/src/rev/349b4741ede5
branches: trunk
changeset: 789704:349b4741ede5
user: matt <matt%NetBSD.org@localhost>
date: Wed Sep 04 02:39:01 2013 +0000
description:
Very very very prelimnary support for cubieboard 1 & 2 based on the
Allwinner A10 & A20 SoCs. It links and that's about all it does.
Many drivers are stubs with autoconf glue.
com, ahcisata, sdhc, usb might have a chance of working.
diffstat:
sys/arch/arm/allwinner/awin_ahcisata.c | 110 ++++++++
sys/arch/arm/allwinner/awin_board.c | 179 ++++++++++++++
sys/arch/arm/allwinner/awin_com.c | 123 +++++++++
sys/arch/arm/allwinner/awin_eth.c | 87 ++++++
sys/arch/arm/allwinner/awin_gige.c | 87 ++++++
sys/arch/arm/allwinner/awin_gpio.c | 85 ++++++
sys/arch/arm/allwinner/awin_icu.c | 89 +++++++
sys/arch/arm/allwinner/awin_intr.h | 4 +-
sys/arch/arm/allwinner/awin_io.c | 180 ++++++++++++++
sys/arch/arm/allwinner/awin_nand.c | 87 ++++++
sys/arch/arm/allwinner/awin_reg.h | 13 +-
sys/arch/arm/allwinner/awin_sdhc.c | 132 ++++++++++
sys/arch/arm/allwinner/awin_space.c | 419 +++++++++++++++++++++++++++++++++
sys/arch/arm/allwinner/awin_tmr.c | 89 +++++++
sys/arch/arm/allwinner/awin_twi.c | 87 ++++++
sys/arch/arm/allwinner/awin_usb.c | 311 ++++++++++++++++++++++++
sys/arch/arm/allwinner/awin_var.h | 32 ++-
sys/arch/arm/allwinner/awin_wdc.c | 133 ++++++++++
sys/arch/arm/allwinner/awin_wdt.c | 95 +++++++
sys/arch/arm/allwinner/files.awin | 65 ++--
sys/arch/evbarm/conf/CUBIEBOARD | 5 +-
sys/arch/evbarm/cubie/cubie_machdep.c | 157 +-----------
22 files changed, 2380 insertions(+), 189 deletions(-)
diffs (truncated from 2857 to 300 lines):
diff -r 1f81826590b1 -r 349b4741ede5 sys/arch/arm/allwinner/awin_ahcisata.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/allwinner/awin_ahcisata.c Wed Sep 04 02:39:01 2013 +0000
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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 "locators.h"
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(1, "$NetBSD: awin_ahcisata.c,v 1.1 2013/09/04 02:39:01 matt Exp $");
+
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+
+#include <arm/allwinner/awin_reg.h>
+#include <arm/allwinner/awin_var.h>
+
+#include <dev/ata/atavar.h>
+#include <dev/ic/ahcisatavar.h>
+
+static int awin_ahci_match(device_t, cfdata_t, void *);
+static void awin_ahci_attach(device_t, device_t, void *);
+
+struct awin_ahci_softc {
+ struct ahci_softc asc_sc;
+ void *asc_ih;
+};
+
+CFATTACH_DECL_NEW(awin_ahcisata, sizeof(struct awin_ahci_softc),
+ awin_ahci_match, awin_ahci_attach, NULL, NULL);
+
+static int
+awin_ahci_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct awinio_attach_args * const aio = aux;
+ const struct awin_locators * const loc = &aio->aio_loc;
+ const int port = cf->cf_loc[AWINIOCF_PORT];
+
+ if (strcmp(cf->cf_name, loc->loc_name))
+ return 0;
+
+ if (port != AWINIOCF_PORT_DEFAULT && port != loc->loc_port)
+ return 0;
+
+ return 1;
+}
+
+static void
+awin_ahci_attach(device_t parent, device_t self, void *aux)
+{
+ struct awin_ahci_softc * const asc = device_private(self);
+ struct ahci_softc * const sc = &asc->asc_sc;
+ struct awinio_attach_args * const aio = aux;
+ const struct awin_locators * const loc = &aio->aio_loc;
+
+ sc->sc_atac.atac_dev = self;
+ sc->sc_dmat = aio->aio_dmat;
+ sc->sc_ahcit = aio->aio_core_bst;
+ sc->sc_ahcis = loc->loc_size;
+
+ bus_space_subregion(aio->aio_core_bst, aio->aio_core_bsh,
+ loc->loc_offset, loc->loc_size, &sc->sc_ahcih);
+
+ aprint_naive(": AHCI SATA controller\n");
+ aprint_normal(": AHCI SATA controller\n");
+
+ asc->asc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL,
+ ahci_intr, sc);
+ if (asc->asc_ih == NULL) {
+ aprint_error_dev(self, "failed to establish interrupt %d\n",
+ loc->loc_intr);
+ goto fail;
+ }
+ aprint_normal_dev(self, "interrupting on irq %d\n",
+ loc->loc_intr);
+
+ return;
+
+fail:
+ if (asc->asc_ih) {
+ intr_disestablish(asc->asc_ih);
+ asc->asc_ih = NULL;
+ }
+}
diff -r 1f81826590b1 -r 349b4741ede5 sys/arch/arm/allwinner/awin_board.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/allwinner/awin_board.c Wed Sep 04 02:39:01 2013 +0000
@@ -0,0 +1,179 @@
+/* $NetBSD: awin_board.c,v 1.1 2013/09/04 02:39:01 matt Exp $ */
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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 "opt_allwinner.h"
+
+#define _ARM32_BUS_DMA_PRIVATE
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.1 2013/09/04 02:39:01 matt Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+#include <sys/device.h>
+
+#include <prop/proplib.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+
+#include <arm/mainbus/mainbus.h>
+
+#include <arm/allwinner/awin_reg.h>
+#include <arm/allwinner/awin_var.h>
+
+bus_space_handle_t awin_core_bsh;
+
+struct arm32_bus_dma_tag awin_dma_tag = {
+ _BUS_DMAMAP_FUNCS,
+ _BUS_DMAMEM_FUNCS,
+ _BUS_DMATAG_FUNCS,
+};
+
+#ifdef AWIN_CONSOLE_EARLY
+#include <dev/ic/ns16550reg.h>
+#include <dev/ic/comreg.h>
+#include <dev/cons.h>
+
+static volatile uin32t_t *uart_base;
+
+static int
+awin_cngetc(dev_t dv)
+{
+ if ((uart_base[com_lsr] & LSR_RXRDY) == 0)
+ return -1;
+
+ return uart_base[com_data] & 0xff;
+}
+
+static void
+awin_cnputc(dev_t dv, int c)
+{
+ int timo = 150000;
+
+ while ((uart_base[com_lsr] & LSR_TXRDY) == 0 && --timo > 0)
+ ;
+
+ uart_base[com_data] = c & 0xff;
+
+ timo = 150000;
+ while ((uart_base[com_lsr] & LSR_TSRE) == 0 && --timo > 0)
+ ;
+}
+
+static struct consdev awin_earlycons = {
+ .cn_putc = awin_cnputc,
+ .cn_getc = awin_cngetc,
+ .cn_pollc = nullcnpollc,
+};
+#endif /* BCM53XX_CONSOLE_EARLY */
+
+static void
+awin_cpu_clk(void)
+{
+ struct cpu_info * const ci = curcpu();
+ const uint32_t cpu0_cfg = bus_space_read_4(&awin_bs_tag, awin_core_bsh,
+ AWIN_CCM_OFFSET + AWIN_CPU_AHB_APB0_CFG_REG);
+ const u_int cpu_clk_sel = __SHIFTIN(cpu0_cfg, AWIN_CPU_CLK_SRC_SEL);
+ switch (cpu_clk_sel) {
+ case AWIN_CPU_CLK_SRC_SEL_LOSC:
+ ci->ci_data.cpu_cc_freq = 32768;
+ break;
+ case AWIN_CPU_CLK_SRC_SEL_OSC24M:
+ ci->ci_data.cpu_cc_freq = AWIN_REF_FREQ;
+ break;
+ case AWIN_CPU_CLK_SRC_SEL_PLL1: {
+ const uint32_t pll1_cfg = bus_space_read_4(&awin_bs_tag,
+ awin_core_bsh, AWIN_CCM_OFFSET + AWIN_PLL1_CFG_REG);
+ u_int p = __SHIFTOUT(pll1_cfg, AWIN_PLL_CFG_OUT_EXP_DIVP);
+ u_int n = __SHIFTOUT(pll1_cfg, AWIN_PLL_CFG_FACTOR_N);
+ u_int k = __SHIFTOUT(pll1_cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
+ u_int m = __SHIFTOUT(pll1_cfg, AWIN_PLL_CFG_FACTOR_M) + 1;
+ ci->ci_data.cpu_cc_freq =
+ (AWIN_REF_FREQ * (n ? n : 1) * k / m) >> p;
+ break;
+ }
+ case AWIN_CPU_CLK_SRC_SEL_200MHZ:
+ ci->ci_data.cpu_cc_freq = 200000000;
+ break;
+ }
+}
+
+void
+awin_bootstrap(vaddr_t iobase, vaddr_t uartbase)
+{
+ int error;
+
+#ifdef AWIN_CONSOLE_EARLY
+ uart_base = (volatile uint32_t *)uartbase;
+ cn_tab = &awin_earlycons;
+#endif
+
+ error = bus_space_map(&awin_bs_tag, AWIN_CORE_PBASE,
+ AWIN_CORE_SIZE, 0, &awin_core_bsh);
+ if (error)
+ panic("%s: failed to map BCM53xx %s registers: %d",
+ __func__, "io", error);
+ KASSERT(awin_core_bsh == iobase);
+
+ awin_cpu_clk();
+}
+
+#ifdef MULTIPROCESSOR
+void
+awin_cpu_hatch(struct cpu_info *ci)
+{
+ gtmr_init_cpu_clock(ci);
+}
+#endif
+
+psize_t
+awin_memprobe(void)
+{
+ const uint32_t dcr = bus_space_read_4(&awin_bs_tag, awin_core_bsh,
+ AWIN_DRAM_OFFSET + AWIN_DRAM_DCR_REG);
+
+ psize_t memsize = __SHIFTOUT(dcr, AWIN_DRAM_DCR_IO_WIDTH);
+ memsize <<= __SHIFTOUT(dcr, AWIN_DRAM_DCR_CHIP_DENSITY) + 28 - 3;
+#ifdef VERBOSE_INIT_ARM
+ printf("sdram_config = %#x, memsize = %uMB\n", dcr,
+ (u_int)(memsize >> 20));
+#endif
+ return memsize;
+}
+
+void
+awin_reset(void)
+{
+ bus_space_write_4(&awin_bs_tag, awin_core_bsh,
+ AWIN_CPUCNF_OFFSET + AWIN_CPU0_RST_CTRL_REG, AWIN_CPU_RESET);
+}
diff -r 1f81826590b1 -r 349b4741ede5 sys/arch/arm/allwinner/awin_com.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/allwinner/awin_com.c Wed Sep 04 02:39:01 2013 +0000
Home |
Main Index |
Thread Index |
Old Index