*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
bzero((void *)&gPEClockFrequencyInfo, sizeof(clock_frequency_info_t));
// Start with default values.
- gPEClockFrequencyInfo.bus_clock_rate_hz = 100000000;
- gPEClockFrequencyInfo.cpu_clock_rate_hz = 300000000;
- gPEClockFrequencyInfo.dec_clock_rate_hz = 25000000;
- gPEClockFrequencyInfo.timebase_frequency_hz = 25000000;
+ gPEClockFrequencyInfo.timebase_frequency_hz = 25000000;
+ gPEClockFrequencyInfo.bus_clock_rate_hz = 100000000;
+ gPEClockFrequencyInfo.cpu_clock_rate_hz = 300000000;
// Try to get the values from the device tree.
if (DTFindEntry("device_type", "cpu", &cpu) == kSuccess) {
- if (DTGetProperty(cpu, "bus-frequency",
- (void **)&value, &size) == kSuccess)
- gPEClockFrequencyInfo.bus_clock_rate_hz = *value;
- else {
- if (DTLookupEntry(0, "/", &root) == kSuccess)
- if (DTGetProperty(root, "clock-frequency",
- (void **)&value, &size) == kSuccess)
- gPEClockFrequencyInfo.bus_clock_rate_hz = *value;
+ // Find the time base frequency first.
+ if (DTGetProperty(cpu, "timebase-frequency", (void **)&value, &size) == kSuccess) {
+ // timebase_frequency_hz is only 32 bits, and the device tree should never provide 64 bits
+ // so this if should never be taken.
+ if (size == 8) gPEClockFrequencyInfo.timebase_frequency_hz = *(unsigned long long *)value;
+ else gPEClockFrequencyInfo.timebase_frequency_hz = *value;
+ }
+ gPEClockFrequencyInfo.dec_clock_rate_hz = gPEClockFrequencyInfo.timebase_frequency_hz;
+
+ // Find the bus frequency next. Try the cpu node, then the root.
+ if (DTGetProperty(cpu, "bus-frequency", (void **)&value, &size) == kSuccess) {
+ if (size == 8) gPEClockFrequencyInfo.bus_frequency_hz = *(unsigned long long *)value;
+ else gPEClockFrequencyInfo.bus_frequency_hz = *value;
+ } else {
+ if (DTLookupEntry(0, "/", &root) == kSuccess) {
+ if (DTGetProperty(root, "clock-frequency", (void **)&value, &size) == kSuccess) {
+ if (size == 8) gPEClockFrequencyInfo.bus_frequency_hz = *(unsigned long long *)value;
+ else gPEClockFrequencyInfo.bus_frequency_hz = *value;
+ }
+ }
}
- if (DTGetProperty(cpu, "clock-frequency",
- (void **)&value, &size) == kSuccess)
- gPEClockFrequencyInfo.cpu_clock_rate_hz = *value;
+ gPEClockFrequencyInfo.bus_frequency_min_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+ gPEClockFrequencyInfo.bus_frequency_max_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+
+ if (gPEClockFrequencyInfo.bus_frequency_hz < 0x100000000ULL)
+ gPEClockFrequencyInfo.bus_clock_rate_hz = gPEClockFrequencyInfo.bus_frequency_hz;
+ else
+ gPEClockFrequencyInfo.bus_clock_rate_hz = 0xFFFFFFFF;
- if (DTGetProperty(cpu, "timebase-frequency",
- (void **)&value, &size) == kSuccess) {
- gPEClockFrequencyInfo.dec_clock_rate_hz = *value;
- gPEClockFrequencyInfo.timebase_frequency_hz= *value;
+ // Find the cpu frequency last.
+ if (DTGetProperty(cpu, "clock-frequency", (void **)&value, &size) == kSuccess) {
+ if (size == 8) gPEClockFrequencyInfo.cpu_frequency_hz = *(unsigned long long *)value;
+ else gPEClockFrequencyInfo.cpu_frequency_hz = *value;
}
+
+ gPEClockFrequencyInfo.cpu_frequency_min_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+ gPEClockFrequencyInfo.cpu_frequency_max_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+
+ if (gPEClockFrequencyInfo.cpu_frequency_hz < 0x100000000ULL)
+ gPEClockFrequencyInfo.cpu_clock_rate_hz = gPEClockFrequencyInfo.cpu_frequency_hz;
+ else
+ gPEClockFrequencyInfo.cpu_clock_rate_hz = 0xFFFFFFFF;
}
// Set the num / den pairs form the hz values.
gPEClockFrequencyInfo.timebase_frequency_num = gPEClockFrequencyInfo.timebase_frequency_hz;
gPEClockFrequencyInfo.timebase_frequency_den = 1;
-
+
gPEClockFrequencyInfo.bus_clock_rate_num = gPEClockFrequencyInfo.bus_clock_rate_hz;
gPEClockFrequencyInfo.bus_clock_rate_den = 1;