board-ns2.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2012 (C), Simon Guinot <simon.guinot@sequanux.org>
  3. *
  4. * arch/arm/mach-kirkwood/board-ns2.c
  5. *
  6. * LaCie Network Space v2 board (and parents) initialization for drivers
  7. * not 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/of.h>
  19. #include "common.h"
  20. #include "mpp.h"
  21. static struct mv643xx_eth_platform_data ns2_ge00_data = {
  22. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  23. };
  24. static unsigned int ns2_mpp_config[] __initdata = {
  25. MPP0_SPI_SCn,
  26. MPP1_SPI_MOSI,
  27. MPP2_SPI_SCK,
  28. MPP3_SPI_MISO,
  29. MPP4_NF_IO6,
  30. MPP5_NF_IO7,
  31. MPP6_SYSRST_OUTn,
  32. MPP7_GPO, /* Fan speed (bit 1) */
  33. MPP8_TW0_SDA,
  34. MPP9_TW0_SCK,
  35. MPP10_UART0_TXD,
  36. MPP11_UART0_RXD,
  37. MPP12_GPO, /* Red led */
  38. MPP14_GPIO, /* USB fuse */
  39. MPP16_GPIO, /* SATA 0 power */
  40. MPP17_GPIO, /* SATA 1 power */
  41. MPP18_NF_IO0,
  42. MPP19_NF_IO1,
  43. MPP20_SATA1_ACTn,
  44. MPP21_SATA0_ACTn,
  45. MPP22_GPIO, /* Fan speed (bit 0) */
  46. MPP23_GPIO, /* Fan power */
  47. MPP24_GPIO, /* USB mode select */
  48. MPP25_GPIO, /* Fan rotation fail */
  49. MPP26_GPIO, /* USB device vbus */
  50. MPP28_GPIO, /* USB enable host vbus */
  51. MPP29_GPIO, /* Blue led (slow register) */
  52. MPP30_GPIO, /* Blue led (command register) */
  53. MPP31_GPIO, /* Board power off */
  54. MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */
  55. MPP33_GPO, /* Fan speed (bit 2) */
  56. 0
  57. };
  58. #define NS2_GPIO_POWER_OFF 31
  59. static void ns2_power_off(void)
  60. {
  61. gpio_set_value(NS2_GPIO_POWER_OFF, 1);
  62. }
  63. void __init ns2_init(void)
  64. {
  65. /*
  66. * Basic setup. Needs to be called early.
  67. */
  68. kirkwood_mpp_conf(ns2_mpp_config);
  69. if (of_machine_is_compatible("lacie,netspace_lite_v2") ||
  70. of_machine_is_compatible("lacie,netspace_mini_v2"))
  71. ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
  72. kirkwood_ge00_init(&ns2_ge00_data);
  73. if (gpio_request(NS2_GPIO_POWER_OFF, "power-off") == 0 &&
  74. gpio_direction_output(NS2_GPIO_POWER_OFF, 0) == 0)
  75. pm_power_off = ns2_power_off;
  76. else
  77. pr_err("ns2: failed to configure power-off GPIO\n");
  78. }