diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-11 12:26:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-11 12:26:20 -0400 |
commit | 4120b028dd231743935d954732045a87edda2a0a (patch) | |
tree | b28e702ec5a3350d7772ee92233b4c169422a4f8 /drivers/net/sungem.c | |
parent | 9ec4ff421f032f24416217f23b0c82dc9a5f38f6 (diff) |
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: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/net/sungem.c')
-rw-r--r-- | drivers/net/sungem.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 3f67a42e8503..de399563a9db 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -2817,7 +2817,7 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
2817 | 2817 | ||
2818 | #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) | 2818 | #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC)) |
2819 | /* Fetch MAC address from vital product data of PCI ROM. */ | 2819 | /* Fetch MAC address from vital product data of PCI ROM. */ |
2820 | static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) | 2820 | static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr) |
2821 | { | 2821 | { |
2822 | int this_offset; | 2822 | int this_offset; |
2823 | 2823 | ||
@@ -2838,35 +2838,27 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char | |||
2838 | 2838 | ||
2839 | for (i = 0; i < 6; i++) | 2839 | for (i = 0; i < 6; i++) |
2840 | dev_addr[i] = readb(p + i); | 2840 | dev_addr[i] = readb(p + i); |
2841 | break; | 2841 | return 1; |
2842 | } | 2842 | } |
2843 | return 0; | ||
2843 | } | 2844 | } |
2844 | 2845 | ||
2845 | static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) | 2846 | static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr) |
2846 | { | 2847 | { |
2847 | u32 rom_reg_orig; | 2848 | size_t size; |
2848 | void __iomem *p; | 2849 | void __iomem *p = pci_map_rom(pdev, &size); |
2849 | |||
2850 | if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) { | ||
2851 | if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0) | ||
2852 | goto use_random; | ||
2853 | } | ||
2854 | 2850 | ||
2855 | pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); | 2851 | if (p) { |
2856 | pci_write_config_dword(pdev, pdev->rom_base_reg, | 2852 | int found; |
2857 | rom_reg_orig | PCI_ROM_ADDRESS_ENABLE); | ||
2858 | 2853 | ||
2859 | p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); | 2854 | found = readb(p) == 0x55 && |
2860 | if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) | 2855 | readb(p + 1) == 0xaa && |
2861 | find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); | 2856 | find_eth_addr_in_vpd(p, (64 * 1024), dev_addr); |
2862 | 2857 | pci_unmap_rom(pdev, p); | |
2863 | if (p != NULL) | 2858 | if (found) |
2864 | iounmap(p); | 2859 | return; |
2865 | 2860 | } | |
2866 | pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig); | ||
2867 | return; | ||
2868 | 2861 | ||
2869 | use_random: | ||
2870 | /* Sun MAC prefix then 3 random bytes. */ | 2862 | /* Sun MAC prefix then 3 random bytes. */ |
2871 | dev_addr[0] = 0x08; | 2863 | dev_addr[0] = 0x08; |
2872 | dev_addr[1] = 0x00; | 2864 | dev_addr[1] = 0x00; |