Changeset 965dc18 in mainline for kernel/arch/sparc64/src/cpu/cpu.c


Ignore:
Timestamp:
2008-12-05T19:59:03Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49093a4
Parents:
0258e67
Message:

Merge sparc branch to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/cpu/cpu.c

    r0258e67 r965dc18  
    3333 */
    3434
     35#include <arch/cpu_family.h>
    3536#include <cpu.h>
    3637#include <arch.h>
     
    3839#include <arch/drivers/tick.h>
    3940#include <print.h>
     41#include <arch/cpu_node.h>
     42
     43/**
     44 * Finds out the clock frequency of the current CPU.
     45 *
     46 * @param node  node representing the current CPU in the OFW tree
     47 * @return      clock frequency if "node" is the current CPU and no error
     48 *              occurs, -1 if "node" is not the current CPU or on error
     49 */
     50static int find_cpu_frequency(ofw_tree_node_t *node)
     51{
     52        ofw_tree_property_t *prop;
     53        uint32_t mid;
     54
     55        /* 'upa-portid' for US, 'portid' for US-III, 'cpuid' for US-IV */
     56        prop = ofw_tree_getprop(node, "upa-portid");
     57        if ((!prop) || (!prop->value))
     58                prop = ofw_tree_getprop(node, "portid");
     59        if ((!prop) || (!prop->value))
     60                prop = ofw_tree_getprop(node, "cpuid");
     61       
     62        if (prop && prop->value) {
     63                mid = *((uint32_t *) prop->value);
     64                if (mid == CPU->arch.mid) {
     65                        prop = ofw_tree_getprop(node, "clock-frequency");
     66                        if (prop && prop->value) {
     67                                return *((uint32_t *) prop->value);
     68                        }
     69                }
     70        }
     71       
     72        return -1;
     73}
    4074
    4175/** Perform sparc64 specific initialization of the processor structure for the
     
    4579{
    4680        ofw_tree_node_t *node;
    47         uint32_t mid;
    4881        uint32_t clock_frequency = 0;
    49         upa_config_t upa_config;
    5082       
    51         upa_config.value = upa_config_read();
    52         CPU->arch.mid = upa_config.mid;
     83        CPU->arch.mid = read_mid();
    5384       
    5485        /*
    5586         * Detect processor frequency.
    5687         */
    57         node = ofw_tree_find_child_by_device_type(ofw_tree_lookup("/"), "cpu");
    58         while (node) {
    59                 ofw_tree_property_t *prop;
     88        if (is_us() || is_us_iii()) {
     89                node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
     90                while (node) {
     91                        int f = find_cpu_frequency(node);
     92                        if (f != -1)
     93                                clock_frequency = (uint32_t) f;
     94                        node = ofw_tree_find_peer_by_device_type(node, "cpu");
     95                }
     96        } else if (is_us_iv()) {
     97                node = ofw_tree_find_child(cpus_parent(), "cmp");
     98                while (node) {
     99                        int f;
     100                        f = find_cpu_frequency(
     101                                ofw_tree_find_child(node, "cpu@0"));
     102                        if (f != -1)
     103                                clock_frequency = (uint32_t) f;
     104                        f = find_cpu_frequency(
     105                                ofw_tree_find_child(node, "cpu@1"));
     106                        if (f != -1)
     107                                clock_frequency = (uint32_t) f;
     108                        node = ofw_tree_find_peer_by_name(node, "cmp");
     109                }
     110        }
    60111               
    61                 prop = ofw_tree_getprop(node, "upa-portid");
    62                 if (prop && prop->value) {
    63                         mid = *((uint32_t *) prop->value);
    64                         if (mid == CPU->arch.mid) {
    65                                 prop = ofw_tree_getprop(node,
    66                                     "clock-frequency");
    67                                 if (prop && prop->value)
    68                                         clock_frequency = *((uint32_t *)
    69                                             prop->value);
    70                         }
    71                 }
    72                 node = ofw_tree_find_peer_by_device_type(node, "cpu");
    73         }
    74 
    75112        CPU->arch.clock_frequency = clock_frequency;
    76113        tick_init();
     
    125162                impl = "UltraSPARC III";
    126163                break;
     164        case IMPL_ULTRASPARCIII_PLUS:
     165                impl = "UltraSPARC III+";
     166                break;
     167        case IMPL_ULTRASPARCIII_I:
     168                impl = "UltraSPARC IIIi";
     169                break;
     170        case IMPL_ULTRASPARCIV:
     171                impl = "UltraSPARC IV";
     172                break;
    127173        case IMPL_ULTRASPARCIV_PLUS:
    128174                impl = "UltraSPARC IV+";
Note: See TracChangeset for help on using the changeset viewer.