mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
This adds SPI transaction support, and a debug command to read a few values from the SPI EEPROM. Note that the SPI controller is normally *disabled* with all its I/Os high-Z, so this will not interfere with main processor or Servo on the SPI bus. The bus is only enabled during the SPIROM command itself. BUG=chrome-os-partner:7844 TEST=manual 1) Reboot system 2) on EC console, 'spirom'. Should print Man/Dev ID : 0xef 0x16 JEDEC ID : 0xef 0x40 0x17 Unique ID : 0xd1 0x61 0x44 0xb0 0x63 0x5d 0x40 0x32 Status reg 1: 0x00 Status reg 2: 0x00 Note that unique ID is, well, unique, so it won't match my value. But it should still be something not all 0xff's. 3) Power on the system. x86 should still boot normally, indicating that the EC isn't interfering with the SPI bus. Change-Id: I53bf5fdbbe7a37949375d0463e30e408cc6fb6a8
106 lines
2.9 KiB
C
106 lines
2.9 KiB
C
/* 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.
|
|
*/
|
|
|
|
/* Debug console for Chrome EC */
|
|
|
|
#ifndef __CROS_EC_CONSOLE_H
|
|
#define __CROS_EC_CONSOLE_H
|
|
|
|
#include "board.h"
|
|
#include "common.h"
|
|
|
|
/* Console command; used by DECLARE_CONSOLE_COMMAND macro. */
|
|
struct console_command {
|
|
/* Command name. Case-insensitive. */
|
|
const char *name;
|
|
/* Handler for the command. argv[0] will be the command name. */
|
|
int (*handler)(int argc, char **argv);
|
|
#ifdef CONFIG_CONSOLE_CMDHELP
|
|
/* Description of args */
|
|
const char *argdesc;
|
|
/* Short help for command */
|
|
const char *shorthelp;
|
|
#endif
|
|
};
|
|
|
|
|
|
/* Console channels */
|
|
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,
|
|
CC_LIGHTBAR,
|
|
CC_LPC,
|
|
CC_PORT80,
|
|
CC_POWERBTN,
|
|
CC_PWM,
|
|
CC_SPI,
|
|
CC_SYSTEM,
|
|
CC_TASK,
|
|
CC_USBCHARGE,
|
|
CC_VBOOT,
|
|
/* Channel count; not itself a channel */
|
|
CC_CHANNEL_COUNT
|
|
};
|
|
|
|
/* Mask in channel_mask for a particular channel */
|
|
#define CC_MASK(channel) (1UL << (channel))
|
|
|
|
/* Mask to use to enable all channels */
|
|
#define CC_ALL 0xffffffffUL
|
|
|
|
|
|
/* Put a string to the console channel. */
|
|
int cputs(enum console_channel channel, const char *outstr);
|
|
|
|
/* Print formatted output to the console channel. See uart_vprintf() for
|
|
* valid format codes. */
|
|
int cprintf(enum console_channel channel, const char *format, ...);
|
|
|
|
/* Flush the console output for all channels. */
|
|
void cflush(void);
|
|
|
|
/* Convenience macros for printing to the command channel.
|
|
*
|
|
* Modules may define similar macros in their .c files for their own use; it is
|
|
* recommended those module-specific macros be named CPUTS and CPRINTF. */
|
|
#define ccputs(outstr) cputs(CC_COMMAND, outstr)
|
|
/* gcc allows variable arg lists in macros; see
|
|
* http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html */
|
|
#define ccprintf(format, args...) cprintf(CC_COMMAND, format, ## args)
|
|
|
|
|
|
/* Called by UART when a line of input is pending. */
|
|
void console_has_input(void);
|
|
|
|
|
|
/*
|
|
* Register a console command handler. Note that `name' must never be a
|
|
* beginning of another existing command name.
|
|
*/
|
|
#ifdef CONFIG_CONSOLE_CMDHELP
|
|
#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \
|
|
static const char __con_cmd_label_##name[] = #name; \
|
|
const struct console_command __con_cmd_##name \
|
|
__attribute__((section(".rodata.cmds." #name))) \
|
|
= {__con_cmd_label_##name, routine, argdesc, shorthelp}
|
|
#else
|
|
#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \
|
|
static const char __con_cmd_label_##name[] = #name; \
|
|
const struct console_command __con_cmd_##name \
|
|
__attribute__((section(".rodata.cmds." #name))) \
|
|
= {__con_cmd_label_##name, routine}
|
|
#endif
|
|
|
|
#endif /* __CROS_EC_CONSOLE_H */
|