PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/ppc/syslib/virtex_devices.c

https://github.com/sumitn/linux-2.6.24
C | 276 lines | 218 code | 22 blank | 36 comment | 6 complexity | aeed0c386c5bbe78f9db47bce46e22c8 MD5 | raw file
Possible License(s): GPL-2.0
  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. #define XPAR_AC97_CONTROLLER_REFERENCE(num) { \
  85. .name = "ml403_ac97cr", \
  86. .id = num, \
  87. .num_resources = 3, \
  88. .resource = (struct resource[]) { \
  89. { \
  90. .start = XPAR_OPB_AC97_CONTROLLER_REF_##num##_BASEADDR, \
  91. .end = XPAR_OPB_AC97_CONTROLLER_REF_##num##_HIGHADDR, \
  92. .flags = IORESOURCE_MEM, \
  93. }, \
  94. { \
  95. .start = XPAR_INTC_0_AC97_CONTROLLER_REF_##num##_PLAYBACK_VEC_ID, \
  96. .end = XPAR_INTC_0_AC97_CONTROLLER_REF_##num##_PLAYBACK_VEC_ID, \
  97. .flags = IORESOURCE_IRQ, \
  98. }, \
  99. { \
  100. .start = XPAR_INTC_0_AC97_CONTROLLER_REF_##num##_RECORD_VEC_ID, \
  101. .end = XPAR_INTC_0_AC97_CONTROLLER_REF_##num##_RECORD_VEC_ID, \
  102. .flags = IORESOURCE_IRQ, \
  103. }, \
  104. }, \
  105. }
  106. /* UART 8250 driver platform data table */
  107. struct plat_serial8250_port virtex_serial_platform_data[] = {
  108. #if defined(XPAR_UARTNS550_0_BASEADDR)
  109. XPAR_UART(0),
  110. #endif
  111. #if defined(XPAR_UARTNS550_1_BASEADDR)
  112. XPAR_UART(1),
  113. #endif
  114. #if defined(XPAR_UARTNS550_2_BASEADDR)
  115. XPAR_UART(2),
  116. #endif
  117. #if defined(XPAR_UARTNS550_3_BASEADDR)
  118. XPAR_UART(3),
  119. #endif
  120. #if defined(XPAR_UARTNS550_4_BASEADDR)
  121. XPAR_UART(4),
  122. #endif
  123. #if defined(XPAR_UARTNS550_5_BASEADDR)
  124. XPAR_UART(5),
  125. #endif
  126. #if defined(XPAR_UARTNS550_6_BASEADDR)
  127. XPAR_UART(6),
  128. #endif
  129. #if defined(XPAR_UARTNS550_7_BASEADDR)
  130. XPAR_UART(7),
  131. #endif
  132. { }, /* terminated by empty record */
  133. };
  134. struct platform_device virtex_platform_devices[] = {
  135. /* UARTLITE instances */
  136. #if defined(XPAR_UARTLITE_0_BASEADDR)
  137. XPAR_UARTLITE(0),
  138. #endif
  139. #if defined(XPAR_UARTLITE_1_BASEADDR)
  140. XPAR_UARTLITE(1),
  141. #endif
  142. #if defined(XPAR_UARTLITE_2_BASEADDR)
  143. XPAR_UARTLITE(2),
  144. #endif
  145. #if defined(XPAR_UARTLITE_3_BASEADDR)
  146. XPAR_UARTLITE(3),
  147. #endif
  148. #if defined(XPAR_UARTLITE_4_BASEADDR)
  149. XPAR_UARTLITE(4),
  150. #endif
  151. #if defined(XPAR_UARTLITE_5_BASEADDR)
  152. XPAR_UARTLITE(5),
  153. #endif
  154. #if defined(XPAR_UARTLITE_6_BASEADDR)
  155. XPAR_UARTLITE(6),
  156. #endif
  157. #if defined(XPAR_UARTLITE_7_BASEADDR)
  158. XPAR_UARTLITE(7),
  159. #endif
  160. /* Full UART instances */
  161. #if defined(XPAR_UARTNS550_0_BASEADDR)
  162. {
  163. .name = "serial8250",
  164. .id = 0,
  165. .dev.platform_data = virtex_serial_platform_data,
  166. },
  167. #endif
  168. /* SystemACE instances */
  169. #if defined(XPAR_SYSACE_0_BASEADDR)
  170. XPAR_SYSACE(0),
  171. #endif
  172. #if defined(XPAR_SYSACE_1_BASEADDR)
  173. XPAR_SYSACE(1),
  174. #endif
  175. #if defined(XPAR_TFT_0_BASEADDR)
  176. XPAR_TFT(0),
  177. #endif
  178. #if defined(XPAR_TFT_1_BASEADDR)
  179. XPAR_TFT(1),
  180. #endif
  181. #if defined(XPAR_TFT_2_BASEADDR)
  182. XPAR_TFT(2),
  183. #endif
  184. #if defined(XPAR_TFT_3_BASEADDR)
  185. XPAR_TFT(3),
  186. #endif
  187. /* AC97 Controller Reference instances */
  188. #if defined(XPAR_OPB_AC97_CONTROLLER_REF_0_BASEADDR)
  189. XPAR_AC97_CONTROLLER_REFERENCE(0),
  190. #endif
  191. #if defined(XPAR_OPB_AC97_CONTROLLER_REF_1_BASEADDR)
  192. XPAR_AC97_CONTROLLER_REFERENCE(1),
  193. #endif
  194. };
  195. /* Early serial support functions */
  196. static void __init
  197. virtex_early_serial_init(int num, struct plat_serial8250_port *pdata)
  198. {
  199. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  200. struct uart_port serial_req;
  201. memset(&serial_req, 0, sizeof(serial_req));
  202. serial_req.mapbase = pdata->mapbase;
  203. serial_req.membase = pdata->membase;
  204. serial_req.irq = pdata->irq;
  205. serial_req.uartclk = pdata->uartclk;
  206. serial_req.regshift = pdata->regshift;
  207. serial_req.iotype = pdata->iotype;
  208. serial_req.flags = pdata->flags;
  209. gen550_init(num, &serial_req);
  210. #endif
  211. }
  212. void __init
  213. virtex_early_serial_map(void)
  214. {
  215. #ifdef CONFIG_SERIAL_8250
  216. struct plat_serial8250_port *pdata;
  217. int i = 0;
  218. pdata = virtex_serial_platform_data;
  219. while(pdata && pdata->flags) {
  220. pdata->membase = ioremap(pdata->mapbase, 0x100);
  221. virtex_early_serial_init(i, pdata);
  222. pdata++;
  223. i++;
  224. }
  225. #endif /* CONFIG_SERIAL_8250 */
  226. }
  227. /*
  228. * default fixup routine; do nothing and return success.
  229. *
  230. * Reimplement this routine in your custom board support file to
  231. * override the default behaviour
  232. */
  233. int __attribute__ ((weak))
  234. virtex_device_fixup(struct platform_device *dev)
  235. {
  236. return 0;
  237. }
  238. static int __init virtex_init(void)
  239. {
  240. struct platform_device *index = virtex_platform_devices;
  241. unsigned int ret = 0;
  242. int i;
  243. for (i = 0; i < ARRAY_SIZE(virtex_platform_devices); i++, index++) {
  244. if (virtex_device_fixup(index) != 0)
  245. continue;
  246. if (platform_device_register(index)) {
  247. ret = 1;
  248. printk(KERN_ERR "cannot register dev %s:%d\n",
  249. index->name, index->id);
  250. }
  251. }
  252. return ret;
  253. }
  254. subsys_initcall(virtex_init);