Re: USB charging over TPS65950 BCI

2009-09-14 Thread Gregoire Gentil
I don't know. I haven't seen yet a battery driver that works correctly
with the TPS65950 and I have ping multiple times various people at TI.
Perhaps Gandhar will have an idea. I think that it would be valuable for
the community that somebody at TI provides some patches to report
correctly everything around the battery,

Grégoire


On Fri, 2009-09-11 at 19:31 +0530, pramod gurav wrote: 
 hi gregoire,
 i did not mention about charge current. the sysfs entry charge_current
 always returns 360.
 
 
 -- 
 Best Regards
 Pramod
 
 
 On Fri, Sep 11, 2009 at 7:21 PM, pramod gurav pramodfo...@gmail.com wrote:
  Hello gregoire,
 
  Really sorry I could not reply to your mail as I was busy with some other 
  work.
  I applied your above patch tested. The sysfs entries return correct
  values for status, charger device(online), voltage_now. But the
  current across the battery is reported wrong. I compared the values
  returned by current_now sysfs entry with multimeter values across the
  battery. The values were varying whenever I remove AC and plug it
  back. But what I could see was the current_now value was approximately
  double the actual current across the battery.
  Without your patch the twl4030_bci gives wrong values for current_now,
  voltage_now, capacity etc.
  But your patch fixes this issue.
 
  But the USB charging did not work. Is USB charging functional with
  TWL4030 on any of the OMAP boards?
 
 
  Don't mind for the late reply. Thanks for your help.
 
  --
  Thanks and Best Regards
  Pramod
 
  On Wed, Aug 5, 2009 at 9:48 PM, Gregoire Gentil grego...@gentil.com wrote:
  Hello,
 
  Any feed-back on the patch I sent? Have you tried it? Have you fixed
  your problem?
 
  Grégoire
 
 
  On Fri, 2009-07-31 at 23:41 -0700, Gregoire Gentil wrote:
  On Fri, 2009-07-31 at 19:19 +0530, pramod gurav wrote:
   Hi All,
   I was trying to get the USB battery charging working over TPS65950 BCI
   on the OMAP3430 custom board. I am working with linux-omap-2.6
   v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
   I passed interrupt details to these drivers from platform_device
   structure from my board file. I could get the AC charging working. The
   AC and USB detection worked. However the USB charging is not
   happening.
   I read through the TPS TRM and took the dumps of the registers from
   BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
   USB charger between host and the board. The register settings seem to
   be fine. But the battery is not charging. I am using BQ27000 chip for
   battery monitoring and I can see the battery voltage is decreasing.
  
   Following are the register dumps of TWL with and without USB plugged in:
  
   These are the register contents when USB charger is plugged in:
   BCIMDEN = 0x11
   REG_BOOT_BCI= 0x37
   REG_POWER_CTRL  = 0x20
   REG_BCIMFSTS4   = 0xf4
   REG_BCIMFSTS1   = 0x13
   REG_BCIIREF1= 0x68
   REG_BCIIREF2= 0x3
   REG_BCIMFEN4= 0x6f
   REG_BCIMFSTS2   = 0x0
   REG_BCIMSTATEC  = 0x12
   REG_STS_HW_CONDITIONS= 0x90
  
  
   These are the register contents when USB charger is plugged out:
   BCIMDEN = 0x0
   REG_BOOT_BCI= 0x35
   REG_POWER_CTRL  = 0x20
   REG_BCIMFSTS4   = 0xf0
   REG_BCIMFSTS1   = 0xaa
   REG_BCIIREF1= 0x68
   REG_BCIIREF2= 0x3
   REG_BCIMFEN4= 0x68
   REG_BCIMFSTS2   = 0x0
   REG_BCIMSTATEC  =0x0
   REG_STS_HW_CONDITIONS= 0x10
  
   Is there anything more I need to support to get BCI USB charging
   working? Need I follow any USB Communication protocol between Host and
   the board.
   I have pasted the kernel boot logs for reference at the end.
   Can any one please guide me to some pointers?
  
   --
   Best Regards
   Pramod
  I'm experiencing some problems with TWL4030 DC charging and I'm
  interested by this kind of problem. Basically, the values reported by
  our patch is different from the current going to the battery. We wrote
  the attached enhanced patch so as to edit at run-time the charging mode
  and various values including charge_current. It's against 2.6.29 but I
  think that it should work again 2.6.28. Unfortunately, starting 2.6.30,
  Tony has removed all the BCI battery code and has asked for updated code
  against mainline but I've not seen anything so far.
 
  Pramod, can you try the attached patch (perhaps, it will help you) and
  can you tell if you see the exact current going to the battery reported
  by the driver?
 
  Grégoire
 
 
 
 
 
  --- a/drivers/power/twl4030_bci_battery.c 2009-07-22 
  18:27:16.0
  -0700
  +++ b/drivers/power/twl4030_bci_battery.c 2009-07-22 
  18:30:22.0
  -0700
  @@ -15,6 +15,9 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
 
  +/* Boot with automatic charge */
  +#define CHARGE_MODE 1
  +
   #include linux/init.h
   #include linux/module.h
   #include linux/device.h
  @@ -50,6 +53,7 @@
   /* Boot BCI flag bits */
   #define BCIAUTOWEN

