aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWilly Tarreau <willy@w.ods.org>2005-09-11 03:04:07 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-11 12:28:17 -0400
commitce1289adeb67b5480f35cb257cbf6e9881153783 (patch)
treec1643ec9c2e0df2a53f52df27b5075e5acf63224 /drivers
parent4120b028dd231743935d954732045a87edda2a0a (diff)
[PATCH] Sun HME: enable and map PCI ROM properly
This ports the Sun GEM ROM mapping/enable fixes it sunhme (which used the same PCI ROM mapping code). Without this, I get NULL MAC addresses for all 4 ports (it's a SUN QFE). With it, I get the correct addresses (the ones printed on the label on the card). Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sunhme.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index f02fe4119b2c..9f046cae2f71 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2954,7 +2954,7 @@ static int is_quattro_p(struct pci_dev *pdev)
2954} 2954}
2955 2955
2956/* Fetch MAC address from vital product data of PCI ROM. */ 2956/* Fetch MAC address from vital product data of PCI ROM. */
2957static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) 2957static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr)
2958{ 2958{
2959 int this_offset; 2959 int this_offset;
2960 2960
@@ -2977,42 +2977,33 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, uns
2977 2977
2978 for (i = 0; i < 6; i++) 2978 for (i = 0; i < 6; i++)
2979 dev_addr[i] = readb(p + i); 2979 dev_addr[i] = readb(p + i);
2980 break; 2980 return 1;
2981 } 2981 }
2982 index--; 2982 index--;
2983 } 2983 }
2984 return 0;
2984} 2985}
2985 2986
2986static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) 2987static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr)
2987{ 2988{
2988 u32 rom_reg_orig; 2989 size_t size;
2989 void __iomem *p; 2990 void __iomem *p = pci_map_rom(pdev, &size);
2990 int index;
2991 2991
2992 index = 0; 2992 if (p) {
2993 if (is_quattro_p(pdev)) 2993 int index = 0;
2994 index = PCI_SLOT(pdev->devfn); 2994 int found;
2995
2996 if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) {
2997 if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0)
2998 goto use_random;
2999 }
3000 2995
3001 pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig); 2996 if (is_quattro_p(pdev))
3002 pci_write_config_dword(pdev, pdev->rom_base_reg, 2997 index = PCI_SLOT(pdev->devfn);
3003 rom_reg_orig | PCI_ROM_ADDRESS_ENABLE);
3004 2998
3005 p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024)); 2999 found = readb(p) == 0x55 &&
3006 if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa) 3000 readb(p + 1) == 0xaa &&
3007 find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); 3001 find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr);
3008 3002 pci_unmap_rom(pdev, p);
3009 if (p != NULL) 3003 if (found)
3010 iounmap(p); 3004 return;
3011 3005 }
3012 pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig);
3013 return;
3014 3006
3015use_random:
3016 /* Sun MAC prefix then 3 random bytes. */ 3007 /* Sun MAC prefix then 3 random bytes. */
3017 dev_addr[0] = 0x08; 3008 dev_addr[0] = 0x08;
3018 dev_addr[1] = 0x00; 3009 dev_addr[1] = 0x00;