tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

HID over I2C: I2C changes



Hello,                                                   
newer laptops have touchpad connected to an I2C controller instead of
PS/2 or USB, and we don't support this yet.              
To support this we need a few adjustements to existing subsystems.
This mail is about the changes to I2C. Changes on USB/HID will
follow in separate mail, ACPI changes have already been sent.

Changes needed to the I2C framework are minor.
I2C HID devices have an extra property registered, "hid-descr-addr".
Instead of adding device-specific members to i2c_attach_args,
I propose to pass the whole dictionary to the child as ia_prop.
See attached diff.

Maybe we could then remove some members from i2c_attach_args,
like ia_cookie. I've not tried this yet (ia_size appears as a good
candidate but it's a cf_loc for direct-config busses).

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
Index: dev/i2c/i2c.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/i2c.c,v
retrieving revision 1.56
diff -u -p -u -r1.56 i2c.c
--- dev/i2c/i2c.c	28 Oct 2017 04:53:55 -0000	1.56
+++ dev/i2c/i2c.c	1 Dec 2017 15:19:30 -0000
@@ -140,6 +140,7 @@ iic_search(device_t parent, cfdata_t cf,
 	ia.ia_name = NULL;
 	ia.ia_ncompat = 0;
 	ia.ia_compat = NULL;
+	ia.ia_prop = NULL;
 
 	for (ia.ia_addr = 0; ia.ia_addr <= I2C_MAX_ADDR; ia.ia_addr++) {
 		if (sc->sc_devices[ia.ia_addr] != NULL)
@@ -262,6 +263,7 @@ iic_attach(device_t parent, device_t sel
 			ia.ia_name = name;
 			ia.ia_cookie = cookie;
 			ia.ia_size = size;
+			ia.ia_prop = dev;
 
 			buf = NULL;
 			cdata = prop_dictionary_get(dev, "compatible");
Index: dev/i2c/i2cvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/i2cvar.h,v
retrieving revision 1.9
diff -u -p -u -r1.9 i2cvar.h
--- dev/i2c/i2cvar.h	13 Dec 2015 17:14:56 -0000	1.9
+++ dev/i2c/i2cvar.h	1 Dec 2017 15:19:30 -0000
@@ -125,6 +125,7 @@ struct i2c_attach_args {
 	int		ia_ncompat;	/* number of pointers in the
 					   ia_compat array */
 	const char **	ia_compat;	/* chip names */
+	prop_dictionary_t ia_prop;	/* dictionnary for this device */
 	/*
 	 * The following is of limited usefulness and should only be used
 	 * in rare cases where we really know what we are doing. Example:
@@ -134,6 +135,8 @@ struct i2c_attach_args {
 	 * may be present. Example: on OpenFirmware machines the device
 	 * tree OF node - if available. This info is hard to transport
 	 * down to MD drivers through the MI i2c bus otherwise.
+	 * 
+	 * On ACPI platforms this is the ACPI_HANDLE of the device.
 	 */
 	uintptr_t	ia_cookie;	/* OF node in openfirmware machines */
 };


Home | Main Index | Thread Index | Old Index