RE: USB charging over TPS65950 BCI

2009-09-14 Thread Syed Mohammed, Khasim


 -Original Message-
 From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
 ow...@vger.kernel.org] On Behalf Of Gregoire Gentil
 Sent: Tuesday, September 15, 2009 4:24 AM
 To: pramod gurav
 Cc: linux-omap@vger.kernel.org; Tim Yamin; Dighe, Gandhar
 Subject: Re: USB charging over TPS65950 BCI

 I don't know. I haven't seen yet a battery driver that works correctly
 with the TPS65950 and I have ping multiple times various people at TI.
Isn't this driver working for you? 
http://git.omapzoom.org/?p=repo/omapkernel.git;a=blob;f=drivers/power/twl4030_bci_battery.c;h=816db99e086f69d3efa46efd0ccbb60753a57b59;hb=android-2.6.27

I know OMAP Zoom has battery driver and it does support USB charging. It works 
on Open Pandora to an extent as well.

 Perhaps Gandhar will have an idea. I think that it would be valuable for
 the community that somebody at TI provides some patches to report
 correctly everything around the battery,
No idea why it wasn’t published.

Regards,
Khasim

 Grégoire


 On Fri, 2009-09-11 at 19:31 +0530, pramod gurav wrote:
  hi gregoire,
  i did not mention about charge current. the sysfs entry charge_current
  always returns 360.
 
 
  --
  Best Regards
  Pramod
 
 
  On Fri, Sep 11, 2009 at 7:21 PM, pramod gurav pramodfo...@gmail.com
 wrote:
   Hello gregoire,
  
   Really sorry I could not reply to your mail as I was busy with some other
 work.
   I applied your above patch tested. The sysfs entries return correct
   values for status, charger device(online), voltage_now. But the
   current across the battery is reported wrong. I compared the values
   returned by current_now sysfs entry with multimeter values across the
   battery. The values were varying whenever I remove AC and plug it
   back. But what I could see was the current_now value was approximately
   double the actual current across the battery.
   Without your patch the twl4030_bci gives wrong values for current_now,
   voltage_now, capacity etc.
   But your patch fixes this issue.
  
   But the USB charging did not work. Is USB charging functional with
   TWL4030 on any of the OMAP boards?
  
  
   Don't mind for the late reply. Thanks for your help.
  
   --
   Thanks and Best Regards
   Pramod
  
   On Wed, Aug 5, 2009 at 9:48 PM, Gregoire Gentil grego...@gentil.com
 wrote:
   Hello,
  
   Any feed-back on the patch I sent? Have you tried it? Have you fixed
   your problem?
  
   Grégoire
  
  
   On Fri, 2009-07-31 at 23:41 -0700, Gregoire Gentil wrote:
   On Fri, 2009-07-31 at 19:19 +0530, pramod gurav wrote:
Hi All,
I was trying to get the USB battery charging working over TPS65950
 BCI
on the OMAP3430 custom board. I am working with linux-omap-2.6
v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
I passed interrupt details to these drivers from platform_device
structure from my board file. I could get the AC charging working.
 The
