2 * Copyright (C) 2011 Simon Guinot <sguinot@lacie.com>
4 * Based on Kirkwood support:
6 * Marvell Semiconductor <www.marvell.com>
7 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
9 * See file CREDITS for list of people who contributed to this
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.
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.
25 #include <asm/arch/cpu.h>
26 #include <asm/arch/kirkwood.h>
27 #include <asm/arch/mpp.h>
28 #include <asm/arch/gpio.h>
30 #include "../common/common.h"
33 DECLARE_GLOBAL_DATA_PTR;
35 /* GPIO configuration: start FAN at low speed, USB and HDD */
37 #define WIRELESS_SPACE_OE_LOW 0xFF006808
38 #define WIRELESS_SPACE_OE_HIGH 0x0000F989
39 #define WIRELESS_SPACE_OE_VAL_LOW 0x00010080
40 #define WIRELESS_SPACE_OE_VAL_HIGH 0x00000240
42 #define WIRELESS_SPACE_REAR_BUTTON 13
43 #define WIRELESS_SPACE_FRONT_BUTTON 43
45 const u32 kwmpp_config[] = {
53 MPP7_GPO, /* Fan speed (bit 1) */
58 MPP13_GPIO, /* Red led */
59 MPP14_GPIO, /* USB fuse */
61 MPP16_GPIO, /* SATA 0 power */
62 MPP17_GPIO, /* SATA 1 power */
65 MPP20_GE1_0, /* Gigabit Ethernet 1 */
81 MPP36_GPIO, /* Fan speed (bit 2) */
82 MPP37_GPIO, /* Fan speed (bit 0) */
83 MPP38_GPIO, /* Fan power */
84 MPP39_GPIO, /* Fan rotation fail */
85 MPP40_GPIO, /* Ethernet switch link */
86 MPP41_GPIO, /* USB enable host vbus */
87 MPP42_GPIO, /* LED clock control */
88 MPP43_GPIO, /* WPS button (0=Pushed, 1=Released) */
89 MPP44_GPIO, /* Red LED on/off */
90 MPP45_GPIO, /* Red LED timer blink (on=off=100ms) */
91 MPP46_GPIO, /* Green LED on/off */
92 MPP47_GPIO, /* LED (blue, green) SATA activity blink */
93 MPP48_GPIO, /* Blue LED on/off */
97 struct mv88e61xx_config swcfg = {
99 .vlancfg = MV88E61XX_VLANCFG_ROUTER,
100 .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
101 .led_init = MV88E61XX_LED_INIT_EN,
102 .mdip = MV88E61XX_MDIP_NOCHANGE,
103 .portstate = MV88E61XX_PORTSTT_FORWARDING,
105 .ports_enabled = 0x3F,
108 int board_early_init_f(void)
110 /* Gpio configuration */
111 kw_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
112 WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
114 /* Multi-Purpose Pins Functionality configuration */
115 kirkwood_mpp_conf(kwmpp_config, NULL);
123 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
125 /* Boot parameters address */
126 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
131 #if defined(CONFIG_MISC_INIT_R)
132 int misc_init_r(void)
134 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
135 if (!getenv("ethaddr")) {
137 if (lacie_read_mac_address(mac) == 0)
138 eth_setenv_enetaddr("ethaddr", mac);
145 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
146 /* Configure and initialize PHY */
149 /* configure switch on egiga0 */
150 mv88e61xx_switch_initialize(&swcfg);
154 #if defined(CONFIG_KIRKWOOD_GPIO) && defined(CONFIG_WIRELESS_SPACE_CMD)
155 /* Return GPIO button status */
157 do_ws(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
159 if (strcmp(argv[1], "button") == 0) {
160 if (strcmp(argv[2], "rear") == 0)
161 /* invert GPIO result for intuitive while/until use */
162 return !kw_gpio_get_value(WIRELESS_SPACE_REAR_BUTTON);
163 else if (strcmp(argv[2], "front") == 0)
164 return kw_gpio_get_value(WIRELESS_SPACE_FRONT_BUTTON);
172 U_BOOT_CMD(ws, 3, 0, do_ws,
173 "Return GPIO button status 0=off 1=on",
174 "- ws button rear|front: test buttons' states\n"