aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/board-info.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/board-info.c')
-rw-r--r--arch/arm/mach-tegra/board-info.c201
1 files changed, 201 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-info.c b/arch/arm/mach-tegra/board-info.c
new file mode 100644
index 00000000000..1bcd0d52bd2
--- /dev/null
+++ b/arch/arm/mach-tegra/board-info.c
@@ -0,0 +1,201 @@
1/*
2 * arch/arm/mach-tegra/board-info.c
3 *
4 * File to contain changes for sku id, serial id, chip id, etc.
5 *
6 * Copyright (c) 2010-2012, NVIDIA Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#include <linux/proc_fs.h>
24#include <linux/seq_file.h>
25#include "board.h"
26
27/* skuinfo is 18 character long xxx-xxxxx-xxxx-xxx
28 *so buffer size is set to 18+1 */
29#define SKUINFO_BUF_SIZE 19
30/* skuver is 2 character long XX so buffer size is set to 2+1 */
31#define SKUVER_BUF_SIZE 3
32
33/* prodinfo is 18 character long xxx-xxxxx-xxxx-xxx
34 * so buffer size is set to 18+1 */
35#define PRODINFO_BUF_SIZE 19
36/* prodver is 2 character long XX so buffer size is set to 2+1 */
37#define PRODVER_BUF_SIZE 3
38
39static unsigned int board_serial_low;
40static unsigned int board_serial_high;
41static char prodinfo_buffer[PRODINFO_BUF_SIZE];
42static char prodver_buffer[PRODVER_BUF_SIZE];
43static char skuinfo_buffer[SKUINFO_BUF_SIZE];
44static char skuver_buffer[SKUVER_BUF_SIZE];
45
46static int __init sku_info_setup(char *line)
47{
48 memcpy(skuinfo_buffer, line, SKUINFO_BUF_SIZE);
49 return 1;
50}
51
52__setup("nvsku=", sku_info_setup);
53
54static int __init sku_ver_setup(char *line)
55{
56 memcpy(skuver_buffer, line, SKUVER_BUF_SIZE);
57 return 1;
58}
59
60__setup("SkuVer=", sku_ver_setup);
61
62static int __init prod_info_setup(char *line)
63{
64 memcpy(prodinfo_buffer, line, PRODINFO_BUF_SIZE);
65 return 1;
66}
67
68__setup("ProdInfo=", prod_info_setup);
69
70static int __init prod_ver_setup(char *line)
71{
72 memcpy(prodver_buffer, line, PRODVER_BUF_SIZE);
73 return 1;
74}
75
76__setup("ProdVer=", prod_ver_setup);
77
78static int read_skuinfo_proc_show(struct seq_file *m, void *v)
79{
80 seq_printf(m, "%s\n", skuinfo_buffer);
81 return 0;
82}
83
84static int read_skuinfo_proc_open(struct inode *inode, struct file *file)
85{
86 return single_open(file, read_skuinfo_proc_show, NULL);
87}
88
89static const struct file_operations read_skuinfo_proc_fops = {
90 .open = read_skuinfo_proc_open,
91 .read = seq_read,
92 .llseek = seq_lseek,
93 .release = single_release,
94};
95
96static int read_skuver_proc_show(struct seq_file *m, void *v)
97{
98 seq_printf(m, "%s\n", skuver_buffer);
99 return 0;
100}
101
102static int read_skuver_proc_open(struct inode *inode, struct file *file)
103{
104 return single_open(file, read_skuver_proc_show, NULL);
105}
106
107static const struct file_operations read_skuver_proc_fops = {
108 .open = read_skuver_proc_open,
109 .read = seq_read,
110 .llseek = seq_lseek,
111 .release = single_release,
112};
113
114static int read_serialinfo_proc_show(struct seq_file *m, void *v)
115{
116 seq_printf(m, "%013llu\n",
117 (((unsigned long long int)board_serial_high) << 32) |
118 board_serial_low);
119 return 0;
120}
121
122static int read_serialinfo_proc_open(struct inode *inode, struct file *file)
123{
124 return single_open(file, read_serialinfo_proc_show, NULL);
125}
126
127static const struct file_operations read_serialinfo_proc_fops = {
128 .open = read_serialinfo_proc_open,
129 .read = seq_read,
130 .llseek = seq_lseek,
131 .release = single_release,
132};
133
134static int read_prodinfo_proc_show(struct seq_file *m, void *v)
135{
136 seq_printf(m, "%s\n", prodinfo_buffer);
137 return 0;
138}
139
140static int read_prodinfo_proc_open(struct inode *inode, struct file *file)
141{
142 return single_open(file, read_prodinfo_proc_show, NULL);
143}
144
145static const struct file_operations read_prodinfo_proc_fops = {
146 .open = read_prodinfo_proc_open,
147 .read = seq_read,
148 .llseek = seq_lseek,
149 .release = single_release,
150};
151
152static int read_prodver_proc_show(struct seq_file *m, void *v)
153{
154 seq_printf(m, "%s\n", prodver_buffer);
155 return 0;
156}
157
158static int read_prodver_proc_open(struct inode *inode, struct file *file)
159{
160 return single_open(file, read_prodver_proc_show, NULL);
161}
162
163static const struct file_operations read_prodver_proc_fops = {
164 .open = read_prodver_proc_open,
165 .read = seq_read,
166 .llseek = seq_lseek,
167 .release = single_release,
168};
169
170int __init tegra_init_board_info(void)
171{
172 board_serial_low = system_serial_low;
173 board_serial_high = system_serial_high;
174
175 if (!proc_create("board_serial", 0, NULL, &read_serialinfo_proc_fops)) {
176 printk(KERN_ERR "Can't create proc entry for board_serial!\n");
177 return -1;
178 }
179
180 if (!proc_create("skuinfo", 0, NULL, &read_skuinfo_proc_fops)) {
181 printk(KERN_ERR "Can't create proc entry for skuinfo!\n");
182 return -1;
183 }
184
185 if (!proc_create("skuver", 0, NULL, &read_skuver_proc_fops)) {
186 printk(KERN_ERR "Can't create proc entry for skuver!\n");
187 return -1;
188 }
189
190 if (!proc_create("prodinfo", 0, NULL, &read_prodinfo_proc_fops)) {
191 printk(KERN_ERR "Can't create proc entry for prodinfo!\n");
192 return -1;
193 }
194
195 if (!proc_create("prodver", 0, NULL, &read_prodver_proc_fops)) {
196 printk(KERN_ERR "Can't create proc entry for prodver!\n");
197 return -1;
198 }
199
200 return 0;
201}