Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Silicon/Marvell/Marvell.dec b/Silicon/Marvell/Marvell.dec
- index 20a32ef..12bac55 100644
- --- a/Silicon/Marvell/Marvell.dec
- +++ b/Silicon/Marvell/Marvell.dec
- @@ -216,7 +216,6 @@
- [Protocols]
- gMarvellBoardDescProtocolGuid = { 0xebed8738, 0xd4a6, 0x4001, { 0xa9, 0xc9, 0x52, 0xb0, 0xcb, 0x7d, 0xdb, 0xf9 }}
- gMarvellEepromProtocolGuid = { 0x71954bda, 0x60d3, 0x4ef8, { 0x8e, 0x3c, 0x0e, 0x33, 0x9f, 0x3b, 0xc2, 0x2b }}
- - gMarvellGpioProtocolGuid = { 0x8b01a5b7, 0xc570, 0x4e97, { 0x80, 0x95, 0x4f, 0x74, 0x2a, 0x8d, 0x7d, 0x43 }}
- gMarvellMdioProtocolGuid = { 0x40010b03, 0x5f08, 0x496a, { 0xa2, 0x64, 0x10, 0x5e, 0x72, 0xd3, 0x71, 0xaa }}
- gMarvellPhyProtocolGuid = { 0x32f48a43, 0x37e3, 0x4acf, { 0x93, 0xc4, 0x3e, 0x57, 0xa7, 0xb0, 0xfb, 0xdc }}
- gMarvellSpiMasterProtocolGuid = { 0x23de66a3, 0xf666, 0x4b3e, { 0xaa, 0xa2, 0x68, 0x9b, 0x18, 0xae, 0x2e, 0x19 }}
- diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
- index b26f55b..c995515 100644
- --- a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
- +++ b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.inf
- @@ -25,6 +25,7 @@
- Armada70x0DbBoardDescLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- index bbe7ff8..8d33e1d 100644
- --- a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- +++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- @@ -32,6 +32,7 @@
- NonDiscoverableInitLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Marvell/Marvell.dec
- @@ -41,7 +42,7 @@
- IoLib
- [Protocols]
- - gMarvellGpioProtocolGuid
- + gEmbeddedGpioProtocolGuid
- [Depex]
- gMarvellPlatformInitCompleteProtocolGuid
- diff --git a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
- index 2d39d96..786b7f0 100644
- --- a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
- +++ b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.inf
- @@ -25,6 +25,7 @@
- Armada80x0DbBoardDescLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- index 00b5ed5..e69e48a 100644
- --- a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- +++ b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- @@ -33,6 +33,7 @@
- NonDiscoverableInitLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Marvell/Marvell.dec
- @@ -42,7 +43,7 @@
- IoLib
- [Protocols]
- - gMarvellGpioProtocolGuid
- + gEmbeddedGpioProtocolGuid
- [Depex]
- gMarvellPlatformInitCompleteProtocolGuid
- diff --git a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
- index 63a4f66..43e4b9e 100644
- --- a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
- +++ b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.inf
- @@ -25,6 +25,7 @@
- Armada80x0McBinBoardDescLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- index 66720d2..d0190b6 100644
- --- a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- +++ b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.inf
- @@ -33,6 +33,7 @@
- NonDiscoverableInitLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Marvell/Marvell.dec
- @@ -42,7 +43,7 @@
- IoLib
- [Protocols]
- - gMarvellGpioProtocolGuid
- + gEmbeddedGpioProtocolGuid
- [Depex]
- gMarvellPlatformInitCompleteProtocolGuid
- diff --git a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf
- index 5503463..e707fe9 100644
- --- a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf
- +++ b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf
- @@ -25,6 +25,7 @@
- PlatInitDxe.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
- index 2b73b73..48a320c 100644
- --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
- +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.inf
- @@ -24,6 +24,7 @@
- Armada7k8kSoCDescLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
- index 0b93948..0b641fe 100644
- --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
- +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.inf
- @@ -42,6 +42,7 @@
- MvBoardDescDxe.h
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
- index 2d56433..5ff9130 100644
- --- a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
- +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf
- @@ -24,6 +24,7 @@
- MvGpioDxe.h
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- @@ -36,8 +37,8 @@
- UefiLib
- [Protocols]
- + gEmbeddedGpioProtocolGuid
- gMarvellBoardDescProtocolGuid
- - gMarvellGpioProtocolGuid
- [Depex]
- TRUE
- diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf
- index 3066732..3b1ab4e 100644
- --- a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf
- +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf
- @@ -24,6 +24,7 @@
- MvPca95xxDxe.h
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- @@ -37,8 +38,8 @@
- [Protocols]
- gEfiDriverBindingProtocolGuid
- gEfiI2cIoProtocolGuid
- + gEmbeddedGpioProtocolGuid
- gMarvellBoardDescProtocolGuid
- - gMarvellGpioProtocolGuid
- [Depex]
- TRUE
- diff --git a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
- index 0eef350..e5bd370 100755
- --- a/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
- +++ b/Silicon/Marvell/Drivers/I2c/MvI2cDxe/MvI2cDxe.inf
- @@ -41,6 +41,7 @@
- MvI2cDxe.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- diff --git a/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf b/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf
- index 739576f..8a877da 100644
- --- a/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf
- +++ b/Silicon/Marvell/Drivers/Net/MvMdioDxe/MvMdioDxe.inf
- @@ -45,6 +45,7 @@
- [Packages]
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf b/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf
- index 00c738a..09c5842 100644
- --- a/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf
- +++ b/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonDxe.inf
- @@ -35,6 +35,7 @@
- XenonSdMmcOverride.h
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf b/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
- index 36f498b..c360edd 100644
- --- a/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
- +++ b/Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
- @@ -41,6 +41,7 @@
- [Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- + EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Library/IcuLib/IcuLib.inf b/Silicon/Marvell/Library/IcuLib/IcuLib.inf
- index 0010141..ea662be 100644
- --- a/Silicon/Marvell/Library/IcuLib/IcuLib.inf
- +++ b/Silicon/Marvell/Library/IcuLib/IcuLib.inf
- @@ -24,6 +24,7 @@
- IcuLib.c
- [Packages]
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf b/Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
- index e2381f4..805a057 100644
- --- a/Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
- +++ b/Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
- @@ -41,6 +41,7 @@
- [Packages]
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- + EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- Silicon/Marvell/Marvell.dec
- diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
- new file mode 100644
- index 0000000..8a0e424
- --- /dev/null
- +++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
- @@ -0,0 +1,23 @@
- +/**
- +*
- +* Copyright (c) 2018, Marvell International Ltd. All rights reserved.
- +*
- +* This program and the accompanying materials are licensed and made available
- +* under the terms and conditions of the BSD License which accompanies this
- +* distribution. The full text of the license may be found at
- +* http://opensource.org/licenses/bsd-license.php
- +*
- +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- +*
- +**/
- +#ifndef __NON_DISCOVERABLE_INIT_LIB_H__
- +#define __NON_DISCOVERABLE_INIT_LIB_H__
- +
- +#define ARMADA_70x0_DB_IO_EXPANDER0 0
- +#define ARMADA_70x0_DB_VBUS0_PIN 0
- +#define ARMADA_70x0_DB_VBUS0_LIMIT_PIN 4
- +#define ARMADA_70x0_DB_VBUS1_PIN 1
- +#define ARMADA_70x0_DB_VBUS1_LIMIT_PIN 5
- +
- +#endif
- diff --git a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
- new file mode 100644
- index 0000000..64373ff
- --- /dev/null
- +++ b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
- @@ -0,0 +1,28 @@
- +/**
- +*
- +* Copyright (c) 2017, Linaro Ltd. All rights reserved.
- +* Copyright (c) 2018, Marvell International Ltd. All rights reserved.
- +*
- +* This program and the accompanying materials are licensed and made available
- +* under the terms and conditions of the BSD License which accompanies this
- +* distribution. The full text of the license may be found at
- +* http://opensource.org/licenses/bsd-license.php
- +*
- +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- +*
- +**/
- +#ifndef __NON_DISCOVERABLE_INIT_LIB_H__
- +#define __NON_DISCOVERABLE_INIT_LIB_H__
- +
- +#define ARMADA_80x0_DB_IO_EXPANDER0 0
- +#define ARMADA_80x0_DB_VBUS0_PIN 0
- +#define ARMADA_80x0_DB_VBUS0_LIMIT_PIN 4
- +#define ARMADA_80x0_DB_VBUS1_PIN 1
- +#define ARMADA_80x0_DB_VBUS1_LIMIT_PIN 5
- +
- +#define ARMADA_80x0_DB_IO_EXPANDER1 1
- +#define ARMADA_80x0_DB_VBUS2_PIN 0
- +#define ARMADA_80x0_DB_VBUS2_LIMIT_PIN 4
- +
- +#endif
- diff --git a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h
- new file mode 100644
- index 0000000..38e1f20
- --- /dev/null
- +++ b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.h
- @@ -0,0 +1,20 @@
- +/**
- +*
- +* Copyright (c) 2017, Linaro Ltd. All rights reserved.
- +* Copyright (c) 2018, Marvell International Ltd. All rights reserved.
- +*
- +* This program and the accompanying materials are licensed and made available
- +* under the terms and conditions of the BSD License which accompanies this
- +* distribution. The full text of the license may be found at
- +* http://opensource.org/licenses/bsd-license.php
- +*
- +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- +*
- +**/
- +#ifndef __NON_DISCOVERABLE_INIT_LIB_H__
- +#define __NON_DISCOVERABLE_INIT_LIB_H__
- +
- +#define ARMADA_80x0_MCBIN_VBUS0_PIN 15
- +
- +#endif
- diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
- index 85dd67c..bfc8639 100644
- --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
- +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
- @@ -22,7 +22,7 @@
- // Common macros
- //
- #define MV_SOC_CP_BASE(Cp) (0xF2000000 + ((Cp) * 0x2000000))
- -#define MV_SOC_AP_COUNT 1
- +#define MV_SOC_AP806_COUNT 1
- //
- // Platform description of AHCI controllers
- @@ -41,8 +41,8 @@
- //
- // Platform description of GPIO controllers
- //
- -#define MV_SOC_AP_GPIO_BASE 0xF06F5040
- -#define MV_SOC_AP_GPIO_PIN_COUNT 20
- +#define MV_SOC_AP806_GPIO_BASE 0xF06F5040
- +#define MV_SOC_AP806_GPIO_PIN_COUNT 20
- #define MV_SOC_GPIO_PER_CP_COUNT 2
- #define MV_SOC_CP_GPIO_BASE(Gpio) (0x440100 + ((Gpio) * 0x40))
- #define MV_SOC_CP_GPIO_PIN_COUNT(Gpio) ((Gpio) == 0 ? 32 : 31)
- diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
- index 48744dc..4e5422b 100644
- --- a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
- +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h
- @@ -29,24 +29,21 @@
- #include <Uefi/UefiBaseType.h>
- -#define GPIO_SIGNATURE SIGNATURE_32 ('G', 'P', 'I', 'O')
- +#define MV_GPIO_SIGNATURE SIGNATURE_32 ('G', 'P', 'I', 'O')
- -#ifndef BIT
- -#define BIT(nr) (1 << (nr))
- -#endif
- -
- -// Marvell GPIO Controller Registers
- -#define GPIO_DATA_OUT_REG (0x0)
- -#define GPIO_OUT_EN_REG (0x4)
- -#define GPIO_BLINK_EN_REG (0x8)
- -#define GPIO_DATA_IN_POL_REG (0xc)
- -#define GPIO_DATA_IN_REG (0x10)
- +// Marvell MV_GPIO Controller Registers
- +#define MV_GPIO_DATA_OUT_REG (0x0)
- +#define MV_GPIO_OUT_EN_REG (0x4)
- +#define MV_GPIO_BLINK_EN_REG (0x8)
- +#define MV_GPIO_DATA_IN_POL_REG (0xc)
- +#define MV_GPIO_DATA_IN_REG (0x10)
- typedef struct {
- - MARVELL_GPIO_PROTOCOL GpioProtocol;
- - MV_BOARD_GPIO_DESC *Desc;
- - UINTN Signature;
- - EFI_HANDLE Handle;
- + EMBEDDED_GPIO GpioProtocol;
- + GPIO_CONTROLLER *SoCGpio;
- + UINTN GpioDeviceCount;
- + UINTN Signature;
- + EFI_HANDLE Handle;
- } MV_GPIO;
- #endif // __MV_GPIO_H__
- diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h
- index 43daee0..1fed739 100644
- --- a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h
- +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h
- @@ -32,10 +32,6 @@
- #define PCA95XX_GPIO_SIGNATURE SIGNATURE_32 ('I', 'O', 'E', 'X')
- -#ifndef BIT
- -#define BIT(nr) (1 << (nr))
- -#endif
- -
- #define PCA95XX_INPUT_REG 0x0
- #define PCA95XX_OUTPUT_REG 0x2
- #define PCA95XX_DIRECTION_REG 0x6
- @@ -58,17 +54,12 @@ typedef enum {
- PCA9557_PIN_COUNT = 16,
- } PCA95XX_PIN_COUNT;
- -typedef enum {
- - PCA95XX_READ,
- - PCA95XX_WRITE,
- -} PCA95XX_OPERATION;
- -
- typedef struct {
- - MARVELL_GPIO_PROTOCOL GpioProtocol;
- - MV_I2C_IO_EXPANDER_DESC *ControllerDesc;
- - UINTN ControllerCount;
- - UINTN Signature;
- - EFI_HANDLE ControllerHandle;
- + EMBEDDED_GPIO GpioProtocol;
- + MV_GPIO_EXPANDER *GpioExpanders;
- + UINTN GpioExpanderCount;
- + UINTN Signature;
- + EFI_HANDLE ControllerHandle;
- } PCA95XX;
- #endif
- diff --git a/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h b/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h
- index 7629c86..6ec5ace 100644
- --- a/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h
- +++ b/Silicon/Marvell/Include/Library/ArmadaBoardDescLib.h
- @@ -31,20 +31,20 @@ typedef struct {
- UINTN ChipId;
- UINTN I2cAddress;
- UINTN I2cBus;
- -} MV_I2C_IO_EXPANDER_DESC;
- +} MV_GPIO_EXPANDER;
- typedef struct {
- - MV_SOC_GPIO_DESC *SoC;
- - UINTN GpioDevCount;
- - MV_I2C_IO_EXPANDER_DESC *I2cIoExpanderDesc;
- - UINTN I2cIoExpanderCount;
- -} MV_BOARD_GPIO_DESC;
- + GPIO_CONTROLLER *SoCGpio;
- + UINTN GpioDeviceCount;
- + MV_GPIO_EXPANDER *GpioExpanders;
- + UINTN GpioExpanderCount;
- +} MV_BOARD_GPIO_DESCRIPTION;
- EFI_STATUS
- EFIAPI
- -ArmadaBoardDescGpioGet (
- - IN OUT MV_I2C_IO_EXPANDER_DESC **I2cIoExpanderDesc,
- - IN OUT UINTN *I2cIoExpanderCount
- +ArmadaBoardGpioExpanderGet (
- + IN OUT MV_GPIO_EXPANDER **GpioExpanders,
- + IN OUT UINTN *GpioExpanderCount
- );
- //
- diff --git a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h
- index f3d4f80..26b075a 100644
- --- a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h
- +++ b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h
- @@ -17,6 +17,8 @@
- #include <Library/MvComPhyLib.h>
- #include <Library/NonDiscoverableDeviceRegistrationLib.h>
- +#include <Protocol/EmbeddedGpio.h>
- +
- //
- // ComPhy SoC description
- //
- @@ -48,16 +50,11 @@ ArmadaSoCDescCpBaseGet (
- //
- // GPIO devices description template definition
- //
- -typedef struct {
- - UINTN GpioBaseAddress;
- - UINTN GpioPinCount;
- -} MV_SOC_GPIO_DESC;
- -
- EFI_STATUS
- EFIAPI
- -ArmadaSoCDescGpioGet (
- - IN OUT MV_SOC_GPIO_DESC **GpioDesc,
- - IN OUT UINTN *DescCount
- +ArmadaSoCGpioGet (
- + IN OUT GPIO_CONTROLLER **SoCGpioDescription,
- + IN OUT UINTN *Count
- );
- //
- diff --git a/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h b/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h
- index eaffce3..18de24f 100644
- --- a/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h
- +++ b/Silicon/Marvell/Include/Library/NonDiscoverableInitLib.h
- @@ -20,7 +20,7 @@
- NON_DISCOVERABLE_DEVICE_INIT
- EFIAPI
- -GetInitializerForType (
- +NonDiscoverableDeviceInitializerGet (
- IN NON_DISCOVERABLE_DEVICE_TYPE Type,
- IN UINTN Index
- );
- diff --git a/Silicon/Marvell/Include/Protocol/BoardDesc.h b/Silicon/Marvell/Include/Protocol/BoardDesc.h
- index e06d689..02905ea 100644
- --- a/Silicon/Marvell/Include/Protocol/BoardDesc.h
- +++ b/Silicon/Marvell/Include/Protocol/BoardDesc.h
- @@ -50,9 +50,9 @@ EFI_STATUS
- typedef
- EFI_STATUS
- -(EFIAPI *MV_BOARD_DESC_GPIO_GET) (
- - IN MARVELL_BOARD_DESC_PROTOCOL *This,
- - IN OUT MV_BOARD_GPIO_DESC **GpioDesc
- +(EFIAPI *MV_BOARD_GPIO_DESCRIPTION_GET) (
- + IN MARVELL_BOARD_DESC_PROTOCOL *This,
- + IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription
- );
- typedef
- @@ -113,7 +113,6 @@ VOID
- struct _MARVELL_BOARD_DESC_PROTOCOL {
- MV_BOARD_DESC_AHCI_GET BoardDescAhciGet;
- MV_BOARD_DESC_COMPHY_GET BoardDescComPhyGet;
- - MV_BOARD_DESC_GPIO_GET BoardDescGpioGet;
- MV_BOARD_DESC_I2C_GET BoardDescI2cGet;
- MV_BOARD_DESC_MDIO_GET BoardDescMdioGet;
- MV_BOARD_DESC_PP2_GET BoardDescPp2Get;
- @@ -121,6 +120,7 @@ struct _MARVELL_BOARD_DESC_PROTOCOL {
- MV_BOARD_DESC_UTMI_GET BoardDescUtmiGet;
- MV_BOARD_DESC_XHCI_GET BoardDescXhciGet;
- MV_BOARD_DESC_FREE BoardDescFree;
- + MV_BOARD_GPIO_DESCRIPTION_GET GpioDescriptionGet;
- };
- #endif // __MARVELL_BOARD_DESC_PROTOCOL_H__
- diff --git a/Silicon/Marvell/Include/Protocol/MvGpio.h b/Silicon/Marvell/Include/Protocol/MvGpio.h
- index a335cab..8bddd2f 100644
- --- a/Silicon/Marvell/Include/Protocol/MvGpio.h
- +++ b/Silicon/Marvell/Include/Protocol/MvGpio.h
- @@ -11,8 +11,8 @@
- * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- *
- **/
- -#ifndef __MARVELL_GPIO_PROTOCOL_H__
- -#define __MARVELL_GPIO_PROTOCOL_H__
- +#ifndef __MV_GPIO_PROTOCOL_H__
- +#define __MV_GPIO_PROTOCOL_H__
- #include <Uefi.h>
- @@ -21,19 +21,22 @@
- #include <Library/MemoryAllocationLib.h>
- #include <Library/UefiBootServicesTableLib.h>
- -extern EFI_GUID gMarvellGpioProtocolGuid;
- -
- -typedef struct _MARVELL_GPIO_PROTOCOL MARVELL_GPIO_PROTOCOL;
- +#include <Protocol/EmbeddedGpio.h>
- typedef enum {
- - GPIO_MODE_INPUT = 0x0,
- - GPIO_MODE_OUTPUT = 0x1
- -} MARVELL_GPIO_MODE;
- + MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER,
- + MV_GPIO_DRIVER_TYPE_PCA95X,
- +} MV_GPIO_DRIVER_TYPE;
- typedef enum {
- - GPIO_DRIVER_TYPE_SOC_CONTROLLER = 0x0,
- - GPIO_DRIVER_TYPE_PCA95XX = 0x1
- -} MARVELL_GPIO_DRIVER_TYPE;
- + MV_GPIO_AP806_CONTROLLER0,
- + MV_GPIO_CP0_CONTROLLER0,
- + MV_GPIO_CP0_CONTROLLER1,
- + MV_GPIO_CP1_CONTROLLER0,
- + MV_GPIO_CP1_CONTROLLER1,
- + MV_GPIO_CP2_CONTROLLER0,
- + MV_GPIO_CP2_CONTROLLER1,
- +} MV_GPIO_SOC_CONTROLLER_TYPE;
- typedef enum {
- PCA9505_ID,
- @@ -48,74 +51,64 @@ typedef enum {
- PCA9556_ID,
- PCA9557_ID,
- PCA95XX_MAX_ID,
- -} MARVELL_IO_EXPANDER_TYPE_PCA95XX;
- -
- -typedef
- -EFI_STATUS
- -(EFIAPI *MV_GPIO_DIRECTION_OUTPUT) (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- - );
- -
- -typedef
- -EFI_STATUS
- -(EFIAPI *MV_GPIO_DIRECTION_INPUT) (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin
- - );
- -
- -typedef
- -EFI_STATUS
- -(EFIAPI *MV_GPIO_GET_FUNCTION) (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - OUT MARVELL_GPIO_MODE *Mode
- - );
- -
- -typedef
- -EFI_STATUS
- -(EFIAPI *MV_GPIO_GET_VALUE) (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - OUT BOOLEAN *Value
- - );
- -
- -typedef
- -EFI_STATUS
- -(EFIAPI *MV_GPIO_SET_VALUE) (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- - );
- -
- -struct _MARVELL_GPIO_PROTOCOL {
- - MV_GPIO_DIRECTION_INPUT DirectionInput;
- - MV_GPIO_DIRECTION_OUTPUT DirectionOutput;
- - MV_GPIO_GET_FUNCTION GetFunction;
- - MV_GPIO_GET_VALUE GetValue;
- - MV_GPIO_SET_VALUE SetValue;
- -};
- +} MV_GPIO_EXPANDER_TYPE_PCA95XX;
- typedef struct {
- - VENDOR_DEVICE_PATH Header;
- - MARVELL_GPIO_DRIVER_TYPE GpioDriverType;
- - EFI_DEVICE_PATH_PROTOCOL End;
- + VENDOR_DEVICE_PATH Header;
- + MV_GPIO_DRIVER_TYPE GpioDriverType;
- + EFI_DEVICE_PATH_PROTOCOL End;
- } MV_GPIO_DEVICE_PATH;
- typedef struct {
- - UINTN ControllerId;
- - UINTN PinNumber;
- - BOOLEAN ActiveHigh;
- -} GPIO_PIN_DESC;
- + UINTN ControllerId;
- + UINTN PinNumber;
- + BOOLEAN ActiveHigh;
- +} MV_GPIO_PIN;
- /*
- - * Select desired protocol producer upon MARVELL_GPIO_DRIVER_TYPE
- + * Check if the driver type matches the requested value.
- + * In case of the success open the GPIO protocol and return.
- + */
- +STATIC
- +inline
- +EFI_STATUS
- +EFIAPI
- +MvGpioFindMatchingDriver (
- + IN MV_GPIO_DRIVER_TYPE GpioDriverType,
- + IN EFI_HANDLE HandleBuffer,
- + IN EFI_DEVICE_PATH *DevicePath,
- + IN OUT EMBEDDED_GPIO **GpioProtocol
- + )
- +{
- + MV_GPIO_DEVICE_PATH *GpioDevicePath;
- + EFI_STATUS Status;
- +
- + while (!IsDevicePathEndType (DevicePath)) {
- + /* Check if GpioDriverType matches one found in the device path */
- + GpioDevicePath = (MV_GPIO_DEVICE_PATH *)DevicePath;
- + if (GpioDevicePath->GpioDriverType != GpioDriverType) {
- + DevicePath = NextDevicePathNode (DevicePath);
- + continue;
- + }
- +
- + /*
- + * Open GpioProtocol. With EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute
- + * the consumer is not obliged to call CloseProtocol.
- + */
- + Status = gBS->OpenProtocol (HandleBuffer,
- + &gEmbeddedGpioProtocolGuid,
- + (VOID **)GpioProtocol,
- + gImageHandle,
- + NULL,
- + EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- + return Status;
- + }
- +
- + return EFI_NOT_FOUND;
- +}
- +
- +/*
- + * Select desired protocol producer upon MV_GPIO_DRIVER_TYPE
- * field of driver's MV_GPIO_DEVICE_PATH.
- */
- STATIC
- @@ -123,20 +116,19 @@ inline
- EFI_STATUS
- EFIAPI
- MvGpioGetProtocol (
- - IN MARVELL_GPIO_DRIVER_TYPE GpioDriverType,
- - IN OUT MARVELL_GPIO_PROTOCOL **GpioProtocol
- + IN MV_GPIO_DRIVER_TYPE GpioDriverType,
- + IN OUT EMBEDDED_GPIO **GpioProtocol
- )
- {
- - MV_GPIO_DEVICE_PATH *GpioDevicePath;
- EFI_DEVICE_PATH *DevicePath;
- EFI_HANDLE *HandleBuffer;
- EFI_STATUS Status;
- UINTN HandleCount;
- UINTN Index;
- - /* Locate Handles of all MARVELL_GPIO_PROTOCOL producers */
- + /* Locate Handles of all EMBEDDED_GPIO producers */
- Status = gBS->LocateHandleBuffer (ByProtocol,
- - &gMarvellGpioProtocolGuid,
- + &gEmbeddedGpioProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer);
- @@ -159,41 +151,32 @@ MvGpioGetProtocol (
- continue;
- }
- - while (!IsDevicePathEndType (DevicePath)) {
- - /* Check if GpioDriverType matches one found in the device path */
- - GpioDevicePath = (MV_GPIO_DEVICE_PATH *)DevicePath;
- - if (GpioDevicePath->GpioDriverType != GpioDriverType) {
- - DevicePath = NextDevicePathNode (DevicePath);
- - continue;
- - }
- -
- - /*
- - * Open GpioProtocol. With EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute
- - * the consumer is not obliged to call CloseProtocol.
- - */
- - Status = gBS->OpenProtocol (HandleBuffer[Index],
- - &gMarvellGpioProtocolGuid,
- - (VOID **)GpioProtocol,
- - gImageHandle,
- - NULL,
- - EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: Unable to open GPIO protocol\n",
- - __FUNCTION__));
- - gBS->FreePool (HandleBuffer);
- - return Status;
- - }
- -
- - gBS->FreePool (HandleBuffer);
- -
- - return EFI_SUCCESS;
- + /*
- + * Check if the driver type matches the requested value.
- + * In case of the success open the GPIO protocol and return.
- + * If there is no match, repeat procedure with the next handle.
- + */
- + Status = MvGpioFindMatchingDriver (GpioDriverType,
- + HandleBuffer[Index],
- + DevicePath,
- + GpioProtocol);
- + if (Status == EFI_NOT_FOUND) {
- + continue;
- + } else if (EFI_ERROR (Status)) {
- + DEBUG ((DEBUG_ERROR,
- + "%a: Unable to open GPIO protocol\n",
- + __FUNCTION__));
- }
- +
- + gBS->FreePool (HandleBuffer);
- +
- + return Status;
- }
- + /* No matching GPIO protocol producer was found */
- gBS->FreePool (HandleBuffer);
- - return EFI_UNSUPPORTED;
- + return EFI_NOT_FOUND;
- }
- -#endif // __MARVELL_GPIO_PROTOCOL_H__
- +#endif // __MV_GPIO_PROTOCOL_H__
- diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
- index 7d788fb..9595b01 100644
- --- a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
- +++ b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
- @@ -24,6 +24,29 @@
- #include <Protocol/MvGpio.h>
- //
- +// GPIO Expander
- +//
- +STATIC MV_GPIO_EXPANDER mGpioExpander = {
- + PCA9555_ID,
- + 0x21,
- + 0x0,
- +};
- +
- +
- +EFI_STATUS
- +EFIAPI
- +ArmadaBoardGpioExpanderGet (
- + IN OUT MV_GPIO_EXPANDER **GpioExpanders,
- + IN OUT UINTN *GpioExpanderCount
- + )
- +{
- + *GpioExpanderCount = 1;
- + *GpioExpanders = &mGpioExpander;
- +
- + return EFI_SUCCESS;
- +}
- +
- +//
- // Order of devices in SdMmcDescTemplate has to be in par with ArmadaSoCDescLib
- //
- STATIC
- @@ -48,12 +71,6 @@ MV_BOARD_SDMMC_DESC mSdMmcDescTemplate[] = {
- }
- };
- -STATIC MV_I2C_IO_EXPANDER_DESC mI2cIoExpanderDescTemplate = {
- - PCA9555_ID,
- - 0x21,
- - 0x0,
- -};
- -
- EFI_STATUS
- EFIAPI
- ArmadaBoardDescSdMmcGet (
- @@ -66,16 +83,3 @@ ArmadaBoardDescSdMmcGet (
- return EFI_SUCCESS;
- }
- -
- -EFI_STATUS
- -EFIAPI
- -ArmadaBoardDescGpioGet (
- - IN OUT MV_I2C_IO_EXPANDER_DESC **I2cIoExpanderDesc,
- - IN OUT UINTN *I2cIoExpanderCount
- - )
- -{
- - *I2cIoExpanderCount = 1;
- - *I2cIoExpanderDesc = &mI2cIoExpanderDescTemplate;
- -
- - return EFI_SUCCESS;
- -}
- diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- index a93576e..586b189 100644
- --- a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- +++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- @@ -25,13 +25,9 @@
- #include <Protocol/MvGpio.h>
- #include <Protocol/NonDiscoverableDevice.h>
- -#define ARMADA_70x0_DB_IO_EXPANDER0 0
- -#define ARMADA_70x0_DB_VBUS0_PIN 0
- -#define ARMADA_70x0_DB_VBUS0_LIMIT_PIN 4
- -#define ARMADA_70x0_DB_VBUS1_PIN 1
- -#define ARMADA_70x0_DB_VBUS1_LIMIT_PIN 5
- +#include "NonDiscoverableInitLib.h"
- -STATIC CONST GPIO_PIN_DESC mArmada70x0DbVbusEn[] = {
- +STATIC CONST MV_GPIO_PIN mXhciVbusPins[] = {
- {
- ARMADA_70x0_DB_IO_EXPANDER0,
- ARMADA_70x0_DB_VBUS0_PIN,
- @@ -57,28 +53,29 @@ STATIC CONST GPIO_PIN_DESC mArmada70x0DbVbusEn[] = {
- STATIC
- EFI_STATUS
- EFIAPI
- -Armada70x0DbInitXhciVbus (
- - IN NON_DISCOVERABLE_DEVICE *This
- +XhciInit (
- + IN NON_DISCOVERABLE_DEVICE *This
- )
- {
- - CONST GPIO_PIN_DESC *VbusEnPinDesc;
- - MARVELL_GPIO_PROTOCOL *GpioProtocol;
- - EFI_STATUS Status;
- - UINTN Index;
- + CONST MV_GPIO_PIN *VbusPin;
- + EMBEDDED_GPIO_MODE Mode;
- + EMBEDDED_GPIO_PIN Gpio;
- + EMBEDDED_GPIO *GpioProtocol;
- + EFI_STATUS Status;
- + UINTN Index;
- - Status = MvGpioGetProtocol (GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol);
- + Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__));
- return Status;
- }
- - VbusEnPinDesc = mArmada70x0DbVbusEn;
- - for (Index = 0; Index < ARRAY_SIZE (mArmada70x0DbVbusEn); Index++) {
- - GpioProtocol->DirectionOutput (GpioProtocol,
- - VbusEnPinDesc->ControllerId,
- - VbusEnPinDesc->PinNumber,
- - VbusEnPinDesc->ActiveHigh);
- - VbusEnPinDesc++;
- + VbusPin = mXhciVbusPins;
- + for (Index = 0; Index < ARRAY_SIZE (mXhciVbusPins); Index++) {
- + Mode = VbusPin->ActiveHigh ? GPIO_MODE_OUTPUT_1 : GPIO_MODE_OUTPUT_0;
- + Gpio = GPIO (VbusPin->ControllerId, VbusPin->PinNumber);
- + GpioProtocol->Set (GpioProtocol, Gpio, Mode);
- + VbusPin++;
- }
- return EFI_SUCCESS;
- @@ -86,13 +83,13 @@ Armada70x0DbInitXhciVbus (
- NON_DISCOVERABLE_DEVICE_INIT
- EFIAPI
- -GetInitializerForType (
- +NonDiscoverableDeviceInitializerGet (
- IN NON_DISCOVERABLE_DEVICE_TYPE Type,
- IN UINTN Index
- )
- {
- if (Type == NonDiscoverableDeviceTypeXhci) {
- - return Armada70x0DbInitXhciVbus;
- + return XhciInit;
- }
- return NULL;
- diff --git a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
- index ef6023f..a1ac4bf 100644
- --- a/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
- +++ b/Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c
- @@ -24,6 +24,35 @@
- #include <Protocol/MvGpio.h>
- //
- +// GPIO Expanders
- +//
- +STATIC MV_GPIO_EXPANDER mGpioExpanders[] = {
- + {
- + PCA9555_ID,
- + 0x21,
- + 0x0,
- + },
- + {
- + PCA9555_ID,
- + 0x25,
- + 0x0,
- + },
- +};
- +
- +EFI_STATUS
- +EFIAPI
- +ArmadaBoardGpioExpanderGet (
- + IN OUT MV_GPIO_EXPANDER **GpioExpanders,
- + IN OUT UINTN *GpioExpanderCount
- + )
- +{
- + *GpioExpanderCount = ARRAY_SIZE (mGpioExpanders);
- + *GpioExpanders = mGpioExpanders;
- +
- + return EFI_SUCCESS;
- +}
- +
- +//
- // Order of devices in SdMmcDescTemplate has to be in par with ArmadaSoCDescLib
- //
- STATIC
- @@ -48,19 +77,6 @@ MV_BOARD_SDMMC_DESC mSdMmcDescTemplate[] = {
- }
- };
- -STATIC MV_I2C_IO_EXPANDER_DESC mI2cIoExpanderDescTemplate[] = {
- - {
- - PCA9555_ID,
- - 0x21,
- - 0x0,
- - },
- - {
- - PCA9555_ID,
- - 0x25,
- - 0x0,
- - },
- -};
- -
- EFI_STATUS
- EFIAPI
- ArmadaBoardDescSdMmcGet (
- @@ -73,16 +89,3 @@ ArmadaBoardDescSdMmcGet (
- return EFI_SUCCESS;
- }
- -
- -EFI_STATUS
- -EFIAPI
- -ArmadaBoardDescGpioGet (
- - IN OUT MV_I2C_IO_EXPANDER_DESC **I2cIoExpanderDesc,
- - IN OUT UINTN *I2cIoExpanderCount
- - )
- -{
- - *I2cIoExpanderCount = ARRAY_SIZE (mI2cIoExpanderDescTemplate);
- - *I2cIoExpanderDesc = mI2cIoExpanderDescTemplate;
- -
- - return EFI_SUCCESS;
- -}
- diff --git a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- index 05f6b89..3988f9a 100644
- --- a/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- +++ b/Platform/Marvell/Armada80x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- @@ -25,17 +25,9 @@
- #include <Protocol/MvGpio.h>
- #include <Protocol/NonDiscoverableDevice.h>
- -#define ARMADA_80x0_DB_IO_EXPANDER0 0
- -#define ARMADA_80x0_DB_VBUS0_PIN 0
- -#define ARMADA_80x0_DB_VBUS0_LIMIT_PIN 4
- -#define ARMADA_80x0_DB_VBUS1_PIN 1
- -#define ARMADA_80x0_DB_VBUS1_LIMIT_PIN 5
- +#include "NonDiscoverableInitLib.h"
- -#define ARMADA_80x0_DB_IO_EXPANDER1 1
- -#define ARMADA_80x0_DB_VBUS2_PIN 0
- -#define ARMADA_80x0_DB_VBUS2_LIMIT_PIN 4
- -
- -STATIC CONST GPIO_PIN_DESC mArmada80x0DbVbusEn[] = {
- +STATIC CONST MV_GPIO_PIN mXhciVbusPins[] = {
- {
- ARMADA_80x0_DB_IO_EXPANDER0,
- ARMADA_80x0_DB_VBUS0_PIN,
- @@ -71,28 +63,29 @@ STATIC CONST GPIO_PIN_DESC mArmada80x0DbVbusEn[] = {
- STATIC
- EFI_STATUS
- EFIAPI
- -Armada80x0DbInitXhciVbus (
- - IN NON_DISCOVERABLE_DEVICE *This
- +XhciInit (
- + IN NON_DISCOVERABLE_DEVICE *This
- )
- {
- - CONST GPIO_PIN_DESC *VbusEnPinDesc;
- - MARVELL_GPIO_PROTOCOL *GpioProtocol;
- - EFI_STATUS Status;
- - UINTN Index;
- + CONST MV_GPIO_PIN *VbusPin;
- + EMBEDDED_GPIO_MODE Mode;
- + EMBEDDED_GPIO_PIN Gpio;
- + EMBEDDED_GPIO *GpioProtocol;
- + EFI_STATUS Status;
- + UINTN Index;
- - Status = MvGpioGetProtocol (GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol);
- + Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__));
- return Status;
- }
- - VbusEnPinDesc = mArmada80x0DbVbusEn;
- - for (Index = 0; Index < ARRAY_SIZE (mArmada80x0DbVbusEn); Index++) {
- - GpioProtocol->DirectionOutput (GpioProtocol,
- - VbusEnPinDesc->ControllerId,
- - VbusEnPinDesc->PinNumber,
- - VbusEnPinDesc->ActiveHigh);
- - VbusEnPinDesc++;
- + VbusPin = mXhciVbusPins;
- + for (Index = 0; Index < ARRAY_SIZE (mXhciVbusPins); Index++) {
- + Mode = VbusPin->ActiveHigh ? GPIO_MODE_OUTPUT_1 : GPIO_MODE_OUTPUT_0;
- + Gpio = GPIO (VbusPin->ControllerId, VbusPin->PinNumber);
- + GpioProtocol->Set (GpioProtocol, Gpio, Mode);
- + VbusPin++;
- }
- return EFI_SUCCESS;
- @@ -100,13 +93,13 @@ Armada80x0DbInitXhciVbus (
- NON_DISCOVERABLE_DEVICE_INIT
- EFIAPI
- -GetInitializerForType (
- +NonDiscoverableDeviceInitializerGet (
- IN NON_DISCOVERABLE_DEVICE_TYPE Type,
- IN UINTN Index
- )
- {
- if (Type == NonDiscoverableDeviceTypeXhci) {
- - return Armada80x0DbInitXhciVbus;
- + return XhciInit;
- }
- return NULL;
- diff --git a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
- index 3f4e404..32596ad 100644
- --- a/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
- +++ b/Platform/SolidRun/Armada80x0McBin/Armada80x0McBinBoardDescLib/Armada80x0McBinBoardDescLib.c
- @@ -22,6 +22,23 @@
- #include <Library/UefiBootServicesTableLib.h>
- //
- +// GPIO Expander
- +//
- +EFI_STATUS
- +EFIAPI
- +ArmadaBoardGpioExpanderGet (
- + IN OUT MV_GPIO_EXPANDER **GpioExpanders,
- + IN OUT UINTN *GpioExpanderCount
- + )
- +{
- + /* No GPIO expanders on board */
- + *GpioExpanders = NULL;
- + *GpioExpanderCount = 0;
- +
- + return EFI_SUCCESS;
- +}
- +
- +//
- // Order of devices in SdMmcDescTemplate has to be in par with ArmadaSoCDescLib
- //
- STATIC
- @@ -58,17 +75,3 @@ ArmadaBoardDescSdMmcGet (
- return EFI_SUCCESS;
- }
- -
- -EFI_STATUS
- -EFIAPI
- -ArmadaBoardDescGpioGet (
- - IN OUT MV_I2C_IO_EXPANDER_DESC **I2cIoExpanderDesc,
- - IN OUT UINTN *I2cIoExpanderCount
- - )
- -{
- - /* No I2C IO expanders on board */
- - *I2cIoExpanderDesc = NULL;
- - *I2cIoExpanderCount = 0;
- -
- - return EFI_SUCCESS;
- -}
- diff --git a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- index 764b3b8..676feeb 100644
- --- a/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- +++ b/Platform/SolidRun/Armada80x0McBin/NonDiscoverableInitLib/NonDiscoverableInitLib.c
- @@ -25,11 +25,10 @@
- #include <Protocol/MvGpio.h>
- #include <Protocol/NonDiscoverableDevice.h>
- -#define ARMADA_80x0_CP0_CONTROLLER1_INDEX 2
- -#define ARMADA_80x0_MCBIN_VBUS0_PIN 15
- +#include "NonDiscoverableInitLib.h"
- -STATIC CONST GPIO_PIN_DESC mArmada80x0McBinVbusEn = {
- - ARMADA_80x0_CP0_CONTROLLER1_INDEX,
- +STATIC CONST MV_GPIO_PIN mXhciVbusPin = {
- + MV_GPIO_CP0_CONTROLLER1,
- ARMADA_80x0_MCBIN_VBUS0_PIN,
- TRUE,
- };
- @@ -37,36 +36,35 @@ STATIC CONST GPIO_PIN_DESC mArmada80x0McBinVbusEn = {
- STATIC
- EFI_STATUS
- EFIAPI
- -Armada80x0McBinInitXhciVbus (
- - IN NON_DISCOVERABLE_DEVICE *This
- +XhciInit (
- + IN NON_DISCOVERABLE_DEVICE *This
- )
- {
- - MARVELL_GPIO_PROTOCOL *GpioProtocol;
- - EFI_STATUS Status;
- + EMBEDDED_GPIO *GpioProtocol;
- + EFI_STATUS Status;
- - Status = MvGpioGetProtocol (GPIO_DRIVER_TYPE_SOC_CONTROLLER, &GpioProtocol);
- + Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER, &GpioProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__));
- return Status;
- }
- - GpioProtocol->DirectionOutput (GpioProtocol,
- - mArmada80x0McBinVbusEn.ControllerId,
- - mArmada80x0McBinVbusEn.PinNumber,
- - mArmada80x0McBinVbusEn.ActiveHigh);
- + GpioProtocol->Set (GpioProtocol,
- + GPIO (mXhciVbusPin.ControllerId, mXhciVbusPin.PinNumber),
- + GPIO_MODE_OUTPUT_1);
- return Status;
- }
- NON_DISCOVERABLE_DEVICE_INIT
- EFIAPI
- -GetInitializerForType (
- +NonDiscoverableDeviceInitializerGet (
- IN NON_DISCOVERABLE_DEVICE_TYPE Type,
- IN UINTN Index
- )
- {
- if (Type == NonDiscoverableDeviceTypeXhci) {
- - return Armada80x0McBinInitXhciVbus;
- + return XhciInit;
- }
- return NULL;
- diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
- index 7db4ec7..5b72c20 100644
- --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
- +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
- @@ -74,37 +74,37 @@ ArmadaSoCDescCpBaseGet (
- EFI_STATUS
- EFIAPI
- -ArmadaSoCDescGpioGet (
- - IN OUT MV_SOC_GPIO_DESC **GpioDesc,
- - IN OUT UINTN *DescCount
- +ArmadaSoCGpioGet (
- + IN OUT GPIO_CONTROLLER **SoCGpioDescription,
- + IN OUT UINTN *Count
- )
- {
- - MV_SOC_GPIO_DESC *Desc;
- + GPIO_CONTROLLER *GpioInstance;
- UINTN CpCount, CpIndex, Index;
- CpCount = FixedPcdGet8 (PcdMaxCpCount);
- - *DescCount = CpCount * MV_SOC_GPIO_PER_CP_COUNT + MV_SOC_AP_COUNT;
- - Desc = AllocateZeroPool (*DescCount * sizeof (MV_SOC_GPIO_DESC));
- - if (Desc == NULL) {
- + *Count = CpCount * MV_SOC_GPIO_PER_CP_COUNT + MV_SOC_AP806_COUNT;
- + GpioInstance = AllocateZeroPool (*Count * sizeof (GPIO_CONTROLLER));
- + if (GpioInstance == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__));
- return EFI_OUT_OF_RESOURCES;
- }
- - *GpioDesc = Desc;
- + *SoCGpioDescription = GpioInstance;
- - /* AP GPIO controller */
- - Desc->GpioBaseAddress = MV_SOC_AP_GPIO_BASE;
- - Desc->GpioPinCount = MV_SOC_AP_GPIO_PIN_COUNT;
- - Desc++;
- + /* AP806 GPIO controller */
- + GpioInstance->RegisterBase = MV_SOC_AP806_GPIO_BASE;
- + GpioInstance->InternalGpioCount = MV_SOC_AP806_GPIO_PIN_COUNT;
- + GpioInstance++;
- - /* CP GPIO controllers */
- + /* CP110 GPIO controllers */
- for (CpIndex = 0; CpIndex < CpCount; CpIndex++) {
- for (Index = 0; Index < MV_SOC_GPIO_PER_CP_COUNT; Index++) {
- - Desc->GpioBaseAddress = MV_SOC_CP_BASE (CpIndex) +
- - MV_SOC_CP_GPIO_BASE (Index);
- - Desc->GpioPinCount = MV_SOC_CP_GPIO_PIN_COUNT (Index);
- - Desc++;
- + GpioInstance->RegisterBase = MV_SOC_CP_BASE (CpIndex) +
- + MV_SOC_CP_GPIO_BASE (Index);
- + GpioInstance->InternalGpioCount = MV_SOC_CP_GPIO_PIN_COUNT (Index);
- + GpioInstance++;
- }
- }
- diff --git a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
- index c5305b7..e348b85 100644
- --- a/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
- +++ b/Silicon/Marvell/Drivers/BoardDesc/MvBoardDescDxe.c
- @@ -100,47 +100,42 @@ MvBoardDescComPhyGet (
- STATIC
- EFI_STATUS
- -MvBoardDescGpioGet (
- - IN MARVELL_BOARD_DESC_PROTOCOL *This,
- - IN OUT MV_BOARD_GPIO_DESC **GpioDesc
- +MvBoardGpioDescriptionGet (
- + IN MARVELL_BOARD_DESC_PROTOCOL *This,
- + IN OUT MV_BOARD_GPIO_DESCRIPTION **GpioDescription
- )
- {
- - MV_I2C_IO_EXPANDER_DESC *I2cIoExpanderDesc;
- - UINTN SoCGpioCount, I2cIoExpanderCount;
- - STATIC MV_BOARD_GPIO_DESC *BoardDesc;
- - MV_SOC_GPIO_DESC *SoCDesc;
- + MV_BOARD_GPIO_DESCRIPTION *Description;
- + UINTN SoCGpioCount, GpioExpanderCount;
- + MV_GPIO_EXPANDER *GpioExpanders;
- + GPIO_CONTROLLER *SoCGpio;
- EFI_STATUS Status;
- - if (BoardDesc != NULL) {
- - *GpioDesc = BoardDesc;
- - return EFI_SUCCESS;
- - }
- -
- /* Get SoC data about all available GPIO controllers */
- - Status = ArmadaSoCDescGpioGet (&SoCDesc, &SoCGpioCount);
- + Status = ArmadaSoCGpioGet (&SoCGpio, &SoCGpioCount);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- /* Get per-board information about all available I2C IO expanders */
- - Status = ArmadaBoardDescGpioGet (&I2cIoExpanderDesc, &I2cIoExpanderCount);
- + Status = ArmadaBoardGpioExpanderGet (&GpioExpanders, &GpioExpanderCount);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- /* Allocate and fill board description */
- - BoardDesc = AllocateZeroPool (sizeof (MV_BOARD_GPIO_DESC));
- - if (BoardDesc == NULL) {
- + Description = AllocateZeroPool (sizeof (MV_BOARD_GPIO_DESCRIPTION));
- + if (Description == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__));
- return EFI_OUT_OF_RESOURCES;
- }
- - BoardDesc->SoC = SoCDesc;
- - BoardDesc->GpioDevCount = SoCGpioCount;
- - BoardDesc->I2cIoExpanderDesc = I2cIoExpanderDesc;
- - BoardDesc->I2cIoExpanderCount = I2cIoExpanderCount;
- + Description->SoCGpio = SoCGpio;
- + Description->GpioDeviceCount = SoCGpioCount;
- + Description->GpioExpanders = GpioExpanders;
- + Description->GpioExpanderCount = GpioExpanderCount;
- - *GpioDesc = BoardDesc;
- + *GpioDescription = Description;
- return EFI_SUCCESS;
- }
- @@ -611,7 +606,6 @@ MvBoardDescInitProtocol (
- {
- BoardDescProtocol->BoardDescAhciGet = MvBoardDescAhciGet;
- BoardDescProtocol->BoardDescComPhyGet = MvBoardDescComPhyGet;
- - BoardDescProtocol->BoardDescGpioGet = MvBoardDescGpioGet;
- BoardDescProtocol->BoardDescI2cGet = MvBoardDescI2cGet;
- BoardDescProtocol->BoardDescMdioGet = MvBoardDescMdioGet;
- BoardDescProtocol->BoardDescPp2Get = MvBoardDescPp2Get;
- @@ -619,6 +613,7 @@ MvBoardDescInitProtocol (
- BoardDescProtocol->BoardDescUtmiGet = MvBoardDescUtmiGet;
- BoardDescProtocol->BoardDescXhciGet = MvBoardDescXhciGet;
- BoardDescProtocol->BoardDescFree = MvBoardDescFree;
- + BoardDescProtocol->GpioDescriptionGet = MvBoardGpioDescriptionGet;
- return EFI_SUCCESS;
- }
- diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c
- index fc2d416..4d5e530 100644
- --- a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c
- +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c
- @@ -16,21 +16,21 @@
- STATIC MV_GPIO *mGpioInstance;
- -STATIC MV_GPIO_DEVICE_PATH mGpioDevicePathTemplate = {
- +STATIC MV_GPIO_DEVICE_PATH mDevicePathTemplate = {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8) (sizeof (VENDOR_DEVICE_PATH) +
- - sizeof (MARVELL_GPIO_DRIVER_TYPE)),
- + sizeof (MV_GPIO_DRIVER_TYPE)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH) +
- - sizeof (MARVELL_GPIO_DRIVER_TYPE)) >> 8),
- + sizeof (MV_GPIO_DRIVER_TYPE)) >> 8),
- },
- },
- EFI_CALLER_ID_GUID
- },
- - GPIO_DRIVER_TYPE_SOC_CONTROLLER,
- + MV_GPIO_DRIVER_TYPE_SOC_CONTROLLER,
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- @@ -41,14 +41,32 @@ STATIC MV_GPIO_DEVICE_PATH mGpioDevicePathTemplate = {
- }
- };
- +#if !defined(MDEPKG_NDEBUG)
- +/**
- +
- +Routine Description:
- +
- + Verifies if controller index / GPIO pin values
- + are within proper boundaries.
- +
- +Arguments:
- +
- + ControllerIndex - index of controller
- + GpioPin - which pin to read
- +
- +Returns:
- +
- + EFI_SUCCESS - GPIO pin / controller index are proper
- + EFI_INVALID_PARAMETER - GPIO pin / controller index is out of range
- +**/
- STATIC
- EFI_STATUS
- MvGpioValidate (
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin
- + IN UINTN ControllerIndex,
- + IN UINTN GpioPin
- )
- {
- - if (ControllerIndex >= mGpioInstance->Desc->GpioDevCount) {
- + if (ControllerIndex >= mGpioInstance->GpioDeviceCount) {
- DEBUG ((DEBUG_ERROR,
- "%a: Invalid GPIO ControllerIndex: %d\n",
- __FUNCTION__,
- @@ -56,7 +74,7 @@ MvGpioValidate (
- return EFI_INVALID_PARAMETER;
- }
- - if (GpioPin >= mGpioInstance->Desc->SoC[ControllerIndex].GpioPinCount) {
- + if (GpioPin >= mGpioInstance->SoCGpio[ControllerIndex].InternalGpioCount) {
- DEBUG ((DEBUG_ERROR,
- "%a: GPIO pin #%d not available in Controller#%d\n",
- __FUNCTION__,
- @@ -67,165 +85,200 @@ MvGpioValidate (
- return EFI_SUCCESS;
- }
- +#endif
- -STATIC
- -EFI_STATUS
- -MvGpioDirectionOutput (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- - )
- -{
- - UINTN BaseAddress;
- - EFI_STATUS Status;
- +/**
- - Status = MvGpioValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: Fail to set output for pin #%d\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- +Routine Description:
- - BaseAddress = mGpioInstance->Desc->SoC[ControllerIndex].GpioBaseAddress;
- + Gets the mode (function) of a GPIO pin
- - MmioAndThenOr32 (BaseAddress + GPIO_DATA_OUT_REG,
- - ~BIT (GpioPin),
- - (Value) << GpioPin);
- +Arguments:
- - MmioAnd32 (BaseAddress + GPIO_OUT_EN_REG, ~BIT (GpioPin));
- + This - pointer to protocol
- + Gpio - which pin
- + Mode - pointer to output mode value
- - return EFI_SUCCESS;
- -}
- +Returns:
- + EFI_SUCCESS - mode value retrieved
- + EFI_INVALID_PARAMETER - Mode is a null pointer or Gpio pin is out of range
- +
- +**/
- STATIC
- EFI_STATUS
- -MvGpioDirectionInput (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin
- +MvGpioGetMode (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + OUT EMBEDDED_GPIO_MODE *Mode
- )
- {
- + UINTN ControllerIndex;
- UINTN BaseAddress;
- - EFI_STATUS Status;
- + UINTN GpioPin;
- - Status = MvGpioValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: Fail to set input for pin #%d\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + GpioPin = GPIO_PIN (Gpio);
- + ControllerIndex = GPIO_PORT (Gpio);
- +
- + ASSERT_EFI_ERROR (MvGpioValidate (ControllerIndex, GpioPin));
- - BaseAddress = mGpioInstance->Desc->SoC[ControllerIndex].GpioBaseAddress;
- + BaseAddress = mGpioInstance->SoCGpio[ControllerIndex].RegisterBase;
- - MmioOr32 (BaseAddress + GPIO_OUT_EN_REG, BIT (GpioPin));
- + if (MmioRead32 (BaseAddress + MV_GPIO_OUT_EN_REG) & (1 << GpioPin)) {
- + *Mode = GPIO_MODE_INPUT;
- + } else {
- + if (MmioRead32 (BaseAddress + MV_GPIO_DATA_IN_REG) & (1 << GpioPin)) {
- + *Mode = GPIO_MODE_OUTPUT_1;
- + } else {
- + *Mode = GPIO_MODE_OUTPUT_0;
- + }
- + }
- return EFI_SUCCESS;
- }
- +/**
- +
- +Routine Description:
- +
- + Gets the state of a GPIO pin
- +
- +Arguments:
- +
- + This - pointer to protocol
- + Gpio - which pin to read
- + Value - state of the pin
- +
- +Returns:
- +
- + EFI_SUCCESS - GPIO state returned in Value
- + EFI_INVALID_PARAMETER - Value is NULL pointer or Gpio pin is out of range
- +**/
- STATIC
- EFI_STATUS
- -MvGpioGetFunction (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - OUT MARVELL_GPIO_MODE *Mode
- +MvGpioGet (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + OUT UINTN *Value
- )
- {
- - UINT32 RegVal;
- + UINTN ControllerIndex;
- UINTN BaseAddress;
- - EFI_STATUS Status;
- + UINTN GpioPin;
- - Status = MvGpioValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: Fail to get function of pin #%d\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + GpioPin = GPIO_PIN (Gpio);
- + ControllerIndex = GPIO_PORT (Gpio);
- - BaseAddress = mGpioInstance->Desc->SoC[ControllerIndex].GpioBaseAddress;
- + ASSERT_EFI_ERROR (MvGpioValidate (ControllerIndex, GpioPin));
- - RegVal = MmioRead32 (BaseAddress + GPIO_OUT_EN_REG);
- - *Mode = ((RegVal & BIT (GpioPin)) ? GPIO_MODE_INPUT : GPIO_MODE_OUTPUT);
- + BaseAddress = mGpioInstance->SoCGpio[ControllerIndex].RegisterBase;
- +
- + if (MmioRead32 (BaseAddress + MV_GPIO_DATA_IN_REG) & (1 << GpioPin)) {
- + *Value = 1;
- + } else {
- + *Value = 0;
- + }
- return EFI_SUCCESS;
- }
- +/**
- +
- +Routine Description:
- +
- + Sets the state of a GPIO pin
- +
- +Arguments:
- +
- + This - pointer to protocol
- + Gpio - which pin to modify
- + Mode - mode to set
- +
- +Returns:
- +
- + EFI_SUCCESS - GPIO set as requested
- + EFI_UNSUPPORTED - Mode is not supported
- + EFI_INVALID_PARAMETER - Gpio pin is out of range
- +**/
- STATIC
- EFI_STATUS
- -MvGpioGetValue (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN OUT BOOLEAN *Value
- +MvGpioSet (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + IN EMBEDDED_GPIO_MODE Mode
- )
- {
- + UINTN ControllerIndex;
- UINTN BaseAddress;
- - EFI_STATUS Status;
- + UINTN GpioPin;
- - Status = MvGpioValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: Fail to get value of pin #%d\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + GpioPin = GPIO_PIN (Gpio);
- + ControllerIndex = GPIO_PORT (Gpio);
- +
- + ASSERT_EFI_ERROR (MvGpioValidate (ControllerIndex, GpioPin));
- +
- + BaseAddress = mGpioInstance->SoCGpio[ControllerIndex].RegisterBase;
- - BaseAddress = mGpioInstance->Desc->SoC[ControllerIndex].GpioBaseAddress;
- + switch (Mode) {
- + case GPIO_MODE_OUTPUT_0:
- + MmioAnd32 (BaseAddress + MV_GPIO_DATA_OUT_REG, ~(1 << GpioPin));
- + MmioAnd32 (BaseAddress + MV_GPIO_OUT_EN_REG, ~(1 << GpioPin));
- + break;
- - *Value = !!(MmioRead32 (BaseAddress + GPIO_DATA_IN_REG) & BIT (GpioPin));
- + case GPIO_MODE_OUTPUT_1:
- + MmioOr32 (BaseAddress + MV_GPIO_DATA_OUT_REG, (1 << GpioPin));
- + MmioAnd32 (BaseAddress + MV_GPIO_OUT_EN_REG, ~(1 << GpioPin));
- + break;
- + case GPIO_MODE_INPUT:
- + MmioOr32 (BaseAddress + MV_GPIO_OUT_EN_REG, (1 << GpioPin));
- + break;
- +
- + default:
- + return EFI_UNSUPPORTED;
- + }
- +
- return EFI_SUCCESS;
- }
- -STATIC
- -EFI_STATUS
- -MvGpioSetValue (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- - )
- -{
- - UINTN BaseAddress;
- - EFI_STATUS Status;
- +/**
- - Status = MvGpioValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: Fail to get value of pin #%d\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- +Routine Description:
- - BaseAddress = mGpioInstance->Desc->SoC[ControllerIndex].GpioBaseAddress;
- + Sets the pull-up / pull-down resistor of a GPIO pin
- - MmioAndThenOr32 (BaseAddress + GPIO_DATA_OUT_REG,
- - ~BIT (GpioPin),
- - Value << GpioPin);
- +Arguments:
- - return EFI_SUCCESS;
- + This - pointer to protocol
- + Gpio - which pin
- + Direction - pull-up, pull-down, or none
- +
- +Returns:
- +
- + EFI_UNSUPPORTED - Can not perform the requested operation
- +
- +**/
- +EFI_STATUS
- +EFIAPI
- +MvGpioSetPull (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + IN EMBEDDED_GPIO_PULL Direction
- + )
- +{
- + return EFI_UNSUPPORTED;
- }
- STATIC
- VOID
- MvGpioInitProtocol (
- - IN MARVELL_GPIO_PROTOCOL *GpioProtocol
- + IN EMBEDDED_GPIO *GpioProtocol
- )
- {
- - GpioProtocol->DirectionInput = MvGpioDirectionInput;
- - GpioProtocol->DirectionOutput = MvGpioDirectionOutput;
- - GpioProtocol->GetFunction = MvGpioGetFunction;
- - GpioProtocol->GetValue = MvGpioGetValue;
- - GpioProtocol->SetValue = MvGpioSetValue;
- + GpioProtocol->Get = MvGpioGet;
- + GpioProtocol->Set = MvGpioSet;
- + GpioProtocol->GetMode = MvGpioGetMode;
- + GpioProtocol->SetPull = MvGpioSetPull;
- }
- EFI_STATUS
- @@ -235,13 +288,13 @@ MvGpioEntryPoint (
- IN EFI_SYSTEM_TABLE *SystemTable
- )
- {
- - MARVELL_BOARD_DESC_PROTOCOL *BoardDescProtocol;
- + MARVELL_BOARD_DESC_PROTOCOL *MvBoardProtocol;
- + MV_BOARD_GPIO_DESCRIPTION *GpioDescription;
- MV_GPIO_DEVICE_PATH *GpioDevicePath;
- - MV_BOARD_GPIO_DESC *Desc;
- EFI_STATUS Status;
- GpioDevicePath = AllocateCopyPool (sizeof (MV_GPIO_DEVICE_PATH),
- - &mGpioDevicePathTemplate);
- + &mDevicePathTemplate);
- if (GpioDevicePath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- @@ -255,7 +308,7 @@ MvGpioEntryPoint (
- /* Obtain list of available controllers */
- Status = gBS->LocateProtocol (&gMarvellBoardDescProtocolGuid,
- NULL,
- - (VOID **)&BoardDescProtocol);
- + (VOID **)&MvBoardProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: Cannot locate BoardDesc protocol\n",
- @@ -263,7 +316,8 @@ MvGpioEntryPoint (
- goto ErrLocateBoardDesc;
- }
- - Status = BoardDescProtocol->BoardDescGpioGet (BoardDescProtocol, &Desc);
- + Status = MvBoardProtocol->GpioDescriptionGet (MvBoardProtocol,
- + &GpioDescription);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: Cannot get GPIO board desc from BoardDesc protocol\n",
- @@ -271,23 +325,43 @@ MvGpioEntryPoint (
- goto ErrLocateBoardDesc;
- }
- - mGpioInstance->Signature = GPIO_SIGNATURE;
- - mGpioInstance->Desc = Desc;
- + mGpioInstance->Signature = MV_GPIO_SIGNATURE;
- + mGpioInstance->GpioDeviceCount = GpioDescription->GpioDeviceCount;
- + mGpioInstance->SoCGpio = AllocateCopyPool (sizeof (GPIO_CONTROLLER) *
- + GpioDescription->GpioDeviceCount,
- + GpioDescription->SoCGpio);
- + if (mGpioInstance->SoCGpio == NULL) {
- + DEBUG ((DEBUG_ERROR,
- + "%a: Fail to copy GPIO SoC controllers description\n",
- + __FUNCTION__));
- + Status = EFI_OUT_OF_RESOURCES;
- + goto ErrAllocateSoCGpio;
- + }
- MvGpioInitProtocol (&mGpioInstance->GpioProtocol);
- Status = gBS->InstallMultipleProtocolInterfaces (&(mGpioInstance->Handle),
- - &gMarvellGpioProtocolGuid,
- + &gEmbeddedGpioProtocolGuid,
- &(mGpioInstance->GpioProtocol),
- &gEfiDevicePathProtocolGuid,
- (EFI_DEVICE_PATH_PROTOCOL *)GpioDevicePath,
- NULL);
- if (EFI_ERROR (Status)) {
- - goto ErrLocateBoardDesc;
- + goto ErrInstallProtocols;
- }
- + gBS->FreePool (GpioDescription->SoCGpio);
- + gBS->FreePool (GpioDescription);
- +
- return EFI_SUCCESS;
- +ErrInstallProtocols:
- + gBS->FreePool (mGpioInstance->SoCGpio);
- +
- +ErrAllocateSoCGpio:
- + gBS->FreePool (GpioDescription->SoCGpio);
- + gBS->FreePool (GpioDescription);
- +
- ErrLocateBoardDesc:
- gBS->FreePool (mGpioInstance);
- diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c
- index f4a474e..37c2b27 100644
- --- a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c
- +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c
- @@ -20,21 +20,21 @@
- STATIC PCA95XX *mPca95xxInstance;
- -STATIC MV_GPIO_DEVICE_PATH mPca95xxDevicePathTemplate = {
- +STATIC MV_GPIO_DEVICE_PATH mDevicePathTemplate = {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8) (sizeof (VENDOR_DEVICE_PATH) +
- - sizeof (MARVELL_GPIO_DRIVER_TYPE)),
- + sizeof (MV_GPIO_DRIVER_TYPE)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH) +
- - sizeof (MARVELL_GPIO_DRIVER_TYPE)) >> 8),
- + sizeof (MV_GPIO_DRIVER_TYPE)) >> 8),
- },
- },
- EFI_CALLER_ID_GUID
- },
- - GPIO_DRIVER_TYPE_PCA95XX,
- + MV_GPIO_DRIVER_TYPE_PCA95XX,
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- @@ -59,6 +59,24 @@ STATIC PCA95XX_PIN_COUNT mPca95xxPinCount[PCA95XX_MAX_ID] = {
- PCA9557_PIN_COUNT,
- };
- +#if !defined(MDEPKG_NDEBUG)
- +/**
- +
- +Routine Description:
- +
- + Verifies if controller index / GPIO pin values
- + are within proper boundaries.
- +
- +Arguments:
- +
- + ControllerIndex - index of controller
- + GpioPin - which pin to read
- +
- +Returns:
- +
- + EFI_SUCCESS - GPIO pin / controller index are proper
- + EFI_INVALID_PARAMETER - GPIO pin / controller index is out of range
- +**/
- STATIC
- EFI_STATUS
- MvPca95xxValidate (
- @@ -68,7 +86,7 @@ MvPca95xxValidate (
- {
- UINTN ControllerId;
- - if (ControllerIndex >= mPca95xxInstance->ControllerCount) {
- + if (ControllerIndex >= mPca95xxInstance->GpioExpanderCount) {
- DEBUG ((DEBUG_ERROR,
- "%a: Invalid GPIO ControllerIndex: %d\n",
- __FUNCTION__,
- @@ -76,7 +94,7 @@ MvPca95xxValidate (
- return EFI_INVALID_PARAMETER;
- }
- - ControllerId = mPca95xxInstance->ControllerDesc[ControllerIndex].ChipId;
- + ControllerId = mPca95xxInstance->GpioExpanders[ControllerIndex].ChipId;
- if (GpioPin >= mPca95xxPinCount[ControllerId]) {
- DEBUG ((DEBUG_ERROR,
- @@ -89,6 +107,7 @@ MvPca95xxValidate (
- return EFI_SUCCESS;
- }
- +#endif
- EFI_STATUS
- EFIAPI
- @@ -102,8 +121,8 @@ MvPca95xxGetI2c (
- EFI_HANDLE *HandleBuffer;
- EFI_STATUS Status;
- - I2cBus = mPca95xxInstance->ControllerDesc[ControllerIndex].I2cBus;
- - I2cAddress = mPca95xxInstance->ControllerDesc[ControllerIndex].I2cAddress;
- + I2cBus = mPca95xxInstance->GpioExpanders[ControllerIndex].I2cBus;
- + I2cAddress = mPca95xxInstance->GpioExpanders[ControllerIndex].I2cAddress;
- /* Locate Handles of all EfiI2cIoProtocol producers */
- Status = gBS->LocateHandleBuffer (ByProtocol,
- @@ -146,7 +165,7 @@ MvPca95xxI2cTransfer (
- IN EFI_I2C_IO_PROTOCOL *I2cIo,
- IN UINT8 Address,
- IN UINT8 *Buffer,
- - IN PCA95XX_OPERATION Operation
- + IN UINT32 Flag
- )
- {
- EFI_I2C_REQUEST_PACKET *RequestPacket;
- @@ -168,8 +187,7 @@ MvPca95xxI2cTransfer (
- RequestPacket->Operation[0].Buffer[0] = Address & MAX_UINT8;
- RequestPacket->Operation[1].LengthInBytes = PCA95XX_OPERATION_LENGTH;
- RequestPacket->Operation[1].Buffer = Buffer;
- - RequestPacket->Operation[1].Flags = (Operation == PCA95XX_READ ?
- - I2C_FLAG_READ : I2C_FLAG_NORESTART);
- + RequestPacket->Operation[1].Flags = Flag;
- Status = I2cIo->QueueRequest (I2cIo, 0, NULL, RequestPacket, NULL);
- if (EFI_ERROR (Status)) {
- @@ -192,7 +210,7 @@ MvPca95xxReadRegs (
- OUT UINT8 *RegVal
- )
- {
- - return MvPca95xxI2cTransfer (I2cIo, Reg, RegVal, PCA95XX_READ);
- + return MvPca95xxI2cTransfer (I2cIo, Reg, RegVal, I2C_FLAG_READ);
- }
- STATIC
- @@ -203,15 +221,15 @@ MvPca95xxWriteRegs (
- IN UINT8 RegVal
- )
- {
- - return MvPca95xxI2cTransfer (I2cIo, Reg, &RegVal, PCA95XX_WRITE);
- + return MvPca95xxI2cTransfer (I2cIo, Reg, &RegVal, I2C_FLAG_NORESTART);
- }
- STATIC
- EFI_STATUS
- MvPca95xxSetOutputValue (
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- + IN UINTN ControllerIndex,
- + IN UINTN GpioPin,
- + IN EMBEDDED_GPIO_MODE Mode
- )
- {
- EFI_I2C_IO_PROTOCOL *I2cIo;
- @@ -233,10 +251,10 @@ MvPca95xxSetOutputValue (
- return EFI_DEVICE_ERROR;
- }
- - if (Value) {
- - RegVal |= BIT (GpioPin % PCA95XX_BANK_SIZE);
- + if (Mode == GPIO_MODE_OUTPUT_1) {
- + RegVal |= (1 << (GpioPin % PCA95XX_BANK_SIZE));
- } else {
- - RegVal &= ~BIT (GpioPin % PCA95XX_BANK_SIZE);
- + RegVal &= ~(1 << (GpioPin % PCA95XX_BANK_SIZE));
- }
- Status = MvPca95xxWriteRegs (I2cIo, PCA95XX_OUTPUT_REG + Bank, RegVal);
- @@ -251,9 +269,9 @@ MvPca95xxSetOutputValue (
- STATIC
- EFI_STATUS
- MvPca95xxSetDirection (
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN MARVELL_GPIO_MODE Direction
- + IN UINTN ControllerIndex,
- + IN UINTN GpioPin,
- + IN EMBEDDED_GPIO_MODE Mode
- )
- {
- EFI_I2C_IO_PROTOCOL *I2cIo;
- @@ -275,10 +293,10 @@ MvPca95xxSetDirection (
- return Status;
- }
- - if (Direction == GPIO_MODE_INPUT) {
- - RegVal |= BIT (GpioPin % PCA95XX_BANK_SIZE);
- + if (Mode == GPIO_MODE_INPUT) {
- + RegVal |= (1 << (GpioPin % PCA95XX_BANK_SIZE));
- } else {
- - RegVal &= ~BIT (GpioPin % PCA95XX_BANK_SIZE);
- + RegVal &= ~(1 << (GpioPin % PCA95XX_BANK_SIZE));
- }
- Status = MvPca95xxWriteRegs (I2cIo, PCA95XX_DIRECTION_REG + Bank, RegVal);
- @@ -292,10 +310,10 @@ MvPca95xxSetDirection (
- STATIC
- EFI_STATUS
- -MvPca95xxIsOutput (
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - OUT MARVELL_GPIO_MODE *Mode
- +MvPca95xxReadMode (
- + IN UINTN ControllerIndex,
- + IN UINTN GpioPin,
- + OUT EMBEDDED_GPIO_MODE *Mode
- )
- {
- EFI_I2C_IO_PROTOCOL *I2cIo;
- @@ -303,14 +321,7 @@ MvPca95xxIsOutput (
- UINT8 RegVal;
- UINTN Bank;
- - Status = MvPca95xxValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: invalid pin/controller data\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + ASSERT_EFI_ERROR (MvPca95xxValidate (ControllerIndex, GpioPin));
- Status = MvPca95xxGetI2c (ControllerIndex, &I2cIo);
- if (EFI_ERROR (Status)) {
- @@ -326,97 +337,61 @@ MvPca95xxIsOutput (
- return Status;
- }
- - *Mode = ((RegVal & BIT (GpioPin % PCA95XX_BANK_SIZE)) ?
- - GPIO_MODE_INPUT : GPIO_MODE_OUTPUT);
- + if (RegVal & (1 << (GpioPin % PCA95XX_BANK_SIZE))) {
- + *Mode = GPIO_MODE_INPUT;
- + } else {
- + Status = MvPca95xxReadRegs (I2cIo, PCA95XX_INPUT_REG + Bank, &RegVal);
- + if (EFI_ERROR (Status)) {
- + DEBUG ((DEBUG_ERROR, "%a: fail to read device register\n", __FUNCTION__));
- + return Status;
- + }
- +
- + if (RegVal & (1 << (GpioPin % PCA95XX_BANK_SIZE))) {
- + *Mode = GPIO_MODE_OUTPUT_1;
- + } else {
- + *Mode = GPIO_MODE_OUTPUT_0;
- + }
- + }
- return EFI_SUCCESS;
- }
- -STATIC
- -EFI_STATUS
- -MvPca95xxDirectionOutput (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- - )
- -{
- - EFI_STATUS Status;
- -
- - Status = MvPca95xxValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: invalid pin/controller data\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- -
- - /* Configure output value. */
- - Status = MvPca95xxSetOutputValue (ControllerIndex, GpioPin, Value);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR, "%a: fail to set ouput value\n", __FUNCTION__));
- - return EFI_DEVICE_ERROR;
- - }
- +/**
- - /* Configure direction as output. */
- - Status = MvPca95xxSetDirection (ControllerIndex, GpioPin, GPIO_MODE_OUTPUT);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR, "%a: fail to set direction\n", __FUNCTION__));
- - }
- +Routine Description:
- - return Status;
- -}
- + Gets the mode (function) of a GPIO pin
- -STATIC
- -EFI_STATUS
- -MvPca95xxDirectionInput (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin
- - )
- -{
- - EFI_STATUS Status;
- +Arguments:
- - Status = MvPca95xxValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: invalid pin/controller data\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + This - pointer to protocol
- + Gpio - which pin
- + Mode - pointer to output mode value
- - /* Configure direction as input. */
- - Status = MvPca95xxSetDirection (ControllerIndex, GpioPin, GPIO_MODE_INPUT);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR, "%a: fail to set direction\n", __FUNCTION__));
- - }
- +Returns:
- - return Status;
- -}
- + EFI_SUCCESS - mode value retrieved
- + EFI_INVALID_PARAMETER - Mode is a null pointer or Gpio pin is out of range
- +**/
- STATIC
- EFI_STATUS
- -MvPca95xxGetFunction (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - OUT MARVELL_GPIO_MODE *Mode
- +MvPca95xxGetMode (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + OUT EMBEDDED_GPIO_MODE *Mode
- )
- {
- EFI_STATUS Status;
- + UINTN ControllerIndex;
- + UINTN GpioPin;
- - Status = MvPca95xxValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: invalid pin/controller data\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + GpioPin = GPIO_PIN (Gpio);
- + ControllerIndex = GPIO_PORT (Gpio);
- - Status = MvPca95xxIsOutput (ControllerIndex, GpioPin, Mode);
- + ASSERT_EFI_ERROR (MvPca95xxValidate (ControllerIndex, GpioPin));
- +
- + Status = MvPca95xxReadMode (ControllerIndex, GpioPin, Mode);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: fail to get pin %d of controller#%d mode\n",
- @@ -428,28 +403,42 @@ MvPca95xxGetFunction (
- return Status;
- }
- +/**
- +
- +Routine Description:
- +
- + Gets the state of a GPIO pin
- +
- +Arguments:
- +
- + This - pointer to protocol
- + Gpio - which pin to read
- + Value - state of the pin
- +
- +Returns:
- +
- + EFI_SUCCESS - GPIO state returned in Value
- + EFI_INVALID_PARAMETER - Value is NULL pointer or Gpio pin is out of range
- +**/
- STATIC
- EFI_STATUS
- -MvPca95xxGetValue (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN OUT BOOLEAN *Value
- +MvPca95xxGet (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + OUT UINTN *Value
- )
- {
- EFI_I2C_IO_PROTOCOL *I2cIo;
- EFI_STATUS Status;
- + UINTN ControllerIndex;
- + UINTN GpioPin;
- UINT8 RegVal;
- UINTN Bank;
- - Status = MvPca95xxValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: invalid pin/controller data\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + GpioPin = GPIO_PIN (Gpio);
- + ControllerIndex = GPIO_PORT (Gpio);
- +
- + ASSERT_EFI_ERROR (MvPca95xxValidate (ControllerIndex, GpioPin));
- Status = MvPca95xxGetI2c (ControllerIndex, &I2cIo);
- if (EFI_ERROR (Status)) {
- @@ -465,51 +454,113 @@ MvPca95xxGetValue (
- return Status;
- }
- - *Value = !!(RegVal & BIT (GpioPin % PCA95XX_BANK_SIZE));
- + if (RegVal & (1 << (GpioPin % PCA95XX_BANK_SIZE))) {
- + *Value = 1;
- + } else {
- + *Value = 0;
- + }
- return EFI_SUCCESS;
- }
- +/**
- +
- +Routine Description:
- +
- + Sets the state of a GPIO pin
- +
- +Arguments:
- +
- + This - pointer to protocol
- + Gpio - which pin to modify
- + Mode - mode to set
- +
- +Returns:
- +
- + EFI_SUCCESS - GPIO set as requested
- + EFI_UNSUPPORTED - Mode is not supported
- + EFI_INVALID_PARAMETER - Gpio pin is out of range
- +**/
- STATIC
- EFI_STATUS
- -MvPca95xxSetValue (
- - IN MARVELL_GPIO_PROTOCOL *This,
- - IN UINTN ControllerIndex,
- - IN UINTN GpioPin,
- - IN BOOLEAN Value
- +MvPca95xxSet (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + IN EMBEDDED_GPIO_MODE Mode
- )
- {
- EFI_STATUS Status;
- + UINTN ControllerIndex;
- + UINTN GpioPin;
- - Status = MvPca95xxValidate (ControllerIndex, GpioPin);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR,
- - "%a: invalid pin/controller data\n",
- - __FUNCTION__,
- - GpioPin));
- - return Status;
- - }
- + GpioPin = GPIO_PIN (Gpio);
- + ControllerIndex = GPIO_PORT (Gpio);
- - Status = MvPca95xxSetOutputValue (ControllerIndex, GpioPin, Value);
- - if (EFI_ERROR (Status)) {
- - DEBUG ((DEBUG_ERROR, "%a: fail to set ouput value\n", __FUNCTION__));
- + ASSERT_EFI_ERROR (MvPca95xxValidate (ControllerIndex, GpioPin));
- +
- + switch (Mode) {
- + case GPIO_MODE_OUTPUT_0:
- + case GPIO_MODE_OUTPUT_1:
- + Status = MvPca95xxSetOutputValue (ControllerIndex, GpioPin, Mode);
- + if (EFI_ERROR (Status)) {
- + DEBUG ((DEBUG_ERROR, "%a: fail to set ouput value\n", __FUNCTION__));
- + return Status;
- + }
- +
- + /* Fall-through */
- + case GPIO_MODE_INPUT:
- + Status = MvPca95xxSetDirection (ControllerIndex, GpioPin, Mode);
- + if (EFI_ERROR (Status)) {
- + DEBUG ((DEBUG_ERROR, "%a: fail to set direction\n", __FUNCTION__));
- + return Status;
- + }
- + break;
- +
- + default:
- + return EFI_UNSUPPORTED;
- }
- - return Status;
- + return EFI_SUCCESS;
- }
- +/**
- +
- +Routine Description:
- +
- + Sets the pull-up / pull-down resistor of a GPIO pin
- +
- +Arguments:
- +
- + This - pointer to protocol
- + Gpio - which pin
- + Direction - pull-up, pull-down, or none
- +
- +Returns:
- +
- + EFI_UNSUPPORTED - Can not perform the requested operation
- +
- +**/
- +EFI_STATUS
- +EFIAPI
- +MvPca95xxSetPull (
- + IN EMBEDDED_GPIO *This,
- + IN EMBEDDED_GPIO_PIN Gpio,
- + IN EMBEDDED_GPIO_PULL Direction
- + )
- +{
- + return EFI_UNSUPPORTED;
- +}
- STATIC
- VOID
- MvPca95xxInitProtocol (
- - IN MARVELL_GPIO_PROTOCOL *GpioProtocol
- + IN EMBEDDED_GPIO *GpioProtocol
- )
- {
- - GpioProtocol->DirectionInput = MvPca95xxDirectionInput;
- - GpioProtocol->DirectionOutput = MvPca95xxDirectionOutput;
- - GpioProtocol->GetFunction = MvPca95xxGetFunction;
- - GpioProtocol->GetValue = MvPca95xxGetValue;
- - GpioProtocol->SetValue = MvPca95xxSetValue;
- + GpioProtocol->Get = MvPca95xxGet;
- + GpioProtocol->Set = MvPca95xxSet;
- + GpioProtocol->GetMode = MvPca95xxGetMode;
- + GpioProtocol->SetPull = MvPca95xxSetPull;
- }
- EFI_STATUS
- @@ -519,15 +570,15 @@ MvPca95xxEntryPoint (
- IN EFI_SYSTEM_TABLE *SystemTable
- )
- {
- - MARVELL_BOARD_DESC_PROTOCOL *BoardDescProtocol;
- + MARVELL_BOARD_DESC_PROTOCOL *MvBoardProtocol;
- + MV_BOARD_GPIO_DESCRIPTION *GpioDescription;
- MV_GPIO_DEVICE_PATH *Pca95xxDevicePath;
- - MV_BOARD_GPIO_DESC *GpioDesc;
- EFI_STATUS Status;
- /* Obtain list of available controllers */
- Status = gBS->LocateProtocol (&gMarvellBoardDescProtocolGuid,
- NULL,
- - (VOID **)&BoardDescProtocol);
- + (VOID **)&MvBoardProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: Cannot locate BoardDesc protocol\n",
- @@ -535,24 +586,26 @@ MvPca95xxEntryPoint (
- return Status;
- }
- - Status = BoardDescProtocol->BoardDescGpioGet (BoardDescProtocol, &GpioDesc);
- - if (EFI_ERROR (Status) || !GpioDesc->I2cIoExpanderDesc) {
- + Status = MvBoardProtocol->GpioDescriptionGet (MvBoardProtocol,
- + &GpioDescription);
- + if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: Cannot get GPIO board desc from BoardDesc protocol\n",
- __FUNCTION__));
- return Status;
- - } else if (!GpioDesc->I2cIoExpanderDesc) {
- + } else if (GpioDescription->GpioExpanders == NULL) {
- /* Silently exit, if the board does not support the controllers */
- return EFI_SUCCESS;
- }
- Pca95xxDevicePath = AllocateCopyPool (sizeof (MV_GPIO_DEVICE_PATH),
- - &mPca95xxDevicePathTemplate);
- + &mDevicePathTemplate);
- if (Pca95xxDevicePath == NULL) {
- DEBUG ((DEBUG_ERROR,
- "%a: Fail to allocate Pca95xxDevicePath\n",
- __FUNCTION__));
- - return EFI_OUT_OF_RESOURCES;
- + Status = EFI_OUT_OF_RESOURCES;
- + goto ErrPca95xxDevicePathAlloc;
- }
- mPca95xxInstance = AllocateZeroPool (sizeof (PCA95XX));
- @@ -560,33 +613,39 @@ MvPca95xxEntryPoint (
- DEBUG ((DEBUG_ERROR,
- "%a: Fail to allocate mPca95xxInstance\n",
- __FUNCTION__));
- + Status = EFI_OUT_OF_RESOURCES;
- goto ErrPca95xxInstanceAlloc;
- }
- MvPca95xxInitProtocol (&mPca95xxInstance->GpioProtocol);
- mPca95xxInstance->Signature = PCA95XX_GPIO_SIGNATURE;
- - mPca95xxInstance->ControllerDesc = GpioDesc->I2cIoExpanderDesc;
- - mPca95xxInstance->ControllerCount = GpioDesc->I2cIoExpanderCount;
- + mPca95xxInstance->GpioExpanders = GpioDescription->GpioExpanders;
- + mPca95xxInstance->GpioExpanderCount = GpioDescription->GpioExpanderCount;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &(mPca95xxInstance->ControllerHandle),
- - &gMarvellGpioProtocolGuid,
- + &gEmbeddedGpioProtocolGuid,
- &(mPca95xxInstance->GpioProtocol),
- &gEfiDevicePathProtocolGuid,
- (EFI_DEVICE_PATH_PROTOCOL *)Pca95xxDevicePath,
- NULL);
- if (EFI_ERROR (Status)) {
- - goto ErrLocateBoardDesc;
- + goto ErrInstallProtocols;
- }
- + gBS->FreePool (GpioDescription);
- +
- return EFI_SUCCESS;
- -ErrLocateBoardDesc:
- +ErrInstallProtocols:
- gBS->FreePool (mPca95xxInstance);
- ErrPca95xxInstanceAlloc:
- gBS->FreePool (Pca95xxDevicePath);
- +ErrPca95xxDevicePathAlloc:
- + gBS->FreePool (GpioDescription);
- +
- return Status;
- }
- diff --git a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c
- index 031293e..74040b2 100644
- --- a/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c
- +++ b/Silicon/Marvell/Drivers/NonDiscoverableDxe/NonDiscoverableDxe.c
- @@ -58,7 +58,9 @@ NonDiscoverableInitXhci (
- Status = RegisterNonDiscoverableMmioDevice (
- NonDiscoverableDeviceTypeXhci,
- Desc[i].SoC->XhciDmaType,
- - GetInitializerForType (NonDiscoverableDeviceTypeXhci, i),
- + NonDiscoverableDeviceInitializerGet (
- + NonDiscoverableDeviceTypeXhci,
- + i),
- NULL,
- 1,
- Desc[i].SoC->XhciBaseAddress,
- @@ -87,7 +89,9 @@ NonDiscoverableInitAhci (
- Status = RegisterNonDiscoverableMmioDevice (
- NonDiscoverableDeviceTypeAhci,
- Desc[i].SoC->AhciDmaType,
- - GetInitializerForType (NonDiscoverableDeviceTypeAhci, i),
- + NonDiscoverableDeviceInitializerGet (
- + NonDiscoverableDeviceTypeAhci,
- + i),
- NULL,
- 1,
- Desc[i].SoC->AhciBaseAddress,
- @@ -116,7 +120,9 @@ NonDiscoverableInitSdhci (
- Status = RegisterNonDiscoverableMmioDevice (
- NonDiscoverableDeviceTypeSdhci,
- Desc[i].SoC->SdMmcDmaType,
- - GetInitializerForType (NonDiscoverableDeviceTypeSdhci, i),
- + NonDiscoverableDeviceInitializerGet (
- + NonDiscoverableDeviceTypeSdhci,
- + i),
- NULL,
- 1,
- Desc[i].SoC->SdMmcBaseAddress,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement