From: Stephen Boyd <swboyd@chromium.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Satya Priya <quic_c_skakit@quicinc.com>
Cc: Lee Jones <lee.jones@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
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
Subject: Re: [PATCH V12 7/9] regulator: Add a regulator driver for the PM8008 PMIC
Date: Mon, 16 May 2022 12:03:08 -0700 [thread overview]
Message-ID: <CAE-0n51JeC7oobCYNCJ-rOi3n_FVPBjz7yFmtwKEDeqWcX0vFw@mail.gmail.com> (raw)
In-Reply-To: <1652275113-10277-8-git-send-email-quic_c_skakit@quicinc.com>
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 <linux/device.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/qcom_pm8008.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
Is this include used?
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/of_regulator.h>
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);
> +}
> +
next prev parent reply other threads:[~2022-05-16 19:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 13:18 [PATCH V12 0/9] Add Qualcomm Technologies, Inc. PM8008 regulator driver Satya Priya
2022-05-11 13:18 ` [PATCH V12 1/9] dt-bindings: mfd: pm8008: Add reset-gpios Satya Priya
2022-05-11 13:18 ` [PATCH V12 2/9] dt-bindings: mfd: pm8008: Change the address cells Satya Priya
2022-05-17 17:54 ` Rob Herring
2022-05-11 13:18 ` [PATCH V12 3/9] dt-bindings: mfd: pm8008: Add regulators for pm8008 Satya Priya
2022-05-17 17:55 ` Rob Herring
2022-05-11 13:18 ` [PATCH V12 4/9] mfd: pm8008: Add reset-gpios Satya Priya
2022-05-11 13:18 ` [PATCH V12 5/9] mfd: pm8008: Remove the regmap member from pm8008_data struct Satya Priya
2022-05-11 13:18 ` [PATCH V12 6/9] mfd: pm8008: Use i2c_new_dummy_device() API Satya Priya
2022-05-16 18:56 ` Stephen Boyd
2022-05-11 13:18 ` [PATCH V12 7/9] regulator: Add a regulator driver for the PM8008 PMIC Satya Priya
2022-05-16 12:12 ` Dan Carpenter
2022-05-16 19:03 ` Stephen Boyd [this message]
2022-05-19 12:06 ` Satya Priya Kakitapalli (Temp)
2022-05-11 13:18 ` [PATCH V12 8/9] arm64: dts: qcom: pm8008: Add base dts file Satya Priya
2022-05-11 13:18 ` [PATCH V12 9/9] arm64: dts: qcom: sc7280: Add pm8008 support for sc7280-idp Satya Priya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAE-0n51JeC7oobCYNCJ-rOi3n_FVPBjz7yFmtwKEDeqWcX0vFw@mail.gmail.com \
--to=swboyd@chromium.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_c_skakit@quicinc.com \
--cc=quic_collinsd@quicinc.com \
--cc=quic_jprakash@quicinc.com \
--cc=quic_subbaram@quicinc.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).