@@ -257,19 +257,73 @@ static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
(plat->debounce_ms << 1));
}
+static int stmpe_keypad_fill_used_pins(struct platform_device *pdev,
+ struct stmpe_keypad *keypad,
+ struct stmpe_keypad_platform_data *plat)
+{
+ struct device_node *np = pdev->dev.of_node;
+ unsigned int proplen;
+ const __be32 *prop;
+ int i;
+
+ if (np) {
+ prop = of_get_property(np, "linux,keymap", &proplen);
+ if (!prop) {
+ dev_err(&pdev->dev,
+ "linux,keymap property not defined\n");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < proplen / sizeof(u32); i++) {
+ unsigned int key = be32_to_cpup(prop + i);
+
+ keypad->cols |= 1 << KEY_COL(key);
+ keypad->rows |= 1 << KEY_ROW(key);
+ }
+ } else {
+ 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);
+ }
+ }
+
+ return 0;
+}
+
+static void __devinit stmpe_keypad_of_probe(struct device_node *np,
+ struct stmpe_keypad_platform_data *plat)
+{
+ of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
+ of_property_read_u32(np, "stericsson,scan-count", &plat->scan_count);
+
+ if (of_get_property(np, "stericsson,no-autorepeat", NULL))
+ plat->no_autorepeat = true;
+}
+
static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
{
struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
struct stmpe_keypad_platform_data *plat;
+ struct device_node *np = pdev->dev.of_node;
struct stmpe_keypad *keypad;
struct input_dev *input;
int ret;
int irq;
- int i;
plat = stmpe->pdata->keypad;
- if (!plat)
- return -ENODEV;
+ if (!plat) {
+ if (np) {
+ plat = devm_kzalloc(&pdev->dev,
+ sizeof(*plat), GFP_KERNEL);
+ if (!plat)
+ return -ENOMEM;
+
+ stmpe_keypad_of_probe(np, plat);
+ } else
+ return -ENODEV;
+ }
irq = platform_get_irq(pdev, 0);
if (irq < 0)
@@ -300,12 +354,7 @@ static int __devinit 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(pdev, keypad, plat);
keypad->stmpe = stmpe;
keypad->plat = plat;
@@ -321,6 +321,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),
};