3333
3434#define DRV_NAME "ftgmac100"
3535
36+ enum ftgmac100_mac_id {
37+ FTGMAC100_FARADAY = 1 ,
38+ FTGMAC100_AST2400 ,
39+ FTGMAC100_AST2500 ,
40+ FTGMAC100_AST2600
41+ };
42+
43+ struct ftgmac100_match_data {
44+ enum ftgmac100_mac_id mac_id ;
45+ };
46+
3647/* Arbitrary values, I am not sure the HW has limits */
3748#define MAX_RX_QUEUE_ENTRIES 1024
3849#define MAX_TX_QUEUE_ENTRIES 1024
@@ -66,6 +77,8 @@ struct ftgmac100 {
6677 struct resource * res ;
6778 void __iomem * base ;
6879
80+ enum ftgmac100_mac_id mac_id ;
81+
6982 /* Rx ring */
7083 unsigned int rx_q_entries ;
7184 struct ftgmac100_rxdes * rxdes ;
@@ -1835,6 +1848,8 @@ static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
18351848
18361849static int ftgmac100_probe (struct platform_device * pdev )
18371850{
1851+ const struct ftgmac100_match_data * match_data ;
1852+ enum ftgmac100_mac_id mac_id ;
18381853 struct resource * res ;
18391854 int irq ;
18401855 struct net_device * netdev ;
@@ -1843,6 +1858,16 @@ static int ftgmac100_probe(struct platform_device *pdev)
18431858 struct device_node * np ;
18441859 int err = 0 ;
18451860
1861+ np = pdev -> dev .of_node ;
1862+ if (np ) {
1863+ match_data = of_device_get_match_data (& pdev -> dev );
1864+ if (!match_data )
1865+ return - EINVAL ;
1866+ mac_id = match_data -> mac_id ;
1867+ } else {
1868+ mac_id = FTGMAC100_FARADAY ;
1869+ }
1870+
18461871 res = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
18471872 if (!res )
18481873 return - ENXIO ;
@@ -1870,6 +1895,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
18701895 priv = netdev_priv (netdev );
18711896 priv -> netdev = netdev ;
18721897 priv -> dev = & pdev -> dev ;
1898+ priv -> mac_id = mac_id ;
18731899 INIT_WORK (& priv -> reset_task , ftgmac100_reset_task );
18741900
18751901 /* map io memory */
@@ -1900,7 +1926,6 @@ static int ftgmac100_probe(struct platform_device *pdev)
19001926 if (err )
19011927 goto err_phy_connect ;
19021928
1903- np = pdev -> dev .of_node ;
19041929 if (np && (of_device_is_compatible (np , "aspeed,ast2400-mac" ) ||
19051930 of_device_is_compatible (np , "aspeed,ast2500-mac" ) ||
19061931 of_device_is_compatible (np , "aspeed,ast2600-mac" ))) {
@@ -2090,11 +2115,31 @@ static void ftgmac100_remove(struct platform_device *pdev)
20902115 free_netdev (netdev );
20912116}
20922117
2118+ static const struct ftgmac100_match_data ftgmac100_match_data_ast2400 = {
2119+ .mac_id = FTGMAC100_AST2400
2120+ };
2121+
2122+ static const struct ftgmac100_match_data ftgmac100_match_data_ast2500 = {
2123+ .mac_id = FTGMAC100_AST2500
2124+ };
2125+
2126+ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = {
2127+ .mac_id = FTGMAC100_AST2600
2128+ };
2129+
2130+ static const struct ftgmac100_match_data ftgmac100_match_data_faraday = {
2131+ .mac_id = FTGMAC100_FARADAY
2132+ };
2133+
20932134static const struct of_device_id ftgmac100_of_match [] = {
2094- { .compatible = "aspeed,ast2400-mac" },
2095- { .compatible = "aspeed,ast2500-mac" },
2096- { .compatible = "aspeed,ast2600-mac" },
2097- { .compatible = "faraday,ftgmac100" },
2135+ { .compatible = "aspeed,ast2400-mac" ,
2136+ .data = & ftgmac100_match_data_ast2400 },
2137+ { .compatible = "aspeed,ast2500-mac" ,
2138+ .data = & ftgmac100_match_data_ast2500 },
2139+ { .compatible = "aspeed,ast2600-mac" ,
2140+ .data = & ftgmac100_match_data_ast2600 },
2141+ { .compatible = "faraday,ftgmac100" ,
2142+ .data = & ftgmac100_match_data_faraday },
20982143 { }
20992144};
21002145MODULE_DEVICE_TABLE (of , ftgmac100_of_match );
0 commit comments