forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
234 additions
and
14 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
target/linux/generic/hack-6.1/9909-net-phy-dp83848-leds-init.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- a/drivers/net/phy/dp83848.c | ||
+++ b/drivers/net/phy/dp83848.c | ||
@@ -16,6 +16,8 @@ | ||
/* Registers */ | ||
#define DP83848_MICR 0x11 /* MII Interrupt Control Register */ | ||
#define DP83848_MISR 0x12 /* MII Interrupt Status Register */ | ||
+#define DP83848_LEDCR 0x18 /* LED Direct Control Register */ | ||
+#define DP83848_PHYCR 0x19 /* PHY Control Register */ | ||
|
||
/* MICR Register Fields */ | ||
#define DP83848_MICR_INT_OE BIT(0) /* Interrupt Output Enable */ | ||
@@ -31,6 +33,10 @@ | ||
#define DP83848_MISR_ED_INT_EN BIT(6) /* Energy detect */ | ||
#define DP83848_MISR_LQM_INT_EN BIT(7) /* Link Quality Monitor */ | ||
|
||
+/* PHYCR Register Fields */ | ||
+#define DP83848_PHYCR_LED_CNFG BIT(5) /* LED Configuration */ | ||
+#define DP83848_PHYCR_FORCE_MDIX BIT(14) /* Force MDIX */ | ||
+ | ||
#define DP83848_INT_EN_MASK \ | ||
(DP83848_MISR_ANC_INT_EN | \ | ||
DP83848_MISR_DUP_INT_EN | \ | ||
@@ -109,6 +115,39 @@ | ||
return IRQ_HANDLED; | ||
} | ||
|
||
+static int ns_dp83848_config_init(struct phy_device *phydev) | ||
+{ | ||
+ int val; | ||
+ | ||
+ msleep(1); | ||
+ | ||
+ val = phy_read(phydev, MII_PHYSID1) << 16; | ||
+ val |= phy_read(phydev, MII_PHYSID2); | ||
+ phydev_info(phydev, "%s: phy_id: %x", __func__, val); | ||
+ if (val != NS_DP83848C_PHY_ID) | ||
+ return 0; | ||
+ | ||
+ val = phy_read(phydev, DP83848_PHYCR); | ||
+ if (val & DP83848_PHYCR_LED_CNFG) { | ||
+ phydev_info(phydev, "%s: fix led value: %x", __func__, val); | ||
+ val &= ~DP83848_PHYCR_LED_CNFG; | ||
+ // val |= DP83848_PHYCR_FORCE_MDIX; | ||
+ msleep(10); | ||
+ phy_write(phydev, DP83848_PHYCR, val); | ||
+ msleep(10); | ||
+ phy_write(phydev, DP83848_PHYCR, val); | ||
+ msleep(10); | ||
+ val = phy_read(phydev, DP83848_PHYCR); | ||
+ phydev_info(phydev, "%s: fixed led value: %x", __func__, val); | ||
+ // val = phy_read(phydev, DP83848_LEDCR); | ||
+ // phydev_info(phydev, "%s: led direct control value: %x", __func__, val); | ||
+ } else { | ||
+ phydev_info(phydev, "%s: led value: %x", __func__, val); | ||
+ } | ||
+ | ||
+ return 0; | ||
+} | ||
+ | ||
static int dp83848_config_init(struct phy_device *phydev) | ||
{ | ||
int val; | ||
@@ -153,7 +192,7 @@ | ||
DP83848_PHY_DRIVER(TI_DP83848C_PHY_ID, "TI DP83848C 10/100 Mbps PHY", | ||
NULL), | ||
DP83848_PHY_DRIVER(NS_DP83848C_PHY_ID, "NS DP83848C 10/100 Mbps PHY", | ||
- NULL), | ||
+ ns_dp83848_config_init), | ||
DP83848_PHY_DRIVER(TI_DP83620_PHY_ID, "TI DP83620 10/100 Mbps PHY", | ||
dp83848_config_init), | ||
DP83848_PHY_DRIVER(TLK10X_PHY_ID, "TI TLK10X 10/100 Mbps PHY", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- /dev/null | ||
+++ b/arch/arm/boot/dts/sun8i-t3-tlink-dly-t3v2.dtsi | ||
@@ -0,0 +1,536 @@ | ||
@@ -0,0 +1,534 @@ | ||
+/* | ||
+ * Copyright (C) 2021 Dirk Chang <[email protected]> | ||
+ * | ||
|
@@ -122,15 +122,13 @@ | |
+ phy-handle = <&emac_phy>; | ||
+ phy-supply = <®_dcdc1>; | ||
+ phy-mode = "mii"; | ||
+ reset-gpios = <&pio 7 27 GPIO_ACTIVE_LOW>; /* PH27 */ | ||
+ status = "okay"; | ||
+}; | ||
+ | ||
+&emac_mdio { | ||
+ status = "okay"; | ||
+ phy-supply = <®_dcdc1>; | ||
+ reset-gpios = <&pio 7 27 GPIO_ACTIVE_LOW>; /* PH27 */ | ||
+ reset-assert-us = <10000>; | ||
+ reset-deassert-us = <1000000>; | ||
+ allwinner,emac-fix-phy-id = <0x20005c90>; | ||
+ | ||
+ emac_phy: ethernet-phy@1 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
sun8i-r40-tlink-nano-a40i.dtb \ | ||
--- /dev/null | ||
+++ b/arch/arm/boot/dts/sun8i-r40-tlink-k2x.dts | ||
@@ -0,0 +1,623 @@ | ||
@@ -0,0 +1,624 @@ | ||
+/* | ||
+ * Copyright (C) 2022 Dirk Chang <[email protected]> | ||
+ * | ||
|
@@ -255,6 +255,7 @@ | |
+ phy-handle = <&emac_phy>; | ||
+ phy-supply = <®_vdd_io_3v3>; | ||
+ phy-mode = "mii"; | ||
+ reset-gpios = <&pio 7 27 GPIO_ACTIVE_LOW>; /* PH27 */ | ||
+ status = "okay"; | ||
+}; | ||
+ | ||
|
@@ -270,9 +271,9 @@ | |
+ motorcomm,led0 = <0x331>; | ||
+ motorcomm,led1 = <0x30>; | ||
+ | ||
+ reset-gpios = <&pio 7 27 GPIO_ACTIVE_LOW>; /* PH27 */ | ||
+ reset-assert-us = <10000>; | ||
+ reset-deassert-us = <1000000>; | ||
+ // reset-gpios = <&pio 7 27 GPIO_ACTIVE_LOW>; /* PH27 */ | ||
+ // reset-assert-us = <10000>; | ||
+ // reset-deassert-us = <1000000>; | ||
+ }; | ||
+}; | ||
+ | ||
|
96 changes: 96 additions & 0 deletions
96
target/linux/sunxi/patches-6.1/9900-sun8i-r40-second-ethernet-reset-when-open.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c | ||
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c | ||
@@ -21,6 +21,8 @@ | ||
#include <linux/mii.h> | ||
#include <linux/module.h> | ||
#include <linux/netdevice.h> | ||
+#include <linux/gpio.h> | ||
+#include <linux/of_gpio.h> | ||
#include <linux/of_address.h> | ||
#include <linux/of_irq.h> | ||
#include <linux/of_mdio.h> | ||
@@ -98,6 +100,7 @@ | ||
struct reset_control *reset; | ||
|
||
phy_interface_t phy_interface; | ||
+ int phyrst; | ||
struct dma_chan *rx_chan; | ||
phys_addr_t emac_rx_fifo; | ||
}; | ||
@@ -846,6 +849,16 @@ | ||
if (request_irq(dev->irq, &emac_interrupt, 0, dev->name, dev)) | ||
return -EAGAIN; | ||
|
||
+ if (gpio_is_valid(db->phyrst)) { | ||
+ dev_err(db->dev, "%s sun4i-emac reset gpio %d \n", __func__, db->phyrst); | ||
+ gpio_set_value(db->phyrst, 0); | ||
+ // msleep(300); | ||
+ udelay(200); | ||
+ gpio_set_value(db->phyrst, 1); | ||
+ udelay(200); | ||
+ // msleep(40); | ||
+ } | ||
+ | ||
/* Initialize EMAC board */ | ||
emac_reset(db); | ||
emac_init_device(dev); | ||
@@ -980,6 +993,7 @@ | ||
struct net_device *ndev; | ||
int ret = 0; | ||
const struct emac_quirks *quirks; | ||
+ enum of_gpio_flags flags; | ||
|
||
int alias_id; | ||
|
||
@@ -1053,6 +1067,32 @@ | ||
goto out_assert_reset; | ||
} | ||
|
||
+ db->phyrst = of_get_named_gpio_flags(pdev->dev.of_node, "reset-gpios", 0, | ||
+ &flags); | ||
+ if (gpio_is_valid(db->phyrst)) { | ||
+ | ||
+ flags = (flags == OF_GPIO_ACTIVE_LOW ? GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH); | ||
+ | ||
+ ret = devm_gpio_request_one(&pdev->dev, db->phyrst, flags, | ||
+ "sun4i_emac_reset"); | ||
+ if (ret) { | ||
+ dev_err(&pdev->dev, "failed to request reset gpio %d: %d\n", | ||
+ db->phyrst, ret);; | ||
+ | ||
+ goto out_assert_reset; | ||
+ } | ||
+ | ||
+ dev_err(&pdev->dev, "%s sun4i-emac reset gpio %d flags %d\n", | ||
+ __func__, db->phyrst, flags);; | ||
+ // msleep(20); | ||
+ gpio_set_value(db->phyrst, 0); | ||
+ udelay(200); | ||
+ // msleep(300); | ||
+ gpio_set_value(db->phyrst, 1); | ||
+ udelay(200); | ||
+ // msleep(40); | ||
+ } | ||
+ | ||
ret = sunxi_sram_claim(&pdev->dev); | ||
if (ret) { | ||
dev_err(&pdev->dev, "Error couldn't map SRAM to device\n"); | ||
@@ -1122,6 +1162,9 @@ | ||
out: | ||
dev_err(db->dev, "not found (%d).\n", ret); | ||
|
||
+ if (gpio_is_valid(db->phyrst)) | ||
+ gpio_free(db->phyrst); | ||
+ | ||
free_netdev(ndev); | ||
|
||
return ret; | ||
@@ -1143,6 +1186,8 @@ | ||
reset_control_assert(db->reset); | ||
irq_dispose_mapping(ndev->irq); | ||
iounmap(db->membase); | ||
+ if (gpio_is_valid(db->phyrst)) | ||
+ gpio_free(db->phyrst); | ||
free_netdev(ndev); | ||
|
||
dev_dbg(&pdev->dev, "released and freed device\n"); |
19 changes: 19 additions & 0 deletions
19
.../linux/sunxi/patches-6.1/9901-drivers-net-stmmac-sun8i-fix-double-disable-regulator.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | ||
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | ||
@@ -1045,8 +1045,14 @@ | ||
if (gmac->variant->soc_has_internal_phy) | ||
sun8i_dwmac_unpower_internal_phy(gmac); | ||
|
||
- regulator_disable(gmac->regulator_phy); | ||
- regulator_disable(gmac->regulator_phy_io); | ||
+ if (gmac->regulator_phy) { | ||
+ regulator_disable(gmac->regulator_phy); | ||
+ gmac->regulator_phy = NULL; | ||
+ } | ||
+ if (gmac->regulator_phy_io) { | ||
+ regulator_disable(gmac->regulator_phy_io); | ||
+ gmac->regulator_phy_io = NULL; | ||
+ } | ||
} | ||
|
||
static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable) |
35 changes: 35 additions & 0 deletions
35
...x/sunxi/patches-6.1/9902-net-stmmac-main-fix-dvr-remove-crash-when-mdio-init-failed.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h | ||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h | ||
@@ -324,6 +324,9 @@ | ||
/* XDP BPF Program */ | ||
unsigned long *af_xdp_zc_qps; | ||
struct bpf_prog *xdp_prog; | ||
+ | ||
+ /* For unregister_netdev crash */ | ||
+ int netdev_inited; | ||
}; | ||
|
||
enum stmmac_state { | ||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | ||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | ||
@@ -7479,6 +7479,7 @@ | ||
__func__, ret); | ||
goto error_netdev_register; | ||
} | ||
+ priv->netdev_inited = 1; | ||
|
||
#ifdef CONFIG_DEBUG_FS | ||
stmmac_init_fs(ndev); | ||
@@ -7529,8 +7530,10 @@ | ||
|
||
stmmac_stop_all_dma(priv); | ||
stmmac_mac_set(priv, priv->ioaddr, false); | ||
- netif_carrier_off(ndev); | ||
- unregister_netdev(ndev); | ||
+ if (priv->netdev_inited) { | ||
+ netif_carrier_off(ndev); | ||
+ unregister_netdev(ndev); | ||
+ } | ||
|
||
#ifdef CONFIG_DEBUG_FS | ||
stmmac_exit_fs(ndev); |