10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
20 #define AB3100_OTP0 0xb0
21 #define AB3100_OTP1 0xb1
22 #define AB3100_OTP2 0xb2
23 #define AB3100_OTP3 0xb3
24 #define AB3100_OTP4 0xb4
25 #define AB3100_OTP5 0xb5
26 #define AB3100_OTP6 0xb6
27 #define AB3100_OTP7 0xb7
28 #define AB3100_OTPP 0xbf
71 dev_err(otp->
dev,
"unable to read OTPP register\n");
78 dev_err(otp->
dev,
"unable to read OTP register page\n");
83 otp->
locked = (otpp & 0x80);
84 otp->
freq = (otpp & 0x40) ? 32768 : 34100;
85 otp->
paf = (otpval[1] & 0x80);
86 otp->
imeich = (otpval[1] & 0x40);
87 otp->
cid = ((otpval[1] << 8) | otpval[0]) & 0x3fff;
88 otp->
tac = ((otpval[4] & 0x0f) << 16) | (otpval[3] << 8) | otpval[2];
89 otp->
fac = ((otpval[5] & 0x0f) << 4) | (otpval[4] >> 4);
90 otp->
svn = (otpval[7] << 12) | (otpval[6] << 4) | (otpval[5] >> 4);
98 #ifdef CONFIG_DEBUG_FS
99 static int ab3100_show_otp(
struct seq_file *
s,
void *
v)
107 "CHANGEABLE" :
"NOT CHANGEABLE");
119 .
open = ab3100_otp_open,
130 &ab3100_otp_operations);
132 dev_err(dev,
"AB3100 debugfs OTP file registration failed!\n");
144 static inline int __init ab3100_otp_init_debugfs(
struct device *dev,
155 #define SHOW_AB3100_ATTR(name) \
156 static ssize_t ab3100_otp_##name##_show(struct device *dev, \
157 struct device_attribute *attr, \
160 struct ab3100_otp *otp = dev_get_drvdata(dev); \
161 return sprintf(buf, "%u\n", otp->name); \
192 dev_err(&pdev->
dev,
"could not allocate AB3100 OTP device\n");
198 platform_set_drvdata(pdev, otp);
200 err = ab3100_otp_read(otp);
204 dev_info(&pdev->
dev,
"AB3100 OTP readout registered\n");
207 for (i = 0; i <
ARRAY_SIZE(ab3100_otp_attrs); i++) {
209 &ab3100_otp_attrs[i]);
211 goto err_create_file;
215 err = ab3100_otp_init_debugfs(&pdev->
dev, otp);
217 goto err_init_debugfs;
232 struct ab3100_otp *otp = platform_get_drvdata(pdev);
235 for (i = 0; i <
ARRAY_SIZE(ab3100_otp_attrs); i++)
237 &ab3100_otp_attrs[i]);
238 ab3100_otp_exit_debugfs(otp);
245 .name =
"ab3100-otp",
248 .remove =
__exit_p(ab3100_otp_remove),
251 static int __init ab3100_otp_init(
void)
257 static void __exit ab3100_otp_exit(
void)