~ubuntu-branches/ubuntu/karmic/linux-mvl-dove/karmic-proposed

« back to all changes in this revision

Viewing changes to arch/arm/mach-dove/mv_hal_support/mvKW_HAL_glue.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader
  • Date: 2010-03-10 22:24:12 UTC
  • mto: (15.1.2 karmic-security)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100310222412-k86m3r53jw0je7x1
Tags: upstream-2.6.31
ImportĀ upstreamĀ versionĀ 2.6.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
Copyright (C) Marvell International Ltd. and its affiliates
3
 
 
4
 
This software file (the "File") is owned and distributed by Marvell 
5
 
International Ltd. and/or its affiliates ("Marvell") under the following
6
 
alternative licensing terms.  Once you have made an election to distribute the
7
 
File under one of the following license alternatives, please (i) delete this
8
 
introductory statement regarding license alternatives, (ii) delete the two
9
 
license alternatives that you have not elected to use and (iii) preserve the
10
 
Marvell copyright notice above.
11
 
 
12
 
 
13
 
********************************************************************************
14
 
Marvell GPL License Option
15
 
 
16
 
If you received this File from Marvell, you may opt to use, redistribute and/or 
17
 
modify this File in accordance with the terms and conditions of the General 
18
 
Public License Version 2, June 1991 (the "GPL License"), a copy of which is 
19
 
available along with the File in the license.txt file or by writing to the Free 
20
 
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or 
21
 
on the worldwide web at http://www.gnu.org/licenses/gpl.txt. 
22
 
 
23
 
THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED 
24
 
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY 
25
 
DISCLAIMED.  The GPL License provides additional details about this warranty 
26
 
disclaimer.
27
 
*******************************************************************************/
28
 
/*******************************************************************************
29
 
* mvKW_HAL_glue - 
30
 
*
31
 
* DESCRIPTION:
32
 
*
33
 
* DEPENDENCIES:
34
 
*       None.
35
 
*
36
 
*******************************************************************************/
37
 
 
38
 
#include "mvOs.h"
39
 
#include "mvCommon.h"
40
 
#include "ctrlEnv/mvCtrlEnvRegs.h"
41
 
#include "mvSysHwConfig.h"
42
 
#ifdef CONFIG_MV_INCLUDE_GIG_ETH
43
 
#include "eth/mvEth.h"
44
 
#endif
45
 
 
46
 
/*******************************************************************************
47
 
* mvCtrlEthMaxPortGet - Get Marvell controller number of etherent ports.
48
 
*
49
 
* DESCRIPTION:
50
 
*       This function returns Marvell controller number of etherent port.
51
 
*
52
 
* INPUT:
53
 
*       None.
54
 
*
55
 
* OUTPUT:
56
 
*       None.
57
 
*
58
 
* RETURN:
59
 
*       Marvell controller number of etherent port.
60
 
*
61
 
*******************************************************************************/
62
 
#if 1
63
 
MV_U32 mvCtrlEthMaxPortGet(MV_VOID)
64
 
{
65
 
     return 1;
66
 
}
67
 
 
68
 
/*******************************************************************************
69
 
* mvCtrlModelGet - Get Marvell controller device model (Id)
70
 
*
71
 
* DESCRIPTION:
72
 
*       This function returns 16bit describing the device model (ID) as defined
73
 
*       in PCI Device and Vendor ID configuration register offset 0x0.
74
 
*
75
 
* INPUT:
76
 
*       None.
77
 
*
78
 
* OUTPUT:
79
 
*       None.
80
 
*
81
 
* RETURN:
82
 
*       16bit desscribing Marvell controller ID 
83
 
*
84
 
*******************************************************************************/
85
 
MV_U16 mvCtrlModelGet(MV_VOID)
86
 
{
87
 
     return     MV_6781_DEV_ID;
88
 
}
89
 
MV_U8 mvCtrlRevGet(MV_VOID)
90
 
{
91
 
#ifdef CONFIG_DOVE_REV_Z0
92
 
        return 0;
93
 
#endif
94
 
#ifdef CONFIG_DOVE_REV_Y0
95
 
        return 2;
96
 
#endif
97
 
}
98
 
