1 /*
2 * Copyright (c) 2021 iSoftStone Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include "hdf_wifi_product.h"
10 #include "wifi_mac80211_ops.h"
11 #include "hdf_wlan_utils.h"
12
13 #define HDF_LOG_TAG Xr829Driver
14
15 /***********************************************************/
16 /* variable and function declare */
17 /***********************************************************/
18 struct net_device *save_kernel_net = NULL;
19
20 /***********************************************************/
21 /* variable and function declare */
22 /***********************************************************/
23 extern int32_t hdf_netdev_init(struct NetDevice *netDev);
24 extern int32_t hdf_netdev_open(struct NetDevice *netDev);
25 extern int32_t hdf_netdev_stop(struct NetDevice *netDev);
26 extern struct net_device *GetLinuxInfByNetDevice(const struct NetDevice *netDevice);
27 extern void set_krn_netdev(struct net_device *dev);
28 extern int xradio_init(void);
29 extern void xradio_exit(void);
30
31 /***********************************************************/
32 /* Function declare */
33 /***********************************************************/
InitXr829Chip(struct HdfWlanDevice * device)34 int32_t InitXr829Chip(struct HdfWlanDevice *device)
35 {
36 HDF_LOGE("%s: start...", __func__);
37 return HDF_SUCCESS;
38 }
39
DeinitXr829Chip(struct HdfWlanDevice * device)40 int32_t DeinitXr829Chip(struct HdfWlanDevice *device)
41 {
42 int32_t ret = 0;
43
44 (void)device;
45 HDF_LOGE("%s: start...", __func__);
46 /*if (ret != 0)
47 {
48 HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret);
49 }*/
50 return ret;
51 }
52
Xr829Init(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)53 int32_t Xr829Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
54 {
55 struct HdfWifiNetDeviceData *data = NULL;
56 struct net_device *netdev = NULL;
57
58 (void)chipDriver;
59 HDF_LOGE("%s: start...", __func__);
60
61 if (netDevice == NULL)
62 {
63 HDF_LOGE("%s:para is null!", __func__);
64 return HDF_FAILURE;
65 }
66
67 netdev = GetLinuxInfByNetDevice(netDevice);
68 if (netdev == NULL) {
69 HDF_LOGE("%s net_device is null!", __func__);
70 return HDF_FAILURE;
71 }
72
73 set_krn_netdev(netdev);
74
75 data = GetPlatformData(netDevice);
76 if (data == NULL)
77 {
78 HDF_LOGE("%s:netdevice data null!", __func__);
79 return HDF_FAILURE;
80 }
81
82 /* set netdevice ops to netDevice */
83 hdf_netdev_init(netDevice);
84 netDevice->classDriverPriv = data;
85
86 xradio_init();
87 NetDeviceAdd(netDevice);
88
89 HDF_LOGE("%s: success", __func__);
90
91 //ret = hdf_netdev_open(netDevice);
92 return HDF_SUCCESS;
93 }
94
Xr829Deinit(struct HdfChipDriver * chipDriver,struct NetDevice * netDevice)95 int32_t Xr829Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
96 {
97 HDF_LOGE("%s: start...", __func__);
98 (void)netDevice;
99 (void)chipDriver;
100 xradio_exit();
101 return HDF_SUCCESS;
102 }
103
set_krn_netdev(struct net_device * dev)104 void set_krn_netdev(struct net_device *dev) {
105 save_kernel_net = dev;
106 }
107
get_krn_netdev(void)108 struct net_device *get_krn_netdev(void) {
109 return save_kernel_net;
110 }
111
112 EXPORT_SYMBOL(set_krn_netdev);
113 EXPORT_SYMBOL(get_krn_netdev);
114