summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/dts/test.dts28
-rw-r--r--arch/sandbox/include/asm/clk.h111
-rw-r--r--arch/sandbox/include/asm/gpio.h16
-rw-r--r--arch/sandbox/include/asm/reset.h21
-rw-r--r--arch/sandbox/include/asm/test.h9
5 files changed, 169 insertions, 16 deletions
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 686c215aea..9e46f9e815 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -108,8 +108,23 @@
compatible = "denx,u-boot-fdt-test";
};
- clk@0 {
+ clk_fixed: clk-fixed {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <1234>;
+ };
+
+ clk_sandbox: clk-sbox {
compatible = "sandbox,clk";
+ #clock-cells = <1>;
+ };
+
+ clk-test {
+ compatible = "sandbox,clk-test";
+ clocks = <&clk_fixed>,
+ <&clk_sandbox 1>,
+ <&clk_sandbox 0>;
+ clock-names = "fixed", "i2c", "spi";
};
eth@10002000 {
@@ -259,6 +274,17 @@
compatible = "sandbox,reset";
};
+ resetc: reset-ctl {
+ compatible = "sandbox,reset-ctl";
+ #reset-cells = <1>;
+ };
+
+ reset-ctl-test {
+ compatible = "sandbox,reset-ctl-test";
+ resets = <&resetc 100>, <&resetc 2>;
+ reset-names = "other", "test";
+ };
+
rproc_1: rproc@1 {
compatible = "sandbox,test-processor";
remoteproc-name = "remoteproc-test-dev1";
diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h
new file mode 100644
index 0000000000..9dc6c8184b
--- /dev/null
+++ b/arch/sandbox/include/asm/clk.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef __SANDBOX_CLK_H
+#define __SANDBOX_CLK_H
+
+#include <common.h>
+
+struct udevice;
+
+/**
+ * enum sandbox_clk_id - Identity of clocks implemented by the sandbox clock
+ * provider.
+ *
+ * These IDs are within/relative-to the clock provider.
+ */
+enum sandbox_clk_id {
+ SANDBOX_CLK_ID_SPI,
+ SANDBOX_CLK_ID_I2C,
+
+ SANDBOX_CLK_ID_COUNT,
+};
+
+/**
+ * enum sandbox_clk_test_id - Identity of the clocks consumed by the sandbox
+ * clock test device.
+ *
+ * These are the IDs the clock consumer knows the clocks as.
+ */
+enum sandbox_clk_test_id {
+ SANDBOX_CLK_TEST_ID_FIXED,
+ SANDBOX_CLK_TEST_ID_SPI,
+ SANDBOX_CLK_TEST_ID_I2C,
+
+ SANDBOX_CLK_TEST_ID_COUNT,
+};
+
+/**
+ * sandbox_clk_query_rate - Query the current rate of a sandbox clock.
+ *
+ * @dev: The sandbox clock provider device.
+ * @id: The clock to query.
+ * @return: The rate of the clock.
+ */
+ulong sandbox_clk_query_rate(struct udevice *dev, int id);
+/**
+ * sandbox_clk_query_enable - Query the enable state of a sandbox clock.
+ *
+ * @dev: The sandbox clock provider device.
+ * @id: The clock to query.
+ * @return: The rate of the clock.
+ */
+int sandbox_clk_query_enable(struct udevice *dev, int id);
+
+/**
+ * sandbox_clk_test_get - Ask the sandbox clock test device to request its
+ * clocks.
+ *
+ * @dev: The sandbox clock test (client) devivce.
+ * @return: 0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_get(struct udevice *dev);
+/**
+ * sandbox_clk_test_get_rate - Ask the sandbox clock test device to query a
+ * clock's rate.
+ *
+ * @dev: The sandbox clock test (client) devivce.
+ * @id: The test device's clock ID to query.
+ * @return: The rate of the clock.
+ */
+ulong sandbox_clk_test_get_rate(struct udevice *dev, int id);
+/**
+ * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a
+ * clock's rate.
+ *
+ * @dev: The sandbox clock test (client) devivce.
+ * @id: The test device's clock ID to configure.
+ * @return: The new rate of the clock.
+ */
+ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate);
+/**
+ * sandbox_clk_test_enable - Ask the sandbox clock test device to enable a
+ * clock.
+ *
+ * @dev: The sandbox clock test (client) devivce.
+ * @id: The test device's clock ID to configure.
+ * @return: 0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_enable(struct udevice *dev, int id);
+/**
+ * sandbox_clk_test_disable - Ask the sandbox clock test device to disable a
+ * clock.
+ *
+ * @dev: The sandbox clock test (client) devivce.
+ * @id: The test device's clock ID to configure.
+ * @return: 0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_disable(struct udevice *dev, int id);
+/**
+ * sandbox_clk_test_free - Ask the sandbox clock test device to free its
+ * clocks.
+ *
+ * @dev: The sandbox clock test (client) devivce.
+ * @return: 0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_free(struct udevice *dev);
+
+#endif
diff --git a/arch/sandbox/include/asm/gpio.h b/arch/sandbox/include/asm/gpio.h
index 427af2c970..73b42f0f08 100644
--- a/arch/sandbox/include/asm/gpio.h
+++ b/arch/sandbox/include/asm/gpio.h
@@ -26,7 +26,8 @@
/**
* Return the simulated value of a GPIO (used only in sandbox test code)
*
- * @param gp GPIO number
+ * @param dev device to use
+ * @param offset GPIO offset within bank
* @return -1 on error, 0 if GPIO is low, >0 if high
*/
int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset);
@@ -34,8 +35,9 @@ int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset);
/**
* Set the simulated value of a GPIO (used only in sandbox test code)
*
- * @param gp GPIO number
- * @param value value to set (0 for low, non-zero for high)
+ * @param dev device to use
+ * @param offset GPIO offset within bank
+ * @param value value to set (0 for low, non-zero for high)
* @return -1 on error, 0 if ok
*/
int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value);
@@ -63,7 +65,8 @@ int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset);
/**
* Return the simulated direction of a GPIO (used only in sandbox test code)
*
- * @param gp GPIO number
+ * @param dev device to use
+ * @param offset GPIO offset within bank
* @return -1 on error, 0 if GPIO is input, >0 if output
*/
int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset);
@@ -71,8 +74,9 @@ int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset);
/**
* Set the simulated direction of a GPIO (used only in sandbox test code)
*
- * @param gp GPIO number
- * @param output 0 to set as input, 1 to set as output
+ * @param dev device to use
+ * @param offset GPIO offset within bank
+ * @param output 0 to set as input, 1 to set as output
* @return -1 on error, 0 if ok
*/
int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset,
diff --git a/arch/sandbox/include/asm/reset.h b/arch/sandbox/include/asm/reset.h
new file mode 100644
index 0000000000..7146aa5ab2
--- /dev/null
+++ b/arch/sandbox/include/asm/reset.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef __SANDBOX_RESET_H
+#define __SANDBOX_RESET_H
+
+#include <common.h>
+
+struct udevice;
+
+int sandbox_reset_query(struct udevice *dev, unsigned long id);
+
+int sandbox_reset_test_get(struct udevice *dev);
+int sandbox_reset_test_assert(struct udevice *dev);
+int sandbox_reset_test_deassert(struct udevice *dev);
+int sandbox_reset_test_free(struct udevice *dev);
+
+#endif
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 224b0ebaf9..451a78e590 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -19,15 +19,6 @@
#define SANDBOX_CLK_RATE 32768
-enum {
- PERIPH_ID_FIRST = 0,
- PERIPH_ID_SPI = PERIPH_ID_FIRST,
- PERIPH_ID_I2C,
- PERIPH_ID_PCI,
-
- PERIPH_ID_COUNT,
-};
-
/* System controller driver data */
enum {
SYSCON0 = 32,
OpenPOWER on IntegriCloud