AC and USB detection worked. However the USB charging is not
happening.
I read through the TPS TRM and took the dumps of the registers from
BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
USB charger between host and the board. The register settings seem to
be fine. But the battery is not charging. I am using BQ27000 chip for
battery monitoring and I can see the battery voltage is decreasing.
   
Following are the register dumps of TWL with and without USB plugged
 in:
   
These are the register contents when USB charger is plugged in:
BCIMDEN = 0x11
REG_BOOT_BCI= 0x37
REG_POWER_CTRL  = 0x20
REG_BCIMFSTS4   = 0xf4
REG_BCIMFSTS1   = 0x13
REG_BCIIREF1= 0x68
REG_BCIIREF2= 0x3
REG_BCIMFEN4= 0x6f
REG_BCIMFSTS2   = 0x0
REG_BCIMSTATEC  = 0x12
REG_STS_HW_CONDITIONS= 0x90
   
   
These are the register contents when USB charger is plugged out:
BCIMDEN = 0x0
REG_BOOT_BCI= 0x35
REG_POWER_CTRL  = 0x20
REG_BCIMFSTS4   = 0xf0
REG_BCIMFSTS1   = 0xaa
REG_BCIIREF1= 0x68
REG_BCIIREF2= 0x3
REG_BCIMFEN4= 0x68
REG_BCIMFSTS2   = 0x0
REG_BCIMSTATEC  =0x0
REG_STS_HW_CONDITIONS= 0x10
   
Is there anything more I need to support to get BCI USB charging
working? Need I follow any USB Communication protocol between Host
 and
the board.
I have pasted the kernel boot logs for reference at the end.
Can any one please guide me to some pointers?
   
--
Best Regards
Pramod
   I'm experiencing some problems with TWL4030 DC charging and I'm
   interested by this kind of problem. Basically, the values reported by
   our patch is different from the current going to the battery. We wrote
   the attached enhanced patch so as to edit at run-time the charging mode
   and various values including charge_current. It's against 2.6.29 but I
   think that it should work again 2.6.28. Unfortunately, starting 2.6.30,
   Tony has removed all the BCI battery

RE: USB charging over TPS65950 BCI

2009-09-14 Thread Dighe, Gandhar
Hi Khasim,

Actually it works very well on Pandora. For some reasons he had problems with 
CV mode. When he switched his schematics to non-limited charger as in part (D) 
in the data manual he was able to use charger properly.


Regards,

Gandhar Dighe,
Texas Instruments Inc.
phone: (214)567-4146
TPS659xx Forum - http://community.ti.com/forums/107.aspx

My carbon footprint is 11 tons/yr and is reducing. What's your? Check here and 
join the rally!!
-Original Message-
From: Syed Mohammed, Khasim
Sent: Monday, September 14, 2009 6:21 PM
To: grego...@gentil.com; pramod gurav
Cc: linux-omap@vger.kernel.org; Tim Yamin; Dighe, Gandhar
Subject: RE: USB charging over TPS65950 BCI



 -Original Message-
 From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
 ow...@vger.kernel.org] On Behalf Of Gregoire Gentil
 Sent: Tuesday, September 15, 2009 4:24 AM
 To: pramod gurav
 Cc: linux-omap@vger.kernel.org; Tim Yamin; Dighe, Gandhar
 Subject: Re: USB charging over TPS65950 BCI

 I don't know. I haven't seen yet a battery driver that works correctly
 with the TPS65950 and I have ping multiple times various people at TI.
Isn't this driver working for you? 
http://git.omapzoom.org/?p=repo/omapkernel.git;a=blob;f=drivers/power/twl4030_bci_battery.c;h=816db99e086f69d3efa46efd0ccbb60753a57b59;hb=android-2.6.27

I know OMAP Zoom has battery driver and it does support USB charging. It works 
on Open Pandora to an extent as well.

 Perhaps Gandhar will have an idea. I think that it would be valuable for
 the community that somebody at TI provides some patches to report
 correctly everything around the battery,
No idea why it wasn't published.

