wrt350n-v2-setup.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * arch/arm/mach-orion5x/wrt350n-v2-setup.c
  3. *
  4. * This file is licensed under the terms of the GNU General Public
  5. * License version 2. This program is licensed "as is" without any
  6. * warranty of any kind, whether express or implied.
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/pci.h>
  12. #include <linux/irq.h>
  13. #include <linux/delay.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/ethtool.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/gpio.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/pci.h>
  21. #include <mach/orion5x.h>
  22. #include "common.h"
  23. #include "mpp.h"
  24. static struct orion5x_mpp_mode wrt350n_v2_mpp_modes[] __initdata = {
  25. { 0, MPP_GPIO }, /* Power LED green (0=on) */
  26. { 1, MPP_GPIO }, /* Security LED (0=on) */
  27. { 2, MPP_GPIO }, /* Internal Button (0=on) */
  28. { 3, MPP_GPIO }, /* Reset Button (0=on) */
  29. { 4, MPP_GPIO }, /* PCI int */
  30. { 5, MPP_GPIO }, /* Power LED orange (0=on) */
  31. { 6, MPP_GPIO }, /* USB LED (0=on) */
  32. { 7, MPP_GPIO }, /* Wireless LED (0=on) */
  33. { 8, MPP_UNUSED }, /* ??? */
  34. { 9, MPP_GIGE }, /* GE_RXERR */
  35. { 10, MPP_UNUSED }, /* ??? */
  36. { 11, MPP_UNUSED }, /* ??? */
  37. { 12, MPP_GIGE }, /* GE_TXD[4] */
  38. { 13, MPP_GIGE }, /* GE_TXD[5] */
  39. { 14, MPP_GIGE }, /* GE_TXD[6] */
  40. { 15, MPP_GIGE }, /* GE_TXD[7] */
  41. { 16, MPP_GIGE }, /* GE_RXD[4] */
  42. { 17, MPP_GIGE }, /* GE_RXD[5] */
  43. { 18, MPP_GIGE }, /* GE_RXD[6] */
  44. { 19, MPP_GIGE }, /* GE_RXD[7] */
  45. { -1 },
  46. };
  47. /*
  48. * 8M NOR flash Device bus boot chip select
  49. */
  50. #define WRT350N_V2_NOR_BOOT_BASE 0xf4000000
  51. #define WRT350N_V2_NOR_BOOT_SIZE SZ_8M
  52. static struct mtd_partition wrt350n_v2_nor_flash_partitions[] = {
  53. {
  54. .name = "kernel",
  55. .offset = 0x00000000,
  56. .size = 0x00760000,
  57. }, {
  58. .name = "rootfs",
  59. .offset = 0x001a0000,
  60. .size = 0x005c0000,
  61. }, {
  62. .name = "lang",
  63. .offset = 0x00760000,
  64. .size = 0x00040000,
  65. }, {
  66. .name = "nvram",
  67. .offset = 0x007a0000,
  68. .size = 0x00020000,
  69. }, {
  70. .name = "u-boot",
  71. .offset = 0x007c0000,
  72. .size = 0x00040000,
  73. },
  74. };
  75. static struct physmap_flash_data wrt350n_v2_nor_flash_data = {
  76. .width = 1,
  77. .parts = wrt350n_v2_nor_flash_partitions,
  78. .nr_parts = ARRAY_SIZE(wrt350n_v2_nor_flash_partitions),
  79. };
  80. static struct resource wrt350n_v2_nor_flash_resource = {
  81. .flags = IORESOURCE_MEM,
  82. .start = WRT350N_V2_NOR_BOOT_BASE,
  83. .end = WRT350N_V2_NOR_BOOT_BASE + WRT350N_V2_NOR_BOOT_SIZE - 1,
  84. };
  85. static struct platform_device wrt350n_v2_nor_flash = {
  86. .name = "physmap-flash",
  87. .id = 0,
  88. .dev = {
  89. .platform_data = &wrt350n_v2_nor_flash_data,
  90. },
  91. .num_resources = 1,
  92. .resource = &wrt350n_v2_nor_flash_resource,
  93. };
  94. static struct mv643xx_eth_platform_data wrt350n_v2_eth_data = {
  95. .phy_addr = MV643XX_ETH_PHY_NONE,
  96. .speed = SPEED_1000,
  97. .duplex = DUPLEX_FULL,
  98. };
  99. static void __init wrt350n_v2_init(void)
  100. {
  101. /*
  102. * Setup basic Orion functions. Need to be called early.
  103. */
  104. orion5x_init();
  105. orion5x_mpp_conf(wrt350n_v2_mpp_modes);
  106. /*
  107. * Configure peripherals.
  108. */
  109. orion5x_ehci0_init();
  110. orion5x_eth_init(&wrt350n_v2_eth_data);
  111. orion5x_uart0_init();
  112. orion5x_setup_dev_boot_win(WRT350N_V2_NOR_BOOT_BASE,
  113. WRT350N_V2_NOR_BOOT_SIZE);
  114. platform_device_register(&wrt350n_v2_nor_flash);
  115. }
  116. static int __init wrt350n_v2_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  117. {
  118. int irq;
  119. /*
  120. * Check for devices with hard-wired IRQs.
  121. */
  122. irq = orion5x_pci_map_irq(dev, slot, pin);
  123. if (irq != -1)
  124. return irq;
  125. /*
  126. * Mini-PCI slot.
  127. */
  128. if (slot == 7)
  129. return gpio_to_irq(4);
  130. return -1;
  131. }
  132. static struct hw_pci wrt350n_v2_pci __initdata = {
  133. .nr_controllers = 2,
  134. .swizzle = pci_std_swizzle,
  135. .setup = orion5x_pci_sys_setup,
  136. .scan = orion5x_pci_sys_scan_bus,
  137. .map_irq = wrt350n_v2_pci_map_irq,
  138. };
  139. static int __init wrt350n_v2_pci_init(void)
  140. {
  141. if (machine_is_wrt350n_v2())
  142. pci_common_init(&wrt350n_v2_pci);
  143. return 0;
  144. }
  145. subsys_initcall(wrt350n_v2_pci_init);
  146. MACHINE_START(WRT350N_V2, "Linksys WRT350N v2")
  147. /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
  148. .phys_io = ORION5X_REGS_PHYS_BASE,
  149. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  150. .boot_params = 0x00000100,
  151. .init_machine = wrt350n_v2_init,
  152. .map_io = orion5x_map_io,
  153. .init_irq = orion5x_init_irq,
  154. .timer = &orion5x_timer,
  155. .fixup = tag_fixup_mem32,
  156. MACHINE_END