[U-Boot] [RESEND PATCH v2 0/5] net/pch_gbe: updates for MIPS Boston board

This series is a resend of selected net/pch_gbe patches from the original patch series [1] which was blocked by other patch series. This series only contains the net/pch_gbe patches required for MIPS Boston board, but whose can be separately applied.
[1] https://lists.denx.de/pipermail/u-boot/2016-September/268137.html
Changes in v2: - move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() to the next patch as suggested by Bin Meng - move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() from the previous patch to this one as suggested by Bin Meng
Paul Burton (5): net: pch_gbe: Reset during probe net: pch_gbe: Fix rx descriptor buffer addresses net: pch_gbe: CPU accessible addresses are virtual net: pch_gbe: Add cache maintenance net: pch_gbe: Support PHY reset GPIOs
drivers/net/pch_gbe.c | 71 +++++++++++++++++++++++++++++++++++++++++---------- drivers/net/pch_gbe.h | 1 + 2 files changed, 58 insertions(+), 14 deletions(-)

From: Paul Burton paul.burton@imgtec.com
Using the EG20T gigabit ethernet controller on the MIPS Boston board, we find that we have to reset the controller in order for the RGMII link to the PHY to become functional. Without doing so we constantly time out in pch_gbe_mdio_ready.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com ---
Changes in v2: None
drivers/net/pch_gbe.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index d40fff0e48..4aac0f67a0 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -422,6 +422,7 @@ int pch_gbe_probe(struct udevice *dev) struct pch_gbe_priv *priv; struct eth_pdata *plat = dev_get_platdata(dev); void *iobase; + int err;
/* * The priv structure contains the descriptors and frame buffers which @@ -444,6 +445,10 @@ int pch_gbe_probe(struct udevice *dev) pch_gbe_mdio_init(dev->name, priv->mac_regs); priv->bus = miiphy_get_dev_by_name(dev->name);
+ err = pch_gbe_reset(dev); + if (err) + return err; + return pch_gbe_phy_init(dev); }

On 30 April 2017 at 13:57, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
Using the EG20T gigabit ethernet controller on the MIPS Boston board, we find that we have to reset the controller in order for the RGMII link to the PHY to become functional. Without doing so we constantly time out in pch_gbe_mdio_ready.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com
Changes in v2: None
drivers/net/pch_gbe.c | 5 +++++ 1 file changed, 5 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
Using the EG20T gigabit ethernet controller on the MIPS Boston board, we find that we have to reset the controller in order for the RGMII link to the PHY to become functional. Without doing so we constantly time out in pch_gbe_mdio_ready.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


From: Paul Burton paul.burton@imgtec.com
The loop to set up buffer addresses in rx descriptors always operated on descriptor 0, rather than on each descriptor sequentially. Fix this in order to setup correct buffer addresses for each descriptor.
Signed-off-by: Paul Burton paul.burton@imgtec.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
---
Changes in v2: - move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() to the next patch as suggested by Bin Meng
drivers/net/pch_gbe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 4aac0f67a0..7d15616356 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -117,8 +117,8 @@ static void pch_gbe_rx_descs_init(struct udevice *dev)
memset(rx_desc, 0, sizeof(struct pch_gbe_rx_desc) * PCH_GBE_DESC_NUM); for (i = 0; i < PCH_GBE_DESC_NUM; i++) - rx_desc->buffer_addr = dm_pci_phys_to_mem(priv->dev, - (ulong)(priv->rx_buff[i])); + rx_desc[i].buffer_addr = dm_pci_phys_to_mem(priv->dev, + priv->rx_buff[i]);
writel(dm_pci_phys_to_mem(priv->dev, (ulong)rx_desc), &mac_regs->rx_dsc_base);

On 30 April 2017 at 13:57, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
The loop to set up buffer addresses in rx descriptors always operated on descriptor 0, rather than on each descriptor sequentially. Fix this in order to setup correct buffer addresses for each descriptor.
Signed-off-by: Paul Burton paul.burton@imgtec.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
Changes in v2:
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() to the next patch as suggested by Bin Meng
drivers/net/pch_gbe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Eek!
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
The loop to set up buffer addresses in rx descriptors always operated on descriptor 0, rather than on each descriptor sequentially. Fix this in order to setup correct buffer addresses for each descriptor.
Signed-off-by: Paul Burton paul.burton@imgtec.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


From: Paul Burton paul.burton@imgtec.com
Use the virt_to_bus & bus_to_virt functions rather than phys_to_bus & bus_to_phys, since the addresses accessed by the CPU will be virtual rather than physical. On MIPS physical & virtual addresses differ as we use virtual addresses in kseg0, and attempting to use physical addresses directly caused problems as they're in the user segment which would be mapped via the uninitialised TLB.
Signed-off-by: Paul Burton paul.burton@imgtec.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
---
Changes in v2: - move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() from the previous patch to this one as suggested by Bin Meng
drivers/net/pch_gbe.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 7d15616356..14323512b0 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -117,15 +117,15 @@ static void pch_gbe_rx_descs_init(struct udevice *dev)
memset(rx_desc, 0, sizeof(struct pch_gbe_rx_desc) * PCH_GBE_DESC_NUM); for (i = 0; i < PCH_GBE_DESC_NUM; i++) - rx_desc[i].buffer_addr = dm_pci_phys_to_mem(priv->dev, + rx_desc[i].buffer_addr = dm_pci_virt_to_mem(priv->dev, priv->rx_buff[i]);
- writel(dm_pci_phys_to_mem(priv->dev, (ulong)rx_desc), + writel(dm_pci_virt_to_mem(priv->dev, rx_desc), &mac_regs->rx_dsc_base); writel(sizeof(struct pch_gbe_rx_desc) * (PCH_GBE_DESC_NUM - 1), &mac_regs->rx_dsc_size);
- writel(dm_pci_phys_to_mem(priv->dev, (ulong)(rx_desc + 1)), + writel(dm_pci_virt_to_mem(priv->dev, rx_desc + 1), &mac_regs->rx_dsc_sw_p); }
@@ -137,11 +137,11 @@ static void pch_gbe_tx_descs_init(struct udevice *dev)
memset(tx_desc, 0, sizeof(struct pch_gbe_tx_desc) * PCH_GBE_DESC_NUM);
- writel(dm_pci_phys_to_mem(priv->dev, (ulong)tx_desc), + writel(dm_pci_virt_to_mem(priv->dev, tx_desc), &mac_regs->tx_dsc_base); writel(sizeof(struct pch_gbe_tx_desc) * (PCH_GBE_DESC_NUM - 1), &mac_regs->tx_dsc_size); - writel(dm_pci_phys_to_mem(priv->dev, (ulong)(tx_desc + 1)), + writel(dm_pci_virt_to_mem(priv->dev, tx_desc + 1), &mac_regs->tx_dsc_sw_p); }
@@ -251,7 +251,7 @@ static int pch_gbe_send(struct udevice *dev, void *packet, int length) if (length < 64) frame_ctrl |= PCH_GBE_TXD_CTRL_APAD;
- tx_desc->buffer_addr = dm_pci_phys_to_mem(priv->dev, (ulong)packet); + tx_desc->buffer_addr = dm_pci_virt_to_mem(priv->dev, packet); tx_desc->length = length; tx_desc->tx_words_eob = length + 3; tx_desc->tx_frame_ctrl = frame_ctrl; @@ -262,7 +262,7 @@ static int pch_gbe_send(struct udevice *dev, void *packet, int length) if (++priv->tx_idx >= PCH_GBE_DESC_NUM) priv->tx_idx = 0;
- writel(dm_pci_phys_to_mem(priv->dev, (ulong)(tx_head + priv->tx_idx)), + writel(dm_pci_virt_to_mem(priv->dev, tx_head + priv->tx_idx), &mac_regs->tx_dsc_sw_p);
start = get_timer(0); @@ -283,7 +283,8 @@ static int pch_gbe_recv(struct udevice *dev, int flags, uchar **packetp) struct pch_gbe_priv *priv = dev_get_priv(dev); struct pch_gbe_regs *mac_regs = priv->mac_regs; struct pch_gbe_rx_desc *rx_desc; - ulong hw_desc, buffer_addr, length; + ulong hw_desc, length; + void *buffer;
rx_desc = &priv->rx_desc[priv->rx_idx];
@@ -291,12 +292,12 @@ static int pch_gbe_recv(struct udevice *dev, int flags, uchar **packetp) hw_desc = readl(&mac_regs->rx_dsc_hw_p_hld);
/* Just return if not receiving any packet */ - if ((ulong)rx_desc == hw_desc) + if (virt_to_phys(rx_desc) == hw_desc) return -EAGAIN;
- buffer_addr = dm_pci_mem_to_phys(priv->dev, rx_desc->buffer_addr); - *packetp = (uchar *)buffer_addr; length = rx_desc->rx_words_eob - 3 - ETH_FCS_LEN; + buffer = dm_pci_mem_to_virt(priv->dev, rx_desc->buffer_addr, length, 0); + *packetp = (uchar *)buffer;
return length; } @@ -315,7 +316,7 @@ static int pch_gbe_free_pkt(struct udevice *dev, uchar *packet, int length) if (++rx_swp >= PCH_GBE_DESC_NUM) rx_swp = 0;
- writel(dm_pci_phys_to_mem(priv->dev, (ulong)(rx_head + rx_swp)), + writel(dm_pci_virt_to_mem(priv->dev, rx_head + rx_swp), &mac_regs->rx_dsc_sw_p);
return 0;

On 30 April 2017 at 13:57, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
Use the virt_to_bus & bus_to_virt functions rather than phys_to_bus & bus_to_phys, since the addresses accessed by the CPU will be virtual rather than physical. On MIPS physical & virtual addresses differ as we use virtual addresses in kseg0, and attempting to use physical addresses directly caused problems as they're in the user segment which would be mapped via the uninitialised TLB.
Signed-off-by: Paul Burton paul.burton@imgtec.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
Changes in v2:
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() from the previous patch to this one as suggested by Bin Meng
drivers/net/pch_gbe.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
Use the virt_to_bus & bus_to_virt functions rather than phys_to_bus & bus_to_phys, since the addresses accessed by the CPU will be virtual rather than physical. On MIPS physical & virtual addresses differ as we use virtual addresses in kseg0, and attempting to use physical addresses directly caused problems as they're in the user segment which would be mapped via the uninitialised TLB.
Signed-off-by: Paul Burton paul.burton@imgtec.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


From: Paul Burton paul.burton@imgtec.com
On MIPS systems DMA isn't coherent with the CPU caches unless an IOCU is present. When there is no IOCU we need to writeback or invalidate the data caches at appropriate points. Perform this cache maintenance in the pch_gbe driver which is used on the MIPS Boston development board.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com ---
Changes in v2: None
drivers/net/pch_gbe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 14323512b0..8866f6632f 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -120,6 +120,8 @@ static void pch_gbe_rx_descs_init(struct udevice *dev) rx_desc[i].buffer_addr = dm_pci_virt_to_mem(priv->dev, priv->rx_buff[i]);
+ flush_dcache_range((ulong)rx_desc, (ulong)&rx_desc[PCH_GBE_DESC_NUM]); + writel(dm_pci_virt_to_mem(priv->dev, rx_desc), &mac_regs->rx_dsc_base); writel(sizeof(struct pch_gbe_rx_desc) * (PCH_GBE_DESC_NUM - 1), @@ -137,6 +139,8 @@ static void pch_gbe_tx_descs_init(struct udevice *dev)
memset(tx_desc, 0, sizeof(struct pch_gbe_tx_desc) * PCH_GBE_DESC_NUM);
+ flush_dcache_range((ulong)tx_desc, (ulong)&tx_desc[PCH_GBE_DESC_NUM]); + writel(dm_pci_virt_to_mem(priv->dev, tx_desc), &mac_regs->tx_dsc_base); writel(sizeof(struct pch_gbe_tx_desc) * (PCH_GBE_DESC_NUM - 1), @@ -245,6 +249,8 @@ static int pch_gbe_send(struct udevice *dev, void *packet, int length) u32 int_st; ulong start;
+ flush_dcache_range((ulong)packet, (ulong)packet + length); + tx_head = &priv->tx_desc[0]; tx_desc = &priv->tx_desc[priv->tx_idx];
@@ -258,6 +264,8 @@ static int pch_gbe_send(struct udevice *dev, void *packet, int length) tx_desc->dma_status = 0; tx_desc->gbec_status = 0;
+ flush_dcache_range((ulong)tx_desc, (ulong)&tx_desc[1]); + /* Test the wrap-around condition */ if (++priv->tx_idx >= PCH_GBE_DESC_NUM) priv->tx_idx = 0; @@ -295,8 +303,12 @@ static int pch_gbe_recv(struct udevice *dev, int flags, uchar **packetp) if (virt_to_phys(rx_desc) == hw_desc) return -EAGAIN;
+ /* Invalidate the descriptor */ + invalidate_dcache_range((ulong)rx_desc, (ulong)&rx_desc[1]); + length = rx_desc->rx_words_eob - 3 - ETH_FCS_LEN; buffer = dm_pci_mem_to_virt(priv->dev, rx_desc->buffer_addr, length, 0); + invalidate_dcache_range((ulong)buffer, (ulong)buffer + length); *packetp = (uchar *)buffer;
return length;

On 30 April 2017 at 13:57, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
On MIPS systems DMA isn't coherent with the CPU caches unless an IOCU is present. When there is no IOCU we need to writeback or invalidate the data caches at appropriate points. Perform this cache maintenance in the pch_gbe driver which is used on the MIPS Boston development board.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com
Changes in v2: None
drivers/net/pch_gbe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
On MIPS systems DMA isn't coherent with the CPU caches unless an IOCU is present. When there is no IOCU we need to writeback or invalidate the data caches at appropriate points. Perform this cache maintenance in the pch_gbe driver which is used on the MIPS Boston development board.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


From: Paul Burton paul.burton@imgtec.com
Add support to the pch_gbe driver for resetting the PHY using a GPIO specified in the device tree. This matches the support already in Linux.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com ---
Changes in v2: None
drivers/net/pch_gbe.c | 29 +++++++++++++++++++++++++++-- drivers/net/pch_gbe.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 8866f6632f..cc3ca8b3da 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -12,6 +12,7 @@ #include <asm/io.h> #include <pci.h> #include <miiphy.h> +#include <asm/gpio.h> #include "pch_gbe.h"
#if !defined(CONFIG_PHYLIB) @@ -72,6 +73,14 @@ static int pch_gbe_reset(struct udevice *dev) priv->rx_idx = 0; priv->tx_idx = 0;
+ if (dm_gpio_is_valid(&priv->gpio_phy_reset)) { + /* Reset the PHY */ + dm_gpio_set_value(&priv->gpio_phy_reset, 1); + udelay(15000); + dm_gpio_set_value(&priv->gpio_phy_reset, 0); + udelay(5000); + } + writel(PCH_GBE_ALL_RST, &mac_regs->reset);
/* @@ -451,6 +460,11 @@ int pch_gbe_probe(struct udevice *dev) plat->iobase = (ulong)iobase; priv->mac_regs = (struct pch_gbe_regs *)iobase;
+ err = gpio_request_by_name(dev, "phy-reset-gpios", 0, + &priv->gpio_phy_reset, GPIOD_IS_OUT); + if (err && (err != -ENOENT)) + return err; + /* Read MAC address from SROM and initialize dev->enetaddr with it */ pch_gbe_mac_read(priv->mac_regs, plat->enetaddr);
@@ -460,9 +474,17 @@ int pch_gbe_probe(struct udevice *dev)
err = pch_gbe_reset(dev); if (err) - return err; + goto out_err;
- return pch_gbe_phy_init(dev); + err = pch_gbe_phy_init(dev); + if (err) + goto out_err; + + return 0; +out_err: + if (dm_gpio_is_valid(&priv->gpio_phy_reset)) + dm_gpio_free(dev, &priv->gpio_phy_reset); + return err; }
int pch_gbe_remove(struct udevice *dev) @@ -473,6 +495,9 @@ int pch_gbe_remove(struct udevice *dev) mdio_unregister(priv->bus); mdio_free(priv->bus);
+ if (dm_gpio_is_valid(&priv->gpio_phy_reset)) + dm_gpio_free(dev, &priv->gpio_phy_reset); + return 0; }
diff --git a/drivers/net/pch_gbe.h b/drivers/net/pch_gbe.h index 0ea0c73a4f..1d13380837 100644 --- a/drivers/net/pch_gbe.h +++ b/drivers/net/pch_gbe.h @@ -293,6 +293,7 @@ struct pch_gbe_priv { struct udevice *dev; int rx_idx; int tx_idx; + struct gpio_desc gpio_phy_reset; };
#endif /* _PCH_GBE_H_ */

On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
From: Paul Burton paul.burton@imgtec.com
Add support to the pch_gbe driver for resetting the PHY using a GPIO specified in the device tree. This matches the support already in Linux.
Signed-off-by: Paul Burton paul.burton@imgtec.com Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Bin Meng bmeng.cn@gmail.com Tested-by: Bin Meng bmeng.cn@gmail.com
Signed-off-by: Daniel Schwierzeck daniel.schwierzeck@gmail.com
Changes in v2: None
drivers/net/pch_gbe.c | 29 +++++++++++++++++++++++++++-- drivers/net/pch_gbe.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 8866f6632f..cc3ca8b3da 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -12,6 +12,7 @@ #include <asm/io.h> #include <pci.h> #include <miiphy.h> +#include <asm/gpio.h> #include "pch_gbe.h"
#if !defined(CONFIG_PHYLIB) @@ -72,6 +73,14 @@ static int pch_gbe_reset(struct udevice *dev) priv->rx_idx = 0; priv->tx_idx = 0;
if (dm_gpio_is_valid(&priv->gpio_phy_reset)) {
/* Reset the PHY */
dm_gpio_set_value(&priv->gpio_phy_reset, 1);
udelay(15000);
It seems these delays should come from the device tree as well.
Same as: http://www.mail-archive.com/u-boot@lists.denx.de/msg250563.html or here: https://patchwork.ozlabs.org/patch/731278/
dm_gpio_set_value(&priv->gpio_phy_reset, 0);
udelay(5000);
}
writel(PCH_GBE_ALL_RST, &mac_regs->reset); /*
@@ -451,6 +460,11 @@ int pch_gbe_probe(struct udevice *dev) plat->iobase = (ulong)iobase; priv->mac_regs = (struct pch_gbe_regs *)iobase;
err = gpio_request_by_name(dev, "phy-reset-gpios", 0,
&priv->gpio_phy_reset, GPIOD_IS_OUT);
if (err && (err != -ENOENT))
return err;
/* Read MAC address from SROM and initialize dev->enetaddr with it */ pch_gbe_mac_read(priv->mac_regs, plat->enetaddr);
@@ -460,9 +474,17 @@ int pch_gbe_probe(struct udevice *dev)
err = pch_gbe_reset(dev); if (err)
return err;
goto out_err;
return pch_gbe_phy_init(dev);
err = pch_gbe_phy_init(dev);
if (err)
goto out_err;
return 0;
+out_err:
if (dm_gpio_is_valid(&priv->gpio_phy_reset))
dm_gpio_free(dev, &priv->gpio_phy_reset);
return err;
}
int pch_gbe_remove(struct udevice *dev) @@ -473,6 +495,9 @@ int pch_gbe_remove(struct udevice *dev) mdio_unregister(priv->bus); mdio_free(priv->bus);
if (dm_gpio_is_valid(&priv->gpio_phy_reset))
dm_gpio_free(dev, &priv->gpio_phy_reset);
return 0;
}
diff --git a/drivers/net/pch_gbe.h b/drivers/net/pch_gbe.h index 0ea0c73a4f..1d13380837 100644 --- a/drivers/net/pch_gbe.h +++ b/drivers/net/pch_gbe.h @@ -293,6 +293,7 @@ struct pch_gbe_priv { struct udevice *dev; int rx_idx; int tx_idx;
struct gpio_desc gpio_phy_reset;
};
#endif /* _PCH_GBE_H_ */
2.11.0
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

