1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2021 Tony Dinh <mibodhi@gmail.com>
5 * Jason Cooper <u-boot@lakedaemon.net>
8 * Marvell Semiconductor <www.marvell.com>
9 * Written-by: Siddarth Gore <gores@marvell.com>
16 #include <asm/arch/cpu.h>
17 #include <asm/arch/soc.h>
18 #include <asm/arch/mpp.h>
19 #include <asm/global_data.h>
20 #include "dreamplug.h"
22 DECLARE_GLOBAL_DATA_PTR;
24 int board_early_init_f(void)
27 * default gpio configuration
28 * There are maximum 64 gpios controlled through 2 sets of registers
29 * the below configuration configures mainly initial LED status
31 mvebu_config_gpio(DREAMPLUG_OE_VAL_LOW,
32 DREAMPLUG_OE_VAL_HIGH,
33 DREAMPLUG_OE_LOW, DREAMPLUG_OE_HIGH);
35 /* Multi-Purpose Pins Functionality configuration */
36 static const u32 kwmpp_config[] = {
37 MPP0_SPI_SCn, /* SPI Flash */
47 MPP10_UART0_TXD, /* Serial */
49 MPP12_SD_CLK, /* SDIO Slot */
57 MPP20_GE1_0, /* Gigabit Ethernet */
73 MPP36_GPIO, /* 7 external GPIO pins (36 - 45) */
84 MPP47_GPIO, /* Bluetooth LED */
85 MPP48_GPIO, /* Wifi LED */
86 MPP49_GPIO, /* Wifi AP LED */
89 kirkwood_mpp_conf(kwmpp_config, NULL);
95 /* adress of boot parameters */
96 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
101 static int fdt_get_phy_addr(const char *path)
103 const void *fdt = gd->fdt_blob;
106 int node, phandle, addr;
108 /* Find the node by its full path */
109 node = fdt_path_offset(fdt, path);
111 /* Look up phy-handle */
112 val = fdt_getprop(fdt, node, "phy-handle", NULL);
114 phandle = fdt32_to_cpu(*val);
117 /* Follow it to its node */
118 node = fdt_node_offset_by_phandle(fdt, phandle);
121 reg = fdt_getprop(fdt, node, "reg", NULL);
123 addr = fdt32_to_cpu(*reg);
132 #ifdef CONFIG_RESET_PHY_R
133 void mv_phy_88e1116_init(const char *name, const char *path)
138 if (miiphy_set_current_dev(name))
141 phyaddr = fdt_get_phy_addr(path);
146 * Enable RGMII delay on Tx and Rx for CPU port
147 * Ref: sec 4.7.2 of chip datasheet
149 miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 2);
150 miiphy_read(name, phyaddr, MV88E1116_MAC_CTRL2_REG, ®);
151 reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
152 miiphy_write(name, phyaddr, MV88E1116_MAC_CTRL2_REG, reg);
153 miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 0);
156 miiphy_reset(name, phyaddr);
158 printf("88E1116 Initialized on %s\n", name);
163 char *eth0_name = "ethernet-controller@72000";
164 char *eth0_path = "/ocp@f1000000/ethernet-controller@72000/ethernet0-port@0";
165 char *eth1_name = "ethernet-controller@76000";
166 char *eth1_path = "/ocp@f1000000/ethernet-controller@72000/ethernet1-port@0";
168 /* configure and initialize both PHY's */
169 mv_phy_88e1116_init(eth0_name, eth0_path);
170 mv_phy_88e1116_init(eth1_name, eth1_path);
172 #endif /* CONFIG_RESET_PHY_R */