dsa.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. /*
  2. * net/dsa/dsa.c - Hardware switch handling
  3. * Copyright (c) 2008-2009 Marvell Semiconductor
  4. * Copyright (c) 2013 Florian Fainelli <florian@openwrt.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #include <linux/list.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/slab.h>
  14. #include <linux/module.h>
  15. #include <net/dsa.h>
  16. #include <linux/of.h>
  17. #include <linux/of_mdio.h>
  18. #include <linux/of_platform.h>
  19. #include "dsa_priv.h"
  20. char dsa_driver_version[] = "0.1";
  21. /* switch driver registration ***********************************************/
  22. static DEFINE_MUTEX(dsa_switch_drivers_mutex);
  23. static LIST_HEAD(dsa_switch_drivers);
  24. void register_switch_driver(struct dsa_switch_driver *drv)
  25. {
  26. mutex_lock(&dsa_switch_drivers_mutex);
  27. list_add_tail(&drv->list, &dsa_switch_drivers);
  28. mutex_unlock(&dsa_switch_drivers_mutex);
  29. }
  30. EXPORT_SYMBOL_GPL(register_switch_driver);
  31. void unregister_switch_driver(struct dsa_switch_driver *drv)
  32. {
  33. mutex_lock(&dsa_switch_drivers_mutex);
  34. list_del_init(&drv->list);
  35. mutex_unlock(&dsa_switch_drivers_mutex);
  36. }
  37. EXPORT_SYMBOL_GPL(unregister_switch_driver);
  38. static struct dsa_switch_driver *
  39. dsa_switch_probe(struct device *host_dev, int sw_addr, char **_name)
  40. {
  41. struct dsa_switch_driver *ret;
  42. struct list_head *list;
  43. char *name;
  44. ret = NULL;
  45. name = NULL;
  46. mutex_lock(&dsa_switch_drivers_mutex);
  47. list_for_each(list, &dsa_switch_drivers) {
  48. struct dsa_switch_driver *drv;
  49. drv = list_entry(list, struct dsa_switch_driver, list);
  50. name = drv->probe(host_dev, sw_addr);
  51. if (name != NULL) {
  52. ret = drv;
  53. break;
  54. }
  55. }
  56. mutex_unlock(&dsa_switch_drivers_mutex);
  57. *_name = name;
  58. return ret;
  59. }
  60. /* basic switch operations **************************************************/
  61. static struct dsa_switch *
  62. dsa_switch_setup(struct dsa_switch_tree *dst, int index,
  63. struct device *parent, struct device *host_dev)
  64. {
  65. struct dsa_chip_data *pd = dst->pd->chip + index;
  66. struct dsa_switch_driver *drv;
  67. struct dsa_switch *ds;
  68. int ret;
  69. char *name;
  70. int i;
  71. bool valid_name_found = false;
  72. /*
  73. * Probe for switch model.
  74. */
  75. drv = dsa_switch_probe(host_dev, pd->sw_addr, &name);
  76. if (drv == NULL) {
  77. printk(KERN_ERR "%s[%d]: could not detect attached switch\n",
  78. dst->master_netdev->name, index);
  79. return ERR_PTR(-EINVAL);
  80. }
  81. printk(KERN_INFO "%s[%d]: detected a %s switch\n",
  82. dst->master_netdev->name, index, name);
  83. /*
  84. * Allocate and initialise switch state.
  85. */
  86. ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL);
  87. if (ds == NULL)
  88. return ERR_PTR(-ENOMEM);
  89. ds->dst = dst;
  90. ds->index = index;
  91. ds->pd = dst->pd->chip + index;
  92. ds->drv = drv;
  93. ds->master_dev = host_dev;
  94. /*
  95. * Validate supplied switch configuration.
  96. */
  97. for (i = 0; i < DSA_MAX_PORTS; i++) {
  98. char *name;
  99. name = pd->port_names[i];
  100. if (name == NULL)
  101. continue;
  102. if (!strcmp(name, "cpu")) {
  103. if (dst->cpu_switch != -1) {
  104. printk(KERN_ERR "multiple cpu ports?!\n");
  105. ret = -EINVAL;
  106. goto out;
  107. }
  108. dst->cpu_switch = index;
  109. dst->cpu_port = i;
  110. } else if (!strcmp(name, "dsa")) {
  111. ds->dsa_port_mask |= 1 << i;
  112. } else {
  113. ds->phys_port_mask |= 1 << i;
  114. }
  115. valid_name_found = true;
  116. }
  117. if (!valid_name_found && i == DSA_MAX_PORTS) {
  118. ret = -EINVAL;
  119. goto out;
  120. }
  121. /* Make the built-in MII bus mask match the number of ports,
  122. * switch drivers can override this later
  123. */
  124. ds->phys_mii_mask = ds->phys_port_mask;
  125. /*
  126. * If the CPU connects to this switch, set the switch tree
  127. * tagging protocol to the preferred tagging format of this
  128. * switch.
  129. */
  130. if (dst->cpu_switch == index) {
  131. switch (drv->tag_protocol) {
  132. #ifdef CONFIG_NET_DSA_TAG_DSA
  133. case DSA_TAG_PROTO_DSA:
  134. dst->rcv = dsa_netdev_ops.rcv;
  135. break;
  136. #endif
  137. #ifdef CONFIG_NET_DSA_TAG_EDSA
  138. case DSA_TAG_PROTO_EDSA:
  139. dst->rcv = edsa_netdev_ops.rcv;
  140. break;
  141. #endif
  142. #ifdef CONFIG_NET_DSA_TAG_TRAILER
  143. case DSA_TAG_PROTO_TRAILER:
  144. dst->rcv = trailer_netdev_ops.rcv;
  145. break;
  146. #endif
  147. #ifdef CONFIG_NET_DSA_TAG_BRCM
  148. case DSA_TAG_PROTO_BRCM:
  149. dst->rcv = brcm_netdev_ops.rcv;
  150. break;
  151. #endif
  152. case DSA_TAG_PROTO_NONE:
  153. break;
  154. default:
  155. ret = -ENOPROTOOPT;
  156. goto out;
  157. }
  158. dst->tag_protocol = drv->tag_protocol;
  159. }
  160. /*
  161. * Do basic register setup.
  162. */
  163. ret = drv->setup(ds);
  164. if (ret < 0)
  165. goto out;
  166. ret = drv->set_addr(ds, dst->master_netdev->dev_addr);
  167. if (ret < 0)
  168. goto out;
  169. ds->slave_mii_bus = mdiobus_alloc();
  170. if (ds->slave_mii_bus == NULL) {
  171. ret = -ENOMEM;
  172. goto out;
  173. }
  174. dsa_slave_mii_bus_init(ds);
  175. ret = mdiobus_register(ds->slave_mii_bus);
  176. if (ret < 0)
  177. goto out_free;
  178. /*
  179. * Create network devices for physical switch ports.
  180. */
  181. for (i = 0; i < DSA_MAX_PORTS; i++) {
  182. struct net_device *slave_dev;
  183. if (!(ds->phys_port_mask & (1 << i)))
  184. continue;
  185. slave_dev = dsa_slave_create(ds, parent, i, pd->port_names[i]);
  186. if (slave_dev == NULL) {
  187. printk(KERN_ERR "%s[%d]: can't create dsa "
  188. "slave device for port %d(%s)\n",
  189. dst->master_netdev->name,
  190. index, i, pd->port_names[i]);
  191. continue;
  192. }
  193. ds->ports[i] = slave_dev;
  194. }
  195. return ds;
  196. out_free:
  197. mdiobus_free(ds->slave_mii_bus);
  198. out:
  199. kfree(ds);
  200. return ERR_PTR(ret);
  201. }
  202. static void dsa_switch_destroy(struct dsa_switch *ds)
  203. {
  204. }
  205. #ifdef CONFIG_PM_SLEEP
  206. static int dsa_switch_suspend(struct dsa_switch *ds)
  207. {
  208. int i, ret = 0;
  209. /* Suspend slave network devices */
  210. for (i = 0; i < DSA_MAX_PORTS; i++) {
  211. if (!(ds->phys_port_mask & (1 << i)))
  212. continue;
  213. ret = dsa_slave_suspend(ds->ports[i]);
  214. if (ret)
  215. return ret;
  216. }
  217. if (ds->drv->suspend)
  218. ret = ds->drv->suspend(ds);
  219. return ret;
  220. }
  221. static int dsa_switch_resume(struct dsa_switch *ds)
  222. {
  223. int i, ret = 0;
  224. if (ds->drv->resume)
  225. ret = ds->drv->resume(ds);
  226. if (ret)
  227. return ret;
  228. /* Resume slave network devices */
  229. for (i = 0; i < DSA_MAX_PORTS; i++) {
  230. if (!(ds->phys_port_mask & (1 << i)))
  231. continue;
  232. ret = dsa_slave_resume(ds->ports[i]);
  233. if (ret)
  234. return ret;
  235. }
  236. return 0;
  237. }
  238. #endif
  239. /* link polling *************************************************************/
  240. static void dsa_link_poll_work(struct work_struct *ugly)
  241. {
  242. struct dsa_switch_tree *dst;
  243. int i;
  244. dst = container_of(ugly, struct dsa_switch_tree, link_poll_work);
  245. for (i = 0; i < dst->pd->nr_chips; i++) {
  246. struct dsa_switch *ds = dst->ds[i];
  247. if (ds != NULL && ds->drv->poll_link != NULL)
  248. ds->drv->poll_link(ds);
  249. }
  250. mod_timer(&dst->link_poll_timer, round_jiffies(jiffies + HZ));
  251. }
  252. static void dsa_link_poll_timer(unsigned long _dst)
  253. {
  254. struct dsa_switch_tree *dst = (void *)_dst;
  255. schedule_work(&dst->link_poll_work);
  256. }
  257. /* platform driver init and cleanup *****************************************/
  258. static int dev_is_class(struct device *dev, void *class)
  259. {
  260. if (dev->class != NULL && !strcmp(dev->class->name, class))
  261. return 1;
  262. return 0;
  263. }
  264. static struct device *dev_find_class(struct device *parent, char *class)
  265. {
  266. if (dev_is_class(parent, class)) {
  267. get_device(parent);
  268. return parent;
  269. }
  270. return device_find_child(parent, class, dev_is_class);
  271. }
  272. struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
  273. {
  274. struct device *d;
  275. d = dev_find_class(dev, "mdio_bus");
  276. if (d != NULL) {
  277. struct mii_bus *bus;
  278. bus = to_mii_bus(d);
  279. put_device(d);
  280. return bus;
  281. }
  282. return NULL;
  283. }
  284. EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus);
  285. static struct net_device *dev_to_net_device(struct device *dev)
  286. {
  287. struct device *d;
  288. d = dev_find_class(dev, "net");
  289. if (d != NULL) {
  290. struct net_device *nd;
  291. nd = to_net_dev(d);
  292. dev_hold(nd);
  293. put_device(d);
  294. return nd;
  295. }
  296. return NULL;
  297. }
  298. #ifdef CONFIG_OF
  299. static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
  300. struct dsa_chip_data *cd,
  301. int chip_index,
  302. struct device_node *link)
  303. {
  304. int ret;
  305. const __be32 *reg;
  306. int link_port_addr;
  307. int link_sw_addr;
  308. struct device_node *parent_sw;
  309. int len;
  310. parent_sw = of_get_parent(link);
  311. if (!parent_sw)
  312. return -EINVAL;
  313. reg = of_get_property(parent_sw, "reg", &len);
  314. if (!reg || (len != sizeof(*reg) * 2))
  315. return -EINVAL;
  316. link_sw_addr = be32_to_cpup(reg + 1);
  317. if (link_sw_addr >= pd->nr_chips)
  318. return -EINVAL;
  319. /* First time routing table allocation */
  320. if (!cd->rtable) {
  321. cd->rtable = kmalloc(pd->nr_chips * sizeof(s8), GFP_KERNEL);
  322. if (!cd->rtable)
  323. return -ENOMEM;
  324. /* default to no valid uplink/downlink */
  325. memset(cd->rtable, -1, pd->nr_chips * sizeof(s8));
  326. }
  327. reg = of_get_property(link, "reg", NULL);
  328. if (!reg) {
  329. ret = -EINVAL;
  330. goto out;
  331. }
  332. link_port_addr = be32_to_cpup(reg);
  333. cd->rtable[link_sw_addr] = link_port_addr;
  334. return 0;
  335. out:
  336. kfree(cd->rtable);
  337. return ret;
  338. }
  339. static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
  340. {
  341. int i;
  342. int port_index;
  343. for (i = 0; i < pd->nr_chips; i++) {
  344. port_index = 0;
  345. while (port_index < DSA_MAX_PORTS) {
  346. kfree(pd->chip[i].port_names[port_index]);
  347. port_index++;
  348. }
  349. kfree(pd->chip[i].rtable);
  350. }
  351. kfree(pd->chip);
  352. }
  353. static int dsa_of_probe(struct platform_device *pdev)
  354. {
  355. struct device_node *np = pdev->dev.of_node;
  356. struct device_node *child, *mdio, *ethernet, *port, *link;
  357. struct mii_bus *mdio_bus;
  358. struct platform_device *ethernet_dev;
  359. struct dsa_platform_data *pd;
  360. struct dsa_chip_data *cd;
  361. const char *port_name;
  362. int chip_index, port_index;
  363. const unsigned int *sw_addr, *port_reg;
  364. int ret;
  365. mdio = of_parse_phandle(np, "dsa,mii-bus", 0);
  366. if (!mdio)
  367. return -EINVAL;
  368. mdio_bus = of_mdio_find_bus(mdio);
  369. if (!mdio_bus)
  370. return -EINVAL;
  371. ethernet = of_parse_phandle(np, "dsa,ethernet", 0);
  372. if (!ethernet)
  373. return -EINVAL;
  374. ethernet_dev = of_find_device_by_node(ethernet);
  375. if (!ethernet_dev)
  376. return -ENODEV;
  377. pd = kzalloc(sizeof(*pd), GFP_KERNEL);
  378. if (!pd)
  379. return -ENOMEM;
  380. pdev->dev.platform_data = pd;
  381. pd->netdev = &ethernet_dev->dev;
  382. pd->nr_chips = of_get_child_count(np);
  383. if (pd->nr_chips > DSA_MAX_SWITCHES)
  384. pd->nr_chips = DSA_MAX_SWITCHES;
  385. pd->chip = kzalloc(pd->nr_chips * sizeof(struct dsa_chip_data),
  386. GFP_KERNEL);
  387. if (!pd->chip) {
  388. ret = -ENOMEM;
  389. goto out_free;
  390. }
  391. chip_index = -1;
  392. for_each_available_child_of_node(np, child) {
  393. chip_index++;
  394. cd = &pd->chip[chip_index];
  395. cd->of_node = child;
  396. cd->host_dev = &mdio_bus->dev;
  397. sw_addr = of_get_property(child, "reg", NULL);
  398. if (!sw_addr)
  399. continue;
  400. cd->sw_addr = be32_to_cpup(sw_addr);
  401. if (cd->sw_addr > PHY_MAX_ADDR)
  402. continue;
  403. for_each_available_child_of_node(child, port) {
  404. port_reg = of_get_property(port, "reg", NULL);
  405. if (!port_reg)
  406. continue;
  407. port_index = be32_to_cpup(port_reg);
  408. port_name = of_get_property(port, "label", NULL);
  409. if (!port_name)
  410. continue;
  411. cd->port_dn[port_index] = port;
  412. cd->port_names[port_index] = kstrdup(port_name,
  413. GFP_KERNEL);
  414. if (!cd->port_names[port_index]) {
  415. ret = -ENOMEM;
  416. goto out_free_chip;
  417. }
  418. link = of_parse_phandle(port, "link", 0);
  419. if (!strcmp(port_name, "dsa") && link &&
  420. pd->nr_chips > 1) {
  421. ret = dsa_of_setup_routing_table(pd, cd,
  422. chip_index, link);
  423. if (ret)
  424. goto out_free_chip;
  425. }
  426. if (port_index == DSA_MAX_PORTS)
  427. break;
  428. }
  429. }
  430. return 0;
  431. out_free_chip:
  432. dsa_of_free_platform_data(pd);
  433. out_free:
  434. kfree(pd);
  435. pdev->dev.platform_data = NULL;
  436. return ret;
  437. }
  438. static void dsa_of_remove(struct platform_device *pdev)
  439. {
  440. struct dsa_platform_data *pd = pdev->dev.platform_data;
  441. if (!pdev->dev.of_node)
  442. return;
  443. dsa_of_free_platform_data(pd);
  444. kfree(pd);
  445. }
  446. #else
  447. static inline int dsa_of_probe(struct platform_device *pdev)
  448. {
  449. return 0;
  450. }
  451. static inline void dsa_of_remove(struct platform_device *pdev)
  452. {
  453. }
  454. #endif
  455. static int dsa_probe(struct platform_device *pdev)
  456. {
  457. static int dsa_version_printed;
  458. struct dsa_platform_data *pd = pdev->dev.platform_data;
  459. struct net_device *dev;
  460. struct dsa_switch_tree *dst;
  461. int i, ret;
  462. if (!dsa_version_printed++)
  463. printk(KERN_NOTICE "Distributed Switch Architecture "
  464. "driver version %s\n", dsa_driver_version);
  465. if (pdev->dev.of_node) {
  466. ret = dsa_of_probe(pdev);
  467. if (ret)
  468. return ret;
  469. pd = pdev->dev.platform_data;
  470. }
  471. if (pd == NULL || pd->netdev == NULL)
  472. return -EINVAL;
  473. dev = dev_to_net_device(pd->netdev);
  474. if (dev == NULL) {
  475. ret = -EINVAL;
  476. goto out;
  477. }
  478. if (dev->dsa_ptr != NULL) {
  479. dev_put(dev);
  480. ret = -EEXIST;
  481. goto out;
  482. }
  483. dst = kzalloc(sizeof(*dst), GFP_KERNEL);
  484. if (dst == NULL) {
  485. dev_put(dev);
  486. ret = -ENOMEM;
  487. goto out;
  488. }
  489. platform_set_drvdata(pdev, dst);
  490. dst->pd = pd;
  491. dst->master_netdev = dev;
  492. dst->cpu_switch = -1;
  493. dst->cpu_port = -1;
  494. for (i = 0; i < pd->nr_chips; i++) {
  495. struct dsa_switch *ds;
  496. ds = dsa_switch_setup(dst, i, &pdev->dev, pd->chip[i].host_dev);
  497. if (IS_ERR(ds)) {
  498. printk(KERN_ERR "%s[%d]: couldn't create dsa switch "
  499. "instance (error %ld)\n", dev->name, i,
  500. PTR_ERR(ds));
  501. continue;
  502. }
  503. dst->ds[i] = ds;
  504. if (ds->drv->poll_link != NULL)
  505. dst->link_poll_needed = 1;
  506. }
  507. /*
  508. * If we use a tagging format that doesn't have an ethertype
  509. * field, make sure that all packets from this point on get
  510. * sent to the tag format's receive function.
  511. */
  512. wmb();
  513. dev->dsa_ptr = (void *)dst;
  514. if (dst->link_poll_needed) {
  515. INIT_WORK(&dst->link_poll_work, dsa_link_poll_work);
  516. init_timer(&dst->link_poll_timer);
  517. dst->link_poll_timer.data = (unsigned long)dst;
  518. dst->link_poll_timer.function = dsa_link_poll_timer;
  519. dst->link_poll_timer.expires = round_jiffies(jiffies + HZ);
  520. add_timer(&dst->link_poll_timer);
  521. }
  522. return 0;
  523. out:
  524. dsa_of_remove(pdev);
  525. return ret;
  526. }
  527. static int dsa_remove(struct platform_device *pdev)
  528. {
  529. struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
  530. int i;
  531. if (dst->link_poll_needed)
  532. del_timer_sync(&dst->link_poll_timer);
  533. flush_work(&dst->link_poll_work);
  534. for (i = 0; i < dst->pd->nr_chips; i++) {
  535. struct dsa_switch *ds = dst->ds[i];
  536. if (ds != NULL)
  537. dsa_switch_destroy(ds);
  538. }
  539. dsa_of_remove(pdev);
  540. return 0;
  541. }
  542. static void dsa_shutdown(struct platform_device *pdev)
  543. {
  544. }
  545. static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
  546. struct packet_type *pt, struct net_device *orig_dev)
  547. {
  548. struct dsa_switch_tree *dst = dev->dsa_ptr;
  549. if (unlikely(dst == NULL)) {
  550. kfree_skb(skb);
  551. return 0;
  552. }
  553. return dst->rcv(skb, dev, pt, orig_dev);
  554. }
  555. static struct packet_type dsa_pack_type __read_mostly = {
  556. .type = cpu_to_be16(ETH_P_XDSA),
  557. .func = dsa_switch_rcv,
  558. };
  559. #ifdef CONFIG_PM_SLEEP
  560. static int dsa_suspend(struct device *d)
  561. {
  562. struct platform_device *pdev = to_platform_device(d);
  563. struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
  564. int i, ret = 0;
  565. for (i = 0; i < dst->pd->nr_chips; i++) {
  566. struct dsa_switch *ds = dst->ds[i];
  567. if (ds != NULL)
  568. ret = dsa_switch_suspend(ds);
  569. }
  570. return ret;
  571. }
  572. static int dsa_resume(struct device *d)
  573. {
  574. struct platform_device *pdev = to_platform_device(d);
  575. struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
  576. int i, ret = 0;
  577. for (i = 0; i < dst->pd->nr_chips; i++) {
  578. struct dsa_switch *ds = dst->ds[i];
  579. if (ds != NULL)
  580. ret = dsa_switch_resume(ds);
  581. }
  582. return ret;
  583. }
  584. #endif
  585. static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume);
  586. static const struct of_device_id dsa_of_match_table[] = {
  587. { .compatible = "brcm,bcm7445-switch-v4.0" },
  588. { .compatible = "marvell,dsa", },
  589. {}
  590. };
  591. MODULE_DEVICE_TABLE(of, dsa_of_match_table);
  592. static struct platform_driver dsa_driver = {
  593. .probe = dsa_probe,
  594. .remove = dsa_remove,
  595. .shutdown = dsa_shutdown,
  596. .driver = {
  597. .name = "dsa",
  598. .owner = THIS_MODULE,
  599. .of_match_table = dsa_of_match_table,
  600. .pm = &dsa_pm_ops,
  601. },
  602. };
  603. static int __init dsa_init_module(void)
  604. {
  605. int rc;
  606. rc = platform_driver_register(&dsa_driver);
  607. if (rc)
  608. return rc;
  609. dev_add_pack(&dsa_pack_type);
  610. return 0;
  611. }
  612. module_init(dsa_init_module);
  613. static void __exit dsa_cleanup_module(void)
  614. {
  615. dev_remove_pack(&dsa_pack_type);
  616. platform_driver_unregister(&dsa_driver);
  617. }
  618. module_exit(dsa_cleanup_module);
  619. MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
  620. MODULE_DESCRIPTION("Driver for Distributed Switch Architecture switch chips");
  621. MODULE_LICENSE("GPL");
  622. MODULE_ALIAS("platform:dsa");