From: <mis...@us...> - 2007-07-23 23:02:10
|
Revision: 1206 http://svn.sourceforge.net/hackndev/?rev=1206&view=rev Author: miska_tx Date: 2007-07-23 16:02:05 -0700 (Mon, 23 Jul 2007) Log Message: ----------- PalmTX: Better corgi_bl integration (now we use corgi_bl suspend to turn off display) Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-07-23 12:47:37 UTC (rev 1205) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-07-23 23:02:05 UTC (rev 1206) @@ -157,10 +157,13 @@ static void palmtx_bl_power(int on) { - SET_PALMTX_GPIO(BL_POWER, on); - pxa_set_cken(CKEN0_PWM0, on); - pxa_set_cken(CKEN1_PWM1, on); - mdelay(50); + if(GET_PALMTX_GPIO(BL_POWER)!=on) { + SET_PALMTX_GPIO(LCD_POWER, on); + SET_PALMTX_GPIO(BL_POWER, on); + pxa_set_cken(CKEN0_PWM0, on); + pxa_set_cken(CKEN1_PWM1, on); + mdelay(50); + } } static void palmtx_set_bl_intensity(int intensity) Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c 2007-07-23 12:47:37 UTC (rev 1205) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c 2007-07-23 23:02:05 UTC (rev 1206) @@ -47,10 +47,6 @@ while(!(OSCC & OSCC_OOK)) {} - /* Turn off LCD power */ - SET_PALMTX_GPIO(LCD_POWER,0); - /* Turn screen off */ - SET_PALMTX_GPIO(BL_POWER,0); /* Turn off USB power */ SET_PALMTX_GPIO(USB_POWER,0); @@ -73,10 +69,6 @@ /* Here are all of special to resume Palm TX */ - /* Turn on LCD power */ - SET_PALMTX_GPIO(LCD_POWER,1); - /* Turn screen on */ - SET_PALMTX_GPIO(BL_POWER,1); /* Turn on USB power */ SET_PALMTX_GPIO(USB_POWER,1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-08-11 05:21:33
|
Revision: 1234 http://hackndev.svn.sourceforge.net/hackndev/?rev=1234&view=rev Author: marex_z71 Date: 2007-08-10 22:21:30 -0700 (Fri, 10 Aug 2007) Log Message: ----------- PalmTX: cleanup, adding pcmcia driver skeleton (not working yet) Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c Added Paths: ----------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pcmcia.c Removed Paths: ------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_lcd.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig 2007-08-11 02:00:54 UTC (rev 1233) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig 2007-08-11 05:21:30 UTC (rev 1234) @@ -4,7 +4,7 @@ help This enables support for Palm TX handheld. -config PALMTX_DEBUG +config PALMTX_DEBUG bool "Debug output for Palm TX" depends on MACH_XSCALE_PALMTX default n @@ -27,3 +27,9 @@ help Enable support for suspend/resume the Palm TX PDA. +config PALMTX_PCMCIA + tristate "Palm TX PCMCIA driver" + depends on MACH_XSCALE_PALMTX + help + This driver handles the CF/PCCARD/PCMCIA bus. + Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile 2007-08-11 02:00:54 UTC (rev 1233) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile 2007-08-11 05:21:30 UTC (rev 1234) @@ -4,5 +4,5 @@ # obj-$(CONFIG_MACH_XSCALE_PALMTX) += palmtx.o obj-$(CONFIG_PALMTX_BATTERY) += palmtx_battery.o -obj-$(CONFIG_PM) += palmtx_pm.o -#obj-$(CONFIG_PALMTX_PCMCIA) += palmtx_pcmcia.o +obj-$(CONFIG_PALMTX_PM) += palmtx_pm.o +obj-$(CONFIG_PALMTX_PCMCIA) += palmtx_pcmcia.o Deleted: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2007-08-11 02:00:54 UTC (rev 1233) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2007-08-11 05:21:30 UTC (rev 1234) @@ -1,492 +0,0 @@ -/* - * linux/arch/arm/mach-pxa/palmtx/palmld_ac97.c - * - * Touchscreen/battery driver for Palm TX' WM9712 AC97 codec - * - * Based on palmld_ac97.c code from Alex Osborne - * - */ - - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/input.h> -#include <linux/device.h> -#include <linux/workqueue.h> -#include <linux/battery.h> -#include <linux/irq.h> - -#include <asm/apm.h> -#include <asm/delay.h> -#include <asm/mach-types.h> -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/arch/hardware.h> -#include <asm/arch/pxa-regs.h> -#include <asm/arch/irqs.h> - -#include <sound/driver.h> -#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/initval.h> -#include <sound/ac97_codec.h> -#include <sound/wm9712.h> - -#include <asm/arch/palmtx-gpio.h> -#include <asm/arch/palmtx-init.h> - - -#define X_AXIS_MAX 3900 -#define X_AXIS_MIN 350 -#define Y_AXIS_MAX 3750 -#define Y_AXIS_MIN 320 -#define PRESSURE_MIN 0 -#define PRESSURE_MAX 150 - -#define DIG2_INIT 0x0001 /* initial value for digitiser2 reg */ - -#define DEFAULT_PRESSURE_TRESHOLD 45160 /* default pressure treshold for pen up/down */ -#define DEFAULT_X_AXIS_FUZZ 5 /* default x axis noise treshold */ -#define DEFAULT_Y_AXIS_FUZZ 35 /* default y axis noise treshold */ -#define PRESSURE_FUZZ 5 /* default pressure noise treshold */ - -#define palmld_ac97_WORK_QUEUE_NAME "palmld_ac97_workqueue" - -/* module parameters */ - -static int ptrsh = DEFAULT_PRESSURE_TRESHOLD; -module_param(ptrsh, int, 0); -MODULE_PARM_DESC(ptrsh, "pressure treshold for pen up/down"); - -static int dbglvl = 0; // debug disabled -module_param(dbglvl, int, 0); -MODULE_PARM_DESC(dbglvl, "debug level (0 is disabled)"); - -static int xdjtrsh = DEFAULT_X_AXIS_FUZZ; -module_param(xdjtrsh, int, 0); -MODULE_PARM_DESC(xdjtrsh, "treshold for x axis jitter"); - -static int ydjtrsh = DEFAULT_Y_AXIS_FUZZ; -module_param(ydjtrsh, int, 0); -MODULE_PARM_DESC(ydjtrsh, "treshold for y axis jitter"); - - -static DECLARE_MUTEX_LOCKED(queue_sem); -static DECLARE_MUTEX(digitiser_sem); -static DECLARE_MUTEX(battery_update_mutex); - -static struct workqueue_struct *palmld_ac97_workqueue; -static struct work_struct palmld_ac97_irq_task; - -struct input_dev *palmld_ac97_input; -struct device *palmld_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; - -/* - * ac97 codec - */ - -void wm97xx_gpio_func(int gpio, int func) -{ - int GEn; - GEn = ac97->bus->ops->read(ac97, 0x56); - if(func) - GEn |= gpio; - else - GEn &= ~gpio; - ac97->bus->ops->write(ac97, 0x56, GEn); -} - - -void wm97xx_gpio_mode(int gpio, int config, int polarity, int sticky, int wakeup) -{ - int GCn, GPn, GSn, GWn; - GCn = ac97->bus->ops->read(ac97, 0x4c); - GPn = ac97->bus->ops->read(ac97, 0x4e); - GSn = ac97->bus->ops->read(ac97, 0x50); - GWn = ac97->bus->ops->read(ac97, 0x52); - - if(config) - GCn |= gpio; - else - GCn &= ~gpio; - - if(polarity) - GPn |= gpio; - else - GPn &= ~gpio; - - if(sticky) - GSn |= gpio; - else - GSn &= ~gpio; - - if(wakeup) - GWn |= gpio; - else - GWn &= ~gpio; - - ac97->bus->ops->write(ac97, 0x4c, GCn); - ac97->bus->ops->write(ac97, 0x4e, GPn); - ac97->bus->ops->write(ac97, 0x50, GSn); - ac97->bus->ops->write(ac97, 0x52, GWn); -} - - -static void wm97xx_set_digitiser_power(int value) -{ - ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2base | value); -} - - -/* - * note: for the TX there's some code that gets enabled in linux/sound/pxa2xx-ac97.c - * (ifdef CONFIG_MACH_PALMTX) that tries to implement some recommended procedure for - * reading/writing reg 0x54 from a Intel's document - * (PXA27x Specification Update: 28007109.pdf sec.: E54) - */ - -static int palmld_ac97_take_reading(int adcsel) -{ - int timeout = 15; - u16 r76 = 0; - u16 r7a; - - r76 |= adcsel; /* set ADCSEL (ADC source) */ - r76 |= WM97XX_DELAY(3); /* set settling time delay */ - r76 &= ~(1<<11); /* COO = 0 (single measurement) */ - r76 &= ~(1<<10); /* CTC = 0 (polling mode) */ - r76 |= (1<<15); /* initiate measurement (POLL) */ - - ac97->bus->ops->write(ac97, 0x76, r76); - - // wait settling time - udelay ((3 * AC97_LINK_FRAME) + 167); - - /* wait for POLL to go low */ - while((ac97->bus->ops->read(ac97, 0x76) & 0x8000) && timeout){ - udelay(AC97_LINK_FRAME); - timeout--; - } - - if (timeout == 0){ - printk("palmld_ac97: discarding reading due to POLL wait timout on 0x76\n"); - return 0; - } - - r7a = ac97->bus->ops->read(ac97, 0x7a); - - if ((r7a & WM97XX_ADCSEL_MASK) != adcsel){ - printk("palmld_ac97: discarding reading -> wrong ADC source\n"); - return 0; - } - - return (int) r7a; -} - - -static void palmld_ac97_pendown(void) -{ - int xread, yread, pressure; - int valid_coords=0, btn_pressed = 0; - - /* take readings until the pen goes up */ - do { - /* take readings */ - xread = palmld_ac97_take_reading(WM97XX_ADCSEL_X); - yread = palmld_ac97_take_reading(WM97XX_ADCSEL_Y); - pressure = palmld_ac97_take_reading(WM97XX_ADCSEL_PRES); - - valid_coords = (xread & 0xfff) && (yread & 0xfff) && (pressure & 0xfff); - - if(valid_coords && (pressure < ptrsh)) { - btn_pressed = 1; - input_report_key(palmld_ac97_input, BTN_TOUCH, 1); - input_report_abs(palmld_ac97_input, ABS_X, xread & 0xfff); - input_report_abs(palmld_ac97_input, ABS_Y, yread & 0xfff); - input_report_abs(palmld_ac97_input, ABS_PRESSURE, pressure & 0xfff); - input_sync(palmld_ac97_input); - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ/100); - set_current_state(TASK_RUNNING); - } - } while( valid_coords ); - - - if (btn_pressed) { - input_report_key(palmld_ac97_input, BTN_TOUCH, 0); - input_report_abs(palmld_ac97_input, ABS_X, 0); - input_report_abs(palmld_ac97_input, ABS_Y, 0); - input_report_abs(palmld_ac97_input, ABS_PRESSURE, 0); - input_sync(palmld_ac97_input); - } - -} - - -static void palmld_ac97_irq_work(void *data) -{ - //struct device *dev = data; - //ac97_t *ac97 = dev->platform_data; - u16 levels; - u16 polarity; - - levels = ac97->bus->ops->read(ac97, 0x54); - polarity = ac97->bus->ops->read(ac97, 0x4e); - - if(polarity & levels & WM97XX_GPIO_13) { - // power up digitiser: - down(&digitiser_sem); - wm97xx_set_digitiser_power(WM97XX_PRP_DET_DIG); - - palmld_ac97_pendown(); - - /* power down digitiser to conserve power */ - wm97xx_set_digitiser_power(WM97XX_PRP_DET); - ac97->bus->ops->write(ac97, 0x4e, polarity & ~WM97XX_GPIO_13); - up(&digitiser_sem); - } - else { - ac97->bus->ops->write(ac97, 0x4e, polarity | WM97XX_GPIO_13); - } - - ac97->bus->ops->write(ac97, 0x54, levels & ~WM97XX_GPIO_13); - - udelay(1); - up(&queue_sem); - enable_irq(IRQ_GPIO_PALMTX_WM9712_IRQ); -} - - -static irqreturn_t palmld_ac97_irq_handler(int irq, void *dev_id, struct pt_regs *regs) -{ - if (down_trylock(&queue_sem) == 0){ - disable_irq(IRQ_GPIO_PALMTX_WM9712_IRQ); - queue_work(palmld_ac97_workqueue, &palmld_ac97_irq_task); - } - - return IRQ_HANDLED; -} - -/* battery */ - - -void palmld_battery_read_adc(int force) -{ - u16 vread; - - if(!force && ((last_battery_update + 10 *HZ) > jiffies)) - return; - - if(down_trylock(&battery_update_mutex)) - return; - - down(&digitiser_sem); - wm97xx_set_digitiser_power(WM97XX_PRP_DET_DIG); - vread = palmld_ac97_take_reading(WM97XX_ADCSEL_BMON); - wm97xx_set_digitiser_power(WM97XX_PRP_DET); - up(&digitiser_sem); - - previous_voltage = current_voltage; - current_voltage = vread & 0xfff; - last_battery_update = jiffies; - - up(&battery_update_mutex); -} - - -int palmld_battery_min_voltage(struct battery *b) -{ - return PALMTX_BAT_MIN_VOLTAGE; -} - - -int palmld_battery_max_voltage(struct battery *b) -{ - return PALMTX_BAT_MAX_VOLTAGE; /* mV */ -} - - -// let's suppose AVDD=+3.3v so battV = intV * 3 * 0.80586 -// note: 0.80586 = 3.3/4095 -int palmld_battery_get_voltage(struct battery *b) -{ - if (battery_registered){ - palmld_battery_read_adc(0); - return current_voltage * 3 * 80586 / 100000; - } - else{ - printk("palmld_battery: cannot get voltage -> battery driver unregistered\n"); - return 0; - } -} - - -int palmld_battery_get_status(struct battery *b) -{ - int ac_connected = GET_GPIO(GPIO_NR_PALMTX_POWER_DETECT); - int usb_connected = !GET_GPIO(GPIO_NR_PALMTX_USB_DETECT); - - if (current_voltage <= 0) - return BATTERY_STATUS_UNKNOWN; - - if (ac_connected || usb_connected){ - // TODO: ok maybe this is too stupid ... to be reviewed - if ( ( current_voltage > previous_voltage ) || (current_voltage <= PALMTX_BAT_MAX_VOLTAGE) ) - return BATTERY_STATUS_CHARGING; - return BATTERY_STATUS_NOT_CHARGING; - } - else - return BATTERY_STATUS_DISCHARGING; -} - - -struct battery palmtx_battery = { - .name = "palmtx-battery", - .id = "battery0", - .get_min_voltage = palmld_battery_min_voltage, - .get_max_voltage = palmld_battery_max_voltage, - .get_voltage = palmld_battery_get_voltage, - .get_status = palmld_battery_get_status, -}; - - - - -static int __init palmld_ac97_probe(struct device *dev) -{ - int err; - u16 d2 = DIG2_INIT; // init d1 too? - - if(!machine_is_xscale_palmtx()) - return -ENODEV; - - ac97 = to_ac97_t(dev); - - set_irq_type(IRQ_GPIO_PALMTX_WM9712_IRQ, IRQT_RISING); - - err = request_irq(IRQ_GPIO_PALMTX_WM9712_IRQ, palmld_ac97_irq_handler, - SA_INTERRUPT, "WM9712 pendown IRQ", dev); - - if(err) { - printk(KERN_ERR "palmld_ac97_probe: cannot request pen down IRQ\n"); - return -1; - } - - /* reset levels */ - ac97->bus->ops->write(ac97, 0x54, 0); - - /* disable digitiser to save power, enable pen-down detect */ - d2 |= WM97XX_PRP_DET; - d2base = d2; - ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2base); - - /* enable interrupts on codec's gpio 2 (connected to cpu gpio 27) */ - wm97xx_gpio_mode(WM97XX_GPIO_2, WM97XX_GPIO_OUT, WM97XX_GPIO_POL_HIGH, - WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE); - wm97xx_gpio_func(WM97XX_GPIO_2, 0); - - /* enable pen detect interrupt */ - wm97xx_gpio_mode(WM97XX_GPIO_13, WM97XX_GPIO_OUT, WM97XX_GPIO_POL_HIGH, - WM97XX_GPIO_STICKY, WM97XX_GPIO_WAKE); - - /* turn off irq gpio inverting */ - ac97->bus->ops->write(ac97, 0x58, ac97->bus->ops->read(ac97, 0x58)&~1); - - /* turn on the digitiser and pen down detector */ - ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2base | WM97XX_PRP_DETW); - - /* setup the input device */ - palmld_ac97_input = input_allocate_device(); - if (palmld_ac97_input == NULL){ - printk ("palmld_ac97_probe: cannot allocate input device\n"); - return -ENOMEM; - } - - palmld_ac97_input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); - - palmld_ac97_input->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); - input_set_abs_params(palmld_ac97_input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, xdjtrsh, 0); - input_set_abs_params(palmld_ac97_input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, ydjtrsh, 0); - input_set_abs_params(palmld_ac97_input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, PRESSURE_FUZZ, 0); - - palmld_ac97_input->name = "palmtx touchscreen"; - palmld_ac97_input->dev = dev; - palmld_ac97_input->id.bustype = BUS_HOST; - input_register_device(palmld_ac97_input); - - /* register battery */ - - if(battery_class_register(&palmtx_battery)) { - printk(KERN_ERR "palmld_ac97_probe: could not register battery class\n"); - } - else{ - battery_registered = 1; - } - - /* setup work queue */ - palmld_ac97_workqueue = create_workqueue(palmld_ac97_WORK_QUEUE_NAME); - INIT_WORK(&palmld_ac97_irq_task, palmld_ac97_irq_work); - - up(&queue_sem); - return 0; -} - - -static int palmld_ac97_remove (struct device *dev) -{ - // TODO: stop running tasks if any? - - battery_class_unregister(&palmtx_battery); - ac97 = NULL; - input_unregister_device(palmld_ac97_input); - return 0; -} - - -static struct device_driver palmld_ac97_driver = { - .name = "palmld_ac97 (WM9712)", - .bus = &ac97_bus_type, - .owner = THIS_MODULE, - .probe = palmld_ac97_probe, - .remove = palmld_ac97_remove, - -#ifdef CONFIG_PM - .suspend = NULL, - .resume = NULL, -#endif -}; - - -static int __init palmld_ac97_init(void) -{ - if(!machine_is_xscale_palmtx()) - return -ENODEV; - - return driver_register(&palmld_ac97_driver); -} - - -static void __exit palmld_ac97_exit(void) -{ - driver_unregister(&palmld_ac97_driver); -} - - -module_init(palmld_ac97_init); -module_exit(palmld_ac97_exit); - -MODULE_AUTHOR ("Alex Osborne <bob...@gm...>"); -MODULE_DESCRIPTION ("WM9712 AC97 codec support for Palm TX"); -MODULE_LICENSE ("GPL"); Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-08-11 02:00:54 UTC (rev 1233) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-08-11 05:21:30 UTC (rev 1234) @@ -236,20 +236,14 @@ void bcm2035_bt_reset(int on) { printk(KERN_NOTICE "Switch BT reset %d\n", on); - if (on) - SET_PALMTX_GPIO( BT_RESET, 1 ); - else - SET_PALMTX_GPIO( BT_RESET, 0 ); + SET_PALMTX_GPIO( BT_RESET, on ? 1 : 0 ); } EXPORT_SYMBOL(bcm2035_bt_reset); void bcm2035_bt_power(int on) { - printk(KERN_NOTICE "Switch BT power %d\n", on); - if (on) - SET_PALMTX_GPIO( BT_POWER, 1 ); - else - SET_PALMTX_GPIO( BT_POWER, 0 ); + printk(KERN_NOTICE "Switch BT power %d\n", on ? 1 : 0); + SET_PALMTX_GPIO( BT_POWER, on ? 1 : 0 ); } EXPORT_SYMBOL(bcm2035_bt_power); @@ -314,8 +308,8 @@ static struct pxa2xx_udc_mach_info palmtx_udc_mach_info __initdata = { - .udc_is_connected = palmtx_udc_is_connected, - .udc_command = palmtx_udc_command, + .udc_is_connected = palmtx_udc_is_connected, + .udc_command = palmtx_udc_command, }; @@ -334,9 +328,11 @@ }; static struct platform_device palmtx_ac97 = { - .name = "pxa2xx-ac97", - .id = -1, - .dev = { .platform_data = &palmtx_audio_ops }, + .name = "pxa2xx-ac97", + .id = -1, + .dev = { + .platform_data = &palmtx_audio_ops + }, }; /******************** @@ -348,7 +344,7 @@ .id = -1, .dev = { .platform_data = NULL, - }, + }, }; static struct platform_device *devices[] __initdata = { @@ -395,19 +391,24 @@ static struct pxafb_mach_info palmtx_lcd_screen = { .modes = palmtx_lcd_modes, .num_modes = ARRAY_SIZE(palmtx_lcd_modes), - .lccr0 = PALMTX_INIT_LCD_LLC0, - .lccr3 = PALMTX_INIT_LCD_LLC3, + .lccr0 = PALMTX_INIT_LCD_LLC0, + .lccr3 = PALMTX_INIT_LCD_LLC3, .pxafb_backlight_power = NULL, }; static struct map_desc palmtx_io_desc[] __initdata = { - // PCMCIA socket 0 { - .virtual = 0xf1000000, + .virtual = 0xf0000000, .pfn = __phys_to_pfn(0x20000000), .length = 0x00100000, .type = MT_DEVICE }, + { + .virtual = 0xf1000000, + .pfn = __phys_to_pfn(0x30000000), + .length = 0x00100000, + .type = MT_DEVICE + }, }; Deleted: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_lcd.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_lcd.c 2007-08-11 02:00:54 UTC (rev 1233) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_lcd.c 2007-08-11 05:21:30 UTC (rev 1234) @@ -1,143 +0,0 @@ -/* - * Palm TX LCD driver - * - * Based on Asus MyPal 716 LCD and Backlight driver - * - * 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. - * - */ - -#include <linux/module.h> -#include <linux/init.h> -#include <linux/notifier.h> -#include <linux/lcd.h> -#include <linux/fb.h> -#include <linux/delay.h> -#include <linux/platform_device.h> - -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#include <asm/mach-types.h> - -#include <asm/hardware.h> -#include <asm/arch/pxa-regs.h> -#include <asm/arch/pxafb.h> - -#include <asm/arch/palmtx-gpio.h> -#include <asm/arch/palmtx-init.h> - -static int lcd_power; - -int palmtx_lcd_set_power(struct lcd_device *lm, int level) -{ - switch (level) { - case FB_BLANK_UNBLANK: - case FB_BLANK_NORMAL: - // this is very likely incomplete !!! - printk("palmtx_lcd: turning LCD on\n"); - SET_GPIO(GPIO_NR_PALMTX_LCD_POWER, 1); - mdelay(70); - break; - case FB_BLANK_VSYNC_SUSPEND: - case FB_BLANK_HSYNC_SUSPEND: - break; - case FB_BLANK_POWERDOWN: - // this is very likely incomplete !!! - printk("palmtx_lcd: turning LCD off\n"); - SET_GPIO(GPIO_NR_PALMTX_LCD_POWER, 0); - mdelay(65); - break; - } - - lcd_power = level; - - return 0; -} - -static int palmtx_lcd_get_power(struct lcd_device *lm) -{ - printk("palmtx_lcd: power is set to %d", lcd_power); - return lcd_power; -} - -struct lcd_properties palmtx_lcd_properties = -{ - .owner = THIS_MODULE, - .set_power = palmtx_lcd_set_power, - .get_power = palmtx_lcd_get_power, -}; - -static struct lcd_device *pxafb_lcd_device; - - -int palmtx_lcd_probe(struct device *dev) -{ - if (!machine_is_xscale_palmtx()) - return -ENODEV; - - pxafb_lcd_device = lcd_device_register("pxafb", NULL, &palmtx_lcd_properties); - - if (IS_ERR(pxafb_lcd_device)){ - printk("palmtx_lcd_probe: cannot register LCD device\n"); - return -ENOMEM; - } - - printk ("palmtx LCD driver registered\n"); - - return 0; -} - -static int palmtx_lcd_remove(struct device *dev) -{ - lcd_device_unregister(pxafb_lcd_device); - printk ("palmtx LCD driver unregistered\n"); - return 0; -} - -#ifdef CONFIG_PM - -static int palmtx_lcd_suspend(struct device *dev, pm_message_t state) -{ - palmtx_lcd_set_power(pxafb_lcd_device, FB_BLANK_UNBLANK); - return 0; -} - -static int palmtx_lcd_resume(struct device *dev) -{ - palmtx_lcd_set_power(pxafb_lcd_device, FB_BLANK_POWERDOWN); - return 0; -} -#endif - -static struct device_driver palmtx_lcd_driver = { - .name = "palmtx-lcd", - .bus = &platform_bus_type, - .probe = palmtx_lcd_probe, - .remove = palmtx_lcd_remove, -#ifdef CONFIG_PM - .suspend = palmtx_lcd_suspend, - .resume = palmtx_lcd_resume, -#endif -}; - -static int palmtx_lcd_init(void) -{ - if (!machine_is_xscale_palmtx()) - return -ENODEV; - - return driver_register(&palmtx_lcd_driver); -} - -static void palmtx_lcd_exit(void) -{ - lcd_device_unregister(pxafb_lcd_device); - driver_unregister(&palmtx_lcd_driver); -} - -module_init(palmtx_lcd_init); -module_exit(palmtx_lcd_exit); - -MODULE_DESCRIPTION("LCD driver for Palm TX"); -MODULE_LICENSE("GPL"); Added: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pcmcia.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pcmcia.c (rev 0) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pcmcia.c 2007-08-11 05:21:30 UTC (rev 1234) @@ -0,0 +1,162 @@ +/* + + Driver for Palm T|X PCMCIA + + (C) 2007 by Marek Vasut <mar...@gm...> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/interrupt.h> +#include <linux/init.h> +#include <linux/device.h> +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/irq.h> + +#include <asm/mach-types.h> +#include <asm/hardware.h> +#include <../drivers/pcmcia/soc_common.h> +#include <asm/arch/pxa-regs.h> +#include <asm/arch/palmtx-gpio.h> +#include <asm/irq.h> + +#define DRV_NAME "palmtx_pcmcia" + +/* Debuging macro */ +#define PALMTX_PCMCIA_DEBUG + +#ifdef PALMTX_PCMCIA_DEBUG +#define palmtx_pcmcia_dbg(format, args...) \ + printk(KERN_INFO DRV_NAME": " format, ## args) +#else +#define palmtx_pcmcia_dbg(format, args...) do {} while (0) +#endif + +/* GPIO defines */ +#define PALMTX_PCMCIA_IRQ 116 +#define PALMTX_PCMCIA_POWER 94 +#define PALMTX_PCMCIA_RESET 108 +/* other possible GPIOs - 46 and 70 ? */ + +static int palmtx_pcmcia_hw_init (struct soc_pcmcia_socket *skt) +{ + set_irq_type(PALMTX_PCMCIA_IRQ, IRQT_FALLING); + skt->irq = IRQ_GPIO(PALMTX_PCMCIA_IRQ); + + palmtx_pcmcia_dbg("%s:%i, Socket:%d\n", __FUNCTION__, __LINE__, skt->nr); + return 0; +} + +static void palmtx_pcmcia_hw_shutdown (struct soc_pcmcia_socket *skt) +{ + palmtx_pcmcia_dbg("%s:%i\n", __FUNCTION__, __LINE__); +} + + +static void +palmtx_pcmcia_socket_state (struct soc_pcmcia_socket *skt, struct pcmcia_state *state) +{ + state->detect = 1; /* always inserted */ + state->ready = GET_GPIO(PALMTX_PCMCIA_IRQ) ? 1 : 0; + state->bvd1 = 1; + state->bvd2 = 1; + state->wrprot = 1; + state->vs_3v = 1; + state->vs_Xv = 0; +} + +static int +palmtx_pcmcia_configure_socket (struct soc_pcmcia_socket *skt, const socket_state_t *state) +{ + palmtx_pcmcia_dbg("%s:%i Reset:%d Vcc:%d\n", __FUNCTION__, __LINE__, + (state->flags & SS_RESET) ? 1 : 0, state->Vcc); + + SET_GPIO(PALMTX_PCMCIA_POWER, 1); + SET_GPIO(PALMTX_PCMCIA_RESET, (state->flags & SS_RESET) ? 1 : 0); + + return 0; +} + +static void palmtx_pcmcia_socket_init(struct soc_pcmcia_socket *skt) +{ + palmtx_pcmcia_dbg("%s:%i\n", __FUNCTION__, __LINE__); +} + +static void palmtx_pcmcia_socket_suspend (struct soc_pcmcia_socket *skt) +{ + palmtx_pcmcia_dbg("%s:%i\n", __FUNCTION__, __LINE__); +} + +static struct pcmcia_low_level palmtx_pcmcia_ops = { + .owner = THIS_MODULE, + + .first = 0, + .nr = 2, + + .hw_init = palmtx_pcmcia_hw_init, + .hw_shutdown = palmtx_pcmcia_hw_shutdown, + + .socket_state = palmtx_pcmcia_socket_state, + .configure_socket = palmtx_pcmcia_configure_socket, + + .socket_init = palmtx_pcmcia_socket_init, + .socket_suspend = palmtx_pcmcia_socket_suspend, +}; + + +static void palmtx_pcmcia_release (struct device * dev) +{ + palmtx_pcmcia_dbg("%s:%i\n", __FUNCTION__, __LINE__); +} + + +static struct platform_device palmtx_pcmcia_device = { + .name = "pxa2xx-pcmcia", + .id = 0, + .dev = { + .platform_data = &palmtx_pcmcia_ops, + .release = palmtx_pcmcia_release + } +}; + +static int __init palmtx_pcmcia_init(void) +{ + palmtx_pcmcia_dbg("%s:%i\n", __FUNCTION__, __LINE__); + + if(!machine_is_xscale_palmtx()) + return -ENODEV; + + return platform_device_register (&palmtx_pcmcia_device); +} + +static void __exit palmtx_pcmcia_exit(void) +{ + palmtx_pcmcia_dbg("%s:%i\n", __FUNCTION__, __LINE__); + + platform_device_unregister (&palmtx_pcmcia_device); +} + +module_init(palmtx_pcmcia_init); +module_exit(palmtx_pcmcia_exit); + +MODULE_AUTHOR ("Marek Vasut <mar...@gm...>"); +MODULE_DESCRIPTION ("PCMCIA support for Palm T|X"); +MODULE_LICENSE ("GPL"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-08-27 15:42:23
|
Revision: 1276 http://hackndev.svn.sourceforge.net/hackndev/?rev=1276&view=rev Author: marex_z71 Date: 2007-08-25 21:55:37 -0700 (Sat, 25 Aug 2007) Log Message: ----------- PalmTX: polishing the code, replaced comments with C-style ones, used TABs, removed useless braces etc. Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-08-26 04:40:15 UTC (rev 1275) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-08-26 04:55:37 UTC (rev 1276) @@ -156,10 +156,10 @@ **************/ struct platform_device palmtx_border = { - .name = "palmtx-border", - .id = -1, - .dev = { - .platform_data = NULL, + .name = "palmtx-border", + .id = -1, + .dev = { + .platform_data = NULL, }, }; @@ -169,23 +169,23 @@ static void palmtx_bl_power(int on) { - if(GET_PALMTX_GPIO(BL_POWER)!=on) { - SET_PALMTX_GPIO(LCD_POWER, on); - SET_PALMTX_GPIO(BL_POWER, on); - pxa_set_cken(CKEN0_PWM0, on); - pxa_set_cken(CKEN1_PWM1, on); - mdelay(50); - } + if(GET_PALMTX_GPIO(BL_POWER)!=on) { + SET_PALMTX_GPIO(LCD_POWER, on); + SET_PALMTX_GPIO(BL_POWER, on); + pxa_set_cken(CKEN0_PWM0, on); + pxa_set_cken(CKEN1_PWM1, on); + mdelay(50); + } } static void palmtx_set_bl_intensity(int intensity) { - palmtx_bl_power(intensity ? 1 : 0); - if(intensity) { - PWM_CTRL0 = 0x7; - PWM_PERVAL0 = PALMTX_PERIOD; - PWM_PWDUTY0 = intensity; - } + palmtx_bl_power(intensity ? 1 : 0); + if(intensity) { + PWM_CTRL0 = 0x7; + PWM_PERVAL0 = PALMTX_PERIOD; + PWM_PWDUTY0 = intensity; + } } static struct corgibl_machinfo palmtx_bl_machinfo = { @@ -333,7 +333,7 @@ .name = "pxa2xx-ac97", .id = -1, .dev = { - .platform_data = &palmtx_audio_ops + .platform_data = &palmtx_audio_ops }, }; @@ -342,9 +342,9 @@ ********************/ struct platform_device palmtx_pm = { - .name = "palmtx-pm", - .id = -1, - .dev = { + .name = "palmtx-pm", + .id = -1, + .dev = { .platform_data = NULL, }, }; @@ -377,18 +377,18 @@ static struct pxafb_mode_info palmtx_lcd_modes[] = { { .pixclock = 0, - .xres = 320, // PPL + 1 - .yres = 480, // LPP + 1 - .bpp = 16, // BPP + .xres = 320, /* PPL + 1 */ + .yres = 480, /* LPP + 1 */ + .bpp = 16, /* BPP */ - // linux palmos - .left_margin = 32, // BLW + 1 (BLW=31) - .right_margin = 1, // ELW + 1 (ELW=3) * - .upper_margin = 7, // BFW + 1 (BFW=7) * - .lower_margin = 1, // EFW + 1 (EFW=8) * + /* linux palmos */ + .left_margin = 32, /* BLW + 1 (BLW=31) */ + .right_margin = 1, /* ELW + 1 (ELW=3) */ + .upper_margin = 7, /* BFW + 1 (BFW=7) */ + .lower_margin = 1, /* EFW + 1 (EFW=8) */ - .hsync_len = 4, // HSW + 1 (HSW=3) - .vsync_len = 1, // VSW + 1 (VSW=0) + .hsync_len = 4, /* HSW + 1 (HSW=3) */ + .vsync_len = 1, /* VSW + 1 (VSW=0) */ }, }; @@ -422,11 +422,11 @@ static void __init palmtx_init(void) { - // disable primary codec interrupt to prevent WM9712 constantly interrupting the CPU - // and preventing the boot process to complete (Thanx Alex & Shadowmite!) + /* disable primary codec interrupt to prevent WM9712 constantly interrupting the CPU + and preventing the boot process to complete (Thanx Alex & Shadowmite!) */ GCR &= ~GCR_PRIRDY_IEN; - // configure AC97's GPIOs + /* configure AC97's GPIOs */ pxa_gpio_mode(GPIO28_BITCLK_AC97_MD); pxa_gpio_mode(GPIO29_SDATA_IN_AC97_MD); pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD); Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c 2007-08-26 04:40:15 UTC (rev 1275) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c 2007-08-26 04:55:37 UTC (rev 1276) @@ -73,13 +73,12 @@ int palmtx_battery_get_voltage(struct power_supply *b) { - if (bat.battery_registered){ + if (bat.battery_registered) { bat.previous_voltage = bat.current_voltage; bat.current_voltage = wm97xx_read_aux_adc(bat.wm, WM97XX_AUX_ID3); bat.last_battery_update = jiffies; return bat.current_voltage * 1889/1000 + 7678/10; - } - else{ + } else { printk("palmtx_battery: cannot get voltage -> battery driver unregistered\n"); return 0; } @@ -87,10 +86,9 @@ int palmtx_battery_get_capacity(struct power_supply *b) { - if (bat.battery_registered){ + 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)))*100); - } else{ printk("palmtx_battery: cannot get capacity -> battery driver unregistered\n"); return 0; @@ -196,14 +194,14 @@ static struct device_driver palmtx_wm97xx_driver = { - .name = "wm97xx-touchscreen", - .bus = &wm97xx_bus_type, - .owner = THIS_MODULE, - .probe = palmtx_wm97xx_probe, - .remove = palmtx_wm97xx_remove, - .suspend = palmtx_wm97xx_suspend, - .resume = palmtx_wm97xx_resume, - .shutdown = palmtx_wm97xx_shutdown + .name = "wm97xx-touchscreen", + .bus = &wm97xx_bus_type, + .owner = THIS_MODULE, + .probe = palmtx_wm97xx_probe, + .remove = palmtx_wm97xx_remove, + .suspend = palmtx_wm97xx_suspend, + .resume = palmtx_wm97xx_resume, + .shutdown = palmtx_wm97xx_shutdown }; static int palmtx_ac_is_connected (void){ @@ -232,9 +230,9 @@ info->ac_line_status = palmtx_ac_is_connected() ? APM_AC_ONLINE : APM_AC_OFFLINE; - if (info->ac_line_status) { + if (info->ac_line_status) info->battery_status = APM_BATTERY_STATUS_CHARGING; - } else { + else { if (percent > 50) info->battery_status = APM_BATTERY_STATUS_HIGH; else if (percent < 5) @@ -256,9 +254,8 @@ /* register battery to APM layer */ bat.battery_registered = 0; - if(power_supply_register(NULL, &palmtx_battery)) { + if(power_supply_register(NULL, &palmtx_battery)) printk(KERN_ERR "palmtx_ac97_probe: could not register battery class\n"); - } else { bat.battery_registered = 1; printk("Battery registered\n"); Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c 2007-08-26 04:40:15 UTC (rev 1275) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_pm.c 2007-08-26 04:55:37 UTC (rev 1276) @@ -91,8 +91,8 @@ } struct pxa_ll_pm_ops palmtx_ll_pm_ops = { - .suspend = palmtx_pxa_ll_pm_suspend, - .resume = palmtx_pxa_ll_pm_resume, + .suspend = palmtx_pxa_ll_pm_suspend, + .resume = palmtx_pxa_ll_pm_resume, }; static int palmtx_pm_probe(struct device *dev) @@ -102,11 +102,11 @@ } struct device_driver palmtx_pm_driver = { - .name = "palmtx-pm", - .bus = &platform_bus_type, - .probe = palmtx_pm_probe, - .suspend = palmtx_suspend, - .resume = palmtx_resume, + .name = "palmtx-pm", + .bus = &platform_bus_type, + .probe = palmtx_pm_probe, + .suspend = palmtx_suspend, + .resume = palmtx_resume, }; static int __init palmtx_pm_init(void) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mis...@us...> - 2007-09-26 14:45:09
|
Revision: 1342 http://hackndev.svn.sourceforge.net/hackndev/?rev=1342&view=rev Author: miska_tx Date: 2007-09-26 07:44:58 -0700 (Wed, 26 Sep 2007) Log Message: ----------- PalmTX: Migration to the universal batery driver Signed-off-by: Michal Hrusecky <Mic...@se...> Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c Removed Paths: ------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig 2007-09-26 14:42:12 UTC (rev 1341) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Kconfig 2007-09-26 14:44:58 UTC (rev 1342) @@ -11,16 +11,6 @@ help Enable core debug output for Palm TX modules. -config PALMTX_BATTERY - tristate "Palm TX Battery support" - select TOUCHSCREEN_WM97XX - select POWER_SUPPLY - depends on MACH_XSCALE_PALMTX - default m - help - Enable support for Palm TX battery to APM. - ATM use it only as module, otherwise it hangs. - config PALMTX_PM tristate "Palm TX Power Management support" depends on MACH_XSCALE_PALMTX Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile 2007-09-26 14:42:12 UTC (rev 1341) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/Makefile 2007-09-26 14:44:58 UTC (rev 1342) @@ -3,6 +3,5 @@ # # obj-$(CONFIG_MACH_XSCALE_PALMTX) += palmtx.o -obj-$(CONFIG_PALMTX_BATTERY) += palmtx_battery.o obj-$(CONFIG_PALMTX_PM) += palmtx_pm.o obj-$(CONFIG_PALMTX_PCMCIA) += palmtx_pcmcia.o Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-09-26 14:42:12 UTC (rev 1341) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx.c 2007-09-26 14:44:58 UTC (rev 1342) @@ -169,6 +169,25 @@ }; /************* + * Batery * + *************/ + +int palmtx_ac_is_connected (void){ + /* when charger is plugged in, then status is ONLINE */ + return GET_PALMTX_GPIO(POWER_DETECT)||(!GET_PALMTX_GPIO(USB_DETECT_N)); +} + +static struct palm_battery_data palm_battery_info = { + .bat_min_voltage = PALMTX_BAT_MIN_VOLTAGE, + .bat_max_voltage = PALMTX_BAT_MAX_VOLTAGE, + .bat_max_life_mins = PALMTX_MAX_LIFE_MINS, + .ac_connected = &palmtx_ac_is_connected, +}; + +EXPORT_SYMBOL_GPL(palm_battery_info); + + +/************* * Backlight * *************/ Deleted: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c 2007-09-26 14:42:12 UTC (rev 1341) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmtx_battery.c 2007-09-26 14:44:58 UTC (rev 1342) @@ -1,285 +0,0 @@ -/************************************************************************ - * linux/arch/arm/mach-pxa/palmztx/palmtx_battery.c * - * Battery driver for Palm TX * - * * - * Author: Jan Herman <2h...@se...> * - * * - * Based on code for Palm Zire 72 by * - * * - * Authors: Jan Herman <2h...@se...> * - * Sergey Lapin <sl...@ha...> * - * * - ************************************************************************/ - - -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/input.h> -#include <linux/device.h> -#include <linux/workqueue.h> -#include <linux/power_supply.h> -#include <linux/apm-emulation.h> -#include <linux/wm97xx.h> - -#include <asm/delay.h> -#include <asm/mach-types.h> -#include <asm/mach/arch.h> -#include <asm/mach/map.h> -#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> - -struct palmtx_battery_dev -{ - struct wm97xx * wm; - int battery_registered; - int current_voltage; - int previous_voltage; - u32 last_battery_update; -}; - -struct palmtx_battery_dev bat; - -#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 - -int palmtx_battery_min_voltage(struct power_supply *b) -{ - return PALMTX_BAT_MIN_VOLTAGE; -} - - -int palmtx_battery_max_voltage(struct power_supply *b) -{ - return PALMTX_BAT_MAX_VOLTAGE; /* mV */ -} - -static int palmtx_ac_is_connected (void){ - /* when charger is plugged in, then status is ONLINE */ - return GET_PALMTX_GPIO(POWER_DETECT)||(!GET_PALMTX_GPIO(USB_DETECT_N)); -} - -/* - This formula is based on battery life of my battery 1100mAh. Original battery in Zire72 is Li-On 920mAh - V_batt = ADCSEL_BMON * 1,889 + 767,8 [mV] -*/ - -int palmtx_battery_get_voltage(struct power_supply *b) -{ - if (bat.battery_registered) { - bat.previous_voltage = bat.current_voltage; - bat.current_voltage = wm97xx_read_aux_adc(bat.wm, WM97XX_AUX_ID3); - bat.last_battery_update = jiffies; - return bat.current_voltage * 1889/1000 + 7678/10; - } else { - printk("palmtx_battery: cannot get voltage -> battery driver unregistered\n"); - return 0; - } -} - -int palmtx_battery_get_capacity(struct power_supply *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)))*100); - else{ - printk("palmtx_battery: cannot get capacity -> battery driver unregistered\n"); - return 0; - } -} - -int palmtx_battery_get_status(struct power_supply *b) -{ - if ( palmtx_ac_is_connected() && - ( ( bat.current_voltage > bat.previous_voltage ) || - (bat.current_voltage <= palmtx_battery_max_voltage(b)) ) ) - return POWER_SUPPLY_STATUS_CHARGING; - else - return POWER_SUPPLY_STATUS_NOT_CHARGING; -} - -static int palmtx_battery_get_property(struct power_supply *b, - enum power_supply_property psp, - union power_supply_propval *val) -{ - switch (psp) { - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: - val->intval = palmtx_battery_max_voltage(b); - break; - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: - val->intval = palmtx_battery_min_voltage(b); - break; - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: - val->intval = 100; - break; - case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN: - val->intval = 0; - break; - case POWER_SUPPLY_PROP_CHARGE_NOW: - val->intval = palmtx_battery_get_capacity(b); - break; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = palmtx_battery_get_voltage(b); - break; - case POWER_SUPPLY_PROP_STATUS: - val->intval = palmtx_battery_get_status(b); - break; - default: - break; - }; - - return 0; -} - -static enum power_supply_property palmtx_battery_props[] = { - POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, - POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, - POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN, - POWER_SUPPLY_PROP_CHARGE_NOW, - POWER_SUPPLY_PROP_VOLTAGE_NOW, - POWER_SUPPLY_PROP_STATUS, -}; - -struct power_supply palmtx_battery = { - .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) -{ - struct wm97xx *wm = dev->driver_data; - bat.wm = wm; - return 0; -} - -static int palmtx_wm97xx_remove(struct device *dev) -{ - return 0; -} - -static void -palmtx_wm97xx_shutdown(struct device *dev) -{ -#if defined(CONFIG_APM_EMULATION) || defined(CONFIG_APM_MODULE) - apm_get_power_status = apm_get_power_status_orig; -#endif -} - -static int -palmtx_wm97xx_suspend(struct device *dev, pm_message_t state) -{ - return 0; -} - -static int -palmtx_wm97xx_resume(struct device *dev) -{ - return 0; -} - - -static struct device_driver palmtx_wm97xx_driver = { - .name = "wm97xx-touchscreen", - .bus = &wm97xx_bus_type, - .owner = THIS_MODULE, - .probe = palmtx_wm97xx_probe, - .remove = palmtx_wm97xx_remove, - .suspend = palmtx_wm97xx_suspend, - .resume = palmtx_wm97xx_resume, - .shutdown = palmtx_wm97xx_shutdown -}; - - -#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) -{ - int min, max, curr, percent; - - curr = palmtx_battery_get_voltage(&palmtx_battery); - min = palmtx_battery_min_voltage(&palmtx_battery); - max = palmtx_battery_max_voltage(&palmtx_battery); - - curr = curr - min; - if (curr < 0) curr = 0; - max = max - min; - - percent = curr*100/max; - - info->battery_life = percent; - - info->ac_line_status = palmtx_ac_is_connected() ? APM_AC_ONLINE : APM_AC_OFFLINE; - - if (info->ac_line_status) - info->battery_status = APM_BATTERY_STATUS_CHARGING; - else { - if (percent > 50) - info->battery_status = APM_BATTERY_STATUS_HIGH; - else if (percent < 5) - info->battery_status = APM_BATTERY_STATUS_CRITICAL; - else - info->battery_status = APM_BATTERY_STATUS_LOW; - } - - info->time = percent * PALMTX_MAX_LIFE_MINS/100; - info->units = APM_UNITS_MINS; -} -#endif -static int __init palmtx_wm97xx_init(void) -{ -#ifndef MODULE - int ret; -#endif - - /* register battery to APM layer */ - bat.battery_registered = 0; - - if(power_supply_register(NULL, &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_EMULATION) || defined(CONFIG_APM_MODULE) - apm_get_power_status_orig = apm_get_power_status; - apm_get_power_status = palmtx_apm_get_power_status; -#endif -#ifndef MODULE - /* If we're in kernel, we could accidentally be run before wm97xx - and thus have panic */ - if((ret = bus_register(&wm97xx_bus_type)) < 0) - return ret; -#endif - return driver_register(&palmtx_wm97xx_driver); -} - -static void __exit palmtx_wm97xx_exit(void) -{ -/* TODO - recover APM callback to original state */ - power_supply_unregister(&palmtx_battery); - driver_unregister(&palmtx_wm97xx_driver); -} - -module_init(palmtx_wm97xx_init); -module_exit(palmtx_wm97xx_exit); - -/* Module information */ -MODULE_AUTHOR("Jan Herman <2h...@se...>"); -MODULE_DESCRIPTION("wm97xx battery driver for Palm TX"); -MODULE_LICENSE("GPL"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |