summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2015-05-08 10:46:59 -0400
committerTom Rini <trini@konsulko.com>2015-05-08 10:46:59 -0400
commit02ffb580e6ab7aaa7f6703ed35f489e97439cb65 (patch)
tree77cea28c53d54583a3acfa5534a8aa10054eb29c /arch
parent57cc4e64c13bc5f42cb5e8572d2c46e25cf7aea1 (diff)
parenta5e1bcdeebebabdc5d013fbd488f87a4e62ff411 (diff)
downloadu-boot-02ffb580e6ab7aaa7f6703ed35f489e97439cb65.tar.gz
u-boot-02ffb580e6ab7aaa7f6703ed35f489e97439cb65.tar.bz2
u-boot-02ffb580e6ab7aaa7f6703ed35f489e97439cb65.zip
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'arch')
-rw-r--r--arch/sandbox/cpu/cpu.c5
-rw-r--r--arch/sandbox/cpu/os.c18
-rw-r--r--arch/sandbox/cpu/start.c20
-rw-r--r--arch/sandbox/dts/sandbox.dts12
-rw-r--r--arch/sandbox/include/asm/eth.h2
-rw-r--r--arch/sandbox/include/asm/rtc.h28
-rw-r--r--arch/sandbox/include/asm/state.h1
-rw-r--r--arch/sandbox/include/asm/test.h39
8 files changed, 116 insertions, 9 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 168f2efa33..b6aae3718a 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -45,11 +45,6 @@ void __udelay(unsigned long usec)
os_usleep(usec);
}
-unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
-{
- return os_get_nsec() / 1000;
-}
-
int cleanup_before_linux(void)
{
return 0;
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 4d5f805753..e6dd17e9ef 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -24,6 +24,7 @@
#include <asm/sections.h>
#include <asm/state.h>
#include <os.h>
+#include <rtc_def.h>
/* Operating System Interface */
@@ -537,3 +538,20 @@ int os_jump_to_image(const void *dest, int size)
return unlink(fname);
}
+
+void os_localtime(struct rtc_time *rt)
+{
+ time_t t = time(NULL);
+ struct tm *tm;
+
+ tm = localtime(&t);
+ rt->tm_sec = tm->tm_sec;
+ rt->tm_min = tm->tm_min;
+ rt->tm_hour = tm->tm_hour;
+ rt->tm_mday = tm->tm_mday;
+ rt->tm_mon = tm->tm_mon + 1;
+ rt->tm_year = tm->tm_year + 1900;
+ rt->tm_wday = tm->tm_wday;
+ rt->tm_yday = tm->tm_yday;
+ rt->tm_isdst = tm->tm_isdst;
+}
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index ec010402d7..b23d08b5a1 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -77,12 +77,18 @@ int sandbox_main_loop_init(void)
struct sandbox_state *state = state_get_current();
/* Execute command if required */
- if (state->cmd) {
- int retval;
+ if (state->cmd || state->run_distro_boot) {
+ int retval = 0;
cli_init();
- retval = run_command_list(state->cmd, -1, 0);
+ if (state->cmd)
+ retval = run_command_list(state->cmd, -1, 0);
+
+ if (state->run_distro_boot)
+ retval = cli_simple_run_command("run distro_bootcmd",
+ 0);
+
if (!state->interactive)
os_exit(retval);
}
@@ -90,6 +96,14 @@ int sandbox_main_loop_init(void)
return 0;
}
+static int sandbox_cmdline_cb_boot(struct sandbox_state *state,
+ const char *arg)
+{
+ state->run_distro_boot = true;
+ return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(boot, 'b', 0, "Run distro boot commands");
+
static int sandbox_cmdline_cb_command(struct sandbox_state *state,
const char *arg)
{
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index efa2097b2d..82d186ee5b 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -8,7 +8,9 @@
aliases {
eth5 = "/eth@90000000";
+ i2c0 = &i2c_0;
pci0 = &pci;
+ rtc0 = &rtc_0;
};
chosen {
@@ -90,7 +92,7 @@
num-gpios = <10>;
};
- i2c@0 {
+ i2c_0: i2c@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0 0>;
@@ -105,6 +107,14 @@
sandbox,size = <128>;
};
};
+
+ rtc_0: rtc@43 {
+ reg = <0x43>;
+ compatible = "sandbox-rtc";
+ emul {
+ compatible = "sandbox,i2c-rtc";
+ };
+ };
};
spi@0 {
diff --git a/arch/sandbox/include/asm/eth.h b/arch/sandbox/include/asm/eth.h
index 4b79ede9b9..88804fb8e2 100644
--- a/arch/sandbox/include/asm/eth.h
+++ b/arch/sandbox/include/asm/eth.h
@@ -12,4 +12,6 @@
void sandbox_eth_disable_response(int index, bool disable);
+void sandbox_eth_skip_timeout(void);
+
#endif /* __ETH_H */
diff --git a/arch/sandbox/include/asm/rtc.h b/arch/sandbox/include/asm/rtc.h
new file mode 100644
index 0000000000..5ed4584641
--- /dev/null
+++ b/arch/sandbox/include/asm/rtc.h
@@ -0,0 +1,28 @@
+/*
+ * Simulate an I2C real time clock
+ *
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __asm_rtc_h
+#define __asm_rtc_h
+
+/* Register numbers in the sandbox RTC */
+enum {
+ REG_SEC = 5,
+ REG_MIN,
+ REG_HOUR,
+ REG_MDAY,
+ REG_MON,
+ REG_YEAR,
+ REG_WDAY,
+
+ REG_RESET = 0x20,
+
+ REG_COUNT = 0x80,
+};
+
+#endif
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index a0c24ba1e0..a57480a996 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -42,6 +42,7 @@ struct sandbox_spi_info {
struct sandbox_state {
const char *cmd; /* Command to execute */
bool interactive; /* Enable cmdline after execute */
+ bool run_distro_boot; /* Automatically run distro bootcommands */
const char *fdt_fname; /* Filename of FDT binary */
const char *parse_err; /* Error to report from parsing */
int argc; /* Program arguments */
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 8e490e96d7..91a5c79ad2 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -17,6 +17,16 @@
#define SANDBOX_PCI_CLASS_CODE PCI_CLASS_CODE_COMM
#define SANDBOX_PCI_CLASS_SUB_CODE PCI_CLASS_SUB_CODE_COMM_SERIAL
+/**
+ * sandbox_i2c_set_test_mode() - set test mode for running unit tests
+ *
+ * See sandbox_i2c_xfer() for the behaviour changes.
+ *
+ * @bus: sandbox I2C bus to adjust
+ * @test_mode: true to select test mode, false to run normally
+ */
+void sandbox_i2c_set_test_mode(struct udevice *bus, bool test_mode);
+
enum sandbox_i2c_eeprom_test_mode {
SIE_TEST_MODE_NONE,
/* Permits read/write of only one byte per I2C transaction */
@@ -28,4 +38,33 @@ void sandbox_i2c_eeprom_set_test_mode(struct udevice *dev,
void sandbox_i2c_eeprom_set_offset_len(struct udevice *dev, int offset_len);
+/*
+ * sandbox_timer_add_offset()
+ *
+ * Allow tests to add to the time reported through lib/time.c functions
+ * offset: number of milliseconds to advance the system time
+ */
+void sandbox_timer_add_offset(unsigned long offset);
+
+/**
+ * sandbox_i2c_rtc_set_offset() - set the time offset from system/base time
+ *
+ * @dev: RTC device to adjust
+ * @use_system_time: true to use system time, false to use @base_time
+ * @offset: RTC offset from current system/base time (-1 for no
+ * change)
+ * @return old value of RTC offset
+ */
+long sandbox_i2c_rtc_set_offset(struct udevice *dev, bool use_system_time,
+ int offset);
+
+/**
+ * sandbox_i2c_rtc_get_set_base_time() - get and set the base time
+ *
+ * @dev: RTC device to adjust
+ * @base_time: New base system time (set to -1 for no change)
+ * @return old base time
+ */
+long sandbox_i2c_rtc_get_set_base_time(struct udevice *dev, long base_time);
+
#endif