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 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
28 #include <asm/arch/cpu.h>
29 #include <asm/arch/kirkwood.h>
30 #include <asm/arch/mpp.h>
31 #include <asm/arch/gpio.h>
32 #include "netspace_v2.h"
34 DECLARE_GLOBAL_DATA_PTR;
36 int board_early_init_f(void)
38 /* Gpio configuration */
39 kw_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
40 NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
42 /* Multi-Purpose Pins Functionality configuration */
43 u32 kwmpp_config[] = {
51 MPP7_GPO, /* Fan speed (bit 1) */
56 MPP12_GPO, /* Red led */
57 MPP14_GPIO, /* USB fuse */
58 MPP16_GPIO, /* SATA 0 power */
59 MPP17_GPIO, /* SATA 1 power */
64 MPP22_GPIO, /* Fan speed (bit 0) */
65 MPP23_GPIO, /* Fan power */
66 MPP24_GPIO, /* USB mode select */
67 MPP25_GPIO, /* Fan rotation fail */
68 MPP26_GPIO, /* USB vbus-in detection */
69 MPP28_GPIO, /* USB enable vbus-out */
70 MPP29_GPIO, /* Blue led (slow register) */
71 MPP30_GPIO, /* Blue led (command register) */
72 MPP31_GPIO, /* Board power off */
73 MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */
74 MPP33_GPIO, /* Fan speed (bit 2) */
77 kirkwood_mpp_conf(kwmpp_config);
85 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
87 /* Boot parameters address */
88 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
95 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
96 if (!getenv("ethaddr")) {
101 /* I2C-0 for on-board EEPROM */
104 /* Check layout version for EEPROM data */
105 ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,
106 CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
107 (uchar *) &version, 2);
109 printf("Error: failed to read I2C EEPROM @%02x\n",
110 CONFIG_SYS_I2C_EEPROM_ADDR);
113 version = be16_to_cpu(version);
114 if (version < 1 || version > 3) {
115 printf("Error: unknown version %d for EEPROM data\n",
120 /* Read Ethernet MAC address from EEPROM */
121 ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 2,
122 CONFIG_SYS_I2C_EEPROM_ADDR_LEN, mac, 6);
124 printf("Error: failed to read I2C EEPROM @%02x\n",
125 CONFIG_SYS_I2C_EEPROM_ADDR);
128 eth_setenv_enetaddr("ethaddr", mac);
130 #endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_EEPROM_ADDR */
135 void mv_phy_88e1116_init(char *name)
140 if (miiphy_set_current_dev(name))
143 /* command to read PHY dev address */
144 if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
145 printf("Err..(%s) could not read PHY dev address\n", __func__);
150 * Enable RGMII delay on Tx and Rx for CPU port
151 * Ref: sec 4.7.2 of chip datasheet
153 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
154 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®);
155 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
156 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
157 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
160 if (miiphy_read(name, devadr, MII_BMCR, ®) != 0) {
161 printf("Err..(%s) PHY status read failed\n", __func__);
164 if (miiphy_write(name, devadr, MII_BMCR, reg | 0x8000) != 0) {
165 printf("Err..(%s) PHY reset failed\n", __func__);
169 debug("88E1116 Initialized on %s\n", name);
172 /* Configure and initialize PHY */
175 mv_phy_88e1116_init("egiga0");
178 /* Return GPIO button status */
180 do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
182 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
185 U_BOOT_CMD(button, 1, 1, do_read_button,
186 "Return GPIO button status 0=off 1=on", "");