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

rk3568 :) I verified the work with this CPU.

пт, 6 окт. 2023 г. в 13:04, Ahmad Fatoum <a.fatoum@pengutronix.de>:
>
> 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 |
>



  reply	other threads:[~2023-10-06 10:22 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 ` [PATCH 1/2] nvmem: Add Rockchip OTP controller driver Ahmad Fatoum
2023-10-06 10:20   ` Alexander Shiyan [this message]
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=CAP1tNvSL9p4HhvVN-yhVwDtOTCdJ8hoXomU-BinaR_P2VeSROA@mail.gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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