|
From: <med...@us...> - 2007-06-16 14:27:48
|
Revision: 1038
http://svn.sourceforge.net/hackndev/?rev=1038&view=rev
Author: medaglia
Date: 2007-06-16 07:27:37 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Palm TE2: Code clean-up; added buttons support using gpio-keys.
Modified Paths:
--------------
linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/Makefile
linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2.c
Removed Paths:
-------------
linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/gpioed.c
linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_ac97.c
linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_buttons.c
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/Makefile
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/Makefile 2007-06-14 21:46:15 UTC (rev 1037)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/Makefile 2007-06-16 14:27:37 UTC (rev 1038)
@@ -3,6 +3,3 @@
#
obj-$(CONFIG_MACH_TUNGE2) += palmte2.o
-obj-$(CONFIG_PALMTE2_BUTTONS) += palmte2_buttons.o
-obj-$(CONFIG_GPIOD) += gpioed.o
-obj-$(CONFIG_PALMTE2_AC97) += palmte2_ac97.o
Deleted: linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/gpioed.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/gpioed.c 2007-06-14 21:46:15 UTC (rev 1037)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/gpioed.c 2007-06-16 14:27:37 UTC (rev 1038)
@@ -1,206 +0,0 @@
-/*** Basic includes ***/
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/proc_fs.h>
-
-#include <linux/interrupt.h>
-#include <asm/irq.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/mach-types.h>
-#include <asm/hardware.h>
-#include <linux/sched.h>
-#include <linux/workqueue.h>
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irqs.h>
-#include <asm/uaccess.h>
-
-/*** GPIO macros ***/
-#define GET_PALMT3_GPIO(gpio) \
- (GPLR(GPIO_NR_PALMT3_ ## gpio) & GPIO_bit(GPIO_NR_PALMT3_ ## gpio))
-
-#define SET_PALMT3_GPIO(gpio, setp) \
- do { \
- if (setp) \
- GPSR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \
- else \
- GPCR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \
- } while (0)
-
-#define SET_PALMT3_GPIO_N(gpio, setp) \
- do { \
- if (setp) \
- GPCR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \
- else \
- GPSR(GPIO_NR_PALMT3_ ## gpio) = GPIO_bit(GPIO_NR_PALMT3_ ## gpio); \
- } while (0)
-
-#define GET_GPIO(gpio) (GPLR(gpio) & GPIO_bit(gpio))
-
-/*** /proc interface ***/
-static struct proc_dir_entry *proc_intf;
-#define procfs_name "gpioed"
-#define PROCFS_MAX_SIZE 20
-
-static char procfs_buffer[PROCFS_MAX_SIZE];
-static unsigned long procfs_buffer_size = 0;
-
-int procfile_read(char *buffer, char **buffer_location, off_t offset, int buffer_length, int *eof, void *data)
-{
- int ret;
- long int i;
- long int address = 0xff000000;
-
- if (offset > 0) {
- ret = 0;
- } else {
- ret = sprintf(buffer, "%lx = %lx\n", address+i, *((unsigned long*)(address+i)));
- }
- return ret;
-}
-
-void handle_request(void);
-
-int procfile_write(struct file *file, const char *buffer, unsigned long count, void *data)
-{
- procfs_buffer_size = count;
- if (procfs_buffer_size > PROCFS_MAX_SIZE ) {
- procfs_buffer_size = PROCFS_MAX_SIZE;
- }
-
- /* write data to the buffer */
- if ( copy_from_user(procfs_buffer, buffer, procfs_buffer_size) ) {
- return -EFAULT;
- }
-
- handle_request();
-
- return procfs_buffer_size;
-}
-
-/*** IRQ (GPIO) handling ***/
-static struct workqueue_struct *my_workqueue;
-#define MY_WORK_QUEUE_NAME "GPIOed"
-
-static void handle_gpio(void* irq)
-{
- int gpn = (int)irq;
- printk(KERN_ERR "*** GPIO *** %d *** is *** %s ***\n", gpn, GET_GPIO(gpn) ? "high" : "low");
-}
-
-irqreturn_t gpio_irq(int irq, void *dev_id, struct pt_regs *regs)
-{
- static int initialised = 0;
- static struct work_struct task;
-
- if (initialised == 0) {
- INIT_WORK(&task, handle_gpio, dev_id);
- initialised = 1;
- } else {
- PREPARE_WORK(&task, handle_gpio, dev_id);
- }
-
- queue_work(my_workqueue, &task);
-
- return IRQ_HANDLED;
-}
-
-/*** GPIO R/W ***/
-static int gpio_get(int id)
-{
- return GET_GPIO(id);
-}
-
-static void gpio_set(int id, int on)
-{
- do {
- if (on)
- GPSR(id) = GPIO_bit(id);
- else
- GPCR(id) = GPIO_bit(id);
- } while (0);
-}
-
-static int gpio_watch(int x)
-{
- int ret;
- ret = request_irq (IRQ_GPIO(x), gpio_irq, SA_SAMPLE_RANDOM, "test_handler", (void*)x);
- set_irq_type (IRQ_GPIO(x), IRQT_BOTHEDGE);
- if(ret!=0) {
- printk(KERN_ERR "GPIOed: failed to register for GPIO %d\n", x);
- return 1;
- } else {
- printk(KERN_ERR "GPIOed: Registered GPIO %d\n", x);
- return 0;
- }
-}
-
-/*** Request handler ***/
-void handle_request()
-{
- char *p = NULL;
- unsigned long id = simple_strtoul(procfs_buffer+2, &p, 10);
- switch(procfs_buffer[0]) {
- case 'r':
- printk(KERN_ERR "GPIOed: GPIO %lu is %s\n", id, gpio_get(id)?"high":"low");
- break;
- case 's':
- gpio_watch(id);
- break;
- case 'h':
- gpio_set(id, 1);
- printk(KERN_ERR "GPIOed: GPIO %lu set high\n", id);
- break;
- case 'l':
- gpio_set(id, 0);
- printk(KERN_ERR "GPIOed: GPIO %lu set low\n", id);
- break;
- default:
- printk(KERN_ERR "GPIOed: Unknown request\n");
- break;
- }
-}
-
-/*** init&exit ***/
-static int __init gpioed_init(void)
-{
- my_workqueue = create_workqueue(MY_WORK_QUEUE_NAME);
-
- proc_intf = create_proc_entry(procfs_name, 0644, NULL);
- if (proc_intf == NULL) {
- remove_proc_entry(procfs_name, &proc_root);
- printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",
- procfs_name);
- return -ENOMEM;
- }
-
- proc_intf->read_proc = procfile_read;
- proc_intf->write_proc = procfile_write;
- proc_intf->owner = THIS_MODULE;
- proc_intf->mode = S_IFREG | S_IRUGO;
- proc_intf->uid = 0;
- proc_intf->gid = 0;
- proc_intf->size = 37;
-
- printk(KERN_INFO "/proc/%s created\n", procfs_name);
-
- return 0;
-}
-
-static void __exit gpioed_exit(void)
-{
- destroy_workqueue(my_workqueue);
- remove_proc_entry(procfs_name, &proc_root);
- printk(KERN_INFO "/proc/%s removed\n", procfs_name);
-}
-
-
-/*** Some more stuff ***/
-module_init(gpioed_init);
-module_exit(gpioed_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Vladimir \"Farcaller\" Pouzanov <far...@gm...>");
-MODULE_DESCRIPTION("GPIO editor for PXA26x");
-
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2.c 2007-06-14 21:46:15 UTC (rev 1037)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2.c 2007-06-16 14:27:37 UTC (rev 1038)
@@ -1,5 +1,5 @@
/*
- * Hardware definitions for Tungsten E2.
+ * Hardware definitions for Palm Tungsten E2.
*
* Based on: palmld.c from Alex Osborne.
*
@@ -9,12 +9,12 @@
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/input.h>
#include <asm/mach/arch.h>
#include <asm/mach-types.h>
#include <asm/arch/hardware.h>
#include <asm/mach/map.h>
#include <asm/domain.h>
-#include <asm/page.h>
#include <linux/device.h>
#include <linux/platform_device.h>
@@ -26,11 +26,11 @@
#include <asm/arch/pxafb.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/udc.h>
-#include <asm/arch/irda.h>
#include <asm/arch/mmc.h>
-#include <asm/arch/palmld-gpio.h>
#include <asm/arch/pxapwm-bl.h>
+#include <linux/gpio_keys.h>
+#include <asm/arch/palmte2-gpio.h>
#include <sound/driver.h>
#include <sound/core.h>
#include <sound/pcm.h>
@@ -41,109 +41,31 @@
#define DEBUG
-/**
- * IRDA
- */
-#if 0
-static void
-palmte2_irda_configure (struct uart_pxa_port *up, int enable)
-{
- /* printk("irda_configure, %d\n", enable); */
- /* Switch STUART RX/TX pins to SIR */
-
- pxa_gpio_mode(GPIO_NR_PALMLD_STD_RXD_MD);
- pxa_gpio_mode(GPIO_NR_PALMLD_STD_TXD_MD);
-
- /* make sure FIR ICP is off */
- ICCR0 = 0;
-
- /* XXX: It's a BIG hack, but it works for now. Must be fixed! */
- STISR = 0x17;
-
-#if 0
- if (enable) {
- /* configure STUART to for SIR */
- STISR = STISR_RCVEIR | STISR_RXPL;
- } else {
- STISR = 0;
- }
-#endif
-}
-
-static void
-palmte2_irda_set_txrx (struct uart_pxa_port *up, int txrx)
-{
- unsigned old_stisr = STISR;
- unsigned new_stisr = old_stisr;
-
- /* XXX: Another big hack that works for now. */
- txrx = PXA_SERIAL_RX;
-
- if (txrx & PXA_SERIAL_TX) {
- /* Ignore RX if TX is set */
- txrx &= PXA_SERIAL_TX;
- new_stisr |= STISR_XMITIR;
- } else
- new_stisr &= ~STISR_XMITIR;
-
- if (txrx & PXA_SERIAL_RX)
- new_stisr |= STISR_RCVEIR;
- else
- new_stisr &= ~STISR_RCVEIR;
-
- if (new_stisr != old_stisr) {
- while (!(STLSR & LSR_TEMT));
- STISR = new_stisr;
- }
-}
-
-static int
-palmte2_irda_get_txrx (struct uart_pxa_port *up)
-{
- return (((STISR & STISR_XMITIR) ? PXA_SERIAL_TX : 0) |
- ((STISR & STISR_RCVEIR) ? PXA_SERIAL_RX : 0));
-
-}
-
-static struct platform_pxa_serial_funcs palmte2_pxa_irda_funcs = {
- .configure = palmte2_irda_configure,
- .set_txrx = palmte2_irda_set_txrx,
- .get_txrx = palmte2_irda_get_txrx,
-};
-
-#endif
-
-struct platform_device palmte2_buttons = {
- .name = "palmte2-buttons",
- .id = -1,
-};
-
-/**
+/*
* AC97 audio controller
*/
-static pxa2xx_audio_ops_t palmld_audio_ops = {
- /*
- .startup = palmld_audio_startup,
+static pxa2xx_audio_ops_t palmte2_audio_ops = {
+/*
+ .startup = palmte2_audio_startup,
.shutdown = mst_audio_shutdown,
.suspend = mst_audio_suspend,
.resume = mst_audio_resume,
- */
+*/
};
-static struct platform_device palmld_ac97 = {
+static struct platform_device palmte2_ac97 = {
.name = "pxa2xx-ac97",
.id = -1,
.dev = {
- .platform_data = &palmld_audio_ops
+ .platform_data = &palmte2_audio_ops
},
};
-/**
- * * * Backlight
- * *
- * */
+/*
+ * Backlight
+ */
static struct pxapwmbl_platform_data palmte2_backlight_data = {
.pwm = 0,
.max_intensity = 0x160,
@@ -160,31 +82,42 @@
},
};
+/*
+ * Keypad - gpio_keys
+ */
-static struct platform_device *devices[] __initdata = {
- &palmte2_buttons,
- &palmld_ac97,
- &palmte2_backlight,
+#ifdef CONFIG_KEYBOARD_GPIO
+
+static struct gpio_keys_button palmte2_pxa_buttons[] = {
+ {KEY_F4, GPIO_NR_PALMTE2_KP_DKIN0, 1, "Notes"},
+ {KEY_F3, GPIO_NR_PALMTE2_KP_DKIN1, 1, "Tasks"},
+ {KEY_F1, GPIO_NR_PALMTE2_KP_DKIN2, 1, "Calendar"},
+ {KEY_F2, GPIO_NR_PALMTE2_KP_DKIN3, 1, "Contacts"},
+ {KEY_ENTER, GPIO_NR_PALMTE2_KP_DKIN4, 1, "Center"},
+ {KEY_DOWN, GPIO_NR_PALMTE2_KP_DKIN5, 1, "Left"},
+ {KEY_UP, GPIO_NR_PALMTE2_KP_DKIN6, 1, "Right"},
+ {KEY_RIGHT, GPIO_NR_PALMTE2_KP_DKIN7, 1, "Down"},
+ {KEY_LEFT, GPIO_NR_PALMTE2_KP_DKIN8, 1, "Up"},
};
-/* framebuffer */
+static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
+ .buttons = palmte2_pxa_buttons,
+ .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
+};
-static void palm_backlight_power(int on)
-{
- /* TODO */
- if(on) {
- /* setup backlight PWM settings */
- PWM_CTRL0 = 0x7;
- PWM_PWDUTY0 = 0x11a;
- PWM_PERVAL0 = 0x16c;
- /* turn on PWMs */
- CKEN |= CKEN0_PWM0 | CKEN1_PWM1;
- } else {
- /* turn off PWMs */
- CKEN &= ~(CKEN0_PWM0 | CKEN1_PWM1);
- }
-}
+static struct platform_device palmte2_pxa_keys = {
+ .name = "gpio-keys",
+ .dev = {
+ .platform_data = &palmte2_pxa_keys_data,
+ },
+};
+#endif
+
+/*
+ * Framebuffer
+ */
+
static struct pxafb_mode_info palmte2_lcd_modes[] = {
{
.pixclock = 0,
@@ -193,7 +126,7 @@
.bpp = 16,
.hsync_len = 4,
.vsync_len = 1,
-
+
.left_margin = 28,
.right_margin = 7,
.upper_margin = 7,
@@ -205,30 +138,36 @@
static struct pxafb_mach_info palmte2_lcd_screen = {
.modes = palmte2_lcd_modes,
.num_modes = ARRAY_SIZE(palmte2_lcd_modes),
-
.lccr0 = 0x000000F9,
.lccr3 = 0x04700006,
- .pxafb_backlight_power = palm_backlight_power,
+ .pxafb_backlight_power = NULL,
};
+/*
+ * Init Machine
+ */
+
+static struct platform_device *devices[] __initdata = {
+ &palmte2_ac97,
+#ifdef CONFIG_KEYBOARD_GPIO
+ &palmte2_pxa_keys,
+#endif
+ &palmte2_backlight,
+};
+
static void __init palmte2_init(void)
{
GCR &= ~GCR_PRIRDY_IEN;
-
+
set_pxa_fb_info(&palmte2_lcd_screen);
-
-/* stuart_device.dev.platform_data = &palmte2_pxa_irda_funcs; */
- platform_add_devices(devices, ARRAY_SIZE(devices));
- /*
- palmte2_irda_configure (NULL, 1);
- palmte2_irda_set_txrx (NULL, PXA_SERIAL_TX);
- */
+ platform_add_devices(devices, ARRAY_SIZE(devices));
}
MACHINE_START(TUNGE2, "Palm Tungsten E2")
-/* Maintainer: Carlos E. Medaglia Dyonisio <ca...@ne...> */
-/* .phys_ram = 0xa0000000, */
+
+ /* Maintainer: Carlos E. Medaglia Dyonisio <ca...@ne...> */
+
.phys_io = 0x40000000,
.io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
.map_io = pxa_map_io,
Deleted: linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_ac97.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_ac97.c 2007-06-14 21:46:15 UTC (rev 1037)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_ac97.c 2007-06-16 14:27:37 UTC (rev 1038)
@@ -1,597 +0,0 @@
-/*
- * linux/arch/arm/mach-pxa/palmte2/palmte2-ts.c
- *
- * Touchscreen/battery driver for Palm LifeDrive's WM9712 AC97 codec.
- *
- * Author: Alex Osborne <bob...@gm...>
- */
-
-#include <linux/kernel.h>
-#include <linux/module.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 <asm/delay.h>
-#include <asm/system.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irqs.h>
-/* XXX: Should be changed! */
-//#include <asm/arch-pxa/palmld-ac97.h>
-#include <linux/wm97xx.h>
-
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <sound/driver.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/initval.h>
-#include <sound/ac97_codec.h>
-
-#define TS_IRQ 50
-
-#define palmte2_ac97_WORK_QUEUE_NAME "palmte2_ac97.c"
-#define palmte2_headphones_ac97_WORK_QUEUE_NAME "palmte2_headphones_ac97.c"
-
-#define GET_GPIO(gpio) \
- (GPLR(gpio) & GPIO_bit(gpio))
-
-#define X_AXIS_MAX 3800
-#define X_AXIS_MIN 200
-#define Y_AXIS_MAX 3910
-#define Y_AXIS_MIN 200
-#define PRESSURE_MIN 0
-#define PRESSURE_MAX 300
-
-#define GPIO_DEBUG
-
-static spinlock_t palmte2_ac97_lock = SPIN_LOCK_UNLOCKED;
-
-static struct workqueue_struct *palmte2_ac97_workqueue;
-static struct workqueue_struct *palmte2_headphones_ac97_workqueue;
-static struct work_struct palmte2_ac97_irq_task;
-static struct work_struct palmte2_headphones_ac97_irq_task;
-struct input_dev *palmte2_ac97_input;
-struct device *palmte2_ac97_dev;
-
-static u64 battery_update_jiffies_64 = 0;
-static int battery_voltage;
-static int penup = 1;
-static int doing_work = 0;
-
-DECLARE_MUTEX(battery_update_mutex);
-
-/*
- * ac97 codec
- */
-
-void wm97xx_gpio_func(ac97_t *ac97, 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(ac97_t *ac97, 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);
-}
-
-void wm97xx_set_digitiser_power(struct device *dev, int value)
-{
- ac97_t *ac97 = dev->platform_data;
- u16 d2;
-
- d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2);
- d2 |= value;
- ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2);
-}
-
-/*
- * This is a hack that waits until the ac97 bus is free. I was unable to find
- * a more appropriate way of doing this, but it seems to work. If we don't use
- * this, then the driver will eventually conflict with another driver's use
- * of AC97 (probably audio) and will lockup.
- */
-void wait_for_ac97(void)
-{
- int timeout=1000;
-
- while (CAR & CAR_CAIP) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(HZ/100);
- set_current_state(TASK_RUNNING);
- if(!timeout--) {
- printk("palmte2_ac97_pendown: CAR_CAIP timeout\n");
- return;
- }
- }
- CAR &= ~CAR_CAIP;
-
-}
-
-static int palmte2_ac97_take_reading(struct device *dev, int adcsel)
-{
- ac97_t *ac97 = dev->platform_data;
- int timeout=200;
- u16 r76, r7a;
-
- r76 = ac97->bus->ops->read(ac97, 0x76);
- r76 &= ~WM97XX_ADCSEL_MASK; /* clear ADCSEL */
- r76 |= adcsel; /* set ADCSEL */
- r76 &= ~(1<<11); /* COO = 0 (single measurement) */
- r76 &= ~(1<<10); /* CTC = 0 (polling mode) */
- r76 |= (1<<15); /* start reading */
- ac97->bus->ops->write(ac97, 0x76, r76);
-
- do {
- if(!(timeout--)) {
- printk("palmte2_ac97_pendown: timed out waiting for poll to complete.\n");
- return 0;
- }
- r76 = ac97->bus->ops->read(ac97, 0x76);
- } while((r76 & (1<<15)));
-
- r7a = ac97->bus->ops->read(ac97, 0x7a);
-
- return r7a;
-}
-
-
-
-/*
- * battery
- */
-
-void update_data(int force)
-{
- u16 reading;
- ac97_t *ac97;
-
- if(!force && (battery_update_jiffies_64 + HZ > jiffies_64)) {
- return;
- }
-
- if(down_trylock(&battery_update_mutex)) {
- return;
- }
-
-
- spin_lock(&palmte2_ac97_lock);
- wait_for_ac97();
-
- #ifdef GPIO_DEBUG
- ac97 = palmte2_ac97_dev->platform_data;
-
- // invert and univert the gpio a few times while watching
- // the PXA's gpios to see if we can spot a connection ;)
- printk("%x %x %x %x\n", GPLR0, GPLR1, GPLR2, GPLR3);
-
- reading = ac97->bus->ops->read(ac97, 0x58);
- ac97->bus->ops->write(ac97, 0x58, reading | 1);
- udelay(10);
- printk("%x %x %x %x\n", GPLR0, GPLR1, GPLR2, GPLR3);
-
- reading = ac97->bus->ops->read(ac97, 0x58);
- ac97->bus->ops->write(ac97, 0x58, reading & (~1));
- udelay(10);
- printk("%x %x %x %x\n", GPLR0, GPLR1, GPLR2, GPLR3);
-
-
- #else
- wm97xx_set_digitiser_power(palmte2_ac97_dev, WM97XX_PRP_DET_DIG);
- reading = palmte2_ac97_take_reading(palmte2_ac97_dev, WM97XX_ADCSEL_BMON);
- wm97xx_set_digitiser_power(palmte2_ac97_dev, WM97XX_PRP_DET);
-
- #endif
-
- spin_unlock(&palmte2_ac97_lock);
- battery_voltage = reading & 0xfff;
- printk("Battery: %d\n", battery_voltage);
-
- battery_update_jiffies_64 = jiffies_64;
- up(&battery_update_mutex);
-}
-
-int get_min_voltage(struct battery *b)
-{
- return 0;
-}
-int get_min_charge(struct battery *b)
-{
- return 0;
-}
-int get_max_voltage(struct battery *b)
-{
- return 4750; /* mV */
-}
-int get_max_charge(struct battery *b)
-{
- return 1;
-}
-int get_voltage(struct battery *b)
-{
- update_data(0);
- return battery_voltage;
-}
-int get_charge(struct battery *b)
-{
- return 0;
-}
-int get_status(struct battery *b)
-{
- return 0; //power_status == POWER_NONE? 0: 1;
-}
-
-static struct battery palmte2_battery = {
- .name = "palmte2-ac97",
- .id = "battery0",
- .get_min_voltage = get_min_voltage,
- .get_min_current = NULL,
- .get_min_charge = get_min_charge,
- .get_max_voltage = get_max_voltage,
- .get_max_current = NULL,
- .get_max_charge = get_max_charge,
- .get_temp = NULL,
- .get_voltage = get_voltage,
- .get_current = NULL,
- .get_charge = get_charge,
- .get_status = get_status,
-};
-
-static void
-battery_class_release(struct class_device *dev)
-{
-}
-
-static void
-battery_class_class_release(struct class *class)
-{
-}
-
-
-/*
- * touchscreen
- */
-
-static void palmte2_ac97_pendown(struct device *dev)
-{
- //ac97_t *ac97 = dev->platform_data;
- int xread, yread, pressure;
- int pendown=0, valid_coords=0;
-
- input_report_key(palmte2_ac97_input, BTN_TOUCH, !penup);
- /* take readings until the pen goes up */
- do {
- spin_lock(&palmte2_ac97_lock);
- wait_for_ac97();
-
- /* power up digitiser */
- wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET_DIG);
-
- /* take readings */
- xread = palmte2_ac97_take_reading(dev, WM97XX_ADCSEL_X);
- yread = palmte2_ac97_take_reading(dev, WM97XX_ADCSEL_Y);
- pressure = palmte2_ac97_take_reading(dev, WM97XX_ADCSEL_PRES);
-
- /* power down digitiser to conserve power */
- wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET);
-
- pendown = pressure & (1<<15);
- valid_coords = (xread & 0xfff) && (yread & 0xfff) && (pressure & 0xfff);
-
- if (valid_coords) {
- input_report_abs(palmte2_ac97_input, ABS_X, xread & 0xfff);
- input_report_abs(palmte2_ac97_input, ABS_Y, yread & 0xfff);
- input_report_abs(palmte2_ac97_input, ABS_PRESSURE, pressure & 0xfff);
- }
-
- input_sync(palmte2_ac97_input);
-
- spin_unlock(&palmte2_ac97_lock);
-
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(HZ/100);
- set_current_state(TASK_RUNNING);
- } while(!penup);
-
- input_report_key(palmte2_ac97_input, BTN_TOUCH, !penup);
- input_sync(palmte2_ac97_input);
-
- doing_work = 0;
-}
-
-static void palmte2_ac97_irq_work(void *data)
-{
- struct device *dev = data;
- palmte2_ac97_pendown(dev);
-}
-
-static void palmte2_headphones_ac97_irq_work(void *data)
-{
- u16 reg;
- ac97_t *ac97;
- struct device *dev = data;
-
- ac97 = dev->platform_data;
-
- reg = ac97->bus->ops->read(ac97, 0x24);
-
- printk("reg: %x\n", reg);
- if(GET_GPIO(12)) {
- //reg = ((reg | 0x08) & (~0x30));
- reg = 0x1cef;
- ac97->bus->ops->write(ac97, 0x24, reg);
- printk("reg: %x\n", reg);
- } else {
- // reg = ((reg & ~0x08) | (0x30));
- reg = 0x1f77;
- ac97->bus->ops->write(ac97, 0x24, reg);
- printk("reg: %x\n", reg);
- }
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x00));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x02));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x04));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x06));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x08));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x0a));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x0c));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x0e));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x10));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x12));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x14));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x16));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x18));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x1a));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x1c));
- printk("AC97: NULL\n");
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x20));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x22));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x24));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x26));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x28));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x2a));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x2c));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x2e));
- printk("AC97: NULL\n");
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x32));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x34));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x36));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x38));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x3a));
-}
-
-static irqreturn_t palmte2_ac97_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
- /*
- * we can't use ac97 from within the interrupt handler, so schedule a task
- * to do the actual handling.
- */
- /* XXX: 50? Should be a define */
- penup = !GET_GPIO(50);
- rmb();
-
- if (!penup && !doing_work) {
- /* XXX: Should be changed to a spin_lock! (?) */
- doing_work = 1;
- queue_work(palmte2_ac97_workqueue, &palmte2_ac97_irq_task);
- }
-
- return IRQ_HANDLED;
-}
-
-static irqreturn_t palmte2_headphones_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
- //reg = ac97->bus->ops->read(ac97, 0x58);
- queue_work(palmte2_headphones_ac97_workqueue, &palmte2_headphones_ac97_irq_task);
- /*
- if(GET_GPIO(12)) {
- ac97->bus->ops->write(ac97, 0x24, ((reg | 0x08) & (~0x30)));
- } else {
- ac97->bus->ops->write(ac97, 0x24, ((reg & ~0x08) | (0x30)));
- }
-*/
- return IRQ_HANDLED;
-}
-
-static int __init palmte2_ac97_probe(struct device *dev)
-{
- int err;
- ac97_t *ac97 = dev->platform_data;
- u16 d2;
-
- if(!machine_is_tunge2())
- return -ENODEV;
-
- /* for use by bettery level monitor */
- palmte2_ac97_dev = dev;
-
- /* setup work queue */
- palmte2_ac97_workqueue = create_workqueue(palmte2_ac97_WORK_QUEUE_NAME);
- INIT_WORK(&palmte2_ac97_irq_task, palmte2_ac97_irq_work, dev);
-
- palmte2_headphones_ac97_workqueue = create_workqueue(palmte2_headphones_ac97_WORK_QUEUE_NAME);
- INIT_WORK(&palmte2_headphones_ac97_irq_task, palmte2_headphones_ac97_irq_work, dev);
-
- set_irq_type(IRQ_GPIO(TS_IRQ), IRQT_BOTHEDGE);
- err = request_irq(IRQ_GPIO(50), palmte2_ac97_irq_handler,
- SA_INTERRUPT, "Touchscreen", dev);
-
- set_irq_type(IRQ_GPIO(12), IRQT_BOTHEDGE);
- err = request_irq(IRQ_GPIO(12), palmte2_headphones_irq_handler,
- SA_INTERRUPT, "Headphones", dev);
-
- if(err) {
- printk(KERN_ERR "palmte2_ac97_probe: cannot request touchscreen IRQ\n");
- return -1;
- }
-
- spin_lock(&palmte2_ac97_lock);
-
- /* reset levels */
- ac97->bus->ops->write(ac97, 0x54, 0);
-
- /* disable digitiser to save power, enable pen-down detect */
-/* d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2);
- d2 |= WM97XX_PRP_DET;
- ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2);
-*/
- /* enable interrupts on codec's gpio 2 (connected to cpu gpio 27) */
- /* ????? */
- wm97xx_gpio_mode(ac97, WM97XX_GPIO_3, WM97XX_GPIO_IN,
- WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE);
- wm97xx_gpio_func(ac97, WM97XX_GPIO_3, 0);
-
- wm97xx_gpio_mode(ac97, WM97XX_GPIO_13, WM97XX_GPIO_IN,
- WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE);
-
- /* disable ada detect interrupt */
- wm97xx_gpio_mode(ac97, WM97XX_GPIO_12, WM97XX_GPIO_IN,
- WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE);
-
- /* turn off irq gpio inverting */
- ac97->bus->ops->write(ac97, 0x58, ac97->bus->ops->read(ac97, 0x58)&~1);
-
- /* turn on the digitiser and DISABLE pen down detector */
- d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2);
- d2 |= WM97XX_PRP_DETW;
- ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2);
-
- spin_unlock(&palmte2_ac97_lock);
-
- /* setup the input device */
- palmte2_ac97_input = input_allocate_device();
- palmte2_ac97_input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
- palmte2_ac97_input->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
- input_set_abs_params(palmte2_ac97_input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
- input_set_abs_params(palmte2_ac97_input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
- input_set_abs_params(palmte2_ac97_input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);
-
- palmte2_ac97_input->name = "Palm Tungsten E2 touchscreen";
- palmte2_ac97_input->dev = dev;
- palmte2_ac97_input->id.bustype = BUS_HOST;
- input_register_device(palmte2_ac97_input);
-
- /* register battery */
- if(battery_class_register(&palmte2_battery)) {
- printk(KERN_ERR "palmte2_ac97_probe: Could not register battery "
- "class\n");
- } else {
- palmte2_battery.class_dev.class->release = battery_class_release;
- palmte2_battery.class_dev.class->class_release = battery_class_class_release;
- }
-
- ac97->bus->ops->write(ac97, 0x16, 0x8000);
-
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x00));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x02));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x04));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x06));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x08));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x0a));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x0c));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x0e));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x10));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x12));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x14));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x16));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x18));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x1a));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x1c));
- printk("AC97: NULL\n");
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x20));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x22));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x24));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x26));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x28));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x2a));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x2c));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x2e));
- printk("AC97: NULL\n");
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x32));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x34));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x36));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x38));
- printk("AC97: 0x%x\n", ac97->bus->ops->read(ac97, 0x3a));
- return 0;
-}
-
-static int palmte2_ac97_remove (struct device *dev)
-{
- ac97_t *ac97 = dev->platform_data;
- printk("x: %x\n", ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2));
- input_unregister_device(palmte2_ac97_input);
- free_irq(IRQ_GPIO(TS_IRQ), dev);
- return 0;
-}
-
-static struct device_driver palmte2_ac97_driver = {
- .name = "WM9711,WM9712",
- .bus = &ac97_bus_type,
- .probe = palmte2_ac97_probe,
- .remove = palmte2_ac97_remove,
-#ifdef CONFIG_PM
- .suspend = NULL,
- .resume = NULL,
-#endif
-};
-
-static int __init palmte2_ac97_init(void)
-{
- if(!machine_is_tunge2())
- return -ENODEV;
-
- return driver_register(&palmte2_ac97_driver);
-}
-
-static void palmte2_ac97_exit(void)
-{
- driver_unregister(&palmte2_ac97_driver);
-}
-
-module_init(palmte2_ac97_init);
-module_exit(palmte2_ac97_exit);
-
-MODULE_AUTHOR ("Carlos Eduardo Medaglia Dyonisio <ca...@ne...>");
-MODULE_DESCRIPTION ("WM9712L AC97 codec support for Palm Tungsten E2");
-MODULE_LICENSE ("GPL");
Deleted: linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_buttons.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_buttons.c 2007-06-14 21:46:15 UTC (rev 1037)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmte2/palmte2_buttons.c 2007-06-16 14:27:37 UTC (rev 1038)
@@ -1,148 +0,0 @@
-/*
- * linux/arch/arm/mach-pxa/palmte2/palmte2-buttons.c
- *
- * Button driver for Palm Tungsten E2
- *
- * Author: Carlos Eduardo Medaglia Dyonisio <ca...@ne...>
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/input.h>
-#include <linux/device.h>
-#include <linux/platform_device.h>
-#include <asm/irq.h>
-#include <asm/mach/irq.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>
-
-#define GET_GPIO(gpio) (GPLR(gpio) & GPIO_bit(gpio))
-
-#define MAX_BUTTONS 23
-
-struct input_dev *button_dev;
-static struct device_driver palmte2_buttons_driver;
-
-static struct {
- int keycode;
- char *desc;
-} palmte2_buttons[MAX_BUTTONS] = {
- { -1, NULL }, /* GPIO 0 */
- { -1, NULL },
- { -1, "Power" },
- { -1, NULL },
- { -1, NULL },
- { KEY_F4, "Notes" }, /* GPIO 5 */
- { -1, NULL },
- { KEY_F3, "Tasks" },
- { -1, NULL },
- { -1, NULL },
- { -1, NULL }, /* GPIO 10 */
- { KEY_LEFTSHIFT, "Calendar" },
- { -1, NULL },
- { KEY_PAGEUP, "Contacts" },
- { KEY_ENTER, "Center" },
- { -1, NULL }, /* GPIO 15 */
- { -1, NULL },
- { -1, NULL },
- { -1, NULL },
- { KEY_LEFT, "Left" },
- { KEY_RIGHT, "Right" }, /* GPIO 20 */
- { KEY_DOWN, "Down" },
- { KEY_UP, "Up" }
-};
-
-static irqreturn_t palmte2_keypad_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
- input_report_key(button_dev, palmte2_buttons[IRQ_TO_GPIO(irq)].keycode,
- GET_GPIO(IRQ_TO_GPIO(irq)) ? 0 : 1);
- return IRQ_HANDLED;
-}
-
-static int __init palmte2_buttons_probe(struct device *dev)
-{
- int err = 0;
- int i;
-
- if(!machine_is_tunge2())
- return -ENODEV;
-
- button_dev = input_allocate_device();
- button_dev->evbit[0] = BIT(EV_KEY);
- for(i=0;i<MAX_BUTTONS;i++) {
- if(palmte2_buttons[i].keycode >= 0) {
- button_dev->keybit[LONG(palmte2_buttons[i].keycode)] |=
- BIT(palmte2_buttons[i].keycode);
- }
- }
- button_dev->name = "Palm Tungsten E2 buttons";
- button_dev->id.bustype = BUS_HOST;
- input_register_device(button_dev);
-
- for(i=0;i<MAX_BUTTONS;i++) {
- if(palmte2_buttons[i].keycode >= 0) {
- err += request_irq(IRQ_GPIO(i),
- palmte2_keypad_irq_handler,
- SA_SAMPLE_RANDOM | SA_INTERRUPT,
- "keypad", (void*)i);
- set_irq_type(IRQ_GPIO(i), IRQT_BOTHEDGE);
- }
- }
-
- if(err) {
- printk("err = %d\n", err);
- }
-
- return 0;
-}
-
-static int __exit palmte2_buttons_remove (struct device *dev)
-{
- int i;
- for(i=0;i<MAX_BUTTONS;i++) {
- if(palmte2_buttons[i].keycode >= 0) {
- free_irq(IRQ_GPIO(i), (void*)i);
- }
- }
- return 0;
-}
-
-static struct device_driver palmte2_buttons_driver = {
- .name = "palmte2-buttons",
- .bus = &platform_bus_type,
- .probe = palmte2_buttons_probe,
- .remove = palmte2_buttons_remove,
-#ifdef CONFIG_PM
- .suspend = NULL,
- .resume = NULL,
-#endif
-};
-
-static int __init palmte2_buttons_init(void)
-{
- if(!machine_is_tunge2())
- return -ENODEV;
-
- return driver_register(&palmte2_buttons_driver);
-}
-
-static void __exit palmte2_buttons_exit(void)
-{
- input_unregister_device(button_dev);
- driver_unregister(&palmte2_buttons_driver);
-}
-
-module_init(palmte2_buttons_init);
-module_exit(palmte2_buttons_exit);
-
-MODULE_AUTHOR ("Carlos Eduardo Medaglia Dyonisio <ca...@ne...>");
-MODULE_DESCRIPTION ("Button support for Palm Tungsten E2");
-MODULE_LICENSE ("GPL");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|