Skip to content

Commit 8799d7b

Browse files
committed
commandline: Remove --has-mec
Now we can autodetect, we don't need it anymore, yay! Signed-off-by: Daniel Schaefer <[email protected]>
1 parent aad9433 commit 8799d7b

File tree

11 files changed

+32
-91
lines changed

11 files changed

+32
-91
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ Options:
202202
Specify I2C addresses of the PD chips (Advanced)
203203
--pd-ports <PD_PORTS> <PD_PORTS>
204204
Specify I2C ports of the PD chips (Advanced)
205-
--has-mec <HAS_MEC>
206-
Specify the type of EC chip (MEC/MCHP or other) [possible values: true, false]
207205
-t, --test Run self-test to check if interaction with EC is possible
208206
-h, --help Print help information
209207
```

completions/bash/framework_tool

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ _framework_tool() {
5050
"--driver"
5151
"--pd-addrs"
5252
"--pd-ports"
53-
"--has-mec"
5453
"-t" "--test"
5554
"-h" "--help"
5655
)
@@ -59,7 +58,6 @@ _framework_tool() {
5958
local inputdeck_modes=("auto" "off" "on")
6059
local console_modes=("recent" "follow")
6160
local drivers=("portio" "cros-ec" "windows")
62-
local has_mec_options=("true" "false")
6361
local brightness_options=("high" "medium" "low" "ultra-low")
6462

6563
local current_word prev_word
@@ -77,8 +75,6 @@ _framework_tool() {
7775
COMPREPLY=( $(compgen -W "${console_modes[*]}" -- "$current_word") )
7876
elif [[ $prev_word == "--driver" ]]; then
7977
COMPREPLY=( $(compgen -W "${drivers[*]}" -- "$current_word") )
80-
elif [[ $prev_word == "--has-mec" ]]; then
81-
COMPREPLY=( $(compgen -W "${has_mec_options[*]}" -- "$current_word") )
8278
elif [[ $prev_word == "--fp-brightness" ]]; then
8379
COMPREPLY=( $(compgen -W "${brightness_options[*]}" -- "$current_word") )
8480
fi

completions/zsh/_framework_tool

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ options=(
4848
'--driver[Select which driver is used]:driver:(portio cros-ec windows)'
4949
'--pd-addrs[Specify I2C addresses of the PD chips (Advanced)]:pd_addrs'
5050
'--pd-ports[Specify I2C ports of the PD chips (Advanced)]:pd_ports'
51-
'--has-mec[Specify the type of EC chip (MEC/MCHP or other)]:has_mec:(true false)'
5251
'-t[Run self-test to check if interaction with EC is possible]'
5352
'-h[Print help]'
5453
)

framework_lib/src/ccgx/device.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ impl PdPort {
4141
let platform = &(*config).as_ref().unwrap().platform;
4242

4343
match (platform, self) {
44-
(Platform::GenericFramework((left, _), _, _), PdPort::Left01) => *left,
45-
(Platform::GenericFramework((_, right), _, _), PdPort::Right23) => *right,
44+
(Platform::GenericFramework((left, _), _), PdPort::Left01) => *left,
45+
(Platform::GenericFramework((_, right), _), PdPort::Right23) => *right,
4646
// Framework AMD Platforms (CCG8)
4747
(
4848
Platform::Framework13Amd7080
@@ -70,8 +70,8 @@ impl PdPort {
7070
let platform = &(*config).as_ref().unwrap().platform;
7171

7272
Ok(match (platform, self) {
73-
(Platform::GenericFramework(_, (left, _), _), PdPort::Left01) => *left,
74-
(Platform::GenericFramework(_, (_, right), _), PdPort::Right23) => *right,
73+
(Platform::GenericFramework(_, (left, _)), PdPort::Left01) => *left,
74+
(Platform::GenericFramework(_, (_, right)), PdPort::Right23) => *right,
7575
(Platform::IntelGen11, _) => 6,
7676
(Platform::IntelGen12 | Platform::IntelGen13, PdPort::Left01) => 6,
7777
(Platform::IntelGen12 | Platform::IntelGen13, PdPort::Right23) => 7,

framework_lib/src/chromium_ec/mod.rs

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -201,24 +201,6 @@ const BOARD_VERSION_NPC_DB: [i32; BOARD_VERSION_COUNT] = [
201201
100, 311, 521, 721, 931, 1131, 1341, 1551, 1751, 1961, 2171, 2370, 2580, 2780, 2990, 3200,
202202
];
203203

204-
pub fn has_mec() -> bool {
205-
let platform = smbios::get_platform().unwrap();
206-
if let Platform::GenericFramework(_, _, has_mec) = platform {
207-
return has_mec;
208-
}
209-
210-
// TODO: Should turn this around
211-
!matches!(
212-
smbios::get_platform().unwrap(),
213-
Platform::Framework13Amd7080
214-
| Platform::Framework16Amd7080
215-
| Platform::IntelCoreUltra1
216-
| Platform::Framework13AmdAi300
217-
| Platform::Framework12IntelGen13
218-
| Platform::FrameworkDesktopAmdAiMax300
219-
)
220-
}
221-
222204
pub trait CrosEcDriver {
223205
fn read_memory(&self, offset: u16, length: u16) -> Option<Vec<u8>>;
224206
fn send_command(&self, command: u16, command_version: u8, data: &[u8]) -> EcResult<Vec<u8>>;
@@ -953,30 +935,25 @@ impl CrosEc {
953935
// Everything before is probably a header.
954936
// TODO: I don't think there are magic bytes on zephyr firmware
955937
//
956-
if has_mec() {
957-
println!(" Check MCHP magic byte at start of firmware code.");
958-
// Make sure we can read at an offset and with arbitrary length
959-
let data = self.read_ec_flash(FLASH_PROGRAM_OFFSET, 16).unwrap();
960-
debug!("Expecting beginning with 50 48 43 4D ('PHCM' in ASCII)");
961-
debug!("{:02X?}", data);
962-
println!(
963-
" {:02X?} ASCII:{:?}",
964-
&data[..4],
965-
core::str::from_utf8(&data[..4])
966-
);
967-
968-
if data[0..4] != [0x50, 0x48, 0x43, 0x4D] {
969-
println!(" INVALID: {:02X?}", &data[0..3]);
970-
res = Err(EcError::DeviceError(format!(
971-
"INVALID: {:02X?}",
972-
&data[0..3]
973-
)));
974-
}
938+
debug!(" Check MCHP magic bytes at start of firmware code.");
939+
// Make sure we can read at an offset and with arbitrary length
940+
let data = self.read_ec_flash(FLASH_PROGRAM_OFFSET, 16).unwrap();
941+
debug!("Expecting beginning with 50 48 43 4D ('PHCM' in ASCII)");
942+
debug!("{:02X?}", data);
943+
debug!(
944+
" {:02X?} ASCII:{:?}",
945+
&data[..4],
946+
core::str::from_utf8(&data[..4])
947+
);
948+
949+
let has_mec = data[0..4] == [0x50, 0x48, 0x43, 0x4D];
950+
if has_mec {
951+
debug!(" Found MCHP magic bytes at start of firmware code.");
975952
}
976953

977954
// ===== Test 4 =====
978955
println!(" Read flash flags");
979-
let data = if has_mec() {
956+
let data = if has_mec {
980957
self.read_ec_flash(MEC_FLASH_FLAGS, 0x80).unwrap()
981958
} else {
982959
self.read_ec_flash(NPC_FLASH_FLAGS, 0x80).unwrap()

framework_lib/src/commandline/clap_std.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,15 @@ struct ClapCli {
228228
driver: Option<CrosEcDriverType>,
229229

230230
/// Specify I2C addresses of the PD chips (Advanced)
231-
#[clap(number_of_values = 2, requires("pd_ports"), requires("has_mec"))]
231+
#[clap(number_of_values = 2, requires("pd_ports"))]
232232
#[arg(long)]
233233
pd_addrs: Vec<u16>,
234234

235235
/// Specify I2C ports of the PD chips (Advanced)
236-
#[clap(number_of_values = 2, requires("pd_addrs"), requires("has_mec"))]
236+
#[clap(number_of_values = 2, requires("pd_addrs"))]
237237
#[arg(long)]
238238
pd_ports: Vec<u8>,
239239

240-
/// Specify the type of EC chip (MEC/MCHP or other)
241-
#[clap(requires("pd_addrs"), requires("pd_ports"))]
242-
#[arg(long)]
243-
has_mec: Option<bool>,
244-
245240
/// Run self-test to check if interaction with EC is possible
246241
#[arg(long, short)]
247242
test: bool,
@@ -408,7 +403,6 @@ pub fn parse(args: &[String]) -> Cli {
408403
driver: args.driver,
409404
pd_addrs,
410405
pd_ports,
411-
has_mec: args.has_mec,
412406
test: args.test,
413407
// TODO: Set help. Not very important because Clap handles this by itself
414408
help: false,

framework_lib/src/commandline/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ pub struct Cli {
191191
pub hash: Option<String>,
192192
pub pd_addrs: Option<(u16, u16)>,
193193
pub pd_ports: Option<(u8, u8)>,
194-
pub has_mec: Option<bool>,
195194
pub help: bool,
196195
pub info: bool,
197196
pub flash_gpu_descriptor: Option<(u8, String)>,
@@ -701,12 +700,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
701700
}
702701

703702
// Must be run before any application code to set the config
704-
if args.pd_addrs.is_some() && args.pd_ports.is_some() && args.has_mec.is_some() {
705-
let platform = Platform::GenericFramework(
706-
args.pd_addrs.unwrap(),
707-
args.pd_ports.unwrap(),
708-
args.has_mec.unwrap(),
709-
);
703+
if args.pd_addrs.is_some() && args.pd_ports.is_some() {
704+
let platform = Platform::GenericFramework(args.pd_addrs.unwrap(), args.pd_ports.unwrap());
710705
Config::set(platform);
711706
}
712707

@@ -1169,7 +1164,7 @@ fn selftest(ec: &CrosEc) -> Option<()> {
11691164
} else {
11701165
println!(" SMBIOS Platform: Unknown");
11711166
println!();
1172-
println!("Specify custom platform parameters with --pd-ports --pd-addrs --has-mec");
1167+
println!("Specify custom platform parameters with --pd-ports --pd-addrs");
11731168
return None;
11741169
};
11751170

framework_lib/src/commandline/uefi.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pub fn parse(args: &[String]) -> Cli {
106106
driver: Some(CrosEcDriverType::Portio),
107107
pd_addrs: None,
108108
pd_ports: None,
109-
has_mec: None,
110109
test: false,
111110
help: false,
112111
flash_gpu_descriptor: None,
@@ -610,22 +609,6 @@ pub fn parse(args: &[String]) -> Cli {
610609
None
611610
};
612611
found_an_option = true;
613-
} else if arg == "--has-mec" {
614-
cli.has_mec = if args.len() > i + 1 {
615-
if let Ok(b) = args[i + 1].parse::<bool>() {
616-
Some(b)
617-
} else {
618-
println!(
619-
"Invalid value for --has-mec: '{}'. Must be 'true' or 'false'.",
620-
args[i + 1]
621-
);
622-
None
623-
}
624-
} else {
625-
println!("--has-mec requires extra boolean argument.");
626-
None
627-
};
628-
found_an_option = true;
629612
} else if arg == "--raw-command" {
630613
cli.raw_command = args[1..].to_vec();
631614
} else if arg == "--compare-version" {
@@ -699,11 +682,10 @@ pub fn parse(args: &[String]) -> Cli {
699682
}
700683
}
701684

702-
let custom_platform = cli.pd_addrs.is_some() && cli.pd_ports.is_some() && cli.has_mec.is_some();
703-
let no_customization =
704-
cli.pd_addrs.is_none() && cli.pd_ports.is_none() && cli.has_mec.is_none();
685+
let custom_platform = cli.pd_addrs.is_some() && cli.pd_ports.is_some();
686+
let no_customization = cli.pd_addrs.is_none() && cli.pd_ports.is_none();
705687
if !(custom_platform || no_customization) {
706-
println!("To customize the platform you need to provide all of --pd-addrs, --pd-ports and --has-mec");
688+
println!("To customize the platform you need to provide all of --pd-addrs, and --pd-ports");
707689
}
708690

709691
if args.len() == 1 && cli.paginate {

framework_lib/src/smbios.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub enum ConfigDigit0 {
4646
pub fn is_framework() -> bool {
4747
if matches!(
4848
get_platform(),
49-
Some(Platform::GenericFramework((_, _), (_, _), _))
49+
Some(Platform::GenericFramework((_, _), (_, _)))
5050
) {
5151
return true;
5252
}
@@ -252,7 +252,7 @@ pub fn get_platform() -> Option<Platform> {
252252
// Except if it's a GenericFramework platform
253253
let config = Config::get();
254254
let platform = &(*config).as_ref().unwrap().platform;
255-
if matches!(platform, Platform::GenericFramework((_, _), (_, _), _)) {
255+
if matches!(platform, Platform::GenericFramework((_, _), (_, _))) {
256256
return Some(*platform);
257257
}
258258
}

framework_lib/src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub enum Platform {
3636
/// Framework Desktop - AMD Ryzen AI Max 300
3737
FrameworkDesktopAmdAiMax300,
3838
/// Generic Framework device
39-
/// pd_addrs, pd_ports, has_mec
40-
GenericFramework((u16, u16), (u8, u8), bool),
39+
/// pd_addrs, pd_ports
40+
GenericFramework((u16, u16), (u8, u8)),
4141
}
4242

4343
#[derive(Debug, PartialEq, Clone, Copy)]

rgbkbd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# Example invocation in fish shell
33
# cargo build && sudo ./target/debug/framework_tool \
4-
# --driver portio --has-mec false --pd-ports 1 1 --pd-addrs 64 64 \
4+
# --driver portio --pd-ports 1 1 --pd-addrs 64 64 \
55
# (./rgbkbd.py | string split ' ')
66

77
BRIGHTNESS = 1

0 commit comments

Comments
 (0)