Module Name: src Committed By: jmcneill Date: Sat Jun 10 15:13:19 UTC 2017
Modified Files: src/sys/arch/arm/samsung: exynos_intr.h exynos_reg.h exynos_soc.c exynos_sscom.c files.exynos sscom.c src/sys/arch/evbarm/conf: EXYNOS files.exynos std.exynos src/sys/arch/evbarm/exynos: platform.h Added Files: src/sys/arch/arm/samsung: exynos_platform.c Removed Files: src/sys/arch/arm/samsung: exynos5422_dma.c exynos_fdt.c src/sys/arch/evbarm/exynos: exynos_machdep.c Log Message: Get the EXYNOS kernel building again with recent FDT changes. Untested. To generate a diff of this commit: cvs rdiff -u -r1.1 -r0 src/sys/arch/arm/samsung/exynos5422_dma.c cvs rdiff -u -r1.4 -r0 src/sys/arch/arm/samsung/exynos_fdt.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/samsung/exynos_intr.h cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/samsung/exynos_platform.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/samsung/exynos_reg.h cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/samsung/exynos_soc.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/samsung/exynos_sscom.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/samsung/files.exynos cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/samsung/sscom.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/evbarm/conf/EXYNOS cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbarm/conf/files.exynos cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/conf/std.exynos cvs rdiff -u -r1.7 -r0 src/sys/arch/evbarm/exynos/exynos_machdep.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/exynos/platform.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_intr.h diff -u src/sys/arch/arm/samsung/exynos_intr.h:1.2 src/sys/arch/arm/samsung/exynos_intr.h:1.3 --- src/sys/arch/arm/samsung/exynos_intr.h:1.2 Fri Sep 5 08:01:05 2014 +++ src/sys/arch/arm/samsung/exynos_intr.h Sat Jun 10 15:13:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_intr.h,v 1.2 2014/09/05 08:01:05 skrll Exp $ */ +/* $NetBSD: exynos_intr.h,v 1.3 2017/06/10 15:13:18 jmcneill Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,18 +32,6 @@ #ifndef _ARM_SAMSUNG_EXYNOS_INTR_H_ #define _ARM_SAMSUNG_EXYNOS_INTR_H_ -#define PIC_MAXSOURCES GIC_MAXSOURCES(224) -#define PIC_MAXMAXSOURCES (PIC_MAXSOURCES + 32) /* XXX */ - -/* - * The Exynos uses a generic interrupt controller - */ -#include <arm/cortex/gic_intr.h> - -#ifdef _KERNEL_OPT -#include "opt_exynos.h" -#endif - /* * The GIC supports * - 16 Software Generated Interrupts (SGIs) @@ -61,9 +49,5 @@ #define IRQ_MCT_LTIMER IRQ_PPI(12) -#ifdef EXYNOS5 -#include <arm/cortex/gtmr_intr.h> -#endif - #endif /* _ARM_SAMSUNG_EXYNOS_INTR_H_ */ Index: src/sys/arch/arm/samsung/exynos_reg.h diff -u src/sys/arch/arm/samsung/exynos_reg.h:1.13 src/sys/arch/arm/samsung/exynos_reg.h:1.14 --- src/sys/arch/arm/samsung/exynos_reg.h:1.13 Tue Sep 30 14:20:55 2014 +++ src/sys/arch/arm/samsung/exynos_reg.h Sat Jun 10 15:13:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_reg.h,v 1.13 2014/09/30 14:20:55 reinoud Exp $ */ +/* $NetBSD: exynos_reg.h,v 1.14 2017/06/10 15:13:18 jmcneill Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -97,10 +97,10 @@ #define EXYNOS_BLOCK_SIZE 0x00010000 -#if defined(EXYNOS5) +#if defined(SOC_EXYNOS5) #include <arm/samsung/exynos5_reg.h> #endif -#if defined(EXYNOS4) +#if defined(SOC_EXYNOS4) #include <arm/samsung/exynos4_reg.h> #endif Index: src/sys/arch/arm/samsung/exynos_soc.c diff -u src/sys/arch/arm/samsung/exynos_soc.c:1.31 src/sys/arch/arm/samsung/exynos_soc.c:1.32 --- src/sys/arch/arm/samsung/exynos_soc.c:1.31 Mon Dec 21 04:58:50 2015 +++ src/sys/arch/arm/samsung/exynos_soc.c Sat Jun 10 15:13:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_soc.c,v 1.31 2015/12/21 04:58:50 marty Exp $ */ +/* $NetBSD: exynos_soc.c,v 1.32 2017/06/10 15:13:18 jmcneill Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,10 +31,8 @@ #include "opt_exynos.h" -#define _ARM32_BUS_DMA_PRIVATE - #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.31 2015/12/21 04:58:50 marty Exp $"); +__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.32 2017/06/10 15:13:18 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -76,7 +74,7 @@ struct cpu_freq { }; -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 const struct cpu_freq cpu_freq_settings_exynos4[] = { { 200, 3, 100, 2}, { 300, 4, 200, 2}, @@ -100,7 +98,7 @@ const struct cpu_freq cpu_freq_settings_ #endif -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 #define EXYNOS5_DEFAULT_ENTRY 7 const struct cpu_freq cpu_freq_settings_exynos5[] = { { 200, 3, 100, 2}, @@ -207,7 +205,7 @@ exynos_cpu_boot(int cpu) } -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 /* * The latency values used below are `magic' and probably chosen empirically. * For the 4210 variant the data latency is lower, a 0x110. This is currently @@ -456,13 +454,13 @@ exynos_dump_clocks(void) uint32_t freq; printf("Initial PLL settings\n"); -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 DUMP_PLL(4, APLL); DUMP_PLL(4, MPLL); DUMP_PLL(4, EPLL); DUMP_PLL(4, VPLL); #endif -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 DUMP_PLL(5, APLL); DUMP_PLL(5, MPLL); DUMP_PLL(5, KPLL); @@ -480,6 +478,15 @@ exynos_dump_clocks(void) /* XXX clock stuff needs major work XXX */ void +exynos_init_clkout_for_usb(void) +{ + /* Select XUSBXTI as source for CLKOUT */ + bus_space_write_4(&armv7_generic_bs_tag, exynos_pmu_bsh, + EXYNOS_PMU_DEBUG_CLKOUT, 0x1000); +} + + +void exynos_clocks_bootstrap(void) { KASSERT(ncpu_freq_settings != 0); @@ -493,7 +500,7 @@ exynos_clocks_bootstrap(void) /* set (max) cpufreq */ fsel = ncpu_freq_settings-1; -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 /* XXX BUGFIX selecting freq on E5 goes wrong for now XXX */ fsel = EXYNOS5_DEFAULT_ENTRY; #endif @@ -524,7 +531,7 @@ exynos_bootstrap(vaddr_t iobase, vaddr_t printf("Exynos early console operational\n\n"); #endif -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 core_size = EXYNOS4_CORE_SIZE; audiocore_size = EXYNOS4_AUDIOCORE_SIZE; audiocore_pbase = EXYNOS4_AUDIOCORE_PBASE; @@ -538,7 +545,7 @@ exynos_bootstrap(vaddr_t iobase, vaddr_t ncpu_freq_settings = __arraycount(cpu_freq_settings_exynos4); #endif -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 core_size = EXYNOS5_CORE_SIZE; audiocore_size = EXYNOS5_AUDIOCORE_SIZE; audiocore_pbase = EXYNOS5_AUDIOCORE_PBASE; @@ -594,9 +601,6 @@ exynos_bootstrap(vaddr_t iobase, vaddr_t panic("%s: failed to subregion cmu apll registers: %d", __func__, error); - /* init bus dma tags */ - exynos_dma_bootstrap(physmem * PAGE_SIZE); - /* gpio bootstrapping delayed */ } @@ -625,7 +629,7 @@ exynos_device_register(device_t self, vo extern uint32_t exynos_soc_id; switch (EXYNOS_PRODUCT_ID(exynos_soc_id)) { -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 case 0xe5410: /* offsets not changed on matt's request */ #if 0 @@ -643,7 +647,7 @@ exynos_device_register(device_t self, vo break; } #endif -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 case 0xe4410: case 0xe4412: { struct mpcore_attach_args * const mpcaa = aux; @@ -661,7 +665,7 @@ exynos_device_register(device_t self, vo return; } if (device_is_a(self, "armgtmr") || device_is_a(self, "mct")) { -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 /* * The global timer is dependent on the MCT running. */ @@ -733,7 +737,7 @@ exynos_usb2_set_isolation(bool on) } -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 static void exynos4_usb2phy_enable(bus_space_handle_t usb2phy_bsh) { @@ -794,7 +798,7 @@ exynos4_usb2phy_enable(bus_space_handle_ #endif -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 static void exynos5410_usb2phy_enable(bus_space_handle_t usb2phy_bsh) { @@ -909,10 +913,10 @@ exynos_usb_phy_init(bus_space_handle_t u /* disable phy isolation */ exynos_usb2_set_isolation(false); -#ifdef EXYNOS4 +#ifdef SOC_EXYNOS4 exynos4_usb2phy_enable(usb2phy_bsh); #endif -#ifdef EXYNOS5 +#ifdef SOC_EXYNOS5 if (IS_EXYNOS5410_P()) { exynos5410_usb2phy_enable(usb2phy_bsh); /* TBD: USB3 phy init */ Index: src/sys/arch/arm/samsung/exynos_sscom.c diff -u src/sys/arch/arm/samsung/exynos_sscom.c:1.7 src/sys/arch/arm/samsung/exynos_sscom.c:1.8 --- src/sys/arch/arm/samsung/exynos_sscom.c:1.7 Mon Dec 21 00:54:35 2015 +++ src/sys/arch/arm/samsung/exynos_sscom.c Sat Jun 10 15:13:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_sscom.c,v 1.7 2015/12/21 00:54:35 marty Exp $ */ +/* $NetBSD: exynos_sscom.c,v 1.8 2017/06/10 15:13:18 jmcneill Exp $ */ /* * Copyright (c) 2014 Reinoud Zandijk @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.7 2015/12/21 00:54:35 marty Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.8 2017/06/10 15:13:18 jmcneill Exp $"); #include "opt_sscom.h" #include "opt_ddb.h" @@ -79,10 +79,14 @@ static void sscom_attach(device_t, devic CFATTACH_DECL_NEW(exynos_sscom, sizeof(struct sscom_softc), sscom_match, sscom_attach, NULL, NULL); +static const char * const compatible[] = { + "samsung,exynos4210-uart", + NULL +}; + static int sscom_match(device_t parent, cfdata_t cf, void *aux) { - const char * const compatible[] = { "samsung,exynos4210-uart", NULL }; struct fdt_attach_args * const faa = aux; return of_match_compatible(faa->faa_phandle, compatible); @@ -147,32 +151,39 @@ sscom_attach(device_t parent, device_t s { struct sscom_softc *sc = device_private(self); struct fdt_attach_args *faa = aux; - int unit = -1; + const int phandle = faa->faa_phandle; + bus_space_tag_t bst = faa->faa_bst; bus_space_handle_t bsh; - bus_space_tag_t bst; + struct clk *clk_uart, *clk_uart_baud0; bus_addr_t addr; bus_size_t size; - int error; - int i; - if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) { aprint_error(": couldn't get registers\n"); return; } - /* unit is required for the sscom driver, which desperately - * needs to be rewritten. For now, this hack gets the answer. - * MJF: FIX ME - */ - for (i = 1; i < num_exynos_uarts_entries; i += 2) - if (EXYNOS_CORE_PBASE + exynos_uarts[i] == addr) - break; - unit = exynos_uarts[i-1]; + + if (bus_space_map(bst, addr, size, 0, &bsh) != 0) { + aprint_error(": couldn't map registers\n"); + return; + } + + clk_uart = fdtbus_clock_get(phandle, "uart"); + clk_uart_baud0 = fdtbus_clock_get(phandle, "clk_uart_baud0"); + if (clk_uart == NULL || clk_uart_baud0 == NULL) { + aprint_error(": couldn't get clocks\n"); + return; + } + if (clk_enable(clk_uart) != 0 || clk_enable(clk_uart_baud0) != 0) { + aprint_error(": couldn't enable clocks\n"); + return; + } sc->sc_dev = self; sc->sc_iot = bst = faa->faa_bst; - sc->sc_ioh = exynos_uarts[i] + EXYNOS_CORE_VBASE; - sc->sc_unit = unit; - sc->sc_frequency = EXYNOS_UART_FREQ; + sc->sc_ioh = bsh; + sc->sc_unit = phandle; + sc->sc_frequency = clk_get_rate(clk_uart); sc->sc_change_txrx_interrupts = exynos_change_txrx_interrupts; sc->sc_clear_interrupts = exynos_clear_interrupts; @@ -181,26 +192,15 @@ sscom_attach(device_t parent, device_t s sc->sc_rx_irqno = 0; sc->sc_tx_irqno = 0; - if (!sscom_is_console(sc->sc_iot, unit, &sc->sc_ioh)) { - error = bus_space_map(bst, addr, size, 0, &bsh); - if (error) { - aprint_error(": couldn't map %#llx: %d\n", - (uint64_t)addr, error); - return; - } - sc->sc_ioh = bsh; - } else { - aprint_normal(" (console) "); - } + if (sscom_is_console(sc->sc_iot, phandle, &sc->sc_ioh)) + aprint_normal(" (console)"); aprint_normal("\n"); -#if 0 - void *ih = fdtbus_intr_establish(faa->faa_phandle, 0, IPL_SERIAL, + void *ih = fdtbus_intr_establish(phandle, 0, IPL_SERIAL, FDT_INTR_MPSAFE, sscomintr, sc); if (ih == NULL) aprint_error_dev(self, "failed to establish interrupt\n"); -#endif sscom_attach_subr(sc); @@ -226,3 +226,49 @@ exynos_sscom_kgdb_attach(bus_space_tag_t } #endif /* KGDB */ #endif + + +/* + * Console support + */ + +static int +exynos_sscom_console_match(int phandle) +{ + return of_match_compatible(phandle, compatible); +} + +static void +exynos_sscom_console_consinit(struct fdt_attach_args *faa, u_int uart_freq) +{ + const struct sscom_uart_info info = { + .iobase = 0, /* Offset from bsh */ + .unit = faa->faa_phandle + }; + const int phandle = faa->faa_phandle; + bus_space_tag_t bst = faa->faa_bst; + bus_space_handle_t bsh; + bus_addr_t addr; + bus_size_t size; + tcflag_t flags; + int speed; + + fdtbus_get_reg(phandle, 0, &addr, &size); + speed = fdtbus_get_stdout_speed(); + if (speed < 0) + speed = 115200; /* default */ + flags = fdtbus_get_stdout_flags(); + + if (bus_space_map(bst, addr, size, 0, &bsh) != 0) + panic("cannot map console UART"); + + if (sscom_cnattach(bst, bsh, &info, speed, uart_freq, flags) != 0) + panic("cannot attach console UART"); +} + +static const struct fdt_console exynos_sscom_console = { + .match = exynos_sscom_console_match, + .consinit = exynos_sscom_console_consinit, +}; + +FDT_CONSOLE(exynos_sscom, &exynos_sscom_console); Index: src/sys/arch/arm/samsung/files.exynos diff -u src/sys/arch/arm/samsung/files.exynos:1.21 src/sys/arch/arm/samsung/files.exynos:1.22 --- src/sys/arch/arm/samsung/files.exynos:1.21 Sun Jan 3 04:10:58 2016 +++ src/sys/arch/arm/samsung/files.exynos Sat Jun 10 15:13:18 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.exynos,v 1.21 2016/01/03 04:10:58 marty Exp $ +# $NetBSD: files.exynos,v 1.22 2017/06/10 15:13:18 jmcneill Exp $ # # Configuration info for Samsung Exynos SoC ARM Peripherals # @@ -13,10 +13,10 @@ file arch/arm/arm32/arm32_kvminit.c file arch/arm/arm32/arm32_reboot.c file arch/arm/arm32/irq_dispatch.S file arch/arm/arm32/armv7_generic_space.c +file arch/arm/arm32/armv7_generic_dma.c file arch/arm/arm/bus_space_a4x.S file arch/arm/samsung/exynos_soc.c -#file arch/arm/samsung/exynos_space.c file arch/arm/samsung/exynos_smc.S arm_trustzone_firmware # Console parameters @@ -30,23 +30,20 @@ defparam opt_exynos.h EXYNOS_WDT_DEFA defflag opt_exynos.h EXYNOS_CONSOLE_EARLY # -defflag opt_exynos.h EXYNOS4: CPU_CORTEXA9 -defflag opt_exynos.h EXYNOS4120: EXYNOS4 -defflag opt_exynos.h EXYNOS4212: EXYNOS4 -defflag opt_exynos.h EXYNOS4412: EXYNOS4 -defflag opt_exynos.h EXYNOS4412P: EXYNOS4 -defflag opt_exynos.h EXYNOS5: CPU_CORTEXA15 -defflag opt_exynos.h EXYNOS5250: EXYNOS5 -defflag opt_exynos.h EXYNOS5260: EXYNOS5 -defflag opt_exynos.h EXYNOS5410: EXYNOS5 -defflag opt_exynos.h EXYNOS5420: EXYNOS5 -defflag opt_exynos.h EXYNOS5440: EXYNOS5 -defflag opt_exynos.h EXYNOS5422: EXYNOS5 - -# On-board I/O -device exynosfdt : bus_space_generic, fdtbus -attach exynosfdt at mainbus with exynos_fdt -file arch/arm/samsung/exynos_fdt.c exynos_fdt +defflag opt_exynos.h SOC_EXYNOS4: CPU_CORTEXA9 +defflag opt_exynos.h SOC_EXYNOS4120: SOC_EXYNOS4 +defflag opt_exynos.h SOC_EXYNOS4212: SOC_EXYNOS4 +defflag opt_exynos.h SOC_EXYNOS4412: SOC_EXYNOS4 +defflag opt_exynos.h SOC_EXYNOS4412P: SOC_EXYNOS4 +defflag opt_exynos.h SOC_EXYNOS5: CPU_CORTEXA15 +defflag opt_exynos.h SOC_EXYNOS5250: SOC_EXYNOS5 +defflag opt_exynos.h SOC_EXYNOS5260: SOC_EXYNOS5 +defflag opt_exynos.h SOC_EXYNOS5410: SOC_EXYNOS5 +defflag opt_exynos.h SOC_EXYNOS5420: SOC_EXYNOS5 +defflag opt_exynos.h SOC_EXYNOS5440: SOC_EXYNOS5 +defflag opt_exynos.h SOC_EXYNOS5422: SOC_EXYNOS5 + +file arch/arm/samsung/exynos_platform.c soc_exynos5 # Interrupt combiner device exyointr @@ -120,8 +117,6 @@ device exyoi2c: i2cbus, i2c_bitbang attach exyoi2c at fdt with exynos_i2c file arch/arm/samsung/exynos_i2c.c exynos_i2c needs-flag -file arch/arm/samsung/exynos5422_dma.c - device exy5422clk: clk attach exy5422clk at fdt with exynos5422_clock file arch/arm/samsung/exynos5422_clock.c exynos5422_clock Index: src/sys/arch/arm/samsung/sscom.c diff -u src/sys/arch/arm/samsung/sscom.c:1.8 src/sys/arch/arm/samsung/sscom.c:1.9 --- src/sys/arch/arm/samsung/sscom.c:1.8 Mon Apr 13 21:18:41 2015 +++ src/sys/arch/arm/samsung/sscom.c Sat Jun 10 15:13:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sscom.c,v 1.8 2015/04/13 21:18:41 riastradh Exp $ */ +/* $NetBSD: sscom.c,v 1.9 2017/06/10 15:13:18 jmcneill Exp $ */ /* * Copyright (c) 2002, 2003 Fujitsu Component Limited @@ -98,7 +98,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.8 2015/04/13 21:18:41 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.9 2017/06/10 15:13:18 jmcneill Exp $"); #include "opt_sscom.h" #include "opt_ddb.h" @@ -179,13 +179,9 @@ static int sscom_to_tiocm(struct sscom_s static void sscom_iflush(struct sscom_softc *); static int sscomhwiflow(struct tty *tp, int block); -#if defined(KGDB) || \ - defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) || \ - defined(SSCOM2CONSOLE) || defined(SSCOM3CONSOLE) 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 extern struct cfdriver sscom_cd; @@ -1836,9 +1832,6 @@ sscomintr(void *v) } -#if defined(KGDB) || \ - defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) || \ - defined(SSCOM2CONSOLE) || defined(SSCOM3CONSOLE) /* * Initialize UART for use as console or KGDB line. */ @@ -1882,11 +1875,6 @@ sscom_init(bus_space_tag_t iot, bus_spac return 0; } -#endif - -#if \ - defined(SSCOM0CONSOLE) || defined(SSCOM1CONSOLE) || \ - defined(SSCOM2CONSOLE) || defined(SSCOM3CONSOLE) /* * Following are all routines needed for SSCOM to act as console */ @@ -2024,8 +2012,6 @@ sscomcnpollc(dev_t dev, int on) sscom_readaheadcount = 0; } -#endif /* SSCOM0CONSOLE||SSCOM1CONSOLE */ - #ifdef KGDB int sscom_kgdb_attach(bus_space_tag_t iot, bus_space_handle_t ioh, Index: src/sys/arch/evbarm/conf/EXYNOS diff -u src/sys/arch/evbarm/conf/EXYNOS:1.14 src/sys/arch/evbarm/conf/EXYNOS:1.15 --- src/sys/arch/evbarm/conf/EXYNOS:1.14 Sun Apr 16 15:49:26 2017 +++ src/sys/arch/evbarm/conf/EXYNOS Sat Jun 10 15:13:19 2017 @@ -1,301 +1,94 @@ # -# $NetBSD: EXYNOS,v 1.14 2017/04/16 15:49:26 jmcneill Exp $ +# $NetBSD: EXYNOS,v 1.15 2017/06/10 15:13:19 jmcneill Exp $ # -# ODROID-XU -- ODROID-XU4 Exynos5422 based kernel +# Samsung Exynos SoC kernel # include "arch/evbarm/conf/std.exynos" +include "arch/evbarm/conf/GENERIC.common" -no makeoptions CPUFLAGS -makeoptions CPUFLAGS="-mcpu=cortex-a7 -mfpu=neon" -no makeoptions BOARDTYPE -makeoptions BOARDTYPE="hardkernel_odroid_xu4" -no makeoptions KERNEL_BASE_PHYS -no makeoptions KERNEL_BASE_VIRT -makeoptions KERNEL_BASE_PHYS="0x80000000" -makeoptions KERNEL_BASE_VIRT="0x80000000" -options PMAP_NEED_ALLOC_POOLPAGE -options MEMSIZE=2048 - -# estimated number of users - -maxusers 8 - -# Standard system options - -options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT -#options NTP # NTP phase/frequency locked loop - -# CPU options -options CPU_CORTEX options CPU_CORTEXA7 options CPU_CORTEXA15 -options EXYNOS5422 -#options MULTIPROCESSOR +options SOC_EXYNOS5422 +options MULTIPROCESSOR -options FDT # not really but soon -pseudo-device openfirm # jmcneill: oops, fdtbus should depend on - # openfirm. don't let me forget. - - -options PMAPCOUNTERS -options BUSDMA_COUNTERS -options EXYNOS_CONSOLE_EARLY -#options UVMHIST -options USBHIST -options USBHIST_SIZE=100000 -#options UVMHIST_PRINT,KERNHIST_DELAY=0 -options __HAVE_MM_MD_DIRECT_MAPPED_PHYS -#options PMAP_NEED_ALLOC_POOLPAGE - -# Specify the memory size in megabytes (optional). -#options MEMSIZE=2048 - -# File systems -file-system FFS # UFS -#file-system LFS # log-structured file system -file-system MFS # memory file system -file-system NFS # Network file system -#file-system ADOSFS # AmigaDOS-compatible file system -#file-system EXT2FS # second extended file system (linux) -#file-system CD9660 # ISO 9660 + Rock Ridge file system -file-system MSDOSFS # MS-DOS file system -#file-system FDESC # /dev/fd -file-system KERNFS # /kern -#file-system NULLFS # loopback file system -file-system PROCFS # /proc -#file-system PUFFS # Userspace file systems (e.g. ntfs-3g & sshfs) -#file-system UMAPFS # NULLFS + uid and gid remapping -#file-system UNION # union file system -file-system TMPFS # memory file system -file-system PTYFS # /dev/pts/N support - -# File system options -#options QUOTA # legacy UFS quotas -#options QUOTA2 # new, in-filesystem UFS quotas -#options DISKLABEL_EI # disklabel Endian Independent support -#options FFS_EI # FFS Endian Independent support -options NFSSERVER -options WAPBL # File system journaling support -#options FFS_NO_SNAPSHOT # No FFS snapshot support - -# Networking options - -#options GATEWAY # packet forwarding -options INET # IP + ICMP + TCP + UDP -options INET6 # IPV6 -#options IPSEC # IP security -#options IPSEC_DEBUG # debug for IP security -#options MROUTING # IP multicast routing -#options PIM # Protocol Independent Multicast -#options NETATALK # AppleTalk networking -#options PPP_BSDCOMP # BSD-Compress compression support for PPP -#options PPP_DEFLATE # Deflate compression support for PPP -#options PPP_FILTER # Active filter support for PPP (requires bpf) -#options TCP_DEBUG # Record last TCP_NDEBUG packets with SO_DEBUG - -#options NFS_BOOT_BOOTP -#options NFS_BOOT_DHCP -#options NFS_BOOT_BOOTSTATIC -#options NFS_BOOTSTATIC_MYIP="\"192.168.0.22\"" -#options NFS_BOOTSTATIC_GWIP="\"192.168.0.1\"" -#options NFS_BOOTSTATIC_MASK="\"255.255.255.0\"" -#options NFS_BOOTSTATIC_SERVADDR="\"192.168.0.5\"" -#options NFS_BOOTSTATIC_SERVER="\"192.168.0.5:/stuff/nfs/odroid\"" - -#options NFS_BOOT_RWSIZE=1024 - -# Compatibility options - -options COMPAT_NETBSD32 # allow running arm (e.g. non-earm) binaries -#options COMPAT_43 # 4.3BSD compatibility. -#options COMPAT_09 # NetBSD 0.9, -#options COMPAT_10 # NetBSD 1.0, -#options COMPAT_11 # NetBSD 1.1, -#options COMPAT_12 # NetBSD 1.2, -#options COMPAT_13 # NetBSD 1.3, -#options COMPAT_14 # NetBSD 1.4, -#options COMPAT_15 # NetBSD 1.5, -#options COMPAT_16 # NetBSD 1.6, -#options COMPAT_20 # NetBSD 2.0, -#options COMPAT_30 # NetBSD 3.0, -#options COMPAT_40 # NetBSD 4.0, -#options COMPAT_50 # NetBSD 5.0, -options COMPAT_60 # NetBSD 6.0, and -options COMPAT_70 # NetBSD 7.0 binary compatibility. -#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended. -#options COMPAT_BSDPTY # /dev/[pt]ty?? ptys. - -# Shared memory options - -options SYSVMSG # System V-like message queues -options SYSVSEM # System V-like semaphores -options SYSVSHM # System V-like memory sharing - -# Device options - -#options MEMORY_DISK_HOOKS # boottime setup of ramdisk -#options MEMORY_DISK_ROOT_SIZE=8192 # Size in blocks -#options MEMORY_DISK_DYNAMIC -#options MINIROOTSIZE=1000 # Size in blocks -#options MEMORY_DISK_IS_ROOT # use memory disk as root - -# Wedge support -options DKWEDGE_AUTODISCOVER # Automatically add dk(4) instances -options DKWEDGE_METHOD_GPT # Supports GPT partitions as wedges - -# Miscellaneous kernel options -options KTRACE # system call tracing, a la ktrace(1) -#options SCSIVERBOSE # Verbose SCSI errors -#options MIIVERBOSE # Verbose MII autoconfuration messages -options DDB_KEYCODE=0x40 -#options USERCONF # userconf(4) support -#options PIPE_SOCKETPAIR # smaller, but slower pipe(2) - -# Development and Debugging options - -#options PERFCTRS # performance counters -options DIAGNOSTIC # internal consistency checks -options DEBUG -options LOCKDEBUG -options PMAP_DEBUG # Enable pmap_debug_level code +pseudo-device openfirm # /dev/openfirm + +#options DIAGNOSTIC # internal consistency checks +#options DEBUG +#options LOCKDEBUG +#options PMAP_DEBUG # Enable pmap_debug_level code #options IPKDB # remote kernel debugging -options VERBOSE_INIT_ARM # verbose bootstraping messages -options DDB # in-kernel debugger -options DDB_ONPANIC=1 -options DDB_HISTORY_SIZE=100 # Enable history editing in DDB -options DDB_VERBOSE_HELP -#options KGDB +#options VERBOSE_INIT_ARM # verbose bootstrapping messages +# CONSADDR is required for early init messages from VERBOSE_INIT_ARM. +#options CONSADDR=0x70006300 + makeoptions DEBUG="-g" # compile full symbol table makeoptions COPY_SYMTAB=1 -## USB Debugging options -options USB_DEBUG -options EHCI_DEBUG -options OHCI_DEBUG -options UHUB_DEBUG -options USBVERBOSE - - -# Valid options for BOOT_ARGS: -# single Boot to single user only -# kdb Give control to kernel debugger -# ask Ask for file name to reboot from -# memorydisk=<n> Set memorydisk size to <n> KB -# quiet Show aprint_naive output -# verbose Show aprint_normal and aprint_verbose output -#options BOOT_ARGS="\"\"" -options BOOT_ARGS="\"verbose\"" - config netbsd root on ? type ? -# The main bus device -mainbus0 at root - -# The boot cpu and secondary CPUs -cpu0 at mainbus? -cpu* at mainbus? # Multiprocessor - -# core devices -armperiph0 at mainbus? -armgic0 at armperiph? # Interrupt Controller -armgtmr0 at armperiph? # Generic Timer - -# On-board I/O -exynosfdt0 at mainbus? +# Device tree support +armfdt0 at root fdt* at fdtbus? -fregulator* at fdt? - -#interrupt controller -exyointr0 at fdt? -gic* at fdt? +# CPUs +cpus* at fdt? pass 0 +cpu* at cpus? + +fclock* at fdt? pass 4 +fregulator* at fdt? pass 4 +gpiokeys* at fdt? + +# Timer +gtmr* at fdt? pass 1 # ARM Generic Timer +armgtmr0 at gtmr? +mct* at fdt? # Exynos Multi Core Timer (MCT) + +# Interrupt controller +exyointr* at fdt? pass 1 +gic* at fdt? pass 1 # GIC +armgic0 at gic? # Clock controller -exy5422clk* at fdt? # Exynos5422 clock controller +exy5422clk* at fdt? pass 3 # Exynos5422 clock controller -# Integrated Samsung UARTs -sscom* at fdt? # UART ? - -# Exynos Watchdog Timer -exyowdt* at fdt? # watchdog +# GPIO controller +exyopctl* at fdt? pass 2 # GPIO +gpio* at gpiobus? -# Exynos chip id +# Exynos SoC support chipid* at fdt? +sysmmu* at fdt? -# Exynos system MMUs -sysmmu* at fdt? - -# Exynos RTC -exyortc* at fdt? +# UART +sscom* at fdt? # UART -# Exynos Multi Core timer (MCT) -mct* at fdt? +# I2C +exyoi2c* at fdt? # I2C +iic* at exyoi2c? -# GPIO -exyopctl* at fdt? -gpio* at gpiobus? - -# On-board USB 2.0 -exyousbphy* at fdt? -ohci* at fdt? -ehci* at fdt? -usb* at ohci? -usb* at ehci? - -# On-board USB 3.0 -exyousb* at fdt? -#xhci* at fdt? -#usb* at xhci? - -# I2C devices -exyoi2c* at fdt? -#i2c* at exyoi2c? +# RTC +exyortc* at fdt? # RTC -# SD/MMC -dwcmmc* at fdt? +# SDMMC +dwcmmc* at fdt? # SDMMC sdmmc* at dwcmmc? ld0 at sdmmc0 ld1 at sdmmc1 ld2 at sdmmc2 +ld3 at sdmmc3 ld* at sdmmc? -# MISSING SUPPORT -# eMMC -# uSD -# SPI -# ADC -# PMIC (via I2C #4) -# PWM for Cooling fan -# HDMI -# I2S -# GPU - -# serial console connectivity -options SSCOM2CONSOLE, CONSPEED=115200 +# USB +exyousbphy* at fdt? +exyousb* at fdt? +ohci* at fdt? # OUSB +ehci* at fdt? # EUSB +usb* at ohci? +usb* at ehci? -# include all USB devices include "dev/usb/usbdevices.config" - midi* at midibus? -# Pseudo-Devices - -# disk/mass storage pseudo-devices -#pseudo-device md # memory disk device (ramdisk) -#pseudo-device vnd # disk-like interface to files -#pseudo-device fss # file system snapshot device -#pseudo-device putter # for puffs and pud -pseudo-device drvctl # driver control - -# network pseudo-devices -pseudo-device bpfilter # Berkeley packet filter -pseudo-device loop # network loopback -#pseudo-device kttcp # network loopback - -# miscellaneous pseudo-devices -pseudo-device pty # pseudo-terminals -#options RND_COM -#pseudo-device clockctl # user control of clock subsystem -pseudo-device ksyms # /dev/ksyms -#pseudo-device lockstat # lock profiling +cinclude "arch/evbarm/conf/TEGRA.local" Index: src/sys/arch/evbarm/conf/files.exynos diff -u src/sys/arch/evbarm/conf/files.exynos:1.2 src/sys/arch/evbarm/conf/files.exynos:1.3 --- src/sys/arch/evbarm/conf/files.exynos:1.2 Mon Dec 14 22:06:57 2015 +++ src/sys/arch/evbarm/conf/files.exynos Sat Jun 10 15:13:19 2017 @@ -1,18 +1,8 @@ -# $NetBSD: files.exynos,v 1.2 2015/12/14 22:06:57 marty Exp $ +# $NetBSD: files.exynos,v 1.3 2017/06/10 15:13:19 jmcneill Exp $ # -# EXYNOS 5422 board configuration info +# EXYNOS board configuration info # -file arch/evbarm/exynos/exynos_machdep.c +include "arch/evbarm/conf/files.fdt" -# Kernel boot arguments -defparam opt_machdep.h BOOT_ARGS - -# FDT - -include "dev/ofw/files.ofw" -include "dev/fdt/files.fdt" -include "arch/arm/fdt/files.fdt" - -# Pull in Exynos SoC default -include "arch/arm/samsung/files.exynos" +include "arch/arm/samsung/files.exynos" Index: src/sys/arch/evbarm/conf/std.exynos diff -u src/sys/arch/evbarm/conf/std.exynos:1.1 src/sys/arch/evbarm/conf/std.exynos:1.2 --- src/sys/arch/evbarm/conf/std.exynos:1.1 Sun Dec 6 00:31:24 2015 +++ src/sys/arch/evbarm/conf/std.exynos Sat Jun 10 15:13:19 2017 @@ -1,35 +1,35 @@ -# $NetBSD: std.exynos,v 1.1 2015/12/06 00:31:24 marty Exp $ +# $NetBSD: std.exynos,v 1.2 2017/06/10 15:13:19 jmcneill Exp $ # -# standard NetBSD/evbarm for EXYNOS options machine evbarm arm include "arch/evbarm/conf/std.evbarm" -# Pull in EXYNOS config definitions -include "arch/evbarm/conf/files.exynos" +include "arch/evbarm/conf/files.exynos" -makeoptions CPUFLAGS="-march=armv7-a -mfpu=neon" +makeoptions CPUFLAGS="-march=armv7-a -mfpu=neon" -# To support easy transit to ../arch/arm/arm32 +options ARM_TRUSTZONE_FIRMWARE +options __NO_FIQ + +options FDT # Flattened Device Tree support options MODULAR options MODULAR_DEFAULT_AUTOLOAD -options ARM_HAS_VBAR -options CORTEX_PMC options __HAVE_CPU_COUNTER options __HAVE_FAST_SOFTINTS # should be in types.h +options ARM_HAS_VBAR #options __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#options PMAP_NEED_ALLOC_POOLPAGE options TPIDRPRW_IS_CURCPU options KERNEL_BASE_EXT=0x80000000 options FPU_VFP - -# All shipped Samsung SoC's that are not Samsung products have this -options ARM_TRUSTZONE_FIRMWARE -options __NO_FIQ +options PCI_NETBSD_CONFIGURE +options __HAVE_PCI_CONF_HOOK +options __BUS_SPACE_HAS_STREAM_METHODS makeoptions KERNEL_BASE_PHYS="0x80000000" makeoptions KERNEL_BASE_VIRT="0x80000000" makeoptions BOARDTYPE="exynos" makeoptions BOARDMKFRAG="${THISARM}/conf/mk.exynos" -options ARM_INTR_IMPL="<arch/arm/samsung/exynos_intr.h>" +options ARM_INTR_IMPL="<arch/arm/fdt/fdt_intr.h>" options ARM_GENERIC_TODR Index: src/sys/arch/evbarm/exynos/platform.h diff -u src/sys/arch/evbarm/exynos/platform.h:1.1 src/sys/arch/evbarm/exynos/platform.h:1.2 --- src/sys/arch/evbarm/exynos/platform.h:1.1 Sun Dec 6 00:33:44 2015 +++ src/sys/arch/evbarm/exynos/platform.h Sat Jun 10 15:13:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: platform.h,v 1.1 2015/12/06 00:33:44 marty Exp $ */ +/* $NetBSD: platform.h,v 1.2 2017/06/10 15:13:19 jmcneill Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,11 +32,7 @@ #ifndef _ARM_EXYNOS_PLATFORM_H #define _ARM_EXYNOS_PLATFORM_H -/* - * Kernel VM space 16Mb behind KERNEL_BASE upto 0xeff00000 - */ -#define KERNEL_VM_BASE 0xc0000000 -#define KERNEL_VM_SIZE (EXYNOS_CORE_VBASE - KERNEL_VM_BASE) +#include <arch/evbarm/fdt/platform.h> /* * IO space Added files: Index: src/sys/arch/arm/samsung/exynos_platform.c diff -u /dev/null src/sys/arch/arm/samsung/exynos_platform.c:1.1 --- /dev/null Sat Jun 10 15:13:19 2017 +++ src/sys/arch/arm/samsung/exynos_platform.c Sat Jun 10 15:13:18 2017 @@ -0,0 +1,143 @@ +/* $NetBSD: exynos_platform.c,v 1.1 2017/06/10 15:13:18 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared D. McNeill <jmcne...@invisible.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_exynos.h" +#include "opt_multiprocessor.h" +#include "opt_fdt_arm.h" + +#include "ukbd.h" + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: exynos_platform.c,v 1.1 2017/06/10 15:13:18 jmcneill Exp $"); + +#include <sys/param.h> +#include <sys/bus.h> +#include <sys/cpu.h> +#include <sys/device.h> +#include <sys/termios.h> + +#include <dev/fdt/fdtvar.h> + +#include <uvm/uvm_extern.h> + +#include <machine/bootconfig.h> +#include <arm/cpufunc.h> + +#include <arm/samsung/exynos_reg.h> +#include <arm/samsung/exynos_var.h> + +#include <arm/cortex/gtmr_var.h> + +#include <arm/fdt/arm_fdtvar.h> + +#define EXYNOS_CORE_VBASE 0xf0000000 + +#define DEVMAP_ALIGN(a) ((a) & ~L1_S_OFFSET) +#define DEVMAP_SIZE(s) roundup2((s), L1_S_SIZE) +#define DEVMAP_ENTRY(va, pa, sz) \ + { \ + .pd_va = DEVMAP_ALIGN(va), \ + .pd_pa = DEVMAP_ALIGN(pa), \ + .pd_size = DEVMAP_SIZE(sz), \ + .pd_prot = VM_PROT_READ|VM_PROT_WRITE, \ + .pd_cache = PTE_NOCACHE \ + } +#define DEVMAP_ENTRY_END { 0 } + +static const struct pmap_devmap * +exynos_platform_devmap(void) +{ + static const struct pmap_devmap devmap[] = { + DEVMAP_ENTRY(EXYNOS_CORE_VBASE, + EXYNOS_CORE_PBASE, + EXYNOS_CORE_SIZE), + DEVMAP_ENTRY_END + }; + + return devmap; +} + +static void +exynos_platform_bootstrap(void) +{ + exynos_bootstrap(EXYNOS_CORE_PBASE, 0 /* XXX */); +} + +static void +exynos_platform_init_attach_args(struct fdt_attach_args *faa) +{ + extern struct bus_space armv7_generic_bs_tag; + extern struct bus_space armv7_generic_a4x_bs_tag; + extern struct arm32_bus_dma_tag armv7_generic_dma_tag; + + faa->faa_bst = &armv7_generic_bs_tag; + faa->faa_a4x_bst = &armv7_generic_a4x_bs_tag; + faa->faa_dmat = &armv7_generic_dma_tag; +} + +static void +exynos_platform_early_putchar(char c) +{ +} + +static void +exynos_platform_device_register(device_t self, void *aux) +{ + exynos_device_register(self, aux); +} + +static void +exynos_platform_reset(void) +{ + printf("%s: not implemented\n", __func__); +} + +static void +exynos_platform_delay(u_int us) +{ + gtmr_delay(us); +} + +static u_int +exynos_platform_uart_freq(void) +{ + return EXYNOS_UART_FREQ; +} + +static const struct arm_platform exynos5_platform = { + .devmap = exynos_platform_devmap, + .bootstrap = exynos_platform_bootstrap, + .init_attach_args = exynos_platform_init_attach_args, + .early_putchar = exynos_platform_early_putchar, + .device_register = exynos_platform_device_register, + .reset = exynos_platform_reset, + .delay = exynos_platform_delay, + .uart_freq = exynos_platform_uart_freq, +}; + +ARM_PLATFORM(exynos5, "samsung,exynos5", &exynos5_platform);