1 /*
2  * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #include "Driver_ETH_MAC.h"
20 
21 #define ARM_ETH_MAC_DRV_VERSION    ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
22 
23 /* Driver Version */
24 static const ARM_DRIVER_VERSION DriverVersion = {
25     ARM_ETH_MAC_API_VERSION,
26     ARM_ETH_MAC_DRV_VERSION
27 };
28 
29 /* Driver Capabilities */
30 static const ARM_ETH_MAC_CAPABILITIES DriverCapabilities = {
31     0, /* 1 = IPv4 header checksum verified on receive */
32     0, /* 1 = IPv6 checksum verification supported on receive */
33     0, /* 1 = UDP payload checksum verified on receive */
34     0, /* 1 = TCP payload checksum verified on receive */
35     0, /* 1 = ICMP payload checksum verified on receive */
36     0, /* 1 = IPv4 header checksum generated on transmit */
37     0, /* 1 = IPv6 checksum generation supported on transmit */
38     0, /* 1 = UDP payload checksum generated on transmit */
39     0, /* 1 = TCP payload checksum generated on transmit */
40     0, /* 1 = ICMP payload checksum generated on transmit */
41     0, /* Ethernet Media Interface type */
42     0, /* 1 = driver provides initial valid MAC address */
43     0, /* 1 = callback event \ref ARM_ETH_MAC_EVENT_RX_FRAME generated */
44     0, /* 1 = callback event \ref ARM_ETH_MAC_EVENT_TX_FRAME generated */
45     0, /* 1 = wakeup event \ref ARM_ETH_MAC_EVENT_WAKEUP generated */
46     0, /* 1 = Precision Timer supported */
47     0  /* Reserved (must be zero) */
48 };
49 
50 //
51 //  Functions
52 //
53 
ARM_ETH_MAC_GetVersion(void)54 static ARM_DRIVER_VERSION ARM_ETH_MAC_GetVersion(void)
55 {
56   return DriverVersion;
57 }
58 
ARM_ETH_MAC_GetCapabilities(void)59 static ARM_ETH_MAC_CAPABILITIES ARM_ETH_MAC_GetCapabilities(void)
60 {
61   return DriverCapabilities;
62 }
63 
ARM_ETH_MAC_Initialize(ARM_ETH_MAC_SignalEvent_t cb_event)64 static int32_t ARM_ETH_MAC_Initialize(ARM_ETH_MAC_SignalEvent_t cb_event)
65 {
66 }
67 
ARM_ETH_MAC_Uninitialize(void)68 static int32_t ARM_ETH_MAC_Uninitialize(void)
69 {
70 }
71 
ARM_ETH_MAC_PowerControl(ARM_POWER_STATE state)72 static int32_t ARM_ETH_MAC_PowerControl(ARM_POWER_STATE state)
73 {
74     switch (state)
75     {
76     case ARM_POWER_OFF:
77         break;
78 
79     case ARM_POWER_LOW:
80         break;
81 
82     case ARM_POWER_FULL:
83         break;
84     }
85     return ARM_DRIVER_OK;
86 }
87 
ARM_ETH_MAC_GetMacAddress(ARM_ETH_MAC_ADDR * ptr_addr)88 static int32_t ARM_ETH_MAC_GetMacAddress(ARM_ETH_MAC_ADDR *ptr_addr)
89 {
90 }
91 
ARM_ETH_MAC_SetMacAddress(const ARM_ETH_MAC_ADDR * ptr_addr)92 static int32_t ARM_ETH_MAC_SetMacAddress(const ARM_ETH_MAC_ADDR *ptr_addr)
93 {
94 }
95 
ARM_ETH_MAC_SetAddressFilter(const ARM_ETH_MAC_ADDR * ptr_addr,uint32_t num_addr)96 static int32_t ARM_ETH_MAC_SetAddressFilter(const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr)
97 {
98 }
99 
ARM_ETH_MAC_SendFrame(const uint8_t * frame,uint32_t len,uint32_t flags)100 static int32_t ARM_ETH_MAC_SendFrame(const uint8_t *frame, uint32_t len, uint32_t flags)
101 {
102 }
103 
ARM_ETH_MAC_ReadFrame(uint8_t * frame,uint32_t len)104 static int32_t ARM_ETH_MAC_ReadFrame(uint8_t *frame, uint32_t len)
105 {
106 }
107 
ARM_ETH_MAC_GetRxFrameSize(void)108 static uint32_t ARM_ETH_MAC_GetRxFrameSize(void)
109 {
110 }
111 
ARM_ETH_MAC_GetRxFrameTime(ARM_ETH_MAC_TIME * time)112 static int32_t ARM_ETH_MAC_GetRxFrameTime(ARM_ETH_MAC_TIME *time)
113 {
114 }
115 
ARM_ETH_MAC_GetTxFrameTime(ARM_ETH_MAC_TIME * time)116 static int32_t ARM_ETH_MAC_GetTxFrameTime(ARM_ETH_MAC_TIME *time)
117 {
118 }
119 
ARM_ETH_MAC_Control(uint32_t control,uint32_t arg)120 static int32_t ARM_ETH_MAC_Control(uint32_t control, uint32_t arg)
121 {
122     switch (control)
123     {
124     case ARM_ETH_MAC_CONFIGURE:
125 
126         switch (arg & ARM_ETH_MAC_SPEED_Msk)
127         {
128         case ARM_ETH_MAC_SPEED_10M:
129             break;
130         case ARM_ETH_SPEED_100M:
131             break;
132         default:
133             return ARM_DRIVER_ERROR_UNSUPPORTED;
134         }
135 
136         switch (arg & ARM_ETH_MAC_DUPLEX_Msk)
137         {
138         case ARM_ETH_MAC_DUPLEX_FULL:
139             break;
140         }
141 
142         if (arg & ARM_ETH_MAC_LOOPBACK)
143         {
144         }
145 
146         if ((arg & ARM_ETH_MAC_CHECKSUM_OFFLOAD_RX) ||
147             (arg & ARM_ETH_MAC_CHECKSUM_OFFLOAD_TX))
148         {
149             return ARM_DRIVER_ERROR_UNSUPPORTED;
150         }
151 
152         if (!(arg & ARM_ETH_MAC_ADDRESS_BROADCAST))
153         {
154         }
155 
156         if (arg & ARM_ETH_MAC_ADDRESS_MULTICAST)
157         {
158         }
159 
160         if (arg & ARM_ETH_MAC_ADDRESS_ALL)
161         {
162         }
163 
164         break;
165 
166     case ARM_ETH_MAC_CONTROL_TX:
167         break;
168 
169     case ARM_ETH_MAC_CONTROL_RX:
170         break;
171 
172     case ARM_ETH_MAC_FLUSH:
173         if (arg & ARM_ETH_MAC_FLUSH_RX)
174         {
175         }
176         if (arg & ARM_ETH_MAC_FLUSH_TX)
177         {
178         }
179         break;
180 
181     case ARM_ETH_MAC_SLEEP:
182         break;
183 
184     case ARM_ETH_MAC_VLAN_FILTER:
185         break;
186 
187     default:
188         return ARM_DRIVER_ERROR_UNSUPPORTED;
189     }
190 }
191 
ARM_ETH_MAC_ControlTimer(uint32_t control,ARM_ETH_MAC_TIME * time)192 static int32_t ARM_ETH_MAC_ControlTimer(uint32_t control, ARM_ETH_MAC_TIME *time)
193 {
194 }
195 
ARM_ETH_MAC_PHY_Read(uint8_t phy_addr,uint8_t reg_addr,uint16_t * data)196 static int32_t ARM_ETH_MAC_PHY_Read(uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
197 {
198 }
199 
ARM_ETH_MAC_PHY_Write(uint8_t phy_addr,uint8_t reg_addr,uint16_t data)200 static int32_t ARM_ETH_MAC_PHY_Write(uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
201 {
202 }
203 
ARM_ETH_MAC_SignalEvent(uint32_t event)204 static void ARM_ETH_MAC_SignalEvent(uint32_t event)
205 {
206 }
207 
208 // End ETH MAC Interface
209 
210 extern \
211 ARM_DRIVER_ETH_MAC Driver_ETH_MAC0;
212 ARM_DRIVER_ETH_MAC Driver_ETH_MAC0 =
213 {
214     ARM_ETH_MAC_GetVersion,
215     ARM_ETH_MAC_GetCapabilities,
216     ARM_ETH_MAC_Initialize,
217     ARM_ETH_MAC_Uninitialize,
218     ARM_ETH_MAC_PowerControl,
219     ARM_ETH_MAC_GetMacAddress,
220     ARM_ETH_MAC_SetMacAddress,
221     ARM_ETH_MAC_SetAddressFilter,
222     ARM_ETH_MAC_SendFrame,
223     ARM_ETH_MAC_ReadFrame,
224     ARM_ETH_MAC_GetRxFrameSize,
225     ARM_ETH_MAC_GetRxFrameTime,
226     ARM_ETH_MAC_GetTxFrameTime,
227     ARM_ETH_MAC_ControlTimer,
228     ARM_ETH_MAC_Control,
229     ARM_ETH_MAC_PHY_Read,
230     ARM_ETH_MAC_PHY_Write
231 };
232