forked from xuos/xiuos
Re-design xhci functions to dock with USB core
This commit is contained in:
parent
97e0d1aa67
commit
04a0e2a0f6
|
@ -1 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright : (C) 2022 Phytium Information Technology, Inc.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
|
||||||
|
* either version 1.0 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Phytium Public License for more details.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* FilePath: usb_hc_xhci.c
|
||||||
|
* Date: 2022-09-19 17:24:36
|
||||||
|
* LastEditTime: 2022-09-19 17:24:36
|
||||||
|
* Description: This file is for xhci function implementation.
|
||||||
|
*
|
||||||
|
* Modify History:
|
||||||
|
* Ver Who Date Changes
|
||||||
|
* ----- ------ -------- --------------------------------------
|
||||||
|
* 1.0 zhugengyu 2022/9/19 init commit
|
||||||
|
* 1.1 zhugengyu 2022/10/9 add dumpers and fix command abort
|
||||||
|
* 2.0 zhugengyu 2023/3/29 support usb3.0 device attached at roothub
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
File name: usb_hc_xhci.h
|
||||||
|
Description: the xhci functions to dock with the USB core layer.
|
||||||
|
Others: take CherryUSB v0.1.2/CherryUSB/osal/usb_osal.h for references
|
||||||
|
https://github.com/cherry-embedded/CherryUSB/blob/v0.10.2/osal/usb_osal.h
|
||||||
|
History:
|
||||||
|
1. Date: 2024-06-17
|
||||||
|
Author: AIIT XUOS Lab
|
||||||
|
Modification: rewrite xhci functions to dock with USB core layer, so that the USB core can easily expand to other USB IP.
|
||||||
|
*************************************************/
|
||||||
#include "usb_hc_xhci.h"
|
#include "usb_hc_xhci.h"
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,90 @@
|
||||||
#define USB_HC_XHCI_H_
|
#define USB_HC_XHCI_H_
|
||||||
|
|
||||||
#include "xhci.h"
|
#include "xhci.h"
|
||||||
|
#include "usbh_core.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief xHCI host controller hardware init.
|
||||||
|
*
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usb_hc_init(uint32_t id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get frame number.
|
||||||
|
*
|
||||||
|
* @return frame number.
|
||||||
|
*/
|
||||||
|
uint16_t xhci_usbh_get_frame_number(void);
|
||||||
|
/**
|
||||||
|
* @brief control roothub.
|
||||||
|
*
|
||||||
|
* @param usb usb bus instance
|
||||||
|
* @param setup setup request buffer.
|
||||||
|
* @param buf buf for reading response or write data.
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usbh_roothub_control(struct usbh_bus *usb, struct usb_setup_packet *setup, uint8_t *buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief reconfig endpoint pipe.
|
||||||
|
*
|
||||||
|
* @param pipe A memory allocated for pipe.
|
||||||
|
* @param dev_addr device address.
|
||||||
|
* @param ep_mps endpoint max packet size.
|
||||||
|
* @param mult endpoint additional transcation
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usbh_ep_pipe_reconfigure(struct usbh_bus *usb, usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Allocate pipe for endpoint
|
||||||
|
*
|
||||||
|
* @param pipe A memory location provided by the caller in which to save the allocated pipe.
|
||||||
|
* @param ep_cfg Describes the endpoint info to be allocated.
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Free a pipe in which saves endpoint info.
|
||||||
|
*
|
||||||
|
* @param pipe A memory location provided by the caller in which to free the allocated endpoint info.
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usbh_pipe_free(usbh_pipe_t pipe);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Submit a usb transfer request to an xHCI endpoint.
|
||||||
|
*
|
||||||
|
* If timeout is not zero, this function will be in poll transfer mode,
|
||||||
|
* otherwise will be in async transfer mode.
|
||||||
|
*
|
||||||
|
* @param urb Usb request block.
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usbh_submit_urb(struct usbh_urb *urb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Cancel a transfer request.
|
||||||
|
*
|
||||||
|
* This function will call When calls usbh_submit_urb and return -ETIMEOUT or -ESHUTDOWN.
|
||||||
|
*
|
||||||
|
* @param urb Usb request block.
|
||||||
|
* @return On success will return 0, and others indicate fail.
|
||||||
|
*/
|
||||||
|
int xhci_usbh_kill_urb(struct usbh_urb *urb);
|
||||||
|
|
||||||
|
void XHCI_USBH_IRQHandler(void *param);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue