-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mediatek: add support for OpenEmbed SOM7981 (#12524)
* kernel: crypto: add atmel i2c hw accelerator support Signed-off-by: Tianling Shen <[email protected]> * kernel: add led act/polarity select for rtl8221 phy Signed-off-by: Tianling Shen <[email protected]> * mediatek: add support for OpenEmbed SOM7981 Hardware specification: SoC: MediaTek MT7981B 2x A53 Flash: 256 MiB SPI-NAND RAM: 0.5/1 GB DDR4 Ethernet: 1x 1GbE, 1x 2.5GbE (RTL8221B) WiFi: MediaTek MT7976C USB: 1x M.2 B-Key GPIO: 26-Pin header UART: 6 GND, 8 TX, 10 RX (in Pin header) Button: Reset Installation: The board comes with a third-party custom OpenWrt image, you can upload sysupgrade image via LuCI directly WITHOUT keeping configurations. Or power on the board with pressing reset button for 5 second, then visit http://192.168.1.1 and upload -factory.bin firmware. Signed-off-by: Tianling Shen <[email protected]> --------- Signed-off-by: Tianling Shen <[email protected]> Signed-off-by: Tianling Shen <[email protected]>
- Loading branch information
1 parent
9a4a925
commit 8061c8b
Showing
17 changed files
with
444 additions
and
45 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ Signed-off-by: David S. Miller <[email protected]> | |
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -1941,11 +1941,11 @@ static int mtk_poll_rx(struct napi_struc | ||
@@ -1940,11 +1940,11 @@ static int mtk_poll_rx(struct napi_struc | ||
u8 *data, *new_data; | ||
struct mtk_rx_dma_v2 *rxd, trxd; | ||
int done = 0, bytes = 0; | ||
|
@@ -32,7 +32,7 @@ Signed-off-by: David S. Miller <[email protected]> | |
u32 hash, reason; | ||
int mac = 0; | ||
|
||
@@ -2122,7 +2122,8 @@ release_desc: | ||
@@ -2121,7 +2121,8 @@ release_desc: | ||
else | ||
rxd->rxd2 = RX_DMA_PREP_PLEN0(ring->buf_size); | ||
|
||
|
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 |
---|---|---|
|
@@ -18,36 +18,55 @@ Signed-off-by: Yangyu Chen <[email protected]> | |
|
||
--- a/drivers/net/phy/realtek.c | ||
+++ b/drivers/net/phy/realtek.c | ||
@@ -66,6 +66,10 @@ | ||
@@ -66,6 +66,12 @@ | ||
#define RTL8221B_PHYCR1_ALDPS_EN BIT(2) | ||
#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12) | ||
|
||
+#define RTL8221B_NR_LEDS 3 | ||
+#define RTL8221B_LED_LINK_SELECT 0xd032 | ||
+#define RTL8221B_LED_LINK_SELECT_OFFSET 0x2 | ||
+#define RTL8221B_LED_ACT_SELECT 0xd040 | ||
+#define RTL8221B_LED_POLARITY_SELECT 0xd044 | ||
+ | ||
#define RTL8366RB_POWER_SAVE 0x15 | ||
#define RTL8366RB_POWER_SAVE_ON BIT(12) | ||
|
||
@@ -921,6 +925,28 @@ static irqreturn_t rtl9000a_handle_inter | ||
@@ -921,6 +927,45 @@ static irqreturn_t rtl9000a_handle_inter | ||
return IRQ_HANDLED; | ||
} | ||
|
||
+static int rtl8221b_config_led(struct phy_device *phydev) { | ||
+ struct device_node *node = phydev->mdio.dev.of_node; | ||
+ u32 link_select[RTL8221B_NR_LEDS]; | ||
+ u32 act_select, polarity_select; | ||
+ int i, val; | ||
+ | ||
+ val = of_property_read_u32_array(node, "realtek,led-link-select", | ||
+ val = of_property_read_u32_array(node, "realtek,led-link-select", | ||
+ link_select, RTL8221B_NR_LEDS); | ||
+ if (!val) { | ||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET, | ||
+ link_select[i]); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
+ } | ||
+ | ||
+ if (val) | ||
+ return 0; | ||
+ val = of_property_read_u32(node, "realtek,led-act-select", | ||
+ &act_select); | ||
+ if (!val) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_ACT_SELECT, act_select); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
+ | ||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET, | ||
+ link_select[i]); | ||
+ val = of_property_read_u32(node, "realtek,led-polarity-select", | ||
+ &polarity_select); | ||
+ if (!val) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_POLARITY_SELECT, polarity_select); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
|
@@ -58,7 +77,7 @@ Signed-off-by: Yangyu Chen <[email protected]> | |
static int rtl8221b_config_init(struct phy_device *phydev) | ||
{ | ||
u16 option_mode; | ||
@@ -968,7 +994,7 @@ static int rtl8221b_config_init(struct p | ||
@@ -968,7 +1013,7 @@ static int rtl8221b_config_init(struct p | ||
phy_read_mmd_poll_timeout(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, | ||
val, !(val & BIT(0)), 500, 100000, false); | ||
|
||
|
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 |
---|---|---|
|
@@ -18,36 +18,55 @@ Signed-off-by: Yangyu Chen <[email protected]> | |
|
||
--- a/drivers/net/phy/realtek.c | ||
+++ b/drivers/net/phy/realtek.c | ||
@@ -66,6 +66,10 @@ | ||
@@ -66,6 +66,12 @@ | ||
#define RTL8221B_PHYCR1_ALDPS_EN BIT(2) | ||
#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12) | ||
|
||
+#define RTL8221B_NR_LEDS 3 | ||
+#define RTL8221B_LED_LINK_SELECT 0xd032 | ||
+#define RTL8221B_LED_LINK_SELECT_OFFSET 0x2 | ||
+#define RTL8221B_LED_ACT_SELECT 0xd040 | ||
+#define RTL8221B_LED_POLARITY_SELECT 0xd044 | ||
+ | ||
#define RTL8366RB_POWER_SAVE 0x15 | ||
#define RTL8366RB_POWER_SAVE_ON BIT(12) | ||
|
||
@@ -932,6 +936,28 @@ static irqreturn_t rtl9000a_handle_inter | ||
@@ -932,6 +938,45 @@ static irqreturn_t rtl9000a_handle_inter | ||
return IRQ_HANDLED; | ||
} | ||
|
||
+static int rtl8221b_config_led(struct phy_device *phydev) { | ||
+ struct device_node *node = phydev->mdio.dev.of_node; | ||
+ u32 link_select[RTL8221B_NR_LEDS]; | ||
+ u32 act_select, polarity_select; | ||
+ int i, val; | ||
+ | ||
+ val = of_property_read_u32_array(node, "realtek,led-link-select", | ||
+ val = of_property_read_u32_array(node, "realtek,led-link-select", | ||
+ link_select, RTL8221B_NR_LEDS); | ||
+ if (!val) { | ||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET, | ||
+ link_select[i]); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
+ } | ||
+ | ||
+ if (val) | ||
+ return 0; | ||
+ val = of_property_read_u32(node, "realtek,led-act-select", | ||
+ &act_select); | ||
+ if (!val) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_ACT_SELECT, act_select); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
+ | ||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET, | ||
+ link_select[i]); | ||
+ val = of_property_read_u32(node, "realtek,led-polarity-select", | ||
+ &polarity_select); | ||
+ if (!val) { | ||
+ val = phy_write_mmd(phydev, RTL8221B_MMD_PHY_CTRL, | ||
+ RTL8221B_LED_POLARITY_SELECT, polarity_select); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
|
@@ -58,7 +77,7 @@ Signed-off-by: Yangyu Chen <[email protected]> | |
static int rtl8221b_config_init(struct phy_device *phydev) | ||
{ | ||
u16 option_mode; | ||
@@ -979,7 +1005,7 @@ static int rtl8221b_config_init(struct p | ||
@@ -979,7 +1024,7 @@ static int rtl8221b_config_init(struct p | ||
phy_read_mmd_poll_timeout(phydev, RTL8221B_MMD_SERDES_CTRL, 0x7587, | ||
val, !(val & BIT(0)), 500, 100000, false); | ||
|
||
|
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 |
---|---|---|
|
@@ -18,36 +18,55 @@ Signed-off-by: Yangyu Chen <[email protected]> | |
|
||
--- a/drivers/net/phy/realtek.c | ||
+++ b/drivers/net/phy/realtek.c | ||
@@ -86,6 +86,10 @@ | ||
@@ -86,6 +86,12 @@ | ||
#define RTL8221B_PHYCR1_ALDPS_EN BIT(2) | ||
#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12) | ||
|
||
+#define RTL8221B_NR_LEDS 3 | ||
+#define RTL8221B_LED_LINK_SELECT 0xd032 | ||
+#define RTL8221B_LED_LINK_SELECT_OFFSET 0x2 | ||
+#define RTL8221B_LED_ACT_SELECT 0xd040 | ||
+#define RTL8221B_LED_POLARITY_SELECT 0xd044 | ||
+ | ||
#define RTL8366RB_POWER_SAVE 0x15 | ||
#define RTL8366RB_POWER_SAVE_ON BIT(12) | ||
|
||
@@ -787,6 +791,28 @@ static int rtl822x_write_mmd(struct phy_ | ||
@@ -787,6 +793,45 @@ static int rtl822x_write_mmd(struct phy_ | ||
return ret; | ||
} | ||
|
||
+static int rtl822xb_config_led(struct phy_device *phydev) { | ||
+ struct device_node *node = phydev->mdio.dev.of_node; | ||
+ u32 link_select[RTL8221B_NR_LEDS]; | ||
+ u32 act_select, polarity_select; | ||
+ int i, val; | ||
+ | ||
+ val = of_property_read_u32_array(node, "realtek,led-link-select", | ||
+ val = of_property_read_u32_array(node, "realtek,led-link-select", | ||
+ link_select, RTL8221B_NR_LEDS); | ||
+ if (!val) { | ||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) { | ||
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2, | ||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET, | ||
+ link_select[i]); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
+ } | ||
+ | ||
+ if (val) | ||
+ return 0; | ||
+ val = of_property_read_u32(node, "realtek,led-act-select", | ||
+ &act_select); | ||
+ if (!val) { | ||
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2, | ||
+ RTL8221B_LED_ACT_SELECT, act_select); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
+ | ||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) { | ||
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2, | ||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET, | ||
+ link_select[i]); | ||
+ val = of_property_read_u32(node, "realtek,led-polarity-select", | ||
+ &polarity_select); | ||
+ if (!val) { | ||
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2, | ||
+ RTL8221B_LED_POLARITY_SELECT, polarity_select); | ||
+ if (val < 0) | ||
+ return val; | ||
+ } | ||
|
@@ -58,7 +77,7 @@ Signed-off-by: Yangyu Chen <[email protected]> | |
static int rtl822xb_config_init(struct phy_device *phydev) | ||
{ | ||
bool has_2500, has_sgmii; | ||
@@ -863,7 +889,7 @@ static int rtl822xb_config_init(struct p | ||
@@ -863,7 +908,7 @@ static int rtl822xb_config_init(struct p | ||
if (ret < 0) | ||
return ret; | ||
|
||
|
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
@@ -253,6 +253,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -255,6 +255,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
if (rhashtable_lookup(ð->flow_table, &f->cookie, mtk_flow_ht_params)) | ||
return -EEXIST; | ||
|
||
|
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 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -3097,8 +3097,8 @@ static irqreturn_t mtk_handle_irq_rx(int | ||
@@ -3098,8 +3098,8 @@ static irqreturn_t mtk_handle_irq_rx(int | ||
|
||
eth->rx_events++; | ||
if (likely(napi_schedule_prep(ð->rx_napi))) { | ||
|
@@ -20,7 +20,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
} | ||
|
||
return IRQ_HANDLED; | ||
@@ -3110,8 +3110,8 @@ static irqreturn_t mtk_handle_irq_tx(int | ||
@@ -3111,8 +3111,8 @@ static irqreturn_t mtk_handle_irq_tx(int | ||
|
||
eth->tx_events++; | ||
if (likely(napi_schedule_prep(ð->tx_napi))) { | ||
|
@@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
} | ||
|
||
return IRQ_HANDLED; | ||
@@ -4885,6 +4885,8 @@ static int mtk_probe(struct platform_dev | ||
@@ -4886,6 +4886,8 @@ static int mtk_probe(struct platform_dev | ||
* for NAPI to work | ||
*/ | ||
init_dummy_netdev(ð->dummy_dev); | ||
|
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 |
---|---|---|
|
@@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
switch (speed) { | ||
case SPEED_2500: | ||
case SPEED_1000: | ||
@@ -3290,6 +3291,9 @@ found: | ||
@@ -3291,6 +3292,9 @@ found: | ||
if (dp->index >= MTK_QDMA_NUM_QUEUES) | ||
return NOTIFY_DONE; | ||
|
||
|
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
@@ -235,7 +235,8 @@ out: | ||
@@ -237,7 +237,8 @@ out: | ||
} | ||
|
||
static int | ||
|
@@ -36,15 +36,15 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
{ | ||
struct flow_rule *rule = flow_cls_offload_flow_rule(f); | ||
struct flow_action_entry *act; | ||
@@ -455,6 +456,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -457,6 +458,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
entry->cookie = f->cookie; | ||
memcpy(&entry->data, &foe, sizeof(entry->data)); | ||
entry->wed_index = wed_index; | ||
+ entry->ppe_index = ppe_index; | ||
|
||
err = mtk_foe_entry_commit(eth->ppe[entry->ppe_index], entry); | ||
if (err < 0) | ||
@@ -523,25 +525,15 @@ mtk_flow_offload_stats(struct mtk_eth *e | ||
@@ -525,25 +527,15 @@ mtk_flow_offload_stats(struct mtk_eth *e | ||
|
||
static DEFINE_MUTEX(mtk_flow_offload_mutex); | ||
|
||
|
@@ -73,7 +73,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
break; | ||
case FLOW_CLS_DESTROY: | ||
err = mtk_flow_offload_destroy(eth, cls); | ||
@@ -559,6 +551,23 @@ mtk_eth_setup_tc_block_cb(enum tc_setup_ | ||
@@ -561,6 +553,23 @@ mtk_eth_setup_tc_block_cb(enum tc_setup_ | ||
} | ||
|
||
static int | ||
|
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 |
---|---|---|
|
@@ -308,7 +308,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
seq_printf(m, "%05x %s %7s", i, | ||
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
@@ -502,24 +502,21 @@ static int | ||
@@ -504,24 +504,21 @@ static int | ||
mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f) | ||
{ | ||
struct mtk_flow_entry *entry; | ||
|
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 |
---|---|---|
|
@@ -478,7 +478,7 @@ Signed-off-by: Daniel Golle <[email protected]> | |
static const struct phylink_mac_ops mtk_phylink_ops = { | ||
.validate = phylink_generic_validate, | ||
.mac_select_pcs = mtk_mac_select_pcs, | ||
@@ -4560,8 +4674,21 @@ static int mtk_add_mac(struct mtk_eth *e | ||
@@ -4561,8 +4675,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); | ||
|
@@ -500,7 +500,7 @@ Signed-off-by: Daniel Golle <[email protected]> | |
phylink = phylink_create(&mac->phylink_config, | ||
of_fwnode_handle(mac->of_node), | ||
phy_mode, &mtk_phylink_ops); | ||
@@ -4754,6 +4881,13 @@ static int mtk_probe(struct platform_dev | ||
@@ -4755,6 +4882,13 @@ static int mtk_probe(struct platform_dev | ||
|
||
if (err) | ||
return err; | ||
|
Oops, something went wrong.