/* * ltcusb.h * * Created on: 14-Apr-2023 * Author: pushpkant */ /** * @file ltcusb.h * @brief Library for USB controller. */ #ifndef INCLUDE_LTCUSB_H_ #define INCLUDE_LTCUSB_H_ #pragma pack(1) #include #include #include "ltcusb_raw_rw.h" #include "ltcusb_regs.h" #include "ltcusb_regs_offsets.h" #include "ltcusb_regs_ops.h" #include "ltcusb_data_types.h" #include "GenMac.h" #include "request_fifo.h" #include "event_fifo.h" //#include "uart.h" //#include "pic.h" //#include "utils.h" #include //#include // RISC V Addresses #define EVENT_FIFO_ADDR_RV 0x00200000 #define TRB_FIFO_ADDR_RV 0x00300000 #define REQ_FIFO_ADDR_RV 0x00400000 #define DESC_FIFO_ADDR_RV 0x00500000 /**@todo not clear about this*/ // USB23 Addresses #define EVENT_FIFO_ADDR_USB23 0x00000010 #define TRB_FIFO_ADDR_USB23 0x00001000 #define REQ_FIFO_ADDR_USB23 0x0004ff00 #define DESC_FIFO_ADDR_USB23 0x00050000 #define BULK_ADDRESS_USB23 0x00060000 #define CONTROL_ADDRESS_USB23 0x00070000 #define INTERRUPT_ADDRESS_USB23 0x00080000 // Size of Bulk and Interrupt TRBs #define INTERRUPT_IN_HS_DATA_SIZE 0x400 //1024 #define INTERRUPT_IN_FS_DATA_SIZE 0x40 //64 #define INTERRUPT_OUT_HS_DATA_SIZE 0x400 //1024 #define INTERRUPT_OUT_FS_DATA_SIZE 0x40 //64 #define BULK_IN_HS_DATA_SIZE 0x200 //512 #define BULK_IN_FS_DATA_SIZE 0x40 //64 #define BULK_OUT_HS_DATA_SIZE 0x200 //512 #define BULK_OUT_FS_DATA_SIZE 0x40 //64 //in geventsize inti command #define EVENT_FIFO_SIZE 0x400 //Suspend enable #define SUSPEND_EN FALSE // Simulation Parameter #define SIM_EN FALSE // External Clock Parameter #define EXT_CLK_EN FALSE //#define USB_SPEED high_speed_usb extern uint32_t USB_SPEED; /** * @brief Connection_Speed (USB_SPEED) */ extern uint32_t Connect_Speed; /** * @brief To Enabe or Disable UART */ extern uint32_t UART_Enable; /** * @brief Size of the addresses available on the USB controller. */ #define USB_ADDRESS_SIZE (20UL) /** * @brief Lowest Possible address on the USB Controller. */ #define USB_ADDRESS_MIN (0x00) /** * @brief Highest Possible address on the USB controller. */ #define USB_ADDRESS_MAX ((1UL << (USB_ADDRESS_SIZE + 1UL)) - 1UL) /** * @brief Offset of the memory mapped USB controller. */ #define USB_ADDRESS_OFFSET (1UL << 20UL) /** * @brief The maximum address allocated for the ltcusb. * @note This register holds the maximum allowed address. This depends on * build type. For RISC-V this number depends on ADDRESS SIZE and on * GNU build this is a UINT64_MAX value. */ extern const uint32_t ltcusb_addr_max; /** * @brief RISC-V core frequency in Mega-Hertz. */ #define RV_FREQ_MHZ 60UL /** * @brief The synopsys id to be checked with the GSNPSID register. * @todo Correct the value. */ #define SYNOPSYS_ID 0x11223344 /** * @brief Retry count before giving up from the hardware to get any * information. */ #define RETRY_COUNT 100 /** * @brief Error when execution of command. */ #define EXECUTE_CMD_ERR 200 /**@todo add description here.*/ extern int ltcusb_init(); #define set_vid_pid(vid,pid) do{device_descriptor_data.idVendor = (vid);\ device_descriptor_data.idProduct = (pid);}while(0); #endif /* INCLUDE_LTCUSB_H_ */