summaryrefslogtreecommitdiff
path: root/board/kunimitsu
diff options
context:
space:
mode:
authorKyoung Kim <kyoung.il.kim@intel.com>2016-01-20 11:40:50 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-01-22 09:57:07 -0800
commit0e8928920c0ec8b00da6da477ee719671046bb31 (patch)
tree66c3170aff0bb96e394ae1ef679c13b382a18959 /board/kunimitsu
parent09a1fee89210ddea70c0935b3d2eea232b7ca28e (diff)
downloadchrome-ec-0e8928920c0ec8b00da6da477ee719671046bb31.tar.gz
Kunimitsu: Fix leak on pin for battery_present.
Since battery pin 5 is the voltage across internal 10Kohm thermistor and is not either 0V or 3.3V, typically 330mV with external 100Kohm. Using GPIO configuration to detect this pin causes extra power consumption and this pin is reconfigured as ADC. BUG=cros-bug-49610 BRANCH=glados TEST=check if battery is detected. Use 'adc' console command and check if it shows 'BATTPRES' with volatage in mV. Change-Id: I907b94629b0581a6a27e6f0cecda12ddef09a4f0 Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com> Reviewed-on: https://chromium-review.googlesource.com/322771 Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com> Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board/kunimitsu')
-rw-r--r--board/kunimitsu/board.c25
-rw-r--r--board/kunimitsu/board.h3
-rw-r--r--board/kunimitsu/gpio.inc10
3 files changed, 32 insertions, 6 deletions
diff --git a/board/kunimitsu/board.c b/board/kunimitsu/board.c
index 2a899c3392..5a8b9eef07 100644
--- a/board/kunimitsu/board.c
+++ b/board/kunimitsu/board.c
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
/* Skylake Chrome Reference Design board-specific configuration */
-
+#include "adc.h"
#include "adc_chip.h"
#include "als.h"
+#include "battery.h"
#include "button.h"
#include "charge_manager.h"
#include "charge_state.h"
@@ -100,6 +101,8 @@ BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
/* ADC channels */
const struct adc_t adc_channels[] = {
+ /* read voltage in battery thermistor as battery present */
+ [ADC_BATT_PRESENT] = {"BATTPRES", 3300, 1024, 0, 0},
/* Vbus sensing. Converted to mV, full ADC is equivalent to 30V. */
[ADC_VBUS] = {"VBUS", 30000, 1024, 0, 1},
/* Adapter current output or battery discharging current */
@@ -628,3 +631,23 @@ static void board_handle_reboot(void)
; /* wait here */
}
DECLARE_HOOK(HOOK_INIT, board_handle_reboot, HOOK_PRIO_FIRST);
+
+#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
+/*
+ * Physical detection of battery via ADC.
+ *
+ * Uppper limit of valid voltage level(mV), when battery is attached to ADC port,
+ * is across the internal thermistor with external pullup resistor.
+ */
+#define BATT_PRESENT_MV 1500
+enum battery_present battery_is_present(void)
+{
+ /*
+ * if voltage is below certain level(dependant on ratio of
+ * internal thermistor and external pullup resister),
+ * battery is attached.
+ */
+ return (adc_read_channel(ADC_BATT_PRESENT) > BATT_PRESENT_MV) ?
+ BP_NO : BP_YES;
+}
+#endif
diff --git a/board/kunimitsu/board.h b/board/kunimitsu/board.h
index 1eb1e3bdb0..4db8382b9f 100644
--- a/board/kunimitsu/board.h
+++ b/board/kunimitsu/board.h
@@ -11,7 +11,7 @@
/* Optional features */
#define CONFIG_ADC
#define CONFIG_BATTERY_CUT_OFF
-#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
+#define CONFIG_BATTERY_PRESENT_CUSTOM
#define CONFIG_BATTERY_SMART
#define CONFIG_BOARD_VERSION
#define CONFIG_BUTTON_COUNT 2
@@ -158,6 +158,7 @@
/* ADC signal */
enum adc_channel {
+ ADC_BATT_PRESENT,
ADC_VBUS,
ADC_AMON_BMON,
ADC_PSYS,
diff --git a/board/kunimitsu/gpio.inc b/board/kunimitsu/gpio.inc
index b62aa978ea..f063f4b515 100644
--- a/board/kunimitsu/gpio.inc
+++ b/board/kunimitsu/gpio.inc
@@ -54,7 +54,6 @@ GPIO(USB_C0_DP_HPD, PIN(46), GPIO_OUT_LOW)
GPIO(USB_C1_DP_HPD, PIN(51), GPIO_OUT_LOW)
GPIO(CPU_PROCHOT, PIN(52), GPIO_OUT_LOW)
GPIO(ENABLE_TOUCHPAD, PIN(53), GPIO_OUT_LOW)
-GPIO(BAT_PRESENT_L, PIN(56), GPIO_INPUT)
GPIO(USB_PD_WAKE, PIN(60), GPIO_OUT_LOW)
/* When asserted, ME does not lock security descriptor */
GPIO(PCH_SEC_DISABLE_L, PIN(65), GPIO_ODR_HIGH)
@@ -145,9 +144,12 @@ ALTERNATE(PIN_MASK(2, 0x3f), 2, MODULE_I2C, GPIO_ODR_HIGH)
/* I2C0_1 CLK - GPIO134 */
ALTERNATE(PIN_MASK(13, 0x10), 2, MODULE_I2C, GPIO_ODR_HIGH)
-/* ADC pins */
-/* ADC1 - GPIO057 / PPVAR_BOOSTIN_SENSE */
-ALTERNATE(PIN_MASK(5, 0x80), 1, MODULE_ADC, GPIO_ANALOG)
+/*
+ * ADC pins
+ * ADC0 - GPIO056 / EC_BATT_TMP/BATT_BAT_PRESENT_L
+ * ADC1 - GPIO057 / PPVAR_BOOSTIN_SENSE
+ */
+ALTERNATE(PIN_MASK(5, 0xC0), 1, MODULE_ADC, GPIO_ANALOG)
/* ADC3 - GPIO061 / IADP_ACMON_BMON. ADC4 - GPIO062 / PMON_PSYS */
ALTERNATE(PIN_MASK(6, 0x06), 1, MODULE_ADC, GPIO_ANALOG)