Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
76e1c802
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
76e1c802
编写于
11月 05, 2017
作者:
W
weety
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BSP][dm365] Fixed net link down issue.
上级
06e84c8f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
29 deletion
+16
-29
bsp/dm365/drivers/davinci_emac.c
bsp/dm365/drivers/davinci_emac.c
+16
-29
未找到文件。
bsp/dm365/drivers/davinci_emac.c
浏览文件 @
76e1c802
...
...
@@ -62,7 +62,6 @@ static inline rt_uint32_t virt_to_phys(void *addr)
static
struct
emac_priv
davinci_emac_device
;
static
struct
rt_semaphore
sem_ack
;
/* clock frequency for EMAC */
static
unsigned
long
emac_bus_frequency
;
...
...
@@ -240,6 +239,7 @@ static int davinci_emac_phy_init(rt_device_t dev)
rt_kprintf
(
"%s: link down (status: 0x%04x)
\n
"
,
dev
->
parent
.
name
,
status
);
priv
->
link
=
0
;
eth_device_linkchange
(
&
priv
->
parent
,
RT_FALSE
);
return
0
;
}
else
{
adv
=
emac_mii_read
(
priv
,
priv
->
phy_addr
,
MII_ADVERTISE
);
...
...
@@ -256,6 +256,7 @@ static int davinci_emac_phy_init(rt_device_t dev)
priv
->
speed
=
speed
;
priv
->
duplex
=
duplex
;
priv
->
link
=
1
;
eth_device_linkchange
(
&
priv
->
parent
,
RT_TRUE
);
return
1
;
}
...
...
@@ -387,7 +388,7 @@ static int emac_net_tx_complete(struct emac_priv *priv,
priv
->
net_dev_stats
.
tx_bytes
+=
p
->
len
;
//free pbuf
}
rt_sem_release
(
&
sem_ack
);
return
0
;
}
...
...
@@ -553,6 +554,8 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, rt_uint
struct
emac_tx_bd
__iomem
*
curr_bd
;
struct
emac_txch
*
txch
;
struct
emac_netbufobj
*
buf_list
;
rt_uint32_t
num_pkts
=
0
;
int
retry
=
0
;
txch
=
priv
->
txch
[
ch
];
buf_list
=
pkt
->
buf_list
;
/* get handle to the buffer array */
...
...
@@ -563,12 +566,21 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, rt_uint
pkt
->
pkt_length
=
EMAC_DEF_MIN_ETHPKTSIZE
;
}
try:
rt_sem_take
(
&
priv
->
tx_lock
,
RT_WAITING_FOREVER
);
curr_bd
=
txch
->
bd_pool_head
;
if
(
curr_bd
==
RT_NULL
)
{
txch
->
out_of_tx_bd
++
;
rt_sem_release
(
&
priv
->
tx_lock
);
return
EMAC_ERR_TX_OUT_OF_BD
;
num_pkts
=
emac_tx_bdproc
(
priv
,
EMAC_DEF_TX_CH
,
EMAC_DEF_TX_MAX_SERVICE
);
if
(
!
num_pkts
)
{
retry
++
;
if
(
retry
>
5
)
return
EMAC_ERR_TX_OUT_OF_BD
;
rt_thread_delay
(
1
);
}
goto
try
;
}
txch
->
bd_pool_head
=
curr_bd
->
next
;
...
...
@@ -713,38 +725,14 @@ static void emac_dev_tx_timeout(struct emac_priv *priv)
/* transmit packet. */
rt_err_t
rt_davinci_emac_tx
(
rt_device_t
dev
,
struct
pbuf
*
p
)
{
/*struct pbuf* q;
rt_uint8_t* bufptr, *buf = RT_NULL;
unsigned long ctrl;
rt_uint32_t addr;*/
rt_err_t
err
;
struct
emac_priv
*
priv
=
dev
->
user_data
;
emac_dev_xmit
(
p
,
priv
);
#if 0
buf = rt_malloc(p->tot_len);
if (!buf) {
rt_kprintf("%s:alloc buf failed\n", __func__);
return -RT_ENOMEM;
}
bufptr = buf;
/*for (q = p; q != RT_NULL; q = q->next)
{
memcpy(bufptr, q->payload, q->len);
bufptr += q->len;
}*/
#endif
/* wait ack */
err
=
rt_sem_take
(
&
sem_ack
,
RT_TICK_PER_SECOND
*
5
);
err
=
emac_dev_xmit
(
p
,
priv
);
if
(
err
!=
RT_EOK
)
{
emac_dev_tx_timeout
(
priv
);
}
//rt_free(buf);
return
RT_EOK
;
}
...
...
@@ -1672,7 +1660,6 @@ void rt_hw_davinci_emac_init()
davinci_emac_device
.
version
=
EMAC_VERSION_2
;
davinci_emac_device
.
rmii_en
=
0
;
davinci_emac_device
.
phy_addr
=
0x09
;
rt_sem_init
(
&
sem_ack
,
"tx_ack"
,
0
,
RT_IPC_FLAG_FIFO
);
rt_sem_init
(
&
priv
->
tx_lock
,
"tx_lock"
,
1
,
RT_IPC_FLAG_FIFO
);
rt_sem_init
(
&
priv
->
rx_lock
,
"rx_lock"
,
1
,
RT_IPC_FLAG_FIFO
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录