Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93225
b: refs/heads/master
c: 45d09e1
h: refs/heads/master
i:
  93223: 2e1f3ac
v: v3
  • Loading branch information
Dmitry Torokhov committed Apr 2, 2008
1 parent 73e8402 commit 11ca75a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4db8a5f21e5149e09949516eef98b78b68880075
refs/heads/master: 45d09e1e097ea5fc0bcb98a6226d90b412e6923a
73 changes: 48 additions & 25 deletions trunk/drivers/input/keyboard/locomokbd.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*
* Copyright (c) 2005 John Lenz
* LoCoMo keyboard driver for Linux-based ARM PDAs:
* - SHARP Zaurus Collie (SL-5500)
* - SHARP Zaurus Poodle (SL-5600)
*
* Copyright (c) 2005 John Lenz
* Based on from xtkbd.c
*/

/*
* LoCoMo keyboard driver for Linux/ARM
*/

/*
*
*
* 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
Expand Down Expand Up @@ -47,7 +45,8 @@ MODULE_LICENSE("GPL");
#define KEY_CONTACT KEY_F18
#define KEY_CENTER KEY_F15

static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
static const unsigned char
locomokbd_keycode[LOCOMOKBD_NUMKEYS] __devinitconst = {
0, KEY_ESC, KEY_ACTIVITY, 0, 0, 0, 0, 0, 0, 0, /* 0 - 9 */
0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_HOME, KEY_CONTACT, /* 10 - 19 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 29 */
Expand All @@ -67,22 +66,21 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
#define KB_COLS 8
#define KB_ROWMASK(r) (1 << (r))
#define SCANCODE(c,r) ( ((c)<<4) + (r) + 1 )
#define NR_SCANCODES 128

#define KB_DELAY 8
#define SCAN_INTERVAL (HZ/10)
#define LOCOMOKBD_PRESSED 1

struct locomokbd {
unsigned char keycode[LOCOMOKBD_NUMKEYS];
struct input_dev *input;
char phys[32];

struct locomo_dev *ldev;
unsigned long base;
spinlock_t lock;

struct timer_list timer;
unsigned long suspend_jiffies;
unsigned int count_cancel;
};

/* helper functions for reading the keyboard matrix */
Expand Down Expand Up @@ -128,7 +126,7 @@ static inline void locomokbd_reset_col(unsigned long membase, int col)
/* Scan the hardware keyboard and push any changes up through the input layer */
static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
{
unsigned int row, col, rowd, scancode;
unsigned int row, col, rowd;
unsigned long flags;
unsigned int num_pressed;
unsigned long membase = locomokbd->base;
Expand All @@ -145,13 +143,33 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)

rowd = ~locomo_readl(membase + LOCOMO_KIB);
for (row = 0; row < KB_ROWS; row++) {
unsigned int scancode, pressed, key;

scancode = SCANCODE(col, row);
if (rowd & KB_ROWMASK(row)) {
num_pressed += 1;
input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1);
} else {
input_report_key(locomokbd->input, locomokbd->keycode[scancode], 0);
}
pressed = rowd & KB_ROWMASK(row);
key = locomokbd->keycode[scancode];

input_report_key(locomokbd->input, key, pressed);
if (likely(!pressed))
continue;

num_pressed++;

/* The "Cancel/ESC" key is labeled "On/Off" on
* Collie and Poodle and should suspend the device
* if it was pressed for more than a second. */
if (unlikely(key == KEY_ESC)) {
if (!time_after(jiffies,
locomokbd->suspend_jiffies + HZ))
continue;
if (locomokbd->count_cancel++
!= (HZ/SCAN_INTERVAL + 1))
continue;
input_event(locomokbd->input, EV_PWR,
KEY_SUSPEND, 1);
locomokbd->suspend_jiffies = jiffies;
} else
locomokbd->count_cancel = 0;
}
locomokbd_reset_col(membase, col);
}
Expand All @@ -162,6 +180,8 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
/* if any keys are pressed, enable the timer */
if (num_pressed)
mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL);
else
locomokbd->count_cancel = 0;

spin_unlock_irqrestore(&locomokbd->lock, flags);
}
Expand All @@ -186,10 +206,11 @@ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
static void locomokbd_timer_callback(unsigned long data)
{
struct locomokbd *locomokbd = (struct locomokbd *) data;

locomokbd_scankeyboard(locomokbd);
}

static int locomokbd_probe(struct locomo_dev *dev)
static int __devinit locomokbd_probe(struct locomo_dev *dev)
{
struct locomokbd *locomokbd;
struct input_dev *input_dev;
Expand All @@ -211,7 +232,6 @@ static int locomokbd_probe(struct locomo_dev *dev)
goto err_free_mem;
}

locomokbd->ldev = dev;
locomo_set_drvdata(dev, locomokbd);

locomokbd->base = (unsigned long) dev->mapbase;
Expand All @@ -222,6 +242,8 @@ static int locomokbd_probe(struct locomo_dev *dev)
locomokbd->timer.function = locomokbd_timer_callback;
locomokbd->timer.data = (unsigned long) locomokbd;

locomokbd->suspend_jiffies = jiffies;

locomokbd->input = input_dev;
strcpy(locomokbd->phys, "locomokbd/input0");

Expand All @@ -233,9 +255,10 @@ static int locomokbd_probe(struct locomo_dev *dev)
input_dev->id.version = 0x0100;
input_dev->dev.parent = &dev->dev;

