SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions | Variables
usb_controller.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <common.h>
#include <log.h>
#include <sys-clk.h>
#include "usb.h"
#include "usb_controller.h"
Include dependency graph for usb_controller.c:

Functions

uint32_t usb_controller_open_otg (uint32_t otg_no)
 Open the USB OTG controller.
 
int usb_controller_close_otg (uint64_t husb)
 Close the USB OTG controller.
 
static uint32_t usb_controller_wake_up_clear_change_detect (uint32_t reg_val)
 
static void usb_controller_force_id_low (uint32_t addr)
 
static void usb_controller_force_id_high (uint32_t addr)
 
static void usb_controller_force_id_disable (uint32_t addr)
 
void usb_controller_force_id_status (uint64_t husb, uint32_t id_type)
 Set the ID status for the USB controller.
 
static void usb_controller_force_vbus_valid_disable (uint32_t addr)
 
static void usb_controller_force_vbus_valid_low (uint32_t addr)
 
static void usb_controller_force_vbus_valid_high (uint32_t addr)
 
void usb_controller_force_vbus_valid (uint64_t husb, uint32_t vbus_type)
 Force the VBUS valid state for the USB controller.
 
void usb_controller_id_pull_enable (uint64_t husb)
 Enable the ID pull-up resistor for the USB controller.
 
void usb_controller_id_pull_disable (uint64_t husb)
 Disable the ID pull-up resistor for the USB controller.
 
void usb_controller_dpdm_pull_enable (uint64_t husb)
 Enable the DP/DM pull-up resistors for the USB controller.
 
void usb_controller_dpdm_pull_disable (uint64_t husb)
 Disable the DP/DM pull-up resistors for the USB controller.
 
void usb_controller_select_bus (uint64_t husb, uint32_t io_type, uint32_t ep_type, uint32_t ep_index)
 
void usb_controller_int_disable_usb_misc_all (uint64_t husb)
 Disable all miscellaneous USB interrupts.
 
void usb_controller_int_disable_ep_all (uint64_t husb, uint32_t ep_type)
 Disable all endpoint-specific interrupts.
 
void usb_controller_int_enable_usb_misc_uint (uint64_t husb, uint32_t mask)
 Enable specific miscellaneous USB interrupts.
 
void usb_controller_int_disable_usb_misc_uint (uint64_t husb, uint32_t mask)
 Disable specific miscellaneous USB interrupts.
 
void usb_controller_int_enable_ep (uint64_t husb, uint32_t ep_type, uint32_t ep_index)
 Enable interrupts for a specific endpoint.
 
uint32_t usb_controller_get_active_ep (uint64_t husb)
 Get the active endpoint for the USB controller.
 
void usb_controller_select_active_ep (uint64_t husb, uint8_t ep_index)
 Select the active endpoint for the USB controller.
 
void usb_controller_config_fifo_tx_ep_default (uint32_t addr)
 Configure the FIFO for a default transmit endpoint.
 
void usb_controller_config_fifo_tx_ep (uint32_t addr, uint32_t is_double_fifo, uint32_t fifo_size, uint32_t fifo_addr)
 Configure the FIFO for a transmit endpoint.
 
void usb_controller_config_fifo_rx_ep_default (uint32_t addr)
 Configure the FIFO for a default receive endpoint.
 
void usb_controller_config_fifo_rx_ep (uint32_t addr, uint32_t is_double_fifo, uint32_t fifo_size, uint32_t fifo_addr)
 Configure the FIFO for a receive endpoint.
 
void usb_controller_config_fifo (uint64_t husb, uint32_t ep_type, uint32_t is_double_fifo, uint32_t fifo_size, uint32_t fifo_addr)
 Configure the FIFO for a specific endpoint.
 
uint32_t usb_controller_int_ep_pending (uint64_t husb, uint32_t ep_type)
 Get the pending interrupt status for a specific endpoint.
 
void usb_controller_int_clear_ep_pending (uint64_t husb, uint32_t ep_type, uint8_t ep_index)
 Clear the pending interrupt flag for a specific endpoint.
 
void usb_controller_int_clear_ep_pending_all (uint64_t husb, uint32_t ep_type)
 Clear the pending interrupt flags for all endpoints of a specific type.
 
uint32_t usb_controller_int_misc_pending (uint64_t husb)
 Get the pending miscellaneous interrupt status.
 
void usb_controller_int_clear_misc_pending (uint64_t husb, uint32_t mask)
 Clear the pending miscellaneous interrupt flag.
 
void usb_controller_int_clear_misc_pending_all (uint64_t husb)
 Clear the pending miscellaneous interrupt flags for all interrupts.
 
void usb_controller_int_disable_ep (uint64_t husb, uint32_t ep_type, uint8_t ep_index)
 Disable interrupts for a specific endpoint.
 
uint32_t usb_controller_get_vbus_status (uint64_t husb)
 
uint32_t usb_controller_read_len_from_fifo (uint64_t husb, uint32_t ep_type)
 
uint32_t usb_controller_write_packet (uint64_t husb, uint32_t fifo, uint32_t cnt, void *buff)
 
