On Wed, May 13, 2015 at 01:47:48PM +1000, Jonathan Gray wrote:
> Instead of hard coding board names twice use an array and put the value
> in hw_prod so it will show up in sysctl.
>
> This omits setting hw_vendor as fdt sets just one string and
> we'll likely move to that at some point.
>
> The printf from before copyright changes to the decimal
> machine id/board id.
Here's an extended version that moves the device tables out into the soc
directories.
The agtimer/amptimer frequency is no longer set in imx/exynos
directories as both were just setting the respective TIMER_FREQUENCY
values.
Tested on bbb and qemu-system-arm -M cubieboard.
Index: armv7/armv7.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/armv7/armv7.c,v
retrieving revision 1.8
diff -u -p -r1.8 armv7.c
--- armv7/armv7.c 12 May 2015 04:40:31 -0000 1.8
+++ armv7/armv7.c 14 May 2015 06:43:31 -0000
@@ -22,7 +22,10 @@
#include <machine/bus.h>
#include <arm/armv7/armv7var.h>
#include <armv7/armv7/armv7var.h>
-#include <armv7/sunxi/sunxireg.h>
+
+#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
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++) {
Index: armv7/armv7_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/armv7/armv7_machdep.c,v
retrieving revision 1.21
diff -u -p -r1.21 armv7_machdep.c
--- armv7/armv7_machdep.c 12 May 2015 04:31:10 -0000 1.21
+++ armv7/armv7_machdep.c 14 May 2015 06:43:32 -0000
@@ -755,7 +755,7 @@ initarm(void *arg0, void *arg1, void *ar
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);
Index: armv7/armv7_machdep.h
===================================================================
RCS file: /cvs/src/sys/arch/armv7/armv7/armv7_machdep.h,v
retrieving revision 1.1
diff -u -p -r1.1 armv7_machdep.h
--- armv7/armv7_machdep.h 30 Oct 2013 20:20:23 -0000 1.1
+++ armv7/armv7_machdep.h 14 May 2015 06:43:32 -0000
@@ -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;
Index: armv7/armv7var.h
===================================================================
RCS file: /cvs/src/sys/arch/armv7/armv7/armv7var.h,v
retrieving revision 1.4
diff -u -p -r1.4 armv7var.h
--- armv7/armv7var.h 8 May 2015 03:38:26 -0000 1.4
+++ armv7/armv7var.h 14 May 2015 06:43:32 -0000
@@ -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;
@@ -92,6 +99,10 @@ void omap3_init(void);
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__ */
Index: armv7/autoconf.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/armv7/autoconf.c,v
retrieving revision 1.1
diff -u -p -r1.1 autoconf.c
--- armv7/autoconf.c 4 Sep 2013 14:38:25 -0000 1.1
+++ armv7/autoconf.c 14 May 2015 06:43:32 -0000
@@ -53,7 +53,10 @@
#include <machine/bootconfig.h>
#include <machine/intr.h>
+#include <armv7/armv7/armv7_machdep.h>
+
struct device *bootdv = NULL;
+extern char *hw_prod;
void dumpconf(void);
@@ -71,6 +74,15 @@ device_register(struct device *dev, void
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();
/*
Index: exynos/exynos.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/exynos/exynos.c,v
retrieving revision 1.1
diff -u -p -r1.1 exynos.c
--- exynos/exynos.c 26 Jan 2015 02:48:24 -0000 1.1
+++ exynos/exynos.c 14 May 2015 06:43:32 -0000
@@ -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);
+}
Index: exynos/exynos_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/exynos/exynos_machdep.c,v
retrieving revision 1.1
diff -u -p -r1.1 exynos_machdep.c
--- exynos/exynos_machdep.c 26 Jan 2015 02:48:24 -0000 1.1
+++ exynos/exynos_machdep.c 14 May 2015 06:43:32 -0000
@@ -30,6 +30,7 @@
#include <armv7/armv7/armv7_machdep.h>
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
Index: imx/files.imx
===================================================================
RCS file: /cvs/src/sys/arch/armv7/imx/files.imx,v
retrieving revision 1.2
diff -u -p -r1.2 files.imx
--- imx/files.imx 6 Nov 2013 19:03:07 -0000 1.2
+++ imx/files.imx 14 May 2015 06:43:32 -0000
@@ -3,7 +3,7 @@
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
Index: imx/imx.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/imx/imx.c,v
retrieving revision 1.3
diff -u -p -r1.3 imx.c
--- imx/imx.c 6 Nov 2013 19:03:07 -0000 1.3
+++ imx/imx.c 14 May 2015 06:43:32 -0000
@@ -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);
+}
Index: imx/imx_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/imx/imx_machdep.c,v
retrieving revision 1.12
diff -u -p -r1.12 imx_machdep.c
--- imx/imx_machdep.c 8 May 2015 03:38:26 -0000 1.12
+++ imx/imx_machdep.c 14 May 2015 06:43:32 -0000
@@ -33,6 +33,7 @@
#include <armv7/armv7/armv7_machdep.h>
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
Index: omap/files.omap
===================================================================
RCS file: /cvs/src/sys/arch/armv7/omap/files.omap,v
retrieving revision 1.6
diff -u -p -r1.6 files.omap
--- omap/files.omap 18 Mar 2014 07:34:17 -0000 1.6
+++ omap/files.omap 14 May 2015 06:43:32 -0000
@@ -3,7 +3,7 @@
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
Index: omap/omap.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/omap/omap.c,v
retrieving revision 1.4
diff -u -p -r1.4 omap.c
--- omap/omap.c 6 Nov 2013 19:03:07 -0000 1.4
+++ omap/omap.c 14 May 2015 06:43:32 -0000
@@ -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);
+}
Index: omap/omap_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/omap/omap_machdep.c,v
retrieving revision 1.3
diff -u -p -r1.3 omap_machdep.c
--- omap/omap_machdep.c 22 Jan 2015 14:33:01 -0000 1.3
+++ omap/omap_machdep.c 14 May 2015 06:43:32 -0000
@@ -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
Index: sunxi/files.sunxi
===================================================================
RCS file: /cvs/src/sys/arch/armv7/sunxi/files.sunxi,v
retrieving revision 1.2
diff -u -p -r1.2 files.sunxi
--- sunxi/files.sunxi 6 Nov 2013 19:03:07 -0000 1.2
+++ sunxi/files.sunxi 14 May 2015 06:43:32 -0000
@@ -3,7 +3,7 @@
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
Index: sunxi/sunxi.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/sunxi/sunxi.c,v
retrieving revision 1.3
diff -u -p -r1.3 sunxi.c
--- sunxi/sunxi.c 6 Nov 2013 19:03:07 -0000 1.3
+++ sunxi/sunxi.c 14 May 2015 06:43:32 -0000
@@ -20,7 +20,9 @@
#include <machine/bus.h>
+#include <arm/armv7/armv7var.h>
#include <armv7/armv7/armv7var.h>
+#include <armv7/sunxi/sunxireg.h>
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);
+}
Index: sunxi/sunxi_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/sunxi/sunxi_machdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 sunxi_machdep.c
--- sunxi/sunxi_machdep.c 22 Jan 2015 14:33:01 -0000 1.5
+++ sunxi/sunxi_machdep.c 14 May 2015 06:43:32 -0000
@@ -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