platform.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Pb1500 board platform device registration
  3. *
  4. * Copyright (C) 2009 Manuel Lauss
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/dma-mapping.h>
  21. #include <linux/init.h>
  22. #include <linux/platform_device.h>
  23. #include <asm/mach-au1x00/au1000.h>
  24. #include <asm/mach-db1x00/bcsr.h>
  25. #include "../platform.h"
  26. static int pb1500_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
  27. {
  28. if ((slot < 12) || (slot > 13) || pin == 0)
  29. return -1;
  30. if (slot == 12)
  31. return (pin == 1) ? AU1500_PCI_INTA : 0xff;
  32. if (slot == 13) {
  33. switch (pin) {
  34. case 1: return AU1500_PCI_INTA;
  35. case 2: return AU1500_PCI_INTB;
  36. case 3: return AU1500_PCI_INTC;
  37. case 4: return AU1500_PCI_INTD;
  38. }
  39. }
  40. return -1;
  41. }
  42. static struct resource alchemy_pci_host_res[] = {
  43. [0] = {
  44. .start = AU1500_PCI_PHYS_ADDR,
  45. .end = AU1500_PCI_PHYS_ADDR + 0xfff,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. };
  49. static struct alchemy_pci_platdata pb1500_pci_pd = {
  50. .board_map_irq = pb1500_map_pci_irq,
  51. .pci_cfg_set = PCI_CONFIG_AEN | PCI_CONFIG_R2H | PCI_CONFIG_R1H |
  52. PCI_CONFIG_CH |
  53. #if defined(__MIPSEB__)
  54. PCI_CONFIG_SIC_HWA_DAT | PCI_CONFIG_SM,
  55. #else
  56. 0,
  57. #endif
  58. };
  59. static struct platform_device pb1500_pci_host = {
  60. .dev.platform_data = &pb1500_pci_pd,
  61. .name = "alchemy-pci",
  62. .id = 0,
  63. .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
  64. .resource = alchemy_pci_host_res,
  65. };
  66. static int __init pb1500_dev_init(void)
  67. {
  68. int swapped;
  69. /* PCMCIA. single socket, identical to Pb1100 */
  70. db1x_register_pcmcia_socket(
  71. AU1000_PCMCIA_ATTR_PHYS_ADDR,
  72. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
  73. AU1000_PCMCIA_MEM_PHYS_ADDR,
  74. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
  75. AU1000_PCMCIA_IO_PHYS_ADDR,
  76. AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
  77. AU1500_GPIO11_INT, AU1500_GPIO9_INT, /* card / insert */
  78. /*AU1500_GPIO10_INT*/0, 0, 0); /* stschg / eject / id */
  79. swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT;
  80. db1x_register_norflash(64 * 1024 * 1024, 4, swapped);
  81. platform_device_register(&pb1500_pci_host);
  82. return 0;
  83. }
  84. arch_initcall(pb1500_dev_init);