siu.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * NEC VR4100 series SIU platform device.
  3. *
  4. * Copyright (C) 2007-2008 Yoichi Yuasa <yuasa@linux-mips.org>
  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 Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/errno.h>
  21. #include <linux/init.h>
  22. #include <linux/ioport.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/serial_core.h>
  25. #include <linux/irq.h>
  26. #include <asm/cpu.h>
  27. #include <asm/vr41xx/siu.h>
  28. static unsigned int siu_type1_ports[SIU_PORTS_MAX] __initdata = {
  29. PORT_VR41XX_SIU,
  30. PORT_UNKNOWN,
  31. };
  32. static struct resource siu_type1_resource[] __initdata = {
  33. {
  34. .start = 0x0c000000,
  35. .end = 0x0c00000a,
  36. .flags = IORESOURCE_MEM,
  37. },
  38. {
  39. .start = SIU_IRQ,
  40. .end = SIU_IRQ,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. };
  44. static unsigned int siu_type2_ports[SIU_PORTS_MAX] __initdata = {
  45. PORT_VR41XX_SIU,
  46. PORT_VR41XX_DSIU,
  47. };
  48. static struct resource siu_type2_resource[] __initdata = {
  49. {
  50. .start = 0x0f000800,
  51. .end = 0x0f00080a,
  52. .flags = IORESOURCE_MEM,
  53. },
  54. {
  55. .start = 0x0f000820,
  56. .end = 0x0f000829,
  57. .flags = IORESOURCE_MEM,
  58. },
  59. {
  60. .start = SIU_IRQ,
  61. .end = SIU_IRQ,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. {
  65. .start = DSIU_IRQ,
  66. .end = DSIU_IRQ,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. static int __init vr41xx_siu_add(void)
  71. {
  72. struct platform_device *pdev;
  73. struct resource *res;
  74. unsigned int num;
  75. int retval;
  76. pdev = platform_device_alloc("SIU", -1);
  77. if (!pdev)
  78. return -ENOMEM;
  79. switch (current_cpu_type()) {
  80. case CPU_VR4111:
  81. case CPU_VR4121:
  82. pdev->dev.platform_data = siu_type1_ports;
  83. res = siu_type1_resource;
  84. num = ARRAY_SIZE(siu_type1_resource);
  85. break;
  86. case CPU_VR4122:
  87. case CPU_VR4131:
  88. case CPU_VR4133:
  89. pdev->dev.platform_data = siu_type2_ports;
  90. res = siu_type2_resource;
  91. num = ARRAY_SIZE(siu_type2_resource);
  92. break;
  93. default:
  94. retval = -ENODEV;
  95. goto err_free_device;
  96. }
  97. retval = platform_device_add_resources(pdev, res, num);
  98. if (retval)
  99. goto err_free_device;
  100. retval = platform_device_add(pdev);
  101. if (retval)
  102. goto err_free_device;
  103. return 0;
  104. err_free_device:
  105. platform_device_put(pdev);
  106. return retval;
  107. }
  108. device_initcall(vr41xx_siu_add);
  109. void __init vr41xx_siu_setup(void)
  110. {
  111. struct uart_port port;
  112. struct resource *res;
  113. unsigned int *type;
  114. int i;
  115. switch (current_cpu_type()) {
  116. case CPU_VR4111:
  117. case CPU_VR4121:
  118. type = siu_type1_ports;
  119. res = siu_type1_resource;
  120. break;
  121. case CPU_VR4122:
  122. case CPU_VR4131:
  123. case CPU_VR4133:
  124. type = siu_type2_ports;
  125. res = siu_type2_resource;
  126. break;
  127. default:
  128. return;
  129. }
  130. for (i = 0; i < SIU_PORTS_MAX; i++) {
  131. port.line = i;
  132. port.type = type[i];
  133. if (port.type == PORT_UNKNOWN)
  134. break;
  135. port.mapbase = res[i].start;
  136. port.membase = (unsigned char __iomem *)KSEG1ADDR(res[i].start);
  137. vr41xx_siu_early_setup(&port);
  138. }
  139. }