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. |
Timothy Pearson | acbdade | 2015-10-17 04:36:47 -0500 | [diff] [blame] | 5 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 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; version 2 of the License. |
| 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. |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef SB700_SMBUS_H |
| 18 | #define SB700_SMBUS_H |
| 19 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | #include "stddef.h" |
| 22 | #include <arch/io.h> |
| 23 | |
Timothy Pearson | acbdade | 2015-10-17 04:36:47 -0500 | [diff] [blame] | 24 | #define SMBUS_IO_BASE 0xb00 |
| 25 | #define SMBUS_AUX_IO_BASE 0xb20 |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 26 | |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 27 | #define SMBHSTSTAT 0x0 |
| 28 | #define SMBSLVSTAT 0x1 |
| 29 | #define SMBHSTCTRL 0x2 |
| 30 | #define SMBHSTCMD 0x3 |
| 31 | #define SMBHSTADDR 0x4 |
| 32 | #define SMBHSTDAT0 0x5 |
| 33 | #define SMBHSTDAT1 0x6 |
| 34 | #define SMBHSTBLKDAT 0x7 |
| 35 | |
| 36 | #define SMBSLVCTRL 0x8 |
| 37 | #define SMBSLVCMD_SHADOW 0x9 |
| 38 | #define SMBSLVEVT 0xa |
| 39 | #define SMBSLVDAT 0xc |
| 40 | |
| 41 | #define AX_INDXC 0 |
| 42 | #define AX_INDXP 1 |
| 43 | #define AXCFG 2 |
| 44 | #define ABCFG 3 |
| 45 | |
| 46 | #define AB_INDX 0xCD8 |
| 47 | #define AB_DATA (AB_INDX+4) |
| 48 | |
| 49 | /* Between 1-10 seconds, We should never timeout normally |
| 50 | * Longer than this is just painful when a timeout condition occurs. |
| 51 | */ |
| 52 | #define SMBUS_TIMEOUT (100*1000*10) |
| 53 | |
| 54 | #define abcfg_reg(reg, mask, val) \ |
| 55 | alink_ab_indx((ABCFG), (reg), (mask), (val)) |
| 56 | #define axcfg_reg(reg, mask, val) \ |
| 57 | alink_ab_indx((AXCFG), (reg), (mask), (val)) |
| 58 | #define axindxc_reg(reg, mask, val) \ |
| 59 | alink_ax_indx(0, (reg), (mask), (val)) |
| 60 | #define axindxp_reg(reg, mask, val) \ |
| 61 | alink_ax_indx(1, (reg), (mask), (val)) |
| 62 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 63 | void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val); |
| 64 | void alink_ax_indx(u32 space, u32 axindc, u32 mask, u32 val); |
Stefan Reinauer | 5e33e82 | 2010-07-07 21:59:06 +0000 | [diff] [blame] | 65 | int do_smbus_recv_byte(u32 smbus_io_base, u32 device); |
| 66 | 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] | 67 | int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address); |
| 68 | int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val); |
| 69 | |
Zheng Bao | eff2ffd | 2010-03-16 01:38:54 +0000 | [diff] [blame] | 70 | #endif |