Blame view

drivers/mfd/ab8500-debugfs.c 11.9 KB
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
1
2
3
4
5
6
7
8
9
10
  /*
   * Copyright (C) ST-Ericsson SA 2010
   *
   * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
   * License Terms: GNU General Public License v2
   */
  
  #include <linux/seq_file.h>
  #include <linux/uaccess.h>
  #include <linux/fs.h>
4e36dd331   Paul Gortmaker   mfd: Add module.h...
11
  #include <linux/module.h>
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
12
13
14
15
  #include <linux/debugfs.h>
  #include <linux/platform_device.h>
  
  #include <linux/mfd/abx500.h>
ee66e653c   Linus Walleij   mfd: Unify abx500...
16
  #include <linux/mfd/abx500/ab8500.h>
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
17
18
19
20
21
22
23
24
25
26
27
  
  static u32 debug_bank;
  static u32 debug_address;
  
  /**
   * struct ab8500_reg_range
   * @first: the first address of the range
   * @last: the last address of the range
   * @perm: access permissions for the range
   */
  struct ab8500_reg_range {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
28
29
30
  	u8 first;
  	u8 last;
  	u8 perm;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
31
32
33
34
35
36
37
38
39
  };
  
  /**
   * struct ab8500_i2c_ranges
   * @num_ranges: the number of ranges in the list
   * @bankid: bank identifier
   * @range: the list of register ranges
   */
  struct ab8500_i2c_ranges {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
40
41
42
  	u8 num_ranges;
  	u8 bankid;
  	const struct ab8500_reg_range *range;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
43
44
45
46
47
48
49
50
  };
  
  #define AB8500_NAME_STRING "ab8500"
  #define AB8500_NUM_BANKS 22
  
  #define AB8500_REV_REG 0x80
  
  static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
  	[0x0] = {
  		.num_ranges = 0,
  		.range = 0,
  	},
  	[AB8500_SYS_CTRL1_BLOCK] = {
  		.num_ranges = 3,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x02,
  			},
  			{
  				.first = 0x42,
  				.last = 0x42,
  			},
  			{
  				.first = 0x80,
  				.last = 0x81,
  			},
  		},
  	},
  	[AB8500_SYS_CTRL2_BLOCK] = {
  		.num_ranges = 4,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x0D,
  			},
  			{
  				.first = 0x0F,
  				.last = 0x17,
  			},
  			{
  				.first = 0x30,
  				.last = 0x30,
  			},
  			{
  				.first = 0x32,
  				.last = 0x33,
  			},
  		},
  	},
  	[AB8500_REGU_CTRL1] = {
  		.num_ranges = 3,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x00,
  			},
  			{
  				.first = 0x03,
  				.last = 0x10,
  			},
  			{
  				.first = 0x80,
  				.last = 0x84,
  			},
  		},
  	},
  	[AB8500_REGU_CTRL2] = {
  		.num_ranges = 5,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x15,
  			},
  			{
  				.first = 0x17,
  				.last = 0x19,
  			},
  			{
  				.first = 0x1B,
  				.last = 0x1D,
  			},
  			{
  				.first = 0x1F,
  				.last = 0x22,
  			},
  			{
  				.first = 0x40,
  				.last = 0x44,
  			},
  			/* 0x80-0x8B is SIM registers and should
  			 * not be accessed from here */
  		},
  	},
  	[AB8500_USB] = {
  		.num_ranges = 2,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x80,
  				.last = 0x83,
  			},
  			{
  				.first = 0x87,
  				.last = 0x8A,
  			},
  		},
  	},
  	[AB8500_TVOUT] = {
  		.num_ranges = 9,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x12,
  			},
  			{
  				.first = 0x15,
  				.last = 0x17,
  			},
  			{
  				.first = 0x19,
  				.last = 0x21,
  			},
  			{
  				.first = 0x27,
  				.last = 0x2C,
  			},
  			{
  				.first = 0x41,
  				.last = 0x41,
  			},
  			{
  				.first = 0x45,
  				.last = 0x5B,
  			},
  			{
  				.first = 0x5D,
  				.last = 0x5D,
  			},
  			{
  				.first = 0x69,
  				.last = 0x69,
  			},
  			{
  				.first = 0x80,
  				.last = 0x81,
  			},
  		},
  	},
  	[AB8500_DBI] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
193
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
194
195
196
197
198
199
200
201
202
203
204
205
  	},
  	[AB8500_ECI_AV_ACC] = {
  		.num_ranges = 1,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x80,
  				.last = 0x82,
  			},
  		},
  	},
  	[0x9] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
