qca8k.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2009 Felix Fietkau <nbd@nbd.name>
  4. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (c) 2015, 2019, The Linux Foundation. All rights reserved.
  6. * Copyright (c) 2016 John Crispin <john@phrozen.org>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/phy.h>
  10. #include <linux/netdevice.h>
  11. #include <net/dsa.h>
  12. #include <linux/of_net.h>
  13. #include <linux/of_platform.h>
  14. #include <linux/if_bridge.h>
  15. #include <linux/mdio.h>
  16. #include <linux/gpio/consumer.h>
  17. #include <linux/etherdevice.h>
  18. #include "qca8k.h"
  19. #define MIB_DESC(_s, _o, _n) \
  20. { \
  21. .size = (_s), \
  22. .offset = (_o), \
  23. .name = (_n), \
  24. }
  25. static const struct qca8k_mib_desc ar8327_mib[] = {
  26. MIB_DESC(1, 0x00, "RxBroad"),
  27. MIB_DESC(1, 0x04, "RxPause"),
  28. MIB_DESC(1, 0x08, "RxMulti"),
  29. MIB_DESC(1, 0x0c, "RxFcsErr"),
  30. MIB_DESC(1, 0x10, "RxAlignErr"),
  31. MIB_DESC(1, 0x14, "RxRunt"),
  32. MIB_DESC(1, 0x18, "RxFragment"),
  33. MIB_DESC(1, 0x1c, "Rx64Byte"),
  34. MIB_DESC(1, 0x20, "Rx128Byte"),
  35. MIB_DESC(1, 0x24, "Rx256Byte"),
  36. MIB_DESC(1, 0x28, "Rx512Byte"),
  37. MIB_DESC(1, 0x2c, "Rx1024Byte"),
  38. MIB_DESC(1, 0x30, "Rx1518Byte"),
  39. MIB_DESC(1, 0x34, "RxMaxByte"),
  40. MIB_DESC(1, 0x38, "RxTooLong"),
  41. MIB_DESC(2, 0x3c, "RxGoodByte"),
  42. MIB_DESC(2, 0x44, "RxBadByte"),
  43. MIB_DESC(1, 0x4c, "RxOverFlow"),
  44. MIB_DESC(1, 0x50, "Filtered"),
  45. MIB_DESC(1, 0x54, "TxBroad"),
  46. MIB_DESC(1, 0x58, "TxPause"),
  47. MIB_DESC(1, 0x5c, "TxMulti"),
  48. MIB_DESC(1, 0x60, "TxUnderRun"),
  49. MIB_DESC(1, 0x64, "Tx64Byte"),
  50. MIB_DESC(1, 0x68, "Tx128Byte"),
  51. MIB_DESC(1, 0x6c, "Tx256Byte"),
  52. MIB_DESC(1, 0x70, "Tx512Byte"),
  53. MIB_DESC(1, 0x74, "Tx1024Byte"),
  54. MIB_DESC(1, 0x78, "Tx1518Byte"),
  55. MIB_DESC(1, 0x7c, "TxMaxByte"),
  56. MIB_DESC(1, 0x80, "TxOverSize"),
  57. MIB_DESC(2, 0x84, "TxByte"),
  58. MIB_DESC(1, 0x8c, "TxCollision"),
  59. MIB_DESC(1, 0x90, "TxAbortCol"),
  60. MIB_DESC(1, 0x94, "TxMultiCol"),
  61. MIB_DESC(1, 0x98, "TxSingleCol"),
  62. MIB_DESC(1, 0x9c, "TxExcDefer"),
  63. MIB_DESC(1, 0xa0, "TxDefer"),
  64. MIB_DESC(1, 0xa4, "TxLateCol"),
  65. };
  66. /* The 32bit switch registers are accessed indirectly. To achieve this we need
  67. * to set the page of the register. Track the last page that was set to reduce
  68. * mdio writes
  69. */
  70. static u16 qca8k_current_page = 0xffff;
  71. static void
  72. qca8k_split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)
  73. {
  74. regaddr >>= 1;
  75. *r1 = regaddr & 0x1e;
  76. regaddr >>= 5;
  77. *r2 = regaddr & 0x7;
  78. regaddr >>= 3;
  79. *page = regaddr & 0x3ff;
  80. }
  81. static u32
  82. qca8k_mii_read32(struct mii_bus *bus, int phy_id, u32 regnum)
  83. {
  84. u32 val;
  85. int ret;
  86. ret = bus->read(bus, phy_id, regnum);
  87. if (ret >= 0) {
  88. val = ret;
  89. ret = bus->read(bus, phy_id, regnum + 1);
  90. val |= ret << 16;
  91. }
  92. if (ret < 0) {
  93. dev_err_ratelimited(&bus->dev,
  94. "failed to read qca8k 32bit register\n");
  95. return ret;
  96. }
  97. return val;
  98. }
  99. static void
  100. qca8k_mii_write32(struct mii_bus *bus, int phy_id, u32 regnum, u32 val)
  101. {
  102. u16 lo, hi;
  103. int ret;
  104. lo = val & 0xffff;
  105. hi = (u16)(val >> 16);
  106. ret = bus->write(bus, phy_id, regnum, lo);
  107. if (ret >= 0)
  108. ret = bus->write(bus, phy_id, regnum + 1, hi);
  109. if (ret < 0)
  110. dev_err_ratelimited(&bus->dev,
  111. "failed to write qca8k 32bit register\n");
  112. }
  113. static void
  114. qca8k_set_page(struct mii_bus *bus, u16 page)
  115. {
  116. if (page == qca8k_current_page)
  117. return;
  118. if (bus->write(bus, 0x18, 0, page) < 0)
  119. dev_err_ratelimited(&bus->dev,
  120. "failed to set qca8k page\n");
  121. qca8k_current_page = page;
  122. }
  123. static u32
  124. qca8k_read(struct qca8k_priv *priv, u32 reg)
  125. {
  126. u16 r1, r2, page;
  127. u32 val;
  128. qca8k_split_addr(reg, &r1, &r2, &page);
  129. mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
  130. qca8k_set_page(priv->bus, page);
  131. val = qca8k_mii_read32(priv->bus, 0x10 | r2, r1);
  132. mutex_unlock(&priv->bus->mdio_lock);
  133. return val;
  134. }
  135. static void
  136. qca8k_write(struct qca8k_priv *priv, u32 reg, u32 val)
  137. {
  138. u16 r1, r2, page;
  139. qca8k_split_addr(reg, &r1, &r2, &page);
  140. mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
  141. qca8k_set_page(priv->bus, page);
  142. qca8k_mii_write32(priv->bus, 0x10 | r2, r1, val);
  143. mutex_unlock(&priv->bus->mdio_lock);
  144. }
  145. static u32
  146. qca8k_rmw(struct qca8k_priv *priv, u32 reg, u32 mask, u32 val)
  147. {
  148. u16 r1, r2, page;
  149. u32 ret;
  150. qca8k_split_addr(reg, &r1, &r2, &page);
  151. mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
  152. qca8k_set_page(priv->bus, page);
  153. ret = qca8k_mii_read32(priv->bus, 0x10 | r2, r1);
  154. ret &= ~mask;
  155. ret |= val;
  156. qca8k_mii_write32(priv->bus, 0x10 | r2, r1, ret);
  157. mutex_unlock(&priv->bus->mdio_lock);
  158. return ret;
  159. }
  160. static void
  161. qca8k_reg_set(struct qca8k_priv *priv, u32 reg, u32 val)
  162. {
  163. qca8k_rmw(priv, reg, 0, val);
  164. }
  165. static void
  166. qca8k_reg_clear(struct qca8k_priv *priv, u32 reg, u32 val)
  167. {
  168. qca8k_rmw(priv, reg, val, 0);
  169. }
  170. static int
  171. qca8k_regmap_read(void *ctx, uint32_t reg, uint32_t *val)
  172. {
  173. struct qca8k_priv *priv = (struct qca8k_priv *)ctx;
  174. *val = qca8k_read(priv, reg);
  175. return 0;
  176. }
  177. static int
  178. qca8k_regmap_write(void *ctx, uint32_t reg, uint32_t val)
  179. {
  180. struct qca8k_priv *priv = (struct qca8k_priv *)ctx;
  181. qca8k_write(priv, reg, val);
  182. return 0;
  183. }
  184. static const struct regmap_range qca8k_readable_ranges[] = {
  185. regmap_reg_range(0x0000, 0x00e4), /* Global control */
  186. regmap_reg_range(0x0100, 0x0168), /* EEE control */
  187. regmap_reg_range(0x0200, 0x0270), /* Parser control */
  188. regmap_reg_range(0x0400, 0x0454), /* ACL */
  189. regmap_reg_range(0x0600, 0x0718), /* Lookup */
  190. regmap_reg_range(0x0800, 0x0b70), /* QM */
  191. regmap_reg_range(0x0c00, 0x0c80), /* PKT */
  192. regmap_reg_range(0x0e00, 0x0e98), /* L3 */
  193. regmap_reg_range(0x1000, 0x10ac), /* MIB - Port0 */
  194. regmap_reg_range(0x1100, 0x11ac), /* MIB - Port1 */
  195. regmap_reg_range(0x1200, 0x12ac), /* MIB - Port2 */
  196. regmap_reg_range(0x1300, 0x13ac), /* MIB - Port3 */
  197. regmap_reg_range(0x1400, 0x14ac), /* MIB - Port4 */
  198. regmap_reg_range(0x1500, 0x15ac), /* MIB - Port5 */
  199. regmap_reg_range(0x1600, 0x16ac), /* MIB - Port6 */
  200. };
  201. static const struct regmap_access_table qca8k_readable_table = {
  202. .yes_ranges = qca8k_readable_ranges,
  203. .n_yes_ranges = ARRAY_SIZE(qca8k_readable_ranges),
  204. };
  205. static struct regmap_config qca8k_regmap_config = {
  206. .reg_bits = 16,
  207. .val_bits = 32,
  208. .reg_stride = 4,
  209. .max_register = 0x16ac, /* end MIB - Port6 range */
  210. .reg_read = qca8k_regmap_read,
  211. .reg_write = qca8k_regmap_write,
  212. .rd_table = &qca8k_readable_table,
  213. };
  214. static int
  215. qca8k_busy_wait(struct qca8k_priv *priv, u32 reg, u32 mask)
  216. {
  217. unsigned long timeout;
  218. timeout = jiffies + msecs_to_jiffies(20);
  219. /* loop until the busy flag has cleared */
  220. do {
  221. u32 val = qca8k_read(priv, reg);
  222. int busy = val & mask;
  223. if (!busy)
  224. break;
  225. cond_resched();
  226. } while (!time_after_eq(jiffies, timeout));
  227. return time_after_eq(jiffies, timeout);
  228. }
  229. static void
  230. qca8k_fdb_read(struct qca8k_priv *priv, struct qca8k_fdb *fdb)
  231. {
  232. u32 reg[4];
  233. int i;
  234. /* load the ARL table into an array */
  235. for (i = 0; i < 4; i++)
  236. reg[i] = qca8k_read(priv, QCA8K_REG_ATU_DATA0 + (i * 4));
  237. /* vid - 83:72 */
  238. fdb->vid = (reg[2] >> QCA8K_ATU_VID_S) & QCA8K_ATU_VID_M;
  239. /* aging - 67:64 */
  240. fdb->aging = reg[2] & QCA8K_ATU_STATUS_M;
  241. /* portmask - 54:48 */
  242. fdb->port_mask = (reg[1] >> QCA8K_ATU_PORT_S) & QCA8K_ATU_PORT_M;
  243. /* mac - 47:0 */
  244. fdb->mac[0] = (reg[1] >> QCA8K_ATU_ADDR0_S) & 0xff;
  245. fdb->mac[1] = reg[1] & 0xff;
  246. fdb->mac[2] = (reg[0] >> QCA8K_ATU_ADDR2_S) & 0xff;
  247. fdb->mac[3] = (reg[0] >> QCA8K_ATU_ADDR3_S) & 0xff;
  248. fdb->mac[4] = (reg[0] >> QCA8K_ATU_ADDR4_S) & 0xff;
  249. fdb->mac[5] = reg[0] & 0xff;
  250. }
  251. static void
  252. qca8k_fdb_write(struct qca8k_priv *priv, u16 vid, u8 port_mask, const u8 *mac,
  253. u8 aging)
  254. {
  255. u32 reg[3] = { 0 };
  256. int i;
  257. /* vid - 83:72 */
  258. reg[2] = (vid & QCA8K_ATU_VID_M) << QCA8K_ATU_VID_S;
  259. /* aging - 67:64 */
  260. reg[2] |= aging & QCA8K_ATU_STATUS_M;
  261. /* portmask - 54:48 */
  262. reg[1] = (port_mask & QCA8K_ATU_PORT_M) << QCA8K_ATU_PORT_S;
  263. /* mac - 47:0 */
  264. reg[1] |= mac[0] << QCA8K_ATU_ADDR0_S;
  265. reg[1] |= mac[1];
  266. reg[0] |= mac[2] << QCA8K_ATU_ADDR2_S;
  267. reg[0] |= mac[3] << QCA8K_ATU_ADDR3_S;
  268. reg[0] |= mac[4] << QCA8K_ATU_ADDR4_S;
  269. reg[0] |= mac[5];
  270. /* load the array into the ARL table */
  271. for (i = 0; i < 3; i++)
  272. qca8k_write(priv, QCA8K_REG_ATU_DATA0 + (i * 4), reg[i]);
  273. }
  274. static int
  275. qca8k_fdb_access(struct qca8k_priv *priv, enum qca8k_fdb_cmd cmd, int port)
  276. {
  277. u32 reg;
  278. /* Set the command and FDB index */
  279. reg = QCA8K_ATU_FUNC_BUSY;
  280. reg |= cmd;
  281. if (port >= 0) {
  282. reg |= QCA8K_ATU_FUNC_PORT_EN;
  283. reg |= (port & QCA8K_ATU_FUNC_PORT_M) << QCA8K_ATU_FUNC_PORT_S;
  284. }
  285. /* Write the function register triggering the table access */
  286. qca8k_write(priv, QCA8K_REG_ATU_FUNC, reg);
  287. /* wait for completion */
  288. if (qca8k_busy_wait(priv, QCA8K_REG_ATU_FUNC, QCA8K_ATU_FUNC_BUSY))
  289. return -1;
  290. /* Check for table full violation when adding an entry */
  291. if (cmd == QCA8K_FDB_LOAD) {
  292. reg = qca8k_read(priv, QCA8K_REG_ATU_FUNC);
  293. if (reg & QCA8K_ATU_FUNC_FULL)
  294. return -1;
  295. }
  296. return 0;
  297. }
  298. static int
  299. qca8k_fdb_next(struct qca8k_priv *priv, struct qca8k_fdb *fdb, int port)
  300. {
  301. int ret;
  302. qca8k_fdb_write(priv, fdb->vid, fdb->port_mask, fdb->mac, fdb->aging);
  303. ret = qca8k_fdb_access(priv, QCA8K_FDB_NEXT, port);
  304. if (ret >= 0)
  305. qca8k_fdb_read(priv, fdb);
  306. return ret;
  307. }
  308. static int
  309. qca8k_fdb_add(struct qca8k_priv *priv, const u8 *mac, u16 port_mask,
  310. u16 vid, u8 aging)
  311. {
  312. int ret;
  313. mutex_lock(&priv->reg_mutex);
  314. qca8k_fdb_write(priv, vid, port_mask, mac, aging);
  315. ret = qca8k_fdb_access(priv, QCA8K_FDB_LOAD, -1);
  316. mutex_unlock(&priv->reg_mutex);
  317. return ret;
  318. }
  319. static int
  320. qca8k_fdb_del(struct qca8k_priv *priv, const u8 *mac, u16 port_mask, u16 vid)
  321. {
  322. int ret;
  323. mutex_lock(&priv->reg_mutex);
  324. qca8k_fdb_write(priv, vid, port_mask, mac, 0);
  325. ret = qca8k_fdb_access(priv, QCA8K_FDB_PURGE, -1);
  326. mutex_unlock(&priv->reg_mutex);
  327. return ret;
  328. }
  329. static void
  330. qca8k_fdb_flush(struct qca8k_priv *priv)
  331. {
  332. mutex_lock(&priv->reg_mutex);
  333. qca8k_fdb_access(priv, QCA8K_FDB_FLUSH, -1);
  334. mutex_unlock(&priv->reg_mutex);
  335. }
  336. static void
  337. qca8k_mib_init(struct qca8k_priv *priv)
  338. {
  339. mutex_lock(&priv->reg_mutex);
  340. qca8k_reg_set(priv, QCA8K_REG_MIB, QCA8K_MIB_FLUSH | QCA8K_MIB_BUSY);
  341. qca8k_busy_wait(priv, QCA8K_REG_MIB, QCA8K_MIB_BUSY);
  342. qca8k_reg_set(priv, QCA8K_REG_MIB, QCA8K_MIB_CPU_KEEP);
  343. qca8k_write(priv, QCA8K_REG_MODULE_EN, QCA8K_MODULE_EN_MIB);
  344. mutex_unlock(&priv->reg_mutex);
  345. }
  346. static int
  347. qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
  348. {
  349. u32 reg, val;
  350. switch (port) {
  351. case 0:
  352. reg = QCA8K_REG_PORT0_PAD_CTRL;
  353. break;
  354. case 6:
  355. reg = QCA8K_REG_PORT6_PAD_CTRL;
  356. break;
  357. default:
  358. pr_err("Can't set PAD_CTRL on port %d\n", port);
  359. return -EINVAL;
  360. }
  361. /* Configure a port to be directly connected to an external
  362. * PHY or MAC.
  363. */
  364. switch (mode) {
  365. case PHY_INTERFACE_MODE_RGMII:
  366. /* RGMII mode means no delay so don't enable the delay */
  367. val = QCA8K_PORT_PAD_RGMII_EN;
  368. qca8k_write(priv, reg, val);
  369. break;
  370. case PHY_INTERFACE_MODE_RGMII_ID:
  371. /* RGMII_ID needs internal delay. This is enabled through
  372. * PORT5_PAD_CTRL for all ports, rather than individual port
  373. * registers
  374. */
  375. qca8k_write(priv, reg,
  376. QCA8K_PORT_PAD_RGMII_EN |
  377. QCA8K_PORT_PAD_RGMII_TX_DELAY(QCA8K_MAX_DELAY) |
  378. QCA8K_PORT_PAD_RGMII_RX_DELAY(QCA8K_MAX_DELAY));
  379. qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL,
  380. QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
  381. break;
  382. case PHY_INTERFACE_MODE_SGMII:
  383. qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
  384. break;
  385. default:
  386. pr_err("xMII mode %d not supported\n", mode);
  387. return -EINVAL;
  388. }
  389. return 0;
  390. }
  391. static void
  392. qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable)
  393. {
  394. u32 mask = QCA8K_PORT_STATUS_TXMAC | QCA8K_PORT_STATUS_RXMAC;
  395. /* Port 0 and 6 have no internal PHY */
  396. if (port > 0 && port < 6)
  397. mask |= QCA8K_PORT_STATUS_LINK_AUTO;
  398. if (enable)
  399. qca8k_reg_set(priv, QCA8K_REG_PORT_STATUS(port), mask);
  400. else
  401. qca8k_reg_clear(priv, QCA8K_REG_PORT_STATUS(port), mask);
  402. }
  403. static u32
  404. qca8k_port_to_phy(int port)
  405. {
  406. /* From Andrew Lunn:
  407. * Port 0 has no internal phy.
  408. * Port 1 has an internal PHY at MDIO address 0.
  409. * Port 2 has an internal PHY at MDIO address 1.
  410. * ...
  411. * Port 5 has an internal PHY at MDIO address 4.
  412. * Port 6 has no internal PHY.
  413. */
  414. return port - 1;
  415. }
  416. static int
  417. qca8k_mdio_write(struct qca8k_priv *priv, int port, u32 regnum, u16 data)
  418. {
  419. u32 phy, val;
  420. if (regnum >= QCA8K_MDIO_MASTER_MAX_REG)
  421. return -EINVAL;
  422. /* callee is responsible for not passing bad ports,
  423. * but we still would like to make spills impossible.
  424. */
  425. phy = qca8k_port_to_phy(port) % PHY_MAX_ADDR;
  426. val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN |
  427. QCA8K_MDIO_MASTER_WRITE | QCA8K_MDIO_MASTER_PHY_ADDR(phy) |
  428. QCA8K_MDIO_MASTER_REG_ADDR(regnum) |
  429. QCA8K_MDIO_MASTER_DATA(data);
  430. qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val);
  431. return qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL,
  432. QCA8K_MDIO_MASTER_BUSY);
  433. }
  434. static int
  435. qca8k_mdio_read(struct qca8k_priv *priv, int port, u32 regnum)
  436. {
  437. u32 phy, val;
  438. if (regnum >= QCA8K_MDIO_MASTER_MAX_REG)
  439. return -EINVAL;
  440. /* callee is responsible for not passing bad ports,
  441. * but we still would like to make spills impossible.
  442. */
  443. phy = qca8k_port_to_phy(port) % PHY_MAX_ADDR;
  444. val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN |
  445. QCA8K_MDIO_MASTER_READ | QCA8K_MDIO_MASTER_PHY_ADDR(phy) |
  446. QCA8K_MDIO_MASTER_REG_ADDR(regnum);
  447. qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val);
  448. if (qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL,
  449. QCA8K_MDIO_MASTER_BUSY))
  450. return -ETIMEDOUT;
  451. val = (qca8k_read(priv, QCA8K_MDIO_MASTER_CTRL) &
  452. QCA8K_MDIO_MASTER_DATA_MASK);
  453. return val;
  454. }
  455. static int
  456. qca8k_phy_write(struct dsa_switch *ds, int port, int regnum, u16 data)
  457. {
  458. struct qca8k_priv *priv = ds->priv;
  459. return qca8k_mdio_write(priv, port, regnum, data);
  460. }
  461. static int
  462. qca8k_phy_read(struct dsa_switch *ds, int port, int regnum)
  463. {
  464. struct qca8k_priv *priv = ds->priv;
  465. int ret;
  466. ret = qca8k_mdio_read(priv, port, regnum);
  467. if (ret < 0)
  468. return 0xffff;
  469. return ret;
  470. }
  471. static int
  472. qca8k_setup_mdio_bus(struct qca8k_priv *priv)
  473. {
  474. u32 internal_mdio_mask = 0, external_mdio_mask = 0, reg;
  475. struct device_node *ports, *port;
  476. int err;
  477. ports = of_get_child_by_name(priv->dev->of_node, "ports");
  478. if (!ports)
  479. return -EINVAL;
  480. for_each_available_child_of_node(ports, port) {
  481. err = of_property_read_u32(port, "reg", &reg);
  482. if (err) {
  483. of_node_put(port);
  484. of_node_put(ports);
  485. return err;
  486. }
  487. if (!dsa_is_user_port(priv->ds, reg))
  488. continue;
  489. if (of_property_read_bool(port, "phy-handle"))
  490. external_mdio_mask |= BIT(reg);
  491. else
  492. internal_mdio_mask |= BIT(reg);
  493. }
  494. of_node_put(ports);
  495. if (!external_mdio_mask && !internal_mdio_mask) {
  496. dev_err(priv->dev, "no PHYs are defined.\n");
  497. return -EINVAL;
  498. }
  499. /* The QCA8K_MDIO_MASTER_EN Bit, which grants access to PHYs through
  500. * the MDIO_MASTER register also _disconnects_ the external MDC
  501. * passthrough to the internal PHYs. It's not possible to use both
  502. * configurations at the same time!
  503. *
  504. * Because this came up during the review process:
  505. * If the external mdio-bus driver is capable magically disabling
  506. * the QCA8K_MDIO_MASTER_EN and mutex/spin-locking out the qca8k's
  507. * accessors for the time being, it would be possible to pull this
  508. * off.
  509. */
  510. if (!!external_mdio_mask && !!internal_mdio_mask) {
  511. dev_err(priv->dev, "either internal or external mdio bus configuration is supported.\n");
  512. return -EINVAL;
  513. }
  514. if (external_mdio_mask) {
  515. /* Make sure to disable the internal mdio bus in cases
  516. * a dt-overlay and driver reload changed the configuration
  517. */
  518. qca8k_reg_clear(priv, QCA8K_MDIO_MASTER_CTRL,
  519. QCA8K_MDIO_MASTER_EN);
  520. return 0;
  521. }
  522. priv->ops.phy_read = qca8k_phy_read;
  523. priv->ops.phy_write = qca8k_phy_write;
  524. return 0;
  525. }
  526. static int
  527. qca8k_setup(struct dsa_switch *ds)
  528. {
  529. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  530. int ret, i, phy_mode = -1;
  531. u32 mask;
  532. /* Make sure that port 0 is the cpu port */
  533. if (!dsa_is_cpu_port(ds, 0)) {
  534. pr_err("port 0 is not the CPU port\n");
  535. return -EINVAL;
  536. }
  537. mutex_init(&priv->reg_mutex);
  538. /* Start by setting up the register mapping */
  539. priv->regmap = devm_regmap_init(ds->dev, NULL, priv,
  540. &qca8k_regmap_config);
  541. if (IS_ERR(priv->regmap))
  542. pr_warn("regmap initialization failed");
  543. ret = qca8k_setup_mdio_bus(priv);
  544. if (ret)
  545. return ret;
  546. /* Initialize CPU port pad mode (xMII type, delays...) */
  547. phy_mode = of_get_phy_mode(ds->ports[QCA8K_CPU_PORT].dn);
  548. if (phy_mode < 0) {
  549. pr_err("Can't find phy-mode for master device\n");
  550. return phy_mode;
  551. }
  552. ret = qca8k_set_pad_ctrl(priv, QCA8K_CPU_PORT, phy_mode);
  553. if (ret < 0)
  554. return ret;
  555. /* Enable CPU Port, force it to maximum bandwidth and full-duplex */
  556. mask = QCA8K_PORT_STATUS_SPEED_1000 | QCA8K_PORT_STATUS_TXFLOW |
  557. QCA8K_PORT_STATUS_RXFLOW | QCA8K_PORT_STATUS_DUPLEX;
  558. qca8k_write(priv, QCA8K_REG_PORT_STATUS(QCA8K_CPU_PORT), mask);
  559. qca8k_reg_set(priv, QCA8K_REG_GLOBAL_FW_CTRL0,
  560. QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN);
  561. qca8k_port_set_status(priv, QCA8K_CPU_PORT, 1);
  562. priv->port_sts[QCA8K_CPU_PORT].enabled = 1;
  563. /* Enable MIB counters */
  564. qca8k_mib_init(priv);
  565. /* Enable QCA header mode on the cpu port */
  566. qca8k_write(priv, QCA8K_REG_PORT_HDR_CTRL(QCA8K_CPU_PORT),
  567. QCA8K_PORT_HDR_CTRL_ALL << QCA8K_PORT_HDR_CTRL_TX_S |
  568. QCA8K_PORT_HDR_CTRL_ALL << QCA8K_PORT_HDR_CTRL_RX_S);
  569. /* Disable forwarding by default on all ports */
  570. for (i = 0; i < QCA8K_NUM_PORTS; i++)
  571. qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i),
  572. QCA8K_PORT_LOOKUP_MEMBER, 0);
  573. /* Disable MAC by default on all user ports */
  574. for (i = 1; i < QCA8K_NUM_PORTS; i++)
  575. if (dsa_is_user_port(ds, i))
  576. qca8k_port_set_status(priv, i, 0);
  577. /* Forward all unknown frames to CPU port for Linux processing */
  578. qca8k_write(priv, QCA8K_REG_GLOBAL_FW_CTRL1,
  579. BIT(0) << QCA8K_GLOBAL_FW_CTRL1_IGMP_DP_S |
  580. BIT(0) << QCA8K_GLOBAL_FW_CTRL1_BC_DP_S |
  581. BIT(0) << QCA8K_GLOBAL_FW_CTRL1_MC_DP_S |
  582. BIT(0) << QCA8K_GLOBAL_FW_CTRL1_UC_DP_S);
  583. /* Setup connection between CPU port & user ports */
  584. for (i = 0; i < QCA8K_NUM_PORTS; i++) {
  585. /* CPU port gets connected to all user ports of the switch */
  586. if (dsa_is_cpu_port(ds, i)) {
  587. qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(QCA8K_CPU_PORT),
  588. QCA8K_PORT_LOOKUP_MEMBER, dsa_user_ports(ds));
  589. }
  590. /* Invividual user ports get connected to CPU port only */
  591. if (dsa_is_user_port(ds, i)) {
  592. int shift = 16 * (i % 2);
  593. qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i),
  594. QCA8K_PORT_LOOKUP_MEMBER,
  595. BIT(QCA8K_CPU_PORT));
  596. /* Enable ARP Auto-learning by default */
  597. qca8k_reg_set(priv, QCA8K_PORT_LOOKUP_CTRL(i),
  598. QCA8K_PORT_LOOKUP_LEARN);
  599. /* For port based vlans to work we need to set the
  600. * default egress vid
  601. */
  602. qca8k_rmw(priv, QCA8K_EGRESS_VLAN(i),
  603. 0xffff << shift, 1 << shift);
  604. qca8k_write(priv, QCA8K_REG_PORT_VLAN_CTRL0(i),
  605. QCA8K_PORT_VLAN_CVID(1) |
  606. QCA8K_PORT_VLAN_SVID(1));
  607. }
  608. }
  609. /* Flush the FDB table */
  610. qca8k_fdb_flush(priv);
  611. return 0;
  612. }
  613. static void
  614. qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy)
  615. {
  616. struct qca8k_priv *priv = ds->priv;
  617. u32 reg;
  618. /* Force fixed-link setting for CPU port, skip others. */
  619. if (!phy_is_pseudo_fixed_link(phy))
  620. return;
  621. /* Set port speed */
  622. switch (phy->speed) {
  623. case 10:
  624. reg = QCA8K_PORT_STATUS_SPEED_10;
  625. break;
  626. case 100:
  627. reg = QCA8K_PORT_STATUS_SPEED_100;
  628. break;
  629. case 1000:
  630. reg = QCA8K_PORT_STATUS_SPEED_1000;
  631. break;
  632. default:
  633. dev_dbg(priv->dev, "port%d link speed %dMbps not supported.\n",
  634. port, phy->speed);
  635. return;
  636. }
  637. /* Set duplex mode */
  638. if (phy->duplex == DUPLEX_FULL)
  639. reg |= QCA8K_PORT_STATUS_DUPLEX;
  640. /* Force flow control */
  641. if (dsa_is_cpu_port(ds, port))
  642. reg |= QCA8K_PORT_STATUS_RXFLOW | QCA8K_PORT_STATUS_TXFLOW;
  643. /* Force link down before changing MAC options */
  644. qca8k_port_set_status(priv, port, 0);
  645. qca8k_write(priv, QCA8K_REG_PORT_STATUS(port), reg);
  646. qca8k_port_set_status(priv, port, 1);
  647. }
  648. static void
  649. qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data)
  650. {
  651. int i;
  652. if (stringset != ETH_SS_STATS)
  653. return;
  654. for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++)
  655. strncpy(data + i * ETH_GSTRING_LEN, ar8327_mib[i].name,
  656. ETH_GSTRING_LEN);
  657. }
  658. static void
  659. qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
  660. uint64_t *data)
  661. {
  662. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  663. const struct qca8k_mib_desc *mib;
  664. u32 reg, i;
  665. u64 hi;
  666. for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++) {
  667. mib = &ar8327_mib[i];
  668. reg = QCA8K_PORT_MIB_COUNTER(port) + mib->offset;
  669. data[i] = qca8k_read(priv, reg);
  670. if (mib->size == 2) {
  671. hi = qca8k_read(priv, reg + 4);
  672. data[i] |= hi << 32;
  673. }
  674. }
  675. }
  676. static int
  677. qca8k_get_sset_count(struct dsa_switch *ds, int port, int sset)
  678. {
  679. if (sset != ETH_SS_STATS)
  680. return 0;
  681. return ARRAY_SIZE(ar8327_mib);
  682. }
  683. static int
  684. qca8k_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *eee)
  685. {
  686. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  687. u32 lpi_en = QCA8K_REG_EEE_CTRL_LPI_EN(port);
  688. u32 reg;
  689. mutex_lock(&priv->reg_mutex);
  690. reg = qca8k_read(priv, QCA8K_REG_EEE_CTRL);
  691. if (eee->eee_enabled)
  692. reg |= lpi_en;
  693. else
  694. reg &= ~lpi_en;
  695. qca8k_write(priv, QCA8K_REG_EEE_CTRL, reg);
  696. mutex_unlock(&priv->reg_mutex);
  697. return 0;
  698. }
  699. static int
  700. qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e)
  701. {
  702. /* Nothing to do on the port's MAC */
  703. return 0;
  704. }
  705. static void
  706. qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
  707. {
  708. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  709. u32 stp_state;
  710. switch (state) {
  711. case BR_STATE_DISABLED:
  712. stp_state = QCA8K_PORT_LOOKUP_STATE_DISABLED;
  713. break;
  714. case BR_STATE_BLOCKING:
  715. stp_state = QCA8K_PORT_LOOKUP_STATE_BLOCKING;
  716. break;
  717. case BR_STATE_LISTENING:
  718. stp_state = QCA8K_PORT_LOOKUP_STATE_LISTENING;
  719. break;
  720. case BR_STATE_LEARNING:
  721. stp_state = QCA8K_PORT_LOOKUP_STATE_LEARNING;
  722. break;
  723. case BR_STATE_FORWARDING:
  724. default:
  725. stp_state = QCA8K_PORT_LOOKUP_STATE_FORWARD;
  726. break;
  727. }
  728. qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
  729. QCA8K_PORT_LOOKUP_STATE_MASK, stp_state);
  730. }
  731. static int
  732. qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br)
  733. {
  734. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  735. int port_mask = BIT(QCA8K_CPU_PORT);
  736. int i;
  737. for (i = 1; i < QCA8K_NUM_PORTS; i++) {
  738. if (dsa_to_port(ds, i)->bridge_dev != br)
  739. continue;
  740. /* Add this port to the portvlan mask of the other ports
  741. * in the bridge
  742. */
  743. qca8k_reg_set(priv,
  744. QCA8K_PORT_LOOKUP_CTRL(i),
  745. BIT(port));
  746. if (i != port)
  747. port_mask |= BIT(i);
  748. }
  749. /* Add all other ports to this ports portvlan mask */
  750. qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
  751. QCA8K_PORT_LOOKUP_MEMBER, port_mask);
  752. return 0;
  753. }
  754. static void
  755. qca8k_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br)
  756. {
  757. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  758. int i;
  759. for (i = 1; i < QCA8K_NUM_PORTS; i++) {
  760. if (dsa_to_port(ds, i)->bridge_dev != br)
  761. continue;
  762. /* Remove this port to the portvlan mask of the other ports
  763. * in the bridge
  764. */
  765. qca8k_reg_clear(priv,
  766. QCA8K_PORT_LOOKUP_CTRL(i),
  767. BIT(port));
  768. }
  769. /* Set the cpu port to be the only one in the portvlan mask of
  770. * this port
  771. */
  772. qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
  773. QCA8K_PORT_LOOKUP_MEMBER, BIT(QCA8K_CPU_PORT));
  774. }
  775. static int
  776. qca8k_port_enable(struct dsa_switch *ds, int port,
  777. struct phy_device *phy)
  778. {
  779. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  780. if (!dsa_is_user_port(ds, port))
  781. return 0;
  782. qca8k_port_set_status(priv, port, 1);
  783. priv->port_sts[port].enabled = 1;
  784. phy_support_asym_pause(phy);
  785. return 0;
  786. }
  787. static void
  788. qca8k_port_disable(struct dsa_switch *ds, int port)
  789. {
  790. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  791. qca8k_port_set_status(priv, port, 0);
  792. priv->port_sts[port].enabled = 0;
  793. }
  794. static int
  795. qca8k_port_fdb_insert(struct qca8k_priv *priv, const u8 *addr,
  796. u16 port_mask, u16 vid)
  797. {
  798. /* Set the vid to the port vlan id if no vid is set */
  799. if (!vid)
  800. vid = 1;
  801. return qca8k_fdb_add(priv, addr, port_mask, vid,
  802. QCA8K_ATU_STATUS_STATIC);
  803. }
  804. static int
  805. qca8k_port_fdb_add(struct dsa_switch *ds, int port,
  806. const unsigned char *addr, u16 vid)
  807. {
  808. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  809. u16 port_mask = BIT(port);
  810. return qca8k_port_fdb_insert(priv, addr, port_mask, vid);
  811. }
  812. static int
  813. qca8k_port_fdb_del(struct dsa_switch *ds, int port,
  814. const unsigned char *addr, u16 vid)
  815. {
  816. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  817. u16 port_mask = BIT(port);
  818. if (!vid)
  819. vid = 1;
  820. return qca8k_fdb_del(priv, addr, port_mask, vid);
  821. }
  822. static int
  823. qca8k_port_fdb_dump(struct dsa_switch *ds, int port,
  824. dsa_fdb_dump_cb_t *cb, void *data)
  825. {
  826. struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
  827. struct qca8k_fdb _fdb = { 0 };
  828. int cnt = QCA8K_NUM_FDB_RECORDS;
  829. bool is_static;
  830. int ret = 0;
  831. mutex_lock(&priv->reg_mutex);
  832. while (cnt-- && !qca8k_fdb_next(priv, &_fdb, port)) {
  833. if (!_fdb.aging)
  834. break;
  835. is_static = (_fdb.aging == QCA8K_ATU_STATUS_STATIC);
  836. ret = cb(_fdb.mac, _fdb.vid, is_static, data);
  837. if (ret)
  838. break;
  839. }
  840. mutex_unlock(&priv->reg_mutex);
  841. return 0;
  842. }
  843. static enum dsa_tag_protocol
  844. qca8k_get_tag_protocol(struct dsa_switch *ds, int port)
  845. {
  846. return DSA_TAG_PROTO_QCA;
  847. }
  848. static const struct dsa_switch_ops qca8k_switch_ops = {
  849. .get_tag_protocol = qca8k_get_tag_protocol,
  850. .setup = qca8k_setup,
  851. .adjust_link = qca8k_adjust_link,
  852. .get_strings = qca8k_get_strings,
  853. .get_ethtool_stats = qca8k_get_ethtool_stats,
  854. .get_sset_count = qca8k_get_sset_count,
  855. .get_mac_eee = qca8k_get_mac_eee,
  856. .set_mac_eee = qca8k_set_mac_eee,
  857. .port_enable = qca8k_port_enable,
  858. .port_disable = qca8k_port_disable,
  859. .port_stp_state_set = qca8k_port_stp_state_set,
  860. .port_bridge_join = qca8k_port_bridge_join,
  861. .port_bridge_leave = qca8k_port_bridge_leave,
  862. .port_fdb_add = qca8k_port_fdb_add,
  863. .port_fdb_del = qca8k_port_fdb_del,
  864. .port_fdb_dump = qca8k_port_fdb_dump,
  865. };
  866. static int
  867. qca8k_sw_probe(struct mdio_device *mdiodev)
  868. {
  869. struct qca8k_priv *priv;
  870. u32 id;
  871. /* allocate the private data struct so that we can probe the switches
  872. * ID register
  873. */
  874. priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
  875. if (!priv)
  876. return -ENOMEM;
  877. priv->bus = mdiodev->bus;
  878. priv->dev = &mdiodev->dev;
  879. priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
  880. GPIOD_ASIS);
  881. if (IS_ERR(priv->reset_gpio))
  882. return PTR_ERR(priv->reset_gpio);
  883. if (priv->reset_gpio) {
  884. gpiod_set_value_cansleep(priv->reset_gpio, 1);
  885. /* The active low duration must be greater than 10 ms
  886. * and checkpatch.pl wants 20 ms.
  887. */
  888. msleep(20);
  889. gpiod_set_value_cansleep(priv->reset_gpio, 0);
  890. }
  891. /* read the switches ID register */
  892. id = qca8k_read(priv, QCA8K_REG_MASK_CTRL);
  893. id >>= QCA8K_MASK_CTRL_ID_S;
  894. id &= QCA8K_MASK_CTRL_ID_M;
  895. if (id != QCA8K_ID_QCA8337)
  896. return -ENODEV;
  897. priv->ds = dsa_switch_alloc(&mdiodev->dev, QCA8K_NUM_PORTS);
  898. if (!priv->ds)
  899. return -ENOMEM;
  900. priv->ds->priv = priv;
  901. priv->ops = qca8k_switch_ops;
  902. priv->ds->ops = &priv->ops;
  903. mutex_init(&priv->reg_mutex);
  904. dev_set_drvdata(&mdiodev->dev, priv);
  905. return dsa_register_switch(priv->ds);
  906. }
  907. static void
  908. qca8k_sw_remove(struct mdio_device *mdiodev)
  909. {
  910. struct qca8k_priv *priv = dev_get_drvdata(&mdiodev->dev);
  911. int i;
  912. for (i = 0; i < QCA8K_NUM_PORTS; i++)
  913. qca8k_port_set_status(priv, i, 0);
  914. dsa_unregister_switch(priv->ds);
  915. }
  916. #ifdef CONFIG_PM_SLEEP
  917. static void
  918. qca8k_set_pm(struct qca8k_priv *priv, int enable)
  919. {
  920. int i;
  921. for (i = 0; i < QCA8K_NUM_PORTS; i++) {
  922. if (!priv->port_sts[i].enabled)
  923. continue;
  924. qca8k_port_set_status(priv, i, enable);
  925. }
  926. }
  927. static int qca8k_suspend(struct device *dev)
  928. {
  929. struct qca8k_priv *priv = dev_get_drvdata(dev);
  930. qca8k_set_pm(priv, 0);
  931. return dsa_switch_suspend(priv->ds);
  932. }
  933. static int qca8k_resume(struct device *dev)
  934. {
  935. struct qca8k_priv *priv = dev_get_drvdata(dev);
  936. qca8k_set_pm(priv, 1);
  937. return dsa_switch_resume(priv->ds);
  938. }
  939. #endif /* CONFIG_PM_SLEEP */
  940. static SIMPLE_DEV_PM_OPS(qca8k_pm_ops,
  941. qca8k_suspend, qca8k_resume);
  942. static const struct of_device_id qca8k_of_match[] = {
  943. { .compatible = "qca,qca8334" },
  944. { .compatible = "qca,qca8337" },
  945. { /* sentinel */ },
  946. };
  947. static struct mdio_driver qca8kmdio_driver = {
  948. .probe = qca8k_sw_probe,
  949. .remove = qca8k_sw_remove,
  950. .mdiodrv.driver = {
  951. .name = "qca8k",
  952. .of_match_table = qca8k_of_match,
  953. .pm = &qca8k_pm_ops,
  954. },
  955. };
  956. mdio_module_driver(qca8kmdio_driver);
  957. MODULE_AUTHOR("Mathieu Olivari, John Crispin <john@phrozen.org>");
  958. MODULE_DESCRIPTION("Driver for QCA8K ethernet switch family");
  959. MODULE_LICENSE("GPL v2");
  960. MODULE_ALIAS("platform:qca8k");