Skip to content

Commit 7c16f0a

Browse files
committed
Merge tag 'i2c-for-6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "The core gains placeholders for recently added functions when CONFIG_I2C is not defined as well documentation fixes to start using inclusive terminology. The drivers get paths in DT bindings fixed as well as proper interrupt handling for the ocores driver" * tag 'i2c-for-6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: docs: i2c: summary: be clearer with 'controller/target' and 'adapter/client' pairs docs: i2c: summary: document 'local' and 'remote' targets docs: i2c: summary: document use of inclusive language docs: i2c: summary: update speed mode description docs: i2c: summary: update I2C specification link docs: i2c: summary: start sentences consistently. i2c: Add nop fwnode operations i2c: ocores: set IACK bit after core is enabled dt-bindings: i2c: google,cros-ec-i2c-tunnel: correct path to i2c-controller schema dt-bindings: i2c: atmel,at91sam: correct path to i2c-controller schema
2 parents d14f278 + 2c50f89 commit 7c16f0a

File tree

6 files changed

+83
-41
lines changed

6 files changed

+83
-41
lines changed

Documentation/devicetree/bindings/i2c/atmel,at91sam-i2c.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ required:
7777
- clocks
7878

7979
allOf:
80-
- $ref: i2c-controller.yaml
80+
- $ref: /schemas/i2c/i2c-controller.yaml#
8181
- if:
8282
properties:
8383
compatible:

Documentation/devicetree/bindings/i2c/google,cros-ec-i2c-tunnel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ description: |
2121
google,cros-ec-spi or google,cros-ec-i2c.
2222
2323
allOf:
24-
- $ref: i2c-controller.yaml#
24+
- $ref: /schemas/i2c/i2c-controller.yaml#
2525

2626
properties:
2727
compatible:

Documentation/i2c/i2c_bus.svg

Lines changed: 8 additions & 7 deletions
Loading

Documentation/i2c/summary.rst

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,80 @@ Introduction to I2C and SMBus
33
=============================
44

55
I²C (pronounce: I squared C and written I2C in the kernel documentation) is
6-
a protocol developed by Philips. It is a slow two-wire protocol (variable
7-
speed, up to 400 kHz), with a high speed extension (3.4 MHz). It provides
6+
a protocol developed by Philips. It is a two-wire protocol with variable
7+
speed (typically up to 400 kHz, high speed modes up to 5 MHz). It provides
88
an inexpensive bus for connecting many types of devices with infrequent or
9-
low bandwidth communications needs. I2C is widely used with embedded
10-
systems. Some systems use variants that don't meet branding requirements,
9+
low bandwidth communications needs. I2C is widely used with embedded
10+
systems. Some systems use variants that don't meet branding requirements,
1111
and so are not advertised as being I2C but come under different names,
1212
e.g. TWI (Two Wire Interface), IIC.
1313

14-
The latest official I2C specification is the `"I2C-bus specification and user
15-
manual" (UM10204) <https://www.nxp.com/webapp/Download?colCode=UM10204>`_
16-
published by NXP Semiconductors. However, you need to log-in to the site to
17-
access the PDF. An older version of the specification (revision 6) is archived
18-
`here <https://web.archive.org/web/20210813122132/https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_.
14+
The latest official I2C specification is the `"I²C-bus specification and user
15+
manual" (UM10204) <https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_
16+
published by NXP Semiconductors, version 7 as of this writing.
1917

2018
SMBus (System Management Bus) is based on the I2C protocol, and is mostly
21-
a subset of I2C protocols and signaling. Many I2C devices will work on an
19+
a subset of I2C protocols and signaling. Many I2C devices will work on an
2220
SMBus, but some SMBus protocols add semantics beyond what is required to
23-
achieve I2C branding. Modern PC mainboards rely on SMBus. The most common
21+
achieve I2C branding. Modern PC mainboards rely on SMBus. The most common
2422
devices connected through SMBus are RAM modules configured using I2C EEPROMs,
2523
and hardware monitoring chips.
2624

2725
Because the SMBus is mostly a subset of the generalized I2C bus, we can
28-
use its protocols on many I2C systems. However, there are systems that don't
26+
use its protocols on many I2C systems. However, there are systems that don't
2927
meet both SMBus and I2C electrical constraints; and others which can't
3028
implement all the common SMBus protocol semantics or messages.
3129

3230

3331
Terminology
3432
===========
3533

36-
Using the terminology from the official documentation, the I2C bus connects
37-
one or more *master* chips and one or more *slave* chips.
34+
The I2C bus connects one or more controller chips and one or more target chips.
3835

3936
.. kernel-figure:: i2c_bus.svg
40-
:alt: Simple I2C bus with one master and 3 slaves
37+
:alt: Simple I2C bus with one controller and 3 targets
4138

