virtex_devices.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. /*
  70. * ML300/ML403 Video Device: shortcut macro for single instance
  71. */
  72. #define XPAR_TFT(num) { \
  73. .name = "xilinxfb", \
  74. .id = num, \
  75. .num_resources = 1, \
  76. .resource = (struct resource[]) { \
  77. { \
  78. .start = XPAR_TFT_##num##_BASEADDR, \
  79. .end = XPAR_TFT_##num##_BASEADDR+7, \
  80. .flags = IORESOURCE_IO, \
  81. }, \
  82. }, \
  83. }
  84. /* UART 8250 driver platform data table */
  85. struct plat_serial8250_port virtex_serial_platform_data[] = {
  86. #if defined(XPAR_UARTNS550_0_BASEADDR)
  87. XPAR_UART(0),
  88. #endif
  89. #if defined(XPAR_UARTNS550_1_BASEADDR)
  90. XPAR_UART(1),
  91. #endif
  92. #if defined(XPAR_UARTNS550_2_BASEADDR)
  93. XPAR_UART(2),
  94. #endif
  95. #if defined(XPAR_UARTNS550_3_BASEADDR)
  96. XPAR_UART(3),
  97. #endif
  98. #if defined(XPAR_UARTNS550_4_BASEADDR)
  99. XPAR_UART(4),
  100. #endif
  101. #if defined(XPAR_UARTNS550_5_BASEADDR)
  102. XPAR_UART(5),
  103. #endif
  104. #if defined(XPAR_UARTNS550_6_BASEADDR)
  105. XPAR_UART(6),
  106. #endif
  107. #if defined(XPAR_UARTNS550_7_BASEADDR)
  108. XPAR_UART(7),
  109. #endif
  110. { }, /* terminated by empty record */
  111. };
  112. struct platform_device virtex_platform_devices[] = {
  113. /* UARTLITE instances */
  114. #if defined(XPAR_UARTLITE_0_BASEADDR)
  115. XPAR_UARTLITE(0),
  116. #endif
  117. #if defined(XPAR_UARTLITE_1_BASEADDR)
  118. XPAR_UARTLITE(1),
  119. #endif
  120. #if defined(XPAR_UARTLITE_2_BASEADDR)
  121. XPAR_UARTLITE(2),
  122. #endif
  123. #if defined(XPAR_UARTLITE_3_BASEADDR)
  124. XPAR_UARTLITE(3),
  125. #endif
  126. #if defined(XPAR_UARTLITE_4_BASEADDR)
  127. XPAR_UARTLITE(4),
  128. #endif
  129. #if defined(XPAR_UARTLITE_5_BASEADDR)
  130. XPAR_UARTLITE(5),
  131. #endif
  132. #if defined(XPAR_UARTLITE_6_BASEADDR)
  133. XPAR_UARTLITE(6),
  134. #endif
  135. #if defined(XPAR_UARTLITE_7_BASEADDR)
  136. XPAR_UARTLITE(7),
  137. #endif
  138. /* Full UART instances */
  139. #if defined(XPAR_UARTNS550_0_BASEADDR)
  140. {
  141. .name = "serial8250",
  142. .id = 0,
  143. .dev.platform_data = virtex_serial_platform_data,
  144. },
  145. #endif
  146. /* SystemACE instances */
  147. #if defined(XPAR_SYSACE_0_BASEADDR)
  148. XPAR_SYSACE(0),
  149. #endif
  150. #if defined(XPAR_SYSACE_1_BASEADDR)
  151. XPAR_SYSACE(1),
  152. #endif
  153. #if defined(XPAR_TFT_0_BASEADDR)
  154. XPAR_TFT(0),
  155. #endif
  156. #if defined(XPAR_TFT_1_BASEADDR)
  157. XPAR_TFT(1),
  158. #endif
  159. #if defined(XPAR_TFT_2_BASEADDR)
  160. XPAR_TFT(2),
  161. #endif
  162. #if defined(XPAR_TFT_3_BASEADDR)
  163. XPAR_TFT(3),
  164. #endif
  165. };
  166. /* Early serial support functions */
  167. static void __init
  168. virtex_early_serial_init(int num, struct plat_serial8250_port *pdata)
  169. {
  170. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  171. struct uart_port serial_req;
  172. memset(&serial_req, 0, sizeof(serial_req));
  173. serial_req.mapbase = pdata->mapbase;
  174. serial_req.membase = pdata->membase;
  175. serial_req.irq = pdata->irq;
  176. serial_req.uartclk = pdata->uartclk;
  177. serial_req.regshift = pdata->regshift;
  178. serial_req.iotype = pdata->iotype;
  179. serial_req.flags = pdata->flags;
  180. gen550_init(num, &serial_req);
  181. #endif
  182. }
  183. void __init
  184. virtex_early_serial_map(void)
  185. {
  186. #ifdef CONFIG_SERIAL_8250
  187. struct plat_serial8250_port *pdata;
  188. int i = 0;
  189. pdata = virtex_serial_platform_data;
  190. while(pdata && pdata->flags) {
  191. pdata->membase = ioremap(pdata->mapbase, 0x100);
  192. virtex_early_serial_init(i, pdata);
  193. pdata++;
  194. i++;
  195. }
  196. #endif /* CONFIG_SERIAL_8250 */
  197. }
  198. /*
  199. * default fixup routine; do nothing and return success.
  200. *
  201. * Reimplement this routine in your custom board support file to
  202. * override the default behaviour
  203. */
  204. int __attribute__ ((weak))
  205. virtex_device_fixup(struct platform_device *dev)
  206. {
  207. return 0;
  208. }
  209. static int __init virtex_init(void)
  210. {
  211. struct platform_device *index = virtex_platform_devices;
  212. unsigned int ret = 0;
  213. int i;
  214. for (i = 0; i < ARRAY_SIZE(virtex_platform_devices); i++, index++) {
  215. if (virtex_device_fixup(index) != 0)
  216. continue;
  217. if (platform_device_register(index)) {
  218. ret = 1;
  219. printk(KERN_ERR "cannot register dev %s:%d\n",
  220. index->name, index->id);
  221. }
  222. }
  223. return ret;
  224. }
  225. subsys_initcall(virtex_init);