summaryrefslogtreecommitdiff
path: root/Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'Platform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c')
-rwxr-xr-xPlatform/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.c42
1 files changed, 24 insertions, 18 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