summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorGUI <[email protected]>2024-11-26 10:02:50 +0800
committerGitHub <[email protected]>2024-11-26 10:02:50 +0800
commit1a24ae06f32b2dc794e6cac5d4a1a2785b0c9596 (patch)
treecc80d11babd4e1f078791aced66d93aa0c0ead65 /components/drivers/include
parent9afe6a51826fb84de229de220dab2077aa5734b2 (diff)
[DM/FEATURE] Support reset controller (#9630)
* [DM/FEATURE] Support reset controller Reset controllers are central units that control the reset signals to multiple peripherals. The reset controller API is split into two parts: 1. The consumer driver interface, which allows peripheral drivers to request control over their reset input signals 2. The reset controller driver interface which is used by drivers for reset controller devices to register their reset controls to provide them to the consumers. * [RESET/SIMPLE] Support simple reset Currently this driver supports: - Altera SoCFPGAs - ASPEED BMC SoCs - Bitmain BM1880 SoC - Realtek SoCs - RCC reset controller in STM32 MCUs - Allwinner SoCs - SiFive FU740 SoCs - Sophgo SoCs Signed-off-by: GuEe-GUI <[email protected]>
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/reset.h82
-rw-r--r--components/drivers/include/rtdevice.h4
2 files changed, 86 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/reset.h b/components/drivers/include/drivers/reset.h
new file mode 100644
index 0000000000..6339fe931e
--- /dev/null
+++ b/components/drivers/include/drivers/reset.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-11-26 GuEe-GUI first version
+ */
+
+#ifndef __RESET_H__
+#define __RESET_H__
+
+#include <rthw.h>
+#include <rtthread.h>
+#include <drivers/ofw.h>
+
+#define RT_RESET_CONTROLLER_OBJ_NAME "RSTC"
+
+struct rt_reset_control_ops;
+
+struct rt_reset_controller
+{
+ struct rt_object parent;
+
+ rt_list_t rstc_nodes;
+
+ const char *name;
+ const struct rt_reset_control_ops *ops;
+
+ struct rt_ofw_node *ofw_node;
+ void *priv;
+
+ struct rt_spinlock spinlock;
+};
+
+struct rt_reset_control
+{
+ rt_list_t list;
+
+ struct rt_reset_controller *rstcer;
+
+ int id;
+ const char *con_id;
+ rt_bool_t is_array;
+
+ void *priv;
+};
+
+struct rt_reset_control_ops
+{
+ /*
+ * rt_ofw_cell_args return:
+ * args[0] = rstc.id
+ */
+ rt_err_t (*ofw_parse)(struct rt_reset_control *rstc, struct rt_ofw_cell_args *args);
+ /* API */
+ rt_err_t (*reset)(struct rt_reset_control *rstc);
+ rt_err_t (*assert)(struct rt_reset_control *rstc);
+ rt_err_t (*deassert)(struct rt_reset_control *rstc);
+ int (*status)(struct rt_reset_control *rstc);
+};
+
+rt_err_t rt_reset_controller_register(struct rt_reset_controller *rstcer);
+rt_err_t rt_reset_controller_unregister(struct rt_reset_controller *rstcer);
+
+rt_err_t rt_reset_control_reset(struct rt_reset_control *rstc);
+rt_err_t rt_reset_control_assert(struct rt_reset_control *rstc);
+rt_err_t rt_reset_control_deassert(struct rt_reset_control *rstc);
+int rt_reset_control_status(struct rt_reset_control *rstc);
+
+rt_ssize_t rt_reset_control_get_count(struct rt_device *dev);
+struct rt_reset_control *rt_reset_control_get_array(struct rt_device *dev);
+struct rt_reset_control *rt_reset_control_get_by_index(struct rt_device *dev, int index);
+struct rt_reset_control *rt_reset_control_get_by_name(struct rt_device *dev, const char *name);
+void rt_reset_control_put(struct rt_reset_control *rstc);
+
+struct rt_reset_control *rt_ofw_get_reset_control_array(struct rt_ofw_node *np);
+struct rt_reset_control *rt_ofw_get_reset_control_by_index(struct rt_ofw_node *np, int index);
+struct rt_reset_control *rt_ofw_get_reset_control_by_name(struct rt_ofw_node *np, const char *name);
+
+#endif /* __RESET_H__ */
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index aa56b6820c..34152cefb6 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -79,6 +79,10 @@ extern "C" {
#include "drivers/pic.h"
#endif /* RT_USING_PIC */
+#ifdef RT_USING_RESET
+#include "drivers/reset.h"
+#endif /* RT_USING_RESET */
+
#ifdef RT_USING_SCSI
#include "drivers/scsi.h"
#endif /* RT_USING_SCSI */