summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen Lin <yelin@nvidia.com>2013-06-28 16:18:02 -0700
committerChromeBot <chrome-bot@google.com>2013-07-02 13:33:59 -0700
commit09329a5f4bb58c7dc454f8ae93701f6da67ba769 (patch)
treea61007b89aa0d96015aa69e462f822d968e3957c
parent9179a3191dd0fbf6e5b5ad37985ef99b1ca2414e (diff)
downloadchrome-ec-09329a5f4bb58c7dc454f8ae93701f6da67ba769.tar.gz
ec: Add puppy support
Add board/puppy files to support Puppy board. BUG=None TEST=tested on Venice board Change-Id: I9b678b219f7b3e12cd109f41fab28d7b70d15717 Signed-off-by: Yen Lin <yelin@nvidia.com> Reviewed-on: https://gerrit.chromium.org/gerrit/60561 Reviewed-by: Andrew Chew <achew@nvidia.com> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Jimmy Zhang <jimmzhang@nvidia.com> Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com> Tested-by: Jimmy Zhang <jimmzhang@nvidia.com>
-rw-r--r--board/puppy/board.c162
-rw-r--r--board/puppy/board.h129
-rw-r--r--board/puppy/build.mk13
-rw-r--r--board/puppy/ec.tasklist24
4 files changed, 328 insertions, 0 deletions
diff --git a/board/puppy/board.c b/board/puppy/board.c
new file mode 100644
index 0000000000..0162a0605a
--- /dev/null
+++ b/board/puppy/board.c
@@ -0,0 +1,162 @@
+/* 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.
+ */
+/* Puppy board-specific configuration */
+
+#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 "pmu_tpschrome.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[GPIO_COUNT] = {
+ /* Inputs with interrupt handlers are first for efficiency */
+ {"KB_PWR_ON_L", GPIO_B, (1<<5), GPIO_INT_BOTH, gaia_power_event},
+ {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event},
+ {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_RISING, gaia_power_event},
+ {"CHARGER_INT", GPIO_C, (1<<6), GPIO_INT_RISING, pmu_irq_handler},
+ {"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, lid_interrupt},
+ {"SUSPEND_L", GPIO_C, (1<<7), GPIO_KB_INPUT, gaia_suspend_event},
+ {"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
+ spi_event},
+ {"AC_PRESENT", GPIO_A, (1<<0), GPIO_INT_BOTH, extpower_interrupt},
+ {"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN01", GPIO_C, (1<<9), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN02", GPIO_C, (1<<10), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN03", GPIO_C, (1<<11), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN04", GPIO_C, (1<<12), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN05", GPIO_C, (1<<14), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN06", GPIO_C, (1<<15), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ {"KB_IN07", GPIO_D, (1<<2), GPIO_KB_INPUT,
+ keyboard_raw_gpio_interrupt},
+ /* Other inputs */
+ {"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL},
+ /* Outputs */
+ {"AP_RESET_L", GPIO_B, (1<<3), GPIO_OUT_HIGH, NULL},
+ {"CHARGER_EN", GPIO_B, (1<<2), GPIO_OUT_LOW, NULL},
+ {"EC_INT", GPIO_B, (1<<9), GPIO_ODR_HIGH, NULL},
+ {"EN_PP1350", GPIO_H, (1<<1), GPIO_OUT_LOW, NULL},
+ {"EN_PP3300", GPIO_A, (1<<8), GPIO_OUT_LOW, NULL},
+ {"EN_PP5000", GPIO_A, (1<<11), GPIO_OUT_LOW, NULL},
+ {"ENTERING_RW", GPIO_H, (1<<0), GPIO_OUT_LOW, NULL},
+ {"I2C1_SCL", GPIO_B, (1<<6), GPIO_ODR_HIGH, NULL},
+ {"I2C1_SDA", GPIO_B, (1<<7), GPIO_ODR_HIGH, NULL},
+ {"I2C2_SCL", GPIO_B, (1<<10), GPIO_ODR_HIGH, NULL},
+ {"I2C2_SDA", GPIO_B, (1<<11), GPIO_ODR_HIGH, NULL},
+ {"LED_POWER_L", GPIO_A, (1<<2), GPIO_OUT_HIGH, NULL},
+ {"PMIC_PWRON_L", GPIO_A, (1<<12), GPIO_OUT_HIGH, NULL},
+ {"PMIC_RESET", GPIO_A, (1<<15), GPIO_OUT_LOW, NULL},
+ {"KB_OUT00", GPIO_B, (1<<0), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT01", GPIO_B, (1<<8), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT02", GPIO_B, (1<<12), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT03", GPIO_B, (1<<13), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT04", GPIO_B, (1<<14), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT05", GPIO_B, (1<<15), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT06", GPIO_C, (1<<0), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT07", GPIO_C, (1<<1), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT08", GPIO_C, (1<<2), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT09", GPIO_B, (1<<1), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT10", GPIO_C, (1<<5), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT11", GPIO_C, (1<<4), GPIO_KB_OUTPUT, NULL},
+ {"KB_OUT12", GPIO_A, (1<<13), GPIO_KB_OUTPUT, NULL},
+};
+
+/* I2C ports */
+const struct i2c_port_t i2c_ports[I2C_PORTS_USED] = {
+ {"host", I2C_PORT_HOST, 100},
+};
+
+void board_config_post_gpio_init(void)
+{
+ /* I2C SCL/SDA on PB10-11 and PB6-7 */
+ gpio_set_alternate_function(GPIO_B,
+ (1 << 11) | (1 << 10) | (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);
+}
+
+#ifdef CONFIG_PMU_BOARD_INIT
+int pmu_board_init(void)
+{
+ int ver, failure = 0;
+
+ /* Set fast charging timeout to 6 hours*/
+ if (!failure)
+ failure = pmu_set_fastcharge(TIMEOUT_6HRS);
+ /* Enable external gpio CHARGER_EN control */
+ if (!failure)
+ failure = pmu_enable_ext_control(1);
+ /* Disable force charging */
+ if (!failure)
+ failure = pmu_enable_charger(0);
+
+ /* Set NOITERM bit */
+ if (!failure)
+ failure = pmu_low_current_charging(1);
+
+ /*
+ * High temperature charging
+ * termination voltage: 2.1V
+ * termination current: 100%
+ */
+ if (!failure)
+ failure = pmu_set_term_voltage(RANGE_T34, TERM_V2100);
+ if (!failure)
+ failure = pmu_set_term_current(RANGE_T34, TERM_I1000);
+ /*
+ * Standard temperature charging
+ * termination voltage: 2.1V
+ * termination current: 100%
+ */
+ if (!failure)
+ failure = pmu_set_term_voltage(RANGE_T23, TERM_V2100);
+ if (!failure)
+ failure = pmu_set_term_current(RANGE_T23, TERM_I1000);
+
+ /*
+ * Ignore TPSCHROME NTC reading in T40. This is snow board specific
+ * setting. Check:
+ * http://crosbug.com/p/12221
+ * http://crosbug.com/p/13171
+ */
+ if (!failure)
+ failure = pmu_set_term_voltage(RANGE_T40, TERM_V2100);
+ if (!failure)
+ failure = pmu_set_term_current(RANGE_T40, TERM_I1000);
+
+ /* Workaround init values before ES3 */
+ if (pmu_version(&ver) || ver < 3) {
+ /* Termination current: 75% */
+ if (!failure)
+ failure = pmu_set_term_current(RANGE_T34, TERM_I0750);
+ if (!failure)
+ failure = pmu_set_term_current(RANGE_T23, TERM_I0750);
+ if (!failure)
+ failure = pmu_set_term_current(RANGE_T40, TERM_I0750);
+ }
+
+ return failure ? EC_ERROR_UNKNOWN : EC_SUCCESS;
+}
+#endif /* CONFIG_BOARD_PMU_INIT */
diff --git a/board/puppy/board.h b/board/puppy/board.h
new file mode 100644
index 0000000000..2c29f5b5f9
--- /dev/null
+++ b/board/puppy/board.h
@@ -0,0 +1,129 @@
+/* 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.
+ */
+
+/* Puppy board configuration */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+/* Use USART1 as console serial port */
+#define CONFIG_CONSOLE_UART 1
+
+/* Debug features */
+#define CONFIG_ASSERT_HELP
+#define CONFIG_CONSOLE_CMDHELP
+#define CONFIG_PANIC_HELP
+#define CONFIG_TASK_PROFILING
+#define CONFIG_WATCHDOG_HELP
+
+/* Optional features */
+#define CONFIG_BATTERY_BQ20Z453
+#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_CMD_PMU
+#define CONFIG_EXTPOWER_GPIO
+#define CONFIG_HOST_COMMAND_STATUS
+#define CONFIG_I2C
+#define CONFIG_KEYBOARD_PROTOCOL_MKBP
+#define CONFIG_LID_SWITCH
+#define CONFIG_PMU_BOARD_INIT
+#define CONFIG_PMU_HARD_RESET
+#define CONFIG_PMU_TPS65090
+#define CONFIG_SMART_BATTERY
+#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_A, GPIO_B, GPIO_C
+
+/*
+ * 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_PORT_SLAVE 1
+#define I2C_PORTS_USED 1
+
+/* Timer selection */
+#define TIM_CLOCK_MSB 3
+#define TIM_CLOCK_LSB 9
+#define TIM_POWER_LED 2
+#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_PP1800_LDO2,
+ GPIO_SOC1V8_XPSHOLD,
+ GPIO_CHARGER_INT,
+ 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_AP_RESET_L,
+ GPIO_CHARGER_EN,
+ GPIO_EC_INT,
+ GPIO_EN_PP1350,
+ GPIO_EN_PP3300,
+ GPIO_EN_PP5000,
+ GPIO_ENTERING_RW,
+ GPIO_I2C1_SCL,
+ GPIO_I2C1_SDA,
+ GPIO_I2C2_SCL,
+ GPIO_I2C2_SDA,
+ GPIO_LED_POWER_L,
+ GPIO_PMIC_PWRON_L,
+ GPIO_PMIC_RESET,
+ 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,
+ /* Number of GPIOs; not an actual GPIO */
+ GPIO_COUNT
+};
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __BOARD_H */
diff --git a/board/puppy/build.mk b/board/puppy/build.mk
new file mode 100644
index 0000000000..8de1b957d3
--- /dev/null
+++ b/board/puppy/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 STM32L151R8H6
+CHIP:=stm32
+CHIP_FAMILY:=stm32l
+CHIP_VARIANT:=stm32l15x
+
+board-y=board.o
diff --git a/board/puppy/ec.tasklist b/board/puppy/ec.tasklist
new file mode 100644
index 0000000000..7f1f1de257
--- /dev/null
+++ b/board/puppy/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)