add KPU driver and resource in XiZi for edu-riscv64
This commit is contained in:
@@ -55,6 +55,7 @@ enum BusType_e
|
||||
TYPE_ADC_BUS,
|
||||
TYPE_DAC_BUS,
|
||||
TYPE_CAMERA_BUS,
|
||||
TYPE_KPU_BUS,
|
||||
TYPE_BUS_END,
|
||||
};
|
||||
|
||||
@@ -82,6 +83,7 @@ enum DevType
|
||||
TYPE_ADC_DEV,
|
||||
TYPE_DAC_DEV,
|
||||
TYPE_CAMERA_DEV,
|
||||
TYPE_KPU_DEV,
|
||||
TYPE_DEV_END,
|
||||
};
|
||||
|
||||
@@ -109,6 +111,7 @@ enum DriverType_e
|
||||
TYPE_ADC_DRV,
|
||||
TYPE_DAC_DRV,
|
||||
TYPE_CAMERA_DRV,
|
||||
TYPE_KPU_DRV,
|
||||
TYPE_DRV_END,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file bus_kpu.h
|
||||
* @brief define kpu bus and drv function using bus driver framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-12-19
|
||||
*/
|
||||
|
||||
#ifndef BUS_KPU_H
|
||||
#define BUS_KPU_H
|
||||
|
||||
#include <bus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct KpuDriver
|
||||
{
|
||||
struct Driver driver;
|
||||
|
||||
uint32 (*configure) (void *drv, struct BusConfigureInfo *configure_info);
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
struct KpuBus
|
||||
{
|
||||
struct Bus bus;
|
||||
|
||||
void *private_data;
|
||||
};
|
||||
|
||||
/*Register the KPU bus*/
|
||||
int KpuBusInit(struct KpuBus *kpu_bus, const char *bus_name);
|
||||
|
||||
/*Register the KPU driver*/
|
||||
int KpuDriverInit(struct KpuDriver *kpu_driver, const char *driver_name);
|
||||
|
||||
/*Release the KPU device*/
|
||||
int KpuReleaseBus(struct KpuBus *kpu_bus);
|
||||
|
||||
/*Register the KPU driver to the KPU bus*/
|
||||
int KpuDriverAttachToBus(const char *drv_name, const char *bus_name);
|
||||
|
||||
/*Register the driver, manage with the double linklist*/
|
||||
int KpuDriverRegister(struct Driver *driver);
|
||||
|
||||
/*Find the register driver*/
|
||||
DriverType KpuDriverFind(const char *drv_name, enum DriverType_e drv_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file dev_kpu.h
|
||||
* @brief define kpu dev function using bus driver framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022-12-19
|
||||
*/
|
||||
|
||||
#ifndef DEV_KPU_H
|
||||
#define DEV_KPU_H
|
||||
|
||||
#include <bus.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct KpuDataStandard
|
||||
{
|
||||
uint16 addr;
|
||||
uint16 flags;
|
||||
uint16 len;
|
||||
uint16 retries;
|
||||
uint8 *buf;
|
||||
|
||||
struct KpuDataStandard *next;
|
||||
};
|
||||
|
||||
struct KpuDevDone
|
||||
{
|
||||
uint32 (*dev_open) (void *kpu_device);
|
||||
uint32 (*dev_close) (void *kpu_device);
|
||||
uint32 (*dev_write) (void *kpu_device, struct BusBlockWriteParam *msg);
|
||||
uint32 (*dev_read) (void *kpu_device, struct BusBlockReadParam *msg);
|
||||
};
|
||||
|
||||
struct KpuHardwareDevice
|
||||
{
|
||||
struct HardwareDev haldev;
|
||||
const struct KpuDevDone *kpu_dev_done;
|
||||
};
|
||||
|
||||
/*Register the KPU device*/
|
||||
int KpuDeviceRegister(struct KpuHardwareDevice *kpu_device, void *kpu_param, const char *device_name);
|
||||
|
||||
/*Register the KPU device to the KPU bus*/
|
||||
int KpuDeviceAttachToBus(const char *dev_name, const char *bus_name);
|
||||
|
||||
/*Find the register KPU device*/
|
||||
HardwareDevType KpuDeviceFind(const char *dev_name, enum DevType dev_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -111,4 +111,9 @@ HardwareDevType ObtainConsole(void);
|
||||
#include <dev_camera.h>
|
||||
#endif
|
||||
|
||||
#ifdef RESOURCES_KPU
|
||||
#include <bus_kpu.h>
|
||||
#include <dev_kpu.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user