|
From: <hap...@us...> - 2007-02-02 23:37:57
|
Revision: 790
http://svn.sourceforge.net/hackndev/?rev=790&view=rev
Author: happy-slapin
Date: 2007-02-02 15:37:44 -0800 (Fri, 02 Feb 2007)
Log Message:
-----------
z72: New battery infrastructure
Modified Paths:
--------------
linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Kconfig
linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Makefile
linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Kconfig
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Kconfig 2007-02-02 09:01:13 UTC (rev 789)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Kconfig 2007-02-02 23:37:44 UTC (rev 790)
@@ -5,14 +5,6 @@
help
This enables support for PalmOne Zire 72 handheld.
-config PALMZ72_AC97
- tristate "Palm Zire 72 AC97 Driver"
- depends on MACH_PALMZ72
- default y if MACH_PALMZ72
- help
- Enable support for WM9712 touchscreen and battery driver for
- the PalmOne Zire 72 PDA.
-
config PALMZ72_PM
tristate "Palm Zire 72 Power Management support"
depends on MACH_PALMZ72
@@ -22,10 +14,12 @@
config PALMZ72_BATTERY
tristate "Palm Zire 72 Battery support"
- depends on MACH_PALMZ72 && TOUCHSCREEN_WM97XX
- default n
+ select TOUCHSCREEN_WM97XX
+ depends on MACH_PALMZ72
+ default m
help
Enable support for PalmOne Zire 72 battery to APM.
+ ATM use it only as module, otherwise it hangs.
config GPIOED
tristate "GPIOED"
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Makefile
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Makefile 2007-02-02 09:01:13 UTC (rev 789)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/Makefile 2007-02-02 23:37:44 UTC (rev 790)
@@ -3,7 +3,6 @@
#
obj-$(CONFIG_MACH_PALMZ72) += palmz72.o
-obj-$(CONFIG_PALMZ72_AC97) += palmz72_ac97.o
obj-$(CONFIG_PALMZ72_PM) += palmz72_pm.o
obj-$(CONFIG_PALMZ72_BATTERY) += palmz72_battery.o
obj-$(CONFIG_GPIOED) += gpioed.o
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c 2007-02-02 09:01:13 UTC (rev 789)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_battery.c 2007-02-02 23:37:44 UTC (rev 790)
@@ -1,9 +1,9 @@
/************************************************************************
- * linux/arch/arm/mach-pxa/palmz72/palmz72_ac97.c *
+ * linux/arch/arm/mach-pxa/palmz72/palmz72_battery.c *
* *
* Touchscreen/battery driver for Palm Zire 72 WM9712 AC97 codec *
- * Author: Jan Herman <2h...@se...> *
- * Based on palmld_ac97.c code from Alex Osborne *
+ * Authos: Jan Herman <2h...@se...> *
+ * Sergey Lapin <sl...@ha...> *
* *
************************************************************************/
@@ -32,75 +32,22 @@
#include <sound/pcm.h>
#include <sound/initval.h>
#include <linux/wm97xx.h>
-//#include <sound/wm9712.h>
#include <asm/arch/palmz72-gpio.h>
#include <asm/arch/palmz72-init.h>
-#define palmz72_ac97_WORK_QUEUE_NAME "palmz72_ac97_workqueue"
-
-
-/*********************
- * Module parameters *
- *********************/
-static DECLARE_MUTEX(battery_update_mutex);
-
-//static struct work_struct palmz72_ac97_irq_task;
-
-//struct device *palmz72_ac97_dev;
-
-//static ac97_t *ac97;
-
-static int battery_registered = 0;
-static unsigned long last_battery_update = 0;
-static int current_voltage;
-static int previous_voltage;
-//static u16 d2base;
-
-
-
-//EXPERIMENTAL DRIVER...
-
-/***********
- * Battery *
- ***********/
-
-
-void palmz72_battery_read_adc(unsigned long data)
+struct palmz72_battery_dev
{
- //unsigned long data;
- u16 vread;
- //int force;
-
- struct wm97xx *wm = (struct wm97xx*) data;
- //struct wm97xx* wm;
+ struct wm97xx * wm;
+ int battery_registered;
+ int current_voltage;
+ int previous_voltage;
+ u32 last_battery_update;
+};
- //if(wm == NULL) {
- // printk("Batt update error: struct wm97xx* wm is null!\n");
- // return;
- //}
+struct palmz72_battery_dev bat;
- //if(!force && ((last_battery_update + 10 *HZ) > jiffies))
- // return;
- //
- //if(down_trylock(&battery_update_mutex))
- // return;
-
- //aux_waiting:1;
- //vread = wm97xx_read_aux_adc(wm, WM97XX_AUX_ID3);
- vread = 1680; // THIS MUST READ AUX_ID3 on WM9712 -- for slapin.. other of battery works
-
- previous_voltage = current_voltage;
- current_voltage = vread & 0xfff;
- last_battery_update = jiffies;
-
- printk("Battery: %d\n", current_voltage);
-
- up(&battery_update_mutex);
-}
-
-
int palmz72_battery_min_voltage(struct battery *b)
{
return PALMZ72_BAT_MIN_VOLTAGE;
@@ -119,10 +66,12 @@
int palmz72_battery_get_voltage(struct battery *b)
{
- if (battery_registered){
- palmz72_battery_read_adc(0);
- printk("Battery [mV]: %d\n", current_voltage * 1889/1000 + 7678/10 );
- return current_voltage * 1889/1000 + 7678/10;
+ if (bat.battery_registered){
+ bat.previous_voltage = bat.current_voltage;
+ bat.current_voltage = wm97xx_read_aux_adc(bat.wm, TS_BMON);
+ bat.last_battery_update = jiffies;
+ printk("Battery [mV]: %d\n", bat.current_voltage * 1889/1000 + 7678/10 );
+ return bat.current_voltage * 1889/1000 + 7678/10;
}
else{
printk("palmz72_battery: cannot get voltage -> battery driver unregistered\n");
@@ -136,11 +85,11 @@
int ac_connected = GET_GPIO(GPIO_NR_PALMZ72_POWER_DETECT);
int usb_connected = !GET_GPIO(GPIO_NR_PALMZ72_USB_DETECT);
- if (current_voltage <= 0)
+ if (bat.current_voltage <= 0)
return BATTERY_STATUS_UNKNOWN;
if (ac_connected || usb_connected){
- if ( ( current_voltage > previous_voltage ) || (current_voltage <= PALMZ72_BAT_MAX_VOLTAGE) )
+ if ( ( bat.current_voltage > bat.previous_voltage ) || (bat.current_voltage <= PALMZ72_BAT_MAX_VOLTAGE) )
return BATTERY_STATUS_CHARGING;
return BATTERY_STATUS_NOT_CHARGING;
}
@@ -148,7 +97,6 @@
return BATTERY_STATUS_DISCHARGING;
}
-
struct battery palmz72_battery = {
.name = "palmz72_battery",
.id = "battery0",
@@ -158,8 +106,29 @@
.get_status = palmz72_battery_get_status,
};
+static int palmz72_wm97xx_probe(struct device *dev)
+{
+ struct wm97xx *wm = dev->driver_data;
+ bat.wm = wm;
+ return 0;
+}
+static int palmz72_wm97xx_remove(struct device *dev)
+{
+// struct wm97xx *wm = dev->driver_data;
+ return 0;
+}
+static struct device_driver palmz72_wm97xx_driver = {
+ .name = "wm97xx-touchscreen",
+ .bus = &wm97xx_bus_type,
+ .owner = THIS_MODULE,
+ .probe = palmz72_wm97xx_probe,
+ .remove = palmz72_wm97xx_remove,
+ .suspend = NULL,
+ .resume = NULL
+};
+
static int palmz72_ac_is_connected (void){
/* when charger is plugged in and USB is not connected, then status is ONLINE */
int ret = (!(GET_GPIO(GPIO_NR_PALMZ72_USB_PULLUP)) && !(GET_GPIO(GPIO_NR_PALMZ72_USB_DETECT)));;
@@ -171,17 +140,16 @@
return ret;
}
-/*******
- * APM *
- *******/
-
+#ifdef CONFIG_APM
+
+/* APM status query callback implementation */
static void palmz72_apm_get_power_status(struct apm_power_info *info)
{
int min, max, curr, percent;
- curr = palmz72_battery_get_voltage(NULL);
- min = palmz72_battery_min_voltage(NULL);
- max = palmz72_battery_max_voltage(NULL);
+ curr = palmz72_battery_get_voltage(&palmz72_battery);
+ min = palmz72_battery_min_voltage(&palmz72_battery);
+ max = palmz72_battery_max_voltage(&palmz72_battery);
curr = curr - min;
if (curr < 0) curr = 0;
@@ -207,50 +175,36 @@
info->time = percent * PALMZ72_MAX_LIFE_MINS/100;
info->units = APM_UNITS_MINS;
}
-
-typedef void (*apm_get_power_status_t)(struct apm_power_info*);
-
-int set_apm_get_power_status(apm_get_power_status_t t)
+#endif
+static int __init palmz72_wm97xx_init(void)
{
- apm_get_power_status = t;
+ /* register battery to APM layer */
+ bat.battery_registered = 0;
- return 0;
-}
-
-
-/* end of APM implementing */
-
-
-
-static int __init palmz72_ac97_init(void)
-{
-
-/* register battery to APM layer */
-
- if(battery_class_register(&palmz72_battery)) {
- printk(KERN_ERR "palmz72_ac97_probe: could not register battery class\n");
- }
- else{
- battery_registered = 1;
- printk("Battery registered\n");
- }
-#ifdef CONFIG_PM
- apm_get_power_status = palmz72_apm_get_power_status;
- return 0;
+ if(battery_class_register(&palmz72_battery)) {
+ printk(KERN_ERR "palmz72_ac97_probe: could not register battery class\n");
+ }
+ else {
+ bat.battery_registered = 1;
+ printk("Battery registered\n");
+ }
+#ifdef CONFIG_APM
+ apm_get_power_status = palmz72_apm_get_power_status;
#endif
-
+ return driver_register(&palmz72_wm97xx_driver);
}
-
-static void __exit palmz72_ac97_exit(void)
+static void __exit palmz72_wm97xx_exit(void)
{
- driver_unregister(&palmz72_battery);
+/* TODO - recover APM callback to original state */
+ battery_class_unregister(&palmz72_battery);
+ driver_unregister(&palmz72_wm97xx_driver);
}
+module_init(palmz72_wm97xx_init);
+module_exit(palmz72_wm97xx_exit);
-module_init(palmz72_ac97_init);
-module_exit(palmz72_ac97_exit);
-
-MODULE_AUTHOR ("Jan Herman <2h...@se...>");
-MODULE_DESCRIPTION ("WM9712 battery support for PalmOne Zire 72");
-MODULE_LICENSE ("GPL");
+/* Module information */
+MODULE_AUTHOR("Sergey Lapin <sl...@ha...> Jan Herman <2h...@se...>");
+MODULE_DESCRIPTION("wm97xx battery driver for Palm Zire 72");
+MODULE_LICENSE("GPL");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|