wnr854t-setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * arch/arm/mach-orion5x/wnr854t-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 wnr854t_mpp_modes[] __initdata = {
  25. { 0, MPP_GPIO }, /* Power LED green (0=on) */
  26. { 1, MPP_GPIO }, /* Reset Button (0=off) */
  27. { 2, MPP_GPIO }, /* Power LED blink (0=off) */
  28. { 3, MPP_GPIO }, /* WAN Status LED amber (0=off) */
  29. { 4, MPP_GPIO }, /* PCI int */
  30. { 5, MPP_GPIO }, /* ??? */
  31. { 6, MPP_GPIO }, /* ??? */
  32. { 7, MPP_GPIO }, /* ??? */
  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 WNR854T_NOR_BOOT_BASE 0xf4000000
  51. #define WNR854T_NOR_BOOT_SIZE SZ_8M
  52. static struct mtd_partition wnr854t_nor_flash_partitions[] = {
  53. {
  54. .name = "kernel",
  55. .offset = 0x00000000,
  56. .size = 0x00100000,
  57. }, {
  58. .name = "rootfs",
  59. .offset = 0x00100000,
  60. .size = 0x00660000,
  61. }, {
  62. .name = "uboot",
  63. .offset = 0x00760000,
  64. .size = 0x00040000,
  65. },
  66. };
  67. static struct physmap_flash_data wnr854t_nor_flash_data = {
  68. .width = 2,
  69. .parts = wnr854t_nor_flash_partitions,
  70. .nr_parts = ARRAY_SIZE(wnr854t_nor_flash_partitions),
  71. };
  72. static struct resource wnr854t_nor_flash_resource = {
  73. .flags = IORESOURCE_MEM,
  74. .start = WNR854T_NOR_BOOT_BASE,
  75. .end = WNR854T_NOR_BOOT_BASE + WNR854T_NOR_BOOT_SIZE - 1,
  76. };
  77. static struct platform_device wnr854t_nor_flash = {
  78. .name = "physmap-flash",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &wnr854t_nor_flash_data,
  82. },
  83. .num_resources = 1,
  84. .resource = &wnr854t_nor_flash_resource,
  85. };
  86. static struct mv643xx_eth_platform_data wnr854t_eth_data = {
  87. .phy_addr = MV643XX_ETH_PHY_NONE,
  88. .speed = SPEED_1000,
  89. .duplex = DUPLEX_FULL,
  90. };
  91. static void __init wnr854t_init(void)
  92. {
  93. /*
  94. * Setup basic Orion functions. Need to be called early.
  95. */
  96. orion5x_init();
  97. orion5x_mpp_conf(wnr854t_mpp_modes);
  98. /*
  99. * Configure peripherals.
  100. */
  101. orion5x_eth_init(&wnr854t_eth_data);
  102. orion5x_uart0_init();
  103. orion5x_setup_dev_boot_win(WNR854T_NOR_BOOT_BASE,
  104. WNR854T_NOR_BOOT_SIZE);
  105. platform_device_register(&wnr854t_nor_flash);
  106. }
  107. static int __init wnr854t_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  108. {
  109. int irq;
  110. /*
  111. * Check for devices with hard-wired IRQs.
  112. */
  113. irq = orion5x_pci_map_irq(dev, slot, pin);
  114. if (irq != -1)
  115. return irq;
  116. /*
  117. * Mini-PCI slot.
  118. */
  119. if (slot == 7)
  120. return gpio_to_irq(4);
  121. return -1;
  122. }
  123. static struct hw_pci wnr854t_pci __initdata = {
  124. .nr_controllers = 2,
  125. .swizzle = pci_std_swizzle,
  126. .setup = orion5x_pci_sys_setup,
  127. .scan = orion5x_pci_sys_scan_bus,
  128. .map_irq = wnr854t_pci_map_irq,
  129. };
  130. static int __init wnr854t_pci_init(void)
  131. {
  132. if (machine_is_wnr854t())
  133. pci_common_init(&wnr854t_pci);
  134. return 0;
  135. }
  136. subsys_initcall(wnr854t_pci_init);
  137. MACHINE_START(WNR854T, "Netgear WNR854T")
  138. /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
  139. .phys_io = ORION5X_REGS_PHYS_BASE,
  140. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  141. .boot_params = 0x00000100,
  142. .init_machine = wnr854t_init,
  143. .map_io = orion5x_map_io,
  144. .init_irq = orion5x_init_irq,
  145. .timer = &orion5x_timer,
  146. .fixup = tag_fixup_mem32,
  147. MACHINE_END