1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS 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**************************************/
43 * Interface to power-throttle control, measurement, and debugging
50 #ifndef __CVMX_POWER_THROTTLE_H__
51 #define __CVMX_POWER_THROTTLE_H__
57 * a field of the POWTHROTTLE register
59 static struct cvmx_power_throttle_rfield_t {
60 char name[16]; /* the field's name */
61 int32_t pos; /* position of the field's LSb */
62 int32_t len; /* the field's length */
63 } cvmx_power_throttle_rfield[] = {
64 #define CVMX_PTH_INDEX_MAXPOW 0
66 #define CVMX_PTH_INDEX_POWER 1
68 #define CVMX_PTH_INDEX_THROTT 2
70 #define CVMX_PTH_INDEX_RESERVED 3
72 #define CVMX_PTH_INDEX_DISTAG 4
74 #define CVMX_PTH_INDEX_PERIOD 5
76 #define CVMX_PTH_INDEX_POWLIM 6
78 #define CVMX_PTH_INDEX_MAXTHR 7
80 #define CVMX_PTH_INDEX_MINTHR 8
82 #define CVMX_PTH_INDEX_MAX 9
85 #define CVMX_PTH_GET_MASK(len, pos) \
86 ((((uint64_t)1 << (len)) - 1) << (pos))
89 * Get the i'th field of power-throttle register r.
91 static inline uint64_t cvmx_power_throttle_get_field(int i, uint64_t r)
93 if (OCTEON_IS_MODEL(OCTEON_CN6XXX))
96 struct cvmx_power_throttle_rfield_t *p;
98 assert((i >= 0) && (i < CVMX_PTH_INDEX_MAX));
100 p = &cvmx_power_throttle_rfield[i];
101 m = CVMX_PTH_GET_MASK(p->len, p->pos);
103 return((r & m) >> p->pos);
109 * Set the i'th field of power-throttle register r to v.
111 static inline int cvmx_power_throttle_set_field(int i, uint64_t r, uint64_t v)
113 if (OCTEON_IS_MODEL(OCTEON_CN6XXX))
116 struct cvmx_power_throttle_rfield_t *p;
118 assert((i >= 0) && (i < CVMX_PTH_INDEX_MAX));
120 p = &cvmx_power_throttle_rfield[i];
121 m = CVMX_PTH_GET_MASK(p->len, p->pos);
123 return((~m & r) | ((v << p->pos) & m));
129 * API Function Prototypes
131 extern int cvmx_power_throttle_self(uint8_t percentage);
132 extern int cvmx_power_throttle(uint8_t percentage, uint64_t coremask);
137 #endif /* __CVMX_POWER_THROTTLE_H__ */