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>
15 #include <asm/mach-types.h>
16 #include <asm/arch/cpu.h>
17 #include <asm/arch/soc.h>
18 #include <asm/arch/mpp.h>
19 #include <asm/arch/gpio.h>
21 #include "net2big_v2.h"
22 #include "../common/common.h"
23 #include "../common/cpld-gpio-bus.h"
25 DECLARE_GLOBAL_DATA_PTR;
27 int board_early_init_f(void)
29 /* GPIO configuration */
30 mvebu_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
31 NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
33 /* Multi-Purpose Pins Functionality configuration */
34 static const u32 kwmpp_config[] = {
40 MPP7_GPO, /* Request power-off */
45 MPP13_GPIO, /* Rear power switch (on|auto) */
46 MPP14_GPIO, /* USB fuse alarm */
47 MPP15_GPIO, /* Rear power switch (auto|off) */
48 MPP16_GPIO, /* SATA HDD1 power */
49 MPP17_GPIO, /* SATA HDD2 power */
52 MPP24_GPIO, /* USB mode select */
53 MPP26_GPIO, /* USB device vbus */
54 MPP28_GPIO, /* USB enable host vbus */
55 MPP29_GPIO, /* CPLD GPIO bus ALE */
56 MPP34_GPIO, /* Rear Push button 0=on 1=off */
57 MPP35_GPIO, /* Inhibit switch power-off */
58 MPP36_GPIO, /* SATA HDD1 presence */
59 MPP37_GPIO, /* SATA HDD2 presence */
60 MPP40_GPIO, /* eSATA presence */
61 MPP44_GPIO, /* CPLD GPIO bus (data 0) */
62 MPP45_GPIO, /* CPLD GPIO bus (data 1) */
63 MPP46_GPIO, /* CPLD GPIO bus (data 2) */
64 MPP47_GPIO, /* CPLD GPIO bus (addr 0) */
65 MPP48_GPIO, /* CPLD GPIO bus (addr 1) */
66 MPP49_GPIO, /* CPLD GPIO bus (addr 2) */
70 kirkwood_mpp_conf(kwmpp_config, NULL);
78 gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2;
80 /* Boot parameters address */
81 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
86 #if defined(CONFIG_MISC_INIT_R)
88 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_G762_ADDR)
90 * Start I2C fan (GMT G762 controller)
92 static void init_fan(void)
98 /* Enable open-loop and PWM modes */
100 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
101 G762_REG_FAN_CMD1, 1, &data, 1) != 0)
104 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
105 G762_REG_SET_CNT, 1, &data, 1) != 0)
108 * RPM to PWM (set_out register) fan speed conversion array:
121 * Start fan at low speed (2800 RPM):
124 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
125 G762_REG_SET_OUT, 1, &data, 1) != 0)
130 printf("Error: failed to start I2C fan @%02x\n",
131 CONFIG_SYS_I2C_G762_ADDR);
134 static void init_fan(void) {}
135 #endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */
137 #if defined(CONFIG_NET2BIG_V2) && defined(CONFIG_KIRKWOOD_GPIO)
141 * - address register : bit [0-2] -> GPIO [47-49]
142 * - data register : bit [0-2] -> GPIO [44-46]
143 * - enable register : GPIO 29
145 static unsigned cpld_gpio_bus_addr[] = { 47, 48, 49 };
146 static unsigned cpld_gpio_bus_data[] = { 44, 45, 46 };
148 static struct cpld_gpio_bus cpld_gpio_bus = {
149 .addr = cpld_gpio_bus_addr,
150 .num_addr = ARRAY_SIZE(cpld_gpio_bus_addr),
151 .data = cpld_gpio_bus_data,
152 .num_data = ARRAY_SIZE(cpld_gpio_bus_data),
157 * LEDs configuration:
159 * The LEDs are controlled by a CPLD and can be configured through
162 * Address register selection:
165 * ----------------------------
167 * 1 | front LED brightness
168 * 2 | SATA LED brightness
175 * Data register configuration:
177 * data | LED brightness
178 * -------------------------------------------------
183 * data | front LED mode
184 * -------------------------------------------------
188 * 3 | blink blue on=1 sec and blue off=1 sec
189 * 4 | blink red on=1 sec and red off=1 sec
190 * 5 | blink blue on=2.5 sec and red on=0.5 sec
191 * 6 | blink blue on=1 sec and red on=1 sec
192 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
194 * data | SATA LED mode
195 * -------------------------------------------------
197 * 1 | SATA activity blink
199 * 3 | blink blue on=1 sec and blue off=1 sec
200 * 4 | blink red on=1 sec and red off=1 sec
201 * 5 | blink blue on=2.5 sec and red on=0.5 sec
202 * 6 | blink blue on=1 sec and red on=1 sec
205 static void init_leds(void)
207 /* Enable the front blue LED */
208 cpld_gpio_bus_write(&cpld_gpio_bus, 0, 1);
209 cpld_gpio_bus_write(&cpld_gpio_bus, 1, 3);
211 /* Configure SATA LEDs to blink in relation with the SATA activity */
212 cpld_gpio_bus_write(&cpld_gpio_bus, 3, 1);
213 cpld_gpio_bus_write(&cpld_gpio_bus, 4, 1);
214 cpld_gpio_bus_write(&cpld_gpio_bus, 2, 3);
217 static void init_leds(void) {}
218 #endif /* CONFIG_NET2BIG_V2 && CONFIG_KIRKWOOD_GPIO */
220 int misc_init_r(void)
223 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
224 if (!env_get("ethaddr")) {
226 if (lacie_read_mac_address(mac) == 0)
227 eth_env_set_enetaddr("ethaddr", mac);
234 #endif /* CONFIG_MISC_INIT_R */
236 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
237 /* Configure and initialize PHY */
240 mv_phy_88e1116_init("egiga0", 8);
244 #if defined(CONFIG_KIRKWOOD_GPIO)
245 /* Return GPIO push button status */
247 do_read_push_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
249 return !kw_gpio_get_value(NET2BIG_V2_GPIO_PUSH_BUTTON);
252 U_BOOT_CMD(button, 1, 1, do_read_push_button,
253 "Return GPIO push button status 0=off 1=on", "");