From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Pete Batard <pete@akeo.ie>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
Leif Lindholm <leif.lindholm@linaro.org>
Subject: Re: [PATCH v3 edk2-platforms 02/23] Silicon/Broadcom/Bcm283x: Add GpioLib
Date: Mon, 28 Jan 2019 14:02:42 +0100 [thread overview]
Message-ID: <CAKv+Gu_Qff03muEZ82sT0WDfDDLGaRxoFs=a8=Jkdge7m+F+3g@mail.gmail.com> (raw)
In-Reply-To: <20190128124445.9868-3-pete@akeo.ie>
On Mon, 28 Jan 2019 at 13:45, Pete Batard <pete@akeo.ie> wrote:
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
> Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c | 88 ++++++++++++++++++++
> Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf | 39 +++++++++
> Silicon/Broadcom/Include/IndustryStandard/Bcm2836Gpio.h | 60 +++++++++++++
> 3 files changed, 187 insertions(+)
>
> diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
> new file mode 100644
> index 000000000000..eb6accafb01e
> --- /dev/null
> +++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
> @@ -0,0 +1,88 @@
> +/** @file
> + *
> + * GPIO manipulation.
> + *
> + * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
> + *
> + * 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 <Uefi.h>
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +#include <IndustryStandard/Bcm2836.h>
> +#include <IndustryStandard/Bcm2836Gpio.h>
> +
> +STATIC
> +VOID
> +GpioFSELModify (
> + IN UINTN RegIndex,
> + IN UINT32 ModifyMask,
> + IN UINT32 FunctionMask
> + )
> +{
> + UINT32 Val;
> + EFI_PHYSICAL_ADDRESS Reg;
> +
> + Reg = RegIndex * sizeof (UINT32) + GPIO_GPFSEL0;
> +
> + ASSERT (Reg <= GPIO_GPFSEL5);
> + ASSERT ((~ModifyMask & FunctionMask) == 0);
> +
> + Val = MmioRead32 (Reg);
> + Val &= ~ModifyMask;
> + Val |= FunctionMask;
> + MmioWrite32 (Reg, Val);
> +}
> +
> +VOID
> +GpioPinFuncSet (
> + IN UINTN Pin,
> + IN UINTN Function
> + )
> +{
> + UINTN RegIndex;
> + UINTN SelIndex;
> + UINT32 ModifyMask;
> + UINT32 FunctionMask;
> +
> + ASSERT (Pin < GPIO_PINS);
> + ASSERT (Function <= GPIO_FSEL_MASK);
> +
> + RegIndex = Pin / 10;
> + SelIndex = Pin % 10;
> +
> + ModifyMask = GPIO_FSEL_MASK << (SelIndex * GPIO_FSEL_BITS_PER_PIN);
> + FunctionMask = Function << (SelIndex * GPIO_FSEL_BITS_PER_PIN);
> + GpioFSELModify (RegIndex, ModifyMask, FunctionMask);
> +}
> +
> +UINTN
> +GpioPinFuncGet (
> + IN UINTN Pin
> + )
> +{
> + UINT32 Val;
> + UINTN RegIndex;
> + UINTN SelIndex;
> + EFI_PHYSICAL_ADDRESS Reg;
> +
> + ASSERT (Pin < GPIO_PINS);
> +
> + RegIndex = Pin / 10;
> + SelIndex = Pin % 10;
> + Reg = RegIndex * sizeof (UINT32) + GPIO_GPFSEL0;
> +
> + Val = MmioRead32 (Reg);
> + Val >>= SelIndex * GPIO_FSEL_BITS_PER_PIN;
> + Val &= GPIO_FSEL_MASK;
> + return Val;
> +}
> diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf
> new file mode 100644
> index 000000000000..68ebe44e3d1c
> --- /dev/null
> +++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf
> @@ -0,0 +1,39 @@
> +#/** @file
> +#
> +# Manipulate GPIOs.
> +#
> +# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
> +#
> +# 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 = GpioLib
> + FILE_GUID = B9F59B6B-B105-41C7-8F5A-2C60DD7FD7AB
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = GpioLib
> +
> +[Sources]
> + GpioLib.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + MdePkg/MdePkg.dec
> + EmbeddedPkg/EmbeddedPkg.dec
> + Silicon/Broadcom/Bcm283x/Bcm283x.dec
> +
> +[LibraryClasses]
> + BaseLib
> + DebugLib
> + IoLib
> +
> +[Guids]
> diff --git a/Silicon/Broadcom/Include/IndustryStandard/Bcm2836Gpio.h b/Silicon/Broadcom/Include/IndustryStandard/Bcm2836Gpio.h
Please move this header to Silicon/Broadcom/Bcm283x/...
> new file mode 100644
> index 000000000000..45774b639ca8
> --- /dev/null
> +++ b/Silicon/Broadcom/Include/IndustryStandard/Bcm2836Gpio.h
> @@ -0,0 +1,60 @@
> +/** @file
> + *
> + * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
> + * Copyright (c) Microsoft Corporation. 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 __BCM2836_GPIO_H__
> +#define __BCM2836_GPIO_H__
> +
> +#define GPIO_BASE_ADDRESS (BCM2836_SOC_REGISTERS + 0x00200000)
> +
> +#define GPIO_GPFSEL0 (GPIO_BASE_ADDRESS + 0x00)
> +#define GPIO_GPFSEL1 (GPIO_BASE_ADDRESS + 0x04)
> +#define GPIO_GPFSEL2 (GPIO_BASE_ADDRESS + 0x08)
> +#define GPIO_GPFSEL3 (GPIO_BASE_ADDRESS + 0x0C)
> +#define GPIO_GPFSEL4 (GPIO_BASE_ADDRESS + 0x10)
> +#define GPIO_GPFSEL5 (GPIO_BASE_ADDRESS + 0x14)
> +
> +#define GPIO_GPCLR0 (GPIO_BASE_ADDRESS + 0x28)
> +#define GPIO_GPCLR1 (GPIO_BASE_ADDRESS + 0x2C)
> +
> +#define GPIO_GPSET0 (GPIO_BASE_ADDRESS + 0x1C)
> +#define GPIO_GPSET1 (GPIO_BASE_ADDRESS + 0x20)
> +
> +#define GPIO_FSEL_INPUT 0x0
> +#define GPIO_FSEL_OUTPUT 0x1
> +#define GPIO_FSEL_ALT0 0x4
> +#define GPIO_FSEL_ALT1 0x5
> +#define GPIO_FSEL_ALT2 0x6
> +#define GPIO_FSEL_ALT3 0x7
> +#define GPIO_FSEL_ALT4 0x3
> +#define GPIO_FSEL_ALT5 0x2
> +
> +#define GPIO_FSEL_PINS_PER_REGISTER 10
> +#define GPIO_FSEL_BITS_PER_PIN 3
> +#define GPIO_FSEL_MASK ((1 << GPIO_FSEL_BITS_PER_PIN) - 1)
> +
> +#define GPIO_PINS 54
> +
> +VOID
> +GpioPinFuncSet (
> + IN UINTN Pin,
> + IN UINTN Function
> + );
> +
> +UINTN
> +GpioPinFuncGet (
> + IN UINTN Pin
> + );
> +
Please move these elsewhere: they don't belong in the IP block header.
> +#endif /* __BCM2836_GPIO_H__ */
> --
> 2.17.0.windows.1
>
next prev parent reply other threads:[~2019-01-28 13:02 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 12:44 [PATCH v3 edk2-platforms 00/23] Platform/Raspberry: Add Raspberry Pi 3 support Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 01/23] Silicon/Broadcom/Bcm282x: Add interrupt driver Pete Batard
2019-01-28 12:59 ` Ard Biesheuvel
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 02/23] Silicon/Broadcom/Bcm283x: Add GpioLib Pete Batard
2019-01-28 13:02 ` Ard Biesheuvel [this message]
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 03/23] Platform/Raspberry/Pi3: Add ACPI tables Pete Batard
2019-01-28 13:24 ` Ard Biesheuvel
2019-01-29 12:54 ` Pete Batard
2019-01-29 12:57 ` Ard Biesheuvel
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 04/23] Platform/Raspberry/Pi3: Add reset and memory init libraries Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 05/23] Platform/Raspberry/Pi3: Add platform library Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 06/23] Platform/Raspberry/Pi3: Add RTC library Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 07/23] Platform/Raspberry/Pi3: Add firmware driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 08/23] Platform/Raspberry/Pi3: Add platform config driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 09/23] Platform/Raspberry/Pi3: Add SMBIOS driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 10/23] Platform/Raspberry/Pi3: Add display driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 11/23] Platform/Raspberry/Pi3: Add console driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 12/23] Platform/Raspberry/Pi3: Add NV storage driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 13/23] Platform/Raspberry/Pi3: Add Device Tree driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 14/23] Platform/Raspberry/Pi3: Add base MMC driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 15/23] Platform/Raspberry/Pi3: Add Arasan " Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 16/23] Platform/Raspberry/Pi3: Add SD Host driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 17/23] Platform/Raspberry/Pi3: Add platform boot manager and helper libraries Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 18/23] Platform/Raspberry/Pi3: Add USB host driver Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 19/23] Platform/Raspberry/Pi3: Add platform Pete Batard
2019-01-28 13:10 ` Ard Biesheuvel
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 20/23] Platform/Raspberry/Pi3: Add platform readme Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 21/23] Platform/Raspberry/Pi3 *NON-OSI*: Add ATF binaries Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 2/23] Platform/Raspberry/Pi3 *NON-OSI*: Add Device Tree binaries Pete Batard
2019-01-28 12:44 ` [PATCH v3 edk2-platforms 23/23] Platform/Raspberry/Pi3 *NON-OSI*: Add logo driver Pete Batard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKv+Gu_Qff03muEZ82sT0WDfDDLGaRxoFs=a8=Jkdge7m+F+3g@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox