diff options
author | Marcin Wojtas <mw@semihalf.com> | 2017-04-20 17:14:58 +0200 |
---|---|---|
committer | Leif Lindholm <leif.lindholm@linaro.org> | 2017-10-09 17:41:59 +0100 |
commit | 6e6bb65388334f23c1544dd03a444a301fca36a6 (patch) | |
tree | 94ae46839b6f7c9e4873f439c6cc714018fc845f /Platform/Marvell/Drivers | |
parent | 93a4bcbe8d81582c6aaa751b4ca5019e88d3d833 (diff) | |
download | edk2-platforms-6e6bb65388334f23c1544dd03a444a301fca36a6.tar.xz |
Marvell/Drivers: MvI2cDxe: Move devices description to MvHwDescLib
This patch introduces I2c description, using the new structures
and template in MvHwDescLib. This change enables more flexible
addition of multiple I2c controllers and also allows for
removal of string PCD parsing. Update Armada 70x0 DB description
and PortingGuide accordingly.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Platform/Marvell/Drivers')
-rwxr-xr-x | Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c | 42 | ||||
-rwxr-xr-x | Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf | 3 |
2 files changed, 25 insertions, 20 deletions
diff --git a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c index fa79ebccfa..d85ee0bafd 100755 --- a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c +++ b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c @@ -42,12 +42,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
-#include <Library/ParsePcdLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/MvHwDescLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "MvI2cDxe.h"
+DECLARE_A7K8K_I2C_TEMPLATE;
+
STATIC MV_I2C_BAUD_RATE baud_rate;
STATIC MV_I2C_DEVICE_PATH MvI2cDevicePathProtocol = {
@@ -172,35 +174,39 @@ MvI2cInitialise ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ MVHW_I2C_DESC *Desc = &mA7k8kI2cDescTemplate;
+ UINT8 *I2cDeviceTable, Index;
EFI_STATUS Status;
- UINT32 BusCount;
- EFI_PHYSICAL_ADDRESS I2cBaseAddresses[PcdGet32 (PcdI2cBusCount)];
- INTN i;
- BusCount = PcdGet32 (PcdI2cBusCount);
- if (BusCount == 0)
- return EFI_SUCCESS;
+ /* Obtain table with enabled I2c devices */
+ I2cDeviceTable = (UINT8 *)PcdGetPtr (PcdI2cControllersEnabled);
+ if (I2cDeviceTable == NULL) {
+ DEBUG ((DEBUG_ERROR, "Missing PcdI2cControllersEnabled\n"));
+ return EFI_INVALID_PARAMETER;
+ }
- Status = ParsePcdString (
- (CHAR16 *) PcdGetPtr (PcdI2cBaseAddresses),
- BusCount,
- I2cBaseAddresses,
- NULL
- );
- if (EFI_ERROR(Status))
- return Status;
+ if (PcdGetSize (PcdI2cControllersEnabled) > MVHW_MAX_I2C_DEVS) {
+ DEBUG ((DEBUG_ERROR, "Wrong PcdI2cControllersEnabled format\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ /* Initialize enabled chips */
+ for (Index = 0; Index < PcdGetSize (PcdI2cControllersEnabled); Index++) {
+ if (!MVHW_DEV_ENABLED (I2c, Index)) {
+ DEBUG ((DEBUG_ERROR, "Skip I2c chip %d\n", Index));
+ continue;
+ }
- for (i = 0; i < BusCount; i++) {
Status = MvI2cInitialiseController(
ImageHandle,
SystemTable,
- I2cBaseAddresses[i]
+ Desc->I2cBaseAddresses[Index]
);
if (EFI_ERROR(Status))
return Status;
}
- return Status;
+ return EFI_SUCCESS;
}
STATIC
diff --git a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf index 16374ef5e7..80655f13fe 100755 --- a/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf +++ b/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf @@ -55,7 +55,6 @@ UefiLib
UefiDriverEntryPoint
UefiBootServicesTableLib
- ParsePcdLib
[Protocols]
gEfiI2cMasterProtocolGuid
@@ -66,7 +65,7 @@ [Pcd]
gMarvellTokenSpaceGuid.PcdI2cSlaveAddresses
gMarvellTokenSpaceGuid.PcdI2cSlaveBuses
- gMarvellTokenSpaceGuid.PcdI2cBaseAddresses
+ gMarvellTokenSpaceGuid.PcdI2cControllersEnabled
gMarvellTokenSpaceGuid.PcdI2cClockFrequency
gMarvellTokenSpaceGuid.PcdI2cBaudRate
gMarvellTokenSpaceGuid.PcdI2cBusCount
|