mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-06 15:01:35 +00:00
Some boards didn't define the CONFIG_TEMP_SENSOR_POWER_GPIO (such as: Oak),
Due to the hardware design, the power of temp sensor is always on.
But, we can enable/disable the temperature measurement circuitry of tmp432 by
setup the shutdown (SD) bit. Add a new API: tmp432_set_power() to let upper
layer to control the power of tmp432 by SW approach for power saving.
BRANCH=none
BUG=chrome-os-partner:44170
TEST=manual
1. make BOARD=oak -j
2. Turn off the TMP432:
> tmp432 power off
3. check whether tmp432 is shutdown:
> tmp432
ERROR: Temp sensor not powered.
Not Powered
4. Turn on the TMP432:
> tmp432 power on
5. check whether tmp432 is running:
> tmp432
Local:
Temp 29C
Therm Trip 85C
High Alarm 85C
Low Alarm 0C
Remote1:
Temp 27C
Therm Trip 85C
High Alarm 85C
Low Alarm 0C
Remote2:
Temp 27C
Therm Trip 85C
High Alarm 85C
Low Alarm 0C
STATUS: 10000000
CONFIG1: 00000000
CONFIG2: 00111100
Change-Id: Iab95c4c0b0130baf3bce380a8132e08ded8d159e
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/295058
Reviewed-by: Rong Chang <rongchang@chromium.org>
112 lines
3.6 KiB
C
112 lines
3.6 KiB
C
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* TMP432 temperature sensor module for Chrome EC */
|
|
|
|
#ifndef __CROS_EC_TMP432_H
|
|
#define __CROS_EC_TMP432_H
|
|
|
|
#define TMP432_I2C_ADDR 0x98 /* 7-bit address is 0x4C */
|
|
|
|
#define TMP432_IDX_LOCAL 0
|
|
#define TMP432_IDX_REMOTE1 1
|
|
#define TMP432_IDX_REMOTE2 2
|
|
|
|
/* Chip-specific registers */
|
|
#define TMP432_LOCAL 0x00
|
|
#define TMP432_REMOTE1 0x01
|
|
#define TMP432_STATUS 0x02
|
|
#define TMP432_CONFIGURATION1_R 0x03
|
|
#define TMP432_CONVERSION_RATE_R 0x04
|
|
#define TMP432_LOCAL_HIGH_LIMIT_R 0x05
|
|
#define TMP432_LOCAL_LOW_LIMIT_R 0x06
|
|
#define TMP432_REMOTE1_HIGH_LIMIT_R 0x07
|
|
#define TMP432_REMOTE1_LOW_LIMIT_R 0x08
|
|
#define TMP432_CONFIGURATION1_W 0x09
|
|
#define TMP432_CONVERSION_RATE_W 0x0a
|
|
#define TMP432_LOCAL_HIGH_LIMIT_W 0x0b
|
|
#define TMP432_LOCAL_LOW_LIMIT_W 0x0c
|
|
#define TMP432_REMOTE1_HIGH_LIMIT_W 0x0d
|
|
#define TMP432_REMOTE1_LOW_LIMIT_W 0x0e
|
|
#define TMP432_ONESHOT 0x0f
|
|
#define TMP432_REMOTE1_EXTD 0x10
|
|
#define TMP432_REMOTE1_HIGH_LIMIT_EXTD 0x13
|
|
#define TMP432_REMOTE1_LOW_LIMIT_EXTD 0x14
|
|
#define TMP432_REMOTE2_HIGH_LIMIT_R 0x15
|
|
#define TMP432_REMOTE2_HIGH_LIMIT_W 0x15
|
|
#define TMP432_REMOTE2_LOW_LIMIT_R 0x16
|
|
#define TMP432_REMOTE2_LOW_LIMIT_W 0x16
|
|
#define TMP432_REMOTE2_HIGH_LIMIT_EXTD 0x17
|
|
#define TMP432_REMOTE2_LOW_LIMIT_EXTD 0x18
|
|
#define TMP432_REMOTE1_THERM_LIMIT 0x19
|
|
#define TMP432_REMOTE2_THERM_LIMIT 0x1a
|
|
#define TMP432_STATUS_FAULT 0x1b
|
|
#define TMP432_CHANNEL_MASK 0x1f
|
|
#define TMP432_LOCAL_THERM_LIMIT 0x20
|
|
#define TMP432_THERM_HYSTERESIS 0x21
|
|
#define TMP432_CONSECUTIVE_ALERT 0x22
|
|
#define TMP432_REMOTE2 0x23
|
|
#define TMP432_REMOTE2_EXTD 0x24
|
|
#define TMP432_BETA_RANGE_CH1 0x25
|
|
#define TMP432_BETA_RANGE_CH2 0x26
|
|
#define TMP432_NFACTOR_REMOTE1 0x27
|
|
#define TMP432_NFACTOR_REMOTE2 0x28
|
|
#define TMP432_LOCAL_EXTD 0x29
|
|
#define TMP432_STATUS_LIMIT_HIGH 0x35
|
|
#define TMP432_STATUS_LIMIT_LOW 0x36
|
|
#define TMP432_STATUS_THERM 0x37
|
|
#define TMP432_LOCAL_HIGH_LIMIT_EXTD 0x3d
|
|
#define TMP432_LOCAL_LOW_LIMIT_EXTD 0x3e
|
|
#define TMP432_CONFIGURATION2_R 0x3f
|
|
#define TMP432_CONFIGURATION2_W 0x3f
|
|
#define TMP432_RESET_W 0xfc
|
|
#define TMP432_DEVICE_ID 0xfd
|
|
#define TMP432_MANUFACTURER_ID 0xfe
|
|
|
|
/* Config register bits */
|
|
#define TMP432_CONFIG1_TEMP_RANGE (1 << 2)
|
|
#define TMP432_CONFIG1_MODE (1 << 5)
|
|
#define TMP432_CONFIG1_RUN_L (1 << 6)
|
|
#define TMP432_CONFIG1_ALERT_MASK_L (1 << 7)
|
|
#define TMP432_CONFIG2_RESISTANCE_CORRECTION (1 << 2)
|
|
#define TMP432_CONFIG2_LOCAL_ENABLE (1 << 3)
|
|
#define TMP432_CONFIG2_REMOTE1_ENABLE (1 << 4)
|
|
#define TMP432_CONFIG2_REMOTE2_ENABLE (1 << 5)
|
|
|
|
/* Status register bits */
|
|
#define TMP432_STATUS_TEMP_THERM_ALARM (1 << 1)
|
|
#define TMP432_STATUS_OPEN (1 << 2)
|
|
#define TMP432_STATUS_TEMP_LOW_ALARM (1 << 3)
|
|
#define TMP432_STATUS_TEMP_HIGH_ALARM (1 << 4)
|
|
#define TMP432_STATUS_BUSY (1 << 7)
|
|
|
|
enum tmp432_power_state {
|
|
TMP432_POWER_OFF = 0,
|
|
TMP432_POWER_ON,
|
|
TMP432_POWER_COUNT
|
|
};
|
|
|
|
/**
|
|
* Get the last polled value of a sensor.
|
|
*
|
|
* @param idx Index to read. Idx indicates whether to read die
|
|
* temperature or external temperature.
|
|
* @param temp_ptr Destination for temperature in K.
|
|
*
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int tmp432_get_val(int idx, int *temp_ptr);
|
|
|
|
/**
|
|
* Power control function of tmp432 temperature sensor.
|
|
*
|
|
* @param power_on TMP432_POWER_ON: turn tmp432 sensor on.
|
|
* TMP432_POWER_OFF: shut tmp432 sensor down.
|
|
*
|
|
* @return EC_SUCCESS if successful, non-zero if error.
|
|
*/
|
|
int tmp432_set_power(enum tmp432_power_state power_on);
|
|
#endif /* __CROS_EC_TMP432_H */
|