Alexandru Gagniuc | ee2bc27 | 2013-05-21 12:35:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Alexandru Gagniuc <mr.nuke.me@gmail.com> |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Alexandru Gagniuc | ee2bc27 | 2013-05-21 12:35:08 -0500 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include "via_early_smbus.h" |
| 18 | #include <console/console.h> |
| 19 | |
| 20 | /** |
| 21 | * \brief Print an error, should it occur. If no error, just exit. |
| 22 | * |
| 23 | * @param smbus_dev The base SMBus IO port |
| 24 | * @param host_status The data returned on the host status register after |
| 25 | * a transaction is processed. |
| 26 | * @param loops The number of times a transaction was attempted. |
| 27 | * @return 0 if no error occurred |
| 28 | * 1 if an error was detected |
| 29 | */ |
| 30 | int smbus_print_error(u32 smbus_dev, u8 host_status, int loops) |
| 31 | { |
| 32 | /* Check if there actually was an error. */ |
| 33 | if ((host_status == 0x00 || host_status == 0x40 || |
| 34 | host_status == 0x42) && (loops < SMBUS_TIMEOUT)) |
| 35 | return 0; |
| 36 | |
| 37 | if (loops >= SMBUS_TIMEOUT) |
| 38 | printsmbus("SMBus timeout\n"); |
| 39 | if (host_status & (1 << 4)) |
| 40 | printsmbus("Interrupt/SMI# was Failed Bus Transaction\n"); |
| 41 | if (host_status & (1 << 3)) |
| 42 | printsmbus("Bus error\n"); |
| 43 | if (host_status & (1 << 2)) |
| 44 | printsmbus("Device error\n"); |
| 45 | if (host_status & (1 << 1)) |
| 46 | printsmbus("Interrupt/SMI# completed successfully\n"); |
| 47 | if (host_status & (1 << 0)) |
| 48 | printsmbus("Host busy\n"); |
| 49 | return 1; |
| 50 | } |