Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 3 | |
Martin Roth | f5726ea | 2013-01-18 12:55:40 -0700 | [diff] [blame] | 4 | #ifndef HUDSON_SMBUS_H |
| 5 | #define HUDSON_SMBUS_H |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 6 | |
Paul Menzel | 883b03f | 2013-05-06 15:18:57 +0200 | [diff] [blame] | 7 | #include <stdint.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 8 | |
| 9 | #define SMBHSTSTAT 0x0 |
| 10 | #define SMBSLVSTAT 0x1 |
| 11 | #define SMBHSTCTRL 0x2 |
| 12 | #define SMBHSTCMD 0x3 |
| 13 | #define SMBHSTADDR 0x4 |
| 14 | #define SMBHSTDAT0 0x5 |
| 15 | #define SMBHSTDAT1 0x6 |
| 16 | #define SMBHSTBLKDAT 0x7 |
| 17 | |
| 18 | #define SMBSLVCTRL 0x8 |
| 19 | #define SMBSLVCMD_SHADOW 0x9 |
| 20 | #define SMBSLVEVT 0xa |
| 21 | #define SMBSLVDAT 0xc |
| 22 | |
| 23 | #define AX_INDXC 0 |
| 24 | #define AX_INDXP 2 |
| 25 | #define AXCFG 4 |
| 26 | #define ABCFG 6 |
| 27 | #define RC_INDXC 1 |
| 28 | #define RC_INDXP 3 |
| 29 | |
| 30 | #define AB_INDX 0xCD8 |
| 31 | #define AB_DATA (AB_INDX+4) |
| 32 | |
| 33 | /* Between 1-10 seconds, We should never timeout normally |
| 34 | * Longer than this is just painful when a timeout condition occurs. |
| 35 | */ |
| 36 | #define SMBUS_TIMEOUT (100*1000*10) |
| 37 | |
| 38 | #define abcfg_reg(reg, mask, val) \ |
| 39 | alink_ab_indx((ABCFG), (reg), (mask), (val)) |
| 40 | #define axcfg_reg(reg, mask, val) \ |
| 41 | alink_ab_indx((AXCFG), (reg), (mask), (val)) |
| 42 | #define axindxc_reg(reg, mask, val) \ |
| 43 | alink_ax_indx((AX_INDXC), (reg), (mask), (val)) |
| 44 | #define axindxp_reg(reg, mask, val) \ |
| 45 | alink_ax_indx((AX_INDXP), (reg), (mask), (val)) |
| 46 | #define rcindxc_reg(reg, port, mask, val) \ |
| 47 | alink_rc_indx((RC_INDXC), (reg), (port), (mask), (val)) |
| 48 | #define rcindxp_reg(reg, port, mask, val) \ |
| 49 | alink_rc_indx((RC_INDXP), (reg), (port), (mask), (val)) |
| 50 | |
| 51 | int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address); |
| 52 | int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val); |
| 53 | int do_smbus_recv_byte(u32 smbus_io_base, u32 device); |
| 54 | int do_smbus_send_byte(u32 smbus_io_base, u32 device, u8 val); |
| 55 | void alink_rc_indx(u32 reg_space, u32 reg_addr, u32 port, u32 mask, u32 val); |
| 56 | void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val); |
| 57 | void alink_ax_indx(u32 space /*c or p? */ , u32 axindc, u32 mask, u32 val); |
| 58 | |
| 59 | |
| 60 | #endif |