diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-06-08 15:27:06 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-06-08 15:27:06 +0000 |
commit | ec781b303bcbf6dd62c55d5f3ea74f879b01b753 (patch) | |
tree | c748a2dfdb13a80884b4f8475254c3fb9bb6bf57 /sys/arch | |
parent | cacefc814f032ba3ab4bc7b8a36c3f305c0883ac (diff) |
Use fdt to find the console to initialise. Try to use /chosen/stdout-path
if present otherwise fallback to /aliases/serial0.
Don't require a platform match to run the various console init functions
so the init functions will run for unknown board ids.
With and ok kettenis@ on a earlier version.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/armv7/armv7/armv7_machdep.c | 38 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/armv7_machdep.h | 3 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/platform.c | 18 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/exuart.c | 26 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/exynos_machdep.c | 45 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imx_machdep.c | 36 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxuart.c | 22 | ||||
-rw-r--r-- | sys/arch/armv7/omap/omap_com.c | 24 | ||||
-rw-r--r-- | sys/arch/armv7/omap/omap_machdep.c | 27 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sunxi_machdep.c | 25 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sxiuart.c | 23 | ||||
-rw-r--r-- | sys/arch/armv7/vexpress/pl011.c | 22 | ||||
-rw-r--r-- | sys/arch/armv7/vexpress/vexpress_machdep.c | 22 |
13 files changed, 168 insertions, 163 deletions
diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c index 27726122941..40599baf2b7 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.28 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: armv7_machdep.c,v 1.29 2016/06/08 15:27:05 jsg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -900,6 +900,42 @@ process_kernel_args(char *args) } } +void * +fdt_find_cons(const char *name) +{ + char *alias = "serial0"; + char *stdout = NULL; + void *node; + + /* First check if "stdout-path" is set. */ + node = fdt_find_node("/chosen"); + if (node) { + if (fdt_node_property(node, "stdout-path", &stdout)) { + if (stdout[0] != '/') { + /* It's an alias. */ + alias = stdout; + stdout = NULL; + } + } + } + + /* Perform alias lookup if necessary. */ + if (stdout == NULL) { + node = fdt_find_node("/aliases"); + if (node) + fdt_node_property(node, alias, &stdout); + } + + /* Lookup the physical address of the interface. */ + if (stdout) { + node = fdt_find_node(stdout); + if (node && fdt_is_compatible(node, name)) + return (node); + } + + return (NULL); +} + void consinit(void) { diff --git a/sys/arch/armv7/armv7/armv7_machdep.h b/sys/arch/armv7/armv7/armv7_machdep.h index a90676625fb..7533582c6bf 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.7 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: armv7_machdep.h,v 1.8 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -25,6 +25,7 @@ void platform_init_cons(void); void platform_init_mainbus(struct device *); void platform_disable_l2_if_needed(void); struct board_dev *platform_board_devs(); +void *fdt_find_cons(const char *); struct armv7_platform { struct board_dev *devs; diff --git a/sys/arch/armv7/armv7/platform.c b/sys/arch/armv7/armv7/platform.c index 073a53f870c..67a8a686cb0 100644 --- a/sys/arch/armv7/armv7/platform.c +++ b/sys/arch/armv7/armv7/platform.c @@ -1,4 +1,4 @@ -/* $OpenBSD: platform.c,v 1.6 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: platform.c,v 1.7 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> * @@ -33,6 +33,12 @@ static struct armv7_platform *platform; +void exuart_init_cons(void); +void imxuart_init_cons(void); +void omapuart_init_cons(void); +void sxiuart_init_cons(void); +void pl011_init_cons(void); + struct armv7_platform *imx_platform_match(void); struct armv7_platform *omap_platform_match(void); struct armv7_platform *sunxi_platform_match(void); @@ -82,7 +88,15 @@ platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, void platform_init_cons(void) { - platform->init_cons(); + if (platform && platform->init_cons) { + platform->init_cons(); + return; + } + exuart_init_cons(); + imxuart_init_cons(); + omapuart_init_cons(); + sxiuart_init_cons(); + pl011_init_cons(); } void diff --git a/sys/arch/armv7/exynos/exuart.c b/sys/arch/armv7/exynos/exuart.c index 8112b8dc283..6b016ac1ef6 100644 --- a/sys/arch/armv7/exynos/exuart.c +++ b/sys/arch/armv7/exynos/exuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exuart.c,v 1.3 2016/04/24 00:57:23 patrick Exp $ */ +/* $OpenBSD: exuart.c,v 1.4 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@motorola.com> * @@ -31,20 +31,20 @@ #include <dev/cons.h> - #ifdef DDB #include <ddb/db_var.h> #endif #include <machine/bus.h> -#if NFDT > 0 -#include <machine/fdt.h> -#endif +#include <arm/armv7/armv7var.h> #include <armv7/exynos/exuartreg.h> #include <armv7/exynos/exuartvar.h> #include <armv7/armv7/armv7var.h> +#include <armv7/armv7/armv7_machdep.h> #include <armv7/exynos/exclockvar.h> +#include <dev/ofw/fdt.h> + #define DEVUNIT(x) (minor(x) & 0x7f) #define DEVCUA(x) (minor(x) & 0x80) @@ -110,6 +110,8 @@ struct exuart_softc *exuart_sc(dev_t dev); int exuart_intr(void *); +extern int comcnspeed; +extern int comcnmode; /* XXX - we imitate 'com' serial ports and take over their entry points */ /* XXX: These belong elsewhere */ @@ -132,6 +134,20 @@ bus_addr_t exuartconsaddr; tcflag_t exuartconscflag = TTYDEF_CFLAG; int exuartdefaultrate = B115200; +void +exuart_init_cons(void) +{ + struct fdt_memory mem; + void *node; + + if ((node = fdt_find_cons("samsung,exynos4210-uart")) == NULL) + return; + if (fdt_get_memory_address(node, 0, &mem)) + return; + + exuartcnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode); +} + int exuartprobe(struct device *parent, void *self, void *aux) { diff --git a/sys/arch/armv7/exynos/exynos_machdep.c b/sys/arch/armv7/exynos/exynos_machdep.c index 9766982c166..b799dce2477 100644 --- a/sys/arch/armv7/exynos/exynos_machdep.c +++ b/sys/arch/armv7/exynos/exynos_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exynos_machdep.c,v 1.8 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: exynos_machdep.c,v 1.9 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2013 Patrick Wildt <patrick@blueri.se> * @@ -22,10 +22,6 @@ #include <machine/bus.h> -#if NFDT > 0 -#include <machine/fdt.h> -#endif - #include <arm/cortex/smc.h> #include <arm/armv7/armv7var.h> #include <arm/mainbus/mainbus.h> @@ -37,8 +33,6 @@ extern void exdog_reset(void); extern struct board_dev *exynos_board_devs(void); extern void exynos_board_init(void); -extern int comcnspeed; -extern int comcnmode; static void exynos_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, @@ -47,42 +41,6 @@ exynos_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_ bus_space_write_4(iot, ioh, off, val); } -static void -exynos_platform_init_cons(void) -{ - paddr_t paddr; - size_t size; - - switch (board_id) { - case BOARD_ID_EXYNOS5_CHROMEBOOK: -#if NFDT > 0 - void *node; - node = fdt_find_node("/framebuffer"); - if (node != NULL) { - uint32_t *mem; - if (fdt_node_property(node, "reg", (char **)&mem) >= 2*sizeof(uint32_t)) { - paddr = betoh32(*mem++); - size = betoh32(*mem); - } - } -#else - paddr = 0xbfc00000; - size = 0x202000; -#endif - exdisplay_cnattach(&armv7_bs_tag, paddr, size); - break; - case BOARD_ID_EXYNOS4_SMDKC210: - case BOARD_ID_EXYNOS4_NURI: - paddr = 0x13800000; - exuartcnattach(&armv7_bs_tag, paddr, comcnspeed, comcnmode); - break; - default: - printf("board type %x unknown", board_id); - return; - /* XXX - HELP */ - } -} - void exynos_platform_init_mainbus(struct device *self) { @@ -117,7 +75,6 @@ exynos_platform_board_init(void) struct armv7_platform exynos_platform = { .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, .disable_l2_if_needed = exynos_platform_disable_l2_if_needed, diff --git a/sys/arch/armv7/imx/imx_machdep.c b/sys/arch/armv7/imx/imx_machdep.c index 91226433440..23b96d45c4b 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.18 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: imx_machdep.c,v 1.19 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -36,8 +36,6 @@ extern void imxdog_reset(void); extern struct board_dev *imx_board_devs(void); extern void imx_board_init(void); -extern int comcnspeed; -extern int comcnmode; void imx_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, @@ -47,37 +45,6 @@ imx_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t o } void -imx_platform_init_cons(void) -{ - paddr_t paddr; - - switch (board_id) { - /* UART1 */ - case BOARD_ID_IMX6_CUBOXI: - case BOARD_ID_IMX6_HUMMINGBOARD: - case BOARD_ID_IMX6_SABRESD: - case BOARD_ID_IMX6_WANDBOARD: - paddr = 0x02020000; - break; - /* UART2 */ - case BOARD_ID_IMX6_SABRELITE: - case BOARD_ID_IMX6_UDOO: - case BOARD_ID_IMX6_NOVENA: - paddr = 0x021e8000; - break; - /* UART4 */ - case BOARD_ID_IMX6_UTILITE: - paddr = 0x021f0000; - break; - default: - printf("board type %x unknown", board_id); - return; - /* XXX - HELP */ - } - imxuartcnattach(&armv7_bs_tag, paddr, comcnspeed, comcnmode); -} - -void imx_platform_init_mainbus(struct device *self) { mainbus_legacy_found(self, "cortex"); @@ -111,7 +78,6 @@ imx_platform_board_init(void) struct armv7_platform imx_platform = { .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, diff --git a/sys/arch/armv7/imx/imxuart.c b/sys/arch/armv7/imx/imxuart.c index 54fbb777ee4..1b284fdb221 100644 --- a/sys/arch/armv7/imx/imxuart.c +++ b/sys/arch/armv7/imx/imxuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxuart.c,v 1.4 2016/05/18 06:49:28 kettenis Exp $ */ +/* $OpenBSD: imxuart.c,v 1.5 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@motorola.com> * @@ -37,11 +37,15 @@ #endif #include <machine/bus.h> +#include <arm/armv7/armv7var.h> #include <armv7/imx/imxuartreg.h> #include <armv7/imx/imxuartvar.h> #include <armv7/armv7/armv7var.h> +#include <armv7/armv7/armv7_machdep.h> #include <armv7/imx/imxccmvar.h> +#include <dev/ofw/fdt.h> + #define DEVUNIT(x) (minor(x) & 0x7f) #define DEVCUA(x) (minor(x) & 0x80) @@ -104,6 +108,8 @@ struct imxuart_softc *imxuart_sc(dev_t dev); int imxuart_intr(void *); +extern int comcnspeed; +extern int comcnmode; /* XXX - we imitate 'com' serial ports and take over their entry points */ /* XXX: These belong elsewhere */ @@ -127,6 +133,20 @@ struct cdevsw imxuartdev = cdev_tty_init(3/*XXX NIMXUART */ ,imxuart); /* 12: serial port */ void +imxuart_init_cons(void) +{ + struct fdt_memory mem; + void *node; + + if ((node = fdt_find_cons("fsl,imx21-uart")) == NULL) + return; + if (fdt_get_memory_address(node, 0, &mem)) + return; + + imxuartcnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode); +} + +void imxuartattach(struct device *parent, struct device *self, void *args) { struct armv7_attach_args *aa = args; diff --git a/sys/arch/armv7/omap/omap_com.c b/sys/arch/armv7/omap/omap_com.c index 9a3a94c4f20..a7ee6ba427f 100644 --- a/sys/arch/armv7/omap/omap_com.c +++ b/sys/arch/armv7/omap/omap_com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: omap_com.c,v 1.2 2013/11/06 19:03:07 syl Exp $ */ +/* $OpenBSD: omap_com.c,v 1.3 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. * All rights reserved. @@ -49,6 +49,9 @@ #include <arch/arm/armv7/armv7var.h> #include <armv7/armv7/armv7var.h> +#include <armv7/armv7/armv7_machdep.h> + +#include <dev/ofw/fdt.h> #define com_isr 8 #define ISR_RECV (ISR_RXPL | ISR_XMODE | ISR_RCVEIR) @@ -56,12 +59,31 @@ void omapuart_attach(struct device *, struct device *, void *); int omapuart_activate(struct device *, int); +extern int comcnspeed; +extern int comcnmode; + struct cfattach com_omap_ca = { sizeof (struct com_softc), NULL, omapuart_attach, NULL, omapuart_activate }; void +omapuart_init_cons(void) +{ + struct fdt_memory mem; + void *node; + + if ((node = fdt_find_cons("ti,omap3-uart")) == NULL) + return; + if (fdt_get_memory_address(node, 0, &mem)) + return; + + comcnattach(&armv7_a4x_bs_tag, mem.addr, comcnspeed, 48000000, + comcnmode); + comdefaultrate = comcnspeed; +} + +void omapuart_attach(struct device *parent, struct device *self, void *aux) { struct com_softc *sc = (struct com_softc *)self; diff --git a/sys/arch/armv7/omap/omap_machdep.c b/sys/arch/armv7/omap/omap_machdep.c index 2a08eadf0e8..a7c95fc8e2b 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.8 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: omap_machdep.c,v 1.9 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -37,8 +37,6 @@ extern void omap4_smc_call(uint32_t, uint32_t); extern void omdog_reset(void); extern struct board_dev *omap_board_devs(void); extern void omap_board_init(void); -extern int comcnspeed; -extern int comcnmode; void omap_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, @@ -56,28 +54,6 @@ omap_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, } void -omap_platform_init_cons(void) -{ - paddr_t paddr; - - switch (board_id) { - case BOARD_ID_OMAP3_BEAGLE: - case BOARD_ID_OMAP3_OVERO: - paddr = 0x49020000; - break; - case BOARD_ID_AM335X_BEAGLEBONE: - paddr = 0x44e09000; - break; - case BOARD_ID_OMAP4_PANDA: - paddr = 0x48020000; - break; - } - - comcnattach(&armv7_a4x_bs_tag, paddr, comcnspeed, 48000000, comcnmode); - comdefaultrate = comcnspeed; -} - -void omap_platform_init_mainbus(struct device *self) { mainbus_legacy_found(self, "cortex"); @@ -116,7 +92,6 @@ omap_platform_board_init(void) struct armv7_platform omap_platform = { .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, diff --git a/sys/arch/armv7/sunxi/sunxi_machdep.c b/sys/arch/armv7/sunxi/sunxi_machdep.c index ea60f789914..2f16f561f62 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.10 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: sunxi_machdep.c,v 1.11 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -36,8 +36,6 @@ extern int sxiuartcnattach(bus_space_tag_t, bus_addr_t, int, long, tcflag_t); extern void sxidog_reset(void); extern struct board_dev *sunxi_board_devs(void); extern void sunxi_board_init(void); -extern int comcnspeed; -extern int comcnmode; void sunxi_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, @@ -47,26 +45,6 @@ sunxi_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, } void -sunxi_platform_init_cons(void) -{ - paddr_t paddr; - - switch (board_id) { - case BOARD_ID_SUN4I_A10: - case BOARD_ID_SUN7I_A20: - paddr = 0x01c28000; /* UART0 */ - break; - default: - sxiuartcnattach(&armv7_a4x_bs_tag, paddr, comcnspeed, - 24000000, comcnmode); - panic("board type %x unknown", board_id); - } - - sxiuartcnattach(&armv7_a4x_bs_tag, paddr, comcnspeed, 24000000, - comcnmode); -} - -void sunxi_platform_init_mainbus(struct device *self) { mainbus_legacy_found(self, "cortex"); @@ -100,7 +78,6 @@ sunxi_platform_board_init(void) struct armv7_platform sunxi_platform = { .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, diff --git a/sys/arch/armv7/sunxi/sxiuart.c b/sys/arch/armv7/sunxi/sxiuart.c index 5a7136f0e43..a00475feebe 100644 --- a/sys/arch/armv7/sunxi/sxiuart.c +++ b/sys/arch/armv7/sunxi/sxiuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxiuart.c,v 1.4 2015/04/22 11:39:04 jsg Exp $ */ +/* $OpenBSD: sxiuart.c,v 1.5 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@motorola.com> * Copyright (c) 2013 Artturi Alm @@ -38,10 +38,14 @@ #include <machine/bus.h> +#include <arm/armv7/armv7var.h> #include <armv7/armv7/armv7var.h> +#include <armv7/armv7/armv7_machdep.h> #include <armv7/sunxi/sxiuartreg.h> #include <armv7/sunxi/sunxireg.h> +#include <dev/ofw/fdt.h> + #define DEVUNIT(x) (minor(x) & 0x7f) #define DEVCUA(x) (minor(x) & 0x80) @@ -103,6 +107,8 @@ void sxiuart_raisedtr(void *); void sxiuart_softint(void *); int sxiuart_intr(void *); +extern int comcnspeed; +extern int comcnmode; struct sxiuart_softc *sxiuart_sc(dev_t); @@ -135,6 +141,21 @@ struct cdevsw sxiuartdev = cdev_tty_init(1/*XXX NIMXUART */ , sxiuart); /* 12: serial port */ void +sxiuart_init_cons(void) +{ + struct fdt_memory mem; + void *node; + + if ((node = fdt_find_cons("snps,dw-apb-uart")) == NULL) + return; + if (fdt_get_memory_address(node, 0, &mem)) + return; + + sxiuartcnattach(&armv7_a4x_bs_tag, mem.addr, comcnspeed, 24000000, + comcnmode); +} + +void sxiuartattach(struct device *parent, struct device *self, void *args) { struct armv7_attach_args *aa = args; diff --git a/sys/arch/armv7/vexpress/pl011.c b/sys/arch/armv7/vexpress/pl011.c index 50a902b6be3..5006388ec7c 100644 --- a/sys/arch/armv7/vexpress/pl011.c +++ b/sys/arch/armv7/vexpress/pl011.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pl011.c,v 1.2 2016/04/24 00:57:23 patrick Exp $ */ +/* $OpenBSD: pl011.c,v 1.3 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> @@ -42,9 +42,13 @@ #if NFDT > 0 #include <machine/fdt.h> #endif +#include <arm/armv7/armv7var.h> #include <armv7/vexpress/pl011reg.h> #include <armv7/vexpress/pl011var.h> #include <armv7/armv7/armv7var.h> +#include <armv7/armv7/armv7_machdep.h> + +#include <dev/ofw/fdt.h> #define DEVUNIT(x) (minor(x) & 0x7f) #define DEVCUA(x) (minor(x) & 0x80) @@ -112,6 +116,8 @@ struct pl011_softc *pl011_sc(dev_t dev); int pl011_intr(void *); +extern int comcnspeed; +extern int comcnmode; /* XXX - we imitate 'com' serial ports and take over their entry points */ /* XXX: These belong elsewhere */ @@ -131,6 +137,20 @@ bus_addr_t pl011consaddr; tcflag_t pl011conscflag = TTYDEF_CFLAG; int pl011defaultrate = B38400; +void +pl011_init_cons(void) +{ + struct fdt_memory mem; + void *node; + + if ((node = fdt_find_cons("arm,pl011")) == NULL) + return; + if (fdt_get_memory_address(node, 0, &mem)) + return; + + pl011cnattach(&armv7_bs_tag, mem.addr, comcnspeed, comcnmode); +} + int pl011probe(struct device *parent, void *self, void *aux) { diff --git a/sys/arch/armv7/vexpress/vexpress_machdep.c b/sys/arch/armv7/vexpress/vexpress_machdep.c index 2d9104276a9..005cbe57973 100644 --- a/sys/arch/armv7/vexpress/vexpress_machdep.c +++ b/sys/arch/armv7/vexpress/vexpress_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vexpress_machdep.c,v 1.3 2016/06/04 18:09:16 jsg Exp $ */ +/* $OpenBSD: vexpress_machdep.c,v 1.4 2016/06/08 15:27:05 jsg Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -38,8 +38,6 @@ extern void sysconf_shutdown(void); extern struct board_dev *vexpress_board_devs(void); extern void vexpress_board_init(void); extern int vexpress_legacy_map(void); -extern int comcnspeed; -extern int comcnmode; void vexpress_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, @@ -49,23 +47,6 @@ vexpress_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, bus_siz } void -vexpress_platform_init_cons(void) -{ - paddr_t paddr; - - switch (board_id) { - default: - case BOARD_ID_VEXPRESS: - if (vexpress_legacy_map()) - paddr = 0x10009000; - else - paddr = 0x1c090000; - break; - } - pl011cnattach(&armv7_bs_tag, paddr, comcnspeed, comcnmode); -} - -void vexpress_platform_init_mainbus(struct device *self) { mainbus_legacy_found(self, "cortex"); @@ -99,7 +80,6 @@ vexpress_platform_board_init(void) struct armv7_platform vexpress_platform = { .board_init = vexpress_platform_board_init, .smc_write = vexpress_platform_smc_write, - .init_cons = vexpress_platform_init_cons, .watchdog_reset = vexpress_platform_watchdog_reset, .powerdown = vexpress_platform_powerdown, .disable_l2_if_needed = vexpress_platform_disable_l2_if_needed, |