On Mon, Apr 18, 2016 at 01:34:54AM +0200, Marcin Wojtas wrote:
From: Bartosz Szczepanek bsz@semihalf.com
MvEeprom driver produces EFI_EEPROM_PROTOCOL, which can be used by
So ... with a "global" protocol name like EFI_EEPROM_PROTOCOL, there is a good argument for attempting to move the generic descriptions into MdeModulePkg and try to get included into EDK2.
If you would prefer not to do so, I would probably like it renamed to something like MARVELL_EFI_EEPROM_PROTOCOL.
other drivers or applications. Working EFI_I2C_IO_PROTOCOL is required by driver to operate.
EEPROM devices' addresses need to be fed via 'PcdEepromI2cAddresses'.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bartosz Szczepanek bsz@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
Documentation/Marvell/Drivers/EepromDriver.txt | 95 ++++++++ Drivers/I2c/Devices/MvEeprom/MvEeprom.c | 292 +++++++++++++++++++++++++ Drivers/I2c/Devices/MvEeprom/MvEeprom.h | 90 ++++++++ Drivers/I2c/Devices/MvEeprom/MvEeprom.inf | 70 ++++++ Platforms/Marvell/Include/Protocol/Eeprom.h | 60 +++++ Platforms/Marvell/Marvell.dec | 4 + 6 files changed, 611 insertions(+) create mode 100644 Documentation/Marvell/Drivers/EepromDriver.txt create mode 100644 Drivers/I2c/Devices/MvEeprom/MvEeprom.c create mode 100644 Drivers/I2c/Devices/MvEeprom/MvEeprom.h create mode 100644 Drivers/I2c/Devices/MvEeprom/MvEeprom.inf create mode 100644 Platforms/Marvell/Include/Protocol/Eeprom.h
diff --git a/Documentation/Marvell/Drivers/EepromDriver.txt b/Documentation/Marvell/Drivers/EepromDriver.txt new file mode 100644 index 0000000..8c352c8 --- /dev/null +++ b/Documentation/Marvell/Drivers/EepromDriver.txt @@ -0,0 +1,95 @@ +1. Introduction +--------------- +**MvEeprom** driver creates EFI_EEPROM_PROTOCOL, which ++is used for managing eeprom.
+2. MvEeprom driver design +------------------------- +Every I2C device driver should implement EFI_DRIVER_BINDING_PROTOCOL and +consume EFI_I2C_IO_PROTOCOL for transactions on I2C bus. MvEeprom driver +additionally implements EFI_EEPROM_PROTOCOL.
- 2.1 EFI_DRIVER_BINDING_PROTOCOL
- Driver Binding protocol is extensively covered in UEFI documentation, as
- it is not specific to I2C stack. The only difference is that Supported()
- function should check if EFI_I2C_IO_PROTOCOL provides valid EFI_GUID value.
- Excerpt from MvEepromSupported():
- Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiI2cIoProtocolGuid,
(VOID **) &TmpI2cIo,
gImageHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR(Status)) {
return EFI_UNSUPPORTED;
- }
- /* get EEPROM devices' addresses from PCD */
- EepromAddresses = PcdGetPtr (PcdEepromI2cAddresses);
- if (EepromAddresses == 0) {
Status = EFI_UNSUPPORTED;
goto out;
- }
- Status = EFI_UNSUPPORTED;
- for (i = 0; EepromAddresses[i] != '\0'; i++) {
/* last byte of GUID contains address on I2C bus */
EepromGuid.Data4[7] = EepromAddresses[i];
if (CompareGuid(TmpI2cIo->DeviceGuid, &EepromGuid)) {
DEBUG((DEBUG_INFO, "A8kEepromSupported: offered GUID fits desired\n"));
Status = EFI_SUCCESS;
break;
}
- }
- 2.2 EFI_I2C_IO_PROTOCOL
- This protocol is provided by generic I2C stack. Multiple drivers can use IO
- protocol at once, as queueing is implemented.
- QueueRequest is a routine that queues an I2C transaction to the I2C
- controller for execution on the I2C bus.
- 2.3 EFI_EEPROM_PROTOCOL
- typedef struct _EFI_EEPROM_PROTOCOL EFI_EEPROM_PROTOCOL;
- #define EEPROM_READ 0x1
- #define EEPROM_WRITE 0x0
- typedef
- EFI_STATUS
- (EFIAPI *EFI_EEPROM_TRANSFER) (
IN CONST EFI_EEPROM_PROTOCOL *This,
IN UINT16 Address,
IN UINT32 Length,
IN UINT8 *Buffer,
IN UINT8 Operation
);
- struct _EFI_EEPROM_PROTOCOL {
EFI_EEPROM_TRANSFER Transfer;
UINT8 Identifier;
- };
+3. Adding new I2C slave device drivers +-------------------------------------- +In order to support I2C slave device other than EEPROM, new driver should +be created. Required steps follow.
- Create driver directory (OpenPlatformPkg/Drivers/I2c/Devices/...).
- Create stubs of .inf and .c files (MvEeprom files are a reference),
include .inf file in platform .dsc and .fdf files.
- Implement EFI_DRIVER_BINDING_PROTOCOL - Start(), Stop(), Supported()
functions' implementation is a must. EFI_DRIVER_BINDING_PROTOCOL
should be installed at driver's entry point.
- Add I2C address of device to PcdI2cSlaveAddresses in .dsc file.
- Test available EFI_I2C_IO_PROTOCOLs in Supported() - find instance
with valid GUID (consisting of I2C_GUID and slave I2C address).
- Open EFI_I2C_IO_PROTOCOL for usage in Start(). After that, QueueRequest
function should be available.
- Implement core functionality of driver (using QueueRequest to access I2C).
- (not mandatory) Produce/consume additional protocols.
diff --git a/Drivers/I2c/Devices/MvEeprom/MvEeprom.c b/Drivers/I2c/Devices/MvEeprom/MvEeprom.c
Just want to say - we don't tend to see enough documentation of EFI code, so this is much appreciated.
new file mode 100644 index 0000000..2b0d191 --- /dev/null +++ b/Drivers/I2c/Devices/MvEeprom/MvEeprom.c @@ -0,0 +1,292 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#include <Protocol/DriverBinding.h> +#include <Protocol/I2cIo.h> +#include <Protocol/Eeprom.h>
+#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/IoLib.h> +#include <Library/DebugLib.h> +#include <Library/PcdLib.h> +#include <Library/UefiLib.h> +#include <Library/UefiBootServicesTableLib.h>
+#include <Pi/PiI2c.h>
+#include "MvEeprom.h"
+/* Last byte of GUID will contain address of device */
I am pretty sure this violates the GUID specification/rfc4122. All of the GUID should be produced by a compliant generator.
+#define I2C_GUID \
- { \
- 0x391fc679, 0x6cb0, 0x4f01, { 0x9a, 0xc7, 0x8e, 0x1b, 0x78, 0x6b, 0x7a, 0x00 } \
- }
+EFI_DRIVER_BINDING_PROTOCOL gDriverBindingProtocol = {
- MvEepromSupported,
- MvEepromStart,
- MvEepromStop
+};
+EFI_STATUS +EFIAPI +MvEepromSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
+{
- EFI_STATUS Status = EFI_UNSUPPORTED;
- EFI_GUID EepromGuid = I2C_GUID;
- EFI_I2C_IO_PROTOCOL *TmpI2cIo;
- UINT8 *EepromAddresses;
- UINTN i;
- Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiI2cIoProtocolGuid,
(VOID **) &TmpI2cIo,
gImageHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR(Status)) {
- return EFI_UNSUPPORTED;
- }
- /* get EEPROM devices' addresses from PCD */
- EepromAddresses = PcdGetPtr (PcdEepromI2cAddresses);
- if (EepromAddresses == 0) {
- Status = EFI_UNSUPPORTED;
- DEBUG((DEBUG_INFO, "MvEepromSupported: I2C device found, but it's not EEPROM\n"));
- goto out;
- }
- Status = EFI_UNSUPPORTED;
- for (i = 0; EepromAddresses[i] != '\0'; i++) {
- /* last byte of GUID contains address on I2C bus */
- EepromGuid.Data4[7] = EepromAddresses[i];
- if (CompareGuid(TmpI2cIo->DeviceGuid, &EepromGuid)) {
DEBUG((DEBUG_INFO, "MvEepromSupported: attached to EEPROM device\n"));
Status = EFI_SUCCESS;
break;
- }
- }
+out:
- gBS->CloseProtocol (
ControllerHandle,
&gEfiI2cIoProtocolGuid,
gImageHandle,
ControllerHandle
);
- return Status;
+}
+EFI_STATUS +EFIAPI +MvEepromTransfer (
- IN CONST EFI_EEPROM_PROTOCOL *This,
- IN UINT16 Address,
- IN UINT32 Length,
- IN UINT8 *Buffer,
- IN UINT8 Operation
- )
+{
- EFI_I2C_REQUEST_PACKET *RequestPacket;
- UINTN RequestPacketSize;
- EFI_STATUS Status = EFI_SUCCESS;
- EEPROM_CONTEXT *EepromContext = EEPROM_SC_FROM_EEPROM(This);
- UINT32 BufferLength;
- UINT32 Transmitted = 0;
- UINT32 CurrentAddress = Address;
- ASSERT(EepromContext != NULL);
- ASSERT(EepromContext->I2cIo != NULL);
- RequestPacketSize = sizeof(UINTN) + sizeof (EFI_I2C_OPERATION) * 2;
- RequestPacket = AllocateZeroPool (RequestPacketSize);
- if (RequestPacket == NULL)
- return EFI_OUT_OF_RESOURCES;
- /* First operation contains address, the second is buffer */
- RequestPacket->OperationCount = 2;
- RequestPacket->Operation[0].LengthInBytes = 2;
- RequestPacket->Operation[0].Buffer = AllocateZeroPool ( RequestPacket->Operation[0].LengthInBytes );
- if (RequestPacket->Operation[0].Buffer == NULL) {
- FreePool(RequestPacket);
- return EFI_OUT_OF_RESOURCES;
- }
- RequestPacket->Operation[1].Flags = (Operation == EEPROM_READ ? I2C_FLAG_READ : I2C_FLAG_NORESTART);
- while (Length > 0) {
- CurrentAddress = Address + Transmitted;
- BufferLength = (Length <= MAX_BUFFER_LENGTH ? Length : MAX_BUFFER_LENGTH);
- RequestPacket->Operation[0].Buffer[0] = (CurrentAddress >> 8) & 0xff;
- RequestPacket->Operation[0].Buffer[1] = CurrentAddress & 0xff;
- RequestPacket->Operation[1].LengthInBytes = BufferLength;
- RequestPacket->Operation[1].Buffer = Buffer + Transmitted;
- Status = EepromContext->I2cIo->QueueRequest(EepromContext->I2cIo, 0, NULL, RequestPacket, NULL);
- if (EFI_ERROR(Status)) {
DEBUG((DEBUG_ERROR, "MvEepromTransfer: error %d during transmission\n", Status));
break;
- }
- Length -= BufferLength;
- Transmitted += BufferLength;
- }
- FreePool(RequestPacket->Operation[0].Buffer);
- FreePool(RequestPacket);
- return Status;
+}
+EFI_STATUS +EFIAPI +MvEepromStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
+{
- EFI_STATUS Status = EFI_SUCCESS;
- EEPROM_CONTEXT *EepromContext;
- EepromContext = AllocateZeroPool (sizeof(EEPROM_CONTEXT));
- if (EepromContext == NULL) {
- DEBUG((DEBUG_ERROR, "MvEeprom: allocation fail\n"));
- return EFI_OUT_OF_RESOURCES;
- }
- EepromContext->ControllerHandle = ControllerHandle;
- EepromContext->Signature = EEPROM_SIGNATURE;
- EepromContext->EepromProtocol.Transfer = MvEepromTransfer;
- Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiI2cIoProtocolGuid,
(VOID **) &EepromContext->I2cIo,
gImageHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "MvEeprom: failed to open I2cIo\n"));
- FreePool(EepromContext);
- return EFI_UNSUPPORTED;
- }
- EepromContext->EepromProtocol.Identifier = EepromContext->I2cIo->DeviceIndex;
- Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiEepromProtocolGuid, &EepromContext->EepromProtocol,
NULL
);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "MvEeprom: failed to install EEPROM protocol\n"));
- goto fail;
- }
- return Status;
+fail:
- FreePool(EepromContext);
- gBS->CloseProtocol (
ControllerHandle,
&gEfiI2cIoProtocolGuid,
gImageHandle,
ControllerHandle
);
- return Status;
+}
+EFI_STATUS +EFIAPI +MvEepromStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
- )
+{
- EFI_EEPROM_PROTOCOL *EepromProtocol;
- EFI_STATUS Status;
- EEPROM_CONTEXT *EepromContext;
- Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiEepromProtocolGuid,
(VOID **) &EepromProtocol,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- EepromContext = EEPROM_SC_FROM_EEPROM(EepromProtocol);
- gBS->UninstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiEepromProtocolGuid, &EepromContext->EepromProtocol,
&gEfiDriverBindingProtocolGuid, &gDriverBindingProtocol,
NULL
);
- gBS->CloseProtocol (
ControllerHandle,
&gEfiI2cIoProtocolGuid,
gImageHandle,
ControllerHandle
);
- FreePool(EepromContext);
- return EFI_SUCCESS;
+}
+EFI_STATUS +EFIAPI +MvEepromInitialise (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- EFI_STATUS Status;
- Status = gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
&gEfiDriverBindingProtocolGuid, &gDriverBindingProtocol,
NULL
);
- return Status;
+} diff --git a/Drivers/I2c/Devices/MvEeprom/MvEeprom.h b/Drivers/I2c/Devices/MvEeprom/MvEeprom.h new file mode 100644 index 0000000..bcbe4a5 --- /dev/null +++ b/Drivers/I2c/Devices/MvEeprom/MvEeprom.h @@ -0,0 +1,90 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#ifndef __MV_EEPROM_H__ +#define __MV_EEPROM_H__
+#include <Uefi.h>
+#define EEPROM_SIGNATURE SIGNATURE_32 ('E', 'E', 'P', 'R')
+#define MAX_BUFFER_LENGTH 64
+#define I2C_FLAG_NORESTART 0x00000002
+typedef struct {
- UINT32 Signature;
- EFI_HANDLE ControllerHandle;
- EFI_I2C_IO_PROTOCOL *I2cIo;
- EFI_EEPROM_PROTOCOL EepromProtocol;
+} EEPROM_CONTEXT;
+#define EEPROM_SC_FROM_IO(a) CR (a, EEPROM_CONTEXT, I2cIo, EEPROM_SIGNATURE) +#define EEPROM_SC_FROM_EEPROM(a) CR (a, EEPROM_CONTEXT, EepromProtocol, EEPROM_SIGNATURE)
+EFI_STATUS +EFIAPI +MvEepromSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
+EFI_STATUS +EFIAPI +MvEepromStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
+EFI_STATUS +EFIAPI +MvEepromStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
- );
+EFI_STATUS +EFIAPI +MvEepromTransfer (
- IN CONST EFI_EEPROM_PROTOCOL *This,
- IN UINT16 Address,
- IN UINT32 Length,
- IN UINT8 *Buffer,
- IN UINT8 Operation
- );
+#endif // __MV_EEPROM_H__ diff --git a/Drivers/I2c/Devices/MvEeprom/MvEeprom.inf b/Drivers/I2c/Devices/MvEeprom/MvEeprom.inf new file mode 100644 index 0000000..767c13e --- /dev/null +++ b/Drivers/I2c/Devices/MvEeprom/MvEeprom.inf @@ -0,0 +1,70 @@ +# Copyright (C) 2016 Marvell International Ltd. +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute and/or +# modify this File under the following licensing terms. +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +#* Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +#* Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +#* Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#
+[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MvEeprom
- FILE_GUID = 59fc3843-d8d4-40aa-ae07-38967138509c
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = MvEepromInitialise
+[Sources.common]
- MvEeprom.c
+[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- ArmPkg/ArmPkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
+[LibraryClasses]
- IoLib
- PcdLib
- BaseLib
- BaseMemoryLib
- DebugLib
- UefiLib
- UefiDriverEntryPoint
- UefiBootServicesTableLib
+[Protocols]
- gEfiI2cIoProtocolGuid
- gEfiDriverBindingProtocolGuid
- gEfiEepromProtocolGuid
+[Pcd]
- gMarvellTokenSpaceGuid.PcdEepromI2cAddresses
+[Depex]
- TRUE
diff --git a/Platforms/Marvell/Include/Protocol/Eeprom.h b/Platforms/Marvell/Include/Protocol/Eeprom.h new file mode 100644 index 0000000..41f7e0e --- /dev/null +++ b/Platforms/Marvell/Include/Protocol/Eeprom.h
While I don't see a need for the name of the file to be changed if kept in OpenPlatformPkg ...
@@ -0,0 +1,60 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met:
+* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+* Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+#ifndef __EEPROM_H__ +#define __EEPROM_H__
... I would probably like to see the include guard given a less global name (__MARVELL_EEPROM_H_).
+#define EFI_EEPROM_PROTOCOL_GUID { 0xcd728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }}
+typedef struct _EFI_EEPROM_PROTOCOL EFI_EEPROM_PROTOCOL;
+#define EEPROM_READ 0x1 +#define EEPROM_WRITE 0x0 +typedef +EFI_STATUS +(EFIAPI *EFI_EEPROM_TRANSFER) (
- IN CONST EFI_EEPROM_PROTOCOL *This,
- IN UINT16 Address,
- IN UINT32 Length,
- IN UINT8 *Buffer,
- IN UINT8 Operation
- );
+struct _EFI_EEPROM_PROTOCOL {
- EFI_EEPROM_TRANSFER Transfer;
- UINT8 Identifier;
+};
+extern EFI_GUID gEfiEepromProtocolGuid; +#endif diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index 2a7a7e2..a07a6d2 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -106,7 +106,11 @@ #I2C gMarvellTokenSpaceGuid.PcdI2cSlaveAddresses|{ 0 }|VOID*|0x3000046
- gMarvellTokenSpaceGuid.PcdEepromI2cAddresses|{ 0 }|VOID*|0x3000050 gMarvellTokenSpaceGuid.PcdI2cBaseAddress|0|UINT64|0x3000047 gMarvellTokenSpaceGuid.PcdI2cClockFrequency|0|UINT32|0x3000048 gMarvellTokenSpaceGuid.PcdI2cBaudRate|0|UINT32|0x3000049
+[Protocols]
- gEfiEepromProtocolGuid = { 0xcd728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }}
-- 1.8.3.1