From patchwork Thu Jul 30 01:36:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6897901 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B5CE49F39D for ; Thu, 30 Jul 2015 01:38:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B489E20268 for ; Thu, 30 Jul 2015 01:38:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A16C20172 for ; Thu, 30 Jul 2015 01:38:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754477AbbG3Bhq (ORCPT ); Wed, 29 Jul 2015 21:37:46 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:54568 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754561AbbG3BhE (ORCPT ); Wed, 29 Jul 2015 21:37:04 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NSA00DB71TQZW20@mailout3.w1.samsung.com>; Thu, 30 Jul 2015 02:37:02 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-22-55b97fbe1f93 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id C0.78.04846.EBF79B55; Thu, 30 Jul 2015 02:37:02 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NSA00C2W1TAJX10@eusync3.samsung.com>; Thu, 30 Jul 2015 02:37:02 +0100 (BST) From: Krzysztof Kozlowski To: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, Dmitry Torokhov , Dan Murphy , Jaewon Kim , linux-input@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH v2 3/4] Input: max77693: Add support for Maxim 77843 Date: Thu, 30 Jul 2015 10:36:43 +0900 Message-id: <1438220204-377-4-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438220204-377-1-git-send-email-k.kozlowski@samsung.com> References: <1438220204-377-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJLMWRmVeSWpSXmKPExsVy+t/xq7r76neGGly5xmQx9eETNovDi14w WnSf3sJqsaPhCKvF6xeGFt+udDBZ3Pz0jdXi8q45bA4cHjtn3WX32LSqk82jb8sqRo/jN7Yz eXzeJBfAGsVlk5Kak1mWWqRvl8CVcWJyF3vBYs2KI28/MDUwTlLqYuTkkBAwkbjwdgkbhC0m ceHeeiCbi0NIYCmjxMPFD6Gc/4wSJxc/ZgapYhMwlti8fAlYQkTgF6PE1u8TWEESzAKGEj/f /WEHsYUFXCTmH9gM1sAioCrx6corJhCbV8BVYv/Ro6wQ6+QkTh6bDGZzCrhJdB8/DVYjBFTT tWI/2wRG3gWMDKsYRVNLkwuKk9JzDfWKE3OLS/PS9ZLzczcxQgLsyw7GxcesDjEKcDAq8fDO 0NkRKsSaWFZcmXuIUYKDWUmE19ZnZ6gQb0piZVVqUX58UWlOavEhRmkOFiVx3rm73ocICaQn lqRmp6YWpBbBZJk4OKUaGDWL+w7wLMteo6oeeLQt/W2EgdKaeT3mqnnTrJodeD2NzY5OD/mk /y6S4VvWGQnLE+EB7q8P/d20hsGvuFq3LXT5dvGZk8QC5q69v6QzX9ymjmv7G5u/zu/0xdqr /H/6f2L/sc39/8uYnc1BV6Z/C66t3MWklfP4jnXG5Q2Z32b/rr/zIiOoRImlOCPRUIu5qDgR APAl3lgsAgAA Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Maxim 77843 haptic driver differs from 77693 by: 1. Setting the bias. 2. Different configuration register. 3. Not enabling the low-sys DAC. 4. Using same regmap for PMIC and haptic blocks. Incorporate all differences into max77693 haptic driver so both devices can be supported. Signed-off-by: Krzysztof Kozlowski Acked-by: Dmitry Torokhov --- drivers/input/misc/Kconfig | 6 ++--- drivers/input/misc/max77693-haptic.c | 48 +++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index d4f0a817e858..f5d7a98a329d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -167,12 +167,12 @@ config INPUT_M68K_BEEP depends on M68K config INPUT_MAX77693_HAPTIC - tristate "MAXIM MAX77693 haptic controller support" - depends on MFD_MAX77693 && PWM + tristate "MAXIM MAX77693/MAX77843 haptic controller support" + depends on (MFD_MAX77693 || MFD_MAX77843) && PWM select INPUT_FF_MEMLESS help This option enables support for the haptic controller on - MAXIM MAX77693 chip. + MAXIM MAX77693 and MAX77843 chips. To compile this driver as module, choose M here: the module will be called max77693-haptic. diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 4c0f67ab66d9..6d96bff32a0e 100644 --- a/drivers/input/misc/max77693-haptic.c +++ b/drivers/input/misc/max77693-haptic.c @@ -1,8 +1,9 @@ /* - * MAXIM MAX77693 Haptic device driver + * MAXIM MAX77693/MAX77843 Haptic device driver * - * Copyright (C) 2014 Samsung Electronics + * Copyright (C) 2014,2015 Samsung Electronics * Jaewon Kim + * Krzysztof Kozlowski * * This program is not provided / owned by Maxim Integrated Products. * @@ -26,6 +27,7 @@ #include #include #include +#include #define MAX_MAGNITUDE_SHIFT 16 @@ -80,6 +82,26 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) return 0; } +static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on) +{ + int error; + + if (haptic->dev_type != TYPE_MAX77843) + return 0; + + error = regmap_update_bits(haptic->regmap_haptic, + MAX77843_SYS_REG_MAINCTRL1, + MAX77843_MAINCTRL1_BIASEN_MASK, + on << MAINCTRL1_BIASEN_SHIFT); + if (error) { + dev_err(haptic->dev, "failed to %s bias: %d\n", + on ? "enable" : "disable", error); + return error; + } + + return 0; +} + static int max77693_haptic_configure(struct max77693_haptic *haptic, bool enable) { @@ -94,6 +116,12 @@ static int max77693_haptic_configure(struct max77693_haptic *haptic, MAX77693_HAPTIC_PWM_DIVISOR_128); config_reg = MAX77693_HAPTIC_REG_CONFIG2; break; + case TYPE_MAX77843: + value = (haptic->type << MCONFIG_MODE_SHIFT) | + (enable << MCONFIG_MEN_SHIFT) | + MAX77693_HAPTIC_PWM_DIVISOR_128; + config_reg = MAX77843_HAP_REG_MCONFIG; + break; default: return -EINVAL; } @@ -113,6 +141,9 @@ static int max77693_haptic_lowsys(struct max77693_haptic *haptic, bool enable) { int error; + if (haptic->dev_type != TYPE_MAX77693) + return 0; + error = regmap_update_bits(haptic->regmap_pmic, MAX77693_PMIC_REG_LSCNFG, MAX77693_PMIC_LOW_SYS_MASK, @@ -228,6 +259,10 @@ static int max77693_haptic_open(struct input_dev *dev) struct max77693_haptic *haptic = input_get_drvdata(dev); int error; + error = max77843_haptic_bias(haptic, true); + if (error) + return error; + error = regulator_enable(haptic->motor_reg); if (error) { dev_err(haptic->dev, @@ -250,6 +285,8 @@ static void max77693_haptic_close(struct input_dev *dev) if (error) dev_err(haptic->dev, "failed to disable regulator: %d\n", error); + + max77843_haptic_bias(haptic, false); } static int max77693_haptic_probe(struct platform_device *pdev) @@ -274,6 +311,9 @@ static int max77693_haptic_probe(struct platform_device *pdev) case TYPE_MAX77693: haptic->regmap_haptic = max77693->regmap_haptic; break; + case TYPE_MAX77843: + haptic->regmap_haptic = max77693->regmap; + break; default: dev_err(&pdev->dev, "unsupported device type: %u\n", haptic->dev_type); @@ -359,6 +399,7 @@ static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, static const struct platform_device_id max77693_haptic_id[] = { { "max77693-haptic", TYPE_MAX77693 }, + { "max77843-haptic", TYPE_MAX77843 }, {}, }; MODULE_DEVICE_TABLE(platform, max77693_haptic_id); @@ -374,6 +415,7 @@ static struct platform_driver max77693_haptic_driver = { module_platform_driver(max77693_haptic_driver); MODULE_AUTHOR("Jaewon Kim "); -MODULE_DESCRIPTION("MAXIM MAX77693 Haptic driver"); +MODULE_AUTHOR("Krzysztof Kozlowski "); +MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver"); MODULE_ALIAS("platform:max77693-haptic"); MODULE_LICENSE("GPL");