ts219-setup.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. *
  3. * QNAP TS-11x/TS-21x 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_ts219_i2c_rtc = {
  28. I2C_BOARD_INFO("s35390a", 0x30),
  29. };
  30. static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = {
  31. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  32. };
  33. static struct mv_sata_platform_data qnap_ts219_sata_data = {
  34. .n_ports = 2,
  35. };
  36. static struct gpio_keys_button qnap_ts219_buttons[] = {
  37. {
  38. .code = KEY_COPY,
  39. .gpio = 15,
  40. .desc = "USB Copy",
  41. .active_low = 1,
  42. },
  43. {
  44. .code = KEY_RESTART,
  45. .gpio = 16,
  46. .desc = "Reset",
  47. .active_low = 1,
  48. },
  49. };
  50. static struct gpio_keys_platform_data qnap_ts219_button_data = {
  51. .buttons = qnap_ts219_buttons,
  52. .nbuttons = ARRAY_SIZE(qnap_ts219_buttons),
  53. };
  54. static struct platform_device qnap_ts219_button_device = {
  55. .name = "gpio-keys",
  56. .id = -1,
  57. .num_resources = 0,
  58. .dev = {
  59. .platform_data = &qnap_ts219_button_data,
  60. }
  61. };
  62. static unsigned int qnap_ts219_mpp_config[] __initdata = {
  63. MPP0_SPI_SCn,
  64. MPP1_SPI_MOSI,
  65. MPP2_SPI_SCK,
  66. MPP3_SPI_MISO,
  67. MPP4_SATA1_ACTn,
  68. MPP5_SATA0_ACTn,
  69. MPP8_TW0_SDA,
  70. MPP9_TW0_SCK,
  71. MPP10_UART0_TXD,
  72. MPP11_UART0_RXD,
  73. MPP13_UART1_TXD, /* PIC controller */
  74. MPP14_UART1_RXD, /* PIC controller */
  75. MPP15_GPIO, /* USB Copy button (on devices with 88F6281) */
  76. MPP16_GPIO, /* Reset button (on devices with 88F6281) */
  77. MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */
  78. MPP37_GPIO, /* Reset button (on devices with 88F6282) */
  79. MPP43_GPIO, /* USB Copy button (on devices with 88F6282) */
  80. MPP44_GPIO, /* Board ID: 0: TS-11x, 1: TS-21x */
  81. 0
  82. };
  83. static void __init qnap_ts219_init(void)
  84. {
  85. u32 dev, rev;
  86. /*
  87. * Basic setup. Needs to be called early.
  88. */
  89. kirkwood_init();
  90. kirkwood_mpp_conf(qnap_ts219_mpp_config);
  91. kirkwood_uart0_init();
  92. kirkwood_uart1_init(); /* A PIC controller is connected here. */
  93. qnap_tsx1x_register_flash();
  94. kirkwood_i2c_init();
  95. i2c_register_board_info(0, &qnap_ts219_i2c_rtc, 1);
  96. kirkwood_pcie_id(&dev, &rev);
  97. if (dev == MV88F6282_DEV_ID) {
  98. qnap_ts219_buttons[0].gpio = 43; /* USB Copy button */
  99. qnap_ts219_buttons[1].gpio = 37; /* Reset button */
  100. qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
  101. }
  102. kirkwood_ge00_init(&qnap_ts219_ge00_data);
  103. kirkwood_sata_init(&qnap_ts219_sata_data);
  104. kirkwood_ehci_init();
  105. platform_device_register(&qnap_ts219_button_device);
  106. pm_power_off = qnap_tsx1x_power_off;
  107. }
  108. static int __init ts219_pci_init(void)
  109. {
  110. if (machine_is_ts219())
  111. kirkwood_pcie_init(KW_PCIE1 | KW_PCIE0);
  112. return 0;
  113. }
  114. subsys_initcall(ts219_pci_init);
  115. MACHINE_START(TS219, "QNAP TS-119/TS-219")
  116. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  117. .atag_offset = 0x100,
  118. .init_machine = qnap_ts219_init,
  119. .map_io = kirkwood_map_io,
  120. .init_early = kirkwood_init_early,
  121. .init_irq = kirkwood_init_irq,
  122. .timer = &kirkwood_timer,
  123. .restart = kirkwood_restart,
  124. MACHINE_END