Moving OMAP 3530 code out of BeagleBoard package into its own package
[mirror_edk2.git] / Omap35xxPkg / Library / ResetSystemLib / ResetSystemLib.c
1 /** @file
2 Template library implementation to support ResetSystem Runtime call.
3
4 Fill in the templates with what ever makes you system reset.
5
6
7 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
8
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18
19
20 #include <PiDxe.h>
21
22 #include <Library/PcdLib.h>
23 #include <Library/ArmLib.h>
24 #include <Library/CacheMaintenanceLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/EfiResetSystemLib.h>
27
28 #include <Library/BeagleBoardSystemLib.h>
29
30 /**
31 Resets the entire platform.
32
33 @param ResetType The type of reset to perform.
34 @param ResetStatus The status code for the reset.
35 @param DataSize The size, in bytes, of WatchdogData.
36 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
37 EfiResetShutdown the data buffer starts with a Null-terminated
38 Unicode string, optionally followed by additional binary data.
39
40 **/
41 EFI_STATUS
42 EFIAPI
43 LibResetSystem (
44 IN EFI_RESET_TYPE ResetType,
45 IN EFI_STATUS ResetStatus,
46 IN UINTN DataSize,
47 IN CHAR16 *ResetData OPTIONAL
48 )
49 {
50 if (ResetData != NULL) {
51 DEBUG((EFI_D_ERROR, "%s", ResetData));
52 }
53
54 switch (ResetType) {
55 case EfiResetWarm:
56 // Map a warm reset into a cold reset
57 case EfiResetCold:
58 case EfiResetShutdown:
59 default:
60 // Perform cold reset of the system.
61 MmioOr32 (PRM_RSTCTRL, RST_DPLL3);
62 while ((MmioRead32(PRM_RSTST) & GLOBAL_COLD_RST) != 0x1);
63 break;
64 }
65
66 // If the reset didn't work, return an error.
67 ASSERT (FALSE);
68 return EFI_DEVICE_ERROR;
69 }
70
71
72
73 /**
74 Initialize any infrastructure required for LibResetSystem () to function.
75
76 @param ImageHandle The firmware allocated handle for the EFI image.
77 @param SystemTable A pointer to the EFI System Table.
78
79 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
80
81 **/
82 EFI_STATUS
83 EFIAPI
84 LibInitializeResetSystem (
85 IN EFI_HANDLE ImageHandle,
86 IN EFI_SYSTEM_TABLE *SystemTable
87 )
88 {
89 return EFI_SUCCESS;
90 }
91