blob: 5ac4ea603ec223cbfb1472c17bbac027ccf5bd64 [file] [log] [blame]
Zheng Baod0985752011-01-20 04:45:48 +00001/*
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.
Zheng Baod0985752011-01-20 04:45:48 +000014 */
15
16#ifndef SB800_SMBUS_H
17#define SB800_SMBUS_H
18
19//#include <stdint.h>
20
21#define SMBHSTSTAT 0x0
22#define SMBSLVSTAT 0x1
23#define SMBHSTCTRL 0x2
24#define SMBHSTCMD 0x3
25#define SMBHSTADDR 0x4
26#define SMBHSTDAT0 0x5
27#define SMBHSTDAT1 0x6
28#define SMBHSTBLKDAT 0x7
29
30#define SMBSLVCTRL 0x8
31#define SMBSLVCMD_SHADOW 0x9
32#define SMBSLVEVT 0xa
33#define SMBSLVDAT 0xc
34
35#define AX_INDXC 0
36#define AX_INDXP 2
37#define AXCFG 4
38#define ABCFG 6
39#define RC_INDXC 1
40#define RC_INDXP 3
41
42#define AB_INDX 0xCD8
43#define AB_DATA (AB_INDX+4)
44
45/* Between 1-10 seconds, We should never timeout normally
46 * Longer than this is just painful when a timeout condition occurs.
47 */
48#define SMBUS_TIMEOUT (100*1000*10)
49
50#define abcfg_reg(reg, mask, val) \
51 alink_ab_indx((ABCFG), (reg), (mask), (val))
52#define axcfg_reg(reg, mask, val) \
53 alink_ab_indx((AXCFG), (reg), (mask), (val))
54#define axindxc_reg(reg, mask, val) \
55 alink_ax_indx((AX_INDXC), (reg), (mask), (val))
56#define axindxp_reg(reg, mask, val) \
57 alink_ax_indx((AX_INDXP), (reg), (mask), (val))
58#define rcindxc_reg(reg, port, mask, val) \
59 alink_rc_indx((RC_INDXC), (reg), (port), (mask), (val))
60#define rcindxp_reg(reg, port, mask, val) \
61 alink_rc_indx((RC_INDXP), (reg), (port), (mask), (val))
62
63int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address);
64int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val);
65int do_smbus_recv_byte(u32 smbus_io_base, u32 device);
66int do_smbus_send_byte(u32 smbus_io_base, u32 device, u8 val);
67void alink_rc_indx(u32 reg_space, u32 reg_addr, u32 port, u32 mask, u32 val);
68void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val);
69void alink_ax_indx(u32 space /*c or p? */ , u32 axindc, u32 mask, u32 val);
70
71
72#endif