source: rtems/bsps/powerpc/shared/cpuIdent.c @ b82a4b4

5
Last change on this file since b82a4b4 was 7dbc43d, checked in by Sebastian Huber <sebastian.huber@…>, on 03/13/18 at 05:18:38

bsps/powerpc: Move basic support to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 *  cpuIdent.c -- Cpu identification code
3 *
4 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
5 *
6 *  Added MPC8260 Andy Dachs <a.dachs@sstl.co.uk>
7 *  Surrey Satellite Technology Limited
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 *
13 */
14
15#include <libcpu/cpuIdent.h>
16#include <libcpu/spr.h>
17#include <rtems/bspIo.h>
18
19/*
20 * Generate inline code to read Processor Version Register
21 */
22SPR_RO(PPC_PVR)
23
24ppc_cpu_id_t       current_ppc_cpu      = PPC_UNKNOWN;
25ppc_cpu_revision_t current_ppc_revision = 0xff;
26ppc_feature_t      current_ppc_features;
27
28const char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu)
29{
30  switch (cpu) {
31    case PPC_405:               return "PPC405";
32        case PPC_405GP:         return "PPC405GP";
33        case PPC_405EX:         return "PPC405EX";
34    case PPC_440:               return "PPC440";
35    case PPC_601:               return "MPC601";
36    case PPC_5XX:               return "MPC5XX";
37    case PPC_603:               return "MPC603";
38    case PPC_603ev:             return "MPC603ev";
39    case PPC_604:               return "MPC604";
40    case PPC_750:               return "MPC750";
41    case PPC_750_IBM:           return "IBM PPC750";
42    case PPC_7400:              return "MPC7400";
43    case PPC_7455:              return "MPC7455";
44    case PPC_7457:              return "MPC7457";
45    case PPC_603le:             return "MPC603le";
46    case PPC_604e:              return "MPC604e";
47    case PPC_604r:              return "MPC604r";
48    case PPC_620:               return "MPC620";
49    case PPC_860:               return "MPC860";
50    case PPC_8260:              return "MPC8260";
51    case PPC_8245:              return "MPC8245";
52    case PPC_8540:              return "MPC8540";
53    case PPC_PSIM:              return "PSIM";
54    case PPC_e200z0:            return "e200z0";
55    case PPC_e200z1:            return "e200z1";
56    case PPC_e200z4:            return "e200z4";
57    case PPC_e200z6:            return "e200z6";
58    case PPC_e200z7:            return "e200z7";
59    case PPC_e500v2:            return "e500v2";
60    case PPC_e6500:             return "e6500";
61    default:
62      printk("Unknown CPU value of 0x%x. Please add it to "
63             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", cpu );
64  }
65  return "UNKNOWN";
66}
67
68ppc_cpu_id_t get_ppc_cpu_type(void)
69{
70  /*
71   * cpu types listed here have the lowermost nibble as a version identifier
72   * we will tweak them to the standard version
73   */
74  const uint32_t ppc_cpu_id_version_nibble[] = {
75    PPC_e200z0,
76    PPC_e200z1,
77    PPC_e200z4,
78    PPC_e200z6,
79    PPC_e200z7
80  };
81
82  unsigned int pvr;
83  int i;
84
85  if ( PPC_UNKNOWN != current_ppc_cpu )
86        return current_ppc_cpu;
87
88  pvr = (_read_PPC_PVR() >> 16);
89  /*
90   * apply tweaks to ignore version
91   */
92  for (i = 0;
93       i < (sizeof(ppc_cpu_id_version_nibble)
94            /sizeof(ppc_cpu_id_version_nibble[0]));
95       i++) {
96    if ((pvr & 0xfff0) == (ppc_cpu_id_version_nibble[i] & 0xfff0)) {
97      pvr = ppc_cpu_id_version_nibble[i];
98      break;
99    }
100  }
101
102  current_ppc_cpu = (ppc_cpu_id_t) pvr;
103
104  switch (pvr) {
105    case PPC_405:
106    case PPC_405GP:
107    case PPC_405EX:
108    case PPC_440:
109    case PPC_601:
110    case PPC_5XX:
111    case PPC_603:
112    case PPC_603ev:
113    case PPC_603le:
114    case PPC_604:
115    case PPC_604r:
116    case PPC_750:
117    case PPC_750_IBM:
118    case PPC_7400:
119    case PPC_7455:
120    case PPC_7457:
121    case PPC_604e:
122    case PPC_620:
123    case PPC_860:
124    case PPC_8260:
125    case PPC_8245:
126    case PPC_PSIM:
127    case PPC_8540:
128    case PPC_e200z0:
129    case PPC_e200z1:
130    case PPC_e200z4:
131    case PPC_e200z6:
132    case PPC_e200z7:
133    case PPC_e300c1:
134    case PPC_e300c2:
135    case PPC_e300c3:
136    case PPC_e500v2:
137    case PPC_e6500:
138      break;
139    default:
140      printk("Unknown PVR value of 0x%x. Please add it to "
141             "<libcpu/powerpc/shared/include/cpuIdent.c>\n", pvr );
142    return PPC_UNKNOWN;
143  }
144
145  /* determine features */
146
147  /* FIXME: This is incomplete; I couldn't go through all the
148   * manuals (yet).
149   */
150  switch ( current_ppc_cpu ) {
151    case PPC_7455:
152    case PPC_7457:
153                current_ppc_features.has_8_bats                 = 1;
154    case PPC_7400:
155        /* NOTE: PSIM PVR doesn't tell us anything (its
156     *       contents are not set based on what model
157       *       the user chooses but has to be programmed via
158         *       the device file with the special value 0xfffe
159         *       telling us that we have a 'psim cpu').
160         *
161         *       I'm not sure pagetables work if the user chooses
162         *       e.g., the 603 model...
163         */
164        case PPC_PSIM:
165                current_ppc_features.has_altivec                = 1;
166        case PPC_604:
167        case PPC_604e:
168        case PPC_604r:
169        case PPC_750:
170        case PPC_750_IBM:
171                current_ppc_features.has_hw_ptbl_lkup   = 1;
172        case PPC_8260:
173        case PPC_8245:
174        case PPC_601:
175        case PPC_603:
176        case PPC_603e:
177        case PPC_603ev:
178        case PPC_603le:
179                current_ppc_features.is_60x                             = 1;
180        default:
181        break;
182  }
183
184  switch ( current_ppc_cpu ) {
185    case PPC_e6500:
186      current_ppc_features.has_altivec = 1;
187      break;
188    default:
189      break;
190  }
191
192  switch ( current_ppc_cpu ) {
193        case PPC_405:
194        case PPC_405GP:
195        case PPC_405EX:
196                current_ppc_features.is_bookE                   = PPC_BOOKE_405;
197        break;
198    case PPC_440:
199      current_ppc_features.is_bookE          = PPC_BOOKE_STD;
200      break;
201        case PPC_8540:
202        case PPC_e200z0:
203        case PPC_e200z1:
204        case PPC_e200z4:
205        case PPC_e200z6:
206        case PPC_e200z7:
207        case PPC_e500v2:
208        case PPC_e6500:
209                current_ppc_features.is_bookE                   = PPC_BOOKE_E500;
210                break;
211        default:
212        break;
213  }
214
215  switch ( current_ppc_cpu ) {
216        case PPC_860:
217                current_ppc_features.has_16byte_clne    = 1;
218        default:
219        break;
220  }
221
222  switch ( current_ppc_cpu ) {
223    case PPC_603e:
224    case PPC_603ev:
225    case PPC_603le:
226    case PPC_e300c1:
227    case PPC_e300c2:
228    case PPC_e300c3:
229    case PPC_8240:
230                current_ppc_features.has_shadowed_gprs  = 1;
231        default:
232        break;
233  }
234
235  return current_ppc_cpu;
236}
237
238ppc_cpu_revision_t get_ppc_cpu_revision(void)
239{
240  ppc_cpu_revision_t rev = (ppc_cpu_revision_t) (_read_PPC_PVR() & 0xffff);
241  current_ppc_revision = rev;
242  return rev;
243}
Note: See TracBrowser for help on using the repository browser.