2 * Battery driver for the Openmoko GTA01 device, using the pcf50606 chip.
4 * This is nothing more than a write-thru interface to the real logic,
5 * which is part of the pcf50606.c multifunction chip driver.
6 * Copyright © 2008 Mike Westerhof <mwester@dls.net>
9 * Portions liberally borrowed from olpc_battery.c, copyright below:
10 * Copyright © 2006 David Woodhouse <dwmw2@infradead.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
17 #include <linux/module.h>
18 #include <linux/err.h>
19 #include <linux/platform_device.h>
20 #include <linux/power_supply.h>
21 #include <linux/jiffies.h>
22 #include <linux/sched.h>
24 /*********************************************************************
25 * This global is set by the pcf50606 driver to the correct callback
26 *********************************************************************/
28 extern int (*pmu_bat_get_property
)(struct power_supply
*,
29 enum power_supply_property
,
30 union power_supply_propval
*);
33 /*********************************************************************
35 *********************************************************************/
36 static int gta01_bat_get_property(struct power_supply
*psy
,
37 enum power_supply_property psp
,
38 union power_supply_propval
*val
)
40 if (pmu_bat_get_property
)
41 return (pmu_bat_get_property
)(psy
, psp
, val
);
46 static enum power_supply_property gta01_bat_props
[] = {
47 POWER_SUPPLY_PROP_STATUS
,
48 POWER_SUPPLY_PROP_PRESENT
,
49 POWER_SUPPLY_PROP_ONLINE
,
50 POWER_SUPPLY_PROP_VOLTAGE_NOW
,
51 POWER_SUPPLY_PROP_CURRENT_NOW
,
52 POWER_SUPPLY_PROP_TEMP
,
53 POWER_SUPPLY_PROP_CAPACITY
,
56 /*********************************************************************
58 *********************************************************************/
60 static struct platform_device
*bat_pdev
;
62 static struct power_supply gta01_bat
= {
63 .properties
= gta01_bat_props
,
64 .num_properties
= ARRAY_SIZE(gta01_bat_props
),
65 .get_property
= gta01_bat_get_property
,
66 .use_for_apm
= 0, /* pcf50606 driver has its own apm driver */
69 static int __init
gta01_bat_init(void)
73 bat_pdev
= platform_device_register_simple("gta01-battery", 0, NULL
, 0);
75 return PTR_ERR(bat_pdev
);
77 gta01_bat
.name
= bat_pdev
->name
;
79 ret
= power_supply_register(&bat_pdev
->dev
, >a01_bat
);
81 platform_device_unregister(bat_pdev
);
86 static void __exit
gta01_bat_exit(void)
88 power_supply_unregister(>a01_bat
);
89 platform_device_unregister(bat_pdev
);
92 module_init(gta01_bat_init
);
93 module_exit(gta01_bat_exit
);
95 MODULE_AUTHOR("Mike Westerhof <mwester@dls.net>");
96 MODULE_LICENSE("GPL");
97 MODULE_DESCRIPTION("Battery driver for GTA01");