net/axgbe: add structs for MAC init and reset
[dpdk.git] / drivers / net / axgbe / axgbe_dev.c
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved.
3  *   Copyright(c) 2018 Synopsys, Inc. All rights reserved.
4  */
5
6 #include "axgbe_ethdev.h"
7 #include "axgbe_common.h"
8 #include "axgbe_phy.h"
9
10 static int __axgbe_exit(struct axgbe_port *pdata)
11 {
12         unsigned int count = 2000;
13
14         /* Issue a software reset */
15         AXGMAC_IOWRITE_BITS(pdata, DMA_MR, SWR, 1);
16         rte_delay_us(10);
17
18         /* Poll Until Poll Condition */
19         while (--count && AXGMAC_IOREAD_BITS(pdata, DMA_MR, SWR))
20                 rte_delay_us(500);
21
22         if (!count)
23                 return -EBUSY;
24
25         return 0;
26 }
27
28 static int axgbe_exit(struct axgbe_port *pdata)
29 {
30         int ret;
31
32         /* To guard against possible incorrectly generated interrupts,
33          * issue the software reset twice.
34          */
35         ret = __axgbe_exit(pdata);
36         if (ret)
37                 return ret;
38
39         return __axgbe_exit(pdata);
40 }
41
42 void axgbe_init_function_ptrs_dev(struct axgbe_hw_if *hw_if)
43 {
44         hw_if->exit = axgbe_exit;
45 }