From: Krzysztof Kozlowski <krzk@kernel.org>
To: ChiYuan Huang <u0084500@gmail.com>
Cc: Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
cy_huang <cy_huang@richtek.com>,
gene_chen@richtek.com, lkml <linux-kernel@vger.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>
Subject: Re: [PATCH 2/2] regulator: rt5759: Add support for Richtek RT5759 DCDC converter
Date: Fri, 25 Mar 2022 15:47:35 +0100 [thread overview]
Message-ID: <e4a15ceb-c013-96be-48d1-e65267400463@kernel.org> (raw)
In-Reply-To: <CADiBU39RGQj1-+yK18mZf3MR78KACKqb2kAxkCFKGXKpJ6Nqxw@mail.gmail.com>
On 25/03/2022 15:10, ChiYuan Huang wrote:
> Krzysztof Kozlowski <krzk@kernel.org> 於 2022年3月25日 週五 下午8:17寫道:
>>
>> On 25/03/2022 02:06, cy_huang wrote:
>>> From: ChiYuan Huang <cy_huang@richtek.com>
>>>
>>> Add support for Richtek RT5759 high-performance DCDC converter.
>>>
>>> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
>>> ---
>>> drivers/regulator/Kconfig | 10 +
>>> drivers/regulator/Makefile | 1 +
>>> drivers/regulator/rt5759-regulator.c | 372 +++++++++++++++++++++++++++++++++++
>>> 3 files changed, 383 insertions(+)
>>> create mode 100644 drivers/regulator/rt5759-regulator.c
>>>
>>
>> (...)
>>
>>> +static int rt5759_init_device_property(struct rt5759_priv *priv)
>>> +{
>>> + unsigned int val = 0;
>>> + bool wdt_enable;
>>> +
>>> + /*
>>> + * Only RT5759A support external watchdog input
>>> + */
>>> + if (priv->chip_type != CHIP_TYPE_RT5759A)
>>> + return 0;
>>> +
>>> + wdt_enable = device_property_read_bool(priv->dev,
>>> + "richtek,watchdog-enable");
>>> + if (wdt_enable)
>>
>> No need for separate wdt_enable variable.
>>
> Ack in next.
>>> + val = RT5759A_WDTEN_MASK;
>>> +
>>> + return regmap_update_bits(priv->regmap, RT5759A_REG_WDTEN,
>>> + RT5759A_WDTEN_MASK, val);
>>> +}
>>> +
>>> +static int rt5759_manufacturer_check(struct rt5759_priv *priv)
>>> +{
>>> + unsigned int vendor;
>>> + int ret;
>>> +
>>> + ret = regmap_read(priv->regmap, RT5759_REG_VENDORINFO, &vendor);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + if (vendor != RT5759_MANUFACTURER_ID) {
>>> + dev_err(priv->dev, "vendor info not correct (%d)\n", vendor);
>>> + return -EINVAL;
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static bool rt5759_is_accessible_reg(struct device *dev, unsigned int reg)
>>> +{
>>> + struct rt5759_priv *priv = dev_get_drvdata(dev);
>>> +
>>> + if (reg <= RT5759_REG_DCDCSET)
>>> + return true;
>>> +
>>> + if (priv->chip_type == CHIP_TYPE_RT5759A && reg == RT5759A_REG_WDTEN)
>>> + return true;
>>> +
>>> + return false;
>>> +}
>>> +
>>> +static const struct regmap_config rt5759_regmap_config = {
>>> + .reg_bits = 8,
>>> + .val_bits = 8,
>>> + .max_register = RT5759A_REG_WDTEN,
>>> + .readable_reg = rt5759_is_accessible_reg,
>>> + .writeable_reg = rt5759_is_accessible_reg,
>>> +};
>>> +
>>> +static int rt5759_probe(struct i2c_client *i2c)
>>> +{
>>> + struct rt5759_priv *priv;
>>> + int ret;
>>> +
>>> + priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
>>> + if (!priv)
>>> + return -ENOMEM;
>>> +
>>> + priv->dev = &i2c->dev;
>>> + priv->chip_type = (unsigned long)of_device_get_match_data(&i2c->dev);
>>> + i2c_set_clientdata(i2c, priv);
>>> +
>>> + priv->regmap = devm_regmap_init_i2c(i2c, &rt5759_regmap_config);
>>> + if (IS_ERR(priv->regmap)) {
>>> + ret = PTR_ERR(priv->regmap);
>>> + dev_err(&i2c->dev, "Failed to allocate regmap (%d)\n", ret);
>>> + return ret;
>>> + }
>>> +
>>> + ret = rt5759_manufacturer_check(priv);
>>> + if (ret) {
>>> + dev_err(&i2c->dev, "Failed to check device (%d)\n", ret);
>>> + return ret;
>>> + }
>>> +
>>> + ret = rt5759_init_device_property(priv);
>>> + if (ret) {
>>> + dev_err(&i2c->dev, "Failed to init device (%d)\n", ret);
>>> + return ret;
>>> + }
>>> +
>>> + return rt5759_regulator_register(priv);
>>> +}
>>> +
>>> +static const struct of_device_id __maybe_unused rt5759_device_table[] = {
>>
>> I don't think this can be __maybe_unused. It is always referenced via
>> of_match_table, isn't it?
>>
> I think it can declared as '__maybe_unused'.
> If 'of_device_id' is unused, then in probe stage,
> 'of_device_get_match_data' will return NULL.
But your of_device_id cannot be unused. It is always referenced.
> priv->chip_type will get zero as the return value. And it will be
> treated as rt5759, not rt5759a.
> The difference between these two are only watchdog function supported or not.
Best regards,
Krzysztof
next prev parent reply other threads:[~2022-03-25 14:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 1:06 [PATCH 0/2] Add Richtek RT5759 buck converter support cy_huang
2022-03-25 1:06 ` [PATCH 1/2] dt-bindings: regulator: Add binding for Richtek RT5759 DCDC converter cy_huang
2022-03-25 12:14 ` Krzysztof Kozlowski
2022-03-25 13:44 ` ChiYuan Huang
2022-03-25 14:46 ` Krzysztof Kozlowski
2022-03-25 14:53 ` ChiYuan Huang
2022-03-25 1:06 ` [PATCH 2/2] regulator: rt5759: Add support " cy_huang
2022-03-25 12:17 ` Krzysztof Kozlowski
2022-03-25 14:10 ` ChiYuan Huang
2022-03-25 14:47 ` Krzysztof Kozlowski [this message]
2022-03-25 14:59 ` ChiYuan Huang
2022-03-25 15:37 ` Krzysztof Kozlowski
2022-03-25 15:50 ` ChiYuan Huang
2022-03-25 15:55 ` Krzysztof Kozlowski
2022-03-25 16:05 ` Mark Brown
2022-03-25 16:08 ` Krzysztof Kozlowski
2022-03-26 0:58 ` ChiYuan Huang
2022-03-26 1:07 ` Mark Brown
2022-03-26 7:55 ` ChiYuan Huang
2022-03-26 8:13 ` Krzysztof Kozlowski
2022-03-26 8:24 ` ChiYuan Huang
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=e4a15ceb-c013-96be-48d1-e65267400463@kernel.org \
--to=krzk@kernel.org \
--cc=broonie@kernel.org \
--cc=cy_huang@richtek.com \
--cc=devicetree@vger.kernel.org \
--cc=gene_chen@richtek.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=u0084500@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