• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd
3  * This file contains confidential and proprietary information of
4  * OSWare Technology Co., Ltd
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://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,
14  * WITHOUT 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 <linux/etherdevice.h>
20 #include <linux/rtnetlink.h>
21 #include <linux/version.h>
22 #include <linux/delay.h>
23 
24 #include "net_adapter.h"
25 #include "eth_chip_driver.h"
26 #include "net_device.h"
27 #include "net_device_adapter.h"
28 #include "osal_mem.h"
29 #include "nxpeth_phy.h"
30 
31 struct NetDevice *g_hdf_netdev;
32 extern int fec_driver_init(void);
33 extern int32_t GetSizeOfPrivData(void);
InitNxpethDriver(struct EthDevice * ethDevice)34 int32_t InitNxpethDriver(struct EthDevice *ethDevice)
35 {
36     int32_t ret;
37     int32_t size = GetSizeOfPrivData();
38 
39     if (ethDevice == NULL) {
40         HDF_LOGE("%s input is NULL!", __func__);
41         return HDF_FAILURE;
42     }
43 
44     g_hdf_netdev = ethDevice->netdev;
45     g_hdf_netdev->mlPriv = (struct fec_enet_private *)OsalMemCalloc(size);
46     if (g_hdf_netdev->mlPriv == NULL) {
47         HDF_LOGE("%s kzalloc mlPriv failed!", __func__);
48         return HDF_FAILURE;
49     } else {
50         HDF_LOGE("%s kzalloc mlPriv ok!", __func__);
51     }
52 
53     fec_driver_init();
54     ret = EthernetInitNetdev(ethDevice->netdev);
55     if (ret != HDF_SUCCESS) {
56         HDF_LOGE("%s failed to init ethernet netDev", __func__);
57         return HDF_FAILURE;
58     }
59 
60     return HDF_SUCCESS;
61 }
62 
DeinitNxpethDriver(struct EthDevice * ethDevice)63 int32_t DeinitNxpethDriver(struct EthDevice *ethDevice)
64 {
65     return HDF_SUCCESS;
66 }
67 
GetSizeOfPrivData(void)68 int32_t GetSizeOfPrivData(void)
69 {
70     return sizeof(struct fec_enet_private);
71 }
72 
73 struct fec_enet_private *
fec_get_priv_data(struct NetDevice * netDev)74 fec_get_priv_data(struct NetDevice *netDev)
75 {
76     return (struct fec_enet_private*)g_hdf_netdev->mlPriv;
77 }
78 
fec_get_hdfnet(void)79 struct NetDevice *fec_get_hdfnet(void)
80 {
81     return g_hdf_netdev;
82 }
83 EXPORT_SYMBOL(GetSizeOfPrivData);
84 EXPORT_SYMBOL(fec_get_priv_data);
85 EXPORT_SYMBOL(fec_get_hdfnet);