Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c - Use __BIT() macro to define I2C_F_* bits.



details:   https://anonhg.NetBSD.org/src/rev/2b23875764c3
branches:  trunk
changeset: 1017481:2b23875764c3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Dec 29 00:26:51 2020 +0000

description:
- Use __BIT() macro to define I2C_F_* bits.
- Define an I2C_F_SPEED bitfield that can be used to specify an
  I2C bus speed:

  -> Standard Mode (100Kb/s)
  -> Fast Mode (400Kb/s)
  -> Fast Mode Plus (1Mb/s)
  -> High Speed (3.4Mb/s)

The speed values are treated as advisory; if a controller does not support
the requested speed mode, fallback to a lower one is allowed.

(Currently, all controllers simply use Standard Mode.)

diffstat:

 sys/dev/i2c/i2cvar.h |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (34 lines):

diff -r 5bb5456e3a6b -r 2b23875764c3 sys/dev/i2c/i2cvar.h
--- a/sys/dev/i2c/i2cvar.h      Mon Dec 28 22:36:16 2020 +0000
+++ b/sys/dev/i2c/i2cvar.h      Tue Dec 29 00:26:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2cvar.h,v 1.20 2020/07/07 16:14:23 thorpej Exp $      */
+/*     $NetBSD: i2cvar.h,v 1.21 2020/12/29 00:26:51 thorpej Exp $      */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -44,12 +44,18 @@
 #include <prop/proplib.h>
 
 /* Flags passed to i2c routines. */
-#define        I2C_F_WRITE             0x00    /* new transfer is a write */
-#define        I2C_F_READ              0x01    /* new transfer is a read */
-#define        I2C_F_LAST              0x02    /* last byte of read */
-#define        I2C_F_STOP              0x04    /* send stop after byte */
-#define        I2C_F_POLL              0x08    /* poll, don't sleep */
-#define        I2C_F_PEC               0x10    /* smbus packet error checking */
+#define        I2C_F_WRITE     0               /* new transfer is a write */
+#define        I2C_F_READ      __BIT(0)        /* new transfer is a read */
+#define        I2C_F_LAST      __BIT(1)        /* last byte of read */
+#define        I2C_F_STOP      __BIT(2)        /* send stop after byte */
+#define        I2C_F_POLL      __BIT(3)        /* poll, don't sleep */
+#define        I2C_F_PEC       __BIT(4)        /* smbus packet error checking */
+#define        I2C_F_SPEED     __BITS(28,31)   /* I2C transfer speed selector */
+
+#define        I2C_SPEED_SM            0       /* standard mode (100Kb/s) */
+#define        I2C_SPEED_FM            1       /* fast mode (400Kb/s) */
+#define        I2C_SPEED_FMPLUS        2       /* fast mode+ (1Mb/s) */
+#define        I2C_SPEED_HS            3       /* high speed (3.4Mb/s) */
 
 /* i2c bus instance properties */
 #define        I2C_PROP_INDIRECT_PROBE_STRATEGY        \



Home | Main Index | Thread Index | Old Index