206
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
  	},
  	[AB8500_GPADC] = {
  		.num_ranges = 1,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x08,
  			},
  		},
  	},
  	[AB8500_CHARGER] = {
  		.num_ranges = 8,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x03,
  			},
  			{
  				.first = 0x05,
  				.last = 0x05,
  			},
  			{
  				.first = 0x40,
  				.last = 0x40,
  			},
  			{
  				.first = 0x42,
  				.last = 0x42,
  			},
  			{
  				.first = 0x44,
  				.last = 0x44,
  			},
  			{
  				.first = 0x50,
  				.last = 0x55,
  			},
  			{
  				.first = 0x80,
  				.last = 0x82,
  			},
  			{
  				.first = 0xC0,
  				.last = 0xC2,
  			},
  		},
  	},
  	[AB8500_GAS_GAUGE] = {
  		.num_ranges = 3,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x00,
  			},
  			{
  				.first = 0x07,
  				.last = 0x0A,
  			},
  			{
  				.first = 0x10,
  				.last = 0x14,
  			},
  		},
  	},
  	[AB8500_AUDIO] = {
  		.num_ranges = 1,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x6F,
  			},
  		},
  	},
  	[AB8500_INTERRUPT] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
282
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
  	},
  	[AB8500_RTC] = {
  		.num_ranges = 1,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x0F,
  			},
  		},
  	},
  	[AB8500_MISC] = {
  		.num_ranges = 8,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x00,
  				.last = 0x05,
  			},
  			{
  				.first = 0x10,
  				.last = 0x15,
  			},
  			{
  				.first = 0x20,
  				.last = 0x25,
  			},
  			{
  				.first = 0x30,
  				.last = 0x35,
  			},
  			{
  				.first = 0x40,
  				.last = 0x45,
  			},
  			{
  				.first = 0x50,
  				.last = 0x50,
  			},
  			{
  				.first = 0x60,
  				.last = 0x67,
  			},
  			{
  				.first = 0x80,
  				.last = 0x80,
  			},
  		},
  	},
  	[0x11] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
332
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
333
334
335
  	},
  	[0x12] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
336
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
337
338
339
  	},
  	[0x13] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
340
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
341
342
343
  	},
  	[0x14] = {
  		.num_ranges = 0,
87fff232c   Mark Brown   mfd: Use NULL to ...
344
  		.range = NULL,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
345
346
347
348
349
350
351
352
353
354
  	},
  	[AB8500_OTP_EMUL] = {
  		.num_ranges = 1,
  		.range = (struct ab8500_reg_range[]) {
  			{
  				.first = 0x01,
  				.last = 0x0F,
  			},
  		},
  	},
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
355
356
357
358
  };
  
  static int ab8500_registers_print(struct seq_file *s, void *p)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
  	struct device *dev = s->private;
  	unsigned int i;
  	u32 bank = debug_bank;
  
  	seq_printf(s, AB8500_NAME_STRING " register values:
  ");
  
  	seq_printf(s, " bank %u:
  ", bank);
  	for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
  		u32 reg;
  
  		for (reg = debug_ranges[bank].range[i].first;
  			reg <= debug_ranges[bank].range[i].last;
  			reg++) {
  			u8 value;
  			int err;
  
  			err = abx500_get_register_interruptible(dev,
  				(u8)bank, (u8)reg, &value);
  			if (err < 0) {
  				dev_err(dev, "ab->read fail %d
  ", err);
  				return err;
  			}
  
  			err = seq_printf(s, "  [%u/0x%02X]: 0x%02X
  ", bank,
  				reg, value);
  			if (err < 0) {
  				dev_err(dev, "seq_printf overflow
  ");
  				/* Error is not returned here since
  				 * the output is wanted in any case */
  				return 0;
  			}
  		}
  	}
  	return 0;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
398
399
400
401
  }
  
  static int ab8500_registers_open(struct inode *inode, struct file *file)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
402
  	return single_open(file, ab8500_registers_print, inode->i_private);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
403
404
405
  }
  
  static const struct file_operations ab8500_registers_fops = {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
406
407
408
409
410
  	.open = ab8500_registers_open,
  	.read = seq_read,
  	.llseek = seq_lseek,
  	.release = single_release,
  	.owner = THIS_MODULE,
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
411
412
413
414
  };
  
  static int ab8500_bank_print(struct seq_file *s, void *p)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
415
416
  	return seq_printf(s, "%d
  ", debug_bank);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
417
418
419
420
  }
  
  static int ab8500_bank_open(struct inode *inode, struct file *file)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
421
  	return single_open(file, ab8500_bank_print, inode->i_private);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
422
423
424
  }
  
  static ssize_t ab8500_bank_write(struct file *file,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
425
426
  	const char __user *user_buf,
  	size_t count, loff_t *ppos)
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
427
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
428
  	struct device *dev = ((struct seq_file *)(file->private_data))->private;
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
429
430
431
432
  	unsigned long user_bank;
  	int err;
  
  	/* Get userspace string and assure termination */
