blob: ad0edaa71335c17d4b7cc69bf07ea7d2b2f11fb2 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2<:copyright-BRCM:2016:DUAL/GPL:standard
3
4 Broadcom Proprietary and Confidential.(c) 2016 Broadcom
5 All Rights Reserved
6
7Unless you and Broadcom execute a separate written software license
8agreement governing use of this software, this software is licensed
9to you under the terms of the GNU General Public License version 2
10(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
11with the following added to such license:
12
13 As a special exception, the copyright holders of this software give
14 you permission to link this software with independent modules, and
15 to copy and distribute the resulting executable under terms of your
16 choice, provided that you also meet, for each linked independent
17 module, the terms and conditions of the license of that module.
18 An independent module is a module which is not derived from this
19 software. The special exception does not apply to any modifications
20 of the software.
21
22Not withstanding the above, under no circumstances may you combine
23this software in any way with any other Broadcom software provided
24under a license other than the GPL, without Broadcom's express prior
25written consent.
26
27:>
28 */
29
30#ifndef _BCMOLT_I2C_DEVS_H_
31#define _BCMOLT_I2C_DEVS_H_
32
33/* When inserting the module (with insmod) onlt the I2C switch devices (I2C_SWX_I2C_ADDR)
34 will be automatically detected, and therefore will be probed.
35 Probing all other devices can be done after inerting the module via sysfs.
36 for example, in order to probe FPGA device, the following line should be applied:
37 -- echo maple_i2c FPGA_I2C_ADDR > /sys/bus/i2c/devices/i2c-0/new_device --
38*/
39enum client_num
40{
41 SLAVE_SWITCH_70 = 0,
42 SLAVE_SWITCH_71 = 1,
43 SLAVE_SWITCH_72 = 2,
44 SLAVE_SWITCH_73 = 3,
45 SLAVE_SWITCH_74 = 4,
46 SLAVE_SFP_50 = 5,
47 SLAVE_SFP_51 = 6,
48 SLAVE_FPGA_40 = 7,
49 SLAVE_PON_DPLL_68 = 8,
50 SLAVE_PM_DPLL_6A = 9,
51 SLAVE_CXP_R_54 = 10,
52 SLAVE_PCIE_SW_3C = 11,
53 SLAVE_NUM_OF_SLAVES
54};
55
56
57/*****************************************************************
58 maple_i2c_write
59
60 DESCRIPTION:
61 Writes serially data to I2C device
62
63 PARAMETERS:
64 client num - The client to write to.
65 buf - The buffer to write.
66 count - Number of bytes to write
67
68 OUTPUT:
69 The number of bytes that were written, when fails return negative number
70********************************************************************/
71ssize_t maple_i2c_write(unsigned char client_num, char *buf, size_t count);
72
73/*****************************************************************
74 maple_i2c_read
75
76 DESCRIPTION:
77 Read serially data from I2C device
78
79 PARAMETERS:
80 client num - The client to write to.
81 buf - The buffer to read to.
82 count - Number of bytes to read
83
84 OUTPUT:
85 The number of bytes that were read, when fails return negative number
86********************************************************************/
87ssize_t maple_i2c_read(unsigned char client_num, char *buf, size_t count);
88
89/*****************************************************************
90 maple_i2c_write_byte
91
92 DESCRIPTION:
93 Write byte to I2C device
94
95 PARAMETERS:
96 client num - The client to write to.
97 offset - The offset to write to.
98 val - Tha data to write.
99
100 OUTPUT:
101 0 on success, -1 on failure.
102********************************************************************/
103int maple_i2c_write_byte(unsigned char client_num, unsigned char offset, unsigned char val);
104
105/*****************************************************************
106 maple_i2c_read_byte
107
108 DESCRIPTION:
109 Read byte from I2C device
110
111 PARAMETERS:
112 client num - The client to read from.
113 offset - The offset to read from.
114 data - the read value is written to this pointer.
115 OUTPUT:
116 0 on success, -1 on failure.
117********************************************************************/
118int maple_i2c_read_byte(unsigned char client_num, unsigned char offset, unsigned char* data);
119
120/*****************************************************************
121 maple_i2c_write_word
122
123 DESCRIPTION:
124 Write 16 bit word to I2C device
125
126 PARAMETERS:
127 client num - The client to write to.
128 offset - The offset to write to.
129 val - Tha data to write.
130
131 OUTPUT:
132 0 on success, -1 on failure.
133********************************************************************/
134int maple_i2c_write_word(unsigned char client_num, unsigned char offset, unsigned short val);
135
136/*****************************************************************
137 maple_i2c_read_word
138
139 DESCRIPTION:
140 Read 16 bit word from I2C device
141
142 PARAMETERS:
143 client num - The client to read from.
144 offset - The offset to read from.
145 data - the read value is written to this pointer.
146 OUTPUT:
147 0 on success, -1 on failure.
148********************************************************************/
149int maple_i2c_read_word(unsigned char client_num, unsigned char offset, unsigned short* data);
150
151/*****************************************************************
152 maple_i2c_write_reg
153
154 DESCRIPTION:
155 Write 32 bit register to I2C device
156
157 PARAMETERS:
158 client num - The client to write to.
159 offset - The offset to write to.
160 val - Tha data to write.
161
162 OUTPUT:
163 0 on success, -1 on failure.
164********************************************************************/
165int maple_i2c_write_reg(unsigned char client_num, unsigned char offset, int val);
166
167/*****************************************************************
168 maple_i2c_read_reg
169
170 DESCRIPTION:
171 Read 32 bit word from I2C device
172
173 PARAMETERS:
174 client num - The client to read from.
175 offset - The offset to read from.
176 data - the read value is written to this pointer.
177 OUTPUT:
178 0 on success, -1 on failure.
179********************************************************************/
180int maple_i2c_read_reg(unsigned char client_num, unsigned char offset, unsigned int* data);
181
182/*****************************************************************
183 maple_i2c_write_fpga
184
185 DESCRIPTION:
186 Write 32 bit register to I2C fpga device
187
188 PARAMETERS:
189 client num - The client to write to.
190 offset - The offset to write to.
191 val - Tha data to write.
192
193 OUTPUT:
194 0 on success, -1 on failure.
195********************************************************************/
196int maple_i2c_write_fpga(unsigned char client_num, unsigned int offset, unsigned int val);
197
198/*****************************************************************
199 maple_i2c_read_fpga
200
201 DESCRIPTION:
202 Read 32 bit word from I2C fpga device
203
204 PARAMETERS:
205 client num - The client to read from.
206 offset - The offset to read from.
207 data - the read value is written to this pointer.
208 OUTPUT:
209 0 on success, -1 on failure.
210********************************************************************/
211int maple_i2c_read_fpga(unsigned char client_num, unsigned int offset, unsigned int* data);
212
213/*****************************************************************
214 maple_i2c_get_client
215
216 DESCRIPTION:
217 Gets an I2C client number from an address
218
219 PARAMETERS:
220 addr - The address of the client.
221 OUTPUT:
222 The client number for this client, or SLAVE_NUM_OF_SLAVES on failure.
223********************************************************************/
224enum client_num maple_i2c_get_client(unsigned int addr);
225
226#endif /* _MAPLE_I2C_DEVS_H_ */