summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-04-24 17:55:01 -0700
committerRandall Spangler <rspangler@chromium.org>2012-04-24 18:34:46 -0700
commit470916fb0f856945f2a93c7fd160845b5f659be1 (patch)
tree18652a5cff68223ec72650afc12e1e2e727c8529
parent135f14bf498ab19b6e75efc3a0d18ef7c8a8752d (diff)
downloadchrome-ec-470916fb0f856945f2a93c7fd160845b5f659be1.tar.gz
Use console output instead of uart output for console commands
This completes console output cleanup. The remaining calls to uart_puts() and uart_printf() actually need to be that way. Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:7464 TEST=manual Change-Id: Ib1d6d370d30429017b3d11994894fece75fab6ea
-rw-r--r--board/bds/dummy_charger.c32
-rw-r--r--chip/lm4/adc.c8
-rw-r--r--chip/lm4/clock.c11
-rw-r--r--chip/lm4/eeprom.c39
-rw-r--r--chip/lm4/i2c.c29
-rw-r--r--chip/lm4/peci.c7
-rw-r--r--chip/lm4/pwm.c53
-rw-r--r--chip/lm4/uart.c4
-rw-r--r--chip/stm32l/dma.c19
-rw-r--r--chip/stm32l/gpio.c10
-rw-r--r--chip/stm32l/i2c.c27
-rw-r--r--common/charger_bq24725.c31
-rw-r--r--common/console.c16
-rw-r--r--common/eoption.c17
-rw-r--r--common/flash_commands.c66
-rw-r--r--common/gaia_power.c11
-rw-r--r--common/gpio_commands.c21
-rw-r--r--common/host_event_commands.c29
-rw-r--r--common/keyboard.c4
-rw-r--r--common/memory_commands.c14
-rw-r--r--common/port80.c2
-rw-r--r--common/power_led.c9
-rw-r--r--common/pstore_commands.c5
-rw-r--r--common/smart_battery.c83
-rw-r--r--common/temp_sensor.c10
-rw-r--r--common/thermal.c59
-rw-r--r--common/tmp006.c20
-rw-r--r--common/usb_charge.c20
-rw-r--r--common/vboot.c10
-rw-r--r--common/x86_power.c4
-rw-r--r--core/cortex-m/timer.c18
-rw-r--r--include/console.h6
32 files changed, 348 insertions, 346 deletions
diff --git a/board/bds/dummy_charger.c b/board/bds/dummy_charger.c
index c4ee308e1c..836b3b6cf9 100644
--- a/board/bds/dummy_charger.c
+++ b/board/bds/dummy_charger.c
@@ -7,7 +7,6 @@
#include "charger.h"
#include "console.h"
#include "i2c.h"
-#include "uart.h"
#include "util.h"
/* Address of battery charger */
@@ -29,57 +28,58 @@ static int command_charger(int argc, char **argv)
int rv;
int d;
- uart_puts("Reading battery charger...\n");
+ ccputs("Reading battery charger...\n");
rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0xfe, &d);
if (rv)
return rv;
- uart_printf(" Manufacturer ID: 0x%04x\n", d);
+ ccprintf(" Manufacturer ID: 0x%04x\n", d);
rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0xff, &d);
- uart_printf(" Device ID: 0x%04x\n", d);
+ ccprintf(" Device ID: 0x%04x\n", d);
rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x12, &d);
- uart_printf(" Option: 0x%04x\n", d);
+ ccprintf(" Option: 0x%04x\n", d);
rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x14, &d);
- uart_printf(" Charge current: 0x%04x\n", d);
+ ccprintf(" Charge current: 0x%04x\n", d);
rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x15, &d);
- uart_printf(" Charge voltage: 0x%04x\n", d);
+ ccprintf(" Charge voltage: 0x%04x\n", d);
rv = i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, 0x3f, &d);
- uart_printf(" Input current: 0x%04x\n", d);
+ ccprintf(" Input current: 0x%04x\n", d);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(charger, command_charger);
+
static int command_battery(int argc, char **argv)
{
int rv;
int d;
- uart_puts("Reading battery...\n");
+ ccputs("Reading battery...\n");
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x08, &d);
if (rv)
return rv;
- uart_printf(" Temperature: 0x%04x = %d C\n",
- d, (d-2731)/10);
+ ccprintf(" Temperature: 0x%04x = %d C\n",
+ d, (d-2731)/10);
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x09, &d);
- uart_printf(" Voltage: 0x%04x = %d mV\n", d, d);
+ ccprintf(" Voltage: 0x%04x = %d mV\n", d, d);
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x0f, &d);
- uart_printf(" Remaining capacity: 0x%04x = %d mAh\n", d, d);
+ ccprintf(" Remaining capacity: 0x%04x = %d mAh\n", d, d);
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x10, &d);
- uart_printf(" Full charge capacity: 0x%04x = %d mAh\n", d, d);
+ ccprintf(" Full charge capacity: 0x%04x = %d mAh\n", d, d);
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x14, &d);
- uart_printf(" Desired charge current: 0x%04x = %d mA\n", d, d);
+ ccprintf(" Desired charge current: 0x%04x = %d mA\n", d, d);
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, 0x15, &d);
- uart_printf(" Desired charge voltage: 0x%04x = %d mV\n", d, d);
+ ccprintf(" Desired charge voltage: 0x%04x = %d mV\n", d, d);
return EC_SUCCESS;
diff --git a/chip/lm4/adc.c b/chip/lm4/adc.c
index 18f8dbe3a7..d265d0f283 100644
--- a/chip/lm4/adc.c
+++ b/chip/lm4/adc.c
@@ -13,7 +13,6 @@
#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
extern const struct adc_t adc_channels[ADC_CH_COUNT];
@@ -181,7 +180,7 @@ DECLARE_IRQ(LM4_IRQ_ADC0_SS3, ss3_interrupt, 2);
static int command_ectemp(int argc, char **argv)
{
int t = adc_read_channel(ADC_CH_EC_TEMP);
- uart_printf("EC temperature is %d K = %d C\n", t, t-273);
+ ccprintf("EC temperature is %d K = %d C\n", t, t-273);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(ectemp, command_ectemp);
@@ -192,9 +191,8 @@ static int command_adc(int argc, char **argv)
int i;
for (i = 0; i < ADC_CH_COUNT; ++i)
- uart_printf("ADC channel \"%s\" = %d\n",
- adc_channels[i].name,
- adc_read_channel(i));
+ ccprintf("ADC channel \"%s\" = %d\n",
+ adc_channels[i].name, adc_read_channel(i));
return EC_SUCCESS;
}
diff --git a/chip/lm4/clock.c b/chip/lm4/clock.c
index 84608f7ee7..81e36c001e 100644
--- a/chip/lm4/clock.c
+++ b/chip/lm4/clock.c
@@ -15,7 +15,6 @@
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
#define PLL_CLOCK 66666667 /* System clock = 200MHz PLL/3 = 66.667MHz */
@@ -113,8 +112,8 @@ static int command_sleep(int argc, char **argv)
gpio_set_level(GPIO_DEBUG_LED, 0);
#endif
- uart_printf("Going to sleep : level %d clock %d...\n", level, clock);
- uart_flush_output();
+ ccprintf("Going to sleep : level %d clock %d...\n", level, clock);
+ cflush();
/* clock setting */
if (clock) {
@@ -161,8 +160,8 @@ static int command_sleep(int argc, char **argv)
}
if (uartfbrd) {
- uart_printf("We are still alive. RCC=%08x\n", LM4_SYSTEM_RCC);
- uart_flush_output();
+ ccprintf("We are still alive. RCC=%08x\n", LM4_SYSTEM_RCC);
+ cflush();
}
asm volatile("cpsid i");
@@ -195,7 +194,7 @@ static int command_pll(int argc, char **argv)
{
/* Toggle the PLL */
clock_enable_pll(LM4_SYSTEM_RCC & LM4_SYSTEM_RCC_BYPASS ? 1 : 0);
- uart_printf("Clock frequency is now %d\n", clock_get_freq());
+ ccprintf("Clock frequency is now %d\n", clock_get_freq());
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(pll, command_pll);
diff --git a/chip/lm4/eeprom.c b/chip/lm4/eeprom.c
index c605d0e560..f5783ad664 100644
--- a/chip/lm4/eeprom.c
+++ b/chip/lm4/eeprom.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -7,7 +7,6 @@
#include "eeprom.h"
#include "console.h"
-#include "uart.h"
#include "registers.h"
#include "util.h"
@@ -120,9 +119,9 @@ int eeprom_hide(int block)
static int command_eeprom_info(int argc, char **argv)
{
- uart_printf("EEPROM: %d blocks of %d bytes\n",
- eeprom_get_block_count(), eeprom_get_block_size());
- uart_printf(" Block-hide flags: 0x%08x\n", LM4_EEPROM_EEHIDE);
+ ccprintf("EEPROM: %d blocks of %d bytes\n",
+ eeprom_get_block_count(), eeprom_get_block_size());
+ ccprintf(" Block-hide flags: 0x%08x\n", LM4_EEPROM_EEHIDE);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(eeinfo, command_eeprom_info);
@@ -137,28 +136,27 @@ static int command_eeprom_read(int argc, char **argv)
uint32_t d;
if (argc < 2) {
- uart_puts("Usage: eeread <block> [offset]\n");
+ ccputs("Usage: eeread <block> [offset]\n");
return EC_ERROR_UNKNOWN;
}
block = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid block\n");
+ ccputs("Invalid block\n");
return EC_ERROR_UNKNOWN;
}
if (argc > 2) {
offset = strtoi(argv[2], &e, 0);
if (*e) {
- uart_puts("Invalid offset\n");
+ ccputs("Invalid offset\n");
return EC_ERROR_UNKNOWN;
}
}
rv = eeprom_read(block, offset, sizeof(d), (char *)&d);
if (rv == EC_SUCCESS)
- uart_printf("Block %d offset %d = 0x%08x\n",
- block, offset, d);
+ ccprintf("Block %d offset %d = 0x%08x\n", block, offset, d);
return rv;
}
DECLARE_CONSOLE_COMMAND(eeread, command_eeprom_read);
@@ -173,31 +171,30 @@ static int command_eeprom_write(int argc, char **argv)
uint32_t d;
if (argc < 4) {
- uart_puts("Usage: eeread <block> <offset> <data>\n");
+ ccputs("Usage: eeread <block> <offset> <data>\n");
return EC_ERROR_UNKNOWN;
}
block = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid block\n");
+ ccputs("Invalid block\n");
return EC_ERROR_UNKNOWN;
}
offset = strtoi(argv[2], &e, 0);
if (*e) {
- uart_puts("Invalid offset\n");
+ ccputs("Invalid offset\n");
return EC_ERROR_UNKNOWN;
}
d = strtoi(argv[3], &e, 0);
if (*e) {
- uart_puts("Invalid data\n");
+ ccputs("Invalid data\n");
return EC_ERROR_UNKNOWN;
}
- uart_printf("Writing 0x%08x to block %d offset %d...\n",
- d, block, offset);
+ ccprintf("Writing 0x%08x to block %d offset %d...\n", d, block, offset);
rv = eeprom_write(block, offset, sizeof(d), (char *)&d);
if (rv == EC_SUCCESS)
- uart_puts("done.\n");
+ ccputs("done.\n");
return rv;
}
DECLARE_CONSOLE_COMMAND(eewrite, command_eeprom_write);
@@ -210,20 +207,20 @@ static int command_eeprom_hide(int argc, char **argv)
int rv;
if (argc < 2) {
- uart_puts("Usage: eehide <block>\n");
+ ccputs("Usage: eehide <block>\n");
return EC_ERROR_UNKNOWN;
}
block = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid block\n");
+ ccputs("Invalid block\n");
return EC_ERROR_UNKNOWN;
}
- uart_printf("Hiding EEPROM block %d...\n", block);
+ ccprintf("Hiding EEPROM block %d...\n", block);
rv = eeprom_hide(block);
if (rv == EC_SUCCESS)
- uart_printf("Done.\n");
+ ccprintf("Done.\n");
return rv;
}
DECLARE_CONSOLE_COMMAND(eehide, command_eeprom_hide);
diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c
index 8a5a93b3c8..7daf585a2e 100644
--- a/chip/lm4/i2c.c
+++ b/chip/lm4/i2c.c
@@ -14,7 +14,6 @@
#include "task.h"
#include "timer.h"
#include "registers.h"
-#include "uart.h"
#include "util.h"
#define NUM_PORTS 6
@@ -318,24 +317,24 @@ static void scan_bus(int port, char *desc)
int rv;
int a;
- uart_printf("Scanning %s I2C bus (%d)...\n", desc, port);
+ ccprintf("Scanning %s I2C bus (%d)...\n", desc, port);
mutex_lock(port_mutex + port);
for (a = 0; a < 0x100; a += 2) {
- uart_puts(".");
+ ccputs(".");
/* Do a single read */
LM4_I2C_MSA(port) = a | 0x01;
LM4_I2C_MCS(port) = 0x07;
rv = wait_idle(port);
if (rv == EC_SUCCESS)
- uart_printf("\nFound device at 8-bit addr 0x%02x\n", a);
+ ccprintf("\nFound device at 8-bit addr 0x%02x\n", a);
}
mutex_unlock(port_mutex + port);
- uart_puts("\n");
+ ccputs("\n");
}
@@ -347,37 +346,37 @@ static int command_i2cread(int argc, char **argv)
int d, i;
if (argc < 3) {
- uart_puts("Usage: i2cread <port> <addr> [count]\n");
+ ccputs("Usage: i2cread <port> <addr> [count]\n");
return EC_ERROR_UNKNOWN;
}
port = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid port\n");
+ ccputs("Invalid port\n");
return EC_ERROR_INVAL;
}
if (port != I2C_PORT_THERMAL && port != I2C_PORT_BATTERY &&
port != I2C_PORT_CHARGER) {
- uart_puts("Unsupported port\n");
+ ccputs("Unsupported port\n");
return EC_ERROR_UNKNOWN;
}
addr = strtoi(argv[2], &e, 0);
if (*e || (addr & 0x01)) {
- uart_puts("Invalid addr; try 'i2cscan' command\n");
+ ccputs("Invalid addr; try 'i2cscan' command\n");
return EC_ERROR_INVAL;
}
if (argc > 3) {
count = strtoi(argv[3], &e, 0);
if (*e) {
- uart_puts("Invalid count\n");
+ ccputs("Invalid count\n");
return EC_ERROR_INVAL;
}
}
- uart_printf("Reading %d bytes from I2C device %d:0x%02x...\n",
- count, port, addr);
+ ccprintf("Reading %d bytes from I2C device %d:0x%02x...\n",
+ count, port, addr);
mutex_lock(port_mutex + port);
LM4_I2C_MSA(port) = addr | 0x01;
for (i = 0; i < count; i++) {
@@ -391,10 +390,10 @@ static int command_i2cread(int argc, char **argv)
return rv;
}
d = LM4_I2C_MDR(port) & 0xff;
- uart_printf("0x%02x ", d);
+ ccprintf("0x%02x ", d);
}
mutex_unlock(port_mutex + port);
- uart_puts("\n");
+ ccputs("\n");
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(i2cread, command_i2cread);
@@ -405,7 +404,7 @@ static int command_scan(int argc, char **argv)
scan_bus(I2C_PORT_THERMAL, "thermal");
scan_bus(I2C_PORT_BATTERY, "battery");
scan_bus(I2C_PORT_CHARGER, "charger");
- uart_puts("done.\n");
+ ccputs("done.\n");
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(i2cscan, command_scan);
diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c
index 8accb1d1d5..6bbdaa832c 100644
--- a/chip/lm4/peci.c
+++ b/chip/lm4/peci.c
@@ -13,7 +13,6 @@
#include "peci.h"
#include "registers.h"
#include "temp_sensor.h"
-#include "uart.h"
#include "util.h"
/* Max junction temperature for processor in degrees C */
@@ -102,11 +101,11 @@ static int command_peci_temp(int argc, char **argv)
{
int t = peci_get_cpu_temp();
if (t == -1) {
- uart_puts("Error reading CPU temperature via PECI\n");
- uart_printf("Error code = 0x%04x\n", LM4_PECI_M0D0 & 0xffff);
+ ccputs("Error reading CPU temperature via PECI\n");
+ ccprintf("Error code = 0x%04x\n", LM4_PECI_M0D0 & 0xffff);
return EC_ERROR_UNKNOWN;
}
- uart_printf("Current CPU temperature = %d K = %d C\n", t, t - 273);
+ ccprintf("Current CPU temperature = %d K = %d C\n", t, t - 273);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp);
diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c
index 0a37ffc5b8..e947e0a55f 100644
--- a/chip/lm4/pwm.c
+++ b/chip/lm4/pwm.c
@@ -9,15 +9,14 @@
#include "console.h"
#include "gpio.h"
#include "hooks.h"
+#include "lpc.h"
+#include "lpc_commands.h"
#include "pwm.h"
#include "registers.h"
-#include "uart.h"
-#include "util.h"
#include "task.h"
#include "thermal.h"
#include "timer.h"
-#include "lpc.h"
-#include "lpc_commands.h"
+#include "util.h"
/* Maximum RPM for fan controller */
#define MAX_RPM 0x1fff
@@ -145,17 +144,17 @@ void pwm_task(void)
static int command_fan_info(int argc, char **argv)
{
- uart_printf("Fan actual speed: %4d rpm\n", pwm_get_fan_rpm());
- uart_printf(" target speed: %4d rpm\n",
- (LM4_FAN_FANCMD(FAN_CH_CPU) & MAX_RPM) * CPU_FAN_SCALE);
- uart_printf(" duty cycle: %d%%\n",
- ((LM4_FAN_FANCMD(FAN_CH_CPU) >> 16)) * 100 / MAX_PWM);
- uart_printf(" status: %d\n",
- (LM4_FAN_FANSTS >> (2 * FAN_CH_CPU)) & 0x03);
- uart_printf(" enabled: %s\n",
- LM4_FAN_FANCTL & (1 << FAN_CH_CPU) ? "yes" : "no");
- uart_printf(" powered: %s\n",
- gpio_get_level(GPIO_ENABLE_VS) ? "yes" : "no");
+ ccprintf("Fan actual speed: %4d rpm\n", pwm_get_fan_rpm());
+ ccprintf(" target speed: %4d rpm\n",
+ (LM4_FAN_FANCMD(FAN_CH_CPU) & MAX_RPM) * CPU_FAN_SCALE);
+ ccprintf(" duty cycle: %d%%\n",
+ ((LM4_FAN_FANCMD(FAN_CH_CPU) >> 16)) * 100 / MAX_PWM);
+ ccprintf(" status: %d\n",
+ (LM4_FAN_FANSTS >> (2 * FAN_CH_CPU)) & 0x03);
+ ccprintf(" enabled: %s\n",
+ LM4_FAN_FANCTL & (1 << FAN_CH_CPU) ? "yes" : "no");
+ ccprintf(" powered: %s\n",
+ gpio_get_level(GPIO_ENABLE_VS) ? "yes" : "no");
return EC_SUCCESS;
}
@@ -169,17 +168,17 @@ static int command_fan_set(int argc, char **argv)
int rv;
if (argc < 2) {
- uart_puts("Usage: fanset <rpm>\n");
+ ccputs("Usage: fanset <rpm>\n");
return EC_ERROR_UNKNOWN;
}
rpm = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid speed\n");
+ ccputs("Invalid speed\n");
return EC_ERROR_UNKNOWN;
}
- uart_printf("Setting fan speed to %d rpm...\n", rpm);
+ ccprintf("Setting fan speed to %d rpm...\n", rpm);
/* Move the fan to automatic control */
if (LM4_FAN_FANCH(FAN_CH_CPU) & 0x0001) {
@@ -196,7 +195,7 @@ static int command_fan_set(int argc, char **argv)
rv = pwm_set_fan_target_rpm(rpm);
if (rv == EC_SUCCESS)
- uart_printf("Done.\n");
+ ccprintf("Done.\n");
return rv;
}
@@ -210,18 +209,18 @@ static int command_fan_duty(int argc, char **argv)
char *e;
if (argc < 2) {
- uart_puts("Usage: fanduty <percent>\n");
+ ccputs("Usage: fanduty <percent>\n");
return EC_ERROR_UNKNOWN;
}
d = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid duty cycle\n");
+ ccputs("Invalid duty cycle\n");
return EC_ERROR_UNKNOWN;
}
pwm = (MAX_PWM * d) / 100;
- uart_printf("Setting fan duty cycle to %d%% = 0x%x...\n", d, pwm);
+ ccprintf("Setting fan duty cycle to %d%% = 0x%x...\n", d, pwm);
/* Move the fan to manual control */
if (!(LM4_FAN_FANCH(FAN_CH_CPU) & 0x0001)) {
@@ -251,21 +250,21 @@ static int command_kblight(int argc, char **argv)
int i;
if (argc < 2) {
- uart_printf("Keyboard backlight is at %d%%\n",
- pwm_get_keyboard_backlight());
+ ccprintf("Keyboard backlight is at %d%%\n",
+ pwm_get_keyboard_backlight());
return EC_SUCCESS;
}
i = strtoi(argv[1], &e, 0);
if (*e) {
- uart_puts("Invalid percent\n");
+ ccputs("Invalid percent\n");
return EC_ERROR_UNKNOWN;
}
- uart_printf("Setting keyboard backlight to %d%%...\n", i);
+ ccprintf("Setting keyboard backlight to %d%%...\n", i);
rv = pwm_set_keyboard_backlight(i);
if (rv == EC_SUCCESS)
- uart_printf("Done.\n");
+ ccprintf("Done.\n");
return rv;
}
DECLARE_CONSOLE_COMMAND(kblight, command_kblight);
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index 652f1edf37..baa8129602 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -5,8 +5,6 @@
/* UART module for Chrome EC */
-#include <stdarg.h>
-
#include "board.h"
#include "console.h"
#include "gpio.h"
@@ -246,7 +244,7 @@ static int command_comxtest(int argc, char **argv)
/* Put characters to COMX port */
const char *c = argc > 1 ? argv[1] : "testing comx output!";
- uart_printf("Writing \"%s\\r\\n\" to COMx UART...\n", c);
+ ccprintf("Writing \"%s\\r\\n\" to COMx UART...\n", c);
while (*c)
uart_comx_putc_wait(*c++);
diff --git a/chip/stm32l/dma.c b/chip/stm32l/dma.c
index 6ab971d34b..f357c7b6c3 100644
--- a/chip/stm32l/dma.c
+++ b/chip/stm32l/dma.c
@@ -6,9 +6,12 @@
#include "dma.h"
#include "registers.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_DMA, outstr)
+#define CPRINTF(format, args...) cprintf(CC_DMA, format, ## args)
+
/**
* Get a pointer to a DMA channel.
@@ -110,17 +113,17 @@ void dma_check(int channel, char *buff)
chan = get_channel(channel);
count = REG32(&chan->cndtr);
- uart_printf("c=%d\n", count);
+ CPRINTF("c=%d\n", count);
udelay(1000 * 100);
- uart_printf("c=%d\n",
+ CPRINTF("c=%d\n",
REG32(&chan->cndtr));
for (i = 0; i < count; i++)
- uart_printf("%02x ", buff[i]);
+ CPRINTF("%02x ", buff[i]);
udelay(1000 * 100);
- uart_printf("c=%d\n",
+ CPRINTF("c=%d\n",
REG32(&chan->cndtr));
for (i = 0; i < count; i++)
- uart_printf("%02x ", buff[i]);
+ CPRINTF("%02x ", buff[i]);
}
/* Run a check of memory-to-memory DMA */
@@ -155,8 +158,8 @@ void dma_test(void)
ctrl |= DMA_EN;
REG32(&chan->ccr) = ctrl;
for (i = 0; i < count; i++)
- uart_printf("%d/%d ", periph[i], memory[i]);
- uart_printf("\ncount=%d\n", REG32(&chan->cndtr));
+ CPRINTF("%d/%d ", periph[i], memory[i]);
+ CPRINTF("\ncount=%d\n", REG32(&chan->cndtr));
}
#endif /* CONFIG_TEST */
diff --git a/chip/stm32l/gpio.c b/chip/stm32l/gpio.c
index d56efa32d4..5545b741a0 100644
--- a/chip/stm32l/gpio.c
+++ b/chip/stm32l/gpio.c
@@ -6,13 +6,17 @@
/* GPIO module for Chrome EC */
#include "board.h"
+#include "console.h"
#include "gpio.h"
#include "hooks.h"
#include "registers.h"
#include "task.h"
-#include "uart.h"
#include "util.h"
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_GPIO, outstr)
+#define CPRINTF(format, args...) cprintf(CC_GPIO, format, ## args)
+
/* Signal information from board.c. Must match order from enum gpio_signal. */
extern const struct gpio_info gpio_list[GPIO_COUNT];
@@ -151,8 +155,8 @@ int gpio_enable_interrupt(enum gpio_signal signal)
#ifdef CONFIG_DEBUG
if (exti_events[bit]) {
- uart_printf("Overriding %s with %s on EXTI%d\n",
- exti_events[bit]->name, g->name, bit);
+ CPRINTF("Overriding %s with %s on EXTI%d\n",
+ exti_events[bit]->name, g->name, bit);
}
#endif
exti_events[bit] = g;
diff --git a/chip/stm32l/i2c.c b/chip/stm32l/i2c.c
index 0c4aff57de..1ff3b88f90 100644
--- a/chip/stm32l/i2c.c
+++ b/chip/stm32l/i2c.c
@@ -12,7 +12,10 @@
#include "message.h"
#include "registers.h"
#include "task.h"
-#include "uart.h"
+
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_I2C, outstr)
+#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)
/* 8-bit I2C slave address */
#define I2C_ADDRESS 0xec
@@ -108,7 +111,7 @@ void i2c2_work_task(void)
/* RxNE; AP issued write command */
i2c_read_raw(I2C2, &i2c_xmit_mode[I2C2], 1);
#ifdef CONFIG_DEBUG
- uart_printf("%s: i2c2_xmit_mode: %02x\n",
+ CPRINTF("%s: i2c2_xmit_mode: %02x\n",
__func__, i2c_xmit_mode[I2C2]);
#endif
} else if (tmp16 & (1 << 7)) {
@@ -118,7 +121,7 @@ void i2c2_work_task(void)
if (msg_len > 0) {
i2c_write_raw(I2C2, out_msg, msg_len);
} else {
- uart_printf("%s: unexpected mode %u\n",
+ CPRINTF("%s: unexpected mode %u\n",
__func__, i2c_xmit_mode[I2C2]);
}
}
@@ -138,24 +141,24 @@ static void i2c_event_handler(int port)
STM32L_I2C_SR1(port);
STM32L_I2C_SR2(port);
#ifdef CONFIG_DEBUG
- uart_printf("%s: ADDR\n", __func__);
+ CPRINTF("%s: ADDR\n", __func__);
#endif
} else if (i2c_sr1[port] & (1 << 2)) {
;
#ifdef CONFIG_DEBUG
- uart_printf("%s: BTF\n", __func__);
+ CPRINTF("%s: BTF\n", __func__);
#endif
} else if (i2c_sr1[port] & (1 << 4)) {
/* clear STOPF bit by reading SR1 and then writing CR1 */
STM32L_I2C_SR1(port);
STM32L_I2C_CR1(port) = STM32L_I2C_CR1(port);
#ifdef CONFIG_DEBUG
- uart_printf("%s: STOPF\n", __func__);
+ CPRINTF("%s: STOPF\n", __func__);
#endif
} else {
;
#ifdef CONFIG_DEBUG
- uart_printf("%s: unknown event\n", __func__);
+ CPRINTF("%s: unknown event\n", __func__);
#endif
}
@@ -176,12 +179,12 @@ static void i2c_error_handler(int port)
if (i2c_sr1[port] & 1 << 10) {
/* ACK failed (NACK); expected when AP reads final byte.
* Software must clear AF bit. */
- uart_printf("%s: AF detected\n", __func__);
+ CPRINTF("%s: AF detected\n", __func__);
}
- uart_printf("%s: tx byte count: %u, rx_byte_count: %u\n",
+ CPRINTF("%s: tx byte count: %u, rx_byte_count: %u\n",
__func__, tx_byte_count, rx_byte_count);
- uart_printf("%s: I2C_SR1(%s): 0x%04x\n", __func__, port, i2c_sr1[port]);
- uart_printf("%s: I2C_SR2(%s): 0x%04x\n",
+ CPRINTF("%s: I2C_SR1(%s): 0x%04x\n", __func__, port, i2c_sr1[port]);
+ CPRINTF("%s: I2C_SR2(%s): 0x%04x\n",
__func__, port, STM32L_I2C_SR2(port));
#endif
@@ -219,7 +222,7 @@ static int i2c_init2(void)
task_enable_irq(STM32L_IRQ_I2C2_EV);
task_enable_irq(STM32L_IRQ_I2C2_ER);
- uart_printf("done\n");
+ CPUTS("done\n");
return EC_SUCCESS;
}
diff --git a/common/charger_bq24725.c b/common/charger_bq24725.c
index 5df2cc7803..6ab586e370 100644
--- a/common/charger_bq24725.c
+++ b/common/charger_bq24725.c
@@ -12,7 +12,6 @@
#include "common.h"
#include "i2c.h"
#include "smart_battery.h"
-#include "uart.h"
#include "util.h"
/* Sense resistor configurations and macros */
@@ -179,10 +178,10 @@ int charger_post_init(void)
static void print_usage(void)
{
- uart_puts("Usage: charger [set_command value]\n");
- uart_puts(" charger input input_current_in_mA\n");
- uart_puts(" charger voltage voltage_limit_in_mV\n");
- uart_puts(" charger current current_limit_in_mA\n\n");
+ ccputs("Usage: charger [set_command value]\n");
+ ccputs(" charger input input_current_in_mA\n");
+ ccputs(" charger voltage voltage_limit_in_mV\n");
+ ccputs(" charger current current_limit_in_mA\n\n");
}
static int print_info(void)
@@ -191,46 +190,46 @@ static int print_info(void)
int d;
const struct charger_info *info;
- uart_puts("Charger properties : now (max, min, step)\n");
+ ccputs("Charger properties : now (max, min, step)\n");
/* info */
info = charger_get_info();
- uart_printf(" name : %s\n", info->name);
+ ccprintf(" name : %s\n", info->name);
/* manufacturer id */
rv = charger_manufacturer_id(&d);
if (rv)
return rv;
- uart_printf(" manufacturer id: 0x%04x\n", d);
+ ccprintf(" manufacturer id: 0x%04x\n", d);
/* device id */
rv = charger_device_id(&d);
if (rv)
return rv;
- uart_printf(" device id : 0x%04x\n", d);
+ ccprintf(" device id : 0x%04x\n", d);
/* charge voltage limit */
rv = charger_get_voltage(&d);
if (rv)
return rv;
- uart_printf(" voltage : %5d (%5d, %4d, %3d)\n", d,
- info->voltage_max, info->voltage_min, info->voltage_step);
+ ccprintf(" voltage : %5d (%5d, %4d, %3d)\n", d,
+ info->voltage_max, info->voltage_min, info->voltage_step);
/* charge current limit */
rv = charger_get_current(&d);
if (rv)
return rv;
- uart_printf(" current : %5d (%5d, %4d, %3d)\n", d,
- info->current_max, info->current_min, info->current_step);
+ ccprintf(" current : %5d (%5d, %4d, %3d)\n", d,
+ info->current_max, info->current_min, info->current_step);
/* input current limit */
rv = charger_get_input_current(&d);
if (rv)
return rv;
- uart_printf(" input current : %5d (%5d, %4d, %3d)\n", d,
- info->input_current_max, info->input_current_min,
- info->input_current_step);
+ ccprintf(" input current : %5d (%5d, %4d, %3d)\n", d,
+ info->input_current_max, info->input_current_min,
+ info->input_current_step);
return EC_SUCCESS;
}
diff --git a/common/console.c b/common/console.c
index 0eff6e3529..4a94588535 100644
--- a/common/console.c
+++ b/common/console.c
@@ -25,7 +25,11 @@ static char input_buf[80]; /* Current console command line */
static const char *channel_names[CC_CHANNEL_COUNT] = {
"command",
"charger",
+ "chipset",
+ "dma",
+ "gpio",
"hostcmd",
+ "i2c",
"i8042",
"keyboard",
"keyscan",
@@ -36,7 +40,7 @@ static const char *channel_names[CC_CHANNEL_COUNT] = {
"system",
"task",
"usbcharge",
- "x86power",
+ "vboot",
};
/*****************************************************************************/
@@ -160,8 +164,8 @@ static int console_init(void)
{
*input_buf = '\0';
uart_set_console_mode(1);
- uart_printf("Console is enabled; type HELP for help.\n");
- uart_puts(PROMPT);
+ ccprintf("Console is enabled; type HELP for help.\n");
+ ccputs(PROMPT);
/* TODO: restore channel list from EEPROM */
@@ -183,8 +187,8 @@ static void console_process(void)
rv = handle_command(input_buf);
if (rv != EC_SUCCESS)
- uart_printf("Command returned error %d\n", rv);
- uart_puts(PROMPT);
+ ccprintf("Command returned error %d\n", rv);
+ ccputs(PROMPT);
}
}
@@ -220,7 +224,7 @@ static int command_help(int argc, char **argv)
const char *prev = " ";
int i;
- uart_puts("Known commands:");
+ ccputs("Known commands:");
/* Sort the commands by name */
for (i = 0; i < ncmds; i++) {
diff --git a/common/eoption.c b/common/eoption.c
index cf70fd537d..f25efcd68d 100644
--- a/common/eoption.c
+++ b/common/eoption.c
@@ -9,7 +9,6 @@
#include "console.h"
#include "eeprom.h"
#include "eoption.h"
-#include "uart.h"
#include "util.h"
#define EOPTION_MAGIC 0x456f /* Magic number for header 'Eo' */
@@ -142,22 +141,22 @@ static int command_eoption_get(int argc, char **argv)
if (argc == 2) {
i = find_option_by_name(argv[1], bool_opts);
if (i == -1) {
- uart_puts("Unknown option.\n");
+ ccputs("Unknown option.\n");
return EC_ERROR_INVAL;
}
d = bool_opts + i;
- uart_printf(" %d %s\n", eoption_get_bool(i), d->name);
+ ccprintf(" %d %s\n", eoption_get_bool(i), d->name);
return EC_SUCCESS;
}
/* Otherwise print them all */
- uart_puts("Boolean options:\n");
+ ccputs("Boolean options:\n");
for (i = 0, d = bool_opts; d->name; i++, d++) {
- uart_printf(" %d %s\n", eoption_get_bool(i), d->name);
+ ccprintf(" %d %s\n", eoption_get_bool(i), d->name);
/* We have enough options that we'll overflow the output buffer
* without flushing */
- uart_flush_output();
+ cflush();
}
return EC_SUCCESS;
}
@@ -170,13 +169,13 @@ static int command_eoption_set(int argc, char **argv)
int v, i;
if (argc < 3) {
- uart_puts("Usage: optset <option> <value>\n");
+ ccputs("Usage: optset <option> <value>\n");
return EC_ERROR_INVAL;
}
v = strtoi(argv[2], &e, 0);
if (*e) {
- uart_puts("Invalid value.\n");
+ ccputs("Invalid value.\n");
return EC_ERROR_INVAL;
}
@@ -184,7 +183,7 @@ static int command_eoption_set(int argc, char **argv)
if (i != -1) {
return eoption_set_bool(i, v);
} else {
- uart_puts("Unknown option.\n");
+ ccputs("Unknown option.\n");
return EC_ERROR_INVAL;
}
}
diff --git a/common/flash_commands.c b/common/flash_commands.c
index 1e08f26769..1ef8956db2 100644
--- a/common/flash_commands.c
+++ b/common/flash_commands.c
@@ -11,7 +11,6 @@
#include "registers.h" /* TODO: remove; only for temp debugging */
#include "shared_mem.h"
#include "system.h"
-#include "uart.h"
#include "util.h"
/* Parse offset and size from command line argv[0] and argv[1].
@@ -26,24 +25,24 @@ static int parse_offset_size(int argc, char **argv, int *offset, int *size)
if (argc >= 1) {
i = (uint32_t)strtoi(argv[0], &e, 0);
if (e && *e) {
- uart_printf("Invalid offset \"%s\"\n", argv[0]);
+ ccprintf("Invalid offset \"%s\"\n", argv[0]);
return EC_ERROR_INVAL;
}
*offset = i;
} else if (*offset < 0) {
- uart_puts("Must specify offset.\n");
+ ccputs("Must specify offset.\n");
return EC_ERROR_INVAL;
}
if (argc >= 2) {
i = (uint32_t)strtoi(argv[1], &e, 1);
if (e && *e) {
- uart_printf("Invalid size \"%s\"\n", argv[1]);
+ ccprintf("Invalid size \"%s\"\n", argv[1]);
return EC_ERROR_INVAL;
}
*size = i;
} else if (*size < 0) {
- uart_puts("Must specify offset and size.\n");
+ ccputs("Must specify offset and size.\n");
return EC_ERROR_INVAL;
}
@@ -60,34 +59,34 @@ static int command_flash_info(int argc, char **argv)
int banks = flash_get_size() / flash_get_protect_block_size();
int i;
- uart_printf("Physical size: %4d KB\n", flash_physical_size() / 1024);
- uart_printf("Usable size: %4d KB\n", flash_get_size() / 1024);
- uart_printf("Write block: %4d B\n", flash_get_write_block_size());
- uart_printf("Erase block: %4d B\n", flash_get_erase_block_size());
- uart_printf("Protect block: %4d B\n", flash_get_protect_block_size());
+ ccprintf("Physical size: %4d KB\n", flash_physical_size() / 1024);
+ ccprintf("Usable size: %4d KB\n", flash_get_size() / 1024);
+ ccprintf("Write block: %4d B\n", flash_get_write_block_size());
+ ccprintf("Erase block: %4d B\n", flash_get_erase_block_size());
+ ccprintf("Protect block: %4d B\n", flash_get_protect_block_size());
i = flash_get_protect_lock();
- uart_printf("Protect lock: %s%s\n",
- (i & FLASH_PROTECT_LOCK_SET) ? "LOCKED" : "unlocked",
- (i & FLASH_PROTECT_LOCK_APPLIED) ? " AND APPLIED" : "");
- uart_printf("WP pin: %s\n", (i & FLASH_PROTECT_PIN_ASSERTED) ?
- "ASSERTED" : "deasserted");
+ ccprintf("Protect lock: %s%s\n",
+ (i & FLASH_PROTECT_LOCK_SET) ? "LOCKED" : "unlocked",
+ (i & FLASH_PROTECT_LOCK_APPLIED) ? " AND APPLIED" : "");
+ ccprintf("WP pin: %s\n", (i & FLASH_PROTECT_PIN_ASSERTED) ?
+ "ASSERTED" : "deasserted");
wp = flash_get_protect_array();
- uart_puts("Protected now:");
+ ccputs("Protected now:");
for (i = 0; i < banks; i++) {
if (!(i & 7))
- uart_puts(" ");
- uart_puts(wp[i] & FLASH_PROTECT_UNTIL_REBOOT ? "Y" : ".");
+ ccputs(" ");
+ ccputs(wp[i] & FLASH_PROTECT_UNTIL_REBOOT ? "Y" : ".");
}
- uart_puts("\n Persistent: ");
+ ccputs("\n Persistent: ");
for (i = 0; i < banks; i++) {
if (!(i & 7))
- uart_puts(" ");
- uart_puts(wp[i] & FLASH_PROTECT_PERSISTENT ? "Y" : ".");
+ ccputs(" ");
+ ccputs(wp[i] & FLASH_PROTECT_PERSISTENT ? "Y" : ".");
}
- uart_puts("\n");
+ ccputs("\n");
return EC_SUCCESS;
}
@@ -104,7 +103,7 @@ static int command_flash_erase(int argc, char **argv)
if (rv)
return rv;
- uart_printf("Erasing %d bytes at offset 0x%x (%d)...\n",
+ ccprintf("Erasing %d bytes at offset 0x%x (%d)...\n",
size, offset, offset);
return flash_erase(offset, size);
}
@@ -125,14 +124,14 @@ static int command_flash_write(int argc, char **argv)
return rv;
if (size > shared_mem_size()) {
- uart_puts("Truncating size\n");
+ ccputs("Truncating size\n");
size = shared_mem_size();
}
/* Acquire the shared memory buffer */
rv = shared_mem_acquire(size, 0, &data);
if (rv) {
- uart_printf("Unable to acquire %d byte buffer\n", size);
+ ccprintf("Unable to acquire %d byte buffer\n", size);
return rv;
}
@@ -140,13 +139,13 @@ static int command_flash_write(int argc, char **argv)
for (i = 0; i < size; i++)
data[i] = i;
- uart_printf("Writing %d bytes to offset 0x%x (%d)...\n",
- size, offset, offset);
+ ccprintf("Writing %d bytes to offset 0x%x (%d)...\n",
+ size, offset, offset);
rv = flash_write(offset, size, data);
if (rv == EC_SUCCESS)
- uart_puts("done.\n");
+ ccputs("done.\n");
else
- uart_printf("failed. (error %d)\n", rv);
+ ccprintf("failed. (error %d)\n", rv);
/* Free the buffer */
shared_mem_release(data);
@@ -168,7 +167,7 @@ static int command_flash_wp(int argc, char **argv)
int rv;
if (argc < 2) {
- uart_puts(flash_wp_help);
+ ccputs(flash_wp_help);
return EC_ERROR_INVAL;
}
@@ -190,7 +189,7 @@ static int command_flash_wp(int argc, char **argv)
else if (!strcasecmp(argv[1], "clear"))
return flash_set_protect(offset, size, 0);
else {
- uart_puts(flash_wp_help);
+ ccputs(flash_wp_help);
return EC_ERROR_INVAL;
}
@@ -225,11 +224,8 @@ enum lpc_status flash_command_checksum(uint8_t *data)
int j;
for (cs = 0, j = 0; j < p->size; ++j) {
- if (flash_read(p->offset + j, 1, &byte)) {
- uart_printf("flash_read() error at 0x%02x.\n",
- p->offset + j);
+ if (flash_read(p->offset + j, 1, &byte))
return EC_LPC_RESULT_ERROR;
- }
BYTE_IN(cs, byte);
}
diff --git a/common/gaia_power.c b/common/gaia_power.c
index 110157481c..ec06fb2d98 100644
--- a/common/gaia_power.c
+++ b/common/gaia_power.c
@@ -11,9 +11,12 @@
#include "gpio.h"
#include "task.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
+#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
+
/* Time necessary for the 5v regulator output to stabilize */
#define DELAY_5V_SETUP 1000 /* 1ms */
@@ -56,7 +59,7 @@ static int wait_in_signal(enum gpio_signal signal, int value, int timeout)
if ((now.val >= deadline.val) ||
(task_wait_event(deadline.val - now.val) ==
TASK_EVENT_TIMER)) {
- uart_printf("Timeout waiting for GPIO %d\n", signal);
+ CPRINTF("Timeout waiting for GPIO %d\n", signal);
return EC_ERROR_TIMEOUT;
}
}
@@ -179,7 +182,7 @@ void gaia_power_task(void)
/* Power ON state */
ap_on = 1;
- uart_printf("AP running ...\n");
+ CPUTS("AP running ...\n");
/* Wait for power off from AP or long power button press */
wait_for_power_off();
@@ -187,7 +190,7 @@ void gaia_power_task(void)
gpio_set_level(GPIO_EN_PP3300, 0);
gpio_set_level(GPIO_EN_PP1350, 0);
gpio_set_level(GPIO_EN_PP5000, 0);
- uart_printf("Shutdown complete.\n");
+ CPUTS("Shutdown complete.\n");
/* Ensure the power button is released */
wait_in_signal(GPIO_EC_PWRON, 0, -1);
diff --git a/common/gpio_commands.c b/common/gpio_commands.c
index 66bebb4b8d..c1f444a0c7 100644
--- a/common/gpio_commands.c
+++ b/common/gpio_commands.c
@@ -8,7 +8,6 @@
#include "board.h"
#include "console.h"
#include "gpio.h"
-#include "uart.h"
#include "util.h"
@@ -61,30 +60,30 @@ static int command_gpio_get(int argc, char **argv)
if (argc == 2) {
i = find_signal_by_name(argv[1]);
if (i == GPIO_COUNT) {
- uart_puts("Unknown signal name.\n");
+ ccputs("Unknown signal name.\n");
return EC_ERROR_UNKNOWN;
}
g = gpio_list + i;
v = gpio_get_level(i);
changed = last_val_changed(i, v);
- uart_printf(" %d%c %s\n", v, (changed ? '*' : ' '), g->name);
+ ccprintf(" %d%c %s\n", v, (changed ? '*' : ' '), g->name);
return EC_SUCCESS;
}
/* Otherwise print them all */
- uart_puts("Current GPIO levels:\n");
+ ccputs("Current GPIO levels:\n");
for (i = 0; i < GPIO_COUNT; i++, g++) {
if (!g->mask)
continue; /* Skip unsupported signals */
v = gpio_get_level(i);
changed = last_val_changed(i, v);
- uart_printf(" %d%c %s\n", v, (changed ? '*' : ' '), g->name);
+ ccprintf(" %d%c %s\n", v, (changed ? '*' : ' '), g->name);
/* We have enough GPIOs that we'll overflow the output buffer
* without flushing */
- uart_flush_output();
+ cflush();
}
return EC_SUCCESS;
}
@@ -98,29 +97,29 @@ static int command_gpio_set(int argc, char **argv)
int v, i;
if (argc < 3) {
- uart_puts("Usage: gpioset <signal_name> <0|1>\n");
+ ccputs("Usage: gpioset <signal_name> <0|1>\n");
return EC_ERROR_UNKNOWN;
}
i = find_signal_by_name(argv[1]);
if (i == GPIO_COUNT) {
- uart_puts("Unknown signal name.\n");
+ ccputs("Unknown signal name.\n");
return EC_ERROR_UNKNOWN;
}
g = gpio_list + i;
if (!g->mask) {
- uart_puts("Signal is not implemented.\n");
+ ccputs("Signal is not implemented.\n");
return EC_ERROR_UNKNOWN;
}
if (!(g->flags & GPIO_OUTPUT)) {
- uart_puts("Signal is not an output.\n");
+ ccputs("Signal is not an output.\n");
return EC_ERROR_UNKNOWN;
}
v = strtoi(argv[2], &e, 0);
if (*e) {
- uart_puts("Invalid signal value.\n");
+ ccputs("Invalid signal value.\n");
return EC_ERROR_UNKNOWN;
}
diff --git a/common/host_event_commands.c b/common/host_event_commands.c
index 955f062728..3590966fd2 100644
--- a/common/host_event_commands.c
+++ b/common/host_event_commands.c
@@ -8,7 +8,6 @@
#include "console.h"
#include "host_command.h"
#include "lpc.h"
-#include "uart.h"
#include "util.h"
/*****************************************************************************/
@@ -21,39 +20,39 @@ static int command_host_event(int argc, char **argv)
char *e;
int i = strtoi(argv[2], &e, 0);
if (*e) {
- uart_puts("Invalid event mask\n");
+ ccputs("Invalid event mask\n");
return EC_ERROR_INVAL;
}
if (!strcasecmp(argv[1], "set")) {
- uart_printf("Setting host event mask 0x%08x\n", i);
+ ccprintf("Setting host event mask 0x%08x\n", i);
lpc_set_host_events(i);
} else if (!strcasecmp(argv[1], "clear")) {
- uart_printf("Clearing host event mask 0x%08x\n", i);
+ ccprintf("Clearing host event mask 0x%08x\n", i);
lpc_clear_host_events(i);
} else if (!strcasecmp(argv[1], "smi")) {
- uart_printf("Setting SMI mask to 0x%08x\n", i);
+ ccprintf("Setting SMI mask to 0x%08x\n", i);
lpc_set_host_event_mask(LPC_HOST_EVENT_SMI, i);
} else if (!strcasecmp(argv[1], "sci")) {
- uart_printf("Setting SCI mask to 0x%08x\n", i);
+ ccprintf("Setting SCI mask to 0x%08x\n", i);
lpc_set_host_event_mask(LPC_HOST_EVENT_SCI, i);
} else if (!strcasecmp(argv[1], "wake")) {
- uart_printf("Setting wake mask to 0x%08x\n", i);
+ ccprintf("Setting wake mask to 0x%08x\n", i);
lpc_set_host_event_mask(LPC_HOST_EVENT_WAKE, i);
} else {
- uart_puts("Unknown sub-command\n");
+ ccputs("Unknown sub-command\n");
return EC_ERROR_INVAL;
}
}
/* Print current SMI/SCI status */
- uart_printf("Raw host events: 0x%08x\n", lpc_get_host_events());
- uart_printf("SMI mask: 0x%08x\n",
- lpc_get_host_event_mask(LPC_HOST_EVENT_SMI));
- uart_printf("SCI mask: 0x%08x\n",
- lpc_get_host_event_mask(LPC_HOST_EVENT_SCI));
- uart_printf("Wake mask: 0x%08x\n",
- lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE));
+ ccprintf("Raw host events: 0x%08x\n", lpc_get_host_events());
+ ccprintf("SMI mask: 0x%08x\n",
+ lpc_get_host_event_mask(LPC_HOST_EVENT_SMI));
+ ccprintf("SCI mask: 0x%08x\n",
+ lpc_get_host_event_mask(LPC_HOST_EVENT_SCI));
+ ccprintf("Wake mask: 0x%08x\n",
+ lpc_get_host_event_mask(LPC_HOST_EVENT_WAKE));
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(hostevent, command_host_event);
diff --git a/common/keyboard.c b/common/keyboard.c
index 3764329d91..0e56a6dd9c 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -735,8 +735,6 @@ static int command_codeset(int argc, char **argv)
return EC_ERROR_UNKNOWN;
}
- uart_flush_output();
-
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(codeset, command_codeset);
@@ -768,8 +766,6 @@ static int command_controller_ram(int argc, char **argv)
return EC_ERROR_UNKNOWN;
}
- uart_flush_output();
-
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(ctrlram, command_controller_ram);
diff --git a/common/memory_commands.c b/common/memory_commands.c
index 476aa92498..e8bff757cd 100644
--- a/common/memory_commands.c
+++ b/common/memory_commands.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -6,7 +6,6 @@
/* System module for Chrome EC */
#include "console.h"
-#include "uart.h"
#include "util.h"
@@ -16,14 +15,14 @@ static int command_write_word(int argc, char **argv)
uint32_t value;
if (argc != 3) {
- uart_puts("Usage: ww <address> <value>\n");
+ ccputs("Usage: ww <address> <value>\n");
return EC_ERROR_UNKNOWN;
}
address = (uint32_t*)strtoi(argv[1], NULL, 0);
value = strtoi(argv[2], NULL, 0);
- uart_printf("write word 0x%p = 0x%08x\n", address, value);
- uart_flush_output();
+ ccprintf("write word 0x%p = 0x%08x\n", address, value);
+ cflush(); /* Flush before writing in case this crashes */
*address = value;
@@ -39,14 +38,13 @@ static int command_read_word(int argc, char **argv)
uint32_t value;
if (argc != 2) {
- uart_puts("Usage: rw <address>\n");
+ ccputs("Usage: rw <address>\n");
return EC_ERROR_UNKNOWN;
}
address = (uint32_t*)strtoi(argv[1], NULL, 0);
value = *address;
- uart_printf("read word 0x%p = 0x%08x\n", address, value);
- uart_flush_output();
+ ccprintf("read word 0x%p = 0x%08x\n", address, value);
return EC_SUCCESS;
}
diff --git a/common/port80.c b/common/port80.c
index f048a54884..edfdb7c54a 100644
--- a/common/port80.c
+++ b/common/port80.c
@@ -24,7 +24,7 @@ void port_80_write(int data)
/* Note that this currently prints from inside the LPC interrupt
* itself. Probably not worth the system overhead to buffer the data
* and print it from a task, because we're printing a small amount of
- * data and uart_printf() doesn't block. */
+ * data and cprintf() doesn't block. */
CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data);
history[head] = data;
diff --git a/common/power_led.c b/common/power_led.c
index b90c72ae95..6f38c0f202 100644
--- a/common/power_led.c
+++ b/common/power_led.c
@@ -9,7 +9,6 @@
#include "onewire.h"
#include "power_led.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
#define POWERLED_RETRIES 10
@@ -87,14 +86,14 @@ static int command_powerled(int argc, char **argv)
}
}
if (i >= POWERLED_COLOR_COUNT) {
- uart_puts("Please specify a color:");
+ ccputs("Please specify a color:");
for (i = 0; i < POWERLED_COLOR_COUNT; i++)
- uart_printf(" %s", color_names[i]);
- uart_puts("\n");
+ ccprintf(" %s", color_names[i]);
+ ccputs("\n");
return EC_ERROR_INVAL;
}
- uart_printf("Setting power LED to %s...\n", color_names[i]);
+ ccprintf("Setting power LED to %s...\n", color_names[i]);
return powerled_set(i);
}
DECLARE_CONSOLE_COMMAND(powerled, command_powerled);
diff --git a/common/pstore_commands.c b/common/pstore_commands.c
index 489e554941..afb9a16852 100644
--- a/common/pstore_commands.c
+++ b/common/pstore_commands.c
@@ -8,17 +8,14 @@
#include "board.h"
#include "eeprom.h"
#include "host_command.h"
-#include "uart.h"
#include "util.h"
+
enum lpc_status pstore_command_get_info(uint8_t *data)
{
struct lpc_response_pstore_info *r =
(struct lpc_response_pstore_info *)data;
- uart_printf("ee block size=%d, count=%d\n",
- eeprom_get_block_size(), eeprom_get_block_count());
-
ASSERT(EEPROM_BLOCK_START_PSTORE + EEPROM_BLOCK_COUNT_PSTORE <=
eeprom_get_block_count());
diff --git a/common/smart_battery.c b/common/smart_battery.c
index 49ed800afe..f921ba15f4 100644
--- a/common/smart_battery.c
+++ b/common/smart_battery.c
@@ -8,7 +8,6 @@
#include "console.h"
#include "smart_battery.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
/* Read battery discharging current
@@ -106,6 +105,7 @@ int battery_manufacturer_date(int *year, int *month, int *day)
return EC_SUCCESS;
}
+/*****************************************************************************/
/* Console commands */
static int command_battery(int argc, char **argv)
@@ -116,69 +116,69 @@ static int command_battery(int argc, char **argv)
char text[32];
const char *unit;
- uart_puts("Reading battery...\n");
+ ccputs("Reading battery...\n");
rv = battery_temperature(&d);
if (rv)
return rv;
- uart_printf(" Temperature: 0x%04x = %d x 0.1K (%d C)\n",
- d, d, (d-2731)/10);
+ ccprintf(" Temperature: 0x%04x = %d x 0.1K (%d C)\n",
+ d, d, (d-2731)/10);
- uart_printf(" Manufacturer: %s\n",
- battery_manufacturer_name(text, sizeof(text)) == EC_SUCCESS ?
- text : "(error)");
+ ccprintf(" Manufacturer: %s\n",
+ battery_manufacturer_name(text, sizeof(text)) == EC_SUCCESS ?
+ text : "(error)");
- uart_printf(" Device: %s\n",
- battery_device_name(text, sizeof(text)) == EC_SUCCESS ?
- text : "(error)");
+ ccprintf(" Device: %s\n",
+ battery_device_name(text, sizeof(text)) == EC_SUCCESS ?
+ text : "(error)");
- uart_printf(" Chemistry: %s\n",
- battery_device_chemistry(text, sizeof(text)) == EC_SUCCESS ?
- text : "(error)");
+ ccprintf(" Chemistry: %s\n",
+ battery_device_chemistry(text, sizeof(text)) == EC_SUCCESS ?
+ text : "(error)");
battery_serial_number(&d);
- uart_printf(" Serial number: 0x%04x\n", d);
+ ccprintf(" Serial number: 0x%04x\n", d);
battery_voltage(&d);
- uart_printf(" Voltage: 0x%04x = %d mV\n", d, d);
+ ccprintf(" Voltage: 0x%04x = %d mV\n", d, d);
battery_desired_voltage(&d);
- uart_printf(" Desired voltage 0x%04x = %d mV\n", d, d);
+ ccprintf(" Desired voltage 0x%04x = %d mV\n", d, d);
battery_design_voltage(&d);
- uart_printf(" Design output voltage 0x%04x = %d mV\n", d, d);
+ ccprintf(" Design output voltage 0x%04x = %d mV\n", d, d);
battery_current(&d);
- uart_printf(" Current: 0x%04x = %d mA",
+ ccprintf(" Current: 0x%04x = %d mA",
d & 0xffff, d);
if (d > 0)
- uart_puts("(CHG)");
+ ccputs("(CHG)");
else if (d < 0)
- uart_puts("(DISCHG)");
- uart_puts("\n");
+ ccputs("(DISCHG)");
+ ccputs("\n");
battery_desired_current(&d);
- uart_printf(" Desired current 0x%04x = %d mA\n", d, d);
+ ccprintf(" Desired current 0x%04x = %d mA\n", d, d);
battery_get_battery_mode(&d);
- uart_printf(" Battery mode: 0x%04x\n", d);
+ ccprintf(" Battery mode: 0x%04x\n", d);
unit = (d & MODE_CAPACITY) ? "0 mW" : " mAh";
battery_state_of_charge(&d);
- uart_printf(" %% of charge: %d %%\n", d);
+ ccprintf(" %% of charge: %d %%\n", d);
battery_state_of_charge_abs(&d);
- uart_printf(" Abs %% of charge: %d %%\n", d);
+ ccprintf(" Abs %% of charge: %d %%\n", d);
battery_remaining_capacity(&d);
- uart_printf(" Remaining capacity: %d%s\n", d, unit);
+ ccprintf(" Remaining capacity: %d%s\n", d, unit);
battery_full_charge_capacity(&d);
- uart_printf(" Full charge capacity: %d%s\n", d, unit);
+ ccprintf(" Full charge capacity: %d%s\n", d, unit);
battery_design_capacity(&d);
- uart_printf(" Design capacity: %d%s\n", d, unit);
+ ccprintf(" Design capacity: %d%s\n", d, unit);
battery_time_to_empty(&d);
if (d == 65535) {
@@ -188,7 +188,7 @@ static int command_battery(int argc, char **argv)
hour = d / 60;
minute = d % 60;
}
- uart_printf(" Time to empty: %dh:%d\n", hour, minute);
+ ccprintf(" Time to empty: %dh:%d\n", hour, minute);
battery_time_to_full(&d);
if (d == 65535) {
@@ -198,12 +198,13 @@ static int command_battery(int argc, char **argv)
hour = d / 60;
minute = d % 60;
}
- uart_printf(" Time to full: %dh:%d\n", hour, minute);
+ ccprintf(" Time to full: %dh:%d\n", hour, minute);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(battery, command_battery);
+
static int command_sb(int argc, char **argv)
{
int rv;
@@ -215,39 +216,39 @@ static int command_sb(int argc, char **argv)
cmd = strtoi(argv[2], &e, 0);
if (*e) {
- uart_puts("Invalid cmd.\n");
+ ccputs("Invalid cmd.\n");
goto usage;
}
if (argv[1][0] == 'r') {
rv = i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, &d);
if (rv) {
- uart_puts("I2C read failed.\n");
+ ccputs("I2C read failed.\n");
return rv;
}
- uart_printf("R SBCMD[%04x] 0x%04x (%d)\n", cmd, d, d);
+ ccprintf("R SBCMD[%04x] 0x%04x (%d)\n", cmd, d, d);
return EC_SUCCESS;
} else if (argc >= 4 && argv[1][0] == 'w') {
d = strtoi(argv[3], &e, 0);
if (*e) {
- uart_puts("Invalid w_word.\n");
+ ccputs("Invalid w_word.\n");
goto usage;
}
- uart_printf("W SBCMD[%04x] 0x%04x (%d)\n", cmd, d, d);
+ ccprintf("W SBCMD[%04x] 0x%04x (%d)\n", cmd, d, d);
rv = i2c_write16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, d);
if (rv) {
- uart_puts("I2C write failed.\n");
+ ccputs("I2C write failed.\n");
return rv;
}
return EC_SUCCESS;
}
usage:
- uart_puts("Usage:sb <r/w> cmd [uint16_t w_word]\n");
- uart_puts(" sb r 0x14 // desired charging current\n");
- uart_puts(" sb r 0x15 // desired charging voltage\n");
- uart_puts(" sb r 0x3 // battery mode\n");
- uart_puts(" sb w 0x3 0xe001 // set battery mode\n");
+ ccputs("Usage:sb <r/w> cmd [uint16_t w_word]\n");
+ ccputs(" sb r 0x14 // desired charging current\n");
+ ccputs(" sb r 0x15 // desired charging voltage\n");
+ ccputs(" sb r 0x3 // battery mode\n");
+ ccputs(" sb w 0x3 0xe001 // set battery mode\n");
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(sb, command_sb);
diff --git a/common/temp_sensor.c b/common/temp_sensor.c
index 36c24632cb..013b4f0d87 100644
--- a/common/temp_sensor.c
+++ b/common/temp_sensor.c
@@ -19,7 +19,6 @@
#include "thermal.h"
#include "timer.h"
#include "tmp006.h"
-#include "uart.h"
#include "util.h"
/* Defined in board_temp_sensor.c. Must be in the same order as
@@ -27,6 +26,7 @@
*/
extern const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT];
+
int temp_sensor_read(enum temp_sensor_id id)
{
const struct temp_sensor_t *sensor;
@@ -107,17 +107,17 @@ static int command_temps(int argc, char **argv)
int rv = 0;
int t;
- uart_puts("Reading temperature sensors...\n");
+ ccputs("Reading temperature sensors...\n");
for (i = 0; i < TEMP_SENSOR_COUNT; ++i) {
- uart_printf(" %-20s: ", temp_sensors[i].name);
+ ccprintf(" %-20s: ", temp_sensors[i].name);
t = temp_sensor_read(i);
if (t < 0) {
- uart_printf("Error\n");
+ ccprintf("Error\n");
rv = -1;
}
else
- uart_printf("%d K = %d C\n", t, t - 273);
+ ccprintf("%d K = %d C\n", t, t - 273);
}
if (rv == -1)
diff --git a/common/thermal.c b/common/thermal.c
index 866f857d32..2143007adc 100644
--- a/common/thermal.c
+++ b/common/thermal.c
@@ -16,7 +16,6 @@
#include "temp_sensor.h"
#include "thermal.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
#include "x86_power.h"
@@ -28,7 +27,7 @@ extern const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT];
/* Temperature threshold configuration. Must be in the same order as in
* enum temp_sensor_type. Threshold values for overheated action first.
* Followed by fan speed stepping thresholds. */
-struct thermal_config_t thermal_config[TEMP_SENSOR_TYPE_COUNT] = {
+static struct thermal_config_t thermal_config[TEMP_SENSOR_TYPE_COUNT] = {
/* TEMP_SENSOR_TYPE_CPU */
{THERMAL_CONFIG_WARNING_ON_FAIL,
{343, 348, 353, 318, 323, 328, 333, 338}},
@@ -44,7 +43,8 @@ struct thermal_config_t thermal_config[TEMP_SENSOR_TYPE_COUNT] = {
* turn off fan according to temperature readings. Modify this to turn off fan
* when we have reliable temperature readings. See crosbug.com/p/8479
*/
-const int fan_speed[THERMAL_FAN_STEPS + 1] = {4000, 5000, 6000, 7000, 8000, -1};
+static const int fan_speed[THERMAL_FAN_STEPS + 1] = {4000, 5000, 6000, 7000,
+ 8000, -1};
/* Number of consecutive overheated events for each temperature sensor. */
static int8_t ot_count[TEMP_SENSOR_COUNT][THRESHOLD_COUNT + THERMAL_FAN_STEPS];
@@ -204,13 +204,13 @@ void thermal_task(void)
static void print_thermal_config(enum temp_sensor_type type)
{
const struct thermal_config_t *config = thermal_config + type;
- uart_printf("Sensor Type %d:\n", type);
- uart_printf("\tWarning: %d K \n",
- config->thresholds[THRESHOLD_WARNING]);
- uart_printf("\tCPU Down: %d K \n",
- config->thresholds[THRESHOLD_CPU_DOWN]);
- uart_printf("\tPower Down: %d K \n",
- config->thresholds[THRESHOLD_POWER_DOWN]);
+ ccprintf("Sensor Type %d:\n", type);
+ ccprintf("\tWarning: %d K\n",
+ config->thresholds[THRESHOLD_WARNING]);
+ ccprintf("\tCPU Down: %d K\n",
+ config->thresholds[THRESHOLD_CPU_DOWN]);
+ ccprintf("\tPower Down: %d K\n",
+ config->thresholds[THRESHOLD_POWER_DOWN]);
}
@@ -219,12 +219,12 @@ static void print_fan_stepping(enum temp_sensor_type type)
const struct thermal_config_t *config = thermal_config + type;
int i;
- uart_printf("Sensor Type %d:\n", type);
- uart_printf("\tLowest speed: %d RPM\n", fan_speed[0]);
+ ccprintf("Sensor Type %d:\n", type);
+ ccprintf("\tLowest speed: %d RPM\n", fan_speed[0]);
for (i = 0; i < THERMAL_FAN_STEPS; ++i)
- uart_printf("\t%3d K: %d RPM\n",
- config->thresholds[THRESHOLD_COUNT + i],
- fan_speed[i+1]);
+ ccprintf("\t%3d K: %d RPM\n",
+ config->thresholds[THRESHOLD_COUNT + i],
+ fan_speed[i+1]);
}
@@ -234,14 +234,15 @@ static int command_thermal_config(int argc, char **argv)
int sensor_type, threshold_id, value;
if (argc != 2 && argc != 4) {
- uart_puts("Usage: thermal <sensor_type> [<threshold_id> <value>]\n");
+ ccputs("Usage: thermal <sensor_type> "
+ "[<threshold_id> <value>]\n");
return EC_ERROR_UNKNOWN;
}
sensor_type = strtoi(argv[1], &e, 0);
if ((e && *e) || sensor_type < 0 ||
sensor_type >= TEMP_SENSOR_TYPE_COUNT) {
- uart_puts("Bad sensor type ID.\n");
+ ccputs("Bad sensor type ID.\n");
return EC_ERROR_UNKNOWN;
}
@@ -252,19 +253,19 @@ static int command_thermal_config(int argc, char **argv)
threshold_id = strtoi(argv[2], &e, 0);
if ((e && *e) || threshold_id < 0 || threshold_id >= THRESHOLD_COUNT) {
- uart_puts("Bad threshold ID.\n");
+ ccputs("Bad threshold ID.\n");
return EC_ERROR_UNKNOWN;
}
value = strtoi(argv[3], &e, 0);
if ((e && *e) || value < 0) {
- uart_puts("Bad threshold value.\n");
+ ccputs("Bad threshold value.\n");
return EC_ERROR_UNKNOWN;
}
thermal_config[sensor_type].thresholds[threshold_id] = value;
- uart_printf("Setting threshold %d of sensor type %d to %d\n",
- threshold_id, sensor_type, value);
+ ccprintf("Setting threshold %d of sensor type %d to %d\n",
+ threshold_id, sensor_type, value);
return EC_SUCCESS;
}
@@ -277,14 +278,15 @@ static int command_fan_config(int argc, char **argv)
int sensor_type, stepping_id, value;
if (argc != 2 && argc != 4) {
- uart_puts("Usage: thermalfan <sensor_type> [<stepping_id> <value>]\n");
+ ccputs("Usage: thermalfan <sensor_type> "
+ "[<stepping_id> <value>]\n");
return EC_ERROR_UNKNOWN;
}
sensor_type = strtoi(argv[1], &e, 0);
if ((e && *e) || sensor_type < 0 ||
sensor_type >= TEMP_SENSOR_TYPE_COUNT) {
- uart_puts("Bad sensor type ID.\n");
+ ccputs("Bad sensor type ID.\n");
return EC_ERROR_UNKNOWN;
}
@@ -295,19 +297,20 @@ static int command_fan_config(int argc, char **argv)
stepping_id = strtoi(argv[2], &e, 0);
if ((e && *e) || stepping_id < 0 || stepping_id >= THERMAL_FAN_STEPS) {
- uart_puts("Bad stepping ID.\n");
+ ccputs("Bad stepping ID.\n");
return EC_ERROR_UNKNOWN;
}
value = strtoi(argv[3], &e, 0);
if ((e && *e) || value < 0) {
- uart_puts("Bad threshold value.\n");
+ ccputs("Bad threshold value.\n");
return EC_ERROR_UNKNOWN;
}
- thermal_config[sensor_type].thresholds[THRESHOLD_COUNT + stepping_id] = value;
- uart_printf("Setting fan step %d of sensor type %d to %d K\n",
- stepping_id, sensor_type, value);
+ thermal_config[sensor_type].thresholds[THRESHOLD_COUNT + stepping_id] =
+ value;
+ ccprintf("Setting fan step %d of sensor type %d to %d K\n",
+ stepping_id, sensor_type, value);
return EC_SUCCESS;
}
diff --git a/common/tmp006.c b/common/tmp006.c
index 46cd8dbe30..f95706ca1b 100644
--- a/common/tmp006.c
+++ b/common/tmp006.c
@@ -203,6 +203,8 @@ static int tmp006_poll_sensor(int sensor_id)
return EC_SUCCESS;
}
+
+/* Print temperature info for a sensor; used by console command. */
static int tmp006_print(int idx)
{
int vraw, v;
@@ -212,35 +214,35 @@ static int tmp006_print(int idx)
int addr = tmp006_sensors[idx].addr;
- uart_printf("Debug data from %s:\n", tmp006_sensors[idx].name);
+ ccprintf("Debug data from %s:\n", tmp006_sensors[idx].name);
/* TODO: For now, all TMP006 sensors are powered by VS. Modify this
* if we have different design.
*/
if (gpio_get_level(GPIO_PGOOD_1_8VS) == 0) {
- uart_puts("Sensor powered off.\n");
+ ccputs("Sensor powered off.\n");
return EC_ERROR_UNKNOWN;
}
rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0xfe, &d);
if (rv)
return rv;
- uart_printf(" Manufacturer ID: 0x%04x\n", d);
+ ccprintf(" Manufacturer ID: 0x%04x\n", d);
rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0xff, &d);
- uart_printf(" Device ID: 0x%04x\n", d);
+ ccprintf(" Device ID: 0x%04x\n", d);
rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0x02, &d);
- uart_printf(" Config: 0x%04x\n", d);
+ ccprintf(" Config: 0x%04x\n", d);
rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0x00, &vraw);
v = ((int)(int16_t)vraw * 15625) / 100;
- uart_printf(" Voltage: 0x%04x = %d nV\n", vraw, v);
+ ccprintf(" Voltage: 0x%04x = %d nV\n", vraw, v);
rv = i2c_read16(TMP006_PORT(addr), TMP006_REG(addr), 0x01, &traw);
t = ((int)(int16_t)traw * 100) / 128;
- uart_printf(" Temperature: 0x%04x = %d.%02d C\n",
- traw, t / 100, t > 0 ? t % 100 : 100 - (t % 100));
+ ccprintf(" Temperature: 0x%04x = %d.%02d C\n",
+ traw, t / 100, t > 0 ? t % 100 : 100 - (t % 100));
return EC_SUCCESS;
}
@@ -285,7 +287,7 @@ static int command_sensor_info(int argc, char **argv)
rv = tmp006_print(i);
if (rv != EC_SUCCESS)
rv1 = rv;
- uart_flush_output();
+ cflush();
}
return rv1;
diff --git a/common/usb_charge.c b/common/usb_charge.c
index f14cfe393d..ace535fbe4 100644
--- a/common/usb_charge.c
+++ b/common/usb_charge.c
@@ -9,10 +9,10 @@
#include "console.h"
#include "gpio.h"
#include "hooks.h"
-#include "uart.h"
#include "usb_charge.h"
#include "util.h"
+
static void usb_charge_set_control_mode(int port_id, int mode)
{
if (port_id == 0) {
@@ -91,28 +91,28 @@ static int command_set_mode(int argc, char **argv)
char* endptr;
if (argc != 3) {
- uart_puts("Usage: usbchargemode <port_id> <mode>\n");
- uart_puts("Modes: 0=Disabled.\n"
- " 1=Dedicated charging. Auto select.\n"
- " 2=Dedicated charging. BC 1.2.\n"
- " 3=Downstream. Max 500mA.\n"
- " 4=Downstream. Max 1.5A.\n");
+ ccputs("Usage: usbchargemode <port_id> <mode>\n");
+ ccputs("Modes: 0=Disabled.\n"
+ " 1=Dedicated charging. Auto select.\n"
+ " 2=Dedicated charging. BC 1.2.\n"
+ " 3=Downstream. Max 500mA.\n"
+ " 4=Downstream. Max 1.5A.\n");
return EC_ERROR_UNKNOWN;
}
port_id = strtoi(argv[1], &endptr, 0);
if (*endptr || port_id < 0 || port_id >= USB_CHARGE_PORT_COUNT) {
- uart_puts("Invalid port ID.\n");
+ ccputs("Invalid port ID.\n");
return EC_ERROR_UNKNOWN;
}
mode = strtoi(argv[2], &endptr, 0);
if (*endptr || mode < 0 || mode >= USB_CHARGE_MODE_COUNT) {
- uart_puts("Invalid mode.\n");
+ ccputs("Invalid mode.\n");
return EC_ERROR_UNKNOWN;
}
- uart_printf("Setting USB mode...\n");
+ ccprintf("Setting USB mode...\n");
return usb_charge_set_mode(port_id, mode);
}
DECLARE_CONSOLE_COMMAND(usbchargemode, command_set_mode);
diff --git a/common/vboot.c b/common/vboot.c
index 727a92ef4b..b96765b97b 100644
--- a/common/vboot.c
+++ b/common/vboot.c
@@ -5,13 +5,17 @@
/* Verified boot module for Chrome EC */
+#include "console.h"
#include "gpio.h"
#include "keyboard_scan.h"
#include "system.h"
-#include "uart.h"
#include "util.h"
#include "vboot.h"
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_VBOOT, outstr)
+#define CPRINTF(format, args...) cprintf(CC_VBOOT, format, ## args)
+
/* Jumps to one of the RW images if necessary. */
static void jump_to_other_image(void)
@@ -23,7 +27,7 @@ static void jump_to_other_image(void)
#ifdef CONFIG_TASK_KEYSCAN
/* Don't jump if recovery requested */
if (keyboard_scan_recovery_pressed()) {
- uart_puts("Vboot staying in RO because key pressed.\n");
+ CPUTS("[Vboot staying in RO because key pressed]\n");
return;
}
#endif
@@ -37,7 +41,7 @@ static void jump_to_other_image(void)
/* TODO: (crosbug.com/p/8572) Daisy and discovery don't define a GPIO
* for the recovery signal from servo, so can't check it. */
if (gpio_get_level(GPIO_RECOVERYn) == 0) {
- uart_puts("Vboot staying in RO due to recovery signal.\n");
+ CPUTS("[Vboot staying in RO due to recovery signal]\n");
return;
}
#endif
diff --git a/common/x86_power.c b/common/x86_power.c
index de6a5cfe5d..1d4a228c88 100644
--- a/common/x86_power.c
+++ b/common/x86_power.c
@@ -20,8 +20,8 @@
#include "x86_power.h"
/* Console output macros */
-#define CPUTS(outstr) cputs(CC_X86POWER, outstr)
-#define CPRINTF(format, args...) cprintf(CC_X86POWER, format, ## args)
+#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
+#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
/* Default timeout in us; if we've been waiting this long for an input
* transition, just jump to the next state. */
diff --git a/core/cortex-m/timer.c b/core/cortex-m/timer.c
index e4915e76ad..1501b0e269 100644
--- a/core/cortex-m/timer.c
+++ b/core/cortex-m/timer.c
@@ -167,7 +167,7 @@ DECLARE_CONSOLE_COMMAND(waitms, command_wait);
static int command_get_time(int argc, char **argv)
{
timestamp_t ts = get_time();
- uart_printf("Time: 0x%016lx = %ld us\n", ts.val, ts.val);
+ ccprintf("Time: 0x%016lx = %ld us\n", ts.val, ts.val);
return EC_SUCCESS;
}
@@ -181,16 +181,16 @@ int command_timer_info(int argc, char **argv)
__hw_clock_event_get();
int tskid;
- uart_printf("Time: 0x%016lx us\n"
- "Deadline: 0x%016lx -> %10ld us from now\n"
- "Active timers:\n",
- t, deadline, deadline - t);
+ ccprintf("Time: 0x%016lx us\n"
+ "Deadline: 0x%016lx -> %10ld us from now\n"
+ "Active timers:\n",
+ t, deadline, deadline - t);
for (tskid = 0; tskid < TASK_ID_COUNT; tskid++) {
if (timer_running & (1<<tskid)) {
- uart_printf(" Tsk %2d 0x%016lx -> %10ld\n", tskid,
- timer_deadline[tskid].val,
- timer_deadline[tskid].val - t);
- uart_flush_output();
+ ccprintf(" Tsk %2d 0x%016lx -> %10ld\n", tskid,
+ timer_deadline[tskid].val,
+ timer_deadline[tskid].val - t);
+ cflush();
}
}
return EC_SUCCESS;
diff --git a/include/console.h b/include/console.h
index b0d3f5b63e..9b7e3b380a 100644
--- a/include/console.h
+++ b/include/console.h
@@ -24,7 +24,11 @@ enum console_channel {
CC_COMMAND = 0, /* Console command (interactive I/O). Use this only
* inside a console command routine. */
CC_CHARGER,
+ CC_CHIPSET,
+ CC_DMA,
+ CC_GPIO,
CC_HOSTCMD,
+ CC_I2C,
CC_I8042,
CC_KEYBOARD,
CC_KEYSCAN,
@@ -35,7 +39,7 @@ enum console_channel {
CC_SYSTEM,
CC_TASK,
CC_USBCHARGE,
- CC_X86POWER,
+ CC_VBOOT,
/* Channel count; not itself a channel */
CC_CHANNEL_COUNT
};