Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1 | /* |
| 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 | */ |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 7 | /* |
| 8 | * AB8500 register access |
| 9 | * ====================== |
| 10 | * |
| 11 | * read: |
| 12 | * # echo BANK > <debugfs>/ab8500/register-bank |
| 13 | * # echo ADDR > <debugfs>/ab8500/register-address |
| 14 | * # cat <debugfs>/ab8500/register-value |
| 15 | * |
| 16 | * write: |
| 17 | * # echo BANK > <debugfs>/ab8500/register-bank |
| 18 | * # echo ADDR > <debugfs>/ab8500/register-address |
| 19 | * # echo VALUE > <debugfs>/ab8500/register-value |
| 20 | * |
| 21 | * read all registers from a bank: |
| 22 | * # echo BANK > <debugfs>/ab8500/register-bank |
| 23 | * # cat <debugfs>/ab8500/all-bank-register |
| 24 | * |
| 25 | * BANK target AB8500 register bank |
| 26 | * ADDR target AB8500 register address |
| 27 | * VALUE decimal or 0x-prefixed hexadecimal |
| 28 | * |
| 29 | * |
| 30 | * User Space notification on AB8500 IRQ |
| 31 | * ===================================== |
| 32 | * |
| 33 | * Allows user space entity to be notified when target AB8500 IRQ occurs. |
| 34 | * When subscribed, a sysfs entry is created in ab8500.i2c platform device. |
| 35 | * One can pool this file to get target IRQ occurence information. |
| 36 | * |
| 37 | * subscribe to an AB8500 IRQ: |
| 38 | * # echo IRQ > <debugfs>/ab8500/irq-subscribe |
| 39 | * |
| 40 | * unsubscribe from an AB8500 IRQ: |
| 41 | * # echo IRQ > <debugfs>/ab8500/irq-unsubscribe |
| 42 | * |
| 43 | * |
| 44 | * AB8500 register formated read/write access |
| 45 | * ========================================== |
| 46 | * |
| 47 | * Read: read data, data>>SHIFT, data&=MASK, output data |
| 48 | * [0xABCDEF98] shift=12 mask=0xFFF => 0x00000CDE |
| 49 | * Write: read data, data &= ~(MASK<<SHIFT), data |= (VALUE<<SHIFT), write data |
| 50 | * [0xABCDEF98] shift=12 mask=0xFFF value=0x123 => [0xAB123F98] |
| 51 | * |
| 52 | * Usage: |
| 53 | * # echo "CMD [OPTIONS] BANK ADRESS [VALUE]" > $debugfs/ab8500/hwreg |
| 54 | * |
| 55 | * CMD read read access |
| 56 | * write write access |
| 57 | * |
| 58 | * BANK target reg bank |
| 59 | * ADDRESS target reg address |
| 60 | * VALUE (write) value to be updated |
| 61 | * |
| 62 | * OPTIONS |
| 63 | * -d|-dec (read) output in decimal |
| 64 | * -h|-hexa (read) output in 0x-hexa (default) |
| 65 | * -l|-w|-b 32bit (default), 16bit or 8bit reg access |
| 66 | * -m|-mask MASK 0x-hexa mask (default 0xFFFFFFFF) |
| 67 | * -s|-shift SHIFT bit shift value (read:left, write:right) |
| 68 | * -o|-offset OFFSET address offset to add to ADDRESS value |
| 69 | * |
| 70 | * Warning: bit shift operation is applied to bit-mask. |
| 71 | * Warning: bit shift direction depends on read or right command. |
| 72 | */ |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 73 | |
| 74 | #include <linux/seq_file.h> |
| 75 | #include <linux/uaccess.h> |
| 76 | #include <linux/fs.h> |
Paul Gortmaker | 4e36dd3 | 2011-07-03 15:13:27 -0400 | [diff] [blame] | 77 | #include <linux/module.h> |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 78 | #include <linux/debugfs.h> |
| 79 | #include <linux/platform_device.h> |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 80 | #include <linux/interrupt.h> |
| 81 | #include <linux/kobject.h> |
| 82 | #include <linux/slab.h> |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 83 | #include <linux/irq.h> |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 84 | |
| 85 | #include <linux/mfd/abx500.h> |
Linus Walleij | 0cd5b6d0 | 2013-02-06 23:23:01 +0100 | [diff] [blame] | 86 | #include <linux/mfd/abx500/ab8500.h> |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 87 | #include <linux/mfd/abx500/ab8500-gpadc.h> |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 88 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 89 | #ifdef CONFIG_DEBUG_FS |
| 90 | #include <linux/string.h> |
| 91 | #include <linux/ctype.h> |
| 92 | #endif |
| 93 | |
Linus Walleij | eb1f958 | 2012-11-22 18:50:06 +0100 | [diff] [blame] | 94 | /* TODO: this file should not reference IRQ_DB8500_AB8500! */ |
| 95 | #include <mach/irqs.h> |
| 96 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 97 | static u32 debug_bank; |
| 98 | static u32 debug_address; |
| 99 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 100 | static int irq_first; |
| 101 | static int irq_last; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 102 | static u32 *irq_count; |
| 103 | static int num_irqs; |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 104 | |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 105 | static struct device_attribute **dev_attr; |
| 106 | static char **event_name; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 107 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 108 | static u8 avg_sample = SAMPLE_16; |
| 109 | static u8 trig_edge = RISING_EDGE; |
| 110 | static u8 conv_type = ADC_SW; |
| 111 | static u8 trig_timer; |
| 112 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 113 | /** |
| 114 | * struct ab8500_reg_range |
| 115 | * @first: the first address of the range |
| 116 | * @last: the last address of the range |
| 117 | * @perm: access permissions for the range |
| 118 | */ |
| 119 | struct ab8500_reg_range { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 120 | u8 first; |
| 121 | u8 last; |
| 122 | u8 perm; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | /** |
Lee Jones | 822672a | 2012-06-20 13:56:38 +0100 | [diff] [blame] | 126 | * struct ab8500_prcmu_ranges |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 127 | * @num_ranges: the number of ranges in the list |
| 128 | * @bankid: bank identifier |
| 129 | * @range: the list of register ranges |
| 130 | */ |
Lee Jones | 822672a | 2012-06-20 13:56:38 +0100 | [diff] [blame] | 131 | struct ab8500_prcmu_ranges { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 132 | u8 num_ranges; |
| 133 | u8 bankid; |
| 134 | const struct ab8500_reg_range *range; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 135 | }; |
| 136 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 137 | /* hwreg- "mask" and "shift" entries ressources */ |
| 138 | struct hwreg_cfg { |
| 139 | u32 bank; /* target bank */ |
| 140 | u32 addr; /* target address */ |
| 141 | uint fmt; /* format */ |
| 142 | uint mask; /* read/write mask, applied before any bit shift */ |
| 143 | int shift; /* bit shift (read:right shift, write:left shift */ |
| 144 | }; |
| 145 | /* fmt bit #0: 0=hexa, 1=dec */ |
| 146 | #define REG_FMT_DEC(c) ((c)->fmt & 0x1) |
| 147 | #define REG_FMT_HEX(c) (!REG_FMT_DEC(c)) |
| 148 | |
| 149 | static struct hwreg_cfg hwreg_cfg = { |
| 150 | .addr = 0, /* default: invalid phys addr */ |
| 151 | .fmt = 0, /* default: 32bit access, hex output */ |
| 152 | .mask = 0xFFFFFFFF, /* default: no mask */ |
| 153 | .shift = 0, /* default: no bit shift */ |
| 154 | }; |
| 155 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 156 | #define AB8500_NAME_STRING "ab8500" |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 157 | #define AB8500_ADC_NAME_STRING "gpadc" |
Philippe Langlais | 40c064e | 2011-10-17 09:48:55 +0200 | [diff] [blame] | 158 | #define AB8500_NUM_BANKS 24 |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 159 | |
| 160 | #define AB8500_REV_REG 0x80 |
| 161 | |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 162 | static struct ab8500_prcmu_ranges *debug_ranges; |
| 163 | |
| 164 | struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 165 | [0x0] = { |
| 166 | .num_ranges = 0, |
Lee Jones | fad55a8 | 2013-01-14 17:17:34 +0000 | [diff] [blame] | 167 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 168 | }, |
| 169 | [AB8500_SYS_CTRL1_BLOCK] = { |
| 170 | .num_ranges = 3, |
| 171 | .range = (struct ab8500_reg_range[]) { |
| 172 | { |
| 173 | .first = 0x00, |
| 174 | .last = 0x02, |
| 175 | }, |
| 176 | { |
| 177 | .first = 0x42, |
| 178 | .last = 0x42, |
| 179 | }, |
| 180 | { |
| 181 | .first = 0x80, |
| 182 | .last = 0x81, |
| 183 | }, |
| 184 | }, |
| 185 | }, |
| 186 | [AB8500_SYS_CTRL2_BLOCK] = { |
| 187 | .num_ranges = 4, |
| 188 | .range = (struct ab8500_reg_range[]) { |
| 189 | { |
| 190 | .first = 0x00, |
| 191 | .last = 0x0D, |
| 192 | }, |
| 193 | { |
| 194 | .first = 0x0F, |
| 195 | .last = 0x17, |
| 196 | }, |
| 197 | { |
| 198 | .first = 0x30, |
| 199 | .last = 0x30, |
| 200 | }, |
| 201 | { |
| 202 | .first = 0x32, |
| 203 | .last = 0x33, |
| 204 | }, |
| 205 | }, |
| 206 | }, |
| 207 | [AB8500_REGU_CTRL1] = { |
| 208 | .num_ranges = 3, |
| 209 | .range = (struct ab8500_reg_range[]) { |
| 210 | { |
| 211 | .first = 0x00, |
| 212 | .last = 0x00, |
| 213 | }, |
| 214 | { |
| 215 | .first = 0x03, |
| 216 | .last = 0x10, |
| 217 | }, |
| 218 | { |
| 219 | .first = 0x80, |
| 220 | .last = 0x84, |
| 221 | }, |
| 222 | }, |
| 223 | }, |
| 224 | [AB8500_REGU_CTRL2] = { |
| 225 | .num_ranges = 5, |
| 226 | .range = (struct ab8500_reg_range[]) { |
| 227 | { |
| 228 | .first = 0x00, |
| 229 | .last = 0x15, |
| 230 | }, |
| 231 | { |
| 232 | .first = 0x17, |
| 233 | .last = 0x19, |
| 234 | }, |
| 235 | { |
| 236 | .first = 0x1B, |
| 237 | .last = 0x1D, |
| 238 | }, |
| 239 | { |
| 240 | .first = 0x1F, |
| 241 | .last = 0x22, |
| 242 | }, |
| 243 | { |
| 244 | .first = 0x40, |
| 245 | .last = 0x44, |
| 246 | }, |
| 247 | /* 0x80-0x8B is SIM registers and should |
| 248 | * not be accessed from here */ |
| 249 | }, |
| 250 | }, |
| 251 | [AB8500_USB] = { |
| 252 | .num_ranges = 2, |
| 253 | .range = (struct ab8500_reg_range[]) { |
| 254 | { |
| 255 | .first = 0x80, |
| 256 | .last = 0x83, |
| 257 | }, |
| 258 | { |
| 259 | .first = 0x87, |
| 260 | .last = 0x8A, |
| 261 | }, |
| 262 | }, |
| 263 | }, |
| 264 | [AB8500_TVOUT] = { |
| 265 | .num_ranges = 9, |
| 266 | .range = (struct ab8500_reg_range[]) { |
| 267 | { |
| 268 | .first = 0x00, |
| 269 | .last = 0x12, |
| 270 | }, |
| 271 | { |
| 272 | .first = 0x15, |
| 273 | .last = 0x17, |
| 274 | }, |
| 275 | { |
| 276 | .first = 0x19, |
| 277 | .last = 0x21, |
| 278 | }, |
| 279 | { |
| 280 | .first = 0x27, |
| 281 | .last = 0x2C, |
| 282 | }, |
| 283 | { |
| 284 | .first = 0x41, |
| 285 | .last = 0x41, |
| 286 | }, |
| 287 | { |
| 288 | .first = 0x45, |
| 289 | .last = 0x5B, |
| 290 | }, |
| 291 | { |
| 292 | .first = 0x5D, |
| 293 | .last = 0x5D, |
| 294 | }, |
| 295 | { |
| 296 | .first = 0x69, |
| 297 | .last = 0x69, |
| 298 | }, |
| 299 | { |
| 300 | .first = 0x80, |
| 301 | .last = 0x81, |
| 302 | }, |
| 303 | }, |
| 304 | }, |
| 305 | [AB8500_DBI] = { |
| 306 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 307 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 308 | }, |
| 309 | [AB8500_ECI_AV_ACC] = { |
| 310 | .num_ranges = 1, |
| 311 | .range = (struct ab8500_reg_range[]) { |
| 312 | { |
| 313 | .first = 0x80, |
| 314 | .last = 0x82, |
| 315 | }, |
| 316 | }, |
| 317 | }, |
| 318 | [0x9] = { |
| 319 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 320 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 321 | }, |
| 322 | [AB8500_GPADC] = { |
| 323 | .num_ranges = 1, |
| 324 | .range = (struct ab8500_reg_range[]) { |
| 325 | { |
| 326 | .first = 0x00, |
| 327 | .last = 0x08, |
| 328 | }, |
| 329 | }, |
| 330 | }, |
| 331 | [AB8500_CHARGER] = { |
Philippe Langlais | 40c064e | 2011-10-17 09:48:55 +0200 | [diff] [blame] | 332 | .num_ranges = 9, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 333 | .range = (struct ab8500_reg_range[]) { |
| 334 | { |
| 335 | .first = 0x00, |
| 336 | .last = 0x03, |
| 337 | }, |
| 338 | { |
| 339 | .first = 0x05, |
| 340 | .last = 0x05, |
| 341 | }, |
| 342 | { |
| 343 | .first = 0x40, |
| 344 | .last = 0x40, |
| 345 | }, |
| 346 | { |
| 347 | .first = 0x42, |
| 348 | .last = 0x42, |
| 349 | }, |
| 350 | { |
| 351 | .first = 0x44, |
| 352 | .last = 0x44, |
| 353 | }, |
| 354 | { |
| 355 | .first = 0x50, |
| 356 | .last = 0x55, |
| 357 | }, |
| 358 | { |
| 359 | .first = 0x80, |
| 360 | .last = 0x82, |
| 361 | }, |
| 362 | { |
| 363 | .first = 0xC0, |
| 364 | .last = 0xC2, |
| 365 | }, |
Philippe Langlais | 40c064e | 2011-10-17 09:48:55 +0200 | [diff] [blame] | 366 | { |
| 367 | .first = 0xf5, |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 368 | .last = 0xf6, |
Philippe Langlais | 40c064e | 2011-10-17 09:48:55 +0200 | [diff] [blame] | 369 | }, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 370 | }, |
| 371 | }, |
| 372 | [AB8500_GAS_GAUGE] = { |
| 373 | .num_ranges = 3, |
| 374 | .range = (struct ab8500_reg_range[]) { |
| 375 | { |
| 376 | .first = 0x00, |
| 377 | .last = 0x00, |
| 378 | }, |
| 379 | { |
| 380 | .first = 0x07, |
| 381 | .last = 0x0A, |
| 382 | }, |
| 383 | { |
| 384 | .first = 0x10, |
| 385 | .last = 0x14, |
| 386 | }, |
| 387 | }, |
| 388 | }, |
Philippe Langlais | 40c064e | 2011-10-17 09:48:55 +0200 | [diff] [blame] | 389 | [AB8500_DEVELOPMENT] = { |
| 390 | .num_ranges = 1, |
| 391 | .range = (struct ab8500_reg_range[]) { |
| 392 | { |
| 393 | .first = 0x00, |
| 394 | .last = 0x00, |
| 395 | }, |
| 396 | }, |
| 397 | }, |
| 398 | [AB8500_DEBUG] = { |
| 399 | .num_ranges = 1, |
| 400 | .range = (struct ab8500_reg_range[]) { |
| 401 | { |
| 402 | .first = 0x05, |
| 403 | .last = 0x07, |
| 404 | }, |
| 405 | }, |
| 406 | }, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 407 | [AB8500_AUDIO] = { |
| 408 | .num_ranges = 1, |
| 409 | .range = (struct ab8500_reg_range[]) { |
| 410 | { |
| 411 | .first = 0x00, |
| 412 | .last = 0x6F, |
| 413 | }, |
| 414 | }, |
| 415 | }, |
| 416 | [AB8500_INTERRUPT] = { |
| 417 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 418 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 419 | }, |
| 420 | [AB8500_RTC] = { |
| 421 | .num_ranges = 1, |
| 422 | .range = (struct ab8500_reg_range[]) { |
| 423 | { |
| 424 | .first = 0x00, |
| 425 | .last = 0x0F, |
| 426 | }, |
| 427 | }, |
| 428 | }, |
| 429 | [AB8500_MISC] = { |
| 430 | .num_ranges = 8, |
| 431 | .range = (struct ab8500_reg_range[]) { |
| 432 | { |
| 433 | .first = 0x00, |
| 434 | .last = 0x05, |
| 435 | }, |
| 436 | { |
| 437 | .first = 0x10, |
| 438 | .last = 0x15, |
| 439 | }, |
| 440 | { |
| 441 | .first = 0x20, |
| 442 | .last = 0x25, |
| 443 | }, |
| 444 | { |
| 445 | .first = 0x30, |
| 446 | .last = 0x35, |
| 447 | }, |
| 448 | { |
| 449 | .first = 0x40, |
| 450 | .last = 0x45, |
| 451 | }, |
| 452 | { |
| 453 | .first = 0x50, |
| 454 | .last = 0x50, |
| 455 | }, |
| 456 | { |
| 457 | .first = 0x60, |
| 458 | .last = 0x67, |
| 459 | }, |
| 460 | { |
| 461 | .first = 0x80, |
| 462 | .last = 0x80, |
| 463 | }, |
| 464 | }, |
| 465 | }, |
| 466 | [0x11] = { |
| 467 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 468 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 469 | }, |
| 470 | [0x12] = { |
| 471 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 472 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 473 | }, |
| 474 | [0x13] = { |
| 475 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 476 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 477 | }, |
| 478 | [0x14] = { |
| 479 | .num_ranges = 0, |
Mark Brown | 87fff23 | 2010-12-13 14:06:47 +0000 | [diff] [blame] | 480 | .range = NULL, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 481 | }, |
| 482 | [AB8500_OTP_EMUL] = { |
| 483 | .num_ranges = 1, |
| 484 | .range = (struct ab8500_reg_range[]) { |
| 485 | { |
| 486 | .first = 0x01, |
| 487 | .last = 0x0F, |
| 488 | }, |
| 489 | }, |
| 490 | }, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 491 | }; |
| 492 | |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 493 | struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { |
| 494 | [0x0] = { |
| 495 | .num_ranges = 0, |
| 496 | .range = NULL, |
| 497 | }, |
| 498 | [AB8500_SYS_CTRL1_BLOCK] = { |
| 499 | .num_ranges = 5, |
| 500 | .range = (struct ab8500_reg_range[]) { |
| 501 | { |
| 502 | .first = 0x00, |
| 503 | .last = 0x04, |
| 504 | }, |
| 505 | { |
| 506 | .first = 0x42, |
| 507 | .last = 0x42, |
| 508 | }, |
| 509 | { |
| 510 | .first = 0x52, |
| 511 | .last = 0x52, |
| 512 | }, |
| 513 | { |
| 514 | .first = 0x54, |
| 515 | .last = 0x57, |
| 516 | }, |
| 517 | { |
| 518 | .first = 0x80, |
| 519 | .last = 0x83, |
| 520 | }, |
| 521 | }, |
| 522 | }, |
| 523 | [AB8500_SYS_CTRL2_BLOCK] = { |
| 524 | .num_ranges = 5, |
| 525 | .range = (struct ab8500_reg_range[]) { |
| 526 | { |
| 527 | .first = 0x00, |
| 528 | .last = 0x0D, |
| 529 | }, |
| 530 | { |
| 531 | .first = 0x0F, |
| 532 | .last = 0x17, |
| 533 | }, |
| 534 | { |
| 535 | .first = 0x20, |
| 536 | .last = 0x20, |
| 537 | }, |
| 538 | { |
| 539 | .first = 0x30, |
| 540 | .last = 0x30, |
| 541 | }, |
| 542 | { |
| 543 | .first = 0x32, |
| 544 | .last = 0x3A, |
| 545 | }, |
| 546 | }, |
| 547 | }, |
| 548 | [AB8500_REGU_CTRL1] = { |
| 549 | .num_ranges = 3, |
| 550 | .range = (struct ab8500_reg_range[]) { |
| 551 | { |
| 552 | .first = 0x00, |
| 553 | .last = 0x00, |
| 554 | }, |
| 555 | { |
| 556 | .first = 0x03, |
| 557 | .last = 0x11, |
| 558 | }, |
| 559 | { |
| 560 | .first = 0x80, |
| 561 | .last = 0x86, |
| 562 | }, |
| 563 | }, |
| 564 | }, |
| 565 | [AB8500_REGU_CTRL2] = { |
| 566 | .num_ranges = 6, |
| 567 | .range = (struct ab8500_reg_range[]) { |
| 568 | { |
| 569 | .first = 0x00, |
| 570 | .last = 0x06, |
| 571 | }, |
| 572 | { |
| 573 | .first = 0x08, |
| 574 | .last = 0x15, |
| 575 | }, |
| 576 | { |
| 577 | .first = 0x17, |
| 578 | .last = 0x19, |
| 579 | }, |
| 580 | { |
| 581 | .first = 0x1B, |
| 582 | .last = 0x1D, |
| 583 | }, |
| 584 | { |
| 585 | .first = 0x1F, |
| 586 | .last = 0x30, |
| 587 | }, |
| 588 | { |
| 589 | .first = 0x40, |
| 590 | .last = 0x48, |
| 591 | }, |
| 592 | /* 0x80-0x8B is SIM registers and should |
| 593 | * not be accessed from here */ |
| 594 | }, |
| 595 | }, |
| 596 | [AB8500_USB] = { |
| 597 | .num_ranges = 3, |
| 598 | .range = (struct ab8500_reg_range[]) { |
| 599 | { |
| 600 | .first = 0x80, |
| 601 | .last = 0x83, |
| 602 | }, |
| 603 | { |
| 604 | .first = 0x87, |
| 605 | .last = 0x8A, |
| 606 | }, |
| 607 | { |
| 608 | .first = 0x91, |
| 609 | .last = 0x94, |
| 610 | }, |
| 611 | }, |
| 612 | }, |
| 613 | [AB8500_TVOUT] = { |
| 614 | .num_ranges = 0, |
| 615 | .range = NULL, |
| 616 | }, |
| 617 | [AB8500_DBI] = { |
| 618 | .num_ranges = 0, |
| 619 | .range = NULL, |
| 620 | }, |
| 621 | [AB8500_ECI_AV_ACC] = { |
| 622 | .num_ranges = 1, |
| 623 | .range = (struct ab8500_reg_range[]) { |
| 624 | { |
| 625 | .first = 0x80, |
| 626 | .last = 0x82, |
| 627 | }, |
| 628 | }, |
| 629 | }, |
| 630 | [AB8500_RESERVED] = { |
| 631 | .num_ranges = 0, |
| 632 | .range = NULL, |
| 633 | }, |
| 634 | [AB8500_GPADC] = { |
| 635 | .num_ranges = 1, |
| 636 | .range = (struct ab8500_reg_range[]) { |
| 637 | { |
| 638 | .first = 0x00, |
| 639 | .last = 0x08, |
| 640 | }, |
| 641 | }, |
| 642 | }, |
| 643 | [AB8500_CHARGER] = { |
| 644 | .num_ranges = 9, |
| 645 | .range = (struct ab8500_reg_range[]) { |
| 646 | { |
| 647 | .first = 0x02, |
| 648 | .last = 0x03, |
| 649 | }, |
| 650 | { |
| 651 | .first = 0x05, |
| 652 | .last = 0x05, |
| 653 | }, |
| 654 | { |
| 655 | .first = 0x40, |
| 656 | .last = 0x44, |
| 657 | }, |
| 658 | { |
| 659 | .first = 0x50, |
| 660 | .last = 0x57, |
| 661 | }, |
| 662 | { |
| 663 | .first = 0x60, |
| 664 | .last = 0x60, |
| 665 | }, |
| 666 | { |
| 667 | .first = 0xA0, |
| 668 | .last = 0xA7, |
| 669 | }, |
| 670 | { |
| 671 | .first = 0xAF, |
| 672 | .last = 0xB2, |
| 673 | }, |
| 674 | { |
| 675 | .first = 0xC0, |
| 676 | .last = 0xC2, |
| 677 | }, |
| 678 | { |
| 679 | .first = 0xF5, |
| 680 | .last = 0xF5, |
| 681 | }, |
| 682 | }, |
| 683 | }, |
| 684 | [AB8500_GAS_GAUGE] = { |
| 685 | .num_ranges = 3, |
| 686 | .range = (struct ab8500_reg_range[]) { |
| 687 | { |
| 688 | .first = 0x00, |
| 689 | .last = 0x00, |
| 690 | }, |
| 691 | { |
| 692 | .first = 0x07, |
| 693 | .last = 0x0A, |
| 694 | }, |
| 695 | { |
| 696 | .first = 0x10, |
| 697 | .last = 0x14, |
| 698 | }, |
| 699 | }, |
| 700 | }, |
| 701 | [AB8500_AUDIO] = { |
| 702 | .num_ranges = 1, |
| 703 | .range = (struct ab8500_reg_range[]) { |
| 704 | { |
| 705 | .first = 0x00, |
| 706 | .last = 0x83, |
| 707 | }, |
| 708 | }, |
| 709 | }, |
| 710 | [AB8500_INTERRUPT] = { |
| 711 | .num_ranges = 11, |
| 712 | .range = (struct ab8500_reg_range[]) { |
| 713 | { |
| 714 | .first = 0x00, |
| 715 | .last = 0x04, |
| 716 | }, |
| 717 | { |
| 718 | .first = 0x06, |
| 719 | .last = 0x07, |
| 720 | }, |
| 721 | { |
| 722 | .first = 0x09, |
| 723 | .last = 0x09, |
| 724 | }, |
| 725 | { |
| 726 | .first = 0x0B, |
| 727 | .last = 0x0C, |
| 728 | }, |
| 729 | { |
| 730 | .first = 0x12, |
| 731 | .last = 0x15, |
| 732 | }, |
| 733 | { |
| 734 | .first = 0x18, |
| 735 | .last = 0x18, |
| 736 | }, |
| 737 | /* Latch registers should not be read here */ |
| 738 | { |
| 739 | .first = 0x40, |
| 740 | .last = 0x44, |
| 741 | }, |
| 742 | { |
| 743 | .first = 0x46, |
| 744 | .last = 0x49, |
| 745 | }, |
| 746 | { |
| 747 | .first = 0x4B, |
| 748 | .last = 0x4D, |
| 749 | }, |
| 750 | { |
| 751 | .first = 0x52, |
| 752 | .last = 0x55, |
| 753 | }, |
| 754 | { |
| 755 | .first = 0x58, |
| 756 | .last = 0x58, |
| 757 | }, |
| 758 | /* LatchHier registers should not be read here */ |
| 759 | }, |
| 760 | }, |
| 761 | [AB8500_RTC] = { |
| 762 | .num_ranges = 2, |
| 763 | .range = (struct ab8500_reg_range[]) { |
| 764 | { |
| 765 | .first = 0x00, |
| 766 | .last = 0x14, |
| 767 | }, |
| 768 | { |
| 769 | .first = 0x16, |
| 770 | .last = 0x17, |
| 771 | }, |
| 772 | }, |
| 773 | }, |
| 774 | [AB8500_MISC] = { |
| 775 | .num_ranges = 8, |
| 776 | .range = (struct ab8500_reg_range[]) { |
| 777 | { |
| 778 | .first = 0x00, |
| 779 | .last = 0x06, |
| 780 | }, |
| 781 | { |
| 782 | .first = 0x10, |
| 783 | .last = 0x16, |
| 784 | }, |
| 785 | { |
| 786 | .first = 0x20, |
| 787 | .last = 0x26, |
| 788 | }, |
| 789 | { |
| 790 | .first = 0x30, |
| 791 | .last = 0x36, |
| 792 | }, |
| 793 | { |
| 794 | .first = 0x40, |
| 795 | .last = 0x46, |
| 796 | }, |
| 797 | { |
| 798 | .first = 0x50, |
| 799 | .last = 0x50, |
| 800 | }, |
| 801 | { |
| 802 | .first = 0x60, |
| 803 | .last = 0x6B, |
| 804 | }, |
| 805 | { |
| 806 | .first = 0x80, |
| 807 | .last = 0x82, |
| 808 | }, |
| 809 | }, |
| 810 | }, |
| 811 | [AB8500_DEVELOPMENT] = { |
| 812 | .num_ranges = 2, |
| 813 | .range = (struct ab8500_reg_range[]) { |
| 814 | { |
| 815 | .first = 0x00, |
| 816 | .last = 0x00, |
| 817 | }, |
| 818 | { |
| 819 | .first = 0x05, |
| 820 | .last = 0x05, |
| 821 | }, |
| 822 | }, |
| 823 | }, |
| 824 | [AB8500_DEBUG] = { |
| 825 | .num_ranges = 1, |
| 826 | .range = (struct ab8500_reg_range[]) { |
| 827 | { |
| 828 | .first = 0x05, |
| 829 | .last = 0x07, |
| 830 | }, |
| 831 | }, |
| 832 | }, |
| 833 | [AB8500_PROD_TEST] = { |
| 834 | .num_ranges = 0, |
| 835 | .range = NULL, |
| 836 | }, |
| 837 | [AB8500_STE_TEST] = { |
| 838 | .num_ranges = 0, |
| 839 | .range = NULL, |
| 840 | }, |
| 841 | [AB8500_OTP_EMUL] = { |
| 842 | .num_ranges = 1, |
| 843 | .range = (struct ab8500_reg_range[]) { |
| 844 | { |
| 845 | .first = 0x01, |
| 846 | .last = 0x15, |
| 847 | }, |
| 848 | }, |
| 849 | }, |
| 850 | }; |
| 851 | |
Lee Jones | 971480f | 2012-11-19 12:20:03 +0100 | [diff] [blame] | 852 | struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { |
| 853 | [AB8500_M_FSM_RANK] = { |
| 854 | .num_ranges = 1, |
| 855 | .range = (struct ab8500_reg_range[]) { |
| 856 | { |
| 857 | .first = 0x00, |
| 858 | .last = 0x0B, |
| 859 | }, |
| 860 | }, |
| 861 | }, |
| 862 | [AB8500_SYS_CTRL1_BLOCK] = { |
| 863 | .num_ranges = 6, |
| 864 | .range = (struct ab8500_reg_range[]) { |
| 865 | { |
| 866 | .first = 0x00, |
| 867 | .last = 0x04, |
| 868 | }, |
| 869 | { |
| 870 | .first = 0x42, |
| 871 | .last = 0x42, |
| 872 | }, |
| 873 | { |
| 874 | .first = 0x50, |
| 875 | .last = 0x54, |
| 876 | }, |
| 877 | { |
| 878 | .first = 0x57, |
| 879 | .last = 0x57, |
| 880 | }, |
| 881 | { |
| 882 | .first = 0x80, |
| 883 | .last = 0x83, |
| 884 | }, |
| 885 | { |
| 886 | .first = 0x90, |
| 887 | .last = 0x90, |
| 888 | }, |
| 889 | }, |
| 890 | }, |
| 891 | [AB8500_SYS_CTRL2_BLOCK] = { |
| 892 | .num_ranges = 5, |
| 893 | .range = (struct ab8500_reg_range[]) { |
| 894 | { |
| 895 | .first = 0x00, |
| 896 | .last = 0x0D, |
| 897 | }, |
| 898 | { |
| 899 | .first = 0x0F, |
| 900 | .last = 0x10, |
| 901 | }, |
| 902 | { |
| 903 | .first = 0x20, |
| 904 | .last = 0x21, |
| 905 | }, |
| 906 | { |
| 907 | .first = 0x32, |
| 908 | .last = 0x3C, |
| 909 | }, |
| 910 | { |
| 911 | .first = 0x40, |
| 912 | .last = 0x42, |
| 913 | }, |
| 914 | }, |
| 915 | }, |
| 916 | [AB8500_REGU_CTRL1] = { |
| 917 | .num_ranges = 4, |
| 918 | .range = (struct ab8500_reg_range[]) { |
| 919 | { |
| 920 | .first = 0x03, |
| 921 | .last = 0x15, |
| 922 | }, |
| 923 | { |
| 924 | .first = 0x20, |
| 925 | .last = 0x20, |
| 926 | }, |
| 927 | { |
| 928 | .first = 0x80, |
| 929 | .last = 0x85, |
| 930 | }, |
| 931 | { |
| 932 | .first = 0x87, |
| 933 | .last = 0x88, |
| 934 | }, |
| 935 | }, |
| 936 | }, |
| 937 | [AB8500_REGU_CTRL2] = { |
| 938 | .num_ranges = 8, |
| 939 | .range = (struct ab8500_reg_range[]) { |
| 940 | { |
| 941 | .first = 0x00, |
| 942 | .last = 0x06, |
| 943 | }, |
| 944 | { |
| 945 | .first = 0x08, |
| 946 | .last = 0x15, |
| 947 | }, |
| 948 | { |
| 949 | .first = 0x17, |
| 950 | .last = 0x19, |
| 951 | }, |
| 952 | { |
| 953 | .first = 0x1B, |
| 954 | .last = 0x1D, |
| 955 | }, |
| 956 | { |
| 957 | .first = 0x1F, |
| 958 | .last = 0x2F, |
| 959 | }, |
| 960 | { |
| 961 | .first = 0x31, |
| 962 | .last = 0x3A, |
| 963 | }, |
| 964 | { |
| 965 | .first = 0x43, |
| 966 | .last = 0x44, |
| 967 | }, |
| 968 | { |
| 969 | .first = 0x48, |
| 970 | .last = 0x49, |
| 971 | }, |
| 972 | }, |
| 973 | }, |
| 974 | [AB8500_USB] = { |
| 975 | .num_ranges = 3, |
| 976 | .range = (struct ab8500_reg_range[]) { |
| 977 | { |
| 978 | .first = 0x80, |
| 979 | .last = 0x83, |
| 980 | }, |
| 981 | { |
| 982 | .first = 0x87, |
| 983 | .last = 0x8A, |
| 984 | }, |
| 985 | { |
| 986 | .first = 0x91, |
| 987 | .last = 0x94, |
| 988 | }, |
| 989 | }, |
| 990 | }, |
| 991 | [AB8500_TVOUT] = { |
| 992 | .num_ranges = 0, |
| 993 | .range = NULL |
| 994 | }, |
| 995 | [AB8500_DBI] = { |
| 996 | .num_ranges = 4, |
| 997 | .range = (struct ab8500_reg_range[]) { |
| 998 | { |
| 999 | .first = 0x00, |
| 1000 | .last = 0x07, |
| 1001 | }, |
| 1002 | { |
| 1003 | .first = 0x10, |
| 1004 | .last = 0x11, |
| 1005 | }, |
| 1006 | { |
| 1007 | .first = 0x20, |
| 1008 | .last = 0x21, |
| 1009 | }, |
| 1010 | { |
| 1011 | .first = 0x30, |
| 1012 | .last = 0x43, |
| 1013 | }, |
| 1014 | }, |
| 1015 | }, |
| 1016 | [AB8500_ECI_AV_ACC] = { |
| 1017 | .num_ranges = 2, |
| 1018 | .range = (struct ab8500_reg_range[]) { |
| 1019 | { |
| 1020 | .first = 0x00, |
| 1021 | .last = 0x03, |
| 1022 | }, |
| 1023 | { |
| 1024 | .first = 0x80, |
| 1025 | .last = 0x82, |
| 1026 | }, |
| 1027 | }, |
| 1028 | }, |
| 1029 | [AB8500_RESERVED] = { |
| 1030 | .num_ranges = 0, |
| 1031 | .range = NULL, |
| 1032 | }, |
| 1033 | [AB8500_GPADC] = { |
| 1034 | .num_ranges = 4, |
| 1035 | .range = (struct ab8500_reg_range[]) { |
| 1036 | { |
| 1037 | .first = 0x00, |
| 1038 | .last = 0x01, |
| 1039 | }, |
| 1040 | { |
| 1041 | .first = 0x04, |
| 1042 | .last = 0x06, |
| 1043 | }, |
| 1044 | { |
| 1045 | .first = 0x09, |
| 1046 | .last = 0x0A, |
| 1047 | }, |
| 1048 | { |
| 1049 | .first = 0x10, |
| 1050 | .last = 0x14, |
| 1051 | }, |
| 1052 | }, |
| 1053 | }, |
| 1054 | [AB8500_CHARGER] = { |
| 1055 | .num_ranges = 10, |
| 1056 | .range = (struct ab8500_reg_range[]) { |
| 1057 | { |
| 1058 | .first = 0x00, |
| 1059 | .last = 0x00, |
| 1060 | }, |
| 1061 | { |
| 1062 | .first = 0x02, |
| 1063 | .last = 0x05, |
| 1064 | }, |
| 1065 | { |
| 1066 | .first = 0x40, |
| 1067 | .last = 0x44, |
| 1068 | }, |
| 1069 | { |
| 1070 | .first = 0x50, |
| 1071 | .last = 0x57, |
| 1072 | }, |
| 1073 | { |
| 1074 | .first = 0x60, |
| 1075 | .last = 0x60, |
| 1076 | }, |
| 1077 | { |
| 1078 | .first = 0x70, |
| 1079 | .last = 0x70, |
| 1080 | }, |
| 1081 | { |
| 1082 | .first = 0xA0, |
| 1083 | .last = 0xA9, |
| 1084 | }, |
| 1085 | { |
| 1086 | .first = 0xAF, |
| 1087 | .last = 0xB2, |
| 1088 | }, |
| 1089 | { |
| 1090 | .first = 0xC0, |
| 1091 | .last = 0xC6, |
| 1092 | }, |
| 1093 | { |
| 1094 | .first = 0xF5, |
| 1095 | .last = 0xF5, |
| 1096 | }, |
| 1097 | }, |
| 1098 | }, |
| 1099 | [AB8500_GAS_GAUGE] = { |
| 1100 | .num_ranges = 3, |
| 1101 | .range = (struct ab8500_reg_range[]) { |
| 1102 | { |
| 1103 | .first = 0x00, |
| 1104 | .last = 0x00, |
| 1105 | }, |
| 1106 | { |
| 1107 | .first = 0x07, |
| 1108 | .last = 0x0A, |
| 1109 | }, |
| 1110 | { |
| 1111 | .first = 0x10, |
| 1112 | .last = 0x14, |
| 1113 | }, |
| 1114 | }, |
| 1115 | }, |
| 1116 | [AB8500_AUDIO] = { |
| 1117 | .num_ranges = 1, |
| 1118 | .range = (struct ab8500_reg_range[]) { |
| 1119 | { |
| 1120 | .first = 0x00, |
| 1121 | .last = 0x9f, |
| 1122 | }, |
| 1123 | }, |
| 1124 | }, |
| 1125 | [AB8500_INTERRUPT] = { |
| 1126 | .num_ranges = 6, |
| 1127 | .range = (struct ab8500_reg_range[]) { |
| 1128 | { |
| 1129 | .first = 0x00, |
| 1130 | .last = 0x05, |
| 1131 | }, |
| 1132 | { |
| 1133 | .first = 0x0B, |
| 1134 | .last = 0x0D, |
| 1135 | }, |
| 1136 | { |
| 1137 | .first = 0x12, |
| 1138 | .last = 0x20, |
| 1139 | }, |
| 1140 | /* Latch registers should not be read here */ |
| 1141 | { |
| 1142 | .first = 0x40, |
| 1143 | .last = 0x45, |
| 1144 | }, |
| 1145 | { |
| 1146 | .first = 0x4B, |
| 1147 | .last = 0x4D, |
| 1148 | }, |
| 1149 | { |
| 1150 | .first = 0x52, |
| 1151 | .last = 0x60, |
| 1152 | }, |
| 1153 | /* LatchHier registers should not be read here */ |
| 1154 | }, |
| 1155 | }, |
| 1156 | [AB8500_RTC] = { |
| 1157 | .num_ranges = 3, |
| 1158 | .range = (struct ab8500_reg_range[]) { |
| 1159 | { |
| 1160 | .first = 0x00, |
| 1161 | .last = 0x07, |
| 1162 | }, |
| 1163 | { |
| 1164 | .first = 0x0B, |
| 1165 | .last = 0x18, |
| 1166 | }, |
| 1167 | { |
| 1168 | .first = 0x20, |
| 1169 | .last = 0x25, |
| 1170 | }, |
| 1171 | }, |
| 1172 | }, |
| 1173 | [AB8500_MISC] = { |
| 1174 | .num_ranges = 9, |
| 1175 | .range = (struct ab8500_reg_range[]) { |
| 1176 | { |
| 1177 | .first = 0x00, |
| 1178 | .last = 0x06, |
| 1179 | }, |
| 1180 | { |
| 1181 | .first = 0x10, |
| 1182 | .last = 0x16, |
| 1183 | }, |
| 1184 | { |
| 1185 | .first = 0x20, |
| 1186 | .last = 0x26, |
| 1187 | }, |
| 1188 | { |
| 1189 | .first = 0x30, |
| 1190 | .last = 0x36, |
| 1191 | }, |
| 1192 | { |
| 1193 | .first = 0x40, |
| 1194 | .last = 0x49, |
| 1195 | }, |
| 1196 | { |
| 1197 | .first = 0x50, |
| 1198 | .last = 0x50, |
| 1199 | }, |
| 1200 | { |
| 1201 | .first = 0x60, |
| 1202 | .last = 0x6B, |
| 1203 | }, |
| 1204 | { |
| 1205 | .first = 0x70, |
| 1206 | .last = 0x74, |
| 1207 | }, |
| 1208 | { |
| 1209 | .first = 0x80, |
| 1210 | .last = 0x82, |
| 1211 | }, |
| 1212 | }, |
| 1213 | }, |
| 1214 | [AB8500_DEVELOPMENT] = { |
| 1215 | .num_ranges = 3, |
| 1216 | .range = (struct ab8500_reg_range[]) { |
| 1217 | { |
| 1218 | .first = 0x00, |
| 1219 | .last = 0x01, |
| 1220 | }, |
| 1221 | { |
| 1222 | .first = 0x06, |
| 1223 | .last = 0x06, |
| 1224 | }, |
| 1225 | { |
| 1226 | .first = 0x10, |
| 1227 | .last = 0x21, |
| 1228 | }, |
| 1229 | }, |
| 1230 | }, |
| 1231 | [AB8500_DEBUG] = { |
| 1232 | .num_ranges = 3, |
| 1233 | .range = (struct ab8500_reg_range[]) { |
| 1234 | { |
| 1235 | .first = 0x01, |
| 1236 | .last = 0x0C, |
| 1237 | }, |
| 1238 | { |
| 1239 | .first = 0x0E, |
| 1240 | .last = 0x11, |
| 1241 | }, |
| 1242 | { |
| 1243 | .first = 0x80, |
| 1244 | .last = 0x81, |
| 1245 | }, |
| 1246 | }, |
| 1247 | }, |
| 1248 | [AB8500_PROD_TEST] = { |
| 1249 | .num_ranges = 0, |
| 1250 | .range = NULL, |
| 1251 | }, |
| 1252 | [AB8500_STE_TEST] = { |
| 1253 | .num_ranges = 0, |
| 1254 | .range = NULL, |
| 1255 | }, |
| 1256 | [AB8500_OTP_EMUL] = { |
| 1257 | .num_ranges = 1, |
| 1258 | .range = (struct ab8500_reg_range[]) { |
| 1259 | { |
| 1260 | .first = 0x00, |
| 1261 | .last = 0x3F, |
| 1262 | }, |
| 1263 | }, |
| 1264 | }, |
| 1265 | }; |
| 1266 | |
| 1267 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 1268 | static irqreturn_t ab8500_debug_handler(int irq, void *data) |
| 1269 | { |
| 1270 | char buf[16]; |
| 1271 | struct kobject *kobj = (struct kobject *)data; |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 1272 | unsigned int irq_abb = irq - irq_first; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 1273 | |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 1274 | if (irq_abb < num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 1275 | irq_count[irq_abb]++; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 1276 | /* |
| 1277 | * This makes it possible to use poll for events (POLLPRI | POLLERR) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 1278 | * from userspace on sysfs file named <irq-nr> |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 1279 | */ |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 1280 | sprintf(buf, "%d", irq); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 1281 | sysfs_notify(kobj, NULL, buf); |
| 1282 | |
| 1283 | return IRQ_HANDLED; |
| 1284 | } |
| 1285 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1286 | /* Prints to seq_file or log_buf */ |
| 1287 | static int ab8500_registers_print(struct device *dev, u32 bank, |
| 1288 | struct seq_file *s) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1289 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1290 | unsigned int i; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1291 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1292 | for (i = 0; i < debug_ranges[bank].num_ranges; i++) { |
| 1293 | u32 reg; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1294 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1295 | for (reg = debug_ranges[bank].range[i].first; |
| 1296 | reg <= debug_ranges[bank].range[i].last; |
| 1297 | reg++) { |
| 1298 | u8 value; |
| 1299 | int err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1300 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1301 | err = abx500_get_register_interruptible(dev, |
| 1302 | (u8)bank, (u8)reg, &value); |
| 1303 | if (err < 0) { |
| 1304 | dev_err(dev, "ab->read fail %d\n", err); |
| 1305 | return err; |
| 1306 | } |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1307 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1308 | if (s) { |
Mattias Wallin | cfc0849 | 2012-05-28 15:53:58 +0200 | [diff] [blame] | 1309 | err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n", |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1310 | bank, reg, value); |
| 1311 | if (err < 0) { |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1312 | /* Error is not returned here since |
| 1313 | * the output is wanted in any case */ |
| 1314 | return 0; |
| 1315 | } |
| 1316 | } else { |
Mattias Wallin | cfc0849 | 2012-05-28 15:53:58 +0200 | [diff] [blame] | 1317 | printk(KERN_INFO" [0x%02X/0x%02X]: 0x%02X\n", |
| 1318 | bank, reg, value); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1319 | } |
| 1320 | } |
| 1321 | } |
| 1322 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1323 | } |
| 1324 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1325 | static int ab8500_print_bank_registers(struct seq_file *s, void *p) |
| 1326 | { |
| 1327 | struct device *dev = s->private; |
| 1328 | u32 bank = debug_bank; |
| 1329 | |
| 1330 | seq_printf(s, AB8500_NAME_STRING " register values:\n"); |
| 1331 | |
Mattias Wallin | cfc0849 | 2012-05-28 15:53:58 +0200 | [diff] [blame] | 1332 | seq_printf(s, " bank 0x%02X:\n", bank); |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1333 | |
| 1334 | ab8500_registers_print(dev, bank, s); |
| 1335 | return 0; |
| 1336 | } |
| 1337 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1338 | static int ab8500_registers_open(struct inode *inode, struct file *file) |
| 1339 | { |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1340 | return single_open(file, ab8500_print_bank_registers, inode->i_private); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1341 | } |
| 1342 | |
| 1343 | static const struct file_operations ab8500_registers_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1344 | .open = ab8500_registers_open, |
| 1345 | .read = seq_read, |
| 1346 | .llseek = seq_lseek, |
| 1347 | .release = single_release, |
| 1348 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1349 | }; |
| 1350 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1351 | static int ab8500_print_all_banks(struct seq_file *s, void *p) |
| 1352 | { |
| 1353 | struct device *dev = s->private; |
| 1354 | unsigned int i; |
| 1355 | int err; |
| 1356 | |
| 1357 | seq_printf(s, AB8500_NAME_STRING " register values:\n"); |
| 1358 | |
Lee Jones | 971480f | 2012-11-19 12:20:03 +0100 | [diff] [blame] | 1359 | for (i = 0; i < AB8500_NUM_BANKS; i++) { |
Mattias Wallin | cfc0849 | 2012-05-28 15:53:58 +0200 | [diff] [blame] | 1360 | err = seq_printf(s, " bank 0x%02X:\n", i); |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1361 | |
| 1362 | ab8500_registers_print(dev, i, s); |
| 1363 | } |
| 1364 | return 0; |
| 1365 | } |
| 1366 | |
Mian Yousaf Kaukab | 1d843a6 | 2012-01-27 11:35:41 +0100 | [diff] [blame] | 1367 | /* Dump registers to kernel log */ |
| 1368 | void ab8500_dump_all_banks(struct device *dev) |
| 1369 | { |
| 1370 | unsigned int i; |
| 1371 | |
| 1372 | printk(KERN_INFO"ab8500 register values:\n"); |
| 1373 | |
| 1374 | for (i = 1; i < AB8500_NUM_BANKS; i++) { |
Mattias Wallin | cfc0849 | 2012-05-28 15:53:58 +0200 | [diff] [blame] | 1375 | printk(KERN_INFO" bank 0x%02X:\n", i); |
Mian Yousaf Kaukab | 1d843a6 | 2012-01-27 11:35:41 +0100 | [diff] [blame] | 1376 | ab8500_registers_print(dev, i, NULL); |
| 1377 | } |
| 1378 | } |
| 1379 | |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1380 | /* Space for 500 registers. */ |
| 1381 | #define DUMP_MAX_REGS 700 |
| 1382 | struct ab8500_register_dump |
| 1383 | { |
| 1384 | u8 bank; |
| 1385 | u8 reg; |
| 1386 | u8 value; |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1387 | } ab8500_complete_register_dump[DUMP_MAX_REGS]; |
| 1388 | |
| 1389 | extern int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size); |
| 1390 | |
| 1391 | /* This shall only be called upon kernel panic! */ |
| 1392 | void ab8500_dump_all_banks_to_mem(void) |
| 1393 | { |
| 1394 | int i, r = 0; |
| 1395 | u8 bank; |
Jonas Aaberg | 222460c | 2012-06-18 10:35:28 +0200 | [diff] [blame] | 1396 | int err = 0; |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1397 | |
| 1398 | pr_info("Saving all ABB registers at \"ab8500_complete_register_dump\" " |
| 1399 | "for crash analyze.\n"); |
| 1400 | |
Lee Jones | 971480f | 2012-11-19 12:20:03 +0100 | [diff] [blame] | 1401 | for (bank = 0; bank < AB8500_NUM_BANKS; bank++) { |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1402 | for (i = 0; i < debug_ranges[bank].num_ranges; i++) { |
| 1403 | u8 reg; |
| 1404 | |
| 1405 | for (reg = debug_ranges[bank].range[i].first; |
| 1406 | reg <= debug_ranges[bank].range[i].last; |
| 1407 | reg++) { |
| 1408 | u8 value; |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1409 | |
| 1410 | err = prcmu_abb_read(bank, reg, &value, 1); |
| 1411 | |
Jonas Aaberg | 222460c | 2012-06-18 10:35:28 +0200 | [diff] [blame] | 1412 | if (err < 0) |
| 1413 | goto out; |
| 1414 | |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1415 | ab8500_complete_register_dump[r].bank = bank; |
| 1416 | ab8500_complete_register_dump[r].reg = reg; |
| 1417 | ab8500_complete_register_dump[r].value = value; |
| 1418 | |
| 1419 | r++; |
| 1420 | |
| 1421 | if (r >= DUMP_MAX_REGS) { |
| 1422 | pr_err("%s: too many register to dump!\n", |
| 1423 | __func__); |
Jonas Aaberg | 222460c | 2012-06-18 10:35:28 +0200 | [diff] [blame] | 1424 | err = -EINVAL; |
| 1425 | goto out; |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1426 | } |
| 1427 | } |
| 1428 | } |
| 1429 | } |
Jonas Aaberg | 222460c | 2012-06-18 10:35:28 +0200 | [diff] [blame] | 1430 | out: |
| 1431 | if (err >= 0) |
| 1432 | pr_info("Saved all ABB registers.\n"); |
| 1433 | else |
| 1434 | pr_info("Failed to save all ABB registers.\n"); |
Lee Jones | 5ff9090 | 2013-02-12 14:35:28 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 1437 | static int ab8500_all_banks_open(struct inode *inode, struct file *file) |
| 1438 | { |
| 1439 | struct seq_file *s; |
| 1440 | int err; |
| 1441 | |
| 1442 | err = single_open(file, ab8500_print_all_banks, inode->i_private); |
| 1443 | if (!err) { |
| 1444 | /* Default buf size in seq_read is not enough */ |
| 1445 | s = (struct seq_file *)file->private_data; |
| 1446 | s->size = (PAGE_SIZE * 2); |
| 1447 | s->buf = kmalloc(s->size, GFP_KERNEL); |
| 1448 | if (!s->buf) { |
| 1449 | single_release(inode, file); |
| 1450 | err = -ENOMEM; |
| 1451 | } |
| 1452 | } |
| 1453 | return err; |
| 1454 | } |
| 1455 | |
| 1456 | static const struct file_operations ab8500_all_banks_fops = { |
| 1457 | .open = ab8500_all_banks_open, |
| 1458 | .read = seq_read, |
| 1459 | .llseek = seq_lseek, |
| 1460 | .release = single_release, |
| 1461 | .owner = THIS_MODULE, |
| 1462 | }; |
| 1463 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1464 | static int ab8500_bank_print(struct seq_file *s, void *p) |
| 1465 | { |
Mattias Wallin | cfc0849 | 2012-05-28 15:53:58 +0200 | [diff] [blame] | 1466 | return seq_printf(s, "0x%02X\n", debug_bank); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1467 | } |
| 1468 | |
| 1469 | static int ab8500_bank_open(struct inode *inode, struct file *file) |
| 1470 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1471 | return single_open(file, ab8500_bank_print, inode->i_private); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1472 | } |
| 1473 | |
| 1474 | static ssize_t ab8500_bank_write(struct file *file, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1475 | const char __user *user_buf, |
| 1476 | size_t count, loff_t *ppos) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1477 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1478 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1479 | unsigned long user_bank; |
| 1480 | int err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1481 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1482 | err = kstrtoul_from_user(user_buf, count, 0, &user_bank); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1483 | if (err) |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1484 | return err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1485 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1486 | if (user_bank >= AB8500_NUM_BANKS) { |
| 1487 | dev_err(dev, "debugfs error input > number of banks\n"); |
| 1488 | return -EINVAL; |
| 1489 | } |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1490 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1491 | debug_bank = user_bank; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1492 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1493 | return count; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | static int ab8500_address_print(struct seq_file *s, void *p) |
| 1497 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1498 | return seq_printf(s, "0x%02X\n", debug_address); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1499 | } |
| 1500 | |
| 1501 | static int ab8500_address_open(struct inode *inode, struct file *file) |
| 1502 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1503 | return single_open(file, ab8500_address_print, inode->i_private); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1504 | } |
| 1505 | |
| 1506 | static ssize_t ab8500_address_write(struct file *file, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1507 | const char __user *user_buf, |
| 1508 | size_t count, loff_t *ppos) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1509 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1510 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1511 | unsigned long user_address; |
| 1512 | int err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1513 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1514 | err = kstrtoul_from_user(user_buf, count, 0, &user_address); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1515 | if (err) |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1516 | return err; |
| 1517 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1518 | if (user_address > 0xff) { |
| 1519 | dev_err(dev, "debugfs error input > 0xff\n"); |
| 1520 | return -EINVAL; |
| 1521 | } |
| 1522 | debug_address = user_address; |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 1523 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1524 | return count; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1525 | } |
| 1526 | |
| 1527 | static int ab8500_val_print(struct seq_file *s, void *p) |
| 1528 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1529 | struct device *dev = s->private; |
| 1530 | int ret; |
| 1531 | u8 regvalue; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1532 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1533 | ret = abx500_get_register_interruptible(dev, |
| 1534 | (u8)debug_bank, (u8)debug_address, ®value); |
| 1535 | if (ret < 0) { |
| 1536 | dev_err(dev, "abx500_get_reg fail %d, %d\n", |
| 1537 | ret, __LINE__); |
| 1538 | return -EINVAL; |
| 1539 | } |
| 1540 | seq_printf(s, "0x%02X\n", regvalue); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1541 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1542 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1543 | } |
| 1544 | |
| 1545 | static int ab8500_val_open(struct inode *inode, struct file *file) |
| 1546 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1547 | return single_open(file, ab8500_val_print, inode->i_private); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1548 | } |
| 1549 | |
| 1550 | static ssize_t ab8500_val_write(struct file *file, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1551 | const char __user *user_buf, |
| 1552 | size_t count, loff_t *ppos) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1553 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1554 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1555 | unsigned long user_val; |
| 1556 | int err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1557 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1558 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1559 | if (err) |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1560 | return err; |
| 1561 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1562 | if (user_val > 0xff) { |
| 1563 | dev_err(dev, "debugfs error input > 0xff\n"); |
| 1564 | return -EINVAL; |
| 1565 | } |
| 1566 | err = abx500_set_register_interruptible(dev, |
| 1567 | (u8)debug_bank, debug_address, (u8)user_val); |
| 1568 | if (err < 0) { |
| 1569 | printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__); |
| 1570 | return -EINVAL; |
| 1571 | } |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1572 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1573 | return count; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1574 | } |
| 1575 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 1576 | /* |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1577 | * Interrupt status |
| 1578 | */ |
| 1579 | static u32 num_interrupts[AB8500_MAX_NR_IRQS]; |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1580 | static u32 num_wake_interrupts[AB8500_MAX_NR_IRQS]; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1581 | static int num_interrupt_lines; |
| 1582 | |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1583 | bool __attribute__((weak)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int) |
| 1584 | { |
| 1585 | return false; |
| 1586 | } |
| 1587 | |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1588 | void ab8500_debug_register_interrupt(int line) |
| 1589 | { |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1590 | if (line < num_interrupt_lines) { |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1591 | num_interrupts[line]++; |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1592 | if (suspend_test_wake_cause_interrupt_is_mine(IRQ_DB8500_AB8500)) |
| 1593 | num_wake_interrupts[line]++; |
| 1594 | } |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1595 | } |
| 1596 | |
| 1597 | static int ab8500_interrupts_print(struct seq_file *s, void *p) |
| 1598 | { |
| 1599 | int line; |
| 1600 | |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1601 | seq_printf(s, "name: number: number of: wake:\n"); |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1602 | |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1603 | for (line = 0; line < num_interrupt_lines; line++) { |
| 1604 | struct irq_desc *desc = irq_to_desc(line + irq_first); |
| 1605 | struct irqaction *action = desc->action; |
| 1606 | |
| 1607 | seq_printf(s, "%3i: %6i %4i", line, |
| 1608 | num_interrupts[line], |
| 1609 | num_wake_interrupts[line]); |
| 1610 | |
| 1611 | if (desc && desc->name) |
| 1612 | seq_printf(s, "-%-8s", desc->name); |
| 1613 | if (action) { |
| 1614 | seq_printf(s, " %s", action->name); |
| 1615 | while ((action = action->next) != NULL) |
| 1616 | seq_printf(s, ", %s", action->name); |
| 1617 | } |
| 1618 | seq_putc(s, '\n'); |
| 1619 | } |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1620 | |
| 1621 | return 0; |
| 1622 | } |
| 1623 | |
| 1624 | static int ab8500_interrupts_open(struct inode *inode, struct file *file) |
| 1625 | { |
| 1626 | return single_open(file, ab8500_interrupts_print, inode->i_private); |
| 1627 | } |
| 1628 | |
| 1629 | /* |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 1630 | * - HWREG DB8500 formated routines |
| 1631 | */ |
| 1632 | static int ab8500_hwreg_print(struct seq_file *s, void *d) |
| 1633 | { |
| 1634 | struct device *dev = s->private; |
| 1635 | int ret; |
| 1636 | u8 regvalue; |
| 1637 | |
| 1638 | ret = abx500_get_register_interruptible(dev, |
| 1639 | (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, ®value); |
| 1640 | if (ret < 0) { |
| 1641 | dev_err(dev, "abx500_get_reg fail %d, %d\n", |
| 1642 | ret, __LINE__); |
| 1643 | return -EINVAL; |
| 1644 | } |
| 1645 | |
| 1646 | if (hwreg_cfg.shift >= 0) |
| 1647 | regvalue >>= hwreg_cfg.shift; |
| 1648 | else |
| 1649 | regvalue <<= -hwreg_cfg.shift; |
| 1650 | regvalue &= hwreg_cfg.mask; |
| 1651 | |
| 1652 | if (REG_FMT_DEC(&hwreg_cfg)) |
| 1653 | seq_printf(s, "%d\n", regvalue); |
| 1654 | else |
| 1655 | seq_printf(s, "0x%02X\n", regvalue); |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
| 1659 | static int ab8500_hwreg_open(struct inode *inode, struct file *file) |
| 1660 | { |
| 1661 | return single_open(file, ab8500_hwreg_print, inode->i_private); |
| 1662 | } |
| 1663 | |
Lee Jones | c7ebaee | 2013-02-26 14:03:33 +0000 | [diff] [blame] | 1664 | #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01 |
| 1665 | #define AB8500_SUPPLY_CONTROL_REG 0x00 |
| 1666 | #define AB8500_FIRST_SIM_REG 0x80 |
| 1667 | #define AB8500_LAST_SIM_REG 0x8B |
| 1668 | #define AB8505_LAST_SIM_REG 0x8C |
| 1669 | |
| 1670 | static int ab8500_print_modem_registers(struct seq_file *s, void *p) |
| 1671 | { |
| 1672 | struct device *dev = s->private; |
| 1673 | struct ab8500 *ab8500; |
| 1674 | int err; |
| 1675 | u8 value; |
| 1676 | u8 orig_value; |
| 1677 | u32 bank = AB8500_REGU_CTRL2; |
| 1678 | u32 last_sim_reg = AB8500_LAST_SIM_REG; |
| 1679 | u32 reg; |
| 1680 | |
| 1681 | ab8500 = dev_get_drvdata(dev->parent); |
| 1682 | dev_warn(dev, "WARNING! This operation can interfer with modem side\n" |
| 1683 | "and should only be done with care\n"); |
| 1684 | |
| 1685 | err = abx500_get_register_interruptible(dev, |
| 1686 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value); |
| 1687 | if (err < 0) { |
| 1688 | dev_err(dev, "ab->read fail %d\n", err); |
| 1689 | return err; |
| 1690 | } |
| 1691 | /* Config 1 will allow APE side to read SIM registers */ |
| 1692 | err = abx500_set_register_interruptible(dev, |
| 1693 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, |
| 1694 | AB8500_SUPPLY_CONTROL_CONFIG_1); |
| 1695 | if (err < 0) { |
| 1696 | dev_err(dev, "ab->write fail %d\n", err); |
| 1697 | return err; |
| 1698 | } |
| 1699 | |
| 1700 | seq_printf(s, " bank 0x%02X:\n", bank); |
| 1701 | |
| 1702 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) |
| 1703 | last_sim_reg = AB8505_LAST_SIM_REG; |
| 1704 | |
| 1705 | for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) { |
| 1706 | err = abx500_get_register_interruptible(dev, |
| 1707 | bank, reg, &value); |
| 1708 | if (err < 0) { |
| 1709 | dev_err(dev, "ab->read fail %d\n", err); |
| 1710 | return err; |
| 1711 | } |
| 1712 | err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n", |
| 1713 | bank, reg, value); |
| 1714 | } |
| 1715 | err = abx500_set_register_interruptible(dev, |
| 1716 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value); |
| 1717 | if (err < 0) { |
| 1718 | dev_err(dev, "ab->write fail %d\n", err); |
| 1719 | return err; |
| 1720 | } |
| 1721 | return 0; |
| 1722 | } |
| 1723 | |
| 1724 | static int ab8500_modem_open(struct inode *inode, struct file *file) |
| 1725 | { |
| 1726 | return single_open(file, ab8500_print_modem_registers, inode->i_private); |
| 1727 | } |
| 1728 | |
| 1729 | static const struct file_operations ab8500_modem_fops = { |
| 1730 | .open = ab8500_modem_open, |
| 1731 | .read = seq_read, |
| 1732 | .llseek = seq_lseek, |
| 1733 | .release = single_release, |
| 1734 | .owner = THIS_MODULE, |
| 1735 | }; |
| 1736 | |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1737 | static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p) |
| 1738 | { |
| 1739 | int bat_ctrl_raw; |
| 1740 | int bat_ctrl_convert; |
| 1741 | struct ab8500_gpadc *gpadc; |
| 1742 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1743 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1744 | bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL, |
| 1745 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1746 | bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1747 | BAT_CTRL, bat_ctrl_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1748 | |
| 1749 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1750 | bat_ctrl_convert, bat_ctrl_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file) |
| 1754 | { |
| 1755 | return single_open(file, ab8500_gpadc_bat_ctrl_print, inode->i_private); |
| 1756 | } |
| 1757 | |
| 1758 | static const struct file_operations ab8500_gpadc_bat_ctrl_fops = { |
| 1759 | .open = ab8500_gpadc_bat_ctrl_open, |
| 1760 | .read = seq_read, |
| 1761 | .llseek = seq_lseek, |
| 1762 | .release = single_release, |
| 1763 | .owner = THIS_MODULE, |
| 1764 | }; |
| 1765 | |
| 1766 | static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p) |
| 1767 | { |
| 1768 | int btemp_ball_raw; |
| 1769 | int btemp_ball_convert; |
| 1770 | struct ab8500_gpadc *gpadc; |
| 1771 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1772 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1773 | btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL, |
| 1774 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1775 | btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1776 | btemp_ball_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1777 | |
| 1778 | return seq_printf(s, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1779 | "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1780 | } |
| 1781 | |
| 1782 | static int ab8500_gpadc_btemp_ball_open(struct inode *inode, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1783 | struct file *file) |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1784 | { |
| 1785 | return single_open(file, ab8500_gpadc_btemp_ball_print, inode->i_private); |
| 1786 | } |
| 1787 | |
| 1788 | static const struct file_operations ab8500_gpadc_btemp_ball_fops = { |
| 1789 | .open = ab8500_gpadc_btemp_ball_open, |
| 1790 | .read = seq_read, |
| 1791 | .llseek = seq_lseek, |
| 1792 | .release = single_release, |
| 1793 | .owner = THIS_MODULE, |
| 1794 | }; |
| 1795 | |
| 1796 | static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p) |
| 1797 | { |
| 1798 | int main_charger_v_raw; |
| 1799 | int main_charger_v_convert; |
| 1800 | struct ab8500_gpadc *gpadc; |
| 1801 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1802 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1803 | main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V, |
| 1804 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1805 | main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1806 | MAIN_CHARGER_V, main_charger_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1807 | |
| 1808 | return seq_printf(s, "%d,0x%X\n", |
| 1809 | main_charger_v_convert, main_charger_v_raw); |
| 1810 | } |
| 1811 | |
| 1812 | static int ab8500_gpadc_main_charger_v_open(struct inode *inode, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1813 | struct file *file) |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1814 | { |
| 1815 | return single_open(file, ab8500_gpadc_main_charger_v_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1816 | inode->i_private); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1817 | } |
| 1818 | |
| 1819 | static const struct file_operations ab8500_gpadc_main_charger_v_fops = { |
| 1820 | .open = ab8500_gpadc_main_charger_v_open, |
| 1821 | .read = seq_read, |
| 1822 | .llseek = seq_lseek, |
| 1823 | .release = single_release, |
| 1824 | .owner = THIS_MODULE, |
| 1825 | }; |
| 1826 | |
| 1827 | static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p) |
| 1828 | { |
| 1829 | int acc_detect1_raw; |
| 1830 | int acc_detect1_convert; |
| 1831 | struct ab8500_gpadc *gpadc; |
| 1832 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1833 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1834 | acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1, |
| 1835 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1836 | acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1837 | acc_detect1_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1838 | |
| 1839 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1840 | acc_detect1_convert, acc_detect1_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | static int ab8500_gpadc_acc_detect1_open(struct inode *inode, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1844 | struct file *file) |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1845 | { |
| 1846 | return single_open(file, ab8500_gpadc_acc_detect1_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1847 | inode->i_private); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1848 | } |
| 1849 | |
| 1850 | static const struct file_operations ab8500_gpadc_acc_detect1_fops = { |
| 1851 | .open = ab8500_gpadc_acc_detect1_open, |
| 1852 | .read = seq_read, |
| 1853 | .llseek = seq_lseek, |
| 1854 | .release = single_release, |
| 1855 | .owner = THIS_MODULE, |
| 1856 | }; |
| 1857 | |
| 1858 | static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p) |
| 1859 | { |
| 1860 | int acc_detect2_raw; |
| 1861 | int acc_detect2_convert; |
| 1862 | struct ab8500_gpadc *gpadc; |
| 1863 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1864 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1865 | acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2, |
| 1866 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1867 | acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1868 | ACC_DETECT2, acc_detect2_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1869 | |
| 1870 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1871 | acc_detect2_convert, acc_detect2_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1872 | } |
| 1873 | |
| 1874 | static int ab8500_gpadc_acc_detect2_open(struct inode *inode, |
| 1875 | struct file *file) |
| 1876 | { |
| 1877 | return single_open(file, ab8500_gpadc_acc_detect2_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1878 | inode->i_private); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1879 | } |
| 1880 | |
| 1881 | static const struct file_operations ab8500_gpadc_acc_detect2_fops = { |
| 1882 | .open = ab8500_gpadc_acc_detect2_open, |
| 1883 | .read = seq_read, |
| 1884 | .llseek = seq_lseek, |
| 1885 | .release = single_release, |
| 1886 | .owner = THIS_MODULE, |
| 1887 | }; |
| 1888 | |
| 1889 | static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p) |
| 1890 | { |
| 1891 | int aux1_raw; |
| 1892 | int aux1_convert; |
| 1893 | struct ab8500_gpadc *gpadc; |
| 1894 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1895 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1896 | aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1, |
| 1897 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1898 | aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1899 | aux1_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1900 | |
| 1901 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1902 | aux1_convert, aux1_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1903 | } |
| 1904 | |
| 1905 | static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file) |
| 1906 | { |
| 1907 | return single_open(file, ab8500_gpadc_aux1_print, inode->i_private); |
| 1908 | } |
| 1909 | |
| 1910 | static const struct file_operations ab8500_gpadc_aux1_fops = { |
| 1911 | .open = ab8500_gpadc_aux1_open, |
| 1912 | .read = seq_read, |
| 1913 | .llseek = seq_lseek, |
| 1914 | .release = single_release, |
| 1915 | .owner = THIS_MODULE, |
| 1916 | }; |
| 1917 | |
| 1918 | static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p) |
| 1919 | { |
| 1920 | int aux2_raw; |
| 1921 | int aux2_convert; |
| 1922 | struct ab8500_gpadc *gpadc; |
| 1923 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1924 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1925 | aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2, |
| 1926 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1927 | aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1928 | aux2_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1929 | |
| 1930 | return seq_printf(s, "%d,0x%X\n", |
| 1931 | aux2_convert, aux2_raw); |
| 1932 | } |
| 1933 | |
| 1934 | static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file) |
| 1935 | { |
| 1936 | return single_open(file, ab8500_gpadc_aux2_print, inode->i_private); |
| 1937 | } |
| 1938 | |
| 1939 | static const struct file_operations ab8500_gpadc_aux2_fops = { |
| 1940 | .open = ab8500_gpadc_aux2_open, |
| 1941 | .read = seq_read, |
| 1942 | .llseek = seq_lseek, |
| 1943 | .release = single_release, |
| 1944 | .owner = THIS_MODULE, |
| 1945 | }; |
| 1946 | |
| 1947 | static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p) |
| 1948 | { |
| 1949 | int main_bat_v_raw; |
| 1950 | int main_bat_v_convert; |
| 1951 | struct ab8500_gpadc *gpadc; |
| 1952 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1953 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1954 | main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V, |
| 1955 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1956 | main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1957 | main_bat_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1958 | |
| 1959 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1960 | main_bat_v_convert, main_bat_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1961 | } |
| 1962 | |
| 1963 | static int ab8500_gpadc_main_bat_v_open(struct inode *inode, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1964 | struct file *file) |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1965 | { |
| 1966 | return single_open(file, ab8500_gpadc_main_bat_v_print, inode->i_private); |
| 1967 | } |
| 1968 | |
| 1969 | static const struct file_operations ab8500_gpadc_main_bat_v_fops = { |
| 1970 | .open = ab8500_gpadc_main_bat_v_open, |
| 1971 | .read = seq_read, |
| 1972 | .llseek = seq_lseek, |
| 1973 | .release = single_release, |
| 1974 | .owner = THIS_MODULE, |
| 1975 | }; |
| 1976 | |
| 1977 | static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p) |
| 1978 | { |
| 1979 | int vbus_v_raw; |
| 1980 | int vbus_v_convert; |
| 1981 | struct ab8500_gpadc *gpadc; |
| 1982 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1983 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1984 | vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V, |
| 1985 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1986 | vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1987 | vbus_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1988 | |
| 1989 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 1990 | vbus_v_convert, vbus_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1991 | } |
| 1992 | |
| 1993 | static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file) |
| 1994 | { |
| 1995 | return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private); |
| 1996 | } |
| 1997 | |
| 1998 | static const struct file_operations ab8500_gpadc_vbus_v_fops = { |
| 1999 | .open = ab8500_gpadc_vbus_v_open, |
| 2000 | .read = seq_read, |
| 2001 | .llseek = seq_lseek, |
| 2002 | .release = single_release, |
| 2003 | .owner = THIS_MODULE, |
| 2004 | }; |
| 2005 | |
| 2006 | static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p) |
| 2007 | { |
| 2008 | int main_charger_c_raw; |
| 2009 | int main_charger_c_convert; |
| 2010 | struct ab8500_gpadc *gpadc; |
| 2011 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2012 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2013 | main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C, |
| 2014 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2015 | main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2016 | MAIN_CHARGER_C, main_charger_c_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2017 | |
| 2018 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2019 | main_charger_c_convert, main_charger_c_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2020 | } |
| 2021 | |
| 2022 | static int ab8500_gpadc_main_charger_c_open(struct inode *inode, |
| 2023 | struct file *file) |
| 2024 | { |
| 2025 | return single_open(file, ab8500_gpadc_main_charger_c_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2026 | inode->i_private); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2027 | } |
| 2028 | |
| 2029 | static const struct file_operations ab8500_gpadc_main_charger_c_fops = { |
| 2030 | .open = ab8500_gpadc_main_charger_c_open, |
| 2031 | .read = seq_read, |
| 2032 | .llseek = seq_lseek, |
| 2033 | .release = single_release, |
| 2034 | .owner = THIS_MODULE, |
| 2035 | }; |
| 2036 | |
| 2037 | static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p) |
| 2038 | { |
| 2039 | int usb_charger_c_raw; |
| 2040 | int usb_charger_c_convert; |
| 2041 | struct ab8500_gpadc *gpadc; |
| 2042 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2043 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2044 | usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C, |
| 2045 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2046 | usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2047 | USB_CHARGER_C, usb_charger_c_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2048 | |
| 2049 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2050 | usb_charger_c_convert, usb_charger_c_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2051 | } |
| 2052 | |
| 2053 | static int ab8500_gpadc_usb_charger_c_open(struct inode *inode, |
| 2054 | struct file *file) |
| 2055 | { |
| 2056 | return single_open(file, ab8500_gpadc_usb_charger_c_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2057 | inode->i_private); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2058 | } |
| 2059 | |
| 2060 | static const struct file_operations ab8500_gpadc_usb_charger_c_fops = { |
| 2061 | .open = ab8500_gpadc_usb_charger_c_open, |
| 2062 | .read = seq_read, |
| 2063 | .llseek = seq_lseek, |
| 2064 | .release = single_release, |
| 2065 | .owner = THIS_MODULE, |
| 2066 | }; |
| 2067 | |
| 2068 | static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p) |
| 2069 | { |
| 2070 | int bk_bat_v_raw; |
| 2071 | int bk_bat_v_convert; |
| 2072 | struct ab8500_gpadc *gpadc; |
| 2073 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2074 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2075 | bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V, |
| 2076 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2077 | bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2078 | BK_BAT_V, bk_bat_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2079 | |
| 2080 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2081 | bk_bat_v_convert, bk_bat_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2082 | } |
| 2083 | |
| 2084 | static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file) |
| 2085 | { |
| 2086 | return single_open(file, ab8500_gpadc_bk_bat_v_print, inode->i_private); |
| 2087 | } |
| 2088 | |
| 2089 | static const struct file_operations ab8500_gpadc_bk_bat_v_fops = { |
| 2090 | .open = ab8500_gpadc_bk_bat_v_open, |
| 2091 | .read = seq_read, |
| 2092 | .llseek = seq_lseek, |
| 2093 | .release = single_release, |
| 2094 | .owner = THIS_MODULE, |
| 2095 | }; |
| 2096 | |
| 2097 | static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p) |
| 2098 | { |
| 2099 | int die_temp_raw; |
| 2100 | int die_temp_convert; |
| 2101 | struct ab8500_gpadc *gpadc; |
| 2102 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2103 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2104 | die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP, |
| 2105 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2106 | die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2107 | die_temp_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2108 | |
| 2109 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2110 | die_temp_convert, die_temp_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2111 | } |
| 2112 | |
| 2113 | static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file) |
| 2114 | { |
| 2115 | return single_open(file, ab8500_gpadc_die_temp_print, inode->i_private); |
| 2116 | } |
| 2117 | |
| 2118 | static const struct file_operations ab8500_gpadc_die_temp_fops = { |
| 2119 | .open = ab8500_gpadc_die_temp_open, |
| 2120 | .read = seq_read, |
| 2121 | .llseek = seq_lseek, |
| 2122 | .release = single_release, |
| 2123 | .owner = THIS_MODULE, |
| 2124 | }; |
| 2125 | |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 2126 | static int ab8500_gpadc_usb_id_print(struct seq_file *s, void *p) |
| 2127 | { |
| 2128 | int usb_id_raw; |
| 2129 | int usb_id_convert; |
| 2130 | struct ab8500_gpadc *gpadc; |
| 2131 | |
| 2132 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2133 | usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID, |
| 2134 | avg_sample, trig_edge, trig_timer, conv_type); |
| 2135 | usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID, |
| 2136 | usb_id_raw); |
| 2137 | |
| 2138 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2139 | usb_id_convert, usb_id_raw); |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 2140 | } |
| 2141 | |
| 2142 | static int ab8500_gpadc_usb_id_open(struct inode *inode, struct file *file) |
| 2143 | { |
| 2144 | return single_open(file, ab8500_gpadc_usb_id_print, inode->i_private); |
| 2145 | } |
| 2146 | |
| 2147 | static const struct file_operations ab8500_gpadc_usb_id_fops = { |
| 2148 | .open = ab8500_gpadc_usb_id_open, |
| 2149 | .read = seq_read, |
| 2150 | .llseek = seq_lseek, |
| 2151 | .release = single_release, |
| 2152 | .owner = THIS_MODULE, |
| 2153 | }; |
| 2154 | |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2155 | static int ab8540_gpadc_xtal_temp_print(struct seq_file *s, void *p) |
| 2156 | { |
| 2157 | int xtal_temp_raw; |
| 2158 | int xtal_temp_convert; |
| 2159 | struct ab8500_gpadc *gpadc; |
| 2160 | |
| 2161 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2162 | xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP, |
| 2163 | avg_sample, trig_edge, trig_timer, conv_type); |
| 2164 | xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP, |
| 2165 | xtal_temp_raw); |
| 2166 | |
| 2167 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2168 | xtal_temp_convert, xtal_temp_raw); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2169 | } |
| 2170 | |
| 2171 | static int ab8540_gpadc_xtal_temp_open(struct inode *inode, struct file *file) |
| 2172 | { |
| 2173 | return single_open(file, ab8540_gpadc_xtal_temp_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2174 | inode->i_private); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2175 | } |
| 2176 | |
| 2177 | static const struct file_operations ab8540_gpadc_xtal_temp_fops = { |
| 2178 | .open = ab8540_gpadc_xtal_temp_open, |
| 2179 | .read = seq_read, |
| 2180 | .llseek = seq_lseek, |
| 2181 | .release = single_release, |
| 2182 | .owner = THIS_MODULE, |
| 2183 | }; |
| 2184 | |
| 2185 | static int ab8540_gpadc_vbat_true_meas_print(struct seq_file *s, void *p) |
| 2186 | { |
| 2187 | int vbat_true_meas_raw; |
| 2188 | int vbat_true_meas_convert; |
| 2189 | struct ab8500_gpadc *gpadc; |
| 2190 | |
| 2191 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2192 | vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS, |
| 2193 | avg_sample, trig_edge, trig_timer, conv_type); |
| 2194 | vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS, |
| 2195 | vbat_true_meas_raw); |
| 2196 | |
| 2197 | return seq_printf(s, "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2198 | vbat_true_meas_convert, vbat_true_meas_raw); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2199 | } |
| 2200 | |
| 2201 | static int ab8540_gpadc_vbat_true_meas_open(struct inode *inode, |
| 2202 | struct file *file) |
| 2203 | { |
| 2204 | return single_open(file, ab8540_gpadc_vbat_true_meas_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2205 | inode->i_private); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | static const struct file_operations ab8540_gpadc_vbat_true_meas_fops = { |
| 2209 | .open = ab8540_gpadc_vbat_true_meas_open, |
| 2210 | .read = seq_read, |
| 2211 | .llseek = seq_lseek, |
| 2212 | .release = single_release, |
| 2213 | .owner = THIS_MODULE, |
| 2214 | }; |
| 2215 | |
| 2216 | static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file *s, void *p) |
| 2217 | { |
| 2218 | int bat_ctrl_raw; |
| 2219 | int bat_ctrl_convert; |
| 2220 | int ibat_raw; |
| 2221 | int ibat_convert; |
| 2222 | struct ab8500_gpadc *gpadc; |
| 2223 | |
| 2224 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2225 | bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT, |
| 2226 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); |
| 2227 | |
| 2228 | bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL, |
| 2229 | bat_ctrl_raw); |
| 2230 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2231 | ibat_raw); |
| 2232 | |
| 2233 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2234 | bat_ctrl_convert, bat_ctrl_raw, |
| 2235 | ibat_convert, ibat_raw); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2236 | } |
| 2237 | |
| 2238 | static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode *inode, |
| 2239 | struct file *file) |
| 2240 | { |
| 2241 | return single_open(file, ab8540_gpadc_bat_ctrl_and_ibat_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2242 | inode->i_private); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2243 | } |
| 2244 | |
| 2245 | static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops = { |
| 2246 | .open = ab8540_gpadc_bat_ctrl_and_ibat_open, |
| 2247 | .read = seq_read, |
| 2248 | .llseek = seq_lseek, |
| 2249 | .release = single_release, |
| 2250 | .owner = THIS_MODULE, |
| 2251 | }; |
| 2252 | |
| 2253 | static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file *s, void *p) |
| 2254 | { |
| 2255 | int vbat_meas_raw; |
| 2256 | int vbat_meas_convert; |
| 2257 | int ibat_raw; |
| 2258 | int ibat_convert; |
| 2259 | struct ab8500_gpadc *gpadc; |
| 2260 | |
| 2261 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2262 | vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT, |
| 2263 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); |
| 2264 | vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V, |
| 2265 | vbat_meas_raw); |
| 2266 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2267 | ibat_raw); |
| 2268 | |
| 2269 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2270 | vbat_meas_convert, vbat_meas_raw, |
| 2271 | ibat_convert, ibat_raw); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2272 | } |
| 2273 | |
| 2274 | static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode *inode, |
| 2275 | struct file *file) |
| 2276 | { |
| 2277 | return single_open(file, ab8540_gpadc_vbat_meas_and_ibat_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2278 | inode->i_private); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops = { |
| 2282 | .open = ab8540_gpadc_vbat_meas_and_ibat_open, |
| 2283 | .read = seq_read, |
| 2284 | .llseek = seq_lseek, |
| 2285 | .release = single_release, |
| 2286 | .owner = THIS_MODULE, |
| 2287 | }; |
| 2288 | |
| 2289 | static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file *s, void *p) |
| 2290 | { |
| 2291 | int vbat_true_meas_raw; |
| 2292 | int vbat_true_meas_convert; |
| 2293 | int ibat_raw; |
| 2294 | int ibat_convert; |
| 2295 | struct ab8500_gpadc *gpadc; |
| 2296 | |
| 2297 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2298 | vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc, |
| 2299 | VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge, |
| 2300 | trig_timer, conv_type, &ibat_raw); |
| 2301 | vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
| 2302 | VBAT_TRUE_MEAS, vbat_true_meas_raw); |
| 2303 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2304 | ibat_raw); |
| 2305 | |
| 2306 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2307 | vbat_true_meas_convert, vbat_true_meas_raw, |
| 2308 | ibat_convert, ibat_raw); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2309 | } |
| 2310 | |
| 2311 | static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode *inode, |
| 2312 | struct file *file) |
| 2313 | { |
| 2314 | return single_open(file, ab8540_gpadc_vbat_true_meas_and_ibat_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2315 | inode->i_private); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2316 | } |
| 2317 | |
| 2318 | static const struct file_operations ab8540_gpadc_vbat_true_meas_and_ibat_fops = { |
| 2319 | .open = ab8540_gpadc_vbat_true_meas_and_ibat_open, |
| 2320 | .read = seq_read, |
| 2321 | .llseek = seq_lseek, |
| 2322 | .release = single_release, |
| 2323 | .owner = THIS_MODULE, |
| 2324 | }; |
| 2325 | |
| 2326 | static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file *s, void *p) |
| 2327 | { |
| 2328 | int bat_temp_raw; |
| 2329 | int bat_temp_convert; |
| 2330 | int ibat_raw; |
| 2331 | int ibat_convert; |
| 2332 | struct ab8500_gpadc *gpadc; |
| 2333 | |
| 2334 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2335 | bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT, |
| 2336 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); |
| 2337 | bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, |
| 2338 | bat_temp_raw); |
| 2339 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2340 | ibat_raw); |
| 2341 | |
| 2342 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2343 | bat_temp_convert, bat_temp_raw, |
| 2344 | ibat_convert, ibat_raw); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode *inode, |
| 2348 | struct file *file) |
| 2349 | { |
| 2350 | return single_open(file, ab8540_gpadc_bat_temp_and_ibat_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2351 | inode->i_private); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2352 | } |
| 2353 | |
| 2354 | static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops = { |
| 2355 | .open = ab8540_gpadc_bat_temp_and_ibat_open, |
| 2356 | .read = seq_read, |
| 2357 | .llseek = seq_lseek, |
| 2358 | .release = single_release, |
| 2359 | .owner = THIS_MODULE, |
| 2360 | }; |
| 2361 | |
| 2362 | static int ab8540_gpadc_otp_cal_print(struct seq_file *s, void *p) |
| 2363 | { |
| 2364 | struct ab8500_gpadc *gpadc; |
| 2365 | u16 vmain_l, vmain_h, btemp_l, btemp_h; |
| 2366 | u16 vbat_l, vbat_h, ibat_l, ibat_h; |
| 2367 | |
| 2368 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2369 | ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h, |
| 2370 | &vbat_l, &vbat_h, &ibat_l, &ibat_h); |
| 2371 | return seq_printf(s, "VMAIN_L:0x%X\n" |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2372 | "VMAIN_H:0x%X\n" |
| 2373 | "BTEMP_L:0x%X\n" |
| 2374 | "BTEMP_H:0x%X\n" |
| 2375 | "VBAT_L:0x%X\n" |
| 2376 | "VBAT_H:0x%X\n" |
| 2377 | "IBAT_L:0x%X\n" |
| 2378 | "IBAT_H:0x%X\n", |
| 2379 | vmain_l, vmain_h, btemp_l, btemp_h, vbat_l, vbat_h, ibat_l, ibat_h); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2380 | } |
| 2381 | |
| 2382 | static int ab8540_gpadc_otp_cal_open(struct inode *inode, struct file *file) |
| 2383 | { |
| 2384 | return single_open(file, ab8540_gpadc_otp_cal_print, inode->i_private); |
| 2385 | } |
| 2386 | |
| 2387 | static const struct file_operations ab8540_gpadc_otp_calib_fops = { |
| 2388 | .open = ab8540_gpadc_otp_cal_open, |
| 2389 | .read = seq_read, |
| 2390 | .llseek = seq_lseek, |
| 2391 | .release = single_release, |
| 2392 | .owner = THIS_MODULE, |
| 2393 | }; |
| 2394 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2395 | static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p) |
| 2396 | { |
| 2397 | return seq_printf(s, "%d\n", avg_sample); |
| 2398 | } |
| 2399 | |
| 2400 | static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file) |
| 2401 | { |
| 2402 | return single_open(file, ab8500_gpadc_avg_sample_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2403 | inode->i_private); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2404 | } |
| 2405 | |
| 2406 | static ssize_t ab8500_gpadc_avg_sample_write(struct file *file, |
| 2407 | const char __user *user_buf, |
| 2408 | size_t count, loff_t *ppos) |
| 2409 | { |
| 2410 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2411 | unsigned long user_avg_sample; |
| 2412 | int err; |
| 2413 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2414 | err = kstrtoul_from_user(user_buf, count, 0, &user_avg_sample); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2415 | if (err) |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2416 | return err; |
| 2417 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2418 | if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4) |
| 2419 | || (user_avg_sample == SAMPLE_8) |
| 2420 | || (user_avg_sample == SAMPLE_16)) { |
| 2421 | avg_sample = (u8) user_avg_sample; |
| 2422 | } else { |
| 2423 | dev_err(dev, "debugfs error input: " |
| 2424 | "should be egal to 1, 4, 8 or 16\n"); |
| 2425 | return -EINVAL; |
| 2426 | } |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2427 | |
| 2428 | return count; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2429 | } |
| 2430 | |
| 2431 | static const struct file_operations ab8500_gpadc_avg_sample_fops = { |
| 2432 | .open = ab8500_gpadc_avg_sample_open, |
| 2433 | .read = seq_read, |
| 2434 | .write = ab8500_gpadc_avg_sample_write, |
| 2435 | .llseek = seq_lseek, |
| 2436 | .release = single_release, |
| 2437 | .owner = THIS_MODULE, |
| 2438 | }; |
| 2439 | |
| 2440 | static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p) |
| 2441 | { |
| 2442 | return seq_printf(s, "%d\n", trig_edge); |
| 2443 | } |
| 2444 | |
| 2445 | static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file) |
| 2446 | { |
| 2447 | return single_open(file, ab8500_gpadc_trig_edge_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2448 | inode->i_private); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2449 | } |
| 2450 | |
| 2451 | static ssize_t ab8500_gpadc_trig_edge_write(struct file *file, |
| 2452 | const char __user *user_buf, |
| 2453 | size_t count, loff_t *ppos) |
| 2454 | { |
| 2455 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2456 | unsigned long user_trig_edge; |
| 2457 | int err; |
| 2458 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2459 | err = kstrtoul_from_user(user_buf, count, 0, &user_trig_edge); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2460 | if (err) |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2461 | return err; |
| 2462 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2463 | if ((user_trig_edge == RISING_EDGE) |
| 2464 | || (user_trig_edge == FALLING_EDGE)) { |
| 2465 | trig_edge = (u8) user_trig_edge; |
| 2466 | } else { |
| 2467 | dev_err(dev, "Wrong input:\n" |
| 2468 | "Enter 0. Rising edge\n" |
| 2469 | "Enter 1. Falling edge\n"); |
| 2470 | return -EINVAL; |
| 2471 | } |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2472 | |
| 2473 | return count; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2474 | } |
| 2475 | |
| 2476 | static const struct file_operations ab8500_gpadc_trig_edge_fops = { |
| 2477 | .open = ab8500_gpadc_trig_edge_open, |
| 2478 | .read = seq_read, |
| 2479 | .write = ab8500_gpadc_trig_edge_write, |
| 2480 | .llseek = seq_lseek, |
| 2481 | .release = single_release, |
| 2482 | .owner = THIS_MODULE, |
| 2483 | }; |
| 2484 | |
| 2485 | static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p) |
| 2486 | { |
| 2487 | return seq_printf(s, "%d\n", trig_timer); |
| 2488 | } |
| 2489 | |
| 2490 | static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file) |
| 2491 | { |
| 2492 | return single_open(file, ab8500_gpadc_trig_timer_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2493 | inode->i_private); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2494 | } |
| 2495 | |
| 2496 | static ssize_t ab8500_gpadc_trig_timer_write(struct file *file, |
| 2497 | const char __user *user_buf, |
| 2498 | size_t count, loff_t *ppos) |
| 2499 | { |
| 2500 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2501 | unsigned long user_trig_timer; |
| 2502 | int err; |
| 2503 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2504 | err = kstrtoul_from_user(user_buf, count, 0, &user_trig_timer); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2505 | if (err) |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2506 | return err; |
| 2507 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2508 | if ((user_trig_timer >= 0) && (user_trig_timer <= 255)) { |
| 2509 | trig_timer = (u8) user_trig_timer; |
| 2510 | } else { |
| 2511 | dev_err(dev, "debugfs error input: " |
| 2512 | "should be beetween 0 to 255\n"); |
| 2513 | return -EINVAL; |
| 2514 | } |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2515 | |
| 2516 | return count; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2517 | } |
| 2518 | |
| 2519 | static const struct file_operations ab8500_gpadc_trig_timer_fops = { |
| 2520 | .open = ab8500_gpadc_trig_timer_open, |
| 2521 | .read = seq_read, |
| 2522 | .write = ab8500_gpadc_trig_timer_write, |
| 2523 | .llseek = seq_lseek, |
| 2524 | .release = single_release, |
| 2525 | .owner = THIS_MODULE, |
| 2526 | }; |
| 2527 | |
| 2528 | static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p) |
| 2529 | { |
| 2530 | return seq_printf(s, "%d\n", conv_type); |
| 2531 | } |
| 2532 | |
| 2533 | static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file) |
| 2534 | { |
| 2535 | return single_open(file, ab8500_gpadc_conv_type_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2536 | inode->i_private); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2537 | } |
| 2538 | |
| 2539 | static ssize_t ab8500_gpadc_conv_type_write(struct file *file, |
| 2540 | const char __user *user_buf, |
| 2541 | size_t count, loff_t *ppos) |
| 2542 | { |
| 2543 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2544 | unsigned long user_conv_type; |
| 2545 | int err; |
| 2546 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2547 | err = kstrtoul_from_user(user_buf, count, 0, &user_conv_type); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2548 | if (err) |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2549 | return err; |
| 2550 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2551 | if ((user_conv_type == ADC_SW) |
| 2552 | || (user_conv_type == ADC_HW)) { |
| 2553 | conv_type = (u8) user_conv_type; |
| 2554 | } else { |
| 2555 | dev_err(dev, "Wrong input:\n" |
| 2556 | "Enter 0. ADC SW conversion\n" |
| 2557 | "Enter 1. ADC HW conversion\n"); |
| 2558 | return -EINVAL; |
| 2559 | } |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2560 | |
| 2561 | return count; |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2562 | } |
| 2563 | |
| 2564 | static const struct file_operations ab8500_gpadc_conv_type_fops = { |
| 2565 | .open = ab8500_gpadc_conv_type_open, |
| 2566 | .read = seq_read, |
| 2567 | .write = ab8500_gpadc_conv_type_write, |
| 2568 | .llseek = seq_lseek, |
| 2569 | .release = single_release, |
| 2570 | .owner = THIS_MODULE, |
| 2571 | }; |
| 2572 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2573 | /* |
| 2574 | * return length of an ASCII numerical value, 0 is string is not a |
| 2575 | * numerical value. |
| 2576 | * string shall start at value 1st char. |
| 2577 | * string can be tailed with \0 or space or newline chars only. |
| 2578 | * value can be decimal or hexadecimal (prefixed 0x or 0X). |
| 2579 | */ |
| 2580 | static int strval_len(char *b) |
| 2581 | { |
| 2582 | char *s = b; |
| 2583 | if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) { |
| 2584 | s += 2; |
| 2585 | for (; *s && (*s != ' ') && (*s != '\n'); s++) { |
| 2586 | if (!isxdigit(*s)) |
| 2587 | return 0; |
| 2588 | } |
| 2589 | } else { |
| 2590 | if (*s == '-') |
| 2591 | s++; |
| 2592 | for (; *s && (*s != ' ') && (*s != '\n'); s++) { |
| 2593 | if (!isdigit(*s)) |
| 2594 | return 0; |
| 2595 | } |
| 2596 | } |
| 2597 | return (int) (s-b); |
| 2598 | } |
| 2599 | |
| 2600 | /* |
| 2601 | * parse hwreg input data. |
| 2602 | * update global hwreg_cfg only if input data syntax is ok. |
| 2603 | */ |
| 2604 | static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg, |
| 2605 | struct device *dev) |
| 2606 | { |
| 2607 | uint write, val = 0; |
| 2608 | u8 regvalue; |
| 2609 | int ret; |
| 2610 | struct hwreg_cfg loc = { |
| 2611 | .bank = 0, /* default: invalid phys addr */ |
| 2612 | .addr = 0, /* default: invalid phys addr */ |
| 2613 | .fmt = 0, /* default: 32bit access, hex output */ |
| 2614 | .mask = 0xFFFFFFFF, /* default: no mask */ |
| 2615 | .shift = 0, /* default: no bit shift */ |
| 2616 | }; |
| 2617 | |
| 2618 | /* read or write ? */ |
| 2619 | if (!strncmp(b, "read ", 5)) { |
| 2620 | write = 0; |
| 2621 | b += 5; |
| 2622 | } else if (!strncmp(b, "write ", 6)) { |
| 2623 | write = 1; |
| 2624 | b += 6; |
| 2625 | } else |
| 2626 | return -EINVAL; |
| 2627 | |
| 2628 | /* OPTIONS -l|-w|-b -s -m -o */ |
| 2629 | while ((*b == ' ') || (*b == '-')) { |
| 2630 | if (*(b-1) != ' ') { |
| 2631 | b++; |
| 2632 | continue; |
| 2633 | } |
| 2634 | if ((!strncmp(b, "-d ", 3)) || |
| 2635 | (!strncmp(b, "-dec ", 5))) { |
| 2636 | b += (*(b+2) == ' ') ? 3 : 5; |
| 2637 | loc.fmt |= (1<<0); |
| 2638 | } else if ((!strncmp(b, "-h ", 3)) || |
| 2639 | (!strncmp(b, "-hex ", 5))) { |
| 2640 | b += (*(b+2) == ' ') ? 3 : 5; |
| 2641 | loc.fmt &= ~(1<<0); |
| 2642 | } else if ((!strncmp(b, "-m ", 3)) || |
| 2643 | (!strncmp(b, "-mask ", 6))) { |
| 2644 | b += (*(b+2) == ' ') ? 3 : 6; |
| 2645 | if (strval_len(b) == 0) |
| 2646 | return -EINVAL; |
| 2647 | loc.mask = simple_strtoul(b, &b, 0); |
| 2648 | } else if ((!strncmp(b, "-s ", 3)) || |
| 2649 | (!strncmp(b, "-shift ", 7))) { |
| 2650 | b += (*(b+2) == ' ') ? 3 : 7; |
| 2651 | if (strval_len(b) == 0) |
| 2652 | return -EINVAL; |
| 2653 | loc.shift = simple_strtol(b, &b, 0); |
| 2654 | } else { |
| 2655 | return -EINVAL; |
| 2656 | } |
| 2657 | } |
| 2658 | /* get arg BANK and ADDRESS */ |
| 2659 | if (strval_len(b) == 0) |
| 2660 | return -EINVAL; |
| 2661 | loc.bank = simple_strtoul(b, &b, 0); |
| 2662 | while (*b == ' ') |
| 2663 | b++; |
| 2664 | if (strval_len(b) == 0) |
| 2665 | return -EINVAL; |
| 2666 | loc.addr = simple_strtoul(b, &b, 0); |
| 2667 | |
| 2668 | if (write) { |
| 2669 | while (*b == ' ') |
| 2670 | b++; |
| 2671 | if (strval_len(b) == 0) |
| 2672 | return -EINVAL; |
| 2673 | val = simple_strtoul(b, &b, 0); |
| 2674 | } |
| 2675 | |
| 2676 | /* args are ok, update target cfg (mainly for read) */ |
| 2677 | *cfg = loc; |
| 2678 | |
| 2679 | #ifdef ABB_HWREG_DEBUG |
| 2680 | pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d" |
| 2681 | "value=0x%X\n", (write) ? "write" : "read", |
| 2682 | REG_FMT_DEC(cfg) ? "decimal" : "hexa", |
| 2683 | cfg->addr, cfg->mask, cfg->shift, val); |
| 2684 | #endif |
| 2685 | |
| 2686 | if (!write) |
| 2687 | return 0; |
| 2688 | |
| 2689 | ret = abx500_get_register_interruptible(dev, |
| 2690 | (u8)cfg->bank, (u8)cfg->addr, ®value); |
| 2691 | if (ret < 0) { |
| 2692 | dev_err(dev, "abx500_get_reg fail %d, %d\n", |
| 2693 | ret, __LINE__); |
| 2694 | return -EINVAL; |
| 2695 | } |
| 2696 | |
| 2697 | if (cfg->shift >= 0) { |
| 2698 | regvalue &= ~(cfg->mask << (cfg->shift)); |
| 2699 | val = (val & cfg->mask) << (cfg->shift); |
| 2700 | } else { |
| 2701 | regvalue &= ~(cfg->mask >> (-cfg->shift)); |
| 2702 | val = (val & cfg->mask) >> (-cfg->shift); |
| 2703 | } |
| 2704 | val = val | regvalue; |
| 2705 | |
| 2706 | ret = abx500_set_register_interruptible(dev, |
| 2707 | (u8)cfg->bank, (u8)cfg->addr, (u8)val); |
| 2708 | if (ret < 0) { |
| 2709 | pr_err("abx500_set_reg failed %d, %d", ret, __LINE__); |
| 2710 | return -EINVAL; |
| 2711 | } |
| 2712 | |
| 2713 | return 0; |
| 2714 | } |
| 2715 | |
| 2716 | static ssize_t ab8500_hwreg_write(struct file *file, |
| 2717 | const char __user *user_buf, size_t count, loff_t *ppos) |
| 2718 | { |
| 2719 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2720 | char buf[128]; |
| 2721 | int buf_size, ret; |
| 2722 | |
| 2723 | /* Get userspace string and assure termination */ |
| 2724 | buf_size = min(count, (sizeof(buf)-1)); |
| 2725 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2726 | return -EFAULT; |
| 2727 | buf[buf_size] = 0; |
| 2728 | |
| 2729 | /* get args and process */ |
| 2730 | ret = hwreg_common_write(buf, &hwreg_cfg, dev); |
| 2731 | return (ret) ? ret : buf_size; |
| 2732 | } |
| 2733 | |
| 2734 | /* |
| 2735 | * - irq subscribe/unsubscribe stuff |
| 2736 | */ |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2737 | static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p) |
| 2738 | { |
| 2739 | seq_printf(s, "%d\n", irq_first); |
| 2740 | |
| 2741 | return 0; |
| 2742 | } |
| 2743 | |
| 2744 | static int ab8500_subscribe_unsubscribe_open(struct inode *inode, |
| 2745 | struct file *file) |
| 2746 | { |
| 2747 | return single_open(file, ab8500_subscribe_unsubscribe_print, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2748 | inode->i_private); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2749 | } |
| 2750 | |
| 2751 | /* |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2752 | * Userspace should use poll() on this file. When an event occur |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2753 | * the blocking poll will be released. |
| 2754 | */ |
| 2755 | static ssize_t show_irq(struct device *dev, |
| 2756 | struct device_attribute *attr, char *buf) |
| 2757 | { |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2758 | unsigned long name; |
| 2759 | unsigned int irq_index; |
| 2760 | int err; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2761 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2762 | err = strict_strtoul(attr->attr.name, 0, &name); |
| 2763 | if (err) |
| 2764 | return err; |
| 2765 | |
| 2766 | irq_index = name - irq_first; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2767 | if (irq_index >= num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2768 | return -EINVAL; |
| 2769 | else |
| 2770 | return sprintf(buf, "%u\n", irq_count[irq_index]); |
| 2771 | } |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2772 | |
| 2773 | static ssize_t ab8500_subscribe_write(struct file *file, |
| 2774 | const char __user *user_buf, |
| 2775 | size_t count, loff_t *ppos) |
| 2776 | { |
| 2777 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2778 | unsigned long user_val; |
| 2779 | int err; |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2780 | unsigned int irq_index; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2781 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2782 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2783 | if (err) |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2784 | return err; |
| 2785 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2786 | if (user_val < irq_first) { |
| 2787 | dev_err(dev, "debugfs error input < %d\n", irq_first); |
| 2788 | return -EINVAL; |
| 2789 | } |
| 2790 | if (user_val > irq_last) { |
| 2791 | dev_err(dev, "debugfs error input > %d\n", irq_last); |
| 2792 | return -EINVAL; |
| 2793 | } |
| 2794 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2795 | irq_index = user_val - irq_first; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2796 | if (irq_index >= num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2797 | return -EINVAL; |
| 2798 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2799 | /* |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2800 | * This will create a sysfs file named <irq-nr> which userspace can |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2801 | * use to select or poll and get the AB8500 events |
| 2802 | */ |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2803 | dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), |
| 2804 | GFP_KERNEL); |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2805 | event_name[irq_index] = kmalloc(count, GFP_KERNEL); |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2806 | sprintf(event_name[irq_index], "%lu", user_val); |
| 2807 | dev_attr[irq_index]->show = show_irq; |
| 2808 | dev_attr[irq_index]->store = NULL; |
| 2809 | dev_attr[irq_index]->attr.name = event_name[irq_index]; |
| 2810 | dev_attr[irq_index]->attr.mode = S_IRUGO; |
| 2811 | err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2812 | if (err < 0) { |
| 2813 | printk(KERN_ERR "sysfs_create_file failed %d\n", err); |
| 2814 | return err; |
| 2815 | } |
| 2816 | |
| 2817 | err = request_threaded_irq(user_val, NULL, ab8500_debug_handler, |
| 2818 | IRQF_SHARED | IRQF_NO_SUSPEND, |
| 2819 | "ab8500-debug", &dev->kobj); |
| 2820 | if (err < 0) { |
| 2821 | printk(KERN_ERR "request_threaded_irq failed %d, %lu\n", |
| 2822 | err, user_val); |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2823 | sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2824 | return err; |
| 2825 | } |
| 2826 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2827 | return count; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2828 | } |
| 2829 | |
| 2830 | static ssize_t ab8500_unsubscribe_write(struct file *file, |
| 2831 | const char __user *user_buf, |
| 2832 | size_t count, loff_t *ppos) |
| 2833 | { |
| 2834 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2835 | unsigned long user_val; |
| 2836 | int err; |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2837 | unsigned int irq_index; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2838 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2839 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2840 | if (err) |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2841 | return err; |
| 2842 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2843 | if (user_val < irq_first) { |
| 2844 | dev_err(dev, "debugfs error input < %d\n", irq_first); |
| 2845 | return -EINVAL; |
| 2846 | } |
| 2847 | if (user_val > irq_last) { |
| 2848 | dev_err(dev, "debugfs error input > %d\n", irq_last); |
| 2849 | return -EINVAL; |
| 2850 | } |
| 2851 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2852 | irq_index = user_val - irq_first; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2853 | if (irq_index >= num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2854 | return -EINVAL; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2855 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2856 | /* Set irq count to 0 when unsubscribe */ |
| 2857 | irq_count[irq_index] = 0; |
| 2858 | |
| 2859 | if (dev_attr[irq_index]) |
| 2860 | sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); |
| 2861 | |
| 2862 | |
| 2863 | free_irq(user_val, &dev->kobj); |
| 2864 | kfree(event_name[irq_index]); |
| 2865 | kfree(dev_attr[irq_index]); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2866 | |
srinidhi kasagar | 7b830ae | 2012-11-23 15:11:00 +0530 | [diff] [blame] | 2867 | return count; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2868 | } |
| 2869 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2870 | /* |
| 2871 | * - several deubgfs nodes fops |
| 2872 | */ |
| 2873 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2874 | static const struct file_operations ab8500_bank_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2875 | .open = ab8500_bank_open, |
| 2876 | .write = ab8500_bank_write, |
| 2877 | .read = seq_read, |
| 2878 | .llseek = seq_lseek, |
| 2879 | .release = single_release, |
| 2880 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2881 | }; |
| 2882 | |
| 2883 | static const struct file_operations ab8500_address_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2884 | .open = ab8500_address_open, |
| 2885 | .write = ab8500_address_write, |
| 2886 | .read = seq_read, |
| 2887 | .llseek = seq_lseek, |
| 2888 | .release = single_release, |
| 2889 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2890 | }; |
| 2891 | |
| 2892 | static const struct file_operations ab8500_val_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2893 | .open = ab8500_val_open, |
| 2894 | .write = ab8500_val_write, |
| 2895 | .read = seq_read, |
| 2896 | .llseek = seq_lseek, |
| 2897 | .release = single_release, |
| 2898 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2899 | }; |
| 2900 | |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 2901 | static const struct file_operations ab8500_interrupts_fops = { |
| 2902 | .open = ab8500_interrupts_open, |
| 2903 | .read = seq_read, |
| 2904 | .llseek = seq_lseek, |
| 2905 | .release = single_release, |
| 2906 | .owner = THIS_MODULE, |
| 2907 | }; |
| 2908 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2909 | static const struct file_operations ab8500_subscribe_fops = { |
| 2910 | .open = ab8500_subscribe_unsubscribe_open, |
| 2911 | .write = ab8500_subscribe_write, |
| 2912 | .read = seq_read, |
| 2913 | .llseek = seq_lseek, |
| 2914 | .release = single_release, |
| 2915 | .owner = THIS_MODULE, |
| 2916 | }; |
| 2917 | |
| 2918 | static const struct file_operations ab8500_unsubscribe_fops = { |
| 2919 | .open = ab8500_subscribe_unsubscribe_open, |
| 2920 | .write = ab8500_unsubscribe_write, |
| 2921 | .read = seq_read, |
| 2922 | .llseek = seq_lseek, |
| 2923 | .release = single_release, |
| 2924 | .owner = THIS_MODULE, |
| 2925 | }; |
| 2926 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2927 | static const struct file_operations ab8500_hwreg_fops = { |
| 2928 | .open = ab8500_hwreg_open, |
| 2929 | .write = ab8500_hwreg_write, |
| 2930 | .read = seq_read, |
| 2931 | .llseek = seq_lseek, |
| 2932 | .release = single_release, |
| 2933 | .owner = THIS_MODULE, |
| 2934 | }; |
| 2935 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2936 | static struct dentry *ab8500_dir; |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2937 | static struct dentry *ab8500_gpadc_dir; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2938 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 2939 | static int ab8500_debug_probe(struct platform_device *plf) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2940 | { |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2941 | struct dentry *file; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2942 | int ret = -ENOMEM; |
| 2943 | struct ab8500 *ab8500; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2944 | debug_bank = AB8500_MISC; |
| 2945 | debug_address = AB8500_REV_REG & 0x00FF; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2946 | |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2947 | ab8500 = dev_get_drvdata(plf->dev.parent); |
| 2948 | num_irqs = ab8500->mask_size; |
| 2949 | |
Ashok G | 70bad04 | 2012-02-28 10:21:00 +0530 | [diff] [blame] | 2950 | irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2951 | if (!irq_count) |
| 2952 | return -ENOMEM; |
| 2953 | |
| 2954 | dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL); |
| 2955 | if (!dev_attr) |
| 2956 | goto out_freeirq_count; |
| 2957 | |
| 2958 | event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL); |
| 2959 | if (!event_name) |
| 2960 | goto out_freedev_attr; |
| 2961 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2962 | irq_first = platform_get_irq_byname(plf, "IRQ_FIRST"); |
| 2963 | if (irq_first < 0) { |
| 2964 | dev_err(&plf->dev, "First irq not found, err %d\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2965 | irq_first); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2966 | ret = irq_first; |
| 2967 | goto out_freeevent_name; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2968 | } |
| 2969 | |
| 2970 | irq_last = platform_get_irq_byname(plf, "IRQ_LAST"); |
| 2971 | if (irq_last < 0) { |
| 2972 | dev_err(&plf->dev, "Last irq not found, err %d\n", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2973 | irq_last); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2974 | ret = irq_last; |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 2975 | goto out_freeevent_name; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2976 | } |
| 2977 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2978 | ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); |
| 2979 | if (!ab8500_dir) |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2980 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2981 | |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2982 | ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2983 | ab8500_dir); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2984 | if (!ab8500_gpadc_dir) |
| 2985 | goto err; |
| 2986 | |
| 2987 | file = debugfs_create_file("all-bank-registers", S_IRUGO, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2988 | ab8500_dir, &plf->dev, &ab8500_registers_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2989 | if (!file) |
| 2990 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2991 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 2992 | file = debugfs_create_file("all-banks", S_IRUGO, |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2993 | ab8500_dir, &plf->dev, &ab8500_all_banks_fops); |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 2994 | if (!file) |
| 2995 | goto err; |
| 2996 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 2997 | file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 2998 | ab8500_dir, &plf->dev, &ab8500_bank_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2999 | if (!file) |
| 3000 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3001 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3002 | file = debugfs_create_file("register-address", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3003 | ab8500_dir, &plf->dev, &ab8500_address_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3004 | if (!file) |
| 3005 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3006 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3007 | file = debugfs_create_file("register-value", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3008 | ab8500_dir, &plf->dev, &ab8500_val_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3009 | if (!file) |
| 3010 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3011 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3012 | file = debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3013 | ab8500_dir, &plf->dev, &ab8500_subscribe_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3014 | if (!file) |
| 3015 | goto err; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 3016 | |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3017 | if (is_ab8500(ab8500)) { |
| 3018 | debug_ranges = ab8500_debug_ranges; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3019 | num_interrupt_lines = AB8500_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3020 | } else if (is_ab8505(ab8500)) { |
| 3021 | debug_ranges = ab8505_debug_ranges; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3022 | num_interrupt_lines = AB8505_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3023 | } else if (is_ab9540(ab8500)) { |
| 3024 | debug_ranges = ab8505_debug_ranges; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3025 | num_interrupt_lines = AB9540_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3026 | } else if (is_ab8540(ab8500)) { |
Lee Jones | 971480f | 2012-11-19 12:20:03 +0100 | [diff] [blame] | 3027 | debug_ranges = ab8540_debug_ranges; |
Lee Jones | e436ddf | 2013-02-26 10:09:41 +0000 | [diff] [blame] | 3028 | num_interrupt_lines = AB8540_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3029 | } |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3030 | |
| 3031 | file = debugfs_create_file("interrupts", (S_IRUGO), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3032 | ab8500_dir, &plf->dev, &ab8500_interrupts_fops); |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3033 | if (!file) |
| 3034 | goto err; |
| 3035 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3036 | file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3037 | ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3038 | if (!file) |
| 3039 | goto err; |
| 3040 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3041 | file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3042 | ab8500_dir, &plf->dev, &ab8500_hwreg_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3043 | if (!file) |
| 3044 | goto err; |
| 3045 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3046 | file = debugfs_create_file("all-modem-registers", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | c7ebaee | 2013-02-26 14:03:33 +0000 | [diff] [blame] | 3047 | ab8500_dir, &plf->dev, &ab8500_modem_fops); |
| 3048 | if (!file) |
| 3049 | goto err; |
| 3050 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3051 | file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3052 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3053 | if (!file) |
| 3054 | goto err; |
| 3055 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3056 | file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3057 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_btemp_ball_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3058 | if (!file) |
| 3059 | goto err; |
| 3060 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3061 | file = debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3062 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_v_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3063 | if (!file) |
| 3064 | goto err; |
| 3065 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3066 | file = debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3067 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect1_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3068 | if (!file) |
| 3069 | goto err; |
| 3070 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3071 | file = debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3072 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect2_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3073 | if (!file) |
| 3074 | goto err; |
| 3075 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3076 | file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3077 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux1_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3078 | if (!file) |
| 3079 | goto err; |
| 3080 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3081 | file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3082 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux2_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3083 | if (!file) |
| 3084 | goto err; |
| 3085 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3086 | file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3087 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_bat_v_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3088 | if (!file) |
| 3089 | goto err; |
| 3090 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3091 | file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3092 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_vbus_v_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3093 | if (!file) |
| 3094 | goto err; |
| 3095 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3096 | file = debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3097 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_c_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3098 | if (!file) |
| 3099 | goto err; |
| 3100 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3101 | file = debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3102 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_charger_c_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3103 | if (!file) |
| 3104 | goto err; |
| 3105 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3106 | file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3107 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bk_bat_v_fops); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3108 | if (!file) |
| 3109 | goto err; |
| 3110 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3111 | file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3112 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_die_temp_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3113 | if (!file) |
| 3114 | goto err; |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 3115 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3116 | file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 3117 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_id_fops); |
| 3118 | if (!file) |
| 3119 | goto err; |
| 3120 | |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3121 | if (is_ab8540(ab8500)) { |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3122 | file = debugfs_create_file("xtal_temp", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3123 | ab8500_gpadc_dir, &plf->dev, &ab8540_gpadc_xtal_temp_fops); |
| 3124 | if (!file) |
| 3125 | goto err; |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3126 | file = debugfs_create_file("vbattruemeas", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3127 | ab8500_gpadc_dir, &plf->dev, |
| 3128 | &ab8540_gpadc_vbat_true_meas_fops); |
| 3129 | if (!file) |
| 3130 | goto err; |
| 3131 | file = debugfs_create_file("batctrl_and_ibat", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3132 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3133 | &plf->dev, &ab8540_gpadc_bat_ctrl_and_ibat_fops); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3134 | if (!file) |
| 3135 | goto err; |
| 3136 | file = debugfs_create_file("vbatmeas_and_ibat", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3137 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3138 | &plf->dev, |
| 3139 | &ab8540_gpadc_vbat_meas_and_ibat_fops); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3140 | if (!file) |
| 3141 | goto err; |
| 3142 | file = debugfs_create_file("vbattruemeas_and_ibat", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3143 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3144 | &plf->dev, |
| 3145 | &ab8540_gpadc_vbat_true_meas_and_ibat_fops); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3146 | if (!file) |
| 3147 | goto err; |
| 3148 | file = debugfs_create_file("battemp_and_ibat", |
Lee Jones | 9f9ba15 | 2013-02-26 12:05:15 +0000 | [diff] [blame] | 3149 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3150 | &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops); |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3151 | if (!file) |
| 3152 | goto err; |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3153 | file = debugfs_create_file("otp_calib", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3154 | ab8500_gpadc_dir, &plf->dev, &ab8540_gpadc_otp_calib_fops); |
| 3155 | if (!file) |
| 3156 | goto err; |
| 3157 | } |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3158 | file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3159 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_avg_sample_fops); |
| 3160 | if (!file) |
| 3161 | goto err; |
| 3162 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3163 | file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3164 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_edge_fops); |
| 3165 | if (!file) |
| 3166 | goto err; |
| 3167 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3168 | file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3169 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_timer_fops); |
| 3170 | if (!file) |
| 3171 | goto err; |
| 3172 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3173 | file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3174 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_conv_type_fops); |
| 3175 | if (!file) |
| 3176 | goto err; |
| 3177 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3178 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3179 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3180 | err: |
| 3181 | if (ab8500_dir) |
| 3182 | debugfs_remove_recursive(ab8500_dir); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3183 | dev_err(&plf->dev, "failed to create debugfs entries.\n"); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 3184 | out_freeevent_name: |
| 3185 | kfree(event_name); |
| 3186 | out_freedev_attr: |
| 3187 | kfree(dev_attr); |
| 3188 | out_freeirq_count: |
| 3189 | kfree(irq_count); |
| 3190 | |
| 3191 | return ret; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3192 | } |
| 3193 | |
Bill Pemberton | 4740f73 | 2012-11-19 13:26:01 -0500 | [diff] [blame] | 3194 | static int ab8500_debug_remove(struct platform_device *plf) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3195 | { |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3196 | debugfs_remove_recursive(ab8500_dir); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 3197 | kfree(event_name); |
| 3198 | kfree(dev_attr); |
| 3199 | kfree(irq_count); |
| 3200 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3201 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3202 | } |
| 3203 | |
| 3204 | static struct platform_driver ab8500_debug_driver = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3205 | .driver = { |
| 3206 | .name = "ab8500-debug", |
| 3207 | .owner = THIS_MODULE, |
| 3208 | }, |
| 3209 | .probe = ab8500_debug_probe, |
Bill Pemberton | 8444921 | 2012-11-19 13:20:24 -0500 | [diff] [blame] | 3210 | .remove = ab8500_debug_remove |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3211 | }; |
| 3212 | |
| 3213 | static int __init ab8500_debug_init(void) |
| 3214 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3215 | return platform_driver_register(&ab8500_debug_driver); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3216 | } |
| 3217 | |
| 3218 | static void __exit ab8500_debug_exit(void) |
| 3219 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3220 | platform_driver_unregister(&ab8500_debug_driver); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3221 | } |
| 3222 | subsys_initcall(ab8500_debug_init); |
| 3223 | module_exit(ab8500_debug_exit); |
| 3224 | |
| 3225 | MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com"); |
| 3226 | MODULE_DESCRIPTION("AB8500 DEBUG"); |
| 3227 | MODULE_LICENSE("GPL v2"); |