dsa.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  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. default:
  153. break;
  154. }
  155. dst->tag_protocol = drv->tag_protocol;
  156. }
  157. /*
  158. * Do basic register setup.
  159. */
  160. ret = drv->setup(ds);
  161. if (ret < 0)
  162. goto out;
  163. ret = drv->set_addr(ds, dst->master_netdev->dev_addr);
  164. if (ret < 0)
  165. goto out;
  166. ds->slave_mii_bus = mdiobus_alloc();
  167. if (ds->slave_mii_bus == NULL) {
  168. ret = -ENOMEM;
  169. goto out;
  170. }
  171. dsa_slave_mii_bus_init(ds);
  172. ret = mdiobus_register(ds->slave_mii_bus);
  173. if (ret < 0)
  174. goto out_free;
  175. /*
  176. * Create network devices for physical switch ports.
  177. */
  178. for (i = 0; i < DSA_MAX_PORTS; i++) {
  179. struct net_device *slave_dev;
  180. if (!(ds->phys_port_mask & (1 << i)))
  181. continue;
  182. slave_dev = dsa_slave_create(ds, parent, i, pd->port_names[i]);
  183. if (slave_dev == NULL) {
  184. printk(KERN_ERR "%s[%d]: can't create dsa "
  185. "slave device for port %d(%s)\n",
  186. dst->master_netdev->name,
  187. index, i, pd->port_names[i]);
  188. continue;
  189. }
  190. ds->ports[i] = slave_dev;
  191. }
  192. return ds;
  193. out_free:
  194. mdiobus_free(ds->slave_mii_bus);
  195. out:
  196. kfree(ds);
  197. return ERR_PTR(ret);
  198. }
  199. static void dsa_switch_destroy(struct dsa_switch *ds)
  200. {
  201. }
  202. #ifdef CONFIG_PM_SLEEP
  203. static int dsa_switch_suspend(struct dsa_switch *ds)
  204. {
  205. int i, ret = 0;
  206. /* Suspend slave network devices */
  207. for (i = 0; i < DSA_MAX_PORTS; i++) {
  208. if (!(ds->phys_port_mask & (1 << i)))
  209. continue;
  210. ret = dsa_slave_suspend(ds->ports[i]);
  211. if (ret)
  212. return ret;
  213. }
  214. if (ds->drv->suspend)
  215. ret = ds->drv->suspend(ds);
  216. return ret;
  217. }
  218. static int dsa_switch_resume(struct dsa_switch *ds)
  219. {
  220. int i, ret = 0;
  221. if (ds->drv->resume)
  222. ret = ds->drv->resume(ds);
  223. if (ret)
  224. return ret;
  225. /* Resume slave network devices */
  226. for (i = 0; i < DSA_MAX_PORTS; i++) {
  227. if (!(ds->phys_port_mask & (1 << i)))
  228. continue;
  229. ret = dsa_slave_resume(ds->ports[i]);
  230. if (ret)
  231. return ret;
  232. }
  233. return 0;
  234. }
  235. #endif
  236. /* link polling *************************************************************/
  237. static void dsa_link_poll_work(struct work_struct *ugly)
  238. {
  239. struct dsa_switch_tree *dst;
  240. int i;
  241. dst = container_of(ugly, struct dsa_switch_tree, link_poll_work);
  242. for (i = 0; i < dst->pd->nr_chips; i++) {
  243. struct dsa_switch *ds = dst->ds[i];
  244. if (ds != NULL && ds->drv->poll_link != NULL)
  245. ds->drv->poll_link(ds);
  246. }
  247. mod_timer(&dst->link_poll_timer, round_jiffies(jiffies + HZ));
  248. }
  249. static void dsa_link_poll_timer(unsigned long _dst)
  250. {
  251. struct dsa_switch_tree *dst = (void *)_dst;
  252. schedule_work(&dst->link_poll_work);
  253. }
  254. /* platform driver init and cleanup *****************************************/
  255. static int dev_is_class(struct device *dev, void *class)
  256. {
  257. if (dev->class != NULL && !strcmp(dev->class->name, class))
  258. return 1;
  259. return 0;
  260. }
  261. static struct device *dev_find_class(struct device *parent, char *class)
  262. {
  263. if (dev_is_class(parent, class)) {
  264. get_device(parent);
  265. return parent;
  266. }
  267. return device_find_child(parent, class, dev_is_class);
  268. }
  269. struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
  270. {
  271. struct device *d;
  272. d = dev_find_class(dev, "mdio_bus");
  273. if (d != NULL) {
  274. struct mii_bus *bus;
  275. bus = to_mii_bus(d);
  276. put_device(d);
  277. return bus;
  278. }
  279. return NULL;
  280. }
  281. EXPORT_SYMBOL_GPL(dsa_host_dev_to_mii_bus);
  282. static struct net_device *dev_to_net_device(struct device *dev)
  283. {
  284. struct device *d;
  285. d = dev_find_class(dev, "net");
  286. if (d != NULL) {
  287. struct net_device *nd;
  288. nd = to_net_dev(d);
  289. dev_hold(nd);
  290. put_device(d);
  291. return nd;
  292. }
  293. return NULL;
  294. }
  295. #ifdef CONFIG_OF
  296. static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
  297. struct dsa_chip_data *cd,
  298. int chip_index,
  299. struct device_node *link)
  300. {
  301. int ret;
  302. const __be32 *reg;
  303. int link_port_addr;
  304. int link_sw_addr;
  305. struct device_node *parent_sw;
  306. int len;
  307. parent_sw = of_get_parent(link);
  308. if (!parent_sw)
  309. return -EINVAL;
  310. reg = of_get_property(parent_sw, "reg", &len);
  311. if (!reg || (len != sizeof(*reg) * 2))
  312. return -EINVAL;
  313. link_sw_addr = be32_to_cpup(reg + 1);
  314. if (link_sw_addr >= pd->nr_chips)
  315. return -EINVAL;
  316. /* First time routing table allocation */
  317. if (!cd->rtable) {
  318. cd->rtable = kmalloc(pd->nr_chips * sizeof(s8), GFP_KERNEL);
  319. if (!cd->rtable)
  320. return -ENOMEM;
  321. /* default to no valid uplink/downlink */
  322. memset(cd->rtable, -1, pd->nr_chips * sizeof(s8));
  323. }
  324. reg = of_get_property(link, "reg", NULL);
  325. if (!reg) {
  326. ret = -EINVAL;
  327. goto out;
  328. }
  329. link_port_addr = be32_to_cpup(reg);
  330. cd->rtable[link_sw_addr] = link_port_addr;
  331. return 0;
  332. out:
  333. kfree(cd->rtable);
  334. return ret;
  335. }
  336. static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
  337. {
  338. int i;
  339. int port_index;
  340. for (i = 0; i < pd->nr_chips; i++) {
  341. port_index = 0;
  342. while (port_index < DSA_MAX_PORTS) {
  343. kfree(pd->chip[i].port_names[port_index]);
  344. port_index++;
  345. }
  346. kfree(pd->chip[i].rtable);
  347. }
  348. kfree(pd->chip);
  349. }
  350. static int dsa_of_probe(struct platform_device *pdev)
  351. {
  352. struct device_node *np = pdev->dev.of_node;
  353. struct device_node *child, *mdio, *ethernet, *port, *link;
  354. struct mii_bus *mdio_bus;
  355. struct platform_device *ethernet_dev;
  356. struct dsa_platform_data *pd;
  357. struct dsa_chip_data *cd;
  358. const char *port_name;
  359. int chip_index, port_index;
  360. const unsigned int *sw_addr, *port_reg;
  361. int ret;
  362. mdio = of_parse_phandle(np, "dsa,mii-bus", 0);
  363. if (!mdio)
  364. return -EINVAL;
  365. mdio_bus = of_mdio_find_bus(mdio);
  366. if (!mdio_bus)
  367. return -EINVAL;
  368. ethernet = of_parse_phandle(np, "dsa,ethernet", 0);
  369. if (!ethernet)
  370. return -EINVAL;
  371. ethernet_dev = of_find_device_by_node(ethernet);
  372. if (!ethernet_dev)
  373. return -ENODEV;
  374. pd = kzalloc(sizeof(*pd), GFP_KERNEL);
  375. if (!pd)
  376. return -ENOMEM;
  377. pdev->dev.platform_data = pd;
  378. pd->netdev = &ethernet_dev->dev;
  379. pd->nr_chips = of_get_child_count(np);
  380. if (pd->nr_chips > DSA_MAX_SWITCHES)
  381. pd->nr_chips = DSA_MAX_SWITCHES;
  382. pd->chip = kzalloc(pd->nr_chips * sizeof(struct dsa_chip_data),
  383. GFP_KERNEL);
  384. if (!pd->chip) {
  385. ret = -ENOMEM;
  386. goto out_free;
  387. }
  388. chip_index = -1;
  389. for_each_available_child_of_node(np, child) {
  390. chip_index++;
  391. cd = &pd->chip[chip_index];
  392. cd->of_node = child;
  393. cd->host_dev = &mdio_bus->dev;
  394. sw_addr = of_get_property(child, "reg", NULL);
  395. if (!sw_addr)
  396. continue;
  397. cd->sw_addr = be32_to_cpup(sw_addr);
  398. if (cd->sw_addr > PHY_MAX_ADDR)
  399. continue;
  400. for_each_available_child_of_node(child, port) {
  401. port_reg = of_get_property(port, "reg", NULL);
  402. if (!port_reg)
  403. continue;
  404. port_index = be32_to_cpup(port_reg);
  405. port_name = of_get_property(port, "label", NULL);
  406. if (!port_name)
  407. continue;
  408. cd->port_dn[port_index] = port;
  409. cd->port_names[port_index] = kstrdup(port_name,
  410. GFP_KERNEL);
  411. if (!cd->port_names[port_index]) {
  412. ret = -ENOMEM;
  413. goto out_free_chip;
  414. }
  415. link = of_parse_phandle(port, "link", 0);
  416. if (!strcmp(port_name, "dsa") && link &&
  417. pd->nr_chips > 1) {
  418. ret = dsa_of_setup_routing_table(pd, cd,
  419. chip_index, link);
  420. if (ret)
  421. goto out_free_chip;
  422. }
  423. if (port_index == DSA_MAX_PORTS)
  424. break;
  425. }
  426. }
  427. return 0;
  428. out_free_chip:
  429. dsa_of_free_platform_data(pd);
  430. out_free:
  431. kfree(pd);
  432. pdev->dev.platform_data = NULL;
  433. return ret;
  434. }
  435. static void dsa_of_remove(struct platform_device *pdev)
  436. {
  437. struct dsa_platform_data *pd = pdev->dev.platform_data;
  438. if (!pdev->dev.of_node)
  439. return;
  440. dsa_of_free_platform_data(pd);
  441. kfree(pd);
  442. }
  443. #else
  444. static inline int dsa_of_probe(struct platform_device *pdev)
  445. {
  446. return 0;
  447. }
  448. static inline void dsa_of_remove(struct platform_device *pdev)
  449. {
  450. }
  451. #endif
  452. static int dsa_probe(struct platform_device *pdev)
  453. {
  454. static int dsa_version_printed;
  455. struct dsa_platform_data *pd = pdev->dev.platform_data;
  456. struct net_device *dev;
  457. struct dsa_switch_tree *dst;
  458. int i, ret;
  459. if (!dsa_version_printed++)
  460. printk(KERN_NOTICE "Distributed Switch Architecture "
  461. "driver version %s\n", dsa_driver_version);
  462. if (pdev->dev.of_node) {
  463. ret = dsa_of_probe(pdev);
  464. if (ret)
  465. return ret;
  466. pd = pdev->dev.platform_data;
  467. }
  468. if (pd == NULL || pd->netdev == NULL)
  469. return -EINVAL;
  470. dev = dev_to_net_device(pd->netdev);
  471. if (dev == NULL) {
  472. ret = -EINVAL;
  473. goto out;
  474. }
  475. if (dev->dsa_ptr != NULL) {
  476. dev_put(dev);
  477. ret = -EEXIST;
  478. goto out;
  479. }
  480. dst = kzalloc(sizeof(*dst), GFP_KERNEL);
  481. if (dst == NULL) {
  482. dev_put(dev);
  483. ret = -ENOMEM;
  484. goto out;
  485. }
  486. platform_set_drvdata(pdev, dst);
  487. dst->pd = pd;
  488. dst->master_netdev = dev;
  489. dst->cpu_switch = -1;
  490. dst->cpu_port = -1;
  491. for (i = 0; i < pd->nr_chips; i++) {
  492. struct dsa_switch *ds;
  493. ds = dsa_switch_setup(dst, i, &pdev->dev, pd->chip[i].host_dev);
  494. if (IS_ERR(ds)) {
  495. printk(KERN_ERR "%s[%d]: couldn't create dsa switch "
  496. "instance (error %ld)\n", dev->name, i,
  497. PTR_ERR(ds));
  498. continue;
  499. }
  500. dst->ds[i] = ds;
  501. if (ds->drv->poll_link != NULL)
  502. dst->link_poll_needed = 1;
  503. }
  504. /*
  505. * If we use a tagging format that doesn't have an ethertype
  506. * field, make sure that all packets from this point on get
  507. * sent to the tag format's receive function.
  508. */
  509. wmb();
  510. dev->dsa_ptr = (void *)dst;
  511. if (dst->link_poll_needed) {
  512. INIT_WORK(&dst->link_poll_work, dsa_link_poll_work);
  513. init_timer(&dst->link_poll_timer);
  514. dst->link_poll_timer.data = (unsigned long)dst;
  515. dst->link_poll_timer.function = dsa_link_poll_timer;
  516. dst->link_poll_timer.expires = round_jiffies(jiffies + HZ);
  517. add_timer(&dst->link_poll_timer);
  518. }
  519. return 0;
  520. out:
  521. dsa_of_remove(pdev);
  522. return ret;
  523. }
  524. static int dsa_remove(struct platform_device *pdev)
  525. {
  526. struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
  527. int i;
  528. if (dst->link_poll_needed)
  529. del_timer_sync(&dst->link_poll_timer);
  530. flush_work(&dst->link_poll_work);
  531. for (i = 0; i < dst->pd->nr_chips; i++) {
  532. struct dsa_switch *ds = dst->ds[i];
  533. if (ds != NULL)
  534. dsa_switch_destroy(ds);
  535. }
  536. dsa_of_remove(pdev);
  537. return 0;
  538. }
  539. static void dsa_shutdown(struct platform_device *pdev)
  540. {
  541. }
  542. static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
  543. struct packet_type *pt, struct net_device *orig_dev)
  544. {
  545. struct dsa_switch_tree *dst = dev->dsa_ptr;
  546. if (unlikely(dst == NULL)) {
  547. kfree_skb(skb);
  548. return 0;
  549. }
  550. return dst->rcv(skb, dev, pt, orig_dev);
  551. }
  552. static struct packet_type dsa_pack_type __read_mostly = {
  553. .type = cpu_to_be16(ETH_P_XDSA),
  554. .func = dsa_switch_rcv,
  555. };
  556. #ifdef CONFIG_PM_SLEEP
  557. static int dsa_suspend(struct device *d)
  558. {
  559. struct platform_device *pdev = to_platform_device(d);
  560. struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
  561. int i, ret = 0;
  562. for (i = 0; i < dst->pd->nr_chips; i++) {
  563. struct dsa_switch *ds = dst->ds[i];
  564. if (ds != NULL)
  565. ret = dsa_switch_suspend(ds);
  566. }
  567. return ret;
  568. }
  569. static int dsa_resume(struct device *d)
  570. {
  571. struct platform_device *pdev = to_platform_device(d);
  572. struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
  573. int i, ret = 0;
  574. for (i = 0; i < dst->pd->nr_chips; i++) {
  575. struct dsa_switch *ds = dst->ds[i];
  576. if (ds != NULL)
  577. ret = dsa_switch_resume(ds);
  578. }
  579. return ret;
  580. }
  581. #endif
  582. static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume);
  583. static const struct of_device_id dsa_of_match_table[] = {
  584. { .compatible = "brcm,bcm7445-switch-v4.0" },
  585. { .compatible = "marvell,dsa", },
  586. {}
  587. };
  588. MODULE_DEVICE_TABLE(of, dsa_of_match_table);
  589. static struct platform_driver dsa_driver = {
  590. .probe = dsa_probe,
  591. .remove = dsa_remove,
  592. .shutdown = dsa_shutdown,
  593. .driver = {
  594. .name = "dsa",
  595. .owner = THIS_MODULE,
  596. .of_match_table = dsa_of_match_table,
  597. .pm = &dsa_pm_ops,
  598. },
  599. };
  600. static int __init dsa_init_module(void)
  601. {
  602. int rc;
  603. rc = platform_driver_register(&dsa_driver);
  604. if (rc)
  605. return rc;
  606. dev_add_pack(&dsa_pack_type);
  607. return 0;
  608. }
  609. module_init(dsa_init_module);
  610. static void __exit dsa_cleanup_module(void)
  611. {
  612. dev_remove_pack(&dsa_pack_type);
  613. platform_driver_unregister(&dsa_driver);
  614. }
  615. module_exit(dsa_cleanup_module);
  616. MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
  617. MODULE_DESCRIPTION("Driver for Distributed Switch Architecture switch chips");
  618. MODULE_LICENSE("GPL");
  619. MODULE_ALIAS("platform:dsa");