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 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1482 | /* Get userspace string and assure termination */ |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1483 | err = kstrtoul_from_user(user_buf, count, 0, &user_bank); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1484 | if (err) |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1485 | return err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1486 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1487 | if (user_bank >= AB8500_NUM_BANKS) { |
| 1488 | dev_err(dev, "debugfs error input > number of banks\n"); |
| 1489 | return -EINVAL; |
| 1490 | } |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1491 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1492 | debug_bank = user_bank; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1493 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1494 | return count; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1495 | } |
| 1496 | |
| 1497 | static int ab8500_address_print(struct seq_file *s, void *p) |
| 1498 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1499 | return seq_printf(s, "0x%02X\n", debug_address); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1500 | } |
| 1501 | |
| 1502 | static int ab8500_address_open(struct inode *inode, struct file *file) |
| 1503 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1504 | return single_open(file, ab8500_address_print, inode->i_private); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1505 | } |
| 1506 | |
| 1507 | static ssize_t ab8500_address_write(struct file *file, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1508 | const char __user *user_buf, |
| 1509 | size_t count, loff_t *ppos) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1510 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1511 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1512 | unsigned long user_address; |
| 1513 | int err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1514 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1515 | /* Get userspace string and assure termination */ |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1516 | err = kstrtoul_from_user(user_buf, count, 0, &user_address); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1517 | if (err) |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1518 | return err; |
| 1519 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1520 | if (user_address > 0xff) { |
| 1521 | dev_err(dev, "debugfs error input > 0xff\n"); |
| 1522 | return -EINVAL; |
| 1523 | } |
| 1524 | debug_address = user_address; |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1525 | return count; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | static int ab8500_val_print(struct seq_file *s, void *p) |
| 1529 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1530 | struct device *dev = s->private; |
| 1531 | int ret; |
| 1532 | u8 regvalue; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1533 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1534 | ret = abx500_get_register_interruptible(dev, |
| 1535 | (u8)debug_bank, (u8)debug_address, ®value); |
| 1536 | if (ret < 0) { |
| 1537 | dev_err(dev, "abx500_get_reg fail %d, %d\n", |
| 1538 | ret, __LINE__); |
| 1539 | return -EINVAL; |
| 1540 | } |
| 1541 | seq_printf(s, "0x%02X\n", regvalue); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1542 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1543 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1544 | } |
| 1545 | |
| 1546 | static int ab8500_val_open(struct inode *inode, struct file *file) |
| 1547 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1548 | return single_open(file, ab8500_val_print, inode->i_private); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1549 | } |
| 1550 | |
| 1551 | static ssize_t ab8500_val_write(struct file *file, |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1552 | const char __user *user_buf, |
| 1553 | size_t count, loff_t *ppos) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1554 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1555 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1556 | unsigned long user_val; |
| 1557 | int err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1558 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1559 | /* Get userspace string and assure termination */ |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1560 | err = kstrtoul_from_user(user_buf, count, 0, &user_val); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1561 | if (err) |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1562 | return err; |
| 1563 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 1564 | if (user_val > 0xff) { |
| 1565 | dev_err(dev, "debugfs error input > 0xff\n"); |
| 1566 | return -EINVAL; |
| 1567 | } |
| 1568 | err = abx500_set_register_interruptible(dev, |
| 1569 | (u8)debug_bank, debug_address, (u8)user_val); |
| 1570 | if (err < 0) { |
| 1571 | printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__); |
| 1572 | return -EINVAL; |
| 1573 | } |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1574 | |
Peter Huewe | 8504d63 | 2011-06-06 22:43:32 +0200 | [diff] [blame] | 1575 | return count; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 1576 | } |
| 1577 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 1578 | /* |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1579 | * Interrupt status |
| 1580 | */ |
| 1581 | static u32 num_interrupts[AB8500_MAX_NR_IRQS]; |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1582 | static u32 num_wake_interrupts[AB8500_MAX_NR_IRQS]; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1583 | static int num_interrupt_lines; |
| 1584 | |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1585 | bool __attribute__((weak)) suspend_test_wake_cause_interrupt_is_mine(u32 my_int) |
| 1586 | { |
| 1587 | return false; |
| 1588 | } |
| 1589 | |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1590 | void ab8500_debug_register_interrupt(int line) |
| 1591 | { |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1592 | if (line < num_interrupt_lines) { |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1593 | num_interrupts[line]++; |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1594 | if (suspend_test_wake_cause_interrupt_is_mine(IRQ_DB8500_AB8500)) |
| 1595 | num_wake_interrupts[line]++; |
| 1596 | } |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1597 | } |
| 1598 | |
| 1599 | static int ab8500_interrupts_print(struct seq_file *s, void *p) |
| 1600 | { |
| 1601 | int line; |
| 1602 | |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1603 | seq_printf(s, "name: number: number of: wake:\n"); |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1604 | |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 1605 | for (line = 0; line < num_interrupt_lines; line++) { |
| 1606 | struct irq_desc *desc = irq_to_desc(line + irq_first); |
| 1607 | struct irqaction *action = desc->action; |
| 1608 | |
| 1609 | seq_printf(s, "%3i: %6i %4i", line, |
| 1610 | num_interrupts[line], |
| 1611 | num_wake_interrupts[line]); |
| 1612 | |
| 1613 | if (desc && desc->name) |
| 1614 | seq_printf(s, "-%-8s", desc->name); |
| 1615 | if (action) { |
| 1616 | seq_printf(s, " %s", action->name); |
| 1617 | while ((action = action->next) != NULL) |
| 1618 | seq_printf(s, ", %s", action->name); |
| 1619 | } |
| 1620 | seq_putc(s, '\n'); |
| 1621 | } |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 1622 | |
| 1623 | return 0; |
| 1624 | } |
| 1625 | |
| 1626 | static int ab8500_interrupts_open(struct inode *inode, struct file *file) |
| 1627 | { |
| 1628 | return single_open(file, ab8500_interrupts_print, inode->i_private); |
| 1629 | } |
| 1630 | |
| 1631 | /* |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 1632 | * - HWREG DB8500 formated routines |
| 1633 | */ |
| 1634 | static int ab8500_hwreg_print(struct seq_file *s, void *d) |
| 1635 | { |
| 1636 | struct device *dev = s->private; |
| 1637 | int ret; |
| 1638 | u8 regvalue; |
| 1639 | |
| 1640 | ret = abx500_get_register_interruptible(dev, |
| 1641 | (u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, ®value); |
| 1642 | if (ret < 0) { |
| 1643 | dev_err(dev, "abx500_get_reg fail %d, %d\n", |
| 1644 | ret, __LINE__); |
| 1645 | return -EINVAL; |
| 1646 | } |
| 1647 | |
| 1648 | if (hwreg_cfg.shift >= 0) |
| 1649 | regvalue >>= hwreg_cfg.shift; |
| 1650 | else |
| 1651 | regvalue <<= -hwreg_cfg.shift; |
| 1652 | regvalue &= hwreg_cfg.mask; |
| 1653 | |
| 1654 | if (REG_FMT_DEC(&hwreg_cfg)) |
| 1655 | seq_printf(s, "%d\n", regvalue); |
| 1656 | else |
| 1657 | seq_printf(s, "0x%02X\n", regvalue); |
| 1658 | return 0; |
| 1659 | } |
| 1660 | |
| 1661 | static int ab8500_hwreg_open(struct inode *inode, struct file *file) |
| 1662 | { |
| 1663 | return single_open(file, ab8500_hwreg_print, inode->i_private); |
| 1664 | } |
| 1665 | |
Lee Jones | c7ebaee | 2013-02-26 14:03:33 +0000 | [diff] [blame] | 1666 | #define AB8500_SUPPLY_CONTROL_CONFIG_1 0x01 |
| 1667 | #define AB8500_SUPPLY_CONTROL_REG 0x00 |
| 1668 | #define AB8500_FIRST_SIM_REG 0x80 |
| 1669 | #define AB8500_LAST_SIM_REG 0x8B |
| 1670 | #define AB8505_LAST_SIM_REG 0x8C |
| 1671 | |
| 1672 | static int ab8500_print_modem_registers(struct seq_file *s, void *p) |
| 1673 | { |
| 1674 | struct device *dev = s->private; |
| 1675 | struct ab8500 *ab8500; |
| 1676 | int err; |
| 1677 | u8 value; |
| 1678 | u8 orig_value; |
| 1679 | u32 bank = AB8500_REGU_CTRL2; |
| 1680 | u32 last_sim_reg = AB8500_LAST_SIM_REG; |
| 1681 | u32 reg; |
| 1682 | |
| 1683 | ab8500 = dev_get_drvdata(dev->parent); |
| 1684 | dev_warn(dev, "WARNING! This operation can interfer with modem side\n" |
| 1685 | "and should only be done with care\n"); |
| 1686 | |
| 1687 | err = abx500_get_register_interruptible(dev, |
| 1688 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, &orig_value); |
| 1689 | if (err < 0) { |
| 1690 | dev_err(dev, "ab->read fail %d\n", err); |
| 1691 | return err; |
| 1692 | } |
| 1693 | /* Config 1 will allow APE side to read SIM registers */ |
| 1694 | err = abx500_set_register_interruptible(dev, |
| 1695 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, |
| 1696 | AB8500_SUPPLY_CONTROL_CONFIG_1); |
| 1697 | if (err < 0) { |
| 1698 | dev_err(dev, "ab->write fail %d\n", err); |
| 1699 | return err; |
| 1700 | } |
| 1701 | |
| 1702 | seq_printf(s, " bank 0x%02X:\n", bank); |
| 1703 | |
| 1704 | if (is_ab9540(ab8500) || is_ab8505(ab8500)) |
| 1705 | last_sim_reg = AB8505_LAST_SIM_REG; |
| 1706 | |
| 1707 | for (reg = AB8500_FIRST_SIM_REG; reg <= last_sim_reg; reg++) { |
| 1708 | err = abx500_get_register_interruptible(dev, |
| 1709 | bank, reg, &value); |
| 1710 | if (err < 0) { |
| 1711 | dev_err(dev, "ab->read fail %d\n", err); |
| 1712 | return err; |
| 1713 | } |
| 1714 | err = seq_printf(s, " [0x%02X/0x%02X]: 0x%02X\n", |
| 1715 | bank, reg, value); |
| 1716 | } |
| 1717 | err = abx500_set_register_interruptible(dev, |
| 1718 | AB8500_REGU_CTRL1, AB8500_SUPPLY_CONTROL_REG, orig_value); |
| 1719 | if (err < 0) { |
| 1720 | dev_err(dev, "ab->write fail %d\n", err); |
| 1721 | return err; |
| 1722 | } |
| 1723 | return 0; |
| 1724 | } |
| 1725 | |
| 1726 | static int ab8500_modem_open(struct inode *inode, struct file *file) |
| 1727 | { |
| 1728 | return single_open(file, ab8500_print_modem_registers, inode->i_private); |
| 1729 | } |
| 1730 | |
| 1731 | static const struct file_operations ab8500_modem_fops = { |
| 1732 | .open = ab8500_modem_open, |
| 1733 | .read = seq_read, |
| 1734 | .llseek = seq_lseek, |
| 1735 | .release = single_release, |
| 1736 | .owner = THIS_MODULE, |
| 1737 | }; |
| 1738 | |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1739 | static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p) |
| 1740 | { |
| 1741 | int bat_ctrl_raw; |
| 1742 | int bat_ctrl_convert; |
| 1743 | struct ab8500_gpadc *gpadc; |
| 1744 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1745 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1746 | bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL, |
| 1747 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1748 | bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1749 | BAT_CTRL, bat_ctrl_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1750 | |
| 1751 | return seq_printf(s, "%d,0x%X\n", |
| 1752 | bat_ctrl_convert, bat_ctrl_raw); |
| 1753 | } |
| 1754 | |
| 1755 | static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file) |
| 1756 | { |
| 1757 | return single_open(file, ab8500_gpadc_bat_ctrl_print, inode->i_private); |
| 1758 | } |
| 1759 | |
| 1760 | static const struct file_operations ab8500_gpadc_bat_ctrl_fops = { |
| 1761 | .open = ab8500_gpadc_bat_ctrl_open, |
| 1762 | .read = seq_read, |
| 1763 | .llseek = seq_lseek, |
| 1764 | .release = single_release, |
| 1765 | .owner = THIS_MODULE, |
| 1766 | }; |
| 1767 | |
| 1768 | static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p) |
| 1769 | { |
| 1770 | int btemp_ball_raw; |
| 1771 | int btemp_ball_convert; |
| 1772 | struct ab8500_gpadc *gpadc; |
| 1773 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1774 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1775 | btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL, |
| 1776 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1777 | btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1778 | btemp_ball_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1779 | |
| 1780 | return seq_printf(s, |
| 1781 | "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw); |
| 1782 | } |
| 1783 | |
| 1784 | static int ab8500_gpadc_btemp_ball_open(struct inode *inode, |
| 1785 | struct file *file) |
| 1786 | { |
| 1787 | return single_open(file, ab8500_gpadc_btemp_ball_print, inode->i_private); |
| 1788 | } |
| 1789 | |
| 1790 | static const struct file_operations ab8500_gpadc_btemp_ball_fops = { |
| 1791 | .open = ab8500_gpadc_btemp_ball_open, |
| 1792 | .read = seq_read, |
| 1793 | .llseek = seq_lseek, |
| 1794 | .release = single_release, |
| 1795 | .owner = THIS_MODULE, |
| 1796 | }; |
| 1797 | |
| 1798 | static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p) |
| 1799 | { |
| 1800 | int main_charger_v_raw; |
| 1801 | int main_charger_v_convert; |
| 1802 | struct ab8500_gpadc *gpadc; |
| 1803 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1804 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1805 | main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V, |
| 1806 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1807 | main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1808 | MAIN_CHARGER_V, main_charger_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1809 | |
| 1810 | return seq_printf(s, "%d,0x%X\n", |
| 1811 | main_charger_v_convert, main_charger_v_raw); |
| 1812 | } |
| 1813 | |
| 1814 | static int ab8500_gpadc_main_charger_v_open(struct inode *inode, |
| 1815 | struct file *file) |
| 1816 | { |
| 1817 | return single_open(file, ab8500_gpadc_main_charger_v_print, |
| 1818 | inode->i_private); |
| 1819 | } |
| 1820 | |
| 1821 | static const struct file_operations ab8500_gpadc_main_charger_v_fops = { |
| 1822 | .open = ab8500_gpadc_main_charger_v_open, |
| 1823 | .read = seq_read, |
| 1824 | .llseek = seq_lseek, |
| 1825 | .release = single_release, |
| 1826 | .owner = THIS_MODULE, |
| 1827 | }; |
| 1828 | |
| 1829 | static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p) |
| 1830 | { |
| 1831 | int acc_detect1_raw; |
| 1832 | int acc_detect1_convert; |
| 1833 | struct ab8500_gpadc *gpadc; |
| 1834 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1835 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1836 | acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1, |
| 1837 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1838 | acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1839 | acc_detect1_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1840 | |
| 1841 | return seq_printf(s, "%d,0x%X\n", |
| 1842 | acc_detect1_convert, acc_detect1_raw); |
| 1843 | } |
| 1844 | |
| 1845 | static int ab8500_gpadc_acc_detect1_open(struct inode *inode, |
| 1846 | struct file *file) |
| 1847 | { |
| 1848 | return single_open(file, ab8500_gpadc_acc_detect1_print, |
| 1849 | inode->i_private); |
| 1850 | } |
| 1851 | |
| 1852 | static const struct file_operations ab8500_gpadc_acc_detect1_fops = { |
| 1853 | .open = ab8500_gpadc_acc_detect1_open, |
| 1854 | .read = seq_read, |
| 1855 | .llseek = seq_lseek, |
| 1856 | .release = single_release, |
| 1857 | .owner = THIS_MODULE, |
| 1858 | }; |
| 1859 | |
| 1860 | static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p) |
| 1861 | { |
| 1862 | int acc_detect2_raw; |
| 1863 | int acc_detect2_convert; |
| 1864 | struct ab8500_gpadc *gpadc; |
| 1865 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1866 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1867 | acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2, |
| 1868 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1869 | acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1870 | ACC_DETECT2, acc_detect2_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1871 | |
| 1872 | return seq_printf(s, "%d,0x%X\n", |
| 1873 | acc_detect2_convert, acc_detect2_raw); |
| 1874 | } |
| 1875 | |
| 1876 | static int ab8500_gpadc_acc_detect2_open(struct inode *inode, |
| 1877 | struct file *file) |
| 1878 | { |
| 1879 | return single_open(file, ab8500_gpadc_acc_detect2_print, |
| 1880 | inode->i_private); |
| 1881 | } |
| 1882 | |
| 1883 | static const struct file_operations ab8500_gpadc_acc_detect2_fops = { |
| 1884 | .open = ab8500_gpadc_acc_detect2_open, |
| 1885 | .read = seq_read, |
| 1886 | .llseek = seq_lseek, |
| 1887 | .release = single_release, |
| 1888 | .owner = THIS_MODULE, |
| 1889 | }; |
| 1890 | |
| 1891 | static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p) |
| 1892 | { |
| 1893 | int aux1_raw; |
| 1894 | int aux1_convert; |
| 1895 | struct ab8500_gpadc *gpadc; |
| 1896 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1897 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1898 | aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1, |
| 1899 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1900 | aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1901 | aux1_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1902 | |
| 1903 | return seq_printf(s, "%d,0x%X\n", |
| 1904 | aux1_convert, aux1_raw); |
| 1905 | } |
| 1906 | |
| 1907 | static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file) |
| 1908 | { |
| 1909 | return single_open(file, ab8500_gpadc_aux1_print, inode->i_private); |
| 1910 | } |
| 1911 | |
| 1912 | static const struct file_operations ab8500_gpadc_aux1_fops = { |
| 1913 | .open = ab8500_gpadc_aux1_open, |
| 1914 | .read = seq_read, |
| 1915 | .llseek = seq_lseek, |
| 1916 | .release = single_release, |
| 1917 | .owner = THIS_MODULE, |
| 1918 | }; |
| 1919 | |
| 1920 | static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p) |
| 1921 | { |
| 1922 | int aux2_raw; |
| 1923 | int aux2_convert; |
| 1924 | struct ab8500_gpadc *gpadc; |
| 1925 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1926 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1927 | aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2, |
| 1928 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1929 | aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1930 | aux2_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1931 | |
| 1932 | return seq_printf(s, "%d,0x%X\n", |
| 1933 | aux2_convert, aux2_raw); |
| 1934 | } |
| 1935 | |
| 1936 | static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file) |
| 1937 | { |
| 1938 | return single_open(file, ab8500_gpadc_aux2_print, inode->i_private); |
| 1939 | } |
| 1940 | |
| 1941 | static const struct file_operations ab8500_gpadc_aux2_fops = { |
| 1942 | .open = ab8500_gpadc_aux2_open, |
| 1943 | .read = seq_read, |
| 1944 | .llseek = seq_lseek, |
| 1945 | .release = single_release, |
| 1946 | .owner = THIS_MODULE, |
| 1947 | }; |
| 1948 | |
| 1949 | static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p) |
| 1950 | { |
| 1951 | int main_bat_v_raw; |
| 1952 | int main_bat_v_convert; |
| 1953 | struct ab8500_gpadc *gpadc; |
| 1954 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1955 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1956 | main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V, |
| 1957 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1958 | 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] | 1959 | main_bat_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1960 | |
| 1961 | return seq_printf(s, "%d,0x%X\n", |
| 1962 | main_bat_v_convert, main_bat_v_raw); |
| 1963 | } |
| 1964 | |
| 1965 | static int ab8500_gpadc_main_bat_v_open(struct inode *inode, |
| 1966 | struct file *file) |
| 1967 | { |
| 1968 | return single_open(file, ab8500_gpadc_main_bat_v_print, inode->i_private); |
| 1969 | } |
| 1970 | |
| 1971 | static const struct file_operations ab8500_gpadc_main_bat_v_fops = { |
| 1972 | .open = ab8500_gpadc_main_bat_v_open, |
| 1973 | .read = seq_read, |
| 1974 | .llseek = seq_lseek, |
| 1975 | .release = single_release, |
| 1976 | .owner = THIS_MODULE, |
| 1977 | }; |
| 1978 | |
| 1979 | static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p) |
| 1980 | { |
| 1981 | int vbus_v_raw; |
| 1982 | int vbus_v_convert; |
| 1983 | struct ab8500_gpadc *gpadc; |
| 1984 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 1985 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1986 | vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V, |
| 1987 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1988 | vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 1989 | vbus_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 1990 | |
| 1991 | return seq_printf(s, "%d,0x%X\n", |
| 1992 | vbus_v_convert, vbus_v_raw); |
| 1993 | } |
| 1994 | |
| 1995 | static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file) |
| 1996 | { |
| 1997 | return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private); |
| 1998 | } |
| 1999 | |
| 2000 | static const struct file_operations ab8500_gpadc_vbus_v_fops = { |
| 2001 | .open = ab8500_gpadc_vbus_v_open, |
| 2002 | .read = seq_read, |
| 2003 | .llseek = seq_lseek, |
| 2004 | .release = single_release, |
| 2005 | .owner = THIS_MODULE, |
| 2006 | }; |
| 2007 | |
| 2008 | static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p) |
| 2009 | { |
| 2010 | int main_charger_c_raw; |
| 2011 | int main_charger_c_convert; |
| 2012 | struct ab8500_gpadc *gpadc; |
| 2013 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2014 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2015 | main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C, |
| 2016 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2017 | main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2018 | MAIN_CHARGER_C, main_charger_c_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2019 | |
| 2020 | return seq_printf(s, "%d,0x%X\n", |
| 2021 | main_charger_c_convert, main_charger_c_raw); |
| 2022 | } |
| 2023 | |
| 2024 | static int ab8500_gpadc_main_charger_c_open(struct inode *inode, |
| 2025 | struct file *file) |
| 2026 | { |
| 2027 | return single_open(file, ab8500_gpadc_main_charger_c_print, |
| 2028 | inode->i_private); |
| 2029 | } |
| 2030 | |
| 2031 | static const struct file_operations ab8500_gpadc_main_charger_c_fops = { |
| 2032 | .open = ab8500_gpadc_main_charger_c_open, |
| 2033 | .read = seq_read, |
| 2034 | .llseek = seq_lseek, |
| 2035 | .release = single_release, |
| 2036 | .owner = THIS_MODULE, |
| 2037 | }; |
| 2038 | |
| 2039 | static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p) |
| 2040 | { |
| 2041 | int usb_charger_c_raw; |
| 2042 | int usb_charger_c_convert; |
| 2043 | struct ab8500_gpadc *gpadc; |
| 2044 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2045 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2046 | usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C, |
| 2047 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2048 | usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2049 | USB_CHARGER_C, usb_charger_c_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2050 | |
| 2051 | return seq_printf(s, "%d,0x%X\n", |
| 2052 | usb_charger_c_convert, usb_charger_c_raw); |
| 2053 | } |
| 2054 | |
| 2055 | static int ab8500_gpadc_usb_charger_c_open(struct inode *inode, |
| 2056 | struct file *file) |
| 2057 | { |
| 2058 | return single_open(file, ab8500_gpadc_usb_charger_c_print, |
| 2059 | inode->i_private); |
| 2060 | } |
| 2061 | |
| 2062 | static const struct file_operations ab8500_gpadc_usb_charger_c_fops = { |
| 2063 | .open = ab8500_gpadc_usb_charger_c_open, |
| 2064 | .read = seq_read, |
| 2065 | .llseek = seq_lseek, |
| 2066 | .release = single_release, |
| 2067 | .owner = THIS_MODULE, |
| 2068 | }; |
| 2069 | |
| 2070 | static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p) |
| 2071 | { |
| 2072 | int bk_bat_v_raw; |
| 2073 | int bk_bat_v_convert; |
| 2074 | struct ab8500_gpadc *gpadc; |
| 2075 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2076 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2077 | bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V, |
| 2078 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2079 | bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2080 | BK_BAT_V, bk_bat_v_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2081 | |
| 2082 | return seq_printf(s, "%d,0x%X\n", |
| 2083 | bk_bat_v_convert, bk_bat_v_raw); |
| 2084 | } |
| 2085 | |
| 2086 | static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file) |
| 2087 | { |
| 2088 | return single_open(file, ab8500_gpadc_bk_bat_v_print, inode->i_private); |
| 2089 | } |
| 2090 | |
| 2091 | static const struct file_operations ab8500_gpadc_bk_bat_v_fops = { |
| 2092 | .open = ab8500_gpadc_bk_bat_v_open, |
| 2093 | .read = seq_read, |
| 2094 | .llseek = seq_lseek, |
| 2095 | .release = single_release, |
| 2096 | .owner = THIS_MODULE, |
| 2097 | }; |
| 2098 | |
| 2099 | static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p) |
| 2100 | { |
| 2101 | int die_temp_raw; |
| 2102 | int die_temp_convert; |
| 2103 | struct ab8500_gpadc *gpadc; |
| 2104 | |
Philippe Langlais | 8908c04 | 2012-04-18 15:52:59 +0200 | [diff] [blame] | 2105 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2106 | die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP, |
| 2107 | avg_sample, trig_edge, trig_timer, conv_type); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2108 | die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP, |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2109 | die_temp_raw); |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2110 | |
| 2111 | return seq_printf(s, "%d,0x%X\n", |
| 2112 | die_temp_convert, die_temp_raw); |
| 2113 | } |
| 2114 | |
| 2115 | static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file) |
| 2116 | { |
| 2117 | return single_open(file, ab8500_gpadc_die_temp_print, inode->i_private); |
| 2118 | } |
| 2119 | |
| 2120 | static const struct file_operations ab8500_gpadc_die_temp_fops = { |
| 2121 | .open = ab8500_gpadc_die_temp_open, |
| 2122 | .read = seq_read, |
| 2123 | .llseek = seq_lseek, |
| 2124 | .release = single_release, |
| 2125 | .owner = THIS_MODULE, |
| 2126 | }; |
| 2127 | |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 2128 | static int ab8500_gpadc_usb_id_print(struct seq_file *s, void *p) |
| 2129 | { |
| 2130 | int usb_id_raw; |
| 2131 | int usb_id_convert; |
| 2132 | struct ab8500_gpadc *gpadc; |
| 2133 | |
| 2134 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2135 | usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID, |
| 2136 | avg_sample, trig_edge, trig_timer, conv_type); |
| 2137 | usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID, |
| 2138 | usb_id_raw); |
| 2139 | |
| 2140 | return seq_printf(s, "%d,0x%X\n", |
| 2141 | usb_id_convert, usb_id_raw); |
| 2142 | } |
| 2143 | |
| 2144 | static int ab8500_gpadc_usb_id_open(struct inode *inode, struct file *file) |
| 2145 | { |
| 2146 | return single_open(file, ab8500_gpadc_usb_id_print, inode->i_private); |
| 2147 | } |
| 2148 | |
| 2149 | static const struct file_operations ab8500_gpadc_usb_id_fops = { |
| 2150 | .open = ab8500_gpadc_usb_id_open, |
| 2151 | .read = seq_read, |
| 2152 | .llseek = seq_lseek, |
| 2153 | .release = single_release, |
| 2154 | .owner = THIS_MODULE, |
| 2155 | }; |
| 2156 | |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 2157 | static int ab8540_gpadc_xtal_temp_print(struct seq_file *s, void *p) |
| 2158 | { |
| 2159 | int xtal_temp_raw; |
| 2160 | int xtal_temp_convert; |
| 2161 | struct ab8500_gpadc *gpadc; |
| 2162 | |
| 2163 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2164 | xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP, |
| 2165 | avg_sample, trig_edge, trig_timer, conv_type); |
| 2166 | xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP, |
| 2167 | xtal_temp_raw); |
| 2168 | |
| 2169 | return seq_printf(s, "%d,0x%X\n", |
| 2170 | xtal_temp_convert, xtal_temp_raw); |
| 2171 | } |
| 2172 | |
| 2173 | static int ab8540_gpadc_xtal_temp_open(struct inode *inode, struct file *file) |
| 2174 | { |
| 2175 | return single_open(file, ab8540_gpadc_xtal_temp_print, |
| 2176 | inode->i_private); |
| 2177 | } |
| 2178 | |
| 2179 | static const struct file_operations ab8540_gpadc_xtal_temp_fops = { |
| 2180 | .open = ab8540_gpadc_xtal_temp_open, |
| 2181 | .read = seq_read, |
| 2182 | .llseek = seq_lseek, |
| 2183 | .release = single_release, |
| 2184 | .owner = THIS_MODULE, |
| 2185 | }; |
| 2186 | |
| 2187 | static int ab8540_gpadc_vbat_true_meas_print(struct seq_file *s, void *p) |
| 2188 | { |
| 2189 | int vbat_true_meas_raw; |
| 2190 | int vbat_true_meas_convert; |
| 2191 | struct ab8500_gpadc *gpadc; |
| 2192 | |
| 2193 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2194 | vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS, |
| 2195 | avg_sample, trig_edge, trig_timer, conv_type); |
| 2196 | vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS, |
| 2197 | vbat_true_meas_raw); |
| 2198 | |
| 2199 | return seq_printf(s, "%d,0x%X\n", |
| 2200 | vbat_true_meas_convert, vbat_true_meas_raw); |
| 2201 | } |
| 2202 | |
| 2203 | static int ab8540_gpadc_vbat_true_meas_open(struct inode *inode, |
| 2204 | struct file *file) |
| 2205 | { |
| 2206 | return single_open(file, ab8540_gpadc_vbat_true_meas_print, |
| 2207 | inode->i_private); |
| 2208 | } |
| 2209 | |
| 2210 | static const struct file_operations ab8540_gpadc_vbat_true_meas_fops = { |
| 2211 | .open = ab8540_gpadc_vbat_true_meas_open, |
| 2212 | .read = seq_read, |
| 2213 | .llseek = seq_lseek, |
| 2214 | .release = single_release, |
| 2215 | .owner = THIS_MODULE, |
| 2216 | }; |
| 2217 | |
| 2218 | static int ab8540_gpadc_bat_ctrl_and_ibat_print(struct seq_file *s, void *p) |
| 2219 | { |
| 2220 | int bat_ctrl_raw; |
| 2221 | int bat_ctrl_convert; |
| 2222 | int ibat_raw; |
| 2223 | int ibat_convert; |
| 2224 | struct ab8500_gpadc *gpadc; |
| 2225 | |
| 2226 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2227 | bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT, |
| 2228 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); |
| 2229 | |
| 2230 | bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL, |
| 2231 | bat_ctrl_raw); |
| 2232 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2233 | ibat_raw); |
| 2234 | |
| 2235 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
| 2236 | bat_ctrl_convert, bat_ctrl_raw, |
| 2237 | ibat_convert, ibat_raw); |
| 2238 | } |
| 2239 | |
| 2240 | static int ab8540_gpadc_bat_ctrl_and_ibat_open(struct inode *inode, |
| 2241 | struct file *file) |
| 2242 | { |
| 2243 | return single_open(file, ab8540_gpadc_bat_ctrl_and_ibat_print, |
| 2244 | inode->i_private); |
| 2245 | } |
| 2246 | |
| 2247 | static const struct file_operations ab8540_gpadc_bat_ctrl_and_ibat_fops = { |
| 2248 | .open = ab8540_gpadc_bat_ctrl_and_ibat_open, |
| 2249 | .read = seq_read, |
| 2250 | .llseek = seq_lseek, |
| 2251 | .release = single_release, |
| 2252 | .owner = THIS_MODULE, |
| 2253 | }; |
| 2254 | |
| 2255 | static int ab8540_gpadc_vbat_meas_and_ibat_print(struct seq_file *s, void *p) |
| 2256 | { |
| 2257 | int vbat_meas_raw; |
| 2258 | int vbat_meas_convert; |
| 2259 | int ibat_raw; |
| 2260 | int ibat_convert; |
| 2261 | struct ab8500_gpadc *gpadc; |
| 2262 | |
| 2263 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2264 | vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT, |
| 2265 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); |
| 2266 | vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V, |
| 2267 | vbat_meas_raw); |
| 2268 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2269 | ibat_raw); |
| 2270 | |
| 2271 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
| 2272 | vbat_meas_convert, vbat_meas_raw, |
| 2273 | ibat_convert, ibat_raw); |
| 2274 | } |
| 2275 | |
| 2276 | static int ab8540_gpadc_vbat_meas_and_ibat_open(struct inode *inode, |
| 2277 | struct file *file) |
| 2278 | { |
| 2279 | return single_open(file, ab8540_gpadc_vbat_meas_and_ibat_print, |
| 2280 | inode->i_private); |
| 2281 | } |
| 2282 | |
| 2283 | static const struct file_operations ab8540_gpadc_vbat_meas_and_ibat_fops = { |
| 2284 | .open = ab8540_gpadc_vbat_meas_and_ibat_open, |
| 2285 | .read = seq_read, |
| 2286 | .llseek = seq_lseek, |
| 2287 | .release = single_release, |
| 2288 | .owner = THIS_MODULE, |
| 2289 | }; |
| 2290 | |
| 2291 | static int ab8540_gpadc_vbat_true_meas_and_ibat_print(struct seq_file *s, void *p) |
| 2292 | { |
| 2293 | int vbat_true_meas_raw; |
| 2294 | int vbat_true_meas_convert; |
| 2295 | int ibat_raw; |
| 2296 | int ibat_convert; |
| 2297 | struct ab8500_gpadc *gpadc; |
| 2298 | |
| 2299 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2300 | vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc, |
| 2301 | VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge, |
| 2302 | trig_timer, conv_type, &ibat_raw); |
| 2303 | vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, |
| 2304 | VBAT_TRUE_MEAS, vbat_true_meas_raw); |
| 2305 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2306 | ibat_raw); |
| 2307 | |
| 2308 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
| 2309 | vbat_true_meas_convert, vbat_true_meas_raw, |
| 2310 | ibat_convert, ibat_raw); |
| 2311 | } |
| 2312 | |
| 2313 | static int ab8540_gpadc_vbat_true_meas_and_ibat_open(struct inode *inode, |
| 2314 | struct file *file) |
| 2315 | { |
| 2316 | return single_open(file, ab8540_gpadc_vbat_true_meas_and_ibat_print, |
| 2317 | inode->i_private); |
| 2318 | } |
| 2319 | |
| 2320 | static const struct file_operations ab8540_gpadc_vbat_true_meas_and_ibat_fops = { |
| 2321 | .open = ab8540_gpadc_vbat_true_meas_and_ibat_open, |
| 2322 | .read = seq_read, |
| 2323 | .llseek = seq_lseek, |
| 2324 | .release = single_release, |
| 2325 | .owner = THIS_MODULE, |
| 2326 | }; |
| 2327 | |
| 2328 | static int ab8540_gpadc_bat_temp_and_ibat_print(struct seq_file *s, void *p) |
| 2329 | { |
| 2330 | int bat_temp_raw; |
| 2331 | int bat_temp_convert; |
| 2332 | int ibat_raw; |
| 2333 | int ibat_convert; |
| 2334 | struct ab8500_gpadc *gpadc; |
| 2335 | |
| 2336 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2337 | bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT, |
| 2338 | avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw); |
| 2339 | bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL, |
| 2340 | bat_temp_raw); |
| 2341 | ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL, |
| 2342 | ibat_raw); |
| 2343 | |
| 2344 | return seq_printf(s, "%d,0x%X\n" "%d,0x%X\n", |
| 2345 | bat_temp_convert, bat_temp_raw, |
| 2346 | ibat_convert, ibat_raw); |
| 2347 | } |
| 2348 | |
| 2349 | static int ab8540_gpadc_bat_temp_and_ibat_open(struct inode *inode, |
| 2350 | struct file *file) |
| 2351 | { |
| 2352 | return single_open(file, ab8540_gpadc_bat_temp_and_ibat_print, |
| 2353 | inode->i_private); |
| 2354 | } |
| 2355 | |
| 2356 | static const struct file_operations ab8540_gpadc_bat_temp_and_ibat_fops = { |
| 2357 | .open = ab8540_gpadc_bat_temp_and_ibat_open, |
| 2358 | .read = seq_read, |
| 2359 | .llseek = seq_lseek, |
| 2360 | .release = single_release, |
| 2361 | .owner = THIS_MODULE, |
| 2362 | }; |
| 2363 | |
| 2364 | static int ab8540_gpadc_otp_cal_print(struct seq_file *s, void *p) |
| 2365 | { |
| 2366 | struct ab8500_gpadc *gpadc; |
| 2367 | u16 vmain_l, vmain_h, btemp_l, btemp_h; |
| 2368 | u16 vbat_l, vbat_h, ibat_l, ibat_h; |
| 2369 | |
| 2370 | gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
| 2371 | ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h, |
| 2372 | &vbat_l, &vbat_h, &ibat_l, &ibat_h); |
| 2373 | return seq_printf(s, "VMAIN_L:0x%X\n" |
| 2374 | "VMAIN_H:0x%X\n" |
| 2375 | "BTEMP_L:0x%X\n" |
| 2376 | "BTEMP_H:0x%X\n" |
| 2377 | "VBAT_L:0x%X\n" |
| 2378 | "VBAT_H:0x%X\n" |
| 2379 | "IBAT_L:0x%X\n" |
| 2380 | "IBAT_H:0x%X\n" |
| 2381 | , |
| 2382 | vmain_l, |
| 2383 | vmain_h, |
| 2384 | btemp_l, |
| 2385 | btemp_h, |
| 2386 | vbat_l, |
| 2387 | vbat_h, |
| 2388 | ibat_l, |
| 2389 | ibat_h); |
| 2390 | } |
| 2391 | |
| 2392 | static int ab8540_gpadc_otp_cal_open(struct inode *inode, struct file *file) |
| 2393 | { |
| 2394 | return single_open(file, ab8540_gpadc_otp_cal_print, inode->i_private); |
| 2395 | } |
| 2396 | |
| 2397 | static const struct file_operations ab8540_gpadc_otp_calib_fops = { |
| 2398 | .open = ab8540_gpadc_otp_cal_open, |
| 2399 | .read = seq_read, |
| 2400 | .llseek = seq_lseek, |
| 2401 | .release = single_release, |
| 2402 | .owner = THIS_MODULE, |
| 2403 | }; |
| 2404 | |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 2405 | static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p) |
| 2406 | { |
| 2407 | return seq_printf(s, "%d\n", avg_sample); |
| 2408 | } |
| 2409 | |
| 2410 | static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file) |
| 2411 | { |
| 2412 | return single_open(file, ab8500_gpadc_avg_sample_print, |
| 2413 | inode->i_private); |
| 2414 | } |
| 2415 | |
| 2416 | static ssize_t ab8500_gpadc_avg_sample_write(struct file *file, |
| 2417 | const char __user *user_buf, |
| 2418 | size_t count, loff_t *ppos) |
| 2419 | { |
| 2420 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2421 | char buf[32]; |
| 2422 | int buf_size; |
| 2423 | unsigned long user_avg_sample; |
| 2424 | int err; |
| 2425 | |
| 2426 | /* Get userspace string and assure termination */ |
| 2427 | buf_size = min(count, (sizeof(buf) - 1)); |
| 2428 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2429 | return -EFAULT; |
| 2430 | buf[buf_size] = 0; |
| 2431 | |
| 2432 | err = strict_strtoul(buf, 0, &user_avg_sample); |
| 2433 | if (err) |
| 2434 | return -EINVAL; |
| 2435 | if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4) |
| 2436 | || (user_avg_sample == SAMPLE_8) |
| 2437 | || (user_avg_sample == SAMPLE_16)) { |
| 2438 | avg_sample = (u8) user_avg_sample; |
| 2439 | } else { |
| 2440 | dev_err(dev, "debugfs error input: " |
| 2441 | "should be egal to 1, 4, 8 or 16\n"); |
| 2442 | return -EINVAL; |
| 2443 | } |
| 2444 | return buf_size; |
| 2445 | } |
| 2446 | |
| 2447 | static const struct file_operations ab8500_gpadc_avg_sample_fops = { |
| 2448 | .open = ab8500_gpadc_avg_sample_open, |
| 2449 | .read = seq_read, |
| 2450 | .write = ab8500_gpadc_avg_sample_write, |
| 2451 | .llseek = seq_lseek, |
| 2452 | .release = single_release, |
| 2453 | .owner = THIS_MODULE, |
| 2454 | }; |
| 2455 | |
| 2456 | static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p) |
| 2457 | { |
| 2458 | return seq_printf(s, "%d\n", trig_edge); |
| 2459 | } |
| 2460 | |
| 2461 | static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file) |
| 2462 | { |
| 2463 | return single_open(file, ab8500_gpadc_trig_edge_print, |
| 2464 | inode->i_private); |
| 2465 | } |
| 2466 | |
| 2467 | static ssize_t ab8500_gpadc_trig_edge_write(struct file *file, |
| 2468 | const char __user *user_buf, |
| 2469 | size_t count, loff_t *ppos) |
| 2470 | { |
| 2471 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2472 | char buf[32]; |
| 2473 | int buf_size; |
| 2474 | unsigned long user_trig_edge; |
| 2475 | int err; |
| 2476 | |
| 2477 | /* Get userspace string and assure termination */ |
| 2478 | buf_size = min(count, (sizeof(buf) - 1)); |
| 2479 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2480 | return -EFAULT; |
| 2481 | buf[buf_size] = 0; |
| 2482 | |
| 2483 | err = strict_strtoul(buf, 0, &user_trig_edge); |
| 2484 | if (err) |
| 2485 | return -EINVAL; |
| 2486 | if ((user_trig_edge == RISING_EDGE) |
| 2487 | || (user_trig_edge == FALLING_EDGE)) { |
| 2488 | trig_edge = (u8) user_trig_edge; |
| 2489 | } else { |
| 2490 | dev_err(dev, "Wrong input:\n" |
| 2491 | "Enter 0. Rising edge\n" |
| 2492 | "Enter 1. Falling edge\n"); |
| 2493 | return -EINVAL; |
| 2494 | } |
| 2495 | return buf_size; |
| 2496 | } |
| 2497 | |
| 2498 | static const struct file_operations ab8500_gpadc_trig_edge_fops = { |
| 2499 | .open = ab8500_gpadc_trig_edge_open, |
| 2500 | .read = seq_read, |
| 2501 | .write = ab8500_gpadc_trig_edge_write, |
| 2502 | .llseek = seq_lseek, |
| 2503 | .release = single_release, |
| 2504 | .owner = THIS_MODULE, |
| 2505 | }; |
| 2506 | |
| 2507 | static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p) |
| 2508 | { |
| 2509 | return seq_printf(s, "%d\n", trig_timer); |
| 2510 | } |
| 2511 | |
| 2512 | static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file) |
| 2513 | { |
| 2514 | return single_open(file, ab8500_gpadc_trig_timer_print, |
| 2515 | inode->i_private); |
| 2516 | } |
| 2517 | |
| 2518 | static ssize_t ab8500_gpadc_trig_timer_write(struct file *file, |
| 2519 | const char __user *user_buf, |
| 2520 | size_t count, loff_t *ppos) |
| 2521 | { |
| 2522 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2523 | char buf[32]; |
| 2524 | int buf_size; |
| 2525 | unsigned long user_trig_timer; |
| 2526 | int err; |
| 2527 | |
| 2528 | /* Get userspace string and assure termination */ |
| 2529 | buf_size = min(count, (sizeof(buf) - 1)); |
| 2530 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2531 | return -EFAULT; |
| 2532 | buf[buf_size] = 0; |
| 2533 | |
| 2534 | err = strict_strtoul(buf, 0, &user_trig_timer); |
| 2535 | if (err) |
| 2536 | return -EINVAL; |
| 2537 | if ((user_trig_timer >= 0) && (user_trig_timer <= 255)) { |
| 2538 | trig_timer = (u8) user_trig_timer; |
| 2539 | } else { |
| 2540 | dev_err(dev, "debugfs error input: " |
| 2541 | "should be beetween 0 to 255\n"); |
| 2542 | return -EINVAL; |
| 2543 | } |
| 2544 | return buf_size; |
| 2545 | } |
| 2546 | |
| 2547 | static const struct file_operations ab8500_gpadc_trig_timer_fops = { |
| 2548 | .open = ab8500_gpadc_trig_timer_open, |
| 2549 | .read = seq_read, |
| 2550 | .write = ab8500_gpadc_trig_timer_write, |
| 2551 | .llseek = seq_lseek, |
| 2552 | .release = single_release, |
| 2553 | .owner = THIS_MODULE, |
| 2554 | }; |
| 2555 | |
| 2556 | static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p) |
| 2557 | { |
| 2558 | return seq_printf(s, "%d\n", conv_type); |
| 2559 | } |
| 2560 | |
| 2561 | static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file) |
| 2562 | { |
| 2563 | return single_open(file, ab8500_gpadc_conv_type_print, |
| 2564 | inode->i_private); |
| 2565 | } |
| 2566 | |
| 2567 | static ssize_t ab8500_gpadc_conv_type_write(struct file *file, |
| 2568 | const char __user *user_buf, |
| 2569 | size_t count, loff_t *ppos) |
| 2570 | { |
| 2571 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2572 | char buf[32]; |
| 2573 | int buf_size; |
| 2574 | unsigned long user_conv_type; |
| 2575 | int err; |
| 2576 | |
| 2577 | /* Get userspace string and assure termination */ |
| 2578 | buf_size = min(count, (sizeof(buf) - 1)); |
| 2579 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2580 | return -EFAULT; |
| 2581 | buf[buf_size] = 0; |
| 2582 | |
| 2583 | err = strict_strtoul(buf, 0, &user_conv_type); |
| 2584 | if (err) |
| 2585 | return -EINVAL; |
| 2586 | if ((user_conv_type == ADC_SW) |
| 2587 | || (user_conv_type == ADC_HW)) { |
| 2588 | conv_type = (u8) user_conv_type; |
| 2589 | } else { |
| 2590 | dev_err(dev, "Wrong input:\n" |
| 2591 | "Enter 0. ADC SW conversion\n" |
| 2592 | "Enter 1. ADC HW conversion\n"); |
| 2593 | return -EINVAL; |
| 2594 | } |
| 2595 | return buf_size; |
| 2596 | } |
| 2597 | |
| 2598 | static const struct file_operations ab8500_gpadc_conv_type_fops = { |
| 2599 | .open = ab8500_gpadc_conv_type_open, |
| 2600 | .read = seq_read, |
| 2601 | .write = ab8500_gpadc_conv_type_write, |
| 2602 | .llseek = seq_lseek, |
| 2603 | .release = single_release, |
| 2604 | .owner = THIS_MODULE, |
| 2605 | }; |
| 2606 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2607 | /* |
| 2608 | * return length of an ASCII numerical value, 0 is string is not a |
| 2609 | * numerical value. |
| 2610 | * string shall start at value 1st char. |
| 2611 | * string can be tailed with \0 or space or newline chars only. |
| 2612 | * value can be decimal or hexadecimal (prefixed 0x or 0X). |
| 2613 | */ |
| 2614 | static int strval_len(char *b) |
| 2615 | { |
| 2616 | char *s = b; |
| 2617 | if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) { |
| 2618 | s += 2; |
| 2619 | for (; *s && (*s != ' ') && (*s != '\n'); s++) { |
| 2620 | if (!isxdigit(*s)) |
| 2621 | return 0; |
| 2622 | } |
| 2623 | } else { |
| 2624 | if (*s == '-') |
| 2625 | s++; |
| 2626 | for (; *s && (*s != ' ') && (*s != '\n'); s++) { |
| 2627 | if (!isdigit(*s)) |
| 2628 | return 0; |
| 2629 | } |
| 2630 | } |
| 2631 | return (int) (s-b); |
| 2632 | } |
| 2633 | |
| 2634 | /* |
| 2635 | * parse hwreg input data. |
| 2636 | * update global hwreg_cfg only if input data syntax is ok. |
| 2637 | */ |
| 2638 | static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg, |
| 2639 | struct device *dev) |
| 2640 | { |
| 2641 | uint write, val = 0; |
| 2642 | u8 regvalue; |
| 2643 | int ret; |
| 2644 | struct hwreg_cfg loc = { |
| 2645 | .bank = 0, /* default: invalid phys addr */ |
| 2646 | .addr = 0, /* default: invalid phys addr */ |
| 2647 | .fmt = 0, /* default: 32bit access, hex output */ |
| 2648 | .mask = 0xFFFFFFFF, /* default: no mask */ |
| 2649 | .shift = 0, /* default: no bit shift */ |
| 2650 | }; |
| 2651 | |
| 2652 | /* read or write ? */ |
| 2653 | if (!strncmp(b, "read ", 5)) { |
| 2654 | write = 0; |
| 2655 | b += 5; |
| 2656 | } else if (!strncmp(b, "write ", 6)) { |
| 2657 | write = 1; |
| 2658 | b += 6; |
| 2659 | } else |
| 2660 | return -EINVAL; |
| 2661 | |
| 2662 | /* OPTIONS -l|-w|-b -s -m -o */ |
| 2663 | while ((*b == ' ') || (*b == '-')) { |
| 2664 | if (*(b-1) != ' ') { |
| 2665 | b++; |
| 2666 | continue; |
| 2667 | } |
| 2668 | if ((!strncmp(b, "-d ", 3)) || |
| 2669 | (!strncmp(b, "-dec ", 5))) { |
| 2670 | b += (*(b+2) == ' ') ? 3 : 5; |
| 2671 | loc.fmt |= (1<<0); |
| 2672 | } else if ((!strncmp(b, "-h ", 3)) || |
| 2673 | (!strncmp(b, "-hex ", 5))) { |
| 2674 | b += (*(b+2) == ' ') ? 3 : 5; |
| 2675 | loc.fmt &= ~(1<<0); |
| 2676 | } else if ((!strncmp(b, "-m ", 3)) || |
| 2677 | (!strncmp(b, "-mask ", 6))) { |
| 2678 | b += (*(b+2) == ' ') ? 3 : 6; |
| 2679 | if (strval_len(b) == 0) |
| 2680 | return -EINVAL; |
| 2681 | loc.mask = simple_strtoul(b, &b, 0); |
| 2682 | } else if ((!strncmp(b, "-s ", 3)) || |
| 2683 | (!strncmp(b, "-shift ", 7))) { |
| 2684 | b += (*(b+2) == ' ') ? 3 : 7; |
| 2685 | if (strval_len(b) == 0) |
| 2686 | return -EINVAL; |
| 2687 | loc.shift = simple_strtol(b, &b, 0); |
| 2688 | } else { |
| 2689 | return -EINVAL; |
| 2690 | } |
| 2691 | } |
| 2692 | /* get arg BANK and ADDRESS */ |
| 2693 | if (strval_len(b) == 0) |
| 2694 | return -EINVAL; |
| 2695 | loc.bank = simple_strtoul(b, &b, 0); |
| 2696 | while (*b == ' ') |
| 2697 | b++; |
| 2698 | if (strval_len(b) == 0) |
| 2699 | return -EINVAL; |
| 2700 | loc.addr = simple_strtoul(b, &b, 0); |
| 2701 | |
| 2702 | if (write) { |
| 2703 | while (*b == ' ') |
| 2704 | b++; |
| 2705 | if (strval_len(b) == 0) |
| 2706 | return -EINVAL; |
| 2707 | val = simple_strtoul(b, &b, 0); |
| 2708 | } |
| 2709 | |
| 2710 | /* args are ok, update target cfg (mainly for read) */ |
| 2711 | *cfg = loc; |
| 2712 | |
| 2713 | #ifdef ABB_HWREG_DEBUG |
| 2714 | pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d" |
| 2715 | "value=0x%X\n", (write) ? "write" : "read", |
| 2716 | REG_FMT_DEC(cfg) ? "decimal" : "hexa", |
| 2717 | cfg->addr, cfg->mask, cfg->shift, val); |
| 2718 | #endif |
| 2719 | |
| 2720 | if (!write) |
| 2721 | return 0; |
| 2722 | |
| 2723 | ret = abx500_get_register_interruptible(dev, |
| 2724 | (u8)cfg->bank, (u8)cfg->addr, ®value); |
| 2725 | if (ret < 0) { |
| 2726 | dev_err(dev, "abx500_get_reg fail %d, %d\n", |
| 2727 | ret, __LINE__); |
| 2728 | return -EINVAL; |
| 2729 | } |
| 2730 | |
| 2731 | if (cfg->shift >= 0) { |
| 2732 | regvalue &= ~(cfg->mask << (cfg->shift)); |
| 2733 | val = (val & cfg->mask) << (cfg->shift); |
| 2734 | } else { |
| 2735 | regvalue &= ~(cfg->mask >> (-cfg->shift)); |
| 2736 | val = (val & cfg->mask) >> (-cfg->shift); |
| 2737 | } |
| 2738 | val = val | regvalue; |
| 2739 | |
| 2740 | ret = abx500_set_register_interruptible(dev, |
| 2741 | (u8)cfg->bank, (u8)cfg->addr, (u8)val); |
| 2742 | if (ret < 0) { |
| 2743 | pr_err("abx500_set_reg failed %d, %d", ret, __LINE__); |
| 2744 | return -EINVAL; |
| 2745 | } |
| 2746 | |
| 2747 | return 0; |
| 2748 | } |
| 2749 | |
| 2750 | static ssize_t ab8500_hwreg_write(struct file *file, |
| 2751 | const char __user *user_buf, size_t count, loff_t *ppos) |
| 2752 | { |
| 2753 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2754 | char buf[128]; |
| 2755 | int buf_size, ret; |
| 2756 | |
| 2757 | /* Get userspace string and assure termination */ |
| 2758 | buf_size = min(count, (sizeof(buf)-1)); |
| 2759 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2760 | return -EFAULT; |
| 2761 | buf[buf_size] = 0; |
| 2762 | |
| 2763 | /* get args and process */ |
| 2764 | ret = hwreg_common_write(buf, &hwreg_cfg, dev); |
| 2765 | return (ret) ? ret : buf_size; |
| 2766 | } |
| 2767 | |
| 2768 | /* |
| 2769 | * - irq subscribe/unsubscribe stuff |
| 2770 | */ |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2771 | static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p) |
| 2772 | { |
| 2773 | seq_printf(s, "%d\n", irq_first); |
| 2774 | |
| 2775 | return 0; |
| 2776 | } |
| 2777 | |
| 2778 | static int ab8500_subscribe_unsubscribe_open(struct inode *inode, |
| 2779 | struct file *file) |
| 2780 | { |
| 2781 | return single_open(file, ab8500_subscribe_unsubscribe_print, |
| 2782 | inode->i_private); |
| 2783 | } |
| 2784 | |
| 2785 | /* |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2786 | * Userspace should use poll() on this file. When an event occur |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2787 | * the blocking poll will be released. |
| 2788 | */ |
| 2789 | static ssize_t show_irq(struct device *dev, |
| 2790 | struct device_attribute *attr, char *buf) |
| 2791 | { |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2792 | unsigned long name; |
| 2793 | unsigned int irq_index; |
| 2794 | int err; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2795 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2796 | err = strict_strtoul(attr->attr.name, 0, &name); |
| 2797 | if (err) |
| 2798 | return err; |
| 2799 | |
| 2800 | irq_index = name - irq_first; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2801 | if (irq_index >= num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2802 | return -EINVAL; |
| 2803 | else |
| 2804 | return sprintf(buf, "%u\n", irq_count[irq_index]); |
| 2805 | } |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2806 | |
| 2807 | static ssize_t ab8500_subscribe_write(struct file *file, |
| 2808 | const char __user *user_buf, |
| 2809 | size_t count, loff_t *ppos) |
| 2810 | { |
| 2811 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2812 | char buf[32]; |
| 2813 | int buf_size; |
| 2814 | unsigned long user_val; |
| 2815 | int err; |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2816 | unsigned int irq_index; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2817 | |
| 2818 | /* Get userspace string and assure termination */ |
| 2819 | buf_size = min(count, (sizeof(buf)-1)); |
| 2820 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2821 | return -EFAULT; |
| 2822 | buf[buf_size] = 0; |
| 2823 | |
| 2824 | err = strict_strtoul(buf, 0, &user_val); |
| 2825 | if (err) |
| 2826 | return -EINVAL; |
| 2827 | if (user_val < irq_first) { |
| 2828 | dev_err(dev, "debugfs error input < %d\n", irq_first); |
| 2829 | return -EINVAL; |
| 2830 | } |
| 2831 | if (user_val > irq_last) { |
| 2832 | dev_err(dev, "debugfs error input > %d\n", irq_last); |
| 2833 | return -EINVAL; |
| 2834 | } |
| 2835 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2836 | irq_index = user_val - irq_first; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2837 | if (irq_index >= num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2838 | return -EINVAL; |
| 2839 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2840 | /* |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2841 | * This will create a sysfs file named <irq-nr> which userspace can |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2842 | * use to select or poll and get the AB8500 events |
| 2843 | */ |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2844 | dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), |
| 2845 | GFP_KERNEL); |
| 2846 | event_name[irq_index] = kmalloc(buf_size, GFP_KERNEL); |
| 2847 | sprintf(event_name[irq_index], "%lu", user_val); |
| 2848 | dev_attr[irq_index]->show = show_irq; |
| 2849 | dev_attr[irq_index]->store = NULL; |
| 2850 | dev_attr[irq_index]->attr.name = event_name[irq_index]; |
| 2851 | dev_attr[irq_index]->attr.mode = S_IRUGO; |
| 2852 | err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2853 | if (err < 0) { |
| 2854 | printk(KERN_ERR "sysfs_create_file failed %d\n", err); |
| 2855 | return err; |
| 2856 | } |
| 2857 | |
| 2858 | err = request_threaded_irq(user_val, NULL, ab8500_debug_handler, |
| 2859 | IRQF_SHARED | IRQF_NO_SUSPEND, |
| 2860 | "ab8500-debug", &dev->kobj); |
| 2861 | if (err < 0) { |
| 2862 | printk(KERN_ERR "request_threaded_irq failed %d, %lu\n", |
| 2863 | err, user_val); |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2864 | sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2865 | return err; |
| 2866 | } |
| 2867 | |
| 2868 | return buf_size; |
| 2869 | } |
| 2870 | |
| 2871 | static ssize_t ab8500_unsubscribe_write(struct file *file, |
| 2872 | const char __user *user_buf, |
| 2873 | size_t count, loff_t *ppos) |
| 2874 | { |
| 2875 | struct device *dev = ((struct seq_file *)(file->private_data))->private; |
| 2876 | char buf[32]; |
| 2877 | int buf_size; |
| 2878 | unsigned long user_val; |
| 2879 | int err; |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2880 | unsigned int irq_index; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2881 | |
| 2882 | /* Get userspace string and assure termination */ |
| 2883 | buf_size = min(count, (sizeof(buf)-1)); |
| 2884 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2885 | return -EFAULT; |
| 2886 | buf[buf_size] = 0; |
| 2887 | |
| 2888 | err = strict_strtoul(buf, 0, &user_val); |
| 2889 | if (err) |
| 2890 | return -EINVAL; |
| 2891 | if (user_val < irq_first) { |
| 2892 | dev_err(dev, "debugfs error input < %d\n", irq_first); |
| 2893 | return -EINVAL; |
| 2894 | } |
| 2895 | if (user_val > irq_last) { |
| 2896 | dev_err(dev, "debugfs error input > %d\n", irq_last); |
| 2897 | return -EINVAL; |
| 2898 | } |
| 2899 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2900 | irq_index = user_val - irq_first; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2901 | if (irq_index >= num_irqs) |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2902 | return -EINVAL; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2903 | |
Mattias Wallin | 0b337e7 | 2010-11-19 17:55:11 +0100 | [diff] [blame] | 2904 | /* Set irq count to 0 when unsubscribe */ |
| 2905 | irq_count[irq_index] = 0; |
| 2906 | |
| 2907 | if (dev_attr[irq_index]) |
| 2908 | sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr); |
| 2909 | |
| 2910 | |
| 2911 | free_irq(user_val, &dev->kobj); |
| 2912 | kfree(event_name[irq_index]); |
| 2913 | kfree(dev_attr[irq_index]); |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2914 | |
| 2915 | return buf_size; |
| 2916 | } |
| 2917 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2918 | /* |
| 2919 | * - several deubgfs nodes fops |
| 2920 | */ |
| 2921 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2922 | static const struct file_operations ab8500_bank_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2923 | .open = ab8500_bank_open, |
| 2924 | .write = ab8500_bank_write, |
| 2925 | .read = seq_read, |
| 2926 | .llseek = seq_lseek, |
| 2927 | .release = single_release, |
| 2928 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2929 | }; |
| 2930 | |
| 2931 | static const struct file_operations ab8500_address_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2932 | .open = ab8500_address_open, |
| 2933 | .write = ab8500_address_write, |
| 2934 | .read = seq_read, |
| 2935 | .llseek = seq_lseek, |
| 2936 | .release = single_release, |
| 2937 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2938 | }; |
| 2939 | |
| 2940 | static const struct file_operations ab8500_val_fops = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2941 | .open = ab8500_val_open, |
| 2942 | .write = ab8500_val_write, |
| 2943 | .read = seq_read, |
| 2944 | .llseek = seq_lseek, |
| 2945 | .release = single_release, |
| 2946 | .owner = THIS_MODULE, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2947 | }; |
| 2948 | |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 2949 | static const struct file_operations ab8500_interrupts_fops = { |
| 2950 | .open = ab8500_interrupts_open, |
| 2951 | .read = seq_read, |
| 2952 | .llseek = seq_lseek, |
| 2953 | .release = single_release, |
| 2954 | .owner = THIS_MODULE, |
| 2955 | }; |
| 2956 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 2957 | static const struct file_operations ab8500_subscribe_fops = { |
| 2958 | .open = ab8500_subscribe_unsubscribe_open, |
| 2959 | .write = ab8500_subscribe_write, |
| 2960 | .read = seq_read, |
| 2961 | .llseek = seq_lseek, |
| 2962 | .release = single_release, |
| 2963 | .owner = THIS_MODULE, |
| 2964 | }; |
| 2965 | |
| 2966 | static const struct file_operations ab8500_unsubscribe_fops = { |
| 2967 | .open = ab8500_subscribe_unsubscribe_open, |
| 2968 | .write = ab8500_unsubscribe_write, |
| 2969 | .read = seq_read, |
| 2970 | .llseek = seq_lseek, |
| 2971 | .release = single_release, |
| 2972 | .owner = THIS_MODULE, |
| 2973 | }; |
| 2974 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2975 | static const struct file_operations ab8500_hwreg_fops = { |
| 2976 | .open = ab8500_hwreg_open, |
| 2977 | .write = ab8500_hwreg_write, |
| 2978 | .read = seq_read, |
| 2979 | .llseek = seq_lseek, |
| 2980 | .release = single_release, |
| 2981 | .owner = THIS_MODULE, |
| 2982 | }; |
| 2983 | |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2984 | static struct dentry *ab8500_dir; |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 2985 | static struct dentry *ab8500_gpadc_dir; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2986 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 2987 | static int ab8500_debug_probe(struct platform_device *plf) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2988 | { |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 2989 | struct dentry *file; |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2990 | int ret = -ENOMEM; |
| 2991 | struct ab8500 *ab8500; |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 2992 | debug_bank = AB8500_MISC; |
| 2993 | debug_address = AB8500_REV_REG & 0x00FF; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 2994 | |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2995 | ab8500 = dev_get_drvdata(plf->dev.parent); |
| 2996 | num_irqs = ab8500->mask_size; |
| 2997 | |
Ashok G | 70bad04 | 2012-02-28 10:21:00 +0530 | [diff] [blame] | 2998 | irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 2999 | if (!irq_count) |
| 3000 | return -ENOMEM; |
| 3001 | |
| 3002 | dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL); |
| 3003 | if (!dev_attr) |
| 3004 | goto out_freeirq_count; |
| 3005 | |
| 3006 | event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL); |
| 3007 | if (!event_name) |
| 3008 | goto out_freedev_attr; |
| 3009 | |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 3010 | irq_first = platform_get_irq_byname(plf, "IRQ_FIRST"); |
| 3011 | if (irq_first < 0) { |
| 3012 | dev_err(&plf->dev, "First irq not found, err %d\n", |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3013 | irq_first); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 3014 | ret = irq_first; |
| 3015 | goto out_freeevent_name; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 3016 | } |
| 3017 | |
| 3018 | irq_last = platform_get_irq_byname(plf, "IRQ_LAST"); |
| 3019 | if (irq_last < 0) { |
| 3020 | dev_err(&plf->dev, "Last irq not found, err %d\n", |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3021 | irq_last); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 3022 | ret = irq_last; |
Jonas Aaberg | 2cf64e2 | 2012-05-31 07:57:07 +0200 | [diff] [blame] | 3023 | goto out_freeevent_name; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 3024 | } |
| 3025 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3026 | ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); |
| 3027 | if (!ab8500_dir) |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3028 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3029 | |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3030 | ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING, |
| 3031 | ab8500_dir); |
| 3032 | if (!ab8500_gpadc_dir) |
| 3033 | goto err; |
| 3034 | |
| 3035 | file = debugfs_create_file("all-bank-registers", S_IRUGO, |
| 3036 | ab8500_dir, &plf->dev, &ab8500_registers_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3037 | if (!file) |
| 3038 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3039 | |
Mian Yousaf Kaukab | 42002c6 | 2012-01-26 15:39:20 +0100 | [diff] [blame] | 3040 | file = debugfs_create_file("all-banks", S_IRUGO, |
| 3041 | ab8500_dir, &plf->dev, &ab8500_all_banks_fops); |
| 3042 | if (!file) |
| 3043 | goto err; |
| 3044 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3045 | file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3046 | ab8500_dir, &plf->dev, &ab8500_bank_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3047 | if (!file) |
| 3048 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3049 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3050 | file = debugfs_create_file("register-address", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3051 | ab8500_dir, &plf->dev, &ab8500_address_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3052 | if (!file) |
| 3053 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3054 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3055 | file = debugfs_create_file("register-value", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3056 | ab8500_dir, &plf->dev, &ab8500_val_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3057 | if (!file) |
| 3058 | goto err; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3059 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3060 | file = debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3061 | ab8500_dir, &plf->dev, &ab8500_subscribe_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3062 | if (!file) |
| 3063 | goto err; |
Lee Jones | 4b8ac08 | 2013-01-14 16:10:36 +0000 | [diff] [blame] | 3064 | |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3065 | if (is_ab8500(ab8500)) { |
| 3066 | debug_ranges = ab8500_debug_ranges; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3067 | num_interrupt_lines = AB8500_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3068 | } else if (is_ab8505(ab8500)) { |
| 3069 | debug_ranges = ab8505_debug_ranges; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3070 | num_interrupt_lines = AB8505_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3071 | } else if (is_ab9540(ab8500)) { |
| 3072 | debug_ranges = ab8505_debug_ranges; |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3073 | num_interrupt_lines = AB9540_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3074 | } else if (is_ab8540(ab8500)) { |
Lee Jones | 971480f | 2012-11-19 12:20:03 +0100 | [diff] [blame] | 3075 | debug_ranges = ab8540_debug_ranges; |
Lee Jones | e436ddf | 2013-02-26 10:09:41 +0000 | [diff] [blame] | 3076 | num_interrupt_lines = AB8540_NR_IRQS; |
Lee Jones | 9581ae3 | 2012-07-06 16:11:50 +0200 | [diff] [blame] | 3077 | } |
Bengt Jonsson | 8f0eb43 | 2012-02-14 13:01:00 +0100 | [diff] [blame] | 3078 | |
| 3079 | file = debugfs_create_file("interrupts", (S_IRUGO), |
| 3080 | ab8500_dir, &plf->dev, &ab8500_interrupts_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("irq-unsubscribe", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3085 | ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3086 | if (!file) |
| 3087 | goto err; |
| 3088 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3089 | file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3090 | ab8500_dir, &plf->dev, &ab8500_hwreg_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("all-modem-registers", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | c7ebaee | 2013-02-26 14:03:33 +0000 | [diff] [blame] | 3095 | ab8500_dir, &plf->dev, &ab8500_modem_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("bat_ctrl", (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_bat_ctrl_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("btemp_ball", (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_btemp_ball_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("main_charger_v", (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_main_charger_v_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("acc_detect1", (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_acc_detect1_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("acc_detect2", (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_acc_detect2_fops); |
| 3121 | if (!file) |
| 3122 | goto err; |
| 3123 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3124 | file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3125 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux1_fops); |
| 3126 | if (!file) |
| 3127 | goto err; |
| 3128 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3129 | file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3130 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux2_fops); |
| 3131 | if (!file) |
| 3132 | goto err; |
| 3133 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3134 | 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] | 3135 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_bat_v_fops); |
| 3136 | if (!file) |
| 3137 | goto err; |
| 3138 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3139 | file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3140 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_vbus_v_fops); |
| 3141 | if (!file) |
| 3142 | goto err; |
| 3143 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3144 | 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] | 3145 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_c_fops); |
| 3146 | if (!file) |
| 3147 | goto err; |
| 3148 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3149 | 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] | 3150 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_charger_c_fops); |
| 3151 | if (!file) |
| 3152 | goto err; |
| 3153 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3154 | 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] | 3155 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bk_bat_v_fops); |
| 3156 | if (!file) |
| 3157 | goto err; |
| 3158 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3159 | file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP), |
John Beckett | 1478a31 | 2011-05-31 13:54:27 +0100 | [diff] [blame] | 3160 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_die_temp_fops); |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3161 | if (!file) |
| 3162 | goto err; |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 3163 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3164 | file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 127629d | 2013-02-26 14:04:37 +0000 | [diff] [blame] | 3165 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_id_fops); |
| 3166 | if (!file) |
| 3167 | goto err; |
| 3168 | |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3169 | if (is_ab8540(ab8500)) { |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3170 | file = debugfs_create_file("xtal_temp", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3171 | ab8500_gpadc_dir, &plf->dev, &ab8540_gpadc_xtal_temp_fops); |
| 3172 | if (!file) |
| 3173 | goto err; |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3174 | file = debugfs_create_file("vbattruemeas", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3175 | ab8500_gpadc_dir, &plf->dev, |
| 3176 | &ab8540_gpadc_vbat_true_meas_fops); |
| 3177 | if (!file) |
| 3178 | goto err; |
| 3179 | file = debugfs_create_file("batctrl_and_ibat", |
| 3180 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3181 | &plf->dev, &ab8540_gpadc_bat_ctrl_and_ibat_fops); |
| 3182 | if (!file) |
| 3183 | goto err; |
| 3184 | file = debugfs_create_file("vbatmeas_and_ibat", |
| 3185 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3186 | &plf->dev, |
| 3187 | &ab8540_gpadc_vbat_meas_and_ibat_fops); |
| 3188 | if (!file) |
| 3189 | goto err; |
| 3190 | file = debugfs_create_file("vbattruemeas_and_ibat", |
| 3191 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3192 | &plf->dev, |
| 3193 | &ab8540_gpadc_vbat_true_meas_and_ibat_fops); |
| 3194 | if (!file) |
| 3195 | goto err; |
| 3196 | file = debugfs_create_file("battemp_and_ibat", |
| 3197 | (S_IRUGO | S_IWUGO), ab8500_gpadc_dir, |
| 3198 | &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops); |
| 3199 | if (!file) |
| 3200 | goto err; |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3201 | file = debugfs_create_file("otp_calib", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | bc6b413 | 2013-02-26 14:02:31 +0000 | [diff] [blame] | 3202 | ab8500_gpadc_dir, &plf->dev, &ab8540_gpadc_otp_calib_fops); |
| 3203 | if (!file) |
| 3204 | goto err; |
| 3205 | } |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3206 | file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3207 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_avg_sample_fops); |
| 3208 | if (!file) |
| 3209 | goto err; |
| 3210 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3211 | file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3212 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_edge_fops); |
| 3213 | if (!file) |
| 3214 | goto err; |
| 3215 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3216 | file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3217 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_trig_timer_fops); |
| 3218 | if (!file) |
| 3219 | goto err; |
| 3220 | |
Lee Jones | f38487f | 2013-02-26 14:09:08 +0000 | [diff] [blame] | 3221 | file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP), |
Lee Jones | 7348234 | 2013-02-26 10:06:55 +0000 | [diff] [blame] | 3222 | ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_conv_type_fops); |
| 3223 | if (!file) |
| 3224 | goto err; |
| 3225 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3226 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3227 | |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3228 | err: |
| 3229 | if (ab8500_dir) |
| 3230 | debugfs_remove_recursive(ab8500_dir); |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3231 | dev_err(&plf->dev, "failed to create debugfs entries.\n"); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 3232 | out_freeevent_name: |
| 3233 | kfree(event_name); |
| 3234 | out_freedev_attr: |
| 3235 | kfree(dev_attr); |
| 3236 | out_freeirq_count: |
| 3237 | kfree(irq_count); |
| 3238 | |
| 3239 | return ret; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3240 | } |
| 3241 | |
Bill Pemberton | 4740f73 | 2012-11-19 13:26:01 -0500 | [diff] [blame] | 3242 | static int ab8500_debug_remove(struct platform_device *plf) |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3243 | { |
carriere etienne | 0fbce76 | 2011-04-08 16:26:36 +0200 | [diff] [blame] | 3244 | debugfs_remove_recursive(ab8500_dir); |
Linus Walleij | ddba25f | 2012-02-03 11:19:05 +0100 | [diff] [blame] | 3245 | kfree(event_name); |
| 3246 | kfree(dev_attr); |
| 3247 | kfree(irq_count); |
| 3248 | |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3249 | return 0; |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3250 | } |
| 3251 | |
| 3252 | static struct platform_driver ab8500_debug_driver = { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3253 | .driver = { |
| 3254 | .name = "ab8500-debug", |
| 3255 | .owner = THIS_MODULE, |
| 3256 | }, |
| 3257 | .probe = ab8500_debug_probe, |
Bill Pemberton | 8444921 | 2012-11-19 13:20:24 -0500 | [diff] [blame] | 3258 | .remove = ab8500_debug_remove |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3259 | }; |
| 3260 | |
| 3261 | static int __init ab8500_debug_init(void) |
| 3262 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3263 | return platform_driver_register(&ab8500_debug_driver); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3264 | } |
| 3265 | |
| 3266 | static void __exit ab8500_debug_exit(void) |
| 3267 | { |
Mattias Wallin | d7b9f32 | 2010-11-26 13:06:39 +0100 | [diff] [blame] | 3268 | platform_driver_unregister(&ab8500_debug_driver); |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 3269 | } |
| 3270 | subsys_initcall(ab8500_debug_init); |
| 3271 | module_exit(ab8500_debug_exit); |
| 3272 | |
| 3273 | MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com"); |
| 3274 | MODULE_DESCRIPTION("AB8500 DEBUG"); |
| 3275 | MODULE_LICENSE("GPL v2"); |