Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Advanced Micro Devices, Inc. |
| 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; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #ifndef SB700_SMBUS_H |
| 21 | #define SB700_SMBUS_H |
| 22 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 23 | #include <stdint.h> |
| 24 | #include "stddef.h" |
| 25 | #include <arch/io.h> |
| 26 | |
| 27 | #define SMBUS_IO_BASE 0x6000 /* Is it a temporary SMBus I/O base address? */ |
| 28 | /*SIZE 0x40 */ |
| 29 | |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 30 | #define SMBHSTSTAT 0x0 |
| 31 | #define SMBSLVSTAT 0x1 |
| 32 | #define SMBHSTCTRL 0x2 |
| 33 | #define SMBHSTCMD 0x3 |
| 34 | #define SMBHSTADDR 0x4 |
| 35 | #define SMBHSTDAT0 0x5 |
| 36 | #define SMBHSTDAT1 0x6 |
| 37 | #define SMBHSTBLKDAT 0x7 |
| 38 | |
| 39 | #define SMBSLVCTRL 0x8 |
| 40 | #define SMBSLVCMD_SHADOW 0x9 |
| 41 | #define SMBSLVEVT 0xa |
| 42 | #define SMBSLVDAT 0xc |
| 43 | |
| 44 | #define AX_INDXC 0 |
| 45 | #define AX_INDXP 1 |
| 46 | #define AXCFG 2 |
| 47 | #define ABCFG 3 |
| 48 | |
| 49 | #define AB_INDX 0xCD8 |
| 50 | #define AB_DATA (AB_INDX+4) |
| 51 | |
| 52 | /* Between 1-10 seconds, We should never timeout normally |
| 53 | * Longer than this is just painful when a timeout condition occurs. |
| 54 | */ |
| 55 | #define SMBUS_TIMEOUT (100*1000*10) |
| 56 | |
| 57 | #define abcfg_reg(reg, mask, val) \ |
| 58 | alink_ab_indx((ABCFG), (reg), (mask), (val)) |
| 59 | #define axcfg_reg(reg, mask, val) \ |
| 60 | alink_ab_indx((AXCFG), (reg), (mask), (val)) |
| 61 | #define axindxc_reg(reg, mask, val) \ |
| 62 | alink_ax_indx(0, (reg), (mask), (val)) |
| 63 | #define axindxp_reg(reg, mask, val) \ |
| 64 | alink_ax_indx(1, (reg), (mask), (val)) |
| 65 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 66 | void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val); |
| 67 | void alink_ax_indx(u32 space, u32 axindc, u32 mask, u32 val); |
Stefan Reinauer | 5e33e82 | 2010-07-07 21:59:06 +0000 | [diff] [blame] | 68 | int do_smbus_recv_byte(u32 smbus_io_base, u32 device); |
| 69 | int do_smbus_send_byte(u32 smbus_io_base, u32 device, u8 val); |
Zheng Bao | 0b2cda8 | 2010-03-23 06:49:16 +0000 | [diff] [blame] | 70 | int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address); |
| 71 | int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val); |
| 72 | |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 73 | #endif |