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