Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3274739iob; Mon, 16 May 2022 17:52:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXrNk0Ek/mufvrZAZ1ia35qkiRXSGfhGsDMWX8Dl0pEYbEMznZTvgZD/w67FWklTqvCAZa X-Received: by 2002:a17:903:288:b0:15f:a13:dfd5 with SMTP id j8-20020a170903028800b0015f0a13dfd5mr20649398plr.55.1652748762640; Mon, 16 May 2022 17:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652748762; cv=none; d=google.com; s=arc-20160816; b=UETxNMRgyELunW3/jbZx3Zvee02SdeRULDKixA1aS82ghxUFihlr1WOKOWx4J+i63o QNlPSJPOeWU5zj6vIhjrMwN2xbGWYOiu0sPqi7vDl78K4nrZKrw/WchIYILkZ4MhJ3Xk flYOLEq8h5tejDhWNcOwQaQMB9psFt45eFj3l8vMXHBY4v0dhrB5rIhj8HEdmWpcyuzc L8OXCJq4ER99cvFhuXMfzqfIZFNCF0OshGIwpRGpCKMyyyK1xDY6lDqC9t2lMTeCGDF3 vgjtscPLJdoW9osNvdJN5CRDf4gu+79rGi8c39Ezk2f4mfL5esxV8RHwKZUHMcLpxsRx S8JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=V4GahDx2+UnkOWB2njUSr2HS/Dy+k/intVgLF5yRzLM=; b=meoOIP0i1UqZtyQM/Cm7jgoS5LOLyeT3XQRomjAiNImVRFTctFGHpMND+KIQstgSsi zOuNJeR3sT/LNUQ7K5pbTK4NqIvHFeRFVtRv0QQc654ZF9BhMIYb5TVhMDTpxV2X9maj eOWPBEedplvoT/Jmqap4QNt7PASkr2DKntPVzeD5LPaTkgXuSVth02dv7O+iu6+m7HEw w9EQ95IDm3eM6a56ZCjHi769RC5cqpu1FVMIK28BHI1V2T3wCa6tfwJccXjnB+neMAKt ezTpNA/pRwNaeASmJjyD/Jmr5yVv6XsFfaXW+JW5H8t66NdkxFNCkdAGrog5YRLeO8Oo PX0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QP66kbFa; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk1-20020a17090b4a0100b001d23d1efc22si1169041pjb.1.2022.05.16.17.52.31; Mon, 16 May 2022 17:52:42 -0700 (PDT) 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=@chromium.org header.s=google header.b=QP66kbFa; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345247AbiEPTDN (ORCPT + 99 others); Mon, 16 May 2022 15:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345238AbiEPTDL (ORCPT ); Mon, 16 May 2022 15:03:11 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5452F3EB82 for ; Mon, 16 May 2022 12:03:10 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id y20-20020a056830071400b00606a2ebd91bso10683736ots.5 for ; Mon, 16 May 2022 12:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to:cc; bh=V4GahDx2+UnkOWB2njUSr2HS/Dy+k/intVgLF5yRzLM=; b=QP66kbFap0dA2vLnSmHdxk2AoXOTdqe7hb6v4tnSQW8iqhqaz7qNKz9OLoio6gX7Cj BqXaUE6kVM+ivPQf2VZUtfYbN1PZrrSOWIiRlwwYRuSAXD8IQ3tIUVtR+4L/ETIV280S M94XYinqs+gK3IV95dVEbmtTOSLiN0/w2ovvE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to:cc; bh=V4GahDx2+UnkOWB2njUSr2HS/Dy+k/intVgLF5yRzLM=; b=y39n9/LdteQWFQwvL9I64BnTTr+8Ue/hwZuZc4FGgaPz9IqmiSnKx7TpsbSZ0Sk5wU 2NmWbZXDHfDUq79ANgdXRTwjxh6dnyv/A9yfNOyP5SjwWI/itbwNMW7hOMtsf/MzjuiP 9syqnfrIuKoI/TJvUecDSJ1GaC5ig7GEQW66Ljj0ZUxG/N8sOgT0Kj73qXU4U3F5VF5X 7KKJvPTExJcdO+1b+Zj53tBPdjrAwMtsVf6mp6+LdX0urldwNKyhDEkko6wN2ZUdwjpL x6SLlal9T6+5ni3GU41PdBK0NsAt1RTboh6K7wbmOij1fqFF2KlOD5gqjxmjO2t1DrGy XHzA== X-Gm-Message-State: AOAM5311KyemcLGWTYi3L5KKI3VYTFZ8Zsd3wN37/gSRZuonpGzCVpq/ si1ft4J3/SUkoqmC+s87XzLLt7oKUZM+l3y8kl+Hpg== X-Received: by 2002:a05:6830:13ce:b0:606:702b:87f0 with SMTP id e14-20020a05683013ce00b00606702b87f0mr6480452otq.159.1652727789630; Mon, 16 May 2022 12:03:09 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 16 May 2022 12:03:08 -0700 MIME-Version: 1.0 In-Reply-To: <1652275113-10277-8-git-send-email-quic_c_skakit@quicinc.com> References: <1652275113-10277-1-git-send-email-quic_c_skakit@quicinc.com> <1652275113-10277-8-git-send-email-quic_c_skakit@quicinc.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Mon, 16 May 2022 12:03:08 -0700 Message-ID: Subject: Re: [PATCH V12 7/9] regulator: Add a regulator driver for the PM8008 PMIC To: Bjorn Andersson , Rob Herring , Satya Priya Cc: Lee Jones , Liam Girdwood , Mark Brown , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, quic_collinsd@quicinc.com, quic_subbaram@quicinc.com, quic_jprakash@quicinc.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Quoting Satya Priya (2022-05-11 06:18:31) > diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c > new file mode 100644 > index 0000000..0361f02 > --- /dev/null > +++ b/drivers/regulator/qcom-pm8008-regulator.c > @@ -0,0 +1,221 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* Copyright (c) 2022, The Linux Foundation. All rights reserved. */ > + > +#include > +#include > +#include > +#include > +#include Is this include used? > +#include > +#include > +#include > +#include > +#include Is this include used? > + > +#define VSET_STEP_MV 8 > +#define VSET_STEP_UV (VSET_STEP_MV * 1000) > + > +#define LDO_ENABLE_REG(base) ((base) + 0x46) > +#define ENABLE_BIT BIT(7) > + > +#define LDO_VSET_LB_REG(base) ((base) + 0x40) > + > +#define LDO_STEPPER_CTL_REG(base) ((base) + 0x3b) > +#define DEFAULT_VOLTAGE_STEPPER_RATE 38400 > +#define STEP_RATE_MASK GENMASK(1, 0) > + > +struct pm8008_regulator_data { > + const char *name; > + const char *supply_name; > + int min_uv; > + int max_uv; > + int min_dropout_uv; > + const struct linear_range *voltage_range; > +}; > + > +struct pm8008_regulator { > + struct device *dev; > + struct regmap *regmap; > + struct regulator_desc rdesc; > + u16 base; > + int step_rate; > + int voltage_selector; > +}; > + > +static const struct linear_range nldo_ranges[] = { > + REGULATOR_LINEAR_RANGE(528000, 0, 122, 8000), > +}; > + > +static const struct linear_range pldo_ranges[] = { > + REGULATOR_LINEAR_RANGE(1504000, 0, 237, 8000), > +}; > + > +static const struct pm8008_regulator_data reg_data[] = { > + /* name parent min_uv max_uv headroom_uv voltage_range */ > + { "ldo1", "vdd_l1_l2", 528000, 1504000, 225000, nldo_ranges, }, > + { "ldo2", "vdd_l1_l2", 528000, 1504000, 225000, nldo_ranges, }, > + { "ldo3", "vdd_l3_l4", 1504000, 3400000, 300000, pldo_ranges, }, > + { "ldo4", "vdd_l3_l4", 1504000, 3400000, 300000, pldo_ranges, }, > + { "ldo5", "vdd_l5", 1504000, 3400000, 200000, pldo_ranges, }, > + { "ldo6", "vdd_l6", 1504000, 3400000, 200000, pldo_ranges, }, > + { "ldo7", "vdd_l7", 1504000, 3400000, 200000, pldo_ranges, }, > +}; > + > +static int pm8008_regulator_get_voltage(struct regulator_dev *rdev) > +{ > + struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev); > + > + return pm8008_reg->voltage_selector; > +} > + > +static inline int pm8008_write_voltage(struct pm8008_regulator *pm8008_reg, > + int mV) > +{ > + __le16 vset_raw; > + > + vset_raw = cpu_to_le16(mV); > + > + return regmap_bulk_write(pm8008_reg->regmap, > + LDO_VSET_LB_REG(pm8008_reg->base), > + (const void *)&vset_raw, sizeof(vset_raw)); Does sparse complain about casting away __le16? > +} > + > +static int pm8008_regulator_set_voltage_time(struct regulator_dev *rdev, > + int old_uV, int new_uv) > +{ > + struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev); > + > + return DIV_ROUND_UP(abs(new_uv - old_uV), pm8008_reg->step_rate); > +} > +