Skip to content

Conversation

pamaury
Copy link

@pamaury pamaury commented Sep 10, 2025

Replaces #164

@pamaury pamaury changed the base branch from usbdev to ot-earlgrey-9.2.0 September 10, 2025 11:51
@pamaury pamaury force-pushed the usbdev branch 2 times, most recently from b3d7d26 to 49df0bb Compare September 10, 2025 12:48
Copy link

@rivos-eblot rivos-eblot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we want to merge a full dummy device.
It seems for now it does nothing really useful(?)

What does this bring vs. the OT_UNIMP device it replaces?

// IBEX_DEV_STRING_PROP("ot_id", "usbdev"),
// IBEX_DEV_UINT_PROP("irq-count", 18u),
// IBEX_DEV_UINT_PROP("alert-count", 1u),
IBEX_DEV_UINT_PROP("pclk", OT_EG_USBDEV_CLK_HZ)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an outdated way to configure the clock. USB device should be connected to the clock manager instead (see other peripherals for example, e.g. OT_UART)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may have commented on the old version of the PR? The current version does not have pclk anymore. Can you let me know if the code is correct though?

#include "qom/object.h"

#define TYPE_OT_USBDEV "ot-usbdev"
OBJECT_DECLARE_SIMPLE_TYPE(OtUSBDEVState, OT_USBDEV)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also an outdated syntax, since device class need to be defined, so that the non-legacy reset function needs to be defined. See other OT devices for examples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it to OBJECT_DECLARE_TYPE which seems to be what the other devices use

.gpio = IBEXGPIOCONNDEFS(
OT_EG_SOC_GPIO_ALERT(0, 21)
)
// IBEX_DEV_STRING_PROP("ot_id", "usbdev"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code to be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a comment on the outdated code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a comment on the outdated code

Please let me know when it is ready to review: even when I refresh I see comments that seem more recent than the actual code which seems to move while I review it :-)

review

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum interesting ^^ I will move the PR to draft and set it to ready againa after I fixed everything

@@ -66,6 +66,7 @@
#include "hw/opentitan/ot_sram_ctrl.h"
#include "hw/opentitan/ot_timer.h"
#include "hw/opentitan/ot_uart.h"
#include "hw/opentitan/ot_usbdev.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems in wrong order, see scripts/opentitan/ot-format.sh

Note that we discovered earlier this week that the CI does not fail when this script is called (it is missing some extra commands that are part of the gitlab CI but did not make it to the github version, my mistake)

FIELD(USBCTRL, RESUME_LINK_ACTIVE, 1u, 1u)
FIELD(USBCTRL, DEVICE_ADDRESS, 16u, 7u)
REG32(EP_OUT_ENABLE, 0x14u)
FIELD(EP_OUT_ENABLE, ENABLE_0, 0u, 1u)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHARED_FIELD() should be used whenever possible, for endpoints and configs it might be useful. Or maybe in this specific cases, it does not really make sense to define bitfields at all, only a mask (1u << ENDPOINT_COUNT) - 1u would be more useful.

I have not look at the USB device implementation: it the number of endpoints is configurable, it might even make sense to define it as a property and only use it for validation/management.

@pamaury pamaury marked this pull request as draft September 10, 2025 13:16
Signed-off-by: Douglas Reis <[email protected]>
Signed-off-by: Amaury Pouly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants