diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-05-19 03:30:55 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-05-19 03:30:55 +0000 |
commit | b098ed7dc4876291686b3ad382cda7283ca950c0 (patch) | |
tree | fc13c2f9139f6a95153c2a2d0977b2699449c050 | |
parent | fc24250d0c9b59294f4a462cbc3f8f32f731e32b (diff) |
Abstract the soc_machdep.c functions to allow a kernel to be built for
multiple socs.
From Patrick Wildt in bitrig with some additional changes.
-rw-r--r-- | sys/arch/armv7/armv7/armv7.c | 27 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/armv7_machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/armv7_machdep.h | 23 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/armv7var.h | 14 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/autoconf.c | 3 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/platform.c | 117 | ||||
-rw-r--r-- | sys/arch/armv7/conf/files.armv7 | 3 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/exynos.c | 20 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/exynos_machdep.c | 29 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imx.c | 20 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imx_machdep.c | 49 | ||||
-rw-r--r-- | sys/arch/armv7/omap/omap.c | 22 | ||||
-rw-r--r-- | sys/arch/armv7/omap/omap_machdep.c | 50 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sunxi.c | 29 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sunxi_machdep.c | 49 |
15 files changed, 364 insertions, 100 deletions
diff --git a/sys/arch/armv7/armv7/armv7.c b/sys/arch/armv7/armv7/armv7.c index 817553284e6..e1385155ec4 100644 --- a/sys/arch/armv7/armv7/armv7.c +++ b/sys/arch/armv7/armv7/armv7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7.c,v 1.9 2015/05/15 15:35:43 jsg Exp $ */ +/* $OpenBSD: armv7.c,v 1.10 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -22,10 +22,7 @@ #include <machine/bus.h> #include <arm/armv7/armv7var.h> #include <armv7/armv7/armv7var.h> - -#include "imx.h" -#include "omap.h" -#include "sunxi.h" +#include <armv7/armv7/armv7_machdep.h> struct arm32_bus_dma_tag armv7_bus_dma_tag = { 0, @@ -98,30 +95,14 @@ armv7_match(struct device *parent, void *cfdata, void *aux) 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; - int i; - for (i = 0; i < nitems(board_attach); i++) { - sc->sc_board_devs = board_attach[i](); - if (sc->sc_board_devs != NULL) - break; - } + platform_board_init(); + sc->sc_board_devs = platform_board_devs(); if (hw_prod) printf(": %s\n", hw_prod); diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c index 6e8087ee38d..da8e1575b72 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.23 2015/05/19 00:05:59 jsg Exp $ */ +/* $OpenBSD: armv7_machdep.c,v 1.24 2015/05/19 03:30:54 jsg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -404,8 +404,6 @@ initarm(void *arg0, void *arg1, void *arg2) if (set_cpufuncs()) panic("cpu not recognized!"); - platform_disable_l2_if_needed(); - /* * Temporarily replace bus_space_map() functions so that * console devices can get mapped. @@ -419,11 +417,14 @@ initarm(void *arg0, void *arg1, void *arg2) armv7_a4x_bs_tag.bs_map = bootstrap_bs_map; tmp_bs_tag.bs_map = bootstrap_bs_map; + platform_init(); + platform_disable_l2_if_needed(); + /* setup a serial console for very early boot */ consinit(); /* Talk to the user */ - printf("\n%s booting ...\n", platform_boot_name); + printf("\n%s booting ...\n", platform_boot_name()); printf("arg0 %p arg1 %p arg2 %p\n", arg0, arg1, arg2); parse_uboot_tags(arg2); diff --git a/sys/arch/armv7/armv7/armv7_machdep.h b/sys/arch/armv7/armv7/armv7_machdep.h index 02fb5f033c8..6ac995ebd1b 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.3 2015/05/19 00:05:59 jsg Exp $ */ +/* $OpenBSD: armv7_machdep.h,v 1.4 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -18,11 +18,28 @@ #ifndef __PLATFORMVAR_H__ #define __PLATFORMVAR_H__ +void platform_init(void); +void platform_board_init(); void platform_powerdown(void); void platform_watchdog_reset(void); void platform_init_cons(void); -const char *platform_board_name(void); void platform_disable_l2_if_needed(void); -extern const char *platform_boot_name; +void platform_board_init(void); +const char *platform_boot_name(void); +const char *platform_board_name(void); +struct board_dev *platform_board_devs(); + +struct armv7_platform { + const char *boot_name; + const char *(*board_name)(void); + struct board_dev *devs; + void (*board_init)(void); + void (*smc_write)(bus_space_tag_t, bus_space_handle_t, bus_size_t, + uint32_t, uint32_t); + void (*init_cons)(void); + void (*watchdog_reset)(void); + void (*powerdown)(void); + void (*disable_l2_if_needed)(void); +}; #endif /* __PLATFORMVAR_H__ */ diff --git a/sys/arch/armv7/armv7/armv7var.h b/sys/arch/armv7/armv7/armv7var.h index 723e1cae94f..b20e2c3c5e7 100644 --- a/sys/arch/armv7/armv7/armv7var.h +++ b/sys/arch/armv7/armv7/armv7var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7var.h,v 1.5 2015/05/15 15:35:43 jsg Exp $ */ +/* $OpenBSD: armv7var.h,v 1.6 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -92,17 +92,5 @@ int armv7_submatch(struct device *, void *, void *); #define BOARD_ID_IMX6_CUBOXI 4821 extern uint32_t board_id; -/* different arch init */ -void am335x_init(void); -void imx6_init(void); -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__ */ diff --git a/sys/arch/armv7/armv7/autoconf.c b/sys/arch/armv7/armv7/autoconf.c index 9d33337ff73..1c0e4895d67 100644 --- a/sys/arch/armv7/armv7/autoconf.c +++ b/sys/arch/armv7/armv7/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.2 2015/05/15 15:35:43 jsg Exp $ */ +/* $OpenBSD: autoconf.c,v 1.3 2015/05/19 03:30:54 jsg Exp $ */ /* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */ /* @@ -52,6 +52,7 @@ #include <machine/bootconfig.h> #include <machine/intr.h> +#include <machine/bus.h> #include <armv7/armv7/armv7_machdep.h> diff --git a/sys/arch/armv7/armv7/platform.c b/sys/arch/armv7/armv7/platform.c new file mode 100644 index 00000000000..062111ff37d --- /dev/null +++ b/sys/arch/armv7/armv7/platform.c @@ -0,0 +1,117 @@ +/* $OpenBSD: platform.c,v 1.1 2015/05/19 03:30:54 jsg Exp $ */ +/* + * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/types.h> +#include <sys/systm.h> + +#include <machine/bus.h> + +#include <armv7/armv7/armv7var.h> +#include <armv7/armv7/armv7_machdep.h> +#include <arm/cortex/smc.h> + +#include "imx.h" +#include "omap.h" +#include "sunxi.h" + +static struct armv7_platform *platform; + +struct armv7_platform *imx_platform_match(void); +struct armv7_platform *omap_platform_match(void); +struct armv7_platform *sunxi_platform_match(void); + +struct armv7_platform * (*plat_match[])(void) = { +#if NIMX > 0 + imx_platform_match, +#endif +#if NOMAP > 0 + omap_platform_match, +#endif +#if NSUNXI > 0 + sunxi_platform_match, +#endif +}; + +void +platform_init(void) +{ + int i; + + for (i = 0; i < nitems(plat_match); i++) { + platform = plat_match[i](); + if (platform != NULL) + break; + } + if (platform == NULL) + panic("no matching armv7 platform"); +} + +const char * +platform_boot_name(void) +{ + return platform->boot_name; +} + +void +platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, + uint32_t op, uint32_t val) +{ + platform->smc_write(iot, ioh, off, op, val); +} + +void +platform_init_cons(void) +{ + platform->init_cons(); +} + +void +platform_watchdog_reset(void) +{ + platform->watchdog_reset(); +} + +void +platform_powerdown(void) +{ + platform->powerdown(); +} + +const char * +platform_board_name(void) +{ + return (platform->board_name()); +} + +void +platform_disable_l2_if_needed(void) +{ + platform->disable_l2_if_needed(); +} + +struct board_dev * +platform_board_devs() +{ + return (platform->devs); +} + +void +platform_board_init() +{ + platform->board_init(); +} diff --git a/sys/arch/armv7/conf/files.armv7 b/sys/arch/armv7/conf/files.armv7 index acdea23b479..eaa97fb74d0 100644 --- a/sys/arch/armv7/conf/files.armv7 +++ b/sys/arch/armv7/conf/files.armv7 @@ -1,4 +1,4 @@ -# $OpenBSD: files.armv7,v 1.10 2014/07/11 21:54:37 tedu Exp $ +# $OpenBSD: files.armv7,v 1.11 2015/05/19 03:30:54 jsg Exp $ maxpartitions 16 maxusers 2 8 64 @@ -24,6 +24,7 @@ file arch/arm/arm/softintr.c file arch/armv7/armv7/armv7.c file arch/armv7/armv7/armv7_machdep.c file arch/armv7/armv7/autoconf.c +file arch/armv7/armv7/platform.c file arch/arm/arm/disksubr.c disk include "dev/sdmmc/files.sdmmc" diff --git a/sys/arch/armv7/exynos/exynos.c b/sys/arch/armv7/exynos/exynos.c index 57171dddd2b..8b2e79849cd 100644 --- a/sys/arch/armv7/exynos/exynos.c +++ b/sys/arch/armv7/exynos/exynos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exynos.c,v 1.2 2015/05/15 15:35:43 jsg Exp $ */ +/* $OpenBSD: exynos.c,v 1.3 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -41,6 +41,8 @@ exynos_match(struct device *parent, void *cfdata, void *aux) return (0); } +void exynos5_init(); + struct cfattach exynos_ca = { sizeof(struct armv7_softc), exynos_match, armv7_attach, NULL, config_activate_children @@ -81,18 +83,28 @@ struct armv7_board exynos_boards[] = { }; struct board_dev * -exynos_board_attach(void) +exynos_board_devs(void) +{ + int i; + + for (i = 0; exynos_boards[i].name != NULL; i++) { + if (exynos_boards[i].board_id == board_id) + return (exynos_boards[i].devs); + } + return (NULL); +} + +void +exynos_board_init(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 * diff --git a/sys/arch/armv7/exynos/exynos_machdep.c b/sys/arch/armv7/exynos/exynos_machdep.c index ae2e210d2c7..e82e7ca9827 100644 --- a/sys/arch/armv7/exynos/exynos_machdep.c +++ b/sys/arch/armv7/exynos/exynos_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD */ +/* $OpenBSD: exynos_machdep.c,v 1.3 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> * @@ -31,7 +31,8 @@ extern void exdog_reset(void); extern char *exynos_board_name(void); -extern int32_t agtimer_frequency; +extern struct board_dev *exynos_board_devs(void); +extern void exynos_board_init(void); extern int comcnspeed; extern int comcnmode; @@ -81,7 +82,7 @@ exynos_platform_powerdown(void) } const char * -platform_board_name(void) +exynos_platform_board_name(void) { return (exynos_board_name()); } @@ -92,12 +93,32 @@ exynos_platform_disable_l2_if_needed(void) } +void +exynos_platform_board_init(void) +{ + exynos_board_init(); +} + struct armv7_platform exynos_platform = { .boot_name = "OpenBSD/exynos", + .board_name = exynos_platform_board_name, + .board_init = exynos_platform_board_init, .smc_write = exynos_platform_smc_write, .init_cons = exynos_platform_init_cons, .watchdog_reset = exynos_platform_watchdog_reset, .powerdown = exynos_platform_powerdown, - .print_board_type = exynos_platform_print_board_type, .disable_l2_if_needed = exynos_platform_disable_l2_if_needed, }; + +struct armv7_platform * +exynos_platform_match(void) +{ + struct board_dev *devs; + + devs = exynos_board_devs(); + if (devs == NULL) + return (NULL); + + exynos_platform.devs = devs; + return (&exynos_platform); +} diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c index 28b291de81c..c75c956c028 100644 --- a/sys/arch/armv7/imx/imx.c +++ b/sys/arch/armv7/imx/imx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx.c,v 1.6 2015/05/17 12:28:03 jsg Exp $ */ +/* $OpenBSD: imx.c,v 1.7 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -23,6 +23,8 @@ #include <armv7/armv7/armv7var.h> +void imx6_init(); + struct cfattach imx_ca = { sizeof(struct armv7_softc), armv7_match, armv7_attach, NULL, config_activate_children @@ -259,18 +261,28 @@ struct armv7_board imx_boards[] = { }; struct board_dev * -imx_board_attach(void) +imx_board_devs(void) +{ + int i; + + for (i = 0; imx_boards[i].name != NULL; i++) { + if (imx_boards[i].board_id == board_id) + return (imx_boards[i].devs); + } + return (NULL); +} + +void +imx_board_init(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 * diff --git a/sys/arch/armv7/imx/imx_machdep.c b/sys/arch/armv7/imx/imx_machdep.c index ce90a8cf861..d36da87f02f 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.14 2015/05/19 00:05:59 jsg Exp $ */ +/* $OpenBSD: imx_machdep.c,v 1.15 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -34,21 +34,20 @@ extern void imxdog_reset(void); extern char *imx_board_name(void); -extern int32_t amptimer_frequency; +extern struct board_dev *imx_board_devs(void); +extern void imx_board_init(void); extern int comcnspeed; extern int comcnmode; -const char *platform_boot_name = "OpenBSD/imx"; - void -platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, +imx_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, uint32_t op, uint32_t val) { bus_space_write_4(iot, ioh, off, val); } void -platform_init_cons(void) +imx_platform_init_cons(void) { paddr_t paddr; @@ -80,25 +79,55 @@ platform_init_cons(void) } void -platform_watchdog_reset(void) +imx_platform_watchdog_reset(void) { imxdog_reset(); } void -platform_powerdown(void) +imx_platform_powerdown(void) { } const char * -platform_board_name(void) +imx_platform_board_name(void) { return (imx_board_name()); } void -platform_disable_l2_if_needed(void) +imx_platform_disable_l2_if_needed(void) +{ + +} + +void +imx_platform_board_init(void) { + imx_board_init(); +} + +struct armv7_platform imx_platform = { + .boot_name = "OpenBSD/imx", + .board_name = imx_platform_board_name, + .board_init = imx_platform_board_init, + .smc_write = imx_platform_smc_write, + .init_cons = imx_platform_init_cons, + .watchdog_reset = imx_platform_watchdog_reset, + .powerdown = imx_platform_powerdown, + .disable_l2_if_needed = imx_platform_disable_l2_if_needed, +}; + +struct armv7_platform * +imx_platform_match(void) +{ + struct board_dev *devs; + + devs = imx_board_devs(); + if (devs == NULL) + return (NULL); + imx_platform.devs = devs; + return (&imx_platform); } diff --git a/sys/arch/armv7/omap/omap.c b/sys/arch/armv7/omap/omap.c index 2ed35880efc..02b9a71d1a3 100644 --- a/sys/arch/armv7/omap/omap.c +++ b/sys/arch/armv7/omap/omap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap.c,v 1.5 2015/05/15 15:35:43 jsg Exp $ */ +/* $OpenBSD: omap.c,v 1.6 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * @@ -22,6 +22,10 @@ #include <armv7/armv7/armv7var.h> +void omap3_init(); +void omap4_init(); +void am335x_init(); + struct cfattach omap_ca = { sizeof(struct armv7_softc), armv7_match, armv7_attach }; @@ -131,18 +135,28 @@ struct armv7_board omap_boards[] = { }; struct board_dev * -omap_board_attach(void) +omap_board_devs(void) +{ + int i; + + for (i = 0; omap_boards[i].name != NULL; i++) { + if (omap_boards[i].board_id == board_id) + return (omap_boards[i].devs); + } + return (NULL); +} + +void +omap_board_init(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 * diff --git a/sys/arch/armv7/omap/omap_machdep.c b/sys/arch/armv7/omap/omap_machdep.c index ca67d37d138..4e29a3e8291 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.5 2015/05/19 00:05:59 jsg Exp $ */ +/* $OpenBSD: omap_machdep.c,v 1.6 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -35,14 +35,14 @@ extern void omap4_smc_call(uint32_t, uint32_t); extern void omdog_reset(void); extern char *omap_board_name(void); +extern struct board_dev *omap_board_devs(void); +extern void omap_board_init(void); extern int comcnspeed; extern int comcnmode; -const char *platform_boot_name = "OpenBSD/omap"; - void -platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, - uint32_t op, uint32_t val) +omap_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, + bus_size_t off, uint32_t op, uint32_t val) { switch (op) { case 0x100: /* PL310 DEBUG */ @@ -56,7 +56,7 @@ platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, } void -platform_init_cons(void) +omap_platform_init_cons(void) { paddr_t paddr; @@ -78,25 +78,25 @@ platform_init_cons(void) } void -platform_watchdog_reset(void) +omap_platform_watchdog_reset(void) { omdog_reset(); } void -platform_powerdown(void) +omap_platform_powerdown(void) { } const char * -platform_board_name(void) +omap_platform_board_name(void) { return (omap_board_name()); } void -platform_disable_l2_if_needed(void) +omap_platform_disable_l2_if_needed(void) { switch (board_id) { case BOARD_ID_OMAP4_PANDA: @@ -105,3 +105,33 @@ platform_disable_l2_if_needed(void) break; } } + +void +omap_platform_board_init(void) +{ + omap_board_init(); +} + +struct armv7_platform omap_platform = { + .boot_name = "OpenBSD/omap", + .board_name = omap_platform_board_name, + .board_init = omap_platform_board_init, + .smc_write = omap_platform_smc_write, + .init_cons = omap_platform_init_cons, + .watchdog_reset = omap_platform_watchdog_reset, + .powerdown = omap_platform_powerdown, + .disable_l2_if_needed = omap_platform_disable_l2_if_needed, +}; + +struct armv7_platform * +omap_platform_match(void) +{ + struct board_dev *devs; + + devs = omap_board_devs(); + if (devs == NULL) + return (NULL); + + omap_platform.devs = devs; + return (&omap_platform); +} diff --git a/sys/arch/armv7/sunxi/sunxi.c b/sys/arch/armv7/sunxi/sunxi.c index cbcb90bdf7f..504214461f4 100644 --- a/sys/arch/armv7/sunxi/sunxi.c +++ b/sys/arch/armv7/sunxi/sunxi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunxi.c,v 1.4 2015/05/15 15:35:43 jsg Exp $ */ +/* $OpenBSD: sunxi.c,v 1.5 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * @@ -24,6 +24,9 @@ #include <armv7/armv7/armv7var.h> #include <armv7/sunxi/sunxireg.h> +void sxia1x_init(); +void sxia20_init(); + struct cfattach sunxi_ca = { sizeof(struct armv7_softc), armv7_match, armv7_attach }; @@ -103,23 +106,33 @@ struct armv7_board sunxi_boards[] = { { 0, NULL, NULL, NULL }, }; - struct board_dev * -sunxi_board_attach(void) +sunxi_board_devs(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) + return (sunxi_boards[i].devs); + } + return (NULL); +} + +void +sunxi_board_init(void) +{ + bus_space_handle_t ioh; + int i, match = 0; + + 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; + match = 1; break; } } - if (devs) { + if (match) { if (bus_space_map(&armv7_bs_tag, SYSCTRL_ADDR, SYSCTRL_SIZE, 0, &ioh)) panic("sunxi_attach: bus_space_map failed!"); @@ -127,8 +140,6 @@ sunxi_board_attach(void) bus_space_write_4(&armv7_bs_tag, ioh, 4, bus_space_read_4(&armv7_bs_tag, ioh, 4) | (5 << 2)); } - - return (devs); } const char * diff --git a/sys/arch/armv7/sunxi/sunxi_machdep.c b/sys/arch/armv7/sunxi/sunxi_machdep.c index 210fb292cb0..808b3b89dbe 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.7 2015/05/19 00:05:59 jsg Exp $ */ +/* $OpenBSD: sunxi_machdep.c,v 1.8 2015/05/19 03:30:54 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -34,20 +34,20 @@ 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 struct board_dev *sunxi_board_devs(void); +extern void sunxi_board_init(void); extern int comcnspeed; extern int comcnmode; -const char *platform_boot_name = "OpenBSD/sunxi"; - void -platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, - uint32_t op, uint32_t val) +sunxi_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, + bus_size_t off, uint32_t op, uint32_t val) { } void -platform_init_cons(void) +sunxi_platform_init_cons(void) { paddr_t paddr; @@ -67,26 +67,55 @@ platform_init_cons(void) } void -platform_watchdog_reset(void) +sunxi_platform_watchdog_reset(void) { sxidog_reset(); } void -platform_powerdown(void) +sunxi_platform_powerdown(void) { } const char * -platform_board_name(void) +sunxi_platform_board_name(void) { return (sunxi_board_name()); } void -platform_disable_l2_if_needed(void) +sunxi_platform_disable_l2_if_needed(void) { } +void +sunxi_platform_board_init(void) +{ + sunxi_board_init(); +} + +struct armv7_platform sunxi_platform = { + .boot_name = "OpenBSD/sunxi", + .board_name = sunxi_platform_board_name, + .board_init = sunxi_platform_board_init, + .smc_write = sunxi_platform_smc_write, + .init_cons = sunxi_platform_init_cons, + .watchdog_reset = sunxi_platform_watchdog_reset, + .powerdown = sunxi_platform_powerdown, + .disable_l2_if_needed = sunxi_platform_disable_l2_if_needed, +}; + +struct armv7_platform * +sunxi_platform_match(void) +{ + struct board_dev *devs; + + devs = sunxi_board_devs(); + if (devs == NULL) + return (NULL); + + sunxi_platform.devs = devs; + return (&sunxi_platform); +} |