summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsu Henry <Henry.Hsu@quantatw.com>2015-02-12 09:47:22 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-18 16:09:51 +0000
commit2db6e41b3eee8bc8d66213eb6e2fb2520974d06d (patch)
tree95276d6e3811d504e97338d082a4cf944232b722
parent80dde2c452b4cf58637ad8eb7c206bd7553ac668 (diff)
downloadchrome-ec-2db6e41b3eee8bc8d66213eb6e2fb2520974d06d.tar.gz
Banjo: Init board
Copy gnawty setting to init board. BUG=none BRANCH=banjo TEST=Run "make BOARD=banjo" and "make buildall -j" to build code and ec.bin can be generated. Change-Id: I627bb46f5dca0a4e1f76b09ed9103b9a15d5b9b9 Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/248950 Tested-by: Katherine Hsieh <Katherine.Hsieh@quantatw.com> Reviewed-by: Mohammed Habibulla <moch@google.com> Commit-Queue: David Wu <david_wu@quantatw.com>
-rw-r--r--board/banjo/battery.c63
-rw-r--r--board/banjo/board.c225
-rw-r--r--board/banjo/board.h200
-rw-r--r--board/banjo/build.mk12
-rw-r--r--board/banjo/ec.tasklist28
-rw-r--r--board/banjo/led.c187
-rw-r--r--chip/lm4/openocd/lm4x_cmds.tcl12
-rwxr-xr-xutil/flash_ec1
8 files changed, 728 insertions, 0 deletions
diff --git a/board/banjo/battery.c b/board/banjo/battery.c
new file mode 100644
index 0000000000..af5c275e05
--- /dev/null
+++ b/board/banjo/battery.c
@@ -0,0 +1,63 @@
+/* Copyright (c) 2015 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
+
+static const struct battery_info info = {
+ .voltage_max = 12900, /* mV */
+ .voltage_normal = 11400,
+ .voltage_min = 9000,
+ .precharge_current = 256, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 75,
+};
+
+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_ERROR : EC_RES_SUCCESS;
+}
+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/banjo/board.c b/board/banjo/board.c
new file mode 100644
index 0000000000..139df09457
--- /dev/null
+++ b/board/banjo/board.c
@@ -0,0 +1,225 @@
+/* Copyright (c) 2015 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 Banjo board configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "backlight.h"
+#include "charge_state.h"
+#include "charger.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.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,
+ power_signal_interrupt},
+ {"PCH_SLP_S4_L", LM4_GPIO_H, (1<<1), GPIO_INT_BOTH_DSLEEP |
+ GPIO_PULL_UP,
+ power_signal_interrupt},
+ {"PP1050_PGOOD", LM4_GPIO_H, (1<<4), GPIO_INT_BOTH,
+ power_signal_interrupt},
+ {"PP3300_PCH_PGOOD", LM4_GPIO_C, (1<<4), GPIO_INT_BOTH,
+ power_signal_interrupt},
+ {"PP5000_PGOOD", LM4_GPIO_N, (1<<0), GPIO_INT_BOTH,
+ power_signal_interrupt},
+ {"S5_PGOOD", LM4_GPIO_G, (1<<0), GPIO_INT_BOTH,
+ power_signal_interrupt},
+ {"VCORE_PGOOD", LM4_GPIO_C, (1<<6), GPIO_INT_BOTH,
+ power_signal_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},
+#ifdef CONFIG_CHIPSET_DEBUG
+ {"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},
+#endif
+ {"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_J, (1<<1), 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, 0x54, 1, MODULE_PWM_LED, GPIO_OPEN_DRAIN}, /* FAN0PWM 0&3&4 */
+ {GPIO_M, 0x40, 1, MODULE_PWM_LED, GPIO_OPEN_DRAIN}, /* FAN0PWM 2 */
+};
+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_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"},
+#ifdef CONFIG_CHIPSET_DEBUG
+ {GPIO_PCH_SLP_SX_L, 1, "SLP_SX#_DEASSERTED"},
+ {GPIO_PCH_SUS_STAT_L, 0, "SUS_STAT#_ASSERTED"},
+ {GPIO_PCH_SUSPWRDNACK, 1, "SUSPWRDNACK_ASSERTED"},
+#endif
+};
+BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_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 40X the differential
+ * voltage, so 1000mA ==> 400mV.
+ * ADC returns 0x000-0xFFF, which maps to 0.0-3.3V (as configured).
+ * mA = 1000 * ADC_VALUE / ADC_READ_MAX * 3300 / 400
+ */
+ {"ChargerCurrent", LM4_ADC_SEQ1, 33000, ADC_READ_MAX * 4, 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},
+ {2, 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.
+ * Sensor index and name must match those present in coreboot:
+ * src/mainboard/google/${board}/acpi/dptf.asl
+ * TMP432_Internal_bot of location on PCB BOT.
+ * TMP432_Power_bot of location on PCB BOT.
+ * TMP432_CPU_bot of location on PCB BOT.
+ */
+const struct temp_sensor_t temp_sensors[] = {
+ {"ECInternal", TEMP_SENSOR_TYPE_BOARD, chip_temp_sensor_get_val, 0, 4},
+ {"TMP432_Internal_bot", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
+ TMP432_IDX_LOCAL, 4},
+ {"TMP432_Power_bot", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
+ TMP432_IDX_REMOTE1, 4},
+ {"TMP432_CPU_bot", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val,
+ TMP432_IDX_REMOTE2, 4},
+ {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_temp_sensor_get_val, 0, 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},
+ {{0, 0, 0}, 0, 0},
+};
+BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
+
+/**
+ * Discharge battery when on AC power for factory test.
+ */
+int board_discharge_on_ac(int enable)
+{
+ return charger_discharge_on_ac(enable);
+}
diff --git a/board/banjo/board.h b/board/banjo/board.h
new file mode 100644
index 0000000000..20f086ee3e
--- /dev/null
+++ b/board/banjo/board.h
@@ -0,0 +1,200 @@
+/* Copyright (c) 2015 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 Banjo mainboard */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+/* Optional features */
+#define CONFIG_AP_HANG_DETECT
+#define CONFIG_BACKLIGHT_LID
+#define CONFIG_BATTERY_LEVEL_CRITICAL 7
+#define CONFIG_BATTERY_LEVEL_LOW 13
+#define CONFIG_BATTERY_LEVEL_NEAR_FULL 95
+#define CONFIG_BATTERY_SMART
+#define CONFIG_BOARD_VERSION
+#define CONFIG_CHARGER
+#define CONFIG_CHARGER_BQ24715
+#define CONFIG_CHARGER_DISCHARGE_ON_AC
+#define CONFIG_CHARGER_INPUT_CURRENT 2176 /* 45 W adapter, 19 V, 2A */
+#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_I2C_PASSTHRU_RESTRICTED
+#define CONFIG_KEYBOARD_COL2_INVERTED
+#define CONFIG_KEYBOARD_IRQ_GPIO GPIO_KBD_IRQ_L
+#define CONFIG_KEYBOARD_PROTOCOL_8042
+#define CONFIG_LED_COMMON
+#define CONFIG_LOW_POWER_IDLE
+#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_IN_S3
+#define CONFIG_USB_PORT_POWER_SMART
+#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_CDP
+#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
+#define CONFIG_VBOOT_HASH
+#define CONFIG_WIRELESS
+#define CONFIG_WIRELESS_SUSPEND \
+ (EC_WIRELESS_SWITCH_WLAN | EC_WIRELESS_SWITCH_WLAN_POWER)
+
+#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 */
+#ifdef CONFIG_CHIPSET_DEBUG
+ 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 */
+#endif
+ 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 */
+ 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
+};
+
+/* power signal definitions */
+enum power_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,
+#ifdef CONFIG_CHIPSET_DEBUG
+ X86_SLP_SX_DEASSERTED,
+ X86_SUS_STAT_ASSERTED,
+ X86_SUSPWRDNACK_ASSERTED,
+#endif
+
+ /* Number of X86 signals */
+ POWER_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_BLUE,
+ PWM_CH_LED_ORANGE,
+ PWM_CH_LED_BLUE_POWER_LED,
+ PWM_CH_LED_ORANGE_POWER_LED,
+
+ /* 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,
+
+ /* Battery temperature sensor */
+ TEMP_SENSOR_BATTERY,
+
+ TEMP_SENSOR_COUNT
+};
+
+/* Discharge battery when on AC power for factory test. */
+int board_discharge_on_ac(int enable);
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __BOARD_H */
diff --git a/board/banjo/build.mk b/board/banjo/build.mk
new file mode 100644
index 0000000000..d05ff6ff60
--- /dev/null
+++ b/board/banjo/build.mk
@@ -0,0 +1,12 @@
+# -*- makefile -*-
+# Copyright (c) 2015 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/banjo/ec.tasklist b/board/banjo/ec.tasklist
new file mode 100644
index 0000000000..062500cef8
--- /dev/null
+++ b/board/banjo/ec.tasklist
@@ -0,0 +1,28 @@
+/* -*- c -*- */
+/* Copyright (c) 2015 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_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/banjo/led.c b/board/banjo/led.c
new file mode 100644
index 0000000000..51c816906a
--- /dev/null
+++ b/board/banjo/led.c
@@ -0,0 +1,187 @@
+/* Copyright (c) 2015 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 Banjo
+ */
+
+#include "charge_state.h"
+#include "chipset.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "led_common.h"
+#include "pwm.h"
+#include "util.h"
+#include "extpower.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_RED,
+ LED_YELLOW,
+ LED_BLUE,
+
+ /* Number of colors, not a color itself */
+ LED_COLOR_COUNT
+};
+
+/* Brightness vs. color, for {red, green} LEDs */
+static const uint8_t color_brightness[LED_COLOR_COUNT][2] = {
+ {0, 0},
+ {100, 0},
+ {30, 45},
+ {20, 60},
+ {0, 100},
+};
+
+/**
+ * Set LED color
+ *
+ * @param color Enumerated color value
+ */
+static void set_color_battery_led(enum led_color color)
+{
+ pwm_set_duty(PWM_CH_LED_ORANGE, color_brightness[color][0]);
+ pwm_set_duty(PWM_CH_LED_BLUE, color_brightness[color][1]);
+}
+
+static void set_color_power_led(enum led_color color)
+{
+ pwm_set_duty(PWM_CH_LED_ORANGE_POWER_LED, color_brightness[color][0]);
+ pwm_set_duty(PWM_CH_LED_BLUE_POWER_LED, color_brightness[color][1]);
+}
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ brightness_range[EC_LED_COLOR_YELLOW] = 100;
+ brightness_range[EC_LED_COLOR_BLUE] = 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_BLUE_POWER_LED,
+ brightness[EC_LED_COLOR_BLUE]);
+ pwm_set_duty(PWM_CH_LED_ORANGE_POWER_LED,
+ brightness[EC_LED_COLOR_YELLOW]);
+ } else {
+ pwm_set_duty(PWM_CH_LED_BLUE,
+ brightness[EC_LED_COLOR_BLUE]);
+ pwm_set_duty(PWM_CH_LED_ORANGE,
+ brightness[EC_LED_COLOR_YELLOW]);
+ }
+ 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_ORANGE, 1);
+ pwm_enable(PWM_CH_LED_BLUE, 1);
+ pwm_enable(PWM_CH_LED_ORANGE_POWER_LED, 1);
+ pwm_enable(PWM_CH_LED_BLUE_POWER_LED, 1);
+ set_color_battery_led(LED_OFF);
+ set_color_power_led(LED_OFF);
+}
+DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_DEFAULT);
+
+/**
+ * Called by hook task every 250 ms
+ */
+static void power_led(void)
+{
+ static unsigned power_ticks;
+ static int previous_state_suspend;
+
+ power_ticks++;
+
+ /* If we don't control the LED, nothing to do */
+ if (!led_auto_control_is_enabled(EC_LED_ID_POWER_LED))
+ return;
+
+ if (chipset_in_state(CHIPSET_STATE_SUSPEND)) {
+ if (!previous_state_suspend)
+ power_ticks = 0;
+
+ /* If chipset state in suspend, blink orange, 25% duty cycle,
+ * 4 sec period.
+ */
+ set_color_power_led((power_ticks % 16) < 4 ?
+ LED_ORANGE : LED_OFF);
+ previous_state_suspend = 1;
+ return;
+ }
+
+ previous_state_suspend = 0;
+
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ set_color_power_led(LED_OFF);
+ else if (chipset_in_state(CHIPSET_STATE_ON))
+ set_color_power_led(LED_BLUE);
+
+}
+
+static void battery_led(void)
+{
+ struct batt_params batt;
+ static unsigned battery_ticks;
+ int chstate = charge_get_state();
+ battery_ticks++;
+
+ battery_get_params(&batt);
+ /* If we don't control the LED, nothing to do */
+ if (!led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
+ return;
+
+ /* If Battery critical Low, blink orange, 50% duty cycle,
+ * 2 sec period.
+ */
+ if (!extpower_is_present() && chipset_in_state(CHIPSET_STATE_ON) &&
+ (batt.state_of_charge <= CONFIG_BATTERY_LEVEL_CRITICAL)) {
+ set_color_battery_led((battery_ticks & 0x4) ?
+ LED_ORANGE : LED_OFF);
+ return;
+ }
+
+ /* If Battery Low, blink orange, 25% duty cycle, 4 sec period */
+ if (!extpower_is_present() && chipset_in_state(CHIPSET_STATE_ON) &&
+ (batt.state_of_charge <= CONFIG_BATTERY_LEVEL_LOW)) {
+ set_color_battery_led((battery_ticks % 16) < 4 ?
+ LED_ORANGE : LED_OFF);
+ return;
+ }
+
+ /* If the system is charging, solid orange */
+ if (chstate == PWR_STATE_CHARGE) {
+ set_color_battery_led(LED_ORANGE);
+ return;
+ }
+
+ /* If AC connected and fully charged (or close to it), solid blue */
+ if (chstate == PWR_STATE_CHARGE_NEAR_FULL ||
+ chstate == PWR_STATE_IDLE) {
+ set_color_battery_led(LED_BLUE);
+ return;
+ }
+
+ /* Otherwise, system is off and AC not connected, LED off */
+ set_color_battery_led(LED_OFF);
+}
+
+static void led_tick(void)
+{
+ battery_led();
+ power_led();
+}
+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 9c8f5e73d3..872fee3b3d 100644
--- a/chip/lm4/openocd/lm4x_cmds.tcl
+++ b/chip/lm4/openocd/lm4x_cmds.tcl
@@ -223,6 +223,18 @@ proc flash_candy_rw { } {
flash_lm4 ../../../build/candy/ec.RW.bin 131072
}
+proc flash_banjo { } {
+ flash_lm4 ../../../build/banjo/ec.bin 0
+}
+
+proc flash_banjo_ro { } {
+ flash_lm4 ../../../build/banjo/ec.RO.flat 0
+}
+
+proc flash_banjo_rw { } {
+ flash_lm4 ../../../build/banjo/ec.RW.bin 131072
+}
+
# link has pstate in last sector
proc unprotect_link { } {
reset halt
diff --git a/util/flash_ec b/util/flash_ec
index f536d65422..da6534cf16 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -9,6 +9,7 @@ COMMON_SH=/usr/lib/crosutils/common.sh
# Note: Link is a special case and is not included here.
BOARDS_LM4=(
+ banjo
clapper
cranky
candy