summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-08-03 03:09:57 +0800
committerChromeBot <chrome-bot@google.com>2013-08-04 13:11:09 -0700
commit4f1938f6211ffad804c4cd76e91dc27a1740c5c2 (patch)
treec0c5651ec2002d61becfe86d469d3ed0fe250cb1
parent19e30d9c7d1eed48e94952e5e73fdeb7d703656e (diff)
downloadchrome-ec-4f1938f6211ffad804c4cd76e91dc27a1740c5c2.tar.gz
Add kirby board
GPIO mappings are according to current schematic. Charging and power sequence code need to be fixed. Charging is disabled now, and some power sequence code is #ifdef'd out for kirby to compile. BUG=chrome-os-partner:21607 TEST=Build all boards (including Kirby.) BRANCH=None Change-Id: I3a48a7779dab8aad0d086c41e0be19223cd7d6c9 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64364 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/kirby/board.c122
-rw-r--r--board/kirby/board.h115
-rw-r--r--board/kirby/build.mk13
-rw-r--r--board/kirby/ec.tasklist24
-rw-r--r--common/chipset_gaia.c18
5 files changed, 290 insertions, 2 deletions
diff --git a/board/kirby/board.c b/board/kirby/board.c
new file mode 100644
index 0000000000..f22bebd44f
--- /dev/null
+++ b/board/kirby/board.c
@@ -0,0 +1,122 @@
+/* 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.
+ */
+/* Pit board-specific configuration */
+
+#include "battery_pack.h"
+#include "common.h"
+#include "extpower.h"
+#include "gaia_power.h"
+#include "gpio.h"
+#include "i2c.h"
+#include "keyboard_raw.h"
+#include "lid_switch.h"
+#include "registers.h"
+#include "spi.h"
+#include "task.h"
+#include "util.h"
+
+#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH)
+#define GPIO_KB_OUTPUT GPIO_ODR_HIGH
+
+/* GPIO signal list. Must match order from enum gpio_signal. */
+const struct gpio_info gpio_list[] = {
+ /* Inputs with interrupt handlers are first for efficiency */
+ {"KB_PWR_ON_L", GPIO_A, (1<<0), GPIO_INT_BOTH, gaia_power_event},
+ {"XPSHOLD", GPIO_E, (1<<5), GPIO_INT_RISING, gaia_power_event},
+ {"CHARGER_INT_L", GPIO_E, (1<<2), GPIO_INT_FALLING,
+ NULL /*pmu_irq_handler*/},
+ {"USB_CHG_INT", GPIO_E, (1<<15), GPIO_INT_RISING,
+ NULL /*extpower_interrupt*/},
+ {"USBPD_INT_L", GPIO_E, (1<<1), GPIO_INT_FALLING,
+ NULL /*extpower_interrupt*/},
+ {"LID_OPEN", GPIO_E, (1<<6), GPIO_INT_BOTH, lid_interrupt},
+ {"SUSPEND_L", GPIO_E, (1<<3), GPIO_INT_BOTH, gaia_suspend_event},
+ {"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
+ spi_event},
+ {"AC_PRESENT", GPIO_A, (1<<1), GPIO_INT_BOTH,
+ NULL /*extpower_interrupt*/},
+ {"KB_IN00", GPIO_E, (1<<7), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN01", GPIO_E, (1<<8), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN02", GPIO_E, (1<<9), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN03", GPIO_E, (1<<10), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN04", GPIO_E, (1<<11), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN05", GPIO_E, (1<<12), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN06", GPIO_E, (1<<13), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN07", GPIO_E, (1<<14), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ /* Other inputs */
+ {"WP_L", GPIO_B, (1<<3), GPIO_INPUT, NULL},
+ /* Outputs */
+ {"CHARGER_EN_L", GPIO_B, (1<<8), GPIO_OUT_HIGH, NULL},
+ {"EC_INT", GPIO_C, (1<<9), GPIO_ODR_HIGH, NULL},
+ {"EC_INT2", GPIO_B, (1<<4), GPIO_ODR_HIGH, NULL},
+ {"ID_MUX", GPIO_B, (1<<11), GPIO_ODR_HIGH, NULL},
+ {"BCHGR_OTG", GPIO_B, (1<<12), GPIO_OUT_LOW, NULL},
+ {"BCHGR_PSEL", GPIO_B, (1<<14), GPIO_OUT_HIGH, NULL},
+ {"EN_PP3300", GPIO_C, (1<<11), GPIO_OUT_LOW, NULL},
+ {"ENTERING_RW", GPIO_B, (1<<15), GPIO_OUT_LOW, NULL},
+ {"BST_LED_EN", GPIO_C, (1<<10), GPIO_OUT_LOW, NULL},
+ {"I2C1_SCL", GPIO_B, (1<<6), GPIO_ODR_HIGH, NULL},
+ {"I2C1_SDA", GPIO_B, (1<<7), GPIO_ODR_HIGH, NULL},
+ {"CHG_LED_Y", GPIO_C, (1<<6), GPIO_OUT_HIGH, NULL},
+ {"CHG_LED_G", GPIO_C, (1<<7), GPIO_OUT_HIGH, NULL},
+ {"CHG_LED_R", GPIO_C, (1<<8), GPIO_OUT_HIGH, NULL},
+ {"PMIC_PWRON", GPIO_C, (1<<12), GPIO_OUT_LOW, NULL},
+ {"KB_OUT00", GPIO_D, (1<<0), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT01", GPIO_D, (1<<1), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT02", GPIO_D, (1<<2), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT03", GPIO_D, (1<<3), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT04", GPIO_D, (1<<4), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT05", GPIO_D, (1<<5), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT06", GPIO_D, (1<<6), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT07", GPIO_D, (1<<7), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT08", GPIO_D, (1<<8), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT09", GPIO_D, (1<<9), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT10", GPIO_D, (1<<10), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT11", GPIO_D, (1<<11), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT12", GPIO_D, (1<<12), GPIO_KB_OUTPUT, NULL},
+ /*
+ * Unimplemented
+ * TODO: Remove these when codes compile without them
+ */
+ GPIO_SIGNAL_NOT_IMPLEMENTED("I2C2_SCL"),
+ GPIO_SIGNAL_NOT_IMPLEMENTED("I2C2_SDA"),
+};
+BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT);
+
+/* Battery temperature ranges in degrees C */
+const struct battery_temperature_ranges bat_temp_ranges = {
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 100,
+};
+
+/* I2C ports */
+const struct i2c_port_t i2c_ports[] = {
+ {"host", I2C_PORT_HOST, 100},
+};
+BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED);
+
+void board_config_post_gpio_init(void)
+{
+ /* I2C SCL/SDA on PB6-7 */
+ gpio_set_alternate_function(GPIO_B, (1 << 7) | (1 << 6), GPIO_ALT_I2C);
+
+ /* USART1 on pins PA9/PA10 */
+ gpio_set_alternate_function(GPIO_A, (1 << 9) | (1 << 10),
+ GPIO_ALT_USART);
+
+ /* TODO: Set TIM3 for PC6-8 here? */
+}
diff --git a/board/kirby/board.h b/board/kirby/board.h
new file mode 100644
index 0000000000..6fa0d4d3a1
--- /dev/null
+++ b/board/kirby/board.h
@@ -0,0 +1,115 @@
+/* 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.
+ */
+
+/* Pit board configuration */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+/* Optional features */
+#define CONFIG_BOARD_POST_GPIO_INIT
+#ifdef HAS_TASK_CHARGER
+#define CONFIG_CHARGER_TPS65090
+#endif
+#ifdef HAS_TASK_CHIPSET
+#define CONFIG_CHIPSET_GAIA
+#endif
+/* #define CONFIG_EXTPOWER_USB */
+#define CONFIG_HOST_COMMAND_STATUS
+#define CONFIG_I2C
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
+#define CONFIG_SPI
+
+#ifndef __ASSEMBLER__
+
+/* By default, enable all console messages except keyboard */
+#define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_KEYSCAN))
+
+/* Keyboard output port list */
+#define KB_OUT_PORT_LIST GPIO_D
+
+/*
+ * Charging.
+ *
+ * "HOST" means the port where the EC is the master, which has the battery,
+ * charger and PMU.
+ *
+ * "SLAVE" means the port where the EC is the slave, which has the AP (host
+ * processor).
+ *
+ * TODO: In this context, "host" is badly overloaded and confusing.
+ */
+#define I2C_PORT_HOST 0
+#define I2C_PORT_BATTERY I2C_PORT_HOST
+#define I2C_PORT_CHARGER I2C_PORT_HOST
+#define I2C_PORTS_USED 1
+
+/* Timer selection */
+#define TIM_CLOCK_MSB 3
+#define TIM_CLOCK_LSB 9
+#define TIM_WATCHDOG 4
+
+/* GPIO signal list */
+enum gpio_signal {
+ /* Inputs with interrupt handlers are first for efficiency */
+ GPIO_KB_PWR_ON_L = 0,
+ GPIO_SOC1V8_XPSHOLD,
+ GPIO_CHARGER_INT,
+ GPIO_USB_CHG_INT,
+ GPIO_USBPD_INT_L,
+ GPIO_LID_OPEN,
+ GPIO_SUSPEND_L,
+ GPIO_SPI1_NSS,
+ GPIO_AC_PRESENT,
+ /* Keyboard inputs */
+ GPIO_KB_IN00,
+ GPIO_KB_IN01,
+ GPIO_KB_IN02,
+ GPIO_KB_IN03,
+ GPIO_KB_IN04,
+ GPIO_KB_IN05,
+ GPIO_KB_IN06,
+ GPIO_KB_IN07,
+ /* Other inputs */
+ GPIO_WP_L,
+ /* Outputs */
+ GPIO_CHARGER_EN,
+ GPIO_EC_INT,
+ GPIO_EC_INT2,
+ GPIO_ID_MUX,
+ GPIO_BCHGR_OTG,
+ GPIO_BCHGR_PSEL,
+ GPIO_EN_PP3300,
+ GPIO_ENTERING_RW,
+ GPIO_BST_LED_EN,
+ GPIO_I2C1_SCL,
+ GPIO_I2C1_SDA,
+ GPIO_CHG_LED_Y,
+ GPIO_CHG_LED_G,
+ GPIO_CHG_LED_R,
+ GPIO_PMIC_PWRON,
+ GPIO_KB_OUT00,
+ GPIO_KB_OUT01,
+ GPIO_KB_OUT02,
+ GPIO_KB_OUT03,
+ GPIO_KB_OUT04,
+ GPIO_KB_OUT05,
+ GPIO_KB_OUT06,
+ GPIO_KB_OUT07,
+ GPIO_KB_OUT08,
+ GPIO_KB_OUT09,
+ GPIO_KB_OUT10,
+ GPIO_KB_OUT11,
+ GPIO_KB_OUT12,
+ /* Unimplemented */
+ GPIO_I2C2_SCL,
+ GPIO_I2C2_SDA,
+ /* Number of GPIOs; not an actual GPIO */
+ GPIO_COUNT
+};
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __BOARD_H */
diff --git a/board/kirby/build.mk b/board/kirby/build.mk
new file mode 100644
index 0000000000..3d89a2fca7
--- /dev/null
+++ b/board/kirby/build.mk
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+# 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.
+#
+# Board specific files build
+
+# the IC is STmicro STM32L151VB
+CHIP:=stm32
+CHIP_FAMILY:=stm32l
+CHIP_VARIANT:=stm32l15x
+
+board-y=board.o
diff --git a/board/kirby/ec.tasklist b/board/kirby/ec.tasklist
new file mode 100644
index 0000000000..9b044dca8c
--- /dev/null
+++ b/board/kirby/ec.tasklist
@@ -0,0 +1,24 @@
+/* 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.
+ */
+
+/**
+ * List of enabled tasks in the priority order
+ *
+ * The first one has the lowest priority.
+ *
+ * For each task, use the macro TASK(n, r, d, s) where :
+ * 'n' in the name of the task
+ * 'r' in the main routine of the task
+ * 'd' in an opaque parameter passed to the routine at startup
+ * 's' is the stack size in bytes; must be a multiple of 8
+ */
+#define CONFIG_TASK_LIST \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \
+ /* TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) */ \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE)
diff --git a/common/chipset_gaia.c b/common/chipset_gaia.c
index de773f30ce..8ea5ff334e 100644
--- a/common/chipset_gaia.c
+++ b/common/chipset_gaia.c
@@ -166,7 +166,7 @@ static int wait_in_signal(enum gpio_signal signal, int value, int timeout)
*/
static void set_pmic_pwrok(int asserted)
{
-#ifdef BOARD_pit
+#if defined(BOARD_pit) || defined(BOARD_kirby)
/* Signal is active-high */
gpio_set_level(GPIO_PMIC_PWRON, asserted);
#else
@@ -281,9 +281,11 @@ static int gaia_power_init(void)
{
/* Enable interrupts for our GPIOs */
gpio_enable_interrupt(GPIO_KB_PWR_ON_L);
- gpio_enable_interrupt(GPIO_PP1800_LDO2);
gpio_enable_interrupt(GPIO_SOC1V8_XPSHOLD);
gpio_enable_interrupt(GPIO_SUSPEND_L);
+#ifndef BOARD_kirby
+ gpio_enable_interrupt(GPIO_PP1800_LDO2);
+#endif
/* Leave power off only if requested by reset flags */
if (!(system_get_reset_flags() & RESET_FLAG_AP_OFF)) {
@@ -332,7 +334,9 @@ void chipset_reset(int is_cold)
* contents. This is useful for looking at kernel log message contents
* from previous boot in cases where the AP/OS is hard hung.
*/
+#ifndef BOARD_kirby
gpio_set_level(GPIO_EN_PP5000, 0);
+#endif
gpio_set_level(GPIO_EN_PP3300, 0);
power_request = POWER_REQ_ON;
@@ -343,9 +347,13 @@ void chipset_force_shutdown(void)
{
/* Turn off all rails */
gpio_set_level(GPIO_EN_PP3300, 0);
+#ifndef BOARD_kirby
gpio_set_level(GPIO_EN_PP1350, 0);
+#endif
set_pmic_pwrok(0);
+#ifndef BOARD_kirby
gpio_set_level(GPIO_EN_PP5000, 0);
+#endif
}
/*****************************************************************************/
@@ -402,10 +410,12 @@ static int check_for_power_on_event(void)
*/
static int power_on(void)
{
+#ifndef BOARD_kirby
/* Enable 5v power rail */
gpio_set_level(GPIO_EN_PP5000, 1);
/* Wait for it to stabilize */
usleep(DELAY_5V_SETUP);
+#endif
#if defined(BOARD_pit) || defined(BOARD_puppy)
/*
@@ -426,6 +436,7 @@ static int power_on(void)
set_pmic_pwrok(1);
}
+#ifndef BOARD_kirby
/* wait for all PMIC regulators to be ready */
wait_in_signal(GPIO_PP1800_LDO2, 1, PMIC_TIMEOUT);
@@ -445,6 +456,7 @@ static int power_on(void)
gpio_set_level(GPIO_EN_PP1350, 1);
/* Wait to avoid large inrush current */
usleep(DELAY_RAIL_STAGGERING);
+#endif
/* Enable 3.3v power rail, if it's not already on */
gpio_set_level(GPIO_EN_PP3300, 1);
@@ -513,7 +525,9 @@ static void power_off(void)
lid_opened = 0;
enable_sleep(SLEEP_MASK_AP_RUN);
powerled_set_state(POWERLED_STATE_OFF);
+#ifndef BOARD_kirby
pmu_shutdown();
+#endif
CPRINTF("[%T power shutdown complete]\n");
}