FORCE_POWER
This commit is contained in:
121
you-ass-bee-see/Cargo.lock
generated
121
you-ass-bee-see/Cargo.lock
generated
@@ -24,6 +24,29 @@ version = "0.1.10"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "coreboot-collector"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"err-derive",
|
||||||
|
"libc",
|
||||||
|
"sysfs-class",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "err-derive"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "22deed3a8124cff5fa835713fa105621e43bbdc46690c3a6b68328a012d350d4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn",
|
||||||
|
"synstructure",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "i2cdev"
|
name = "i2cdev"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
@@ -55,6 +78,103 @@ dependencies = [
|
|||||||
"void",
|
"void",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "numtoa"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e521b6adefa0b2c1fa5d2abdf9a5216288686fe6146249215d884c0e5ab320b0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error-attr",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error-attr"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.53"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synstructure"
|
||||||
|
version = "0.12.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sysfs-class"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "git+https://github.com/pop-os/sysfs-class.git#c3b86e07c36feb9b705b8c24af1498cbd396de4e"
|
||||||
|
dependencies = [
|
||||||
|
"numtoa",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "void"
|
name = "void"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@@ -65,5 +185,6 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
|||||||
name = "you-ass-bee-see"
|
name = "you-ass-bee-see"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"coreboot-collector",
|
||||||
"i2cdev",
|
"i2cdev",
|
||||||
]
|
]
|
||||||
|
@@ -7,4 +7,5 @@ edition = "2018"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
coreboot-collector = { path = "../tools/coreboot-collector" }
|
||||||
i2cdev = "0.4.4"
|
i2cdev = "0.4.4"
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
|
use coreboot_collector::sideband::Sideband;
|
||||||
use i2cdev::core::I2CDevice;
|
use i2cdev::core::I2CDevice;
|
||||||
use i2cdev::linux::LinuxI2CDevice;
|
use i2cdev::linux::LinuxI2CDevice;
|
||||||
use std::fs;
|
use std::{fs, thread, time};
|
||||||
|
|
||||||
const IECS_CMD: u8 = 8;
|
const IECS_CMD: u8 = 8;
|
||||||
const IECS_DATA: u8 = 9;
|
const IECS_DATA: u8 = 9;
|
||||||
@@ -12,6 +13,8 @@ const CMD_BLKW: u32 = 0x574b4c42;
|
|||||||
const CMD_BOPS: u32 = 0x53504f42;
|
const CMD_BOPS: u32 = 0x53504f42;
|
||||||
const CMD_PCYC: u32 = 0x43594350;
|
const CMD_PCYC: u32 = 0x43594350;
|
||||||
|
|
||||||
|
const GPIO_FORCE_POWER: (u8, u8) = (0x6E, 0x82); // GPP_A23
|
||||||
|
|
||||||
fn read<I: I2CDevice>(dev: &mut I, reg: u8) -> Result<u32, I::Error> {
|
fn read<I: I2CDevice>(dev: &mut I, reg: u8) -> Result<u32, I::Error> {
|
||||||
let bytes = dev.smbus_read_block_data(reg)?;
|
let bytes = dev.smbus_read_block_data(reg)?;
|
||||||
//TODO: return error on bytes.len() != 4
|
//TODO: return error on bytes.len() != 4
|
||||||
@@ -46,7 +49,20 @@ fn command<I: I2CDevice>(dev: &mut I, cmd: u32) -> Result<u32, I::Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
//TODO: force power and sleep 40ms
|
//TODO: check model
|
||||||
|
|
||||||
|
let sideband = unsafe { Sideband::new(0xFD00_0000).unwrap() };
|
||||||
|
|
||||||
|
// Set FORCE_POWER high
|
||||||
|
unsafe {
|
||||||
|
let (port, pad) = GPIO_FORCE_POWER;
|
||||||
|
let mut value = sideband.gpio(port, pad);
|
||||||
|
value |= 1;
|
||||||
|
sideband.set_gpio(port, pad, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sleep 40ms
|
||||||
|
thread::sleep(time::Duration::from_millis(40));
|
||||||
|
|
||||||
let mut dev = LinuxI2CDevice::new("/dev/i2c-11", 0x40).unwrap();
|
let mut dev = LinuxI2CDevice::new("/dev/i2c-11", 0x40).unwrap();
|
||||||
eprintln!("Vendor: {:X}", read(&mut dev, 0).unwrap());
|
eprintln!("Vendor: {:X}", read(&mut dev, 0).unwrap());
|
||||||
@@ -58,6 +74,9 @@ fn main() {
|
|||||||
println!("{}: {:X}", i, read(&mut dev, i).unwrap());
|
println!("{}: {:X}", i, read(&mut dev, i).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
write(&mut dev, IECS_DATA, 0).unwrap();
|
||||||
|
println!("IECS_DATA: {:X}", read(&mut dev, IECS_DATA).unwrap());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
eprintln!("Set offset to 0");
|
eprintln!("Set offset to 0");
|
||||||
write(&mut dev, IECS_DATA, 0).unwrap();
|
write(&mut dev, IECS_DATA, 0).unwrap();
|
||||||
@@ -105,4 +124,12 @@ fn main() {
|
|||||||
|
|
||||||
eprintln!("Successfully flashed retimer");
|
eprintln!("Successfully flashed retimer");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Set FORCE_POWER low
|
||||||
|
unsafe {
|
||||||
|
let (port, pad) = GPIO_FORCE_POWER;
|
||||||
|
let mut value = sideband.gpio(port, pad);
|
||||||
|
value &= !1;
|
||||||
|
sideband.set_gpio(port, pad, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user