Add support to extended EC series

Signed-off-by: Anton Kochkov <anton.kochkov@gmail.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5650 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Anton Kochkov 2010-06-29 21:13:20 +00:00 committed by Stefan Reinauer
parent 9a82eebe1a
commit 7e59f769ef
3 changed files with 52 additions and 19 deletions

View File

@ -38,7 +38,7 @@ int send_ec_command(uint8_t command)
debug("."); debug(".");
} }
if (!timeout) { if (!timeout) {
printf("Timeout while sending command 0x%02x to EC!\n", debug("Timeout while sending command 0x%02x to EC!\n",
command); command);
// return -1; // return -1;
} }
@ -57,8 +57,8 @@ int send_ec_data(uint8_t data)
if ((timeout & 0xff) == 0) if ((timeout & 0xff) == 0)
debug("."); debug(".");
} }
if (!timeout) { if (timeout) {
printf("Timeout while sending data 0x%02x to EC!\n", data); debug("Timeout while sending data 0x%02x to EC!\n", data);
// return -1; // return -1;
} }
@ -89,7 +89,7 @@ uint8_t recv_ec_data(void)
debug("."); debug(".");
} }
if (!timeout) { if (!timeout) {
printf("\nTimeout while receiving data from EC!\n"); debug("\nTimeout while receiving data from EC!\n");
// return -1; // return -1;
} }
@ -101,15 +101,37 @@ uint8_t recv_ec_data(void)
uint8_t ec_read(uint8_t addr) uint8_t ec_read(uint8_t addr)
{ {
send_ec_command(0x80); send_ec_command(RD_EC);
send_ec_data(addr); send_ec_data(addr);
return recv_ec_data(); return recv_ec_data();
} }
uint8_t ec_ext_read(uint16_t addr)
{
send_ec_command(WR_EC);
send_ec_data(0x02);
send_ec_data(addr & 0xff);
send_ec_command(RX_EC);
send_ec_data(addr >> 8);
return recv_ec_data();
}
int ec_ext_write(uint16_t addr, uint8_t data)
{
send_ec_command(WR_EC);
send_ec_data(0x02);
send_ec_data(addr & 0xff);
send_ec_command(WX_EC);
send_ec_data(addr >> 8);
return send_ec_data(data);
}
int ec_write(uint8_t addr, uint8_t data) int ec_write(uint8_t addr, uint8_t data)
{ {
send_ec_command(0x81); send_ec_command(WR_EC);
send_ec_data(addr); send_ec_data(addr);
return send_ec_data(data); return send_ec_data(data);

View File

@ -22,8 +22,8 @@
#include <stdint.h> #include <stdint.h>
#define EC_DATA 0x62 #define EC_DATA 0x62
#define EC_SC 0x66 #define EC_SC 0x66
/* EC_SC input */ /* EC_SC input */
#define EC_SMI_EVT (1 << 6) // 1: SMI event pending #define EC_SMI_EVT (1 << 6) // 1: SMI event pending
@ -40,12 +40,16 @@
#define BE_EC 0x82 // Burst Enable Embedded Controller #define BE_EC 0x82 // Burst Enable Embedded Controller
#define BD_EC 0x83 // Burst Disable Embedded Controller #define BD_EC 0x83 // Burst Disable Embedded Controller
#define QR_EC 0x84 // Query Embedded Controller #define QR_EC 0x84 // Query Embedded Controller
#define RX_EC 0xf0 // Read Extended operation
#define WX_EC 0xf1 // Write Extended operation
int send_ec_command(uint8_t command); int send_ec_command(uint8_t command);
int send_ec_data(uint8_t data); int send_ec_data(uint8_t data);
int send_ec_data_nowait(uint8_t data); int send_ec_data_nowait(uint8_t data);
uint8_t recv_ec_data(void); uint8_t recv_ec_data(void);
uint8_t ec_read(uint8_t addr); uint8_t ec_read(uint8_t addr);
int ec_write(uint8_t addr, uint8_t data);
uint8_t ec_ext_read(uint16_t addr);
int ec_ext_write(uint16_t addr, uint8_t data);
uint8_t ec_idx_read(uint16_t addr); uint8_t ec_idx_read(uint16_t addr);
#endif #endif

View File

@ -45,16 +45,17 @@ void print_version(void)
void print_usage(const char *name) void print_usage(const char *name)
{ {
printf("usage: %s [-vh?V]\n", name); printf("usage: %s [-vh?Vi]\n", name);
printf("\n" printf("\n"
" -v | --version: print the version\n" " -v | --version: print the version\n"
" -h | --help: print this help\n\n" " -h | --help: print this help\n\n"
" -V | --verbose: print debug information\n" " -V | --verbose: print debug information\n"
" -i | --idx: print IDX RAM\n"
"\n"); "\n");
exit(1); exit(1);
} }
int verbose = 0; int verbose = 0, dump_idx = 0;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -64,10 +65,11 @@ int main(int argc, char *argv[])
{"version", 0, 0, 'v'}, {"version", 0, 0, 'v'},
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"verbose", 0, 0, 'V'}, {"verbose", 0, 0, 'V'},
{"idx", 0, 0, 'i'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
while ((opt = getopt_long(argc, argv, "vh?V", while ((opt = getopt_long(argc, argv, "vh?Vi",
long_options, &option_index)) != EOF) { long_options, &option_index)) != EOF) {
switch (opt) { switch (opt) {
case 'v': case 'v':
@ -77,6 +79,8 @@ int main(int argc, char *argv[])
case 'V': case 'V':
verbose = 1; verbose = 1;
break; break;
case 'i':
dump_idx = 1;
case 'h': case 'h':
case '?': case '?':
default: default:
@ -99,14 +103,17 @@ int main(int argc, char *argv[])
} }
printf("\n\n"); printf("\n\n");
printf("EC IDX RAM:\n"); if (dump_idx) {
for (i = 0; i < 0x10000; i++) { printf("EC IDX RAM:\n");
if ((i % 0x10) == 0) for (i = 0; i < 0x10000; i++) {
printf("\n%04x: ", i); if ((i % 0x10) == 0)
printf("%02x ", ec_idx_read(i)); printf("\n%04x: ", i);
printf("%02x ", ec_idx_read(i));
}
printf("\n\n");
} else {
printf("Not dumping EC IDX RAM.\n");
} }
printf("\n\n");
return 0; return 0;
} }