提交 748031f9 编写于 作者: M Magnus Damm 提交者: David S. Miller

net: allow sh_eth to get mac address through platform data

Extend the sh_eth driver to allow passing the mac address
using the platform data structure. This to simplify board
setup code.
Signed-off-by: NMagnus Damm <damm@opensource.se>
Tested-by: NKuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a6e4bc53
...@@ -7,6 +7,7 @@ struct sh_eth_plat_data { ...@@ -7,6 +7,7 @@ struct sh_eth_plat_data {
int phy; int phy;
int edmac_endian; int edmac_endian;
unsigned char mac_addr[6];
unsigned no_ether_link:1; unsigned no_ether_link:1;
unsigned ether_link_active_low:1; unsigned ether_link_active_low:1;
}; };
......
...@@ -298,16 +298,20 @@ static void update_mac_address(struct net_device *ndev) ...@@ -298,16 +298,20 @@ static void update_mac_address(struct net_device *ndev)
* When you want use this device, you must set MAC address in bootloader. * When you want use this device, you must set MAC address in bootloader.
* *
*/ */
static void read_mac_address(struct net_device *ndev) static void read_mac_address(struct net_device *ndev, unsigned char *mac)
{ {
u32 ioaddr = ndev->base_addr; u32 ioaddr = ndev->base_addr;
ndev->dev_addr[0] = (ctrl_inl(ioaddr + MAHR) >> 24); if (mac[0] || mac[1] || mac[2] || mac[3] || mac[4] || mac[5]) {
ndev->dev_addr[1] = (ctrl_inl(ioaddr + MAHR) >> 16) & 0xFF; memcpy(ndev->dev_addr, mac, 6);
ndev->dev_addr[2] = (ctrl_inl(ioaddr + MAHR) >> 8) & 0xFF; } else {
ndev->dev_addr[3] = (ctrl_inl(ioaddr + MAHR) & 0xFF); ndev->dev_addr[0] = (ctrl_inl(ioaddr + MAHR) >> 24);
ndev->dev_addr[4] = (ctrl_inl(ioaddr + MALR) >> 8) & 0xFF; ndev->dev_addr[1] = (ctrl_inl(ioaddr + MAHR) >> 16) & 0xFF;
ndev->dev_addr[5] = (ctrl_inl(ioaddr + MALR) & 0xFF); ndev->dev_addr[2] = (ctrl_inl(ioaddr + MAHR) >> 8) & 0xFF;
ndev->dev_addr[3] = (ctrl_inl(ioaddr + MAHR) & 0xFF);
ndev->dev_addr[4] = (ctrl_inl(ioaddr + MALR) >> 8) & 0xFF;
ndev->dev_addr[5] = (ctrl_inl(ioaddr + MALR) & 0xFF);
}
} }
struct bb_info { struct bb_info {
...@@ -1427,7 +1431,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -1427,7 +1431,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
mdp->post_fw = POST_FW >> (devno << 1); mdp->post_fw = POST_FW >> (devno << 1);
/* read and set MAC address */ /* read and set MAC address */
read_mac_address(ndev); read_mac_address(ndev, pd->mac_addr);
/* First device only init */ /* First device only init */
if (!devno) { if (!devno) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册