• 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 "devsvc_manager_clnt.h"
20 #include "eth_chip_driver.h"
21 #include "hdf_device_desc.h"
22 #include "hdf_log.h"
23 #include "nxpeth_mac.h"
24 #include "nxpeth_phy.h"
25 #include "osal_mem.h"
26 
27 static const char* NXP_ETHERNET_DRIVER_NAME = "nxpeth-fec";
28 
HdfEthRegNxpDriverFactory(void)29 static int32_t HdfEthRegNxpDriverFactory(void)
30 {
31     static struct HdfEthChipDriverFactory tmpFactory = { 0 };
32     struct HdfEthChipDriverManager *driverMgr = HdfEthGetChipDriverMgr();
33 
34     if (driverMgr == NULL && driverMgr->RegChipDriver == NULL) {
35         HDF_LOGE("%s fail: driverMgr is NULL", __func__);
36         return HDF_FAILURE;
37     }
38     tmpFactory.driverName = NXP_ETHERNET_DRIVER_NAME;
39     tmpFactory.InitEthDriver = InitNxpethDriver;
40     tmpFactory.GetMacAddr = EthNxpRandomAddr;
41     tmpFactory.DeinitEthDriver = DeinitNxpethDriver;
42     tmpFactory.BuildMacDriver = BuildNxpMacDriver;
43     tmpFactory.ReleaseMacDriver = ReleaseNxpMacDriver;
44     if (driverMgr->RegChipDriver(&tmpFactory) != HDF_SUCCESS) {
45         HDF_LOGE("%s fail: driverMgr is NULL", __func__);
46         return HDF_FAILURE;
47     }
48     HDF_LOGI("nxp eth driver register success");
49     return HDF_SUCCESS;
50 }
51 
HdfEthNxpChipDriverInit(struct HdfDeviceObject * device)52 static int32_t HdfEthNxpChipDriverInit(struct HdfDeviceObject *device)
53 {
54     (void)device;
55     return HdfEthRegNxpDriverFactory();
56 }
57 
HdfEthNxpDriverBind(struct HdfDeviceObject * dev)58 static int32_t HdfEthNxpDriverBind(struct HdfDeviceObject *dev)
59 {
60     (void)dev;
61     return HDF_SUCCESS;
62 }
63 
HdfEthNxpChipRelease(struct HdfDeviceObject * object)64 static void HdfEthNxpChipRelease(struct HdfDeviceObject *object)
65 {
66     (void)object;
67 }
68 
69 struct HdfDriverEntry g_hdfnxpethchipentry = {
70     .moduleVersion = 1,
71     .Bind = HdfEthNxpDriverBind,
72     .Init = HdfEthNxpChipDriverInit,
73     .Release = HdfEthNxpChipRelease,
74     .moduleName = "HDF_ETHERNET_CHIPS"
75 };
76 
77 HDF_INIT(g_hdfnxpethchipentry);
78