Skip to content

Kernel: Add HID over I²C support via the OpenCores I²C controller used in RVVM#26612

Open
spholz wants to merge 9 commits intoSerenityOS:masterfrom
spholz:rvvm-hid
Open

Kernel: Add HID over I²C support via the OpenCores I²C controller used in RVVM#26612
spholz wants to merge 9 commits intoSerenityOS:masterfrom
spholz:rvvm-hid

Conversation

@spholz
Copy link
Member

@spholz spholz commented Feb 15, 2026

This makes mouse and keyboard input work in RVVM!

Both the I²C abstraction and the OpenCores I²C controller driver is currently very basic.

(Note: Serenity currently hangs during boot in the latest released RVVM version, 0.6. I made a PR to cherry-pick a fix for this into our RVVM port: #26611)

This allows you to easily convert those types to ReadonlyBytes.
A similar struct is also defined in Drivers/HID.cpp, where it's actually
used.
We never query devices by their name, so using a HashMap is unnecessary.
Additionally, the next commit will make it possible for drivers to
scan for new child devices and probe drivers on them.
This means that the HashMap will then potentially resize while the
parent driver is still being probed, causing Device references to get
invalid.

Now that this code doesn't use a HashMap anymore, we need to ensure that
every device is only scanned once, so I added a comment mentioning that
requirement.
Alternatively, we could store a bool somewhere whether the device was
already scanned or not. But there's no good place to put that other
than in LibDeviceTree's Node class. However, I don't think we should
modify LibDeviceTree for this kernel-specific use case.
This will be necessary for bus drivers like I²C, where bus nodes have
children that get registered by the bus driver.

For reference, this is what an I²C controller node with its child
devices could look like:
```dts
i2c@deadbeef {
    compatible = "some,i2c-controller";
    reg = <0xdeadbeef>;

    i2c-device@8 {
        compatible = "some,i2c-device";
        reg = <0x8>;
    };
};
```
DeviceTree::Management will initially only scan for devices in the root
node and all child "simple-bus" nodes. For other bus nodes, bus drivers
are responsible for registering child devices since there is no simple
address translation for these kinds of buses and the bus driver might
need to initialize the bus first.

For I²C, the `reg` properties contain the I²C addresses. I²C controller
nodes don't have a `ranges` property since there is no address mapping
between the child and parent address space.
Similar to the API for interrupt controllers, this allows I²C drivers
to obtain a reference to its parent I²C controller.
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant