ts41x-setup.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. *
  3. * QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS Board Setup
  4. *
  5. * Copyright (C) 2009 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_keys.h>
  20. #include <linux/input.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/mach/arch.h>
  23. #include <mach/kirkwood.h>
  24. #include "common.h"
  25. #include "mpp.h"
  26. #include "tsx1x-common.h"
  27. static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = {
  28. I2C_BOARD_INFO("s35390a", 0x30),
  29. };
  30. static struct mv643xx_eth_platform_data qnap_ts41x_ge00_data = {
  31. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  32. };
  33. static struct mv643xx_eth_platform_data qnap_ts41x_ge01_data = {
  34. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  35. };
  36. static struct mv_sata_platform_data qnap_ts41x_sata_data = {
  37. .n_ports = 2,
  38. };
  39. static struct gpio_keys_button qnap_ts41x_buttons[] = {
  40. {
  41. .code = KEY_COPY,
  42. .gpio = 43,
  43. .desc = "USB Copy",
  44. .active_low = 1,
  45. },
  46. {
  47. .code = KEY_RESTART,
  48. .gpio = 37,
  49. .desc = "Reset",
  50. .active_low = 1,
  51. },
  52. };
  53. static struct gpio_keys_platform_data qnap_ts41x_button_data = {
  54. .buttons = qnap_ts41x_buttons,
  55. .nbuttons = ARRAY_SIZE(qnap_ts41x_buttons),
  56. };
  57. static struct platform_device qnap_ts41x_button_device = {
  58. .name = "gpio-keys",
  59. .id = -1,
  60. .num_resources = 0,
  61. .dev = {
  62. .platform_data = &qnap_ts41x_button_data,
  63. }
  64. };
  65. static unsigned int qnap_ts41x_mpp_config[] __initdata = {
  66. MPP0_SPI_SCn,
  67. MPP1_SPI_MOSI,
  68. MPP2_SPI_SCK,
  69. MPP3_SPI_MISO,
  70. MPP6_SYSRST_OUTn,
  71. MPP7_PEX_RST_OUTn,
  72. MPP8_TW_SDA,
  73. MPP9_TW_SCK,
  74. MPP10_UART0_TXD,
  75. MPP11_UART0_RXD,
  76. MPP13_UART1_TXD, /* PIC controller */
  77. MPP14_UART1_RXD, /* PIC controller */
  78. MPP15_SATA0_ACTn,
  79. MPP16_SATA1_ACTn,
  80. MPP20_GE1_0,
  81. MPP21_GE1_1,
  82. MPP22_GE1_2,
  83. MPP23_GE1_3,
  84. MPP24_GE1_4,
  85. MPP25_GE1_5,
  86. MPP26_GE1_6,
  87. MPP27_GE1_7,
  88. MPP30_GE1_10,
  89. MPP31_GE1_11,
  90. MPP32_GE1_12,
  91. MPP33_GE1_13,
  92. MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */
  93. MPP37_GPIO, /* Reset button */
  94. MPP43_GPIO, /* USB Copy button */
  95. MPP44_GPIO, /* Board ID: 0: TS-419U, 1: TS-419 */
  96. MPP45_GPIO, /* JP1: 0: console, 1: LCD */
  97. MPP46_GPIO, /* External SATA HDD1 error indicator */
  98. MPP47_GPIO, /* External SATA HDD2 error indicator */
  99. MPP48_GPIO, /* External SATA HDD3 error indicator */
  100. MPP49_GPIO, /* External SATA HDD4 error indicator */
  101. 0
  102. };
  103. static void __init qnap_ts41x_init(void)
  104. {
  105. /*
  106. * Basic setup. Needs to be called early.
  107. */
  108. kirkwood_init();
  109. kirkwood_mpp_conf(qnap_ts41x_mpp_config);
  110. kirkwood_uart0_init();
  111. kirkwood_uart1_init(); /* A PIC controller is connected here. */
  112. qnap_tsx1x_register_flash();
  113. kirkwood_i2c_init();
  114. i2c_register_board_info(0, &qnap_ts41x_i2c_rtc, 1);
  115. kirkwood_ge00_init(&qnap_ts41x_ge00_data);
  116. kirkwood_ge01_init(&qnap_ts41x_ge01_data);
  117. kirkwood_sata_init(&qnap_ts41x_sata_data);
  118. kirkwood_ehci_init();
  119. platform_device_register(&qnap_ts41x_button_device);
  120. pm_power_off = qnap_tsx1x_power_off;
  121. }
  122. static int __init ts41x_pci_init(void)
  123. {
  124. if (machine_is_ts41x())
  125. kirkwood_pcie_init();
  126. return 0;
  127. }
  128. subsys_initcall(ts41x_pci_init);
  129. MACHINE_START(TS41X, "QNAP TS-41x")
  130. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  131. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  132. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  133. .boot_params = 0x00000100,
  134. .init_machine = qnap_ts41x_init,
  135. .map_io = kirkwood_map_io,
  136. .init_irq = kirkwood_init_irq,
  137. .timer = &kirkwood_timer,
  138. MACHINE_END