platform.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Pb1550 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-au1x00/au1xxx_dbdma.h>
  25. #include <asm/mach-pb1x00/pb1550.h>
  26. #include <asm/mach-db1x00/bcsr.h>
  27. #include "../platform.h"
  28. static int pb1550_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
  29. {
  30. if ((slot < 12) || (slot > 13) || pin == 0)
  31. return -1;
  32. if (slot == 12) {
  33. switch (pin) {
  34. case 1: return AU1500_PCI_INTB;
  35. case 2: return AU1500_PCI_INTC;
  36. case 3: return AU1500_PCI_INTD;
  37. case 4: return AU1500_PCI_INTA;
  38. }
  39. }
  40. if (slot == 13) {
  41. switch (pin) {
  42. case 1: return AU1500_PCI_INTA;
  43. case 2: return AU1500_PCI_INTB;
  44. case 3: return AU1500_PCI_INTC;
  45. case 4: return AU1500_PCI_INTD;
  46. }
  47. }
  48. return -1;
  49. }
  50. static struct resource alchemy_pci_host_res[] = {
  51. [0] = {
  52. .start = AU1500_PCI_PHYS_ADDR,
  53. .end = AU1500_PCI_PHYS_ADDR + 0xfff,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. };
  57. static struct alchemy_pci_platdata pb1550_pci_pd = {
  58. .board_map_irq = pb1550_map_pci_irq,
  59. };
  60. static struct platform_device pb1550_pci_host = {
  61. .dev.platform_data = &pb1550_pci_pd,
  62. .name = "alchemy-pci",
  63. .id = 0,
  64. .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
  65. .resource = alchemy_pci_host_res,
  66. };
  67. static struct resource au1550_psc2_res[] = {
  68. [0] = {
  69. .start = AU1550_PSC2_PHYS_ADDR,
  70. .end = AU1550_PSC2_PHYS_ADDR + 0xfff,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. [1] = {
  74. .start = AU1550_PSC2_INT,
  75. .end = AU1550_PSC2_INT,
  76. .flags = IORESOURCE_IRQ,
  77. },
  78. [2] = {
  79. .start = AU1550_DSCR_CMD0_PSC2_TX,
  80. .end = AU1550_DSCR_CMD0_PSC2_TX,
  81. .flags = IORESOURCE_DMA,
  82. },
  83. [3] = {
  84. .start = AU1550_DSCR_CMD0_PSC2_RX,
  85. .end = AU1550_DSCR_CMD0_PSC2_RX,
  86. .flags = IORESOURCE_DMA,
  87. },
  88. };
  89. static struct platform_device pb1550_i2c_dev = {
  90. .name = "au1xpsc_smbus",
  91. .id = 0, /* bus number */
  92. .num_resources = ARRAY_SIZE(au1550_psc2_res),
  93. .resource = au1550_psc2_res,
  94. };
  95. static int __init pb1550_dev_init(void)
  96. {
  97. int swapped;
  98. /* Pb1550, like all others, also has statuschange irqs; however they're
  99. * wired up on one of the Au1550's shared GPIO201_205 line, which also
  100. * services the PCMCIA card interrupts. So we ignore statuschange and
  101. * use the GPIO201_205 exclusively for card interrupts, since a) pcmcia
  102. * drivers are used to shared irqs and b) statuschange isn't really use-
  103. * ful anyway.
  104. */
  105. db1x_register_pcmcia_socket(
  106. AU1000_PCMCIA_ATTR_PHYS_ADDR,
  107. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
  108. AU1000_PCMCIA_MEM_PHYS_ADDR,
  109. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
  110. AU1000_PCMCIA_IO_PHYS_ADDR,
  111. AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
  112. AU1550_GPIO201_205_INT, AU1550_GPIO0_INT, 0, 0, 0);
  113. db1x_register_pcmcia_socket(
  114. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x008000000,
  115. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x008400000 - 1,
  116. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x008000000,
  117. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x008400000 - 1,
  118. AU1000_PCMCIA_IO_PHYS_ADDR + 0x008000000,
  119. AU1000_PCMCIA_IO_PHYS_ADDR + 0x008010000 - 1,
  120. AU1550_GPIO201_205_INT, AU1550_GPIO1_INT, 0, 0, 1);
  121. swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_PB1550_SWAPBOOT;
  122. db1x_register_norflash(128 * 1024 * 1024, 4, swapped);
  123. platform_device_register(&pb1550_pci_host);
  124. platform_device_register(&pb1550_i2c_dev);
  125. return 0;
  126. }
  127. arch_initcall(pb1550_dev_init);