Re: [edk2] [platforms: PATCH v2 10/12] Marvell/Drivers: MvPca95xxDxe: Introduce GPIO expander driver
On Thu, Jan 10, 2019 at 02:44:37AM +0100, Marcin Wojtas wrote: > Marvell Armada 7k/8k-based platforms may use Pca95xx to extend > amount of the GPIO pins. > > This patch introduces support for them. The new driver implements > a generic EMBEDDED_GPIO protocol. > > In order to ease description of used PCA9XXX controllers > add a common enum type. It can be used e.g. in the board description > library to specify the expander model on a board (instead of passing > a raw number). Update relevant libraries. > > Driver is based on initial work done by Allen Yan . > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas > --- > Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf > | 45 ++ > Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h > | 65 ++ > Silicon/Marvell/Include/Protocol/MvGpio.h > | 16 + > > Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c > | 2 +- > > Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c > | 4 +- > Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c > | 651 > 6 files changed, 780 insertions(+), 3 deletions(-) > create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf > create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h > create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c > > diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf > b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf > new file mode 100644 > index 000..3b1ab4e > --- /dev/null > +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf > @@ -0,0 +1,45 @@ > +## @file > +# > +# Copyright (c) 2017, 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. > +# > + > +[Defines] > + INF_VERSION= 0x0001001A > + BASE_NAME = MvPca95xxDxe > + FILE_GUID = f0e405eb-8407-43b9-88e6-2f7d70715c72 > + MODULE_TYPE= DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT= MvPca95xxEntryPoint > + > +[Sources] > + MvPca95xxDxe.c > + MvPca95xxDxe.h > + > +[Packages] > + EmbeddedPkg/EmbeddedPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + Silicon/Marvell/Marvell.dec > + > +[LibraryClasses] > + DebugLib > + MemoryAllocationLib > + UefiDriverEntryPoint > + UefiLib > + > +[Protocols] > + gEfiDriverBindingProtocolGuid > + gEfiI2cIoProtocolGuid > + gEmbeddedGpioProtocolGuid > + gMarvellBoardDescProtocolGuid > + > +[Depex] > + TRUE > diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h > b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h > new file mode 100644 > index 000..1fed739 > --- /dev/null > +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h > @@ -0,0 +1,65 @@ > +/** > +* > +* 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 __MV_PCA953X_H__ > +#define __MV_PCA953X_H__ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#include > + > +#define PCA95XX_GPIO_SIGNATURE SIGNATURE_32 ('I', 'O', 'E', 'X') > + > +#define PCA95XX_INPUT_REG0x0 > +#define PCA95XX_OUTPUT_REG 0x2 > +#define PCA95XX_DIRECTION_REG0x6 > + > +#define PCA95XX_BANK_SIZE8 > +#define PCA95XX_OPERATION_COUNT 2 > +#define PCA95XX_OPERATION_LENGTH 1 > + > +typedef enum { > + PCA9505_PIN_COUNT = 40, > + PCA9534_PIN_COUNT = 8, > + PCA9535_PIN_COUNT = 16, > + PCA9536_PIN_COUNT = 4, > + PCA9537_PIN_COUNT = 4, > + PCA9538_PIN_COUNT = 8, > + PCA9539_PIN_COUNT = 16, > + PCA9554_PIN_COUNT = 8, > + PCA9555_PIN_COUNT = 16, > + PCA9556_PIN_COUNT = 16, > + PCA9557_PIN_COUNT = 16, > +} PCA95XX_PIN_COUNT; > + > +typedef struct { > +
[edk2] [platforms: PATCH v2 10/12] Marvell/Drivers: MvPca95xxDxe: Introduce GPIO expander driver
Marvell Armada 7k/8k-based platforms may use Pca95xx to extend amount of the GPIO pins. This patch introduces support for them. The new driver implements a generic EMBEDDED_GPIO protocol. In order to ease description of used PCA9XXX controllers add a common enum type. It can be used e.g. in the board description library to specify the expander model on a board (instead of passing a raw number). Update relevant libraries. Driver is based on initial work done by Allen Yan . Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf | 45 ++ Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h | 65 ++ Silicon/Marvell/Include/Protocol/MvGpio.h | 16 + Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c | 2 +- Platform/Marvell/Armada80x0Db/Armada80x0DbBoardDescLib/Armada80x0DbBoardDescLib.c | 4 +- Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c | 651 6 files changed, 780 insertions(+), 3 deletions(-) create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h create mode 100644 Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.c diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf new file mode 100644 index 000..3b1ab4e --- /dev/null +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.inf @@ -0,0 +1,45 @@ +## @file +# +# Copyright (c) 2017, 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. +# + +[Defines] + INF_VERSION= 0x0001001A + BASE_NAME = MvPca95xxDxe + FILE_GUID = f0e405eb-8407-43b9-88e6-2f7d70715c72 + MODULE_TYPE= DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT= MvPca95xxEntryPoint + +[Sources] + MvPca95xxDxe.c + MvPca95xxDxe.h + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + DebugLib + MemoryAllocationLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEfiDriverBindingProtocolGuid + gEfiI2cIoProtocolGuid + gEmbeddedGpioProtocolGuid + gMarvellBoardDescProtocolGuid + +[Depex] + TRUE diff --git a/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h new file mode 100644 index 000..1fed739 --- /dev/null +++ b/Silicon/Marvell/Drivers/Gpio/MvPca95xxDxe/MvPca95xxDxe.h @@ -0,0 +1,65 @@ +/** +* +* 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 __MV_PCA953X_H__ +#define __MV_PCA953X_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#define PCA95XX_GPIO_SIGNATURE SIGNATURE_32 ('I', 'O', 'E', 'X') + +#define PCA95XX_INPUT_REG0x0 +#define PCA95XX_OUTPUT_REG 0x2 +#define PCA95XX_DIRECTION_REG0x6 + +#define PCA95XX_BANK_SIZE8 +#define PCA95XX_OPERATION_COUNT 2 +#define PCA95XX_OPERATION_LENGTH 1 + +typedef enum { + PCA9505_PIN_COUNT = 40, + PCA9534_PIN_COUNT = 8, + PCA9535_PIN_COUNT = 16, + PCA9536_PIN_COUNT = 4, + PCA9537_PIN_COUNT = 4, + PCA9538_PIN_COUNT = 8, + PCA9539_PIN_COUNT = 16, + PCA9554_PIN_COUNT = 8, + PCA9555_PIN_COUNT = 16, + PCA9556_PIN_COUNT = 16, + PCA9557_PIN_COUNT = 16, +} PCA95XX_PIN_COUNT; + +typedef struct { + EMBEDDED_GPIO GpioProtocol; + MV_GPIO_EXPANDER *GpioExpanders; + UINTN GpioExpanderCount; + UINTN Signature; + EFI_HANDLE ControllerHandle; +} PCA95XX; + +#endif diff --git a/Silicon/Marvell/Include/Protocol/MvGpio.h b/Silicon/Marvell/Include/Protocol/MvGpio.h index 3319b79..5037fc2 100644 ---