aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaricheri, Muralidharan <m-karicheri2@ti.com>2015-01-29 18:15:51 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-31 20:33:07 -0500
commit58c11b5faed6913f73f2763d3a85e4a668e8ba2b (patch)
tree94b1e068f2a91fd553d18d534eeec8ca619dc1e0
parent932eb7638ad7d9145620178992044b5e87356969 (diff)
drivers: net: cpsw: make cpsw_ale.c a module to allow re-use on Keystone
NetCP on Keystone has cpsw ale function similar to other TI SoCs and this driver is re-used. To allow both ti cpsw and keystone netcp to re-use the driver, convert the cpsw ale to a module and configure it through Kconfig option CONFIG_TI_CPSW_ALE. Currently it is statically linked to both TI CPSW and NetCP and this causes issues when the above drivers are built as dynamic modules. This patch addresses this issue While at it, fix the Makefile and code to build both netcp_core and netcp_ethss as dynamic modules. This is needed to support arm allmodconfig. This also requires exporting of API calls provided by netcp_core so that both the above can be dynamic modules. Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Tested-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/ti/Kconfig19
-rw-r--r--drivers/net/ethernet/ti/Makefile8
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.c26
-rw-r--r--drivers/net/ethernet/ti/netcp_core.c8
-rw-r--r--drivers/net/ethernet/ti/netcp_ethss.c5
5 files changed, 59 insertions, 7 deletions
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index 4ea1663f3dea..3bc992cd70b7 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -56,12 +56,18 @@ config TI_CPSW_PHY_SEL
56 This driver supports configuring of the phy mode connected to 56 This driver supports configuring of the phy mode connected to
57 the CPSW. 57 the CPSW.
58 58
59config TI_CPSW_ALE
60 tristate "TI CPSW ALE Support"
61 ---help---
62 This driver supports TI's CPSW ALE module.
63
59config TI_CPSW 64config TI_CPSW
60 tristate "TI CPSW Switch Support" 65 tristate "TI CPSW Switch Support"
61 depends on ARCH_DAVINCI || ARCH_OMAP2PLUS 66 depends on ARCH_DAVINCI || ARCH_OMAP2PLUS
62 select TI_DAVINCI_CPDMA 67 select TI_DAVINCI_CPDMA
63 select TI_DAVINCI_MDIO 68 select TI_DAVINCI_MDIO
64 select TI_CPSW_PHY_SEL 69 select TI_CPSW_PHY_SEL
70 select TI_CPSW_ALE
65 select MFD_SYSCON 71 select MFD_SYSCON
66 select REGMAP 72 select REGMAP
67 ---help--- 73 ---help---
@@ -80,15 +86,24 @@ config TI_CPTS
80 and Layer 2 packets, and the driver offers a PTP Hardware Clock. 86 and Layer 2 packets, and the driver offers a PTP Hardware Clock.
81 87
82config TI_KEYSTONE_NETCP 88config TI_KEYSTONE_NETCP
83 tristate "TI Keystone NETCP Ethernet subsystem Support" 89 tristate "TI Keystone NETCP Core Support"
90 select TI_CPSW_ALE
84 depends on OF 91 depends on OF
85 depends on KEYSTONE_NAVIGATOR_DMA && KEYSTONE_NAVIGATOR_QMSS 92 depends on KEYSTONE_NAVIGATOR_DMA && KEYSTONE_NAVIGATOR_QMSS
86 ---help--- 93 ---help---
87 This driver supports TI's Keystone NETCP Ethernet subsystem. 94 This driver supports TI's Keystone NETCP Core.
88 95
89 To compile this driver as a module, choose M here: the module 96 To compile this driver as a module, choose M here: the module
90 will be called keystone_netcp. 97 will be called keystone_netcp.
91 98
99config TI_KEYSTONE_NETCP_ETHSS
100 depends on TI_KEYSTONE_NETCP
101 tristate "TI Keystone NETCP Ethernet subsystem Support"
102 ---help---
103
104 To compile this driver as a module, choose M here: the module
105 will be called keystone_netcp_ethss.
106
92config TLAN 107config TLAN
93 tristate "TI ThunderLAN support" 108 tristate "TI ThunderLAN support"
94 depends on (PCI || EISA) 109 depends on (PCI || EISA)
diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
index 5475cf60fa2d..d420d9413e4a 100644
--- a/drivers/net/ethernet/ti/Makefile
+++ b/drivers/net/ethernet/ti/Makefile
@@ -11,9 +11,11 @@ obj-$(CONFIG_TI_DAVINCI_EMAC) += davinci_emac.o
11obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o 11obj-$(CONFIG_TI_DAVINCI_MDIO) += davinci_mdio.o
12obj-$(CONFIG_TI_DAVINCI_CPDMA) += davinci_cpdma.o 12obj-$(CONFIG_TI_DAVINCI_CPDMA) += davinci_cpdma.o
13obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o 13obj-$(CONFIG_TI_CPSW_PHY_SEL) += cpsw-phy-sel.o
14obj-$(CONFIG_TI_CPSW_ALE) += cpsw_ale.o
14obj-$(CONFIG_TI_CPSW) += ti_cpsw.o 15obj-$(CONFIG_TI_CPSW) += ti_cpsw.o
15ti_cpsw-y := cpsw_ale.o cpsw.o cpts.o 16ti_cpsw-y := cpsw.o cpts.o
16 17
17obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o 18obj-$(CONFIG_TI_KEYSTONE_NETCP) += keystone_netcp.o
18keystone_netcp-y := netcp_core.o netcp_ethss.o netcp_sgmii.o \ 19keystone_netcp-y := netcp_core.o
19 netcp_xgbepcsr.o cpsw_ale.o 20obj-$(CONFIG_TI_KEYSTONE_NETCP_ETHSS) += keystone_netcp_ethss.o
21keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 5246b3a18ff8..6e927b4583aa 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -13,6 +13,7 @@
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 */ 14 */
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/seq_file.h> 18#include <linux/seq_file.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
@@ -146,7 +147,7 @@ static int cpsw_ale_write(struct cpsw_ale *ale, int idx, u32 *ale_entry)
146 return idx; 147 return idx;
147} 148}
148 149
149int cpsw_ale_match_addr(struct cpsw_ale *ale, u8 *addr, u16 vid) 150static int cpsw_ale_match_addr(struct cpsw_ale *ale, u8 *addr, u16 vid)
150{ 151{
151 u32 ale_entry[ALE_ENTRY_WORDS]; 152 u32 ale_entry[ALE_ENTRY_WORDS];
152 int type, idx; 153 int type, idx;
@@ -167,7 +168,7 @@ int cpsw_ale_match_addr(struct cpsw_ale *ale, u8 *addr, u16 vid)
167 return -ENOENT; 168 return -ENOENT;
168} 169}
169 170
170int cpsw_ale_match_vlan(struct cpsw_ale *ale, u16 vid) 171static int cpsw_ale_match_vlan(struct cpsw_ale *ale, u16 vid)
171{ 172{
172 u32 ale_entry[ALE_ENTRY_WORDS]; 173 u32 ale_entry[ALE_ENTRY_WORDS];
173 int type, idx; 174 int type, idx;
@@ -265,6 +266,7 @@ int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
265 } 266 }
266 return 0; 267 return 0;
267} 268}
269EXPORT_SYMBOL_GPL(cpsw_ale_flush_multicast);
268 270
269static void cpsw_ale_flush_ucast(struct cpsw_ale *ale, u32 *ale_entry, 271static void cpsw_ale_flush_ucast(struct cpsw_ale *ale, u32 *ale_entry,
270 int port_mask) 272 int port_mask)
@@ -297,6 +299,7 @@ int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask)
297 } 299 }
298 return 0; 300 return 0;
299} 301}
302EXPORT_SYMBOL_GPL(cpsw_ale_flush);
300 303
301static inline void cpsw_ale_set_vlan_entry_type(u32 *ale_entry, 304static inline void cpsw_ale_set_vlan_entry_type(u32 *ale_entry,
302 int flags, u16 vid) 305 int flags, u16 vid)
@@ -334,6 +337,7 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
334 cpsw_ale_write(ale, idx, ale_entry); 337 cpsw_ale_write(ale, idx, ale_entry);
335 return 0; 338 return 0;
336} 339}
340EXPORT_SYMBOL_GPL(cpsw_ale_add_ucast);
337 341
338int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port, 342int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
339 int flags, u16 vid) 343 int flags, u16 vid)
@@ -349,6 +353,7 @@ int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
349 cpsw_ale_write(ale, idx, ale_entry); 353 cpsw_ale_write(ale, idx, ale_entry);
350 return 0; 354 return 0;
351} 355}
356EXPORT_SYMBOL_GPL(cpsw_ale_del_ucast);
352 357
353int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask, 358int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
354 int flags, u16 vid, int mcast_state) 359 int flags, u16 vid, int mcast_state)
@@ -380,6 +385,7 @@ int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
380 cpsw_ale_write(ale, idx, ale_entry); 385 cpsw_ale_write(ale, idx, ale_entry);
381 return 0; 386 return 0;
382} 387}
388EXPORT_SYMBOL_GPL(cpsw_ale_add_mcast);
383 389
384int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask, 390int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
385 int flags, u16 vid) 391 int flags, u16 vid)
@@ -401,6 +407,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
401 cpsw_ale_write(ale, idx, ale_entry); 407 cpsw_ale_write(ale, idx, ale_entry);
402 return 0; 408 return 0;
403} 409}
410EXPORT_SYMBOL_GPL(cpsw_ale_del_mcast);
404 411
405int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag, 412int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
406 int reg_mcast, int unreg_mcast) 413 int reg_mcast, int unreg_mcast)
@@ -430,6 +437,7 @@ int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
430 cpsw_ale_write(ale, idx, ale_entry); 437 cpsw_ale_write(ale, idx, ale_entry);
431 return 0; 438 return 0;
432} 439}
440EXPORT_SYMBOL_GPL(cpsw_ale_add_vlan);
433 441
434int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask) 442int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
435{ 443{
@@ -450,6 +458,7 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
450 cpsw_ale_write(ale, idx, ale_entry); 458 cpsw_ale_write(ale, idx, ale_entry);
451 return 0; 459 return 0;
452} 460}
461EXPORT_SYMBOL_GPL(cpsw_ale_del_vlan);
453 462
454void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti) 463void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti)
455{ 464{
@@ -479,6 +488,7 @@ void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti)
479 cpsw_ale_write(ale, idx, ale_entry); 488 cpsw_ale_write(ale, idx, ale_entry);
480 } 489 }
481} 490}
491EXPORT_SYMBOL_GPL(cpsw_ale_set_allmulti);
482 492
483struct ale_control_info { 493struct ale_control_info {
484 const char *name; 494 const char *name;
@@ -704,6 +714,7 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
704 714
705 return 0; 715 return 0;
706} 716}
717EXPORT_SYMBOL_GPL(cpsw_ale_control_set);
707 718
708int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control) 719int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
709{ 720{
@@ -727,6 +738,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
727 tmp = __raw_readl(ale->params.ale_regs + offset) >> shift; 738 tmp = __raw_readl(ale->params.ale_regs + offset) >> shift;
728 return tmp & BITMASK(info->bits); 739 return tmp & BITMASK(info->bits);
729} 740}
741EXPORT_SYMBOL_GPL(cpsw_ale_control_get);
730 742
731static void cpsw_ale_timer(unsigned long arg) 743static void cpsw_ale_timer(unsigned long arg)
732{ 744{
@@ -750,6 +762,7 @@ int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout)
750 } 762 }
751 return 0; 763 return 0;
752} 764}
765EXPORT_SYMBOL_GPL(cpsw_ale_set_ageout);
753 766
754void cpsw_ale_start(struct cpsw_ale *ale) 767void cpsw_ale_start(struct cpsw_ale *ale)
755{ 768{
@@ -769,11 +782,13 @@ void cpsw_ale_start(struct cpsw_ale *ale)
769 add_timer(&ale->timer); 782 add_timer(&ale->timer);
770 } 783 }
771} 784}
785EXPORT_SYMBOL_GPL(cpsw_ale_start);
772 786
773void cpsw_ale_stop(struct cpsw_ale *ale) 787void cpsw_ale_stop(struct cpsw_ale *ale)
774{ 788{
775 del_timer_sync(&ale->timer); 789 del_timer_sync(&ale->timer);
776} 790}
791EXPORT_SYMBOL_GPL(cpsw_ale_stop);
777 792
778struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params) 793struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
779{ 794{
@@ -788,6 +803,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
788 803
789 return ale; 804 return ale;
790} 805}
806EXPORT_SYMBOL_GPL(cpsw_ale_create);
791 807
792int cpsw_ale_destroy(struct cpsw_ale *ale) 808int cpsw_ale_destroy(struct cpsw_ale *ale)
793{ 809{
@@ -797,6 +813,7 @@ int cpsw_ale_destroy(struct cpsw_ale *ale)
797 kfree(ale); 813 kfree(ale);
798 return 0; 814 return 0;
799} 815}
816EXPORT_SYMBOL_GPL(cpsw_ale_destroy);
800 817
801void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) 818void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
802{ 819{
@@ -807,3 +824,8 @@ void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
807 data += ALE_ENTRY_WORDS; 824 data += ALE_ENTRY_WORDS;
808 } 825 }
809} 826}
827EXPORT_SYMBOL_GPL(cpsw_ale_dump);
828
829MODULE_LICENSE("GPL v2");
830MODULE_DESCRIPTION("TI CPSW ALE driver");
831MODULE_AUTHOR("Texas Instruments");
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index ba3002ec710a..a31a8c3c8e7c 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -354,6 +354,7 @@ fail:
354 netcp_unregister_module(module); 354 netcp_unregister_module(module);
355 return ret; 355 return ret;
356} 356}
357EXPORT_SYMBOL_GPL(netcp_register_module);
357 358
358static void netcp_release_module(struct netcp_device *netcp_device, 359static void netcp_release_module(struct netcp_device *netcp_device,
359 struct netcp_module *module) 360 struct netcp_module *module)
@@ -414,6 +415,7 @@ void netcp_unregister_module(struct netcp_module *module)
414 415
415 mutex_unlock(&netcp_modules_lock); 416 mutex_unlock(&netcp_modules_lock);
416} 417}
418EXPORT_SYMBOL_GPL(netcp_unregister_module);
417 419
418void *netcp_module_get_intf_data(struct netcp_module *module, 420void *netcp_module_get_intf_data(struct netcp_module *module,
419 struct netcp_intf *intf) 421 struct netcp_intf *intf)
@@ -425,6 +427,7 @@ void *netcp_module_get_intf_data(struct netcp_module *module,
425 return intf_modpriv->module_priv; 427 return intf_modpriv->module_priv;
426 return NULL; 428 return NULL;
427} 429}
430EXPORT_SYMBOL_GPL(netcp_module_get_intf_data);
428 431
429/* Module TX and RX Hook management */ 432/* Module TX and RX Hook management */
430struct netcp_hook_list { 433struct netcp_hook_list {
@@ -459,6 +462,7 @@ int netcp_register_txhook(struct netcp_intf *netcp_priv, int order,
459 462
460 return 0; 463 return 0;
461} 464}
465EXPORT_SYMBOL_GPL(netcp_register_txhook);
462 466
463int netcp_unregister_txhook(struct netcp_intf *netcp_priv, int order, 467int netcp_unregister_txhook(struct netcp_intf *netcp_priv, int order,
464 netcp_hook_rtn *hook_rtn, void *hook_data) 468 netcp_hook_rtn *hook_rtn, void *hook_data)
@@ -480,6 +484,7 @@ int netcp_unregister_txhook(struct netcp_intf *netcp_priv, int order,
480 spin_unlock_irqrestore(&netcp_priv->lock, flags); 484 spin_unlock_irqrestore(&netcp_priv->lock, flags);
481 return -ENOENT; 485 return -ENOENT;
482} 486}
487EXPORT_SYMBOL_GPL(netcp_unregister_txhook);
483 488
484int netcp_register_rxhook(struct netcp_intf *netcp_priv, int order, 489int netcp_register_rxhook(struct netcp_intf *netcp_priv, int order,
485 netcp_hook_rtn *hook_rtn, void *hook_data) 490 netcp_hook_rtn *hook_rtn, void *hook_data)
@@ -1226,6 +1231,7 @@ int netcp_txpipe_close(struct netcp_tx_pipe *tx_pipe)
1226 } 1231 }
1227 return 0; 1232 return 0;
1228} 1233}
1234EXPORT_SYMBOL_GPL(netcp_txpipe_close);
1229 1235
1230int netcp_txpipe_open(struct netcp_tx_pipe *tx_pipe) 1236int netcp_txpipe_open(struct netcp_tx_pipe *tx_pipe)
1231{ 1237{
@@ -1267,6 +1273,7 @@ err:
1267 tx_pipe->dma_channel = NULL; 1273 tx_pipe->dma_channel = NULL;
1268 return ret; 1274 return ret;
1269} 1275}
1276EXPORT_SYMBOL_GPL(netcp_txpipe_open);
1270 1277
1271int netcp_txpipe_init(struct netcp_tx_pipe *tx_pipe, 1278int netcp_txpipe_init(struct netcp_tx_pipe *tx_pipe,
1272 struct netcp_device *netcp_device, 1279 struct netcp_device *netcp_device,
@@ -1278,6 +1285,7 @@ int netcp_txpipe_init(struct netcp_tx_pipe *tx_pipe,
1278 tx_pipe->dma_queue_id = dma_queue_id; 1285 tx_pipe->dma_queue_id = dma_queue_id;
1279 return 0; 1286 return 0;
1280} 1287}
1288EXPORT_SYMBOL_GPL(netcp_txpipe_init);
1281 1289
1282static struct netcp_addr *netcp_addr_find(struct netcp_intf *netcp, 1290static struct netcp_addr *netcp_addr_find(struct netcp_intf *netcp,
1283 const u8 *addr, 1291 const u8 *addr,
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index fa1041a78b46..345cd2563772 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/module.h>
22#include <linux/of_mdio.h> 23#include <linux/of_mdio.h>
23#include <linux/of_address.h> 24#include <linux/of_address.h>
24#include <linux/if_vlan.h> 25#include <linux/if_vlan.h>
@@ -2154,3 +2155,7 @@ static void __exit keystone_gbe_exit(void)
2154 netcp_unregister_module(&xgbe_module); 2155 netcp_unregister_module(&xgbe_module);
2155} 2156}
2156module_exit(keystone_gbe_exit); 2157module_exit(keystone_gbe_exit);
2158
2159MODULE_LICENSE("GPL v2");
2160MODULE_DESCRIPTION("TI NETCP ETHSS driver for Keystone SOCs");
2161MODULE_AUTHOR("Sandeep Nair <sandeep_n@ti.com");