Regards,
Khasim

 Grégoire


 On Fri, 2009-09-11 at 19:31 +0530, pramod gurav wrote:
  hi gregoire,
  i did not mention about charge current. the sysfs entry charge_current
  always returns 360.
 
 
  --
  Best Regards
  Pramod
 
 
  On Fri, Sep 11, 2009 at 7:21 PM, pramod gurav pramodfo...@gmail.com
 wrote:
   Hello gregoire,
  
   Really sorry I could not reply to your mail as I was busy with some other
 work.
   I applied your above patch tested. The sysfs entries return correct
   values for status, charger device(online), voltage_now. But the
   current across the battery is reported wrong. I compared the values
   returned by current_now sysfs entry with multimeter values across the
   battery. The values were varying whenever I remove AC and plug it
   back. But what I could see was the current_now value was approximately
   double the actual current across the battery.
   Without your patch the twl4030_bci gives wrong values for current_now,
   voltage_now, capacity etc.
   But your patch fixes this issue.
  
   But the USB charging did not work. Is USB charging functional with
   TWL4030 on any of the OMAP boards?
  
  
   Don't mind for the late reply. Thanks for your help.
  
   --
   Thanks and Best Regards
   Pramod
  
   On Wed, Aug 5, 2009 at 9:48 PM, Gregoire Gentil grego...@gentil.com
 wrote:
   Hello,
  
   Any feed-back on the patch I sent? Have you tried it? Have you fixed
   your problem?
  
   Grégoire
  
  
   On Fri, 2009-07-31 at 23:41 -0700, Gregoire Gentil wrote:
   On Fri, 2009-07-31 at 19:19 +0530, pramod gurav wrote:
Hi All,
I was trying to get the USB battery charging working over TPS65950
 BCI
on the OMAP3430 custom board. I am working with linux-omap-2.6
v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
I passed interrupt details to these drivers from platform_device
structure from my board file. I could get the AC charging working.
 The
AC and USB detection worked. However the USB charging is not
happening.
I read through the TPS TRM and took the dumps of the registers from
BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
USB charger between host and the board. The register settings seem to
be fine. But the battery is not charging. I am using BQ27000 chip for
battery monitoring and I can see the battery voltage is decreasing.
   
Following are the register dumps of TWL with and without USB plugged
 in:
   
These are the register contents when USB charger is plugged in:
BCIMDEN = 0x11
REG_BOOT_BCI= 0x37
REG_POWER_CTRL  = 0x20
REG_BCIMFSTS4   = 0xf4
REG_BCIMFSTS1   = 0x13
REG_BCIIREF1= 0x68
REG_BCIIREF2= 0x3
REG_BCIMFEN4= 0x6f
REG_BCIMFSTS2   = 0x0
REG_BCIMSTATEC  = 0x12
REG_STS_HW_CONDITIONS= 0x90
   
   
These are the register contents when USB charger is plugged out:
BCIMDEN = 0x0
REG_BOOT_BCI= 0x35
REG_POWER_CTRL  = 0x20
REG_BCIMFSTS4   = 0xf0
REG_BCIMFSTS1   = 0xaa
REG_BCIIREF1= 0x68
REG_BCIIREF2= 0x3
REG_BCIMFEN4= 0x68
REG_BCIMFSTS2   = 0x0
REG_BCIMSTATEC  =0x0
REG_STS_HW_CONDITIONS= 0x10
   
Is there anything more I need to support to get BCI USB charging
working? Need I follow any USB

Re: USB charging over TPS65950 BCI

2009-09-11 Thread pramod gurav
hi gregoire,
i did not mention about charge current. the sysfs entry charge_current
always returns 360.


-- 
Best Regards
Pramod


