Alexandru Gagniuc | 359501a | 2013-05-21 12:17:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 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. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | /** |
Martin Roth | 2507820 | 2015-01-06 21:05:23 -0700 | [diff] [blame] | 21 | * @file device/early_smbus.h |
Alexandru Gagniuc | 359501a | 2013-05-21 12:17:58 -0500 | [diff] [blame] | 22 | * |
| 23 | * This file defines a common API for accessing the SMBus during early |
| 24 | * initialization. It defines the prototypes for common SMBus functions. The |
| 25 | * actual implementations are hardware-dependent. |
| 26 | * |
| 27 | * The first parameter of all SMBus functions take a u32 value smbus_dev which |
| 28 | * represents some information on how to access the device, and is |
| 29 | * implementation defined. Usually, it just contains the IO base for the smbus. |
| 30 | * To get this argument @ref smbus_get_device() can be used. |
| 31 | * |
| 32 | * The header only defines the prototypes. Several steps are needed to use |
| 33 | * these: |
| 34 | * |
| 35 | * 1. Include this header |
| 36 | * @code{.c} |
| 37 | * #include <device/early_smbus.h> |
| 38 | * @endcode |
| 39 | * |
| 40 | * 2. Implement early_smbus.c for the hardware, or find a compatible |
| 41 | * implementation. |
| 42 | * |
| 43 | * 3. Link against the file that implements these functions. In the Makefile.inc |
| 44 | * of the chipset, add: |
| 45 | * @code |
| 46 | * romstage-y += ./path/to/early_smbus.c |
| 47 | * @endcode |
| 48 | */ |
| 49 | |
| 50 | #ifndef DEVICE_EARLY_SMBUS_H |
| 51 | #define DEVICE_EARLY_SMBUS_H |
| 52 | |
| 53 | #include <stdint.h> |
| 54 | |
| 55 | /** |
| 56 | * \brief printk macro for SMBus debugging |
| 57 | */ |
Alexandru Gagniuc | 5c4645b | 2013-06-05 20:01:42 -0500 | [diff] [blame] | 58 | #if defined(CONFIG_DEBUG_SMBUS) && (CONFIG_DEBUG_SMBUS) |
Alexandru Gagniuc | 359501a | 2013-05-21 12:17:58 -0500 | [diff] [blame] | 59 | #define printsmbus(x, ...) printk(BIOS_DEBUG, x, ##__VA_ARGS__) |
| 60 | #else |
| 61 | #define printsmbus(x, ...) |
| 62 | #endif |
| 63 | |
| 64 | u32 smbus_get_device(void); |
| 65 | void smbus_reset(u32 smbus_dev); |
| 66 | int smbus_print_error(u32 smbus_dev, u8 host_status, int loops); |
| 67 | int smbus_is_busy(u32 smbus_dev); |
| 68 | int smbus_wait_until_ready(u32 smbus_dev); |
| 69 | u8 smbus_read_byte(u32 smbus_dev, u8 addr, u8 offset); |
| 70 | |
| 71 | void smbus_delay(void); |
| 72 | |
| 73 | #endif /* DEVICE_EARLY_SMBUS_H */ |