common.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * arch/arm/plat-orion/common.c
  3. *
  4. * Marvell Orion SoC common setup code used by multiple mach-/common.c
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/serial_8250.h>
  14. /* Fill in the resources structure and link it into the platform
  15. device structure. There is always a memory region, and nearly
  16. always an interrupt.*/
  17. static void fill_resources(struct platform_device *device,
  18. struct resource *resources,
  19. resource_size_t mapbase,
  20. resource_size_t size,
  21. unsigned int irq)
  22. {
  23. device->resource = resources;
  24. device->num_resources = 1;
  25. resources[0].flags = IORESOURCE_MEM;
  26. resources[0].start = mapbase;
  27. resources[0].end = mapbase + size;
  28. if (irq != NO_IRQ) {
  29. device->num_resources++;
  30. resources[1].flags = IORESOURCE_IRQ;
  31. resources[1].start = irq;
  32. resources[1].end = irq;
  33. }
  34. }
  35. /*****************************************************************************
  36. * UART
  37. ****************************************************************************/
  38. static void __init uart_complete(
  39. struct platform_device *orion_uart,
  40. struct plat_serial8250_port *data,
  41. struct resource *resources,
  42. unsigned int membase,
  43. resource_size_t mapbase,
  44. unsigned int irq,
  45. unsigned int uartclk)
  46. {
  47. data->mapbase = mapbase;
  48. data->membase = (void __iomem *)membase;
  49. data->irq = irq;
  50. data->uartclk = uartclk;
  51. orion_uart->dev.platform_data = data;
  52. fill_resources(orion_uart, resources, mapbase, 0xff, irq);
  53. platform_device_register(orion_uart);
  54. }
  55. /*****************************************************************************
  56. * UART0
  57. ****************************************************************************/
  58. static struct plat_serial8250_port orion_uart0_data[] = {
  59. {
  60. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  61. .iotype = UPIO_MEM,
  62. .regshift = 2,
  63. }, {
  64. },
  65. };
  66. static struct resource orion_uart0_resources[2];
  67. static struct platform_device orion_uart0 = {
  68. .name = "serial8250",
  69. .id = PLAT8250_DEV_PLATFORM,
  70. };
  71. void __init orion_uart0_init(unsigned int membase,
  72. resource_size_t mapbase,
  73. unsigned int irq,
  74. unsigned int uartclk)
  75. {
  76. uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
  77. membase, mapbase, irq, uartclk);
  78. }
  79. /*****************************************************************************
  80. * UART1
  81. ****************************************************************************/
  82. static struct plat_serial8250_port orion_uart1_data[] = {
  83. {
  84. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  85. .iotype = UPIO_MEM,
  86. .regshift = 2,
  87. }, {
  88. },
  89. };
  90. static struct resource orion_uart1_resources[2];
  91. static struct platform_device orion_uart1 = {
  92. .name = "serial8250",
  93. .id = PLAT8250_DEV_PLATFORM1,
  94. };
  95. void __init orion_uart1_init(unsigned int membase,
  96. resource_size_t mapbase,
  97. unsigned int irq,
  98. unsigned int uartclk)
  99. {
  100. uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
  101. membase, mapbase, irq, uartclk);
  102. }
  103. /*****************************************************************************
  104. * UART2
  105. ****************************************************************************/
  106. static struct plat_serial8250_port orion_uart2_data[] = {
  107. {
  108. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  109. .iotype = UPIO_MEM,
  110. .regshift = 2,
  111. }, {
  112. },
  113. };
  114. static struct resource orion_uart2_resources[2];
  115. static struct platform_device orion_uart2 = {
  116. .name = "serial8250",
  117. .id = PLAT8250_DEV_PLATFORM2,
  118. };
  119. void __init orion_uart2_init(unsigned int membase,
  120. resource_size_t mapbase,
  121. unsigned int irq,
  122. unsigned int uartclk)
  123. {
  124. uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
  125. membase, mapbase, irq, uartclk);
  126. }
  127. /*****************************************************************************
  128. * UART3
  129. ****************************************************************************/
  130. static struct plat_serial8250_port orion_uart3_data[] = {
  131. {
  132. .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
  133. .iotype = UPIO_MEM,
  134. .regshift = 2,
  135. }, {
  136. },
  137. };
  138. static struct resource orion_uart3_resources[2];
  139. static struct platform_device orion_uart3 = {
  140. .name = "serial8250",
  141. .id = 3,
  142. };
  143. void __init orion_uart3_init(unsigned int membase,
  144. resource_size_t mapbase,
  145. unsigned int irq,
  146. unsigned int uartclk)
  147. {
  148. uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
  149. membase, mapbase, irq, uartclk);
  150. }