ts41x-setup.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. *
  3. * QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS Board Setup
  4. *
  5. * Copyright (C) 2009-2010 Martin Michlmayr <tbm@cyrius.com>
  6. * Copyright (C) 2008 Byron Bradley <byron.bbradley@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/i2c.h>
  17. #include <linux/mv643xx_eth.h>
  18. #include <linux/ata_platform.h>
  19. #include <linux/gpio.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/io.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <mach/kirkwood.h>
  26. #include "common.h"
  27. #include "mpp.h"
  28. #include "tsx1x-common.h"
  29. /* for the PCIe reset workaround */
  30. #include <plat/pcie.h>
  31. #define QNAP_TS41X_JUMPER_JP1 45
  32. static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = {
  33. I2C_BOARD_INFO("s35390a", 0x30),
  34. };
  35. static struct mv643xx_eth_platform_data qnap_ts41x_ge00_data = {
  36. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  37. };
  38. static struct mv643xx_eth_platform_data qnap_ts41x_ge01_data = {
  39. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  40. };
  41. static struct mv_sata_platform_data qnap_ts41x_sata_data = {
  42. .n_ports = 2,
  43. };
  44. static struct gpio_keys_button qnap_ts41x_buttons[] = {
  45. {
  46. .code = KEY_COPY,
  47. .gpio = 43,
  48. .desc = "USB Copy",
  49. .active_low = 1,
  50. },
  51. {
  52. .code = KEY_RESTART,
  53. .gpio = 37,
  54. .desc = "Reset",
  55. .active_low = 1,
  56. },
  57. };
  58. static struct gpio_keys_platform_data qnap_ts41x_button_data = {
  59. .buttons = qnap_ts41x_buttons,
  60. .nbuttons = ARRAY_SIZE(qnap_ts41x_buttons),
  61. };
  62. static struct platform_device qnap_ts41x_button_device = {
  63. .name = "gpio-keys",
  64. .id = -1,
  65. .num_resources = 0,
  66. .dev = {
  67. .platform_data = &qnap_ts41x_button_data,
  68. }
  69. };
  70. static unsigned int qnap_ts41x_mpp_config[] __initdata = {
  71. MPP0_SPI_SCn,
  72. MPP1_SPI_MOSI,
  73. MPP2_SPI_SCK,
  74. MPP3_SPI_MISO,
  75. MPP6_SYSRST_OUTn,
  76. MPP7_PEX_RST_OUTn,
  77. MPP8_TW0_SDA,
  78. MPP9_TW0_SCK,
  79. MPP10_UART0_TXD,
  80. MPP11_UART0_RXD,
  81. MPP13_UART1_TXD, /* PIC controller */
  82. MPP14_UART1_RXD, /* PIC controller */
  83. MPP15_SATA0_ACTn,
  84. MPP16_SATA1_ACTn,
  85. MPP20_GE1_TXD0,
  86. MPP21_GE1_TXD1,
  87. MPP22_GE1_TXD2,
  88. MPP23_GE1_TXD3,
  89. MPP24_GE1_RXD0,
  90. MPP25_GE1_RXD1,
  91. MPP26_GE1_RXD2,
  92. MPP27_GE1_RXD3,
  93. MPP30_GE1_RXCTL,
  94. MPP31_GE1_RXCLK,
  95. MPP32_GE1_TCLKOUT,
  96. MPP33_GE1_TXCTL,
  97. MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */
  98. MPP37_GPIO, /* Reset button */
  99. MPP43_GPIO, /* USB Copy button */
  100. MPP44_GPIO, /* Board ID: 0: TS-419U, 1: TS-419 */
  101. MPP45_GPIO, /* JP1: 0: LCD, 1: serial console */
  102. MPP46_GPIO, /* External SATA HDD1 error indicator */
  103. MPP47_GPIO, /* External SATA HDD2 error indicator */
  104. MPP48_GPIO, /* External SATA HDD3 error indicator */
  105. MPP49_GPIO, /* External SATA HDD4 error indicator */
  106. 0
  107. };
  108. static void __init qnap_ts41x_init(void)
  109. {
  110. u32 dev, rev;
  111. /*
  112. * Basic setup. Needs to be called early.
  113. */
  114. kirkwood_init();
  115. kirkwood_mpp_conf(qnap_ts41x_mpp_config);
  116. kirkwood_uart0_init();
  117. kirkwood_uart1_init(); /* A PIC controller is connected here. */
  118. qnap_tsx1x_register_flash();
  119. kirkwood_i2c_init();
  120. i2c_register_board_info(0, &qnap_ts41x_i2c_rtc, 1);
  121. kirkwood_pcie_id(&dev, &rev);
  122. if (dev == MV88F6282_DEV_ID) {
  123. qnap_ts41x_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
  124. qnap_ts41x_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1);
  125. }
  126. kirkwood_ge00_init(&qnap_ts41x_ge00_data);
  127. kirkwood_ge01_init(&qnap_ts41x_ge01_data);
  128. kirkwood_sata_init(&qnap_ts41x_sata_data);
  129. kirkwood_ehci_init();
  130. platform_device_register(&qnap_ts41x_button_device);
  131. pm_power_off = qnap_tsx1x_power_off;
  132. if (gpio_request(QNAP_TS41X_JUMPER_JP1, "JP1") == 0)
  133. gpio_export(QNAP_TS41X_JUMPER_JP1, 0);
  134. }
  135. static int __init ts41x_pci_init(void)
  136. {
  137. if (machine_is_ts41x()) {
  138. u32 dev, rev;
  139. /*
  140. * Without this explicit reset, the PCIe SATA controller
  141. * (Marvell 88sx7042/sata_mv) is known to stop working
  142. * after a few minutes.
  143. */
  144. orion_pcie_reset(PCIE_VIRT_BASE);
  145. kirkwood_pcie_id(&dev, &rev);
  146. if (dev == MV88F6282_DEV_ID)
  147. kirkwood_pcie_init(KW_PCIE1 | KW_PCIE0);
  148. else
  149. kirkwood_pcie_init(KW_PCIE0);
  150. }
  151. return 0;
  152. }
  153. subsys_initcall(ts41x_pci_init);
  154. MACHINE_START(TS41X, "QNAP TS-41x")
  155. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  156. .atag_offset = 0x100,
  157. .init_machine = qnap_ts41x_init,
  158. .map_io = kirkwood_map_io,
  159. .init_early = kirkwood_init_early,
  160. .init_irq = kirkwood_init_irq,
  161. .init_time = kirkwood_timer_init,
  162. .restart = kirkwood_restart,
  163. MACHINE_END