1*422d05daSIan Lepore.\"- 2*422d05daSIan Lepore.\" SPDX-License-Identifier: BSD-2-Clause 3*422d05daSIan Lepore.\" 4*422d05daSIan Lepore.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org> 5*422d05daSIan Lepore.\" 6*422d05daSIan Lepore.\" Redistribution and use in source and binary forms, with or without 7*422d05daSIan Lepore.\" modification, are permitted provided that the following conditions 8*422d05daSIan Lepore.\" are met: 9*422d05daSIan Lepore.\" 1. Redistributions of source code must retain the above copyright 10*422d05daSIan Lepore.\" notice, this list of conditions and the following disclaimer. 11*422d05daSIan Lepore.\" 2. Redistributions in binary form must reproduce the above copyright 12*422d05daSIan Lepore.\" notice, this list of conditions and the following disclaimer in the 13*422d05daSIan Lepore.\" documentation and/or other materials provided with the distribution. 14*422d05daSIan Lepore.\" 15*422d05daSIan Lepore.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*422d05daSIan Lepore.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*422d05daSIan Lepore.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*422d05daSIan Lepore.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*422d05daSIan Lepore.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*422d05daSIan Lepore.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*422d05daSIan Lepore.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*422d05daSIan Lepore.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*422d05daSIan Lepore.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*422d05daSIan Lepore.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*422d05daSIan Lepore.\" SUCH DAMAGE. 26*422d05daSIan Lepore.\" 27*422d05daSIan Lepore.\" $FreeBSD$ 28*422d05daSIan Lepore.\" 29*422d05daSIan Lepore.Dd January 1, 2020 30*422d05daSIan Lepore.Dt IICMUX 4 31*422d05daSIan Lepore.Os 32*422d05daSIan Lepore.Sh NAME 33*422d05daSIan Lepore.Nm iicmux 34*422d05daSIan Lepore.Nd I2C bus mulitiplexer framework 35*422d05daSIan Lepore.Sh SYNOPSIS 36*422d05daSIan LeporeTo compile this driver into the kernel, 37*422d05daSIan Leporeplace the following line in your 38*422d05daSIan Leporekernel configuration file: 39*422d05daSIan Lepore.Bd -ragged -offset indent 40*422d05daSIan Lepore.Cd "device iicmux" 41*422d05daSIan Lepore.Ed 42*422d05daSIan Lepore.Pp 43*422d05daSIan LeporeAlternatively, to load the driver as a 44*422d05daSIan Leporemodule at boot time, place the following line in 45*422d05daSIan Lepore.Xr loader.conf 5 : 46*422d05daSIan Lepore.Bd -literal -offset indent 47*422d05daSIan Leporeiicmux_load="YES" 48*422d05daSIan Lepore.Ed 49*422d05daSIan Lepore.Pp 50*422d05daSIan LeporeNote that it is usually not necessary to explicitly load the 51*422d05daSIan Leporedriver module, as it will be loaded automatically along with 52*422d05daSIan Leporethe driver for the specific mux hardware in use. 53*422d05daSIan Lepore.Sh DESCRIPTION 54*422d05daSIan LeporeThe 55*422d05daSIan Lepore.Nm 56*422d05daSIan Leporeframework provides support code to help implement drivers for various 57*422d05daSIan LeporeI2C bus multiplexer (mux) hardware. 58*422d05daSIan Lepore.Nm 59*422d05daSIan Leporeis not a standalone driver, 60*422d05daSIan Leporeit is a collection of support functions and driver methods which are 61*422d05daSIan Leporeused by individual mux hardware drivers. 62*422d05daSIan LeporeIt will be loaded automatically when needed by a mux hardware driver. 63*422d05daSIan LeporeThis manual page provides an overview of the I2C mux framework and its 64*422d05daSIan Leporebehavior. 65*422d05daSIan Lepore.Pp 66*422d05daSIan LeporeGenerally speaking, an I2C mux is connected to an upstream I2C bus, and to 67*422d05daSIan Leporeone or more downstream I2C buses, and it can be commanded to connect 68*422d05daSIan Leporeany one of the downstream buses to the upstream bus. 69*422d05daSIan LeporeSome hardware may be able to connect multiple downstream buses at the 70*422d05daSIan Leporesame time, but that concept is not supported by 71*422d05daSIan Lepore.Nm . 72*422d05daSIan Lepore.Pp 73*422d05daSIan LeporeThe 74*422d05daSIan Lepore.Nm 75*422d05daSIan Leporeframework operates automatically when I2C slave devices initiate I/O. 76*422d05daSIan LeporeIt does not require (or even allow for) any external control to select 77*422d05daSIan Leporethe active downstream bus. 78*422d05daSIan Lepore.Pp 79*422d05daSIan LeporeWhen there is no I/O in progress, the mux is said to be in the 80*422d05daSIan Lepore.Dq idle 81*422d05daSIan Leporestate. 82*422d05daSIan LeporeSome mux hardware has the ability to disconnect all downstream buses 83*422d05daSIan Leporewhen in an idle state. 84*422d05daSIan LeporeOther hardware must always have one of the downstream buses connected. 85*422d05daSIan LeporeIndividual mux hardware drivers typically provide a way to select which 86*422d05daSIan Leporedownstream bus (if any) should be connected while in the idle state. 87*422d05daSIan LeporeIn the absence of such configuration, whichever downstream bus was 88*422d05daSIan Leporelast used remains connected to the upstream bus. 89*422d05daSIan Lepore.Pp 90*422d05daSIan LeporeWhen an I2C slave device on a bus downstream of a mux initiates I/O, 91*422d05daSIan Leporeit first requests exclusive use of the bus by calling 92*422d05daSIan Lepore.Fn iicbus_request_bus . 93*422d05daSIan LeporeThis request is communicated to the bus's parent, which is the 94*422d05daSIan Lepore.Nm 95*422d05daSIan Leporeframework 96*422d05daSIan Leporemux driver. 97*422d05daSIan LeporeOnce exclusive bus ownership is obtained, the mux driver 98*422d05daSIan Leporeconnects the upstream I2C bus to the downstream bus which hosts the 99*422d05daSIan Leporeslave device that requested bus ownership. 100*422d05daSIan LeporeThe mux hardware maintains that upstream-to-downstream connection until 101*422d05daSIan Leporethe slave device calls 102*422d05daSIan Lepore.Fn iicbus_release_bus . 103*422d05daSIan LeporeBefore releasing ownership, the mux driver returns the mux hardware to 104*422d05daSIan Leporethe idle state. 105*422d05daSIan Lepore.Sh FDT CONFIGURATION 106*422d05daSIan LeporeOn an 107*422d05daSIan Lepore.Xr fdt 4 108*422d05daSIan Leporebased system, an I2C mux device node is defined as a child node of its 109*422d05daSIan Leporeupstream I2C bus when the mux device is an I2C slave itself. 110*422d05daSIan LeporeIt may be defined as a child node of any other bus or device in the 111*422d05daSIan Leporesystem when it is not an I2C slave, in which case the 112*422d05daSIan Lepore.Va i2c-parent 113*422d05daSIan Leporeproperty indicates which upstream bus the mux is attached to. 114*422d05daSIan LeporeIn either case, the children of the mux node are additional I2C buses, which 115*422d05daSIan Leporewill have one or more I2C slave devices described in their child nodes. 116*422d05daSIan Lepore.Pp 117*422d05daSIan LeporeDrivers using the 118*422d05daSIan Lepore.Nm 119*422d05daSIan Leporeframework conform to the standard 120*422d05daSIan Lepore.Bk -words 121*422d05daSIan Lepore.Li i2c/i2c-mux.txt 122*422d05daSIan Lepore.Ek 123*422d05daSIan Leporebindings document. 124*422d05daSIan Lepore.Sh HINTS CONFIGURATION 125*422d05daSIan LeporeOn a 126*422d05daSIan Lepore.Xr device.hints 5 127*422d05daSIan Leporebased system, these values are configurable for 128*422d05daSIan Lepore.Nm 129*422d05daSIan Leporeframework drivers : 130*422d05daSIan Lepore.Bl -tag -width indent 131*422d05daSIan Lepore.It Va hint.<driver>.<unit>.at 132*422d05daSIan LeporeThe upstream 133*422d05daSIan Lepore.Xr iicbus 4 134*422d05daSIan Leporethe 135*422d05daSIan Lepore.Nm 136*422d05daSIan Leporeinstance is attached to. 137*422d05daSIan Lepore.El 138*422d05daSIan Lepore.Pp 139*422d05daSIan LeporeWhen configured via hints, the driver automatically adds an iicbus 140*422d05daSIan Leporeinstance for every downstream bus supported by the chip. 141*422d05daSIan LeporeThere is currently no way to indicate used versus unused downstream buses. 142*422d05daSIan Lepore.Sh SEE ALSO 143*422d05daSIan Lepore.Xr iicbus 4 , 144*422d05daSIan Lepore.Sh HISTORY 145*422d05daSIan LeporeThe 146*422d05daSIan Lepore.Nm 147*422d05daSIan Leporeframework first appeared in 148*422d05daSIan Lepore.Fx 13.0 . 149