Skip to content

Commit 7779f26

Browse files
committed
Merge branch 'net-asp22-optimizations'
Justin Chen says: ==================== Support for ASP 2.2 and optimizations ASP 2.2 adds some power savings during low power modes. Also make various improvements when entering low power modes and reduce MDIO traffic by hooking up interrupts. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents fc809e1 + cc7f105 commit 7779f26

File tree

6 files changed

+204
-118
lines changed

6 files changed

+204
-118
lines changed

Documentation/devicetree/bindings/net/brcm,asp-v2.0.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ description: Broadcom Ethernet controller first introduced with 72165
1515
properties:
1616
compatible:
1717
oneOf:
18+
- items:
19+
- enum:
20+
- brcm,bcm74165b0-asp
21+
- const: brcm,asp-v2.2
1822
- items:
1923
- enum:
2024
- brcm,bcm74165-asp

Documentation/devicetree/bindings/net/brcm,unimac-mdio.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ properties:
2424
- brcm,genet-mdio-v5
2525
- brcm,asp-v2.0-mdio
2626
- brcm,asp-v2.1-mdio
27+
- brcm,asp-v2.2-mdio
2728
- brcm,unimac-mdio
2829

2930
reg:

drivers/net/ethernet/broadcom/asp2/bcmasp.c

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ static void _intr2_mask_set(struct bcmasp_priv *priv, u32 mask)
3131
priv->irq_mask |= mask;
3232
}
3333

34+
void bcmasp_enable_phy_irq(struct bcmasp_intf *intf, int en)
35+
{
36+
struct bcmasp_priv *priv = intf->parent;
37+
38+
/* Only supported with internal phys */
39+
if (!intf->internal_phy)
40+
return;
41+
42+
if (en)
43+
_intr2_mask_clear(priv, ASP_INTR2_PHY_EVENT(intf->channel));
44+
else
45+
_intr2_mask_set(priv, ASP_INTR2_PHY_EVENT(intf->channel));
46+
}
47+
3448
void bcmasp_enable_tx_irq(struct bcmasp_intf *intf, int en)
3549
{
3650
struct bcmasp_priv *priv = intf->parent;
@@ -79,6 +93,9 @@ static void bcmasp_intr2_handling(struct bcmasp_intf *intf, u32 status)
7993
__napi_schedule_irqoff(&intf->tx_napi);
8094
}
8195
}
96+
97+
if (status & ASP_INTR2_PHY_EVENT(intf->channel))
98+
phy_mac_interrupt(intf->ndev->phydev);
8299
}
83100

84101
static irqreturn_t bcmasp_isr(int irq, void *data)
@@ -972,7 +989,26 @@ static void bcmasp_core_init(struct bcmasp_priv *priv)
972989
ASP_INTR2_CLEAR);
973990
}
974991

975-
static void bcmasp_core_clock_select(struct bcmasp_priv *priv, bool slow)
992+
static void bcmasp_core_clock_select_many(struct bcmasp_priv *priv, bool slow)
993+
{
994+
u32 reg;
995+
996+
reg = ctrl2_core_rl(priv, ASP_CTRL2_CORE_CLOCK_SELECT);
997+
if (slow)
998+
reg &= ~ASP_CTRL2_CORE_CLOCK_SELECT_MAIN;
999+
else
1000+
reg |= ASP_CTRL2_CORE_CLOCK_SELECT_MAIN;
1001+
ctrl2_core_wl(priv, reg, ASP_CTRL2_CORE_CLOCK_SELECT);
1002+
1003+
reg = ctrl2_core_rl(priv, ASP_CTRL2_CPU_CLOCK_SELECT);
1004+
if (slow)
1005+
reg &= ~ASP_CTRL2_CPU_CLOCK_SELECT_MAIN;
1006+
else
1007+
reg |= ASP_CTRL2_CPU_CLOCK_SELECT_MAIN;
1008+
ctrl2_core_wl(priv, reg, ASP_CTRL2_CPU_CLOCK_SELECT);
1009+
}
1010+
1011+
static void bcmasp_core_clock_select_one(struct bcmasp_priv *priv, bool slow)
9761012
{
9771013
u32 reg;
9781014

@@ -1166,6 +1202,24 @@ static void bcmasp_wol_irq_destroy_per_intf(struct bcmasp_priv *priv)
11661202
}
11671203
}
11681204

