diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-10-17 15:05:04 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-23 21:27:40 +0000 |
commit | 2ad076f8a02c8a3165a76dfb093cefd79fdbfc67 (patch) | |
tree | 13f9d0505f564f07c9867aabf11b7083613666d4 /driver | |
parent | 8cf03ac0563294fbdeca2dc133d06f0b51c9a546 (diff) | |
download | chrome-ec-2ad076f8a02c8a3165a76dfb093cefd79fdbfc67.tar.gz |
cleanup: Rename and move header files
Device-specific headers belong in driver/ or chip/. The include/
directory should be for common interfaces.
Code should not normally need to include driver-specific headers. If
it does, it should use the full relative path from the EC project root
(for example, drivers/charger/bq24715.h).
Change-Id: Id23db37a431e2d802a74ec601db6f69b613352ba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173746
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/bq24192.c | 2 | ||||
-rw-r--r-- | driver/charger/bq24192.h | 28 | ||||
-rw-r--r-- | driver/charger/bq24707a.c | 2 | ||||
-rw-r--r-- | driver/charger/bq24707a.h | 44 | ||||
-rw-r--r-- | driver/charger/bq24715.c | 2 | ||||
-rw-r--r-- | driver/charger/bq24715.h | 130 | ||||
-rw-r--r-- | driver/charger/bq24725.c | 2 | ||||
-rw-r--r-- | driver/charger/bq24725.h | 50 | ||||
-rw-r--r-- | driver/charger/bq24738.c | 2 | ||||
-rw-r--r-- | driver/charger/bq24738.h | 60 | ||||
-rw-r--r-- | driver/led/lp5562.h | 76 | ||||
-rw-r--r-- | driver/temp_sensor/g781.c | 2 | ||||
-rw-r--r-- | driver/temp_sensor/g781.h | 70 | ||||
-rw-r--r-- | driver/temp_sensor/tmp006.h | 32 | ||||
-rw-r--r-- | driver/tsu6721.h | 111 |
15 files changed, 607 insertions, 6 deletions
diff --git a/driver/charger/bq24192.c b/driver/charger/bq24192.c index 72f778d367..17297cd9ce 100644 --- a/driver/charger/bq24192.c +++ b/driver/charger/bq24192.c @@ -5,8 +5,8 @@ * TI bq24192 battery charger driver. */ +#include "bq24192.h" #include "charger.h" -#include "charger_bq24192.h" #include "common.h" #include "console.h" #include "gpio.h" diff --git a/driver/charger/bq24192.h b/driver/charger/bq24192.h new file mode 100644 index 0000000000..4177dc5c2c --- /dev/null +++ b/driver/charger/bq24192.h @@ -0,0 +1,28 @@ +/* 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. + * + * TI bq24192 battery charger driver. + */ + +#ifndef __CROS_EC_CHARGER_BQ24192_H +#define __CROS_EC_CHARGER_BQ24192_H + +#define BQ24192_ADDR 0xd6 + +/* Registers */ +#define BQ24192_REG_INPUT_CTRL 0x0 +#define BQ24192_REG_POWER_ON_CFG 0x1 +#define BQ24192_REG_CHG_CURRENT 0x2 +#define BQ24192_REG_PRE_CHG_CURRENT 0x3 +#define BQ24192_REG_CHG_VOLTAGE 0x4 +#define BQ24192_REG_CHG_TERM_TMR 0x5 +#define BQ24192_REG_IR_COMP 0x6 +#define BQ24192_REG_MISC_OP 0x7 +#define BQ24192_REG_STATUS 0x8 +#define BQ24192_REG_FAULT 0x9 +#define BQ24192_REG_ID 0xa + +#define BQ24192_DEVICE_ID 0x2b + +#endif /* __CROS_EC_CHARGER_BQ24192_H */ diff --git a/driver/charger/bq24707a.c b/driver/charger/bq24707a.c index 43bd32eb91..67467610df 100644 --- a/driver/charger/bq24707a.c +++ b/driver/charger/bq24707a.c @@ -6,8 +6,8 @@ */ #include "battery_smart.h" +#include "bq24707a.h" #include "charger.h" -#include "charger_bq24707a.h" #include "console.h" #include "common.h" #include "util.h" diff --git a/driver/charger/bq24707a.h b/driver/charger/bq24707a.h new file mode 100644 index 0000000000..744e991283 --- /dev/null +++ b/driver/charger/bq24707a.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2012 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. + * + * TI bq24707A battery charger driver. + */ + +#ifndef __CROS_EC_CHARGER_BQ24707A_H +#define __CROS_EC_CHARGER_BQ24707A_H + +/* Chip specific commands */ +#define BQ24707_CHARGE_OPTION 0x12 +#define BQ24707_INPUT_CURRENT 0x3f +#define BQ24707_MANUFACTURE_ID 0xfe +#define BQ24707_DEVICE_ID 0xff + +/* ChargeOption 0x12 */ +#define OPTION_CHARGE_INHIBIT (1 << 0) +#define OPTION_ACOC_THRESHOLD (3 << 1) +#define OPTION_COMPARATOR_THRESHOLD (1 << 4) +#define OPTION_IOUT_SELECTION (1 << 5) +#define OPTION_IFAULT_HI_THRESHOLD (3 << 7) +#define OPTION_EMI_FREQ_ENABLE (1 << 9) +#define OPTION_EMI_FREQ_ADJ (1 << 10) +#define OPTION_WATCHDOG_TIMER (3 << 13) +#define OPTION_AOC_DELITCH_TIME (1 << 15) +/* OPTION_ACOC_THRESHOLD */ +#define ACOC_THRESHOLD_DISABLE (0 << 1) +#define ACOC_THRESHOLD_133X (1 << 1) +#define ACOC_THRESHOLD_166X_DEFAULT (2 << 1) +#define ACOC_THRESHOLD_222X (3 << 1) +/* OPTION_IFAULT_HI_THRESHOLD */ +#define IFAULT_THRESHOLD_300MV (0 << 7) +#define IFAULT_THRESHOLD_500MV (1 << 7) +#define IFAULT_THRESHOLD_700MV_DEFAULT (2 << 7) +#define IFAULT_THRESHOLD_900MV (3 << 7) +/* OPTION_WATCHDOG_TIMER */ +#define CHARGE_WATCHDOG_DISABLE (0 << 13) +#define CHARGE_WATCHDOG_44SEC (1 << 13) +#define CHARGE_WATCHDOG_88SEC (2 << 13) +#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13) + +#endif /* __CROS_EC_CHARGER_BQ24707A_H */ + diff --git a/driver/charger/bq24715.c b/driver/charger/bq24715.c index d90b35b021..14779225fc 100644 --- a/driver/charger/bq24715.c +++ b/driver/charger/bq24715.c @@ -6,8 +6,8 @@ */ #include "battery_smart.h" +#include "bq24715.h" #include "charger.h" -#include "charger_bq24715.h" #include "console.h" #include "common.h" #include "util.h" diff --git a/driver/charger/bq24715.h b/driver/charger/bq24715.h new file mode 100644 index 0000000000..1c3df77725 --- /dev/null +++ b/driver/charger/bq24715.h @@ -0,0 +1,130 @@ +/* Copyright (c) 2012 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. + * + * TI bq24715 battery charger driver. + */ + +#ifndef __CROS_EC_CHARGER_BQ24715_H +#define __CROS_EC_CHARGER_BQ24715_H + +/* NOTES: + * If battery is not present keep charge current register (0x14) at 0. + * Max charge voltage (0x15) needs to be programmed before 0x14. + */ + +/* Chip specific registers */ +#define BQ24715_CHARGE_OPTION 0x12 +#define BQ24715_CHARGE_CURRENT 0x14 +#define BQ24715_MAX_CHARGE_VOLTAGE 0x15 +#define BQ24715_MIN_SYSTEM_VOLTAGE 0x3e +#define BQ24715_INPUT_CURRENT 0x3f +#define BQ24715_MANUFACTURER_ID 0xfe +#define BQ24715_DEVICE_ID 0xff + +/* ChargeOption Register - 0x12 */ +#define OPT_LOWPOWER_MASK (1 << 15) +#define OPT_LOWPOWER_DSCHRG_I_MON_ON (0 << 15) +#define OPT_LOWPOWER_DSCHRG_I_MON_OFF (1 << 15) +#define OPT_WATCHDOG_MASK (3 << 13) +#define OPT_WATCHDOG_DISABLE (0 << 13) +#define OPT_WATCHDOG_44SEC (1 << 13) +#define OPT_WATCHDOG_88SEC (2 << 13) +#define OPT_WATCHDOG_175SEC (3 << 13) +#define OPT_SYSOVP_MASK (1 << 12) +#define OPT_SYSOVP_15P1_3SEC_10P1_2SEC (0 << 12) +#define OPT_SYSOVP_17P0_3SEC_11P3_2SEC (1 << 12) +#define OPT_SYSOVP_STATUS_MASK (1 << 11) +#define OPT_SYSOVP_STATUS (1 << 11) +#define OPT_AUDIO_FREQ_LIMIT_MASK (1 << 10) +#define OPT_AUDIO_FREQ_NO_LIMIT (0 << 10) +#define OPT_AUDIO_FREQ_40KHZ_LIMIT (1 << 10) +#define OPT_SWITCH_FREQ_MASK (3 << 8) +#define OPT_SWITCH_FREQ_600KHZ (0 << 8) +#define OPT_SWITCH_FREQ_800KHZ (1 << 8) +#define OPT_SWITCH_FREQ_1MHZ (2 << 8) +#define OPT_SWITCH_FREQ_800KHZ_DUP (3 << 8) +#define OPT_ACOC_MASK (1 << 7) +#define OPT_ACOC_DISABLED (0 << 7) +#define OPT_ACOC_333PCT_IPDM (1 << 7) +#define OPT_LSFET_OCP_MASK (1 << 6) +#define OPT_LSFET_OCP_250MV (0 << 6) +#define OPT_LSFET_OCP_350MV (1 << 6) +#define OPT_LEARN_MASK (1 << 5) +#define OPT_LEARN_DISABLE (0 << 5) +#define OPT_LEARN_ENABLE (1 << 5) +#define OPT_IOUT_MASK (1 << 4) +#define OPT_IOUT_40X (0 << 4) +#define OPT_IOUT_16X (1 << 4) +#define OPT_FIX_IOUT_MASK (1 << 3) +#define OPT_FIX_IOUT_IDPM_EN (0 << 3) +#define OPT_FIX_IOUT_ALWAYS (1 << 3) +#define OPT_LDO_MODE_MASK (1 << 2) +#define OPT_LDO_DISABLE (0 << 2) +#define OPT_LDO_ENABLE (1 << 2) +#define OPT_ODPM_MASK (1 << 1) +#define OPT_ODPM_DISABLE (0 << 1) +#define OPT_ODPM_ENABLE (1 << 1) +#define OPT_CHARGE_INHIBIT_MASK (1 << 0) +#define OPT_CHARGE_ENABLE (0 << 0) +#define OPT_CHARGE_DISABLE (1 << 0) + + +/* ChargeCurrent Register - 0x14 + * The ChargeCurrent register controls a DAC. Therefore + * the below definitions are cummulative. */ +#define CHARGE_I_64MA (1 << 6) +#define CHARGE_I_128MA (1 << 7) +#define CHARGE_I_256MA (1 << 8) +#define CHARGE_I_512MA (1 << 9) +#define CHARGE_I_1024MA (1 << 10) +#define CHARGE_I_2048MA (1 << 11) +#define CHARGE_I_4096MA (1 << 12) +#define CHARGE_I_OFF (0) +#define CHARGE_I_MIN (128) +#define CHARGE_I_MAX (8128) +#define CHARGE_I_STEP (64) + +/* MaxChargeVoltage Register - 0x15 + * The MaxChargeVoltage register controls a DAC. Therefore + * the below definitions are cummulative. */ +#define CHARGE_V_16MV (1 << 4) +#define CHARGE_V_32MV (1 << 5) +#define CHARGE_V_64MV (1 << 6) +#define CHARGE_V_128MV (1 << 7) +#define CHARGE_V_256MV (1 << 8) +#define CHARGE_V_512MV (1 << 9) +#define CHARGE_V_1024MV (1 << 10) +#define CHARGE_V_2048MV (1 << 11) +#define CHARGE_V_4096MV (1 << 12) +#define CHARGE_V_8192MV (1 << 13) +#define CHARGE_V_MIN (4096) +#define CHARGE_V_MAX (0x3ff0) +#define CHARGE_V_STEP (16) + +/* MinSystemVoltage Register - 0x3e + * The MinSystemVoltage register controls a DAC. Therefore + * the below definitions are cummulative. */ +#define MIN_SYS_V_256MV (1 << 8) +#define MIN_SYS_V_512MV (1 << 9) +#define MIN_SYS_V_1024MV (1 << 10) +#define MIN_SYS_V_2048MV (1 << 11) +#define MIN_SYS_V_4096MV (1 << 12) +#define MIN_SYS_V_8192MV (1 << 13) +#define MIN_SYS_V_MIN (4096) + +/* InputCurrent Register - 0x3f + * The InputCurrent register controls a DAC. Therefore + * the below definitions are cummulative. */ +#define INPUT_I_64MA (1 << 6) +#define INPUT_I_128MA (1 << 7) +#define INPUT_I_256MA (1 << 8) +#define INPUT_I_512MA (1 << 9) +#define INPUT_I_1024MA (1 << 10) +#define INPUT_I_2048MA (1 << 11) +#define INPUT_I_4096MA (1 << 12) +#define INPUT_I_MIN (128) +#define INPUT_I_MAX (8064) +#define INPUT_I_STEP (64) + +#endif /* __CROS_EC_CHARGER_BQ24715_H */ diff --git a/driver/charger/bq24725.c b/driver/charger/bq24725.c index 3e418c7216..2265a294b7 100644 --- a/driver/charger/bq24725.c +++ b/driver/charger/bq24725.c @@ -6,8 +6,8 @@ */ #include "battery_smart.h" +#include "bq24725.h" #include "charger.h" -#include "charger_bq24725.h" #include "console.h" #include "common.h" #include "util.h" diff --git a/driver/charger/bq24725.h b/driver/charger/bq24725.h new file mode 100644 index 0000000000..3deb41d125 --- /dev/null +++ b/driver/charger/bq24725.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2012 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. + * + * TI bq24725 battery charger driver. + */ + +#ifndef __CROS_EC_CHARGER_BQ24725_H +#define __CROS_EC_CHARGER_BQ24725_H + +/* Chip specific commands */ +#define BQ24725_CHARGE_OPTION 0x12 +#define BQ24725_INPUT_CURRENT 0x3f +#define BQ24725_MANUFACTURE_ID 0xfe +#define BQ24725_DEVICE_ID 0xff + +/* ChargeOption 0x12 */ +#define OPTION_CHARGE_INHIBIT (1 << 0) +#define OPTION_ACOC_THRESHOLD (3 << 1) +#define OPTION_IOUT_SELECTION (1 << 5) +#define OPTION_LEARN_ENABLE (1 << 6) +#define OPTION_IFAULT_HI_THRESHOLD (3 << 7) +#define OPTION_EMI_FREQ_ENABLE (1 << 9) +#define OPTION_EMI_FREQ_ADJ (1 << 10) +#define OPTION_BAT_DEPLETION_THRESHOLD (3 << 11) +#define OPTION_WATCHDOG_TIMER (3 << 13) +#define OPTION_AOC_DELITCH_TIME (1 << 15) +/* OPTION_ACOC_THRESHOLD */ +#define ACOC_THRESHOLD_DISABLE (0 << 1) +#define ACOC_THRESHOLD_133X (1 << 1) +#define ACOC_THRESHOLD_166X_DEFAULT (2 << 1) +#define ACOC_THRESHOLD_222X (3 << 1) +/* OPTION_IFAULT_HI_THRESHOLD */ +#define IFAULT_THRESHOLD_300MV (0 << 7) +#define IFAULT_THRESHOLD_500MV (1 << 7) +#define IFAULT_THRESHOLD_700MV_DEFAULT (2 << 7) +#define IFAULT_THRESHOLD_900MV (3 << 7) +/* OPTION_BAT_DEPLETION_THRESHOLD */ +#define FALLING_THRESHOLD_5919 (0 << 11) +#define FALLING_THRESHOLD_6265 (1 << 11) +#define FALLING_THRESHOLD_6655 (2 << 11) +#define FALLING_THRESHOLD_7097_DEFAULT (3 << 11) +/* OPTION_WATCHDOG_TIMER */ +#define CHARGE_WATCHDOG_DISABLE (0 << 13) +#define CHARGE_WATCHDOG_44SEC (1 << 13) +#define CHARGE_WATCHDOG_88SEC (2 << 13) +#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13) + +#endif /* __CROS_EC_CHARGER_BQ24725_H */ + diff --git a/driver/charger/bq24738.c b/driver/charger/bq24738.c index 057e71c12f..7bd8e42a02 100644 --- a/driver/charger/bq24738.c +++ b/driver/charger/bq24738.c @@ -6,8 +6,8 @@ */ #include "battery_smart.h" +#include "bq24738.h" #include "charger.h" -#include "charger_bq24738.h" #include "console.h" #include "common.h" #include "util.h" diff --git a/driver/charger/bq24738.h b/driver/charger/bq24738.h new file mode 100644 index 0000000000..402b801a0c --- /dev/null +++ b/driver/charger/bq24738.h @@ -0,0 +1,60 @@ +/* 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. + * + * TI bq24738 battery charger driver. + */ + +#ifndef __CROS_EC_CHARGER_BQ24738_H +#define __CROS_EC_CHARGER_BQ24738_H + +/* Chip specific commands */ +#define BQ24738_CHARGE_OPTION 0x12 +#define BQ24738_INPUT_CURRENT 0x3f +#define BQ24738_MANUFACTURE_ID 0xfe +#define BQ24738_DEVICE_ID 0xff + +/* ChargeOption 0x12 */ +#define OPTION_CHARGE_INHIBIT (1 << 0) +#define OPTION_ACOC_THRESHOLD (1 << 1) +#define OPTION_BOOST_MODE_STATE (1 << 2) +#define OPTION_BOOST_MODE_ENABLE (1 << 3) +#define OPTION_ACDET_STATE (1 << 4) +#define OPTION_IOUT_SELECTION (1 << 5) +#define OPTION_LEARN_ENABLE (1 << 6) +#define OPTION_IFAULT_LOW_THRESHOLD (1 << 7) +#define OPTION_IFAULT_HI_ENABLE (1 << 8) +#define OPTION_EMI_FREQ_ENABLE (1 << 9) +#define OPTION_EMI_FREQ_ADJ (1 << 10) +#define OPTION_BAT_DEPLETION_THRESHOLD (3 << 11) +#define OPTION_WATCHDOG_TIMER (3 << 13) +#define OPTION_ACPRES_DEGLITCH_TIME (1 << 15) + +/* OPTION_ACOC_THRESHOLD */ +#define ACOC_THRESHOLD_DISABLE (0 << 1) +#define ACOC_THRESHOLD_133X (1 << 1) + +/* OPTION_IFAULT_LOW_THRESHOLD */ +#define IFAULT_LOW_135MV_DEFAULT (0 << 7) +#define IFAULT_LOW_230MV (1 << 7) + +/* OPTION_BAT_DEPLETION_THRESHOLD */ +#define FALLING_THRESHOLD_5919 (0 << 11) +#define FALLING_THRESHOLD_6265 (1 << 11) +#define FALLING_THRESHOLD_6655 (2 << 11) +#define FALLING_THRESHOLD_7097_DEFAULT (3 << 11) + +/* OPTION_WATCHDOG_TIMER */ +#define CHARGE_WATCHDOG_DISABLE (0 << 13) +#define CHARGE_WATCHDOG_44SEC (1 << 13) +#define CHARGE_WATCHDOG_88SEC (2 << 13) +#define CHARGE_WATCHDOG_175SEC_DEFAULT (3 << 13) + +/* OPTION_ACPRES_DEGLITCH_TIME */ +#define ACPRES_DEGLITCH_150MS (0 << 15) +#define ACPRES_DEGLITCH_1300MS_DEFAULT (1 << 15) + +/* Discharge battery when on AC power. */ +int charger_discharge_on_ac(int enable); + +#endif /* __CROS_EC_CHARGER_BQ24738_H */ diff --git a/driver/led/lp5562.h b/driver/led/lp5562.h new file mode 100644 index 0000000000..aaa32e5fb0 --- /dev/null +++ b/driver/led/lp5562.h @@ -0,0 +1,76 @@ +/* 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. + * + * TI LP5562 LED driver. + */ + +#ifndef LP5562_H +#define LP5562_H + +#define LP5562_REG_ENABLE 0x00 +#define LP5562_REG_OP_MODE 0x01 +#define LP5562_REG_B_PWM 0x02 +#define LP5562_REG_G_PWM 0x03 +#define LP5562_REG_R_PWM 0x04 +#define LP5562_REG_B_CURRENT 0x05 +#define LP5562_REG_G_CURRENT 0x06 +#define LP5562_REG_R_CURRENT 0x07 +#define LP5562_REG_CONFIG 0x08 +#define LP5562_REG_ENG1_PC 0x09 +#define LP5562_REG_ENG2_PC 0x0a +#define LP5562_REG_ENG3_PC 0x0b +#define LP5562_REG_STATUS 0x0c +#define LP5562_REG_RESET 0x0d +#define LP5562_REG_W_PWM 0x0e +#define LP5562_REG_W_CURRENT 0x0f +#define LP5562_REG_LED_MAP 0x70 + +#define LP5562_REG_ENG_PROG(n) (0x10 + ((n)-1) * 0x20) + +/* Brightness range: 0x00 - 0xff */ +#define LP5562_COLOR_NONE 0x000000 +#define LP5562_COLOR_RED(b) (0x010000 * (b)) +#define LP5562_COLOR_GREEN(b) (0x000100 * (b)) +#define LP5562_COLOR_BLUE(b) (0x000001 * (b)) + +#define LP5562_ENG_SEL_NONE 0x0 +#define LP5562_ENG_SEL_1 0x1 +#define LP5562_ENG_SEL_2 0x2 +#define LP5562_ENG_SEL_3 0x3 + +#define LP5562_ENG_HOLD 0x0 +#define LP5562_ENG_STEP 0x1 +#define LP5562_ENG_RUN 0x2 + +/* Power on and initialize LP5562. */ +int lp5562_poweron(void); + +/* Power off LP5562. */ +int lp5562_poweroff(void); + +/* + * Set LED color. + * The parameter 'rgb' is in the format 0x00RRGGBB. + */ +int lp5562_set_color(uint32_t rgb); + +/* Set lighting engine used by each color */ +int lp5562_set_engine(uint8_t r, uint8_t g, uint8_t b); + +/* Load lighting engine program */ +int lp5562_engine_load(int engine, const uint8_t *program, int size); + +/* Control lighting engine execution state */ +int lp5562_engine_control(int eng1, int eng2, int eng3); + +/* Get engine execution state. Return 0xee on error. */ +int lp5562_get_engine_state(int engine); + +/* Get current program counter. Return 0xee on error. */ +int lp5562_get_pc(int engine); + +/* Set program counter */ +int lp5562_set_pc(int engine, int val); + +#endif /* LP5562_H */ diff --git a/driver/temp_sensor/g781.c b/driver/temp_sensor/g781.c index 389b12629e..a28bce8de8 100644 --- a/driver/temp_sensor/g781.c +++ b/driver/temp_sensor/g781.c @@ -7,10 +7,10 @@ #include "common.h" #include "console.h" +#include "g781.h" #include "gpio.h" #include "i2c.h" #include "hooks.h" -#include "temp_sensor_g781.h" #include "util.h" static int g781_temp_val_local; diff --git a/driver/temp_sensor/g781.h b/driver/temp_sensor/g781.h new file mode 100644 index 0000000000..6463155659 --- /dev/null +++ b/driver/temp_sensor/g781.h @@ -0,0 +1,70 @@ +/* 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. + */ + +/* G781 temperature sensor module for Chrome EC */ + +#ifndef __CROS_EC_TEMP_SENSOR_G781_H +#define __CROS_EC_TEMP_SENSOR_G781_H + +#define G781_I2C_ADDR 0x98 /* 7-bit address is 0x4C */ + +#define G781_IDX_INTERNAL 0 +#define G781_IDX_EXTERNAL 1 + +/* Chip-specific commands */ +#define G781_TEMP_LOCAL 0x00 +#define G781_TEMP_REMOTE 0x01 +#define G781_STATUS 0x02 +#define G781_CONFIGURATION_R 0x03 +#define G781_CONVERSION_RATE_R 0x04 +#define G781_LOCAL_TEMP_HIGH_LIMIT_R 0x05 +#define G781_LOCAL_TEMP_LOW_LIMIT_R 0x06 +#define G781_REMOTE_TEMP_HIGH_LIMIT_R 0x07 +#define G781_REMOTE_TEMP_LOW_LIMIT_R 0x08 +#define G781_CONFIGURATION_W 0x09 +#define G781_CONVERSION_RATE_W 0x0a +#define G781_LOCAL_TEMP_HIGH_LIMIT_W 0x0b +#define G781_LOCAL_TEMP_LOW_LIMIT_W 0x0c +#define G781_REMOTE_TEMP_HIGH_LIMIT_W 0x0d +#define G781_REMOTE_TEMP_LOW_LIMIT_W 0x0e +#define G781_ONESHOT 0x0f +#define G781_REMOTE_TEMP_EXTENDED 0x10 +#define G781_REMOTE_TEMP_OFFSET_HIGH 0x11 +#define G781_REMOTE_TEMP_OFFSET_EXTD 0x12 +#define G781_REMOTE_T_HIGH_LIMIT_EXTD 0x13 +#define G781_REMOTE_T_LOW_LIMIT_EXTD 0x14 +#define G781_REMOTE_TEMP_THERM_LIMIT 0x19 +#define G781_LOCAL_TEMP_THERM_LIMIT 0x20 +#define G781_THERM_HYSTERESIS 0x21 +#define G781_ALERT_FAULT_QUEUE_CODE 0x22 +#define G781_MANUFACTURER_ID 0xFE +#define G781_DEVICE_ID 0xFF + +/* Config register bits */ +#define G781_CONFIGURATION_STANDBY (1 << 6) +#define G781_CONFIGURATION_ALERT_MASK (1 << 7) + +/* Status register bits */ +#define G781_STATUS_LOCAL_TEMP_THERM_ALARM (1 << 0) +#define G781_STATUS_REMOTE_TEMP_THERM_ALARM (1 << 1) +#define G781_STATUS_REMOTE_TEMP_FAULT (1 << 2) +#define G781_STATUS_REMOTE_TEMP_LOW_ALARM (1 << 3) +#define G781_STATUS_REMOTE_TEMP_HIGH_ALARM (1 << 4) +#define G781_STATUS_LOCAL_TEMP_LOW_ALARM (1 << 5) +#define G781_STATUS_LOCAL_TEMP_HIGH_ALARM (1 << 6) +#define G781_STATUS_BUSY (1 << 7) + +/** + * 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 g781_get_val(int idx, int *temp_ptr); + +#endif /* __CROS_EC_TEMP_SENSOR_G781_H */ diff --git a/driver/temp_sensor/tmp006.h b/driver/temp_sensor/tmp006.h new file mode 100644 index 0000000000..78f8e0044a --- /dev/null +++ b/driver/temp_sensor/tmp006.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2012 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. + */ + +/* TMP006 temperature sensor module for Chrome EC */ + +#ifndef __CROS_EC_TMP006_H +#define __CROS_EC_TMP006_H + +#define TMP006_ADDR(PORT,REG) ((PORT << 16) + REG) +#define TMP006_PORT(ADDR) (ADDR >> 16) +#define TMP006_REG(ADDR) (ADDR & 0xffff) + +struct tmp006_t { + const char* name; + int addr; /* I2C address formed by TMP006_ADDR macro. */ +}; + +/** + * Get the last polled value of a sensor. + * + * @param idx Index to read. The low bit in idx indicates whether + * to read die temperature or object temperature. The + * other bits serve as internal index to tmp006 module. + * @param temp_ptr Destination for temperature in K. + * + * @return EC_SUCCESS if successful, non-zero if error. + */ +int tmp006_get_val(int idx, int *temp_ptr); + +#endif /* __CROS_EC_TMP006_H */ diff --git a/driver/tsu6721.h b/driver/tsu6721.h new file mode 100644 index 0000000000..e614be7e09 --- /dev/null +++ b/driver/tsu6721.h @@ -0,0 +1,111 @@ +/* Copyright (c) 2012 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. + * + * TI TSU6721 USB port switch. + */ + +#ifndef TSU6721_H +#define TSU6721_H + +#define TSU6721_REG_DEV_ID 0x01 +#define TSU6721_REG_CONTROL 0x02 +#define TSU6721_REG_INT1 0x03 +#define TSU6721_REG_INT2 0x04 +#define TSU6721_REG_INT_MASK1 0x05 +#define TSU6721_REG_INT_MASK2 0x06 +#define TSU6721_REG_ADC 0x07 +#define TSU6721_REG_TIMING1 0x08 +#define TSU6721_REG_TIMING2 0x09 +#define TSU6721_REG_DEV_TYPE1 0x0A +#define TSU6721_REG_DEV_TYPE2 0x0B +#define TSU6721_REG_BUTTON1 0x0C +#define TSU6721_REG_BUTTON2 0x0D +#define TSU6721_REG_MANUAL1 0x13 +#define TSU6721_REG_MANUAL2 0x14 +#define TSU6721_REG_DEV_TYPE3 0x15 +#define TSU6721_REG_RESET 0x1B +#define TSU6721_REG_TIMER 0x20 +#define TSU6721_REG_OCP1 0x21 +#define TSU6721_REG_OCP2 0x22 + +#define TSU6721_CTRL_AUTO (1 << 2) + +enum tsu6721_mux { + TSU6721_MUX_AUTO = 0x00, + TSU6721_MUX_USB = 0x24, + TSU6721_MUX_AUDIO = 0x48, + TSU6721_MUX_UART = 0x6C, +}; + +#define TSU6721_INT_ATTACH 0x0001 +#define TSU6721_INT_DETACH 0x0002 +#define TSU6721_INT_KP 0x0004 +#define TSU6721_INT_LKP 0x0008 +#define TSU6721_INT_LKR 0x0010 +#define TSU6721_INT_OVP_EN 0x0020 +#define TSU6721_INT_OCP_EN 0x0040 +#define TSU6721_INT_OVP_OCP_OTP_DIS 0x0080 +#define TSU6721_INT_AV_CHANGE 0x0100 +#define TSU6721_INT_RES_ATTACH 0x0200 +#define TSU6721_INT_ADC_CHANGE 0x0400 +#define TSU6721_INT_STUCK_KEY 0x0800 +#define TSU6721_INT_STUCK_KEY_RCV 0x1000 +#define TSU6721_INT_CONNECT 0x2000 +#define TSU6721_INT_OTP_EN 0x4000 +#define TSU6721_INT_VBUS 0x8000 + +#define TSU6721_TYPE_NONE 0x000000 +#define TSU6721_TYPE_OTG 0x000080 +#define TSU6721_TYPE_DCP 0x000040 +#define TSU6721_TYPE_CDP 0x000020 +#define TSU6721_TYPE_CHG12 0x000010 +#define TSU6721_TYPE_UART 0x000008 +#define TSU6721_TYPE_USB_HOST 0x000004 +#define TSU6721_TYPE_AUDIO2 0x000002 +#define TSU6721_TYPE_AUDIO1 0x000001 +#define TSU6721_TYPE_AUDIO3 0x008000 +#define TSU6721_TYPE_JIG_UART_ON 0x000400 +#define TSU6721_TYPE_U200_CHG 0x400000 +#define TSU6721_TYPE_APPLE_CHG 0x200000 +#define TSU6721_TYPE_NON_STD_CHG 0x040000 +/* VBUS_DEBOUNCED might show up together with other type */ +#define TSU6721_TYPE_VBUS_DEBOUNCED 0x020000 + +/* Initialize TSU6721. */ +int tsu6721_init(void); + +/* Read TSU6721 register. */ +uint8_t tsu6721_read(uint8_t reg); + +/* Write TSU6721 register. */ +int tsu6721_write(uint8_t reg, uint8_t val); + +/* Enable interrupts. */ +int tsu6721_enable_interrupts(void); + +/* Disable all interrupts. */ +int tsu6721_disable_interrupts(void); + +/* Set interrupt mask. */ +int tsu6721_set_interrupt_mask(uint16_t mask); + +/* Get and clear current interrupt status. Return value is a combination of + * TSU6721_INT_* */ +int tsu6721_get_interrupts(void); + +/* Get but keep interrupt status. Return value is a combination of + * TSU6721_INT_* */ +int tsu6721_peek_interrupts(void); + +/* Get attached device type. Return value is one or a combination of + * TSU6721_TYPE_* */ +int tsu6721_get_device_type(void); + +/* Control TSU6721 mux. */ +int tsu6721_mux(enum tsu6721_mux sel); + +/* Reset TSU6721. */ +void tsu6721_reset(void); + +#endif /* TSU6721_H */ |