summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-01-07 09:49:00 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-01-08 02:22:34 +0000
commit91abb52837429cf5b1e580f86bf4f2352a18fb5d (patch)
tree954f2c10b73ba37c9ee5ddd3c0bc6530dd10bea7
parent7964fa2bdc108efb20b0ce3b7dc4a161e951c28a (diff)
downloadchrome-ec-91abb52837429cf5b1e580f86bf4f2352a18fb5d.tar.gz
Add squawks board
Implement LED color policy (crosbug.com/p/23957) Update battery vendor information (crosbug.com/p/24684) BUG=chrome-os-partner:24885 BRANCH=rambi TEST=manual system on, lidclose -> power LED off system on, lidopen -> power LED on system suspended -> power LED blinks green every 2 sec system suspended, lid closed -> power LED off system off -> power LED off plug AC in, battfake 95 -> charging LED green plug AC in, battfake 94 -> charging LED orange unplug AC, battfake 10 -> charging LED off unplug AC, battfake 9 -> charging LED blinks orange battcutoff -> after a few sec, system powered down plug back in AC -> system comes back on charger -> I_in < 1700 Change-Id: I89161e2c024d85197b8612a40a61dd50c106549e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181755
-rw-r--r--board/squawks/battery.c68
-rw-r--r--board/squawks/board.c201
-rw-r--r--board/squawks/board.h182
-rw-r--r--board/squawks/build.mk12
-rw-r--r--board/squawks/ec.tasklist29
-rw-r--r--board/squawks/led.c163
-rw-r--r--chip/lm4/openocd/lm4x_cmds.tcl9
-rwxr-xr-xutil/flash_ec4
8 files changed, 665 insertions, 3 deletions
diff --git a/board/squawks/battery.c b/board/squawks/battery.c
new file mode 100644
index 0000000000..156818d7fd
--- /dev/null
+++ b/board/squawks/battery.c
@@ -0,0 +1,68 @@
+/* Copyright (c) 2012 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.
+ *
+ * Battery pack vendor provided charging profile
+ */
+
+#include "battery.h"
+#include "battery_smart.h"
+#include "console.h"
+#include "gpio.h"
+#include "host_command.h"
+#include "util.h"
+
+/* Shutdown mode parameter to write to manufacturer access register */
+#define SB_SHUTDOWN_DATA 0x0010
+
+/* 3S1P battery */
+static const struct battery_info info = {
+ .voltage_max = 12600, /* mV */
+ .voltage_normal = 10800,
+ .voltage_min = 8250,
+ /*
+ * Precharge current max is 400 mA, but 384 mA is as close to that
+ * as the charger can get without going over.
+ */
+ .precharge_current = 384, /* mA */
+ .start_charging_min_c = 10,
+ .start_charging_max_c = 45,
+ .charging_min_c = 10,
+ .charging_max_c = 45,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+};
+
+const struct battery_info *battery_get_info(void)
+{
+ return &info;
+}
+
+static int cutoff(void)
+{
+ int rv;
+
+ /* Ship mode command must be sent twice to take effect */
+ rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
+
+ if (rv != EC_SUCCESS)
+ return rv;
+
+ return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
+}
+
+static int battery_command_cut_off(struct host_cmd_handler_args *args)
+{
+ return cutoff() ? EC_RES_SUCCESS : EC_RES_ERROR;
+}
+DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off,
+ EC_VER_MASK(0));
+
+static int command_battcutoff(int argc, char **argv)
+{
+ return cutoff();
+}
+DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff,
+ NULL,
+ "Enable battery cutoff (ship mode)",
+ NULL);
diff --git a/board/squawks/board.c b/board/squawks/board.c
new file mode 100644
index 0000000000..b15bd65f1b
--- /dev/null
+++ b/board/squawks/board.c
@@ -0,0 +1,201 @@
+/* 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.
+ */
+/* EC for Squawks board configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "backlight.h"
+#include "power.h"
+#include "common.h"
+#include "driver/temp_sensor/tmp432.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "host_command.h"
+#include "i2c.h"
+#include "jtag.h"
+#include "keyboard_scan.h"
+#include "lid_switch.h"
+#include "peci.h"
+#include "power_button.h"
+#include "pwm.h"
+#include "pwm_chip.h"
+#include "registers.h"
+#include "switch.h"
+#include "temp_sensor.h"
+#include "temp_sensor_chip.h"
+#include "thermal.h"
+#include "timer.h"
+#include "uart.h"
+#include "util.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", LM4_GPIO_A, (1<<2), GPIO_INT_BOTH_DSLEEP,
+ power_button_interrupt},
+ {"LID_OPEN", LM4_GPIO_A, (1<<3), GPIO_INT_BOTH_DSLEEP,
+ lid_interrupt},
+ {"AC_PRESENT", LM4_GPIO_H, (1<<3), GPIO_INT_BOTH_DSLEEP,
+ extpower_interrupt},
+ {"PCH_SLP_S3_L", LM4_GPIO_G, (1<<7), GPIO_INT_BOTH_DSLEEP |
+ GPIO_PULL_UP,
+ x86_interrupt},
+ {"PCH_SLP_S4_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH_DSLEEP |
+ GPIO_PULL_UP,
+ x86_interrupt},
+ {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH,
+ x86_interrupt},
+ {"PP3300_PCH_PGOOD", LM4_GPIO_C, (1<<4), GPIO_INT_BOTH,
+ x86_interrupt},
+ {"PP5000_PGOOD", LM4_GPIO_N, (1<<0), GPIO_INT_BOTH,
+ x86_interrupt},
+ {"S5_PGOOD", LM4_GPIO_G, (1<<0), GPIO_INT_BOTH,
+ x86_interrupt},
+ {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH,
+ x86_interrupt},
+ {"WP_L", LM4_GPIO_A, (1<<4), GPIO_INT_BOTH,
+ switch_interrupt},
+ {"JTAG_TCK", LM4_GPIO_C, (1<<0), GPIO_DEFAULT,
+ jtag_interrupt},
+ {"UART0_RX", LM4_GPIO_A, (1<<0), GPIO_INT_BOTH_DSLEEP |
+ GPIO_PULL_UP,
+ uart_deepsleep_interrupt},
+
+ /* Other inputs */
+ {"BOARD_VERSION1", LM4_GPIO_Q, (1<<5), GPIO_INPUT, NULL},
+ {"BOARD_VERSION2", LM4_GPIO_Q, (1<<6), GPIO_INPUT, NULL},
+ {"BOARD_VERSION3", LM4_GPIO_Q, (1<<7), GPIO_INPUT, NULL},
+ {"PCH_SLP_SX_L", LM4_GPIO_G, (1<<3), GPIO_INPUT|GPIO_PULL_UP,
+ NULL},
+ {"PCH_SUS_STAT_L", LM4_GPIO_G, (1<<6), GPIO_INPUT|GPIO_PULL_UP,
+ NULL},
+ {"PCH_SUSPWRDNACK", LM4_GPIO_G, (1<<2), GPIO_INPUT|GPIO_PULL_UP,
+ NULL},
+ {"PP1000_S0IX_PGOOD", LM4_GPIO_H, (1<<6), GPIO_INPUT, NULL},
+ {"USB1_OC_L", LM4_GPIO_E, (1<<7), GPIO_INPUT, NULL},
+ {"USB2_OC_L", LM4_GPIO_E, (1<<0), GPIO_INPUT, NULL},
+
+ /* Outputs; all unasserted by default except for reset signals */
+ {"CPU_PROCHOT", LM4_GPIO_B, (1<<5), GPIO_OUT_LOW, NULL},
+ {"ENABLE_BACKLIGHT", LM4_GPIO_M, (1<<7), GPIO_ODR_HIGH, NULL},
+ {"ENABLE_TOUCHPAD", LM4_GPIO_N, (1<<1), GPIO_OUT_LOW, NULL},
+ {"ENTERING_RW", LM4_GPIO_D, (1<<6), GPIO_OUT_LOW, NULL},
+ {"LPC_CLKRUN_L", LM4_GPIO_M, (1<<2), GPIO_ODR_HIGH, NULL},
+ {"PCH_CORE_PWROK", LM4_GPIO_F, (1<<5), GPIO_OUT_LOW, NULL},
+ {"PCH_PWRBTN_L", LM4_GPIO_H, (1<<0), GPIO_ODR_HIGH, NULL},
+ {"PCH_RCIN_L", LM4_GPIO_F, (1<<3), GPIO_ODR_HIGH, NULL},
+ {"PCH_RSMRST_L", LM4_GPIO_F, (1<<1), GPIO_OUT_LOW, NULL},
+ {"PCH_SMI_L", LM4_GPIO_F, (1<<4), GPIO_ODR_HIGH, NULL},
+ {"PCH_SOC_OVERRIDE", LM4_GPIO_G, (1<<1), GPIO_OUT_LOW, NULL},
+ {"PCH_SYS_PWROK", LM4_GPIO_H, (1<<2), GPIO_OUT_LOW, NULL},
+ {"PCH_WAKE_L", LM4_GPIO_F, (1<<0), GPIO_ODR_HIGH, NULL},
+ {"PP1350_EN", LM4_GPIO_H, (1<<5), GPIO_OUT_LOW, NULL},
+ {"PP3300_DX_EN", LM4_GPIO_J, (1<<2), GPIO_OUT_LOW, NULL},
+ {"PP3300_LTE_EN", LM4_GPIO_D, (1<<4), GPIO_OUT_LOW, NULL},
+ {"PP3300_WLAN_EN", LM4_GPIO_J, (1<<0), GPIO_OUT_LOW, NULL},
+ {"PP5000_EN", LM4_GPIO_H, (1<<7), GPIO_OUT_LOW, NULL},
+ {"PPSX_EN", LM4_GPIO_L, (1<<6), GPIO_OUT_LOW, NULL},
+ {"SUSP_VR_EN", LM4_GPIO_C, (1<<7), GPIO_OUT_LOW, NULL},
+ {"TOUCHSCREEN_RESET_L", LM4_GPIO_N, (1<<7), GPIO_OUT_LOW, NULL},
+ {"USB_CTL1", LM4_GPIO_E, (1<<6), GPIO_OUT_LOW, NULL},
+ {"USB_ILIM_SEL", LM4_GPIO_E, (1<<5), GPIO_OUT_LOW, NULL},
+ {"USB1_ENABLE", LM4_GPIO_E, (1<<4), GPIO_OUT_LOW, NULL},
+ {"USB2_ENABLE", LM4_GPIO_D, (1<<5), GPIO_OUT_LOW, NULL},
+ {"VCORE_EN", LM4_GPIO_C, (1<<5), GPIO_OUT_LOW, NULL},
+ {"WLAN_OFF_L", LM4_GPIO_J, (1<<4), GPIO_OUT_LOW, NULL},
+ {"PCH_SCI_L", LM4_GPIO_M, (1<<1), GPIO_ODR_HIGH, NULL},
+ {"KBD_IRQ_L", LM4_GPIO_M, (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, 0x03, 1, MODULE_UART}, /* UART0 */
+ {GPIO_B, 0x04, 3, MODULE_I2C}, /* I2C0 SCL */
+ {GPIO_B, 0x08, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C0 SDA */
+ {GPIO_B, 0x40, 3, MODULE_I2C}, /* I2C5 SCL */
+ {GPIO_B, 0x80, 3, MODULE_I2C, GPIO_OPEN_DRAIN}, /* I2C5 SDA */
+ {GPIO_D, 0x0f, 2, MODULE_SPI}, /* SPI1 */
+ {GPIO_L, 0x3f, 15, MODULE_LPC}, /* LPC */
+ {GPIO_M, 0x21, 15, MODULE_LPC}, /* LPC */
+ {GPIO_N, 0x50, 1, MODULE_PWM_LED, GPIO_OPEN_DRAIN}, /* FAN0PWM 3&4 */
+ {GPIO_M, 0x40, 1, MODULE_PWM_LED, GPIO_OPEN_DRAIN}, /* FAN0PWM0 */
+};
+const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
+
+/* x86 signal list. Must match order of enum x86_signal. */
+const struct x86_signal_info x86_signal_list[] = {
+ {GPIO_PP1050_PGOOD, 1, "PGOOD_PP1050"},
+ {GPIO_PP3300_PCH_PGOOD, 1, "PGOOD_PP3300_PCH"},
+ {GPIO_PP5000_PGOOD, 1, "PGOOD_PP5000"},
+ {GPIO_S5_PGOOD, 1, "PGOOD_S5"},
+ {GPIO_VCORE_PGOOD, 1, "PGOOD_VCORE"},
+ {GPIO_PP1000_S0IX_PGOOD, 1, "PGOOD_PP1000_S0IX"},
+ {GPIO_PCH_SLP_S3_L, 1, "SLP_S3#_DEASSERTED"},
+ {GPIO_PCH_SLP_S4_L, 1, "SLP_S4#_DEASSERTED"},
+ {GPIO_PCH_SLP_SX_L, 1, "SLP_SX#_DEASSERTED"},
+ {GPIO_PCH_SUS_STAT_L, 0, "SUS_STAT#_ASSERTED"},
+ {GPIO_PCH_SUSPWRDNACK, 1, "SUSPWRDNACK_ASSERTED"},
+};
+BUILD_ASSERT(ARRAY_SIZE(x86_signal_list) == X86_SIGNAL_COUNT);
+
+/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
+const struct adc_t adc_channels[] = {
+ /* EC internal temperature is calculated by
+ * 273 + (295 - 450 * ADC_VALUE / ADC_READ_MAX) / 2
+ * = -225 * ADC_VALUE / ADC_READ_MAX + 420.5
+ */
+ {"ECTemp", LM4_ADC_SEQ0, -225, ADC_READ_MAX, 420,
+ LM4_AIN_NONE, 0x0e /* TS0 | IE0 | END0 */, 0, 0},
+
+ /* IOUT == ICMNT is on PE3/AIN0 */
+ /* We have 0.01-ohm resistors, and IOUT is 20X the differential
+ * voltage, so 1000mA ==> 200mV.
+ * ADC returns 0x000-0xFFF, which maps to 0.0-3.3V (as configured).
+ * mA = 1000 * ADC_VALUE / ADC_READ_MAX * 3300 / 200
+ */
+ {"ChargerCurrent", LM4_ADC_SEQ1, 33000, ADC_READ_MAX * 2, 0,
+ LM4_AIN(0), 0x06 /* IE0 | END0 */, LM4_GPIO_E, (1<<3)},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
+const struct pwm_t pwm_channels[] = {
+ {4, PWM_CONFIG_ACTIVE_LOW},
+ {3, PWM_CONFIG_ACTIVE_LOW},
+ {0, PWM_CONFIG_ACTIVE_LOW},
+};
+
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+
+/* I2C ports */
+const struct i2c_port_t i2c_ports[] = {
+ {"batt_chg", 0, 100},
+ {"thermal", 5, 100},
+};
+const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+/* Temperature sensors data; must be in same order as enum temp_sensor_id. */
+const struct temp_sensor_t temp_sensors[] = {
+ {"ECInternal", TEMP_SENSOR_TYPE_BOARD, chip_temp_sensor_get_val, 0, 4},
+ {"TMP432_Internal", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
+ TMP432_IDX_LOCAL, 4},
+ {"TMP432_Power_top", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
+ TMP432_IDX_REMOTE1, 4},
+ {"TMP432_CPU_bottom", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
+ TMP432_IDX_REMOTE2, 4},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+/* Thermal limits for each temp sensor. All temps are in degrees K. Must be in
+ * same order as enum temp_sensor_id. To always ignore any temp, use 0.
+ */
+struct ec_thermal_config thermal_params[] = {
+ {{0, 0, 0}, 0, 0},
+ {{0, 0, 0}, 0, 0},
+ {{0, 0, 0}, 0, 0},
+ {{0, 0, 0}, 0, 0},
+};
+BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
diff --git a/board/squawks/board.h b/board/squawks/board.h
new file mode 100644
index 0000000000..af9f4a7208
--- /dev/null
+++ b/board/squawks/board.h
@@ -0,0 +1,182 @@
+/* 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.
+ */
+
+/* Configuration for Rambi mainboard */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+/* Optional features */
+#define CONFIG_AP_HANG_DETECT
+#define CONFIG_BACKLIGHT_LID
+#define CONFIG_BATTERY_SMART
+#define CONFIG_BOARD_VERSION
+#define CONFIG_CHARGER
+#define CONFIG_CHARGER_BQ24715
+#define CONFIG_CHARGER_INPUT_CURRENT 1700 /* 33 W adapter, 19 V, 1.75 A */
+#define CONFIG_CHARGER_SENSE_RESISTOR 10 /* Charge sense resistor, mOhm */
+#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 /* Input senso resistor, mOhm */
+#define CONFIG_CHIPSET_BAYTRAIL
+#define CONFIG_CHIPSET_CAN_THROTTLE
+#define CONFIG_CHIPSET_X86
+#define CONFIG_CMD_GSV
+#define CONFIG_EXTPOWER_GPIO
+#define CONFIG_KEYBOARD_COL2_INVERTED
+#define CONFIG_KEYBOARD_IRQ_GPIO GPIO_KBD_IRQ_L
+#define CONFIG_KEYBOARD_PROTOCOL_8042
+#define CONFIG_LED_COMMON
+#undef CONFIG_PECI
+#define CONFIG_POWER_BUTTON
+#define CONFIG_POWER_BUTTON_X86
+#define CONFIG_PWM
+#define CONFIG_SCI_GPIO GPIO_PCH_SCI_L
+#define CONFIG_TEMP_SENSOR
+#define CONFIG_TEMP_SENSOR_TMP432
+#define CONFIG_USB_PORT_POWER_SMART
+#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
+#define CONFIG_WIRELESS
+
+#ifndef __ASSEMBLER__
+
+/* I2C ports */
+#define I2C_PORT_BATTERY 0
+#define I2C_PORT_CHARGER 0
+#define I2C_PORT_THERMAL 5
+
+/* 13x8 keyboard scanner uses an entire GPIO bank for row inputs */
+#define KB_SCAN_ROW_IRQ LM4_IRQ_GPIOK
+#define KB_SCAN_ROW_GPIO LM4_GPIO_K
+
+/* Host connects to keyboard controller module via LPC */
+#define HOST_KB_BUS_LPC
+
+/* USB ports */
+#define USB_PORT_COUNT 2
+
+/* Wireless signals */
+#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L
+#define WIRELESS_GPIO_WWAN GPIO_PP3300_LTE_EN
+#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN
+
+/* GPIO signal definitions. */
+enum gpio_signal {
+ /* Inputs with interrupt handlers are first for efficiency */
+ GPIO_POWER_BUTTON_L = 0, /* Power button */
+ GPIO_LID_OPEN, /* Lid switch */
+ GPIO_AC_PRESENT, /* AC power present */
+ GPIO_PCH_SLP_S3_L, /* SLP_S3# signal from PCH */
+ GPIO_PCH_SLP_S4_L, /* SLP_S4# signal from PCH */
+ GPIO_PP1050_PGOOD, /* Power good on 1.05V */
+ GPIO_PP3300_PCH_PGOOD, /* Power good on 3.3V (PCH supply) */
+ GPIO_PP5000_PGOOD, /* Power good on 5V */
+ GPIO_S5_PGOOD, /* Power good on S5 supplies */
+ GPIO_VCORE_PGOOD, /* Power good on core VR */
+ GPIO_WP_L, /* Write protect input */
+ GPIO_JTAG_TCK, /* JTAG clock input */
+ GPIO_UART0_RX, /* UART0 RX input */
+
+ /* Other inputs */
+ GPIO_BOARD_VERSION1, /* Board version stuffing resistor 1 */
+ GPIO_BOARD_VERSION2, /* Board version stuffing resistor 2 */
+ GPIO_BOARD_VERSION3, /* Board version stuffing resistor 3 */
+ GPIO_PCH_SLP_SX_L, /* SLP_S0IX# signal from PCH */
+ GPIO_PCH_SUS_STAT_L, /* SUS_STAT# signal from PCH */
+ GPIO_PCH_SUSPWRDNACK, /* SUSPWRDNACK signal from PCH */
+ GPIO_PP1000_S0IX_PGOOD, /* Power good on 1.00V (S0iX supplies) */
+ GPIO_USB1_OC_L, /* USB port overcurrent warning */
+ GPIO_USB2_OC_L, /* USB port overcurrent warning */
+
+ /* Outputs */
+ GPIO_CPU_PROCHOT, /* Force CPU to think it's overheated */
+ GPIO_ENABLE_BACKLIGHT, /* Enable backlight power */
+ GPIO_ENABLE_TOUCHPAD, /* Enable touchpad power */
+ GPIO_ENTERING_RW, /* Indicate when EC is entering RW code */
+ GPIO_LPC_CLKRUN_L, /* Request that PCH drive LPC clock */
+ GPIO_PCH_CORE_PWROK, /* Indicate core well power is stable */
+ GPIO_PCH_PWRBTN_L, /* Power button output to PCH */
+ GPIO_PCH_RCIN_L, /* Reset line to PCH (for 8042 emulation) */
+ GPIO_PCH_RSMRST_L, /* Reset PCH resume power plane logic */
+ GPIO_PCH_SMI_L, /* System management interrupt to PCH */
+ GPIO_PCH_SOC_OVERRIDE, /* SOC override signal to PCH; when high, ME
+ * ignores security descriptor */
+ /*
+ * TODO(crosbug.com/p/24424): Remove old assignment and remove _NEW
+ * from the new one when we deprecate the 1.5 boards.
+ */
+ GPIO_PCH_SYS_PWROK, /* EC thinks everything is up and ready */
+ GPIO_PCH_WAKE_L, /* Wake signal from EC to PCH */
+ GPIO_PP1350_EN, /* Enable 1.35V supply */
+ GPIO_PP3300_DX_EN, /* Enable power to lots of peripherals */
+ GPIO_PP3300_LTE_EN, /* Enable LTE radio */
+ GPIO_PP3300_WLAN_EN, /* Enable WiFi power */
+ GPIO_PP5000_EN, /* Enable 5V supply */
+ GPIO_PPSX_EN, /* Enable PP1350_PCH_SX, PP1000_PCH_SX */
+ GPIO_SUSP_VR_EN, /* Enable 1.05V regulator */
+ GPIO_TOUCHSCREEN_RESET_L, /* Reset touch screen */
+ GPIO_USB_CTL1, /* USB control signal 1 to both ports */
+ GPIO_USB_ILIM_SEL, /* USB current limit to both ports */
+ GPIO_USB1_ENABLE, /* USB port 1 output power enable */
+ GPIO_USB2_ENABLE, /* USB port 2 output power enable */
+ GPIO_VCORE_EN, /* Enable core power supplies */
+ GPIO_WLAN_OFF_L, /* Disable WiFi radio */
+ GPIO_PCH_SCI_L, /* Assert SCI to PCH */
+ GPIO_KBD_IRQ_L, /* Negative edge triggered irq. */
+
+ /* Number of GPIOs; not an actual GPIO */
+ GPIO_COUNT
+};
+
+/* x86 signal definitions */
+enum x86_signal {
+ X86_PGOOD_PP1050 = 0,
+ X86_PGOOD_PP3300_PCH,
+ X86_PGOOD_PP5000,
+ X86_PGOOD_S5,
+ X86_PGOOD_VCORE,
+ X86_PGOOD_PP1000_S0IX,
+ X86_SLP_S3_DEASSERTED,
+ X86_SLP_S4_DEASSERTED,
+ X86_SLP_SX_DEASSERTED,
+ X86_SUS_STAT_ASSERTED,
+ X86_SUSPWRDNACK_ASSERTED,
+
+ /* Number of X86 signals */
+ X86_SIGNAL_COUNT
+};
+
+enum adc_channel {
+ /* EC internal die temperature in degrees K. */
+ ADC_CH_EC_TEMP = 0,
+
+ /* Charger current in mA. */
+ ADC_CH_CHARGER_CURRENT,
+
+ ADC_CH_COUNT
+};
+
+enum pwm_channel {
+ PWM_CH_LED_BATTERY_GREEN,
+ PWM_CH_LED_BATTERY_ORANGE,
+ PWM_CH_LED_POWER_GREEN,
+
+ /* Number of PWM channels */
+ PWM_CH_COUNT
+};
+
+enum temp_sensor_id {
+ /* EC internal temperature sensor */
+ TEMP_SENSOR_EC_INTERNAL = 0,
+
+ /* TMP432 local and remote sensors */
+ TEMP_SENSOR_I2C_TMP432_LOCAL,
+ TEMP_SENSOR_I2C_TMP432_REMOTE1,
+ TEMP_SENSOR_I2C_TMP432_REMOTE2,
+
+ TEMP_SENSOR_COUNT
+};
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __BOARD_H */
diff --git a/board/squawks/build.mk b/board/squawks/build.mk
new file mode 100644
index 0000000000..f771f4f0ec
--- /dev/null
+++ b/board/squawks/build.mk
@@ -0,0 +1,12 @@
+# -*- 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 TI Stellaris LM4
+CHIP:=lm4
+
+board-y=battery.o board.o led.o
diff --git a/board/squawks/ec.tasklist b/board/squawks/ec.tasklist
new file mode 100644
index 0000000000..c8284ec561
--- /dev/null
+++ b/board/squawks/ec.tasklist
@@ -0,0 +1,29 @@
+/* -*- c -*- */
+/* 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_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
+ * 'n' is the name of the task
+ * 'r' is the main routine of the task
+ * 'd' is 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(VBOOTHASH, vboot_hash_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(POWERBTN, power_button_task, NULL, TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE)
diff --git a/board/squawks/led.c b/board/squawks/led.c
new file mode 100644
index 0000000000..c65d4c02fc
--- /dev/null
+++ b/board/squawks/led.c
@@ -0,0 +1,163 @@
+/* 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.
+ *
+ * Battery LED control for Rambi
+ */
+
+#include "charge_state.h"
+#include "chipset.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "led_common.h"
+#include "lid_switch.h"
+#include "pwm.h"
+#include "util.h"
+
+const enum ec_led_id supported_led_ids[] = {
+ EC_LED_ID_BATTERY_LED, EC_LED_ID_POWER_LED};
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+enum led_color {
+ LED_OFF = 0,
+ LED_ORANGE,
+ LED_GREEN,
+};
+
+/**
+ * Set battery LED color
+ *
+ * @param color Enumerated color value
+ */
+static void set_battery_led_color(enum led_color color)
+{
+ pwm_set_duty(PWM_CH_LED_BATTERY_ORANGE, color == LED_ORANGE ? 100 : 0);
+ pwm_set_duty(PWM_CH_LED_BATTERY_GREEN, color == LED_GREEN ? 100 : 0);
+}
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ if (led_id == EC_LED_ID_POWER_LED) {
+ brightness_range[EC_LED_COLOR_GREEN] = 100;
+ } else {
+ brightness_range[EC_LED_COLOR_RED] = 100;
+ brightness_range[EC_LED_COLOR_GREEN] = 100;
+ }
+}
+
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
+{
+ if (led_id == EC_LED_ID_POWER_LED) {
+ pwm_set_duty(PWM_CH_LED_BATTERY_GREEN,
+ brightness[EC_LED_COLOR_GREEN]);
+ } else {
+ pwm_set_duty(PWM_CH_LED_BATTERY_ORANGE,
+ brightness[EC_LED_COLOR_RED]);
+ pwm_set_duty(PWM_CH_LED_BATTERY_GREEN,
+ brightness[EC_LED_COLOR_GREEN]);
+ }
+ return EC_SUCCESS;
+}
+
+static void led_init(void)
+{
+ /* Configure GPIOs */
+ gpio_config_module(MODULE_PWM_LED, 1);
+
+ /*
+ * Enable PWMs and set to 0% duty cycle. If they're disabled, the LM4
+ * seems to ground the pins instead of letting them float.
+ */
+ pwm_enable(PWM_CH_LED_BATTERY_ORANGE, 1);
+ pwm_enable(PWM_CH_LED_BATTERY_GREEN, 1);
+ pwm_enable(PWM_CH_LED_POWER_GREEN, 1);
+ pwm_set_duty(PWM_CH_LED_POWER_GREEN, 0);
+ set_battery_led_color(LED_OFF);
+}
+DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_DEFAULT);
+
+/**
+ * Return new duty cycle for power LED (0-100).
+ */
+static int new_power_led_brightness(void)
+{
+ static unsigned ticks;
+ static int suspended_prev;
+
+ int suspended = chipset_in_state(CHIPSET_STATE_SUSPEND);
+
+ /* If we're just suspending now, reset ticks so LED changes quickly */
+ if (suspended && !suspended_prev)
+ ticks = 0;
+ else
+ ticks++;
+
+ suspended_prev = suspended;
+
+ /* If lid is closed, LED is off in all chipset states */
+ if (!lid_is_open())
+ return 0;
+
+ /* If chipset is on, LED is on */
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ return 100;
+
+ /* If chipset isn't on or suspended, it's off; LED is off */
+ if (!chipset_in_state(CHIPSET_STATE_SUSPEND))
+ return 0;
+
+ /* Suspended. Blink with 25% duty cycle, 2 sec period */
+ return (ticks % 8 < 2) ? 100 : 0;
+}
+
+/**
+ * Return new color for battery LED.
+ */
+static enum led_color new_battery_led_color(void)
+{
+ static unsigned ticks;
+
+ int chstate = charge_get_state();
+
+ ticks++;
+
+ /* If charging error, blink orange, 50% duty cycle, 0.5 sec period */
+ if (chstate == PWR_STATE_ERROR)
+ return (ticks & 0x1) ? LED_ORANGE : LED_OFF;
+
+ /* If charge-force-idle, blink green, 50% duty cycle, 2 sec period */
+ if (chstate == PWR_STATE_IDLE &&
+ (charge_get_flags() & CHARGE_FLAG_FORCE_IDLE))
+ return (ticks & 0x4) ? LED_GREEN : LED_OFF;
+
+ /* If the system is charging, orange under 95%; green if over */
+ if (chstate == PWR_STATE_CHARGE)
+ return charge_get_percent() < 95 ? LED_ORANGE : LED_GREEN;
+
+ /* If AC connected and fully charged (or close to it), solid green */
+ if (chstate == PWR_STATE_CHARGE_NEAR_FULL ||
+ chstate == PWR_STATE_IDLE) {
+ return LED_GREEN;
+ }
+
+ /* Otherwise, discharging; flash orange if less than 10% power */
+ if (charge_get_percent() < 10)
+ return (ticks % 8 < 2) ? LED_ORANGE : LED_OFF;
+
+ /* Discharging and greater than 10% power, so off */
+ return LED_OFF;
+}
+
+/**
+ * Called by hook task every 250 ms
+ */
+static void led_tick(void)
+{
+ if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
+ pwm_set_duty(PWM_CH_LED_POWER_GREEN,
+ new_power_led_brightness());
+
+ if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
+ set_battery_led_color(new_battery_led_color());
+}
+DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
diff --git a/chip/lm4/openocd/lm4x_cmds.tcl b/chip/lm4/openocd/lm4x_cmds.tcl
index 98c7f503c7..962ee9f033 100644
--- a/chip/lm4/openocd/lm4x_cmds.tcl
+++ b/chip/lm4/openocd/lm4x_cmds.tcl
@@ -35,7 +35,6 @@ proc flash_rambi { } {
flash_lm4 ../../../build/rambi/ec.bin 0
}
-# 128KB images
proc flash_samus { } {
flash_lm4 ../../../build/samus/ec.bin 0
}
@@ -48,6 +47,14 @@ proc flash_samus_rw { } {
flash_lm4 ../../../build/samus/ec.RW.bin 131072
}
+proc flash_squawks { } {
+ flash_lm4 ../../../build/squawks/ec.bin 0
+}
+
+proc flash_squawks_ro { } {
+ flash_lm4 ../../../build/squawks/ec.RO.flat 0
+}
+
proc flash_falco { } {
flash_lm4 ../../../build/falco/ec.bin 0
}
diff --git a/util/flash_ec b/util/flash_ec
index 055d69b6cc..9a64bde8c4 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -222,8 +222,8 @@ fi
save="$(servo_save)"
case "${BOARD}" in
- pit | snow | spring | discovery | nyan ) flash_stm32 ;;
- samus | falco | peppy | rambi ) flash_lm4 ;;
+ discovery | nyan | pit | snow | spring ) flash_stm32 ;;
+ falco | peppy | rambi | samus | squawks ) flash_lm4 ;;
link ) flash_link ;;
*) die "board ${BOARD} not supported" ;;
esac