Skip to content

Commit b90e958

Browse files
Zick WeiCommit Bot
authored andcommitted
guybrush: move thermal sensor/setting to variant
This patch move thermal sensor and setting to variant, let variant have their own setting. BUG=none BRANCH=none TEST=make BOARD=dewatt, make BOARD=guybrush, make BOARD=nipperkin Signed-off-by: Zick Wei <[email protected]> Change-Id: Ibf37a0a45d1a728abc5ed88dde230f0561698bbc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3132547 Reviewed-by: Devin Lu <[email protected]> Reviewed-by: Rob Barnes <[email protected]> Commit-Queue: Rob Barnes <[email protected]>
1 parent 6116078 commit b90e958

File tree

8 files changed

+516
-171
lines changed

8 files changed

+516
-171
lines changed

baseboard/guybrush/baseboard.c

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
/* Guybrush family-specific configuration */
77

8-
#include "adc.h"
98
#include "cros_board_info.h"
109
#include "base_fw_config.h"
1110
#include "battery_fuel_gauge.h"
@@ -23,8 +22,6 @@
2322
#include "driver/retimer/ps8811.h"
2423
#include "driver/retimer/ps8818.h"
2524
#include "driver/tcpm/nct38xx.h"
26-
#include "driver/temp_sensor/sb_tsi.h"
27-
#include "driver/temp_sensor/tmp112.h"
2825
#include "driver/usb_mux/anx7451.h"
2926
#include "driver/usb_mux/amd_fp6.h"
3027
#include "fan.h"
@@ -39,9 +36,6 @@
3936
#include "pi3usb9201.h"
4037
#include "power.h"
4138
#include "pwm.h"
42-
#include "temp_sensor.h"
43-
#include "thermal.h"
44-
#include "temp_sensor/thermistor.h"
4539
#include "usb_mux.h"
4640
#include "usb_pd_tcpm.h"
4741
#include "usbc_ppc.h"
@@ -149,145 +143,7 @@ const struct i2c_port_t i2c_ports[] = {
149143
};
150144
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
151145

152-
/* ADC Channels */
153-
const struct adc_t adc_channels[] = {
154-
[ADC_TEMP_SENSOR_SOC] = {
155-
.name = "SOC",
156-
.input_ch = NPCX_ADC_CH0,
157-
.factor_mul = ADC_MAX_VOLT,
158-
.factor_div = ADC_READ_MAX + 1,
159-
.shift = 0,
160-
},
161-
[ADC_TEMP_SENSOR_CHARGER] = {
162-
.name = "CHARGER",
163-
.input_ch = NPCX_ADC_CH1,
164-
.factor_mul = ADC_MAX_VOLT,
165-
.factor_div = ADC_READ_MAX + 1,
166-
.shift = 0,
167-
},
168-
[ADC_TEMP_SENSOR_MEMORY] = {
169-
.name = "MEMORY",
170-
.input_ch = NPCX_ADC_CH2,
171-
.factor_mul = ADC_MAX_VOLT,
172-
.factor_div = ADC_READ_MAX + 1,
173-
.shift = 0,
174-
},
175-
[ADC_CORE_IMON1] = {
176-
.name = "CORE_I",
177-
.input_ch = NPCX_ADC_CH3,
178-
.factor_mul = ADC_MAX_VOLT,
179-
.factor_div = ADC_READ_MAX + 1,
180-
.shift = 0,
181-
},
182-
[ADC_SOC_IMON2] = {
183-
.name = "SOC_I",
184-
.input_ch = NPCX_ADC_CH4,
185-
.factor_mul = ADC_MAX_VOLT,
186-
.factor_div = ADC_READ_MAX + 1,
187-
.shift = 0,
188-
},
189-
};
190-
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
191146

