1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*  *********************************************************************
3     *  SB1250 Board Support Package
4     *
5     *  SMBUS Constants				File: sb1250_smbus.h
6     *
7     *  This module contains constants and macros useful for
8     *  manipulating the SB1250's SMbus devices.
9     *
10     *  SB1250 specification level:  10/21/02
11     *  BCM1280 specification level:  11/24/03
12     *
13     *********************************************************************
14     *
15     *  Copyright 2000,2001,2002,2003
16     *  Broadcom Corporation. All rights reserved.
17     *
18     ********************************************************************* */
19 
20 
21 #ifndef _SB1250_SMBUS_H
22 #define _SB1250_SMBUS_H
23 
24 #include <asm/sibyte/sb1250_defs.h>
25 
26 /*
27  * SMBus Clock Frequency Register (Table 14-2)
28  */
29 
30 #define S_SMB_FREQ_DIV		    0
31 #define M_SMB_FREQ_DIV		    _SB_MAKEMASK(13, S_SMB_FREQ_DIV)
32 #define V_SMB_FREQ_DIV(x)	    _SB_MAKEVALUE(x, S_SMB_FREQ_DIV)
33 
34 #define K_SMB_FREQ_400KHZ	    0x1F
35 #define K_SMB_FREQ_100KHZ	    0x7D
36 #define K_SMB_FREQ_10KHZ	    1250
37 
38 #define S_SMB_CMD		    0
39 #define M_SMB_CMD		    _SB_MAKEMASK(8, S_SMB_CMD)
40 #define V_SMB_CMD(x)		    _SB_MAKEVALUE(x, S_SMB_CMD)
41 
42 /*
43  * SMBus control register (Table 14-4)
44  */
45 
46 #define M_SMB_ERR_INTR		    _SB_MAKEMASK1(0)
47 #define M_SMB_FINISH_INTR	    _SB_MAKEMASK1(1)
48 
49 #define S_SMB_DATA_OUT		    4
50 #define M_SMB_DATA_OUT		    _SB_MAKEMASK1(S_SMB_DATA_OUT)
51 #define V_SMB_DATA_OUT(x)	    _SB_MAKEVALUE(x, S_SMB_DATA_OUT)
52 
53 #define M_SMB_DATA_DIR		    _SB_MAKEMASK1(5)
54 #define M_SMB_DATA_DIR_OUTPUT	    M_SMB_DATA_DIR
55 #define M_SMB_CLK_OUT		    _SB_MAKEMASK1(6)
56 #define M_SMB_DIRECT_ENABLE	    _SB_MAKEMASK1(7)
57 
58 /*
59  * SMBus status registers (Table 14-5)
60  */
61 
62 #define M_SMB_BUSY		    _SB_MAKEMASK1(0)
63 #define M_SMB_ERROR		    _SB_MAKEMASK1(1)
64 #define M_SMB_ERROR_TYPE	    _SB_MAKEMASK1(2)
65 
66 #if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
67 #define S_SMB_SCL_IN		    5
68 #define M_SMB_SCL_IN		    _SB_MAKEMASK1(S_SMB_SCL_IN)
69 #define V_SMB_SCL_IN(x)		    _SB_MAKEVALUE(x, S_SMB_SCL_IN)
70 #define G_SMB_SCL_IN(x)		    _SB_GETVALUE(x, S_SMB_SCL_IN, M_SMB_SCL_IN)
71 #endif /* 1250 PASS3 || 112x PASS1 || 1480 */
72 
73 #define S_SMB_REF		    6
74 #define M_SMB_REF		    _SB_MAKEMASK1(S_SMB_REF)
75 #define V_SMB_REF(x)		    _SB_MAKEVALUE(x, S_SMB_REF)
76 #define G_SMB_REF(x)		    _SB_GETVALUE(x, S_SMB_REF, M_SMB_REF)
77 
78 #define S_SMB_DATA_IN		    7
79 #define M_SMB_DATA_IN		    _SB_MAKEMASK1(S_SMB_DATA_IN)
80 #define V_SMB_DATA_IN(x)	    _SB_MAKEVALUE(x, S_SMB_DATA_IN)
81 #define G_SMB_DATA_IN(x)	    _SB_GETVALUE(x, S_SMB_DATA_IN, M_SMB_DATA_IN)
82 
83 /*
84  * SMBus Start/Command registers (Table 14-9)
85  */
86 
87 #define S_SMB_ADDR		    0
88 #define M_SMB_ADDR		    _SB_MAKEMASK(7, S_SMB_ADDR)
89 #define V_SMB_ADDR(x)		    _SB_MAKEVALUE(x, S_SMB_ADDR)
90 #define G_SMB_ADDR(x)		    _SB_GETVALUE(x, S_SMB_ADDR, M_SMB_ADDR)
91 
92 #define M_SMB_QDATA		    _SB_MAKEMASK1(7)
93 
94 #define S_SMB_TT		    8
95 #define M_SMB_TT		    _SB_MAKEMASK(3, S_SMB_TT)
96 #define V_SMB_TT(x)		    _SB_MAKEVALUE(x, S_SMB_TT)
97 #define G_SMB_TT(x)		    _SB_GETVALUE(x, S_SMB_TT, M_SMB_TT)
98 
99 #define K_SMB_TT_WR1BYTE	    0
100 #define K_SMB_TT_WR2BYTE	    1
101 #define K_SMB_TT_WR3BYTE	    2
102 #define K_SMB_TT_CMD_RD1BYTE	    3
103 #define K_SMB_TT_CMD_RD2BYTE	    4
104 #define K_SMB_TT_RD1BYTE	    5
105 #define K_SMB_TT_QUICKCMD	    6
106 #define K_SMB_TT_EEPROMREAD	    7
107 
108 #define V_SMB_TT_WR1BYTE	    V_SMB_TT(K_SMB_TT_WR1BYTE)
109 #define V_SMB_TT_WR2BYTE	    V_SMB_TT(K_SMB_TT_WR2BYTE)
110 #define V_SMB_TT_WR3BYTE	    V_SMB_TT(K_SMB_TT_WR3BYTE)
111 #define V_SMB_TT_CMD_RD1BYTE	    V_SMB_TT(K_SMB_TT_CMD_RD1BYTE)
112 #define V_SMB_TT_CMD_RD2BYTE	    V_SMB_TT(K_SMB_TT_CMD_RD2BYTE)
113 #define V_SMB_TT_RD1BYTE	    V_SMB_TT(K_SMB_TT_RD1BYTE)
114 #define V_SMB_TT_QUICKCMD	    V_SMB_TT(K_SMB_TT_QUICKCMD)
115 #define V_SMB_TT_EEPROMREAD	    V_SMB_TT(K_SMB_TT_EEPROMREAD)
116 
117 #define M_SMB_PEC		    _SB_MAKEMASK1(15)
118 
119 /*
120  * SMBus Data Register (Table 14-6) and SMBus Extra Register (Table 14-7)
121  */
122 
123 #define S_SMB_LB		    0
124 #define M_SMB_LB		    _SB_MAKEMASK(8, S_SMB_LB)
125 #define V_SMB_LB(x)		    _SB_MAKEVALUE(x, S_SMB_LB)
126 
127 #define S_SMB_MB		    8
128 #define M_SMB_MB		    _SB_MAKEMASK(8, S_SMB_MB)
129 #define V_SMB_MB(x)		    _SB_MAKEVALUE(x, S_SMB_MB)
130 
131 
132 /*
133  * SMBus Packet Error Check register (Table 14-8)
134  */
135 
136 #define S_SPEC_PEC		    0
137 #define M_SPEC_PEC		    _SB_MAKEMASK(8, S_SPEC_PEC)
138 #define V_SPEC_MB(x)		    _SB_MAKEVALUE(x, S_SPEC_PEC)
139 
140 
141 #if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
142 
143 #define S_SMB_CMDH		    8
144 #define M_SMB_CMDH		    _SB_MAKEMASK(8, S_SMB_CMDH)
145 #define V_SMB_CMDH(x)		    _SB_MAKEVALUE(x, S_SMB_CMDH)
146 
147 #define M_SMB_EXTEND		    _SB_MAKEMASK1(14)
148 
149 #define S_SMB_DFMT		    8
150 #define M_SMB_DFMT		    _SB_MAKEMASK(3, S_SMB_DFMT)
151 #define V_SMB_DFMT(x)		    _SB_MAKEVALUE(x, S_SMB_DFMT)
152 #define G_SMB_DFMT(x)		    _SB_GETVALUE(x, S_SMB_DFMT, M_SMB_DFMT)
153 
154 #define K_SMB_DFMT_1BYTE	    0
155 #define K_SMB_DFMT_2BYTE	    1
156 #define K_SMB_DFMT_3BYTE	    2
157 #define K_SMB_DFMT_4BYTE	    3
158 #define K_SMB_DFMT_NODATA	    4
159 #define K_SMB_DFMT_CMD4BYTE	    5
160 #define K_SMB_DFMT_CMD5BYTE	    6
161 #define K_SMB_DFMT_RESERVED	    7
162 
163 #define V_SMB_DFMT_1BYTE	    V_SMB_DFMT(K_SMB_DFMT_1BYTE)
164 #define V_SMB_DFMT_2BYTE	    V_SMB_DFMT(K_SMB_DFMT_2BYTE)
165 #define V_SMB_DFMT_3BYTE	    V_SMB_DFMT(K_SMB_DFMT_3BYTE)
166 #define V_SMB_DFMT_4BYTE	    V_SMB_DFMT(K_SMB_DFMT_4BYTE)
167 #define V_SMB_DFMT_NODATA	    V_SMB_DFMT(K_SMB_DFMT_NODATA)
168 #define V_SMB_DFMT_CMD4BYTE	    V_SMB_DFMT(K_SMB_DFMT_CMD4BYTE)
169 #define V_SMB_DFMT_CMD5BYTE	    V_SMB_DFMT(K_SMB_DFMT_CMD5BYTE)
170 #define V_SMB_DFMT_RESERVED	    V_SMB_DFMT(K_SMB_DFMT_RESERVED)
171 
172 #define S_SMB_AFMT		    11
173 #define M_SMB_AFMT		    _SB_MAKEMASK(2, S_SMB_AFMT)
174 #define V_SMB_AFMT(x)		    _SB_MAKEVALUE(x, S_SMB_AFMT)
175 #define G_SMB_AFMT(x)		    _SB_GETVALUE(x, S_SMB_AFMT, M_SMB_AFMT)
176 
177 #define K_SMB_AFMT_NONE		    0
178 #define K_SMB_AFMT_ADDR		    1
179 #define K_SMB_AFMT_ADDR_CMD1BYTE    2
180 #define K_SMB_AFMT_ADDR_CMD2BYTE    3
181 
182 #define V_SMB_AFMT_NONE		    V_SMB_AFMT(K_SMB_AFMT_NONE)
183 #define V_SMB_AFMT_ADDR		    V_SMB_AFMT(K_SMB_AFMT_ADDR)
184 #define V_SMB_AFMT_ADDR_CMD1BYTE    V_SMB_AFMT(K_SMB_AFMT_ADDR_CMD1BYTE)
185 #define V_SMB_AFMT_ADDR_CMD2BYTE    V_SMB_AFMT(K_SMB_AFMT_ADDR_CMD2BYTE)
186 
187 #define M_SMB_DIR		    _SB_MAKEMASK1(13)
188 
189 #endif /* 1250 PASS2 || 112x PASS1 || 1480 */
190 
191 #endif
192