wnr854t-setup.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. // arch/arm/mach-orion5x/wnr854t-setup.c
  3. #include <linux/gpio.h>
  4. #include <linux/kernel.h>
  5. #include <linux/init.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/pci.h>
  8. #include <linux/irq.h>
  9. #include <linux/delay.h>
  10. #include <linux/mtd/physmap.h>
  11. #include <linux/mv643xx_eth.h>
  12. #include <linux/ethtool.h>
  13. #include <linux/platform_data/dsa.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/mach/arch.h>
  16. #include <asm/mach/pci.h>
  17. #include "orion5x.h"
  18. #include "common.h"
  19. #include "mpp.h"
  20. static unsigned int wnr854t_mpp_modes[] __initdata = {
  21. MPP0_GPIO, /* Power LED green (0=on) */
  22. MPP1_GPIO, /* Reset Button (0=off) */
  23. MPP2_GPIO, /* Power LED blink (0=off) */
  24. MPP3_GPIO, /* WAN Status LED amber (0=off) */
  25. MPP4_GPIO, /* PCI int */
  26. MPP5_GPIO, /* ??? */
  27. MPP6_GPIO, /* ??? */
  28. MPP7_GPIO, /* ??? */
  29. MPP8_UNUSED, /* ??? */
  30. MPP9_GIGE, /* GE_RXERR */
  31. MPP10_UNUSED, /* ??? */
  32. MPP11_UNUSED, /* ??? */
  33. MPP12_GIGE, /* GE_TXD[4] */
  34. MPP13_GIGE, /* GE_TXD[5] */
  35. MPP14_GIGE, /* GE_TXD[6] */
  36. MPP15_GIGE, /* GE_TXD[7] */
  37. MPP16_GIGE, /* GE_RXD[4] */
  38. MPP17_GIGE, /* GE_RXD[5] */
  39. MPP18_GIGE, /* GE_RXD[6] */
  40. MPP19_GIGE, /* GE_RXD[7] */
  41. 0,
  42. };
  43. /*
  44. * 8M NOR flash Device bus boot chip select
  45. */
  46. #define WNR854T_NOR_BOOT_BASE 0xf4000000
  47. #define WNR854T_NOR_BOOT_SIZE SZ_8M
  48. static struct mtd_partition wnr854t_nor_flash_partitions[] = {
  49. {
  50. .name = "kernel",
  51. .offset = 0x00000000,
  52. .size = 0x00100000,
  53. }, {
  54. .name = "rootfs",
  55. .offset = 0x00100000,
  56. .size = 0x00660000,
  57. }, {
  58. .name = "uboot",
  59. .offset = 0x00760000,
  60. .size = 0x00040000,
  61. },
  62. };
  63. static struct physmap_flash_data wnr854t_nor_flash_data = {
  64. .width = 2,
  65. .parts = wnr854t_nor_flash_partitions,
  66. .nr_parts = ARRAY_SIZE(wnr854t_nor_flash_partitions),
  67. };
  68. static struct resource wnr854t_nor_flash_resource = {
  69. .flags = IORESOURCE_MEM,
  70. .start = WNR854T_NOR_BOOT_BASE,
  71. .end = WNR854T_NOR_BOOT_BASE + WNR854T_NOR_BOOT_SIZE - 1,
  72. };
  73. static struct platform_device wnr854t_nor_flash = {
  74. .name = "physmap-flash",
  75. .id = 0,
  76. .dev = {
  77. .platform_data = &wnr854t_nor_flash_data,
  78. },
  79. .num_resources = 1,
  80. .resource = &wnr854t_nor_flash_resource,
  81. };
  82. static struct mv643xx_eth_platform_data wnr854t_eth_data = {
  83. .phy_addr = MV643XX_ETH_PHY_NONE,
  84. .speed = SPEED_1000,
  85. .duplex = DUPLEX_FULL,
  86. };
  87. static struct dsa_chip_data wnr854t_switch_chip_data = {
  88. .port_names[0] = "lan3",
  89. .port_names[1] = "lan4",
  90. .port_names[2] = "wan",
  91. .port_names[3] = "cpu",
  92. .port_names[5] = "lan1",
  93. .port_names[7] = "lan2",
  94. };
  95. static void __init wnr854t_init(void)
  96. {
  97. /*
  98. * Setup basic Orion functions. Need to be called early.
  99. */
  100. orion5x_init();
  101. orion5x_mpp_conf(wnr854t_mpp_modes);
  102. /*
  103. * Configure peripherals.
  104. */
  105. orion5x_eth_init(&wnr854t_eth_data);
  106. orion5x_eth_switch_init(&wnr854t_switch_chip_data);
  107. orion5x_uart0_init();
  108. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  109. ORION_MBUS_DEVBUS_BOOT_ATTR,
  110. WNR854T_NOR_BOOT_BASE,
  111. WNR854T_NOR_BOOT_SIZE);
  112. platform_device_register(&wnr854t_nor_flash);
  113. }
  114. static int __init wnr854t_pci_map_irq(const struct pci_dev *dev, u8 slot,
  115. u8 pin)
  116. {
  117. int irq;
  118. /*
  119. * Check for devices with hard-wired IRQs.
  120. */
  121. irq = orion5x_pci_map_irq(dev, slot, pin);
  122. if (irq != -1)
  123. return irq;
  124. /*
  125. * Mini-PCI slot.
  126. */
  127. if (slot == 7)
  128. return gpio_to_irq(4);
  129. return -1;
  130. }
  131. static struct hw_pci wnr854t_pci __initdata = {
  132. .nr_controllers = 2,
  133. .setup = orion5x_pci_sys_setup,
  134. .scan = orion5x_pci_sys_scan_bus,
  135. .map_irq = wnr854t_pci_map_irq,
  136. };
  137. static int __init wnr854t_pci_init(void)
  138. {
  139. if (machine_is_wnr854t())
  140. pci_common_init(&wnr854t_pci);
  141. return 0;
  142. }
  143. subsys_initcall(wnr854t_pci_init);
  144. MACHINE_START(WNR854T, "Netgear WNR854T")
  145. /* Maintainer: Imre Kaloz <[email protected]> */
  146. .atag_offset = 0x100,
  147. .nr_irqs = ORION5X_NR_IRQS,
  148. .init_machine = wnr854t_init,
  149. .map_io = orion5x_map_io,
  150. .init_early = orion5x_init_early,
  151. .init_irq = orion5x_init_irq,
  152. .init_time = orion5x_timer_init,
  153. .fixup = tag_fixup_mem32,
  154. .restart = orion5x_restart,
  155. MACHINE_END