Derek Waldner | 3b42119 | 2016-04-14 12:13:48 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the superiotool project. |
| 3 | * |
| 4 | * Copyright (C) 2016 Derek Waldner |
| 5 | * Copyright (C) 2016 Sencore Inc <opensource@sencore.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #include "superiotool.h" |
| 19 | |
| 20 | #define DEVICE_ID_BYTE1_REG 0x20 |
| 21 | #define DEVICE_ID_BYTE2_REG 0x21 |
| 22 | |
| 23 | #define VENDOR_ID_BYTE1_REG 0x23 |
| 24 | #define VENDOR_ID_BYTE2_REG 0x24 |
| 25 | |
| 26 | #define EXAR_VENDOR_ID 0xa813 |
| 27 | |
| 28 | static const struct superio_registers reg_table[] = { |
| 29 | {0x8403, "XR28V384", { |
| 30 | /* We assume reserved bits are read as 0. */ |
| 31 | {NOLDN, NULL, |
| 32 | {0x02,0x07,0x20,0x21,0x23,0x24,0x25,0x26,0x27,EOT}, |
| 33 | {0x00,0x00,0x03,0x84,0x13,0xa8,0x00,0x00,0x00,EOT}}, |
| 34 | {0x0, "COM1", |
| 35 | {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf4,0xf5,0xf6,EOT}, |
| 36 | {0x01,0x03,0xf8,0x03,0x00,0x44,0x00,0x00,0x00,EOT}}, |
| 37 | {0x1, "COM2", |
| 38 | {0x30,0x60,0x61,0x70,0xf0,0xf4,0xf5,0xf6,EOT}, |
| 39 | {0x01,0x02,0xf8,0x04,0x00,0x00,0x00,0x00,EOT}}, |
| 40 | {0x2, "COM3", |
| 41 | {0x30,0x60,0x61,0x70,0xf0,0xf4,0xf5,0xf6,EOT}, |
| 42 | {0x01,0x03,0xe8,0x05,0x00,0x00,0x00,0x00,EOT}}, |
| 43 | {0x3, "COM4", |
| 44 | {0x30,0x60,0x61,0x70,0xf0,0xf4,0xf5,0xf6,EOT}, |
| 45 | {0x01,0x02,0xe8,0x09,0x00,0x00,0x00,0x00,EOT}}, |
| 46 | {0x8, "WDT", |
| 47 | {0x30,0x60,0x61,0x70,0xf0,0xf1,EOT}, |
| 48 | {0x01,0x04,0x42,0x00,0x02,0x0a,EOT}}, |
| 49 | {EOT}}}, |
| 50 | {EOT} |
| 51 | }; |
| 52 | |
| 53 | void enter_conf_mode_exar(uint16_t port) |
| 54 | { |
| 55 | OUTB(0x67, port); |
| 56 | OUTB(0x67, port); |
| 57 | } |
| 58 | |
| 59 | void exit_conf_mode_exar(uint16_t port) |
| 60 | { |
| 61 | OUTB(0xaa, port); |
| 62 | } |
| 63 | |
| 64 | void probe_idregs_exar(uint16_t port) |
| 65 | { |
| 66 | uint16_t vid, did; |
| 67 | |
| 68 | probing_for("Exar", "", port); |
| 69 | |
| 70 | enter_conf_mode_exar(port); |
| 71 | |
| 72 | did = regval(port, DEVICE_ID_BYTE1_REG); |
| 73 | did |= (regval(port, DEVICE_ID_BYTE2_REG) << 8); |
| 74 | |
| 75 | vid = regval(port, VENDOR_ID_BYTE1_REG); |
| 76 | vid |= (regval(port, VENDOR_ID_BYTE2_REG) << 8); |
| 77 | |
| 78 | if (vid != EXAR_VENDOR_ID || superio_unknown(reg_table, did)) { |
| 79 | if (verbose) |
| 80 | printf(NOTFOUND "vid=0x%04x, id=0x%04x\n", vid, did); |
| 81 | exit_conf_mode_exar(port); |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | printf("Found Exar %s (vid=0x%04x, id=0x%04x) at 0x%x\n", |
| 86 | get_superio_name(reg_table, did), vid, did, port); |
| 87 | chip_found = 1; |
| 88 | |
| 89 | dump_superio("Exar", reg_table, port, did, LDN_SEL); |
| 90 | |
| 91 | exit_conf_mode_exar(port); |
| 92 | } |
| 93 | |
| 94 | void print_exar_chips(void) |
| 95 | { |
| 96 | print_vendor_chips("Exar", reg_table); |
| 97 | } |