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 * @file
42 *
43 * Interface to power-throttle control, measurement, and debugging
44 * facilities.
45 *
46 * <hr>$Revision: 70030 $<hr>
47 *
48 */
49
50#ifndef __CVMX_POWER_THROTTLE_H__
51#define __CVMX_POWER_THROTTLE_H__
52#ifdef	__cplusplus
53extern "C" {
54#endif
55
56enum cvmx_power_throttle_field_index {
57    CVMX_PTH_INDEX_MAXPOW,
58    CVMX_PTH_INDEX_POWER,
59    CVMX_PTH_INDEX_THROTT,
60    CVMX_PTH_INDEX_RESERVED,
61    CVMX_PTH_INDEX_DISTAG,
62    CVMX_PTH_INDEX_PERIOD,
63    CVMX_PTH_INDEX_POWLIM,
64    CVMX_PTH_INDEX_MAXTHR,
65    CVMX_PTH_INDEX_MINTHR,
66    CVMX_PTH_INDEX_HRMPOWADJ,
67    CVMX_PTH_INDEX_OVRRD,
68    CVMX_PTH_INDEX_MAX
69};
70typedef enum cvmx_power_throttle_field_index cvmx_power_throttle_field_index_t;
71
72/**
73 * Throttle power to percentage% of configured maximum (MAXPOW).
74 *
75 * @param percentage	0 to 100
76 * @return 0 for success and -1 for error.
77 */
78extern int cvmx_power_throttle_self(uint8_t percentage);
79
80/**
81 * Throttle power to percentage% of configured maximum (MAXPOW)
82 * for the cores identified in coremask.
83 *
84 * @param percentage 	0 to 100
85 * @param coremask	bit mask where each bit identifies a core.
86 * @return 0 for success and -1 for error.
87 */
88extern int cvmx_power_throttle(uint8_t percentage, uint64_t coremask);
89
90/**
91 * The same functionality as cvmx_power_throttle() but it takes a
92 * bitmap-based coremask as a parameter.
93 */
94extern int cvmx_power_throttle_bmp(uint8_t percentage,
95    struct cvmx_coremask *pcm);
96
97/**
98 * Get the i'th field of the power throttle register
99 *
100 * @param r is the value of the power throttle register
101 * @param i is the index of the field
102 *
103 * @return (uint64_t)-1 on failure.
104 */
105extern uint64_t cvmx_power_throttle_get_field(uint64_t r,
106    cvmx_power_throttle_field_index_t i);
107
108/**
109 * Retrieve the content of the power throttle register of a core
110 *
111 * @param ppid is the core id
112 *
113 * @return (uint64_t)-1 on failure.
114 */
115extern uint64_t cvmx_power_throttle_get_register(int ppid);
116
117#ifdef	__cplusplus
118}
119#endif
120#endif /* __CVMX_POWER_THROTTLE_H__ */
121