mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-02-14 12:21:53 +00:00
Fix support of Z8102AX with kernel 6.6
This commit is contained in:
parent
918612e30a
commit
3747235464
14 changed files with 1456 additions and 40 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
/ {
|
||||
model = "ZBT Z8102AX";
|
||||
compatible = "z8102ax", "mediatek,mt7981";
|
||||
compatible = "z8102ax", "mediatek,mt7981", "zbtlink,zbt-z8102ax";
|
||||
|
||||
aliases {
|
||||
serial0 = &uart0;
|
||||
|
@ -16,10 +16,12 @@
|
|||
led-failsafe = &led_status_red;
|
||||
led-running = &led_status_green;
|
||||
led-upgrade = &led_status_green;
|
||||
label-mac-device = &gmac0;
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8 loglevel=8";
|
||||
};
|
||||
|
||||
gpio-keys {
|
||||
|
@ -44,43 +46,82 @@
|
|||
|
||||
led_status_red: red {
|
||||
label = "red:status";
|
||||
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
|
||||
gpios = <&pio 9 GPIO_ACTIVE_HIGH>;
|
||||
color = <LED_COLOR_ID_RED>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
};
|
||||
|
||||
led_status_green: green {
|
||||
label = "green:status";
|
||||
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
|
||||
color = <LED_COLOR_ID_GREEN>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
};
|
||||
|
||||
led_status_blue: blue {
|
||||
label = "blue:status";
|
||||
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
|
||||
color = <LED_COLOR_ID_BLUE>;
|
||||
function = LED_FUNCTION_STATUS;
|
||||
};
|
||||
|
||||
led_status_4g: 4g {
|
||||
label = "4g:status";
|
||||
led_status_modem1: modem1 {
|
||||
label = "modem1:status";
|
||||
gpios = <&pio 8 GPIO_ACTIVE_LOW>;
|
||||
color = <LED_COLOR_ID_BLUE>;
|
||||
function = LED_FUNCTION_USB;
|
||||
function-enumerator = <0>;
|
||||
};
|
||||
|
||||
led_status_4g2: 4g2 {
|
||||
label = "4g2:status";
|
||||
gpios = <&pio 13 GPIO_ACTIVE_LOW>;
|
||||
led_status_modem2: modem2 {
|
||||
label = "modem2:status";
|
||||
gpios = <&pio 14 GPIO_ACTIVE_LOW>;
|
||||
color = <LED_COLOR_ID_BLUE>;
|
||||
function = LED_FUNCTION_USB;
|
||||
function-enumerator = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
watchdog {
|
||||
compatible = "linux,wdt-gpio";
|
||||
gpios = <&pio 2 GPIO_ACTIVE_HIGH>;
|
||||
hw_algo = "toggle";
|
||||
hw_margin_ms = <1000>;
|
||||
};
|
||||
usb_vbus: regulator-usb-vbus {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "usb_vbus";
|
||||
regulator-min-microvolt = <5000000>;
|
||||
regulator-max-microvolt = <5000000>;
|
||||
gpio = <&pio 12 GPIO_ACTIVE_HIGH>;
|
||||
enable-active-high;
|
||||
regulator-boot-on;
|
||||
|
||||
gpio-export {
|
||||
compatible = "gpio-export";
|
||||
#size-cells = <0>;
|
||||
|
||||
pcie {
|
||||
gpio-export,name = "pcie_power";
|
||||
gpio-export,output = <1>;
|
||||
gpios = <&pio 3 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
modem1 {
|
||||
gpio-export,name = "modem1";
|
||||
gpio-export,output = <1>;
|
||||
gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
modem2 {
|
||||
gpio-export,name = "modem2";
|
||||
gpio-export,output = <1>;
|
||||
gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
sim1 {
|
||||
gpio-export,name = "sim1";
|
||||
gpio-export,output = <1>;
|
||||
gpios = <&pio 6 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
sim2 {
|
||||
gpio-export,name = "sim2";
|
||||
gpio-export,output = <1>;
|
||||
gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -136,6 +177,10 @@
|
|||
spi-tx-buswidth = <4>;
|
||||
spi-rx-buswidth = <4>;
|
||||
|
||||
mediatek,nmbm;
|
||||
mediatek,bmt-max-ratio = <1>;
|
||||
mediatek,bmt-max-reserved-blocks = <64>;
|
||||
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
|
@ -159,7 +204,7 @@
|
|||
};
|
||||
|
||||
partition@380000 {
|
||||
label = "fip";
|
||||
label = "FIP";
|
||||
reg = <0x0380000 0x0200000>;
|
||||
read-only;
|
||||
};
|
||||
|
@ -179,37 +224,26 @@
|
|||
port@0 {
|
||||
reg = <0>;
|
||||
label = "lan1";
|
||||
nvmem-cell-names = "mac-address";
|
||||
nvmem-cells = <&macaddr_factory_004>;
|
||||
mac-address-increment = <2>;
|
||||
};
|
||||
|
||||
port@1 {
|
||||
reg = <1>;
|
||||
label = "lan2";
|
||||
nvmem-cell-names = "mac-address";
|
||||
nvmem-cells = <&macaddr_factory_004>;
|
||||
mac-address-increment = <2>;
|
||||
};
|
||||
|
||||
port@2 {
|
||||
reg = <2>;
|
||||
label = "lan3";
|
||||
nvmem-cell-names = "mac-address";
|
||||
nvmem-cells = <&macaddr_factory_004>;
|
||||
mac-address-increment = <2>;
|
||||
};
|
||||
|
||||
port@3 {
|
||||
reg = <3>;
|
||||
label = "lan4";
|
||||
nvmem-cell-names = "mac-address";
|
||||
nvmem-cells = <&macaddr_factory_004>;
|
||||
mac-address-increment = <2>;
|
||||
};
|
||||
|
||||
port@6 {
|
||||
reg = <6>;
|
||||
label = "cpu";
|
||||
ethernet = <&gmac0>;
|
||||
phy-mode = "2500base-x";
|
||||
|
||||
|
@ -223,6 +257,23 @@
|
|||
};
|
||||
|
||||
&pio {
|
||||
gpio-line-names =
|
||||
"wps",
|
||||
"reset",
|
||||
"watchdog",
|
||||
"pcie",
|
||||
"modem1",
|
||||
"modem2",
|
||||
"sim1",
|
||||
"sim2",
|
||||
"modem1_status",
|
||||
"red_status",
|
||||
"green_status",
|
||||
"blue_status",
|
||||
"",
|
||||
"",
|
||||
"modem2_status";
|
||||
|
||||
spi0_flash_pins: spi0-pins {
|
||||
mux {
|
||||
function = "spi";
|
||||
|
@ -251,22 +302,19 @@
|
|||
status = "okay";
|
||||
};
|
||||
|
||||
&wifi {
|
||||
status = "okay";
|
||||
|
||||
mediatek,mtd-eeprom = <&factory 0x0>;
|
||||
};
|
||||
|
||||
&usb_phy {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&xhci {
|
||||
vbus-supply = <&usb_vbus>;
|
||||
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&wifi {
|
||||
status = "okay";
|
||||
mediatek,mtd-eeprom = <&factory 0x0>;
|
||||
};
|
||||
|
||||
&factory {
|
||||
compatible = "nvmem-cells";
|
||||
#address-cells = <1>;
|
||||
|
@ -275,4 +323,4 @@
|
|||
macaddr_factory_004: macaddr@004 {
|
||||
reg = <0x004 0x6>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -133,7 +133,7 @@ static struct platform_driver clk_mt7988_eth_drv = {
|
|||
.of_match_table = of_match_clk_mt7986_eth,
|
||||
},
|
||||
.probe = mtk_clk_simple_probe,
|
||||
.remove = mtk_clk_simple_remove,
|
||||
.remove_new = mtk_clk_simple_remove,
|
||||
};
|
||||
module_platform_driver(clk_mt7988_eth_drv);
|
||||
|
||||
|
|
|
@ -371,6 +371,6 @@ static struct platform_driver clk_mt7988_infracfg_drv = {
|
|||
.of_match_table = of_match_clk_mt7988_infracfg,
|
||||
},
|
||||
.probe = mtk_clk_simple_probe,
|
||||
.remove = mtk_clk_simple_remove,
|
||||
.remove_new = mtk_clk_simple_remove,
|
||||
};
|
||||
module_platform_driver(clk_mt7988_infracfg_drv);
|
||||
|
|
|
@ -436,7 +436,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt7988_topckgen);
|
|||
|
||||
static struct platform_driver clk_mt7988_topckgen_drv = {
|
||||
.probe = mtk_clk_simple_probe,
|
||||
.remove = mtk_clk_simple_remove,
|
||||
.remove_new = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt7988-topckgen",
|
||||
.of_match_table = of_match_clk_mt7988_topckgen,
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
--- a/drivers/pinctrl/mediatek/Kconfig
|
||||
+++ b/drivers/pinctrl/mediatek/Kconfig
|
||||
@@ -141,6 +141,13 @@ config PINCTRL_MT7986
|
||||
default ARM64 && ARCH_MEDIATEK
|
||||
select PINCTRL_MTK_MOORE
|
||||
|
||||
+config PINCTRL_MT7988
|
||||
+ bool "Mediatek MT7988 pin control"
|
||||
+ depends on OF
|
||||
+ depends on ARM64 || COMPILE_TEST
|
||||
+ default ARCH_MEDIATEK
|
||||
+ select PINCTRL_MTK_MOORE
|
||||
+
|
||||
config PINCTRL_MT8167
|
||||
bool "Mediatek MT8167 pin control"
|
||||
depends on OF
|
||||
--- a/drivers/pinctrl/mediatek/Makefile
|
||||
+++ b/drivers/pinctrl/mediatek/Makefile
|
||||
@@ -20,6 +20,7 @@ obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-
|
||||
obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o
|
||||
obj-$(CONFIG_PINCTRL_MT7981) += pinctrl-mt7981.o
|
||||
obj-$(CONFIG_PINCTRL_MT7986) += pinctrl-mt7986.o
|
||||
+obj-$(CONFIG_PINCTRL_MT7988) += pinctrl-mt7988.o
|
||||
obj-$(CONFIG_PINCTRL_MT8167) += pinctrl-mt8167.o
|
||||
obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o
|
||||
obj-$(CONFIG_PINCTRL_MT8183) += pinctrl-mt8183.o
|
|
@ -0,0 +1,31 @@
|
|||
--- a/drivers/clk/mediatek/Kconfig
|
||||
+++ b/drivers/clk/mediatek/Kconfig
|
||||
@@ -415,6 +415,15 @@ config COMMON_CLK_MT7986_ETHSYS
|
||||
This driver adds support for clocks for Ethernet and SGMII
|
||||
required on MediaTek MT7986 SoC.
|
||||
|
||||
+config COMMON_CLK_MT7988
|
||||
+ bool "Clock driver for MediaTek MT7988"
|
||||
+ depends on ARCH_MEDIATEK || COMPILE_TEST
|
||||
+ select COMMON_CLK_MEDIATEK
|
||||
+ default ARCH_MEDIATEK
|
||||
+ help
|
||||
+ This driver supports MediaTek MT7988 basic clocks and clocks
|
||||
+ required for various periperals found on MediaTek.
|
||||
+
|
||||
config COMMON_CLK_MT8135
|
||||
bool "Clock driver for MediaTek MT8135"
|
||||
depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST
|
||||
--- a/drivers/clk/mediatek/Makefile
|
||||
+++ b/drivers/clk/mediatek/Makefile
|
||||
@@ -60,6 +60,10 @@ obj-$(CONFIG_COMMON_CLK_MT7986) += clk-m
|
||||
obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-topckgen.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-infracfg.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7986_ETHSYS) += clk-mt7986-eth.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7988) += clk-mt7988-apmixed.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7988) += clk-mt7988-topckgen.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7988) += clk-mt7988-infracfg.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7988) += clk-mt7988-eth.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135-apmixedsys.o clk-mt8135.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT8167) += clk-mt8167-apmixedsys.o clk-mt8167.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT8167_AUDSYS) += clk-mt8167-aud.o
|
|
@ -0,0 +1,130 @@
|
|||
From bfd3acc428085742d754a6d328d1a93ebf9451df Mon Sep 17 00:00:00 2001
|
||||
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
||||
Date: Thu, 23 Jun 2022 18:29:51 +0800
|
||||
Subject: [PATCH 1/6] drivers: spi-mt65xx: Move chip_config to driver's private
|
||||
data
|
||||
|
||||
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
||||
---
|
||||
drivers/spi/spi-mt65xx.c | 29 +++++++++---------------
|
||||
include/linux/platform_data/spi-mt65xx.h | 17 --------------
|
||||
2 files changed, 11 insertions(+), 35 deletions(-)
|
||||
delete mode 100644 include/linux/platform_data/spi-mt65xx.h
|
||||
|
||||
--- a/drivers/spi/spi-mt65xx.c
|
||||
+++ b/drivers/spi/spi-mt65xx.c
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/platform_device.h>
|
||||
-#include <linux/platform_data/spi-mt65xx.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/spi/spi-mem.h>
|
||||
@@ -171,6 +170,8 @@ struct mtk_spi {
|
||||
struct device *dev;
|
||||
dma_addr_t tx_dma;
|
||||
dma_addr_t rx_dma;
|
||||
+ u32 sample_sel;
|
||||
+ u32 get_tick_dly;
|
||||
};
|
||||
|
||||
static const struct mtk_spi_compatible mtk_common_compat;
|
||||
@@ -216,15 +217,6 @@ static const struct mtk_spi_compatible m
|
||||
.no_need_unprepare = true,
|
||||
};
|
||||
|
||||
-/*
|
||||
- * A piece of default chip info unless the platform
|
||||
- * supplies it.
|
||||
- */
|
||||
-static const struct mtk_chip_config mtk_default_chip_info = {
|
||||
- .sample_sel = 0,
|
||||
- .tick_delay = 0,
|
||||
-};
|
||||
-
|
||||
static const struct of_device_id mtk_spi_of_match[] = {
|
||||
{ .compatible = "mediatek,spi-ipm",
|
||||
.data = (void *)&mtk_ipm_compat,
|
||||
@@ -352,7 +344,6 @@ static int mtk_spi_hw_init(struct spi_ma
|
||||
{
|
||||
u16 cpha, cpol;
|
||||
u32 reg_val;
|
||||
- struct mtk_chip_config *chip_config = spi->controller_data;
|
||||
struct mtk_spi *mdata = spi_master_get_devdata(master);
|
||||
|
||||
cpha = spi->mode & SPI_CPHA ? 1 : 0;
|
||||
@@ -402,7 +393,7 @@ static int mtk_spi_hw_init(struct spi_ma
|
||||
else
|
||||
reg_val &= ~SPI_CMD_CS_POL;
|
||||
|
||||
- if (chip_config->sample_sel)
|
||||
+ if (mdata->sample_sel)
|
||||
reg_val |= SPI_CMD_SAMPLE_SEL;
|
||||
else
|
||||
reg_val &= ~SPI_CMD_SAMPLE_SEL;
|
||||
@@ -429,20 +420,20 @@ static int mtk_spi_hw_init(struct spi_ma
|
||||
if (mdata->dev_comp->ipm_design) {
|
||||
reg_val = readl(mdata->base + SPI_CMD_REG);
|
||||
reg_val &= ~SPI_CMD_IPM_GET_TICKDLY_MASK;
|
||||
- reg_val |= ((chip_config->tick_delay & 0x7)
|
||||
+ reg_val |= ((mdata->get_tick_dly & 0x7)
|
||||
<< SPI_CMD_IPM_GET_TICKDLY_OFFSET);
|
||||
writel(reg_val, mdata->base + SPI_CMD_REG);
|
||||
} else {
|
||||
reg_val = readl(mdata->base + SPI_CFG1_REG);
|
||||
reg_val &= ~SPI_CFG1_GET_TICK_DLY_MASK;
|
||||
- reg_val |= ((chip_config->tick_delay & 0x7)
|
||||
+ reg_val |= ((mdata->get_tick_dly & 0x7)
|
||||
<< SPI_CFG1_GET_TICK_DLY_OFFSET);
|
||||
writel(reg_val, mdata->base + SPI_CFG1_REG);
|
||||
}
|
||||
} else {
|
||||
reg_val = readl(mdata->base + SPI_CFG1_REG);
|
||||
reg_val &= ~SPI_CFG1_GET_TICK_DLY_MASK_V1;
|
||||
- reg_val |= ((chip_config->tick_delay & 0x3)
|
||||
+ reg_val |= ((mdata->get_tick_dly & 0x3)
|
||||
<< SPI_CFG1_GET_TICK_DLY_OFFSET_V1);
|
||||
writel(reg_val, mdata->base + SPI_CFG1_REG);
|
||||
}
|
||||
@@ -732,9 +723,6 @@ static int mtk_spi_setup(struct spi_devi
|
||||
{
|
||||
struct mtk_spi *mdata = spi_master_get_devdata(spi->master);
|
||||
|
||||
- if (!spi->controller_data)
|
||||
- spi->controller_data = (void *)&mtk_default_chip_info;
|
||||
-
|
||||
if (mdata->dev_comp->need_pad_sel && spi_get_csgpiod(spi, 0))
|
||||
/* CS de-asserted, gpiolib will handle inversion */
|
||||
gpiod_direction_output(spi_get_csgpiod(spi, 0), 0);
|
||||
@@ -1138,6 +1126,10 @@ static int mtk_spi_probe(struct platform
|
||||
mdata = spi_master_get_devdata(master);
|
||||
mdata->dev_comp = device_get_match_data(dev);
|
||||
|
||||
+ /* Set device configs to default first. Calibrate it later. */
|
||||
+ mdata->sample_sel = 0;
|
||||
+ mdata->get_tick_dly = 2;
|
||||
+
|
||||
if (mdata->dev_comp->enhance_timing)
|
||||
master->mode_bits |= SPI_CS_HIGH;
|
||||
|
||||
--- a/include/linux/platform_data/spi-mt65xx.h
|
||||
+++ /dev/null
|
||||
@@ -1,17 +0,0 @@
|
||||
-/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
-/*
|
||||
- * MTK SPI bus driver definitions
|
||||
- *
|
||||
- * Copyright (c) 2015 MediaTek Inc.
|
||||
- * Author: Leilk Liu <leilk.liu@mediatek.com>
|
||||
- */
|
||||
-
|
||||
-#ifndef ____LINUX_PLATFORM_DATA_SPI_MTK_H
|
||||
-#define ____LINUX_PLATFORM_DATA_SPI_MTK_H
|
||||
-
|
||||
-/* Board specific platform_data */
|
||||
-struct mtk_chip_config {
|
||||
- u32 sample_sel;
|
||||
- u32 tick_delay;
|
||||
-};
|
||||
-#endif
|
|
@ -0,0 +1,237 @@
|
|||
From 2ade0172154e50c8a2bfd8634c6eff943cffea29 Mon Sep 17 00:00:00 2001
|
||||
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
||||
Date: Thu, 23 Jun 2022 18:35:52 +0800
|
||||
Subject: [PATCH 2/6] drivers: spi: Add support for dynamic calibration
|
||||
|
||||
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
||||
---
|
||||
drivers/spi/spi.c | 137 ++++++++++++++++++++++++++++++++++++++++
|
||||
include/linux/spi/spi.h | 42 ++++++++++++
|
||||
2 files changed, 179 insertions(+)
|
||||
|
||||
--- a/drivers/spi/spi.c
|
||||
+++ b/drivers/spi/spi.c
|
||||
@@ -1385,6 +1385,70 @@ static int spi_transfer_wait(struct spi_
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int spi_do_calibration(struct spi_controller *ctlr, struct spi_device *spi,
|
||||
+ int (*cal_read)(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen), void *drv_priv)
|
||||
+{
|
||||
+ int datalen = ctlr->cal_rule->datalen;
|
||||
+ int addrlen = ctlr->cal_rule->addrlen;
|
||||
+ u8 *buf;
|
||||
+ int ret;
|
||||
+ int i;
|
||||
+ struct list_head *cal_head, *listptr;
|
||||
+ struct spi_cal_target *target;
|
||||
+
|
||||
+ /* Calculate calibration result */
|
||||
+ int hit_val, total_hit, origin;
|
||||
+ bool hit;
|
||||
+
|
||||
+ /* Make sure we can start calibration */
|
||||
+ if(!ctlr->cal_target || !ctlr->cal_rule || !ctlr->append_caldata)
|
||||
+ return 0;
|
||||
+
|
||||
+ buf = kzalloc(datalen * sizeof(u8), GFP_KERNEL);
|
||||
+ if(!buf)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ ret = ctlr->append_caldata(ctlr);
|
||||
+ if (ret)
|
||||
+ goto cal_end;
|
||||
+
|
||||
+ cal_head = ctlr->cal_target;
|
||||
+ list_for_each(listptr, cal_head) {
|
||||
+ target = list_entry(listptr, struct spi_cal_target, list);
|
||||
+
|
||||
+ hit = false;
|
||||
+ hit_val = 0;
|
||||
+ total_hit = 0;
|
||||
+ origin = *target->cal_item;
|
||||
+
|
||||
+ for(i=target->cal_min; i<=target->cal_max; i+=target->step) {
|
||||
+ *target->cal_item = i;
|
||||
+ ret = (*cal_read)(drv_priv, ctlr->cal_rule->addr, addrlen, buf, datalen);
|
||||
+ if(ret)
|
||||
+ break;
|
||||
+ dev_dbg(&spi->dev, "controller cal item value: 0x%x\n", i);
|
||||
+ if(memcmp(ctlr->cal_rule->match_data, buf, datalen * sizeof(u8)) == 0) {
|
||||
+ hit = true;
|
||||
+ hit_val += i;
|
||||
+ total_hit++;
|
||||
+ dev_dbg(&spi->dev, "golden data matches data read!\n");
|
||||
+ }
|
||||
+ }
|
||||
+ if(hit) {
|
||||
+ *target->cal_item = DIV_ROUND_CLOSEST(hit_val, total_hit);
|
||||
+ dev_info(&spi->dev, "calibration result: 0x%x", *target->cal_item);
|
||||
+ } else {
|
||||
+ *target->cal_item = origin;
|
||||
+ dev_warn(&spi->dev, "calibration failed, fallback to default: 0x%x", origin);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+cal_end:
|
||||
+ kfree(buf);
|
||||
+ return ret? ret: 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(spi_do_calibration);
|
||||
+
|
||||
static void _spi_transfer_delay_ns(u32 ns)
|
||||
{
|
||||
if (!ns)
|
||||
@@ -2219,6 +2283,75 @@ void spi_flush_queue(struct spi_controll
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
+static inline void alloc_cal_data(struct list_head **cal_target,
|
||||
+ struct spi_cal_rule **cal_rule, bool enable)
|
||||
+{
|
||||
+ if(enable) {
|
||||
+ *cal_target = kmalloc(sizeof(struct list_head), GFP_KERNEL);
|
||||
+ INIT_LIST_HEAD(*cal_target);
|
||||
+ *cal_rule = kmalloc(sizeof(struct spi_cal_rule), GFP_KERNEL);
|
||||
+ } else {
|
||||
+ kfree(*cal_target);
|
||||
+ kfree(*cal_rule);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int of_spi_parse_cal_dt(struct spi_controller *ctlr, struct spi_device *spi,
|
||||
+ struct device_node *nc)
|
||||
+{
|
||||
+ u32 value;
|
||||
+ int rc;
|
||||
+ const char *cal_mode;
|
||||
+
|
||||
+ rc = of_property_read_bool(nc, "spi-cal-enable");
|
||||
+ if (rc)
|
||||
+ alloc_cal_data(&ctlr->cal_target, &ctlr->cal_rule, true);
|
||||
+ else
|
||||
+ return 0;
|
||||
+
|
||||
+ rc = of_property_read_string(nc, "spi-cal-mode", &cal_mode);
|
||||
+ if(!rc) {
|
||||
+ if(strcmp("read-data", cal_mode) == 0){
|
||||
+ ctlr->cal_rule->mode = SPI_CAL_READ_DATA;
|
||||
+ } else if(strcmp("read-pp", cal_mode) == 0) {
|
||||
+ ctlr->cal_rule->mode = SPI_CAL_READ_PP;
|
||||
+ return 0;
|
||||
+ } else if(strcmp("read-sfdp", cal_mode) == 0){
|
||||
+ ctlr->cal_rule->mode = SPI_CAL_READ_SFDP;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ } else
|
||||
+ goto err;
|
||||
+
|
||||
+ ctlr->cal_rule->datalen = 0;
|
||||
+ rc = of_property_read_u32(nc, "spi-cal-datalen", &value);
|
||||
+ if(!rc && value > 0) {
|
||||
+ ctlr->cal_rule->datalen = value;
|
||||
+
|
||||
+ ctlr->cal_rule->match_data = kzalloc(value * sizeof(u8), GFP_KERNEL);
|
||||
+ rc = of_property_read_u8_array(nc, "spi-cal-data",
|
||||
+ ctlr->cal_rule->match_data, value);
|
||||
+ if(rc)
|
||||
+ kfree(ctlr->cal_rule->match_data);
|
||||
+ }
|
||||
+
|
||||
+ rc = of_property_read_u32(nc, "spi-cal-addrlen", &value);
|
||||
+ if(!rc && value > 0) {
|
||||
+ ctlr->cal_rule->addrlen = value;
|
||||
+
|
||||
+ ctlr->cal_rule->addr = kzalloc(value * sizeof(u32), GFP_KERNEL);
|
||||
+ rc = of_property_read_u32_array(nc, "spi-cal-addr",
|
||||
+ ctlr->cal_rule->addr, value);
|
||||
+ if(rc)
|
||||
+ kfree(ctlr->cal_rule->addr);
|
||||
+ }
|
||||
+ return 0;
|
||||
+
|
||||
+err:
|
||||
+ alloc_cal_data(&ctlr->cal_target, &ctlr->cal_rule, false);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void of_spi_parse_dt_cs_delay(struct device_node *nc,
|
||||
struct spi_delay *delay, const char *prop)
|
||||
{
|
||||
@@ -2337,6 +2470,10 @@ of_register_spi_device(struct spi_contro
|
||||
if (rc)
|
||||
goto err_out;
|
||||
|
||||
+ rc = of_spi_parse_cal_dt(ctlr, spi, nc);
|
||||
+ if (rc)
|
||||
+ goto err_out;
|
||||
+
|
||||
/* Store a pointer to the node in the device structure */
|
||||
of_node_get(nc);
|
||||
spi->dev.of_node = nc;
|
||||
--- a/include/linux/spi/spi.h
|
||||
+++ b/include/linux/spi/spi.h
|
||||
@@ -318,6 +318,40 @@ struct spi_driver {
|
||||
struct device_driver driver;
|
||||
};
|
||||
|
||||
+enum {
|
||||
+ SPI_CAL_READ_DATA = 0,
|
||||
+ SPI_CAL_READ_PP = 1, /* only for SPI-NAND */
|
||||
+ SPI_CAL_READ_SFDP = 2, /* only for SPI-NOR */
|
||||
+};
|
||||
+
|
||||
+struct nand_addr {
|
||||
+ unsigned int lun;
|
||||
+ unsigned int plane;
|
||||
+ unsigned int eraseblock;
|
||||
+ unsigned int page;
|
||||
+ unsigned int dataoffs;
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * Read calibration rule from device dts node.
|
||||
+ * Once calibration result matches the rule, we regard is as success.
|
||||
+ */
|
||||
+struct spi_cal_rule {
|
||||
+ int datalen;
|
||||
+ u8 *match_data;
|
||||
+ int addrlen;
|
||||
+ u32 *addr;
|
||||
+ int mode;
|
||||
+};
|
||||
+
|
||||
+struct spi_cal_target {
|
||||
+ u32 *cal_item;
|
||||
+ int cal_min; /* min of cal_item */
|
||||
+ int cal_max; /* max of cal_item */
|
||||
+ int step; /* Increase/decrease cal_item */
|
||||
+ struct list_head list;
|
||||
+};
|
||||
+
|
||||
static inline struct spi_driver *to_spi_driver(struct device_driver *drv)
|
||||
{
|
||||
return drv ? container_of(drv, struct spi_driver, driver) : NULL;
|
||||
@@ -703,6 +737,11 @@ struct spi_controller {
|
||||
void *dummy_rx;
|
||||
void *dummy_tx;
|
||||
|
||||
+ /* For calibration */
|
||||
+ int (*append_caldata)(struct spi_controller *ctlr);
|
||||
+ struct list_head *cal_target;
|
||||
+ struct spi_cal_rule *cal_rule;
|
||||
+
|
||||
int (*fw_translate_cs)(struct spi_controller *ctlr, unsigned cs);
|
||||
|
||||
/*
|
||||
@@ -1510,7 +1549,10 @@ spi_register_board_info(struct spi_board
|
||||
{ return 0; }
|
||||
#endif
|
||||
|
||||
+extern int spi_do_calibration(struct spi_controller *ctlr,
|
||||
+ struct spi_device *spi, int (*cal_read)(void *, u32 *, int, u8 *, int), void *drv_priv);
|
||||
+
|
||||
/*
|
||||
* If you're hotplugging an adapter with devices (parport, USB, etc)
|
||||
* use spi_new_device() to describe each device. You can also call
|
||||
* spi_unregister_device() to start making that device vanish, but
|
|
@ -0,0 +1,41 @@
|
|||
From 06640a5da2973318c06e516da16a5b579622e7c5 Mon Sep 17 00:00:00 2001
|
||||
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
||||
Date: Thu, 23 Jun 2022 18:37:55 +0800
|
||||
Subject: [PATCH 3/6] drivers: spi-mem: Add spi calibration hook
|
||||
|
||||
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
||||
---
|
||||
drivers/spi/spi-mem.c | 8 ++++++++
|
||||
include/linux/spi/spi-mem.h | 4 ++++
|
||||
2 files changed, 12 insertions(+)
|
||||
|
||||
--- a/drivers/spi/spi-mem.c
|
||||
+++ b/drivers/spi/spi-mem.c
|
||||
@@ -419,6 +419,14 @@ int spi_mem_exec_op(struct spi_mem *mem,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spi_mem_exec_op);
|
||||
|
||||
+int spi_mem_do_calibration(struct spi_mem *mem,
|
||||
+ int (*cal_read)(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen),
|
||||
+ void *priv)
|
||||
+{
|
||||
+ return spi_do_calibration(mem->spi->controller, mem->spi, cal_read, priv);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(spi_mem_do_calibration);
|
||||
+
|
||||
/**
|
||||
* spi_mem_get_name() - Return the SPI mem device name to be used by the
|
||||
* upper layer if necessary
|
||||
--- a/include/linux/spi/spi-mem.h
|
||||
+++ b/include/linux/spi/spi-mem.h
|
||||
@@ -366,6 +366,10 @@ bool spi_mem_supports_op(struct spi_mem
|
||||
int spi_mem_exec_op(struct spi_mem *mem,
|
||||
const struct spi_mem_op *op);
|
||||
|
||||
+int spi_mem_do_calibration(struct spi_mem *mem,
|
||||
+ int (*cal_read)(void *, u32 *, int, u8 *, int),
|
||||
+ void *priv);
|
||||
+
|
||||
const char *spi_mem_get_name(struct spi_mem *mem);
|
||||
|
||||
struct spi_mem_dirmap_desc *
|
|
@ -0,0 +1,43 @@
|
|||
From d278c7a0bf730318a7ccf8d0a8b434c813e23fd0 Mon Sep 17 00:00:00 2001
|
||||
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
||||
Date: Thu, 23 Jun 2022 18:39:03 +0800
|
||||
Subject: [PATCH 4/6] drivers: spi-mt65xx: Add controller's calibration
|
||||
paramter
|
||||
|
||||
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
||||
---
|
||||
drivers/spi/spi-mt65xx.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
--- a/drivers/spi/spi-mt65xx.c
|
||||
+++ b/drivers/spi/spi-mt65xx.c
|
||||
@@ -832,6 +832,21 @@ static irqreturn_t mtk_spi_interrupt(int
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
+static int mtk_spi_append_caldata(struct spi_controller *ctlr)
|
||||
+{
|
||||
+ struct spi_cal_target *cal_target = kmalloc(sizeof(*cal_target), GFP_KERNEL);
|
||||
+ struct mtk_spi *mdata = spi_master_get_devdata(ctlr);
|
||||
+
|
||||
+ cal_target->cal_item = &mdata->get_tick_dly;
|
||||
+ cal_target->cal_min = 0;
|
||||
+ cal_target->cal_max = 7;
|
||||
+ cal_target->step = 1;
|
||||
+
|
||||
+ list_add(&cal_target->list, ctlr->cal_target);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int mtk_spi_mem_adjust_op_size(struct spi_mem *mem,
|
||||
struct spi_mem_op *op)
|
||||
{
|
||||
@@ -1122,6 +1137,7 @@ static int mtk_spi_probe(struct platform
|
||||
master->setup = mtk_spi_setup;
|
||||
master->set_cs_timing = mtk_spi_set_hw_cs_timing;
|
||||
master->use_gpio_descriptors = true;
|
||||
+ master->append_caldata = mtk_spi_append_caldata;
|
||||
|
||||
mdata = spi_master_get_devdata(master);
|
||||
mdata->dev_comp = device_get_match_data(dev);
|
|
@ -0,0 +1,81 @@
|
|||
From 7670ec4a14891a1a182b98a9c403ffbf6b49e4b1 Mon Sep 17 00:00:00 2001
|
||||
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
||||
Date: Thu, 23 Jun 2022 18:39:56 +0800
|
||||
Subject: [PATCH 5/6] drivers: mtd: spinand: Add calibration support for
|
||||
spinand
|
||||
|
||||
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
||||
---
|
||||
drivers/mtd/nand/spi/core.c | 54 +++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 54 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/nand/spi/core.c
|
||||
+++ b/drivers/mtd/nand/spi/core.c
|
||||
@@ -978,6 +978,56 @@ static int spinand_manufacturer_match(st
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
+int spinand_cal_read(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen) {
|
||||
+ struct spinand_device *spinand = (struct spinand_device *)priv;
|
||||
+ struct device *dev = &spinand->spimem->spi->dev;
|
||||
+ struct spi_mem_op op = SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, buf, readlen);
|
||||
+ struct nand_pos pos;
|
||||
+ struct nand_page_io_req req;
|
||||
+ u8 status;
|
||||
+ int ret;
|
||||
+
|
||||
+ if(addrlen != sizeof(struct nand_addr)/sizeof(unsigned int)) {
|
||||
+ dev_err(dev, "Must provide correct addr(length) for spinand calibration\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ ret = spinand_reset_op(spinand);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* We should store our golden data in first target because
|
||||
+ * we can't switch target at this moment.
|
||||
+ */
|
||||
+ pos = (struct nand_pos){
|
||||
+ .target = 0,
|
||||
+ .lun = *addr,
|
||||
+ .plane = *(addr+1),
|
||||
+ .eraseblock = *(addr+2),
|
||||
+ .page = *(addr+3),
|
||||
+ };
|
||||
+
|
||||
+ req = (struct nand_page_io_req){
|
||||
+ .pos = pos,
|
||||
+ .dataoffs = *(addr+4),
|
||||
+ .datalen = readlen,
|
||||
+ .databuf.in = buf,
|
||||
+ .mode = MTD_OPS_AUTO_OOB,
|
||||
+ };
|
||||
+
|
||||
+ ret = spinand_load_page_op(spinand, &req);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = spinand_wait(spinand, &status);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = spi_mem_exec_op(spinand->spimem, &op);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int spinand_id_detect(struct spinand_device *spinand)
|
||||
{
|
||||
u8 *id = spinand->id.data;
|
||||
@@ -1228,6 +1278,10 @@ static int spinand_init(struct spinand_d
|
||||
if (!spinand->scratchbuf)
|
||||
return -ENOMEM;
|
||||
|
||||
+ ret = spi_mem_do_calibration(spinand->spimem, spinand_cal_read, spinand);
|
||||
+ if (ret)
|
||||
+ dev_err(dev, "Failed to calibrate SPI-NAND (err = %d)\n", ret);
|
||||
+
|
||||
ret = spinand_detect(spinand);
|
||||
if (ret)
|
||||
goto err_free_bufs;
|
|
@ -0,0 +1,57 @@
|
|||
From f3fe3b15eca7908eaac57f9b8387a5dbc45ec5b2 Mon Sep 17 00:00:00 2001
|
||||
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
||||
Date: Thu, 23 Jun 2022 18:40:59 +0800
|
||||
Subject: [PATCH 6/6] drivers: mtd: spi-nor: Add calibration support for
|
||||
spi-nor
|
||||
|
||||
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
||||
---
|
||||
drivers/mtd/nand/spi/core.c | 5 ++++-
|
||||
drivers/mtd/spi-nor/core.c | 15 +++++++++++++++
|
||||
2 files changed, 19 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/mtd/nand/spi/core.c
|
||||
+++ b/drivers/mtd/nand/spi/core.c
|
||||
@@ -1019,7 +1019,10 @@ int spinand_cal_read(void *priv, u32 *ad
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- ret = spinand_wait(spinand, &status);
|
||||
+ ret = spinand_wait(spinand,
|
||||
+ SPINAND_READ_INITIAL_DELAY_US,
|
||||
+ SPINAND_READ_POLL_DELAY_US,
|
||||
+ &status);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
--- a/drivers/mtd/spi-nor/core.c
|
||||
+++ b/drivers/mtd/spi-nor/core.c
|
||||
@@ -2900,6 +2900,18 @@ static const struct flash_info *spi_nor_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+static int spi_nor_cal_read(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen)
|
||||
+{
|
||||
+ struct spi_nor *nor = (struct spi_nor *)priv;
|
||||
+
|
||||
+ nor->reg_proto = SNOR_PROTO_1_1_1;
|
||||
+ nor->read_proto = SNOR_PROTO_1_1_1;
|
||||
+ nor->read_opcode = SPINOR_OP_READ;
|
||||
+ nor->read_dummy = 0;
|
||||
+
|
||||
+ return nor->controller_ops->read(nor, *addr, readlen, buf);
|
||||
+}
|
||||
+
|
||||
static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
|
||||
const char *name)
|
||||
{
|
||||
@@ -3003,6 +3015,9 @@ int spi_nor_scan(struct spi_nor *nor, co
|
||||
if (!nor->bouncebuf)
|
||||
return -ENOMEM;
|
||||
|
||||
+ if(nor->spimem)
|
||||
+ spi_mem_do_calibration(nor->spimem, spi_nor_cal_read, nor);
|
||||
+
|
||||
info = spi_nor_get_flash_info(nor, name);
|
||||
if (IS_ERR(info))
|
||||
return PTR_ERR(info);
|
|
@ -0,0 +1,599 @@
|
|||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 2 Nov 2023 16:47:07 +0100
|
||||
Subject: [PATCH net-next 1/2] net: ethernet: mediatek: split tx and rx fields
|
||||
in mtk_soc_data struct
|
||||
|
||||
Split tx and rx fields in mtk_soc_data struct. This is a preliminary
|
||||
patch to roll back to QDMA for MT7986 SoC in order to fix a hw hang
|
||||
if the device receives a corrupted packet.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 210 ++++++++++++--------
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 29 +--
|
||||
2 files changed, 139 insertions(+), 100 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -1238,7 +1238,7 @@ 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->txrx.txd_size,
|
||||
+ cnt * soc->tx.desc_size,
|
||||
ð->phy_scratch_ring,
|
||||
GFP_KERNEL);
|
||||
if (unlikely(!eth->scratch_ring))
|
||||
@@ -1254,16 +1254,16 @@ static int mtk_init_fq_dma(struct mtk_et
|
||||
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
|
||||
return -ENOMEM;
|
||||
|
||||
- phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt - 1);
|
||||
+ phy_ring_tail = eth->phy_scratch_ring + soc->tx.desc_size * (cnt - 1);
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
struct mtk_tx_dma_v2 *txd;
|
||||
|
||||
- txd = eth->scratch_ring + i * soc->txrx.txd_size;
|
||||
+ txd = eth->scratch_ring + i * soc->tx.desc_size;
|
||||
txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE;
|
||||
if (i < cnt - 1)
|
||||
txd->txd2 = eth->phy_scratch_ring +
|
||||
- (i + 1) * soc->txrx.txd_size;
|
||||
+ (i + 1) * soc->tx.desc_size;
|
||||
|
||||
txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE);
|
||||
txd->txd4 = 0;
|
||||
@@ -1512,7 +1512,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
||||
if (itxd == ring->last_free)
|
||||
return -ENOMEM;
|
||||
|
||||
- itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size);
|
||||
+ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_size);
|
||||
memset(itx_buf, 0, sizeof(*itx_buf));
|
||||
|
||||
txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size,
|
||||
@@ -1553,7 +1553,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
||||
|
||||
memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info));
|
||||
txd_info.size = min_t(unsigned int, frag_size,
|
||||
- soc->txrx.dma_max_len);
|
||||
+ soc->tx.dma_max_len);
|
||||
txd_info.qid = queue;
|
||||
txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 &&
|
||||
!(frag_size - txd_info.size);
|
||||
@@ -1566,7 +1566,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,
|
||||
- soc->txrx.txd_size);
|
||||
+ soc->tx.desc_size);
|
||||
if (new_desc)
|
||||
memset(tx_buf, 0, sizeof(*tx_buf));
|
||||
tx_buf->data = (void *)MTK_DMA_DUMMY_DESC;
|
||||
@@ -1609,7 +1609,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
||||
} else {
|
||||
int next_idx;
|
||||
|
||||
- next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->txrx.txd_size),
|
||||
+ next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->tx.desc_size),
|
||||
ring->dma_size);
|
||||
mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0);
|
||||
}
|
||||
@@ -1618,7 +1618,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
||||
|
||||
err_dma:
|
||||
do {
|
||||
- tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size);
|
||||
+ tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_size);
|
||||
|
||||
/* unmap dma */
|
||||
mtk_tx_unmap(eth, tx_buf, NULL, false);
|
||||
@@ -1643,7 +1643,7 @@ static int mtk_cal_txd_req(struct mtk_et
|
||||
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
|
||||
frag = &skb_shinfo(skb)->frags[i];
|
||||
nfrags += DIV_ROUND_UP(skb_frag_size(frag),
|
||||
- eth->soc->txrx.dma_max_len);
|
||||
+ eth->soc->tx.dma_max_len);
|
||||
}
|
||||
} else {
|
||||
nfrags += skb_shinfo(skb)->nr_frags;
|
||||
@@ -1784,7 +1784,7 @@ static struct mtk_rx_ring *mtk_get_rx_ri
|
||||
|
||||
ring = ð->rx_ring[i];
|
||||
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
|
||||
- rxd = ring->dma + idx * eth->soc->txrx.rxd_size;
|
||||
+ rxd = ring->dma + idx * eth->soc->rx.desc_size;
|
||||
if (rxd->rxd2 & RX_DMA_DONE) {
|
||||
ring->calc_idx_update = true;
|
||||
return ring;
|
||||
@@ -1952,7 +1952,7 @@ static int mtk_xdp_submit_frame(struct m
|
||||
}
|
||||
htxd = txd;
|
||||
|
||||
- tx_buf = mtk_desc_to_tx_buf(ring, txd, soc->txrx.txd_size);
|
||||
+ tx_buf = mtk_desc_to_tx_buf(ring, txd, soc->tx.desc_size);
|
||||
memset(tx_buf, 0, sizeof(*tx_buf));
|
||||
htx_buf = tx_buf;
|
||||
|
||||
@@ -1971,7 +1971,7 @@ static int mtk_xdp_submit_frame(struct m
|
||||
goto unmap;
|
||||
|
||||
tx_buf = mtk_desc_to_tx_buf(ring, txd,
|
||||
- soc->txrx.txd_size);
|
||||
+ soc->tx.desc_size);
|
||||
memset(tx_buf, 0, sizeof(*tx_buf));
|
||||
n_desc++;
|
||||
}
|
||||
@@ -2009,7 +2009,7 @@ static int mtk_xdp_submit_frame(struct m
|
||||
} else {
|
||||
int idx;
|
||||
|
||||
- idx = txd_to_idx(ring, txd, soc->txrx.txd_size);
|
||||
+ idx = txd_to_idx(ring, txd, soc->tx.desc_size);
|
||||
mtk_w32(eth, NEXT_DESP_IDX(idx, ring->dma_size),
|
||||
MT7628_TX_CTX_IDX0);
|
||||
}
|
||||
@@ -2020,7 +2020,7 @@ static int mtk_xdp_submit_frame(struct m
|
||||
|
||||
unmap:
|
||||
while (htxd != txd) {
|
||||
- tx_buf = mtk_desc_to_tx_buf(ring, htxd, soc->txrx.txd_size);
|
||||
+ tx_buf = mtk_desc_to_tx_buf(ring, htxd, soc->tx.desc_size);
|
||||
mtk_tx_unmap(eth, tx_buf, NULL, false);
|
||||
|
||||
htxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
|
||||
@@ -2151,7 +2151,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
goto rx_done;
|
||||
|
||||
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size);
|
||||
- rxd = ring->dma + idx * eth->soc->txrx.rxd_size;
|
||||
+ rxd = ring->dma + idx * eth->soc->rx.desc_size;
|
||||
data = ring->data[idx];
|
||||
|
||||
if (!mtk_rx_get_desc(eth, &trxd, rxd))
|
||||
@@ -2286,7 +2286,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
rxdcsum = &trxd.rxd4;
|
||||
}
|
||||
|
||||
- if (*rxdcsum & eth->soc->txrx.rx_dma_l4_valid)
|
||||
+ if (*rxdcsum & eth->soc->rx.dma_l4_valid)
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
else
|
||||
skb_checksum_none_assert(skb);
|
||||
@@ -2410,7 +2410,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
|
||||
break;
|
||||
|
||||
tx_buf = mtk_desc_to_tx_buf(ring, desc,
|
||||
- eth->soc->txrx.txd_size);
|
||||
+ eth->soc->tx.desc_size);
|
||||
if (!tx_buf->data)
|
||||
break;
|
||||
|
||||
@@ -2461,7 +2461,7 @@ static int mtk_poll_tx_pdma(struct mtk_e
|
||||
}
|
||||
mtk_tx_unmap(eth, tx_buf, &bq, true);
|
||||
|
||||
- desc = ring->dma + cpu * eth->soc->txrx.txd_size;
|
||||
+ desc = ring->dma + cpu * eth->soc->tx.desc_size;
|
||||
ring->last_free = desc;
|
||||
atomic_inc(&ring->free_count);
|
||||
|
||||
@@ -2551,7 +2551,7 @@ static int mtk_napi_rx(struct napi_struc
|
||||
do {
|
||||
int rx_done;
|
||||
|
||||
- mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask,
|
||||
+ mtk_w32(eth, eth->soc->rx.irq_done_mask,
|
||||
reg_map->pdma.irq_status);
|
||||
rx_done = mtk_poll_rx(napi, budget - rx_done_total, eth);
|
||||
rx_done_total += rx_done;
|
||||
@@ -2567,10 +2567,10 @@ static int mtk_napi_rx(struct napi_struc
|
||||
return budget;
|
||||
|
||||
} while (mtk_r32(eth, reg_map->pdma.irq_status) &
|
||||
- eth->soc->txrx.rx_irq_done_mask);
|
||||
+ eth->soc->rx.irq_done_mask);
|
||||
|
||||
if (napi_complete_done(napi, rx_done_total))
|
||||
- mtk_rx_irq_enable(eth, eth->soc->txrx.rx_irq_done_mask);
|
||||
+ mtk_rx_irq_enable(eth, eth->soc->rx.irq_done_mask);
|
||||
|
||||
return rx_done_total;
|
||||
}
|
||||
@@ -2579,7 +2579,7 @@ static int mtk_tx_alloc(struct mtk_eth *
|
||||
{
|
||||
const struct mtk_soc_data *soc = eth->soc;
|
||||
struct mtk_tx_ring *ring = ð->tx_ring;
|
||||
- int i, sz = soc->txrx.txd_size;
|
||||
+ int i, sz = soc->tx.desc_size;
|
||||
struct mtk_tx_dma_v2 *txd;
|
||||
int ring_size;
|
||||
u32 ofs, val;
|
||||
@@ -2702,14 +2702,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->txrx.txd_size,
|
||||
+ ring->dma_size * soc->tx.desc_size,
|
||||
ring->dma, ring->phys);
|
||||
ring->dma = NULL;
|
||||
}
|
||||
|
||||
if (ring->dma_pdma) {
|
||||
dma_free_coherent(eth->dma_dev,
|
||||
- ring->dma_size * soc->txrx.txd_size,
|
||||
+ ring->dma_size * soc->tx.desc_size,
|
||||
ring->dma_pdma, ring->phys_pdma);
|
||||
ring->dma_pdma = NULL;
|
||||
}
|
||||
@@ -2764,15 +2764,15 @@ 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->txrx.rxd_size,
|
||||
- &ring->phys, GFP_KERNEL);
|
||||
+ rx_dma_size * eth->soc->rx.desc_size,
|
||||
+ &ring->phys, GFP_KERNEL);
|
||||
} else {
|
||||
struct mtk_tx_ring *tx_ring = ð->tx_ring;
|
||||
|
||||
ring->dma = tx_ring->dma + tx_ring_size *
|
||||
- eth->soc->txrx.txd_size * (ring_no + 1);
|
||||
+ eth->soc->tx.desc_size * (ring_no + 1);
|
||||
ring->phys = tx_ring->phys + tx_ring_size *
|
||||
- eth->soc->txrx.txd_size * (ring_no + 1);
|
||||
+ eth->soc->tx.desc_size * (ring_no + 1);
|
||||
}
|
||||
|
||||
if (!ring->dma)
|
||||
@@ -2783,7 +2783,7 @@ static int mtk_rx_alloc(struct mtk_eth *
|
||||
dma_addr_t dma_addr;
|
||||
void *data;
|
||||
|
||||
- rxd = ring->dma + i * eth->soc->txrx.rxd_size;
|
||||
+ rxd = ring->dma + i * eth->soc->rx.desc_size;
|
||||
if (ring->page_pool) {
|
||||
data = mtk_page_pool_get_buff(ring->page_pool,
|
||||
&dma_addr, GFP_KERNEL);
|
||||
@@ -2874,7 +2874,7 @@ static void mtk_rx_clean(struct mtk_eth
|
||||
if (!ring->data[i])
|
||||
continue;
|
||||
|
||||
- rxd = ring->dma + i * eth->soc->txrx.rxd_size;
|
||||
+ rxd = ring->dma + i * eth->soc->rx.desc_size;
|
||||
if (!rxd->rxd1)
|
||||
continue;
|
||||
|
||||
@@ -2891,7 +2891,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->txrx.rxd_size,
|
||||
+ ring->dma_size * eth->soc->rx.desc_size,
|
||||
ring->dma, ring->phys);
|
||||
ring->dma = NULL;
|
||||
}
|
||||
@@ -3254,7 +3254,7 @@ static void mtk_dma_free(struct mtk_eth
|
||||
netdev_reset_queue(eth->netdev[i]);
|
||||
if (!MTK_HAS_CAPS(soc->caps, MTK_SRAM) && eth->scratch_ring) {
|
||||
dma_free_coherent(eth->dma_dev,
|
||||
- MTK_QDMA_RING_SIZE * soc->txrx.txd_size,
|
||||
+ MTK_QDMA_RING_SIZE * soc->tx.desc_size,
|
||||
eth->scratch_ring, eth->phy_scratch_ring);
|
||||
eth->scratch_ring = NULL;
|
||||
eth->phy_scratch_ring = 0;
|
||||
@@ -3304,7 +3304,7 @@ static irqreturn_t mtk_handle_irq_rx(int
|
||||
|
||||
eth->rx_events++;
|
||||
if (likely(napi_schedule_prep(ð->rx_napi))) {
|
||||
- mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask);
|
||||
+ mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask);
|
||||
__napi_schedule(ð->rx_napi);
|
||||
}
|
||||
|
||||
@@ -3330,9 +3330,9 @@ static irqreturn_t mtk_handle_irq(int ir
|
||||
const struct mtk_reg_map *reg_map = eth->soc->reg_map;
|
||||
|
||||
if (mtk_r32(eth, reg_map->pdma.irq_mask) &
|
||||
- eth->soc->txrx.rx_irq_done_mask) {
|
||||
+ eth->soc->rx.irq_done_mask) {
|
||||
if (mtk_r32(eth, reg_map->pdma.irq_status) &
|
||||
- eth->soc->txrx.rx_irq_done_mask)
|
||||
+ eth->soc->rx.irq_done_mask)
|
||||
mtk_handle_irq_rx(irq, _eth);
|
||||
}
|
||||
if (mtk_r32(eth, reg_map->tx_irq_mask) & MTK_TX_DONE_INT) {
|
||||
@@ -3350,10 +3350,10 @@ static void mtk_poll_controller(struct n
|
||||
struct mtk_eth *eth = mac->hw;
|
||||
|
||||
mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
|
||||
- mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask);
|
||||
+ mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask);
|
||||
mtk_handle_irq_rx(eth->irq[2], dev);
|
||||
mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
|
||||
- mtk_rx_irq_enable(eth, eth->soc->txrx.rx_irq_done_mask);
|
||||
+ mtk_rx_irq_enable(eth, eth->soc->rx.irq_done_mask);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3516,7 +3516,7 @@ static int mtk_open(struct net_device *d
|
||||
napi_enable(ð->tx_napi);
|
||||
napi_enable(ð->rx_napi);
|
||||
mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
|
||||
- mtk_rx_irq_enable(eth, soc->txrx.rx_irq_done_mask);
|
||||
+ mtk_rx_irq_enable(eth, soc->rx.irq_done_mask);
|
||||
refcount_set(ð->dma_refcnt, 1);
|
||||
}
|
||||
else
|
||||
@@ -3599,7 +3599,7 @@ static int mtk_stop(struct net_device *d
|
||||
mtk_gdm_config(eth, MTK_GDMA_DROP_ALL);
|
||||
|
||||
mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
|
||||
- mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask);
|
||||
+ mtk_rx_irq_disable(eth, eth->soc->rx.irq_done_mask);
|
||||
napi_disable(ð->tx_napi);
|
||||
napi_disable(ð->rx_napi);
|
||||
|
||||
@@ -4075,9 +4075,9 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
|
||||
/* FE int grouping */
|
||||
mtk_w32(eth, MTK_TX_DONE_INT, reg_map->pdma.int_grp);
|
||||
- mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, reg_map->pdma.int_grp + 4);
|
||||
+ mtk_w32(eth, eth->soc->rx.irq_done_mask, reg_map->pdma.int_grp + 4);
|
||||
mtk_w32(eth, MTK_TX_DONE_INT, reg_map->qdma.int_grp);
|
||||
- mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, reg_map->qdma.int_grp + 4);
|
||||
+ mtk_w32(eth, eth->soc->rx.irq_done_mask, reg_map->qdma.int_grp + 4);
|
||||
mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP);
|
||||
|
||||
if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
@@ -5172,11 +5172,15 @@ static const struct mtk_soc_data mt2701_
|
||||
.required_clks = MT7623_CLKS_BITMAP,
|
||||
.required_pctl = true,
|
||||
.version = 1,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
+ .dma_l4_valid = RX_DMA_L4_VALID,
|
||||
.dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
.dma_len_offset = 16,
|
||||
},
|
||||
@@ -5192,11 +5196,15 @@ static const struct mtk_soc_data mt7621_
|
||||
.offload_version = 1,
|
||||
.hash_offset = 2,
|
||||
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
+ .dma_l4_valid = RX_DMA_L4_VALID,
|
||||
.dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
.dma_len_offset = 16,
|
||||
},
|
||||
@@ -5214,11 +5222,15 @@ static const struct mtk_soc_data mt7622_
|
||||
.hash_offset = 2,
|
||||
.has_accounting = true,
|
||||
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
+ .dma_l4_valid = RX_DMA_L4_VALID,
|
||||
.dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
.dma_len_offset = 16,
|
||||
},
|
||||
@@ -5235,11 +5247,15 @@ static const struct mtk_soc_data mt7623_
|
||||
.hash_offset = 2,
|
||||
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
|
||||
.disable_pll_modes = true,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
+ .dma_l4_valid = RX_DMA_L4_VALID,
|
||||
.dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
.dma_len_offset = 16,
|
||||
},
|
||||
@@ -5254,11 +5270,15 @@ static const struct mtk_soc_data mt7629_
|
||||
.required_pctl = false,
|
||||
.has_accounting = true,
|
||||
.version = 1,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
+ .dma_l4_valid = RX_DMA_L4_VALID,
|
||||
.dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
.dma_len_offset = 16,
|
||||
},
|
||||
@@ -5276,11 +5296,15 @@ static const struct mtk_soc_data mt7981_
|
||||
.hash_offset = 4,
|
||||
.has_accounting = true,
|
||||
.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma_v2),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma_v2),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT_V2,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID_V2,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma_v2),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
|
||||
+ .dma_len_offset = 8,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma_v2),
|
||||
+ .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,
|
||||
.dma_len_offset = 8,
|
||||
},
|
||||
@@ -5298,11 +5322,15 @@ static const struct mtk_soc_data mt7986_
|
||||
.hash_offset = 4,
|
||||
.has_accounting = true,
|
||||
.foe_entry_size = MTK_FOE_ENTRY_V2_SIZE,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma_v2),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma_v2),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT_V2,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID_V2,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma_v2),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
|
||||
+ .dma_len_offset = 8,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma_v2),
|
||||
+ .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,
|
||||
.dma_len_offset = 8,
|
||||
},
|
||||
@@ -5320,11 +5348,15 @@ static const struct mtk_soc_data mt7988_
|
||||
.hash_offset = 4,
|
||||
.has_accounting = true,
|
||||
.foe_entry_size = MTK_FOE_ENTRY_V3_SIZE,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma_v2),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma_v2),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT_V2,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID_V2,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma_v2),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
|
||||
+ .dma_len_offset = 8,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma_v2),
|
||||
+ .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,
|
||||
.dma_len_offset = 8,
|
||||
},
|
||||
@@ -5337,11 +5369,15 @@ static const struct mtk_soc_data rt5350_
|
||||
.required_clks = MT7628_CLKS_BITMAP,
|
||||
.required_pctl = false,
|
||||
.version = 1,
|
||||
- .txrx = {
|
||||
- .txd_size = sizeof(struct mtk_tx_dma),
|
||||
- .rxd_size = sizeof(struct mtk_rx_dma),
|
||||
- .rx_irq_done_mask = MTK_RX_DONE_INT,
|
||||
- .rx_dma_l4_valid = RX_DMA_L4_VALID_PDMA,
|
||||
+ .tx = {
|
||||
+ .desc_size = sizeof(struct mtk_tx_dma),
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
+ },
|
||||
+ .rx = {
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
+ .dma_l4_valid = RX_DMA_L4_VALID_PDMA,
|
||||
.dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
.dma_len_offset = 16,
|
||||
},
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -326,8 +326,8 @@
|
||||
/* QDMA descriptor txd3 */
|
||||
#define TX_DMA_OWNER_CPU BIT(31)
|
||||
#define TX_DMA_LS0 BIT(30)
|
||||
-#define TX_DMA_PLEN0(x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset)
|
||||
-#define TX_DMA_PLEN1(x) ((x) & eth->soc->txrx.dma_max_len)
|
||||
+#define TX_DMA_PLEN0(x) (((x) & eth->soc->tx.dma_max_len) << eth->soc->tx.dma_len_offset)
|
||||
+#define TX_DMA_PLEN1(x) ((x) & eth->soc->tx.dma_max_len)
|
||||
#define TX_DMA_SWC BIT(14)
|
||||
#define TX_DMA_PQID GENMASK(3, 0)
|
||||
#define TX_DMA_ADDR64_MASK GENMASK(3, 0)
|
||||
@@ -347,8 +347,8 @@
|
||||
/* QDMA descriptor rxd2 */
|
||||
#define RX_DMA_DONE BIT(31)
|
||||
#define RX_DMA_LSO BIT(30)
|
||||
-#define RX_DMA_PREP_PLEN0(x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset)
|
||||
-#define RX_DMA_GET_PLEN0(x) (((x) >> eth->soc->txrx.dma_len_offset) & eth->soc->txrx.dma_max_len)
|
||||
+#define RX_DMA_PREP_PLEN0(x) (((x) & eth->soc->rx.dma_max_len) << eth->soc->rx.dma_len_offset)
|
||||
+#define RX_DMA_GET_PLEN0(x) (((x) >> eth->soc->rx.dma_len_offset) & eth->soc->rx.dma_max_len)
|
||||
#define RX_DMA_VTAG BIT(15)
|
||||
#define RX_DMA_ADDR64_MASK GENMASK(3, 0)
|
||||
#if IS_ENABLED(CONFIG_64BIT)
|
||||
@@ -1279,10 +1279,9 @@ struct mtk_reg_map {
|
||||
* @foe_entry_size Foe table entry size.
|
||||
* @has_accounting Bool indicating support for accounting of
|
||||
* offloaded flows.
|
||||
- * @txd_size Tx DMA descriptor size.
|
||||
- * @rxd_size Rx DMA descriptor size.
|
||||
- * @rx_irq_done_mask Rx irq done register mask.
|
||||
- * @rx_dma_l4_valid Rx DMA valid register mask.
|
||||
+ * @desc_size Tx/Rx DMA descriptor size.
|
||||
+ * @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.
|
||||
* @dma_len_offset Tx/Rx DMA length field offset.
|
||||
*/
|
||||
@@ -1300,13 +1299,17 @@ struct mtk_soc_data {
|
||||
bool has_accounting;
|
||||
bool disable_pll_modes;
|
||||
struct {
|
||||
- u32 txd_size;
|
||||
- u32 rxd_size;
|
||||
- u32 rx_irq_done_mask;
|
||||
- u32 rx_dma_l4_valid;
|
||||
+ u32 desc_size;
|
||||
u32 dma_max_len;
|
||||
u32 dma_len_offset;
|
||||
- } txrx;
|
||||
+ } tx;
|
||||
+ struct {
|
||||
+ u32 desc_size;
|
||||
+ u32 irq_done_mask;
|
||||
+ u32 dma_l4_valid;
|
||||
+ u32 dma_max_len;
|
||||
+ u32 dma_len_offset;
|
||||
+ } rx;
|
||||
};
|
||||
|
||||
#define MTK_DMA_MONITOR_TIMEOUT msecs_to_jiffies(1000)
|
|
@ -0,0 +1,123 @@
|
|||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 10 Oct 2023 21:06:43 +0200
|
||||
Subject: [PATCH net-next 2/2] net: ethernet: mediatek: use QDMA instead of
|
||||
ADMAv2 on MT7981 and MT7986
|
||||
|
||||
ADMA is plagued by RX hangs which can't easily detected and happen upon
|
||||
receival of a corrupted package.
|
||||
Use QDMA just like on netsys v1 which is also still present and usable, and
|
||||
doesn't suffer from that problem.
|
||||
|
||||
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 46 ++++++++++-----------
|
||||
1 file changed, 23 insertions(+), 23 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -108,16 +108,16 @@ static const struct mtk_reg_map mt7986_r
|
||||
.tx_irq_mask = 0x461c,
|
||||
.tx_irq_status = 0x4618,
|
||||
.pdma = {
|
||||
- .rx_ptr = 0x6100,
|
||||
- .rx_cnt_cfg = 0x6104,
|
||||
- .pcrx_ptr = 0x6108,
|
||||
- .glo_cfg = 0x6204,
|
||||
- .rst_idx = 0x6208,
|
||||
- .delay_irq = 0x620c,
|
||||
- .irq_status = 0x6220,
|
||||
- .irq_mask = 0x6228,
|
||||
- .adma_rx_dbg0 = 0x6238,
|
||||
- .int_grp = 0x6250,
|
||||
+ .rx_ptr = 0x4100,
|
||||
+ .rx_cnt_cfg = 0x4104,
|
||||
+ .pcrx_ptr = 0x4108,
|
||||
+ .glo_cfg = 0x4204,
|
||||
+ .rst_idx = 0x4208,
|
||||
+ .delay_irq = 0x420c,
|
||||
+ .irq_status = 0x4220,
|
||||
+ .irq_mask = 0x4228,
|
||||
+ .adma_rx_dbg0 = 0x4238,
|
||||
+ .int_grp = 0x4250,
|
||||
},
|
||||
.qdma = {
|
||||
.qtx_cfg = 0x4400,
|
||||
@@ -1206,7 +1206,7 @@ static bool mtk_rx_get_desc(struct mtk_e
|
||||
rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
|
||||
rxd->rxd3 = READ_ONCE(dma_rxd->rxd3);
|
||||
rxd->rxd4 = READ_ONCE(dma_rxd->rxd4);
|
||||
- if (mtk_is_netsys_v2_or_greater(eth)) {
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
rxd->rxd5 = READ_ONCE(dma_rxd->rxd5);
|
||||
rxd->rxd6 = READ_ONCE(dma_rxd->rxd6);
|
||||
}
|
||||
@@ -2158,7 +2158,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
break;
|
||||
|
||||
/* find out which mac the packet come from. values start at 1 */
|
||||
- if (mtk_is_netsys_v2_or_greater(eth)) {
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
u32 val = RX_DMA_GET_SPORT_V2(trxd.rxd5);
|
||||
|
||||
switch (val) {
|
||||
@@ -2270,7 +2270,7 @@ static int mtk_poll_rx(struct napi_struc
|
||||
skb->dev = netdev;
|
||||
bytes += skb->len;
|
||||
|
||||
- if (mtk_is_netsys_v2_or_greater(eth)) {
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
reason = FIELD_GET(MTK_RXD5_PPE_CPU_REASON, trxd.rxd5);
|
||||
hash = trxd.rxd5 & MTK_RXD5_FOE_ENTRY;
|
||||
if (hash != MTK_RXD5_FOE_ENTRY)
|
||||
@@ -2820,7 +2820,7 @@ static int mtk_rx_alloc(struct mtk_eth *
|
||||
|
||||
rxd->rxd3 = 0;
|
||||
rxd->rxd4 = 0;
|
||||
- if (mtk_is_netsys_v2_or_greater(eth)) {
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
rxd->rxd5 = 0;
|
||||
rxd->rxd6 = 0;
|
||||
rxd->rxd7 = 0;
|
||||
@@ -4021,7 +4021,7 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
else
|
||||
mtk_hw_reset(eth);
|
||||
|
||||
- if (mtk_is_netsys_v2_or_greater(eth)) {
|
||||
+ if (mtk_is_netsys_v3_or_greater(eth)) {
|
||||
/* Set FE to PDMAv2 if necessary */
|
||||
val = mtk_r32(eth, MTK_FE_GLO_MISC);
|
||||
mtk_w32(eth, val | BIT(4), MTK_FE_GLO_MISC);
|
||||
@@ -5302,11 +5302,11 @@ static const struct mtk_soc_data mt7981_
|
||||
.dma_len_offset = 8,
|
||||
},
|
||||
.rx = {
|
||||
- .desc_size = sizeof(struct mtk_rx_dma_v2),
|
||||
- .irq_done_mask = MTK_RX_DONE_INT_V2,
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
.dma_l4_valid = RX_DMA_L4_VALID_V2,
|
||||
- .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
|
||||
- .dma_len_offset = 8,
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5328,11 +5328,11 @@ static const struct mtk_soc_data mt7986_
|
||||
.dma_len_offset = 8,
|
||||
},
|
||||
.rx = {
|
||||
- .desc_size = sizeof(struct mtk_rx_dma_v2),
|
||||
- .irq_done_mask = MTK_RX_DONE_INT_V2,
|
||||
+ .desc_size = sizeof(struct mtk_rx_dma),
|
||||
+ .irq_done_mask = MTK_RX_DONE_INT,
|
||||
.dma_l4_valid = RX_DMA_L4_VALID_V2,
|
||||
- .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
|
||||
- .dma_len_offset = 8,
|
||||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN,
|
||||
+ .dma_len_offset = 16,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in a new issue