• Home
  • Raw
  • Download

Lines Matching +full:otp +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2007-2009 ST-Ericsson AB
6 * Driver to read out OTP from the AB3100 Mixed-signal circuit
19 /* The OTP registers */
33 * @locked: whether the OTP is locked, after locking, no more bits
35 * to change bits from 1->0.
36 * @freq: clocking frequency for the OTP, this frequency is either
62 static int __init ab3100_otp_read(struct ab3100_otp *otp) in ab3100_otp_read() argument
68 err = abx500_get_register_interruptible(otp->dev, 0, in ab3100_otp_read()
71 dev_err(otp->dev, "unable to read OTPP register\n"); in ab3100_otp_read()
75 err = abx500_get_register_page_interruptible(otp->dev, 0, in ab3100_otp_read()
78 dev_err(otp->dev, "unable to read OTP register page\n"); in ab3100_otp_read()
82 /* Cache OTP properties, they never change by nature */ in ab3100_otp_read()
83 otp->locked = (otpp & 0x80); in ab3100_otp_read()
84 otp->freq = (otpp & 0x40) ? 32768 : 34100; in ab3100_otp_read()
85 otp->paf = (otpval[1] & 0x80); in ab3100_otp_read()
86 otp->imeich = (otpval[1] & 0x40); in ab3100_otp_read()
87 otp->cid = ((otpval[1] << 8) | otpval[0]) & 0x3fff; in ab3100_otp_read()
88 otp->tac = ((otpval[4] & 0x0f) << 16) | (otpval[3] << 8) | otpval[2]; in ab3100_otp_read()
89 otp->fac = ((otpval[5] & 0x0f) << 4) | (otpval[4] >> 4); in ab3100_otp_read()
90 otp->svn = (otpval[7] << 12) | (otpval[6] << 4) | (otpval[5] >> 4); in ab3100_otp_read()
95 * This is a simple debugfs human-readable file that dumps out
96 * the contents of the OTP.
101 struct ab3100_otp *otp = s->private; in ab3100_show_otp() local
103 seq_printf(s, "OTP is %s\n", otp->locked ? "LOCKED" : "UNLOCKED"); in ab3100_show_otp()
104 seq_printf(s, "OTP clock switch startup is %uHz\n", otp->freq); in ab3100_show_otp()
105 seq_printf(s, "PAF is %s\n", otp->paf ? "SET" : "NOT SET"); in ab3100_show_otp()
106 seq_printf(s, "IMEI is %s\n", otp->imeich ? in ab3100_show_otp()
108 seq_printf(s, "CID: 0x%04x (decimal: %d)\n", otp->cid, otp->cid); in ab3100_show_otp()
109 seq_printf(s, "IMEI: %u-%u-%u\n", otp->tac, otp->fac, otp->svn); in ab3100_show_otp()
115 return single_open(file, ab3100_show_otp, inode->i_private); in ab3100_otp_open()
126 struct ab3100_otp *otp) in ab3100_otp_init_debugfs() argument
128 otp->debugfs = debugfs_create_file("ab3100_otp", S_IFREG | S_IRUGO, in ab3100_otp_init_debugfs()
129 NULL, otp, &ab3100_otp_operations); in ab3100_otp_init_debugfs()
132 static void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp) in ab3100_otp_exit_debugfs() argument
134 debugfs_remove(otp->debugfs); in ab3100_otp_exit_debugfs()
139 struct ab3100_otp *otp) in ab3100_otp_init_debugfs() argument
143 static inline void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp) in ab3100_otp_exit_debugfs() argument
153 struct ab3100_otp *otp = dev_get_drvdata(dev); \
154 return sprintf(buf, "%u\n", otp->name); \
179 struct ab3100_otp *otp; in ab3100_otp_probe() local
183 otp = devm_kzalloc(&pdev->dev, sizeof(struct ab3100_otp), GFP_KERNEL); in ab3100_otp_probe()
184 if (!otp) in ab3100_otp_probe()
185 return -ENOMEM; in ab3100_otp_probe()
187 otp->dev = &pdev->dev; in ab3100_otp_probe()
190 platform_set_drvdata(pdev, otp); in ab3100_otp_probe()
192 err = ab3100_otp_read(otp); in ab3100_otp_probe()
196 dev_info(&pdev->dev, "AB3100 OTP readout registered\n"); in ab3100_otp_probe()
200 err = device_create_file(&pdev->dev, in ab3100_otp_probe()
207 ab3100_otp_init_debugfs(&pdev->dev, otp); in ab3100_otp_probe()
212 while (--i >= 0) in ab3100_otp_probe()
213 device_remove_file(&pdev->dev, &ab3100_otp_attrs[i]); in ab3100_otp_probe()
219 struct ab3100_otp *otp = platform_get_drvdata(pdev); in ab3100_otp_remove() local
223 device_remove_file(&pdev->dev, in ab3100_otp_remove()
225 ab3100_otp_exit_debugfs(otp); in ab3100_otp_remove()
231 .name = "ab3100-otp",
239 MODULE_DESCRIPTION("AB3100 OTP Readout Driver");