//EXPORT_SYMBOL(mvCtrlEthMaxPortGet);
99
 
#endif
100
 
 
101
 
 
102
 
/*******************************************************************************
103
 
* mvBoardTclkGet - Get the board Tclk (Controller clock)
104
 
*
105
 
* DESCRIPTION:
106
 
*       This routine extract the controller core clock.
107
 
*       This function uses the controller counters to make identification.
108
 
*               Note: In order to avoid interference, make sure task context switch
109
 
*               and interrupts will not occure during this function operation
110
 
*
111
 
* INPUT:
112
 
*       countNum - Counter number.
113
 
*
114
 
* OUTPUT:
115
 
*       None.
116
 
*
117
 
* RETURN:
118
 
*       32bit clock cycles in Hertz.
119
 
*
120
 
*******************************************************************************/
121
 
MV_U32 mvBoardTclkGet(MV_VOID)
122
 
{
123
 
#if defined(TCLK_AUTO_DETECT)
124
 
        MV_U32 tmpTClkRate = 166666667;
125
 
 
126
 
        tmpTClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET_REG0);
127
 
        tmpTClkRate &= MSAR_TCLCK_MASK;
128
 
 
129
 
        switch (tmpTClkRate)
130
 
        {
131
 
        case MSAR_TCLCK_166:
132
 
                tmpTClkRate = MV_BOARD_TCLK_166MHZ;
133
 
                break;
134
 
        }
135
 
        return tmpTClkRate;
136
 
#else
137
 
        return MV_BOARD_DEFAULT_TCLK;
138
 
#endif
139
 
 
140
 
}
141
 
#include <asm/mach-types.h>
142
 
#ifdef CONFIG_MV_INCLUDE_GIG_ETH
143
 
/*******************************************************************************
144
 
* mvBoardPhyAddrGet - Get the phy address
145
 
*
146
 
* DESCRIPTION:
147
 
*       This routine returns the Phy address of a given ethernet port.
148
 
*
149
 
* INPUT:
150
 
*       ethPortNum - Ethernet port number.
151
 
*
152
 
* OUTPUT:
153
 
*       None.
154
 
*
155
 
* RETURN:
156
 
*       32bit describing Phy address, -1 if the port number is wrong.
157
 
*
158
 
*******************************************************************************/
159
 
MV_32 mvBoardPhyAddrGet(MV_U32 ethPortNum)
160
 
{
161
 
#if 0
162
 
        MV_U32 boardId= mvBoardIdGet();
163
 
 
164
 
        if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID)))
165
 
        {
166
 
                mvOsPrintf("mvBoardPhyAddrGet: Board unknown.\n");
167
 
                return MV_ERROR;
168
 
        }
169
 
 
170
 
        return BOARD_INFO(boardId)->pBoardMacInfo[ethPortNum].boardEthSmiAddr;
171
 
#else
172
 
#if 0
173
 
        MV_U32 ret = 0;
174
 
        if(machine_is_rd88f6281())
175
 
             ret = 0;
176
 
        else if (machine_is_db88f6281_bp())
177
 
             ret = 8;
178
 
        else if (machine_is_rd88f6192_nas())
179
 
             ret = 8;
180
 
        else
181
 
             printk("error in %s: unknown board\n", __func__);
182
 
#endif
183
 
        MV_U32 ret = 8;
184
 
//      printk("%s: PhyAddr: %x\n", __func__, ret);
185
 
        return ret;
186
 
#endif
187
 
}
188
 
 
189
 
/*******************************************************************************
190
 
* mvBoardMacSpeedGet - Get the Mac speed
191
 
*
192
 
* DESCRIPTION:
193
 
*       This routine returns the Mac speed if pre define of a given ethernet port.
194
 
*
195
 
* INPUT:
196
 
*       ethPortNum - Ethernet port number.
197
 
*
198
 
* OUTPUT:
199
 
*       None.
200
 
*
201
 
* RETURN:
202
 
*       MV_BOARD_MAC_SPEED, -1 if the port number is wrong.
203
 
*
204
 
*******************************************************************************/
205
 
MV_ETH_MAC_SPEED      mvBoardMacSpeedGet(MV_U32 ethPortNum)
206
 
