blob: 9a0211aa88971c0207b3caa18d30eab6cb57821a [file] [log] [blame]
Mattias Wallin5814fc32010-09-13 16:05:04 +02001/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
5 * License Terms: GNU General Public License v2
6 */
7
8#include <linux/seq_file.h>
9#include <linux/uaccess.h>
10#include <linux/fs.h>
Paul Gortmaker4e36dd32011-07-03 15:13:27 -040011#include <linux/module.h>
Mattias Wallin5814fc32010-09-13 16:05:04 +020012#include <linux/debugfs.h>
13#include <linux/platform_device.h>
14
15#include <linux/mfd/abx500.h>
Linus Walleijee66e652011-12-02 14:16:33 +010016#include <linux/mfd/abx500/ab8500.h>
Mattias Wallin5814fc32010-09-13 16:05:04 +020017
18static u32 debug_bank;
19static u32 debug_address;
20
21/**
22 * struct ab8500_reg_range
23 * @first: the first address of the range
24 * @last: the last address of the range
25 * @perm: access permissions for the range
26 */
27struct ab8500_reg_range {
Mattias Wallind7b9f322010-11-26 13:06:39 +010028 u8 first;
29 u8 last;
30 u8 perm;
Mattias Wallin5814fc32010-09-13 16:05:04 +020031};
32
33/**
34 * struct ab8500_i2c_ranges
35 * @num_ranges: the number of ranges in the list
36 * @bankid: bank identifier
37 * @range: the list of register ranges
38 */
39struct ab8500_i2c_ranges {
Mattias Wallind7b9f322010-11-26 13:06:39 +010040 u8 num_ranges;
41 u8 bankid;
42 const struct ab8500_reg_range *range;
Mattias Wallin5814fc32010-09-13 16:05:04 +020043};
44
45#define AB8500_NAME_STRING "ab8500"
46#define AB8500_NUM_BANKS 22
47
48#define AB8500_REV_REG 0x80
49
50static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = {
Mattias Wallind7b9f322010-11-26 13:06:39 +010051 [0x0] = {
52 .num_ranges = 0,
53 .range = 0,
54 },
55 [AB8500_SYS_CTRL1_BLOCK] = {
56 .num_ranges = 3,
57 .range = (struct ab8500_reg_range[]) {
58 {
59 .first = 0x00,
60 .last = 0x02,
61 },
62 {
63 .first = 0x42,
64 .last = 0x42,
65 },
66 {
67 .first = 0x80,
68 .last = 0x81,
69 },
70 },
71 },
72 [AB8500_SYS_CTRL2_BLOCK] = {
73 .num_ranges = 4,
74 .range = (struct ab8500_reg_range[]) {
75 {
76 .first = 0x00,
77 .last = 0x0D,
78 },
79 {
80 .first = 0x0F,
81 .last = 0x17,
82 },
83 {
84 .first = 0x30,
85 .last = 0x30,
86 },
87 {
88 .first = 0x32,
89 .last = 0x33,
90 },
91 },
92 },
93 [AB8500_REGU_CTRL1] = {
94 .num_ranges = 3,
95 .range = (struct ab8500_reg_range[]) {
96 {
97 .first = 0x00,
98 .last = 0x00,
99 },
100 {
101 .first = 0x03,
102 .last = 0x10,
103 },
104 {
105 .first = 0x80,
106 .last = 0x84,
107 },
108 },
109 },
110 [AB8500_REGU_CTRL2] = {
111 .num_ranges = 5,
112 .range = (struct ab8500_reg_range[]) {
113 {
114 .first = 0x00,
115 .last = 0x15,
116 },
117 {
118 .first = 0x17,
119 .last = 0x19,
120 },
121 {
122 .first = 0x1B,
123 .last = 0x1D,
124 },
125 {
126 .first = 0x1F,
127 .last = 0x22,
128 },
129 {
130 .first = 0x40,
131 .last = 0x44,
132 },
133 /* 0x80-0x8B is SIM registers and should
134 * not be accessed from here */
135 },
136 },
137 [AB8500_USB] = {
138 .num_ranges = 2,
139 .range = (struct ab8500_reg_range[]) {
140 {
141 .first = 0x80,
142 .last = 0x83,
143 },
144 {
145 .first = 0x87,
146 .last = 0x8A,
147 },
148 },
149 },
150 [AB8500_TVOUT] = {
151 .num_ranges = 9,
152 .range = (struct ab8500_reg_range[]) {
153 {
154 .first = 0x00,
155 .last = 0x12,
156 },
157 {
158 .first = 0x15,
159 .last = 0x17,
160 },
161 {
162 .first = 0x19,
163 .last = 0x21,
164 },
165 {
166 .first = 0x27,
167 .last = 0x2C,
168 },
169 {
170 .first = 0x41,
171 .last = 0x41,
172 },
173 {
174 .first = 0x45,
175 .last = 0x5B,
176 },
177 {
178 .first = 0x5D,
179 .last = 0x5D,
180 },
181 {
182 .first = 0x69,
183 .last = 0x69,
184 },
185 {
186 .first = 0x80,
187 .last = 0x81,
188 },
189 },
190 },
191 [AB8500_DBI] = {
192 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000193 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100194 },
195 [AB8500_ECI_AV_ACC] = {
196 .num_ranges = 1,
197 .range = (struct ab8500_reg_range[]) {
198 {
199 .first = 0x80,
200 .last = 0x82,
201 },
202 },
203 },
204 [0x9] = {
205 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000206 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100207 },
208 [AB8500_GPADC] = {
209 .num_ranges = 1,
210 .range = (struct ab8500_reg_range[]) {
211 {
212 .first = 0x00,
213 .last = 0x08,
214 },
215 },
216 },
217 [AB8500_CHARGER] = {
218 .num_ranges = 8,
219 .range = (struct ab8500_reg_range[]) {
220 {
221 .first = 0x00,
222 .last = 0x03,
223 },
224 {
225 .first = 0x05,
226 .last = 0x05,
227 },
228 {
229 .first = 0x40,
230 .last = 0x40,
231 },
232 {
233 .first = 0x42,
234 .last = 0x42,
235 },
236 {
237 .first = 0x44,
238 .last = 0x44,
239 },
240 {
241 .first = 0x50,
242 .last = 0x55,
243 },
244 {
245 .first = 0x80,
246 .last = 0x82,
247 },
248 {
249 .first = 0xC0,
250 .last = 0xC2,
251 },
252 },
253 },
254 [AB8500_GAS_GAUGE] = {
255 .num_ranges = 3,
256 .range = (struct ab8500_reg_range[]) {
257 {
258 .first = 0x00,
259 .last = 0x00,
260 },
261 {
262 .first = 0x07,
263 .last = 0x0A,
264 },
265 {
266 .first = 0x10,
267 .last = 0x14,
268 },
269 },
270 },
271 [AB8500_AUDIO] = {
272 .num_ranges = 1,
273 .range = (struct ab8500_reg_range[]) {
274 {
275 .first = 0x00,
276 .last = 0x6F,
277 },
278 },
279 },
280 [AB8500_INTERRUPT] = {
281 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000282 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100283 },
284 [AB8500_RTC] = {
285 .num_ranges = 1,
286 .range = (struct ab8500_reg_range[]) {
287 {
288 .first = 0x00,
289 .last = 0x0F,
290 },
291 },
292 },
293 [AB8500_MISC] = {
294 .num_ranges = 8,
295 .range = (struct ab8500_reg_range[]) {
296 {
297 .first = 0x00,
298 .last = 0x05,
299 },
300 {
301 .first = 0x10,
302 .last = 0x15,
303 },
304 {
305 .first = 0x20,
306 .last = 0x25,
307 },
308 {
309 .first = 0x30,
310 .last = 0x35,
311 },
312 {
313 .first = 0x40,
314 .last = 0x45,
315 },
316 {
317 .first = 0x50,
318 .last = 0x50,
319 },
320 {
321 .first = 0x60,
322 .last = 0x67,
323 },
324 {
325 .first = 0x80,
326 .last = 0x80,
327 },
328 },
329 },
330 [0x11] = {
331 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000332 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100333 },
334 [0x12] = {
335 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000336 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100337 },
338 [0x13] = {
339 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000340 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100341 },
342 [0x14] = {
343 .num_ranges = 0,
Mark Brown87fff232010-12-13 14:06:47 +0000344 .range = NULL,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100345 },
346 [AB8500_OTP_EMUL] = {
347 .num_ranges = 1,
348 .range = (struct ab8500_reg_range[]) {
349 {
350 .first = 0x01,
351 .last = 0x0F,
352 },
353 },
354 },
Mattias Wallin5814fc32010-09-13 16:05:04 +0200355};
356
357static int ab8500_registers_print(struct seq_file *s, void *p)
358{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100359 struct device *dev = s->private;
360 unsigned int i;
361 u32 bank = debug_bank;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200362
Mattias Wallind7b9f322010-11-26 13:06:39 +0100363 seq_printf(s, AB8500_NAME_STRING " register values:\n");
Mattias Wallin5814fc32010-09-13 16:05:04 +0200364
Mattias Wallind7b9f322010-11-26 13:06:39 +0100365 seq_printf(s, " bank %u:\n", bank);
366 for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
367 u32 reg;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200368
Mattias Wallind7b9f322010-11-26 13:06:39 +0100369 for (reg = debug_ranges[bank].range[i].first;
370 reg <= debug_ranges[bank].range[i].last;
371 reg++) {
372 u8 value;
373 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200374
Mattias Wallind7b9f322010-11-26 13:06:39 +0100375 err = abx500_get_register_interruptible(dev,
376 (u8)bank, (u8)reg, &value);
377 if (err < 0) {
378 dev_err(dev, "ab->read fail %d\n", err);
379 return err;
380 }
Mattias Wallin5814fc32010-09-13 16:05:04 +0200381
Mattias Wallind7b9f322010-11-26 13:06:39 +0100382 err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", bank,
383 reg, value);
384 if (err < 0) {
385 dev_err(dev, "seq_printf overflow\n");
386 /* Error is not returned here since
387 * the output is wanted in any case */
388 return 0;
389 }
390 }
391 }
392 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200393}
394
395static int ab8500_registers_open(struct inode *inode, struct file *file)
396{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100397 return single_open(file, ab8500_registers_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200398}
399
400static const struct file_operations ab8500_registers_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100401 .open = ab8500_registers_open,
402 .read = seq_read,
403 .llseek = seq_lseek,
404 .release = single_release,
405 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +0200406};
407
408static int ab8500_bank_print(struct seq_file *s, void *p)
409{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100410 return seq_printf(s, "%d\n", debug_bank);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200411}
412
413static int ab8500_bank_open(struct inode *inode, struct file *file)
414{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100415 return single_open(file, ab8500_bank_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200416}
417
418static ssize_t ab8500_bank_write(struct file *file,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100419 const char __user *user_buf,
420 size_t count, loff_t *ppos)
Mattias Wallin5814fc32010-09-13 16:05:04 +0200421{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100422 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Mattias Wallind7b9f322010-11-26 13:06:39 +0100423 unsigned long user_bank;
424 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200425
Mattias Wallind7b9f322010-11-26 13:06:39 +0100426 /* Get userspace string and assure termination */
Peter Huewe8504d632011-06-06 22:43:32 +0200427 err = kstrtoul_from_user(user_buf, count, 0, &user_bank);
Mattias Wallind7b9f322010-11-26 13:06:39 +0100428 if (err)
Peter Huewe8504d632011-06-06 22:43:32 +0200429 return err;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200430
Mattias Wallind7b9f322010-11-26 13:06:39 +0100431 if (user_bank >= AB8500_NUM_BANKS) {
432 dev_err(dev, "debugfs error input > number of banks\n");
433 return -EINVAL;
434 }
Mattias Wallin5814fc32010-09-13 16:05:04 +0200435
Mattias Wallind7b9f322010-11-26 13:06:39 +0100436 debug_bank = user_bank;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200437
Peter Huewe8504d632011-06-06 22:43:32 +0200438 return count;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200439}
440
441static int ab8500_address_print(struct seq_file *s, void *p)
442{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100443 return seq_printf(s, "0x%02X\n", debug_address);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200444}
445
446static int ab8500_address_open(struct inode *inode, struct file *file)
447{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100448 return single_open(file, ab8500_address_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200449}
450
451static ssize_t ab8500_address_write(struct file *file,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100452 const char __user *user_buf,
453 size_t count, loff_t *ppos)
Mattias Wallin5814fc32010-09-13 16:05:04 +0200454{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100455 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Mattias Wallind7b9f322010-11-26 13:06:39 +0100456 unsigned long user_address;
457 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200458
Mattias Wallind7b9f322010-11-26 13:06:39 +0100459 /* Get userspace string and assure termination */
Peter Huewe8504d632011-06-06 22:43:32 +0200460 err = kstrtoul_from_user(user_buf, count, 0, &user_address);
Mattias Wallind7b9f322010-11-26 13:06:39 +0100461 if (err)
Peter Huewe8504d632011-06-06 22:43:32 +0200462 return err;
463
Mattias Wallind7b9f322010-11-26 13:06:39 +0100464 if (user_address > 0xff) {
465 dev_err(dev, "debugfs error input > 0xff\n");
466 return -EINVAL;
467 }
468 debug_address = user_address;
Peter Huewe8504d632011-06-06 22:43:32 +0200469 return count;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200470}
471
472static int ab8500_val_print(struct seq_file *s, void *p)
473{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100474 struct device *dev = s->private;
475 int ret;
476 u8 regvalue;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200477
Mattias Wallind7b9f322010-11-26 13:06:39 +0100478 ret = abx500_get_register_interruptible(dev,
479 (u8)debug_bank, (u8)debug_address, &regvalue);
480 if (ret < 0) {
481 dev_err(dev, "abx500_get_reg fail %d, %d\n",
482 ret, __LINE__);
483 return -EINVAL;
484 }
485 seq_printf(s, "0x%02X\n", regvalue);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200486
Mattias Wallind7b9f322010-11-26 13:06:39 +0100487 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200488}
489
490static int ab8500_val_open(struct inode *inode, struct file *file)
491{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100492 return single_open(file, ab8500_val_print, inode->i_private);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200493}
494
495static ssize_t ab8500_val_write(struct file *file,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100496 const char __user *user_buf,
497 size_t count, loff_t *ppos)
Mattias Wallin5814fc32010-09-13 16:05:04 +0200498{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100499 struct device *dev = ((struct seq_file *)(file->private_data))->private;
Mattias Wallind7b9f322010-11-26 13:06:39 +0100500 unsigned long user_val;
501 int err;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200502
Mattias Wallind7b9f322010-11-26 13:06:39 +0100503 /* Get userspace string and assure termination */
Peter Huewe8504d632011-06-06 22:43:32 +0200504 err = kstrtoul_from_user(user_buf, count, 0, &user_val);
Mattias Wallind7b9f322010-11-26 13:06:39 +0100505 if (err)
Peter Huewe8504d632011-06-06 22:43:32 +0200506 return err;
507
Mattias Wallind7b9f322010-11-26 13:06:39 +0100508 if (user_val > 0xff) {
509 dev_err(dev, "debugfs error input > 0xff\n");
510 return -EINVAL;
511 }
512 err = abx500_set_register_interruptible(dev,
513 (u8)debug_bank, debug_address, (u8)user_val);
514 if (err < 0) {
515 printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
516 return -EINVAL;
517 }
Mattias Wallin5814fc32010-09-13 16:05:04 +0200518
Peter Huewe8504d632011-06-06 22:43:32 +0200519 return count;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200520}
521
522static const struct file_operations ab8500_bank_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100523 .open = ab8500_bank_open,
524 .write = ab8500_bank_write,
525 .read = seq_read,
526 .llseek = seq_lseek,
527 .release = single_release,
528 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +0200529};
530
531static const struct file_operations ab8500_address_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100532 .open = ab8500_address_open,
533 .write = ab8500_address_write,
534 .read = seq_read,
535 .llseek = seq_lseek,
536 .release = single_release,
537 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +0200538};
539
540static const struct file_operations ab8500_val_fops = {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100541 .open = ab8500_val_open,
542 .write = ab8500_val_write,
543 .read = seq_read,
544 .llseek = seq_lseek,
545 .release = single_release,
546 .owner = THIS_MODULE,
Mattias Wallin5814fc32010-09-13 16:05:04 +0200547};
548
549static struct dentry *ab8500_dir;
550static struct dentry *ab8500_reg_file;
551static struct dentry *ab8500_bank_file;
552static struct dentry *ab8500_address_file;
553static struct dentry *ab8500_val_file;
554
555static int __devinit ab8500_debug_probe(struct platform_device *plf)
556{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100557 debug_bank = AB8500_MISC;
558 debug_address = AB8500_REV_REG & 0x00FF;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200559
Mattias Wallind7b9f322010-11-26 13:06:39 +0100560 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
561 if (!ab8500_dir)
562 goto exit_no_debugfs;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200563
Mattias Wallind7b9f322010-11-26 13:06:39 +0100564 ab8500_reg_file = debugfs_create_file("all-bank-registers",
565 S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops);
566 if (!ab8500_reg_file)
567 goto exit_destroy_dir;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200568
Mattias Wallind7b9f322010-11-26 13:06:39 +0100569 ab8500_bank_file = debugfs_create_file("register-bank",
Vasiliy Kulikov44bdcb52011-02-04 15:23:43 +0300570 (S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_bank_fops);
Mattias Wallind7b9f322010-11-26 13:06:39 +0100571 if (!ab8500_bank_file)
572 goto exit_destroy_reg;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200573
Mattias Wallind7b9f322010-11-26 13:06:39 +0100574 ab8500_address_file = debugfs_create_file("register-address",
Vasiliy Kulikov44bdcb52011-02-04 15:23:43 +0300575 (S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
Mattias Wallind7b9f322010-11-26 13:06:39 +0100576 &ab8500_address_fops);
577 if (!ab8500_address_file)
578 goto exit_destroy_bank;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200579
Mattias Wallind7b9f322010-11-26 13:06:39 +0100580 ab8500_val_file = debugfs_create_file("register-value",
Vasiliy Kulikov44bdcb52011-02-04 15:23:43 +0300581 (S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_val_fops);
Mattias Wallind7b9f322010-11-26 13:06:39 +0100582 if (!ab8500_val_file)
583 goto exit_destroy_address;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200584
Mattias Wallind7b9f322010-11-26 13:06:39 +0100585 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200586
587exit_destroy_address:
Mattias Wallind7b9f322010-11-26 13:06:39 +0100588 debugfs_remove(ab8500_address_file);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200589exit_destroy_bank:
Mattias Wallind7b9f322010-11-26 13:06:39 +0100590 debugfs_remove(ab8500_bank_file);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200591exit_destroy_reg:
Mattias Wallind7b9f322010-11-26 13:06:39 +0100592 debugfs_remove(ab8500_reg_file);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200593exit_destroy_dir:
Mattias Wallind7b9f322010-11-26 13:06:39 +0100594 debugfs_remove(ab8500_dir);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200595exit_no_debugfs:
Mattias Wallind7b9f322010-11-26 13:06:39 +0100596 dev_err(&plf->dev, "failed to create debugfs entries.\n");
597 return -ENOMEM;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200598}
599
600static int __devexit ab8500_debug_remove(struct platform_device *plf)
601{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100602 debugfs_remove(ab8500_val_file);
603 debugfs_remove(ab8500_address_file);
604 debugfs_remove(ab8500_bank_file);
605 debugfs_remove(ab8500_reg_file);
606 debugfs_remove(ab8500_dir);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200607
Mattias Wallind7b9f322010-11-26 13:06:39 +0100608 return 0;
Mattias Wallin5814fc32010-09-13 16:05:04 +0200609}
610
611static struct platform_driver ab8500_debug_driver = {
Mattias Wallind7b9f322010-11-26 13:06:39 +0100612 .driver = {
613 .name = "ab8500-debug",
614 .owner = THIS_MODULE,
615 },
616 .probe = ab8500_debug_probe,
617 .remove = __devexit_p(ab8500_debug_remove)
Mattias Wallin5814fc32010-09-13 16:05:04 +0200618};
619
620static int __init ab8500_debug_init(void)
621{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100622 return platform_driver_register(&ab8500_debug_driver);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200623}
624
625static void __exit ab8500_debug_exit(void)
626{
Mattias Wallind7b9f322010-11-26 13:06:39 +0100627 platform_driver_unregister(&ab8500_debug_driver);
Mattias Wallin5814fc32010-09-13 16:05:04 +0200628}
629subsys_initcall(ab8500_debug_init);
630module_exit(ab8500_debug_exit);
631
632MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
633MODULE_DESCRIPTION("AB8500 DEBUG");
634MODULE_LICENSE("GPL v2");