From: Jonathan Cameron <jic23@kernel.org>
To: 杨明金 <magicyangmingjin@gmail.com>
Cc: Mingjin Yang <mingjin.yang@unisoc.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Ling_Ling.Xu@unisoc.com, Jinfeng.Lin1@unisoc.com,
Yangbin.Li@unisoc.com, Jiansheng.Wu@unisoc.com,
Orson Zhai <orsonzhai@gmail.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V0 2/2] iio: adc: sprd_pmic_adc: Add support for UMP serise pmic adc
Date: Sun, 3 Sep 2023 12:14:37 +0100 [thread overview]
Message-ID: <20230903121437.520e5da3@jic23-huawei> (raw)
In-Reply-To: <CAKJtOf5chsyPrnMZGv32YFvxG1x5cDtBQmzk7wRqCn7C2+cB=g@mail.gmail.com>
On Wed, 30 Aug 2023 15:15:12 +0800
杨明金 <magicyangmingjin@gmail.com> wrote:
> Jonathan Cameron <jic23@kernel.org> 于2023年8月28日周一 23:56写道:
> >
Hi,
Please crop replies to relevant part only. Hopefully I found it!
> > > +static int sprd_adc_enable(struct sprd_adc_data *data, int channel)
> > > +{
> > > + int ret = 0;
> > > + u32 reg_read = 0;
> > > +
> > > + if (data->pm_data.clk_regmap) {
> > > + ret = regmap_update_bits(data->pm_data.clk_regmap, data->pm_data.clk_reg,
> > > + data->pm_data.clk_reg_mask,
> > > + data->pm_data.clk_reg_mask);
> > > + ret |= regmap_read(data->pm_data.clk_regmap, data->pm_data.clk_reg, ®_read);
> > > + if (ret) {
> > > + dev_err(data->dev, "failed to enable clk26m, channel %d\n", channel);
> > > + return ret;
> > > + }
> > > + dev_dbg(data->dev, "enable clk26m: ch %d, reg_read 0x%x\n", channel, reg_read);
> >
> > Directly accessing the regmap of a clock seems unusual. Why not provide generic clock interfaces
> > for this?
>
> This register is used to vote to enable/disable the pmic 26m clk which
> is provided to modules like audio, typec and adc.
> Therefore, this clk cannot be disabled or enabled directly.
clk_enable() and friends support reference counted enable and disable
so I don't understand why this needs something unusual.
>
> > > +static int sprd_adc_probe(struct platform_device *pdev)
> > > +{
> > > + struct device_node *np = pdev->dev.of_node;
> > > + struct sprd_adc_data *sprd_data;
> > > + const struct sprd_adc_variant_data *pdata;
> > > + struct iio_dev *indio_dev;
> > > + int ret;
> > > +
> > > + pdata = of_device_get_match_data(&pdev->dev);
> >
> > device_get_match_data()
> >
> >
> > > + if (!pdata) {
> > > + dev_err(&pdev->dev, "No matching driver data found\n");
> > > + return -EINVAL;
> > > + }
> > > +
> > > + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*sprd_data));
> > > + if (!indio_dev)
> > > + return -ENOMEM;
> > > +
> > > + sprd_data = iio_priv(indio_dev);
> > > +
> > > + sprd_data->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> > > + if (!sprd_data->regmap) {
> > > + dev_err(&pdev->dev, "failed to get ADC regmap\n");
> > > + return -ENODEV;
> > > + }
> > > +
> > > + ret = of_property_read_u32(np, "reg", &sprd_data->base);
> >
> > Even though some elements of this (of_hwspin...) don't have generic firmware
> > interfaces, I would prefer to see those from linux/property.h used
> > wherever possible. It will take us a long time to make that a subsystem
> > wide change, but good not to have more unnecessary instances of device tree
> > specific property reading.
>
> Sorry, I don't understand what needs to be modified. Can you provide
> more information or give an example?
> Do you mean that the "reg" property reading is unnecessary?
No. Where possibly use
device_property_read_u32(dev, "reg".. etc
and similar functions from
include/linux/property.h rather than device tree specific ones.
The generic property handling deals with various different types of firmware
without needing drivers to be aware of it.
Some elements that you need here do not have generic property handling so
for those you will need to continue using the of_ variants.
Note that this is to support long term move of everything to the generic
firmware framework. Even if we drivers in IIO etc that are really device
tree only there are benefits for maintenance in using one framework
for all drivers. As some IIO drivers do support other firmware types
(ACPI for example) the generic version is the preferred choice.
Thanks,
Jonathan
next prev parent reply other threads:[~2023-09-03 11:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 8:02 [PATCH V0 0/2] Add support for UMP serise pmic adc Mingjin Yang
2023-08-16 8:02 ` [PATCH V0 1/2] dt-bindings: iio: adc: Add support for ump518 " Mingjin Yang
2023-08-16 14:44 ` Conor Dooley
2023-08-28 14:40 ` Jonathan Cameron
2023-08-16 8:02 ` [PATCH V0 2/2] iio: adc: sprd_pmic_adc: Add support for UMP serise " Mingjin Yang
2023-08-16 14:07 ` kernel test robot
2023-08-28 14:38 ` Jonathan Cameron
2023-08-28 15:57 ` Jonathan Cameron
2023-08-30 7:15 ` 杨明金
2023-09-03 11:14 ` Jonathan Cameron [this message]
2023-09-05 2:59 ` 杨明金
2023-09-10 13:57 ` Jonathan Cameron
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=20230903121437.520e5da3@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jiansheng.Wu@unisoc.com \
--cc=Jinfeng.Lin1@unisoc.com \
--cc=Ling_Ling.Xu@unisoc.com \
--cc=Yangbin.Li@unisoc.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=magicyangmingjin@gmail.com \
--cc=mingjin.yang@unisoc.com \
--cc=orsonzhai@gmail.com \
--cc=robh+dt@kernel.org \
--cc=zhang.lyra@gmail.com \
/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).