On Fri, Sep 11, 2009 at 7:21 PM, pramod gurav pramodfo...@gmail.com wrote:
 Hello gregoire,

 Really sorry I could not reply to your mail as I was busy with some other 
 work.
 I applied your above patch tested. The sysfs entries return correct
 values for status, charger device(online), voltage_now. But the
 current across the battery is reported wrong. I compared the values
 returned by current_now sysfs entry with multimeter values across the
 battery. The values were varying whenever I remove AC and plug it
 back. But what I could see was the current_now value was approximately
 double the actual current across the battery.
 Without your patch the twl4030_bci gives wrong values for current_now,
 voltage_now, capacity etc.
 But your patch fixes this issue.

 But the USB charging did not work. Is USB charging functional with
 TWL4030 on any of the OMAP boards?


 Don't mind for the late reply. Thanks for your help.

 --
 Thanks and Best Regards
 Pramod

 On Wed, Aug 5, 2009 at 9:48 PM, Gregoire Gentil grego...@gentil.com wrote:
 Hello,

 Any feed-back on the patch I sent? Have you tried it? Have you fixed
 your problem?

 Grégoire


 On Fri, 2009-07-31 at 23:41 -0700, Gregoire Gentil wrote:
 On Fri, 2009-07-31 at 19:19 +0530, pramod gurav wrote:
  Hi All,
  I was trying to get the USB battery charging working over TPS65950 BCI
  on the OMAP3430 custom board. I am working with linux-omap-2.6
  v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
  I passed interrupt details to these drivers from platform_device
  structure from my board file. I could get the AC charging working. The
  AC and USB detection worked. However the USB charging is not
  happening.
  I read through the TPS TRM and took the dumps of the registers from
  BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
  USB charger between host and the board. The register settings seem to
  be fine. But the battery is not charging. I am using BQ27000 chip for
  battery monitoring and I can see the battery voltage is decreasing.
 
  Following are the register dumps of TWL with and without USB plugged in:
 
  These are the register contents when USB charger is plugged in:
  BCIMDEN         = 0x11
  REG_BOOT_BCI    = 0x37
  REG_POWER_CTRL  = 0x20
  REG_BCIMFSTS4   = 0xf4
  REG_BCIMFSTS1   = 0x13
  REG_BCIIREF1    = 0x68
  REG_BCIIREF2    = 0x3
  REG_BCIMFEN4    = 0x6f
  REG_BCIMFSTS2   = 0x0
  REG_BCIMSTATEC  = 0x12
  REG_STS_HW_CONDITIONS= 0x90
 
 
  These are the register contents when USB charger is plugged out:
  BCIMDEN         = 0x0
  REG_BOOT_BCI    = 0x35
  REG_POWER_CTRL  = 0x20
  REG_BCIMFSTS4   = 0xf0
  REG_BCIMFSTS1   = 0xaa
  REG_BCIIREF1    = 0x68
  REG_BCIIREF2    = 0x3
  REG_BCIMFEN4    = 0x68
  REG_BCIMFSTS2   = 0x0
  REG_BCIMSTATEC  =0x0
  REG_STS_HW_CONDITIONS= 0x10
 
  Is there anything more I need to support to get BCI USB charging
  working? Need I follow any USB Communication protocol between Host and
  the board.
  I have pasted the kernel boot logs for reference at the end.
  Can any one please guide me to some pointers?
 
  --
  Best Regards
  Pramod
 I'm experiencing some problems with TWL4030 DC charging and I'm
 interested by this kind of problem. Basically, the values reported by
 our patch is different from the current going to the battery. We wrote
 the attached enhanced patch so as to edit at run-time the charging mode
 and various values including charge_current. It's against 2.6.29 but I
 think that it should work again 2.6.28. Unfortunately, starting 2.6.30,
 Tony has removed all the BCI battery code and has asked for updated code
 against mainline but I've not seen anything so far.

 Pramod, can you try the attached patch (perhaps, it will help you) and
 can you tell if you see the exact current going to the battery reported
 by the driver?

 Grégoire





 --- a/drivers/power/twl4030_bci_battery.c     2009-07-22 18:27:16.0
 -0700
 +++ b/drivers/power/twl4030_bci_battery.c     2009-07-22 18:30:22.0
 -0700
 @@ -15,6 +15,9 @@
   * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   */

 +/* Boot with automatic charge */
 +#define CHARGE_MODE 1
 +
  #include linux/init.h
  #include linux/module.h
  #include linux/device.h
 @@ -50,6 +53,7 @@
  /* Boot BCI flag bits */
  #define BCIAUTOWEN           0x020
  #define CONFIG_DONE          0x010
 +#define CVENAC                       0x004
  #define BCIAUTOUSB           0x002
  #define BCIAUTOAC            0x001
  #define BCIMSTAT_MASK                0x03F
 @@ -81,6 +85,11 @@
  #define REG_BB_CFG           0x012
  #define BBCHEN                       0x010

 +/* GPBR */
 +#define REG_GPBR1            0x0c
 +#define MADC_HFCLK_EN                0x80
 +#define DEFAULT_MADC_CLK_EN  0x10
 +
  /* Power supply charge interrupt */
  #define REG_PWR_ISR1         0x00
  #define 