8504d6380   Peter Huewe   mfd: Use kstrtoul...
433
  	err = kstrtoul_from_user(user_buf, count, 0, &user_bank);
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
434
  	if (err)
8504d6380   Peter Huewe   mfd: Use kstrtoul...
435
  		return err;
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
436
437
438
439
440
441
442
443
  
  	if (user_bank >= AB8500_NUM_BANKS) {
  		dev_err(dev, "debugfs error input > number of banks
  ");
  		return -EINVAL;
  	}
  
  	debug_bank = user_bank;
8504d6380   Peter Huewe   mfd: Use kstrtoul...
444
  	return count;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
445
446
447
448
  }
  
  static int ab8500_address_print(struct seq_file *s, void *p)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
449
450
  	return seq_printf(s, "0x%02X
  ", debug_address);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
451
452
453
454
  }
  
  static int ab8500_address_open(struct inode *inode, struct file *file)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
455
  	return single_open(file, ab8500_address_print, inode->i_private);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
456
457
458
  }
  
  static ssize_t ab8500_address_write(struct file *file,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
459
460
  	const char __user *user_buf,
  	size_t count, loff_t *ppos)
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
461
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
462
  	struct device *dev = ((struct seq_file *)(file->private_data))->private;
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
463
464
465
466
  	unsigned long user_address;
  	int err;
  
  	/* Get userspace string and assure termination */
8504d6380   Peter Huewe   mfd: Use kstrtoul...
467
  	err = kstrtoul_from_user(user_buf, count, 0, &user_address);
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
468
  	if (err)
8504d6380   Peter Huewe   mfd: Use kstrtoul...
469
  		return err;
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
470
471
472
473
474
475
  	if (user_address > 0xff) {
  		dev_err(dev, "debugfs error input > 0xff
  ");
  		return -EINVAL;
  	}
  	debug_address = user_address;
8504d6380   Peter Huewe   mfd: Use kstrtoul...
476
  	return count;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
477
478
479
480
  }
  
  static int ab8500_val_print(struct seq_file *s, void *p)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
  	struct device *dev = s->private;
  	int ret;
  	u8 regvalue;
  
  	ret = abx500_get_register_interruptible(dev,
  		(u8)debug_bank, (u8)debug_address, &regvalue);
  	if (ret < 0) {
  		dev_err(dev, "abx500_get_reg fail %d, %d
  ",
  			ret, __LINE__);
  		return -EINVAL;
  	}
  	seq_printf(s, "0x%02X
  ", regvalue);
  
  	return 0;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
497
498
499
500
  }
  
  static int ab8500_val_open(struct inode *inode, struct file *file)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
501
  	return single_open(file, ab8500_val_print, inode->i_private);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
502
503
504
  }
  
  static ssize_t ab8500_val_write(struct file *file,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
505
506
  	const char __user *user_buf,
  	size_t count, loff_t *ppos)
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
507
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
508
  	struct device *dev = ((struct seq_file *)(file->private_data))->private;
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
509
510
511
512
  	unsigned long user_val;
  	int err;
  
  	/* Get userspace string and assure termination */
8504d6380   Peter Huewe   mfd: Use kstrtoul...
513
  	err = kstrtoul_from_user(user_buf, count, 0, &user_val);
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
514
  	if (err)
