public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: cy_huang <u0084500@gmail.com>, broonie@kernel.org, robh+dt@kernel.org
Cc: lgirdwood@gmail.com, cy_huang@richtek.com, gene_chen@richtek.com,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] regulator: rt5759: Add support for Richtek RT5759 DCDC converter
Date: Fri, 25 Mar 2022 13:17:10 +0100	[thread overview]
Message-ID: <d2b431f8-9197-4a42-4ee2-4e771e20e0aa@kernel.org> (raw)
In-Reply-To: <1648170401-6351-3-git-send-email-u0084500@gmail.com>

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.

> +		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?

> +	{ .compatible = "richtek,rt5759", .data = (void *)CHIP_TYPE_RT5759 },
> +	{ .compatible = "richtek,rt5759a", .data = (void *)CHIP_TYPE_RT5759A },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, rt5759_device_table);
> +
> +static struct i2c_driver rt5759_driver = {
> +	.driver = {
> +		.name = "rt5759",
> +		.of_match_table = rt5759_device_table,
> +	},
> +	.probe_new = rt5759_probe,
> +};
> +module_i2c_driver(rt5759_driver);
> +
> +MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>");
> +MODULE_DESCRIPTION("Richtek RT5759 Regulator Driver");
> +MODULE_LICENSE("GPL v2");


Best regards,
Krzysztof

  reply	other threads:[~2022-03-25 12:17 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 [this message]
2022-03-25 14:10     ` ChiYuan Huang
2022-03-25 14:47       ` Krzysztof Kozlowski
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=d2b431f8-9197-4a42-4ee2-4e771e20e0aa@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