board-dnskw.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright 2012 (C), Jamie Lentin <jm@lentin.co.uk>
  3. *
  4. * arch/arm/mach-kirkwood/board-dnskw.c
  5. *
  6. * D-link DNS-320 & DNS-325 NAS Init for drivers not converted to
  7. * 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 "common.h"
  19. #include "mpp.h"
  20. static struct mv643xx_eth_platform_data dnskw_ge00_data = {
  21. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  22. };
  23. static unsigned int dnskw_mpp_config[] __initdata = {
  24. MPP13_UART1_TXD, /* Custom ... */
  25. MPP14_UART1_RXD, /* ... Controller (DNS-320 only) */
  26. MPP20_SATA1_ACTn, /* LED: White Right HDD */
  27. MPP21_SATA0_ACTn, /* LED: White Left HDD */
  28. MPP24_GPIO,
  29. MPP25_GPIO,
  30. MPP26_GPIO, /* LED: Power */
  31. MPP27_GPIO, /* LED: Red Right HDD */
  32. MPP28_GPIO, /* LED: Red Left HDD */
  33. MPP29_GPIO, /* LED: Red USB (DNS-325 only) */
  34. MPP30_GPIO,
  35. MPP31_GPIO,
  36. MPP32_GPIO,
  37. MPP33_GPO,
  38. MPP34_GPIO, /* Button: Front power */
  39. MPP35_GPIO, /* LED: Red USB (DNS-320 only) */
  40. MPP36_GPIO, /* Power: Turn off board */
  41. MPP37_GPIO, /* Power: Turn back on after power failure */
  42. MPP38_GPIO,
  43. MPP39_GPIO, /* Power: SATA0 */
  44. MPP40_GPIO, /* Power: SATA1 */
  45. MPP41_GPIO, /* SATA0 present */
  46. MPP42_GPIO, /* SATA1 present */
  47. MPP43_GPIO, /* LED: White USB */
  48. MPP44_GPIO, /* Fan: Tachometer Pin */
  49. MPP45_GPIO, /* Fan: high speed */
  50. MPP46_GPIO, /* Fan: low speed */
  51. MPP47_GPIO, /* Button: Back unmount */
  52. MPP48_GPIO, /* Button: Back reset */
  53. MPP49_GPIO, /* Temp Alarm (DNS-325) Pin of U5 (DNS-320) */
  54. 0
  55. };
  56. static void dnskw_power_off(void)
  57. {
  58. gpio_set_value(36, 1);
  59. }
  60. /* Register any GPIO for output and set the value */
  61. static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
  62. {
  63. if (gpio_request(gpio, name) == 0 &&
  64. gpio_direction_output(gpio, 0) == 0) {
  65. gpio_set_value(gpio, def);
  66. if (gpio_export(gpio, 0) != 0)
  67. pr_err("dnskw: Failed to export GPIO %s\n", name);
  68. } else
  69. pr_err("dnskw: Failed to register %s\n", name);
  70. }
  71. void __init dnskw_init(void)
  72. {
  73. kirkwood_mpp_conf(dnskw_mpp_config);
  74. kirkwood_ge00_init(&dnskw_ge00_data);
  75. /* Register power-off GPIO. */
  76. if (gpio_request(36, "dnskw:power:off") == 0
  77. && gpio_direction_output(36, 0) == 0)
  78. pm_power_off = dnskw_power_off;
  79. else
  80. pr_err("dnskw: failed to configure power-off GPIO\n");
  81. /* Ensure power is supplied to both HDDs */
  82. dnskw_gpio_register(39, "dnskw:power:sata0", 1);
  83. dnskw_gpio_register(40, "dnskw:power:sata1", 1);
  84. /* Set NAS to turn back on after a power failure */
  85. dnskw_gpio_register(37, "dnskw:power:recover", 1);
  86. }