xref: /linux/arch/mips/include/asm/sibyte/sb1250_smbus.h (revision bcefe12eff5dca6fdfa94ed85e5bee66380d5cd9)
1 /*  *********************************************************************
2     *  SB1250 Board Support Package
3     *
4     *  SMBUS Constants                          File: sb1250_smbus.h
5     *
6     *  This module contains constants and macros useful for
7     *  manipulating the SB1250's SMbus devices.
8     *
9     *  SB1250 specification level:  10/21/02
10     *  BCM1280 specification level:  11/24/03
11     *
12     *********************************************************************
13     *
14     *  Copyright 2000,2001,2002,2003
15     *  Broadcom Corporation. All rights reserved.
16     *
17     *  This program is free software; you can redistribute it and/or
18     *  modify it under the terms of the GNU General Public License as
19     *  published by the Free Software Foundation; either version 2 of
20     *  the License, or (at your option) any later version.
21     *
22     *  This program is distributed in the hope that it will be useful,
23     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25     *  GNU General Public License for more details.
26     *
27     *  You should have received a copy of the GNU General Public License
28     *  along with this program; if not, write to the Free Software
29     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30     *  MA 02111-1307 USA
31     ********************************************************************* */
32 
33 
34 #ifndef _SB1250_SMBUS_H
35 #define _SB1250_SMBUS_H
36 
37 #include "sb1250_defs.h"
38 
39 /*
40  * SMBus Clock Frequency Register (Table 14-2)
41  */
42 
43 #define S_SMB_FREQ_DIV              0
44 #define M_SMB_FREQ_DIV              _SB_MAKEMASK(13, S_SMB_FREQ_DIV)
45 #define V_SMB_FREQ_DIV(x)           _SB_MAKEVALUE(x, S_SMB_FREQ_DIV)
46 
47 #define K_SMB_FREQ_400KHZ	    0x1F
48 #define K_SMB_FREQ_100KHZ	    0x7D
49 #define K_SMB_FREQ_10KHZ	    1250
50 
51 #define S_SMB_CMD                   0
52 #define M_SMB_CMD                   _SB_MAKEMASK(8, S_SMB_CMD)
53 #define V_SMB_CMD(x)                _SB_MAKEVALUE(x, S_SMB_CMD)
54 
55 /*
56  * SMBus control register (Table 14-4)
57  */
58 
59 #define M_SMB_ERR_INTR              _SB_MAKEMASK1(0)
60 #define M_SMB_FINISH_INTR           _SB_MAKEMASK1(1)
61 
62 #define S_SMB_DATA_OUT              4
63 #define M_SMB_DATA_OUT              _SB_MAKEMASK1(S_SMB_DATA_OUT)
64 #define V_SMB_DATA_OUT(x)           _SB_MAKEVALUE(x, S_SMB_DATA_OUT)
65 
66 #define M_SMB_DATA_DIR              _SB_MAKEMASK1(5)
67 #define M_SMB_DATA_DIR_OUTPUT       M_SMB_DATA_DIR
68 #define M_SMB_CLK_OUT               _SB_MAKEMASK1(6)
69 #define M_SMB_DIRECT_ENABLE         _SB_MAKEMASK1(7)
70 
71 /*
72  * SMBus status registers (Table 14-5)
73  */
74 
75 #define M_SMB_BUSY                  _SB_MAKEMASK1(0)
76 #define M_SMB_ERROR                 _SB_MAKEMASK1(1)
77 #define M_SMB_ERROR_TYPE            _SB_MAKEMASK1(2)
78 
79 #if SIBYTE_HDR_FEATURE(1250, PASS3) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
80 #define S_SMB_SCL_IN                5
81 #define M_SMB_SCL_IN                _SB_MAKEMASK1(S_SMB_SCL_IN)
82 #define V_SMB_SCL_IN(x)             _SB_MAKEVALUE(x, S_SMB_SCL_IN)
83 #define G_SMB_SCL_IN(x)             _SB_GETVALUE(x, S_SMB_SCL_IN, M_SMB_SCL_IN)
84 #endif /* 1250 PASS3 || 112x PASS1 || 1480 */
85 
86 #define S_SMB_REF                   6
87 #define M_SMB_REF                   _SB_MAKEMASK1(S_SMB_REF)
88 #define V_SMB_REF(x)                _SB_MAKEVALUE(x, S_SMB_REF)
89 #define G_SMB_REF(x)                _SB_GETVALUE(x, S_SMB_REF, M_SMB_REF)
90 
91 #define S_SMB_DATA_IN               7
92 #define M_SMB_DATA_IN               _SB_MAKEMASK1(S_SMB_DATA_IN)
93 #define V_SMB_DATA_IN(x)            _SB_MAKEVALUE(x, S_SMB_DATA_IN)
94 #define G_SMB_DATA_IN(x)            _SB_GETVALUE(x, S_SMB_DATA_IN, M_SMB_DATA_IN)
95 
96 /*
97  * SMBus Start/Command registers (Table 14-9)
98  */
99 
100 #define S_SMB_ADDR                  0
101 #define M_SMB_ADDR                  _SB_MAKEMASK(7, S_SMB_ADDR)
102 #define V_SMB_ADDR(x)               _SB_MAKEVALUE(x, S_SMB_ADDR)
103 #define G_SMB_ADDR(x)               _SB_GETVALUE(x, S_SMB_ADDR, M_SMB_ADDR)
104 
105 #define M_SMB_QDATA                 _SB_MAKEMASK1(7)
106 
107 #define S_SMB_TT                    8
108 #define M_SMB_TT                    _SB_MAKEMASK(3, S_SMB_TT)
109 #define V_SMB_TT(x)                 _SB_MAKEVALUE(x, S_SMB_TT)
110 #define G_SMB_TT(x)                 _SB_GETVALUE(x, S_SMB_TT, M_SMB_TT)
111 
112 #define K_SMB_TT_WR1BYTE            0
113 #define K_SMB_TT_WR2BYTE            1
114 #define K_SMB_TT_WR3BYTE            2
115 #define K_SMB_TT_CMD_RD1BYTE        3
116 #define K_SMB_TT_CMD_RD2BYTE        4
117 #define K_SMB_TT_RD1BYTE            5
118 #define K_SMB_TT_QUICKCMD           6
119 #define K_SMB_TT_EEPROMREAD         7
120 
121 #define V_SMB_TT_WR1BYTE	    V_SMB_TT(K_SMB_TT_WR1BYTE)
122 #define V_SMB_TT_WR2BYTE	    V_SMB_TT(K_SMB_TT_WR2BYTE)
123 #define V_SMB_TT_WR3BYTE	    V_SMB_TT(K_SMB_TT_WR3BYTE)
124 #define V_SMB_TT_CMD_RD1BYTE	    V_SMB_TT(K_SMB_TT_CMD_RD1BYTE)
125 #define V_SMB_TT_CMD_RD2BYTE	    V_SMB_TT(K_SMB_TT_CMD_RD2BYTE)
126 #define V_SMB_TT_RD1BYTE	    V_SMB_TT(K_SMB_TT_RD1BYTE)
127 #define V_SMB_TT_QUICKCMD	    V_SMB_TT(K_SMB_TT_QUICKCMD)
128 #define V_SMB_TT_EEPROMREAD	    V_SMB_TT(K_SMB_TT_EEPROMREAD)
129 
130 #define M_SMB_PEC                   _SB_MAKEMASK1(15)
131 
132 /*
133  * SMBus Data Register (Table 14-6) and SMBus Extra Register (Table 14-7)
134  */
135 
136 #define S_SMB_LB                    0
137 #define M_SMB_LB                    _SB_MAKEMASK(8, S_SMB_LB)
138 #define V_SMB_LB(x)                 _SB_MAKEVALUE(x, S_SMB_LB)
139 
140 #define S_SMB_MB                    8
141 #define M_SMB_MB                    _SB_MAKEMASK(8, S_SMB_MB)
142 #define V_SMB_MB(x)                 _SB_MAKEVALUE(x, S_SMB_MB)
143 
144 
145 /*
146  * SMBus Packet Error Check register (Table 14-8)
147  */
148 
149 #define S_SPEC_PEC                  0
150 #define M_SPEC_PEC                  _SB_MAKEMASK(8, S_SPEC_PEC)
151 #define V_SPEC_MB(x)                _SB_MAKEVALUE(x, S_SPEC_PEC)
152 
153 
154 #if SIBYTE_HDR_FEATURE(1250, PASS2) || SIBYTE_HDR_FEATURE(112x, PASS1) || SIBYTE_HDR_FEATURE_CHIP(1480)
155 
156 #define S_SMB_CMDH                  8
157 #define M_SMB_CMDH                  _SB_MAKEMASK(8, S_SMB_CMDH)
158 #define V_SMB_CMDH(x)               _SB_MAKEVALUE(x, S_SMB_CMDH)
159 
160 #define M_SMB_EXTEND		    _SB_MAKEMASK1(14)
161 
162 #define S_SMB_DFMT                  8
163 #define M_SMB_DFMT                  _SB_MAKEMASK(3, S_SMB_DFMT)
164 #define V_SMB_DFMT(x)               _SB_MAKEVALUE(x, S_SMB_DFMT)
165 #define G_SMB_DFMT(x)               _SB_GETVALUE(x, S_SMB_DFMT, M_SMB_DFMT)
166 
167 #define K_SMB_DFMT_1BYTE            0
168 #define K_SMB_DFMT_2BYTE            1
169 #define K_SMB_DFMT_3BYTE            2
170 #define K_SMB_DFMT_4BYTE            3
171 #define K_SMB_DFMT_NODATA           4
172 #define K_SMB_DFMT_CMD4BYTE         5
173 #define K_SMB_DFMT_CMD5BYTE         6
174 #define K_SMB_DFMT_RESERVED         7
175 
176 #define V_SMB_DFMT_1BYTE	    V_SMB_DFMT(K_SMB_DFMT_1BYTE)
177 #define V_SMB_DFMT_2BYTE	    V_SMB_DFMT(K_SMB_DFMT_2BYTE)
178 #define V_SMB_DFMT_3BYTE	    V_SMB_DFMT(K_SMB_DFMT_3BYTE)
179 #define V_SMB_DFMT_4BYTE	    V_SMB_DFMT(K_SMB_DFMT_4BYTE)
180 #define V_SMB_DFMT_NODATA	    V_SMB_DFMT(K_SMB_DFMT_NODATA)
181 #define V_SMB_DFMT_CMD4BYTE	    V_SMB_DFMT(K_SMB_DFMT_CMD4BYTE)
182 #define V_SMB_DFMT_CMD5BYTE	    V_SMB_DFMT(K_SMB_DFMT_CMD5BYTE)
183 #define V_SMB_DFMT_RESERVED	    V_SMB_DFMT(K_SMB_DFMT_RESERVED)
184 
185 #define S_SMB_AFMT                  11
186 #define M_SMB_AFMT                  _SB_MAKEMASK(2, S_SMB_AFMT)
187 #define V_SMB_AFMT(x)               _SB_MAKEVALUE(x, S_SMB_AFMT)
188 #define G_SMB_AFMT(x)               _SB_GETVALUE(x, S_SMB_AFMT, M_SMB_AFMT)
189 
190 #define K_SMB_AFMT_NONE             0
191 #define K_SMB_AFMT_ADDR             1
192 #define K_SMB_AFMT_ADDR_CMD1BYTE    2
193 #define K_SMB_AFMT_ADDR_CMD2BYTE    3
194 
195 #define V_SMB_AFMT_NONE		    V_SMB_AFMT(K_SMB_AFMT_NONE)
196 #define V_SMB_AFMT_ADDR		    V_SMB_AFMT(K_SMB_AFMT_ADDR)
197 #define V_SMB_AFMT_ADDR_CMD1BYTE    V_SMB_AFMT(K_SMB_AFMT_ADDR_CMD1BYTE)
198 #define V_SMB_AFMT_ADDR_CMD2BYTE    V_SMB_AFMT(K_SMB_AFMT_ADDR_CMD2BYTE)
199 
200 #define M_SMB_DIR		    _SB_MAKEMASK1(13)
201 
202 #endif /* 1250 PASS2 || 112x PASS1 || 1480 */
203 
204 #endif
205