summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/designware.c10
-rw-r--r--drivers/net/designware.h4
-rw-r--r--drivers/net/fec_mxc.c6
-rw-r--r--drivers/net/fec_mxc.h2
-rw-r--r--drivers/net/fsl-mc/Kconfig12
-rw-r--r--drivers/net/fsl-mc/Makefile4
-rw-r--r--drivers/net/fsl-mc/dpsparser.c138
-rw-r--r--drivers/net/fsl-mc/mc.c264
-rw-r--r--drivers/net/mvneta.c4
-rw-r--r--drivers/net/mvpp2.c9
-rw-r--r--drivers/net/sun8i_emac.c12
11 files changed, 420 insertions, 45 deletions
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 5c2d5e5a79..19fc34f771 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -82,7 +82,7 @@ static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
return ret;
}
-#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_GPIO)
+#if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO)
static int dw_mdio_reset(struct mii_dev *bus)
{
struct udevice *dev = bus->priv;
@@ -128,7 +128,7 @@ static int dw_mdio_init(const char *name, void *priv)
bus->read = dw_mdio_read;
bus->write = dw_mdio_write;
snprintf(bus->name, sizeof(bus->name), "%s", name);
-#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_GPIO)
+#if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO)
bus->reset = dw_mdio_reset;
#endif
@@ -807,12 +807,12 @@ const struct eth_ops designware_eth_ops = {
int designware_eth_ofdata_to_platdata(struct udevice *dev)
{
struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
struct dw_eth_dev *priv = dev_get_priv(dev);
#endif
struct eth_pdata *pdata = &dw_pdata->eth_pdata;
const char *phy_mode;
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
int reset_flags = GPIOD_IS_OUT;
#endif
int ret = 0;
@@ -829,7 +829,7 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
if (dev_read_bool(dev, "snps,reset-active-low"))
reset_flags |= GPIOD_ACTIVE_LOW;
diff --git a/drivers/net/designware.h b/drivers/net/designware.h
index dea12b7048..3519a4167a 100644
--- a/drivers/net/designware.h
+++ b/drivers/net/designware.h
@@ -7,7 +7,7 @@
#ifndef _DW_ETH_H
#define _DW_ETH_H
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
#include <asm-generic/gpio.h>
#endif
@@ -235,7 +235,7 @@ struct dw_eth_dev {
#ifndef CONFIG_DM_ETH
struct eth_device *dev;
#endif
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
struct gpio_desc reset_gpio;
#endif
#ifdef CONFIG_CLK
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 2aa1029d42..bc5b63d788 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1309,7 +1309,7 @@ static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
return 0;
}
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
/* FEC GPIO reset */
static void fec_gpio_reset(struct fec_priv *priv)
{
@@ -1402,7 +1402,7 @@ static int fecmxc_probe(struct udevice *dev)
}
#endif
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
fec_gpio_reset(priv);
#endif
/* Reset chip. */
@@ -1508,7 +1508,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
device_get_supply_regulator(dev, "phy-supply", &priv->phy_supply);
#endif
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
&priv->phy_reset_gpio, GPIOD_IS_OUT);
if (ret < 0)
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 723b06a651..159aec8967 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -255,7 +255,7 @@ struct fec_priv {
#ifdef CONFIG_DM_REGULATOR
struct udevice *phy_supply;
#endif
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
struct gpio_desc phy_reset_gpio;
uint32_t reset_delay;
uint32_t reset_post_delay;
diff --git a/drivers/net/fsl-mc/Kconfig b/drivers/net/fsl-mc/Kconfig
index 25a2cb8ffa..2cf651d3b3 100644
--- a/drivers/net/fsl-mc/Kconfig
+++ b/drivers/net/fsl-mc/Kconfig
@@ -22,4 +22,16 @@ config SYS_MC_RSV_MEM_ALIGN
Reserved memory needs to be aligned for MC to use. Default value
is 512MB.
+config MC_DRAM_SPB_OFFSET
+ hex "Soft Parser SPB DRAM offset"
+ default 0x00F40000
+ help
+ Set the DRAM offset for Soft Parser Blob.
+
+config MC_SPB_MAX_SIZE
+ hex "Soft Parser SPB maximum size"
+ default 0x00020000
+ help
+ Set the maximum size for Soft Parser Blob.
+
endif # FSL_MC_ENET
diff --git a/drivers/net/fsl-mc/Makefile b/drivers/net/fsl-mc/Makefile
index 1b1b4a77f8..5a1acd576a 100644
--- a/drivers/net/fsl-mc/Makefile
+++ b/drivers/net/fsl-mc/Makefile
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright 2014 Freescale Semiconductor, Inc.
+# Copyright 2018 NXP
# Layerscape MC driver
obj-y += mc.o \
@@ -9,5 +10,6 @@ obj-y += mc.o \
dprc.o \
dpbp.o \
dpni.o \
- dpmac.o
+ dpmac.o \
+ dpsparser.o
obj-y += dpio/
diff --git a/drivers/net/fsl-mc/dpsparser.c b/drivers/net/fsl-mc/dpsparser.c
new file mode 100644
index 0000000000..cfd1ba66a0
--- /dev/null
+++ b/drivers/net/fsl-mc/dpsparser.c
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Data Path Soft Parser
+ *
+ * Copyright 2018 NXP
+ */
+#include <fsl-mc/fsl_mc_sys.h>
+#include <fsl-mc/fsl_mc_cmd.h>
+#include <fsl-mc/fsl_dpsparser.h>
+
+int dpsparser_open(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 *token)
+{
+ struct mc_command cmd = { 0 };
+ int err;
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_OPEN,
+ cmd_flags,
+ 0);
+
+ /* send command to mc*/
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ /* retrieve response parameters */
+ *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+ return err;
+}
+
+int dpsparser_close(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token)
+{
+ struct mc_command cmd = { 0 };
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_CLOSE, cmd_flags,
+ token);
+
+ /* send command to mc*/
+ return mc_send_command(mc_io, &cmd);
+}
+
+int dpsparser_create(struct fsl_mc_io *mc_io,
+ u16 token,
+ u32 cmd_flags,
+ u32 *obj_id)
+{
+ struct mc_command cmd = { 0 };
+ int err;
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_CREATE,
+ cmd_flags,
+ token);
+
+ /* send command to mc*/
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ /* retrieve response parameters */
+ MC_CMD_READ_OBJ_ID(cmd, *obj_id);
+
+ return 0;
+}
+
+int dpsparser_destroy(struct fsl_mc_io *mc_io,
+ u16 token,
+ u32 cmd_flags,
+ u32 obj_id)
+{
+ struct mc_command cmd = { 0 };
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_DESTROY,
+ cmd_flags,
+ token);
+
+ /* set object id to destroy */
+ CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
+
+ /* send command to mc*/
+ return mc_send_command(mc_io, &cmd);
+}
+
+int dpsparser_apply_spb(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 token,
+ u64 blob_addr,
+ u16 *error)
+{
+ struct mc_command cmd = { 0 };
+ int err;
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_APPLY_SPB,
+ cmd_flags,
+ token);
+ DPSPARSER_CMD_BLOB_SET_ADDR(cmd, blob_addr);
+
+ /* send command to mc*/
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ /* retrieve response parameters: MC error code */
+ DPSPARSER_CMD_BLOB_REPORT_ERROR(cmd, *error);
+
+ return 0;
+}
+
+int dpsparser_get_api_version(struct fsl_mc_io *mc_io,
+ u32 cmd_flags,
+ u16 *major_ver,
+ u16 *minor_ver)
+{
+ struct mc_command cmd = { 0 };
+ int err;
+
+ /* prepare command */
+ cmd.header = mc_encode_cmd_header(DPSPARSER_CMDID_GET_API_VERSION,
+ cmd_flags, 0);
+
+ /* send command to mc */
+ err = mc_send_command(mc_io, &cmd);
+ if (err)
+ return err;
+
+ /* retrieve response parameters */
+ mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
+
+ return 0;
+}
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index ffc408e3a4..8ff43a91c7 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2014 Freescale Semiconductor, Inc.
- * Copyright 2017 NXP
* Copyright 2017-2018 NXP
*/
#include <common.h>
@@ -21,6 +20,7 @@
#include <fsl-mc/fsl_dprc.h>
#include <fsl-mc/fsl_dpio.h>
#include <fsl-mc/fsl_dpni.h>
+#include <fsl-mc/fsl_dpsparser.h>
#include <fsl-mc/fsl_qbman_portal.h>
#include <fsl-mc/ldpaa_wriop.h>
@@ -35,6 +35,7 @@
DECLARE_GLOBAL_DATA_PTR;
static int mc_memset_resv_ram;
+static struct mc_version mc_ver_info;
static int mc_boot_status = -1;
static int mc_dpl_applied = -1;
#ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
@@ -49,6 +50,9 @@ struct fsl_dpbp_obj *dflt_dpbp = NULL;
struct fsl_dpio_obj *dflt_dpio = NULL;
struct fsl_dpni_obj *dflt_dpni = NULL;
static u64 mc_lazy_dpl_addr;
+static u32 dpsparser_obj_id;
+static u16 dpsparser_handle;
+static char *mc_err_msg_apply_spb[] = MC_ERROR_MSG_APPLY_SPB;
#ifdef DEBUG
void dump_ram_words(const char *title, void *addr)
@@ -92,7 +96,6 @@ void dump_mc_ccsr_regs(struct mc_ccsr_registers __iomem *mc_ccsr_regs)
#endif /* DEBUG */
-#ifndef CONFIG_SYS_LS_MC_FW_IN_DDR
/**
* Copying MC firmware or DPL image to DDR
*/
@@ -105,6 +108,7 @@ static int mc_copy_image(const char *title,
return 0;
}
+#ifndef CONFIG_SYS_LS_MC_FW_IN_DDR
/**
* MC firmware FIT image parser checks if the image is in FIT
* format, verifies integrity of the image and calculates
@@ -691,7 +695,6 @@ int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
const void *raw_image_addr;
size_t raw_image_size = 0;
#endif
- struct mc_version mc_ver_info;
u8 mc_ram_num_256mb_blocks;
size_t mc_ram_size = mc_get_dram_block_size();
@@ -1447,6 +1450,170 @@ err:
return err;
}
+static bool is_dpsparser_supported(void)
+{
+ /* dpsparser support was first introduced in MC version: 10.12.0 */
+ if (mc_ver_info.major < 10)
+ return false;
+ if (mc_ver_info.major == 10)
+ return (mc_ver_info.minor >= 12);
+ return true;
+}
+
+static int dpsparser_version_check(struct fsl_mc_io *mc_io)
+{
+ int error;
+ u16 major_ver, minor_ver;
+
+ if (!is_dpsparser_supported())
+ return 0;
+
+ error = dpsparser_get_api_version(mc_io, 0,
+ &major_ver,
+ &minor_ver);
+ if (error < 0) {
+ printf("dpsparser_get_api_version() failed: %d\n", error);
+ return error;
+ }
+
+ if (major_ver < DPSPARSER_VER_MAJOR || (major_ver ==
+ DPSPARSER_VER_MAJOR && minor_ver < DPSPARSER_VER_MINOR)) {
+ printf("DPSPARSER version mismatch found %u.%u,",
+ major_ver, minor_ver);
+ printf("supported version is %u.%u\n",
+ DPSPARSER_VER_MAJOR, DPSPARSER_VER_MINOR);
+ }
+
+ return error;
+}
+
+static int dpsparser_init(void)
+{
+ int err = 0;
+
+ if (!is_dpsparser_supported())
+ return 0;
+
+ err = dpsparser_create(dflt_mc_io,
+ dflt_dprc_handle,
+ MC_CMD_NO_FLAGS,
+ &dpsparser_obj_id);
+ if (err)
+ printf("dpsparser_create() failed\n");
+
+ err = dpsparser_version_check(dflt_mc_io);
+ if (err < 0) {
+ printf("dpsparser_version_check() failed: %d\n", err);
+ goto err_version_check;
+ }
+
+ err = dpsparser_open(dflt_mc_io,
+ MC_CMD_NO_FLAGS,
+ &dpsparser_handle);
+ if (err < 0) {
+ printf("dpsparser_open() failed: %d\n", err);
+ goto err_open;
+ }
+
+ return err;
+
+err_open:
+err_version_check:
+ dpsparser_destroy(dflt_mc_io,
+ dflt_dprc_handle,
+ MC_CMD_NO_FLAGS, dpsparser_obj_id);
+
+ return err;
+}
+
+#ifdef DPSPARSER_DESTROY
+/* TODO: refactoring needed in the future to allow DPSPARSER object destroy
+ * Workaround: DO NOT destroy DPSPARSER object because it needs to be available
+ * on Apply DPL
+ */
+static int dpsparser_exit(void)
+{
+ int err;
+
+ if (!is_dpsparser_supported())
+ return 0;
+
+ dpsparser_close(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle);
+ if (err < 0) {
+ printf("dpsparser_close() failed: %d\n", err);
+ goto err;
+ }
+
+ err = dpsparser_destroy(dflt_mc_io, dflt_dprc_handle,
+ MC_CMD_NO_FLAGS, dpsparser_obj_id);
+ if (err < 0) {
+ printf("dpsparser_destroy() failed: %d\n", err);
+ goto err;
+ }
+ return 0;
+
+err:
+ return err;
+}
+#endif
+
+int mc_apply_spb(u64 mc_spb_addr)
+{
+ int err = 0;
+ u16 error, err_arr_size;
+ u64 mc_spb_offset;
+ u32 spb_size;
+ struct sp_blob_header *sp_blob;
+ u64 mc_ram_addr = mc_get_dram_addr();
+
+ if (!is_dpsparser_supported())
+ return 0;
+
+ if (!mc_spb_addr) {
+ printf("fsl-mc: Invalid Blob address\n");
+ return -1;
+ }
+
+#ifdef CONFIG_MC_DRAM_SPB_OFFSET
+ mc_spb_offset = CONFIG_MC_DRAM_SPB_OFFSET;
+#else
+#error "CONFIG_MC_DRAM_SPB_OFFSET not defined"
+#endif
+
+ // Read blob header and get size of SPB blob
+ sp_blob = (struct sp_blob_header *)mc_spb_addr;
+ spb_size = le32_to_cpu(sp_blob->length);
+ if (spb_size > CONFIG_MC_SPB_MAX_SIZE) {
+ printf("\nfsl-mc: ERROR: Bad SPB image (too large: %d)\n",
+ spb_size);
+ return -EINVAL;
+ }
+
+ mc_copy_image("MC SP Blob", mc_spb_addr, spb_size,
+ mc_ram_addr + mc_spb_offset);
+
+ //Invoke MC command to apply SPB blob
+ printf("fsl-mc: Applying soft parser blob... ");
+ err = dpsparser_apply_spb(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle,
+ mc_spb_offset, &error);
+ if (err)
+ return err;
+
+ if (error == 0) {
+ printf("SUCCESS\n");
+ } else {
+ printf("FAILED with error code = %d:\n", error);
+ err_arr_size = (u16)ARRAY_SIZE(mc_err_msg_apply_spb);
+
+ if (error > 0 && error < err_arr_size)
+ printf(mc_err_msg_apply_spb[error]);
+ else
+ printf(MC_ERROR_MSG_SPB_UNKNOWN);
+ }
+
+ return err;
+}
+
static int mc_init_object(void)
{
int err = 0;
@@ -1475,6 +1642,12 @@ static int mc_init_object(void)
goto err;
}
+ err = dpsparser_init();
+ if (err < 0) {
+ printf("dpsparser_init() failed: %d\n", err);
+ goto err;
+ }
+
return 0;
err:
return err;
@@ -1608,39 +1781,87 @@ static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
break;
- case 'l':
+ case 'l': {
+ /* lazyapply */
+ u64 mc_dpl_addr;
+
+ if (argc < 4)
+ goto usage;
+
+ if (get_dpl_apply_status() == 0) {
+ printf("fsl-mc: DPL already applied\n");
+ return err;
+ }
+
+ mc_dpl_addr = simple_strtoull(argv[3], NULL, 16);
+
+ if (get_mc_boot_status() != 0) {
+ printf("fsl-mc: Deploying data path layout ..");
+ printf("ERROR (MC is not booted)\n");
+ return -ENODEV;
+ }
+
+ /*
+ * We will do the actual dpaa exit and dpl apply
+ * later from announce_and_cleanup().
+ */
+ mc_lazy_dpl_addr = mc_dpl_addr;
+ break;
+ }
+
case 'a': {
- u64 mc_dpl_addr;
+ /* apply */
+ char sub_cmd;
+ u64 mc_apply_addr;
- if (argc < 4)
- goto usage;
+ if (argc < 4)
+ goto usage;
+
+ sub_cmd = argv[2][0];
+ switch (sub_cmd) {
+ case 'd':
+ case 'D':
if (get_dpl_apply_status() == 0) {
printf("fsl-mc: DPL already applied\n");
return err;
}
-
- mc_dpl_addr = simple_strtoull(argv[3], NULL,
- 16);
-
if (get_mc_boot_status() != 0) {
printf("fsl-mc: Deploying data path layout ..");
printf("ERROR (MC is not booted)\n");
return -ENODEV;
}
- if (argv[1][0] == 'l') {
- /*
- * We will do the actual dpaa exit and dpl apply
- * later from announce_and_cleanup().
- */
- mc_lazy_dpl_addr = mc_dpl_addr;
- } else {
- /* The user wants it applied now */
- if (!fsl_mc_ldpaa_exit(NULL))
- err = mc_apply_dpl(mc_dpl_addr);
+ mc_apply_addr = simple_strtoull(argv[3], NULL, 16);
+
+ /* The user wants DPL applied now */
+ if (!fsl_mc_ldpaa_exit(NULL))
+ err = mc_apply_dpl(mc_apply_addr);
+ break;
+
+ case 's':
+ if (!is_dpsparser_supported()) {
+ printf("fsl-mc: apply spb command .. ");
+ printf("ERROR: requires at least MC 10.12.0\n");
+ return err;
}
+ if (get_mc_boot_status() != 0) {
+ printf("fsl-mc: Deploying Soft Parser Blob...");
+ printf("ERROR (MC is not booted)\n");
+ return err;
+ }
+
+ mc_apply_addr = simple_strtoull(argv[3], NULL, 16);
+
+ /* Apply spb (Soft Parser Blob) */
+ err = mc_apply_spb(mc_apply_addr);
break;
+
+ default:
+ printf("Invalid option: %s\n", argv[2]);
+ goto usage;
+ }
+ break;
}
default:
printf("Invalid option: %s\n", argv[1]);
@@ -1658,6 +1879,7 @@ U_BOOT_CMD(
"start mc [FW_addr] [DPC_addr] - Start Management Complex\n"
"fsl_mc apply DPL [DPL_addr] - Apply DPL file\n"
"fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n"
+ "fsl_mc apply spb [spb_addr] - Apply SPB Soft Parser Blob\n"
"fsl_mc start aiop [FW_addr] - Start AIOP\n"
);
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 6f76a6b0dc..5fe8500199 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -276,7 +276,7 @@ struct mvneta_port {
int init;
int phyaddr;
struct phy_device *phydev;
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
struct gpio_desc phy_reset_gpio;
#endif
struct mii_dev *bus;
@@ -1754,7 +1754,7 @@ static int mvneta_probe(struct udevice *dev)
if (ret)
return ret;
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
gpio_request_by_name(dev, "phy-reset-gpios", 0,
&pp->phy_reset_gpio, GPIOD_IS_OUT);
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index c5d1f9cf9f..917d06b6e0 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -959,7 +959,8 @@ struct mvpp2_port {
phy_interface_t phy_interface;
int phyaddr;
struct udevice *mdio_dev;
-#ifdef CONFIG_DM_GPIO
+ struct mii_dev *bus;
+#if CONFIG_IS_ENABLED(DM_GPIO)
struct gpio_desc phy_reset_gpio;
struct gpio_desc phy_tx_disable_gpio;
#endif
@@ -4742,7 +4743,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
return -EINVAL;
}
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
gpio_request_by_name(dev, "phy-reset-gpios", 0,
&port->phy_reset_gpio, GPIOD_IS_OUT);
gpio_request_by_name(dev, "marvell,sfp-tx-disable-gpio", 0,
@@ -4769,7 +4770,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
return 0;
}
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
/* Port GPIO initialization */
static void mvpp2_gpio_init(struct mvpp2_port *port)
{
@@ -4802,7 +4803,7 @@ static int mvpp2_port_probe(struct udevice *dev,
}
mvpp2_port_power_up(port);
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
mvpp2_gpio_init(port);
#endif
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 9551918796..6f10578c88 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -24,7 +24,7 @@
#include <net.h>
#include <reset.h>
#include <dt-bindings/pinctrl/sun4i-a10.h>
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
#include <asm-generic/gpio.h>
#endif
@@ -142,7 +142,7 @@ struct emac_eth_dev {
struct clk ephy_clk;
struct reset_ctl tx_rst;
struct reset_ctl ephy_rst;
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
struct gpio_desc reset_gpio;
#endif
};
@@ -696,7 +696,7 @@ err_tx_clk:
return ret;
}
-#if defined(CONFIG_DM_GPIO)
+#if CONFIG_IS_ENABLED(DM_GPIO)
static int sun8i_mdio_reset(struct mii_dev *bus)
{
struct udevice *dev = bus->priv;
@@ -743,7 +743,7 @@ static int sun8i_mdio_init(const char *name, struct udevice *priv)
bus->write = sun8i_mdio_write;
snprintf(bus->name, sizeof(bus->name), name);
bus->priv = (void *)priv;
-#if defined(CONFIG_DM_GPIO)
+#if CONFIG_IS_ENABLED(DM_GPIO)
bus->reset = sun8i_mdio_reset;
#endif
@@ -905,7 +905,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
const fdt32_t *reg;
int node = dev_of_offset(dev);
int offset = 0;
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
int reset_flags = GPIOD_IS_OUT;
#endif
int ret;
@@ -999,7 +999,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
printf("%s: Invalid RX delay value %d\n", __func__,
sun8i_pdata->rx_delay_ps);
-#ifdef CONFIG_DM_GPIO
+#if CONFIG_IS_ENABLED(DM_GPIO)
if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"snps,reset-active-low"))
reset_flags |= GPIOD_ACTIVE_LOW;