]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/misc/mxc_ocotp.c
arm: mxs: ocotp: disable OCOTP clock after access is finished
[karo-tx-uboot.git] / drivers / misc / mxc_ocotp.c
index 3de1245699626aa4429dba9462ef398ef77bd63c..4f222e6f991a28bf5418ba42e165eb67ee22ebd1 100644 (file)
@@ -60,7 +60,7 @@ static int prepare_access(struct ocotp_regs **regs, u32 bank, u32 word,
        *regs = (struct ocotp_regs *)OCOTP_BASE_ADDR;
 
        if (bank >= ARRAY_SIZE((*regs)->bank) ||
-                       word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) >> 2 ||
+                       word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) ||
                        !assert) {
                printf("mxc_ocotp %s(): Invalid argument\n", caller);
                return -EINVAL;
@@ -80,7 +80,6 @@ static int finish_access(struct ocotp_regs *regs, const char *caller)
 
        err = !!(readl(&regs->ctrl) & BM_CTRL_ERROR);
        clear_error(regs);
-
        enable_ocotp_clk(0);
 
        if (err) {
@@ -122,8 +121,8 @@ static void set_timing(struct ocotp_regs *regs)
        relax = DIV_ROUND_UP(ipg_clk * BV_TIMING_RELAX_NS, 1000000000) - 1;
        strobe_read = DIV_ROUND_UP(ipg_clk * BV_TIMING_STROBE_READ_NS,
                                        1000000000) + 2 * (relax + 1) - 1;
-       strobe_prog = DIV_ROUND(ipg_clk * BV_TIMING_STROBE_PROG_US, 1000000) +
-                       2 * (relax + 1) - 1;
+       strobe_prog = DIV_ROUND_CLOSEST(ipg_clk * BV_TIMING_STROBE_PROG_US,
+                                               1000000) + 2 * (relax + 1) - 1;
 
        timing = BF(strobe_read, TIMING_STROBE_READ) |
                        BF(relax, TIMING_RELAX) |