当前位置:   article > 正文

Zynq-Linux移植学习笔记之34-使用PCS/PMA IP核配置网络

pma ip

1、硬件设计

设计图如下,zynq PS ETH1连接PCS/PMA IP核。

这里PCS/PMA IP核相当于PHY,外部通过PCB连接到光模块。IP核的对应配置如下:

上面重要的部分是PHY的地址1.

 

2、uboot设计

在uboot中启用双网卡,需要修改zynq-common.h和zynq-zc70x.h两个配置文件

首先在zynq-zc70x.h中增加GEM1并且设置PHY地址为1

 

然后修改zynq-common.h文件,增加CONFIG_HAS_ETH1并设置eth1addr环境变量地址

在zynq_gem.c中增加针对不同网卡的配置

 

源码如下

  1. /*
  2. * (C) Copyright 2011 Michal Simek
  3. *
  4. * Michal SIMEK <monstr@monstr.eu>
  5. *
  6. * Based on Xilinx gmac driver:
  7. * (C) Copyright 2011 Xilinx
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <net.h>
  13. #include <config.h>
  14. #include <malloc.h>
  15. #include <asm/io.h>
  16. #include <phy.h>
  17. #include <miiphy.h>
  18. #include <watchdog.h>
  19. #include <asm/arch/hardware.h>
  20. #include <asm/arch/sys_proto.h>
  21. /* Bit/mask specification */
  22. #define ZYNQ_GEM_PHYMNTNC_OP_MASK 0x40020000 /* operation mask bits */
  23. #define ZYNQ_GEM_PHYMNTNC_OP_R_MASK 0x20000000 /* read operation */
  24. #define ZYNQ_GEM_PHYMNTNC_OP_W_MASK 0x10000000 /* write operation */
  25. #define ZYNQ_GEM_PHYMNTNC_PHYAD_SHIFT_MASK 23 /* Shift bits for PHYAD */
  26. #define ZYNQ_GEM_PHYMNTNC_PHREG_SHIFT_MASK 18 /* Shift bits for PHREG */
  27. #define ZYNQ_GEM_RXBUF_EOF_MASK 0x00008000 /* End of frame. */
  28. #define ZYNQ_GEM_RXBUF_SOF_MASK 0x00004000 /* Start of frame. */
  29. #define ZYNQ_GEM_RXBUF_LEN_MASK 0x00003FFF /* Mask for length field */
  30. #define ZYNQ_GEM_RXBUF_WRAP_MASK 0x00000002 /* Wrap bit, last BD */
  31. #define ZYNQ_GEM_RXBUF_NEW_MASK 0x00000001 /* Used bit.. */
  32. #define ZYNQ_GEM_RXBUF_ADD_MASK 0xFFFFFFFC /* Mask for address */
  33. /* Wrap bit, last descriptor */
  34. #define ZYNQ_GEM_TXBUF_WRAP_MASK 0x40000000
  35. #define ZYNQ_GEM_TXBUF_LAST_MASK 0x00008000 /* Last buffer */
  36. #define ZYNQ_GEM_NWCTRL_TXEN_MASK 0x00000008 /* Enable transmit */
  37. #define ZYNQ_GEM_NWCTRL_RXEN_MASK 0x00000004 /* Enable receive */
  38. #define ZYNQ_GEM_NWCTRL_MDEN_MASK 0x00000010 /* Enable MDIO port */
  39. #define ZYNQ_GEM_NWCTRL_STARTTX_MASK 0x00000200 /* Start tx (tx_go) */
  40. #define ZYNQ_GEM_NWCFG_SPEED100 0x000000001 /* 100 Mbps operation */
  41. #define ZYNQ_GEM_NWCFG_SPEED1000 0x000000400 /* 1Gbps operation */
  42. #define ZYNQ_GEM_NWCFG_FDEN 0x000000002 /* Full Duplex mode */
  43. #define ZYNQ_GEM_NWCFG_FSREM 0x000020000 /* FCS removal */
  44. #define ZYNQ_GEM_NWCFG_MDCCLKDIV 0x000080000 /* Div pclk by 32, 80MHz */
  45. #define ZYNQ_GEM_NWCFG_MDCCLKDIV2 0x0000c0000 /* Div pclk by 48, 120MHz */
  46. #define ZYNQ_GEM_NWCFG_INIT (ZYNQ_GEM_NWCFG_FDEN | \
  47. ZYNQ_GEM_NWCFG_FSREM | \
  48. ZYNQ_GEM_NWCFG_MDCCLKDIV)
  49. #define ZYNQ_GEM_NWSR_MDIOIDLE_MASK 0x00000004 /* PHY management idle */
  50. #define ZYNQ_GEM_DMACR_BLENGTH 0x00000004 /* INCR4 AHB bursts */
  51. /* Use full configured addressable space (8 Kb) */
  52. #define ZYNQ_GEM_DMACR_RXSIZE 0x00000300
  53. /* Use full configured addressable space (4 Kb) */
  54. #define ZYNQ_GEM_DMACR_TXSIZE 0x00000400
  55. /* Set with binary 00011000 to use 1536 byte(1*max length frame/buffer) */
  56. #define ZYNQ_GEM_DMACR_RXBUF 0x00180000
  57. #define ZYNQ_GEM_DMACR_INIT (ZYNQ_GEM_DMACR_BLENGTH | \
  58. ZYNQ_GEM_DMACR_RXSIZE | \
  59. ZYNQ_GEM_DMACR_TXSIZE | \
  60. ZYNQ_GEM_DMACR_RXBUF)
  61. /* Use MII register 1 (MII status register) to detect PHY */
  62. #define PHY_DETECT_REG 1
  63. /* Mask used to verify certain PHY features (or register contents)
  64. * in the register above:
  65. * 0x1000: 10Mbps full duplex support
  66. * 0x0800: 10Mbps half duplex support
  67. * 0x0008: Auto-negotiation support
  68. */
  69. #define PHY_DETECT_MASK 0x1808
  70. /* TX BD status masks */
  71. #define ZYNQ_GEM_TXBUF_FRMLEN_MASK 0x000007ff
  72. #define ZYNQ_GEM_TXBUF_EXHAUSTED 0x08000000
  73. #define ZYNQ_GEM_TXBUF_UNDERRUN 0x10000000
  74. /* Clock frequencies for different speeds */
  75. #define ZYNQ_GEM_FREQUENCY_10 2500000UL
  76. #define ZYNQ_GEM_FREQUENCY_100 25000000UL
  77. #define ZYNQ_GEM_FREQUENCY_1000 125000000UL
  78. /* Device registers */
  79. struct zynq_gem_regs {
  80. u32 nwctrl; /* Network Control reg */
  81. u32 nwcfg; /* Network Config reg */
  82. u32 nwsr; /* Network Status reg */
  83. u32 reserved1;
  84. u32 dmacr; /* DMA Control reg */
  85. u32 txsr; /* TX Status reg */
  86. u32 rxqbase; /* RX Q Base address reg */
  87. u32 txqbase; /* TX Q Base address reg */
  88. u32 rxsr; /* RX Status reg */
  89. u32 reserved2[2];
  90. u32 idr; /* Interrupt Disable reg */
  91. u32 reserved3;
  92. u32 phymntnc; /* Phy Maintaince reg */
  93. u32 reserved4[18];
  94. u32 hashl; /* Hash Low address reg */
  95. u32 hashh; /* Hash High address reg */
  96. #define LADDR_LOW 0
  97. #define LADDR_HIGH 1
  98. u32 laddr[4][LADDR_HIGH + 1]; /* Specific1 addr low/high reg */
  99. u32 match[4]; /* Type ID1 Match reg */
  100. u32 reserved6[18];
  101. u32 stat[44]; /* Octects transmitted Low reg - stat start */
  102. };
  103. /* BD descriptors */
  104. struct emac_bd {
  105. u32 addr; /* Next descriptor pointer */
  106. u32 status;
  107. };
  108. int net_base_addr;
  109. #define RX_BUF 3
  110. /* Page table entries are set to 1MB, or multiples of 1MB
  111. * (not < 1MB). driver uses less bd's so use 1MB bdspace.
  112. */
  113. #define BD_SPACE 0x100000
  114. /* BD separation space */
  115. #define BD_SEPRN_SPACE 64
  116. /* Initialized, rxbd_current, rx_first_buf must be 0 after init */
  117. struct zynq_gem_priv {
  118. struct emac_bd *tx_bd;
  119. struct emac_bd *rx_bd;
  120. char *rxbuffers;
  121. u32 rxbd_current;
  122. u32 rx_first_buf;
  123. int phyaddr;
  124. u32 emio;
  125. int init;
  126. struct phy_device *phydev;
  127. struct mii_dev *bus;
  128. };
  129. static inline int mdio_wait(struct eth_device *dev)
  130. {
  131. struct zynq_gem_regs *regs = (struct zynq_gem_regs *)dev->iobase;
  132. u32 timeout = 20000;
  133. /* Wait till MDIO interface is ready to accept a new transaction. */
  134. while (--timeout) {
  135. if (readl(&regs->nwsr) & ZYNQ_GEM_NWSR_MDIOIDLE_MASK)
  136. break;
  137. WATCHDOG_RESET();
  138. }
  139. if (!timeout) {
  140. printf("%s: Timeout\n", __func__);
  141. return 1;
  142. }
  143. return 0;
  144. }
  145. static u32 phy_setup_op(struct eth_device *dev, u32 phy_addr, u32 regnum,
  146. u32 op, u16 *data)
  147. {
  148. u32 mgtcr;
  149. struct zynq_gem_regs *regs = (struct zynq_gem_regs *)dev->iobase;
  150. if (mdio_wait(dev))
  151. return 1;
  152. /* Construct mgtcr mask for the operation */
  153. mgtcr = ZYNQ_GEM_PHYMNTNC_OP_MASK | op |
  154. (phy_addr << ZYNQ_GEM_PHYMNTNC_PHYAD_SHIFT_MASK) |
  155. (regnum << ZYNQ_GEM_PHYMNTNC_PHREG_SHIFT_MASK)| *data;
  156. /* Write mgtcr and wait for completion */
  157. writel(mgtcr, &regs->phymntnc);
  158. if (mdio_wait(dev))
  159. return 1;
  160. if (op == ZYNQ_GEM_PHYMNTNC_OP_R_MASK)
  161. *data = readl(&regs->phymntnc);
  162. return 0;
  163. }
  164. static u32 phyread(struct eth_device *dev, u32 phy_addr, u32 regnum, u16 *val)
  165. {
  166. return phy_setup_op(dev, phy_addr, regnum,
  167. ZYNQ_GEM_PHYMNTNC_OP_R_MASK, val);
  168. }
  169. static u32 phywrite(struct eth_device *dev, u32 phy_addr, u32 regnum, u16 data)
  170. {
  171. return phy_setup_op(dev, phy_addr, regnum,
  172. ZYNQ_GEM_PHYMNTNC_OP_W_MASK, &data);
  173. }
  174. #ifndef CONFIG_PHYLIB
  175. static int phy_rst(struct eth_device *dev)
  176. {
  177. struct zynq_gem_priv *priv = dev->priv;
  178. u16 tmp;
  179. phyread(dev, priv->phyaddr, 0, &tmp);
  180. tmp |= 0x8000;
  181. phywrite(dev, priv->phyaddr, 0, tmp);
  182. phyread(dev, priv->phyaddr, 0, &tmp);
  183. while (tmp & 0x8000) {
  184. putc('.');
  185. if (ctrlc())
  186. return 1;
  187. phyread(dev, priv->phyaddr, 0, &tmp);
  188. }
  189. puts("\nPHY reset complete.\n");
  190. return 0;
  191. }
  192. #endif
  193. static void phy_negotiat(struct eth_device *dev)
  194. {
  195. struct zynq_gem_priv *priv = dev->priv;
  196. u16 control;
  197. u16 status;
  198. u16 temp;
  199. u16 timeout_counter=0;
  200. phywrite(dev,priv->phyaddr, 22, 2);
  201. phyread(dev, priv->phyaddr, 21, &control);
  202. control |= 0x0030;
  203. phywrite(dev, priv->phyaddr, 21, control);
  204. phywrite(dev, priv->phyaddr, 22, 0);
  205. phyread(dev, priv->phyaddr, 4, &control);
  206. control |= 0x0800;
  207. control |= 0x0400;
  208. control |= (0x0100 | 0x0080);
  209. control |= (0x0040 | 0x0020);
  210. phywrite(dev, priv->phyaddr, 4, control);
  211. phyread(dev, priv->phyaddr, 9,&control);
  212. control |= 0x0300;
  213. phywrite(dev, priv->phyaddr, 9,control);
  214. phywrite(dev, priv->phyaddr, 22, 0);
  215. phyread(dev, priv->phyaddr, 16,&control);
  216. control |= (7 << 12); /* max number of gigabit attempts */
  217. control |= (1 << 11); /* enable downshift */
  218. phywrite(dev, priv->phyaddr, 16,control);
  219. phyread(dev, priv->phyaddr, 0, &control);
  220. control |= 0x1000;
  221. control |= 0x0200;
  222. phywrite(dev, priv->phyaddr, 0, control);
  223. phyread(dev, priv->phyaddr, 0, &control);
  224. control |= 0x8000;
  225. phywrite(dev, priv->phyaddr, 0, control);
  226. while (1)
  227. {
  228. phyread(dev, priv->phyaddr, 0, &control);
  229. if (control & 0x8000)
  230. {
  231. continue;
  232. }
  233. else
  234. {
  235. break;
  236. }
  237. }
  238. phyread(dev, priv->phyaddr, 1, &status);
  239. while ( !(status & 0x0020) )
  240. {
  241. phyread(dev, priv->phyaddr,19, &temp);
  242. // timeout_counter++;
  243. // if (timeout_counter == 30)
  244. // {
  245. // printf("Auto negotiation error\n");
  246. // return;
  247. // }
  248. phyread(dev, priv->phyaddr, 1, &status);
  249. }
  250. printf("autonegotiation complete.\n");
  251. }
  252. static void phy_detection(struct eth_device *dev)
  253. {
  254. int i;
  255. u16 phyreg;
  256. struct zynq_gem_priv *priv = dev->priv;
  257. if (priv->phyaddr != -1) {
  258. phyread(dev, priv->phyaddr, PHY_DETECT_REG, &phyreg);
  259. if ((phyreg != 0xFFFF) &&
  260. ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
  261. /* Found a valid PHY address */
  262. debug("Default phy address %d is valid\n",
  263. priv->phyaddr);
  264. return;
  265. } else {
  266. debug("PHY address is not setup correctly %d\n",
  267. priv->phyaddr);
  268. priv->phyaddr = -1;
  269. }
  270. }
  271. debug("detecting phy address\n");
  272. if (priv->phyaddr == -1) {
  273. /* detect the PHY address */
  274. for (i = 31; i >= 0; i--) {
  275. phyread(dev, i, PHY_DETECT_REG, &phyreg);
  276. if ((phyreg != 0xFFFF) &&
  277. ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
  278. /* Found a valid PHY address */
  279. priv->phyaddr = i;
  280. debug("Found valid phy address, %d\n", i);
  281. return;
  282. }
  283. }
  284. }
  285. priv->phyaddr = 0;
  286. debug("No PHY detected. Assuming a PHY at address 0\r\n");
  287. }
  288. static int zynq_gem_setup_mac(struct eth_device *dev)
  289. {
  290. u32 i, macaddrlow, macaddrhigh;
  291. struct zynq_gem_regs *regs = (struct zynq_gem_regs *)dev->iobase;
  292. /* Set the MAC bits [31:0] in BOT */
  293. macaddrlow = dev->enetaddr[0];
  294. macaddrlow |= dev->enetaddr[1] << 8;
  295. macaddrlow |= dev->enetaddr[2] << 16;
  296. macaddrlow |= dev->enetaddr[3] << 24;
  297. /* Set MAC bits [47:32] in TOP */
  298. macaddrhigh = dev->enetaddr[4];
  299. macaddrhigh |= dev->enetaddr[5] << 8;
  300. for (i = 0; i < 4; i++) {
  301. writel(0, &regs->laddr[i][LADDR_LOW]);
  302. writel(0, &regs->laddr[i][LADDR_HIGH]);
  303. /* Do not use MATCHx register */
  304. writel(0, &regs->match[i]);
  305. }
  306. writel(macaddrlow, &regs->laddr[0][LADDR_LOW]);
  307. writel(macaddrhigh, &regs->laddr[0][LADDR_HIGH]);
  308. return 0;
  309. }
  310. static int zynq_gem_init(struct eth_device *dev, bd_t * bis)
  311. {
  312. u32 i;
  313. u16 tmp;
  314. unsigned short PhyReg;
  315. unsigned long clk_rate = 0;
  316. struct phy_device *phydev;
  317. const u32 stat_size = (sizeof(struct zynq_gem_regs) -
  318. offsetof(struct zynq_gem_regs, stat)) / 4;
  319. struct zynq_gem_regs *regs = (struct zynq_gem_regs *)dev->iobase;
  320. struct zynq_gem_priv *priv = dev->priv;
  321. const u32 supported = SUPPORTED_10baseT_Half |
  322. SUPPORTED_10baseT_Full |
  323. SUPPORTED_100baseT_Half |
  324. SUPPORTED_100baseT_Full |
  325. SUPPORTED_1000baseT_Half |
  326. SUPPORTED_1000baseT_Full;
  327. if (!priv->init) {
  328. /* Disable all interrupts */
  329. writel(0xFFFFFFFF, &regs->idr);
  330. /* Disable the receiver & transmitter */
  331. writel(0, &regs->nwctrl);
  332. writel(0, &regs->txsr);
  333. writel(0, &regs->rxsr);
  334. writel(0, &regs->phymntnc);
  335. /* Clear the Hash registers for the mac address
  336. * pointed by AddressPtr
  337. */
  338. writel(0x0, &regs->hashl);
  339. /* Write bits [63:32] in TOP */
  340. writel(0x0, &regs->hashh);
  341. /* Clear all counters */
  342. for (i = 0; i <= stat_size; i++)
  343. readl(&regs->stat[i]);
  344. /* Setup RxBD space */
  345. memset(priv->rx_bd, 0, RX_BUF * sizeof(struct emac_bd));
  346. for (i = 0; i < RX_BUF; i++) {
  347. priv->rx_bd[i].status = 0xF0000000;
  348. priv->rx_bd[i].addr =
  349. ((u32)(priv->rxbuffers) +
  350. (i * PKTSIZE_ALIGN));
  351. }
  352. /* WRAP bit to last BD */
  353. priv->rx_bd[--i].addr |= ZYNQ_GEM_RXBUF_WRAP_MASK;
  354. /* Write RxBDs to IP */
  355. writel((u32)priv->rx_bd, &regs->rxqbase);
  356. /* Setup for DMA Configuration register */
  357. writel(ZYNQ_GEM_DMACR_INIT, &regs->dmacr);
  358. /* Setup for Network Control register, MDIO, Rx and Tx enable */
  359. setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_MDEN_MASK);
  360. priv->init++;
  361. }
  362. //debug("phy detection.\n");
  363. //phy_detection(dev);
  364. //phy_rst(dev);
  365. //phy_negotiat(dev);
  366. if(net_base_addr==0xe000b000)
  367. {
  368. priv->phyaddr=0;
  369. //change to page 0
  370. phyread(dev, priv->phyaddr, 22, &PhyReg);
  371. PhyReg = PhyReg & 0xfffe;
  372. phywrite(dev, priv->phyaddr, 22, PhyReg);
  373. phyread(dev, priv->phyaddr, 20, &PhyReg);
  374. PhyReg = PhyReg | 0x82;
  375. phywrite(dev, priv->phyaddr, 20, PhyReg);
  376. /* reset phy */
  377. phyread(dev, priv->phyaddr, 0, &PhyReg);
  378. PhyReg |= 0x8000;
  379. phywrite(dev, priv->phyaddr, 0, PhyReg);
  380. for(i=0;i<1000000000;i++); //Delay
  381. phyread(dev, priv->phyaddr, 0, &PhyReg);
  382. PhyReg |= 0x1000;
  383. PhyReg |= 0x0200;
  384. PhyReg &= 0xFBFF;
  385. phywrite(dev, priv->phyaddr, 0, PhyReg);
  386. phyread(dev, priv->phyaddr, 1, &PhyReg);
  387. while ( !(PhyReg & 0x0020) )
  388. {
  389. phyread(dev, priv->phyaddr, 1, &PhyReg);
  390. }
  391. printf("GEM0 autonegotiation complete.\n");
  392. }
  393. else
  394. {
  395. #if 1
  396. priv->phyaddr=1;
  397. phyread(dev, priv->phyaddr, 0, &PhyReg);
  398. PhyReg |= 0x1000;
  399. PhyReg |= 0x0200;
  400. PhyReg &= 0xFBFF;
  401. phywrite(dev, priv->phyaddr, 0, PhyReg);
  402. phyread(dev, priv->phyaddr, 1, &PhyReg);
  403. while ( !(PhyReg & 0x0020) )
  404. {
  405. phyread(dev, priv->phyaddr, 1, &PhyReg);
  406. }
  407. printf("GEM1 autonegotiation complete.\n");
  408. #endif
  409. }
  410. puts("GEM link speed is 1000Mbps\n");
  411. writel(ZYNQ_GEM_NWCFG_INIT | ZYNQ_GEM_NWCFG_SPEED1000, &regs->nwcfg);
  412. setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_RXEN_MASK |
  413. ZYNQ_GEM_NWCTRL_TXEN_MASK);
  414. return 0;
  415. }
  416. static int zynq_gem_send(struct eth_device *dev, void *ptr, int len)
  417. {
  418. u32 addr, size;
  419. struct zynq_gem_priv *priv = dev->priv;
  420. struct zynq_gem_regs *regs = (struct zynq_gem_regs *)dev->iobase;
  421. /* setup BD */
  422. writel((u32)priv->tx_bd, &regs->txqbase);
  423. /* Setup Tx BD */
  424. memset(priv->tx_bd, 0, sizeof(struct emac_bd));
  425. priv->tx_bd->addr = (u32)ptr;
  426. priv->tx_bd->status = (len & ZYNQ_GEM_TXBUF_FRMLEN_MASK) |
  427. ZYNQ_GEM_TXBUF_LAST_MASK;
  428. addr = (u32) ptr;
  429. addr &= ~(ARCH_DMA_MINALIGN - 1);
  430. size = roundup(len, ARCH_DMA_MINALIGN);
  431. flush_dcache_range(addr, addr + size);
  432. barrier();
  433. /* Start transmit */
  434. setbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_STARTTX_MASK);
  435. /* Read TX BD status */
  436. if (priv->tx_bd->status & ZYNQ_GEM_TXBUF_UNDERRUN)
  437. printf("TX underrun\n");
  438. if (priv->tx_bd->status & ZYNQ_GEM_TXBUF_EXHAUSTED)
  439. printf("TX buffers exhausted in mid frame\n");
  440. return 0;
  441. }
  442. /* Do not check frame_recd flag in rx_status register 0x20 - just poll BD */
  443. static int zynq_gem_recv(struct eth_device *dev)
  444. {
  445. int frame_len;
  446. struct zynq_gem_priv *priv = dev->priv;
  447. struct emac_bd *current_bd = &priv->rx_bd[priv->rxbd_current];
  448. struct emac_bd *first_bd;
  449. if (!(current_bd->addr & ZYNQ_GEM_RXBUF_NEW_MASK))
  450. return 0;
  451. if (!(current_bd->status &
  452. (ZYNQ_GEM_RXBUF_SOF_MASK | ZYNQ_GEM_RXBUF_EOF_MASK))) {
  453. printf("GEM: SOF or EOF not set for last buffer received!\n");
  454. return 0;
  455. }
  456. frame_len = current_bd->status & ZYNQ_GEM_RXBUF_LEN_MASK;
  457. if (frame_len) {
  458. u32 addr = current_bd->addr & ZYNQ_GEM_RXBUF_ADD_MASK;
  459. addr &= ~(ARCH_DMA_MINALIGN - 1);
  460. u32 size = roundup(frame_len, ARCH_DMA_MINALIGN);
  461. invalidate_dcache_range(addr, addr + size);
  462. NetReceive((u8 *)addr, frame_len);
  463. if (current_bd->status & ZYNQ_GEM_RXBUF_SOF_MASK)
  464. priv->rx_first_buf = priv->rxbd_current;
  465. else {
  466. current_bd->addr &= ~ZYNQ_GEM_RXBUF_NEW_MASK;
  467. current_bd->status = 0xF0000000; /* FIXME */
  468. }
  469. if (current_bd->status & ZYNQ_GEM_RXBUF_EOF_MASK) {
  470. first_bd = &priv->rx_bd[priv->rx_first_buf];
  471. first_bd->addr &= ~ZYNQ_GEM_RXBUF_NEW_MASK;
  472. first_bd->status = 0xF0000000;
  473. }
  474. if ((++priv->rxbd_current) >= RX_BUF)
  475. priv->rxbd_current = 0;
  476. }
  477. return frame_len;
  478. }
  479. static void zynq_gem_halt(struct eth_device *dev)
  480. {
  481. struct zynq_gem_regs *regs = (struct zynq_gem_regs *)dev->iobase;
  482. clrsetbits_le32(&regs->nwctrl, ZYNQ_GEM_NWCTRL_RXEN_MASK |
  483. ZYNQ_GEM_NWCTRL_TXEN_MASK, 0);
  484. }
  485. static int zynq_gem_miiphyread(const char *devname, uchar addr,
  486. uchar reg, ushort *val)
  487. {
  488. struct eth_device *dev = eth_get_dev();
  489. int ret;
  490. ret = phyread(dev, addr, reg, val);
  491. debug("%s 0x%x, 0x%x, 0x%x\n", __func__, addr, reg, *val);
  492. return ret;
  493. }
  494. static int zynq_gem_miiphy_write(const char *devname, uchar addr,
  495. uchar reg, ushort val)
  496. {
  497. struct eth_device *dev = eth_get_dev();
  498. debug("%s 0x%x, 0x%x, 0x%x\n", __func__, addr, reg, val);
  499. return phywrite(dev, addr, reg, val);
  500. }
  501. int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio)
  502. {
  503. struct eth_device *dev;
  504. struct zynq_gem_priv *priv;
  505. void *bd_space;
  506. printf("zynq_gem_initialize: baseAddr = 0x%x, phyAddr = 0x%x.\n",base_addr,phy_addr);
  507. net_base_addr=base_addr;
  508. dev = calloc(1, sizeof(*dev));
  509. if (dev == NULL)
  510. return -1;
  511. dev->priv = calloc(1, sizeof(struct zynq_gem_priv));
  512. if (dev->priv == NULL) {
  513. free(dev);
  514. return -1;
  515. }
  516. priv = dev->priv;
  517. /* Align rxbuffers to ARCH_DMA_MINALIGN */
  518. priv->rxbuffers = memalign(ARCH_DMA_MINALIGN, RX_BUF * PKTSIZE_ALIGN);
  519. memset(priv->rxbuffers, 0, RX_BUF * PKTSIZE_ALIGN);
  520. /* Align bd_space to 1MB */
  521. bd_space = memalign(1 << MMU_SECTION_SHIFT, BD_SPACE);
  522. mmu_set_region_dcache_behaviour((u32)bd_space, BD_SPACE, DCACHE_OFF);
  523. /* Initialize the bd spaces for tx and rx bd's */
  524. priv->tx_bd = (struct emac_bd *)bd_space;
  525. priv->rx_bd = (struct emac_bd *)((u32)bd_space + BD_SEPRN_SPACE);
  526. priv->phyaddr = phy_addr;
  527. priv->emio = emio;
  528. sprintf(dev->name, "Gem.%x_%x", base_addr,phy_addr);
  529. dev->iobase = base_addr;
  530. dev->init = zynq_gem_init;
  531. dev->halt = zynq_gem_halt;
  532. dev->send = zynq_gem_send;
  533. dev->recv = zynq_gem_recv;
  534. dev->write_hwaddr = zynq_gem_setup_mac;
  535. eth_register(dev);
  536. #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
  537. debug("zynq_gem MII init.\n");
  538. miiphy_register(dev->name, zynq_gem_miiphyread, zynq_gem_miiphy_write);
  539. priv->bus = miiphy_get_dev_by_name(dev->name);
  540. #endif
  541. zynq_gem_init(dev,bis);
  542. return 1;
  543. }

 

 

