From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 29 Nov 2013 17:10:38 +0100 (CET) Received: from mail-ea0-f178.google.com ([209.85.215.178]:33277 "EHLO mail-ea0-f178.google.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S6867276Ab3K2QKMguYxj (ORCPT ); Fri, 29 Nov 2013 17:10:12 +0100 Received: by mail-ea0-f178.google.com with SMTP id d10so7146152eaj.9 for ; Fri, 29 Nov 2013 08:10:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=edBdK/AE3I/LT+lz53zSn5uOpu5lAUvcw8N/24AYdCg=; b=qQW1Bc8xuiuFa6QTfjeSMNy18P2Lw5WKiGr7/rpsFlKNvoCtVojnbAK4dSOCKChC1f +1Af0GvPknU4Rv392qrhdrlCczweWKkEwDoH8YDJI0BpEmC4mushPLnird5/y8PE+xv6 /3tYl/xrGR6bpEt5QxiA6gwjhhPVpP5cAee95IdViD0yaq0849G6Xuv9y66mtZcyv1XJ OgmZ+0eCigVuB0W9/DZYQ5qZaRTWSQYTySFwsoTf7U8Wt18Fh9Q7SUwQqbI5iDTyt7Vc /aJDoj/fc8CHki39sfdgQLCQECwHBw8x/xzxPJqXWKXhFcPrLKaxILp4O+ADbZLF15jF v05w== X-Received: by 10.14.179.130 with SMTP id h2mr20995432eem.34.1385741407301; Fri, 29 Nov 2013 08:10:07 -0800 (PST) Received: from linux-samsung700g7a.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPSA id m1sm36346284eeg.0.2013.11.29.08.10.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2013 08:10:06 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: linux-mips@linux-mips.org, Ralf Baechle Cc: Hauke Mehrtens , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V2 2/2] MIPS: BCM47XX: Prepare support for GPIO buttons Date: Fri, 29 Nov 2013 17:09:57 +0100 Message-Id: <1385741397-32740-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1385741397-32740-1-git-send-email-zajec5@gmail.com> References: <1385741397-32740-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 38601 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: zajec5@gmail.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips So far this adds support for one Netgear model only, but it's designed and ready to add many more device. We could hopefully import database from OpenWrt. Support for SSB is currently disabled, because SSB doesn't implement IRQ domain yet. Signed-off-by: Rafał Miłecki --- arch/mips/bcm47xx/Makefile | 2 +- arch/mips/bcm47xx/bcm47xx_private.h | 3 ++ arch/mips/bcm47xx/buttons.c | 81 +++++++++++++++++++++++++++++++++++ arch/mips/bcm47xx/setup.c | 1 + 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 arch/mips/bcm47xx/buttons.c diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile index 84e9aed..006a05e 100644 --- a/arch/mips/bcm47xx/Makefile +++ b/arch/mips/bcm47xx/Makefile @@ -4,5 +4,5 @@ # obj-y += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o -obj-y += board.o leds.o +obj-y += board.o buttons.o leds.o obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o diff --git a/arch/mips/bcm47xx/bcm47xx_private.h b/arch/mips/bcm47xx/bcm47xx_private.h index 1a1e600..5c94ace 100644 --- a/arch/mips/bcm47xx/bcm47xx_private.h +++ b/arch/mips/bcm47xx/bcm47xx_private.h @@ -3,6 +3,9 @@ #include +/* buttons.c */ +int __init bcm47xx_buttons_register(void); + /* leds.c */ void __init bcm47xx_leds_register(void); diff --git a/arch/mips/bcm47xx/buttons.c b/arch/mips/bcm47xx/buttons.c new file mode 100644 index 0000000..ecd6b1b --- /dev/null +++ b/arch/mips/bcm47xx/buttons.c @@ -0,0 +1,81 @@ +#include "bcm47xx_private.h" + +#include +#include +#include +#include +#include +#include + +struct input_dev *input; + +/************************************************** + * Database + **************************************************/ + +static struct gpio_keys_button +bcm47xx_buttons_netgear_wndr4500_v1[] = { + { + .code = KEY_WPS_BUTTON, + .gpio = 4, + .active_low = 1, + }, + { + .code = KEY_RFKILL, + .gpio = 5, + .active_low = 1, + }, + { + .code = KEY_RESTART, + .gpio = 6, + .active_low = 1, + }, +}; + +/************************************************** + * Init + **************************************************/ + +static struct gpio_keys_platform_data bcm47xx_button_pdata; + +static struct platform_device bcm47xx_buttons_gpio_keys = { + .name = "gpio-keys", + .dev = { + .platform_data = &bcm47xx_button_pdata, + } +}; + +#define bcm47xx_set_bdata(dev_buttons) do { \ + bcm47xx_button_pdata.buttons = dev_buttons; \ + bcm47xx_button_pdata.nbuttons = ARRAY_SIZE(dev_buttons); \ +} while (0) + +int __init bcm47xx_buttons_register(void) +{ + enum bcm47xx_board board = bcm47xx_board_get(); + int err; + +#ifdef CONFIG_BCM47XX_SSB + if (bcm47xx_bus_type == BCM47XX_BUS_TYPE_SSB) { + pr_debug("Buttons on SSB are not supported yet.\n"); + return -ENOTSUPP; + } +#endif + + switch (board) { + case BCM47XX_BOARD_NETGEAR_WNDR4500V1: + bcm47xx_set_bdata(bcm47xx_buttons_netgear_wndr4500_v1); + break; + default: + pr_debug("No buttons configuration found for this device\n"); + return -ENOTSUPP; + } + + err = platform_device_register(&bcm47xx_buttons_gpio_keys); + if (err) { + pr_err("Failed to register platform device: %d\n", err); + return err; + } + + return 0; +} diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index 7e61c0b..a791124 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c @@ -242,6 +242,7 @@ static int __init bcm47xx_register_bus_complete(void) #endif } + bcm47xx_buttons_register(); bcm47xx_leds_register(); return 0; -- 1.7.10.4