[edk2-devel] [edk2-platforms][PATCH 2/3] Silicon/Broadcom/Bcm283x: Move Bcm2835 RNG defines to their own header

Pete Batard posted 3 patches 6 years, 2 months ago
[edk2-devel] [edk2-platforms][PATCH 2/3] Silicon/Broadcom/Bcm283x: Move Bcm2835 RNG defines to their own header
Posted by Pete Batard 6 years, 2 months ago
While the Bcm2835 and Bcm2838 RNG appear to share the same register layout,
we prefer moving the RNG specific defines into their own header in case
this assertion doesn't hold true with future RNG drivers.

Also, this should make it clearer to see which specific elements apply to
which SoC implementation.

Signed-off-by: Pete Batard <pete@akeo.ie>
---
 Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c |  2 +-
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h | 22 ++++++++++++++++++++
 Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h    |  9 --------
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c
index ea86f9b3877e..84d194ea8472 100644
--- a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c
+++ b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c
@@ -14,7 +14,7 @@
 #include <Library/IoLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 
-#include <IndustryStandard/Bcm2836.h>
+#include <IndustryStandard/Bcm2835Rng.h>
 
 #include <Protocol/Rng.h>
 
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h
new file mode 100644
index 000000000000..817c91cb24c1
--- /dev/null
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h
@@ -0,0 +1,22 @@
+/** @file
+ *
+ *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>.
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#ifndef BCM2835_RNG_H__
+#define BCM2835_RNG_H__
+
+#define BCM2835_RNG_OFFSET                  0x00104000
+#define RNG_BASE_ADDRESS                    ((FixedPcdGet64 (PcdBcm283xRegistersAddress)) \
+                                            + BCM2835_RNG_OFFSET)
+
+#define RNG_CTRL                            (RNG_BASE_ADDRESS + 0x0)
+#define RNG_STATUS                          (RNG_BASE_ADDRESS + 0x4)
+#define RNG_DATA                            (RNG_BASE_ADDRESS + 0x8)
+
+#define RNG_CTRL_ENABLE                     0x1
+
+#endif /* BCM2835_RNG_H__ */
diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
index 72c8e9dc4b14..02107086d439 100644
--- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
+++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
@@ -50,13 +50,4 @@
 #define BCM2836_INTC_TIMER_CONTROL_OFFSET                   0x00000040
 #define BCM2836_INTC_TIMER_PENDING_OFFSET                   0x00000060
 
-/* random number generator */
-#define RNG_BASE_ADDRESS   (BCM2836_SOC_REGISTERS + 0x00104000)
-
-#define RNG_CTRL           (RNG_BASE_ADDRESS + 0x0)
-#define RNG_STATUS         (RNG_BASE_ADDRESS + 0x4)
-#define RNG_DATA           (RNG_BASE_ADDRESS + 0x8)
-
-#define RNG_CTRL_ENABLE    0x1
-
 #endif /*__BCM2836_H__ */
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#51526): https://edk2.groups.io/g/devel/message/51526
Mute This Topic: https://groups.io/mt/64721567/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-platforms][PATCH 2/3] Silicon/Broadcom/Bcm283x: Move Bcm2835 RNG defines to their own header
Posted by Philippe Mathieu-Daudé 6 years, 2 months ago
On 12/2/19 12:55 PM, Pete Batard wrote:
> While the Bcm2835 and Bcm2838 RNG appear to share the same register layout,
> we prefer moving the RNG specific defines into their own header in case
> this assertion doesn't hold true with future RNG drivers.
> 
> Also, this should make it clearer to see which specific elements apply to
> which SoC implementation.
> 
> Signed-off-by: Pete Batard <pete@akeo.ie>
> ---
>   Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c |  2 +-
>   Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h | 22 ++++++++++++++++++++
>   Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h    |  9 --------
>   3 files changed, 23 insertions(+), 10 deletions(-)
> 
> diff --git a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c
> index ea86f9b3877e..84d194ea8472 100644
> --- a/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c
> +++ b/Silicon/Broadcom/Bcm283x/Drivers/Bcm2835RngDxe/Bcm2835RngDxe.c
> @@ -14,7 +14,7 @@
>   #include <Library/IoLib.h>
>   #include <Library/UefiBootServicesTableLib.h>
>   
> -#include <IndustryStandard/Bcm2836.h>
> +#include <IndustryStandard/Bcm2835Rng.h>
>   
>   #include <Protocol/Rng.h>
>   
> diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h
> new file mode 100644
> index 000000000000..817c91cb24c1
> --- /dev/null
> +++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2835Rng.h
> @@ -0,0 +1,22 @@
> +/** @file
> + *
> + *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>.
> + *
> + *  SPDX-License-Identifier: BSD-2-Clause-Patent
> + *
> + **/
> +
> +#ifndef BCM2835_RNG_H__
> +#define BCM2835_RNG_H__
> +
> +#define BCM2835_RNG_OFFSET                  0x00104000
> +#define RNG_BASE_ADDRESS                    ((FixedPcdGet64 (PcdBcm283xRegistersAddress)) \
> +                                            + BCM2835_RNG_OFFSET)
> +
> +#define RNG_CTRL                            (RNG_BASE_ADDRESS + 0x0)
> +#define RNG_STATUS                          (RNG_BASE_ADDRESS + 0x4)
> +#define RNG_DATA                            (RNG_BASE_ADDRESS + 0x8)
> +
> +#define RNG_CTRL_ENABLE                     0x1
> +
> +#endif /* BCM2835_RNG_H__ */
> diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
> index 72c8e9dc4b14..02107086d439 100644
> --- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
> +++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h
> @@ -50,13 +50,4 @@
>   #define BCM2836_INTC_TIMER_CONTROL_OFFSET                   0x00000040
>   #define BCM2836_INTC_TIMER_PENDING_OFFSET                   0x00000060
>   
> -/* random number generator */
> -#define RNG_BASE_ADDRESS   (BCM2836_SOC_REGISTERS + 0x00104000)
> -
> -#define RNG_CTRL           (RNG_BASE_ADDRESS + 0x0)
> -#define RNG_STATUS         (RNG_BASE_ADDRESS + 0x4)
> -#define RNG_DATA           (RNG_BASE_ADDRESS + 0x8)
> -
> -#define RNG_CTRL_ENABLE    0x1
> -
>   #endif /*__BCM2836_H__ */
> 

Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#51530): https://edk2.groups.io/g/devel/message/51530
Mute This Topic: https://groups.io/mt/64721567/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-