board-lsxl.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright 2012 (C), Michael Walle <michael@walle.cc>
  3. *
  4. * arch/arm/mach-kirkwood/board-lsxl.c
  5. *
  6. * Buffalo Linkstation LS-XHL and LS-CHLv2 init for drivers not
  7. * converted to flattened device tree yet.
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <linux/gpio.h>
  18. #include <linux/gpio-fan.h>
  19. #include "common.h"
  20. #include "mpp.h"
  21. static struct mv643xx_eth_platform_data lsxl_ge00_data = {
  22. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  23. };
  24. static struct mv643xx_eth_platform_data lsxl_ge01_data = {
  25. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  26. };
  27. static unsigned int lsxl_mpp_config[] __initdata = {
  28. MPP10_GPO, /* HDD Power Enable */
  29. MPP11_GPIO, /* USB Vbus Enable */
  30. MPP18_GPO, /* FAN High Enable# */
  31. MPP19_GPO, /* FAN Low Enable# */
  32. MPP36_GPIO, /* Function Blue LED */
  33. MPP37_GPIO, /* Alarm LED */
  34. MPP38_GPIO, /* Info LED */
  35. MPP39_GPIO, /* Power LED */
  36. MPP40_GPIO, /* Fan Lock */
  37. MPP41_GPIO, /* Function Button */
  38. MPP42_GPIO, /* Power Switch */
  39. MPP43_GPIO, /* Power Auto Switch */
  40. MPP48_GPIO, /* Function Red LED */
  41. 0
  42. };
  43. #define LSXL_GPIO_FAN_HIGH 18
  44. #define LSXL_GPIO_FAN_LOW 19
  45. #define LSXL_GPIO_FAN_LOCK 40
  46. static struct gpio_fan_alarm lsxl_alarm = {
  47. .gpio = LSXL_GPIO_FAN_LOCK,
  48. };
  49. static struct gpio_fan_speed lsxl_speeds[] = {
  50. {
  51. .rpm = 0,
  52. .ctrl_val = 3,
  53. }, {
  54. .rpm = 1500,
  55. .ctrl_val = 1,
  56. }, {
  57. .rpm = 3250,
  58. .ctrl_val = 2,
  59. }, {
  60. .rpm = 5000,
  61. .ctrl_val = 0,
  62. }
  63. };
  64. static int lsxl_gpio_list[] = {
  65. LSXL_GPIO_FAN_HIGH, LSXL_GPIO_FAN_LOW,
  66. };
  67. static struct gpio_fan_platform_data lsxl_fan_data = {
  68. .num_ctrl = ARRAY_SIZE(lsxl_gpio_list),
  69. .ctrl = lsxl_gpio_list,
  70. .alarm = &lsxl_alarm,
  71. .num_speed = ARRAY_SIZE(lsxl_speeds),
  72. .speed = lsxl_speeds,
  73. };
  74. static struct platform_device lsxl_fan_device = {
  75. .name = "gpio-fan",
  76. .id = -1,
  77. .num_resources = 0,
  78. .dev = {
  79. .platform_data = &lsxl_fan_data,
  80. },
  81. };
  82. /*
  83. * On the LS-XHL/LS-CHLv2, the shutdown process is following:
  84. * - Userland monitors key events until the power switch goes to off position
  85. * - The board reboots
  86. * - U-boot starts and goes into an idle mode waiting for the user
  87. * to move the switch to ON position
  88. *
  89. */
  90. static void lsxl_power_off(void)
  91. {
  92. kirkwood_restart('h', NULL);
  93. }
  94. #define LSXL_GPIO_HDD_POWER 10
  95. #define LSXL_GPIO_USB_POWER 11
  96. void __init lsxl_init(void)
  97. {
  98. /*
  99. * Basic setup. Needs to be called early.
  100. */
  101. kirkwood_mpp_conf(lsxl_mpp_config);
  102. /* usb and sata power on */
  103. gpio_set_value(LSXL_GPIO_USB_POWER, 1);
  104. gpio_set_value(LSXL_GPIO_HDD_POWER, 1);
  105. kirkwood_ehci_init();
  106. kirkwood_ge00_init(&lsxl_ge00_data);
  107. kirkwood_ge01_init(&lsxl_ge01_data);
  108. platform_device_register(&lsxl_fan_device);
  109. /* register power-off method */
  110. pm_power_off = lsxl_power_off;
  111. }