dmitrysmagin / dingoo-linux

Automatically exported from code.google.com/p/dingoo-linux
1 stars 2 forks source link

Allow battery level reading #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
-

Original issue reported on code.google.com by igga...@gmail.com on 10 Jun 2009 at 10:45

GoogleCodeExporter commented 9 years ago

Original comment by igga...@gmail.com on 14 Jun 2009 at 3:17

GoogleCodeExporter commented 9 years ago
Can you give me a short pointer on this one? Might be a good learning 
experience. :)

Original comment by tor...@pltn.org on 29 Jun 2009 at 3:07

GoogleCodeExporter commented 9 years ago
Good to see some help coming :-)

This is what I would do:

1- Investigate what's the standard way to read the battery level from userspace.

2-  Investigate how battery level is read in kernel for other systems.
Focus on special platforms like handheld devices, because I bet in PC
platforms it is ACPI and that would be huge overkill.

3- Locate a driver for one of those platforms that use an integrated
ADC to read battery voltage, and use it as a template.

4- Study how the ADC works in the JZ4740. Check if there is some code
in the linux kernel (I seem to remember ther was something in the
"char drivers" section... sorry, don't have the code here). Also check
out the uCOSII code.

Anything you find out, please let me know. I'll be glad to help as time permits.

Original comment by igga...@gmail.com on 29 Jun 2009 at 9:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
there indeed was some code in the char drivers. there are ldc-specific 
functions for
reading the battery and a general function (jz_read_battery) which calls a
function pointer. the general function wasn't used anywhere, so i added a ioctl
(IOCTL_GET_BATTERY 2) to the jz-ts driver. seems to return a value between 0 
and max
int32 (defined as JZ_TS_MAX_BATTERY).

i still have to test this with a discharged dingoo, though ... the value also
fluctuates a bit, but i assume this is normal. 

Original comment by tor...@pltn.org on 30 Jun 2009 at 10:06

GoogleCodeExporter commented 9 years ago
ok, the value returned is still somewhere near JZ_TS_MAX_BATTERY when the 
original
firmware displays about 1/3 discharge.

Original comment by tor...@pltn.org on 1 Jul 2009 at 9:05

GoogleCodeExporter commented 9 years ago
got it working now (watching my dingoo slowly charge via usb), will clean it up 
and
send a patch against trunk ...

Original comment by tor...@pltn.org on 1 Jul 2009 at 6:54

GoogleCodeExporter commented 9 years ago
the patch

Original comment by tor...@pltn.org on 1 Jul 2009 at 7:31

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch. Eventually I implemented it via /proc/jz/battery which is 
more
convenient.

Original comment by igga...@gmail.com on 5 Jul 2009 at 4:37