4239
Simple I2C bus
4340

44-
A **master** chip is a node that starts communications with slaves. In the
45-
Linux kernel implementation it is called an **adapter** or bus. Adapter
46-
drivers are in the ``drivers/i2c/busses/`` subdirectory.
41+
A **controller** chip is a node that starts communications with targets. In the
42+
Linux kernel implementation it is also called an "adapter" or "bus". Controller
43+
drivers are usually in the ``drivers/i2c/busses/`` subdirectory.
4744

48-
An **algorithm** contains general code that can be used to implement a
49-
whole class of I2C adapters. Each specific adapter driver either depends on
50-
an algorithm driver in the ``drivers/i2c/algos/`` subdirectory, or includes
51-
its own implementation.
45+
An **algorithm** contains general code that can be used to implement a whole
46+
class of I2C controllers. Each specific controller driver either depends on an
47+
algorithm driver in the ``drivers/i2c/algos/`` subdirectory, or includes its
48+
own implementation.
5249

53-
A **slave** chip is a node that responds to communications when addressed
54-
by the master. In Linux it is called a **client**. Client drivers are kept
55-
in a directory specific to the feature they provide, for example
56-
``drivers/media/gpio/`` for GPIO expanders and ``drivers/media/i2c/`` for
50+
A **target** chip is a node that responds to communications when addressed by a
51+
controller. In the Linux kernel implementation it is also called a "client".
52+
While targets are usually separate external chips, Linux can also act as a
53+
target (needs hardware support) and respond to another controller on the bus.
54+
This is then called a **local target**. In contrast, an external chip is called
55+
a **remote target**.
56+
57+
Target drivers are kept in a directory specific to the feature they provide,
58+
for example ``drivers/gpio/`` for GPIO expanders and ``drivers/media/i2c/`` for
5759
video-related chips.
5860

59-
For the example configuration in figure, you will need a driver for your
60-
I2C adapter, and drivers for your I2C devices (usually one driver for each
61-
device).
61+
For the example configuration in the figure above, you will need one driver for
62+
the I2C controller, and drivers for your I2C targets. Usually one driver for
63+
each target.
64+
65+
Synonyms
66+
--------
67+
68+
As mentioned above, the Linux I2C implementation historically uses the terms
69+
"adapter" for controller and "client" for target. A number of data structures
70+
have these synonyms in their name. So, when discussing implementation details,
71+
you should be aware of these terms as well. The official wording is preferred,
72+
though.
73+
74+
Outdated terminology
75+
--------------------
76+
77+
In earlier I2C specifications, controller was named "master" and target was
78+
named "slave". These terms have been obsoleted with v7 of the specification and
79+
their use is also discouraged by the Linux Kernel Code of Conduct. You may
80+
still find them in references to documentation which has not been updated. The
81+
general attitude, however, is to use the inclusive terms: controller and
82+
target. Work to replace the old terminology in the Linux Kernel is on-going.

drivers/i2c/busses/i2c-ocores.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ static int ocores_init(struct device *dev, struct ocores_i2c *i2c)
431431
oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8);
432432

433433
/* Init the device */
434-
oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
435434
oc_setreg(i2c, OCI2C_CONTROL, ctrl | OCI2C_CTRL_EN);
435+
oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK);
436436

437437
return 0;
438438
}

include/linux/i2c.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,6 @@ int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr);
960960
#define builtin_i2c_driver(__i2c_driver) \
961961
builtin_driver(__i2c_driver, i2c_add_driver)
962962

963-
#endif /* I2C */
964-
965963
/* must call put_device() when done with returned i2c_client device */
966964
struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode);
967965

@@ -971,6 +969,28 @@ struct i2c_adapter *i2c_find_adapter_by_fwnode(struct fwnode_handle *fwnode);
971969
/* must call i2c_put_adapter() when done with returned i2c_adapter device */
972970
struct i2c_adapter *i2c_get_adapter_by_fwnode(struct fwnode_handle *fwnode);
973971

972+
#else /* I2C */
973+
974+
static inline struct i2c_client *
975+
i2c_find_device_by_fwnode(struct fwnode_handle *fwnode)
976+
{
977+
return NULL;
978+
}
979+
980+
static inline struct i2c_adapter *
981+
i2c_find_adapter_by_fwnode(struct fwnode_handle *fwnode)
982+
{
983+
return NULL;
984+
}
985+
986+
static inline struct i2c_adapter *
987+
i2c_get_adapter_by_fwnode(struct fwnode_handle *fwnode)
988+
{
989+
return NULL;
990+
}
991+
992+
#endif /* !I2C */
993+
974994
#if IS_ENABLED(CONFIG_OF)
975995
/* must call put_device() when done with returned i2c_client device */
976996
static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)

0 commit comments

Comments
 (0)