]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-thunder.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-thunder.h
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3  *  reserved.
4  *
5  *
6  *  Redistribution and use in source and binary forms, with or without
7  *  modification, are permitted provided that the following conditions are
8  *  met:
9  *
10  *      * Redistributions of source code must retain the above copyright
11  *        notice, this list of conditions and the following disclaimer.
12  *
13  *      * Redistributions in binary form must reproduce the above
14  *        copyright notice, this list of conditions and the following
15  *        disclaimer in the documentation and/or other materials provided
16  *        with the distribution.
17  *
18  *      * Neither the name of Cavium Networks nor the names of
19  *        its contributors may be used to endorse or promote products
20  *        derived from this software without specific prior written
21  *        permission.
22  *
23  *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24  *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25  *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26  *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27  *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28  *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29  *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30  *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31  *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32  *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43
44 #ifndef __CVMX_THUNDER_H__
45 #define __CVMX_THUNDER_H__
46
47 /**
48  * @file
49  *
50  * Interface to the Thunder specific devices
51  *
52  * <hr>$Revision: 41586 $<hr>
53  *
54  */
55
56 #ifdef  __cplusplus
57 extern "C" {
58 #endif
59
60 #define CVMX_RTC_DS1374_ADDR   (0x68)
61
62 /*
63  * Read time-of-day counter.
64  * This function is called internally by cvmx-rtc functions.
65  */
66 uint32_t cvmx_rtc_ds1374_read(void);
67
68 /*
69  * Write time-of-day counter.
70  * This function is called internally by cvmx-rtc functions.
71  */
72 int      cvmx_rtc_ds1374_write(uint32_t time);
73
74
75 /**
76  * LAN bypass modes.
77  */
78 typedef enum {
79     CVMX_LAN_BYPASS_OFF = 0,   /**< LAN bypass is disabled, port 0 and port 1
80                                     are always connected to Octeon */
81     CVMX_LAN_BYPASS_GPIO,      /**< LAN bypass controlled by GPIO only */
82     CVMX_LAN_BYPASS_WATCHDOG,  /**< LAN bypass controlled by watchdog (and GPIO) */
83     CVMX_LAN_BYPASS_LAST       /* Keep as last entry */
84 } cvmx_lan_bypass_mode_t;
85
86
87 /**
88  * Set LAN bypass mode.
89  *
90  * Supported modes are:
91  * - CVMX_LAN_BYPASS_OFF
92  *     <br>LAN ports are connected ( port 0 <--> Octeon <--> port 1 )
93  *
94  * - CVMX_LAN_BYPASS_GPIO
95  *     <br>LAN bypass is controlled by software using cvmx_lan_bypass_force() function.
96  *     When transitioning to this mode, default is LAN bypass enabled
97  *     ( port 0 <--> port 1, disconnected from Octeon ).
98  *
99  * - CVMX_LAN_BYPASS_WATCHDOG
100  *     <br>LAN bypass is inactive as long as the watchdog is kept alive.
101  *     The default expiration time is 1 second and the function to
102  *     call periodically to prevent watchdog expiration is
103  *     cvmx_lan_bypass_keep_alive().
104  *
105  * @param mode           LAN bypass mode
106  *
107  * @return Error code, or 0 in case of success
108  */
109 int  cvmx_lan_bypass_mode_set(cvmx_lan_bypass_mode_t mode);
110
111 /**
112  * Return status of LAN bypass circuit.
113  *
114  * @return 1 if ports are in LAN bypass, or 0 if normally connected
115  */
116 int  cvmx_lan_bypass_is_active(void);
117
118 /**
119  * Refresh watchdog timer.
120  *
121  * Call periodically (less than 1 second) to prevent triggering LAN bypass.
122  * The alternative cvmx_lan_bypass_keep_alive_ms() is provided for cases
123  * where a variable interval is required.
124  */
125 void cvmx_lan_bypass_keep_alive(void);
126
127 /**
128  * Refresh watchdog timer, setting a specific expiration interval.
129  *
130  * @param interval_ms     Interval, in milliseconds, to next watchdog expiration.
131  */
132 void cvmx_lan_bypass_keep_alive_ms(uint32_t interval_ms);
133
134 /**
135  * Control LAN bypass via software.
136  *
137  * @param force_bypass   Force LAN bypass to active (1) or inactive (0)
138  *
139  * @return Error code, or 0 in case of success
140  */
141 int  cvmx_lan_bypass_force(int force_bypass);
142
143
144 #ifdef  __cplusplus
145 }
146 #endif
147
148 #endif  /* __CVMX_THUNDER_H__ */