summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRong Chang <rongchang@chromium.org>2015-05-25 10:37:26 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-10 15:49:19 +0000
commit63a9dc19b580d9a3ec2bc4f73c76b6a016b8802f (patch)
treef92e91cac27f9307cc031952176e7b5bcfd462f9
parenta585141db0d8012be637919d081e7fabbcd644ff (diff)
downloadchrome-ec-63a9dc19b580d9a3ec2bc4f73c76b6a016b8802f.tar.gz
oak: Modify GPIO list for rev 1.5 boards
Rev 1.5 hardware redefined EC and PD phy IO controls. This change adds macro to map configurations at compile time. BRANCH=none BUG=none TEST=manual build and flash ec.bin plug type-c charger on port 0 Change-Id: I60c2f1448fbdea9bb72d1f3b19de366cad150087 Signed-off-by: Rong Chang <rongchang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/274771 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--board/oak/board.c17
-rw-r--r--board/oak/board.h27
-rw-r--r--board/oak/gpio.inc22
-rw-r--r--board/oak_pd/board.h4
-rw-r--r--board/oak_pd/gpio.inc7
-rw-r--r--board/oak_pd/usb_pd_config.h59
6 files changed, 104 insertions, 32 deletions
diff --git a/board/oak/board.c b/board/oak/board.c
index b902265b62..77a1d4c3b9 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -5,6 +5,7 @@
/* Oak board configuration */
+#include "adc_chip.h"
#include "battery.h"
#include "charger.h"
#include "chipset.h"
@@ -17,6 +18,7 @@
#include "i2c.h"
#include "keyboard_raw.h"
#include "lid_switch.h"
+#include "pi3usb30532.h"
#include "power.h"
#include "power_button.h"
#include "registers.h"
@@ -66,9 +68,22 @@ const struct power_signal_info power_signal_list[] = {
{GPIO_SOC_POWER_GOOD, 1, "POWER_GOOD"}, /* Active high */
{GPIO_SUSPEND_L, 0, "SUSPEND#_ASSERTED"}, /* Active low */
};
-
BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ /* VDC_BOOSTIN_SENSE(PC1): ADC_IN11, output in mV */
+ [ADC_VBUS] = {"VBUS", 33000, 4096, 0, STM32_AIN(11)},
+ /*
+ * PSYS_MONITOR(PA2): ADC_IN2, 1.44 uA/W on 6.05k Ohm
+ * output in mW
+ */
+ [ADC_PSYS] = {"PSYS", 379415, 4096, 0, STM32_AIN(2)},
+ /* AMON_BMON(PC0): ADC_IN10, output in uV */
+ [ADC_AMON_BMON] = {"AMON_BMON", 183333, 4096, 0, STM32_AIN(10)},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
{"battery", I2C_PORT_BATTERY, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA},
diff --git a/board/oak/board.h b/board/oak/board.h
index 6f6a1ee2ee..ced0b44075 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -8,15 +8,31 @@
#ifndef __BOARD_H
#define __BOARD_H
+/* Board revision */
+#undef CONFIG_BOARD_OAK_REV_1
+#define CONFIG_BOARD_OAK_REV_1_5
+#undef CONFIG_BOARD_OAK_REV_2
+
+#define CONFIG_ADC
+#undef CONFIG_ADC_WATCHDOG
/* Add for AC adaptor, charger, battery */
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_SMART
#define CONFIG_CHARGER
+
+#ifdef CONFIG_BOARD_OAK_REV_1
#define CONFIG_CHARGER_BQ24773
-#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 2150
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#else
+#define CONFIG_CHARGER_ISL9237
+#define CONFIG_CHARGER_INPUT_CURRENT 2250
+#define CONFIG_CHARGER_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
+#endif /* CONFIG_BOARD_OAK_REV_1 */
+
+#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_V2
#define CONFIG_CHIPSET_MEDIATEK
#define CONFIG_FORCE_CONSOLE_RESUME
@@ -72,6 +88,11 @@
* port 1: 0x55 << 1
*/
#define CONFIG_USB_SWITCH_I2C_ADDRS {0x54 << 1, 0x55 << 1}
+/* BC 1.2 charger */
+#define CONFIG_USB_SWITCH_PI3USB30532
+#define CONFIG_USB_SWITCH_PI3USB9281
+#undef CONFIG_USB_SWITCH_PI3USB9281_MUX_GPIO
+#define CONFIG_USB_SWITCH_PI3USB9281_MUX_GPIO GPIO_USB_C_BC12_SEL
#ifndef __ASSEMBLER__
@@ -82,6 +103,7 @@
#define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C, GPIO_D
/* 2 I2C master ports, connect to battery, charger, pd and USB switches */
+#define I2C_PORT_MASTER 0
#define I2C_PORT_BATTERY 0
#define I2C_PORT_CHARGER 0
#define I2C_PORT_PD_MCU 1
@@ -108,6 +130,9 @@ enum pwm_channel {
};
enum adc_channel {
+ ADC_VBUS = 0,
+ ADC_PSYS,
+ ADC_AMON_BMON,
ADC_CH_COUNT
};
diff --git a/board/oak/gpio.inc b/board/oak/gpio.inc
index 478ea660d2..849c970b6c 100644
--- a/board/oak/gpio.inc
+++ b/board/oak/gpio.inc
@@ -30,6 +30,7 @@ GPIO_INT(KB_IN07, PIN(D, 2), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt)
GPIO(5V_POWER_GOOD, PIN(A, 1), GPIO_INPUT)
GPIO(EC_WAKE, PIN(A, 0), GPIO_INPUT|GPIO_PULL_DOWN)
GPIO(WP_L, PIN(B, 4), GPIO_INPUT) /* Write protect input */
+GPIO(BATT_TH, PIN(E, 3), GPIO_INPUT|GPIO_PULL_UP)
/* Board version */
GPIO(BOARD_VERSION1, PIN(E, 10), GPIO_INPUT|GPIO_PULL_UP) /* Board ID 0 */
@@ -55,7 +56,12 @@ GPIO(KB_OUT08, PIN(C, 2), GPIO_KB_OUTPUT)
GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT)
GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT)
GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT)
+#ifdef CONFIG_BOARD_OAK_REV_1
GPIO(KB_OUT12, PIN(A, 13), GPIO_KB_OUTPUT)
+#else
+GPIO(KB_OUT12, PIN(D, 5), GPIO_KB_OUTPUT)
+#endif /* CONFIG_BOARD_OAK_REV_1 */
+
GPIO(SYSTEM_POWER_H, PIN(B, 10), GPIO_OUT_LOW)
GPIO(PMIC_PWRON_H, PIN(A, 12), GPIO_OUT_LOW)
GPIO(PMIC_WARM_RESET_H, PIN(B, 3), GPIO_OUT_LOW)
@@ -67,6 +73,19 @@ GPIO(USB_C1_5V_OUT, PIN(D, 10), GPIO_OUT_LOW) /* USBC port 1 5V */
GPIO(USB_C1_CHARGE_L, PIN(D, 11), GPIO_OUT_HIGH) /* USBC port 1 charge */
GPIO(USB_PD_VBUS_WAKE, PIN(B, 15), GPIO_OUT_LOW) /* PD VBUS wake */
GPIO(USB_DP_HPD, PIN(F, 3), GPIO_OUT_LOW)
+GPIO(DP_MUX_ENABLE, PIN(E, 6), GPIO_OUT_HIGH)
+GPIO(DP_SWITCH_CTL, PIN(E, 5), GPIO_OUT_LOW)
+
+#ifdef CONFIG_BOARD_OAK_REV_1
+GPIO(USB_C_BC12_SEL, PIN(A, 14), GPIO_OUT_LOW)
+#else
+GPIO(USB_C_BC12_SEL, PIN(D, 7), GPIO_OUT_LOW)
+#endif /* CONFIG_BOARD_OAK_REV_1 */
+
+/* Analog pins */
+GPIO(VDC_BOOSTIN_SENSE, PIN(C, 1), GPIO_ANALOG) /* ADC_IN11 */
+GPIO(PSYS_MONITOR, PIN(A, 2), GPIO_ANALOG) /* ADC_IN2 */
+GPIO(AMON_BMON, PIN(C, 0), GPIO_ANALOG) /* ADC_IN10 */
/*
* I2C pins should be configured as inputs until I2C module is
@@ -77,9 +96,6 @@ GPIO(I2C0_SDA, PIN(B, 7), GPIO_INPUT)
GPIO(I2C1_SCL, PIN(B, 13), GPIO_INPUT) /* PD I2C */
GPIO(I2C1_SDA, PIN(B, 14), GPIO_INPUT)
-/* Unimplemented signals which we need to emulate for now */
-UNIMPLEMENTED(NONE)
-
ALTERNATE(PIN_MASK(A, 0x0600), 1, MODULE_UART, 0) /* USART1: PA9/PA10 */
ALTERNATE(PIN_MASK(B, 0x00c0), 1, MODULE_I2C, 0) /* I2C MASTER:PB6/7 */
ALTERNATE(PIN_MASK(B, 0x6000), 5, MODULE_I2C, 0) /* I2C MASTER:PB13/14 */
diff --git a/board/oak_pd/board.h b/board/oak_pd/board.h
index ac3d6eae64..07e763057a 100644
--- a/board/oak_pd/board.h
+++ b/board/oak_pd/board.h
@@ -8,6 +8,10 @@
#ifndef __BOARD_H
#define __BOARD_H
+#undef CONFIG_BOARD_OAK_REV_1
+#define CONFIG_BOARD_OAK_REV_1_5
+#undef CONFIG_BOARD_OAK_REV_2
+
/*
* The flash size is only 32kB.
* No space for 2 partitions,
diff --git a/board/oak_pd/gpio.inc b/board/oak_pd/gpio.inc
index 542f887f35..9547f57bba 100644
--- a/board/oak_pd/gpio.inc
+++ b/board/oak_pd/gpio.inc
@@ -42,9 +42,12 @@ GPIO(USB_C1_CC2_ODL, PIN(A, 8), GPIO_ODR_LOW)
GPIO(SLAVE_I2C_SCL, PIN(B, 6), GPIO_INPUT)
GPIO(SLAVE_I2C_SDA, PIN(B, 7), GPIO_INPUT)
-/* Case closed debugging. */
+#ifdef CONFIG_OAK_BOARD_REV_1
GPIO(EC_INT, PIN(A, 14), GPIO_OUT_HIGH)
-GPIO(TP_194, PIN(B, 5), GPIO_OUT_LOW)
+#else
+GPIO(EC_INT, PIN(B, 5), GPIO_OUT_HIGH)
+#endif
+
UNIMPLEMENTED(WP_L)
UNIMPLEMENTED(ENTERING_RW)
diff --git a/board/oak_pd/usb_pd_config.h b/board/oak_pd/usb_pd_config.h
index 2f91727cb8..d704e2a8ae 100644
--- a/board/oak_pd/usb_pd_config.h
+++ b/board/oak_pd/usb_pd_config.h
@@ -95,7 +95,7 @@ static inline void pd_set_pins_speed(int port)
STM32_GPIO_OSPEEDR(GPIO_B) |= 0x00030000;
} else {
/* 40 MHz pin speed on SPI PB13/14,
- * (USB_C1_TX_CLKIN & USB_C1_CC1_TX_DATA)
+ * (USB_C1_TX_CLKIN & USB_C1_CCX_TX_DATA)
*/
STM32_GPIO_OSPEEDR(GPIO_B) |= 0x3C000000;
/* 40 MHz pin speed on TIM15_CH2 (PB15) */
@@ -143,7 +143,19 @@ static inline void pd_tx_enable(int port, int polarity)
/* put SPI function on TX pin */
/* USB_C1_CCX_TX_DATA: PB14 is SPI1 MISO */
gpio_set_alternate_function(GPIO_B, 0x4000, 0);
- /* TODO: MCU ADC pin output low */
+ /* MCU ADC pin output low */
+ if (polarity) {
+ STM32_GPIO_MODER(GPIO_A) = (STM32_GPIO_MODER(GPIO_A)
+ & ~(3 << (2*5))) /* PA5 disable ADC */
+ | (1 << (2*5)); /* Set as GPO */
+ gpio_set_level(GPIO_USB_C1_CC2_PD, 0);
+ } else {
+ STM32_GPIO_MODER(GPIO_A) = (STM32_GPIO_MODER(GPIO_A)
+ & ~(3 << (2*0))) /* PA0 disable ADC */
+ | (1 << (2*0)); /* Set as GPO */
+ gpio_set_level(GPIO_USB_C1_CC1_PD, 0);
+ }
+
/*
* There is a pin muxer to select CC1 or CC2 TX_DATA,
* Pin mux is controlled by USB_C1_CC2_TX_SEL pin,
@@ -158,37 +170,32 @@ static inline void pd_tx_enable(int port, int polarity)
static inline void pd_tx_disable(int port, int polarity)
{
if (port == 0) {
- /* output low on SPI TX to disable the FET */
if (polarity) {/* PA6 is SPI1 MISO */
- gpio_set_alternate_function(GPIO_A, 0x0040, -1);
- /* TODO: Set MCU ADC PA4 pin to ADC function (Hi-Z) */
+ /* set ADC PA4 pin to ADC function (Hi-Z) */
STM32_GPIO_MODER(GPIO_A) = (STM32_GPIO_MODER(GPIO_A)
| (3 << (2*4))) /* PA4 as ADC */
& ~(1 << (2*4)); /* disable GPO */
+ gpio_set_alternate_function(GPIO_A, 0x0040, -1);
} else {/* PB4 is SPI1 MISO */
- gpio_set_alternate_function(GPIO_B, 0x0010, -1);
- /* put the low level reference in Hi-Z */
- /* TODO: Set MCU ADC PA2 pin to ADC function (Hi-Z) */
+ /* set ADC PA4 pin to ADC function (Hi-Z) */
STM32_GPIO_MODER(GPIO_A) = (STM32_GPIO_MODER(GPIO_A)
- | (3 << (2*2))) /* PA2 disable ADC */
- & ~(1 << (2*2)); /* Set as GPO */
+ | (3 << (2*2))) /* PA2 as ADC */
+ & ~(1 << (2*2)); /* disable GPO */
+ gpio_set_alternate_function(GPIO_B, 0x0010, -1);
}
} else {
- /* Select the pin according to the polarity */
- gpio_set_level(GPIO_USB_C1_CC2_TX_SEL, polarity);
- /* output low on SPI TX to disable the FET */
- /* PB14 is SPI2 MISO */
- STM32_GPIO_MODER(GPIO_B) = (STM32_GPIO_MODER(GPIO_B)
- & ~(3 << (2*14))) /* Pin14 disable ADC */
- | (1 << (2*14)); /* Set as GPO */
- /* 00: Input mode (reset state)
- * 01: General purpose output mode
- * 10: Alternate function mode
- * 11: Analog mode
- */
-
- /* put the low level reference in Hi-Z */
- /* TODO: Set MCU ADC pin to ADC function (Hi-Z) */
+ if (polarity) {
+ /* set ADC PA4 pin to ADC function (Hi-Z) */
+ STM32_GPIO_MODER(GPIO_A) = (STM32_GPIO_MODER(GPIO_A)
+ | (3 << (2*5))) /* PA5 as ADC */
+ & ~(1 << (2*5)); /* disable GPO */
+ } else {
+ /* set ADC PA4 pin to ADC function (Hi-Z) */
+ STM32_GPIO_MODER(GPIO_A) = (STM32_GPIO_MODER(GPIO_A)
+ | (3 << (2*0))) /* PA0 as ADC */
+ & ~(1 << (2*0)); /* disable GPO */
+ }
+ gpio_set_alternate_function(GPIO_B, 0x4000, -1);
}
}
@@ -246,6 +253,7 @@ static inline void pd_set_host_mode(int port, int enable)
/* High-Z is used for host mode. */
gpio_set_level(GPIO_USB_C1_CC1_ODL, 1);
gpio_set_level(GPIO_USB_C1_CC2_ODL, 1);
+ /* Set TX Hi-Z */
gpio_set_flags(GPIO_USB_C1_CCX_TX_DATA, GPIO_INPUT);
} else {
/* Set HOST_HIGH to High-Z for device mode. */
@@ -314,3 +322,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable)
}
#endif /* __USB_PD_CONFIG_H */
+