Hi Daniel,
On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
This series is a resend of selected net/pch_gbe patches from the original patch series [1] which was blocked by other patch series. This series only contains the net/pch_gbe patches required for MIPS Boston board, but whose can be separately applied.
[1] https://lists.denx.de/pipermail/u-boot/2016-September/268137.html
Changes in v2:
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() to the next patch as suggested by Bin Meng
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() from the previous patch to this one as suggested by Bin Meng
Paul Burton (5): net: pch_gbe: Reset during probe net: pch_gbe: Fix rx descriptor buffer addresses net: pch_gbe: CPU accessible addresses are virtual net: pch_gbe: Add cache maintenance net: pch_gbe: Support PHY reset GPIOs
This series is assigned to you in patchwork. Does that mean you would like to apply it? If you want me to apply it, please delegate it to me.
Cheers, -Joe
drivers/net/pch_gbe.c | 71 +++++++++++++++++++++++++++++++++++++++++---------- drivers/net/pch_gbe.h | 1 + 2 files changed, 58 insertions(+), 14 deletions(-)
-- 2.11.0
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

Hi Joe,
Am 30.05.2017 um 22:29 schrieb Joe Hershberger:
Hi Daniel,
On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
This series is a resend of selected net/pch_gbe patches from the original patch series [1] which was blocked by other patch series. This series only contains the net/pch_gbe patches required for MIPS Boston board, but whose can be separately applied.
[1] https://lists.denx.de/pipermail/u-boot/2016-September/268137.html
Changes in v2:
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() to the next patch as suggested by Bin Meng
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() from the previous patch to this one as suggested by Bin Meng
Paul Burton (5): net: pch_gbe: Reset during probe net: pch_gbe: Fix rx descriptor buffer addresses net: pch_gbe: CPU accessible addresses are virtual net: pch_gbe: Add cache maintenance net: pch_gbe: Support PHY reset GPIOs
This series is assigned to you in patchwork. Does that mean you would like to apply it? If you want me to apply it, please delegate it to me.
ok, I've delegated patches 1/5 to 4/5 to you. I'll send another version of patch 5/5 which fetches the PHY reset interval from device-tree. But I need some time, so at least the first four patches could be applied. Thanks!

