siu.c 3.3 KB

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