blob: 0e6b7b80d12efead86ada6236ec81d761a1f5d2f [file] [log] [blame]
Zheng Baoeff2ffd2010-03-16 01:38:54 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
Timothy Pearsonacbdade2015-10-17 04:36:47 -05005 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
Zheng Baoeff2ffd2010-03-16 01:38:54 +00006 *
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 Baoeff2ffd2010-03-16 01:38:54 +000015 */
16
17#ifndef SB700_SMBUS_H
18#define SB700_SMBUS_H
19
efdesign9800c8c4a2011-07-20 12:37:58 -060020#include <stdint.h>
21#include "stddef.h"
22#include <arch/io.h>
23
Timothy Pearsonacbdade2015-10-17 04:36:47 -050024#define SMBUS_IO_BASE 0xb00
25#define SMBUS_AUX_IO_BASE 0xb20
efdesign9800c8c4a2011-07-20 12:37:58 -060026
Zheng Baoeff2ffd2010-03-16 01:38:54 +000027#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
efdesign9800c8c4a2011-07-20 12:37:58 -060063void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val);
64void alink_ax_indx(u32 space, u32 axindc, u32 mask, u32 val);
Stefan Reinauer5e33e822010-07-07 21:59:06 +000065int do_smbus_recv_byte(u32 smbus_io_base, u32 device);
66int do_smbus_send_byte(u32 smbus_io_base, u32 device, u8 val);
Zheng Bao0b2cda82010-03-23 06:49:16 +000067int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address);
68int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val);
69
Zheng Baoeff2ffd2010-03-16 01:38:54 +000070#endif