Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp422806lqg; Thu, 11 Apr 2024 07:08:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1jR4eRs/EpPT5uYpaCnWRg+v2EeXwT7DkbQgPXyqPggDaAIJ6mFV/tG5ATgbNN7Idcb3QM4qY7TaOeoPfFqOa6AiJDg5f1Tj1JfabzA== X-Google-Smtp-Source: AGHT+IGtoCLYgkLXzAevGwDILeaUtGJnQWy7q3ulqWR6txJl44tZ1GipRGvxnJh7B6W5L8II8bQv X-Received: by 2002:a05:6a00:124c:b0:6ec:eacb:ecd2 with SMTP id u12-20020a056a00124c00b006eceacbecd2mr6751675pfi.33.1712844509803; Thu, 11 Apr 2024 07:08:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712844509; cv=pass; d=google.com; s=arc-20160816; b=wwAbp/zVMvo+x4cqkb2ivzW3RJEUOfL7dPQu4M5WiaIl5tLTrquw8UqrDxnta7w353 ks53PhBg8A2herUxoUW92JzHZAIYIE2b3k0G7nxI/ZeH/mhJoqXZ+dU9+y8aujWfLmGN QSgzKTgVkRVNELrEmYWxx2ERcqouxnsXWNMbqjPB6abP0ODg5KLzqRae4Y5yc7Prtz+a sYGNXBsqKmM86vrVSW1wFRBOZHwSb0Rsbdd0qdYed+KBZYD/8wDv+POLaOS8zqAJNlxk Ro/71OozFFFegsEdz9M3B4WwExypYNzEmfzv3dJ3UJmqSx66v3Lw/csn34wj0a2WRPax xAKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=8vWKNp5NOyzk1nvCBVyzQsUw06V4AN1AfvxUVSvqf1M=; fh=iTzJ2H1wEvTp9arzqKHkEO9GdQjFyUydq3lgST85mjE=; b=d/UdJhH5Nt0md5a+DcXQpDnjy7fOuYZyrTe4YkAHXv0iZUkqhVIm/pqnLswSF40Pzg dJJAunGxYHYHPzNnFcKbIl2o4yl0NCWZ91fR7II1xn9zIJGYtG4MBdNCW51z7XKydz9I nRPqo2oLQ22HyK8s2KH+R7nGWd9VKiGLqnBiqxDEo76EwN1ejzLYaM+6X1p688DHxcuZ 4H1rvn+qcPKDFZHDPxHk1/duVeKe4zZZiVe3evvkgL3roi0Wt67Knb4s2aaXbh3iSH+o r2PLxbit7LI/LVvoZT8fvSEai3HsnF5nO9muZIxYKxZUKBTNhX8RoEAv1JJ8yLlz2U35 iykQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="fk9dgjL/"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-140561-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f24-20020a637558000000b005dc3c49442esi1307479pgn.732.2024.04.11.07.08.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140561-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="fk9dgjL/"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-140561-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140561-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 84F9FB29E7B for ; Thu, 11 Apr 2024 13:48:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63E721534E8; Thu, 11 Apr 2024 13:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="fk9dgjL/" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 769FB1EB26; Thu, 11 Apr 2024 13:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712843116; cv=none; b=IoZtqD2mXCQNpOJAdpXnXm0gl3DOqKLWzAyM9cQ6fPhzf3PnDF6Ycb5VTL+Ko12mYcn9gZQEdHHeMxr/HgIExvTfM1iSOF9RF2ZY5zI2nj//y4HcLLZLaU0LGeIpxcXUw23E96HfzDcySjUQMfrAhtddTXvvSwjLVJV+RcetO/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712843116; c=relaxed/simple; bh=Vef2IPFjkusUWnM9mmNBw7GsUxZyGnBJjs80zDYEVf4=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=bsZAVDzgvqbw92zH4/RTLELDjkfFZfClUfNZ+/SxdK7nKzoEh9nXewHik+26l7zI55lRdRjNAGq+FC0+2i1/6xs4Jicv+buNdZwSqXOP6VtA0N7DJx7yLtoKlyT0qfV0rXpMrHCLgqyo+Fqp8nI6J/Cb3yWon4KemHKHddQ73jA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=fk9dgjL/; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 43BDcJ37013981; Thu, 11 Apr 2024 13:45:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=8vWKNp5NOyzk1nvCBVyzQsUw06V4AN1AfvxUVSvqf1M=; b=fk 9dgjL/sycJIMj1SDfqZL9GDehjEIzHsBaoWJSHSg3Be0hYMAEwl7Fw9zI72aIctk SCNjuIpqbgWxqdq2Odqki9wA0PTv0f5MTK/D8cooPfmrABfRoct2tPn5B+Qkrgs8 CDA47mKhDjDIe+TYv2p8CNaPJESNmbsg/cRqJpwQ4IZ0jCE+goQz/ifQE4ZWKHHH bmLXrfgbl/7dTfCD5+UzGSFOpoyEEkxgIQHee6beTqPuWpCiL1BdWeWgNJ9YMWbm M3o8XKeGiVNjnHftwhSaYBgAJUrs5TQGWSEYFVtI6q2VO68CFsmFRoMq5PTlVUPe Vl1gdyCsZb0nBulw5gMQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xe9jsa148-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Apr 2024 13:44:47 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43BDi7RD018671 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Apr 2024 13:44:07 GMT Received: from [10.253.34.126] (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 11 Apr 2024 06:44:02 -0700 Message-ID: Date: Thu, 11 Apr 2024 21:43:59 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v9 2/4] input: pm8xxx-vibrator: refactor to support new SPMI vibrator Content-Language: en-US To: Dmitry Baryshkov CC: , Andy Gross , Bjorn Andersson , Konrad Dybcio , "Dmitry Torokhov" , Rob Herring , Krzysztof Kozlowski , , , , References: <20240411-pm8xxx-vibrator-new-design-v9-0-7bf56cb92b28@quicinc.com> <20240411-pm8xxx-vibrator-new-design-v9-2-7bf56cb92b28@quicinc.com> From: Fenglin Wu In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: PsVZnEuLpXAM2rwWwkWHRnxLKI3hnFcy X-Proofpoint-GUID: PsVZnEuLpXAM2rwWwkWHRnxLKI3hnFcy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-11_06,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxlogscore=958 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404110099 On 2024/4/11 18:58, Dmitry Baryshkov wrote: > On Thu, 11 Apr 2024 at 11:32, Fenglin Wu via B4 Relay > wrote: >> >> From: Fenglin Wu >> >> Currently, vibrator control register addresses are hard coded, >> including the base address and offsets, it's not flexible to >> support new SPMI vibrator module which is usually included in >> different PMICs with different base address. Refactor it by using >> the base address defined in devicetree. >> >> Signed-off-by: Fenglin Wu >> --- >> drivers/input/misc/pm8xxx-vibrator.c | 42 ++++++++++++++++++++++++------------ >> 1 file changed, 28 insertions(+), 14 deletions(-) >> >> diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c >> index 89f0f1c810d8..2959edca8eb9 100644 >> --- a/drivers/input/misc/pm8xxx-vibrator.c >> +++ b/drivers/input/misc/pm8xxx-vibrator.c >> @@ -20,26 +20,26 @@ >> #define MAX_FF_SPEED 0xff >> >> struct pm8xxx_regs { >> - unsigned int enable_addr; >> + unsigned int enable_offset; >> unsigned int enable_mask; >> >> - unsigned int drv_addr; >> + unsigned int drv_offset; >> unsigned int drv_mask; >> unsigned int drv_shift; >> unsigned int drv_en_manual_mask; >> }; >> >> static const struct pm8xxx_regs pm8058_regs = { >> - .drv_addr = 0x4A, >> + .drv_offset = 0x4A, > > If the DT already has reg = <0x4a> and you add drv_offset = 0x4a, > which register will be used by the driver? > > Also, while we are at it, please downcase all the hex numbers that you > are touching. > For SSBI vibrator, the "reg" value defined in DT is not used, see below. >> .drv_mask = 0xf8, >> .drv_shift = 3, >> .drv_en_manual_mask = 0xfc, >> }; >> >> static struct pm8xxx_regs pm8916_regs = { >> - .enable_addr = 0xc046, >> + .enable_offset = 0x46, [...] >> @@ -170,7 +173,7 @@ static int pm8xxx_vib_probe(struct platform_device *pdev) >> struct pm8xxx_vib *vib; >> struct input_dev *input_dev; >> int error; >> - unsigned int val; >> + unsigned int val, reg_base = 0; >> const struct pm8xxx_regs *regs; >> >> vib = devm_kzalloc(&pdev->dev, sizeof(*vib), GFP_KERNEL); >> @@ -190,13 +193,24 @@ static int pm8xxx_vib_probe(struct platform_device *pdev) >> >> regs = of_device_get_match_data(&pdev->dev); >> >> + if (regs->enable_offset != 0) { >> + error = fwnode_property_read_u32(pdev->dev.fwnode, "reg", ®_base); >> + if (error < 0) { >> + dev_err(&pdev->dev, "Failed to read reg address, rc=%d\n", error); >> + return error; >> + } >> + } >> + >> + vib->enable_addr = reg_base + regs->enable_offset; >> + vib->drv_addr = reg_base + regs->drv_offset; The reg_base is initialized as 0 and it is assigned as the "reg" value defined in DT only for SPMI vibrators. >> + >> /* operate in manual mode */ >> - error = regmap_read(vib->regmap, regs->drv_addr, &val); >> + error = regmap_read(vib->regmap, vib->drv_addr, &val); >> if (error < 0) >> return error; >> >> val &= regs->drv_en_manual_mask; >> - error = regmap_write(vib->regmap, regs->drv_addr, val); >> + error = regmap_write(vib->regmap, vib->drv_addr, val); >> if (error < 0) >> return error; >> >> >> -- >> 2.25.1 >> >> > >