cpsw.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. /*
  2. * Texas Instruments Ethernet Switch Driver
  3. *
  4. * Copyright (C) 2012 Texas Instruments
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/io.h>
  17. #include <linux/clk.h>
  18. #include <linux/timer.h>
  19. #include <linux/module.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/irqreturn.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/if_ether.h>
  24. #include <linux/etherdevice.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/phy.h>
  27. #include <linux/workqueue.h>
  28. #include <linux/delay.h>
  29. #include <linux/pm_runtime.h>
  30. #include <linux/of.h>
  31. #include <linux/of_net.h>
  32. #include <linux/of_device.h>
  33. #include <linux/platform_data/cpsw.h>
  34. #include "cpsw_ale.h"
  35. #include "davinci_cpdma.h"
  36. #define CPSW_DEBUG (NETIF_MSG_HW | NETIF_MSG_WOL | \
  37. NETIF_MSG_DRV | NETIF_MSG_LINK | \
  38. NETIF_MSG_IFUP | NETIF_MSG_INTR | \
  39. NETIF_MSG_PROBE | NETIF_MSG_TIMER | \
  40. NETIF_MSG_IFDOWN | NETIF_MSG_RX_ERR | \
  41. NETIF_MSG_TX_ERR | NETIF_MSG_TX_DONE | \
  42. NETIF_MSG_PKTDATA | NETIF_MSG_TX_QUEUED | \
  43. NETIF_MSG_RX_STATUS)
  44. #define cpsw_info(priv, type, format, ...) \
  45. do { \
  46. if (netif_msg_##type(priv) && net_ratelimit()) \
  47. dev_info(priv->dev, format, ## __VA_ARGS__); \
  48. } while (0)
  49. #define cpsw_err(priv, type, format, ...) \
  50. do { \
  51. if (netif_msg_##type(priv) && net_ratelimit()) \
  52. dev_err(priv->dev, format, ## __VA_ARGS__); \
  53. } while (0)
  54. #define cpsw_dbg(priv, type, format, ...) \
  55. do { \
  56. if (netif_msg_##type(priv) && net_ratelimit()) \
  57. dev_dbg(priv->dev, format, ## __VA_ARGS__); \
  58. } while (0)
  59. #define cpsw_notice(priv, type, format, ...) \
  60. do { \
  61. if (netif_msg_##type(priv) && net_ratelimit()) \
  62. dev_notice(priv->dev, format, ## __VA_ARGS__); \
  63. } while (0)
  64. #define CPSW_MAJOR_VERSION(reg) (reg >> 8 & 0x7)
  65. #define CPSW_MINOR_VERSION(reg) (reg & 0xff)
  66. #define CPSW_RTL_VERSION(reg) ((reg >> 11) & 0x1f)
  67. #define CPDMA_RXTHRESH 0x0c0
  68. #define CPDMA_RXFREE 0x0e0
  69. #define CPDMA_TXHDP 0x00
  70. #define CPDMA_RXHDP 0x20
  71. #define CPDMA_TXCP 0x40
  72. #define CPDMA_RXCP 0x60
  73. #define cpsw_dma_regs(base, offset) \
  74. (void __iomem *)((base) + (offset))
  75. #define cpsw_dma_rxthresh(base, offset) \
  76. (void __iomem *)((base) + (offset) + CPDMA_RXTHRESH)
  77. #define cpsw_dma_rxfree(base, offset) \
  78. (void __iomem *)((base) + (offset) + CPDMA_RXFREE)
  79. #define cpsw_dma_txhdp(base, offset) \
  80. (void __iomem *)((base) + (offset) + CPDMA_TXHDP)
  81. #define cpsw_dma_rxhdp(base, offset) \
  82. (void __iomem *)((base) + (offset) + CPDMA_RXHDP)
  83. #define cpsw_dma_txcp(base, offset) \
  84. (void __iomem *)((base) + (offset) + CPDMA_TXCP)
  85. #define cpsw_dma_rxcp(base, offset) \
  86. (void __iomem *)((base) + (offset) + CPDMA_RXCP)
  87. #define CPSW_POLL_WEIGHT 64
  88. #define CPSW_MIN_PACKET_SIZE 60
  89. #define CPSW_MAX_PACKET_SIZE (1500 + 14 + 4 + 4)
  90. #define RX_PRIORITY_MAPPING 0x76543210
  91. #define TX_PRIORITY_MAPPING 0x33221100
  92. #define CPDMA_TX_PRIORITY_MAP 0x76543210
  93. #define cpsw_enable_irq(priv) \
  94. do { \
  95. u32 i; \
  96. for (i = 0; i < priv->num_irqs; i++) \
  97. enable_irq(priv->irqs_table[i]); \
  98. } while (0);
  99. #define cpsw_disable_irq(priv) \
  100. do { \
  101. u32 i; \
  102. for (i = 0; i < priv->num_irqs; i++) \
  103. disable_irq_nosync(priv->irqs_table[i]); \
  104. } while (0);
  105. static int debug_level;
  106. module_param(debug_level, int, 0);
  107. MODULE_PARM_DESC(debug_level, "cpsw debug level (NETIF_MSG bits)");
  108. static int ale_ageout = 10;
  109. module_param(ale_ageout, int, 0);
  110. MODULE_PARM_DESC(ale_ageout, "cpsw ale ageout interval (seconds)");
  111. static int rx_packet_max = CPSW_MAX_PACKET_SIZE;
  112. module_param(rx_packet_max, int, 0);
  113. MODULE_PARM_DESC(rx_packet_max, "maximum receive packet size (bytes)");
  114. struct cpsw_ss_regs {
  115. u32 id_ver;
  116. u32 soft_reset;
  117. u32 control;
  118. u32 int_control;
  119. u32 rx_thresh_en;
  120. u32 rx_en;
  121. u32 tx_en;
  122. u32 misc_en;
  123. };
  124. struct cpsw_regs {
  125. u32 id_ver;
  126. u32 control;
  127. u32 soft_reset;
  128. u32 stat_port_en;
  129. u32 ptype;
  130. };
  131. struct cpsw_slave_regs {
  132. u32 max_blks;
  133. u32 blk_cnt;
  134. u32 flow_thresh;
  135. u32 port_vlan;
  136. u32 tx_pri_map;
  137. u32 ts_ctl;
  138. u32 ts_seq_ltype;
  139. u32 ts_vlan;
  140. u32 sa_lo;
  141. u32 sa_hi;
  142. };
  143. struct cpsw_host_regs {
  144. u32 max_blks;
  145. u32 blk_cnt;
  146. u32 flow_thresh;
  147. u32 port_vlan;
  148. u32 tx_pri_map;
  149. u32 cpdma_tx_pri_map;
  150. u32 cpdma_rx_chan_map;
  151. };
  152. struct cpsw_sliver_regs {
  153. u32 id_ver;
  154. u32 mac_control;
  155. u32 mac_status;
  156. u32 soft_reset;
  157. u32 rx_maxlen;
  158. u32 __reserved_0;
  159. u32 rx_pause;
  160. u32 tx_pause;
  161. u32 __reserved_1;
  162. u32 rx_pri_map;
  163. };
  164. struct cpsw_slave {
  165. struct cpsw_slave_regs __iomem *regs;
  166. struct cpsw_sliver_regs __iomem *sliver;
  167. int slave_num;
  168. u32 mac_control;
  169. struct cpsw_slave_data *data;
  170. struct phy_device *phy;
  171. };
  172. struct cpsw_priv {
  173. spinlock_t lock;
  174. struct platform_device *pdev;
  175. struct net_device *ndev;
  176. struct resource *cpsw_res;
  177. struct resource *cpsw_ss_res;
  178. struct napi_struct napi;
  179. struct device *dev;
  180. struct cpsw_platform_data data;
  181. struct cpsw_regs __iomem *regs;
  182. struct cpsw_ss_regs __iomem *ss_regs;
  183. struct cpsw_host_regs __iomem *host_port_regs;
  184. u32 msg_enable;
  185. struct net_device_stats stats;
  186. int rx_packet_max;
  187. int host_port;
  188. struct clk *clk;
  189. u8 mac_addr[ETH_ALEN];
  190. struct cpsw_slave *slaves;
  191. struct cpdma_ctlr *dma;
  192. struct cpdma_chan *txch, *rxch;
  193. struct cpsw_ale *ale;
  194. /* snapshot of IRQ numbers */
  195. u32 irqs_table[4];
  196. u32 num_irqs;
  197. };
  198. #define napi_to_priv(napi) container_of(napi, struct cpsw_priv, napi)
  199. #define for_each_slave(priv, func, arg...) \
  200. do { \
  201. int idx; \
  202. for (idx = 0; idx < (priv)->data.slaves; idx++) \
  203. (func)((priv)->slaves + idx, ##arg); \
  204. } while (0)
  205. static void cpsw_intr_enable(struct cpsw_priv *priv)
  206. {
  207. __raw_writel(0xFF, &priv->ss_regs->tx_en);
  208. __raw_writel(0xFF, &priv->ss_regs->rx_en);
  209. cpdma_ctlr_int_ctrl(priv->dma, true);
  210. return;
  211. }
  212. static void cpsw_intr_disable(struct cpsw_priv *priv)
  213. {
  214. __raw_writel(0, &priv->ss_regs->tx_en);
  215. __raw_writel(0, &priv->ss_regs->rx_en);
  216. cpdma_ctlr_int_ctrl(priv->dma, false);
  217. return;
  218. }
  219. void cpsw_tx_handler(void *token, int len, int status)
  220. {
  221. struct sk_buff *skb = token;
  222. struct net_device *ndev = skb->dev;
  223. struct cpsw_priv *priv = netdev_priv(ndev);
  224. if (unlikely(netif_queue_stopped(ndev)))
  225. netif_start_queue(ndev);
  226. priv->stats.tx_packets++;
  227. priv->stats.tx_bytes += len;
  228. dev_kfree_skb_any(skb);
  229. }
  230. void cpsw_rx_handler(void *token, int len, int status)
  231. {
  232. struct sk_buff *skb = token;
  233. struct net_device *ndev = skb->dev;
  234. struct cpsw_priv *priv = netdev_priv(ndev);
  235. int ret = 0;
  236. /* free and bail if we are shutting down */
  237. if (unlikely(!netif_running(ndev)) ||
  238. unlikely(!netif_carrier_ok(ndev))) {
  239. dev_kfree_skb_any(skb);
  240. return;
  241. }
  242. if (likely(status >= 0)) {
  243. skb_put(skb, len);
  244. skb->protocol = eth_type_trans(skb, ndev);
  245. netif_receive_skb(skb);
  246. priv->stats.rx_bytes += len;
  247. priv->stats.rx_packets++;
  248. skb = NULL;
  249. }
  250. if (unlikely(!netif_running(ndev))) {
  251. if (skb)
  252. dev_kfree_skb_any(skb);
  253. return;
  254. }
  255. if (likely(!skb)) {
  256. skb = netdev_alloc_skb_ip_align(ndev, priv->rx_packet_max);
  257. if (WARN_ON(!skb))
  258. return;
  259. ret = cpdma_chan_submit(priv->rxch, skb, skb->data,
  260. skb_tailroom(skb), GFP_KERNEL);
  261. }
  262. WARN_ON(ret < 0);
  263. }
  264. static irqreturn_t cpsw_interrupt(int irq, void *dev_id)
  265. {
  266. struct cpsw_priv *priv = dev_id;
  267. if (likely(netif_running(priv->ndev))) {
  268. cpsw_intr_disable(priv);
  269. cpsw_disable_irq(priv);
  270. napi_schedule(&priv->napi);
  271. }
  272. return IRQ_HANDLED;
  273. }
  274. static inline int cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num)
  275. {
  276. if (priv->host_port == 0)
  277. return slave_num + 1;
  278. else
  279. return slave_num;
  280. }
  281. static int cpsw_poll(struct napi_struct *napi, int budget)
  282. {
  283. struct cpsw_priv *priv = napi_to_priv(napi);
  284. int num_tx, num_rx;
  285. num_tx = cpdma_chan_process(priv->txch, 128);
  286. num_rx = cpdma_chan_process(priv->rxch, budget);
  287. if (num_rx || num_tx)
  288. cpsw_dbg(priv, intr, "poll %d rx, %d tx pkts\n",
  289. num_rx, num_tx);
  290. if (num_rx < budget) {
  291. napi_complete(napi);
  292. cpsw_intr_enable(priv);
  293. cpdma_ctlr_eoi(priv->dma);
  294. cpsw_enable_irq(priv);
  295. }
  296. return num_rx;
  297. }
  298. static inline void soft_reset(const char *module, void __iomem *reg)
  299. {
  300. unsigned long timeout = jiffies + HZ;
  301. __raw_writel(1, reg);
  302. do {
  303. cpu_relax();
  304. } while ((__raw_readl(reg) & 1) && time_after(timeout, jiffies));
  305. WARN(__raw_readl(reg) & 1, "failed to soft-reset %s\n", module);
  306. }
  307. #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \
  308. ((mac)[2] << 16) | ((mac)[3] << 24))
  309. #define mac_lo(mac) (((mac)[4] << 0) | ((mac)[5] << 8))
  310. static void cpsw_set_slave_mac(struct cpsw_slave *slave,
  311. struct cpsw_priv *priv)
  312. {
  313. __raw_writel(mac_hi(priv->mac_addr), &slave->regs->sa_hi);
  314. __raw_writel(mac_lo(priv->mac_addr), &slave->regs->sa_lo);
  315. }
  316. static void _cpsw_adjust_link(struct cpsw_slave *slave,
  317. struct cpsw_priv *priv, bool *link)
  318. {
  319. struct phy_device *phy = slave->phy;
  320. u32 mac_control = 0;
  321. u32 slave_port;
  322. if (!phy)
  323. return;
  324. slave_port = cpsw_get_slave_port(priv, slave->slave_num);
  325. if (phy->link) {
  326. mac_control = priv->data.mac_control;
  327. /* enable forwarding */
  328. cpsw_ale_control_set(priv->ale, slave_port,
  329. ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
  330. if (phy->speed == 1000)
  331. mac_control |= BIT(7); /* GIGABITEN */
  332. if (phy->duplex)
  333. mac_control |= BIT(0); /* FULLDUPLEXEN */
  334. /* set speed_in input in case RMII mode is used in 100Mbps */
  335. if (phy->speed == 100)
  336. mac_control |= BIT(15);
  337. *link = true;
  338. } else {
  339. mac_control = 0;
  340. /* disable forwarding */
  341. cpsw_ale_control_set(priv->ale, slave_port,
  342. ALE_PORT_STATE, ALE_PORT_STATE_DISABLE);
  343. }
  344. if (mac_control != slave->mac_control) {
  345. phy_print_status(phy);
  346. __raw_writel(mac_control, &slave->sliver->mac_control);
  347. }
  348. slave->mac_control = mac_control;
  349. }
  350. static void cpsw_adjust_link(struct net_device *ndev)
  351. {
  352. struct cpsw_priv *priv = netdev_priv(ndev);
  353. bool link = false;
  354. for_each_slave(priv, _cpsw_adjust_link, priv, &link);
  355. if (link) {
  356. netif_carrier_on(ndev);
  357. if (netif_running(ndev))
  358. netif_wake_queue(ndev);
  359. } else {
  360. netif_carrier_off(ndev);
  361. netif_stop_queue(ndev);
  362. }
  363. }
  364. static inline int __show_stat(char *buf, int maxlen, const char *name, u32 val)
  365. {
  366. static char *leader = "........................................";
  367. if (!val)
  368. return 0;
  369. else
  370. return snprintf(buf, maxlen, "%s %s %10d\n", name,
  371. leader + strlen(name), val);
  372. }
  373. static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
  374. {
  375. char name[32];
  376. u32 slave_port;
  377. sprintf(name, "slave-%d", slave->slave_num);
  378. soft_reset(name, &slave->sliver->soft_reset);
  379. /* setup priority mapping */
  380. __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map);
  381. __raw_writel(TX_PRIORITY_MAPPING, &slave->regs->tx_pri_map);
  382. /* setup max packet size, and mac address */
  383. __raw_writel(priv->rx_packet_max, &slave->sliver->rx_maxlen);
  384. cpsw_set_slave_mac(slave, priv);
  385. slave->mac_control = 0; /* no link yet */
  386. slave_port = cpsw_get_slave_port(priv, slave->slave_num);
  387. cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
  388. 1 << slave_port, 0, ALE_MCAST_FWD_2);
  389. slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
  390. &cpsw_adjust_link, 0, slave->data->phy_if);
  391. if (IS_ERR(slave->phy)) {
  392. dev_err(priv->dev, "phy %s not found on slave %d\n",
  393. slave->data->phy_id, slave->slave_num);
  394. slave->phy = NULL;
  395. } else {
  396. dev_info(priv->dev, "phy found : id is : 0x%x\n",
  397. slave->phy->phy_id);
  398. phy_start(slave->phy);
  399. }
  400. }
  401. static void cpsw_init_host_port(struct cpsw_priv *priv)
  402. {
  403. /* soft reset the controller and initialize ale */
  404. soft_reset("cpsw", &priv->regs->soft_reset);
  405. cpsw_ale_start(priv->ale);
  406. /* switch to vlan unaware mode */
  407. cpsw_ale_control_set(priv->ale, 0, ALE_VLAN_AWARE, 0);
  408. /* setup host port priority mapping */
  409. __raw_writel(CPDMA_TX_PRIORITY_MAP,
  410. &priv->host_port_regs->cpdma_tx_pri_map);
  411. __raw_writel(0, &priv->host_port_regs->cpdma_rx_chan_map);
  412. cpsw_ale_control_set(priv->ale, priv->host_port,
  413. ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
  414. cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, 0);
  415. cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
  416. 1 << priv->host_port, 0, ALE_MCAST_FWD_2);
  417. }
  418. static int cpsw_ndo_open(struct net_device *ndev)
  419. {
  420. struct cpsw_priv *priv = netdev_priv(ndev);
  421. int i, ret;
  422. u32 reg;
  423. cpsw_intr_disable(priv);
  424. netif_carrier_off(ndev);
  425. pm_runtime_get_sync(&priv->pdev->dev);
  426. reg = __raw_readl(&priv->regs->id_ver);
  427. dev_info(priv->dev, "initializing cpsw version %d.%d (%d)\n",
  428. CPSW_MAJOR_VERSION(reg), CPSW_MINOR_VERSION(reg),
  429. CPSW_RTL_VERSION(reg));
  430. /* initialize host and slave ports */
  431. cpsw_init_host_port(priv);
  432. for_each_slave(priv, cpsw_slave_open, priv);
  433. /* setup tx dma to fixed prio and zero offset */
  434. cpdma_control_set(priv->dma, CPDMA_TX_PRIO_FIXED, 1);
  435. cpdma_control_set(priv->dma, CPDMA_RX_BUFFER_OFFSET, 0);
  436. /* disable priority elevation and enable statistics on all ports */
  437. __raw_writel(0, &priv->regs->ptype);
  438. /* enable statistics collection only on the host port */
  439. __raw_writel(0x7, &priv->regs->stat_port_en);
  440. if (WARN_ON(!priv->data.rx_descs))
  441. priv->data.rx_descs = 128;
  442. for (i = 0; i < priv->data.rx_descs; i++) {
  443. struct sk_buff *skb;
  444. ret = -ENOMEM;
  445. skb = netdev_alloc_skb_ip_align(priv->ndev,
  446. priv->rx_packet_max);
  447. if (!skb)
  448. break;
  449. ret = cpdma_chan_submit(priv->rxch, skb, skb->data,
  450. skb_tailroom(skb), GFP_KERNEL);
  451. if (WARN_ON(ret < 0))
  452. break;
  453. }
  454. /* continue even if we didn't manage to submit all receive descs */
  455. cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i);
  456. cpdma_ctlr_start(priv->dma);
  457. cpsw_intr_enable(priv);
  458. napi_enable(&priv->napi);
  459. cpdma_ctlr_eoi(priv->dma);
  460. return 0;
  461. }
  462. static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv)
  463. {
  464. if (!slave->phy)
  465. return;
  466. phy_stop(slave->phy);
  467. phy_disconnect(slave->phy);
  468. slave->phy = NULL;
  469. }
  470. static int cpsw_ndo_stop(struct net_device *ndev)
  471. {
  472. struct cpsw_priv *priv = netdev_priv(ndev);
  473. cpsw_info(priv, ifdown, "shutting down cpsw device\n");
  474. cpsw_intr_disable(priv);
  475. cpdma_ctlr_int_ctrl(priv->dma, false);
  476. cpdma_ctlr_stop(priv->dma);
  477. netif_stop_queue(priv->ndev);
  478. napi_disable(&priv->napi);
  479. netif_carrier_off(priv->ndev);
  480. cpsw_ale_stop(priv->ale);
  481. for_each_slave(priv, cpsw_slave_stop, priv);
  482. pm_runtime_put_sync(&priv->pdev->dev);
  483. return 0;
  484. }
  485. static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
  486. struct net_device *ndev)
  487. {
  488. struct cpsw_priv *priv = netdev_priv(ndev);
  489. int ret;
  490. ndev->trans_start = jiffies;
  491. if (skb_padto(skb, CPSW_MIN_PACKET_SIZE)) {
  492. cpsw_err(priv, tx_err, "packet pad failed\n");
  493. priv->stats.tx_dropped++;
  494. return NETDEV_TX_OK;
  495. }
  496. ret = cpdma_chan_submit(priv->txch, skb, skb->data,
  497. skb->len, GFP_KERNEL);
  498. if (unlikely(ret != 0)) {
  499. cpsw_err(priv, tx_err, "desc submit failed\n");
  500. goto fail;
  501. }
  502. return NETDEV_TX_OK;
  503. fail:
  504. priv->stats.tx_dropped++;
  505. netif_stop_queue(ndev);
  506. return NETDEV_TX_BUSY;
  507. }
  508. static void cpsw_ndo_change_rx_flags(struct net_device *ndev, int flags)
  509. {
  510. /*
  511. * The switch cannot operate in promiscuous mode without substantial
  512. * headache. For promiscuous mode to work, we would need to put the
  513. * ALE in bypass mode and route all traffic to the host port.
  514. * Subsequently, the host will need to operate as a "bridge", learn,
  515. * and flood as needed. For now, we simply complain here and
  516. * do nothing about it :-)
  517. */
  518. if ((flags & IFF_PROMISC) && (ndev->flags & IFF_PROMISC))
  519. dev_err(&ndev->dev, "promiscuity ignored!\n");
  520. /*
  521. * The switch cannot filter multicast traffic unless it is configured
  522. * in "VLAN Aware" mode. Unfortunately, VLAN awareness requires a
  523. * whole bunch of additional logic that this driver does not implement
  524. * at present.
  525. */
  526. if ((flags & IFF_ALLMULTI) && !(ndev->flags & IFF_ALLMULTI))
  527. dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n");
  528. }
  529. static void cpsw_ndo_tx_timeout(struct net_device *ndev)
  530. {
  531. struct cpsw_priv *priv = netdev_priv(ndev);
  532. cpsw_err(priv, tx_err, "transmit timeout, restarting dma\n");
  533. priv->stats.tx_errors++;
  534. cpsw_intr_disable(priv);
  535. cpdma_ctlr_int_ctrl(priv->dma, false);
  536. cpdma_chan_stop(priv->txch);
  537. cpdma_chan_start(priv->txch);
  538. cpdma_ctlr_int_ctrl(priv->dma, true);
  539. cpsw_intr_enable(priv);
  540. cpdma_ctlr_eoi(priv->dma);
  541. }
  542. static struct net_device_stats *cpsw_ndo_get_stats(struct net_device *ndev)
  543. {
  544. struct cpsw_priv *priv = netdev_priv(ndev);
  545. return &priv->stats;
  546. }
  547. #ifdef CONFIG_NET_POLL_CONTROLLER
  548. static void cpsw_ndo_poll_controller(struct net_device *ndev)
  549. {
  550. struct cpsw_priv *priv = netdev_priv(ndev);
  551. cpsw_intr_disable(priv);
  552. cpdma_ctlr_int_ctrl(priv->dma, false);
  553. cpsw_interrupt(ndev->irq, priv);
  554. cpdma_ctlr_int_ctrl(priv->dma, true);
  555. cpsw_intr_enable(priv);
  556. cpdma_ctlr_eoi(priv->dma);
  557. }
  558. #endif
  559. static const struct net_device_ops cpsw_netdev_ops = {
  560. .ndo_open = cpsw_ndo_open,
  561. .ndo_stop = cpsw_ndo_stop,
  562. .ndo_start_xmit = cpsw_ndo_start_xmit,
  563. .ndo_change_rx_flags = cpsw_ndo_change_rx_flags,
  564. .ndo_validate_addr = eth_validate_addr,
  565. .ndo_change_mtu = eth_change_mtu,
  566. .ndo_tx_timeout = cpsw_ndo_tx_timeout,
  567. .ndo_get_stats = cpsw_ndo_get_stats,
  568. #ifdef CONFIG_NET_POLL_CONTROLLER
  569. .ndo_poll_controller = cpsw_ndo_poll_controller,
  570. #endif
  571. };
  572. static void cpsw_get_drvinfo(struct net_device *ndev,
  573. struct ethtool_drvinfo *info)
  574. {
  575. struct cpsw_priv *priv = netdev_priv(ndev);
  576. strcpy(info->driver, "TI CPSW Driver v1.0");
  577. strcpy(info->version, "1.0");
  578. strcpy(info->bus_info, priv->pdev->name);
  579. }
  580. static u32 cpsw_get_msglevel(struct net_device *ndev)
  581. {
  582. struct cpsw_priv *priv = netdev_priv(ndev);
  583. return priv->msg_enable;
  584. }
  585. static void cpsw_set_msglevel(struct net_device *ndev, u32 value)
  586. {
  587. struct cpsw_priv *priv = netdev_priv(ndev);
  588. priv->msg_enable = value;
  589. }
  590. static const struct ethtool_ops cpsw_ethtool_ops = {
  591. .get_drvinfo = cpsw_get_drvinfo,
  592. .get_msglevel = cpsw_get_msglevel,
  593. .set_msglevel = cpsw_set_msglevel,
  594. .get_link = ethtool_op_get_link,
  595. };
  596. static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv)
  597. {
  598. void __iomem *regs = priv->regs;
  599. int slave_num = slave->slave_num;
  600. struct cpsw_slave_data *data = priv->data.slave_data + slave_num;
  601. slave->data = data;
  602. slave->regs = regs + data->slave_reg_ofs;
  603. slave->sliver = regs + data->sliver_reg_ofs;
  604. }
  605. static int cpsw_probe_dt(struct cpsw_platform_data *data,
  606. struct platform_device *pdev)
  607. {
  608. struct device_node *node = pdev->dev.of_node;
  609. struct device_node *slave_node;
  610. int i = 0, ret;
  611. u32 prop;
  612. if (!node)
  613. return -EINVAL;
  614. if (of_property_read_u32(node, "slaves", &prop)) {
  615. pr_err("Missing slaves property in the DT.\n");
  616. return -EINVAL;
  617. }
  618. data->slaves = prop;
  619. data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) *
  620. data->slaves, GFP_KERNEL);
  621. if (!data->slave_data) {
  622. pr_err("Could not allocate slave memory.\n");
  623. return -EINVAL;
  624. }
  625. data->no_bd_ram = of_property_read_bool(node, "no_bd_ram");
  626. if (of_property_read_u32(node, "cpdma_channels", &prop)) {
  627. pr_err("Missing cpdma_channels property in the DT.\n");
  628. ret = -EINVAL;
  629. goto error_ret;
  630. }
  631. data->channels = prop;
  632. if (of_property_read_u32(node, "host_port_no", &prop)) {
  633. pr_err("Missing host_port_no property in the DT.\n");
  634. ret = -EINVAL;
  635. goto error_ret;
  636. }
  637. data->host_port_num = prop;
  638. if (of_property_read_u32(node, "cpdma_reg_ofs", &prop)) {
  639. pr_err("Missing cpdma_reg_ofs property in the DT.\n");
  640. ret = -EINVAL;
  641. goto error_ret;
  642. }
  643. data->cpdma_reg_ofs = prop;
  644. if (of_property_read_u32(node, "cpdma_sram_ofs", &prop)) {
  645. pr_err("Missing cpdma_sram_ofs property in the DT.\n");
  646. ret = -EINVAL;
  647. goto error_ret;
  648. }
  649. data->cpdma_sram_ofs = prop;
  650. if (of_property_read_u32(node, "ale_reg_ofs", &prop)) {
  651. pr_err("Missing ale_reg_ofs property in the DT.\n");
  652. ret = -EINVAL;
  653. goto error_ret;
  654. }
  655. data->ale_reg_ofs = prop;
  656. if (of_property_read_u32(node, "ale_entries", &prop)) {
  657. pr_err("Missing ale_entries property in the DT.\n");
  658. ret = -EINVAL;
  659. goto error_ret;
  660. }
  661. data->ale_entries = prop;
  662. if (of_property_read_u32(node, "host_port_reg_ofs", &prop)) {
  663. pr_err("Missing host_port_reg_ofs property in the DT.\n");
  664. ret = -EINVAL;
  665. goto error_ret;
  666. }
  667. data->host_port_reg_ofs = prop;
  668. if (of_property_read_u32(node, "hw_stats_reg_ofs", &prop)) {
  669. pr_err("Missing hw_stats_reg_ofs property in the DT.\n");
  670. ret = -EINVAL;
  671. goto error_ret;
  672. }
  673. data->hw_stats_reg_ofs = prop;
  674. if (of_property_read_u32(node, "bd_ram_ofs", &prop)) {
  675. pr_err("Missing bd_ram_ofs property in the DT.\n");
  676. ret = -EINVAL;
  677. goto error_ret;
  678. }
  679. data->bd_ram_ofs = prop;
  680. if (of_property_read_u32(node, "bd_ram_size", &prop)) {
  681. pr_err("Missing bd_ram_size property in the DT.\n");
  682. ret = -EINVAL;
  683. goto error_ret;
  684. }
  685. data->bd_ram_size = prop;
  686. if (of_property_read_u32(node, "rx_descs", &prop)) {
  687. pr_err("Missing rx_descs property in the DT.\n");
  688. ret = -EINVAL;
  689. goto error_ret;
  690. }
  691. data->rx_descs = prop;
  692. if (of_property_read_u32(node, "mac_control", &prop)) {
  693. pr_err("Missing mac_control property in the DT.\n");
  694. ret = -EINVAL;
  695. goto error_ret;
  696. }
  697. data->mac_control = prop;
  698. for_each_child_of_node(node, slave_node) {
  699. struct cpsw_slave_data *slave_data = data->slave_data + i;
  700. const char *phy_id = NULL;
  701. const void *mac_addr = NULL;
  702. if (of_property_read_string(slave_node, "phy_id", &phy_id)) {
  703. pr_err("Missing slave[%d] phy_id property\n", i);
  704. ret = -EINVAL;
  705. goto error_ret;
  706. }
  707. slave_data->phy_id = phy_id;
  708. if (of_property_read_u32(slave_node, "slave_reg_ofs", &prop)) {
  709. pr_err("Missing slave[%d] slave_reg_ofs property\n", i);
  710. ret = -EINVAL;
  711. goto error_ret;
  712. }
  713. slave_data->slave_reg_ofs = prop;
  714. if (of_property_read_u32(slave_node, "sliver_reg_ofs",
  715. &prop)) {
  716. pr_err("Missing slave[%d] sliver_reg_ofs property\n",
  717. i);
  718. ret = -EINVAL;
  719. goto error_ret;
  720. }
  721. slave_data->sliver_reg_ofs = prop;
  722. mac_addr = of_get_mac_address(slave_node);
  723. if (mac_addr)
  724. memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN);
  725. i++;
  726. }
  727. return 0;
  728. error_ret:
  729. kfree(data->slave_data);
  730. return ret;
  731. }
  732. static int __devinit cpsw_probe(struct platform_device *pdev)
  733. {
  734. struct cpsw_platform_data *data = pdev->dev.platform_data;
  735. struct net_device *ndev;
  736. struct cpsw_priv *priv;
  737. struct cpdma_params dma_params;
  738. struct cpsw_ale_params ale_params;
  739. void __iomem *regs;
  740. struct resource *res;
  741. int ret = 0, i, k = 0;
  742. ndev = alloc_etherdev(sizeof(struct cpsw_priv));
  743. if (!ndev) {
  744. pr_err("error allocating net_device\n");
  745. return -ENOMEM;
  746. }
  747. platform_set_drvdata(pdev, ndev);
  748. priv = netdev_priv(ndev);
  749. spin_lock_init(&priv->lock);
  750. priv->pdev = pdev;
  751. priv->ndev = ndev;
  752. priv->dev = &ndev->dev;
  753. priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG);
  754. priv->rx_packet_max = max(rx_packet_max, 128);
  755. if (cpsw_probe_dt(&priv->data, pdev)) {
  756. pr_err("cpsw: platform data missing\n");
  757. ret = -ENODEV;
  758. goto clean_ndev_ret;
  759. }
  760. data = &priv->data;
  761. if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
  762. memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
  763. pr_info("Detected MACID = %pM", priv->mac_addr);
  764. } else {
  765. eth_random_addr(priv->mac_addr);
  766. pr_info("Random MACID = %pM", priv->mac_addr);
  767. }
  768. memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
  769. priv->slaves = kzalloc(sizeof(struct cpsw_slave) * data->slaves,
  770. GFP_KERNEL);
  771. if (!priv->slaves) {
  772. ret = -EBUSY;
  773. goto clean_ndev_ret;
  774. }
  775. for (i = 0; i < data->slaves; i++)
  776. priv->slaves[i].slave_num = i;
  777. pm_runtime_enable(&pdev->dev);
  778. priv->clk = clk_get(&pdev->dev, "fck");
  779. if (IS_ERR(priv->clk)) {
  780. dev_err(&pdev->dev, "fck is not found\n");
  781. ret = -ENODEV;
  782. goto clean_slave_ret;
  783. }
  784. priv->cpsw_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  785. if (!priv->cpsw_res) {
  786. dev_err(priv->dev, "error getting i/o resource\n");
  787. ret = -ENOENT;
  788. goto clean_clk_ret;
  789. }
  790. if (!request_mem_region(priv->cpsw_res->start,
  791. resource_size(priv->cpsw_res), ndev->name)) {
  792. dev_err(priv->dev, "failed request i/o region\n");
  793. ret = -ENXIO;
  794. goto clean_clk_ret;
  795. }
  796. regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res));
  797. if (!regs) {
  798. dev_err(priv->dev, "unable to map i/o region\n");
  799. goto clean_cpsw_iores_ret;
  800. }
  801. priv->regs = regs;
  802. priv->host_port = data->host_port_num;
  803. priv->host_port_regs = regs + data->host_port_reg_ofs;
  804. priv->cpsw_ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  805. if (!priv->cpsw_ss_res) {
  806. dev_err(priv->dev, "error getting i/o resource\n");
  807. ret = -ENOENT;
  808. goto clean_clk_ret;
  809. }
  810. if (!request_mem_region(priv->cpsw_ss_res->start,
  811. resource_size(priv->cpsw_ss_res), ndev->name)) {
  812. dev_err(priv->dev, "failed request i/o region\n");
  813. ret = -ENXIO;
  814. goto clean_clk_ret;
  815. }
  816. regs = ioremap(priv->cpsw_ss_res->start,
  817. resource_size(priv->cpsw_ss_res));
  818. if (!regs) {
  819. dev_err(priv->dev, "unable to map i/o region\n");
  820. goto clean_cpsw_ss_iores_ret;
  821. }
  822. priv->ss_regs = regs;
  823. for_each_slave(priv, cpsw_slave_init, priv);
  824. memset(&dma_params, 0, sizeof(dma_params));
  825. dma_params.dev = &pdev->dev;
  826. dma_params.dmaregs = cpsw_dma_regs((u32)priv->regs,
  827. data->cpdma_reg_ofs);
  828. dma_params.rxthresh = cpsw_dma_rxthresh((u32)priv->regs,
  829. data->cpdma_reg_ofs);
  830. dma_params.rxfree = cpsw_dma_rxfree((u32)priv->regs,
  831. data->cpdma_reg_ofs);
  832. dma_params.txhdp = cpsw_dma_txhdp((u32)priv->regs,
  833. data->cpdma_sram_ofs);
  834. dma_params.rxhdp = cpsw_dma_rxhdp((u32)priv->regs,
  835. data->cpdma_sram_ofs);
  836. dma_params.txcp = cpsw_dma_txcp((u32)priv->regs,
  837. data->cpdma_sram_ofs);
  838. dma_params.rxcp = cpsw_dma_rxcp((u32)priv->regs,
  839. data->cpdma_sram_ofs);
  840. dma_params.num_chan = data->channels;
  841. dma_params.has_soft_reset = true;
  842. dma_params.min_packet_size = CPSW_MIN_PACKET_SIZE;
  843. dma_params.desc_mem_size = data->bd_ram_size;
  844. dma_params.desc_align = 16;
  845. dma_params.has_ext_regs = true;
  846. dma_params.desc_mem_phys = data->no_bd_ram ? 0 :
  847. (u32 __force)priv->cpsw_res->start + data->bd_ram_ofs;
  848. dma_params.desc_hw_addr = data->hw_ram_addr ?
  849. data->hw_ram_addr : dma_params.desc_mem_phys ;
  850. priv->dma = cpdma_ctlr_create(&dma_params);
  851. if (!priv->dma) {
  852. dev_err(priv->dev, "error initializing dma\n");
  853. ret = -ENOMEM;
  854. goto clean_iomap_ret;
  855. }
  856. priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0),
  857. cpsw_tx_handler);
  858. priv->rxch = cpdma_chan_create(priv->dma, rx_chan_num(0),
  859. cpsw_rx_handler);
  860. if (WARN_ON(!priv->txch || !priv->rxch)) {
  861. dev_err(priv->dev, "error initializing dma channels\n");
  862. ret = -ENOMEM;
  863. goto clean_dma_ret;
  864. }
  865. memset(&ale_params, 0, sizeof(ale_params));
  866. ale_params.dev = &ndev->dev;
  867. ale_params.ale_regs = (void *)((u32)priv->regs) +
  868. ((u32)data->ale_reg_ofs);
  869. ale_params.ale_ageout = ale_ageout;
  870. ale_params.ale_entries = data->ale_entries;
  871. ale_params.ale_ports = data->slaves;
  872. priv->ale = cpsw_ale_create(&ale_params);
  873. if (!priv->ale) {
  874. dev_err(priv->dev, "error initializing ale engine\n");
  875. ret = -ENODEV;
  876. goto clean_dma_ret;
  877. }
  878. ndev->irq = platform_get_irq(pdev, 0);
  879. if (ndev->irq < 0) {
  880. dev_err(priv->dev, "error getting irq resource\n");
  881. ret = -ENOENT;
  882. goto clean_ale_ret;
  883. }
  884. while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
  885. for (i = res->start; i <= res->end; i++) {
  886. if (request_irq(i, cpsw_interrupt, IRQF_DISABLED,
  887. dev_name(&pdev->dev), priv)) {
  888. dev_err(priv->dev, "error attaching irq\n");
  889. goto clean_ale_ret;
  890. }
  891. priv->irqs_table[k] = i;
  892. priv->num_irqs = k;
  893. }
  894. k++;
  895. }
  896. ndev->flags |= IFF_ALLMULTI; /* see cpsw_ndo_change_rx_flags() */
  897. ndev->netdev_ops = &cpsw_netdev_ops;
  898. SET_ETHTOOL_OPS(ndev, &cpsw_ethtool_ops);
  899. netif_napi_add(ndev, &priv->napi, cpsw_poll, CPSW_POLL_WEIGHT);
  900. /* register the network device */
  901. SET_NETDEV_DEV(ndev, &pdev->dev);
  902. ret = register_netdev(ndev);
  903. if (ret) {
  904. dev_err(priv->dev, "error registering net device\n");
  905. ret = -ENODEV;
  906. goto clean_irq_ret;
  907. }
  908. cpsw_notice(priv, probe, "initialized device (regs %x, irq %d)\n",
  909. priv->cpsw_res->start, ndev->irq);
  910. return 0;
  911. clean_irq_ret:
  912. free_irq(ndev->irq, priv);
  913. clean_ale_ret:
  914. cpsw_ale_destroy(priv->ale);
  915. clean_dma_ret:
  916. cpdma_chan_destroy(priv->txch);
  917. cpdma_chan_destroy(priv->rxch);
  918. cpdma_ctlr_destroy(priv->dma);
  919. clean_iomap_ret:
  920. iounmap(priv->regs);
  921. clean_cpsw_ss_iores_ret:
  922. release_mem_region(priv->cpsw_ss_res->start,
  923. resource_size(priv->cpsw_ss_res));
  924. clean_cpsw_iores_ret:
  925. release_mem_region(priv->cpsw_res->start,
  926. resource_size(priv->cpsw_res));
  927. clean_clk_ret:
  928. clk_put(priv->clk);
  929. clean_slave_ret:
  930. pm_runtime_disable(&pdev->dev);
  931. kfree(priv->slaves);
  932. clean_ndev_ret:
  933. free_netdev(ndev);
  934. return ret;
  935. }
  936. static int __devexit cpsw_remove(struct platform_device *pdev)
  937. {
  938. struct net_device *ndev = platform_get_drvdata(pdev);
  939. struct cpsw_priv *priv = netdev_priv(ndev);
  940. pr_info("removing device");
  941. platform_set_drvdata(pdev, NULL);
  942. free_irq(ndev->irq, priv);
  943. cpsw_ale_destroy(priv->ale);
  944. cpdma_chan_destroy(priv->txch);
  945. cpdma_chan_destroy(priv->rxch);
  946. cpdma_ctlr_destroy(priv->dma);
  947. iounmap(priv->regs);
  948. release_mem_region(priv->cpsw_res->start,
  949. resource_size(priv->cpsw_res));
  950. release_mem_region(priv->cpsw_ss_res->start,
  951. resource_size(priv->cpsw_ss_res));
  952. pm_runtime_disable(&pdev->dev);
  953. clk_put(priv->clk);
  954. kfree(priv->slaves);
  955. free_netdev(ndev);
  956. return 0;
  957. }
  958. static int cpsw_suspend(struct device *dev)
  959. {
  960. struct platform_device *pdev = to_platform_device(dev);
  961. struct net_device *ndev = platform_get_drvdata(pdev);
  962. if (netif_running(ndev))
  963. cpsw_ndo_stop(ndev);
  964. pm_runtime_put_sync(&pdev->dev);
  965. return 0;
  966. }
  967. static int cpsw_resume(struct device *dev)
  968. {
  969. struct platform_device *pdev = to_platform_device(dev);
  970. struct net_device *ndev = platform_get_drvdata(pdev);
  971. pm_runtime_get_sync(&pdev->dev);
  972. if (netif_running(ndev))
  973. cpsw_ndo_open(ndev);
  974. return 0;
  975. }
  976. static const struct dev_pm_ops cpsw_pm_ops = {
  977. .suspend = cpsw_suspend,
  978. .resume = cpsw_resume,
  979. };
  980. static const struct of_device_id cpsw_of_mtable[] = {
  981. { .compatible = "ti,cpsw", },
  982. { /* sentinel */ },
  983. };
  984. static struct platform_driver cpsw_driver = {
  985. .driver = {
  986. .name = "cpsw",
  987. .owner = THIS_MODULE,
  988. .pm = &cpsw_pm_ops,
  989. .of_match_table = of_match_ptr(cpsw_of_mtable),
  990. },
  991. .probe = cpsw_probe,
  992. .remove = __devexit_p(cpsw_remove),
  993. };
  994. static int __init cpsw_init(void)
  995. {
  996. return platform_driver_register(&cpsw_driver);
  997. }
  998. late_initcall(cpsw_init);
  999. static void __exit cpsw_exit(void)
  1000. {
  1001. platform_driver_unregister(&cpsw_driver);
  1002. }
  1003. module_exit(cpsw_exit);
  1004. MODULE_LICENSE("GPL");
  1005. MODULE_AUTHOR("Cyril Chemparathy <cyril@ti.com>");
  1006. MODULE_AUTHOR("Mugunthan V N <mugunthanvnm@ti.com>");
  1007. MODULE_DESCRIPTION("TI CPSW Ethernet driver");