1 /** @file
2   I2C Device Enumerate Protocol as defined in the PI 1.3 specification.
3 
4   This protocol supports the enumerations of device on the I2C bus.
5 
6   Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
7   This program and the accompanying materials
8   are licensed and made available under the terms and conditions of the BSD License
9   which accompanies this distribution.  The full text of the license may be found at
10   http://opensource.org/licenses/bsd-license.php
11 
12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 
15   @par Revision Reference:
16   This protocol is from PI Version 1.3.
17 
18 **/
19 
20 #ifndef __I2C_ENUMERATE_H__
21 #define __I2C_ENUMERATE_H__
22 
23 #include <Pi/PiI2c.h>
24 
25 #define EFI_I2C_ENUMERATE_PROTOCOL_GUID   { 0xda8cd7c4, 0x1c00, 0x49e2, { 0x80, 0x3e, 0x52, 0x14, 0xe7, 0x01, 0x89, 0x4c }}
26 
27 typedef struct _EFI_I2C_ENUMERATE_PROTOCOL  EFI_I2C_ENUMERATE_PROTOCOL;
28 
29 /**
30   Enumerate the I2C devices
31 
32   This function enables the caller to traverse the set of I2C devices
33   on an I2C bus.
34 
35   @param[in]  This              The platform data for the next device on
36                                 the I2C bus was returned successfully.
37   @param[in, out] Device        Pointer to a buffer containing an
38                                 EFI_I2C_DEVICE structure.  Enumeration is
39                                 started by setting the initial EFI_I2C_DEVICE
40                                 structure pointer to NULL.  The buffer
41                                 receives an EFI_I2C_DEVICE structure pointer
42                                 to the next I2C device.
43 
44   @retval EFI_SUCCESS           The platform data for the next device on
45                                 the I2C bus was returned successfully.
46   @retval EFI_INVALID_PARAMETER Device is NULL
47   @retval EFI_NO_MAPPING        *Device does not point to a valid
48                                 EFI_I2C_DEVICE structure returned in a
49                                 previous call Enumerate().
50 
51 **/
52 typedef
53 EFI_STATUS
54 (EFIAPI *EFI_I2C_ENUMERATE_PROTOCOL_ENUMERATE) (
55   IN CONST EFI_I2C_ENUMERATE_PROTOCOL *This,
56   IN OUT CONST EFI_I2C_DEVICE         **Device
57   );
58 
59 /**
60   Get the requested I2C bus frequency for a specified bus configuration.
61 
62   This function returns the requested I2C bus clock frequency for the
63   I2cBusConfiguration.  This routine is provided for diagnostic purposes
64   and is meant to be called after calling Enumerate to get the
65   I2cBusConfiguration value.
66 
67   @param[in] This                 Pointer to an EFI_I2C_ENUMERATE_PROTOCOL
68                                   structure.
69   @param[in] I2cBusConfiguration  I2C bus configuration to access the I2C
70                                   device
71   @param[out] *BusClockHertz      Pointer to a buffer to receive the I2C
72                                   bus clock frequency in Hertz
73 
74   @retval EFI_SUCCESS           The I2C bus frequency was returned
75                                 successfully.
76   @retval EFI_INVALID_PARAMETER BusClockHertz was NULL
77   @retval EFI_NO_MAPPING        Invalid I2cBusConfiguration value
78 
79 **/
80 typedef
81 EFI_STATUS
82 (EFIAPI *EFI_I2C_ENUMERATE_PROTOCOL_GET_BUS_FREQUENCY) (
83   IN CONST EFI_I2C_ENUMERATE_PROTOCOL *This,
84   IN UINTN                            I2cBusConfiguration,
85   OUT UINTN                           *BusClockHertz
86   );
87 
88 ///
89 /// I2C Enumerate protocol
90 ///
91 struct _EFI_I2C_ENUMERATE_PROTOCOL {
92   ///
93   /// Traverse the set of I2C devices on an I2C bus.  This routine
94   /// returns the next I2C device on an I2C bus.
95   ///
96   EFI_I2C_ENUMERATE_PROTOCOL_ENUMERATE         Enumerate;
97 
98   ///
99   /// Get the requested I2C bus frequency for a specified bus
100   /// configuration.
101   ///
102   EFI_I2C_ENUMERATE_PROTOCOL_GET_BUS_FREQUENCY GetBusFrequency;
103 };
104 
105 ///
106 /// Reference to variable defined in the .DEC file
107 ///
108 extern EFI_GUID gEfiI2cEnumerateProtocolGuid;
109 
110 #endif  //  __I2C_ENUMERATE_H__
111