]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/octeon-sdk/cvmx-thunder.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / octeon-sdk / cvmx-thunder.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Inc. (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 Inc. 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  * This Software, including technical data, may be subject to U.S. export  control
24  * laws, including the U.S. Export Administration Act and its  associated
25  * regulations, and may be subject to export or import  regulations in other
26  * countries.
27
28  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38  ***********************license end**************************************/
39
40
41
42
43
44
45
46 #ifndef __CVMX_THUNDER_H__
47 #define __CVMX_THUNDER_H__
48
49 /**
50  * @file
51  *
52  * Interface to the Thunder specific devices
53  *
54  * <hr>$Revision: 70030 $<hr>
55  *
56  */
57
58 #ifdef  __cplusplus
59 extern "C" {
60 #endif
61
62 #define CVMX_RTC_DS1374_ADDR   (0x68)
63
64 /*
65  * Read time-of-day counter.
66  * This function is called internally by cvmx-rtc functions.
67  */
68 uint32_t cvmx_rtc_ds1374_read(void);
69
70 /*
71  * Write time-of-day counter.
72  * This function is called internally by cvmx-rtc functions.
73  */
74 int      cvmx_rtc_ds1374_write(uint32_t time);
75
76
77 /**
78  * LAN bypass modes.
79  */
80 typedef enum {
81     CVMX_LAN_BYPASS_OFF = 0,   /**< LAN bypass is disabled, port 0 and port 1
82                                     are always connected to Octeon */
83     CVMX_LAN_BYPASS_GPIO,      /**< LAN bypass controlled by GPIO only */
84     CVMX_LAN_BYPASS_WATCHDOG,  /**< LAN bypass controlled by watchdog (and GPIO) */
85     CVMX_LAN_BYPASS_LAST       /* Keep as last entry */
86 } cvmx_lan_bypass_mode_t;
87
88
89 /**
90  * Set LAN bypass mode.
91  *
92  * Supported modes are:
93  * - CVMX_LAN_BYPASS_OFF
94  *     <br>LAN ports are connected ( port 0 <--> Octeon <--> port 1 )
95  *
96  * - CVMX_LAN_BYPASS_GPIO
97  *     <br>LAN bypass is controlled by software using cvmx_lan_bypass_force() function.
98  *     When transitioning to this mode, default is LAN bypass enabled
99  *     ( port 0 <--> port 1, disconnected from Octeon ).
100  *
101  * - CVMX_LAN_BYPASS_WATCHDOG
102  *     <br>LAN bypass is inactive as long as the watchdog is kept alive.
103  *     The default expiration time is 1 second and the function to
104  *     call periodically to prevent watchdog expiration is
105  *     cvmx_lan_bypass_keep_alive().
106  *
107  * @param mode           LAN bypass mode
108  *
109  * @return Error code, or 0 in case of success
110  */
111 int  cvmx_lan_bypass_mode_set(cvmx_lan_bypass_mode_t mode);
112
113 /**
114  * Return status of LAN bypass circuit.
115  *
116  * @return 1 if ports are in LAN bypass, or 0 if normally connected
117  */
118 int  cvmx_lan_bypass_is_active(void);
119
120 /**
121  * Refresh watchdog timer.
122  *
123  * Call periodically (less than 1 second) to prevent triggering LAN bypass.
124  * The alternative cvmx_lan_bypass_keep_alive_ms() is provided for cases
125  * where a variable interval is required.
126  */
127 void cvmx_lan_bypass_keep_alive(void);
128
129 /**
130  * Refresh watchdog timer, setting a specific expiration interval.
131  *
132  * @param interval_ms     Interval, in milliseconds, to next watchdog expiration.
133  */
134 void cvmx_lan_bypass_keep_alive_ms(uint32_t interval_ms);
135
136 /**
137  * Control LAN bypass via software.
138  *
139  * @param force_bypass   Force LAN bypass to active (1) or inactive (0)
140  *
141  * @return Error code, or 0 in case of success
142  */
143 int  cvmx_lan_bypass_force(int force_bypass);
144
145
146 #ifdef  __cplusplus
147 }
148 #endif
149
150 #endif  /* __CVMX_THUNDER_H__ */