uint32_t usb_controller_read_packet (uint64_t husb, uint32_t fifo, uint32_t cnt, void *buff)
 
void usb_controller_config_fifo_base (uint64_t husb, uint32_t sram_base)
 
uint32_t usb_controller_get_port_fifo_start_addr (uint64_t husb)
 
uint32_t usb_controller_get_port_fifo_size (uint64_t husb)
 
uint32_t usb_controller_select_fifo (uint64_t husb, uint32_t ep_index)
 

Variables

static uint32_t usbc_base_address [USBC_MAX_CTL_NUM] = {SUNXI_USB0_BASE}
 
static usb_controller_otg_t usbc_otg_array [USBC_MAX_OPEN_NUM]
 
static fifo_info_t usbc_info_g
 

Function Documentation

◆ usb_controller_close_otg()

int usb_controller_close_otg ( uint64_t  husb)

Close the USB OTG controller.

Parameters
husbThe handle to the USB controller.
Returns
Returns the status of the operation.

◆ usb_controller_config_fifo()

void usb_controller_config_fifo ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  is_double_fifo,
uint32_t  fifo_size,
uint32_t  fifo_addr 
)

Configure the FIFO for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
is_double_fifoWhether the endpoint has double buffering enabled.
fifo_sizeThe size of the FIFO.
fifo_addrThe base address of the FIFO.

◆ usb_controller_config_fifo_base()

void usb_controller_config_fifo_base ( uint64_t  husb,
uint32_t  sram_base 
)

◆ usb_controller_config_fifo_rx_ep()

void usb_controller_config_fifo_rx_ep ( uint32_t  addr,
uint32_t  is_double_fifo,
uint32_t  fifo_size,
uint32_t  fifo_addr 
)

Configure the FIFO for a receive endpoint.

Parameters
addrThe address of the USB controller.
is_double_fifoWhether the endpoint has double buffering enabled.
fifo_sizeThe size of the FIFO.
fifo_addrThe base address of the FIFO.

◆ usb_controller_config_fifo_rx_ep_default()

void usb_controller_config_fifo_rx_ep_default ( uint32_t  addr)

Configure the FIFO for a default receive endpoint.

Parameters
addrThe address of the USB controller.

◆ usb_controller_config_fifo_tx_ep()

void usb_controller_config_fifo_tx_ep ( uint32_t  addr,
uint32_t  is_double_fifo,
uint32_t  fifo_size,
uint32_t  fifo_addr 
)

Configure the FIFO for a transmit endpoint.

Parameters
addrThe address of the USB controller.
is_double_fifoWhether the endpoint has double buffering enabled.
fifo_sizeThe size of the FIFO.
fifo_addrThe base address of the FIFO.

◆ usb_controller_config_fifo_tx_ep_default()

void usb_controller_config_fifo_tx_ep_default ( uint32_t  addr)

Configure the FIFO for a default transmit endpoint.

Parameters
addrThe address of the USB controller.

◆ usb_controller_dpdm_pull_disable()

void usb_controller_dpdm_pull_disable ( uint64_t  husb)

Disable the DP/DM pull-up resistors for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_dpdm_pull_enable()

void usb_controller_dpdm_pull_enable ( uint64_t  husb)

Enable the DP/DM pull-up resistors for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_force_id_disable()

static void usb_controller_force_id_disable ( uint32_t  addr)
static

◆ usb_controller_force_id_high()

static void usb_controller_force_id_high ( uint32_t  addr)
static

◆ usb_controller_force_id_low()

static void usb_controller_force_id_low ( uint32_t  addr)
static

◆ usb_controller_force_id_status()

void usb_controller_force_id_status ( uint64_t  husb,
uint32_t  id_type 
)

Set the ID status for the USB controller.

Parameters
husbThe handle to the USB controller.
id_typeThe type of ID status to set.

◆ usb_controller_force_vbus_valid()

void usb_controller_force_vbus_valid ( uint64_t  husb,
uint32_t  vbus_type 
)

Force the VBUS valid state for the USB controller.

Parameters
husbThe handle to the USB controller.
vbus_typeThe type of VBUS state to force.

◆ usb_controller_force_vbus_valid_disable()

static void usb_controller_force_vbus_valid_disable ( uint32_t  addr)
static

◆ usb_controller_force_vbus_valid_high()

static void usb_controller_force_vbus_valid_high ( uint32_t  addr)
static

◆ usb_controller_force_vbus_valid_low()

static void usb_controller_force_vbus_valid_low ( uint32_t  addr)
static

◆ usb_controller_get_active_ep()

uint32_t usb_controller_get_active_ep ( uint64_t  husb)

Get the active endpoint for the USB controller.

Parameters
husbThe handle to the USB controller.
Returns
Returns the active endpoint.

◆ usb_controller_get_port_fifo_size()

uint32_t usb_controller_get_port_fifo_size ( uint64_t  husb)

◆ usb_controller_get_port_fifo_start_addr()

uint32_t usb_controller_get_port_fifo_start_addr ( uint64_t  husb)

◆ usb_controller_get_vbus_status()

uint32_t usb_controller_get_vbus_status ( uint64_t  husb)