{
207
 
#if 0
208
 
        MV_U32 boardId= mvBoardIdGet();
209
 
 
210
 
        if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID)))
211
 
        {
212
 
                mvOsPrintf("mvBoardMacSpeedGet: Board unknown.\n");
213
 
                return MV_ERROR;
214
 
        }
215
 
 
216
 
        return BOARD_INFO(boardId)->pBoardMacInfo[ethPortNum].boardMacSpeed;
217
 
#else
218
 
#if 0
219
 
        if(machine_is_rd88f6281())
220
 
             return BOARD_MAC_SPEED_1000M;
221
 
        else if (machine_is_db88f6281_bp())
222
 
             return BOARD_MAC_SPEED_AUTO;
223
 
        else if (machine_is_rd88f6192_nas())
224
 
             return BOARD_MAC_SPEED_AUTO;
225
 
        else
226
 
             printk("error in %s: unknown board", __func__);
227
 
#endif
228
 
        return ETH_MAC_SPEED_AUTO;
229
 
#endif
230
 
}
231
 
 
232
 
MV_BOOL mvBoardIsPortInSgmii(MV_U32 ethPortNum)
233
 
{
234
 
     return MV_TRUE;
235
 
}
236
 
 
237
 
u32 overEthAddr = 0;
238
 
//u8     mvMacAddr[6] = {0, };
239
 
u8 mvMacAddr[CONFIG_MV_ETH_PORTS_NUM][6];
240
 
u16 mvMtu[CONFIG_MV_ETH_PORTS_NUM] = {0};
241
 
 
242
 
#endif
243
 
/*******************************************************************************
244
 
* mvBoardSpecInitGet -
245
 
*
246
 
* DESCRIPTION:
247
 
*
248
 
* INPUT:
249
 
*
250
 
* OUTPUT:
251
 
*       None.
252
 
*
253
 
* RETURN: Return MV_TRUE and parameters in case board need spesific phy init, 
254
 
*         otherwise return MV_FALSE. 
255
 
*
256
 
*
257
 
*******************************************************************************/
258
 
 
259
 
MV_BOOL mvBoardSpecInitGet(MV_U32* regOff, MV_U32* data)
260
 
{
261
 
        return MV_FALSE;
262
 
}
263
 
 
264
 
MV_U32 mvCpuPclkGet(MV_VOID)
265
 
{
266
 
#if defined(PCLCK_AUTO_DETECT)
267
 
     MV_U32  tmpPClkRate=0;
268
 
     MV_U32 cpuCLK[] = MV_CPU_CLCK_TBL;
269
 
     
270
 
     tmpPClkRate = MV_REG_READ(MPP_SAMPLE_AT_RESET_REG0);
271
 
     tmpPClkRate = tmpPClkRate & MSAR_CPUCLCK_MASK;
272
 
     tmpPClkRate = tmpPClkRate >> MSAR_CPUCLCK_OFFS;
273
 
     
274
 
     tmpPClkRate = cpuCLK[tmpPClkRate];
275
 
          
276
 
     return tmpPClkRate;
277
 
#else
278
 
     return MV_DEFAULT_PCLK
279
 
#endif
280
 
}
281
 
/*******************************************************************************
282
 
 * mvCpuL2ClkGet - Get the CPU L2 (CPU bus clock)
283
 
 *
284
 
 * DESCRIPTION:
285
 
 *       This routine extract the CPU L2 clock.
286
 
 *
287
 
 * RETURN:
288
 
 *       32bit clock cycles in Hertz.
289
 
 *
290
 
 *******************************************************************************/
291
 
MV_U32  mvCpuL2ClkGet(MV_VOID)
292
 
{
293
 
#ifdef L2CLK_AUTO_DETECT
294
 
     MV_U32 L2ClkRate, tmp, pClkRate, indexL2Rtio;
295
 
     MV_U32 cpuCLK[] = MV_CPU_CLCK_TBL;
296
 
     MV_U32 L2Rtio[][2] = MV_L2_CLCK_RTIO_TBL;
297
 
 
298
 
     pClkRate = mvCpuPclkGet();
299
 
 
300
 
     tmp = MV_REG_READ(MPP_SAMPLE_AT_RESET_REG0);
301
 
     indexL2Rtio = tmp & MSAR_L2CLCK_RTIO_MASK;
302
 
     indexL2Rtio = indexL2Rtio >> MSAR_L2CLCK_RTIO_OFFS;
303
 
 
304
 
     L2ClkRate = ((pClkRate * L2Rtio[indexL2Rtio][1]) / L2Rtio[indexL2Rtio][0]);
305
 
 
306
 
     return L2ClkRate;
307
 
#else
308
 
     return MV_BOARD_DEFAULT_L2CLK;
309
 
#endif
310
 
}
311
 
