virtex_devices.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Virtex hard ppc405 core common device listing
  3. *
  4. * Copyright 2005-2007 Secret Lab Technologies Ltd.
  5. * Copyright 2005 Freescale Semiconductor Inc.
  6. * Copyright 2002-2004 MontaVista Software, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/module.h>
  15. #include <linux/device.h>
  16. #include <linux/serial_8250.h>
  17. #include <syslib/virtex_devices.h>
  18. #include <platforms/4xx/xparameters/xparameters.h>
  19. #include <asm/io.h>
  20. /*
  21. * UARTLITE: shortcut macro for single instance
  22. */
  23. #define XPAR_UARTLITE(num) { \
  24. .name = "uartlite", \
  25. .id = num, \
  26. .num_resources = 2, \
  27. .resource = (struct resource[]) { \
  28. { \
  29. .start = XPAR_UARTLITE_##num##_BASEADDR + 3, \
  30. .end = XPAR_UARTLITE_##num##_HIGHADDR, \
  31. .flags = IORESOURCE_MEM, \
  32. }, \
  33. { \
  34. .start = XPAR_INTC_0_UARTLITE_##num##_VEC_ID, \
  35. .flags = IORESOURCE_IRQ, \
  36. }, \
  37. }, \
  38. }
  39. /*
  40. * Full UART: shortcut macro for single instance + platform data structure
  41. */
  42. #define XPAR_UART(num) { \
  43. .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
  44. .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
  45. .iotype = UPIO_MEM, \
  46. .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
  47. .flags = UPF_BOOT_AUTOCONF, \
  48. .regshift = 2, \
  49. }
  50. /*
  51. * SystemACE: shortcut macro for single instance
  52. */
  53. #define XPAR_SYSACE(num) { \
  54. .name = "xsysace", \
  55. .id = XPAR_SYSACE_##num##_DEVICE_ID, \
  56. .num_resources = 2, \
  57. .resource = (struct resource[]) { \
  58. { \
  59. .start = XPAR_SYSACE_##num##_BASEADDR, \
  60. .end = XPAR_SYSACE_##num##_HIGHADDR, \
  61. .flags = IORESOURCE_MEM, \
  62. }, \
  63. { \
  64. .start = XPAR_INTC_0_SYSACE_##num##_VEC_ID, \
  65. .flags = IORESOURCE_IRQ, \
  66. }, \
  67. }, \
  68. }
  69. /* UART 8250 driver platform data table */
  70. struct plat_serial8250_port virtex_serial_platform_data[] = {
  71. #if defined(XPAR_UARTNS550_0_BASEADDR)
  72. XPAR_UART(0),
  73. #endif
  74. #if defined(XPAR_UARTNS550_1_BASEADDR)
  75. XPAR_UART(1),
  76. #endif
  77. #if defined(XPAR_UARTNS550_2_BASEADDR)
  78. XPAR_UART(2),
  79. #endif
  80. #if defined(XPAR_UARTNS550_3_BASEADDR)
  81. XPAR_UART(3),
  82. #endif
  83. #if defined(XPAR_UARTNS550_4_BASEADDR)
  84. XPAR_UART(4),
  85. #endif
  86. #if defined(XPAR_UARTNS550_5_BASEADDR)
  87. XPAR_UART(5),
  88. #endif
  89. #if defined(XPAR_UARTNS550_6_BASEADDR)
  90. XPAR_UART(6),
  91. #endif
  92. #if defined(XPAR_UARTNS550_7_BASEADDR)
  93. XPAR_UART(7),
  94. #endif
  95. { }, /* terminated by empty record */
  96. };
  97. struct platform_device virtex_platform_devices[] = {
  98. /* UARTLITE instances */
  99. #if defined(XPAR_UARTLITE_0_BASEADDR)
  100. XPAR_UARTLITE(0),
  101. #endif
  102. #if defined(XPAR_UARTLITE_1_BASEADDR)
  103. XPAR_UARTLITE(1),
  104. #endif
  105. #if defined(XPAR_UARTLITE_2_BASEADDR)
  106. XPAR_UARTLITE(2),
  107. #endif
  108. #if defined(XPAR_UARTLITE_3_BASEADDR)
  109. XPAR_UARTLITE(3),
  110. #endif
  111. #if defined(XPAR_UARTLITE_4_BASEADDR)
  112. XPAR_UARTLITE(4),
  113. #endif
  114. #if defined(XPAR_UARTLITE_5_BASEADDR)
  115. XPAR_UARTLITE(5),
  116. #endif
  117. #if defined(XPAR_UARTLITE_6_BASEADDR)
  118. XPAR_UARTLITE(6),
  119. #endif
  120. #if defined(XPAR_UARTLITE_7_BASEADDR)
  121. XPAR_UARTLITE(7),
  122. #endif
  123. /* Full UART instances */
  124. #if defined(XPAR_UARTNS550_0_BASEADDR)
  125. {
  126. .name = "serial8250",
  127. .id = 0,
  128. .dev.platform_data = virtex_serial_platform_data,
  129. },
  130. #endif
  131. /* SystemACE instances */
  132. #if defined(XPAR_SYSACE_0_BASEADDR)
  133. XPAR_SYSACE(0),
  134. #endif
  135. #if defined(XPAR_SYSACE_1_BASEADDR)
  136. XPAR_SYSACE(1),
  137. #endif
  138. /* ML300/403 reference design framebuffer */
  139. #if defined(XPAR_TFT_0_BASEADDR)
  140. {
  141. .name = "xilinxfb",
  142. .id = 0,
  143. .num_resources = 1,
  144. .resource = (struct resource[]) {
  145. {
  146. .start = XPAR_TFT_0_BASEADDR,
  147. .end = XPAR_TFT_0_BASEADDR+7,
  148. .flags = IORESOURCE_IO,
  149. },
  150. },
  151. },
  152. #endif
  153. };
  154. /* Early serial support functions */
  155. static void __init
  156. virtex_early_serial_init(int num, struct plat_serial8250_port *pdata)
  157. {
  158. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  159. struct uart_port serial_req;
  160. memset(&serial_req, 0, sizeof(serial_req));
  161. serial_req.mapbase = pdata->mapbase;
  162. serial_req.membase = pdata->membase;
  163. serial_req.irq = pdata->irq;
  164. serial_req.uartclk = pdata->uartclk;
  165. serial_req.regshift = pdata->regshift;
  166. serial_req.iotype = pdata->iotype;
  167. serial_req.flags = pdata->flags;
  168. gen550_init(num, &serial_req);
  169. #endif
  170. }
  171. void __init
  172. virtex_early_serial_map(void)
  173. {
  174. #ifdef CONFIG_SERIAL_8250
  175. struct plat_serial8250_port *pdata;
  176. int i = 0;
  177. pdata = virtex_serial_platform_data;
  178. while(pdata && pdata->flags) {
  179. pdata->membase = ioremap(pdata->mapbase, 0x100);
  180. virtex_early_serial_init(i, pdata);
  181. pdata++;
  182. i++;
  183. }
  184. #endif /* CONFIG_SERIAL_8250 */
  185. }
  186. /*
  187. * default fixup routine; do nothing and return success.
  188. *
  189. * Reimplement this routine in your custom board support file to
  190. * override the default behaviour
  191. */
  192. int __attribute__ ((weak))
  193. virtex_device_fixup(struct platform_device *dev)
  194. {
  195. return 0;
  196. }
  197. static int __init virtex_init(void)
  198. {
  199. struct platform_device *index = virtex_platform_devices;
  200. unsigned int ret = 0;
  201. int i;
  202. for (i = 0; i < ARRAY_SIZE(virtex_platform_devices); i++, index++) {
  203. if (virtex_device_fixup(index) != 0)
  204. continue;
  205. if (platform_device_register(index)) {
  206. ret = 1;
  207. printk(KERN_ERR "cannot register dev %s:%d\n",
  208. index->name, index->id);
  209. }
  210. }
  211. return ret;
  212. }
  213. subsys_initcall(virtex_init);