3、devicetree设置

devicetree中需要设置ETH1节点下的PHY配置信息,如下:

可以通过修改产生devicetree的相应的配置文件得到

完整的devicetree如下

  1. /dts-v1/;
  2. / {
  3. #address-cells = <0x1>;
  4. #size-cells = <0x1>;
  5. compatible = "xlnx,zynq-7000";
  6. cpus {
  7. #address-cells = <0x1>;
  8. #size-cells = <0x0>;
  9. cpu@0 {
  10. compatible = "arm,cortex-a9";
  11. device_type = "cpu";
  12. reg = <0x0>;
  13. clocks = <0x1 0x3>;
  14. clock-latency = <0x3e8>;
  15. cpu0-supply = <0x2>;
  16. operating-points = <0xa4cb8 0xf4240 0x5265c 0xf4240>;
  17. };
  18. cpu@1 {
  19. compatible = "arm,cortex-a9";
  20. device_type = "cpu";
  21. reg = <0x1>;
  22. clocks = <0x1 0x3>;
  23. };
  24. };
  25. fpga-full {
  26. compatible = "fpga-region";
  27. fpga-mgr = <0x3>;
  28. #address-cells = <0x1>;
  29. #size-cells = <0x1>;
  30. ranges;
  31. };
  32. pmu@f8891000 {
  33. compatible = "arm,cortex-a9-pmu";
  34. interrupts = <0x0 0x5 0x4 0x0 0x6 0x4>;
  35. interrupt-parent = <0x4>;
  36. reg = <0xf8891000 0x1000 0xf8893000 0x1000>;
  37. };
  38. fixedregulator {
  39. compatible = "regulator-fixed";
  40. regulator-name = "VCCPINT";
  41. regulator-min-microvolt = <0xf4240>;
  42. regulator-max-microvolt = <0xf4240>;
  43. regulator-boot-on;
  44. regulator-always-on;
  45. linux,phandle = <0x2>;
  46. phandle = <0x2>;
  47. };
  48. amba {
  49. u-boot,dm-pre-reloc;
  50. compatible = "simple-bus";
  51. #address-cells = <0x1>;
  52. #size-cells = <0x1>;
  53. interrupt-parent = <0x4>;
  54. ranges;
  55. adc@f8007100 {
  56. compatible = "xlnx,zynq-xadc-1.00.a";
  57. reg = <0xf8007100 0x20>;
  58. interrupts = <0x0 0x7 0x4>;
  59. interrupt-parent = <0x4>;
  60. clocks = <0x1 0xc>;
  61. };
  62. can@e0008000 {
  63. compatible = "xlnx,zynq-can-1.0";
  64. status = "disabled";
  65. clocks = <0x1 0x13 0x1 0x24>;
  66. clock-names = "can_clk", "pclk";
  67. reg = <0xe0008000 0x1000>;
  68. interrupts = <0x0 0x1c 0x4>;
  69. interrupt-parent = <0x4>;
  70. tx-fifo-depth = <0x40>;
  71. rx-fifo-depth = <0x40>;
  72. };
  73. can@e0009000 {
  74. compatible = "xlnx,zynq-can-1.0";
  75. status = "disabled";
  76. clocks = <0x1 0x14 0x1 0x25>;
  77. clock-names = "can_clk", "pclk";
  78. reg = <0xe0009000 0x1000>;
  79. interrupts = <0x0 0x33 0x4>;
  80. interrupt-parent = <0x4>;
  81. tx-fifo-depth = <0x40>;
  82. rx-fifo-depth = <0x40>;
  83. };
  84. gpio@e000a000 {
  85. compatible = "xlnx,zynq-gpio-1.0";
  86. #gpio-cells = <0x2>;
  87. clocks = <0x1 0x2a>;
  88. gpio-controller;
  89. interrupt-controller;
  90. #interrupt-cells = <0x2>;
  91. interrupt-parent = <0x4>;
  92. interrupts = <0x0 0x14 0x4>;
  93. reg = <0xe000a000 0x1000>;
  94. emio-gpio-width = <0x40>;
  95. gpio-mask-high = <0x0>;
  96. gpio-mask-low = <0x5600>;
  97. };
  98. i2c@e0004000 {
  99. compatible = "cdns,i2c-r1p10";
  100. status = "okay";
  101. clocks = <0x1 0x26>;
  102. interrupt-parent = <0x4>;
  103. interrupts = <0x0 0x19 0x4>;
  104. reg = <0xe0004000 0x1000>;
  105. #address-cells = <0x1>;
  106. #size-cells = <0x0>;
  107. clock-frequency = <0x61a80>;
  108. };
  109. i2c@e0005000 {
  110. compatible = "cdns,i2c-r1p10";
  111. status = "okay";
  112. clocks = <0x1 0x27>;
  113. interrupt-parent = <0x4>;
  114. interrupts = <0x0 0x30 0x4>;
  115. reg = <0xe0005000 0x1000>;
  116. #address-cells = <0x1>;
  117. #size-cells = <0x0>;
  118. clock-frequency = <0x61a80>;
  119. };
  120. interrupt-controller@f8f01000 {
  121. compatible = "arm,cortex-a9-gic";
  122. #interrupt-cells = <0x3>;
  123. interrupt-controller;
  124. reg = <0xf8f01000 0x1000 0xf8f00100 0x100>;
  125. num_cpus = <0x2>;
  126. num_interrupts = <0x60>;
  127. linux,phandle = <0x4>;
  128. phandle = <0x4>;
  129. };
  130. cache-controller@f8f02000 {
  131. compatible = "arm,pl310-cache";
  132. reg = <0xf8f02000 0x1000>;
  133. interrupts = <0x0 0x2 0x4>;
  134. arm,data-latency = <0x3 0x2 0x2>;
  135. arm,tag-latency = <0x2 0x2 0x2>;
  136. cache-unified;
  137. cache-level = <0x2>;
  138. };
  139. memory-controller@f8006000 {
  140. compatible = "xlnx,zynq-ddrc-a05";
  141. reg = <0xf8006000 0x1000>;
  142. };
  143. ocmc@f800c000 {
  144. compatible = "xlnx,zynq-ocmc-1.0";
  145. interrupt-parent = <0x4>;
  146. interrupts = <0x0 0x3 0x4>;
  147. reg = <0xf800c000 0x1000>;
  148. };
  149. serial@e0000000 {
  150. compatible = "xlnx,xuartps", "cdns,uart-r1p8";
  151. status = "okay";
  152. clocks = <0x1 0x17 0x1 0x28>;
  153. clock-names = "uart_clk", "pclk";
  154. reg = <0xe0000000 0x1000>;
  155. interrupts = <0x0 0x1b 0x4>;
  156. device_type = "serial";
  157. port-number = <0x0>;
  158. };
  159. serial@e0001000 {
  160. compatible = "xlnx,xuartps", "cdns,uart-r1p8";
  161. status = "okay";
  162. clocks = <0x1 0x18 0x1 0x29>;
  163. clock-names = "uart_clk", "pclk";
  164. reg = <0xe0001000 0x1000>;
  165. interrupts = <0x0 0x32 0x4>;
  166. device_type = "serial";
  167. port-number = <0x1>;
  168. };
  169. spi@e0006000 {
  170. compatible = "xlnx,zynq-spi-r1p6";
  171. reg = <0xe0006000 0x1000>;
  172. status = "disabled";
  173. interrupt-parent = <0x4>;
  174. interrupts = <0x0 0x1a 0x4>;
  175. clocks = <0x1 0x19 0x1 0x22>;
  176. clock-names = "ref_clk", "pclk";
  177. #address-cells = <0x1>;
  178. #size-cells = <0x0>;
  179. };
  180. spi@e0007000 {
  181. compatible = "xlnx,zynq-spi-r1p6";
  182. reg = <0xe0007000 0x1000>;
  183. status = "disabled";
  184. interrupt-parent = <0x4>;
  185. interrupts = <0x0 0x31 0x4>;
  186. clocks = <0x1 0x1a 0x1 0x23>;
  187. clock-names = "ref_clk", "pclk";
  188. #address-cells = <0x1>;
  189. #size-cells = <0x0>;
  190. };
  191. spi@e000d000 {
  192. clock-names = "ref_clk", "pclk";
  193. clocks = <0x1 0xa 0x1 0x2b>;
  194. compatible = "xlnx,zynq-qspi-1.0";
  195. status = "okay";
  196. interrupt-parent = <0x4>;
  197. interrupts = <0x0 0x13 0x4>;
  198. reg = <0xe000d000 0x1000>;
  199. #address-cells = <0x1>;
  200. #size-cells = <0x0>;
  201. is-dual = <0x1>;
  202. num-cs = <0x1>;
  203. };
  204. memory-controller@e000e000 {
  205. #address-cells = <0x1>;
  206. #size-cells = <0x1>;
  207. status = "disabled";
  208. clock-names = "memclk", "aclk";
  209. clocks = <0x1 0xb 0x1 0x2c>;
  210. compatible = "arm,pl353-smc-r2p1";
  211. interrupt-parent = <0x4>;
  212. interrupts = <0x0 0x12 0x4>;
  213. ranges;
  214. reg = <0xe000e000 0x1000>;
  215. flash@e1000000 {
  216. status = "disabled";
  217. compatible = "arm,pl353-nand-r2p1";
  218. reg = <0xe1000000 0x1000000>;
  219. #address-cells = <0x1>;
  220. #size-cells = <0x1>;
  221. };
  222. flash@e2000000 {
  223. status = "disabled";
  224. compatible = "cfi-flash";
  225. reg = <0xe2000000 0x2000000>;
  226. #address-cells = <0x1>;
  227. #size-cells = <0x1>;
  228. };
  229. };
  230. ethernet@e000b000 {
  231. compatible = "cdns,zynq-gem", "cdns,gem";
  232. reg = <0xe000b000 0x1000>;
  233. status = "okay";
  234. interrupts = <0x0 0x16 0x4>;
  235. clocks = <0x1 0x1e 0x1 0x1e 0x1 0xd>;
  236. clock-names = "pclk", "hclk", "tx_clk";
  237. #address-cells = <0x1>;
  238. #size-cells = <0x0>;
  239. phy-mode = "rgmii-id";
  240. xlnx,ptp-enet-clock = <0x6b49d20>;
  241. };
  242. ethernet@e000c000 {
  243. compatible = "cdns,zynq-gem", "cdns,gem";
  244. reg = <0xe000c000 0x1000>;
  245. status = "okay";
  246. interrupts = <0x0 0x2d 0x4>;
  247. clocks = <0x1 0x1f 0x1 0x1f 0x1 0xe>;
  248. clock-names = "pclk", "hclk", "tx_clk";
  249. #address-cells = <0x1>;
  250. #size-cells = <0x0>;
  251. phy-mode = "gmii";
  252. xlnx,ptp-enet-clock = <0x6b49d20>;
  253. phy-handle = <0x5>;
  254. phy@1 {
  255. compatible = "Xilinx PCS/PMA PHY";
  256. device_type = "ethernet-phy";
  257. xlnx,phy-type = <0x5>;
  258. reg = <0x1>;
  259. linux,phandle = <0x5>;
  260. phandle = <0x5>;
  261. };
  262. };
  263. sdhci@e0100000 {
  264. compatible = "arasan,sdhci-8.9a";
  265. status = "disabled";
  266. clock-names = "clk_xin", "clk_ahb";
  267. clocks = <0x1 0x15 0x1 0x20>;
  268. interrupt-parent = <0x4>;
  269. interrupts = <0x0 0x18 0x4>;
  270. reg = <0xe0100000 0x1000>;
  271. };
  272. sdhci@e0101000 {
  273. compatible = "arasan,sdhci-8.9a";
  274. status = "disabled";
  275. clock-names = "clk_xin", "clk_ahb";
  276. clocks = <0x1 0x16 0x1 0x21>;
  277. interrupt-parent = <0x4>;
  278. interrupts = <0x0 0x2f 0x4>;
  279. reg = <0xe0101000 0x1000>;
  280. };
  281. slcr@f8000000 {
  282. #address-cells = <0x1>;
  283. #size-cells = <0x1>;
  284. compatible = "xlnx,zynq-slcr", "syscon", "simple-mfd";
  285. reg = <0xf8000000 0x1000>;
  286. ranges;
  287. linux,phandle = <0x6>;
  288. phandle = <0x6>;
  289. clkc@100 {
  290. #clock-cells = <0x1>;
  291. compatible = "xlnx,ps7-clkc";
  292. fclk-enable = <0x1>;
  293. clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x", "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x", "dci", "lqspi", "smc", "pcap", "gem0", "gem1", "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1", "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1", "dma", "usb0_aper", "usb1_aper", "gem0_aper", "gem1_aper", "sdio0_aper", "sdio1_aper", "spi0_aper", "spi1_aper", "can0_aper", "can1_aper", "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper", "gpio_aper", "lqspi_aper", "smc_aper", "swdt", "dbg_trc", "dbg_apb";
  294. reg = <0x100 0x100>;
  295. ps-clk-frequency = <0x2faf080>;
  296. linux,phandle = <0x1>;
  297. phandle = <0x1>;
  298. };
  299. rstc@200 {
  300. compatible = "xlnx,zynq-reset";
  301. reg = <0x200 0x48>;
  302. #reset-cells = <0x1>;
  303. syscon = <0x6>;
  304. };
  305. pinctrl@700 {
  306. compatible = "xlnx,pinctrl-zynq";
  307. reg = <0x700 0x200>;
  308. syscon = <0x6>;
  309. };
  310. };
  311. dmac@f8003000 {
  312. compatible = "arm,pl330", "arm,primecell";
  313. reg = <0xf8003000 0x1000>;
  314. interrupt-parent = <0x4>;
  315. interrupt-names = "abort", "dma0", "dma1", "dma2", "dma3", "dma4", "dma5", "dma6", "dma7";
  316. interrupts = <0x0 0xd 0x4 0x0 0xe 0x4 0x0 0xf 0x4 0x0 0x10 0x4 0x0 0x11 0x4 0x0 0x28 0x4 0x0 0x29 0x4 0x0 0x2a 0x4 0x0 0x2b 0x4>;
  317. #dma-cells = <0x1>;
  318. #dma-channels = <0x8>;
  319. #dma-requests = <0x4>;
  320. clocks = <0x1 0x1b>;
  321. clock-names = "apb_pclk";
  322. };
  323. devcfg@f8007000 {
  324. compatible = "xlnx,zynq-devcfg-1.0";
  325. interrupt-parent = <0x4>;
  326. interrupts = <0x0 0x8 0x4>;
  327. reg = <0xf8007000 0x100>;
  328. clocks = <0x1 0xc 0x1 0xf 0x1 0x10 0x1 0x11 0x1 0x12>;
  329. clock-names = "ref_clk", "fclk0", "fclk1", "fclk2", "fclk3";
  330. syscon = <0x6>;
  331. linux,phandle = <0x3>;
  332. phandle = <0x3>;
  333. };
  334. efuse@f800d000 {
  335. compatible = "xlnx,zynq-efuse";
  336. reg = <0xf800d000 0x20>;
  337. };
  338. timer@f8f00200 {
  339. compatible = "arm,cortex-a9-global-timer";
  340. reg = <0xf8f00200 0x20>;
  341. interrupts = <0x1 0xb 0x301>;
  342. interrupt-parent = <0x4>;
  343. clocks = <0x1 0x4>;
  344. };
  345. timer@f8001000 {
  346. interrupt-parent = <0x4>;
  347. interrupts = <0x0 0xa 0x4 0x0 0xb 0x4 0x0 0xc 0x4>;
  348. compatible = "cdns,ttc";
  349. clocks = <0x1 0x6>;
  350. reg = <0xf8001000 0x1000>;
  351. };
  352. timer@f8002000 {
  353. interrupt-parent = <0x4>;
  354. interrupts = <0x0 0x25 0x4 0x0 0x26 0x4 0x0 0x27 0x4>;
  355. compatible = "cdns,ttc";
  356. clocks = <0x1 0x6>;
  357. reg = <0xf8002000 0x1000>;
  358. };
  359. timer@f8f00600 {
  360. interrupt-parent = <0x4>;
  361. interrupts = <0x1 0xd 0x301>;
  362. compatible = "arm,cortex-a9-twd-timer";
  363. reg = <0xf8f00600 0x20>;
  364. clocks = <0x1 0x4>;
  365. };
  366. usb@e0002000 {
  367. compatible = "xlnx,zynq-usb-2.20a", "chipidea,usb2";
  368. status = "disabled";
  369. clocks = <0x1 0x1c>;
  370. interrupt-parent = <0x4>;
  371. interrupts = <0x0 0x15 0x4>;
  372. reg = <0xe0002000 0x1000>;
  373. phy_type = "ulpi";
  374. };
  375. usb@e0003000 {
  376. compatible = "xlnx,zynq-usb-2.20a", "chipidea,usb2";
  377. status = "disabled";
  378. clocks = <0x1 0x1d>;
  379. interrupt-parent = <0x4>;
  380. interrupts = <0x0 0x2c 0x4>;
  381. reg = <0xe0003000 0x1000>;
  382. phy_type = "ulpi";
  383. };
  384. watchdog@f8005000 {
  385. clocks = <0x1 0x2d>;
  386. compatible = "cdns,wdt-r1p2";
  387. interrupt-parent = <0x4>;
  388. interrupts = <0x0 0x9 0x1>;
  389. reg = <0xf8005000 0x1000>;
  390. timeout-sec = <0xa>;
  391. };
  392. };
  393. amba_pl {
  394. #address-cells = <0x1>;
  395. #size-cells = <0x1>;
  396. compatible = "simple-bus";
  397. ranges;
  398. gpio@41200000 {
  399. #gpio-cells = <0x2>;
  400. compatible = "xlnx,xps-gpio-1.00.a";
  401. gpio-controller;
  402. reg = <0x41200000 0x10000>;
  403. xlnx,all-inputs = <0x0>;
  404. xlnx,all-inputs-2 = <0x0>;
  405. xlnx,all-outputs = <0x1>;
  406. xlnx,all-outputs-2 = <0x0>;
  407. xlnx,dout-default = <0x2>;
  408. xlnx,dout-default-2 = <0x0>;
  409. xlnx,gpio-width = <0x3>;
  410. xlnx,gpio2-width = <0x20>;
  411. xlnx,interrupt-present = <0x0>;
  412. xlnx,is-dual = <0x0>;
  413. xlnx,tri-default = <0xffffffff>;
  414. xlnx,tri-default-2 = <0xffffffff>;
  415. };
  416. gpio@41210000 {
  417. #gpio-cells = <0x2>;
  418. compatible = "xlnx,xps-gpio-1.00.a";
  419. gpio-controller;
  420. reg = <0x41210000 0x10000>;
  421. xlnx,all-inputs = <0x0>;
  422. xlnx,all-inputs-2 = <0x0>;
  423. xlnx,all-outputs = <0x1>;
  424. xlnx,all-outputs-2 = <0x0>;
  425. xlnx,dout-default = <0x0>;
  426. xlnx,dout-default-2 = <0x0>;
  427. xlnx,gpio-width = <0xc>;
  428. xlnx,gpio2-width = <0x20>;
  429. xlnx,interrupt-present = <0x0>;
  430. xlnx,is-dual = <0x0>;
  431. xlnx,tri-default = <0xffffffff>;
  432. xlnx,tri-default-2 = <0xffffffff>;
  433. };
  434. gpio@41220000 {
  435. #gpio-cells = <0x2>;
  436. compatible = "xlnx,xps-gpio-1.00.a";
  437. gpio-controller;
  438. reg = <0x41220000 0x10000>;
  439. xlnx,all-inputs = <0x0>;
  440. xlnx,all-inputs-2 = <0x0>;
  441. xlnx,all-outputs = <0x1>;
  442. xlnx,all-outputs-2 = <0x0>;
  443. xlnx,dout-default = <0xaa>;
  444. xlnx,dout-default-2 = <0x0>;
  445. xlnx,gpio-width = <0x8>;
  446. xlnx,gpio2-width = <0x20>;
  447. xlnx,interrupt-present = <0x0>;
  448. xlnx,is-dual = <0x0>;
  449. xlnx,tri-default = <0xffffffff>;
  450. xlnx,tri-default-2 = <0xffffffff>;
  451. };
  452. gpio@41230000 {
  453. #gpio-cells = <0x2>;
  454. compatible = "xlnx,xps-gpio-1.00.a";
  455. gpio-controller;
  456. reg = <0x41230000 0x10000>;
  457. xlnx,all-inputs = <0x1>;
  458. xlnx,all-inputs-2 = <0x0>;
  459. xlnx,all-outputs = <0x0>;
  460. xlnx,all-outputs-2 = <0x0>;
  461. xlnx,dout-default = <0x0>;
  462. xlnx,dout-default-2 = <0x0>;
  463. xlnx,gpio-width = <0x6>;
  464. xlnx,gpio2-width = <0x20>;
  465. xlnx,interrupt-present = <0x0>;
  466. xlnx,is-dual = <0x0>;
  467. xlnx,tri-default = <0xffffffff>;
  468. xlnx,tri-default-2 = <0xffffffff>;
  469. };
  470. gpio@41240000 {
  471. #gpio-cells = <0x2>;
  472. compatible = "xlnx,xps-gpio-1.00.a";
  473. gpio-controller;
  474. reg = <0x41240000 0x10000>;
  475. xlnx,all-inputs = <0x1>;
  476. xlnx,all-inputs-2 = <0x0>;
  477. xlnx,all-outputs = <0x0>;
  478. xlnx,all-outputs-2 = <0x0>;
  479. xlnx,dout-default = <0x0>;
  480. xlnx,dout-default-2 = <0x0>;
  481. xlnx,gpio-width = <0x6>;
  482. xlnx,gpio2-width = <0x20>;
  483. xlnx,interrupt-present = <0x0>;
  484. xlnx,is-dual = <0x0>;
  485. xlnx,tri-default = <0xffffffff>;
  486. xlnx,tri-default-2 = <0xffffffff>;
  487. };
  488. gpio@41250000 {
  489. #gpio-cells = <0x2>;
  490. compatible = "xlnx,xps-gpio-1.00.a";
  491. gpio-controller;
  492. reg = <0x41250000 0x10000>;
  493. xlnx,all-inputs = <0x1>;
  494. xlnx,all-inputs-2 = <0x0>;
  495. xlnx,all-outputs = <0x0>;
  496. xlnx,all-outputs-2 = <0x0>;
  497. xlnx,dout-default = <0x0>;
  498. xlnx,dout-default-2 = <0x0>;
  499. xlnx,gpio-width = <0x4>;
  500. xlnx,gpio2-width = <0x20>;
  501. xlnx,interrupt-present = <0x0>;
  502. xlnx,is-dual = <0x0>;
  503. xlnx,tri-default = <0xffffffff>;
  504. xlnx,tri-default-2 = <0xffffffff>;
  505. };
  506. gpio@41260000 {
  507. #gpio-cells = <0x2>;
  508. compatible = "xlnx,xps-gpio-1.00.a";
  509. gpio-controller;
  510. reg = <0x41260000 0x10000>;
  511. xlnx,all-inputs = <0x1>;
  512. xlnx,all-inputs-2 = <0x0>;
  513. xlnx,all-outputs = <0x0>;
  514. xlnx,all-outputs-2 = <0x0>;
  515. xlnx,dout-default = <0x0>;
  516. xlnx,dout-default-2 = <0x0>;
  517. xlnx,gpio-width = <0x2>;
  518. xlnx,gpio2-width = <0x20>;
  519. xlnx,interrupt-present = <0x0>;
  520. xlnx,is-dual = <0x0>;
  521. xlnx,tri-default = <0xffffffff>;
  522. xlnx,tri-default-2 = <0xffffffff>;
  523. };
  524. gpio@41270000 {
  525. #gpio-cells = <0x2>;
  526. compatible = "xlnx,xps-gpio-1.00.a";
  527. gpio-controller;
  528. reg = <0x41270000 0x10000>;
  529. xlnx,all-inputs = <0x0>;
  530. xlnx,all-inputs-2 = <0x0>;
  531. xlnx,all-outputs = <0x1>;
  532. xlnx,all-outputs-2 = <0x0>;
  533. xlnx,dout-default = <0x0>;
  534. xlnx,dout-default-2 = <0x0>;
  535. xlnx,gpio-width = <0x2>;
  536. xlnx,gpio2-width = <0x20>;
  537. xlnx,interrupt-present = <0x0>;
  538. xlnx,is-dual = <0x0>;
  539. xlnx,tri-default = <0xffffffff>;
  540. xlnx,tri-default-2 = <0xffffffff>;
  541. };
  542. gpio@41280000 {
  543. #gpio-cells = <0x2>;
  544. compatible = "xlnx,xps-gpio-1.00.a";
  545. gpio-controller;
  546. reg = <0x41280000 0x10000>;
  547. xlnx,all-inputs = <0x0>;
  548. xlnx,all-inputs-2 = <0x0>;
  549. xlnx,all-outputs = <0x1>;
  550. xlnx,all-outputs-2 = <0x0>;
  551. xlnx,dout-default = <0x1>;
  552. xlnx,dout-default-2 = <0x0>;
  553. xlnx,gpio-width = <0x1>;
  554. xlnx,gpio2-width = <0x20>;
  555. xlnx,interrupt-present = <0x0>;
  556. xlnx,is-dual = <0x0>;
  557. xlnx,tri-default = <0xffffffff>;
  558. xlnx,tri-default-2 = <0xffffffff>;
  559. };
  560. axi_pwm@43c10000 {
  561. compatible = "xlnx,axi-pwm-1.0";
  562. reg = <0x43c10000 0x10000>;
  563. xlnx,s00-axi-addr-width = <0x6>;
  564. xlnx,s00-axi-data-width = <0x20>;
  565. };
  566. xadc_wiz@43c00000 {
  567. clock-names = "ref_clk";
  568. clocks = <0x1 0x0>;
  569. compatible = "xlnx,axi-xadc-1.00.a";
  570. reg = <0x43c00000 0x10000>;
  571. xlnx,alarm-limit-r0 = <0xb5ed>;
  572. xlnx,alarm-limit-r1 = <0x57e4>;
  573. xlnx,alarm-limit-r10 = <0x5555>;
  574. xlnx,alarm-limit-r11 = <0x5111>;
  575. xlnx,alarm-limit-r12 = <0x9999>;
  576. xlnx,alarm-limit-r13 = <0x91eb>;
  577. xlnx,alarm-limit-r14 = <0x6aaa>;
  578. xlnx,alarm-limit-r15 = <0x6666>;
  579. xlnx,alarm-limit-r2 = <0xa147>;
  580. xlnx,alarm-limit-r3 = <0xca33>;
  581. xlnx,alarm-limit-r4 = <0xa93a>;
  582. xlnx,alarm-limit-r5 = <0x52c6>;
  583. xlnx,alarm-limit-r6 = <0x9555>;
  584. xlnx,alarm-limit-r7 = <0xae4e>;
  585. xlnx,alarm-limit-r8 = <0x5999>;
  586. xlnx,alarm-limit-r9 = <0x5111>;
  587. xlnx,configuration-r0 = <0x0>;
  588. xlnx,configuration-r1 = <0x2100>;
  589. xlnx,configuration-r2 = <0x400>;
  590. xlnx,dclk-frequency = <0x64>;
  591. xlnx,external-mux = "none";
  592. xlnx,external-mux-channel = "VP_VN";
  593. xlnx,external-muxaddr-enable = <0x0>;
  594. xlnx,fifo-depth = <0x7>;
  595. xlnx,has-axi = <0x1>;
  596. xlnx,has-axi4stream = <0x0>;
  597. xlnx,has-busy = <0x1>;
  598. xlnx,has-channel = <0x1>;
  599. xlnx,has-convst = <0x0>;
  600. xlnx,has-convstclk = <0x0>;
  601. xlnx,has-dclk = <0x1>;
  602. xlnx,has-drp = <0x0>;
  603. xlnx,has-eoc = <0x1>;
  604. xlnx,has-eos = <0x1>;
  605. xlnx,has-external-mux = <0x0>;
  606. xlnx,has-jtagbusy = <0x0>;
  607. xlnx,has-jtaglocked = <0x0>;
  608. xlnx,has-jtagmodified = <0x0>;
  609. xlnx,has-ot-alarm = <0x1>;
  610. xlnx,has-reset = <0x0>;
  611. xlnx,has-temp-bus = <0x0>;
  612. xlnx,has-user-temp-alarm = <0x1>;
  613. xlnx,has-vbram-alarm = <0x0>;
  614. xlnx,has-vccaux-alarm = <0x1>;
  615. xlnx,has-vccddro-alarm = <0x1>;
  616. xlnx,has-vccint-alarm = <0x1>;
  617. xlnx,has-vccpaux-alarm = <0x1>;
  618. xlnx,has-vccpint-alarm = <0x1>;
  619. xlnx,has-vn = <0x1>;
  620. xlnx,has-vp = <0x1>;
  621. xlnx,include-intr = <0x1>;
  622. xlnx,sampling-rate = "961538.4615384615";
  623. xlnx,sequence-r0 = <0x77e0>;
  624. xlnx,sequence-r1 = <0x9f77>;
  625. xlnx,sequence-r2 = <0x47e0>;
  626. xlnx,sequence-r3 = <0x9f77>;
  627. xlnx,sequence-r4 = <0x0>;
  628. xlnx,sequence-r5 = <0x0>;
  629. xlnx,sequence-r6 = <0x0>;
  630. xlnx,sequence-r7 = <0x9f77>;
  631. xlnx,sim-file-name = "design";
  632. xlnx,sim-file-rel-path = "./";
  633. xlnx,sim-file-sel = "Default";
  634. xlnx,vaux0 = <0x1>;
  635. xlnx,vaux1 = <0x1>;
  636. xlnx,vaux10 = <0x1>;
  637. xlnx,vaux11 = <0x1>;
  638. xlnx,vaux12 = <0x1>;
  639. xlnx,vaux13 = <0x0>;
  640. xlnx,vaux14 = <0x0>;
  641. xlnx,vaux15 = <0x1>;
  642. xlnx,vaux2 = <0x1>;
  643. xlnx,vaux3 = <0x0>;
  644. xlnx,vaux4 = <0x1>;
  645. xlnx,vaux5 = <0x1>;
  646. xlnx,vaux6 = <0x1>;
  647. xlnx,vaux7 = <0x0>;
  648. xlnx,vaux8 = <0x1>;
  649. xlnx,vaux9 = <0x1>;
  650. };
  651. };
  652. chosen {
  653. bootargs = "earlycon";
  654. stdout-path = "serial0:115200n8";
  655. };
  656. aliases {
  657. ethernet0 = "/amba/ethernet@e000b000";
  658. ethernet1 = "/amba/ethernet@e000c000";
  659. serial0 = "/amba/serial@e0000000";
  660. serial1 = "/amba/serial@e0001000";
  661. spi0 = "/amba/spi@e000d000";
  662. };
  663. memory {
  664. device_type = "memory";
  665. reg = <0x0 0x40000000>;
  666. };
  667. };

 

4、内核配置

内核中需要包含下面两个驱动,一个是网卡驱动,一个是phy驱动

 

5、文件系统设置

文件系统中增加ethtool工具,方便对网卡进行各种配置

下载源码,解压,执行:

再make即可。然后将ethtool拷贝到ramdisk内

 

6、测试

系统启动后会出现错误,提示无法产生时钟,导致速率不对,如下

查阅xilinx论坛,链接见这里 发现需要关闭PCS/PMA的自协商,这时就需要用到ethtool工具了。

然后就可以ping通电脑了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/81740
推荐阅读
相关标签
  

闽ICP备14008679号