192-
/* Temp Sensors */
193-
static int board_get_memory_temp(int, int *);
194-
195-
const struct tmp112_sensor_t tmp112_sensors[] = {
196-
{ I2C_PORT_SENSOR, TMP112_I2C_ADDR_FLAGS0 },
197-
{ I2C_PORT_SENSOR, TMP112_I2C_ADDR_FLAGS1 },
198-
};
199-
BUILD_ASSERT(ARRAY_SIZE(tmp112_sensors) == TMP112_COUNT);
200-
201-
const struct temp_sensor_t temp_sensors[] = {
202-
[TEMP_SENSOR_SOC] = {
203-
.name = "SOC",
204-
.type = TEMP_SENSOR_TYPE_BOARD,
205-
.read = board_get_soc_temp_k,
206-
.idx = TMP112_SOC,
207-
},
208-
[TEMP_SENSOR_CHARGER] = {
209-
.name = "Charger",
210-
.type = TEMP_SENSOR_TYPE_BOARD,
211-
.read = get_temp_3v3_30k9_47k_4050b,
212-
.idx = ADC_TEMP_SENSOR_CHARGER,
213-
},
214-
[TEMP_SENSOR_MEMORY] = {
215-
.name = "Memory",
216-
.type = TEMP_SENSOR_TYPE_BOARD,
217-
.read = board_get_memory_temp,
218-
.idx = ADC_TEMP_SENSOR_MEMORY,
219-
},
220-
[TEMP_SENSOR_CPU] = {
221-
.name = "CPU",
222-
.type = TEMP_SENSOR_TYPE_CPU,
223-
.read = sb_tsi_get_val,
224-
.idx = 0,
225-
},
226-
[TEMP_SENSOR_AMBIENT] = {
227-
.name = "Ambient",
228-
.type = TEMP_SENSOR_TYPE_BOARD,
229-
.read = tmp112_get_val_k,
230-
.idx = TMP112_AMB,
231-
},
232-
};
233-
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
234-
235-
struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT] = {
236-
[TEMP_SENSOR_SOC] = {
237-
.temp_host = {
238-
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
239-
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
240-
},
241-
.temp_host_release = {
242-
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
243-
},
244-
/* TODO: Setting fan off to 0 so it's allways on */
245-
.temp_fan_off = C_TO_K(0),
246-
.temp_fan_max = C_TO_K(70),
247-
},
248-
[TEMP_SENSOR_CHARGER] = {
249-
.temp_host = {
250-
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
251-
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
252-
},
253-
.temp_host_release = {
254-
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
255-
},
256-
.temp_fan_off = 0,
257-
.temp_fan_max = 0,
258-
},
259-
[TEMP_SENSOR_MEMORY] = {
260-
.temp_host = {
261-
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
262-
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
263-
},
264-
.temp_host_release = {
265-
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
266-
},
267-
.temp_fan_off = 0,
268-
.temp_fan_max = 0,
269-
},
270-
[TEMP_SENSOR_CPU] = {
271-
.temp_host = {
272-
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
273-
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
274-
},
275-
.temp_host_release = {
276-
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
277-
},
278-
/*
279-
* CPU temp sensor fan thresholds are high because they are a
280-
* backup for the SOC temp sensor fan thresholds.
281-
*/
282-
.temp_fan_off = C_TO_K(60),
283-
.temp_fan_max = C_TO_K(90),
284-
},
285-
/*
286-
* Note: Leave ambient entries at 0, both as it does not represent a
287-
* hotspot and as not all boards have this sensor
288-
*/
289-
};
290-
BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
291147

292148
const struct charger_config_t chg_chips[] = {
293149
{
@@ -813,13 +669,6 @@ void bc12_interrupt(enum gpio_signal signal)
813669
}
814670
}
815671

816-
static int board_get_memory_temp(int idx, int *temp_k)
817-
{
818-
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
819-
return EC_ERROR_NOT_POWERED;
820-
return get_temp_3v3_30k9_47k_4050b(idx, temp_k);
821-
}
822-
823672
/**
824673
* Return if VBUS is sagging too low
825674
*/

baseboard/guybrush/baseboard.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -314,33 +314,13 @@ enum usba_port {
314314
USBA_PORT_COUNT
315315
};
316316

