From: jsg Date: Fri, 2 Jan 2015 01:57:33 +0000 (+0000) Subject: Add some additional i.MX6 board types from Bitrig. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=352624d7941d1d4af07487ebe94c15d0ca3397c9;p=openbsd Add some additional i.MX6 board types from Bitrig. CompuLab Utilite, SolidRun HummingBoard/CuBox-i and UDOO. --- diff --git a/sys/arch/armv7/armv7/armv7.c b/sys/arch/armv7/armv7/armv7.c index 2dbb92dd43b..342dd157c1e 100644 --- a/sys/arch/armv7/armv7/armv7.c +++ b/sys/arch/armv7/armv7/armv7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7.c,v 1.3 2014/03/18 07:34:17 syl Exp $ */ +/* $OpenBSD: armv7.c,v 1.4 2015/01/02 01:57:33 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -47,6 +47,27 @@ struct armv7_dev *armv7_devs = NULL; #define DEVNAME(sc) (sc)->sc_dv.dv_xname +struct board_dev hummingboard_devs[] = { + { "imxocotp", 0 }, + { "imxccm", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxuart", 0 }, + { "imxgpio", 0 }, + { "imxgpio", 1 }, + { "imxgpio", 2 }, + { "imxgpio", 3 }, + { "imxgpio", 4 }, + { "imxgpio", 5 }, + { "imxgpio", 6 }, + { "imxesdhc", 1 }, + { "ehci", 0 }, + { "ehci", 1 }, + { "imxenet", 0 }, + { "ahci", 0 }, + { NULL, 0 } +}; + struct board_dev phyflex_imx6_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, @@ -89,6 +110,48 @@ struct board_dev sabrelite_devs[] = { { NULL, 0 } }; +struct board_dev udoo_devs[] = { + { "imxocotp", 0 }, + { "imxccm", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxuart", 1 }, + { "imxgpio", 0 }, + { "imxgpio", 1 }, + { "imxgpio", 2 }, + { "imxgpio", 3 }, + { "imxgpio", 4 }, + { "imxgpio", 5 }, + { "imxgpio", 6 }, + { "imxesdhc", 2 }, + { "imxesdhc", 3 }, + { "ehci", 0 }, + { "imxenet", 0 }, + { "ahci", 0 }, + { NULL, 0 } +}; + +struct board_dev utilite_devs[] = { + { "imxocotp", 0 }, + { "imxccm", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxuart", 3 }, + { "imxgpio", 0 }, + { "imxgpio", 1 }, + { "imxgpio", 2 }, + { "imxgpio", 3 }, + { "imxgpio", 4 }, + { "imxgpio", 5 }, + { "imxgpio", 6 }, + { "imxiic", 2 }, + { "imxesdhc", 2 }, + { "ehci", 0 }, + { "imxenet", 0 }, + { "ahci", 0 }, + { NULL, 0 } +}; + struct board_dev wandboard_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, @@ -291,6 +354,16 @@ armv7_attach(struct device *parent, struct device *self, void *aux) bus_space_handle_t ioh; switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + printf(": i.MX6 SolidRun CuBox-i\n"); + imx6_init(); + sc->sc_board_devs = hummingboard_devs; + break; + case BOARD_ID_IMX6_HUMMINGBOARD: + printf(": i.MX6 SolidRun HummingBoard\n"); + imx6_init(); + sc->sc_board_devs = hummingboard_devs; + break; case BOARD_ID_IMX6_PHYFLEX: printf(": PhyFLEX-i.MX6\n"); imx6_init(); @@ -301,6 +374,16 @@ armv7_attach(struct device *parent, struct device *self, void *aux) imx6_init(); sc->sc_board_devs = sabrelite_devs; break; + case BOARD_ID_IMX6_UDOO: + printf(": i.MX6 UDOO\n"); + imx6_init(); + sc->sc_board_devs = udoo_devs; + break; + case BOARD_ID_IMX6_UTILITE: + printf(": i.MX6 Utilite\n"); + imx6_init(); + sc->sc_board_devs = utilite_devs; + break; case BOARD_ID_IMX6_WANDBOARD: printf(": i.MX6 Wandboard\n"); imx6_init(); diff --git a/sys/arch/armv7/armv7/armv7var.h b/sys/arch/armv7/armv7/armv7var.h index 01c96bba987..65a38222f97 100644 --- a/sys/arch/armv7/armv7/armv7var.h +++ b/sys/arch/armv7/armv7/armv7var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7var.h,v 1.1 2013/11/06 19:08:06 syl Exp $ */ +/* $OpenBSD: armv7var.h,v 1.2 2015/01/02 01:57:33 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -73,10 +73,14 @@ int armv7_submatch(struct device *, void *, void *); #define BOARD_ID_OMAP4_PANDA 2791 #define BOARD_ID_IMX6_PHYFLEX 3529 #define BOARD_ID_AM335X_BEAGLEBONE 3589 -#define BOARD_ID_SUN4I_A10 4104 #define BOARD_ID_IMX6_SABRELITE 3769 +#define BOARD_ID_SUN4I_A10 4104 +#define BOARD_ID_IMX6_UTILITE 4273 #define BOARD_ID_SUN7I_A20 4283 #define BOARD_ID_IMX6_WANDBOARD 4412 +#define BOARD_ID_IMX6_HUMMINGBOARD 4773 +#define BOARD_ID_IMX6_UDOO 4800 +#define BOARD_ID_IMX6_CUBOXI 4821 extern uint32_t board_id; /* different arch init */ diff --git a/sys/arch/armv7/imx/imx_machdep.c b/sys/arch/armv7/imx/imx_machdep.c index 2c25439e40c..47ad7ccf4a8 100644 --- a/sys/arch/armv7/imx/imx_machdep.c +++ b/sys/arch/armv7/imx/imx_machdep.c @@ -52,15 +52,18 @@ platform_init_cons(void) paddr_t paddr; switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: + case BOARD_ID_IMX6_WANDBOARD: + paddr = 0x02020000; + break; case BOARD_ID_IMX6_PHYFLEX: paddr = 0x021f0000; break; case BOARD_ID_IMX6_SABRELITE: + case BOARD_ID_IMX6_UDOO: paddr = 0x021e8000; break; - case BOARD_ID_IMX6_WANDBOARD: - paddr = 0x02020000; - break; default: printf("board type %x unknown", board_id); return; @@ -85,6 +88,14 @@ void platform_print_board_type(void) { switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + amptimer_frequency = 396 * 1000 * 1000; + printf("board type: CuBox-i\n"); + break; + case BOARD_ID_IMX6_HUMMINGBOARD: + amptimer_frequency = 396 * 1000 * 1000; + printf("board type: HummingBoard\n"); + break; case BOARD_ID_IMX6_PHYFLEX: amptimer_frequency = 396 * 1000 * 1000; printf("board type: phyFLEX-i.MX6\n"); @@ -93,6 +104,14 @@ platform_print_board_type(void) amptimer_frequency = 396 * 1000 * 1000; printf("board type: SABRE Lite\n"); break; + case BOARD_ID_IMX6_UDOO: + amptimer_frequency = 396 * 1000 * 1000; + printf("board type: UDOO\n"); + break; + case BOARD_ID_IMX6_UTILITE: + amptimer_frequency = 396 * 1000 * 1000; + printf("board type: Utilite\n"); + break; case BOARD_ID_IMX6_WANDBOARD: amptimer_frequency = 396 * 1000 * 1000; printf("board type: Wandboard\n"); diff --git a/sys/arch/armv7/imx/imxehci.c b/sys/arch/armv7/imx/imxehci.c index ef49b4fe375..3896fca22c6 100644 --- a/sys/arch/armv7/imx/imxehci.c +++ b/sys/arch/armv7/imx/imxehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxehci.c,v 1.4 2014/05/19 13:11:31 mpi Exp $ */ +/* $OpenBSD: imxehci.c,v 1.5 2015/01/02 01:57:33 jsg Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt * @@ -62,8 +62,12 @@ #define USBNC_USB_UH1_CTRL_OVER_CUR_DIS (1 << 7) /* board specific */ +#define EHCI_HUMMINGBOARD_USB_H1_PWR 0 +#define EHCI_HUMMINGBOARD_USB_OTG_PWR (2*32+22) +#define EHCI_NITROGEN6X_USB_HUB_RST (6*32+12) #define EHCI_PHYFLEX_USB_H1_PWR 0 #define EHCI_PHYFLEX_USB_OTG_PWR 111 +#define EHCI_UTILITE_USB_HUB_RST (6*32+8) void imxehci_attach(struct device *, struct device *, void *); int imxehci_detach(struct device *, int); @@ -129,6 +133,19 @@ imxehci_attach(struct device *parent, struct device *self, void *aux) imxgpio_set_bit(EHCI_PHYFLEX_USB_H1_PWR); delay(10); break; + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: + imxgpio_set_bit(EHCI_HUMMINGBOARD_USB_H1_PWR); + imxgpio_set_dir(EHCI_HUMMINGBOARD_USB_H1_PWR, IMXGPIO_DIR_OUT); + delay(10); + break; + case BOARD_ID_IMX6_UTILITE: + imxgpio_clear_bit(EHCI_UTILITE_USB_HUB_RST); + imxgpio_set_dir(EHCI_UTILITE_USB_HUB_RST, IMXGPIO_DIR_OUT); + delay(10); + imxgpio_set_bit(EHCI_UTILITE_USB_HUB_RST); + delay(1000); + break; } imxccm_enable_usboh3(); diff --git a/sys/arch/armv7/imx/imxenet.c b/sys/arch/armv7/imx/imxenet.c index a9e556d9bee..357a9a703c5 100644 --- a/sys/arch/armv7/imx/imxenet.c +++ b/sys/arch/armv7/imx/imxenet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxenet.c,v 1.8 2014/12/22 02:26:53 tedu Exp $ */ +/* $OpenBSD: imxenet.c,v 1.9 2015/01/02 01:57:33 jsg Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt * @@ -132,10 +132,19 @@ #define ENET_MII_CLK 2500 #define ENET_ALIGNMENT 16 -#define ENET_SABRELITE_PHY 6 -#define ENET_PHYFLEX_PHY 3 -#define ENET_PHYFLEX_PHY_RST 87 -#define ENET_WANDBOARD_PHY 1 +#define ENET_HUMMINGBOARD_PHY 0 +#define ENET_HUMMINGBOARD_PHY_RST (3*32+15) +#define ENET_SABRELITE_PHY 6 +#define ENET_SABRELITE_PHY_RST (2*32+23) +#define ENET_NITROGEN6X_PHY 6 +#define ENET_NITROGEN6X_PHY_RST (0*32+27) +#define ENET_UDOO_PHY 6 +#define ENET_UDOO_PHY_RST (2*32+23) +#define ENET_UDOO_PWR (1*32+31) +#define ENET_UTILITE_PHY 0 +#define ENET_WANDBOARD_PHY 1 +#define ENET_PHYFLEX_PHY 3 +#define ENET_PHYFLEX_PHY_RST (2*32+23) #define HREAD4(sc, reg) \ (bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg))) @@ -221,6 +230,19 @@ imxenet_attach(struct device *parent, struct device *self, void *args) switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: + /* We need to reset the AR8035 PHY twice. */ + imxgpio_clear_bit(ENET_HUMMINGBOARD_PHY_RST); + imxgpio_set_dir(ENET_HUMMINGBOARD_PHY_RST, IMXGPIO_DIR_OUT); + delay(2000); + imxgpio_set_bit(ENET_HUMMINGBOARD_PHY_RST); + delay(2000); + imxgpio_clear_bit(ENET_HUMMINGBOARD_PHY_RST); + delay(2000); + imxgpio_set_bit(ENET_HUMMINGBOARD_PHY_RST); + delay(2000); + break; case BOARD_ID_IMX6_PHYFLEX: case BOARD_ID_IMX6_SABRELITE: /* phyFLEX i.MX6 and SABRE Lite PHY reset */ @@ -229,6 +251,15 @@ imxenet_attach(struct device *parent, struct device *self, void *args) imxgpio_set_bit(ENET_PHYFLEX_PHY_RST); delay(10); break; + case BOARD_ID_IMX6_UDOO: + imxgpio_set_bit(ENET_UDOO_PWR); + imxgpio_set_dir(ENET_UDOO_PWR, IMXGPIO_DIR_OUT); + imxgpio_clear_bit(ENET_UDOO_PHY_RST); + imxgpio_set_dir(ENET_UDOO_PHY_RST, IMXGPIO_DIR_OUT); + delay(1000 * 1); + imxgpio_set_bit(ENET_UDOO_PHY_RST); + delay(1000 * 100); + break; } /* reset the controller */ @@ -353,12 +384,22 @@ imxenet_chip_init(struct imxenet_softc *sc) switch (board_id) { - case BOARD_ID_IMX6_SABRELITE: - phy = ENET_SABRELITE_PHY; + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: + phy = ENET_HUMMINGBOARD_PHY; break; case BOARD_ID_IMX6_PHYFLEX: phy = ENET_PHYFLEX_PHY; break; + case BOARD_ID_IMX6_SABRELITE: + phy = ENET_SABRELITE_PHY; + break; + case BOARD_ID_IMX6_UDOO: + phy = ENET_UDOO_PHY; + break; + case BOARD_ID_IMX6_UTILITE: + phy = ENET_UTILITE_PHY; + break; case BOARD_ID_IMX6_WANDBOARD: phy = ENET_WANDBOARD_PHY; break; @@ -366,8 +407,36 @@ imxenet_chip_init(struct imxenet_softc *sc) switch (board_id) { + case BOARD_ID_IMX6_UDOO: /* Micrel KSZ9031 */ + /* prefer master mode */ + imxenet_miibus_writereg(dev, phy, 0x9, 0x1c00); + + /* control data pad skew */ + imxenet_miibus_writereg(dev, phy, 0x0d, 0x0002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0004); + imxenet_miibus_writereg(dev, phy, 0x0d, 0x4002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0000); + + /* rx data pad skew */ + imxenet_miibus_writereg(dev, phy, 0x0d, 0x0002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0005); + imxenet_miibus_writereg(dev, phy, 0x0d, 0x4002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0000); + + /* tx data pad skew */ + imxenet_miibus_writereg(dev, phy, 0x0d, 0x0002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0006); + imxenet_miibus_writereg(dev, phy, 0x0d, 0x4002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0000); + + /* gtx and rx data pad skew */ + imxenet_miibus_writereg(dev, phy, 0x0d, 0x0002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x0008); + imxenet_miibus_writereg(dev, phy, 0x0d, 0x4002); + imxenet_miibus_writereg(dev, phy, 0x0e, 0x03ff); + break; case BOARD_ID_IMX6_PHYFLEX: - case BOARD_ID_IMX6_SABRELITE: + case BOARD_ID_IMX6_SABRELITE: /* Micrel KSZ9021 */ /* prefer master mode */ imxenet_miibus_writereg(dev, phy, 0x9, 0x1f00); @@ -387,7 +456,10 @@ imxenet_chip_init(struct imxenet_softc *sc) /* enable all interrupts */ imxenet_miibus_writereg(dev, phy, 0x1b, 0xff00); break; - case BOARD_ID_IMX6_WANDBOARD: + case BOARD_ID_IMX6_CUBOXI: /* AR8035 */ + case BOARD_ID_IMX6_HUMMINGBOARD: /* AR8035 */ + case BOARD_ID_IMX6_UTILITE: + case BOARD_ID_IMX6_WANDBOARD: /* AR8031 */ /* disable SmartEEE */ imxenet_miibus_writereg(dev, phy, 0x0d, 0x0003); imxenet_miibus_writereg(dev, phy, 0x0e, 0x805d); diff --git a/sys/arch/armv7/imx/imxesdhc.c b/sys/arch/armv7/imx/imxesdhc.c index 24e51eef646..6d5c8cdcaea 100644 --- a/sys/arch/armv7/imx/imxesdhc.c +++ b/sys/arch/armv7/imx/imxesdhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxesdhc.c,v 1.4 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: imxesdhc.c,v 1.5 2015/01/02 01:57:33 jsg Exp $ */ /* * Copyright (c) 2009 Dale Rahn * Copyright (c) 2006 Uwe Stuehler @@ -435,6 +435,12 @@ imxesdhc_card_detect(sdmmc_chipset_handle_t sch) switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: + gpio = 0*32 + 4; + imxgpio_set_dir(gpio, IMXGPIO_DIR_IN); + return imxgpio_get_bit(gpio) ? 0 : 1; + break; case BOARD_ID_IMX6_PHYFLEX: switch (sc->unit) { case 1: @@ -459,6 +465,33 @@ imxesdhc_card_detect(sdmmc_chipset_handle_t sch) return 0; } return imxgpio_get_bit(gpio) ? 0 : 1; + case BOARD_ID_IMX6_UDOO: + switch (sc->unit) { + /* + * One of these is the SD card, another the wifi + * the third is not connected (?) + */ + case 0: + case 1: + case 2: + case 3: + gpio = 3*32 + 9; + break; + return 1; + default: + return 0; + } + return 1; + case BOARD_ID_IMX6_UTILITE: + switch (sc->unit) { + case 2: + gpio = 6*32 + 1; + break; + default: + return 0; + } + imxgpio_set_dir(gpio, IMXGPIO_DIR_IN); + return imxgpio_get_bit(gpio) ? 0 : 1; case BOARD_ID_IMX6_WANDBOARD: switch (sc->unit) { case 0: diff --git a/sys/arch/armv7/imx/imxgpio.c b/sys/arch/armv7/imx/imxgpio.c index 9b23e89b237..325d638fa85 100644 --- a/sys/arch/armv7/imx/imxgpio.c +++ b/sys/arch/armv7/imx/imxgpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxgpio.c,v 1.3 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: imxgpio.c,v 1.4 2015/01/02 01:57:33 jsg Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -101,8 +101,12 @@ int imxgpio_match(struct device *parent, void *v, void *aux) { switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: case BOARD_ID_IMX6_PHYFLEX: case BOARD_ID_IMX6_SABRELITE: + case BOARD_ID_IMX6_UDOO: + case BOARD_ID_IMX6_UTILITE: case BOARD_ID_IMX6_WANDBOARD: break; /* continue trying */ default: @@ -124,8 +128,12 @@ imxgpio_attach(struct device *parent, struct device *self, void *args) switch (board_id) { + case BOARD_ID_IMX6_CUBOXI: + case BOARD_ID_IMX6_HUMMINGBOARD: case BOARD_ID_IMX6_PHYFLEX: case BOARD_ID_IMX6_SABRELITE: + case BOARD_ID_IMX6_UDOO: + case BOARD_ID_IMX6_UTILITE: case BOARD_ID_IMX6_WANDBOARD: sc->sc_get_bit = imxgpio_v6_get_bit; sc->sc_set_bit = imxgpio_v6_set_bit;