platform.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Copyright(C) MontaVista Software Inc, 2006
  3. *
  4. * Author: dmitry pervushin <dpervushin@ru.mvista.com>
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/kernel.h>
  22. #include <linux/types.h>
  23. #include <linux/ioport.h>
  24. #include <linux/serial_8250.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <asm/cpu.h>
  27. #include <asm/bootinfo.h>
  28. #include <asm/addrspace.h>
  29. #include <asm/time.h>
  30. #include <asm/bcache.h>
  31. #include <asm/irq.h>
  32. #include <asm/reboot.h>
  33. #include <asm/traps.h>
  34. #include <asm/emma/emma2rh.h>
  35. #define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
  36. static struct resource i2c_emma_resources_0[] = {
  37. {
  38. .name = NULL,
  39. .start = EMMA2RH_IRQ_PIIC0,
  40. .end = EMMA2RH_IRQ_PIIC0,
  41. .flags = IORESOURCE_IRQ
  42. }, {
  43. .name = NULL,
  44. .start = EMMA2RH_PIIC0_BASE,
  45. .end = EMMA2RH_PIIC0_BASE + 0x1000,
  46. .flags = 0
  47. },
  48. };
  49. struct resource i2c_emma_resources_1[] = {
  50. {
  51. .name = NULL,
  52. .start = EMMA2RH_IRQ_PIIC1,
  53. .end = EMMA2RH_IRQ_PIIC1,
  54. .flags = IORESOURCE_IRQ
  55. }, {
  56. .name = NULL,
  57. .start = EMMA2RH_PIIC1_BASE,
  58. .end = EMMA2RH_PIIC1_BASE + 0x1000,
  59. .flags = 0
  60. },
  61. };
  62. struct resource i2c_emma_resources_2[] = {
  63. {
  64. .name = NULL,
  65. .start = EMMA2RH_IRQ_PIIC2,
  66. .end = EMMA2RH_IRQ_PIIC2,
  67. .flags = IORESOURCE_IRQ
  68. }, {
  69. .name = NULL,
  70. .start = EMMA2RH_PIIC2_BASE,
  71. .end = EMMA2RH_PIIC2_BASE + 0x1000,
  72. .flags = 0
  73. },
  74. };
  75. struct platform_device i2c_emma_devices[] = {
  76. [0] = {
  77. .name = I2C_EMMA2RH,
  78. .id = 0,
  79. .resource = i2c_emma_resources_0,
  80. .num_resources = ARRAY_SIZE(i2c_emma_resources_0),
  81. },
  82. [1] = {
  83. .name = I2C_EMMA2RH,
  84. .id = 1,
  85. .resource = i2c_emma_resources_1,
  86. .num_resources = ARRAY_SIZE(i2c_emma_resources_1),
  87. },
  88. [2] = {
  89. .name = I2C_EMMA2RH,
  90. .id = 2,
  91. .resource = i2c_emma_resources_2,
  92. .num_resources = ARRAY_SIZE(i2c_emma_resources_2),
  93. },
  94. };
  95. #define EMMA2RH_SERIAL_CLOCK 18544000
  96. #define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
  97. static struct plat_serial8250_port platform_serial_ports[] = {
  98. [0] = {
  99. .membase= (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3),
  100. .mapbase = EMMA2RH_PFUR0_BASE + 3,
  101. .irq = EMMA2RH_IRQ_PFUR0,
  102. .uartclk = EMMA2RH_SERIAL_CLOCK,
  103. .regshift = 4,
  104. .iotype = UPIO_MEM,
  105. .flags = EMMA2RH_SERIAL_FLAGS,
  106. }, [1] = {
  107. .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3),
  108. .mapbase = EMMA2RH_PFUR1_BASE + 3,
  109. .irq = EMMA2RH_IRQ_PFUR1,
  110. .uartclk = EMMA2RH_SERIAL_CLOCK,
  111. .regshift = 4,
  112. .iotype = UPIO_MEM,
  113. .flags = EMMA2RH_SERIAL_FLAGS,
  114. }, [2] = {
  115. .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
  116. .mapbase = EMMA2RH_PFUR2_BASE + 3,
  117. .irq = EMMA2RH_IRQ_PFUR2,
  118. .uartclk = EMMA2RH_SERIAL_CLOCK,
  119. .regshift = 4,
  120. .iotype = UPIO_MEM,
  121. .flags = EMMA2RH_SERIAL_FLAGS,
  122. }, [3] = {
  123. .flags = 0,
  124. },
  125. };
  126. static struct platform_device serial_emma = {
  127. .name = "serial8250",
  128. .dev = {
  129. .platform_data = &platform_serial_ports,
  130. },
  131. };
  132. static struct mtd_partition markeins_parts[] = {
  133. [0] = {
  134. .name = "RootFS",
  135. .offset = 0x00000000,
  136. .size = 0x00c00000,
  137. },
  138. [1] = {
  139. .name = "boot code area",
  140. .offset = MTDPART_OFS_APPEND,
  141. .size = 0x00100000,
  142. },
  143. [2] = {
  144. .name = "kernel image",
  145. .offset = MTDPART_OFS_APPEND,
  146. .size = 0x00300000,
  147. },
  148. [3] = {
  149. .name = "RootFS2",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = 0x00c00000,
  152. },
  153. [4] = {
  154. .name = "boot code area2",
  155. .offset = MTDPART_OFS_APPEND,
  156. .size = 0x00100000,
  157. },
  158. [5] = {
  159. .name = "kernel image2",
  160. .offset = MTDPART_OFS_APPEND,
  161. .size = MTDPART_SIZ_FULL,
  162. },
  163. };
  164. static struct physmap_flash_data markeins_flash_data = {
  165. .width = 2,
  166. .nr_parts = ARRAY_SIZE(markeins_parts),
  167. .parts = markeins_parts
  168. };
  169. static struct resource markeins_flash_resource = {
  170. .start = 0x1e000000,
  171. .end = 0x02000000,
  172. .flags = IORESOURCE_MEM
  173. };
  174. static struct platform_device markeins_flash_device = {
  175. .name = "physmap-flash",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &markeins_flash_data,
  179. },
  180. .num_resources = 1,
  181. .resource = &markeins_flash_resource,
  182. };
  183. static struct platform_device *devices[] = {
  184. i2c_emma_devices,
  185. i2c_emma_devices + 1,
  186. i2c_emma_devices + 2,
  187. &serial_emma,
  188. &markeins_flash_device,
  189. };
  190. static int __init platform_devices_setup(void)
  191. {
  192. return platform_add_devices(devices, ARRAY_SIZE(devices));
  193. }
  194. arch_initcall(platform_devices_setup);