317-
/* ADC Channels */
318-
enum adc_channel {
319-
ADC_TEMP_SENSOR_SOC = 0,
320-
ADC_TEMP_SENSOR_CHARGER,
321-
ADC_TEMP_SENSOR_MEMORY,
322-
ADC_CORE_IMON1,
323-
ADC_SOC_IMON2,
324-
ADC_CH_COUNT
325-
};
326-
327317
/* TMP112 sensors */
328318
enum tmp112_sensor {
329319
TMP112_SOC,
330320
TMP112_AMB,
331321
TMP112_COUNT,
332322
};
333323

334-
/* Temp Sensors */
335-
enum temp_sensor_id {
336-
TEMP_SENSOR_SOC = 0,
337-
TEMP_SENSOR_CHARGER,
338-
TEMP_SENSOR_MEMORY,
339-
TEMP_SENSOR_CPU,
340-
TEMP_SENSOR_AMBIENT,
341-
TEMP_SENSOR_COUNT
342-
};
343-
344324
enum sensor_id {
345325
LID_ACCEL,
346326
BASE_ACCEL,

board/dewatt/board.c

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
/* Guybrush board-specific configuration */
77

8+
#include "adc.h"
89
#include "base_fw_config.h"
910
#include "board_fw_config.h"
1011
#include "button.h"
@@ -16,6 +17,8 @@
1617
#include "driver/accel_bma422.h"
1718
#include "driver/retimer/ps8811.h"
1819
#include "driver/retimer/ps8818.h"
20+
#include "driver/temp_sensor/sb_tsi.h"
21+
#include "driver/temp_sensor/tmp112.h"
1922
#include "extpower.h"
2023
#include "gpio.h"
2124
#include "hooks.h"
@@ -25,8 +28,10 @@
2528
#include "power_button.h"
2629
#include "switch.h"
2730
#include "tablet_mode.h"
31+
#include "temp_sensor.h"
2832
#include "temp_sensor/thermistor.h"
2933
#include "temp_sensor/tmp112.h"
34+
#include "thermal.h"
3035
#include "usb_mux.h"
3136

3237
#include "gpio_list.h" /* Must come after other header files. */
@@ -383,3 +388,150 @@ int board_get_ambient_temp_mk(int *temp_mk)
383388

384389
return tmp112_get_val_mk(TMP112_AMB, temp_mk);
385390
}
391+
392+
/* ADC Channels */
393+
const struct adc_t adc_channels[] = {
394+
[ADC_TEMP_SENSOR_SOC] = {
395+
.name = "SOC",
396+
.input_ch = NPCX_ADC_CH0,
397+
.factor_mul = ADC_MAX_VOLT,
398+
.factor_div = ADC_READ_MAX + 1,
399+
.shift = 0,
400+
},
401+
[ADC_TEMP_SENSOR_CHARGER] = {
402+
.name = "CHARGER",
403+
.input_ch = NPCX_ADC_CH1,
404+
.factor_mul = ADC_MAX_VOLT,
405+
.factor_div = ADC_READ_MAX + 1,
406+
.shift = 0,
407+
},
408+
[ADC_TEMP_SENSOR_MEMORY] = {
409+
.name = "MEMORY",
410+
.input_ch = NPCX_ADC_CH2,
411+
.factor_mul = ADC_MAX_VOLT,
412+
.factor_div = ADC_READ_MAX + 1,
413+
.shift = 0,
414+
},
415+
[ADC_CORE_IMON1] = {
416+
.name = "CORE_I",
417+
.input_ch = NPCX_ADC_CH3,
418+
.factor_mul = ADC_MAX_VOLT,
419+
.factor_div = ADC_READ_MAX + 1,
420+
.shift = 0,
421+
},
422+
[ADC_SOC_IMON2] = {
423+
.name = "SOC_I",
424+
.input_ch = NPCX_ADC_CH4,
425+
.factor_mul = ADC_MAX_VOLT,
426+
.factor_div = ADC_READ_MAX + 1,
427+
.shift = 0,
428+
},
429+
};
430+
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
431+
432+
/* Temp Sensors */
433+
static int board_get_memory_temp(int, int *);
434+
435+
const struct tmp112_sensor_t tmp112_sensors[] = {
436+
{ I2C_PORT_SENSOR, TMP112_I2C_ADDR_FLAGS0 },
437+
{ I2C_PORT_SENSOR, TMP112_I2C_ADDR_FLAGS1 },
438+
};
439+
BUILD_ASSERT(ARRAY_SIZE(tmp112_sensors) == TMP112_COUNT);
440+
441+
const struct temp_sensor_t temp_sensors[] = {
442+
[TEMP_SENSOR_SOC] = {
443+
.name = "SOC",
444+
.type = TEMP_SENSOR_TYPE_BOARD,
445+
.read = board_get_soc_temp_k,
446+
.idx = TMP112_SOC,
447+
},
448+
[TEMP_SENSOR_CHARGER] = {
449+
.name = "Charger",
450+
.type = TEMP_SENSOR_TYPE_BOARD,
451+
.read = get_temp_3v3_30k9_47k_4050b,
452+
.idx = ADC_TEMP_SENSOR_CHARGER,
453+
},
454+
[TEMP_SENSOR_MEMORY] = {
455+
.name = "Memory",
456+
.type = TEMP_SENSOR_TYPE_BOARD,
457+
.read = board_get_memory_temp,
458+
.idx = ADC_TEMP_SENSOR_MEMORY,
459+
},
460+
[TEMP_SENSOR_CPU] = {
461+
.name = "CPU",
462+
.type = TEMP_SENSOR_TYPE_CPU,
463+
.read = sb_tsi_get_val,
464+
.idx = 0,
465+
},
466+
[TEMP_SENSOR_AMBIENT] = {
467+
.name = "Ambient",
468+
.type = TEMP_SENSOR_TYPE_BOARD,
469+
.read = tmp112_get_val_k,
470+
.idx = TMP112_AMB,
471+
},
472+
};
473+
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
474+
475+
struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT] = {
476+
[TEMP_SENSOR_SOC] = {
477+
.temp_host = {
478+
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
479+
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
480+
},
481+
.temp_host_release = {
482+
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
483+
},
484+
/* TODO: Setting fan off to 0 so it's allways on */
485+
.temp_fan_off = C_TO_K(0),
486+
.temp_fan_max = C_TO_K(70),
487+
},
488+
[TEMP_SENSOR_CHARGER] = {
489+
.temp_host = {
490+
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
491+
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
492+
},
493+
.temp_host_release = {
494+
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
495+
},
496+
.temp_fan_off = 0,
497+
.temp_fan_max = 0,
498+
},
499+
[TEMP_SENSOR_MEMORY] = {
500+
.temp_host = {
501+
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
502+
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
503+
},
504+
.temp_host_release = {
505+
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
506+
},
507+
.temp_fan_off = 0,
508+
.temp_fan_max = 0,
509+
},
510+
[TEMP_SENSOR_CPU] = {
511+
.temp_host = {
512+
[EC_TEMP_THRESH_HIGH] = C_TO_K(100),
513+
[EC_TEMP_THRESH_HALT] = C_TO_K(105),
514+
},
515+
.temp_host_release = {
516+
[EC_TEMP_THRESH_HIGH] = C_TO_K(80),
517+
},
518+
/*
519+
* CPU temp sensor fan thresholds are high because they are a
520+
* backup for the SOC temp sensor fan thresholds.
521+
*/
522+
.temp_fan_off = C_TO_K(60),
523+
.temp_fan_max = C_TO_K(90),
524+
},
525+
/*
526+
* Note: Leave ambient entries at 0, both as it does not represent a
527+
* hotspot and as not all boards have this sensor
528+
*/
529+
};
530+
BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
531+
532+
static int board_get_memory_temp(int idx, int *temp_k)
533+
{
534+
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
535+
return EC_ERROR_NOT_POWERED;
536+
return get_temp_3v3_30k9_47k_4050b(idx, temp_k);
537+
}

0 commit comments

Comments
 (0)