kernel-5.15/0623-dwmac_baikal-clear-PHY-reset-before-calling-generic-.patch
Mikhail Novosyolov 839b6a86b6 Add support of Baikal-M SoCs
Information about config values was taken from:

From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Thu, 4 Feb 2021 19:35:14 +0400
Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board)

* DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks

* SERIAL_8250_DW=y: serial console

* I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board
  management controller) and RTC (Real Time Clock) are connected
  via I2C.

* GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration

* RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically
  sets the system time from the hardware clock

* TP_BMC=y: amongst other things handles the power button

* DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter

* CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence
  CMA should reserve enough (contiguous) memory.
  Note: CMA reserves memory during very early init, hence the size
  has to be hard-coded into CONFIG

* MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob.
  Note: kernel mode code is GPLv2, so it's fine to distribute it.

* SENSORS_BT1_PVT=m: hardware temperature/voltage sensors

* PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes
  ages (60 seconds or so) to probe the hardware. If compiled in
  substantially increases the boot time, and machine is completely
  unresponsive during probing PCIe. When built as a module probing
  executes concurrently with other boot activities (unless booting
  from a PCIe device)

* STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
2021-06-22 16:35:50 +03:00

60 lines
1.9 KiB
Diff

From b7110f36a3ea12867eabcd5caeb104d23e1a3f4a Mon Sep 17 00:00:00 2001
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
Date: Wed, 24 Feb 2021 16:45:30 +0400
Subject: [PATCH 623/625] dwmac_baikal: clear PHY reset before calling generic
setup routine
Without this attaching to Micrel PHY fails with the following error:
[ 17.596114] Micrel KSZ9031 Gigabit PHY stmmac-2:03: phy_poll_reset failed: -110
[ 17.603602] baikal-dwmac 30250000.eth1 eth1: no phy at addr -1
[ 17.609468] baikal-dwmac 30250000.eth1 eth1: stmmac_open: Cannot attach to PHY (error: -19)
Closes: #39714
---
.../net/ethernet/stmicro/stmmac/dwmac-baikal.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-baikal.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-baikal.c
index 646051cd500d..e706ece9b4f5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-baikal.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-baikal.c
@@ -34,6 +34,14 @@ struct baikal_dwmac {
struct clk *tx2_clk;
};
+static void clear_phy_reset(void __iomem *ioaddr)
+{
+ u32 value;
+ value = readl(ioaddr + MAC_GPIO);
+ value |= MAC_GPIO_GPO0;
+ writel(value, ioaddr + MAC_GPIO);
+}
+
static int baikal_dwmac_dma_reset(void __iomem *ioaddr)
{
int err;
@@ -44,10 +52,7 @@ static int baikal_dwmac_dma_reset(void __iomem *ioaddr)
writel(value, ioaddr + DMA_BUS_MODE);
udelay(10);
- /* Clear PHY reset */
- value = readl(ioaddr + MAC_GPIO);
- value |= MAC_GPIO_GPO0;
- writel(value, ioaddr + MAC_GPIO);
+ clear_phy_reset(ioaddr);
pr_info("PHY re-inited for Baikal DWMAC\n");
err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
@@ -90,6 +95,8 @@ static struct mac_device_info* baikal_dwmac_setup(void *ppriv)
if (!mac)
return NULL;
+ clear_phy_reset(priv->ioaddr);
+
mac->dma = &baikal_dwmac_dma_ops;
old_mac = priv->hw;
priv->hw = mac;
--
2.31.1