--- a/init/Kconfig
+++ b/init/Kconfig
-@@ -1534,6 +1534,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
- the unaligned access emulation.
- see arch/parisc/kernel/unaligned.c for reference
+@@ -1625,6 +1625,17 @@ config SYSFS_SYSCALL
+
+ If unsure say N here.
+config KALLSYMS_UNCOMPRESSED
+ bool "Keep kallsyms uncompressed"
* and return the first char from this token. If MSB of length
--- a/kernel/vmcore_info.c
+++ b/kernel/vmcore_info.c
-@@ -214,8 +214,10 @@ static int __init crash_save_vmcoreinfo_
+@@ -218,8 +218,10 @@ static int __init crash_save_vmcoreinfo_
#ifdef CONFIG_KALLSYMS
VMCOREINFO_SYMBOL(kallsyms_names);
VMCOREINFO_SYMBOL(kallsyms_num_syms);
#endif /* CONFIG_KALLSYMS */
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
-@@ -62,6 +62,7 @@ static struct addr_range percpu_range =
+@@ -57,6 +57,7 @@ static struct addr_range text_ranges[] =
static struct sym_entry **table;
static unsigned int table_size, table_cnt;
static int all_symbols;
+static int uncompressed;
- static int absolute_percpu;
static int token_profit[0x10000];
-@@ -412,13 +413,17 @@ static void write_src(void)
+
+@@ -399,13 +400,17 @@ static void write_src(void)
for (k = 0; k < table[i]->len; k++)
printf(", 0x%02x", table[i]->sym[k]);
}
printf("\n");
-@@ -429,20 +434,22 @@ static void write_src(void)
+@@ -416,20 +421,22 @@ static void write_src(void)
free(markers);
output_label("kallsyms_offsets");
-@@ -532,6 +539,9 @@ static unsigned char *find_token(unsigne
+@@ -508,6 +515,9 @@ static unsigned char *find_token(unsigne
{
int i;
for (i = 0; i < len - 1; i++) {
if (str[i] == token[0] && str[i+1] == token[1])
return &str[i];
-@@ -604,6 +614,9 @@ static void optimize_result(void)
+@@ -580,6 +590,9 @@ static void optimize_result(void)
{
int i, best;
/* using the '\0' symbol last allows compress_symbols to use standard
* fast string functions */
for (i = 255; i >= 0; i--) {
-@@ -763,6 +776,7 @@ int main(int argc, char **argv)
+@@ -717,6 +730,7 @@ int main(int argc, char **argv)
+ while (1) {
static const struct option long_options[] = {
{"all-symbols", no_argument, &all_symbols, 1},
- {"absolute-percpu", no_argument, &absolute_percpu, 1},
+ {"uncompressed", no_argument, &uncompressed, 1},
{},
};
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
-@@ -144,6 +144,10 @@ kallsyms()
- kallsymopt="${kallsymopt} --absolute-percpu"
+@@ -142,6 +142,10 @@ kallsyms()
+ kallsymopt="${kallsymopt} --all-symbols"
fi
+ if is_enabled CONFIG_KALLSYMS_UNCOMPRESSED; then
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
-@@ -167,8 +167,7 @@ static const struct spinand_info macroni
- &update_cache_variants),
+@@ -187,7 +187,6 @@ static const struct spinand_info macroni
SPINAND_HAS_QE_BIT,
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
-- macronix_ecc_get_status),
-- SPINAND_CONT_READ(macronix_set_cont_read)),
-+ macronix_ecc_get_status)),
+ macronix_ecc_get_status),
+- SPINAND_CONT_READ(macronix_set_cont_read),
+ SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
+ macronix_set_read_retry)),
SPINAND_INFO("MX35LF4GE4AD",
- SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x37, 0x03),
- NAND_MEMORG(1, 4096, 128, 64, 2048, 40, 1, 1, 1),
-@@ -178,8 +177,7 @@ static const struct spinand_info macroni
- &update_cache_variants),
+@@ -200,7 +199,6 @@ static const struct spinand_info macroni
SPINAND_HAS_QE_BIT,
SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
-- macronix_ecc_get_status),
-- SPINAND_CONT_READ(macronix_set_cont_read)),
-+ macronix_ecc_get_status)),
+ macronix_ecc_get_status),
+- SPINAND_CONT_READ(macronix_set_cont_read),
+ SPINAND_READ_RETRY(MACRONIX_NUM_READ_RETRY_MODES,
+ macronix_set_read_retry)),
SPINAND_INFO("MX35LF1G24AD",
- SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14, 0x03),
- NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
-@@ -1,4 +1,4 @@
+@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
--spinand-objs := core.o alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o
+ spinand-objs := core.o otp.o
+-spinand-objs += alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o
-spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o
-+spinand-objs := core.o alliancememory.o ato.o esmt.o etron.o fmsh.o foresee.o gigadevice.o
++spinand-objs += alliancememory.o ato.o esmt.o etron.o fmsh.o foresee.o gigadevice.o
+spinand-objs += macronix.o micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o
obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
-@@ -1186,6 +1186,7 @@ static const struct spinand_manufacturer
+@@ -1237,6 +1237,7 @@ static const struct spinand_manufacturer
&ato_spinand_manufacturer,
&esmt_8c_spinand_manufacturer,
&esmt_c8_spinand_manufacturer,
+
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
-+ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),
-+ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
-+ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
-+ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
-+ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
-+ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
++ SPINAND_PAGE_READ_FROM_CACHE_1S_4S_4S_OP(0, 1, NULL, 0, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_1S_2S_2S_OP(0, 1, NULL, 0, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_FAST_1S_1S_1S_OP(0, 1, NULL, 0, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
-+ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
-+ SPINAND_PROG_LOAD(true, 0, NULL, 0));
++ SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0),
++ SPINAND_PROG_LOAD_1S_1S_1S_OP(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
-+ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
-+ SPINAND_PROG_LOAD(false, 0, NULL, 0));
++ SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
++ SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
+
+static int etron_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+};
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
-@@ -264,6 +264,7 @@ extern const struct spinand_manufacturer
+@@ -356,6 +356,7 @@ extern const struct spinand_manufacturer
extern const struct spinand_manufacturer ato_spinand_manufacturer;
extern const struct spinand_manufacturer esmt_8c_spinand_manufacturer;
extern const struct spinand_manufacturer esmt_c8_spinand_manufacturer;
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <unistd.h>
-+ #include <string.h>
++ #include <linux/string.h>
+ #include <asm/types.h>
+ #include <errno.h>
+ #include <linux/jffs2.h>
+ #define STATIC
+#endif
+
-+#include "lzma/LzmaDec.h"
-+#include "lzma/LzmaEnc.h"
++#include <linux/lzma/LzmaDec.h>
++#include <linux/lzma/LzmaEnc.h>
+
+#define LZMA_BEST_LEVEL (9)
+#define LZMA_BEST_LC (0)
+#endif
--- /dev/null
+++ b/include/linux/lzma/Types.h
-@@ -0,0 +1,226 @@
+@@ -0,0 +1,227 @@
+/* Types.h -- Basic types
+2009-11-23 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_TYPES_H
+#define __7Z_TYPES_H
+
-+#include <stddef.h>
++#include <linux/types.h>
++#include <linux/stddef.h>
+
+#ifdef _WIN32
+#include <windows.h>
#define JFFS2_NODE_ACCURATE 0x2000
--- a/lib/Kconfig
+++ b/lib/Kconfig
-@@ -353,6 +353,12 @@ config ZSTD_DECOMPRESS
+@@ -216,6 +216,12 @@ config ZSTD_DECOMPRESS
source "lib/xz/Kconfig"
# ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
--- a/lib/Makefile
+++ b/lib/Makefile
-@@ -126,6 +126,16 @@ CFLAGS_kobject.o += -DDEBUG
+@@ -117,6 +117,16 @@ CFLAGS_kobject.o += -DDEBUG
CFLAGS_kobject_uevent.o += -DDEBUG
endif
obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
-@@ -185,6 +195,8 @@ obj-$(CONFIG_ZSTD_COMPRESS) += zstd/
+@@ -165,6 +175,8 @@ obj-$(CONFIG_ZSTD_COMPRESS) += zstd/
obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd/
obj-$(CONFIG_XZ_DEC) += xz/
obj-$(CONFIG_RAID6_PQ) += raid6/
+/* LzFind.c -- Match finder for LZ algorithms
+2009-04-22 : Igor Pavlov : Public domain */
+
-+#include <string.h>
++#include <linux/string.h>
+
-+#include "LzFind.h"
-+#include "LzHash.h"
++#include <linux/lzma/LzFind.h>
++#include <linux/lzma/LzHash.h>
+
+#define kEmptyHashValue 0
+#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
+/* LzmaDec.c -- LZMA Decoder
+2009-09-20 : Igor Pavlov : Public domain */
+
-+#include "LzmaDec.h"
++#include <linux/lzma/LzmaDec.h>
+
-+#include <string.h>
++#include <linux/string.h>
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+/* LzmaEnc.c -- LZMA Encoder
+2009-11-24 : Igor Pavlov : Public domain */
+
-+#include <string.h>
++#include <linux/string.h>
+
+/* #define SHOW_STAT */
+/* #define SHOW_STAT2 */
+#include <stdio.h>
+#endif
+
-+#include "LzmaEnc.h"
++#include <linux/lzma/LzmaEnc.h>
+
+/* disable MT */
+#define _7ZIP_ST
+
-+#include "LzFind.h"
++#include <linux/lzma/LzFind.h>
+#ifndef _7ZIP_ST
+#include "LzFindMt.h"
+#endif
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
-@@ -111,7 +111,7 @@ static void dummy_setup(struct net_devic
+@@ -113,7 +113,7 @@ static void dummy_setup(struct net_devic
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
dev->lltx = true;
dev->features |= NETIF_F_SG | NETIF_F_FRAGLIST;
dev->hw_features |= dev->features;
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
-@@ -174,7 +174,7 @@ static void gen_lo_setup(struct net_devi
+@@ -175,7 +175,7 @@ static void gen_lo_setup(struct net_devi
dev->lltx = true;
- dev->netns_local = true;
+ dev->netns_immutable = true;
netif_keep_dst(dev);
- dev->hw_features = NETIF_F_GSO_SOFTWARE;
+ dev->hw_features = NETIF_F_GSO_SOFTWARE_ALL;
| NETIF_F_HW_CSUM
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
-@@ -903,7 +903,7 @@ static int macvlan_hwtstamp_set(struct n
+@@ -904,7 +904,7 @@ static int macvlan_hwtstamp_set(struct n
static struct lock_class_key macvlan_netdev_addr_lock_key;
#define ALWAYS_ON_OFFLOADS \
#define ALWAYS_ON_FEATURES ALWAYS_ON_OFFLOADS
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
-@@ -211,13 +211,14 @@ static inline int find_next_netdev_featu
-
+@@ -213,13 +213,14 @@ static inline int find_next_netdev_featu
/* List of features with software fallbacks. */
- #define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | NETIF_F_GSO_SCTP | \
+ #define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | \
+ NETIF_F_GSO_ACCECN | NETIF_F_GSO_SCTP | \
- NETIF_F_GSO_UDP_L4 | NETIF_F_GSO_FRAGLIST)
+ NETIF_F_GSO_UDP_L4)
+#define NETIF_F_GSO_SOFTWARE_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_FRAGLIST)
if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK))
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
-@@ -538,7 +538,7 @@ static int vlan_dev_init(struct net_devi
+@@ -537,7 +537,7 @@ static int vlan_dev_init(struct net_devi
dev->state |= (1 << __LINK_STATE_NOCARRIER);
dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG |
NETIF_F_GSO_ENCAP_ALL |
NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC |
NETIF_F_FCOE_CRC | NETIF_F_FSO;
-@@ -634,7 +634,7 @@ static netdev_features_t vlan_dev_fix_fe
+@@ -633,7 +633,7 @@ static netdev_features_t vlan_dev_fix_fe
if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
lower_features |= NETIF_F_HW_CSUM;
features = netdev_intersect_features(features, lower_features);
}
--- a/net/core/sock.c
+++ b/net/core/sock.c
-@@ -2557,7 +2557,7 @@ void sk_setup_caps(struct sock *sk, stru
+@@ -2620,7 +2620,7 @@ void sk_setup_caps(struct sock *sk, stru
icsk->icsk_ack.dst_quick_ack = dst_metric(dst, RTAX_QUICKACK);
}
if (sk->sk_route_caps & NETIF_F_GSO)
if (sk_can_gso(sk)) {
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
-@@ -2023,7 +2023,7 @@ void ieee80211_color_collision_detection
+@@ -2083,7 +2083,7 @@ void ieee80211_color_collision_detection
/* interface handling */
#define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
NETIF_F_HW_CSUM | NETIF_F_SG | \
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
-@@ -8724,7 +8724,7 @@ static int nft_register_flowtable_net_ho
- err = flowtable->data.type->setup(&flowtable->data,
- hook->ops.dev,
- FLOW_BLOCK_BIND);
-- if (err < 0)
-+ if (err < 0 && err != -EOPNOTSUPP)
- goto err_unregister_net_hooks;
+@@ -9091,7 +9091,7 @@ static int nft_register_flowtable_ops(st
- err = nf_register_net_hook(net, &hook->ops);
+ err = flowtable->data.type->setup(&flowtable->data,
+ ops->dev, FLOW_BLOCK_BIND);
+- if (err < 0)
++ if (err < 0 && err != -EOPNOTSUPP)
+ return err;
+
+ err = nf_register_net_hook(net, ops);
u16 vid)
{
+ const unsigned char *dest = eth_hdr(skb)->h_dest;
+ enum skb_drop_reason reason = SKB_DROP_REASON_NO_TX_TARGET;
struct net_bridge_port *prev = NULL;
struct net_bridge_port *p;
-
-@@ -219,6 +220,10 @@ void br_flood(struct net_bridge *br, str
+@@ -220,6 +221,10 @@ void br_flood(struct net_bridge *br, str
case BR_PKT_MULTICAST:
if (!(p->flags & BR_MCAST_FLOOD) && skb->dev != br->dev)
continue;
if (!(p->flags & BR_BCAST_FLOOD) && skb->dev != br->dev)
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
-@@ -368,6 +368,8 @@ static rx_handler_result_t br_handle_fra
+@@ -384,6 +384,8 @@ static rx_handler_result_t br_handle_fra
fwd_mask |= p->group_fwd_mask;
switch (dest[5]) {
case 0x00: /* Bridge Group Address */
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
-@@ -1094,6 +1094,7 @@ enum {
+@@ -1098,6 +1098,7 @@ enum {
IFLA_BRPORT_MCAST_MAX_GROUPS,
IFLA_BRPORT_NEIGH_VLAN_SUPPRESS,
IFLA_BRPORT_BACKUP_NHID,
(!(p->flags & BR_PORT_LOCKED) || !(p->flags & BR_LEARNING))) {
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
-@@ -62,7 +62,7 @@
+@@ -63,7 +63,7 @@
#include "dev.h"
#define RTNL_MAX_TYPE 50
struct rtnl_link {
rtnl_doit_func doit;
-@@ -5009,7 +5009,9 @@ int ndo_dflt_bridge_getlink(struct sk_bu
+@@ -5295,7 +5295,9 @@ int ndo_dflt_bridge_getlink(struct sk_bu
brport_nla_put_flag(skb, flags, mask,
IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD) ||
brport_nla_put_flag(skb, flags, mask,
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -43,6 +43,11 @@ MODULE_PARM_DESC(msg_level, "Message lev
+@@ -44,6 +44,11 @@ MODULE_PARM_DESC(msg_level, "Message lev
offsetof(struct mtk_hw_stats, xdp_stats.x) / \
sizeof(u64) }
static const struct mtk_reg_map mtk_reg_map = {
.tx_irq_mask = 0x1a1c,
.tx_irq_status = 0x1a18,
-@@ -1160,14 +1165,14 @@ static int mtk_init_fq_dma(struct mtk_et
- eth->scratch_ring = eth->sram_base;
- else
- eth->scratch_ring = dma_alloc_coherent(eth->dma_dev,
-- cnt * soc->tx.desc_size,
-+ TX_DESC_OFS(eth, cnt),
- ð->phy_scratch_ring,
- GFP_KERNEL);
+@@ -1306,13 +1311,13 @@ static int mtk_init_fq_dma(struct mtk_et
+ dma_addr_t dma_addr;
+ int i, j, len;
+
+- eth->scratch_ring = mtk_dma_ring_alloc(eth, cnt * soc->tx.desc_size,
++ eth->scratch_ring = mtk_dma_ring_alloc(eth, TX_DESC_OFS(eth, cnt),
+ ð->phy_scratch_ring, true);
if (unlikely(!eth->scratch_ring))
return -ENOMEM;
for (j = 0; j < DIV_ROUND_UP(soc->tx.fq_dma_size, MTK_FQ_DMA_LENGTH); j++) {
len = min_t(int, cnt - j * MTK_FQ_DMA_LENGTH, MTK_FQ_DMA_LENGTH);
-@@ -1186,11 +1191,11 @@ static int mtk_init_fq_dma(struct mtk_et
+@@ -1331,11 +1336,11 @@ static int mtk_init_fq_dma(struct mtk_et
for (i = 0; i < len; i++) {
struct mtk_tx_dma_v2 *txd;
txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE);
if (MTK_HAS_CAPS(soc->caps, MTK_36BIT_DMA))
-@@ -1220,9 +1225,9 @@ static void *mtk_qdma_phys_to_virt(struc
+@@ -1365,9 +1370,9 @@ static void *mtk_qdma_phys_to_virt(struc
}
static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring,
return &ring->buf[idx];
}
-@@ -1233,9 +1238,9 @@ static struct mtk_tx_dma *qdma_to_pdma(s
+@@ -1378,9 +1383,9 @@ static struct mtk_tx_dma *qdma_to_pdma(s
return ring->dma_pdma - (struct mtk_tx_dma *)ring->dma + dma;
}
}
static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
-@@ -1443,7 +1448,7 @@ static int mtk_tx_map(struct sk_buff *sk
+@@ -1588,7 +1593,7 @@ static int mtk_tx_map(struct sk_buff *sk
if (itxd == ring->last_free)
return -ENOMEM;
memset(itx_buf, 0, sizeof(*itx_buf));
txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size,
-@@ -1497,7 +1502,7 @@ static int mtk_tx_map(struct sk_buff *sk
+@@ -1642,7 +1647,7 @@ static int mtk_tx_map(struct sk_buff *sk
mtk_tx_set_dma_desc(dev, txd, &txd_info);
tx_buf = mtk_desc_to_tx_buf(ring, txd,
if (new_desc)
memset(tx_buf, 0, sizeof(*tx_buf));
tx_buf->data = (void *)MTK_DMA_DUMMY_DESC;
-@@ -1540,7 +1545,7 @@ static int mtk_tx_map(struct sk_buff *sk
+@@ -1685,7 +1690,7 @@ static int mtk_tx_map(struct sk_buff *sk
} else {
int next_idx;
ring->dma_size);
mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0);
}
-@@ -1549,7 +1554,7 @@ static int mtk_tx_map(struct sk_buff *sk
+@@ -1694,7 +1699,7 @@ static int mtk_tx_map(struct sk_buff *sk
err_dma:
do {
/* unmap dma */
mtk_tx_unmap(eth, tx_buf, NULL, false);
-@@ -1723,7 +1728,7 @@ static struct mtk_rx_ring *mtk_get_rx_ri
+@@ -1868,7 +1873,7 @@ static struct mtk_rx_ring *mtk_get_rx_ri
ring = ð->rx_ring[i];
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
if (rxd->rxd2 & RX_DMA_DONE) {
ring->calc_idx_update = true;
return ring;
-@@ -1891,7 +1896,7 @@ static int mtk_xdp_submit_frame(struct m
+@@ -2036,7 +2041,7 @@ static int mtk_xdp_submit_frame(struct m
}
htxd = txd;
memset(tx_buf, 0, sizeof(*tx_buf));
htx_buf = tx_buf;
-@@ -1910,7 +1915,7 @@ static int mtk_xdp_submit_frame(struct m
+@@ -2055,7 +2060,7 @@ static int mtk_xdp_submit_frame(struct m
goto unmap;
tx_buf = mtk_desc_to_tx_buf(ring, txd,
memset(tx_buf, 0, sizeof(*tx_buf));
n_desc++;
}
-@@ -1948,7 +1953,7 @@ static int mtk_xdp_submit_frame(struct m
+@@ -2093,7 +2098,7 @@ static int mtk_xdp_submit_frame(struct m
} else {
int idx;
mtk_w32(eth, NEXT_DESP_IDX(idx, ring->dma_size),
MT7628_TX_CTX_IDX0);
}
-@@ -1959,7 +1964,7 @@ static int mtk_xdp_submit_frame(struct m
+@@ -2104,7 +2109,7 @@ static int mtk_xdp_submit_frame(struct m
unmap:
while (htxd != txd) {
mtk_tx_unmap(eth, tx_buf, NULL, false);
htxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
-@@ -2091,7 +2096,7 @@ static int mtk_poll_rx(struct napi_struc
+@@ -2236,7 +2241,7 @@ static int mtk_poll_rx(struct napi_struc
goto rx_done;
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
data = ring->data[idx];
if (!mtk_rx_get_desc(eth, &trxd, rxd))
-@@ -2355,7 +2360,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
+@@ -2503,7 +2508,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
break;
tx_buf = mtk_desc_to_tx_buf(ring, desc,
if (!tx_buf->data)
break;
-@@ -2406,7 +2411,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
+@@ -2554,7 +2559,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
}
mtk_tx_unmap(eth, tx_buf, &bq, true);
ring->last_free = desc;
atomic_inc(&ring->free_count);
-@@ -2524,7 +2529,7 @@ static int mtk_tx_alloc(struct mtk_eth *
+@@ -2672,7 +2677,7 @@ static int mtk_tx_alloc(struct mtk_eth *
{
const struct mtk_soc_data *soc = eth->soc;
struct mtk_tx_ring *ring = ð->tx_ring;
struct mtk_tx_dma_v2 *txd;
int ring_size;
u32 ofs, val;
-@@ -2571,7 +2576,7 @@ static int mtk_tx_alloc(struct mtk_eth *
+@@ -2712,7 +2717,7 @@ static int mtk_tx_alloc(struct mtk_eth *
* descriptors in ring->dma_pdma.
*/
if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) {
&ring->phys_pdma, GFP_KERNEL);
if (!ring->dma_pdma)
goto no_tx_mem;
-@@ -2586,7 +2591,7 @@ static int mtk_tx_alloc(struct mtk_eth *
+@@ -2727,7 +2732,7 @@ static int mtk_tx_alloc(struct mtk_eth *
atomic_set(&ring->free_count, ring_size - 2);
ring->next_free = ring->dma;
ring->last_free = (void *)txd;
ring->thresh = MAX_SKB_FRAGS;
/* make sure that all changes to the dma ring are flushed before we
-@@ -2598,7 +2603,7 @@ static int mtk_tx_alloc(struct mtk_eth *
+@@ -2739,7 +2744,7 @@ static int mtk_tx_alloc(struct mtk_eth *
mtk_w32(eth, ring->phys, soc->reg_map->qdma.ctx_ptr);
mtk_w32(eth, ring->phys, soc->reg_map->qdma.dtx_ptr);
mtk_w32(eth,
soc->reg_map->qdma.crx_ptr);
mtk_w32(eth, ring->last_free_ptr, soc->reg_map->qdma.drx_ptr);
-@@ -2647,14 +2652,14 @@ static void mtk_tx_clean(struct mtk_eth
+@@ -2776,7 +2781,6 @@ no_tx_mem:
+
+ static void mtk_tx_clean(struct mtk_eth *eth)
+ {
+- const struct mtk_soc_data *soc = eth->soc;
+ struct mtk_tx_ring *ring = ð->tx_ring;
+ int i;
+
+@@ -2788,14 +2792,14 @@ static void mtk_tx_clean(struct mtk_eth
}
- if (!MTK_HAS_CAPS(soc->caps, MTK_SRAM) && ring->dma) {
- dma_free_coherent(eth->dma_dev,
-- ring->dma_size * soc->tx.desc_size,
-+ TX_DESC_OFS(eth, ring->dma_size),
- ring->dma, ring->phys);
+
+ if (ring->dma) {
+- mtk_dma_ring_free(eth, ring->dma_size * soc->tx.desc_size,
++ mtk_dma_ring_free(eth, TX_DESC_OFS(eth, ring->dma_size),
+ ring->dma, ring->phys, true);
ring->dma = NULL;
}
ring->dma_pdma, ring->phys_pdma);
ring->dma_pdma = NULL;
}
-@@ -2710,15 +2715,13 @@ static int mtk_rx_alloc(struct mtk_eth *
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SRAM) ||
- rx_flag != MTK_RX_FLAGS_NORMAL) {
- ring->dma = dma_alloc_coherent(eth->dma_dev,
-- rx_dma_size * eth->soc->rx.desc_size,
-+ RX_DESC_OFS(eth, rx_dma_size),
- &ring->phys, GFP_KERNEL);
- } else {
- struct mtk_tx_ring *tx_ring = ð->tx_ring;
-
-- ring->dma = tx_ring->dma + tx_ring_size *
-- eth->soc->tx.desc_size * (ring_no + 1);
-- ring->phys = tx_ring->phys + tx_ring_size *
-- eth->soc->tx.desc_size * (ring_no + 1);
-+ ring->dma = tx_ring->dma + TX_DESC_OFS(eth, tx_ring_size * (ring_no + 1));
-+ ring->phys = tx_ring->phys + TX_DESC_OFS(eth, tx_ring_size * (ring_no + 1));
+@@ -2844,7 +2848,7 @@ static int mtk_rx_alloc(struct mtk_eth *
}
+ ring->dma = mtk_dma_ring_alloc(eth,
+- rx_dma_size * eth->soc->rx.desc_size,
++ RX_DESC_OFS(eth, rx_dma_size),
+ &ring->phys,
+ rx_flag == MTK_RX_FLAGS_NORMAL);
if (!ring->dma)
-@@ -2729,7 +2732,7 @@ static int mtk_rx_alloc(struct mtk_eth *
+@@ -2855,7 +2859,7 @@ static int mtk_rx_alloc(struct mtk_eth *
dma_addr_t dma_addr;
void *data;
if (ring->page_pool) {
data = mtk_page_pool_get_buff(ring->page_pool,
&dma_addr, GFP_KERNEL);
-@@ -2820,7 +2823,7 @@ static void mtk_rx_clean(struct mtk_eth
+@@ -2946,7 +2950,7 @@ static void mtk_rx_clean(struct mtk_eth
if (!ring->data[i])
continue;
if (!rxd->rxd1)
continue;
-@@ -2837,7 +2840,7 @@ static void mtk_rx_clean(struct mtk_eth
+@@ -2962,7 +2966,7 @@ static void mtk_rx_clean(struct mtk_eth
+ }
- if (!in_sram && ring->dma) {
- dma_free_coherent(eth->dma_dev,
-- ring->dma_size * eth->soc->rx.desc_size,
-+ RX_DESC_OFS(eth, ring->dma_size),
- ring->dma, ring->phys);
+ if (ring->dma) {
+- mtk_dma_ring_free(eth, ring->dma_size * eth->soc->rx.desc_size,
++ mtk_dma_ring_free(eth, RX_DESC_OFS(eth, ring->dma_size),
+ ring->dma, ring->phys, in_sram);
ring->dma = NULL;
}
-@@ -3208,7 +3211,7 @@ static void mtk_dma_free(struct mtk_eth
+@@ -3332,7 +3336,7 @@ static void mtk_dma_free(struct mtk_eth
+ }
- if (!MTK_HAS_CAPS(soc->caps, MTK_SRAM) && eth->scratch_ring) {
- dma_free_coherent(eth->dma_dev,
-- MTK_QDMA_RING_SIZE * soc->tx.desc_size,
-+ TX_DESC_OFS(eth, MTK_QDMA_RING_SIZE),
- eth->scratch_ring, eth->phy_scratch_ring);
+ if (eth->scratch_ring) {
+- mtk_dma_ring_free(eth, soc->tx.fq_dma_size * soc->tx.desc_size,
++ mtk_dma_ring_free(eth, TX_DESC_OFS(eth, soc->tx.fq_dma_size),
+ eth->scratch_ring, eth->phy_scratch_ring,
+ true);
eth->scratch_ring = NULL;
- eth->phy_scratch_ring = 0;
-@@ -5245,6 +5248,9 @@ static void mtk_remove(struct platform_d
+@@ -5386,6 +5390,9 @@ static void mtk_remove(struct platform_d
mtk_mdio_cleanup(eth);
}
static const struct mtk_soc_data mt2701_data = {
.reg_map = &mtk_reg_map,
.caps = MT7623_CAPS | MTK_HWLRO,
-@@ -5253,14 +5259,14 @@ static const struct mtk_soc_data mt2701_
+@@ -5394,14 +5401,14 @@ static const struct mtk_soc_data mt2701_
.required_pctl = true,
.version = 1,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_size = MTK_DMA_SIZE(2K),
-@@ -5281,14 +5287,14 @@ static const struct mtk_soc_data mt7621_
+@@ -5422,14 +5429,14 @@ static const struct mtk_soc_data mt7621_
.hash_offset = 2,
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_size = MTK_DMA_SIZE(2K),
-@@ -5311,14 +5317,14 @@ static const struct mtk_soc_data mt7622_
+@@ -5452,14 +5459,14 @@ static const struct mtk_soc_data mt7622_
.has_accounting = true,
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_size = MTK_DMA_SIZE(2K),
-@@ -5340,14 +5346,14 @@ static const struct mtk_soc_data mt7623_
+@@ -5481,14 +5488,14 @@ static const struct mtk_soc_data mt7623_
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
.disable_pll_modes = true,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_size = MTK_DMA_SIZE(2K),
-@@ -5366,14 +5372,14 @@ static const struct mtk_soc_data mt7629_
+@@ -5507,14 +5514,14 @@ static const struct mtk_soc_data mt7629_
.has_accounting = true,
.version = 1,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_size = MTK_DMA_SIZE(2K),
-@@ -5396,14 +5402,14 @@ static const struct mtk_soc_data mt7981_
+@@ -5537,14 +5544,14 @@ static const struct mtk_soc_data mt7981_
.has_accounting = true,
.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID_V2,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
-@@ -5426,14 +5432,14 @@ static const struct mtk_soc_data mt7986_
+@@ -5567,14 +5574,14 @@ static const struct mtk_soc_data mt7986_
.has_accounting = true,
.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID_V2,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
-@@ -5456,14 +5462,14 @@ static const struct mtk_soc_data mt7988_
+@@ -5597,14 +5604,14 @@ static const struct mtk_soc_data mt7988_
.has_accounting = true,
.foe_entry_size = MTK_FOE_ENTRY_V3_SIZE,
.tx = {
.irq_done_mask = MTK_RX_DONE_INT_V2,
.dma_l4_valid = RX_DMA_L4_VALID_V2,
.dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
-@@ -5480,13 +5486,13 @@ static const struct mtk_soc_data rt5350_
+@@ -5621,13 +5628,13 @@ static const struct mtk_soc_data rt5350_
.required_pctl = false,
.version = 1,
.tx = {
.dma_max_len = MTK_TX_DMA_BUF_LEN,
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
-@@ -1160,7 +1160,7 @@ struct mtk_reg_map {
+@@ -1200,7 +1200,7 @@ struct mtk_reg_map {
* @foe_entry_size Foe table entry size.
* @has_accounting Bool indicating support for accounting of
* offloaded flows.
* @irq_done_mask Rx irq done register mask.
* @dma_l4_valid Rx DMA valid register mask.
* @dma_max_len Max DMA tx/rx buffer length.
-@@ -1181,14 +1181,14 @@ struct mtk_soc_data {
+@@ -1221,14 +1221,14 @@ struct mtk_soc_data {
bool has_accounting;
bool disable_pll_modes;
struct {
--- 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";
+@@ -35,8 +35,16 @@ static const char *mtk_eth_path_name(u64
+ return "gmac2_2p5gphy";
case MTK_ETH_PATH_GMAC2_GEPHY:
return "gmac2_gephy";
+ case MTK_ETH_PATH_GMAC3_SGMII:
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_
+@@ -190,7 +198,48 @@ static int set_mux_gmac1_gmac2_to_sgmii_
return 0;
}
{
unsigned int val = 0;
bool updated = true;
-@@ -182,6 +254,9 @@ static int set_mux_gmac12_to_gephy_sgmii
+@@ -207,6 +256,9 @@ static int set_mux_gmac12_to_gephy_sgmii
case MTK_ETH_PATH_GMAC2_SGMII:
val |= SYSCFG0_SGMII_GMAC2_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,
+@@ -245,7 +297,15 @@ static const struct mtk_eth_muxc mtk_eth
}, {
.name = "mux_gmac12_to_gephy_sgmii",
.cap_bit = MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII,
},
};
-@@ -249,12 +336,39 @@ out:
+@@ -278,12 +338,26 @@ out:
return err;
}
+ /* 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)
{
+ 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);
#include <linux/jhash.h>
#include <linux/bitfield.h>
#include <net/dsa.h>
-@@ -522,6 +524,30 @@ static void mtk_setup_bridge_switch(stru
+@@ -523,6 +525,30 @@ static void mtk_setup_bridge_switch(stru
MTK_GSW_CFG);
}
static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config,
phy_interface_t interface)
{
-@@ -530,6 +556,21 @@ static struct phylink_pcs *mtk_mac_selec
+@@ -531,6 +557,21 @@ static struct phylink_pcs *mtk_mac_selec
struct mtk_eth *eth = mac->hw;
unsigned int sid;
if (interface == PHY_INTERFACE_MODE_SGMII ||
phy_interface_mode_is_8023z(interface)) {
sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ?
-@@ -581,7 +622,22 @@ static void mtk_mac_config(struct phylin
+@@ -543,21 +584,13 @@ static struct phylink_pcs *mtk_mac_selec
+ }
+
+ static int mtk_mac_prepare(struct phylink_config *config, unsigned int mode,
+- phy_interface_t iface)
++ phy_interface_t interface)
+ {
+ struct mtk_mac *mac = container_of(config, struct mtk_mac,
+ phylink_config);
+- struct mtk_eth *eth = mac->hw;
+
+- if (mtk_interface_mode_is_xgmii(eth, iface) &&
+- mac->id != MTK_GMAC1_ID) {
+- mtk_m32(mac->hw, XMAC_MCR_TRX_DISABLE,
+- XMAC_MCR_TRX_DISABLE, MTK_XMAC_MCR(mac->id));
+-
+- mtk_m32(mac->hw, MTK_XGMAC_FORCE_MODE(mac->id) |
+- MTK_XGMAC_FORCE_LINK(mac->id),
+- MTK_XGMAC_FORCE_MODE(mac->id), MTK_XGMAC_STS(mac->id));
+- }
++ if (mac->pextp && mac->interface != interface)
++ phy_reset(mac->pextp);
+
+ return 0;
+ }
+@@ -602,6 +635,15 @@ static void mtk_mac_config(struct phylin
goto init_err;
}
break;
+ }
+ 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;
-@@ -628,8 +684,6 @@ static void mtk_mac_config(struct phylin
+ if (mac->id == MTK_GMAC2_ID &&
+ MTK_HAS_CAPS(eth->soc->caps, MTK_2P5GPHY)) {
+@@ -655,8 +697,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);
}
/* SGMII */
-@@ -646,21 +700,40 @@ static void mtk_mac_config(struct phylin
+@@ -673,21 +713,40 @@ static void mtk_mac_config(struct phylin
/* Save the syscfg0 value for mac_finish */
mac->syscfg0 = val;
}
/* Setup gmac */
-- if (mtk_is_netsys_v3_or_greater(eth) &&
-- mac->interface == PHY_INTERFACE_MODE_INTERNAL) {
+- if (mtk_interface_mode_is_xgmii(eth, 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 (mtk_is_netsys_v3_or_greater(eth)) {
-+ if (mtk_interface_mode_is_xgmii(state->interface)) {
++ if (mtk_interface_mode_is_xgmii(eth, 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);
+ 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) ||
++ if ((mtk_interface_mode_is_xgmii(eth, mac->interface) ||
+ mac->interface == PHY_INTERFACE_MODE_NA) &&
+ !mtk_check_gmac23_idle(mac) &&
+ !test_bit(MTK_RESETTING, ð->state))
return;
err_phy:
-@@ -673,6 +746,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)
- {
-@@ -681,6 +766,10 @@ static int mtk_mac_finish(struct phylink
+@@ -708,6 +767,10 @@ static int mtk_mac_finish(struct phylink
struct mtk_eth *eth = mac->hw;
u32 mcr_cur, mcr_new;
/* Enable SGMII */
if (interface == PHY_INTERFACE_MODE_SGMII ||
phy_interface_mode_is_8023z(interface))
-@@ -705,10 +794,14 @@ static void mtk_mac_link_down(struct phy
- {
- struct mtk_mac *mac = container_of(config, struct mtk_mac,
+@@ -734,16 +797,11 @@ static void mtk_mac_link_down(struct phy
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)) {
+ if (!mtk_interface_mode_is_xgmii(mac->hw, interface)) {
+- /* GMAC modes */
+- mtk_m32(mac->hw,
+- MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK, 0,
+- MTK_MAC_MCR(mac->id));
+- } else if (mac->id != MTK_GMAC1_ID) {
+- /* XGMAC except for built-in switch */
+- mtk_m32(mac->hw, XMAC_MCR_TRX_DISABLE, XMAC_MCR_TRX_DISABLE,
+- MTK_XMAC_MCR(mac->id));
+- mtk_m32(mac->hw, MTK_XGMAC_FORCE_LINK(mac->id), 0,
+- MTK_XGMAC_STS(mac->id));
+ 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,
-@@ -780,13 +873,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));
-@@ -830,9 +921,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,
+@@ -858,10 +916,9 @@ static void mtk_gdm_mac_link_up(struct m
+ 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)
+ int speed, int duplex, bool tx_pause, bool rx_pause)
-+{
+ {
+- u32 mcr;
+ 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);
+
+ if (mac->id == MTK_GMAC1_ID)
+ return;
+@@ -869,15 +926,15 @@ static void mtk_xgdm_mac_link_up(struct
+ /* 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));
+ mtk_m32(mac->hw, XMAC_GLB_CNTCLR, XMAC_GLB_CNTCLR, MTK_XMAC_CNT_CTRL(mac->id));
-+
+
+- mtk_m32(mac->hw, MTK_XGMAC_FORCE_LINK(mac->id),
+- MTK_XGMAC_FORCE_LINK(mac->id), MTK_XGMAC_STS(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 = mtk_r32(mac->hw, MTK_XMAC_MCR(mac->id));
+- mcr &= ~(XMAC_MCR_FORCE_TX_FC | XMAC_MCR_FORCE_RX_FC |
+- XMAC_MCR_TRX_DISABLE);
+ 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);
+ /* Configure pause modes -
+ * phylink will avoid these for half duplex
+ */
+@@ -903,8 +960,13 @@ static void mtk_mac_link_up(struct phyli
+ 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,
-@@ -3591,6 +3736,9 @@ static int mtk_open(struct net_device *d
+ static void mtk_mac_disable_tx_lpi(struct phylink_config *config)
+ {
+ struct mtk_mac *mac = container_of(config, struct mtk_mac,
+@@ -3765,6 +3827,9 @@ static int mtk_open(struct net_device *d
ppe_num = eth->soc->ppe_num;
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
if (err) {
netdev_err(dev, "%s: could not attach PHY: %d\n", __func__,
-@@ -3738,6 +3886,9 @@ static int mtk_stop(struct net_device *d
+@@ -3912,6 +3977,9 @@ static int mtk_stop(struct net_device *d
for (i = 0; i < ARRAY_SIZE(eth->ppe); i++)
mtk_ppe_stop(eth->ppe[i]);
return 0;
}
-@@ -4837,6 +4988,7 @@ static const struct net_device_ops mtk_n
+@@ -4968,6 +5036,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);
phy_interface_t phy_mode;
struct phylink *phylink;
struct mtk_mac *mac;
-@@ -4875,16 +5027,44 @@ static int mtk_add_mac(struct mtk_eth *e
+@@ -5004,16 +5073,44 @@ static int mtk_add_mac(struct mtk_eth *e
mac->id = id;
mac->hw = eth;
mac->of_node = np;
}
memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
-@@ -4967,8 +5147,21 @@ static int mtk_add_mac(struct mtk_eth *e
+@@ -5099,8 +5196,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);
phylink = phylink_create(&mac->phylink_config,
of_fwnode_handle(mac->of_node),
phy_mode, &mtk_phylink_ops);
-@@ -5019,6 +5212,26 @@ free_netdev:
+@@ -5156,6 +5266,26 @@ free_netdev:
return err;
}
void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
{
struct net_device *dev, *tmp;
-@@ -5165,7 +5378,8 @@ static int mtk_probe(struct platform_dev
+@@ -5309,7 +5439,8 @@ static int mtk_probe(struct platform_dev
regmap_write(cci, 0, 3);
}
err = mtk_sgmii_init(eth);
if (err)
-@@ -5276,6 +5490,24 @@ static int mtk_probe(struct platform_dev
+@@ -5418,6 +5549,24 @@ static int mtk_probe(struct platform_dev
}
}
+ }
+
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
- err = devm_request_irq(eth->dev, eth->irq[0],
+ err = devm_request_irq(eth->dev, eth->irq[MTK_FE_IRQ_SHARED],
mtk_handle_irq, 0,
-@@ -5386,6 +5618,11 @@ static void mtk_remove(struct platform_d
+@@ -5528,6 +5677,11 @@ static void mtk_remove(struct platform_d
mtk_stop(eth->netdev[i]);
mac = netdev_priv(eth->netdev[i]);
phylink_disconnect_phy(mac->phylink);
#include <linux/rhashtable.h>
#include <linux/dim.h>
#include <linux/bitfield.h>
-@@ -527,6 +528,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
-@@ -552,6 +568,7 @@
+@@ -570,6 +571,7 @@
#define SYSCFG0_SGMII_GMAC2 ((3 << 8) & SYSCFG0_SGMII_MASK)
#define SYSCFG0_SGMII_GMAC1_V2 BIT(9)
#define SYSCFG0_SGMII_GMAC2_V2 BIT(8)
/* ethernet subsystem clock register */
-@@ -590,6 +607,11 @@
- #define GEPHY_MAC_SEL BIT(1)
-
- /* Top misc registers */
-+#define TOP_MISC_NETSYS_PCS_MUX 0x0
-+#define NETSYS_PCS_MUX_MASK GENMASK(1, 0)
-+#define MUX_G2_USXGMII_SEL BIT(1)
+@@ -611,6 +613,7 @@
+ #define TOP_MISC_NETSYS_PCS_MUX 0x0
+ #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
-@@ -614,6 +636,8 @@
+@@ -636,6 +639,8 @@
#define MT7628_SDM_RBCNT (MT7628_SDM_OFFSET + 0x10c)
#define MT7628_SDM_CS_ERR (MT7628_SDM_OFFSET + 0x110)
#define MTK_FE_CDM1_FSM 0x220
#define MTK_FE_CDM2_FSM 0x224
#define MTK_FE_CDM3_FSM 0x238
-@@ -622,6 +646,11 @@
+@@ -644,6 +649,11 @@
#define MTK_FE_CDM6_FSM 0x328
#define MTK_FE_GDM1_FSM 0x228
#define MTK_FE_GDM2_FSM 0x22C
#define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100))
-@@ -945,6 +974,8 @@ enum mkt_eth_capabilities {
+@@ -972,6 +982,7 @@ enum mkt_eth_capabilities {
MTK_RGMII_BIT = 0,
MTK_TRGMII_BIT,
MTK_SGMII_BIT,
+ MTK_USXGMII_BIT,
-+ MTK_2P5GPHY_BIT,
+ MTK_2P5GPHY_BIT,
MTK_ESW_BIT,
MTK_GEPHY_BIT,
- MTK_MUX_BIT,
-@@ -965,8 +996,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,
+@@ -996,6 +1007,8 @@ enum mkt_eth_capabilities {
+ 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,
/* PATH BITS */
MTK_ETH_PATH_GMAC1_RGMII_BIT,
-@@ -974,14 +1008,21 @@ enum mkt_eth_capabilities {
- MTK_ETH_PATH_GMAC1_SGMII_BIT,
- MTK_ETH_PATH_GMAC2_RGMII_BIT,
+@@ -1005,13 +1018,18 @@ enum mkt_eth_capabilities {
MTK_ETH_PATH_GMAC2_SGMII_BIT,
-+ MTK_ETH_PATH_GMAC2_2P5GPHY_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,
++ MTK_ETH_PATH_GMAC3_USXGMII_BIT
};
/* Supported hardware group on SoCs */
#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_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 +1045,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 \
+@@ -1041,6 +1059,10 @@ enum mkt_eth_capabilities {
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)
/* Supported path present on SoCs */
#define MTK_ETH_PATH_GMAC1_RGMII BIT_ULL(MTK_ETH_PATH_GMAC1_RGMII_BIT)
-@@ -1015,8 +1062,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)
+@@ -1050,7 +1072,11 @@ enum mkt_eth_capabilities {
#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_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_GMAC1_RGMII (MTK_ETH_PATH_GMAC1_RGMII | MTK_RGMII)
#define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII)
-@@ -1024,7 +1076,12 @@ enum mkt_eth_capabilities {
- #define MTK_GMAC2_RGMII (MTK_ETH_PATH_GMAC2_RGMII | MTK_RGMII)
+@@ -1059,7 +1085,11 @@ enum mkt_eth_capabilities {
#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_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)
/* MUXes present on SoCs */
/* 0: GDM1 -> GMAC1, 1: GDM1 -> ESW */
-@@ -1043,10 +1100,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 */
+@@ -1086,6 +1116,12 @@ enum mkt_eth_capabilities {
#define MTK_MUX_GMAC12_TO_GEPHY_SGMII \
(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII | MTK_MUX)
#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x))
#define MT7621_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \
-@@ -1078,8 +1145,12 @@ enum mkt_eth_capabilities {
+@@ -1117,9 +1153,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_GMAC2_2P5GPHY | \
+- MTK_MUX_GMAC2_TO_2P5GPHY | 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 | \
struct mtk_tx_dma_desc_info {
dma_addr_t addr;
-@@ -1327,6 +1398,9 @@ struct mtk_mac {
+@@ -1366,6 +1405,9 @@ struct mtk_mac {
struct device_node *of_node;
struct phylink *phylink;
struct phylink_config phylink_config;
struct mtk_eth *hw;
struct mtk_hw_stats *hw_stats;
__be32 hwlro_ip[MTK_MAX_LRO_IP_CNT];
-@@ -1450,6 +1524,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);
-
-@@ -1458,8 +1545,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);
+@@ -1517,6 +1559,7 @@ int mtk_gmac_sgmii_path_setup(struct mtk
+ 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);
static struct mtk_pcs_lynxi *pcs_to_mtk_pcs_lynxi(struct phylink_pcs *pcs)
{
return container_of(pcs, struct mtk_pcs_lynxi, pcs);
-@@ -117,6 +139,17 @@ static void mtk_pcs_lynxi_get_state(stru
+@@ -118,6 +140,17 @@ static void mtk_pcs_lynxi_get_state(stru
FIELD_GET(SGMII_LPA, adv));
}
static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode,
phy_interface_t interface,
const unsigned long *advertising,
-@@ -162,6 +195,7 @@ static int mtk_pcs_lynxi_config(struct p
+@@ -163,6 +196,7 @@ static int mtk_pcs_lynxi_config(struct p
SGMII_PHYA_PWD);
/* Reset SGMII PCS state */
regmap_set_bits(mpcs->regmap, SGMSYS_RESERVED_0,
SGMII_SW_RESET);
-@@ -248,10 +282,29 @@ static void mtk_pcs_lynxi_link_up(struct
+@@ -249,10 +283,29 @@ static void mtk_pcs_lynxi_link_up(struct
}
}
mpcs->interface = PHY_INTERFACE_MODE_NA;
}
-@@ -262,11 +315,12 @@ static const struct phylink_pcs_ops mtk_
+@@ -263,11 +316,12 @@ static const struct phylink_pcs_ops mtk_
.pcs_an_restart = mtk_pcs_lynxi_restart_an,
.pcs_link_up = mtk_pcs_lynxi_link_up,
.pcs_disable = mtk_pcs_lynxi_disable,
{
struct mtk_pcs_lynxi *mpcs;
u32 id, ver;
-@@ -274,29 +328,33 @@ struct phylink_pcs *mtk_pcs_lynxi_create
+@@ -275,29 +329,33 @@ struct phylink_pcs *mtk_pcs_lynxi_create
ret = regmap_read(regmap, SGMSYS_PCS_DEVICE_ID, &id);
if (ret < 0)
mpcs->ana_rgc3 = ana_rgc3;
mpcs->regmap = regmap;
-@@ -307,6 +365,13 @@ struct phylink_pcs *mtk_pcs_lynxi_create
- mpcs->interface = PHY_INTERFACE_MODE_NA;
+@@ -311,6 +369,13 @@ struct phylink_pcs *mtk_pcs_lynxi_create
+ __set_bit(PHY_INTERFACE_MODE_2500BASEX, mpcs->pcs.supported_interfaces);
return &mpcs->pcs;
+};
}
EXPORT_SYMBOL(mtk_pcs_lynxi_create);
-@@ -319,5 +384,142 @@ void mtk_pcs_lynxi_destroy(struct phylin
+@@ -323,5 +388,142 @@ void mtk_pcs_lynxi_destroy(struct phylin
}
EXPORT_SYMBOL(mtk_pcs_lynxi_destroy);
+ .of_match_table = mtk_pcs_lynxi_of_match,
+ },
+ .probe = mtk_pcs_lynxi_probe,
-+ .remove_new = mtk_pcs_lynxi_remove,
++ .remove = mtk_pcs_lynxi_remove,
+};
+module_platform_driver(mtk_pcs_lynxi_driver);
+
--- a/MAINTAINERS
+++ b/MAINTAINERS
-@@ -14432,7 +14432,9 @@ M: Daniel Golle <daniel@makrotopia.org>
+@@ -15790,7 +15790,9 @@ M: Daniel Golle <daniel@makrotopia.org>
L: netdev@vger.kernel.org
S: Maintained
F: drivers/net/pcs/pcs-mtk-lynxi.c
+ differential pairs via an embedded LynxI PHY.
+
config PCS_RZN1_MIIC
- tristate "Renesas RZ/N1 MII converter"
- depends on OF && (ARCH_RZN1 || COMPILE_TEST)
+ tristate "Renesas RZ/N1, RZ/N2H, RZ/T2H MII converter"
+ depends on OF
--- a/drivers/net/pcs/Makefile
+++ b/drivers/net/pcs/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o
+ .of_match_table = mtk_usxgmii_of_mtable,
+ },
+ .probe = mtk_usxgmii_probe,
-+ .remove_new = mtk_usxgmii_remove,
++ .remove = mtk_usxgmii_remove,
+};
+module_platform_driver(mtk_usxgmii_driver);
+
return 0;
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
-@@ -965,7 +965,8 @@ static int _set_opp_voltage(struct devic
+@@ -1054,7 +1054,8 @@ static int _set_opp_voltage(struct devic
static int
_opp_config_clk_single(struct device *dev, struct opp_table *opp_table,
{
unsigned long *target = data;
unsigned long freq;
-@@ -997,8 +998,8 @@ _opp_config_clk_single(struct device *de
+@@ -1086,8 +1087,8 @@ _opp_config_clk_single(struct device *de
* the order in which they are present in the array while scaling up.
*/
int dev_pm_opp_config_clks_simple(struct device *dev,
{
int ret, i;
-@@ -1265,7 +1266,7 @@ static int _set_opp(struct device *dev,
+@@ -1353,7 +1354,7 @@ static int _set_opp(struct device *dev,
}
if (opp_table->config_clks) {
if (ret)
return ret;
}
-@@ -1344,7 +1345,7 @@ int dev_pm_opp_set_rate(struct device *d
+@@ -1430,7 +1431,7 @@ int dev_pm_opp_set_rate(struct device *d
* equivalent to a clk_set_rate()
*/
if (!_get_opp_count(opp_table)) {
-- ret = opp_table->config_clks(dev, opp_table, NULL,
-+ ret = opp_table->config_clks(dev, opp_table, NULL, NULL,
- &target_freq, false);
- goto put_opp_table;
+- return opp_table->config_clks(dev, opp_table, NULL,
++ return opp_table->config_clks(dev, opp_table, NULL, NULL,
+ &target_freq, false);
}
+
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
-@@ -1122,8 +1122,8 @@ out:
+@@ -1149,8 +1149,8 @@ out:
}
int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table,
struct list_head *head = &hba->clk_list_head;
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
-@@ -50,7 +50,8 @@ typedef int (*config_regulators_t)(struc
+@@ -51,7 +51,8 @@ typedef int (*config_regulators_t)(struc
struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp,
struct regulator **regulators, unsigned int count);
struct dev_pm_opp *opp, void *data, bool scaling_down);
/**
-@@ -184,8 +185,8 @@ int dev_pm_opp_set_config(struct device
+@@ -208,8 +209,8 @@ int dev_pm_opp_set_config(struct device
int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config);
void dev_pm_opp_clear_config(int token);
int dev_pm_opp_config_clks_simple(struct device *dev,
struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp);
int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate);
-@@ -395,8 +396,8 @@ static inline int devm_pm_opp_set_config
+@@ -442,8 +443,8 @@ static inline int devm_pm_opp_set_config
static inline void dev_pm_opp_clear_config(int token) {}
static inline int dev_pm_opp_config_clks_simple(struct device *dev,
}
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
-@@ -1333,8 +1333,8 @@ void ufshcd_mcq_enable(struct ufs_hba *h
+@@ -1327,8 +1327,8 @@ void ufshcd_mcq_enable_esi(struct ufs_hb
void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg);
int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table,
#include <linux/bitfield.h>
+#include <linux/completion.h>
+ #include <linux/cleanup.h>
#include <linux/kernel.h>
#include <linux/sched.h>
- #include <linux/pci.h>
-@@ -36,6 +37,7 @@
+@@ -38,6 +39,7 @@
#endif
static int sysfs_initialized; /* = 0 */
/* show configuration fields */
#define pci_config_attr(field, format_string) \
-@@ -1551,12 +1553,32 @@ static const struct attribute_group pci_
+@@ -1701,12 +1703,32 @@ static const struct attribute_group pci_
.is_visible = resource_resize_is_visible,
};
}
/**
-@@ -1577,21 +1599,23 @@ static int __init pci_sysfs_init(void)
+@@ -1727,21 +1749,23 @@ static int __init pci_sysfs_init(void)
{
struct pci_dev *pdev = NULL;
struct pci_bus *pbus = NULL;
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
-@@ -484,6 +484,7 @@ struct pci_dev {
- unsigned int rom_attr_enabled:1; /* Display of ROM attribute enabled? */
+@@ -490,6 +490,7 @@ struct pci_dev {
+ unsigned int non_mappable_bars:1; /* BARs can't be mapped to user-space */
pci_dev_flags_t dev_flags;
atomic_t enable_cnt; /* pci_enable_device has been called */
+ bool sysfs_init; /* sysfs entry has been created */
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
-@@ -276,7 +276,6 @@ struct advk_pcie {
+@@ -277,7 +277,6 @@ struct advk_pcie {
u8 wins_count;
struct irq_domain *rp_irq_domain;
struct irq_domain *irq_domain;
- struct irq_chip irq_chip;
raw_spinlock_t irq_lock;
- struct irq_domain *msi_domain;
struct irq_domain *msi_inner_domain;
-@@ -1418,14 +1417,19 @@ static void advk_pcie_irq_unmask(struct
+ raw_spinlock_t msi_irq_lock;
+@@ -1406,14 +1405,19 @@ static void advk_pcie_irq_unmask(struct
raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
}
irq_set_chip_data(virq, pcie);
return 0;
-@@ -1485,7 +1489,6 @@ static int advk_pcie_init_irq_domain(str
+@@ -1471,7 +1475,6 @@ static int advk_pcie_init_irq_domain(str
struct device *dev = &pcie->pdev->dev;
struct device_node *node = dev->of_node;
struct device_node *pcie_intc_node;
int ret = 0;
raw_spin_lock_init(&pcie->irq_lock);
-@@ -1496,28 +1499,14 @@ static int advk_pcie_init_irq_domain(str
+@@ -1482,27 +1485,13 @@ static int advk_pcie_init_irq_domain(str
return -ENODEV;
}
- irq_chip->irq_mask = advk_pcie_irq_mask;
- irq_chip->irq_unmask = advk_pcie_irq_unmask;
-
- pcie->irq_domain =
- irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
- &advk_pcie_irq_domain_ops, pcie);
+ pcie->irq_domain = irq_domain_create_linear(of_fwnode_handle(pcie_intc_node), PCI_NUM_INTX,
+ &advk_pcie_irq_domain_ops, pcie);
if (!pcie->irq_domain) {
dev_err(dev, "Failed to get a INTx IRQ domain\n");
ret = -ENOMEM;