8504d6380   Peter Huewe   mfd: Use kstrtoul...
515
  		return err;
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
516
517
518
519
520
521
522
523
524
525
526
  	if (user_val > 0xff) {
  		dev_err(dev, "debugfs error input > 0xff
  ");
  		return -EINVAL;
  	}
  	err = abx500_set_register_interruptible(dev,
  		(u8)debug_bank, debug_address, (u8)user_val);
  	if (err < 0) {
  		printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
  		return -EINVAL;
  	}
8504d6380   Peter Huewe   mfd: Use kstrtoul...
527
  	return count;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
528
529
530
  }
  
  static const struct file_operations ab8500_bank_fops = {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
531
532
533
534
535
536
  	.open = ab8500_bank_open,
  	.write = ab8500_bank_write,
  	.read = seq_read,
  	.llseek = seq_lseek,
  	.release = single_release,
  	.owner = THIS_MODULE,
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
537
538
539
  };
  
  static const struct file_operations ab8500_address_fops = {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
540
541
542
543
544
545
  	.open = ab8500_address_open,
  	.write = ab8500_address_write,
  	.read = seq_read,
  	.llseek = seq_lseek,
  	.release = single_release,
  	.owner = THIS_MODULE,
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
546
547
548
  };
  
  static const struct file_operations ab8500_val_fops = {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
549
550
551
552
553
554
  	.open = ab8500_val_open,
  	.write = ab8500_val_write,
  	.read = seq_read,
  	.llseek = seq_lseek,
  	.release = single_release,
  	.owner = THIS_MODULE,
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
555
556
557
558
559
560
561
562
563
564
  };
  
  static struct dentry *ab8500_dir;
  static struct dentry *ab8500_reg_file;
  static struct dentry *ab8500_bank_file;
  static struct dentry *ab8500_address_file;
  static struct dentry *ab8500_val_file;
  
  static int __devinit ab8500_debug_probe(struct platform_device *plf)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
565
566
  	debug_bank = AB8500_MISC;
  	debug_address = AB8500_REV_REG & 0x00FF;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
567

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
568
569
570
  	ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
  	if (!ab8500_dir)
  		goto exit_no_debugfs;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
571

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
572
573
574
575
  	ab8500_reg_file = debugfs_create_file("all-bank-registers",
  		S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops);
  	if (!ab8500_reg_file)
  		goto exit_destroy_dir;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
576

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
577
  	ab8500_bank_file = debugfs_create_file("register-bank",
44bdcb54d   Vasiliy Kulikov   mfd: ab8500: worl...
578
  		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_bank_fops);
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
579
580
  	if (!ab8500_bank_file)
  		goto exit_destroy_reg;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
581

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
582
  	ab8500_address_file = debugfs_create_file("register-address",
44bdcb54d   Vasiliy Kulikov   mfd: ab8500: worl...
583
  		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
584
585
586
  		&ab8500_address_fops);
  	if (!ab8500_address_file)
  		goto exit_destroy_bank;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
587

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
588
  	ab8500_val_file = debugfs_create_file("register-value",
44bdcb54d   Vasiliy Kulikov   mfd: ab8500: worl...
589
  		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_val_fops);
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
590
591
  	if (!ab8500_val_file)
  		goto exit_destroy_address;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
592

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
593
  	return 0;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
594
595
  
  exit_destroy_address:
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
596
  	debugfs_remove(ab8500_address_file);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
597
  exit_destroy_bank:
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
598
  	debugfs_remove(ab8500_bank_file);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
599
  exit_destroy_reg:
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
600
  	debugfs_remove(ab8500_reg_file);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
601
  exit_destroy_dir:
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
602
  	debugfs_remove(ab8500_dir);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
603
  exit_no_debugfs:
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
604
605
606
  	dev_err(&plf->dev, "failed to create debugfs entries.
  ");
  	return -ENOMEM;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
607
608
609
610
  }
  
  static int __devexit ab8500_debug_remove(struct platform_device *plf)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
611
612
613
614
615
  	debugfs_remove(ab8500_val_file);
  	debugfs_remove(ab8500_address_file);
  	debugfs_remove(ab8500_bank_file);
  	debugfs_remove(ab8500_reg_file);
  	debugfs_remove(ab8500_dir);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
616

d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
617
  	return 0;
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
618
619
620
  }
  
  static struct platform_driver ab8500_debug_driver = {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
621
622
623
624
625
626
  	.driver = {
  		.name = "ab8500-debug",
  		.owner = THIS_MODULE,
  	},
  	.probe  = ab8500_debug_probe,
  	.remove = __devexit_p(ab8500_debug_remove)
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
627
628
629
630
  };
  
  static int __init ab8500_debug_init(void)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
631
  	return platform_driver_register(&ab8500_debug_driver);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
632
633
634
635
  }
  
  static void __exit ab8500_debug_exit(void)
  {
d7b9f3220   Mattias Wallin   mfd: Fix ab8500-d...
636
  	platform_driver_unregister(&ab8500_debug_driver);
5814fc35e   Mattias Wallin   mfd: AB8500 debugfs
637
638
639
640
641
642
643
  }
  subsys_initcall(ab8500_debug_init);
  module_exit(ab8500_debug_exit);
  
  MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
  MODULE_DESCRIPTION("AB8500 DEBUG");
  MODULE_LICENSE("GPL v2");