cns3420vb.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Cavium Networks CNS3420 Validation Board
  3. *
  4. * Copyright 2000 Deep Blue Solutions Ltd
  5. * Copyright 2008 ARM Limited
  6. * Copyright 2008 Cavium Networks
  7. * Scott Shu
  8. * Copyright 2010 MontaVista Software, LLC.
  9. * Anton Vorontsov <avorontsov@mvista.com>
  10. *
  11. * This file is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License, Version 2, as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/kernel.h>
  17. #include <linux/compiler.h>
  18. #include <linux/io.h>
  19. #include <linux/dma-mapping.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/serial_8250.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <asm/setup.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/time.h>
  31. #include <mach/cns3xxx.h>
  32. #include <mach/irqs.h>
  33. #include "core.h"
  34. #include "devices.h"
  35. /*
  36. * NOR Flash
  37. */
  38. static struct mtd_partition cns3420_nor_partitions[] = {
  39. {
  40. .name = "uboot",
  41. .size = 0x00040000,
  42. .offset = 0,
  43. .mask_flags = MTD_WRITEABLE,
  44. }, {
  45. .name = "kernel",
  46. .size = 0x004C0000,
  47. .offset = MTDPART_OFS_APPEND,
  48. }, {
  49. .name = "filesystem",
  50. .size = 0x7000000,
  51. .offset = MTDPART_OFS_APPEND,
  52. }, {
  53. .name = "filesystem2",
  54. .size = 0x0AE0000,
  55. .offset = MTDPART_OFS_APPEND,
  56. }, {
  57. .name = "ubootenv",
  58. .size = MTDPART_SIZ_FULL,
  59. .offset = MTDPART_OFS_APPEND,
  60. },
  61. };
  62. static struct physmap_flash_data cns3420_nor_pdata = {
  63. .width = 2,
  64. .parts = cns3420_nor_partitions,
  65. .nr_parts = ARRAY_SIZE(cns3420_nor_partitions),
  66. };
  67. static struct resource cns3420_nor_res = {
  68. .start = CNS3XXX_FLASH_BASE,
  69. .end = CNS3XXX_FLASH_BASE + SZ_128M - 1,
  70. .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
  71. };
  72. static struct platform_device cns3420_nor_pdev = {
  73. .name = "physmap-flash",
  74. .id = 0,
  75. .resource = &cns3420_nor_res,
  76. .num_resources = 1,
  77. .dev = {
  78. .platform_data = &cns3420_nor_pdata,
  79. },
  80. };
  81. /*
  82. * UART
  83. */
  84. static void __init cns3420_early_serial_setup(void)
  85. {
  86. #ifdef CONFIG_SERIAL_8250_CONSOLE
  87. static struct uart_port cns3420_serial_port = {
  88. .membase = (void __iomem *)CNS3XXX_UART0_BASE_VIRT,
  89. .mapbase = CNS3XXX_UART0_BASE,
  90. .irq = IRQ_CNS3XXX_UART0,
  91. .iotype = UPIO_MEM,
  92. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
  93. .regshift = 2,
  94. .uartclk = 24000000,
  95. .line = 0,
  96. .type = PORT_16550A,
  97. .fifosize = 16,
  98. };
  99. early_serial_setup(&cns3420_serial_port);
  100. #endif
  101. }
  102. /*
  103. * USB
  104. */
  105. static struct resource cns3xxx_usb_ehci_resources[] = {
  106. [0] = {
  107. .start = CNS3XXX_USB_BASE,
  108. .end = CNS3XXX_USB_BASE + SZ_16M - 1,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. [1] = {
  112. .start = IRQ_CNS3XXX_USB_EHCI,
  113. .flags = IORESOURCE_IRQ,
  114. },
  115. };
  116. static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32);
  117. static struct platform_device cns3xxx_usb_ehci_device = {
  118. .name = "cns3xxx-ehci",
  119. .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources),
  120. .resource = cns3xxx_usb_ehci_resources,
  121. .dev = {
  122. .dma_mask = &cns3xxx_usb_ehci_dma_mask,
  123. .coherent_dma_mask = DMA_BIT_MASK(32),
  124. },
  125. };
  126. static struct resource cns3xxx_usb_ohci_resources[] = {
  127. [0] = {
  128. .start = CNS3XXX_USB_OHCI_BASE,
  129. .end = CNS3XXX_USB_OHCI_BASE + SZ_16M - 1,
  130. .flags = IORESOURCE_MEM,
  131. },
  132. [1] = {
  133. .start = IRQ_CNS3XXX_USB_OHCI,
  134. .flags = IORESOURCE_IRQ,
  135. },
  136. };
  137. static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32);
  138. static struct platform_device cns3xxx_usb_ohci_device = {
  139. .name = "cns3xxx-ohci",
  140. .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources),
  141. .resource = cns3xxx_usb_ohci_resources,
  142. .dev = {
  143. .dma_mask = &cns3xxx_usb_ohci_dma_mask,
  144. .coherent_dma_mask = DMA_BIT_MASK(32),
  145. },
  146. };
  147. /*
  148. * Initialization
  149. */
  150. static struct platform_device *cns3420_pdevs[] __initdata = {
  151. &cns3420_nor_pdev,
  152. &cns3xxx_usb_ehci_device,
  153. &cns3xxx_usb_ohci_device,
  154. };
  155. static void __init cns3420_init(void)
  156. {
  157. cns3xxx_l2x0_init();
  158. platform_add_devices(cns3420_pdevs, ARRAY_SIZE(cns3420_pdevs));
  159. cns3xxx_ahci_init();
  160. cns3xxx_sdhci_init();
  161. pm_power_off = cns3xxx_power_off;
  162. }
  163. static struct map_desc cns3420_io_desc[] __initdata = {
  164. {
  165. .virtual = CNS3XXX_UART0_BASE_VIRT,
  166. .pfn = __phys_to_pfn(CNS3XXX_UART0_BASE),
  167. .length = SZ_4K,
  168. .type = MT_DEVICE,
  169. },
  170. };
  171. static void __init cns3420_map_io(void)
  172. {
  173. cns3xxx_map_io();
  174. iotable_init(cns3420_io_desc, ARRAY_SIZE(cns3420_io_desc));
  175. cns3420_early_serial_setup();
  176. }
  177. MACHINE_START(CNS3420VB, "Cavium Networks CNS3420 Validation Board")
  178. .boot_params = 0x00000100,
  179. .map_io = cns3420_map_io,
  180. .init_irq = cns3xxx_init_irq,
  181. .timer = &cns3xxx_timer,
  182. .init_machine = cns3420_init,
  183. MACHINE_END