Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peripheral(usbhs): various fixes and enhancements #13

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/peripherals/FV2x_V3x_USBHS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
- name: USBHS
address: 0x40023400
registers:
kind: usb
version: v3hs
kind: usbhs
version: v3
block: USB
rcc:
bus_clock: HCLK
Expand Down
108 changes: 92 additions & 16 deletions data/registers/usb_v3hs.yaml → data/registers/usbhs_v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,20 @@ block/USBD:
description: endpoint 0 DMA buffer address.
byte_offset: 0x1C
bit_size: 32
fieldset: EP_DMA
- name: EP_RX_DMA
description: endpoint n (n=1-15) DMA RX buffer address.
byte_offset: 0x20
bit_size: 32
array:
len: 15
stride: 4
fieldset: EP_DMA
- name: EP_TX_DMA
description: endpoint n (n=1-15) DMA TX buffer address.
byte_offset: 0x5C
bit_size: 32
array:
len: 15
stride: 4
fieldset: EP_DMA
- name: EP_MAX_LEN
description: endpoint n (n=0-15) max acceptable length.
byte_offset: 0x98
Expand All @@ -109,23 +106,23 @@ block/USBD:
bit_size: 16
array:
len: 16
stride: 12
stride: 4
fieldset: EP_LEN
- name: EP_TX_CTRL
description: endpoint n (n=0-15) send control.
byte_offset: 0xDA
bit_size: 8
array:
len: 16
stride: 12
stride: 4
fieldset: EP_TX_CTRL
- name: EP_RX_CTRL
description: endpoint n (n=0-15) receive control.
byte_offset: 0xDB
bit_size: 8
array:
len: 16
stride: 12
stride: 4
fieldset: EP_RX_CTRL

block/USBH:
Expand All @@ -149,12 +146,10 @@ block/USBH:
description: USB host receive buffer start address
byte_offset: 0x24
bit_size: 32
fieldset: EP_DMA
- name: TX_DMA
description: USB host transmit buffer start address
byte_offset: 0x28
bit_size: 32
fieldset: EP_DMA
- name: RX_MAX_LEN
description: USB host receive maximum length packet register
byte_offset: 0xA0
Expand Down Expand Up @@ -215,6 +210,7 @@ fieldset/CTRL:
description: "enable USB low speed: 00=full speed, 01=high speed, 10 =low speed."
bit_offset: 5
bit_size: 2
enum: SPEED_TYPE
- name: HOST_MODE
description: "enable USB host mode: 0=device mode, 1=host mode."
bit_offset: 7
Expand Down Expand Up @@ -331,6 +327,7 @@ fieldset/INT_ST:
description: RO, bit mask of current token PID code received for USB device mode.
bit_offset: 4
bit_size: 2
enum: USB_TOKEN
- name: TOG_OK
description: RO, indicate current USB transfer toggle is OK.
bit_offset: 6
Expand Down Expand Up @@ -383,6 +380,7 @@ fieldset/SPEED_TYPE:
description: in host mode, it indicates the speed type of the currently connected device; in device mode, it indicates the speed type of the current device.
bit_offset: 0
bit_size: 2
enum: SPEED_TYPE
fieldset/SUSPEND:
description: indicate USB suspend status.
bit_size: 8
Expand Down Expand Up @@ -428,13 +426,15 @@ fieldset/EP_TYPE:
description: Endpoint 1 to 15 receive type, 1 means synchronous transmission
bit_offset: 17
bit_size: 1
enum: ENDPOINT_TYPE
array:
len: 15
stride: 1
- name: T_TYPE
description: Endpoint 1 to 15 transmit type, 1 means synchronous transmission
bit_offset: 1
bit_size: 1
enum: ENDPOINT_TYPE
array:
len: 15
stride: 1
Expand Down Expand Up @@ -468,10 +468,12 @@ fieldset/EP_TX_CTRL:
description: MASK_UEP_T_TOG
bit_offset: 3
bit_size: 2
enum: EP_TOG
- name: MASK_UEP_T_RES
description: MASK_UEP_T_RES
bit_offset: 0
bit_size: 2
enum: EP_TX_RESPONSE
fieldset/EP_RX_CTRL:
description: endpoint n receive control.
bit_size: 8
Expand All @@ -484,10 +486,12 @@ fieldset/EP_RX_CTRL:
description: MASK_UEP_R_TOG
bit_offset: 3
bit_size: 2
enum: EP_TOG
- name: MASK_UEP_R_RES
description: MASK_UEP_R_RES
bit_offset: 0
bit_size: 2
enum: EP_RX_RESPONSE

# --------
# UH
Expand Down Expand Up @@ -617,14 +621,6 @@ fieldset/UH_SPLIT_DATA:
bit_size: 12

# shared
fieldset/EP_DMA:
description: USB endpoint DMA buffer address.
bit_size: 32
fields:
- name: ADDR
description: USB endpoint DMA buffer address. 4byte aligned.
bit_offset: 0
bit_size: 17
fieldset/EP_LEN:
description: endpoint n acceptable length.
bit_size: 16
Expand All @@ -633,3 +629,83 @@ fieldset/EP_LEN:
description: endpoint n acceptable length.
bit_offset: 0
bit_size: 11

enum/SPEED_TYPE:
bit_size: 2
variants:
- name: FullSpeed
description: USB Full Speed (12Mbps)
value: 0
- name: HighSpeed
description: USB High Speed (480Mbps)
value: 1
- name: LowSpeed
description: USB Low Speed (1.5Mbps)
value: 2

enum/USB_TOKEN:
bit_size: 2
variants:
- name: OUT
description: OUT Packet
value: 0
- name: SOF
description: Start of Frame
value: 1
- name: IN
description: IN Packet
value: 2
- name: SETUP
description: SETUP Packet
value: 3

enum/ENDPOINT_TYPE:
bit_size: 1
variants:
- name: NISO
description: Non Isochronous (Interrupt/Bulk)
value: 0
- name: ISO
description: Isochronous Transfer
value: 1

enum/EP_TOG:
bit_size: 2
variants:
- name: DATA0
value: 0
- name: DATA1
value: 1
- name: DATA2
value: 2
- name: MDATA
value: 3

enum/EP_TX_RESPONSE:
bit_size: 2
variants:
- name: ACK
description: Respond with DATA0/DATA1 and expect ACK
value: 0
- name: NAK
description: Respond with NAK or Busy
value: 2
- name: STALL
description: Respond with STALL or Error
value: 3

enum/EP_RX_RESPONSE:
bit_size: 2
variants:
- name: ACK
description: Respond with ACK
value: 0
- name: NYET
description: Respond NYET
value: 1
- name: NAK
description: Respond with NAK(Busy)
value: 2
- name: STALL
description: Respond with STALL(Error)
value: 3
Loading