1 /******************************************************************************
2 *
3 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
4 * Analog Devices, Inc.),
5 * Copyright (C) 2023-2024 Analog Devices, Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ******************************************************************************/
20
21 /******* Includes *******/
22 #include "emac.h"
23 #include "emac_reva.h"
24 #include "mxc_sys.h"
25
26 /******* Definitions *******/
27 /* **** Definitions **** */
28 #define CONFIG_EMAC_SEARCH_PHY /**! Enable EMAC PHY ID Search */
29
30 /******* Functions *******/
31 /* ************************************************************************* */
32 /* Control/Configuration Functions */
33 /* ************************************************************************* */
34
MXC_EMAC_Init(mxc_emac_config_t * config)35 int MXC_EMAC_Init(mxc_emac_config_t *config)
36 {
37 if (!config) {
38 return E_NULL_PTR;
39 }
40
41 MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_EMAC);
42 MXC_GPIO_Config(&gpio_cfg_emac_P2a);
43 MXC_GPIO_Config(&gpio_cfg_emac_P2b);
44
45 return MXC_EMAC_RevA_Init((mxc_emac_reva_config_t *)config);
46 }
47
MXC_EMAC_SetConfiguration(mxc_emac_config_t * config)48 int MXC_EMAC_SetConfiguration(mxc_emac_config_t *config)
49 {
50 return MXC_EMAC_RevA_SetConfiguration((mxc_emac_reva_config_t *)config);
51 }
52
MXC_EMAC_SetHwAddr(unsigned char * enetaddr)53 int MXC_EMAC_SetHwAddr(unsigned char *enetaddr)
54 {
55 return MXC_EMAC_RevA_SetHwAddr(enetaddr);
56 }
57
MXC_EMAC_EnableInterruptEvents(unsigned int events)58 int MXC_EMAC_EnableInterruptEvents(unsigned int events)
59 {
60 return MXC_EMAC_RevA_EnableInterruptEvents(events);
61 }
62
MXC_EMAC_DisableInterruptEvents(unsigned int events)63 int MXC_EMAC_DisableInterruptEvents(unsigned int events)
64 {
65 return MXC_EMAC_RevA_DisableInterruptEvents(events);
66 }
67
68 /* ************************************************************************* */
69 /* Low-Level Functions */
70 /* ************************************************************************* */
MXC_EMAC_Start(void)71 int MXC_EMAC_Start(void)
72 {
73 return MXC_EMAC_RevA_Start();
74 }
75
MXC_EMAC_Stop(void)76 int MXC_EMAC_Stop(void)
77 {
78 return MXC_EMAC_RevA_Stop();
79 }
80
MXC_EMAC_ReadLinkStatus(void)81 int MXC_EMAC_ReadLinkStatus(void)
82 {
83 return MXC_EMAC_RevA_ReadLinkStatus();
84 }
85
86 /* ************************************************************************* */
87 /* Transaction-Level Functions */
88 /* ************************************************************************* */
MXC_EMAC_SendSync(const void * packet,unsigned int length)89 int MXC_EMAC_SendSync(const void *packet, unsigned int length)
90 {
91 return MXC_EMAC_RevA_SendSync(packet, length);
92 }
93
MXC_EMAC_SendAsync(const void * packet,unsigned int length)94 int MXC_EMAC_SendAsync(const void *packet, unsigned int length)
95 {
96 return MXC_EMAC_RevA_SendAsync(packet, length);
97 }
98
MXC_EMAC_Recv(void * rx_buff,unsigned int max_len)99 int MXC_EMAC_Recv(void *rx_buff, unsigned int max_len)
100 {
101 return MXC_EMAC_RevA_Recv(rx_buff, max_len);
102 }
103
MXC_EMAC_IrqHandler(void)104 void MXC_EMAC_IrqHandler(void)
105 {
106 MXC_EMAC_RevA_IrqHandler();
107 }
108