mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
Fix z8102ax kernel 6.10 compilation
This commit is contained in:
parent
aa572cfc21
commit
c84e4b5ef4
49 changed files with 328 additions and 10899 deletions
|
@ -8376,5 +8376,22 @@ CONFIG_USB_DEFAULT_AUTHORIZATION_MODE=1
|
|||
# CONFIG_LEDS_KTD202X is not set
|
||||
# CONFIG_LEDS_NCP5623 is not set
|
||||
# CONFIG_AF8133J is not set
|
||||
# CONFIG_PHY_MTK_MIPI_CSI_0_5 is not set
|
||||
# CONFIG_FSCACHE is not set
|
||||
# CONFIG_TEST_FPU is not set
|
||||
# CONFIG_NET_DSA_TAG_VSC73XX_8021Q is not set
|
||||
# CONFIG_PCI_PWRCTL_PWRSEQ is not set
|
||||
# CONFIG_NET_AIROHA is not set
|
||||
# CONFIG_NET_VENDOR_META is not set
|
||||
# CONFIG_SPI_CH341 is not set
|
||||
# CONFIG_GPIO_SLOPPY_LOGIC_ANALYZER is not set
|
||||
# CONFIG_GPIO_VIRTUSER is not set
|
||||
# CONFIG_POWER_SEQUENCING is not set
|
||||
# CONFIG_SENSORS_MP2891 is not set
|
||||
# CONFIG_SENSORS_MP2993 is not set
|
||||
# CONFIG_SENSORS_MP5920 is not set
|
||||
# CONFIG_SENSORS_MP9941 is not set
|
||||
# CONFIG_SENSORS_SPD5118 is not set
|
||||
# CONFIG_CZNIC_PLATFORMS is not set
|
||||
# CONFIG_QCOM_PD_MAPPER is not set
|
||||
# CONFIG_PWM_GPIO is not set
|
||||
# CONFIG_FSCACHE is not set
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
From 880d1311335120f64447ca9d11933872d734e19a Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Mon, 27 Mar 2023 18:41:54 +0100
|
||||
Subject: [PATCH] generic: pcs-mtk-lynxi: add hack to use 2500Base-X without AN
|
||||
|
||||
Using 2500Base-T SFP modules e.g. on the BananaPi R3 requires manually
|
||||
disabling auto-negotiation, e.g. using ethtool. While a proper fix
|
||||
using SFP quirks is being discussed upstream, bring a work-around to
|
||||
restore user experience to what it was before the switch to the
|
||||
dedicated SGMII PCS driver.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/pcs/pcs-mtk-lynxi.c
|
||||
+++ b/drivers/net/pcs/pcs-mtk-lynxi.c
|
||||
@@ -114,14 +114,23 @@ static void mtk_pcs_lynxi_get_state(stru
|
||||
struct phylink_link_state *state)
|
||||
{
|
||||
struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs);
|
||||
- unsigned int bm, adv;
|
||||
+ unsigned int bm, bmsr, adv;
|
||||
|
||||
/* Read the BMSR and LPA */
|
||||
regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm);
|
||||
- regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
|
||||
+ bmsr = FIELD_GET(SGMII_BMSR, bm);
|
||||
+
|
||||
+ if (state->interface == PHY_INTERFACE_MODE_2500BASEX) {
|
||||
+ state->link = !!(bmsr & BMSR_LSTATUS);
|
||||
+ state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE);
|
||||
+ state->speed = SPEED_2500;
|
||||
+ state->duplex = DUPLEX_FULL;
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm),
|
||||
- FIELD_GET(SGMII_LPA, adv));
|
||||
+ regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);
|
||||
+ phylink_mii_c22_pcs_decode_state(state, bmsr, FIELD_GET(SGMII_LPA, adv));
|
||||
}
|
||||
|
||||
static void mtk_sgmii_reset(struct mtk_pcs_lynxi *mpcs)
|
||||
@@ -142,7 +151,7 @@ static int mtk_pcs_lynxi_config(struct p
|
||||
{
|
||||
struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs);
|
||||
bool mode_changed = false, changed;
|
||||
- unsigned int rgc3, sgm_mode, bmcr;
|
||||
+ unsigned int rgc3, sgm_mode, bmcr = 0;
|
||||
int advertise, link_timer;
|
||||
|
||||
advertise = phylink_mii_c22_pcs_encode_advertisement(interface,
|
||||
@@ -165,9 +174,8 @@ static int mtk_pcs_lynxi_config(struct p
|
||||
if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) {
|
||||
if (interface == PHY_INTERFACE_MODE_SGMII)
|
||||
sgm_mode |= SGMII_SPEED_DUPLEX_AN;
|
||||
- bmcr = BMCR_ANENABLE;
|
||||
- } else {
|
||||
- bmcr = 0;
|
||||
+ if (interface != PHY_INTERFACE_MODE_2500BASEX)
|
||||
+ bmcr = BMCR_ANENABLE;
|
||||
}
|
||||
|
||||
if (mpcs->interface != interface) {
|
|
@ -1,81 +0,0 @@
|
|||
From patchwork Thu Feb 6 17:19:41 2020
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Patchwork-Submitter: Daniel Golle <daniel@makrotopia.org>
|
||||
X-Patchwork-Id: 1234465
|
||||
Date: Thu, 6 Feb 2020 19:19:41 +0200
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
To: linux-mtd@lists.infradead.org
|
||||
Subject: [PATCH v2] mtd: spi-nor: Add support for xt25f128b chip
|
||||
Message-ID: <20200206171941.GA2398@makrotopia.org>
|
||||
MIME-Version: 1.0
|
||||
Content-Disposition: inline
|
||||
List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mtd>,
|
||||
<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>
|
||||
Cc: Eitan Cohen <eitan@neot-semadar.com>, Piotr Dymacz <pepe2k@gmail.com>,
|
||||
Tudor Ambarus <tudor.ambarus@microchip.com>
|
||||
Sender: "linux-mtd" <linux-mtd-bounces@lists.infradead.org>
|
||||
Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org
|
||||
|
||||
Add XT25F128B made by XTX Technology (Shenzhen) Limited.
|
||||
This chip supports dual and quad read and uniform 4K-byte erase.
|
||||
Verified on Teltonika RUT955 which comes with XT25F128B in recent
|
||||
versions of the device.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
drivers/mtd/spi-nor/spi-nor.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/spi-nor/Makefile
|
||||
+++ b/drivers/mtd/spi-nor/Makefile
|
||||
@@ -17,6 +17,7 @@ spi-nor-objs += sst.o
|
||||
spi-nor-objs += winbond.o
|
||||
spi-nor-objs += xilinx.o
|
||||
spi-nor-objs += xmc.o
|
||||
+spi-nor-objs += xtx.o
|
||||
spi-nor-$(CONFIG_DEBUG_FS) += debugfs.o
|
||||
obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o
|
||||
|
||||
--- /dev/null
|
||||
+++ b/drivers/mtd/spi-nor/xtx.c
|
||||
@@ -0,0 +1,17 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+#include <linux/mtd/spi-nor.h>
|
||||
+
|
||||
+#include "core.h"
|
||||
+
|
||||
+static const struct flash_info xtx_parts[] = {
|
||||
+ /* XTX Technology (Shenzhen) Limited */
|
||||
+ { "xt25f128b", INFO(0x0B4018, 0, 64 * 1024, 256)
|
||||
+ NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
||||
+ SPI_NOR_QUAD_READ) },
|
||||
+};
|
||||
+
|
||||
+const struct spi_nor_manufacturer spi_nor_xtx = {
|
||||
+ .name = "xtx",
|
||||
+ .parts = xtx_parts,
|
||||
+ .nparts = ARRAY_SIZE(xtx_parts),
|
||||
+};
|
||||
--- a/drivers/mtd/spi-nor/core.c
|
||||
+++ b/drivers/mtd/spi-nor/core.c
|
||||
@@ -2017,6 +2017,7 @@ static const struct spi_nor_manufacturer
|
||||
&spi_nor_winbond,
|
||||
&spi_nor_xilinx,
|
||||
&spi_nor_xmc,
|
||||
+ &spi_nor_xtx,
|
||||
};
|
||||
|
||||
static const struct flash_info spi_nor_generic_flash = {
|
||||
--- a/drivers/mtd/spi-nor/core.h
|
||||
+++ b/drivers/mtd/spi-nor/core.h
|
||||
@@ -647,6 +647,7 @@ extern const struct spi_nor_manufacturer
|
||||
extern const struct spi_nor_manufacturer spi_nor_winbond;
|
||||
extern const struct spi_nor_manufacturer spi_nor_xilinx;
|
||||
extern const struct spi_nor_manufacturer spi_nor_xmc;
|
||||
+extern const struct spi_nor_manufacturer spi_nor_xtx;
|
||||
|
||||
extern const struct attribute_group *spi_nor_sysfs_groups[];
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Subject: ubi: auto-attach mtd device named "ubi" or "data" on boot
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/mtd/ubi/build.c | 36 ++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/ubi/build.c
|
||||
+++ b/drivers/mtd/ubi/build.c
|
||||
@@ -1258,6 +1258,74 @@ static struct mtd_notifier ubi_mtd_notif
|
||||
.remove = ubi_notify_remove,
|
||||
};
|
||||
|
||||
+
|
||||
+/*
|
||||
+ * This function tries attaching mtd partitions named either "ubi" or "data"
|
||||
+ * during boot.
|
||||
+ */
|
||||
+static void __init ubi_auto_attach(void)
|
||||
+{
|
||||
+ int err;
|
||||
+ struct mtd_info *mtd;
|
||||
+ loff_t offset = 0;
|
||||
+ size_t len;
|
||||
+ char magic[4];
|
||||
+
|
||||
+ /* try attaching mtd device named "ubi" or "data" */
|
||||
+ mtd = open_mtd_device("ubi");
|
||||
+ if (IS_ERR(mtd))
|
||||
+ mtd = open_mtd_device("data");
|
||||
+
|
||||
+ if (IS_ERR(mtd))
|
||||
+ return;
|
||||
+
|
||||
+ /* get the first not bad block */
|
||||
+ if (mtd_can_have_bb(mtd))
|
||||
+ while (mtd_block_isbad(mtd, offset)) {
|
||||
+ offset += mtd->erasesize;
|
||||
+
|
||||
+ if (offset > mtd->size) {
|
||||
+ pr_err("UBI error: Failed to find a non-bad "
|
||||
+ "block on mtd%d\n", mtd->index);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* check if the read from flash was successful */
|
||||
+ err = mtd_read(mtd, offset, 4, &len, (void *) magic);
|
||||
+ if ((err && !mtd_is_bitflip(err)) || len != 4) {
|
||||
+ pr_err("UBI error: unable to read from mtd%d\n", mtd->index);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ /* check for a valid ubi magic */
|
||||
+ if (strncmp(magic, "UBI#", 4)) {
|
||||
+ pr_err("UBI error: no valid UBI magic found inside mtd%d\n", mtd->index);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ /* don't auto-add media types where UBI doesn't makes sense */
|
||||
+ if (mtd->type != MTD_NANDFLASH &&
|
||||
+ mtd->type != MTD_NORFLASH &&
|
||||
+ mtd->type != MTD_DATAFLASH &&
|
||||
+ mtd->type != MTD_MLCNANDFLASH)
|
||||
+ goto cleanup;
|
||||
+
|
||||
+ mutex_lock(&ubi_devices_mutex);
|
||||
+ pr_notice("UBI: auto-attach mtd%d\n", mtd->index);
|
||||
+ err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0, false);
|
||||
+ mutex_unlock(&ubi_devices_mutex);
|
||||
+ if (err < 0) {
|
||||
+ pr_err("UBI error: cannot attach mtd%d\n", mtd->index);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+
|
||||
+cleanup:
|
||||
+ put_mtd_device(mtd);
|
||||
+}
|
||||
+
|
||||
static int __init ubi_init_attach(void)
|
||||
{
|
||||
int err, i, k;
|
||||
@@ -1308,6 +1376,12 @@ static int __init ubi_init_attach(void)
|
||||
}
|
||||
}
|
||||
|
||||
+ /* auto-attach mtd devices only if built-in to the kernel and no ubi.mtd
|
||||
+ * parameter was given */
|
||||
+ if (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ !ubi_is_module() && !mtd_devs)
|
||||
+ ubi_auto_attach();
|
||||
+
|
||||
return 0;
|
||||
|
||||
out_detach:
|
File diff suppressed because it is too large
Load diff
|
@ -1,936 +0,0 @@
|
|||
From d5e337e7aecc2e1cc9e96768062610adb95f8f72 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 12 Dec 2023 03:51:14 +0000
|
||||
Subject: [PATCH] net: ethernet: mtk_eth_soc: add paths and SerDes modes for
|
||||
MT7988
|
||||
|
||||
MT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to
|
||||
connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R,
|
||||
2500Base-X, 1000Base-X and Cisco SGMII interface modes.
|
||||
|
||||
Implement support for configuring for the new paths to SerDes interfaces
|
||||
and the internal 2.5G PHY.
|
||||
|
||||
Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and
|
||||
setup the new PHYA on MT7988 to access the also still existing old
|
||||
LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII PCS interface
|
||||
modes.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_path.c | 122 +++++++-
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 292 +++++++++++++++++--
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 107 ++++++-
|
||||
3 files changed, 470 insertions(+), 51 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_path.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_path.c
|
||||
@@ -31,10 +31,20 @@ static const char *mtk_eth_path_name(u64
|
||||
return "gmac2_rgmii";
|
||||
case MTK_ETH_PATH_GMAC2_SGMII:
|
||||
return "gmac2_sgmii";
|
||||
+ case MTK_ETH_PATH_GMAC2_2P5GPHY:
|
||||
+ return "gmac2_2p5gphy";
|
||||
case MTK_ETH_PATH_GMAC2_GEPHY:
|
||||
return "gmac2_gephy";
|
||||
+ case MTK_ETH_PATH_GMAC3_SGMII:
|
||||
+ return "gmac3_sgmii";
|
||||
case MTK_ETH_PATH_GDM1_ESW:
|
||||
return "gdm1_esw";
|
||||
+ case MTK_ETH_PATH_GMAC1_USXGMII:
|
||||
+ return "gmac1_usxgmii";
|
||||
+ case MTK_ETH_PATH_GMAC2_USXGMII:
|
||||
+ return "gmac2_usxgmii";
|
||||
+ case MTK_ETH_PATH_GMAC3_USXGMII:
|
||||
+ return "gmac3_usxgmii";
|
||||
default:
|
||||
return "unknown path";
|
||||
}
|
||||
@@ -127,6 +137,27 @@ static int set_mux_u3_gmac2_to_qphy(stru
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int set_mux_gmac2_to_2p5gphy(struct mtk_eth *eth, u64 path)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ if (path == MTK_ETH_PATH_GMAC2_2P5GPHY) {
|
||||
+ ret = regmap_clear_bits(eth->ethsys, ETHSYS_SYSCFG0, SYSCFG0_SGMII_GMAC2_V2);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Setup mux to 2p5g PHY */
|
||||
+ ret = regmap_clear_bits(eth->infra, TOP_MISC_NETSYS_PCS_MUX, MUX_G2_USXGMII_SEL);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ dev_dbg(eth->dev, "path %s in %s updated\n",
|
||||
+ mtk_eth_path_name(path), __func__);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
@@ -165,7 +196,48 @@ static int set_mux_gmac1_gmac2_to_sgmii_
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
|
||||
+static int set_mux_gmac123_to_usxgmii(struct mtk_eth *eth, u64 path)
|
||||
+{
|
||||
+ unsigned int val = 0;
|
||||
+ bool updated = true;
|
||||
+ int mac_id = 0;
|
||||
+
|
||||
+ /* Disable SYSCFG1 SGMII */
|
||||
+ regmap_read(eth->ethsys, ETHSYS_SYSCFG0, &val);
|
||||
+
|
||||
+ switch (path) {
|
||||
+ case MTK_ETH_PATH_GMAC1_USXGMII:
|
||||
+ val &= ~(u32)SYSCFG0_SGMII_GMAC1_V2;
|
||||
+ mac_id = MTK_GMAC1_ID;
|
||||
+ break;
|
||||
+ case MTK_ETH_PATH_GMAC2_USXGMII:
|
||||
+ val &= ~(u32)SYSCFG0_SGMII_GMAC2_V2;
|
||||
+ mac_id = MTK_GMAC2_ID;
|
||||
+ break;
|
||||
+ case MTK_ETH_PATH_GMAC3_USXGMII:
|
||||
+ val &= ~(u32)SYSCFG0_SGMII_GMAC3_V2;
|
||||
+ mac_id = MTK_GMAC3_ID;
|
||||
+ break;
|
||||
+ default:
|
||||
+ updated = false;
|
||||
+ };
|
||||
+
|
||||
+ if (updated) {
|
||||
+ regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0,
|
||||
+ SYSCFG0_SGMII_MASK, val);
|
||||
+
|
||||
+ if (mac_id == MTK_GMAC2_ID)
|
||||
+ regmap_set_bits(eth->infra, TOP_MISC_NETSYS_PCS_MUX,
|
||||
+ MUX_G2_USXGMII_SEL);
|
||||
+ }
|
||||
+
|
||||
+ dev_dbg(eth->dev, "path %s in %s updated = %d\n",
|
||||
+ mtk_eth_path_name(path), __func__, updated);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int set_mux_gmac123_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
bool updated = true;
|
||||
@@ -182,6 +254,9 @@ static int set_mux_gmac12_to_gephy_sgmii
|
||||
case MTK_ETH_PATH_GMAC2_SGMII:
|
||||
val |= SYSCFG0_SGMII_GMAC2_V2;
|
||||
break;
|
||||
+ case MTK_ETH_PATH_GMAC3_SGMII:
|
||||
+ val |= SYSCFG0_SGMII_GMAC3_V2;
|
||||
+ break;
|
||||
default:
|
||||
updated = false;
|
||||
}
|
||||
@@ -210,13 +285,25 @@ static const struct mtk_eth_muxc mtk_eth
|
||||
.cap_bit = MTK_ETH_MUX_U3_GMAC2_TO_QPHY,
|
||||
.set_path = set_mux_u3_gmac2_to_qphy,
|
||||
}, {
|
||||
+ .name = "mux_gmac2_to_2p5gphy",
|
||||
+ .cap_bit = MTK_ETH_MUX_GMAC2_TO_2P5GPHY,
|
||||
+ .set_path = set_mux_gmac2_to_2p5gphy,
|
||||
+ }, {
|
||||
.name = "mux_gmac1_gmac2_to_sgmii_rgmii",
|
||||
.cap_bit = MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII,
|
||||
.set_path = set_mux_gmac1_gmac2_to_sgmii_rgmii,
|
||||
}, {
|
||||
.name = "mux_gmac12_to_gephy_sgmii",
|
||||
.cap_bit = MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII,
|
||||
- .set_path = set_mux_gmac12_to_gephy_sgmii,
|
||||
+ .set_path = set_mux_gmac123_to_gephy_sgmii,
|
||||
+ }, {
|
||||
+ .name = "mux_gmac123_to_gephy_sgmii",
|
||||
+ .cap_bit = MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII,
|
||||
+ .set_path = set_mux_gmac123_to_gephy_sgmii,
|
||||
+ }, {
|
||||
+ .name = "mux_gmac123_to_usxgmii",
|
||||
+ .cap_bit = MTK_ETH_MUX_GMAC123_TO_USXGMII,
|
||||
+ .set_path = set_mux_gmac123_to_usxgmii,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -249,12 +336,39 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
+int mtk_gmac_usxgmii_path_setup(struct mtk_eth *eth, int mac_id)
|
||||
+{
|
||||
+ u64 path;
|
||||
+
|
||||
+ path = (mac_id == MTK_GMAC1_ID) ? MTK_ETH_PATH_GMAC1_USXGMII :
|
||||
+ (mac_id == MTK_GMAC2_ID) ? MTK_ETH_PATH_GMAC2_USXGMII :
|
||||
+ MTK_ETH_PATH_GMAC3_USXGMII;
|
||||
+
|
||||
+ /* Setup proper MUXes along the path */
|
||||
+ return mtk_eth_mux_setup(eth, path);
|
||||
+}
|
||||
+
|
||||
int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
|
||||
{
|
||||
u64 path;
|
||||
|
||||
- path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_SGMII :
|
||||
- MTK_ETH_PATH_GMAC2_SGMII;
|
||||
+ path = (mac_id == MTK_GMAC1_ID) ? MTK_ETH_PATH_GMAC1_SGMII :
|
||||
+ (mac_id == MTK_GMAC2_ID) ? MTK_ETH_PATH_GMAC2_SGMII :
|
||||
+ MTK_ETH_PATH_GMAC3_SGMII;
|
||||
+
|
||||
+ /* Setup proper MUXes along the path */
|
||||
+ return mtk_eth_mux_setup(eth, path);
|
||||
+}
|
||||
+
|
||||
+int mtk_gmac_2p5gphy_path_setup(struct mtk_eth *eth, int mac_id)
|
||||
+{
|
||||
+ u64 path = 0;
|
||||
+
|
||||
+ if (mac_id == MTK_GMAC2_ID)
|
||||
+ path = MTK_ETH_PATH_GMAC2_2P5GPHY;
|
||||
+
|
||||
+ if (!path)
|
||||
+ return -EINVAL;
|
||||
|
||||
/* Setup proper MUXes along the path */
|
||||
return mtk_eth_mux_setup(eth, path);
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <linux/pinctrl/devinfo.h>
|
||||
#include <linux/phylink.h>
|
||||
#include <linux/pcs/pcs-mtk-lynxi.h>
|
||||
+#include <linux/pcs/pcs-mtk-usxgmii.h>
|
||||
+#include <linux/phy/phy.h>
|
||||
#include <linux/jhash.h>
|
||||
#include <linux/bitfield.h>
|
||||
#include <net/dsa.h>
|
||||
@@ -261,12 +263,8 @@ static const char * const mtk_clks_sourc
|
||||
"ethwarp_wocpu2",
|
||||
"ethwarp_wocpu1",
|
||||
"ethwarp_wocpu0",
|
||||
- "top_usxgmii0_sel",
|
||||
- "top_usxgmii1_sel",
|
||||
"top_sgm0_sel",
|
||||
"top_sgm1_sel",
|
||||
- "top_xfi_phy0_xtal_sel",
|
||||
- "top_xfi_phy1_xtal_sel",
|
||||
"top_eth_gmii_sel",
|
||||
"top_eth_refck_50m_sel",
|
||||
"top_eth_sys_200m_sel",
|
||||
@@ -509,6 +507,30 @@ static void mtk_setup_bridge_switch(stru
|
||||
MTK_GSW_CFG);
|
||||
}
|
||||
|
||||
+static bool mtk_check_gmac23_idle(struct mtk_mac *mac)
|
||||
+{
|
||||
+ u32 mac_fsm, gdm_fsm;
|
||||
+
|
||||
+ mac_fsm = mtk_r32(mac->hw, MTK_MAC_FSM(mac->id));
|
||||
+
|
||||
+ switch (mac->id) {
|
||||
+ case MTK_GMAC2_ID:
|
||||
+ gdm_fsm = mtk_r32(mac->hw, MTK_FE_GDM2_FSM);
|
||||
+ break;
|
||||
+ case MTK_GMAC3_ID:
|
||||
+ gdm_fsm = mtk_r32(mac->hw, MTK_FE_GDM3_FSM);
|
||||
+ break;
|
||||
+ default:
|
||||
+ return true;
|
||||
+ };
|
||||
+
|
||||
+ if ((mac_fsm & 0xFFFF0000) == 0x01010000 &&
|
||||
+ (gdm_fsm & 0xFFFF0000) == 0x00000000)
|
||||
+ return true;
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -517,6 +539,21 @@ static struct phylink_pcs *mtk_mac_selec
|
||||
struct mtk_eth *eth = mac->hw;
|
||||
unsigned int sid;
|
||||
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
+ switch (interface) {
|
||||
+ case PHY_INTERFACE_MODE_1000BASEX:
|
||||
+ case PHY_INTERFACE_MODE_2500BASEX:
|
||||
+ case PHY_INTERFACE_MODE_SGMII:
|
||||
+ return mac->sgmii_pcs;
|
||||
+ case PHY_INTERFACE_MODE_5GBASER:
|
||||
+ case PHY_INTERFACE_MODE_10GBASER:
|
||||
+ case PHY_INTERFACE_MODE_USXGMII:
|
||||
+ return mac->usxgmii_pcs;
|
||||
+ default:
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (interface == PHY_INTERFACE_MODE_SGMII ||
|
||||
phy_interface_mode_is_8023z(interface)) {
|
||||
sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ?
|
||||
@@ -568,7 +605,22 @@ static void mtk_mac_config(struct phylin
|
||||
goto init_err;
|
||||
}
|
||||
break;
|
||||
+ case PHY_INTERFACE_MODE_USXGMII:
|
||||
+ case PHY_INTERFACE_MODE_10GBASER:
|
||||
+ case PHY_INTERFACE_MODE_5GBASER:
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_USXGMII)) {
|
||||
+ err = mtk_gmac_usxgmii_path_setup(eth, mac->id);
|
||||
+ if (err)
|
||||
+ goto init_err;
|
||||
+ }
|
||||
+ break;
|
||||
case PHY_INTERFACE_MODE_INTERNAL:
|
||||
+ if (mac->id == MTK_GMAC2_ID &&
|
||||
+ MTK_HAS_CAPS(eth->soc->caps, MTK_2P5GPHY)) {
|
||||
+ err = mtk_gmac_2p5gphy_path_setup(eth, mac->id);
|
||||
+ if (err)
|
||||
+ goto init_err;
|
||||
+ }
|
||||
break;
|
||||
default:
|
||||
goto err_phy;
|
||||
@@ -615,8 +667,6 @@ static void mtk_mac_config(struct phylin
|
||||
val &= ~SYSCFG0_GE_MODE(SYSCFG0_GE_MASK, mac->id);
|
||||
val |= SYSCFG0_GE_MODE(ge_mode, mac->id);
|
||||
regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val);
|
||||
-
|
||||
- mac->interface = state->interface;
|
||||
}
|
||||
|
||||
/* SGMII */
|
||||
@@ -633,21 +683,40 @@ static void mtk_mac_config(struct phylin
|
||||
|
||||
/* Save the syscfg0 value for mac_finish */
|
||||
mac->syscfg0 = val;
|
||||
- } else if (phylink_autoneg_inband(mode)) {
|
||||
+ } else if (state->interface != PHY_INTERFACE_MODE_USXGMII &&
|
||||
+ state->interface != PHY_INTERFACE_MODE_10GBASER &&
|
||||
+ state->interface != PHY_INTERFACE_MODE_5GBASER &&
|
||||
+ phylink_autoneg_inband(mode)) {
|
||||
dev_err(eth->dev,
|
||||
- "In-band mode not supported in non SGMII mode!\n");
|
||||
+ "In-band mode not supported in non-SerDes modes!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Setup gmac */
|
||||
- if (mtk_is_netsys_v3_or_greater(eth) &&
|
||||
- mac->interface == PHY_INTERFACE_MODE_INTERNAL) {
|
||||
- mtk_w32(mac->hw, MTK_GDMA_XGDM_SEL, MTK_GDMA_EG_CTRL(mac->id));
|
||||
- mtk_w32(mac->hw, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(mac->id));
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
+ if (mtk_interface_mode_is_xgmii(state->interface)) {
|
||||
+ mtk_w32(mac->hw, MTK_GDMA_XGDM_SEL, MTK_GDMA_EG_CTRL(mac->id));
|
||||
+ mtk_w32(mac->hw, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(mac->id));
|
||||
+
|
||||
+ if (mac->id == MTK_GMAC1_ID)
|
||||
+ mtk_setup_bridge_switch(eth);
|
||||
+ } else {
|
||||
+ mtk_w32(eth, 0, MTK_GDMA_EG_CTRL(mac->id));
|
||||
|
||||
- mtk_setup_bridge_switch(eth);
|
||||
+ /* FIXME: In current hardware design, we have to reset FE
|
||||
+ * when swtiching XGDM to GDM. Therefore, here trigger an SER
|
||||
+ * to let GDM go back to the initial state.
|
||||
+ */
|
||||
+ if ((mtk_interface_mode_is_xgmii(mac->interface) ||
|
||||
+ mac->interface == PHY_INTERFACE_MODE_NA) &&
|
||||
+ !mtk_check_gmac23_idle(mac) &&
|
||||
+ !test_bit(MTK_RESETTING, ð->state))
|
||||
+ schedule_work(ð->pending_work);
|
||||
+ }
|
||||
}
|
||||
|
||||
+ mac->interface = state->interface;
|
||||
+
|
||||
return;
|
||||
|
||||
err_phy:
|
||||
@@ -660,6 +729,18 @@ init_err:
|
||||
mac->id, phy_modes(state->interface), err);
|
||||
}
|
||||
|
||||
+static int mtk_mac_prepare(struct phylink_config *config, unsigned int mode,
|
||||
+ phy_interface_t interface)
|
||||
+{
|
||||
+ struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||
+ phylink_config);
|
||||
+
|
||||
+ if (mac->pextp && mac->interface != interface)
|
||||
+ phy_reset(mac->pextp);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -668,6 +749,10 @@ static int mtk_mac_finish(struct phylink
|
||||
struct mtk_eth *eth = mac->hw;
|
||||
u32 mcr_cur, mcr_new;
|
||||
|
||||
+ /* Setup PMA/PMD */
|
||||
+ if (mac->pextp)
|
||||
+ phy_set_mode_ext(mac->pextp, PHY_MODE_ETHERNET, interface);
|
||||
+
|
||||
/* Enable SGMII */
|
||||
if (interface == PHY_INTERFACE_MODE_SGMII ||
|
||||
phy_interface_mode_is_8023z(interface))
|
||||
@@ -692,10 +777,14 @@ static void mtk_mac_link_down(struct phy
|
||||
{
|
||||
struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||
phylink_config);
|
||||
- u32 mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
|
||||
|
||||
- mcr &= ~(MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK);
|
||||
- mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
|
||||
+ if (!mtk_interface_mode_is_xgmii(interface)) {
|
||||
+ mtk_m32(mac->hw, MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK, 0, MTK_MAC_MCR(mac->id));
|
||||
+ if (mtk_is_netsys_v3_or_greater(mac->hw))
|
||||
+ mtk_m32(mac->hw, MTK_XGMAC_FORCE_LINK(mac->id), 0, MTK_XGMAC_STS(mac->id));
|
||||
+ } else if (mtk_is_netsys_v3_or_greater(mac->hw) && mac->id != MTK_GMAC1_ID) {
|
||||
+ mtk_m32(mac->hw, XMAC_MCR_TRX_DISABLE, XMAC_MCR_TRX_DISABLE, MTK_XMAC_MCR(mac->id));
|
||||
+ }
|
||||
}
|
||||
|
||||
static void mtk_set_queue_speed(struct mtk_eth *eth, unsigned int idx,
|
||||
@@ -767,13 +856,11 @@ static void mtk_set_queue_speed(struct m
|
||||
mtk_w32(eth, val, soc->reg_map->qdma.qtx_sch + ofs);
|
||||
}
|
||||
|
||||
-static void mtk_mac_link_up(struct phylink_config *config,
|
||||
- struct phy_device *phy,
|
||||
- unsigned int mode, phy_interface_t interface,
|
||||
- int speed, int duplex, bool tx_pause, bool rx_pause)
|
||||
+static void mtk_gdm_mac_link_up(struct mtk_mac *mac,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex, bool tx_pause, bool rx_pause)
|
||||
{
|
||||
- struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||
- phylink_config);
|
||||
u32 mcr;
|
||||
|
||||
mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
|
||||
@@ -807,9 +894,63 @@ static void mtk_mac_link_up(struct phyli
|
||||
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
|
||||
}
|
||||
|
||||
+static void mtk_xgdm_mac_link_up(struct mtk_mac *mac,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex, bool tx_pause, bool rx_pause)
|
||||
+{
|
||||
+ u32 mcr, force_link = 0;
|
||||
+
|
||||
+ if (mac->id == MTK_GMAC1_ID)
|
||||
+ return;
|
||||
+
|
||||
+ /* Eliminate the interference(before link-up) caused by PHY noise */
|
||||
+ mtk_m32(mac->hw, XMAC_LOGIC_RST, 0, MTK_XMAC_LOGIC_RST(mac->id));
|
||||
+ mdelay(20);
|
||||
+ mtk_m32(mac->hw, XMAC_GLB_CNTCLR, XMAC_GLB_CNTCLR, MTK_XMAC_CNT_CTRL(mac->id));
|
||||
+
|
||||
+ if (mac->interface == PHY_INTERFACE_MODE_INTERNAL || mac->id == MTK_GMAC3_ID)
|
||||
+ force_link = MTK_XGMAC_FORCE_LINK(mac->id);
|
||||
+
|
||||
+ mtk_m32(mac->hw, MTK_XGMAC_FORCE_LINK(mac->id), force_link, MTK_XGMAC_STS(mac->id));
|
||||
+
|
||||
+ mcr = mtk_r32(mac->hw, MTK_XMAC_MCR(mac->id));
|
||||
+ mcr &= ~(XMAC_MCR_FORCE_TX_FC | XMAC_MCR_FORCE_RX_FC | XMAC_MCR_TRX_DISABLE);
|
||||
+ /* Configure pause modes -
|
||||
+ * phylink will avoid these for half duplex
|
||||
+ */
|
||||
+ if (tx_pause)
|
||||
+ mcr |= XMAC_MCR_FORCE_TX_FC;
|
||||
+ if (rx_pause)
|
||||
+ mcr |= XMAC_MCR_FORCE_RX_FC;
|
||||
+
|
||||
+ mtk_w32(mac->hw, mcr, MTK_XMAC_MCR(mac->id));
|
||||
+}
|
||||
+
|
||||
+static void mtk_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex, bool tx_pause, bool rx_pause)
|
||||
+{
|
||||
+ struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||
+ phylink_config);
|
||||
+
|
||||
+ if (mtk_is_netsys_v3_or_greater(mac->hw) && mtk_interface_mode_is_xgmii(interface))
|
||||
+ mtk_xgdm_mac_link_up(mac, phy, mode, interface, speed, duplex,
|
||||
+ tx_pause, rx_pause);
|
||||
+ else
|
||||
+ mtk_gdm_mac_link_up(mac, phy, mode, interface, speed, duplex,
|
||||
+ tx_pause, rx_pause);
|
||||
+
|
||||
+ /* Repeat pextp setup to tune link */
|
||||
+ if (mac->pextp)
|
||||
+ phy_set_mode_ext(mac->pextp, PHY_MODE_ETHERNET, interface);
|
||||
+}
|
||||
+
|
||||
static const struct phylink_mac_ops mtk_phylink_ops = {
|
||||
.mac_select_pcs = mtk_mac_select_pcs,
|
||||
.mac_config = mtk_mac_config,
|
||||
+ .mac_prepare = mtk_mac_prepare,
|
||||
.mac_finish = mtk_mac_finish,
|
||||
.mac_link_down = mtk_mac_link_down,
|
||||
.mac_link_up = mtk_mac_link_up,
|
||||
@@ -3403,6 +3544,9 @@ static int mtk_open(struct net_device *d
|
||||
struct mtk_eth *eth = mac->hw;
|
||||
int i, err;
|
||||
|
||||
+ if (mac->pextp)
|
||||
+ phy_power_on(mac->pextp);
|
||||
+
|
||||
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
|
||||
if (err) {
|
||||
netdev_err(dev, "%s: could not attach PHY: %d\n", __func__,
|
||||
@@ -3532,6 +3676,9 @@ static int mtk_stop(struct net_device *d
|
||||
for (i = 0; i < ARRAY_SIZE(eth->ppe); i++)
|
||||
mtk_ppe_stop(eth->ppe[i]);
|
||||
|
||||
+ if (mac->pextp)
|
||||
+ phy_power_off(mac->pextp);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4529,6 +4676,7 @@ static const struct net_device_ops mtk_n
|
||||
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
||||
{
|
||||
const __be32 *_id = of_get_property(np, "reg", NULL);
|
||||
+ struct device_node *pcs_np;
|
||||
phy_interface_t phy_mode;
|
||||
struct phylink *phylink;
|
||||
struct mtk_mac *mac;
|
||||
@@ -4565,16 +4713,41 @@ static int mtk_add_mac(struct mtk_eth *e
|
||||
mac->id = id;
|
||||
mac->hw = eth;
|
||||
mac->of_node = np;
|
||||
+ pcs_np = of_parse_phandle(mac->of_node, "pcs-handle", 0);
|
||||
+ if (pcs_np) {
|
||||
+ mac->sgmii_pcs = mtk_pcs_lynxi_get(eth->dev, pcs_np);
|
||||
+ if (IS_ERR(mac->sgmii_pcs)) {
|
||||
+ if (PTR_ERR(mac->sgmii_pcs) == -EPROBE_DEFER)
|
||||
+ return -EPROBE_DEFER;
|
||||
|
||||
- err = of_get_ethdev_address(mac->of_node, eth->netdev[id]);
|
||||
- if (err == -EPROBE_DEFER)
|
||||
- return err;
|
||||
+ dev_err(eth->dev, "cannot select SGMII PCS, error %ld\n",
|
||||
+ PTR_ERR(mac->sgmii_pcs));
|
||||
+ return PTR_ERR(mac->sgmii_pcs);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- if (err) {
|
||||
- /* If the mac address is invalid, use random mac address */
|
||||
- eth_hw_addr_random(eth->netdev[id]);
|
||||
- dev_err(eth->dev, "generated random MAC address %pM\n",
|
||||
- eth->netdev[id]->dev_addr);
|
||||
+ pcs_np = of_parse_phandle(mac->of_node, "pcs-handle", 1);
|
||||
+ if (pcs_np) {
|
||||
+ mac->usxgmii_pcs = mtk_usxgmii_pcs_get(eth->dev, pcs_np);
|
||||
+ if (IS_ERR(mac->usxgmii_pcs)) {
|
||||
+ if (PTR_ERR(mac->usxgmii_pcs) == -EPROBE_DEFER)
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ dev_err(eth->dev, "cannot select USXGMII PCS, error %ld\n",
|
||||
+ PTR_ERR(mac->usxgmii_pcs));
|
||||
+ return PTR_ERR(mac->usxgmii_pcs);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth) && (mac->sgmii_pcs || mac->usxgmii_pcs)) {
|
||||
+ mac->pextp = devm_of_phy_get(eth->dev, mac->of_node, NULL);
|
||||
+ if (IS_ERR(mac->pextp)) {
|
||||
+ if (PTR_ERR(mac->pextp) != -EPROBE_DEFER)
|
||||
+ dev_err(eth->dev, "cannot get PHY, error %ld\n",
|
||||
+ PTR_ERR(mac->pextp));
|
||||
+
|
||||
+ return PTR_ERR(mac->pextp);
|
||||
+ }
|
||||
}
|
||||
|
||||
memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
|
||||
@@ -4657,8 +4830,21 @@ static int mtk_add_mac(struct mtk_eth *e
|
||||
phy_interface_zero(mac->phylink_config.supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
+ } else if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_USXGMII)) {
|
||||
+ mac->phylink_config.mac_capabilities |= MAC_5000FD | MAC_10000FD;
|
||||
+ __set_bit(PHY_INTERFACE_MODE_5GBASER,
|
||||
+ mac->phylink_config.supported_interfaces);
|
||||
+ __set_bit(PHY_INTERFACE_MODE_10GBASER,
|
||||
+ mac->phylink_config.supported_interfaces);
|
||||
+ __set_bit(PHY_INTERFACE_MODE_USXGMII,
|
||||
+ mac->phylink_config.supported_interfaces);
|
||||
}
|
||||
|
||||
+ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) &&
|
||||
+ id == MTK_GMAC2_ID)
|
||||
+ __set_bit(PHY_INTERFACE_MODE_INTERNAL,
|
||||
+ mac->phylink_config.supported_interfaces);
|
||||
+
|
||||
phylink = phylink_create(&mac->phylink_config,
|
||||
of_fwnode_handle(mac->of_node),
|
||||
phy_mode, &mtk_phylink_ops);
|
||||
@@ -4709,6 +4895,26 @@ free_netdev:
|
||||
return err;
|
||||
}
|
||||
|
||||
+static int mtk_mac_assign_address(struct mtk_eth *eth, int i, bool test_defer_only)
|
||||
+{
|
||||
+ int err = of_get_ethdev_address(eth->mac[i]->of_node, eth->netdev[i]);
|
||||
+
|
||||
+ if (err == -EPROBE_DEFER)
|
||||
+ return err;
|
||||
+
|
||||
+ if (test_defer_only)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (err) {
|
||||
+ /* If the mac address is invalid, use random mac address */
|
||||
+ eth_hw_addr_random(eth->netdev[i]);
|
||||
+ dev_err(eth->dev, "generated random MAC address %pM\n",
|
||||
+ eth->netdev[i]);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
|
||||
{
|
||||
struct net_device *dev, *tmp;
|
||||
@@ -4855,7 +5061,8 @@ static int mtk_probe(struct platform_dev
|
||||
regmap_write(cci, 0, 3);
|
||||
}
|
||||
|
||||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) {
|
||||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII) &&
|
||||
+ !mtk_is_netsys_v3_or_greater(eth)) {
|
||||
err = mtk_sgmii_init(eth);
|
||||
|
||||
if (err)
|
||||
@@ -4966,6 +5173,24 @@ static int mtk_probe(struct platform_dev
|
||||
}
|
||||
}
|
||||
|
||||
+ for (i = 0; i < MTK_MAX_DEVS; i++) {
|
||||
+ if (!eth->netdev[i])
|
||||
+ continue;
|
||||
+
|
||||
+ err = mtk_mac_assign_address(eth, i, true);
|
||||
+ if (err)
|
||||
+ goto err_deinit_hw;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < MTK_MAX_DEVS; i++) {
|
||||
+ if (!eth->netdev[i])
|
||||
+ continue;
|
||||
+
|
||||
+ err = mtk_mac_assign_address(eth, i, false);
|
||||
+ if (err)
|
||||
+ goto err_deinit_hw;
|
||||
+ }
|
||||
+
|
||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
|
||||
err = devm_request_irq(eth->dev, eth->irq[0],
|
||||
mtk_handle_irq, 0,
|
||||
@@ -5068,6 +5293,11 @@ static int mtk_remove(struct platform_de
|
||||
mtk_stop(eth->netdev[i]);
|
||||
mac = netdev_priv(eth->netdev[i]);
|
||||
phylink_disconnect_phy(mac->phylink);
|
||||
+ if (mac->sgmii_pcs)
|
||||
+ mtk_pcs_lynxi_put(mac->sgmii_pcs);
|
||||
+
|
||||
+ if (mac->usxgmii_pcs)
|
||||
+ mtk_usxgmii_pcs_put(mac->usxgmii_pcs);
|
||||
}
|
||||
|
||||
mtk_wed_exit();
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/u64_stats_sync.h>
|
||||
#include <linux/refcount.h>
|
||||
#include <linux/phylink.h>
|
||||
+#include <linux/reset.h>
|
||||
#include <linux/rhashtable.h>
|
||||
#include <linux/dim.h>
|
||||
#include <linux/bitfield.h>
|
||||
@@ -504,6 +505,21 @@
|
||||
#define INTF_MODE_RGMII_1000 (TRGMII_MODE | TRGMII_CENTRAL_ALIGNED)
|
||||
#define INTF_MODE_RGMII_10_100 0
|
||||
|
||||
+/* XFI Mac control registers */
|
||||
+#define MTK_XMAC_BASE(x) (0x12000 + (((x) - 1) * 0x1000))
|
||||
+#define MTK_XMAC_MCR(x) (MTK_XMAC_BASE(x))
|
||||
+#define XMAC_MCR_TRX_DISABLE 0xf
|
||||
+#define XMAC_MCR_FORCE_TX_FC BIT(5)
|
||||
+#define XMAC_MCR_FORCE_RX_FC BIT(4)
|
||||
+
|
||||
+/* XFI Mac logic reset registers */
|
||||
+#define MTK_XMAC_LOGIC_RST(x) (MTK_XMAC_BASE(x) + 0x10)
|
||||
+#define XMAC_LOGIC_RST BIT(0)
|
||||
+
|
||||
+/* XFI Mac count global control */
|
||||
+#define MTK_XMAC_CNT_CTRL(x) (MTK_XMAC_BASE(x) + 0x100)
|
||||
+#define XMAC_GLB_CNTCLR BIT(0)
|
||||
+
|
||||
/* GPIO port control registers for GMAC 2*/
|
||||
#define GPIO_OD33_CTRL8 0x4c0
|
||||
#define GPIO_BIAS_CTRL 0xed0
|
||||
@@ -529,6 +545,7 @@
|
||||
#define SYSCFG0_SGMII_GMAC2 ((3 << 8) & SYSCFG0_SGMII_MASK)
|
||||
#define SYSCFG0_SGMII_GMAC1_V2 BIT(9)
|
||||
#define SYSCFG0_SGMII_GMAC2_V2 BIT(8)
|
||||
+#define SYSCFG0_SGMII_GMAC3_V2 BIT(7)
|
||||
|
||||
|
||||
/* ethernet subsystem clock register */
|
||||
@@ -567,6 +584,11 @@
|
||||
#define GEPHY_MAC_SEL BIT(1)
|
||||
|
||||
/* Top misc registers */
|
||||
+#define TOP_MISC_NETSYS_PCS_MUX 0x84
|
||||
+#define NETSYS_PCS_MUX_MASK GENMASK(1, 0)
|
||||
+#define MUX_G2_USXGMII_SEL BIT(1)
|
||||
+#define MUX_HSGMII1_G1_SEL BIT(0)
|
||||
+
|
||||
#define USB_PHY_SWITCH_REG 0x218
|
||||
#define QPHY_SEL_MASK GENMASK(1, 0)
|
||||
#define SGMII_QPHY_SEL 0x2
|
||||
@@ -591,6 +613,8 @@
|
||||
#define MT7628_SDM_RBCNT (MT7628_SDM_OFFSET + 0x10c)
|
||||
#define MT7628_SDM_CS_ERR (MT7628_SDM_OFFSET + 0x110)
|
||||
|
||||
+/* Debug Purpose Register */
|
||||
+#define MTK_PSE_FQFC_CFG 0x100
|
||||
#define MTK_FE_CDM1_FSM 0x220
|
||||
#define MTK_FE_CDM2_FSM 0x224
|
||||
#define MTK_FE_CDM3_FSM 0x238
|
||||
@@ -599,6 +623,11 @@
|
||||
#define MTK_FE_CDM6_FSM 0x328
|
||||
#define MTK_FE_GDM1_FSM 0x228
|
||||
#define MTK_FE_GDM2_FSM 0x22C
|
||||
+#define MTK_FE_GDM3_FSM 0x23C
|
||||
+#define MTK_FE_PSE_FREE 0x240
|
||||
+#define MTK_FE_DROP_FQ 0x244
|
||||
+#define MTK_FE_DROP_FC 0x248
|
||||
+#define MTK_FE_DROP_PPE 0x24C
|
||||
|
||||
#define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100))
|
||||
|
||||
@@ -723,12 +752,8 @@ enum mtk_clks_map {
|
||||
MTK_CLK_ETHWARP_WOCPU2,
|
||||
MTK_CLK_ETHWARP_WOCPU1,
|
||||
MTK_CLK_ETHWARP_WOCPU0,
|
||||
- MTK_CLK_TOP_USXGMII_SBUS_0_SEL,
|
||||
- MTK_CLK_TOP_USXGMII_SBUS_1_SEL,
|
||||
MTK_CLK_TOP_SGM_0_SEL,
|
||||
MTK_CLK_TOP_SGM_1_SEL,
|
||||
- MTK_CLK_TOP_XFI_PHY_0_XTAL_SEL,
|
||||
- MTK_CLK_TOP_XFI_PHY_1_XTAL_SEL,
|
||||
MTK_CLK_TOP_ETH_GMII_SEL,
|
||||
MTK_CLK_TOP_ETH_REFCK_50M_SEL,
|
||||
MTK_CLK_TOP_ETH_SYS_200M_SEL,
|
||||
@@ -799,19 +824,9 @@ enum mtk_clks_map {
|
||||
BIT_ULL(MTK_CLK_GP3) | BIT_ULL(MTK_CLK_XGP1) | \
|
||||
BIT_ULL(MTK_CLK_XGP2) | BIT_ULL(MTK_CLK_XGP3) | \
|
||||
BIT_ULL(MTK_CLK_CRYPTO) | \
|
||||
- BIT_ULL(MTK_CLK_SGMII_TX_250M) | \
|
||||
- BIT_ULL(MTK_CLK_SGMII_RX_250M) | \
|
||||
- BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \
|
||||
- BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \
|
||||
BIT_ULL(MTK_CLK_ETHWARP_WOCPU2) | \
|
||||
BIT_ULL(MTK_CLK_ETHWARP_WOCPU1) | \
|
||||
BIT_ULL(MTK_CLK_ETHWARP_WOCPU0) | \
|
||||
- BIT_ULL(MTK_CLK_TOP_USXGMII_SBUS_0_SEL) | \
|
||||
- BIT_ULL(MTK_CLK_TOP_USXGMII_SBUS_1_SEL) | \
|
||||
- BIT_ULL(MTK_CLK_TOP_SGM_0_SEL) | \
|
||||
- BIT_ULL(MTK_CLK_TOP_SGM_1_SEL) | \
|
||||
- BIT_ULL(MTK_CLK_TOP_XFI_PHY_0_XTAL_SEL) | \
|
||||
- BIT_ULL(MTK_CLK_TOP_XFI_PHY_1_XTAL_SEL) | \
|
||||
BIT_ULL(MTK_CLK_TOP_ETH_GMII_SEL) | \
|
||||
BIT_ULL(MTK_CLK_TOP_ETH_REFCK_50M_SEL) | \
|
||||
BIT_ULL(MTK_CLK_TOP_ETH_SYS_200M_SEL) | \
|
||||
@@ -945,6 +960,8 @@ enum mkt_eth_capabilities {
|
||||
MTK_RGMII_BIT = 0,
|
||||
MTK_TRGMII_BIT,
|
||||
MTK_SGMII_BIT,
|
||||
+ MTK_USXGMII_BIT,
|
||||
+ MTK_2P5GPHY_BIT,
|
||||
MTK_ESW_BIT,
|
||||
MTK_GEPHY_BIT,
|
||||
MTK_MUX_BIT,
|
||||
@@ -965,8 +982,11 @@ enum mkt_eth_capabilities {
|
||||
MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT,
|
||||
MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY_BIT,
|
||||
MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT,
|
||||
+ MTK_ETH_MUX_GMAC2_TO_2P5GPHY_BIT,
|
||||
MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT,
|
||||
MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT,
|
||||
+ MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII_BIT,
|
||||
+ MTK_ETH_MUX_GMAC123_TO_USXGMII_BIT,
|
||||
|
||||
/* PATH BITS */
|
||||
MTK_ETH_PATH_GMAC1_RGMII_BIT,
|
||||
@@ -974,14 +994,21 @@ enum mkt_eth_capabilities {
|
||||
MTK_ETH_PATH_GMAC1_SGMII_BIT,
|
||||
MTK_ETH_PATH_GMAC2_RGMII_BIT,
|
||||
MTK_ETH_PATH_GMAC2_SGMII_BIT,
|
||||
+ MTK_ETH_PATH_GMAC2_2P5GPHY_BIT,
|
||||
MTK_ETH_PATH_GMAC2_GEPHY_BIT,
|
||||
+ MTK_ETH_PATH_GMAC3_SGMII_BIT,
|
||||
MTK_ETH_PATH_GDM1_ESW_BIT,
|
||||
+ MTK_ETH_PATH_GMAC1_USXGMII_BIT,
|
||||
+ MTK_ETH_PATH_GMAC2_USXGMII_BIT,
|
||||
+ MTK_ETH_PATH_GMAC3_USXGMII_BIT,
|
||||
};
|
||||
|
||||
/* Supported hardware group on SoCs */
|
||||
#define MTK_RGMII BIT_ULL(MTK_RGMII_BIT)
|
||||
#define MTK_TRGMII BIT_ULL(MTK_TRGMII_BIT)
|
||||
#define MTK_SGMII BIT_ULL(MTK_SGMII_BIT)
|
||||
+#define MTK_USXGMII BIT_ULL(MTK_USXGMII_BIT)
|
||||
+#define MTK_2P5GPHY BIT_ULL(MTK_2P5GPHY_BIT)
|
||||
#define MTK_ESW BIT_ULL(MTK_ESW_BIT)
|
||||
#define MTK_GEPHY BIT_ULL(MTK_GEPHY_BIT)
|
||||
#define MTK_MUX BIT_ULL(MTK_MUX_BIT)
|
||||
@@ -1004,10 +1031,16 @@ enum mkt_eth_capabilities {
|
||||
BIT_ULL(MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY_BIT)
|
||||
#define MTK_ETH_MUX_U3_GMAC2_TO_QPHY \
|
||||
BIT_ULL(MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT)
|
||||
+#define MTK_ETH_MUX_GMAC2_TO_2P5GPHY \
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC2_TO_2P5GPHY_BIT)
|
||||
#define MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII \
|
||||
BIT_ULL(MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT)
|
||||
#define MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII \
|
||||
BIT_ULL(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT)
|
||||
+#define MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII \
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII_BIT)
|
||||
+#define MTK_ETH_MUX_GMAC123_TO_USXGMII \
|
||||
+ BIT_ULL(MTK_ETH_MUX_GMAC123_TO_USXGMII_BIT)
|
||||
|
||||
/* Supported path present on SoCs */
|
||||
#define MTK_ETH_PATH_GMAC1_RGMII BIT_ULL(MTK_ETH_PATH_GMAC1_RGMII_BIT)
|
||||
@@ -1015,8 +1048,13 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_ETH_PATH_GMAC1_SGMII BIT_ULL(MTK_ETH_PATH_GMAC1_SGMII_BIT)
|
||||
#define MTK_ETH_PATH_GMAC2_RGMII BIT_ULL(MTK_ETH_PATH_GMAC2_RGMII_BIT)
|
||||
#define MTK_ETH_PATH_GMAC2_SGMII BIT_ULL(MTK_ETH_PATH_GMAC2_SGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC2_2P5GPHY BIT_ULL(MTK_ETH_PATH_GMAC2_2P5GPHY_BIT)
|
||||
#define MTK_ETH_PATH_GMAC2_GEPHY BIT_ULL(MTK_ETH_PATH_GMAC2_GEPHY_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC3_SGMII BIT_ULL(MTK_ETH_PATH_GMAC3_SGMII_BIT)
|
||||
#define MTK_ETH_PATH_GDM1_ESW BIT_ULL(MTK_ETH_PATH_GDM1_ESW_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC1_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC1_USXGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC2_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC2_USXGMII_BIT)
|
||||
+#define MTK_ETH_PATH_GMAC3_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC3_USXGMII_BIT)
|
||||
|
||||
#define MTK_GMAC1_RGMII (MTK_ETH_PATH_GMAC1_RGMII | MTK_RGMII)
|
||||
#define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII)
|
||||
@@ -1024,7 +1062,12 @@ enum mkt_eth_capabilities {
|
||||
#define MTK_GMAC2_RGMII (MTK_ETH_PATH_GMAC2_RGMII | MTK_RGMII)
|
||||
#define MTK_GMAC2_SGMII (MTK_ETH_PATH_GMAC2_SGMII | MTK_SGMII)
|
||||
#define MTK_GMAC2_GEPHY (MTK_ETH_PATH_GMAC2_GEPHY | MTK_GEPHY)
|
||||
+#define MTK_GMAC2_2P5GPHY (MTK_ETH_PATH_GMAC2_2P5GPHY | MTK_2P5GPHY)
|
||||
+#define MTK_GMAC3_SGMII (MTK_ETH_PATH_GMAC3_SGMII | MTK_SGMII)
|
||||
#define MTK_GDM1_ESW (MTK_ETH_PATH_GDM1_ESW | MTK_ESW)
|
||||
+#define MTK_GMAC1_USXGMII (MTK_ETH_PATH_GMAC1_USXGMII | MTK_USXGMII)
|
||||
+#define MTK_GMAC2_USXGMII (MTK_ETH_PATH_GMAC2_USXGMII | MTK_USXGMII)
|
||||
+#define MTK_GMAC3_USXGMII (MTK_ETH_PATH_GMAC3_USXGMII | MTK_USXGMII)
|
||||
|
||||
/* MUXes present on SoCs */
|
||||
/* 0: GDM1 -> GMAC1, 1: GDM1 -> ESW */
|
||||
@@ -1043,10 +1086,20 @@ enum mkt_eth_capabilities {
|
||||
(MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII | MTK_MUX | \
|
||||
MTK_SHARED_SGMII)
|
||||
|
||||
+/* 2: GMAC2 -> XGMII */
|
||||
+#define MTK_MUX_GMAC2_TO_2P5GPHY \
|
||||
+ (MTK_ETH_MUX_GMAC2_TO_2P5GPHY | MTK_MUX | MTK_INFRA)
|
||||
+
|
||||
/* 0: GMACx -> GEPHY, 1: GMACx -> SGMII where x is 1 or 2 */
|
||||
#define MTK_MUX_GMAC12_TO_GEPHY_SGMII \
|
||||
(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII | MTK_MUX)
|
||||
|
||||
+#define MTK_MUX_GMAC123_TO_GEPHY_SGMII \
|
||||
+ (MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII | MTK_MUX)
|
||||
+
|
||||
+#define MTK_MUX_GMAC123_TO_USXGMII \
|
||||
+ (MTK_ETH_MUX_GMAC123_TO_USXGMII | MTK_MUX | MTK_INFRA)
|
||||
+
|
||||
#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x))
|
||||
|
||||
#define MT7621_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \
|
||||
@@ -1078,8 +1131,12 @@ enum mkt_eth_capabilities {
|
||||
MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
|
||||
MTK_RSTCTRL_PPE1 | MTK_SRAM)
|
||||
|
||||
-#define MT7988_CAPS (MTK_36BIT_DMA | MTK_GDM1_ESW | MTK_QDMA | \
|
||||
- MTK_RSTCTRL_PPE1 | MTK_RSTCTRL_PPE2 | MTK_SRAM)
|
||||
+#define MT7988_CAPS (MTK_36BIT_DMA | MTK_GDM1_ESW | MTK_GMAC1_SGMII | \
|
||||
+ MTK_GMAC2_2P5GPHY | MTK_GMAC2_SGMII | MTK_GMAC2_USXGMII | \
|
||||
+ MTK_GMAC3_SGMII | MTK_GMAC3_USXGMII | \
|
||||
+ MTK_MUX_GMAC123_TO_GEPHY_SGMII | \
|
||||
+ MTK_MUX_GMAC123_TO_USXGMII | MTK_MUX_GMAC2_TO_2P5GPHY | \
|
||||
+ MTK_QDMA | MTK_RSTCTRL_PPE1 | MTK_RSTCTRL_PPE2 | MTK_SRAM)
|
||||
|
||||
struct mtk_tx_dma_desc_info {
|
||||
dma_addr_t addr;
|
||||
@@ -1322,6 +1379,9 @@ struct mtk_mac {
|
||||
struct device_node *of_node;
|
||||
struct phylink *phylink;
|
||||
struct phylink_config phylink_config;
|
||||
+ struct phylink_pcs *sgmii_pcs;
|
||||
+ struct phylink_pcs *usxgmii_pcs;
|
||||
+ struct phy *pextp;
|
||||
struct mtk_eth *hw;
|
||||
struct mtk_hw_stats *hw_stats;
|
||||
__be32 hwlro_ip[MTK_MAX_LRO_IP_CNT];
|
||||
@@ -1445,6 +1505,19 @@ static inline u32 mtk_get_ib2_multicast_
|
||||
return MTK_FOE_IB2_MULTICAST;
|
||||
}
|
||||
|
||||
+static inline bool mtk_interface_mode_is_xgmii(phy_interface_t interface)
|
||||
+{
|
||||
+ switch (interface) {
|
||||
+ case PHY_INTERFACE_MODE_INTERNAL:
|
||||
+ case PHY_INTERFACE_MODE_USXGMII:
|
||||
+ case PHY_INTERFACE_MODE_10GBASER:
|
||||
+ case PHY_INTERFACE_MODE_5GBASER:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* read the hardware status register */
|
||||
void mtk_stats_update_mac(struct mtk_mac *mac);
|
||||
|
||||
@@ -1453,8 +1526,10 @@ u32 mtk_r32(struct mtk_eth *eth, unsigne
|
||||
u32 mtk_m32(struct mtk_eth *eth, u32 mask, u32 set, unsigned int reg);
|
||||
|
||||
int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id);
|
||||
+int mtk_gmac_2p5gphy_path_setup(struct mtk_eth *eth, int mac_id);
|
||||
int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id);
|
||||
int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id);
|
||||
+int mtk_gmac_usxgmii_path_setup(struct mtk_eth *eth, int mac_id);
|
||||
|
||||
int mtk_eth_offload_init(struct mtk_eth *eth);
|
||||
int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|
@ -1,147 +0,0 @@
|
|||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Subject: libata: add ledtrig support
|
||||
|
||||
This adds a LED trigger for each ATA port indicating disk activity.
|
||||
|
||||
As this is needed only on specific platforms (NAS SoCs and such),
|
||||
these platforms should define ARCH_WANTS_LIBATA_LEDS if there
|
||||
are boards with LED(s) intended to indicate ATA disk activity and
|
||||
need the OS to take care of that.
|
||||
In that way, if not selected, LED trigger support not will be
|
||||
included in libata-core and both, codepaths and structures remain
|
||||
untouched.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/ata/Kconfig | 16 ++++++++++++++++
|
||||
drivers/ata/libata-core.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
||||
include/linux/libata.h | 9 +++++++++
|
||||
3 files changed, 66 insertions(+)
|
||||
|
||||
--- a/drivers/ata/Kconfig
|
||||
+++ b/drivers/ata/Kconfig
|
||||
@@ -67,6 +67,22 @@ config ATA_FORCE
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
+config ARCH_WANT_LIBATA_LEDS
|
||||
+ bool
|
||||
+
|
||||
+config ATA_LEDS
|
||||
+ bool "support ATA port LED triggers"
|
||||
+ depends on ARCH_WANT_LIBATA_LEDS
|
||||
+ select NEW_LEDS
|
||||
+ select LEDS_CLASS
|
||||
+ select LEDS_TRIGGERS
|
||||
+ default y
|
||||
+ help
|
||||
+ This option adds a LED trigger for each registered ATA port.
|
||||
+ It is used to drive disk activity leds connected via GPIO.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
config ATA_ACPI
|
||||
bool "ATA ACPI Support"
|
||||
depends on ACPI
|
||||
--- a/drivers/ata/libata-core.c
|
||||
+++ b/drivers/ata/libata-core.c
|
||||
@@ -685,6 +685,17 @@ static inline void ata_set_tf_cdl(struct
|
||||
qc->flags |= ATA_QCFLAG_HAS_CDL | ATA_QCFLAG_RESULT_TF;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+#define LIBATA_BLINK_DELAY 20 /* ms */
|
||||
+static inline void ata_led_act(struct ata_port *ap)
|
||||
+{
|
||||
+ if (unlikely(!ap->ledtrig))
|
||||
+ return;
|
||||
+
|
||||
+ led_trigger_blink_oneshot(ap->ledtrig, LIBATA_BLINK_DELAY, LIBATA_BLINK_DELAY, 0);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/**
|
||||
* ata_build_rw_tf - Build ATA taskfile for given read/write request
|
||||
* @qc: Metadata associated with the taskfile to build
|
||||
@@ -4771,6 +4782,9 @@ void __ata_qc_complete(struct ata_queued
|
||||
link->active_tag = ATA_TAG_POISON;
|
||||
ap->nr_active_links--;
|
||||
}
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+ ata_led_act(ap);
|
||||
+#endif
|
||||
|
||||
/* clear exclusive status */
|
||||
if (unlikely(qc->flags & ATA_QCFLAG_CLEAR_EXCL &&
|
||||
@@ -5494,6 +5508,9 @@ struct ata_port *ata_port_alloc(struct a
|
||||
ap->stats.unhandled_irq = 1;
|
||||
ap->stats.idle_irq = 1;
|
||||
#endif
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+ ap->ledtrig = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
|
||||
+#endif
|
||||
ata_sff_port_init(ap);
|
||||
|
||||
return ap;
|
||||
@@ -5530,6 +5547,12 @@ static void ata_host_release(struct kref
|
||||
kfree(ap->pmp_link);
|
||||
kfree(ap->slave_link);
|
||||
kfree(ap->ncq_sense_buf);
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+ if (ap->ledtrig) {
|
||||
+ led_trigger_unregister(ap->ledtrig);
|
||||
+ kfree(ap->ledtrig);
|
||||
+ };
|
||||
+#endif
|
||||
kfree(ap);
|
||||
host->ports[i] = NULL;
|
||||
}
|
||||
@@ -5920,7 +5943,23 @@ int ata_host_register(struct ata_host *h
|
||||
host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
|
||||
host->ports[i]->local_port_no = i + 1;
|
||||
}
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+ for (i = 0; i < host->n_ports; i++) {
|
||||
+ if (unlikely(!host->ports[i]->ledtrig))
|
||||
+ continue;
|
||||
|
||||
+ snprintf(host->ports[i]->ledtrig_name,
|
||||
+ sizeof(host->ports[i]->ledtrig_name), "ata%u",
|
||||
+ host->ports[i]->print_id);
|
||||
+
|
||||
+ host->ports[i]->ledtrig->name = host->ports[i]->ledtrig_name;
|
||||
+
|
||||
+ if (led_trigger_register(host->ports[i]->ledtrig)) {
|
||||
+ kfree(host->ports[i]->ledtrig);
|
||||
+ host->ports[i]->ledtrig = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
/* Create associated sysfs transport objects */
|
||||
for (i = 0; i < host->n_ports; i++) {
|
||||
rc = ata_tport_add(host->dev,host->ports[i]);
|
||||
--- a/include/linux/libata.h
|
||||
+++ b/include/linux/libata.h
|
||||
@@ -23,6 +23,9 @@
|
||||
#include <linux/cdrom.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/async.h>
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+#include <linux/leds.h>
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* Define if arch has non-standard setup. This is a _PCI_ standard
|
||||
@@ -875,6 +878,12 @@ struct ata_port {
|
||||
#ifdef CONFIG_ATA_ACPI
|
||||
struct ata_acpi_gtm __acpi_init_gtm; /* use ata_acpi_init_gtm() */
|
||||
#endif
|
||||
+
|
||||
+#ifdef CONFIG_ATA_LEDS
|
||||
+ struct led_trigger *ledtrig;
|
||||
+ char ledtrig_name[8];
|
||||
+#endif
|
||||
+
|
||||
/* owned by EH */
|
||||
u8 *ncq_sense_buf;
|
||||
u8 sector_buf[ATA_SECT_SIZE] ____cacheline_aligned;
|
Loading…
Add table
Add a link
Reference in a new issue