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