summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Lin <jimmy.lin@quantatw.com>2014-08-14 19:03:59 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-20 06:37:21 +0000
commit61f089815de40af51346a0372d0b05cef3e08242 (patch)
treefd3cd29e4d651065d742cac2bf90e62dce9c8bd9
parent191671ea6b50143cafc739913972d6b6742289ea (diff)
downloadchrome-ec-61f089815de40af51346a0372d0b05cef3e08242.tar.gz
kitty:Initial EC for bring up kitty
Based on nyan project and modify as below items, 1.Disable keyboard and Battery function. 2.Add LED.c file. 3.To config all GPIO by latest schematic. 4.Remove Battery.c file. BUG=chrome-os-partner:31320 BRANCH=kitty TEST=Buildall and check board can boot up. Change-Id: I1854e8fdfa2cd8f95ffdcbf1357e6a91b5abc5f4 Signed-off-by: Jimmy Lin <jimmy.Lin@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/212407 Tested-by: 挺倫 林 <jimmy.lin@quantatw.com> Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: 挺倫 林 <jimmy.lin@quantatw.com>
-rw-r--r--board/kitty/board.c82
-rw-r--r--board/kitty/board.h85
-rw-r--r--board/kitty/build.mk13
-rw-r--r--board/kitty/ec.tasklist22
-rw-r--r--board/kitty/led.c85
-rw-r--r--chip/stm32/clock-stm32l.c4
-rw-r--r--power/tegra.c3
-rwxr-xr-xutil/flash_ec3
8 files changed, 295 insertions, 2 deletions
diff --git a/board/kitty/board.c b/board/kitty/board.c
new file mode 100644
index 0000000000..f0abfc12b3
--- /dev/null
+++ b/board/kitty/board.c
@@ -0,0 +1,82 @@
+/* Copyright (c) 2014 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.
+ */
+/* Kitty board-specific configuration */
+
+#include "chipset.h"
+#include "common.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "i2c.h"
+#include "power.h"
+#include "power_button.h"
+#include "pwm.h"
+#include "pwm_chip.h"
+#include "registers.h"
+#include "spi.h"
+#include "task.h"
+#include "util.h"
+#include "timer.h"
+
+
+/* GPIO signal list. Must match order from enum gpio_signal. */
+const struct gpio_info gpio_list[] = {
+ /* Inputs with interrupt handlers are first for efficiency */
+ {"POWER_BUTTON_L", GPIO_B, (1<<5), GPIO_INT_BOTH,
+ power_button_interrupt},
+ {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH,
+ power_signal_interrupt},
+ {"LID_OPEN", GPIO_C, (1<<13), GPIO_DEFAULT, NULL},
+ {"SUSPEND_L", GPIO_C, (1<<7), GPIO_INT_BOTH,
+ power_signal_interrupt},
+ {"SPI1_NSS", GPIO_A, (1<<4), GPIO_INT_BOTH | GPIO_PULL_UP,
+ spi_event},
+ {"AC_PRESENT", GPIO_A, (1<<0), GPIO_DEFAULT, NULL},
+ {"USB_CTL3", GPIO_C, (1<<11), GPIO_ODR_HIGH, NULL},
+ {"USB_CTL2", GPIO_C, (1<<12), GPIO_ODR_HIGH, NULL},
+ {"USB_CTL1", GPIO_C, (1<<15), GPIO_OUT_LOW, NULL},
+ {"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL},
+ {"AP_RESET_L", GPIO_B, (1<<3), GPIO_ODR_HIGH, NULL},
+ {"EC_INT", GPIO_B, (1<<9), GPIO_ODR_HIGH, 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},
+ {"PMIC_PWRON_L", GPIO_A, (1<<12), GPIO_OUT_HIGH, NULL},
+ {"PMIC_RESET", GPIO_A, (1<<15), GPIO_OUT_LOW, NULL},
+ {"PWR_LED0", GPIO_B, (1<<10), GPIO_OUT_LOW, NULL},
+ {"USB_ILIM_SEL", GPIO_A, (1<<8), GPIO_OUT_LOW, NULL},
+ {"USB_STATUS_L", GPIO_A, (1<<11), GPIO_INT_BOTH, NULL},
+ {"EC_BL_OVERRIDE", GPIO_H, (1<<1), GPIO_ODR_HIGH, NULL},
+ {"PMIC_THERM_L", GPIO_A, (1<<1), GPIO_ODR_HIGH, NULL},
+ {"PMIC_WARM_RESET_L", GPIO_C, (1<<3), GPIO_ODR_HIGH, NULL},
+};
+BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT);
+
+/* Pins with alternate functions */
+const struct gpio_alt_func gpio_alt_funcs[] = {
+ {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI, GPIO_DEFAULT},
+ {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART, GPIO_DEFAULT},
+ {GPIO_B, 0x00c0, GPIO_ALT_I2C, MODULE_I2C, GPIO_DEFAULT},
+};
+const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
+
+/* power signal list. Must match order of enum power_signal. */
+const struct power_signal_info power_signal_list[] = {
+ {GPIO_SOC1V8_XPSHOLD, 1, "XPSHOLD"},
+ {GPIO_SUSPEND_L, 0, "SUSPEND#_ASSERTED"},
+};
+BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
+
+/* I2C ports */
+const struct i2c_port_t i2c_ports[] = {
+ {"master", I2C_PORT_MASTER, 100, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
+};
+const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
+const struct pwm_t pwm_channels[] = {
+ {STM32_TIM(2), STM32_TIM_CH(3),
+ PWM_CONFIG_ACTIVE_LOW, GPIO_PWR_LED0},
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
diff --git a/board/kitty/board.h b/board/kitty/board.h
new file mode 100644
index 0000000000..a906d7dd10
--- /dev/null
+++ b/board/kitty/board.h
@@ -0,0 +1,85 @@
+/* Copyright (c) 2014 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.
+ */
+
+/* kitty board configuration */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+/* Optional features */
+#define CONFIG_AP_HANG_DETECT
+#define CONFIG_CHIPSET_TEGRA
+#define CONFIG_POWER_COMMON
+#define CONFIG_EXTPOWER_GPIO
+#define CONFIG_HOST_COMMAND_STATUS
+#define CONFIG_I2C
+#define CONFIG_SPI
+#define CONFIG_PWM
+#define CONFIG_POWER_BUTTON
+#define CONFIG_VBOOT_HASH
+#define CONFIG_LED_COMMON
+
+#ifndef __ASSEMBLER__
+
+
+
+/* Single I2C port, where the EC is the master. */
+#define I2C_PORT_MASTER 0
+
+/* 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_POWER_BUTTON_L = 0,
+ GPIO_SOC1V8_XPSHOLD,
+ GPIO_LID_OPEN,
+ GPIO_SUSPEND_L,
+ GPIO_SPI1_NSS,
+ GPIO_AC_PRESENT,
+ GPIO_USB_CTL3,
+ GPIO_USB_CTL2,
+ GPIO_USB_CTL1,
+ GPIO_WP_L,
+ GPIO_AP_RESET_L,
+ GPIO_EC_INT,
+ GPIO_ENTERING_RW,
+ GPIO_I2C1_SCL,
+ GPIO_I2C1_SDA,
+ GPIO_PMIC_PWRON_L,
+ GPIO_PMIC_RESET,
+ GPIO_PWR_LED0,
+ GPIO_USB_ILIM_SEL,
+ GPIO_USB_STATUS_L,
+ GPIO_EC_BL_OVERRIDE,
+ GPIO_PMIC_THERM_L,
+ GPIO_PMIC_WARM_RESET_L,
+ /* Number of GPIOs; not an actual GPIO */
+ GPIO_COUNT
+};
+
+enum power_signal {
+ TEGRA_XPSHOLD = 0,
+ TEGRA_SUSPEND_ASSERTED,
+
+ /* Number of power signals */
+ POWER_SIGNAL_COUNT
+};
+
+enum pwm_channel {
+ PWM_CH_POWER_LED = 0,
+ /* Number of PWM channels */
+ PWM_CH_COUNT
+};
+
+
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __BOARD_H */
diff --git a/board/kitty/build.mk b/board/kitty/build.mk
new file mode 100644
index 0000000000..7598dc3eac
--- /dev/null
+++ b/board/kitty/build.mk
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+# Copyright (c) 2014 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 STM32L100RBT6
+CHIP:=stm32
+CHIP_FAMILY:=stm32l
+CHIP_VARIANT:=stm32l100
+
+board-y=board.o led.o
diff --git a/board/kitty/ec.tasklist b/board/kitty/ec.tasklist
new file mode 100644
index 0000000000..df91c86a55
--- /dev/null
+++ b/board/kitty/ec.tasklist
@@ -0,0 +1,22 @@
+/* Copyright (c) 2014 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, LARGER_TASK_STACK_SIZE) \
+ TASK_NOTEST(POWERLED, power_led_task, NULL, 256) \
+ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)
diff --git a/board/kitty/led.c b/board/kitty/led.c
new file mode 100644
index 0000000000..82772ca527
--- /dev/null
+++ b/board/kitty/led.c
@@ -0,0 +1,85 @@
+/* Copyright (c) 2014 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.
+ *
+ * Power LED control for Kitty
+ */
+
+#include "gpio.h"
+#include "hooks.h"
+#include "chipset.h"
+#include "led_common.h"
+#include "util.h"
+
+const enum ec_led_id supported_led_ids[] = {EC_LED_ID_POWER_LED};
+
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+enum led_color {
+ LED_OFF = 0,
+ LED_WHITE,
+ LED_COLOR_COUNT /* Number of colors, not a color itself */
+};
+
+static int pwr_led_set_color(enum led_color color)
+{
+ switch (color) {
+ case LED_OFF:
+ gpio_set_level(GPIO_PWR_LED0, 0);
+ break;
+ case LED_WHITE:
+ gpio_set_level(GPIO_PWR_LED0, 1);
+ break;
+ default:
+ return EC_ERROR_UNKNOWN;
+ }
+ return EC_SUCCESS;
+}
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ brightness_range[EC_LED_COLOR_WHITE] = 1;
+}
+
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
+{
+ switch (led_id) {
+ case EC_LED_ID_POWER_LED:
+ if (brightness[EC_LED_COLOR_WHITE] != 0)
+ pwr_led_set_color(LED_WHITE);
+ else
+ pwr_led_set_color(LED_OFF);
+ break;
+ default:
+ return EC_ERROR_UNKNOWN;
+ }
+ return EC_SUCCESS;
+}
+
+static void kitty_led_set_power(void)
+{
+ static int power_second;
+
+ power_second++;
+
+ /* PWR LED behavior:
+ * Power on: White
+ * Suspend: White in breeze mode ( 1 sec on/ 3 sec off)
+ * Power off: OFF
+ */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ pwr_led_set_color(LED_OFF);
+ else if (chipset_in_state(CHIPSET_STATE_ON))
+ pwr_led_set_color(LED_WHITE);
+ else if (chipset_in_state(CHIPSET_STATE_SUSPEND))
+ pwr_led_set_color((power_second & 3) ? LED_OFF : LED_WHITE);
+}
+
+/** * Called by hook task every 1 sec */
+static void led_second(void)
+{
+ if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
+ kitty_led_set_power();
+}
+DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT);
+
diff --git a/chip/stm32/clock-stm32l.c b/chip/stm32/clock-stm32l.c
index 502a8187c3..3d320a4982 100644
--- a/chip/stm32/clock-stm32l.c
+++ b/chip/stm32/clock-stm32l.c
@@ -196,7 +196,9 @@ void clock_enable_module(enum module_id module, int enable)
*/
void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
{
+#ifdef CONFIG_KEYBOARD_PROTOCOL_MKBP
int i;
+#endif
fake_hibernate = 1;
#ifdef CONFIG_POWER_COMMON
@@ -218,6 +220,7 @@ void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
power_set_state(POWER_G3);
#endif
+#ifdef CONFIG_KEYBOARD_PROTOCOL_MKBP
/*
* Change keyboard outputs to high-Z to reduce power draw.
* We don't need corresponding code to change them back,
@@ -227,6 +230,7 @@ void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
*/
for (i = GPIO_KB_OUT00; i < GPIO_KB_OUT00 + KEYBOARD_COLS; i++)
gpio_set_flags(i, GPIO_INPUT);
+#endif
ccprints("fake hibernate. waits for power button/lid/RTC/AC");
cflush();
diff --git a/power/tegra.c b/power/tegra.c
index 41c1e83b16..60f9044277 100644
--- a/power/tegra.c
+++ b/power/tegra.c
@@ -270,8 +270,9 @@ enum power_state power_chipset_init(void)
* Some batteries use clock stretching feature, which requires
* more time to be stable. See http://crosbug.com/p/28289
*/
+#ifndef BOARD_KITTY
battery_wait_for_stable();
-
+#endif
return init_power_state;
}
diff --git a/util/flash_ec b/util/flash_ec
index 3bfee7c61d..2af7475668 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -239,7 +239,8 @@ fi
save="$(servo_save)"
case "${BOARD}" in
- big | blaze | discovery | nyan | pit | snow | spring ) flash_stm32 ;;
+ big | blaze | discovery | kitty | nyan | pit | snow | spring ) \
+ flash_stm32 ;;
fruitpie | zinger) flash_stm32 ;;
falco | peppy | rambi | samus | squawks ) flash_lm4 ;;
link ) flash_link ;;