ts41x-setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. #define QNAP_TS41X_JUMPER_JP1 45
  29. static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = {
  30. I2C_BOARD_INFO("s35390a", 0x30),
  31. };
  32. static struct mv643xx_eth_platform_data qnap_ts41x_ge00_data = {
  33. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  34. };
  35. static struct mv643xx_eth_platform_data qnap_ts41x_ge01_data = {
  36. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  37. };
  38. static struct mv_sata_platform_data qnap_ts41x_sata_data = {
  39. .n_ports = 2,
  40. };
  41. static struct gpio_keys_button qnap_ts41x_buttons[] = {
  42. {
  43. .code = KEY_COPY,
  44. .gpio = 43,
  45. .desc = "USB Copy",
  46. .active_low = 1,
  47. },
  48. {
  49. .code = KEY_RESTART,
  50. .gpio = 37,
  51. .desc = "Reset",
  52. .active_low = 1,
  53. },
  54. };
  55. static struct gpio_keys_platform_data qnap_ts41x_button_data = {
  56. .buttons = qnap_ts41x_buttons,
  57. .nbuttons = ARRAY_SIZE(qnap_ts41x_buttons),
  58. };
  59. static struct platform_device qnap_ts41x_button_device = {
  60. .name = "gpio-keys",
  61. .id = -1,
  62. .num_resources = 0,
  63. .dev = {
  64. .platform_data = &qnap_ts41x_button_data,
  65. }
  66. };
  67. static unsigned int qnap_ts41x_mpp_config[] __initdata = {
  68. MPP0_SPI_SCn,
  69. MPP1_SPI_MOSI,
  70. MPP2_SPI_SCK,
  71. MPP3_SPI_MISO,
  72. MPP6_SYSRST_OUTn,
  73. MPP7_PEX_RST_OUTn,
  74. MPP8_TW0_SDA,
  75. MPP9_TW0_SCK,
  76. MPP10_UART0_TXD,
  77. MPP11_UART0_RXD,
  78. MPP13_UART1_TXD, /* PIC controller */
  79. MPP14_UART1_RXD, /* PIC controller */
  80. MPP15_SATA0_ACTn,
  81. MPP16_SATA1_ACTn,
  82. MPP20_GE1_TXD0,
  83. MPP21_GE1_TXD1,
  84. MPP22_GE1_TXD2,
  85. MPP23_GE1_TXD3,
  86. MPP24_GE1_RXD0,
  87. MPP25_GE1_RXD1,
  88. MPP26_GE1_RXD2,
  89. MPP27_GE1_RXD3,
  90. MPP30_GE1_RXCTL,
  91. MPP31_GE1_RXCLK,
  92. MPP32_GE1_TCLKOUT,
  93. MPP33_GE1_TXCTL,
  94. MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */
  95. MPP37_GPIO, /* Reset button */
  96. MPP43_GPIO, /* USB Copy button */
  97. MPP44_GPIO, /* Board ID: 0: TS-419U, 1: TS-419 */
  98. MPP45_GPIO, /* JP1: 0: LCD, 1: serial console */
  99. MPP46_GPIO, /* External SATA HDD1 error indicator */
  100. MPP47_GPIO, /* External SATA HDD2 error indicator */
  101. MPP48_GPIO, /* External SATA HDD3 error indicator */
  102. MPP49_GPIO, /* External SATA HDD4 error indicator */
  103. 0
  104. };
  105. static void __init qnap_ts41x_init(void)
  106. {
  107. /*
  108. * Basic setup. Needs to be called early.
  109. */
  110. kirkwood_init();
  111. kirkwood_mpp_conf(qnap_ts41x_mpp_config);
  112. kirkwood_uart0_init();
  113. kirkwood_uart1_init(); /* A PIC controller is connected here. */
  114. qnap_tsx1x_register_flash();
  115. kirkwood_i2c_init();
  116. i2c_register_board_info(0, &qnap_ts41x_i2c_rtc, 1);
  117. kirkwood_ge00_init(&qnap_ts41x_ge00_data);
  118. kirkwood_ge01_init(&qnap_ts41x_ge01_data);
  119. kirkwood_sata_init(&qnap_ts41x_sata_data);
  120. kirkwood_ehci_init();
  121. platform_device_register(&qnap_ts41x_button_device);
  122. pm_power_off = qnap_tsx1x_power_off;
  123. if (gpio_request(QNAP_TS41X_JUMPER_JP1, "JP1") == 0)
  124. gpio_export(QNAP_TS41X_JUMPER_JP1, 0);
  125. }
  126. static int __init ts41x_pci_init(void)
  127. {
  128. if (machine_is_ts41x())
  129. kirkwood_pcie_init(KW_PCIE0);
  130. return 0;
  131. }
  132. subsys_initcall(ts41x_pci_init);
  133. MACHINE_START(TS41X, "QNAP TS-41x")
  134. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  135. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  136. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  137. .boot_params = 0x00000100,
  138. .init_machine = qnap_ts41x_init,
  139. .map_io = kirkwood_map_io,
  140. .init_irq = kirkwood_init_irq,
  141. .timer = &kirkwood_timer,
  142. MACHINE_END