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 * SPDX-License-Identifier: GPL-2.0+
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/kirkwood.h>
16 #include <asm/arch/mpp.h>
17 #include <asm/arch/gpio.h>
19 #include "../common/common.h"
22 DECLARE_GLOBAL_DATA_PTR
;
24 /* GPIO configuration: start FAN at low speed, USB and HDD */
26 #define WIRELESS_SPACE_OE_LOW 0xFF006808
27 #define WIRELESS_SPACE_OE_HIGH 0x0000F989
28 #define WIRELESS_SPACE_OE_VAL_LOW 0x00010080
29 #define WIRELESS_SPACE_OE_VAL_HIGH 0x00000240
31 #define WIRELESS_SPACE_REAR_BUTTON 13
32 #define WIRELESS_SPACE_FRONT_BUTTON 43
34 const u32 kwmpp_config
[] = {
42 MPP7_GPO
, /* Fan speed (bit 1) */
47 MPP13_GPIO
, /* Red led */
48 MPP14_GPIO
, /* USB fuse */
50 MPP16_GPIO
, /* SATA 0 power */
51 MPP17_GPIO
, /* SATA 1 power */
54 MPP20_GE1_0
, /* Gigabit Ethernet 1 */
70 MPP36_GPIO
, /* Fan speed (bit 2) */
71 MPP37_GPIO
, /* Fan speed (bit 0) */
72 MPP38_GPIO
, /* Fan power */
73 MPP39_GPIO
, /* Fan rotation fail */
74 MPP40_GPIO
, /* Ethernet switch link */
75 MPP41_GPIO
, /* USB enable host vbus */
76 MPP42_GPIO
, /* LED clock control */
77 MPP43_GPIO
, /* WPS button (0=Pushed, 1=Released) */
78 MPP44_GPIO
, /* Red LED on/off */
79 MPP45_GPIO
, /* Red LED timer blink (on=off=100ms) */
80 MPP46_GPIO
, /* Green LED on/off */
81 MPP47_GPIO
, /* LED (blue, green) SATA activity blink */
82 MPP48_GPIO
, /* Blue LED on/off */
86 struct mv88e61xx_config swcfg
= {
88 .vlancfg
= MV88E61XX_VLANCFG_ROUTER
,
89 .rgmii_delay
= MV88E61XX_RGMII_DELAY_EN
,
90 .led_init
= MV88E61XX_LED_INIT_EN
,
91 .mdip
= MV88E61XX_MDIP_NOCHANGE
,
92 .portstate
= MV88E61XX_PORTSTT_FORWARDING
,
94 .ports_enabled
= 0x3F,
97 int board_early_init_f(void)
99 /* Gpio configuration */
100 kw_config_gpio(WIRELESS_SPACE_OE_VAL_LOW
, WIRELESS_SPACE_OE_VAL_HIGH
,
101 WIRELESS_SPACE_OE_LOW
, WIRELESS_SPACE_OE_HIGH
);
103 /* Multi-Purpose Pins Functionality configuration */
104 kirkwood_mpp_conf(kwmpp_config
, NULL
);
112 gd
->bd
->bi_arch_number
= CONFIG_MACH_TYPE
;
114 /* Boot parameters address */
115 gd
->bd
->bi_boot_params
= kw_sdram_bar(0) + 0x100;
120 #if defined(CONFIG_MISC_INIT_R)
121 int misc_init_r(void)
123 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
124 if (!getenv("ethaddr")) {
126 if (lacie_read_mac_address(mac
) == 0)
127 eth_setenv_enetaddr("ethaddr", mac
);
134 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
135 /* Configure and initialize PHY */
138 /* configure switch on egiga0 */
139 mv88e61xx_switch_initialize(&swcfg
);
143 #if defined(CONFIG_KIRKWOOD_GPIO) && defined(CONFIG_WIRELESS_SPACE_CMD)
144 /* Return GPIO button status */
146 do_ws(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
148 if (strcmp(argv
[1], "button") == 0) {
149 if (strcmp(argv
[2], "rear") == 0)
150 /* invert GPIO result for intuitive while/until use */
151 return !kw_gpio_get_value(WIRELESS_SPACE_REAR_BUTTON
);
152 else if (strcmp(argv
[2], "front") == 0)
153 return kw_gpio_get_value(WIRELESS_SPACE_FRONT_BUTTON
);
161 U_BOOT_CMD(ws
, 3, 0, do_ws
,
162 "Return GPIO button status 0=off 1=on",
163 "- ws button rear|front: test buttons' states\n"