mv2120-setup.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/irq.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/leds.h>
  17. #include <linux/gpio_keys.h>
  18. #include <linux/input.h>
  19. #include <linux/i2c.h>
  20. #include <linux/ata_platform.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/gpio.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/arch/orion5x.h>
  25. #include "common.h"
  26. #include "mpp.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 = 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 struct orion5x_mpp_mode mv2120_mpp_modes[] __initdata = {
  97. { 0, MPP_GPIO }, /* Sys status LED */
  98. { 1, MPP_GPIO }, /* Sys error LED */
  99. { 2, MPP_GPIO }, /* OverTemp interrupt */
  100. { 3, MPP_GPIO }, /* RTC interrupt */
  101. { 4, MPP_GPIO }, /* V_LED 5V */
  102. { 5, MPP_GPIO }, /* V_LED 3.3V */
  103. { 6, MPP_UNUSED },
  104. { 7, MPP_UNUSED },
  105. { 8, MPP_GPIO }, /* SATA 0 fail LED */
  106. { 9, MPP_GPIO }, /* SATA 1 fail LED */
  107. { 10, MPP_UNUSED },
  108. { 11, MPP_UNUSED },
  109. { 12, MPP_SATA_LED }, /* SATA 0 presence */
  110. { 13, MPP_SATA_LED }, /* SATA 1 presence */
  111. { 14, MPP_SATA_LED }, /* SATA 0 active */
  112. { 15, MPP_SATA_LED }, /* SATA 1 active */
  113. { 16, MPP_UNUSED },
  114. { 17, MPP_GPIO }, /* Reset button */
  115. { 18, MPP_GPIO }, /* Power button */
  116. { 19, MPP_GPIO }, /* Power off */
  117. { -1 },
  118. };
  119. static struct i2c_board_info __initdata mv2120_i2c_rtc = {
  120. I2C_BOARD_INFO("pcf8563", 0x51),
  121. .irq = 0,
  122. };
  123. static void mv2120_power_off(void)
  124. {
  125. pr_info("%s: triggering power-off...\n", __func__);
  126. gpio_set_value(MV2120_GPIO_POWER_OFF, 0);
  127. }
  128. static void __init mv2120_init(void)
  129. {
  130. /* Setup basic Orion functions. Need to be called early. */
  131. orion5x_init();
  132. orion5x_mpp_conf(mv2120_mpp_modes);
  133. /*
  134. * Configure peripherals.
  135. */
  136. orion5x_ehci0_init();
  137. orion5x_ehci1_init();
  138. orion5x_eth_init(&mv2120_eth_data);
  139. orion5x_i2c_init();
  140. orion5x_sata_init(&mv2120_sata_data);
  141. orion5x_uart0_init();
  142. orion5x_setup_dev_boot_win(MV2120_NOR_BOOT_BASE, MV2120_NOR_BOOT_SIZE);
  143. platform_device_register(&mv2120_nor_flash);
  144. platform_device_register(&mv2120_button_device);
  145. if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) {
  146. if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0)
  147. mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ);
  148. else
  149. gpio_free(MV2120_GPIO_RTC_IRQ);
  150. }
  151. i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
  152. /* register mv2120 specific power-off method */
  153. if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
  154. gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
  155. pr_err("mv2120: failed to setup power-off GPIO\n");
  156. pm_power_off = mv2120_power_off;
  157. }
  158. /* Warning: HP uses a wrong mach-type (=526) in their bootloader */
  159. MACHINE_START(MV2120, "HP Media Vault mv2120")
  160. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  161. .phys_io = ORION5X_REGS_PHYS_BASE,
  162. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  163. .boot_params = 0x00000100,
  164. .init_machine = mv2120_init,
  165. .map_io = orion5x_map_io,
  166. .init_irq = orion5x_init_irq,
  167. .timer = &orion5x_timer,
  168. .fixup = tag_fixup_mem32
  169. MACHINE_END