Lines Matching refs:otp
47 static int lan9662_otp_power(struct lan9662_otp *otp, bool up) in lan9662_otp_power() argument
49 void __iomem *pwrdn = OTP_OTP_PWR_DN(otp->base); in lan9662_otp_power()
53 if (lan9662_otp_wait_flag_clear(OTP_OTP_STATUS(otp->base), in lan9662_otp_power()
63 static int lan9662_otp_execute(struct lan9662_otp *otp) in lan9662_otp_execute() argument
65 if (lan9662_otp_wait_flag_clear(OTP_OTP_CMD_GO(otp->base), in lan9662_otp_execute()
69 if (lan9662_otp_wait_flag_clear(OTP_OTP_STATUS(otp->base), in lan9662_otp_execute()
76 static void lan9662_otp_set_address(struct lan9662_otp *otp, u32 offset) in lan9662_otp_set_address() argument
78 writel(0xff & (offset >> 8), OTP_OTP_ADDR_HI(otp->base)); in lan9662_otp_set_address()
79 writel(0xff & offset, OTP_OTP_ADDR_LO(otp->base)); in lan9662_otp_set_address()
82 static int lan9662_otp_read_byte(struct lan9662_otp *otp, u32 offset, u8 *dst) in lan9662_otp_read_byte() argument
87 lan9662_otp_set_address(otp, offset); in lan9662_otp_read_byte()
88 writel(OTP_OTP_FUNC_CMD_OTP_READ, OTP_OTP_FUNC_CMD(otp->base)); in lan9662_otp_read_byte()
89 writel(OTP_OTP_CMD_GO_OTP_GO, OTP_OTP_CMD_GO(otp->base)); in lan9662_otp_read_byte()
90 rc = lan9662_otp_execute(otp); in lan9662_otp_read_byte()
92 pass = readl(OTP_OTP_PASS_FAIL(otp->base)); in lan9662_otp_read_byte()
95 *dst = (u8) readl(OTP_OTP_RD_DATA(otp->base)); in lan9662_otp_read_byte()
100 static int lan9662_otp_write_byte(struct lan9662_otp *otp, u32 offset, u8 data) in lan9662_otp_write_byte() argument
105 lan9662_otp_set_address(otp, offset); in lan9662_otp_write_byte()
106 writel(OTP_OTP_PRGM_MODE_OTP_PGM_MODE_BYTE, OTP_OTP_PRGM_MODE(otp->base)); in lan9662_otp_write_byte()
107 writel(data, OTP_OTP_PRGM_DATA(otp->base)); in lan9662_otp_write_byte()
108 writel(OTP_OTP_FUNC_CMD_OTP_PROGRAM, OTP_OTP_FUNC_CMD(otp->base)); in lan9662_otp_write_byte()
109 writel(OTP_OTP_CMD_GO_OTP_GO, OTP_OTP_CMD_GO(otp->base)); in lan9662_otp_write_byte()
111 rc = lan9662_otp_execute(otp); in lan9662_otp_write_byte()
113 pass = readl(OTP_OTP_PASS_FAIL(otp->base)); in lan9662_otp_write_byte()
125 struct lan9662_otp *otp = context; in lan9662_otp_read() local
130 lan9662_otp_power(otp, true); in lan9662_otp_read()
132 rc = lan9662_otp_read_byte(otp, offset + i, &data); in lan9662_otp_read()
137 lan9662_otp_power(otp, false); in lan9662_otp_read()
145 struct lan9662_otp *otp = context; in lan9662_otp_write() local
150 lan9662_otp_power(otp, true); in lan9662_otp_write()
154 rc = lan9662_otp_read_byte(otp, offset + i, &data); in lan9662_otp_write()
162 rc = lan9662_otp_write_byte(otp, offset + i, in lan9662_otp_write()
168 lan9662_otp_power(otp, false); in lan9662_otp_write()
186 struct lan9662_otp *otp; in lan9662_otp_probe() local
188 otp = devm_kzalloc(&pdev->dev, sizeof(*otp), GFP_KERNEL); in lan9662_otp_probe()
189 if (!otp) in lan9662_otp_probe()
192 otp->dev = dev; in lan9662_otp_probe()
193 otp->base = devm_platform_ioremap_resource(pdev, 0); in lan9662_otp_probe()
194 if (IS_ERR(otp->base)) in lan9662_otp_probe()
195 return PTR_ERR(otp->base); in lan9662_otp_probe()
197 otp_config.priv = otp; in lan9662_otp_probe()