◆ usb_controller_id_pull_disable()

void usb_controller_id_pull_disable ( uint64_t  husb)

Disable the ID pull-up resistor for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_id_pull_enable()

void usb_controller_id_pull_enable ( uint64_t  husb)

Enable the ID pull-up resistor for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_int_clear_ep_pending()

void usb_controller_int_clear_ep_pending ( uint64_t  husb,
uint32_t  ep_type,
uint8_t  ep_index 
)

Clear the pending interrupt flag for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
ep_indexThe index of the endpoint.

◆ usb_controller_int_clear_ep_pending_all()

void usb_controller_int_clear_ep_pending_all ( uint64_t  husb,
uint32_t  ep_type 
)

Clear the pending interrupt flags for all endpoints of a specific type.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.

◆ usb_controller_int_clear_misc_pending()

void usb_controller_int_clear_misc_pending ( uint64_t  husb,
uint32_t  mask 
)

Clear the pending miscellaneous interrupt flag.

Parameters
husbThe handle to the USB controller.
maskThe interrupt mask to clear.

◆ usb_controller_int_clear_misc_pending_all()

void usb_controller_int_clear_misc_pending_all ( uint64_t  husb)

Clear the pending miscellaneous interrupt flags for all interrupts.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_int_disable_ep()

void usb_controller_int_disable_ep ( uint64_t  husb,
uint32_t  ep_type,
uint8_t  ep_index 
)

Disable interrupts for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
ep_indexThe index of the endpoint.

◆ usb_controller_int_disable_ep_all()

void usb_controller_int_disable_ep_all ( uint64_t  husb,
uint32_t  ep_type 
)

Disable all endpoint-specific interrupts.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint to disable interrupts for.

◆ usb_controller_int_disable_usb_misc_all()

void usb_controller_int_disable_usb_misc_all ( uint64_t  husb)

Disable all miscellaneous USB interrupts.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_int_disable_usb_misc_uint()

void usb_controller_int_disable_usb_misc_uint ( uint64_t  husb,
uint32_t  mask 
)

Disable specific miscellaneous USB interrupts.

Parameters
husbThe handle to the USB controller.
maskThe interrupt mask to enable.

◆ usb_controller_int_enable_ep()

void usb_controller_int_enable_ep ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  ep_index 
)

Enable interrupts for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint to enable interrupts for.
ep_indexThe index of the endpoint to enable interrupts for.

◆ usb_controller_int_enable_usb_misc_uint()

void usb_controller_int_enable_usb_misc_uint ( uint64_t  husb,
uint32_t  mask 
)

Enable specific miscellaneous USB interrupts.

Parameters
husbThe handle to the USB controller.
maskThe interrupt mask to enable.

◆ usb_controller_int_ep_pending()

uint32_t usb_controller_int_ep_pending ( uint64_t  husb,
uint32_t  ep_type 
)

Get the pending interrupt status for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
Returns
Returns the pending interrupt status.

◆ usb_controller_int_misc_pending()

uint32_t usb_controller_int_misc_pending ( uint64_t  husb)

Get the pending miscellaneous interrupt status.

Parameters
husbThe handle to the USB controller.
Returns
Returns the pending miscellaneous interrupt status.

◆ usb_controller_open_otg()

uint32_t usb_controller_open_otg ( uint32_t  otg_no)

Open the USB OTG controller.

Parameters
otg_noThe OTG controller number.
Returns
Returns the status of the operation.

◆ usb_controller_read_len_from_fifo()

uint32_t usb_controller_read_len_from_fifo ( uint64_t  husb,
uint32_t  ep_type 
)

◆ usb_controller_read_packet()

uint32_t usb_controller_read_packet ( uint64_t  husb,
uint32_t  fifo,
uint32_t  cnt,
void *  buff 
)

◆ usb_controller_select_active_ep()

void usb_controller_select_active_ep ( uint64_t  husb,
uint8_t  ep_index 
)

Select the active endpoint for the USB controller.

Parameters
husbThe handle to the USB controller.
ep_indexThe index of the endpoint to select as active.

◆ usb_controller_select_bus()

void usb_controller_select_bus ( uint64_t  husb,
uint32_t  io_type,
uint32_t  ep_type,
uint32_t  ep_index 
)

◆ usb_controller_select_fifo()

uint32_t usb_controller_select_fifo ( uint64_t  husb,
uint32_t  ep_index 
)

◆ usb_controller_wake_up_clear_change_detect()

static uint32_t usb_controller_wake_up_clear_change_detect ( uint32_t  reg_val)
static

◆ usb_controller_write_packet()

uint32_t usb_controller_write_packet ( uint64_t  husb,
uint32_t  fifo,
uint32_t  cnt,
void *  buff 
)

Variable Documentation

◆ usbc_base_address

uint32_t usbc_base_address[USBC_MAX_CTL_NUM] = {SUNXI_USB0_BASE}
static

◆ usbc_info_g

fifo_info_t usbc_info_g
static

◆ usbc_otg_array

usb_controller_otg_t usbc_otg_array[USBC_MAX_OPEN_NUM]
static