Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp716672rwb; Wed, 16 Nov 2022 06:50:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Pb1xHgJ0ZsvCnTXsaj7+NTtz8CMYbxiHPX3+Gl3K8nnBSFjbNwqDEz+5uEVR2Xv0vFmAZ X-Received: by 2002:aa7:d759:0:b0:463:fec2:dfb1 with SMTP id a25-20020aa7d759000000b00463fec2dfb1mr19773943eds.303.1668610245237; Wed, 16 Nov 2022 06:50:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668610245; cv=none; d=google.com; s=arc-20160816; b=HS2nSW7kjQvQhDcCBUDc+XY8cENHQN6DnelLVr5iB9WJAG6N5GzVOHYu8PS+v22IZJ KCHAqRxWJJdTl3jr++MUP7HQpZVGX/Ay4uOuQ/XeC9doye6q+92QLiLBvPrkjQfh6uBh 2m66XVzI1kM5ZiYnhjDOmOutWCv/VkdbyuBTDoR+XNpqVwX7cm6ASrvN4hFE1CRtSasK CeToP/KUTDH4CELlvXBGrl2ywH2bivObEgdH4fgi/qANqQHDX+CaRh2lgmoOJbbCcRXu cAu1DNXYYNXBlc0AmBlPTbjoSjfXPyKKslkPDbK8HJabAAw67Bc1UWnOGAQ7m4KeW2cI XG9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=03AO/d+34sX5YN3fjNIOuZvahaBINhyoO8pKIANrSLg=; b=i4WWeff2M5FzVqbMUlvFYpoBrP7DsFGKZiGcAOIMgNBlOjhA4CupZGrZJRIELjaxqi wm1S6t1CmNgyQB1cKo3uazYnjrhNDWBzoPn41/VLNMIIAr5RPAUhN41RAEEAI+agRda1 ozxFJW9Dl97uiResykuadjVi20vJyyx9u96R7u9+ZPYK4hVA/ELY5PxR9n77F9UJN69c 3g6+7gPU2l0kB8OwummEig/gdh+jxlq1SXWmjF0Na+2d0KTWfWRS5MftpuaOHLKEZZw/ CljpbD+LiS4j/+FiZx89Pjj1/DL1Wf8oCHGwCSxwISvCWzu/OFBC0TVfMKmcc+0Zcg+p 9Zkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FdKmOSWs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m15-20020a50930f000000b0045cad599362si13928154eda.530.2022.11.16.06.50.22; Wed, 16 Nov 2022 06:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FdKmOSWs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232590AbiKPORM (ORCPT + 91 others); Wed, 16 Nov 2022 09:17:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233509AbiKPORH (ORCPT ); Wed, 16 Nov 2022 09:17:07 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8C67DF57; Wed, 16 Nov 2022 06:17:06 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id p8so29699153lfu.11; Wed, 16 Nov 2022 06:17:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=03AO/d+34sX5YN3fjNIOuZvahaBINhyoO8pKIANrSLg=; b=FdKmOSWs5xFN+58wikER67yYa5Vny4ZcI3G1EZaRA47K3g3cxQSoYX2Rf5H2vc84iv 5hYP4a1AOLTId+qe9ZTmuf6dKhq+6CqIPWkHjQFgCulwkXfOlrbnkEV/t+MAbPVoG0hk d8k2SKK1PsulPklunT7RtLkWS560LFjyi1EGSVvH4ymKDViaJdZXdz6xk9ZguePd1R0/ s8Nq3AkP+h/E8dzSguyzN0C4v3NzhkyF/xmfOoJzWprJC14pMjq47vQkuQZNU0ECOGG5 ePrAG4QUC+b9qEwIvud9lAp0SnxJtnfwGagSY3+BwLIrtQh7Uy55vM1BPeHJi2LDK67b urAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=03AO/d+34sX5YN3fjNIOuZvahaBINhyoO8pKIANrSLg=; b=uIEU2ylqpDpOdFvv6TlvplLzLphvri+Qm5xnwZeN/coGyrYua96+X6HmZyMgLoyrls x/1/Mtz77vaQwVPBoCpXQMwg9ZSbEXFkrRyWcB7wV3dc+Ynz7iXQA33ersiut10Ygs0k T0Fppz+W35viJvruKMk1IWxYtvqCmXc8JUPNT59I9z7Qj0dhHkQO6aH+kACGDgNcbBS1 2zog/+RNuI907e3/wL/Y5ENT/1gZN5L0a3YStSR124zwzA6UFM6RrhEzi80r3y1ZIVo8 MfwTDdeU0qMWzqugjSaAfJulWwoUsxsMDqzaK6ONCcueUPA+NpZaD6U56X84V118gHAk kriw== X-Gm-Message-State: ANoB5plcIR+QZ/ECPHC49H5tOcD5uy5dTBTKYwLFWXuvpQ35YIIKXxgg E/ABGVR1fpbY9d30RUyPr00= X-Received: by 2002:a05:6512:3ba8:b0:4b0:7a03:60dc with SMTP id g40-20020a0565123ba800b004b07a0360dcmr6789861lfv.567.1668608224875; Wed, 16 Nov 2022 06:17:04 -0800 (PST) Received: from ?IPV6:2001:14ba:16f3:4a00::7? (dc75zzyyyyyyyyyyyyydt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::7]) by smtp.gmail.com with ESMTPSA id v15-20020a2ea44f000000b0027738fd1eb6sm3018470ljn.110.2022.11.16.06.17.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 06:17:04 -0800 (PST) Message-ID: Date: Wed, 16 Nov 2022 16:17:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Content-Language: en-US To: Alexandre Mergnat , Flora Fu , Matthias Brugger , Dmitry Torokhov , Tianping Fang , Fabien Parent , Krzysztof Kozlowski , Liam Girdwood , Alexandre Belloni , Mark Brown , Sean Wang , Chen Zhong , Pavel Machek , Lee Jones , Alessandro Zummo , Rob Herring Cc: Krzysztof Kozlowski , Rob Herring , Mattijs Korpershoek , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-leds@vger.kernel.org, Fabien Parent , AngeloGioacchino Del Regno , linux-rtc@vger.kernel.org, linux-input@vger.kernel.org References: <20221005-mt6357-support-v5-0-8210d955dd3d@baylibre.com> <20221005-mt6357-support-v5-9-8210d955dd3d@baylibre.com> From: Matti Vaittinen Subject: Re: [PATCH v5 09/10] regulator: add mt6357 regulator In-Reply-To: <20221005-mt6357-support-v5-9-8210d955dd3d@baylibre.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, All Please, treat my review more as initiation for discussion than 'hard requirements' for this driver. I am in no point or no "confidence level" to give you any requirements ;) On 11/16/22 14:33, Alexandre Mergnat wrote: > From: Fabien Parent > > Add regulator driver for the MT6357 PMIC. > > Signed-off-by: Fabien Parent > Reviewed-by: AngeloGioacchino Del Regno > Signed-off-by: Alexandre Mergnat > --- //snip > +/* > + * MT6357 regulators' information > + * > + * @desc: standard fields of regulator description. > + * @da_vsel_reg: Monitor register for query buck's voltage. > + * @da_vsel_mask: Mask for query buck's voltage. > + */ > +struct mt6357_regulator_info { > + struct regulator_desc desc; > + u32 da_vsel_reg; > + u32 da_vsel_mask; > +}; > + //snip > +/** > + * mt6357_get_buck_voltage_sel - get_voltage_sel for regmap users > + * > + * @rdev: regulator to operate on > + * > + * Regulators that use regmap for their register I/O can set the > + * da_vsel_reg and da_vsel_mask fields in the info structure and > + * then use this as their get_voltage_vsel operation. > + */ > +static int mt6357_get_buck_voltage_sel(struct regulator_dev *rdev) > +{ > + int ret, regval; > + struct mt6357_regulator_info *info = rdev_get_drvdata(rdev); > + > + ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val); > + if (ret != 0) { > + dev_err(&rdev->dev, > + "Failed to get mt6357 Buck %s vsel reg: %d\n", > + info->desc.name, ret); > + return ret; > + } > + > + regval &= info->da_vsel_mask; > + regval >>= ffs(info->da_vsel_mask) - 1; > + > + return regval; > +} If I read this right, the device has separate register(s) for writing and reading the voltage? I wonder if this is a completely unique setup? If this is not unique, then it might be worth adding another field for 'vsel_get' register and a flag in regulator desc - and modify the generic regmap helpers to handle this in common code if the special register? Not sure if this HW design is common enough to warrant the added confusion though. You and Mark may have more insight. > + > +static const struct linear_range buck_volt_range1[] = { > + REGULATOR_LINEAR_RANGE(518750, 0, 0x7f, 6250), > +}; > + > +static const struct linear_range buck_volt_range2[] = { > + REGULATOR_LINEAR_RANGE(500000, 0, 0x7f, 6250), > +}; > + > +static const struct linear_range buck_volt_range3[] = { > + REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000), > +}; > + > +static const struct linear_range buck_volt_range4[] = { > + REGULATOR_LINEAR_RANGE(1200000, 0, 0x7f, 12500), > +}; I am unsure if we should aim for dropping the REGULATOR_LINEAR_RANGE() and using the LINEAR_RANGE(). If yes, then it might simplify things if new drivers used LINEAR_RANGE() from the day 1. If we don't, then it makes sense to keep consistently using REGULATOR_LINEAR_RANGE() for all of the drivers. I am not sure which way is the right way. > +static int mt6357_regulator_probe(struct platform_device *pdev) > +{ > + struct mt6397_chip *mt6357 = dev_get_drvdata(pdev->dev.parent); I am unsure what data do you need from the parent. If it is just the regmap / device-tree node / device, then it does not (in my opinion) really warrant using parent's drvdata. One can often get away with the dev_get_regmap(pdev->dev.parent, NULL). Anyways, the driver looks good to me. Yours, -- Matti Vaittinen -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~