soft_i2c and ds1307 with tqm823l
Hi,
I'm working on getting a ds1307 realtime clock working with a tqm823l as a new user to u-boot (I've never compiled u-boot or ppcboot before).
I'd like to make some improvements to the README which is already excellent but seems to have a couple of omissions, particularly regarding the configuration of u-boot to work with i2c.
Firstly, the ds1307 code compiles fine, but of course it needs the i2c code to be compiled alongside it. Although this is obvious, the newcomer to u-boot doesn't (i.e. I didn't) know that calling for ds1307.c to be compiled doesn't in itself cause the i2c code to be compiled, so a note to this effect in the realtime clock section of the README would be a helpful addition.
Now, in trying to get I2C properly compiled, I find quite a lot of information about I2C setup in the README.
Here's a line from the README (starting at line 907):
"If this is selected, either CONFIG_HARD_I2C or CONFIG_SOFT_I2C must
be defined to include the appropriate I2C driver."
No mention is made of what values the 'appropriate driver' might have or where to look for them. I assume you might define something like this:
#define CONFIG_HARD_I2C mpc8xx
But I can't see what you'd write for CONFIG_SOFT_I2C. A bit more clarification here would be useful.
There are a number of extra defines related to CONFIG_SOFT_I2C, such as I2C_INIT, I2C_PORT, etc. It's not too clear what these should be set to. The diff between my TQM823L.h and the original TQM823L.h is (also attached as changes.diff):
Some investigation has shown that I need to set I2C_SDA and I2C_SCL to the name of the correct functions. What are the possibilities for these? The same seems to be true of I2C_READ.
What are the units for I2C_DELAY? I'm assuming seconds. Why is there both I2C_DELAY and CFG_I2C_SPEED to configure? These seem to configure the same thing - the speed of the I2C clock line.
Ok, I think that should be enough for now,
best regards,
Seb James.
Just a couple of edits to my posting.
Quoted 5 lines · Seb James
Hi,
I'm working on getting a ds1307 realtime clock working with a tqm823l as a new user to u-boot (I've never compiled u-boot or ppcboot before).
Quoted 7 lines
I'd like to make some improvements to the README which is already excellent but seems to have a couple of omissions, particularly regarding the configuration of u-boot to work with i2c.
Firstly, the ds1307 code compiles fine, but of course it needs the i2c code to be compiled alongside it...
...in order to be able to link it into the u-boot image.
Quoted 21 lines
Although this is obvious, the newcomer
to u-boot doesn't (i.e. I didn't) know that calling fords1307.cto be compiled doesn't in itself cause the i2c code to be compiled, so a note to this effect in the realtime clock section of the README would be a helpful addition.Now, in trying to get I2C properly compiled, I find quite a lot of information about I2C setup in the README.
Here's a line from the README (starting at line 907):
"If this is selected, either
CONFIG_HARD_I2CorCONFIG_SOFT_I2Cmust
be defined to include the appropriate I2C driver."No mention is made of what values the 'appropriate driver' might have or where to look for them. I assume you might define something like this:
Quoted 7 lines
#define
CONFIG_HARD_I2Cmpc8xxBut I can't see what you'd write for
CONFIG_SOFT_I2C. A bit more clarification here would be useful.There are a number of extra defines related to
CONFIG_SOFT_I2C, such asI2C_INIT,I2C_PORT, etc. It's not too clear what these should be set to.
Regarding this line:
Quoted 2 lines
The diff between my
TQM823L.hand the originalTQM823L.his (also attached as changes.diff):
sorry - the diff wasn't attached, this line shouldn't have been in the posting. I was going to do this and then decided it wasn't necessary.
Quoted 31 lines
Some investigation has shown that I need to set
I2C_SDAandI2C_SCLto the name of the correct functions. What are the possibilities for these? The same seems to be true ofI2C_READ.What are the units for
I2C_DELAY? I'm assuming seconds. Why is there bothI2C_DELAYandCFG_I2C_SPEEDto configure? These seem to configure the same thing - the speed of the I2C clock line.Ok, I think that should be enough for now,
best regards,
Seb James.
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Some investigation has shown that I need to set
I2C_SDAandI2C_SCLto the name of the correct functions. What are the possibilities for these? The same seems to be true ofI2C_READ.
These are macros that define code (think of inline functions) to set the SDA resp. SCL port pin to high (bit=1) or low (bit-0). I2C_READ will read the state of the SDA port pin.
Isn't this obvious from the sources?
Quoted 1 line
Quoted 1 line
What are the units for
I2C_DELAY? I'm assuming seconds. Why is there
Again, see the source code. A definition like this should be self-explainatory:
#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */
Quoted 2 lines
Quoted 2 lines
both
I2C_DELAYandCFG_I2C_SPEEDto configure? These seem to configure the same thing - the speed of the I2C clock line.
Hysterical reasons. I2C_DELAY => soft_i2c, CFG_I2C_SPEED => hard-i2c
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
A dog always bit deepest on the veterinary hand.
- Terry Pratchett, _Wyrd Sisters_Dear Seb,
Quoted 3 lines · in message <[email protected]> you wrote:
I'm working on getting a ds1307 realtime clock working with a tqm823l as a new user to u-boot (I've never compiled u-boot or ppcboot before).
This is not correct. You compiled and installed PPCBoot in our training a year and a couple of days ago :-)
Quoted 6 lines
Firstly, the ds1307 code compiles fine, but of course it needs the i2c code to be compiled alongside it. Although this is obvious, the newcomer to u-boot doesn't (i.e. I didn't) know that calling for
ds1307.cto be compiled doesn't in itself cause the i2c code to be compiled, so a note to this effect in the realtime clock section of the README would be a helpful addition.
Please feel free to submit a patch...
Quoted 10 lines
Here's a line from the README (starting at line 907):
"If this is selected, either
CONFIG_HARD_I2CorCONFIG_SOFT_I2Cmust
be defined to include the appropriate I2C driver."No mention is made of what values the 'appropriate driver' might have or where to look for them. I assume you might define something like this:
#define
CONFIG_HARD_I2Cmpc8xx
No. Just "#define CONFIG_HARD_I2C" is OK, as for each CPU there is always exactly one hard-i2c and one soft-i2c driver.
Quoted 2 lines
But I can't see what you'd write for
CONFIG_SOFT_I2C. A bit more clarification here would be useful.
Just:
#define CONFIG_SOFT_I2C
It must be defined - that's all :-)
Quoted 4 lines
There are a number of extra defines related to
CONFIG_SOFT_I2C, such asI2C_INIT,I2C_PORT, etc. It's not too clear what these should be set to. The diff between myTQM823L.hand the originalTQM823L.his (also attached as changes.diff):
No diff attached.
Best regards,
Wolfgang Denk
Signature · 6 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies and the other is to make it so complicated that there are no obvious defi- ciencies. - Charles Anthony Richard Hoare
Thanks for the help Wolfgang,
Quoted 5 lines · Wolfgang Denk
Dear Seb,
in message <[email protected]> you wrote:
Quoted 9 lines
Quoted 4 lines
I'm working on getting a ds1307 realtime clock working with a tqm823l as a new user to u-boot (I've never compiled u-boot or ppcboot before).
This is not correct. You compiled and installed PPCBoot in our training a year and a couple of days ago :-)
That's true. Ok, not for a while though...
Quoted 11 lines
Quoted 10 lines
Firstly, the ds1307 code compiles fine, but of course it needs the i2c code to be compiled alongside it. Although this is obvious, the newcomer to u-boot doesn't (i.e. I didn't) know that calling for
ds1307.cto be compiled doesn't in itself cause the i2c code to be compiled, so a note to this effect in the realtime clock section of the README would be a helpful addition.
Quoted 3 lines
Please feel free to submit a patch...
Yes, I'll do that when I'm sure I think there needs to be one and what it should be :)
Quoted 25 lines
Quoted 4 lines
Here's a line from the README (starting at line 907):
Quoted 10 lines
"If this is selected, either
CONFIG_HARD_I2CorCONFIG_SOFT_I2Cmust
be defined to include the appropriate I2C driver."No mention is made of what values the 'appropriate driver' might have or where to look for them. I assume you might define something like this:
#define
CONFIG_HARD_I2Cmpc8xxNo. Just "#define
CONFIG_HARD_I2C" is OK, as for each CPU there is always exactly one hard-i2c and one soft-i2c driver.Quoted 4 lines
But I can't see what you'd write for
CONFIG_SOFT_I2C. A bit more clarification here would be useful.
Quoted 7 lines
Just:
#define CONFIG_SOFT_I2CIt must be defined - that's all :-)
Ok, well I've successfully compiled with CONFIG_HARD_I2C and have communicated with my clock, so that is good. Next up is transferring the date in u-boot to linux, but I'm sure that will be documented somewhere.
As for CONFIG_SOFT_I2C; Attached (really this time) is a diff between the original u-boot-0.4.0/include/configs/TQM823L.h and the one that I have altered. The compile of soft_i2c.c fails with the following error messages:
ppc_8xx-gcc -g -Os -mrelocatable -ffixed-r14 -meabi -D__KERNEL__
-DTEXT_BASE=0x40000000 -I/eldk/ppc_8xx/usr/src/u-boot-0.4.0/include -fno-builtin -nostdinc -isystem /eldk/usr/lib/gcc-lib/ppc-linux/2.95.4/include -pipe -DCONFIG_PPC -D__powerpc__ -DCONFIG_8xx -ffixed-r2 -ffixed-r29 -mstring -mcpu=860 -msoft-float -Wall -Wstrict-prototypes -c -o soft_i2c.o soft_i2c.c soft_i2c.c: In function `send_reset':
soft_i2c.c:86: warning: implicit declaration of function I2C_SCL' soft_i2c.c:87: warning: implicit declaration of function I2C_SDA' soft_i2c.c:91: `I2C_TRISTATE' undeclared (first use in this function) soft_i2c.c:91: (Each undeclared identifier is reported only once soft_i2c.c:91: for each function it appears in.)
soft_i2c.c:94: I2C_DELAY' undeclared (first use in this function) soft_i2c.c:82: warning: unused variable immr'soft_i2c.c: In function `send_start':
soft_i2c.c:116: I2C_DELAY' undeclared (first use in this function) soft_i2c.c:118: I2C_ACTIVE' undeclared (first use in this function) soft_i2c.c:113: warning: unused variable `immr'soft_i2c.c: In function `send_stop':
soft_i2c.c:139: I2C_DELAY' undeclared (first use in this function) soft_i2c.c:141: I2C_ACTIVE' undeclared (first use in this function) soft_i2c.c:147: I2C_TRISTATE' undeclared (first use in this function) soft_i2c.c:135: warning: unused variable immr'soft_i2c.c: In function `send_ack':
soft_i2c.c:163: I2C_ACTIVE' undeclared (first use in this function) soft_i2c.c:165: I2C_DELAY' undeclared (first use in this function) soft_i2c.c:160: warning: unused variable `immr'soft_i2c.c: In function `write_byte':
soft_i2c.c:193: I2C_ACTIVE' undeclared (first use in this function) soft_i2c.c:196: I2C_DELAY' undeclared (first use in this function) soft_i2c.c:212: I2C_TRISTATE' undeclared (first use in this function) soft_i2c.c:217: I2C_READ' undeclared (first use in this function) soft_i2c.c:188: warning: unused variable `immr'
soft_i2c.c:191: warning: nack' might be used uninitialized in this function soft_i2c.c: In function read_byte':
soft_i2c.c:244: I2C_TRISTATE' undeclared (first use in this function) soft_i2c.c:248: I2C_DELAY' undeclared (first use in this function) soft_i2c.c:252: I2C_READ' undeclared (first use in this function) soft_i2c.c:236: warning: unused variable immr'
make[1]: *** [soft_i2c.o] Error 1
make[1]: Leaving directory `/eldk/ppc_8xx/usr/src/u-boot-0.4.0/common'
make: *** [subdirs] Error 1
[seb at mst26 u-boot-0.4.0]$
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: changes.diff
Url: http://lists.denx.de/pipermail/u-boot/attachments/20030630/a532463b/attachment.txt
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 5 lines
This is not correct. You compiled and installed PPCBoot in our training a year and a couple of days ago :-)
That's true. Ok, not for a while though...
:-)
Quoted 4 lines
Quoted 2 lines
Please feel free to submit a patch...
Yes, I'll do that when I'm sure I think there needs to be one and what it should be :)
There shouldbe one. You asked these questions after all - prrof that such an explanation is needed.
Quoted 3 lines
Ok, well I've successfully compiled with
CONFIG_HARD_I2Cand have communicated with my clock, so that is good. Next up is transferring the date in u-boot to linux, but I'm sure that will be documented somewhere.
You don't "transfer" the daye. Linux will pick it up itself (which requires an RTC driver and eventually some modifications).
Quoted 4 lines
As for
CONFIG_SOFT_I2C; Attached (really this time) is a diff between the originalu-boot-0.4.0/include/configs/TQM823L.hand the one that I have altered. The compile ofsoft_i2c.cfails with the following error messages:
That's because you did not define the required macros (see for example the configuration in lwmon.h).
Best regards,
Wolfgang Denk
Signature · 3 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de Life is a game. Money is how we keep score. - Ted Turner
Wolfgang Denk wrote:
[ snip ]
Quoted 9 lines
Quoted 5 lines
Ok, well I've successfully compiled with
CONFIG_HARD_I2Cand have communicated with my clock, so that is good. Next up is transferring the date in u-boot to linux, but I'm sure that will be documented somewhere.You don't "transfer" the daye. Linux will pick it up itself (which requires an RTC driver and eventually some modifications).
Let me check that I understand: As far as I can see the u-boot realtime clock drivers just allow you to set and read the time from the u-boot command line; a useful utility. If linux is to read the time from the realtime clock it must have a realtime clock driver of its own; there's no way that u-boot can pass the time to linux at boot time? (Of course, this would be fraught with difficulties, because depending on how fast your cpu boots linux, a different amount of time would elapse before linux could actually do something with the passed date stamp).
So, next up for me is to write a linux driver for the ds1307. I was actually in the middle of that before getting sidetracked by the u-boot rtc code. However, the u-boot code has enabled me to hardware debug my realtime clock circuit, so that was very useful. Has anyone written a linux driver for the ds1307 or similar? (I'm cross posting to the linuxppc-embedded list to ask this question).
Quoted 11 lines
Quoted 6 lines
As for
CONFIG_SOFT_I2C; Attached (really this time) is a diff between the originalu-boot-0.4.0/include/configs/TQM823L.hand the one that I have altered. The compile ofsoft_i2c.cfails with the following error messages:That's because you did not define the required macros (see for example the configuration in
lwmon.h).
Right, so it's not the case that you just #define CONFIG_SOFT_I2C; you have to correctly define the macros. I shall do some work on the readme and post a diff later on. Thanks for the pointers.
best,
Seb
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Dear Seb,
Quoted 4 lines · in message <[email protected]> you wrote:
command line; a useful utility. If linux is to read the time from the realtime clock it must have a realtime clock driver of its own; there's no way that u-boot can pass the time to linux at boot time? (Of course,
Correct.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: [email protected] Old programmers never die, they just become managers.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 5 lines · Wolfgang Denk
Dear Seb,
in message <[email protected]> you wrote:
Quoted 10 lines
Quoted 5 lines
command line; a useful utility. If linux is to read the time from the realtime clock it must have a realtime clock driver of its own; there's no way that u-boot can pass the time to linux at boot time? (Of course,
Correct.
Ok. Here is a diff (created as specified in the README) of the README. The old file is the README file that came in the u-boot-0.4.0 tarball. The changes that I've made are some extra information to help someone to add i2c and realtime clock support to u-boot.
Seb.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ssj_readme.diff
Url: http://lists.denx.de/pipermail/u-boot/attachments/20030630/118b6bfe/attachment.txt
Quoted 3 lines · In message <[email protected]> you wrote:
Ok. Here is a diff (created as specified in the README) of the README. The old file is the README file that came in the u-boot-0.4.0 tarball.
Thanks, added.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de While money can't buy happiness, it certainly lets you choose your own form of misery.