Skip to content

Commit 4d70630

Browse files
committed
rendmp: add RAA229620A support
Fixes #569
1 parent 788c966 commit 4d70630

1 file changed

Lines changed: 87 additions & 17 deletions

File tree

cmd/rendmp/src/lib.rs

Lines changed: 87 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct RendmpArgs {
216216
#[clap(long, group = "subcommand")]
217217
open_pin: bool,
218218

219-
/// checks for open pins on the given converter
219+
/// performs a phase check on the converter
220220
#[clap(long, group = "subcommand")]
221221
phase_check: bool,
222222

@@ -959,6 +959,7 @@ fn rendmp_ingest(subargs: &RendmpArgs) -> Result<()> {
959959
enum SupportedDevice {
960960
ISL68224,
961961
RAA229618,
962+
RAA229620A,
962963
}
963964

964965
impl SupportedDevice {
@@ -967,6 +968,7 @@ impl SupportedDevice {
967968
match self {
968969
SupportedDevice::ISL68224 => 3,
969970
SupportedDevice::RAA229618 => 2,
971+
SupportedDevice::RAA229620A => 2,
970972
}
971973
}
972974

@@ -993,6 +995,19 @@ impl SupportedDevice {
993995
}
994996
phases
995997
}
998+
SupportedDevice::RAA229620A => {
999+
let mut phases = vec![];
1000+
for phase in 0..12 {
1001+
phases.push((phase.to_string(), phase));
1002+
}
1003+
for i in 0..2 {
1004+
// The 20 here looks like a copy paste mistake from the
1005+
// '618, but is deliberate; we believe the bit offset here
1006+
// is the same as the '618 despite the smaller phase count.
1007+
phases.push((format!("VSEN{i}"), i + 20));
1008+
}
1009+
phases
1010+
}
9961011
}
9971012
}
9981013
}
@@ -1133,6 +1148,10 @@ fn get_pin_states(
11331148
0x00BE, 0x00BF, // open-pin
11341149
0xE904, 0xE905, // mask
11351150
],
1151+
SupportedDevice::RAA229620A => &[
1152+
0x0046, 0x0047, // open-pin
1153+
0xE904, 0xE905, // mask
1154+
],
11361155
};
11371156
let mut ops = vec![];
11381157
for &r in regs {
@@ -1159,7 +1178,7 @@ fn get_pin_states(
11591178
// experiments and discussion with Renesas.
11601179
let (open, mask) = match dev {
11611180
SupportedDevice::ISL68224 => (values[0] as u64, values[1] as u64),
1162-
SupportedDevice::RAA229618 => {
1181+
SupportedDevice::RAA229618 | SupportedDevice::RAA229620A => {
11631182
let open = values[0] as u64 | ((values[1] as u64) << 32);
11641183
let mask = values[2] as u64 | ((values[3] as u64) << 32);
11651184
(open, mask)
@@ -1645,19 +1664,17 @@ fn rendmp_phase_check<'a>(
16451664
// we don't), this should be factored out into a humility-spd crate that
16461665
// both "spd" and "rendmp" would use.
16471666
//
1648-
if cmd_spd::spd_any(hubris, core)? {
1649-
if subargs.force_phase_check {
1650-
warn!(
1651-
"DIMMs are present, but phase check has been forced; if the \
1652-
checked phase powers a DIMM, this may hang the I2C bus!"
1653-
);
1654-
} else {
1655-
bail!(
1656-
"cannot check phases with DIMMs present: if a checked \
1657-
phase powers a DIMM, an I2C hang can result; this can be \
1658-
overridden with --force-phase-check -- but use this carefully"
1659-
);
1660-
}
1667+
if subargs.force_phase_check {
1668+
warn!(
1669+
"DIMM presence check disabled, if this check hangs, remove the \
1670+
DIMMs and retry."
1671+
);
1672+
} else if cmd_spd::spd_any(hubris, core)? {
1673+
bail!(
1674+
"cannot check phases with DIMMs present: if a checked \
1675+
phase powers a DIMM, an I2C hang can result; this can be \
1676+
overridden with --force-phase-check -- but use this carefully"
1677+
);
16611678
}
16621679

16631680
// Pick out the target device
@@ -1698,7 +1715,7 @@ fn rendmp_phase_check<'a>(
16981715
// faults when we write it back
16991716
let disable_fault_reg: u16 = match dev {
17001717
SupportedDevice::ISL68224 => 0xE952,
1701-
SupportedDevice::RAA229618 => 0xE932,
1718+
SupportedDevice::RAA229618 | SupportedDevice::RAA229620A => 0xE932,
17021719
};
17031720

17041721
////////////////////////////////////////////////////////////////////////////
@@ -1725,7 +1742,13 @@ fn rendmp_phase_check<'a>(
17251742
worker.read_word32(index, true, LOOPCFG as u8)?;
17261743
worker.read_word(index, true, PEAK_OCUC_COUNT as u8)?;
17271744

1728-
// Set PMBus command codes 0xD0 and 0xD1 to 0x8000 (disable VMon)
1745+
// Set the appropriate device-specific PMBus command codes to input
1746+
// voltage thresholding, by setting the thresholds to a very negative
1747+
// value. This should ensure that it always thinks the input value is
1748+
// high enough.
1749+
//
1750+
// This is a 16-bit two's-complement register, so 0x8000 is the most
1751+
// negative value.
17291752
match dev {
17301753
SupportedDevice::ISL68224 => {
17311754
use pmbus::commands::isl68224::CommandCode;
@@ -1760,6 +1783,26 @@ fn rendmp_phase_check<'a>(
17601783
let reg = (0xEA5B + rail * 0x80) as u16;
17611784
worker.read_dma(addr, reg)?;
17621785
}
1786+
SupportedDevice::RAA229620A => {
1787+
use pmbus::commands::raa229620a::CommandCode;
1788+
worker.write_word(
1789+
index,
1790+
true,
1791+
CommandCode::VIN_ON as u8,
1792+
0x8000,
1793+
)?;
1794+
worker.write_word(
1795+
index,
1796+
true,
1797+
CommandCode::VIN_OFF as u8,
1798+
0x8000,
1799+
)?;
1800+
1801+
// This undocumented read of 0xEA5B matches the '618; Renesas
1802+
// described it as "phase count control for partial fast add."
1803+
let reg = (0xEA5B + rail * 0x80) as u16;
1804+
worker.read_dma(addr, reg)?;
1805+
}
17631806
}
17641807

17651808
worker.read_dma(addr, disable_fault_reg + rail as u16)?;
@@ -1852,6 +1895,26 @@ fn rendmp_phase_check<'a>(
18521895
bail!("failed to set VIN_OFF for {rail}: {e}",);
18531896
}
18541897

1898+
// Clear bit 0 of DMA register EA5B and write it back
1899+
// (the name part_fast_add comes from Power Navigator)
1900+
let mut part_fast_add = match next()? {
1901+
Ok(v) => v.expect_read_dma()?,
1902+
Err(e) => {
1903+
bail!("worker.failed to read EA5B for rail {rail}: {e}")
1904+
}
1905+
};
1906+
part_fast_add &= !1; // clear bit 0
1907+
let reg = (0xEA5B + rail * 0x80) as u16;
1908+
worker.write_dma(addr, reg, part_fast_add)?;
1909+
}
1910+
SupportedDevice::RAA229620A => {
1911+
if let Err(e) = next()? {
1912+
bail!("failed to set VIN_ON for {rail}: {e}",);
1913+
}
1914+
if let Err(e) = next()? {
1915+
bail!("failed to set VIN_OFF for {rail}: {e}",);
1916+
}
1917+
18551918
// Clear bit 0 of DMA register EA5B and write it back
18561919
// (the name part_fast_add comes from Power Navigator)
18571920
let mut part_fast_add = match next()? {
@@ -1922,6 +1985,12 @@ fn rendmp_phase_check<'a>(
19221985
bail!("failed to modify EA5B for rail {rail}: {e}")
19231986
}
19241987
},
1988+
SupportedDevice::RAA229620A => match next()? {
1989+
Ok(v) => v.expect_write_dma()?,
1990+
Err(e) => {
1991+
bail!("failed to modify EA5B for rail {rail}: {e}")
1992+
}
1993+
},
19251994
SupportedDevice::ISL68224 => {
19261995
// no changes were made specifically for the ISL68224
19271996
}
@@ -2082,6 +2151,7 @@ fn rendmp_phase_check<'a>(
20822151
};
20832152
let device = match dev {
20842153
SupportedDevice::RAA229618 => pmbus::Device::Raa229618,
2154+
SupportedDevice::RAA229620A => pmbus::Device::Raa229620A,
20852155
SupportedDevice::ISL68224 => pmbus::Device::Isl68224,
20862156
};
20872157

0 commit comments

Comments
 (0)