]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-twsi-raw.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmx-twsi-raw.h
1 /***********************license start***************
2  * Copyright (c) 2003-2007, Cavium Networks. All rights reserved.
3  *
4  * This software file (the "File") is owned and distributed by Cavium
5  * Networks ("Cavium") under the following dual licensing option: The dual
6  * licensing option gives you, the licensee, the choice between the following
7  * alternative licensing terms.  Once you have made an election to use the
8  * File under one of the following alternative licensing terms (license
9  * types) you are bound by the respective terms and you may distribute the
10  * file (or any derivative thereof), to the extent allowed by the respective
11  * licensing term, only if you (i) delete this introductory statement
12  * regarding the dual licensing option from the file you will distribute,
13  * (ii) delete the licensing term that you have elected NOT to use from the
14  * file you will distribute and (iii) follow the respective licensing term
15  * that you have elected to use with respect to the correct attribution or
16  * licensing term that you have to include with your distribution.
17  *
18  * ***
19  * OCTEON SDK License Type 2:
20  *
21  * IMPORTANT: Read this Agreement carefully before clicking on the "I accept"
22  * button to download the Software and/or before using the Software.  This
23  * License Agreement (the "Agreement") is a legal agreement between you,
24  * either an individual or a single legal entity ("You" or "you"), and Cavium
25  * Networks ("Cavium").  This Agreement governs your use of the Cavium
26  * software that can be downloaded after accepting this Agreement and/or that
27  * is accompanied by this Agreement (the "Software").  You must accept the
28  * terms of this Agreement before downloading and/or using the Software.  By
29  * clicking on the "I accept" button to download and/or by using the
30  * Software, you are indicating that you have read and understood, and assent
31  * to be bound by, the terms of this Agreement.  If you do not agree to the
32  * terms of the Agreement, you are not granted any rights whatsoever in the
33  * Software.  If you are not willing to be bound by these terms and
34  * conditions, you should not use or cease all use of the Software.  This
35  * Software is the property of Cavium Networks and constitutes the
36  * proprietary information of Cavium Networks.  You agree to take reasonable
37  * steps to prevent the disclosure, unauthorized use or unauthorized
38  * distribution of the Software to any third party.
39  *
40  * License Grant.  Subject to the terms and conditions of this Agreement,
41  * Cavium grants you a nonexclusive, non-transferable, worldwide, fully-paid
42  * and royalty-free license to
43  *
44  * (a) install, reproduce, and execute the executable version of the Software
45  * solely for your internal use and only (a) on hardware manufactured by
46  * Cavium, or (b) software of Cavium that simulates Cavium hardware;
47 *
48  * (b) create derivative works of any portions of the Software provided to
49  * you by Cavium in source code form, which portions enable features of the
50  * Cavium hardware products you or your licensees are entitled to use,
51  * provided that any such derivative works must be used only (a) on hardware
52  * manufactured by Cavium, or (b) software of Cavium that simulates Cavium
53  * hardware; and
54  *
55  * (c) distribute derivative works you created in accordance with clause (b)
56  * above, only in executable form and only if such distribution (i)
57  * reproduces the copyright notice that can be found at the very end of this
58  * Agreement and (ii) is pursuant to a binding license agreement that
59  * contains terms no less restrictive and no less protective of Cavium than
60  * this Agreement.  You will immediately notify Cavium if you become aware of
61  * any breach of any such license agreement.
62  *
63  * Restrictions.  The rights granted to you in this Agreement are subject to
64  * the following restrictions: Except as expressly set forth in this
65  * Agreement (a) you will not license, sell, rent, lease, transfer, assign,
66  * display, host, outsource, disclose or otherwise commercially exploit or
67  * make the Software, or any derivatives you create under this Agreement,
68  * available to any third party; (b) you will not modify or create derivative
69  * works of any part of the Software; (c) you will not access or use the
70  * Software in order to create similar or competitive products, components,
71  * or services; and (d), no part of the Software may be copied (except for
72  * the making of a single archival copy), reproduced, distributed,
73  * republished, downloaded, displayed, posted or transmitted in any form or
74  * by any means.
75  *
76  * Ownership.  You acknowledge and agree that, subject to the license grant
77  * contained in this Agreement and as between you and Cavium (a) Cavium owns
78  * all copies of and intellectual property rights to the Software, however
79  * made, and retains all rights in and to the Software, including all
80  * intellectual property rights therein, and (b) you own all the derivate
81  * works of the Software created by you under this Agreement, subject to
82  * Cavium's rights in the Software.  There are no implied licenses under this
83  * Agreement, and any rights not expressly granted to your hereunder are
84  * reserved by Cavium.  You will not, at any time, contest anywhere in the
85  * world Cavium's ownership of the intellectual property rights in and to the
86  * Software.
87  *
88  * Disclaimer of Warranties.  The Software is provided to you free of charge,
89  * and on an "As-Is" basis.  Cavium provides no technical support, warranties
90  * or remedies for the Software.  Cavium and its suppliers disclaim all
91 * express, implied or statutory warranties relating to the Software,
92  * including but not limited to, merchantability, fitness for a particular
93  * purpose, title, and non-infringement.  Cavium does not warrant that the
94  * Software and the use thereof will be error-free, that defects will be
95  * corrected, or that the Software is free of viruses or other harmful
96  * components.  If applicable law requires any warranties with respect to the
97  * Software, all such warranties are limited in duration to thirty (30) days
98  * from the date of download or first use, whichever comes first.
99  *
100  * Limitation of Liability.  Neither Cavium nor its suppliers shall be
101  * responsible or liable with respect to any subject matter of this Agreement
102  * or terms or conditions related thereto under any contract, negligence,
103  * strict liability or other theory (a) for loss or inaccuracy of data or
104  * cost of procurement of substitute goods, services or technology, or (b)
105  * for any indirect, incidental or consequential damages including, but not
106  * limited to loss of revenues and loss of profits.  Cavium's aggregate
107  * cumulative liability hereunder shall not exceed the greater of Fifty U.S.
108  * Dollars (U.S.$50.00) or the amount paid by you for the Software that
109  * caused the damage.  Certain states and/or jurisdictions do not allow the
110  * exclusion of implied warranties or limitation of liability for incidental
111  * or consequential damages, so the exclusions set forth above may not apply
112  * to you.
113  *
114  * Basis of Bargain.  The warranty disclaimer and limitation of liability set
115  * forth above are fundamental elements of the basis of the agreement between
116  * Cavium and you.  Cavium would not provide the Software without such
117  * limitations.  The warranty disclaimer and limitation of liability inure to
118  * the benefit of Cavium and Cavium's suppliers.
119  *
120  * Term and Termination.  This Agreement and the licenses granted hereunder
121  * are effective on the date you accept the terms of this Agreement, download
122  * the Software, or use the Software, whichever comes first, and shall
123  * continue unless this Agreement is terminated pursuant to this section.
124  * This Agreement immediately terminates in the event that you materially
125  * breach any of the terms hereof.  You may terminate this Agreement at any
126  * time, with or without cause, by destroying any copies of the Software in
127  * your possession.  Upon termination, the license granted hereunder shall
128  * terminate but the Sections titled "Restrictions", "Ownership", "Disclaimer
129  * of Warranties", "Limitation of Liability", "Basis of Bargain", "Term and
130  * Termination", "Export", and "Miscellaneous" will remain in effect.
131  *
132  * Export.  The Software and related technology are subject to U.S.  export
133  * control laws and may be subject to export or import regulations in other
134  * countries.  You agree to strictly comply with all such laws and
135  * regulations and acknowledges that you have the responsibility to obtain
136  * authorization to export, re-export, or import the Software and related
137  * technology, as may be required.  You will indemnify and hold Cavium
138  * harmless from any and all claims, losses, liabilities, damages, fines,
139  * penalties, costs and expenses (including attorney's fees) arising from or
140  * relating to any breach by you of your obligations under this section.
141  * Your obligations under this section shall survive the expiration or
142  * termination of this Agreement.
143  *
144  * Miscellaneous.  Neither the rights nor the obligations arising under this
145  * Agreement are assignable by you, and any such attempted assignment or
146  * transfer shall be void and without effect.  This Agreement shall be
147  * governed by and construed in accordance with the laws of the State of
148  * California without regard to any conflicts of laws provisions that would
149  * require application of the laws of another jurisdiction.  Any action under
150  * or relating to this Agreement shall be brought in the state and federal
151  * courts located in California, with venue in the courts located in Santa
152  * Clara County and each party hereby submits to the personal jurisdiction of
153  * such courts; provided, however, that nothing herein will operate to
154  * prohibit or restrict Cavium from filing for and obtaining injunctive
155  * relief from any court of competent jurisdiction.  The United Nations
156  * Convention on Contracts for the International Sale of Goods shall not
157  * apply to this Agreement.  In the event that any provision of this
158  * Agreement is found to be contrary to law, then such provision shall be
159  * construed as nearly as possible to reflect the intention of the parties,
160  * with the other provisions remaining in full force and effect.  Any notice
161  * to you may be provided by email.  This Agreement constitutes the entire
162  * agreement between the parties and supersedes all prior or contemporaneous,
163  * agreements, understandings and communications between the parties, whether
164  * written or oral, pertaining to the subject matter hereof.  Any
165  * modifications of this Agreement must be in writing and agreed to by both
166  * parties.
167  *
168  * Copyright (c) 2003-2007, Cavium Networks. All rights reserved.
169  *
170  * ***
171  *
172  * OCTEON SDK License Type 4:
173  *
174  * Author: Cavium Networks
175  *
176  * Contact: support@caviumnetworks.com
177  * This file is part of the OCTEON SDK
178  *
179  * Copyright (c) 2007 Cavium Networks
180  *
181  * This file is free software; you can redistribute it and/or modify
182  * it under the terms of the GNU General Public License, Version 2, as published by
183  * the Free Software Foundation.
184  *
185  * This file is distributed in the hope that it will be useful,
186  * but AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty of
187  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
188  * See the GNU General Public License for more details.
189  * it under the terms of the GNU General Public License, Version 2, as published by
190  * the Free Software Foundation.
191  *
192  * You should have received a copy of the GNU General Public License
193  * along with this file; if not, write to the Free Software
194  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
195  * or visit http://www.gnu.org/licenses/.
196  *
197  * This file may also be available under a different license from Cavium.
198  * Contact Cavium Networks for more information
199  ***********************license end**************************************/
200
201
202 #ifndef __CVMX_TWSI_RAW_H__
203 #define __CVMX_TWSI_RAW_H__
204
205 /* Addresses for twsi 8-bit registers. Gets written to EOP_IA field of MIO_TWS_SW_TWSI reg
206 *  when OP = 6 and SLONLY =0 */
207 #define TWSI_SLAVE_ADD_REG      0
208 #define TWSI_DATA_REG           1
209 #define TWSI_CTL_REG            2
210 #define TWSI_STAT_REG           3 /* read only */
211 #define TWSI_CLKCTL_REG         3 /* write only */
212 #define TWSI_SLAVE_EXTADD_REG   4       
213 #define TWSI_RST_REG            7
214
215 /* twsi core slave address reg */
216 typedef union{
217     uint8_t u8;
218     struct{
219         uint8_t slave_addr7     : 7;
220         uint8_t gce    : 1;
221
222     }s;
223 } octeon_twsi_slave_add_t;
224
225 /* twsi core 10-bit slave address reg */
226 typedef union{
227     uint8_t u8;
228     struct{
229         uint8_t slave_addr8     : 8;
230     }s;
231 } octeon_twsi_slave_extadd_t;
232
233 /* twsi core control register */
234 typedef union{
235     uint8_t u8;
236     struct{
237         uint8_t ce     : 1;  /* enable HLC*/
238         uint8_t enab   : 1;  /* bus enable */
239         uint8_t sta    : 1;  /* start request */
240         uint8_t stp    : 1;  /* stop request */
241         uint8_t iflg   : 1;  /* interrupt flag - request completed (1) start new (0) */
242         uint8_t aak    : 1;  /* assert ack (1) -neg ack at end of Rx sequence */ 
243         uint8_t rsv    : 2;  /* not used */
244     }s;
245 } octeon_twsi_ctl_t;
246
247 /* clock dividers register */
248 typedef union{
249     uint8_t u8;
250     struct{
251         uint8_t m_divider   : 4;
252         uint8_t n_divider   : 3;
253     }s;
254 } octeon_twsi_clkctl_t;
255
256 /* address of the remote slave + r/w bit */
257 typedef union{
258     uint8_t u8;
259     struct{
260         uint8_t slave_addr7     : 7; 
261         uint8_t r               : 1; /* read (1) write (0) bit */
262     }s;
263 } octeon_twsi_addr_t;
264
265 /* core state reg */
266 typedef union{
267     uint8_t u8;
268     struct{
269         uint8_t stat    : 8;
270     }s;
271 } octeon_twsi_stat_t;
272
273  /* data byte reg */
274 typedef union{
275     uint8_t u8;
276     struct{
277         uint8_t data    : 8;
278     }s;
279 } octeon_twsi_data_t;
280
281 /* twsi core states as reported in twsi core stat register */
282 #define TWSI_BUS_ERROR                  0x00
283 #define TWSI_START_TXED                 0x08
284 #define TWSI_ADDR_W_TX_ACK_RXED         0x18
285 #define TWSI_ADDR_W_TX_NACK_RXED        0x20
286
287 #define TWSI_DATA_TX_ACK_RXED           0x28
288 #define TWSI_DATA_TX_NACK_RXED  0x30
289 #define TWSI_ARB_LOST                   0x38
290 #define TWSI_ADDR_R_TX_ACK_RXED         0x40
291
292 #define TWSI_ADDR_R_TX_NACK_RXED        0x48
293 #define TWSI_DATA_RX_ACK_TXED           0x50
294 #define TWSI_DATA_RX_NACK_TXED          0x58
295 #define TWSI_SLAVE_ADDR_RX_ACK_TXED     0x60
296
297 #define TWSI_ARB_LOST_SLAVE_ADDR_RX     0x68
298 #define TWSI_GEN_ADDR_RXED_ACK_TXED     0x70
299 #define TWSI_ARB_LOST_GEN_ADDR_RXED     0x78
300 #define TWSI_SLAVE_DATA_RX_ACK_TXED     0x80
301
302 #define TWSI_SLAVE_DATA_RX_NACK_TXED    0x88
303 #define TWSI_GEN_DATA_RX_ACK_TXED       0x90
304 #define TWSI_GEN_DATA_RX_NACK_TXED      0x98
305 #define TWSI_SLAVE_STOP_OR_START_RXED   0xa0
306
307 #define TWSI_SLAVE_ADDR_R_RX_ACK_TXED   0xa8
308 #define TWSI_ARB_LOST_SLAVE_ADDR_R_RX_ACK_TXED 0xb0
309 #define TWSI_SLAVE_DATA_TX_ACK_RXED     0xb8
310 #define TWSI_SLAVE_DATA_TX_NACK_RXED    0xc0
311
312 #define TWSI_SLAVE_LAST_DATA_TX_ACK_RXED 0xc8
313 #define TWSI_SECOND_ADDR_W_TX_ACK_RXED  0xd0
314 #define TWSI_SECOND_ADDR_W_TX_NACK_RXED 0xd8
315 #define TWSI_IDLE                       0xf8
316
317 #ifndef LINUX
318 /* msg definition similar to Linux */
319 struct i2c_msg {
320         uint16_t addr;     /* slave address                        */
321         uint16_t flags;
322         uint16_t len;              /* msg length                           */
323         uint8_t *buf;              /* pointer to msg data                  */
324 };
325 #define I2C_M_TEN       0x10    /* we have a ten bit chip address       */
326 #define I2C_M_RD        0x01
327 #endif
328
329 int octeon_i2c_xfer_msg_raw(int twsi_id, struct i2c_msg *msg);
330
331 #endif