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.
Index: armv7/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/armv7.c 12 May 2015 04:40:31 -0000 1.8
+++ armv7/armv7/armv7.c 13 May 2015 03:30:43 -0000
@@ -388,6 +388,8 @@ armv7_match(struct device *parent, void
return (1);
}
+extern char *hw_prod;
+
void
armv7_attach(struct device *parent, struct device *self, void *aux)
{
@@ -398,78 +400,60 @@ armv7_attach(struct device *parent, stru
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;
@@ -478,6 +462,10 @@ armv7_attach(struct device *parent, stru
printf("\n");
panic("%s: board type 0x%x unknown", __func__, board_id);
}
+
+ if (hw_prod)
+ printf(": %s", hw_prod);
+ printf("\n");
if (issunxi) {
/*
Index: armv7/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/armv7_machdep.c 12 May 2015 04:31:10 -0000 1.21
+++ armv7/armv7/armv7_machdep.c 13 May 2015 03:30:43 -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/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/armv7/autoconf.c 4 Sep 2013 14:38:25 -0000 1.1
+++ armv7/armv7/autoconf.c 13 May 2015 03:30:43 -0000
@@ -53,6 +53,8 @@
#include <machine/bootconfig.h>
#include <machine/intr.h>
+#include <armv7/armv7/armv7_machdep.h>
+
struct device *bootdv = NULL;
void dumpconf(void);
@@ -71,6 +73,8 @@ device_register(struct device *dev, void
void
cpu_configure(void)
{
+ platform_print_board_type();
+
softintr_init();
/*
Index: armv7/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
--- armv7/exynos/exynos_machdep.c 26 Jan 2015 02:48:24 -0000 1.1
+++ armv7/exynos/exynos_machdep.c 13 May 2015 03:30:43 -0000
@@ -34,6 +34,17 @@ extern int32_t agtimer_frequency;
extern int comcnspeed;
extern int comcnmode;
+extern char *hw_prod;
+
+struct {
+ uint32_t board_id;
+ const char *product;
+} board_names[] = {
+ { BOARD_ID_EXYNOS5_CHROMEBOOK, "Exynos 5 Chromebook" },
+ { 0, NULL },
+};
+
+
static void
exynos_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t off,
uint32_t op, uint32_t val)
@@ -82,13 +93,18 @@ exynos_platform_powerdown(void)
static void
exynos_platform_print_board_type(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);
+ int i, len;
+
+ agtimer_frequency = 24 * 1000 * 1000;
+
+ for (i = 0; board_names[i].product != NULL; i++) {
+ if (board_names[i].board_id == board_id) {
+ len = strlen(board_names[i].product) + 1;
+ hw_prod = malloc(len, M_DEVBUF, M_NOWAIT);
+ if (hw_prod)
+ strlcpy(hw_prod, board_names[i].product, len);
+ break;
+ }
}
}
Index: armv7/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
--- armv7/imx/imx_machdep.c 8 May 2015 03:38:26 -0000 1.12
+++ armv7/imx/imx_machdep.c 13 May 2015 03:30:43 -0000
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/termios.h>
+#include <sys/malloc.h>
#include <machine/bus.h>
#include <machine/bootconfig.h>
@@ -38,6 +39,23 @@ extern int comcnspeed;
extern int comcnmode;
const char *platform_boot_name = "OpenBSD/imx";
+extern char *hw_prod;
+
+struct {
+ uint32_t board_id;
+ const char *product;
+} board_names[] = {
+ { BOARD_ID_IMX6_CUBOXI, "SolidRun CuBox-i" },
+ { BOARD_ID_IMX6_HUMMINGBOARD, "SolidRun HummingBoard" },
+ { BOARD_ID_IMX6_PHYFLEX, "Phytec phyFLEX-i.MX6" },
+ { BOARD_ID_IMX6_SABRELITE, "Freescale i.MX6 SABRE Lite" },
+ { BOARD_ID_IMX6_SABRESD, "Freescale i.MX6 SABRE SD" },
+ { BOARD_ID_IMX6_UDOO, "Udoo i.MX6" },
+ { BOARD_ID_IMX6_UTILITE, "CompuLab Utilite" },
+ { BOARD_ID_IMX6_NOVENA, "Kosagi Novena" },
+ { BOARD_ID_IMX6_WANDBOARD, "Wandboard i.MX6" },
+ { 0, NULL },
+};
void
platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
@@ -93,45 +111,17 @@ platform_powerdown(void)
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");
- 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);
+ int i, len;
+ amptimer_frequency = 396 * 1000 * 1000;
+
+ for (i = 0; board_names[i].product != NULL; i++) {
+ if (board_names[i].board_id == board_id) {
+ len = strlen(board_names[i].product) + 1;
+ hw_prod = malloc(len, M_DEVBUF, M_NOWAIT);
+ if (hw_prod)
+ strlcpy(hw_prod, board_names[i].product, len);
+ break;
+ }
}
}
Index: armv7/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
--- armv7/omap/omap_machdep.c 22 Jan 2015 14:33:01 -0000 1.3
+++ armv7/omap/omap_machdep.c 13 May 2015 03:30:43 -0000
@@ -20,6 +20,7 @@
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/termios.h>
+#include <sys/malloc.h>
#include <machine/bus.h>
#include <machine/bootconfig.h>
@@ -38,6 +39,18 @@ extern int comcnspeed;
extern int comcnmode;
const char *platform_boot_name = "OpenBSD/omap";
+extern char *hw_prod;
+
+struct {
+ uint32_t board_id;
+ const char *product;
+} board_names[] = {
+ { BOARD_ID_OMAP3_BEAGLE, "TI OMAP3 BeagleBoard" },
+ { BOARD_ID_AM335X_BEAGLEBONE, "TI AM335x BeagleBone" },
+ { BOARD_ID_OMAP3_OVERO, "Gumstix OMAP3 Overo" },
+ { BOARD_ID_OMAP4_PANDA, "TI OMAP4 PandaBoard" },
+ { 0, NULL },
+};
void
platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
@@ -91,21 +104,16 @@ platform_powerdown(void)
void
platform_print_board_type(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);
+ int i, len;
+
+ for (i = 0; board_names[i].product != NULL; i++) {
+ if (board_names[i].board_id == board_id) {
+ len = strlen(board_names[i].product) + 1;
+ hw_prod = malloc(len, M_DEVBUF, M_NOWAIT);
+ if (hw_prod)
+ strlcpy(hw_prod, board_names[i].product, len);
+ break;
+ }
}
}
Index: armv7/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
--- armv7/sunxi/sunxi_machdep.c 22 Jan 2015 14:33:01 -0000 1.5
+++ armv7/sunxi/sunxi_machdep.c 13 May 2015 03:30:43 -0000
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/termios.h>
+#include <sys/malloc.h>
#include <machine/bus.h>
#include <machine/bootconfig.h>
@@ -37,6 +38,16 @@ extern int comcnspeed;
extern int comcnmode;
const char *platform_boot_name = "OpenBSD/sunxi";
+extern char *hw_prod;
+
+struct {
+ uint32_t board_id;
+ const char *product;
+} board_names[] = {
+ { BOARD_ID_SUN4I_A10, "Allwinner A1x" },
+ { BOARD_ID_SUN7I_A20, "Allwinner A20" },
+ { 0, NULL },
+};
void
platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
@@ -80,7 +91,17 @@ platform_powerdown(void)
void
platform_print_board_type(void)
{
+ int i, len;
+ for (i = 0; board_names[i].product != NULL; i++) {
+ if (board_names[i].board_id == board_id) {
+ len = strlen(board_names[i].product) + 1;
+ hw_prod = malloc(len, M_DEVBUF, M_NOWAIT);
+ if (hw_prod)
+ strlcpy(hw_prod, board_names[i].product, len);
+ break;
+ }
+ }
}
void