Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
6c323103
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6c323103
编写于
11月 28, 2007
作者:
F
Francois Romieu
提交者:
David S. Miller
1月 28, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
r6040: remove virt_to_bus
Signed-off-by:
N
Francois Romieu
<
romieu@fr.zoreil.com
>
上级
5125a786
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
53 deletion
+50
-53
drivers/net/r6040.c
drivers/net/r6040.c
+50
-53
未找到文件。
drivers/net/r6040.c
浏览文件 @
6c323103
...
...
@@ -126,8 +126,8 @@
#define TX_DCNT 0x80
/* TX descriptor count */
#define RX_DCNT 0x80
/* RX descriptor count */
#define MAX_BUF_SIZE 0x600
#define
ALLOC_DESC_SIZE ((TX_DCNT+RX_DCNT) * \
sizeof(struct r6040_descriptor) + 0x10
)
#define
RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor))
#define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor)
)
#define MBCR_DEFAULT 0x012A
/* MAC Bus Control Register */
#define MCAST_MAX 4
/* Max number multicast addresses to filter */
...
...
@@ -164,10 +164,12 @@ struct r6040_private {
struct
r6040_descriptor
*
rx_remove_ptr
;
struct
r6040_descriptor
*
tx_insert_ptr
;
struct
r6040_descriptor
*
tx_remove_ptr
;
struct
r6040_descriptor
*
rx_ring
;
struct
r6040_descriptor
*
tx_ring
;
dma_addr_t
rx_ring_dma
;
dma_addr_t
tx_ring_dma
;
u16
tx_free_desc
,
rx_free_desc
,
phy_addr
,
phy_mode
;
u16
mcr0
,
mcr1
;
dma_addr_t
desc_dma
;
char
*
desc_pool
;
u16
switch_sig
;
struct
net_device
*
dev
;
struct
mii_if_info
mii_if
;
...
...
@@ -291,6 +293,7 @@ static void r6040_down(struct net_device *dev)
{
struct
r6040_private
*
lp
=
netdev_priv
(
dev
);
void
__iomem
*
ioaddr
=
lp
->
base
;
struct
pci_dev
*
pdev
=
lp
->
pdev
;
int
i
;
int
limit
=
2048
;
u16
*
adrp
;
...
...
@@ -334,8 +337,8 @@ static void r6040_down(struct net_device *dev)
}
/* Free Descriptor memory */
pci_free_consistent
(
lp
->
pdev
,
ALLOC_DESC_SIZE
,
lp
->
desc_pool
,
lp
->
desc
_dma
);
pci_free_consistent
(
pdev
,
RX_DESC_SIZE
,
lp
->
rx_ring
,
lp
->
rx_ring_dma
);
pci_free_consistent
(
pdev
,
TX_DESC_SIZE
,
lp
->
tx_ring
,
lp
->
tx_ring
_dma
);
}
static
int
...
...
@@ -577,67 +580,53 @@ static void r6040_poll_controller(struct net_device *dev)
#endif
static
void
r6040_init_ring_desc
(
struct
r6040_descriptor
*
desc_ring
,
dma_addr_t
desc_dma
,
int
size
)
{
struct
r6040_descriptor
*
desc
=
desc_ring
;
dma_addr_t
mapping
=
desc_dma
;
while
(
size
--
>
0
)
{
mapping
+=
sizeof
(
sizeof
(
*
desc
));
desc
->
ndesc
=
cpu_to_le32
(
mapping
);
desc
->
vndescp
=
desc
+
1
;
desc
++
;
}
desc
--
;
desc
->
ndesc
=
cpu_to_le32
(
desc_dma
);
desc
->
vndescp
=
desc_ring
;
}
/* Init RDC MAC */
static
void
r6040_up
(
struct
net_device
*
dev
)
{
struct
r6040_private
*
lp
=
netdev_priv
(
dev
);
struct
r6040_descriptor
*
descptr
;
void
__iomem
*
ioaddr
=
lp
->
base
;
int
i
;
__le32
tmp_addr
;
dma_addr_t
desc_dma
,
start_dma
;
/* Initialize */
lp
->
tx_free_desc
=
TX_DCNT
;
lp
->
rx_free_desc
=
0
;
/* Init descriptor */
memset
(
lp
->
desc_pool
,
0
,
ALLOC_DESC_SIZE
);
/* Let all descriptor = 0 */
lp
->
tx_insert_ptr
=
(
struct
r6040_descriptor
*
)
lp
->
desc_pool
;
lp
->
tx_remove_ptr
=
lp
->
tx_insert_ptr
;
lp
->
rx_insert_ptr
=
(
struct
r6040_descriptor
*
)
lp
->
tx_insert_ptr
+
TX_DCNT
;
lp
->
rx_remove_ptr
=
lp
->
rx_insert_ptr
;
lp
->
tx_remove_ptr
=
lp
->
tx_insert_ptr
=
lp
->
tx_ring
;
lp
->
rx_remove_ptr
=
lp
->
rx_insert_ptr
=
lp
->
rx_ring
;
/* Init TX descriptor */
descptr
=
lp
->
tx_insert_ptr
;
desc_dma
=
lp
->
desc_dma
;
start_dma
=
desc_dma
;
for
(
i
=
0
;
i
<
TX_DCNT
;
i
++
)
{
descptr
->
ndesc
=
cpu_to_le32
(
desc_dma
+
sizeof
(
struct
r6040_descriptor
));
descptr
->
vndescp
=
(
descptr
+
1
);
descptr
=
(
descptr
+
1
);
desc_dma
+=
sizeof
(
struct
r6040_descriptor
);
}
(
descptr
-
1
)
->
ndesc
=
cpu_to_le32
(
start_dma
);
(
descptr
-
1
)
->
vndescp
=
lp
->
tx_insert_ptr
;
r6040_init_ring_desc
(
lp
->
tx_ring
,
lp
->
tx_ring_dma
,
TX_DCNT
);
/* Init RX descriptor */
start_dma
=
desc_dma
;
descptr
=
lp
->
rx_insert_ptr
;
for
(
i
=
0
;
i
<
RX_DCNT
;
i
++
)
{
descptr
->
ndesc
=
cpu_to_le32
(
desc_dma
+
sizeof
(
struct
r6040_descriptor
));
descptr
->
vndescp
=
(
descptr
+
1
);
descptr
=
(
descptr
+
1
);
desc_dma
+=
sizeof
(
struct
r6040_descriptor
);
}
(
descptr
-
1
)
->
ndesc
=
cpu_to_le32
(
start_dma
);
(
descptr
-
1
)
->
vndescp
=
lp
->
rx_insert_ptr
;
r6040_init_ring_desc
(
lp
->
rx_ring
,
lp
->
rx_ring_dma
,
RX_DCNT
);
/* Allocate buffer for RX descriptor */
rx_buf_alloc
(
lp
,
dev
);
/* TX and RX descriptor start Register */
tmp_addr
=
cpu_to_le32
((
u32
)
lp
->
tx_insert_ptr
);
tmp_addr
=
virt_to_bus
((
volatile
void
*
)
tmp_addr
);
/* Lower 16-bits to MTD_SA0 */
iowrite16
(
tmp_addr
,
ioaddr
+
MTD_SA0
);
/* Higher 16-bits to MTD_SA1 */
iowrite16
((
u16
)(
tmp_addr
>>
16
),
ioaddr
+
MTD_SA1
);
tmp_addr
=
cpu_to_le32
((
u32
)
lp
->
rx_insert_ptr
);
tmp_addr
=
virt_to_bus
((
volatile
void
*
)
tmp_addr
);
iowrite16
(
tmp_addr
,
ioaddr
+
MRD_SA0
);
iowrite16
((
u16
)(
tmp_addr
>>
16
),
ioaddr
+
MRD_SA1
);
/*
* TX and RX descriptor start registers.
* Lower 16-bits to MxD_SA0. Higher 16-bits to MxD_SA1.
*/
iowrite16
(
lp
->
tx_ring_dma
,
ioaddr
+
MTD_SA0
);
iowrite16
(
lp
->
tx_ring_dma
>>
16
,
ioaddr
+
MTD_SA1
);
iowrite16
(
lp
->
rx_ring_dma
,
ioaddr
+
MRD_SA0
);
iowrite16
(
lp
->
rx_ring_dma
>>
16
,
ioaddr
+
MRD_SA1
);
/* Buffer Size Register */
iowrite16
(
MAX_BUF_SIZE
,
ioaddr
+
MR_BSR
);
...
...
@@ -743,10 +732,18 @@ r6040_open(struct net_device *dev)
r6040_mac_address
(
dev
);
/* Allocate Descriptor memory */
lp
->
desc_pool
=
pci_alloc_consistent
(
lp
->
pdev
,
ALLOC_DESC_SIZE
,
&
lp
->
desc_dma
);
if
(
!
lp
->
desc_pool
)
lp
->
rx_ring
=
pci_alloc_consistent
(
lp
->
pdev
,
RX_DESC_SIZE
,
&
lp
->
rx_ring_dma
);
if
(
!
lp
->
rx_ring
)
return
-
ENOMEM
;
lp
->
tx_ring
=
pci_alloc_consistent
(
lp
->
pdev
,
TX_DESC_SIZE
,
&
lp
->
tx_ring_dma
);
if
(
!
lp
->
tx_ring
)
{
pci_free_consistent
(
lp
->
pdev
,
RX_DESC_SIZE
,
lp
->
rx_ring
,
lp
->
rx_ring_dma
);
return
-
ENOMEM
;
}
r6040_up
(
dev
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录