1.\" 2.\" This file and its contents are supplied under the terms of the 3.\" Common Development and Distribution License ("CDDL"), version 1.0. 4.\" You may only use this file in accordance with the terms of version 5.\" 1.0 of the CDDL. 6.\" 7.\" A full copy of the text of the CDDL should have accompanied this 8.\" source. A copy of the CDDL is also available via the Internet at 9.\" http://www.illumos.org/license/CDDL. 10.\" 11.\" 12.\" Copyright 2025 Oxide Computer Company 13.\" 14.Dd October 4, 2025 15.Dt I2CADM 8 16.Os 17.Sh NAME 18.Nm i2cadm 19.Nd I2C administration 20.Sh SYNOPSIS 21.Nm 22.Cm controller 23.Cm list 24.Op Fl H 25.Op Fl o Ar field Ns [,...] Op Fl p 26.Op Ar filter Ns ... 27.Nm 28.Cm controller 29.Cm prop 30.Cm get 31.Op Fl H 32.Op Fl o Ar field Ns [,...] Op Fl p 33.Ar controller 34.Op Ar filter Ns ... 35.Nm 36.Cm controller 37.Cm prop 38.Cm set 39.Ar controller 40.Ar property Ns = Ns Ar value 41.Nm 42.Cm device 43.Cm list 44.Op Fl H 45.Op Fl o Ar field Ns [,...] Op Fl p 46.Op Ar filter Ns ... 47.Nm 48.Cm device 49.Cm addrs 50.Op Fl H 51.Op Fl o Ar field Ns [,...] Op Fl p 52.Op Ar filter Ns ... 53.Nm 54.Cm device 55.Cm add 56.Op Fl c Ar compat 57.Ar port 58.Ar name 59.Ar address 60.Nm 61.Cm device 62.Cm remove 63.Ar path 64.Nm 65.Cm mux 66.Cm list 67.Op Fl H 68.Op Fl o Ar field Ns [,...] Op Fl p 69.Op Ar filter Ns ... 70.Nm 71.Cm port 72.Cm list 73.Op Fl H 74.Op Fl o Ar field Ns [,...] Op Fl p 75.Op Ar filter Ns ... 76.Nm 77.Cm port 78.Cm map 79.Op Fl H 80.Op Fl o Ar field Ns [,...] Op Fl p 81.Ar port 82.Nm 83.Cm io 84.Op Fl m Ar mode 85.Fl d Ar destination 86.Op Fl a Ar address 87.Op Fl c Ar command 88.Op Fl w Ar wlen 89.Op Fl r Ar rlen 90.Op Fl o Ar output 91.Ar data 92.Nm 93.Cm scan 94.Op Fl d Ar device 95.Op Fl H 96.Op Fl o Ar field Ns [,...] Op Fl p 97.Ar port 98.Sh DESCRIPTION 99The 100.Nm 101utility is used to enumerate and manipulate I2C and SMBus controllers, 102devices, ports, and multiplexors. 103.Pp 104There are four top-level objects in 105.Nm ; 106.Bl -tag -width Ds 107.It Controllers 108These are hardware device that can perform I2C or SMBus operations that 109target devices on the bus. 110.Nm 111provides the ability to list them as well as get and set properties on 112specific controllers. 113.It Devices 114Device represent targets on the I2C bus which provide some functionality 115at a given address. 116Devices run the gamut including functions like EEPROMs, sensors, GPIO 117controllers, voltage regulators, and more. 118Many devices will have a corresponding device driver that provides 119functionality through a standard system mechanism, but there is no 120requirement for a driver. 121.It Ports 122A port is a logical point on an I2C bus under which one or more devices 123can be found. 124I2C ports are found directly under controllers and multiplexors. 125I2C ports under a controller represent the start of a unique I2C bus and 126addresses that are used are specific to that bus. 127.Nm 128provides the ability to list ports and print information about the 129addresses that are in use on the port directly or downstream of it. 130.It Multiplexors 131Multiplexors provide a means of isolating segments of an I2C bus from 132one another, which is generally used to avoid overlapping I2C addresses. 133A multiplexor provides a fixed number of ports and the system will 134transparently activate and deactivate ports based on I/O requests and 135their targets. 136At most one port will ever be active on a multiplexor at any given time. 137.Nm 138provides the ability to discover and list multiplexors. 139.El 140.Pp 141All listing operations leverage the standard illumos output format 142library 143.Po 144.Xr ofmt 3OFMT 145.Pc 146allowing the selection of specific output fields, the omission of the 147header 148.Pq Fl H , 149and a parsable mode intended for programmatic consumption 150.Pq Fl p . 151When requesting parsable output, the colon 152.Po 153.Do 154: 155.Dc 156.Pc 157character is used as a delimiter between fields and any delimiters that 158would appear in an output field will be escaped with a backslash 159character 160.Po 161.Do 162\e 163.Dc 164.Pc . 165.Pp 166Getting information about I2C devices, controllers, ports, and muxes 167requires that a process have the 168.Brq Dv PRIV_SYS_DEVICES 169privilege. 170.Ss I2C Paths 171All of the different entities that can be found on an I2C bus are 172described through a path that indicates the route through the bus to get 173to an entity. 174Consider the following I2C devices: 175.Bd -literal 176 177 178 +------------+ 179 | dwi2c4 | 180 | 1 port | 181 | controller | 182 +------------+ +------+ 183 | | lm75 | 184 +---------->| 0x48 | 185 | +------+ 186 v 187 +------------+ 188 | pca9548 | 189 | 0x72 | 190 | 8 port mux | 191 +------------+ 192 | 193 * ... port 0, 1-7 not pictured 194 | 195 v 196 +------------+ 197 | pca9545 | 198 | 0x72 | 199 | 4 port mux | 200 +------------+ 201 | 202 * ... port 2, 0-1,3 not pictured 203 | 204 v 205 +---------+ 206 | at24c02 | 207 | 0x57 | 208 | EEPROM | 209 +---------+ 210.Ed 211.Pp 212The following are what different paths refer to for this: 213.Bl -tag -width Pa 214.It Pa dwi2c4 215This refers to the controller itself. 216.It Pa dwi2c4/0 217This refers to the primary port under a controller. 218This could be used for performing device scans, I/O, or manually adding 219or removing devices. 220.It Pa dwi2c4/0/0x48 221This refers to the LM75 temperature sensor that is directly attached to 222the controller's port. 223.It Pa dwi2c4/0/0x72 224This string refers to the 8-port mux directly under the controller's 225port. 226.It Pa dwi2c4/0/0x72/0/0x70/2/0x57 227This is a complex string that refers to the AT24C02 EEPROM. 228Along the way are all of the devices and ports that are used to get to 229it. 230A more verbose form of this path would be 231.Pa dwi2c4/0/pca9548@0x72/0/pca9545@0x70/2/at24c02@0x57 . 232.El 233.Pp 234When constructing paths, controllers are always referred to by their 235name and instance. 236Ports are always referred to by their name, which is usually a number 237based upon the datasheet. 238Devices can be referred to in three ways at their point in the tree. 239Using the first mux as an example: 240.Bl -enum 241.It 242Using the device's primary I2C address: 243.Ql 0x72 . 244.It 245Using the device's name and primary address: 246.Ql pca9548@0x72 . 247.It 248Using the device's driver name and instance: 249.Ql pca9454x0 . 250.El 251.Sh SUBCOMMANDS 252The following commands are supported by 253.Nm : 254.Bl -tag -width "" 255.It Xo 256.Nm 257.Cm controller 258.Cm list 259.Op Fl H 260.Op Fl o Ar field Ns [,...] Op Fl p 261.Op Ar filter Ns ... 262.Xc 263List all of the I2C controllers in the system and provide basic 264information about them. 265.Pp 266The following fields are supported: 267.Bl -tag -width PROVIDER 268.It Sy NAME 269This is the name of the I2C controller in the system. 270All I2C paths will start with a controller name. 271.It Sy TYPE 272This is the primary type of the controller, but is not indicative of all 273I/O that they can perform. 274An SMBus controller may support directly performing I2C. 275The valid controller types are: 276.Bl -tag -width smbus 277.It i2c 278An I2C controller. 279.It i3c 280An I3C controller. 281.It smbus 282An SMBus controller. 283.El 284.It Sy SPEED 285A string that describe the speed that the bus is operating at, along 286with some of the physical capabilities. 287The valid speed values are: 288.Bl -tag -width fast-plus 289.It standard 290Standard speed operates the bus at 100 kHz. 291.It fast 292Fast speed operates the bus at 400 kHz. 293.It fast-plus 294Fast-plus speed operates the bus at 1 MHz. 295.It high 296High-speed operate the bus at 3.4 MHz. 297.It ultra 298Ultra-fast speed operate the bus at 5 MHz. 299.El 300.It Sy NPORTS 301The number of ports that are under the controller. 302.It Sy DRIVER 303The name of the driver for the controller. 304.It Sy INSTANCE 305The name of the device driver instance for the controller. 306.It Sy PROVIDER 307The 308.Pa /devices 309path to the kernel provider for this controller. 310.El 311.Pp 312The following options are supported: 313.Bl -tag -width Fl 314.It Fl H 315Omit the column header when printing output. 316.It Fl o Ar field Ns [,...] 317A comma-delineated list of fields to output, selected from the ones 318above. 319.It Fl p 320Displays the output in a machine-parsable format. 321When requesting parsable output, the 322.Fl o 323option is required to specifically control which fields are included. 324.El 325.Pp 326The following operands are supported: 327.Bl -tag -width Ar 328.It Ar filter 329One or more filters may be specified which are used to constrain the 330list of controllers that are printed. 331Each 332.Ar filter 333may either match the name of a controller or driver. 334.Pp 335If any filter is specified and does not match, then that is treated as 336an error. 337.Pp 338Because these are filters, they do not control the order that items are 339printed out, only what is printed out. 340.El 341.It Xo 342.Nm 343.Cm controller 344.Cm prop 345.Cm get 346.Op Fl H 347.Op Fl o Ar field Ns [,...] Op Fl p 348.Ar controller 349.Op Ar filter Ns ... 350.Xc 351List all properties, their values, and corresponding metadata on the 352specific controller 353.Ar controller . 354.Pp 355The following fields are supported: 356.Bl -tag -width PROPERTY 357.It Sy PROPERTY 358The name of the property. 359.It Sy PERM 360Indicates whether the property is readable or both readable and 361writable. 362.It Sy VALUE 363The current value of the property. 364.It Sy DEFAULT 365The default value for the property on the specific instance of the 366controller. 367This is the value the system will start with assuming no tuning has been 368performed. 369Some properties may not have a default value. 370.It Sy POSSIBLE 371A list of possible values that the property might take. 372This may be a series of numeric ranges or a list of specific values. 373Some properties may not have a set of possible values. 374.It Sy TYPE 375Indicates the type of the property. 376The system has the following I2C property types: 377.Bl -tag -width bit32 378.It Sy u32 379Indicates that the property is a 32-bit unsigned value. 380.It Sy bit32 381Indicates that the property is a 32-bit unsigned bitfield. 382The presence or absence of each bit indicates a specific feature or 383property. 384.El 385.It Sy CONTROLLER 386The name of the controller the property is being retrieved from. 387.It Sy ID 388The system's numeric identifier for the property. 389.El 390.Pp 391The following options are supported: 392.Bl -tag -width Fl 393.It Fl H 394Omit the column header when printing output. 395.It Fl o Ar field Ns [,...] 396A comma-delineated list of fields to output, selected from the ones 397above. 398.It Fl p 399Displays the output in a machine-parsable format. 400When requesting parsable output, the 401.Fl o 402option is required to specifically control which fields are included. 403.El 404The following operands are supported: 405.Bl -tag -width Ar 406.It Ar filter 407One or more filters may be specified which are used to constrain the 408list of properties that are printed. 409Each 410.Ar filter 411must match the name of a property. 412For a list of properties, see the 413.Sx PROPERTIES 414section. 415.Pp 416If any filter is specified and does not match, then that is treated as 417an error. 418.Pp 419Because these are filters, they do not control the order that items are 420printed out, only what is printed out. 421.El 422.It Xo 423.Nm 424.Cm controller 425.Cm prop 426.Cm set 427.Ar controller 428.Ar property Ns = Ns Ar value 429.Xc 430Set the value of a single named 431.Ar property 432on the controller, 433.Ar controller , 434to the indicated 435.Ar value. 436.Ar value 437will be parsed based upon the specific property and its type. 438Properties which are translated into strings, can be specified as either 439an integer value or the corresponding string. 440.Pp 441To see the list of properties on a controller use 442.Nm 443.Cm controller 444.Cm prop 445.Cm get . 446For a list of all properties, see the 447.Sx PROPERTIES 448section. 449.It Xo 450.Nm 451.Cm device 452.Cm list 453.Op Fl H 454.Op Fl o Ar field Ns [,...] Op Fl p 455.Op Ar filter Ns ... 456.Xc 457Lists basic information about all devices known to the system across all 458controllers. 459These are devices that have been discovered through a platform-specific 460means or explicitly added by an administrator through the 461.Nm 462.Cm device 463.Cm add 464command. 465.Pp 466The following fields are supported: 467.Bl -tag -width INSTANCE 468.It Sy NAME 469The name of the device. 470This corresponds to the device tree's node name. 471.It Sy ADDR 472The primary I2C address that this device has. 473This corresponds to the device tree's reg[0] entry. 474.It Sy INSTANCE 475The driver instance of the device, if any. 476.It Sy PATH 477The I2C path of the device. 478.El 479.Pp 480The following options are supported: 481.Bl -tag -width Fl 482.It Fl H 483Omit the column header when printing output. 484.It Fl o Ar field Ns [,...] 485A comma-delineated list of fields to output, selected from the ones 486above. 487.It Fl p 488Displays the output in a machine-parsable format. 489When requesting parsable output, the 490.Fl o 491option is required to specifically control which fields are included. 492.El 493.Pp 494The following operands are supported: 495.Bl -tag -width Ar 496.It Ar filter 497One or more filters may be specified which are used to constrain the 498list of properties that are printed. 499Each 500.Ar filter 501may match a device's primary address, a device name, a driver name, a 502driver instance, or a portion of the device's I2C path. 503.Pp 504If any filter is specified and does not match, then that is treated as 505an error. 506.Pp 507Because these are filters, they do not control the order that items are 508printed out, only what is printed out. 509.El 510.It Xo 511.Nm 512.Cm device 513.Cm addrs 514.Op Fl H 515.Op Fl o Ar field Ns [,...] Op Fl p 516.Op Ar filter Ns ... 517.Xc 518Print the I2C addresses and their sources for device's in the system. 519A device's address may come from the platform or it may be an additional 520address that the driver itself claims and is either unique to that 521device or shared amongst all instance of a particular driver. 522.Pp 523The following fields are supported: 524.Bl -tag -width SOURCE 525.It Sy PATH 526The I2C path of the device. 527.It Sy TYPE 528The type of the address. 529This is either 530.Sy 7-bit 531or 532.Sy 10-bit . 533.It Sy ADDR 534The address in question on the device. 535.It Sy SOURCE 536Indicates how the device was assigned the address. 537One of the following values: 538.Bl -tag -width platform 539.It Sy platform 540This address came from information provided by the platform. 541This includes firmware sources or addresses assigned as part of an 542operator calling 543.Nm 544.Cm device 545.Cm add . 546.It Sy claimed 547This addresses was claimed exclusively by the device driver. 548For example, several EEPROMs require multiple I2C addresses to cover 549their entire memory map, but only the base address is often provided by 550the platform. 551.It Sy shared 552This address was claimed by a device driver and is permitted to be used 553across all instances of the device driver. 554.El 555.El 556.Pp 557The following options are supported: 558.Bl -tag -width Fl 559.It Fl H 560Omit the column header when printing output. 561.It Fl o Ar field Ns [,...] 562A comma-delineated list of fields to output, selected from the ones 563above. 564.It Fl p 565Displays the output in a machine-parsable format. 566When requesting parsable output, the 567.Fl o 568option is required to specifically control which fields are included. 569.El 570The following operands are supported: 571.Bl -tag -width Ar 572.It Ar filter 573One or more filters may be specified which are used to constrain the 574list of properties that are printed. 575Each 576.Ar filter 577may match a device's particular address, a device name, a driver name, a 578driver instance, or a portion of the device's I2C path. 579.Pp 580If any filter is specified and does not match, then that is treated as 581an error. 582.Pp 583Because these are filters, they do not control the order that items are 584printed out, only what is printed out. 585.El 586.It Xo 587.Nm 588.Cm device 589.Cm add 590.Op Fl c Ar compat 591.Ar port 592.Ar name 593.Ar address 594.Xc 595Add a new device to the system. 596The system will attempt to attach a driver to this device; however, even 597if there is no driver for the device, it can be created regardless. 598.Pp 599The following options are supported: 600.Bl -tag -width Fl 601.It Fl c Ar compat 602Add the specified compatibility entry 603.Ar compat 604to the newly created device node's 605.Ql compatible 606property. 607When the system considers device drivers to attach to an I2C device it 608will search for matches against the device's 609.Ql compatible 610property and then attempt to match the device's name. 611.Pp 612This property may be specified multiple times in order to add multiple 613entries. 614The order is meaningful and will reflect the order specified on the 615command line. 616The matching algorithm walks the list in order and terminates on the 617first found match. 618More specific entries should be specified first. 619.El 620.Pp 621The following operands are supported: 622.Bl -tag -width Ar 623.It Ar port 624Specifies the I2C path to the port that the device will be created 625under. 626This may be either a port on a controller or a port under a multiplexor. 627Device's under a mux are allowed to have conflicting addresses with 628devices on other ports of a given mux. 629The mux will be implicitly activated when performing I/O to the device. 630.It Ar name 631The name of the new device. 632This generally should match something about the device itself such as 633the part number. 634.Pp 635Device name's may be at most 31 characters. 636The first character must be an upper or lower case letter. 637The remaining characters may be upper or lower case letters, numbers, or 638one of the following punctuation characters: the comma 639.Pq Sq \&, , 640the period 641.Pq Sq \&. , 642the hyphen 643.Pq Sq - , 644the plus sign 645.Pq Sq + , 646and the underscore 647.Pq Sq _ . 648.It Ar address 649The address to assign to the device. 650Only 7-bit addresses are permitted. 651The string will be parsed according to the specified base. 652It is recommended to specify addresses in hexadecimal with the leading 653.Dq 0x . 654.El 655.It Xo 656.Nm 657.Cm device 658.Cm remove 659.Ar path 660.Xc 661Attempts to remove the specified device indicated by the I2C path 662.Ar path . 663This may fail if the device is actively being used. 664.It Xo 665.Nm 666.Cm mux 667.Cm list 668.Op Fl H 669.Op Fl o Ar field Ns [,...] Op Fl p 670.Op Ar filter Ns ... 671.Xc 672List all multiplexors known to the system. 673.Pp 674The following fields are supported: 675.Bl -tag -width INSTANCE 676.It Sy DEVICE 677The name of the I2C device that implements the multiplexor. 678.It Sy NPORTS 679The number of ports on the multiplexor. 680.It Sy NAME 681The name of the multiplexor itself. 682.It Sy INSTANCE 683The device driver instance that powers the multiplexor. 684.It Sy PATH 685The I2C path of the multiplexor. 686.El 687.Pp 688The following options are supported: 689.Bl -tag -width Fl 690.It Fl H 691Omit the column header when printing output. 692.It Fl o Ar field Ns [,...] 693A comma-delineated list of fields to output, selected from the ones 694above. 695.It Fl p 696Displays the output in a machine-parsable format. 697When requesting parsable output, the 698.Fl o 699option is required to specifically control which fields are included. 700.El 701.Pp 702The following operands are supported: 703.Bl -tag -width Ar 704.It Ar filter 705One or more filters may be specified which are used to constrain the 706list of multiplexors that are printed. 707Each 708.Ar filter 709may either match the multiplexor name, its device's name, or its 710device's driver. 711.Pp 712If any filter is specified and does not match, then that is treated as 713an error. 714.Pp 715Because these are filters, they do not control the order that items are 716printed out, only what is printed out. 717.El 718.It Xo 719.Nm 720.Cm port 721.Cm list 722.Op Fl H 723.Op Fl o Ar field Ns [,...] Op Fl p 724.Op Ar filter Ns ... 725.Xc 726List all ports known to the system. 727.Pp 728The following fields are supported: 729.Bl -tag -width PORTNO 730.It Sy PATH 731The I2C path of the port. 732.It Sy TYPE 733Indicates the type of port. 734One of the following values: 735.Bl -tag -width multiplexor 736.It Sy controller 737The port belongs to a controller. 738.It Sy multiplexor 739The port belongs to a mux. 740.El 741.It Sy NAME 742The name of the port. 743Port names generally follow the datasheet and are either 0-based or 7441-based. 745.It Sy PORTNO 746The 0-based system assigned ID for this port. 747.It Sy NDEVS 748The number of devices that are directly under this port. 749This does not include devices that are under subsequent ports like a 750multiplexor. 751.It Sy TDEVS 752The total number of devices that are under this port, including all 753multiplexors. 754.El 755.Pp 756The following options are supported: 757.Bl -tag -width Fl 758.It Fl H 759Omit the column header when printing output. 760.It Fl o Ar field Ns [,...] 761A comma-delineated list of fields to output, selected from the ones 762above. 763.It Fl p 764Displays the output in a machine-parsable format. 765When requesting parsable output, the 766.Fl o 767option is required to specifically control which fields are included. 768.El 769.Pp 770The following operands are supported: 771.Bl -tag -width Ar 772.It Ar filter 773One or more filters may be specified which are used to constrain the 774list of ports that are printed. 775Each 776.Ar filter 777may either match the port's name, its type, or its I2C path. 778.Pp 779If any filter is specified and does not match, then that is treated as 780an error. 781.Pp 782Because these are filters, they do not control the order that items are 783printed out, only what is printed out. 784.El 785.It Xo 786.Nm 787.Cm port 788.Cm map 789.Op Fl H 790.Op Fl o Ar field Ns [,...] Op Fl p 791.Ar port 792.Xc 793Prints a map of how addresses are used directly under the specified port 794.Ar port 795by devices known to the system. 796This does not perform I/O to scan for addresses that could be used but 797are unknown to the system, instead use 798.Nm 799.Cm scan 800for that. 801By default, the command will output a human-oriented table organized 802into rows with 16 columns each. 803For machine parsable stable, output use the 804.Fl p 805and 806.Fl o 807options. 808.Pp 809The table will use the following characters to indicate specific cases: 810.Bl -tag -width Ds 811.It L 812Indicates that the address corresponds to a device 813this port. 814.It v 815Indicates that the address is used downstream of this port by a device 816under a mux port. 817The address in question could not be assigned to another device because 818of this. 819.It S 820Indicates that this address is being treated as a shared address across 821multiple instances of a device driver. 822A list of shared addresses and the corresponding major numbers and 823drivers will be printed following the table. 824.It - 825Indicates that this address is not in use. 826.It E 827An unexpected error occurred. 828.El 829.Pp 830The following fields are supported: 831.Bl -tag -width DRIVER 832.It Sy ADDR 833The I2C address in question. 834The address is printed in decimal. 835.It Sy COUNT 836The number of devices that are using this address in the port. 837.It Sy TYPE 838The type of address. 839One of the following values: 840.Bl -tag -width downstream 841.It Sy local 842Indicates that this address is in use by a device directly on the port. 843.It Sy downstream 844Indicates that this address is in use by a device downstream of the 845port. 846.It Sy shared 847Indicates that the address is being actively shared by one or more 848instances of a given device driver. 849.It Sy none 850Indicates that this address is not in use. 851.It Sy error 852Indicates that information about this addrses is not available because 853an error occurred. 854.El 855.It Sy MAJOR 856For shared addresses, indicates the major number of the driver that is 857sharing the address. 858.It Sy DRIVER 859For shared addresses, indicates the name of the device driver that is 860sharing the address. 861.El 862.Pp 863The following options are supported: 864.Bl -tag -width Fl 865.It Fl H 866Omit the column header when printing output. 867.It Fl o Ar field Ns [,...] 868A comma-delineated list of fields to output, selected from the ones 869above. 870.It Fl p 871Displays the output in a machine-parsable format. 872When requesting parsable output, the 873.Fl o 874option is required to specifically control which fields are included. 875.El 876.Pp 877The following operands are required: 878.Bl -tag -width Ar 879.It Ar port 880The I2C path of the port to print information about. 881.El 882.It Xo 883.Nm 884.Cm io 885.Op Fl m Ar mode 886.Fl d Ar destination 887.Op Fl a Ar address 888.Op Fl c Ar command 889.Op Fl w Ar wlen 890.Op Fl r Ar rlen 891.Op Fl o Ar output 892.Ar data 893.Xc 894Perform arbitrary I/O to a specific device or address on the I2C bus. 895This will perform a single transaction based on the type specified by 896the 897.Ar mode 898argument, which defaults to I2C. 899Transmitted data will be taken from the positional arguments and 900received data will be output in a hexdump if 901.Fl o 902is not specified. 903.Pp 904Care should be taken when performing I/O to arbitrary devices. 905If a kernel device driver is attached this can potentially confuse the 906driver. 907If the device is modified, this can potentially lead to an unbootable or 908unsable system. 909For example, modifying the EERPOM on a DRAM device could lead to DRAM 910training failures. 911The following options are supported: 912.Bl -tag -width Fl 913.It Fl a Ar address 914A string that indicates the numeric 7-bit address to send the I/O to. 915.It Fl c Ar command 916An SMBus command to send. 917This option is only valid when using an SMBus mode with 918.Fl m 919that requires a command to be specified. 920.It Fl d Ar destination 921An I2C path that indicates where the I/O should target. 922If this is a port, then an address must be specified with the 923.Fl a 924option. 925If the path includes mux ports, they will be implicitly activated as 926part of performing this operation. 927If the path ends at a device, the device's primary address 928.Pq reg[0] 929will be used. 930.It Fl m Ar mode 931Specifies the type of I/O request that should be sent. 932The following types are supported: 933.Bl -tag -width write-block-i2c 934.It i2c 935Perform a general I2C transaction. 936One or both of 937.Fl r 938and 939.Fl w 940must be used and non-zero. 941.It quick-read 942Perform an SMBus quick read. 943No data arguments may be specified or are required. 944.It quick-write 945Perform an SMBus quick write. 946No data arguments may be specified or are required. 947.It recv-u8 948Receive a single byte. 949No data arguments may be specified or are required. 950.It read-u8 951Perform the SMBus read byte operation. 952An SMBus command must be specified with 953.Fl c . 954.It read-u16 955Perform the SMBus read word operation. 956An SMBus command must be specified with 957.Fl c . 958.It read-u32 959Perform the SMBus read u32 operation. 960An SMBus command must be specified with 961.Fl c . 962.It read-u64 963Perform the SMBus read u64 operation. 964An SMBus command must be specified with 965.Fl c . 966.It read-block-i2c 967Perform an SMBus I2C block read operation. 968An SMBus command must be specified with 969.Fl c . 970A read length must be specified with 971.Fl r . 972It will not be sent on the wire, unlike a traditional SMBus block read. 973.It send-u8 974Transmit a single byte. 975.It write-u8 976Perform the SMBus write byte operation. 977An SMBus command must be specified with 978.Fl c 979and a single data operand must be specified. 980.It write-u16 981Perform the SMBus write word operation. 982An SMBus command must be specified with 983.Fl c 984and a single data operand must be specified. 985.It write-u32 986Perform the SMBus write u32 operation. 987An SMBus command must be specified with 988.Fl c 989and a single data operand must be specified. 990.It write-u64 991Perform the SMBus write u64 operation. 992An SMBus command must be specified with 993.Fl c 994and a single data operand must be specified. 995.It write-block 996Perform an SMBus write block operation. 997SMBus block write with command and length 998An SMBus command must be specified with 999.Fl c 1000and the number of byte to write must be specified with 1001.Fl w . 1002Both the command and the write length will be sent on the wire. 1003There must be a single-byte positional argument for each byte indicated 1004with 1005.Fl w . 1006.It write-block-i2c 1007Operates as per write-block above, but the byte length is not sent on 1008the wire. 1009.It call 1010Performs the SMBus process call operation. 1011An SMBus command must be specified with 1012.Fl c 1013and a single positional data argument must be specified. 1014Process call transmits and then reads a u16. 1015.El 1016.It Fl o Ar output 1017Send received binary data to the file 1018.Ar output 1019rather than performing a hexadecimal dump to standard out. 1020.It Fl r Ar rlen 1021Specifies the number of bytes that should be read from the device. 1022.It Fl w Ar wlen 1023Specifies the number of bytes that should be transmitted to the device. 1024There must be one positional argument for each byte that should be 1025transmitted. 1026.El 1027.It Xo 1028.Nm 1029.Cm scan 1030.Op Fl d Ar device 1031.Op Fl H 1032.Op Fl o Ar field Ns [,...] Op Fl p 1033.Ar port 1034.Xc 1035Scan the specified I2C 1036.Ar port 1037for devices. 1038This works by attempting to perform I/O to every non-reserved address on 1039the bus. 1040If the port belongs to a mux, then all of the appropriate mux segments 1041will be enabled prior to performing the scan. 1042The command will output a human-oriented table by default organized into 1043rows with 16 columns each. 1044For machine parsable, stable output use the 1045.Fl p 1046and 1047.Fl o 1048options. 1049.Pp 1050The table will use the following characters to indicate specific cases: 1051.Bl -tag -width Ds 1052.It @ 1053Indicates that a device was found at the address. 1054.It - 1055Indicates that no device was found at the address. 1056.It S 1057Indicates that the address was skipped as the 1058.Fl d 1059option was used and the address in question wasn't listed. 1060.It R 1061Indicates that the address is considered reserved and therefore was not 1062scanned. 1063.It X 1064Indicates that a time out occurred. 1065.It Err 1066Indicates that an error occurred. 1067Following the table, a list of address-specific errors will be printed. 1068.El 1069.Pp 1070Unfortunately, the only way to determine if a device is there is by 1071attempting to do I/O to it. 1072The scan defaults to performing a single byte read. 1073Note, there is no safe way to scan for devices and it is quite possible 1074for system damage to occur from scanning! 1075.Pp 1076The following fields are supported when using machine parsable output: 1077.Bl -tag -width RESULT 1078.It Sy ADDR 1079The I2C address that was scanned, printed in hexadecimal. 1080.It Sy RESULT 1081A string that describes the result. 1082Valid strings include: 1083.Dq found , 1084.Dq missing , 1085.Dq reserved , 1086.Dq timeout , 1087.Dq error , 1088and 1089.Dq skipped . 1090.It Sy ERROR 1091A string that includes information about the error that occurred. 1092This is only valid if the 1093.Sy RESULT 1094field is error. 1095.El 1096The following options are supported: 1097.Bl -tag -width Fl 1098.It Fl d Ar device 1099Restrict the scan to the specified I2C address. 1100This may be specified multiple times to only scan a subset of devices. 1101.It Fl H 1102Omit the column header when printing output. 1103.It Fl o Ar field Ns [,...] 1104A comma-delineated list of fields to output, selected from the ones 1105above. 1106.It Fl p 1107Displays the output in a machine-parsable format. 1108When requesting parsable output, the 1109.Fl o 1110option is required to specifically control which fields are included. 1111.El 1112.Pp 1113The following operands are required: 1114.Bl -tag -width Ar 1115.It Ar port 1116An I2C path that terminates at a port. 1117If the port is downstream of a multiplexor, all of the segments required 1118to send to that port will be enabled, allowing the results to be 1119included in the scan. 1120Otherwise, multiplexors will be disabled during the scan. 1121.El 1122.El 1123.Sh PROPERTIES 1124The system supports a number of named I2C properties. 1125Properties are consider either read-only or read-write. 1126Some properties may be read-write on one controller and then read-only 1127or possibly even unsupported on another controller. 1128Whether a property is supported, is writable, and the valid values a 1129property can take will vary from one controller to another. 1130.Pp 1131There are some properties which control timing parameters on the I2C 1132bus. 1133These properties often have a single instance for each speed that the 1134I2C bus can operate at. 1135This allows for one to set the tuning properties to the correct value 1136before changing the speed without impacting the current operation. 1137.Pp 1138Properties have a specific type which is either the 1139.Sy u32 1140or 1141.Sy bit32 1142which are 32-bit integers that represent a single value or a bitfield 1143where each bit conveys its own meaning respectively. 1144A few properties such as 1145.Em speed , 1146.Em type , 1147and 1148.Em smbus-ops 1149have well known string values that correspond to fields. 1150By default the tools print the stable human-readable strings for these. 1151Properties with these are called out in the property table. 1152.Pp 1153The following properties are supported: 1154.Bl -tag -width clock-Thigh-high 1155.It speed 1156Describes the frequency of the bus. 1157This is a 1158.Sy u32 1159that is translated to the following string values: 1160.Bl -tag -width fast-plus 1161.It Sy standard 1162100 kHz standard operation. 1163.It Sy fast 1164400 kHz fast-mode operation. 1165.It Sy fast-plus 11661 MHz fast-mode plus operation. 1167.It Sy high 11683.4 MHz high-speed operation. 1169.It Sy ultra 11705 MHz ultra-fast operation. 1171.El 1172.It ports 1173A 1174.Sy u32 1175property that indicates the number of ports under the controller. 1176This property is always read-only and generally will be 1. 1177.It type 1178Describes the type of controller. 1179This is always read-only 1180.Sy u32 1181property that is translated to the following string values: 1182.Bl -tag -width smbus 1183.It i2c 1184Indicates that this is an I2C controller. 1185.It i3c 1186Indicates that this is an I3C controller. 1187.It smbus 1188Indicates that this is an SMBus controller. 1189.El 1190.Pp 1191Some controllers can support more than one I/O command request. 1192For example, all I3C controllers support operating as an I2C controller. 1193Similarly some SMBus controllers support first-class I2C operation. 1194This property only indicates the primary mode of the controller. 1195.It smbus-ops 1196Describes the set of SMBus operations that the controller supports. 1197This is a read-only 1198.Sy bit32 1199property that is translated to the following string values: 1200.Bl -tag -width write-i2c-block 1201.It Sy quick 1202The controller supports the SMBus quick read and write operation. 1203.It Sy send-byte 1204The controller supports the SMBus send byte operation. 1205.It Sy recv-byte 1206The controller supports the SMBus receive byte operation. 1207.It Sy write-byte 1208The controller supports the SMBus write byte operation. 1209.It Sy read-byte 1210The controller supports the SMBus read byte operation. 1211.It Sy write-word 1212The controller supports the SMBus write word 1213.Pq 16-bit 1214operation. 1215.It Sy read-word 1216The controller supports the SMBus read word 1217.Pq 16-bit 1218operation. 1219.It Sy process-call 1220The controller supports the SMBus process call operation which transmits 1221a 16-bit value and then reads back a 16-bit value. 1222.It Sy write-block 1223The controller supports the SMBus write block operation which transmits 1224the SMBus command, the byte length, and all the bytes. 1225.It Sy read-block 1226The controller supports the SMBus read block operation which reads a 1227variable number of bytes that are indicated by the target. 1228.It Sy host-notify 1229The controller supports sending out the host notification command. 1230This is generally only used for SMBus targets and not controllers. 1231.It Sy block-call 1232The controller supports the SMBus block call operation which transmits 1233and then receives a variable number of bytes. 1234.It Sy write-u32 1235The controller supports the SMBus write 32-bit operation. 1236.It Sy read-u32 1237The controller supports the SMBus read 32-bit operation. 1238.It Sy write-u64 1239The controller supports the SMBus write 64-bit operation. 1240.It Sy read-u64 1241The controller supports the SMBus read 64-bit operation. 1242.It Sy write-i2c-block 1243The controller supports a variant of the write block operation that is 1244compatible with I2C by not transmitting the number of bytes that the 1245controller will send. 1246.It Sy read-i2c-block 1247The controller supports a variant of the read block operation that is 1248compatible with I2C by explicitly reading a fixed number of bytes. 1249The number of bytes is not transmitted on the wire. 1250.El 1251.It i2c-max-read 1252This is a read-only 1253.Sy u32 1254property that indicates the largest I2C read the controller can 1255receive in one operation. 1256.It i2c-max-write 1257This is a read-only 1258.Sy u32 1259property that indicates the largest I2C write the controller can 1260transmit in one operation. 1261.It smbus-max-block 1262This is a read-only 1263.Sy u32 1264property that indicates the largest SMBus block operation the controller 1265can perform. 1266.It clock-Thigh-std 1267This property indicates the high period of the I2C clock. 1268It is a 1269.Sy u32 1270property that is counted in terms of clock cycles. 1271This property only applies when the bus is operating at standard speed. 1272.It clock-Tlow-std 1273This property indicates the low period of the I2C clock. 1274It is a 1275.Sy u32 1276property that is counted in terms of clock cycles. 1277This property only applies when the bus is operating at standard speed. 1278.It clock-Thigh-fast 1279This property indicates the high period of the I2C clock. 1280It is a 1281.Sy u32 1282property that is counted in terms of clock cycles. 1283This property only applies when the bus is operating at fast-mode and 1284fast-mode plus speeds. 1285.It clock-Tlow-fast 1286This property indicates the low period of the I2C clock. 1287It is a 1288.Sy u32 1289property that is counted in terms of clock cycles. 1290This property only applies when the bus is operating at fast-mode and 1291fast-mode plus speeds. 1292.It clock-Thigh-high 1293This property indicates the high period of the I2C clock. 1294It is a 1295.Sy u32 1296property that is counted in terms of clock cycles. 1297This property only applies when the bus is operating at fast-mode and 1298high speed. 1299.It clock-Tlow-high 1300This property indicates the low period of the I2C clock. 1301It is a 1302.Sy u32 1303property that is counted in terms of clock cycles. 1304This property only applies when the bus is operating at fast-mode and 1305high speed. 1306.El 1307.Sh EXIT STATUS 1308The 1309.Nm 1310utility exits 0 on success. 1311If an error occurs, it exits 1, and provides additional details about 1312the underlying cause of the error. 1313If there was an invalid or missing command line options, then 1314.Nm 1315exits 2. 1316.Pp 1317When performing a listing operation, if no items are listed or if a filter 1318is specified but is not matched, then these conditions are all treated as 1319errors and 1320.Nm 1321exits 1. 1322.Sh EXAMPLES 1323.Sy Example 1 1324Listing Controllers 1325.Pp 1326This example shows how to discover I2C and SMBus controllers in the 1327system. 1328.Bd -literal -offset indent 1329# i2cadm controller list 1330NAME TYPE SPEED NPORTS PROVIDER 1331ismt0 smbus standard 1 /pci@0,0/pci8086,7270@f/i2cnex@ismt0 1332pchsmbus0 smbus standard 1 /pci@0,0/pci8086,7270@1f, 1333 4/i2cnex@pchsmbus0 1334.Ed 1335.Pp 1336The controller information can be changed by requesting specific fields 1337or adding a filter: 1338.Bd -literal -offset indent 1339# i2cadm controller list -o name,speed ismt 1340NAME SPEED 1341ismt0 standard 1342.Ed 1343.Pp 1344.Sy Example 2 1345Listing Devices 1346.Pp 1347This example shows how to discover the I2C devices that the system knows 1348about. 1349.Bd -literal -offset indent 1350# i2cadm device list 1351NAME ADDR INSTANCE PATH 1352at24c32 0x50 at24c0 ismt0/0/0x50 1353pca9548 0x72 pca954x0 pchsmbus0/0/0x72 1354pca9548 0x73 pca954x1 pchsmbus0/0/0x73 1355pca9548 0x74 pca954x2 pchsmbus0/0/0x74 1356pca9548 0x75 pca954x3 pchsmbus0/0/0x75 1357pca9548 0x76 pca954x4 pchsmbus0/0/0x76 1358tmp431 0x4c tmp43x0 pchsmbus0/0/0x72/6/0x4c 1359lm75 0x48 lm7x0 pchsmbus0/0/0x73/1/0x48 1360lm75 0x49 lm7x1 pchsmbus0/0/0x73/1/0x49 1361lm75 0x4a lm7x2 pchsmbus0/0/0x73/1/0x4a 1362lm75 0x4b lm7x3 pchsmbus0/0/0x73/1/0x4b 1363lm75 0x4c lm7x4 pchsmbus0/0/0x73/1/0x4c 1364lm75 0x4d lm7x5 pchsmbus0/0/0x73/1/0x4d 1365lm75 0x4e lm7x6 pchsmbus0/0/0x73/1/0x4e 1366lm75 0x4f lm7x7 pchsmbus0/0/0x73/1/0x4f 1367.Ed 1368.Pp 1369One can also print out a subset of devices in a parsable form: 1370.Bd -literal -offset indent 1371# i2cadm device list -Hpo name,path lm75 1372lm75:pchsmbus0/0/0x73/1/0x48 1373lm75:pchsmbus0/0/0x73/1/0x49 1374lm75:pchsmbus0/0/0x73/1/0x4a 1375lm75:pchsmbus0/0/0x73/1/0x4b 1376lm75:pchsmbus0/0/0x73/1/0x4c 1377lm75:pchsmbus0/0/0x73/1/0x4d 1378lm75:pchsmbus0/0/0x73/1/0x4e 1379lm75:pchsmbus0/0/0x73/1/0x4f 1380.Ed 1381.Pp 1382.Sy Example 3 1383Adding a Device 1384.Pp 1385This example shows how we would add an AT24C32 EEPROM that is at 1386address 0x50. 1387.Bd -literal -offset indent 1388# i2cadm device add ismt0/0 at24c32 0x50 1389# i2cadm device list at24c32 1390NAME ADDR INSTANCE PATH 1391at24c32 0x50 at24c0 ismt0/0/0x50 1392.Ed 1393.Pp 1394Let's say we now wanted to add a TMP431 with 7-bit address address 0x4c 1395that is under port 6 of an 8-port PCA9548 at 0x72: 1396.Bd -literal -offset indent 1397# i2cadm mux list pca954x0 1398DEVICE NPORTS NAME INSTANCE PATH 1399pca9548 8 pca954x0 pca954x0 pchsmbus0/0/0x72 1400# i2cadm device add pchsmbus0/0/0x72/6 tmp431 0x4c 1401# i2cadm device list tmp431 1402NAME ADDR INSTANCE PATH 1403tmp431 0x4c tmp43x0 pchsmbus0/0/0x72/6/0x4c 1404.Ed 1405.Pp 1406.Sy Example 4 1407Scanning an I2C bus 1408.Pp 1409This shows 1410.Bd -literal 1411# i2cadm scan pchsmbus0/0 1412Device scan on pchsmbus0/0: 1413 1414 - = No Device @ = Device Found 1415 R = Reserved S = Skipped 1416 X = Timed Out Err = Error 1417 1418ADDR 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 14190x00 R R R R R R R R - - - - - - - - 14200x10 - - - - - - - - - - - - - - - - 14210x20 - - - - - - - - - - - - - - - - 14220x30 - - - - - - - - - - - - - - - - 14230x40 - - - - @ - - - - - - - - - - - 14240x50 - - - - - - - - - - - - - - - - 14250x60 - - - - - - - - @ - - - - - - - 14260x70 - - @ @ @ @ @ - R R R R R R R R 1427.Ed 1428.Pp 1429To instead scan on a port of a given mux, you would change the path to 1430indicate that. 1431For example: 1432.Bd -literal 1433# i2cadm scan pchsmbus0/0/0x72/6 1434Device scan on pchsmbus0/0/0x72/6: 1435 1436 - = No Device @ = Device Found 1437 R = Reserved S = Skipped 1438 X = Timed Out Err = Error 1439 1440ADDR 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 14410x00 R R R R R R R R - - - - - - - - 14420x10 - - - - - - - - - - - - - - - - 14430x20 - - - - - - - - - - - - - - - - 14440x30 - - - - - - - - - - - - - - - - 14450x40 - - - - @ - - - - - - - @ - - - 14460x50 - - - - - - - - - - - - - - - - 14470x60 - - - - - - - - @ - - - - - - - 14480x70 - - @ @ @ @ @ - R R R R R R R R 1449.Ed 1450.Pp 1451.Sy Example 5 1452Printing a Port Address Map 1453.Pp 1454The following shows how to see a list of addresses that are in use on a 1455given port according to the system. 1456This may not be every device that is present on the bus as the system 1457may not have been told about them. 1458.Bd -literal 1459# i2cadm port map pchsmbus0/0 1460Address map for pchsmbus0/0: 1461 1462 - = No Device L = Local Device 1463 S = Shared v = Downstream 1464 E = Error 1465 1466ADDR 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 14670x00 - - - - - - - - - - - - - - - - 14680x10 - - - - - - - - - - - - - - - - 14690x20 - - - - - - - - - - - - - - - - 14700x30 - - - - - - - - - - - - - - - - 14710x40 - - - - - - - - 1v 1v 1v 1v 2v 1v 1v 1v 14720x50 - - - - - - - - - - - - - - - - 14730x60 - - - - - - - - - - - - - - - - 14740x70 - - L L L L L - - - - - - - - - 1475.Ed 1476.Pp 1477In this case there are a number of downstream devices on this port that 1478are below the muxes. 1479If we then ask for the map of everything on a given mux port that most 1480of those are on we'd instead see: 1481.Bd -literal 1482# i2cadm port map pchsmbus0/0/0x73/1 1483Address map for pchsmbus0/0/0x73/1: 1484 1485 - = No Device L = Local Device 1486 S = Shared v = Downstream 1487 E = Error 1488 1489ADDR 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 14900x00 - - - - - - - - - - - - - - - - 14910x10 - - - - - - - - - - - - - - - - 14920x20 - - - - - - - - - - - - - - - - 14930x30 - - - - - - - - - - - - - - - - 14940x40 - - - - - - - - L L L L L L L L 14950x50 - - - - - - - - - - - - - - - - 14960x60 - - - - - - - - - - - - - - - - 14970x70 - - - - - - - - - - - - - - - - 1498.Ed 1499.Sh INTERFACE STABILITY 1500The command line interface of 1501.Nm 1502is 1503.Sy Evolving . 1504The output of 1505.Nm 1506is 1507.Sy Not-An-Interface 1508and may change at any time. 1509.Sh SEE ALSO 1510.Xr ofmt 3OFMT 1511