2 * Copyright (C) 2013 Suriyan Ramasami <suriyan.r@gmail.com>
4 * Based on dockstar.c originally written by
5 * Copyright (C) 2010 Eric C. Cooper <ecc@cmu.edu>
7 * Based on sheevaplug.c originally written by
8 * Prafulla Wadaskar <prafulla@marvell.com>
10 * Marvell Semiconductor <www.marvell.com>
12 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/mach-types.h>
18 #include <asm/arch/soc.h>
19 #include <asm/arch/mpp.h>
20 #include <asm/arch/cpu.h>
23 DECLARE_GLOBAL_DATA_PTR;
25 int board_early_init_f(void)
27 /* Multi-Purpose Pins Functionality configuration */
28 static const u32 kwmpp_config[] = {
83 * default gpio configuration
84 * There are maximum 64 gpios controlled through 2 sets of registers
85 * the below configuration configures mainly initial LED status
87 mvebu_config_gpio(GOFLEXHOME_OE_VAL_LOW,
88 GOFLEXHOME_OE_VAL_HIGH,
89 GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
90 kirkwood_mpp_conf(kwmpp_config, NULL);
97 * arch number of board
99 gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME;
101 /* address of boot parameters */
102 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
107 #ifdef CONFIG_RESET_PHY_R
108 /* Configure and enable MV88E1116 PHY */
113 char *name = "egiga0";
115 if (miiphy_set_current_dev(name))
118 /* command to read PHY dev address */
119 if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) {
120 printf("Err..%s could not read PHY dev address\n",
126 * Enable RGMII delay on Tx and Rx for CPU port
127 * Ref: sec 4.7.2 of chip datasheet
129 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
130 miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®);
131 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
132 miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
133 miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
136 miiphy_reset(name, devadr);
138 printf("88E1116 Initialized on %s\n", name);
140 #endif /* CONFIG_RESET_PHY_R */
142 #define GREEN_LED (1 << 14)
143 #define ORANGE_LED (1 << 15)
144 #define BOTH_LEDS (GREEN_LED | ORANGE_LED)
145 #define NEITHER_LED 0
147 static void set_leds(u32 leds, u32 blinking)
149 struct kwgpio_registers *r;
153 r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
154 oe = readl(&r->oe) | BOTH_LEDS;
155 writel(oe & ~leds, &r->oe); /* active low */
156 bl = readl(&r->blink_en) & ~BOTH_LEDS;
157 writel(bl | blinking, &r->blink_en);
160 void show_boot_progress(int val)
163 case BOOTSTAGE_ID_RUN_OS: /* booting Linux */
164 set_leds(BOTH_LEDS, NEITHER_LED);
166 case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */
167 set_leds(GREEN_LED, GREEN_LED);
170 if (val < 0) /* error */
171 set_leds(ORANGE_LED, ORANGE_LED);