1// 2// Copyright 2010 Intel Corporation 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16#define RC_GLOBAL_CLOCK_MHZ 1600 17#define RPC_ROOT 0 18#define RC_NUM_VOLTAGE_DOMAINS 6 19#define RC_MIN_VOLTAGE_LEVEL 0 20#define RC_MAX_VOLTAGE_LEVEL 6 21#define RC_MAX_FREQUENCY_DIVIDER 16 // maximum divider value, so lowest F 22#define RC_MIN_FREQUENCY_DIVIDER 2 // minimum divider value, so highest F 23#define RC_NUM_FREQUENCY_DIVIDERS (RC_MAX_FREQUENCY_DIVIDER+1) 24#define RC_NUM_VOLTAGE_LEVELS 7 25#define RPC_PHYSICAL_ADDRESS 0xFB000000 26#ifndef COPPERRIDGE 27/* real latency is probably closer to 8 800 000 */ 28#define RC_WAIT_CYCLES 1000000 29#endif 30#define TILEDIVIDER 0x00000080 31#define RC_DEFAULT_VOLTAGE_LEVEL 4 32#define RC_DEFAULT_FREQUENCY_DIVIDER 3 // corresponds to tile clock of 1600/3 33 34 35typedef struct { 36float volt; 37int VID; 38int MHz_cap; 39} triple; 40 41int RCCE_set_frequency(int); 42static int RC_wait_voltage(RCCE_REQUEST *); 43static int RC_set_frequency_divider(int, int); 44long long RC_global_clock(void); 45unsigned int FID_word(int, int); 46unsigned int VID_word(int, int); 47 48#ifdef RC_POWER_MANAGEMENT 49#ifndef COPPERRIDGE 50 typedef struct { 51 volatile int queue[RC_NUM_VOLTAGE_DOMAINS]; 52 volatile long long start_time; 53 } RCCE_RPC_REGULATOR; 54#define REGULATOR_LENGTH (PAD32byte(sizeof(RCCE_RPC_REGULATOR))) 55 extern RCCE_RPC_REGULATOR *RCCE_RPC_regulator; 56 extern long long RC_time_at_birth; 57#endif 58 extern RCCE_COMM RCCE_V_COMM; 59 extern RCCE_COMM RCCE_F_COMM; 60 extern RCCE_COMM RCCE_P_COMM; 61 extern int RCCE_ue_F_masters[4]; 62 extern int RCCE_set_power_active; 63 extern int RC_current_voltage_level; 64 extern int RC_current_frequency_divider; 65 66 int RCCE_init_RPC(int *, int, int); 67#endif 68 69#ifdef _OPENMP 70 #pragma omp threadprivate (RCCE_ue_F_masters) 71 #pragma omp threadprivate (RCCE_V_COMM, RCCE_F_COMM, RCCE_P_COMM) 72 #pragma omp threadprivate (RCCE_set_power_active) 73 #pragma omp threadprivate (RC_current_voltage_level, RC_current_frequency_divider) 74#ifndef COPPERRIDGE 75 #pragma omp threadprivate (RC_time_at_birth) 76 #pragma omp threadprivate (RCCE_RPC_regulator) 77#endif 78#endif 79 80