From a1944fba460cc5176acbeaf9214a40355d54f449 Mon Sep 17 00:00:00 2001 From: Codetector Date: Mon, 30 Sep 2024 16:12:57 -0700 Subject: [PATCH 1/6] fix(otg/usbfs): Correct OTG/USBFS Interrupt definition --- data/peripherals/FV2x_V3x_USBFS.yaml | 7 +++---- data/peripherals/FV2x_V3x_USB_OTG_FS.yaml | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/data/peripherals/FV2x_V3x_USBFS.yaml b/data/peripherals/FV2x_V3x_USBFS.yaml index 193cb1c..ef04ead 100644 --- a/data/peripherals/FV2x_V3x_USBFS.yaml +++ b/data/peripherals/FV2x_V3x_USBFS.yaml @@ -12,10 +12,9 @@ register: AHBPCENR field: OTG_EN interrupts: - - signal: HP - interrupt: USB_HP_CAN1_TX - - signal: LP - interrupt: USB_LP_CAN1_RX0 + - signal: GLOBAL + interrupt: OTG_FS + # Note: Pretty sure this does not belong here, this is for USBD only - signal: WKUP interrupt: USB_WKUP pins: diff --git a/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml b/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml index c55e2d5..b2ebc17 100644 --- a/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml +++ b/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml @@ -12,10 +12,9 @@ register: AHBPCENR field: OTG_EN interrupts: - - signal: HP - interrupt: USB_HP_CAN1_TX - - signal: LP - interrupt: USB_LP_CAN1_RX0 + - signal: GLOBAL + interrupt: OTG_FS + # Note: Pretty sure this does not belong here, this is for USBD - signal: WKUP interrupt: USB_WKUP pins: From 00ae04e69db3a64dd1f036119ecf06310f0bfde8 Mon Sep 17 00:00:00 2001 From: Codetector Date: Mon, 30 Sep 2024 16:13:23 -0700 Subject: [PATCH 2/6] style(USBHS): Fix USBHS yaml file to have consistent style with other. --- data/peripherals/FV2x_V3x_USBHS.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data/peripherals/FV2x_V3x_USBHS.yaml b/data/peripherals/FV2x_V3x_USBHS.yaml index 5f9cc7b..f1d2c6e 100644 --- a/data/peripherals/FV2x_V3x_USBHS.yaml +++ b/data/peripherals/FV2x_V3x_USBHS.yaml @@ -15,8 +15,10 @@ register: AHBRSTR field: USBHSRST interrupts: - - { "signal": "GLOBAL", "interrupt": "USBHS" } - - { "signal": "WAKEUP", "interrupt": "USBHS_WKUP" } + - signal: GLOBAL + interrupt: USBHS + - signal: WAKEUP + interrupt: USBHS_WKUP pins: - pin: PB6 signal: DM From d211fda42f4cca640709aae96608cbb55c06558b Mon Sep 17 00:00:00 2001 From: Codetector Date: Mon, 30 Sep 2024 16:50:01 -0700 Subject: [PATCH 3/6] fix(usbfs/otgfs): Remove WAKEUP from USBFS/OTG_FS. USBFS/OTG_FS actually fire the "GLOBAL" interrupt for WAKEUP. the USB_WAKEUP is for USBD. --- data/peripherals/FV2x_V3x_USBFS.yaml | 3 --- data/peripherals/FV2x_V3x_USB_OTG_FS.yaml | 3 --- 2 files changed, 6 deletions(-) diff --git a/data/peripherals/FV2x_V3x_USBFS.yaml b/data/peripherals/FV2x_V3x_USBFS.yaml index ef04ead..d52b2dc 100644 --- a/data/peripherals/FV2x_V3x_USBFS.yaml +++ b/data/peripherals/FV2x_V3x_USBFS.yaml @@ -14,9 +14,6 @@ interrupts: - signal: GLOBAL interrupt: OTG_FS - # Note: Pretty sure this does not belong here, this is for USBD only - - signal: WKUP - interrupt: USB_WKUP pins: - pin: PA11 signal: DM diff --git a/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml b/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml index b2ebc17..ccf4c7b 100644 --- a/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml +++ b/data/peripherals/FV2x_V3x_USB_OTG_FS.yaml @@ -14,9 +14,6 @@ interrupts: - signal: GLOBAL interrupt: OTG_FS - # Note: Pretty sure this does not belong here, this is for USBD - - signal: WKUP - interrupt: USB_WKUP pins: - pin: PA11 signal: DM From 390931d98859935df643b8fb9bc2091ba10a00e9 Mon Sep 17 00:00:00 2001 From: Codetector Date: Tue, 8 Oct 2024 00:23:35 -0700 Subject: [PATCH 4/6] fix(usbfs/otgfs): Introduce Enums --- data/registers/otg_v2.yaml | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/data/registers/otg_v2.yaml b/data/registers/otg_v2.yaml index 8849dbf..b0b5d88 100644 --- a/data/registers/otg_v2.yaml +++ b/data/registers/otg_v2.yaml @@ -329,6 +329,7 @@ fieldset/USB_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 @@ -470,6 +471,7 @@ fieldset/UEP_TX_CTRL: description: bit mask of handshake response type for USB endpoint X transmittal (IN). bit_offset: 0 bit_size: 2 + enum: EP_TX_RESPONSE - name: T_TOG description: "prepared data toggle flag of USB endpoint X transmittal (IN): 0=DATA0, 1=DATA1." bit_offset: 2 @@ -486,6 +488,7 @@ fieldset/UEP_RX_CTRL: description: bit mask of handshake response type for USB endpoint X receiving (OUT). bit_offset: 0 bit_size: 2 + enum: EP_RX_RESPONSE - name: R_TOG description: "expected data toggle flag of USB endpoint X receiving (OUT): 0=DATA0, 1=DATA1." bit_offset: 2 @@ -592,3 +595,51 @@ fieldset/UH_TX_CTRL: - name: T_AUTO_TOG bit_offset: 3 bit_size: 1 + +enum/EP_TX_RESPONSE: + bit_size: 2 + variants: + - name: ACK + description: Respond with DATA0/DATA1 and expect ACK + value: 0 + - name: None + description: Respond with DATA0/DATA1 and not expect ACK + value: 1 + - 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: None + description: Timeout / No Response, used for non-EP0 iso/sync transfer + value: 1 + - name: NAK + description: Respond with NAK or Busy + value: 2 + - name: STALL + description: Respond with STALL or Error + value: 3 + +enum/USB_TOKEN: + bit_size: 2 + variants: + - name: OUT + description: OUT Packet + value: 0 + - name: Rsvd + description: Reserved + value: 1 + - name: IN + description: IN Packet + value: 2 + - name: SETUP + description: Setup Packet + value: 3 \ No newline at end of file From 2490c6cca066d9f52b6091cf280179ea0cb4bd9a Mon Sep 17 00:00:00 2001 From: Dummyc0m Date: Tue, 8 Oct 2024 00:42:20 -0700 Subject: [PATCH 5/6] split out endpoint mode registers --- data/registers/otg_v2.yaml | 122 ++++++++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 23 deletions(-) diff --git a/data/registers/otg_v2.yaml b/data/registers/otg_v2.yaml index b0b5d88..26c0593 100644 --- a/data/registers/otg_v2.yaml +++ b/data/registers/otg_v2.yaml @@ -63,17 +63,17 @@ block/USBD: description: endpoint 4/1 mode. byte_offset: 12 bit_size: 8 - fieldset: UEP_MOD + fieldset: UEP4_1_MOD - name: UEP2_3_MOD description: Endpoint 2/3 mode control register. byte_offset: 13 bit_size: 8 - fieldset: UEP_MOD + fieldset: UEP2_3_MOD - name: UEP5_6_MOD description: endpoint 5/6 mode. byte_offset: 14 bit_size: 8 - fieldset: UEP_MOD + fieldset: UEP5_6_MOD - name: UEP7_MOD description: endpoint 7 mode. byte_offset: 15 @@ -422,44 +422,110 @@ fieldset/UDEV_CTRL: description: USB device port UD+/UD- pin internal pull-down resistor control. bit_offset: 7 bit_size: 1 -fieldset/UEP_MOD: - description: endpoint a/b mode. lower bits comes first +fieldset/UEP4_1_MOD: + description: endpoint 4/1 mode. bit_size: 8 fields: - - name: BUF_MOD - description: buffer mode of USB endpoint + - name: UEP4_BUF_MOD + description: buffer mode of USB endpoint 4. bit_offset: 0 bit_size: 1 - array: - len: 2 - stride: 4 - - name: TX_EN - description: enable USB endpoint 1 transmittal (IN). + enum: BUF_MODE + - name: UEP4_TX_EN + description: enable USB endpoint 4 transmittal (IN). bit_offset: 2 bit_size: 1 - array: - len: 2 - stride: 4 - - name: RX_EN + - name: UEP4_RX_EN description: enable USB endpoint 4 receiving (OUT). bit_offset: 3 bit_size: 1 - array: - len: 2 - stride: 4 + - name: UEP1_BUF_MOD + description: buffer mode of USB endpoint 1. + bit_offset: 4 + bit_size: 1 + enum: BUF_MODE + - name: UEP1_TX_EN + description: enable USB endpoint 1 transmittal (IN). + bit_offset: 6 + bit_size: 1 + - name: UEP1_RX_EN + description: enable USB endpoint 1 receiving (OUT). + bit_offset: 7 + bit_size: 1 +fieldset/UEP2_3_MOD: + description: endpoint 2/3 mode. + bit_size: 8 + fields: + - name: UEP2_BUF_MOD + description: buffer mode of USB endpoint 2. + bit_offset: 0 + bit_size: 1 + enum: BUF_MODE + - name: UEP2_TX_EN + description: enable USB endpoint 2 transmittal (IN). + bit_offset: 2 + bit_size: 1 + - name: UEP2_RX_EN + description: enable USB endpoint 2 receiving (OUT). + bit_offset: 3 + bit_size: 1 + - name: UEP3_BUF_MOD + description: buffer mode of USB endpoint 3. + bit_offset: 4 + bit_size: 1 + enum: BUF_MODE + - name: UEP3_TX_EN + description: enable USB endpoint 3 transmittal (IN). + bit_offset: 6 + bit_size: 1 + - name: UEP3_RX_EN + description: enable USB endpoint 3 receiving (OUT). + bit_offset: 7 + bit_size: 1 +fieldset/UEP5_6_MOD: + description: endpoint 5/6 mode. + bit_size: 8 + fields: + - name: UEP5_BUF_MOD + description: buffer mode of USB endpoint 5. + bit_offset: 0 + bit_size: 1 + enum: BUF_MODE + - name: UEP5_TX_EN + description: enable USB endpoint 5 transmittal (IN). + bit_offset: 2 + bit_size: 1 + - name: UEP5_RX_EN + description: enable USB endpoint 5 receiving (OUT). + bit_offset: 3 + bit_size: 1 + - name: UEP6_BUF_MOD + description: buffer mode of USB endpoint 6. + bit_offset: 4 + bit_size: 1 + enum: BUF_MODE + - name: UEP6_TX_EN + description: enable USB endpoint 6 transmittal (IN). + bit_offset: 6 + bit_size: 1 + - name: UEP6_RX_EN + description: enable USB endpoint 6 receiving (OUT). + bit_offset: 7 + bit_size: 1 fieldset/UEP7_MOD: description: endpoint 7 mode. bit_size: 8 fields: - - name: BUF_MOD + - name: UEP7_BUF_MOD description: buffer mode of USB endpoint 7. bit_offset: 0 bit_size: 1 - - name: TX_EN + enum: BUF_MODE + - name: UEP7_TX_EN description: enable USB endpoint 7 transmittal (IN). bit_offset: 2 bit_size: 1 - - name: RX_EN + - name: UEP7_RX_EN description: enable USB endpoint 7 receiving (OUT). bit_offset: 3 bit_size: 1 @@ -642,4 +708,14 @@ enum/USB_TOKEN: value: 2 - name: SETUP description: Setup Packet - value: 3 \ No newline at end of file + value: 3 + +enum/BUF_MODE: + bit_size: 1 + variants: + - name: SINGLE + description: Single Buffer Mode + value: 0 + - name: DOUBLE + description: Double Buffer Mode + value: 1 From cbf6312cae8042a79bd8514868d8cd44f3a0bdeb Mon Sep 17 00:00:00 2001 From: Dummyc0m Date: Tue, 8 Oct 2024 00:42:42 -0700 Subject: [PATCH 6/6] use /usr/bin/env bash for better hygiene --- d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d b/d index 8ad5966..d408b44 100755 --- a/d +++ b/d @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex