From patchwork Fri Nov 1 11:33:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 1187925 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 474KpB030Pz9s4Y for ; Fri, 1 Nov 2019 22:33:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729811AbfKALdx (ORCPT ); Fri, 1 Nov 2019 07:33:53 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44340 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbfKALdx (ORCPT ); Fri, 1 Nov 2019 07:33:53 -0400 Received: by mail-lj1-f194.google.com with SMTP id g3so3804664ljl.11; Fri, 01 Nov 2019 04:33:51 -0700 (PDT) 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=Vrqlo3hyO170NOon6HiWMgUQFYqrMhoyqTxgOzANokA=; b=jSYUTQCjwNJtMs8SRatnU7Lf19yM5wkXwAzCdiZYHHPdycq2tZKmYaDo37kPJgobNY JbRFwehk8KXaGDEVtqWdMStFXSV6kgQccrvPkxqnh3yCHcm6cuTh/ky67VryU/mjWxJh wNYJ58UIUsYe/aS9x4EUkQxbzHw1/kZ3bGFOjrpplB3ZnojLsE8/Ms1cIZjMRVQ39FBC 2S0TGfaoSG+O59bDGUQ1//rWB+pE5ygIrdkpX0/Er3e0Ag0Yh/6Dg153WaKn0U8x+Omf eMFHEJ48EXvp5KJ1xIb8GFwQ0OVG1l8Dnfz/ndNnuJ7vArePRdZtcZNj5QqNnGUxPqkR Fhjg== X-Gm-Message-State: APjAAAV9RHbd9HXXVcAADhfa17wZ2b35eZBSP9X0a5axyjubylon29jU /l2UQplcGDZXE2gCGaZB3SI= X-Google-Smtp-Source: APXvYqxR+7n0wR8zSiraCCMwUPMV734zVsH3IAuuV5WMP4wJxH8Nstd+WW3fAkM75n9TNP+qRxF1og== X-Received: by 2002:a2e:9595:: with SMTP id w21mr7944505ljh.181.1572608030359; Fri, 01 Nov 2019 04:33:50 -0700 (PDT) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id r19sm2366685lfi.13.2019.11.01.04.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 04:33:49 -0700 (PDT) Date: Fri, 1 Nov 2019 13:33:38 +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 , Michael Turquette , Stephen Boyd , Linus Walleij , Bartosz Golaszewski , Alessandro Zummo , Alexandre Belloni , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org Subject: [RFC PATCH v3 05/15] 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 --- Changes from v2 - No changes drivers/mfd/rohm-bd71828.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c index b7de79e1fcdb..f77ba1ec3e99 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"), @@ -36,6 +50,10 @@ static struct mfd_cell bd71828_mfd_cells[] = { .name = "bd70528-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,9 +306,19 @@ static int bd71828_i2c_probe(struct i2c_client *i2c, dev_err(&i2c->dev, "Failed to add IRQ chip\n"); return ret; } + 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,