1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49#include "IxOsal.h"
50#include "IxVersionId.h"
51#include "IxFeatureCtrl.h"
52
53
54#define IX_FEATURE_CTRL_READ(result) \
55do { \
56ixFeatureCtrlExpMap(); \
57(result) = IX_OSAL_READ_LONG(ixFeatureCtrlRegister); \
58} while (0)
59
60
61#define IX_FEATURE_CTRL_WRITE(value) \
62do { \
63ixFeatureCtrlExpMap(); \
64IX_OSAL_WRITE_LONG(ixFeatureCtrlRegister, (value)); \
65} while (0)
66
67
68
69
70
71#define IX_FEATURE_CTRL_REG_OFFSET (0x00000028)
72
73
74
75PRIVATE BOOL ixFeatureCtrlExpCfgRegionMapped = FALSE;
76
77
78PRIVATE VUINT32 *ixFeatureCtrlRegister = NULL;
79
80
81PRIVATE BOOL swConfiguration[IX_FEATURECTRL_SWCONFIG_MAX];
82
83
84PRIVATE BOOL swConfigurationFlag = FALSE ;
85
86
87#ifdef __ixp42X
88UINT32 componentMask[IX_FEATURECTRL_MAX_COMPONENTS] = {
89 (0x1<<IX_FEATURECTRL_RCOMP),
90 (0x1<<IX_FEATURECTRL_USB),
91 (0x1<<IX_FEATURECTRL_HASH),
92 (0x1<<IX_FEATURECTRL_AES),
93 (0x1<<IX_FEATURECTRL_DES),
94 (0x1<<IX_FEATURECTRL_HDLC),
95 (0x1<<IX_FEATURECTRL_AAL),
96 (0x1<<IX_FEATURECTRL_HSS),
97 (0x1<<IX_FEATURECTRL_UTOPIA),
98 (0x1<<IX_FEATURECTRL_ETH0),
99 (0x1<<IX_FEATURECTRL_ETH1),
100 (0x1<<IX_FEATURECTRL_NPEA),
101 (0x1<<IX_FEATURECTRL_NPEB),
102 (0x1<<IX_FEATURECTRL_NPEC),
103 (0x1<<IX_FEATURECTRL_PCI),
104 IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE,
105 (0x3<<IX_FEATURECTRL_UTOPIA_PHY_LIMIT),
106 (0x1<<IX_FEATURECTRL_UTOPIA_PHY_LIMIT_BIT2),
107 IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE,
108 IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE,
109 IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE,
110 IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE,
111 IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE
112};
113#elif defined (__ixp46X)
114UINT32 componentMask[IX_FEATURECTRL_MAX_COMPONENTS] = {
115 (0x1<<IX_FEATURECTRL_RCOMP),
116 (0x1<<IX_FEATURECTRL_USB),
117 (0x1<<IX_FEATURECTRL_HASH),
118 (0x1<<IX_FEATURECTRL_AES),
119 (0x1<<IX_FEATURECTRL_DES),
120 (0x1<<IX_FEATURECTRL_HDLC),
121 IX_FEATURECTRL_COMPONENT_ALWAYS_AVAILABLE,
122 (0x1<<IX_FEATURECTRL_HSS),
123 (0x1<<IX_FEATURECTRL_UTOPIA),
124 (0x1<<IX_FEATURECTRL_ETH0),
125 (0x1<<IX_FEATURECTRL_ETH1),
126 (0x1<<IX_FEATURECTRL_NPEA),
127 (0x1<<IX_FEATURECTRL_NPEB),
128 (0x1<<IX_FEATURECTRL_NPEC),
129 (0x1<<IX_FEATURECTRL_PCI),
130 (0x1<<IX_FEATURECTRL_ECC_TIMESYNC),
131 (0x3<<IX_FEATURECTRL_UTOPIA_PHY_LIMIT),
132 (0x1<<IX_FEATURECTRL_UTOPIA_PHY_LIMIT_BIT2),
133 (0x1<<IX_FEATURECTRL_USB_HOST_CONTROLLER),
134 (0x1<<IX_FEATURECTRL_NPEA_ETH),
135 (0x1<<IX_FEATURECTRL_NPEB_ETH),
136 (0x1<<IX_FEATURECTRL_RSA),
137 (0x3<<IX_FEATURECTRL_XSCALE_MAX_FREQ),
138 (0x1<<IX_FEATURECTRL_XSCALE_MAX_FREQ_BIT2)
139};
140#endif
141
142
143
144
145PRIVATE
146void ixFeatureCtrlExpMap(void);
147
148PRIVATE
149void ixFeatureCtrlSwConfigurationInit(void);
150
151
152
153
154PRIVATE
155void ixFeatureCtrlExpMap(void)
156{
157 UINT32 expCfgBaseAddress = 0;
158
159
160
161 if (ixFeatureCtrlExpCfgRegionMapped == TRUE)
162 {
163 return;
164 }
165
166
167 expCfgBaseAddress = (UINT32)
168 (IX_OSAL_MEM_MAP(IX_OSAL_IXP400_EXP_BUS_REGS_PHYS_BASE,
169 IX_OSAL_IXP400_EXP_REG_MAP_SIZE));
170
171
172 IX_OSAL_ASSERT(expCfgBaseAddress);
173
174
175 ixFeatureCtrlRegister =
176 (VUINT32 *) (expCfgBaseAddress + IX_FEATURE_CTRL_REG_OFFSET);
177
178
179 ixFeatureCtrlExpCfgRegionMapped = TRUE;
180}
181
182
183
184
185
186PRIVATE void ixFeatureCtrlSwConfigurationInit(void)
187{
188 UINT32 i;
189 if (FALSE == swConfigurationFlag)
190 {
191 for (i=0; i<IX_FEATURECTRL_SWCONFIG_MAX ; i++)
192 {
193
194 swConfiguration[i]= TRUE ;
195 }
196
197 swConfigurationFlag = TRUE ;
198 }
199}
200
201
202
203
204IxFeatureCtrlReg
205ixFeatureCtrlRead (void)
206{
207 IxFeatureCtrlReg result;
208
209#if CPU!=SIMSPARCSOLARIS
210
211 IX_FEATURE_CTRL_READ(result);
212 return result;
213#else
214
215 result = 0xFFFFFFFF;
216 return result;
217#endif
218}
219
220
221
222
223void
224ixFeatureCtrlWrite (IxFeatureCtrlReg expUnitReg)
225{
226#if CPU!=SIMSPARCSOLARIS
227
228 IX_FEATURE_CTRL_WRITE(expUnitReg);
229#endif
230}
231
232
233
234
235
236IxFeatureCtrlReg
237ixFeatureCtrlHwCapabilityRead (void)
238{
239 IxFeatureCtrlReg currentReg, hwCapability;
240
241
242 currentReg = ixFeatureCtrlRead();
243
244
245
246 ixFeatureCtrlWrite(0);
247
248
249 hwCapability = ixFeatureCtrlRead();
250
251
252 ixFeatureCtrlWrite(currentReg);
253
254
255 return hwCapability;
256}
257
258
259
260
261
262IX_STATUS
263ixFeatureCtrlComponentCheck (IxFeatureCtrlComponentType componentType)
264{
265 IxFeatureCtrlReg expUnitReg;
266 UINT32 mask = 0;
267
268
269 mask=componentMask[componentType];
270
271
272 if(IX_FEATURECTRL_COMPONENT_NOT_AVAILABLE == mask)
273 {
274 return IX_FEATURE_CTRL_COMPONENT_DISABLED;
275 }
276
277 if(IX_FEATURECTRL_COMPONENT_ALWAYS_AVAILABLE == mask)
278 {
279 return IX_FEATURE_CTRL_COMPONENT_ENABLED;
280 }
281
282
283 expUnitReg = ixFeatureCtrlRead();
284
285
286
287
288
289
290
291
292
293
294
295 expUnitReg = ~expUnitReg ;
296
297 if (expUnitReg & mask)
298 {
299 return (IX_FEATURE_CTRL_COMPONENT_ENABLED);
300 }
301 else
302 {
303 return (IX_FEATURE_CTRL_COMPONENT_DISABLED);
304 }
305}
306
307
308
309
310
311IxFeatureCtrlProductId
312ixFeatureCtrlProductIdRead ()
313{
314#if CPU!=SIMSPARCSOLARIS
315 IxFeatureCtrlProductId pdId = 0 ;
316
317
318
319#ifndef __wince
320 __asm__("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(pdId) :);
321#else
322
323#ifndef IN_KERNEL
324 BOOL mode;
325#endif
326 extern IxFeatureCtrlProductId AsmixFeatureCtrlProductIdRead();
327
328#ifndef IN_KERNEL
329 mode = SetKMode(TRUE);
330#endif
331 pdId = AsmixFeatureCtrlProductIdRead();
332#ifndef IN_KERNEL
333 SetKMode(mode);
334#endif
335
336#endif
337 return (pdId);
338#else
339
340 return 0xffffffff;
341#endif
342}
343
344
345
346
347IxFeatureCtrlDeviceId
348ixFeatureCtrlDeviceRead ()
349{
350 return ((ixFeatureCtrlProductIdRead() >> IX_FEATURE_CTRL_DEVICE_TYPE_OFFSET)
351 & IX_FEATURE_CTRL_DEVICE_TYPE_MASK);
352}
353
354
355
356
357
358IX_STATUS
359ixFeatureCtrlSwConfigurationCheck (IxFeatureCtrlSwConfig swConfigType)
360{
361 if (swConfigType >= IX_FEATURECTRL_SWCONFIG_MAX)
362 {
363 ixOsalLog(IX_OSAL_LOG_LVL_WARNING,
364 IX_OSAL_LOG_DEV_STDOUT,
365 "FeatureCtrl: Invalid software configuraiton input.\n",
366 0, 0, 0, 0, 0, 0);
367
368 return IX_FEATURE_CTRL_SWCONFIG_DISABLED;
369 }
370
371
372 ixFeatureCtrlSwConfigurationInit();
373
374
375 return ((swConfiguration[(UINT32)swConfigType] == TRUE) ? IX_FEATURE_CTRL_SWCONFIG_ENABLED: IX_FEATURE_CTRL_SWCONFIG_DISABLED);
376}
377
378
379
380
381void
382ixFeatureCtrlSwConfigurationWrite (IxFeatureCtrlSwConfig swConfigType, BOOL enabled)
383{
384 if (swConfigType >= IX_FEATURECTRL_SWCONFIG_MAX)
385 {
386 ixOsalLog(IX_OSAL_LOG_LVL_WARNING,
387 IX_OSAL_LOG_DEV_STDOUT,
388 "FeatureCtrl: Invalid software configuraiton input.\n",
389 0, 0, 0, 0, 0, 0);
390
391 return;
392 }
393
394
395 ixFeatureCtrlSwConfigurationInit();
396
397
398 swConfiguration[(UINT32)swConfigType]=enabled ;
399}
400
401
402
403
404void
405ixFeatureCtrlIxp400SwVersionShow (void)
406{
407 printf ("\nIXP400 Software Release %s %s\n\n", IX_VERSION_ID, IX_VERSION_INTERNAL_ID);
408
409}
410
411
412
413
414IxFeatureCtrlBuildDevice
415ixFeatureCtrlSoftwareBuildGet (void)
416{
417 #ifdef __ixp42X
418 return IX_FEATURE_CTRL_SW_BUILD_IXP42X;
419 #else
420 return IX_FEATURE_CTRL_SW_BUILD_IXP46X;
421 #endif
422}
423