linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca@lucaceresoli.net>
To: linux-i2c@vger.kernel.org, linux-doc@vger.kernel.org
Cc: Luca Ceresoli <luca@lucaceresoli.net>,
	Wolfram Sang <wsa@the-dreams.de>, Jean Delvare <jdelvare@suse.de>,
	Peter Rosin <peda@axentia.se>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 21/28] docs: i2c: instantiating-devices: rearrange static instatiation
Date: Wed, 29 Jan 2020 16:19:46 +0100	[thread overview]
Message-ID: <20200129151953.31582-22-luca@lucaceresoli.net> (raw)
In-Reply-To: <20200129151953.31582-1-luca@lucaceresoli.net>


Among the "static" instantiation methods the "board file" method is
described first. Move it as last, since it is being replaced by the other
methods.

Also fix subsubsection heading syntax and remove the "Method 1[abc]"
prefix as the subsubsection structure clarifies the logical hierarchy.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>

---

Changes in v2:
 - add clarifying commas, make empty lines consistent (Jean Delvare)
---
 Documentation/i2c/instantiating-devices.rst | 97 ++++++++++++---------
 1 file changed, 54 insertions(+), 43 deletions(-)

diff --git a/Documentation/i2c/instantiating-devices.rst b/Documentation/i2c/instantiating-devices.rst
index e823c4ad4e7f..665bf00792ba 100644
--- a/Documentation/i2c/instantiating-devices.rst
+++ b/Documentation/i2c/instantiating-devices.rst
@@ -9,54 +9,27 @@ reason, the kernel code must instantiate I2C devices explicitly. There are
 several ways to achieve this, depending on the context and requirements.
 
 
-Method 1a: Declare the I2C devices by bus number
-------------------------------------------------
+Method 1: Declare the I2C devices statically
+--------------------------------------------
 
 This method is appropriate when the I2C bus is a system bus as is the case
-for many embedded systems. On such systems, each I2C bus has a number
-which is known in advance. It is thus possible to pre-declare the I2C
-devices which live on this bus. This is done with an array of struct
-i2c_board_info which is registered by calling i2c_register_board_info().
+for many embedded systems. On such systems, each I2C bus has a number which
+is known in advance. It is thus possible to pre-declare the I2C devices
+which live on this bus.
 
-Example (from omap2 h4)::
+This information is provided to the kernel in a different way on different
+architectures: device tree, ACPI or board files.
 
-  static struct i2c_board_info h4_i2c_board_info[] __initdata = {
-	{
-		I2C_BOARD_INFO("isp1301_omap", 0x2d),
-		.irq		= OMAP_GPIO_IRQ(125),
-	},
-	{	/* EEPROM on mainboard */
-		I2C_BOARD_INFO("24c01", 0x52),
-		.platform_data	= &m24c01,
-	},
-	{	/* EEPROM on cpu card */
-		I2C_BOARD_INFO("24c01", 0x57),
-		.platform_data	= &m24c01,
-	},
-  };
-
-  static void __init omap_h4_init(void)
-  {
-	(...)
-	i2c_register_board_info(1, h4_i2c_board_info,
-			ARRAY_SIZE(h4_i2c_board_info));
-	(...)
-  }
-
-The above code declares 3 devices on I2C bus 1, including their respective
-addresses and custom data needed by their drivers. When the I2C bus in
-question is registered, the I2C devices will be instantiated automatically
-by i2c-core.
+When the I2C bus in question is registered, the I2C devices will be
+instantiated automatically by i2c-core. The devices will be automatically
+unbound and destroyed when the I2C bus they sit on goes away (if ever).
 
-The devices will be automatically unbound and destroyed when the I2C bus
-they sit on goes away (if ever.)
 
+Declare the I2C devices via devicetree
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Method 1b: Declare the I2C devices via devicetree
--------------------------------------------------
-
-This method has the same implications as method 1a. The declaration of I2C
-devices is here done via devicetree as subnodes of the master controller.
+On platforms using devicetree, the declaration of I2C devices is done in
+subnodes of the master controller.
 
 Example::
 
@@ -82,13 +55,51 @@ additional properties which might be needed to set up the device, please refer
 to its devicetree documentation in Documentation/devicetree/bindings/.
 
 
