MLK-16204-1 nvmem: add imx-scu-ocotp driver
authorPeng Fan <peng.fan@nxp.com>
Thu, 17 Aug 2017 09:06:21 +0000 (17:06 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
commit9a88300d3f4687a48ddfa9b5510ccb798fe1d48b
tree5280591e54d6bdf8f1f668f1832cca023390ed89
parent49b832af518259ea2aba3c61ff45dd49c877d7d8
MLK-16204-1 nvmem: add imx-scu-ocotp driver

Add imx-scu-ocotp driver to support i.MX8QM/QXP.

The usage, add an entry in ocotp node, such as the test_1 entry:
ocotp: ocotp {
               #address-cells = <1>;
               #size-cells = <1>;
               compatible = "fsl,imx8qm-ocotp", "syscon";

               test_1: test_1@40 {
                       reg = <0x41 0x8>;
                       bits = <4 40>;
               };
       };

Then in your device node, add this:
       node: node {
        .....
                nvmem-cells = <&test_1>;
                nvmem-cell-names = "test_1";
       };

Then in your driver, using the following piece code:

       +#include <linux/nvmem-consumer.h>

       struct nvmem_cell *cell;
       u8 *val;
       size_t len;
       int i;
       cell = devm_nvmem_cell_get(&pdev->dev, "test_1");
       if (IS_ERR(cell)) {
               if (PTR_ERR(cell) == -EPROBE_DEFER)
                       return -EPROBE_DEFER;
       }
       val = nvmem_cell_read(cell, &len);

The val points the contents that you need.

After shutdown or driver remove, use this:
       devm_nvmem_cell_put(&pdev->dev, cell);

Note: we not reuse the imx-ocotp driver, because mix scu api with
legacy code will cost many maintenance efforts. When we have common
api support, we could merge the two.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
drivers/nvmem/Kconfig
drivers/nvmem/Makefile
drivers/nvmem/imx-scu-ocotp.c [new file with mode: 0644]