|
From: <mar...@us...> - 2007-05-27 21:06:25
|
Revision: 1001
http://svn.sourceforge.net/hackndev/?rev=1001&view=rev
Author: marex_z71
Date: 2007-05-27 14:05:55 -0700 (Sun, 27 May 2007)
Log Message:
-----------
l4p: fix battery driver on other models, needs to be revided though
Modified Paths:
--------------
linux4palm/linux/trunk/arch/arm/mach-pxa/palmt5/palmt5_battery.c
linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c
linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmt5/palmt5_battery.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmt5/palmt5_battery.c 2007-05-27 17:44:20 UTC (rev 1000)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmt5/palmt5_battery.c 2007-05-27 21:05:55 UTC (rev 1001)
@@ -16,8 +16,9 @@
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/battery.h>
+#include <linux/apm-emulation.h>
+#include <linux/wm97xx.h>
-#include <asm/apm.h>
#include <asm/delay.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -25,16 +26,14 @@
#include <asm/arch/hardware.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/irqs.h>
+#include <asm/arch/palmt5-gpio.h>
+#include <asm/arch/palmt5-init.h>
#include <sound/driver.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/initval.h>
-#include <linux/wm97xx.h>
-#include <asm/arch/palmt5-gpio.h>
-#include <asm/arch/palmt5-init.h>
-
struct palmt5_battery_dev
{
struct wm97xx * wm;
@@ -46,7 +45,7 @@
struct palmt5_battery_dev bat;
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
/* original APM hook */
static void (*apm_get_power_status_orig)(struct apm_power_info *info);
#endif
@@ -81,6 +80,17 @@
}
}
+int palmt5_battery_get_capacity(struct battery *b)
+{
+ if (bat.battery_registered){
+ return ((palmt5_battery_get_voltage(b)-palmt5_battery_min_voltage(b))
+ /(palmt5_battery_max_voltage(b)-palmt5_battery_min_voltage(b)));
+ }
+ else{
+ printk("palmt5_battery: cannot get capacity -> battery driver unregistered\n");
+ return 0;
+ }
+}
int palmt5_battery_get_status(struct battery *b)
{
@@ -99,13 +109,53 @@
return BATTERY_STATUS_DISCHARGING;
}
+int tmp;
+
+static void *palmt5_battery_get_property(struct battery *b, enum battery_property bp)
+{
+ switch (bp) {
+ case BATTERY_PROP_VOLTAGE_MAX_DESIGN:
+ tmp = palmt5_battery_max_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_VOLTAGE_MIN_DESIGN:
+ tmp = palmt5_battery_min_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_CHARGE_FULL_DESIGN:
+ tmp = 100;
+ return &tmp;
+ case BATTERY_PROP_CHARGE_EMPTY_DESIGN:
+ tmp = 0;
+ return &tmp;
+ case BATTERY_PROP_CHARGE_NOW:
+ tmp = palmt5_battery_get_capacity(b);
+ return &tmp;
+ case BATTERY_PROP_VOLTAGE_NOW:
+ tmp = palmt5_battery_get_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_STATUS:
+ tmp = palmt5_battery_get_status(b);
+ return &tmp;
+ default: break;
+ };
+
+ return NULL;
+}
+
+static enum battery_property palmld_battery_props[] = {
+ BATTERY_PROP_VOLTAGE_MAX_DESIGN,
+ BATTERY_PROP_VOLTAGE_MIN_DESIGN,
+ BATTERY_PROP_CHARGE_FULL_DESIGN,
+ BATTERY_PROP_CHARGE_EMPTY_DESIGN,
+ BATTERY_PROP_CHARGE_NOW,
+ BATTERY_PROP_VOLTAGE_NOW,
+ BATTERY_PROP_STATUS,
+};
+
struct battery palmt5_battery = {
- .name = "palmt5_battery",
- .id = "battery0",
- .get_min_voltage = palmt5_battery_min_voltage,
- .get_max_voltage = palmt5_battery_max_voltage,
- .get_voltage = palmt5_battery_get_voltage,
- .get_status = palmt5_battery_get_status,
+ .name = "palmt5_battery",
+ .get_property = palmt5_battery_get_property,
+ .properties = palmt5_battery_props,
+ .num_properties = ARRAY_SIZE(palmt5_battery_props),
};
static int palmt5_wm97xx_probe(struct device *dev)
@@ -123,7 +173,7 @@
static void
palmt5_wm97xx_shutdown(struct device *dev)
{
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
apm_get_power_status = apm_get_power_status_orig;
#endif
}
@@ -163,7 +213,7 @@
return ret;
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
/* APM status query callback implementation */
static void palmt5_apm_get_power_status(struct apm_power_info *info)
@@ -208,14 +258,14 @@
/* register battery to APM layer */
bat.battery_registered = 0;
- if(battery_class_register(&palmt5_battery)) {
+ if(battery_register(&palmt5_battery)) {
printk(KERN_ERR "palmt5_ac97_probe: could not register battery class\n");
}
else {
bat.battery_registered = 1;
printk("Battery registered\n");
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
apm_get_power_status_orig = apm_get_power_status;
apm_get_power_status = palmt5_apm_get_power_status;
#endif
@@ -231,7 +281,7 @@
static void __exit palmt5_wm97xx_exit(void)
{
/* TODO - recover APM callback to original state */
- battery_class_unregister(&palmt5_battery);
+ battery_unregister(&palmt5_battery);
driver_unregister(&palmt5_wm97xx_driver);
}
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c 2007-05-27 17:44:20 UTC (rev 1000)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c 2007-05-27 21:05:55 UTC (rev 1001)
@@ -21,8 +21,9 @@
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/battery.h>
+#include <linux/apm-emulation.h>
+#include <linux/wm97xx.h>
-#include <asm/apm.h>
#include <asm/delay.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -30,16 +31,14 @@
#include <asm/arch/hardware.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/irqs.h>
+#include <asm/arch/palmtx-gpio.h>
+#include <asm/arch/palmtx-init.h>
#include <sound/driver.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/initval.h>
-#include <linux/wm97xx.h>
-#include <asm/arch/palmtx-gpio.h>
-#include <asm/arch/palmtx-init.h>
-
struct palmtx_battery_dev
{
struct wm97xx * wm;
@@ -51,7 +50,7 @@
struct palmtx_battery_dev bat;
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
/* original APM hook */
static void (*apm_get_power_status_orig)(struct apm_power_info *info);
#endif
@@ -86,6 +85,17 @@
}
}
+int palmtx_battery_get_capacity(struct battery *b)
+{
+ if (bat.battery_registered){
+ return ((palmtx_battery_get_voltage(b)-palmtx_battery_min_voltage(b))
+ /(palmtx_battery_max_voltage(b)-palmtx_battery_min_voltage(b)));
+ }
+ else{
+ printk("palmtx_battery: cannot get capacity -> battery driver unregistered\n");
+ return 0;
+ }
+}
int palmtx_battery_get_status(struct battery *b)
{
@@ -104,13 +114,53 @@
return BATTERY_STATUS_DISCHARGING;
}
+int tmp;
+
+static void *palmtx_battery_get_property(struct battery *b, enum battery_property bp)
+{
+ switch (bp) {
+ case BATTERY_PROP_VOLTAGE_MAX_DESIGN:
+ tmp = palmtx_battery_max_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_VOLTAGE_MIN_DESIGN:
+ tmp = palmtx_battery_min_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_CHARGE_FULL_DESIGN:
+ tmp = 100;
+ return &tmp;
+ case BATTERY_PROP_CHARGE_EMPTY_DESIGN:
+ tmp = 0;
+ return &tmp;
+ case BATTERY_PROP_CHARGE_NOW:
+ tmp = palmtx_battery_get_capacity(b);
+ return &tmp;
+ case BATTERY_PROP_VOLTAGE_NOW:
+ tmp = palmtx_battery_get_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_STATUS:
+ tmp = palmtx_battery_get_status(b);
+ return &tmp;
+ default: break;
+ };
+
+ return NULL;
+}
+
+static enum battery_property palmtx_battery_props[] = {
+ BATTERY_PROP_VOLTAGE_MAX_DESIGN,
+ BATTERY_PROP_VOLTAGE_MIN_DESIGN,
+ BATTERY_PROP_CHARGE_FULL_DESIGN,
+ BATTERY_PROP_CHARGE_EMPTY_DESIGN,
+ BATTERY_PROP_CHARGE_NOW,
+ BATTERY_PROP_VOLTAGE_NOW,
+ BATTERY_PROP_STATUS,
+};
+
struct battery palmtx_battery = {
- .name = "palmtx_battery",
- .id = "battery0",
- .get_min_voltage = palmtx_battery_min_voltage,
- .get_max_voltage = palmtx_battery_max_voltage,
- .get_voltage = palmtx_battery_get_voltage,
- .get_status = palmtx_battery_get_status,
+ .name = "palmtx_battery",
+ .get_property = palmtx_battery_get_property,
+ .properties = palmtx_battery_props,
+ .num_properties = ARRAY_SIZE(palmtx_battery_props),
};
static int palmtx_wm97xx_probe(struct device *dev)
@@ -128,7 +178,7 @@
static void
palmtx_wm97xx_shutdown(struct device *dev)
{
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
apm_get_power_status = apm_get_power_status_orig;
#endif
}
@@ -168,7 +218,7 @@
return ret;
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
/* APM status query callback implementation */
static void palmtx_apm_get_power_status(struct apm_power_info *info)
@@ -213,14 +263,14 @@
/* register battery to APM layer */
bat.battery_registered = 0;
- if(battery_class_register(&palmtx_battery)) {
+ if(battery_register(&palmtx_battery)) {
printk(KERN_ERR "palmtx_ac97_probe: could not register battery class\n");
}
else {
bat.battery_registered = 1;
printk("Battery registered\n");
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
apm_get_power_status_orig = apm_get_power_status;
apm_get_power_status = palmtx_apm_get_power_status;
#endif
@@ -236,7 +286,7 @@
static void __exit palmtx_wm97xx_exit(void)
{
/* TODO - recover APM callback to original state */
- battery_class_unregister(&palmtx_battery);
+ battery_unregister(&palmtx_battery);
driver_unregister(&palmtx_wm97xx_driver);
}
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c 2007-05-27 17:44:20 UTC (rev 1000)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c 2007-05-27 21:05:55 UTC (rev 1001)
@@ -17,8 +17,9 @@
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/battery.h>
+#include <linux/apm-emulation.h>
+#include <linux/wm97xx.h>
-#include <asm/apm.h>
#include <asm/delay.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
@@ -26,6 +27,8 @@
#include <asm/arch/hardware.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/irqs.h>
+#include <asm/arch/palmz72-gpio.h>
+#include <asm/arch/palmz72-init.h>
#include <sound/driver.h>
#include <sound/core.h>
@@ -47,7 +50,7 @@
struct palmz72_battery_dev bat;
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
/* original APM hook */
static void (*apm_get_power_status_orig)(struct apm_power_info *info);
#endif
@@ -82,6 +85,17 @@
}
}
+int palmz72_battery_get_capacity(struct battery *b)
+{
+ if (bat.battery_registered){
+ return ((palmz72_battery_get_voltage(b)-palmz72_battery_min_voltage(b))
+ /(palmz72_battery_max_voltage(b)-palmz72_battery_min_voltage(b)));
+ }
+ else{
+ printk("palmz72_battery: cannot get capacity -> battery driver unregistered\n");
+ return 0;
+ }
+}
int palmz72_battery_get_status(struct battery *b)
{
@@ -100,13 +114,53 @@
return BATTERY_STATUS_DISCHARGING;
}
+int tmp;
+
+static void *palmz72_battery_get_property(struct battery *b, enum battery_property bp)
+{
+ switch (bp) {
+ case BATTERY_PROP_VOLTAGE_MAX_DESIGN:
+ tmp = palmz72_battery_max_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_VOLTAGE_MIN_DESIGN:
+ tmp = palmz72_battery_min_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_CHARGE_FULL_DESIGN:
+ tmp = 100;
+ return &tmp;
+ case BATTERY_PROP_CHARGE_EMPTY_DESIGN:
+ tmp = 0;
+ return &tmp;
+ case BATTERY_PROP_CHARGE_NOW:
+ tmp = palmz72_battery_get_capacity(b);
+ return &tmp;
+ case BATTERY_PROP_VOLTAGE_NOW:
+ tmp = palmz72_battery_get_voltage(b);
+ return &tmp;
+ case BATTERY_PROP_STATUS:
+ tmp = palmz72_battery_get_status(b);
+ return &tmp;
+ default: break;
+ };
+
+ return NULL;
+}
+
+static enum battery_property palmz72_battery_props[] = {
+ BATTERY_PROP_VOLTAGE_MAX_DESIGN,
+ BATTERY_PROP_VOLTAGE_MIN_DESIGN,
+ BATTERY_PROP_CHARGE_FULL_DESIGN,
+ BATTERY_PROP_CHARGE_EMPTY_DESIGN,
+ BATTERY_PROP_CHARGE_NOW,
+ BATTERY_PROP_VOLTAGE_NOW,
+ BATTERY_PROP_STATUS,
+};
+
struct battery palmz72_battery = {
- .name = "palmz72_battery",
- .id = "battery0",
- .get_min_voltage = palmz72_battery_min_voltage,
- .get_max_voltage = palmz72_battery_max_voltage,
- .get_voltage = palmz72_battery_get_voltage,
- .get_status = palmz72_battery_get_status,
+ .name = "palmz72_battery",
+ .get_property = palmz72_battery_get_property,
+ .properties = palmz72_battery_props,
+ .num_properties = ARRAY_SIZE(palmz72_battery_props),
};
static int palmz72_wm97xx_probe(struct device *dev)
@@ -124,7 +178,7 @@
static void
palmz72_wm97xx_shutdown(struct device *dev)
{
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
apm_get_power_status = apm_get_power_status_orig;
#endif
}
@@ -164,7 +218,7 @@
return ret;
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
/* APM status query callback implementation */
static void palmz72_apm_get_power_status(struct apm_power_info *info)
@@ -209,14 +263,14 @@
/* register battery to APM layer */
bat.battery_registered = 0;
- if(battery_class_register(&palmz72_battery)) {
+ if(battery_register(&palmz72_battery)) {
printk(KERN_ERR "palmz72_ac97_probe: could not register battery class\n");
}
else {
bat.battery_registered = 1;
printk("Battery registered\n");
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE)
apm_get_power_status_orig = apm_get_power_status;
apm_get_power_status = palmz72_apm_get_power_status;
#endif
@@ -232,7 +286,7 @@
static void __exit palmz72_wm97xx_exit(void)
{
/* TODO - recover APM callback to original state */
- battery_class_unregister(&palmz72_battery);
+ battery_unregister(&palmz72_battery);
driver_unregister(&palmz72_wm97xx_driver);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|