-Method 1c: Declare the I2C devices via ACPI
--------------------------------------------
+Declare the I2C devices via ACPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 ACPI can also describe I2C devices. There is special documentation for this
 which is currently located at :doc:`../firmware-guide/acpi/enumeration`.
 
 
+Declare the I2C devices in board files
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In many embedded architectures, devicetree has replaced the old hardware
+description based on board files, but the latter are still used in old
+code. Instantiating I2C devices via board files is done with an array of
+struct i2c_board_info which is registered by calling
+i2c_register_board_info().
+
+Example (from omap2 h4)::
+
+  static struct i2c_board_info h4_i2c_board_info[] __initdata = {
+	{
+		I2C_BOARD_INFO("isp1301_omap", 0x2d),
+		.irq		= OMAP_GPIO_IRQ(125),
+	},
+	{	/* EEPROM on mainboard */
+		I2C_BOARD_INFO("24c01", 0x52),
+		.platform_data	= &m24c01,
+	},
+	{	/* EEPROM on cpu card */
+		I2C_BOARD_INFO("24c01", 0x57),
+		.platform_data	= &m24c01,
+	},
+  };
+
+  static void __init omap_h4_init(void)
+  {
+	(...)
+	i2c_register_board_info(1, h4_i2c_board_info,
+			ARRAY_SIZE(h4_i2c_board_info));
+	(...)
+  }
+
+The above code declares 3 devices on I2C bus 1, including their respective
+addresses and custom data needed by their drivers.
+
+
 Method 2: Instantiate the devices explicitly
 --------------------------------------------
 
-- 
2.25.0


  parent reply	other threads:[~2020-01-29 16:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 15:19 [PATCH v3 00/28] docs: i2c: rework I2C documentation, part I Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 01/28] docs: i2c: sort index logically Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 02/28] docs: i2c: summary: extend introduction Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 03/28] docs: i2c: summary: rewrite the "terminology" section Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 04/28] docs: i2c: call it "I2C" consistently Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 05/28] docs: i2c: fix typo Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 06/28] docs: i2c: replace "I2C-transfer" -> "I2C transfer" consistently Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 07/28] docs: i2c: i2c-protocol: fix kernel-doc function syntax Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 08/28] docs: i2c: i2c-protocol: properly name start and stop conditions Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 09/28] docs: i2c: i2c-protocol: remove unneeded colons from table Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 10/28] docs: i2c: i2c-protocol: use proper names for ACK and NACK Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 11/28] docs: i2c: smbus-protocol: fix link syntax Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 12/28] docs: i2c: smbus-protocol: properly name start and stop conditions Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 13/28] docs: i2c: smbus-protocol: remove unneeded colons from table Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 14/28] docs: i2c: smbus-protocol: use proper names for ACK and NACK Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 15/28] docs: i2c: smbus-protocol: enable kernel-doc function syntax Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 16/28] docs: i2c: smbus-protocol: fix " Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 17/28] docs: i2c: smbus-protocol: fix typo Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 18/28] docs: i2c: smbus-protocol: fix punctuation Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 19/28] docs: i2c: smbus-protocol: improve I2C Block transactions description Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 20/28] docs: i2c: instantiating-devices: fix internal hyperlink Luca Ceresoli
2020-01-29 15:19 ` Luca Ceresoli [this message]
2020-01-29 15:19 ` [PATCH v3 22/28] docs: i2c: instantiating-devices: use monospace for sysfs attributes Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 23/28] docs: i2c: old-module-parameters: fix internal hyperlink Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 24/28] docs: i2c: old-module-parameters: clarify this is for obsolete kernels Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 25/28] docs: i2c: old-module-parameters: use monospace instead of "" Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 26/28] docs: i2c: rename sections so the overall picture is clearer Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 27/28] docs: i2c: i2c-protocol: use same wording as smbus-protocol Luca Ceresoli
2020-01-29 15:19 ` [PATCH v3 28/28] docs: i2c: writing-clients: properly name the stop condition Luca Ceresoli
2020-01-29 21:10 ` [PATCH v3 00/28] docs: i2c: rework I2C documentation, part I Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200129151953.31582-22-luca@lucaceresoli.net \
    --to=luca@lucaceresoli.net \
    --cc=jdelvare@suse.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).