1205+
static void bcmasp_eee_fixup(struct bcmasp_intf *intf, bool en)
1206+
{
1207+
u32 reg, phy_lpi_overwrite;
1208+
1209+
reg = rx_edpkt_core_rl(intf->parent, ASP_EDPKT_SPARE_REG);
1210+
phy_lpi_overwrite = intf->internal_phy ? ASP_EDPKT_SPARE_REG_EPHY_LPI :
1211+
ASP_EDPKT_SPARE_REG_GPHY_LPI;
1212+
1213+
if (en)
1214+
reg |= phy_lpi_overwrite;
1215+
else
1216+
reg &= ~phy_lpi_overwrite;
1217+
1218+
rx_edpkt_core_wl(intf->parent, reg, ASP_EDPKT_SPARE_REG);
1219+
1220+
usleep_range(50, 100);
1221+
}
1222+
11691223
static struct bcmasp_hw_info v20_hw_info = {
11701224
.rx_ctrl_flush = ASP_RX_CTRL_FLUSH,
11711225
.umac2fb = UMAC2FB_OFFSET,
@@ -1178,6 +1232,7 @@ static const struct bcmasp_plat_data v20_plat_data = {
11781232
.init_wol = bcmasp_init_wol_per_intf,
11791233
.enable_wol = bcmasp_enable_wol_per_intf,
11801234
.destroy_wol = bcmasp_wol_irq_destroy_per_intf,
1235+
.core_clock_select = bcmasp_core_clock_select_one,
11811236
.hw_info = &v20_hw_info,
11821237
};
11831238

@@ -1194,17 +1249,39 @@ static const struct bcmasp_plat_data v21_plat_data = {
11941249
.init_wol = bcmasp_init_wol_shared,
11951250
.enable_wol = bcmasp_enable_wol_shared,
11961251
.destroy_wol = bcmasp_wol_irq_destroy_shared,
1252+
.core_clock_select = bcmasp_core_clock_select_one,
1253+
.hw_info = &v21_hw_info,
1254+
};
1255+
1256+
static const struct bcmasp_plat_data v22_plat_data = {
1257+
.init_wol = bcmasp_init_wol_shared,
1258+
.enable_wol = bcmasp_enable_wol_shared,
1259+
.destroy_wol = bcmasp_wol_irq_destroy_shared,
1260+
.core_clock_select = bcmasp_core_clock_select_many,
11971261
.hw_info = &v21_hw_info,
1262+
.eee_fixup = bcmasp_eee_fixup,
11981263
};
11991264

1265+
static void bcmasp_set_pdata(struct bcmasp_priv *priv, const struct bcmasp_plat_data *pdata)
1266+
{
1267+
priv->init_wol = pdata->init_wol;
1268+
priv->enable_wol = pdata->enable_wol;
1269+
priv->destroy_wol = pdata->destroy_wol;
1270+
priv->core_clock_select = pdata->core_clock_select;
1271+
priv->eee_fixup = pdata->eee_fixup;
1272+
priv->hw_info = pdata->hw_info;
1273+
}
1274+
12001275
static const struct of_device_id bcmasp_of_match[] = {
12011276
{ .compatible = "brcm,asp-v2.0", .data = &v20_plat_data },
12021277
{ .compatible = "brcm,asp-v2.1", .data = &v21_plat_data },
1278+
{ .compatible = "brcm,asp-v2.2", .data = &v22_plat_data },
12031279
{ /* sentinel */ },
12041280
};
12051281
MODULE_DEVICE_TABLE(of, bcmasp_of_match);
12061282

12071283
static const struct of_device_id bcmasp_mdio_of_match[] = {
1284+
{ .compatible = "brcm,asp-v2.2-mdio", },
12081285
{ .compatible = "brcm,asp-v2.1-mdio", },
12091286
{ .compatible = "brcm,asp-v2.0-mdio", },
12101287
{ /* sentinel */ },
@@ -1265,16 +1342,13 @@ static int bcmasp_probe(struct platform_device *pdev)
12651342
if (!pdata)
12661343
return dev_err_probe(dev, -EINVAL, "unable to find platform data\n");
12671344

1268-
priv->init_wol = pdata->init_wol;
1269-
priv->enable_wol = pdata->enable_wol;
1270-
priv->destroy_wol = pdata->destroy_wol;
1271-
priv->hw_info = pdata->hw_info;
1345+
bcmasp_set_pdata(priv, pdata);
12721346

12731347
/* Enable all clocks to ensure successful probing */
12741348
bcmasp_core_clock_set(priv, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE, 0);
12751349

12761350
/* Switch to the main clock */
1277-
bcmasp_core_clock_select(priv, false);
1351+
priv->core_clock_select(priv, false);
12781352

12791353
bcmasp_intr2_mask_set_all(priv);
12801354
bcmasp_intr2_clear_all(priv);
@@ -1381,7 +1455,7 @@ static int __maybe_unused bcmasp_suspend(struct device *d)
13811455
*/
13821456
bcmasp_core_clock_set(priv, 0, ASP_CTRL_CLOCK_CTRL_ASP_TX_DISABLE);
13831457

1384-
bcmasp_core_clock_select(priv, true);
1458+
priv->core_clock_select(priv, true);
13851459

13861460
clk_disable_unprepare(priv->clk);
13871461

@@ -1399,7 +1473,7 @@ static int __maybe_unused bcmasp_resume(struct device *d)
13991473
return ret;
14001474

14011475
/* Switch to the main clock domain */
1402-
bcmasp_core_clock_select(priv, false);
1476+
priv->core_clock_select(priv, false);
14031477

14041478
/* Re-enable all clocks for re-initialization */
14051479
bcmasp_core_clock_set(priv, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE, 0);

drivers/net/ethernet/broadcom/asp2/bcmasp.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define ASP_INTR2_TX_DESC(intr) BIT((intr) + 14)
2020
#define ASP_INTR2_UMC0_WAKE BIT(22)
2121
#define ASP_INTR2_UMC1_WAKE BIT(28)
22+
#define ASP_INTR2_PHY_EVENT(intr) ((intr) ? BIT(30) | BIT(31) : \
23+
BIT(24) | BIT(25))
2224

2325
#define ASP_WAKEUP_INTR2_OFFSET 0x1200
2426
#define ASP_WAKEUP_INTR2_STATUS 0x0
@@ -33,6 +35,12 @@
3335
#define ASP_WAKEUP_INTR2_FILT_1 BIT(3)
3436
#define ASP_WAKEUP_INTR2_FW BIT(4)
3537

38+
#define ASP_CTRL2_OFFSET 0x2000
39+
#define ASP_CTRL2_CORE_CLOCK_SELECT 0x0
40+
#define ASP_CTRL2_CORE_CLOCK_SELECT_MAIN BIT(0)
41+
#define ASP_CTRL2_CPU_CLOCK_SELECT 0x4
42+
#define ASP_CTRL2_CPU_CLOCK_SELECT_MAIN BIT(0)
43+
3644
#define ASP_TX_ANALYTICS_OFFSET 0x4c000
3745
#define ASP_TX_ANALYTICS_CTRL 0x0
3846

@@ -134,8 +142,11 @@ enum asp_rx_net_filter_block {
134142
#define ASP_EDPKT_RX_PKT_CNT 0x138
135143
#define ASP_EDPKT_HDR_EXTR_CNT 0x13c
136144
#define ASP_EDPKT_HDR_OUT_CNT 0x140
145+
#define ASP_EDPKT_SPARE_REG 0x174
146+
#define ASP_EDPKT_SPARE_REG_EPHY_LPI BIT(4)
147+
#define ASP_EDPKT_SPARE_REG_GPHY_LPI BIT(3)
137148

138-
#define ASP_CTRL 0x101000
149+
#define ASP_CTRL_OFFSET 0x101000
139150
#define ASP_CTRL_ASP_SW_INIT 0x04
140151
#define ASP_CTRL_ASP_SW_INIT_ACPUSS_CORE BIT(0)
141152
#define ASP_CTRL_ASP_SW_INIT_ASP_TX BIT(1)
@@ -306,6 +317,7 @@ struct bcmasp_intf {
306317
struct bcmasp_desc *rx_edpkt_cpu;
307318
dma_addr_t rx_edpkt_dma_addr;
308319
dma_addr_t rx_edpkt_dma_read;
320+
dma_addr_t rx_edpkt_dma_valid;
309321

310322
/* RX buffer prefetcher ring*/
311323
void *rx_ring_cpu;
@@ -372,6 +384,8 @@ struct bcmasp_plat_data {
372384
void (*init_wol)(struct bcmasp_priv *priv);
373385
void (*enable_wol)(struct bcmasp_intf *intf, bool en);
374386
void (*destroy_wol)(struct bcmasp_priv *priv);
387+
void (*core_clock_select)(struct bcmasp_priv *priv, bool slow);
388+
void (*eee_fixup)(struct bcmasp_intf *priv, bool en);
375389
struct bcmasp_hw_info *hw_info;
376390
};
377391

@@ -390,6 +404,8 @@ struct bcmasp_priv {
390404
void (*init_wol)(struct bcmasp_priv *priv);
391405
void (*enable_wol)(struct bcmasp_intf *intf, bool en);
392406
void (*destroy_wol)(struct bcmasp_priv *priv);
407+
void (*core_clock_select)(struct bcmasp_priv *priv, bool slow);
408+
void (*eee_fixup)(struct bcmasp_intf *intf, bool en);
393409

394410
void __iomem *base;
395411
struct bcmasp_hw_info *hw_info;
@@ -530,7 +546,8 @@ BCMASP_CORE_IO_MACRO(rx_analytics, ASP_RX_ANALYTICS_OFFSET);
530546
BCMASP_CORE_IO_MACRO(rx_ctrl, ASP_RX_CTRL_OFFSET);
531547
BCMASP_CORE_IO_MACRO(rx_filter, ASP_RX_FILTER_OFFSET);
532548
BCMASP_CORE_IO_MACRO(rx_edpkt, ASP_EDPKT_OFFSET);
533-
BCMASP_CORE_IO_MACRO(ctrl, ASP_CTRL);
549+
BCMASP_CORE_IO_MACRO(ctrl, ASP_CTRL_OFFSET);
550+
BCMASP_CORE_IO_MACRO(ctrl2, ASP_CTRL2_OFFSET);
534551

535552
struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv,
536553
struct device_node *ndev_dn, int i);
@@ -541,6 +558,8 @@ void bcmasp_enable_tx_irq(struct bcmasp_intf *intf, int en);
541558

542559
void bcmasp_enable_rx_irq(struct bcmasp_intf *intf, int en);
543560

561+
void bcmasp_enable_phy_irq(struct bcmasp_intf *intf, int en);
562+
544563
void bcmasp_flush_rx_port(struct bcmasp_intf *intf);
545564

546565
extern const struct ethtool_ops bcmasp_ethtool_ops;

0 commit comments

Comments
 (0)