1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
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.
13 ********************************************************************************
14 Marvell GPL License Option
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.
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
27 *******************************************************************************/
28 /*******************************************************************************
29 * mvOsCpuArchLib.c - Marvell CPU architecture library
32 * This library introduce Marvell API for OS dependent CPU architecture
33 * APIs. This library introduce single CPU architecture services APKI
39 *******************************************************************************/
42 #include <asm/processor.h>
45 static MV_U32
read_p15_c0 (void);
48 #define ARM_ID_REVISION_OFFS 0
49 #define ARM_ID_REVISION_MASK (0xf << ARM_ID_REVISION_OFFS)
51 #define ARM_ID_PART_NUM_OFFS 4
52 #define ARM_ID_PART_NUM_MASK (0xfff << ARM_ID_PART_NUM_OFFS)
54 #define ARM_ID_ARCH_OFFS 16
55 #define ARM_ID_ARCH_MASK (0xf << ARM_ID_ARCH_OFFS)
57 #define ARM_ID_VAR_OFFS 20
58 #define ARM_ID_VAR_MASK (0xf << ARM_ID_VAR_OFFS)
60 #define ARM_ID_ASCII_OFFS 24
61 #define ARM_ID_ASCII_MASK (0xff << ARM_ID_ASCII_OFFS)
65 void* mvOsIoCachedMalloc( void* osHandle
, MV_U32 size
, MV_ULONG
* pPhyAddr
,
68 void *p
= kmalloc( size
, GFP_KERNEL
);
69 *pPhyAddr
= pci_map_single( osHandle
, p
, 0, PCI_DMA_BIDIRECTIONAL
);
72 void* mvOsIoUncachedMalloc( void* osHandle
, MV_U32 size
, MV_ULONG
* pPhyAddr
,
75 return pci_alloc_consistent( osHandle
, size
, (dma_addr_t
*)pPhyAddr
);
78 void mvOsIoUncachedFree( void* osHandle
, MV_U32 size
, MV_ULONG phyAddr
, void* pVirtAddr
,
81 return pci_free_consistent( osHandle
, size
, pVirtAddr
, (dma_addr_t
)phyAddr
);
84 void mvOsIoCachedFree( void* osHandle
, MV_U32 size
, MV_ULONG phyAddr
, void* pVirtAddr
,
87 return kfree( pVirtAddr
);
93 get_random_bytes(&rand
, sizeof(rand
) );
97 /*******************************************************************************
111 *******************************************************************************/
112 MV_U32
mvOsCpuRevGet( MV_VOID
)
114 return ((read_p15_c0() & ARM_ID_REVISION_MASK
) >> ARM_ID_REVISION_OFFS
);
116 /*******************************************************************************
128 * 32bit CPU Part number
130 *******************************************************************************/
131 MV_U32
mvOsCpuPartGet( MV_VOID
)
133 return ((read_p15_c0() & ARM_ID_PART_NUM_MASK
) >> ARM_ID_PART_NUM_OFFS
);
135 /*******************************************************************************
147 * 32bit CPU Architicture number
149 *******************************************************************************/
150 MV_U32
mvOsCpuArchGet( MV_VOID
)
152 return ((read_p15_c0() & ARM_ID_ARCH_MASK
) >> ARM_ID_ARCH_OFFS
);
154 /*******************************************************************************
166 * 32bit CPU Variant number
168 *******************************************************************************/
169 MV_U32
mvOsCpuVarGet( MV_VOID
)
171 return ((read_p15_c0() & ARM_ID_VAR_MASK
) >> ARM_ID_VAR_OFFS
);
173 /*******************************************************************************
174 * mvOsCpuAsciiGet() -
185 * 32bit CPU Variant number
187 *******************************************************************************/
188 MV_U32
mvOsCpuAsciiGet( MV_VOID
)
190 return ((read_p15_c0() & ARM_ID_ASCII_MASK
) >> ARM_ID_ASCII_OFFS
);
196 static unsigned long read_p15_c0 (void)
198 /* read co-processor 15, register #0 (ID register) */
199 static MV_U32
read_p15_c0 (void)
203 __asm__
__volatile__(
204 "mrc p15, 0, %0, c0, c0, 0 @ read control reg\n"
This page took 0.054584 seconds and 5 git commands to generate.