From patchwork Fri Nov 24 09:30:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 119560 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1952214qgn; Fri, 24 Nov 2017 01:30:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMYe6alA/kcC8FvSfwyei2L52CydXf/u/jpkbr2f4epbSSsGroH32qZVW7Bxie/pzNqM9SAV X-Received: by 10.99.120.10 with SMTP id t10mr9097789pgc.393.1511515853814; Fri, 24 Nov 2017 01:30:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511515853; cv=none; d=google.com; s=arc-20160816; b=XI5eGOK21ueOywIv6oGFXEOXL4rgfRJ1KXATmX1cykEJCzEM4p8PdRc77TCAJmP/XL 0RvKed+3NSt12JLrL+LB6ICYXtK2y8Bo2CRTWNyke/iqtGxmh5jCPCdWXRZ9eJu2V7j7 jkKlp3LfFlPI/tsPD6p1pw3rPsuXMckAtafhC1sKx1rrft3Gu1UdQEcmvTIcI4I2DA4J 4/THGHsTHe4yQP1nDtuqS23GGMj2O9nKhNgc64j7u4tNQaCcVa4YAghZ+V1I1oJOkbLa 6KIUS7u+gL5F9CtlvqY+DDLXBu1R1cD1l9We517HjjPG7dEoByaSUB/jz5gw8+X6Mzhj MiGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=hTdQEwzkCHxZcvB5E1i3W0skU/iyhywyIghYvhYiYws=; b=AjeQ+0EwfiWH1gdIxAlSY9DBnRce2nn0KHz3+oYTcPxS+jChorL20auA1AzMbOntoK 9CdNew9FGCZUtLn+C5DTmlxkBOu3dHhnmgMi272w+pfPMnxclWl8ZLN7DdMp8eeNbt46 lGNOLHQh56cK9fgDwxN0KFaKUOWiKIFY+tviolfWVCKlO8ajXlIVMc3m4pzvKb6GLkmn UeDnMlJk1R9Nyg9UATk0jv5u2ukdmDTAjdHYPzgzvSxGHclc9/XuUGm/HTQE/OrNV22O w1NHTs2I9752Gay+0TklkLZGQs8mIqOWyRm2IjMYVjI0MW1AypeaiTeBKQxB7D3b81u5 pEsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZunHVpSi; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si19793425pfg.173.2017.11.24.01.30.53 for ; Fri, 24 Nov 2017 01:30:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZunHVpSi; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752322AbdKXJaw (ORCPT ); Fri, 24 Nov 2017 04:30:52 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36215 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752759AbdKXJav (ORCPT ); Fri, 24 Nov 2017 04:30:51 -0500 Received: by mail-lf0-f68.google.com with SMTP id k66so24748664lfg.3 for ; Fri, 24 Nov 2017 01:30:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xCnI7XSqOKfUZ6TJHPtNBJMofvgtA3o1rRrtGoZsc9M=; b=ZunHVpSiAKOLFDa9GqcYxaTfKN2CYeApcTUMm2gEmevT831ohYZbBxFKAjDNcFmIwR ohFigJQgytaMDkksOyqXPR/Kvy9DU0jrmlFP+x75ZgF133vx3GArPhzxM8gYoE/yikwi kn7H3ef9ERuzNlxfLdqUyGBZnLtEB8JFCbYBA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xCnI7XSqOKfUZ6TJHPtNBJMofvgtA3o1rRrtGoZsc9M=; b=axekf5ptFkPJiznQfncG7tvkjTNOp0n9Wydn/EaQw8YLeueCbXsMbNT6hHr6R4Ng45 ZHgfAevDChBUOqwM9YHv4uJqmJPdz/syKnfqnXNEKFEfxP877SdcMnGfjxzibsmPf2IW nH4/pok7vNQ1cvnYVVSWl7Ow/9GB+qYUd3pfjBgWe19vYjUDEhP8MZrWVzdrrGQB23mD CyVOQVlnB2X0OoAPTujBPvhmIK4y2/zLnGlx+hAMKuo24EMl3eRYnQ5SG6CxghTDgAlf WNINb88atv7badIlsVUKMOH+OXAPAsIkyo1hYTa2ZENpqKHSig7Q4TuiCEsEIPrxA/jM hwMw== X-Gm-Message-State: AJaThX52ZTRQbEBLpqxXtR5349ODIoQmWTnjBWRyr+NZBMXn+o6rmXVd Hx4wWo1paKADhmkF4ZufAXhYG5seN+Y= X-Received: by 10.46.27.131 with SMTP id c3mr9687238ljf.40.1511515850348; Fri, 24 Nov 2017 01:30:50 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:49 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 1/5] Input: gpio-keys: Support getting descriptors from board Date: Fri, 24 Nov 2017 10:30:41 +0100 Message-Id: <20171124093045.5961-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org There are any number of board files in the kernel providing keys/pushbuttons/switches using simple GPIO. In order to transfer these smoothly to use GPIO descriptors with descriptor tables in the board files and no static GPIO numbers, we need to accept that the board files provide named GPIOs associated with the GPIO chip device. Luckily gpio_keys of both polled and interrupt-enabled type will optionally pass a "desc" field which we can use as the name of the GPIO to look up and request a GPIO line for a certain key defined in a per-board descriptor lookup table. Signed-off-by: Linus Walleij --- drivers/input/keyboard/gpio_keys.c | 14 +++++++++++++- drivers/input/keyboard/gpio_keys_polled.c | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 87e613dc33b8..420262a4fd54 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -520,7 +520,9 @@ static int gpio_keys_setup_key(struct platform_device *pdev, } else if (gpio_is_valid(button->gpio)) { /* * Legacy GPIO number, so request the GPIO here and - * convert it to descriptor. + * convert it to descriptor. This code goes away once + * we convert all old board files to provide descriptor + * tables. */ unsigned flags = GPIOF_IN; @@ -537,6 +539,16 @@ static int gpio_keys_setup_key(struct platform_device *pdev, bdata->gpiod = gpio_to_desc(button->gpio); if (!bdata->gpiod) return -EINVAL; + } else { + /* + * Try to look up from the descriptor table, includes + * letting gpiolib handle inversion semantics. This is + * optional since we have interrupt-only keys as well. + */ + bdata->gpiod = devm_gpiod_get_optional(dev, desc, + GPIOD_IN); + if (IS_ERR(bdata->gpiod)) + return PTR_ERR(bdata->gpiod); } if (bdata->gpiod) { diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index edc7262103b9..1bc428a7edea 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c @@ -342,6 +342,16 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) button->gpio); return -EINVAL; } + } else { + /* + * Try to look up from the descriptor table, includes + * letting gpiolib handle inversion semantics. + */ + bdata->gpiod = devm_gpiod_get_optional(dev, + button->desc, + GPIOD_IN); + if (IS_ERR(bdata->gpiod)) + return PTR_ERR(bdata->gpiod); } bdata->last_state = -1; From patchwork Fri Nov 24 09:30:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 119561 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1952258qgn; Fri, 24 Nov 2017 01:30:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMa1T/RcmTVlk/BE7a/32fKO9Cc3O9UEhXJu7hdYu06Sni19iVlOOPZeHT2gwK76E0tXRRV8 X-Received: by 10.84.169.67 with SMTP id g61mr4289933plb.152.1511515855704; Fri, 24 Nov 2017 01:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511515855; cv=none; d=google.com; s=arc-20160816; b=doMYXtJptFgLiqUFjVxuEqkYdR4tng9A9izIi2VSAD5hF+2Y9uEUTi3jPUgrfqDEiA OKvSXc5zuo9LUtlQwzQLioP3W4L8fGi4EMfGuEjSLL5JQ2MF2Z6Ssn6xI9pMfud2BG44 Y4b2tVnfKB/FMJnsIsMMkh4nEvOZQYiQiWCApYz9Mc4INWl7aBhvKjfpqXezALcuSapD qMRwjvfF8kLz9VKEjVqgbQTPMEUp0E8+oAMMvUfU+LFmE4UUxkR4u+rTirxkNeNAJr6d 09afQgu3G5se9OMpej+DZgbcnJYVmHoOzXbOksNhm5r+WOt/tEYgUYl3bMhVxAIiGXEL eXdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=amoPk+PEV3kDbsBtrtoL3Bs114v7bFQdlKYw1kTedcA=; b=CPNzt3vOdi0ZP4sTAOwJSKG4CkaPdY53228YVXiCtirrt27HJM/i+lFvHSJJnOHKMr R5ybynESp2+VrmW0ouMlrw4BWlNyb3aasGx7O1usb/Q+5Ca8P7cxRD5+lUG+SkA/yfz5 4kxczAQkJX2p7to5ZDlwEoLPLH/+ryjiBSure2QNiEjuGU0Vz1sTkjrpxRhnKxnhkyRW KCAvtLUIckAvJ3Ydg0xtPNtn6NU6jtpNMBsFthoQhehhrm0sBRCnnrPjGKZek+RtzCMV 5+mZEQlLxSvTaWxO5acmw8A8l2L1dV6z+F52IvOrb1C9cejkMTErygWvZoXdCyQQCE4C lSTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g3JjEjF5; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si19793425pfg.173.2017.11.24.01.30.55 for ; Fri, 24 Nov 2017 01:30:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g3JjEjF5; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbdKXJay (ORCPT ); Fri, 24 Nov 2017 04:30:54 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:39677 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbdKXJax (ORCPT ); Fri, 24 Nov 2017 04:30:53 -0500 Received: by mail-lf0-f67.google.com with SMTP id x76so20102146lfb.6 for ; Fri, 24 Nov 2017 01:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BLM/E4znKAlNdOQWjqTuitwFLoge9b3S7NgfeG+1l1o=; b=g3JjEjF5VodimWnRUUjFMJLLHGDkrrUbmPY67nbLtrxI1uwkHg72c1xBEsUBXLkVyI WQAAGgdoda6bIINH3MRh1cjwVgveTqSk2HULZ7uS4ADSrA0EizeOxhm8c5V9daF8TUZs aXVzgU9Fvglu4tSkygvc45j0mUdIZ6yJngjRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BLM/E4znKAlNdOQWjqTuitwFLoge9b3S7NgfeG+1l1o=; b=OI9mQ2t9ryU4jiaIz367axfi6Dbt7jwkXqJ6c32bYVK9BbPj0cggD3y+EMVlBl92on sM5acgBCXD9EHsUhiY1zV2ysSouYDdCrMScGwPIicosNP6XLgcVExnmB8djoHnFmUmZB jyuh2K/2NOAlvSHQ5vKtwbf1u2A+TCS+O5ZWlKhNFIL6c/+ZUhEkuvmb42yPv3k9bGQY zulVHSnDA8tljvmMqFNK9dK6VjIGq9KlPyOU9tZ0NxrLwSm+vZtnChtoxMkk5Z9vRIj4 L06GwWWwIf5vPOC0J3zFkLlZMexS3zwt3zmgJBU5UdBvVf5Hqr6xgvg1olTITgmvjdEg X3wQ== X-Gm-Message-State: AJaThX66CwS8Sorfq4p9gFEJOAlRNVOfWXdgNDbmWvs1AzGPGJwqxYHh zj3+xZ1m7eRTcoHz4PYqFFmmgw== X-Received: by 10.46.91.75 with SMTP id p72mr10456843ljb.95.1511515852513; Fri, 24 Nov 2017 01:30:52 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:51 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 2/5] gpio: pca953x: Name the gpiochip after the I2C address Date: Fri, 24 Nov 2017 10:30:42 +0100 Message-Id: <20171124093045.5961-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Just putting the name of the I2C device as name for the GPIO chip (label) is ambigous, and makes it hard for us to use GPIO descriptor tables on systems such as DaVinci DA850EVM which has two chips but on I2C address 0x20 and 0x21. Instead, append "-XX" to the GPIOchip name using the I2C address so we get a unique chip name that can be used in descriptor tables, such as "tca6416-20" and "tca6416-21" on the DaVinci DA850EVM. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-pca953x.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index babb7bd2ba59..bab09f1a6bc9 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -413,10 +413,17 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc, mutex_unlock(&chip->i2c_lock); } -static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) +static int pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) { + struct i2c_client *client = chip->client; struct gpio_chip *gc; + static char *chipname; + /* Gives a chip name from the chip name and I2C address */ + chipname = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%02x", + client->name, client->addr); + if (!chipname) + return -ENOMEM; gc = &chip->gpio_chip; gc->direction_input = pca953x_gpio_direction_input; @@ -429,10 +436,12 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) gc->base = chip->gpio_start; gc->ngpio = gpios; - gc->label = chip->client->name; + gc->label = chipname; gc->parent = &chip->client->dev; gc->owner = THIS_MODULE; gc->names = chip->names; + + return 0; } #ifdef CONFIG_GPIO_PCA953X_IRQ @@ -848,7 +857,9 @@ static int pca953x_probe(struct i2c_client *client, /* initialize cached registers from their original values. * we can't share this chip with another i2c master. */ - pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK); + ret = pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK); + if (ret) + goto err_exit; if (chip->gpio_chip.ngpio <= 8) { chip->write_regs = pca953x_write_regs_8; From patchwork Fri Nov 24 09:30:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 119562 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1952292qgn; Fri, 24 Nov 2017 01:30:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMazsrJrFETtC2/oiqewUxZcxH9TRh7Rfv3/gdBDVunEzxXrKpNRG/7Ffw9b8RMQbd6hFPT3 X-Received: by 10.101.81.67 with SMTP id g3mr27250531pgq.262.1511515857836; Fri, 24 Nov 2017 01:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511515857; cv=none; d=google.com; s=arc-20160816; b=gZ4JqbG1vPH/9X+zS91bf/j9QPiUBfWaglekw0Jy4gAffal6wboYGph+SRCwazhS7P 7uBDyNdLLyjQJbaA9Kmne+uIyjVv0lPA2OtnBgns6hBism6EpYonccuJwkXLmwSoJc9f Ruv3B5jZ3qCwIkDq299tDOgqSjOAwaLB0JBVRNQ1EQN4TVh8ILlMgCulRBVK2oC92Uv/ cA5gXot2rgoL04iDxtiF15wkB0U6wB7TyYa1CqaBlAZJHqK54FyAALTd3HZfmeSVQj3b SCf97g6ToCrKWbPYtOjKmJyIw57KrUNJbtPWQ44109WHGhQc5j+Ytboe/bQ3e+1nLTNO kDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=k0goBvPbWcOAdM95ODYSzRb94HnmeVJ48z75QSoN8Yg=; b=BRa3dchJFeuoG4XbQy6jbA3fUmUfQNVe0Edwu7IApdNq82Ypx8nQZsBsAYV+bmr7z3 Odnkirq3FovSXnhG+8jqFnVf43OE58QZ3Jybu4+W8FI3aQIjJReTUHfh9Hkx/r2nYfJh +2XDl9D/DdO41P+hMKNUai79obsozofL2mbYDlxsq1PAsEEJj9vR6e+teJTZoAaVtkcN uyIoCQwpSXXzQaOgxVJBqrToUI+OIg8Q7Gm6MpCZoAXkdX5df4SGtBOqhhHSjTM7erEr fBHhI3Eocuyv4nz+ZmbNu2TgxWxi/CB3RLghTxUsHy4yET+/2F9GrLnGl5ZyhyL3D/7Y oErA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JcV7sica; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si19793425pfg.173.2017.11.24.01.30.57 for ; Fri, 24 Nov 2017 01:30:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JcV7sica; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752935AbdKXJa4 (ORCPT ); Fri, 24 Nov 2017 04:30:56 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39681 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbdKXJa4 (ORCPT ); Fri, 24 Nov 2017 04:30:56 -0500 Received: by mail-lf0-f66.google.com with SMTP id x76so20102268lfb.6 for ; Fri, 24 Nov 2017 01:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xFL0cCmj3jzdG7ZmbOu+d9yCkniP2YUrU6RBdNJ2KiQ=; b=JcV7sicamyQxrl/Uwd6yEfwcUXHRb+Vx4KuJoNvm0zNyzxUR/UMv8VIx1jES1/C67O JKei4X2utT7TR1xp0zWyH1kidxYdfOvJnszHN7H5g0o8eFw+H7TQm6vGz+ZD9+1BoOXY TJilmDlND5/fA08CJOQiESIh02PGIC/oJO7Ww= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xFL0cCmj3jzdG7ZmbOu+d9yCkniP2YUrU6RBdNJ2KiQ=; b=QQKrlbyJO5hqisODl+LAQdD3CavCqvlvlXFhunWLKJ+9b7RarIgmdCyUExqZIZokyZ NInJzi/yQyItIt9zuPN4qn5V4lF6gvd3f6TanUc4dfRAG1h893Rqa0z94bRfBmC9HoOR 7An/H5K4q5zGbf/LJqA0zhv82CXsPMVxx761xUBFbeCpWsDpmZFOWvwRkEJqzCZbjNXu weyCayln/uTjaKFek1KBc2VTMSdE1nYD9UIEz33wELNth17FPAZe5EPyM8KzXux7zbfG WIFYKZbAP12CpLyd7f7Xd4HVfwB4tLhwHSHQaCPTLGq2sOqNey4Ma67GGC0DN3Cro3UY otkg== X-Gm-Message-State: AJaThX7aGKf9n6+IiJh5k5ITHvRJUmS308e9smaVISpCQgZZ9TVBrzYM jgeV/qFxXSyjuhwNWRXzbyNqHA== X-Received: by 10.46.95.28 with SMTP id t28mr10007120ljb.110.1511515854357; Fri, 24 Nov 2017 01:30:54 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:53 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 3/5] ARM: davinci: Switch DA850EVM to use GPIO descriptors Date: Fri, 24 Nov 2017 10:30:43 +0100 Message-Id: <20171124093045.5961-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org To get rid of the global GPIO numberspace we need to move to using descriptor tables with local offsets on the GPIO chip to reference the GPIO lines used by kernel drivers. This moves the DaVinci DA850EVM board over to using GPIO descriptors for passing GPIOs to the GPIO keys. Signed-off-by: Linus Walleij --- arch/arm/mach-davinci/board-da850-evm.c | 57 ++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index cbde0030c092..3792d760020f 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -404,11 +404,9 @@ static const char * const da850_evm_ui_exp[] = { static struct gpio_keys_button da850_evm_ui_keys[] = { [0 ... DA850_N_UI_PB - 1] = { .type = EV_KEY, - .active_low = 1, .wakeup = 0, .debounce_interval = DA850_KEYS_DEBOUNCE_MS, .code = -1, /* assigned at runtime */ - .gpio = -1, /* assigned at runtime */ .desc = NULL, /* assigned at runtime */ }, }; @@ -427,6 +425,29 @@ static struct platform_device da850_evm_ui_keys_device = { }, }; +static struct gpiod_lookup_table da850_evm_ui_keys_gpios_table = { + .dev_id = "gpio-keys-polled", + .table = { + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB8, + "pb8", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB7, + "pb7", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB6, + "pb6", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB5, + "pb5", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB4, + "pb4", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB3, + "pb3", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB2, + "pb2", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB1, + "pb1", GPIO_ACTIVE_LOW), + + }, +}; + static void da850_evm_ui_keys_init(unsigned gpio) { int i; @@ -436,8 +457,8 @@ static void da850_evm_ui_keys_init(unsigned gpio) button = &da850_evm_ui_keys[i]; button->code = KEY_F8 - i; button->desc = da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i]; - button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i; } + gpiod_add_lookup_table(&da850_evm_ui_keys_gpios_table); } #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT @@ -572,21 +593,17 @@ static const char * const da850_evm_bb_exp[] = { static struct gpio_keys_button da850_evm_bb_keys[] = { [0] = { .type = EV_KEY, - .active_low = 1, .wakeup = 0, .debounce_interval = DA850_KEYS_DEBOUNCE_MS, .code = KEY_PROG1, .desc = NULL, /* assigned at runtime */ - .gpio = -1, /* assigned at runtime */ }, [1 ... DA850_N_BB_USER_SW] = { .type = EV_SW, - .active_low = 1, .wakeup = 0, .debounce_interval = DA850_KEYS_DEBOUNCE_MS, .code = -1, /* assigned at runtime */ .desc = NULL, /* assigned at runtime */ - .gpio = -1, /* assigned at runtime */ }, }; @@ -604,6 +621,30 @@ static struct platform_device da850_evm_bb_keys_device = { }, }; +static struct gpiod_lookup_table da850_evm_bb_keys_gpios_table = { + .dev_id = "gpio-keys-polled", + .table = { + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_PB1, + "user_pb1", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW1, + "user_sw1", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW2, + "user_sw2", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW3, + "user_sw3", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW4, + "user_sw4", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW5, + "user_sw5", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW6, + "user_sw6", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW7, + "user_sw7", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW8, + "user_sw8", GPIO_ACTIVE_LOW), + }, +}; + static void da850_evm_bb_keys_init(unsigned gpio) { int i; @@ -617,8 +658,8 @@ static void da850_evm_bb_keys_init(unsigned gpio) button = &da850_evm_bb_keys[i + 1]; button->code = SW_LID + i; button->desc = da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i]; - button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i; } + gpiod_add_lookup_table(&da850_evm_bb_keys_gpios_table); } #define DA850_N_BB_USER_LED 2 From patchwork Fri Nov 24 09:30:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 119563 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1952329qgn; Fri, 24 Nov 2017 01:30:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMZnW8czIhp90wOTnUoEFgv6kBG83EphFs3P/PleCVuqpyysnCQ/C/P6LzMI8xoun+VXXhiU X-Received: by 10.101.97.129 with SMTP id c1mr12747940pgv.223.1511515859709; Fri, 24 Nov 2017 01:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511515859; cv=none; d=google.com; s=arc-20160816; b=txUDu8Ho/Ofi6vI4K4lebmmF1M//0DADOlZeWev2rtRjTUhLqbPIYhgfZfwHhTl4LS 1e3Ecpoit+rk0WHkqg/bj0PU/EOPPdWrCJSEouyD2bH9Q5Njz2tp6ChpBYOIphCDTTMF zDRgR69olkqdRWQ5LnhO1YVIypJq+KJZswAlMWmH5VTWhS+30aUO5h9wTWoRod6PvDQD +VPpjwepTWH+Q922g8nICT/3rVxOutB/prh3G3h9KhbS4S0h1c/w23qli+dVyz7lE+2B +XfwXwvMewyTb66hdl8u2ywXAqlFzMQJ2QHa3Jifyq0ZsWiBfsOzuhzKhGqpFd5UCLT6 a3BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3xZE+c/iKsg+ogfXDgWfboY64n+Oj6WHwftvxdEUUd0=; b=xJaGDLD6p84Q2iLabVDB1GdLMVfJf7Qegnl71GkgcCG6WpTM3Tk6Hq30tRdtTKPaAf y4zpoFf4wrcFzXq0zHSygbwzlL6VxNVeSOklUig7vwPTbx9OdAjzxokb9Kpqpaj6HRca ZX/KJJR+llWTjATWz8Z7raDWDKTlt82XkJR3zRhiLpYxsHZ1MZ8EAuhq0cG6i4QpGSoM CA8mflMM9m3WmVohHHtaRi+64E0m0JVeUNX2ChMqE0Qu1RbzRiMOjk0lBuFBvziCfgTo F/JkwO+TFOQGwlT7pxJvQ1anOoYgUoXeh2C6H7cVg9XpNkIEsxpnlx3+oL5ey9kBfJOV bL0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NM80WJlT; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si19793425pfg.173.2017.11.24.01.30.59 for ; Fri, 24 Nov 2017 01:30:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NM80WJlT; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752955AbdKXJa6 (ORCPT ); Fri, 24 Nov 2017 04:30:58 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:43072 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752897AbdKXJa5 (ORCPT ); Fri, 24 Nov 2017 04:30:57 -0500 Received: by mail-lf0-f67.google.com with SMTP id 73so24709412lfu.10 for ; Fri, 24 Nov 2017 01:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FfCbL7POz2zTVSA27EZCFb4JYkm59xgZeWdYnwsfK6I=; b=NM80WJlTMnTFTzwL/a64VfAqTDuQ0YCQlvTQSrnxhgW0zWUb4AeelvO8Gl4wGNEum4 o+3XDRyF5IdWAJZVY+EfPU3HOayyDYv1kC82cOKHkn9S++oqmHaMVIbrYj93Ll8in9L9 Ulv8CnAPtaCP5batWbT+lPunCGg9Je4aIYDew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FfCbL7POz2zTVSA27EZCFb4JYkm59xgZeWdYnwsfK6I=; b=N8oGCX54VHJpf3FgMMXfHaUYg/PtUt89I39oUrtNgoa13tKnEZ3MlfJvJnhCbV3LKJ BNl0DAqrK2T9Z6OCG0xdqidzcVBudFuQA1aLDcCKCNWI0ScNBS8S5zqCuGJgKrQZJwbH n7QsKNMZZExgyj5MyVslBy/nFc45CNf42SjU3uJIolBbqvYx4XgR167C+mhw7/2GVWFH eZ6XCUDHUCfrPbRR1Fp8+9H75+i/IiCjnOe0FcNRXDMQL8WO9I9E6c8bU/bWEV29q0Pg tmh2CBsUPBBhL8vafuBEFnpyY/I/IQVs2LU5NnMW8kx8wQaG0Ht1To7ygQ/D9D0+FNEM /yBg== X-Gm-Message-State: AJaThX4r/9JMIr/SXTKYDam9sptjTCNGxbZUc1Ui4U31mhEE21KlKPrD 8Dhcf2UzB+YezmDiAaTUkIp55kCiLzI= X-Received: by 10.46.9.14 with SMTP id 14mr7460706ljj.175.1511515856013; Fri, 24 Nov 2017 01:30:56 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:55 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 4/5] ARM: imx: Give all GPIO chips a unique name Date: Fri, 24 Nov 2017 10:30:44 +0100 Message-Id: <20171124093045.5961-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The name/label of the GPIO chips is used in GPIO lookup tables so these need to be unique per chip. Suffix each GPIO chip with an instance number so these lookups will work as expected. Signed-off-by: Linus Walleij --- arch/arm/mach-imx/mm-imx21.c | 12 ++++++------ arch/arm/mach-imx/mm-imx27.c | 12 ++++++------ arch/arm/mach-imx/mm-imx3.c | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c index 2e91ab2ca378..9e7ec6f17d01 100644 --- a/arch/arm/mach-imx/mm-imx21.c +++ b/arch/arm/mach-imx/mm-imx21.c @@ -84,12 +84,12 @@ void __init imx21_soc_init(void) mxc_arch_reset_init(MX21_IO_ADDRESS(MX21_WDOG_BASE_ADDR)); mxc_device_init(); - mxc_register_gpio("imx21-gpio", 0, MX21_GPIO1_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 1, MX21_GPIO2_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 2, MX21_GPIO3_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 3, MX21_GPIO4_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 4, MX21_GPIO5_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-0", 0, MX21_GPIO1_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-1", 1, MX21_GPIO2_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-2", 2, MX21_GPIO3_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-3", 3, MX21_GPIO4_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-4", 4, MX21_GPIO5_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-5", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); pinctrl_provide_dummies(); imx_add_imx_dma("imx21-dma", MX21_DMA_BASE_ADDR, diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c index 862b9b7762c7..e2eb5dec659e 100644 --- a/arch/arm/mach-imx/mm-imx27.c +++ b/arch/arm/mach-imx/mm-imx27.c @@ -85,12 +85,12 @@ void __init imx27_soc_init(void) mxc_device_init(); /* i.mx27 has the i.mx21 type gpio */ - mxc_register_gpio("imx21-gpio", 0, MX27_GPIO1_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 1, MX27_GPIO2_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 2, MX27_GPIO3_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 3, MX27_GPIO4_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 4, MX27_GPIO5_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); - mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-0", 0, MX27_GPIO1_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-1", 1, MX27_GPIO2_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-2", 2, MX27_GPIO3_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-3", 3, MX27_GPIO4_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-4", 4, MX27_GPIO5_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); + mxc_register_gpio("imx21-gpio-5", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); pinctrl_provide_dummies(); imx_add_imx_dma("imx27-dma", MX27_DMA_BASE_ADDR, diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c index 7638a35b3b36..9568300f7554 100644 --- a/arch/arm/mach-imx/mm-imx3.c +++ b/arch/arm/mach-imx/mm-imx3.c @@ -188,9 +188,9 @@ void __init imx31_soc_init(void) mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR)); mxc_device_init(); - mxc_register_gpio("imx31-gpio", 0, MX31_GPIO1_BASE_ADDR, SZ_16K, MX31_INT_GPIO1, 0); - mxc_register_gpio("imx31-gpio", 1, MX31_GPIO2_BASE_ADDR, SZ_16K, MX31_INT_GPIO2, 0); - mxc_register_gpio("imx31-gpio", 2, MX31_GPIO3_BASE_ADDR, SZ_16K, MX31_INT_GPIO3, 0); + mxc_register_gpio("imx31-gpio-0", 0, MX31_GPIO1_BASE_ADDR, SZ_16K, MX31_INT_GPIO1, 0); + mxc_register_gpio("imx31-gpio-1", 1, MX31_GPIO2_BASE_ADDR, SZ_16K, MX31_INT_GPIO2, 0); + mxc_register_gpio("imx31-gpio-2", 2, MX31_GPIO3_BASE_ADDR, SZ_16K, MX31_INT_GPIO3, 0); pinctrl_provide_dummies(); @@ -298,9 +298,9 @@ void __init imx35_soc_init(void) mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR)); mxc_device_init(); - mxc_register_gpio("imx35-gpio", 0, MX35_GPIO1_BASE_ADDR, SZ_16K, MX35_INT_GPIO1, 0); - mxc_register_gpio("imx35-gpio", 1, MX35_GPIO2_BASE_ADDR, SZ_16K, MX35_INT_GPIO2, 0); - mxc_register_gpio("imx35-gpio", 2, MX35_GPIO3_BASE_ADDR, SZ_16K, MX35_INT_GPIO3, 0); + mxc_register_gpio("imx35-gpio-0", 0, MX35_GPIO1_BASE_ADDR, SZ_16K, MX35_INT_GPIO1, 0); + mxc_register_gpio("imx35-gpio-1", 1, MX35_GPIO2_BASE_ADDR, SZ_16K, MX35_INT_GPIO2, 0); + mxc_register_gpio("imx35-gpio-2", 2, MX35_GPIO3_BASE_ADDR, SZ_16K, MX35_INT_GPIO3, 0); pinctrl_provide_dummies(); if (to_version == 1) { From patchwork Fri Nov 24 09:30:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 119564 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1952373qgn; Fri, 24 Nov 2017 01:31:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMZAbkpSaO6flWAxXNXO/EMFxzm2EBgobc/hcBh1voGqt5e9erYqbNFBtiJQMHhGWCUUkkWp X-Received: by 10.159.231.2 with SMTP id w2mr27831456plq.286.1511515862141; Fri, 24 Nov 2017 01:31:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511515862; cv=none; d=google.com; s=arc-20160816; b=Dt0EBuOs94ZBQePk4Qn9QOWU6HxhE6+CemfFYSOmF53t/5ry6W9FeHV7VVtn8rbILU d9zD17lAx7kNq+kYvMDYR139UrEZkhfLPPDo154asxU8om7tchM3DsJA8PuRQl7ANUl+ Rn5hH9lHXFUPElqh8+UUrLXSlmu5ua/MWsZjXaxlMy87P2slDbpg4CPZ2EpyyC57hQ1Y Xpm0godfQ6nMC0REuZIt1v3yQN3J4DAbPA3FGOEhtGxGK9WU97denUboCO+9bN5UgCIn tuo9PemgGadelsaQh7VwFtks0vM8SbkhZBIACLECe1VcuiORke+5OrQAzLHzHhfnu+ar Srcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=U+ipJZwb6cQx6Hmh23rM0hG8LtJHRZh6XjWRMd+NGC4=; b=EonbIcmPm2EO1iBGhuyMlDec/32O5fRR6kRcY7+scRbJaS2wgYJVKjGA+ED2n5dagn 50yi2KKQ5QXC73RhybL48nLpUAjIwrHnmHOh+lXhtkBjzifoyqnLbAZ5B9rfa00RzKxX T7Qhn3cSA9hK28aKkXe4OI77QF7jVtd2jzqyAxHg6u4klldeNbEN7vhh6Yk2QNZOIHyc jQ9A8iCB8z/erK3TEL3TWwBISeHCoHszUQLDINGuGDRVA3+/P5YNM+8VNAtZ+tmUbWYy YgWqear8jpg4UFZd4n7XV2rXySMFqr/DyVh6S1ctZj/M0dFDlORSWRoBJJZnziPLqdqw JaUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RTavoLep; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si19793425pfg.173.2017.11.24.01.31.02 for ; Fri, 24 Nov 2017 01:31:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RTavoLep; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753010AbdKXJbB (ORCPT ); Fri, 24 Nov 2017 04:31:01 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:39691 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753004AbdKXJa7 (ORCPT ); Fri, 24 Nov 2017 04:30:59 -0500 Received: by mail-lf0-f67.google.com with SMTP id x76so20102465lfb.6 for ; Fri, 24 Nov 2017 01:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uWr10+NzL1BqSwGiDT41HpkblX7lII/QBqSLImqAID4=; b=RTavoLepnGb5l23gl5Vkv1hWkd5fs8tqE43a6I+JHfZgm4ezq2P0lTpnI6K0BQioTu vWFWaxJHlByE3AEM1qay7HqUqPHqaowbono3h1FTPTIFVMbu9G39XgW5YBwLa/PjYz5m Qg4cRrhEbTMSgVnz7mO1ICSjcZjuGmtEcVd10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uWr10+NzL1BqSwGiDT41HpkblX7lII/QBqSLImqAID4=; b=GF/bA213w0wJqSX/kgq/92exHehUy6TOZo2D1vM/7Bg44/F9Y5q6rvCsKT/eCwI33e sLBNxIoHR3EZR42pTHyEQgp+rx90QMr52D/QFcVEdRTc9ByxfwFaG3Syb3qgV+j39X04 TMQKtlekINTtA6kAZQ3YJBnrvLiemwqVTeqx+b6G6ucvGLErpxUY0pTZup9m+8MUq4++ 5f5GrYbRakE3cfBgqxEqUivQYCD4OGA29XcarjCsTJxNYpbpT/L2Gzgk052u2I3P82mr y5f/wIp+39/Jsw1/haWbYNRrbTa/ZEN6KrHeJ8rQBJ8CMpd/imZpE4Zk8HJxDavBAbV8 DVuQ== X-Gm-Message-State: AJaThX6V3VOdySUDjFWojt9v8lKaCLSslyhsEg3ODY7JTvfO+ToY6rXJ wx+xbQNcbmB/1s2gH55buAbs9g== X-Received: by 10.46.91.79 with SMTP id p76mr11005006ljb.22.1511515857773; Fri, 24 Nov 2017 01:30:57 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:57 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij , Marc Reilly Subject: [PATCH 5/5] ARM: imx: Use GPIO descriptors for gpio_keys Date: Fri, 24 Nov 2017 10:30:45 +0100 Message-Id: <20171124093045.5961-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This switches all relevant i.MX boards still using boardfiles to using GPIO descriptors to look up the GPIO lines for gpio_keys. Most conversions were straight-forward, I dropped comments on how the offsets are looked up where appropriate. The VPR200 board was seemingly incorrect. It assigned the members of struct gpio_keys_button with the direct, non-C99 syntax like so: #define VPR_KEY_DEBOUNCE 500 static struct gpio_keys_button vpr200_gpio_keys_table[] = { {KEY_F2, GPIO_BUTTON1, 1, "vpr-keys: F2", 0, VPR_KEY_DEBOUNCE}, {KEY_F3, GPIO_BUTTON2, 1, "vpr-keys: F3", 0, VPR_KEY_DEBOUNCE}, (...) This is confusing as it seems to have been wrong already when the patch was merged. The members are assigned in order: struct gpio_keys_button { unsigned int code; int gpio; int active_low; const char *desc; unsigned int type; int wakeup; int debounce_interval; bool can_disable; (...) Meaning KEY_XX, GPIO_BUTTON1, 1, "key name", type us right, then comes wakeup capability and this should be 0 or 1, but is instead assigned VPR_KEY_DEBOUNCE which is 500. I have corrected the code to do what I think the author intended. I consider this a non-critical fix because I bet it works (or the board is completely unused), but add the fixing tag for reference. Cc: Marc Reilly Fixes: 00c89c1d1831 ("Introduce VPR200 board.") Signed-off-by: Linus Walleij --- arch/arm/mach-imx/mach-armadillo5x0.c | 19 ++++-- arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 26 ++++++-- arch/arm/mach-imx/mach-pcm037_eet.c | 52 +++++++++++---- arch/arm/mach-imx/mach-vpr200.c | 99 ++++++++++++++++++++++++----- 4 files changed, 155 insertions(+), 41 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-imx/mach-armadillo5x0.c b/arch/arm/mach-imx/mach-armadillo5x0.c index 17a97ba2cecf..829a252eaa2a 100644 --- a/arch/arm/mach-imx/mach-armadillo5x0.c +++ b/arch/arm/mach-imx/mach-armadillo5x0.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -265,14 +266,10 @@ static struct i2c_board_info armadillo5x0_i2c_rtc = { static struct gpio_keys_button armadillo5x0_buttons[] = { { .code = KEY_ENTER, /*28*/ - .gpio = IOMUX_TO_GPIO(MX31_PIN_SCLK0), - .active_low = 1, .desc = "menu", .wakeup = 1, }, { .code = KEY_BACK, /*158*/ - .gpio = IOMUX_TO_GPIO(MX31_PIN_SRST0), - .active_low = 1, .desc = "back", .wakeup = 1, } @@ -284,6 +281,19 @@ static const struct gpio_keys_platform_data .nbuttons = ARRAY_SIZE(armadillo5x0_buttons), }; +static struct gpiod_lookup_table armadillo5x0_buttons_gpios_table = { + .dev_id = "gpio-keys", + .table = { + /* + * These are GPIOs M31_PIN_SCLK0 and MX31_PIN_SRSR0, + * global GPIO numbers 66 and 67, with 32 GPIOs per chip + * these are chip 2 offsets 2 and 3 + */ + GPIO_LOOKUP("imx31-gpio-2", 2, "menu", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx31-gpio-2", 3, "back", GPIO_ACTIVE_LOW), + }, +}; + /* * NAND Flash */ @@ -525,6 +535,7 @@ static void __init armadillo5x0_late(void) gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0)); platform_add_devices(devices, ARRAY_SIZE(devices)); + gpiod_add_lookup_table(&armadillo5x0_buttons_gpios_table); imx_add_gpio_keys(&armadillo5x0_button_data); /* SMSC9118 IRQ pin */ diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c index 5169dfba9718..97c6e163ef36 100644 --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -274,25 +275,19 @@ static struct gpio_keys_button visstrim_gpio_keys[] = { { .type = EV_KEY, .code = KEY_RESTART, - .gpio = (GPIO_PORTC + 15), .desc = "Default config", - .active_low = 0, .wakeup = 1, }, { .type = EV_KEY, .code = KEY_RECORD, - .gpio = (GPIO_PORTF + 14), .desc = "Record", - .active_low = 0, .wakeup = 1, }, { .type = EV_KEY, .code = KEY_STOP, - .gpio = (GPIO_PORTF + 13), .desc = "Stop", - .active_low = 0, .wakeup = 1, } }; @@ -303,6 +298,24 @@ static const struct gpio_keys_platform_data .nbuttons = ARRAY_SIZE(visstrim_gpio_keys), }; +static struct gpiod_lookup_table visstrim_gpio_keys_gpios_table = { + .dev_id = "gpio-keys", + .table = { + /* + * These keys are on "PORT E" offset 15 and "PORT F" + * offsets 14 and 13. This corresponds to imx21-gpio-4 + * and imx21-gpio-5, as this SoC has the i.MX21 GPIO + * block. + */ + GPIO_LOOKUP("imx21-gpio-4", 15, "Default config", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx21-gpio-5", 14, "Record", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx21-gpio-5", 13, "Stop", + GPIO_ACTIVE_HIGH), + }, +}; + /* led */ static const struct gpio_led visstrim_m10_leds[] __initconst = { { @@ -563,6 +576,7 @@ static void __init visstrim_m10_late_init(void) if (ret) pr_err("Failed to request gpios (%d)\n", ret); + gpiod_add_lookup_table(&visstrim_gpio_keys_gpios_table); imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); imx_add_platform_device("mx27vis", 0, NULL, 0, &snd_mx27vis_pdata, diff --git a/arch/arm/mach-imx/mach-pcm037_eet.c b/arch/arm/mach-imx/mach-pcm037_eet.c index 95bd97710494..9b3d0246ed63 100644 --- a/arch/arm/mach-imx/mach-pcm037_eet.c +++ b/arch/arm/mach-imx/mach-pcm037_eet.c @@ -7,6 +7,7 @@ * published by the Free Software Foundation. */ #include +#include #include #include #include @@ -68,85 +69,71 @@ static struct gpio_keys_button pcm037_gpio_keys[] = { { .type = EV_KEY, .code = KEY_L, - .gpio = 0, .desc = "Wheel Manual", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_A, - .gpio = 1, .desc = "Wheel AF", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_V, - .gpio = 2, .desc = "Wheel View", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_M, - .gpio = 3, .desc = "Wheel Menu", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_UP, - .gpio = 32, .desc = "Nav Pad Up", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_RIGHT, - .gpio = 33, .desc = "Nav Pad Right", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_DOWN, - .gpio = 34, .desc = "Nav Pad Down", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_LEFT, - .gpio = 35, .desc = "Nav Pad Left", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_ENTER, - .gpio = 38, .desc = "Nav Pad Ok", .wakeup = 0, }, { .type = EV_KEY, .code = KEY_O, - .gpio = 39, .desc = "Wheel Off", .wakeup = 0, }, { .type = EV_KEY, .code = BTN_FORWARD, - .gpio = 50, .desc = "Focus Forward", .wakeup = 0, }, { .type = EV_KEY, .code = BTN_BACK, - .gpio = 51, .desc = "Focus Backward", .wakeup = 0, }, { .type = EV_KEY, .code = BTN_MIDDLE, - .gpio = 52, .desc = "Release Half", .wakeup = 0, }, { .type = EV_KEY, .code = BTN_EXTRA, - .gpio = 53, .desc = "Release Full", .wakeup = 0, }, @@ -159,6 +146,42 @@ static const struct gpio_keys_platform_data .rep = 0, /* No auto-repeat */ }; +static struct gpiod_lookup_table pcm037_gpio_keys_gpios_table = { + .dev_id = "gpio-keys", + .table = { + /* These are on the first GPIO chip */ + GPIO_LOOKUP("imx31-gpio-0", 0, "Wheel Manual", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-0", 1, "Wheel AF", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-0", 2, "Wheel View", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-0", 3, "Wheel Menu", + GPIO_ACTIVE_HIGH), + /* GPIOs 32..62 are simply offsets 0..31 on chip 1 */ + GPIO_LOOKUP("imx31-gpio-1", 0, "Nav Pad Up", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 1, "Nav Pad Right", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 2, "Nav Pad Down", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 3, "Nav Pad Left", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 6, "Nav Pad Ok", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 7, "Wheel Off", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 18, "Focus Forward", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 19, "Focus Backward", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 20, "Release Half", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("imx31-gpio-1", 21, "Release Full", + GPIO_ACTIVE_HIGH), + }, +}; + int __init pcm037_eet_init_devices(void) { if (pcm037_variant() != PCM037_EET) @@ -171,6 +194,7 @@ int __init pcm037_eet_init_devices(void) spi_register_board_info(pcm037_spi_dev, ARRAY_SIZE(pcm037_spi_dev)); imx31_add_spi_imx0(&pcm037_spi1_pdata); + gpiod_add_lookup_table(&pcm037_gpio_keys_gpios_table); imx_add_gpio_keys(&pcm037_gpio_keys_platform_data); return 0; diff --git a/arch/arm/mach-imx/mach-vpr200.c b/arch/arm/mach-imx/mach-vpr200.c index 5ff154c9a086..e8ca1a7b55fc 100644 --- a/arch/arm/mach-imx/mach-vpr200.c +++ b/arch/arm/mach-imx/mach-vpr200.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -41,15 +42,6 @@ #define GPIO_LCDPWR IMX_GPIO_NR(1, 2) #define GPIO_PMIC_INT IMX_GPIO_NR(2, 0) -#define GPIO_BUTTON1 IMX_GPIO_NR(1, 4) -#define GPIO_BUTTON2 IMX_GPIO_NR(1, 5) -#define GPIO_BUTTON3 IMX_GPIO_NR(1, 7) -#define GPIO_BUTTON4 IMX_GPIO_NR(1, 8) -#define GPIO_BUTTON5 IMX_GPIO_NR(1, 9) -#define GPIO_BUTTON6 IMX_GPIO_NR(1, 10) -#define GPIO_BUTTON7 IMX_GPIO_NR(1, 11) -#define GPIO_BUTTON8 IMX_GPIO_NR(1, 12) - static const struct fb_videomode fb_modedb[] = { { /* 800x480 @ 60 Hz */ @@ -119,16 +111,66 @@ static const struct mxc_nand_platform_data .flash_bbt = 1, }; +#define GPIO_BUTTON1 IMX_GPIO_NR(1, 4) +#define GPIO_BUTTON2 IMX_GPIO_NR(1, 5) +#define GPIO_BUTTON3 IMX_GPIO_NR(1, 7) +#define GPIO_BUTTON4 IMX_GPIO_NR(1, 8) +#define GPIO_BUTTON5 IMX_GPIO_NR(1, 9) +#define GPIO_BUTTON6 IMX_GPIO_NR(1, 10) +#define GPIO_BUTTON7 IMX_GPIO_NR(1, 11) +#define GPIO_BUTTON8 IMX_GPIO_NR(1, 12) + + #define VPR_KEY_DEBOUNCE 500 static struct gpio_keys_button vpr200_gpio_keys_table[] = { - {KEY_F2, GPIO_BUTTON1, 1, "vpr-keys: F2", 0, VPR_KEY_DEBOUNCE}, - {KEY_F3, GPIO_BUTTON2, 1, "vpr-keys: F3", 0, VPR_KEY_DEBOUNCE}, - {KEY_F4, GPIO_BUTTON3, 1, "vpr-keys: F4", 0, VPR_KEY_DEBOUNCE}, - {KEY_F5, GPIO_BUTTON4, 1, "vpr-keys: F5", 0, VPR_KEY_DEBOUNCE}, - {KEY_F6, GPIO_BUTTON5, 1, "vpr-keys: F6", 0, VPR_KEY_DEBOUNCE}, - {KEY_F7, GPIO_BUTTON6, 1, "vpr-keys: F7", 0, VPR_KEY_DEBOUNCE}, - {KEY_F8, GPIO_BUTTON7, 1, "vpr-keys: F8", 1, VPR_KEY_DEBOUNCE}, - {KEY_F9, GPIO_BUTTON8, 1, "vpr-keys: F9", 1, VPR_KEY_DEBOUNCE}, + { + .code = KEY_F2, + .desc = "vpr-keys: F2", + .type = 0, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F3, + .desc = "vpr-keys: F3", + .type = 0, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F4, + .desc = "vpr-keys: F4", + .type = 0, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F5, + .desc = "vpr-keys: F5", + .type = 0, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F6, + .desc = "vpr-keys: F6", + .type = 0, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F7, + .desc = "vpr-keys: F7", + .type = 0, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F8, + .desc = "vpr-keys: F8", + .type = 1, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, + { + .code = KEY_F9, + .desc = "vpr-keys: F9", + .type = 1, + .debounce_interval = VPR_KEY_DEBOUNCE, + }, }; static const struct gpio_keys_platform_data @@ -137,6 +179,28 @@ static const struct gpio_keys_platform_data .nbuttons = ARRAY_SIZE(vpr200_gpio_keys_table), }; +static struct gpiod_lookup_table vpr200_gpio_keys_gpios_table = { + .dev_id = "gpio-keys", + .table = { + GPIO_LOOKUP("imx35-gpio-0", 4, "vpr-keys: F2", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 5, "vpr-keys: F3", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 7, "vpr-keys: F4", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 8, "vpr-keys: F5", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 9, "vpr-keys: F6", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 10, "vpr-keys: F7", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 11, "vpr-keys: F8", + GPIO_ACTIVE_LOW), + GPIO_LOOKUP("imx35-gpio-0", 12, "vpr-keys: F9", + GPIO_ACTIVE_LOW), + }, +}; + static struct mc13xxx_platform_data vpr200_pmic = { .flags = MC13XXX_USE_ADC | MC13XXX_USE_TOUCHSCREEN, }; @@ -284,6 +348,7 @@ static void __init vpr200_board_init(void) static void __init vpr200_late_init(void) { + gpiod_add_lookup_table(&vpr200_gpio_keys_gpios_table); imx_add_gpio_keys(&vpr200_gpio_keys_data); platform_add_devices(devices, ARRAY_SIZE(devices));