Re: [edk2] [platforms: PATCH v3 08/12] Marvell/Drivers: MvGpioDxe: Introduce platform GPIO driver
On Thu, Jan 17, 2019 at 12:15:11PM +0100, Marcin Wojtas wrote: > Marvell Armada 7k/8k SoCs comprise integrated GPIO controllers, > one in AP806 and two in each south bridge hardware blocks. > > This patch introduces support for them. The new driver implements > a generic EMBEDDED_GPIO protocol. > > In order to ease description of used GPIO pins and controllers > of the Armada 7k8k platforms, add a common enum type. > > Based on original work of Jing Hua . > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm > --- > Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf | 44 +++ > Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h | 49 +++ > Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c | 353 > > 3 files changed, 446 insertions(+) > create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf > create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h > create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c > > diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf > b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf > new file mode 100644 > index 000..5ff9130 > --- /dev/null > +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf > @@ -0,0 +1,44 @@ > +## @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 = MvGpioDxe > + FILE_GUID = 706eb761-b3b5-4f41-8558-5fd9217c0079 > + MODULE_TYPE= DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT= MvGpioEntryPoint > + > +[Sources] > + MvGpioDxe.c > + MvGpioDxe.h > + > +[Packages] > + EmbeddedPkg/EmbeddedPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + Silicon/Marvell/Marvell.dec > + > +[LibraryClasses] > + ArmadaSoCDescLib > + DebugLib > + MemoryAllocationLib > + UefiDriverEntryPoint > + UefiLib > + > +[Protocols] > + gEmbeddedGpioProtocolGuid > + gMarvellBoardDescProtocolGuid > + > +[Depex] > + TRUE > diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h > b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h > new file mode 100644 > index 000..6e56ec1 > --- /dev/null > +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h > @@ -0,0 +1,49 @@ > +/** > +* > +* 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_GPIO_H__ > +#define __MV_GPIO_H__ > + > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include > + > +#define MV_GPIO_SIGNATURESIGNATURE_64 ('M', 'V','_','G', 'P', > 'I','O',' ') > + > +// 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 { > + EMBEDDED_GPIO GpioProtocol; > + GPIO_CONTROLLER *SoCGpio; > + UINTN GpioDeviceCount; > + UINTN Signature; > + EFI_HANDLEHandle; > +} MV_GPIO; > + > +#endif // __MV_GPIO_H__ > diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c > b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c > new file mode 100644 > index 000..1d37ecc > --- /dev/null > +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c > @@ -0,0 +1,353 @@ > +/** > +* > +* 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, > +* W
[edk2] [platforms: PATCH v3 08/12] Marvell/Drivers: MvGpioDxe: Introduce platform GPIO driver
Marvell Armada 7k/8k SoCs comprise integrated GPIO controllers, one in AP806 and two in each south bridge hardware blocks. This patch introduces support for them. The new driver implements a generic EMBEDDED_GPIO protocol. In order to ease description of used GPIO pins and controllers of the Armada 7k8k platforms, add a common enum type. Based on original work of Jing Hua . Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf | 44 +++ Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h | 49 +++ Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c | 353 3 files changed, 446 insertions(+) create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h create mode 100644 Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf new file mode 100644 index 000..5ff9130 --- /dev/null +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.inf @@ -0,0 +1,44 @@ +## @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 = MvGpioDxe + FILE_GUID = 706eb761-b3b5-4f41-8558-5fd9217c0079 + MODULE_TYPE= DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT= MvGpioEntryPoint + +[Sources] + MvGpioDxe.c + MvGpioDxe.h + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Marvell/Marvell.dec + +[LibraryClasses] + ArmadaSoCDescLib + DebugLib + MemoryAllocationLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEmbeddedGpioProtocolGuid + gMarvellBoardDescProtocolGuid + +[Depex] + TRUE diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h new file mode 100644 index 000..6e56ec1 --- /dev/null +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.h @@ -0,0 +1,49 @@ +/** +* +* 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_GPIO_H__ +#define __MV_GPIO_H__ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define MV_GPIO_SIGNATURESIGNATURE_64 ('M', 'V','_','G', 'P', 'I','O',' ') + +// 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 { + EMBEDDED_GPIO GpioProtocol; + GPIO_CONTROLLER *SoCGpio; + UINTN GpioDeviceCount; + UINTN Signature; + EFI_HANDLEHandle; +} MV_GPIO; + +#endif // __MV_GPIO_H__ diff --git a/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c new file mode 100644 index 000..1d37ecc --- /dev/null +++ b/Silicon/Marvell/Drivers/Gpio/MvGpioDxe/MvGpioDxe.c @@ -0,0 +1,353 @@ +/** +* +* 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. +* +**/ + +#include "MvGpioDxe.h" + +STATIC MV_GPIO *mGpioInstance; + +STATIC MV_GPIO_DEVICE_PATH mDevicePathTemplate = { + { +{ + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { +(UINT8) (sizeof (VENDOR_DEVICE_PATH) + + sizeof (MV_GPIO_DRIVER_TYPE)), +(UINT8) ((sizeof (VENDOR_D