!994 modify HDF wlan bus, support either sdio or usb

Merge pull request !994 from bayanxing/master
This commit is contained in:
openharmony_ci
2022-06-01 06:24:49 +00:00
committed by Gitee
10 changed files with 290 additions and 75 deletions
+4 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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.
@@ -74,6 +74,9 @@ struct BusDev {
};
struct BusDev *HdfWlanCreateBusManager(const struct HdfConfigWlanBus *busConfig);
int32_t HdfWlanBusAbsInit(struct BusDev *dev, const struct HdfConfigWlanBus *busConfig);
int32_t HdfWlanConfigBusAbs(uint8_t busId);
#ifdef __cplusplus
#if __cplusplus
+2 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) 2020-2022 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.
@@ -79,6 +79,7 @@ enum WifiMainFeatureType {
enum WifiBusType {
BUS_SDIO, /**< Secure Digital Input and Output (SDIO) */
BUS_USB, /**< Universal Serial Bus (USB) */
BUS_BUTT,
};
#ifdef __cplusplus
+14 -13
View File
@@ -1,15 +1,18 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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"
#include "hdf_log.h"
#include "hdf_wlan_config.h"
#include "hdf_base.h"
#include "hdf_ibus_intf.h"
#ifdef __cplusplus
#if __cplusplus
@@ -23,21 +26,19 @@ struct BusDev *HdfWlanCreateBusManager(const struct HdfConfigWlanBus *busConfig)
if (busConfig == NULL) {
return NULL;
}
if (busConfig->busType >= BUS_BUTT) {
HDF_LOGE("%s:bus type %u not support!", __func__, busConfig->busType);
return NULL;
}
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;
if (HdfWlanBusAbsInit(bus, busConfig) != HDF_SUCCESS) {
OsalMemFree(bus);
return NULL;
}
return bus;
}
+14 -5
View File
@@ -1,15 +1,19 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 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"
#include "hdf_wlan_sdio.h"
#include "hdf_base.h"
#include "hdf_ibus_intf.h"
#include "hdf_log.h"
#include "securec.h"
#ifdef __cplusplus
#if __cplusplus
@@ -289,8 +293,8 @@ static struct DevHandle *HdfGetDevHandle(struct BusDev *dev, const struct HdfCon
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].deviceId = tmpChipList->chipInst[cnt].chipBus.deviceId[0];
palSdioConfig[cnt].vendorId = tmpChipList->chipInst[cnt].chipBus.vendorId;
palSdioConfig[cnt].funcNr = busCfg->funcNum[0];
handle = SdioOpen(busCfg->busIdx, &palSdioConfig[cnt]);
if (handle != NULL) {
@@ -368,7 +372,7 @@ static void HdfSetBusOps(struct BusDev *dev)
dev->ops.claimHost = HdfSdioClaimHost;
dev->ops.releaseHost = HdfSdioReleaseHost;
}
int32_t HdfSdioBusInit(struct BusDev *dev, const struct HdfConfigWlanBus *busConfig)
int32_t HdfWlanBusAbsInit(struct BusDev *dev, const struct HdfConfigWlanBus *busConfig)
{
if (dev == NULL) {
HDF_LOGE("%s:set sdio device ops failed!", __func__);
@@ -378,6 +382,11 @@ int32_t HdfSdioBusInit(struct BusDev *dev, const struct HdfConfigWlanBus *busCon
return HdfSdioInit(dev, busConfig);
}
int32_t HdfWlanConfigBusAbs(uint8_t busId)
{
return HdfWlanConfigSDIO(busId);
}
#ifdef __cplusplus
#if __cplusplus
}
-32
View File
@@ -1,32 +0,0 @@
/*
* 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
+238
View File
@@ -0,0 +1,238 @@
/*
* Copyright (c) 2022 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 "osal_mem.h"
#include "wifi_inc.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
static int32_t HdfGetUsbInfo(struct BusDev *dev, struct BusConfig *busCfg)
{
(void)dev;
(void)busCfg;
HDF_LOGI("%s:get usb info", __func__);
return HDF_SUCCESS;
}
static void HdfUsbReleaseDev(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 HdfUsbEnableFunc(struct BusDev *dev)
{
(void)dev;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbDisableFunc(struct BusDev *dev)
{
(void)dev;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbCliamIrq(struct BusDev *dev, IrqHandler *handler, void *data)
{
(void)dev;
(void)handler;
(void)data;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static void HdfUsbClaimHost(struct BusDev *dev)
{
(void)dev;
HDF_LOGI("%s:", __func__);
}
static void HdfUsbReleaseHost(struct BusDev *dev)
{
(void)dev;
HDF_LOGI("%s:", __func__);
}
static int32_t HdfUsbReleaseIrq(struct BusDev *dev)
{
(void)dev;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbReset(struct BusDev *dev)
{
(void)dev;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbReadN(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
{
(void)dev;
(void)addr;
(void)cnt;
(void)buf;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbReadFunc0(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
{
(void)dev;
(void)addr;
(void)cnt;
(void)buf;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbReadSpcReg(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf, uint32_t sg_len)
{
(void)dev;
(void)addr;
(void)cnt;
(void)buf;
(void)sg_len;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbWriteN(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
{
(void)dev;
(void)addr;
(void)cnt;
(void)buf;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbWriteFunc0(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf)
{
(void)dev;
(void)addr;
(void)cnt;
(void)buf;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbWriteSpcReg(struct BusDev *dev, uint32_t addr, uint32_t cnt, uint8_t *buf, uint32_t sg_len)
{
(void)dev;
(void)addr;
(void)cnt;
(void)buf;
(void)sg_len;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static int32_t HdfUsbSetBlk(struct BusDev *dev, uint32_t blkSize)
{
(void)dev;
(void)blkSize;
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static struct DevHandle *HdfGetDevHandle(struct BusDev *dev, const struct HdfConfigWlanBus *busCfg)
{
int32_t cnt;
struct HdfConfigWlanChipList *tmpChipList = NULL;
(void)busCfg;
struct HdfConfigWlanRoot *rootConfig = HdfWlanGetModuleConfigRoot();
if (rootConfig == NULL) {
HDF_LOGE("%s: NULL ptr!", __func__);
return NULL;
}
tmpChipList = &rootConfig->wlanConfig.chipList;
cnt = 0;
if (cnt == tmpChipList->chipInstSize || cnt == WLAN_MAX_CHIP_NUM) {
HDF_LOGE("%s: NO usb card detected!", __func__);
return NULL;
}
dev->devBase = NULL;
dev->priData.driverName = tmpChipList->chipInst[cnt].driverName;
return NULL;
}
static int32_t HdfUsbInit(struct BusDev *dev, const struct HdfConfigWlanBus *busCfg)
{
if (dev == NULL || busCfg == NULL) {
HDF_LOGE("%s: input parameter error!", __func__);
return HDF_FAILURE;
}
(void)HdfGetDevHandle(dev, busCfg);
HDF_LOGI("%s:", __func__);
return HDF_SUCCESS;
}
static void HdfSetBusOps(struct BusDev *dev)
{
dev->ops.getBusInfo = HdfGetUsbInfo;
dev->ops.deInit = HdfUsbReleaseDev;
dev->ops.init = HdfUsbInit;
dev->ops.readData = HdfUsbReadN;
dev->ops.writeData = HdfUsbWriteN;
dev->ops.bulkRead = HdfUsbReadSpcReg;
dev->ops.bulkWrite = HdfUsbWriteSpcReg;
dev->ops.readFunc0 = HdfUsbReadFunc0;
dev->ops.writeFunc0 = HdfUsbWriteFunc0;
dev->ops.claimIrq = HdfUsbCliamIrq;
dev->ops.releaseIrq = HdfUsbReleaseIrq;
dev->ops.disableBus = HdfUsbDisableFunc;
dev->ops.reset = HdfUsbReset;
dev->ops.claimHost = HdfUsbClaimHost;
dev->ops.releaseHost = HdfUsbReleaseHost;
}
int32_t HdfWlanBusAbsInit(struct BusDev *dev, const struct HdfConfigWlanBus *busConfig)
{
if (dev == NULL) {
HDF_LOGE("%s:set usb device ops failed!", __func__);
return HDF_FAILURE;
}
HdfSetBusOps(dev);
return HdfUsbInit(dev, busConfig);
}
int32_t HdfWlanConfigBusAbs(uint8_t busId)
{
(void)busId;
return HDF_SUCCESS;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
+4 -9
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) 2020-2022 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.
@@ -18,7 +18,6 @@
#include "osal_thread.h"
#include "message/message_router.h"
#include "hdf_wlan_chipdriver_manager.h"
#include "hdf_wlan_sdio.h"
#include "hdf_wlan_config.h"
#include "hdf_wlan_utils.h"
@@ -137,7 +136,7 @@ static int32_t HdfWlanGetConfig(const struct HdfDeviceObject *device)
return HDF_SUCCESS;
}
#ifndef CONFIG_DRIVERS_HDF_NETDEV_EXT
#ifndef CONFIG_AP6XXX_WIFI6_HDF
static int32_t HdfWlanPowerOnProcess(struct PowerManager *powerMgr)
{
if (powerMgr == NULL) {
@@ -361,7 +360,7 @@ static struct HdfWlanDevice *ProbeDevice(struct HdfConfigWlanDevInst *deviceConf
device->powers = HdfWlanCreatePowerManager(&deviceConfig->powers);
device->reset = HdfWlanCreateResetManager(&deviceConfig->reset, deviceConfig->bootUpTimeOut);
#ifndef CONFIG_DRIVERS_HDF_NETDEV_EXT
#ifndef CONFIG_AP6XXX_WIFI6_HDF
ret = HdfWlanPowerOnProcess(device->powers);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s:HdfWlanPowerOnProcess failed!", __func__);
@@ -471,11 +470,7 @@ static int32_t HdfWlanInitThread(void *para)
return HDF_SUCCESS;
}
for (i = 0; i < devList->deviceListSize; i++) {
#ifndef CONFIG_DRIVERS_HDF_NETDEV_EXT
ret = HdfWlanConfigSDIO(devList->deviceInst[i].bus.busIdx);
#else
ret = HDF_SUCCESS;
#endif
ret = HdfWlanConfigBusAbs(devList->deviceInst[i].bus.busIdx);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s:HdfWlanConfigSDIO %d failed!ret=%d", __func__, devList->deviceInst[i].bus.busIdx, ret);
continue;
+4 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) 2020-2022 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.
@@ -12,7 +12,7 @@
#define WLAN_DEVICE_MAX 3
#define WLAN_MAX_CHIP_NUM 3
#define BUS_FUNC_MAX 1
#define CHIP_SDIO_DEVICE_ID_COUNT 1
#define CHIP_BUS_DEVICE_ID_COUNT 1
struct HdfConfigWlanStation {
const char *name;
@@ -97,13 +97,13 @@ struct HdfConfigWlanDeviceList {
/* ----------------------------------------------*
* chip config *
* ---------------------------------------------- */
struct HdfConfWlanSdioArgs {
struct HdfConfWlanBusArgs {
uint16_t vendorId;
uint16_t deviceId[1];
};
struct HdfConfigWlanChipInst {
const char *driverName;
struct HdfConfWlanSdioArgs chipSdio;
struct HdfConfWlanBusArgs chipBus;
};
struct HdfConfigWlanChipList {
struct HdfConfigWlanChipInst chipInst[WLAN_MAX_CHIP_NUM];
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) 2020-2022 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.
@@ -432,10 +432,10 @@ static int32_t ParseWlanDevListConfig(const struct DeviceResourceNode *node, str
}
/* BEGIN for WLAN2.1 to get chips configures: Added by hdf-wlan */
static int32_t ParseWlanChipSdioConfig(const struct DeviceResourceNode *node, struct HdfConfWlanSdioArgs *sdioArgs)
static int32_t ParseWlanChipBusConfig(const struct DeviceResourceNode *node, struct HdfConfWlanBusArgs *busArgs)
{
struct DeviceResourceIface *drsOps = NULL;
if (node == NULL || sdioArgs == NULL) {
if (node == NULL || busArgs == NULL) {
HDF_LOGE("%s: at least one of the paras is NULL!", __func__);
return HDF_FAILURE;
}
@@ -445,11 +445,11 @@ static int32_t ParseWlanChipSdioConfig(const struct DeviceResourceNode *node, st
return HDF_FAILURE;
}
if (drsOps->GetUint16(node, "vendorId", &sdioArgs->vendorId, 0) != HDF_SUCCESS) {
if (drsOps->GetUint16(node, "vendorId", &busArgs->vendorId, 0) != HDF_SUCCESS) {
HDF_LOGE("%s: vendorId fail!", __func__);
return HDF_FAILURE;
}
if (drsOps->GetUint16Array(node, "deviceId", sdioArgs->deviceId, CHIP_SDIO_DEVICE_ID_COUNT, 0) != HDF_SUCCESS) {
if (drsOps->GetUint16Array(node, "deviceId", busArgs->deviceId, CHIP_BUS_DEVICE_ID_COUNT, 0) != HDF_SUCCESS) {
HDF_LOGE("%s: deviceId fail!", __func__);
return HDF_FAILURE;
}
@@ -477,12 +477,12 @@ static int32_t ParseWlanChipsCompsConfig(const struct DeviceResourceNode *node,
}
HDF_LOGI("%s: driverName=%s", __func__, chipInst->driverName);
chipBusNode = drsOps->GetChildNode(node, "sdio");
chipBusNode = drsOps->GetChildNode(node, "bus");
if (chipBusNode == NULL) {
HDF_LOGE("%s: GetChildNode fail!", __func__);
return HDF_FAILURE;
}
if (ParseWlanChipSdioConfig(chipBusNode, &chipInst->chipSdio) != HDF_SUCCESS) {
if (ParseWlanChipBusConfig(chipBusNode, &chipInst->chipBus) != HDF_SUCCESS) {
return HDF_FAILURE;
}
@@ -45,8 +45,8 @@ int32_t HdfChipReset(struct ResetManager *resetManager)
}
resetMgrImpl = (struct ResetManagerImpl*)resetManager;
if (resetMgrImpl->resetData.resetCfg.resetType == RESET_ALWAYS_ON) {
HDF_LOGE("%s: the reset type is not managed", __func__);
return HDF_FAILURE;
HDF_LOGI("%s: the reset type is not managed", __func__);
return HDF_SUCCESS;
}
ret = GpioSetDir(resetMgrImpl->resetData.resetCfg.gpioId, GPIO_DIR_OUT);
if (ret != HDF_SUCCESS) {
@@ -103,4 +103,4 @@ struct ResetManager* HdfWlanCreateResetManager(const struct HdfConfWlanRest *con
resetMgrImpl->base.Release = HdfWlanResetMgrRelease;
return (struct ResetManager*)resetMgrImpl;
}
}