ts41x-setup.c 4.5 KB

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