dev-eth.c 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  1. /*
  2. * Atheros AR71xx SoC platform devices
  3. *
  4. * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
  5. * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  7. *
  8. * Parts of this file are based on Atheros 2.6.15 BSP
  9. * Parts of this file are based on Atheros 2.6.31 BSP
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License version 2 as published
  13. * by the Free Software Foundation.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/delay.h>
  18. #include <linux/etherdevice.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/serial_8250.h>
  21. #include <linux/clk.h>
  22. #include <linux/sizes.h>
  23. #include <asm/mach-ath79/ath79.h>
  24. #include <asm/mach-ath79/ar71xx_regs.h>
  25. #include <asm/mach-ath79/irq.h>
  26. #include "common.h"
  27. #include "dev-eth.h"
  28. unsigned char ath79_mac_base[ETH_ALEN] __initdata;
  29. static struct resource ath79_mdio0_resources[] = {
  30. {
  31. .name = "mdio_base",
  32. .flags = IORESOURCE_MEM,
  33. .start = AR71XX_GE0_BASE,
  34. .end = AR71XX_GE0_BASE + 0x200 - 1,
  35. }
  36. };
  37. struct ag71xx_mdio_platform_data ath79_mdio0_data;
  38. struct platform_device ath79_mdio0_device = {
  39. .name = "ag71xx-mdio",
  40. .id = 0,
  41. .resource = ath79_mdio0_resources,
  42. .num_resources = ARRAY_SIZE(ath79_mdio0_resources),
  43. .dev = {
  44. .platform_data = &ath79_mdio0_data,
  45. },
  46. };
  47. static struct resource ath79_mdio1_resources[] = {
  48. {
  49. .name = "mdio_base",
  50. .flags = IORESOURCE_MEM,
  51. .start = AR71XX_GE1_BASE,
  52. .end = AR71XX_GE1_BASE + 0x200 - 1,
  53. }
  54. };
  55. struct ag71xx_mdio_platform_data ath79_mdio1_data;
  56. struct platform_device ath79_mdio1_device = {
  57. .name = "ag71xx-mdio",
  58. .id = 1,
  59. .resource = ath79_mdio1_resources,
  60. .num_resources = ARRAY_SIZE(ath79_mdio1_resources),
  61. .dev = {
  62. .platform_data = &ath79_mdio1_data,
  63. },
  64. };
  65. static void ath79_set_pll(u32 cfg_reg, u32 pll_reg, u32 pll_val, u32 shift)
  66. {
  67. void __iomem *base;
  68. u32 t;
  69. base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  70. t = __raw_readl(base + cfg_reg);
  71. t &= ~(3 << shift);
  72. t |= (2 << shift);
  73. __raw_writel(t, base + cfg_reg);
  74. udelay(100);
  75. __raw_writel(pll_val, base + pll_reg);
  76. t |= (3 << shift);
  77. __raw_writel(t, base + cfg_reg);
  78. udelay(100);
  79. t &= ~(3 << shift);
  80. __raw_writel(t, base + cfg_reg);
  81. udelay(100);
  82. printk(KERN_DEBUG "ar71xx: pll_reg %#x: %#x\n",
  83. (unsigned int)(base + pll_reg), __raw_readl(base + pll_reg));
  84. iounmap(base);
  85. }
  86. static void __init ath79_mii_ctrl_set_if(unsigned int reg,
  87. unsigned int mii_if)
  88. {
  89. void __iomem *base;
  90. u32 t;
  91. base = ioremap(AR71XX_MII_BASE, AR71XX_MII_SIZE);
  92. t = __raw_readl(base + reg);
  93. t &= ~(AR71XX_MII_CTRL_IF_MASK);
  94. t |= (mii_if & AR71XX_MII_CTRL_IF_MASK);
  95. __raw_writel(t, base + reg);
  96. iounmap(base);
  97. }
  98. static void ath79_mii_ctrl_set_speed(unsigned int reg, unsigned int speed)
  99. {
  100. void __iomem *base;
  101. unsigned int mii_speed;
  102. u32 t;
  103. switch (speed) {
  104. case SPEED_10:
  105. mii_speed = AR71XX_MII_CTRL_SPEED_10;
  106. break;
  107. case SPEED_100:
  108. mii_speed = AR71XX_MII_CTRL_SPEED_100;
  109. break;
  110. case SPEED_1000:
  111. mii_speed = AR71XX_MII_CTRL_SPEED_1000;
  112. break;
  113. default:
  114. BUG();
  115. }
  116. base = ioremap(AR71XX_MII_BASE, AR71XX_MII_SIZE);
  117. t = __raw_readl(base + reg);
  118. t &= ~(AR71XX_MII_CTRL_SPEED_MASK << AR71XX_MII_CTRL_SPEED_SHIFT);
  119. t |= mii_speed << AR71XX_MII_CTRL_SPEED_SHIFT;
  120. __raw_writel(t, base + reg);
  121. iounmap(base);
  122. }
  123. static unsigned long ar934x_get_mdio_ref_clock(void)
  124. {
  125. void __iomem *base;
  126. unsigned long ret;
  127. u32 t;
  128. base = ioremap(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  129. ret = 0;
  130. t = __raw_readl(base + AR934X_PLL_SWITCH_CLOCK_CONTROL_REG);
  131. if (t & AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL) {
  132. ret = 100 * 1000 * 1000;
  133. } else {
  134. struct clk *clk;
  135. clk = clk_get(NULL, "ref");
  136. if (!IS_ERR(clk))
  137. ret = clk_get_rate(clk);
  138. }
  139. iounmap(base);
  140. return ret;
  141. }
  142. void __init ath79_register_mdio(unsigned int id, u32 phy_mask)
  143. {
  144. struct platform_device *mdio_dev;
  145. struct ag71xx_mdio_platform_data *mdio_data;
  146. unsigned int max_id;
  147. if (ath79_soc == ATH79_SOC_AR9341 ||
  148. ath79_soc == ATH79_SOC_AR9342 ||
  149. ath79_soc == ATH79_SOC_AR9344 ||
  150. ath79_soc == ATH79_SOC_QCA9556 ||
  151. ath79_soc == ATH79_SOC_QCA9558 ||
  152. ath79_soc == ATH79_SOC_QCA956X)
  153. max_id = 1;
  154. else
  155. max_id = 0;
  156. if (id > max_id) {
  157. printk(KERN_ERR "ar71xx: invalid MDIO id %u\n", id);
  158. return;
  159. }
  160. switch (ath79_soc) {
  161. case ATH79_SOC_AR7241:
  162. case ATH79_SOC_AR9330:
  163. case ATH79_SOC_AR9331:
  164. case ATH79_SOC_QCA9533:
  165. case ATH79_SOC_TP9343:
  166. mdio_dev = &ath79_mdio1_device;
  167. mdio_data = &ath79_mdio1_data;
  168. break;
  169. case ATH79_SOC_AR9341:
  170. case ATH79_SOC_AR9342:
  171. case ATH79_SOC_AR9344:
  172. case ATH79_SOC_QCA9556:
  173. case ATH79_SOC_QCA9558:
  174. case ATH79_SOC_QCA956X:
  175. if (id == 0) {
  176. mdio_dev = &ath79_mdio0_device;
  177. mdio_data = &ath79_mdio0_data;
  178. } else {
  179. mdio_dev = &ath79_mdio1_device;
  180. mdio_data = &ath79_mdio1_data;
  181. }
  182. break;
  183. case ATH79_SOC_AR7242:
  184. ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG,
  185. AR7242_PLL_REG_ETH0_INT_CLOCK, 0x62000000,
  186. AR71XX_ETH0_PLL_SHIFT);
  187. /* fall through */
  188. default:
  189. mdio_dev = &ath79_mdio0_device;
  190. mdio_data = &ath79_mdio0_data;
  191. break;
  192. }
  193. mdio_data->phy_mask = phy_mask;
  194. switch (ath79_soc) {
  195. case ATH79_SOC_AR7240:
  196. mdio_data->is_ar7240 = 1;
  197. /* fall through */
  198. case ATH79_SOC_AR7241:
  199. mdio_data->builtin_switch = 1;
  200. break;
  201. case ATH79_SOC_AR9330:
  202. mdio_data->is_ar9330 = 1;
  203. /* fall through */
  204. case ATH79_SOC_AR9331:
  205. mdio_data->builtin_switch = 1;
  206. break;
  207. case ATH79_SOC_AR9341:
  208. case ATH79_SOC_AR9342:
  209. case ATH79_SOC_AR9344:
  210. if (id == 1) {
  211. mdio_data->builtin_switch = 1;
  212. mdio_data->ref_clock = ar934x_get_mdio_ref_clock();
  213. mdio_data->mdio_clock = 6250000;
  214. }
  215. mdio_data->is_ar934x = 1;
  216. break;
  217. case ATH79_SOC_QCA9533:
  218. case ATH79_SOC_TP9343:
  219. mdio_data->builtin_switch = 1;
  220. break;
  221. case ATH79_SOC_QCA9556:
  222. case ATH79_SOC_QCA9558:
  223. mdio_data->is_ar934x = 1;
  224. break;
  225. case ATH79_SOC_QCA956X:
  226. if (id == 1)
  227. mdio_data->builtin_switch = 1;
  228. mdio_data->is_ar934x = 1;
  229. break;
  230. default:
  231. break;
  232. }
  233. platform_device_register(mdio_dev);
  234. }
  235. struct ath79_eth_pll_data ath79_eth0_pll_data;
  236. struct ath79_eth_pll_data ath79_eth1_pll_data;
  237. static u32 ath79_get_eth_pll(unsigned int mac, int speed)
  238. {
  239. struct ath79_eth_pll_data *pll_data;
  240. u32 pll_val;
  241. switch (mac) {
  242. case 0:
  243. pll_data = &ath79_eth0_pll_data;
  244. break;
  245. case 1:
  246. pll_data = &ath79_eth1_pll_data;
  247. break;
  248. default:
  249. BUG();
  250. }
  251. switch (speed) {
  252. case SPEED_10:
  253. pll_val = pll_data->pll_10;
  254. break;
  255. case SPEED_100:
  256. pll_val = pll_data->pll_100;
  257. break;
  258. case SPEED_1000:
  259. pll_val = pll_data->pll_1000;
  260. break;
  261. default:
  262. BUG();
  263. }
  264. return pll_val;
  265. }
  266. static void ath79_set_speed_ge0(int speed)
  267. {
  268. u32 val = ath79_get_eth_pll(0, speed);
  269. ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH0_INT_CLOCK,
  270. val, AR71XX_ETH0_PLL_SHIFT);
  271. ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
  272. }
  273. static void ath79_set_speed_ge1(int speed)
  274. {
  275. u32 val = ath79_get_eth_pll(1, speed);
  276. ath79_set_pll(AR71XX_PLL_REG_SEC_CONFIG, AR71XX_PLL_REG_ETH1_INT_CLOCK,
  277. val, AR71XX_ETH1_PLL_SHIFT);
  278. ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
  279. }
  280. static void ar7242_set_speed_ge0(int speed)
  281. {
  282. u32 val = ath79_get_eth_pll(0, speed);
  283. void __iomem *base;
  284. base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  285. __raw_writel(val, base + AR7242_PLL_REG_ETH0_INT_CLOCK);
  286. iounmap(base);
  287. }
  288. static void ar91xx_set_speed_ge0(int speed)
  289. {
  290. u32 val = ath79_get_eth_pll(0, speed);
  291. ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH0_INT_CLOCK,
  292. val, AR913X_ETH0_PLL_SHIFT);
  293. ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
  294. }
  295. static void ar91xx_set_speed_ge1(int speed)
  296. {
  297. u32 val = ath79_get_eth_pll(1, speed);
  298. ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH1_INT_CLOCK,
  299. val, AR913X_ETH1_PLL_SHIFT);
  300. ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
  301. }
  302. static void ar934x_set_speed_ge0(int speed)
  303. {
  304. void __iomem *base;
  305. u32 val = ath79_get_eth_pll(0, speed);
  306. base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  307. __raw_writel(val, base + AR934X_PLL_ETH_XMII_CONTROL_REG);
  308. iounmap(base);
  309. }
  310. static void qca955x_set_speed_xmii(int speed)
  311. {
  312. void __iomem *base;
  313. u32 val = ath79_get_eth_pll(0, speed);
  314. base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  315. __raw_writel(val, base + QCA955X_PLL_ETH_XMII_CONTROL_REG);
  316. iounmap(base);
  317. }
  318. static void qca955x_set_speed_sgmii(int id, int speed)
  319. {
  320. void __iomem *base;
  321. u32 val = ath79_get_eth_pll(id, speed);
  322. base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  323. __raw_writel(val, base + QCA955X_PLL_ETH_SGMII_CONTROL_REG);
  324. iounmap(base);
  325. }
  326. static void qca9556_set_speed_sgmii(int speed)
  327. {
  328. qca955x_set_speed_sgmii(0, speed);
  329. }
  330. static void qca9558_set_speed_sgmii(int speed)
  331. {
  332. qca955x_set_speed_sgmii(1, speed);
  333. }
  334. static void qca956x_set_speed_sgmii(int speed)
  335. {
  336. void __iomem *base;
  337. u32 val = ath79_get_eth_pll(0, speed);
  338. base = ioremap_nocache(AR71XX_PLL_BASE, AR71XX_PLL_SIZE);
  339. __raw_writel(val, base + QCA955X_PLL_ETH_SGMII_CONTROL_REG);
  340. iounmap(base);
  341. }
  342. static void ath79_set_speed_dummy(int speed)
  343. {
  344. }
  345. static void ath79_ddr_flush_ge0(void)
  346. {
  347. ath79_ddr_wb_flush(0);
  348. }
  349. static void ath79_ddr_flush_ge1(void)
  350. {
  351. ath79_ddr_wb_flush(1);
  352. }
  353. static struct resource ath79_eth0_resources[] = {
  354. {
  355. .name = "mac_base",
  356. .flags = IORESOURCE_MEM,
  357. .start = AR71XX_GE0_BASE,
  358. .end = AR71XX_GE0_BASE + 0x200 - 1,
  359. }, {
  360. .name = "mac_irq",
  361. .flags = IORESOURCE_IRQ,
  362. .start = ATH79_CPU_IRQ(4),
  363. .end = ATH79_CPU_IRQ(4),
  364. },
  365. };
  366. struct ag71xx_platform_data ath79_eth0_data = {
  367. .reset_bit = AR71XX_RESET_GE0_MAC,
  368. };
  369. struct platform_device ath79_eth0_device = {
  370. .name = "ag71xx",
  371. .id = 0,
  372. .resource = ath79_eth0_resources,
  373. .num_resources = ARRAY_SIZE(ath79_eth0_resources),
  374. .dev = {
  375. .platform_data = &ath79_eth0_data,
  376. },
  377. };
  378. static struct resource ath79_eth1_resources[] = {
  379. {
  380. .name = "mac_base",
  381. .flags = IORESOURCE_MEM,
  382. .start = AR71XX_GE1_BASE,
  383. .end = AR71XX_GE1_BASE + 0x200 - 1,
  384. }, {
  385. .name = "mac_irq",
  386. .flags = IORESOURCE_IRQ,
  387. .start = ATH79_CPU_IRQ(5),
  388. .end = ATH79_CPU_IRQ(5),
  389. },
  390. };
  391. struct ag71xx_platform_data ath79_eth1_data = {
  392. .reset_bit = AR71XX_RESET_GE1_MAC,
  393. };
  394. struct platform_device ath79_eth1_device = {
  395. .name = "ag71xx",
  396. .id = 1,
  397. .resource = ath79_eth1_resources,
  398. .num_resources = ARRAY_SIZE(ath79_eth1_resources),
  399. .dev = {
  400. .platform_data = &ath79_eth1_data,
  401. },
  402. };
  403. struct ag71xx_switch_platform_data ath79_switch_data;
  404. #define AR71XX_PLL_VAL_1000 0x00110000
  405. #define AR71XX_PLL_VAL_100 0x00001099
  406. #define AR71XX_PLL_VAL_10 0x00991099
  407. #define AR724X_PLL_VAL_1000 0x00110000
  408. #define AR724X_PLL_VAL_100 0x00001099
  409. #define AR724X_PLL_VAL_10 0x00991099
  410. #define AR7242_PLL_VAL_1000 0x16000000
  411. #define AR7242_PLL_VAL_100 0x00000101
  412. #define AR7242_PLL_VAL_10 0x00001616
  413. #define AR913X_PLL_VAL_1000 0x1a000000
  414. #define AR913X_PLL_VAL_100 0x13000a44
  415. #define AR913X_PLL_VAL_10 0x00441099
  416. #define AR933X_PLL_VAL_1000 0x00110000
  417. #define AR933X_PLL_VAL_100 0x00001099
  418. #define AR933X_PLL_VAL_10 0x00991099
  419. #define AR934X_PLL_VAL_1000 0x16000000
  420. #define AR934X_PLL_VAL_100 0x00000101
  421. #define AR934X_PLL_VAL_10 0x00001616
  422. #define QCA956X_PLL_VAL_1000 0x03000000
  423. #define QCA956X_PLL_VAL_100 0x00000101
  424. #define QCA956X_PLL_VAL_10 0x00001919
  425. static void __init ath79_init_eth_pll_data(unsigned int id)
  426. {
  427. struct ath79_eth_pll_data *pll_data;
  428. u32 pll_10, pll_100, pll_1000;
  429. switch (id) {
  430. case 0:
  431. pll_data = &ath79_eth0_pll_data;
  432. break;
  433. case 1:
  434. pll_data = &ath79_eth1_pll_data;
  435. break;
  436. default:
  437. BUG();
  438. }
  439. switch (ath79_soc) {
  440. case ATH79_SOC_AR7130:
  441. case ATH79_SOC_AR7141:
  442. case ATH79_SOC_AR7161:
  443. pll_10 = AR71XX_PLL_VAL_10;
  444. pll_100 = AR71XX_PLL_VAL_100;
  445. pll_1000 = AR71XX_PLL_VAL_1000;
  446. break;
  447. case ATH79_SOC_AR7240:
  448. case ATH79_SOC_AR7241:
  449. pll_10 = AR724X_PLL_VAL_10;
  450. pll_100 = AR724X_PLL_VAL_100;
  451. pll_1000 = AR724X_PLL_VAL_1000;
  452. break;
  453. case ATH79_SOC_AR7242:
  454. pll_10 = AR7242_PLL_VAL_10;
  455. pll_100 = AR7242_PLL_VAL_100;
  456. pll_1000 = AR7242_PLL_VAL_1000;
  457. break;
  458. case ATH79_SOC_AR9130:
  459. case ATH79_SOC_AR9132:
  460. pll_10 = AR913X_PLL_VAL_10;
  461. pll_100 = AR913X_PLL_VAL_100;
  462. pll_1000 = AR913X_PLL_VAL_1000;
  463. break;
  464. case ATH79_SOC_AR9330:
  465. case ATH79_SOC_AR9331:
  466. pll_10 = AR933X_PLL_VAL_10;
  467. pll_100 = AR933X_PLL_VAL_100;
  468. pll_1000 = AR933X_PLL_VAL_1000;
  469. break;
  470. case ATH79_SOC_AR9341:
  471. case ATH79_SOC_AR9342:
  472. case ATH79_SOC_AR9344:
  473. case ATH79_SOC_QCA9533:
  474. case ATH79_SOC_QCA9556:
  475. case ATH79_SOC_QCA9558:
  476. case ATH79_SOC_TP9343:
  477. pll_10 = AR934X_PLL_VAL_10;
  478. pll_100 = AR934X_PLL_VAL_100;
  479. pll_1000 = AR934X_PLL_VAL_1000;
  480. break;
  481. case ATH79_SOC_QCA956X:
  482. pll_10 = QCA956X_PLL_VAL_10;
  483. pll_100 = QCA956X_PLL_VAL_100;
  484. pll_1000 = QCA956X_PLL_VAL_1000;
  485. break;
  486. default:
  487. BUG();
  488. }
  489. if (!pll_data->pll_10)
  490. pll_data->pll_10 = pll_10;
  491. if (!pll_data->pll_100)
  492. pll_data->pll_100 = pll_100;
  493. if (!pll_data->pll_1000)
  494. pll_data->pll_1000 = pll_1000;
  495. }
  496. static int __init ath79_setup_phy_if_mode(unsigned int id,
  497. struct ag71xx_platform_data *pdata)
  498. {
  499. unsigned int mii_if;
  500. switch (id) {
  501. case 0:
  502. switch (ath79_soc) {
  503. case ATH79_SOC_AR7130:
  504. case ATH79_SOC_AR7141:
  505. case ATH79_SOC_AR7161:
  506. case ATH79_SOC_AR9130:
  507. case ATH79_SOC_AR9132:
  508. switch (pdata->phy_if_mode) {
  509. case PHY_INTERFACE_MODE_MII:
  510. mii_if = AR71XX_MII0_CTRL_IF_MII;
  511. break;
  512. case PHY_INTERFACE_MODE_GMII:
  513. mii_if = AR71XX_MII0_CTRL_IF_GMII;
  514. break;
  515. case PHY_INTERFACE_MODE_RGMII:
  516. mii_if = AR71XX_MII0_CTRL_IF_RGMII;
  517. break;
  518. case PHY_INTERFACE_MODE_RMII:
  519. mii_if = AR71XX_MII0_CTRL_IF_RMII;
  520. break;
  521. default:
  522. return -EINVAL;
  523. }
  524. ath79_mii_ctrl_set_if(AR71XX_MII_REG_MII0_CTRL, mii_if);
  525. break;
  526. case ATH79_SOC_AR7240:
  527. case ATH79_SOC_AR7241:
  528. case ATH79_SOC_AR9330:
  529. case ATH79_SOC_AR9331:
  530. case ATH79_SOC_QCA9533:
  531. case ATH79_SOC_TP9343:
  532. pdata->phy_if_mode = PHY_INTERFACE_MODE_MII;
  533. break;
  534. case ATH79_SOC_AR7242:
  535. /* FIXME */
  536. case ATH79_SOC_AR9341:
  537. case ATH79_SOC_AR9342:
  538. case ATH79_SOC_AR9344:
  539. switch (pdata->phy_if_mode) {
  540. case PHY_INTERFACE_MODE_MII:
  541. case PHY_INTERFACE_MODE_GMII:
  542. case PHY_INTERFACE_MODE_RGMII:
  543. case PHY_INTERFACE_MODE_RMII:
  544. break;
  545. default:
  546. return -EINVAL;
  547. }
  548. break;
  549. case ATH79_SOC_QCA9556:
  550. case ATH79_SOC_QCA9558:
  551. case ATH79_SOC_QCA956X:
  552. switch (pdata->phy_if_mode) {
  553. case PHY_INTERFACE_MODE_MII:
  554. case PHY_INTERFACE_MODE_RGMII:
  555. case PHY_INTERFACE_MODE_SGMII:
  556. break;
  557. default:
  558. return -EINVAL;
  559. }
  560. break;
  561. default:
  562. BUG();
  563. }
  564. break;
  565. case 1:
  566. switch (ath79_soc) {
  567. case ATH79_SOC_AR7130:
  568. case ATH79_SOC_AR7141:
  569. case ATH79_SOC_AR7161:
  570. case ATH79_SOC_AR9130:
  571. case ATH79_SOC_AR9132:
  572. switch (pdata->phy_if_mode) {
  573. case PHY_INTERFACE_MODE_RMII:
  574. mii_if = AR71XX_MII1_CTRL_IF_RMII;
  575. break;
  576. case PHY_INTERFACE_MODE_RGMII:
  577. mii_if = AR71XX_MII1_CTRL_IF_RGMII;
  578. break;
  579. default:
  580. return -EINVAL;
  581. }
  582. ath79_mii_ctrl_set_if(AR71XX_MII_REG_MII1_CTRL, mii_if);
  583. break;
  584. case ATH79_SOC_AR7240:
  585. case ATH79_SOC_AR7241:
  586. case ATH79_SOC_AR9330:
  587. case ATH79_SOC_AR9331:
  588. case ATH79_SOC_TP9343:
  589. pdata->phy_if_mode = PHY_INTERFACE_MODE_GMII;
  590. break;
  591. case ATH79_SOC_AR7242:
  592. /* FIXME */
  593. case ATH79_SOC_AR9341:
  594. case ATH79_SOC_AR9342:
  595. case ATH79_SOC_AR9344:
  596. case ATH79_SOC_QCA9533:
  597. case ATH79_SOC_QCA956X:
  598. switch (pdata->phy_if_mode) {
  599. case PHY_INTERFACE_MODE_MII:
  600. case PHY_INTERFACE_MODE_GMII:
  601. break;
  602. default:
  603. return -EINVAL;
  604. }
  605. break;
  606. case ATH79_SOC_QCA9556:
  607. case ATH79_SOC_QCA9558:
  608. switch (pdata->phy_if_mode) {
  609. case PHY_INTERFACE_MODE_MII:
  610. case PHY_INTERFACE_MODE_RGMII:
  611. case PHY_INTERFACE_MODE_SGMII:
  612. break;
  613. default:
  614. return -EINVAL;
  615. }
  616. break;
  617. default:
  618. BUG();
  619. }
  620. break;
  621. }
  622. return 0;
  623. }
  624. void __init ath79_setup_ar933x_phy4_switch(bool mac, bool mdio)
  625. {
  626. void __iomem *base;
  627. u32 t;
  628. base = ioremap(AR933X_GMAC_BASE, AR933X_GMAC_SIZE);
  629. t = __raw_readl(base + AR933X_GMAC_REG_ETH_CFG);
  630. t &= ~(AR933X_ETH_CFG_SW_PHY_SWAP | AR933X_ETH_CFG_SW_PHY_ADDR_SWAP);
  631. if (mac)
  632. t |= AR933X_ETH_CFG_SW_PHY_SWAP;
  633. if (mdio)
  634. t |= AR933X_ETH_CFG_SW_PHY_ADDR_SWAP;
  635. __raw_writel(t, base + AR933X_GMAC_REG_ETH_CFG);
  636. iounmap(base);
  637. }
  638. void __init ath79_setup_ar934x_eth_cfg(u32 mask)
  639. {
  640. void __iomem *base;
  641. u32 t;
  642. base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
  643. t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  644. t &= ~(AR934X_ETH_CFG_RGMII_GMAC0 |
  645. AR934X_ETH_CFG_MII_GMAC0 |
  646. AR934X_ETH_CFG_GMII_GMAC0 |
  647. AR934X_ETH_CFG_SW_ONLY_MODE |
  648. AR934X_ETH_CFG_SW_PHY_SWAP);
  649. t |= mask;
  650. __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
  651. /* flush write */
  652. __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  653. iounmap(base);
  654. }
  655. void __init ath79_setup_ar934x_eth_rx_delay(unsigned int rxd,
  656. unsigned int rxdv)
  657. {
  658. void __iomem *base;
  659. u32 t;
  660. rxd &= AR934X_ETH_CFG_RXD_DELAY_MASK;
  661. rxdv &= AR934X_ETH_CFG_RDV_DELAY_MASK;
  662. base = ioremap(AR934X_GMAC_BASE, AR934X_GMAC_SIZE);
  663. t = __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  664. t &= ~(AR934X_ETH_CFG_RXD_DELAY_MASK << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
  665. AR934X_ETH_CFG_RDV_DELAY_MASK << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
  666. t |= (rxd << AR934X_ETH_CFG_RXD_DELAY_SHIFT |
  667. rxdv << AR934X_ETH_CFG_RDV_DELAY_SHIFT);
  668. __raw_writel(t, base + AR934X_GMAC_REG_ETH_CFG);
  669. /* flush write */
  670. __raw_readl(base + AR934X_GMAC_REG_ETH_CFG);
  671. iounmap(base);
  672. }
  673. void __init ath79_setup_qca955x_eth_cfg(u32 mask)
  674. {
  675. void __iomem *base;
  676. u32 t;
  677. base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
  678. t = __raw_readl(base + QCA955X_GMAC_REG_ETH_CFG);
  679. t &= ~(QCA955X_ETH_CFG_RGMII_EN | QCA955X_ETH_CFG_GE0_SGMII);
  680. t |= mask;
  681. __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
  682. iounmap(base);
  683. }
  684. void __init ath79_setup_qca956x_eth_cfg(u32 mask)
  685. {
  686. void __iomem *base;
  687. u32 t;
  688. base = ioremap(QCA956X_GMAC_BASE, QCA956X_GMAC_SIZE);
  689. t = __raw_readl(base + QCA956X_GMAC_REG_ETH_CFG);
  690. t &= ~(QCA956X_ETH_CFG_SW_ONLY_MODE |
  691. QCA956X_ETH_CFG_SW_PHY_SWAP);
  692. t |= mask;
  693. __raw_writel(t, base + QCA956X_GMAC_REG_ETH_CFG);
  694. /* flush write */
  695. __raw_readl(base + QCA956X_GMAC_REG_ETH_CFG);
  696. iounmap(base);
  697. }
  698. static int ath79_eth_instance __initdata;
  699. void __init ath79_register_eth(unsigned int id)
  700. {
  701. struct platform_device *pdev;
  702. struct ag71xx_platform_data *pdata;
  703. int err;
  704. if (id > 1) {
  705. printk(KERN_ERR "ar71xx: invalid ethernet id %d\n", id);
  706. return;
  707. }
  708. ath79_init_eth_pll_data(id);
  709. if (id == 0)
  710. pdev = &ath79_eth0_device;
  711. else
  712. pdev = &ath79_eth1_device;
  713. pdata = pdev->dev.platform_data;
  714. pdata->max_frame_len = 1540;
  715. pdata->desc_pktlen_mask = 0xfff;
  716. err = ath79_setup_phy_if_mode(id, pdata);
  717. if (err) {
  718. printk(KERN_ERR
  719. "ar71xx: invalid PHY interface mode for GE%u\n", id);
  720. return;
  721. }
  722. if (id == 0)
  723. pdata->ddr_flush = ath79_ddr_flush_ge0;
  724. else
  725. pdata->ddr_flush = ath79_ddr_flush_ge1;
  726. switch (ath79_soc) {
  727. case ATH79_SOC_AR7130:
  728. if (id == 0)
  729. pdata->set_speed = ath79_set_speed_ge0;
  730. else
  731. pdata->set_speed = ath79_set_speed_ge1;
  732. break;
  733. case ATH79_SOC_AR7141:
  734. case ATH79_SOC_AR7161:
  735. if (id == 0)
  736. pdata->set_speed = ath79_set_speed_ge0;
  737. else
  738. pdata->set_speed = ath79_set_speed_ge1;
  739. pdata->has_gbit = 1;
  740. break;
  741. case ATH79_SOC_AR7242:
  742. if (id == 0) {
  743. pdata->reset_bit |= AR724X_RESET_GE0_MDIO |
  744. AR71XX_RESET_GE0_PHY;
  745. pdata->set_speed = ar7242_set_speed_ge0;
  746. } else {
  747. pdata->reset_bit |= AR724X_RESET_GE1_MDIO |
  748. AR71XX_RESET_GE1_PHY;
  749. pdata->set_speed = ath79_set_speed_dummy;
  750. }
  751. pdata->has_gbit = 1;
  752. pdata->is_ar724x = 1;
  753. break;
  754. case ATH79_SOC_AR7241:
  755. if (id == 0)
  756. pdata->reset_bit |= AR724X_RESET_GE0_MDIO;
  757. else
  758. pdata->reset_bit |= AR724X_RESET_GE1_MDIO;
  759. /* fall through */
  760. case ATH79_SOC_AR7240:
  761. if (id == 0) {
  762. pdata->reset_bit |= AR71XX_RESET_GE0_PHY;
  763. pdata->set_speed = ath79_set_speed_dummy;
  764. pdata->phy_mask = BIT(4);
  765. } else {
  766. pdata->reset_bit |= AR71XX_RESET_GE1_PHY;
  767. pdata->set_speed = ath79_set_speed_dummy;
  768. pdata->speed = SPEED_1000;
  769. pdata->duplex = DUPLEX_FULL;
  770. pdata->switch_data = &ath79_switch_data;
  771. pdata->use_flow_control = 1;
  772. ath79_switch_data.phy_poll_mask |= BIT(4);
  773. }
  774. pdata->has_gbit = 1;
  775. pdata->is_ar724x = 1;
  776. if (ath79_soc == ATH79_SOC_AR7240)
  777. pdata->is_ar7240 = 1;
  778. break;
  779. case ATH79_SOC_AR9132:
  780. pdata->has_gbit = 1;
  781. /* fall through */
  782. case ATH79_SOC_AR9130:
  783. if (id == 0)
  784. pdata->set_speed = ar91xx_set_speed_ge0;
  785. else
  786. pdata->set_speed = ar91xx_set_speed_ge1;
  787. pdata->is_ar91xx = 1;
  788. break;
  789. case ATH79_SOC_AR9330:
  790. case ATH79_SOC_AR9331:
  791. if (id == 0) {
  792. pdata->reset_bit = AR933X_RESET_GE0_MAC |
  793. AR933X_RESET_GE0_MDIO;
  794. pdata->set_speed = ath79_set_speed_dummy;
  795. pdata->phy_mask = BIT(4);
  796. } else {
  797. pdata->reset_bit = AR933X_RESET_GE1_MAC |
  798. AR933X_RESET_GE1_MDIO;
  799. pdata->set_speed = ath79_set_speed_dummy;
  800. pdata->speed = SPEED_1000;
  801. pdata->has_gbit = 1;
  802. pdata->duplex = DUPLEX_FULL;
  803. pdata->switch_data = &ath79_switch_data;
  804. pdata->use_flow_control = 1;
  805. ath79_switch_data.phy_poll_mask |= BIT(4);
  806. }
  807. pdata->is_ar724x = 1;
  808. break;
  809. case ATH79_SOC_AR9341:
  810. case ATH79_SOC_AR9342:
  811. case ATH79_SOC_AR9344:
  812. case ATH79_SOC_QCA9533:
  813. if (id == 0) {
  814. pdata->reset_bit = AR934X_RESET_GE0_MAC |
  815. AR934X_RESET_GE0_MDIO;
  816. pdata->set_speed = ar934x_set_speed_ge0;
  817. if (ath79_soc == ATH79_SOC_QCA9533)
  818. pdata->disable_inline_checksum_engine = 1;
  819. } else {
  820. pdata->reset_bit = AR934X_RESET_GE1_MAC |
  821. AR934X_RESET_GE1_MDIO;
  822. pdata->set_speed = ath79_set_speed_dummy;
  823. pdata->switch_data = &ath79_switch_data;
  824. /* reset the built-in switch */
  825. ath79_device_reset_set(AR934X_RESET_ETH_SWITCH);
  826. ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH);
  827. }
  828. pdata->has_gbit = 1;
  829. pdata->is_ar724x = 1;
  830. pdata->max_frame_len = SZ_16K - 1;
  831. pdata->desc_pktlen_mask = SZ_16K - 1;
  832. break;
  833. case ATH79_SOC_TP9343:
  834. if (id == 0) {
  835. pdata->reset_bit = AR933X_RESET_GE0_MAC |
  836. AR933X_RESET_GE0_MDIO;
  837. pdata->set_speed = ath79_set_speed_dummy;
  838. if (!pdata->phy_mask)
  839. pdata->phy_mask = BIT(4);
  840. } else {
  841. pdata->reset_bit = AR933X_RESET_GE1_MAC |
  842. AR933X_RESET_GE1_MDIO;
  843. pdata->set_speed = ath79_set_speed_dummy;
  844. pdata->speed = SPEED_1000;
  845. pdata->duplex = DUPLEX_FULL;
  846. pdata->switch_data = &ath79_switch_data;
  847. pdata->use_flow_control = 1;
  848. ath79_switch_data.phy_poll_mask |= BIT(4);
  849. }
  850. pdata->has_gbit = 1;
  851. pdata->is_ar724x = 1;
  852. break;
  853. case ATH79_SOC_QCA9556:
  854. case ATH79_SOC_QCA9558:
  855. if (id == 0) {
  856. pdata->reset_bit = QCA955X_RESET_GE0_MAC |
  857. QCA955X_RESET_GE0_MDIO;
  858. pdata->set_speed = qca955x_set_speed_xmii;
  859. /* QCA9556 only has SGMII interface */
  860. if (ath79_soc == ATH79_SOC_QCA9556)
  861. pdata->set_speed = qca9556_set_speed_sgmii;
  862. } else {
  863. pdata->reset_bit = QCA955X_RESET_GE1_MAC |
  864. QCA955X_RESET_GE1_MDIO;
  865. pdata->set_speed = qca9558_set_speed_sgmii;
  866. }
  867. pdata->has_gbit = 1;
  868. pdata->is_ar724x = 1;
  869. /*
  870. * Limit the maximum frame length to 4095 bytes.
  871. * Although the documentation says that the hardware
  872. * limit is 16383 bytes but that does not work in
  873. * practice. It seems that the hardware only updates
  874. * the lowest 12 bits of the packet length field
  875. * in the RX descriptor.
  876. */
  877. pdata->max_frame_len = SZ_4K - 1;
  878. pdata->desc_pktlen_mask = SZ_16K - 1;
  879. break;
  880. case ATH79_SOC_QCA956X:
  881. if (id == 0) {
  882. pdata->reset_bit = QCA955X_RESET_GE0_MAC |
  883. QCA955X_RESET_GE0_MDIO;
  884. if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
  885. pdata->set_speed = qca956x_set_speed_sgmii;
  886. else
  887. pdata->set_speed = ar934x_set_speed_ge0;
  888. pdata->disable_inline_checksum_engine = 1;
  889. } else {
  890. pdata->reset_bit = QCA955X_RESET_GE1_MAC |
  891. QCA955X_RESET_GE1_MDIO;
  892. pdata->set_speed = ath79_set_speed_dummy;
  893. pdata->switch_data = &ath79_switch_data;
  894. pdata->speed = SPEED_1000;
  895. pdata->duplex = DUPLEX_FULL;
  896. pdata->use_flow_control = 1;
  897. /* reset the built-in switch */
  898. ath79_device_reset_set(AR934X_RESET_ETH_SWITCH);
  899. ath79_device_reset_clear(AR934X_RESET_ETH_SWITCH);
  900. }
  901. pdata->has_gbit = 1;
  902. pdata->is_ar724x = 1;
  903. break;
  904. default:
  905. BUG();
  906. }
  907. switch (pdata->phy_if_mode) {
  908. case PHY_INTERFACE_MODE_GMII:
  909. case PHY_INTERFACE_MODE_RGMII:
  910. case PHY_INTERFACE_MODE_SGMII:
  911. if (!pdata->has_gbit) {
  912. printk(KERN_ERR "ar71xx: no gbit available on eth%d\n",
  913. id);
  914. return;
  915. }
  916. /* fallthrough */
  917. default:
  918. break;
  919. }
  920. if (!is_valid_ether_addr(pdata->mac_addr)) {
  921. random_ether_addr(pdata->mac_addr);
  922. printk(KERN_DEBUG
  923. "ar71xx: using random MAC address for eth%d\n",
  924. ath79_eth_instance);
  925. }
  926. if (pdata->mii_bus_dev == NULL) {
  927. switch (ath79_soc) {
  928. case ATH79_SOC_AR9341:
  929. case ATH79_SOC_AR9342:
  930. case ATH79_SOC_AR9344:
  931. if (id == 0)
  932. pdata->mii_bus_dev = &ath79_mdio0_device.dev;
  933. else
  934. pdata->mii_bus_dev = &ath79_mdio1_device.dev;
  935. break;
  936. case ATH79_SOC_AR7241:
  937. case ATH79_SOC_AR9330:
  938. case ATH79_SOC_AR9331:
  939. case ATH79_SOC_QCA9533:
  940. case ATH79_SOC_TP9343:
  941. pdata->mii_bus_dev = &ath79_mdio1_device.dev;
  942. break;
  943. case ATH79_SOC_QCA9556:
  944. case ATH79_SOC_QCA9558:
  945. /* don't assign any MDIO device by default */
  946. break;
  947. case ATH79_SOC_QCA956X:
  948. if (pdata->phy_if_mode != PHY_INTERFACE_MODE_SGMII)
  949. pdata->mii_bus_dev = &ath79_mdio1_device.dev;
  950. break;
  951. default:
  952. pdata->mii_bus_dev = &ath79_mdio0_device.dev;
  953. break;
  954. }
  955. }
  956. /* Reset the device */
  957. ath79_device_reset_set(pdata->reset_bit);
  958. msleep(100);
  959. ath79_device_reset_clear(pdata->reset_bit);
  960. msleep(100);
  961. platform_device_register(pdev);
  962. ath79_eth_instance++;
  963. }
  964. void __init ath79_set_mac_base(unsigned char *mac)
  965. {
  966. memcpy(ath79_mac_base, mac, ETH_ALEN);
  967. }
  968. void __init ath79_parse_ascii_mac(char *mac_str, u8 *mac)
  969. {
  970. int t;
  971. t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
  972. &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
  973. if (t != ETH_ALEN)
  974. t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
  975. &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
  976. if (t != ETH_ALEN || !is_valid_ether_addr(mac)) {
  977. memset(mac, 0, ETH_ALEN);
  978. printk(KERN_DEBUG "ar71xx: invalid mac address \"%s\"\n",
  979. mac_str);
  980. }
  981. }
  982. void __init ath79_extract_mac_reverse(u8 *ptr, u8 *out)
  983. {
  984. int i;
  985. for (i = 0; i < ETH_ALEN; i++) {
  986. out[i] = ptr[ETH_ALEN-i-1];
  987. }
  988. }
  989. static void __init ath79_set_mac_base_ascii(char *str)
  990. {
  991. u8 mac[ETH_ALEN];
  992. ath79_parse_ascii_mac(str, mac);
  993. ath79_set_mac_base(mac);
  994. }
  995. static int __init ath79_ethaddr_setup(char *str)
  996. {
  997. ath79_set_mac_base_ascii(str);
  998. return 1;
  999. }
  1000. __setup("ethaddr=", ath79_ethaddr_setup);
  1001. static int __init ath79_kmac_setup(char *str)
  1002. {
  1003. ath79_set_mac_base_ascii(str);
  1004. return 1;
  1005. }
  1006. __setup("kmac=", ath79_kmac_setup);
  1007. void __init ath79_init_mac(unsigned char *dst, const unsigned char *src,
  1008. int offset)
  1009. {
  1010. int t;
  1011. if (!dst)
  1012. return;
  1013. if (!src || !is_valid_ether_addr(src)) {
  1014. memset(dst, '\0', ETH_ALEN);
  1015. return;
  1016. }
  1017. t = (((u32) src[3]) << 16) + (((u32) src[4]) << 8) + ((u32) src[5]);
  1018. t += offset;
  1019. dst[0] = src[0];
  1020. dst[1] = src[1];
  1021. dst[2] = src[2];
  1022. dst[3] = (t >> 16) & 0xff;
  1023. dst[4] = (t >> 8) & 0xff;
  1024. dst[5] = t & 0xff;
  1025. }
  1026. void __init ath79_init_local_mac(unsigned char *dst, const unsigned char *src)
  1027. {
  1028. int i;
  1029. if (!dst)
  1030. return;
  1031. if (!src || !is_valid_ether_addr(src)) {
  1032. memset(dst, '\0', ETH_ALEN);
  1033. return;
  1034. }
  1035. for (i = 0; i < ETH_ALEN; i++)
  1036. dst[i] = src[i];
  1037. dst[0] |= 0x02;
  1038. }