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