1- /* mbed Microcontroller Library
2- * Copyright (c) 2006-2013 ARM Limited
1+ /* Copyright (c) 2020 Renesas Electronics Corporation.
2+ * SPDX-License-Identifier: Apache-2.0
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1414 * limitations under the License.
1515 */
1616#include <string.h>
17- #include "ethernet_api .h"
17+ #include "rza1_eth .h"
1818#include "cmsis.h"
1919#include "mbed_interface.h"
2020#include "mbed_toolchain.h"
2121#include "mbed_error.h"
2222#include "iodefine.h"
23- #include "ethernetext_api .h"
23+ #include "rza1_eth_ext .h"
2424
2525#if DEVICE_ETHERNET
2626
8989 /* 0x00000001 : Receive frame CRC error */
9090#define EDMAC_EESIPR_INI_EtherC (0x00400000) /* 0x00400000 : E-MAC status register */
9191
92- void ethernet_address (char * );
93- void ethernet_set_link (int , int );
92+ void rza1_ethernet_address (char * );
93+ void rza1_ethernet_set_link (int , int );
9494
9595
9696/* Send descriptor */
@@ -114,13 +114,13 @@ typedef struct tag_edmac_recv_desc {
114114/* Transmit/receive buffers (must be allocated in 16-byte boundaries) */
115115#if defined(__ICCARM__ )
116116#pragma data_alignment=16
117- static uint8_t ethernet_nc_memory [(sizeof (edmac_send_desc_t ) * NUM_OF_TX_DESCRIPTOR ) +
117+ static uint8_t rza1_ethernet_nc_memory [(sizeof (edmac_send_desc_t ) * NUM_OF_TX_DESCRIPTOR ) +
118118 (sizeof (edmac_recv_desc_t ) * NUM_OF_RX_DESCRIPTOR ) +
119119 (NUM_OF_TX_DESCRIPTOR * SIZE_OF_BUFFER ) +
120120 (NUM_OF_RX_DESCRIPTOR * SIZE_OF_BUFFER )] //16 bytes aligned!
121121 @ ".mirrorram ";
122122#else
123- static uint8_t ethernet_nc_memory [(sizeof (edmac_send_desc_t ) * NUM_OF_TX_DESCRIPTOR ) +
123+ static uint8_t rza1_ethernet_nc_memory [(sizeof (edmac_send_desc_t ) * NUM_OF_TX_DESCRIPTOR ) +
124124 (sizeof (edmac_recv_desc_t ) * NUM_OF_RX_DESCRIPTOR ) +
125125 (NUM_OF_TX_DESCRIPTOR * SIZE_OF_BUFFER ) +
126126 (NUM_OF_RX_DESCRIPTOR * SIZE_OF_BUFFER )]
@@ -162,7 +162,7 @@ static void set_ether_pir(uint32_t set_data);
162162static void wait_100us (int32_t wait_cnt );
163163
164164
165- int ethernetext_init (ethernet_cfg_t * p_ethcfg ) {
165+ int ethernetext_init (rza1_ethernet_cfg_t * p_ethcfg ) {
166166 int32_t i ;
167167 uint16_t val ;
168168
@@ -210,38 +210,6 @@ int ethernetext_init(ethernet_cfg_t *p_ethcfg) {
210210 wait_100us (250 ); /* 25msec */
211211 GPIOP4 |= 0x0004 ; /* P4_2 Outputs high level */
212212 wait_100us (100 ); /* 10msec */
213- #elif defined(TARGET_VK_RZ_A1H )
214- /* -->4F<-- P1_14(ET_COL) */
215- GPIOPMC1 |= 0x4000 ;
216- GPIOPFCAE1 &= ~0x4000 ;
217- GPIOPFCE1 |= 0x4000 ;
218- GPIOPFC1 |= 0x4000 ;
219- GPIOPIPC1 |= 0x4000 ;
220-
221- /* -->2F<-- P2_0(ET_TXCLK), P2_1(ET_TXER), P2_2(ET_TXEN), P2_3(ET_CRS), P2_4(ET_TXD0),
222- P2_5(ET_TXD1), P2_6(ET_TXD2), P2_7(ET_TXD3), P2_8(ET_RXD0), P2_9(ET_RXD1), P2_10(ET_RXD2) P2_11(ET_RXD3) */
223- GPIOPMC2 |= 0x0FFF ;
224- GPIOPFCAE2 &= ~0x0FFF ;
225- GPIOPFCE2 &= ~0x0FFF ;
226- GPIOPFC2 |= 0x0FFF ;
227- GPIOPIPC2 |= 0x0FFF ;
228-
229- /* -->3F<-- P3_3(ET_MDIO), P3_4(ET_RXCLK), P3_5(ET_RXER), P3_6(ET_RXDV) */
230- GPIOPMC3 |= 0x0078 ;
231- GPIOPFCAE3 &= ~0x0078 ;
232- GPIOPFCE3 &= ~0x0078 ;
233- GPIOPFC3 |= 0x0078 ;
234- GPIOPIPC3 |= 0x0078 ;
235-
236- /* -->3F<-- P7_0(ET_MDC) */
237- GPIOPMC7 |= 0x0001 ;
238- GPIOPFCAE7 &= ~0x0001 ;
239- GPIOPFCE7 |= 0x0001 ;
240- GPIOPFC7 &= ~0x0001 ;
241- GPIOPIPC7 |= 0x0001 ;
242-
243- /* Resets the E-MAC,E-DMAC */
244- lan_reg_reset ();
245213#else
246214#error "There is no initialization processing."
247215#endif
@@ -265,7 +233,7 @@ int ethernetext_init(ethernet_cfg_t *p_ethcfg) {
265233 if (p_ethcfg -> ether_mac != NULL ) {
266234 (void )memcpy (mac_addr , p_ethcfg -> ether_mac , sizeof (mac_addr ));
267235 } else {
268- ethernet_address (mac_addr ); /* Get MAC Address */
236+ rza1_ethernet_address (mac_addr ); /* Get MAC Address */
269237 }
270238
271239 return 0 ;
@@ -390,24 +358,24 @@ void ethernetext_set_all_multicast(int all) {
390358}
391359
392360
393- int ethernet_init () {
394- ethernet_cfg_t ethcfg ;
361+ int rza1_ethernet_init () {
362+ rza1_ethernet_cfg_t ethcfg ;
395363
396364 ethcfg .int_priority = 5 ;
397365 ethcfg .recv_cb = NULL ;
398366 ethcfg .ether_mac = NULL ;
399367 ethernetext_init (& ethcfg );
400- ethernet_set_link (-1 , 0 ); /* Auto-Negotiation */
368+ rza1_ethernet_set_link (-1 , 0 ); /* Auto-Negotiation */
401369
402370 return 0 ;
403371}
404372
405- void ethernet_free () {
373+ void rza1_ethernet_free () {
406374 ETHERARSTR |= 0x00000001 ; /* ETHER software reset */
407375 CPGSTBCR7 |= CPG_STBCR7_BIT_MSTP74 ; /* disable ETHER clock */
408376}
409377
410- int ethernet_write (const char * data , int slen ) {
378+ int rza1_ethernet_write (const char * data , int slen ) {
411379 edmac_send_desc_t * p_send_desc ;
412380 int32_t copy_size ;
413381
@@ -431,7 +399,7 @@ int ethernet_write(const char *data, int slen) {
431399 return copy_size ;
432400}
433401
434- int ethernet_send () {
402+ int rza1_ethernet_send () {
435403 edmac_send_desc_t * p_send_desc ;
436404 int32_t ret ;
437405
@@ -463,7 +431,7 @@ int ethernet_send() {
463431 return ret ;
464432}
465433
466- int ethernet_receive () {
434+ int rza1_ethernet_receive () {
467435 edmac_recv_desc_t * p_recv_desc ;
468436 int32_t receive_size = 0 ;
469437
@@ -507,7 +475,7 @@ int ethernet_receive() {
507475 return receive_size ;
508476}
509477
510- int ethernet_read (char * data , int dlen ) {
478+ int rza1_ethernet_read (char * data , int dlen ) {
511479 edmac_recv_desc_t * p_recv_desc = p_recv_end_desc ; /* Read top descriptor */
512480 int32_t copy_size ;
513481
@@ -525,13 +493,13 @@ int ethernet_read(char *data, int dlen) {
525493 return copy_size ;
526494}
527495
528- void ethernet_address (char * mac ) {
496+ void rza1_ethernet_address (char * mac ) {
529497 if (mac != NULL ) {
530498 mbed_mac_address (mac ); /* Get MAC Address */
531499 }
532500}
533501
534- int ethernet_link (void ) {
502+ int rza1_ethernet_link (void ) {
535503 int32_t ret ;
536504 uint16_t data ;
537505
@@ -545,7 +513,7 @@ int ethernet_link(void) {
545513 return ret ;
546514}
547515
548- void ethernet_set_link (int speed , int duplex ) {
516+ void rza1_ethernet_set_link (int speed , int duplex ) {
549517 uint16_t data ;
550518 int32_t i ;
551519 int32_t link ;
@@ -612,8 +580,8 @@ static void lan_desc_create(void) {
612580 int32_t i ;
613581 uint8_t * p_memory_top ;
614582
615- (void )memset ((void * )ethernet_nc_memory , 0 , sizeof (ethernet_nc_memory ));
616- p_memory_top = ethernet_nc_memory ;
583+ (void )memset ((void * )rza1_ethernet_nc_memory , 0 , sizeof (rza1_ethernet_nc_memory ));
584+ p_memory_top = rza1_ethernet_nc_memory ;
617585
618586 /* Descriptor area configuration */
619587 p_eth_desc_dsend = (edmac_send_desc_t * )p_memory_top ;
0 commit comments