1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2011 Simon Guinot <sguinot@lacie.com>
5 * Based on Kirkwood support:
7 * Marvell Semiconductor <www.marvell.com>
8 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
17 #include <asm/global_data.h>
18 #include <asm/mach-types.h>
19 #include <asm/arch/cpu.h>
20 #include <asm/arch/soc.h>
21 #include <asm/arch/mpp.h>
22 #include <asm/arch/gpio.h>
24 #include "net2big_v2.h"
25 #include "../common/common.h"
26 #include "../common/cpld-gpio-bus.h"
28 DECLARE_GLOBAL_DATA_PTR;
30 int board_early_init_f(void)
32 /* GPIO configuration */
33 mvebu_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
34 NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
36 /* Multi-Purpose Pins Functionality configuration */
37 static const u32 kwmpp_config[] = {
43 MPP7_GPO, /* Request power-off */
48 MPP13_GPIO, /* Rear power switch (on|auto) */
49 MPP14_GPIO, /* USB fuse alarm */
50 MPP15_GPIO, /* Rear power switch (auto|off) */
51 MPP16_GPIO, /* SATA HDD1 power */
52 MPP17_GPIO, /* SATA HDD2 power */
55 MPP24_GPIO, /* USB mode select */
56 MPP26_GPIO, /* USB device vbus */
57 MPP28_GPIO, /* USB enable host vbus */
58 MPP29_GPIO, /* CPLD GPIO bus ALE */
59 MPP34_GPIO, /* Rear Push button 0=on 1=off */
60 MPP35_GPIO, /* Inhibit switch power-off */
61 MPP36_GPIO, /* SATA HDD1 presence */
62 MPP37_GPIO, /* SATA HDD2 presence */
63 MPP40_GPIO, /* eSATA presence */
64 MPP44_GPIO, /* CPLD GPIO bus (data 0) */
65 MPP45_GPIO, /* CPLD GPIO bus (data 1) */
66 MPP46_GPIO, /* CPLD GPIO bus (data 2) */
67 MPP47_GPIO, /* CPLD GPIO bus (addr 0) */
68 MPP48_GPIO, /* CPLD GPIO bus (addr 1) */
69 MPP49_GPIO, /* CPLD GPIO bus (addr 2) */
73 kirkwood_mpp_conf(kwmpp_config, NULL);
81 gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2;
83 /* Boot parameters address */
84 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
89 #if defined(CONFIG_MISC_INIT_R)
91 #if defined(CONFIG_CMD_I2C) && defined(CFG_SYS_I2C_G762_ADDR)
93 * Start I2C fan (GMT G762 controller)
95 static void init_fan(void)
101 /* Enable open-loop and PWM modes */
103 if (i2c_write(CFG_SYS_I2C_G762_ADDR,
104 G762_REG_FAN_CMD1, 1, &data, 1) != 0)
107 if (i2c_write(CFG_SYS_I2C_G762_ADDR,
108 G762_REG_SET_CNT, 1, &data, 1) != 0)
111 * RPM to PWM (set_out register) fan speed conversion array:
124 * Start fan at low speed (2800 RPM):
127 if (i2c_write(CFG_SYS_I2C_G762_ADDR,
128 G762_REG_SET_OUT, 1, &data, 1) != 0)
133 printf("Error: failed to start I2C fan @%02x\n",
134 CFG_SYS_I2C_G762_ADDR);
137 static void init_fan(void) {}
138 #endif /* CONFIG_CMD_I2C && CFG_SYS_I2C_G762_ADDR */
140 #if defined(CONFIG_NET2BIG_V2) && defined(CONFIG_KIRKWOOD_GPIO)
144 * - address register : bit [0-2] -> GPIO [47-49]
145 * - data register : bit [0-2] -> GPIO [44-46]
146 * - enable register : GPIO 29
148 static unsigned cpld_gpio_bus_addr[] = { 47, 48, 49 };
149 static unsigned cpld_gpio_bus_data[] = { 44, 45, 46 };
151 static struct cpld_gpio_bus cpld_gpio_bus = {
152 .addr = cpld_gpio_bus_addr,
153 .num_addr = ARRAY_SIZE(cpld_gpio_bus_addr),
154 .data = cpld_gpio_bus_data,
155 .num_data = ARRAY_SIZE(cpld_gpio_bus_data),
160 * LEDs configuration:
162 * The LEDs are controlled by a CPLD and can be configured through
165 * Address register selection:
168 * ----------------------------
170 * 1 | front LED brightness
171 * 2 | SATA LED brightness
178 * Data register configuration:
180 * data | LED brightness
181 * -------------------------------------------------
186 * data | front LED mode
187 * -------------------------------------------------
191 * 3 | blink blue on=1 sec and blue off=1 sec
192 * 4 | blink red on=1 sec and red off=1 sec
193 * 5 | blink blue on=2.5 sec and red on=0.5 sec
194 * 6 | blink blue on=1 sec and red on=1 sec
195 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
197 * data | SATA LED mode
198 * -------------------------------------------------
200 * 1 | SATA activity blink
202 * 3 | blink blue on=1 sec and blue off=1 sec
203 * 4 | blink red on=1 sec and red off=1 sec
204 * 5 | blink blue on=2.5 sec and red on=0.5 sec
205 * 6 | blink blue on=1 sec and red on=1 sec
208 static void init_leds(void)
210 /* Enable the front blue LED */
211 cpld_gpio_bus_write(&cpld_gpio_bus, 0, 1);
212 cpld_gpio_bus_write(&cpld_gpio_bus, 1, 3);
214 /* Configure SATA LEDs to blink in relation with the SATA activity */
215 cpld_gpio_bus_write(&cpld_gpio_bus, 3, 1);
216 cpld_gpio_bus_write(&cpld_gpio_bus, 4, 1);
217 cpld_gpio_bus_write(&cpld_gpio_bus, 2, 3);
220 static void init_leds(void) {}
221 #endif /* CONFIG_NET2BIG_V2 && CONFIG_KIRKWOOD_GPIO */
223 int misc_init_r(void)
226 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
227 if (!env_get("ethaddr")) {
229 if (lacie_read_mac_address(mac) == 0)
230 eth_env_set_enetaddr("ethaddr", mac);
237 #endif /* CONFIG_MISC_INIT_R */
239 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
240 /* Configure and initialize PHY */
243 mv_phy_88e1116_init("ethernet-controller@72000", 8);
247 #if defined(CONFIG_KIRKWOOD_GPIO)
248 /* Return GPIO push button status */
250 do_read_push_button(struct cmd_tbl *cmdtp, int flag, int argc,
253 return !kw_gpio_get_value(NET2BIG_V2_GPIO_PUSH_BUTTON);
256 U_BOOT_CMD(button, 1, 1, do_read_push_button,
257 "Return GPIO push button status 0=off 1=on", "");