@@ -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+
3448void 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
84101static 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+
11691223static 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+
12001275static 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};
12051281MODULE_DEVICE_TABLE (of , bcmasp_of_match );
12061282
12071283static 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 );
0 commit comments