bcm_sf2.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /*
  2. * Broadcom Starfighter 2 DSA switch driver
  3. *
  4. * Copyright (C) 2014, Broadcom Corporation
  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/module.h>
  13. #include <linux/netdevice.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/of.h>
  17. #include <linux/phy.h>
  18. #include <linux/phy_fixed.h>
  19. #include <linux/mii.h>
  20. #include <linux/of.h>
  21. #include <linux/of_irq.h>
  22. #include <linux/of_address.h>
  23. #include <linux/of_net.h>
  24. #include <linux/of_mdio.h>
  25. #include <net/dsa.h>
  26. #include <linux/ethtool.h>
  27. #include <linux/if_bridge.h>
  28. #include <linux/brcmphy.h>
  29. #include <linux/etherdevice.h>
  30. #include <net/switchdev.h>
  31. #include <linux/platform_data/b53.h>
  32. #include "bcm_sf2.h"
  33. #include "bcm_sf2_regs.h"
  34. #include "b53/b53_priv.h"
  35. #include "b53/b53_regs.h"
  36. static enum dsa_tag_protocol bcm_sf2_sw_get_tag_protocol(struct dsa_switch *ds)
  37. {
  38. return DSA_TAG_PROTO_BRCM;
  39. }
  40. static void bcm_sf2_imp_vlan_setup(struct dsa_switch *ds, int cpu_port)
  41. {
  42. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  43. unsigned int i;
  44. u32 reg;
  45. /* Enable the IMP Port to be in the same VLAN as the other ports
  46. * on a per-port basis such that we only have Port i and IMP in
  47. * the same VLAN.
  48. */
  49. for (i = 0; i < priv->hw_params.num_ports; i++) {
  50. if (!((1 << i) & ds->enabled_port_mask))
  51. continue;
  52. reg = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(i));
  53. reg |= (1 << cpu_port);
  54. core_writel(priv, reg, CORE_PORT_VLAN_CTL_PORT(i));
  55. }
  56. }
  57. static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port)
  58. {
  59. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  60. u32 reg, val;
  61. /* Enable the port memories */
  62. reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
  63. reg &= ~P_TXQ_PSM_VDD(port);
  64. core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL);
  65. /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */
  66. reg = core_readl(priv, CORE_IMP_CTL);
  67. reg |= (RX_BCST_EN | RX_MCST_EN | RX_UCST_EN);
  68. reg &= ~(RX_DIS | TX_DIS);
  69. core_writel(priv, reg, CORE_IMP_CTL);
  70. /* Enable forwarding */
  71. core_writel(priv, SW_FWDG_EN, CORE_SWMODE);
  72. /* Enable IMP port in dumb mode */
  73. reg = core_readl(priv, CORE_SWITCH_CTRL);
  74. reg |= MII_DUMB_FWDG_EN;
  75. core_writel(priv, reg, CORE_SWITCH_CTRL);
  76. /* Resolve which bit controls the Broadcom tag */
  77. switch (port) {
  78. case 8:
  79. val = BRCM_HDR_EN_P8;
  80. break;
  81. case 7:
  82. val = BRCM_HDR_EN_P7;
  83. break;
  84. case 5:
  85. val = BRCM_HDR_EN_P5;
  86. break;
  87. default:
  88. val = 0;
  89. break;
  90. }
  91. /* Enable Broadcom tags for IMP port */
  92. reg = core_readl(priv, CORE_BRCM_HDR_CTRL);
  93. reg |= val;
  94. core_writel(priv, reg, CORE_BRCM_HDR_CTRL);
  95. /* Enable reception Broadcom tag for CPU TX (switch RX) to
  96. * allow us to tag outgoing frames
  97. */
  98. reg = core_readl(priv, CORE_BRCM_HDR_RX_DIS);
  99. reg &= ~(1 << port);
  100. core_writel(priv, reg, CORE_BRCM_HDR_RX_DIS);
  101. /* Enable transmission of Broadcom tags from the switch (CPU RX) to
  102. * allow delivering frames to the per-port net_devices
  103. */
  104. reg = core_readl(priv, CORE_BRCM_HDR_TX_DIS);
  105. reg &= ~(1 << port);
  106. core_writel(priv, reg, CORE_BRCM_HDR_TX_DIS);
  107. /* Force link status for IMP port */
  108. reg = core_readl(priv, CORE_STS_OVERRIDE_IMP);
  109. reg |= (MII_SW_OR | LINK_STS);
  110. core_writel(priv, reg, CORE_STS_OVERRIDE_IMP);
  111. }
  112. static void bcm_sf2_eee_enable_set(struct dsa_switch *ds, int port, bool enable)
  113. {
  114. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  115. u32 reg;
  116. reg = core_readl(priv, CORE_EEE_EN_CTRL);
  117. if (enable)
  118. reg |= 1 << port;
  119. else
  120. reg &= ~(1 << port);
  121. core_writel(priv, reg, CORE_EEE_EN_CTRL);
  122. }
  123. static void bcm_sf2_gphy_enable_set(struct dsa_switch *ds, bool enable)
  124. {
  125. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  126. u32 reg;
  127. reg = reg_readl(priv, REG_SPHY_CNTRL);
  128. if (enable) {
  129. reg |= PHY_RESET;
  130. reg &= ~(EXT_PWR_DOWN | IDDQ_BIAS | CK25_DIS);
  131. reg_writel(priv, reg, REG_SPHY_CNTRL);
  132. udelay(21);
  133. reg = reg_readl(priv, REG_SPHY_CNTRL);
  134. reg &= ~PHY_RESET;
  135. } else {
  136. reg |= EXT_PWR_DOWN | IDDQ_BIAS | PHY_RESET;
  137. reg_writel(priv, reg, REG_SPHY_CNTRL);
  138. mdelay(1);
  139. reg |= CK25_DIS;
  140. }
  141. reg_writel(priv, reg, REG_SPHY_CNTRL);
  142. /* Use PHY-driven LED signaling */
  143. if (!enable) {
  144. reg = reg_readl(priv, REG_LED_CNTRL(0));
  145. reg |= SPDLNK_SRC_SEL;
  146. reg_writel(priv, reg, REG_LED_CNTRL(0));
  147. }
  148. }
  149. static inline void bcm_sf2_port_intr_enable(struct bcm_sf2_priv *priv,
  150. int port)
  151. {
  152. unsigned int off;
  153. switch (port) {
  154. case 7:
  155. off = P7_IRQ_OFF;
  156. break;
  157. case 0:
  158. /* Port 0 interrupts are located on the first bank */
  159. intrl2_0_mask_clear(priv, P_IRQ_MASK(P0_IRQ_OFF));
  160. return;
  161. default:
  162. off = P_IRQ_OFF(port);
  163. break;
  164. }
  165. intrl2_1_mask_clear(priv, P_IRQ_MASK(off));
  166. }
  167. static inline void bcm_sf2_port_intr_disable(struct bcm_sf2_priv *priv,
  168. int port)
  169. {
  170. unsigned int off;
  171. switch (port) {
  172. case 7:
  173. off = P7_IRQ_OFF;
  174. break;
  175. case 0:
  176. /* Port 0 interrupts are located on the first bank */
  177. intrl2_0_mask_set(priv, P_IRQ_MASK(P0_IRQ_OFF));
  178. intrl2_0_writel(priv, P_IRQ_MASK(P0_IRQ_OFF), INTRL2_CPU_CLEAR);
  179. return;
  180. default:
  181. off = P_IRQ_OFF(port);
  182. break;
  183. }
  184. intrl2_1_mask_set(priv, P_IRQ_MASK(off));
  185. intrl2_1_writel(priv, P_IRQ_MASK(off), INTRL2_CPU_CLEAR);
  186. }
  187. static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
  188. struct phy_device *phy)
  189. {
  190. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  191. s8 cpu_port = ds->dst[ds->index].cpu_port;
  192. u32 reg;
  193. /* Clear the memory power down */
  194. reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
  195. reg &= ~P_TXQ_PSM_VDD(port);
  196. core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL);
  197. /* Clear the Rx and Tx disable bits and set to no spanning tree */
  198. core_writel(priv, 0, CORE_G_PCTL_PORT(port));
  199. /* Re-enable the GPHY and re-apply workarounds */
  200. if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1) {
  201. bcm_sf2_gphy_enable_set(ds, true);
  202. if (phy) {
  203. /* if phy_stop() has been called before, phy
  204. * will be in halted state, and phy_start()
  205. * will call resume.
  206. *
  207. * the resume path does not configure back
  208. * autoneg settings, and since we hard reset
  209. * the phy manually here, we need to reset the
  210. * state machine also.
  211. */
  212. phy->state = PHY_READY;
  213. phy_init_hw(phy);
  214. }
  215. }
  216. /* Enable MoCA port interrupts to get notified */
  217. if (port == priv->moca_port)
  218. bcm_sf2_port_intr_enable(priv, port);
  219. /* Set this port, and only this one to be in the default VLAN,
  220. * if member of a bridge, restore its membership prior to
  221. * bringing down this port.
  222. */
  223. reg = core_readl(priv, CORE_PORT_VLAN_CTL_PORT(port));
  224. reg &= ~PORT_VLAN_CTRL_MASK;
  225. reg |= (1 << port);
  226. reg |= priv->dev->ports[port].vlan_ctl_mask;
  227. core_writel(priv, reg, CORE_PORT_VLAN_CTL_PORT(port));
  228. bcm_sf2_imp_vlan_setup(ds, cpu_port);
  229. /* If EEE was enabled, restore it */
  230. if (priv->port_sts[port].eee.eee_enabled)
  231. bcm_sf2_eee_enable_set(ds, port, true);
  232. return 0;
  233. }
  234. static void bcm_sf2_port_disable(struct dsa_switch *ds, int port,
  235. struct phy_device *phy)
  236. {
  237. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  238. u32 off, reg;
  239. if (priv->wol_ports_mask & (1 << port))
  240. return;
  241. if (port == priv->moca_port)
  242. bcm_sf2_port_intr_disable(priv, port);
  243. if (priv->int_phy_mask & 1 << port && priv->hw_params.num_gphy == 1)
  244. bcm_sf2_gphy_enable_set(ds, false);
  245. if (dsa_is_cpu_port(ds, port))
  246. off = CORE_IMP_CTL;
  247. else
  248. off = CORE_G_PCTL_PORT(port);
  249. reg = core_readl(priv, off);
  250. reg |= RX_DIS | TX_DIS;
  251. core_writel(priv, reg, off);
  252. /* Power down the port memory */
  253. reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
  254. reg |= P_TXQ_PSM_VDD(port);
  255. core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL);
  256. }
  257. /* Returns 0 if EEE was not enabled, or 1 otherwise
  258. */
  259. static int bcm_sf2_eee_init(struct dsa_switch *ds, int port,
  260. struct phy_device *phy)
  261. {
  262. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  263. struct ethtool_eee *p = &priv->port_sts[port].eee;
  264. int ret;
  265. p->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full);
  266. ret = phy_init_eee(phy, 0);
  267. if (ret)
  268. return 0;
  269. bcm_sf2_eee_enable_set(ds, port, true);
  270. return 1;
  271. }
  272. static int bcm_sf2_sw_get_eee(struct dsa_switch *ds, int port,
  273. struct ethtool_eee *e)
  274. {
  275. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  276. struct ethtool_eee *p = &priv->port_sts[port].eee;
  277. u32 reg;
  278. reg = core_readl(priv, CORE_EEE_LPI_INDICATE);
  279. e->eee_enabled = p->eee_enabled;
  280. e->eee_active = !!(reg & (1 << port));
  281. return 0;
  282. }
  283. static int bcm_sf2_sw_set_eee(struct dsa_switch *ds, int port,
  284. struct phy_device *phydev,
  285. struct ethtool_eee *e)
  286. {
  287. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  288. struct ethtool_eee *p = &priv->port_sts[port].eee;
  289. p->eee_enabled = e->eee_enabled;
  290. if (!p->eee_enabled) {
  291. bcm_sf2_eee_enable_set(ds, port, false);
  292. } else {
  293. p->eee_enabled = bcm_sf2_eee_init(ds, port, phydev);
  294. if (!p->eee_enabled)
  295. return -EOPNOTSUPP;
  296. }
  297. return 0;
  298. }
  299. static int bcm_sf2_sw_indir_rw(struct bcm_sf2_priv *priv, int op, int addr,
  300. int regnum, u16 val)
  301. {
  302. int ret = 0;
  303. u32 reg;
  304. reg = reg_readl(priv, REG_SWITCH_CNTRL);
  305. reg |= MDIO_MASTER_SEL;
  306. reg_writel(priv, reg, REG_SWITCH_CNTRL);
  307. /* Page << 8 | offset */
  308. reg = 0x70;
  309. reg <<= 2;
  310. core_writel(priv, addr, reg);
  311. /* Page << 8 | offset */
  312. reg = 0x80 << 8 | regnum << 1;
  313. reg <<= 2;
  314. if (op)
  315. ret = core_readl(priv, reg);
  316. else
  317. core_writel(priv, val, reg);
  318. reg = reg_readl(priv, REG_SWITCH_CNTRL);
  319. reg &= ~MDIO_MASTER_SEL;
  320. reg_writel(priv, reg, REG_SWITCH_CNTRL);
  321. return ret & 0xffff;
  322. }
  323. static int bcm_sf2_sw_mdio_read(struct mii_bus *bus, int addr, int regnum)
  324. {
  325. struct bcm_sf2_priv *priv = bus->priv;
  326. /* Intercept reads from Broadcom pseudo-PHY address, else, send
  327. * them to our master MDIO bus controller
  328. */
  329. if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
  330. return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0);
  331. else
  332. return mdiobus_read_nested(priv->master_mii_bus, addr, regnum);
  333. }
  334. static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
  335. u16 val)
  336. {
  337. struct bcm_sf2_priv *priv = bus->priv;
  338. /* Intercept writes to the Broadcom pseudo-PHY address, else,
  339. * send them to our master MDIO bus controller
  340. */
  341. if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
  342. bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
  343. else
  344. mdiobus_write_nested(priv->master_mii_bus, addr, regnum, val);
  345. return 0;
  346. }
  347. static irqreturn_t bcm_sf2_switch_0_isr(int irq, void *dev_id)
  348. {
  349. struct bcm_sf2_priv *priv = dev_id;
  350. priv->irq0_stat = intrl2_0_readl(priv, INTRL2_CPU_STATUS) &
  351. ~priv->irq0_mask;
  352. intrl2_0_writel(priv, priv->irq0_stat, INTRL2_CPU_CLEAR);
  353. return IRQ_HANDLED;
  354. }
  355. static irqreturn_t bcm_sf2_switch_1_isr(int irq, void *dev_id)
  356. {
  357. struct bcm_sf2_priv *priv = dev_id;
  358. priv->irq1_stat = intrl2_1_readl(priv, INTRL2_CPU_STATUS) &
  359. ~priv->irq1_mask;
  360. intrl2_1_writel(priv, priv->irq1_stat, INTRL2_CPU_CLEAR);
  361. if (priv->irq1_stat & P_LINK_UP_IRQ(P7_IRQ_OFF))
  362. priv->port_sts[7].link = 1;
  363. if (priv->irq1_stat & P_LINK_DOWN_IRQ(P7_IRQ_OFF))
  364. priv->port_sts[7].link = 0;
  365. return IRQ_HANDLED;
  366. }
  367. static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
  368. {
  369. unsigned int timeout = 1000;
  370. u32 reg;
  371. reg = core_readl(priv, CORE_WATCHDOG_CTRL);
  372. reg |= SOFTWARE_RESET | EN_CHIP_RST | EN_SW_RESET;
  373. core_writel(priv, reg, CORE_WATCHDOG_CTRL);
  374. do {
  375. reg = core_readl(priv, CORE_WATCHDOG_CTRL);
  376. if (!(reg & SOFTWARE_RESET))
  377. break;
  378. usleep_range(1000, 2000);
  379. } while (timeout-- > 0);
  380. if (timeout == 0)
  381. return -ETIMEDOUT;
  382. return 0;
  383. }
  384. static void bcm_sf2_intr_disable(struct bcm_sf2_priv *priv)
  385. {
  386. intrl2_0_mask_set(priv, 0xffffffff);
  387. intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_CLEAR);
  388. intrl2_1_mask_set(priv, 0xffffffff);
  389. intrl2_1_writel(priv, 0xffffffff, INTRL2_CPU_CLEAR);
  390. }
  391. static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
  392. struct device_node *dn)
  393. {
  394. struct device_node *port;
  395. const char *phy_mode_str;
  396. int mode;
  397. unsigned int port_num;
  398. int ret;
  399. priv->moca_port = -1;
  400. for_each_available_child_of_node(dn, port) {
  401. if (of_property_read_u32(port, "reg", &port_num))
  402. continue;
  403. /* Internal PHYs get assigned a specific 'phy-mode' property
  404. * value: "internal" to help flag them before MDIO probing
  405. * has completed, since they might be turned off at that
  406. * time
  407. */
  408. mode = of_get_phy_mode(port);
  409. if (mode < 0) {
  410. ret = of_property_read_string(port, "phy-mode",
  411. &phy_mode_str);
  412. if (ret < 0)
  413. continue;
  414. if (!strcasecmp(phy_mode_str, "internal"))
  415. priv->int_phy_mask |= 1 << port_num;
  416. }
  417. if (mode == PHY_INTERFACE_MODE_MOCA)
  418. priv->moca_port = port_num;
  419. }
  420. }
  421. static int bcm_sf2_mdio_register(struct dsa_switch *ds)
  422. {
  423. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  424. struct device_node *dn;
  425. static int index;
  426. int err;
  427. /* Find our integrated MDIO bus node */
  428. dn = of_find_compatible_node(NULL, NULL, "brcm,unimac-mdio");
  429. priv->master_mii_bus = of_mdio_find_bus(dn);
  430. if (!priv->master_mii_bus)
  431. return -EPROBE_DEFER;
  432. get_device(&priv->master_mii_bus->dev);
  433. priv->master_mii_dn = dn;
  434. priv->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
  435. if (!priv->slave_mii_bus)
  436. return -ENOMEM;
  437. priv->slave_mii_bus->priv = priv;
  438. priv->slave_mii_bus->name = "sf2 slave mii";
  439. priv->slave_mii_bus->read = bcm_sf2_sw_mdio_read;
  440. priv->slave_mii_bus->write = bcm_sf2_sw_mdio_write;
  441. snprintf(priv->slave_mii_bus->id, MII_BUS_ID_SIZE, "sf2-%d",
  442. index++);
  443. priv->slave_mii_bus->dev.of_node = dn;
  444. /* Include the pseudo-PHY address to divert reads towards our
  445. * workaround. This is only required for 7445D0, since 7445E0
  446. * disconnects the internal switch pseudo-PHY such that we can use the
  447. * regular SWITCH_MDIO master controller instead.
  448. *
  449. * Here we flag the pseudo PHY as needing special treatment and would
  450. * otherwise make all other PHY read/writes go to the master MDIO bus
  451. * controller that comes with this switch backed by the "mdio-unimac"
  452. * driver.
  453. */
  454. if (of_machine_is_compatible("brcm,bcm7445d0"))
  455. priv->indir_phy_mask |= (1 << BRCM_PSEUDO_PHY_ADDR);
  456. else
  457. priv->indir_phy_mask = 0;
  458. ds->phys_mii_mask = priv->indir_phy_mask;
  459. ds->slave_mii_bus = priv->slave_mii_bus;
  460. priv->slave_mii_bus->parent = ds->dev->parent;
  461. priv->slave_mii_bus->phy_mask = ~priv->indir_phy_mask;
  462. if (dn)
  463. err = of_mdiobus_register(priv->slave_mii_bus, dn);
  464. else
  465. err = mdiobus_register(priv->slave_mii_bus);
  466. if (err)
  467. of_node_put(dn);
  468. return err;
  469. }
  470. static void bcm_sf2_mdio_unregister(struct bcm_sf2_priv *priv)
  471. {
  472. mdiobus_unregister(priv->slave_mii_bus);
  473. if (priv->master_mii_dn)
  474. of_node_put(priv->master_mii_dn);
  475. }
  476. static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, int port)
  477. {
  478. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  479. /* The BCM7xxx PHY driver expects to find the integrated PHY revision
  480. * in bits 15:8 and the patch level in bits 7:0 which is exactly what
  481. * the REG_PHY_REVISION register layout is.
  482. */
  483. return priv->hw_params.gphy_rev;
  484. }
  485. static void bcm_sf2_sw_adjust_link(struct dsa_switch *ds, int port,
  486. struct phy_device *phydev)
  487. {
  488. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  489. struct ethtool_eee *p = &priv->port_sts[port].eee;
  490. u32 id_mode_dis = 0, port_mode;
  491. const char *str = NULL;
  492. u32 reg;
  493. switch (phydev->interface) {
  494. case PHY_INTERFACE_MODE_RGMII:
  495. str = "RGMII (no delay)";
  496. id_mode_dis = 1;
  497. case PHY_INTERFACE_MODE_RGMII_TXID:
  498. if (!str)
  499. str = "RGMII (TX delay)";
  500. port_mode = EXT_GPHY;
  501. break;
  502. case PHY_INTERFACE_MODE_MII:
  503. str = "MII";
  504. port_mode = EXT_EPHY;
  505. break;
  506. case PHY_INTERFACE_MODE_REVMII:
  507. str = "Reverse MII";
  508. port_mode = EXT_REVMII;
  509. break;
  510. default:
  511. /* All other PHYs: internal and MoCA */
  512. goto force_link;
  513. }
  514. /* If the link is down, just disable the interface to conserve power */
  515. if (!phydev->link) {
  516. reg = reg_readl(priv, REG_RGMII_CNTRL_P(port));
  517. reg &= ~RGMII_MODE_EN;
  518. reg_writel(priv, reg, REG_RGMII_CNTRL_P(port));
  519. goto force_link;
  520. }
  521. /* Clear id_mode_dis bit, and the existing port mode, but
  522. * make sure we enable the RGMII block for data to pass
  523. */
  524. reg = reg_readl(priv, REG_RGMII_CNTRL_P(port));
  525. reg &= ~ID_MODE_DIS;
  526. reg &= ~(PORT_MODE_MASK << PORT_MODE_SHIFT);
  527. reg &= ~(RX_PAUSE_EN | TX_PAUSE_EN);
  528. reg |= port_mode | RGMII_MODE_EN;
  529. if (id_mode_dis)
  530. reg |= ID_MODE_DIS;
  531. if (phydev->pause) {
  532. if (phydev->asym_pause)
  533. reg |= TX_PAUSE_EN;
  534. reg |= RX_PAUSE_EN;
  535. }
  536. reg_writel(priv, reg, REG_RGMII_CNTRL_P(port));
  537. pr_info("Port %d configured for %s\n", port, str);
  538. force_link:
  539. /* Force link settings detected from the PHY */
  540. reg = SW_OVERRIDE;
  541. switch (phydev->speed) {
  542. case SPEED_1000:
  543. reg |= SPDSTS_1000 << SPEED_SHIFT;
  544. break;
  545. case SPEED_100:
  546. reg |= SPDSTS_100 << SPEED_SHIFT;
  547. break;
  548. }
  549. if (phydev->link)
  550. reg |= LINK_STS;
  551. if (phydev->duplex == DUPLEX_FULL)
  552. reg |= DUPLX_MODE;
  553. core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(port));
  554. if (!phydev->is_pseudo_fixed_link)
  555. p->eee_enabled = bcm_sf2_eee_init(ds, port, phydev);
  556. }
  557. static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
  558. struct fixed_phy_status *status)
  559. {
  560. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  561. u32 duplex, pause;
  562. u32 reg;
  563. duplex = core_readl(priv, CORE_DUPSTS);
  564. pause = core_readl(priv, CORE_PAUSESTS);
  565. status->link = 0;
  566. /* MoCA port is special as we do not get link status from CORE_LNKSTS,
  567. * which means that we need to force the link at the port override
  568. * level to get the data to flow. We do use what the interrupt handler
  569. * did determine before.
  570. *
  571. * For the other ports, we just force the link status, since this is
  572. * a fixed PHY device.
  573. */
  574. if (port == priv->moca_port) {
  575. status->link = priv->port_sts[port].link;
  576. /* For MoCA interfaces, also force a link down notification
  577. * since some version of the user-space daemon (mocad) use
  578. * cmd->autoneg to force the link, which messes up the PHY
  579. * state machine and make it go in PHY_FORCING state instead.
  580. */
  581. if (!status->link)
  582. netif_carrier_off(ds->ports[port].netdev);
  583. status->duplex = 1;
  584. } else {
  585. status->link = 1;
  586. status->duplex = !!(duplex & (1 << port));
  587. }
  588. reg = core_readl(priv, CORE_STS_OVERRIDE_GMIIP_PORT(port));
  589. reg |= SW_OVERRIDE;
  590. if (status->link)
  591. reg |= LINK_STS;
  592. else
  593. reg &= ~LINK_STS;
  594. core_writel(priv, reg, CORE_STS_OVERRIDE_GMIIP_PORT(port));
  595. if ((pause & (1 << port)) &&
  596. (pause & (1 << (port + PAUSESTS_TX_PAUSE_SHIFT)))) {
  597. status->asym_pause = 1;
  598. status->pause = 1;
  599. }
  600. if (pause & (1 << port))
  601. status->pause = 1;
  602. }
  603. static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
  604. {
  605. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  606. unsigned int port;
  607. bcm_sf2_intr_disable(priv);
  608. /* Disable all ports physically present including the IMP
  609. * port, the other ones have already been disabled during
  610. * bcm_sf2_sw_setup
  611. */
  612. for (port = 0; port < DSA_MAX_PORTS; port++) {
  613. if ((1 << port) & ds->enabled_port_mask ||
  614. dsa_is_cpu_port(ds, port))
  615. bcm_sf2_port_disable(ds, port, NULL);
  616. }
  617. return 0;
  618. }
  619. static int bcm_sf2_sw_resume(struct dsa_switch *ds)
  620. {
  621. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  622. unsigned int port;
  623. int ret;
  624. ret = bcm_sf2_sw_rst(priv);
  625. if (ret) {
  626. pr_err("%s: failed to software reset switch\n", __func__);
  627. return ret;
  628. }
  629. if (priv->hw_params.num_gphy == 1)
  630. bcm_sf2_gphy_enable_set(ds, true);
  631. for (port = 0; port < DSA_MAX_PORTS; port++) {
  632. if ((1 << port) & ds->enabled_port_mask)
  633. bcm_sf2_port_setup(ds, port, NULL);
  634. else if (dsa_is_cpu_port(ds, port))
  635. bcm_sf2_imp_setup(ds, port);
  636. }
  637. return 0;
  638. }
  639. static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
  640. struct ethtool_wolinfo *wol)
  641. {
  642. struct net_device *p = ds->dst[ds->index].master_netdev;
  643. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  644. struct ethtool_wolinfo pwol;
  645. /* Get the parent device WoL settings */
  646. p->ethtool_ops->get_wol(p, &pwol);
  647. /* Advertise the parent device supported settings */
  648. wol->supported = pwol.supported;
  649. memset(&wol->sopass, 0, sizeof(wol->sopass));
  650. if (pwol.wolopts & WAKE_MAGICSECURE)
  651. memcpy(&wol->sopass, pwol.sopass, sizeof(wol->sopass));
  652. if (priv->wol_ports_mask & (1 << port))
  653. wol->wolopts = pwol.wolopts;
  654. else
  655. wol->wolopts = 0;
  656. }
  657. static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
  658. struct ethtool_wolinfo *wol)
  659. {
  660. struct net_device *p = ds->dst[ds->index].master_netdev;
  661. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  662. s8 cpu_port = ds->dst[ds->index].cpu_port;
  663. struct ethtool_wolinfo pwol;
  664. p->ethtool_ops->get_wol(p, &pwol);
  665. if (wol->wolopts & ~pwol.supported)
  666. return -EINVAL;
  667. if (wol->wolopts)
  668. priv->wol_ports_mask |= (1 << port);
  669. else
  670. priv->wol_ports_mask &= ~(1 << port);
  671. /* If we have at least one port enabled, make sure the CPU port
  672. * is also enabled. If the CPU port is the last one enabled, we disable
  673. * it since this configuration does not make sense.
  674. */
  675. if (priv->wol_ports_mask && priv->wol_ports_mask != (1 << cpu_port))
  676. priv->wol_ports_mask |= (1 << cpu_port);
  677. else
  678. priv->wol_ports_mask &= ~(1 << cpu_port);
  679. return p->ethtool_ops->set_wol(p, wol);
  680. }
  681. static int bcm_sf2_vlan_op_wait(struct bcm_sf2_priv *priv)
  682. {
  683. unsigned int timeout = 10;
  684. u32 reg;
  685. do {
  686. reg = core_readl(priv, CORE_ARLA_VTBL_RWCTRL);
  687. if (!(reg & ARLA_VTBL_STDN))
  688. return 0;
  689. usleep_range(1000, 2000);
  690. } while (timeout--);
  691. return -ETIMEDOUT;
  692. }
  693. static int bcm_sf2_vlan_op(struct bcm_sf2_priv *priv, u8 op)
  694. {
  695. core_writel(priv, ARLA_VTBL_STDN | op, CORE_ARLA_VTBL_RWCTRL);
  696. return bcm_sf2_vlan_op_wait(priv);
  697. }
  698. static void bcm_sf2_sw_configure_vlan(struct dsa_switch *ds)
  699. {
  700. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  701. unsigned int port;
  702. /* Clear all VLANs */
  703. bcm_sf2_vlan_op(priv, ARLA_VTBL_CMD_CLEAR);
  704. for (port = 0; port < priv->hw_params.num_ports; port++) {
  705. if (!((1 << port) & ds->enabled_port_mask))
  706. continue;
  707. core_writel(priv, 1, CORE_DEFAULT_1Q_TAG_P(port));
  708. }
  709. }
  710. static int bcm_sf2_sw_setup(struct dsa_switch *ds)
  711. {
  712. struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
  713. unsigned int port;
  714. /* Enable all valid ports and disable those unused */
  715. for (port = 0; port < priv->hw_params.num_ports; port++) {
  716. /* IMP port receives special treatment */
  717. if ((1 << port) & ds->enabled_port_mask)
  718. bcm_sf2_port_setup(ds, port, NULL);
  719. else if (dsa_is_cpu_port(ds, port))
  720. bcm_sf2_imp_setup(ds, port);
  721. else
  722. bcm_sf2_port_disable(ds, port, NULL);
  723. }
  724. bcm_sf2_sw_configure_vlan(ds);
  725. return 0;
  726. }
  727. /* The SWITCH_CORE register space is managed by b53 but operates on a page +
  728. * register basis so we need to translate that into an address that the
  729. * bus-glue understands.
  730. */
  731. #define SF2_PAGE_REG_MKADDR(page, reg) ((page) << 10 | (reg) << 2)
  732. static int bcm_sf2_core_read8(struct b53_device *dev, u8 page, u8 reg,
  733. u8 *val)
  734. {
  735. struct bcm_sf2_priv *priv = dev->priv;
  736. *val = core_readl(priv, SF2_PAGE_REG_MKADDR(page, reg));
  737. return 0;
  738. }
  739. static int bcm_sf2_core_read16(struct b53_device *dev, u8 page, u8 reg,
  740. u16 *val)
  741. {
  742. struct bcm_sf2_priv *priv = dev->priv;
  743. *val = core_readl(priv, SF2_PAGE_REG_MKADDR(page, reg));
  744. return 0;
  745. }
  746. static int bcm_sf2_core_read32(struct b53_device *dev, u8 page, u8 reg,
  747. u32 *val)
  748. {
  749. struct bcm_sf2_priv *priv = dev->priv;
  750. *val = core_readl(priv, SF2_PAGE_REG_MKADDR(page, reg));
  751. return 0;
  752. }
  753. static int bcm_sf2_core_read64(struct b53_device *dev, u8 page, u8 reg,
  754. u64 *val)
  755. {
  756. struct bcm_sf2_priv *priv = dev->priv;
  757. *val = core_readq(priv, SF2_PAGE_REG_MKADDR(page, reg));
  758. return 0;
  759. }
  760. static int bcm_sf2_core_write8(struct b53_device *dev, u8 page, u8 reg,
  761. u8 value)
  762. {
  763. struct bcm_sf2_priv *priv = dev->priv;
  764. core_writel(priv, value, SF2_PAGE_REG_MKADDR(page, reg));
  765. return 0;
  766. }
  767. static int bcm_sf2_core_write16(struct b53_device *dev, u8 page, u8 reg,
  768. u16 value)
  769. {
  770. struct bcm_sf2_priv *priv = dev->priv;
  771. core_writel(priv, value, SF2_PAGE_REG_MKADDR(page, reg));
  772. return 0;
  773. }
  774. static int bcm_sf2_core_write32(struct b53_device *dev, u8 page, u8 reg,
  775. u32 value)
  776. {
  777. struct bcm_sf2_priv *priv = dev->priv;
  778. core_writel(priv, value, SF2_PAGE_REG_MKADDR(page, reg));
  779. return 0;
  780. }
  781. static int bcm_sf2_core_write64(struct b53_device *dev, u8 page, u8 reg,
  782. u64 value)
  783. {
  784. struct bcm_sf2_priv *priv = dev->priv;
  785. core_writeq(priv, value, SF2_PAGE_REG_MKADDR(page, reg));
  786. return 0;
  787. }
  788. static struct b53_io_ops bcm_sf2_io_ops = {
  789. .read8 = bcm_sf2_core_read8,
  790. .read16 = bcm_sf2_core_read16,
  791. .read32 = bcm_sf2_core_read32,
  792. .read48 = bcm_sf2_core_read64,
  793. .read64 = bcm_sf2_core_read64,
  794. .write8 = bcm_sf2_core_write8,
  795. .write16 = bcm_sf2_core_write16,
  796. .write32 = bcm_sf2_core_write32,
  797. .write48 = bcm_sf2_core_write64,
  798. .write64 = bcm_sf2_core_write64,
  799. };
  800. static int bcm_sf2_sw_probe(struct platform_device *pdev)
  801. {
  802. const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
  803. struct device_node *dn = pdev->dev.of_node;
  804. struct b53_platform_data *pdata;
  805. struct dsa_switch_ops *ops;
  806. struct bcm_sf2_priv *priv;
  807. struct b53_device *dev;
  808. struct dsa_switch *ds;
  809. void __iomem **base;
  810. struct resource *r;
  811. unsigned int i;
  812. u32 reg, rev;
  813. int ret;
  814. priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
  815. if (!priv)
  816. return -ENOMEM;
  817. ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
  818. if (!ops)
  819. return -ENOMEM;
  820. dev = b53_switch_alloc(&pdev->dev, &bcm_sf2_io_ops, priv);
  821. if (!dev)
  822. return -ENOMEM;
  823. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  824. if (!pdata)
  825. return -ENOMEM;
  826. /* Auto-detection using standard registers will not work, so
  827. * provide an indication of what kind of device we are for
  828. * b53_common to work with
  829. */
  830. pdata->chip_id = BCM7445_DEVICE_ID;
  831. dev->pdata = pdata;
  832. priv->dev = dev;
  833. ds = dev->ds;
  834. /* Override the parts that are non-standard wrt. normal b53 devices */
  835. memcpy(ops, ds->ops, sizeof(*ops));
  836. ds->ops = ops;
  837. ds->ops->get_tag_protocol = bcm_sf2_sw_get_tag_protocol;
  838. ds->ops->setup = bcm_sf2_sw_setup;
  839. ds->ops->get_phy_flags = bcm_sf2_sw_get_phy_flags;
  840. ds->ops->adjust_link = bcm_sf2_sw_adjust_link;
  841. ds->ops->fixed_link_update = bcm_sf2_sw_fixed_link_update;
  842. ds->ops->suspend = bcm_sf2_sw_suspend;
  843. ds->ops->resume = bcm_sf2_sw_resume;
  844. ds->ops->get_wol = bcm_sf2_sw_get_wol;
  845. ds->ops->set_wol = bcm_sf2_sw_set_wol;
  846. ds->ops->port_enable = bcm_sf2_port_setup;
  847. ds->ops->port_disable = bcm_sf2_port_disable;
  848. ds->ops->get_eee = bcm_sf2_sw_get_eee;
  849. ds->ops->set_eee = bcm_sf2_sw_set_eee;
  850. /* Avoid having DSA free our slave MDIO bus (checking for
  851. * ds->slave_mii_bus and ds->ops->phy_read being non-NULL)
  852. */
  853. ds->ops->phy_read = NULL;
  854. dev_set_drvdata(&pdev->dev, priv);
  855. spin_lock_init(&priv->indir_lock);
  856. mutex_init(&priv->stats_mutex);
  857. bcm_sf2_identify_ports(priv, dn->child);
  858. priv->irq0 = irq_of_parse_and_map(dn, 0);
  859. priv->irq1 = irq_of_parse_and_map(dn, 1);
  860. base = &priv->core;
  861. for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
  862. r = platform_get_resource(pdev, IORESOURCE_MEM, i);
  863. *base = devm_ioremap_resource(&pdev->dev, r);
  864. if (IS_ERR(*base)) {
  865. pr_err("unable to find register: %s\n", reg_names[i]);
  866. return PTR_ERR(*base);
  867. }
  868. base++;
  869. }
  870. ret = bcm_sf2_sw_rst(priv);
  871. if (ret) {
  872. pr_err("unable to software reset switch: %d\n", ret);
  873. return ret;
  874. }
  875. ret = bcm_sf2_mdio_register(ds);
  876. if (ret) {
  877. pr_err("failed to register MDIO bus\n");
  878. return ret;
  879. }
  880. /* Disable all interrupts and request them */
  881. bcm_sf2_intr_disable(priv);
  882. ret = devm_request_irq(&pdev->dev, priv->irq0, bcm_sf2_switch_0_isr, 0,
  883. "switch_0", priv);
  884. if (ret < 0) {
  885. pr_err("failed to request switch_0 IRQ\n");
  886. goto out_mdio;
  887. }
  888. ret = devm_request_irq(&pdev->dev, priv->irq1, bcm_sf2_switch_1_isr, 0,
  889. "switch_1", priv);
  890. if (ret < 0) {
  891. pr_err("failed to request switch_1 IRQ\n");
  892. goto out_mdio;
  893. }
  894. /* Reset the MIB counters */
  895. reg = core_readl(priv, CORE_GMNCFGCFG);
  896. reg |= RST_MIB_CNT;
  897. core_writel(priv, reg, CORE_GMNCFGCFG);
  898. reg &= ~RST_MIB_CNT;
  899. core_writel(priv, reg, CORE_GMNCFGCFG);
  900. /* Get the maximum number of ports for this switch */
  901. priv->hw_params.num_ports = core_readl(priv, CORE_IMP0_PRT_ID) + 1;
  902. if (priv->hw_params.num_ports > DSA_MAX_PORTS)
  903. priv->hw_params.num_ports = DSA_MAX_PORTS;
  904. /* Assume a single GPHY setup if we can't read that property */
  905. if (of_property_read_u32(dn, "brcm,num-gphy",
  906. &priv->hw_params.num_gphy))
  907. priv->hw_params.num_gphy = 1;
  908. rev = reg_readl(priv, REG_SWITCH_REVISION);
  909. priv->hw_params.top_rev = (rev >> SWITCH_TOP_REV_SHIFT) &
  910. SWITCH_TOP_REV_MASK;
  911. priv->hw_params.core_rev = (rev & SF2_REV_MASK);
  912. rev = reg_readl(priv, REG_PHY_REVISION);
  913. priv->hw_params.gphy_rev = rev & PHY_REVISION_MASK;
  914. ret = b53_switch_register(dev);
  915. if (ret)
  916. goto out_mdio;
  917. pr_info("Starfighter 2 top: %x.%02x, core: %x.%02x base: 0x%p, IRQs: %d, %d\n",
  918. priv->hw_params.top_rev >> 8, priv->hw_params.top_rev & 0xff,
  919. priv->hw_params.core_rev >> 8, priv->hw_params.core_rev & 0xff,
  920. priv->core, priv->irq0, priv->irq1);
  921. return 0;
  922. out_mdio:
  923. bcm_sf2_mdio_unregister(priv);
  924. return ret;
  925. }
  926. static int bcm_sf2_sw_remove(struct platform_device *pdev)
  927. {
  928. struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
  929. /* Disable all ports and interrupts */
  930. priv->wol_ports_mask = 0;
  931. bcm_sf2_sw_suspend(priv->dev->ds);
  932. dsa_unregister_switch(priv->dev->ds);
  933. bcm_sf2_mdio_unregister(priv);
  934. return 0;
  935. }
  936. static void bcm_sf2_sw_shutdown(struct platform_device *pdev)
  937. {
  938. struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
  939. /* For a kernel about to be kexec'd we want to keep the GPHY on for a
  940. * successful MDIO bus scan to occur. If we did turn off the GPHY
  941. * before (e.g: port_disable), this will also power it back on.
  942. *
  943. * Do not rely on kexec_in_progress, just power the PHY on.
  944. */
  945. if (priv->hw_params.num_gphy == 1)
  946. bcm_sf2_gphy_enable_set(priv->dev->ds, true);
  947. }
  948. #ifdef CONFIG_PM_SLEEP
  949. static int bcm_sf2_suspend(struct device *dev)
  950. {
  951. struct platform_device *pdev = to_platform_device(dev);
  952. struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
  953. return dsa_switch_suspend(priv->dev->ds);
  954. }
  955. static int bcm_sf2_resume(struct device *dev)
  956. {
  957. struct platform_device *pdev = to_platform_device(dev);
  958. struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
  959. return dsa_switch_resume(priv->dev->ds);
  960. }
  961. #endif /* CONFIG_PM_SLEEP */
  962. static SIMPLE_DEV_PM_OPS(bcm_sf2_pm_ops,
  963. bcm_sf2_suspend, bcm_sf2_resume);
  964. static const struct of_device_id bcm_sf2_of_match[] = {
  965. { .compatible = "brcm,bcm7445-switch-v4.0" },
  966. { /* sentinel */ },
  967. };
  968. MODULE_DEVICE_TABLE(of, bcm_sf2_of_match);
  969. static struct platform_driver bcm_sf2_driver = {
  970. .probe = bcm_sf2_sw_probe,
  971. .remove = bcm_sf2_sw_remove,
  972. .shutdown = bcm_sf2_sw_shutdown,
  973. .driver = {
  974. .name = "brcm-sf2",
  975. .of_match_table = bcm_sf2_of_match,
  976. .pm = &bcm_sf2_pm_ops,
  977. },
  978. };
  979. module_platform_driver(bcm_sf2_driver);
  980. MODULE_AUTHOR("Broadcom Corporation");
  981. MODULE_DESCRIPTION("Driver for Broadcom Starfighter 2 ethernet switch chip");
  982. MODULE_LICENSE("GPL");
  983. MODULE_ALIAS("platform:brcm-sf2");