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