Re: USB charging over TPS65950 BCI

2009-08-02 Thread Grazvydas Ignotas
On Fri, Jul 31, 2009 at 4:49 PM, pramod guravpramodfo...@gmail.com wrote:
 Hi All,
 I was trying to get the USB battery charging working over TPS65950 BCI
 on the OMAP3430 custom board. I am working with linux-omap-2.6
 v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
 I passed interrupt details to these drivers from platform_device
 structure from my board file. I could get the AC charging working. The
 AC and USB detection worked. However the USB charging is not
 happening.
 I read through the TPS TRM and took the dumps of the registers from
 BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
 USB charger between host and the board. The register settings seem to
 be fine. But the battery is not charging. I am using BQ27000 chip for
 battery monitoring and I can see the battery voltage is decreasing.

There seem to be USB related changes in Zoom git, you can try and see
if it helps:
http://git.omapzoom.org/?p=repo/omapkernel.git;a=blob;f=drivers/power/twl4030_bci_battery.c;hb=refs/heads/ti-2.6.27-omap3

Let us know if it helps.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB charging over TPS65950 BCI

2009-08-01 Thread Gregoire Gentil
On Fri, 2009-07-31 at 19:19 +0530, pramod gurav wrote:
 Hi All,
 I was trying to get the USB battery charging working over TPS65950 BCI
 on the OMAP3430 custom board. I am working with linux-omap-2.6
 v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
 I passed interrupt details to these drivers from platform_device
 structure from my board file. I could get the AC charging working. The
 AC and USB detection worked. However the USB charging is not
 happening.
 I read through the TPS TRM and took the dumps of the registers from
 BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
 USB charger between host and the board. The register settings seem to
 be fine. But the battery is not charging. I am using BQ27000 chip for
 battery monitoring and I can see the battery voltage is decreasing.
 
 Following are the register dumps of TWL with and without USB plugged in:
 
 These are the register contents when USB charger is plugged in:
 BCIMDEN = 0x11
 REG_BOOT_BCI= 0x37
 REG_POWER_CTRL  = 0x20
 REG_BCIMFSTS4   = 0xf4
 REG_BCIMFSTS1   = 0x13
 REG_BCIIREF1= 0x68
 REG_BCIIREF2= 0x3
 REG_BCIMFEN4= 0x6f
 REG_BCIMFSTS2   = 0x0
 REG_BCIMSTATEC  = 0x12
 REG_STS_HW_CONDITIONS= 0x90
 
 
 These are the register contents when USB charger is plugged out:
 BCIMDEN = 0x0
 REG_BOOT_BCI= 0x35
 REG_POWER_CTRL  = 0x20
 REG_BCIMFSTS4   = 0xf0
 REG_BCIMFSTS1   = 0xaa
 REG_BCIIREF1= 0x68
 REG_BCIIREF2= 0x3
 REG_BCIMFEN4= 0x68
 REG_BCIMFSTS2   = 0x0
 REG_BCIMSTATEC  =0x0
 REG_STS_HW_CONDITIONS= 0x10
 
 Is there anything more I need to support to get BCI USB charging
 working? Need I follow any USB Communication protocol between Host and
 the board.
 I have pasted the kernel boot logs for reference at the end.
 Can any one please guide me to some pointers?
 
 -- 
 Best Regards
 Pramod
