From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sascha Hauer <s.hauer@pengutronix.de>,
Russell King <rmk+kernel@armlinux.org.uk>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 17/40] net: ethernet: mvneta: Fix Serdes configuration for SoCs without comphy
Date: Wed, 1 Jul 2020 21:23:38 -0400 [thread overview]
Message-ID: <20200702012402.2701121-17-sashal@kernel.org> (raw)
In-Reply-To: <20200702012402.2701121-1-sashal@kernel.org>
From: Sascha Hauer <s.hauer@pengutronix.de>
[ Upstream commit b4748553f53f2971e07d2619f13d461daac0f3bb ]
The MVNETA_SERDES_CFG register is only available on older SoCs like the
Armada XP. On newer SoCs like the Armada 38x the fields are moved to
comphy. This patch moves the writes to this register next to the comphy
initialization, so that depending on the SoC either comphy or
MVNETA_SERDES_CFG is configured.
With this we no longer write to the MVNETA_SERDES_CFG on SoCs where it
doesn't exist.
Suggested-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/marvell/mvneta.c | 80 +++++++++++++++------------
1 file changed, 44 insertions(+), 36 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index a10ae28ebc8aa..b0599b205b36e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -104,6 +104,7 @@
#define MVNETA_TX_IN_PRGRS BIT(1)
#define MVNETA_TX_FIFO_EMPTY BIT(8)
#define MVNETA_RX_MIN_FRAME_SIZE 0x247c
+/* Only exists on Armada XP and Armada 370 */
#define MVNETA_SERDES_CFG 0x24A0
#define MVNETA_SGMII_SERDES_PROTO 0x0cc7
#define MVNETA_QSGMII_SERDES_PROTO 0x0667
@@ -3164,26 +3165,55 @@ static int mvneta_setup_txqs(struct mvneta_port *pp)
return 0;
}
-static int mvneta_comphy_init(struct mvneta_port *pp)
+static int mvneta_comphy_init(struct mvneta_port *pp, phy_interface_t interface)
{
int ret;
- if (!pp->comphy)
- return 0;
-
- ret = phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET,
- pp->phy_interface);
+ ret = phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET, interface);
if (ret)
return ret;
return phy_power_on(pp->comphy);
}
+static int mvneta_config_interface(struct mvneta_port *pp,
+ phy_interface_t interface)
+{
+ int ret = 0;
+
+ if (pp->comphy) {
+ if (interface == PHY_INTERFACE_MODE_SGMII ||
+ interface == PHY_INTERFACE_MODE_1000BASEX ||
+ interface == PHY_INTERFACE_MODE_2500BASEX) {
+ ret = mvneta_comphy_init(pp, interface);
+ }
+ } else {
+ switch (interface) {
+ case PHY_INTERFACE_MODE_QSGMII:
+ mvreg_write(pp, MVNETA_SERDES_CFG,
+ MVNETA_QSGMII_SERDES_PROTO);
+ break;
+
+ case PHY_INTERFACE_MODE_SGMII:
+ case PHY_INTERFACE_MODE_1000BASEX:
+ mvreg_write(pp, MVNETA_SERDES_CFG,
+ MVNETA_SGMII_SERDES_PROTO);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ pp->phy_interface = interface;
+
+ return ret;
+}
+
static void mvneta_start_dev(struct mvneta_port *pp)
{
int cpu;
- WARN_ON(mvneta_comphy_init(pp));
+ WARN_ON(mvneta_config_interface(pp, pp->phy_interface));
mvneta_max_rx_size_set(pp, pp->pkt_size);
mvneta_txq_max_tx_size_set(pp, pp->pkt_size);
@@ -3561,14 +3591,10 @@ static void mvneta_mac_config(struct phylink_config *config, unsigned int mode,
if (state->speed == SPEED_2500)
new_ctrl4 |= MVNETA_GMAC4_SHORT_PREAMBLE_ENABLE;
- if (pp->comphy && pp->phy_interface != state->interface &&
- (state->interface == PHY_INTERFACE_MODE_SGMII ||
- state->interface == PHY_INTERFACE_MODE_1000BASEX ||
- state->interface == PHY_INTERFACE_MODE_2500BASEX)) {
- pp->phy_interface = state->interface;
-
- WARN_ON(phy_power_off(pp->comphy));
- WARN_ON(mvneta_comphy_init(pp));
+ if (pp->phy_interface != state->interface) {
+ if (pp->comphy)
+ WARN_ON(phy_power_off(pp->comphy));
+ WARN_ON(mvneta_config_interface(pp, state->interface));
}
if (new_ctrl0 != gmac_ctrl0)
@@ -4464,20 +4490,10 @@ static void mvneta_conf_mbus_windows(struct mvneta_port *pp,
}
/* Power up the port */
-static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
+static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
{
/* MAC Cause register should be cleared */
mvreg_write(pp, MVNETA_UNIT_INTR_CAUSE, 0);
-
- if (phy_mode == PHY_INTERFACE_MODE_QSGMII)
- mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_QSGMII_SERDES_PROTO);
- else if (phy_mode == PHY_INTERFACE_MODE_SGMII ||
- phy_interface_mode_is_8023z(phy_mode))
- mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
- else if (!phy_interface_mode_is_rgmii(phy_mode))
- return -EINVAL;
-
- return 0;
}
/* Device initialization routine */
@@ -4661,11 +4677,7 @@ static int mvneta_probe(struct platform_device *pdev)
if (err < 0)
goto err_netdev;
- err = mvneta_port_power_up(pp, phy_mode);
- if (err < 0) {
- dev_err(&pdev->dev, "can't power up port\n");
- goto err_netdev;
- }
+ mvneta_port_power_up(pp, phy_mode);
/* Armada3700 network controller does not support per-cpu
* operation, so only single NAPI should be initialized.
@@ -4818,11 +4830,7 @@ static int mvneta_resume(struct device *device)
}
}
mvneta_defaults_set(pp);
- err = mvneta_port_power_up(pp, pp->phy_interface);
- if (err < 0) {
- dev_err(device, "can't power up port\n");
- return err;
- }
+ mvneta_port_power_up(pp, pp->phy_interface);
netif_device_attach(dev);
--
2.25.1
next prev parent reply other threads:[~2020-07-02 1:33 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 1:23 [PATCH AUTOSEL 5.4 01/40] regmap: fix alignment issue Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 02/40] perf/x86/rapl: Move RAPL support to common x86 code Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 03/40] perf/x86/rapl: Fix RAPL config variable bug Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 04/40] ARM: dts: omap4-droid4: Fix spi configuration and increase rate Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 05/40] drm/ttm: Fix dma_fence refcnt leak when adding move fence Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 06/40] drm/tegra: hub: Do not enable orphaned window group Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 07/40] gpu: host1x: Detach driver on unregister Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 08/40] btrfs: use kfree() in btrfs_ioctl_get_subvol_info() Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 09/40] drm: mcde: Fix display initialization problem Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 10/40] ASoC: SOF: Intel: add PCI ID for CometLake-S Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 11/40] ASoC: SOF: Intel: add PCI IDs for ICL-H and TGL-H Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 12/40] net: usb: ax88179_178a: fix packet alignment padding Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 13/40] ALSA: hda: Intel: add missing PCI IDs for ICL-H, TGL-H and EKL Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 14/40] usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 15/40] spi: spidev: fix a race between spidev_release and spidev_remove Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 16/40] spi: spidev: fix a potential use-after-free in spidev_release() Sasha Levin
2020-07-02 1:23 ` Sasha Levin [this message]
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 18/40] net: ethernet: mvneta: Add 2500BaseX support for SoCs without comphy Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 19/40] tg3: driver sleeps indefinitely when EEH errors exceed eeh_max_freezes Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 20/40] ixgbe: protect ring accesses with READ- and WRITE_ONCE Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 21/40] i40e: " Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 22/40] ibmvnic: continue to init in CRQ reset returns H_CLOSED Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 23/40] powerpc/kvm/book3s64: Fix kernel crash with nested kvm & DEBUG_VIRTUAL Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 24/40] usbnet: smsc95xx: Fix use-after-free after removal Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 25/40] iommu/vt-d: Don't apply gfx quirks to untrusted devices Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 26/40] drm: panel-orientation-quirks: Add quirk for Asus T101HA panel Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 27/40] drm: panel-orientation-quirks: Use generic orientation-data for Acer S1003 Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 28/40] s390/kasan: fix early pgm check handler execution Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 29/40] s390/debug: avoid kernel warning on too large number of pages Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 30/40] cifs: Fix double add page to memcg when cifs_readpages Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 31/40] drm/sun4i: mixer: Call of_dma_configure if there's an IOMMU Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 32/40] cifs: update ctime and mtime during truncate Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 33/40] ARM: imx6: add missing put_device() call in imx6q_suspend_init() Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 34/40] scsi: mptscsih: Fix read sense data size Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 35/40] usb: dwc3: pci: Fix reference count leak in dwc3_pci_resume_work Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 36/40] block: release bip in a right way in error path Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 37/40] nvme-rdma: assign completion vector correctly Sasha Levin
2020-07-02 1:23 ` [PATCH AUTOSEL 5.4 38/40] x86/entry: Increase entry_stack size to a full page Sasha Levin
2020-07-02 1:24 ` [PATCH AUTOSEL 5.4 39/40] kgdb: Avoid suspicious RCU usage warning Sasha Levin
2020-07-02 1:24 ` [PATCH AUTOSEL 5.4 40/40] sched/core: Check cpus_mask, not cpus_ptr in __set_cpus_allowed_ptr(), to fix mask corruption Sasha Levin
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=20200702012402.2701121-17-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=s.hauer@pengutronix.de \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).