xref: /freebsd/share/man/man4/iicmux.4 (revision d458747eb2ae0e21ab87278d9c3888336ce83633)
1422d05daSIan Lepore.\"-
2422d05daSIan Lepore.\" SPDX-License-Identifier: BSD-2-Clause
3422d05daSIan Lepore.\"
4422d05daSIan Lepore.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
5422d05daSIan Lepore.\"
6422d05daSIan Lepore.\" Redistribution and use in source and binary forms, with or without
7422d05daSIan Lepore.\" modification, are permitted provided that the following conditions
8422d05daSIan Lepore.\" are met:
9422d05daSIan Lepore.\" 1. Redistributions of source code must retain the above copyright
10422d05daSIan Lepore.\"    notice, this list of conditions and the following disclaimer.
11422d05daSIan Lepore.\" 2. Redistributions in binary form must reproduce the above copyright
12422d05daSIan Lepore.\"    notice, this list of conditions and the following disclaimer in the
13422d05daSIan Lepore.\"    documentation and/or other materials provided with the distribution.
14422d05daSIan Lepore.\"
15422d05daSIan Lepore.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16422d05daSIan Lepore.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17422d05daSIan Lepore.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18422d05daSIan Lepore.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19422d05daSIan Lepore.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20422d05daSIan Lepore.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21422d05daSIan Lepore.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22422d05daSIan Lepore.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23422d05daSIan Lepore.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24422d05daSIan Lepore.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25422d05daSIan Lepore.\" SUCH DAMAGE.
26422d05daSIan Lepore.\"
27422d05daSIan Lepore.\" $FreeBSD$
28422d05daSIan Lepore.\"
29422d05daSIan Lepore.Dd January 1, 2020
30422d05daSIan Lepore.Dt IICMUX 4
31422d05daSIan Lepore.Os
32422d05daSIan Lepore.Sh NAME
33422d05daSIan Lepore.Nm iicmux
34422d05daSIan Lepore.Nd I2C bus mulitiplexer framework
35422d05daSIan Lepore.Sh SYNOPSIS
36422d05daSIan LeporeTo compile this driver into the kernel,
37422d05daSIan Leporeplace the following line in your
38422d05daSIan Leporekernel configuration file:
39422d05daSIan Lepore.Bd -ragged -offset indent
40422d05daSIan Lepore.Cd "device iicmux"
41422d05daSIan Lepore.Ed
42422d05daSIan Lepore.Pp
43422d05daSIan LeporeAlternatively, to load the driver as a
44422d05daSIan Leporemodule at boot time, place the following line in
45422d05daSIan Lepore.Xr loader.conf 5 :
46422d05daSIan Lepore.Bd -literal -offset indent
47422d05daSIan Leporeiicmux_load="YES"
48422d05daSIan Lepore.Ed
49422d05daSIan Lepore.Pp
50422d05daSIan LeporeNote that it is usually not necessary to explicitly load the
51422d05daSIan Leporedriver module, as it will be loaded automatically along with
52422d05daSIan Leporethe driver for the specific mux hardware in use.
53422d05daSIan Lepore.Sh DESCRIPTION
54422d05daSIan LeporeThe
55422d05daSIan Lepore.Nm
56422d05daSIan Leporeframework provides support code to help implement drivers for various
57422d05daSIan LeporeI2C bus multiplexer (mux) hardware.
58422d05daSIan Lepore.Nm
59422d05daSIan Leporeis not a standalone driver,
60422d05daSIan Leporeit is a collection of support functions and driver methods which are
61422d05daSIan Leporeused by individual mux hardware drivers.
62422d05daSIan LeporeIt will be loaded automatically when needed by a mux hardware driver.
63422d05daSIan LeporeThis manual page provides an overview of the I2C mux framework and its
64422d05daSIan Leporebehavior.
65422d05daSIan Lepore.Pp
66422d05daSIan LeporeGenerally speaking, an I2C mux is connected to an upstream I2C bus, and to
67422d05daSIan Leporeone or more downstream I2C buses, and it can be commanded to connect
68422d05daSIan Leporeany one of the downstream buses to the upstream bus.
69422d05daSIan LeporeSome hardware may be able to connect multiple downstream buses at the
70422d05daSIan Leporesame time, but that concept is not supported by
71422d05daSIan Lepore.Nm .
72422d05daSIan Lepore.Pp
73422d05daSIan LeporeThe
74422d05daSIan Lepore.Nm
75422d05daSIan Leporeframework operates automatically when I2C slave devices initiate I/O.
76422d05daSIan LeporeIt does not require (or even allow for) any external control to select
77422d05daSIan Leporethe active downstream bus.
78422d05daSIan Lepore.Pp
79422d05daSIan LeporeWhen there is no I/O in progress, the mux is said to be in the
80422d05daSIan Lepore.Dq idle
81422d05daSIan Leporestate.
82422d05daSIan LeporeSome mux hardware has the ability to disconnect all downstream buses
83422d05daSIan Leporewhen in an idle state.
84422d05daSIan LeporeOther hardware must always have one of the downstream buses connected.
85422d05daSIan LeporeIndividual mux hardware drivers typically provide a way to select which
86422d05daSIan Leporedownstream bus (if any) should be connected while in the idle state.
87422d05daSIan LeporeIn the absence of such configuration, whichever downstream bus was
88422d05daSIan Leporelast used remains connected to the upstream bus.
89422d05daSIan Lepore.Pp
90422d05daSIan LeporeWhen an I2C slave device on a bus downstream of a mux initiates I/O,
91422d05daSIan Leporeit first requests exclusive use of the bus by calling
92422d05daSIan Lepore.Fn iicbus_request_bus .
93422d05daSIan LeporeThis request is communicated to the bus's parent, which is the
94422d05daSIan Lepore.Nm
95422d05daSIan Leporeframework
96422d05daSIan Leporemux driver.
97422d05daSIan LeporeOnce exclusive bus ownership is obtained, the mux driver
98422d05daSIan Leporeconnects the upstream I2C bus to the downstream bus which hosts the
99422d05daSIan Leporeslave device that requested bus ownership.
100422d05daSIan LeporeThe mux hardware maintains that upstream-to-downstream connection until
101422d05daSIan Leporethe slave device calls
102422d05daSIan Lepore.Fn iicbus_release_bus .
103422d05daSIan LeporeBefore releasing ownership, the mux driver returns the mux hardware to
104422d05daSIan Leporethe idle state.
105422d05daSIan Lepore.Sh FDT CONFIGURATION
106422d05daSIan LeporeOn an
107422d05daSIan Lepore.Xr fdt 4
108422d05daSIan Leporebased system, an I2C mux device node is defined as a child node of its
109422d05daSIan Leporeupstream I2C bus when the mux device is an I2C slave itself.
110422d05daSIan LeporeIt may be defined as a child node of any other bus or device in the
111422d05daSIan Leporesystem when it is not an I2C slave, in which case the
112422d05daSIan Lepore.Va i2c-parent
113422d05daSIan Leporeproperty indicates which upstream bus the mux is attached to.
114422d05daSIan LeporeIn either case, the children of the mux node are additional I2C buses, which
115422d05daSIan Leporewill have one or more I2C slave devices described in their child nodes.
116422d05daSIan Lepore.Pp
117422d05daSIan LeporeDrivers using the
118422d05daSIan Lepore.Nm
119422d05daSIan Leporeframework conform to the standard
120422d05daSIan Lepore.Bk -words
121422d05daSIan Lepore.Li i2c/i2c-mux.txt
122422d05daSIan Lepore.Ek
123422d05daSIan Leporebindings document.
124422d05daSIan Lepore.Sh HINTS CONFIGURATION
125422d05daSIan LeporeOn a
126422d05daSIan Lepore.Xr device.hints 5
127422d05daSIan Leporebased system, these values are configurable for
128422d05daSIan Lepore.Nm
129422d05daSIan Leporeframework drivers :
130422d05daSIan Lepore.Bl -tag -width indent
131422d05daSIan Lepore.It Va hint.<driver>.<unit>.at
132422d05daSIan LeporeThe upstream
133422d05daSIan Lepore.Xr iicbus 4
134422d05daSIan Leporethe
135422d05daSIan Lepore.Nm
136422d05daSIan Leporeinstance is attached to.
137422d05daSIan Lepore.El
138422d05daSIan Lepore.Pp
139422d05daSIan LeporeWhen configured via hints, the driver automatically adds an iicbus
140422d05daSIan Leporeinstance for every downstream bus supported by the chip.
141422d05daSIan LeporeThere is currently no way to indicate used versus unused downstream buses.
142422d05daSIan Lepore.Sh SEE ALSO
143*d458747eSChristian Brueffer.Xr iicbus 4
144422d05daSIan Lepore.Sh HISTORY
145422d05daSIan LeporeThe
146422d05daSIan Lepore.Nm
147422d05daSIan Leporeframework first appeared in
148422d05daSIan Lepore.Fx 13.0 .
149