32 #define TRACE_LEVEL NIC_TRACE_LEVEL
36 #include "cpg_iobitmask.h"
46 #if defined(__ICCARM__)
49 #pragma data_alignment = 32
50 #pragma location = RZA1_ETH_RAM_SECTION
53 #pragma data_alignment = 32
54 #pragma location = RZA1_ETH_RAM_SECTION
57 #pragma data_alignment = 32
58 #pragma location = RZA1_ETH_RAM_SECTION
61 #pragma data_alignment = 32
62 #pragma location = RZA1_ETH_RAM_SECTION
125 TRACE_INFO(
"Initializing RZ/A1 Ethernet MAC...\r\n");
128 nicDriverInterface = interface;
131 CPG.STBCR7 &= ~CPG_STBCR7_MSTP74;
154 if(interface->phyDriver != NULL)
157 error = interface->phyDriver->init(interface);
159 else if(interface->switchDriver != NULL)
162 error = interface->switchDriver->init(interface);
205 ETHER.MAHR0 = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
206 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
209 ETHER.MALR0 = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
256 #if defined(USE_RSK_RZA1H) || defined(USE_HACHIKO)
258 PORT1.PMCn.BIT.PMCn14 = 1;
259 PORT1.PFCn.BIT.PFCn14 = 1;
260 PORT1.PFCEn.BIT.PFCEn14 = 1;
261 PORT1.PFCAEn.BIT.PFCAEn14 = 0;
262 PORT1.PIPCn.BIT.PIPCn14 = 1;
265 PORT2.PMCn.BIT.PMCn0 = 1;
266 PORT2.PFCn.BIT.PFCn0 = 1;
267 PORT2.PFCEn.BIT.PFCEn0 = 0;
268 PORT2.PFCAEn.BIT.PFCAEn0 = 0;
269 PORT2.PIPCn.BIT.PIPCn0 = 1;
272 PORT2.PMCn.BIT.PMCn1 = 1;
273 PORT2.PFCn.BIT.PFCn1 = 1;
274 PORT2.PFCEn.BIT.PFCEn1 = 0;
275 PORT2.PFCAEn.BIT.PFCAEn1 = 0;
276 PORT2.PIPCn.BIT.PIPCn1 = 1;
279 PORT2.PMCn.BIT.PMCn2 = 1;
280 PORT2.PFCn.BIT.PFCn2 = 1;
281 PORT2.PFCEn.BIT.PFCEn2 = 0;
282 PORT2.PFCAEn.BIT.PFCAEn2 = 0;
283 PORT2.PIPCn.BIT.PIPCn2 = 1;
286 PORT2.PMCn.BIT.PMCn3 = 1;
287 PORT2.PFCn.BIT.PFCn3 = 1;
288 PORT2.PFCEn.BIT.PFCEn3 = 0;
289 PORT2.PFCAEn.BIT.PFCAEn3 = 0;
290 PORT2.PIPCn.BIT.PIPCn3 = 1;
293 PORT2.PMCn.BIT.PMCn4 = 1;
294 PORT2.PFCn.BIT.PFCn4 = 1;
295 PORT2.PFCEn.BIT.PFCEn4 = 0;
296 PORT2.PFCAEn.BIT.PFCAEn4 = 0;
297 PORT2.PIPCn.BIT.PIPCn4 = 1;
300 PORT2.PMCn.BIT.PMCn5 = 1;
301 PORT2.PFCn.BIT.PFCn5 = 1;
302 PORT2.PFCEn.BIT.PFCEn5 = 0;
303 PORT2.PFCAEn.BIT.PFCAEn5 = 0;
304 PORT2.PIPCn.BIT.PIPCn5 = 1;
307 PORT2.PMCn.BIT.PMCn6 = 1;
308 PORT2.PFCn.BIT.PFCn6 = 1;
309 PORT2.PFCEn.BIT.PFCEn6 = 0;
310 PORT2.PFCAEn.BIT.PFCAEn6 = 0;
311 PORT2.PIPCn.BIT.PIPCn6 = 1;
314 PORT2.PMCn.BIT.PMCn7 = 1;
315 PORT2.PFCn.BIT.PFCn7 = 1;
316 PORT2.PFCEn.BIT.PFCEn7 = 0;
317 PORT2.PFCAEn.BIT.PFCAEn7 = 0;
318 PORT2.PIPCn.BIT.PIPCn7 = 1;
321 PORT2.PMCn.BIT.PMCn8 = 1;
322 PORT2.PFCn.BIT.PFCn8 = 1;
323 PORT2.PFCEn.BIT.PFCEn8 = 0;
324 PORT2.PFCAEn.BIT.PFCAEn8 = 0;
325 PORT2.PIPCn.BIT.PIPCn8 = 1;
328 PORT2.PMCn.BIT.PMCn9 = 1;
329 PORT2.PFCn.BIT.PFCn9 = 1;
330 PORT2.PFCEn.BIT.PFCEn9 = 0;
331 PORT2.PFCAEn.BIT.PFCAEn9 = 0;
332 PORT2.PIPCn.BIT.PIPCn9 = 1;
335 PORT2.PMCn.BIT.PMCn10 = 1;
336 PORT2.PFCn.BIT.PFCn10 = 1;
337 PORT2.PFCEn.BIT.PFCEn10 = 0;
338 PORT2.PFCAEn.BIT.PFCAEn10 = 0;
339 PORT2.PIPCn.BIT.PIPCn10 = 1;
342 PORT2.PMCn.BIT.PMCn11 = 1;
343 PORT2.PFCn.BIT.PFCn11 = 1;
344 PORT2.PFCEn.BIT.PFCEn11 = 0;
345 PORT2.PFCAEn.BIT.PFCAEn11 = 0;
346 PORT2.PIPCn.BIT.PIPCn11 = 1;
349 PORT3.PMCn.BIT.PMCn3 = 1;
350 PORT3.PFCn.BIT.PFCn3 = 1;
351 PORT3.PFCEn.BIT.PFCEn3 = 0;
352 PORT3.PFCAEn.BIT.PFCAEn3 = 0;
353 PORT3.PIPCn.BIT.PIPCn3 = 1;
356 PORT3.PMCn.BIT.PMCn4 = 1;
357 PORT3.PFCn.BIT.PFCn4 = 1;
358 PORT3.PFCEn.BIT.PFCEn4 = 0;
359 PORT3.PFCAEn.BIT.PFCAEn4 = 0;
360 PORT3.PIPCn.BIT.PIPCn4 = 1;
363 PORT3.PMCn.BIT.PMCn5 = 1;
364 PORT3.PFCn.BIT.PFCn5 = 1;
365 PORT3.PFCEn.BIT.PFCEn5 = 0;
366 PORT3.PFCAEn.BIT.PFCAEn5 = 0;
367 PORT3.PIPCn.BIT.PIPCn5 = 1;
370 PORT3.PMCn.BIT.PMCn6 = 1;
371 PORT3.PFCn.BIT.PFCn6 = 1;
372 PORT3.PFCEn.BIT.PFCEn6 = 0;
373 PORT3.PFCAEn.BIT.PFCAEn6 = 0;
374 PORT3.PIPCn.BIT.PIPCn6 = 1;
377 PORT5.PMCn.BIT.PMCn9 = 1;
378 PORT5.PFCn.BIT.PFCn9 = 1;
379 PORT5.PFCEn.BIT.PFCEn9 = 0;
380 PORT5.PFCAEn.BIT.PFCAEn9 = 0;
381 PORT5.PIPCn.BIT.PIPCn9 = 1;
384 #elif defined(USE_VK_RZA1H)
386 PORT1.PMCn.BIT.PMCn14 = 1;
387 PORT1.PFCn.BIT.PFCn14 = 1;
388 PORT1.PFCEn.BIT.PFCEn14 = 1;
389 PORT1.PFCAEn.BIT.PFCAEn14 = 0;
390 PORT1.PIPCn.BIT.PIPCn14 = 1;
393 PORT2.PMCn.BIT.PMCn0 = 1;
394 PORT2.PFCn.BIT.PFCn0 = 1;
395 PORT2.PFCEn.BIT.PFCEn0 = 0;
396 PORT2.PFCAEn.BIT.PFCAEn0 = 0;
397 PORT2.PIPCn.BIT.PIPCn0 = 1;
400 PORT2.PMCn.BIT.PMCn1 = 1;
401 PORT2.PFCn.BIT.PFCn1 = 1;
402 PORT2.PFCEn.BIT.PFCEn1 = 0;
403 PORT2.PFCAEn.BIT.PFCAEn1 = 0;
404 PORT2.PIPCn.BIT.PIPCn1 = 1;
407 PORT2.PMCn.BIT.PMCn2 = 1;
408 PORT2.PFCn.BIT.PFCn2 = 1;
409 PORT2.PFCEn.BIT.PFCEn2 = 0;
410 PORT2.PFCAEn.BIT.PFCAEn2 = 0;
411 PORT2.PIPCn.BIT.PIPCn2 = 1;
414 PORT2.PMCn.BIT.PMCn3 = 1;
415 PORT2.PFCn.BIT.PFCn3 = 1;
416 PORT2.PFCEn.BIT.PFCEn3 = 0;
417 PORT2.PFCAEn.BIT.PFCAEn3 = 0;
418 PORT2.PIPCn.BIT.PIPCn3 = 1;
421 PORT2.PMCn.BIT.PMCn4 = 1;
422 PORT2.PFCn.BIT.PFCn4 = 1;
423 PORT2.PFCEn.BIT.PFCEn4 = 0;
424 PORT2.PFCAEn.BIT.PFCAEn4 = 0;
425 PORT2.PIPCn.BIT.PIPCn4 = 1;
428 PORT2.PMCn.BIT.PMCn5 = 1;
429 PORT2.PFCn.BIT.PFCn5 = 1;
430 PORT2.PFCEn.BIT.PFCEn5 = 0;
431 PORT2.PFCAEn.BIT.PFCAEn5 = 0;
432 PORT2.PIPCn.BIT.PIPCn5 = 1;
435 PORT2.PMCn.BIT.PMCn6 = 1;
436 PORT2.PFCn.BIT.PFCn6 = 1;
437 PORT2.PFCEn.BIT.PFCEn6 = 0;
438 PORT2.PFCAEn.BIT.PFCAEn6 = 0;
439 PORT2.PIPCn.BIT.PIPCn6 = 1;
442 PORT2.PMCn.BIT.PMCn7 = 1;
443 PORT2.PFCn.BIT.PFCn7 = 1;
444 PORT2.PFCEn.BIT.PFCEn7 = 0;
445 PORT2.PFCAEn.BIT.PFCAEn7 = 0;
446 PORT2.PIPCn.BIT.PIPCn7 = 1;
449 PORT2.PMCn.BIT.PMCn8 = 1;
450 PORT2.PFCn.BIT.PFCn8 = 1;
451 PORT2.PFCEn.BIT.PFCEn8 = 0;
452 PORT2.PFCAEn.BIT.PFCAEn8 = 0;
453 PORT2.PIPCn.BIT.PIPCn8 = 1;
456 PORT2.PMCn.BIT.PMCn9 = 1;
457 PORT2.PFCn.BIT.PFCn9 = 1;
458 PORT2.PFCEn.BIT.PFCEn9 = 0;
459 PORT2.PFCAEn.BIT.PFCAEn9 = 0;
460 PORT2.PIPCn.BIT.PIPCn9 = 1;
463 PORT2.PMCn.BIT.PMCn10 = 1;
464 PORT2.PFCn.BIT.PFCn10 = 1;
465 PORT2.PFCEn.BIT.PFCEn10 = 0;
466 PORT2.PFCAEn.BIT.PFCAEn10 = 0;
467 PORT2.PIPCn.BIT.PIPCn10 = 1;
470 PORT2.PMCn.BIT.PMCn11 = 1;
471 PORT2.PFCn.BIT.PFCn11 = 1;
472 PORT2.PFCEn.BIT.PFCEn11 = 0;
473 PORT2.PFCAEn.BIT.PFCAEn11 = 0;
474 PORT2.PIPCn.BIT.PIPCn11 = 1;
477 PORT3.PMCn.BIT.PMCn3 = 1;
478 PORT3.PFCn.BIT.PFCn3 = 1;
479 PORT3.PFCEn.BIT.PFCEn3 = 0;
480 PORT3.PFCAEn.BIT.PFCAEn3 = 0;
481 PORT3.PIPCn.BIT.PIPCn3 = 1;
484 PORT3.PMCn.BIT.PMCn4 = 1;
485 PORT3.PFCn.BIT.PFCn4 = 1;
486 PORT3.PFCEn.BIT.PFCEn4 = 0;
487 PORT3.PFCAEn.BIT.PFCAEn4 = 0;
488 PORT3.PIPCn.BIT.PIPCn4 = 1;
491 PORT3.PMCn.BIT.PMCn5 = 1;
492 PORT3.PFCn.BIT.PFCn5 = 1;
493 PORT3.PFCEn.BIT.PFCEn5 = 0;
494 PORT3.PFCAEn.BIT.PFCAEn5 = 0;
495 PORT3.PIPCn.BIT.PIPCn5 = 1;
498 PORT3.PMCn.BIT.PMCn6 = 1;
499 PORT3.PFCn.BIT.PFCn6 = 1;
500 PORT3.PFCEn.BIT.PFCEn6 = 0;
501 PORT3.PFCAEn.BIT.PFCAEn6 = 0;
502 PORT3.PIPCn.BIT.PIPCn6 = 1;
505 PORT7.PMCn.BIT.PMCn0 = 1;
506 PORT7.PFCn.BIT.PFCn0 = 0;
507 PORT7.PFCEn.BIT.PFCEn0 = 1;
508 PORT7.PFCAEn.BIT.PFCAEn0 = 0;
509 PORT7.PIPCn.BIT.PIPCn0 = 1;
512 #elif defined(USE_STREAM_IT_RZ)
514 PORT8.PMCn.BIT.PMCn0 = 1;
515 PORT8.PFCn.BIT.PFCn0 = 1;
516 PORT8.PFCEn.BIT.PFCEn0 = 0;
517 PORT8.PFCAEn.BIT.PFCAEn0 = 0;
518 PORT8.PIPCn.BIT.PIPCn0 = 1;
521 PORT8.PMCn.BIT.PMCn1 = 1;
522 PORT8.PFCn.BIT.PFCn1 = 1;
523 PORT8.PFCEn.BIT.PFCEn1 = 0;
524 PORT8.PFCAEn.BIT.PFCAEn1 = 0;
525 PORT8.PIPCn.BIT.PIPCn1 = 1;
528 PORT8.PMCn.BIT.PMCn2 = 1;
529 PORT8.PFCn.BIT.PFCn2 = 1;
530 PORT8.PFCEn.BIT.PFCEn2 = 0;
531 PORT8.PFCAEn.BIT.PFCAEn2 = 0;
532 PORT8.PIPCn.BIT.PIPCn2 = 1;
535 PORT8.PMCn.BIT.PMCn3 = 1;
536 PORT8.PFCn.BIT.PFCn3 = 1;
537 PORT8.PFCEn.BIT.PFCEn3 = 0;
538 PORT8.PFCAEn.BIT.PFCAEn3 = 0;
539 PORT8.PIPCn.BIT.PIPCn3 = 1;
542 PORT8.PMCn.BIT.PMCn4 = 1;
543 PORT8.PFCn.BIT.PFCn4 = 1;
544 PORT8.PFCEn.BIT.PFCEn4 = 0;
545 PORT8.PFCAEn.BIT.PFCAEn4 = 0;
546 PORT8.PIPCn.BIT.PIPCn4 = 1;
549 PORT8.PMCn.BIT.PMCn5 = 1;
550 PORT8.PFCn.BIT.PFCn5 = 1;
551 PORT8.PFCEn.BIT.PFCEn5 = 0;
552 PORT8.PFCAEn.BIT.PFCAEn5 = 0;
553 PORT8.PIPCn.BIT.PIPCn5 = 1;
556 PORT8.PMCn.BIT.PMCn6 = 1;
557 PORT8.PFCn.BIT.PFCn6 = 1;
558 PORT8.PFCEn.BIT.PFCEn6 = 0;
559 PORT8.PFCAEn.BIT.PFCAEn6 = 0;
560 PORT8.PIPCn.BIT.PIPCn6 = 1;
563 PORT8.PMCn.BIT.PMCn7 = 1;
564 PORT8.PFCn.BIT.PFCn7 = 1;
565 PORT8.PFCEn.BIT.PFCEn7 = 0;
566 PORT8.PFCAEn.BIT.PFCAEn7 = 0;
567 PORT8.PIPCn.BIT.PIPCn7 = 1;
570 PORT8.PMCn.BIT.PMCn8 = 1;
571 PORT8.PFCn.BIT.PFCn8 = 1;
572 PORT8.PFCEn.BIT.PFCEn8 = 0;
573 PORT8.PFCAEn.BIT.PFCAEn8 = 0;
574 PORT8.PIPCn.BIT.PIPCn8 = 1;
577 PORT8.PMCn.BIT.PMCn9 = 1;
578 PORT8.PFCn.BIT.PFCn9 = 1;
579 PORT8.PFCEn.BIT.PFCEn9 = 0;
580 PORT8.PFCAEn.BIT.PFCAEn9 = 0;
581 PORT8.PIPCn.BIT.PIPCn9 = 1;
584 PORT8.PMCn.BIT.PMCn10 = 1;
585 PORT8.PFCn.BIT.PFCn10 = 1;
586 PORT8.PFCEn.BIT.PFCEn10 = 0;
587 PORT8.PFCAEn.BIT.PFCAEn10 = 0;
588 PORT8.PIPCn.BIT.PIPCn10 = 1;
591 PORT8.PMCn.BIT.PMCn14 = 1;
592 PORT8.PFCn.BIT.PFCn14 = 1;
593 PORT8.PFCEn.BIT.PFCEn14 = 0;
594 PORT8.PFCAEn.BIT.PFCAEn14 = 0;
595 PORT8.PIPCn.BIT.PIPCn14 = 1;
598 PORT8.PMCn.BIT.PMCn15 = 1;
599 PORT8.PFCn.BIT.PFCn15 = 1;
600 PORT8.PFCEn.BIT.PFCEn15 = 0;
601 PORT8.PFCAEn.BIT.PFCAEn15 = 0;
602 PORT8.PIPCn.BIT.PIPCn15 = 1;
605 PORT9.PMCn.BIT.PMCn0 = 1;
606 PORT9.PFCn.BIT.PFCn0 = 1;
607 PORT9.PFCEn.BIT.PFCEn0 = 0;
608 PORT9.PFCAEn.BIT.PFCAEn0 = 0;
609 PORT9.PIPCn.BIT.PIPCn0 = 1;
612 PORT9.PMCn.BIT.PMCn1 = 1;
613 PORT9.PFCn.BIT.PFCn1 = 1;
614 PORT9.PFCEn.BIT.PFCEn1 = 0;
615 PORT9.PFCAEn.BIT.PFCAEn1 = 0;
616 PORT9.PIPCn.BIT.PIPCn1 = 1;
619 PORT9.PMCn.BIT.PMCn2 = 1;
620 PORT9.PFCn.BIT.PFCn2 = 1;
621 PORT9.PFCEn.BIT.PFCEn2 = 0;
622 PORT9.PFCAEn.BIT.PFCAEn2 = 0;
623 PORT9.PIPCn.BIT.PIPCn2 = 1;
626 PORT9.PMCn.BIT.PMCn3 = 1;
627 PORT9.PFCn.BIT.PFCn3 = 1;
628 PORT9.PFCEn.BIT.PFCEn3 = 0;
629 PORT9.PFCAEn.BIT.PFCAEn3 = 0;
630 PORT9.PIPCn.BIT.PIPCn3 = 1;
633 PORT9.PMCn.BIT.PMCn4 = 1;
634 PORT9.PFCn.BIT.PFCn4 = 1;
635 PORT9.PFCEn.BIT.PFCEn4 = 0;
636 PORT9.PFCAEn.BIT.PFCAEn4 = 0;
637 PORT9.PIPCn.BIT.PIPCn4 = 1;
640 PORT2.PMCn.BIT.PMCn7 = 0;
641 PORT2.PIPCn.BIT.PIPCn7 = 0;
642 PORT2.PMn.BIT.PMn7 = 0;
645 PORT2.Pn.BIT.Pn7 = 0;
647 PORT2.Pn.BIT.Pn7 = 1;
728 if(interface->phyDriver != NULL)
731 interface->phyDriver->tick(interface);
733 else if(interface->switchDriver != NULL)
736 interface->switchDriver->tick(interface);
753 R_INTC_Enable(INTC_ID_ETHERI);
756 if(interface->phyDriver != NULL)
759 interface->phyDriver->enableIrq(interface);
761 else if(interface->switchDriver != NULL)
764 interface->switchDriver->enableIrq(interface);
781 R_INTC_Disable(INTC_ID_ETHERI);
784 if(interface->phyDriver != NULL)
787 interface->phyDriver->disableIrq(interface);
789 else if(interface->switchDriver != NULL)
792 interface->switchDriver->disableIrq(interface);
818 status = ETHER.EESR0;
841 nicDriverInterface->nicEvent =
TRUE;
1043 volatile uint32_t *addrHigh;
1044 volatile uint32_t *addrLow;
1051 ETHER.MAHR0 = (interface->macAddr.b[0] << 24) | (interface->macAddr.b[1] << 16) |
1052 (interface->macAddr.b[2] << 8) | interface->macAddr.b[3];
1055 ETHER.MALR0 = (interface->macAddr.b[4] << 8) | interface->macAddr.b[5];
1062 entry = &interface->macAddrFilter[i];
1071 addrHigh = ÐER.TSU_ADRH0 + 2 * i;
1072 addrLow = ÐER.TSU_ADRL0 + 2 * i;
1081 *addrHigh = (entry->
addr.b[0] << 24) | (entry->
addr.b[1] << 16) |
1082 (entry->
addr.b[2] << 8) | entry->
addr.b[3];
1090 *addrLow = (entry->
addr.b[4] << 8) | entry->
addr.b[5];
1093 ETHER.TSU_TEN |= 1 << (31 - i);
1098 ETHER.TSU_TEN &= ~(1 << (31 - i));
1221 if((
data & 0x80000000) != 0)