Commit 4120b028 authored by Linus Torvalds's avatar Linus Torvalds

Sun GEM ethernet: enable and map PCI ROM properly

This same patch was reported to fix the MAC address detection on sunhme
(next patch).  Most people seem to be running this on Sparcs or PPC
machines, where we get the MAC address from their respective firmware
rather than from the (previously broken) ROM mapping routines.
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9ec4ff42
...@@ -2817,7 +2817,7 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -2817,7 +2817,7 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
#if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC))
/* Fetch MAC address from vital product data of PCI ROM. */ /* Fetch MAC address from vital product data of PCI ROM. */
static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
{ {
int this_offset; int this_offset;
...@@ -2838,35 +2838,27 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char ...@@ -2838,35 +2838,27 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
dev_addr[i] = readb(p + i); dev_addr[i] = readb(p + i);
break; return 1;
} }
return 0;
} }
static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr)
{ {
u32 rom_reg_orig; size_t size;
void __iomem *p; void __iomem *p = pci_map_rom(pdev, &size);
if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) {
if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0)
goto use_random;
}
pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); if (p) {
pci_write_config_dword(pdev, pdev->rom_base_reg, int found;
rom_reg_orig | PCI_ROM_ADDRESS_ENABLE);
p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); found = readb(p) == 0x55 &&
if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) readb(p + 1) == 0xaa &&
find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
pci_unmap_rom(pdev, p);
if (p != NULL) if (found)
iounmap(p);
pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig);
return; return;
}
use_random:
/* Sun MAC prefix then 3 random bytes. */ /* Sun MAC prefix then 3 random bytes. */
dev_addr[0] = 0x08; dev_addr[0] = 0x08;
dev_addr[1] = 0x00; dev_addr[1] = 0x00;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment