Skip to content

Commit

Permalink
reset during I2C transaction can induce mayhem (#1281)
Browse files Browse the repository at this point in the history
We have seen a series of vexing VPD problems on reset, with a variety
of underlying causes.  While we fixed several of these, the problem
remained (see #1196) -- and one clear cause was a reset during an I2C
transaction, resulting in an errant first transaction after the reset.
This fix engages in the time-honored tradition of wiggling SCL on
reset, and then inducing a STOP condition to effectively terminate any
zombie I2C transactions.
  • Loading branch information
bcantrill authored Apr 15, 2023
1 parent 4d6a3a5 commit 0a4f0f3
Show file tree
Hide file tree
Showing 26 changed files with 366 additions and 799 deletions.
5 changes: 3 additions & 2 deletions app/demo-stm32h7-nucleo/app-h743.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ extern-regions = [ "sram2", "sram3", "sram4" ]
[[config.i2c.controllers]]
controller = 2

[[config.i2c.controllers.ports.F.pins]]
pins = [ 0, 1 ]
[config.i2c.controllers.ports.F]
scl.pin = 1
sda.pin = 0
af = 4

#
Expand Down
6 changes: 3 additions & 3 deletions app/demo-stm32h7-nucleo/app-h753.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ extern-regions = [ "sram2", "sram3", "sram4" ]
[[config.i2c.controllers]]
controller = 2

[[config.i2c.controllers.ports.F.pins]]
pins = [ 0, 1 ]
[config.i2c.controllers.ports.F]
scl.pin = 1
sda.pin = 0
af = 4

#
Expand All @@ -211,7 +212,6 @@ af = 4
# driver = "ltc4306"
# address = 0b1001_010


[config.spi.spi1]
controller = 1

Expand Down
5 changes: 3 additions & 2 deletions app/donglet/app-g031-i2c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ features = ["insomniac"]
[[config.i2c.controllers]]
controller = 1

[[config.i2c.controllers.ports.B.pins]]
pins = [ 6, 9 ]
[config.i2c.controllers.ports.B]
scl.pin = 6
sda.pin = 9
af = 6

#
Expand Down
5 changes: 3 additions & 2 deletions app/donglet/app-g031.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ features = ["insomniac"]
[[config.i2c.controllers]]
controller = 1

[[config.i2c.controllers.ports.B.pins]]
pins = [ 6, 9 ]
[config.i2c.controllers.ports.B]
scl.pin = 6
sda.pin = 9
af = 6

#
Expand Down
31 changes: 17 additions & 14 deletions app/gemini-bu/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,44 +163,48 @@ controller = 1

[config.i2c.controllers.ports.B]
name = "onboard"

[[config.i2c.controllers.ports.B.pins]]
pins = [ 8, 9 ]
scl.pin = 8
sda.pin = 9
af = 4

[[config.i2c.controllers]]
controller = 2
target = true

[[config.i2c.controllers.ports.F.pins]]
pins = [ 0, 1]
[config.i2c.controllers.ports.F]
scl.pin = 1
sda.pin = 0
af = 4

[[config.i2c.controllers]]
controller = 3

[[config.i2c.controllers.ports.H.pins]]
pins = [ 7, 8 ]
[config.i2c.controllers.ports.H]
scl.pin = 7
sda.pin = 8
af = 4

[[config.i2c.controllers]]
controller = 4

[[config.i2c.controllers.ports.D.pins]]
pins = [ 12, 13 ]
[config.i2c.controllers.ports.D]
scl.pin = 12
sda.pin = 13
af = 4

[[config.i2c.controllers.ports.F.pins]]
pins = [ 14, 15 ]
[config.i2c.controllers.ports.F]
scl.pin = 14
sda.pin = 15
af = 4

[[config.i2c.controllers.ports.F.muxes]]
driver = "ltc4306"
address = 0x44
enable = { port = "G", pin = 0 }

[[config.i2c.controllers.ports.H.pins]]
pins = [ 11, 12 ]
[config.i2c.controllers.ports.H]
scl.pin = 11
sda.pin = 12
af = 4

[[config.i2c.devices]]
Expand Down Expand Up @@ -268,7 +272,6 @@ address = 0x24
description = "TPS546B24A evaluation board"
power = { rails = [ "TPS_EVL_VOUT" ] }


[config.spi.spi2]
controller = 2

Expand Down
20 changes: 15 additions & 5 deletions app/gimlet/rev-b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ target = true
[config.i2c.controllers.ports.B]
name = "spd"
description = "SPD proxy"
pins = [ { pins = [ 6, 7 ], af = 4 } ]
scl.pin = 6
sda.pin = 7
af = 4

#
# I2C2: Front/M.2 bus
Expand All @@ -364,7 +366,9 @@ controller = 2
[config.i2c.controllers.ports.B]
name = "m2"
description = "M.2 bus"
pins = [ { pins = [ 10, 11 ], af = 4 } ]
scl.pin = 10
sda.pin = 11
af = 4
muxes = [ { driver = "pca9548", address = 0x73 } ]

#
Expand All @@ -374,7 +378,9 @@ muxes = [ { driver = "pca9548", address = 0x73 } ]
[config.i2c.controllers.ports.F]
name = "front"
description = "Front bus"
pins = [ { pins = [ 0, 1 ], af = 4 } ]
scl.pin = 1
sda.pin = 0
af = 4

#
# Shark fin muxes
Expand Down Expand Up @@ -404,7 +410,9 @@ controller = 3
[config.i2c.controllers.ports.H]
name = "mid"
description = "Mid bus"
pins = [ { pins = [ 7, 8 ], af = 4 } ]
scl.pin = 7
sda.pin = 8
af = 4

#
# I2C4: Rear bus
Expand All @@ -419,7 +427,9 @@ controller = 4
[config.i2c.controllers.ports.F]
name = "rear"
description = "Rear bus"
pins = [ { pins = [ 14, 15 ], af = 4 } ]
scl.pin = 14
sda.pin = 15
af = 4

[[config.i2c.devices]]
bus = "front"
Expand Down
22 changes: 16 additions & 6 deletions app/gimlet/rev-c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ task-slots = ["i2c_driver"]

[tasks.vpd]
name = "task-vpd"
priority = 4
priority = 5
max-sizes = {flash = 8192, ram = 1024}
start = true
task-slots = ["sys", "i2c_driver"]
Expand Down Expand Up @@ -349,7 +349,9 @@ target = true
[config.i2c.controllers.ports.B]
name = "spd"
description = "SPD proxy"
pins = [ { pins = [ 6, 7 ], af = 4 } ]
scl.pin = 6
sda.pin = 7
af = 4

#
# I2C2: Front/M.2 bus
Expand All @@ -364,7 +366,9 @@ controller = 2
[config.i2c.controllers.ports.B]
name = "m2"
description = "M.2 bus"
pins = [ { pins = [ 10, 11 ], af = 4 } ]
scl.pin = 10
sda.pin = 11
af = 4
muxes = [ { driver = "pca9548", address = 0x73 } ]

#
Expand All @@ -374,7 +378,9 @@ muxes = [ { driver = "pca9548", address = 0x73 } ]
[config.i2c.controllers.ports.F]
name = "front"
description = "Front bus"
pins = [ { pins = [ 0, 1 ], af = 4 } ]
scl.pin = 1
sda.pin = 0
af = 4

#
# Shark fin muxes
Expand Down Expand Up @@ -404,7 +410,9 @@ controller = 3
[config.i2c.controllers.ports.H]
name = "mid"
description = "Mid bus"
pins = [ { pins = [ 7, 8 ], af = 4 } ]
scl.pin = 7
sda.pin = 8
af = 4

#
# I2C4: Rear bus
Expand All @@ -419,7 +427,9 @@ controller = 4
[config.i2c.controllers.ports.F]
name = "rear"
description = "Rear bus"
pins = [ { pins = [ 14, 15 ], af = 4 } ]
scl.pin = 14
sda.pin = 15
af = 4

[[config.i2c.devices]]
bus = "front"
Expand Down
20 changes: 15 additions & 5 deletions app/gimlet/rev-d.toml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ target = true
[config.i2c.controllers.ports.B]
name = "spd"
description = "SPD proxy"
pins = [ { pins = [ 6, 7 ], af = 4 } ]
scl.pin = 6
sda.pin = 7
af = 4

#
# I2C2: Front/M.2 bus
Expand All @@ -364,7 +366,9 @@ controller = 2
[config.i2c.controllers.ports.B]
name = "m2"
description = "M.2 bus"
pins = [ { pins = [ 10, 11 ], af = 4 } ]
scl.pin = 10
sda.pin = 11
af = 4

[[config.i2c.controllers.ports.B.muxes]]
driver = "pca9548"
Expand All @@ -378,7 +382,9 @@ nreset = { port = "E", pin = 15 } # SP_TO_I2C_SW_M2_A2_V3P3
[config.i2c.controllers.ports.F]
name = "front"
description = "Front bus"
pins = [ { pins = [ 0, 1 ], af = 4 } ]
scl.pin = 1
sda.pin = 0
af = 4

#
# Shark fin muxes
Expand Down Expand Up @@ -411,7 +417,9 @@ controller = 3
[config.i2c.controllers.ports.H]
name = "mid"
description = "Mid bus"
pins = [ { pins = [ 7, 8 ], af = 4 } ]
scl.pin = 7
sda.pin = 8
af = 4

#
# I2C4: Rear bus
Expand All @@ -426,7 +434,9 @@ controller = 4
[config.i2c.controllers.ports.F]
name = "rear"
description = "Rear bus"
pins = [ { pins = [ 14, 15 ], af = 4 } ]
scl.pin = 14
sda.pin = 15
af = 4

[[config.i2c.devices]]
bus = "front"
Expand Down
Loading

0 comments on commit 0a4f0f3

Please sign in to comment.