diff mbox series

[U-Boot,11/45] rtc: Allow use of RTC in SPL and TPL

Message ID 20181001182249.129565-12-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show
Series Various fixes and improvements | expand

Commit Message

Simon Glass Oct. 1, 2018, 6:22 p.m. UTC
Add Kconfig options so that the RTC can be used in SPL and TPL. This is
helpful for accessing the contents of CMOS RAM, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/rtc/Kconfig      | 18 ++++++++++++++++++
 drivers/rtc/Makefile     |  2 +-
 drivers/rtc/rtc-uclass.c |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

Comments

Simon Glass Oct. 9, 2018, 11:55 p.m. UTC | #1
Add Kconfig options so that the RTC can be used in SPL and TPL. This is
helpful for accessing the contents of CMOS RAM, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/rtc/Kconfig      | 18 ++++++++++++++++++
 drivers/rtc/Makefile     |  2 +-
 drivers/rtc/rtc-uclass.c |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

Applied to u-boot-dm
Heinrich Schuchardt Oct. 11, 2018, 7:21 p.m. UTC | #2
On 10/01/2018 08:22 PM, Simon Glass wrote:
> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
> helpful for accessing the contents of CMOS RAM, for example.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

Hello Simon,

with this patch x86_64 does not boot anymore:
$ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
### ERROR ### Please RESET the board ###

