board-dnskw.c 3.0 KB

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