XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Functions
dwc2.h File Reference
#include <stdint.h>
Include dependency graph for dwc2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dwc2_usb_endpoint_t
 
struct  usb_setup_packet_t
 

Macros

#define USB_PID_SETUP   3
 
#define USB_PID_DATA   2
 
#define USB_PID_DATA0   0
 
#define USB_PID_DATA2   1
 
#define DWC2_GET_PORT_SPEED(hport)   ((hport >> 17) & 0x3)
 
#define EP_OUT   0
 
#define EP_IN   1
 
#define EP_BIDIR   2
 
#define EP_CONTROL   0
 
#define EP_ISOCHRONOUS   1
 
#define EP_BULK   2
 
#define EP_INTERRUPT   3
 

Functions

uint32_t dwc2_read (uint64_t base)
 dwc2_read – reads a value from dwc2 register
 
void dwc2_write (uint64_t base, uint32_t value)
 dwc2_write – write a value to dwc2 register
 
void dwc2_control_transfer (struct dwc2_core_regs *regs, dwc2_usb_endpoint_t *ep, uint8_t bmRequestType, uint8_t b_request, uint16_t wValue, uint16_t wIndex, void *data, uint16_t wLength)
 
void dwc2_interrupt_transfer (dwc2_core_regs *regs, dwc2_usb_endpoint_t *ep, void *intbuf, uint8_t ch, uint32_t odd, uint8_t pid)
 
void dwc2_enumerate_root_device (struct dwc2_core_regs *regs)
 
void dwc2_handle_channel_interrupt (dwc2_core_regs *regs, int ch)
 dwc2_handle_channel_interrupt – handle channel interrupts here
 
void * dwc2_get_dma_address ()
 dwc2_get_dma_address – return pre allocated dma address
 
void * dwc2_get_dma_address_phys ()
 
void dwc2_flush_tx_fifo (struct dwc2_core_regs *regs, uint32_t nfifo)
 
void dwc2_flush_rx_fifo (struct dwc2_core_regs *regs)
 
void dwc2_add_to_used_dma_list (void *phys)
 dwc2_add_to_used_dma_list – there is a bug i guess within the dwc2 ip where same buffer can't be used for setup packet
 
void dwc2_free_used_dma_list ()
 dwc2_free_used_dma_list – free up all used physical memories, this function must be called at the end of the class driver initialization
 
void root_hub_transfer_int (dwc2_core_regs *regs, uint8_t pid)
 
void * root_hub_get_interrupt_buffer ()
 
void root_hub_handle_port_change (dwc2_core_regs *regs, uint8_t port)
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ DWC2_GET_PORT_SPEED

#define DWC2_GET_PORT_SPEED (   hport)    ((hport >> 17) & 0x3)

◆ EP_BIDIR

#define EP_BIDIR   2

◆ EP_BULK

#define EP_BULK   2

◆ EP_CONTROL

#define EP_CONTROL   0

◆ EP_IN

#define EP_IN   1

◆ EP_INTERRUPT

#define EP_INTERRUPT   3

◆ EP_ISOCHRONOUS

#define EP_ISOCHRONOUS   1

◆ EP_OUT

#define EP_OUT   0

◆ USB_PID_DATA

#define USB_PID_DATA   2

◆ USB_PID_DATA0

#define USB_PID_DATA0   0

◆ USB_PID_DATA2

#define USB_PID_DATA2   1

◆ USB_PID_SETUP

#define USB_PID_SETUP   3

Function Documentation

◆ dwc2_add_to_used_dma_list()

void dwc2_add_to_used_dma_list ( void *  phys)
extern

dwc2_add_to_used_dma_list – there is a bug i guess within the dwc2 ip where same buffer can't be used for setup packet

◆ dwc2_control_transfer()

void dwc2_control_transfer ( struct dwc2_core_regs regs,
dwc2_usb_endpoint_t ep,
uint8_t  bmRequestType,
uint8_t  b_request,
uint16_t  wValue,
uint16_t  wIndex,
void *  data,
uint16_t  wLength 
)
extern

setup the status stage

free up the channel

◆ dwc2_enumerate_root_device()

void dwc2_enumerate_root_device ( struct dwc2_core_regs regs)
extern

dwc2_enumerate_root_device – enumerate the root device

Parameters
regs– pointer to system regs

no strings for root hub, iss iss bom laaj pali no ??

next set address, and configure the hub, because devices are waiting to get powered in

PORT power up

◆ dwc2_flush_rx_fifo()

void dwc2_flush_rx_fifo ( struct dwc2_core_regs regs)
extern

◆ dwc2_flush_tx_fifo()

void dwc2_flush_tx_fifo ( struct dwc2_core_regs regs,
uint32_t  nfifo 
)
extern

◆ dwc2_free_used_dma_list()

void dwc2_free_used_dma_list ( )
extern

dwc2_free_used_dma_list – free up all used physical memories, this function must be called at the end of the class driver initialization

◆ dwc2_get_dma_address()

void * dwc2_get_dma_address ( )
extern

dwc2_get_dma_address – return pre allocated dma address

◆ dwc2_get_dma_address_phys()

void * dwc2_get_dma_address_phys ( )
extern

◆ dwc2_handle_channel_interrupt()

void dwc2_handle_channel_interrupt ( dwc2_core_regs regs,
int  ch 
)
extern

dwc2_handle_channel_interrupt – handle channel interrupts here

Parameters
regs– Pointer to dwc2 core registers
ch– channel numbers

W1C

◆ dwc2_interrupt_transfer()

void dwc2_interrupt_transfer ( dwc2_core_regs regs,
dwc2_usb_endpoint_t ep,
void *  intbuf,
uint8_t  ch,
uint32_t  odd,
uint8_t  pid 
)
extern

◆ dwc2_read()

uint32_t dwc2_read ( uint64_t  base)
extern

dwc2_read – reads a value from dwc2 register

Parameters
base– memory base

◆ dwc2_write()

void dwc2_write ( uint64_t  base,
uint32_t  value 
)
extern

dwc2_write – write a value to dwc2 register

Parameters
base– memory base
value– value to write

◆ root_hub_get_interrupt_buffer()

void * root_hub_get_interrupt_buffer ( )
extern

◆ root_hub_handle_port_change()

void root_hub_handle_port_change ( dwc2_core_regs regs,
uint8_t  port 
)
extern

◆ root_hub_transfer_int()

void root_hub_transfer_int ( dwc2_core_regs regs,
uint8_t  pid 
)
extern