From 2cb278da88680d8392df5614cda2dd4a3daeb4e6 Mon Sep 17 00:00:00 2001 From: jsg Date: Fri, 15 May 2015 15:35:43 +0000 Subject: [PATCH] Make board attaching table driven and move it out into the soc directories. Move the device tables while here as was done in bitrig. With these changes the only use of the board id defines is in the soc directories. Tested by matthieu and djm on imx and myself on omap and sunxi (qemu). ok djm@, ok jasper@ on an earlier version --- sys/arch/armv7/armv7/armv7.c | 420 ++----------------------- sys/arch/armv7/armv7/armv7_machdep.c | 4 +- sys/arch/armv7/armv7/armv7_machdep.h | 4 +- sys/arch/armv7/armv7/armv7var.h | 13 +- sys/arch/armv7/armv7/autoconf.c | 14 +- sys/arch/armv7/exynos/exynos.c | 41 ++- sys/arch/armv7/exynos/exynos_machdep.c | 14 +- sys/arch/armv7/imx/files.imx | 4 +- sys/arch/armv7/imx/imx.c | 257 ++++++++++++++- sys/arch/armv7/imx/imx_machdep.c | 48 +-- sys/arch/armv7/omap/files.omap | 4 +- sys/arch/armv7/omap/omap.c | 130 +++++++- sys/arch/armv7/omap/omap_machdep.c | 24 +- sys/arch/armv7/sunxi/files.sunxi | 4 +- sys/arch/armv7/sunxi/sunxi.c | 117 ++++++- sys/arch/armv7/sunxi/sunxi_machdep.c | 9 +- 16 files changed, 623 insertions(+), 484 deletions(-) diff --git a/sys/arch/armv7/armv7/armv7.c b/sys/arch/armv7/armv7/armv7.c index 03b441987ee..817553284e6 100644 --- a/sys/arch/armv7/armv7/armv7.c +++ b/sys/arch/armv7/armv7/armv7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7.c,v 1.8 2015/05/12 04:40:31 jsg Exp $ */ +/* $OpenBSD: armv7.c,v 1.9 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -22,7 +22,10 @@ #include #include #include -#include + +#include "imx.h" +#include "omap.h" +#include "sunxi.h" struct arm32_bus_dma_tag armv7_bus_dma_tag = { 0, @@ -47,301 +50,6 @@ 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 }, - { "imxdog", 0 }, - { "imxocotp", 0 }, - { "imxuart", 3 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { "imxesdhc", 1 }, - { "imxesdhc", 2 }, - { "ehci", 0 }, - { "imxenet", 0 }, - { "ahci", 0 }, - { NULL, 0 } -}; - -struct board_dev sabrelite_devs[] = { - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxdog", 0 }, - { "imxocotp", 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 sabresd_devs[] = { - { "imxocotp", 0 }, - { "imxccm", 0 }, - { "imxtemp", 0 }, - { "imxiomuxc", 0 }, - { "imxdog", 0 }, - { "imxuart", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { "imxesdhc", 1 }, - { "imxesdhc", 2 }, - { "imxesdhc", 3 }, - { "ehci", 0 }, - { "imxenet", 0 }, - { "ahci", 0 }, - { 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 }, - { "imxesdhc", 2 }, - { "ehci", 0 }, - { "imxenet", 0 }, - { "ahci", 0 }, - { NULL, 0 } -}; - -struct board_dev novena_devs[] = { - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxdog", 0 }, - { "imxocotp", 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 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 beagleboard_devs[] = { - { "prcm", 0 }, - { "intc", 0 }, - { "gptimer", 0 }, - { "gptimer", 1 }, - { "omdog", 0 }, - { "omgpio", 0 }, - { "omgpio", 1 }, - { "omgpio", 2 }, - { "omgpio", 3 }, - { "omgpio", 4 }, - { "omgpio", 5 }, - { "ommmc", 0 }, /* HSMMC1 */ - { "com", 2 }, /* UART3 */ - { NULL, 0 } -}; - -struct board_dev beaglebone_devs[] = { - { "prcm", 0 }, - { "sitaracm", 0 }, - { "intc", 0 }, - { "edma", 0 }, - { "dmtimer", 0 }, - { "dmtimer", 1 }, - { "omdog", 0 }, - { "omgpio", 0 }, - { "omgpio", 1 }, - { "omgpio", 2 }, - { "omgpio", 3 }, - { "tiiic", 0 }, - { "tiiic", 1 }, - { "tiiic", 2 }, - { "ommmc", 0 }, /* HSMMC0 */ - { "ommmc", 1 }, /* HSMMC1 */ - { "com", 0 }, /* UART0 */ - { "cpsw", 0 }, - { NULL, 0 } -}; - -struct board_dev overo_devs[] = { - { "prcm", 0 }, - { "intc", 0 }, - { "gptimer", 0 }, - { "gptimer", 1 }, - { "omdog", 0 }, - { "omgpio", 0 }, - { "omgpio", 1 }, - { "omgpio", 2 }, - { "omgpio", 3 }, - { "omgpio", 4 }, - { "omgpio", 5 }, - { "ommmc", 0 }, /* HSMMC1 */ - { "com", 2 }, /* UART3 */ - { NULL, 0 } -}; - -struct board_dev pandaboard_devs[] = { - { "omapid", 0 }, - { "prcm", 0 }, - { "omdog", 0 }, - { "omgpio", 0 }, - { "omgpio", 1 }, - { "omgpio", 2 }, - { "omgpio", 3 }, - { "omgpio", 4 }, - { "omgpio", 5 }, - { "ommmc", 0 }, /* HSMMC1 */ - { "com", 2 }, /* UART3 */ - { "ehci", 0 }, - { NULL, 0 } -}; - -struct board_dev sun4i_devs[] = { - { "sxipio", 0 }, - { "sxiccmu", 0 }, - { "a1xintc", 0 }, - { "sxitimer", 0 }, - { "sxitimer", 1 }, - { "sxitimer", 2 }, - { "sxidog", 0 }, - { "sxirtc", 0 }, - { "sxiuart", 0 }, - { "sxiuart", 1 }, - { "sxiuart", 2 }, - { "sxiuart", 3 }, - { "sxiuart", 4 }, - { "sxiuart", 5 }, - { "sxiuart", 6 }, - { "sxiuart", 7 }, - { "sxie", 0 }, - { "ahci", 0 }, - { "ehci", 0 }, - { "ehci", 1 }, -#if 0 - { "ohci", 0 }, - { "ohci", 1 }, -#endif - { NULL, 0 } -}; - -struct board_dev sun7i_devs[] = { - { "sxipio", 0 }, - { "sxiccmu", 0 }, - { "sxitimer", 0 }, - { "sxitimer", 1 }, - { "sxitimer", 2 }, - { "sxidog", 0 }, - { "sxirtc", 0 }, - { "sxiuart", 0 }, - { "sxiuart", 1 }, - { "sxiuart", 2 }, - { "sxiuart", 3 }, - { "sxiuart", 4 }, - { "sxiuart", 5 }, - { "sxiuart", 6 }, - { "sxiuart", 7 }, - { "sxie", 0 }, - { "ahci", 0 }, - { "ehci", 0 }, - { "ehci", 1 }, -#if 0 - { "ohci", 0 }, - { "ohci", 1 }, -#endif - { NULL, 0 } -}; - /* * We do direct configuration of devices on this SoC "bus", so we * never call the child device's match function at all (it can be @@ -388,109 +96,37 @@ armv7_match(struct device *parent, void *cfdata, void *aux) return (1); } +extern char *hw_prod; + +struct board_dev * (*board_attach[])(void) = { +#if NIMX > 0 + imx_board_attach, +#endif +#if NOMAP > 0 + omap_board_attach, +#endif +#if NSUNXI > 0 + sunxi_board_attach, +#endif +}; + void armv7_attach(struct device *parent, struct device *self, void *aux) { struct armv7_softc *sc = (struct armv7_softc *)self; struct board_dev *bd; - uint32_t issunxi = 0; - bus_space_handle_t ioh; + int i; - 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(); - sc->sc_board_devs = phyflex_imx6_devs; - break; - case BOARD_ID_IMX6_SABRELITE: - printf(": i.MX6 SABRE Lite\n"); - imx6_init(); - sc->sc_board_devs = sabrelite_devs; - break; - case BOARD_ID_IMX6_SABRESD: - printf(": i.MX6 SABRE SD\n"); - imx6_init(); - sc->sc_board_devs = sabresd_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_NOVENA: - printf(": i.MX6 Novena\n"); - imx6_init(); - sc->sc_board_devs = novena_devs; - break; - case BOARD_ID_IMX6_WANDBOARD: - printf(": i.MX6 Wandboard\n"); - imx6_init(); - sc->sc_board_devs = wandboard_devs; - break; - case BOARD_ID_OMAP3_BEAGLE: - printf(": BeagleBoard\n"); - omap3_init(); - sc->sc_board_devs = beagleboard_devs; - break; - case BOARD_ID_AM335X_BEAGLEBONE: - printf(": BeagleBone\n"); - am335x_init(); - sc->sc_board_devs = beaglebone_devs; - break; - case BOARD_ID_OMAP3_OVERO: - printf(": Gumstix Overo\n"); - omap3_init(); - sc->sc_board_devs = overo_devs; - break; - case BOARD_ID_OMAP4_PANDA: - printf(": PandaBoard\n"); - omap4_init(); - sc->sc_board_devs = pandaboard_devs; - break; - case BOARD_ID_SUN4I_A10: - printf(": A1X\n"); - sxia1x_init(); - sc->sc_board_devs = sun4i_devs; - issunxi = 1; - break; - case BOARD_ID_SUN7I_A20: - printf(": A20\n"); - sxia20_init(); - sc->sc_board_devs = sun7i_devs; - issunxi = 1; - break; - default: - printf("\n"); - panic("%s: board type 0x%x unknown", __func__, board_id); + for (i = 0; i < nitems(board_attach); i++) { + sc->sc_board_devs = board_attach[i](); + if (sc->sc_board_devs != NULL) + break; } - if (issunxi) { - /* - * XXX think of a better place to do this, as there might - * be need for access by other drivers later. - */ - if (bus_space_map(&armv7_bs_tag, SYSCTRL_ADDR, SYSCTRL_SIZE, 0, - &ioh)) - panic("sunxi_attach: bus_space_map failed!"); - /* map the part of SRAM dedicated to EMAC to EMAC */ - bus_space_write_4(&armv7_bs_tag, ioh, 4, - bus_space_read_4(&armv7_bs_tag, ioh, 4) | (5 << 2)); - } + if (hw_prod) + printf(": %s\n", hw_prod); + else + printf(": UNKNOWN BOARD %u\n", board_id); /* Directly configure on-board devices (dev* in config file). */ for (bd = sc->sc_board_devs; bd->name != NULL; bd++) { diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c index 7857212b438..6bb8746ad9b 100644 --- a/sys/arch/armv7/armv7/armv7_machdep.c +++ b/sys/arch/armv7/armv7/armv7_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7_machdep.c,v 1.21 2015/05/12 04:31:10 jsg Exp $ */ +/* $OpenBSD: armv7_machdep.c,v 1.22 2015/05/15 15:35:43 jsg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -755,7 +755,7 @@ initarm(void *arg0, void *arg1, void *arg2) if (boothowto & RB_KDB) Debugger(); #endif - platform_print_board_type(); + printf("board type: %u\n", board_id); /* We return the new stack pointer address */ return(kernelstack.pv_va + USPACE_SVC_STACK_TOP); diff --git a/sys/arch/armv7/armv7/armv7_machdep.h b/sys/arch/armv7/armv7/armv7_machdep.h index e133cdbd217..0243a8a4682 100644 --- a/sys/arch/armv7/armv7/armv7_machdep.h +++ b/sys/arch/armv7/armv7/armv7_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7_machdep.h,v 1.1 2013/10/30 20:20:23 syl Exp $ */ +/* $OpenBSD: armv7_machdep.h,v 1.2 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon * @@ -21,7 +21,7 @@ void platform_powerdown(void); void platform_watchdog_reset(void); void platform_init_cons(void); -void platform_print_board_type(void); +const char *platform_board_name(void); void platform_bootconfig_dram(BootConfig *, psize_t *, psize_t *); void platform_disable_l2_if_needed(void); extern const char *platform_boot_name; diff --git a/sys/arch/armv7/armv7/armv7var.h b/sys/arch/armv7/armv7/armv7var.h index 9d0414c264e..723e1cae94f 100644 --- a/sys/arch/armv7/armv7/armv7var.h +++ b/sys/arch/armv7/armv7/armv7var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7var.h,v 1.4 2015/05/08 03:38:26 jsg Exp $ */ +/* $OpenBSD: armv7var.h,v 1.5 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -25,6 +25,13 @@ struct board_dev { int unit; }; +struct armv7_board { + uint32_t board_id; + const char *name; + struct board_dev *devs; + void (*init)(void); +}; + /* Needed by omap, imx, sunxi */ struct armv7_softc { struct device sc_dv; @@ -93,5 +100,9 @@ void omap4_init(void); void sxia1x_init(void); void sxia20_init(void); +struct board_dev *imx_board_attach(void); +struct board_dev *omap_board_attach(void); +struct board_dev *sunxi_board_attach(void); + #endif /* __ARMV7VAR_H__ */ diff --git a/sys/arch/armv7/armv7/autoconf.c b/sys/arch/armv7/armv7/autoconf.c index 5f89e5ddf5c..9d33337ff73 100644 --- a/sys/arch/armv7/armv7/autoconf.c +++ b/sys/arch/armv7/armv7/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.1 2013/09/04 14:38:25 patrick Exp $ */ +/* $OpenBSD: autoconf.c,v 1.2 2015/05/15 15:35:43 jsg Exp $ */ /* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */ /* @@ -53,7 +53,10 @@ #include #include +#include + struct device *bootdv = NULL; +extern char *hw_prod; void dumpconf(void); @@ -71,6 +74,15 @@ device_register(struct device *dev, void *aux) void cpu_configure(void) { + int len; + const char *name = platform_board_name(); + if (name) { + len = strlen(name) + 1; + hw_prod = malloc(len, M_DEVBUF, M_NOWAIT); + if (hw_prod) + strlcpy(hw_prod, name, len); + } + softintr_init(); /* diff --git a/sys/arch/armv7/exynos/exynos.c b/sys/arch/armv7/exynos/exynos.c index dc370633cc8..57171dddd2b 100644 --- a/sys/arch/armv7/exynos/exynos.c +++ b/sys/arch/armv7/exynos/exynos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exynos.c,v 1.1 2015/01/26 02:48:24 bmercer Exp $ */ +/* $OpenBSD: exynos.c,v 1.2 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -69,3 +69,42 @@ struct board_dev chromebook_devs[] = { // { "exesdhc", 3 }, { NULL, 0 } }; + +struct armv7_board exynos_boards[] = { + { + BOARD_ID_EXYNOS5_CHROMEBOOK, + "Exynos 5 Chromebook", + chromebook_devs, + exynos5_init, + }, + { 0, NULL, NULL, NULL }, +}; + +struct board_dev * +exynos_board_attach(void) +{ + int i; + + for (i = 0; exynos_boards[i].name != NULL; i++) { + if (exynos_boards[i].board_id == board_id) { + exynos_boards[i].init(); + return (exynos_boards[i].devs); + break; + } + } + return (NULL); +} + +const char * +exynos_board_name(void) +{ + int i; + + for (i = 0; exynos_boards[i].name != NULL; i++) { + if (exynos_boards[i].board_id == board_id) { + return (exynos_boards[i].name); + break; + } + } + return (NULL); +} diff --git a/sys/arch/armv7/exynos/exynos_machdep.c b/sys/arch/armv7/exynos/exynos_machdep.c index aff9bf38c13..ae2e210d2c7 100644 --- a/sys/arch/armv7/exynos/exynos_machdep.c +++ b/sys/arch/armv7/exynos/exynos_machdep.c @@ -30,6 +30,7 @@ #include extern void exdog_reset(void); +extern char *exynos_board_name(void); extern int32_t agtimer_frequency; extern int comcnspeed; extern int comcnmode; @@ -79,17 +80,10 @@ exynos_platform_powerdown(void) } -static void -exynos_platform_print_board_type(void) +const char * +platform_board_name(void) { - switch (board_id) { - case BOARD_ID_EXYNOS5_CHROMEBOOK: - agtimer_frequency = 24 * 1000 * 1000; - printf("board type: Exynos 5 Chromebook\n"); - break; - default: - printf("board type %x unknown\n", board_id); - } + return (exynos_board_name()); } static void diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx index a408d71a880..3e7ec3351f6 100644 --- a/sys/arch/armv7/imx/files.imx +++ b/sys/arch/armv7/imx/files.imx @@ -1,9 +1,9 @@ -# $OpenBSD: files.imx,v 1.2 2013/11/06 19:03:07 syl Exp $ +# $OpenBSD: files.imx,v 1.3 2015/05/15 15:35:43 jsg Exp $ define imx {} device imx: imx attach imx at mainbus -file arch/armv7/imx/imx_machdep.c imx +file arch/armv7/imx/imx_machdep.c imx needs-flag file arch/armv7/imx/imx.c imx file arch/armv7/imx/imx6.c diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c index d08a5438c91..17c5ab2eca9 100644 --- a/sys/arch/armv7/imx/imx.c +++ b/sys/arch/armv7/imx/imx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx.c,v 1.3 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: imx.c,v 1.4 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -32,3 +32,258 @@ struct cfdriver imx_cd = { NULL, "imx", DV_DULL }; +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 }, + { "imxdog", 0 }, + { "imxocotp", 0 }, + { "imxuart", 3 }, + { "imxgpio", 0 }, + { "imxgpio", 1 }, + { "imxgpio", 2 }, + { "imxgpio", 3 }, + { "imxgpio", 4 }, + { "imxgpio", 5 }, + { "imxgpio", 6 }, + { "imxesdhc", 1 }, + { "imxesdhc", 2 }, + { "ehci", 0 }, + { "imxenet", 0 }, + { "ahci", 0 }, + { NULL, 0 } +}; + +struct board_dev sabrelite_devs[] = { + { "imxccm", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxocotp", 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 sabresd_devs[] = { + { "imxocotp", 0 }, + { "imxccm", 0 }, + { "imxtemp", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxuart", 0 }, + { "imxgpio", 0 }, + { "imxgpio", 1 }, + { "imxgpio", 2 }, + { "imxgpio", 3 }, + { "imxgpio", 4 }, + { "imxgpio", 5 }, + { "imxgpio", 6 }, + { "imxesdhc", 1 }, + { "imxesdhc", 2 }, + { "imxesdhc", 3 }, + { "ehci", 0 }, + { "imxenet", 0 }, + { "ahci", 0 }, + { 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 }, + { "imxesdhc", 2 }, + { "ehci", 0 }, + { "imxenet", 0 }, + { "ahci", 0 }, + { NULL, 0 } +}; + +struct board_dev novena_devs[] = { + { "imxccm", 0 }, + { "imxiomuxc", 0 }, + { "imxdog", 0 }, + { "imxocotp", 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 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 armv7_board imx_boards[] = { + { + BOARD_ID_IMX6_CUBOXI, + "SolidRun CuBox-i", + hummingboard_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_HUMMINGBOARD, + "SolidRun HummingBoard", + hummingboard_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_PHYFLEX, + "Phytec phyFLEX-i.MX6", + phyflex_imx6_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_SABRELITE, + "Freescale i.MX6 SABRE Lite", + sabrelite_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_SABRESD, + "Freescale i.MX6 SABRE SD", + sabresd_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_UDOO, + "Udoo i.MX6", + udoo_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_UTILITE, + "CompuLab Utilite", + utilite_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_NOVENA, + "Kosagi Novena", + novena_devs, + imx6_init, + }, + { + BOARD_ID_IMX6_WANDBOARD, + "Wandboard i.MX6", + wandboard_devs, + imx6_init, + }, + { 0, NULL, NULL, NULL }, +}; + +struct board_dev * +imx_board_attach(void) +{ + int i; + + for (i = 0; imx_boards[i].name != NULL; i++) { + if (imx_boards[i].board_id == board_id) { + imx_boards[i].init(); + return (imx_boards[i].devs); + break; + } + } + return (NULL); +} + +const char * +imx_board_name(void) +{ + int i; + + for (i = 0; imx_boards[i].name != NULL; i++) { + if (imx_boards[i].board_id == board_id) { + return (imx_boards[i].name); + break; + } + } + return (NULL); +} diff --git a/sys/arch/armv7/imx/imx_machdep.c b/sys/arch/armv7/imx/imx_machdep.c index cfc67ceeb4b..67099f59145 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.12 2015/05/08 03:38:26 jsg Exp $ */ +/* $OpenBSD: imx_machdep.c,v 1.13 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon * @@ -33,6 +33,7 @@ #include extern void imxdog_reset(void); +extern char *imx_board_name(void); extern int32_t amptimer_frequency; extern int comcnspeed; extern int comcnmode; @@ -90,49 +91,10 @@ platform_powerdown(void) } -void -platform_print_board_type(void) +const char * +platform_board_name(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"); - break; - case BOARD_ID_IMX6_SABRELITE: - amptimer_frequency = 396 * 1000 * 1000; - printf("board type: SABRE Lite\n"); - break; - case BOARD_ID_IMX6_SABRESD: - amptimer_frequency = 396 * 1000 * 1000; - printf("board type: SABRE SD\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_NOVENA: - amptimer_frequency = 396 * 1000 * 1000; - printf("board type: Novena\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); - } + return (imx_board_name()); } void diff --git a/sys/arch/armv7/omap/files.omap b/sys/arch/armv7/omap/files.omap index 697e0ac2b41..8fd446f32de 100644 --- a/sys/arch/armv7/omap/files.omap +++ b/sys/arch/armv7/omap/files.omap @@ -1,9 +1,9 @@ -# $OpenBSD: files.omap,v 1.6 2014/03/18 07:34:17 syl Exp $ +# $OpenBSD: files.omap,v 1.7 2015/05/15 15:35:43 jsg Exp $ define omap {} device omap: omap attach omap at mainbus -file arch/armv7/omap/omap_machdep.c omap +file arch/armv7/omap/omap_machdep.c omap needs-flag file arch/armv7/omap/omap.c omap file arch/armv7/omap/omap3.c file arch/armv7/omap/omap4.c diff --git a/sys/arch/armv7/omap/omap.c b/sys/arch/armv7/omap/omap.c index 56e0cc2efe2..2ed35880efc 100644 --- a/sys/arch/armv7/omap/omap.c +++ b/sys/arch/armv7/omap/omap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap.c,v 1.4 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: omap.c,v 1.5 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * @@ -30,3 +30,131 @@ struct cfdriver omap_cd = { NULL, "omap", DV_DULL }; +struct board_dev beagleboard_devs[] = { + { "prcm", 0 }, + { "intc", 0 }, + { "gptimer", 0 }, + { "gptimer", 1 }, + { "omdog", 0 }, + { "omgpio", 0 }, + { "omgpio", 1 }, + { "omgpio", 2 }, + { "omgpio", 3 }, + { "omgpio", 4 }, + { "omgpio", 5 }, + { "ommmc", 0 }, /* HSMMC1 */ + { "com", 2 }, /* UART3 */ + { NULL, 0 } +}; + +struct board_dev beaglebone_devs[] = { + { "prcm", 0 }, + { "sitaracm", 0 }, + { "intc", 0 }, + { "edma", 0 }, + { "dmtimer", 0 }, + { "dmtimer", 1 }, + { "omdog", 0 }, + { "omgpio", 0 }, + { "omgpio", 1 }, + { "omgpio", 2 }, + { "omgpio", 3 }, + { "tiiic", 0 }, + { "tiiic", 1 }, + { "tiiic", 2 }, + { "ommmc", 0 }, /* HSMMC0 */ + { "ommmc", 1 }, /* HSMMC1 */ + { "com", 0 }, /* UART0 */ + { "cpsw", 0 }, + { NULL, 0 } +}; + +struct board_dev overo_devs[] = { + { "prcm", 0 }, + { "intc", 0 }, + { "gptimer", 0 }, + { "gptimer", 1 }, + { "omdog", 0 }, + { "omgpio", 0 }, + { "omgpio", 1 }, + { "omgpio", 2 }, + { "omgpio", 3 }, + { "omgpio", 4 }, + { "omgpio", 5 }, + { "ommmc", 0 }, /* HSMMC1 */ + { "com", 2 }, /* UART3 */ + { NULL, 0 } +}; + +struct board_dev pandaboard_devs[] = { + { "omapid", 0 }, + { "prcm", 0 }, + { "omdog", 0 }, + { "omgpio", 0 }, + { "omgpio", 1 }, + { "omgpio", 2 }, + { "omgpio", 3 }, + { "omgpio", 4 }, + { "omgpio", 5 }, + { "ommmc", 0 }, /* HSMMC1 */ + { "com", 2 }, /* UART3 */ + { "ehci", 0 }, + { NULL, 0 } +}; + +struct armv7_board omap_boards[] = { + { + BOARD_ID_OMAP3_BEAGLE, + "TI OMAP3 BeagleBoard", + beagleboard_devs, + omap3_init, + }, + { + BOARD_ID_AM335X_BEAGLEBONE, + "TI AM335x BeagleBone", + beaglebone_devs, + am335x_init, + }, + { + BOARD_ID_OMAP3_OVERO, + "Gumstix OMAP3 Overo", + overo_devs, + omap3_init, + }, + { + BOARD_ID_OMAP4_PANDA, + "TI OMAP4 PandaBoard", + pandaboard_devs, + omap4_init, + }, + { 0, NULL, NULL, NULL }, +}; + +struct board_dev * +omap_board_attach(void) +{ + int i; + + for (i = 0; omap_boards[i].name != NULL; i++) { + if (omap_boards[i].board_id == board_id) { + omap_boards[i].init(); + return (omap_boards[i].devs); + break; + } + } + return (NULL); +} + +const char * +omap_board_name(void) +{ + int i; + + for (i = 0; omap_boards[i].name != NULL; i++) { + if (omap_boards[i].board_id == board_id) { + return (omap_boards[i].name); + break; + } + } + return (NULL); +} diff --git a/sys/arch/armv7/omap/omap_machdep.c b/sys/arch/armv7/omap/omap_machdep.c index 1d4ff31874f..f3bb79d78e5 100644 --- a/sys/arch/armv7/omap/omap_machdep.c +++ b/sys/arch/armv7/omap/omap_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap_machdep.c,v 1.3 2015/01/22 14:33:01 krw Exp $ */ +/* $OpenBSD: omap_machdep.c,v 1.4 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon * @@ -34,6 +34,7 @@ extern void omap4_smc_call(uint32_t, uint32_t); extern void omdog_reset(void); +extern char *omap_board_name(void); extern int comcnspeed; extern int comcnmode; @@ -88,25 +89,10 @@ platform_powerdown(void) } -void -platform_print_board_type(void) +const char * +platform_board_name(void) { - switch (board_id) { - case BOARD_ID_OMAP3_BEAGLE: - printf("board type: beagle\n"); - break; - case BOARD_ID_AM335X_BEAGLEBONE: - printf("board type: beaglebone\n"); - break; - case BOARD_ID_OMAP3_OVERO: - printf("board type: overo\n"); - break; - case BOARD_ID_OMAP4_PANDA: - printf("board type: panda\n"); - break; - default: - printf("board type %x unknown", board_id); - } + return (omap_board_name()); } void diff --git a/sys/arch/armv7/sunxi/files.sunxi b/sys/arch/armv7/sunxi/files.sunxi index 8a21e510bb3..80c4ba4a9b4 100644 --- a/sys/arch/armv7/sunxi/files.sunxi +++ b/sys/arch/armv7/sunxi/files.sunxi @@ -1,9 +1,9 @@ -# $OpenBSD: files.sunxi,v 1.2 2013/11/06 19:03:07 syl Exp $ +# $OpenBSD: files.sunxi,v 1.3 2015/05/15 15:35:43 jsg Exp $ define sunxi {} device sunxi: sunxi attach sunxi at mainbus -file arch/armv7/sunxi/sunxi_machdep.c sunxi +file arch/armv7/sunxi/sunxi_machdep.c sunxi needs-flag file arch/armv7/sunxi/sunxi.c sunxi file arch/armv7/sunxi/sun4i.c file arch/armv7/sunxi/sun7i.c diff --git a/sys/arch/armv7/sunxi/sunxi.c b/sys/arch/armv7/sunxi/sunxi.c index 41936919b41..cbcb90bdf7f 100644 --- a/sys/arch/armv7/sunxi/sunxi.c +++ b/sys/arch/armv7/sunxi/sunxi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunxi.c,v 1.3 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: sunxi.c,v 1.4 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * @@ -20,7 +20,9 @@ #include +#include #include +#include struct cfattach sunxi_ca = { sizeof(struct armv7_softc), armv7_match, armv7_attach @@ -29,3 +31,116 @@ struct cfattach sunxi_ca = { struct cfdriver sunxi_cd = { NULL, "sunxi", DV_DULL }; + +struct board_dev sun4i_devs[] = { + { "sxipio", 0 }, + { "sxiccmu", 0 }, + { "a1xintc", 0 }, + { "sxitimer", 0 }, + { "sxitimer", 1 }, + { "sxitimer", 2 }, + { "sxidog", 0 }, + { "sxirtc", 0 }, + { "sxiuart", 0 }, + { "sxiuart", 1 }, + { "sxiuart", 2 }, + { "sxiuart", 3 }, + { "sxiuart", 4 }, + { "sxiuart", 5 }, + { "sxiuart", 6 }, + { "sxiuart", 7 }, + { "sxie", 0 }, + { "ahci", 0 }, + { "ehci", 0 }, + { "ehci", 1 }, +#if 0 + { "ohci", 0 }, + { "ohci", 1 }, +#endif + { NULL, 0 } +}; + +struct board_dev sun7i_devs[] = { + { "sxipio", 0 }, + { "sxiccmu", 0 }, + { "sxitimer", 0 }, + { "sxitimer", 1 }, + { "sxitimer", 2 }, + { "sxidog", 0 }, + { "sxirtc", 0 }, + { "sxiuart", 0 }, + { "sxiuart", 1 }, + { "sxiuart", 2 }, + { "sxiuart", 3 }, + { "sxiuart", 4 }, + { "sxiuart", 5 }, + { "sxiuart", 6 }, + { "sxiuart", 7 }, + { "sxie", 0 }, + { "ahci", 0 }, + { "ehci", 0 }, + { "ehci", 1 }, +#if 0 + { "ohci", 0 }, + { "ohci", 1 }, +#endif + { NULL, 0 } +}; + +struct armv7_board sunxi_boards[] = { + { + BOARD_ID_SUN4I_A10, + "Allwinner A1x", + sun4i_devs, + sxia1x_init, + }, + { + BOARD_ID_SUN7I_A20, + "Allwinner A20", + sun7i_devs, + sxia20_init, + }, + { 0, NULL, NULL, NULL }, +}; + + +struct board_dev * +sunxi_board_attach(void) +{ + struct board_dev *devs = NULL; + bus_space_handle_t ioh; + int i; + + for (i = 0; sunxi_boards[i].name != NULL; i++) { + if (sunxi_boards[i].board_id == board_id) { + sunxi_boards[i].init(); + devs = sunxi_boards[i].devs; + break; + } + } + + if (devs) { + if (bus_space_map(&armv7_bs_tag, SYSCTRL_ADDR, SYSCTRL_SIZE, 0, + &ioh)) + panic("sunxi_attach: bus_space_map failed!"); + /* map the part of SRAM dedicated to EMAC to EMAC */ + bus_space_write_4(&armv7_bs_tag, ioh, 4, + bus_space_read_4(&armv7_bs_tag, ioh, 4) | (5 << 2)); + } + + return (devs); +} + +const char * +sunxi_board_name(void) +{ + int i; + + for (i = 0; sunxi_boards[i].name != NULL; i++) { + if (sunxi_boards[i].board_id == board_id) { + return (sunxi_boards[i].name); + break; + } + } + return (NULL); +} diff --git a/sys/arch/armv7/sunxi/sunxi_machdep.c b/sys/arch/armv7/sunxi/sunxi_machdep.c index 398893d0b41..5972b1c9784 100644 --- a/sys/arch/armv7/sunxi/sunxi_machdep.c +++ b/sys/arch/armv7/sunxi/sunxi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunxi_machdep.c,v 1.5 2015/01/22 14:33:01 krw Exp $ */ +/* $OpenBSD: sunxi_machdep.c,v 1.6 2015/05/15 15:35:43 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon * @@ -33,6 +33,7 @@ extern int sxiuartcnattach(bus_space_tag_t, bus_addr_t, int, long, tcflag_t); extern void sxidog_reset(void); +extern char *sunxi_board_name(void); extern int comcnspeed; extern int comcnmode; @@ -77,10 +78,10 @@ platform_powerdown(void) } -void -platform_print_board_type(void) +const char * +platform_board_name(void) { - + return (sunxi_board_name()); } void -- 2.20.1