board-ib62x0.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright 2012 (C), Simon Baatz <gmbnomis@gmail.com>
  3. *
  4. * arch/arm/mach-kirkwood/board-ib62x0.c
  5. *
  6. * RaidSonic ICY BOX IB-NAS6210 & IB-NAS6220 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/mv643xx_eth.h>
  19. #include <linux/gpio.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/leds.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <mach/kirkwood.h>
  26. #include "common.h"
  27. #include "mpp.h"
  28. #define IB62X0_GPIO_POWER_OFF 24
  29. static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
  30. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  31. };
  32. static struct mv_sata_platform_data ib62x0_sata_data = {
  33. .n_ports = 2,
  34. };
  35. static unsigned int ib62x0_mpp_config[] __initdata = {
  36. MPP0_NF_IO2,
  37. MPP1_NF_IO3,
  38. MPP2_NF_IO4,
  39. MPP3_NF_IO5,
  40. MPP4_NF_IO6,
  41. MPP5_NF_IO7,
  42. MPP18_NF_IO0,
  43. MPP19_NF_IO1,
  44. MPP22_GPIO, /* OS LED red */
  45. MPP24_GPIO, /* Power off device */
  46. MPP25_GPIO, /* OS LED green */
  47. MPP27_GPIO, /* USB transfer LED */
  48. MPP28_GPIO, /* Reset button */
  49. MPP29_GPIO, /* USB Copy button */
  50. 0
  51. };
  52. static struct gpio_led ib62x0_led_pins[] = {
  53. {
  54. .name = "ib62x0:green:os",
  55. .default_trigger = "default-on",
  56. .gpio = 25,
  57. .active_low = 0,
  58. },
  59. {
  60. .name = "ib62x0:red:os",
  61. .default_trigger = "none",
  62. .gpio = 22,
  63. .active_low = 0,
  64. },
  65. {
  66. .name = "ib62x0:red:usb_copy",
  67. .default_trigger = "none",
  68. .gpio = 27,
  69. .active_low = 0,
  70. },
  71. };
  72. static struct gpio_led_platform_data ib62x0_led_data = {
  73. .leds = ib62x0_led_pins,
  74. .num_leds = ARRAY_SIZE(ib62x0_led_pins),
  75. };
  76. static struct platform_device ib62x0_led_device = {
  77. .name = "leds-gpio",
  78. .id = -1,
  79. .dev = {
  80. .platform_data = &ib62x0_led_data,
  81. }
  82. };
  83. static struct gpio_keys_button ib62x0_button_pins[] = {
  84. {
  85. .code = KEY_COPY,
  86. .gpio = 29,
  87. .desc = "USB Copy",
  88. .active_low = 1,
  89. },
  90. {
  91. .code = KEY_RESTART,
  92. .gpio = 28,
  93. .desc = "Reset",
  94. .active_low = 1,
  95. },
  96. };
  97. static struct gpio_keys_platform_data ib62x0_button_data = {
  98. .buttons = ib62x0_button_pins,
  99. .nbuttons = ARRAY_SIZE(ib62x0_button_pins),
  100. };
  101. static struct platform_device ib62x0_button_device = {
  102. .name = "gpio-keys",
  103. .id = -1,
  104. .num_resources = 0,
  105. .dev = {
  106. .platform_data = &ib62x0_button_data,
  107. }
  108. };
  109. static void ib62x0_power_off(void)
  110. {
  111. gpio_set_value(IB62X0_GPIO_POWER_OFF, 1);
  112. }
  113. void __init ib62x0_init(void)
  114. {
  115. /*
  116. * Basic setup. Needs to be called early.
  117. */
  118. kirkwood_mpp_conf(ib62x0_mpp_config);
  119. kirkwood_ehci_init();
  120. kirkwood_ge00_init(&ib62x0_ge00_data);
  121. kirkwood_sata_init(&ib62x0_sata_data);
  122. platform_device_register(&ib62x0_led_device);
  123. platform_device_register(&ib62x0_button_device);
  124. if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 &&
  125. gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0)
  126. pm_power_off = ib62x0_power_off;
  127. else
  128. pr_err("board-ib62x0: failed to configure power-off GPIO\n");
  129. }