-
Notifications
You must be signed in to change notification settings - Fork 11
[opentitan, usbdev] Create a dummy usbdev block #180
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
base: ot-earlgrey-9.2.0
Are you sure you want to change the base?
Conversation
b3d7d26
to
49df0bb
Compare
There was a problem hiding this 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?
hw/riscv/ot_earlgrey.c
Outdated
// 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) |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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/hw/opentitan/ot_usbdev.h
Outdated
#include "qom/object.h" | ||
|
||
#define TYPE_OT_USBDEV "ot-usbdev" | ||
OBJECT_DECLARE_SIMPLE_TYPE(OtUSBDEVState, OT_USBDEV) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
hw/riscv/ot_earlgrey.c
Outdated
.gpio = IBEXGPIOCONNDEFS( | ||
OT_EG_SOC_GPIO_ALERT(0, 21) | ||
) | ||
// IBEX_DEV_STRING_PROP("ot_id", "usbdev"), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
hw/riscv/ot_earlgrey.c
Outdated
@@ -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" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Signed-off-by: Douglas Reis <[email protected]> Signed-off-by: Amaury Pouly <[email protected]>
Replaces #164