Skip to content

Commit 067315f

Browse files
committed
[phy] fix the PHY_FULL_DUPLEX conflicts
1 parent 1990af6 commit 067315f

File tree

7 files changed

+36
-58
lines changed

7 files changed

+36
-58
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_eth.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030

3131
#define MAX_ADDR_LEN 6
3232

33+
#undef PHY_FULL_DUPLEX
34+
#define PHY_LINK (1 << 0)
35+
#define PHY_100M (1 << 1)
36+
#define PHY_FULL_DUPLEX (1 << 2)
37+
3338
struct rt_stm32_eth
3439
{
3540
/* inherit from ethernet device */
@@ -401,12 +406,6 @@ void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth)
401406
LOG_E("eth err");
402407
}
403408

404-
enum {
405-
PHY_LINK = (1 << 0),
406-
PHY_100M = (1 << 1),
407-
PHY_FULL_DUPLEX = (1 << 2),
408-
};
409-
410409
static void phy_linkchange()
411410
{
412411
static rt_uint8_t phy_speed = 0;

bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_eth.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
#define LOG_TAG "drv.emac"
2323
#include <drv_log.h>
2424

25+
#undef PHY_FULL_DUPLEX
26+
#undef PHY_HALF_DUPLEX
27+
#define PHY_LINK (1 << 0)
28+
#define PHY_10M (1 << 1)
29+
#define PHY_100M (1 << 2)
30+
#define PHY_1000M (1 << 3)
31+
#define PHY_FULL_DUPLEX (1 << 4)
32+
#define PHY_HALF_DUPLEX (1 << 5)
33+
2534
#define MAX_ADDR_LEN 6
2635
rt_base_t level;
2736

bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_eth.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ typedef struct
5050
uint32_t rdes3;
5151
} RxDmaDesc;
5252

53-
enum {
54-
PHY_LINK = (1 << 0),
55-
PHY_10M = (1 << 1),
56-
PHY_100M = (1 << 2),
57-
PHY_1000M = (1 << 3),
58-
PHY_FULL_DUPLEX = (1 << 4),
59-
PHY_HALF_DUPLEX = (1 << 5)
60-
};
61-
62-
6353
#define RTL8211F_PHY_ADDR 1 /* PHY address */
6454

6555
#define ETH_TXBUFNB 4 /* 4 Tx buffers of size ETH_TX_BUF_SIZE */

bsp/stm32/stm32mp157a-st-ev1/board/ports/eth/drv_eth.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ rt_base_t level;
3030
#define TX_DMA_ADD_BASE 0x2FFC7000
3131
#define RX_DMA_ADD_BASE 0x2FFC7100
3232

33+
#undef PHY_FULL_DUPLEX
34+
#undef PHY_HALF_DUPLEX
35+
#define PHY_LINK (1 << 0)
36+
#define PHY_10M (1 << 1)
37+
#define PHY_100M (1 << 2)
38+
#define PHY_1000M (1 << 3)
39+
#define PHY_FULL_DUPLEX (1 << 4)
40+
#define PHY_HALF_DUPLEX (1 << 5)
41+
3342
#if defined(__ICCARM__)
3443
/* transmit buffer */
3544
#pragma location = TX_ADD_BASE

bsp/stm32/stm32mp157a-st-ev1/board/ports/eth/drv_eth.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ typedef struct
4242
uint32_t rdes3;
4343
} RxDmaDesc;
4444

45-
enum {
46-
PHY_LINK = (1 << 0),
47-
PHY_10M = (1 << 1),
48-
PHY_100M = (1 << 2),
49-
PHY_1000M = (1 << 3),
50-
PHY_FULL_DUPLEX = (1 << 4),
51-
PHY_HALF_DUPLEX = (1 << 5)
52-
};
53-
5445
#define RTL8211E_PHY_ADDR 7 /* PHY address */
5546

5647
#define ETH_TXBUFNB 4 /* 4 Tx buffers of size ETH_TX_BUF_SIZE */

components/drivers/include/drivers/phy.h

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,34 @@ extern "C"
1919
#endif
2020

2121
/* Defines the PHY link speed. This is align with the speed for MAC. */
22-
enum phy_speed
23-
{
24-
PHY_SPEED_10M = 0U, /* PHY 10M speed. */
25-
PHY_SPEED_100M /* PHY 100M speed. */
26-
};
22+
#define PHY_SPEED_10M 0U /* PHY 10M speed. */
23+
#define PHY_SPEED_100M 1U /* PHY 100M speed. */
2724

2825
/* Defines the PHY link duplex. */
29-
enum phy_duplex
30-
{
31-
PHY_HALF_DUPLEX = 0U, /* PHY half duplex. */
32-
PHY_FULL_DUPLEX /* PHY full duplex. */
33-
};
26+
#define PHY_HALF_DUPLEX 0U /* PHY half duplex. */
27+
#define PHY_FULL_DUPLEX 1U /* PHY full duplex. */
3428

3529
/*! @brief Defines the PHY loopback mode. */
36-
enum phy_loop
37-
{
38-
PHY_LOCAL_LOOP = 0U, /* PHY local loopback. */
39-
PHY_REMOTE_LOOP /* PHY remote loopback. */
40-
};
30+
#define PHY_LOCAL_LOOP 0U /* PHY local loopback. */
31+
#define PHY_REMOTE_LOOP 1U /* PHY remote loopback. */
4132

33+
#define PHY_STATUS_OK 0U
34+
#define PHY_STATUS_FAIL 1U
35+
#define PHY_STATUS_TIMEOUT 2U
4236

43-
struct rt_phy_msg
37+
typedef struct rt_phy_msg
4438
{
4539
rt_uint32_t reg;
4640
rt_uint32_t value;
47-
};
41+
}rt_phy_msg_t;
4842

49-
typedef struct rt_phy_msg rt_phy_msg_t;
50-
51-
52-
struct rt_phy_device
43+
typedef struct rt_phy_device
5344
{
5445
struct rt_device parent;
5546
struct rt_mdio_bus *bus;
5647
rt_uint32_t addr;
5748
struct rt_phy_ops *ops;
58-
};
59-
60-
typedef struct rt_phy_device rt_phy_t;
61-
62-
63-
enum {
64-
PHY_STATUS_OK = 0,
65-
PHY_STATUS_FAIL,
66-
PHY_STATUS_TIMEOUT,
67-
};
49+
}rt_phy_t;
6850

6951
typedef rt_int32_t rt_phy_status;
7052

components/drivers/phy/phy.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ static rt_size_t phy_device_write(rt_device_t dev, rt_off_t pos, const void *buf
3131
return phy->bus->ops->write(phy->bus, phy->addr, msg->reg, &(msg->value), 4);
3232
}
3333

34-
35-
3634
#ifdef RT_USING_DEVICE_OPS
3735
const static struct rt_device_ops phy_ops =
3836
{

0 commit comments

Comments
 (0)