2018-12-26 10:17:11 +08:00
|
|
|
/*
|
2023-01-09 10:20:16 +08:00
|
|
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
2018-12-26 10:17:11 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2018-12-25 zylx first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRV_ETH_H__
|
|
|
|
#define __DRV_ETH_H__
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
#include <rtdevice.h>
|
|
|
|
#include <board.h>
|
|
|
|
|
|
|
|
/* The PHY basic control register */
|
|
|
|
#define PHY_BASIC_CONTROL_REG 0x00U
|
|
|
|
#define PHY_RESET_MASK (1<<15)
|
|
|
|
#define PHY_AUTO_NEGOTIATION_MASK (1<<12)
|
|
|
|
|
|
|
|
/* The PHY basic status register */
|
|
|
|
#define PHY_BASIC_STATUS_REG 0x01U
|
|
|
|
#define PHY_LINKED_STATUS_MASK (1<<2)
|
|
|
|
#define PHY_AUTONEGO_COMPLETE_MASK (1<<5)
|
|
|
|
|
|
|
|
/* The PHY ID one register */
|
|
|
|
#define PHY_ID1_REG 0x02U
|
|
|
|
/* The PHY ID two register */
|
|
|
|
#define PHY_ID2_REG 0x03U
|
|
|
|
/* The PHY auto-negotiate advertise register */
|
|
|
|
#define PHY_AUTONEG_ADVERTISE_REG 0x04U
|
|
|
|
|
2023-12-26 20:56:31 +08:00
|
|
|
#if defined(PHY_USING_LAN8720A) || defined(PHY_USING_LAN8742A)
|
2018-12-26 10:17:11 +08:00
|
|
|
/* The PHY interrupt source flag register. */
|
|
|
|
#define PHY_INTERRUPT_FLAG_REG 0x1DU
|
|
|
|
/* The PHY interrupt mask register. */
|
2019-09-03 16:34:49 +08:00
|
|
|
#define PHY_INTERRUPT_MASK_REG 0x1EU
|
2018-12-26 10:17:11 +08:00
|
|
|
#define PHY_LINK_DOWN_MASK (1<<4)
|
|
|
|
#define PHY_AUTO_NEGO_COMPLETE_MASK (1<<6)
|
|
|
|
/* The PHY status register. */
|
|
|
|
#define PHY_Status_REG 0x1FU
|
|
|
|
#define PHY_10M_MASK (1<<2)
|
|
|
|
#define PHY_100M_MASK (1<<3)
|
|
|
|
#define PHY_FULL_DUPLEX_MASK (1<<4)
|
2019-09-03 18:28:58 +08:00
|
|
|
#define PHY_Status_SPEED_10M(sr) ((sr) & PHY_10M_MASK)
|
|
|
|
#define PHY_Status_SPEED_100M(sr) ((sr) & PHY_100M_MASK)
|
|
|
|
#define PHY_Status_FULL_DUPLEX(sr) ((sr) & PHY_FULL_DUPLEX_MASK)
|
2018-12-26 10:17:11 +08:00
|
|
|
|
2021-07-30 14:14:08 +08:00
|
|
|
#elif defined(PHY_USING_DM9161CEP)
|
2018-12-28 14:16:19 +08:00
|
|
|
#define PHY_Status_REG 0x11U
|
|
|
|
#define PHY_10M_MASK ((1<<12) || (1<<13))
|
|
|
|
#define PHY_100M_MASK ((1<<14) || (1<<15))
|
|
|
|
#define PHY_FULL_DUPLEX_MASK ((1<<15) || (1<<13))
|
2019-09-03 18:28:58 +08:00
|
|
|
#define PHY_Status_SPEED_10M(sr) ((sr) & PHY_10M_MASK)
|
|
|
|
#define PHY_Status_SPEED_100M(sr) ((sr) & PHY_100M_MASK)
|
|
|
|
#define PHY_Status_FULL_DUPLEX(sr) ((sr) & PHY_FULL_DUPLEX_MASK)
|
2019-01-08 14:01:02 +08:00
|
|
|
/* The PHY interrupt source flag register. */
|
|
|
|
#define PHY_INTERRUPT_FLAG_REG 0x15U
|
|
|
|
/* The PHY interrupt mask register. */
|
2019-09-03 16:34:49 +08:00
|
|
|
#define PHY_INTERRUPT_MASK_REG 0x15U
|
2019-01-08 14:01:02 +08:00
|
|
|
#define PHY_LINK_CHANGE_FLAG (1<<2)
|
|
|
|
#define PHY_LINK_CHANGE_MASK (1<<9)
|
|
|
|
#define PHY_INT_MASK 0
|
2018-12-28 14:16:19 +08:00
|
|
|
|
2021-07-30 14:14:08 +08:00
|
|
|
#elif defined(PHY_USING_DP83848C)
|
2019-09-03 17:16:36 +08:00
|
|
|
#define PHY_Status_REG 0x10U
|
|
|
|
#define PHY_10M_MASK (1<<1)
|
|
|
|
#define PHY_FULL_DUPLEX_MASK (1<<2)
|
|
|
|
#define PHY_Status_SPEED_10M(sr) ((sr) & PHY_10M_MASK)
|
|
|
|
#define PHY_Status_SPEED_100M(sr) (!PHY_Status_SPEED_10M(sr))
|
|
|
|
#define PHY_Status_FULL_DUPLEX(sr) ((sr) & PHY_FULL_DUPLEX_MASK)
|
|
|
|
/* The PHY interrupt source flag register. */
|
|
|
|
#define PHY_INTERRUPT_FLAG_REG 0x12U
|
|
|
|
#define PHY_LINK_CHANGE_FLAG (1<<13)
|
|
|
|
/* The PHY interrupt control register. */
|
|
|
|
#define PHY_INTERRUPT_CTRL_REG 0x11U
|
|
|
|
#define PHY_INTERRUPT_EN ((1<<0)|(1<<1))
|
|
|
|
/* The PHY interrupt mask register. */
|
|
|
|
#define PHY_INTERRUPT_MASK_REG 0x12U
|
|
|
|
#define PHY_INT_MASK (1<<5)
|
|
|
|
|
2023-12-26 20:56:31 +08:00
|
|
|
#elif defined(PHY_USING_YT8512C)
|
2021-08-08 07:29:05 +08:00
|
|
|
/* The PHY interrupt source flag register. */
|
2023-12-26 20:56:31 +08:00
|
|
|
#define PHY_INTERRUPT_FLAG_REG 0x13U
|
2021-08-08 07:29:05 +08:00
|
|
|
/* The PHY interrupt mask register. */
|
2023-12-26 20:56:31 +08:00
|
|
|
#define PHY_INTERRUPT_MASK_REG 0x12U
|
|
|
|
/* The PHY auto nego and link change mask. */
|
|
|
|
#define PHY_INT_MASK (1<<15)|(3<<10)
|
2021-08-08 07:29:05 +08:00
|
|
|
/* The PHY status register. */
|
2023-12-26 20:56:31 +08:00
|
|
|
#define PHY_Status_REG 0x11U
|
|
|
|
#define PHY_100M_MASK (1<<14)
|
|
|
|
#define PHY_FULL_DUPLEX_MASK (1<<13)
|
|
|
|
#define PHY_Status_SPEED_10M(sr) (!PHY_Status_SPEED_100M(sr))
|
2021-08-08 07:29:05 +08:00
|
|
|
#define PHY_Status_SPEED_100M(sr) ((sr) & PHY_100M_MASK)
|
|
|
|
#define PHY_Status_FULL_DUPLEX(sr) ((sr) & PHY_FULL_DUPLEX_MASK)
|
2023-12-26 20:56:31 +08:00
|
|
|
#endif /* defined(PHY_USING_LAN8720A) || defined(PHY_USING_LAN8742A) */
|
2021-08-08 07:29:05 +08:00
|
|
|
|
2018-12-26 10:17:11 +08:00
|
|
|
#endif /* __DRV_ETH_H__ */
|