summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorWBI\nxf44444 <[email protected]>2020-11-17 11:26:28 +0800
committerWBI\nxf44444 <[email protected]>2020-11-17 11:26:28 +0800
commitbfdbcd30f4f34e53d62f5d014acf4481c5a06412 (patch)
tree5043846c3034b4417172270531c04ab3771b0f02 /components/drivers/include
parent8087a901180c9fccb5951d651b7ce01974aea52a (diff)
parentb0f21335631adcd7b788de7b402a175e5ca4a40b (diff)
audio_kconfig
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/alarm.h7
-rw-r--r--components/drivers/include/drivers/phy.h87
-rw-r--r--components/drivers/include/drivers/phy_mdio.h43
-rw-r--r--components/drivers/include/rtdevice.h5
4 files changed, 141 insertions, 1 deletions
diff --git a/components/drivers/include/drivers/alarm.h b/components/drivers/include/drivers/alarm.h
index b5ebbc86d9..dd59f4c1e8 100644
--- a/components/drivers/include/drivers/alarm.h
+++ b/components/drivers/include/drivers/alarm.h
@@ -6,6 +6,8 @@
* Change Logs:
* Date Author Notes
* 2012-10-27 heyuanjie87 first version.
+ * 2013-05-17 aozima initial alarm event & mutex in system init.
+ * 2020-10-15 zhangsz add alarm flags hour minute second.
*/
#ifndef __ALARM_H__
@@ -22,6 +24,9 @@
#define RT_ALARM_WEEKLY 0x200 /* alarm weekly at Monday or Friday etc. */
#define RT_ALARM_MONTHLY 0x400 /* alarm monthly at someday */
#define RT_ALARM_YAERLY 0x800 /* alarm yearly at a certain date */
+#define RT_ALARM_HOUR 0x1000 /* alarm each hour at a certain min:second */
+#define RT_ALARM_MINUTE 0x2000 /* alarm each minute at a certain second */
+#define RT_ALARM_SECOND 0x4000 /* alarm each second */
/* alarm control cmd */
#define RT_ALARM_CTRL_MODIFY 1 /* modify alarm time or alarm flag */
@@ -67,6 +72,6 @@ void rt_alarm_update(rt_device_t dev, rt_uint32_t event);
rt_err_t rt_alarm_delete(rt_alarm_t alarm);
rt_err_t rt_alarm_start(rt_alarm_t alarm);
rt_err_t rt_alarm_stop(rt_alarm_t alarm);
-void rt_alarm_system_init(void);
+int rt_alarm_system_init(void);
#endif /* __ALARM_H__ */
diff --git a/components/drivers/include/drivers/phy.h b/components/drivers/include/drivers/phy.h
new file mode 100644
index 0000000000..2d1ad9f91f
--- /dev/null
+++ b/components/drivers/include/drivers/phy.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2006-2020, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-10-14 wangqiang the first version
+ */
+
+#ifndef __PHY_H__
+#define __PHY_H__
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Defines the PHY link speed. This is align with the speed for MAC. */
+enum phy_speed
+{
+ PHY_SPEED_10M = 0U, /* PHY 10M speed. */
+ PHY_SPEED_100M /* PHY 100M speed. */
+};
+
+/* Defines the PHY link duplex. */
+enum phy_duplex
+{
+ PHY_HALF_DUPLEX = 0U, /* PHY half duplex. */
+ PHY_FULL_DUPLEX /* PHY full duplex. */
+};
+
+/*! @brief Defines the PHY loopback mode. */
+enum phy_loop
+{
+ PHY_LOCAL_LOOP = 0U, /* PHY local loopback. */
+ PHY_REMOTE_LOOP /* PHY remote loopback. */
+};
+
+
+struct rt_phy_msg
+{
+ rt_uint32_t reg;
+ rt_uint32_t value;
+};
+
+typedef struct rt_phy_msg rt_phy_msg_t;
+
+
+struct rt_phy_device
+{
+ struct rt_device parent;
+ struct rt_mdio_bus *bus;
+ rt_uint32_t addr;
+ struct rt_phy_ops *ops;
+};
+
+typedef struct rt_phy_device rt_phy_t;
+
+
+enum {
+ PHY_STATUS_OK = 0,
+ PHY_STATUS_FAIL,
+ PHY_STATUS_TIMEOUT,
+};
+
+typedef rt_int32_t rt_phy_status;
+
+struct rt_phy_ops
+{
+ rt_phy_status (*init)(void *object, rt_uint32_t phy_addr, rt_uint32_t src_clock_hz);
+ rt_phy_status (*read)(rt_uint32_t reg, rt_uint32_t *data);
+ rt_phy_status (*write)(rt_uint32_t reg, rt_uint32_t data);
+ rt_phy_status (*loopback)(rt_uint32_t mode, rt_uint32_t speed, rt_bool_t enable);
+ rt_phy_status (*get_link_status)(rt_bool_t *status);
+ rt_phy_status (*get_link_speed_duplex)(rt_uint32_t *speed, rt_uint32_t *duplex);
+};
+
+rt_err_t rt_hw_phy_register(struct rt_phy_device *phy, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PHY_H__*/
diff --git a/components/drivers/include/drivers/phy_mdio.h b/components/drivers/include/drivers/phy_mdio.h
new file mode 100644
index 0000000000..d978ec2984
--- /dev/null
+++ b/components/drivers/include/drivers/phy_mdio.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006-2020, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-10-14 wangqiang the first version
+ */
+
+#ifndef __MDIO_H__
+#define __MDIO_H__
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+struct rt_mdio_bus_ops
+{
+ rt_bool_t (*init)(void *bus, rt_uint32_t src_clock_hz);
+ rt_size_t (*read)(void *bus, rt_uint32_t addr, rt_uint32_t reg, void *data, rt_uint32_t size);
+ rt_size_t (*write)(void *bus, rt_uint32_t addr, rt_uint32_t reg, void *data, rt_uint32_t size);
+ rt_bool_t (*uninit)(void *bus);
+};
+
+struct rt_mdio_bus
+{
+ void *hw_obj;
+ char *name;
+ struct rt_mdio_bus_ops *ops;
+};
+
+typedef struct rt_mdio_bus rt_mdio_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index f54290097c..f0fa2f5b4a 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -69,6 +69,11 @@ extern "C" {
#endif /* RT_USING_I2C_BITOPS */
#endif /* RT_USING_I2C */
+#ifdef RT_USING_PHY
+#include "drivers/phy.h"
+#include "drivers/phy_mdio.h"
+#endif /* RT_USING_PHY */
+
#ifdef RT_USING_SDIO
#include "drivers/mmcsd_core.h"
#include "drivers/sd.h"