diff options
author | Anton Kochkov <anton.kochkov@gmail.com> | 2010-06-29 21:13:20 +0000 |
---|---|---|
committer | Stefan Reinauer <stepan@openbios.org> | 2010-06-29 21:13:20 +0000 |
commit | 7e59f769ef02599a6e88df7443780727dc64e3ca (patch) | |
tree | 0107a088d81e0577899e47265ab64cc61afbf3a0 | |
parent | 9a82eebe1a60ed5e49fbfc14cbe006c320846f01 (diff) |
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
-rw-r--r-- | util/ectool/ec.c | 34 | ||||
-rw-r--r-- | util/ectool/ec.h | 10 | ||||
-rw-r--r-- | util/ectool/ectool.c | 27 |
3 files changed, 52 insertions, 19 deletions
diff --git a/util/ectool/ec.c b/util/ectool/ec.c index 35c8d789ab..233e9ba459 100644 --- a/util/ectool/ec.c +++ b/util/ectool/ec.c @@ -38,7 +38,7 @@ int send_ec_command(uint8_t command) debug("."); } if (!timeout) { - printf("Timeout while sending command 0x%02x to EC!\n", + debug("Timeout while sending command 0x%02x to EC!\n", command); // return -1; } @@ -57,8 +57,8 @@ int send_ec_data(uint8_t data) if ((timeout & 0xff) == 0) debug("."); } - if (!timeout) { - printf("Timeout while sending data 0x%02x to EC!\n", data); + if (timeout) { + debug("Timeout while sending data 0x%02x to EC!\n", data); // return -1; } @@ -89,7 +89,7 @@ uint8_t recv_ec_data(void) debug("."); } if (!timeout) { - printf("\nTimeout while receiving data from EC!\n"); + debug("\nTimeout while receiving data from EC!\n"); // return -1; } @@ -101,15 +101,37 @@ uint8_t recv_ec_data(void) uint8_t ec_read(uint8_t addr) { - send_ec_command(0x80); + send_ec_command(RD_EC); send_ec_data(addr); 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) { - send_ec_command(0x81); + send_ec_command(WR_EC); send_ec_data(addr); return send_ec_data(data); diff --git a/util/ectool/ec.h b/util/ectool/ec.h index 7400778117..94ddbf893b 100644 --- a/util/ectool/ec.h +++ b/util/ectool/ec.h @@ -22,8 +22,8 @@ #include <stdint.h> -#define EC_DATA 0x62 -#define EC_SC 0x66 +#define EC_DATA 0x62 +#define EC_SC 0x66 /* EC_SC input */ #define EC_SMI_EVT (1 << 6) // 1: SMI event pending @@ -40,12 +40,16 @@ #define BE_EC 0x82 // Burst Enable Embedded Controller #define BD_EC 0x83 // Burst Disable 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_data(uint8_t data); int send_ec_data_nowait(uint8_t data); uint8_t recv_ec_data(void); 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); #endif diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c index b7bb0ef079..086f159b30 100644 --- a/util/ectool/ectool.c +++ b/util/ectool/ectool.c @@ -45,16 +45,17 @@ void print_version(void) void print_usage(const char *name) { - printf("usage: %s [-vh?V]\n", name); + printf("usage: %s [-vh?Vi]\n", name); printf("\n" " -v | --version: print the version\n" " -h | --help: print this help\n\n" " -V | --verbose: print debug information\n" + " -i | --idx: print IDX RAM\n" "\n"); exit(1); } -int verbose = 0; +int verbose = 0, dump_idx = 0; int main(int argc, char *argv[]) { @@ -64,10 +65,11 @@ int main(int argc, char *argv[]) {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'}, {"verbose", 0, 0, 'V'}, + {"idx", 0, 0, 'i'}, {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) { switch (opt) { case 'v': @@ -77,6 +79,8 @@ int main(int argc, char *argv[]) case 'V': verbose = 1; break; + case 'i': + dump_idx = 1; case 'h': case '?': default: @@ -99,14 +103,17 @@ int main(int argc, char *argv[]) } printf("\n\n"); - printf("EC IDX RAM:\n"); - for (i = 0; i < 0x10000; i++) { - if ((i % 0x10) == 0) - printf("\n%04x: ", i); - printf("%02x ", ec_idx_read(i)); + if (dump_idx) { + printf("EC IDX RAM:\n"); + for (i = 0; i < 0x10000; i++) { + if ((i % 0x10) == 0) + 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; } |