On Wed, May 31, 2017 at 7:45 AM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
Hi Joe,
Am 30.05.2017 um 22:29 schrieb Joe Hershberger:
Hi Daniel,
On Sun, Apr 30, 2017 at 2:57 PM, Daniel Schwierzeck daniel.schwierzeck@gmail.com wrote:
This series is a resend of selected net/pch_gbe patches from the original patch series [1] which was blocked by other patch series. This series only contains the net/pch_gbe patches required for MIPS Boston board, but whose can be separately applied.
[1] https://lists.denx.de/pipermail/u-boot/2016-September/268137.html
Changes in v2:
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() to the next patch as suggested by Bin Meng
- move the switch to dm_pci_virt_to_mem() in pch_gbe_rx_descs_init() from the previous patch to this one as suggested by Bin Meng
Paul Burton (5): net: pch_gbe: Reset during probe net: pch_gbe: Fix rx descriptor buffer addresses net: pch_gbe: CPU accessible addresses are virtual net: pch_gbe: Add cache maintenance net: pch_gbe: Support PHY reset GPIOs
This series is assigned to you in patchwork. Does that mean you would like to apply it? If you want me to apply it, please delegate it to me.
ok, I've delegated patches 1/5 to 4/5 to you. I'll send another version of patch 5/5 which fetches the PHY reset interval from device-tree. But I need some time, so at least the first four patches could be applied. Thanks!
OK, I've sent them to travis for build testing.
https://travis-ci.org/jhershbe/u-boot/builds/237978449 https://travis-ci.org/jhershbe/u-boot/builds/237978597 https://travis-ci.org/jhershbe/u-boot/builds/237978697 https://travis-ci.org/jhershbe/u-boot/builds/237979116
Cheers, -Joe
participants (4)
-
Daniel Schwierzeck
-
Joe Hershberger
-
Joe Hershberger
-
Simon Glass