/*******************************************************************************
312
 
* mvCtrlPwrClckGet - Get Power State of specific Unit
313
 
*
314
 
* DESCRIPTION:          
315
 
*
316
 
* INPUT:
317
 
*
318
 
* OUTPUT:
319
 
*
320
 
* RETURN:
321
 
******************************************************************************/
322
 
MV_BOOL mvCtrlPwrClckGet(MV_UNIT_ID unitId, MV_U32 index)
323
 
{
324
 
        MV_U32 reg = MV_REG_READ(CLOCK_GATING_CTRL_REG);
325
 
        MV_BOOL state = MV_TRUE;
326
 
 
327
 
        switch (unitId)
328
 
        {
329
 
#if defined(MV_INCLUDE_USB)
330
 
        case USB_UNIT_ID:
331
 
                if ((reg & CGC_USBENCLOCK_MASK(index)) == CGC_USBENCLOCK_DIS(index))
332
 
                        state = MV_FALSE;
333
 
                else 
334
 
                        state = MV_TRUE;
335
 
                break;
336
 
#endif
337
 
#if defined(MV_INCLUDE_GIG_ETH)
338
 
        case ETH_GIG_UNIT_ID:
339
 
                if ((reg & CGC_GEENCLOCK_MASK) == CGC_GEENCLOCK_DIS)
340
 
                        state = MV_FALSE;
341
 
                else 
342
 
                        state = MV_TRUE;
343
 
                break;
344
 
#endif
345
 
#if defined(MV_INCLUDE_SATA)
346
 
        case SATA_UNIT_ID:
347
 
                if ((reg & CGC_SATAENCLOCK_MASK) == CGC_SATAENCLOCK_DIS)
348
 
                        state = MV_FALSE;
349
 
                else 
350
 
                        state = MV_TRUE;
351
 
                break;
352
 
#endif
353
 
#if defined(MV_INCLUDE_PEX)
354
 
        case PEX_UNIT_ID:
355
 
                if ((reg & CGC_PEXENCLOCK_MASK(index)) == CGC_PEXENCLOCK_DIS(index))
356
 
                        state = MV_FALSE;
357
 
                else 
358
 
                        state = MV_TRUE;
359
 
                break;
360
 
#endif
361
 
#if defined(MV_INCLUDE_SDIO)
362
 
        case SDIO_UNIT_ID:
363
 
                if ((reg & CGC_SDIOENCLOCK_MASK(index))== CGC_SDIOENCLOCK_DIS(index))
364
 
                        state = MV_FALSE;
365
 
                else 
366
 
                        state = MV_TRUE;
367
 
                break;
368
 
#endif
369
 
#if defined(MV_INCLUDE_NAND)
370
 
        case NAND_UNIT_ID:
371
 
                if ((reg & CGC_NANDENCLOCK_MASK) == CGC_NANDENCLOCK_DIS)
372
 
                        state = MV_FALSE;
373
 
                else 
374
 
                        state = MV_TRUE;
375
 
                break;
376
 
#endif
377
 
#if defined(MV_INCLUDE_CAMERA)
378
 
        case CAMERA_UNIT_ID:
379
 
                if ((reg & CGC_CAMENCLOCK_MASK) == CGC_CAMENCLOCK_DIS)
380
 
                        state = MV_FALSE;
381
 
                else 
382
 
                        state = MV_TRUE;
383
 
                break;
384
 
#endif
385
 
#if defined(MV_INCLUDE_AUDIO)
386
 
        case AUDIO_UNIT_ID:
387
 
                if ((reg & CGC_ADENCLOCK_MASK(index)) == CGC_ADENCLOCK_DIS(index))
388
 
                        state = MV_FALSE;
389
 
                else 
390
 
                        state = MV_TRUE;
391
 
                break;
392
 
#endif
393
 
#if defined(MV_INCLUDE_GPU)
394
 
        case GPU_UNIT_ID:
395
 
                if ((reg & CGC_GPUENCLOCK_MASK) == CGC_GPUENCLOCK_DIS)
396
 
                        state = MV_FALSE;
397
 
                else 
398
 
                        state = MV_TRUE;
399
 
                break;
400
 
#endif
401
 
#if defined(MV_INCLUDE_AC97)
402
 
        case AC97_UNIT_ID:
403
 
                if ((reg & CGC_AC97ENCLOCK_MASK) == CGC_AC97ENCLOCK_DIS)
404
 
                        state = MV_FALSE;
405
 
                else 
406
 
                        state = MV_TRUE;
407
 
                break;
408
 
#endif
409
 
#if defined(MV_INCLUDE_PDAM)
410
 
        case PDMA_UNIT_ID:
411
 
                if ((reg & CGC_PDMAENCLOCK_MASK) == CGC_PDMAENCLOCK_DIS)
412
 
                        state = MV_FALSE;
413
 
                else 
414
 
                        state = MV_TRUE;
415
 
                break;
416
 
#endif
417
 
#if defined(MV_INCLUDE_XOR)
418
 
        case XOR_UNIT_ID:
419
 
                if ((reg & CGC_XORENCLOCK_MASK(index))== CGC_XORENCLOCK_DIS(index))
420
 
                        state = MV_FALSE;
421
 
                else 
422
 
                        state = MV_TRUE;
423
 
                break;
424
 
#endif
425
 
        default:
426
 
                state = MV_TRUE;
427
 
                break;
428
 
        }
429
 
 
430
 
        return state;   
431
 
}
432
 
