From mboxrd@z Thu Jan 1 00:00:00 1970 From: badguy development Subject: LTC1760, ISR Questions Date: Thu, 3 Apr 2008 23:04:02 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5370590827251087969==" Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org Errors-To: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org To: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org List-Id: linux-i2c@vger.kernel.org --===============5370590827251087969== Content-Type: multipart/alternative; boundary="_f7da6e94-46d4-40e6-898b-e0ef8d724bf4_" --_f7da6e94-46d4-40e6-898b-e0ef8d724bf4_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I am developing a driver for the LTC1760 dual battery charger. I have an interrupt occur and I get notification of that. however I cannot seem to clear the interrupt from inside the ISR and thus I= am ruined. I have learned from the research and looking around I have done, that I can= not call just any code in an ISR. the code I want to call will read the AlertResponse register of my LTC1760 = chip and that will clear the interrupt. but I get angry kernel response when I do, below is a brief dump of what I = get: BUG: scheduling while atomic: swapper/0x00010002/0 bad: scheduling from the idle thread! Unable to handle kernel NULL pointer dereference at virtual address 0000000= 0 pgd =3D c0004000 [00000000] *pgd=3D00000000 Internal error: Oops: 17 [#1] Modules linked in: i2c_battery swcamera(PF) clcdc(PF) pvr(PF) gecko_devices CPU: 0 PC is at dequeue_task+0xc/0xa8 LR is at deactivate_task+0x38/0x44 pc : [] lr : [] Tainted: PF sp : c0331c6c ip : c0331c80 fp : c0331c7c r10: 00000000 r9 : 00989642 r8 : b0e7aa00 r7 : c0335f98 r6 : c0331cd8 r5 : 00000001 r4 : c0335f98 r3 : 00000080 r2 : 00000000 r1 : 00000000 r0 : c0335f98 Flags: Nzcv IRQs off FIQs on Mode SVC_32 Segment kernel Control: C5387F Table: 868E8000 DAC: 00000017 Process swapper (pid: 0, stack limit =3D 0xc0330250) All the example code I can find regarding ISR, have access to register offs= ets and can simply clear the interrupt that way. I am new to this and am having a hard time finding direction with regards t= o how to handle linux interrupts. I need to send a request command out i2c to this device to clear this inter= rupt. I am not 100% sure about this, but it is what the data sheet has led me to = believe. I would appreciate any help on this, and perhaps even a reference to what m= aterial I should look at to find this answer. Thanks ahead of time. Please CC me at badguydevelopment-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org=20 I am still trying to join the list. P.S. I accidently clicked send before filling out the Subject, so I scanned th= e maillist and did not find my message. I think perhaps it was rejected due to no subject, if it was not, and I sub= mitted two of them please accept my apologies. -Christian Hunt _________________________________________________________________ Try Chicktionary, a game that tests how many words you can form from the le= tters given. Find this and more puzzles at Live Search Games! http://g.msn.ca/ca55/207= --_f7da6e94-46d4-40e6-898b-e0ef8d724bf4_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello,

I am developing a driver for the LTC1760 dual battery charger= .

 I have an interrupt occur and I get notification of that. however I cannot seem to clear the interrupt from inside the ISR and thus I= am ruined.

I have learned from the research and looking around I have done, that I can= not call just any code in an ISR.
the code I want to call will read the AlertResponse register of my LTC1760 = chip and that will clear the interrupt.

but I get angry kernel response when I do, below is a brief dump of what I = get:

