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/mach-types.h>
18 #include <asm/arch/cpu.h>
19 #include <asm/arch/soc.h>
20 #include <asm/arch/mpp.h>
21 #include <asm/arch/gpio.h>
23 #include "net2big_v2.h"
24 #include "../common/common.h"
25 #include "../common/cpld-gpio-bus.h"
27 DECLARE_GLOBAL_DATA_PTR;
29 int board_early_init_f(void)
31 /* GPIO configuration */
32 mvebu_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
33 NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
35 /* Multi-Purpose Pins Functionality configuration */
36 static const u32 kwmpp_config[] = {
42 MPP7_GPO, /* Request power-off */
47 MPP13_GPIO, /* Rear power switch (on|auto) */
48 MPP14_GPIO, /* USB fuse alarm */
49 MPP15_GPIO, /* Rear power switch (auto|off) */
50 MPP16_GPIO, /* SATA HDD1 power */
51 MPP17_GPIO, /* SATA HDD2 power */
54 MPP24_GPIO, /* USB mode select */
55 MPP26_GPIO, /* USB device vbus */
56 MPP28_GPIO, /* USB enable host vbus */
57 MPP29_GPIO, /* CPLD GPIO bus ALE */
58 MPP34_GPIO, /* Rear Push button 0=on 1=off */
59 MPP35_GPIO, /* Inhibit switch power-off */
60 MPP36_GPIO, /* SATA HDD1 presence */
61 MPP37_GPIO, /* SATA HDD2 presence */
62 MPP40_GPIO, /* eSATA presence */
63 MPP44_GPIO, /* CPLD GPIO bus (data 0) */
64 MPP45_GPIO, /* CPLD GPIO bus (data 1) */
65 MPP46_GPIO, /* CPLD GPIO bus (data 2) */
66 MPP47_GPIO, /* CPLD GPIO bus (addr 0) */
67 MPP48_GPIO, /* CPLD GPIO bus (addr 1) */
68 MPP49_GPIO, /* CPLD GPIO bus (addr 2) */
72 kirkwood_mpp_conf(kwmpp_config, NULL);
80 gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2;
82 /* Boot parameters address */
83 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
88 #if defined(CONFIG_MISC_INIT_R)
90 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_G762_ADDR)
92 * Start I2C fan (GMT G762 controller)
94 static void init_fan(void)
100 /* Enable open-loop and PWM modes */
102 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
103 G762_REG_FAN_CMD1, 1, &data, 1) != 0)
106 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
107 G762_REG_SET_CNT, 1, &data, 1) != 0)
110 * RPM to PWM (set_out register) fan speed conversion array:
123 * Start fan at low speed (2800 RPM):
126 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
127 G762_REG_SET_OUT, 1, &data, 1) != 0)
132 printf("Error: failed to start I2C fan @%02x\n",
133 CONFIG_SYS_I2C_G762_ADDR);
136 static void init_fan(void) {}
137 #endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */
139 #if defined(CONFIG_NET2BIG_V2) && defined(CONFIG_KIRKWOOD_GPIO)
143 * - address register : bit [0-2] -> GPIO [47-49]
144 * - data register : bit [0-2] -> GPIO [44-46]
145 * - enable register : GPIO 29
147 static unsigned cpld_gpio_bus_addr[] = { 47, 48, 49 };
148 static unsigned cpld_gpio_bus_data[] = { 44, 45, 46 };
150 static struct cpld_gpio_bus cpld_gpio_bus = {
151 .addr = cpld_gpio_bus_addr,
152 .num_addr = ARRAY_SIZE(cpld_gpio_bus_addr),
153 .data = cpld_gpio_bus_data,
154 .num_data = ARRAY_SIZE(cpld_gpio_bus_data),
159 * LEDs configuration:
161 * The LEDs are controlled by a CPLD and can be configured through
164 * Address register selection:
167 * ----------------------------
169 * 1 | front LED brightness
170 * 2 | SATA LED brightness
177 * Data register configuration:
179 * data | LED brightness
180 * -------------------------------------------------
185 * data | front LED mode
186 * -------------------------------------------------
190 * 3 | blink blue on=1 sec and blue off=1 sec
191 * 4 | blink red on=1 sec and red off=1 sec
192 * 5 | blink blue on=2.5 sec and red on=0.5 sec
193 * 6 | blink blue on=1 sec and red on=1 sec
194 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
196 * data | SATA LED mode
197 * -------------------------------------------------
199 * 1 | SATA activity blink
201 * 3 | blink blue on=1 sec and blue off=1 sec
202 * 4 | blink red on=1 sec and red off=1 sec
203 * 5 | blink blue on=2.5 sec and red on=0.5 sec
204 * 6 | blink blue on=1 sec and red on=1 sec
207 static void init_leds(void)
209 /* Enable the front blue LED */
210 cpld_gpio_bus_write(&cpld_gpio_bus, 0, 1);
211 cpld_gpio_bus_write(&cpld_gpio_bus, 1, 3);
213 /* Configure SATA LEDs to blink in relation with the SATA activity */
214 cpld_gpio_bus_write(&cpld_gpio_bus, 3, 1);
215 cpld_gpio_bus_write(&cpld_gpio_bus, 4, 1);
216 cpld_gpio_bus_write(&cpld_gpio_bus, 2, 3);
219 static void init_leds(void) {}
220 #endif /* CONFIG_NET2BIG_V2 && CONFIG_KIRKWOOD_GPIO */
222 int misc_init_r(void)
225 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
226 if (!env_get("ethaddr")) {
228 if (lacie_read_mac_address(mac) == 0)
229 eth_env_set_enetaddr("ethaddr", mac);
236 #endif /* CONFIG_MISC_INIT_R */
238 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
239 /* Configure and initialize PHY */
242 mv_phy_88e1116_init("ethernet-controller@72000", 8);
246 #if defined(CONFIG_KIRKWOOD_GPIO)
247 /* Return GPIO push button status */
249 do_read_push_button(struct cmd_tbl *cmdtp, int flag, int argc,
252 return !kw_gpio_get_value(NET2BIG_V2_GPIO_PUSH_BUTTON);
255 U_BOOT_CMD(button, 1, 1, do_read_push_button,
256 "Return GPIO push button status 0=off 1=on", "");