From patchwork Mon Jan 20 06:36:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 1225684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fi.rohmeurope.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 481MR01CZdz9sR1 for ; Mon, 20 Jan 2020 17:37:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725872AbgATGhP (ORCPT ); Mon, 20 Jan 2020 01:37:15 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35227 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgATGhO (ORCPT ); Mon, 20 Jan 2020 01:37:14 -0500 Received: by mail-lf1-f67.google.com with SMTP id z18so1686013lfe.2; Sun, 19 Jan 2020 22:37:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7cLgcPfa6AkaP0nuiBIbdvXYD3ekkNC7oIJfOzgWhL0=; b=c/EqoFexs7+eI5YiZsM6rPv0FiY3Zq3Nx/EzlLDHobBp9m5HvHcK8SVB0ufSuBrdz9 ZguFYkWlzKZEQsE2hAFUnoW3q4M4eUPzKkepm3hnj1D7szWXMfq2eCLmLYcs5SGsPhlo AgQCfwCNZAxZI7kHme0jjsn/cAvlO5yL9ffV72SEfW/Or5h6p6r3CrKoVU/uVIH3mwq+ q1Emh2hAQK+A1l4E5tlwXEs6u7gc0A+hDGVVCTNPFfWEQzC2YY6td0PV8+NkcrJ46YIO YpoTla7lnVYRbcyqKjjBEV2Gwfkh9Snm00V3W0MM61dP2tuKFMZvUo8i/M8avimrHBHu 7TGA== X-Gm-Message-State: APjAAAX+UTVqDdUoD/XG4u4k5M8oyQEjp/oN9r53ugJrIPxOwxrxmvRk ugZlhQdeFXEz/VrcCmJCvvg= X-Google-Smtp-Source: APXvYqw3QkAXxKsWTX94LjDfICIdgaldh7f3RtCvrkYWMOijj2RfSLSrRU9V8JgWjZbfaM3SPRIVww== X-Received: by 2002:a19:c6cd:: with SMTP id w196mr6323406lff.79.1579502231831; Sun, 19 Jan 2020 22:37:11 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id z11sm16258845ljc.97.2020.01.19.22.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jan 2020 22:37:11 -0800 (PST) Date: Mon, 20 Jan 2020 08:36:59 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Jacek Anaszewski , Pavel Machek , Dan Murphy , Rob Herring , Mark Rutland , Lee Jones , Liam Girdwood , Mark Brown , Jonathan Corbet , Michael Turquette , Stephen Boyd , Linus Walleij , Bartosz Golaszewski , Alessandro Zummo , Alexandre Belloni , Greg Kroah-Hartman , Arnd Bergmann , Mauro Carvalho Chehab , Wolfram Sang , Phil Edworthy , Noralf =?iso-8859-1?q?Tr=F8nnes?= , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org Subject: [PATCH v11 06/13] mfd: input: bd71828: Add power-key support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use gpio_keys to send power input-event to user-space when power button (short) press is detected. Signed-off-by: Matti Vaittinen Acked-for-MFD-by: Lee Jones --- No changes since v10 drivers/mfd/rohm-bd71828.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c index 0ec386c9f26b..210261d026f2 100644 --- a/drivers/mfd/rohm-bd71828.c +++ b/drivers/mfd/rohm-bd71828.c @@ -4,7 +4,9 @@ // // ROHM BD71828 PMIC driver +#include #include +#include #include #include #include @@ -15,6 +17,18 @@ #include #include +static struct gpio_keys_button button = { + .code = KEY_POWER, + .gpio = -1, + .type = EV_KEY, +}; + +static struct gpio_keys_platform_data bd71828_powerkey_data = { + .buttons = &button, + .nbuttons = 1, + .name = "bd71828-pwrkey", +}; + static const struct resource rtc_irqs[] = { DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC0, "bd71828-rtc-alm-0"), DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC1, "bd71828-rtc-alm-1"), @@ -35,6 +49,10 @@ static struct mfd_cell bd71828_mfd_cells[] = { .name = "bd71828-rtc", .resources = rtc_irqs, .num_resources = ARRAY_SIZE(rtc_irqs), + }, { + .name = "gpio-keys", + .platform_data = &bd71828_powerkey_data, + .pdata_size = sizeof(bd71828_powerkey_data), }, }; @@ -288,6 +306,14 @@ static int bd71828_i2c_probe(struct i2c_client *i2c) dev_dbg(&i2c->dev, "Registered %d IRQs for chip\n", bd71828_irq_chip.num_irqs); + ret = regmap_irq_get_virq(irq_data, BD71828_INT_SHORTPUSH); + if (ret < 0) { + dev_err(&i2c->dev, "Failed to get the power-key IRQ\n"); + return ret; + } + + button.irq = ret; + ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, bd71828_mfd_cells, ARRAY_SIZE(bd71828_mfd_cells), NULL, 0,