Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: ethernet: dm9000: Accept a MAC address as a bootarg for CI20. #37

Merged
merged 1 commit into from
Jun 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions drivers/net/ethernet/davicom/dm9000.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@

#include "dm9000.h"

#ifdef CONFIG_JZ4780_CI20
static char *mac_addr = NULL;
module_param(mac_addr, charp, 0);
#endif

/* Board/System/Debug information/definition ---------------- */

#define DM9000_PHY 0x40 /* PHY address 0x01 */
Expand Down Expand Up @@ -1438,6 +1443,10 @@ dm9000_probe(struct platform_device *pdev)
int reset_gpios;
enum of_gpio_flags flags;
struct regulator *power;
#ifdef CONFIG_JZ4780_CI20
u8 eth_addr[6];
ssize_t sz = 0;
#endif

power = devm_regulator_get(dev, "vcc");
if (IS_ERR(power)) {
Expand Down Expand Up @@ -1666,20 +1675,34 @@ dm9000_probe(struct platform_device *pdev)
db->mii.mdio_read = dm9000_phy_read;
db->mii.mdio_write = dm9000_phy_write;

mac_src = "eeprom";
#ifdef CONFIG_JZ4780_CI20
mac_src = "bootarg";
if (mac_addr)
sz = sscanf(mac_addr, "%2x:%2x:%2x:%2x:%2x:%2x",
(unsigned int *)eth_addr,
(unsigned int *)(eth_addr + 1),
(unsigned int *)(eth_addr + 2),
(unsigned int *)(eth_addr + 3),
(unsigned int *)(eth_addr + 4),
(unsigned int *)(eth_addr + 5));
if (sz == ETH_ALEN)
ether_addr_copy(ndev->dev_addr, eth_addr);
#endif

/* try reading the node address from the attached EEPROM */
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading the node address from the attached EEPROM */
mac_src = "eeprom";
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
}

if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
mac_src = "platform data";
memcpy(ndev->dev_addr, pdata->dev_addr, ETH_ALEN);
ether_addr_copy(ndev->dev_addr, pdata->dev_addr);
}

if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */

mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
Expand All @@ -1693,7 +1716,6 @@ dm9000_probe(struct platform_device *pdev)
mac_src = "random";
}


platform_set_drvdata(pdev, ndev);
ret = register_netdev(ndev);

Expand Down