Using new driver API

I tried to run driver recently created by @korli, but I can’t manage to make it loaded.

I use Haiku hrev54028 and I created i2c_drivers.hpkg package with following contents:

add-ons/kernel/bus_managers/i2c
add-ons/kernel/busses/i2c/pch_i2c

There are no i2c records in syslog and listimage. Reboot and ls -R /dev don’t help.

Did you add your own ACPI HID to pch_i2c_acpi.cpp?

Not yet. But isn’t it at least load and write something in syslog?

No, unless you enabled trace logs.

I added my device ID, enable tracing and add zero size check for MMIO to prevent “map_backing_store(): called with size=0 for area ‘PCHI2C memory mapped registers’!” KDL. Now something is working:

> i2c /dev/bus/i2c/1/bus_raw
Scanning I2C bus: /dev/bus/i2c/1/bus_raw
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: 00 -- -- -- -- -- -- -- -- 09 -- -- -- -- -- -- 
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

OK. It looks like it didn’t find TCS1. Is it the same on Linux?

I am not familiar with Linux kernel internals and I don’t know how to check it.

I2C6 avalible at /dev/bus/i2c/1/bus_raw that contains i2c HID touchscreen and pen sensor seems working. This tablet also have LED light controlled by i2c.

on ubuntu i2c-tools provides i2cdetect (usage : “sudo i2cdetect 0” for the first bus)

i2c devices in Windows 10:
i2c

Please have a look and comment on the PR https://review.haiku-os.org/c/haiku/+/2469 if it matches your needs.

Is it worth to test https://review.haiku-os.org/c/haiku/+/2466?

sure, it won’t be merged anyway. but it works more or less here for a touchpad (handled as a mouse, not WPT aka windows precision touchpad).

I tried to install i2c_hid, but it fails to load:

ERN: driver "i2c_hid" added
Last message repeated 1 time
KERN: devfs: "i2c_hid" api_version missing
KERN: devfs: "i2c_hid" mandatory driver symbol(s) missing!
KERN: devfs: reload driver "i2c_hid" (4, 126753)
KERN: devfs: "i2c_hid" api_version missing
KERN: devfs: "i2c_hid" mandatory driver symbol(s) missing!

I installed i2c_hid in same way as usb_hid (add-on in /drivers/bin and symlink in /drivers/input)

it’s new driver API, to be installed like acpi_battery for instance.

In what folder it should be installed? I also tried drivers/input and busses/i2c.

It should be in drivers/input.
But I forgot that the scan is not yet implemented for acpi pch_i2c devices.

Is there a quick fix for this, maybe editing device_manager.cpp?

https://git.haiku-os.org/haiku/tree/src/add-ons/kernel/busses/i2c/pch_i2c_acpi.cpp#n113

I implemented acpi_scan_bus and now i2c_hid is loaded and it recognize touchscreen and pen. But threre are no reaction on touchscreen and when attempt to use pen, cursor is moved once to fixed location unrelated to pen position.

Following errors are written to syslog:

KERN: i2c_hid: error waiting for report: Device/File/Resource busy
KERN: i2c_hid: scheduling transfer failed

It probably fails because there are two devices on the same bus. When one is talking to the bus, the other one should take a lock.
will merge this tomorrow if feedback is OK: https://review.haiku-os.org/c/haiku/+/2470