Using new driver API

In the old driver model there is no reservation system and multiple drivers can attempt to use the same hardware. I guess BeOS engineers would already be very happy that there could be one driver for each device, they didn’t think that there could ever be two?

I managed to find ACPI device and call get_current_resources, but returned MMIO range was 0x00000000 .. 0x00000fff. Why start address is zero? Does some initialization sequence required to set MMIO?

On Windows 10 MMIO range is 0x91927000 .. 0x91927fff.

Well, Haiku still boots pretty quickly, and drivers mostly work, so we have not yet run into anything that we need to fix in order to move forward. Certainly we should redesign this for all the reasons you mentioned, but it’s not really holding back the system right now.

2 Likes

Attempt to use test driver on target machine failed because of https://dev.haiku-os.org/ticket/15702.

After adding additional compiler flags I managed to compile test driver on 86_64 and run it on target machine. MMIO range was successfully detected and value is same as in Windows 10. Now I can communicate to I2C controller (I hope).
Syslog:

KERN: driver "acpi_test" added
KERN: devfs: reload driver "acpi_test" (3, 2623034)
KERN: acpi_test: Found device: "\_SB_.PCI0.I2C1"
KERN: acpi_test: Found device: "\_SB_.PCI0.I2C2"
KERN: acpi_test: Found device: "\_SB_.PCI0.I2C3"
KERN: acpi_test: Found device: "\_SB_.PCI0.I2C5"
KERN: acpi_test: Found device: "\_SB_.PCI0.I2C6"
KERN: acpi_test: Found device: "\_SB_.PCI0.I2C7"
KERN: acpi_test: handle: 0xffffffff82b19ba8
KERN: acpi_test: HID: "808622C1"
KERN: acpi_test: _PS0 called
KERN: acpi_test: _STA: 1, 15
KERN: acpi_test: MMIO: 91927000, 4096
KERN: acpi_test: IRQ: 37
KERN: acpi_test: DMA: 26, 2, 2
KERN: acpi_test: DMA: 27, 3, 2
3 Likes

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.