18c2ecf20Sopenharmony_ciCommon multiplexer controller bindings 28c2ecf20Sopenharmony_ci====================================== 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciA multiplexer (or mux) controller will have one, or several, consumer devices 58c2ecf20Sopenharmony_cithat uses the mux controller. Thus, a mux controller can possibly control 68c2ecf20Sopenharmony_ciseveral parallel multiplexers. Presumably there will be at least one 78c2ecf20Sopenharmony_cimultiplexer needed by each consumer, but a single mux controller can of course 88c2ecf20Sopenharmony_cicontrol several multiplexers for a single consumer. 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciA mux controller provides a number of states to its consumers, and the state 118c2ecf20Sopenharmony_cispace is a simple zero-based enumeration. I.e. 0-1 for a 2-way multiplexer, 128c2ecf20Sopenharmony_ci0-7 for an 8-way multiplexer, etc. 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciConsumers 168c2ecf20Sopenharmony_ci--------- 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciMux controller consumers should specify a list of mux controllers that they 198c2ecf20Sopenharmony_ciwant to use with a property containing a 'mux-ctrl-list': 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci mux-ctrl-list ::= <single-mux-ctrl> [mux-ctrl-list] 228c2ecf20Sopenharmony_ci single-mux-ctrl ::= <mux-ctrl-phandle> [mux-ctrl-specifier] 238c2ecf20Sopenharmony_ci mux-ctrl-phandle : phandle to mux controller node 248c2ecf20Sopenharmony_ci mux-ctrl-specifier : array of #mux-control-cells specifying the 258c2ecf20Sopenharmony_ci given mux controller (controller specific) 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciMux controller properties should be named "mux-controls". The exact meaning of 288c2ecf20Sopenharmony_cieach mux controller property must be documented in the device tree binding for 298c2ecf20Sopenharmony_cieach consumer. An optional property "mux-control-names" may contain a list of 308c2ecf20Sopenharmony_cistrings to label each of the mux controllers listed in the "mux-controls" 318c2ecf20Sopenharmony_ciproperty. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciDrivers for devices that use more than a single mux controller can use the 348c2ecf20Sopenharmony_ci"mux-control-names" property to map the name of the requested mux controller 358c2ecf20Sopenharmony_cito an index into the list given by the "mux-controls" property. 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cimux-ctrl-specifier typically encodes the chip-relative mux controller number. 388c2ecf20Sopenharmony_ciIf the mux controller chip only provides a single mux controller, the 398c2ecf20Sopenharmony_cimux-ctrl-specifier can typically be left out. 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciExample: 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci /* One consumer of a 2-way mux controller (one GPIO-line) */ 448c2ecf20Sopenharmony_ci mux: mux-controller { 458c2ecf20Sopenharmony_ci compatible = "gpio-mux"; 468c2ecf20Sopenharmony_ci #mux-control-cells = <0>; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>; 498c2ecf20Sopenharmony_ci }; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci adc-mux { 528c2ecf20Sopenharmony_ci compatible = "io-channel-mux"; 538c2ecf20Sopenharmony_ci io-channels = <&adc 0>; 548c2ecf20Sopenharmony_ci io-channel-names = "parent"; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci mux-controls = <&mux>; 578c2ecf20Sopenharmony_ci mux-control-names = "adc"; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci channels = "sync", "in"; 608c2ecf20Sopenharmony_ci }; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciNote that in the example above, specifying the "mux-control-names" is redundant 638c2ecf20Sopenharmony_cibecause there is only one mux controller in the list. However, if the driver 648c2ecf20Sopenharmony_cifor the consumer node in fact asks for a named mux controller, that name is of 658c2ecf20Sopenharmony_cicourse still required. 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci /* 688c2ecf20Sopenharmony_ci * Two consumers (one for an ADC line and one for an i2c bus) of 698c2ecf20Sopenharmony_ci * parallel 4-way multiplexers controlled by the same two GPIO-lines. 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ci mux: mux-controller { 728c2ecf20Sopenharmony_ci compatible = "gpio-mux"; 738c2ecf20Sopenharmony_ci #mux-control-cells = <0>; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>, 768c2ecf20Sopenharmony_ci <&pioA 1 GPIO_ACTIVE_HIGH>; 778c2ecf20Sopenharmony_ci }; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci adc-mux { 808c2ecf20Sopenharmony_ci compatible = "io-channel-mux"; 818c2ecf20Sopenharmony_ci io-channels = <&adc 0>; 828c2ecf20Sopenharmony_ci io-channel-names = "parent"; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci mux-controls = <&mux>; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci channels = "sync-1", "in", "out", "sync-2"; 878c2ecf20Sopenharmony_ci }; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci i2c-mux { 908c2ecf20Sopenharmony_ci compatible = "i2c-mux"; 918c2ecf20Sopenharmony_ci i2c-parent = <&i2c1>; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci mux-controls = <&mux>; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci #address-cells = <1>; 968c2ecf20Sopenharmony_ci #size-cells = <0>; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci i2c@0 { 998c2ecf20Sopenharmony_ci reg = <0>; 1008c2ecf20Sopenharmony_ci #address-cells = <1>; 1018c2ecf20Sopenharmony_ci #size-cells = <0>; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci ssd1307: oled@3c { 1048c2ecf20Sopenharmony_ci /* ... */ 1058c2ecf20Sopenharmony_ci }; 1068c2ecf20Sopenharmony_ci }; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci i2c@3 { 1098c2ecf20Sopenharmony_ci reg = <3>; 1108c2ecf20Sopenharmony_ci #address-cells = <1>; 1118c2ecf20Sopenharmony_ci #size-cells = <0>; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci pca9555: pca9555@20 { 1148c2ecf20Sopenharmony_ci /* ... */ 1158c2ecf20Sopenharmony_ci }; 1168c2ecf20Sopenharmony_ci }; 1178c2ecf20Sopenharmony_ci }; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ciMux controller nodes 1218c2ecf20Sopenharmony_ci-------------------- 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciMux controller nodes must specify the number of cells used for the 1248c2ecf20Sopenharmony_cispecifier using the '#mux-control-cells' property. 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ciOptionally, mux controller nodes can also specify the state the mux should 1278c2ecf20Sopenharmony_cihave when it is idle. The idle-state property is used for this. If the 1288c2ecf20Sopenharmony_ciidle-state is not present, the mux controller is typically left as is when 1298c2ecf20Sopenharmony_ciit is idle. For multiplexer chips that expose several mux controllers, the 1308c2ecf20Sopenharmony_ciidle-state property is an array with one idle state for each mux controller. 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ciThe special value (-1) may be used to indicate that the mux should be left 1338c2ecf20Sopenharmony_cias is when it is idle. This is the default, but can still be useful for 1348c2ecf20Sopenharmony_cimux controller chips with more than one mux controller, particularly when 1358c2ecf20Sopenharmony_cithere is a need to "step past" a mux controller and set some other idle 1368c2ecf20Sopenharmony_cistate for a mux controller with a higher index. 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ciSome mux controllers have the ability to disconnect the input/output of the 1398c2ecf20Sopenharmony_cimultiplexer. Using this disconnected high-impedance state as the idle state 1408c2ecf20Sopenharmony_ciis indicated with idle state (-2). 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ciThese constants are available in 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci #include <dt-bindings/mux/mux.h> 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cias MUX_IDLE_AS_IS (-1) and MUX_IDLE_DISCONNECT (-2). 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ciAn example mux controller node look like this (the adg972a chip is a triple 1498c2ecf20Sopenharmony_ci4-way multiplexer): 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci mux: mux-controller@50 { 1528c2ecf20Sopenharmony_ci compatible = "adi,adg792a"; 1538c2ecf20Sopenharmony_ci reg = <0x50>; 1548c2ecf20Sopenharmony_ci #mux-control-cells = <1>; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci idle-state = <MUX_IDLE_DISCONNECT MUX_IDLE_AS_IS 2>; 1578c2ecf20Sopenharmony_ci }; 158