input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
BIT_MASK(EV_PWR);
input_dev->keycode = locomokbd->keycode;
input_dev->keycodesize = sizeof(unsigned char);
input_dev->keycodesize = sizeof(locomokbd_keycode[0]);
input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);

memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
Expand Down Expand Up @@ -268,7 +291,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
return err;
}

static int locomokbd_remove(struct locomo_dev *dev)
static int __devexit locomokbd_remove(struct locomo_dev *dev)
{
struct locomokbd *locomokbd = locomo_get_drvdata(dev);

Expand All @@ -292,7 +315,7 @@ static struct locomo_driver keyboard_driver = {
},
.devid = LOCOMO_DEVID_KEYBOARD,
.probe = locomokbd_probe,
.remove = locomokbd_remove,
.remove = __devexit_p(locomokbd_remove),
};

static int __init locomokbd_init(void)
Expand Down
13 changes: 12 additions & 1 deletion trunk/drivers/input/mouse/appletouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
#define GEYSER4_ISO_PRODUCT_ID 0x021B
#define GEYSER4_JIS_PRODUCT_ID 0x021C

#define GEYSER4_HF_ANSI_PRODUCT_ID 0x0229
#define GEYSER4_HF_ISO_PRODUCT_ID 0x022A
#define GEYSER4_HF_JIS_PRODUCT_ID 0x022B

#define ATP_DEVICE(prod) \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
USB_DEVICE_ID_MATCH_INT_CLASS | \
Expand Down Expand Up @@ -93,6 +97,10 @@ static struct usb_device_id atp_table [] = {
{ ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) },
{ ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) },

{ ATP_DEVICE(GEYSER4_HF_ANSI_PRODUCT_ID) },
{ ATP_DEVICE(GEYSER4_HF_ISO_PRODUCT_ID) },
{ ATP_DEVICE(GEYSER4_HF_JIS_PRODUCT_ID) },

/* Terminating entry */
{ }
};
Expand Down Expand Up @@ -217,7 +225,10 @@ static inline int atp_is_geyser_3(struct atp *dev)
(productId == GEYSER3_JIS_PRODUCT_ID) ||
(productId == GEYSER4_ANSI_PRODUCT_ID) ||
(productId == GEYSER4_ISO_PRODUCT_ID) ||
(productId == GEYSER4_JIS_PRODUCT_ID);
(productId == GEYSER4_JIS_PRODUCT_ID) ||
(productId == GEYSER4_HF_ANSI_PRODUCT_ID) ||
(productId == GEYSER4_HF_ISO_PRODUCT_ID) ||
(productId == GEYSER4_HF_JIS_PRODUCT_ID);
}

/*
Expand Down
22 changes: 10 additions & 12 deletions trunk/drivers/input/touchscreen/ads7846.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct ads7846 {
#endif

u16 model;
u16 vref_mv;
u16 vref_delay_usecs;
u16 x_plate_ohms;
u16 pressure_max;
Expand Down Expand Up @@ -184,9 +185,6 @@ struct ads7846 {
* The range is GND..vREF. The ads7843 and ads7835 must use external vREF;
* ads7846 lets that pin be unconnected, to use internal vREF.
*/
static unsigned vREF_mV;
module_param(vREF_mV, uint, 0);
MODULE_PARM_DESC(vREF_mV, "external vREF voltage, in milliVolts");

struct ser_req {
u8 ref_on;
Expand All @@ -213,7 +211,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
struct ads7846 *ts = dev_get_drvdata(dev);
struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
int status;
int uninitialized_var(sample);
int use_internal;

if (!req)
Expand Down Expand Up @@ -270,13 +267,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)

if (status == 0) {
/* on-wire is a must-ignore bit, a BE12 value, then padding */
sample = be16_to_cpu(req->sample);
sample = sample >> 3;
sample &= 0x0fff;
status = be16_to_cpu(req->sample);
status = status >> 3;
status &= 0x0fff;
}

kfree(req);
return status ? status : sample;
return status;
}

#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
Expand Down Expand Up @@ -317,7 +314,7 @@ static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
unsigned retval = v;

/* external resistors may scale vAUX into 0..vREF */
retval *= vREF_mV;
retval *= ts->vref_mv;
retval = retval >> 12;
return retval;
}
Expand Down Expand Up @@ -375,14 +372,14 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
/* hwmon sensors need a reference voltage */
switch (ts->model) {
case 7846:
if (!vREF_mV) {
if (!ts->vref_mv) {
dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n");
vREF_mV = 2500;
ts->vref_mv = 2500;
}
break;
case 7845:
case 7843:
if (!vREF_mV) {
if (!ts->vref_mv) {
dev_warn(&spi->dev,
"external vREF for ADS%d not specified\n",
ts->model);
Expand Down Expand Up @@ -875,6 +872,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)

ts->spi = spi;
ts->input = input_dev;
ts->vref_mv = pdata->vref_mv;

hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ts->timer.function = ads7846_timer;
Expand Down
3 changes: 2 additions & 1 deletion trunk/include/linux/spi/ads7846.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enum ads7846_filter {
struct ads7846_platform_data {
u16 model; /* 7843, 7845, 7846. */
u16 vref_delay_usecs; /* 0 for external vref; etc */
int keep_vref_on:1; /* set to keep vref on for differential
u16 vref_mv; /* external vref value, milliVolts */
bool keep_vref_on; /* set to keep vref on for differential
* measurements as well */

/* Settling time of the analog signals; a function of Vcc and the
Expand Down

0 comments on commit 11ca75a

Please sign in to comment.