diff options
author | 2013-10-05 23:05:11 +0000 | |
---|---|---|
committer | 2013-10-05 23:05:11 +0000 | |
commit | 2efa274660844bb54f13cc827dbd714302d58d84 (patch) | |
tree | 16dd077bd0d778c38f63c56401be0bbfbffa07c4 | |
parent | Disable interrupts in the interrupt handler. This is what FreeBSD does, and (diff) | |
download | wireguard-openbsd-2efa274660844bb54f13cc827dbd714302d58d84.tar.xz wireguard-openbsd-2efa274660844bb54f13cc827dbd714302d58d84.zip |
Support for the i.MX6-based Wandboard Quad.
From Artturi Alm.
-rw-r--r-- | sys/arch/armv7/conf/GENERIC-IMX | 5 | ||||
-rw-r--r-- | sys/arch/armv7/conf/RAMDISK-IMX | 3 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imx.c | 28 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imx_machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxenet.c | 47 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxvar.h | 3 |
6 files changed, 84 insertions, 11 deletions
diff --git a/sys/arch/armv7/conf/GENERIC-IMX b/sys/arch/armv7/conf/GENERIC-IMX index e1b026877fd..f7779591872 100644 --- a/sys/arch/armv7/conf/GENERIC-IMX +++ b/sys/arch/armv7/conf/GENERIC-IMX @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC-IMX,v 1.2 2013/09/11 11:07:29 rapha Exp $ +# $OpenBSD: GENERIC-IMX,v 1.3 2013/10/05 23:05:11 patrick Exp $ # # GENERIC machine description file # @@ -46,7 +46,7 @@ options CPU_ARMv7 # Support the ARMv7 option WSDISPLAY_DEFAULTSCREENS=1 #option WSDISPLAY_COMPAT_PCVT # emulate some ioctls -config bsd root on sd0a swap on sd0b +config bsd swap generic # The main bus device mainbus0 at root @@ -128,6 +128,7 @@ radio* at udsbr? # USB radio #ubt* at uhub? disable # USB Bluetooth ugen* at uhub? # USB Generic driver +atphy* at mii? # Attansic F1 PHYs ukphy* at mii? # "unknown" PHYs scsibus* at scsi? diff --git a/sys/arch/armv7/conf/RAMDISK-IMX b/sys/arch/armv7/conf/RAMDISK-IMX index 87ef8bb7b9f..82bc7a0ab8b 100644 --- a/sys/arch/armv7/conf/RAMDISK-IMX +++ b/sys/arch/armv7/conf/RAMDISK-IMX @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK-IMX,v 1.2 2013/09/11 11:07:30 rapha Exp $ +# $OpenBSD: RAMDISK-IMX,v 1.3 2013/10/05 23:05:11 patrick Exp $ # # GENERIC machine description file # @@ -137,6 +137,7 @@ radio* at udsbr? # USB radio #ubt* at uhub? disable # USB Bluetooth ugen* at uhub? # USB Generic driver +atphy* at mii? # Attansic F1 PHYs ukphy* at mii? # "unknown" PHYs scsibus* at scsi? diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c index 99014634976..0d4d9be0969 100644 --- a/sys/arch/armv7/imx/imx.c +++ b/sys/arch/armv7/imx/imx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx.c,v 1.1 2013/09/06 20:45:53 patrick Exp $ */ +/* $OpenBSD: imx.c,v 1.2 2013/10/05 23:05:11 patrick Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -92,6 +92,27 @@ struct board_dev sabrelite_devs[] = { { NULL, 0 } }; +struct board_dev wandboard_devs[] = { + { "imxccm", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxocotp", 0 }, + { "imxuart", 0 }, + { "imxgpio", 0 }, + { "imxgpio", 1 }, + { "imxgpio", 2 }, + { "imxgpio", 3 }, + { "imxgpio", 4 }, + { "imxgpio", 5 }, + { "imxgpio", 6 }, + { "imxenet", 0 }, + { "imxesdhc", 2 }, + { "imxesdhc", 0 }, + { "ehci", 0 }, + { "ahci", 0 }, /* only on quad, afaik. */ + { NULL, 0 } +}; + struct board_dev *board_devs; struct imx_dev *imx_devs = NULL; @@ -135,6 +156,11 @@ imx_attach(struct device *parent, struct device *self, void *aux) imx6_init(); board_devs = sabrelite_devs; break; + case BOARD_ID_IMX6_WANDBOARD: + printf(": i.MX6 Wandboard\n"); + imx6_init(); + board_devs = wandboard_devs; + break; default: printf("\n"); panic("%s: board type 0x%x unknown", __func__, board_id); diff --git a/sys/arch/armv7/imx/imx_machdep.c b/sys/arch/armv7/imx/imx_machdep.c index 80fc27ebe60..a742c0d6a2a 100644 --- a/sys/arch/armv7/imx/imx_machdep.c +++ b/sys/arch/armv7/imx/imx_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx_machdep.c,v 1.3 2013/09/28 14:16:41 miod Exp $ */ +/* $OpenBSD: imx_machdep.c,v 1.4 2013/10/05 23:05:12 patrick Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -864,6 +864,10 @@ initarm(void *arg0, void *arg1, void *arg2) amptimer_frequency = 396 * 1000 * 1000; printf("board type: SABRE Lite\n"); break; + case BOARD_ID_IMX6_WANDBOARD: + amptimer_frequency = 396 * 1000 * 1000; + printf("board type: Wandboard\n"); + break; default: printf("board type %x unknown\n", board_id); } @@ -954,6 +958,9 @@ consinit(void) case BOARD_ID_IMX6_SABRELITE: paddr = 0x021e8000; break; + case BOARD_ID_IMX6_WANDBOARD: + paddr = 0x02020000; + break; default: printf("board type %x unknown", board_id); return; diff --git a/sys/arch/armv7/imx/imxenet.c b/sys/arch/armv7/imx/imxenet.c index b1426b5285d..b82998c4dae 100644 --- a/sys/arch/armv7/imx/imxenet.c +++ b/sys/arch/armv7/imx/imxenet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxenet.c,v 1.1 2013/09/06 20:45:53 patrick Exp $ */ +/* $OpenBSD: imxenet.c,v 1.2 2013/10/05 23:05:12 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -140,6 +140,7 @@ #define ENET_SABRELITE_PHY 6 #define ENET_PHYFLEX_PHY 3 #define ENET_PHYFLEX_PHY_RST 87 +#define ENET_WANDBOARD_PHY 1 #define HREAD4(sc, reg) \ (bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg))) @@ -201,7 +202,7 @@ struct cfattach imxenet_ca = { }; struct cfdriver imxenet_cd = { - NULL, "imxenet", DV_DULL + NULL, "imxenet", DV_IFNET }; void @@ -350,6 +351,7 @@ imxenet_chip_init(struct imxenet_softc *sc) { struct device *dev = (struct device *) sc; int phy = 0; + uint32_t reg; bus_space_write_4(sc->sc_iot, sc->sc_ioh, ENET_MSCR, (((imxccm_get_fecclk() + (ENET_MII_CLK << 2) - 1) / (ENET_MII_CLK << 2)) << 1) | 0x100); @@ -362,6 +364,9 @@ imxenet_chip_init(struct imxenet_softc *sc) case BOARD_ID_IMX6_PHYFLEX: phy = ENET_PHYFLEX_PHY; break; + case BOARD_ID_IMX6_WANDBOARD: + phy = ENET_WANDBOARD_PHY; + break; } switch (board_id) @@ -387,6 +392,32 @@ imxenet_chip_init(struct imxenet_softc *sc) /* enable all interrupts */ imxenet_miibus_writereg(dev, phy, 0x1b, 0xff00); break; + case BOARD_ID_IMX6_WANDBOARD: + /* disable SmartEEE */ + imxenet_miibus_writereg(dev, phy, 0x0d, 0x0003); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x805d); + imxenet_miibus_writereg(dev, phy, 0x0d, 0x4003); + reg = imxenet_miibus_readreg(dev, phy, 0x0e); + imxenet_miibus_writereg(dev, phy, 0x0e, reg & ~0x0100); + + /* enable 125MHz clk output for AR8031 */ + imxenet_miibus_writereg(dev, phy, 0x0d, 0x0007); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x8016); + imxenet_miibus_writereg(dev, phy, 0x0d, 0x4007); + + reg = imxenet_miibus_readreg(dev, phy, 0x0e) & 0xffe3; + imxenet_miibus_writereg(dev, phy, 0x0e, reg | 0x18); + + /* tx clock delay */ + imxenet_miibus_writereg(dev, phy, 0x1d, 0x0005); + reg = imxenet_miibus_readreg(dev, phy, 0x1e); + imxenet_miibus_writereg(dev, phy, 0x1e, reg | 0x0100); + + /* phy power */ + reg = imxenet_miibus_readreg(dev, phy, 0x00); + if (reg & 0x0800) + imxenet_miibus_writereg(dev, phy, 0x00, reg & ~0x0800); + break; } } @@ -504,13 +535,15 @@ imxenet_init(struct imxenet_softc *sc) /* rx descriptors are ready */ HWRITE4(sc, ENET_RDAR, ENET_RDAR_RDAR); + /* Indicate we are up and running. */ + ifp->if_flags |= IFF_RUNNING; + ifp->if_flags &= ~IFF_OACTIVE; + /* enable interrupts for tx/rx */ HWRITE4(sc, ENET_EIMR, ENET_EIR_TXF | ENET_EIR_RXF); HWRITE4(sc, ENET_EIMR, 0xffffffff); - /* Indicate we are up and running. */ - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + imxenet_start(ifp); } void @@ -709,6 +742,10 @@ imxenet_intr(void *arg) imxenet_recv(sc); } + /* Try to transmit. */ + if (ifp->if_flags & IFF_RUNNING && !IFQ_IS_EMPTY(&ifp->if_snd)) + imxenet_start(ifp); + return 1; } diff --git a/sys/arch/armv7/imx/imxvar.h b/sys/arch/armv7/imx/imxvar.h index 1a00bc99298..df1ec551060 100644 --- a/sys/arch/armv7/imx/imxvar.h +++ b/sys/arch/armv7/imx/imxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: imxvar.h,v 1.1 2013/09/06 20:45:54 patrick Exp $ */ +/* $OpenBSD: imxvar.h,v 1.2 2013/10/05 23:05:12 patrick Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@drahn.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -52,4 +52,5 @@ void *avic_intr_establish(int irqno, int level, int (*func)(void *), /* board identification - from uboot */ #define BOARD_ID_IMX6_PHYFLEX 3529 #define BOARD_ID_IMX6_SABRELITE 3769 +#define BOARD_ID_IMX6_WANDBOARD 4412 extern uint32_t board_id; |