]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c
Add I2C bus DXE driver and I2C host DXE driver following PI 1.3 spec.
[mirror_edk2.git] / MdeModulePkg / Bus / I2c / I2cDxe / I2cDxe.c
1 /** @file
2 This file implements the entrypoint and unload function for I2C DXE module.
3
4 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "I2cDxe.h"
16
17 /**
18 The user Entry Point for I2C module. The user code starts with this function.
19
20 @param[in] ImageHandle The firmware allocated handle for the EFI image.
21 @param[in] SystemTable A pointer to the EFI System Table.
22
23 @retval EFI_SUCCESS The entry point is executed successfully.
24 @retval other Some error occurs when executing this entry point.
25
26 **/
27 EFI_STATUS
28 EFIAPI
29 InitializeI2c(
30 IN EFI_HANDLE ImageHandle,
31 IN EFI_SYSTEM_TABLE *SystemTable
32 )
33 {
34 EFI_STATUS Status;
35
36 //
37 // Install driver model protocol(s).
38 //
39 Status = InitializeI2cHost ( ImageHandle, SystemTable );
40 if ( !EFI_ERROR ( Status ))
41 {
42 Status = InitializeI2cBus ( ImageHandle, SystemTable );
43 }
44 return Status;
45 }
46
47 /**
48 This is the unload handle for I2C module.
49
50 Disconnect the driver specified by ImageHandle from all the devices in the handle database.
51 Uninstall all the protocols installed in the driver entry point.
52
53 @param[in] ImageHandle The drivers' driver image.
54
55 @retval EFI_SUCCESS The image is unloaded.
56 @retval Others Failed to unload the image.
57
58 **/
59 EFI_STATUS
60 EFIAPI
61 I2cUnload (
62 IN EFI_HANDLE ImageHandle
63 )
64 {
65 EFI_STATUS Status;
66
67 //
68 // Disconnect the drivers
69 //
70 Status = I2cBusUnload ( ImageHandle );
71 if ( !EFI_ERROR ( Status )) {
72 Status = I2cHostUnload ( ImageHandle );
73 }
74 return Status;
75 }