Return-Path: Received: from web50703.mail.yahoo.com (web50703.mail.yahoo.com [206.190.38.101]) by ozlabs.org (Postfix) with SMTP id D007767E51 for ; Tue, 14 Nov 2006 10:40:22 +1100 (EST) Message-ID: <20061113233340.65403.qmail@web50703.mail.yahoo.com> Date: Mon, 13 Nov 2006 15:33:40 -0800 (PST) From: "Aniket D." Subject: RTC DS1340 on MPC 8245 - problem To: linuxppc-dev@ozlabs.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-2075033525-1163460820=:64193" List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --0-2075033525-1163460820=:64193 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable =0AProblem:=0A=0AWhen processor dependent macros are =0Aset to use RTC ie (= ppc_md.set_rtc_time =3D mydriver_set_rtc; ppc_md.get_rtc_time =3D =0Amydriv= er_get_rtc_time;), then the scheduler gets messed up and prints a message = =0A=93scheduling when atomic=94.=0A=0ASystem time is not synced to RTC =0At= ime.=0A=0A =0A=0ADetails:=0A=0AProcessor: =0AMPC8245=0A=0AKernel version: L= inux =0A2.6.14=0A=0ARTC chip: DS1340 (I2c =0Abased)=0A=0ADriver used: Stand= ard kernel version =0A2.6.17 or later has a driver for RTC DS1340. I ported= it to work with our =0Aversion of the kernel. So it is the driver provided= by later version of the =0Astandard kernel.=0A=0A =0A=0AI have added the d= river and the read =0Aand write to the RTC works fine. Time that is set to = the rtc remains on the RTC =0Aeven through successive reboots. So the drive= r is working =0Afine.=0A=0AHowever we needed to sync the system =0Atime wit= h the RTC. For this purpose, I tried to use the drivers/rtc/hctosys.c =0Aco= de. This code reads the time from the RTC during bootup, and does a =0Ado_s= ettimeofday so that system time reflects the time in the RTC. However, with= =0Athis change, as soon as settimeofday happens, I read it back, it displa= ys the =0Acorrect time (same as RTC), but after system boots up, the system= time is messed =0Aup again. =0A=0A =0A=0AAnother thing that I changed was = the =0Appc_md.get_rtc_time and ppc_md.set_rtc_time =96 these function point= ers were =0Apointed to my driver=92s get_rtc_time and =0Aset_rtc_time.=0A= =0A =0A=0AIn the same function, =0Appc_md.calibrate_decr is set to initiali= ze the decrementer register. However the =0Appc_md.time_init has still not = been set. I looked up MPC8349 example and they =0Aare enabling the =91time = base=92 in this function. However for 8245 the time base =0Aenable is not a= bit in a register, but it is a signal. So does the =0Appc_md.time_init nee= d to be pointed to some function =96 what should that function =0Ado? Is it= needed at all?=0A=0AAlso, having set the =0Appc_md.calibrate_decr, ppc_md.= get_rtc_time and ppc_md.set_rtc_time, when the =0Asystem boots up, the sche= duler prints a message that says =93scheduling when =0Aatomic=94 and the sy= stem doesn=92t boot beyond this =0Apoint.=0A=0A =0A=0AI have set these ppc_= md function =0Apointers late during the bootup because it depends on initia= lization of the RTC =0Adriver before these pointers are set. =0A=0A =0A=0AN= ow as I understand, before the RTC =0Ais available, the processor uses the = decrementer register to keep time for the =0Ascheduler. When the ppc_md.get= /set_rtc_time are set, the processor starts using =0Athe RTC to keep time. = However the point where the handover from decrementer to =0ARTC happens is = the point where the scheduler gets messed up. =0A=0A=0A =0A=0ACan you pleas= e guide me as to what =0Ais the right way for me to use the RTC. Which are = the places other than the =0Adriver that I need to modify/add?=0A=0A =0A=0A= Thanks,=0A=0AAniket.=0A=0A=0A=0A=0A=0A =0A_________________________________= ___________________________________________________=0ADo you Yahoo!?=0AEver= yone is raving about the all-new Yahoo! Mail beta.=0Ahttp://new.mail.yahoo.= com --0-2075033525-1163460820=:64193 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable
=0A

Problem:

=0A

When processor dependent macros are =0Aset to use RTC ie (ppc_md.set_rt= c_time =3D mydriver_set_rtc; ppc_md.get_rtc_time =3D =0Amydriver_get_rtc_ti= me;), then the scheduler gets messed up and prints a message =0A=93scheduli= ng when atomic=94.

=0A

System time is not synced to RTC =0Atime.<= /p>=0A

 

= =0A

Details:

= =0A

Processor: =0AMPC8245=

=0A

Kernel version: Linux =0A2.6= .14

=0A

RTC chi= p: DS1340 (I2c =0Abased)

=0A

Driver used: Standard kernel version =0A2.6.17 or later has a= driver for RTC DS1340. I ported it to work with our =0Aversion of the kern= el. So it is the driver provided by later version of the =0Astandard kernel= .

=0A

&nbs= p;

=0A

I have added = the driver and the read =0Aand write to the RTC works fine. Time that is se= t to the rtc remains on the RTC =0Aeven through successive reboots. So the = driver is working =0Afine.

=0A

However we needed to sync the system =0Atime with the RTC. = For this purpose, I tried to use the drivers/rtc/hctosys.c =0Acode. This co= de reads the time from the RTC during bootup, and does a =0Ado_settimeofday= so that system time reflects the time in the RTC. However, with =0Athis ch= ange, as soon as settimeofday happens, I read it back, it displays the =0Ac= orrect time (same as RTC), but after system boots up, the system time is me= ssed =0Aup again.

=0A

 

=0A

Another thing that I changed was the =0Appc_md.get_rtc_time and ppc_md.= set_rtc_time =96 these function pointers were =0Apointed to my driver=92s g= et_rtc_time and =0Aset_rtc_time.

=0A

 

=0A

In the same function, =0Appc_md.calibrate_decr is set to = initialize the decrementer register. However the =0Appc_md.time_init has st= ill not been set. I looked up MPC8349 example and they =0Aare enabling the = =91time base=92 in this function. However for 8245 the time base =0Aenable = is not a bit in a register, but it is a signal. So does the =0Appc_md.time_= init need to be pointed to some function =96 what should that function =0Ad= o? Is it needed at all?

=0A

Also, having set the =0Appc_md.calibrate_decr, ppc_md.get_rtc_= time and ppc_md.set_rtc_time, when the =0Asystem boots up, the scheduler pr= ints a message that says =93scheduling when =0Aatomic=94 and the system doe= sn=92t boot beyond this =0Apoint.

=0A

 

=0A

I have set these ppc_md function =0Apointers late duri= ng the bootup because it depends on initialization of the RTC =0Adriver bef= ore these pointers are set.

=0A

 

=0A

Now as I understand, before the RTC =0Ais available, the proc= essor uses the decrementer register to keep time for the =0Ascheduler. When= the ppc_md.get/set_rtc_time are set, the processor starts using =0Athe RTC= to keep time. However the point where the handover from decrementer to =0A= RTC happens is the point where the scheduler gets messed up. =0A=

=0A

 

=0A

Can you please guide me a= s to what =0Ais the right way for me to use the RTC. Which are the places o= ther than the =0Adriver that I need to modify/add?=

=0A

 =0A

Thanks,

= =0A

Aniket.


=0A=0A
Want to start your own business? Lear= n how on Yahoo! Small Business. --0-2075033525-1163460820=:64193--