Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party FreeBSD
提交
352cfb27
T
Third Party FreeBSD
项目概览
OpenHarmony
/
Third Party FreeBSD
接近 2 年 前同步成功
通知
3
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party FreeBSD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
352cfb27
编写于
8月 05, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 05, 2021
浏览文件
操作
浏览文件
下载
差异文件
!22 usb support liteos
Merge pull request !22 from zianed/master
上级
666370ea
640a05a9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
258 addition
and
12 deletion
+258
-12
stand/usb/usb_busdma_loader.c
stand/usb/usb_busdma_loader.c
+4
-0
sys/compat/linuxkpi/common/include/linux/usb.h
sys/compat/linuxkpi/common/include/linux/usb.h
+3
-1
sys/compat/linuxkpi/common/src/linux_usb.c
sys/compat/linuxkpi/common/src/linux_usb.c
+149
-3
sys/dev/usb/implementation/usb_api_pri.h
sys/dev/usb/implementation/usb_api_pri.h
+10
-0
sys/dev/usb/implementation/usb_init.c
sys/dev/usb/implementation/usb_init.c
+65
-7
sys/dev/usb/implementation/usb_init.h
sys/dev/usb/implementation/usb_init.h
+2
-1
sys/dev/usb/usb_device.c
sys/dev/usb/usb_device.c
+11
-0
sys/kern/subr_bus.c
sys/kern/subr_bus.c
+14
-0
未找到文件。
stand/usb/usb_busdma_loader.c
浏览文件 @
352cfb27
...
...
@@ -340,7 +340,11 @@ usb_pc_load_mem(struct usb_page_cache *pc, usb_size_t size, uint8_t data_sync)
if
(
size
>
0
)
{
/* compute physical address */
#if defined (LOSCFG_DRIVERS_HDF_USB_DDK_HOST) || defined (LOSCFG_DRIVERS_HDF_USB_DDK_DEVICE)
usb_pc_common_mem_cb
(
pc
,
(
void
*
)
VMM_TO_UNCACHED_ADDR
((
unsigned
long
)
pc
->
buffer
),
size
);
#else
usb_pc_common_mem_cb
(
pc
,
(
void
*
)(
UINTPTR
)
LOS_DmaVaddrToPaddr
(
pc
->
buffer
),
size
);
#endif
}
if
(
data_sync
==
0
)
{
/*
...
...
sys/compat/linuxkpi/common/include/linux/usb.h
浏览文件 @
352cfb27
...
...
@@ -280,7 +280,9 @@ struct urb {
};
/* various prototypes */
#ifdef LOSCFG_DRIVERS_HDF_USB_DDK_HOST
int
usb_create_usb_device
(
struct
usb_device
*
udev
);
#endif
int
usb_submit_urb
(
struct
urb
*
urb
,
uint16_t
mem_flags
);
int
usb_unlink_urb
(
struct
urb
*
urb
);
int
usb_clear_halt
(
struct
usb_device
*
dev
,
struct
usb_host_endpoint
*
uhe
);
...
...
sys/compat/linuxkpi/common/src/linux_usb.c
浏览文件 @
352cfb27
...
...
@@ -824,6 +824,7 @@ usb_setup_endpoint_agg(struct usb_device *dev,
/* Allocate and setup one generic FreeBSD USB transfer */
cfg
[
0
].
type
=
type
;
#ifndef LOSCFG_DRIVERS_HDF_USB_DDK_HOST
cfg
[
0
].
endpoint
=
addr
&
UE_ADDR
;
cfg
[
0
].
direction
=
addr
&
(
UE_DIR_OUT
|
UE_DIR_IN
);
if
(
packets
>
0
)
...
...
@@ -832,8 +833,27 @@ usb_setup_endpoint_agg(struct usb_device *dev,
cfg
[
0
].
bufsize
=
bufsize
;
cfg
[
0
].
flags
.
ext_buffer
=
1
;
/* enable zero-copy */
cfg
[
0
].
flags
.
proxy_buffer
=
1
;
cfg
[
0
].
flags
.
short_xfer_ok
=
1
;
#else
cfg
[
0
].
endpoint
=
UE_ADDR_ANY
;
cfg
[
0
].
direction
=
addr
&
(
UE_DIR_OUT
|
UE_DIR_IN
);
if
(
packets
>
0
){
cfg
[
0
].
frames
=
packets
<=
USB_FRAMES_MAX
?
packets
:
USB_FRAMES_MAX
;
}
cfg
[
0
].
callback
=
&
usb_linux_non_isoc_callback
;
cfg
[
0
].
bufsize
=
bufsize
;
cfg
[
0
].
frames
=
4
;
cfg
[
0
].
flags
.
pipe_bof
=
1
;
if
(
type
==
UE_INTERRUPT
){
cfg
[
0
].
flags
.
no_pipe_ok
=
1
;
cfg
[
0
].
bufsize
=
0
;
cfg
[
0
].
direction
=
UE_DIR_IN
;
}
if
(
addr
&
UE_DIR_IN
){
cfg
[
0
].
flags
.
short_xfer_ok
=
1
;
}
else
{
cfg
[
0
].
flags
.
force_short_xfer
=
1
;
}
#endif
if
(
usbd_transfer_setup
(
dev
,
&
uhe
->
bsd_iface_index
,
uhe
->
bsd_xfer
,
cfg
,
1
,
uhe
,
&
Gcall
))
{
return
(
-
EINVAL
);
...
...
@@ -978,6 +998,128 @@ usb_linux_create_usb_device(struct usb_device *udev, device_t dev)
return
(
0
);
}
#ifdef LOSCFG_DRIVERS_HDF_USB_DDK_HOST
int
usb_create_usb_device
(
struct
usb_device
*
udev
)
{
struct
usb_config_descriptor
*
cd
=
usbd_get_config_descriptor
(
udev
);
struct
usb_descriptor
*
desc
;
struct
usb_interface_descriptor
*
id
;
struct
usb_endpoint_descriptor
*
ed
;
struct
usb_interface
*
p_ui
=
NULL
;
struct
usb_host_interface
*
p_uhi
=
NULL
;
struct
usb_host_endpoint
*
p_uhe
=
NULL
;
usb_size_t
size
;
uint16_t
niface_total
;
uint16_t
nedesc
;
uint16_t
iface_no_curr
;
uint16_t
iface_index
;
uint8_t
pass
;
uint8_t
iface_no
;
/*
* We do two passes. One pass for computing necessary memory size
* and one pass to initialize all the allocated memory structures.
*/
for
(
pass
=
0
;
pass
<
2
;
pass
++
)
{
iface_no_curr
=
0xFFFF
;
niface_total
=
0
;
iface_index
=
0
;
nedesc
=
0
;
desc
=
NULL
;
/*
* Iterate over all the USB descriptors. Use the USB config
* descriptor pointer provided by the FreeBSD USB stack.
*/
while
((
desc
=
usb_desc_foreach
(
cd
,
desc
)))
{
/*
* Build up a tree according to the descriptors we
* find:
*/
switch
(
desc
->
bDescriptorType
)
{
case
UDESC_DEVICE
:
break
;
case
UDESC_ENDPOINT
:
ed
=
(
void
*
)
desc
;
if
((
ed
->
bLength
<
sizeof
(
*
ed
))
||
(
iface_index
==
0
))
break
;
if
(
p_uhe
!=
NULL
)
{
usb_bcopy
(
ed
,
&
p_uhe
->
desc
,
sizeof
(
p_uhe
->
desc
));
p_uhe
->
bsd_iface_index
=
iface_index
-
1
;
TAILQ_INIT
(
&
p_uhe
->
bsd_urb_list
);
p_uhe
++
;
}
if
(
p_uhi
!=
NULL
)
{
(
p_uhi
-
1
)
->
desc
.
bNumEndpoints
++
;
}
nedesc
++
;
break
;
case
UDESC_INTERFACE
:
id
=
(
void
*
)
desc
;
if
(
id
->
bLength
<
sizeof
(
*
id
))
break
;
if
(
p_uhi
!=
NULL
)
{
usb_bcopy
(
id
,
&
p_uhi
->
desc
,
sizeof
(
p_uhi
->
desc
));
p_uhi
->
desc
.
bNumEndpoints
=
0
;
p_uhi
->
endpoint
=
p_uhe
;
p_uhi
->
string
=
""
;
p_uhi
->
bsd_iface_index
=
iface_index
;
p_uhi
++
;
}
iface_no
=
id
->
bInterfaceNumber
;
niface_total
++
;
if
(
iface_no_curr
!=
iface_no
)
{
if
(
p_ui
)
{
p_ui
->
altsetting
=
p_uhi
-
1
;
p_ui
->
cur_altsetting
=
p_uhi
-
1
;
p_ui
->
num_altsetting
=
1
;
p_ui
->
bsd_iface_index
=
iface_index
;
p_ui
->
linux_udev
=
udev
;
p_ui
++
;
}
iface_no_curr
=
iface_no
;
iface_index
++
;
}
else
{
if
(
p_ui
)
{
(
p_ui
-
1
)
->
num_altsetting
++
;
}
}
break
;
default:
break
;
}
}
if
(
pass
==
0
)
{
size
=
(
sizeof
(
*
p_uhe
)
*
nedesc
)
+
(
sizeof
(
*
p_ui
)
*
iface_index
)
+
(
sizeof
(
*
p_uhi
)
*
niface_total
);
p_uhe
=
zalloc
(
size
);
if
(
p_uhe
==
NULL
)
{
return
(
-
1
);
}
p_ui
=
(
void
*
)(
p_uhe
+
nedesc
);
p_uhi
=
(
void
*
)(
p_ui
+
iface_index
);
udev
->
linux_iface_start
=
p_ui
;
udev
->
linux_iface_end
=
p_ui
+
iface_index
;
udev
->
linux_endpoint_start
=
p_uhe
;
udev
->
linux_endpoint_end
=
p_uhe
+
nedesc
;
usb_bcopy
(
&
udev
->
ddesc
,
&
udev
->
descriptor
,
sizeof
(
udev
->
descriptor
));
usb_bcopy
(
udev
->
ctrl_ep
.
edesc
,
&
udev
->
ep0
.
desc
,
sizeof
(
udev
->
ep0
.
desc
));
}
}
return
(
0
);
}
#endif
/*------------------------------------------------------------------------*
* usb_alloc_urb
*
...
...
@@ -1669,6 +1811,10 @@ setup_bulk:
usbd_copy_in
(
xfer
->
frbuffers
+
data_frame
,
0
,
urb
->
bsd_data_ptr
,
max_bulk
);
usbd_xfer_set_frame_len
(
xfer
,
data_frame
,
max_bulk
);
}
else
{
#ifdef LOSCFG_DRIVERS_HDF_USB_DDK_HOST
usbd_xfer_set_frame_len
(
xfer
,
data_frame
,
max_bulk
);
#endif
}
if
(
xfer
->
flags_int
.
control_xfr
)
{
if
(
max_bulk
>
0
)
{
...
...
@@ -1753,7 +1899,7 @@ usb_bulk_msg(struct usb_device *udev, struct usb_host_endpoint *uhe,
if
(
len
<
0
)
return
(
-
EINVAL
);
err
=
usb_setup_endpoint
(
udev
,
uhe
,
4096
/* bytes */
);
err
=
usb_setup_endpoint
(
udev
,
uhe
,
2048
/* bytes */
);
if
(
err
)
return
(
err
);
...
...
sys/dev/usb/implementation/usb_api_pri.h
浏览文件 @
352cfb27
...
...
@@ -88,6 +88,16 @@ extern struct driver_module_data usb_linux_uhub_driver_mod;
extern
struct
driver_module_data
uhid_uhub_driver_mod
;
#endif
extern
struct
driver_module_data
composite_hiudc3_driver_mod
;
extern
struct
driver_module_data
fcdcacm_simple_driver_mod
;
extern
struct
driver_module_data
fconfig_simple_driver_mod
;
extern
int
hiudc3_init
(
void
);
extern
int
usbd_load_driver
(
void
);
extern
int
usbd_start_udc
(
void
);
extern
int
usbd_enable_interrupt
(
void
);
#ifdef LOSCFG_DRIVERS_USB_HOST_XHCI
int
hixhci_init
(
void
);
#endif
...
...
sys/dev/usb/implementation/usb_init.c
浏览文件 @
352cfb27
...
...
@@ -31,7 +31,8 @@
#include "usb_init.h"
#include "usb_api_pri.h"
#include "devsvc_manager_clnt.h"
#include "hdf_device_desc.h"
typedef
struct
usb_info
{
bool
b_init
;
...
...
@@ -62,7 +63,9 @@ static struct driver_module_data* usb_driver_mode_list[] = {
#endif
#ifdef LOSCFG_DRIVERS_USB_4G_MODEM
#ifndef LOSCFG_DRIVERS_HDF_USB_DDK_HOST
&
cdce_uhub_driver_mod
,
#endif
//&bsd_u3g_uhub_driver_mod,
#endif
...
...
@@ -90,9 +93,16 @@ static struct driver_module_data* usb_driver_mode_list[] = {
#if defined (LOSCFG_DRIVERS_USB_HID_CLASS) && defined (LOSCFG_DRIVERS_HDF_INPUT)
&
uhid_uhub_driver_mod
,
#endif
#ifdef LOSCFG_DRIVERS_HDF_USB_DDK_DEVICE
&
composite_hiudc3_driver_mod
,
#endif
NULL
};
extern
device_t
bus_get_device
(
device_t
dev
,
const
char
*
name
);
void
usbinfo_clean
(
void
)
{
...
...
@@ -151,7 +161,44 @@ usb_unloadonce(void)
return
;
}
#ifdef LOSCFG_DRIVERS_HDF_USB_DDK_DEVICE
static
int
composite_add
(
void
)
{
device_t
udc
;
device_t
composite
;
udc
=
bus_get_device
(
nexus
,
"hiudc3"
);
if
(
udc
==
NULL
)
{
return
-
1
;
}
composite
=
device_add_child
(
udc
,
"composite"
,
-
1
);
if
(
composite
==
NULL
)
{
return
-
1
;
}
if
(
device_probe_and_attach
(
composite
))
{
device_printf
(
composite
,
"WARNING: Probe and attach failed!
\n
"
);
return
-
1
;
}
struct
HdfDeviceObject
*
devObj
=
HdfRegisterDevice
(
"usbfn_master"
,
"usbfn_master"
,
NULL
);
if
(
devObj
==
NULL
)
{
dprintf
(
"%s register usbfn_master may failed
\n
"
,
__func__
);
}
devObj
=
HdfRegisterDevice
(
"usbfn_cdcacm"
,
"usbfn_cdcacm"
,
NULL
);
if
(
devObj
==
NULL
)
{
dprintf
(
"%s register usbfn_cdcacm may failed
\n
"
,
__func__
);
}
devObj
=
HdfRegisterDevice
(
"usbfn_cdcecm"
,
"usbfn_cdcecm"
,
NULL
);
if
(
devObj
==
NULL
)
{
dprintf
(
"%s register usbfn_cdcecm may failed
\n
"
,
__func__
);
}
dprintf
(
"%s success
\n
"
,
__func__
);
return
0
;
}
#endif
/*
* step1: modify DRIVER_MODULE,register all driver module
* step2: make ehci/ohci device (direct skip pci bus)
...
...
@@ -192,12 +239,23 @@ usb_init(controller_type ctype, device_type dtype)
ret
=
hiehci_init
();
#endif
}
else
{
PRINT_ERR
(
"controller type %d dtype %d is error
\n
"
,
ctype
,
dtype
);
goto
err
;
}
if
(
ret
!=
LOS_OK
)
{
goto
err
;
#ifdef LOSCFG_DRIVERS_HDF_USB_DDK_DEVICE
ret
=
usbd_load_driver
();
if
(
ret
!=
LOS_OK
)
{
dprintf
(
"usbd_load_driver failed ,ret = %d
\n
"
,
ret
);
goto
err
;
}
ret
=
composite_add
();
if
(
ret
!=
LOS_OK
)
{
dprintf
(
"composite_add failed ,ret = %d
\n
"
,
ret
);
goto
err
;
}
ret
=
usbd_enable_interrupt
();
if
(
ret
!=
LOS_OK
)
{
dprintf
(
"usbd_enable_interrupt failed, ret = %d
\n
"
,
ret
);
goto
err
;
}
#endif
}
usb_info
.
b_init
=
true
;
...
...
sys/dev/usb/implementation/usb_init.h
浏览文件 @
352cfb27
...
...
@@ -59,7 +59,8 @@ typedef enum device_type {
DEV_UVC
,
/* used for USB video */
DEV_UAC
,
/* used for USB audio */
DEV_CAMERA
,
/* used for USB camera */
DEV_HID
/* used for USB hid */
DEV_HID
,
/* used for USB hid */
DEV_GENERIC
,
/* used for USB generic */
}
device_type
;
/*
...
...
sys/dev/usb/usb_device.c
浏览文件 @
352cfb27
...
...
@@ -26,6 +26,9 @@
#include "implementation/global_implementation.h"
#include "fs/driver.h"
#ifdef LOSCFG_DRIVERS_HDF_USB_PNP_NOTIFY
#include "usb_pnp_notify.h"
#endif
#undef USB_DEBUG_VAR
#define USB_DEBUG_VAR usb_debug
...
...
@@ -1846,6 +1849,10 @@ config_done:
device_get_nameunit
(
udev
->
bus
->
bdev
));
#endif
#ifdef LOSCFG_DRIVERS_HDF_USB_PNP_NOTIFY
UsbPnpNotifyDevice
(
"ATTACH"
,
udev
);
#endif
#if USB_HAVE_DEVCTL
usb_notify_addq
(
"ATTACH"
,
udev
);
#endif
...
...
@@ -2025,6 +2032,10 @@ usb_free_device(struct usb_device *udev, uint8_t flag)
/* set DETACHED state to prevent any further references */
usb_set_device_state
(
udev
,
USB_STATE_DETACHED
);
#ifdef LOSCFG_DRIVERS_HDF_USB_PNP_NOTIFY
UsbPnpNotifyDevice
(
"DETACH"
,
udev
);
#endif
#if USB_HAVE_DEVCTL
usb_notify_addq
(
"DETACH"
,
udev
);
#endif
...
...
sys/kern/subr_bus.c
浏览文件 @
352cfb27
...
...
@@ -1441,6 +1441,20 @@ device_add_child(device_t dev, const char *name, int unit)
return
(
device_add_child_ordered
(
dev
,
0
,
name
,
unit
));
}
device_t
bus_get_device
(
device_t
dev
,
const
char
*
name
)
{
device_t
child
;
PDEBUG
((
"+"
));
TAILQ_FOREACH
(
child
,
&
dev
->
children
,
link
)
{
if
(
!
strcmp
(
device_get_name
(
child
),
name
))
return
(
child
);
}
PDEBUG
((
"-"
));
return
(
NULL
);
}
/**
* @brief Create a new device
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录