1#!/usr/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2025 Oxide Computer Company 15# 16 17# 18# This is designed to set up all of the expected I2C devices that are being 19# simulated. This looks like: 20# 21# 0x10: at24c32 22# 0x20: at24c08 (uses 0x20-0x23) 23# 0x70: pca9548 24# mux 0: 0x71: pca9548 25# mux 0: at24c32: 0x72 26# mux 1: at24c32: 0x72 27# mux 2: at24c32: 0x72 28# mux 3: at24c32: 0x72 29# mux 4: at24c32: 0x72 30# mux 5: at24c32: 0x72 31# mux 6: at24c32: 0x72 32# mux 7: at24c32: 0x72 33# mux 1: 0x71: at24c32 34# mux 2: 0x71: ts5111 35# 0x72: ts5111 36# mux 3: 0x71: ts5111 37# 0x72: ts5111 38# 39 40. $(dirname $0)/common.ksh 41 42# 43# Start a fresh instance of i2csimd. 44# 45if ! svcadm disable -s system/i2csimd; then 46 fatal "failed to disable i2csimd" 47fi 48 49if ! svcadm enable -st system/i2csimd; then 50 fatal "failed to enable i2csimd" 51fi 52 53# 54# Create all of our devices. 55# 56if ! i2cadm device add i2csim0/0 at24c32 0x10; then 57 fatal "failed to add device i2csim0/0/0x10" 58fi 59 60if ! i2cadm device add i2csim0/0 at24c08 0x20; then 61 fatal "failed to add device i2csim0/0/0x20" 62fi 63 64if ! i2cadm device add i2csim0/0 pca9548 0x70; then 65 fatal "failed to add device i2csim0/0/0x70" 66fi 67 68if ! i2cadm device add i2csim0/0/0x70/0 pca9548 0x71; then 69 fatal "failed to add device i2csim0/0/0x70/0/0x71" 70fi 71 72for i in {0..7}; do 73 if ! i2cadm device add i2csim0/0/0x70/0/0x71/$i at24c32 0x72; then 74 fatal "failed to add device i2csim0/0/0x70/0/0x71/$i/0x72" 75 fi 76done 77 78if ! i2cadm device add i2csim0/0/0x70/1 at24c32 0x71; then 79 fatal "failed to add device i2csim0/0/0x70/1/0x71" 80fi 81 82for i in {2..3}; do 83 if ! i2cadm device add i2csim0/0/0x70/$i ts5111 0x71; then 84 fatal "failed to add device i2csim0/0/0x70/$i/0x71" 85 fi 86 87 if ! i2cadm device add i2csim0/0/0x70/$i ts5111 0x72; then 88 fatal "failed to add device i2csim0/0/0x70/$i/0x72" 89 fi 90done 91 92exit $i2c_exit 93