From 1b14b2c922808ac1f7084f301d54173ca0074bf7 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Mon, 24 Sep 2012 17:07:19 +0800 Subject: stm32f: ADC driver This adds basic ADC support for multiple channel conversion. BUG=chrome-os-partner:14316 BRANCH=none TEST=1. Boot on snow. 2. Use keyboard signal as input. Check read value changes as input signal changes. Change-Id: I3c15c37446fa9273d098f6d581573c11ced45b5e Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/33883 Reviewed-by: Vincent Palatin --- board/spring/board.c | 12 ++++++++++++ board/spring/board.h | 10 ++++++++++ 2 files changed, 22 insertions(+) (limited to 'board/spring') diff --git a/board/spring/board.c b/board/spring/board.c index 10d7eb2f1c..9b52f48552 100644 --- a/board/spring/board.c +++ b/board/spring/board.c @@ -4,6 +4,7 @@ */ /* Spring board-specific configuration */ +#include "adc.h" #include "board.h" #include "chipset.h" #include "common.h" @@ -14,6 +15,7 @@ #include "i2c.h" #include "pmu_tpschrome.h" #include "registers.h" +#include "stm32_adc.h" #include "timer.h" #include "util.h" @@ -95,6 +97,16 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"ILIM_500", GPIO_B, (1<<4), GPIO_OUT_LOW, NULL}, }; +/* ADC channels */ +const struct adc_t adc_channels[ADC_CH_COUNT] = { + /* Micro USB ID pin. Raw ADC value. */ + [ADC_CH_USB_ID] = {"USB_ID", 0, 1, 1, 0, STM32_AIN(5), 0}, + /* Micro USB D+ sense pin. Raw ADC value. */ + [ADC_CH_USB_DP_SNS] = {"USB_DP_SNS", 0, 1, 1, 0, STM32_AIN(2), 0}, + /* Micro USB D- sense pin. Raw ADC value. */ + [ADC_CH_USB_DN_SNS] = {"USB_DN_SNS", 0, 1, 1, 0, STM32_AIN(4), 0}, +}; + void configure_board(void) { uint32_t val; diff --git a/board/spring/board.h b/board/spring/board.h index 8acd4fc187..b8ec6ab2ea 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -55,6 +55,16 @@ /* Battery */ #define CONFIG_BATTERY_BQ20Z453 +/* ADC signal */ +#define CONFIG_ADC +enum adc_channel { + ADC_CH_USB_ID = 0, + ADC_CH_USB_DP_SNS, + ADC_CH_USB_DN_SNS, + + ADC_CH_COUNT +}; + /* GPIO signal list */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ -- cgit v1.2.1