Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c More cleanup to i2c autoconfiguration:
details: https://anonhg.NetBSD.org/src/rev/b3883b7003da
branches: trunk
changeset: 319959:b3883b7003da
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Jun 16 21:24:36 2018 +0000
description:
More cleanup to i2c autoconfiguration:
- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.
XXX This driver is an odd-ball with respect to the hardware device.
See comments in the match routine. Unclear how best to handle it.
diffstat:
sys/dev/i2c/hytp14.c | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diffs (49 lines):
diff -r 8a1c20f99fb6 -r b3883b7003da sys/dev/i2c/hytp14.c
--- a/sys/dev/i2c/hytp14.c Sat Jun 16 21:22:13 2018 +0000
+++ b/sys/dev/i2c/hytp14.c Sat Jun 16 21:24:36 2018 +0000
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.7 2016/07/03 12:26:55 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hytp14.c,v 1.8 2018/06/16 21:24:36 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,19 +98,25 @@
static int
hytp14_match(device_t parent, cfdata_t match, void *aux)
{
- struct i2c_attach_args *ia;
+ struct i2c_attach_args *ia = aux;
+ int match_result;
- ia = aux;
+ if (iic_use_direct_match(ia, match, NULL, &match_result))
+ return match_result;
- if (ia->ia_name) {
- /* direct config - check name */
- if (strcmp(ia->ia_name, "hythygtemp") == 0)
- return 1;
- } else {
- /* indirect config - check for configured address */
- if ((ia->ia_addr > 0) && (ia->ia_addr <= 0x7F))
- return 1;
- }
+ if (ia->ia_addr == 0x28)
+ return I2C_MATCH_ADDRESS_ONLY;
+
+ /*
+ * XXXJRT
+ * This device is an odd-ball; the i2c address can be changed
+ * at run-time using a command sequence documented in the
+ * application note, but the timing is critical (within 10ms
+ * after power-on of the device), and the device always starts
+ * up at address 0x28.
+ *
+ * How should we handle this?
+ */
return 0;
}
Home |
Main Index |
Thread Index |
Old Index