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

[rtl872x] Fixes USB serial port not being connectable on AMD based Windows #2625

Merged
merged 2 commits into from
Mar 3, 2023
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
2 changes: 1 addition & 1 deletion bootloader/src/rtl872x/osdep_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ particle::StaticRecursiveCriticalSectionLock sCsLock;
thread_func_t sFunc = nullptr;
void *sCtx = nullptr;

const size_t RTW_USBD_TASK_MAIN_LOOP_SEMAPHORE_OFFSET = 364;
const size_t RTW_USBD_TASK_MAIN_LOOP_SEMAPHORE_OFFSET = 400;
const uint32_t RTW_USBD_TASK_MAIN_LOOP_PERIOD_MS = 1;

class AtomicCountingSemaphore {
Expand Down
16 changes: 9 additions & 7 deletions hal/src/rtl872x/usbd_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ namespace {

SetupRequest sLastUsbSetupRequest = {};

Speed rtlSpeedToDriver(usbd_speed_type_t speed) {
Speed rtlSpeedToDriver(usb_speed_type_t speed) {
switch (speed) {
case USBD_SPEED_HIGH: {
case USB_SPEED_HIGH: {
return Speed::HIGH;
}
case USBD_SPEED_LOW: {
case USB_SPEED_LOW: {
return Speed::LOW;
}
case USBD_SPEED_FULL:
case USB_SPEED_FULL:
default: {
return Speed::FULL;
}
Expand All @@ -78,8 +78,10 @@ uint8_t endpointTypeToRtl(EndpointType type) {
return 0;
}

const size_t RTL_USB_DEV_PCD_OFFSET = 0xd8;
const size_t RTL_USB_PCD_SPINLOCK_OFFSET = 0x15c;
// FIXME: it should be fine to directly use rtlDev_->pcd or &usbd_pcd, but for now keeping things as-is to keep
// changes to a minimum
const size_t RTL_USB_DEV_PCD_OFFSET = offsetof(usb_dev_t, pcd);
const size_t RTL_USB_PCD_SPINLOCK_OFFSET = 0x180;

} // anonymous

Expand Down Expand Up @@ -310,7 +312,7 @@ unsigned RtlUsbDriver::updateEndpointMask(unsigned mask) const {
return mask;
}

uint8_t* RtlUsbDriver::getDescriptorCb(usb_setup_req_t *req, usbd_speed_type_t speed, uint16_t* len) {
uint8_t* RtlUsbDriver::getDescriptorCb(usb_setup_req_t *req, usb_speed_type_t speed, uint16_t* len) {
auto self = instance();
std::lock_guard<RtlUsbDriver> lk(*self);

Expand Down
7 changes: 4 additions & 3 deletions hal/src/rtl872x/usbd_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class RtlUsbDriver : public DeviceDriver {
RtlUsbDriver();
virtual ~RtlUsbDriver();

static uint8_t* getDescriptorCb(usb_setup_req_t *req, usbd_speed_type_t speed, uint16_t* len);
static uint8_t* getDescriptorCb(usb_setup_req_t *req, usb_speed_type_t speed, uint16_t* len);
static uint8_t setConfigCb(usb_dev_t* dev, uint8_t config);
static uint8_t clearConfigCb(usb_dev_t* dev, uint8_t config);
static uint8_t setupCb(usb_dev_t* dev, usb_setup_req_t* req);
Expand Down Expand Up @@ -104,8 +104,7 @@ class RtlUsbDriver : public DeviceDriver {
.rx_fifo_size = USBD_MAX_RX_FIFO_SIZE,
.nptx_fifo_size = USBD_MAX_NPTX_FIFO_SIZE,
.ptx_fifo_size = USBD_MAX_PTX_FIFO_SIZE,
.intr_use_ptx_fifo = 1, // ?
.speed = USBD_SPEED_FULL,
.speed = USB_SPEED_FULL,
.dma_enable = 0, // ?
.self_powered = 1,
.isr_priority = RTL_USBD_ISR_PRIORITY,
Expand All @@ -116,6 +115,8 @@ class RtlUsbDriver : public DeviceDriver {
.set_config = &setConfigCb,
.clear_config = &clearConfigCb,
.setup = &setupCb,
.get_class_descriptor = nullptr,
.clear_feature = nullptr,
.sof = nullptr, // This is not delivered
.suspend = &suspendCb,
.resume = &resumeCb,
Expand Down
2 changes: 1 addition & 1 deletion third_party/ambd_sdk/ambd_sdk
Submodule ambd_sdk updated 26 files
+17 −0 component/common/drivers/usb/common_new/usb_ch9.h
+0 −15 component/common/drivers/usb/common_new/usb_hal_rtl.h
+163 −85 component/common/drivers/usb/device_new/cdc_acm/usbd_cdc_acm.c
+41 −8 component/common/drivers/usb/device_new/cdc_acm/usbd_cdc_acm.h
+24 −28 component/common/drivers/usb/device_new/core/usbd.h
+243 −206 component/common/drivers/usb/device_new/hid/usbd_hid.c
+8 −6 component/common/drivers/usb/device_new/hid/usbd_hid.h
+871 −0 component/common/drivers/usb/device_new/loopback/usbd_loopback.c
+94 −0 component/common/drivers/usb/device_new/loopback/usbd_loopback.h
+209 −199 component/common/drivers/usb/device_new/msc/usbd_msc.c
+8 −4 component/common/drivers/usb/device_new/msc/usbd_msc.h
+129 −100 component/common/drivers/usb/device_new/msc/usbd_scsi.c
+3 −1 component/common/drivers/usb/device_new/msc/usbd_scsi.h
+147 −165 component/common/drivers/usb/device_new/vendor/usbd_vendor.c
+5 −10 component/common/drivers/usb/device_new/vendor/usbd_vendor.h
+102 −0 component/common/example/usbd_cdc_acm_new/RtkUsbCdcAcmSetup.INF
+177 −36 component/common/example/usbd_cdc_acm_new/example_usbd_cdc_acm_new.c
+64 −58 component/common/example/usbd_cdc_acm_new/readme.txt
+26 −22 component/common/example/usbd_hid_mouse_new/example_usbd_hid_mouse_new.c
+57 −57 component/common/example/usbd_hid_mouse_new/readme.txt
+2 −3 component/common/example/usbd_msc_new/example_usbd_msc_new.c
+60 −60 component/common/example/usbd_msc_new/readme.txt
+4 −48 component/common/example/usbd_vendor_new/example_usbd_vendor_new.c
+59 −59 component/common/example/usbd_vendor_new/readme.txt
+1,348 −0 component/soc/realtek/amebad/fwlib/include/rtl8721d_usb.h
+ project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp/asdk/lib/application/lib_usbd_new.a