pci.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Atheros AR71XX/AR724X specific PCI setup code
  3. *
  4. * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/pci.h>
  11. #include <asm/mach-ath79/ath79.h>
  12. #include <asm/mach-ath79/irq.h>
  13. #include <asm/mach-ath79/pci.h>
  14. #include "pci.h"
  15. static struct ar724x_pci_data *pci_data;
  16. static int pci_data_size;
  17. void ar724x_pci_add_data(struct ar724x_pci_data *data, int size)
  18. {
  19. pci_data = data;
  20. pci_data_size = size;
  21. }
  22. int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin)
  23. {
  24. unsigned int devfn = dev->devfn;
  25. int irq = -1;
  26. if (devfn > pci_data_size - 1)
  27. return irq;
  28. irq = pci_data[devfn].irq;
  29. return irq;
  30. }
  31. int pcibios_plat_dev_init(struct pci_dev *dev)
  32. {
  33. unsigned int devfn = dev->devfn;
  34. if (devfn > pci_data_size - 1)
  35. return PCIBIOS_DEVICE_NOT_FOUND;
  36. dev->dev.platform_data = pci_data[devfn].pdata;
  37. return PCIBIOS_SUCCESSFUL;
  38. }
  39. int __init ath79_register_pci(void)
  40. {
  41. if (soc_is_ar724x())
  42. return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2);
  43. return -ENODEV;
  44. }