Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3347798yba; Tue, 23 Apr 2019 02:06:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzN6jNLswYFZWJXFdbxP2NlvFJuaYyiVb0Xy6n/xn70fMKawZOHx3T05IZX194zPDqsdo3D X-Received: by 2002:a63:8f4b:: with SMTP id r11mr23650245pgn.271.1556010406177; Tue, 23 Apr 2019 02:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556010406; cv=none; d=google.com; s=arc-20160816; b=jMRDhJ0+OhsdDxN3g5ATIpd6NaR3dZVU1mFZ7sgcjKgVAde6QPiJXm9v9LYdkEa8kT BsqWx+rWV+TSZQhHtdjqg5aXDbU02zwlQYBJ5hKpbzane/otTJX4PO1UbeFOZck8tvwj Jx01fkkkOOXmIFhc1Qs3UFaCllGyY/t2YXgt/wPtyUy910vys04NGnCx2Q77xe7PBl7X dM8cGxyrA8dq3LVu1c8wtr+M3IBqZKh+DgtvG4LNUTLXoXo5p1QsFYJR7q0QEYSDqVUT XccbmPEiYOkf4l8Spq8Rq8Hq79QhXy93PU86D0YOdFwtdK7vdy81kUKcQpZ2AP1BKAaY SQ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yH8XFskncHoOmFNUeIZORg82y/ikt/RMLTfO1CbkEYI=; b=ZltgBqgguH4fs/d4mMQ9uLmKHorvLsMZVFpC/5h+vdXE+g6kGJp8VNhNaD2UZKOFJF +IPctC+skkWtYeF2KhLKHcKFEyioUSsim4w/MGAApa+cVSBQl3s/w78Z8pYQ2tvx2jjF UPHkOYA90lvIYpfU8fCgxIzcOwpp11ybL57+BuohHn4kDcUKi+FYW+VwkRv/HuekMvbR Y1TGSpJN28TQ8E+xbCYdwAXdCduNqWAn+UKpvuoRcHhJjh9VIETF8/byxcsVHMIO6r6x De6YRxGm5NzZmyhrpjXPf/8ZyFndYz3Qn3uu1gbCwtXGeigrEpJIRvCfVh0Ck/idRas+ EfMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=ECibK3BC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si16321806pfn.30.2019.04.23.02.06.30; Tue, 23 Apr 2019 02:06:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=ECibK3BC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727349AbfDWJFR (ORCPT + 99 others); Tue, 23 Apr 2019 05:05:17 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44509 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727307AbfDWJFP (ORCPT ); Tue, 23 Apr 2019 05:05:15 -0400 Received: by mail-wr1-f67.google.com with SMTP id c5so10300063wrs.11 for ; Tue, 23 Apr 2019 02:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yH8XFskncHoOmFNUeIZORg82y/ikt/RMLTfO1CbkEYI=; b=ECibK3BCeX4EnlUpKpLA68WS9XRL/89tH4dz03sJdoHFffNo0rYOTlt60tz1rJHUGP K/7NVJiJV8QxiwYyZ05R47sYz1FYcxpbbqr60O9Rbzj+LF549T9MSf1DxH2yZnxX7xVb 89DRKiBQRtUgzpoQJaHuUwd3uMWzcv2c54EfuIEZFicqMCAcygA8N3Af5s7MMklscGta GCM5rMlhTBzWPr7oOkeVfH7w9cMqgc8Q7AQNAWTt7prJD3q7MM70iNU0dnO6rVAKd7bS OxuvYov6Bwf5uq16HEpvryWe7lumXAX4iht3ffmHuulwoyhJgjWQnEjDauErvjd1s4/a xhVg== 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:mime-version:content-transfer-encoding; bh=yH8XFskncHoOmFNUeIZORg82y/ikt/RMLTfO1CbkEYI=; b=XapXScGXEexCVIRN1cIxN2A4Dt9mAPmcV3zGO6ll/sR8tVwomTQ67WzT75wO2YR78k /1AfwZYSKl29I8kjF8nkHVe9WJeEHtZQJPFY9/ia3lvQoT/GAQ/nSauc1TqVE5zypwS9 ydN9QlheGYx7dYFvaHe7oznbQzVbCApva/IEcHoXrOUnuJ24Tck2Ozq4ZdX/p2cgjerk lorymqVB/Axnnvrm+YL0xHDbMn2tdf//rjAS4EgBe5OxDxE4a17UEDJp+2kK0Tj8Ikwi vbrKHOYXm6NhGI/aJdR87Z7u1V3ewpadmco/qYTKyzYdMet+mxKmcug0oB/4Lpg68ZHw j+VA== X-Gm-Message-State: APjAAAUjh+c4gHsLSm9KZOaYkx5DJh/dw64eagyX/Z6wIQan5B4Zqgd6 xD0vozJQSepiSwqpgd2Z4h8T2w== X-Received: by 2002:adf:e88b:: with SMTP id d11mr16552204wrm.327.1556010313304; Tue, 23 Apr 2019 02:05:13 -0700 (PDT) Received: from localhost.localdomain (aputeaux-684-1-25-101.w90-86.abo.wanadoo.fr. [90.86.250.101]) by smtp.gmail.com with ESMTPSA id v190sm15360434wme.18.2019.04.23.02.05.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 02:05:12 -0700 (PDT) From: Bartosz Golaszewski To: Rob Herring , Mark Rutland , Linus Walleij , Dmitry Torokhov , Jacek Anaszewski , Pavel Machek , Lee Jones , Sebastian Reichel , Liam Girdwood , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v10 10/11] input: max77650: add onkey support Date: Tue, 23 Apr 2019 11:04:50 +0200 Message-Id: <20190423090451.23711-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423090451.23711-1-brgl@bgdev.pl> References: <20190423090451.23711-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Add support for the push- and slide-button events for max77650. Signed-off-by: Bartosz Golaszewski Acked-by: Dmitry Torokhov Acked-by: Pavel Machek --- drivers/input/misc/Kconfig | 9 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/max77650-onkey.c | 121 ++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 drivers/input/misc/max77650-onkey.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index e15ed1bb8558..85bc675eecd3 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -190,6 +190,15 @@ config INPUT_M68K_BEEP tristate "M68k Beeper support" depends on M68K +config INPUT_MAX77650_ONKEY + tristate "Maxim MAX77650 ONKEY support" + depends on MFD_MAX77650 + help + Support the ONKEY of the MAX77650 PMIC as an input device. + + To compile this driver as a module, choose M here: the module + will be called max77650-onkey. + config INPUT_MAX77693_HAPTIC tristate "MAXIM MAX77693/MAX77843 haptic controller support" depends on (MFD_MAX77693 || MFD_MAX77843) && PWM diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index b936c5b1d4ac..ffd72161c79b 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o +obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o diff --git a/drivers/input/misc/max77650-onkey.c b/drivers/input/misc/max77650-onkey.c new file mode 100644 index 000000000000..fbf6caab7217 --- /dev/null +++ b/drivers/input/misc/max77650-onkey.c @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 BayLibre SAS +// Author: Bartosz Golaszewski +// +// ONKEY driver for MAXIM 77650/77651 charger/power-supply. + +#include +#include +#include +#include +#include +#include +#include + +#define MAX77650_ONKEY_MODE_MASK BIT(3) +#define MAX77650_ONKEY_MODE_PUSH 0x00 +#define MAX77650_ONKEY_MODE_SLIDE BIT(3) + +struct max77650_onkey { + struct input_dev *input; + unsigned int code; +}; + +static irqreturn_t max77650_onkey_falling(int irq, void *data) +{ + struct max77650_onkey *onkey = data; + + input_report_key(onkey->input, onkey->code, 0); + input_sync(onkey->input); + + return IRQ_HANDLED; +} + +static irqreturn_t max77650_onkey_rising(int irq, void *data) +{ + struct max77650_onkey *onkey = data; + + input_report_key(onkey->input, onkey->code, 1); + input_sync(onkey->input); + + return IRQ_HANDLED; +} + +static int max77650_onkey_probe(struct platform_device *pdev) +{ + int irq_r, irq_f, error, mode; + struct max77650_onkey *onkey; + struct device *dev, *parent; + struct regmap *map; + unsigned int type; + + dev = &pdev->dev; + parent = dev->parent; + + map = dev_get_regmap(parent, NULL); + if (!map) + return -ENODEV; + + onkey = devm_kzalloc(dev, sizeof(*onkey), GFP_KERNEL); + if (!onkey) + return -ENOMEM; + + error = device_property_read_u32(dev, "linux,code", &onkey->code); + if (error) + onkey->code = KEY_POWER; + + if (device_property_read_bool(dev, "maxim,onkey-slide")) { + mode = MAX77650_ONKEY_MODE_SLIDE; + type = EV_SW; + } else { + mode = MAX77650_ONKEY_MODE_PUSH; + type = EV_KEY; + } + + error = regmap_update_bits(map, MAX77650_REG_CNFG_GLBL, + MAX77650_ONKEY_MODE_MASK, mode); + if (error) + return error; + + irq_f = platform_get_irq_byname(pdev, "nEN_F"); + if (irq_f < 0) + return irq_f; + + irq_r = platform_get_irq_byname(pdev, "nEN_R"); + if (irq_r < 0) + return irq_r; + + onkey->input = devm_input_allocate_device(dev); + if (!onkey->input) + return -ENOMEM; + + onkey->input->name = "max77650_onkey"; + onkey->input->phys = "max77650_onkey/input0"; + onkey->input->id.bustype = BUS_I2C; + input_set_capability(onkey->input, type, onkey->code); + + error = devm_request_any_context_irq(dev, irq_f, max77650_onkey_falling, + IRQF_ONESHOT, "onkey-down", onkey); + if (error < 0) + return error; + + error = devm_request_any_context_irq(dev, irq_r, max77650_onkey_rising, + IRQF_ONESHOT, "onkey-up", onkey); + if (error < 0) + return error; + + return input_register_device(onkey->input); +} + +static struct platform_driver max77650_onkey_driver = { + .driver = { + .name = "max77650-onkey", + }, + .probe = max77650_onkey_probe, +}; +module_platform_driver(max77650_onkey_driver); + +MODULE_DESCRIPTION("MAXIM 77650/77651 ONKEY driver"); +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_LICENSE("GPL v2"); -- 2.21.0