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