public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Patrick Wildt <patrick@blueri.se>
To: u-boot@lists.denx.de
Subject: [U-Boot] rtl8169: use dm_pci_map_bar
Date: Tue, 11 Jun 2019 13:15:00 +0200	[thread overview]
Message-ID: <20190611111500.GA53008@thor.local> (raw)

Hi,

I have an rtl8169 on a macchiatobin and that card has a 64-bit
memory address.  The current code only reads a single word, which
means it can only support a 32-bit address.  By using dm_pci_map_bar
we don't need to manually parse the register, we can just have it do
its job.

I'm not sure though if this works for all devices since the previous
version had an explicit check for the device.

Patrick

Signed-off-by: Patrick Wildt <patrick@blueri.se>

diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 521e5909a2..f1d2ade253 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -1182,22 +1182,11 @@ static int rtl8169_eth_probe(struct udevice *dev)
 	struct pci_child_platdata *pplat = dev_get_parent_platdata(dev);
 	struct rtl8169_private *priv = dev_get_priv(dev);
 	struct eth_pdata *plat = dev_get_platdata(dev);
-	u32 iobase;
-	int region;
 	int ret;
 
-	debug("rtl8169: REALTEK RTL8169 @0x%x\n", iobase);
-	switch (pplat->device) {
-	case 0x8168:
-		region = 2;
-		break;
-	default:
-		region = 1;
-		break;
-	}
-	dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0 + region * 4, &iobase);
-	iobase &= ~0xf;
-	priv->iobase = (int)dm_pci_mem_to_phys(dev, iobase);
+	priv->iobase = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_2,
+				      PCI_REGION_MEM);
+	printf("rtl8169: REALTEK RTL8169 @0x%x\n", priv->iobase);
 
 	ret = rtl_init(priv->iobase, dev->name, plat->enetaddr);
 	if (ret < 0) {

             reply	other threads:[~2019-06-11 11:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-11 11:15 Patrick Wildt [this message]
2019-06-13  5:40 ` [U-Boot] rtl8169: use dm_pci_map_bar Stefan Roese
2019-06-13  7:16   ` Bin Meng
2019-06-13 16:43     ` Thierry Reding
2019-06-13 23:16       ` Patrick Wildt
2019-06-14  9:55         ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190611111500.GA53008@thor.local \
    --to=patrick@blueri.se \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox