|
From: <mar...@us...> - 2007-02-18 12:43:14
|
Revision: 847
http://svn.sourceforge.net/hackndev/?rev=847&view=rev
Author: marex_z71
Date: 2007-02-18 04:43:11 -0800 (Sun, 18 Feb 2007)
Log Message:
-----------
K2-6-20-hnd0: Sync with 2.6.20-hh from 02/18/2007 13:35 GMT+1 ;minor fixes
Modified Paths:
--------------
linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/Kconfig
linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/aximx50_ts.c
linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_cpld.c
linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_ts.c
linux4palm/linux/trunk/drivers/hwmon/battery/Kconfig
linux4palm/linux/trunk/drivers/hwmon/battery/ds2760_battery.c
linux4palm/linux/trunk/drivers/hwmon/battery/magician-battery.c
linux4palm/linux/trunk/drivers/input/touchscreen/ts-adc-debounce.c
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/Kconfig
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/Kconfig 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/Kconfig 2007-02-18 12:43:11 UTC (rev 847)
@@ -24,7 +24,7 @@
config X50_TS
tristate "ADS7846 / TSC2046 touchscreen support"
depends on MACH_X50
- select TOUCHSCREEN_ADS7846_SSP
+ select TOUCHSCREEN_ADC_DEBOUNCE
help
X50/X51(v) touchscreen support.
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/aximx50_ts.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/aximx50_ts.c 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/aximx50/aximx50_ts.c 2007-02-18 12:43:11 UTC (rev 847)
@@ -14,7 +14,7 @@
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/ads7846.h>
-#include <linux/ads7846ts.h>
+#include <linux/touchscreen-adc.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
@@ -39,8 +39,10 @@
};
struct ads7846ts_ssp_platform_data aximx50_ts_params = {
- .irq = IRQ_GPIO(GPIO_NR_X50_PEN_IRQ_N),
- .gpio = GPIO_NR_X50_PEN_IRQ_N,
+ .pen_irq = IRQ_GPIO(GPIO_NR_X50_PEN_IRQ_N),
+ .pen_gpio = GPIO_NR_X50_PEN_IRQ_N,
+ .adc_dev = &ads7846_ssp.dev,
+ .sense = ads7846_sense,
};
static struct platform_device aximx50_ts = {
.name = "ads7846ts-ssp",
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_cpld.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_cpld.c 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_cpld.c 2007-02-18 12:43:11 UTC (rev 847)
@@ -281,7 +281,7 @@
dbg ("EP\nep_state = 0x%02x\n", cpld->mapping->cpld18);
break;
case 0x4:
- dbg ("BT\n", cable_state);
+ dbg ("BT\n");
break;
case 0x8:
dbg ("AC\ncable_state = 0x%02x\n", cable_state);
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_ts.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_ts.c 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/magician/magician_ts.c 2007-02-18 12:43:11 UTC (rev 847)
@@ -717,21 +717,6 @@
.get_charge = get_charge,
.get_status = get_status,
};
-
-static int
-battery_class_uevent(struct class_device *dev, char **envp, int num_envp,
- char *buffer, int buffer_size)
-{
- return 0;
-}
-
-static void battery_class_release(struct class_device *dev)
-{
-}
-
-static void battery_class_class_release(struct class *class)
-{
-}
#endif
static int tssim_init(void)
@@ -761,10 +746,6 @@
"magician_ts: Could not register battery class\n");
} else {
battery_class = 1;
- magician_power.class_dev.class->uevent = battery_class_uevent;
- magician_power.class_dev.class->release = battery_class_release;
- magician_power.class_dev.class->class_release =
- battery_class_class_release;
}
#endif
Modified: linux4palm/linux/trunk/drivers/hwmon/battery/Kconfig
===================================================================
--- linux4palm/linux/trunk/drivers/hwmon/battery/Kconfig 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/drivers/hwmon/battery/Kconfig 2007-02-18 12:43:11 UTC (rev 847)
@@ -26,8 +26,7 @@
config MAGICIAN_BATTERY
tristate "HTC Magician battery control"
- depends on MACH_MAGICIAN && BATTERY_MONITOR
- select W1_DS2760
+ depends on MACH_MAGICIAN && DS2760_BATTERY
help
Say Y here to enable support for HTC Magician battery control.
Modified: linux4palm/linux/trunk/drivers/hwmon/battery/ds2760_battery.c
===================================================================
--- linux4palm/linux/trunk/drivers/hwmon/battery/ds2760_battery.c 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/drivers/hwmon/battery/ds2760_battery.c 2007-02-18 12:43:11 UTC (rev 847)
@@ -197,7 +197,6 @@
acr[0] = (di->status.full_active_mAh * 4) >> 8;
acr[1] = (di->status.full_active_mAh * 4) & 0xff;
-printk(KERN_ERR "writing %d to ACR\n", di->status.full_active);
if (w1_ds2760_write(di->w1_dev, acr,
DS2760_CURRENT_ACCUM_MSB, 2) < 2)
printk(KERN_ERR "ACR reset failed\n");
Modified: linux4palm/linux/trunk/drivers/hwmon/battery/magician-battery.c
===================================================================
--- linux4palm/linux/trunk/drivers/hwmon/battery/magician-battery.c 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/drivers/hwmon/battery/magician-battery.c 2007-02-18 12:43:11 UTC (rev 847)
@@ -1,542 +1,208 @@
/*
- * Battery driver lowlevel interface for HTC Magician
+ * Battery driver for HTC Magician
*
- * Copyright (c) 2006 Philipp Zabel
- * 2004 Matt Reimer
- * 2004 Szabolcs Gyurko
+ * Copyright 2007 Philipp Zabel <phi...@gm...>
+ * Copyright 2007 Anton Vorontsov <cb...@ma...>
+ * Copyright 2005 SDG Systems, LLC
+ * Copyright 2005 Aric D. Blumer
+ * Copyright 2005 Phil Blundell
*
- * Use consistent with the GNU GPL is permitted,
- * provided that this copyright notice is
- * preserved in its entirety in all copies and derived works.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
*
- * Author: Philipp Zabel <phi...@gm...>
- * December 2006
- *
- * Matt Reimer <mr...@vp...>
- * April 2004, 2005
- *
- * Szabolcs Gyurko <sza...@tl...>
- * September 2004
- *
- * To do:
- *
- * - While suspended, periodically check for battery full and update
- * the LED status.
- * - Should we turn off the charger GPIO when the battery is full?
- * - Is the battery status caching necessary?
+ * History:
+ * 2007/02/14 Anton Vorontsov Use ds2760_battery driver, cleanup
*/
#include <linux/module.h>
-#include <linux/version.h>
-//#include <linux/init.h>
-//#include <linux/fs.h>
-#include <linux/interrupt.h> /* request_irq */
-//#include <linux/sched.h>
-//#include <linux/pm.h>
-//#include <linux/sysctl.h>
-//#include <linux/proc_fs.h>
-#include <linux/delay.h>
-#include <linux/jiffies.h>
#include <linux/platform_device.h>
-#include <linux/battery.h>
+#include <linux/timer.h>
+#include <linux/pm.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
#include <linux/leds.h>
-
-//#include <asm/io.h>
-#include <asm/irq.h> /* IRQF..., IRQT... */
+#include <linux/ds2760_battery.h>
+#include <asm/mach-types.h>
+#include <asm/hardware.h>
#include <asm/apm.h>
-#include <asm/arch/hardware.h> /* __REG */
-#include <asm/arch/pxa-regs.h> /* pxa GPIOs */
-#include <asm/arch/magician.h> /* magician specific GPIOs */
-#include <asm/arch/magician_cpld.h> /* magician_cable_state() */
+#include <asm/gpio.h>
+#include <asm/arch/magician.h>
+#include <asm/arch/magician_cpld.h>
-#include "../../w1/w1.h"
-#include "../../w1/slaves/w1_ds2760.h"
+#define DRIVER_NAME "magician_power"
-extern struct platform_device magician_cpld;
+#define POWER_NONE 0
+#define POWER_AC 1
+#define POWER_USB 2
-#define MAGICIAN_BATTERY_MAX_VOLTAGE 4400 /* My measurements */
-#define MAGICIAN_BATTERY_MIN_VOLTAGE 0 /* Maybe incorrect */
-#define MAGICIAN_BATTERY_MAX_CURRENT 950 /* MUST BE MEASURED */
-#define MAGICIAN_BATTERY_MIN_CURRENT -950 /* Maybe incorrect */
-#define MAGICIAN_BATTERY_MIN_CHARGE 0 /* Maybe incorrect */
+static struct ds2760_device_info ds2760_di;
+static int supply_status;
+static unsigned int ac_irq;
+struct timer_list isr_timer;
-#define BATTERY_CHECK_INTERVAL (HZ * 60) /* every 60 seconds */
+DEFINE_LED_TRIGGER(charging_trig);
+DEFINE_LED_TRIGGER(chargefull_trig);
-#define POWER_NONE 0
-#define POWER_AC 1
+extern struct platform_device magician_cpld;
-/* AC present? */
-static int power_status;
-
-/* w1_samcop device */
-static struct workqueue_struct *probe_q;
-static struct work_struct probe_work;
-
-/* DS2760 device */
-struct device *ds2760_dev = NULL;
-
-/* Cache the battery status for this many seconds. */
-#define STATUS_CACHE_TIME (HZ * 1)
-static struct ds2760_status battery_status;
-
-static int battery_charge_state;
-#define BATTERY_STATE_UNKNOWN 0
-#define BATTERY_DISCHARGING 1
-#define BATTERY_CHARGING 2
-#define BATTERY_FULL 3
-
-/* battery monitor */
-static struct timer_list monitor_timer;
-static struct workqueue_struct *monitor_q;
-static struct work_struct monitor_work;
-
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-/* original APM hook */
-static void (*apm_get_power_status_orig)(struct apm_power_info *info);
-#endif
-
-DEFINE_LED_TRIGGER(magician_charge_led_trigger)
-DEFINE_LED_TRIGGER(magician_charge_full_led_trigger)
-
-magician_battery_read_status(void)
+static void magician_update_leds(struct ds2760_device_info *di)
{
- if (jiffies < (battery_status.update_time + STATUS_CACHE_TIME))
- return 0;
-
- if (!ds2760_dev)
- return 0;
-
- if (!w1_ds2760_status(ds2760_dev, &battery_status)) {
- printk("call to w1_ds2760_status failed (0x%08x)\n",
- (unsigned int)ds2760_dev);
- return 1;
+ if (supply_status) {
+ if (di->charge_status == BATTERY_STATUS_FULL) {
+ led_trigger_event(chargefull_trig, LED_FULL);
+ led_trigger_event(charging_trig, LED_OFF);
+ return;
+ }
+ else if (di->charge_status == BATTERY_STATUS_CHARGING) {
+ led_trigger_event(chargefull_trig, LED_FULL);
+ led_trigger_event(charging_trig, LED_FULL);
+ return;
+ }
}
-
- return 0;
+ led_trigger_event(chargefull_trig, LED_OFF);
+ led_trigger_event(charging_trig, LED_OFF);
}
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-static void
-magician_apm_get_power_status (struct apm_power_info *info)
-{
- magician_battery_read_status();
-
- info->ac_line_status = (power_status != POWER_NONE) ?
- APM_AC_ONLINE : APM_AC_OFFLINE;
-
- if (info->ac_line_status == APM_AC_ONLINE && current > 0) {
- info->battery_status = APM_BATTERY_STATUS_CHARGING;
- } else {
-
- info->battery_status = battery_status.accum_current_mAh >
- ((battery_status.rated_capacity * 75) / 100) ?
- APM_BATTERY_STATUS_HIGH :
- battery_status.accum_current_mAh >
- ((battery_status.rated_capacity* 25) / 100) ?
- APM_BATTERY_STATUS_LOW : APM_BATTERY_STATUS_CRITICAL;
+static void magician_supply_changed(void) {
+ if (supply_status) {
+ /* We're on AC or USB, charge */
+ gpio_set_value(GPIO_NR_MAGICIAN_USB_CHARGE_N, 0);
}
-
- info->battery_flag = info->battery_status;
-
- if (battery_status.rated_capacity)
- info->battery_life = (battery_status.accum_current_mAh * 100) /
- battery_status.rated_capacity;
-
- if (info->battery_life > 100)
- info->battery_life = 100;
- if (info->battery_life < 0)
- info->battery_life = 0;
-
- if (battery_status.current_mA) {
- info->time = - ((battery_status.accum_current_mAh * 6000) /
- battery_status.current_mA) / 100;
- info->units = APM_UNITS_MINS;
- } else
- info->units = APM_UNITS_UNKNOWN;
+ else {
+ /* We're not on AC or USB, don't charge */
+ gpio_set_value(GPIO_NR_MAGICIAN_USB_CHARGE_N, 1);
+ }
}
-#endif
-int
-magician_battery_get_max_voltage(struct battery *bat)
+static int magician_update_supply_status(void)
{
- return MAGICIAN_BATTERY_MAX_VOLTAGE;
-}
+ unsigned int cable_state;
+ cable_state = magician_cable_state(&magician_cpld);
-int
-magician_battery_get_min_voltage(struct battery *bat)
-{
- return MAGICIAN_BATTERY_MIN_VOLTAGE;
-}
+ supply_status = POWER_NONE;
+ if (cable_state == 1) supply_status |= POWER_AC;
+ if (cable_state == 2) supply_status |= POWER_USB;
-int
-magician_battery_get_voltage(struct battery *bat)
-{
- magician_battery_read_status();
- return battery_status.voltage_mV;
+ return supply_status;
}
-int
-magician_battery_get_max_current(struct battery *bat)
+static void magician_isr_timer_func(unsigned long enableirq)
{
- return MAGICIAN_BATTERY_MAX_CURRENT;
-}
+ supply_status = magician_update_supply_status();
-int
-magician_battery_get_min_current(struct battery *bat)
-{
- return MAGICIAN_BATTERY_MIN_CURRENT;
-}
+ magician_supply_changed();
+ magician_update_leds(&ds2760_di);
-int
-magician_battery_get_current(struct battery *bat)
-{
- magician_battery_read_status();
- return battery_status.current_mA;
-}
+ if (ds2760_di.power_supply_changed)
+ ds2760_di.power_supply_changed(&ds2760_di);
-int
-magician_battery_get_max_charge(struct battery *bat)
-{
- magician_battery_read_status();
- return battery_status.rated_capacity;
-}
-
-int
-magician_battery_get_min_charge(struct battery *bat)
-{
- return MAGICIAN_BATTERY_MIN_CHARGE;
-}
-
-int
-magician_battery_get_charge(struct battery *bat)
-{
- magician_battery_read_status();
- return battery_status.accum_current_mAh;
-}
-
-int
-magician_battery_get_temp(struct battery *bat)
-{
- magician_battery_read_status();
- return battery_status.temp_C;
-}
-
-int
-magician_battery_get_status(struct battery *bat)
-{
- int status;
-
- // this could be taken from GPIO30 (CHARGE_EN?) or DS2760 status.
- status = (GPLR(GPIO_NR_MAGICIAN_USB_CHARGE_N) & GPIO_bit(GPIO_NR_MAGICIAN_USB_CHARGE_N)) ?
- BATTERY_STATUS_NOT_CHARGING : BATTERY_STATUS_CHARGING;
-
- return status;
-}
-
-void
-magician_battery_update_status(void *data)
-{
- static int full_counter;
-
- magician_battery_read_status();
-
- if (battery_charge_state == BATTERY_STATE_UNKNOWN)
- full_counter = 0;
-
- /* Set the proper charging rate. */
- power_status = magician_cable_state(&magician_cpld);
- if (power_status) {
-
- GPCR(GPIO_NR_MAGICIAN_USB_CHARGE_N) = GPIO_bit(GPIO_NR_MAGICIAN_USB_CHARGE_N);
- //gpio_set_value(GPIO30_MAGICIAN_USB_CHARGE_N, 0);
-
- if (battery_status.current_mA > 10) {
-
- battery_charge_state = BATTERY_CHARGING;
- full_counter = 0;
-
- } else if (battery_status.current_mA < 10 &&
- battery_charge_state != BATTERY_FULL) {
-
- /* Don't consider the battery to be full unless
- * we've seen the current < 10 mA at least two
- * consecutive times. */
-
- full_counter++;
-
- if (full_counter < 2)
- battery_charge_state = BATTERY_CHARGING;
- else {
-
- unsigned char acr[2];
-
- acr[0] = (battery_status.rated_capacity * 4) >> 8;
- acr[1] = (battery_status.rated_capacity * 4) & 0xff;
-
- if (w1_ds2760_write(ds2760_dev, acr,
- DS2760_CURRENT_ACCUM_MSB, 2) < 2)
- printk(KERN_ERR "ACR reset failed\n");
- battery_charge_state = BATTERY_FULL;
- }
- }
-
- if (battery_charge_state == BATTERY_CHARGING) {
-
- /* Blink the LED while plugged in and charging. */
- led_trigger_event(magician_charge_led_trigger, LED_FULL);
- led_trigger_event(magician_charge_full_led_trigger, LED_FULL);
- //leds_set_frequency(h2200_power_led, 500);
- } else {
-
- /* Set the LED solid while on AC and not charging. */
- led_trigger_event(magician_charge_led_trigger, LED_OFF);
- led_trigger_event(magician_charge_full_led_trigger, LED_FULL);
- //leds_set_frequency(h2200_power_led, 0);
- }
-
- } else {
-
- battery_charge_state = BATTERY_DISCHARGING;
- full_counter = 0;
-
- GPSR(GPIO_NR_MAGICIAN_USB_CHARGE_N) = GPIO_bit(GPIO_NR_MAGICIAN_USB_CHARGE_N);
- //gpio_set_value(GPIO30_MAGICIAN_USB_CHARGE_N, 1);
-
- /* Turn off the LED while unplugged from AC. */
- led_trigger_event(magician_charge_led_trigger, LED_OFF);
- led_trigger_event(magician_charge_full_led_trigger, LED_OFF);
- //leds_set_frequency(h2200_power_led, 0);
+ if (enableirq) {
+ enable_irq(ac_irq);
}
+ return;
}
-static irqreturn_t magician_ac_plug_isr (int isr, void *data)
+static irqreturn_t magician_attach_isr(int irq, void *dev_id)
{
-
- /* Update the LED status right away, for timely feedback. */
-
- int power_status = magician_cable_state(&magician_cpld);
- if (power_status) {
- /* Start off with a solid LED; if we're charging,
- the LED state will be updated when the queued work runs. */
- led_trigger_event(magician_charge_led_trigger, LED_HALF);
- led_trigger_event(magician_charge_full_led_trigger, LED_HALF);
- //leds_set_frequency(h2200_power_led, 0);
- } else {
- led_trigger_event(magician_charge_led_trigger, LED_OFF);
- led_trigger_event(magician_charge_full_led_trigger, LED_OFF);
- //leds_set_frequency(h2200_power_led, 0);
+ if(irq != ac_irq) {
+ printk(DRIVER_NAME " bad irq: %d, not %d\n",
+ irq, ac_irq);
}
- /* Force the data to be re-read. */
- battery_status.update_time = 0;
+ gpio_set_value(GPIO_NR_MAGICIAN_USB_CHARGE_N, 1);
+ mod_timer(&isr_timer, jiffies + HZ/10);
+ disable_irq(ac_irq);
- /* Wait a few seconds to let the DS2760 update its current reading. */
- queue_delayed_work(monitor_q, &monitor_work, HZ * 7);
-
return IRQ_HANDLED;
}
-static struct battery magician_battery = {
- .name = "magician_main",
- .id = "main battery",
- .get_voltage = magician_battery_get_voltage,
- .get_min_voltage = magician_battery_get_min_voltage,
- .get_max_voltage = magician_battery_get_max_voltage,
- .get_current = magician_battery_get_current,
- .get_min_current = magician_battery_get_min_current,
- .get_max_current = magician_battery_get_max_current,
- .get_charge = magician_battery_get_charge,
- .get_min_charge = magician_battery_get_min_charge,
- .get_max_charge = magician_battery_get_max_charge,
- .get_temp = magician_battery_get_temp,
- .get_status = magician_battery_get_status,
-};
-
-/* -------------------------------------------------------------------- */
-
-static int
-magician_battery_match_callback(struct device *dev, void *data)
+static void magician_charge_callback(struct ds2760_device_info *di)
{
- struct w1_slave *sl;
-
- if (!(dev->driver && dev->driver->name &&
- (strcmp(dev->driver->name, "w1_slave_driver") == 0)))
- return 0;
-
- sl = container_of(dev, struct w1_slave, dev);
-
- /* DS2760 w1 slave device names begin with the family number 0x30. */
- if (strncmp(sl->name, "30-", 3) != 0)
- return 0;
-
- return 1;
+ magician_update_leds(di);
+ return;
}
-void
-magician_battery_probe_work(void *data)
+void magician_null_release(struct device *dev)
{
- struct bus_type *bus;
-
- /* Get the battery w1 slave device. */
- bus = find_bus("w1");
- if (bus)
- ds2760_dev = bus_find_device(bus, NULL, NULL,
- magician_battery_match_callback);
-
- if (!ds2760_dev) {
- /* No DS2760 device found; try again later. */
- queue_delayed_work(probe_q, &probe_work, HZ * 5);
- return;
- }
+ return; /* current platform_device api is weird */
}
+static struct ds2760_device_info ds2760_di = {
+ .name = "magician_primary",
+ .id = "main",
+ .max_voltage = 4750,
+ .min_voltage = 0,
+ .max_current = 950,
+ .min_current = -950,
+ .min_charge = 0,
+ .power_supplied = magician_update_supply_status,
+ .charge_callback = magician_charge_callback,
+};
-static void
-magician_battery_timer(unsigned long data)
-{
- queue_work(monitor_q, &monitor_work);
- mod_timer(&monitor_timer, jiffies + BATTERY_CHECK_INTERVAL);
-}
+static struct platform_device ds2760_pdev = {
+ .name = "ds2760-battery",
+ .dev = {
+ .platform_data = &ds2760_di,
+ .release = magician_null_release,
+ },
+};
-static int
-magician_battery_probe(struct platform_device *dev)
-{
- printk("Battery interface for HTC Magician\n");
-
- battery_charge_state = BATTERY_STATE_UNKNOWN;
-
- /* Install an interrupt handler for AC plug/unplug. */
-// set_irq_type(IRQ_MAGICIAN_AC, IRQT_BOTHEDGE);
- request_irq(IRQ_MAGICIAN_AC, magician_ac_plug_isr, IRQF_SAMPLE_RANDOM,
- "AC plug", NULL);
-
- /* Create a workqueue in which the battery monitor will run. */
- monitor_q = create_singlethread_workqueue("battmon");
- INIT_WORK(&monitor_work, magician_battery_update_status, NULL);
-
- /* Create a timer to run the battery monitor every
- BATTERY_CHECK_INTERVAL seconds. */
- init_timer(&monitor_timer);
- monitor_timer.function = magician_battery_timer;
- monitor_timer.data = 0;
-
- /* Start the first monitor task a few seconds from now. */
- mod_timer(&monitor_timer, jiffies + HZ * 10);
-
#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
- apm_get_power_status = magician_apm_get_power_status;
-#endif
-
- led_trigger_register_simple("magician-charge", &magician_charge_led_trigger);
- led_trigger_register_simple("magician-charge-full", &magician_charge_full_led_trigger);
-
- /* Get the DS2760 W1 device. */
- probe_q = create_singlethread_workqueue("battmonprb");
- INIT_WORK(&probe_work, magician_battery_probe_work, NULL);
- magician_battery_probe_work(NULL);
-
- return 0;
-}
-
-static void
-magician_battery_shutdown(struct platform_device *dev)
+static void magician_apm_get_power_status(struct apm_power_info *info)
{
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
- apm_get_power_status = apm_get_power_status_orig;
+ ds2760_di.get_apm_power_info(&ds2760_di, info);
+ return;
+}
#endif
- del_timer_sync(&monitor_timer);
-
- cancel_delayed_work(&monitor_work);
- flush_workqueue(monitor_q);
- destroy_workqueue(monitor_q);
-
- cancel_delayed_work(&probe_work);
- flush_workqueue(probe_q);
- destroy_workqueue(probe_q);
-
- if (ds2760_dev)
- put_device(ds2760_dev);
-
- free_irq(IRQ_MAGICIAN_AC, NULL);
-
- led_trigger_event(magician_charge_led_trigger, LED_OFF);
- led_trigger_event(magician_charge_full_led_trigger, LED_OFF);
- //leds_set_frequency(h2200_power_led, 0);
- led_trigger_unregister_simple(magician_charge_led_trigger);
- led_trigger_unregister_simple(magician_charge_full_led_trigger);
-}
-
-static int
-magician_battery_remove(struct platform_device *dev)
+static int magician_battery_init (void)
{
- magician_battery_shutdown(dev);
- return 0;
-}
+ int ret;
-static int
-magician_battery_suspend(struct platform_device *dev, pm_message_t state)
-{
- cancel_delayed_work(&monitor_work);
- flush_workqueue(monitor_q);
+ setup_timer(&isr_timer, magician_isr_timer_func, 1);
- return 0;
-}
+ ac_irq = IRQ_MAGICIAN_AC;
+ ret = request_irq (ac_irq, magician_attach_isr, IRQF_SAMPLE_RANDOM,
+ "AC plug", NULL);
+ if (ret) goto ac_irq_failed;
-static int
-magician_battery_resume(struct platform_device *dev)
-{
-// battery_charge_state = BATTERY_STATUS_UNKNOWN;
- queue_work(monitor_q, &monitor_work);
- mod_timer(&monitor_timer, jiffies + HZ * 5);
+ ret = platform_device_register(&ds2760_pdev);
+ if (ret) goto platform_device_failed;
- return 0;
-}
+ led_trigger_register_simple("magician-charge-full", &chargefull_trig);
+ led_trigger_register_simple("magician-charge", &charging_trig);
+ magician_isr_timer_func(0);
-static struct platform_driver magician_battery_driver = {
- .driver = {
- .name = "magician-battery",
- },
- .probe = magician_battery_probe,
- .remove = magician_battery_remove,
- .shutdown = magician_battery_shutdown,
- .suspend = magician_battery_suspend,
- .resume = magician_battery_resume
-};
+ #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+ apm_get_power_status = magician_apm_get_power_status;
+ #endif
-static int __init
-magician_battery_init(void)
-{
- int retval;
+ goto success;
- retval = platform_driver_register(&magician_battery_driver);
- if (retval)
- return retval;
-
- retval = battery_class_register(&magician_battery);
-
- return retval;
+platform_device_failed:
+ printk (KERN_ERR "%s: failed to register device\n", __FUNCTION__);
+ free_irq(ac_irq, NULL);
+ac_irq_failed:
+ printk (KERN_ERR "%s: unable to grab AC in IRQ\n", __FUNCTION__);
+success:
+ return ret;
}
-static void __exit magician_battery_exit(void)
+static void magician_battery_exit(void)
{
- battery_class_unregister(&magician_battery);
- platform_driver_unregister(&magician_battery_driver);
+ #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
+ apm_get_power_status = NULL;
+ #endif
+ led_trigger_unregister_simple(chargefull_trig);
+ led_trigger_unregister_simple(charging_trig);
+ free_irq(ac_irq, NULL);
+ del_timer_sync(&isr_timer);
+ platform_device_unregister(&ds2760_pdev);
+ return;
}
module_init(magician_battery_init);
module_exit(magician_battery_exit);
-
MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Szabolcs Gyurko <sza...@tl...>");
-MODULE_DESCRIPTION("HTC Magician battery driver");
-
-/*
- * Local Variables:
- * mode:c
- * c-style:"K&R"
- * c-basic-offset:8
- * End:
- *
- */
Modified: linux4palm/linux/trunk/drivers/input/touchscreen/ts-adc-debounce.c
===================================================================
--- linux4palm/linux/trunk/drivers/input/touchscreen/ts-adc-debounce.c 2007-02-18 12:30:02 UTC (rev 846)
+++ linux4palm/linux/trunk/drivers/input/touchscreen/ts-adc-debounce.c 2007-02-18 12:43:11 UTC (rev 847)
@@ -256,7 +256,7 @@
struct ts_adc *ts = platform_get_drvdata(pdev);
del_timer_sync(&ts->timer);
- free_irq(params->pen_irq, params);
+ free_irq(params->pen_irq, pdev);
input_unregister_device(ts->input);
input_free_device(ts->input);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|