From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by mx.groups.io with SMTP id smtpd.web12.1443.1589146618490857746 for ; Sun, 10 May 2020 14:37:28 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="key unavailable" header.i=@gmail.com header.s=20161025 header.b=oomH2E6l; spf=temperror, err=temporary DNS error (domain: gmail.com, ip: 209.85.222.196, mailfrom: andrey.warkentin@gmail.com) Received: by mail-qk1-f196.google.com with SMTP id n14so7868951qke.8 for ; Sun, 10 May 2020 14:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aB8Q6Knze3KlqEuzNvJzs0dPwYWYqeZkVapbC5ztiTQ=; b=oomH2E6lsNXtEVBNO4g2cyC6E9Utk+uwaz5qWZ3rhDuP6nceUH4OdiscEIvAtfnhCb BxFSaaZOcBeShRUrpSVO8xPpPGVnbL2GHROTrI0T+c0joNJSBCknxm5pOmgtFLueW3p5 hePmzl9sTm4y+0NLun4YTMwrfyxnlJsvwHiF8oRZRMSqT8/tJwSLD2zmgBOg2/nnCp/p 0fYhRsTF/ae4MGzF+yBLkl6GaBkAyjQ+DBDaFtEu51a8pRFwj4FgicuHZGOIV6hINFO5 NWEbpqmWVFc1zDH2r/WPfWSLieho4LmU9ZxdWQwrmYejcq+jT4gpMoT2Q9SUToDDnu6i 5ebg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aB8Q6Knze3KlqEuzNvJzs0dPwYWYqeZkVapbC5ztiTQ=; b=mmdwSwIZvGUTe9uB+Tqiq67/GQqir3MIl3UIlkxc0QFZZ+sav/TlIEz7E9sdDIoPg2 c/HGtxXWEbZIctF67RDtkKX4nRR+deQMacs6DgzsjmiRZlhAhuw6nWqnqEr1RHHp3DHE cJxvHPDWbCQGDvg5GRun9a4i/kJ3WKBqD++HoUdweGNv/TJLD6g/zrzFEUahCZvNxoyv gZvtYmqvV3shd1ZG5dcJPC7IiQKH0Ktjtr4I97RltZTWHtZRkGfX1xAEhcTCsbFxU1YL /leLizX4j+oOkTAREijeuODe5HyKI5Se8RIUgulh4D5uJ6I/KUKZSdfkgaht37B/6Ehb o1DA== X-Gm-Message-State: AGi0PuZX8QpBZKCQHqavFmwfatwXCZmmrh2BjQ+f7zFp/ZX6iH9y2Hll +NHZqUTKkJj4eNYlGH/q5h3BiW+beBs= X-Google-Smtp-Source: APiQypIchwaiv42rfMVpA9/W6Rb9cM0wTS5L0WWFJTpeTb+ZA2FY5BGZlk0iFcTSC/ezg1V56G/pXA== X-Received: by 2002:a05:620a:990:: with SMTP id x16mr5133806qkx.256.1589146617532; Sun, 10 May 2020 14:36:57 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-98-214-99-181.hsd1.il.comcast.net. [98.214.99.181]) by smtp.gmail.com with ESMTPSA id z40sm7671121qtj.45.2020.05.10.14.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 14:36:57 -0700 (PDT) From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: ard.biesheuvel@arm.com, leif@nuviainc.com, pete@akeo.ie, philmd@redhat.com Subject: [edk2-platforms][PATCH 1/1] RPi: add Gpio output set/clear functions to GpioLib Date: Sun, 10 May 2020 14:36:50 -0700 Message-Id: <20200510213650.12829-1-andrey.warkentin@gmail.com> X-Mailer: git-send-email 2.17.1 GpioSet and GpioClear. Using hw of course (not mailbox). Signed-off-by: Andrei Warkentin --- Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h | 10 +++++ Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c | 42 +++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h index 014c6b07..10c9cdfb 100644 --- a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h +++ b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h @@ -24,4 +24,14 @@ GpioPinFuncGet ( IN UINTN Pin ); +VOID +GpioSet ( + IN UINTN Pin + ); + +VOID +GpioClear ( + IN UINTN Pin + ); + #endif /* __GPIO_LIB__ */ diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c index 542b6e8f..716b05be 100644 --- a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c +++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c @@ -18,7 +18,7 @@ STATIC VOID -GpioFSELModify ( +GpioFSelModify ( IN UINTN RegIndex, IN UINT32 ModifyMask, IN UINT32 FunctionMask @@ -38,6 +38,44 @@ GpioFSELModify ( MmioWrite32 (Reg, Val); } +VOID +GpioSet ( + IN UINTN Pin + ) +{ + UINT32 Val; + EFI_PHYSICAL_ADDRESS Reg; + UINT8 RegIndex = Pin / 32; + UINT8 SelIndex = Pin % 32; + + Reg = RegIndex * sizeof (UINT32) + GPIO_GPSET0; + + ASSERT (Reg <= GPIO_GPSET1); + + Val = MmioRead32 (Reg); + Val |= 1 << SelIndex; + MmioWrite32 (Reg, Val); +} + +VOID +GpioClear ( + IN UINTN Pin + ) +{ + UINT32 Val; + EFI_PHYSICAL_ADDRESS Reg; + UINT8 RegIndex = Pin / 32; + UINT8 SelIndex = Pin % 32; + + Reg = RegIndex * sizeof (UINT32) + GPIO_GPCLR0; + + ASSERT (Reg <= GPIO_GPCLR1); + + Val = MmioRead32 (Reg); + Val |= 1 << SelIndex; + MmioWrite32 (Reg, Val); +} + VOID GpioPinFuncSet ( IN UINTN Pin, @@ -57,7 +95,7 @@ GpioPinFuncSet ( ModifyMask = GPIO_FSEL_MASK << (SelIndex * GPIO_FSEL_BITS_PER_PIN); FunctionMask = Function << (SelIndex * GPIO_FSEL_BITS_PER_PIN); - GpioFSELModify (RegIndex, ModifyMask, FunctionMask); + GpioFSelModify (RegIndex, ModifyMask, FunctionMask); } UINTN -- 2.17.1