Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Rename SOC_TI_AM335X to SOC_AM33XX and rename ti_pl...



details:   https://anonhg.NetBSD.org/src/rev/34ec06aeac0d
branches:  trunk
changeset: 460634:34ec06aeac0d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Oct 29 10:54:10 2019 +0000

description:
Rename SOC_TI_AM335X to SOC_AM33XX and rename ti_platform.c to
am3_platform.c

diffstat:

 sys/arch/arm/ti/am3_platform.c |  150 +++++++++++++++++++++++++++++++++++++++++
 sys/arch/arm/ti/files.ti       |    6 +-
 sys/arch/arm/ti/ti_cpufreq.c   |    8 +-
 sys/arch/arm/ti/ti_iicreg.h    |    8 +-
 sys/arch/arm/ti/ti_platform.c  |  150 -----------------------------------------
 sys/arch/arm/ti/ti_platform.h  |    8 --
 sys/arch/evbarm/conf/GENERIC   |    4 +-
 7 files changed, 160 insertions(+), 174 deletions(-)

diffs (truncated from 415 to 300 lines):

diff -r 842a9bd08d78 -r 34ec06aeac0d sys/arch/arm/ti/am3_platform.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/ti/am3_platform.c    Tue Oct 29 10:54:10 2019 +0000
@@ -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);
diff -r 842a9bd08d78 -r 34ec06aeac0d sys/arch/arm/ti/files.ti
--- a/sys/arch/arm/ti/files.ti  Tue Oct 29 10:52:22 2019 +0000
+++ b/sys/arch/arm/ti/files.ti  Tue Oct 29 10:54:10 2019 +0000
@@ -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 @@
 
 # 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
diff -r 842a9bd08d78 -r 34ec06aeac0d sys/arch/arm/ti/ti_cpufreq.c
--- a/sys/arch/arm/ti/ti_cpufreq.c      Tue Oct 29 10:52:22 2019 +0000
+++ b/sys/arch/arm/ti/ti_cpufreq.c      Tue Oct 29 10:54:10 2019 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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_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_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
diff -r 842a9bd08d78 -r 34ec06aeac0d sys/arch/arm/ti/ti_iicreg.h
--- a/sys/arch/arm/ti/ti_iicreg.h       Tue Oct 29 10:52:22 2019 +0000
+++ b/sys/arch/arm/ti/ti_iicreg.h       Tue Oct 29 10:54:10 2019 +0000
@@ -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 */
diff -r 842a9bd08d78 -r 34ec06aeac0d sys/arch/arm/ti/ti_platform.c
--- a/sys/arch/arm/ti/ti_platform.c     Tue Oct 29 10:52:22 2019 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/* $NetBSD: ti_platform.c,v 1.9 2019/10/27 21:26:04 jmcneill Exp $ */
-
-#include "opt_console.h"
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.9 2019/10/27 21:26:04 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)



Home | Main Index | Thread Index | Old Index