Charging battery of imx233 under Linux.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Charging battery of imx233 under Linux.

3,096 Views
pierreparent
Contributor III

Hi,

I seem to understand that in Imx233 battery charging does not occur automatically. You need to do software commands in order to charge the battery.

Though I'm very surprised not to be able to get the hand on any software to handle battery charging. Are we supposed to write it ourself? Is there at least a good documentation describing what register should be written when?

Did someone already tried to write such a program for Linux, here?

Thank's in advance!  :smileyhappy:

Pierre.

Labels (3)
0 Kudos
15 Replies

2,134 Views
lategoodbye
Senior Contributor I

Hi Pierre,

unfortunately there is no power subsystem driver including battery charging support in Linux mainline.

I started to develop a power driver but battery charging is beyond my scope:

https://github.com/lategoodbye/linux-mxs-power

But some guys in the Olimex forum are interested in developing this feature.

BR Stefan

0 Kudos

2,134 Views
pierreparent
Contributor III

Hi,

Thing is we should simply port the existing driver for the kernel 3.X, not recode it form scratch.

I really need this driver, I'm also interested in developing this feature, and I'm going to try my best to port this driver for 3.x kernel, if i can't find nobody who did it.

It seems some people at pengutronix, managed in doing a first dirty but kinda working version. I'm going to try to contact them.

I keep you in touch in this thread! :smileywink:

Pierre.

0 Kudos

2,134 Views
lategoodbye
Senior Contributor I

I understand that you need this feature in the near future and so you prefer a quick hack instead of a proper mainline driver in 3.20 or higher.

But i've seen many attempts for a mxs battery charging driver. All of them are outdated now and not useful for the Linux community.

Please bear in mind that beginning with DT there has been a lot of changes for ARM drivers, so porting to 3.x won't be straight forward.

I've started with the power driver as a helpful basement for all the cool features like battery charging.

Trust me you are not the only one who needs battery charging for mxs.

0 Kudos

2,134 Views
pierreparent
Contributor III

Hi,

Indeed it would be neat to have a clean driver to include in mainline. But I'm no expert in that domain, an for now I'm sure I can do it, and if I did it, if it would be good enough to be included, in official releases.

All I want is the battery to charge, and for everyone it's pretty much the same, I think. For this purpose I don't see any reason why we could not fairly easily:

1-Write a linux3.x module, that is not recognized by linux as a power subsystem, or power driver, but when insmoded charges the battery. We can for this reuse large parts of the existing driver.

2- If 1 is not possible for any reason, do a Userland Program. Because one can write registers (like HW_POWER_CHARGE_SET, and so on), form userland.

Do you see any major obstacle to that?

0 Kudos

2,134 Views
lategoodbye
Senior Contributor I

Hi Pierre,

i didn't look to deep into battery charging but i think this driver needs interaction with other drivers like lradc or regulators. Also there is some IRQ handling necessary for battery protection.

So an userland program isn't a choice beside is really ugly.

BR Stefan

0 Kudos

2,134 Views
pierreparent
Contributor III

Yes you need laradc to get the battery voltage, and to activate 4P2 (so that battery does not get used power the processor).

But I've already done a user land program that gets battery level trough ADC. And an other one which triggers the charger at full current (everything heats up, and it destroys the battery as much as it charges it but it does charge it a little bit) by simply writing the register (W_POWER_CHARGE_SET, 0x0000001f);(HW_POWER_CHARGE_TOG, 0x00010000);. So I'm sure it would be possible to do proper ramp from user-land, following the same algorithm as in the Freescale driver.

But I do agree that a kernel  module is a better choice, that's what I'm going to try first.

0 Kudos

2,134 Views
brolinempey
Contributor I

What is the current status (no pun intended) of your program?  My company needs to force the i.MX283 (yes, not i.MX233) battery charger to always be enabled.  If you have a working program, I prefer to use your program even if it has to be modified for the i.MX283;  I do not want to unnecessarily duplicate your effort.

