From patchwork Fri Oct 5 15:31:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1554141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 045233FE80 for ; Fri, 5 Oct 2012 15:38:01 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TK9vn-0003o9-UL; Fri, 05 Oct 2012 15:35:16 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TK9tq-0002u8-6L for linux-arm-kernel@lists.infradead.org; Fri, 05 Oct 2012 15:33:15 +0000 Received: by mail-wi0-f177.google.com with SMTP id hj13so596727wib.0 for ; Fri, 05 Oct 2012 08:32:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=5+dvO5+TE8MuABIQDylUSjNOeWBBr4RtCM3l3OBVwbs=; b=aZKzu1A1L0xYorPFZPCc4r4cJQ3/Bp3nXj3ETtvIeOxjqEACv0kja98jeywCdCTKMo QldswdfmNvzoUeOL7hbBuOOhdsFIb+yHUN/8DXcVSZ1qWf/wE/4ZG1TBCNa7LvQqWxvi rYb8nATfFzqfQDbCv4MhzT/W24VFXv2FHykXvO4M6LSktsFCr5MSOXq9Vb37Ln5gnoRf Tq8rnMHgTC0IcebeGD1zezyICAwPSBgI3JzSzf1rmjFg2VlP8hltRFImcMaM2mks2A2g MAt45huXVTGx0sv31qPKlV8fNpP63geQ5U44hEN63phr5zvgjJjffCpQUKKCOL27xI15 6VuQ== Received: by 10.180.94.226 with SMTP id df2mr4111988wib.11.1349451129628; Fri, 05 Oct 2012 08:32:09 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id w8sm2906148wif.4.2012.10.05.08.32.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 08:32:09 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/10] input: Enable STMPE keypad driver for Device Tree Date: Fri, 5 Oct 2012 16:31:43 +0100 Message-Id: <1349451107-8009-8-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349451107-8009-1-git-send-email-lee.jones@linaro.org> References: <1349451107-8009-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQlpgzua0hnTTOaRUHDBTyqtQCiNAHOKaG7bN994ZGg5E0ZuVxrbMy8RA4xJTdM/tPS2CvmN X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Dmitry Torokhov , Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de, linux-input@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch allows the STMPE driver to be successfully probed and initialised when Device Tree support is enabled. Besides the usual platform data changes, we also separate the process of filling in the 'in use' pin bitmap, as we have to extract the information from Device Tree in the DT boot case. Cc: Dmitry Torokhov Cc: linux-input@vger.kernel.org Acked-by: Linus Walleij Signed-off-by: Lee Jones --- drivers/input/keyboard/stmpe-keypad.c | 67 ++++++++++++++++++++++++++++----- drivers/mfd/stmpe.c | 1 + 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index 470a877..c722d23 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c @@ -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; diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index ba157d4..b03cc64 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -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), };