Add support to extended EC series Signed-off-by: Anton Kochkov <anton.koch...@gmail.com> ---
Property changes on: . ___________________________________________________________________ Added: svn:ignore + .ec.c.swp
Index: ectool.c =================================================================== --- ectool.c (revision 5614) +++ ectool.c (working copy) @@ -45,16 +45,17 @@ 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 @@ {"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 @@ case 'V': verbose = 1; break; + case 'i': + dump_idx = 1; case 'h': case '?': default: @@ -99,13 +103,15 @@ } printf("\n\n"); - printf("EC IDX RAM:\n"); - for (i = 0; i < 0x10000; 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"); + } + printf("\n\n"); + } return 0; Index: ec.c =================================================================== --- ec.c (revision 5614) +++ ec.c (working copy) @@ -38,7 +38,7 @@ 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 @@ 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 @@ 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 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); Index: ec.h =================================================================== --- ec.h (revision 5614) +++ ec.h (working copy) @@ -22,8 +22,8 @@ #include <stdint.h> -#define EC_DATA 0x62 -#define EC_SC 0x66 +#define EC_SC 0x66 +#define EC_DATA 0x62 /* 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
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot