> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man4/iicmux.4.md).

# iicmux.4

`iicmux` — I2C 总线多路复用器框架

## 名称

`iicmux`

## 概要

要将此驱动编译进内核，请将以下行放入你的内核配置文件中：

> device iicmux

或者，要在引导时以模块形式加载该驱动，请在 loader.conf(5) 中加入以下行：

```sh
iicmux_load="YES"
```

`注意，通常无需显式加载该驱动模块，因为它会随所使用的特定多路复用器硬件的驱动一起自动加载。`

## 描述

`iicmux` 框架提供支持代码，帮助实现各种 I2C 总线多路复用器（mux）硬件的驱动。`iicmux` 不是独立驱动，它是一组支持函数和驱动方法的集合，由各个多路复用器硬件驱动使用。当被多路复用器硬件驱动需要时会自动加载。本手册页提供 I2C 多路复用器框架及其行为的概述。

通常来说，I2C 多路复用器连接到一个上游 I2C 总线以及一个或多个下游 I2C 总线，并可通过命令将任一下游总线连接到上游总线。某些硬件可能能够同时连接多个下游总线，但 `iicmux` 不支持此概念。

当 I2C 从设备发起 I/O 时，`iicmux` 框架会自动运作。它不需要（甚至不允许）任何外部控制来选择活动的下游总线。

当没有进行中的 I/O 时，称多路复用器处于“idle”状态。某些多路复用器硬件在空闲状态下能够断开所有下游总线。其他硬件则必须始终连接某条下游总线。各个多路复用器硬件驱动通常提供一种方式来选择空闲状态下应连接（如有）哪条下游总线。在缺少此类配置时，最后使用的下游总线保持与上游总线连接。

当多路复用器下游总线上某 I2C 从设备发起 I/O 时，它首先通过调用 Fn iicbus\_request\_bus 请求独占使用总线。此请求传达给总线的父级，即 `iicmux` 框架多路复用器驱动。一旦获得独占总线所有权，多路复用器驱动将上游 I2C 总线连接到托管请求总线所有权的从设备的下游总线。多路复用器硬件会维持该上游至下游的连接，直到从设备调用 Fn iicbus\_release\_bus。在释放所有权之前，多路复用器驱动将多路复用器硬件返回至空闲状态。

## FDT 配置

在基于 [fdt(4)](/man/man4/fdt.4.md) 的系统上，当多路复用器设备本身是 I2C 从设备时，I2C 多路复用器设备节点定义为其上游 I2C 总线的子节点。当它不是 I2C 从设备时，可定义为系统中任何其他总线或设备的子节点，此时 `i2c-parent` 属性指示多路复用器附着到哪条上游总线。无论哪种情况，多路复用器节点的子节点都是额外的 I2C 总线，这些总线将在其子节点中描述一个或多个 I2C 从设备。

使用 `iicmux` 框架的驱动遵循标准的 Bk -words `i2c/i2c-mux.txt` Ek 绑定文档。

## 提示配置

在基于 [device.hints(5)](/man/man5/device.hints.5.md) 的系统上，这些值可用于 `iicmux` 框架驱动：

**`hint.<driver>.<unit>.at`** `iicmux` 实例附着的上游 [iicbus(4)](/man/man4/iicbus.4.md)。

通过提示配置时，驱动会自动为芯片支持的每条下游总线添加一个 iicbus 实例。目前无法指示已使用与未使用的下游总线。

## 参见

[iicbus(4)](/man/man4/iicbus.4.md)

## 历史

`iicmux` 框架最早出现于 FreeBSD 13.0。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man4/iicmux.4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
