board-lsxl.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/mtd/partitions.h>
  17. #include <linux/ata_platform.h>
  18. #include <linux/spi/flash.h>
  19. #include <linux/spi/spi.h>
  20. #include <linux/mv643xx_eth.h>
  21. #include <linux/gpio.h>
  22. #include <linux/gpio-fan.h>
  23. #include <linux/input.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <mach/kirkwood.h>
  27. #include "common.h"
  28. #include "mpp.h"
  29. static struct mv643xx_eth_platform_data lsxl_ge00_data = {
  30. .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  31. };
  32. static struct mv643xx_eth_platform_data lsxl_ge01_data = {
  33. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  34. };
  35. static unsigned int lsxl_mpp_config[] __initdata = {
  36. MPP10_GPO, /* HDD Power Enable */
  37. MPP11_GPIO, /* USB Vbus Enable */
  38. MPP18_GPO, /* FAN High Enable# */
  39. MPP19_GPO, /* FAN Low Enable# */
  40. MPP36_GPIO, /* Function Blue LED */
  41. MPP37_GPIO, /* Alarm LED */
  42. MPP38_GPIO, /* Info LED */
  43. MPP39_GPIO, /* Power LED */
  44. MPP40_GPIO, /* Fan Lock */
  45. MPP41_GPIO, /* Function Button */
  46. MPP42_GPIO, /* Power Switch */
  47. MPP43_GPIO, /* Power Auto Switch */
  48. MPP48_GPIO, /* Function Red LED */
  49. 0
  50. };
  51. #define LSXL_GPIO_FAN_HIGH 18
  52. #define LSXL_GPIO_FAN_LOW 19
  53. #define LSXL_GPIO_FAN_LOCK 40
  54. static struct gpio_fan_alarm lsxl_alarm = {
  55. .gpio = LSXL_GPIO_FAN_LOCK,
  56. };
  57. static struct gpio_fan_speed lsxl_speeds[] = {
  58. {
  59. .rpm = 0,
  60. .ctrl_val = 3,
  61. }, {
  62. .rpm = 1500,
  63. .ctrl_val = 1,
  64. }, {
  65. .rpm = 3250,
  66. .ctrl_val = 2,
  67. }, {
  68. .rpm = 5000,
  69. .ctrl_val = 0,
  70. }
  71. };
  72. static int lsxl_gpio_list[] = {
  73. LSXL_GPIO_FAN_HIGH, LSXL_GPIO_FAN_LOW,
  74. };
  75. static struct gpio_fan_platform_data lsxl_fan_data = {
  76. .num_ctrl = ARRAY_SIZE(lsxl_gpio_list),
  77. .ctrl = lsxl_gpio_list,
  78. .alarm = &lsxl_alarm,
  79. .num_speed = ARRAY_SIZE(lsxl_speeds),
  80. .speed = lsxl_speeds,
  81. };
  82. static struct platform_device lsxl_fan_device = {
  83. .name = "gpio-fan",
  84. .id = -1,
  85. .num_resources = 0,
  86. .dev = {
  87. .platform_data = &lsxl_fan_data,
  88. },
  89. };
  90. /*
  91. * On the LS-XHL/LS-CHLv2, the shutdown process is following:
  92. * - Userland monitors key events until the power switch goes to off position
  93. * - The board reboots
  94. * - U-boot starts and goes into an idle mode waiting for the user
  95. * to move the switch to ON position
  96. *
  97. */
  98. static void lsxl_power_off(void)
  99. {
  100. kirkwood_restart('h', NULL);
  101. }
  102. #define LSXL_GPIO_HDD_POWER 10
  103. #define LSXL_GPIO_USB_POWER 11
  104. void __init lsxl_init(void)
  105. {
  106. /*
  107. * Basic setup. Needs to be called early.
  108. */
  109. kirkwood_mpp_conf(lsxl_mpp_config);
  110. /* usb and sata power on */
  111. gpio_set_value(LSXL_GPIO_USB_POWER, 1);
  112. gpio_set_value(LSXL_GPIO_HDD_POWER, 1);
  113. kirkwood_ehci_init();
  114. kirkwood_ge00_init(&lsxl_ge00_data);
  115. kirkwood_ge01_init(&lsxl_ge01_data);
  116. platform_device_register(&lsxl_fan_device);
  117. /* register power-off method */
  118. pm_power_off = lsxl_power_off;
  119. }