From patchwork Wed Jul 29 06:31:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 6889431 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 8A7079F39D for ; Wed, 29 Jul 2015 06:32:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A20EA2079C for ; Wed, 29 Jul 2015 06:32:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68516207B9 for ; Wed, 29 Jul 2015 06:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652AbbG2Gbs (ORCPT ); Wed, 29 Jul 2015 02:31:48 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:65371 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbbG2Gbo (ORCPT ); Wed, 29 Jul 2015 02:31:44 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NS800KOZKSUEG70@mailout4.w1.samsung.com>; Wed, 29 Jul 2015 07:31:42 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-e4-55b8734eb263 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id D1.CC.04846.E4378B55; Wed, 29 Jul 2015 07:31:42 +0100 (BST) Received: from localhost.localdomain ([10.252.80.64]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NS8008EUKSIMK40@eusync1.samsung.com>; Wed, 29 Jul 2015 07:31:41 +0100 (BST) From: Krzysztof Kozlowski To: Dmitry Torokhov Cc: Mark Brown , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Jaewon Kim , Krzysztof Kozlowski Subject: [PATCH 2/4] Input: max77693: Prepare for adding support for Maxim 77843 Date: Wed, 29 Jul 2015 15:31:28 +0900 Message-id: <1438151490-13751-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438151490-13751-1-git-send-email-k.kozlowski@samsung.com> References: <1438151490-13751-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4ZV2/4h2hBuveMVpMffiEzeLwoheM FjsajrBavH5haHHz0zdWi8u75rA5sHnsnHWX3WPTqk42j74tqxg9Pm+SC2CJ4rJJSc3JLEst 0rdL4Mr4+vkQW8FjyYoNWxoYGxi3iHYxcnJICJhILF8+mQXCFpO4cG89WxcjF4eQwFJGiTf3 NrBAOP8ZJU4s+sQKUsUmYCyxefkSNhBbREBfYvvsX4wgRcwCOxglDmxrYAZJCAsESGy6dAyo gYODRUBVYsJXJZAwr4C7xP1H26C2yUmcPDYZbCangIfE8cn3weJCQDWP5i9mmcDIu4CRYRWj aGppckFxUnquoV5xYm5xaV66XnJ+7iZGSAB92cG4+JjVIUYBDkYlHt4ZOjtChVgTy4orcw8x SnAwK4nwBlgBhXhTEiurUovy44tKc1KLDzFKc7AoifPO3fU+REggPbEkNTs1tSC1CCbLxMEp 1cDo/nz/kVLuo79l6/wP1aUmXNpp37y/4o+eotkKnoOxHi1P/W5LyuutYvibcVlndmR60Vsv 93mmgXKV0SxTr02N3FLaFOVz8HT1Bd59p+YavF96Mpp54omEsL1hulYXXb+ucT8W8rz4quXX Ba+4f6R81t59ZeW2lzwHO2Ja/jIx21pOj2+aKteqxFKckWioxVxUnAgASqh7CBwCAAA= 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 Prepare the driver for supporting two devices: Maxim 77693 and 77843: 1. Add table of device ids and store current device type for later usage. 2. Differentiate the haptic device configuration. Signed-off-by: Krzysztof Kozlowski --- drivers/input/misc/max77693-haptic.c | 41 ++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 8dc43c1ebf0e..4c0f67ab66d9 100644 --- a/drivers/input/misc/max77693-haptic.c +++ b/drivers/input/misc/max77693-haptic.c @@ -47,6 +47,8 @@ enum max77693_haptic_pwm_divisor { }; struct max77693_haptic { + enum max77693_types dev_type; + struct regmap *regmap_pmic; struct regmap *regmap_haptic; struct device *dev; @@ -81,16 +83,23 @@ static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic) static int max77693_haptic_configure(struct max77693_haptic *haptic, bool enable) { - unsigned int value; + unsigned int value, config_reg; int error; - value = ((haptic->type << MAX77693_CONFIG2_MODE) | - (enable << MAX77693_CONFIG2_MEN) | - (haptic->mode << MAX77693_CONFIG2_HTYP) | - MAX77693_HAPTIC_PWM_DIVISOR_128); + switch (haptic->dev_type) { + case TYPE_MAX77693: + value = ((haptic->type << MAX77693_CONFIG2_MODE) | + (enable << MAX77693_CONFIG2_MEN) | + (haptic->mode << MAX77693_CONFIG2_HTYP) | + MAX77693_HAPTIC_PWM_DIVISOR_128); + config_reg = MAX77693_HAPTIC_REG_CONFIG2; + break; + default: + return -EINVAL; + } error = regmap_write(haptic->regmap_haptic, - MAX77693_HAPTIC_REG_CONFIG2, value); + config_reg, value); if (error) { dev_err(haptic->dev, "failed to update haptic config: %d\n", error); @@ -254,12 +263,23 @@ static int max77693_haptic_probe(struct platform_device *pdev) return -ENOMEM; haptic->regmap_pmic = max77693->regmap; - haptic->regmap_haptic = max77693->regmap_haptic; haptic->dev = &pdev->dev; haptic->type = MAX77693_HAPTIC_LRA; haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE; haptic->suspend_state = false; + /* Variant-specific init */ + haptic->dev_type = platform_get_device_id(pdev)->driver_data; + switch (haptic->dev_type) { + case TYPE_MAX77693: + haptic->regmap_haptic = max77693->regmap_haptic; + break; + default: + dev_err(&pdev->dev, "unsupported device type: %u\n", + haptic->dev_type); + return -EINVAL; + } + INIT_WORK(&haptic->work, max77693_haptic_play_work); /* Get pwm and regulatot for haptic device */ @@ -337,12 +357,19 @@ static int __maybe_unused max77693_haptic_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, max77693_haptic_suspend, max77693_haptic_resume); +static const struct platform_device_id max77693_haptic_id[] = { + { "max77693-haptic", TYPE_MAX77693 }, + {}, +}; +MODULE_DEVICE_TABLE(platform, max77693_haptic_id); + static struct platform_driver max77693_haptic_driver = { .driver = { .name = "max77693-haptic", .pm = &max77693_haptic_pm_ops, }, .probe = max77693_haptic_probe, + .id_table = max77693_haptic_id, }; module_platform_driver(max77693_haptic_driver);