I'm experiencing some problems with TWL4030 DC charging and I'm
interested by this kind of problem. Basically, the values reported by
our patch is different from the current going to the battery. We wrote
the attached enhanced patch so as to edit at run-time the charging mode
and various values including charge_current. It's against 2.6.29 but I
think that it should work again 2.6.28. Unfortunately, starting 2.6.30,
Tony has removed all the BCI battery code and has asked for updated code
against mainline but I've not seen anything so far.

Pramod, can you try the attached patch (perhaps, it will help you) and
can you tell if you see the exact current going to the battery reported
by the driver?

Grégoire





--- a/drivers/power/twl4030_bci_battery.c   2009-07-22 18:27:16.0
-0700
+++ b/drivers/power/twl4030_bci_battery.c   2009-07-22 18:30:22.0
-0700
@@ -15,6 +15,9 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+/* Boot with automatic charge */
+#define CHARGE_MODE 1
+
 #include linux/init.h
 #include linux/module.h
 #include linux/device.h
@@ -50,6 +53,7 @@
 /* Boot BCI flag bits */
 #define BCIAUTOWEN 0x020
 #define CONFIG_DONE0x010
+#define CVENAC 0x004
 #define BCIAUTOUSB 0x002
 #define BCIAUTOAC  0x001
 #define BCIMSTAT_MASK  0x03F
@@ -81,6 +85,11 @@
 #define REG_BB_CFG 0x012
 #define BBCHEN 0x010
 
+/* GPBR */
+#define REG_GPBR1  0x0c
+#define MADC_HFCLK_EN  0x80
+#define DEFAULT_MADC_CLK_EN0x10
+
 /* Power supply charge interrupt */
 #define REG_PWR_ISR1   0x00
 #define REG_PWR_IMR1   0x01
@@ -125,6 +134,18 @@
 /* BCIEDR3 */
 #defineVBATLVL_EDRRISIN0x02
 
+/* BCIIREF1 */
+#define REG_BCIIREF1   0x027
+#define REG_BCIIREF2   0x028
+
+/* BCIMFTH1 */
+#define REG_BCIMFTH1   0x016
+
+/* Key */
+#define KEY_IIREF  0xE7
+#define KEY_FTH1   0xD2
+#define REG_BCIMFKEY   0x011
+
 /* Step size and prescaler ratio */
 #define TEMP_STEP_SIZE 147
 #define TEMP_PSR_R 100
@@ -142,9 +163,6 @@
 #define ENABLE 1
 #define DISABLE1
 
-/* Ptr to thermistor table */
-int *therm_tbl;
-
 struct twl4030_bci_device_info {
struct device   *dev;
 
@@ -160,6 +178,8 @@
struct power_supply bk_bat;
struct delayed_work twl4030_bci_monitor_work;
struct delayed_work twl4030_bk_bci_monitor_work;
+
+   struct twl4030_bci_platform_data *pdata;
 };
 
 static int usb_charger_flag;
@@ -425,15 +445,21 @@
 /*
  * Enable/Disable AC Charge funtionality.
  */
