2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #include <pexpert/protos.h>
23 #include <pexpert/pexpert.h>
24 #include <pexpert/ppc/powermac.h>
25 #include <pexpert/device_tree.h>
27 /* External declarations */
29 unsigned int LockTimeOut
= 12500000;
31 /* pe_identify_machine:
33 * Sets up platform parameters.
36 void pe_identify_machine(void)
42 // Clear the gPEClockFrequencyInfo struct
43 bzero((void *)&gPEClockFrequencyInfo
, sizeof(clock_frequency_info_t
));
45 // Start with default values.
46 gPEClockFrequencyInfo
.bus_clock_rate_hz
= 100000000;
47 gPEClockFrequencyInfo
.cpu_clock_rate_hz
= 300000000;
48 gPEClockFrequencyInfo
.dec_clock_rate_hz
= 25000000;
49 gPEClockFrequencyInfo
.timebase_frequency_hz
= 25000000;
51 // Try to get the values from the device tree.
52 if (DTFindEntry("device_type", "cpu", &cpu
) == kSuccess
) {
53 if (DTGetProperty(cpu
, "bus-frequency",
54 (void **)&value
, &size
) == kSuccess
)
55 gPEClockFrequencyInfo
.bus_clock_rate_hz
= *value
;
57 if (DTLookupEntry(0, "/", &root
) == kSuccess
)
58 if (DTGetProperty(root
, "clock-frequency",
59 (void **)&value
, &size
) == kSuccess
)
60 gPEClockFrequencyInfo
.bus_clock_rate_hz
= *value
;
63 if (DTGetProperty(cpu
, "clock-frequency",
64 (void **)&value
, &size
) == kSuccess
)
65 gPEClockFrequencyInfo
.cpu_clock_rate_hz
= *value
;
67 if (DTGetProperty(cpu
, "timebase-frequency",
68 (void **)&value
, &size
) == kSuccess
) {
69 gPEClockFrequencyInfo
.dec_clock_rate_hz
= *value
;
70 gPEClockFrequencyInfo
.timebase_frequency_hz
= *value
;
74 // Set the num / den pairs form the hz values.
75 gPEClockFrequencyInfo
.timebase_frequency_num
= gPEClockFrequencyInfo
.timebase_frequency_hz
;
76 gPEClockFrequencyInfo
.timebase_frequency_den
= 1;
78 gPEClockFrequencyInfo
.bus_clock_rate_num
= gPEClockFrequencyInfo
.bus_clock_rate_hz
;
79 gPEClockFrequencyInfo
.bus_clock_rate_den
= 1;
81 gPEClockFrequencyInfo
.bus_to_cpu_rate_num
=
82 (2 * gPEClockFrequencyInfo
.cpu_clock_rate_hz
) / gPEClockFrequencyInfo
.bus_clock_rate_hz
;
83 gPEClockFrequencyInfo
.bus_to_cpu_rate_den
= 2;
85 gPEClockFrequencyInfo
.bus_to_dec_rate_num
= 1;
86 gPEClockFrequencyInfo
.bus_to_dec_rate_den
=
87 gPEClockFrequencyInfo
.bus_clock_rate_hz
/ gPEClockFrequencyInfo
.dec_clock_rate_hz
;
90 /* get_io_base_addr():
92 * Get the base address of the io controller.
94 vm_offset_t
get_io_base_addr(void)
100 if ((DTFindEntry("device_type", "dbdma", &entryP
) == kSuccess
)
101 || (DTFindEntry("device_type", "mac-io", &entryP
) == kSuccess
))
103 if (DTGetProperty(entryP
, "AAPL,address", (void **)&address
, &size
) == kSuccess
)
106 if (DTGetProperty(entryP
, "assigned-addresses", (void **)&address
, &size
) == kSuccess
)
107 // address calculation not correct
111 panic("Can't find this machine's io base address\n");
115 boolean_t
PE_init_ethernet_debugger(void)
120 vm_offset_t
*address
;
121 unsigned char *netAddr
;
125 if ((io
= get_io_base_addr())
126 && (DTFindEntry("name", "mace", &entryP
) == kSuccess
)
127 && (DTGetProperty(entryP
, "local-mac-address", (void **)&netAddr
, &size
) == kSuccess
)
128 && (DTGetProperty(entryP
, "reg", (void **)&address
, &size
) == kSuccess
)
129 && (size
== (2 * 3 * sizeof(vm_offset_t
)) ))
131 extern boolean_t
kdp_mace_init(void *baseAddresses
[3],
132 unsigned char *netAddr
);
135 // address calculation not correct
136 maceAddrs
[0] = (void *) io_map(io
+ address
[0], address
[1]);
137 maceAddrs
[1] = (void *) io_map(io
+ address
[2], 0x1000);
138 maceAddrs
[2] = (void *) (((vm_offset_t
)maceAddrs
[1])
139 + address
[4] - address
[2]);
140 result
= kdp_mace_init( maceAddrs
, netAddr
);
149 vm_offset_t
PE_find_scc(void)
154 if ((io
= get_io_base_addr())
155 && (DTFindEntry("name", "escc", &entryP
) == kSuccess
))
156 io
+= 0x12000; /* Offset to legacy SCC Registers */