365-MIPS-BCM63XX-allow-setting-a-pci-bus-device-for-fall.patch 3.8 KB

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