0 Kudos

2,134 Views
igorpadykov
NXP Employee
NXP Employee

Hi Pierre

i.MX23 Freescale Linux BSP has charger driver, refer to attached Linux Manual

Chapter 27 Battery Charger and Power Source Manager (PSM) Driver

L2.6.31_10.05.00_SDK_SOURCE : Linux 2.6.31 Source Code Files 2010.05 Release.

AN4199 sect.5 Battery Charging Subsystem describes its operation.

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,134 Views
pierreparent
Contributor III

Hi thanks for answering!

Can you be a little bit more specific on where is located the program/driver for battery charging in the package? I download Linux 2.6.31 Source Code Files from your link, but there seems to be thousands of things in it, it is hard to find the precise files we need.

By the way I use a 3.X kernel.

Pierre.

0 Kudos

2,134 Views
igorpadykov
NXP Employee
NXP Employee

Hi Pierre

please check sect.27.3 Source Code Structure attached Linux Manual.

3.X kernel may be supported on meta-fsl-arm mailing list,

https://lists.yoctoproject.org/listinfo/meta-freescale

~igor

0 Kudos

2,134 Views
pierreparent
Contributor III

Ok thanks for the answer.

But believing the doc the driver should be located in directory

drivers/power/mxs/ in the kernel tree, and files in it should be called ddi_bc_api.c,  ddi_bc_hw.c and so on.

But in the L2.6.31_10.05.00_SDK_SOURCE : provided by Freescale there seem to be no such file or directory

In it there is a folder called pkgs in this folder there is a kernel linux-2.6.31.tar.bz2 but this kernel does not contain any of the file or folder mentioned above.

I found these files seemed to be available here: linux-legacy/drivers/power/mxs at master · genesi/linux-legacy · GitHub though this kernel does not seem to actually boot at all once compiled, for now (I'm still making tests).

0 Kudos

2,134 Views
igorpadykov
NXP Employee
NXP Employee

for obtaining linux sources (folders with files) one needs to run ltib, refer for example

AN3984 i.MX35 Board Initialization and Memory Mapping Using the Linux Target Image Builder (LTIB)

Please create new thread if more assistance needed for ltib build.

0 Kudos

2,134 Views
pierreparent
Contributor III

I'm sorry but this is too complicated!

Why don't you simply distribute directly driver sources an/or Linux kernel sources?

I guess, if you can't provide me with a link for direct source download, it might be a GPL violation. GPL says:

Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.

Freescale allows direct download, of binary kernel, but not direct access to the source code, it seems. You need to get them to execute some program that does not work easily under ubuntu or debian (see many threads reporting problems with LTIB, And I can't have it work under debian testing).

Please add a link with kernel sources, that would be very helpfull! :smileywink:

0 Kudos

2,134 Views
sinanakman
Senior Contributor III

Hi Pierre

There is maybe a slight misunderstanding. I am not a Freescale employee but

what Igor refers to as LTIB is their open source build system, not just the kernel.

It includes their kernel patches as well u-boot and their root file system.

As far as I know Freescale does also provide git trees for their own kernel work.

I just googled and it returns me couple locations. The one you like to have is

probably : http://git.freescale.com/git/  (there is also a github tree).

If you look at this above link, you will see many git trees listed and some of them

are fairly recent. I think the one you are looking for is probably :

http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/ which is listed under

"imx" (the third tree from the top in the first link I mentioned above). Please

take a look at this and see if it is what you are looking for.

As mentioned I am not an Freescale employee and I do wish that Freescale

was contributing to mainline Linux tree instead of having their own but this is

a topic for another discussion.

Hope one of the trees I mention above will help you continue your driver work.

If not hopefully Freescale will chime in and provide you what you need.

Regards

Sinan Akman

0 Kudos

2,134 Views
pierreparent
Contributor III

Ok many thanks for the info about git repository I will try it!

Sorry if I got a little bit carried away, in my previous message.

0 Kudos