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