Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch ODROID-C1 onboard ethernet support.
details: https://anonhg.NetBSD.org/src/rev/854e25252e1a
branches: trunk
changeset: 336510:854e25252e1a
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Mar 04 12:36:12 2015 +0000
description:
ODROID-C1 onboard ethernet support.
diffstat:
sys/arch/arm/amlogic/amlogic_board.c | 11 ++-
sys/arch/arm/amlogic/amlogic_crureg.h | 5 +-
sys/arch/arm/amlogic/amlogic_gmac.c | 114 ++++++++++++++++++++++++++++++++++
sys/arch/arm/amlogic/amlogic_intr.h | 4 +-
sys/arch/arm/amlogic/amlogic_io.c | 8 +-
sys/arch/arm/amlogic/amlogic_reg.h | 8 +-
sys/arch/arm/amlogic/amlogic_var.h | 3 +-
sys/arch/arm/amlogic/files.amlogic | 6 +-
sys/arch/evbarm/conf/ODROID-C1 | 7 +-
9 files changed, 153 insertions(+), 13 deletions(-)
diffs (truncated from 314 to 300 lines):
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_board.c
--- a/sys/arch/arm/amlogic/amlogic_board.c Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_board.c Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_board.c,v 1.6 2015/03/01 15:06:09 jmcneill Exp $ */
+/* $NetBSD: amlogic_board.c,v 1.7 2015/03/04 12:36:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_amlogic.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.6 2015/03/01 15:06:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.7 2015/03/04 12:36:12 jmcneill Exp $");
#define _ARM32_BUS_DMA_PRIVATE
#include <sys/param.h>
@@ -157,6 +157,13 @@
return amlogic_get_rate_a9() / div;
}
+void
+amlogic_eth_init(void)
+{
+ CBUS_WRITE(EE_CLK_GATING1_REG,
+ CBUS_READ(EE_CLK_GATING1_REG) | EE_CLK_GATING1_ETHERNET);
+}
+
static void
amlogic_usbphy_clkgate_enable(int port)
{
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_crureg.h
--- a/sys/arch/arm/amlogic/amlogic_crureg.h Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_crureg.h Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_crureg.h,v 1.4 2015/02/28 18:50:57 jmcneill Exp $ */
+/* $NetBSD: amlogic_crureg.h,v 1.5 2015/03/04 12:36:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -39,9 +39,12 @@
#define EE_CLK_GATING1_USB_GENERAL __BIT(26)
#define EE_CLK_GATING1_USB1 __BIT(22)
#define EE_CLK_GATING1_USB0 __BIT(21)
+#define EE_CLK_GATING1_ETHERNET __BIT(3)
+
#define EE_CLK_GATING2_USB0_TO_DDR __BIT(9)
#define EE_CLK_GATING2_USB1_TO_DDR __BIT(8)
+
#define HHI_SYS_CPU_CLK_CNTL1_REG CBUS_REG(0x1057)
#define HHI_SYS_CPU_CLK_CNTL1_SDIV __BITS(29,20)
#define HHI_SYS_CPU_CLK_CNTL1_PERIPH_CLK_MUX __BITS(8,6)
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_gmac.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/amlogic/amlogic_gmac.c Wed Mar 04 12:36:12 2015 +0000
@@ -0,0 +1,114 @@
+/* $NetBSD: amlogic_gmac.c,v 1.1 2015/03/04 12:37:16 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2013, 2014, 2015 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 and Martin Husemann.
+ *
+ * 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: amlogic_gmac.c,v 1.1 2015/03/04 12:37:16 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+
+#include <arm/amlogic/amlogic_reg.h>
+#include <arm/amlogic/amlogic_var.h>
+
+#include <net/if.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <dev/mii/miivar.h>
+
+#include <dev/ic/dwc_gmac_var.h>
+#include <dev/ic/dwc_gmac_reg.h>
+
+static int amlogic_gmac_match(device_t, cfdata_t, void *);
+static void amlogic_gmac_attach(device_t, device_t, void *);
+static int amlogic_gmac_intr(void*);
+
+struct amlogic_gmac_softc {
+ struct dwc_gmac_softc sc_core;
+ void *sc_ih;
+};
+
+CFATTACH_DECL_NEW(amlogic_gmac, sizeof(struct amlogic_gmac_softc),
+ amlogic_gmac_match, amlogic_gmac_attach, NULL, NULL);
+
+static int
+amlogic_gmac_match(device_t parent, cfdata_t cf, void *aux)
+{
+ return 1;
+}
+
+static void
+amlogic_gmac_attach(device_t parent, device_t self, void *aux)
+{
+ struct amlogic_gmac_softc * const sc = device_private(self);
+ struct amlogicio_attach_args * const aio = aux;
+ const struct amlogic_locators * const loc = &aio->aio_loc;
+
+ sc->sc_core.sc_dev = self;
+ sc->sc_core.sc_bst = aio->aio_core_bst;
+ sc->sc_core.sc_dmat = aio->aio_dmat;
+ bus_space_subregion(aio->aio_core_bst, aio->aio_bsh,
+ loc->loc_offset, loc->loc_size, &sc->sc_core.sc_bsh);
+
+ aprint_naive("\n");
+ aprint_normal(": Gigabit Ethernet Controller\n");
+
+ amlogic_eth_init();
+
+ /*
+ * Interrupt handler
+ */
+ sc->sc_ih = intr_establish(loc->loc_intr, IPL_NET, IST_LEVEL,
+ amlogic_gmac_intr, sc);
+ if (sc->sc_ih == NULL) {
+ aprint_error_dev(self, "failed to establish interrupt %d\n",
+ loc->loc_intr);
+ return;
+ }
+ aprint_normal_dev(self, "interrupting on irq %d\n",
+ loc->loc_intr);
+
+ dwc_gmac_attach(&sc->sc_core, GMAC_MII_CLK_100_150M_DIV62);
+}
+
+static int
+amlogic_gmac_intr(void *arg)
+{
+ struct amlogic_gmac_softc *sc = arg;
+
+ return dwc_gmac_intr(&sc->sc_core);
+}
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_intr.h
--- a/sys/arch/arm/amlogic/amlogic_intr.h Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_intr.h Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_intr.h,v 1.3 2015/02/28 15:20:43 jmcneill Exp $ */
+/* $NetBSD: amlogic_intr.h,v 1.4 2015/03/04 12:36:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -35,6 +35,8 @@
#include <arm/cortex/gic_intr.h>
#include <arm/cortex/a9tmr_intr.h>
+#define AMLOGIC_INTR_GMAC 40
+#define AMLOGIC_INTR_MMC 60
#define AMLOGIC_INTR_USB0 62
#define AMLOGIC_INTR_USB1 63
#define AMLOGIC_INTR_UART2AO 70
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_io.c
--- a/sys/arch/arm/amlogic/amlogic_io.c Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_io.c Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_io.c,v 1.3 2015/02/28 15:20:43 jmcneill Exp $ */
+/* $NetBSD: amlogic_io.c,v 1.4 2015/03/04 12:36:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_amlogic.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.3 2015/02/28 15:20:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.4 2015/03/04 12:36:12 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -55,6 +55,8 @@
static bool amlogicio_found = false;
+#define NOPORT AMLOGICIOCF_PORT_DEFAULT
+
static const struct amlogic_locators amlogic_locators[] = {
{ "amlogiccom",
AMLOGIC_UART0AO_OFFSET, AMLOGIC_UART_SIZE, 0, AMLOGIC_INTR_UART0AO },
@@ -64,6 +66,8 @@
AMLOGIC_USB0_OFFSET, AMLOGIC_USB_SIZE, 0, AMLOGIC_INTR_USB0 },
{ "dwctwo",
AMLOGIC_USB1_OFFSET, AMLOGIC_USB_SIZE, 1, AMLOGIC_INTR_USB1 },
+ { "awge",
+ AMLOGIC_GMAC_OFFSET, AMLOGIC_GMAC_SIZE, NOPORT, AMLOGIC_INTR_GMAC },
#if notyet
{ "amlogicmmc",
AMLOGIC_MMC_OFFSET, AMLOGIC_MMC_SIZE, 0, AMLOGIC_INTR_MMC },
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_reg.h
--- a/sys/arch/arm/amlogic/amlogic_reg.h Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_reg.h Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_reg.h,v 1.5 2015/03/01 15:37:26 jmcneill Exp $ */
+/* $NetBSD: amlogic_reg.h,v 1.6 2015/03/04 12:36:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -37,9 +37,6 @@
#define AMLOGIC_CBUS_OFFSET 0x01100000
-#define AMLOGIC_UART0_OFFSET 0x01102130
-#define AMLOGIC_UART1_OFFSET 0x01102137
-#define AMLOGIC_UART2_OFFSET 0x011021c0
#define AMLOGIC_UART0AO_OFFSET 0x081004c0
#define AMLOGIC_UART2AO_OFFSET 0x081004e0
#define AMLOGIC_UART_SIZE 0x20
@@ -58,6 +55,9 @@
#define AMLOGIC_USB1_OFFSET 0x090c0000
#define AMLOGIC_USB_SIZE 0x40000
+#define AMLOGIC_GMAC_OFFSET 0x09410000
+#define AMLOGIC_GMAC_SIZE 0x10000
+
#define AMLOGIC_SRAM_OFFSET 0x19000000
#define AMLOGIC_CPUCONF_OFFSET 0x1901ff80
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/amlogic_var.h
--- a/sys/arch/arm/amlogic/amlogic_var.h Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_var.h Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_var.h,v 1.2 2015/02/28 15:20:43 jmcneill Exp $ */
+/* $NetBSD: amlogic_var.h,v 1.3 2015/03/04 12:36:12 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -57,6 +57,7 @@
void amlogic_bootstrap(void);
void amlogic_usbphy_init(int);
+void amlogic_eth_init(void);
uint32_t amlogic_get_rate_xtal(void);
uint32_t amlogic_get_rate_sys(void);
diff -r 30e040c4275e -r 854e25252e1a sys/arch/arm/amlogic/files.amlogic
--- a/sys/arch/arm/amlogic/files.amlogic Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/arm/amlogic/files.amlogic Wed Mar 04 12:36:12 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.amlogic,v 1.3 2015/02/28 15:20:43 jmcneill Exp $
+# $NetBSD: files.amlogic,v 1.4 2015/03/04 12:36:12 jmcneill Exp $
#
# Configuration info for Amlogic ARM Peripherals
#
@@ -34,6 +34,10 @@
attach dwctwo at amlogicio with amlogic_dwctwo
file arch/arm/amlogic/amlogic_dwctwo.c amlogic_dwctwo
+# ethernet mac
+attach awge at amlogicio with amlogic_gmac
+file arch/arm/amlogic/amlogic_gmac.c amlogic_gmac
+
# Console parameters
defparam opt_amlogic.h CONADDR
defparam opt_amlogic.h CONSPEED
diff -r 30e040c4275e -r 854e25252e1a sys/arch/evbarm/conf/ODROID-C1
--- a/sys/arch/evbarm/conf/ODROID-C1 Wed Mar 04 11:35:59 2015 +0000
+++ b/sys/arch/evbarm/conf/ODROID-C1 Wed Mar 04 12:36:12 2015 +0000
@@ -1,5 +1,5 @@
#
-# $NetBSD: ODROID-C1,v 1.5 2015/03/01 15:37:26 jmcneill Exp $
+# $NetBSD: ODROID-C1,v 1.6 2015/03/04 12:36:12 jmcneill Exp $
#
Home |
Main Index |
Thread Index |
Old Index