Opened 6 years ago

Last modified 5 years ago

#14977 new enhancement

I2C/smbus keyboards and touchpads support

Reported by: adamfowleruk Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Drivers/Input/HID/I2C Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

As per the forum, I've installed Haiku hrev53001 on my PC Specialist Recoil II. The Keyboard and Trackpad do not operate.

Please suggest a solution / missing driver that needs writing.

Attached are the relevant logs. I shall add further windows trace files from prior to Haiku install later too.

Attachments (4)

listdev.txt (3.0 KB ) - added by adamfowleruk 6 years ago.
listusb.txt (612 bytes ) - added by adamfowleruk 6 years ago.
syslog.txt (115.6 KB ) - added by adamfowleruk 6 years ago.
research.zip (460.4 KB ) - added by adamfowleruk 6 years ago.
acpidump and wii demo output on Linux Mint when both trackpad and keyboard were working

Download all attachments as: .zip

Change History (16)

by adamfowleruk, 6 years ago

Attachment: listdev.txt added

by adamfowleruk, 6 years ago

Attachment: listusb.txt added

by adamfowleruk, 6 years ago

Attachment: syslog.txt added

by adamfowleruk, 6 years ago

Attachment: research.zip added

acpidump and wii demo output on Linux Mint when both trackpad and keyboard were working

comment:1 by adamfowleruk, 6 years ago

Here's a thread that references the issue. I can confirm the keyboard worked OOTB in Linux Mint, but the trackpad required the 4.19 kernel.

I think now actually the keyboard was a PS/2 derivative, and the trackpad was the I2C device. It's just the keyboard LIGHTING that's a WMI device. That may well make it simpler.

https://askubuntu.com/questions/1070644/tongfang-gk5cn6z-ubuntu-touchpad-and-keyboard-backlight

comment:2 by waddlesplash, 6 years ago

Component: Drivers/InputDrivers/Input/PS2
Summary: Add support for devices in Recoil IIPS2: multiplexing and reset failed

This part I have not seen before:

KERN: ps2: active multiplexing v1.1 enabled
KERN: ps2: accessing multiplexed mouse port 0 timed out, ignoring it!

This part looks to have the same message as #14856:

KERN: ps2: reset failed
KERN: ps2: devfs_publish_device input/mouse/ps2/3, status = 0xffffffff
KERN: ps2: devfs_publish_device input/keyboard/at/0, status = 0x00000000
KERN: register_domain(4, link)
KERN: ps2: keyboard reset failed, status 0x80000009, data 0xff
KERN: ps2: keyboard probing failed

Likely the first message is the "actual" problem.

comment:3 by pulkomandy, 6 years ago

Synaptics docs on PS/2 multiplexing http://www.isdaman.com/alsos/hardware/mouse/mouse2.pdf

This would normally be used only for pointing devices, but could it be that in your case they multiplexed the keyboard with the touchpad, to connect them both to a single port and save on wiring maybe?

comment:5 by adamfowleruk, 6 years ago

This looks promising as a base library to use for i2c communication:- http://xref.plausible.coop/source/xref/haiku/src/add-ons/kernel/drivers/dvb/cx23882/i2c_core.c

Probably a good idea to start writing an i2cdetect and test utility to allow drivers to be created. What do we think?

Version 0, edited 6 years ago by adamfowleruk (next)

comment:6 by pulkomandy, 6 years ago

We have a software implementation of I2C for probing EDID in VGA displays: http://xref.plausible.coop/source/xref/haiku/src/add-ons/accelerants/common/i2c.c

However I don't know if that would be of much help here.

i2cdetect itself will be easily ported, however, you will need drivers for whatever implements the I2C bus in your case. There is a standard one on motherboards (SMBus), there is a separate one for EDID display (on the graphics card), and there may be more (the datasheet for the touchpad apparently suggests wiring it to the WiFi controller). So, before going further, you would need to figure out which I2C controller is actually used to connect this touchpad. You will need a driver for that, and only then you can make a driver for the touchpad itself.

I2C is a standard protocol, but there is no standard host controller for it (like there is XHCI for USB, for example). The protocol is simple and slow enough that it can be implemented entirely in software using a GPIO line (manually driving the pins to 1 and 0 with careful timing to create the required signal), but it can also be done in hardware, to save CPU use, especially if there is a lot of data to send or it runs at high speeds.

The file I linked is a software implementation.

We also have the i2c_core.c you linked already in tree: http://xref.plausible.coop/source/xref/haiku/src/add-ons/kernel/drivers/dvb/cx23882/i2c_core.c (this one is in a driver for TV tuners, I2C is originally a TV manufacturer standard, to simplify wiring in TVs as they started adding more and more electronics to them).

And we have various I2C implementations in video drivers (also for EDID), some using the generic file I linked above, some using custom code, apparently (and they should be refactored to use the common code, I guess, unless there is indeed some hardware acceleration going on).

It probably makes sense to implement a driver exposing your I2C bus in a way compatible to either FreeBSD's or Linux tools (implementing the same ioctls).

comment:7 by adamfowleruk, 6 years ago

From the discussions on the Linux Kernel site about my device, it appears the keyboard connects to the I2C adapter on the Intel PCH south bridge. This is detectable from PCI (See #14980 for PCI ids file issue). This supports SMBus rather than generic I2C.

So I'll need to detect Intel chips and their PCH subsystems, then expose an SMBus compliant interface in order to talk to various types of hardware.

On the plus side, it will also give Haiku access to other sensors and devices that may be attached. Anything from temperature sensors, to accelerometers, to trackpads... And my keyboard. :)

I'll start reading the source for how Linux and FreeBSD do it, then write a proposal for you guys, before I write any code. It's probably a fairly big job, even if the protocol itself is simple. Drivers built on top of drivers...

comment:8 by pulkomandy, 6 years ago

That makes sense then (from a costs saving perspective, at least), they can get rid of the whole PS/2 support and use the existing SMBus wiring.

So, you will need an SMBus bus and bus_manager, using the device_manager API. It can publish the bus under /dev/bus/i2c/... for linux/freeBSD userland tools to play with it (this will ease testing, I guess), and expose a way for kernel-side drivers to probe it for devices and publish their own nodes.

comment:9 by waddlesplash, 6 years ago

Summary: PS2: multiplexing and reset failedPS2: implement "active multiplexing"

So, actually what's going on here is that there is a new (yes, imagine that!) type of PS/2 multiplexing called "active multiplexing" that we need to implement at the bus level.

Here's the FreeBSD commit implementing just enough of it to do configuration, from November of just last year: https://github.com/freebsd/freebsd/commit/96d45629821938bb1112a2927535366404775290

It's possible, since our PS/2 system is simpler, that we could get away with even less than the ~250 lines FreeBSD needs. Either way, someone with the relevant hardware will need to attempt the work... :)

comment:10 by waddlesplash, 6 years ago

Hmm, actually it seems the multiplexing we implement already is "active multiplexing", though it looks like this is a newer version than we actually support.

comment:11 by pulkomandy, 5 years ago

Component: Drivers/Input/PS2Drivers/Input
Summary: PS2: implement "active multiplexing"I2C/smbus keyboards and touchpads support

comment:12 by korli, 5 years ago

Component: Drivers/InputDrivers/Input/I2C-HID
Note: See TracTickets for help on using tickets.