mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>,
	barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] nvmem: Add Rockchip OTP controller driver
Date: Fri, 6 Oct 2023 12:04:05 +0200	[thread overview]
Message-ID: <4820f5dc-6e80-2970-864c-852739f4163e@pengutronix.de> (raw)
In-Reply-To: <20231006054812.4343-1-eagle.alexander923@gmail.com>

Hi Alexander,

On 06.10.23 07:48, Alexander Shiyan wrote:
> +static __maybe_unused const struct of_device_id rockchip_otp_match[] = {
> +	{
> +		.compatible = "rockchip,px30-otp",
> +		.data = &px30_data,
> +	},
> +	{
> +		.compatible = "rockchip,rk3308-otp",
> +		.data = &px30_data,
> +	},
> +	{
> +		.compatible = "rockchip,rk3568-otp",
> +		.data = &rk3568_data,
> +	},
> +	{
> +		.compatible = "rockchip,rk3588-otp",
> +		.data = &rk3588_data,
> +	},

Just out of curiosity: Which SoC of these are you using?

Cheers,
Ahmad

> +	{ /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, rockchip_otp_match);
> +
> +static int rockchip_otp_probe(struct device *dev)
> +{
> +	struct rockchip_otp *otp;
> +	const struct rockchip_data *data;
> +	struct nvmem_device *nvmem;
> +	struct resource *res;
> +	int ret, i;
> +
> +	data = of_device_get_match_data(dev);
> +	if (!data)
> +		return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
> +
> +	otp = kzalloc(sizeof(*otp), GFP_KERNEL);
> +	if (!otp)
> +		return -ENOMEM;
> +
> +	res = dev_request_mem_resource(dev, 0);
> +	if (IS_ERR(res)) {
> +		ret = PTR_ERR(res);
> +		goto err_free;
> +	}
> +
> +	otp->data = data;
> +	otp->dev = dev;
> +	otp->base = IOMEM(res->start);
> +
> +	otp->clks = kcalloc(data->num_clks, sizeof(*otp->clks), GFP_KERNEL);
> +	if (!otp->clks) {
> +		ret = -ENOMEM;
> +		goto err_free;
> +	}
> +
> +	for (i = 0; i < data->num_clks; ++i)
> +		otp->clks[i].id = data->clks[i];
> +
> +	ret = clk_bulk_get_optional(dev, data->num_clks, otp->clks);
> +	if (ret)
> +		goto err_clk;
> +
> +	otp->rst = reset_control_get(dev, NULL);
> +	if (IS_ERR(otp->rst)) {
> +		ret = PTR_ERR(otp->rst);
> +		goto err_rst;
> +	}
> +
> +	otp_config.size = data->size;
> +	otp_config.priv = otp;
> +	otp_config.dev = dev;
> +
> +	nvmem = nvmem_register(&otp_config);
> +	if (!IS_ERR(nvmem))
> +		return 0;
> +
> +	ret = PTR_ERR(nvmem);
> +
> +	reset_control_put(otp->rst);
> +
> +err_rst:
> +	clk_bulk_put_all(data->num_clks, otp->clks);
> +
> +err_clk:
> +	kfree(otp->clks);
> +
> +err_free:
> +	kfree(otp);
> +
> +	return ret;
> +}
> +
> +static struct driver rockchip_otp_driver = {
> +	.name	= "rockchip-otp",
> +	.probe	= rockchip_otp_probe,
> +	.of_compatible = DRV_OF_COMPAT(rockchip_otp_match),
> +};
> +device_platform_driver(rockchip_otp_driver);

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




  parent reply	other threads:[~2023-10-06 10:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06  5:48 Alexander Shiyan
2023-10-06  5:48 ` [PATCH 2/2] dts: rk356x: Add devicetree node for OTP Alexander Shiyan
2023-10-06 10:04 ` Ahmad Fatoum [this message]
2023-10-06 10:20   ` [PATCH 1/2] nvmem: Add Rockchip OTP controller driver Alexander Shiyan
2023-10-06 11:52 ` Sascha Hauer

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=4820f5dc-6e80-2970-864c-852739f4163e@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=eagle.alexander923@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