@@ -11,15 +11,17 @@ use crate::ccgx::{AppVersion, Application, BaseVersion, ControllerVersion, MainP
1111use crate :: chromium_ec:: command:: EcRequestRaw ;
1212use crate :: chromium_ec:: commands:: { EcRequestReadPdVersion , EcRequestUsbPdPowerInfo } ;
1313use crate :: chromium_ec:: { print_err_ref, CrosEc , CrosEcDriver , EcResult } ;
14+ use crate :: smbios;
1415use crate :: smbios:: get_platform;
16+ use crate :: util:: Platform ;
1517
1618/// Maximum length of strings in memmap
1719const EC_MEMMAP_TEXT_MAX : u16 = 8 ;
1820
1921// The offset address of each type of data in mapped memory.
2022// TODO: Move non-power values to other modules
21- const _EC_MEMMAP_TEMP_SENSOR : u16 = 0x00 ; // Temp sensors 0x00 - 0x0f
22- const _EC_MEMMAP_FAN : u16 = 0x10 ; // Fan speeds 0x10 - 0x17
23+ const EC_MEMMAP_TEMP_SENSOR : u16 = 0x00 ; // Temp sensors 0x00 - 0x0f
24+ const EC_MEMMAP_FAN : u16 = 0x10 ; // Fan speeds 0x10 - 0x17
2325const _EC_MEMMAP_TEMP_SENSOR_B: u16 = 0x18 ; // More temp sensors 0x18 - 0x1f
2426const _EC_MEMMAP_ID: u16 = 0x2120 ; // 0x20 == 'E', 0x21 == 'C'
2527const EC_MEMMAP_ID_VERSION : u16 = 0x22 ; // Version of data in 0x20 - 0x2f
@@ -159,6 +161,56 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
159161 let _events_ver = ec. read_memory ( EC_MEMMAP_EVENTS_VERSION , 2 ) . unwrap ( ) ;
160162}
161163
164+ fn in_c ( t : u8 ) -> u8 {
165+ if t == 255 {
166+ t
167+ } else {
168+ t - 73
169+ }
170+ }
171+
172+ pub fn print_thermal ( ec : & CrosEc ) {
173+ let temps = ec. read_memory ( EC_MEMMAP_TEMP_SENSOR , 0x0F ) . unwrap ( ) ;
174+ let fans = ec. read_memory ( EC_MEMMAP_FAN , 0x08 ) . unwrap ( ) ;
175+
176+ let platform = smbios:: get_platform ( ) ;
177+ match platform {
178+ Some ( Platform :: IntelGen11 ) | Some ( Platform :: IntelGen12 ) | Some ( Platform :: IntelGen13 ) => {
179+ println ! ( " F75303_Local: {:>4} C" , in_c( temps[ 0 ] ) ) ;
180+ println ! ( " F75303_CPU: {:>4} C" , in_c( temps[ 1 ] ) ) ;
181+ println ! ( " F75303_DDR: {:>4} C" , in_c( temps[ 2 ] ) ) ;
182+ println ! ( " Battery: {:>4} C" , in_c( temps[ 3 ] ) ) ;
183+ println ! ( " PECI: {:>4} C" , in_c( temps[ 4 ] ) ) ;
184+ println ! ( " F57397_VCCGT: {:>4} C" , in_c( temps[ 5 ] ) ) ;
185+ }
186+ Some ( Platform :: Framework13Amd | Platform :: Framework16 ) => {
187+ println ! ( " F75303_Local: {:>4} C" , in_c( temps[ 0 ] ) ) ;
188+ println ! ( " F75303_CPU: {:>4} C" , in_c( temps[ 1 ] ) ) ;
189+ println ! ( " F75303_DDR: {:>4} C" , in_c( temps[ 2 ] ) ) ;
190+ println ! ( " APU: {:>4} C" , in_c( temps[ 3 ] ) ) ;
191+ if matches ! ( platform, Some ( Platform :: Framework16 ) ) {
192+ println ! ( " dGPU VR: {:>4} C" , in_c( temps[ 4 ] ) ) ;
193+ println ! ( " dGPU VRAM: {:>4} C" , in_c( temps[ 5 ] ) ) ;
194+ println ! ( " dGPU AMB: {:>4} C" , in_c( temps[ 6 ] ) ) ;
195+ println ! ( " dGPU temp: {:>4} C" , in_c( temps[ 7 ] ) ) ;
196+ }
197+ }
198+ _ => {
199+ println ! ( " Temp 0: {:>4} C" , in_c( temps[ 0 ] ) ) ;
200+ println ! ( " Temp 1: {:>4} C" , in_c( temps[ 1 ] ) ) ;
201+ println ! ( " Temp 2: {:>4} C" , in_c( temps[ 2 ] ) ) ;
202+ println ! ( " Temp 3: {:>4} C" , in_c( temps[ 3 ] ) ) ;
203+ println ! ( " Temp 4: {:>4} C" , in_c( temps[ 4 ] ) ) ;
204+ println ! ( " Temp 5: {:>4} C" , in_c( temps[ 5 ] ) ) ;
205+ println ! ( " Temp 6: {:>4} C" , in_c( temps[ 6 ] ) ) ;
206+ println ! ( " Temp 7: {:>4} C" , in_c( temps[ 7 ] ) ) ;
207+ }
208+ }
209+
210+ let fan0 = u16:: from_le_bytes ( [ fans[ 0 ] , fans[ 1 ] ] ) ;
211+ println ! ( " Fan Speed: {:>4} RPM" , fan0) ;
212+ }
213+
162214// TODO: Use Result
163215pub fn power_info ( ec : & CrosEc ) -> Option < PowerInfo > {
164216 let battery_flag = ec. read_memory ( EC_MEMMAP_BATT_FLAG , 1 ) ?[ 0 ] ;
0 commit comments