power: Expose TDP limit range as platform config

This commit is contained in:
Vicki Pfau 2024-08-27 21:57:50 -07:00
parent 36e88484a4
commit 7c3f2baa05
5 changed files with 46 additions and 7 deletions

View file

@ -16,6 +16,7 @@ use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tracing::{error, warn};
use crate::hardware::is_deck;
use crate::platform::platform_config;
use crate::{path, write_synced};
const GPU_HWMON_PREFIX: &str = "/sys/class/hwmon";
@ -397,6 +398,15 @@ pub(crate) async fn set_tdp_limit(limit: u32) -> Result<()> {
Ok(())
}
pub(crate) async fn get_tdp_limit_range() -> Result<(u32, u32)> {
let range = platform_config()
.await?
.as_ref()
.and_then(|config| config.tdp_limit)
.ok_or(anyhow!("No TDP limit range configured"))?;
Ok((range.min, range.max))
}
#[cfg(test)]
pub(crate) mod test {
use super::*;