mv2120-setup.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
  3. * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as
  7. * published by the Free Software Foundation; either version 2 of the
  8. * License, or (at your option) any later version.
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/irq.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <linux/leds.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/input.h>
  20. #include <linux/i2c.h>
  21. #include <linux/ata_platform.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include "common.h"
  25. #include "mpp.h"
  26. #include "orion5x.h"
  27. #define MV2120_NOR_BOOT_BASE 0xf4000000
  28. #define MV2120_NOR_BOOT_SIZE SZ_512K
  29. #define MV2120_GPIO_RTC_IRQ 3
  30. #define MV2120_GPIO_KEY_RESET 17
  31. #define MV2120_GPIO_KEY_POWER 18
  32. #define MV2120_GPIO_POWER_OFF 19
  33. /*****************************************************************************
  34. * Ethernet
  35. ****************************************************************************/
  36. static struct mv643xx_eth_platform_data mv2120_eth_data = {
  37. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  38. };
  39. static struct mv_sata_platform_data mv2120_sata_data = {
  40. .n_ports = 2,
  41. };
  42. static struct mtd_partition mv2120_partitions[] = {
  43. {
  44. .name = "firmware",
  45. .size = 0x00080000,
  46. .offset = 0,
  47. },
  48. };
  49. static struct physmap_flash_data mv2120_nor_flash_data = {
  50. .width = 1,
  51. .parts = mv2120_partitions,
  52. .nr_parts = ARRAY_SIZE(mv2120_partitions)
  53. };
  54. static struct resource mv2120_nor_flash_resource = {
  55. .flags = IORESOURCE_MEM,
  56. .start = MV2120_NOR_BOOT_BASE,
  57. .end = MV2120_NOR_BOOT_BASE + MV2120_NOR_BOOT_SIZE - 1,
  58. };
  59. static struct platform_device mv2120_nor_flash = {
  60. .name = "physmap-flash",
  61. .id = 0,
  62. .dev = {
  63. .platform_data = &mv2120_nor_flash_data,
  64. },
  65. .resource = &mv2120_nor_flash_resource,
  66. .num_resources = 1,
  67. };
  68. static struct gpio_keys_button mv2120_buttons[] = {
  69. {
  70. .code = KEY_RESTART,
  71. .gpio = MV2120_GPIO_KEY_RESET,
  72. .desc = "reset",
  73. .active_low = 1,
  74. }, {
  75. .code = KEY_POWER,
  76. .gpio = MV2120_GPIO_KEY_POWER,
  77. .desc = "power",
  78. .active_low = 1,
  79. },
  80. };
  81. static struct gpio_keys_platform_data mv2120_button_data = {
  82. .buttons = mv2120_buttons,
  83. .nbuttons = ARRAY_SIZE(mv2120_buttons),
  84. };
  85. static struct platform_device mv2120_button_device = {
  86. .name = "gpio-keys",
  87. .id = -1,
  88. .num_resources = 0,
  89. .dev = {
  90. .platform_data = &mv2120_button_data,
  91. },
  92. };
  93. /****************************************************************************
  94. * General Setup
  95. ****************************************************************************/
  96. static unsigned int mv2120_mpp_modes[] __initdata = {
  97. MPP0_GPIO, /* Sys status LED */
  98. MPP1_GPIO, /* Sys error LED */
  99. MPP2_GPIO, /* OverTemp interrupt */
  100. MPP3_GPIO, /* RTC interrupt */
  101. MPP4_GPIO, /* V_LED 5V */
  102. MPP5_GPIO, /* V_LED 3.3V */
  103. MPP6_UNUSED,
  104. MPP7_UNUSED,
  105. MPP8_GPIO, /* SATA 0 fail LED */
  106. MPP9_GPIO, /* SATA 1 fail LED */
  107. MPP10_UNUSED,
  108. MPP11_UNUSED,
  109. MPP12_SATA_LED, /* SATA 0 presence */
  110. MPP13_SATA_LED, /* SATA 1 presence */
  111. MPP14_SATA_LED, /* SATA 0 active */
  112. MPP15_SATA_LED, /* SATA 1 active */
  113. MPP16_UNUSED,
  114. MPP17_GPIO, /* Reset button */
  115. MPP18_GPIO, /* Power button */
  116. MPP19_GPIO, /* Power off */
  117. 0,
  118. };
  119. static struct i2c_board_info __initdata mv2120_i2c_rtc = {
  120. I2C_BOARD_INFO("pcf8563", 0x51),
  121. .irq = 0,
  122. };
  123. static struct gpio_led mv2120_led_pins[] = {
  124. {
  125. .name = "mv2120:blue:health",
  126. .gpio = 0,
  127. },
  128. {
  129. .name = "mv2120:red:health",
  130. .gpio = 1,
  131. },
  132. {
  133. .name = "mv2120:led:bright",
  134. .gpio = 4,
  135. .default_trigger = "default-on",
  136. },
  137. {
  138. .name = "mv2120:led:dimmed",
  139. .gpio = 5,
  140. },
  141. {
  142. .name = "mv2120:red:sata0",
  143. .gpio = 8,
  144. .active_low = 1,
  145. },
  146. {
  147. .name = "mv2120:red:sata1",
  148. .gpio = 9,
  149. .active_low = 1,
  150. },
  151. };
  152. static struct gpio_led_platform_data mv2120_led_data = {
  153. .leds = mv2120_led_pins,
  154. .num_leds = ARRAY_SIZE(mv2120_led_pins),
  155. };
  156. static struct platform_device mv2120_leds = {
  157. .name = "leds-gpio",
  158. .id = -1,
  159. .dev = {
  160. .platform_data = &mv2120_led_data,
  161. }
  162. };
  163. static void mv2120_power_off(void)
  164. {
  165. pr_info("%s: triggering power-off...\n", __func__);
  166. gpio_set_value(MV2120_GPIO_POWER_OFF, 0);
  167. }
  168. static void __init mv2120_init(void)
  169. {
  170. /* Setup basic Orion functions. Need to be called early. */
  171. orion5x_init();
  172. orion5x_mpp_conf(mv2120_mpp_modes);
  173. /*
  174. * Configure peripherals.
  175. */
  176. orion5x_ehci0_init();
  177. orion5x_ehci1_init();
  178. orion5x_eth_init(&mv2120_eth_data);
  179. orion5x_i2c_init();
  180. orion5x_sata_init(&mv2120_sata_data);
  181. orion5x_uart0_init();
  182. orion5x_xor_init();
  183. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  184. ORION_MBUS_DEVBUS_BOOT_ATTR,
  185. MV2120_NOR_BOOT_BASE,
  186. MV2120_NOR_BOOT_SIZE);
  187. platform_device_register(&mv2120_nor_flash);
  188. platform_device_register(&mv2120_button_device);
  189. if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) {
  190. if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0)
  191. mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ);
  192. else
  193. gpio_free(MV2120_GPIO_RTC_IRQ);
  194. }
  195. i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
  196. platform_device_register(&mv2120_leds);
  197. /* register mv2120 specific power-off method */
  198. if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
  199. gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
  200. pr_err("mv2120: failed to setup power-off GPIO\n");
  201. pm_power_off = mv2120_power_off;
  202. }
  203. /* Warning: HP uses a wrong mach-type (=526) in their bootloader */
  204. MACHINE_START(MV2120, "HP Media Vault mv2120")
  205. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  206. .atag_offset = 0x100,
  207. .nr_irqs = ORION5X_NR_IRQS,
  208. .init_machine = mv2120_init,
  209. .map_io = orion5x_map_io,
  210. .init_early = orion5x_init_early,
  211. .init_irq = orion5x_init_irq,
  212. .init_time = orion5x_timer_init,
  213. .fixup = tag_fixup_mem32,
  214. .restart = orion5x_restart,
  215. MACHINE_END