Module Name: src Committed By: reinoud Date: Wed Apr 16 21:28:51 UTC 2014
Modified Files: src/sys/arch/arm/samsung: exynos_soc.c exynos_sscom.c sscom.c sscom_var.h Log Message: Teach sscom attachment, also the console, to use the busspace handle of the main register space. While here, map in the correct amount of memory or bus_space_map() won't return an error but will wedge the system. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/samsung/exynos_soc.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/samsung/exynos_sscom.c \ src/sys/arch/arm/samsung/sscom.c src/sys/arch/arm/samsung/sscom_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/samsung/exynos_soc.c diff -u src/sys/arch/arm/samsung/exynos_soc.c:1.4 src/sys/arch/arm/samsung/exynos_soc.c:1.5 --- src/sys/arch/arm/samsung/exynos_soc.c:1.4 Sun Apr 13 20:52:29 2014 +++ src/sys/arch/arm/samsung/exynos_soc.c Wed Apr 16 21:28:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_soc.c,v 1.4 2014/04/13 20:52:29 reinoud Exp $ */ +/* $NetBSD: exynos_soc.c,v 1.5 2014/04/16 21:28:51 reinoud Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. * All rights reserved. @@ -33,7 +33,7 @@ #define _ARM32_BUS_DMA_PRIVATE #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.4 2014/04/13 20:52:29 reinoud Exp $"); +__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.5 2014/04/16 21:28:51 reinoud Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -205,10 +205,18 @@ exynos_l2cc_init(void) #endif /* ARM_TRUSTZONE_FIRMWARE */ +#ifndef EXYNOS4 +# define EXYNOS4_CORE_SIZE 0 +#endif +#ifndef EXYNOS5 +# define EXYNOS5_CORE_SIZE 0 +#endif void exynos_bootstrap(vaddr_t iobase, vaddr_t uartbase) { -// int error; + int error; + size_t core_size = IS_EXYNOS4_P() ? + EXYNOS4_CORE_SIZE : EXYNOS5_CORE_SIZE; /* set up early console so we can use printf() and friends */ #ifdef EXYNOS_CONSOLE_EARLY @@ -216,15 +224,13 @@ exynos_bootstrap(vaddr_t iobase, vaddr_t cn_tab = &exynos_earlycons; printf("Exynos early console operational\n\n"); #endif -#if 0 /* map in the exynos io registers */ error = bus_space_map(&exynos_bs_tag, EXYNOS_CORE_PBASE, - 0x04000000 /*EXYNOS_CORE_SIZE*/, 0, &exynos_core_bsh); + core_size, 0, &exynos_core_bsh); if (error) panic("%s: failed to map in Exynos io registers: %d", __func__, error); KASSERT(exynos_core_bsh == iobase); -#endif } Index: src/sys/arch/arm/samsung/exynos_sscom.c diff -u src/sys/arch/arm/samsung/exynos_sscom.c:1.2 src/sys/arch/arm/samsung/exynos_sscom.c:1.3 --- src/sys/arch/arm/samsung/exynos_sscom.c:1.2 Mon Apr 14 21:16:15 2014 +++ src/sys/arch/arm/samsung/exynos_sscom.c Wed Apr 16 21:28:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $ */ +/* $NetBSD: exynos_sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $ */ /* * Copyright (c) 2014 Reinoud Zandijk @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $"); #include "opt_sscom.h" #include "opt_ddb.h" @@ -141,9 +141,10 @@ sscom_attach(device_t parent, device_t s struct sscom_softc *sc = device_private(self); struct exyo_attach_args *exyo = aux; int unit = exyo->exyo_loc.loc_port; - bus_addr_t iobase = exyo->exyo_loc.loc_offset; - aprint_normal( ": UART%d addr=%lx", unit, iobase ); + /* debug */ +// bus_addr_t iobase = exyo->exyo_loc.loc_offset; +// aprint_normal( ": UART%d addr=%lx", unit, iobase ); sc->sc_dev = self; sc->sc_iot = exyo->exyo_core_bst; @@ -157,7 +158,8 @@ sscom_attach(device_t parent, device_t s sc->sc_tx_irqno = UINT_TXD; if (!sscom_is_console(sc->sc_iot, unit, &sc->sc_ioh) - && bus_space_map(sc->sc_iot, iobase, SSCOM_SIZE, 0, &sc->sc_ioh)) { + && bus_space_subregion(sc->sc_iot, exyo->exyo_core_bsh, + exyo->exyo_loc.loc_offset, SSCOM_SIZE, &sc->sc_ioh)) { printf( ": failed to map registers\n" ); return; } Index: src/sys/arch/arm/samsung/sscom.c diff -u src/sys/arch/arm/samsung/sscom.c:1.2 src/sys/arch/arm/samsung/sscom.c:1.3 --- src/sys/arch/arm/samsung/sscom.c:1.2 Mon Apr 14 21:16:15 2014 +++ src/sys/arch/arm/samsung/sscom.c Wed Apr 16 21:28:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $ */ +/* $NetBSD: sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $ */ /* * Copyright (c) 2002, 2003 Fujitsu Component Limited @@ -98,7 +98,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.2 2014/04/14 21:16:15 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.3 2014/04/16 21:28:51 reinoud Exp $"); #include "opt_sscom.h" #include "opt_ddb.h" @@ -181,7 +181,8 @@ static void sscom_iflush(struct sscom_so static int sscomhwiflow(struct tty *tp, int block); #if defined(KGDB) || defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) -static int sscom_init(bus_space_tag_t, const struct sscom_uart_info *, +static int sscom_init(bus_space_tag_t, bus_space_handle_t, + const struct sscom_uart_info *, int, int, tcflag_t, bus_space_handle_t *); #endif @@ -1839,15 +1840,15 @@ sscomintr(void *v) * Initialize UART for use as console or KGDB line. */ static int -sscom_init(bus_space_tag_t iot, const struct sscom_uart_info *config, +sscom_init(bus_space_tag_t iot, bus_space_handle_t base_ioh, + const struct sscom_uart_info *config, int rate, int frequency, tcflag_t cflag, bus_space_handle_t *iohp) { bus_space_handle_t ioh; bus_addr_t iobase = config->iobase; int timo = 150000; - if (bus_space_map(iot, iobase, SSCOM_SIZE, 0, &ioh)) - return ENOMEM; /* ??? */ + bus_space_subregion(iot, base_ioh, iobase, SSCOM_SIZE, &ioh); /* wait until all is transmitted until we enable this device */ while (!(bus_space_read_4(iot, ioh, SSCOM_UTRSTAT) & @@ -1893,12 +1894,14 @@ struct consdev sscomcons = { int -sscom_cnattach(bus_space_tag_t iot, const struct sscom_uart_info *config, +sscom_cnattach(bus_space_tag_t iot, bus_space_handle_t ioh, + const struct sscom_uart_info *config, int rate, int frequency, tcflag_t cflag) { int res; - res = sscom_init(iot, config, rate, frequency, cflag, &sscomconsioh); + res = sscom_init(iot, ioh, config, + rate, frequency, cflag, &sscomconsioh); if (res) return res; @@ -2022,7 +2025,8 @@ sscomcnpollc(dev_t dev, int on) #ifdef KGDB int -sscom_kgdb_attach(bus_space_tag_t iot, const struct sscom_uart_info *config, +sscom_kgdb_attach(bus_space_tag_t iot, bus_space_handle_t ioh, + const struct sscom_uart_info *config, int rate, int frequency, tcflag_t cflag) { int res; @@ -2032,7 +2036,8 @@ sscom_kgdb_attach(bus_space_tag_t iot, c return EBUSY; /* cannot share with console */ } - res = sscom_init(iot, config, rate, frequency, cflag, &sscom_kgdb_ioh); + res = sscom_init(iot, ioh, config, + rate, frequency, cflag, &sscom_kgdb_ioh); if (res) return res; Index: src/sys/arch/arm/samsung/sscom_var.h diff -u src/sys/arch/arm/samsung/sscom_var.h:1.2 src/sys/arch/arm/samsung/sscom_var.h:1.3 --- src/sys/arch/arm/samsung/sscom_var.h:1.2 Mon Apr 14 21:16:15 2014 +++ src/sys/arch/arm/samsung/sscom_var.h Wed Apr 16 21:28:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sscom_var.h,v 1.2 2014/04/14 21:16:15 reinoud Exp $ */ +/* $NetBSD: sscom_var.h,v 1.3 2014/04/16 21:28:51 reinoud Exp $ */ /* * Copyright (c) 2002, 2003 Fujitsu Component Limited @@ -243,13 +243,14 @@ int sscomtxintr(void *); int sscomrxintr(void *); int sscomintr(void *); -int sscom_cnattach(bus_space_tag_t, const struct sscom_uart_info *, - int, int, tcflag_t); +int sscom_cnattach(bus_space_tag_t, bus_space_handle_t, + const struct sscom_uart_info *, int, int, tcflag_t); void sscom_cndetach(void); int sscom_is_console(bus_space_tag_t, int, bus_space_handle_t *); #ifdef KGDB -int sscom_kgdb_attach(bus_space_tag_t, const struct sscom_uart_info *, +int sscom_kgdb_attach(bus_space_tag_t, bus_space_handle_t, + const struct sscom_uart_info *, int, int, tcflag_t); #endif