Lines Matching refs:regs
157 static void wait_busy(struct ocotp_regs *regs, unsigned int delay_us) in wait_busy() argument
159 while (readl(®s->ctrl) & BM_CTRL_BUSY) in wait_busy()
163 static void clear_error(struct ocotp_regs *regs) in clear_error() argument
165 writel(BM_CTRL_ERROR, ®s->ctrl_clr); in clear_error()
168 static int prepare_access(struct ocotp_regs **regs, u32 bank, u32 word, in prepare_access() argument
171 *regs = (struct ocotp_regs *)OCOTP_BASE_ADDR; in prepare_access()
174 word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) >> 2 || in prepare_access()
182 word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) >> 3) { in prepare_access()
190 wait_busy(*regs, 1); in prepare_access()
191 clear_error(*regs); in prepare_access()
196 static int finish_access(struct ocotp_regs *regs, const char *caller) in finish_access() argument
200 err = !!(readl(®s->ctrl) & BM_CTRL_ERROR); in finish_access()
201 clear_error(regs); in finish_access()
205 writel(1, ®s->pdn); in finish_access()
215 static int prepare_read(struct ocotp_regs **regs, u32 bank, u32 word, u32 *val, in prepare_read() argument
218 return prepare_access(regs, bank, word, val != NULL, caller); in prepare_read()
223 struct ocotp_regs *regs; in fuse_read() local
228 ret = prepare_read(®s, bank, word, val, __func__); in fuse_read()
235 *val = readl(®s->bank[phy_bank].fuse_regs[phy_word << 2]); in fuse_read()
238 if (readl(®s->out_status) & BM_OUT_STATUS_DED) { in fuse_read()
239 writel(BM_OUT_STATUS_DED, ®s->out_status_clr); in fuse_read()
244 return finish_access(regs, __func__); in fuse_read()
248 static void set_timing(struct ocotp_regs *regs) in set_timing() argument
262 clrsetbits_le32(®s->timing, BM_TIMING_FSOURCE | BM_TIMING_PROG, in set_timing()
266 static void set_timing(struct ocotp_regs *regs) in set_timing() argument
272 static void set_timing(struct ocotp_regs *regs) in set_timing() argument
290 clrsetbits_le32(®s->timing, BM_TIMING_STROBE_READ | BM_TIMING_RELAX | in set_timing()
295 static void setup_direct_access(struct ocotp_regs *regs, u32 bank, u32 word, in setup_direct_access() argument
313 set_timing(regs); in setup_direct_access()
314 clrsetbits_le32(®s->ctrl, BM_CTRL_WR_UNLOCK | BM_CTRL_ADDR, in setup_direct_access()
321 struct ocotp_regs *regs; in fuse_sense() local
324 ret = prepare_read(®s, bank, word, val, __func__); in fuse_sense()
328 setup_direct_access(regs, bank, word, false); in fuse_sense()
329 writel(BM_READ_CTRL_READ_FUSE, ®s->read_ctrl); in fuse_sense()
330 wait_busy(regs, 1); in fuse_sense()
332 *val = readl((®s->read_fuse_data0) + (word << 2)); in fuse_sense()
334 *val = readl(®s->read_fuse_data); in fuse_sense()
338 if (readl(®s->out_status) & BM_OUT_STATUS_DED) { in fuse_sense()
339 writel(BM_OUT_STATUS_DED, ®s->out_status_clr); in fuse_sense()
345 return finish_access(regs, __func__); in fuse_sense()
348 static int prepare_write(struct ocotp_regs **regs, u32 bank, u32 word, in prepare_write() argument
368 return prepare_access(regs, bank, word, true, caller); in prepare_write()
373 struct ocotp_regs *regs; in fuse_prog() local
376 ret = prepare_write(®s, bank, word, __func__); in fuse_prog()
380 setup_direct_access(regs, bank, word, true); in fuse_prog()
384 writel(0, ®s->data1); in fuse_prog()
385 writel(0, ®s->data2); in fuse_prog()
386 writel(0, ®s->data3); in fuse_prog()
387 writel(val, ®s->data0); in fuse_prog()
390 writel(val, ®s->data1); in fuse_prog()
391 writel(0, ®s->data2); in fuse_prog()
392 writel(0, ®s->data3); in fuse_prog()
393 writel(0, ®s->data0); in fuse_prog()
396 writel(0, ®s->data1); in fuse_prog()
397 writel(val, ®s->data2); in fuse_prog()
398 writel(0, ®s->data3); in fuse_prog()
399 writel(0, ®s->data0); in fuse_prog()
402 writel(0, ®s->data1); in fuse_prog()
403 writel(0, ®s->data2); in fuse_prog()
404 writel(val, ®s->data3); in fuse_prog()
405 writel(0, ®s->data0); in fuse_prog()
408 wait_busy(regs, BV_TIMING_PROG_US); in fuse_prog()
410 writel(val, ®s->data); in fuse_prog()
411 wait_busy(regs, BV_TIMING_STROBE_PROG_US); in fuse_prog()
416 if (readl(®s->out_status) & (BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED)) { in fuse_prog()
417 writel((BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED), ®s->out_status_clr); in fuse_prog()
423 return finish_access(regs, __func__); in fuse_prog()
428 struct ocotp_regs *regs; in fuse_override() local
433 ret = prepare_write(®s, bank, word, __func__); in fuse_override()
440 writel(val, ®s->bank[phy_bank].fuse_regs[phy_word << 2]); in fuse_override()
443 if (readl(®s->out_status) & (BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED)) { in fuse_override()
444 writel((BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED), ®s->out_status_clr); in fuse_override()
450 return finish_access(regs, __func__); in fuse_override()