fixups-sdk7786.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * SDK7786 FPGA PCIe mux handling
  3. *
  4. * Copyright (C) 2010 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #define pr_fmt(fmt) "PCI: " fmt
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/pci.h>
  14. #include <mach/fpga.h>
  15. /*
  16. * The SDK7786 FPGA supports mangling of most of the slots in some way or
  17. * another. Slots 3/4 are special in that only one can be supported at a
  18. * time, and both appear on port 3 to the PCI bus scan. Enabling slot 4
  19. * (the horizontal edge connector) will disable slot 3 entirely.
  20. *
  21. * Misconfigurations can be detected through the FPGA via the slot
  22. * resistors to determine card presence. Hotplug remains unsupported.
  23. */
  24. static unsigned int slot4en __initdata;
  25. char *__init pcibios_setup(char *str)
  26. {
  27. if (strcmp(str, "slot4en") == 0) {
  28. slot4en = 1;
  29. return NULL;
  30. }
  31. return str;
  32. }
  33. static int __init sdk7786_pci_init(void)
  34. {
  35. u16 data = fpga_read_reg(PCIECR);
  36. /*
  37. * Enable slot #4 if it's been specified on the command line.
  38. *
  39. * Optionally reroute if slot #4 has a card present while slot #3
  40. * does not, regardless of command line value.
  41. *
  42. * Card presence is logically inverted.
  43. */
  44. slot4en ?: (!(data & PCIECR_PRST4) && (data & PCIECR_PRST3));
  45. if (slot4en) {
  46. pr_info("Activating PCIe slot#4 (disabling slot#3)\n");
  47. data &= ~PCIECR_PCIEMUX1;
  48. fpga_write_reg(data, PCIECR);
  49. /* Warn about forced rerouting if slot#3 is occupied */
  50. if ((data & PCIECR_PRST3) == 0) {
  51. pr_warning("Unreachable card detected in slot#3\n");
  52. return -EBUSY;
  53. }
  54. } else
  55. pr_info("PCIe slot#4 disabled\n");
  56. return 0;
  57. }
  58. postcore_initcall(sdk7786_pci_init);