1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2013 Suriyan Ramasami <suriyan.r@gmail.com>
5 * Based on dockstar.c originally written by
6 * Copyright (C) 2010 Eric C. Cooper <ecc@cmu.edu>
8 * Based on sheevaplug.c originally written by
9 * Prafulla Wadaskar <prafulla@marvell.com>
11 * Marvell Semiconductor <www.marvell.com>
15 #include <bootstage.h>
19 #include <asm/mach-types.h>
20 #include <asm/arch/soc.h>
21 #include <asm/arch/mpp.h>
22 #include <asm/arch/cpu.h>
25 DECLARE_GLOBAL_DATA_PTR;
27 int board_early_init_f(void)
29 /* Multi-Purpose Pins Functionality configuration */
30 static const u32 kwmpp_config[] = {
85 * default gpio configuration
86 * There are maximum 64 gpios controlled through 2 sets of registers
87 * the below configuration configures mainly initial LED status
89 mvebu_config_gpio(GOFLEXHOME_OE_VAL_LOW,
90 GOFLEXHOME_OE_VAL_HIGH,
91 GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
92 kirkwood_mpp_conf(kwmpp_config, NULL);
99 * arch number of board
101 gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME;
103 /* address of boot parameters */
104 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
109 #ifdef CONFIG_RESET_PHY_R
110 /* Configure and enable MV88E1116 PHY */
115 char *name = "egiga0";
117 if (miiphy_set_current_dev(name))
120 /* command to read PHY dev address */
121 if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) {
122 printf("Err..%s could not read PHY dev address\n",
128 * Enable RGMII delay on Tx and Rx for CPU port
129 * Ref: sec 4.7.2 of chip datasheet
131 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
132 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®);
133 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
134 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
135 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
138 miiphy_reset(name, devadr);
140 printf("88E1116 Initialized on %s\n", name);
142 #endif /* CONFIG_RESET_PHY_R */
144 #define GREEN_LED (1 << 14)
145 #define ORANGE_LED (1 << 15)
146 #define BOTH_LEDS (GREEN_LED | ORANGE_LED)
147 #define NEITHER_LED 0
149 static void set_leds(u32 leds, u32 blinking)
151 struct kwgpio_registers *r;
155 r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
156 oe = readl(&r->oe) | BOTH_LEDS;
157 writel(oe & ~leds, &r->oe); /* active low */
158 bl = readl(&r->blink_en) & ~BOTH_LEDS;
159 writel(bl | blinking, &r->blink_en);
162 void show_boot_progress(int val)
165 case BOOTSTAGE_ID_RUN_OS: /* booting Linux */
166 set_leds(BOTH_LEDS, NEITHER_LED);
168 case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */
169 set_leds(GREEN_LED, GREEN_LED);
172 if (val < 0) /* error */
173 set_leds(ORANGE_LED, ORANGE_LED);