#ifdef CONFIG_MV_INCLUDE_AUDIO
433
 
MV_VOID mvAudioHalInit(MV_U8 unit);
434
 
MV_STATUS mvAudioInit(MV_U8 unit)
435
 
{
436
 
    mvAudioHalInit(unit);
437
 
    
438
 
    return MV_OK;
439
 
}
440
 
#endif
441
 
#ifdef CONFIG_MV_INCLUDE_XOR
442
 
MV_VOID mvXorHalInit (MV_U32 xorChanNum);
443
 
 
444
 
MV_STATUS mvXorInit (MV_VOID)
445
 
{
446
 
     MV_U32         i;
447
 
#if 0
448
 
     /* Initiate XOR address decode */
449
 
     for(i = 0; i < MV_XOR_MAX_UNIT; i++)
450
 
          mvXorInitWinsUnit(i);
451
 
#endif
452
 
     mvXorHalInit(MV_XOR_MAX_CHAN);
453
 
 
454
 
     return MV_OK;
455
 
}
456
 
#endif
457
 
#if 0
458
 
#include "twsi/mvTwsi.h"
459
 
MV_U8 mvBoardA2DTwsiChanNumGet(MV_U8 unit)
460
 
{
461
 
     return 0;
462
 
}
463
 
 
464
 
MV_U8 mvBoardA2DTwsiAddrTypeGet(MV_U8 unit)
465
 
{
466
 
        return ADDR7_BIT;
467
 
}
468
 
 
469
 
 
470
 
MV_U8 mvBoardA2DTwsiAddrGet(MV_U8 port)
471
 
{
472
 
     return 0x4A;
473
 
}
474
 
#endif
475
 
MV_U32 mvCtrlUsbMaxGet(void)
476
 
{
477
 
        return 2;
478
 
}
479
 
 
480
 
MV_U32 mv_crypto_base_get(void)
481
 
{
482
 
        return (DOVE_CESA_VIRT_BASE + 0x10000); 
483
 
}
484
 
 
485
 
MV_U32 mv_crypto_phys_base_get(void)
486
 
{
487
 
        return (DOVE_CESA_PHYS_BASE + 0x10000); 
488
 
}
489
 
 
490
 
MV_U32 mv_crypto_irq_get(void)
491
 
{
492
 
        return IRQ_DOVE_CRYPTO; 
493
 
}