Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 346956
b: refs/heads/master
c: 6ea3238
h: refs/heads/master
v: v3
  • Loading branch information
Dmitry Torokhov committed Nov 24, 2012
1 parent 0be5221 commit 514ad93
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 10 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: e2619cf78e19476bfd7ceaefa9eff0847529346e
refs/heads/master: 6ea32387a0c7fb9ca0213fd22b47c5a1ca4c2972
39 changes: 39 additions & 0 deletions trunk/Documentation/devicetree/bindings/input/stmpe-keypad.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
* STMPE Keypad

Required properties:
- compatible : "st,stmpe-keypad"
- linux,keymap : See ./matrix-keymap.txt

Optional properties:
- debounce-interval : Debouncing interval time in milliseconds
- st,scan-count : Scanning cycles elapsed before key data is updated
- st,no-autorepeat : If specified device will not autorepeat

Example:

stmpe_keypad {
compatible = "st,stmpe-keypad";

debounce-interval = <64>;
st,scan-count = <8>;
st,no-autorepeat;

linux,keymap = <0x205006b
0x4010074
0x3050072
0x1030004
0x502006a
0x500000a
0x5008b
0x706001c
0x405000b
0x6070003
0x3040067
0x303006c
0x60400e7
0x602009e
0x4020073
0x5050002
0x4030069
0x3020008>;
};
60 changes: 51 additions & 9 deletions trunk/drivers/input/keyboard/stmpe-keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,51 @@ static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
(plat->debounce_ms << 1));
}

static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad)
{
int row, col;

for (row = 0; row < STMPE_KEYPAD_MAX_ROWS; row++) {
for (col = 0; col < STMPE_KEYPAD_MAX_COLS; col++) {
int code = MATRIX_SCAN_CODE(row, col,
STMPE_KEYPAD_ROW_SHIFT);
if (keypad->keymap[code] != KEY_RESERVED) {
keypad->rows |= 1 << row;
keypad->cols |= 1 << col;
}
}
}
}

#ifdef CONFIG_OF
static const struct stmpe_keypad_platform_data *
stmpe_keypad_of_probe(struct device *dev)
{
struct device_node *np = dev->of_node;
struct stmpe_keypad_platform_data *plat;

if (!np)
return ERR_PTR(-ENODEV);

plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
if (!plat)
return ERR_PTR(-ENOMEM);

of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
of_property_read_u32(np, "st,scan-count", &plat->scan_count);

plat->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat");

return plat;
}
#else
static inline const struct stmpe_keypad_platform_data *
stmpe_keypad_of_probe(struct device *dev)
{
return ERR_PTR(-EINVAL);
}
#endif

static int stmpe_keypad_probe(struct platform_device *pdev)
{
struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
Expand All @@ -265,11 +310,13 @@ static int stmpe_keypad_probe(struct platform_device *pdev)
struct input_dev *input;
int error;
int irq;
int i;

plat = stmpe->pdata->keypad;
if (!plat)
return -ENODEV;
if (!plat) {
plat = stmpe_keypad_of_probe(&pdev->dev);
if (IS_ERR(plat))
return PTR_ERR(plat);
}

irq = platform_get_irq(pdev, 0);
if (irq < 0)
Expand Down Expand Up @@ -299,12 +346,7 @@ static int stmpe_keypad_probe(struct platform_device *pdev)
if (!plat->no_autorepeat)
__set_bit(EV_REP, input->evbit);

for (i = 0; i < plat->keymap_data->keymap_size; i++) {
unsigned int key = plat->keymap_data->keymap[i];

keypad->cols |= 1 << KEY_COL(key);
keypad->rows |= 1 << KEY_ROW(key);
}
stmpe_keypad_fill_used_pins(keypad);

keypad->stmpe = stmpe;
keypad->plat = plat;
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/mfd/stmpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ static struct resource stmpe_keypad_resources[] = {

static struct mfd_cell stmpe_keypad_cell = {
.name = "stmpe-keypad",
.of_compatible = "st,stmpe-keypad",
.resources = stmpe_keypad_resources,
.num_resources = ARRAY_SIZE(stmpe_keypad_resources),
};
Expand Down

0 comments on commit 514ad93

Please sign in to comment.