From patchwork Mon Apr 23 02:33:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133947 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp487597lji; Sun, 22 Apr 2018 19:34:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx48t64PugLk3GqM2+yA9RCpCBCA2MCJecH6JI0ZCwMaNYl1DFFsn5ySECeOi7G71LvEis36E X-Received: by 10.99.121.69 with SMTP id u66mr7250186pgc.376.1524450876506; Sun, 22 Apr 2018 19:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524450876; cv=none; d=google.com; s=arc-20160816; b=e/pRqTkOCBmxoXWZskArASjib4mMuyvDEbZ4s+P0KMcSIfDt4mdEAvsFnwglL144JB 5OyS5a8m1a7OynL+sryH5lWoX6e/ZzwdXRw0KJJ4fNPsqfud9Rqcc4JCilx3xMfBfwS2 zAbEl76/paMuJNnUxeBDfIZgmt05vbLb36QBxZ9hdNStewB0NLMiNTESoPeZ2mUa1wgY SYhSeizI3LIYmAftlQbTk8y9H99l+ODa5z2KzuHYcti1UVMYKJP6qLpd+AE9X+zS+6UN WsHU862F8qvNdLoZ9Jr+9hrh730uy3NrKyyHiQ6M7RxukcYA548TZbFejYaXN3LCNP6T B6TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=cutPDcPyvCDSHVv6QTF8vFRbQJtg5t+gYvZQuMBmKCc=; b=j99U1oqIoAbyI/SypQtPhuB9nd3l3R+l+rpLnLy/gYzfFQsrQD5zl3u46E1lyhBJmJ 6W0dlStQIlMFWkt5S18/fFYrz1ztRpg2TK67D0EfR+b2SRlloK3E8PKLJahZExgacA5M +j/XvjnrUxPQ99g64gZyjEyLmb0W0RJdA0Zv0ZRp4r/osSMSd03udlixYB14hFprP/L2 fgfAq9thgJLNk/Yl094yJiUxCerolQcpsf6lF797j0ef6XWzTgsoBUgCGqaoVQqmlTna EHPcXXtUHCgen5emkkZovBHSUD25DTjDub8DtYxN8/QL5oHfhiMX/xgSJerMf2+EL5RY 0RFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PAx4U9Tr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12-v6si10528716pld.367.2018.04.22.19.34.36; Sun, 22 Apr 2018 19:34:36 -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=@linaro.org header.s=google header.b=PAx4U9Tr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754274AbeDWCee (ORCPT + 29 others); Sun, 22 Apr 2018 22:34:34 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:41884 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753995AbeDWCea (ORCPT ); Sun, 22 Apr 2018 22:34:30 -0400 Received: by mail-pf0-f194.google.com with SMTP id a2so7968153pff.8 for ; Sun, 22 Apr 2018 19:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=cutPDcPyvCDSHVv6QTF8vFRbQJtg5t+gYvZQuMBmKCc=; b=PAx4U9Trc8aYAsgEw18zHZaKapHfrKR4Lck0zYHSrN4dxejO43lSzE6vA7HufsAVVk ynMddJeyb0pEUOXW51BibajjS3njYWxFqEl7p8LBdDLYDtNeI9pmALmErC+ULao2ehTN NtBL0SMVr59qVOp6UlXXcksI0B4Q9Xwi0sfaU= 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; bh=cutPDcPyvCDSHVv6QTF8vFRbQJtg5t+gYvZQuMBmKCc=; b=ddC1Gs0FgVWUV83z7aI50awxpSGbCjhCFYpR4vmvJ6D6P3xWF1CRuNHcw8Knir+D8e S9VFhuuoKPmWWk6SxD3RUPSYMhiqVnu9nwT3+xD6MA4brOkp4qdnHk+zlHhlD0/tumSD SA0bvobnAY+zQqaGQ9RAFkrKiNb6ByA2ZibjYSAqL8wH9rlp/9OJXhAMdGo3gNGibG4p jc/+gFQn027w7hGQQID0W1ZxQzysu8dndZ6FFLoR9PReJt/52WI9+jNXfcGQo/VE86zp 7K1mKQDuc9HrEIoUY3TqPnCAXqaCf5E2S06DH7fXOk8cBxCIhwk3GhXocKNfyZHWRjJB KXNw== X-Gm-Message-State: ALQs6tCQK+GEZ466Knb94Mlsw5VKy5/ltDmIG/tYoaOSDrE/OTcf0Sg+ x4pIzK2D2Sz92nRGihBon4E52w== X-Received: by 10.99.141.202 with SMTP id z193mr15523939pgd.418.1524450870185; Sun, 22 Apr 2018 19:34:30 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id t11sm17693451pgn.94.2018.04.22.19.34.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Apr 2018 19:34:29 -0700 (PDT) From: Baolin Wang To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, orsonzhai@gmail.com, zhang.lyra@gmail.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, xiaotong.lu@spreadtrum.com Subject: [PATCH v2 1/2] dt-bindings: input: Add Add Spreadtrum SC27xx vibrator documentation Date: Mon, 23 Apr 2018 10:33:35 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaotong Lu This patch adds the binding documentation for Spreadtrum SC27xx series vibrator device. Signed-off-by: Xiaotong Lu Signed-off-by: Baolin Wang --- Changes since v1: - No updates. --- .../bindings/input/sprd,sc27xx-vibra.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt new file mode 100644 index 0000000..92ead29 --- /dev/null +++ b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt @@ -0,0 +1,12 @@ +Spreadtrum SC27xx PMIC Vibrator + +Required properties: +- compatible: should be "sprd,sc27xx-vibrator". +- reg: address of vibrator control register. + +Example : + +vibrator@eb4 { + compatible = "sprd,sc27xx-vibrator"; + reg = <0xeb4>; +}; From patchwork Mon Apr 23 02:33:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 133948 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp487663lji; Sun, 22 Apr 2018 19:34:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/1LFG+/K5aiV2ga0NcheFROET5I22SU6dx9PWzZVMRWtsJ6PWcX7Eq2oUHCKr220YPDItB X-Received: by 2002:a17:902:6ac3:: with SMTP id i3-v6mr19312573plt.142.1524450882348; Sun, 22 Apr 2018 19:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524450882; cv=none; d=google.com; s=arc-20160816; b=W0FOc02QZW4/j3gIaY96GxkemKvuV/7VgEhZDl30ecz6cXxSsXETj2mMoygr/UZ3p3 Cy6BJ0iikrOoFFZ8ZdfUzAkyCNwchX+P/TbPl9elQvWbttNmhgRe+TtaS63LGPZpKp+t cV6mGe6pR+sxKWphxdCmTwl1b2wgL07yAqcGHWVif3nZ024wUn5p13ON4mQeKcGALgH8 3kO6BG1oYoERryz29xg3yQUGnsD0T5jowhbZDa3sgwhN28jJ7cFT8M8ah6NyzZbdJDQd LikUmj06AkuRJDA9s9xLXVqUfpdj6TxNAFDkVhc8AW4rlCMLDiuYtifOVtV2LSSblCvu DE9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=moTp3d7Vst+n/jJ8VuveXvfSYuA0wGyq7I8o+ReCNyo=; b=DXrHuBwCke9IL+CZLRw7Yj75l8OETutEG8mAnhCyJxMZHmlRJVXgcd56zNNlPdJAaY 8cflLWMSkyayy7hkqqvrektarWIFxG3/WlHyNZmKporDP7PqmhfEcsxKrS4I9+fSc0DV +c+DfZqYsjmxOXpFKaNFnK7ZKwUXrx4gsJaWlOb9YSQxC5lTYveho9iXX3D26fw5Ge8R mInOmJ0Km8NVkoyPAIZxgOVeiTxNfFtWTvQM3x9c5FU6doA7Vz7LxPmV+QgISEUB32pm gLZZdpU6854AphXbTwCUU3/7jU+28p59/V7JNDj7bEtRtOcZBB1zyW3W9fjbmLwG2vqv 6UCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aVahReQW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si10442755pff.136.2018.04.22.19.34.42; Sun, 22 Apr 2018 19:34:42 -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=@linaro.org header.s=google header.b=aVahReQW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754293AbeDWCek (ORCPT + 29 others); Sun, 22 Apr 2018 22:34:40 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36631 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754263AbeDWCee (ORCPT ); Sun, 22 Apr 2018 22:34:34 -0400 Received: by mail-pg0-f68.google.com with SMTP id i6so7316957pgv.3 for ; Sun, 22 Apr 2018 19:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=moTp3d7Vst+n/jJ8VuveXvfSYuA0wGyq7I8o+ReCNyo=; b=aVahReQWEofneApKSRBzUyB7XigrCAzQJ6yoEzQ96uprQwY+8c0gJlTS/OhbDDgLT1 115eUUnEmzwTCQmoXrYy4NyLbLgG3vjGjNvL7EllzTvk9jUMAYNyDYQ4hhtkDAFRYvvl o01LZWQI642DddiUZcBZ2Dl3P1xfTniehSWsY= 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:in-reply-to:references; bh=moTp3d7Vst+n/jJ8VuveXvfSYuA0wGyq7I8o+ReCNyo=; b=SFuqzmfgV6vazSGwH4Nxj17cTrUKKUvnIADtpGVkabXxrnUg7BgQituS/nb0v5oPuh g5QeldZeoQYkqzo70iF1YJya9ezT69cXgBD3OBUzW2PNutsVU1PrXJBXzS3ZXwGATFjK S/hAxmJVR5mMNIoSdayIbxHZWUrHDA8YOyab2FxsSpV7wLaLFaWQ5yzZ0dWgpp7ICOAo rvrV/Oc4LsVdWJuzUrPStd73GpULecZRCLqV8R2xe+efxSrNsare6097qY8UM8uD3+rb 1MbskCHtTo8+uexDGdbIPyaFcVBXd00Ztl3zcZzqY9EdhL/y0t4+IRU9KOEdiNo2iHZ5 1uxg== X-Gm-Message-State: ALQs6tATem38XWPhQhrBeR6qyTHf8treGhRtDmyqktYoyVq5/ZbbFdDH kU0gbnWfXPylngOgh5zddy25HQ== X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr19074041plv.52.1524450873616; Sun, 22 Apr 2018 19:34:33 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id t11sm17693451pgn.94.2018.04.22.19.34.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Apr 2018 19:34:33 -0700 (PDT) From: Baolin Wang To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, orsonzhai@gmail.com, zhang.lyra@gmail.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, xiaotong.lu@spreadtrum.com Subject: [PATCH v2 2/2] input: misc: Add Spreadtrum vibrator driver Date: Mon, 23 Apr 2018 10:33:36 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaotong Lu This patch adds the Spreadtrum vibrator driver, which embedded in the Spreadtrum SC27xx series PMICs. Signed-off-by: Xiaotong Lu Signed-off-by: Baolin Wang --- Changes since v1: - Remove input_ff_destroy() and input_unregister_device() --- drivers/input/misc/Kconfig | 10 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/sc27xx-vibra.c | 156 +++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 drivers/input/misc/sc27xx-vibra.c -- 1.7.9.5 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 572b15f..c761c0c 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -841,4 +841,14 @@ config INPUT_RAVE_SP_PWRBUTTON To compile this driver as a module, choose M here: the module will be called rave-sp-pwrbutton. +config INPUT_SC27XX_VIBRA + tristate "Spreadtrum sc27xx vibrator support" + depends on MFD_SC27XX_PMIC || COMPILE_TEST + select INPUT_FF_MEMLESS + help + This option enables support for Spreadtrum sc27xx vibrator driver. + + To compile this driver as a module, choose M here. The module will + be called sc27xx_vibra. + endif diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 72cde28..9d0f9d1 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o +obj-$(CONFIG_INPUT_SC27XX_VIBRA) += sc27xx-vibra.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o diff --git a/drivers/input/misc/sc27xx-vibra.c b/drivers/input/misc/sc27xx-vibra.c new file mode 100644 index 0000000..f78e70f --- /dev/null +++ b/drivers/input/misc/sc27xx-vibra.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Spreadtrum Communications Inc. + */ + +#include +#include +#include +#include +#include +#include + +#define CUR_DRV_CAL_SEL GENMASK(13, 12) +#define SLP_LDOVIBR_PD_EN BIT(9) +#define LDO_VIBR_PD BIT(8) + +struct vibra_info { + struct input_dev *input_dev; + struct work_struct play_work; + struct regmap *regmap; + u32 base; + u32 strength; + bool enabled; +}; + +static void sc27xx_vibra_set(struct vibra_info *info, bool on) +{ + if (on) { + regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 0); + regmap_update_bits(info->regmap, info->base, + SLP_LDOVIBR_PD_EN, 0); + info->enabled = true; + } else { + regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, + LDO_VIBR_PD); + regmap_update_bits(info->regmap, info->base, + SLP_LDOVIBR_PD_EN, SLP_LDOVIBR_PD_EN); + info->enabled = false; + } +} + +static int sc27xx_vibra_hw_init(struct vibra_info *info) +{ + return regmap_update_bits(info->regmap, info->base, CUR_DRV_CAL_SEL, 0); +} + +static void sc27xx_vibra_play_work(struct work_struct *work) +{ + struct vibra_info *info = container_of(work, struct vibra_info, + play_work); + + if (info->strength && !info->enabled) + sc27xx_vibra_set(info, true); + else if (info->enabled) + sc27xx_vibra_set(info, false); +} + +static int sc27xx_vibra_play(struct input_dev *input, void *data, + struct ff_effect *effect) +{ + struct vibra_info *info = input_get_drvdata(input); + + info->strength = effect->u.rumble.weak_magnitude; + schedule_work(&info->play_work); + + return 0; +} + +static void sc27xx_vibra_close(struct input_dev *input) +{ + struct vibra_info *info = input_get_drvdata(input); + + cancel_work_sync(&info->play_work); + if (info->enabled) + sc27xx_vibra_set(info, false); +} + +static int sc27xx_vibra_probe(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct vibra_info *info; + int ret; + + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!info->regmap) { + dev_err(&pdev->dev, "failed to get vibrator regmap.\n"); + return -ENODEV; + } + + ret = of_property_read_u32(node, "reg", &info->base); + if (ret) { + dev_err(&pdev->dev, "failed to get vibrator base address.\n"); + return ret; + } + + info->input_dev = devm_input_allocate_device(&pdev->dev); + if (!info->input_dev) { + dev_err(&pdev->dev, "failed to allocate input device.\n"); + return -ENOMEM; + } + + info->input_dev->name = "sc27xx:vibrator"; + info->input_dev->id.version = 0; + info->input_dev->dev.parent = pdev->dev.parent; + info->input_dev->close = sc27xx_vibra_close; + + input_set_drvdata(info->input_dev, info); + input_set_capability(info->input_dev, EV_FF, FF_RUMBLE); + INIT_WORK(&info->play_work, sc27xx_vibra_play_work); + info->enabled = false; + + ret = input_ff_create_memless(info->input_dev, NULL, sc27xx_vibra_play); + if (ret) { + dev_err(&pdev->dev, "failed to register vibrator to FF.\n"); + return ret; + } + + ret = input_register_device(info->input_dev); + if (ret) { + dev_err(&pdev->dev, "failed to register input device.\n"); + return ret; + } + + ret = sc27xx_vibra_hw_init(info); + if (ret) { + dev_err(&pdev->dev, "failed to initialize the vibrator.\n"); + return ret; + } + + platform_set_drvdata(pdev, info); + return 0; +} + +static const struct of_device_id sc27xx_vibra_of_match[] = { + { .compatible = "sprd,sc27xx-vibrator", }, + {} +}; +MODULE_DEVICE_TABLE(of, sc27xx_vibra_of_match); + +static struct platform_driver sc27xx_vibra_driver = { + .driver = { + .name = "sc27xx-vibrator", + .of_match_table = sc27xx_vibra_of_match, + }, + .probe = sc27xx_vibra_probe, +}; + +module_platform_driver(sc27xx_vibra_driver); + +MODULE_DESCRIPTION("Spreadtrum SC27xx Vibrator Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Xiaotong Lu ");