Module Name: src Committed By: jmcneill Date: Tue Oct 29 10:54:10 UTC 2019
Modified Files: src/sys/arch/arm/ti: files.ti ti_cpufreq.c ti_iicreg.h src/sys/arch/evbarm/conf: GENERIC Added Files: src/sys/arch/arm/ti: am3_platform.c Removed Files: src/sys/arch/arm/ti: ti_platform.c ti_platform.h Log Message: Rename SOC_TI_AM335X to SOC_AM33XX and rename ti_platform.c to am3_platform.c To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/am3_platform.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/ti/files.ti cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_cpufreq.c \ src/sys/arch/arm/ti/ti_iicreg.h cvs rdiff -u -r1.9 -r0 src/sys/arch/arm/ti/ti_platform.c cvs rdiff -u -r1.1 -r0 src/sys/arch/arm/ti/ti_platform.h cvs rdiff -u -r1.60 -r1.61 src/sys/arch/evbarm/conf/GENERIC 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/ti/files.ti diff -u src/sys/arch/arm/ti/files.ti:1.14 src/sys/arch/arm/ti/files.ti:1.15 --- src/sys/arch/arm/ti/files.ti:1.14 Mon Oct 28 23:57:59 2019 +++ src/sys/arch/arm/ti/files.ti Tue Oct 29 10:54:10 2019 @@ -1,8 +1,8 @@ -# $NetBSD: files.ti,v 1.14 2019/10/28 23:57:59 jmcneill Exp $ +# $NetBSD: files.ti,v 1.15 2019/10/29 10:54:10 jmcneill Exp $ # -file arch/arm/ti/ti_platform.c soc_ti file arch/arm/ti/ti_cpufreq.c soc_ti +file arch/arm/ti/am3_platform.c soc_am33xx # Interrupt controller device omapintc: pic, pic_splfuncs @@ -87,4 +87,4 @@ file arch/arm/ti/ti_rng.c ti_rng # SOC parameters defflag opt_soc.h SOC_TI -defflag opt_soc.h SOC_TI_AM335X: SOC_TI +defflag opt_soc.h SOC_AM33XX: SOC_TI Index: src/sys/arch/arm/ti/ti_cpufreq.c diff -u src/sys/arch/arm/ti/ti_cpufreq.c:1.1 src/sys/arch/arm/ti/ti_cpufreq.c:1.2 --- src/sys/arch/arm/ti/ti_cpufreq.c:1.1 Mon Oct 28 21:16:47 2019 +++ src/sys/arch/arm/ti/ti_cpufreq.c Tue Oct 29 10:54:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ti_cpufreq.c,v 1.1 2019/10/28 21:16:47 jmcneill Exp $ */ +/* $NetBSD: ti_cpufreq.c,v 1.2 2019/10/29 10:54:10 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill <jmcne...@invisible.ca> @@ -29,7 +29,7 @@ #include "opt_soc.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ti_cpufreq.c,v 1.1 2019/10/28 21:16:47 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ti_cpufreq.c,v 1.2 2019/10/29 10:54:10 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -44,7 +44,7 @@ static bool ti_opp_probed = false; static bool (*ti_opp_supportedfn)(const int, const int); static struct syscon *ti_opp_syscon; -#ifdef SOC_TI_AM335X +#ifdef SOC_AM33XX #define AM33XX_REV_OFFSET 0x0600 #define AM33XX_REV_MASK 0xf0000000 @@ -93,7 +93,7 @@ ti_opp_probe(const int opp_table) ti_opp_syscon = fdtbus_syscon_acquire(opp_table, "syscon"); -#ifdef SOC_TI_AM335X +#ifdef SOC_AM33XX if (ti_opp_syscon && of_match_compatible(OF_finddevice("/"), am33xx_compatible)) ti_opp_supportedfn = am33xx_opp_supported; #endif Index: src/sys/arch/arm/ti/ti_iicreg.h diff -u src/sys/arch/arm/ti/ti_iicreg.h:1.1 src/sys/arch/arm/ti/ti_iicreg.h:1.2 --- src/sys/arch/arm/ti/ti_iicreg.h:1.1 Sun Oct 27 19:11:07 2019 +++ src/sys/arch/arm/ti/ti_iicreg.h Tue Oct 29 10:54:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ti_iicreg.h,v 1.1 2019/10/27 19:11:07 jmcneill Exp $ */ +/* $NetBSD: ti_iicreg.h,v 1.2 2019/10/29 10:54:10 jmcneill Exp $ */ /* * Copyright (c) 2013 Manuel Bouyer. All rights reserved. @@ -134,10 +134,4 @@ #define I2C_ACTOA_OA1_ACT 0x0002 #define I2C_ACTOA_OA0_ACT 0x0001 -#if defined(TI_AM335X) -#define OMAP2_I2C0_BASE 0x44E0B000 -#define OMAP2_I2C1_BASE 0x4802A000 -#define OMAP2_I2C2_BASE 0x4819C000 -#endif /* TI_AM335X */ - #endif /* _OMAP2IICREG_H */ Index: src/sys/arch/evbarm/conf/GENERIC diff -u src/sys/arch/evbarm/conf/GENERIC:1.60 src/sys/arch/evbarm/conf/GENERIC:1.61 --- src/sys/arch/evbarm/conf/GENERIC:1.60 Mon Oct 28 23:58:18 2019 +++ src/sys/arch/evbarm/conf/GENERIC Tue Oct 29 10:54:10 2019 @@ -1,5 +1,5 @@ # -# $NetBSD: GENERIC,v 1.60 2019/10/28 23:58:18 jmcneill Exp $ +# $NetBSD: GENERIC,v 1.61 2019/10/29 10:54:10 jmcneill Exp $ # # GENERIC ARM (aarch32) kernel # @@ -224,7 +224,7 @@ options SOC_SUN9I_A80 options SOC_TEGRA124 -options SOC_TI_AM335X +options SOC_AM33XX options SOC_VIRT Added files: Index: src/sys/arch/arm/ti/am3_platform.c diff -u /dev/null src/sys/arch/arm/ti/am3_platform.c:1.1 --- /dev/null Tue Oct 29 10:54:10 2019 +++ src/sys/arch/arm/ti/am3_platform.c Tue Oct 29 10:54:10 2019 @@ -0,0 +1,150 @@ +/* $NetBSD: am3_platform.c,v 1.1 2019/10/29 10:54:10 jmcneill Exp $ */ + +#include "opt_console.h" + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: am3_platform.c,v 1.1 2019/10/29 10:54:10 jmcneill Exp $"); + +#include <sys/param.h> + +#include <dev/fdt/fdtvar.h> +#include <arm/fdt/arm_fdtvar.h> + +#include <uvm/uvm_extern.h> + +#include <dev/ic/comreg.h> + +#include <arch/evbarm/fdt/platform.h> + +extern struct bus_space armv7_generic_bs_tag; +extern struct bus_space armv7_generic_a4x_bs_tag; +extern struct arm32_bus_dma_tag arm_generic_dma_tag; + +void am33xx_platform_early_putchar(char); + +void +am33xx_platform_early_putchar(char c) +{ +#ifdef CONSADDR +#define CONSADDR_VA ((CONSADDR - 0x44c00000) + (KERNEL_IO_VBASE | 0x04c00000)) + volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ? + (volatile uint32_t *)CONSADDR_VA : + (volatile uint32_t *)CONSADDR; + + while ((le32toh(uartaddr[com_lsr]) & LSR_TXRDY) == 0) + ; + + uartaddr[com_data] = htole32(c); +#endif +} + + +static const struct pmap_devmap * +am33xx_platform_devmap(void) +{ + static const struct pmap_devmap devmap[] = { + DEVMAP_ENTRY(KERNEL_IO_VBASE | 0x04c00000, 0x44c00000, 0x00400000), + DEVMAP_ENTRY(KERNEL_IO_VBASE | 0x08000000, 0x48000000, 0x01000000), + DEVMAP_ENTRY(KERNEL_IO_VBASE | 0x0a000000, 0x4a000000, 0x01000000), + DEVMAP_ENTRY_END + }; + + return devmap; +} + +static void +am33xx_platform_init_attach_args(struct fdt_attach_args *faa) +{ + faa->faa_bst = &armv7_generic_bs_tag; + faa->faa_a4x_bst = &armv7_generic_a4x_bs_tag; + faa->faa_dmat = &arm_generic_dma_tag; +} + +static void +wdelay(bus_space_tag_t bst, bus_space_handle_t bsh) +{ + while (bus_space_read_4(bst, bsh, 0x34) != 0) + delay(10); +} + +static void +am33xx_platform_bootstrap(void) +{ + static bus_space_tag_t bst = &armv7_generic_bs_tag; + static bus_space_handle_t bsh; + + bus_space_map(bst, 0x44e00000, 0x1000, 0, &bsh); + bus_space_write_4(bst, bsh, 0x508, 0x1); /* CLKSEL_TIMER2_CLK: CLK_M_OSC */ + bus_space_write_4(bst, bsh, 0x50c, 0x1); /* CLKSEL_TIMER3_CLK: CLK_M_OSC */ + bus_space_write_4(bst, bsh, 0x80, 0x2); /* CM_PER_TIMER2_CLKCTRL: MODULEMODE: ENABLE */ + bus_space_write_4(bst, bsh, 0x84, 0x2); /* CM_PER_TIMER3_CLKCTRL: MODULEMODE: ENABLE */ + bus_space_unmap(bst, bsh, 0x1000); + + bus_space_map(bst, 0x48040000, 0x1000, 0, &bsh); /* TIMER2 for delay() */ + + bus_space_write_4(bst, bsh, 0x40, 0); /* Load */ + bus_space_write_4(bst, bsh, 0x3c, 0); /* Counter */ + bus_space_write_4(bst, bsh, 0x38, 3); /* Control */ + + bus_space_unmap(bst, bsh, 0x1000); + + bus_space_map(bst, 0x44e35000, 0x1000, 0, &bsh); + wdelay(bst, bsh); + bus_space_write_4(bst, bsh, 0x48, 0xAAAA); + wdelay(bst, bsh); + bus_space_write_4(bst, bsh, 0x48, 0x5555); + wdelay(bst, bsh); + bus_space_unmap(bst, bsh, 0x1000); + + bus_space_map(bst, 0x44e00000, 0x1000, 0, &bsh); + bus_space_write_4(bst, bsh, 0x4d4, 0); /* suspend watch dog */ + bus_space_unmap(bst, bsh, 0x1000); +} + +static u_int +am33xx_platform_uart_freq(void) +{ + return 48000000; +} + +static void +am33xx_platform_delay(u_int n) +{ + static bus_space_tag_t bst = &armv7_generic_bs_tag; + static bus_space_handle_t bsh = 0; + + uint32_t cur, prev; + long ticks = n * 24; + + if (bsh == 0) + bus_space_map(bst, 0x48040000, 0x1000, 0, &bsh); /* TIMER2 */ + + prev = bus_space_read_4(bst, bsh, 0x3c); + while (ticks > 0) { + cur = bus_space_read_4(bst, bsh, 0x3c); + if (cur >= prev) + ticks -= (cur - prev); + else + ticks -= (UINT32_MAX - cur + prev); + prev = cur; + } +} + +static void +am33xx_platform_reset(void) +{ + volatile uint32_t *resetaddr = (volatile uint32_t *)(KERNEL_IO_VBASE | 0x04e00f00); + + *resetaddr = 1; +} + +static const struct arm_platform am33xx_platform = { + .ap_devmap = am33xx_platform_devmap, + .ap_init_attach_args = am33xx_platform_init_attach_args, + .ap_bootstrap = am33xx_platform_bootstrap, + .ap_uart_freq = am33xx_platform_uart_freq, + .ap_delay = am33xx_platform_delay, + .ap_reset = am33xx_platform_reset, +}; + +ARM_PLATFORM(am33xx, "ti,am33xx", &am33xx_platform);