Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 2 | |
| 3 | #ifndef _SB800_SMBUS_H_ |
| 4 | #define _SB800_SMBUS_H_ |
| 5 | |
Elyes HAOUAS | 0141f0d | 2020-10-01 10:22:34 +0200 | [diff] [blame] | 6 | #include <stdint.h> |
| 7 | |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 8 | #define SMBUS_IO_BASE SMBUS0_BASE_ADDRESS |
| 9 | |
Elyes HAOUAS | 0141f0d | 2020-10-01 10:22:34 +0200 | [diff] [blame] | 10 | #define SMBHSTSTAT 0x0 |
| 11 | #define SMBSLVSTAT 0x1 |
| 12 | #define SMBHSTCTRL 0x2 |
| 13 | #define SMBHSTCMD 0x3 |
| 14 | #define SMBHSTADDR 0x4 |
| 15 | #define SMBHSTDAT0 0x5 |
| 16 | #define SMBHSTDAT1 0x6 |
| 17 | #define SMBHSTBLKDAT 0x7 |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 18 | |
Elyes HAOUAS | 0141f0d | 2020-10-01 10:22:34 +0200 | [diff] [blame] | 19 | #define SMBSLVCTRL 0x8 |
| 20 | #define SMBSLVCMD_SHADOW 0x9 |
| 21 | #define SMBSLVEVT 0xa |
| 22 | #define SMBSLVDAT 0xc |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 23 | |
Elyes HAOUAS | 0141f0d | 2020-10-01 10:22:34 +0200 | [diff] [blame] | 24 | #define AB_INDX 0xcd8 |
| 25 | #define AB_DATA (AB_INDX + 4) |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 26 | |
| 27 | /* Between 1-10 seconds, We should never timeout normally |
| 28 | * Longer than this is just painful when a timeout condition occurs. |
| 29 | */ |
Elyes Haouas | 8833d65 | 2022-07-16 09:40:29 +0200 | [diff] [blame] | 30 | #define SMBUS_TIMEOUT (100 * 1000 * 10) |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 31 | |
| 32 | #define abcfg_reg(reg, mask, val) \ |
| 33 | alink_ab_indx((ABCFG), (reg), (mask), (val)) |
| 34 | #define axcfg_reg(reg, mask, val) \ |
| 35 | alink_ab_indx((AXCFG), (reg), (mask), (val)) |
| 36 | #define axindxc_reg(reg, mask, val) \ |
| 37 | alink_ax_indx((AX_INDXC), (reg), (mask), (val)) |
| 38 | #define axindxp_reg(reg, mask, val) \ |
| 39 | alink_ax_indx((AX_INDXP), (reg), (mask), (val)) |
| 40 | #define rcindxc_reg(reg, port, mask, val) \ |
| 41 | alink_rc_indx((RC_INDXC), (reg), (port), (mask), (val)) |
| 42 | #define rcindxp_reg(reg, port, mask, val) \ |
| 43 | alink_rc_indx((RC_INDXP), (reg), (port), (mask), (val)) |
| 44 | |
| 45 | int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address); |
| 46 | int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val); |
| 47 | int do_smbus_recv_byte(u32 smbus_io_base, u32 device); |
| 48 | int do_smbus_send_byte(u32 smbus_io_base, u32 device, u8 val); |
| 49 | void alink_rc_indx(u32 reg_space, u32 reg_addr, u32 port, u32 mask, u32 val); |
| 50 | void alink_ab_indx(u32 reg_space, u32 reg_addr, u32 mask, u32 val); |
Elyes Haouas | 8833d65 | 2022-07-16 09:40:29 +0200 | [diff] [blame] | 51 | void alink_ax_indx(u32 space /*c or p? */, u32 axindc, u32 mask, u32 val); |
Frank Vibrans | 63e62b0 | 2011-02-14 18:38:14 +0000 | [diff] [blame] | 52 | |
| 53 | #endif |