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+
15 #include <asm/arch/cpu.h>
16 #include <asm/arch/kirkwood.h>
17 #include <asm/arch/mpp.h>
18 #include <asm/arch/gpio.h>
20 #include "net2big_v2.h"
21 #include "../common/common.h"
22 #include "../common/cpld-gpio-bus.h"
24 DECLARE_GLOBAL_DATA_PTR
;
26 int board_early_init_f(void)
28 /* GPIO configuration */
29 kw_config_gpio(NET2BIG_V2_OE_VAL_LOW
, NET2BIG_V2_OE_VAL_HIGH
,
30 NET2BIG_V2_OE_LOW
, NET2BIG_V2_OE_HIGH
);
32 /* Multi-Purpose Pins Functionality configuration */
33 static const u32 kwmpp_config
[] = {
39 MPP7_GPO
, /* Request power-off */
44 MPP13_GPIO
, /* Rear power switch (on|auto) */
45 MPP14_GPIO
, /* USB fuse alarm */
46 MPP15_GPIO
, /* Rear power switch (auto|off) */
47 MPP16_GPIO
, /* SATA HDD1 power */
48 MPP17_GPIO
, /* SATA HDD2 power */
51 MPP24_GPIO
, /* USB mode select */
52 MPP26_GPIO
, /* USB device vbus */
53 MPP28_GPIO
, /* USB enable host vbus */
54 MPP29_GPIO
, /* CPLD GPIO bus ALE */
55 MPP34_GPIO
, /* Rear Push button 0=on 1=off */
56 MPP35_GPIO
, /* Inhibit switch power-off */
57 MPP36_GPIO
, /* SATA HDD1 presence */
58 MPP37_GPIO
, /* SATA HDD2 presence */
59 MPP40_GPIO
, /* eSATA presence */
60 MPP44_GPIO
, /* CPLD GPIO bus (data 0) */
61 MPP45_GPIO
, /* CPLD GPIO bus (data 1) */
62 MPP46_GPIO
, /* CPLD GPIO bus (data 2) */
63 MPP47_GPIO
, /* CPLD GPIO bus (addr 0) */
64 MPP48_GPIO
, /* CPLD GPIO bus (addr 1) */
65 MPP49_GPIO
, /* CPLD GPIO bus (addr 2) */
69 kirkwood_mpp_conf(kwmpp_config
, NULL
);
77 gd
->bd
->bi_arch_number
= MACH_TYPE_NET2BIG_V2
;
79 /* Boot parameters address */
80 gd
->bd
->bi_boot_params
= kw_sdram_bar(0) + 0x100;
85 #if defined(CONFIG_MISC_INIT_R)
87 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_G762_ADDR)
89 * Start I2C fan (GMT G762 controller)
91 static void init_fan(void)
97 /* Enable open-loop and PWM modes */
99 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR
,
100 G762_REG_FAN_CMD1
, 1, &data
, 1) != 0)
103 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR
,
104 G762_REG_SET_CNT
, 1, &data
, 1) != 0)
107 * RPM to PWM (set_out register) fan speed conversion array:
120 * Start fan at low speed (2800 RPM):
123 if (i2c_write(CONFIG_SYS_I2C_G762_ADDR
,
124 G762_REG_SET_OUT
, 1, &data
, 1) != 0)
129 printf("Error: failed to start I2C fan @%02x\n",
130 CONFIG_SYS_I2C_G762_ADDR
);
133 static void init_fan(void) {}
134 #endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */
136 #if defined(CONFIG_NET2BIG_V2) && defined(CONFIG_KIRKWOOD_GPIO)
140 * - address register : bit [0-2] -> GPIO [47-49]
141 * - data register : bit [0-2] -> GPIO [44-46]
142 * - enable register : GPIO 29
144 static unsigned cpld_gpio_bus_addr
[] = { 47, 48, 49 };
145 static unsigned cpld_gpio_bus_data
[] = { 44, 45, 46 };
147 static struct cpld_gpio_bus cpld_gpio_bus
= {
148 .addr
= cpld_gpio_bus_addr
,
149 .num_addr
= ARRAY_SIZE(cpld_gpio_bus_addr
),
150 .data
= cpld_gpio_bus_data
,
151 .num_data
= ARRAY_SIZE(cpld_gpio_bus_data
),
156 * LEDs configuration:
158 * The LEDs are controlled by a CPLD and can be configured through
161 * Address register selection:
164 * ----------------------------
166 * 1 | front LED brightness
167 * 2 | SATA LED brightness
174 * Data register configuration:
176 * data | LED brightness
177 * -------------------------------------------------
182 * data | front LED mode
183 * -------------------------------------------------
187 * 3 | blink blue on=1 sec and blue off=1 sec
188 * 4 | blink red on=1 sec and red off=1 sec
189 * 5 | blink blue on=2.5 sec and red on=0.5 sec
190 * 6 | blink blue on=1 sec and red on=1 sec
191 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
193 * data | SATA LED mode
194 * -------------------------------------------------
196 * 1 | SATA activity blink
198 * 3 | blink blue on=1 sec and blue off=1 sec
199 * 4 | blink red on=1 sec and red off=1 sec
200 * 5 | blink blue on=2.5 sec and red on=0.5 sec
201 * 6 | blink blue on=1 sec and red on=1 sec
204 static void init_leds(void)
206 /* Enable the front blue LED */
207 cpld_gpio_bus_write(&cpld_gpio_bus
, 0, 1);
208 cpld_gpio_bus_write(&cpld_gpio_bus
, 1, 3);
210 /* Configure SATA LEDs to blink in relation with the SATA activity */
211 cpld_gpio_bus_write(&cpld_gpio_bus
, 3, 1);
212 cpld_gpio_bus_write(&cpld_gpio_bus
, 4, 1);
213 cpld_gpio_bus_write(&cpld_gpio_bus
, 2, 3);
216 static void init_leds(void) {}
217 #endif /* CONFIG_NET2BIG_V2 && CONFIG_KIRKWOOD_GPIO */
219 int misc_init_r(void)
222 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
223 if (!getenv("ethaddr")) {
225 if (lacie_read_mac_address(mac
) == 0)
226 eth_setenv_enetaddr("ethaddr", mac
);
233 #endif /* CONFIG_MISC_INIT_R */
235 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
236 /* Configure and initialize PHY */
239 mv_phy_88e1116_init("egiga0", 8);
243 #if defined(CONFIG_KIRKWOOD_GPIO)
244 /* Return GPIO push button status */
246 do_read_push_button(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
248 return !kw_gpio_get_value(NET2BIG_V2_GPIO_PUSH_BUTTON
);
251 U_BOOT_CMD(button
, 1, 1, do_read_push_button
,
252 "Return GPIO push button status 0=off 1=on", "");