@@ -518,7 +518,7 @@ void bcmasp_netfilt_suspend(struct bcmasp_intf *intf)
518518 int ret , i ;
519519
520520 /* Write all filters to HW */
521- for (i = 0 ; i < NUM_NET_FILTERS ; i ++ ) {
521+ for (i = 0 ; i < priv -> num_net_filters ; i ++ ) {
522522 /* If the filter does not match the port, skip programming. */
523523 if (!priv -> net_filters [i ].claimed ||
524524 priv -> net_filters [i ].port != intf -> port )
@@ -551,7 +551,7 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
551551 struct bcmasp_priv * priv = intf -> parent ;
552552 int j = 0 , i ;
553553
554- for (i = 0 ; i < NUM_NET_FILTERS ; i ++ ) {
554+ for (i = 0 ; i < priv -> num_net_filters ; i ++ ) {
555555 if (!priv -> net_filters [i ].claimed ||
556556 priv -> net_filters [i ].port != intf -> port )
557557 continue ;
@@ -577,7 +577,7 @@ int bcmasp_netfilt_get_active(struct bcmasp_intf *intf)
577577 struct bcmasp_priv * priv = intf -> parent ;
578578 int cnt = 0 , i ;
579579
580- for (i = 0 ; i < NUM_NET_FILTERS ; i ++ ) {
580+ for (i = 0 ; i < priv -> num_net_filters ; i ++ ) {
581581 if (!priv -> net_filters [i ].claimed ||
582582 priv -> net_filters [i ].port != intf -> port )
583583 continue ;
@@ -602,7 +602,7 @@ bool bcmasp_netfilt_check_dup(struct bcmasp_intf *intf,
602602 size_t fs_size = 0 ;
603603 int i ;
604604
605- for (i = 0 ; i < NUM_NET_FILTERS ; i ++ ) {
605+ for (i = 0 ; i < priv -> num_net_filters ; i ++ ) {
606606 if (!priv -> net_filters [i ].claimed ||
607607 priv -> net_filters [i ].port != intf -> port )
608608 continue ;
@@ -670,7 +670,7 @@ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf,
670670 int i , open_index = -1 ;
671671
672672 /* Check whether we exceed the filter table capacity */
673- if (loc != RX_CLS_LOC_ANY && loc >= NUM_NET_FILTERS )
673+ if (loc != RX_CLS_LOC_ANY && loc >= priv -> num_net_filters )
674674 return ERR_PTR (- EINVAL );
675675
676676 /* If the filter location is busy (already claimed) and we are initializing
@@ -686,7 +686,7 @@ struct bcmasp_net_filter *bcmasp_netfilt_get_init(struct bcmasp_intf *intf,
686686 /* Initialize the loop index based on the desired location or from 0 */
687687 i = loc == RX_CLS_LOC_ANY ? 0 : loc ;
688688
689- for ( ; i < NUM_NET_FILTERS ; i ++ ) {
689+ for ( ; i < priv -> num_net_filters ; i ++ ) {
690690 /* Found matching network filter */
691691 if (!init &&
692692 priv -> net_filters [i ].claimed &&
@@ -779,7 +779,7 @@ static void bcmasp_en_mda_filter(struct bcmasp_intf *intf, bool en,
779779 priv -> mda_filters [i ].en = en ;
780780 priv -> mda_filters [i ].port = intf -> port ;
781781
782- rx_filter_core_wl (priv , ((intf -> channel + 8 ) |
782+ rx_filter_core_wl (priv , ((intf -> channel + priv -> tx_chan_offset ) |
783783 (en << ASP_RX_FILTER_MDA_CFG_EN_SHIFT ) |
784784 ASP_RX_FILTER_MDA_CFG_UMC_SEL (intf -> port )),
785785 ASP_RX_FILTER_MDA_CFG (i ));
@@ -865,7 +865,7 @@ void bcmasp_disable_all_filters(struct bcmasp_intf *intf)
865865 res_count = bcmasp_total_res_mda_cnt (intf -> parent );
866866
867867 /* Disable all filters held by this port */
868- for (i = res_count ; i < NUM_MDA_FILTERS ; i ++ ) {
868+ for (i = res_count ; i < priv -> num_mda_filters ; i ++ ) {
869869 if (priv -> mda_filters [i ].en &&
870870 priv -> mda_filters [i ].port == intf -> port )
871871 bcmasp_en_mda_filter (intf , 0 , i );
@@ -909,7 +909,7 @@ int bcmasp_set_en_mda_filter(struct bcmasp_intf *intf, unsigned char *addr,
909909
910910 res_count = bcmasp_total_res_mda_cnt (intf -> parent );
911911
912- for (i = res_count ; i < NUM_MDA_FILTERS ; i ++ ) {
912+ for (i = res_count ; i < priv -> num_mda_filters ; i ++ ) {
913913 /* If filter not enabled or belongs to another port skip */
914914 if (!priv -> mda_filters [i ].en ||
915915 priv -> mda_filters [i ].port != intf -> port )
@@ -924,7 +924,7 @@ int bcmasp_set_en_mda_filter(struct bcmasp_intf *intf, unsigned char *addr,
924924 }
925925
926926 /* Create new filter if possible */
927- for (i = res_count ; i < NUM_MDA_FILTERS ; i ++ ) {
927+ for (i = res_count ; i < priv -> num_mda_filters ; i ++ ) {
928928 if (priv -> mda_filters [i ].en )
929929 continue ;
930930
@@ -944,12 +944,12 @@ static void bcmasp_core_init_filters(struct bcmasp_priv *priv)
944944 /* Disable all filters and reset software view since the HW
945945 * can lose context while in deep sleep suspend states
946946 */
947- for (i = 0 ; i < NUM_MDA_FILTERS ; i ++ ) {
947+ for (i = 0 ; i < priv -> num_mda_filters ; i ++ ) {
948948 rx_filter_core_wl (priv , 0x0 , ASP_RX_FILTER_MDA_CFG (i ));
949949 priv -> mda_filters [i ].en = 0 ;
950950 }
951951
952- for (i = 0 ; i < NUM_NET_FILTERS ; i ++ )
952+ for (i = 0 ; i < priv -> num_net_filters ; i ++ )
953953 rx_filter_core_wl (priv , 0x0 , ASP_RX_FILTER_NET_CFG (i ));
954954
955955 /* Top level filter enable bit should be enabled at all times, set
@@ -966,18 +966,8 @@ static void bcmasp_core_init_filters(struct bcmasp_priv *priv)
966966/* ASP core initialization */
967967static void bcmasp_core_init (struct bcmasp_priv * priv )
968968{
969- tx_analytics_core_wl (priv , 0x0 , ASP_TX_ANALYTICS_CTRL );
970- rx_analytics_core_wl (priv , 0x4 , ASP_RX_ANALYTICS_CTRL );
971-
972- rx_edpkt_core_wl (priv , (ASP_EDPKT_HDR_SZ_128 << ASP_EDPKT_HDR_SZ_SHIFT ),
973- ASP_EDPKT_HDR_CFG );
974- rx_edpkt_core_wl (priv ,
975- (ASP_EDPKT_ENDI_BT_SWP_WD << ASP_EDPKT_ENDI_DESC_SHIFT ),
976- ASP_EDPKT_ENDI );
977-
978969 rx_edpkt_core_wl (priv , 0x1b , ASP_EDPKT_BURST_BUF_PSCAL_TOUT );
979970 rx_edpkt_core_wl (priv , 0x3e8 , ASP_EDPKT_BURST_BUF_WRITE_TOUT );
980- rx_edpkt_core_wl (priv , 0x3e8 , ASP_EDPKT_BURST_BUF_READ_TOUT );
981971
982972 rx_edpkt_core_wl (priv , ASP_EDPKT_ENABLE_EN , ASP_EDPKT_ENABLE );
983973
@@ -1020,6 +1010,18 @@ static void bcmasp_core_clock_select_one(struct bcmasp_priv *priv, bool slow)
10201010 ctrl_core_wl (priv , reg , ASP_CTRL_CORE_CLOCK_SELECT );
10211011}
10221012
1013+ static void bcmasp_core_clock_select_one_ctrl2 (struct bcmasp_priv * priv , bool slow )
1014+ {
1015+ u32 reg ;
1016+
1017+ reg = ctrl2_core_rl (priv , ASP_CTRL2_CORE_CLOCK_SELECT );
1018+ if (slow )
1019+ reg &= ~ASP_CTRL2_CORE_CLOCK_SELECT_MAIN ;
1020+ else
1021+ reg |= ASP_CTRL2_CORE_CLOCK_SELECT_MAIN ;
1022+ ctrl2_core_wl (priv , reg , ASP_CTRL2_CORE_CLOCK_SELECT );
1023+ }
1024+
10231025static void bcmasp_core_clock_set_ll (struct bcmasp_priv * priv , u32 clr , u32 set )
10241026{
10251027 u32 reg ;
@@ -1180,29 +1182,51 @@ static void bcmasp_eee_fixup(struct bcmasp_intf *intf, bool en)
11801182
11811183static const struct bcmasp_plat_data v21_plat_data = {
11821184 .core_clock_select = bcmasp_core_clock_select_one ,
1185+ .num_mda_filters = 32 ,
1186+ .num_net_filters = 32 ,
1187+ .tx_chan_offset = 8 ,
1188+ .rx_ctrl_offset = 0x0 ,
11831189};
11841190
11851191static const struct bcmasp_plat_data v22_plat_data = {
11861192 .core_clock_select = bcmasp_core_clock_select_many ,
11871193 .eee_fixup = bcmasp_eee_fixup ,
1194+ .num_mda_filters = 32 ,
1195+ .num_net_filters = 32 ,
1196+ .tx_chan_offset = 8 ,
1197+ .rx_ctrl_offset = 0x0 ,
1198+ };
1199+
1200+ static const struct bcmasp_plat_data v30_plat_data = {
1201+ .core_clock_select = bcmasp_core_clock_select_one_ctrl2 ,
1202+ .num_mda_filters = 20 ,
1203+ .num_net_filters = 16 ,
1204+ .tx_chan_offset = 0 ,
1205+ .rx_ctrl_offset = 0x10000 ,
11881206};
11891207
11901208static void bcmasp_set_pdata (struct bcmasp_priv * priv , const struct bcmasp_plat_data * pdata )
11911209{
11921210 priv -> core_clock_select = pdata -> core_clock_select ;
11931211 priv -> eee_fixup = pdata -> eee_fixup ;
1212+ priv -> num_mda_filters = pdata -> num_mda_filters ;
1213+ priv -> num_net_filters = pdata -> num_net_filters ;
1214+ priv -> tx_chan_offset = pdata -> tx_chan_offset ;
1215+ priv -> rx_ctrl_offset = pdata -> rx_ctrl_offset ;
11941216}
11951217
11961218static const struct of_device_id bcmasp_of_match [] = {
11971219 { .compatible = "brcm,asp-v2.1" , .data = & v21_plat_data },
11981220 { .compatible = "brcm,asp-v2.2" , .data = & v22_plat_data },
1221+ { .compatible = "brcm,asp-v3.0" , .data = & v30_plat_data },
11991222 { /* sentinel */ },
12001223};
12011224MODULE_DEVICE_TABLE (of , bcmasp_of_match );
12021225
12031226static const struct of_device_id bcmasp_mdio_of_match [] = {
12041227 { .compatible = "brcm,asp-v2.1-mdio" , },
12051228 { .compatible = "brcm,asp-v2.2-mdio" , },
1229+ { .compatible = "brcm,asp-v3.0-mdio" , },
12061230 { /* sentinel */ },
12071231};
12081232MODULE_DEVICE_TABLE (of , bcmasp_mdio_of_match );
@@ -1284,6 +1308,17 @@ static int bcmasp_probe(struct platform_device *pdev)
12841308 * how many interfaces come up.
12851309 */
12861310 bcmasp_core_init (priv );
1311+
1312+ priv -> mda_filters = devm_kcalloc (dev , priv -> num_mda_filters ,
1313+ sizeof (* priv -> mda_filters ), GFP_KERNEL );
1314+ if (!priv -> mda_filters )
1315+ return - ENOMEM ;
1316+
1317+ priv -> net_filters = devm_kcalloc (dev , priv -> num_net_filters ,
1318+ sizeof (* priv -> net_filters ), GFP_KERNEL );
1319+ if (!priv -> net_filters )
1320+ return - ENOMEM ;
1321+
12871322 bcmasp_core_init_filters (priv );
12881323
12891324 ports_node = of_find_node_by_name (dev -> of_node , "ethernet-ports" );
0 commit comments