here are the two drivers I wrote (in the attachments).
Angel Sánchez Morales wrote:
> I can take a look at it. Tell me which source files are used and i'll
> look for something.
>
>
> On 12/5/05, Fisherss <[EMAIL PROTECTED]> wrote:
>
>> Actually we will have a basically useful linux system after the touch screen
>> driver being finished. But it really makes me crazy............
>> I can't tranfer the coordinate data to OPIE anyway, it doesn't give me any
>> reaction.
>> Does anyone in this list know how to fix this problem?
>>
>>
>>
>> ---------
>> Fisherss
>>
>> [EMAIL PROTECTED]
>>
>>
>>
>>> ------- Original Message -------
>>> From: Filipe Cardoso Lana <[EMAIL PROTECTED]>
>>> To: The porting effort for the Dell Axim x50 <[email protected]>
>>> Sent: 05-12-5, 2:37:20
>>> Subject: Re: [Aximx50-port] Re: hey, answer from pepper linux
>>>
>>> yes fisherss, pepper pad is almost the same hardware as x50v.
>>> same processor, same video chip, and maybe the same i/o, wifi, bt,
>>> touchscreen. the pepper pad has a 20gb hdd, 8.4 inch touchscreen,
>>> and 256mb of ram...
>>>
>>> Fisherss <[EMAIL PROTECTED]> escreveu:
>>> Oh~~~~ , that's cool !
>>> So we can use a fully functional Linux system more quickly, and it will
>>> save lot of our time. When will they release the code ?
>>>
>>> Angel S?hez Morales wrote:
>>>
>>>> Yup, that thing is using nearly the same hardware as our loved pda :p
>>>> A PXA270, 2700G, and probably some more things.
>>>>
>>>> Jorge Schrauwen wrote:
>>>>
>>>>> I the drivers work i guess so right?
>>>>>
>>>>>
>>>>> On 12/3/05, Fisherss wrote:
>>>>>
>>>>>
>>>>>> Oh, do you guys mean that the pepper linux can be used on Axim ?
>>>>>>
>>>>>> Angel S?hez Morales wrote:
>>>>>>
>>>>>>
>>>>>>> As far as i know, you only need an ARM compiler for your OS and cross
>>>>>>> your fingers and hope that there's no machine independent code :p
>>>>>>>
>>>>>>>
>>>>>>> Jorge Schrauwen wrote:
>>>>>>>
>>>>>>>
>>>>>>>> Nice... but a special compiler is needed? or wil de normal gcc be
>>>>>>>> fine?
>>>>>>>>
>>>>>>>> On 12/1/05, Jay Coles wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> If you have the source then all you need is a
>>>>>>>>> recompile, the only exception bieng anything that
>>>>>>>>> relies on asembbly as its normally x86 or things like
>>>>>>>>> Xen which are highly hardware dependent (i hear that
>>>>>>>>> they are intrested in an ARM port)
>>>>>>>>>
>>>>>>>>> Jay Coles
>>>>>>>>> [EMAIL PROTECTED]
>>>>>>>>>
>>>>>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /"\
>>>>>>>>> ASCII Ribbon Campain against \ /
>>>>>>>>> HTML e-mail and postings. X
>>>>>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ / \
>>>>>>>>>
>>>>>>>>> Intel P4 with HT* technology
>>>>>>>>> * - Hyper Thrashing, burn cache burn
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> __________________________________
>>>>>>>>> Yahoo! Mail - PC Magazine Editors' Choice 2005
>>>>>>>>> http://mail.yahoo.com
>>>>>>>>> --
>>>>>>>>> _______________________________________________
>>>>>>>>> Aximx50-port mailing list
>>>>>>>>> [email protected]
>>>>>>>>> https://www.handhelds.org/mailman/listinfo/aximx50-port
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> ~Jorge
>>>>>>>>
>>>>>> --
>>>>>> _______________________________________________
>>>>>> Aximx50-port mailing list
>>>>>> [email protected]
>>>>>> https://www.handhelds.org/mailman/listinfo/aximx50-port
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> ~Jorge
>>>>>
>>> --
>>> _______________________________________________
>>> Aximx50-port mailing list
>>> [email protected]
>>> https://www.handhelds.org/mailman/listinfo/aximx50-port
>>>
>>>
>>>
>>>
>>> ---------------------------------
>>> Yahoo! doce lar. Fa��do Yahoo! sua homepage.
>>>
>> --
>> _______________________________________________
>> Aximx50-port mailing list
>> [email protected]
>> https://www.handhelds.org/mailman/listinfo/aximx50-port
>>
>>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/config.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/pm.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/device.h>
#include <linux/soc-device.h>
#include <asm/arch/hardware.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
#include <asm/io.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/aximx50-gpio.h>
#define CTRL_START 0x80
#define CTRL_YPOS 0x10
#define CTRL_Z1POS 0x30
#define CTRL_Z2POS 0x40
#define CTRL_XPOS 0x50
#define DIFFMODE_X_POSI 0x00d0
#define DIFFMODE_Y_POSI 0x0090
int x,y,x_new,y_new;
enum touchscreen_state {
STATE_WAIT_FOR_TOUCH, /* Waiting for a PEN interrupt */
STATE_SAMPLING /* Actively sampling ADC */
};
struct touchscreen_data {
enum touchscreen_state state;
struct timer_list timer;
int irq;
struct input_dev input;
};
struct key_data {
int gpiod_val;
int gpiod_bit;
int rising;
int key;
} asic3_key[3];
static unsigned long poll_sample_time = 10; /* Sample every 10 milliseconds */
static struct touchscreen_data *ts_data;
static int irqblock;
static struct input_dev dev_ads7846;
static char ads7846_name[] = "ads7846";
static char ads7846_phys[] = "touchscreen/ads7846";
//MODULE_PARM(poll_sample_time, "i");
static inline void
report_touchpanel(struct touchscreen_data *ts, int pressure, int x, int y)
{
input_report_abs(&ts->input, ABS_PRESSURE, pressure);
input_report_abs(&ts->input, ABS_X, x);
input_report_abs(&ts->input, ABS_Y, y);
input_sync(&ts->input);
}
static void start_read(struct touchscreen_data *touch);
static void
pen_isr(unsigned int irq, void* data, struct pt_regs *regs)
{
struct input_dev *dev = (struct input_dev *)data;
struct touchscreen_data *ts = ts_data;
if (GET_X50_GPIO(TOUCHPANEL_IRQ_N) == 0)
{
SSDR = DIFFMODE_X_POSI;
while (fifo_empty());
x = SSDR;
x_new = (x - 141)*800/3662;
SSDR = DIFFMODE_Y_POSI;
while (fifo_empty());
y = SSDR;
y_new=600 - (y - 197)*600/3630;
printk("%x %x \n",x_new,y_new);
input_report_abs(dev, ABS_X, x_new );
input_report_abs(dev, ABS_Y, y_new );
input_report_abs(dev, ABS_PRESSURE,0);// 0xfff);
input_sync(dev);
input_report_abs(&ts_data->input, ABS_X, x_new & 0xfff);
input_report_abs(&ts_data->input, ABS_Y, y_new & 0xfff);
input_report_abs(&ts_data->input, ABS_PRESSURE, 0xfff);
input_sync(&ts_data->input);
input_report_abs(&ts_data->input, ABS_X, 70);
input_report_abs(&ts_data->input, ABS_Y, 100);
input_report_abs(&ts_data->input, ABS_PRESSURE, 0);
input_sync(&ts_data->input);
// start_read(ts);
return IRQ_HANDLED;
// printk("x: %x y: %x, x_new: %x y_new: %x \n", x, y, x_new,
y_new);
/*
printk(KERN_NOTICE "ts interrupt. Pen is down.\n");
printk(KERN_NOTICE "%x\n",SSCR0);
printk(KERN_NOTICE "%x\n",SSCR1);
printk(KERN_NOTICE "SSSR_P2 : %x\n",SSSR_P2);
printk(KERN_NOTICE "SSDR_P2 : %x\n",SSDR_P2);
printk(KERN_NOTICE "%x\n",SSSR);
printk(KERN_NOTICE "%x\n",SSSR_P2);
printk(KERN_NOTICE "%x\n" ,(GPLR(GET_X50_GPIO(TOUCHPANEL_IRQ_N)) &
GPIO_bit(GET_X50_GPIO(TOUCHPANEL_IRQ_N))));
printk(KERN_NOTICE "%x\n",SSSR_BSY);
printk(KERN_NOTICE "%x\n",SSSR_RNE);
printk(KERN_NOTICE "%x\n",GRER0);
//SSDR_P2 = 0xd00000;
*/
// int ssrval = SSSR_P2;
//disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
//SSDR=CTRL_START | CTRL_YPOS;
//SSDR_P2 = 0xd00000;
//SSDR_P2 = 0x900000;
//printk(KERN_NOTICE "SSDR without delaay: %x\n",SSDR);
//while(ssrval & (1<<2))
//{
// udelay(10);
// printk(KERN_NOTICE "SSDR delay 1 , 10 ums : %x\n",SSDR);
//}
//SSDR_P2= 0x900000;//CTRL_START | CTRL_YPOS;
//printk(KERN_NOTICE "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa SSDR final:
%x\n",SSDR);
//udelay(100);
// printk(KERN_NOTICE "SSDR delay 1 , 100 ums : %x\n",SSDR);
//printk(KERN_NOTICE "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa SSDR & 0xFFFF :
%x\n", SSDR & 0xFFFF);
//udelay(1000);
// printk(KERN_NOTICE "SSDR delay 1 , 1000 ums : %x\n",SSDR);
// udelay(10000);
//printk(KERN_NOTICE "SSDR delay 1 , 10000 ums : %x\n",SSDR);
///////
/*
int antirace;
antirace = 100000;
while ((SSSR & SSSR_BSY) && antirace)
{
udelay(10);
antirace--;
};
//////
printk(KERN_NOTICE "h4000 SSDR : %x\n",SSDR);
//disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
//disable_irq();
}
else
{
printk(KERN_NOTICE "ts interrupt. Pen is up.\n");
// printk(KERN_NOTICE "%x\n",SSDR);
// printk(KERN_NOTICE "%x\n",SSCR);
set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_FALLING);
return;
}
struct touchscreen_data *ts = (struct touchscreen_data *)data; */
//printk(KERN_NOTICE "ts interrupt\n");
/* struct touchscreen_data *ts = dev_id->data; */
//struct touchscreen_data *ts = ts_data;
// if (irq == X50_IRQ(TOUCHPANEL_IRQ_N))
//{
//irqblock = 1;
/*
* Disable the pen interrupt. It's reenabled when the user lifts the
* pen.
*/
/* disable_irq(HX4700_IRQ(TOUCHPANEL_IRQ_N)); */
/* XXX for some reason this disable does not work so I put in the
* irqblock variable. I shouldn't have to. */
/* Update. set_irq_type does work, but the irq code prints a message
* every time. Bummer. */
// set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_RISING);
// disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
// if (ts->state == STATE_WAIT_FOR_TOUCH) {
// ts->state = STATE_SAMPLING;
//start_read(ts);
//} else {
/* Shouldn't happen */
//printk(KERN_ERR "Unexpected ts interrupt\n");
//}
/*
SSDR = DIFFMODE_X_POSI;
while (fifo_empty());
SSDR = DIFFMODE_Y_POSI;
while (fifo_empty()); // printk(KERN_NOTICE "disable irq\n");
*/
}
}
static int fifo_empty(void)
{
if( SSSR & 0x8)
return 0; // is not empty
else
return 1; // empty
}
static void
ssp_init(void)
{
SSCR0 = 0x0000472B;
SSCR1 = 0x00000440;
CKEN |= CKEN3_SSP;
SSCR0 |= 0x00000080;
SSDR = 0x00d0; //DIFFMODE_X_POSI;
while (fifo_empty());
unsigned long r = SSDR;
/* *** Set up the SPI Registers *** */
// SSCR0_P2 =
// (1 << 20) /* Extended Data Size Select */
// | (6 << 8) /* Serial Clock Rate */
// | (0 << 7) /* Synchronous Serial Enable (Disable for now) */
// | (0 << 4) /* Motorola SPI Interface */
/*
x = SSDR;
x_new = (x - 141)*800/3662;
y = SSDR;
y_new=600 - (y - 197)*600/3630;
*/
// | (7 << 0) /* Data Size Select (24-bit) */
// ;
// SSCR1_P2 = 0;
// SSPSP_P2 = 0;
/* Clear the Status */
//SSSR_P2 = SSSR_P2 & 0x00fcfffc;
/* Now enable it */
//SSCR0_P2 =
// (1 << 20) /* Extended Data Size Select */
// | (6 << 8) /* Serial Clock Rate */
// | (1 << 7) /* Synchronous Serial Enable */
// | (0 << 4) /* Motorola SPI Interface */
// | (7 << 0) /* Data Size Select (24-bit) */
// ;
//enable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
}
static void
start_read(struct touchscreen_data *touch)
{
unsigned long inc = (poll_sample_time * HZ) / 1000;
// x = SSDR;
//x_new = (x - 141)*800/3662;
// y = SSDR;
// y_new=600 - (y - 197)*600/3630;
int i;
/* Write here to the serial port. We request X and Y only for now.
* Then we have to wait for poll_sample_time before we read out the serial
* port. Then, when we read it out, we check to see if the pen is still
* down. If so, then we issue another request here.
*/
#define TS_SAMPLES 7
/*
SSDR = DIFFMODE_X_POSI;
while (fifo_empty());
SSDR = DIFFMODE_Y_POSI;
while (fifo_empty());
SSDR =CTRL_START | CTRL_Z1POS);
while (fifo_empty());
SSDR =CTRL_START | CTRL_Z2POS);
while (fifo_empty());
*/
/*
* We do four samples for each, and throw out the highest and lowest, then
* average the other two.
*/
// for(i = 0; i < TS_SAMPLES; i++) {
// while(!(SSSR_P2 & (1 << 2)))
// ;
/* It's not full. Write the command for X */
// SSDR_P2 = 0xd00000 ;/* | (lower_bits << 0) */ /* May want bits 0 and 1
set for keeping power up */
// }
//for(i = 0; i < TS_SAMPLES; i++) {
// while(!(SSSR_P2 & (1 << 2)))
;
/* It's not full. Write the command for Y */
// SSDR_P2 = 0x900000 ;/* | (lower_bits << 0) */ /* May want bits 0 and 1
set for keeping power up */
//}
/*
* Enable the timer. We should get an interrupt, but we want keep a timer
* to ensure that we can detect missing data
*/
mod_timer(&touch->timer, jiffies + inc);
}
static void
x50_ts_timer_callback(unsigned long data)
{
struct input_dev *ts = (struct input_dev *)data;
input_report_abs(ts, ABS_X, x_new );
input_report_abs(ts, ABS_Y, y_new );
input_report_abs(ts, ABS_PRESSURE,0);// 0xfff);
input_sync(ts);
input_report_abs(ts, ABS_X, x_new & 0xfff);
input_report_abs(ts, ABS_Y, y_new & 0xfff);
input_report_abs(ts, ABS_PRESSURE,0xfff);// 0xfff);
input_sync(ts);
input_report_abs(ts, ABS_X,70);
input_report_abs(ts, ABS_Y, 100);
input_report_abs(ts, ABS_PRESSURE,0xfff);// 0xfff);
input_sync(ts);
//if (GET_X50_GPIO(TOUCHPANEL_IRQ_N) == 0)
//printk(KERN_NOTICE "ts callback. Pen is still down.\n");
//else
//printk(KERN_NOTICE "ts callback. Pen is up.\n");
// printk("x: %x y: %x x_new: %x y_new: %x",x,y,x_new,y_new);
return;
}
static int
x50_ts_probe (struct device *dev)
{
/* For some reason ts_probe is not called, so we do the initialization in
* the module init. */
int retval = request_irq(X50_IRQ(TOUCHPANEL_IRQ_N), pen_isr, SA_INTERRUPT,
"x50_ts", ts_data);
if(retval) {
printk("Unable to get interrupt\n");
input_unregister_device (&ts_data->input);
return -ENODEV;
}
set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_FALLING);
dev_set_drvdata(dev, ts_data);
return 0;
}
static void
x50_ts_remove (struct device *dev)
{
struct touchscreen_data *ts = dev_get_drvdata(dev);
del_timer_sync (&ts->timer);
free_irq (ts->irq, ts);
}
static int
x50_ts_suspend (struct device *dev, u32 state, u32 level)
{
#if 0 /* XXX ?? */
struct touchscreen_data *ts = dev_get_drvdata(dev);
if (level == SUSPEND_POWER_DOWN)
ts->dev->disable();
#endif
return 0;
}
static int
x50_ts_resume (struct device *dev, u32 level)
{
struct touchscreen_data *ts = dev_get_drvdata(dev);
#if 0
if (level == RESUME_POWER_ON)
ts->dev->enable();
&ts->input#endif
ts->state = STATE_WAIT_FOR_TOUCH;
ssp_init();
#endif
return 0;
}
static soc_device_id device_ids[] = {
/* XXX Hack in 0x500. This needs to be assigned? */
{ 0x500 },
{ 0 }
};
/*
static struct soc_device_driver soc_driver = {
.device_ids = device_ids,
.driver = {
.name = "x50_ts",
.probe = x50_ts_probe,
.shutdown = x50_ts_remove,
.suspend = x50_ts_suspend,
.resume = x50_ts_resume
}
};
*/
int ts_open(struct input_dev *dev)
{
set_irq_chained_handler(X50_IRQ(TOUCHPANEL_IRQ_N), pen_isr);
// set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_FALLING);
//request_irq (X50_IRQ(TOUCHPANEL_IRQ_N), pen_isr, SA_SAMPLE_RANDOM, "x50_ts",
(void*)dev);
}
void ts_close( struct input_dev *dev )
{
disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
SSCR0 &= ~SSCR0_SSE;
/* make sure to free the IRQ... */
free_irq(X50_IRQ(TOUCHPANEL_IRQ_N), dev);
}
static int
x50_ts_module_init (void)
{
// printk(KERN_NOTICE "Dell Axim x50(v) Touch Screen Driver\n");
/* struct touchscreen_data *ts;
ts = ts_data = kmalloc (sizeof (*ts), GFP_KERNEL);
memset (ts, 0, sizeof (*ts));
memset(&ts->input, 0, sizeof(struct input_dev));
init_input_dev (&ts->input);
ts->input.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
ts->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
ts->input.absmin[ABS_X] = 0;
ts->input.absmax[ABS_X] = 32767;
ts->input.absmin[ABS_Y] = 0;
ts->input.absmax[ABS_Y] = 32767;
ts->input.absmin[ABS_PRESSURE] = 0;
ts->input.absmax[ABS_PRESSURE] = 1;
ts->input.keybit[LONG(KEY_F12)] |= BIT(KEY_F12);
ts->input.keybit[LONG(KEY_F9)] |= BIT(KEY_F9);
ts->input.keybit[LONG(KEY_HOME)] |= BIT(KEY_HOME);
ts->input.name = "x50 ts";
ts->input.private = ts;
input_register_device (&ts->input);
ts->timer.function = x50_ts_timer_callback;
ts->timer.data = (unsigned long)ts;
ts->state = STATE_WAIT_FOR_TOUCH;
init_timer (&ts->timer);
ts->irq = X50_IRQ(TOUCHPANEL_IRQ_N);
*/
h4000_ts_setup(&dev_ads7846);
input_register_device(&dev_ads7846);
// set_irq_chained_handler(X50_IRQ(TOUCHPANEL_IRQ_N), pen_isr);
/* *** Initialize the SSP interface *** */
ssp_init();
pxa_gpio_mode(GPIO23_SCLK_MD);
pxa_gpio_mode(GPIO24_SFRM_MD);
pxa_gpio_mode(GPIO25_STXD_MD);
pxa_gpio_mode(GPIO26_SRXD_MD);
//////////////////////////////////////////////////////////////////
/*
set_GPIO_mode(GPIO23_SCLK_MD);
set_GPIO_mode(GPIO24_SFRM_MD);
set_GPIO_mode(GPIO25_STXD_MD);
set_GPIO_mode(GPIO26_SRXD_MD); */
////////////////////////////////////////////////////////////
//printk(KERN_NOTICE "Dell Axim x50(v) Touch Screen Driver registering...\n");
return 0;
}
static void
x50_ts_module_cleanup (void)
{
//printk(KERN_NOTICE "Dell Axim x50(v) Touch Screen Driver
unregistering...\n");
//soc_driver_unregister (&soc_driver);
}
/*
extern int soc_driver_register(struct soc_device_driver * drv)
{
//drv->driver.bus = &soc_bus_type;
//return driver_register(&drv->driver);
}
EXPORT_SYMBOL(soc_driver_register);
extern void soc_driver_unregister(struct soc_device_driver * drv)
{
driver_unregister(&drv->driver);
}
*/
static int h4000_ts_setup(struct input_dev *dev)
{
enable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
// printk("ts setup\n");
memset(dev, 0x0, sizeof(*dev));
init_input_dev(dev);
dev->private = dev;
dev->name = ads7846_name;
dev->phys = ads7846_phys;
dev->open = ts_open;
dev->close = ts_close;
set_bit(EV_ABS, dev->evbit);
set_bit(ABS_X, dev->absbit);
set_bit(ABS_Y, dev->absbit);
set_bit(ABS_PRESSURE, dev->absbit);
dev->absmin[ABS_PRESSURE] = 0;
dev->absmax[ABS_PRESSURE] = 1;
// dev->absmax[ABS_PRESSURE] = 0xfff;
dev->absmax[ABS_X] = 0xfff;
dev->absmax[ABS_Y] = 0xfff;
dev->absfuzz[ABS_X] = 2;
dev->absfuzz[ABS_Y] = 2;
dev->absflat[ABS_X] = 4;
dev->absflat[ABS_Y] = 4;
dev->id.bustype = BUS_PXA_NSSP;
dev->id.vendor = 0xffff;
dev->id.product = 0xffff;
dev->id.version = 0xffff;
return 0;
}
module_init(x50_ts_module_init);
module_exit(x50_ts_module_cleanup);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Richard Bateman <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("Dell Axim X50(v) Touch Screen Driver");
/* Touch screen driver for the TI something-or-other
*
* Copyright © 2005 SDG Systems, LLC
*
* Based on code that was based on the SAMCOP driver.
* Copyright © 2003, 2004 Compaq Computer Corporation.
*
* Use consistent with the GNU GPL is permitted,
* provided that this copyright notice is
* preserved in its entirety in all copies and derived works.
*
* COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
* AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
* FITNESS FOR ANY PARTICULAR PURPOSE.
*
* Author: Keith Packard <[EMAIL PROTECTED]>
* May 2003
*
* Updates:
*
* 2004-02-11 Michael Opdenacker Renamed names from samcop to shamcop,
* Goal:support HAMCOP and SAMCOP.
* 2004-02-14 Michael Opdenacker Temporary fix for device id handling
*
* 2005-02-18 Aric Blumer Converted basic structure to support
hx4700
*
* 2005-06-20 Richard Bateman Ported to the Dell Axim x50(v)
Handheld
*/
#include <linux/module.h>
#include <linux/version.h>
#include <linux/config.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/pm.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/device.h>
#include <linux/soc-device.h>
#include <asm/arch/hardware.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
#include <asm/io.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/aximx50-gpio.h>
#define CTRL_START 0x80
#define CTRL_YPOS 0x10
#define CTRL_Z1POS 0x30
#define CTRL_Z2POS 0x40
#define CTRL_XPOS 0x50
#define DIFFMODE_X_POSI 0x00d0
#define DIFFMODE_Y_POSI 0x0090
enum touchscreen_state {
STATE_WAIT_FOR_TOUCH, /* Waiting for a PEN interrupt */
STATE_SAMPLING /* Actively sampling ADC */
};
struct touchscreen_data {
enum touchscreen_state state;
struct timer_list timer;
int irq;
struct input_dev input;
};
struct key_data {
int gpiod_val;
int gpiod_bit;
int rising;
int key;
} asic3_key[3];
static unsigned long poll_sample_time = 10; /* Sample every 10 milliseconds */
static struct touchscreen_data *ts_data;
static int irqblock;
MODULE_PARM(poll_sample_time, "i");
static inline void
report_touchpanel(struct touchscreen_data *ts, int pressure, int x, int y)
{
input_report_abs(&ts->input, ABS_PRESSURE, pressure);
input_report_abs(&ts->input, ABS_X, x);
input_report_abs(&ts->input, ABS_Y, y);
input_sync(&ts->input);
}
static void start_read(struct touchscreen_data *touch);
static void
pen_isr(unsigned int irq, void *data, struct pt_regs *regs)
{
struct touchscreen_data *ts = ts_data;
struct input_dev *dev = (struct input_dev *)data;
if (GET_X50_GPIO(TOUCHPANEL_IRQ_N) == 0)
{
unsigned long r;
int x, y, x_new, y_new;
// printk("interrupt occur\n");
SSDR = DIFFMODE_X_POSI;
while (fifo_empty());
x = SSDR;
x_new = (x - 141)*800/3662;
SSDR = DIFFMODE_Y_POSI;
while (fifo_empty());
y = SSDR;
y_new=600 - (y - 197)*600/3630;
/////////////////////////////////////////////////////
input_report_abs(&ts->input, ABS_X, x_new );
input_report_abs(&ts->input, ABS_Y, y_new );
input_report_abs(&ts->input, ABS_PRESSURE,0);// 0xfff);
input_sync(&ts->input);
input_report_abs(&ts->input, ABS_X, x_new & 0xfff);
input_report_abs(&ts->input, ABS_Y, y_new & 0xfff);
input_report_abs(&ts->input, ABS_PRESSURE, 0xfff);
input_sync(&ts->input);
input_report_abs(&ts->input, ABS_X, 70);
input_report_abs(&ts->input, ABS_Y, 100);
input_report_abs(&ts->input, ABS_PRESSURE, 0);
input_sync(&ts->input);
/////////////////////////////////////////////////
input_report_abs(dev, ABS_X, x_new );
input_report_abs(dev, ABS_Y, y_new );
input_report_abs(dev, ABS_PRESSURE,0);// 0xfff);
input_sync(dev);
input_report_abs(dev, ABS_X, x_new & 0xfff);
input_report_abs(dev, ABS_Y, y_new & 0xfff);
input_report_abs(dev, ABS_PRESSURE, 0xfff);
input_sync(dev);
input_report_abs(dev, ABS_X, 70);
input_report_abs(dev, ABS_Y, 100);
input_report_abs(dev, ABS_PRESSURE, 0);
input_sync(dev);
start_read(ts);
// printk("x: %x y: %x, x_new: %x y_new: %x \n", x, y, x_new,
y_new);
/*
printk(KERN_NOTICE "ts interrupt. Pen is down.\n");
printk(KERN_NOTICE "%x\n",SSCR0);
printk(KERN_NOTICE "%x\n",SSCR1);
printk(KERN_NOTICE "SSSR_P2 : %x\n",SSSR_P2);
printk(KERN_NOTICE "SSDR_P2 : %x\n",SSDR_P2);
printk(KERN_NOTICE "%x\n",SSSR);
printk(KERN_NOTICE "%x\n",SSSR_P2);
printk(KERN_NOTICE "%x\n" ,(GPLR(GET_X50_GPIO(TOUCHPANEL_IRQ_N)) &
GPIO_bit(GET_X50_GPIO(TOUCHPANEL_IRQ_N))));
printk(KERN_NOTICE "%x\n",SSSR_BSY);
printk(KERN_NOTICE "%x\n",SSSR_RNE);
printk(KERN_NOTICE "%x\n",GRER0);
//SSDR_P2 = 0xd00000;
*/
// int ssrval = SSSR_P2;
//disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
//SSDR=CTRL_START | CTRL_YPOS;
//SSDR_P2 = 0xd00000;
//SSDR_P2 = 0x900000;
//printk(KERN_NOTICE "SSDR without delaay: %x\n",SSDR);
//while(ssrval & (1<<2))
//{
// udelay(10);
// printk(KERN_NOTICE "SSDR delay 1 , 10 ums : %x\n",SSDR);
//}
//SSDR_P2= 0x900000;//CTRL_START | CTRL_YPOS;
//printk(KERN_NOTICE "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa SSDR
final: %x\n",SSDR);
//udelay(100);
// printk(KERN_NOTICE "SSDR delay 1 , 100 ums : %x\n",SSDR);
//printk(KERN_NOTICE "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa SSDR & 0xFFFF
: %x\n", SSDR & 0xFFFF);
//udelay(1000);
// printk(KERN_NOTICE "SSDR delay 1 , 1000 ums : %x\n",SSDR);
// udelay(10000);
//printk(KERN_NOTICE "SSDR delay 1 , 10000 ums : %x\n",SSDR);
///////
/*
int antirace;
antirace = 100000;
while ((SSSR & SSSR_BSY) && antirace)
{
udelay(10);
antirace--;
};
//////
printk(KERN_NOTICE "h4000 SSDR : %x\n",SSDR);
//disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
//disable_irq();
}
else
{
printk(KERN_NOTICE "ts interrupt. Pen is up.\n");
// printk(KERN_NOTICE "%x\n",SSDR);
// printk(KERN_NOTICE "%x\n",SSCR);
set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_FALLING);
return;
}
*/
//printk(KERN_NOTICE "ts interrupt\n");
/* struct touchscreen_data *ts = dev_id->data; */
//struct touchscreen_data *ts = ts_data;
// if (irq == X50_IRQ(TOUCHPANEL_IRQ_N))
//{
//irqblock = 1;
/*
* Disable the pen interrupt. It's reenabled when the user lifts the
* pen.
*/
/* disable_irq(HX4700_IRQ(TOUCHPANEL_IRQ_N)); */
/* XXX for some reason this disable does not work so I put in the
* irqblock variable. I shouldn't have to. */
/* Update. set_irq_type does work, but the irq code prints a message
* every time. Bummer. */
// set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_RISING);
// disable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
// if (ts->state == STATE_WAIT_FOR_TOUCH) {
// ts->state = STATE_SAMPLING;
//start_read(ts);
//} else {
/* Shouldn't happen */
//printk(KERN_ERR "Unexpected ts interrupt\n");
//}
// printk(KERN_NOTICE "disable irq\n");
}
}
static int fifo_empty(void)
{
if( SSSR & 0x8)
return 0; // is not empty
else
return 1; // empty
}
static void
ssp_init(void)
{
SSCR0 = 0x0000472B;
SSCR1 = 0x00000440;
CKEN |= CKEN3_SSP;
SSCR0 |= 0x00000080;
SSDR = 0x00d0; //DIFFMODE_X_POSI;
while (fifo_empty());
unsigned long r = SSDR;
/* *** Set up the SPI Registers *** */
// SSCR0_P2 =
// (1 << 20) /* Extended Data Size Select */
// | (6 << 8) /* Serial Clock Rate */
// | (0 << 7) /* Synchronous Serial Enable (Disable for now) */
// | (0 << 4) /* Motorola SPI Interface */
// | (7 << 0) /* Data Size Select (24-bit) */
// ;
// SSCR1_P2 = 0;
// SSPSP_P2 = 0;
/* Clear the Status */
//SSSR_P2 = SSSR_P2 & 0x00fcfffc;
/* Now enable it */
//SSCR0_P2 =
// (1 << 20) /* Extended Data Size Select */
// | (6 << 8) /* Serial Clock Rate */
// | (1 << 7) /* Synchronous Serial Enable */
// | (0 << 4) /* Motorola SPI Interface */
// | (7 << 0) /* Data Size Select (24-bit) */
// ;
//enable_irq(X50_IRQ(TOUCHPANEL_IRQ_N));
}
static void
start_read(struct touchscreen_data *touch)
{
unsigned long inc = (poll_sample_time * HZ) / 1000;
int i;
/* Write here to the serial port. We request X and Y only for now.
* Then we have to wait for poll_sample_time before we read out the serial
* port. Then, when we read it out, we check to see if the pen is still
* down. If so, then we issue another request here.
*/
#define TS_SAMPLES 7
/*
* We do four samples for each, and throw out the highest and lowest, then
* average the other two.
*/
// for(i = 0; i < TS_SAMPLES; i++) {
// while(!(SSSR_P2 & (1 << 2)))
// ;
/* It's not full. Write the command for X */
// SSDR_P2 = 0xd00000 ;/* | (lower_bits << 0) */ /* May want bits 0 and 1
set for keeping power up */
// }
//for(i = 0; i < TS_SAMPLES; i++) {
// while(!(SSSR_P2 & (1 << 2)))
;
/* It's not full. Write the command for Y */
// SSDR_P2 = 0x900000 ;/* | (lower_bits << 0) */ /* May want bits 0
and 1 set for keeping power up */
//}
/*
* Enable the timer. We should get an interrupt, but we want keep a timer
* to ensure that we can detect missing data
*/
mod_timer(&touch->timer, jiffies + inc);
}
static void
x50_ts_timer_callback(unsigned long data)
{
//if (GET_X50_GPIO(TOUCHPANEL_IRQ_N) == 0)
//printk(KERN_NOTICE "ts callback. Pen is still down.\n");
//else
//printk(KERN_NOTICE "ts callback. Pen is up.\n");
struct touchscreen_data *ts = (struct touchscreen_data *)data;
static int oldx, oldy;
int ssrval;
unsigned long r;
int x, y, x_new, y_new;
// printk("interrupt occur\n");
SSDR = DIFFMODE_X_POSI;
while (fifo_empty());
x = SSDR;
x_new = (x - 141)*800/3662;
SSDR = DIFFMODE_Y_POSI;
while (fifo_empty());
y = SSDR;
y_new=600 - (y - 197)*600/3630;
input_report_abs(&ts->input, ABS_PRESSURE, 0);
input_report_abs(&ts->input, ABS_X, x);
input_report_abs(&ts->input, ABS_Y, y);
input_sync(&ts->input);
input_report_abs(&ts->input, ABS_X, x_new );
input_report_abs(&ts->input, ABS_Y, y_new );
input_report_abs(&ts->input, ABS_PRESSURE,0);// 0xfff);
input_sync(&ts->input);
input_report_abs(&ts->input, ABS_X, x_new & 0xfff);
input_report_abs(&ts->input, ABS_Y, y_new & 0xfff);
input_report_abs(&ts->input, ABS_PRESSURE, 0xfff);
input_sync(&ts->input);
input_report_abs(&ts->input, ABS_X, 70);
input_report_abs(&ts->input, ABS_Y, 100);
input_report_abs(&ts->input, ABS_PRESSURE, 0);
input_sync(&ts->input);
return;
}
static int
x50_ts_probe (struct device *dev)
{
dev_set_drvdata(dev, ts_data);
request_irq(X50_IRQ(TOUCHPANEL_IRQ_N), pen_isr, SA_INTERRUPT, "x50_ts",
ts_data);
/* For some reason ts_probe is not called, so we do the initialization in
* the module init. */
return 0;
}
static void
x50_ts_remove (struct device *dev)
{
struct touchscreen_data *ts = dev_get_drvdata(dev);
del_timer_sync (&ts->timer);
free_irq (ts->irq, ts);
}
static int
x50_ts_suspend (struct device *dev, u32 state, u32 level)
{
#if 0 /* XXX ?? */
struct touchscreen_data *ts = dev_get_drvdata(dev);
if (level == SUSPEND_POWER_DOWN)
ts->dev->disable();
#endif
return 0;
}
static int
x50_ts_resume (struct device *dev, u32 level)
{
struct touchscreen_data *ts = dev_get_drvdata(dev);
#if 0
if (level == RESUME_POWER_ON)
ts->dev->enable();
#endif
ts->state = STATE_WAIT_FOR_TOUCH;
ssp_init();
return 0;
}
static soc_device_id device_ids[] = {
/* XXX Hack in 0x500. This needs to be assigned? */
{ 0x500 },
{ 0 }
};
static struct soc_device_driver soc_driver = {
.device_ids = device_ids,
.driver = {
.name = "x50_ts",
.probe = x50_ts_probe,
.shutdown = x50_ts_remove,
.suspend = x50_ts_suspend,
.resume = x50_ts_resume
}
};
static int
x50_ts_module_init (void)
{
//printk(KERN_NOTICE "Dell Axim x50(v) Touch Screen Driver\n");
{
struct touchscreen_data *ts;
ts = ts_data = kmalloc (sizeof (*ts), GFP_KERNEL);
memset (ts, 0, sizeof (*ts));
/* *** Set up the input subsystem stuff *** */
memset(&ts->input, 0, sizeof(struct input_dev));
init_input_dev (&ts->input);
ts->input.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
ts->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) |
BIT(ABS_PRESSURE);
ts->input.absmin[ABS_X] = 0;
ts->input.absmax[ABS_X] = 32767;
ts->input.absmin[ABS_Y] = 0;
ts->input.absmax[ABS_Y] = 32767;
ts->input.absmin[ABS_PRESSURE] = 0;
ts->input.absmax[ABS_PRESSURE] = 1;
ts->input.keybit[LONG(KEY_F12)] |= BIT(KEY_F12); /* record */
ts->input.keybit[LONG(KEY_F9)] |= BIT(KEY_F9); /* calendar */
ts->input.keybit[LONG(KEY_HOME)] |= BIT(KEY_HOME);
ts->input.name = "x50 ts";
ts->input.private = ts;
input_register_device (&ts->input);
ts->timer.function = x50_ts_timer_callback;
ts->timer.data = (unsigned long)ts;
ts->state = STATE_WAIT_FOR_TOUCH;
init_timer (&ts->timer);
/* *** Now take care of the IRQ setup *** */
set_irq_chained_handler(X50_IRQ(TOUCHPANEL_IRQ_N), pen_isr);
set_irq_type(X50_IRQ(TOUCHPANEL_IRQ_N), IRQT_FALLING);
/* *** Initialize the SSP interface *** */
ssp_init();
pxa_gpio_mode(GPIO23_SCLK_MD);
pxa_gpio_mode(GPIO24_SFRM_MD);
pxa_gpio_mode(GPIO25_STXD_MD);
pxa_gpio_mode(GPIO26_SRXD_MD);
}
//////////////////////////////////////////////////////////////////
/*
set_GPIO_mode(GPIO23_SCLK_MD);
set_GPIO_mode(GPIO24_SFRM_MD);
set_GPIO_mode(GPIO25_STXD_MD);
set_GPIO_mode(GPIO26_SRXD_MD); */
////////////////////////////////////////////////////////////
//printk(KERN_NOTICE "Dell Axim x50(v) Touch Screen Driver
registering...\n");
return soc_driver_register(&soc_driver);
}
static void
x50_ts_module_cleanup (void)
{
//printk(KERN_NOTICE "Dell Axim x50(v) Touch Screen Driver
unregistering...\n");
soc_driver_unregister (&soc_driver);
}
extern int soc_driver_register(struct soc_device_driver * drv)
{
//drv->driver.bus = &soc_bus_type;
return driver_register(&drv->driver);
}
EXPORT_SYMBOL(soc_driver_register);
extern void soc_driver_unregister(struct soc_device_driver * drv)
{
driver_unregister(&drv->driver);
}
module_init(x50_ts_module_init);
module_exit(x50_ts_module_cleanup);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Richard Bateman <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("Dell Axim X50(v) Touch Screen Driver");
--
_______________________________________________
Aximx50-port mailing list
[email protected]
https://www.handhelds.org/mailman/listinfo/aximx50-port