wireless_space.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (C) 2011 Simon Guinot <sguinot@lacie.com>
  3. *
  4. * Based on Kirkwood support:
  5. * (C) Copyright 2009
  6. * Marvell Semiconductor <www.marvell.com>
  7. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. */
  22. #include <common.h>
  23. #include <command.h>
  24. #include <asm/arch/cpu.h>
  25. #include <asm/arch/kirkwood.h>
  26. #include <asm/arch/mpp.h>
  27. #include <asm/arch/gpio.h>
  28. #include "../common/common.h"
  29. #include "netdev.h"
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /* GPIO configuration: start FAN at low speed, USB and HDD */
  32. #define WIRELESS_SPACE_OE_LOW 0xFF006808
  33. #define WIRELESS_SPACE_OE_HIGH 0x0000F989
  34. #define WIRELESS_SPACE_OE_VAL_LOW 0x00010080
  35. #define WIRELESS_SPACE_OE_VAL_HIGH 0x00000240
  36. #define WIRELESS_SPACE_REAR_BUTTON 13
  37. #define WIRELESS_SPACE_FRONT_BUTTON 43
  38. const u32 kwmpp_config[] = {
  39. MPP0_NF_IO2,
  40. MPP1_NF_IO3,
  41. MPP2_NF_IO4,
  42. MPP3_NF_IO5,
  43. MPP4_NF_IO6,
  44. MPP5_NF_IO7,
  45. MPP6_SYSRST_OUTn,
  46. MPP7_GPO, /* Fan speed (bit 1) */
  47. MPP8_TW_SDA,
  48. MPP9_TW_SCK,
  49. MPP10_UART0_TXD,
  50. MPP11_UART0_RXD,
  51. MPP13_GPIO, /* Red led */
  52. MPP14_GPIO, /* USB fuse */
  53. MPP15_SATA0_ACTn,
  54. MPP16_GPIO, /* SATA 0 power */
  55. MPP17_GPIO, /* SATA 1 power */
  56. MPP18_NF_IO0,
  57. MPP19_NF_IO1,
  58. MPP20_GE1_0, /* Gigabit Ethernet 1 */
  59. MPP21_GE1_1,
  60. MPP22_GE1_2,
  61. MPP23_GE1_3,
  62. MPP24_GE1_4,
  63. MPP25_GE1_5,
  64. MPP26_GE1_6,
  65. MPP27_GE1_7,
  66. MPP28_GE1_8,
  67. MPP29_GE1_9,
  68. MPP30_GE1_10,
  69. MPP31_GE1_11,
  70. MPP32_GE1_12,
  71. MPP33_GE1_13,
  72. MPP34_GE1_14,
  73. MPP35_GE1_15,
  74. MPP36_GPIO, /* Fan speed (bit 2) */
  75. MPP37_GPIO, /* Fan speed (bit 0) */
  76. MPP38_GPIO, /* Fan power */
  77. MPP39_GPIO, /* Fan rotation fail */
  78. MPP40_GPIO, /* Ethernet switch link */
  79. MPP41_GPIO, /* USB enable host vbus */
  80. MPP42_GPIO, /* LED clock control */
  81. MPP43_GPIO, /* WPS button (0=Pushed, 1=Released) */
  82. MPP44_GPIO, /* Red LED on/off */
  83. MPP45_GPIO, /* Red LED timer blink (on=off=100ms) */
  84. MPP46_GPIO, /* Green LED on/off */
  85. MPP47_GPIO, /* LED (blue, green) SATA activity blink */
  86. MPP48_GPIO, /* Blue LED on/off */
  87. 0
  88. };
  89. struct mv88e61xx_config swcfg = {
  90. .name = "egiga0",
  91. .vlancfg = MV88E61XX_VLANCFG_ROUTER,
  92. .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
  93. .led_init = MV88E61XX_LED_INIT_EN,
  94. .mdip = MV88E61XX_MDIP_NOCHANGE,
  95. .portstate = MV88E61XX_PORTSTT_FORWARDING,
  96. .cpuport = 0x20,
  97. .ports_enabled = 0x3F,
  98. };
  99. int board_early_init_f(void)
  100. {
  101. /* Gpio configuration */
  102. kw_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
  103. WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
  104. /* Multi-Purpose Pins Functionality configuration */
  105. kirkwood_mpp_conf(kwmpp_config, NULL);
  106. return 0;
  107. }
  108. int board_init(void)
  109. {
  110. /* Machine number */
  111. gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
  112. /* Boot parameters address */
  113. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  114. return 0;
  115. }
  116. #if defined(CONFIG_MISC_INIT_R)
  117. int misc_init_r(void)
  118. {
  119. #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
  120. if (!getenv("ethaddr")) {
  121. uchar mac[6];
  122. if (lacie_read_mac_address(mac) == 0)
  123. eth_setenv_enetaddr("ethaddr", mac);
  124. }
  125. #endif
  126. return 0;
  127. }
  128. #endif
  129. #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
  130. /* Configure and initialize PHY */
  131. void reset_phy(void)
  132. {
  133. /* configure switch on egiga0 */
  134. mv88e61xx_switch_initialize(&swcfg);
  135. }
  136. #endif
  137. #if defined(CONFIG_KIRKWOOD_GPIO) && defined(CONFIG_WIRELESS_SPACE_CMD)
  138. /* Return GPIO button status */
  139. static int
  140. do_ws(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  141. {
  142. if (strcmp(argv[1], "button") == 0) {
  143. if (strcmp(argv[2], "rear") == 0)
  144. /* invert GPIO result for intuitive while/until use */
  145. return !kw_gpio_get_value(WIRELESS_SPACE_REAR_BUTTON);
  146. else if (strcmp(argv[2], "front") == 0)
  147. return kw_gpio_get_value(WIRELESS_SPACE_FRONT_BUTTON);
  148. else
  149. return -1;
  150. } else {
  151. return -1;
  152. }
  153. }
  154. U_BOOT_CMD(ws, 3, 0, do_ws,
  155. "Return GPIO button status 0=off 1=on",
  156. "- ws button rear|front: test buttons' states\n"
  157. );
  158. #endif