I am currently testing Bin's patch series:
https://patchwork.ozlabs.org/project/uboot/list/?series=70127
[U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper

> 
>  drivers/rtc/Kconfig      | 18 ++++++++++++++++++
>  drivers/rtc/Makefile     |  2 +-
>  drivers/rtc/rtc-uclass.c |  1 +
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 97cf7d84dfa..bcc01b135e5 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -13,6 +13,24 @@ config DM_RTC
>  	  drivers to perform the actual functions. See rtc.h for a
>  	  description of the API.
>  
> +config SPL_DM_RTC
> +	bool "Enable Driver Model for RTC drivers in SPL"
> +	depends on SPL_DM
> +	help
> +	  Enable drver model for real-time-clock drivers. The RTC uclass
> +	  then provides the rtc_get()/rtc_set() interface, delegating to
> +	  drivers to perform the actual functions. See rtc.h for a
> +	  description of the API.
> +
> +config TPL_DM_RTC
> +	bool "Enable Driver Model for RTC drivers in TPL"
> +	depends on TPL_DM
> +	help
> +	  Enable drver model for real-time-clock drivers. The RTC uclass
> +	  then provides the rtc_get()/rtc_set() interface, delegating to
> +	  drivers to perform the actual functions. See rtc.h for a
> +	  description of the API.
> +
>  config RTC_PCF2127
>  	bool "Enable PCF2127 driver"
>  	depends on DM_RTC
> diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> index 513e3ffc079..1724602f1cb 100644
> --- a/drivers/rtc/Makefile
> +++ b/drivers/rtc/Makefile
> @@ -4,7 +4,7 @@
>  # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
>  #ccflags-y += -DDEBUG
>  
> -obj-$(CONFIG_DM_RTC) += rtc-uclass.o
> +obj-$(CONFIG_$(SPL_TPL_)DM_RTC) += rtc-uclass.o

This is the line to be reverted.

Best regards

Heinrich

>  
>  obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
>  obj-y += date.o
> diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
> index c676f0ff359..a0a238aedda 100644
> --- a/drivers/rtc/rtc-uclass.c
> +++ b/drivers/rtc/rtc-uclass.c
> @@ -122,4 +122,5 @@ int rtc_write32(struct udevice *dev, unsigned int reg, u32 value)
>  UCLASS_DRIVER(rtc) = {
>  	.name		= "rtc",
>  	.id		= UCLASS_RTC,
> +	.post_bind	= dm_scan_fdt_dev,
>  };
>
Heinrich Schuchardt Oct. 11, 2018, 7:56 p.m. UTC | #3
On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
> 
> On 10/01/2018 08:22 PM, Simon Glass wrote:
>> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
>> helpful for accessing the contents of CMOS RAM, for example.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
> 
> Hello Simon,
> 
> with this patch x86_64 does not boot anymore:
> $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
> ### ERROR ### Please RESET the board ###
> 
> I am currently testing Bin's patch series:
> https://patchwork.ozlabs.org/project/uboot/list/?series=70127
> [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
> 

As a workaround for qemu-x86_defconfig I have sent a patch changing that
single configuration file. But your patch may have broken more boards.

https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
x86: qemu: enable CONFIG_SPL_DM_RTC

Regards

Heinrich
Bin Meng Oct. 13, 2018, 2:46 a.m. UTC | #4
Hi Heinrich,

On Fri, Oct 12, 2018 at 3:56 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
> >
> > On 10/01/2018 08:22 PM, Simon Glass wrote:
> >> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
> >> helpful for accessing the contents of CMOS RAM, for example.
> >>
> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> ---
> >
> > Hello Simon,
> >
> > with this patch x86_64 does not boot anymore:
> > $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
> > ### ERROR ### Please RESET the board ###
> >
> > I am currently testing Bin's patch series:
> > https://patchwork.ozlabs.org/project/uboot/list/?series=70127
> > [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
> >
>
> As a workaround for qemu-x86_defconfig I have sent a patch changing that
> single configuration file. But your patch may have broken more boards.
>

Thanks for checking.

> https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
> x86: qemu: enable CONFIG_SPL_DM_RTC

Simon, can you take a look at this? Whether I should take Heinrich's
patch directly, or you will re-work the original RTC patch?

Regards,
Bin
Simon Glass Oct. 19, 2018, 3:25 a.m. UTC | #5
Hi Bin,

On 12 October 2018 at 20:46, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Heinrich,
>
> On Fri, Oct 12, 2018 at 3:56 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
>> >
>> > On 10/01/2018 08:22 PM, Simon Glass wrote:
>> >> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
>> >> helpful for accessing the contents of CMOS RAM, for example.
>> >>
>> >> Signed-off-by: Simon Glass <sjg@chromium.org>
>> >> Signed-off-by: Simon Glass <sjg@chromium.org>
>> >> ---
>> >
>> > Hello Simon,
>> >
>> > with this patch x86_64 does not boot anymore:
>> > $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
>> > ### ERROR ### Please RESET the board ###
>> >
>> > I am currently testing Bin's patch series:
>> > https://patchwork.ozlabs.org/project/uboot/list/?series=70127
>> > [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
>> >
>>
>> As a workaround for qemu-x86_defconfig I have sent a patch changing that
>> single configuration file. But your patch may have broken more boards.
>>
>
> Thanks for checking.
>
>> https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
>> x86: qemu: enable CONFIG_SPL_DM_RTC
>
> Simon, can you take a look at this? Whether I should take Heinrich's
> patch directly, or you will re-work the original RTC patch?

I think Heinrich's patch is good.

I don't believe any boards that use DM_RTC are using it in SPL. My
reasoning is that this line would likely cause a build error for such
boards, since they probably don't use DT:

+       .post_bind      = dm_scan_fdt_dev,

Regards,
Simon
Bin Meng Oct. 19, 2018, 4:20 a.m. UTC | #6
Hi Simon,

On Fri, Oct 19, 2018 at 11:25 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On 12 October 2018 at 20:46, Bin Meng <bmeng.cn@gmail.com> wrote:
> > Hi Heinrich,
> >
> > On Fri, Oct 12, 2018 at 3:56 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> >>
> >> On 10/11/2018 09:21 PM, Heinrich Schuchardt wrote:
> >> >
> >> > On 10/01/2018 08:22 PM, Simon Glass wrote:
> >> >> Add Kconfig options so that the RTC can be used in SPL and TPL. This is
> >> >> helpful for accessing the contents of CMOS RAM, for example.
> >> >>
> >> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> >> ---
> >> >
> >> > Hello Simon,
> >> >
> >> > with this patch x86_64 does not boot anymore:
> >> > $ qemu-system-x86_64 -bios u-boot.rom -nographic --enable-kvm --cpu host
> >> > ### ERROR ### Please RESET the board ###
> >> >
> >> > I am currently testing Bin's patch series:
> >> > https://patchwork.ozlabs.org/project/uboot/list/?series=70127
> >> > [U-Boot,1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper
> >> >
> >>
> >> As a workaround for qemu-x86_defconfig I have sent a patch changing that
> >> single configuration file. But your patch may have broken more boards.
> >>
> >
> > Thanks for checking.
> >
> >> https://lists.denx.de/pipermail/u-boot/2018-October/344137.html
> >> x86: qemu: enable CONFIG_SPL_DM_RTC
> >
> > Simon, can you take a look at this? Whether I should take Heinrich's
> > patch directly, or you will re-work the original RTC patch?
>
> I think Heinrich's patch is good.
>

Thanks for the confirmation. I will take Heinrich's patch then.

> I don't believe any boards that use DM_RTC are using it in SPL. My
> reasoning is that this line would likely cause a build error for such
> boards, since they probably don't use DT:
>
> +       .post_bind      = dm_scan_fdt_dev,
>

Regards,
Bin
diff mbox series

Patch

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 97cf7d84dfa..bcc01b135e5 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -13,6 +13,24 @@  config DM_RTC
 	  drivers to perform the actual functions. See rtc.h for a
 	  description of the API.
 
+config SPL_DM_RTC
+	bool "Enable Driver Model for RTC drivers in SPL"
+	depends on SPL_DM
+	help
+	  Enable drver model for real-time-clock drivers. The RTC uclass
+	  then provides the rtc_get()/rtc_set() interface, delegating to
+	  drivers to perform the actual functions. See rtc.h for a
+	  description of the API.
+
+config TPL_DM_RTC
+	bool "Enable Driver Model for RTC drivers in TPL"
+	depends on TPL_DM
+	help
+	  Enable drver model for real-time-clock drivers. The RTC uclass
+	  then provides the rtc_get()/rtc_set() interface, delegating to
+	  drivers to perform the actual functions. See rtc.h for a
+	  description of the API.
+
 config RTC_PCF2127
 	bool "Enable PCF2127 driver"
 	depends on DM_RTC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 513e3ffc079..1724602f1cb 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -4,7 +4,7 @@ 
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #ccflags-y += -DDEBUG
 
-obj-$(CONFIG_DM_RTC) += rtc-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)DM_RTC) += rtc-uclass.o
 
 obj-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
 obj-y += date.o
diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c
index c676f0ff359..a0a238aedda 100644
--- a/drivers/rtc/rtc-uclass.c
+++ b/drivers/rtc/rtc-uclass.c
@@ -122,4 +122,5 @@  int rtc_write32(struct udevice *dev, unsigned int reg, u32 value)
 UCLASS_DRIVER(rtc) = {
 	.name		= "rtc",
 	.id		= UCLASS_RTC,
+	.post_bind	= dm_scan_fdt_dev,
 };