-static int twl4030charger_ac_en(int enable)
+static int twl4030charger_ac_en(int enable, int automatic)
 {
int ret;
 
if (enable) {
/* forcing the field BCIAUTOAC (BOOT_BCI[0) to 1 */
-   ret = clear_n_set(TWL4030_MODULE_PM_MASTER, 0,
-   (CONFIG_DONE | BCIAUTOWEN | BCIAUTOAC),
-   REG_BOOT_BCI);
+ 

USB charging over TPS65950 BCI

2009-07-31 Thread pramod gurav
Hi All,
I was trying to get the USB battery charging working over TPS65950 BCI
on the OMAP3430 custom board. I am working with linux-omap-2.6
v2.6.28-omap1 tag. I enabled the TWL4030 MADC and TWL4030 BCI drivers.
I passed interrupt details to these drivers from platform_device
structure from my board file. I could get the AC charging working. The
AC and USB detection worked. However the USB charging is not
happening.
I read through the TPS TRM and took the dumps of the registers from
BCI and some from TWL USB module and BOOT_BCI whenever I plug in the
USB charger between host and the board. The register settings seem to
be fine. But the battery is not charging. I am using BQ27000 chip for
battery monitoring and I can see the battery voltage is decreasing.

Following are the register dumps of TWL with and without USB plugged in:

These are the register contents when USB charger is plugged in:
BCIMDEN = 0x11
REG_BOOT_BCI= 0x37
REG_POWER_CTRL  = 0x20
REG_BCIMFSTS4   = 0xf4
REG_BCIMFSTS1   = 0x13
REG_BCIIREF1= 0x68
REG_BCIIREF2= 0x3
REG_BCIMFEN4= 0x6f
REG_BCIMFSTS2   = 0x0
REG_BCIMSTATEC  = 0x12
REG_STS_HW_CONDITIONS= 0x90


These are the register contents when USB charger is plugged out:
BCIMDEN = 0x0
REG_BOOT_BCI= 0x35
REG_POWER_CTRL  = 0x20
REG_BCIMFSTS4   = 0xf0
REG_BCIMFSTS1   = 0xaa
REG_BCIIREF1= 0x68
REG_BCIIREF2= 0x3
REG_BCIMFEN4= 0x68
REG_BCIMFSTS2   = 0x0
REG_BCIMSTATEC  =0x0
REG_STS_HW_CONDITIONS= 0x10

Is there anything more I need to support to get BCI USB charging
working? Need I follow any USB Communication protocol between Host and
the board.
I have pasted the kernel boot logs for reference at the end.
Can any one please guide me to some pointers?

-- 
Best Regards
Pramod


Starting kernel ...

Uncompressing 
Linux...
done, boo.
Linux version 2.6.28-omap1-(gpra...@gpramod.mistral.in) (gcc version
4.2.1 (CodeSourcery Sourcery G++ Lite 2007q3-51)) #25 Fri Jul 31
15:48:37 I9
CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c5387f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: OMAP3430 Main Board
Memory policy: ECC disabled, Data cache writeback
OMAP3430 Unknown revision

SRAM: Mapped pa 0x4020 to va 0xd700 size: 0x10
Reserving 4194304 bytes SDRAM for VRAM
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024
Kernel command line: console=ttyS2,115200n8 root=/dev/mmcblk0p2
rootfstype=ext3 rootdelay=3 android.ril=pts/0 init=/init
Unknown boot option `android.ril=pts/0': ignoring
Clocking rate (Crystal/DPLL/ARM core): 26.0/332/500 MHz
Reprogramming SDRC
GPMC revision 5.0
IRQ: Found an INTC at 0xd820 (revision 4.0) with 96 interrupts
Total of 96 interrupts on 1 active controller
OMAP34xx GPIO hardware version 2.5
PID hash table entries: 1024 (order: 10, 4096 bytes)
OMAP clockevent source: GPTIMER12 at 32768 Hz
Console: colour dummy device 80x30
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128MB 128MB = 256MB total
Memory: 250880KB available (3580K code, 755K data, 300K init)
Calibrating delay loop... 494.72 BogoMIPS (lpj=1933312)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 312 bytes
NET: Registered protocol family 16
Found NAND on CS0
Registering NAND on CS0
OMAP DMA hardware revision 4.0
USB: No board-specific platform config found
OMAP DSS rev 2.0
OMAP DISPC rev 3.0
OMAP VENC rev 2
i2c_omap i2c_omap.1: bus 1 rev3.12 at 400 kHz
Skipping twl4030 internal clock init and using bootloader value
(unknown osc rate)
twl4030: PIH (irq 7) chaining IRQs 368..375
twl4030: power (irq 373) chaining IRQs 376..383
twl4030: gpio (irq 368) chaining IRQs 384..401
i2c_omap i2c_omap.2: bus 2 rev3.12 at 400 kHz
i2c_omap i2c_omap.3: bus 3 rev3.12 at 400 kHz
SCSI subsystem initialized
twl4030_usb twl4030_usb: Initialized TWL4030 USB module
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
musb_hdrc: version 6.0, musb-dma, otg (peripheral+host), debug=0
musb_hdrc: USB OTG mode controller at d80ab000 using DMA, IRQ 92
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
TCP established hash table entries: 8192 (order: 4, 65536 bytes)
TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (double precision)
ashmem: initialized
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
JFFS2 version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.
msgmni has been set to 490
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler