board-ib62x0.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/input.h>
  21. #include <linux/leds.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <mach/kirkwood.h>
  25. #include "common.h"
  26. #include "mpp.h"
  27. #define IB62X0_GPIO_POWER_OFF 24
  28. static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
  29. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  30. };
  31. static unsigned int ib62x0_mpp_config[] __initdata = {
  32. MPP0_NF_IO2,
  33. MPP1_NF_IO3,
  34. MPP2_NF_IO4,
  35. MPP3_NF_IO5,
  36. MPP4_NF_IO6,
  37. MPP5_NF_IO7,
  38. MPP18_NF_IO0,
  39. MPP19_NF_IO1,
  40. MPP22_GPIO, /* OS LED red */
  41. MPP24_GPIO, /* Power off device */
  42. MPP25_GPIO, /* OS LED green */
  43. MPP27_GPIO, /* USB transfer LED */
  44. MPP28_GPIO, /* Reset button */
  45. MPP29_GPIO, /* USB Copy button */
  46. 0
  47. };
  48. static struct gpio_led ib62x0_led_pins[] = {
  49. {
  50. .name = "ib62x0:green:os",
  51. .default_trigger = "default-on",
  52. .gpio = 25,
  53. .active_low = 0,
  54. },
  55. {
  56. .name = "ib62x0:red:os",
  57. .default_trigger = "none",
  58. .gpio = 22,
  59. .active_low = 0,
  60. },
  61. {
  62. .name = "ib62x0:red:usb_copy",
  63. .default_trigger = "none",
  64. .gpio = 27,
  65. .active_low = 0,
  66. },
  67. };
  68. static struct gpio_led_platform_data ib62x0_led_data = {
  69. .leds = ib62x0_led_pins,
  70. .num_leds = ARRAY_SIZE(ib62x0_led_pins),
  71. };
  72. static struct platform_device ib62x0_led_device = {
  73. .name = "leds-gpio",
  74. .id = -1,
  75. .dev = {
  76. .platform_data = &ib62x0_led_data,
  77. }
  78. };
  79. static void ib62x0_power_off(void)
  80. {
  81. gpio_set_value(IB62X0_GPIO_POWER_OFF, 1);
  82. }
  83. void __init ib62x0_init(void)
  84. {
  85. /*
  86. * Basic setup. Needs to be called early.
  87. */
  88. kirkwood_mpp_conf(ib62x0_mpp_config);
  89. kirkwood_ehci_init();
  90. kirkwood_ge00_init(&ib62x0_ge00_data);
  91. platform_device_register(&ib62x0_led_device);
  92. if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 &&
  93. gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0)
  94. pm_power_off = ib62x0_power_off;
  95. else
  96. pr_err("board-ib62x0: failed to configure power-off GPIO\n");
  97. }