b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From f393eaacf178e7e8a61eb11a96edd7dfb35cb49d Mon Sep 17 00:00:00 2001 |
| 2 | From: Jonas Gorski <jogo@openwrt.org> |
| 3 | Date: Thu, 31 Jul 2014 20:39:44 +0200 |
| 4 | Subject: [PATCH 10/10] MIPS: BCM63XX: allow setting a pci bus/device for |
| 5 | fallback sprom |
| 6 | |
| 7 | Warn if the set pci bus/slot does not match the actual request. |
| 8 | |
| 9 | Signed-off-by: Jonas Gorski <jogo@openwrt.org> |
| 10 | --- |
| 11 | arch/mips/bcm63xx/sprom.c | 31 ++++++++++++++++++---- |
| 12 | .../asm/mach-bcm63xx/bcm63xx_fallback_sprom.h | 3 +++ |
| 13 | 2 files changed, 29 insertions(+), 5 deletions(-) |
| 14 | |
| 15 | --- a/arch/mips/bcm63xx/sprom.c |
| 16 | +++ b/arch/mips/bcm63xx/sprom.c |
| 17 | @@ -381,13 +381,25 @@ static __initconst u16 bcm4331_sprom[] = |
| 18 | |
| 19 | #endif /* CONFIG_BCMA_HOST_PCI */ |
| 20 | |
| 21 | -static struct ssb_sprom bcm63xx_sprom; |
| 22 | +struct fallback_sprom_match { |
| 23 | + u8 pci_bus; |
| 24 | + u8 pci_dev; |
| 25 | + struct ssb_sprom sprom; |
| 26 | +}; |
| 27 | + |
| 28 | +static struct fallback_sprom_match fallback_sprom; |
| 29 | |
| 30 | #if defined(CONFIG_SSB_PCIHOST) |
| 31 | int bcm63xx_get_fallback_ssb_sprom(struct ssb_bus *bus, struct ssb_sprom *out) |
| 32 | { |
| 33 | if (bus->bustype == SSB_BUSTYPE_PCI) { |
| 34 | - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom)); |
| 35 | + if (bus->host_pci->bus->number != fallback_sprom.pci_bus || |
| 36 | + PCI_SLOT(bus->host_pci->devfn) != fallback_sprom.pci_dev) |
| 37 | + pr_warn("ssb_fallback_sprom: pci bus/device num mismatch: expected %i/%i, but got %i/%i\n", |
| 38 | + fallback_sprom.pci_bus, fallback_sprom.pci_dev, |
| 39 | + bus->host_pci->bus->number, |
| 40 | + PCI_SLOT(bus->host_pci->devfn)); |
| 41 | + memcpy(out, &fallback_sprom.sprom, sizeof(struct ssb_sprom)); |
| 42 | return 0; |
| 43 | } else { |
| 44 | printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n"); |
| 45 | @@ -400,7 +412,13 @@ int bcm63xx_get_fallback_ssb_sprom(struc |
| 46 | int bcm63xx_get_fallback_bcma_sprom(struct bcma_bus *bus, struct ssb_sprom *out) |
| 47 | { |
| 48 | if (bus->hosttype == BCMA_HOSTTYPE_PCI) { |
| 49 | - memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom)); |
| 50 | + if (bus->host_pci->bus->number != fallback_sprom.pci_bus || |
| 51 | + PCI_SLOT(bus->host_pci->devfn) != fallback_sprom.pci_dev) |
| 52 | + pr_warn("bcma_fallback_sprom: pci bus/device num mismatch: expected %i/%i, but got %i/%i\n", |
| 53 | + fallback_sprom.pci_bus, fallback_sprom.pci_dev, |
| 54 | + bus->host_pci->bus->number, |
| 55 | + PCI_SLOT(bus->host_pci->devfn)); |
| 56 | + memcpy(out, &fallback_sprom.sprom, sizeof(struct ssb_sprom)); |
| 57 | return 0; |
| 58 | } else { |
| 59 | printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n"); |
| 60 | @@ -1026,8 +1044,8 @@ int __init bcm63xx_register_fallback_spr |
| 61 | break; |
| 62 | #endif |
| 63 | case SPROM_DEFAULT: |
| 64 | - memcpy(&bcm63xx_sprom, &bcm63xx_default_sprom, |
| 65 | - sizeof(bcm63xx_sprom)); |
| 66 | + memcpy(&fallback_sprom.sprom, &bcm63xx_default_sprom, |
| 67 | + sizeof(bcm63xx_default_sprom)); |
| 68 | break; |
| 69 | default: |
| 70 | return -EINVAL; |
| 71 | @@ -1037,12 +1055,15 @@ int __init bcm63xx_register_fallback_spr |
| 72 | sprom_apply_fixups(template_sprom, data->board_fixups, |
| 73 | data->num_board_fixups); |
| 74 | |
| 75 | - sprom_extract(&bcm63xx_sprom, template_sprom, size); |
| 76 | + sprom_extract(&fallback_sprom.sprom, template_sprom, size); |
| 77 | } |
| 78 | |
| 79 | - memcpy(bcm63xx_sprom.il0mac, data->mac_addr, ETH_ALEN); |
| 80 | - memcpy(bcm63xx_sprom.et0mac, data->mac_addr, ETH_ALEN); |
| 81 | - memcpy(bcm63xx_sprom.et1mac, data->mac_addr, ETH_ALEN); |
| 82 | + memcpy(fallback_sprom.sprom.il0mac, data->mac_addr, ETH_ALEN); |
| 83 | + memcpy(fallback_sprom.sprom.et0mac, data->mac_addr, ETH_ALEN); |
| 84 | + memcpy(fallback_sprom.sprom.et1mac, data->mac_addr, ETH_ALEN); |
| 85 | + |
| 86 | + fallback_sprom.pci_bus = data->pci_bus; |
| 87 | + fallback_sprom.pci_dev = data->pci_dev; |
| 88 | #endif /* defined(CONFIG_SSB_PCIHOST) || defined(CONFIG_BCMA_HOST_PCI) */ |
| 89 | |
| 90 | #if defined(CONFIG_SSB_PCIHOST) |
| 91 | --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h |
| 92 | +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_fallback_sprom.h |
| 93 | @@ -30,6 +30,9 @@ struct fallback_sprom_data { |
| 94 | u8 mac_addr[ETH_ALEN]; |
| 95 | enum sprom_type type; |
| 96 | |
| 97 | + u8 pci_bus; |
| 98 | + u8 pci_dev; |
| 99 | + |
| 100 | struct sprom_fixup *board_fixups; |
| 101 | unsigned int num_board_fixups; |
| 102 | }; |