BUG: scheduling while atomic: swapper/0x00010002/0
bad: sche= duling from the idle thread!
Unable to handle kernel NULL pointer derefe= rence at virtual address 00000000
pgd =3D c0004000
[00000000] *pgd=3D= 00000000
Internal error: Oops: 17 [#1]
Modules linked in: i2c_battery= swcamera(PF) clcdc(PF) pvr(PF) gecko_devices
CPU: 0
PC is at dequeue= _task+0xc/0xa8
LR is at deactivate_task+0x38/0x44
pc : [<c009b070&= gt;]    lr : [<c009b218>]    Tainted: P= F
sp : c0331c6c  ip : c0331c80  fp : c0331c7c
r10: 00000000=   r9 : 00989642  r8 : b0e7aa00
r7 : c0335f98  r6 : c0331c= d8  r5 : 00000001  r4 : c0335f98
r3 : 00000080  r2 : 0000= 0000  r1 : 00000000  r0 : c0335f98
Flags: Nzcv  IRQs off&= nbsp; FIQs on  Mode SVC_32  Segment kernel
Control: C5387F
= Table: 868E8000  DAC: 00000017
Process swapper (pid: 0, stack limit= =3D 0xc0330250)

All the example code I can find regarding ISR, have= access to register offsets and can simply clear the interrupt that way.I am new to this and am having a hard time finding direction with regards = to how to handle linux interrupts.

I need to send a request command = out i2c to this device to clear this interrupt.
I am not 100% sure about= this, but it is what the data sheet has led me to believe.

I would = appreciate any help on this, and perhaps even a reference to what material = I should look at to find this answer.

Thanks ahead of time.

P= lease CC me at badguydevelopment-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org
I am still trying to join = the list.

P.S.
  I accidently clicked send before filling ou= t the Subject, so I scanned the maillist and did not find my message.
I = think perhaps it was rejected due to no subject, if it was not, and I submi= tted two of them please accept my apologies.

    = ;   -Christian Hunt

Sign in today. When you sign in to= Windows Live Messenger you could win $1000 a day until May 12th. Learn more at SignInAndWIN.ca= = --_f7da6e94-46d4-40e6-898b-e0ef8d724bf4_-- --===============5370590827251087969== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ i2c mailing list i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org http://lists.lm-sensors.org/mailman/listinfo/i2c --===============5370590827251087969==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Delvare Subject: Re: LTC1760, ISR Questions Date: Wed, 9 Apr 2008 12:04:38 +0200 Message-ID: <20080409120438.6e399bf3@hyperion.delvare> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org Errors-To: i2c-bounces-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org To: badguy development Cc: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org List-Id: linux-i2c@vger.kernel.org On Thu, 3 Apr 2008 23:04:02 +0000, badguy development wrote: > I am developing a driver for the LTC1760 dual battery charger. > > I have an interrupt occur and I get notification of that. > > however I cannot seem to clear the interrupt from inside the ISR and thus I am ruined. > > > > I have learned from the research and looking around I have done, that I cannot call just any code in an ISR. > > the code I want to call will read the AlertResponse register of my LTC1760 chip and that will clear the interrupt. > > > > but I get angry kernel response when I do, below is a brief dump of what I get: > > BUG: scheduling while atomic: swapper/0x00010002/0 > bad: scheduling from the idle thread! > Unable to handle kernel NULL pointer dereference at virtual address 00000000 > pgd = c0004000 > [00000000] *pgd=00000000 > Internal error: Oops: 17 [#1] > Modules linked in: i2c_battery swcamera(PF) clcdc(PF) pvr(PF) gecko_devices > CPU: 0 > PC is at dequeue_task+0xc/0xa8 > LR is at deactivate_task+0x38/0x44 > pc : [] lr : [] Tainted: PF > sp : c0331c6c ip : c0331c80 fp : c0331c7c > r10: 00000000 r9 : 00989642 r8 : b0e7aa00 > r7 : c0335f98 r6 : c0331cd8 r5 : 00000001 r4 : c0335f98 > r3 : 00000080 r2 : 00000000 r1 : 00000000 r0 : c0335f98 > Flags: Nzcv IRQs off FIQs on Mode SVC_32 Segment kernel > Control: C5387F > Table: 868E8000 DAC: 00000017 > Process swapper (pid: 0, stack limit = 0xc0330250) > > All the example code I can find regarding ISR, have access to register offsets and can simply clear the interrupt that way. > I am new to this and am having a hard time finding direction with regards to how to handle linux interrupts. > > I need to send a request command out i2c to this device to clear this interrupt. > I am not 100% sure about this, but it is what the data sheet has led me to believe. > > I would appreciate any help on this, and perhaps even a reference to what material I should look at to find this answer. Indeed, there are many things you can't do in interrupt context, and in particular you cannot sleep, while most i2c bus drivers do sleep, so reading from or writing to an I2C device is not possible. There are two ways to work around this: * Use a workqueue to do the job. The ISR will add a job to the queue and return, and the job will be run later. Workqueues have their own context so accessing the I2C device is OK for them. This is explained in greater detail in LDD3 [1]. * Implement a non-sleeping mode in your i2c bus driver. That's something new in kernel 2.6.25, so far only the i2c-pxa driver has support for non-sleeping mode. > > Thanks ahead of time. > > Please CC me at badguydevelopment-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > I am still trying to join the list. > > P.S. > I accidently clicked send before filling out the Subject, so I scanned the maillist and did not find my message. > I think perhaps it was rejected due to no subject, if it was not, and I submitted two of them please accept my apologies. The messages can take a couple hours before they show in the archive. Your message was not rejected - although messages with no subject are bad and likely to be ignored by many ;) [1] http://lwn.net/Kernel/LDD3/ -- Jean Delvare _______________________________________________ i2c mailing list i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org http://lists.lm-sensors.org/mailman/listinfo/i2c