From b59889bf344dd261b50d69a5eacfa2874573c7cd Mon Sep 17 00:00:00 2001
From: Pratyush Yadav
Date: Tue, 26 May 2020 17:35:57 +0530
Subject: regmap: Check for out-of-range offsets before mapping them
In regmap_raw_{read,write}_range(), offsets are checked to make sure
they aren't out of range. But this check happens _after_ the address is
mapped from physical memory. Input should be sanity-checked before using
it. Mapping the address before validating it leaves the door open to
passing an invalid address to map_physmem(). So check for out of range
offsets _before_ mapping them.
This fixes a segmentation fault in sandbox when -1 is used as an offset
to regmap_{read,write}().
Signed-off-by: Pratyush Yadav
---
drivers/core/regmap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 4a214ef..a67a237 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -310,13 +310,13 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
}
range = &map->ranges[range_num];
- ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
-
if (offset + val_len > range->size) {
debug("%s: offset/size combination invalid\n", __func__);
return -ERANGE;
}
+ ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
+
switch (val_len) {
case REGMAP_SIZE_8:
*((u8 *)valp) = __read_8(ptr, map->endianness);
@@ -419,13 +419,13 @@ int regmap_raw_write_range(struct regmap *map, uint range_num, uint offset,
}
range = &map->ranges[range_num];
- ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
-
if (offset + val_len > range->size) {
debug("%s: offset/size combination invalid\n", __func__);
return -ERANGE;
}
+ ptr = map_physmem(range->start + offset, val_len, MAP_NOCACHE);
+
switch (val_len) {
case REGMAP_SIZE_8:
__write_8(ptr, val, map->endianness);
--
cgit v1.1
From c03b7612ea346ad7454086d1623fb57098faf315 Mon Sep 17 00:00:00 2001
From: Michael Walle
Date: Tue, 2 Jun 2020 01:47:07 +0200
Subject: usb: provide a device tree node to USB devices
It is possible to specify a device tree node for an USB device. This is
useful if you have a static USB setup and want to use aliases which
point to these nodes, like on the Raspberry Pi.
The nodes are matched against their hub port number, the compatible
strings are not matched for now.
Signed-off-by: Michael Walle
Reviewed-by: Marek Vasut
Reviewed-by: Simon Glass
---
drivers/usb/host/usb-uclass.c | 41 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index cb79dfb..f42c062 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -494,6 +494,35 @@ static int usb_match_one_id(struct usb_device_descriptor *desc,
return usb_match_one_id_intf(desc, int_desc, id);
}
+static ofnode usb_get_ofnode(struct udevice *hub, int port)
+{
+ ofnode node;
+ u32 reg;
+
+ if (!dev_has_of_node(hub))
+ return ofnode_null();
+
+ /*
+ * The USB controller and its USB hub are two different udevices,
+ * but the device tree has only one node for both. Thus we are
+ * assigning this node to both udevices.
+ * If port is zero, the controller scans its root hub, thus we
+ * are using the same ofnode as the controller here.
+ */
+ if (!port)
+ return dev_ofnode(hub);
+
+ ofnode_for_each_subnode(node, dev_ofnode(hub)) {
+ if (ofnode_read_u32(node, "reg", ®))
+ continue;
+
+ if (reg == port)
+ return node;
+ }
+
+ return ofnode_null();
+}
+
/**
* usb_find_and_bind_driver() - Find and bind the right USB driver
*
@@ -502,13 +531,14 @@ static int usb_match_one_id(struct usb_device_descriptor *desc,
static int usb_find_and_bind_driver(struct udevice *parent,
struct usb_device_descriptor *desc,
struct usb_interface_descriptor *iface,
- int bus_seq, int devnum,
+ int bus_seq, int devnum, int port,
struct udevice **devp)
{
struct usb_driver_entry *start, *entry;
int n_ents;
int ret;
char name[30], *str;
+ ofnode node = usb_get_ofnode(parent, port);
*devp = NULL;
debug("%s: Searching for driver\n", __func__);
@@ -533,8 +563,8 @@ static int usb_find_and_bind_driver(struct udevice *parent,
* find another driver. For now this doesn't seem
* necesssary, so just bind the first match.
*/
- ret = device_bind(parent, drv, drv->name, NULL, -1,
- &dev);
+ ret = device_bind_ofnode(parent, drv, drv->name, NULL,
+ node, &dev);
if (ret)
goto error;
debug("%s: Match found: %s\n", __func__, drv->name);
@@ -651,9 +681,10 @@ int usb_scan_device(struct udevice *parent, int port,
if (ret) {
if (ret != -ENOENT)
return ret;
- ret = usb_find_and_bind_driver(parent, &udev->descriptor, iface,
+ ret = usb_find_and_bind_driver(parent, &udev->descriptor,
+ iface,
udev->controller_dev->seq,
- udev->devnum, &dev);
+ udev->devnum, port, &dev);
if (ret)
return ret;
created = true;
--
cgit v1.1
From be1a6e94254af205bd67d69e3bdb26b161ccd72f Mon Sep 17 00:00:00 2001
From: Michael Walle
Date: Tue, 2 Jun 2020 01:47:09 +0200
Subject: dm: uclass: don't assign aliased seq numbers
If there are aliases for an uclass, set the base for the "dynamically"
allocated numbers next to the highest alias.
Please note, that this might lead to holes in the sequences, depending
on the device tree. For example if there is only an alias "ethernet1",
the next device seq number would be 2.
In particular this fixes a problem with boards which are using ethernet
aliases but also might have network add-in cards like the E1000. If the
board is started with the add-in card and depending on the order of the
drivers, the E1000 might occupy the first ethernet device and mess up
all the hardware addresses, because the devices are now shifted by one.
Also adapt the test cases to the new handling and add test cases
checking the holes in the seq numbers.
Signed-off-by: Michael Walle
Reviewed-by: Alex Marginean
Tested-by: Alex Marginean
Acked-by: Vladimir Oltean
Reviewed-by: Simon Glass
Tested-by: Michal Simek [on zcu102-revA]
---
drivers/core/uclass.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
(limited to 'drivers')
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 2ab419c..c3f1b73 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -689,13 +689,14 @@ int uclass_unbind_device(struct udevice *dev)
int uclass_resolve_seq(struct udevice *dev)
{
+ struct uclass *uc = dev->uclass;
+ struct uclass_driver *uc_drv = uc->uc_drv;
struct udevice *dup;
- int seq;
+ int seq = 0;
int ret;
assert(dev->seq == -1);
- ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, dev->req_seq,
- false, &dup);
+ ret = uclass_find_device_by_seq(uc_drv->id, dev->req_seq, false, &dup);
if (!ret) {
dm_warn("Device '%s': seq %d is in use by '%s'\n",
dev->name, dev->req_seq, dup->name);
@@ -707,9 +708,17 @@ int uclass_resolve_seq(struct udevice *dev)
return ret;
}
- for (seq = 0; seq < DM_MAX_SEQ; seq++) {
- ret = uclass_find_device_by_seq(dev->uclass->uc_drv->id, seq,
- false, &dup);
+ if (CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
+ (uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
+ /*
+ * dev_read_alias_highest_id() will return -1 if there no
+ * alias. Thus we can always add one.
+ */
+ seq = dev_read_alias_highest_id(uc_drv->name) + 1;
+ }
+
+ for (; seq < DM_MAX_SEQ; seq++) {
+ ret = uclass_find_device_by_seq(uc_drv->id, seq, false, &dup);
if (ret == -ENODEV)
break;
if (ret)
--
cgit v1.1
From baafd99d13931312ff3e2c1c75922d8a46222f7f Mon Sep 17 00:00:00 2001
From: Bryan O'Donoghue
Date: Thu, 26 Mar 2020 03:54:01 +0000
Subject: net: phy: micrel: ksz8061 implement errata 80000688A fix
Linux commit 232ba3a51cc2 ('net: phy: Micrel KSZ8061: link failure after
cable connect') implements a fix for the above errata.
This patch replicates that errata fix in an ksz8061 specific init routine.
Signed-off-by: Bryan O'Donoghue
Acked-by: Joe Hershberger
---
drivers/net/phy/micrel_ksz8xxx.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
(limited to 'drivers')
diff --git a/drivers/net/phy/micrel_ksz8xxx.c b/drivers/net/phy/micrel_ksz8xxx.c
index 98a0c83..60d42fe 100644
--- a/drivers/net/phy/micrel_ksz8xxx.c
+++ b/drivers/net/phy/micrel_ksz8xxx.c
@@ -82,6 +82,21 @@ static struct phy_driver KSZ8051_driver = {
.shutdown = &genphy_shutdown,
};
+static int ksz8061_config(struct phy_device *phydev)
+{
+ return phy_write(phydev, MDIO_MMD_PMAPMD, MDIO_DEVID1, 0xB61A);
+}
+
+static struct phy_driver KSZ8061_driver = {
+ .name = "Micrel KSZ8061",
+ .uid = 0x00221570,
+ .mask = 0xfffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &ksz8061_config,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
static int ksz8081_config(struct phy_device *phydev)
{
int ret;
@@ -210,6 +225,7 @@ int phy_micrel_ksz8xxx_init(void)
phy_register(&KSZ804_driver);
phy_register(&KSZ8031_driver);
phy_register(&KSZ8051_driver);
+ phy_register(&KSZ8061_driver);
phy_register(&KSZ8081_driver);
phy_register(&KS8721_driver);
phy_register(&ksz8895_driver);
--
cgit v1.1
From a7a435e7d41db6a611427b4cc5fd506a18fb2c2f Mon Sep 17 00:00:00 2001
From: Tom Warren
Date: Thu, 26 Mar 2020 15:59:13 -0700
Subject: net: rt8169: WAR for DHCP not getting IP after kernel boot/reboot
This is a WAR for DHCP failure after rebooting from the L4T kernel. The
r8169.c kernel driver is setting bit 19 of the rt816x HW register 0xF0,
which goes by FuncEvent and MISC in various driver source/datasheets.
That bit is called RxDv_Gated_En in the r8169.c kernel driver. Clear it
here at the end of probe to ensure that U-Boot can get an IP assigned
via DHCP.
Signed-off-by: Tom Warren
---
drivers/net/rtl8169.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
(limited to 'drivers')
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 75058fd..fb4fae2 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -240,6 +240,9 @@ enum RTL8169_register_content {
/*_TBICSRBit*/
TBILinkOK = 0x02000000,
+
+ /* FuncEvent/Misc */
+ RxDv_Gated_En = 0x80000,
};
static struct {
@@ -1210,6 +1213,19 @@ static int rtl8169_eth_probe(struct udevice *dev)
return ret;
}
+ /*
+ * WAR for DHCP failure after rebooting from kernel.
+ * Clear RxDv_Gated_En bit which was set by kernel driver.
+ * Without this, U-Boot can't get an IP via DHCP.
+ * Register (FuncEvent, aka MISC) and RXDV_GATED_EN bit are from
+ * the r8169.c kernel driver.
+ */
+
+ u32 val = RTL_R32(FuncEvent);
+ debug("%s: FuncEvent/Misc (0xF0) = 0x%08X\n", __func__, val);
+ val &= ~RxDv_Gated_En;
+ RTL_W32(FuncEvent, val);
+
return 0;
}
--
cgit v1.1
From 9c6de508a6362a3ddd4067e90f07ae613f312aa4 Mon Sep 17 00:00:00 2001
From: Florin Chiculita
Date: Wed, 29 Apr 2020 14:25:48 +0300
Subject: net: phy: add phyid search in vendor specific space
There are devices accesible through mdio clause-45, such as
retimers, that do not have PMA or PCS blocks.
This patch adds MDIO_MMD_VEND1 on the list of device addresses
where phyid is searched. Previous order of devices was kept.
Signed-off-by: Florin Chiculita
Reviewed-by: Madalin Bucur
---
drivers/net/phy/phy.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index cce09c4..6778989 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -786,17 +786,27 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
uint phy_mask,
phy_interface_t interface)
{
- int i;
struct phy_device *phydev;
-
+ int devad[] = {
+ /* Clause-22 */
+ MDIO_DEVAD_NONE,
+ /* Clause-45 */
+ MDIO_MMD_PMAPMD,
+ MDIO_MMD_WIS,
+ MDIO_MMD_PCS,
+ MDIO_MMD_PHYXS,
+ MDIO_MMD_VEND1,
+ };
+ int i, devad_cnt;
+
+ devad_cnt = sizeof(devad)/sizeof(int);
phydev = search_for_existing_phy(bus, phy_mask, interface);
if (phydev)
return phydev;
- /* Try Standard (ie Clause 22) access */
- /* Otherwise we have to try Clause 45 */
- for (i = 0; i < 5; i++) {
+ /* try different access clauses */
+ for (i = 0; i < devad_cnt; i++) {
phydev = create_phy_by_mask(bus, phy_mask,
- i ? i : MDIO_DEVAD_NONE, interface);
+ devad[i], interface);
if (IS_ERR(phydev))
return NULL;
if (phydev)
--
cgit v1.1
From bc0e578f903d24b5291d34959ad534138ced0780 Mon Sep 17 00:00:00 2001
From: Dan Murphy
Date: Mon, 4 May 2020 16:14:39 -0500
Subject: net: phy: Add support for TI PHY init
ti_phy_init function was allocated to the DP83867 PHY. This function
name is to generic for a specific PHY. The function can be moved to a
TI specific file that can register all TI PHYs that are defined in the
defconfig. The ti_phy_init file will contain all TI PHYs initialization
so that only phy_ti_init can be called from the framework.
In addition to the above the config flag for the DP83867 needs to be changed
in the Kconfig and dependent defconfig files. The config flag that was
used for the DP83867 was also generic in nature so a more specific
config flag for the DP83867 was created.
Acked-by: Michal Simek
Signed-off-by: Dan Murphy
---
drivers/net/phy/Kconfig | 8 ++++++++
drivers/net/phy/Makefile | 3 ++-
drivers/net/phy/dp83867.c | 3 ++-
drivers/net/phy/ti_phy_init.c | 18 ++++++++++++++++++
drivers/net/phy/ti_phy_init.h | 15 +++++++++++++++
5 files changed, 45 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/phy/ti_phy_init.c
create mode 100644 drivers/net/phy/ti_phy_init.h
(limited to 'drivers')
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d1f049e..a5a1ff2 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -243,6 +243,14 @@ config PHY_TERANETICS
config PHY_TI
bool "Texas Instruments Ethernet PHYs support"
+ ---help---
+ Adds PHY registration support for TI PHYs.
+
+config PHY_TI_DP83867
+ select PHY_TI
+ bool "Texas Instruments Ethernet DP83867 PHY support"
+ ---help---
+ Adds support for the TI DP83867 1Gbit PHY.
config PHY_VITESSE
bool "Vitesse Ethernet PHYs support"
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 1d81516..6e72233 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -25,7 +25,8 @@ obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
obj-$(CONFIG_PHY_REALTEK) += realtek.o
obj-$(CONFIG_PHY_SMSC) += smsc.o
obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
-obj-$(CONFIG_PHY_TI) += dp83867.o
+obj-$(CONFIG_PHY_TI) += ti_phy_init.o
+obj-$(CONFIG_PHY_TI_DP83867) += dp83867.o
obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
obj-$(CONFIG_PHY_VITESSE) += vitesse.o
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index d435cc1..eada454 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -14,6 +14,7 @@
#include
#include
+#include "ti_phy_init.h"
/* TI DP83867 */
#define DP83867_DEVADDR 0x1f
@@ -430,7 +431,7 @@ static struct phy_driver DP83867_driver = {
.shutdown = &genphy_shutdown,
};
-int phy_ti_init(void)
+int phy_dp83867_init(void)
{
phy_register(&DP83867_driver);
return 0;
diff --git a/drivers/net/phy/ti_phy_init.c b/drivers/net/phy/ti_phy_init.c
new file mode 100644
index 0000000..277b29a
--- /dev/null
+++ b/drivers/net/phy/ti_phy_init.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TI Generic PHY Init to register any TI Ethernet PHYs
+ *
+ * Author: Dan Murphy
+ *
+ * Copyright (C) 2019-20 Texas Instruments Inc.
+ */
+
+#include "ti_phy_init.h"
+
+int phy_ti_init(void)
+{
+#ifdef CONFIG_PHY_TI_DP83867
+ phy_dp83867_init();
+#endif
+ return 0;
+}
diff --git a/drivers/net/phy/ti_phy_init.h b/drivers/net/phy/ti_phy_init.h
new file mode 100644
index 0000000..6c7f6c6
--- /dev/null
+++ b/drivers/net/phy/ti_phy_init.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * TI Generic Ethernet PHY
+ *
+ * Author: Dan Murphy
+ *
+ * Copyright (C) 2019-20 Texas Instruments Inc.
+ */
+
+#ifndef _TI_GEN_PHY_H
+#define _TI_GEN_PHY_H
+
+int phy_dp83867_init(void);
+
+#endif /* _TI_GEN_PHY_H */
--
cgit v1.1
From 8882238cc4c1276629c989ea1fe71b15358a5040 Mon Sep 17 00:00:00 2001
From: Dan Murphy
Date: Mon, 4 May 2020 16:14:40 -0500
Subject: net: phy: Add DP8382x phy registration to TI PHY init
Add the DP8382X generic PHY registration to the TI PHY init file.
Acked-by: Michal Simek
Signed-off-by: Dan Murphy
---
drivers/net/phy/Kconfig | 7 ++++
drivers/net/phy/ti_phy_init.c | 83 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
(limited to 'drivers')
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index a5a1ff2..b0bd762 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -252,6 +252,13 @@ config PHY_TI_DP83867
---help---
Adds support for the TI DP83867 1Gbit PHY.
+config PHY_TI_GENERIC
+ select PHY_TI
+ bool "Texas Instruments Generic Ethernet PHYs support"
+ ---help---
+ Adds support for Generic TI PHYs that don't need special handling but
+ the PHY name is associated with a PHY ID.
+
config PHY_VITESSE
bool "Vitesse Ethernet PHYs support"
diff --git a/drivers/net/phy/ti_phy_init.c b/drivers/net/phy/ti_phy_init.c
index 277b29a..50eff77 100644
--- a/drivers/net/phy/ti_phy_init.c
+++ b/drivers/net/phy/ti_phy_init.c
@@ -7,12 +7,95 @@
* Copyright (C) 2019-20 Texas Instruments Inc.
*/
+#include
#include "ti_phy_init.h"
+#ifdef CONFIG_PHY_TI_GENERIC
+static struct phy_driver dp83822_driver = {
+ .name = "TI DP83822",
+ .uid = 0x2000a240,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver dp83826nc_driver = {
+ .name = "TI DP83826NC",
+ .uid = 0x2000a110,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver dp83826c_driver = {
+ .name = "TI DP83826C",
+ .uid = 0x2000a130,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver dp83825s_driver = {
+ .name = "TI DP83825S",
+ .uid = 0x2000a140,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver dp83825i_driver = {
+ .name = "TI DP83825I",
+ .uid = 0x2000a150,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver dp83825m_driver = {
+ .name = "TI DP83825M",
+ .uid = 0x2000a160,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver dp83825cs_driver = {
+ .name = "TI DP83825CS",
+ .uid = 0x2000a170,
+ .mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .config = &genphy_config_aneg,
+ .startup = &genphy_startup,
+ .shutdown = &genphy_shutdown,
+};
+#endif /* CONFIG_PHY_TI_GENERIC */
+
int phy_ti_init(void)
{
#ifdef CONFIG_PHY_TI_DP83867
phy_dp83867_init();
#endif
+
+#ifdef CONFIG_PHY_TI_GENERIC
+ phy_register(&dp83822_driver);
+ phy_register(&dp83825s_driver);
+ phy_register(&dp83825i_driver);
+ phy_register(&dp83825m_driver);
+ phy_register(&dp83825cs_driver);
+ phy_register(&dp83826c_driver);
+ phy_register(&dp83826nc_driver);
+#endif
return 0;
}
--
cgit v1.1
From 9962dd25b1e228c5c8f0b33ef89c48093ca2a311 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:35 +0200
Subject: net: rtl8139: Factor out device name assignment
Pull the device name setting into a separate function, as this
will be shared between DM/non-DM variants.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index 0daeefa..cc7fcdf 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -524,6 +524,11 @@ static int rtl8139_bcast_addr(struct eth_device *dev, const u8 *bcast_mac,
return 0;
}
+static void rtl8139_name(char *str, int card_number)
+{
+ sprintf(str, "RTL8139#%u", card_number);
+}
+
static struct pci_device_id supported[] = {
{ PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139 },
{ PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_8139 },
@@ -556,7 +561,7 @@ int rtl8139_initialize(bd_t *bis)
}
memset(dev, 0, sizeof(*dev));
- sprintf(dev->name, "RTL8139#%d", card_number);
+ rtl8139_name(dev->name, card_number);
dev->priv = (void *)devno;
dev->iobase = (int)bus_to_phys(iobase);
--
cgit v1.1
From 1ba8d9844562c74f0d80423d5dac658291d6d2f1 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:36 +0200
Subject: net: rtl8139: Switch from malloc()+memset() to calloc()
Replace malloc()+memset() combination with calloc(), no functional change.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index cc7fcdf..4874c1a 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -554,12 +554,11 @@ int rtl8139_initialize(bd_t *bis)
debug("rtl8139: REALTEK RTL8139 @0x%x\n", iobase);
- dev = (struct eth_device *)malloc(sizeof(*dev));
+ dev = calloc(1, sizeof(*dev));
if (!dev) {
printf("Can not allocate memory of rtl8139\n");
break;
}
- memset(dev, 0, sizeof(*dev));
rtl8139_name(dev->name, card_number);
--
cgit v1.1
From f4385539f1a6b4def6bf74091a2bc11f574d3bd1 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:37 +0200
Subject: net: rtl8139: Use dev->iobase instead of custom ioaddr
Replace the use of custom static ioaddr variable with common dev->iobase,
no functional change.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 84 +++++++++++++++++++++++----------------------------
1 file changed, 38 insertions(+), 46 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index 4874c1a..f829e52 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -192,7 +192,6 @@
#define RTL_STS_RXSTATUSOK BIT(0)
static unsigned int cur_rx, cur_tx;
-static int ioaddr;
/* The RTL8139 can only transmit from a contiguous, aligned memory block. */
static unsigned char tx_buffer[TX_BUF_SIZE] __aligned(4);
@@ -223,42 +222,43 @@ static void rtl8139_eeprom_delay(uintptr_t regbase)
inl(regbase + RTL_REG_CFG9346);
}
-static int rtl8139_read_eeprom(unsigned int location, unsigned int addr_len)
+static int rtl8139_read_eeprom(struct eth_device *dev,
+ unsigned int location, unsigned int addr_len)
{
unsigned int read_cmd = location | (EE_READ_CMD << addr_len);
- uintptr_t ee_addr = ioaddr + RTL_REG_CFG9346;
+ uintptr_t ee_addr = dev->iobase + RTL_REG_CFG9346;
unsigned int retval = 0;
u8 dataval;
int i;
outb(EE_ENB & ~EE_CS, ee_addr);
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
/* Shift the read command bits out. */
for (i = 4 + addr_len; i >= 0; i--) {
dataval = (read_cmd & BIT(i)) ? EE_DATA_WRITE : 0;
outb(EE_ENB | dataval, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
outb(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
}
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
for (i = 16; i > 0; i--) {
outb(EE_ENB | EE_SHIFT_CLK, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
retval <<= 1;
retval |= inb(ee_addr) & EE_DATA_READ;
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
}
/* Terminate the EEPROM access. */
outb(~EE_CS, ee_addr);
- rtl8139_eeprom_delay(ioaddr);
+ rtl8139_eeprom_delay(dev->iobase);
return retval;
}
@@ -275,10 +275,10 @@ static void rtl8139_set_rx_mode(struct eth_device *dev)
RTL_REG_RXCONFIG_ACCEPTMULTICAST |
RTL_REG_RXCONFIG_ACCEPTMYPHYS;
- outl(rtl8139_rx_config | rx_mode, ioaddr + RTL_REG_RXCONFIG);
+ outl(rtl8139_rx_config | rx_mode, dev->iobase + RTL_REG_RXCONFIG);
- outl(0xffffffff, ioaddr + RTL_REG_MAR0 + 0);
- outl(0xffffffff, ioaddr + RTL_REG_MAR0 + 4);
+ outl(0xffffffff, dev->iobase + RTL_REG_MAR0 + 0);
+ outl(0xffffffff, dev->iobase + RTL_REG_MAR0 + 4);
}
static void rtl8139_hw_reset(struct eth_device *dev)
@@ -286,11 +286,11 @@ static void rtl8139_hw_reset(struct eth_device *dev)
u8 reg;
int i;
- outb(RTL_REG_CHIPCMD_CMDRESET, ioaddr + RTL_REG_CHIPCMD);
+ outb(RTL_REG_CHIPCMD_CMDRESET, dev->iobase + RTL_REG_CHIPCMD);
/* Give the chip 10ms to finish the reset. */
for (i = 0; i < 100; i++) {
- reg = inb(ioaddr + RTL_REG_CHIPCMD);
+ reg = inb(dev->iobase + RTL_REG_CHIPCMD);
if (!(reg & RTL_REG_CHIPCMD_CMDRESET))
break;
@@ -308,15 +308,15 @@ static void rtl8139_reset(struct eth_device *dev)
rtl8139_hw_reset(dev);
for (i = 0; i < ETH_ALEN; i++)
- outb(dev->enetaddr[i], ioaddr + RTL_REG_MAC0 + i);
+ outb(dev->enetaddr[i], dev->iobase + RTL_REG_MAC0 + i);
/* Must enable Tx/Rx before setting transfer thresholds! */
outb(RTL_REG_CHIPCMD_CMDRXENB | RTL_REG_CHIPCMD_CMDTXENB,
- ioaddr + RTL_REG_CHIPCMD);
+ dev->iobase + RTL_REG_CHIPCMD);
/* accept no frames yet! */
- outl(rtl8139_rx_config, ioaddr + RTL_REG_RXCONFIG);
- outl((TX_DMA_BURST << 8) | 0x03000000, ioaddr + RTL_REG_TXCONFIG);
+ outl(rtl8139_rx_config, dev->iobase + RTL_REG_RXCONFIG);
+ outl((TX_DMA_BURST << 8) | 0x03000000, dev->iobase + RTL_REG_TXCONFIG);
/*
* The Linux driver changes RTL_REG_CONFIG1 here to use a different
@@ -331,7 +331,7 @@ static void rtl8139_reset(struct eth_device *dev)
debug_cond(DEBUG_RX, "rx ring address is %p\n", rx_ring);
flush_cache((unsigned long)rx_ring, RX_BUF_LEN);
- outl(phys_to_bus((int)rx_ring), ioaddr + RTL_REG_RXBUF);
+ outl(phys_to_bus((int)rx_ring), dev->iobase + RTL_REG_RXBUF);
/*
* If we add multicast support, the RTL_REG_MAR0 register would have
@@ -340,17 +340,17 @@ static void rtl8139_reset(struct eth_device *dev)
* unicast.
*/
outb(RTL_REG_CHIPCMD_CMDRXENB | RTL_REG_CHIPCMD_CMDTXENB,
- ioaddr + RTL_REG_CHIPCMD);
+ dev->iobase + RTL_REG_CHIPCMD);
- outl(rtl8139_rx_config, ioaddr + RTL_REG_RXCONFIG);
+ outl(rtl8139_rx_config, dev->iobase + RTL_REG_RXCONFIG);
/* Start the chip's Tx and Rx process. */
- outl(0, ioaddr + RTL_REG_RXMISSED);
+ outl(0, dev->iobase + RTL_REG_RXMISSED);
rtl8139_set_rx_mode(dev);
/* Disable all known interrupts by setting the interrupt mask. */
- outw(0, ioaddr + RTL_REG_INTRMASK);
+ outw(0, dev->iobase + RTL_REG_INTRMASK);
}
static int rtl8139_send(struct eth_device *dev, void *packet, int length)
@@ -360,8 +360,6 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
unsigned int status;
int i = 0;
- ioaddr = dev->iobase;
-
memcpy(tx_buffer, packet, length);
debug_cond(DEBUG_TX, "sending %d bytes\n", len);
@@ -375,12 +373,12 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
flush_cache((unsigned long)tx_buffer, length);
outl(phys_to_bus((unsigned long)tx_buffer),
- ioaddr + RTL_REG_TXADDR0 + cur_tx * 4);
+ dev->iobase + RTL_REG_TXADDR0 + cur_tx * 4);
outl(((TX_FIFO_THRESH << 11) & 0x003f0000) | len,
- ioaddr + RTL_REG_TXSTATUS0 + cur_tx * 4);
+ dev->iobase + RTL_REG_TXSTATUS0 + cur_tx * 4);
do {
- status = inw(ioaddr + RTL_REG_INTRSTATUS);
+ status = inw(dev->iobase + RTL_REG_INTRSTATUS);
/*
* Only acknlowledge interrupt sources we can properly
* handle here - the RTL_REG_INTRSTATUS_RXOVERFLOW/
@@ -389,14 +387,14 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
*/
status &= RTL_REG_INTRSTATUS_TXOK | RTL_REG_INTRSTATUS_TXERR |
RTL_REG_INTRSTATUS_PCIERR;
- outw(status, ioaddr + RTL_REG_INTRSTATUS);
+ outw(status, dev->iobase + RTL_REG_INTRSTATUS);
if (status)
break;
udelay(10);
} while (i++ < RTL_TIMEOUT);
- txstatus = inl(ioaddr + RTL_REG_TXSTATUS0 + cur_tx * 4);
+ txstatus = inl(dev->iobase + RTL_REG_TXSTATUS0 + cur_tx * 4);
if (!(status & RTL_REG_INTRSTATUS_TXOK)) {
debug_cond(DEBUG_TX,
@@ -426,14 +424,12 @@ static int rtl8139_recv(struct eth_device *dev)
unsigned int status;
int length = 0;
- ioaddr = dev->iobase;
-
- if (inb(ioaddr + RTL_REG_CHIPCMD) & RTL_REG_CHIPCMD_RXBUFEMPTY)
+ if (inb(dev->iobase + RTL_REG_CHIPCMD) & RTL_REG_CHIPCMD_RXBUFEMPTY)
return 0;
- status = inw(ioaddr + RTL_REG_INTRSTATUS);
+ status = inw(dev->iobase + RTL_REG_INTRSTATUS);
/* See below for the rest of the interrupt acknowledges. */
- outw(status & ~rxstat, ioaddr + RTL_REG_INTRSTATUS);
+ outw(status & ~rxstat, dev->iobase + RTL_REG_INTRSTATUS);
debug_cond(DEBUG_RX, "%s: int %hX ", __func__, status);
@@ -474,13 +470,13 @@ static int rtl8139_recv(struct eth_device *dev)
flush_cache((unsigned long)rx_ring, RX_BUF_LEN);
cur_rx = ROUND(cur_rx + rx_size + 4, 4);
- outw(cur_rx - 16, ioaddr + RTL_REG_RXBUFPTR);
+ outw(cur_rx - 16, dev->iobase + RTL_REG_RXBUFPTR);
/*
* See RTL8139 Programming Guide V0.1 for the official handling of
* Rx overflow situations. The document itself contains basically
* no usable information, except for a few exception handling rules.
*/
- outw(status & rxstat, ioaddr + RTL_REG_INTRSTATUS);
+ outw(status & rxstat, dev->iobase + RTL_REG_INTRSTATUS);
return length;
}
@@ -491,18 +487,16 @@ static int rtl8139_init(struct eth_device *dev, bd_t *bis)
int addr_len, i;
u8 reg;
- ioaddr = dev->iobase;
-
/* Bring the chip out of low-power mode. */
- outb(0x00, ioaddr + RTL_REG_CONFIG1);
+ outb(0x00, dev->iobase + RTL_REG_CONFIG1);
- addr_len = rtl8139_read_eeprom(0, 8) == 0x8129 ? 8 : 6;
+ addr_len = rtl8139_read_eeprom(dev, 0, 8) == 0x8129 ? 8 : 6;
for (i = 0; i < 3; i++)
- *ap++ = le16_to_cpu(rtl8139_read_eeprom(i + 7, addr_len));
+ *ap++ = le16_to_cpu(rtl8139_read_eeprom(dev, i + 7, addr_len));
rtl8139_reset(dev);
- reg = inb(ioaddr + RTL_REG_MEDIASTATUS);
+ reg = inb(dev->iobase + RTL_REG_MEDIASTATUS);
if (reg & RTL_REG_MEDIASTATUS_MSRLINKFAIL) {
printf("Cable not connected or other link failure\n");
return -1;
@@ -513,8 +507,6 @@ static int rtl8139_init(struct eth_device *dev, bd_t *bis)
static void rtl8139_stop(struct eth_device *dev)
{
- ioaddr = dev->iobase;
-
rtl8139_hw_reset(dev);
}
--
cgit v1.1
From 8ff1d4a9c8e629253e43d9d04eccbfa773f81e83 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:38 +0200
Subject: net: rtl8139: Clean up bus_to_phys()/phys_to_bus() macros
These macros depended on the dev variable being declared wherever
they were used. This is wrong and will not work with DM anyway, so
pass only the PCI BFD into these macros, which fixes the dependency
and prepares them for DM support as well.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index f829e52..aa13740 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -96,8 +96,8 @@
#define DEBUG_TX 0 /* set to 1 to enable debug code */
#define DEBUG_RX 0 /* set to 1 to enable debug code */
-#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a)
-#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
+#define bus_to_phys(devno, a) pci_mem_to_phys((pci_dev_t)(devno), (a))
+#define phys_to_bus(devno, a) pci_phys_to_mem((pci_dev_t)(devno), (a))
/* Symbolic offsets to registers. */
/* Ethernet hardware address. */
@@ -331,7 +331,7 @@ static void rtl8139_reset(struct eth_device *dev)
debug_cond(DEBUG_RX, "rx ring address is %p\n", rx_ring);
flush_cache((unsigned long)rx_ring, RX_BUF_LEN);
- outl(phys_to_bus((int)rx_ring), dev->iobase + RTL_REG_RXBUF);
+ outl(phys_to_bus(dev->priv, (int)rx_ring), dev->iobase + RTL_REG_RXBUF);
/*
* If we add multicast support, the RTL_REG_MAR0 register would have
@@ -372,7 +372,7 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
tx_buffer[len++] = '\0';
flush_cache((unsigned long)tx_buffer, length);
- outl(phys_to_bus((unsigned long)tx_buffer),
+ outl(phys_to_bus(dev->priv, (unsigned long)tx_buffer),
dev->iobase + RTL_REG_TXADDR0 + cur_tx * 4);
outl(((TX_FIFO_THRESH << 11) & 0x003f0000) | len,
dev->iobase + RTL_REG_TXSTATUS0 + cur_tx * 4);
@@ -555,7 +555,7 @@ int rtl8139_initialize(bd_t *bis)
rtl8139_name(dev->name, card_number);
dev->priv = (void *)devno;
- dev->iobase = (int)bus_to_phys(iobase);
+ dev->iobase = (unsigned long)bus_to_phys(devno, iobase);
dev->init = rtl8139_init;
dev->halt = rtl8139_stop;
dev->send = rtl8139_send;
--
cgit v1.1
From 3feb6f7ff6856e1e903e5a62f6252d37731b6592 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:39 +0200
Subject: net: rtl8139: Introduce device private data
Introduce rtl8139_pdata, which is a super-structure around eth_device
and tracks per-device state, here the device IO address, PCI BDF, RX
and TX ring position. Pass this structure around instead of the old
non-DM eth_device in preparation for DM conversion.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 136 +++++++++++++++++++++++++++++---------------------
1 file changed, 78 insertions(+), 58 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index aa13740..dff77de 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -191,7 +191,14 @@
#define RTL_STS_RXBADALIGN BIT(1)
#define RTL_STS_RXSTATUSOK BIT(0)
-static unsigned int cur_rx, cur_tx;
+struct rtl8139_priv {
+ struct eth_device dev;
+ unsigned int cur_rx;
+ unsigned int cur_tx;
+ unsigned long ioaddr;
+ pci_dev_t devno;
+ unsigned char enetaddr[6];
+};
/* The RTL8139 can only transmit from a contiguous, aligned memory block. */
static unsigned char tx_buffer[TX_BUF_SIZE] __aligned(4);
@@ -222,43 +229,43 @@ static void rtl8139_eeprom_delay(uintptr_t regbase)
inl(regbase + RTL_REG_CFG9346);
}
-static int rtl8139_read_eeprom(struct eth_device *dev,
+static int rtl8139_read_eeprom(struct rtl8139_priv *priv,
unsigned int location, unsigned int addr_len)
{
unsigned int read_cmd = location | (EE_READ_CMD << addr_len);
- uintptr_t ee_addr = dev->iobase + RTL_REG_CFG9346;
+ uintptr_t ee_addr = priv->ioaddr + RTL_REG_CFG9346;
unsigned int retval = 0;
u8 dataval;
int i;
outb(EE_ENB & ~EE_CS, ee_addr);
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
/* Shift the read command bits out. */
for (i = 4 + addr_len; i >= 0; i--) {
dataval = (read_cmd & BIT(i)) ? EE_DATA_WRITE : 0;
outb(EE_ENB | dataval, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
outb(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
}
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
for (i = 16; i > 0; i--) {
outb(EE_ENB | EE_SHIFT_CLK, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
retval <<= 1;
retval |= inb(ee_addr) & EE_DATA_READ;
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
}
/* Terminate the EEPROM access. */
outb(~EE_CS, ee_addr);
- rtl8139_eeprom_delay(dev->iobase);
+ rtl8139_eeprom_delay(priv->ioaddr);
return retval;
}
@@ -268,29 +275,29 @@ static const unsigned int rtl8139_rx_config =
(RX_FIFO_THRESH << 13) |
(RX_DMA_BURST << 8);
-static void rtl8139_set_rx_mode(struct eth_device *dev)
+static void rtl8139_set_rx_mode(struct rtl8139_priv *priv)
{
/* !IFF_PROMISC */
unsigned int rx_mode = RTL_REG_RXCONFIG_ACCEPTBROADCAST |
RTL_REG_RXCONFIG_ACCEPTMULTICAST |
RTL_REG_RXCONFIG_ACCEPTMYPHYS;
- outl(rtl8139_rx_config | rx_mode, dev->iobase + RTL_REG_RXCONFIG);
+ outl(rtl8139_rx_config | rx_mode, priv->ioaddr + RTL_REG_RXCONFIG);
- outl(0xffffffff, dev->iobase + RTL_REG_MAR0 + 0);
- outl(0xffffffff, dev->iobase + RTL_REG_MAR0 + 4);
+ outl(0xffffffff, priv->ioaddr + RTL_REG_MAR0 + 0);
+ outl(0xffffffff, priv->ioaddr + RTL_REG_MAR0 + 4);
}
-static void rtl8139_hw_reset(struct eth_device *dev)
+static void rtl8139_hw_reset(struct rtl8139_priv *priv)
{
u8 reg;
int i;
- outb(RTL_REG_CHIPCMD_CMDRESET, dev->iobase + RTL_REG_CHIPCMD);
+ outb(RTL_REG_CHIPCMD_CMDRESET, priv->ioaddr + RTL_REG_CHIPCMD);
/* Give the chip 10ms to finish the reset. */
for (i = 0; i < 100; i++) {
- reg = inb(dev->iobase + RTL_REG_CHIPCMD);
+ reg = inb(priv->ioaddr + RTL_REG_CHIPCMD);
if (!(reg & RTL_REG_CHIPCMD_CMDRESET))
break;
@@ -298,25 +305,25 @@ static void rtl8139_hw_reset(struct eth_device *dev)
}
}
-static void rtl8139_reset(struct eth_device *dev)
+static void rtl8139_reset(struct rtl8139_priv *priv)
{
int i;
- cur_rx = 0;
- cur_tx = 0;
+ priv->cur_rx = 0;
+ priv->cur_tx = 0;
- rtl8139_hw_reset(dev);
+ rtl8139_hw_reset(priv);
for (i = 0; i < ETH_ALEN; i++)
- outb(dev->enetaddr[i], dev->iobase + RTL_REG_MAC0 + i);
+ outb(priv->enetaddr[i], priv->ioaddr + RTL_REG_MAC0 + i);
/* Must enable Tx/Rx before setting transfer thresholds! */
outb(RTL_REG_CHIPCMD_CMDRXENB | RTL_REG_CHIPCMD_CMDTXENB,
- dev->iobase + RTL_REG_CHIPCMD);
+ priv->ioaddr + RTL_REG_CHIPCMD);
/* accept no frames yet! */
- outl(rtl8139_rx_config, dev->iobase + RTL_REG_RXCONFIG);
- outl((TX_DMA_BURST << 8) | 0x03000000, dev->iobase + RTL_REG_TXCONFIG);
+ outl(rtl8139_rx_config, priv->ioaddr + RTL_REG_RXCONFIG);
+ outl((TX_DMA_BURST << 8) | 0x03000000, priv->ioaddr + RTL_REG_TXCONFIG);
/*
* The Linux driver changes RTL_REG_CONFIG1 here to use a different
@@ -331,7 +338,7 @@ static void rtl8139_reset(struct eth_device *dev)
debug_cond(DEBUG_RX, "rx ring address is %p\n", rx_ring);
flush_cache((unsigned long)rx_ring, RX_BUF_LEN);
- outl(phys_to_bus(dev->priv, (int)rx_ring), dev->iobase + RTL_REG_RXBUF);
+ outl(phys_to_bus(priv->devno, (int)rx_ring), priv->ioaddr + RTL_REG_RXBUF);
/*
* If we add multicast support, the RTL_REG_MAR0 register would have
@@ -340,21 +347,22 @@ static void rtl8139_reset(struct eth_device *dev)
* unicast.
*/
outb(RTL_REG_CHIPCMD_CMDRXENB | RTL_REG_CHIPCMD_CMDTXENB,
- dev->iobase + RTL_REG_CHIPCMD);
+ priv->ioaddr + RTL_REG_CHIPCMD);
- outl(rtl8139_rx_config, dev->iobase + RTL_REG_RXCONFIG);
+ outl(rtl8139_rx_config, priv->ioaddr + RTL_REG_RXCONFIG);
/* Start the chip's Tx and Rx process. */
- outl(0, dev->iobase + RTL_REG_RXMISSED);
+ outl(0, priv->ioaddr + RTL_REG_RXMISSED);
- rtl8139_set_rx_mode(dev);
+ rtl8139_set_rx_mode(priv);
/* Disable all known interrupts by setting the interrupt mask. */
- outw(0, dev->iobase + RTL_REG_INTRMASK);
+ outw(0, priv->ioaddr + RTL_REG_INTRMASK);
}
static int rtl8139_send(struct eth_device *dev, void *packet, int length)
{
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
unsigned int len = length;
unsigned long txstatus;
unsigned int status;
@@ -372,13 +380,13 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
tx_buffer[len++] = '\0';
flush_cache((unsigned long)tx_buffer, length);
- outl(phys_to_bus(dev->priv, (unsigned long)tx_buffer),
- dev->iobase + RTL_REG_TXADDR0 + cur_tx * 4);
+ outl(phys_to_bus(priv->devno, (unsigned long)tx_buffer),
+ priv->ioaddr + RTL_REG_TXADDR0 + priv->cur_tx * 4);
outl(((TX_FIFO_THRESH << 11) & 0x003f0000) | len,
- dev->iobase + RTL_REG_TXSTATUS0 + cur_tx * 4);
+ priv->ioaddr + RTL_REG_TXSTATUS0 + priv->cur_tx * 4);
do {
- status = inw(dev->iobase + RTL_REG_INTRSTATUS);
+ status = inw(priv->ioaddr + RTL_REG_INTRSTATUS);
/*
* Only acknlowledge interrupt sources we can properly
* handle here - the RTL_REG_INTRSTATUS_RXOVERFLOW/
@@ -387,26 +395,26 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
*/
status &= RTL_REG_INTRSTATUS_TXOK | RTL_REG_INTRSTATUS_TXERR |
RTL_REG_INTRSTATUS_PCIERR;
- outw(status, dev->iobase + RTL_REG_INTRSTATUS);
+ outw(status, priv->ioaddr + RTL_REG_INTRSTATUS);
if (status)
break;
udelay(10);
} while (i++ < RTL_TIMEOUT);
- txstatus = inl(dev->iobase + RTL_REG_TXSTATUS0 + cur_tx * 4);
+ txstatus = inl(priv->ioaddr + RTL_REG_TXSTATUS0 + priv->cur_tx * 4);
if (!(status & RTL_REG_INTRSTATUS_TXOK)) {
debug_cond(DEBUG_TX,
"tx timeout/error (%d usecs), status %hX txstatus %lX\n",
10 * i, status, txstatus);
- rtl8139_reset(dev);
+ rtl8139_reset(priv);
return 0;
}
- cur_tx = (cur_tx + 1) % NUM_TX_DESC;
+ priv->cur_tx = (priv->cur_tx + 1) % NUM_TX_DESC;
debug_cond(DEBUG_TX, "tx done, status %hX txstatus %lX\n",
status, txstatus);
@@ -416,6 +424,7 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
static int rtl8139_recv(struct eth_device *dev)
{
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
const unsigned int rxstat = RTL_REG_INTRSTATUS_RXFIFOOVER |
RTL_REG_INTRSTATUS_RXOVERFLOW |
RTL_REG_INTRSTATUS_RXOK;
@@ -424,16 +433,16 @@ static int rtl8139_recv(struct eth_device *dev)
unsigned int status;
int length = 0;
- if (inb(dev->iobase + RTL_REG_CHIPCMD) & RTL_REG_CHIPCMD_RXBUFEMPTY)
+ if (inb(priv->ioaddr + RTL_REG_CHIPCMD) & RTL_REG_CHIPCMD_RXBUFEMPTY)
return 0;
- status = inw(dev->iobase + RTL_REG_INTRSTATUS);
+ status = inw(priv->ioaddr + RTL_REG_INTRSTATUS);
/* See below for the rest of the interrupt acknowledges. */
- outw(status & ~rxstat, dev->iobase + RTL_REG_INTRSTATUS);
+ outw(status & ~rxstat, priv->ioaddr + RTL_REG_INTRSTATUS);
debug_cond(DEBUG_RX, "%s: int %hX ", __func__, status);
- ring_offs = cur_rx % RX_BUF_LEN;
+ ring_offs = priv->cur_rx % RX_BUF_LEN;
/* ring_offs is guaranteed being 4-byte aligned */
rx_status = le32_to_cpu(*(unsigned int *)(rx_ring + ring_offs));
rx_size = rx_status >> 16;
@@ -446,7 +455,7 @@ static int rtl8139_recv(struct eth_device *dev)
(rx_size > ETH_FRAME_LEN + 4)) {
printf("rx error %hX\n", rx_status);
/* this clears all interrupts still pending */
- rtl8139_reset(dev);
+ rtl8139_reset(priv);
return 0;
}
@@ -469,45 +478,51 @@ static int rtl8139_recv(struct eth_device *dev)
}
flush_cache((unsigned long)rx_ring, RX_BUF_LEN);
- cur_rx = ROUND(cur_rx + rx_size + 4, 4);
- outw(cur_rx - 16, dev->iobase + RTL_REG_RXBUFPTR);
+ priv->cur_rx = ROUND(priv->cur_rx + rx_size + 4, 4);
+ outw(priv->cur_rx - 16, priv->ioaddr + RTL_REG_RXBUFPTR);
/*
* See RTL8139 Programming Guide V0.1 for the official handling of
* Rx overflow situations. The document itself contains basically
* no usable information, except for a few exception handling rules.
*/
- outw(status & rxstat, dev->iobase + RTL_REG_INTRSTATUS);
+ outw(status & rxstat, priv->ioaddr + RTL_REG_INTRSTATUS);
return length;
}
static int rtl8139_init(struct eth_device *dev, bd_t *bis)
{
- unsigned short *ap = (unsigned short *)dev->enetaddr;
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
+ unsigned short *ap = (unsigned short *)priv->enetaddr;
int addr_len, i;
u8 reg;
/* Bring the chip out of low-power mode. */
- outb(0x00, dev->iobase + RTL_REG_CONFIG1);
+ outb(0x00, priv->ioaddr + RTL_REG_CONFIG1);
- addr_len = rtl8139_read_eeprom(dev, 0, 8) == 0x8129 ? 8 : 6;
+ addr_len = rtl8139_read_eeprom(priv, 0, 8) == 0x8129 ? 8 : 6;
for (i = 0; i < 3; i++)
- *ap++ = le16_to_cpu(rtl8139_read_eeprom(dev, i + 7, addr_len));
+ *ap++ = le16_to_cpu(rtl8139_read_eeprom(priv, i + 7, addr_len));
- rtl8139_reset(dev);
+ rtl8139_reset(priv);
- reg = inb(dev->iobase + RTL_REG_MEDIASTATUS);
+ reg = inb(priv->ioaddr + RTL_REG_MEDIASTATUS);
if (reg & RTL_REG_MEDIASTATUS_MSRLINKFAIL) {
printf("Cable not connected or other link failure\n");
return -1;
}
+ /* Non-DM compatibility */
+ memcpy(priv->dev.enetaddr, priv->enetaddr, 6);
+
return 0;
}
static void rtl8139_stop(struct eth_device *dev)
{
- rtl8139_hw_reset(dev);
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
+
+ rtl8139_hw_reset(priv);
}
static int rtl8139_bcast_addr(struct eth_device *dev, const u8 *bcast_mac,
@@ -529,6 +544,7 @@ static struct pci_device_id supported[] = {
int rtl8139_initialize(bd_t *bis)
{
+ struct rtl8139_priv *priv;
struct eth_device *dev;
int card_number = 0;
pci_dev_t devno;
@@ -546,16 +562,20 @@ int rtl8139_initialize(bd_t *bis)
debug("rtl8139: REALTEK RTL8139 @0x%x\n", iobase);
- dev = calloc(1, sizeof(*dev));
- if (!dev) {
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
printf("Can not allocate memory of rtl8139\n");
break;
}
+ priv->devno = devno;
+ priv->ioaddr = (unsigned long)bus_to_phys(devno, iobase);
+
+ dev = &priv->dev;
+
rtl8139_name(dev->name, card_number);
- dev->priv = (void *)devno;
- dev->iobase = (unsigned long)bus_to_phys(devno, iobase);
+ dev->iobase = priv->ioaddr; /* Non-DM compatibility */
dev->init = rtl8139_init;
dev->halt = rtl8139_stop;
dev->send = rtl8139_send;
--
cgit v1.1
From 26f59c28bdea91617b3acfd132d5affc55e1ef4a Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:40 +0200
Subject: net: rtl8139: Pass private data into rtl8139_eeprom_delay()
Instead of always calling rtl8139_eeprom_delay() with priv->ioaddr,
call it with priv and let the function access priv->ioaddr. This
reduces code duplication and has no impact, since the compiler will
inline this as needed anyway.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index dff77de..ae5d125 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -220,13 +220,13 @@ static unsigned char rx_ring[RX_BUF_LEN + 16] __aligned(4);
#define EE_READ_CMD 6
#define EE_ERASE_CMD 7
-static void rtl8139_eeprom_delay(uintptr_t regbase)
+static void rtl8139_eeprom_delay(struct rtl8139_priv *priv)
{
/*
* Delay between EEPROM clock transitions.
* No extra delay is needed with 33MHz PCI, but 66MHz may change this.
*/
- inl(regbase + RTL_REG_CFG9346);
+ inl(priv->ioaddr + RTL_REG_CFG9346);
}
static int rtl8139_read_eeprom(struct rtl8139_priv *priv,
@@ -240,32 +240,32 @@ static int rtl8139_read_eeprom(struct rtl8139_priv *priv,
outb(EE_ENB & ~EE_CS, ee_addr);
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
/* Shift the read command bits out. */
for (i = 4 + addr_len; i >= 0; i--) {
dataval = (read_cmd & BIT(i)) ? EE_DATA_WRITE : 0;
outb(EE_ENB | dataval, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
outb(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
}
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
for (i = 16; i > 0; i--) {
outb(EE_ENB | EE_SHIFT_CLK, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
retval <<= 1;
retval |= inb(ee_addr) & EE_DATA_READ;
outb(EE_ENB, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
}
/* Terminate the EEPROM access. */
outb(~EE_CS, ee_addr);
- rtl8139_eeprom_delay(priv->ioaddr);
+ rtl8139_eeprom_delay(priv);
return retval;
}
--
cgit v1.1
From 6a4a5c194df8af25390f4ba30250a76fc0256643 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:41 +0200
Subject: net: rtl8139: Split out common and non-DM functions
Split the driver into common and non-DM functionality, so that the
DM support can later re-use the common code, while we retain the
non-DM code until all the platforms are converted.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 92 +++++++++++++++++++++++++++++++++++++--------------
1 file changed, 68 insertions(+), 24 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index ae5d125..70b09fb 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -193,6 +193,7 @@
struct rtl8139_priv {
struct eth_device dev;
+ unsigned int rxstatus;
unsigned int cur_rx;
unsigned int cur_tx;
unsigned long ioaddr;
@@ -360,9 +361,9 @@ static void rtl8139_reset(struct rtl8139_priv *priv)
outw(0, priv->ioaddr + RTL_REG_INTRMASK);
}
-static int rtl8139_send(struct eth_device *dev, void *packet, int length)
+static int rtl8139_send_common(struct rtl8139_priv *priv,
+ void *packet, int length)
{
- struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
unsigned int len = length;
unsigned long txstatus;
unsigned int status;
@@ -422,25 +423,24 @@ static int rtl8139_send(struct eth_device *dev, void *packet, int length)
return length;
}
-static int rtl8139_recv(struct eth_device *dev)
+static int rtl8139_recv_common(struct rtl8139_priv *priv, unsigned char *rxdata,
+ uchar **packetp)
{
- struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
const unsigned int rxstat = RTL_REG_INTRSTATUS_RXFIFOOVER |
RTL_REG_INTRSTATUS_RXOVERFLOW |
RTL_REG_INTRSTATUS_RXOK;
unsigned int rx_size, rx_status;
unsigned int ring_offs;
- unsigned int status;
int length = 0;
if (inb(priv->ioaddr + RTL_REG_CHIPCMD) & RTL_REG_CHIPCMD_RXBUFEMPTY)
return 0;
- status = inw(priv->ioaddr + RTL_REG_INTRSTATUS);
+ priv->rxstatus = inw(priv->ioaddr + RTL_REG_INTRSTATUS);
/* See below for the rest of the interrupt acknowledges. */
- outw(status & ~rxstat, priv->ioaddr + RTL_REG_INTRSTATUS);
+ outw(priv->rxstatus & ~rxstat, priv->ioaddr + RTL_REG_INTRSTATUS);
- debug_cond(DEBUG_RX, "%s: int %hX ", __func__, status);
+ debug_cond(DEBUG_RX, "%s: int %hX ", __func__, priv->rxstatus);
ring_offs = priv->cur_rx % RX_BUF_LEN;
/* ring_offs is guaranteed being 4-byte aligned */
@@ -462,20 +462,30 @@ static int rtl8139_recv(struct eth_device *dev)
/* Received a good packet */
length = rx_size - 4; /* no one cares about the FCS */
if (ring_offs + 4 + rx_size - 4 > RX_BUF_LEN) {
- unsigned char rxdata[RX_BUF_LEN];
int semi_count = RX_BUF_LEN - ring_offs - 4;
memcpy(rxdata, rx_ring + ring_offs + 4, semi_count);
memcpy(&rxdata[semi_count], rx_ring,
rx_size - 4 - semi_count);
- net_process_received_packet(rxdata, length);
+ *packetp = rxdata;
debug_cond(DEBUG_RX, "rx packet %d+%d bytes",
semi_count, rx_size - 4 - semi_count);
} else {
- net_process_received_packet(rx_ring + ring_offs + 4, length);
+ *packetp = rx_ring + ring_offs + 4;
debug_cond(DEBUG_RX, "rx packet %d bytes", rx_size - 4);
}
+
+ return length;
+}
+
+static int rtl8139_free_pkt_common(struct rtl8139_priv *priv, unsigned int len)
+{
+ const unsigned int rxstat = RTL_REG_INTRSTATUS_RXFIFOOVER |
+ RTL_REG_INTRSTATUS_RXOVERFLOW |
+ RTL_REG_INTRSTATUS_RXOK;
+ unsigned int rx_size = len + 4;
+
flush_cache((unsigned long)rx_ring, RX_BUF_LEN);
priv->cur_rx = ROUND(priv->cur_rx + rx_size + 4, 4);
@@ -485,14 +495,13 @@ static int rtl8139_recv(struct eth_device *dev)
* Rx overflow situations. The document itself contains basically
* no usable information, except for a few exception handling rules.
*/
- outw(status & rxstat, priv->ioaddr + RTL_REG_INTRSTATUS);
+ outw(priv->rxstatus & rxstat, priv->ioaddr + RTL_REG_INTRSTATUS);
- return length;
+ return 0;
}
-static int rtl8139_init(struct eth_device *dev, bd_t *bis)
+static int rtl8139_init_common(struct rtl8139_priv *priv)
{
- struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
unsigned short *ap = (unsigned short *)priv->enetaddr;
int addr_len, i;
u8 reg;
@@ -518,19 +527,11 @@ static int rtl8139_init(struct eth_device *dev, bd_t *bis)
return 0;
}
-static void rtl8139_stop(struct eth_device *dev)
+static void rtl8139_stop_common(struct rtl8139_priv *priv)
{
- struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
-
rtl8139_hw_reset(priv);
}
-static int rtl8139_bcast_addr(struct eth_device *dev, const u8 *bcast_mac,
- int join)
-{
- return 0;
-}
-
static void rtl8139_name(char *str, int card_number)
{
sprintf(str, "RTL8139#%u", card_number);
@@ -542,6 +543,49 @@ static struct pci_device_id supported[] = {
{ }
};
+static int rtl8139_bcast_addr(struct eth_device *dev, const u8 *bcast_mac,
+ int join)
+{
+ return 0;
+}
+
+static int rtl8139_init(struct eth_device *dev, bd_t *bis)
+{
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
+
+ return rtl8139_init_common(priv);
+}
+
+static void rtl8139_stop(struct eth_device *dev)
+{
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
+
+ return rtl8139_stop_common(priv);
+}
+
+static int rtl8139_send(struct eth_device *dev, void *packet, int length)
+{
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
+
+ return rtl8139_send_common(priv, packet, length);
+}
+
+static int rtl8139_recv(struct eth_device *dev)
+{
+ struct rtl8139_priv *priv = container_of(dev, struct rtl8139_priv, dev);
+ unsigned char rxdata[RX_BUF_LEN];
+ uchar *packet;
+ int ret;
+
+ ret = rtl8139_recv_common(priv, rxdata, &packet);
+ if (ret) {
+ net_process_received_packet(packet, ret);
+ rtl8139_free_pkt_common(priv, ret);
+ }
+
+ return ret;
+}
+
int rtl8139_initialize(bd_t *bis)
{
struct rtl8139_priv *priv;
--
cgit v1.1
From 2df3a51510758dc6208ecf36f5e4b929d01f2dd1 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:42 +0200
Subject: net: rtl8139: Use PCI_DEVICE() to define PCI device compat list
Use this macro to fully fill the PCI device ID table. This is mandatory
for the DM PCI support, which checks all the fields.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index 70b09fb..f319017 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -538,8 +538,8 @@ static void rtl8139_name(char *str, int card_number)
}
static struct pci_device_id supported[] = {
- { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139 },
- { PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_8139 },
+ { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_8139) },
{ }
};
--
cgit v1.1
From d8afb8b28efb5af640d693e7f848732141482cfb Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:43 +0200
Subject: net: rtl8139: Read HW address from EEPROM only on probe
Do not re-read the HW address from the EEPROM on every start of
transfer, otherwise the user will not be able to adjust ethaddr
as needed. Read the address only once, when the card is detected.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index f319017..d7fabdb 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -502,17 +502,11 @@ static int rtl8139_free_pkt_common(struct rtl8139_priv *priv, unsigned int len)
static int rtl8139_init_common(struct rtl8139_priv *priv)
{
- unsigned short *ap = (unsigned short *)priv->enetaddr;
- int addr_len, i;
u8 reg;
/* Bring the chip out of low-power mode. */
outb(0x00, priv->ioaddr + RTL_REG_CONFIG1);
- addr_len = rtl8139_read_eeprom(priv, 0, 8) == 0x8129 ? 8 : 6;
- for (i = 0; i < 3; i++)
- *ap++ = le16_to_cpu(rtl8139_read_eeprom(priv, i + 7, addr_len));
-
rtl8139_reset(priv);
reg = inb(priv->ioaddr + RTL_REG_MEDIASTATUS);
@@ -521,9 +515,6 @@ static int rtl8139_init_common(struct rtl8139_priv *priv)
return -1;
}
- /* Non-DM compatibility */
- memcpy(priv->dev.enetaddr, priv->enetaddr, 6);
-
return 0;
}
@@ -532,6 +523,19 @@ static void rtl8139_stop_common(struct rtl8139_priv *priv)
rtl8139_hw_reset(priv);
}
+static void rtl8139_get_hwaddr(struct rtl8139_priv *priv)
+{
+ unsigned short *ap = (unsigned short *)priv->enetaddr;
+ int i, addr_len;
+
+ /* Bring the chip out of low-power mode. */
+ outb(0x00, priv->ioaddr + RTL_REG_CONFIG1);
+
+ addr_len = rtl8139_read_eeprom(priv, 0, 8) == 0x8129 ? 8 : 6;
+ for (i = 0; i < 3; i++)
+ *ap++ = le16_to_cpu(rtl8139_read_eeprom(priv, i + 7, addr_len));
+}
+
static void rtl8139_name(char *str, int card_number)
{
sprintf(str, "RTL8139#%u", card_number);
@@ -626,6 +630,11 @@ int rtl8139_initialize(bd_t *bis)
dev->recv = rtl8139_recv;
dev->mcast = rtl8139_bcast_addr;
+ rtl8139_get_hwaddr(priv);
+
+ /* Non-DM compatibility */
+ memcpy(priv->dev.enetaddr, priv->enetaddr, 6);
+
eth_register(dev);
card_number++;
--
cgit v1.1
From 46c8b18734d273619174006eef498639c06000d3 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 9 May 2020 22:34:44 +0200
Subject: net: rtl8139: Add DM support
Add support for driver model to the driver.
Signed-off-by: Marek Vasut
Cc: Joe Hershberger
---
drivers/net/rtl8139.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 132 insertions(+), 1 deletion(-)
(limited to 'drivers')
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c
index d7fabdb..8a6f305 100644
--- a/drivers/net/rtl8139.c
+++ b/drivers/net/rtl8139.c
@@ -70,6 +70,7 @@
#include
#include
+#include
#include
#include
#include
@@ -96,8 +97,13 @@
#define DEBUG_TX 0 /* set to 1 to enable debug code */
#define DEBUG_RX 0 /* set to 1 to enable debug code */
+#ifdef CONFIG_DM_ETH
+#define bus_to_phys(devno, a) dm_pci_mem_to_phys((devno), (a))
+#define phys_to_bus(devno, a) dm_pci_phys_to_mem((devno), (a))
+#else
#define bus_to_phys(devno, a) pci_mem_to_phys((pci_dev_t)(devno), (a))
#define phys_to_bus(devno, a) pci_phys_to_mem((pci_dev_t)(devno), (a))
+#endif
/* Symbolic offsets to registers. */
/* Ethernet hardware address. */
@@ -192,12 +198,16 @@
#define RTL_STS_RXSTATUSOK BIT(0)
struct rtl8139_priv {
+#ifndef CONFIG_DM_ETH
struct eth_device dev;
+ pci_dev_t devno;
+#else
+ struct udevice *devno;
+#endif
unsigned int rxstatus;
unsigned int cur_rx;
unsigned int cur_tx;
unsigned long ioaddr;
- pci_dev_t devno;
unsigned char enetaddr[6];
};
@@ -547,6 +557,7 @@ static struct pci_device_id supported[] = {
{ }
};
+#ifndef CONFIG_DM_ETH
static int rtl8139_bcast_addr(struct eth_device *dev, const u8 *bcast_mac,
int join)
{
@@ -646,3 +657,123 @@ int rtl8139_initialize(bd_t *bis)
return card_number;
}
+#else /* DM_ETH */
+static int rtl8139_start(struct udevice *dev)
+{
+ struct eth_pdata *plat = dev_get_platdata(dev);
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+
+ memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr));
+
+ return rtl8139_init_common(priv);
+}
+
+static void rtl8139_stop(struct udevice *dev)
+{
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+
+ rtl8139_stop_common(priv);
+}
+
+static int rtl8139_send(struct udevice *dev, void *packet, int length)
+{
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ ret = rtl8139_send_common(priv, packet, length);
+
+ return ret ? 0 : -ETIMEDOUT;
+}
+
+static int rtl8139_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+ static unsigned char rxdata[RX_BUF_LEN];
+
+ return rtl8139_recv_common(priv, rxdata, packetp);
+}
+
+static int rtl8139_free_pkt(struct udevice *dev, uchar *packet, int length)
+{
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+
+ rtl8139_free_pkt_common(priv, length);
+
+ return 0;
+}
+
+static int rtl8139_write_hwaddr(struct udevice *dev)
+{
+ struct eth_pdata *plat = dev_get_platdata(dev);
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+
+ memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr));
+
+ rtl8139_reset(priv);
+
+ return 0;
+}
+
+static int rtl8139_read_rom_hwaddr(struct udevice *dev)
+{
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+
+ rtl8139_get_hwaddr(priv);
+
+ return 0;
+}
+
+static int rtl8139_bind(struct udevice *dev)
+{
+ static int card_number;
+ char name[16];
+
+ rtl8139_name(name, card_number++);
+
+ return device_set_name(dev, name);
+}
+
+static int rtl8139_probe(struct udevice *dev)
+{
+ struct eth_pdata *plat = dev_get_platdata(dev);
+ struct rtl8139_priv *priv = dev_get_priv(dev);
+ u32 iobase;
+
+ dm_pci_read_config32(dev, PCI_BASE_ADDRESS_1, &iobase);
+ iobase &= ~0xf;
+
+ debug("rtl8139: REALTEK RTL8139 @0x%x\n", iobase);
+
+ priv->devno = dev;
+ priv->ioaddr = (unsigned long)bus_to_phys(dev, iobase);
+
+ rtl8139_get_hwaddr(priv);
+ memcpy(plat->enetaddr, priv->enetaddr, sizeof(priv->enetaddr));
+
+ dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x20);
+
+ return 0;
+}
+
+static const struct eth_ops rtl8139_ops = {
+ .start = rtl8139_start,
+ .send = rtl8139_send,
+ .recv = rtl8139_recv,
+ .stop = rtl8139_stop,
+ .free_pkt = rtl8139_free_pkt,
+ .write_hwaddr = rtl8139_write_hwaddr,
+ .read_rom_hwaddr = rtl8139_read_rom_hwaddr,
+};
+
+U_BOOT_DRIVER(eth_rtl8139) = {
+ .name = "eth_rtl8139",
+ .id = UCLASS_ETH,
+ .bind = rtl8139_bind,
+ .probe = rtl8139_probe,
+ .ops = &rtl8139_ops,
+ .priv_auto_alloc_size = sizeof(struct rtl8139_priv),
+ .platdata_auto_alloc_size = sizeof(struct eth_pdata),
+};
+
+U_BOOT_PCI_DEVICE(eth_rtl8139, supported);
+#endif
--
cgit v1.1
From c78ae11e07d84c10ad5ee91593e49fcf20b07359 Mon Sep 17 00:00:00 2001
From: Faiz Abbas
Date: Fri, 22 May 2020 07:32:28 +0530
Subject: mmc: davinci_mmc: Cleanup to use dt in U-boot and static platdata in
SPL
Cleanup this driver to use dt in U-boot and static platdata in SPL.
This requires the following steps:
1. Move all platdata assignment from probe() to ofdata_to_platdata().
This function is only called in U-boot.
2. Replicate all the platdata assignment being done in
ofdata_to_platdata() in the omapl138 board file. This data is used in
the SPL case where SPL_OF_CONTROL is not enabled.
3. Remove SPL_OF_CONTROL and related configs from omapl138_lcdk_defconfig
This cleanup effectively reverts 3ef94715cc ('mmc: davinci: fix mmc boot in SPL')
Signed-off-by: Faiz Abbas
Tested-by: Bartosz Golaszewski
---
drivers/mmc/davinci_mmc.c | 63 +++++++++++++++++++----------------------------
1 file changed, 26 insertions(+), 37 deletions(-)
(limited to 'drivers')
diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c
index 2408a68..4ef9f7c 100644
--- a/drivers/mmc/davinci_mmc.c
+++ b/drivers/mmc/davinci_mmc.c
@@ -18,7 +18,6 @@
#include
#include
-#define DAVINCI_MAX_BLOCKS (32)
#define WATCHDOG_COUNT (100000)
#define get_val(addr) REG(addr)
@@ -34,12 +33,6 @@ struct davinci_mmc_priv {
struct gpio_desc cd_gpio; /* Card Detect GPIO */
struct gpio_desc wp_gpio; /* Write Protect GPIO */
};
-
-struct davinci_mmc_plat
-{
- struct mmc_config cfg;
- struct mmc mmc;
-};
#endif
/* Set davinci clock prescalar value based on the required clock in HZ */
@@ -487,43 +480,16 @@ static int davinci_mmc_probe(struct udevice *dev)
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
struct davinci_mmc_plat *plat = dev_get_platdata(dev);
struct davinci_mmc_priv *priv = dev_get_priv(dev);
- struct mmc_config *cfg = &plat->cfg;
-#ifdef CONFIG_SPL_BUILD
- int ret;
-#endif
-
- cfg->f_min = 200000;
- cfg->f_max = 25000000;
- cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
- cfg->host_caps = MMC_MODE_4BIT, /* DA850 supports only 4-bit SD/MMC */
- cfg->b_max = DAVINCI_MAX_BLOCKS;
- cfg->name = "da830-mmc";
- priv->reg_base = (struct davinci_mmc_regs *)dev_read_addr(dev);
+ priv->reg_base = plat->reg_base;
priv->input_clk = clk_get(DAVINCI_MMCSD_CLKID);
-
#if CONFIG_IS_ENABLED(DM_GPIO)
/* These GPIOs are optional */
gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio, GPIOD_IS_IN);
#endif
-
upriv->mmc = &plat->mmc;
-#ifdef CONFIG_SPL_BUILD
- /*
- * FIXME This is a temporary workaround to enable the driver model in
- * SPL on omapl138-lcdk. For some reason the bind() callback is not
- * being called in SPL for MMC which breaks the mmc boot - the hack
- * is to call mmc_bind() from probe(). We also don't have full DT
- * support in SPL, hence the hard-coded base register address.
- */
- priv->reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE;
- ret = mmc_bind(dev, &plat->mmc, &plat->cfg);
- if (ret)
- return ret;
-#endif
-
return davinci_dm_mmc_init(dev);
}
@@ -534,21 +500,44 @@ static int davinci_mmc_bind(struct udevice *dev)
return mmc_bind(dev, &plat->mmc, &plat->cfg);
}
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static int davinci_mmc_ofdata_to_platdata(struct udevice *dev)
+{
+ struct davinci_mmc_plat *plat = dev_get_platdata(dev);
+ struct mmc_config *cfg = &plat->cfg;
+
+ plat->reg_base = (struct davinci_mmc_regs *)dev_read_addr(dev);
+ cfg->f_min = 200000;
+ cfg->f_max = 25000000;
+ cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
+ cfg->host_caps = MMC_MODE_4BIT, /* DA850 supports only 4-bit SD/MMC */
+ cfg->b_max = DAVINCI_MAX_BLOCKS;
+ cfg->name = "da830-mmc";
+
+ return 0;
+}
+
static const struct udevice_id davinci_mmc_ids[] = {
{ .compatible = "ti,da830-mmc" },
{},
};
-
+#endif
U_BOOT_DRIVER(davinci_mmc_drv) = {
.name = "davinci_mmc",
.id = UCLASS_MMC,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
.of_match = davinci_mmc_ids,
+ .platdata_auto_alloc_size = sizeof(struct davinci_mmc_plat),
+ .ofdata_to_platdata = davinci_mmc_ofdata_to_platdata,
+#endif
#if CONFIG_BLK
.bind = davinci_mmc_bind,
#endif
.probe = davinci_mmc_probe,
.ops = &davinci_mmc_ops,
- .platdata_auto_alloc_size = sizeof(struct davinci_mmc_plat),
.priv_auto_alloc_size = sizeof(struct davinci_mmc_priv),
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
+ .flags = DM_FLAG_PRE_RELOC,
+#endif
};
#endif
--
cgit v1.1
From 5b9ee0fc6f9adb05eefa457a752626cb22cca958 Mon Sep 17 00:00:00 2001
From: Bin Liu
Date: Wed, 3 Jun 2020 14:46:22 +0300
Subject: phy: omap-usb2-phy: disable phy charger detect
AM654x PG1.0 has a silicon bug that D+ is pulled high after POR, which
could cause enumeration failure with some USB hubs. Disabling the
USB2_PHY Charger Detect function will put D+ into the normal state.
Using property "ti,dis-chg-det-quirk" in the DT usb2-phy node to
enable this workaround for AM654x PG1.0.
Signed-off-by: Bin Liu
Signed-off-by: Vignesh Raghavendra
Signed-off-by: Roger Quadros
---
drivers/phy/omap-usb2-phy.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/phy/omap-usb2-phy.c b/drivers/phy/omap-usb2-phy.c
index 0793b97..adc454d 100644
--- a/drivers/phy/omap-usb2-phy.c
+++ b/drivers/phy/omap-usb2-phy.c
@@ -17,6 +17,7 @@
#include
#define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT BIT(0)
+#define OMAP_USB2_DISABLE_CHG_DET BIT(1)
#define OMAP_DEV_PHY_PD BIT(0)
#define OMAP_USB2_PHY_PD BIT(28)
@@ -33,6 +34,10 @@
#define AM654_USB2_VBUS_DET_EN BIT(5)
#define AM654_USB2_VBUSVALID_DET_EN BIT(4)
+#define USB2PHY_CHRG_DET 0x14
+#define USB2PHY_USE_CHG_DET_REG BIT(29)
+#define USB2PHY_DIS_CHG_DET BIT(28)
+
DECLARE_GLOBAL_DATA_PTR;
struct omap_usb2_phy {
@@ -160,6 +165,12 @@ static int omap_usb2_phy_init(struct phy *usb_phy)
writel(val, priv->phy_base + USB2PHY_ANA_CONFIG1);
}
+ if (priv->flags & OMAP_USB2_DISABLE_CHG_DET) {
+ val = readl(priv->phy_base + USB2PHY_CHRG_DET);
+ val |= USB2PHY_USE_CHG_DET_REG | USB2PHY_DIS_CHG_DET;
+ writel(val, priv->phy_base + USB2PHY_CHRG_DET);
+ }
+
return 0;
}
@@ -197,13 +208,25 @@ int omap_usb2_phy_probe(struct udevice *dev)
if (!data)
return -EINVAL;
- if (data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
- priv->phy_base = dev_read_addr_ptr(dev);
+ priv->phy_base = dev_read_addr_ptr(dev);
- if (!priv->phy_base)
- return -EINVAL;
+ if (!priv->phy_base)
+ return -EINVAL;
+
+ if (data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT)
priv->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
- }
+
+ /*
+ * AM654x PG1.0 has a silicon bug that D+ is pulled high after
+ * POR, which could cause enumeration failure with some USB hubs.
+ * Disabling the USB2_PHY Charger Detect function will put D+
+ * into the normal state.
+ *
+ * Using property "ti,dis-chg-det-quirk" in the DT usb2-phy node
+ * to enable this workaround for AM654x PG1.0.
+ */
+ if (dev_read_bool(dev, "ti,dis-chg-det-quirk"))
+ priv->flags |= OMAP_USB2_DISABLE_CHG_DET;
regmap = syscon_regmap_lookup_by_phandle(dev, "syscon-phy-power");
if (!IS_ERR(regmap)) {
--
cgit v1.1
From a37f765219870e4cb4ed9590dff77ed8a380a462 Mon Sep 17 00:00:00 2001
From: Tom Rini
Date: Thu, 4 Jun 2020 16:01:39 -0400
Subject: gpio: omap_gpio: Fix unused function warning in non-DM case
In the case of non-DM_GPIO the function get_gpio_index() will never be
called, and clang will warn about this. Move this to be with the other
non-DM code for easier removal later.
Cc: Lokesh Vutla
Signed-off-by: Tom Rini
Reviewed-by: Lokesh Vutla
---
drivers/gpio/omap_gpio.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 4249850..c986ef0 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -41,11 +41,6 @@ struct gpio_bank {
#endif
-static inline int get_gpio_index(int gpio)
-{
- return gpio & 0x1f;
-}
-
int gpio_is_valid(int gpio)
{
return (gpio >= 0) && (gpio < OMAP_MAX_GPIO);
@@ -122,6 +117,10 @@ static int _get_gpio_value(const struct gpio_bank *bank, int gpio)
}
#if !CONFIG_IS_ENABLED(DM_GPIO)
+static inline int get_gpio_index(int gpio)
+{
+ return gpio & 0x1f;
+}
static inline const struct gpio_bank *get_gpio_bank(int gpio)
{
--
cgit v1.1
From 2af17e2573e8f4b949658ac45cad2e825e5aedc0 Mon Sep 17 00:00:00 2001
From: Tom Rini
Date: Thu, 4 Jun 2020 16:03:55 -0400
Subject: mmc: omap_hsmmc: Add guards around omap_hsmmc_get_cfg()
We only call the function omap_hsmmc_get_cfg in the case of OMAP34XX or
when we have to iodelay recalibration. Add guards for these checks as
clang will otherwise warn.
Cc: Peng Fan
Cc: Lokesh Vutla
Signed-off-by: Tom Rini
Reviewed-by: Peng Fan
Reviewed-by: Lokesh Vutla
---
drivers/mmc/omap_hsmmc.c | 3 +++
1 file changed, 3 insertions(+)
(limited to 'drivers')
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 8636cd7..0e05fe4 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -175,6 +175,8 @@ static inline struct omap_hsmmc_data *omap_hsmmc_get_data(struct mmc *mmc)
return (struct omap_hsmmc_data *)mmc->priv;
#endif
}
+
+#if defined(CONFIG_OMAP34XX) || defined(CONFIG_IODELAY_RECALIBRATION)
static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
{
#if CONFIG_IS_ENABLED(DM_MMC)
@@ -184,6 +186,7 @@ static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
return &((struct omap_hsmmc_data *)mmc->priv)->cfg;
#endif
}
+#endif
#if defined(OMAP_HSMMC_USE_GPIO) && !CONFIG_IS_ENABLED(DM_MMC)
static int omap_mmc_setup_gpio_in(int gpio, const char *label)
--
cgit v1.1
From eab48865f93a19e2a196a6c4e3480f16df4027d9 Mon Sep 17 00:00:00 2001
From: Tom Rini
Date: Thu, 4 Jun 2020 16:05:32 -0400
Subject: net: cpsw: Add __maybe_unused to generated inlines
We generate a number of helper inline functions to make accesses easier.
However not all permutations of each function will be used and clang
will warn about unused ones. Decorate all of them with __maybe_unused
because of this.
Cc: Lokesh Vutla
Signed-off-by: Tom Rini
Reviewed-by: Grygorii Strashko
---
drivers/net/ti/cpsw.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 95761ff..9d4332f 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -247,11 +248,11 @@ static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits,
}
#define DEFINE_ALE_FIELD(name, start, bits) \
-static inline int cpsw_ale_get_##name(u32 *ale_entry) \
+static inline int __maybe_unused cpsw_ale_get_##name(u32 *ale_entry) \
{ \
return cpsw_ale_get_field(ale_entry, start, bits); \
} \
-static inline void cpsw_ale_set_##name(u32 *ale_entry, u32 value) \
+static inline void __maybe_unused cpsw_ale_set_##name(u32 *ale_entry, u32 value) \
{ \
cpsw_ale_set_field(ale_entry, start, bits, value); \
}
--
cgit v1.1
From 8d50551dc77bc87dc6c6b3474e094d9203a24144 Mon Sep 17 00:00:00 2001
From: Chuanhua Han
Date: Thu, 4 Jun 2020 23:16:30 +0800
Subject: dm: spi: Convert Freescale ESPI driver to driver model
Modify the Freescale ESPI driver to support the driver model.
Also resolved the following problems:
===================== WARNING ======================
This board does not use CONFIG_DM_SPI. Please update
the board before v2019.04 for no dm conversion
and v2019.07 for partially dm converted drivers.
Failure to update can lead to driver/board removal
See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_SPI_FLASH. Please update
the board to use CONFIG_SPI_FLASH before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================
Signed-off-by: Chuanhua Han
Signed-off-by: Xiaowei Bao
Signed-off-by: Hou Zhiqiang
Reviewed-by: Jagan Teki
---
drivers/spi/fsl_espi.c | 444 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 321 insertions(+), 123 deletions(-)
(limited to 'drivers')
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c
index 50d194f..5c76fd9 100644
--- a/drivers/spi/fsl_espi.c
+++ b/drivers/spi/fsl_espi.c
@@ -3,7 +3,9 @@
* eSPI controller driver.
*
* Copyright 2010-2011 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
* Author: Mingkai Hu (Mingkai.hu@freescale.com)
+ * Chuanhua Han (chuanhua.han@nxp.com)
*/
#include
@@ -14,10 +16,16 @@
#include
#include
#include
+#include
+#include
+#include
+#include
struct fsl_spi_slave {
struct spi_slave slave;
ccsr_espi_t *espi;
+ u32 speed_hz;
+ unsigned int cs;
unsigned int div16;
unsigned int pm;
int tx_timeout;
@@ -31,6 +39,9 @@ struct fsl_spi_slave {
#define to_fsl_spi_slave(s) container_of(s, struct fsl_spi_slave, slave)
#define US_PER_SECOND 1000000UL
+/* default SCK frequency, unit: HZ */
+#define FSL_ESPI_DEFAULT_SCK_FREQ 10000000
+
#define ESPI_MAX_CS_NUM 4
#define ESPI_FIFO_WIDTH_BIT 32
@@ -65,116 +76,27 @@ struct fsl_spi_slave {
#define ESPI_MAX_DATA_TRANSFER_LEN 0xFFF0
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
- unsigned int max_hz, unsigned int mode)
-{
- struct fsl_spi_slave *fsl;
- sys_info_t sysinfo;
- unsigned long spibrg = 0;
- unsigned long spi_freq = 0;
- unsigned char pm = 0;
-
- if (!spi_cs_is_valid(bus, cs))
- return NULL;
-
- fsl = spi_alloc_slave(struct fsl_spi_slave, bus, cs);
- if (!fsl)
- return NULL;
-
- fsl->espi = (void *)(CONFIG_SYS_MPC85xx_ESPI_ADDR);
- fsl->mode = mode;
- fsl->max_transfer_length = ESPI_MAX_DATA_TRANSFER_LEN;
-
- /* Set eSPI BRG clock source */
- get_sys_info(&sysinfo);
- spibrg = sysinfo.freq_systembus / 2;
- fsl->div16 = 0;
- if ((spibrg / max_hz) > 32) {
- fsl->div16 = ESPI_CSMODE_DIV16;
- pm = spibrg / (max_hz * 16 * 2);
- if (pm > 16) {
- pm = 16;
- debug("Requested speed is too low: %d Hz, %ld Hz "
- "is used.\n", max_hz, spibrg / (32 * 16));
- }
- } else
- pm = spibrg / (max_hz * 2);
- if (pm)
- pm--;
- fsl->pm = pm;
-
- if (fsl->div16)
- spi_freq = spibrg / ((pm + 1) * 2 * 16);
- else
- spi_freq = spibrg / ((pm + 1) * 2);
-
- /* set tx_timeout to 10 times of one espi FIFO entry go out */
- fsl->tx_timeout = DIV_ROUND_UP((US_PER_SECOND * ESPI_FIFO_WIDTH_BIT
- * 10), spi_freq);
-
- return &fsl->slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
- struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
- free(fsl);
-}
-
-int spi_claim_bus(struct spi_slave *slave)
+void fsl_spi_cs_activate(struct spi_slave *slave, uint cs)
{
struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
ccsr_espi_t *espi = fsl->espi;
- unsigned char pm = fsl->pm;
- unsigned int cs = slave->cs;
- unsigned int mode = fsl->mode;
- unsigned int div16 = fsl->div16;
- int i;
-
- debug("%s: bus:%i cs:%i\n", __func__, slave->bus, cs);
-
- /* Enable eSPI interface */
- out_be32(&espi->mode, ESPI_MODE_RXTHR(3)
- | ESPI_MODE_TXTHR(4) | ESPI_MODE_EN);
-
- out_be32(&espi->event, 0xffffffff); /* Clear all eSPI events */
- out_be32(&espi->mask, 0x00000000); /* Mask all eSPI interrupts */
-
- /* Init CS mode interface */
- for (i = 0; i < ESPI_MAX_CS_NUM; i++)
- out_be32(&espi->csmode[i], ESPI_CSMODE_INIT_VAL);
-
- out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs]) &
- ~(ESPI_CSMODE_PM(0xF) | ESPI_CSMODE_DIV16
- | ESPI_CSMODE_CI_INACTIVEHIGH | ESPI_CSMODE_CP_BEGIN_EDGCLK
- | ESPI_CSMODE_REV_MSB_FIRST | ESPI_CSMODE_LEN(0xF)));
-
- /* Set eSPI BRG clock source */
- out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
- | ESPI_CSMODE_PM(pm) | div16);
-
- /* Set eSPI mode */
- if (mode & SPI_CPHA)
- out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
- | ESPI_CSMODE_CP_BEGIN_EDGCLK);
- if (mode & SPI_CPOL)
- out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
- | ESPI_CSMODE_CI_INACTIVEHIGH);
-
- /* Character bit order: msb first */
- out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
- | ESPI_CSMODE_REV_MSB_FIRST);
-
- /* Character length in bits, between 0x3~0xf, i.e. 4bits~16bits */
- out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
- | ESPI_CSMODE_LEN(7));
+ unsigned int com = 0;
+ size_t data_len = fsl->data_len;
- return 0;
+ com &= ~(ESPI_COM_CS(0x3) | ESPI_COM_TRANLEN(0xFFFF));
+ com |= ESPI_COM_CS(cs);
+ com |= ESPI_COM_TRANLEN(data_len - 1);
+ out_be32(&espi->com, com);
}
-void spi_release_bus(struct spi_slave *slave)
+void fsl_spi_cs_deactivate(struct spi_slave *slave)
{
+ struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
+ ccsr_espi_t *espi = fsl->espi;
+ /* clear the RXCNT and TXCNT */
+ out_be32(&espi->mode, in_be32(&espi->mode) & (~ESPI_MODE_EN));
+ out_be32(&espi->mode, in_be32(&espi->mode) | ESPI_MODE_EN);
}
static void fsl_espi_tx(struct fsl_spi_slave *fsl, const void *dout)
@@ -207,7 +129,8 @@ static void fsl_espi_tx(struct fsl_spi_slave *fsl, const void *dout)
debug("***spi_xfer:...Tx timeout! event = %08x\n", event);
}
-static int fsl_espi_rx(struct fsl_spi_slave *fsl, void *din, unsigned int bytes)
+static int fsl_espi_rx(struct fsl_spi_slave *fsl, void *din,
+ unsigned int bytes)
{
ccsr_espi_t *espi = fsl->espi;
unsigned int tmpdin, rx_times;
@@ -239,10 +162,17 @@ static int fsl_espi_rx(struct fsl_spi_slave *fsl, void *din, unsigned int bytes)
return bytes;
}
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
- void *data_in, unsigned long flags)
+void espi_release_bus(struct fsl_spi_slave *fsl)
{
- struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
+ /* Disable the SPI hardware */
+ out_be32(&fsl->espi->mode,
+ in_be32(&fsl->espi->mode) & (~ESPI_MODE_EN));
+}
+
+int espi_xfer(struct fsl_spi_slave *fsl, uint cs, unsigned int bitlen,
+ const void *data_out, void *data_in, unsigned long flags)
+{
+ struct spi_slave *slave = &fsl->slave;
ccsr_espi_t *espi = fsl->espi;
unsigned int event, rx_bytes;
const void *dout = NULL;
@@ -261,13 +191,14 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
max_tran_len = fsl->max_transfer_length;
switch (flags) {
case SPI_XFER_BEGIN:
- cmd_len = fsl->cmd_len = data_len;
+ cmd_len = data_len;
+ fsl->cmd_len = cmd_len;
memcpy(cmd_buf, data_out, cmd_len);
return 0;
case 0:
case SPI_XFER_END:
if (bitlen == 0) {
- spi_cs_deactivate(slave);
+ fsl_spi_cs_deactivate(slave);
return 0;
}
buf_len = 2 * cmd_len + min(data_len, (size_t)max_tran_len);
@@ -307,7 +238,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
num_blks = DIV_ROUND_UP(tran_len + cmd_len, 4);
num_bytes = (tran_len + cmd_len) % 4;
fsl->data_len = tran_len + cmd_len;
- spi_cs_activate(slave);
+ fsl_spi_cs_activate(slave, cs);
/* Clear all eSPI events */
out_be32(&espi->event , 0xffffffff);
@@ -350,37 +281,304 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
*(int *)buffer += tran_len;
}
}
- spi_cs_deactivate(slave);
+ fsl_spi_cs_deactivate(slave);
}
free(buffer);
return 0;
}
+void espi_claim_bus(struct fsl_spi_slave *fsl, unsigned int cs)
+{
+ ccsr_espi_t *espi = fsl->espi;
+ unsigned char pm = fsl->pm;
+ unsigned int mode = fsl->mode;
+ unsigned int div16 = fsl->div16;
+ int i;
+
+ /* Enable eSPI interface */
+ out_be32(&espi->mode, ESPI_MODE_RXTHR(3)
+ | ESPI_MODE_TXTHR(4) | ESPI_MODE_EN);
+
+ out_be32(&espi->event, 0xffffffff); /* Clear all eSPI events */
+ out_be32(&espi->mask, 0x00000000); /* Mask all eSPI interrupts */
+
+ /* Init CS mode interface */
+ for (i = 0; i < ESPI_MAX_CS_NUM; i++)
+ out_be32(&espi->csmode[i], ESPI_CSMODE_INIT_VAL);
+
+ out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs]) &
+ ~(ESPI_CSMODE_PM(0xF) | ESPI_CSMODE_DIV16
+ | ESPI_CSMODE_CI_INACTIVEHIGH | ESPI_CSMODE_CP_BEGIN_EDGCLK
+ | ESPI_CSMODE_REV_MSB_FIRST | ESPI_CSMODE_LEN(0xF)));
+
+ /* Set eSPI BRG clock source */
+ out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
+ | ESPI_CSMODE_PM(pm) | div16);
+
+ /* Set eSPI mode */
+ if (mode & SPI_CPHA)
+ out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
+ | ESPI_CSMODE_CP_BEGIN_EDGCLK);
+ if (mode & SPI_CPOL)
+ out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
+ | ESPI_CSMODE_CI_INACTIVEHIGH);
+
+ /* Character bit order: msb first */
+ out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
+ | ESPI_CSMODE_REV_MSB_FIRST);
+
+ /* Character length in bits, between 0x3~0xf, i.e. 4bits~16bits */
+ out_be32(&espi->csmode[cs], in_be32(&espi->csmode[cs])
+ | ESPI_CSMODE_LEN(7));
+}
+
+void espi_setup_slave(struct fsl_spi_slave *fsl)
+{
+ unsigned int max_hz;
+ sys_info_t sysinfo;
+ unsigned long spibrg = 0;
+ unsigned long spi_freq = 0;
+ unsigned char pm = 0;
+
+ max_hz = fsl->speed_hz;
+
+ get_sys_info(&sysinfo);
+ spibrg = sysinfo.freq_systembus / 2;
+ fsl->div16 = 0;
+ if ((spibrg / max_hz) > 32) {
+ fsl->div16 = ESPI_CSMODE_DIV16;
+ pm = spibrg / (max_hz * 16 * 2);
+ if (pm > 16) {
+ pm = 16;
+ debug("max_hz is too low: %d Hz, %ld Hz is used.\n",
+ max_hz, spibrg / (32 * 16));
+ }
+ } else {
+ pm = spibrg / (max_hz * 2);
+ }
+ if (pm)
+ pm--;
+ fsl->pm = pm;
+
+ if (fsl->div16)
+ spi_freq = spibrg / ((pm + 1) * 2 * 16);
+ else
+ spi_freq = spibrg / ((pm + 1) * 2);
+
+ /* set tx_timeout to 10 times of one espi FIFO entry go out */
+ fsl->tx_timeout = DIV_ROUND_UP((US_PER_SECOND * ESPI_FIFO_WIDTH_BIT
+ * 10), spi_freq);/* Set eSPI BRG clock source */
+}
+
+#if !CONFIG_IS_ENABLED(DM_SPI)
int spi_cs_is_valid(unsigned int bus, unsigned int cs)
{
return bus == 0 && cs < ESPI_MAX_CS_NUM;
}
-void spi_cs_activate(struct spi_slave *slave)
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ unsigned int max_hz, unsigned int mode)
+{
+ struct fsl_spi_slave *fsl;
+
+ if (!spi_cs_is_valid(bus, cs))
+ return NULL;
+
+ fsl = spi_alloc_slave(struct fsl_spi_slave, bus, cs);
+ if (!fsl)
+ return NULL;
+
+ fsl->espi = (void *)(CONFIG_SYS_MPC85xx_ESPI_ADDR);
+ fsl->mode = mode;
+ fsl->max_transfer_length = ESPI_MAX_DATA_TRANSFER_LEN;
+ fsl->speed_hz = max_hz;
+
+ espi_setup_slave(fsl);
+
+ return &fsl->slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
{
struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
- ccsr_espi_t *espi = fsl->espi;
- unsigned int com = 0;
- size_t data_len = fsl->data_len;
- com &= ~(ESPI_COM_CS(0x3) | ESPI_COM_TRANLEN(0xFFFF));
- com |= ESPI_COM_CS(slave->cs);
- com |= ESPI_COM_TRANLEN(data_len - 1);
- out_be32(&espi->com, com);
+ free(fsl);
}
-void spi_cs_deactivate(struct spi_slave *slave)
+int spi_claim_bus(struct spi_slave *slave)
{
struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
- ccsr_espi_t *espi = fsl->espi;
- /* clear the RXCNT and TXCNT */
- out_be32(&espi->mode, in_be32(&espi->mode) & (~ESPI_MODE_EN));
- out_be32(&espi->mode, in_be32(&espi->mode) | ESPI_MODE_EN);
+ espi_claim_bus(fsl, slave->cs);
+
+ return 0;
}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+ struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
+
+ espi_release_bus(fsl);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
+ void *din, unsigned long flags)
+{
+ struct fsl_spi_slave *fsl = (struct fsl_spi_slave *)slave;
+
+ return espi_xfer(fsl, slave->cs, bitlen, dout, din, flags);
+}
+#else
+static void __espi_set_speed(struct fsl_spi_slave *fsl)
+{
+ espi_setup_slave(fsl);
+
+ /* Set eSPI BRG clock source */
+ out_be32(&fsl->espi->csmode[fsl->cs],
+ in_be32(&fsl->espi->csmode[fsl->cs])
+ | ESPI_CSMODE_PM(fsl->pm) | fsl->div16);
+}
+
+static void __espi_set_mode(struct fsl_spi_slave *fsl)
+{
+ /* Set eSPI mode */
+ if (fsl->mode & SPI_CPHA)
+ out_be32(&fsl->espi->csmode[fsl->cs],
+ in_be32(&fsl->espi->csmode[fsl->cs])
+ | ESPI_CSMODE_CP_BEGIN_EDGCLK);
+ if (fsl->mode & SPI_CPOL)
+ out_be32(&fsl->espi->csmode[fsl->cs],
+ in_be32(&fsl->espi->csmode[fsl->cs])
+ | ESPI_CSMODE_CI_INACTIVEHIGH);
+}
+
+static int fsl_espi_claim_bus(struct udevice *dev)
+{
+ struct udevice *bus = dev->parent;
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ espi_claim_bus(fsl, fsl->cs);
+
+ return 0;
+}
+
+static int fsl_espi_release_bus(struct udevice *dev)
+{
+ struct udevice *bus = dev->parent;
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ espi_release_bus(fsl);
+
+ return 0;
+}
+
+static int fsl_espi_xfer(struct udevice *dev, unsigned int bitlen,
+ const void *dout, void *din, unsigned long flags)
+{
+ struct udevice *bus = dev->parent;
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ return espi_xfer(fsl, fsl->cs, bitlen, dout, din, flags);
+}
+
+static int fsl_espi_set_speed(struct udevice *bus, uint speed)
+{
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ debug("%s speed %u\n", __func__, speed);
+ fsl->speed_hz = speed;
+
+ __espi_set_speed(fsl);
+
+ return 0;
+}
+
+static int fsl_espi_set_mode(struct udevice *bus, uint mode)
+{
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ debug("%s mode %u\n", __func__, mode);
+ fsl->mode = mode;
+
+ __espi_set_mode(fsl);
+
+ return 0;
+}
+
+static int fsl_espi_child_pre_probe(struct udevice *dev)
+{
+ struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+ struct udevice *bus = dev->parent;
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ debug("%s cs %u\n", __func__, slave_plat->cs);
+ fsl->cs = slave_plat->cs;
+
+ return 0;
+}
+
+static int fsl_espi_probe(struct udevice *bus)
+{
+ struct fsl_espi_platdata *plat = dev_get_platdata(bus);
+ struct fsl_spi_slave *fsl = dev_get_priv(bus);
+
+ fsl->espi = (ccsr_espi_t *)((u32)plat->regs_addr);
+ fsl->max_transfer_length = ESPI_MAX_DATA_TRANSFER_LEN;
+ fsl->speed_hz = plat->speed_hz;
+
+ debug("%s probe done, bus-num %d.\n", bus->name, bus->seq);
+
+ return 0;
+}
+
+static const struct dm_spi_ops fsl_espi_ops = {
+ .claim_bus = fsl_espi_claim_bus,
+ .release_bus = fsl_espi_release_bus,
+ .xfer = fsl_espi_xfer,
+ .set_speed = fsl_espi_set_speed,
+ .set_mode = fsl_espi_set_mode,
+};
+
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+static int fsl_espi_ofdata_to_platdata(struct udevice *bus)
+{
+ fdt_addr_t addr;
+ struct fsl_espi_platdata *plat = bus->platdata;
+ const void *blob = gd->fdt_blob;
+ int node = dev_of_offset(bus);
+
+ addr = dev_read_addr(bus);
+ if (addr == FDT_ADDR_T_NONE)
+ return -EINVAL;
+
+ plat->regs_addr = lower_32_bits(addr);
+ plat->speed_hz = fdtdec_get_int(blob, node, "spi-max-frequency",
+ FSL_ESPI_DEFAULT_SCK_FREQ);
+
+ debug("ESPI: regs=%p, max-frequency=%d\n",
+ &plat->regs_addr, plat->speed_hz);
+
+ return 0;
+}
+
+static const struct udevice_id fsl_espi_ids[] = {
+ { .compatible = "fsl,mpc8536-espi" },
+ { }
+};
+#endif
+
+U_BOOT_DRIVER(fsl_espi) = {
+ .name = "fsl_espi",
+ .id = UCLASS_SPI,
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+ .of_match = fsl_espi_ids,
+ .ofdata_to_platdata = fsl_espi_ofdata_to_platdata,
+#endif
+ .ops = &fsl_espi_ops,
+ .platdata_auto_alloc_size = sizeof(struct fsl_espi_platdata),
+ .priv_auto_alloc_size = sizeof(struct fsl_spi_slave),
+ .probe = fsl_espi_probe,
+ .child_pre_probe = fsl_espi_child_pre_probe,
+};
+#endif
--
cgit v1.1
From 39b95556f9b97b0fa824871aef53647d6ea0b44e Mon Sep 17 00:00:00 2001
From: Anatolij Gustschin
Date: Mon, 25 May 2020 21:47:19 +0200
Subject: video: make vidconsole commands optional
Converting some boards to DM_VIDEO results in build breakage due
to increased code size. Make video console specific commands
optional to reduce binary size.
Signed-off-by: Anatolij Gustschin
Reviewed-by: Simon Glass
---
drivers/video/Kconfig | 8 ++++++++
drivers/video/vidconsole-uclass.c | 2 ++
2 files changed, 10 insertions(+)
(limited to 'drivers')
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 3812354..d0e9563 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -35,6 +35,14 @@ config BACKLIGHT_GPIO
it understands the standard device tree
(leds/backlight/gpio-backlight.txt)
+config CMD_VIDCONSOLE
+ bool "Enable vidconsole commands lcdputs and setcurs"
+ depends on DM_VIDEO
+ default y
+ help
+ Enabling this will provide 'setcurs' and 'lcdputs' commands which
+ support cursor positioning and drawing strings on video framebuffer.
+
config VIDEO_BPP8
bool "Support 8-bit-per-pixel displays"
depends on DM_VIDEO
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index d30e6db..901347c 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -613,6 +613,7 @@ UCLASS_DRIVER(vidconsole) = {
.per_device_auto_alloc_size = sizeof(struct vidconsole_priv),
};
+#if CONFIG_IS_ENABLED(CMD_VIDCONSOLE)
void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
{
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
@@ -673,3 +674,4 @@ U_BOOT_CMD(
"print string on video framebuffer",
" "
);
+#endif /* CONFIG_IS_ENABLED(CMD_VIDCONSOLE) */
--
cgit v1.1
From 0b12f76f7241cb22d4a41ab048b64c8c3a88199d Mon Sep 17 00:00:00 2001
From: Anatolij Gustschin
Date: Tue, 26 May 2020 00:09:22 +0200
Subject: video: ipuv3: fix building with disabled panel driver
Panel code might be disabled for some boards, make this
driver code optional.
Signed-off-by: Anatolij Gustschin
---
drivers/video/imx/mxc_ipuv3_fb.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/video/imx/mxc_ipuv3_fb.c b/drivers/video/imx/mxc_ipuv3_fb.c
index 4044473..cdef84a 100644
--- a/drivers/video/imx/mxc_ipuv3_fb.c
+++ b/drivers/video/imx/mxc_ipuv3_fb.c
@@ -645,7 +645,6 @@ static int ipuv3_video_probe(struct udevice *dev)
#if defined(CONFIG_DISPLAY)
struct udevice *disp_dev;
#endif
- struct udevice *panel_dev;
u32 fb_start, fb_end;
int ret;
@@ -672,9 +671,13 @@ static int ipuv3_video_probe(struct udevice *dev)
return ret;
}
#endif
- ret = uclass_get_device(UCLASS_PANEL, 0, &panel_dev);
- if (panel_dev)
- panel_enable_backlight(panel_dev);
+ if (CONFIG_IS_ENABLED(PANEL)) {
+ struct udevice *panel_dev;
+
+ ret = uclass_get_device(UCLASS_PANEL, 0, &panel_dev);
+ if (panel_dev)
+ panel_enable_backlight(panel_dev);
+ }
uc_priv->xsize = gmode->xres;
uc_priv->ysize = gmode->yres;
--
cgit v1.1
From e26e520046a1b551f25acf3d7b6705a37c808deb Mon Sep 17 00:00:00 2001
From: Anatolij Gustschin
Date: Tue, 26 May 2020 00:20:49 +0200
Subject: video: make backlight and panel drivers optional
Not all boards use these drivers, so allow to disable them to fix
building boards with U-Boot binary image size restrictions.
Signed-off-by: Anatolij Gustschin
Reviewed-by: Simon Glass
---
drivers/video/Kconfig | 27 +++++++++++++++++++++++++--
drivers/video/Makefile | 5 +++--
2 files changed, 28 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index d0e9563..aaea7ce 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -14,9 +14,17 @@ config DM_VIDEO
option compiles in the video uclass and routes all LCD/video access
through this.
+config BACKLIGHT
+ bool "Enable panel backlight uclass support"
+ depends on DM_VIDEO
+ default y
+ help
+ This provides backlight uclass driver that enables basic panel
+ backlight support.
+
config BACKLIGHT_PWM
bool "Generic PWM based Backlight Driver"
- depends on DM_VIDEO && DM_PWM
+ depends on BACKLIGHT && DM_PWM
default y
help
If you have a LCD backlight adjustable by PWM, say Y to enable
@@ -27,7 +35,7 @@ config BACKLIGHT_PWM
config BACKLIGHT_GPIO
bool "Generic GPIO based Backlight Driver"
- depends on DM_VIDEO
+ depends on BACKLIGHT
help
If you have a LCD backlight adjustable by GPIO, say Y to enable
this driver.
@@ -151,6 +159,21 @@ config NO_FB_CLEAR
loads takes over the screen. This, for example, can be used to
keep splash image on screen until grub graphical boot menu starts.
+config PANEL
+ bool "Enable panel uclass support"
+ depends on DM_VIDEO
+ default y
+ help
+ This provides panel uclass driver that enables basic panel support.
+
+config SIMPLE_PANEL
+ bool "Enable simple panel support"
+ depends on PANEL
+ default y
+ help
+ This turns on a simple panel driver that enables a compatible
+ video panel.
+
source "drivers/video/fonts/Kconfig"
config VIDCONSOLE_AS_LCD
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index df7119d..1dbd09a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -4,17 +4,18 @@
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
ifdef CONFIG_DM
+obj-$(CONFIG_BACKLIGHT) += backlight-uclass.o
obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_backlight.o
obj-$(CONFIG_CONSOLE_NORMAL) += console_normal.o
obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o
obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/
obj-$(CONFIG_DISPLAY) += display-uclass.o
-obj-$(CONFIG_DM_VIDEO) += backlight-uclass.o
obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi-host-uclass.o
-obj-$(CONFIG_DM_VIDEO) += panel-uclass.o simple_panel.o
obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o
obj-$(CONFIG_DM_VIDEO) += video_bmp.o
+obj-$(CONFIG_PANEL) += panel-uclass.o
+obj-$(CONFIG_SIMPLE_PANEL) += simple_panel.o
endif
obj-${CONFIG_EXYNOS_FB} += exynos/
--
cgit v1.1
From db755b36d2ee240cae30de9cccada8fe398b3eef Mon Sep 17 00:00:00 2001
From: Anatolij Gustschin
Date: Mon, 25 May 2020 14:34:17 +0200
Subject: video: ipuv3: remove some useless code to reduce binary size
To enable DM_VIDEO we must decrease binary size to fix build
breakage for some boards, so drop not needed code. Also add
!DM_VIDEO guards which can be later removed when last non DM
users will be converted.
Signed-off-by: Anatolij Gustschin
---
drivers/video/imx/ipu_disp.c | 12 ---------
drivers/video/imx/mxc_ipuv3_fb.c | 57 ++++++++++++++++------------------------
2 files changed, 22 insertions(+), 47 deletions(-)
(limited to 'drivers')
diff --git a/drivers/video/imx/ipu_disp.c b/drivers/video/imx/ipu_disp.c
index c2f00bf..4506989 100644
--- a/drivers/video/imx/ipu_disp.c
+++ b/drivers/video/imx/ipu_disp.c
@@ -1191,9 +1191,6 @@ int32_t ipu_disp_set_global_alpha(ipu_channel_t channel, unsigned char enable,
else
bg_chan = 0;
- if (!g_ipu_clk_enabled)
- clk_enable(g_ipu_clk);
-
if (bg_chan) {
reg = __raw_readl(DP_COM_CONF());
__raw_writel(reg & ~DP_COM_CONF_GWSEL, DP_COM_CONF());
@@ -1217,9 +1214,6 @@ int32_t ipu_disp_set_global_alpha(ipu_channel_t channel, unsigned char enable,
reg = __raw_readl(IPU_SRM_PRI2) | 0x8;
__raw_writel(reg, IPU_SRM_PRI2);
- if (!g_ipu_clk_enabled)
- clk_disable(g_ipu_clk);
-
return 0;
}
@@ -1246,9 +1240,6 @@ int32_t ipu_disp_set_color_key(ipu_channel_t channel, unsigned char enable,
(channel == MEM_BG_ASYNC1 || channel == MEM_FG_ASYNC1)))
return -EINVAL;
- if (!g_ipu_clk_enabled)
- clk_enable(g_ipu_clk);
-
color_key_4rgb = 1;
/* Transform color key from rgb to yuv if CSC is enabled */
if (((fg_csc_type == RGB2YUV) && (bg_csc_type == YUV2YUV)) ||
@@ -1286,8 +1277,5 @@ int32_t ipu_disp_set_color_key(ipu_channel_t channel, unsigned char enable,
reg = __raw_readl(IPU_SRM_PRI2) | 0x8;
__raw_writel(reg, IPU_SRM_PRI2);
- if (!g_ipu_clk_enabled)
- clk_disable(g_ipu_clk);
-
return 0;
}
diff --git a/drivers/video/imx/mxc_ipuv3_fb.c b/drivers/video/imx/mxc_ipuv3_fb.c
index cdef84a..6787201 100644
--- a/drivers/video/imx/mxc_ipuv3_fb.c
+++ b/drivers/video/imx/mxc_ipuv3_fb.c
@@ -38,8 +38,10 @@ DECLARE_GLOBAL_DATA_PTR;
static int mxcfb_map_video_memory(struct fb_info *fbi);
static int mxcfb_unmap_video_memory(struct fb_info *fbi);
+#if !CONFIG_IS_ENABLED(DM_VIDEO)
/* graphics setup */
static GraphicDevice panel;
+#endif
static struct fb_videomode const *gmode;
static uint8_t gdisp;
static uint32_t gpixfmt;
@@ -120,27 +122,6 @@ static uint32_t bpp_to_pixfmt(struct fb_info *fbi)
return pixfmt;
}
-/*
- * Set fixed framebuffer parameters based on variable settings.
- *
- * @param info framebuffer information pointer
- */
-static int mxcfb_set_fix(struct fb_info *info)
-{
- struct fb_fix_screeninfo *fix = &info->fix;
- struct fb_var_screeninfo *var = &info->var;
-
- fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
-
- fix->type = FB_TYPE_PACKED_PIXELS;
- fix->accel = FB_ACCEL_NONE;
- fix->visual = FB_VISUAL_TRUECOLOR;
- fix->xpanstep = 1;
- fix->ypanstep = 1;
-
- return 0;
-}
-
static int setup_disp_channel1(struct fb_info *fbi)
{
ipu_channel_params_t params;
@@ -226,7 +207,6 @@ static int mxcfb_set_par(struct fb_info *fbi)
ipu_disable_channel(mxc_fbi->ipu_ch);
ipu_uninit_channel(mxc_fbi->ipu_ch);
- mxcfb_set_fix(fbi);
mem_len = fbi->var.yres_virtual * fbi->fix.line_length;
if (!fbi->fix.smem_start || (mem_len > fbi->fix.smem_len)) {
@@ -499,6 +479,8 @@ static struct fb_info *mxcfb_init_fbinfo(void)
return fbi;
}
+extern struct clk *g_ipu_clk;
+
/*
* Probe routine for the framebuffer driver. It is called during the
* driver binding process. The following functions are performed in
@@ -512,16 +494,14 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
{
struct fb_info *fbi;
struct mxcfb_info *mxcfbi;
- int ret = 0;
/*
* Initialize FB structures
*/
fbi = mxcfb_init_fbinfo();
- if (!fbi) {
- ret = -ENOMEM;
- goto err0;
- }
+ if (!fbi)
+ return -ENOMEM;
+
mxcfbi = (struct mxcfb_info *)fbi->par;
if (!g_dp_in_use) {
@@ -534,9 +514,11 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
mxcfbi->ipu_di = disp;
+ if (!ipu_clk_enabled())
+ clk_enable(g_ipu_clk);
+
ipu_disp_set_global_alpha(mxcfbi->ipu_ch, 1, 0x80);
ipu_disp_set_color_key(mxcfbi->ipu_ch, 0, 0);
- strcpy(fbi->fix.id, "DISP3 BG");
g_dp_in_use = 1;
@@ -547,7 +529,8 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
mxcfbi->ipu_di_pix_fmt = interface_pix_fmt;
fb_videomode_to_var(&fbi->var, mode);
fbi->var.bits_per_pixel = 16;
- fbi->fix.line_length = fbi->var.xres * (fbi->var.bits_per_pixel / 8);
+ fbi->fix.line_length = fbi->var.xres_virtual *
+ (fbi->var.bits_per_pixel / 8);
fbi->fix.smem_len = fbi->var.yres_virtual * fbi->fix.line_length;
mxcfb_check_var(&fbi->var, fbi);
@@ -555,14 +538,13 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
/* Default Y virtual size is 2x panel size */
fbi->var.yres_virtual = fbi->var.yres * 2;
- mxcfb_set_fix(fbi);
-
/* allocate fb first */
if (mxcfb_map_video_memory(fbi) < 0)
return -ENOMEM;
mxcfb_set_par(fbi);
+#if !CONFIG_IS_ENABLED(DM_VIDEO)
panel.winSizeX = mode->xres;
panel.winSizeY = mode->yres;
panel.plnSizeX = mode->xres;
@@ -573,13 +555,12 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
panel.gdfBytesPP = 2;
panel.gdfIndex = GDF_16BIT_565RGB;
-
+#endif
+#ifdef DEBUG
ipu_dump_registers();
+#endif
return 0;
-
-err0:
- return ret;
}
void ipuv3_fb_shutdown(void)
@@ -604,6 +585,7 @@ void ipuv3_fb_shutdown(void)
}
}
+#if !CONFIG_IS_ENABLED(DM_VIDEO)
void *video_hw_init(void)
{
int ret;
@@ -618,6 +600,7 @@ void *video_hw_init(void)
return (void *)&panel;
}
+#endif
int ipuv3_fb_init(struct fb_videomode const *mode,
uint8_t disp,
@@ -710,8 +693,12 @@ static int ipuv3_video_bind(struct udevice *dev)
}
static const struct udevice_id ipuv3_video_ids[] = {
+#ifdef CONFIG_ARCH_MX6
{ .compatible = "fsl,imx6q-ipu" },
+#endif
+#ifdef CONFIG_ARCH_MX5
{ .compatible = "fsl,imx53-ipu" },
+#endif
{ }
};
--
cgit v1.1
From 22b897a12323364c584b1ff31fe9f5250e0d3481 Mon Sep 17 00:00:00 2001
From: Anatolij Gustschin
Date: Sat, 23 May 2020 17:11:20 +0200
Subject: video: extend stdout video console work-around for 'vga'
cfb_console driver uses 'vga' console name and we still have board
environments defining this name. Re-use existing DM_VIDEO work-
around for console name to support 'vga' name in stdout environment.
Signed-off-by: Anatolij Gustschin
Tested-by: Soeren Moch
Reviewed-by: Simon Glass
Reviewed-by: Tom Rini
---
drivers/video/Kconfig | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
(limited to 'drivers')
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index aaea7ce..01e8dbf 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -177,14 +177,16 @@ config SIMPLE_PANEL
source "drivers/video/fonts/Kconfig"
config VIDCONSOLE_AS_LCD
- bool "Use 'vidconsole' when 'lcd' is seen in stdout"
+ string "Use 'vidconsole' when string defined here is seen in stdout"
depends on DM_VIDEO
- help
- This is a work-around for boards which have 'lcd' in their stdout
- environment variable, but have moved to use driver model for video.
- In this case the console will no-longer work. While it is possible
- to update the environment, the breakage may be confusing for users.
- This option will be removed around the end of 2016.
+ default "lcd" if LCD || TEGRA_COMMON
+ default "vga" if !LCD
+ help
+ This is a work-around for boards which have 'lcd' or 'vga' in their
+ stdout environment variable, but have moved to use driver model for
+ video. In this case the console will no-longer work. While it is
+ possible to update the environment, the breakage may be confusing for
+ users. This option will be removed around the end of 2020.
config VIDEO_COREBOOT
bool "Enable coreboot framebuffer driver support"
--
cgit v1.1
From 0a5be6c5fd031fbdcd499500ad02608008329b29 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:06:48 +0200
Subject: net: eepro100: Remove EEPRO100_SROM_WRITE
This code is never enabled, last board that used it was ELPPC which
was removed some 5 years ago, so just remove this code altogether.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 87 --------------------------------------------------
1 file changed, 87 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index e186ab4..62a0dc7 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -781,93 +781,6 @@ static int read_eeprom (struct eth_device *dev, int location, int addr_len)
return retval;
}
-#ifdef CONFIG_EEPRO100_SROM_WRITE
-int eepro100_write_eeprom (struct eth_device* dev, int location, int addr_len, unsigned short data)
-{
- unsigned short dataval;
- int enable_cmd = 0x3f | EE_EWENB_CMD;
- int write_cmd = location | EE_WRITE_CMD;
- int i;
- unsigned long datalong, tmplong;
-
- OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB, SCBeeprom);
-
- /* Shift the enable command bits out. */
- for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--)
- {
- dataval = (enable_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
- OUTW(dev, EE_ENB | dataval, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom);
- udelay(1);
- }
-
- OUTW(dev, EE_ENB, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB, SCBeeprom);
-
-
- /* Shift the write command bits out. */
- for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--)
- {
- dataval = (write_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
- OUTW(dev, EE_ENB | dataval, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom);
- udelay(1);
- }
-
- /* Write the data */
- datalong= (unsigned long) ((((data) & 0x00ff) << 8) | ( (data) >> 8));
-
- for (i = 0; i< EE_DATA_BITS; i++)
- {
- /* Extract and move data bit to bit DI */
- dataval = ((datalong & 0x8000)>>13) ? EE_DATA_WRITE : 0;
-
- OUTW(dev, EE_ENB | dataval, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom);
- udelay(1);
- OUTW(dev, EE_ENB | dataval, SCBeeprom);
- udelay(1);
-
- datalong = datalong << 1; /* Adjust significant data bit*/
- }
-
- /* Finish up command (toggle CS) */
- OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
- udelay(1); /* delay for more than 250 ns */
- OUTW(dev, EE_ENB, SCBeeprom);
-
- /* Wait for programming ready (D0 = 1) */
- tmplong = 10;
- do
- {
- dataval = INW(dev, SCBeeprom);
- if (dataval & EE_DATA_READ)
- break;
- udelay(10000);
- }
- while (-- tmplong);
-
- if (tmplong == 0)
- {
- printf ("Write i82559 eeprom timed out (100 ms waiting for data ready.\n");
- return -1;
- }
-
- /* Terminate the EEPROM access. */
- OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
-
- return 0;
-}
-#endif
-
static void init_rx_ring (struct eth_device *dev)
{
int i;
--
cgit v1.1
From aba283d838bf5e5c227f2b779feba583c3964c90 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 12:49:16 +0200
Subject: net: eepro100: Clean up comments
Clean the comments up to they trigger fewer checkpatch warnings,
no functional change.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 100 ++++++++++++++++++-------------------------------
1 file changed, 36 insertions(+), 64 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 62a0dc7..503c44a 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -15,8 +15,7 @@
#undef DEBUG
- /* Ethernet chip registers.
- */
+/* Ethernet chip registers. */
#define SCBStatus 0 /* Rx/Command Unit Status *Word* */
#define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */
#define SCBCmd 2 /* Rx/Command Unit Command *Word* */
@@ -30,8 +29,7 @@
#define SCBGenControl 28 /* 82559 General Control Register */
#define SCBGenStatus 29 /* 82559 General Status register */
- /* 82559 SCB status word defnitions
- */
+/* 82559 SCB status word defnitions */
#define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */
#define SCB_STATUS_FR 0x4000 /* frame received */
#define SCB_STATUS_CNA 0x2000 /* CU left active state */
@@ -45,8 +43,7 @@
#define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA)
#define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR)
- /* System control block commands
- */
+/* System control block commands */
/* CU Commands */
#define CU_NOP 0x0000
#define CU_START 0x0010
@@ -81,16 +78,14 @@
#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2))
#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2))
- /* 82559 Port interface commands.
- */
+/* 82559 Port interface commands. */
#define I82559_RESET 0x00000000 /* Software reset */
#define I82559_SELFTEST 0x00000001 /* 82559 Selftest command */
#define I82559_SELECTIVE_RESET 0x00000002
#define I82559_DUMP 0x00000003
#define I82559_DUMP_WAKEUP 0x00000007
- /* 82559 Eeprom interface.
- */
+/* 82559 Eeprom interface. */
#define EE_SHIFT_CLK 0x01 /* EEPROM shift clock. */
#define EE_CS 0x02 /* EEPROM chip select. */
#define EE_DATA_WRITE 0x04 /* EEPROM chip data in. */
@@ -101,15 +96,13 @@
#define EE_CMD_BITS 3
#define EE_DATA_BITS 16
- /* The EEPROM commands include the alway-set leading bit.
- */
+/* The EEPROM commands include the alway-set leading bit. */
#define EE_EWENB_CMD (4 << addr_len)
#define EE_WRITE_CMD (5 << addr_len)
#define EE_READ_CMD (6 << addr_len)
#define EE_ERASE_CMD (7 << addr_len)
- /* Receive frame descriptors.
- */
+/* Receive frame descriptors. */
struct RxFD {
volatile u16 status;
volatile u16 control;
@@ -143,8 +136,7 @@ struct RxFD {
#define RFD_RX_IA_MATCH 0x0002 /* individual address does not match */
#define RFD_RX_TCO 0x0001 /* TCO indication */
- /* Transmit frame descriptors
- */
+/* Transmit frame descriptors */
struct TxFD { /* Transmit frame descriptor set. */
volatile u16 status;
volatile u16 command;
@@ -152,9 +144,9 @@ struct TxFD { /* Transmit frame descriptor set. */
volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */
volatile s32 count;
- volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */
+ volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */
volatile s32 tx_buf_size0; /* Length of Tx frame. */
- volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */
+ volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */
volatile s32 tx_buf_size1; /* Length of Tx frame. */
};
@@ -168,12 +160,11 @@ struct TxFD { /* Transmit frame descriptor set. */
#define TxCB_COUNT_MASK 0x3fff
#define TxCB_COUNT_EOF 0x8000
- /* The Speedo3 Rx and Tx frame/buffer descriptors.
- */
+/* The Speedo3 Rx and Tx frame/buffer descriptors. */
struct descriptor { /* A generic descriptor. */
volatile u16 status;
volatile u16 command;
- volatile u32 link; /* struct descriptor * */
+ volatile u32 link; /* struct descriptor * */
unsigned char params[0];
};
@@ -187,15 +178,14 @@ struct descriptor { /* A generic descriptor. */
#define CONFIG_SYS_STATUS_C 0x8000
#define CONFIG_SYS_STATUS_OK 0x2000
- /* Misc.
- */
+/* Misc. */
#define NUM_RX_DESC PKTBUFSRX
-#define NUM_TX_DESC 1 /* Number of TX descriptors */
+#define NUM_TX_DESC 1 /* Number of TX descriptors */
#define TOUT_LOOP 1000000
-static struct RxFD rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
-static struct TxFD tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
+static struct RxFD rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
+static struct TxFD tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
static int rx_next; /* RX descriptor ring pointer */
static int tx_next; /* TX descriptor ring pointer */
static int tx_threshold;
@@ -293,7 +283,8 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,
return 0;
}
-/* Check if given phyaddr is valid, i.e. there is a PHY connected.
+/*
+ * Check if given phyaddr is valid, i.e. there is a PHY connected.
* Do this by checking model value field from ID2 register.
*/
static struct eth_device* verify_phyaddr (const char *devname,
@@ -363,8 +354,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
#endif
-/* Wait for the chip get the command.
-*/
+/* Wait for the chip get the command. */
static int wait_for_eepro100 (struct eth_device *dev)
{
int i;
@@ -394,8 +384,7 @@ int eepro100_initialize (bd_t * bis)
int idx = 0;
while (1) {
- /* Find PCI device
- */
+ /* Find PCI device */
if ((devno = pci_find_devices (supported, idx++)) < 0) {
break;
}
@@ -412,8 +401,7 @@ int eepro100_initialize (bd_t * bis)
PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
- /* Check if I/O accesses and Bus Mastering are enabled.
- */
+ /* Check if I/O accesses and Bus Mastering are enabled. */
pci_read_config_dword (devno, PCI_COMMAND, &status);
if (!(status & PCI_COMMAND_MEMORY)) {
printf ("Error: Can not enable MEM access.\n");
@@ -459,8 +447,7 @@ int eepro100_initialize (bd_t * bis)
card_number++;
- /* Set the latency timer for value.
- */
+ /* Set the latency timer for value. */
pci_write_config_byte (devno, PCI_LATENCY_TIMER, 0x20);
udelay(10 * 1000);
@@ -478,8 +465,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
int tx_cur;
struct descriptor *ias_cmd, *cfg_cmd;
- /* Reset the ethernet controller
- */
+ /* Reset the ethernet controller */
OUTL (dev, I82559_SELECTIVE_RESET, SCBPort);
udelay(20);
@@ -500,13 +486,11 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
OUTL (dev, 0, SCBPointer);
OUTW (dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
- /* Initialize Rx and Tx rings.
- */
+ /* Initialize Rx and Tx rings. */
init_rx_ring (dev);
purge_tx_ring (dev);
- /* Tell the adapter where the RX ring is located.
- */
+ /* Tell the adapter where the RX ring is located. */
if (!wait_for_eepro100 (dev)) {
printf ("Error: Can not reset ethernet controller.\n");
goto Done;
@@ -550,8 +534,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
goto Done;
}
- /* Send the Individual Address Setup frame
- */
+ /* Send the Individual Address Setup frame */
tx_cur = tx_next;
tx_next = ((tx_next + 1) % NUM_TX_DESC);
@@ -562,8 +545,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
memcpy (ias_cmd->params, dev->enetaddr, 6);
- /* Tell the adapter where the TX ring is located.
- */
+ /* Tell the adapter where the TX ring is located. */
if (!wait_for_eepro100 (dev)) {
printf ("Error: Can not reset ethernet controller.\n");
goto Done;
@@ -626,8 +608,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
goto Done;
}
- /* Send the packet.
- */
+ /* Send the packet. */
OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);
OUTW (dev, SCB_M | CU_START, SCBCmd);
@@ -666,21 +647,16 @@ static int eepro100_recv (struct eth_device *dev)
break;
}
- /* Valid frame status.
- */
+ /* Valid frame status. */
if ((status & RFD_STATUS_OK)) {
- /* A valid frame received.
- */
+ /* A valid frame received. */
length = le32_to_cpu (rx_ring[rx_next].count) & 0x3fff;
- /* Pass the packet up to the protocol
- * layers.
- */
+ /* Pass the packet up to the protocol layers. */
net_process_received_packet((u8 *)rx_ring[rx_next].data,
length);
} else {
- /* There was an error.
- */
+ /* There was an error. */
printf ("RX error status = 0x%08X\n", status);
}
@@ -691,8 +667,7 @@ static int eepro100_recv (struct eth_device *dev)
rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
rx_ring[rx_prev].control = 0;
- /* Update entry information.
- */
+ /* Update entry information. */
rx_next = (rx_next + 1) % NUM_RX_DESC;
}
@@ -700,8 +675,7 @@ static int eepro100_recv (struct eth_device *dev)
printf ("%s: Receiver is not ready, restart it !\n", dev->name);
- /* Reinitialize Rx ring.
- */
+ /* Reinitialize Rx ring. */
init_rx_ring (dev);
if (!wait_for_eepro100 (dev)) {
@@ -719,8 +693,7 @@ static int eepro100_recv (struct eth_device *dev)
static void eepro100_halt (struct eth_device *dev)
{
- /* Reset the ethernet controller
- */
+ /* Reset the ethernet controller */
OUTL (dev, I82559_SELECTIVE_RESET, SCBPort);
udelay(20);
@@ -745,8 +718,7 @@ static void eepro100_halt (struct eth_device *dev)
return;
}
- /* SROM Read.
- */
+/* SROM Read. */
static int read_eeprom (struct eth_device *dev, int location, int addr_len)
{
unsigned short retval = 0;
--
cgit v1.1
From e5352c6bbe1606b4e2e9845dba54a83af14f3da0 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:11:48 +0200
Subject: net: eepro100: Use plain debug()
Convert all the ifdef DEBUG to plain debug(), no functional change.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 503c44a..dd90238 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -13,8 +13,6 @@
#include
#include
-#undef DEBUG
-
/* Ethernet chip registers. */
#define SCBStatus 0 /* Rx/Command Unit Status *Word* */
#define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */
@@ -392,10 +390,8 @@ int eepro100_initialize (bd_t * bis)
pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, &iobase);
iobase &= ~0xf;
-#ifdef DEBUG
- printf ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
- iobase);
-#endif
+ debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
+ iobase);
pci_write_config_dword (devno,
PCI_COMMAND,
@@ -810,10 +806,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)
if (sum != 0xBABA) {
memset (dev->enetaddr, 0, ETH_ALEN);
-#ifdef DEBUG
- printf ("%s: Invalid EEPROM checksum %#4.4x, "
- "check settings before activating this device!\n",
- dev->name, sum);
-#endif
+ debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",
+ dev->name, sum);
}
}
--
cgit v1.1
From db9f1818bfc79fd96301b8b4eae1db8b136e7570 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:17:03 +0200
Subject: net: eepro100: Fix spacing
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl --types SPACING -f --fix --fix-inplace drivers/net/eepro100.c
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 278 ++++++++++++++++++++++++-------------------------
1 file changed, 139 insertions(+), 139 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index dd90238..1b6d537 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -68,13 +68,13 @@
#define CU_STATUS_MASK 0x00C0
#define RU_STATUS_MASK 0x003C
-#define RU_STATUS_IDLE (0<<2)
-#define RU_STATUS_SUS (1<<2)
-#define RU_STATUS_NORES (2<<2)
-#define RU_STATUS_READY (4<<2)
-#define RU_STATUS_NO_RBDS_SUS ((1<<2)|(8<<2))
-#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2))
-#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2))
+#define RU_STATUS_IDLE (0 << 2)
+#define RU_STATUS_SUS (1 << 2)
+#define RU_STATUS_NORES (2 << 2)
+#define RU_STATUS_READY (4 << 2)
+#define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2))
+#define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2))
+#define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2))
/* 82559 Port interface commands. */
#define I82559_RESET 0x00000000 /* Software reset */
@@ -200,15 +200,15 @@ static const char i82558_config_cmd[] = {
0x31, 0x05,
};
-static void init_rx_ring (struct eth_device *dev);
-static void purge_tx_ring (struct eth_device *dev);
+static void init_rx_ring(struct eth_device *dev);
+static void purge_tx_ring(struct eth_device *dev);
-static void read_hw_addr (struct eth_device *dev, bd_t * bis);
+static void read_hw_addr(struct eth_device *dev, bd_t * bis);
-static int eepro100_init (struct eth_device *dev, bd_t * bis);
+static int eepro100_init(struct eth_device *dev, bd_t * bis);
static int eepro100_send(struct eth_device *dev, void *packet, int length);
-static int eepro100_recv (struct eth_device *dev);
-static void eepro100_halt (struct eth_device *dev);
+static int eepro100_recv(struct eth_device *dev);
+static void eepro100_halt(struct eth_device *dev);
#if defined(CONFIG_E500)
#define bus_to_phys(a) (a)
@@ -218,28 +218,28 @@ static void eepro100_halt (struct eth_device *dev);
#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
#endif
-static inline int INW (struct eth_device *dev, u_long addr)
+static inline int INW(struct eth_device *dev, u_long addr)
{
return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase));
}
-static inline void OUTW (struct eth_device *dev, int command, u_long addr)
+static inline void OUTW(struct eth_device *dev, int command, u_long addr)
{
*(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command);
}
-static inline void OUTL (struct eth_device *dev, int command, u_long addr)
+static inline void OUTL(struct eth_device *dev, int command, u_long addr)
{
*(volatile u32 *)((addr + (u_long)dev->iobase)) = cpu_to_le32(command);
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-static inline int INL (struct eth_device *dev, u_long addr)
+static inline int INL(struct eth_device *dev, u_long addr)
{
return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase));
}
-static int get_phyreg (struct eth_device *dev, unsigned char addr,
+static int get_phyreg(struct eth_device *dev, unsigned char addr,
unsigned char reg, unsigned short *value)
{
int cmd;
@@ -247,22 +247,22 @@ static int get_phyreg (struct eth_device *dev, unsigned char addr,
/* read requested data */
cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
- OUTL (dev, cmd, SCBCtrlMDI);
+ OUTL(dev, cmd, SCBCtrlMDI);
do {
udelay(1000);
- cmd = INL (dev, SCBCtrlMDI);
+ cmd = INL(dev, SCBCtrlMDI);
} while (!(cmd & (1 << 28)) && (--timeout));
if (timeout == 0)
return -1;
- *value = (unsigned short) (cmd & 0xffff);
+ *value = (unsigned short)(cmd & 0xffff);
return 0;
}
-static int set_phyreg (struct eth_device *dev, unsigned char addr,
+static int set_phyreg(struct eth_device *dev, unsigned char addr,
unsigned char reg, unsigned short value)
{
int cmd;
@@ -270,9 +270,9 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,
/* write requested data */
cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
- OUTL (dev, cmd | value, SCBCtrlMDI);
+ OUTL(dev, cmd | value, SCBCtrlMDI);
- while (!(INL (dev, SCBCtrlMDI) & (1 << 28)) && (--timeout))
+ while (!(INL(dev, SCBCtrlMDI) & (1 << 28)) && (--timeout))
udelay(1000);
if (timeout == 0)
@@ -285,7 +285,7 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,
* Check if given phyaddr is valid, i.e. there is a PHY connected.
* Do this by checking model value field from ID2 register.
*/
-static struct eth_device* verify_phyaddr (const char *devname,
+static struct eth_device* verify_phyaddr(const char *devname,
unsigned char addr)
{
struct eth_device *dev;
@@ -353,11 +353,11 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
#endif
/* Wait for the chip get the command. */
-static int wait_for_eepro100 (struct eth_device *dev)
+static int wait_for_eepro100(struct eth_device *dev)
{
int i;
- for (i = 0; INW (dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
+ for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
if (i >= TOUT_LOOP) {
return 0;
}
@@ -373,7 +373,7 @@ static struct pci_device_id supported[] = {
{}
};
-int eepro100_initialize (bd_t * bis)
+int eepro100_initialize(bd_t * bis)
{
pci_dev_t devno;
int card_number = 0;
@@ -383,50 +383,50 @@ int eepro100_initialize (bd_t * bis)
while (1) {
/* Find PCI device */
- if ((devno = pci_find_devices (supported, idx++)) < 0) {
+ if ((devno = pci_find_devices(supported, idx++)) < 0) {
break;
}
- pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, &iobase);
+ pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase);
iobase &= ~0xf;
debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
iobase);
- pci_write_config_dword (devno,
+ pci_write_config_dword(devno,
PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
/* Check if I/O accesses and Bus Mastering are enabled. */
- pci_read_config_dword (devno, PCI_COMMAND, &status);
+ pci_read_config_dword(devno, PCI_COMMAND, &status);
if (!(status & PCI_COMMAND_MEMORY)) {
- printf ("Error: Can not enable MEM access.\n");
+ printf("Error: Can not enable MEM access.\n");
continue;
}
if (!(status & PCI_COMMAND_MASTER)) {
- printf ("Error: Can not enable Bus Mastering.\n");
+ printf("Error: Can not enable Bus Mastering.\n");
continue;
}
- dev = (struct eth_device *) malloc (sizeof *dev);
+ dev = (struct eth_device *)malloc(sizeof *dev);
if (!dev) {
printf("eepro100: Can not allocate memory\n");
break;
}
memset(dev, 0, sizeof(*dev));
- sprintf (dev->name, "i82559#%d", card_number);
- dev->priv = (void *) devno; /* this have to come before bus_to_phys() */
- dev->iobase = bus_to_phys (iobase);
+ sprintf(dev->name, "i82559#%d", card_number);
+ dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
+ dev->iobase = bus_to_phys(iobase);
dev->init = eepro100_init;
dev->halt = eepro100_halt;
dev->send = eepro100_send;
dev->recv = eepro100_recv;
- eth_register (dev);
+ eth_register(dev);
-#if defined (CONFIG_MII) || defined(CONFIG_CMD_MII)
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
/* register mii command access routines */
int retval;
struct mii_dev *mdiodev = mdio_alloc();
@@ -444,89 +444,89 @@ int eepro100_initialize (bd_t * bis)
card_number++;
/* Set the latency timer for value. */
- pci_write_config_byte (devno, PCI_LATENCY_TIMER, 0x20);
+ pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20);
udelay(10 * 1000);
- read_hw_addr (dev, bis);
+ read_hw_addr(dev, bis);
}
return card_number;
}
-static int eepro100_init (struct eth_device *dev, bd_t * bis)
+static int eepro100_init(struct eth_device *dev, bd_t * bis)
{
int i, status = -1;
int tx_cur;
struct descriptor *ias_cmd, *cfg_cmd;
/* Reset the ethernet controller */
- OUTL (dev, I82559_SELECTIVE_RESET, SCBPort);
+ OUTL(dev, I82559_SELECTIVE_RESET, SCBPort);
udelay(20);
- OUTL (dev, I82559_RESET, SCBPort);
+ OUTL(dev, I82559_RESET, SCBPort);
udelay(20);
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, 0, SCBPointer);
- OUTW (dev, SCB_M | RUC_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCBPointer);
+ OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd);
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, 0, SCBPointer);
- OUTW (dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCBPointer);
+ OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
/* Initialize Rx and Tx rings. */
- init_rx_ring (dev);
- purge_tx_ring (dev);
+ init_rx_ring(dev);
+ purge_tx_ring(dev);
/* Tell the adapter where the RX ring is located. */
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer);
- OUTW (dev, SCB_M | RUC_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer);
+ OUTW(dev, SCB_M | RUC_START, SCBCmd);
/* Send the Configure frame */
tx_cur = tx_next;
tx_next = ((tx_next + 1) % NUM_TX_DESC);
- cfg_cmd = (struct descriptor *) &tx_ring[tx_cur];
+ cfg_cmd = (struct descriptor *)&tx_ring[tx_cur];
cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE));
cfg_cmd->status = 0;
- cfg_cmd->link = cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next]));
+ cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
- memcpy (cfg_cmd->params, i82558_config_cmd,
- sizeof (i82558_config_cmd));
+ memcpy(cfg_cmd->params, i82558_config_cmd,
+ sizeof(i82558_config_cmd));
- if (!wait_for_eepro100 (dev)) {
- printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);
- OUTW (dev, SCB_M | CU_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
+ OUTW(dev, SCB_M | CU_START, SCBCmd);
for (i = 0;
- !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
+ !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
i++) {
if (i >= TOUT_LOOP) {
- printf ("%s: Tx error buffer not ready\n", dev->name);
+ printf("%s: Tx error buffer not ready\n", dev->name);
goto Done;
}
}
- if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
- printf ("TX error status = 0x%08X\n",
- le16_to_cpu (tx_ring[tx_cur].status));
+ if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
+ printf("TX error status = 0x%08X\n",
+ le16_to_cpu(tx_ring[tx_cur].status));
goto Done;
}
@@ -534,34 +534,34 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)
tx_cur = tx_next;
tx_next = ((tx_next + 1) % NUM_TX_DESC);
- ias_cmd = (struct descriptor *) &tx_ring[tx_cur];
+ ias_cmd = (struct descriptor *)&tx_ring[tx_cur];
ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS));
ias_cmd->status = 0;
- ias_cmd->link = cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next]));
+ ias_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
- memcpy (ias_cmd->params, dev->enetaddr, 6);
+ memcpy(ias_cmd->params, dev->enetaddr, 6);
/* Tell the adapter where the TX ring is located. */
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);
- OUTW (dev, SCB_M | CU_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
+ OUTW(dev, SCB_M | CU_START, SCBCmd);
- for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
+ for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
i++) {
if (i >= TOUT_LOOP) {
- printf ("%s: Tx error buffer not ready\n",
+ printf("%s: Tx error buffer not ready\n",
dev->name);
goto Done;
}
}
- if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
- printf ("TX error status = 0x%08X\n",
- le16_to_cpu (tx_ring[tx_cur].status));
+ if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
+ printf("TX error status = 0x%08X\n",
+ le16_to_cpu(tx_ring[tx_cur].status));
goto Done;
}
@@ -577,48 +577,48 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
int tx_cur;
if (length <= 0) {
- printf ("%s: bad packet size: %d\n", dev->name, length);
+ printf("%s: bad packet size: %d\n", dev->name, length);
goto Done;
}
tx_cur = tx_next;
tx_next = (tx_next + 1) % NUM_TX_DESC;
- tx_ring[tx_cur].command = cpu_to_le16 ( TxCB_CMD_TRANSMIT |
+ tx_ring[tx_cur].command = cpu_to_le16 (TxCB_CMD_TRANSMIT |
TxCB_CMD_SF |
TxCB_CMD_S |
- TxCB_CMD_EL );
+ TxCB_CMD_EL);
tx_ring[tx_cur].status = 0;
tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold);
tx_ring[tx_cur].link =
- cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next]));
+ cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
tx_ring[tx_cur].tx_desc_addr =
- cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_cur].tx_buf_addr0));
+ cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0));
tx_ring[tx_cur].tx_buf_addr0 =
- cpu_to_le32 (phys_to_bus ((u_long) packet));
+ cpu_to_le32 (phys_to_bus((u_long)packet));
tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length);
- if (!wait_for_eepro100 (dev)) {
- printf ("%s: Tx error ethernet controller not ready.\n",
+ if (!wait_for_eepro100(dev)) {
+ printf("%s: Tx error ethernet controller not ready.\n",
dev->name);
goto Done;
}
/* Send the packet. */
- OUTL (dev, phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);
- OUTW (dev, SCB_M | CU_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
+ OUTW(dev, SCB_M | CU_START, SCBCmd);
- for (i = 0; !(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
+ for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
i++) {
if (i >= TOUT_LOOP) {
- printf ("%s: Tx error buffer not ready\n", dev->name);
+ printf("%s: Tx error buffer not ready\n", dev->name);
goto Done;
}
}
- if (!(le16_to_cpu (tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
- printf ("TX error status = 0x%08X\n",
- le16_to_cpu (tx_ring[tx_cur].status));
+ if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
+ printf("TX error status = 0x%08X\n",
+ le16_to_cpu(tx_ring[tx_cur].status));
goto Done;
}
@@ -628,16 +628,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
return status;
}
-static int eepro100_recv (struct eth_device *dev)
+static int eepro100_recv(struct eth_device *dev)
{
u16 status, stat;
int rx_prev, length = 0;
- stat = INW (dev, SCBStatus);
- OUTW (dev, stat & SCB_STATUS_RNR, SCBStatus);
+ stat = INW(dev, SCBStatus);
+ OUTW(dev, stat & SCB_STATUS_RNR, SCBStatus);
for (;;) {
- status = le16_to_cpu (rx_ring[rx_next].status);
+ status = le16_to_cpu(rx_ring[rx_next].status);
if (!(status & RFD_STATUS_C)) {
break;
@@ -646,14 +646,14 @@ static int eepro100_recv (struct eth_device *dev)
/* Valid frame status. */
if ((status & RFD_STATUS_OK)) {
/* A valid frame received. */
- length = le32_to_cpu (rx_ring[rx_next].count) & 0x3fff;
+ length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff;
/* Pass the packet up to the protocol layers. */
net_process_received_packet((u8 *)rx_ring[rx_next].data,
length);
} else {
/* There was an error. */
- printf ("RX error status = 0x%08X\n", status);
+ printf("RX error status = 0x%08X\n", status);
}
rx_ring[rx_next].control = cpu_to_le16 (RFD_CONTROL_S);
@@ -669,87 +669,87 @@ static int eepro100_recv (struct eth_device *dev)
if (stat & SCB_STATUS_RNR) {
- printf ("%s: Receiver is not ready, restart it !\n", dev->name);
+ printf("%s: Receiver is not ready, restart it !\n", dev->name);
/* Reinitialize Rx ring. */
- init_rx_ring (dev);
+ init_rx_ring(dev);
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not restart ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not restart ethernet controller.\n");
goto Done;
}
- OUTL (dev, phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer);
- OUTW (dev, SCB_M | RUC_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer);
+ OUTW(dev, SCB_M | RUC_START, SCBCmd);
}
Done:
return length;
}
-static void eepro100_halt (struct eth_device *dev)
+static void eepro100_halt(struct eth_device *dev)
{
/* Reset the ethernet controller */
- OUTL (dev, I82559_SELECTIVE_RESET, SCBPort);
+ OUTL(dev, I82559_SELECTIVE_RESET, SCBPort);
udelay(20);
- OUTL (dev, I82559_RESET, SCBPort);
+ OUTL(dev, I82559_RESET, SCBPort);
udelay(20);
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, 0, SCBPointer);
- OUTW (dev, SCB_M | RUC_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCBPointer);
+ OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd);
- if (!wait_for_eepro100 (dev)) {
- printf ("Error: Can not reset ethernet controller.\n");
+ if (!wait_for_eepro100(dev)) {
+ printf("Error: Can not reset ethernet controller.\n");
goto Done;
}
- OUTL (dev, 0, SCBPointer);
- OUTW (dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCBPointer);
+ OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
Done:
return;
}
/* SROM Read. */
-static int read_eeprom (struct eth_device *dev, int location, int addr_len)
+static int read_eeprom(struct eth_device *dev, int location, int addr_len)
{
unsigned short retval = 0;
int read_cmd = location | EE_READ_CMD;
int i;
- OUTW (dev, EE_ENB & ~EE_CS, SCBeeprom);
- OUTW (dev, EE_ENB, SCBeeprom);
+ OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
+ OUTW(dev, EE_ENB, SCBeeprom);
/* Shift the read command bits out. */
for (i = 12; i >= 0; i--) {
short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
- OUTW (dev, EE_ENB | dataval, SCBeeprom);
+ OUTW(dev, EE_ENB | dataval, SCBeeprom);
udelay(1);
- OUTW (dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom);
+ OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom);
udelay(1);
}
- OUTW (dev, EE_ENB, SCBeeprom);
+ OUTW(dev, EE_ENB, SCBeeprom);
for (i = 15; i >= 0; i--) {
- OUTW (dev, EE_ENB | EE_SHIFT_CLK, SCBeeprom);
+ OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCBeeprom);
udelay(1);
retval = (retval << 1) |
- ((INW (dev, SCBeeprom) & EE_DATA_READ) ? 1 : 0);
- OUTW (dev, EE_ENB, SCBeeprom);
+ ((INW(dev, SCBeeprom) & EE_DATA_READ) ? 1 : 0);
+ OUTW(dev, EE_ENB, SCBeeprom);
udelay(1);
}
/* Terminate the EEPROM access. */
- OUTW (dev, EE_ENB & ~EE_CS, SCBeeprom);
+ OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
return retval;
}
-static void init_rx_ring (struct eth_device *dev)
+static void init_rx_ring(struct eth_device *dev)
{
int i;
@@ -759,7 +759,7 @@ static void init_rx_ring (struct eth_device *dev)
(i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0;
rx_ring[i].link =
cpu_to_le32 (phys_to_bus
- ((u32) & rx_ring[(i + 1) % NUM_RX_DESC]));
+ ((u32)&rx_ring[(i + 1) % NUM_RX_DESC]));
rx_ring[i].rx_buf_addr = 0xffffffff;
rx_ring[i].count = cpu_to_le32 (PKTSIZE_ALIGN << 16);
}
@@ -767,7 +767,7 @@ static void init_rx_ring (struct eth_device *dev)
rx_next = 0;
}
-static void purge_tx_ring (struct eth_device *dev)
+static void purge_tx_ring(struct eth_device *dev)
{
int i;
@@ -788,14 +788,14 @@ static void purge_tx_ring (struct eth_device *dev)
}
}
-static void read_hw_addr (struct eth_device *dev, bd_t * bis)
+static void read_hw_addr(struct eth_device *dev, bd_t * bis)
{
u16 sum = 0;
int i, j;
- int addr_len = read_eeprom (dev, 0, 6) == 0xffff ? 8 : 6;
+ int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6;
for (j = 0, i = 0; i < 0x40; i++) {
- u16 value = read_eeprom (dev, i, addr_len);
+ u16 value = read_eeprom(dev, i, addr_len);
sum += value;
if (i < 3) {
@@ -805,7 +805,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)
}
if (sum != 0xBABA) {
- memset (dev->enetaddr, 0, ETH_ALEN);
+ memset(dev->enetaddr, 0, ETH_ALEN);
debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",
dev->name, sum);
}
--
cgit v1.1
From 9b12ff9911ec1a3b89648e0753e1d20d4d0ba2b0 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:20:14 +0200
Subject: net: eepro100: Fix braces
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl --types BRACES -f --fix --fix-inplace drivers/net/eepro100.c
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 1b6d537..6dccd59 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -358,9 +358,8 @@ static int wait_for_eepro100(struct eth_device *dev)
int i;
for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
- if (i >= TOUT_LOOP) {
+ if (i >= TOUT_LOOP)
return 0;
- }
}
return 1;
@@ -383,9 +382,9 @@ int eepro100_initialize(bd_t * bis)
while (1) {
/* Find PCI device */
- if ((devno = pci_find_devices(supported, idx++)) < 0) {
+ devno = pci_find_devices(supported, idx++);
+ if (devno < 0)
break;
- }
pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase);
iobase &= ~0xf;
@@ -639,9 +638,8 @@ static int eepro100_recv(struct eth_device *dev)
for (;;) {
status = le16_to_cpu(rx_ring[rx_next].status);
- if (!(status & RFD_STATUS_C)) {
+ if (!(status & RFD_STATUS_C))
break;
- }
/* Valid frame status. */
if ((status & RFD_STATUS_OK)) {
@@ -668,7 +666,6 @@ static int eepro100_recv(struct eth_device *dev)
}
if (stat & SCB_STATUS_RNR) {
-
printf("%s: Receiver is not ready, restart it !\n", dev->name);
/* Reinitialize Rx ring. */
--
cgit v1.1
From 773af836daee64743a51450ee25d758283d4281f Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:21:43 +0200
Subject: net: eepro100: Fix parenthesis alignment
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl --types PARENTHESIS_ALIGNMENT -f --fix --fix-inplace drivers/net/eepro100.c
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 6dccd59..d367052 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -240,7 +240,7 @@ static inline int INL(struct eth_device *dev, u_long addr)
}
static int get_phyreg(struct eth_device *dev, unsigned char addr,
- unsigned char reg, unsigned short *value)
+ unsigned char reg, unsigned short *value)
{
int cmd;
int timeout = 50;
@@ -263,7 +263,7 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,
}
static int set_phyreg(struct eth_device *dev, unsigned char addr,
- unsigned char reg, unsigned short value)
+ unsigned char reg, unsigned short value)
{
int cmd;
int timeout = 50;
@@ -286,7 +286,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,
* Do this by checking model value field from ID2 register.
*/
static struct eth_device* verify_phyaddr(const char *devname,
- unsigned char addr)
+ unsigned char addr)
{
struct eth_device *dev;
unsigned short value;
@@ -393,7 +393,7 @@ int eepro100_initialize(bd_t * bis)
iobase);
pci_write_config_dword(devno,
- PCI_COMMAND,
+ PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
/* Check if I/O accesses and Bus Mastering are enabled. */
@@ -504,7 +504,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis)
cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
memcpy(cfg_cmd->params, i82558_config_cmd,
- sizeof(i82558_config_cmd));
+ sizeof(i82558_config_cmd));
if (!wait_for_eepro100(dev)) {
printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
@@ -525,7 +525,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis)
if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
printf("TX error status = 0x%08X\n",
- le16_to_cpu(tx_ring[tx_cur].status));
+ le16_to_cpu(tx_ring[tx_cur].status));
goto Done;
}
@@ -553,14 +553,14 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis)
i++) {
if (i >= TOUT_LOOP) {
printf("%s: Tx error buffer not ready\n",
- dev->name);
+ dev->name);
goto Done;
}
}
if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
printf("TX error status = 0x%08X\n",
- le16_to_cpu(tx_ring[tx_cur].status));
+ le16_to_cpu(tx_ring[tx_cur].status));
goto Done;
}
@@ -599,7 +599,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
if (!wait_for_eepro100(dev)) {
printf("%s: Tx error ethernet controller not ready.\n",
- dev->name);
+ dev->name);
goto Done;
}
@@ -617,7 +617,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
printf("TX error status = 0x%08X\n",
- le16_to_cpu(tx_ring[tx_cur].status));
+ le16_to_cpu(tx_ring[tx_cur].status));
goto Done;
}
--
cgit v1.1
From 7a30873585c9da2221f652c091bab5e66d5d6653 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:23:13 +0200
Subject: net: eepro100: Fix pointer location
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl --types POINTER_LOCATION -f --fix --fix-inplace drivers/net/eepro100.c
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index d367052..2aad124 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -203,9 +203,9 @@ static const char i82558_config_cmd[] = {
static void init_rx_ring(struct eth_device *dev);
static void purge_tx_ring(struct eth_device *dev);
-static void read_hw_addr(struct eth_device *dev, bd_t * bis);
+static void read_hw_addr(struct eth_device *dev, bd_t *bis);
-static int eepro100_init(struct eth_device *dev, bd_t * bis);
+static int eepro100_init(struct eth_device *dev, bd_t *bis);
static int eepro100_send(struct eth_device *dev, void *packet, int length);
static int eepro100_recv(struct eth_device *dev);
static void eepro100_halt(struct eth_device *dev);
@@ -285,7 +285,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,
* Check if given phyaddr is valid, i.e. there is a PHY connected.
* Do this by checking model value field from ID2 register.
*/
-static struct eth_device* verify_phyaddr(const char *devname,
+static struct eth_device *verify_phyaddr(const char *devname,
unsigned char addr)
{
struct eth_device *dev;
@@ -372,7 +372,7 @@ static struct pci_device_id supported[] = {
{}
};
-int eepro100_initialize(bd_t * bis)
+int eepro100_initialize(bd_t *bis)
{
pci_dev_t devno;
int card_number = 0;
@@ -454,7 +454,7 @@ int eepro100_initialize(bd_t * bis)
}
-static int eepro100_init(struct eth_device *dev, bd_t * bis)
+static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
int i, status = -1;
int tx_cur;
@@ -785,7 +785,7 @@ static void purge_tx_ring(struct eth_device *dev)
}
}
-static void read_hw_addr(struct eth_device *dev, bd_t * bis)
+static void read_hw_addr(struct eth_device *dev, bd_t *bis)
{
u16 sum = 0;
int i, j;
--
cgit v1.1
From 614e95152dd63ac5259cd99c5c90949dcc466123 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:26:50 +0200
Subject: net: eepro100: Fix indented label
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 2aad124..e5bc90f 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -566,7 +566,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
status = 0;
- Done:
+Done:
return status;
}
@@ -623,7 +623,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
status = length;
- Done:
+Done:
return status;
}
@@ -680,7 +680,7 @@ static int eepro100_recv(struct eth_device *dev)
OUTW(dev, SCB_M | RUC_START, SCBCmd);
}
- Done:
+Done:
return length;
}
@@ -707,7 +707,7 @@ static void eepro100_halt(struct eth_device *dev)
OUTL(dev, 0, SCBPointer);
OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
- Done:
+Done:
return;
}
--
cgit v1.1
From b0131730795c1ff7994a008d1c68b3b9b200d213 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:45:41 +0200
Subject: net: eepro100: Fix remaining checkpatch issues
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl -f --fix --fix-inplace drivers/net/eepro100.c
This fixes all the remaining errors except a couple of comments which
are longer than 80 characters, all the volatile misuse and all the
camelcase, that needs a separate patch.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index e5bc90f..45c0136 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -293,7 +293,7 @@ static struct eth_device *verify_phyaddr(const char *devname,
unsigned char model;
dev = eth_get_dev_by_name(devname);
- if (dev == NULL) {
+ if (!dev) {
printf("%s: no such device\n", devname);
return NULL;
}
@@ -322,7 +322,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
struct eth_device *dev;
dev = verify_phyaddr(bus->name, addr);
- if (dev == NULL)
+ if (!dev)
return -1;
if (get_phyreg(dev, addr, reg, &value) != 0) {
@@ -339,7 +339,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
struct eth_device *dev;
dev = verify_phyaddr(bus->name, addr);
- if (dev == NULL)
+ if (!dev)
return -1;
if (set_phyreg(dev, addr, reg, value) != 0) {
@@ -392,9 +392,8 @@ int eepro100_initialize(bd_t *bis)
debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
iobase);
- pci_write_config_dword(devno,
- PCI_COMMAND,
- PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
+ pci_write_config_dword(devno, PCI_COMMAND,
+ PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
/* Check if I/O accesses and Bus Mastering are enabled. */
pci_read_config_dword(devno, PCI_COMMAND, &status);
@@ -408,7 +407,7 @@ int eepro100_initialize(bd_t *bis)
continue;
}
- dev = (struct eth_device *)malloc(sizeof *dev);
+ dev = (struct eth_device *)malloc(sizeof(*dev));
if (!dev) {
printf("eepro100: Can not allocate memory\n");
break;
@@ -429,6 +428,7 @@ int eepro100_initialize(bd_t *bis)
/* register mii command access routines */
int retval;
struct mii_dev *mdiodev = mdio_alloc();
+
if (!mdiodev)
return -ENOMEM;
strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
@@ -453,7 +453,6 @@ int eepro100_initialize(bd_t *bis)
return card_number;
}
-
static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
int i, status = -1;
@@ -499,9 +498,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
tx_next = ((tx_next + 1) % NUM_TX_DESC);
cfg_cmd = (struct descriptor *)&tx_ring[tx_cur];
- cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE));
+ cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
+ CONFIG_SYS_CMD_CONFIGURE);
cfg_cmd->status = 0;
- cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
+ cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
memcpy(cfg_cmd->params, i82558_config_cmd,
sizeof(i82558_config_cmd));
@@ -534,9 +534,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
tx_next = ((tx_next + 1) % NUM_TX_DESC);
ias_cmd = (struct descriptor *)&tx_ring[tx_cur];
- ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS));
+ ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
+ CONFIG_SYS_CMD_IAS);
ias_cmd->status = 0;
- ias_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
+ ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
memcpy(ias_cmd->params, dev->enetaddr, 6);
@@ -549,8 +550,9 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
OUTW(dev, SCB_M | CU_START, SCBCmd);
- for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
- i++) {
+ for (i = 0;
+ !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
+ i++) {
if (i >= TOUT_LOOP) {
printf("%s: Tx error buffer not ready\n",
dev->name);
@@ -607,8 +609,9 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
OUTW(dev, SCB_M | CU_START, SCBCmd);
- for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
- i++) {
+ for (i = 0;
+ !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
+ i++) {
if (i >= TOUT_LOOP) {
printf("%s: Tx error buffer not ready\n", dev->name);
goto Done;
@@ -752,13 +755,13 @@ static void init_rx_ring(struct eth_device *dev)
for (i = 0; i < NUM_RX_DESC; i++) {
rx_ring[i].status = 0;
- rx_ring[i].control =
- (i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0;
+ rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
+ cpu_to_le16 (RFD_CONTROL_S) : 0;
rx_ring[i].link =
- cpu_to_le32 (phys_to_bus
- ((u32)&rx_ring[(i + 1) % NUM_RX_DESC]));
+ cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) %
+ NUM_RX_DESC]));
rx_ring[i].rx_buf_addr = 0xffffffff;
- rx_ring[i].count = cpu_to_le32 (PKTSIZE_ALIGN << 16);
+ rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
}
rx_next = 0;
--
cgit v1.1
From f3878f5c2821cca2c2587adf522319578ed0c1da Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 13:52:50 +0200
Subject: net: eepro100: Fix camelcase
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c
./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 172 ++++++++++++++++++++++++-------------------------
1 file changed, 85 insertions(+), 87 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 45c0136..d3ced08 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -14,18 +14,18 @@
#include
/* Ethernet chip registers. */
-#define SCBStatus 0 /* Rx/Command Unit Status *Word* */
-#define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */
-#define SCBCmd 2 /* Rx/Command Unit Command *Word* */
-#define SCBIntrCtlByte 3 /* Rx/Command Unit Intr.Control Byte */
-#define SCBPointer 4 /* General purpose pointer. */
-#define SCBPort 8 /* Misc. commands and operands. */
-#define SCBflash 12 /* Flash memory control. */
-#define SCBeeprom 14 /* EEPROM memory control. */
-#define SCBCtrlMDI 16 /* MDI interface control. */
-#define SCBEarlyRx 20 /* Early receive byte count. */
-#define SCBGenControl 28 /* 82559 General Control Register */
-#define SCBGenStatus 29 /* 82559 General Status register */
+#define SCB_STATUS 0 /* Rx/Command Unit Status *Word* */
+#define SCB_INT_ACK_BYTE 1 /* Rx/Command Unit STAT/ACK byte */
+#define SCB_CMD 2 /* Rx/Command Unit Command *Word* */
+#define SCB_INTR_CTL_BYTE 3 /* Rx/Command Unit Intr.Control Byte */
+#define SCB_POINTER 4 /* General purpose pointer. */
+#define SCB_PORT 8 /* Misc. commands and operands. */
+#define SCB_FLASH 12 /* Flash memory control. */
+#define SCB_EEPROM 14 /* EEPROM memory control. */
+#define SCB_CTRL_MDI 16 /* MDI interface control. */
+#define SCB_EARLY_RX 20 /* Early receive byte count. */
+#define SCB_GEN_CONTROL 28 /* 82559 General Control Register */
+#define SCB_GEN_STATUS 29 /* 82559 General Status register */
/* 82559 SCB status word defnitions */
#define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */
@@ -101,10 +101,10 @@
#define EE_ERASE_CMD (7 << addr_len)
/* Receive frame descriptors. */
-struct RxFD {
+struct eepro100_rxfd {
volatile u16 status;
volatile u16 control;
- volatile u32 link; /* struct RxFD * */
+ volatile u32 link; /* struct eepro100_rxfd * */
volatile u32 rx_buf_addr; /* void * */
volatile u32 count;
@@ -135,7 +135,7 @@ struct RxFD {
#define RFD_RX_TCO 0x0001 /* TCO indication */
/* Transmit frame descriptors */
-struct TxFD { /* Transmit frame descriptor set. */
+struct eepro100_txfd { /* Transmit frame descriptor set. */
volatile u16 status;
volatile u16 command;
volatile u32 link; /* void * */
@@ -148,15 +148,15 @@ struct TxFD { /* Transmit frame descriptor set. */
volatile s32 tx_buf_size1; /* Length of Tx frame. */
};
-#define TxCB_CMD_TRANSMIT 0x0004 /* transmit command */
-#define TxCB_CMD_SF 0x0008 /* 0=simplified, 1=flexible mode */
-#define TxCB_CMD_NC 0x0010 /* 0=CRC insert by controller */
-#define TxCB_CMD_I 0x2000 /* generate interrupt on completion */
-#define TxCB_CMD_S 0x4000 /* suspend on completion */
-#define TxCB_CMD_EL 0x8000 /* last command block in CBL */
+#define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */
+#define TXCB_CMD_SF 0x0008 /* 0=simplified, 1=flexible mode */
+#define TXCB_CMD_NC 0x0010 /* 0=CRC insert by controller */
+#define TXCB_CMD_I 0x2000 /* generate interrupt on completion */
+#define TXCB_CMD_S 0x4000 /* suspend on completion */
+#define TXCB_CMD_EL 0x8000 /* last command block in CBL */
-#define TxCB_COUNT_MASK 0x3fff
-#define TxCB_COUNT_EOF 0x8000
+#define TXCB_COUNT_MASK 0x3fff
+#define TXCB_COUNT_EOF 0x8000
/* The Speedo3 Rx and Tx frame/buffer descriptors. */
struct descriptor { /* A generic descriptor. */
@@ -182,8 +182,8 @@ struct descriptor { /* A generic descriptor. */
#define TOUT_LOOP 1000000
-static struct RxFD rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
-static struct TxFD tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
+static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
+static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
static int rx_next; /* RX descriptor ring pointer */
static int tx_next; /* TX descriptor ring pointer */
static int tx_threshold;
@@ -247,11 +247,11 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,
/* read requested data */
cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
- OUTL(dev, cmd, SCBCtrlMDI);
+ OUTL(dev, cmd, SCB_CTRL_MDI);
do {
udelay(1000);
- cmd = INL(dev, SCBCtrlMDI);
+ cmd = INL(dev, SCB_CTRL_MDI);
} while (!(cmd & (1 << 28)) && (--timeout));
if (timeout == 0)
@@ -270,9 +270,9 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,
/* write requested data */
cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
- OUTL(dev, cmd | value, SCBCtrlMDI);
+ OUTL(dev, cmd | value, SCB_CTRL_MDI);
- while (!(INL(dev, SCBCtrlMDI) & (1 << 28)) && (--timeout))
+ while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout))
udelay(1000);
if (timeout == 0)
@@ -357,7 +357,7 @@ static int wait_for_eepro100(struct eth_device *dev)
{
int i;
- for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
+ for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
if (i >= TOUT_LOOP)
return 0;
}
@@ -460,25 +460,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
struct descriptor *ias_cmd, *cfg_cmd;
/* Reset the ethernet controller */
- OUTL(dev, I82559_SELECTIVE_RESET, SCBPort);
+ OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
udelay(20);
- OUTL(dev, I82559_RESET, SCBPort);
+ OUTL(dev, I82559_RESET, SCB_PORT);
udelay(20);
if (!wait_for_eepro100(dev)) {
printf("Error: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, 0, SCBPointer);
- OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCB_POINTER);
+ OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
if (!wait_for_eepro100(dev)) {
printf("Error: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, 0, SCBPointer);
- OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCB_POINTER);
+ OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD);
/* Initialize Rx and Tx rings. */
init_rx_ring(dev);
@@ -487,11 +487,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
/* Tell the adapter where the RX ring is located. */
if (!wait_for_eepro100(dev)) {
printf("Error: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer);
- OUTW(dev, SCB_M | RUC_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
+ OUTW(dev, SCB_M | RUC_START, SCB_CMD);
/* Send the Configure frame */
tx_cur = tx_next;
@@ -508,25 +508,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
if (!wait_for_eepro100(dev)) {
printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
- OUTW(dev, SCB_M | CU_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
+ OUTW(dev, SCB_M | CU_START, SCB_CMD);
for (i = 0;
!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
i++) {
if (i >= TOUT_LOOP) {
printf("%s: Tx error buffer not ready\n", dev->name);
- goto Done;
+ goto done;
}
}
if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
printf("TX error status = 0x%08X\n",
le16_to_cpu(tx_ring[tx_cur].status));
- goto Done;
+ goto done;
}
/* Send the Individual Address Setup frame */
@@ -544,11 +544,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
/* Tell the adapter where the TX ring is located. */
if (!wait_for_eepro100(dev)) {
printf("Error: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
- OUTW(dev, SCB_M | CU_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
+ OUTW(dev, SCB_M | CU_START, SCB_CMD);
for (i = 0;
!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
@@ -556,19 +556,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
if (i >= TOUT_LOOP) {
printf("%s: Tx error buffer not ready\n",
dev->name);
- goto Done;
+ goto done;
}
}
if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
printf("TX error status = 0x%08X\n",
le16_to_cpu(tx_ring[tx_cur].status));
- goto Done;
+ goto done;
}
status = 0;
-Done:
+done:
return status;
}
@@ -579,16 +579,14 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
if (length <= 0) {
printf("%s: bad packet size: %d\n", dev->name, length);
- goto Done;
+ goto done;
}
tx_cur = tx_next;
tx_next = (tx_next + 1) % NUM_TX_DESC;
- tx_ring[tx_cur].command = cpu_to_le16 (TxCB_CMD_TRANSMIT |
- TxCB_CMD_SF |
- TxCB_CMD_S |
- TxCB_CMD_EL);
+ tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF |
+ TXCB_CMD_S | TXCB_CMD_EL);
tx_ring[tx_cur].status = 0;
tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold);
tx_ring[tx_cur].link =
@@ -602,31 +600,31 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
if (!wait_for_eepro100(dev)) {
printf("%s: Tx error ethernet controller not ready.\n",
dev->name);
- goto Done;
+ goto done;
}
/* Send the packet. */
- OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer);
- OUTW(dev, SCB_M | CU_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
+ OUTW(dev, SCB_M | CU_START, SCB_CMD);
for (i = 0;
!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
i++) {
if (i >= TOUT_LOOP) {
printf("%s: Tx error buffer not ready\n", dev->name);
- goto Done;
+ goto done;
}
}
if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
printf("TX error status = 0x%08X\n",
le16_to_cpu(tx_ring[tx_cur].status));
- goto Done;
+ goto done;
}
status = length;
-Done:
+done:
return status;
}
@@ -635,8 +633,8 @@ static int eepro100_recv(struct eth_device *dev)
u16 status, stat;
int rx_prev, length = 0;
- stat = INW(dev, SCBStatus);
- OUTW(dev, stat & SCB_STATUS_RNR, SCBStatus);
+ stat = INW(dev, SCB_STATUS);
+ OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS);
for (;;) {
status = le16_to_cpu(rx_ring[rx_next].status);
@@ -676,41 +674,41 @@ static int eepro100_recv(struct eth_device *dev)
if (!wait_for_eepro100(dev)) {
printf("Error: Can not restart ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCBPointer);
- OUTW(dev, SCB_M | RUC_START, SCBCmd);
+ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
+ OUTW(dev, SCB_M | RUC_START, SCB_CMD);
}
-Done:
+done:
return length;
}
static void eepro100_halt(struct eth_device *dev)
{
/* Reset the ethernet controller */
- OUTL(dev, I82559_SELECTIVE_RESET, SCBPort);
+ OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
udelay(20);
- OUTL(dev, I82559_RESET, SCBPort);
+ OUTL(dev, I82559_RESET, SCB_PORT);
udelay(20);
if (!wait_for_eepro100(dev)) {
printf("Error: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, 0, SCBPointer);
- OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCB_POINTER);
+ OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
if (!wait_for_eepro100(dev)) {
printf("Error: Can not reset ethernet controller.\n");
- goto Done;
+ goto done;
}
- OUTL(dev, 0, SCBPointer);
- OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd);
+ OUTL(dev, 0, SCB_POINTER);
+ OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD);
-Done:
+done:
return;
}
@@ -721,31 +719,31 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)
int read_cmd = location | EE_READ_CMD;
int i;
- OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
- OUTW(dev, EE_ENB, SCBeeprom);
+ OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
+ OUTW(dev, EE_ENB, SCB_EEPROM);
/* Shift the read command bits out. */
for (i = 12; i >= 0; i--) {
short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
- OUTW(dev, EE_ENB | dataval, SCBeeprom);
+ OUTW(dev, EE_ENB | dataval, SCB_EEPROM);
udelay(1);
- OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom);
+ OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
udelay(1);
}
- OUTW(dev, EE_ENB, SCBeeprom);
+ OUTW(dev, EE_ENB, SCB_EEPROM);
for (i = 15; i >= 0; i--) {
- OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCBeeprom);
+ OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
udelay(1);
retval = (retval << 1) |
- ((INW(dev, SCBeeprom) & EE_DATA_READ) ? 1 : 0);
- OUTW(dev, EE_ENB, SCBeeprom);
+ ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0);
+ OUTW(dev, EE_ENB, SCB_EEPROM);
udelay(1);
}
/* Terminate the EEPROM access. */
- OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom);
+ OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
return retval;
}
--
cgit v1.1
From 81bdeea2fe62277922a6bd735f936b168352a49d Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 14:14:45 +0200
Subject: net: eepro100: Use standard I/O accessors
The current eepro100 driver accesses its memory mapped registers directly
instead of using the standard I/O accessors. This can cause problems on
some systems as the accesses can get out of order. So convert the direct
volatile dereferences to use the normal in/out macros.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index d3ced08..5d11665 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -220,23 +220,23 @@ static void eepro100_halt(struct eth_device *dev);
static inline int INW(struct eth_device *dev, u_long addr)
{
- return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase));
+ return le16_to_cpu(readw(addr + (void *)dev->iobase));
}
static inline void OUTW(struct eth_device *dev, int command, u_long addr)
{
- *(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command);
+ writew(cpu_to_le16(command), addr + (void *)dev->iobase);
}
static inline void OUTL(struct eth_device *dev, int command, u_long addr)
{
- *(volatile u32 *)((addr + (u_long)dev->iobase)) = cpu_to_le32(command);
+ writel(cpu_to_le32(command), addr + (void *)dev->iobase);
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
static inline int INL(struct eth_device *dev, u_long addr)
{
- return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase));
+ return le32_to_cpu(readl(addr + (void *)dev->iobase));
}
static int get_phyreg(struct eth_device *dev, unsigned char addr,
--
cgit v1.1
From 46df32ef2f8226434b06b43c51cbd94268b343d9 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 14:26:16 +0200
Subject: net: eepro100: Replace purge_tx_ring() with memset()
This function zeroes-out all the descriptors in the TX ring,
use memset() instead.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 5d11665..6fb9192 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -767,23 +767,9 @@ static void init_rx_ring(struct eth_device *dev)
static void purge_tx_ring(struct eth_device *dev)
{
- int i;
-
tx_next = 0;
tx_threshold = 0x01208000;
-
- for (i = 0; i < NUM_TX_DESC; i++) {
- tx_ring[i].status = 0;
- tx_ring[i].command = 0;
- tx_ring[i].link = 0;
- tx_ring[i].tx_desc_addr = 0;
- tx_ring[i].count = 0;
-
- tx_ring[i].tx_buf_addr0 = 0;
- tx_ring[i].tx_buf_size0 = 0;
- tx_ring[i].tx_buf_addr1 = 0;
- tx_ring[i].tx_buf_size1 = 0;
- }
+ memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
}
static void read_hw_addr(struct eth_device *dev, bd_t *bis)
--
cgit v1.1
From 95655b921bdb39aa23a345be13140ab221776705 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 14:30:31 +0200
Subject: net: eepro100: Factor out tx_ring command issuing
This code is replicated in the driver thrice almost verbatim, factor
it out into a separate function and clean it up. No functional change.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 124 +++++++++++++++++++++----------------------------
1 file changed, 53 insertions(+), 71 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 6fb9192..03ba9a4 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -453,11 +453,44 @@ int eepro100_initialize(bd_t *bis)
return card_number;
}
+static int eepro100_txcmd_send(struct eth_device *dev,
+ struct eepro100_txfd *desc)
+{
+ u16 rstat;
+ int i = 0;
+
+ if (!wait_for_eepro100(dev))
+ return -ETIMEDOUT;
+
+ OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER);
+ OUTW(dev, SCB_M | CU_START, SCB_CMD);
+
+ while (true) {
+ rstat = le16_to_cpu(desc->status);
+ if (rstat & CONFIG_SYS_STATUS_C)
+ break;
+
+ if (i++ >= TOUT_LOOP) {
+ printf("%s: Tx error buffer not ready\n", dev->name);
+ return -EINVAL;
+ }
+ }
+
+ rstat = le16_to_cpu(desc->status);
+
+ if (!(rstat & CONFIG_SYS_STATUS_OK)) {
+ printf("TX error status = 0x%08X\n", rstat);
+ return -EIO;
+ }
+
+ return 0;
+}
+
static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
- int i, status = -1;
+ struct eepro100_txfd *ias_cmd, *cfg_cmd;
+ int ret, status = -1;
int tx_cur;
- struct descriptor *ias_cmd, *cfg_cmd;
/* Reset the ethernet controller */
OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
@@ -497,35 +530,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
tx_cur = tx_next;
tx_next = ((tx_next + 1) % NUM_TX_DESC);
- cfg_cmd = (struct descriptor *)&tx_ring[tx_cur];
+ cfg_cmd = &tx_ring[tx_cur];
cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_CONFIGURE);
cfg_cmd->status = 0;
cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
- memcpy(cfg_cmd->params, i82558_config_cmd,
+ memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,
sizeof(i82558_config_cmd));
- if (!wait_for_eepro100(dev)) {
- printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
- goto done;
- }
-
- OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
- OUTW(dev, SCB_M | CU_START, SCB_CMD);
-
- for (i = 0;
- !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
- i++) {
- if (i >= TOUT_LOOP) {
- printf("%s: Tx error buffer not ready\n", dev->name);
- goto done;
- }
- }
-
- if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
- printf("TX error status = 0x%08X\n",
- le16_to_cpu(tx_ring[tx_cur].status));
+ ret = eepro100_txcmd_send(dev, cfg_cmd);
+ if (ret) {
+ if (ret == -ETIMEDOUT)
+ printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
goto done;
}
@@ -533,36 +550,18 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
tx_cur = tx_next;
tx_next = ((tx_next + 1) % NUM_TX_DESC);
- ias_cmd = (struct descriptor *)&tx_ring[tx_cur];
+ ias_cmd = &tx_ring[tx_cur];
ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_IAS);
ias_cmd->status = 0;
ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
- memcpy(ias_cmd->params, dev->enetaddr, 6);
-
- /* Tell the adapter where the TX ring is located. */
- if (!wait_for_eepro100(dev)) {
- printf("Error: Can not reset ethernet controller.\n");
- goto done;
- }
-
- OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
- OUTW(dev, SCB_M | CU_START, SCB_CMD);
-
- for (i = 0;
- !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
- i++) {
- if (i >= TOUT_LOOP) {
- printf("%s: Tx error buffer not ready\n",
- dev->name);
- goto done;
- }
- }
+ memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6);
- if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
- printf("TX error status = 0x%08X\n",
- le16_to_cpu(tx_ring[tx_cur].status));
+ ret = eepro100_txcmd_send(dev, ias_cmd);
+ if (ret) {
+ if (ret == -ETIMEDOUT)
+ printf("Error: Can not reset ethernet controller.\n");
goto done;
}
@@ -574,7 +573,7 @@ done:
static int eepro100_send(struct eth_device *dev, void *packet, int length)
{
- int i, status = -1;
+ int ret, status = -1;
int tx_cur;
if (length <= 0) {
@@ -597,28 +596,11 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
cpu_to_le32 (phys_to_bus((u_long)packet));
tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length);
- if (!wait_for_eepro100(dev)) {
- printf("%s: Tx error ethernet controller not ready.\n",
- dev->name);
- goto done;
- }
-
- /* Send the packet. */
- OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER);
- OUTW(dev, SCB_M | CU_START, SCB_CMD);
-
- for (i = 0;
- !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
- i++) {
- if (i >= TOUT_LOOP) {
- printf("%s: Tx error buffer not ready\n", dev->name);
- goto done;
- }
- }
-
- if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) {
- printf("TX error status = 0x%08X\n",
- le16_to_cpu(tx_ring[tx_cur].status));
+ ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]);
+ if (ret) {
+ if (ret == -ETIMEDOUT)
+ printf("%s: Tx error ethernet controller not ready.\n",
+ dev->name);
goto done;
}
--
cgit v1.1
From 5116aae111b317e82c023af911082aa8d3526a4f Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 14:55:26 +0200
Subject: net: eepro100: Add cache management
Add cache invalidation and flushes wherever the DMA descriptors are
written or read, otherwise this driver cannot work reliably on any
systems where caches are enabled.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 65 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 45 insertions(+), 20 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 03ba9a4..89bfcfb 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -5,6 +5,7 @@
*/
#include
+#include
#include
#include
#include
@@ -459,6 +460,9 @@ static int eepro100_txcmd_send(struct eth_device *dev,
u16 rstat;
int i = 0;
+ flush_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
+
if (!wait_for_eepro100(dev))
return -ETIMEDOUT;
@@ -466,6 +470,8 @@ static int eepro100_txcmd_send(struct eth_device *dev,
OUTW(dev, SCB_M | CU_START, SCB_CMD);
while (true) {
+ invalidate_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
rstat = le16_to_cpu(desc->status);
if (rstat & CONFIG_SYS_STATUS_C)
break;
@@ -476,6 +482,8 @@ static int eepro100_txcmd_send(struct eth_device *dev,
}
}
+ invalidate_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
rstat = le16_to_cpu(desc->status);
if (!(rstat & CONFIG_SYS_STATUS_OK)) {
@@ -523,6 +531,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
goto done;
}
+ /* RX ring cache was already flushed in init_rx_ring() */
OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
OUTW(dev, SCB_M | RUC_START, SCB_CMD);
@@ -573,6 +582,7 @@ done:
static int eepro100_send(struct eth_device *dev, void *packet, int length)
{
+ struct eepro100_txfd *desc;
int ret, status = -1;
int tx_cur;
@@ -584,17 +594,15 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
tx_cur = tx_next;
tx_next = (tx_next + 1) % NUM_TX_DESC;
- tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF |
- TXCB_CMD_S | TXCB_CMD_EL);
- tx_ring[tx_cur].status = 0;
- tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold);
- tx_ring[tx_cur].link =
- cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next]));
- tx_ring[tx_cur].tx_desc_addr =
- cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0));
- tx_ring[tx_cur].tx_buf_addr0 =
- cpu_to_le32 (phys_to_bus((u_long)packet));
- tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length);
+ desc = &tx_ring[tx_cur];
+ desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF |
+ TXCB_CMD_S | TXCB_CMD_EL);
+ desc->status = 0;
+ desc->count = cpu_to_le32(tx_threshold);
+ desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
+ desc->tx_desc_addr = cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0));
+ desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet));
+ desc->tx_buf_size0 = cpu_to_le32(length);
ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]);
if (ret) {
@@ -612,14 +620,18 @@ done:
static int eepro100_recv(struct eth_device *dev)
{
- u16 status, stat;
+ struct eepro100_rxfd *desc;
int rx_prev, length = 0;
+ u16 status, stat;
stat = INW(dev, SCB_STATUS);
OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS);
for (;;) {
- status = le16_to_cpu(rx_ring[rx_next].status);
+ desc = &rx_ring[rx_next];
+ invalidate_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
+ status = le16_to_cpu(desc->status);
if (!(status & RFD_STATUS_C))
break;
@@ -627,22 +639,26 @@ static int eepro100_recv(struct eth_device *dev)
/* Valid frame status. */
if ((status & RFD_STATUS_OK)) {
/* A valid frame received. */
- length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff;
+ length = le32_to_cpu(desc->count) & 0x3fff;
/* Pass the packet up to the protocol layers. */
- net_process_received_packet((u8 *)rx_ring[rx_next].data,
- length);
+ net_process_received_packet((u8 *)desc->data, length);
} else {
/* There was an error. */
printf("RX error status = 0x%08X\n", status);
}
- rx_ring[rx_next].control = cpu_to_le16 (RFD_CONTROL_S);
- rx_ring[rx_next].status = 0;
- rx_ring[rx_next].count = cpu_to_le32 (PKTSIZE_ALIGN << 16);
+ desc->control = cpu_to_le16(RFD_CONTROL_S);
+ desc->status = 0;
+ desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16);
+ flush_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
- rx_ring[rx_prev].control = 0;
+ desc = &rx_ring[rx_prev];
+ desc->control = 0;
+ flush_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
/* Update entry information. */
rx_next = (rx_next + 1) % NUM_RX_DESC;
@@ -659,6 +675,7 @@ static int eepro100_recv(struct eth_device *dev)
goto done;
}
+ /* RX ring cache was already flushed in init_rx_ring() */
OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
OUTW(dev, SCB_M | RUC_START, SCB_CMD);
}
@@ -744,6 +761,10 @@ static void init_rx_ring(struct eth_device *dev)
rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
}
+ flush_dcache_range((unsigned long)rx_ring,
+ (unsigned long)rx_ring +
+ (sizeof(*rx_ring) * NUM_RX_DESC));
+
rx_next = 0;
}
@@ -752,6 +773,10 @@ static void purge_tx_ring(struct eth_device *dev)
tx_next = 0;
tx_threshold = 0x01208000;
memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
+
+ flush_dcache_range((unsigned long)tx_ring,
+ (unsigned long)tx_ring +
+ (sizeof(*tx_ring) * NUM_TX_DESC));
}
static void read_hw_addr(struct eth_device *dev, bd_t *bis)
--
cgit v1.1
From d47cf87db9c89eb0cd00d586111b3b6579b6a5ef Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 15:02:47 +0200
Subject: net: eepro100: Remove volatile misuse
Remove all the remaining use of the 'volatile' keyword, as this is
no longer required. All the accesses which might have needed this
use of 'volatile' have been repaired properly.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 89bfcfb..f3bcb0d 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -103,13 +103,13 @@
/* Receive frame descriptors. */
struct eepro100_rxfd {
- volatile u16 status;
- volatile u16 control;
- volatile u32 link; /* struct eepro100_rxfd * */
- volatile u32 rx_buf_addr; /* void * */
- volatile u32 count;
+ u16 status;
+ u16 control;
+ u32 link; /* struct eepro100_rxfd * */
+ u32 rx_buf_addr; /* void * */
+ u32 count;
- volatile u8 data[PKTSIZE_ALIGN];
+ u8 data[PKTSIZE_ALIGN];
};
#define RFD_STATUS_C 0x8000 /* completion of received frame */
@@ -136,17 +136,17 @@ struct eepro100_rxfd {
#define RFD_RX_TCO 0x0001 /* TCO indication */
/* Transmit frame descriptors */
-struct eepro100_txfd { /* Transmit frame descriptor set. */
- volatile u16 status;
- volatile u16 command;
- volatile u32 link; /* void * */
- volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */
- volatile s32 count;
-
- volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */
- volatile s32 tx_buf_size0; /* Length of Tx frame. */
- volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */
- volatile s32 tx_buf_size1; /* Length of Tx frame. */
+struct eepro100_txfd { /* Transmit frame descriptor set. */
+ u16 status;
+ u16 command;
+ u32 link; /* void * */
+ u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */
+ s32 count;
+
+ u32 tx_buf_addr0; /* void *, frame to be transmitted. */
+ s32 tx_buf_size0; /* Length of Tx frame. */
+ u32 tx_buf_addr1; /* void *, frame to be transmitted. */
+ s32 tx_buf_size1; /* Length of Tx frame. */
};
#define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */
@@ -160,10 +160,10 @@ struct eepro100_txfd { /* Transmit frame descriptor set. */
#define TXCB_COUNT_EOF 0x8000
/* The Speedo3 Rx and Tx frame/buffer descriptors. */
-struct descriptor { /* A generic descriptor. */
- volatile u16 status;
- volatile u16 command;
- volatile u32 link; /* struct descriptor * */
+struct descriptor { /* A generic descriptor. */
+ u16 status;
+ u16 command;
+ u32 link; /* struct descriptor * */
unsigned char params[0];
};
--
cgit v1.1
From 047a800dd6370c5f004b47751f72bb9d4a5d2af5 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 15:07:30 +0200
Subject: net: eepro100: Reorder functions in the driver
Move the functions around in the driver to prepare it for DM conversion.
Drop forward declarations which are not necessary anymore. No functional
change.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 330 ++++++++++++++++++++++++-------------------------
1 file changed, 160 insertions(+), 170 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index f3bcb0d..9db9367 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -5,13 +5,13 @@
*/
#include
+#include
#include
#include
+#include
#include
#include
-#include
#include
-#include
#include
/* Ethernet chip registers. */
@@ -201,16 +201,6 @@ static const char i82558_config_cmd[] = {
0x31, 0x05,
};
-static void init_rx_ring(struct eth_device *dev);
-static void purge_tx_ring(struct eth_device *dev);
-
-static void read_hw_addr(struct eth_device *dev, bd_t *bis);
-
-static int eepro100_init(struct eth_device *dev, bd_t *bis);
-static int eepro100_send(struct eth_device *dev, void *packet, int length);
-static int eepro100_recv(struct eth_device *dev);
-static void eepro100_halt(struct eth_device *dev);
-
#if defined(CONFIG_E500)
#define bus_to_phys(a) (a)
#define phys_to_bus(a) (a)
@@ -353,105 +343,50 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
#endif
-/* Wait for the chip get the command. */
-static int wait_for_eepro100(struct eth_device *dev)
+static void init_rx_ring(struct eth_device *dev)
{
int i;
- for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
- if (i >= TOUT_LOOP)
- return 0;
+ for (i = 0; i < NUM_RX_DESC; i++) {
+ rx_ring[i].status = 0;
+ rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
+ cpu_to_le16 (RFD_CONTROL_S) : 0;
+ rx_ring[i].link =
+ cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) %
+ NUM_RX_DESC]));
+ rx_ring[i].rx_buf_addr = 0xffffffff;
+ rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
}
- return 1;
-}
+ flush_dcache_range((unsigned long)rx_ring,
+ (unsigned long)rx_ring +
+ (sizeof(*rx_ring) * NUM_RX_DESC));
-static struct pci_device_id supported[] = {
- {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557},
- {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559},
- {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER},
- {}
-};
+ rx_next = 0;
+}
-int eepro100_initialize(bd_t *bis)
+static void purge_tx_ring(struct eth_device *dev)
{
- pci_dev_t devno;
- int card_number = 0;
- struct eth_device *dev;
- u32 iobase, status;
- int idx = 0;
-
- while (1) {
- /* Find PCI device */
- devno = pci_find_devices(supported, idx++);
- if (devno < 0)
- break;
-
- pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase);
- iobase &= ~0xf;
-
- debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
- iobase);
-
- pci_write_config_dword(devno, PCI_COMMAND,
- PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
-
- /* Check if I/O accesses and Bus Mastering are enabled. */
- pci_read_config_dword(devno, PCI_COMMAND, &status);
- if (!(status & PCI_COMMAND_MEMORY)) {
- printf("Error: Can not enable MEM access.\n");
- continue;
- }
-
- if (!(status & PCI_COMMAND_MASTER)) {
- printf("Error: Can not enable Bus Mastering.\n");
- continue;
- }
-
- dev = (struct eth_device *)malloc(sizeof(*dev));
- if (!dev) {
- printf("eepro100: Can not allocate memory\n");
- break;
- }
- memset(dev, 0, sizeof(*dev));
-
- sprintf(dev->name, "i82559#%d", card_number);
- dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
- dev->iobase = bus_to_phys(iobase);
- dev->init = eepro100_init;
- dev->halt = eepro100_halt;
- dev->send = eepro100_send;
- dev->recv = eepro100_recv;
-
- eth_register(dev);
-
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
- /* register mii command access routines */
- int retval;
- struct mii_dev *mdiodev = mdio_alloc();
-
- if (!mdiodev)
- return -ENOMEM;
- strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
- mdiodev->read = eepro100_miiphy_read;
- mdiodev->write = eepro100_miiphy_write;
-
- retval = mdio_register(mdiodev);
- if (retval < 0)
- return retval;
-#endif
-
- card_number++;
+ tx_next = 0;
+ tx_threshold = 0x01208000;
+ memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
- /* Set the latency timer for value. */
- pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20);
+ flush_dcache_range((unsigned long)tx_ring,
+ (unsigned long)tx_ring +
+ (sizeof(*tx_ring) * NUM_TX_DESC));
+}
- udelay(10 * 1000);
+/* Wait for the chip get the command. */
+static int wait_for_eepro100(struct eth_device *dev)
+{
+ int i;
- read_hw_addr(dev, bis);
+ for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
+ if (i >= TOUT_LOOP)
+ return 0;
}
- return card_number;
+ return 1;
}
static int eepro100_txcmd_send(struct eth_device *dev,
@@ -494,6 +429,71 @@ static int eepro100_txcmd_send(struct eth_device *dev,
return 0;
}
+/* SROM Read. */
+static int read_eeprom(struct eth_device *dev, int location, int addr_len)
+{
+ unsigned short retval = 0;
+ int read_cmd = location | EE_READ_CMD;
+ int i;
+
+ OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
+ OUTW(dev, EE_ENB, SCB_EEPROM);
+
+ /* Shift the read command bits out. */
+ for (i = 12; i >= 0; i--) {
+ short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
+
+ OUTW(dev, EE_ENB | dataval, SCB_EEPROM);
+ udelay(1);
+ OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
+ udelay(1);
+ }
+ OUTW(dev, EE_ENB, SCB_EEPROM);
+
+ for (i = 15; i >= 0; i--) {
+ OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
+ udelay(1);
+ retval = (retval << 1) |
+ ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0);
+ OUTW(dev, EE_ENB, SCB_EEPROM);
+ udelay(1);
+ }
+
+ /* Terminate the EEPROM access. */
+ OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
+ return retval;
+}
+
+static struct pci_device_id supported[] = {
+ {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557},
+ {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559},
+ {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER},
+ {}
+};
+
+static void read_hw_addr(struct eth_device *dev, bd_t *bis)
+{
+ u16 sum = 0;
+ int i, j;
+ int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6;
+
+ for (j = 0, i = 0; i < 0x40; i++) {
+ u16 value = read_eeprom(dev, i, addr_len);
+
+ sum += value;
+ if (i < 3) {
+ dev->enetaddr[j++] = value;
+ dev->enetaddr[j++] = value >> 8;
+ }
+ }
+
+ if (sum != 0xBABA) {
+ memset(dev->enetaddr, 0, ETH_ALEN);
+ debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",
+ dev->name, sum);
+ }
+}
+
static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
struct eepro100_txfd *ias_cmd, *cfg_cmd;
@@ -711,93 +711,83 @@ done:
return;
}
-/* SROM Read. */
-static int read_eeprom(struct eth_device *dev, int location, int addr_len)
+int eepro100_initialize(bd_t *bis)
{
- unsigned short retval = 0;
- int read_cmd = location | EE_READ_CMD;
- int i;
+ pci_dev_t devno;
+ int card_number = 0;
+ struct eth_device *dev;
+ u32 iobase, status;
+ int idx = 0;
- OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
- OUTW(dev, EE_ENB, SCB_EEPROM);
+ while (1) {
+ /* Find PCI device */
+ devno = pci_find_devices(supported, idx++);
+ if (devno < 0)
+ break;
- /* Shift the read command bits out. */
- for (i = 12; i >= 0; i--) {
- short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
+ pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase);
+ iobase &= ~0xf;
- OUTW(dev, EE_ENB | dataval, SCB_EEPROM);
- udelay(1);
- OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
- udelay(1);
- }
- OUTW(dev, EE_ENB, SCB_EEPROM);
+ debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n",
+ iobase);
- for (i = 15; i >= 0; i--) {
- OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
- udelay(1);
- retval = (retval << 1) |
- ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0);
- OUTW(dev, EE_ENB, SCB_EEPROM);
- udelay(1);
- }
+ pci_write_config_dword(devno, PCI_COMMAND,
+ PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
- /* Terminate the EEPROM access. */
- OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
- return retval;
-}
+ /* Check if I/O accesses and Bus Mastering are enabled. */
+ pci_read_config_dword(devno, PCI_COMMAND, &status);
+ if (!(status & PCI_COMMAND_MEMORY)) {
+ printf("Error: Can not enable MEM access.\n");
+ continue;
+ }
-static void init_rx_ring(struct eth_device *dev)
-{
- int i;
+ if (!(status & PCI_COMMAND_MASTER)) {
+ printf("Error: Can not enable Bus Mastering.\n");
+ continue;
+ }
- for (i = 0; i < NUM_RX_DESC; i++) {
- rx_ring[i].status = 0;
- rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
- cpu_to_le16 (RFD_CONTROL_S) : 0;
- rx_ring[i].link =
- cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) %
- NUM_RX_DESC]));
- rx_ring[i].rx_buf_addr = 0xffffffff;
- rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
- }
+ dev = (struct eth_device *)malloc(sizeof(*dev));
+ if (!dev) {
+ printf("eepro100: Can not allocate memory\n");
+ break;
+ }
+ memset(dev, 0, sizeof(*dev));
- flush_dcache_range((unsigned long)rx_ring,
- (unsigned long)rx_ring +
- (sizeof(*rx_ring) * NUM_RX_DESC));
+ sprintf(dev->name, "i82559#%d", card_number);
+ dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
+ dev->iobase = bus_to_phys(iobase);
+ dev->init = eepro100_init;
+ dev->halt = eepro100_halt;
+ dev->send = eepro100_send;
+ dev->recv = eepro100_recv;
- rx_next = 0;
-}
+ eth_register(dev);
-static void purge_tx_ring(struct eth_device *dev)
-{
- tx_next = 0;
- tx_threshold = 0x01208000;
- memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+ /* register mii command access routines */
+ int retval;
+ struct mii_dev *mdiodev = mdio_alloc();
- flush_dcache_range((unsigned long)tx_ring,
- (unsigned long)tx_ring +
- (sizeof(*tx_ring) * NUM_TX_DESC));
-}
+ if (!mdiodev)
+ return -ENOMEM;
+ strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+ mdiodev->read = eepro100_miiphy_read;
+ mdiodev->write = eepro100_miiphy_write;
-static void read_hw_addr(struct eth_device *dev, bd_t *bis)
-{
- u16 sum = 0;
- int i, j;
- int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6;
+ retval = mdio_register(mdiodev);
+ if (retval < 0)
+ return retval;
+#endif
- for (j = 0, i = 0; i < 0x40; i++) {
- u16 value = read_eeprom(dev, i, addr_len);
+ card_number++;
- sum += value;
- if (i < 3) {
- dev->enetaddr[j++] = value;
- dev->enetaddr[j++] = value >> 8;
- }
- }
+ /* Set the latency timer for value. */
+ pci_write_config_byte(devno, PCI_LATENCY_TIMER, 0x20);
- if (sum != 0xBABA) {
- memset(dev->enetaddr, 0, ETH_ALEN);
- debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",
- dev->name, sum);
+ udelay(10 * 1000);
+
+ read_hw_addr(dev, bis);
}
+
+ return card_number;
}
--
cgit v1.1
From 3a15684dc6ecc9dcc74e3a9357d8e91ebd50aed7 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 15:11:30 +0200
Subject: net: eepro100: Use PCI_DEVICE() to define PCI device compat list
Use this macro to fully fill the PCI device ID table. This is mandatory
for the DM PCI support, which checks all the fields.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 9db9367..74b09e9 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -465,10 +465,10 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)
}
static struct pci_device_id supported[] = {
- {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557},
- {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559},
- {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER},
- {}
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) },
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER) },
+ { }
};
static void read_hw_addr(struct eth_device *dev, bd_t *bis)
--
cgit v1.1
From 6c7d3f6b3fb5860f55d1c7733d2b5929e0721e99 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:13:30 +0200
Subject: net: eepro100: Switch from malloc()+memset() to calloc()
Replace malloc()+memset() combination with calloc(), no functional change.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 74b09e9..8fa6657 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -746,12 +746,11 @@ int eepro100_initialize(bd_t *bis)
continue;
}
- dev = (struct eth_device *)malloc(sizeof(*dev));
+ dev = calloc(1, sizeof(*dev));
if (!dev) {
printf("eepro100: Can not allocate memory\n");
break;
}
- memset(dev, 0, sizeof(*dev));
sprintf(dev->name, "i82559#%d", card_number);
dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
--
cgit v1.1
From 66fed7300d250197c24fb54cad7f6cae7df95fe1 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:20:25 +0200
Subject: net: eepro100: Factor out MII registration
Pull the MII registration code into a separate function. Moreover,
properly free memory in case any of the registration or allocation
functions fail, so this fixes an existing memleak.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 56 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 39 insertions(+), 17 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 8fa6657..861d39c 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -464,6 +464,36 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)
return retval;
}
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+static int eepro100_initialize_mii(struct eth_device *dev)
+{
+ /* register mii command access routines */
+ struct mii_dev *mdiodev;
+ int ret;
+
+ mdiodev = mdio_alloc();
+ if (!mdiodev)
+ return -ENOMEM;
+
+ strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+ mdiodev->read = eepro100_miiphy_read;
+ mdiodev->write = eepro100_miiphy_write;
+
+ ret = mdio_register(mdiodev);
+ if (ret < 0) {
+ mdio_free(mdiodev);
+ return ret;
+ }
+
+ return 0;
+}
+#else
+static int eepro100_initialize_mii(struct eth_device *dev)
+{
+ return 0;
+}
+#endif
+
static struct pci_device_id supported[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) },
@@ -713,11 +743,12 @@ done:
int eepro100_initialize(bd_t *bis)
{
- pci_dev_t devno;
- int card_number = 0;
struct eth_device *dev;
+ int card_number = 0;
u32 iobase, status;
+ pci_dev_t devno;
int idx = 0;
+ int ret;
while (1) {
/* Find PCI device */
@@ -762,21 +793,12 @@ int eepro100_initialize(bd_t *bis)
eth_register(dev);
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
- /* register mii command access routines */
- int retval;
- struct mii_dev *mdiodev = mdio_alloc();
-
- if (!mdiodev)
- return -ENOMEM;
- strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
- mdiodev->read = eepro100_miiphy_read;
- mdiodev->write = eepro100_miiphy_write;
-
- retval = mdio_register(mdiodev);
- if (retval < 0)
- return retval;
-#endif
+ ret = eepro100_initialize_mii(dev);
+ if (ret) {
+ eth_unregister(dev);
+ free(dev);
+ return ret;
+ }
card_number++;
--
cgit v1.1
From a6c06ec8f6598f248ade50d4dd7e5b2f32df2dde Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:23:28 +0200
Subject: net: eepro100: Fix EE_*_CMD macros
Those macros depended on specific variable names to be declared
at their usage sites, fix this by adding an argument to those
macros and also protect the argument with braces.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 861d39c..a8d617c 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -96,10 +96,10 @@
#define EE_DATA_BITS 16
/* The EEPROM commands include the alway-set leading bit. */
-#define EE_EWENB_CMD (4 << addr_len)
-#define EE_WRITE_CMD (5 << addr_len)
-#define EE_READ_CMD (6 << addr_len)
-#define EE_ERASE_CMD (7 << addr_len)
+#define EE_EWENB_CMD(addr_len) (4 << (addr_len))
+#define EE_WRITE_CMD(addr_len) (5 << (addr_len))
+#define EE_READ_CMD(addr_len) (6 << (addr_len))
+#define EE_ERASE_CMD(addr_len) (7 << (addr_len))
/* Receive frame descriptors. */
struct eepro100_rxfd {
@@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,
static int read_eeprom(struct eth_device *dev, int location, int addr_len)
{
unsigned short retval = 0;
- int read_cmd = location | EE_READ_CMD;
+ int read_cmd = location | EE_READ_CMD(addr_len);
int i;
OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
--
cgit v1.1
From acdf5d88827a0420ed0ceee3e45fa08f9d39b483 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:27:37 +0200
Subject: net: eepro100: Drop inline keyword
Drop the inline keyword from the static functions, the compiler has a
much better overview and can decide how to inline those functions much
better.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index a8d617c..4446251 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -209,23 +209,23 @@ static const char i82558_config_cmd[] = {
#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
#endif
-static inline int INW(struct eth_device *dev, u_long addr)
+static int INW(struct eth_device *dev, u_long addr)
{
return le16_to_cpu(readw(addr + (void *)dev->iobase));
}
-static inline void OUTW(struct eth_device *dev, int command, u_long addr)
+static void OUTW(struct eth_device *dev, int command, u_long addr)
{
writew(cpu_to_le16(command), addr + (void *)dev->iobase);
}
-static inline void OUTL(struct eth_device *dev, int command, u_long addr)
+static void OUTL(struct eth_device *dev, int command, u_long addr)
{
writel(cpu_to_le32(command), addr + (void *)dev->iobase);
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-static inline int INL(struct eth_device *dev, u_long addr)
+static int INL(struct eth_device *dev, u_long addr)
{
return le32_to_cpu(readl(addr + (void *)dev->iobase));
}
--
cgit v1.1
From fa9e12102dfc6a5f1f10a75fd1804c16a166ded9 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:38:41 +0200
Subject: net: eepro100: Pass PCI BDF into bus_to_phys()/phys_to_bus()
This is a trick in preparation for adding DM support. By passing in
the PCI BDF into the bus_to_phys()/phys_to_bus() macros and calling
that dev, we can substitute dev with udevice when DM support lands
and do minor adjustment to the macros to support both DM and non-DM
operation. No functional change.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 4446251..532d7aa 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -202,11 +202,11 @@ static const char i82558_config_cmd[] = {
};
#if defined(CONFIG_E500)
-#define bus_to_phys(a) (a)
-#define phys_to_bus(a) (a)
+#define bus_to_phys(dev, a) (a)
+#define phys_to_bus(dev, a) (a)
#else
-#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a)
-#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
+#define bus_to_phys(dev, a) pci_mem_to_phys((dev), (a))
+#define phys_to_bus(dev, a) pci_phys_to_mem((dev), (a))
#endif
static int INW(struct eth_device *dev, u_long addr)
@@ -352,7 +352,8 @@ static void init_rx_ring(struct eth_device *dev)
rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
cpu_to_le16 (RFD_CONTROL_S) : 0;
rx_ring[i].link =
- cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) %
+ cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ (u32)&rx_ring[(i + 1) %
NUM_RX_DESC]));
rx_ring[i].rx_buf_addr = 0xffffffff;
rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16);
@@ -401,7 +402,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,
if (!wait_for_eepro100(dev))
return -ETIMEDOUT;
- OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER);
+ OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)desc), SCB_POINTER);
OUTW(dev, SCB_M | CU_START, SCB_CMD);
while (true) {
@@ -562,7 +563,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
}
/* RX ring cache was already flushed in init_rx_ring() */
- OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
+ OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)&rx_ring[rx_next]),
+ SCB_POINTER);
OUTW(dev, SCB_M | RUC_START, SCB_CMD);
/* Send the Configure frame */
@@ -573,7 +575,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_CONFIGURE);
cfg_cmd->status = 0;
- cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
+ cfg_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ (u32)&tx_ring[tx_next]));
memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,
sizeof(i82558_config_cmd));
@@ -593,7 +596,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_IAS);
ias_cmd->status = 0;
- ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
+ ias_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ (u32)&tx_ring[tx_next]));
memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6);
@@ -629,9 +633,12 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
TXCB_CMD_S | TXCB_CMD_EL);
desc->status = 0;
desc->count = cpu_to_le32(tx_threshold);
- desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next]));
- desc->tx_desc_addr = cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0));
- desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet));
+ desc->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ (u32)&tx_ring[tx_next]));
+ desc->tx_desc_addr = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ (u32)&desc->tx_buf_addr0));
+ desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ (u_long)packet));
desc->tx_buf_size0 = cpu_to_le32(length);
ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]);
@@ -706,7 +713,8 @@ static int eepro100_recv(struct eth_device *dev)
}
/* RX ring cache was already flushed in init_rx_ring() */
- OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER);
+ OUTL(dev, phys_to_bus((pci_dev_t)dev->priv,
+ (u32)&rx_ring[rx_next]), SCB_POINTER);
OUTW(dev, SCB_M | RUC_START, SCB_CMD);
}
@@ -785,7 +793,7 @@ int eepro100_initialize(bd_t *bis)
sprintf(dev->name, "i82559#%d", card_number);
dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
- dev->iobase = bus_to_phys(iobase);
+ dev->iobase = bus_to_phys(devno, iobase);
dev->init = eepro100_init;
dev->halt = eepro100_halt;
dev->send = eepro100_send;
--
cgit v1.1
From bd159c6185676c87e4a1cdbb33a869d4c1e05f9e Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:49:07 +0200
Subject: net: eepro100: Introduce device private data
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 532d7aa..2c25307 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -201,6 +201,10 @@ static const char i82558_config_cmd[] = {
0x31, 0x05,
};
+struct eepro100_priv {
+ struct eth_device dev;
+};
+
#if defined(CONFIG_E500)
#define bus_to_phys(dev, a) (a)
#define phys_to_bus(dev, a) (a)
@@ -751,6 +755,7 @@ done:
int eepro100_initialize(bd_t *bis)
{
+ struct eepro100_priv *priv;
struct eth_device *dev;
int card_number = 0;
u32 iobase, status;
@@ -785,11 +790,12 @@ int eepro100_initialize(bd_t *bis)
continue;
}
- dev = calloc(1, sizeof(*dev));
- if (!dev) {
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
printf("eepro100: Can not allocate memory\n");
break;
}
+ dev = &priv->dev;
sprintf(dev->name, "i82559#%d", card_number);
dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
@@ -804,7 +810,7 @@ int eepro100_initialize(bd_t *bis)
ret = eepro100_initialize_mii(dev);
if (ret) {
eth_unregister(dev);
- free(dev);
+ free(priv);
return ret;
}
--
cgit v1.1
From 389da9743c269a0c8536f4700c11c333a0309958 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 17:10:03 +0200
Subject: net: eepro100: Pass device private data around
This patch replaces the various uses of struct eth_device for accessing
device private data with struct eepro100_priv, which is compatible both
with DM and non-DM operation.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 264 ++++++++++++++++++++++++++-----------------------
1 file changed, 140 insertions(+), 124 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 2c25307..1c33ec3 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -203,6 +203,10 @@ static const char i82558_config_cmd[] = {
struct eepro100_priv {
struct eth_device dev;
+ pci_dev_t devno;
+ char *name;
+ void __iomem *iobase;
+ u8 *enetaddr;
};
#if defined(CONFIG_E500)
@@ -213,40 +217,40 @@ struct eepro100_priv {
#define phys_to_bus(dev, a) pci_phys_to_mem((dev), (a))
#endif
-static int INW(struct eth_device *dev, u_long addr)
+static int INW(struct eepro100_priv *priv, u_long addr)
{
- return le16_to_cpu(readw(addr + (void *)dev->iobase));
+ return le16_to_cpu(readw(addr + priv->iobase));
}
-static void OUTW(struct eth_device *dev, int command, u_long addr)
+static void OUTW(struct eepro100_priv *priv, int command, u_long addr)
{
- writew(cpu_to_le16(command), addr + (void *)dev->iobase);
+ writew(cpu_to_le16(command), addr + priv->iobase);
}
-static void OUTL(struct eth_device *dev, int command, u_long addr)
+static void OUTL(struct eepro100_priv *priv, int command, u_long addr)
{
- writel(cpu_to_le32(command), addr + (void *)dev->iobase);
+ writel(cpu_to_le32(command), addr + priv->iobase);
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-static int INL(struct eth_device *dev, u_long addr)
+static int INL(struct eepro100_priv *priv, u_long addr)
{
- return le32_to_cpu(readl(addr + (void *)dev->iobase));
+ return le32_to_cpu(readl(addr + priv->iobase));
}
-static int get_phyreg(struct eth_device *dev, unsigned char addr,
+static int get_phyreg(struct eepro100_priv *priv, unsigned char addr,
unsigned char reg, unsigned short *value)
{
- int cmd;
int timeout = 50;
+ int cmd;
/* read requested data */
cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
- OUTL(dev, cmd, SCB_CTRL_MDI);
+ OUTL(priv, cmd, SCB_CTRL_MDI);
do {
udelay(1000);
- cmd = INL(dev, SCB_CTRL_MDI);
+ cmd = INL(priv, SCB_CTRL_MDI);
} while (!(cmd & (1 << 28)) && (--timeout));
if (timeout == 0)
@@ -257,17 +261,17 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,
return 0;
}
-static int set_phyreg(struct eth_device *dev, unsigned char addr,
+static int set_phyreg(struct eepro100_priv *priv, unsigned char addr,
unsigned char reg, unsigned short value)
{
- int cmd;
int timeout = 50;
+ int cmd;
/* write requested data */
cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
- OUTL(dev, cmd | value, SCB_CTRL_MDI);
+ OUTL(priv, cmd | value, SCB_CTRL_MDI);
- while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout))
+ while (!(INL(priv, SCB_CTRL_MDI) & (1 << 28)) && (--timeout))
udelay(1000);
if (timeout == 0)
@@ -280,49 +284,45 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,
* Check if given phyaddr is valid, i.e. there is a PHY connected.
* Do this by checking model value field from ID2 register.
*/
-static struct eth_device *verify_phyaddr(const char *devname,
- unsigned char addr)
+static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)
{
- struct eth_device *dev;
- unsigned short value;
- unsigned char model;
-
- dev = eth_get_dev_by_name(devname);
- if (!dev) {
- printf("%s: no such device\n", devname);
- return NULL;
- }
+ unsigned short value, model;
+ int ret;
/* read id2 register */
- if (get_phyreg(dev, addr, MII_PHYSID2, &value) != 0) {
- printf("%s: mii read timeout!\n", devname);
- return NULL;
+ ret = get_phyreg(priv, addr, MII_PHYSID2, &value);
+ if (ret) {
+ printf("%s: mii read timeout!\n", priv->name);
+ return ret;
}
/* get model */
- model = (unsigned char)((value >> 4) & 0x003f);
-
- if (model == 0) {
- printf("%s: no PHY at address %d\n", devname, addr);
- return NULL;
+ model = (value >> 4) & 0x003f;
+ if (!model) {
+ printf("%s: no PHY at address %d\n", priv->name, addr);
+ return -EINVAL;
}
- return dev;
+ return 0;
}
static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
int reg)
{
+ struct eth_device *dev = eth_get_dev_by_name(bus->name);
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
unsigned short value = 0;
- struct eth_device *dev;
+ int ret;
- dev = verify_phyaddr(bus->name, addr);
- if (!dev)
- return -1;
+ ret = verify_phyaddr(priv, addr);
+ if (ret)
+ return ret;
- if (get_phyreg(dev, addr, reg, &value) != 0) {
+ ret = get_phyreg(priv, addr, reg, &value);
+ if (ret) {
printf("%s: mii read timeout!\n", bus->name);
- return -1;
+ return ret;
}
return value;
@@ -331,23 +331,26 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
int reg, u16 value)
{
- struct eth_device *dev;
+ struct eth_device *dev = eth_get_dev_by_name(bus->name);
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
+ int ret;
- dev = verify_phyaddr(bus->name, addr);
- if (!dev)
- return -1;
+ ret = verify_phyaddr(priv, addr);
+ if (ret)
+ return ret;
- if (set_phyreg(dev, addr, reg, value) != 0) {
+ ret = set_phyreg(priv, addr, reg, value);
+ if (ret) {
printf("%s: mii write timeout!\n", bus->name);
- return -1;
+ return ret;
}
return 0;
}
-
#endif
-static void init_rx_ring(struct eth_device *dev)
+static void init_rx_ring(struct eepro100_priv *priv)
{
int i;
@@ -356,7 +359,7 @@ static void init_rx_ring(struct eth_device *dev)
rx_ring[i].control = (i == NUM_RX_DESC - 1) ?
cpu_to_le16 (RFD_CONTROL_S) : 0;
rx_ring[i].link =
- cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ cpu_to_le32(phys_to_bus(priv->devno,
(u32)&rx_ring[(i + 1) %
NUM_RX_DESC]));
rx_ring[i].rx_buf_addr = 0xffffffff;
@@ -370,7 +373,7 @@ static void init_rx_ring(struct eth_device *dev)
rx_next = 0;
}
-static void purge_tx_ring(struct eth_device *dev)
+static void purge_tx_ring(struct eepro100_priv *priv)
{
tx_next = 0;
tx_threshold = 0x01208000;
@@ -382,11 +385,11 @@ static void purge_tx_ring(struct eth_device *dev)
}
/* Wait for the chip get the command. */
-static int wait_for_eepro100(struct eth_device *dev)
+static int wait_for_eepro100(struct eepro100_priv *priv)
{
int i;
- for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
+ for (i = 0; INW(priv, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) {
if (i >= TOUT_LOOP)
return 0;
}
@@ -394,7 +397,7 @@ static int wait_for_eepro100(struct eth_device *dev)
return 1;
}
-static int eepro100_txcmd_send(struct eth_device *dev,
+static int eepro100_txcmd_send(struct eepro100_priv *priv,
struct eepro100_txfd *desc)
{
u16 rstat;
@@ -403,11 +406,11 @@ static int eepro100_txcmd_send(struct eth_device *dev,
flush_dcache_range((unsigned long)desc,
(unsigned long)desc + sizeof(*desc));
- if (!wait_for_eepro100(dev))
+ if (!wait_for_eepro100(priv))
return -ETIMEDOUT;
- OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)desc), SCB_POINTER);
- OUTW(dev, SCB_M | CU_START, SCB_CMD);
+ OUTL(priv, phys_to_bus(priv->devno, (u32)desc), SCB_POINTER);
+ OUTW(priv, SCB_M | CU_START, SCB_CMD);
while (true) {
invalidate_dcache_range((unsigned long)desc,
@@ -417,7 +420,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,
break;
if (i++ >= TOUT_LOOP) {
- printf("%s: Tx error buffer not ready\n", dev->name);
+ printf("%s: Tx error buffer not ready\n", priv->name);
return -EINVAL;
}
}
@@ -435,42 +438,42 @@ static int eepro100_txcmd_send(struct eth_device *dev,
}
/* SROM Read. */
-static int read_eeprom(struct eth_device *dev, int location, int addr_len)
+static int read_eeprom(struct eepro100_priv *priv, int location, int addr_len)
{
unsigned short retval = 0;
int read_cmd = location | EE_READ_CMD(addr_len);
int i;
- OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
- OUTW(dev, EE_ENB, SCB_EEPROM);
+ OUTW(priv, EE_ENB & ~EE_CS, SCB_EEPROM);
+ OUTW(priv, EE_ENB, SCB_EEPROM);
/* Shift the read command bits out. */
for (i = 12; i >= 0; i--) {
short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
- OUTW(dev, EE_ENB | dataval, SCB_EEPROM);
+ OUTW(priv, EE_ENB | dataval, SCB_EEPROM);
udelay(1);
- OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
+ OUTW(priv, EE_ENB | dataval | EE_SHIFT_CLK, SCB_EEPROM);
udelay(1);
}
- OUTW(dev, EE_ENB, SCB_EEPROM);
+ OUTW(priv, EE_ENB, SCB_EEPROM);
for (i = 15; i >= 0; i--) {
- OUTW(dev, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
+ OUTW(priv, EE_ENB | EE_SHIFT_CLK, SCB_EEPROM);
udelay(1);
retval = (retval << 1) |
- ((INW(dev, SCB_EEPROM) & EE_DATA_READ) ? 1 : 0);
- OUTW(dev, EE_ENB, SCB_EEPROM);
+ !!(INW(priv, SCB_EEPROM) & EE_DATA_READ);
+ OUTW(priv, EE_ENB, SCB_EEPROM);
udelay(1);
}
/* Terminate the EEPROM access. */
- OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
+ OUTW(priv, EE_ENB & ~EE_CS, SCB_EEPROM);
return retval;
}
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-static int eepro100_initialize_mii(struct eth_device *dev)
+static int eepro100_initialize_mii(struct eepro100_priv *priv)
{
/* register mii command access routines */
struct mii_dev *mdiodev;
@@ -480,7 +483,7 @@ static int eepro100_initialize_mii(struct eth_device *dev)
if (!mdiodev)
return -ENOMEM;
- strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+ strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN);
mdiodev->read = eepro100_miiphy_read;
mdiodev->write = eepro100_miiphy_write;
@@ -493,7 +496,7 @@ static int eepro100_initialize_mii(struct eth_device *dev)
return 0;
}
#else
-static int eepro100_initialize_mii(struct eth_device *dev)
+static int eepro100_initialize_mii(struct eepro100_priv *priv)
{
return 0;
}
@@ -506,70 +509,72 @@ static struct pci_device_id supported[] = {
{ }
};
-static void read_hw_addr(struct eth_device *dev, bd_t *bis)
+static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis)
{
u16 sum = 0;
int i, j;
- int addr_len = read_eeprom(dev, 0, 6) == 0xffff ? 8 : 6;
+ int addr_len = read_eeprom(priv, 0, 6) == 0xffff ? 8 : 6;
for (j = 0, i = 0; i < 0x40; i++) {
- u16 value = read_eeprom(dev, i, addr_len);
+ u16 value = read_eeprom(priv, i, addr_len);
sum += value;
if (i < 3) {
- dev->enetaddr[j++] = value;
- dev->enetaddr[j++] = value >> 8;
+ priv->enetaddr[j++] = value;
+ priv->enetaddr[j++] = value >> 8;
}
}
if (sum != 0xBABA) {
- memset(dev->enetaddr, 0, ETH_ALEN);
+ memset(priv->enetaddr, 0, ETH_ALEN);
debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n",
- dev->name, sum);
+ priv->name, sum);
}
}
static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
struct eepro100_txfd *ias_cmd, *cfg_cmd;
int ret, status = -1;
int tx_cur;
/* Reset the ethernet controller */
- OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
+ OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT);
udelay(20);
- OUTL(dev, I82559_RESET, SCB_PORT);
+ OUTL(priv, I82559_RESET, SCB_PORT);
udelay(20);
- if (!wait_for_eepro100(dev)) {
+ if (!wait_for_eepro100(priv)) {
printf("Error: Can not reset ethernet controller.\n");
goto done;
}
- OUTL(dev, 0, SCB_POINTER);
- OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
+ OUTL(priv, 0, SCB_POINTER);
+ OUTW(priv, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
- if (!wait_for_eepro100(dev)) {
+ if (!wait_for_eepro100(priv)) {
printf("Error: Can not reset ethernet controller.\n");
goto done;
}
- OUTL(dev, 0, SCB_POINTER);
- OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD);
+ OUTL(priv, 0, SCB_POINTER);
+ OUTW(priv, SCB_M | CU_ADDR_LOAD, SCB_CMD);
/* Initialize Rx and Tx rings. */
- init_rx_ring(dev);
- purge_tx_ring(dev);
+ init_rx_ring(priv);
+ purge_tx_ring(priv);
/* Tell the adapter where the RX ring is located. */
- if (!wait_for_eepro100(dev)) {
+ if (!wait_for_eepro100(priv)) {
printf("Error: Can not reset ethernet controller.\n");
goto done;
}
/* RX ring cache was already flushed in init_rx_ring() */
- OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)&rx_ring[rx_next]),
+ OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]),
SCB_POINTER);
- OUTW(dev, SCB_M | RUC_START, SCB_CMD);
+ OUTW(priv, SCB_M | RUC_START, SCB_CMD);
/* Send the Configure frame */
tx_cur = tx_next;
@@ -579,13 +584,13 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_CONFIGURE);
cfg_cmd->status = 0;
- cfg_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno,
(u32)&tx_ring[tx_next]));
memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,
sizeof(i82558_config_cmd));
- ret = eepro100_txcmd_send(dev, cfg_cmd);
+ ret = eepro100_txcmd_send(priv, cfg_cmd);
if (ret) {
if (ret == -ETIMEDOUT)
printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n");
@@ -600,12 +605,12 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_IAS);
ias_cmd->status = 0;
- ias_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno,
(u32)&tx_ring[tx_next]));
- memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6);
+ memcpy(((struct descriptor *)ias_cmd)->params, priv->enetaddr, 6);
- ret = eepro100_txcmd_send(dev, ias_cmd);
+ ret = eepro100_txcmd_send(priv, ias_cmd);
if (ret) {
if (ret == -ETIMEDOUT)
printf("Error: Can not reset ethernet controller.\n");
@@ -620,12 +625,14 @@ done:
static int eepro100_send(struct eth_device *dev, void *packet, int length)
{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
struct eepro100_txfd *desc;
int ret, status = -1;
int tx_cur;
if (length <= 0) {
- printf("%s: bad packet size: %d\n", dev->name, length);
+ printf("%s: bad packet size: %d\n", priv->name, length);
goto done;
}
@@ -637,19 +644,19 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
TXCB_CMD_S | TXCB_CMD_EL);
desc->status = 0;
desc->count = cpu_to_le32(tx_threshold);
- desc->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
- (u32)&tx_ring[tx_next]));
- desc->tx_desc_addr = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ desc->link = cpu_to_le32(phys_to_bus(priv->devno,
+ (u32)&tx_ring[tx_next]));
+ desc->tx_desc_addr = cpu_to_le32(phys_to_bus(priv->devno,
(u32)&desc->tx_buf_addr0));
- desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv,
+ desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno,
(u_long)packet));
desc->tx_buf_size0 = cpu_to_le32(length);
- ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]);
+ ret = eepro100_txcmd_send(priv, &tx_ring[tx_cur]);
if (ret) {
if (ret == -ETIMEDOUT)
printf("%s: Tx error ethernet controller not ready.\n",
- dev->name);
+ priv->name);
goto done;
}
@@ -661,12 +668,14 @@ done:
static int eepro100_recv(struct eth_device *dev)
{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
struct eepro100_rxfd *desc;
int rx_prev, length = 0;
u16 status, stat;
- stat = INW(dev, SCB_STATUS);
- OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS);
+ stat = INW(priv, SCB_STATUS);
+ OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS);
for (;;) {
desc = &rx_ring[rx_next];
@@ -706,20 +715,20 @@ static int eepro100_recv(struct eth_device *dev)
}
if (stat & SCB_STATUS_RNR) {
- printf("%s: Receiver is not ready, restart it !\n", dev->name);
+ printf("%s: Receiver is not ready, restart it !\n", priv->name);
/* Reinitialize Rx ring. */
- init_rx_ring(dev);
+ init_rx_ring(priv);
- if (!wait_for_eepro100(dev)) {
+ if (!wait_for_eepro100(priv)) {
printf("Error: Can not restart ethernet controller.\n");
goto done;
}
/* RX ring cache was already flushed in init_rx_ring() */
- OUTL(dev, phys_to_bus((pci_dev_t)dev->priv,
- (u32)&rx_ring[rx_next]), SCB_POINTER);
- OUTW(dev, SCB_M | RUC_START, SCB_CMD);
+ OUTL(priv, phys_to_bus(priv->devno,
+ (u32)&rx_ring[rx_next]), SCB_POINTER);
+ OUTW(priv, SCB_M | RUC_START, SCB_CMD);
}
done:
@@ -728,26 +737,29 @@ done:
static void eepro100_halt(struct eth_device *dev)
{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
+
/* Reset the ethernet controller */
- OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT);
+ OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT);
udelay(20);
- OUTL(dev, I82559_RESET, SCB_PORT);
+ OUTL(priv, I82559_RESET, SCB_PORT);
udelay(20);
- if (!wait_for_eepro100(dev)) {
+ if (!wait_for_eepro100(priv)) {
printf("Error: Can not reset ethernet controller.\n");
goto done;
}
- OUTL(dev, 0, SCB_POINTER);
- OUTW(dev, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
+ OUTL(priv, 0, SCB_POINTER);
+ OUTW(priv, SCB_M | RUC_ADDR_LOAD, SCB_CMD);
- if (!wait_for_eepro100(dev)) {
+ if (!wait_for_eepro100(priv)) {
printf("Error: Can not reset ethernet controller.\n");
goto done;
}
- OUTL(dev, 0, SCB_POINTER);
- OUTW(dev, SCB_M | CU_ADDR_LOAD, SCB_CMD);
+ OUTL(priv, 0, SCB_POINTER);
+ OUTW(priv, SCB_M | CU_ADDR_LOAD, SCB_CMD);
done:
return;
@@ -798,8 +810,12 @@ int eepro100_initialize(bd_t *bis)
dev = &priv->dev;
sprintf(dev->name, "i82559#%d", card_number);
- dev->priv = (void *)devno; /* this have to come before bus_to_phys() */
- dev->iobase = bus_to_phys(devno, iobase);
+ priv->name = dev->name;
+ /* this have to come before bus_to_phys() */
+ priv->devno = devno;
+ priv->iobase = (void __iomem *)bus_to_phys(devno, iobase);
+ priv->enetaddr = dev->enetaddr;
+
dev->init = eepro100_init;
dev->halt = eepro100_halt;
dev->send = eepro100_send;
@@ -807,7 +823,7 @@ int eepro100_initialize(bd_t *bis)
eth_register(dev);
- ret = eepro100_initialize_mii(dev);
+ ret = eepro100_initialize_mii(priv);
if (ret) {
eth_unregister(dev);
free(priv);
@@ -821,7 +837,7 @@ int eepro100_initialize(bd_t *bis)
udelay(10 * 1000);
- read_hw_addr(dev, bis);
+ read_hw_addr(priv, bis);
}
return card_number;
--
cgit v1.1
From 39daab23768895c32b82e153c21a7955ae7dacb8 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 17:55:50 +0200
Subject: net: eepro100: Pass device private data into mdiobus
Instead of doing ethernet device lookup by name every time there
is an MDIO access, pass the driver private data via mdiobus priv
to the MDIO bus accessors.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 1c33ec3..78dedbd 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)
static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
int reg)
{
- struct eth_device *dev = eth_get_dev_by_name(bus->name);
- struct eepro100_priv *priv =
- container_of(dev, struct eepro100_priv, dev);
+ struct eepro100_priv *priv = bus->priv;
unsigned short value = 0;
int ret;
@@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
int reg, u16 value)
{
- struct eth_device *dev = eth_get_dev_by_name(bus->name);
- struct eepro100_priv *priv =
- container_of(dev, struct eepro100_priv, dev);
+ struct eepro100_priv *priv = bus->priv;
int ret;
ret = verify_phyaddr(priv, addr);
@@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv *priv)
strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN);
mdiodev->read = eepro100_miiphy_read;
mdiodev->write = eepro100_miiphy_write;
+ mdiodev->priv = priv;
ret = mdio_register(mdiodev);
if (ret < 0) {
--
cgit v1.1
From fb8307e52af1e9dd4854c7b3addd27ef04a098d4 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 17:13:26 +0200
Subject: net: eepro100: Add RX/TX rings into the private data
The RX/TX DMA descriptor rings are per-device-instance private data,
so move them into the private data.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 59 ++++++++++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 24 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 78dedbd..ed6bbd5 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -183,12 +183,6 @@ struct descriptor { /* A generic descriptor. */
#define TOUT_LOOP 1000000
-static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */
-static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */
-static int rx_next; /* RX descriptor ring pointer */
-static int tx_next; /* TX descriptor ring pointer */
-static int tx_threshold;
-
/*
* The parameters for a CmdConfigure operation.
* There are so many options that it would be difficult to document
@@ -202,6 +196,15 @@ static const char i82558_config_cmd[] = {
};
struct eepro100_priv {
+ /* RX descriptor ring */
+ struct eepro100_rxfd rx_ring[NUM_RX_DESC];
+ /* TX descriptor ring */
+ struct eepro100_txfd tx_ring[NUM_TX_DESC];
+ /* RX descriptor ring pointer */
+ int rx_next;
+ /* TX descriptor ring pointer */
+ int tx_next;
+ int tx_threshold;
struct eth_device dev;
pci_dev_t devno;
char *name;
@@ -348,6 +351,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
static void init_rx_ring(struct eepro100_priv *priv)
{
+ struct eepro100_rxfd *rx_ring = priv->rx_ring;
int i;
for (i = 0; i < NUM_RX_DESC; i++) {
@@ -366,13 +370,15 @@ static void init_rx_ring(struct eepro100_priv *priv)
(unsigned long)rx_ring +
(sizeof(*rx_ring) * NUM_RX_DESC));
- rx_next = 0;
+ priv->rx_next = 0;
}
static void purge_tx_ring(struct eepro100_priv *priv)
{
- tx_next = 0;
- tx_threshold = 0x01208000;
+ struct eepro100_txfd *tx_ring = priv->tx_ring;
+
+ priv->tx_next = 0;
+ priv->tx_threshold = 0x01208000;
memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC);
flush_dcache_range((unsigned long)tx_ring,
@@ -533,6 +539,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
struct eepro100_priv *priv =
container_of(dev, struct eepro100_priv, dev);
+ struct eepro100_rxfd *rx_ring = priv->rx_ring;
+ struct eepro100_txfd *tx_ring = priv->tx_ring;
struct eepro100_txfd *ias_cmd, *cfg_cmd;
int ret, status = -1;
int tx_cur;
@@ -569,20 +577,20 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
}
/* RX ring cache was already flushed in init_rx_ring() */
- OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]),
+ OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[priv->rx_next]),
SCB_POINTER);
OUTW(priv, SCB_M | RUC_START, SCB_CMD);
/* Send the Configure frame */
- tx_cur = tx_next;
- tx_next = ((tx_next + 1) % NUM_TX_DESC);
+ tx_cur = priv->tx_next;
+ priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC);
cfg_cmd = &tx_ring[tx_cur];
cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_CONFIGURE);
cfg_cmd->status = 0;
cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno,
- (u32)&tx_ring[tx_next]));
+ (u32)&tx_ring[priv->tx_next]));
memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,
sizeof(i82558_config_cmd));
@@ -595,15 +603,15 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)
}
/* Send the Individual Address Setup frame */
- tx_cur = tx_next;
- tx_next = ((tx_next + 1) % NUM_TX_DESC);
+ tx_cur = priv->tx_next;
+ priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC);
ias_cmd = &tx_ring[tx_cur];
ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND |
CONFIG_SYS_CMD_IAS);
ias_cmd->status = 0;
ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno,
- (u32)&tx_ring[tx_next]));
+ (u32)&tx_ring[priv->tx_next]));
memcpy(((struct descriptor *)ias_cmd)->params, priv->enetaddr, 6);
@@ -624,6 +632,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
{
struct eepro100_priv *priv =
container_of(dev, struct eepro100_priv, dev);
+ struct eepro100_txfd *tx_ring = priv->tx_ring;
struct eepro100_txfd *desc;
int ret, status = -1;
int tx_cur;
@@ -633,16 +642,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)
goto done;
}
- tx_cur = tx_next;
- tx_next = (tx_next + 1) % NUM_TX_DESC;
+ tx_cur = priv->tx_next;
+ priv->tx_next = (priv->tx_next + 1) % NUM_TX_DESC;
desc = &tx_ring[tx_cur];
desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF |
TXCB_CMD_S | TXCB_CMD_EL);
desc->status = 0;
- desc->count = cpu_to_le32(tx_threshold);
+ desc->count = cpu_to_le32(priv->tx_threshold);
desc->link = cpu_to_le32(phys_to_bus(priv->devno,
- (u32)&tx_ring[tx_next]));
+ (u32)&tx_ring[priv->tx_next]));
desc->tx_desc_addr = cpu_to_le32(phys_to_bus(priv->devno,
(u32)&desc->tx_buf_addr0));
desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno,
@@ -667,6 +676,7 @@ static int eepro100_recv(struct eth_device *dev)
{
struct eepro100_priv *priv =
container_of(dev, struct eepro100_priv, dev);
+ struct eepro100_rxfd *rx_ring = priv->rx_ring;
struct eepro100_rxfd *desc;
int rx_prev, length = 0;
u16 status, stat;
@@ -675,7 +685,7 @@ static int eepro100_recv(struct eth_device *dev)
OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS);
for (;;) {
- desc = &rx_ring[rx_next];
+ desc = &rx_ring[priv->rx_next];
invalidate_dcache_range((unsigned long)desc,
(unsigned long)desc + sizeof(*desc));
status = le16_to_cpu(desc->status);
@@ -701,14 +711,14 @@ static int eepro100_recv(struct eth_device *dev)
flush_dcache_range((unsigned long)desc,
(unsigned long)desc + sizeof(*desc));
- rx_prev = (rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
+ rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
desc = &rx_ring[rx_prev];
desc->control = 0;
flush_dcache_range((unsigned long)desc,
(unsigned long)desc + sizeof(*desc));
/* Update entry information. */
- rx_next = (rx_next + 1) % NUM_RX_DESC;
+ priv->rx_next = (priv->rx_next + 1) % NUM_RX_DESC;
}
if (stat & SCB_STATUS_RNR) {
@@ -724,7 +734,8 @@ static int eepro100_recv(struct eth_device *dev)
/* RX ring cache was already flushed in init_rx_ring() */
OUTL(priv, phys_to_bus(priv->devno,
- (u32)&rx_ring[rx_next]), SCB_POINTER);
+ (u32)&rx_ring[priv->rx_next]),
+ SCB_POINTER);
OUTW(priv, SCB_M | RUC_START, SCB_CMD);
}
--
cgit v1.1
From 43b738350ce133bc19c2bd4586ecff486e39e835 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 17:20:39 +0200
Subject: net: eepro100: Drop bd_t pointer from read_hw_addr()
The pointer is unused, so drop it. Rename the function to start
with the eepro100_ prefix.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index ed6bbd5..fb8a68f 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -512,7 +512,7 @@ static struct pci_device_id supported[] = {
{ }
};
-static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis)
+static void eepro100_get_hwaddr(struct eepro100_priv *priv)
{
u16 sum = 0;
int i, j;
@@ -845,7 +845,7 @@ int eepro100_initialize(bd_t *bis)
udelay(10 * 1000);
- read_hw_addr(priv, bis);
+ eepro100_get_hwaddr(priv);
}
return card_number;
--
cgit v1.1
From 8835103e24622cefd37a1a8d5011c160da6a34df Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 17:28:20 +0200
Subject: net: eepro100: Split common parts of non-DM functions out
Split the common code from the non-DM code, so it can be reused by
the DM code later. As always, the recv() function had to be split
into the actual receiving part and free_pkt part to fit with the
DM.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 162 ++++++++++++++++++++++++++++++-------------------
1 file changed, 100 insertions(+), 62 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index fb8a68f..f474832 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -202,6 +202,7 @@ struct eepro100_priv {
struct eepro100_txfd tx_ring[NUM_TX_DESC];
/* RX descriptor ring pointer */
int rx_next;
+ u16 rx_stat;
/* TX descriptor ring pointer */
int tx_next;
int tx_threshold;
@@ -535,10 +536,8 @@ static void eepro100_get_hwaddr(struct eepro100_priv *priv)
}
}
-static int eepro100_init(struct eth_device *dev, bd_t *bis)
+static int eepro100_init_common(struct eepro100_priv *priv)
{
- struct eepro100_priv *priv =
- container_of(dev, struct eepro100_priv, dev);
struct eepro100_rxfd *rx_ring = priv->rx_ring;
struct eepro100_txfd *tx_ring = priv->tx_ring;
struct eepro100_txfd *ias_cmd, *cfg_cmd;
@@ -628,10 +627,9 @@ done:
return status;
}
-static int eepro100_send(struct eth_device *dev, void *packet, int length)
+static int eepro100_send_common(struct eepro100_priv *priv,
+ void *packet, int length)
{
- struct eepro100_priv *priv =
- container_of(dev, struct eepro100_priv, dev);
struct eepro100_txfd *tx_ring = priv->tx_ring;
struct eepro100_txfd *desc;
int ret, status = -1;
@@ -672,82 +670,82 @@ done:
return status;
}
-static int eepro100_recv(struct eth_device *dev)
+static int eepro100_recv_common(struct eepro100_priv *priv, uchar **packetp)
{
- struct eepro100_priv *priv =
- container_of(dev, struct eepro100_priv, dev);
struct eepro100_rxfd *rx_ring = priv->rx_ring;
struct eepro100_rxfd *desc;
- int rx_prev, length = 0;
- u16 status, stat;
+ int length;
+ u16 status;
- stat = INW(priv, SCB_STATUS);
- OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS);
+ priv->rx_stat = INW(priv, SCB_STATUS);
+ OUTW(priv, priv->rx_stat & SCB_STATUS_RNR, SCB_STATUS);
- for (;;) {
- desc = &rx_ring[priv->rx_next];
- invalidate_dcache_range((unsigned long)desc,
- (unsigned long)desc + sizeof(*desc));
- status = le16_to_cpu(desc->status);
+ desc = &rx_ring[priv->rx_next];
+ invalidate_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
+ status = le16_to_cpu(desc->status);
+
+ if (!(status & RFD_STATUS_C))
+ return 0;
+
+ /* Valid frame status. */
+ if (status & RFD_STATUS_OK) {
+ /* A valid frame received. */
+ length = le32_to_cpu(desc->count) & 0x3fff;
+ /* Pass the packet up to the protocol layers. */
+ *packetp = desc->data;
+ return length;
+ }
- if (!(status & RFD_STATUS_C))
- break;
+ /* There was an error. */
+ printf("RX error status = 0x%08X\n", status);
+ return -EINVAL;
+}
- /* Valid frame status. */
- if ((status & RFD_STATUS_OK)) {
- /* A valid frame received. */
- length = le32_to_cpu(desc->count) & 0x3fff;
+static void eepro100_free_pkt_common(struct eepro100_priv *priv)
+{
+ struct eepro100_rxfd *rx_ring = priv->rx_ring;
+ struct eepro100_rxfd *desc;
+ int rx_prev;
- /* Pass the packet up to the protocol layers. */
- net_process_received_packet((u8 *)desc->data, length);
- } else {
- /* There was an error. */
- printf("RX error status = 0x%08X\n", status);
- }
+ desc = &rx_ring[priv->rx_next];
- desc->control = cpu_to_le16(RFD_CONTROL_S);
- desc->status = 0;
- desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16);
- flush_dcache_range((unsigned long)desc,
- (unsigned long)desc + sizeof(*desc));
+ desc->control = cpu_to_le16(RFD_CONTROL_S);
+ desc->status = 0;
+ desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16);
+ flush_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
- rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
- desc = &rx_ring[rx_prev];
- desc->control = 0;
- flush_dcache_range((unsigned long)desc,
- (unsigned long)desc + sizeof(*desc));
+ rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC;
+ desc = &rx_ring[rx_prev];
+ desc->control = 0;
+ flush_dcache_range((unsigned long)desc,
+ (unsigned long)desc + sizeof(*desc));
- /* Update entry information. */
- priv->rx_next = (priv->rx_next + 1) % NUM_RX_DESC;
- }
+ /* Update entry information. */
+ priv->rx_next = (priv->rx_next + 1) % NUM_RX_DESC;
- if (stat & SCB_STATUS_RNR) {
- printf("%s: Receiver is not ready, restart it !\n", priv->name);
+ if (!(priv->rx_stat & SCB_STATUS_RNR))
+ return;
- /* Reinitialize Rx ring. */
- init_rx_ring(priv);
+ printf("%s: Receiver is not ready, restart it !\n", priv->name);
- if (!wait_for_eepro100(priv)) {
- printf("Error: Can not restart ethernet controller.\n");
- goto done;
- }
+ /* Reinitialize Rx ring. */
+ init_rx_ring(priv);
- /* RX ring cache was already flushed in init_rx_ring() */
- OUTL(priv, phys_to_bus(priv->devno,
- (u32)&rx_ring[priv->rx_next]),
- SCB_POINTER);
- OUTW(priv, SCB_M | RUC_START, SCB_CMD);
+ if (!wait_for_eepro100(priv)) {
+ printf("Error: Can not restart ethernet controller.\n");
+ return;
}
-done:
- return length;
+ /* RX ring cache was already flushed in init_rx_ring() */
+ OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[priv->rx_next]),
+ SCB_POINTER);
+ OUTW(priv, SCB_M | RUC_START, SCB_CMD);
}
-static void eepro100_halt(struct eth_device *dev)
+static void eepro100_halt_common(struct eepro100_priv *priv)
{
- struct eepro100_priv *priv =
- container_of(dev, struct eepro100_priv, dev);
-
/* Reset the ethernet controller */
OUTL(priv, I82559_SELECTIVE_RESET, SCB_PORT);
udelay(20);
@@ -773,6 +771,46 @@ done:
return;
}
+static int eepro100_init(struct eth_device *dev, bd_t *bis)
+{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
+
+ return eepro100_init_common(priv);
+}
+
+static void eepro100_halt(struct eth_device *dev)
+{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
+
+ eepro100_halt_common(priv);
+}
+
+static int eepro100_send(struct eth_device *dev, void *packet, int length)
+{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
+
+ return eepro100_send_common(priv, packet, length);
+}
+
+static int eepro100_recv(struct eth_device *dev)
+{
+ struct eepro100_priv *priv =
+ container_of(dev, struct eepro100_priv, dev);
+ uchar *packet;
+ int ret;
+
+ ret = eepro100_recv_common(priv, &packet);
+ if (ret > 0)
+ net_process_received_packet(packet, ret);
+ if (ret)
+ eepro100_free_pkt_common(priv);
+
+ return ret;
+}
+
int eepro100_initialize(bd_t *bis)
{
struct eepro100_priv *priv;
--
cgit v1.1
From af8ecdf7e5d9ec13581906172a1a9762d9a7a504 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 16:26:20 +0200
Subject: net: eepro100: Add DM support
Add support for driver model to the driver.
Signed-off-by: Marek Vasut
---
drivers/net/eepro100.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 128 insertions(+), 1 deletion(-)
(limited to 'drivers')
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index f474832..45ea3b7 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -206,14 +206,21 @@ struct eepro100_priv {
/* TX descriptor ring pointer */
int tx_next;
int tx_threshold;
+#ifdef CONFIG_DM_ETH
+ struct udevice *devno;
+#else
struct eth_device dev;
pci_dev_t devno;
+#endif
char *name;
void __iomem *iobase;
u8 *enetaddr;
};
-#if defined(CONFIG_E500)
+#if defined(CONFIG_DM_ETH)
+#define bus_to_phys(dev, a) dm_pci_mem_to_phys((dev), (a))
+#define phys_to_bus(dev, a) dm_pci_phys_to_mem((dev), (a))
+#elif defined(CONFIG_E500)
#define bus_to_phys(dev, a) (a)
#define phys_to_bus(dev, a) (a)
#else
@@ -771,6 +778,7 @@ done:
return;
}
+#ifndef CONFIG_DM_ETH
static int eepro100_init(struct eth_device *dev, bd_t *bis)
{
struct eepro100_priv *priv =
@@ -888,3 +896,122 @@ int eepro100_initialize(bd_t *bis)
return card_number;
}
+
+#else /* DM_ETH */
+static int eepro100_start(struct udevice *dev)
+{
+ struct eth_pdata *plat = dev_get_platdata(dev);
+ struct eepro100_priv *priv = dev_get_priv(dev);
+
+ memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr));
+
+ return eepro100_init_common(priv);
+}
+
+static void eepro100_stop(struct udevice *dev)
+{
+ struct eepro100_priv *priv = dev_get_priv(dev);
+
+ eepro100_halt_common(priv);
+}
+
+static int eepro100_send(struct udevice *dev, void *packet, int length)
+{
+ struct eepro100_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ ret = eepro100_send_common(priv, packet, length);
+
+ return ret ? 0 : -ETIMEDOUT;
+}
+
+static int eepro100_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+ struct eepro100_priv *priv = dev_get_priv(dev);
+
+ return eepro100_recv_common(priv, packetp);
+}
+
+static int eepro100_free_pkt(struct udevice *dev, uchar *packet, int length)
+{
+ struct eepro100_priv *priv = dev_get_priv(dev);
+
+ eepro100_free_pkt_common(priv);
+
+ return 0;
+}
+
+static int eepro100_read_rom_hwaddr(struct udevice *dev)
+{
+ struct eepro100_priv *priv = dev_get_priv(dev);
+
+ eepro100_get_hwaddr(priv);
+
+ return 0;
+}
+
+static int eepro100_bind(struct udevice *dev)
+{
+ static int card_number;
+ char name[16];
+
+ sprintf(name, "eepro100#%u", card_number++);
+
+ return device_set_name(dev, name);
+}
+
+static int eepro100_probe(struct udevice *dev)
+{
+ struct eth_pdata *plat = dev_get_platdata(dev);
+ struct eepro100_priv *priv = dev_get_priv(dev);
+ u16 command, status;
+ u32 iobase;
+ int ret;
+
+ dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
+ iobase &= ~0xf;
+
+ debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase);
+
+ priv->devno = dev;
+ priv->enetaddr = plat->enetaddr;
+ priv->iobase = (void __iomem *)bus_to_phys(dev, iobase);
+
+ command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
+ dm_pci_write_config16(dev, PCI_COMMAND, command);
+ dm_pci_read_config16(dev, PCI_COMMAND, &status);
+ if ((status & command) != command) {
+ printf("eepro100: Couldn't enable IO access or Bus Mastering\n");
+ return -EINVAL;
+ }
+
+ ret = eepro100_initialize_mii(priv);
+ if (ret)
+ return ret;
+
+ dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x20);
+
+ return 0;
+}
+
+static const struct eth_ops eepro100_ops = {
+ .start = eepro100_start,
+ .send = eepro100_send,
+ .recv = eepro100_recv,
+ .stop = eepro100_stop,
+ .free_pkt = eepro100_free_pkt,
+ .read_rom_hwaddr = eepro100_read_rom_hwaddr,
+};
+
+U_BOOT_DRIVER(eth_eepro100) = {
+ .name = "eth_eepro100",
+ .id = UCLASS_ETH,
+ .bind = eepro100_bind,
+ .probe = eepro100_probe,
+ .ops = &eepro100_ops,
+ .priv_auto_alloc_size = sizeof(struct eepro100_priv),
+ .platdata_auto_alloc_size = sizeof(struct eth_pdata),
+};
+
+U_BOOT_PCI_DEVICE(eth_eepro100, supported);
+#endif
--
cgit v1.1
From 6463b73e0b25b058404c52b48c991abf4f8a94ce Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sat, 23 May 2020 18:07:53 +0200
Subject: net: eepro100: Add Kconfig entries
Add Kconfig entries for the eepro100 driver and convert various boards.
Signed-off-by: Marek Vasut
---
drivers/net/Kconfig | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'drivers')
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index bb23f73..ed07a78 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -193,6 +193,12 @@ config CMD_E1000
used on devices with SPI support you can reprogram the EEPROM from
U-Boot.
+config EEPRO100
+ bool "Intel PRO/100 82557/82559/82559ER Fast Ethernet support"
+ help
+ This driver supports Intel(R) PRO/100 82557/82559/82559ER fast
+ ethernet family of adapters.
+
config ETH_SANDBOX
depends on DM_ETH && SANDBOX
default y
--
cgit v1.1
From 97d5c145592c1d2aa38a8d074fed9aee059ac119 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 15:10:41 +0200
Subject: net: pcnet: Drop typedef struct pcnet_priv_t
Use struct pcnet_priv all over the place instead.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index 260a5a3..c6f080d 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -76,15 +76,15 @@ struct pcnet_uncached_priv {
struct pcnet_init_block init_block;
};
-typedef struct pcnet_priv {
+struct pcnet_priv {
struct pcnet_uncached_priv *uc;
/* Receive Buffer space */
unsigned char (*rx_buf)[RX_RING_SIZE][PKT_BUF_SZ + 4];
int cur_rx;
int cur_tx;
-} pcnet_priv_t;
+};
-static pcnet_priv_t *lp;
+static struct pcnet_priv *lp;
/* Offsets from base I/O address for WIO mode */
#define PCNET_RDP 0x10
@@ -340,9 +340,9 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
* must be aligned on 16-byte boundaries.
*/
if (lp == NULL) {
- addr = (unsigned long)malloc(sizeof(pcnet_priv_t) + 0x10);
+ addr = (unsigned long)malloc(sizeof(*lp) + 0x10);
addr = (addr + 0xf) & ~0xf;
- lp = (pcnet_priv_t *)addr;
+ lp = (struct pcnet_priv *)addr;
addr = (unsigned long)memalign(ARCH_DMA_MINALIGN,
sizeof(*lp->uc));
--
cgit v1.1
From 1524e409ef130e20e6554446d08be967422d27f7 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 18:12:19 +0200
Subject: net: pcnet: Drop PCNET_HAS_PROM
All of one PCNET users has this option set, make this default
and drop this config option.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 5 -----
1 file changed, 5 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index c6f080d..edc4dba 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -241,10 +241,7 @@ static int pcnet_probe(struct eth_device *dev, bd_t *bis, int dev_nr)
{
int chip_version;
char *chipname;
-
-#ifdef PCNET_HAS_PROM
int i;
-#endif
/* Reset the PCnet controller */
pcnet_reset(dev);
@@ -279,7 +276,6 @@ static int pcnet_probe(struct eth_device *dev, bd_t *bis, int dev_nr)
PCNET_DEBUG1("AMD %s\n", chipname);
-#ifdef PCNET_HAS_PROM
/*
* In most chips, after a chip reset, the ethernet address is read from
* the station address PROM at the base address and programmed into the
@@ -293,7 +289,6 @@ static int pcnet_probe(struct eth_device *dev, bd_t *bis, int dev_nr)
dev->enetaddr[2 * i] = val & 0x0ff;
dev->enetaddr[2 * i + 1] = (val >> 8) & 0x0ff;
}
-#endif /* PCNET_HAS_PROM */
return 0;
}
--
cgit v1.1
From e4797c31612d9c31b7b65fce8c3081ae2d150d00 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 17:33:17 +0200
Subject: net: pcnet: Use PCI_DEVICE() to define PCI device compat list
Use this macro to fully fill the PCI device ID table. This is mandatory
for the DM PCI support, which checks all the fields.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index edc4dba..e7ce79e 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -155,7 +155,7 @@ static inline pci_addr_t pcnet_virt_to_mem(const struct eth_device *dev,
}
static struct pci_device_id supported[] = {
- {PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE},
+ { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE) },
{}
};
--
cgit v1.1
From 1c38c36eb99abfd1bc46b90c80f7daa5c65f3527 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:16:45 +0200
Subject: net: pcnet: Simplify private data allocation
The current code is horribly complex. Both the RX and TX buffer
descriptors are 16 bytes in size, the init block is 32 bytes in
size, so simplify the code such that the entire private data of
the driver are allocated cache aligned and the RX and TX buffer
descriptors are part of the private data.
This removes multiple malloc calls and cache flushes.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index e7ce79e..72b9380 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -74,12 +75,13 @@ struct pcnet_uncached_priv {
struct pcnet_rx_head rx_ring[RX_RING_SIZE];
struct pcnet_tx_head tx_ring[TX_RING_SIZE];
struct pcnet_init_block init_block;
-};
+} __aligned(ARCH_DMA_MINALIGN);
struct pcnet_priv {
- struct pcnet_uncached_priv *uc;
+ struct pcnet_uncached_priv ucp;
/* Receive Buffer space */
- unsigned char (*rx_buf)[RX_RING_SIZE][PKT_BUF_SZ + 4];
+ unsigned char rx_buf[RX_RING_SIZE][PKT_BUF_SZ + 4];
+ struct pcnet_uncached_priv *uc;
int cur_rx;
int cur_tx;
};
@@ -335,22 +337,11 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
* must be aligned on 16-byte boundaries.
*/
if (lp == NULL) {
- addr = (unsigned long)malloc(sizeof(*lp) + 0x10);
- addr = (addr + 0xf) & ~0xf;
- lp = (struct pcnet_priv *)addr;
-
- addr = (unsigned long)memalign(ARCH_DMA_MINALIGN,
- sizeof(*lp->uc));
- flush_dcache_range(addr, addr + sizeof(*lp->uc));
- addr = (unsigned long)map_physmem(addr,
- roundup(sizeof(*lp->uc), ARCH_DMA_MINALIGN),
- MAP_NOCACHE);
- lp->uc = (struct pcnet_uncached_priv *)addr;
-
- addr = (unsigned long)memalign(ARCH_DMA_MINALIGN,
- sizeof(*lp->rx_buf));
- flush_dcache_range(addr, addr + sizeof(*lp->rx_buf));
- lp->rx_buf = (void *)addr;
+ lp = malloc_cache_aligned(sizeof(*lp));
+ lp->uc = map_physmem((phys_addr_t)&lp->ucp,
+ sizeof(lp->ucp), MAP_NOCACHE);
+ flush_dcache_range((unsigned long)lp,
+ (unsigned long)lp + sizeof(*lp));
}
uc = lp->uc;
@@ -364,7 +355,7 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
*/
lp->cur_rx = 0;
for (i = 0; i < RX_RING_SIZE; i++) {
- addr = pcnet_virt_to_mem(dev, (*lp->rx_buf)[i]);
+ addr = pcnet_virt_to_mem(dev, lp->rx_buf[i]);
uc->rx_ring[i].base = cpu_to_le32(addr);
uc->rx_ring[i].buf_length = cpu_to_le16(-PKT_BUF_SZ);
uc->rx_ring[i].status = cpu_to_le16(0x8000);
@@ -521,7 +512,7 @@ static int pcnet_recv (struct eth_device *dev)
printf("%s: Rx%d: invalid packet length %d\n",
dev->name, lp->cur_rx, pkt_len);
} else {
- buf = (*lp->rx_buf)[lp->cur_rx];
+ buf = lp->rx_buf[lp->cur_rx];
invalidate_dcache_range((unsigned long)buf,
(unsigned long)buf + pkt_len);
net_process_received_packet(buf, pkt_len);
--
cgit v1.1
From ae38e96c23f3d08e2ec49206a99271252f5b3dc2 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:26:57 +0200
Subject: net: pcnet: Replace memset+malloc with calloc
This combination of functions can be replaced with calloc(),
make it so.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index 72b9380..b670cff 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -184,12 +184,11 @@ int pcnet_initialize(bd_t *bis)
/*
* Allocate and pre-fill the device structure.
*/
- dev = (struct eth_device *)malloc(sizeof(*dev));
+ dev = calloc(1, sizeof(*dev));
if (!dev) {
printf("pcnet: Can not allocate memory\n");
break;
}
- memset(dev, 0, sizeof(*dev));
dev->priv = (void *)(unsigned long)devbusfn;
sprintf(dev->name, "pcnet#%d", dev_nr);
--
cgit v1.1
From 246d2bfcf244326c43dcfffcecfdf684b8a4513d Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:26:00 +0200
Subject: net: pcnet: Move private data allocation to initialize
The private data allocation does not have to be done every time the
NIC is initialized at run time, move the allocation to initialize
function, which means it will be done only once when the driver
starts.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index b670cff..073ffca 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -189,6 +189,20 @@ int pcnet_initialize(bd_t *bis)
printf("pcnet: Can not allocate memory\n");
break;
}
+
+ /*
+ * We only maintain one structure because the drivers will
+ * never be used concurrently. In 32bit mode the RX and TX
+ * ring entries must be aligned on 16-byte boundaries.
+ */
+ if (!lp) {
+ lp = malloc_cache_aligned(sizeof(*lp));
+ lp->uc = map_physmem((phys_addr_t)&lp->ucp,
+ sizeof(lp->ucp), MAP_NOCACHE);
+ flush_dcache_range((unsigned long)lp,
+ (unsigned long)lp + sizeof(*lp));
+ }
+
dev->priv = (void *)(unsigned long)devbusfn;
sprintf(dev->name, "pcnet#%d", dev_nr);
@@ -330,19 +344,6 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
val |= 0x3 << 10;
pcnet_write_csr(dev, 80, val);
- /*
- * We only maintain one structure because the drivers will never
- * be used concurrently. In 32bit mode the RX and TX ring entries
- * must be aligned on 16-byte boundaries.
- */
- if (lp == NULL) {
- lp = malloc_cache_aligned(sizeof(*lp));
- lp->uc = map_physmem((phys_addr_t)&lp->ucp,
- sizeof(lp->ucp), MAP_NOCACHE);
- flush_dcache_range((unsigned long)lp,
- (unsigned long)lp + sizeof(*lp));
- }
-
uc = lp->uc;
uc->init_block.mode = cpu_to_le16(0x0000);
--
cgit v1.1
From 69e08bd735c6d90a00959e0062f587f521f5d3df Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:31:41 +0200
Subject: net: pcnet: Move initialize function at the end
Move the function at the end of the driver, so we could drop
various forward declarations later. No functional change.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 180 ++++++++++++++++++++++++++--------------------------
1 file changed, 89 insertions(+), 91 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index 073ffca..6d464cd 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -161,97 +161,6 @@ static struct pci_device_id supported[] = {
{}
};
-
-int pcnet_initialize(bd_t *bis)
-{
- pci_dev_t devbusfn;
- struct eth_device *dev;
- u16 command, status;
- int dev_nr = 0;
- u32 bar;
-
- PCNET_DEBUG1("\npcnet_initialize...\n");
-
- for (dev_nr = 0;; dev_nr++) {
-
- /*
- * Find the PCnet PCI device(s).
- */
- devbusfn = pci_find_devices(supported, dev_nr);
- if (devbusfn < 0)
- break;
-
- /*
- * Allocate and pre-fill the device structure.
- */
- dev = calloc(1, sizeof(*dev));
- if (!dev) {
- printf("pcnet: Can not allocate memory\n");
- break;
- }
-
- /*
- * We only maintain one structure because the drivers will
- * never be used concurrently. In 32bit mode the RX and TX
- * ring entries must be aligned on 16-byte boundaries.
- */
- if (!lp) {
- lp = malloc_cache_aligned(sizeof(*lp));
- lp->uc = map_physmem((phys_addr_t)&lp->ucp,
- sizeof(lp->ucp), MAP_NOCACHE);
- flush_dcache_range((unsigned long)lp,
- (unsigned long)lp + sizeof(*lp));
- }
-
- dev->priv = (void *)(unsigned long)devbusfn;
- sprintf(dev->name, "pcnet#%d", dev_nr);
-
- /*
- * Setup the PCI device.
- */
- pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, &bar);
- dev->iobase = pci_mem_to_phys(devbusfn, bar);
- dev->iobase &= ~0xf;
-
- PCNET_DEBUG1("%s: devbusfn=0x%x iobase=0x%lx: ",
- dev->name, devbusfn, (unsigned long)dev->iobase);
-
- command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
- pci_write_config_word(devbusfn, PCI_COMMAND, command);
- pci_read_config_word(devbusfn, PCI_COMMAND, &status);
- if ((status & command) != command) {
- printf("%s: Couldn't enable IO access or Bus Mastering\n",
- dev->name);
- free(dev);
- continue;
- }
-
- pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x40);
-
- /*
- * Probe the PCnet chip.
- */
- if (pcnet_probe(dev, bis, dev_nr) < 0) {
- free(dev);
- continue;
- }
-
- /*
- * Setup device structure and register the driver.
- */
- dev->init = pcnet_init;
- dev->halt = pcnet_halt;
- dev->send = pcnet_send;
- dev->recv = pcnet_recv;
-
- eth_register(dev);
- }
-
- udelay(10 * 1000);
-
- return dev_nr;
-}
-
static int pcnet_probe(struct eth_device *dev, bd_t *bis, int dev_nr)
{
int chip_version;
@@ -548,3 +457,92 @@ static void pcnet_halt(struct eth_device *dev)
if (i <= 0)
printf("%s: TIMEOUT: controller reset failed\n", dev->name);
}
+
+int pcnet_initialize(bd_t *bis)
+{
+ pci_dev_t devbusfn;
+ struct eth_device *dev;
+ u16 command, status;
+ int dev_nr = 0;
+ u32 bar;
+
+ PCNET_DEBUG1("\npcnet_initialize...\n");
+
+ for (dev_nr = 0; ; dev_nr++) {
+ /*
+ * Find the PCnet PCI device(s).
+ */
+ devbusfn = pci_find_devices(supported, dev_nr);
+ if (devbusfn < 0)
+ break;
+
+ /*
+ * Allocate and pre-fill the device structure.
+ */
+ dev = calloc(1, sizeof(*dev));
+ if (!dev) {
+ printf("pcnet: Can not allocate memory\n");
+ break;
+ }
+
+ /*
+ * We only maintain one structure because the drivers will
+ * never be used concurrently. In 32bit mode the RX and TX
+ * ring entries must be aligned on 16-byte boundaries.
+ */
+ if (!lp) {
+ lp = malloc_cache_aligned(sizeof(*lp));
+ lp->uc = map_physmem((phys_addr_t)&lp->ucp,
+ sizeof(lp->ucp), MAP_NOCACHE);
+ flush_dcache_range((unsigned long)lp,
+ (unsigned long)lp + sizeof(*lp));
+ }
+
+ dev->priv = (void *)(unsigned long)devbusfn;
+ sprintf(dev->name, "pcnet#%d", dev_nr);
+
+ /*
+ * Setup the PCI device.
+ */
+ pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, &bar);
+ dev->iobase = pci_mem_to_phys(devbusfn, bar);
+ dev->iobase &= ~0xf;
+
+ PCNET_DEBUG1("%s: devbusfn=0x%x iobase=0x%lx: ",
+ dev->name, devbusfn, (unsigned long)dev->iobase);
+
+ command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
+ pci_write_config_word(devbusfn, PCI_COMMAND, command);
+ pci_read_config_word(devbusfn, PCI_COMMAND, &status);
+ if ((status & command) != command) {
+ printf("%s: Couldn't enable IO access or Bus Mastering\n",
+ dev->name);
+ free(dev);
+ continue;
+ }
+
+ pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x40);
+
+ /*
+ * Probe the PCnet chip.
+ */
+ if (pcnet_probe(dev, bis, dev_nr) < 0) {
+ free(dev);
+ continue;
+ }
+
+ /*
+ * Setup device structure and register the driver.
+ */
+ dev->init = pcnet_init;
+ dev->halt = pcnet_halt;
+ dev->send = pcnet_send;
+ dev->recv = pcnet_recv;
+
+ eth_register(dev);
+ }
+
+ udelay(10 * 1000);
+
+ return dev_nr;
+}
--
cgit v1.1
From d20e857e6b60720ff8ca98f8a4411336303e8d5f Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:28:41 +0200
Subject: net: pcnet: Drop useless forward declarations
Remove those as they are not needed anymore.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 6 ------
1 file changed, 6 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index 6d464cd..d8249f0 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -141,12 +141,6 @@ static int pcnet_check(struct eth_device *dev)
return readw(base + PCNET_RAP) == 88;
}
-static int pcnet_init (struct eth_device *dev, bd_t * bis);
-static int pcnet_send(struct eth_device *dev, void *packet, int length);
-static int pcnet_recv (struct eth_device *dev);
-static void pcnet_halt (struct eth_device *dev);
-static int pcnet_probe (struct eth_device *dev, bd_t * bis, int dev_num);
-
static inline pci_addr_t pcnet_virt_to_mem(const struct eth_device *dev,
void *addr)
{
--
cgit v1.1
From 60074d9d3ea048ea0ca369687aaaaed65695fc44 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:31:04 +0200
Subject: net: pcnet: Wrap devbusfn into private data
Instead of using eth_device priv for this PCI devbusfn, free it
so it could be used for driver private data, and wrap devbusfn
into those driver private data.
Note that using the name dev for the variable is a trick left for
later, when DM support is in place, so dm_pci_virt_to_mem() can be
used with minimal ifdeffery.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger
---
drivers/net/pcnet.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
(limited to 'drivers')
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index d8249f0..f7f1b8f 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -82,6 +82,7 @@ struct pcnet_priv {
/* Receive Buffer space */
unsigned char rx_buf[RX_RING_SIZE][PKT_BUF_SZ + 4];
struct pcnet_uncached_priv *uc;
+ pci_dev_t dev;
int cur_rx;
int cur_tx;
};
@@ -141,13 +142,11 @@ static int pcnet_check(struct eth_device *dev)
return readw(base + PCNET_RAP) == 88;
}
-static inline pci_addr_t pcnet_virt_to_mem(const struct eth_device *dev,
- void *addr)
+static inline pci_addr_t pcnet_virt_to_mem(struct pcnet_priv *lp, void *addr)
{
- pci_dev_t devbusfn = (pci_dev_t)(unsigned long)dev->priv;
void *virt_addr = addr;
- return pci_virt_to_mem(devbusfn, virt_addr);
+ return pci_virt_to_mem(lp->dev, virt_addr);
}
static struct pci_device_id supported[] = {
@@ -258,7 +257,7 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
*/
lp->cur_rx = 0;
for (i = 0; i < RX_RING_SIZE; i++) {
- addr = pcnet_virt_to_mem(dev, lp->rx_buf[i]);
+ addr = pcnet_virt_to_mem(lp, lp->rx_buf[i]);
uc->rx_ring[i].base = cpu_to_le32(addr);
uc->rx_ring[i].buf_length = cpu_to_le16(-PKT_BUF_SZ);
uc->rx_ring[i].status = cpu_to_le16(0x8000);
@@ -290,9 +289,9 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
uc->init_block.tlen_rlen = cpu_to_le16(TX_RING_LEN_BITS |
RX_RING_LEN_BITS);
- addr = pcnet_virt_to_mem(dev, uc->rx_ring);
+ addr = pcnet_virt_to_mem(lp, uc->rx_ring);
uc->init_block.rx_ring = cpu_to_le32(addr);
- addr = pcnet_virt_to_mem(dev, uc->tx_ring);
+ addr = pcnet_virt_to_mem(lp, uc->tx_ring);
uc->init_block.tx_ring = cpu_to_le32(addr);
PCNET_DEBUG1("\ntlen_rlen=0x%x rx_ring=0x%x tx_ring=0x%x\n",
@@ -303,7 +302,7 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
* Tell the controller where the Init Block is located.
*/
barrier();
- addr = pcnet_virt_to_mem(dev, &lp->uc->init_block);
+ addr = pcnet_virt_to_mem(lp, &lp->uc->init_block);
pcnet_write_csr(dev, 1, addr & 0xffff);
pcnet_write_csr(dev, 2, (addr >> 16) & 0xffff);
@@ -361,7 +360,7 @@ static int pcnet_send(struct eth_device *dev, void *packet, int pkt_len)
* Setup Tx ring. Caution: the write order is important here,
* set the status with the "ownership" bits last.
*/
- addr = pcnet_virt_to_mem(dev, packet);
+ addr = pcnet_virt_to_mem(lp, packet);
writew(-pkt_len, &entry->length);
writel(0, &entry->misc);
writel(addr, &entry->base);
@@ -492,7 +491,7 @@ int pcnet_initialize(bd_t *bis)
(unsigned long)lp + sizeof(*lp));
}
- dev->priv = (void *)(unsigned long)devbusfn;
+ lp->dev = devbusfn;
sprintf(dev->name, "pcnet#%d", dev_nr);
/*
--
cgit v1.1
From fdf6cbe54d1bdf217bed9b117ed2a823ae5c8dc2 Mon Sep 17 00:00:00 2001
From: Marek Vasut
Date: Sun, 17 May 2020 16:47:07 +0200
Subject: net: pcnet: Pass private data through dev->priv
Get rid of the global point to private data, and rather pass it
thought dev->priv. Also remove the unnecessary check for lp being
non-NULL, since it is always NULL at this point.
Signed-off-by: Marek Vasut
Cc: Daniel Schwierzeck
Cc: Joe Hershberger