From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web09.5635.1574859615705447315 for ; Wed, 27 Nov 2019 05:00:16 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=kH+ND8Bb; spf=pass (domain: linaro.org, ip: 209.85.221.65, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f65.google.com with SMTP id i12so26524087wrn.11 for ; Wed, 27 Nov 2019 05:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=voWHDz3lBBfDczSt6yhNsqKBD9y/Tlwlb8og6wink98=; b=kH+ND8Bbi5a0UbkI75QOMWuOBonOYcIF9WAaZX8Vkp8iCAiPC/rVVRqSsD8lYF/ugg uPImjJkfIq0jHdJ4LXmsyBQHwkQIIKH6unmI/qQZAKUM25HUspc8ZNXUdC1Llctn8Da8 AiqqFv8EsHfSNHVejskcy+pios6DZm9xRue7Rds/MfVjBUC7ADsuZGgciuyc6lMy/zib LYcs8RE5hdMEYzqESoHtBN6VTn1yBKzcZz+uqEI2zrJuIjb8FrL8YLksXlvVOjylVhUN t4vjupomGopVqAbzHJYxa5HEnfMiQcJ0U4xJaOfpO0qyRISR0VR3GqIC7yGu9PznZ1Z+ 2y+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=voWHDz3lBBfDczSt6yhNsqKBD9y/Tlwlb8og6wink98=; b=pG/ds+TQ0ljB9InJebNhxTkGD6C6ied5wrOkiJtOIV+IhXCGx8GuTkmHcrBx8pVR+4 9NbrsfOULif+CyzEfY0VNRYqq89VrpELV5gLAoAEevyHEF6fUAvcxpykEBEnIV4FQzEB nkKUZXUUGRmVThG0HAFon/w25uh7p6g7xhTxs/bigoD5pB9nl08vxy02WdJZgj8qDFjQ zsRVJd+MrVMjaLoCrbi2nliHN7rh80ziEZHQBYs5zmow0tj9Kp1lqxEheomgDuSk/a+J wxoTYZugZKm4D8s+O6EGSFEnMHPYolQw0YEneOcE7Va3mY/0nm9oJbzzbr+cbL+9uLtA 6NXg== X-Gm-Message-State: APjAAAWzyNqJswYKuNsOP54V0XQV/6Q7AcyYHU+6HMUAn+KXDRXpE0mH JEl+aHbOf7aJUziY1GXxdssPZMO9xNkZi8b8YpSJYA== X-Google-Smtp-Source: APXvYqzGp+dEiCL3+bJr5okDvJjPntHGrMk3RjGpuVQTK8AqTIRvUSMJ8Fc8eVlnwsKlGzXyWld14qA+2FgTP1E5Exw= X-Received: by 2002:a5d:6652:: with SMTP id f18mr684730wrw.246.1574859614154; Wed, 27 Nov 2019 05:00:14 -0800 (PST) MIME-Version: 1.0 References: <20191127123706.4604-1-pete@akeo.ie> <20191127123706.4604-2-pete@akeo.ie> In-Reply-To: From: "Ard Biesheuvel" Date: Wed, 27 Nov 2019 14:00:03 +0100 Message-ID: Subject: Re: [edk2-platforms][PATCH 1/5] Silicon/Bcm283x: Clean up Bcm2836.h header To: Pete Batard Cc: edk2-devel-groups-io , Leif Lindholm , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , samer.el-haj-mahmoud@arm.com, "Andrei E. Warkentin" Content-Type: text/plain; charset="UTF-8" On Wed, 27 Nov 2019 at 13:56, Pete Batard wrote: > > On 2019.11.27 12:48, Ard Biesheuvel wrote: > > On Wed, 27 Nov 2019 at 13:37, Pete Batard wrote: > >> > >> Add missing RNG registers, prefer reusing shorter define's > >> instead of PCDs and clean up spacing. > >> > > > > Is there a source for these register definitions? > > I used the most recent Linux driver I could find (but I guess I need to > point out that it was used for reference with regards to the registers. > Especially, no code was copied from that source). > > > It seems the Linux > > driver deviates from the below (and the warmup count thing uses the > > status register as well), so it would be helpful to quote the > > authoritative reference here. > > https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/char/hw_random/iproc-rng200.c#L223-L224 > seems to indicate that RNG_WARMUP_COUNT (0x40000) should go into > RNG_TOTAL_BIT_COUNT_THRESHOLD_OFFSET (them) / RNG_BIT_COUNT_THRESHOLD > (us) and not the status register. > > Now, of course, since we don't have a public datasheet, it's hard to > have absolute certainty on what's the proper register to write, but I > guess the most recent code with a Broadcom Corporation copyright has to > our next best thing when it comes to authoritative answer... > Well, there is this one too https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/char/hw_random/bcm2835-rng.c which is what I used as the basis for the existing version. > > > > > >> Signed-off-by: Pete Batard > >> --- > >> Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h | 23 ++++++++++++-------- > >> 1 file changed, 14 insertions(+), 9 deletions(-) > >> > >> diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h > >> index 72c8e9dc4b14..744c7ac3b9f4 100644 > >> --- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h > >> +++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h > >> @@ -24,8 +24,7 @@ > >> > >> /* watchdog constants */ > >> #define BCM2836_WDOG_OFFSET 0x00100000 > >> -#define BCM2836_WDOG_BASE_ADDRESS (FixedPcdGet64 (PcdBcm283xRegistersAddress) \ > >> - + BCM2836_WDOG_OFFSET) > >> +#define BCM2836_WDOG_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_WDOG_OFFSET) > >> #define BCM2836_WDOG_PASSWORD 0x5a000000 > >> #define BCM2836_WDOG_RSTC_OFFSET 0x0000001c > >> #define BCM2836_WDOG_WDOG_OFFSET 0x00000024 > >> @@ -34,8 +33,7 @@ > >> > >> /* mailbox interface constants */ > >> #define BCM2836_MBOX_OFFSET 0x0000b880 > >> -#define BCM2836_MBOX_BASE_ADDRESS (FixedPcdGet64 (PcdBcm283xRegistersAddress) \ > >> - + BCM2836_MBOX_OFFSET) > >> +#define BCM2836_MBOX_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_MBOX_OFFSET) > >> #define BCM2836_MBOX_READ_OFFSET 0x00000000 > >> #define BCM2836_MBOX_STATUS_OFFSET 0x00000018 > >> #define BCM2836_MBOX_CONFIG_OFFSET 0x0000001c > >> @@ -51,12 +49,19 @@ > >> #define BCM2836_INTC_TIMER_PENDING_OFFSET 0x00000060 > >> > >> /* random number generator */ > >> -#define RNG_BASE_ADDRESS (BCM2836_SOC_REGISTERS + 0x00104000) > >> +#define BCM2836_RNG_OFFSET 0x00104000 > >> +#define RNG_BASE_ADDRESS (BCM2836_SOC_REGISTERS + BCM2836_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 (RNG_BASE_ADDRESS + 0x0) > >> +#define RNG_STATUS (RNG_BASE_ADDRESS + 0x4) > >> +#define RNG_DATA (RNG_BASE_ADDRESS + 0x8) > >> +#define RNG_BIT_COUNT (RNG_BASE_ADDRESS + 0xc) > >> +#define RNG_BIT_COUNT_THRESHOLD (RNG_BASE_ADDRESS + 0x10) > >> +#define RNG_INT_STATUS (RNG_BASE_ADDRESS + 0x18) > >> +#define RNG_INT_ENABLE (RNG_BASE_ADDRESS + 0x1c) > >> +#define RNG_FIFO_DATA (RNG_BASE_ADDRESS + 0x20) > >> +#define RNG_FIFO_COUNT (RNG_BASE_ADDRESS + 0x24) > >> > >> -#define RNG_CTRL_ENABLE 0x1 > >> +#define RNG_CTRL_ENABLE 0x1 > >> > >> #endif /*__BCM2836_H__ */ > >> -- > >> 2.21.0.windows.1 > >> >