mirror of
https://gitee.com/openharmony/drivers_framework
synced 2024-11-23 21:10:02 +00:00
mmc && wifi_bus code
Signed-off-by: lzl <sucer_fater@163.com>
This commit is contained in:
parent
322bc1487a
commit
15200d6fc1
84
include/wifi/hdf_ibus_intf.h
Normal file
84
include/wifi/hdf_ibus_intf.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
|
||||
*
|
||||
* HDF is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
* See the LICENSE file in the root of this repository for complete details.
|
||||
*/
|
||||
|
||||
#ifndef HDF_IBUS_INTF_H
|
||||
#define HDF_IBUS_INTF_H
|
||||
|
||||
#include "hdf_wlan_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct BusDev;
|
||||
typedef void IrqHandler(void *);
|
||||
|
||||
struct SdioConfigInfo {
|
||||
uint32_t maxBlockNum;
|
||||
uint32_t maxBlockSize;
|
||||
uint32_t maxRequestSize;
|
||||
uint32_t funcNumSize;
|
||||
uint32_t irqCap;
|
||||
void *data;
|
||||
};
|
||||
|
||||
union BusInfo {
|
||||
struct SdioConfigInfo sdioInfo;
|
||||
};
|
||||
|
||||
struct BusConfig {
|
||||
uint8_t busType;
|
||||
union BusInfo busInfo;
|
||||
};
|
||||
|
||||
struct PrivateData {
|
||||
void *data;
|
||||
const char *driverName;
|
||||
int32_t (*release)(void *data);
|
||||
};
|
||||
|
||||
struct DevOps {
|
||||
int32_t (*getBusInfo)(struct BusDev *dev, struct BusConfig *busCfg);
|
||||
void (*deInit)(struct BusDev *dev);
|
||||
int32_t (*init)(struct BusDev *dev, const struct HdfConfigWlanBus *busCfg);
|
||||
|
||||
int32_t (*readData)(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf);
|
||||
int32_t (*writeData)(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf);
|
||||
|
||||
int32_t (*bulkRead)(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf, uint32_t sg_len);
|
||||
int32_t (*bulkWrite)(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf, uint32_t sg_len);
|
||||
|
||||
int32_t (*readFunc0)(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf);
|
||||
int32_t (*writeFunc0)(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf);
|
||||
|
||||
int32_t (*disableBus)(struct BusDev *dev);
|
||||
int32_t (*claimIrq)(struct BusDev *dev, IrqHandler *handler, void *data);
|
||||
int32_t (*releaseIrq)(struct BusDev *dev);
|
||||
int32_t (*reset)(struct BusDev *dev);
|
||||
|
||||
void (*claimHost)(struct BusDev *dev);
|
||||
void (*releaseHost)(struct BusDev *dev);
|
||||
};
|
||||
|
||||
struct BusDev {
|
||||
void *devBase;
|
||||
struct DevOps ops;
|
||||
struct PrivateData priData;
|
||||
};
|
||||
|
||||
struct BusDev *HdfWlanCreateBusManager(const struct HdfConfigWlanBus *busConfig);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
@ -36,6 +36,7 @@
|
||||
#include "hdf_wlan_config.h"
|
||||
#include "hdf_wlan_power_manager.h"
|
||||
#include "hdf_wlan_reset_manager.h"
|
||||
#include "hdf_ibus_intf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -74,6 +75,7 @@ struct HdfWlanDevice {
|
||||
struct HdfWlanManufacturer manufacturer; /**< WLAN device manufacturer */
|
||||
struct ResetManager *reset; /**< Chip reset management API */
|
||||
struct PowerManager *powers; /**< Chip power management APIs */
|
||||
struct BusDev *bus;
|
||||
};
|
||||
|
||||
/**
|
||||
|
51
model/network/wifi/bus/hdf_ibus_intf.c
Normal file
51
model/network/wifi/bus/hdf_ibus_intf.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
|
||||
*
|
||||
* HDF is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
* See the LICENSE file in the root of this repository for complete details.
|
||||
*/
|
||||
|
||||
#include "hdf_sdio_intf.h"
|
||||
#include "osal_mem.h"
|
||||
#include "securec.h"
|
||||
#include "wifi_inc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct BusDev *HdfWlanCreateBusManager(const struct HdfConfigWlanBus *busConfig)
|
||||
{
|
||||
if (busConfig == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
struct BusDev *bus = (struct BusDev *)OsalMemCalloc(sizeof(struct BusDev));
|
||||
if (bus == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (busConfig->busType) {
|
||||
case BUS_SDIO:
|
||||
if (HdfSdioBusInit(bus, busConfig) != HDF_SUCCESS) {
|
||||
OsalMemFree(bus);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
HDF_LOGE("%s:bus type not support!", __func__);
|
||||
OsalMemFree(bus);
|
||||
return NULL;
|
||||
}
|
||||
return bus;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
~
|
||||
|
385
model/network/wifi/bus/hdf_sdio_intf.c
Normal file
385
model/network/wifi/bus/hdf_sdio_intf.c
Normal file
@ -0,0 +1,385 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
|
||||
*
|
||||
* HDF is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
* See the LICENSE file in the root of this repository for complete details.
|
||||
*/
|
||||
|
||||
#include "hdf_sdio_intf.h"
|
||||
#include "osal_mem.h"
|
||||
#include "sdio_if.h"
|
||||
#include "wifi_inc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static int32_t HdfGetSdioInfo(struct BusDev *dev, struct BusConfig *busCfg)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
SdioCommonInfo palSdioCommonInfo;
|
||||
if (dev == NULL || busCfg == NULL || busCfg->busType != BUS_SDIO) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
(void)memset_s(&palSdioCommonInfo, sizeof(SdioCommonInfo), 0, sizeof(SdioCommonInfo));
|
||||
|
||||
ret = SdioGetCommonInfo(handle, &palSdioCommonInfo, SDIO_FUNC_INFO);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:get sdio info error!", __func__);
|
||||
return ret;
|
||||
}
|
||||
busCfg->busInfo.sdioInfo.maxBlockNum = palSdioCommonInfo.funcInfo.maxBlockNum;
|
||||
busCfg->busInfo.sdioInfo.maxBlockSize = palSdioCommonInfo.funcInfo.maxBlockSize;
|
||||
busCfg->busInfo.sdioInfo.maxRequestSize = palSdioCommonInfo.funcInfo.maxRequestSize;
|
||||
busCfg->busInfo.sdioInfo.funcNumSize = palSdioCommonInfo.funcInfo.funcNum;
|
||||
busCfg->busInfo.sdioInfo.irqCap = palSdioCommonInfo.funcInfo.irqCap;
|
||||
busCfg->busInfo.sdioInfo.data = palSdioCommonInfo.funcInfo.data;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void HdfSdioReleaseDev(struct BusDev *dev)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return;
|
||||
}
|
||||
if (dev->priData.data != NULL) {
|
||||
dev->priData.release(dev->priData.data);
|
||||
dev->priData.data = NULL;
|
||||
}
|
||||
OsalMemFree(dev);
|
||||
dev = NULL;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioEnableFunc(struct BusDev *dev)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioEnableFunc(handle);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:enable sdio func failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioDisableFunc(struct BusDev *dev)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioDisableFunc(handle);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:disable sdio func failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioCliamIrq(struct BusDev *dev, IrqHandler *handler, void *data)
|
||||
{
|
||||
(void)data;
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioClaimIrq(handle, (SdioIrqHandler *)handler);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:claim sdio irq failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void HdfSdioClaimHost(struct BusDev *dev)
|
||||
{
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
SdioClaimHost(handle);
|
||||
}
|
||||
|
||||
static void HdfSdioReleaseHost(struct BusDev *dev)
|
||||
{
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
SdioReleaseHost(handle);
|
||||
}
|
||||
|
||||
|
||||
static int32_t HdfSdioReleaseIrq(struct BusDev *dev)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioReleaseIrq(handle);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:release sdio irq failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioReset(struct BusDev *dev)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioFlushData(handle);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:reset sdio failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioReadN(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioReadBytes(handle, buf, addr, cnt);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:read sdio data failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioReadFunc0(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioReadBytesFromFunc0(handle, buf, addr, cnt);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:read sdio func0 data failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioReadSpcReg(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf, uint32_t sg_len)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioReadBytesFromFixedAddr(handle, buf, addr, cnt, sg_len);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:read sdio special reg data failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioWriteN(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL || buf == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioWriteBytes(handle, buf, addr, cnt);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:write sdio data failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioWriteFunc0(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL || buf == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioWriteBytesToFunc0(handle, buf, addr, cnt);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:write sdio func0 data failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioWriteSpcReg(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf, uint32_t sg_len)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL || buf == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioWriteBytesToFixedAddr(handle, buf, addr, cnt, sg_len);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGI("%s:write sdio special reg data failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioSetBlk(struct BusDev *dev, uint32_t blkSize)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:input parameter error!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
handle = (struct DevHandle *)dev->devBase;
|
||||
ret = SdioSetBlockSize(handle, blkSize);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:sdio set block size failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct DevHandle *HdfGetDevHandle(struct BusDev *dev, const struct HdfConfigWlanBus *busCfg)
|
||||
{
|
||||
struct DevHandle *handle = NULL;
|
||||
int32_t cnt;
|
||||
struct SdioFunctionConfig palSdioConfig[WLAN_MAX_CHIP_NUM] = {0};
|
||||
struct HdfConfigWlanChipList *tmpChipList = NULL;
|
||||
|
||||
struct HdfConfigWlanRoot *rootConfig = HdfWlanGetModuleConfigRoot();
|
||||
if (rootConfig == NULL) {
|
||||
HDF_LOGE("%s: NULL ptr!", __func__);
|
||||
return NULL;
|
||||
}
|
||||
tmpChipList = &rootConfig->wlanConfig.chipList;
|
||||
for (cnt = 0; (cnt < tmpChipList->chipInstSize) && (cnt < WLAN_MAX_CHIP_NUM); cnt++) {
|
||||
// once detected card break
|
||||
palSdioConfig[cnt].deviceId = tmpChipList->chipInst[cnt].chipSdio.deviceId[0];
|
||||
palSdioConfig[cnt].vendorId = tmpChipList->chipInst[cnt].chipSdio.vendorId;
|
||||
palSdioConfig[cnt].funcNr = busCfg->funcNum[0];
|
||||
handle = SdioOpen(busCfg->busIdx, &palSdioConfig[cnt]);
|
||||
if (handle != NULL) {
|
||||
HDF_LOGI("%s: sdio card detected!", __func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cnt == tmpChipList->chipInstSize || cnt == WLAN_MAX_CHIP_NUM) {
|
||||
HDF_LOGE("%s: NO sdio card detected!", __func__);
|
||||
SdioClose(handle);
|
||||
return NULL;
|
||||
}
|
||||
dev->devBase = handle;
|
||||
dev->priData.driverName = tmpChipList->chipInst[cnt].driverName;
|
||||
return handle;
|
||||
}
|
||||
|
||||
static int32_t HdfSdioInit(struct BusDev *dev, const struct HdfConfigWlanBus *busCfg)
|
||||
{
|
||||
int32_t ret;
|
||||
struct DevHandle *handle = NULL;
|
||||
SdioCommonInfo palSdioCommonInfo;
|
||||
|
||||
if (dev == NULL || busCfg == NULL) {
|
||||
HDF_LOGE("%s: input parameter error!", __func__);
|
||||
goto sdioInitFail;
|
||||
}
|
||||
handle = HdfGetDevHandle(dev, busCfg);
|
||||
if (handle == NULL) {
|
||||
HDF_LOGE("%s: sdio card detected fail!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
SdioClaimHost(handle);
|
||||
(void)memset_s(&palSdioCommonInfo, sizeof(SdioCommonInfo), 0, sizeof(SdioCommonInfo));
|
||||
SdioGetCommonInfo(handle, &palSdioCommonInfo, SDIO_FUNC_INFO);
|
||||
palSdioCommonInfo.funcInfo.enTimeout = busCfg->timeout;
|
||||
SdioSetCommonInfo(handle, &palSdioCommonInfo, SDIO_FUNC_INFO);
|
||||
ret = HdfSdioEnableFunc(dev);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: enable sdio failed!", __func__);
|
||||
goto sdioInitFail;
|
||||
}
|
||||
ret = HdfSdioSetBlk(dev, busCfg->blockSize);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s: set sdio block size failed!", __func__);
|
||||
goto sdioInitFail;
|
||||
}
|
||||
SdioReleaseHost(handle);
|
||||
HDF_LOGI("%s: sdio bus init success!", __func__);
|
||||
return ret;
|
||||
|
||||
sdioInitFail:
|
||||
SdioClose(handle);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
static void HdfSetBusOps(struct BusDev *dev)
|
||||
{
|
||||
dev->ops.getBusInfo = HdfGetSdioInfo;
|
||||
dev->ops.deInit = HdfSdioReleaseDev;
|
||||
dev->ops.init = HdfSdioInit;
|
||||
|
||||
dev->ops.readData = HdfSdioReadN;
|
||||
dev->ops.writeData = HdfSdioWriteN;
|
||||
dev->ops.bulkRead = HdfSdioReadSpcReg;
|
||||
dev->ops.bulkWrite = HdfSdioWriteSpcReg;
|
||||
dev->ops.readFunc0 = HdfSdioReadFunc0;
|
||||
dev->ops.writeFunc0 = HdfSdioWriteFunc0;
|
||||
|
||||
dev->ops.claimIrq = HdfSdioCliamIrq;
|
||||
dev->ops.releaseIrq = HdfSdioReleaseIrq;
|
||||
dev->ops.disableBus = HdfSdioDisableFunc;
|
||||
dev->ops.reset = HdfSdioReset;
|
||||
|
||||
dev->ops.claimHost = HdfSdioClaimHost;
|
||||
dev->ops.releaseHost = HdfSdioReleaseHost;
|
||||
}
|
||||
int32_t HdfSdioBusInit(struct BusDev *dev, const struct HdfConfigWlanBus *busConfig)
|
||||
{
|
||||
if (dev == NULL) {
|
||||
HDF_LOGE("%s:set sdio device ops failed!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
HdfSetBusOps(dev);
|
||||
return HdfSdioInit(dev, busConfig);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
32
model/network/wifi/bus/hdf_sdio_intf.h
Normal file
32
model/network/wifi/bus/hdf_sdio_intf.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
|
||||
*
|
||||
* HDF is dual licensed: you can use it either under the terms of
|
||||
* the GPL, or the BSD license, at your option.
|
||||
* See the LICENSE file in the root of this repository for complete details.
|
||||
*/
|
||||
|
||||
#ifndef HDF_SDIO_INTF_H
|
||||
#define HDF_SDIO_INTF_H
|
||||
|
||||
#include "hdf_base.h"
|
||||
#include "hdf_ibus_intf.h"
|
||||
#include "hdf_log.h"
|
||||
#include "securec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32_t HdfSdioBusInit(struct BusDev *dev, const struct HdfConfigWlanBus *busConfig);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "message/message_router.h"
|
||||
#include "hdf_wlan_chipdriver_manager.h"
|
||||
#include "hdf_wlan_sdio.h"
|
||||
#include "hdf_wlan_sdio.h"
|
||||
#include "hdf_wlan_config.h"
|
||||
#include "hdf_wlan_utils.h"
|
||||
|
||||
@ -39,18 +38,21 @@ int32_t HdfWifiGetBusIdx(void)
|
||||
* @brief as for now, we just support one wlan module in one board cause driver binds to wlan featere
|
||||
* due to that reason, once we detected one chip, we stop rescan.
|
||||
*/
|
||||
int32_t HdfWlanSdioScan(struct HdfWlanDevice *data, struct HdfConfigWlanBus *busConfig)
|
||||
int HdfWlanBusInit(struct HdfWlanDevice *data, const struct HdfConfigWlanBus *busConfig)
|
||||
{
|
||||
/* get config vendId, deviceId and chip-name which used in detect match process */
|
||||
HdfWlanGetSdioTableByConfig();
|
||||
|
||||
HdfWlanSdioScanTriggerByBusIndex(busConfig->busIdx);
|
||||
int32_t ret = HdfWlanGetDetectedChip(data, busConfig);
|
||||
HdfWlanSdioDriverUnReg();
|
||||
if (ret != HDF_SUCCESS) {
|
||||
return ret;
|
||||
struct BusDev *bus = NULL;
|
||||
bus = HdfWlanCreateBusManager(busConfig);
|
||||
if (bus == NULL) {
|
||||
HDF_LOGE("%s:Create bus manager failed!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
HDF_LOGI("driver name = %s", __func__, data->driverName);
|
||||
data->bus = bus;
|
||||
if (bus->priData.driverName == NULL) {
|
||||
HDF_LOGE("%s:get driver name failed!", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
data->driverName = bus->priData.driverName;
|
||||
HDF_LOGI("%s: driver name = %s", __func__, data->driverName);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
@ -324,6 +326,10 @@ inline static void ReleaseWlanDevice(struct HdfWlanDevice *device)
|
||||
device->reset->Release(device->reset);
|
||||
device->reset = NULL;
|
||||
}
|
||||
if (device->bus != NULL && device->bus->ops.deInit != NULL) {
|
||||
device->bus->ops.deInit(device->bus);
|
||||
device->bus = NULL;
|
||||
}
|
||||
OsalMemFree(device);
|
||||
}
|
||||
|
||||
@ -355,7 +361,7 @@ static struct HdfWlanDevice *ProbeDevice(struct HdfConfigWlanDevInst *deviceConf
|
||||
break;
|
||||
}
|
||||
|
||||
ret = HdfWlanSdioScan(device, &deviceConfig->bus);
|
||||
ret = HdfWlanBusInit(device, &deviceConfig->bus);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("%s:NO Sdio Card in hdf wlan init proc", __func__);
|
||||
break;
|
||||
@ -546,3 +552,4 @@ struct HdfDriverEntry g_hdfWifiEntry = {
|
||||
};
|
||||
|
||||
HDF_INIT(g_hdfWifiEntry);
|
||||
|
||||
|
@ -19,11 +19,6 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void HdfWlanGetSdioTableByConfig(void);
|
||||
void HdfWlanSdioScanTriggerByBusIndex(int32_t busIdex);
|
||||
void HdfWlanSdioDriverUnReg(void);
|
||||
int HdfWlanGetDetectedChip(struct HdfWlanDevice *device, const struct HdfConfigWlanBus *busConfig);
|
||||
|
||||
int32_t HdfWlanConfigSDIO(uint8_t busId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -34,3 +29,4 @@ int32_t HdfWlanConfigSDIO(uint8_t busId);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user