summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/src/lib/libbsp/arm/beagle/Makefile.am52
-rw-r--r--c/src/lib/libbsp/arm/beagle/README122
-rw-r--r--c/src/lib/libbsp/arm/beagle/README.JTAG20
-rw-r--r--c/src/lib/libbsp/arm/beagle/TESTING20
-rw-r--r--c/src/lib/libbsp/arm/beagle/clock.c332
-rw-r--r--c/src/lib/libbsp/arm/beagle/clock/beagle-clock-config.c135
-rw-r--r--c/src/lib/libbsp/arm/beagle/configure.ac77
-rw-r--r--c/src/lib/libbsp/arm/beagle/console/console-config.c254
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/beagle-clock-config.h58
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/beagle-timer.h159
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/beagle.h760
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/boot.h117
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/bsp.h455
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/i2c.h89
-rw-r--r--c/src/lib/libbsp/arm/beagle/include/irq.h184
-rw-r--r--c/src/lib/libbsp/arm/beagle/irq.c142
-rw-r--r--c/src/lib/libbsp/arm/beagle/irq/irq.c397
-rw-r--r--c/src/lib/libbsp/arm/beagle/make/custom/beagleboardorig.cfg2
-rw-r--r--c/src/lib/libbsp/arm/beagle/make/custom/beagleboardxm.cfg (renamed from c/src/lib/libbsp/arm/beagle/make/custom/beagle.cfg)5
-rw-r--r--c/src/lib/libbsp/arm/beagle/make/custom/beagleboneblack.cfg2
-rw-r--r--c/src/lib/libbsp/arm/beagle/make/custom/beaglebonewhite.cfg2
-rw-r--r--c/src/lib/libbsp/arm/beagle/misc/boot.c62
-rw-r--r--c/src/lib/libbsp/arm/beagle/misc/i2c.c2
-rw-r--r--c/src/lib/libbsp/arm/beagle/misc/restart.c32
-rw-r--r--c/src/lib/libbsp/arm/beagle/misc/system-clocks.c140
-rw-r--r--c/src/lib/libbsp/arm/beagle/misc/timer.c46
-rw-r--r--c/src/lib/libbsp/arm/beagle/preinstall.am62
-rw-r--r--c/src/lib/libbsp/arm/beagle/rtc/rtc-config.c138
-rw-r--r--c/src/lib/libbsp/arm/beagle/simscripts/bbxm.cfg174
-rw-r--r--c/src/lib/libbsp/arm/beagle/simscripts/gdbinit.bbxm16
-rw-r--r--c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh84
-rw-r--r--c/src/lib/libbsp/arm/beagle/startup/bspreset.c62
-rw-r--r--c/src/lib/libbsp/arm/beagle/startup/bspstart.c30
-rw-r--r--c/src/lib/libbsp/arm/beagle/startup/bspstarthooks.c360
-rw-r--r--c/src/lib/libbsp/arm/beagle/startup/bspstartmmu.c58
-rw-r--r--c/src/lib/libbsp/arm/beagle/startup/linkcmds.beagle56
36 files changed, 1485 insertions, 3221 deletions
diff --git a/c/src/lib/libbsp/arm/beagle/Makefile.am b/c/src/lib/libbsp/arm/beagle/Makefile.am
index 2f537fefac..c6cf9e790f 100644
--- a/c/src/lib/libbsp/arm/beagle/Makefile.am
+++ b/c/src/lib/libbsp/arm/beagle/Makefile.am
@@ -19,6 +19,7 @@ dist_project_lib_DATA = bsp_specs
###############################################################################
include_HEADERS = include/bsp.h
+include_HEADERS += ../../shared/include/tm27.h
nodist_include_HEADERS = ../../shared/include/coverhd.h \
include/bspopts.h
@@ -31,16 +32,19 @@ include_bsp_HEADERS += ../../shared/include/irq-generic.h
include_bsp_HEADERS += ../../shared/include/irq-info.h
include_bsp_HEADERS += ../../shared/include/stackalloc.h
include_bsp_HEADERS += ../../shared/include/uart-output-char.h
-include_bsp_HEADERS += ../../shared/tod.h
+include_bsp_HEADERS += ../shared/include/arm-a8core-start.h
+include_bsp_HEADERS += ../shared/include/arm-cp15-start.h
+include_bsp_HEADERS += ../shared/include/arm-errata.h
+include_bsp_HEADERS += ../shared/include/arm-release-id.h
include_bsp_HEADERS += ../shared/include/start.h
include_bsp_HEADERS += include/irq.h
-include_bsp_HEADERS += include/beagle.h
-include_bsp_HEADERS += include/beagle-clock-config.h
-include_bsp_HEADERS += include/beagle-timer.h
-include_bsp_HEADERS += include/boot.h
include_bsp_HEADERS += include/i2c.h
-include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/arm-cp15.h
+include_libcpu_HEADERS =
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/arm-cp15.h
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/omap3.h
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/am335x.h
+include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/omap_timer.h
###############################################################################
# Data #
@@ -78,13 +82,18 @@ libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
libbsp_a_SOURCES += ../../shared/sbrk.c
libbsp_a_SOURCES += ../../shared/src/stackalloc.c
-libbsp_a_SOURCES += ../../shared/src/uart-output-char.c
+libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
+libbsp_a_SOURCES += ../../shared/timerstub.c
+libbsp_a_SOURCES += ../../shared/cpucounterread.c
libbsp_a_SOURCES += ../shared/abort/simple_abort.c
libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
+libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
# Startup
libbsp_a_SOURCES += startup/bspreset.c
libbsp_a_SOURCES += startup/bspstart.c
+libbsp_a_SOURCES += startup/bspstarthooks.c
+libbsp_a_SOURCES += startup/bspstartmmu.c
# IRQ
libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
@@ -93,7 +102,7 @@ libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
libbsp_a_SOURCES += ../../shared/src/irq-server.c
libbsp_a_SOURCES += ../../shared/src/irq-shell.c
-libbsp_a_SOURCES += irq/irq.c
+libbsp_a_SOURCES += irq.c
# Console
libbsp_a_SOURCES += ../../shared/console.c \
@@ -103,37 +112,18 @@ libbsp_a_SOURCES += ../../shared/console.c \
../../shared/console_write.c \
../../shared/console_control.c
-# Clock
-libbsp_a_SOURCES += clock/beagle-clock-config.c
-libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
-
-# RTC
-libbsp_a_SOURCES += ../../shared/tod.c \
- rtc/rtc-config.c
-
-# Misc
-libbsp_a_SOURCES += misc/boot.c
+# I2C
libbsp_a_SOURCES += misc/i2c.c
-libbsp_a_SOURCES += misc/restart.c
-libbsp_a_SOURCES += misc/system-clocks.c
-libbsp_a_SOURCES += misc/timer.c
-# SSP
-
-# I2C
+# Clock
+libbsp_a_SOURCES += clock.c
+libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
# Cache
libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
-# Start hooks
-libbsp_a_SOURCES += startup/bspstarthooks.c
-
-###############################################################################
-# Network #
-###############################################################################
-
###############################################################################
# Special Rules #
###############################################################################
diff --git a/c/src/lib/libbsp/arm/beagle/README b/c/src/lib/libbsp/arm/beagle/README
index c722ecfc35..e558287408 100644
--- a/c/src/lib/libbsp/arm/beagle/README
+++ b/c/src/lib/libbsp/arm/beagle/README
@@ -1,6 +1,118 @@
-Development board is a BeagleBoard Rev Cx. Basic initialization via stage 1
-bootloader or U-Boot will be assumed. Drivers:
+BSP for beagleboard xm, beaglebone (original aka white), and beaglebone black.
- o Standard UART 3, 4, 5, 6 (Console = 5, 115200N1)
- o Clock uses TIMER 0
- o Ethernet
+original beagleboard isn't tested.
+
+wiki: http://www.rtems.org/wiki/index.php/Beagleboard
+
+1. *** CONFIGURING ************
+
+bsp-specific build options in the environment at build time:
+CONSOLE_POLLED=1 use polled i/o for console, required to run testsuite
+CONSOLE_BAUD=... override default console baud rate
+
+BSPs recognized are:
+beagleboardorig original beagleboard
+beagleboardxm beagleboard xm
+beaglebonewhite original beaglebone
+beagleboneblack beaglebone black
+
+Currently the only distinction in the BSP are between the beagleboards and
+the beaglebones, but the 4 names are specified in case hardware-specific
+distinctions are made in the future, so this can be done without changing the
+usage.
+
+
+2. *** BUILDING ************
+
+To build BSPs for the beaglebone white and beagleboard xm, starting from
+a directory in which you have this source tree in rtems-src:
+
+$ mkdir b-beagle
+$ cd b-beagle
+$ ../rtems-src/configure --target=arm-rtems4.11 --enable-rtemsbsp="beaglebonewhite beagleboardxm"
+$ make all
+
+This should give you .exes somewhere.
+
+Then you need 'mkimage' to transform a .exe file to a u-boot image
+file. first make a flat binary:
+
+$ arm-rtems4.11-objcopy $exe -O binary $exe.bin
+$ gzip -9 $exe.bin
+$ mkimage -A arm -O rtems -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS -d $exe.bin.gz rtems-app.img
+
+All beagles have memory starting at 0x80000000 so the load & run syntax is the same.
+
+3. *** BOOTING ************
+
+Then, boot the beaglebone with u-boot on an SD card and load rtems-app.img
+from u-boot. Interrupt the u-boot boot to get a prompt.
+
+Set up a tftp server and a network connection for netbooting. And to
+copy rtems-app.img to the tftp dir. Otherwise copy the .img to the FAT
+partition on the SD card and make uboot load & run that.
+
+4. *** BEAGLEBONES ************
+
+(tested on both beaglebones)
+
+Beaglebone original (white) or beaglebone black netbooting:
+
+uboot# setenv ipaddr 192.168.12.20
+uboot# setenv serverip 192.168.12.10
+uboot# echo starting from TFTP
+uboot# tftp 0x80800000 rtems-app.img
+uboot# dcache off ; icache off
+uboot# bootm 0x80800000
+
+Beaglebone original (white) or beaglebone black from a FAT partition:
+
+uboot# fatload mmc :1 0x80800000 ticker.img
+uboot# dcache off ; icache off
+uboot# bootm 0x80800000
+
+4. *** BEAGLEBOARD ************
+
+(tested on xm)
+
+For the beagleboard the necessary commands are a bit different because
+of the ethernet over usb:
+
+uboot# setenv serverip 192.168.12.10
+uboot# setenv ipaddr 192.168.12.62
+uboot# setenv usbnet_devaddr e8:03:9a:24:f9:10
+uboot# setenv usbethaddr e8:03:9a:24:f9:11
+uboot# usb start
+uboot# echo starting from TFTP
+uboot# tftp 0x80800000 rtems-app.img
+uboot# dcache off ; icache off
+uboot# bootm 0x80800000
+
+4. *** SD CARD ****************
+
+There is a script here that automatically writes an SD card for any of
+the beagle targets.
+
+Let's write one for the Beaglebone Black. Assuming your source tree is
+at $HOME/development/rtems/rtems-src and your bsp is built and linked
+with examples and installed at $HOME/development/rtems/4.11.
+
+ % cd $HOME/development/rtems/rtems-src/c/src/lib/libbsp/arm/beagle/simscripts
+ % sh sdcard.sh $HOME/development/rtems/4.11 $HOME/development/rtems/b-beagle/arm-rtems4.11/c/beagleboneblack/testsuites/samples/hello/hello.exe
+
+The script should give you a whole bunch of output, ending in:
+
+ Result is in bone_hello.exe-sdcard.img.
+
+There you go. dd that to an SD card and boot!
+
+The script needs to know whether it's for a Beagleboard xM or one of the
+Beaglebones. This is to know which uboot to use. It will detect this
+from the path the executable is in (in the above example, it contains
+'beagleboneblack'), so you have to specify the full path.
+
+
+Good luck & enjoy!
+
+Ben Gras
+beng@shrike-systems.com
diff --git a/c/src/lib/libbsp/arm/beagle/README.JTAG b/c/src/lib/libbsp/arm/beagle/README.JTAG
new file mode 100644
index 0000000000..8d30590b54
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/README.JTAG
@@ -0,0 +1,20 @@
+To run RTEMS from scratch (without any other bootcode) on the beagles,
+you can comfortably load the executables over JTAG using gdb. This is
+necessarily target-specific however.
+
+1. BBXM
+
+ - For access to JTAG using openocd, see simscripts/bbxm.cfg.
+ - openocd then offers access to gdb using simscripts/gdbinit.bbxm.
+ - start openocd using bbxm.cfg
+ - copy your .exe to a new dir and that gdbinit file as .gdbinit in the same dir
+ - go there and start gdb:
+ $ arm-rtems4.11-gdb hello.exe
+ - gdb will invoke the BBXM hardware initialization in the bbxm.cfg
+ and load the ELF over JTAG. type 'c' (for continue) to run it.
+ - breakpoints, C statement and single-instruction stepping work.
+
+2. beaglebone white
+
+This has been tested with openocd and works but not in as much detail as for
+the BBXM yet (i.e. loading an executable from scratch).
diff --git a/c/src/lib/libbsp/arm/beagle/TESTING b/c/src/lib/libbsp/arm/beagle/TESTING
new file mode 100644
index 0000000000..2fea12b714
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/TESTING
@@ -0,0 +1,20 @@
+To build and run the tests for this BSP, use the RTEMS tester.
+The necessary software can be built with the RTEMS source builder.
+
+To build the BSP for testing:
+ - set CONSOLE_POLLED=1 in the configure environment, some tests
+ assume console i/o is polled
+ - add --enable-tests to the configure line
+
+1. Qemu
+
+Linaro Qemu can emulate the beagleboard xm and so run all regression
+tests in software. Build the bbxm.bset from the RTEMS source builder and
+you will get qemu linaro that can run them. There is a beagleboardxm_qemu
+bsp in the RTEMS tester to invoke it with every test.
+
+2. bbxm hardware
+
+This requires JTAG, see README.JTAG. Use the beagleboardxm bsp in the
+RTEMS tester. It starts gdb to connect to openocd to reset the target
+and load the RTEMS executable for each test iteration.
diff --git a/c/src/lib/libbsp/arm/beagle/clock.c b/c/src/lib/libbsp/arm/beagle/clock.c
new file mode 100644
index 0000000000..13c0607b8e
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/clock.c
@@ -0,0 +1,332 @@
+/**
+ * @file
+ *
+ * @ingroup arm_beagle
+ *
+ * @brief Clock driver configuration.
+ */
+
+/*
+ * Copyright (c) 2014 Ben Gras <beng@shrike-systems.com>.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems.h>
+#include <bsp.h>
+
+#include <libcpu/omap_timer.h>
+
+#ifdef ARM_MULTILIB_ARCH_V4
+
+static omap_timer_registers_t regs_v1 = {
+ .TIDR = OMAP3_TIMER_TIDR,
+ .TIOCP_CFG = OMAP3_TIMER_TIOCP_CFG,
+ .TISTAT = OMAP3_TIMER_TISTAT,
+ .TISR = OMAP3_TIMER_TISR,
+ .TIER = OMAP3_TIMER_TIER,
+ .TWER = OMAP3_TIMER_TWER,
+ .TCLR = OMAP3_TIMER_TCLR,
+ .TCRR = OMAP3_TIMER_TCRR,
+ .TLDR = OMAP3_TIMER_TLDR,
+ .TTGR = OMAP3_TIMER_TTGR,
+ .TWPS = OMAP3_TIMER_TWPS,
+ .TMAR = OMAP3_TIMER_TMAR,
+ .TCAR1 = OMAP3_TIMER_TCAR1,
+ .TSICR = OMAP3_TIMER_TSICR,
+ .TCAR2 = OMAP3_TIMER_TCAR2,
+ .TPIR = OMAP3_TIMER_TPIR,
+ .TNIR = OMAP3_TIMER_TNIR,
+ .TCVR = OMAP3_TIMER_TCVR,
+ .TOCR = OMAP3_TIMER_TOCR,
+ .TOWR = OMAP3_TIMER_TOWR,
+};
+
+/* AM335X has a different ip block for the non 1ms timers */
+static omap_timer_registers_t regs_v2 = {
+ .TIDR = AM335X_TIMER_TIDR,
+ .TIOCP_CFG = AM335X_TIMER_TIOCP_CFG,
+ .TISTAT = AM335X_TIMER_IRQSTATUS_RAW,
+ .TISR = AM335X_TIMER_IRQSTATUS,
+ .TIER = AM335X_TIMER_IRQENABLE_SET,
+ .TWER = AM335X_TIMER_IRQWAKEEN,
+ .TCLR = AM335X_TIMER_TCLR,
+ .TCRR = AM335X_TIMER_TCRR,
+ .TLDR = AM335X_TIMER_TLDR,
+ .TTGR = AM335X_TIMER_TTGR,
+ .TWPS = AM335X_TIMER_TWPS,
+ .TMAR = AM335X_TIMER_TMAR,
+ .TCAR1 = AM335X_TIMER_TCAR1,
+ .TSICR = AM335X_TIMER_TSICR,
+ .TCAR2 = AM335X_TIMER_TCAR2,
+ .TPIR = -1, /* UNDEF */
+ .TNIR = -1, /* UNDEF */
+ .TCVR = -1, /* UNDEF */
+ .TOCR = -1, /* UNDEF */
+ .TOWR = -1 /* UNDEF */
+};
+
+/* which timers are in use? target-dependent.
+ * initialize at compile time.
+ */
+
+#if IS_DM3730
+
+static omap_timer_t dm37xx_timer = {
+ .base = OMAP3_GPTIMER1_BASE,
+ .irq_nr = OMAP3_GPT1_IRQ,
+ .regs = &regs_v1
+};
+
+/* free running timer */
+static omap_timer_t dm37xx_fr_timer = {
+ .base = OMAP3_GPTIMER10_BASE,
+ .irq_nr = OMAP3_GPT10_IRQ,
+ .regs = &regs_v1
+};
+
+static struct omap_timer *fr_timer = &dm37xx_fr_timer;
+static struct omap_timer *timer = &dm37xx_timer;
+
+#endif
+
+#if IS_AM335X
+
+/* normal timer */
+static omap_timer_t am335x_timer = {
+ .base = AM335X_DMTIMER1_1MS_BASE,
+ .irq_nr = AM335X_INT_TINT1_1MS,
+ .regs = &regs_v1
+};
+
+/* free running timer */
+static omap_timer_t am335x_fr_timer = {
+ .base = AM335X_DMTIMER7_BASE,
+ .irq_nr = AM335X_INT_TINT7,
+ .regs = &regs_v2
+};
+
+static struct omap_timer *fr_timer = &am335x_fr_timer;
+static struct omap_timer *timer = &am335x_timer;
+
+#endif
+
+static int done = 0;
+
+#if IS_AM335X
+#define FRCLOCK_HZ (16*1500000)
+#endif
+
+#if IS_DM3730
+#define FRCLOCK_HZ (8*1625000)
+#endif
+
+#ifndef FRCLOCK_HZ
+#error expected IS_AM335X or IS_DM3730 to be defined.
+#endif
+
+static void
+omap3_frclock_init(void)
+{
+ uint32_t tisr;
+
+#if IS_DM3730
+ /* Stop timer */
+ mmio_clear(fr_timer->base + fr_timer->regs->TCLR,
+ OMAP3_TCLR_ST);
+
+ /* Use functional clock source for GPTIMER10 */
+ mmio_set(OMAP3_CM_CLKSEL_CORE, OMAP3_CLKSEL_GPT10);
+#endif
+
+#if IS_AM335X
+ /* Disable the module and wait for the module to be disabled */
+ set32(CM_PER_TIMER7_CLKCTRL, CM_MODULEMODE_MASK,
+ CM_MODULEMODE_DISABLED);
+ while ((mmio_read(CM_PER_TIMER7_CLKCTRL) & CM_CLKCTRL_IDLEST)
+ != CM_CLKCTRL_IDLEST_DISABLE);
+
+ set32(CLKSEL_TIMER7_CLK, CLKSEL_TIMER7_CLK_SEL_MASK,
+ CLKSEL_TIMER7_CLK_SEL_SEL2);
+ while ((read32(CLKSEL_TIMER7_CLK) & CLKSEL_TIMER7_CLK_SEL_MASK)
+ != CLKSEL_TIMER7_CLK_SEL_SEL2);
+
+ /* enable the module and wait for the module to be ready */
+ set32(CM_PER_TIMER7_CLKCTRL, CM_MODULEMODE_MASK,
+ CM_MODULEMODE_ENABLE);
+ while ((mmio_read(CM_PER_TIMER7_CLKCTRL) & CM_CLKCTRL_IDLEST)
+ != CM_CLKCTRL_IDLEST_FUNC);
+
+ /* Stop timer */
+ mmio_clear(fr_timer->base + fr_timer->regs->TCLR,
+ OMAP3_TCLR_ST);
+#endif
+
+ /* Start and auto-reload at 0 */
+ mmio_write(fr_timer->base + fr_timer->regs->TLDR, 0x0);
+ mmio_write(fr_timer->base + fr_timer->regs->TCRR, 0x0);
+
+ /* Set up overflow interrupt */
+ tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
+ OMAP3_TISR_TCAR_IT_FLAG;
+ /* Clear interrupt status */
+ mmio_write(fr_timer->base + fr_timer->regs->TISR, tisr);
+ mmio_write(fr_timer->base + fr_timer->regs->TIER,
+ OMAP3_TIER_OVF_IT_ENA);
+
+ /* Start timer, without prescaler */
+ mmio_set(fr_timer->base + fr_timer->regs->TCLR,
+ OMAP3_TCLR_OVF_TRG | OMAP3_TCLR_AR | OMAP3_TCLR_ST);
+ done = 1;
+}
+
+static inline uint32_t
+read_frc(void)
+{
+ if (done == 0) {
+ return 0;
+ }
+ return mmio_read(fr_timer->base + fr_timer->regs->TCRR);
+}
+
+static uint32_t last_tick_nanoseconds;
+
+static void
+beagle_clock_initialize(void)
+{
+ uint32_t freq = 1000000UL/rtems_configuration_get_microseconds_per_tick();
+
+ /* we only support 1ms resolution */
+ uint32_t tisr;
+#if IS_DM3730
+ /* Stop timer */
+ mmio_clear(timer->base + timer->regs->TCLR, OMAP3_TCLR_ST);
+
+ /* Use 32 KHz clock source for GPTIMER1 */
+ mmio_clear(OMAP3_CM_CLKSEL_WKUP, OMAP3_CLKSEL_GPT1);
+#endif
+
+#if IS_AM335X
+ /* disable the module and wait for the module to be disabled */
+ set32(CM_WKUP_TIMER1_CLKCTRL, CM_MODULEMODE_MASK,
+ CM_MODULEMODE_DISABLED);
+ while ((mmio_read(CM_WKUP_TIMER1_CLKCTRL) & CM_CLKCTRL_IDLEST)
+ != CM_CLKCTRL_IDLEST_DISABLE);
+
+ set32(CLKSEL_TIMER1MS_CLK, CLKSEL_TIMER1MS_CLK_SEL_MASK,
+ CLKSEL_TIMER1MS_CLK_SEL_SEL2);
+ while ((read32(CLKSEL_TIMER1MS_CLK) &
+ CLKSEL_TIMER1MS_CLK_SEL_MASK) !=
+ CLKSEL_TIMER1MS_CLK_SEL_SEL2);
+
+ /* enable the module and wait for the module to be ready */
+ set32(CM_WKUP_TIMER1_CLKCTRL, CM_MODULEMODE_MASK,
+ CM_MODULEMODE_ENABLE);
+ while ((mmio_read(CM_WKUP_TIMER1_CLKCTRL) & CM_CLKCTRL_IDLEST)
+ != CM_CLKCTRL_IDLEST_FUNC);
+
+ /* Stop timer */
+ mmio_clear(timer->base + timer->regs->TCLR, OMAP3_TCLR_ST);
+#endif
+
+ /* Use 1-ms tick mode for GPTIMER1 TRM 16.2.4.2.1 */
+ mmio_write(timer->base + timer->regs->TPIR, 232000);
+ mmio_write(timer->base + timer->regs->TNIR, -768000);
+ mmio_write(timer->base + timer->regs->TLDR,
+ 0xffffffff - (32768 / freq) + 1);
+ mmio_write(timer->base + timer->regs->TCRR,
+ 0xffffffff - (32768 / freq) + 1);
+
+ /* Set up overflow interrupt */
+ tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
+ OMAP3_TISR_TCAR_IT_FLAG;
+ /* Clear interrupt status */
+ mmio_write(timer->base + timer->regs->TISR, tisr);
+ mmio_write(timer->base + timer->regs->TIER, OMAP3_TIER_OVF_IT_ENA);
+
+ /* Start timer */
+ mmio_set(timer->base + timer->regs->TCLR,
+ OMAP3_TCLR_OVF_TRG | OMAP3_TCLR_AR | OMAP3_TCLR_ST);
+ /* also initilize the free runnning timer */
+ omap3_frclock_init();
+}
+
+static void beagle_clock_at_tick(void)
+{
+ uint32_t tisr;
+
+ last_tick_nanoseconds = read_frc();
+
+ mmio_write(timer->base + timer->regs->TISR,
+ OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
+ OMAP3_TISR_TCAR_IT_FLAG);
+}
+
+static rtems_interrupt_handler clock_isr = NULL;
+
+static void beagle_clock_handler_install(rtems_interrupt_handler isr)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+ sc = rtems_interrupt_handler_install(
+ timer->irq_nr,
+ "Clock",
+ RTEMS_INTERRUPT_UNIQUE,
+ isr,
+ NULL
+ );
+
+ if (sc != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(0xdeadbeef);
+ }
+ clock_isr = isr;
+}
+
+static void beagle_clock_cleanup(void)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+ /* Disable timer */
+ mmio_clear(timer->base + timer->regs->TCLR, OMAP3_TCLR_ST);
+
+ /* Remove interrupt handler */
+ sc = rtems_interrupt_handler_remove(
+ timer->irq_nr,
+ clock_isr,
+ NULL
+ );
+ if (sc != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(0xdeadbeef);
+ }
+ clock_isr = NULL;
+
+ /* stop frclock */
+ mmio_clear(fr_timer->base + fr_timer->regs->TCLR, OMAP3_TCLR_ST);
+}
+
+static inline uint32_t beagle_clock_nanoseconds_since_last_tick(void)
+{
+ /* this arithmetic also works if read_frc() wraps around, as long
+ * as the subtraction wraps around too
+ */
+ return (read_frc() - (uint64_t) last_tick_nanoseconds) * 1000000000 / FRCLOCK_HZ;
+}
+
+#define Clock_driver_support_at_tick() beagle_clock_at_tick()
+#define Clock_driver_support_initialize_hardware() beagle_clock_initialize()
+#define Clock_driver_support_install_isr(isr, old_isr) \
+ do { \
+ beagle_clock_handler_install(isr); \
+ old_isr = NULL; \
+ } while (0)
+
+#define Clock_driver_support_shutdown_hardware() beagle_clock_cleanup()
+#define Clock_driver_nanoseconds_since_last_tick \
+ beagle_clock_nanoseconds_since_last_tick
+
+/* Include shared source clock driver code */
+#include "../../shared/clockdrv_shell.h"
+
+#endif /* ARM_MULTILIB_ARCH_V4 */
diff --git a/c/src/lib/libbsp/arm/beagle/clock/beagle-clock-config.c b/c/src/lib/libbsp/arm/beagle/clock/beagle-clock-config.c
deleted file mode 100644
index 66d8c2bb85..0000000000
--- a/c/src/lib/libbsp/arm/beagle/clock/beagle-clock-config.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle_clock
- *
- * @brief Clock driver configuration.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <rtems.h>
-
-#include <bsp/beagle-clock-config.h>
-#include <bsp/beagle-timer.h>
-
-#ifdef ARM_MULTILIB_ARCH_V4
-
-/* This is defined in ../../../shared/clockdrv_shell.h */
-void Clock_isr(rtems_irq_hdl_param arg);
-
-static volatile beagle_timer *const beagle_clock =
- (volatile beagle_timer *) BEAGLE_CLOCK_TIMER_BASE;
-
-static void beagle_clock_at_tick(void)
-{
- beagle_clock->ir = BEAGLE_TIMER_IR_MR0;
-}
-
-static void beagle_clock_handler_install(void)
-{
- rtems_status_code sc = RTEMS_SUCCESSFUL;
-
- sc = rtems_interrupt_handler_install(
- BEAGLE_CLOCK_INTERRUPT,
- "Clock",
- RTEMS_INTERRUPT_UNIQUE,
- (rtems_interrupt_handler) Clock_isr,
- NULL
- );
- if (sc != RTEMS_SUCCESSFUL) {
- rtems_fatal_error_occurred(0xdeadbeef);
- }
-}
-
-static void beagle_clock_initialize(void)
-{
- uint64_t interval = ((uint64_t) BEAGLE_CLOCK_REFERENCE
- * (uint64_t) rtems_configuration_get_microseconds_per_tick()) / 1000000;
-
- /* Enable module */
- BEAGLE_CLOCK_MODULE_ENABLE();
-
- /* Reset timer */
- beagle_clock->tcr = BEAGLE_TIMER_TCR_RST;
-
- /* Clear interrupt flags */
- beagle_clock->ir = BEAGLE_TIMER_IR_ALL;
-
- /* Set timer mode */
- beagle_clock->ccr = 0;
-
- /* Timer is incremented every PERIPH_CLK tick */
- beagle_clock->pr = 0;
-
- /* Set match registers */
- beagle_clock->mr0 = (uint32_t) interval;
-
- /* Generate interrupt and reset counter on match with MR0 */
- beagle_clock->mcr = BEAGLE_TIMER_MCR_MR0_INTR | BEAGLE_TIMER_MCR_MR0_RST;
-
- /* No external match */
- beagle_clock->emr = 0x0;
-
- /* Enable timer */
- beagle_clock->tcr = BEAGLE_TIMER_TCR_EN;
-}
-
-static void beagle_clock_cleanup(void)
-{
- rtems_status_code sc = RTEMS_SUCCESSFUL;
-
- /* Disable timer */
- beagle_clock->tcr = 0x0;
-
- /* Remove interrupt handler */
- sc = rtems_interrupt_handler_remove(
- BEAGLE_CLOCK_INTERRUPT,
- (rtems_interrupt_handler) Clock_isr,
- NULL
- );
- if (sc != RTEMS_SUCCESSFUL) {
- rtems_fatal_error_occurred(0xdeadbeef);
- }
-}
-
-static uint32_t beagle_clock_nanoseconds_since_last_tick(void)
-{
- uint64_t k = (1000000000ULL << 32) / BEAGLE_CLOCK_REFERENCE;
- uint64_t c = beagle_clock->tc;
-
- if ((beagle_clock->ir & BEAGLE_TIMER_IR_MR0) != 0) {
- c = beagle_clock->tc + beagle_clock->mr0;
- }
-
- return (uint32_t) ((c * k) >> 32);
-}
-
-#define Clock_driver_support_at_tick() beagle_clock_at_tick()
-#define Clock_driver_support_initialize_hardware() beagle_clock_initialize()
-#define Clock_driver_support_install_isr(isr, old_isr) \
- do { \
- beagle_clock_handler_install(); \
- old_isr = NULL; \
- } while (0)
-
-#define Clock_driver_support_shutdown_hardware() beagle_clock_cleanup()
-#define Clock_driver_nanoseconds_since_last_tick \
- beagle_clock_nanoseconds_since_last_tick
-
-/* Include shared source clock driver code */
-#include "../../../shared/clockdrv_shell.h"
-
-#endif /* ARM_MULTILIB_ARCH_V4 */
diff --git a/c/src/lib/libbsp/arm/beagle/configure.ac b/c/src/lib/libbsp/arm/beagle/configure.ac
index df27768b6d..a7e99eb589 100644
--- a/c/src/lib/libbsp/arm/beagle/configure.ac
+++ b/c/src/lib/libbsp/arm/beagle/configure.ac
@@ -18,78 +18,17 @@ RTEMS_PROG_CC_FOR_TARGET
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
-RTEMS_CHECK_NETWORKING
-AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
+RTEMS_BSPOPTS_SET([IS_DM3730],[beagleboard*],[1])
+RTEMS_BSPOPTS_HELP([IS_DM3730],[true if SOC is DM3730])
-RTEMS_BSPOPTS_SET([BSP_SMALL_MEMORY],[beagle_mzx_stage_1],[1])
-RTEMS_BSPOPTS_SET([BSP_SMALL_MEMORY],[*],[])
-RTEMS_BSPOPTS_HELP([BSP_SMALL_MEMORY],[disable testsuite samples with high memory demands])
+RTEMS_BSPOPTS_SET([IS_AM335X],[beaglebone*],[1])
+RTEMS_BSPOPTS_HELP([IS_AM335X],[true if SOC is AM335X])
-RTEMS_BSPOPTS_SET([BEAGLE_OSCILLATOR_MAIN],[*],[13000000U])
-RTEMS_BSPOPTS_HELP([BEAGLE_OSCILLATOR_MAIN],[main oscillator frequency in Hz])
+RTEMS_BSPOPTS_SET([CONSOLE_BAUD],[*],[115200])
+RTEMS_BSPOPTS_HELP([CONSOLE_BAUD],[initial baud for console UART])
-RTEMS_BSPOPTS_SET([BEAGLE_OSCILLATOR_RTC],[*],[32768U])
-RTEMS_BSPOPTS_HELP([BEAGLE_OSCILLATOR_RTC],[RTC oscillator frequency in Hz])
-
-RTEMS_BSPOPTS_SET([BEAGLE_PERIPH_CLK],[*],[13000000U])
-RTEMS_BSPOPTS_HELP([BEAGLE_PERIPH_CLK],[peripheral clock in Hz])
-
-RTEMS_BSPOPTS_SET([BEAGLE_ETHERNET_RMII],[*],[1])
-RTEMS_BSPOPTS_HELP([BEAGLE_ETHERNET_RMII],[enable RMII for Ethernet])
-
-RTEMS_BSPOPTS_SET([BEAGLE_UART_1_BAUD],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_UART_1_BAUD],[baud for UART 1])
-
-RTEMS_BSPOPTS_SET([BEAGLE_UART_2_BAUD],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_UART_2_BAUD],[baud for UART 2])
-
-RTEMS_BSPOPTS_SET([BEAGLE_UART_7_BAUD],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_UART_7_BAUD],[baud for UART 7])
-
-RTEMS_BSPOPTS_SET([BEAGLE_CONFIG_U3CLK],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_CONFIG_U3CLK],[clock configuration for UART 3])
-
-RTEMS_BSPOPTS_SET([BEAGLE_CONFIG_U4CLK],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_CONFIG_U4CLK],[clock configuration for UART 4])
-
-RTEMS_BSPOPTS_SET([BEAGLE_CONFIG_U5CLK],[*],[0x00001386U])
-RTEMS_BSPOPTS_HELP([BEAGLE_CONFIG_U5CLK],[clock configuration for UART 5])
-
-RTEMS_BSPOPTS_SET([BEAGLE_CONFIG_U6CLK],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_CONFIG_U6CLK],[clock configuration for UART 6])
-
-RTEMS_BSPOPTS_SET([BEAGLE_CONFIG_UART_CLKMODE],[*],[0x00000200U])
-RTEMS_BSPOPTS_HELP([BEAGLE_CONFIG_UART_CLKMODE],[clock mode configuration for UARTs])
-
-RTEMS_BSPOPTS_SET([BEAGLE_DISABLE_MMU],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_DISABLE_MMU],[disable MMU])
-
-RTEMS_BSPOPTS_SET([BEAGLE_DISABLE_READ_WRITE_DATA_CACHE],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_DISABLE_READ_WRITE_DATA_CACHE],[disable cache for read-write data sections])
-
-RTEMS_BSPOPTS_SET([BEAGLE_DISABLE_READ_ONLY_PROTECTION],[*],[])
-RTEMS_BSPOPTS_HELP([BEAGLE_DISABLE_READ_ONLY_PROTECTION],[disable MMU protection of read-only sections])
-
-RTEMS_BSPOPTS_SET([BEAGLE_SCRATCH_AREA_SIZE],[beagle_mzx*],[4096])
-RTEMS_BSPOPTS_HELP([BEAGLE_SCRATCH_AREA_SIZE],[size of scratch area])
-
-RTEMS_BSPOPTS_SET([BEAGLE_STOP_GPDMA],[*],[1])
-RTEMS_BSPOPTS_HELP([BEAGLE_STOP_GPDMA],[stop general purpose DMA at start-up to avoid DMA interference])
-
-RTEMS_BSPOPTS_SET([BEAGLE_STOP_ETHERNET],[*],[1])
-RTEMS_BSPOPTS_HELP([BEAGLE_STOP_ETHERNET],[stop Ethernet controller at start-up to avoid DMA interference])
-
-RTEMS_BSPOPTS_SET([BEAGLE_STOP_USB],[*],[1])
-RTEMS_BSPOPTS_HELP([BEAGLE_STOP_USB],[stop USB controller at start-up to avoid DMA interference])
-
-RTEMS_BSPOPTS_SET([BEAGLE_ENABLE_WATCHDOG_RESET],[*],[1])
-RTEMS_BSPOPTS_HELP([BEAGLE_ENABLE_WATCHDOG_RESET],[bsp_reset() will use the watchdog to reset the chip])
-
-RTEMS_BSPOPTS_SET([BSP_START_RESET_VECTOR],[*],[])
-RTEMS_BSPOPTS_HELP([BSP_START_RESET_VECTOR],[reset vector address for BSP start])
-
-RTEMS_BSPOPTS_SET([TESTS_USE_PRINTK],[*],[1])
-RTEMS_BSPOPTS_HELP([TESTS_USE_PRINTK],[tests use printk() for output])
+RTEMS_BSPOPTS_SET([CONSOLE_POLLED],[*],[0])
+RTEMS_BSPOPTS_HELP([CONSOLE_POLLED],[polled console i/o (e.g. to run testsuite)])
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
RTEMS_BSP_LINKCMDS
diff --git a/c/src/lib/libbsp/arm/beagle/console/console-config.c b/c/src/lib/libbsp/arm/beagle/console/console-config.c
index a9349e8425..63c7ba7feb 100644
--- a/c/src/lib/libbsp/arm/beagle/console/console-config.c
+++ b/c/src/lib/libbsp/arm/beagle/console/console-config.c
@@ -1,7 +1,7 @@
/**
* @file
*
- * @ingroup beagle
+ * @ingroup arm_beagle
*
* @brief Console configuration.
*/
@@ -18,209 +18,120 @@
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
+ *
+ * Modified by Ben Gras <beng@shrike-systems.com> to make
+ * interrupt-driven uart i/o work for beagleboards; beaglebone support added.
*/
#include <libchip/serial.h>
#include <libchip/ns16550.h>
#include <bsp.h>
-#include <bsp/beagle.h>
#include <bsp/irq.h>
+#include <bsp/uart-output-char.h>
+
+#define CONSOLE_UART_THR (*(volatile unsigned int *)BSP_CONSOLE_UART_BASE)
+#define CONSOLE_UART_RHR (*(volatile unsigned int *)BSP_CONSOLE_UART_BASE)
+#define CONSOLE_UART_LSR (*(volatile unsigned int *)(BSP_CONSOLE_UART_BASE+0x14))
+#define CONSOLE_SYSC (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x54))
+#define CONSOLE_SYSS (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x58))
-#define UART3_THR (*(volatile unsigned int *)0x49020000)
-#define UART3_RHR (*(volatile unsigned int *)0x49020000)
-#define UART3_LSR (*(volatile unsigned int *)0x49020014)
#define TX_FIFO_E (1<<5)
#define RX_FIFO_E (1<<0)
-static uint8_t beagle_uart_get_register(uint32_t addr, uint8_t i)
+static uint8_t beagle_uart_get_register(uintptr_t addr, uint8_t i)
{
- volatile uint32_t *reg = (volatile uint32_t *) addr;
+ uint8_t v;
+ volatile uint32_t *reg_r = (volatile uint32_t *) addr + i;
+
+ if(reg_r == (uint32_t*) BSP_CONSOLE_UART_BASE /* reading RHR */ ) {
+ /* check there should be anything in the RHR before accessing it */
+ if(!(CONSOLE_UART_LSR & 0x01)) {
+ return 0;
+ }
+ }
- return (uint8_t) reg [i];
+ v = (uint8_t) *reg_r;
+
+ return v;
}
-static void beagle_uart_set_register(uint32_t addr, uint8_t i, uint8_t val)
+static void beagle_uart_set_register(uintptr_t addr, uint8_t i, uint8_t val)
{
volatile uint32_t *reg = (volatile uint32_t *) addr;
reg [i] = val;
}
-/* FIXME: Console selection */
-
console_tbl Console_Configuration_Ports [] = {
- #ifdef BEAGLE_CONFIG_U5CLK
{
- .sDeviceName = "/dev/ttyS5",
+ .sDeviceName = "/dev/ttyS0",
.deviceType = SERIAL_NS16550,
+#if CONSOLE_POLLED /* option to facilitate running the tests */
.pDeviceFns = &ns16550_fns_polled,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) 1,
- .ulCtrlPort1 = BEAGLE_BASE_UART_5,
- .ulCtrlPort2 = 0,
- .ulDataPort = BEAGLE_BASE_UART_5,
- .getRegister = beagle_uart_get_register,
- .setRegister = beagle_uart_set_register,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_5
- },
- #endif
- #ifdef BEAGLE_CONFIG_U3CLK
- {
- .sDeviceName = "/dev/ttyS3",
- .deviceType = SERIAL_NS16550,
- .pDeviceFns = &ns16550_fns,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) 1,
- .ulCtrlPort1 = BEAGLE_BASE_UART_3,
- .ulCtrlPort2 = 0,
- .ulDataPort = BEAGLE_BASE_UART_3,
- .getRegister = beagle_uart_get_register,
- .setRegister = beagle_uart_set_register,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_3
- },
- #endif
- #ifdef BEAGLE_CONFIG_U4CLK
- {
- .sDeviceName = "/dev/ttyS4",
- .deviceType = SERIAL_NS16550,
+#else
.pDeviceFns = &ns16550_fns,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
+#endif
.ulMargin = 16,
.ulHysteresis = 8,
- .pDeviceParams = (void *) 1,
- .ulCtrlPort1 = BEAGLE_BASE_UART_4,
- .ulCtrlPort2 = 0,
- .ulDataPort = BEAGLE_BASE_UART_4,
+ .pDeviceParams = (void *) CONSOLE_BAUD,
+ .ulCtrlPort1 = BSP_CONSOLE_UART_BASE,
+ .ulDataPort = BSP_CONSOLE_UART_BASE,
+ .ulIntVector = BSP_CONSOLE_UART_IRQ,
.getRegister = beagle_uart_get_register,
.setRegister = beagle_uart_set_register,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_4
+ .ulClock = UART_CLOCK, /* 48MHz base clock */
},
- #endif
- #ifdef BEAGLE_CONFIG_U6CLK
- {
- .sDeviceName = "/dev/ttyS6",
- .deviceType = SERIAL_NS16550,
- .pDeviceFns = &ns16550_fns,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) 1,
- .ulCtrlPort1 = BEAGLE_BASE_UART_6,
- .ulCtrlPort2 = 0,
- .ulDataPort = BEAGLE_BASE_UART_6,
- .getRegister = beagle_uart_get_register,
- .setRegister = beagle_uart_set_register,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_6
- },
- #endif
- #ifdef BEAGLE_UART_1_BAUD
- {
- .sDeviceName = "/dev/ttyS1",
- .deviceType = SERIAL_CUSTOM,
- .pDeviceFns = &ns16550_fns,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) BEAGLE_UART_1_BAUD,
- .ulCtrlPort1 = BEAGLE_BASE_UART_1,
- .ulCtrlPort2 = 0,
- .ulDataPort = 0,
- .getRegister = NULL,
- .setRegister = NULL,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_1
- },
- #endif
- #ifdef BEAGLE_UART_2_BAUD
- {
- .sDeviceName = "/dev/ttyS2",
- .deviceType = SERIAL_CUSTOM,
- .pDeviceFns = &ns16550_fns,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) BEAGLE_UART_2_BAUD,
- .ulCtrlPort1 = BEAGLE_BASE_UART_2,
- .ulCtrlPort2 = 0,
- .ulDataPort = 0,
- .getRegister = NULL,
- .setRegister = NULL,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_2
- },
- #endif
- #ifdef BEAGLE_UART_7_BAUD
- {
- .sDeviceName = "/dev/ttyS7",
- .deviceType = SERIAL_CUSTOM,
- .pDeviceFns = &ns16550_fns,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) BEAGLE_UART_7_BAUD,
- .ulCtrlPort1 = BEAGLE_BASE_UART_7,
- .ulCtrlPort2 = 0,
- .ulDataPort = 0,
- .getRegister = NULL,
- .setRegister = NULL,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 16,
- .ulIntVector = BEAGLE_IRQ_UART_7
- },
- #endif
};
-#define BEAGLE_UART_COUNT \
- (sizeof(Console_Configuration_Ports) / \
- sizeof(Console_Configuration_Ports [0]))
+unsigned long Console_Configuration_Count = 1;
-unsigned long Console_Configuration_Count = BEAGLE_UART_COUNT;
+static int init_needed = 1; // don't rely on bss being 0
-static void uart_write_polled( char c ) {
- // wait until TX-Buffer is empty
- while( ( UART3_LSR & TX_FIFO_E ) == 0 )
- ;
-
- // send character
- UART3_THR = c;
- return c;
+static void beagle_console_init(void)
+{
+ if(init_needed) {
+ const uint32_t div = UART_CLOCK / 16 / CONSOLE_BAUD;
+ CONSOLE_SYSC = 2;
+ while ((CONSOLE_SYSS & 1) == 0)
+ ;
+ if ((CONSOLE_LSR & (CONSOLE_LSR_THRE | CONSOLE_LSR_TEMT)) == CONSOLE_LSR_THRE) {
+ CONSOLE_LCR = 0x83;
+ CONSOLE_DLL = div;
+ CONSOLE_DLM = (div >> 8) & 0xff;
+ CONSOLE_LCR = 0x03;
+ CONSOLE_ACR = 0x00;
+ }
+
+ while ((CONSOLE_LSR & CONSOLE_LSR_TEMT) == 0)
+ ;
+
+ CONSOLE_LCR = 0x80 | 0x03;
+ CONSOLE_DLL = 0x00;
+ CONSOLE_DLM = 0x00;
+ CONSOLE_LCR = 0x03;
+ CONSOLE_MCR = 0x03;
+ CONSOLE_FCR = 0x07;
+ CONSOLE_LCR = 0x83;
+ CONSOLE_DLL = div;
+ CONSOLE_DLM = (div >> 8) & 0xff;
+ CONSOLE_LCR = 0x03;
+ CONSOLE_ACR = 0x00;
+ init_needed = 0;
+ }
}
+#define CONSOLE_THR8 (*(volatile uint8_t *) (BSP_CONSOLE_UART_BASE + 0x00))
+
+static void uart_write_polled( char c )
+{
+ if(init_needed) beagle_console_init();
+
+ while( ( CONSOLE_LSR & TX_FIFO_E ) == 0 )
+ ;
+ CONSOLE_THR8 = c;
+}
-/*
-* Write a character to the console. This is used by printk() and
-* maybe other low level functions. It should not use interrupts or any
-* RTEMS system calls. It needs to be very simple
-*/
static void _BSP_put_char( char c ) {
uart_write_polled( c );
if (c == '\n') {
@@ -228,4 +139,15 @@ static void _BSP_put_char( char c ) {
}
}
+static int _BSP_get_char(void)
+{
+ if ((CONSOLE_LSR & CONSOLE_LSR_RDR) != 0) {
+ return CONSOLE_RBR;
+ } else {
+ return -1;
+ }
+}
+
BSP_output_char_function_type BSP_output_char = _BSP_put_char;
+
+BSP_polling_getchar_function_type BSP_poll_char = _BSP_get_char;
diff --git a/c/src/lib/libbsp/arm/beagle/include/beagle-clock-config.h b/c/src/lib/libbsp/arm/beagle/include/beagle-clock-config.h
deleted file mode 100644
index 18a1d86f75..0000000000
--- a/c/src/lib/libbsp/arm/beagle/include/beagle-clock-config.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle_clock
- *
- * @brief Clock driver configuration.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef LIBBSP_ARM_BEAGLE_BEAGLE_CLOCK_CONFIG_H
-#define LIBBSP_ARM_BEAGLE_BEAGLE_CLOCK_CONFIG_H
-
-#include <bsp.h>
-#include <bsp/irq.h>
-#include <bsp/beagle.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @defgroup beagle_clock Clock Support
- *
- * @ingroup beagle
- *
- * @brief Clock support.
- *
- * @{
- */
-
-#define BEAGLE_CLOCK_INTERRUPT BEAGLE_IRQ_TIMER_0
-
-#define BEAGLE_CLOCK_TIMER_BASE BEAGLE_BASE_TIMER_0
-
-#define BEAGLE_CLOCK_REFERENCE BEAGLE_PERIPH_CLK
-
-#define BEAGLE_CLOCK_MODULE_ENABLE()
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* LIBBSP_ARM_BEAGLE_BEAGLE_CLOCK_CONFIG_H */
diff --git a/c/src/lib/libbsp/arm/beagle/include/beagle-timer.h b/c/src/lib/libbsp/arm/beagle/include/beagle-timer.h
deleted file mode 100644
index d053160b0d..0000000000
--- a/c/src/lib/libbsp/arm/beagle/include/beagle-timer.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle_timer
- *
- * @brief Timer API.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef LIBBSP_ARM_SHARED_BEAGLE_TIMER_H
-#define LIBBSP_ARM_SHARED_BEAGLE_TIMER_H
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup beagle_timer Timer Support
- *
- * @ingroup beagle
- *
- * @brief Timer support.
- *
- * @{
- */
-
-/**
- * @name Interrupt Register Defines
- *
- * @{
- */
-
-#define BEAGLE_TIMER_IR_MR0 0x1U
-#define BEAGLE_TIMER_IR_MR1 0x2U
-#define BEAGLE_TIMER_IR_MR2 0x4U
-#define BEAGLE_TIMER_IR_MR3 0x8U
-#define BEAGLE_TIMER_IR_CR0 0x10U
-#define BEAGLE_TIMER_IR_CR1 0x20U
-#define BEAGLE_TIMER_IR_CR2 0x40U
-#define BEAGLE_TIMER_IR_CR3 0x80U
-#define BEAGLE_TIMER_IR_ALL 0xffU
-
-/** @} */
-
-/**
- * @name Timer Control Register Defines
- *
- * @{
- */
-
-#define BEAGLE_TIMER_TCR_EN 0x1U
-#define BEAGLE_TIMER_TCR_RST 0x2U
-
-/** @} */
-
-/**
- * @name Match Control Register Defines
- *
- * @{
- */
-
-#define BEAGLE_TIMER_MCR_MR0_INTR 0x1U
-#define BEAGLE_TIMER_MCR_MR0_RST 0x2U
-#define BEAGLE_TIMER_MCR_MR0_STOP 0x4U
-#define BEAGLE_TIMER_MCR_MR1_INTR 0x8U
-#define BEAGLE_TIMER_MCR_MR1_RST 0x10U
-#define BEAGLE_TIMER_MCR_MR1_STOP 0x20U
-#define BEAGLE_TIMER_MCR_MR2_INTR 0x40U
-#define BEAGLE_TIMER_MCR_MR2_RST 0x80U
-#define BEAGLE_TIMER_MCR_MR2_STOP 0x100U
-#define BEAGLE_TIMER_MCR_MR3_INTR 0x200U
-#define BEAGLE_TIMER_MCR_MR3_RST 0x400U
-#define BEAGLE_TIMER_MCR_MR3_STOP 0x800U
-
-/** @} */
-
-/**
- * @name Capture Control Register Defines
- *
- * @{
- */
-
-#define BEAGLE_TIMER_CCR_CAP0_RE 0x1U
-#define BEAGLE_TIMER_CCR_CAP0_FE 0x2U
-#define BEAGLE_TIMER_CCR_CAP0_INTR 0x4U
-#define BEAGLE_TIMER_CCR_CAP1_RE 0x8U
-#define BEAGLE_TIMER_CCR_CAP1_FE 0x10U
-#define BEAGLE_TIMER_CCR_CAP1_INTR 0x20U
-#define BEAGLE_TIMER_CCR_CAP2_RE 0x40U
-#define BEAGLE_TIMER_CCR_CAP2_FE 0x80U
-#define BEAGLE_TIMER_CCR_CAP2_INTR 0x100U
-#define BEAGLE_TIMER_CCR_CAP3_RE 0x200U
-#define BEAGLE_TIMER_CCR_CAP3_FE 0x400U
-#define BEAGLE_TIMER_CCR_CAP3_INTR 0x800U
-
-/** @} */
-
-/**
- * @name External Match Register Defines
- *
- * @{
- */
-
-#define BEAGLE_TIMER_EMR_EM0_RE 0x1U
-#define BEAGLE_TIMER_EMR_EM1_FE 0x2U
-#define BEAGLE_TIMER_EMR_EM2_INTR 0x4U
-#define BEAGLE_TIMER_EMR_EM3_RE 0x8U
-#define BEAGLE_TIMER_EMR_EMC0_FE 0x10U
-#define BEAGLE_TIMER_EMR_EMC1_INTR 0x20U
-#define BEAGLE_TIMER_EMR_EMC2_RE 0x40U
-#define BEAGLE_TIMER_EMR_EMC3_FE 0x80U
-
-/** @} */
-
-/**
- * @brief Timer control block.
- */
-typedef struct {
- uint32_t ir;
- uint32_t tcr;
- uint32_t tc;
- uint32_t pr;
- uint32_t pc;
- uint32_t mcr;
- uint32_t mr0;
- uint32_t mr1;
- uint32_t mr2;
- uint32_t mr3;
- uint32_t ccr;
- uint32_t cr0;
- uint32_t cr1;
- uint32_t cr2;
- uint32_t cr3;
- uint32_t emr;
- uint32_t ctcr;
-} beagle_timer;
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* LIBBSP_ARM_SHARED_BEAGLE_TIMER_H */
diff --git a/c/src/lib/libbsp/arm/beagle/include/beagle.h b/c/src/lib/libbsp/arm/beagle/include/beagle.h
deleted file mode 100644
index fb12211ccb..0000000000
--- a/c/src/lib/libbsp/arm/beagle/include/beagle.h
+++ /dev/null
@@ -1,760 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle_reg
- *
- * @brief Register base addresses.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef LIBBSP_ARM_BEAGLE_BEAGLE_H
-#define LIBBSP_ARM_BEAGLE_BEAGLE_H
-
-#include <stdint.h>
-
-#include <bsp/beagle-timer.h>
-
-#define __arch_getb(a) (*(volatile unsigned char *)(a))
-#define __arch_getw(a) (*(volatile unsigned short *)(a))
-#define __arch_getl(a) (*(volatile unsigned int *)(a))
-
-#define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v))
-#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
-#define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v))
-/*
- * TODO: do we need a barrier here?
- */
-
-#define writeb(v,c) ({ unsigned char __v = v; __arch_putb(__v,c); __v; })
-#define writew(v,c) ({ unsigned short __v = v; __arch_putw(__v,c); __v; })
-#define writel(v,c) ({ unsigned int __v = v; __arch_putl(__v,c); __v; })
-
-#define readb(c) ({ unsigned char __v = __arch_getb(c); __v; })
-#define readw(c) ({ unsigned short __v = __arch_getw(c); __v; })
-#define readl(c) ({ unsigned int __v = __arch_getl(c); __v; })
-
-#define SYSTEM_CLOCK_12 12000000
-#define SYSTEM_CLOCK_13 13000000
-#define SYSTEM_CLOCK_192 19200000
-#define SYSTEM_CLOCK_96 96000000
-
-#define OMAP34XX_CORE_L4_IO_BASE 0x48000000
-
-#define BEAGLE_BASE_UART_1 0x4806A000
-#define BEAGLE_BASE_UART_2 0x4806C000
-#define BEAGLE_BASE_UART_3 0x49020000
-#define BEAGLE_BASE_UART_4 0x49020000
-#define BEAGLE_BASE_UART_5 0x49020000
-#define BEAGLE_BASE_UART_5 0x49020000
-#define BEAGLE_BASE_UART_6 0x49020000
-#define BEAGLE_BASE_UART_7 0x49020000
-
-#define BEAGLE_UART_DLL_REG_OFFSET 0x000
-#define BEAGLE_UART_RHR_REG_OFFSET 0x000
-#define BEAGLE_UART_THR_REG_OFFSET 0x000
-#define BEAGLE_UART_DLH_REG_OFFSET 0x004
-#define BEAGLE_UART_IER_REG_OFFSET 0x004
-#define BEAGLE_UART_IIR_REG_OFFSET 0x008
-#define BEAGLE_UART_FCR_REG_OFFSET 0x008
-#define BEAGLE_UART_EFR_REG_OFFSET 0x008
-#define BEAGLE_UART_LCR_REG_OFFSET 0x00C
-#define BEAGLE_UART_MCR_REG_OFFSET 0x010
-#define BEAGLE_UART_XON1_ADDR1_REG_OFFSET 0x010
-#define BEAGLE_UART_LSR_REG_OFFSET 0x014
-#define BEAGLE_UART_XON2_ADDR2_REG_OFFSET 0x014
-#define BEAGLE_UART_MSR_REG_OFFSET 0x018
-#define BEAGLE_UART_TCR_REG_OFFSET 0x018
-#define BEAGLE_UART_XOFF1_REG_OFFSET 0x018
-#define BEAGLE_UART_SPR_REG_OFFSET 0x01C
-#define BEAGLE_UART_TLR_REG_OFFSET 0x01C
-#define BEAGLE_UART_XOFF2_REG_OFFSET 0x01C
-#define BEAGLE_UART_MDR1_REG_OFFSET 0x020
-#define BEAGLE_UART_MDR2_REG_OFFSET 0x024
-#define BEAGLE_UART_SFLSR_REG_OFFSET 0x028
-#define BEAGLE_UART_TXFLL_REG_OFFSET 0x028
-#define BEAGLE_UART_RESUME_REG_OFFSET 0x02C
-#define BEAGLE_UART_TXFLH_REG_OFFSET 0x02C
-#define BEAGLE_UART_SFREGL_REG_OFFSET 0x030
-#define BEAGLE_UART_RXFLL_REG_OFFSET 0x030
-#define BEAGLE_UART_SFREGH_REG_OFFSET 0x034
-#define BEAGLE_UART_RXFLH_REG_OFFSET 0x034
-#define BEAGLE_UART_UASR_REG_OFFSET 0x038
-#define BEAGLE_UART_BLR_REG_OFFSET 0x038
-#define BEAGLE_UART_ACREG_REG_OFFSET 0x03C
-#define BEAGLE_UART_SCR_REG_OFFSET 0x040
-#define BEAGLE_UART_SSR_REG_OFFSET 0x044
-#define BEAGLE_UART_EBLR_REG_OFFSET 0x048
-#define BEAGLE_UART_MVR_REG_OFFSET 0x050
-#define BEAGLE_UART_SYSC_REG_OFFSET 0x054
-#define BEAGLE_UART_SYSS_REG_OFFSET 0x058
-#define BEAGLE_UART_WER_REG_OFFSET 0x05C
-#define BEAGLE_UART_CFPS_REG_OFFSET 0x060
-
-#define BEAGLE_UART5_DLL = BAGLE_BASE_UART5 + BEAGLE_UART_DLL_REG_OFFSET
-#define BEAGLE_UART5_RHR = BAGLE_BASE_UART5 + \
- BEAGLE_UART_BEAGLE_UART_RHR_REG_OFFSET
-#define BEAGLE_UART5_THR = BAGLE_BASE_UART5 + BEAGLE_UART_THR_REG_OFFSET
-#define BEAGLE_UART5_DLH = BAGLE_BASE_UART5 + BEAGLE_UART_DLH_REG_OFFSET
-#define BEAGLE_UART5_IER = BAGLE_BASE_UART5 + BEAGLE_UART_IER_REG_OFFSET
-#define BEAGLE_UART5_IIR = BAGLE_BASE_UART5 + BEAGLE_UART_IIR_REG_OFFSET
-#define BEAGLE_UART5_FCR = BAGLE_BASE_UART5 + BEAGLE_UART_FCR_REG_OFFSET
-#define BEAGLE_UART5_EFR = BAGLE_BASE_UART5 + BEAGLE_UART_EFR_REG_OFFSET
-#define BEAGLE_UART5_LCR = BAGLE_BASE_UART5 + BEAGLE_UART_LCR_REG_OFFSET
-#define BEAGLE_UART5_MCR = BAGLE_BASE_UART5 + BEAGLE_UART_MCR_REG_OFFSET
-#define BEAGLE_UART5_XON1_ADDR1 = BAGLE_BASE_UART5 + \
- BEAGLE_UART_XON1_ADDR1_REG_OFFSET
-#define BEAGLE_UART5_LSR = BAGLE_BASE_UART5 + BEAGLE_UART_LSR_REG_OFFSET
-#define BEAGLE_UART5_XON2_ADDR2 = BAGLE_BASE_UART5 + \
- BEAGLE_UART_XON2_ADDR2_REG_OFFSET
-#define BEAGLE_UART5_MSR = BAGLE_BASE_UART5 + BEAGLE_UART_MSR_REG_OFFSET
-#define BEAGLE_UART5_TCR = BAGLE_BASE_UART5 + BEAGLE_UART_TCR_REG_OFFSET
-#define BEAGLE_UART5_XOFF1 = BAGLE_BASE_UART5 + BEAGLE_UART_XOFF1_REG_OFFSET
-#define BEAGLE_UART5_SPR = BAGLE_BASE_UART5 + BEAGLE_UART_SPR_REG_OFFSET
-#define BEAGLE_UART5_TLR = BAGLE_BASE_UART5 + BEAGLE_UART_TLR_REG_OFFSET
-#define BEAGLE_UART5_XOFF2 = BAGLE_BASE_UART5 + BEAGLE_UART_XOFF2_REG_OFFSET
-#define BEAGLE_UART5_MDR1 = BAGLE_BASE_UART5 + BEAGLE_UART_MDR1_REG_OFFSET
-#define BEAGLE_UART5_MDR2 = BAGLE_BASE_UART5 + BEAGLE_UART_MDR2_REG_OFFSET
-#define BEAGLE_UART5_SFLSR = BAGLE_BASE_UART5 + BEAGLE_UART_SFLSR_REG_OFFSET
-#define BEAGLE_UART5_TXFLL = BAGLE_BASE_UART5 + BEAGLE_UART_TXFLL_REG_OFFSET
-#define BEAGLE_UART5_RESUME = BAGLE_BASE_UART5 + BEAGLE_UART_RESUME_REG_OFFSET
-#define BEAGLE_UART5_TXFLH = BAGLE_BASE_UART5 + BEAGLE_UART_TXFLH_REG_OFFSET
-#define BEAGLE_UART5_SFREGL = BAGLE_BASE_UART5 + BEAGLE_UART_SFREGL_REG_OFFSET
-#define BEAGLE_UART5_RXFLL = BAGLE_BASE_UART5 + BEAGLE_UART_RXFLL_REG_OFFSET
-#define BEAGLE_UART5_SFREGH = BAGLE_BASE_UART5 + BEAGLE_UART_SFREGH_REG_OFFSET
-#define BEAGLE_UART5_RXFLH = BAGLE_BASE_UART5 + BEAGLE_UART_RXFLH_REG_OFFSET
-#define BEAGLE_UART5_UASR = BAGLE_BASE_UART5 + BEAGLE_UART_UASR_REG_OFFSET
-#define BEAGLE_UART5_BLR = BAGLE_BASE_UART5 + BEAGLE_UART_BLR_REG_OFFSET
-#define BEAGLE_UART5_ACREG = BAGLE_BASE_UART5 + BEAGLE_UART_ACREG_REG_OFFSET
-#define BEAGLE_UART5_SCR = BAGLE_BASE_UART5 + BEAGLE_UART_SCR_REG_OFFSET
-#define BEAGLE_UART5_SSR = BAGLE_BASE_UART5 + BEAGLE_UART_SSR_REG_OFFSET
-#define BEAGLE_UART5_EBLR = BAGLE_BASE_UART5 + BEAGLE_UART_EBLR_REG_OFFSET
-#define BEAGLE_UART5_MVR = BAGLE_BASE_UART5 + BEAGLE_UART_MVR_REG_OFFSET
-#define BEAGLE_UART5_SYSC = BAGLE_BASE_UART5 + BEAGLE_UART_SYSC_REG_OFFSET
-#define BEAGLE_UART5_SYSS = BAGLE_BASE_UART5 + BEAGLE_UART_SYSS_REG_OFFSET
-#define BEAGLE_UART5_WER = BAGLE_BASE_UART5 + BEAGLE_UART_WER_REG_OFFSET
-#define BEAGLE_UART5_CFPS = BAGLE_BASE_UART5 + BEAGLE_UART_CFPS_REG_OFFSET
-
-/**
- * @defgroup beagle_reg Register Definitions
- *
- * @ingroup beagle
- *
- * @brief Register definitions.
- *
- * @{
- */
-
-/**
- * @name Register Base Addresses
- *
- * @{
- */
-
-#define BEAGLE_BASE_ADC 0x40048000
-#define BEAGLE_BASE_SYSCON 0x40004000
-#define BEAGLE_BASE_DEBUG_CTRL 0x40040000
-#define BEAGLE_BASE_DMA 0x31000000
-#define BEAGLE_BASE_EMC 0x31080000
-#define BEAGLE_BASE_EMC_CS_0 0xe0000000
-#define BEAGLE_BASE_EMC_CS_1 0xe1000000
-#define BEAGLE_BASE_EMC_CS_2 0xe2000000
-#define BEAGLE_BASE_EMC_CS_3 0xe3000000
-#define BEAGLE_BASE_EMC_DYCS_0 0x80000000
-#define BEAGLE_BASE_EMC_DYCS_1 0xa0000000
-#define BEAGLE_BASE_ETB_CFG 0x310c0000
-#define BEAGLE_BASE_ETB_DATA 0x310e0000
-#define BEAGLE_BASE_ETHERNET 0x31060000
-#define BEAGLE_BASE_GPIO 0x40028000
-#define BEAGLE_BASE_I2C_1 0x400a0000
-#define BEAGLE_BASE_I2C_2 0x400a8000
-#define BEAGLE_BASE_I2S_0 0x20094000
-#define BEAGLE_BASE_I2S_1 0x2009c000
-#define BEAGLE_BASE_IRAM 0x08000000
-#define BEAGLE_BASE_IROM 0x0c000000
-#define BEAGLE_BASE_KEYSCAN 0x40050000
-#define BEAGLE_BASE_LCD 0x31040000
-#define BEAGLE_BASE_MCPWM 0x400e8000
-#define BEAGLE_BASE_MIC 0x40008000
-#define BEAGLE_BASE_NAND_MLC 0x200a8000
-#define BEAGLE_BASE_NAND_SLC 0x20020000
-#define BEAGLE_BASE_PWM_1 0x4005c000
-#define BEAGLE_BASE_PWM_2 0x4005c004
-#define BEAGLE_BASE_PWM_3 0x4002c000
-#define BEAGLE_BASE_PWM_4 0x40030000
-#define BEAGLE_BASE_RTC 0x40024000
-#define BEAGLE_BASE_RTC_RAM 0x40024080
-#define BEAGLE_BASE_SDCARD 0x20098000
-#define BEAGLE_BASE_SIC_1 0x4000c000
-#define BEAGLE_BASE_SIC_2 0x40010000
-#define BEAGLE_BASE_SPI_1 0x20088000
-#define BEAGLE_BASE_SPI_2 0x20090000
-#define BEAGLE_BASE_SSP_0 0x20084000
-#define BEAGLE_BASE_SSP_1 0x2008c000
-#define BEAGLE_BASE_TIMER_0 0x40044000
-#define BEAGLE_BASE_TIMER_1 0x4004c000
-#define BEAGLE_BASE_TIMER_2 0x40058000
-#define BEAGLE_BASE_TIMER_3 0x40060000
-#define BEAGLE_BASE_TIMER_5 0x4002c000
-#define BEAGLE_BASE_TIMER_6 0x40030000
-#define BEAGLE_BASE_TIMER_HS 0x40038000
-#define BEAGLE_BASE_TIMER_MS 0x40034000
-
-//#define BEAGLE_BASE_UART_1 0x40014000
-//#define BEAGLE_BASE_UART_2 0x40018000
-//#define BEAGLE_BASE_UART_3 0x40080000
-//#define BEAGLE_BASE_UART_4 0x40088000
-//#define BEAGLE_BASE_UART_5 0x40090000
-//#define BEAGLE_BASE_UART_5 0x49020000
-//#define BEAGLE_BASE_UART_6 0x40098000
-//#define BEAGLE_BASE_UART_7 0x4001c000
-
-#define BEAGLE_BASE_USB 0x31020000
-#define BEAGLE_BASE_USB_OTG_I2C 0x31020300
-#define BEAGLE_BASE_WDT 0x4003c000
-
-/** @} */
-
-/**
- * @name Miscanellanous Registers
- *
- * @{
- */
-
-#define BEAGLE_U3CLK (*(volatile uint32_t *) 0x400040d0)
-#define BEAGLE_U4CLK (*(volatile uint32_t *) 0x400040d4)
-#define BEAGLE_U5CLK (*(volatile uint32_t *) 0x400040d8)
-#define BEAGLE_U6CLK (*(volatile uint32_t *) 0x400040dc)
-#define BEAGLE_IRDACLK (*(volatile uint32_t *) 0x400040e0)
-#define BEAGLE_UART_CTRL (*(volatile uint32_t *) 0x40054000)
-#define BEAGLE_UART_CLKMODE (*(volatile uint32_t *) 0x40054004)
-#define BEAGLE_UART_LOOP (*(volatile uint32_t *) 0x40054008)
-
-#define BEAGLE_SW_INT (*(volatile uint32_t *) 0x400040a8)
-#define BEAGLE_MAC_CLK_CTRL (*(volatile uint32_t *) 0x40004090)
-#define BEAGLE_USB_DIV (*(volatile uint32_t *) 0x4000401c)
-#define BEAGLE_OTG_CLK_CTRL (*(volatile uint32_t *) 0x31020ff4)
-#define BEAGLE_OTG_CLK_STAT (*(volatile uint32_t *) 0x31020ff8)
-#define BEAGLE_OTG_STAT_CTRL (*(volatile uint32_t *) 0x31020110)
-#define BEAGLE_I2C_RX (*(volatile uint32_t *) 0x31020300)
-#define BEAGLE_I2C_TX (*(volatile uint32_t *) 0x31020300)
-#define BEAGLE_I2C_STS (*(volatile uint32_t *) 0x31020304)
-#define BEAGLE_I2C_CTL (*(volatile uint32_t *) 0x31020308)
-#define BEAGLE_I2C_CLKHI (*(volatile uint32_t *) 0x3102030c)
-#define BEAGLE_I2C_CLKLO (*(volatile uint32_t *) 0x31020310)
-#define BEAGLE_PWR_CTRL (*(volatile uint32_t *) 0x40004044)
-#define BEAGLE_OSC_CTRL (*(volatile uint32_t *) 0x4000404c)
-#define BEAGLE_SYSCLK_CTRL (*(volatile uint32_t *) 0x40004050)
-#define BEAGLE_PLL397_CTRL (*(volatile uint32_t *) 0x40004048)
-#define BEAGLE_HCLKPLL_CTRL (*(volatile uint32_t *) 0x40004058)
-#define BEAGLE_HCLKDIV_CTRL (*(volatile uint32_t *) 0x40004040)
-#define BEAGLE_TEST_CLK (*(volatile uint32_t *) 0x400040a4)
-#define BEAGLE_AUTOCLK_CTRL (*(volatile uint32_t *) 0x400040ec)
-#define BEAGLE_START_ER_PIN (*(volatile uint32_t *) 0x40004030)
-#define BEAGLE_START_ER_INT (*(volatile uint32_t *) 0x40004020)
-#define BEAGLE_P0_INTR_ER (*(volatile uint32_t *) 0x40004018)
-#define BEAGLE_START_SR_PIN (*(volatile uint32_t *) 0x40004038)
-#define BEAGLE_START_SR_INT (*(volatile uint32_t *) 0x40004028)
-#define BEAGLE_START_RSR_PIN (*(volatile uint32_t *) 0x40004034)
-#define BEAGLE_START_RSR_INT (*(volatile uint32_t *) 0x40004024)
-#define BEAGLE_START_APR_PIN (*(volatile uint32_t *) 0x4000403c)
-#define BEAGLE_START_APR_INT (*(volatile uint32_t *) 0x4000402c)
-#define BEAGLE_USB_CTRL (*(volatile uint32_t *) 0x40004064)
-#define BEAGLE_USBDIV_CTRL (*(volatile uint32_t *) 0x4000401c)
-#define BEAGLE_MS_CTRL (*(volatile uint32_t *) 0x40004080)
-#define BEAGLE_DMACLK_CTRL (*(volatile uint32_t *) 0x400040e8)
-#define BEAGLE_FLASHCLK_CTRL (*(volatile uint32_t *) 0x400040c8)
-#define BEAGLE_MACCLK_CTRL (*(volatile uint32_t *) 0x40004090)
-#define BEAGLE_LCDCLK_CTRL (*(volatile uint32_t *) 0x40004054)
-#define BEAGLE_I2S_CTRL (*(volatile uint32_t *) 0x4000407c)
-#define BEAGLE_SSP_CTRL (*(volatile uint32_t *) 0x40004078)
-#define BEAGLE_SPI_CTRL (*(volatile uint32_t *) 0x400040c4)
-#define BEAGLE_I2CCLK_CTRL (*(volatile uint32_t *) 0x400040ac)
-#define BEAGLE_TIMCLK_CTRL1 (*(volatile uint32_t *) 0x400040c0)
-#define BEAGLE_TIMCLK_CTRL (*(volatile uint32_t *) 0x400040bc)
-#define BEAGLE_ADCLK_CTRL (*(volatile uint32_t *) 0x400040b4)
-#define BEAGLE_ADCLK_CTRL1 (*(volatile uint32_t *) 0x40004060)
-#define BEAGLE_KEYCLK_CTRL (*(volatile uint32_t *) 0x400040b0)
-#define BEAGLE_PWMCLK_CTRL (*(volatile uint32_t *) 0x400040b8)
-#define BEAGLE_UARTCLK_CTRL (*(volatile uint32_t *) 0x400040e4)
-#define BEAGLE_POS0_IRAM_CTRL (*(volatile uint32_t *) 0x40004110)
-#define BEAGLE_POS1_IRAM_CTRL (*(volatile uint32_t *) 0x40004114)
-#define BEAGLE_SDRAMCLK_CTRL (*(volatile uint32_t *) 0x40004068)
-
-/** @} */
-
-/**
- * @name Power Control Register (PWR_CTRL)
- *
- * @{
- */
-
-#define PWR_STOP BSP_BIT32(0)
-#define PWR_HIGHCORE_ALWAYS BSP_BIT32(1)
-#define PWR_NORMAL_RUN_MODE BSP_BIT32(2)
-#define PWR_SYSCLKEN_ALWAYS BSP_BIT32(3)
-#define PWR_SYSCLKEN_HIGH BSP_BIT32(4)
-#define PWR_HIGHCORE_HIGH BSP_BIT32(5)
-#define PWR_SDRAM_AUTO_REFRESH BSP_BIT32(7)
-#define PWR_UPDATE_EMCSREFREQ BSP_BIT32(8)
-#define PWR_EMCSREFREQ BSP_BIT32(9)
-#define PWR_HCLK_USES_PERIPH_CLK BSP_BIT32(10)
-
-/** @} */
-
-/**
- * @name HCLK PLL Control Register (HCLKPLL_CTRL)
- *
- * @{
- */
-
-#define HCLK_PLL_LOCK BSP_BIT32(0)
-#define HCLK_PLL_M(val) BSP_FLD32(val, 1, 8)
-#define HCLK_PLL_M_GET(reg) BSP_FLD32GET(reg, 1, 8)
-#define HCLK_PLL_N(val) BSP_FLD32(val, 9, 10)
-#define HCLK_PLL_N_GET(reg) BSP_FLD32GET(reg, 9, 10)
-#define HCLK_PLL_P(val) BSP_FLD32(val, 11, 12)
-#define HCLK_PLL_P_GET(reg) BSP_FLD32GET(reg, 11, 12)
-#define HCLK_PLL_FBD_FCLKOUT BSP_BIT32(13)
-#define HCLK_PLL_DIRECT BSP_BIT32(14)
-#define HCLK_PLL_BYPASS BSP_BIT32(15)
-#define HCLK_PLL_POWER BSP_BIT32(16)
-
-/** @} */
-
-/**
- * @name HCLK Divider Control Register (HCLKDIV_CTRL)
- *
- * @{
- */
-
-#define HCLK_DIV_HCLK(val) BSP_FLD32(val, 0, 1)
-#define HCLK_DIV_HCLK_GET(reg) BSP_FLD32GET(reg, 0, 1)
-#define HCLK_DIV_PERIPH_CLK(val) BSP_FLD32(val, 2, 6)
-#define HCLK_DIV_PERIPH_CLK_GET(reg) BSP_FLD32GET(reg, 2, 6)
-#define HCLK_DIV_DDRAM_CLK(val) BSP_FLD32(val, 7, 8)
-#define HCLK_DIV_DDRAM_CLK_GET(reg) BSP_FLD32GET(reg, 7, 8)
-
-/** @} */
-
-/**
- * @name Timer Clock Control Register (TIMCLK_CTRL)
- *
- * @{
- */
-
-#define TIMCLK_CTRL_WDT BSP_BIT32(0)
-#define TIMCLK_CTRL_HST BSP_BIT32(1)
-
-/** @} */
-
-#define BEAGLE_FILL(a, b, s) uint8_t reserved_ ## b [b - a - sizeof(s)]
-#define BEAGLE_RESERVE(a, b) uint8_t reserved_ ## b [b - a]
-
-typedef struct {
-} beagle_nand_slc;
-
-typedef struct {
-} beagle_ssp;
-
-typedef struct {
-} beagle_spi;
-
-typedef struct {
-} beagle_sd_card;
-
-typedef struct {
-} beagle_usb;
-
-typedef struct {
-} beagle_lcd;
-
-typedef struct {
-} beagle_etb;
-
-typedef struct {
-} beagle_syscon;
-
-typedef struct {
-} beagle_uart_ctrl;
-
-typedef struct {
-} beagle_uart;
-
-typedef struct {
-} beagle_ms_timer;
-
-typedef struct {
-} beagle_hs_timer;
-
-/**
- * @name Watchdog Timer Interrupt Status Register (WDTIM_INT)
- *
- * @{
- */
-
-#define WDTTIM_INT_MATCH_INT BSP_BIT32(0)
-
-/** @} */
-
-/**
- * @name Watchdog Timer Control Register (WDTIM_CTRL)
- *
- * @{
- */
-
-#define WDTTIM_CTRL_COUNT_ENAB BSP_BIT32(0)
-#define WDTTIM_CTRL_RESET_COUNT BSP_BIT32(1)
-#define WDTTIM_CTRL_PAUSE_EN BSP_BIT32(2)
-
-/** @} */
-
-/**
- * @name Watchdog Timer Match Control Register (WDTIM_MCTRL)
- *
- * @{
- */
-
-#define WDTTIM_MCTRL_MR0_INT BSP_BIT32(0)
-#define WDTTIM_MCTRL_RESET_COUNT0 BSP_BIT32(1)
-#define WDTTIM_MCTRL_STOP_COUNT0 BSP_BIT32(2)
-#define WDTTIM_MCTRL_M_RES1 BSP_BIT32(3)
-#define WDTTIM_MCTRL_M_RES2 BSP_BIT32(4)
-#define WDTTIM_MCTRL_RESFRC1 BSP_BIT32(5)
-#define WDTTIM_MCTRL_RESFRC2 BSP_BIT32(6)
-
-/** @} */
-
-/**
- * @name Watchdog Timer External Match Control Register (WDTIM_EMR)
- *
- * @{
- */
-
-#define WDTTIM_EMR_EXT_MATCH0 BSP_BIT32(0)
-#define WDTTIM_EMR_MATCH_CTRL(val) BSP_FLD32(val, 4, 5)
-#define WDTTIM_EMR_MATCH_CTRL_SET(reg, val) BSP_FLD32SET(reg, val, 4, 5)
-
-/** @} */
-
-/**
- * @name Watchdog Timer Reset Source Register (WDTIM_RES)
- *
- * @{
- */
-
-#define WDTTIM_RES_WDT BSP_BIT32(0)
-
-/** @} */
-
-typedef struct {
- uint32_t intr;
- uint32_t ctrl;
- uint32_t counter;
- uint32_t mctrl;
- uint32_t match0;
- uint32_t emr;
- uint32_t pulse;
- uint32_t res;
-} beagle_wdt;
-
-typedef struct {
-} beagle_debug;
-
-typedef struct {
-} beagle_adc;
-
-typedef struct {
-} beagle_keyscan;
-
-typedef struct {
-} beagle_pwm;
-
-typedef struct {
-} beagle_mcpwm;
-
-typedef struct {
- uint32_t mac1;
- uint32_t mac2;
- uint32_t ipgt;
- uint32_t ipgr;
- uint32_t clrt;
- uint32_t maxf;
- uint32_t supp;
- uint32_t test;
- uint32_t mcfg;
- uint32_t mcmd;
- uint32_t madr;
- uint32_t mwtd;
- uint32_t mrdd;
- uint32_t mind;
- uint32_t reserved_0 [2];
- uint32_t sa0;
- uint32_t sa1;
- uint32_t sa2;
- uint32_t reserved_1 [45];
- uint32_t command;
- uint32_t status;
- uint32_t rxdescriptor;
- uint32_t rxstatus;
- uint32_t rxdescriptornum;
- uint32_t rxproduceindex;
- uint32_t rxconsumeindex;
- uint32_t txdescriptor;
- uint32_t txstatus;
- uint32_t txdescriptornum;
- uint32_t txproduceindex;
- uint32_t txconsumeindex;
- uint32_t reserved_2 [10];
- uint32_t tsv0;
- uint32_t tsv1;
- uint32_t rsv;
- uint32_t reserved_3 [3];
- uint32_t flowcontrolcnt;
- uint32_t flowcontrolsts;
- uint32_t reserved_4 [34];
- uint32_t rxfilterctrl;
- uint32_t rxfilterwolsts;
- uint32_t rxfilterwolclr;
- uint32_t reserved_5 [1];
- uint32_t hashfilterl;
- uint32_t hashfilterh;
- uint32_t reserved_6 [882];
- uint32_t intstatus;
- uint32_t intenable;
- uint32_t intclear;
- uint32_t intset;
- uint32_t reserved_7 [1];
- uint32_t powerdown;
-} beagle_eth;
-
-typedef struct {
- uint32_t er;
- uint32_t rsr;
- uint32_t sr;
- uint32_t apr;
- uint32_t atr;
- uint32_t itr;
-} beagle_irq;
-
-typedef struct {
- uint32_t p3_inp_state;
- uint32_t p3_outp_set;
- uint32_t p3_outp_clr;
- uint32_t p3_outp_state;
- uint32_t p2_dir_set;
- uint32_t p2_dir_clr;
- uint32_t p2_dir_state;
- uint32_t p2_inp_state;
- uint32_t p2_outp_set;
- uint32_t p2_outp_clr;
- uint32_t p2_mux_set;
- uint32_t p2_mux_clr;
- uint32_t p2_mux_state;
- BEAGLE_RESERVE(0x034, 0x040);
- uint32_t p0_inp_state;
- uint32_t p0_outp_set;
- uint32_t p0_outp_clr;
- uint32_t p0_outp_state;
- uint32_t p0_dir_set;
- uint32_t p0_dir_clr;
- uint32_t p0_dir_state;
- BEAGLE_RESERVE(0x05c, 0x060);
- uint32_t p1_inp_state;
- uint32_t p1_outp_set;
- uint32_t p1_outp_clr;
- uint32_t p1_outp_state;
- uint32_t p1_dir_set;
- uint32_t p1_dir_clr;
- uint32_t p1_dir_state;
- BEAGLE_RESERVE(0x07c, 0x110);
- uint32_t p3_mux_set;
- uint32_t p3_mux_clr;
- uint32_t p3_mux_state;
- uint32_t p0_mux_set;
- uint32_t p0_mux_clr;
- uint32_t p0_mux_state;
- uint32_t p1_mux_set;
- uint32_t p1_mux_clr;
- uint32_t p1_mux_state;
-} beagle_gpio;
-
-typedef struct {
- uint32_t rx_or_tx;
- uint32_t stat;
- uint32_t ctrl;
- uint32_t clk_hi;
- uint32_t clk_lo;
- uint32_t adr;
- uint32_t rxfl;
- uint32_t txfl;
- uint32_t rxb;
- uint32_t txb;
- uint32_t s_tx;
- uint32_t s_txfl;
-} beagle_i2c;
-
-typedef struct {
- uint32_t ucount;
- uint32_t dcount;
- uint32_t match0;
- uint32_t match1;
- uint32_t ctrl;
- uint32_t intstat;
- uint32_t key;
- uint32_t sram [32];
-} beagle_rtc;
-
-typedef struct {
- uint32_t control;
- uint32_t status;
- uint32_t timeout;
- uint32_t reserved_0 [5];
-} beagle_emc_ahb;
-
-typedef struct {
- union {
- uint32_t w32;
- uint16_t w16;
- uint8_t w8;
- } buff;
- uint32_t reserved_0 [8191];
- union {
- uint32_t w32;
- uint16_t w16;
- uint8_t w8;
- } data;
- uint32_t reserved_1 [8191];
- uint32_t cmd;
- uint32_t addr;
- uint32_t ecc_enc;
- uint32_t ecc_dec;
- uint32_t ecc_auto_enc;
- uint32_t ecc_auto_dec;
- uint32_t rpr;
- uint32_t wpr;
- uint32_t rubp;
- uint32_t robp;
- uint32_t sw_wp_add_low;
- uint32_t sw_wp_add_hig;
- uint32_t icr;
- uint32_t time;
- uint32_t irq_mr;
- uint32_t irq_sr;
- uint32_t reserved_2;
- uint32_t lock_pr;
- uint32_t isr;
- uint32_t ceh;
-} beagle_nand_mlc;
-
-typedef struct {
- beagle_nand_slc nand_slc;
- BEAGLE_FILL(0x20020000, 0x20084000, beagle_nand_slc);
- beagle_ssp ssp_0;
- BEAGLE_FILL(0x20084000, 0x20088000, beagle_ssp);
- beagle_spi spi_1;
- BEAGLE_FILL(0x20088000, 0x2008c000, beagle_spi);
- beagle_ssp ssp_1;
- BEAGLE_FILL(0x2008c000, 0x20090000, beagle_ssp);
- beagle_spi spi_2;
- BEAGLE_FILL(0x20090000, 0x20094000, beagle_spi);
- //beagle_i2s i2s_0;
- //BEAGLE_FILL(0x20094000, 0x20098000, beagle_i2s);
- beagle_sd_card sd_card;
- BEAGLE_FILL(0x20098000, 0x2009c000, beagle_sd_card);
- //beagle_i2s i2s_1;
- //BEAGLE_FILL(0x2009c000, 0x200a8000, beagle_i2s);
- beagle_nand_mlc nand_mlc;
- BEAGLE_FILL(0x200a8000, 0x31000000, beagle_nand_mlc);
- //beagle_dma dma;
- //BEAGLE_FILL(0x31000000, 0x31020000, beagle_dma);
- beagle_usb usb;
- BEAGLE_FILL(0x31020000, 0x31040000, beagle_usb);
- beagle_lcd lcd;
- BEAGLE_FILL(0x31040000, 0x31060000, beagle_lcd);
- beagle_eth eth;
- BEAGLE_FILL(0x31060000, 0x31080000, beagle_eth);
- //beagle_emc emc;
- //BEAGLE_FILL(0x31080000, 0x31080400, beagle_emc);
- beagle_emc_ahb emc_ahb [5];
- BEAGLE_FILL(0x31080400, 0x310c0000, beagle_emc_ahb [5]);
- beagle_etb etb;
- BEAGLE_FILL(0x310c0000, 0x40004000, beagle_etb);
- beagle_syscon syscon;
- BEAGLE_FILL(0x40004000, 0x40008000, beagle_syscon);
- beagle_irq mic;
- BEAGLE_FILL(0x40008000, 0x4000c000, beagle_irq);
- beagle_irq sic_1;
- BEAGLE_FILL(0x4000c000, 0x40010000, beagle_irq);
- beagle_irq sic_2;
- BEAGLE_FILL(0x40010000, 0x40014000, beagle_irq);
- beagle_uart uart_1;
- BEAGLE_FILL(0x40014000, 0x40018000, beagle_uart);
- beagle_uart uart_2;
- BEAGLE_FILL(0x40018000, 0x4001c000, beagle_uart);
- beagle_uart uart_7;
- BEAGLE_FILL(0x4001c000, 0x40024000, beagle_uart);
- beagle_rtc rtc;
- BEAGLE_FILL(0x40024000, 0x40028000, beagle_rtc);
- beagle_gpio gpio;
- BEAGLE_FILL(0x40028000, 0x4002c000, beagle_gpio);
- beagle_timer timer_4;
- BEAGLE_FILL(0x4002c000, 0x40030000, beagle_timer);
- beagle_timer timer_5;
- BEAGLE_FILL(0x40030000, 0x40034000, beagle_timer);
- beagle_ms_timer ms_timer;
- BEAGLE_FILL(0x40034000, 0x40038000, beagle_ms_timer);
- beagle_hs_timer hs_timer;
- BEAGLE_FILL(0x40038000, 0x4003c000, beagle_hs_timer);
- beagle_wdt wdt;
- BEAGLE_FILL(0x4003c000, 0x40040000, beagle_wdt);
- beagle_debug debug;
- BEAGLE_FILL(0x40040000, 0x40044000, beagle_debug);
- beagle_timer timer_0;
- BEAGLE_FILL(0x40044000, 0x40048000, beagle_timer);
- beagle_adc adc;
- BEAGLE_FILL(0x40048000, 0x4004c000, beagle_adc);
- beagle_timer timer_1;
- BEAGLE_FILL(0x4004c000, 0x40050000, beagle_timer);
- beagle_keyscan keyscan;
- BEAGLE_FILL(0x40050000, 0x40054000, beagle_keyscan);
- beagle_uart_ctrl uart_ctrl;
- BEAGLE_FILL(0x40054000, 0x40058000, beagle_uart_ctrl);
- beagle_timer timer_2;
- BEAGLE_FILL(0x40058000, 0x4005c000, beagle_timer);
- beagle_pwm pwm_1_and_pwm_2;
- BEAGLE_FILL(0x4005c000, 0x40060000, beagle_pwm);
- beagle_timer timer3;
- BEAGLE_FILL(0x40060000, 0x40080000, beagle_timer);
- beagle_uart uart_3;
- BEAGLE_FILL(0x40080000, 0x40088000, beagle_uart);
- beagle_uart uart_4;
- BEAGLE_FILL(0x40088000, 0x40090000, beagle_uart);
- beagle_uart uart_5;
- BEAGLE_FILL(0x40090000, 0x40098000, beagle_uart);
- beagle_uart uart_6;
- BEAGLE_FILL(0x40098000, 0x400a0000, beagle_uart);
- beagle_i2c i2c_1;
- BEAGLE_FILL(0x400a0000, 0x400a8000, beagle_i2c);
- beagle_i2c i2c_2;
- BEAGLE_FILL(0x400a8000, 0x400e8000, beagle_i2c);
- beagle_mcpwm mcpwm;
-} beagle_registers;
-
-extern volatile beagle_registers beagle;
-
-/** @} */
-
-#endif /* LIBBSP_ARM_BEAGLE_BEAGLE_H */
diff --git a/c/src/lib/libbsp/arm/beagle/include/boot.h b/c/src/lib/libbsp/arm/beagle/include/boot.h
deleted file mode 100644
index 32e4f0013c..0000000000
--- a/c/src/lib/libbsp/arm/beagle/include/boot.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle_boot
- *
- * @brief Boot support API.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef LIBBSP_ARM_BEAGLE_BOOT_H
-#define LIBBSP_ARM_BEAGLE_BOOT_H
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @defgroup beagle_boot Boot Support
- *
- * @ingroup beagle
- *
- * @brief Boot support.
- *
- * The NXP internal boot program shall be the "stage-0 program".
- *
- * The boot program within the first page of the first or second block shall be
- * "stage-1 program". It will be invoked by the stage-0 program from NXP.
- *
- * The program loaded by the stage-1 program will be the "stage-2 program" or
- * the "boot loader".
- *
- * The program loaded by the stage-2 program will be the "stage-3 program" or
- * the "application".
- *
- * The stage-1 program image must have a format specified by NXP.
- *
- * The stage-2 and stage-3 program images may have any format.
- *
- * @{
- */
-
-
-#define MLC_SMALL_DATA_SIZE 512
-#define MLC_SMALL_DATA_WORD_COUNT (MLC_SMALL_DATA_SIZE / 4)
-
-#define BEAGLE_BOOT_BLOCK_0 0
-#define BEAGLE_BOOT_BLOCK_1 1
-
-#define BEAGLE_BOOT_ICR_SP_3AC_8IF 0xf0
-#define BEAGLE_BOOT_ICR_SP_4AC_8IF 0xd2
-#define BEAGLE_BOOT_ICR_LP_4AC_8IF 0xb4
-#define BEAGLE_BOOT_ICR_LP_5AC_8IF 0x96
-
-typedef union {
- struct {
- uint8_t d0;
- uint8_t reserved_0 [3];
- uint8_t d1;
- uint8_t reserved_1 [3];
- uint8_t d2;
- uint8_t reserved_2 [3];
- uint8_t d3;
- uint8_t reserved_3 [3];
- uint8_t d4;
- uint8_t reserved_4 [3];
- uint8_t d5;
- uint8_t reserved_5 [3];
- uint8_t d6;
- uint8_t reserved_6 [3];
- uint8_t d7;
- uint8_t reserved_7 [3];
- uint8_t d8;
- uint8_t reserved_8 [3];
- uint8_t d9;
- uint8_t reserved_9 [3];
- uint8_t d10;
- uint8_t reserved_10 [3];
- uint8_t d11;
- uint8_t reserved_11 [3];
- uint8_t d12;
- uint8_t reserved_12 [463];
- } field;
- uint32_t data [MLC_SMALL_DATA_WORD_COUNT];
-} beagle_boot_block;
-
-void beagle_setup_boot_block(
- beagle_boot_block *boot_block,
- uint8_t icr,
- uint8_t page_count
-);
-
-void beagle_set_boot_block_bad(
- beagle_boot_block *boot_block
-);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* LIBBSP_ARM_BEAGLE_BOOT_H */
diff --git a/c/src/lib/libbsp/arm/beagle/include/bsp.h b/c/src/lib/libbsp/arm/beagle/include/bsp.h
index 393b75d498..e235efa901 100644
--- a/c/src/lib/libbsp/arm/beagle/include/bsp.h
+++ b/c/src/lib/libbsp/arm/beagle/include/bsp.h
@@ -1,7 +1,7 @@
/**
* @file
*
- * @ingroup beagle
+ * @ingroup arm_beagle
*
* @brief Global BSP definitions.
*/
@@ -18,232 +18,329 @@
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
+ *
+ * Modified by Ben Gras <beng@shrike-systems.com> to add lots
+ * of beagleboard/beaglebone definitions, delete lpc32xx specific
+ * ones, and merge with some other header files.
*/
#ifndef LIBBSP_ARM_BEAGLE_BSP_H
#define LIBBSP_ARM_BEAGLE_BSP_H
#include <bspopts.h>
+#include <stdint.h>
+#include <bsp/start.h>
+#include <bsp/default-initial-extension.h>
#include <rtems.h>
-//#include <rtems/console.h>
-//#include <rtems/clockdrv.h>
-
-#include <bsp/beagle.h>
+#include <rtems/irq-extension.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+#include <libcpu/omap3.h>
+#include <libcpu/am335x.h>
#define BSP_FEATURE_IRQ_EXTENSION
-#ifndef ASM
+/* UART base clock frequency */
+#define UART_CLOCK 48000000
-struct rtems_bsdnet_ifconfig;
+/* Access memory-mapped I/O devices */
+#define mmio_read(a) (*(volatile uint32_t *)(a))
+#define mmio_write(a,v) (*(volatile uint32_t *)(a) = (v))
+#define mmio_set(a,v) mmio_write((a), mmio_read((a)) | (v))
+#define mmio_clear(a,v) mmio_write((a), mmio_read((a)) & ~(v))
-/**
- * @defgroup beagle BEAGLE Support
- *
- * @ingroup bsp_kit
- *
- * @brief BEAGLE support package.
- *
- * @{
- */
+#define REG16(x)(*((volatile uint16_t *)(x)))
+#define REG(x)(*((volatile uint32_t *)(x)))
+#define BIT(x)(0x1 << x)
-/**
- * @brief Network driver attach and detach function.
- */
-int beagle_eth_attach_detach(
- struct rtems_bsdnet_ifconfig *config,
- int attaching
-);
+#define udelay(u) rtems_task_wake_after(1 + ((u)/rtems_configuration_get_microseconds_per_tick()))
-/**
- * @brief Standard network driver attach and detach function.
- */
-#define RTEMS_BSP_NETWORK_DRIVER_ATTACH beagle_eth_attach_detach
+/* Write a uint32_t value to a memory address. */
+static inline void
+write32(uint32_t address, uint32_t value)
+{
+ REG(address) = value;
+}
-/**
- * @brief Standard network driver name.
- */
-#define RTEMS_BSP_NETWORK_DRIVER_NAME "eth0"
+/* Read an uint32_t from a memory address */
+static inline uint32_t
+read32(uint32_t address)
+{
+ return REG(address);
+}
-/**
- * @brief Optimized idle task.
- *
- * This idle task sets the power mode to idle. This causes the processor clock
- * to be stopped, while on-chip peripherals remain active. Any enabled
- * interrupt from a peripheral or an external interrupt source will cause the
- * processor to resume execution.
- *
- * To enable the idle task use the following in the system configuration:
- *
- * @code
- * #include <bsp.h>
- *
- * #define CONFIGURE_INIT
- *
- * #define CONFIGURE_IDLE_TASK_BODY beagle_idle
- *
- * #include <confdefs.h>
- * @endcode
- */
-void *beagleboard_idle(uintptr_t ignored);
+/* Set a 32 bits value depending on a mask */
+static inline void
+set32(uint32_t address, uint32_t mask, uint32_t value)
+{
+ uint32_t val;
+ val = read32(address);
+ /* clear the bits */
+ val &= ~(mask);
+ /* apply the value using the mask */
+ val |= (value & mask);
+ write32(address, val);
+}
-#define BEAGLE_STANDARD_TIMER (&beagle.timer_1)
+/* Write a uint16_t value to a memory address. */
+static inline void
+write16(uint32_t address, uint16_t value)
+{
+ REG16(address) = value;
+}
-static inline unsigned beagleboard_timer(void)
+/* Read an uint16_t from a memory address */
+static inline uint16_t
+read16(uint32_t address)
{
- volatile beagle_timer *timer = BEAGLE_STANDARD_TIMER;
+ return REG16(address);
+}
- return timer->tc;
+/* Data synchronization barrier */
+static inline void dsb(void)
+{
+ asm volatile("dsb" : : : "memory");
}
-static inline void beagleboard_micro_seconds_delay(unsigned us)
+/* Instruction synchronization barrier */
+static inline void isb(void)
{
- unsigned start = beagleboard_timer();
- unsigned delay = us * (BEAGLE_PERIPH_CLK / 1000000);
- unsigned elapsed = 0;
+ asm volatile("isb" : : : "memory");
+}
- do {
- elapsed = beagleboard_timer() - start;
- } while (elapsed < delay);
+/* flush data cache */
+static inline void flush_data_cache(void)
+{
+ asm volatile("mov r0, #0; mcr p15, #0, r0, c7, c10, #4" : : : "memory");
}
-#if BEAGLE_OSCILLATOR_MAIN == 13000000U
- #define BEAGLE_HCLKPLL_CTRL_INIT_VALUE \
- (HCLK_PLL_POWER | HCLK_PLL_DIRECT | HCLK_PLL_M(16 - 1))
- #define BEAGLE_HCLKDIV_CTRL_INIT_VALUE \
- (HCLK_DIV_HCLK(2 - 1) | \
- HCLK_DIV_PERIPH_CLK(16 - 1) | \
- HCLK_DIV_DDRAM_CLK(1))
-#else
- #error "unexpected main oscillator frequency"
+
+#define TIMER_FREQ 1000 /* clock frequency for OMAP timer (1ms) */
+#define TIMER_COUNT(freq) (TIMER_FREQ/(freq)) /* initial value for counter*/
+
+#define __arch_getb(a) (*(volatile unsigned char *)(a))
+#define __arch_getw(a) (*(volatile unsigned short *)(a))
+#define __arch_getl(a) (*(volatile unsigned int *)(a))
+
+#define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v))
+#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
+#define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v))
+
+#define writeb(v,c) ({ unsigned char __v = v; __arch_putb(__v,c); __v; })
+#define writew(v,c) ({ unsigned short __v = v; __arch_putw(__v,c); __v; })
+#define writel(v,c) ({ unsigned int __v = v; __arch_putl(__v,c); __v; })
+
+#define readb(c) ({ unsigned char __v = __arch_getb(c); __v; })
+#define readw(c) ({ unsigned short __v = __arch_getw(c); __v; })
+#define readl(c) ({ unsigned int __v = __arch_getl(c); __v; })
+
+#define SYSTEM_CLOCK_12 12000000
+#define SYSTEM_CLOCK_13 13000000
+#define SYSTEM_CLOCK_192 19200000
+#define SYSTEM_CLOCK_96 96000000
+
+#if !defined(IS_DM3730) && !defined(IS_AM335X)
+#error Unrecognized BSP configured.
#endif
-bool beagleboard_start_pll_setup(
- uint32_t hclkpll_ctrl,
- uint32_t hclkdiv_ctrl,
- bool force
-);
+#if IS_DM3730
+#define BSP_DEVICEMEM_START 0x48000000
+#define BSP_DEVICEMEM_END 0x5F000000
+#endif
-uint32_t beagleboard__sysclk(void);
+#if IS_AM335X
+#define BSP_DEVICEMEM_START 0x44000000
+#define BSP_DEVICEMEM_END 0x57000000
+#endif
-uint32_t beagleboard_hclkpll_clk(void);
+/* per-target uart config */
+#if IS_AM335X
+#define BSP_CONSOLE_UART 1
+#define BSP_CONSOLE_UART_BASE BEAGLE_BASE_UART_1
+#define BSP_CONSOLE_UART_IRQ OMAP3_UART1_IRQ
+#define BEAGLE_BASE_UART_1 0x44E09000
+#define BEAGLE_BASE_UART_2 0x48022000
+#define BEAGLE_BASE_UART_3 0x48024000
+#endif
-uint32_t beagleboard_periph_clk(void);
+/* per-target uart config */
+#if IS_DM3730
+#define BSP_CONSOLE_UART 3
+#define BSP_CONSOLE_UART_BASE BEAGLE_BASE_UART_3
+#define BSP_CONSOLE_UART_IRQ OMAP3_UART3_IRQ
+#define BEAGLE_BASE_UART_1 0x4806A000
+#define BEAGLE_BASE_UART_2 0x4806C000
+#define BEAGLE_BASE_UART_3 0x49020000
+#endif
-uint32_t beagleboard_hclk(void);
+/* i2c stuff */
+typedef struct {
+ uint32_t rx_or_tx;
+ uint32_t stat;
+ uint32_t ctrl;
+ uint32_t clk_hi;
+ uint32_t clk_lo;
+ uint32_t adr;
+ uint32_t rxfl;
+ uint32_t txfl;
+ uint32_t rxb;
+ uint32_t txb;
+ uint32_t s_tx;
+ uint32_t s_txfl;
+} beagle_i2c;
+
+/* sctlr */
+/* Read System Control Register */
+static inline uint32_t read_sctlr()
+{
+ uint32_t ctl;
-uint32_t beagleboard_arm_clk(void);
+ asm volatile("mrc p15, 0, %[ctl], c1, c0, 0 @ Read SCTLR\n\t"
+ : [ctl] "=r" (ctl));
+ return ctl;
+}
-uint32_t beagleboard_dram_clk(void);
+/* Write System Control Register */
+static inline void write_sctlr(uint32_t ctl)
+{
+ asm volatile("mcr p15, 0, %[ctl], c1, c0, 0 @ Write SCTLR\n\t"
+ : : [ctl] "r" (ctl));
+ isb();
+}
-void bsp_restart(void *addr);
+/* Read Auxiliary Control Register */
+static inline uint32_t read_actlr()
+{
+ uint32_t ctl;
-#define BSP_CONSOLE_UART_BASE BEAGLE_BASE_UART_5
+ asm volatile("mrc p15, 0, %[ctl], c1, c0, 1 @ Read ACTLR\n\t"
+ : [ctl] "=r" (ctl));
+ return ctl;
+}
-/**
- * @brief Begin of magic zero area.
- *
- * A read from this area returns zero. Writes have no effect.
- */
-//extern uint32_t beagle_magic_zero_begin [];
+/* Write Auxiliary Control Register */
+static inline void write_actlr(uint32_t ctl)
+{
+ asm volatile("mcr p15, 0, %[ctl], c1, c0, 1 @ Write ACTLR\n\t"
+ : : [ctl] "r" (ctl));
+ isb();
+}
-/**
- * @brief End of magic zero area.
- *
- * A read from this area returns zero. Writes have no effect.
- */
-//extern uint32_t beagle_magic_zero_end [];
+/* Write Translation Table Base Control Register */
+static inline void write_ttbcr(uint32_t bcr)
+{
+ asm volatile("mcr p15, 0, %[bcr], c2, c0, 2 @ Write TTBCR\n\t"
+ : : [bcr] "r" (bcr));
-/**
- * @brief Size of magic zero area.
- *
- * A read from this area returns zero. Writes have no effect.
+ isb();
+}
+
+/* Read Domain Access Control Register */
+static inline uint32_t read_dacr()
+{
+ uint32_t dacr;
+
+ asm volatile("mrc p15, 0, %[dacr], c3, c0, 0 @ Read DACR\n\t"
+ : [dacr] "=r" (dacr));
+
+ return dacr;
+}
+
+
+/* Write Domain Access Control Register */
+static inline void write_dacr(uint32_t dacr)
+{
+ asm volatile("mcr p15, 0, %[dacr], c3, c0, 0 @ Write DACR\n\t"
+ : : [dacr] "r" (dacr));
+
+ isb();
+}
+
+static inline void refresh_tlb(void)
+{
+ dsb();
+
+ /* Invalidate entire unified TLB */
+ asm volatile("mcr p15, 0, %[zero], c8, c7, 0 @ TLBIALL\n\t"
+ : : [zero] "r" (0));
+
+ /* Invalidate all instruction caches to PoU.
+ * Also flushes branch target cache. */
+ asm volatile("mcr p15, 0, %[zero], c7, c5, 0"
+ : : [zero] "r" (0));
+
+ /* Invalidate entire branch predictor array */
+ asm volatile("mcr p15, 0, %[zero], c7, c5, 6"
+ : : [zero] "r" (0)); /* flush BTB */
+
+ dsb();
+ isb();
+}
+
+/* Read Translation Table Base Register 0 */
+static inline uint32_t read_ttbr0()
+{
+ uint32_t bar;
+
+ asm volatile("mrc p15, 0, %[bar], c2, c0, 0 @ Read TTBR0\n\t"
+ : [bar] "=r" (bar));
+
+ return bar & ARM_TTBR_ADDR_MASK;
+}
+
+
+/* Read Translation Table Base Register 0 */
+static inline uint32_t read_ttbr0_unmasked()
+{
+ uint32_t bar;
+
+ asm volatile("mrc p15, 0, %[bar], c2, c0, 0 @ Read TTBR0\n\t"
+ : [bar] "=r" (bar));
+
+ return bar;
+}
+
+/* Write Translation Table Base Register 0 */
+static inline void write_ttbr0(uint32_t bar)
+{
+ dsb();
+ isb();
+ /* In our setup TTBR contains the base address *and* the flags
+ but other pieces of the kernel code expect ttbr to be the
+ base address of the l1 page table. We therefore add the
+ flags here and remove them in the read_ttbr0 */
+ uint32_t v = (bar & ARM_TTBR_ADDR_MASK ) | ARM_TTBR_FLAGS_CACHED;
+ asm volatile("mcr p15, 0, %[bar], c2, c0, 0 @ Write TTBR0\n\t"
+ : : [bar] "r" (v));
+
+ refresh_tlb();
+}
+
+/* Behaviour on fatal error; default: test-friendly.
+ * set breakpoint to bsp_fatal_extension.
*/
-//extern uint32_t beagle_magic_zero_size [];
-
-#ifdef BEAGLE_SCRATCH_AREA_SIZE
- /**
- * @rief Scratch area.
- *
- * The usage is application specific.
- */
- //extern uint8_t beagle_scratch_area [BEAGLE_SCRATCH_AREA_SIZE];
-#endif
+/* Enabling BSP_PRESS_KEY_FOR_RESET prevents noninteractive testing */
+/*#define BSP_PRESS_KEY_FOR_RESET 1 */
+#define BSP_PRINT_EXCEPTION_CONTEXT 1
+ /* human-readable exception info */
+#define BSP_RESET_BOARD_AT_EXIT 1
+ /* causes qemu to exit, signaling end of test */
-#define BEAGLE_DO_STOP_GPDMA \
- do { \
- if ((BEAGLE_DMACLK_CTRL & 0x1) != 0) { \
- if ((beagle.dma.cfg & DMA_CFG_E) != 0) { \
- int i = 0; \
- for (i = 0; i < 8; ++i) { \
- beagle.dma.channels [i].cfg = 0; \
- } \
- beagle.dma.cfg &= ~DMA_CFG_E; \
- } \
- BEAGLE_DMACLK_CTRL = 0; \
- } \
- } while (0)
-
-#define BEAGLE_DO_STOP_ETHERNET \
- do { \
- if ((BEAGLE_MAC_CLK_CTRL & 0x7) == 0x7) { \
- beagle.eth.command = 0x38; \
- beagle.eth.mac1 = 0xcf00; \
- beagle.eth.mac1 = 0; \
- BEAGLE_MAC_CLK_CTRL = 0; \
- } \
- } while (0)
-
-#define BEAGLE_DO_STOP_USB \
- do { \
- if ((BEAGLE_USB_CTRL & 0x010e8000) != 0) { \
- BEAGLE_OTG_CLK_CTRL = 0; \
- BEAGLE_USB_CTRL = 0x80000; \
- } \
- } while (0)
-
-#define BEAGLE_DO_RESTART(addr) \
- do { \
- ARM_SWITCH_REGISTERS; \
- rtems_interrupt_level level; \
- uint32_t ctrl = 0; \
- \
- rtems_interrupt_disable(level); \
- \
- arm_cp15_data_cache_test_and_clean(); \
- arm_cp15_instruction_cache_invalidate(); \
- \
- ctrl = arm_cp15_get_control(); \
- ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M); \
- arm_cp15_set_control(ctrl); \
- \
- __asm__ volatile ( \
- ARM_SWITCH_TO_ARM \
- "mov pc, %[addr]\n" \
- ARM_SWITCH_BACK \
- : ARM_SWITCH_OUTPUT \
- : [addr] "r" (addr) \
- ); \
- } while (0)
-
-/** @} */
/**
- * @defgroup beagle BEAGLE Support
+ * @defgroup arm_beagle Beaglebone, Beagleboard Support
*
- * @ingroup beagle
+ * @ingroup bsp_arm
+ *
+ * @brief Beaglebones and beagleboards support package
*
- * @brief BEAGLE support package.
*/
-#endif /* ASM */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+/**
+ * @brief Beagleboard specific set up of the MMU.
+ *
+ * Provide in the application to override.
+ */
+BSP_START_TEXT_SECTION void beagle_setup_mmu_and_cache(void);
#endif /* LIBBSP_ARM_BEAGLE_BSP_H */
diff --git a/c/src/lib/libbsp/arm/beagle/include/i2c.h b/c/src/lib/libbsp/arm/beagle/include/i2c.h
index 59b9364aba..dbd066a984 100644
--- a/c/src/lib/libbsp/arm/beagle/include/i2c.h
+++ b/c/src/lib/libbsp/arm/beagle/include/i2c.h
@@ -1,7 +1,7 @@
/**
* @file
*
- * @ingroup beagle_i2c
+ * @ingroup arm_beagle
*
* @brief I2C support API.
*/
@@ -25,7 +25,7 @@
#include <rtems.h>
-#include <bsp/beagle.h>
+#include <bsp.h>
#ifdef __cplusplus
extern "C" {
@@ -215,89 +215,6 @@ static int imw ( unsigned char chip, unsigned long addr, unsigned char byte );
static int imd( unsigned char chip, unsigned int addr, unsigned int length );
/**
- * @defgroup beagle_i2c I2C Support
- *
- * @ingroup beagle
- *
- * @brief I2C Support
- *
- * All writes and reads will be performed in master mode. Exclusive bus access
- * will be assumed.
- *
- * @{
- */
-
-/**
- * @name I2C Clock Control Register (I2CCLK_CTRL)
- *
- * @{
- */
-
-//#define I2CCLK_1_EN BSP_BIT32(0)
-//#define I2CCLK_2_EN BSP_BIT32(1)
-//#define I2CCLK_1_HIGH_DRIVE BSP_BIT32(2)
-//#define I2CCLK_2_HIGH_DRIVE BSP_BIT32(3)
-//#define I2CCLK_USB_HIGH_DRIVE BSP_BIT32(4)
-
-/** @} */
-
-/**
- * @name I2C TX Data FIFO Register (I2Cn_TX)
- *
- * @{
- */
-
-//#define I2C_TX_READ BSP_BIT32(0)
-//#define I2C_TX_ADDR(val) BSP_FLD32(val, 1, 7)
-//#define I2C_TX_START BSP_BIT32(8)
-//#define I2C_TX_STOP BSP_BIT32(9)
-
-/** @} */
-
-/**
- * @name I2C Status Register (I2Cn_STAT)
- *
- * @{
- */
-
-//#define I2C_STAT_TDI BSP_BIT32(0)
-//#define I2C_STAT_AFI BSP_BIT32(1)
-//#define I2C_STAT_NAI BSP_BIT32(2)
-//#define I2C_STAT_DRMI BSP_BIT32(3)
-//#define I2C_STAT_DRSI BSP_BIT32(4)
-//#define I2C_STAT_ACTIVE BSP_BIT32(5)
-//#define I2C_STAT_SCL BSP_BIT32(6)
-//#define I2C_STAT_SDA BSP_BIT32(7)
-//#define I2C_STAT_RFF BSP_BIT32(8)
-//#define I2C_STAT_RFE BSP_BIT32(9)
-//#define I2C_STAT_TFF BSP_BIT32(10)
-//#define I2C_STAT_TFE BSP_BIT32(11)
-//#define I2C_STAT_TFFS BSP_BIT32(12)
-//#define I2C_STAT_TFES BSP_BIT32(13)
-
-/** @} */
-
-/**
- * @name I2C Control Register (I2Cn_CTRL)
- *
- * @{
- */
-
-//#define I2C_CTRL_TDIE BSP_BIT32(0)
-//#define I2C_CTRL_AFIE BSP_BIT32(1)
-//#define I2C_CTRL_NAIE BSP_BIT32(2)
-//#define I2C_CTRL_DRMIE BSP_BIT32(3)
-//#define I2C_CTRL_DRSIE BSP_BIT32(4)
-//#define I2C_CTRL_RFFIE BSP_BIT32(5)
-//#define I2C_CTRL_RFDAIE BSP_BIT32(6)
-//#define I2C_CTRL_TFFIO BSP_BIT32(7)
-//#define I2C_CTRL_RESET BSP_BIT32(8)
-//#define I2C_CTRL_SEVEN BSP_BIT32(9)
-//#define I2C_CTRL_TFFSIE BSP_BIT32(10)
-
-/** @} */
-
-/**
* @brief Initializes the I2C module @a i2c.
*
* Valid @a clock_in_hz values are 100000 and 400000.
@@ -444,8 +361,6 @@ static inline rtems_status_code beagle_i2c_read(
return beagle_i2c_write_and_read(i2c, addr, NULL, 0, in, in_size);
}
-/** @} */
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/c/src/lib/libbsp/arm/beagle/include/irq.h b/c/src/lib/libbsp/arm/beagle/include/irq.h
index c25939aa1c..4cbf3a271f 100644
--- a/c/src/lib/libbsp/arm/beagle/include/irq.h
+++ b/c/src/lib/libbsp/arm/beagle/include/irq.h
@@ -1,23 +1,9 @@
/**
* @file
*
- * @ingroup bsp_interrupt
+ * @ingroup arm_beagle
*
- * @brief Interrupt definitions.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * @brief Basic BSP IRQ info.
*/
#ifndef LIBBSP_ARM_BEAGLE_IRQ_H
@@ -29,170 +15,8 @@
#include <rtems/irq.h>
#include <rtems/irq-extension.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @addtogroup bsp_interrupt
- *
- * @{
- */
-
-#define BEAGLE_IRQ_INDEX(module, subindex) ((module) + (subindex))
-
-#define BEAGLE_IRQ_MODULE_MIC 0U
-#define BEAGLE_IRQ_MODULE_SIC_1 32U
-#define BEAGLE_IRQ_MODULE_SIC_2 64U
-#define BEAGLE_IRQ_MODULE_COUNT 3U
-
-/* MIC interrupts */
-#define BEAGLE_IRQ_SIC_1_IRQ BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 0)
-#define BEAGLE_IRQ_SIC_2_IRQ BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 1)
-#define BEAGLE_IRQ_TIMER_4_OR_MCPWM BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 3)
-#define BEAGLE_IRQ_TIMER_5 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 4)
-#define BEAGLE_IRQ_TIMER_HS BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 5)
-#define BEAGLE_IRQ_WDG BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 6)
-
-#define BEAGLE_IRQ_UART_3 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 7)
-#define BEAGLE_IRQ_UART_4 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 8)
-#define BEAGLE_IRQ_UART_5 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 9)
-#define BEAGLE_IRQ_UART_6 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 10)
-
-#define BEAGLE_IRQ_NAND_FLASH BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 11)
-#define BEAGLE_IRQ_SDCARD_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 13)
-#define BEAGLE_IRQ_LCD BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 14)
-#define BEAGLE_IRQ_SDCARD_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 15)
-#define BEAGLE_IRQ_TIMER_0 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 16)
-#define BEAGLE_IRQ_TIMER_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 17)
-#define BEAGLE_IRQ_TIMER_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 18)
-#define BEAGLE_IRQ_TIMER_3 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 19)
-#define BEAGLE_IRQ_SSP_0 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 20)
-#define BEAGLE_IRQ_SSP_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 21)
-#define BEAGLE_IRQ_I2S_0 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 22)
-#define BEAGLE_IRQ_I2S_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 23)
-
-#define BEAGLE_IRQ_UART_7 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 24)
-#define BEAGLE_IRQ_UART_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 25)
-#define BEAGLE_IRQ_UART_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 26)
-
-#define BEAGLE_IRQ_TIMER_MS BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 27)
-#define BEAGLE_IRQ_DMA BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 28)
-#define BEAGLE_IRQ_ETHERNET BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 29)
-#define BEAGLE_IRQ_SIC_1_FIQ BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 30)
-#define BEAGLE_IRQ_SIC_2_FIQ BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_MIC, 31)
-
-/* SIC 1 interrupts */
-#define BEAGLE_IRQ_JTAG_COMM_TX BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 1)
-#define BEAGLE_IRQ_JTAG_COMM_RX BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 2)
-#define BEAGLE_IRQ_GPI_28 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 4)
-#define BEAGLE_IRQ_TS_P BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 6)
-#define BEAGLE_IRQ_TS_IRQ_OR_ADC BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 7)
-#define BEAGLE_IRQ_TS_AUX BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 8)
-#define BEAGLE_IRQ_SPI_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 12)
-#define BEAGLE_IRQ_PLL_USB BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 13)
-#define BEAGLE_IRQ_PLL_HCLK BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 14)
-#define BEAGLE_IRQ_PLL_397 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 17)
-#define BEAGLE_IRQ_I2C_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 18)
-#define BEAGLE_IRQ_I2C_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 19)
-#define BEAGLE_IRQ_RTC BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 20)
-#define BEAGLE_IRQ_KEYSCAN BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 22)
-#define BEAGLE_IRQ_SPI_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 23)
-#define BEAGLE_IRQ_SW BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 24)
-#define BEAGLE_IRQ_USB_OTG_TIMER BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 25)
-#define BEAGLE_IRQ_USB_OTG_ATX BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 26)
-#define BEAGLE_IRQ_USB_HOST BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 27)
-#define BEAGLE_IRQ_USB_DEV_DMA BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 28)
-#define BEAGLE_IRQ_USB_DEV_LP BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 29)
-#define BEAGLE_IRQ_USB_DEV_HP BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 30)
-#define BEAGLE_IRQ_USB_I2C BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_1, 31)
-
-/* SIC 2 interrupts */
-#define BEAGLE_IRQ_GPIO_0 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 0)
-#define BEAGLE_IRQ_GPIO_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 1)
-#define BEAGLE_IRQ_GPIO_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 2)
-#define BEAGLE_IRQ_GPIO_3 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 3)
-#define BEAGLE_IRQ_GPIO_4 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 4)
-#define BEAGLE_IRQ_GPIO_5 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 5)
-#define BEAGLE_IRQ_SPI_2_DATAIN BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 6)
-
-#define BEAGLE_IRQ_UART_2_HCTS BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 7)
-
-#define BEAGLE_IRQ_GPIO_P0_P1_IRQ BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 8)
-#define BEAGLE_IRQ_GPI_8 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 9)
-#define BEAGLE_IRQ_GPI_9 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 10)
-#define BEAGLE_IRQ_GPI_19 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 11)
-
-#define BEAGLE_IRQ_UART_7_HCTS BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 12)
-
-#define BEAGLE_IRQ_GPI_7 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 15)
-#define BEAGLE_IRQ_SDIO BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 18)
-
-#define BEAGLE_IRQ_UART_5_RX BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 19)
-
-#define BEAGLE_IRQ_SPI_1_DATAIN BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 20)
-#define BEAGLE_IRQ_GPI_0 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 22)
-#define BEAGLE_IRQ_GPI_1 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 23)
-#define BEAGLE_IRQ_GPI_2 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 24)
-#define BEAGLE_IRQ_GPI_3 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 25)
-#define BEAGLE_IRQ_GPI_4 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 26)
-#define BEAGLE_IRQ_GPI_5 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 27)
-#define BEAGLE_IRQ_GPI_6 BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 28)
-#define BEAGLE_IRQ_SYSCLK BEAGLE_IRQ_INDEX(BEAGLE_IRQ_MODULE_SIC_2, 31)
-
-#define BEAGLE_IRQ_PRIORITY_VALUE_MIN 0U
-#define BEAGLE_IRQ_PRIORITY_VALUE_MAX 15U
-#define BEAGLE_IRQ_PRIORITY_COUNT (BEAGLE_IRQ_PRIORITY_VALUE_MAX + 1U)
-#define BEAGLE_IRQ_PRIORITY_HIGHEST BEAGLE_IRQ_PRIORITY_VALUE_MIN
-#define BEAGLE_IRQ_PRIORITY_LOWEST BEAGLE_IRQ_PRIORITY_VALUE_MAX
-
-#define BSP_INTERRUPT_VECTOR_MIN BEAGLE_IRQ_SIC_1_IRQ
-#define BSP_INTERRUPT_VECTOR_MAX BEAGLE_IRQ_SYSCLK
-
-#define BEAGLE_IRQ_COUNT (BSP_INTERRUPT_VECTOR_MAX + 1)
-
-void beagle_irq_set_priority(rtems_vector_number vector, unsigned priority);
-
-unsigned beagle_irq_get_priority(rtems_vector_number vector);
-
-typedef enum {
- BEAGLE_IRQ_ACTIVE_LOW_OR_FALLING_EDGE,
- BEAGLE_IRQ_ACTIVE_HIGH_OR_RISING_EDGE
-} beagle_irq_activation_polarity;
-
-void beagle_irq_set_activation_polarity(
- rtems_vector_number vector,
- beagle_irq_activation_polarity activation_polarity
-);
-
-beagle_irq_activation_polarity beagle_irq_get_activation_polarity(
- rtems_vector_number vector
-);
-
-typedef enum {
- BEAGLE_IRQ_LEVEL_SENSITIVE,
- BEAGLE_IRQ_EDGE_SENSITIVE
-} beagle_irq_activation_type;
-
-void beagle_irq_set_activation_type(
- rtems_vector_number vector,
- beagle_irq_activation_type activation_type
-);
-
-beagle_irq_activation_type beagle_irq_get_activation_type(
- rtems_vector_number vector
-);
-
-void beagle_set_exception_handler(
- Arm_symbolic_exception_name exception,
- void (*handler)(void)
-);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+#define BSP_INTERRUPT_VECTOR_MIN 0
+#define BSP_INTERRUPT_VECTOR_MAX 127
#endif /* ASM */
diff --git a/c/src/lib/libbsp/arm/beagle/irq.c b/c/src/lib/libbsp/arm/beagle/irq.c
new file mode 100644
index 0000000000..063034498b
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/irq.c
@@ -0,0 +1,142 @@
+/**
+ * @file
+ *
+ * @ingroup bsp_interrupt
+ * @ingroup arm_beagle
+ *
+ * @brief Interrupt support.
+ */
+
+/*
+ * Copyright (c) 2014 Ben Gras <beng@shrike-systems.com>. All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <bsp.h>
+#include <bsp/irq-generic.h>
+#include <bsp/linker-symbols.h>
+
+#include <rtems/score/armv4.h>
+
+#include <libcpu/arm-cp15.h>
+
+struct omap_intr
+{
+ uint32_t base;
+ int size;
+};
+
+#if IS_DM3730
+static struct omap_intr omap_intr = {
+ .base = OMAP3_DM37XX_INTR_BASE,
+ .size = 0x1000,
+};
+#endif
+
+#if IS_AM335X
+static struct omap_intr omap_intr = {
+ .base = OMAP3_AM335X_INTR_BASE,
+ .size = 0x1000,
+};
+#endif
+
+static int irqs_enabled[BSP_INTERRUPT_VECTOR_MAX+1];
+
+volatile static int level = 0;
+
+void bsp_interrupt_dispatch(void)
+{
+ /* get irq */
+ uint32_t reg = mmio_read(omap_intr.base + OMAP3_INTCPS_SIR_IRQ);
+ int irq;
+ irq = reg & OMAP3_INTR_ACTIVEIRQ_MASK;
+
+ if(!irqs_enabled[irq]) {
+ /* Ignore spurious interrupt */
+ } else {
+ bsp_interrupt_vector_disable(irq);
+
+ /* enable new interrupts, and flush data cache to make sure
+ * it hits the intc
+ */
+ mmio_write(omap_intr.base + OMAP3_INTCPS_CONTROL, OMAP3_INTR_NEWIRQAGR);
+ flush_data_cache();
+ mmio_read(omap_intr.base + OMAP3_INTCPS_SIR_IRQ);
+ flush_data_cache();
+
+ /* keep current irq masked but enable unmasked ones */
+ uint32_t psr = _ARMV4_Status_irq_enable();
+ bsp_interrupt_handler_dispatch(irq);
+
+ _ARMV4_Status_restore(psr);
+
+ bsp_interrupt_vector_enable(irq);
+ }
+}
+
+static uint32_t get_mir_reg(int vector, uint32_t *mask)
+{
+ *mask = 1UL << (vector % 32);
+
+ if(vector < 0) while(1) ;
+ if(vector < 32) return OMAP3_INTCPS_MIR0;
+ if(vector < 64) return OMAP3_INTCPS_MIR1;
+ if(vector < 96) return OMAP3_INTCPS_MIR2;
+ if(vector < 128) return OMAP3_INTCPS_MIR3;
+ while(1) ;
+}
+
+rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
+{
+ uint32_t mask, cur;
+ uint32_t mir_reg = get_mir_reg(vector, &mask);
+
+ cur = mmio_read(omap_intr.base + mir_reg);
+ mmio_write(omap_intr.base + mir_reg, cur & ~mask);
+ flush_data_cache();
+
+ irqs_enabled[vector] = 1;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
+{
+ uint32_t mask, cur;
+ uint32_t mir_reg = get_mir_reg(vector, &mask);
+
+ cur = mmio_read(omap_intr.base + mir_reg);
+ mmio_write(omap_intr.base + mir_reg, cur | mask);
+ flush_data_cache();
+
+ irqs_enabled[vector] = 0;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code bsp_interrupt_facility_initialize(void)
+{
+ int i;
+ uint32_t intc_ilrx;
+
+ /* AM335X TRM 6.2.1 Initialization Sequence */
+ mmio_write(omap_intr.base + OMAP3_INTCPS_SYSCONFIG, OMAP3_SYSCONFIG_AUTOIDLE);
+ mmio_write(omap_intr.base + OMAP3_INTCPS_IDLE, 0);
+ /* priority 0 to all IRQs */
+ for(intc_ilrx = 0x100; intc_ilrx <= 0x2fc; intc_ilrx += 4) {
+ mmio_write(omap_intr.base + intc_ilrx, 0);
+ }
+
+ /* Mask all interrupts */
+ for(i = BSP_INTERRUPT_VECTOR_MIN; i <= BSP_INTERRUPT_VECTOR_MAX; i++)
+ bsp_interrupt_vector_disable(i);
+
+ /* Install generic interrupt handler */
+ arm_cp15_set_exception_handler(ARM_EXCEPTION_IRQ, _ARMV4_Exception_interrupt);
+ arm_cp15_set_vector_base_address((uint32_t) bsp_vector_table_begin);
+
+ return RTEMS_SUCCESSFUL;
+}
diff --git a/c/src/lib/libbsp/arm/beagle/irq/irq.c b/c/src/lib/libbsp/arm/beagle/irq/irq.c
deleted file mode 100644
index 0d58ae4213..0000000000
--- a/c/src/lib/libbsp/arm/beagle/irq/irq.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/**
- * @file
- *
- * @ingroup bsp_interrupt
- *
- * @brief Interrupt support.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <bsp/irq.h>
-#include <bsp/irq-generic.h>
-#include <bsp/beagle.h>
-#include <bsp/linker-symbols.h>
-
-/*
- * Mask out SIC 1 and 2 IRQ request. There is no need to mask out the FIQ,
- * since a pending FIQ would be a fatal error. The default handler will be
- * invoked in this case.
- */
-#define BEAGLE_MIC_STATUS_MASK (~0x3U)
-
-typedef union {
- struct {
- uint32_t mic;
- uint32_t sic_1;
- uint32_t sic_2;
- } field;
- uint32_t fields_table [BEAGLE_IRQ_MODULE_COUNT];
-} beagle_irq_fields;
-
-static uint8_t beagle_irq_priority_table [BEAGLE_IRQ_COUNT];
-
-static beagle_irq_fields beagle_irq_priority_masks [BEAGLE_IRQ_PRIORITY_COUNT];
-
-static beagle_irq_fields beagle_irq_enable;
-
-static inline bool beagle_irq_is_valid(rtems_vector_number vector)
-{
- printk( "beagle_irq_is_valid" );
- return vector <= BSP_INTERRUPT_VECTOR_MAX;
-}
-
-static inline bool beagle_irq_priority_is_valid(unsigned priority)
-{
- printk( "beagle_irq_priority_is_valid" );
- return priority <= BEAGLE_IRQ_PRIORITY_LOWEST;
-}
-
-#define BEAGLE_IRQ_BIT_OPS_DEFINE \
- unsigned bit = index & 0x1fU; \
- unsigned module = index >> 5
-
-#define BEAGLE_IRQ_BIT_OPS_FOR_REG_DEFINE \
- BEAGLE_IRQ_BIT_OPS_DEFINE; \
- unsigned module_offset = module << 14; \
- volatile uint32_t *reg = (volatile uint32_t *) \
- ((volatile char *) &beagle.mic + module_offset + register_offset)
-
-#define BEAGLE_IRQ_OFFSET_ER 0U
-#define BEAGLE_IRQ_OFFSET_RSR 4U
-#define BEAGLE_IRQ_OFFSET_SR 8U
-#define BEAGLE_IRQ_OFFSET_APR 12U
-#define BEAGLE_IRQ_OFFSET_ATR 16U
-#define BEAGLE_IRQ_OFFSET_ITR 20U
-
-static inline bool beagle_irq_is_bit_set_in_register(
- unsigned index,
- unsigned register_offset
-)
-{
- printk( "beagle_irq_is_bit_set_in_register" );
- BEAGLE_IRQ_BIT_OPS_FOR_REG_DEFINE;
- return *reg & (1U << bit);
-}
-
-static inline void beagle_irq_set_bit_in_register(
- unsigned index,
- unsigned register_offset
-)
-{
- printk( "beagle_irq_set_bit_in_register" );
- BEAGLE_IRQ_BIT_OPS_FOR_REG_DEFINE;
-
- *reg |= 1U << bit;
-}
-
-static inline void beagle_irq_clear_bit_in_register(
- unsigned index,
- unsigned register_offset
-)
-{
- printk( "beagle_irq_clear_bit_in_register" );
- BEAGLE_IRQ_BIT_OPS_FOR_REG_DEFINE;
-
- *reg &= ~(1U << bit);
-}
-
-static inline void beagle_irq_set_bit_in_field(
- unsigned index,
- beagle_irq_fields *fields
-)
-{
- printk( "beagle_irq_set_bit_in_field" );
- BEAGLE_IRQ_BIT_OPS_DEFINE;
-
- fields->fields_table [module] |= 1U << bit;
-}
-
-static inline void beagle_irq_clear_bit_in_field(
- unsigned index,
- beagle_irq_fields *fields
-)
-{
- printk( "beagle_irq_clear_bit_in_field" );
- BEAGLE_IRQ_BIT_OPS_DEFINE;
-
- fields->fields_table [module] &= ~(1U << bit);
-}
-
-static inline unsigned beagle_irq_get_index(uint32_t val)
-{
- printk( "beagle_irq_get_index" );
- ARM_SWITCH_REGISTERS;
-
- __asm__ volatile (
- ARM_SWITCH_TO_ARM
- "clz %[val], %[val]\n"
- "rsb %[val], %[val], #31\n"
- ARM_SWITCH_BACK
- : [val] "=r" (val) ARM_SWITCH_ADDITIONAL_OUTPUT
- : "[val]" (val)
- );
-
- return val;
-}
-
-void beagle_irq_set_priority(rtems_vector_number vector, unsigned priority)
-{
- printk( "beagle_irq_set_priority" );
- if (beagle_irq_is_valid(vector)) {
- rtems_interrupt_level level;
- unsigned i = 0;
-
- if (priority > BEAGLE_IRQ_PRIORITY_LOWEST) {
- priority = BEAGLE_IRQ_PRIORITY_LOWEST;
- }
-
- beagle_irq_priority_table [vector] = (uint8_t) priority;
-
- for (i = BEAGLE_IRQ_PRIORITY_HIGHEST; i <= priority; ++i) {
- rtems_interrupt_disable(level);
- beagle_irq_clear_bit_in_field(vector, &beagle_irq_priority_masks [i]);
- rtems_interrupt_enable(level);
- }
-
- for (i = priority + 1; i <= BEAGLE_IRQ_PRIORITY_LOWEST; ++i) {
- rtems_interrupt_disable(level);
- beagle_irq_set_bit_in_field(vector, &beagle_irq_priority_masks [i]);
- rtems_interrupt_enable(level);
- }
- }
-}
-
-unsigned beagle_irq_get_priority(rtems_vector_number vector)
-{
- printk( "beagle_irq_get_priority" );
- if (beagle_irq_is_valid(vector)) {
- return beagle_irq_priority_table [vector];
- } else {
- return BEAGLE_IRQ_PRIORITY_LOWEST;
- }
-}
-
-void beagle_irq_set_activation_polarity(
- rtems_vector_number vector,
- beagle_irq_activation_polarity activation_polarity
-)
-{
- printk( "beagle_irq_set_activation_polarity" );
- if (beagle_irq_is_valid(vector)) {
- rtems_interrupt_level level;
-
- rtems_interrupt_disable(level);
- if (activation_polarity == BEAGLE_IRQ_ACTIVE_HIGH_OR_RISING_EDGE) {
- beagle_irq_set_bit_in_register(vector, BEAGLE_IRQ_OFFSET_APR);
- } else {
- beagle_irq_clear_bit_in_register(vector, BEAGLE_IRQ_OFFSET_APR);
- }
- rtems_interrupt_enable(level);
- }
-}
-
-beagle_irq_activation_polarity beagle_irq_get_activation_polarity(
- rtems_vector_number vector
-)
-{
- printk( "beagle_irq_get_activation_polarity" );
- if (beagle_irq_is_valid(vector)) {
- if (beagle_irq_is_bit_set_in_register(vector, BEAGLE_IRQ_OFFSET_APR)) {
- return BEAGLE_IRQ_ACTIVE_HIGH_OR_RISING_EDGE;
- } else {
- return BEAGLE_IRQ_ACTIVE_LOW_OR_FALLING_EDGE;
- }
- } else {
- return BEAGLE_IRQ_ACTIVE_LOW_OR_FALLING_EDGE;
- }
-}
-
-void beagle_irq_set_activation_type(
- rtems_vector_number vector,
- beagle_irq_activation_type activation_type
-)
-{
- printk( "beagle_irq_set_activation_type" );
- if (beagle_irq_is_valid(vector)) {
- rtems_interrupt_level level;
-
- rtems_interrupt_disable(level);
- if (activation_type == BEAGLE_IRQ_EDGE_SENSITIVE) {
- beagle_irq_set_bit_in_register(vector, BEAGLE_IRQ_OFFSET_ATR);
- } else {
- beagle_irq_clear_bit_in_register(vector, BEAGLE_IRQ_OFFSET_ATR);
- }
- rtems_interrupt_enable(level);
- }
-}
-
-beagle_irq_activation_type beagle_irq_get_activation_type(
- rtems_vector_number vector
-)
-{
- printk( "beagle_irq_get_activation_type" );
- if (beagle_irq_is_valid(vector)) {
- if (beagle_irq_is_bit_set_in_register(vector, BEAGLE_IRQ_OFFSET_ATR)) {
- return BEAGLE_IRQ_EDGE_SENSITIVE;
- } else {
- return BEAGLE_IRQ_LEVEL_SENSITIVE;
- }
- } else {
- return BEAGLE_IRQ_LEVEL_SENSITIVE;
- }
-}
-
-void bsp_interrupt_dispatch(void)
-{
- printk( "bsp_interrupt_dispatch" );
-
- uint32_t status = beagle.mic.sr & BEAGLE_MIC_STATUS_MASK;
- uint32_t er_mic = beagle.mic.er;
- uint32_t er_sic_1 = beagle.sic_1.er;
- uint32_t er_sic_2 = beagle.sic_2.er;
- uint32_t psr = 0;
- beagle_irq_fields *masks = NULL;
- rtems_vector_number vector = 0;
- unsigned priority = 0;
-
- if (status != 0) {
- vector = beagle_irq_get_index(status);
- } else {
- status = beagle.sic_1.sr;
- if (status != 0) {
- vector = beagle_irq_get_index(status) + BEAGLE_IRQ_MODULE_SIC_1;
- } else {
- status = beagle.sic_2.sr;
- if (status != 0) {
- vector = beagle_irq_get_index(status) + BEAGLE_IRQ_MODULE_SIC_2;
- } else {
- return;
- }
- }
- }
-
- priority = beagle_irq_priority_table [vector];
-
- masks = &beagle_irq_priority_masks [priority];
-
- beagle.mic.er = er_mic & masks->field.mic;
- beagle.sic_1.er = er_sic_1 & masks->field.sic_1;
- beagle.sic_2.er = er_sic_2 & masks->field.sic_2;
-
-#if 0
- psr = arm_status_irq_enable();
-#endif
-
- bsp_interrupt_handler_dispatch(vector);
-
-#if 0
- arm_status_restore(psr);
-#endif
-
- beagle.mic.er = er_mic & beagle_irq_enable.field.mic;
- beagle.sic_1.er = er_sic_1 & beagle_irq_enable.field.sic_1;
- beagle.sic_2.er = er_sic_2 & beagle_irq_enable.field.sic_2;
-}
-
-rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
-{
- printk( "bsp_interrupt_vector_enable" );
- rtems_interrupt_level level;
-
- rtems_interrupt_disable(level);
- beagle_irq_set_bit_in_register(vector, BEAGLE_IRQ_OFFSET_ER);
- beagle_irq_set_bit_in_field(vector, &beagle_irq_enable);
- rtems_interrupt_enable(level);
-
- return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
-{
- printk( "bsp_interrupt_vector_disable" );
- rtems_interrupt_level level;
-
- rtems_interrupt_disable(level);
- beagle_irq_clear_bit_in_field(vector, &beagle_irq_enable);
- beagle_irq_clear_bit_in_register(vector, BEAGLE_IRQ_OFFSET_ER);
- rtems_interrupt_enable(level);
-
- return RTEMS_SUCCESSFUL;
-}
-
-void beagle_set_exception_handler(
- Arm_symbolic_exception_name exception,
- void (*handler)(void)
-)
-{
- printk( "beagle_set_exception_handler" );
- if ((unsigned) exception < MAX_EXCEPTIONS) {
- uint32_t *table = (uint32_t *) bsp_vector_table_begin + MAX_EXCEPTIONS;
-
- table [exception] = (uint32_t) handler;
-
- #ifndef BEAGLE_DISABLE_MMU
- rtems_cache_flush_multiple_data_lines(table, 64);
- rtems_cache_invalidate_multiple_instruction_lines(NULL, 64);
- #endif
- }
-}
-
-rtems_status_code bsp_interrupt_facility_initialize(void)
-{
- printk( "bsp_interrupt_facility_initialize" );
- size_t i = 0;
-
- /* Set default priority */
- for (i = 0; i < BEAGLE_IRQ_COUNT; ++i) {
- beagle_irq_priority_table [i] = BEAGLE_IRQ_PRIORITY_LOWEST;
- }
-
- /* Enable SIC 1 and 2 at all priorities */
- for (i = 0; i < BEAGLE_IRQ_PRIORITY_COUNT; ++i) {
- beagle_irq_priority_masks [i].field.mic = 0xc0000003;
- }
-
- /* Disable all interrupts except SIC 1 and 2 */
- beagle_irq_enable.field.sic_2 = 0x0;
- beagle_irq_enable.field.sic_1 = 0x0;
- beagle_irq_enable.field.mic = 0xc0000003;
- beagle.sic_1.er = 0x0;
- beagle.sic_2.er = 0x0;
- beagle.mic.er = 0xc0000003;
-
- /* Set interrupt types to IRQ */
- beagle.mic.itr = 0x0;
- beagle.sic_1.itr = 0x0;
- beagle.sic_2.itr = 0x0;
-
- /* Set interrupt activation polarities */
- beagle.mic.apr = 0x3ff0efe0;
- beagle.sic_1.apr = 0xfbd27184;
- beagle.sic_2.apr = 0x801810c0;
-
- /* Set interrupt activation types */
- beagle.mic.atr = 0x0;
- beagle.sic_1.atr = 0x26000;
- beagle.sic_2.atr = 0x0;
-
-#if 0
- beagle_set_exception_handler(ARM_EXCEPTION_IRQ, arm_exc_interrupt);
-#endif
-
- return RTEMS_SUCCESSFUL;
-}
diff --git a/c/src/lib/libbsp/arm/beagle/make/custom/beagleboardorig.cfg b/c/src/lib/libbsp/arm/beagle/make/custom/beagleboardorig.cfg
new file mode 100644
index 0000000000..447a51e9f6
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/make/custom/beagleboardorig.cfg
@@ -0,0 +1,2 @@
+# Config file for Original BeagleBoard
+include $(RTEMS_ROOT)/make/custom/beagle.inc
diff --git a/c/src/lib/libbsp/arm/beagle/make/custom/beagle.cfg b/c/src/lib/libbsp/arm/beagle/make/custom/beagleboardxm.cfg
index 06c13ee0e6..ec0d2d2bd8 100644
--- a/c/src/lib/libbsp/arm/beagle/make/custom/beagle.cfg
+++ b/c/src/lib/libbsp/arm/beagle/make/custom/beagleboardxm.cfg
@@ -1,5 +1,2 @@
-#
-# Config file for BeagleBoard
-#
-
+# Config file for BeagleBoard XM
include $(RTEMS_ROOT)/make/custom/beagle.inc
diff --git a/c/src/lib/libbsp/arm/beagle/make/custom/beagleboneblack.cfg b/c/src/lib/libbsp/arm/beagle/make/custom/beagleboneblack.cfg
new file mode 100644
index 0000000000..f947dcef29
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/make/custom/beagleboneblack.cfg
@@ -0,0 +1,2 @@
+# Config file for BeagleBone Black
+include $(RTEMS_ROOT)/make/custom/beagle.inc
diff --git a/c/src/lib/libbsp/arm/beagle/make/custom/beaglebonewhite.cfg b/c/src/lib/libbsp/arm/beagle/make/custom/beaglebonewhite.cfg
new file mode 100644
index 0000000000..4b035c031e
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/make/custom/beaglebonewhite.cfg
@@ -0,0 +1,2 @@
+# Config file for Original BeagleBone (aka BeagleBone White)
+include $(RTEMS_ROOT)/make/custom/beagle.inc
diff --git a/c/src/lib/libbsp/arm/beagle/misc/boot.c b/c/src/lib/libbsp/arm/beagle/misc/boot.c
deleted file mode 100644
index 771df7007d..0000000000
--- a/c/src/lib/libbsp/arm/beagle/misc/boot.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle_boot
- *
- * @brief Boot support implementation.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <string.h>
-
-#include <bsp/boot.h>
-
-void beagle_setup_boot_block(
- beagle_boot_block *boot_block,
- uint8_t icr,
- uint8_t page_count
-)
-{
- memset(boot_block, 0, sizeof(*boot_block));
-
- ++page_count;
-
- boot_block->field.d0 = icr;
- boot_block->field.d2 = icr;
- boot_block->field.d4 = page_count;
- boot_block->field.d6 = page_count;
- boot_block->field.d8 = page_count;
- boot_block->field.d10 = page_count;
-
- icr = (uint8_t) ~((unsigned) icr);
- page_count = (uint8_t) ~((unsigned) page_count);
-
- boot_block->field.d1 = icr;
- boot_block->field.d3 = icr;
- boot_block->field.d5 = page_count;
- boot_block->field.d7 = page_count;
- boot_block->field.d9 = page_count;
- boot_block->field.d11 = page_count;
-
- boot_block->field.d12 = 0xaa;
-}
-
-void beagle_set_boot_block_bad(
- beagle_boot_block *boot_block
-)
-{
- boot_block->field.d12 = 0;
-}
diff --git a/c/src/lib/libbsp/arm/beagle/misc/i2c.c b/c/src/lib/libbsp/arm/beagle/misc/i2c.c
index 322c501d3c..ad23f3a2ac 100644
--- a/c/src/lib/libbsp/arm/beagle/misc/i2c.c
+++ b/c/src/lib/libbsp/arm/beagle/misc/i2c.c
@@ -1,7 +1,7 @@
/**
* @file
*
- * @ingroup beagle_i2c
+ * @ingroup arm_beagle
*
* @brief I2C support implementation.
*/
diff --git a/c/src/lib/libbsp/arm/beagle/misc/restart.c b/c/src/lib/libbsp/arm/beagle/misc/restart.c
deleted file mode 100644
index fe7775ae06..0000000000
--- a/c/src/lib/libbsp/arm/beagle/misc/restart.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief Restart implementation.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <rtems.h>
-
-#include <libcpu/arm-cp15.h>
-
-#include <bsp.h>
-
-void bsp_restart(void *addr)
-{
- BEAGLE_DO_RESTART(addr);
-}
diff --git a/c/src/lib/libbsp/arm/beagle/misc/system-clocks.c b/c/src/lib/libbsp/arm/beagle/misc/system-clocks.c
deleted file mode 100644
index 56b5d9aadb..0000000000
--- a/c/src/lib/libbsp/arm/beagle/misc/system-clocks.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief System clocks.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <bsp/beagle.h>
-
-uint32_t beagle_sysclk(void)
-{
- uint32_t sysclk_ctrl = BEAGLE_SYSCLK_CTRL;
-
- return (sysclk_ctrl & 0x1) == 0 ?
- BEAGLE_OSCILLATOR_MAIN
- : (397 * BEAGLE_OSCILLATOR_RTC);
-}
-
-uint32_t beagle_hclkpll_clk(void)
-{
- uint32_t sysclk = beagle_sysclk();
- uint32_t hclkpll_ctrl = BEAGLE_HCLKPLL_CTRL;
- uint32_t m = HCLK_PLL_M_GET(hclkpll_ctrl) + 1;
- uint32_t n = HCLK_PLL_N_GET(hclkpll_ctrl) + 1;
- uint32_t p = 1U << HCLK_PLL_P_GET(hclkpll_ctrl);
- uint32_t hclkpll_clk = 0;
-
- if ((hclkpll_ctrl & HCLK_PLL_BYPASS) != 0) {
- if ((hclkpll_ctrl & HCLK_PLL_DIRECT) != 0) {
- hclkpll_clk = sysclk;
- } else {
- hclkpll_clk = sysclk / (2 * p);
- }
- } else {
- if ((hclkpll_ctrl & HCLK_PLL_DIRECT) != 0) {
- hclkpll_clk = (m * sysclk) / n;
- } else {
- if ((hclkpll_ctrl & HCLK_PLL_FBD_FCLKOUT) != 0) {
- hclkpll_clk = m * (sysclk / n);
- } else {
- hclkpll_clk = (m / (2 * p)) * (sysclk / n);
- }
- }
- }
-
- return hclkpll_clk;
-}
-
-uint32_t beagle_periph_clk(void)
-{
- uint32_t pwr_ctrl = BEAGLE_PWR_CTRL;
- uint32_t periph_clk = 0;
-
- if ((pwr_ctrl & PWR_NORMAL_RUN_MODE) != 0) {
- uint32_t hclkdiv_ctrl = BEAGLE_HCLKDIV_CTRL;
- uint32_t div = HCLK_DIV_PERIPH_CLK_GET(hclkdiv_ctrl) + 1;
-
- periph_clk = beagle_hclkpll_clk() / div;
- } else {
- periph_clk = beagle_sysclk();
- }
-
- return periph_clk;
-}
-
-uint32_t beagle_hclk(void)
-{
- uint32_t pwr_ctrl = BEAGLE_PWR_CTRL;
- uint32_t hclk = 0;
-
- if ((pwr_ctrl & PWR_HCLK_USES_PERIPH_CLK) != 0) {
- hclk = beagle_periph_clk();
- } else {
- if ((pwr_ctrl & PWR_NORMAL_RUN_MODE) != 0) {
- uint32_t hclkdiv_ctrl = BEAGLE_HCLKDIV_CTRL;
- uint32_t div = 1U << HCLK_DIV_HCLK_GET(hclkdiv_ctrl);
-
- hclk = beagle_hclkpll_clk() / div;
- } else {
- hclk = beagle_sysclk();
- }
- }
-
- return hclk;
-}
-
-uint32_t beagle_arm_clk(void)
-{
- uint32_t pwr_ctrl = BEAGLE_PWR_CTRL;
- uint32_t arm_clk = 0;
-
- if ((pwr_ctrl & PWR_HCLK_USES_PERIPH_CLK) != 0) {
- arm_clk = beagle_periph_clk();
- } else {
- if ((pwr_ctrl & PWR_NORMAL_RUN_MODE) != 0) {
- arm_clk = beagle_hclkpll_clk();
- } else {
- arm_clk = beagle_sysclk();
- }
- }
-
- return arm_clk;
-}
-
-uint32_t beagle_dram_clk(void)
-{
- uint32_t hclkdiv_ctrl = BEAGLE_HCLKDIV_CTRL;
- uint32_t div = HCLK_DIV_DDRAM_CLK_GET(hclkdiv_ctrl);
- uint32_t dram_clk = 0;
-
- if (div != 0) {
- uint32_t pwr_ctrl = BEAGLE_PWR_CTRL;
-
- if ((pwr_ctrl & PWR_NORMAL_RUN_MODE) != 0) {
- dram_clk = beagle_hclkpll_clk();
- } else {
- dram_clk = beagle_sysclk();
- }
-
- dram_clk /= div;
- }
-
- return dram_clk;
-}
diff --git a/c/src/lib/libbsp/arm/beagle/misc/timer.c b/c/src/lib/libbsp/arm/beagle/misc/timer.c
deleted file mode 100644
index 50570e0b00..0000000000
--- a/c/src/lib/libbsp/arm/beagle/misc/timer.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief Benchmark timer support.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <rtems.h>
-#include <rtems/btimer.h>
-#include <rtems/timerdrv.h>
-
-#include <bsp.h>
-
-static uint32_t benchmark_timer_base;
-
-void benchmark_timer_initialize(void)
-{
- benchmark_timer_base = beagleboard_timer();
-}
-
-uint32_t benchmark_timer_read(void)
-{
- return beagleboard_timer() - benchmark_timer_base;
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(
- bool find_average_overhead
-)
-{
- /* VOID */
-}
diff --git a/c/src/lib/libbsp/arm/beagle/preinstall.am b/c/src/lib/libbsp/arm/beagle/preinstall.am
index f6823b3dea..bfae8d5a53 100644
--- a/c/src/lib/libbsp/arm/beagle/preinstall.am
+++ b/c/src/lib/libbsp/arm/beagle/preinstall.am
@@ -8,15 +8,15 @@ endif
PREINSTALL_DIRS =
DISTCLEANFILES += $(PREINSTALL_DIRS)
-all-local: $(TMPINSTALL_FILES)
-
-TMPINSTALL_FILES =
-CLEANFILES = $(TMPINSTALL_FILES)
-
all-am: $(PREINSTALL_FILES)
PREINSTALL_FILES =
-CLEANFILES += $(PREINSTALL_FILES)
+CLEANFILES = $(PREINSTALL_FILES)
+
+all-local: $(TMPINSTALL_FILES)
+
+TMPINSTALL_FILES =
+CLEANFILES += $(TMPINSTALL_FILES)
$(PROJECT_LIB)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_LIB)
@@ -46,6 +46,10 @@ $(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
+$(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
+
$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
@@ -78,9 +82,21 @@ $(PROJECT_INCLUDE)/bsp/uart-output-char.h: ../../shared/include/uart-output-char
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/uart-output-char.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/uart-output-char.h
-$(PROJECT_INCLUDE)/bsp/tod.h: ../../shared/tod.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/tod.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/tod.h
+$(PROJECT_INCLUDE)/bsp/arm-a8core-start.h: ../shared/include/arm-a8core-start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-a8core-start.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-a8core-start.h
+
+$(PROJECT_INCLUDE)/bsp/arm-cp15-start.h: ../shared/include/arm-cp15-start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
+
+$(PROJECT_INCLUDE)/bsp/arm-errata.h: ../shared/include/arm-errata.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-errata.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-errata.h
+
+$(PROJECT_INCLUDE)/bsp/arm-release-id.h: ../shared/include/arm-release-id.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-release-id.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-release-id.h
$(PROJECT_INCLUDE)/bsp/start.h: ../shared/include/start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/start.h
@@ -90,22 +106,6 @@ $(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
-$(PROJECT_INCLUDE)/bsp/beagle.h: include/beagle.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/beagle.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/beagle.h
-
-$(PROJECT_INCLUDE)/bsp/beagle-clock-config.h: include/beagle-clock-config.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/beagle-clock-config.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/beagle-clock-config.h
-
-$(PROJECT_INCLUDE)/bsp/beagle-timer.h: include/beagle-timer.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/beagle-timer.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/beagle-timer.h
-
-$(PROJECT_INCLUDE)/bsp/boot.h: include/boot.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/boot.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/boot.h
-
$(PROJECT_INCLUDE)/bsp/i2c.h: include/i2c.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/i2c.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/i2c.h
@@ -114,6 +114,18 @@ $(PROJECT_INCLUDE)/libcpu/arm-cp15.h: ../../../libcpu/arm/shared/include/arm-cp1
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
+$(PROJECT_INCLUDE)/libcpu/omap3.h: ../../../libcpu/arm/shared/include/omap3.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/omap3.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/omap3.h
+
+$(PROJECT_INCLUDE)/libcpu/am335x.h: ../../../libcpu/arm/shared/include/am335x.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/am335x.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/am335x.h
+
+$(PROJECT_INCLUDE)/libcpu/omap_timer.h: ../../../libcpu/arm/shared/include/omap_timer.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/omap_timer.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/omap_timer.h
+
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
diff --git a/c/src/lib/libbsp/arm/beagle/rtc/rtc-config.c b/c/src/lib/libbsp/arm/beagle/rtc/rtc-config.c
deleted file mode 100644
index 903826669d..0000000000
--- a/c/src/lib/libbsp/arm/beagle/rtc/rtc-config.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief RTC configuration.
- */
-
-/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#include <libchip/rtc.h>
-
-#include <bsp.h>
-#include <bsp/beagle.h>
-
-#define BEAGLE_RTC_COUNT 1U
-
-#define BEAGLE_RTC_COUNTER_DELTA 0xfffffffeU
-
-#define BEAGLE_RTC_KEY 0xb5c13f27U
-
-#define BEAGLE_RTC_CTRL_FORCE_ONSW (1U << 7)
-#define BEAGLE_RTC_CTRL_STOP (1U << 6)
-#define BEAGLE_RTC_CTRL_RESET (1U << 4)
-#define BEAGLE_RTC_CTRL_MATCH_1_ONSW (1U << 3)
-#define BEAGLE_RTC_CTRL_MATCH_0_ONSW (1U << 2)
-#define BEAGLE_RTC_CTRL_MATCH_1_INTR (1U << 1)
-#define BEAGLE_RTC_CTRL_MATCH_0_INTR (1U << 0)
-
-static void beagle_rtc_set( uint32_t val ) {
- unsigned i = beagle_arm_clk() / BEAGLE_OSCILLATOR_RTC;
-
- //beagle.rtc.ctrl |= BEAGLE_RTC_CTRL_STOP;
- //beagle.rtc.ucount = val;
- //beagle.rtc.dcount = BEAGLE_RTC_COUNTER_DELTA - val;
- //beagle.rtc.ctrl &= ~BEAGLE_RTC_CTRL_STOP;
-
- /* It needs some time before we can read the values back */
- while( i != 0 ) {
- __asm__ volatile( "nop" );
- --i;
- }
-}
-
-static void beagle_rtc_reset( void ) {
- //beagle.rtc.ctrl = BEAGLE_RTC_CTRL_RESET;
- //beagle.rtc.ctrl = 0;
- //beagle.rtc.key = BEAGLE_RTC_KEY;
- beagle_rtc_set( 0 );
-}
-
-static void beagle_rtc_initialize( int minor ) {
- uint32_t up_first = 0;
- uint32_t up_second = 0;
- uint32_t down_first = 0;
- uint32_t down_second = 0;
-
- //if( beagle.rtc.key != BEAGLE_RTC_KEY ) {
- // beagle_rtc_reset();
- //}
-
- do {
- //up_first = beagle.rtc.ucount;
- //down_first = beagle.rtc.dcount;
- //up_second = beagle.rtc.ucount;
- //down_second = beagle.rtc.dcount;
- } while( up_first != up_second || down_first != down_second );
-
- if( up_first + down_first != BEAGLE_RTC_COUNTER_DELTA ) {
- beagle_rtc_reset();
- }
-}
-
-static int beagle_rtc_get_time( int minor, rtems_time_of_day *tod ) {
- struct timeval now = {
- //.tv_sec = beagle.rtc.ucount,
- .tv_usec = 0
- };
- struct tm time;
-
- gmtime_r( &now.tv_sec, &time );
-
- tod->year = time.tm_year + 1900;
- tod->month = time.tm_mon + 1;
- tod->day = time.tm_mday;
- tod->hour = time.tm_hour;
- tod->minute = time.tm_min;
- tod->second = time.tm_sec;
- tod->ticks = 0;
-
- return RTEMS_SUCCESSFUL;
-}
-
-static int beagle_rtc_set_time( int minor, const rtems_time_of_day *tod ) {
- beagle_rtc_set( _TOD_To_seconds( tod ) );
-
- return 0;
-}
-
-static bool beagle_rtc_probe( int minor ) {
- return true;
-}
-
-const rtc_fns beagle_rtc_ops = {
- .deviceInitialize = beagle_rtc_initialize,
- .deviceGetTime = beagle_rtc_get_time,
- .deviceSetTime = beagle_rtc_set_time
-};
-
-size_t RTC_Count = BEAGLE_RTC_COUNT;
-
-rtems_device_minor_number RTC_Minor = 0;
-
-rtc_tbl RTC_Table [BEAGLE_RTC_COUNT] = {
- {
- .sDeviceName = "/dev/rtc",
- .deviceType = RTC_CUSTOM,
- .pDeviceFns = &beagle_rtc_ops,
- .deviceProbe = beagle_rtc_probe,
- .pDeviceParams = NULL,
- .ulCtrlPort1 = 0,
- .ulDataPort = 0,
- .getRegister = NULL,
- .setRegister = NULL
- }
-};
diff --git a/c/src/lib/libbsp/arm/beagle/simscripts/bbxm.cfg b/c/src/lib/libbsp/arm/beagle/simscripts/bbxm.cfg
new file mode 100644
index 0000000000..a5fe36cd01
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/simscripts/bbxm.cfg
@@ -0,0 +1,174 @@
+# Start with: openocd -f interface/ftdi/flyswatter.cfg -f bbxm.cfg -c 'reset init'
+# or with: openocd -f interface/ftdi/flyswatter2.cfg -f bbxm.cfg -c 'reset init'
+source [find board/ti_beagleboard_xm.cfg]
+
+#
+# Use the MLO file from uboot to initialise the board.
+#
+proc beagleboard_xm_mlo { file } {
+ global _CHIPNAME
+ adapter_khz 10
+ catch { mww phys 0x48307250 0x00000004 }
+ reset init
+ icepick_c_wreset $_CHIPNAME.jrc
+ halt
+ dm37x.cpu arm core_state arm
+ puts "Beagleboard xM MLO: $file"
+ load_image $file 0x402005f8 bin
+ resume 0x40200800
+ sleep 500
+ halt
+}
+
+proc beagleboard_xm_init {} {
+ global _CHIPNAME
+ adapter_khz 10
+ catch { mww phys 0x48307250 0x00000004 }
+ reset init
+ icepick_c_wreset $_CHIPNAME.jrc
+ halt
+ dm37x.cpu arm core_state arm
+
+ mwh 0x6e00007c 0x000000ff ;# omap-gpmc
+ mwh 0x6e00007c 0x00000090 ;# omap-gpmc
+ mwh 0x6e000080 0x00000000 ;# omap-gpmc
+ mwh 0x6e00007c 0x00000000 ;# omap-gpmc
+ mwh 0x6e000080 0x00000000 ;# omap-gpmc
+ mwh 0x6e000080 0x00000000 ;# omap-gpmc
+ mwh 0x6e000080 0x00000000 ;# omap-gpmc
+ mwh 0x6e000080 0x00000000 ;# omap-gpmc
+ mwh 0x6e000080 0x00000000 ;# omap-gpmc
+ mwh 0x6e00007c 0x00000030 ;# omap-gpmc
+ mww 0x48004c00 0x00000020 ;# omap3_cm
+ mww 0x48004c10 0x00000020 ;# omap3_cm
+ mww 0x48314048 0x0000aaaa ;# omap3_mpu_wdt
+ mww 0x48314048 0x00005555 ;# omap3_mpu_wdt
+ mww 0x6c000048 0xffffffff ;# omap3_sms
+ mww 0x48004c40 0x00000013 ;# omap3_cm
+ mww 0x48004c10 0x00000025 ;# omap3_cm
+ mww 0x48004c00 0x00000021 ;# omap3_cm
+ mww 0x48306d40 0x00000003 ;# omap3_prm
+ mww 0x48307270 0x00000083 ;# omap3_prm
+ mww 0x48307270 0x00000080 ;# omap3_prm
+ mww 0x48004904 0x00000015 ;# omap3_cm
+ mww 0x48004d00 0x00110016 ;# omap3_cm
+ mww 0x48005140 0x10020a50 ;# omap3_cm
+ mww 0x48004d40 0x08000040 ;# omap3_cm
+ mww 0x48004d40 0x09900040 ;# omap3_cm
+ mww 0x48004d40 0x09900c40 ;# omap3_cm
+ mww 0x48004d40 0x09900c00 ;# omap3_cm
+ mww 0x48004a40 0x00001305 ;# omap3_cm
+ mww 0x48004a40 0x00001125 ;# omap3_cm
+ mww 0x48004a40 0x00001109 ;# omap3_cm
+ mww 0x48004a40 0x0000110a ;# omap3_cm
+ mww 0x48004b40 0x00000005 ;# omap3_cm
+ mww 0x48004c40 0x00000015 ;# omap3_cm
+ mww 0x48004d00 0x00110006 ;# omap3_cm
+ mww 0x48004d00 0x00110007 ;# omap3_cm
+ mww 0x48004d00 0x00110007 ;# omap3_cm
+ mww 0x48005140 0x03020a50 ;# omap3_cm
+ mww 0x48004f40 0x00000004 ;# omap3_cm
+ mww 0x48004e40 0x00000409 ;# omap3_cm
+ mww 0x48004e40 0x00001009 ;# omap3_cm
+ mww 0x48004d48 0x00000009 ;# omap3_cm
+ mww 0x48004d44 0x02436000 ;# omap3_cm
+ mww 0x48004d44 0x0243600c ;# omap3_cm
+ mww 0x48004a40 0x0000110a ;# omap3_cm
+ mww 0x48004d00 0x00170007 ;# omap3_cm
+ mww 0x48004d04 0x00000011 ;# omap3_cm
+ mww 0x48004d50 0x00000001 ;# omap3_cm
+ mww 0x48004d4c 0x00007800 ;# omap3_cm
+ mww 0x48004d4c 0x0000780c ;# omap3_cm
+ mww 0x48004d00 0x00170037 ;# omap3_cm
+ mww 0x48004d04 0x00000017 ;# omap3_cm
+ mww 0x48004004 0x00000011 ;# omap3_cm
+ mww 0x48004044 0x00000001 ;# omap3_cm
+ mww 0x48004040 0x00081400 ;# omap3_cm
+ mww 0x48004040 0x00081400 ;# omap3_cm
+ mww 0x48004004 0x00000017 ;# omap3_cm
+ mww 0x48004944 0x00000001 ;# omap3_cm
+ mww 0x48004940 0x000a5800 ;# omap3_cm
+ mww 0x48004940 0x000a580c ;# omap3_cm
+ mww 0x48004904 0x00000017 ;# omap3_cm
+ mww 0x48005040 0x000000ff ;# omap3_cm
+ mww 0x48004c40 0x00000015 ;# omap3_cm
+ mww 0x48005040 0x000000ff ;# omap3_cm
+ mww 0x48005010 0x00000008 ;# omap3_cm
+ mww 0x48005000 0x00000008 ;# omap3_cm
+ mww 0x48004a00 0x00002000 ;# omap3_cm
+ mww 0x48004a10 0x00002042 ;# omap3_cm
+ mww 0x48005000 0x00000808 ;# omap3_cm
+ mww 0x48005010 0x00000808 ;# omap3_cm
+ mww 0x48004a00 0x0003a000 ;# omap3_cm
+ mww 0x48004a10 0x0003a042 ;# omap3_cm
+ mww 0x48004c10 0x00000025 ;# omap3_cm
+ mww 0x48004000 0x00000001 ;# omap3_cm
+ mww 0x48004a00 0x03fffe29 ;# omap3_cm
+ mww 0x48004a10 0x3ffffffb ;# omap3_cm
+ mww 0x48004a14 0x0000001f ;# omap3_cm
+ mww 0x48004c00 0x000000e9 ;# omap3_cm
+ mww 0x48004c10 0x0000003f ;# omap3_cm
+ mww 0x48004e00 0x00000005 ;# omap3_cm
+ mww 0x48004e10 0x00000001 ;# omap3_cm
+ mww 0x48004f00 0x00000001 ;# omap3_cm
+ mww 0x48004f10 0x00000001 ;# omap3_cm
+ mww 0x48005000 0x0003ffff ;# omap3_cm
+ mww 0x48005010 0x0003ffff ;# omap3_cm
+ mww 0x48005410 0x00000001 ;# omap3_cm
+ mww 0x48005400 0x00000003 ;# omap3_cm
+ mww 0x48004a18 0x00000004 ;# omap3_cm
+ mww 0x48004a08 0x00000004 ;# omap3_cm
+ mww 0x6e000060 0x00001800 ;# omap-gpmc
+ mww 0x6e000064 0x00141400 ;# omap-gpmc
+ mww 0x6e000068 0x00141400 ;# omap-gpmc
+ mww 0x6e00006c 0x0f010f01 ;# omap-gpmc
+ mww 0x6e000070 0x010c1414 ;# omap-gpmc
+ mww 0x6e000074 0x1f0f0a80 ;# omap-gpmc
+ mww 0x6e000078 0x00000870 ;# omap-gpmc
+ mwb 0x6e00007c 0x000000ff ;# omap-gpmc
+ mwb 0x6e00007c 0x00000070 ;# omap-gpmc
+ mwb 0x6e00007c 0x00000090 ;# omap-gpmc
+ mwb 0x6e000080 0x00000000 ;# omap-gpmc
+ mww 0x6d000010 0x00000002 ;# omap.sdrc
+ mww 0x6d000010 0x00000000 ;# omap.sdrc
+ mww 0x6d000044 0x00000100 ;# omap.sdrc
+ mww 0x6d000070 0x04000081 ;# omap.sdrc
+ mww 0x6d000060 0x0000000a ;# omap.sdrc
+ mww 0x6d000080 0x04590099 ;# omap.sdrc
+ mww 0x6d00009c 0xc29dc4c6 ;# omap.sdrc
+ mww 0x6d0000a0 0x00022322 ;# omap.sdrc
+ mww 0x6d0000a4 0x0004e201 ;# omap.sdrc
+ mww 0x6d0000a8 0x00000000 ;# omap.sdrc
+ mww 0x6d0000a8 0x00000001 ;# omap.sdrc
+ mww 0x6d0000a8 0x00000002 ;# omap.sdrc
+ mww 0x6d0000a8 0x00000002 ;# omap.sdrc
+ mww 0x6d000084 0x00000032 ;# omap.sdrc
+ mww 0x6d000040 0x00000004 ;# omap.sdrc
+ mww 0x6d0000b0 0x04590099 ;# omap.sdrc
+ mww 0x6d0000c4 0xc29dc4c6 ;# omap.sdrc
+ mww 0x6d0000c8 0x00022322 ;# omap.sdrc
+ mww 0x6d0000d4 0x0004e201 ;# omap.sdrc
+ mww 0x6d0000d8 0x00000000 ;# omap.sdrc
+ mww 0x6d0000d8 0x00000001 ;# omap.sdrc
+ mww 0x6d0000d8 0x00000002 ;# omap.sdrc
+ mww 0x6d0000d8 0x00000002 ;# omap.sdrc
+ mww 0x6d0000b4 0x00000032 ;# omap.sdrc
+ mww 0x6d0000b0 0x00000000 ;# omap.sdrc
+ mww 0x6e00001c 0x00000000 ;# omap-gpmc
+ mww 0x6e000040 0x00000000 ;# omap-gpmc
+ mww 0x6e000050 0x00000000 ;# omap-gpmc
+ mww 0x6e000078 0x00000000 ;# omap-gpmc
+ mww 0x6e000078 0x00000000 ;# omap-gpmc
+ mww 0x6e000060 0x00001800 ;# omap-gpmc
+ mww 0x6e000064 0x00141400 ;# omap-gpmc
+ mww 0x6e000068 0x00141400 ;# omap-gpmc
+ mww 0x6e00006c 0x0f010f01 ;# omap-gpmc
+ mww 0x6e000070 0x010c1414 ;# omap-gpmc
+ mww 0x6e000074 0x1f0f0a80 ;# omap-gpmc
+ mww 0x6e000078 0x00000870 ;# omap-gpmc
+ mww 0x48004a00 0x437ffe00 ;# omap3_cm
+ mww 0x48004a10 0x637ffed2 ;# omap3_cm
+ puts "Beagleboard xM initialised"
+}
+
+init
diff --git a/c/src/lib/libbsp/arm/beagle/simscripts/gdbinit.bbxm b/c/src/lib/libbsp/arm/beagle/simscripts/gdbinit.bbxm
new file mode 100644
index 0000000000..32ae9dd9ad
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/simscripts/gdbinit.bbxm
@@ -0,0 +1,16 @@
+target remote localhost:3333
+mon reset halt
+mon beagleboard_xm_init
+load
+
+b _ARMV4_Exception_undef_default
+b _ARMV4_Exception_swi_default
+b _ARMV4_Exception_pref_abort_default
+b _ARMV4_Exception_data_abort_default
+b _ARMV4_Exception_reserved_default
+b _ARMV4_Exception_irq_default
+b _ARMV4_Exception_fiq_default
+
+b rtems_fatal
+b rtems_fatal_error_occurred
+b _exit
diff --git a/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh b/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh
new file mode 100644
index 0000000000..becd2c7720
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh
@@ -0,0 +1,84 @@
+# we store all generated files here.
+TMPDIR=tmp_sdcard_dir.$$
+
+FATIMG=$TMPDIR/bbxm_boot_fat.img
+SIZE=65536
+OFFSET=2048
+FATSIZE=`expr $SIZE - $OFFSET`
+UENV=uEnv.txt
+
+rm -rf $TMPDIR
+mkdir -p $TMPDIR
+
+if [ $# -ne 2 ]
+then echo "Usage: $0 <RTEMS prefix> <RTEMS executable>"
+ exit 1
+fi
+
+PREFIX=$1
+
+if [ ! -d "$PREFIX" ]
+then echo "This script needs the RTEMS tools bindir as the first argument."
+ exit 1
+fi
+
+executable=$2
+
+case "$2" in
+ *beagleboard*)
+ ubootcfg=omap3_beagle
+ imgtype=bb
+ ;;
+ *beaglebone*)
+ ubootcfg=am335x_evm
+ imgtype=bone
+ ;;
+ *)
+ echo "Can't guess which uboot to use - please specify full path to executable."
+ exit 1
+ ;;
+esac
+
+app=rtems-app.img
+
+if [ ! -f "$executable" ]
+then echo "Expecting RTEMS executable as arg; $executable not found."
+ exit 1
+fi
+
+set -e
+
+IMG=${imgtype}_`basename $2`-sdcard.img
+
+# Make an empty image
+dd if=/dev/zero of=$IMG bs=512 seek=`expr $SIZE - 1` count=1
+dd if=/dev/zero of=$FATIMG bs=512 seek=`expr $FATSIZE - 1` count=1
+
+# Make an ms-dos FS on it
+$PREFIX/bin/newfs_msdos -r 1 -m 0xf8 -c 4 -F16 -h 64 -u 32 -S 512 -s $FATSIZE -o 0 ./$FATIMG
+
+# Prepare the executable.
+base=`basename $executable`
+$PREFIX/bin/arm-rtems4.11-objcopy $executable -O binary $TMPDIR/$base.bin
+gzip -9 $TMPDIR/$base.bin
+$PREFIX/bin/mkimage -A arm -O rtems -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS -d $TMPDIR/$base.bin.gz $TMPDIR/$app
+echo "setenv bootdelay 5
+uenvcmd=run boot
+boot=fatload mmc 0 0x80800000 $app ; bootm 0x80800000" >$TMPDIR/$UENV
+
+# Copy the uboot and app image onto the FAT image
+$PREFIX/bin/mcopy -bsp -i $FATIMG $PREFIX/uboot/$ubootcfg/MLO ::MLO
+$PREFIX/bin/mcopy -bsp -i $FATIMG $PREFIX/uboot/$ubootcfg/u-boot.img ::u-boot.img
+$PREFIX/bin/mcopy -bsp -i $FATIMG $TMPDIR/$app ::$app
+$PREFIX/bin/mcopy -bsp -i $FATIMG $TMPDIR/$UENV ::$UENV
+
+# Just a single FAT partition (type C) that uses all of the image
+$PREFIX/bin/partition -m $IMG $OFFSET c:${FATSIZE}\*
+
+# Put the FAT image into the SD image
+dd if=$FATIMG of=$IMG seek=$OFFSET
+
+# cleanup
+rm -rf $TMPDIR
+
+echo "Result is in $IMG."
diff --git a/c/src/lib/libbsp/arm/beagle/startup/bspreset.c b/c/src/lib/libbsp/arm/beagle/startup/bspreset.c
index d937a18abd..5865b7badf 100644
--- a/c/src/lib/libbsp/arm/beagle/startup/bspreset.c
+++ b/c/src/lib/libbsp/arm/beagle/startup/bspreset.c
@@ -1,48 +1,42 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief Reset code.
- */
-
/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
- *
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
- * Germany
- * <claas.ziemke@gmx.net>
+ * Copyright (c) 2014 Ben Gras <beng@shrike-systems.com>. All rights reserved.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * http://www.rtems.org/license/LICENSE.
*/
-#include <stdbool.h>
-
-#include <bspopts.h>
+#include <bsp.h>
#include <bsp/bootcard.h>
-#include <bsp/beagle.h>
-static void watchdog_reset(void)
-{
- #ifdef BEAGLE_ENABLE_WATCHDOG_RESET
- //BEAGLE_TIMCLK_CTRL |= TIMCLK_CTRL_WDT;
- //beagle.wdt.mctrl |= WDTTIM_MCTRL_M_RES1 | WDTTIM_MCTRL_M_RES2;
- //beagle.wdt.emr = WDTTIM_EMR_MATCH_CTRL_SET(beagle.wdt.emr, 0x2);
- //beagle.wdt.ctrl |= WDTTIM_CTRL_COUNT_ENAB;
- //beagle.wdt.match0 = 1;
- //beagle.wdt.counter = 0;
- #endif
-}
+#define AM335X_CM_BASE 0x44E00000
+#define AM335X_CM_SIZE 0x1000
+
+#define AM335X_PRM_DEVICE_OFFSET 0xf00
+#define AM335X_PRM_RSTCTRL_REG 0x00
+#define AM335X_RST_GLOBAL_WARM_SW_BIT 0
-void bsp_reset( void)
+#define DM37XX_CM_BASE 0x48307000
+#define DM37XX_CM_SIZE 0x1000
+#define DM37XX_PRM_RSTCTRL_REG 0x250
+#define DM37XX_RST_DPLL3_BIT 2
+
+void bsp_reset(void)
{
- watchdog_reset();
+#if IS_DM3730
+ static uint32_t reset_base = DM37XX_CM_BASE;
+ while (true) {
+ mmio_set((reset_base + DM37XX_PRM_RSTCTRL_REG),
+ (1 << DM37XX_RST_DPLL3_BIT));
+ }
+#endif
+#if IS_AM335X
+ static uint32_t reset_base = AM335X_CM_BASE;
while (true) {
- /* Do nothing */
+ mmio_set((reset_base + AM335X_PRM_DEVICE_OFFSET +
+ AM335X_PRM_RSTCTRL_REG),
+ (1 << AM335X_RST_GLOBAL_WARM_SW_BIT));
}
+#endif
}
diff --git a/c/src/lib/libbsp/arm/beagle/startup/bspstart.c b/c/src/lib/libbsp/arm/beagle/startup/bspstart.c
index 9cdd04a8fb..b1565640c6 100644
--- a/c/src/lib/libbsp/arm/beagle/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/beagle/startup/bspstart.c
@@ -1,33 +1,29 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief Startup code.
- */
-
/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
*
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
* Germany
- * <claas.ziemke@gmx.net>
+ * <info@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * http://www.rtems.org/license/LICENSE.
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <bsp/irq-generic.h>
-#include <bsp/irq.h>
-#include <bsp/linker-symbols.h>
-#include <bsp/beagle.h>
void bsp_start(void)
{
+#if IS_DM3730
+ const char* type = "dm3730-based";
+#endif
+#if IS_AM335X
+ const char* type = "am335x-based";
+#endif
bsp_interrupt_initialize();
+ printk("\nRTEMS Beagleboard: %s\n", type);
}
diff --git a/c/src/lib/libbsp/arm/beagle/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/beagle/startup/bspstarthooks.c
index 4538b0c2d9..2efa3042a8 100644
--- a/c/src/lib/libbsp/arm/beagle/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/beagle/startup/bspstarthooks.c
@@ -1,366 +1,32 @@
-/**
- * @file
- *
- * @ingroup beagle
- *
- * @brief Startup code.
- */
-
/*
- * Copyright (c) 2012 Claas Ziemke. All rights reserved.
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
*
- * Claas Ziemke
- * Kernerstrasse 11
- * 70182 Stuttgart
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
* Germany
- * <claas.ziemke@gmx.net>
+ * <info@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * http://www.rtems.org/license/LICENSE.
*/
#include <bsp.h>
#include <bsp/start.h>
-#include <bsp/beagle.h>
-#include <bsp/linker-symbols.h>
-#include <bsp/uart-output-char.h>
-#include <libcpu/arm-cp15.h>
-
-#ifdef BEAGLE_DISABLE_READ_WRITE_DATA_CACHE
- #define BEAGLE_MMU_READ_WRITE_DATA BEAGLE_MMU_READ_WRITE
-#else
- #define BEAGLE_MMU_READ_WRITE_DATA BEAGLE_MMU_READ_WRITE_CACHED
-#endif
-
-#ifdef BEAGLE_DISABLE_READ_ONLY_PROTECTION
- #define BEAGLE_MMU_READ_ONLY_DATA BEAGLE_MMU_READ_WRITE_CACHED
- #define BEAGLE_MMU_CODE BEAGLE_MMU_READ_WRITE_CACHED
-#else
- #define BEAGLE_MMU_READ_ONLY_DATA BEAGLE_MMU_READ_ONLY_CACHED
- #define BEAGLE_MMU_CODE BEAGLE_MMU_READ_ONLY_CACHED
-#endif
-
-//LINKER_SYMBOL(beagle_translation_table_base);
-
-static BSP_START_TEXT_SECTION void clear_bss(void)
-{
- const int *end = (const int *) bsp_section_bss_end;
- int *out = (int *) bsp_section_bss_begin;
-
- /* Clear BSS */
- while (out != end) {
- *out = 0;
- ++out;
- }
-}
-
-/*#ifndef BEAGLE_DISABLE_MMU
- typedef struct {
- uint32_t begin;
- uint32_t end;
- uint32_t flags;
- } beagle_mmu_config;
-
- static const BSP_START_DATA_SECTION beagle_mmu_config
- beagle_mmu_config_table [] = {
- {
- .begin = (uint32_t) bsp_section_fast_text_begin,
- .end = (uint32_t) bsp_section_fast_text_end,
- .flags = BEAGLE_MMU_CODE
- }, {
- .begin = (uint32_t) bsp_section_fast_data_begin,
- .end = (uint32_t) bsp_section_fast_data_end,
- .flags = BEAGLE_MMU_READ_WRITE_DATA
-#ifdef BEAGLE_SCRATCH_AREA_SIZE
- }, {
- .begin = (uint32_t) &beagle_scratch_area [0],
- .end = (uint32_t) &beagle_scratch_area [BEAGLE_SCRATCH_AREA_SIZE],
- .flags = BEAGLE_MMU_READ_ONLY_DATA
-#endif
- }, {
- .begin = (uint32_t) bsp_section_start_begin,
- .end = (uint32_t) bsp_section_start_end,
- .flags = BEAGLE_MMU_CODE
- }, {
- .begin = (uint32_t) bsp_section_vector_begin,
- .end = (uint32_t) bsp_section_vector_end,
- .flags = BEAGLE_MMU_READ_WRITE_CACHED
- }, {
- .begin = (uint32_t) bsp_section_text_begin,
- .end = (uint32_t) bsp_section_text_end,
- .flags = BEAGLE_MMU_CODE
- }, {
- .begin = (uint32_t) bsp_section_rodata_begin,
- .end = (uint32_t) bsp_section_rodata_end,
- .flags = BEAGLE_MMU_READ_ONLY_DATA
- }, {
- .begin = (uint32_t) bsp_section_data_begin,
- .end = (uint32_t) bsp_section_data_end,
- .flags = BEAGLE_MMU_READ_WRITE_DATA
- }, {
- .begin = (uint32_t) bsp_section_bss_begin,
- .end = (uint32_t) bsp_section_bss_end,
- .flags = BEAGLE_MMU_READ_WRITE_DATA
- }, {
- .begin = (uint32_t) bsp_section_work_begin,
- .end = (uint32_t) bsp_section_work_end,
- .flags = BEAGLE_MMU_READ_WRITE_DATA
- }, {
- .begin = (uint32_t) bsp_section_stack_begin,
- .end = (uint32_t) bsp_section_stack_end,
- .flags = BEAGLE_MMU_READ_WRITE_DATA
- }, {
- .begin = 0x0U,
- .end = 0x100000U,
- .flags = BEAGLE_MMU_READ_ONLY_CACHED
- }, {
- .begin = 0x20000000U,
- .end = 0x200c0000U,
- .flags = BEAGLE_MMU_READ_WRITE
- }, {
- .begin = 0x30000000U,
- .end = 0x32000000U,
- .flags = BEAGLE_MMU_READ_WRITE
- }, {
- .begin = 0x40000000U,
- .end = 0x40100000U,
- .flags = BEAGLE_MMU_READ_WRITE
- }, {
- .begin = (uint32_t) beagle_magic_zero_begin,
- .end = (uint32_t) beagle_magic_zero_end,
- .flags = BEAGLE_MMU_READ_WRITE_DATA
- }
- };
-
- static BSP_START_TEXT_SECTION void set_translation_table_entries(
- uint32_t *ttb,
- const beagle_mmu_config *config
- )
- {
- uint32_t i = ARM_MMU_SECT_GET_INDEX(config->begin);
- uint32_t iend =
- ARM_MMU_SECT_GET_INDEX(ARM_MMU_SECT_MVA_ALIGN_UP(config->end));
-
- if (config->begin != config->end) {
- while (i < iend) {
- ttb [i] = (i << ARM_MMU_SECT_BASE_SHIFT) | config->flags;
- ++i;
- }
- }
- }
-
- static BSP_START_TEXT_SECTION void
- setup_translation_table_and_enable_mmu(uint32_t ctrl)
- {
- uint32_t const dac =
- ARM_CP15_DAC_DOMAIN(BEAGLE_MMU_CLIENT_DOMAIN, ARM_CP15_DAC_CLIENT);
- uint32_t *const ttb = (uint32_t *) beagle_translation_table_base;
- size_t const config_entry_count =
- sizeof(beagle_mmu_config_table) / sizeof(beagle_mmu_config_table [0]);
- size_t i = 0;
-
- arm_cp15_set_domain_access_control(dac);
- arm_cp15_set_translation_table_base(ttb);
-
- // Initialize translation table with invalid entries
- for (i = 0; i < ARM_MMU_TRANSLATION_TABLE_ENTRY_COUNT; ++i) {
- ttb [i] = 0;
- }
-
- for (i = 0; i < config_entry_count; ++i) {
- set_translation_table_entries(ttb, &beagle_mmu_config_table [i]);
- }
-
- // Enable MMU and cache
- ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
- arm_cp15_set_control(ctrl);
- }
-#endif*/
-
-/*static BSP_START_TEXT_SECTION void setup_mmu_and_cache(void)
-{
- uint32_t ctrl = 0;
-
- // Disable MMU and cache, basic settings
- ctrl = arm_cp15_get_control();
- ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_R | ARM_CP15_CTRL_C
- | ARM_CP15_CTRL_V | ARM_CP15_CTRL_M);
- ctrl |= ARM_CP15_CTRL_S | ARM_CP15_CTRL_A;
- arm_cp15_set_control(ctrl);
-
- arm_cp15_cache_invalidate();
- arm_cp15_tlb_invalidate();
-
- #ifndef BEAGLE_DISABLE_MMU
- //setup_translation_table_and_enable_mmu(ctrl);
- #endif
-}*/
-
-/*BSP_START_TEXT_SECTION bool beagle_start_pll_setup(
- uint32_t hclkpll_ctrl,
- uint32_t hclkdiv_ctrl,
- bool force
-)
-{
- uint32_t pwr_ctrl = BEAGLE_PWR_CTRL;
- bool settings_ok =
- ((BEAGLE_HCLKPLL_CTRL ^ hclkpll_ctrl) & BSP_MSK32(1, 16)) == 0
- && ((BEAGLE_HCLKDIV_CTRL ^ hclkdiv_ctrl) & BSP_MSK32(0, 8)) == 0;
-
- if ((pwr_ctrl & PWR_NORMAL_RUN_MODE) == 0 || (!settings_ok && force)) {
- // Disable HCLK PLL output
- BEAGLE_PWR_CTRL = pwr_ctrl & ~PWR_NORMAL_RUN_MODE;
-
- // Configure HCLK PLL
- BEAGLE_HCLKPLL_CTRL = hclkpll_ctrl;
- while ((BEAGLE_HCLKPLL_CTRL & HCLK_PLL_LOCK) == 0) {
- // Wait
- }
-
- // Setup HCLK divider
- BEAGLE_HCLKDIV_CTRL = hclkdiv_ctrl;
+#include <bsp/arm-cp15-start.h>
+#include <bsp/arm-a8core-start.h>
- // Enable HCLK PLL output
- BEAGLE_PWR_CTRL = pwr_ctrl | PWR_NORMAL_RUN_MODE;
- }
-
- return settings_ok;
-}*/
-
-#if BEAGLE_OSCILLATOR_MAIN != 13000000U
- #error "unexpected main oscillator frequency"
-#endif
-
-/*static BSP_START_TEXT_SECTION void setup_pll(void)
-{
- uint32_t hclkpll_ctrl = BEAGLE_HCLKPLL_CTRL_INIT_VALUE;
- uint32_t hclkdiv_ctrl = BEAGLE_HCLKDIV_CTRL_INIT_VALUE;
-
- beagle_start_pll_setup(hclkpll_ctrl, hclkdiv_ctrl, false);
-}*/
+#include <bsp/uart-output-char.h>
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
- //setup_pll();
- //setup_mmu_and_cache();
-}
-
-/*static BSP_START_TEXT_SECTION void stop_dma_activities(void)
-{
- #ifdef BEAGLE_STOP_GPDMA
- BEAGLE_DO_STOP_GPDMA;
- #endif
-
- #ifdef BEAGLE_STOP_ETHERNET
- BEAGLE_DO_STOP_ETHERNET;
- #endif
-
- #ifdef BEAGLE_STOP_USB
- BEAGLE_DO_STOP_USB;
- #endif
-}*/
-
-static BSP_START_TEXT_SECTION void setup_uarts(void)
-{
- uint32_t uartclk_ctrl = 0;
-
- #ifdef BEAGLE_CONFIG_U3CLK
- uartclk_ctrl |= 1U << 0;
- BEAGLE_U3CLK = BEAGLE_CONFIG_U3CLK;
- #endif
- #ifdef BEAGLE_CONFIG_U4CLK
- uartclk_ctrl |= 1U << 1;
- BEAGLE_U4CLK = BEAGLE_CONFIG_U4CLK;
- #endif
- #ifdef BEAGLE_CONFIG_U5CLK
- uartclk_ctrl |= 1U << 2;
- BEAGLE_U5CLK = BEAGLE_CONFIG_U5CLK;
- #endif
- #ifdef BEAGLE_CONFIG_U6CLK
- uartclk_ctrl |= 1U << 3;
- BEAGLE_U6CLK = BEAGLE_CONFIG_U6CLK;
- #endif
-
- #ifdef BEAGLE_CONFIG_UART_CLKMODE
- BEAGLE_UART_CLKMODE = BEAGLE_CONFIG_UART_CLKMODE;
- #endif
-
- BEAGLE_UARTCLK_CTRL = uartclk_ctrl;
- BEAGLE_UART_CTRL = 0x0;
- BEAGLE_UART_LOOP = 0x0;
-
- #ifdef BEAGLE_CONFIG_U5CLK
- // Clock is already set in BEAGLE_U5CLK
- BSP_CONSOLE_UART_INIT(0x01);
- #endif
}
-/*static BSP_START_TEXT_SECTION void setup_timer(void)
-{
- volatile beagle_timer *timer = BEAGLE_STANDARD_TIMER;
-
- BEAGLE_TIMCLK_CTRL1 = (1U << 2) | (1U << 3);
-
- timer->tcr = BEAGLE_TIMER_TCR_RST;
- timer->ctcr = 0x0;
- timer->pr = 0x0;
- timer->ir = 0xff;
- timer->mcr = 0x0;
- timer->ccr = 0x0;
- timer->tcr = BEAGLE_TIMER_TCR_EN;
-}*/
-
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
- //stop_dma_activities();
- setup_uarts();
- //setup_timer();
-
- // Copy .text section
- arm_cp15_instruction_cache_invalidate();
- bsp_start_memcpy(
- (int *) bsp_section_text_begin,
- (const int *) bsp_section_text_load_begin,
- (size_t) bsp_section_text_size
- );
-
- // Copy .rodata section
- arm_cp15_instruction_cache_invalidate();
- bsp_start_memcpy(
- (int *) bsp_section_rodata_begin,
- (const int *) bsp_section_rodata_load_begin,
- (size_t) bsp_section_rodata_size
- );
-
- // Copy .data section
- arm_cp15_instruction_cache_invalidate();
- bsp_start_memcpy(
- (int *) bsp_section_data_begin,
- (const int *) bsp_section_data_load_begin,
- (size_t) bsp_section_data_size
- );
-
- // Copy .fast_text section
- arm_cp15_instruction_cache_invalidate();
- bsp_start_memcpy(
- (int *) bsp_section_fast_text_begin,
- (const int *) bsp_section_fast_text_load_begin,
- (size_t) bsp_section_fast_text_size
- );
-
- // Copy .fast_data section
- arm_cp15_instruction_cache_invalidate();
- bsp_start_memcpy(
- (int *) bsp_section_fast_data_begin,
- (const int *) bsp_section_fast_data_load_begin,
- (size_t) bsp_section_fast_data_size
- );
-
- // Clear .bss section
- clear_bss();
-
-
-
- // At this point we can use objects outside the .start section
+ arm_a8core_start_hook_1();
+ bsp_start_copy_sections();
+ beagle_setup_mmu_and_cache();
+ bsp_start_clear_bss();
}
diff --git a/c/src/lib/libbsp/arm/beagle/startup/bspstartmmu.c b/c/src/lib/libbsp/arm/beagle/startup/bspstartmmu.c
new file mode 100644
index 0000000000..157edfa0a7
--- /dev/null
+++ b/c/src/lib/libbsp/arm/beagle/startup/bspstartmmu.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info@embedded-brains.de>
+ *
+ * Copyright (c) 2014 Chris Johns. All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <bsp.h>
+#include <bsp/start.h>
+#include <bsp/arm-cp15-start.h>
+
+#define ARM_SECTIONS 4096 /* all sections needed to describe the
+ virtual address space */
+#define ARM_SECTION_SIZE (1024 * 1024) /* how much virtual memory is described
+ by one section */
+
+//static uint32_t pagetable[ARM_SECTIONS] __attribute__((aligned (1024*16)));
+
+BSP_START_DATA_SECTION static const arm_cp15_start_section_config
+beagle_mmu_config_table[] = {
+ ARMV7_CP15_START_DEFAULT_SECTIONS,
+ {
+ .begin = 0x40000000U,
+ .end = 0x4FFFFFFFU,
+ .flags = ARMV7_MMU_DEVICE
+ }
+};
+
+/*
+ * Make weak and let the user override.
+ */
+BSP_START_TEXT_SECTION void beagle_setup_mmu_and_cache(void) __attribute__ ((weak));
+
+BSP_START_TEXT_SECTION void beagle_setup_mmu_and_cache(void)
+{
+ /* turn mmu off first in case it's on */
+ uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
+ ARM_CP15_CTRL_M | ARM_CP15_CTRL_A, /* clear - mmu off */
+ ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
+ );
+
+ arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
+ ctrl,
+ (uint32_t *) bsp_translation_table_base,
+ ARM_MMU_DEFAULT_CLIENT_DOMAIN,
+ &beagle_mmu_config_table[0],
+ RTEMS_ARRAY_SIZE(beagle_mmu_config_table)
+ );
+}
diff --git a/c/src/lib/libbsp/arm/beagle/startup/linkcmds.beagle b/c/src/lib/libbsp/arm/beagle/startup/linkcmds.beagle
index 29e948d4e7..93f1a4989a 100644
--- a/c/src/lib/libbsp/arm/beagle/startup/linkcmds.beagle
+++ b/c/src/lib/libbsp/arm/beagle/startup/linkcmds.beagle
@@ -1,53 +1,45 @@
/**
* @file
*
- * @ingroup beagle_linker
- *
- * @brief Memory map.
- */
-
-/**
- * @defgroup beagle_linker BeagleBoard Application Memory Map
- *
- * @ingroup bsp_linker
- *
- * @brief BeagleBoard application memory map.
+ * @ingroup arm_beagle
*
+ * @brief Linker script for beagles.
*/
MEMORY {
- RAM : ORIGIN = 0x80000000, LENGTH = 32M
- NIRVANA : ORIGIN = 0, LENGTH = 0
+ /* Beagleboards and beaglebones all
+ * have either 256M or 512M memory. We just
+ * use 256M for all.
+ */
+ RAM : ORIGIN = 0x80000000, LENGTH = 256M - 4M
+ RAM_MMU : ORIGIN = 0x80000000 + 256M - 4M, LENGTH = 16k
}
-REGION_ALIAS ("REGION_START", RAM);
-REGION_ALIAS ("REGION_VECTOR", RAM);
-REGION_ALIAS ("REGION_TEXT", RAM);
-REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
-REGION_ALIAS ("REGION_RODATA", RAM);
-REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
-REGION_ALIAS ("REGION_DATA", RAM);
-REGION_ALIAS ("REGION_DATA_LOAD", RAM);
-REGION_ALIAS ("REGION_FAST_TEXT", RAM);
+REGION_ALIAS ("REGION_START", RAM);
+REGION_ALIAS ("REGION_VECTOR", RAM);
+REGION_ALIAS ("REGION_TEXT", RAM);
+REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
+REGION_ALIAS ("REGION_RODATA", RAM);
+REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
+REGION_ALIAS ("REGION_DATA", RAM);
+REGION_ALIAS ("REGION_DATA_LOAD", RAM);
+REGION_ALIAS ("REGION_FAST_TEXT", RAM);
REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM);
-REGION_ALIAS ("REGION_FAST_DATA", RAM);
+REGION_ALIAS ("REGION_FAST_DATA", RAM);
REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
-REGION_ALIAS ("REGION_BSS", RAM);
-REGION_ALIAS ("REGION_WORK", RAM);
-REGION_ALIAS ("REGION_STACK", RAM);
-
-//beagle_scratch_area = ORIGIN (RAM_SCRATCH);
+REGION_ALIAS ("REGION_BSS", RAM);
+REGION_ALIAS ("REGION_WORK", RAM);
+REGION_ALIAS ("REGION_STACK", RAM);
bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1M;
-beagle = 0x20020000;
+bsp_vector_table_in_start_section = 1;
-beagle_magic_zero_begin = 0x05000000;
-beagle_magic_zero_end = 0x07000000;
-beagle_magic_zero_size = beagle_magic_zero_end - beagle_magic_zero_end;
+bsp_translation_table_base = ORIGIN (RAM_MMU);
+bsp_translation_table_end = ORIGIN (RAM_MMU) + LENGTH (RAM_MMU);
INCLUDE linkcmds.armv4