pb1550.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Pb1550 board support.
  3. *
  4. * Copyright (C) 2009-2011 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/interrupt.h>
  23. #include <linux/platform_device.h>
  24. #include <asm/mach-au1x00/au1000.h>
  25. #include <asm/mach-au1x00/au1xxx_dbdma.h>
  26. #include <asm/mach-au1x00/au1550nd.h>
  27. #include <asm/mach-au1x00/gpio.h>
  28. #include <asm/mach-db1x00/bcsr.h>
  29. #include "platform.h"
  30. const char *get_system_type(void)
  31. {
  32. return "PB1550";
  33. }
  34. void __init board_setup(void)
  35. {
  36. u32 pin_func;
  37. bcsr_init(PB1550_BCSR_PHYS_ADDR,
  38. PB1550_BCSR_PHYS_ADDR + PB1550_BCSR_HEXLED_OFS);
  39. alchemy_gpio2_enable();
  40. /*
  41. * Enable PSC1 SYNC for AC'97. Normaly done in audio driver,
  42. * but it is board specific code, so put it here.
  43. */
  44. pin_func = au_readl(SYS_PINFUNC);
  45. au_sync();
  46. pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1;
  47. au_writel(pin_func, SYS_PINFUNC);
  48. bcsr_write(BCSR_PCMCIA, 0); /* turn off PCMCIA power */
  49. printk(KERN_INFO "AMD Alchemy Pb1550 Board\n");
  50. }
  51. /******************************************************************************/
  52. static int pb1550_map_pci_irq(const struct pci_dev *d, u8 slot, u8 pin)
  53. {
  54. if ((slot < 12) || (slot > 13) || pin == 0)
  55. return -1;
  56. if (slot == 12) {
  57. switch (pin) {
  58. case 1: return AU1500_PCI_INTB;
  59. case 2: return AU1500_PCI_INTC;
  60. case 3: return AU1500_PCI_INTD;
  61. case 4: return AU1500_PCI_INTA;
  62. }
  63. }
  64. if (slot == 13) {
  65. switch (pin) {
  66. case 1: return AU1500_PCI_INTA;
  67. case 2: return AU1500_PCI_INTB;
  68. case 3: return AU1500_PCI_INTC;
  69. case 4: return AU1500_PCI_INTD;
  70. }
  71. }
  72. return -1;
  73. }
  74. static struct resource alchemy_pci_host_res[] = {
  75. [0] = {
  76. .start = AU1500_PCI_PHYS_ADDR,
  77. .end = AU1500_PCI_PHYS_ADDR + 0xfff,
  78. .flags = IORESOURCE_MEM,
  79. },
  80. };
  81. static struct alchemy_pci_platdata pb1550_pci_pd = {
  82. .board_map_irq = pb1550_map_pci_irq,
  83. };
  84. static struct platform_device pb1550_pci_host = {
  85. .dev.platform_data = &pb1550_pci_pd,
  86. .name = "alchemy-pci",
  87. .id = 0,
  88. .num_resources = ARRAY_SIZE(alchemy_pci_host_res),
  89. .resource = alchemy_pci_host_res,
  90. };
  91. static struct resource au1550_psc2_res[] = {
  92. [0] = {
  93. .start = AU1550_PSC2_PHYS_ADDR,
  94. .end = AU1550_PSC2_PHYS_ADDR + 0xfff,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. [1] = {
  98. .start = AU1550_PSC2_INT,
  99. .end = AU1550_PSC2_INT,
  100. .flags = IORESOURCE_IRQ,
  101. },
  102. [2] = {
  103. .start = AU1550_DSCR_CMD0_PSC2_TX,
  104. .end = AU1550_DSCR_CMD0_PSC2_TX,
  105. .flags = IORESOURCE_DMA,
  106. },
  107. [3] = {
  108. .start = AU1550_DSCR_CMD0_PSC2_RX,
  109. .end = AU1550_DSCR_CMD0_PSC2_RX,
  110. .flags = IORESOURCE_DMA,
  111. },
  112. };
  113. static struct platform_device pb1550_i2c_dev = {
  114. .name = "au1xpsc_smbus",
  115. .id = 0, /* bus number */
  116. .num_resources = ARRAY_SIZE(au1550_psc2_res),
  117. .resource = au1550_psc2_res,
  118. };
  119. static struct mtd_partition pb1550_nand_parts[] = {
  120. [0] = {
  121. .name = "NAND FS 0",
  122. .offset = 0,
  123. .size = 8 * 1024 * 1024,
  124. },
  125. [1] = {
  126. .name = "NAND FS 1",
  127. .offset = MTDPART_OFS_APPEND,
  128. .size = MTDPART_SIZ_FULL,
  129. },
  130. };
  131. static struct au1550nd_platdata pb1550_nand_pd = {
  132. .parts = pb1550_nand_parts,
  133. .num_parts = ARRAY_SIZE(pb1550_nand_parts),
  134. .devwidth = 0, /* x8 NAND default, needs fixing up */
  135. };
  136. static struct resource pb1550_nand_res[] = {
  137. [0] = {
  138. .start = 0x20000000,
  139. .end = 0x20000fff,
  140. .flags = IORESOURCE_MEM,
  141. },
  142. };
  143. static struct platform_device pb1550_nand_dev = {
  144. .name = "au1550-nand",
  145. .id = -1,
  146. .resource = pb1550_nand_res,
  147. .num_resources = ARRAY_SIZE(pb1550_nand_res),
  148. .dev = {
  149. .platform_data = &pb1550_nand_pd,
  150. },
  151. };
  152. static void __init pb1550_nand_setup(void)
  153. {
  154. int boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) |
  155. ((bcsr_read(BCSR_STATUS) >> 6) & 0x1);
  156. switch (boot_swapboot) {
  157. case 0:
  158. case 2:
  159. case 8:
  160. case 0xC:
  161. case 0xD:
  162. /* x16 NAND Flash */
  163. pb1550_nand_pd.devwidth = 1;
  164. /* fallthrough */
  165. case 1:
  166. case 9:
  167. case 3:
  168. case 0xE:
  169. case 0xF:
  170. /* x8 NAND, already set up */
  171. platform_device_register(&pb1550_nand_dev);
  172. }
  173. }
  174. static int __init pb1550_dev_init(void)
  175. {
  176. int swapped;
  177. irq_set_irq_type(AU1550_GPIO0_INT, IRQF_TRIGGER_LOW);
  178. irq_set_irq_type(AU1550_GPIO1_INT, IRQF_TRIGGER_LOW);
  179. irq_set_irq_type(AU1550_GPIO201_205_INT, IRQF_TRIGGER_HIGH);
  180. /* enable both PCMCIA card irqs in the shared line */
  181. alchemy_gpio2_enable_int(201);
  182. alchemy_gpio2_enable_int(202);
  183. /* Pb1550, like all others, also has statuschange irqs; however they're
  184. * wired up on one of the Au1550's shared GPIO201_205 line, which also
  185. * services the PCMCIA card interrupts. So we ignore statuschange and
  186. * use the GPIO201_205 exclusively for card interrupts, since a) pcmcia
  187. * drivers are used to shared irqs and b) statuschange isn't really use-
  188. * ful anyway.
  189. */
  190. db1x_register_pcmcia_socket(
  191. AU1000_PCMCIA_ATTR_PHYS_ADDR,
  192. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
  193. AU1000_PCMCIA_MEM_PHYS_ADDR,
  194. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
  195. AU1000_PCMCIA_IO_PHYS_ADDR,
  196. AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
  197. AU1550_GPIO201_205_INT, AU1550_GPIO0_INT, 0, 0, 0);
  198. db1x_register_pcmcia_socket(
  199. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x008000000,
  200. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x008400000 - 1,
  201. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x008000000,
  202. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x008400000 - 1,
  203. AU1000_PCMCIA_IO_PHYS_ADDR + 0x008000000,
  204. AU1000_PCMCIA_IO_PHYS_ADDR + 0x008010000 - 1,
  205. AU1550_GPIO201_205_INT, AU1550_GPIO1_INT, 0, 0, 1);
  206. /* NAND setup */
  207. gpio_direction_input(206); /* GPIO206 high */
  208. pb1550_nand_setup();
  209. swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_PB1550_SWAPBOOT;
  210. db1x_register_norflash(128 * 1024 * 1024, 4, swapped);
  211. platform_device_register(&pb1550_pci_host);
  212. platform_device_register(&pb1550_i2c_dev);
  213. return 0;
  214. }
  215. arch_initcall(pb1550_dev_init);