Skip to content

Commit

Permalink
Platform/RaspberryPi: query firmware for 16550 input clock at boot on…
Browse files Browse the repository at this point in the history
… RPi3

Query the firmware for the clock rate that is used to drive the
16550 baud clock, so that we can program the correct baud rate.

Co-authored-by: Pete Batard <pete@akeo.ie>
Co-authored-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Co-authored-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Pete Batard <pete@akeo.ie>
Tested-by: Pete Batard <pete@akeo.ie>
  • Loading branch information
3 people committed May 6, 2020
1 parent 3c29ba3 commit 043ee2e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2020, Andrei Warkentin <andrey.warkentin@gmail.com>
* Copyright (c) 2019-2020, Pete Batard <pete@akeo.ie>
* Copyright (c) 2016, Linaro Limited. All rights reserved.
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
* Copyright (c) 2011-2020, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
Expand Down Expand Up @@ -85,6 +85,14 @@ ASM_FUNC (ArmPlatformPeiBootAction)
adr x2, mBoardRevision
str w0, [x2]

#if (RPI_MODEL == 3)
run .Lclkinfo_buffer

ldr w0, .Lfrequency
adr x2, _gPcd_BinaryPatch_PcdSerialClockRate
str w0, [x2]
#endif

ret

.align 4
Expand Down Expand Up @@ -127,6 +135,21 @@ ASM_FUNC (ArmPlatformPeiBootAction)
.long 0 // end tag
.set .Lrevinfo_size, . - .Lrevinfo_buffer

#if (RPI_MODEL == 3)
.align 4
.Lclkinfo_buffer:
.long .Lclkinfo_size
.long 0x0
.long RPI_MBOX_GET_CLOCK_RATE
.long 8 // buf size
.long 4 // input len
.long 4 // clock id: 0x04 = Core/VPU
.Lfrequency:
.long 0 // frequency
.long 0 // end tag
.set .Lclkinfo_size, . - .Lclkinfo_buffer
#endif

//UINTN
//ArmPlatformGetPrimaryCoreMpId (
// VOID
Expand Down
3 changes: 3 additions & 0 deletions Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize

[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate # RPi3 only

[Ppis]
gArmMpCoreInfoPpiGuid
1 change: 1 addition & 0 deletions Platform/RaspberryPi/RPi3/RPi3.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@

[BuildOptions]
GCC:*_*_*_CC_FLAGS = -DRPI_MODEL=3
GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=3
GCC:*_*_*_ASLPP_FLAGS = -DRPI_MODEL=3
GCC:*_*_*_ASLCC_FLAGS = -DRPI_MODEL=3
GCC:*_*_*_VFRPP_FLAGS = -DRPI_MODEL=3
Expand Down
1 change: 1 addition & 0 deletions Platform/RaspberryPi/RPi4/RPi4.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@

[BuildOptions]
GCC:*_*_*_CC_FLAGS = -DRPI_MODEL=4
GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=4
GCC:*_*_*_ASLPP_FLAGS = -DRPI_MODEL=4
GCC:*_*_*_ASLCC_FLAGS = -DRPI_MODEL=4
GCC:*_*_*_VFRPP_FLAGS = -DRPI_MODEL=4
Expand Down

0 comments on commit 043ee2e

Please sign in to comment.