summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2022-05-04 09:05:03 -0400
committerTom Rini <[email protected]>2022-05-04 09:05:03 -0400
commitc3d451d5e6b7c2ea6d83397d5b6c986ff6ab4ee3 (patch)
tree9101cb7a943fe6d055c08b64de8c8e05f09c591b /board
parent4209f7444541b67bf0505c5f1feccc585fb42583 (diff)
parent95a3a6ee086d47a8e0cd573e327fd48a97d87439 (diff)
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
- mips: octeon: Add ethernet support (Aaron & Stefan) - Misc mvneta changes, cleanups, fixes (Marek)
Diffstat (limited to 'board')
-rw-r--r--board/CZ.NIC/turris_mox/turris_mox.c88
-rw-r--r--board/Marvell/mvebu_armada-37xx/board.c26
-rw-r--r--board/Marvell/octeon_nic23/board.c87
3 files changed, 150 insertions, 51 deletions
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index 9702d1fc782..a4738b3a3ca 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -13,6 +13,7 @@
#include <button.h>
#include <clk.h>
#include <dm.h>
+#include <dm/of_extra.h>
#include <env.h>
#include <fdt_support.h>
#include <init.h>
@@ -216,35 +217,35 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd)
#define SW_SMI_CMD_R(d, r) (0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
#define SW_SMI_CMD_W(d, r) (0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
-static int sw_multi_read(struct mii_dev *bus, int sw, int dev, int reg)
+static int sw_multi_read(struct udevice *bus, int sw, int dev, int reg)
{
- bus->write(bus, sw, 0, 0, SW_SMI_CMD_R(dev, reg));
+ dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 0, SW_SMI_CMD_R(dev, reg));
mdelay(5);
- return bus->read(bus, sw, 0, 1);
+ return dm_mdio_read(bus, sw, MDIO_DEVAD_NONE, 1);
}
-static void sw_multi_write(struct mii_dev *bus, int sw, int dev, int reg,
+static void sw_multi_write(struct udevice *bus, int sw, int dev, int reg,
u16 val)
{
- bus->write(bus, sw, 0, 1, val);
- bus->write(bus, sw, 0, 0, SW_SMI_CMD_W(dev, reg));
+ dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 1, val);
+ dm_mdio_write(bus, sw, MDIO_DEVAD_NONE, 0, SW_SMI_CMD_W(dev, reg));
mdelay(5);
}
-static int sw_scratch_read(struct mii_dev *bus, int sw, int reg)
+static int sw_scratch_read(struct udevice *bus, int sw, int reg)
{
sw_multi_write(bus, sw, 0x1c, 0x1a, (reg & 0x7f) << 8);
return sw_multi_read(bus, sw, 0x1c, 0x1a) & 0xff;
}
-static void sw_led_write(struct mii_dev *bus, int sw, int port, int reg,
+static void sw_led_write(struct udevice *bus, int sw, int port, int reg,
u16 val)
{
sw_multi_write(bus, sw, port, 0x16, 0x8000 | ((reg & 7) << 12)
| (val & 0x7ff));
}
-static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz)
+static void sw_blink_leds(struct udevice *bus, int peridot, int topaz)
{
int i, p;
struct {
@@ -275,7 +276,7 @@ static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz)
}
}
-static void check_switch_address(struct mii_dev *bus, int addr)
+static void check_switch_address(struct udevice *bus, int addr)
{
if (sw_scratch_read(bus, addr, 0x70) >> 3 != addr)
printf("Check of switch MDIO address failed for 0x%02x\n",
@@ -374,36 +375,22 @@ static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
static void mox_phy_leds_start_blinking(void)
{
struct phy_device *phydev;
- struct mii_dev *bus;
- const char *node_name;
- int node;
+ ofnode phy_node;
- node = fdt_path_offset(gd->fdt_blob, "ethernet0");
- if (node < 0) {
- printf("Cannot get eth0!\n");
- return;
- }
+ phy_node = ofnode_get_phy_node(ofnode_path("ethernet0"));
+ if (!ofnode_valid(phy_node))
+ goto err;
- node_name = fdt_get_name(gd->fdt_blob, node, NULL);
- if (!node_name) {
- printf("Cannot get eth0 node name!\n");
- return;
- }
-
- bus = miiphy_get_dev_by_name(node_name);
- if (!bus) {
- printf("Cannot get MDIO bus device!\n");
- return;
- }
-
- phydev = phy_find_by_mask(bus, BIT(1));
- if (!phydev) {
- printf("Cannot get ethernet PHY!\n");
- return;
- }
+ phydev = dm_phy_find_by_ofnode(phy_node);
+ if (!phydev)
+ goto err;
mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
+
+ return;
+err:
+ printf("Cannot get ethernet PHY!\n");
}
static bool read_reset_button(void)
@@ -611,6 +598,26 @@ int show_board_info(void)
return 0;
}
+static struct udevice *mox_mdio_bus(void)
+{
+ struct udevice *bus;
+ ofnode node;
+
+ node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
+ if (!ofnode_valid(node))
+ goto err;
+
+ dm_mdio_probe_devices();
+
+ if (uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus))
+ goto err;
+
+ return bus;
+err:
+ printf("Cannot get MDIO bus device!\n");
+ return NULL;
+}
+
int last_stage_init(void)
{
struct gpio_desc reset_gpio = {};
@@ -636,16 +643,9 @@ int last_stage_init(void)
* 0x70 of Peridot (and potentially Topaz) modules
*/
if (peridot || topaz) {
- struct mii_dev *bus;
- const char *node_name;
- int node;
+ struct udevice *bus = mox_mdio_bus();
- node = fdt_path_offset(gd->fdt_blob, "ethernet0");
- node_name = (node >= 0) ? fdt_get_name(gd->fdt_blob, node, NULL) : NULL;
- bus = node_name ? miiphy_get_dev_by_name(node_name) : NULL;
- if (!bus) {
- printf("Cannot get MDIO bus device!\n");
- } else {
+ if (bus) {
int i;
for (i = 0; i < peridot; ++i)
diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
index 98e1b36d11b..3e5e0a0b5c6 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -11,6 +11,7 @@
#include <i2c.h>
#include <init.h>
#include <mmc.h>
+#include <miiphy.h>
#include <phy.h>
#include <asm/global_data.h>
#include <asm/io.h>
@@ -254,14 +255,15 @@ int board_xhci_enable(fdt_addr_t base)
return 0;
}
+#ifdef CONFIG_LAST_STAGE_INIT
/* Helper function for accessing switch devices in multi-chip connection mode */
-static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
+static int mii_multi_chip_mode_write(struct udevice *bus, int dev_smi_addr,
int smi_addr, int reg, u16 value)
{
u16 smi_cmd = 0;
- if (bus->write(bus, dev_smi_addr, 0,
- MVEBU_SW_SMI_DATA_REG, value) != 0) {
+ if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
+ MVEBU_SW_SMI_DATA_REG, value) != 0) {
printf("Error writing to the PHY addr=%02x reg=%02x\n",
smi_addr, reg);
return -EFAULT;
@@ -272,8 +274,8 @@ static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
(1 << SW_SMI_CMD_SMI_OP_OFF) |
(smi_addr << SW_SMI_CMD_DEV_ADDR_OFF) |
(reg << SW_SMI_CMD_REG_ADDR_OFF);
- if (bus->write(bus, dev_smi_addr, 0,
- MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
+ if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
+ MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
printf("Error writing to the PHY addr=%02x reg=%02x\n",
smi_addr, reg);
return -EFAULT;
@@ -283,11 +285,22 @@ static int mii_multi_chip_mode_write(struct mii_dev *bus, int dev_smi_addr,
}
/* Bring-up board-specific network stuff */
-int board_network_enable(struct mii_dev *bus)
+int last_stage_init(void)
{
+ struct udevice *bus;
+ ofnode node;
+
if (!of_machine_is_compatible("globalscale,espressobin"))
return 0;
+ node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
+ if (!ofnode_valid(node) ||
+ uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus) ||
+ device_probe(bus)) {
+ printf("Cannot find MDIO bus\n");
+ return 0;
+ }
+
/*
* FIXME: remove this code once Topaz driver gets available
* A3720 Community Board Only
@@ -327,6 +340,7 @@ int board_network_enable(struct mii_dev *bus)
return 0;
}
+#endif
#ifdef CONFIG_OF_BOARD_SETUP
int ft_board_setup(void *blob, struct bd_info *bd)
diff --git a/board/Marvell/octeon_nic23/board.c b/board/Marvell/octeon_nic23/board.c
index 9f5eb2e2a18..3e2c5444439 100644
--- a/board/Marvell/octeon_nic23/board.c
+++ b/board/Marvell/octeon_nic23/board.c
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright (C) 2021 Stefan Roese <[email protected]>
+ * Copyright (C) 2021-2022 Stefan Roese <[email protected]>
*/
#include <dm.h>
#include <ram.h>
+#include <asm/gpio.h>
#include <mach/octeon_ddr.h>
#include <mach/cvmx-qlm.h>
@@ -84,6 +85,52 @@ int board_fix_fdt(void *fdt)
return rc;
}
+int board_early_init_f(void)
+{
+ struct gpio_desc gpio = {};
+ ofnode node;
+
+ /* Initial GPIO configuration */
+
+ /* GPIO 7: Vitesse reset */
+ node = ofnode_by_compatible(ofnode_null(), "vitesse,vsc7224");
+ if (ofnode_valid(node)) {
+ gpio_request_by_name_nodev(node, "los", 0, &gpio, GPIOD_IS_IN);
+ dm_gpio_free(gpio.dev, &gpio);
+ gpio_request_by_name_nodev(node, "reset", 0, &gpio,
+ GPIOD_IS_OUT);
+ if (dm_gpio_is_valid(&gpio)) {
+ /* Vitesse reset */
+ debug("%s: Setting GPIO 7 to 1\n", __func__);
+ dm_gpio_set_value(&gpio, 1);
+ }
+ dm_gpio_free(gpio.dev, &gpio);
+ }
+
+ /* SFP+ transmitters */
+ ofnode_for_each_compatible_node(node, "ethernet,sfp-slot") {
+ gpio_request_by_name_nodev(node, "tx_disable", 0,
+ &gpio, GPIOD_IS_OUT);
+ if (dm_gpio_is_valid(&gpio)) {
+ debug("%s: Setting GPIO %d to 1\n", __func__,
+ gpio.offset);
+ dm_gpio_set_value(&gpio, 1);
+ }
+ dm_gpio_free(gpio.dev, &gpio);
+ gpio_request_by_name_nodev(node, "mod_abs", 0, &gpio,
+ GPIOD_IS_IN);
+ dm_gpio_free(gpio.dev, &gpio);
+ gpio_request_by_name_nodev(node, "tx_error", 0, &gpio,
+ GPIOD_IS_IN);
+ dm_gpio_free(gpio.dev, &gpio);
+ gpio_request_by_name_nodev(node, "rx_los", 0, &gpio,
+ GPIOD_IS_IN);
+ dm_gpio_free(gpio.dev, &gpio);
+ }
+
+ return 0;
+}
+
void board_configure_qlms(void)
{
octeon_configure_qlm(4, 3000, CVMX_QLM_MODE_SATA_2X1, 0, 0, 0, 0);
@@ -100,7 +147,45 @@ void board_configure_qlms(void)
int board_late_init(void)
{
+ struct gpio_desc gpio = {};
+ ofnode node;
+
+ /* Turn on SFP+ transmitters */
+ ofnode_for_each_compatible_node(node, "ethernet,sfp-slot") {
+ gpio_request_by_name_nodev(node, "tx_disable", 0,
+ &gpio, GPIOD_IS_OUT);
+ if (dm_gpio_is_valid(&gpio)) {
+ debug("%s: Setting GPIO %d to 0\n", __func__,
+ gpio.offset);
+ dm_gpio_set_value(&gpio, 0);
+ }
+ dm_gpio_free(gpio.dev, &gpio);
+ }
+
board_configure_qlms();
return 0;
}
+
+int last_stage_init(void)
+{
+ struct gpio_desc gpio = {};
+ ofnode node;
+
+ node = ofnode_by_compatible(ofnode_null(), "vitesse,vsc7224");
+ if (!ofnode_valid(node)) {
+ printf("Vitesse SPF DT node not found!");
+ return 0;
+ }
+
+ gpio_request_by_name_nodev(node, "reset", 0, &gpio, GPIOD_IS_OUT);
+ if (dm_gpio_is_valid(&gpio)) {
+ /* Take Vitesse retimer out of reset */
+ debug("%s: Setting GPIO 7 to 0\n", __func__);
+ dm_gpio_set_value(&gpio, 0);
+ mdelay(50);
+ }
+ dm_gpio_free(gpio.dev, &gpio);
+
+ return 0;
+}