Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the LinuxBIOS project. |
| 3 | * |
Uwe Hermann | 4cb7e71 | 2007-09-16 18:17:44 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007 Carl-Daniel Hailfinger |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 5 | * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de> |
| 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 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef SUPERIOTOOL_H |
| 23 | #define SUPERIOTOOL_H |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
Uwe Hermann | 6ff6af7 | 2007-09-18 22:24:34 +0000 | [diff] [blame] | 27 | #include <stdint.h> |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 28 | #include <sys/io.h> |
| 29 | |
Uwe Hermann | d754d2c | 2007-09-18 23:30:24 +0000 | [diff] [blame] | 30 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 31 | |
Uwe Hermann | 4cb7e71 | 2007-09-16 18:17:44 +0000 | [diff] [blame] | 32 | #define EOT -1 /* End Of Table */ |
| 33 | #define NOLDN -2 /* NO LDN needed */ |
| 34 | #define NANA -3 /* Not Available */ |
Uwe Hermann | 6ff6af7 | 2007-09-18 22:24:34 +0000 | [diff] [blame] | 35 | #define RSVD -4 /* Reserved */ |
Uwe Hermann | 4cb7e71 | 2007-09-16 18:17:44 +0000 | [diff] [blame] | 36 | #define MAXNAMELEN 20 /* Maximum Name Length */ |
| 37 | #define MAXLDN 0xa /* Biggest LDN */ |
| 38 | #define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */ |
| 39 | #define MAXNUMIDX 70 /* Maximum number of indexes */ |
| 40 | #define IDXSIZE (MAXNUMIDX + 1) |
Uwe Hermann | d754d2c | 2007-09-18 23:30:24 +0000 | [diff] [blame] | 41 | #define MAXNUMPORTS (2 + 1) /* Maximum number of Super I/O ports */ |
Uwe Hermann | 4cb7e71 | 2007-09-16 18:17:44 +0000 | [diff] [blame] | 42 | |
| 43 | struct superio_registers { |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 44 | int32_t superio_id; /* Signed, as we need EOT. */ |
Uwe Hermann | 4cb7e71 | 2007-09-16 18:17:44 +0000 | [diff] [blame] | 45 | const char name[MAXNAMELEN]; |
Uwe Hermann | 6ff6af7 | 2007-09-18 22:24:34 +0000 | [diff] [blame] | 46 | struct { |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 47 | int ldn; |
| 48 | int idx[IDXSIZE]; |
| 49 | int def[IDXSIZE]; |
Uwe Hermann | 4cb7e71 | 2007-09-16 18:17:44 +0000 | [diff] [blame] | 50 | } ldn[LDNSIZE]; |
| 51 | }; |
| 52 | |
| 53 | /* superiotool.c */ |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 54 | uint8_t regval(uint16_t port, uint8_t reg); |
| 55 | void regwrite(uint16_t port, uint8_t reg, uint8_t val); |
Uwe Hermann | 519419b | 2007-09-16 20:59:01 +0000 | [diff] [blame] | 56 | void dump_superio(const char *name, const struct superio_registers reg_table[], |
Uwe Hermann | 25a6c0f | 2007-09-19 00:48:42 +0000 | [diff] [blame^] | 57 | uint16_t port, uint16_t id); |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 58 | void probe_superio(uint16_t port); |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 59 | |
| 60 | /* fintek.c */ |
Uwe Hermann | 25a6c0f | 2007-09-19 00:48:42 +0000 | [diff] [blame^] | 61 | void enter_conf_mode_fintek(uint16_t port); |
| 62 | void exit_conf_mode_fintek(uint16_t port); |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 63 | void dump_fintek(uint16_t port, uint16_t did); |
| 64 | void probe_idregs_fintek(uint16_t port); |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 65 | |
| 66 | /* ite.c */ |
Uwe Hermann | 25a6c0f | 2007-09-19 00:48:42 +0000 | [diff] [blame^] | 67 | void enter_conf_mode_ite(uint16_t port); |
| 68 | void exit_conf_mode_ite(uint16_t port); |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 69 | void dump_ite(uint16_t port, uint16_t id); |
| 70 | void probe_idregs_ite(uint16_t port); |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 71 | |
| 72 | /* nsc.c */ |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 73 | void dump_ns8374(uint16_t port); |
| 74 | void probe_idregs_simple(uint16_t port); |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 75 | |
Uwe Hermann | 6ff6af7 | 2007-09-18 22:24:34 +0000 | [diff] [blame] | 76 | /* smsc.c */ |
Uwe Hermann | 25a6c0f | 2007-09-19 00:48:42 +0000 | [diff] [blame^] | 77 | void enter_conf_mode_smsc(uint16_t port); |
| 78 | void exit_conf_mode_smsc(uint16_t port); |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 79 | void dump_smsc(uint16_t port, uint16_t id); |
| 80 | void probe_idregs_smsc(uint16_t port); |
Uwe Hermann | d754d2c | 2007-09-18 23:30:24 +0000 | [diff] [blame] | 81 | |
| 82 | /** Table of which config ports to probe on each Super I/O. */ |
| 83 | const static struct { |
Uwe Hermann | de24a0e | 2007-09-19 00:03:14 +0000 | [diff] [blame] | 84 | void (*probe_idregs) (uint16_t port); |
| 85 | int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */ |
Uwe Hermann | d754d2c | 2007-09-18 23:30:24 +0000 | [diff] [blame] | 86 | } superio_ports_table[] = { |
| 87 | {probe_idregs_simple, {0x2e, 0x4e, EOT}}, |
| 88 | {probe_idregs_fintek, {0x2e, 0x4e, EOT}}, |
| 89 | {probe_idregs_ite, {0x2e, 0x4e, EOT}}, |
| 90 | {probe_idregs_smsc, {0x3f0, 0x370, EOT}}, |
| 91 | }; |
Uwe Hermann | 6ff6af7 | 2007-09-18 22:24:34 +0000 | [diff] [blame] | 92 | |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 93 | #endif |