[U-Boot] [PATCH] Add support for Faraday RTC IP FTRTC

Dear Wolfgang Denk,
I am a newbie and I have not realized all the rules, so I have some questions.
On Tue Mar 31 12:24:03 CEST 2009, you wrote:
+static unsigned int rtc = CONFIG_SYS_RTC_BASE;
Please use a proper C structure to describe the RTC; do not use base address plus offsets.
Do you mean U-Boot prefers to use structure to describe registers? What if there were large gaps between registers?
For example, in our ethernet IP FTMAC100, there is nothing in 0x34 - 0x84, 0xa0 - 0xc0. Should I use structure to describe it?
I thought that placing a lot of paddings in a structure is ulgy. How do you think? Is there a guideline about this?
Also in drivers/rtc/pl031.c, the RTC_WRITE_REG and RTC_READ_REG use base + offset.
outl() is not portable across architectures? inl() is not portable across architectures?
Sorry I don't understand.
There are outl() and inl() in most architectures except blackfin, i386 and sparc. And the outl() and the inl() I use are arm ones.
Which macros should I use?
- debug("rtc_get(): record register: %x\n", inl(rtc + FTRTC_OFFSET_RECORD));
Line too long.
Sorry, this is my fault. I will fix them.
Best Regards,
Po-Yu Chuang (莊博宇) === Faraday Technology Corporation, Headquarters TW === = 智原科技股份有限公司 = Dept.: CTD/SD/SSD = Tel : 886-3-578-7888 Ext:8818 = Fax : 886-3-666-3958 = Email: ratbert@faraday-tech.com = WWW : www.faraday-tech.com =======================================================
********************* Confidentiality Notice ************************ This electronic message and any attachments may contain confidential and legally privileged information or information which is otherwise protected from disclosure. If you are not the intended recipient,please do not disclose the contents, either in whole or in part, to anyone,and immediately delete the message and any attachments from your computer system and destroy all hard copies. Thank you for your cooperation. ***********************************************************************

Hi Chuang,
I am a newbie and I have not realized all the rules, so I have some questions.
On Tue Mar 31 12:24:03 CEST 2009, you wrote:
+static unsigned int rtc = CONFIG_SYS_RTC_BASE;
Please use a proper C structure to describe the RTC; do not use base address plus offsets.
Do you mean U-Boot prefers to use structure to describe registers?
Yes, we prefer to have this, as we then also let the compiler do for example type checking.
What if there were large gaps between registers?
Use dummy variables.
For example, in our ethernet IP FTMAC100, there is nothing in 0x34 - 0x84, 0xa0 - 0xc0. Should I use structure to describe it?
Yes please, use for example u32 dummy1[20] for the first gap and u32 dummy2[8] for the second.
I thought that placing a lot of paddings in a structure is ulgy. How do you think? Is there a guideline about this?
We are our own guideline ;)
No, seriously, we try to use structures wherever possible as a means to get more information to the compiler. It also helps preventing stupid errors like having one incorrect offset in a list of 40 defines which are *very* hard to catch.
Also in drivers/rtc/pl031.c, the RTC_WRITE_REG and RTC_READ_REG use base + offset.
outl() is not portable across architectures? inl() is not portable across architectures?
Sorry I don't understand.
There are outl() and inl() in most architectures except blackfin, i386 and sparc. And the outl() and the inl() I use are arm ones.
Which macros should I use?
We should really use macros specifying the expected-byteorder, i.e. in_be32, or out_le32, and so on. Using these macros, we can write drivers even being agnostic on the cpu byte ordering if the device stays the same. (Ok, ok, outl also infers a byte-ordering, but we like more expliciteness).
- debug("rtc_get(): record register: %x\n", inl(rtc + FTRTC_OFFSET_RECORD));
Line too long.
Sorry, this is my fault. I will fix them.
Thanks! Detlev

Hi Detlev Zundel,
Thanks for your kindly help.
I will fix my code and submit again next time.
Thank you!
regards,
Po-Yu Chuang
2009/4/2 Detlev Zundel dzu@denx.de:
Hi Chuang,
I am a newbie and I have not realized all the rules, so I have some questions.
On Tue Mar 31 12:24:03 CEST 2009, you wrote:
+static unsigned int rtc = CONFIG_SYS_RTC_BASE;
Please use a proper C structure to describe the RTC; do not use base address plus offsets.
Do you mean U-Boot prefers to use structure to describe registers?
Yes, we prefer to have this, as we then also let the compiler do for example type checking.
What if there were large gaps between registers?
Use dummy variables.
For example, in our ethernet IP FTMAC100, there is nothing in 0x34 - 0x84, 0xa0 - 0xc0. Should I use structure to describe it?
Yes please, use for example u32 dummy1[20] for the first gap and u32 dummy2[8] for the second.
I thought that placing a lot of paddings in a structure is ulgy. How do you think? Is there a guideline about this?
We are our own guideline ;)
No, seriously, we try to use structures wherever possible as a means to get more information to the compiler. It also helps preventing stupid errors like having one incorrect offset in a list of 40 defines which are *very* hard to catch.
Also in drivers/rtc/pl031.c, the RTC_WRITE_REG and RTC_READ_REG use base + offset.
outl() is not portable across architectures? inl() is not portable across architectures?
Sorry I don't understand.
There are outl() and inl() in most architectures except blackfin, i386 and sparc. And the outl() and the inl() I use are arm ones.
Which macros should I use?
We should really use macros specifying the expected-byteorder, i.e. in_be32, or out_le32, and so on. Using these macros, we can write drivers even being agnostic on the cpu byte ordering if the device stays the same. (Ok, ok, outl also infers a byte-ordering, but we like more expliciteness).
- debug("rtc_get(): record register: %x\n", inl(rtc + FTRTC_OFFSET_RECORD));
Line too long.
Sorry, this is my fault. I will fix them.
Thanks! Detlev
-- I just found out that the brain is like a computer. If that's true, then there really aren't any stupid people. Just people running Windows. -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu@denx.de _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
participants (3)
-
Detlev Zundel
-
Po-Yu Chuang
-
Ratbert Po-Yu Chuang(莊博宇)