ksz_common.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  1. /*
  2. * Microchip switch driver main logic
  3. *
  4. * Copyright (C) 2017
  5. *
  6. * Permission to use, copy, modify, and/or distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <linux/delay.h>
  19. #include <linux/export.h>
  20. #include <linux/gpio.h>
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/platform_data/microchip-ksz.h>
  24. #include <linux/phy.h>
  25. #include <linux/etherdevice.h>
  26. #include <linux/if_bridge.h>
  27. #include <net/dsa.h>
  28. #include <net/switchdev.h>
  29. #include "ksz_priv.h"
  30. static const struct {
  31. int index;
  32. char string[ETH_GSTRING_LEN];
  33. } mib_names[TOTAL_SWITCH_COUNTER_NUM] = {
  34. { 0x00, "rx_hi" },
  35. { 0x01, "rx_undersize" },
  36. { 0x02, "rx_fragments" },
  37. { 0x03, "rx_oversize" },
  38. { 0x04, "rx_jabbers" },
  39. { 0x05, "rx_symbol_err" },
  40. { 0x06, "rx_crc_err" },
  41. { 0x07, "rx_align_err" },
  42. { 0x08, "rx_mac_ctrl" },
  43. { 0x09, "rx_pause" },
  44. { 0x0A, "rx_bcast" },
  45. { 0x0B, "rx_mcast" },
  46. { 0x0C, "rx_ucast" },
  47. { 0x0D, "rx_64_or_less" },
  48. { 0x0E, "rx_65_127" },
  49. { 0x0F, "rx_128_255" },
  50. { 0x10, "rx_256_511" },
  51. { 0x11, "rx_512_1023" },
  52. { 0x12, "rx_1024_1522" },
  53. { 0x13, "rx_1523_2000" },
  54. { 0x14, "rx_2001" },
  55. { 0x15, "tx_hi" },
  56. { 0x16, "tx_late_col" },
  57. { 0x17, "tx_pause" },
  58. { 0x18, "tx_bcast" },
  59. { 0x19, "tx_mcast" },
  60. { 0x1A, "tx_ucast" },
  61. { 0x1B, "tx_deferred" },
  62. { 0x1C, "tx_total_col" },
  63. { 0x1D, "tx_exc_col" },
  64. { 0x1E, "tx_single_col" },
  65. { 0x1F, "tx_mult_col" },
  66. { 0x80, "rx_total" },
  67. { 0x81, "tx_total" },
  68. { 0x82, "rx_discards" },
  69. { 0x83, "tx_discards" },
  70. };
  71. static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
  72. {
  73. u8 data;
  74. ksz_read8(dev, addr, &data);
  75. if (set)
  76. data |= bits;
  77. else
  78. data &= ~bits;
  79. ksz_write8(dev, addr, data);
  80. }
  81. static void ksz_cfg32(struct ksz_device *dev, u32 addr, u32 bits, bool set)
  82. {
  83. u32 data;
  84. ksz_read32(dev, addr, &data);
  85. if (set)
  86. data |= bits;
  87. else
  88. data &= ~bits;
  89. ksz_write32(dev, addr, data);
  90. }
  91. static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
  92. bool set)
  93. {
  94. u32 addr;
  95. u8 data;
  96. addr = PORT_CTRL_ADDR(port, offset);
  97. ksz_read8(dev, addr, &data);
  98. if (set)
  99. data |= bits;
  100. else
  101. data &= ~bits;
  102. ksz_write8(dev, addr, data);
  103. }
  104. static void ksz_port_cfg32(struct ksz_device *dev, int port, int offset,
  105. u32 bits, bool set)
  106. {
  107. u32 addr;
  108. u32 data;
  109. addr = PORT_CTRL_ADDR(port, offset);
  110. ksz_read32(dev, addr, &data);
  111. if (set)
  112. data |= bits;
  113. else
  114. data &= ~bits;
  115. ksz_write32(dev, addr, data);
  116. }
  117. static int wait_vlan_ctrl_ready(struct ksz_device *dev, u32 waiton, int timeout)
  118. {
  119. u8 data;
  120. do {
  121. ksz_read8(dev, REG_SW_VLAN_CTRL, &data);
  122. if (!(data & waiton))
  123. break;
  124. usleep_range(1, 10);
  125. } while (timeout-- > 0);
  126. if (timeout <= 0)
  127. return -ETIMEDOUT;
  128. return 0;
  129. }
  130. static int get_vlan_table(struct dsa_switch *ds, u16 vid, u32 *vlan_table)
  131. {
  132. struct ksz_device *dev = ds->priv;
  133. int ret;
  134. mutex_lock(&dev->vlan_mutex);
  135. ksz_write16(dev, REG_SW_VLAN_ENTRY_INDEX__2, vid & VLAN_INDEX_M);
  136. ksz_write8(dev, REG_SW_VLAN_CTRL, VLAN_READ | VLAN_START);
  137. /* wait to be cleared */
  138. ret = wait_vlan_ctrl_ready(dev, VLAN_START, 1000);
  139. if (ret < 0) {
  140. dev_dbg(dev->dev, "Failed to read vlan table\n");
  141. goto exit;
  142. }
  143. ksz_read32(dev, REG_SW_VLAN_ENTRY__4, &vlan_table[0]);
  144. ksz_read32(dev, REG_SW_VLAN_ENTRY_UNTAG__4, &vlan_table[1]);
  145. ksz_read32(dev, REG_SW_VLAN_ENTRY_PORTS__4, &vlan_table[2]);
  146. ksz_write8(dev, REG_SW_VLAN_CTRL, 0);
  147. exit:
  148. mutex_unlock(&dev->vlan_mutex);
  149. return ret;
  150. }
  151. static int set_vlan_table(struct dsa_switch *ds, u16 vid, u32 *vlan_table)
  152. {
  153. struct ksz_device *dev = ds->priv;
  154. int ret;
  155. mutex_lock(&dev->vlan_mutex);
  156. ksz_write32(dev, REG_SW_VLAN_ENTRY__4, vlan_table[0]);
  157. ksz_write32(dev, REG_SW_VLAN_ENTRY_UNTAG__4, vlan_table[1]);
  158. ksz_write32(dev, REG_SW_VLAN_ENTRY_PORTS__4, vlan_table[2]);
  159. ksz_write16(dev, REG_SW_VLAN_ENTRY_INDEX__2, vid & VLAN_INDEX_M);
  160. ksz_write8(dev, REG_SW_VLAN_CTRL, VLAN_START | VLAN_WRITE);
  161. /* wait to be cleared */
  162. ret = wait_vlan_ctrl_ready(dev, VLAN_START, 1000);
  163. if (ret < 0) {
  164. dev_dbg(dev->dev, "Failed to write vlan table\n");
  165. goto exit;
  166. }
  167. ksz_write8(dev, REG_SW_VLAN_CTRL, 0);
  168. /* update vlan cache table */
  169. dev->vlan_cache[vid].table[0] = vlan_table[0];
  170. dev->vlan_cache[vid].table[1] = vlan_table[1];
  171. dev->vlan_cache[vid].table[2] = vlan_table[2];
  172. exit:
  173. mutex_unlock(&dev->vlan_mutex);
  174. return ret;
  175. }
  176. static void read_table(struct dsa_switch *ds, u32 *table)
  177. {
  178. struct ksz_device *dev = ds->priv;
  179. ksz_read32(dev, REG_SW_ALU_VAL_A, &table[0]);
  180. ksz_read32(dev, REG_SW_ALU_VAL_B, &table[1]);
  181. ksz_read32(dev, REG_SW_ALU_VAL_C, &table[2]);
  182. ksz_read32(dev, REG_SW_ALU_VAL_D, &table[3]);
  183. }
  184. static void write_table(struct dsa_switch *ds, u32 *table)
  185. {
  186. struct ksz_device *dev = ds->priv;
  187. ksz_write32(dev, REG_SW_ALU_VAL_A, table[0]);
  188. ksz_write32(dev, REG_SW_ALU_VAL_B, table[1]);
  189. ksz_write32(dev, REG_SW_ALU_VAL_C, table[2]);
  190. ksz_write32(dev, REG_SW_ALU_VAL_D, table[3]);
  191. }
  192. static int wait_alu_ready(struct ksz_device *dev, u32 waiton, int timeout)
  193. {
  194. u32 data;
  195. do {
  196. ksz_read32(dev, REG_SW_ALU_CTRL__4, &data);
  197. if (!(data & waiton))
  198. break;
  199. usleep_range(1, 10);
  200. } while (timeout-- > 0);
  201. if (timeout <= 0)
  202. return -ETIMEDOUT;
  203. return 0;
  204. }
  205. static int wait_alu_sta_ready(struct ksz_device *dev, u32 waiton, int timeout)
  206. {
  207. u32 data;
  208. do {
  209. ksz_read32(dev, REG_SW_ALU_STAT_CTRL__4, &data);
  210. if (!(data & waiton))
  211. break;
  212. usleep_range(1, 10);
  213. } while (timeout-- > 0);
  214. if (timeout <= 0)
  215. return -ETIMEDOUT;
  216. return 0;
  217. }
  218. static int ksz_reset_switch(struct dsa_switch *ds)
  219. {
  220. struct ksz_device *dev = ds->priv;
  221. u8 data8;
  222. u16 data16;
  223. u32 data32;
  224. /* reset switch */
  225. ksz_cfg(dev, REG_SW_OPERATION, SW_RESET, true);
  226. /* turn off SPI DO Edge select */
  227. ksz_read8(dev, REG_SW_GLOBAL_SERIAL_CTRL_0, &data8);
  228. data8 &= ~SPI_AUTO_EDGE_DETECTION;
  229. ksz_write8(dev, REG_SW_GLOBAL_SERIAL_CTRL_0, data8);
  230. /* default configuration */
  231. ksz_read8(dev, REG_SW_LUE_CTRL_1, &data8);
  232. data8 = SW_AGING_ENABLE | SW_LINK_AUTO_AGING |
  233. SW_SRC_ADDR_FILTER | SW_FLUSH_STP_TABLE | SW_FLUSH_MSTP_TABLE;
  234. ksz_write8(dev, REG_SW_LUE_CTRL_1, data8);
  235. /* disable interrupts */
  236. ksz_write32(dev, REG_SW_INT_MASK__4, SWITCH_INT_MASK);
  237. ksz_write32(dev, REG_SW_PORT_INT_MASK__4, 0x7F);
  238. ksz_read32(dev, REG_SW_PORT_INT_STATUS__4, &data32);
  239. /* set broadcast storm protection 10% rate */
  240. ksz_read16(dev, REG_SW_MAC_CTRL_2, &data16);
  241. data16 &= ~BROADCAST_STORM_RATE;
  242. data16 |= (BROADCAST_STORM_VALUE * BROADCAST_STORM_PROT_RATE) / 100;
  243. ksz_write16(dev, REG_SW_MAC_CTRL_2, data16);
  244. return 0;
  245. }
  246. static void port_setup(struct ksz_device *dev, int port, bool cpu_port)
  247. {
  248. u8 data8;
  249. u16 data16;
  250. /* enable tag tail for host port */
  251. if (cpu_port)
  252. ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_TAIL_TAG_ENABLE,
  253. true);
  254. ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_MAC_LOOPBACK, false);
  255. /* set back pressure */
  256. ksz_port_cfg(dev, port, REG_PORT_MAC_CTRL_1, PORT_BACK_PRESSURE, true);
  257. /* set flow control */
  258. ksz_port_cfg(dev, port, REG_PORT_CTRL_0,
  259. PORT_FORCE_TX_FLOW_CTRL | PORT_FORCE_RX_FLOW_CTRL, true);
  260. /* enable broadcast storm limit */
  261. ksz_port_cfg(dev, port, P_BCAST_STORM_CTRL, PORT_BROADCAST_STORM, true);
  262. /* disable DiffServ priority */
  263. ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_DIFFSERV_PRIO_ENABLE, false);
  264. /* replace priority */
  265. ksz_port_cfg(dev, port, REG_PORT_MRI_MAC_CTRL, PORT_USER_PRIO_CEILING,
  266. false);
  267. ksz_port_cfg32(dev, port, REG_PORT_MTI_QUEUE_CTRL_0__4,
  268. MTI_PVID_REPLACE, false);
  269. /* enable 802.1p priority */
  270. ksz_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_PRIO_ENABLE, true);
  271. /* configure MAC to 1G & RGMII mode */
  272. ksz_pread8(dev, port, REG_PORT_XMII_CTRL_1, &data8);
  273. data8 |= PORT_RGMII_ID_EG_ENABLE;
  274. data8 &= ~PORT_MII_NOT_1GBIT;
  275. data8 &= ~PORT_MII_SEL_M;
  276. data8 |= PORT_RGMII_SEL;
  277. ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8);
  278. /* clear pending interrupts */
  279. ksz_pread16(dev, port, REG_PORT_PHY_INT_ENABLE, &data16);
  280. }
  281. static void ksz_config_cpu_port(struct dsa_switch *ds)
  282. {
  283. struct ksz_device *dev = ds->priv;
  284. int i;
  285. ds->num_ports = dev->port_cnt;
  286. for (i = 0; i < ds->num_ports; i++) {
  287. if (dsa_is_cpu_port(ds, i) && (dev->cpu_ports & (1 << i))) {
  288. dev->cpu_port = i;
  289. /* enable cpu port */
  290. port_setup(dev, i, true);
  291. }
  292. }
  293. }
  294. static int ksz_setup(struct dsa_switch *ds)
  295. {
  296. struct ksz_device *dev = ds->priv;
  297. int ret = 0;
  298. dev->vlan_cache = devm_kcalloc(dev->dev, sizeof(struct vlan_table),
  299. dev->num_vlans, GFP_KERNEL);
  300. if (!dev->vlan_cache)
  301. return -ENOMEM;
  302. ret = ksz_reset_switch(ds);
  303. if (ret) {
  304. dev_err(ds->dev, "failed to reset switch\n");
  305. return ret;
  306. }
  307. /* accept packet up to 2000bytes */
  308. ksz_cfg(dev, REG_SW_MAC_CTRL_1, SW_LEGAL_PACKET_DISABLE, true);
  309. ksz_config_cpu_port(ds);
  310. ksz_cfg(dev, REG_SW_MAC_CTRL_1, MULTICAST_STORM_DISABLE, true);
  311. /* queue based egress rate limit */
  312. ksz_cfg(dev, REG_SW_MAC_CTRL_5, SW_OUT_RATE_LIMIT_QUEUE_BASED, true);
  313. /* start switch */
  314. ksz_cfg(dev, REG_SW_OPERATION, SW_START, true);
  315. return 0;
  316. }
  317. static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds)
  318. {
  319. return DSA_TAG_PROTO_KSZ;
  320. }
  321. static int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg)
  322. {
  323. struct ksz_device *dev = ds->priv;
  324. u16 val = 0;
  325. ksz_pread16(dev, addr, 0x100 + (reg << 1), &val);
  326. return val;
  327. }
  328. static int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
  329. {
  330. struct ksz_device *dev = ds->priv;
  331. ksz_pwrite16(dev, addr, 0x100 + (reg << 1), val);
  332. return 0;
  333. }
  334. static int ksz_enable_port(struct dsa_switch *ds, int port,
  335. struct phy_device *phy)
  336. {
  337. struct ksz_device *dev = ds->priv;
  338. /* setup slave port */
  339. port_setup(dev, port, false);
  340. return 0;
  341. }
  342. static void ksz_disable_port(struct dsa_switch *ds, int port,
  343. struct phy_device *phy)
  344. {
  345. struct ksz_device *dev = ds->priv;
  346. /* there is no port disable */
  347. ksz_port_cfg(dev, port, REG_PORT_CTRL_0, PORT_MAC_LOOPBACK, true);
  348. }
  349. static int ksz_sset_count(struct dsa_switch *ds)
  350. {
  351. return TOTAL_SWITCH_COUNTER_NUM;
  352. }
  353. static void ksz_get_strings(struct dsa_switch *ds, int port, uint8_t *buf)
  354. {
  355. int i;
  356. for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) {
  357. memcpy(buf + i * ETH_GSTRING_LEN, mib_names[i].string,
  358. ETH_GSTRING_LEN);
  359. }
  360. }
  361. static void ksz_get_ethtool_stats(struct dsa_switch *ds, int port,
  362. uint64_t *buf)
  363. {
  364. struct ksz_device *dev = ds->priv;
  365. int i;
  366. u32 data;
  367. int timeout;
  368. mutex_lock(&dev->stats_mutex);
  369. for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) {
  370. data = MIB_COUNTER_READ;
  371. data |= ((mib_names[i].index & 0xFF) << MIB_COUNTER_INDEX_S);
  372. ksz_pwrite32(dev, port, REG_PORT_MIB_CTRL_STAT__4, data);
  373. timeout = 1000;
  374. do {
  375. ksz_pread32(dev, port, REG_PORT_MIB_CTRL_STAT__4,
  376. &data);
  377. usleep_range(1, 10);
  378. if (!(data & MIB_COUNTER_READ))
  379. break;
  380. } while (timeout-- > 0);
  381. /* failed to read MIB. get out of loop */
  382. if (!timeout) {
  383. dev_dbg(dev->dev, "Failed to get MIB\n");
  384. break;
  385. }
  386. /* count resets upon read */
  387. ksz_pread32(dev, port, REG_PORT_MIB_DATA, &data);
  388. dev->mib_value[i] += (uint64_t)data;
  389. buf[i] = dev->mib_value[i];
  390. }
  391. mutex_unlock(&dev->stats_mutex);
  392. }
  393. static void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
  394. {
  395. struct ksz_device *dev = ds->priv;
  396. u8 data;
  397. ksz_pread8(dev, port, P_STP_CTRL, &data);
  398. data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE);
  399. switch (state) {
  400. case BR_STATE_DISABLED:
  401. data |= PORT_LEARN_DISABLE;
  402. break;
  403. case BR_STATE_LISTENING:
  404. data |= (PORT_RX_ENABLE | PORT_LEARN_DISABLE);
  405. break;
  406. case BR_STATE_LEARNING:
  407. data |= PORT_RX_ENABLE;
  408. break;
  409. case BR_STATE_FORWARDING:
  410. data |= (PORT_TX_ENABLE | PORT_RX_ENABLE);
  411. break;
  412. case BR_STATE_BLOCKING:
  413. data |= PORT_LEARN_DISABLE;
  414. break;
  415. default:
  416. dev_err(ds->dev, "invalid STP state: %d\n", state);
  417. return;
  418. }
  419. ksz_pwrite8(dev, port, P_STP_CTRL, data);
  420. }
  421. static void ksz_port_fast_age(struct dsa_switch *ds, int port)
  422. {
  423. struct ksz_device *dev = ds->priv;
  424. u8 data8;
  425. ksz_read8(dev, REG_SW_LUE_CTRL_1, &data8);
  426. data8 |= SW_FAST_AGING;
  427. ksz_write8(dev, REG_SW_LUE_CTRL_1, data8);
  428. data8 &= ~SW_FAST_AGING;
  429. ksz_write8(dev, REG_SW_LUE_CTRL_1, data8);
  430. }
  431. static int ksz_port_vlan_filtering(struct dsa_switch *ds, int port, bool flag)
  432. {
  433. struct ksz_device *dev = ds->priv;
  434. if (flag) {
  435. ksz_port_cfg(dev, port, REG_PORT_LUE_CTRL,
  436. PORT_VLAN_LOOKUP_VID_0, true);
  437. ksz_cfg32(dev, REG_SW_QM_CTRL__4, UNICAST_VLAN_BOUNDARY, true);
  438. ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_VLAN_ENABLE, true);
  439. } else {
  440. ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_VLAN_ENABLE, false);
  441. ksz_cfg32(dev, REG_SW_QM_CTRL__4, UNICAST_VLAN_BOUNDARY, false);
  442. ksz_port_cfg(dev, port, REG_PORT_LUE_CTRL,
  443. PORT_VLAN_LOOKUP_VID_0, false);
  444. }
  445. return 0;
  446. }
  447. static int ksz_port_vlan_prepare(struct dsa_switch *ds, int port,
  448. const struct switchdev_obj_port_vlan *vlan,
  449. struct switchdev_trans *trans)
  450. {
  451. /* nothing needed */
  452. return 0;
  453. }
  454. static void ksz_port_vlan_add(struct dsa_switch *ds, int port,
  455. const struct switchdev_obj_port_vlan *vlan,
  456. struct switchdev_trans *trans)
  457. {
  458. struct ksz_device *dev = ds->priv;
  459. u32 vlan_table[3];
  460. u16 vid;
  461. bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
  462. for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
  463. if (get_vlan_table(ds, vid, vlan_table)) {
  464. dev_dbg(dev->dev, "Failed to get vlan table\n");
  465. return;
  466. }
  467. vlan_table[0] = VLAN_VALID | (vid & VLAN_FID_M);
  468. if (untagged)
  469. vlan_table[1] |= BIT(port);
  470. else
  471. vlan_table[1] &= ~BIT(port);
  472. vlan_table[1] &= ~(BIT(dev->cpu_port));
  473. vlan_table[2] |= BIT(port) | BIT(dev->cpu_port);
  474. if (set_vlan_table(ds, vid, vlan_table)) {
  475. dev_dbg(dev->dev, "Failed to set vlan table\n");
  476. return;
  477. }
  478. /* change PVID */
  479. if (vlan->flags & BRIDGE_VLAN_INFO_PVID)
  480. ksz_pwrite16(dev, port, REG_PORT_DEFAULT_VID, vid);
  481. }
  482. }
  483. static int ksz_port_vlan_del(struct dsa_switch *ds, int port,
  484. const struct switchdev_obj_port_vlan *vlan)
  485. {
  486. struct ksz_device *dev = ds->priv;
  487. bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
  488. u32 vlan_table[3];
  489. u16 vid;
  490. u16 pvid;
  491. ksz_pread16(dev, port, REG_PORT_DEFAULT_VID, &pvid);
  492. pvid = pvid & 0xFFF;
  493. for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
  494. if (get_vlan_table(ds, vid, vlan_table)) {
  495. dev_dbg(dev->dev, "Failed to get vlan table\n");
  496. return -ETIMEDOUT;
  497. }
  498. vlan_table[2] &= ~BIT(port);
  499. if (pvid == vid)
  500. pvid = 1;
  501. if (untagged)
  502. vlan_table[1] &= ~BIT(port);
  503. if (set_vlan_table(ds, vid, vlan_table)) {
  504. dev_dbg(dev->dev, "Failed to set vlan table\n");
  505. return -ETIMEDOUT;
  506. }
  507. }
  508. ksz_pwrite16(dev, port, REG_PORT_DEFAULT_VID, pvid);
  509. return 0;
  510. }
  511. struct alu_struct {
  512. /* entry 1 */
  513. u8 is_static:1;
  514. u8 is_src_filter:1;
  515. u8 is_dst_filter:1;
  516. u8 prio_age:3;
  517. u32 _reserv_0_1:23;
  518. u8 mstp:3;
  519. /* entry 2 */
  520. u8 is_override:1;
  521. u8 is_use_fid:1;
  522. u32 _reserv_1_1:23;
  523. u8 port_forward:7;
  524. /* entry 3 & 4*/
  525. u32 _reserv_2_1:9;
  526. u8 fid:7;
  527. u8 mac[ETH_ALEN];
  528. };
  529. static int ksz_port_fdb_add(struct dsa_switch *ds, int port,
  530. const unsigned char *addr, u16 vid)
  531. {
  532. struct ksz_device *dev = ds->priv;
  533. u32 alu_table[4];
  534. u32 data;
  535. int ret = 0;
  536. mutex_lock(&dev->alu_mutex);
  537. /* find any entry with mac & vid */
  538. data = vid << ALU_FID_INDEX_S;
  539. data |= ((addr[0] << 8) | addr[1]);
  540. ksz_write32(dev, REG_SW_ALU_INDEX_0, data);
  541. data = ((addr[2] << 24) | (addr[3] << 16));
  542. data |= ((addr[4] << 8) | addr[5]);
  543. ksz_write32(dev, REG_SW_ALU_INDEX_1, data);
  544. /* start read operation */
  545. ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
  546. /* wait to be finished */
  547. ret = wait_alu_ready(dev, ALU_START, 1000);
  548. if (ret < 0) {
  549. dev_dbg(dev->dev, "Failed to read ALU\n");
  550. goto exit;
  551. }
  552. /* read ALU entry */
  553. read_table(ds, alu_table);
  554. /* update ALU entry */
  555. alu_table[0] = ALU_V_STATIC_VALID;
  556. alu_table[1] |= BIT(port);
  557. if (vid)
  558. alu_table[1] |= ALU_V_USE_FID;
  559. alu_table[2] = (vid << ALU_V_FID_S);
  560. alu_table[2] |= ((addr[0] << 8) | addr[1]);
  561. alu_table[3] = ((addr[2] << 24) | (addr[3] << 16));
  562. alu_table[3] |= ((addr[4] << 8) | addr[5]);
  563. write_table(ds, alu_table);
  564. ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
  565. /* wait to be finished */
  566. ret = wait_alu_ready(dev, ALU_START, 1000);
  567. if (ret < 0)
  568. dev_dbg(dev->dev, "Failed to write ALU\n");
  569. exit:
  570. mutex_unlock(&dev->alu_mutex);
  571. return ret;
  572. }
  573. static int ksz_port_fdb_del(struct dsa_switch *ds, int port,
  574. const unsigned char *addr, u16 vid)
  575. {
  576. struct ksz_device *dev = ds->priv;
  577. u32 alu_table[4];
  578. u32 data;
  579. int ret = 0;
  580. mutex_lock(&dev->alu_mutex);
  581. /* read any entry with mac & vid */
  582. data = vid << ALU_FID_INDEX_S;
  583. data |= ((addr[0] << 8) | addr[1]);
  584. ksz_write32(dev, REG_SW_ALU_INDEX_0, data);
  585. data = ((addr[2] << 24) | (addr[3] << 16));
  586. data |= ((addr[4] << 8) | addr[5]);
  587. ksz_write32(dev, REG_SW_ALU_INDEX_1, data);
  588. /* start read operation */
  589. ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
  590. /* wait to be finished */
  591. ret = wait_alu_ready(dev, ALU_START, 1000);
  592. if (ret < 0) {
  593. dev_dbg(dev->dev, "Failed to read ALU\n");
  594. goto exit;
  595. }
  596. ksz_read32(dev, REG_SW_ALU_VAL_A, &alu_table[0]);
  597. if (alu_table[0] & ALU_V_STATIC_VALID) {
  598. ksz_read32(dev, REG_SW_ALU_VAL_B, &alu_table[1]);
  599. ksz_read32(dev, REG_SW_ALU_VAL_C, &alu_table[2]);
  600. ksz_read32(dev, REG_SW_ALU_VAL_D, &alu_table[3]);
  601. /* clear forwarding port */
  602. alu_table[2] &= ~BIT(port);
  603. /* if there is no port to forward, clear table */
  604. if ((alu_table[2] & ALU_V_PORT_MAP) == 0) {
  605. alu_table[0] = 0;
  606. alu_table[1] = 0;
  607. alu_table[2] = 0;
  608. alu_table[3] = 0;
  609. }
  610. } else {
  611. alu_table[0] = 0;
  612. alu_table[1] = 0;
  613. alu_table[2] = 0;
  614. alu_table[3] = 0;
  615. }
  616. write_table(ds, alu_table);
  617. ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
  618. /* wait to be finished */
  619. ret = wait_alu_ready(dev, ALU_START, 1000);
  620. if (ret < 0)
  621. dev_dbg(dev->dev, "Failed to write ALU\n");
  622. exit:
  623. mutex_unlock(&dev->alu_mutex);
  624. return ret;
  625. }
  626. static void convert_alu(struct alu_struct *alu, u32 *alu_table)
  627. {
  628. alu->is_static = !!(alu_table[0] & ALU_V_STATIC_VALID);
  629. alu->is_src_filter = !!(alu_table[0] & ALU_V_SRC_FILTER);
  630. alu->is_dst_filter = !!(alu_table[0] & ALU_V_DST_FILTER);
  631. alu->prio_age = (alu_table[0] >> ALU_V_PRIO_AGE_CNT_S) &
  632. ALU_V_PRIO_AGE_CNT_M;
  633. alu->mstp = alu_table[0] & ALU_V_MSTP_M;
  634. alu->is_override = !!(alu_table[1] & ALU_V_OVERRIDE);
  635. alu->is_use_fid = !!(alu_table[1] & ALU_V_USE_FID);
  636. alu->port_forward = alu_table[1] & ALU_V_PORT_MAP;
  637. alu->fid = (alu_table[2] >> ALU_V_FID_S) & ALU_V_FID_M;
  638. alu->mac[0] = (alu_table[2] >> 8) & 0xFF;
  639. alu->mac[1] = alu_table[2] & 0xFF;
  640. alu->mac[2] = (alu_table[3] >> 24) & 0xFF;
  641. alu->mac[3] = (alu_table[3] >> 16) & 0xFF;
  642. alu->mac[4] = (alu_table[3] >> 8) & 0xFF;
  643. alu->mac[5] = alu_table[3] & 0xFF;
  644. }
  645. static int ksz_port_fdb_dump(struct dsa_switch *ds, int port,
  646. dsa_fdb_dump_cb_t *cb, void *data)
  647. {
  648. struct ksz_device *dev = ds->priv;
  649. int ret = 0;
  650. u32 ksz_data;
  651. u32 alu_table[4];
  652. struct alu_struct alu;
  653. int timeout;
  654. mutex_lock(&dev->alu_mutex);
  655. /* start ALU search */
  656. ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_START | ALU_SEARCH);
  657. do {
  658. timeout = 1000;
  659. do {
  660. ksz_read32(dev, REG_SW_ALU_CTRL__4, &ksz_data);
  661. if ((ksz_data & ALU_VALID) || !(ksz_data & ALU_START))
  662. break;
  663. usleep_range(1, 10);
  664. } while (timeout-- > 0);
  665. if (!timeout) {
  666. dev_dbg(dev->dev, "Failed to search ALU\n");
  667. ret = -ETIMEDOUT;
  668. goto exit;
  669. }
  670. /* read ALU table */
  671. read_table(ds, alu_table);
  672. convert_alu(&alu, alu_table);
  673. if (alu.port_forward & BIT(port)) {
  674. ret = cb(alu.mac, alu.fid, alu.is_static, data);
  675. if (ret)
  676. goto exit;
  677. }
  678. } while (ksz_data & ALU_START);
  679. exit:
  680. /* stop ALU search */
  681. ksz_write32(dev, REG_SW_ALU_CTRL__4, 0);
  682. mutex_unlock(&dev->alu_mutex);
  683. return ret;
  684. }
  685. static int ksz_port_mdb_prepare(struct dsa_switch *ds, int port,
  686. const struct switchdev_obj_port_mdb *mdb,
  687. struct switchdev_trans *trans)
  688. {
  689. /* nothing to do */
  690. return 0;
  691. }
  692. static void ksz_port_mdb_add(struct dsa_switch *ds, int port,
  693. const struct switchdev_obj_port_mdb *mdb,
  694. struct switchdev_trans *trans)
  695. {
  696. struct ksz_device *dev = ds->priv;
  697. u32 static_table[4];
  698. u32 data;
  699. int index;
  700. u32 mac_hi, mac_lo;
  701. mac_hi = ((mdb->addr[0] << 8) | mdb->addr[1]);
  702. mac_lo = ((mdb->addr[2] << 24) | (mdb->addr[3] << 16));
  703. mac_lo |= ((mdb->addr[4] << 8) | mdb->addr[5]);
  704. mutex_lock(&dev->alu_mutex);
  705. for (index = 0; index < dev->num_statics; index++) {
  706. /* find empty slot first */
  707. data = (index << ALU_STAT_INDEX_S) |
  708. ALU_STAT_READ | ALU_STAT_START;
  709. ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data);
  710. /* wait to be finished */
  711. if (wait_alu_sta_ready(dev, ALU_STAT_START, 1000) < 0) {
  712. dev_dbg(dev->dev, "Failed to read ALU STATIC\n");
  713. goto exit;
  714. }
  715. /* read ALU static table */
  716. read_table(ds, static_table);
  717. if (static_table[0] & ALU_V_STATIC_VALID) {
  718. /* check this has same vid & mac address */
  719. if (((static_table[2] >> ALU_V_FID_S) == (mdb->vid)) &&
  720. ((static_table[2] & ALU_V_MAC_ADDR_HI) == mac_hi) &&
  721. (static_table[3] == mac_lo)) {
  722. /* found matching one */
  723. break;
  724. }
  725. } else {
  726. /* found empty one */
  727. break;
  728. }
  729. }
  730. /* no available entry */
  731. if (index == dev->num_statics)
  732. goto exit;
  733. /* add entry */
  734. static_table[0] = ALU_V_STATIC_VALID;
  735. static_table[1] |= BIT(port);
  736. if (mdb->vid)
  737. static_table[1] |= ALU_V_USE_FID;
  738. static_table[2] = (mdb->vid << ALU_V_FID_S);
  739. static_table[2] |= mac_hi;
  740. static_table[3] = mac_lo;
  741. write_table(ds, static_table);
  742. data = (index << ALU_STAT_INDEX_S) | ALU_STAT_START;
  743. ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data);
  744. /* wait to be finished */
  745. if (wait_alu_sta_ready(dev, ALU_STAT_START, 1000) < 0)
  746. dev_dbg(dev->dev, "Failed to read ALU STATIC\n");
  747. exit:
  748. mutex_unlock(&dev->alu_mutex);
  749. }
  750. static int ksz_port_mdb_del(struct dsa_switch *ds, int port,
  751. const struct switchdev_obj_port_mdb *mdb)
  752. {
  753. struct ksz_device *dev = ds->priv;
  754. u32 static_table[4];
  755. u32 data;
  756. int index;
  757. int ret = 0;
  758. u32 mac_hi, mac_lo;
  759. mac_hi = ((mdb->addr[0] << 8) | mdb->addr[1]);
  760. mac_lo = ((mdb->addr[2] << 24) | (mdb->addr[3] << 16));
  761. mac_lo |= ((mdb->addr[4] << 8) | mdb->addr[5]);
  762. mutex_lock(&dev->alu_mutex);
  763. for (index = 0; index < dev->num_statics; index++) {
  764. /* find empty slot first */
  765. data = (index << ALU_STAT_INDEX_S) |
  766. ALU_STAT_READ | ALU_STAT_START;
  767. ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data);
  768. /* wait to be finished */
  769. ret = wait_alu_sta_ready(dev, ALU_STAT_START, 1000);
  770. if (ret < 0) {
  771. dev_dbg(dev->dev, "Failed to read ALU STATIC\n");
  772. goto exit;
  773. }
  774. /* read ALU static table */
  775. read_table(ds, static_table);
  776. if (static_table[0] & ALU_V_STATIC_VALID) {
  777. /* check this has same vid & mac address */
  778. if (((static_table[2] >> ALU_V_FID_S) == (mdb->vid)) &&
  779. ((static_table[2] & ALU_V_MAC_ADDR_HI) == mac_hi) &&
  780. (static_table[3] == mac_lo)) {
  781. /* found matching one */
  782. break;
  783. }
  784. }
  785. }
  786. /* no available entry */
  787. if (index == dev->num_statics) {
  788. ret = -EINVAL;
  789. goto exit;
  790. }
  791. /* clear port */
  792. static_table[1] &= ~BIT(port);
  793. if ((static_table[1] & ALU_V_PORT_MAP) == 0) {
  794. /* delete entry */
  795. static_table[0] = 0;
  796. static_table[1] = 0;
  797. static_table[2] = 0;
  798. static_table[3] = 0;
  799. }
  800. write_table(ds, static_table);
  801. data = (index << ALU_STAT_INDEX_S) | ALU_STAT_START;
  802. ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data);
  803. /* wait to be finished */
  804. ret = wait_alu_sta_ready(dev, ALU_STAT_START, 1000);
  805. if (ret < 0)
  806. dev_dbg(dev->dev, "Failed to read ALU STATIC\n");
  807. exit:
  808. mutex_unlock(&dev->alu_mutex);
  809. return ret;
  810. }
  811. static int ksz_port_mirror_add(struct dsa_switch *ds, int port,
  812. struct dsa_mall_mirror_tc_entry *mirror,
  813. bool ingress)
  814. {
  815. struct ksz_device *dev = ds->priv;
  816. if (ingress)
  817. ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, true);
  818. else
  819. ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, true);
  820. ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_SNIFFER, false);
  821. /* configure mirror port */
  822. ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
  823. PORT_MIRROR_SNIFFER, true);
  824. ksz_cfg(dev, S_MIRROR_CTRL, SW_MIRROR_RX_TX, false);
  825. return 0;
  826. }
  827. static void ksz_port_mirror_del(struct dsa_switch *ds, int port,
  828. struct dsa_mall_mirror_tc_entry *mirror)
  829. {
  830. struct ksz_device *dev = ds->priv;
  831. u8 data;
  832. if (mirror->ingress)
  833. ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, false);
  834. else
  835. ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, false);
  836. ksz_pread8(dev, port, P_MIRROR_CTRL, &data);
  837. if (!(data & (PORT_MIRROR_RX | PORT_MIRROR_TX)))
  838. ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
  839. PORT_MIRROR_SNIFFER, false);
  840. }
  841. static const struct dsa_switch_ops ksz_switch_ops = {
  842. .get_tag_protocol = ksz_get_tag_protocol,
  843. .setup = ksz_setup,
  844. .phy_read = ksz_phy_read16,
  845. .phy_write = ksz_phy_write16,
  846. .port_enable = ksz_enable_port,
  847. .port_disable = ksz_disable_port,
  848. .get_strings = ksz_get_strings,
  849. .get_ethtool_stats = ksz_get_ethtool_stats,
  850. .get_sset_count = ksz_sset_count,
  851. .port_stp_state_set = ksz_port_stp_state_set,
  852. .port_fast_age = ksz_port_fast_age,
  853. .port_vlan_filtering = ksz_port_vlan_filtering,
  854. .port_vlan_prepare = ksz_port_vlan_prepare,
  855. .port_vlan_add = ksz_port_vlan_add,
  856. .port_vlan_del = ksz_port_vlan_del,
  857. .port_fdb_dump = ksz_port_fdb_dump,
  858. .port_fdb_add = ksz_port_fdb_add,
  859. .port_fdb_del = ksz_port_fdb_del,
  860. .port_mdb_prepare = ksz_port_mdb_prepare,
  861. .port_mdb_add = ksz_port_mdb_add,
  862. .port_mdb_del = ksz_port_mdb_del,
  863. .port_mirror_add = ksz_port_mirror_add,
  864. .port_mirror_del = ksz_port_mirror_del,
  865. };
  866. struct ksz_chip_data {
  867. u32 chip_id;
  868. const char *dev_name;
  869. int num_vlans;
  870. int num_alus;
  871. int num_statics;
  872. int cpu_ports;
  873. int port_cnt;
  874. };
  875. static const struct ksz_chip_data ksz_switch_chips[] = {
  876. {
  877. .chip_id = 0x00947700,
  878. .dev_name = "KSZ9477",
  879. .num_vlans = 4096,
  880. .num_alus = 4096,
  881. .num_statics = 16,
  882. .cpu_ports = 0x7F, /* can be configured as cpu port */
  883. .port_cnt = 7, /* total physical port count */
  884. },
  885. };
  886. static int ksz_switch_init(struct ksz_device *dev)
  887. {
  888. int i;
  889. mutex_init(&dev->reg_mutex);
  890. mutex_init(&dev->stats_mutex);
  891. mutex_init(&dev->alu_mutex);
  892. mutex_init(&dev->vlan_mutex);
  893. dev->ds->ops = &ksz_switch_ops;
  894. for (i = 0; i < ARRAY_SIZE(ksz_switch_chips); i++) {
  895. const struct ksz_chip_data *chip = &ksz_switch_chips[i];
  896. if (dev->chip_id == chip->chip_id) {
  897. dev->name = chip->dev_name;
  898. dev->num_vlans = chip->num_vlans;
  899. dev->num_alus = chip->num_alus;
  900. dev->num_statics = chip->num_statics;
  901. dev->port_cnt = chip->port_cnt;
  902. dev->cpu_ports = chip->cpu_ports;
  903. break;
  904. }
  905. }
  906. /* no switch found */
  907. if (!dev->port_cnt)
  908. return -ENODEV;
  909. return 0;
  910. }
  911. struct ksz_device *ksz_switch_alloc(struct device *base,
  912. const struct ksz_io_ops *ops,
  913. void *priv)
  914. {
  915. struct dsa_switch *ds;
  916. struct ksz_device *swdev;
  917. ds = dsa_switch_alloc(base, DSA_MAX_PORTS);
  918. if (!ds)
  919. return NULL;
  920. swdev = devm_kzalloc(base, sizeof(*swdev), GFP_KERNEL);
  921. if (!swdev)
  922. return NULL;
  923. ds->priv = swdev;
  924. swdev->dev = base;
  925. swdev->ds = ds;
  926. swdev->priv = priv;
  927. swdev->ops = ops;
  928. return swdev;
  929. }
  930. EXPORT_SYMBOL(ksz_switch_alloc);
  931. int ksz_switch_detect(struct ksz_device *dev)
  932. {
  933. u8 data8;
  934. u32 id32;
  935. int ret;
  936. /* turn off SPI DO Edge select */
  937. ret = ksz_read8(dev, REG_SW_GLOBAL_SERIAL_CTRL_0, &data8);
  938. if (ret)
  939. return ret;
  940. data8 &= ~SPI_AUTO_EDGE_DETECTION;
  941. ret = ksz_write8(dev, REG_SW_GLOBAL_SERIAL_CTRL_0, data8);
  942. if (ret)
  943. return ret;
  944. /* read chip id */
  945. ret = ksz_read32(dev, REG_CHIP_ID0__1, &id32);
  946. if (ret)
  947. return ret;
  948. dev->chip_id = id32;
  949. return 0;
  950. }
  951. EXPORT_SYMBOL(ksz_switch_detect);
  952. int ksz_switch_register(struct ksz_device *dev)
  953. {
  954. int ret;
  955. if (dev->pdata)
  956. dev->chip_id = dev->pdata->chip_id;
  957. if (ksz_switch_detect(dev))
  958. return -EINVAL;
  959. ret = ksz_switch_init(dev);
  960. if (ret)
  961. return ret;
  962. return dsa_register_switch(dev->ds);
  963. }
  964. EXPORT_SYMBOL(ksz_switch_register);
  965. void ksz_switch_remove(struct ksz_device *dev)
  966. {
  967. dsa_unregister_switch(dev->ds);
  968. }
  969. EXPORT_SYMBOL(ksz_switch_remove);
  970. MODULE_AUTHOR("Woojung Huh <Woojung.Huh@microchip.com>");
  971. MODULE_DESCRIPTION("Microchip KSZ Series Switch DSA Driver");
  972. MODULE_LICENSE("GPL");