Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd/ab5500: delete AB5500 support

This platform has been obsoleted and was only available inside of
ST-Ericsson, no users of this code are left in the world. This
deletes the core U5500 support entirely in the same manner as the
obsoleted U8500 silicon was previously deleted.

Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Cc: Rabin Vincent <rabin.vincent@stericsson.com>
Cc: Jonas Aberg <jonas.aberg@stericsson.com>
Cc: Per Forlin <per.forlin@stericsson.com>
Cc: Ulf Hansson <ulf.hansson@stericsson.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+1 -2431
-17
drivers/mfd/Kconfig
··· 648 648 This enables the PCAP ASIC present on EZX Phones. This is 649 649 needed for MMC, TouchScreen, Sound, USB, etc.. 650 650 651 - config AB5500_CORE 652 - bool "ST-Ericsson AB5500 Mixed Signal Power Management chip" 653 - depends on ABX500_CORE && MFD_DB5500_PRCMU 654 - select MFD_CORE 655 - help 656 - Select this option to enable access to AB5500 power management 657 - chip. This connects to the db5500 chip via the I2C bus via PRCMU. 658 - This chip embeds various other multimedia funtionalities as well. 659 - 660 - config AB5500_DEBUG 661 - bool "Enable debug info via debugfs" 662 - depends on AB5500_CORE && DEBUG_FS 663 - default y if DEBUG_FS 664 - help 665 - Select this option if you want debug information from the AB5500 666 - using the debug filesystem, debugfs. 667 - 668 651 config AB8500_CORE 669 652 bool "ST-Ericsson AB8500 Mixed Signal Power Management chip" 670 653 depends on GENERIC_HARDIRQS && ABX500_CORE
-2
drivers/mfd/Makefile
··· 87 87 obj-$(CONFIG_ABX500_CORE) += abx500-core.o 88 88 obj-$(CONFIG_AB3100_CORE) += ab3100-core.o 89 89 obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o 90 - obj-$(CONFIG_AB5500_CORE) += ab5500-core.o 91 - obj-$(CONFIG_AB5500_DEBUG) += ab5500-debugfs.o 92 90 obj-$(CONFIG_AB8500_CORE) += ab8500-core.o ab8500-sysctrl.o 93 91 obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o 94 92 obj-$(CONFIG_AB8500_GPADC) += ab8500-gpadc.o
-1439
drivers/mfd/ab5500-core.c
··· 1 - /* 2 - * Copyright (C) 2007-2011 ST-Ericsson 3 - * License terms: GNU General Public License (GPL) version 2 4 - * Low-level core for exclusive access to the AB5500 IC on the I2C bus 5 - * and some basic chip-configuration. 6 - * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com> 7 - * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> 8 - * Author: Mattias Wallin <mattias.wallin@stericsson.com> 9 - * Author: Rickard Andersson <rickard.andersson@stericsson.com> 10 - * Author: Karl Komierowski <karl.komierowski@stericsson.com> 11 - * Author: Bibek Basu <bibek.basu@stericsson.com> 12 - * 13 - * TODO: Event handling with irq_chip. Waiting for PRCMU fw support. 14 - */ 15 - 16 - #include <linux/module.h> 17 - #include <linux/mutex.h> 18 - #include <linux/err.h> 19 - #include <linux/platform_device.h> 20 - #include <linux/slab.h> 21 - #include <linux/device.h> 22 - #include <linux/irq.h> 23 - #include <linux/interrupt.h> 24 - #include <linux/random.h> 25 - #include <linux/mfd/abx500.h> 26 - #include <linux/mfd/abx500/ab5500.h> 27 - #include <linux/list.h> 28 - #include <linux/bitops.h> 29 - #include <linux/spinlock.h> 30 - #include <linux/mfd/core.h> 31 - #include <linux/mfd/db5500-prcmu.h> 32 - 33 - #include "ab5500-core.h" 34 - #include "ab5500-debugfs.h" 35 - 36 - #define AB5500_NUM_EVENT_REG 23 37 - #define AB5500_IT_LATCH0_REG 0x40 38 - #define AB5500_IT_MASK0_REG 0x60 39 - 40 - /* 41 - * Permissible register ranges for reading and writing per device and bank. 42 - * 43 - * The ranges must be listed in increasing address order, and no overlaps are 44 - * allowed. It is assumed that write permission implies read permission 45 - * (i.e. only RO and RW permissions should be used). Ranges with write 46 - * permission must not be split up. 47 - */ 48 - 49 - #define NO_RANGE {.count = 0, .range = NULL,} 50 - static struct ab5500_i2c_banks ab5500_bank_ranges[AB5500_NUM_DEVICES] = { 51 - [AB5500_DEVID_USB] = { 52 - .nbanks = 1, 53 - .bank = (struct ab5500_i2c_ranges []) { 54 - { 55 - .bankid = AB5500_BANK_USB, 56 - .nranges = 12, 57 - .range = (struct ab5500_reg_range[]) { 58 - { 59 - .first = 0x01, 60 - .last = 0x01, 61 - .perm = AB5500_PERM_RW, 62 - }, 63 - { 64 - .first = 0x80, 65 - .last = 0x83, 66 - .perm = AB5500_PERM_RW, 67 - }, 68 - { 69 - .first = 0x87, 70 - .last = 0x8A, 71 - .perm = AB5500_PERM_RW, 72 - }, 73 - { 74 - .first = 0x8B, 75 - .last = 0x8B, 76 - .perm = AB5500_PERM_RO, 77 - }, 78 - { 79 - .first = 0x91, 80 - .last = 0x92, 81 - .perm = AB5500_PERM_RO, 82 - }, 83 - { 84 - .first = 0x93, 85 - .last = 0x93, 86 - .perm = AB5500_PERM_RW, 87 - }, 88 - { 89 - .first = 0x94, 90 - .last = 0x94, 91 - .perm = AB5500_PERM_RO, 92 - }, 93 - { 94 - .first = 0xA8, 95 - .last = 0xB0, 96 - .perm = AB5500_PERM_RO, 97 - }, 98 - { 99 - .first = 0xB2, 100 - .last = 0xB2, 101 - .perm = AB5500_PERM_RO, 102 - }, 103 - { 104 - .first = 0xB4, 105 - .last = 0xBC, 106 - .perm = AB5500_PERM_RO, 107 - }, 108 - { 109 - .first = 0xBF, 110 - .last = 0xBF, 111 - .perm = AB5500_PERM_RO, 112 - }, 113 - { 114 - .first = 0xC1, 115 - .last = 0xC5, 116 - .perm = AB5500_PERM_RO, 117 - }, 118 - }, 119 - }, 120 - }, 121 - }, 122 - [AB5500_DEVID_ADC] = { 123 - .nbanks = 1, 124 - .bank = (struct ab5500_i2c_ranges []) { 125 - { 126 - .bankid = AB5500_BANK_ADC, 127 - .nranges = 6, 128 - .range = (struct ab5500_reg_range[]) { 129 - { 130 - .first = 0x1F, 131 - .last = 0x22, 132 - .perm = AB5500_PERM_RO, 133 - }, 134 - { 135 - .first = 0x23, 136 - .last = 0x24, 137 - .perm = AB5500_PERM_RW, 138 - }, 139 - { 140 - .first = 0x26, 141 - .last = 0x2D, 142 - .perm = AB5500_PERM_RO, 143 - }, 144 - { 145 - .first = 0x2F, 146 - .last = 0x34, 147 - .perm = AB5500_PERM_RW, 148 - }, 149 - { 150 - .first = 0x37, 151 - .last = 0x57, 152 - .perm = AB5500_PERM_RW, 153 - }, 154 - { 155 - .first = 0x58, 156 - .last = 0x58, 157 - .perm = AB5500_PERM_RO, 158 - }, 159 - }, 160 - }, 161 - }, 162 - }, 163 - [AB5500_DEVID_LEDS] = { 164 - .nbanks = 1, 165 - .bank = (struct ab5500_i2c_ranges []) { 166 - { 167 - .bankid = AB5500_BANK_LED, 168 - .nranges = 1, 169 - .range = (struct ab5500_reg_range[]) { 170 - { 171 - .first = 0x00, 172 - .last = 0x0C, 173 - .perm = AB5500_PERM_RW, 174 - }, 175 - }, 176 - }, 177 - }, 178 - }, 179 - [AB5500_DEVID_VIDEO] = { 180 - .nbanks = 1, 181 - .bank = (struct ab5500_i2c_ranges []) { 182 - { 183 - .bankid = AB5500_BANK_VDENC, 184 - .nranges = 12, 185 - .range = (struct ab5500_reg_range[]) { 186 - { 187 - .first = 0x00, 188 - .last = 0x08, 189 - .perm = AB5500_PERM_RW, 190 - }, 191 - { 192 - .first = 0x09, 193 - .last = 0x09, 194 - .perm = AB5500_PERM_RO, 195 - }, 196 - { 197 - .first = 0x0A, 198 - .last = 0x12, 199 - .perm = AB5500_PERM_RW, 200 - }, 201 - { 202 - .first = 0x15, 203 - .last = 0x19, 204 - .perm = AB5500_PERM_RW, 205 - }, 206 - { 207 - .first = 0x1B, 208 - .last = 0x21, 209 - .perm = AB5500_PERM_RW, 210 - }, 211 - { 212 - .first = 0x27, 213 - .last = 0x2C, 214 - .perm = AB5500_PERM_RW, 215 - }, 216 - { 217 - .first = 0x41, 218 - .last = 0x41, 219 - .perm = AB5500_PERM_RW, 220 - }, 221 - { 222 - .first = 0x45, 223 - .last = 0x5B, 224 - .perm = AB5500_PERM_RW, 225 - }, 226 - { 227 - .first = 0x5D, 228 - .last = 0x5D, 229 - .perm = AB5500_PERM_RW, 230 - }, 231 - { 232 - .first = 0x69, 233 - .last = 0x69, 234 - .perm = AB5500_PERM_RW, 235 - }, 236 - { 237 - .first = 0x6C, 238 - .last = 0x6D, 239 - .perm = AB5500_PERM_RW, 240 - }, 241 - { 242 - .first = 0x80, 243 - .last = 0x81, 244 - .perm = AB5500_PERM_RW, 245 - }, 246 - }, 247 - }, 248 - }, 249 - }, 250 - [AB5500_DEVID_REGULATORS] = { 251 - .nbanks = 2, 252 - .bank = (struct ab5500_i2c_ranges []) { 253 - { 254 - .bankid = AB5500_BANK_STARTUP, 255 - .nranges = 12, 256 - .range = (struct ab5500_reg_range[]) { 257 - { 258 - .first = 0x00, 259 - .last = 0x01, 260 - .perm = AB5500_PERM_RW, 261 - }, 262 - { 263 - .first = 0x1F, 264 - .last = 0x1F, 265 - .perm = AB5500_PERM_RW, 266 - }, 267 - { 268 - .first = 0x2E, 269 - .last = 0x2E, 270 - .perm = AB5500_PERM_RO, 271 - }, 272 - { 273 - .first = 0x2F, 274 - .last = 0x30, 275 - .perm = AB5500_PERM_RW, 276 - }, 277 - { 278 - .first = 0x50, 279 - .last = 0x51, 280 - .perm = AB5500_PERM_RW, 281 - }, 282 - { 283 - .first = 0x60, 284 - .last = 0x61, 285 - .perm = AB5500_PERM_RW, 286 - }, 287 - { 288 - .first = 0x66, 289 - .last = 0x8A, 290 - .perm = AB5500_PERM_RW, 291 - }, 292 - { 293 - .first = 0x8C, 294 - .last = 0x96, 295 - .perm = AB5500_PERM_RW, 296 - }, 297 - { 298 - .first = 0xAA, 299 - .last = 0xB4, 300 - .perm = AB5500_PERM_RW, 301 - }, 302 - { 303 - .first = 0xB7, 304 - .last = 0xBF, 305 - .perm = AB5500_PERM_RW, 306 - }, 307 - { 308 - .first = 0xC1, 309 - .last = 0xCA, 310 - .perm = AB5500_PERM_RW, 311 - }, 312 - { 313 - .first = 0xD3, 314 - .last = 0xE0, 315 - .perm = AB5500_PERM_RW, 316 - }, 317 - }, 318 - }, 319 - { 320 - .bankid = AB5500_BANK_SIM_USBSIM, 321 - .nranges = 1, 322 - .range = (struct ab5500_reg_range[]) { 323 - { 324 - .first = 0x13, 325 - .last = 0x19, 326 - .perm = AB5500_PERM_RW, 327 - }, 328 - }, 329 - }, 330 - }, 331 - }, 332 - [AB5500_DEVID_SIM] = { 333 - .nbanks = 1, 334 - .bank = (struct ab5500_i2c_ranges []) { 335 - { 336 - .bankid = AB5500_BANK_SIM_USBSIM, 337 - .nranges = 1, 338 - .range = (struct ab5500_reg_range[]) { 339 - { 340 - .first = 0x13, 341 - .last = 0x19, 342 - .perm = AB5500_PERM_RW, 343 - }, 344 - }, 345 - }, 346 - }, 347 - }, 348 - [AB5500_DEVID_RTC] = { 349 - .nbanks = 1, 350 - .bank = (struct ab5500_i2c_ranges []) { 351 - { 352 - .bankid = AB5500_BANK_RTC, 353 - .nranges = 2, 354 - .range = (struct ab5500_reg_range[]) { 355 - { 356 - .first = 0x00, 357 - .last = 0x04, 358 - .perm = AB5500_PERM_RW, 359 - }, 360 - { 361 - .first = 0x06, 362 - .last = 0x0C, 363 - .perm = AB5500_PERM_RW, 364 - }, 365 - }, 366 - }, 367 - }, 368 - }, 369 - [AB5500_DEVID_CHARGER] = { 370 - .nbanks = 1, 371 - .bank = (struct ab5500_i2c_ranges []) { 372 - { 373 - .bankid = AB5500_BANK_CHG, 374 - .nranges = 2, 375 - .range = (struct ab5500_reg_range[]) { 376 - { 377 - .first = 0x11, 378 - .last = 0x11, 379 - .perm = AB5500_PERM_RO, 380 - }, 381 - { 382 - .first = 0x12, 383 - .last = 0x1B, 384 - .perm = AB5500_PERM_RW, 385 - }, 386 - }, 387 - }, 388 - }, 389 - }, 390 - [AB5500_DEVID_FUELGAUGE] = { 391 - .nbanks = 1, 392 - .bank = (struct ab5500_i2c_ranges []) { 393 - { 394 - .bankid = AB5500_BANK_FG_BATTCOM_ACC, 395 - .nranges = 2, 396 - .range = (struct ab5500_reg_range[]) { 397 - { 398 - .first = 0x00, 399 - .last = 0x0B, 400 - .perm = AB5500_PERM_RO, 401 - }, 402 - { 403 - .first = 0x0C, 404 - .last = 0x10, 405 - .perm = AB5500_PERM_RW, 406 - }, 407 - }, 408 - }, 409 - }, 410 - }, 411 - [AB5500_DEVID_VIBRATOR] = { 412 - .nbanks = 1, 413 - .bank = (struct ab5500_i2c_ranges []) { 414 - { 415 - .bankid = AB5500_BANK_VIBRA, 416 - .nranges = 2, 417 - .range = (struct ab5500_reg_range[]) { 418 - { 419 - .first = 0x10, 420 - .last = 0x13, 421 - .perm = AB5500_PERM_RW, 422 - }, 423 - { 424 - .first = 0xFE, 425 - .last = 0xFE, 426 - .perm = AB5500_PERM_RW, 427 - }, 428 - }, 429 - }, 430 - }, 431 - }, 432 - [AB5500_DEVID_CODEC] = { 433 - .nbanks = 1, 434 - .bank = (struct ab5500_i2c_ranges []) { 435 - { 436 - .bankid = AB5500_BANK_AUDIO_HEADSETUSB, 437 - .nranges = 2, 438 - .range = (struct ab5500_reg_range[]) { 439 - { 440 - .first = 0x00, 441 - .last = 0x48, 442 - .perm = AB5500_PERM_RW, 443 - }, 444 - { 445 - .first = 0xEB, 446 - .last = 0xFB, 447 - .perm = AB5500_PERM_RW, 448 - }, 449 - }, 450 - }, 451 - }, 452 - }, 453 - [AB5500_DEVID_POWER] = { 454 - .nbanks = 2, 455 - .bank = (struct ab5500_i2c_ranges []) { 456 - { 457 - .bankid = AB5500_BANK_STARTUP, 458 - .nranges = 1, 459 - .range = (struct ab5500_reg_range[]) { 460 - { 461 - .first = 0x30, 462 - .last = 0x30, 463 - .perm = AB5500_PERM_RW, 464 - }, 465 - }, 466 - }, 467 - { 468 - .bankid = AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP, 469 - .nranges = 1, 470 - .range = (struct ab5500_reg_range[]) { 471 - { 472 - .first = 0x01, 473 - .last = 0x01, 474 - .perm = AB5500_PERM_RW, 475 - }, 476 - }, 477 - }, 478 - }, 479 - }, 480 - }; 481 - 482 - #define AB5500_IRQ(bank, bit) ((bank) * 8 + (bit)) 483 - 484 - /* I appologize for the resource names beeing a mix of upper case 485 - * and lower case but I want them to be exact as the documentation */ 486 - static struct mfd_cell ab5500_devs[AB5500_NUM_DEVICES] = { 487 - [AB5500_DEVID_LEDS] = { 488 - .name = "ab5500-leds", 489 - .id = AB5500_DEVID_LEDS, 490 - }, 491 - [AB5500_DEVID_POWER] = { 492 - .name = "ab5500-power", 493 - .id = AB5500_DEVID_POWER, 494 - }, 495 - [AB5500_DEVID_REGULATORS] = { 496 - .name = "ab5500-regulator", 497 - .id = AB5500_DEVID_REGULATORS, 498 - }, 499 - [AB5500_DEVID_SIM] = { 500 - .name = "ab5500-sim", 501 - .id = AB5500_DEVID_SIM, 502 - .num_resources = 1, 503 - .resources = (struct resource[]) { 504 - { 505 - .name = "SIMOFF", 506 - .flags = IORESOURCE_IRQ, 507 - .start = AB5500_IRQ(2, 0), /*rising*/ 508 - .end = AB5500_IRQ(2, 1), /*falling*/ 509 - }, 510 - }, 511 - }, 512 - [AB5500_DEVID_RTC] = { 513 - .name = "ab5500-rtc", 514 - .id = AB5500_DEVID_RTC, 515 - .num_resources = 1, 516 - .resources = (struct resource[]) { 517 - { 518 - .name = "RTC_Alarm", 519 - .flags = IORESOURCE_IRQ, 520 - .start = AB5500_IRQ(1, 7), 521 - .end = AB5500_IRQ(1, 7), 522 - } 523 - }, 524 - }, 525 - [AB5500_DEVID_CHARGER] = { 526 - .name = "ab5500-charger", 527 - .id = AB5500_DEVID_CHARGER, 528 - }, 529 - [AB5500_DEVID_ADC] = { 530 - .name = "ab5500-adc", 531 - .id = AB5500_DEVID_ADC, 532 - .num_resources = 10, 533 - .resources = (struct resource[]) { 534 - { 535 - .name = "TRIGGER-0", 536 - .flags = IORESOURCE_IRQ, 537 - .start = AB5500_IRQ(0, 0), 538 - .end = AB5500_IRQ(0, 0), 539 - }, 540 - { 541 - .name = "TRIGGER-1", 542 - .flags = IORESOURCE_IRQ, 543 - .start = AB5500_IRQ(0, 1), 544 - .end = AB5500_IRQ(0, 1), 545 - }, 546 - { 547 - .name = "TRIGGER-2", 548 - .flags = IORESOURCE_IRQ, 549 - .start = AB5500_IRQ(0, 2), 550 - .end = AB5500_IRQ(0, 2), 551 - }, 552 - { 553 - .name = "TRIGGER-3", 554 - .flags = IORESOURCE_IRQ, 555 - .start = AB5500_IRQ(0, 3), 556 - .end = AB5500_IRQ(0, 3), 557 - }, 558 - { 559 - .name = "TRIGGER-4", 560 - .flags = IORESOURCE_IRQ, 561 - .start = AB5500_IRQ(0, 4), 562 - .end = AB5500_IRQ(0, 4), 563 - }, 564 - { 565 - .name = "TRIGGER-5", 566 - .flags = IORESOURCE_IRQ, 567 - .start = AB5500_IRQ(0, 5), 568 - .end = AB5500_IRQ(0, 5), 569 - }, 570 - { 571 - .name = "TRIGGER-6", 572 - .flags = IORESOURCE_IRQ, 573 - .start = AB5500_IRQ(0, 6), 574 - .end = AB5500_IRQ(0, 6), 575 - }, 576 - { 577 - .name = "TRIGGER-7", 578 - .flags = IORESOURCE_IRQ, 579 - .start = AB5500_IRQ(0, 7), 580 - .end = AB5500_IRQ(0, 7), 581 - }, 582 - { 583 - .name = "TRIGGER-VBAT", 584 - .flags = IORESOURCE_IRQ, 585 - .start = AB5500_IRQ(0, 8), 586 - .end = AB5500_IRQ(0, 8), 587 - }, 588 - { 589 - .name = "TRIGGER-VBAT-TXON", 590 - .flags = IORESOURCE_IRQ, 591 - .start = AB5500_IRQ(0, 9), 592 - .end = AB5500_IRQ(0, 9), 593 - }, 594 - }, 595 - }, 596 - [AB5500_DEVID_FUELGAUGE] = { 597 - .name = "ab5500-fuelgauge", 598 - .id = AB5500_DEVID_FUELGAUGE, 599 - .num_resources = 6, 600 - .resources = (struct resource[]) { 601 - { 602 - .name = "Batt_attach", 603 - .flags = IORESOURCE_IRQ, 604 - .start = AB5500_IRQ(7, 5), 605 - .end = AB5500_IRQ(7, 5), 606 - }, 607 - { 608 - .name = "Batt_removal", 609 - .flags = IORESOURCE_IRQ, 610 - .start = AB5500_IRQ(7, 6), 611 - .end = AB5500_IRQ(7, 6), 612 - }, 613 - { 614 - .name = "UART_framing", 615 - .flags = IORESOURCE_IRQ, 616 - .start = AB5500_IRQ(7, 7), 617 - .end = AB5500_IRQ(7, 7), 618 - }, 619 - { 620 - .name = "UART_overrun", 621 - .flags = IORESOURCE_IRQ, 622 - .start = AB5500_IRQ(8, 0), 623 - .end = AB5500_IRQ(8, 0), 624 - }, 625 - { 626 - .name = "UART_Rdy_RX", 627 - .flags = IORESOURCE_IRQ, 628 - .start = AB5500_IRQ(8, 1), 629 - .end = AB5500_IRQ(8, 1), 630 - }, 631 - { 632 - .name = "UART_Rdy_TX", 633 - .flags = IORESOURCE_IRQ, 634 - .start = AB5500_IRQ(8, 2), 635 - .end = AB5500_IRQ(8, 2), 636 - }, 637 - }, 638 - }, 639 - [AB5500_DEVID_VIBRATOR] = { 640 - .name = "ab5500-vibrator", 641 - .id = AB5500_DEVID_VIBRATOR, 642 - }, 643 - [AB5500_DEVID_CODEC] = { 644 - .name = "ab5500-codec", 645 - .id = AB5500_DEVID_CODEC, 646 - .num_resources = 3, 647 - .resources = (struct resource[]) { 648 - { 649 - .name = "audio_spkr1_ovc", 650 - .flags = IORESOURCE_IRQ, 651 - .start = AB5500_IRQ(9, 5), 652 - .end = AB5500_IRQ(9, 5), 653 - }, 654 - { 655 - .name = "audio_plllocked", 656 - .flags = IORESOURCE_IRQ, 657 - .start = AB5500_IRQ(9, 6), 658 - .end = AB5500_IRQ(9, 6), 659 - }, 660 - { 661 - .name = "audio_spkr2_ovc", 662 - .flags = IORESOURCE_IRQ, 663 - .start = AB5500_IRQ(17, 4), 664 - .end = AB5500_IRQ(17, 4), 665 - }, 666 - }, 667 - }, 668 - [AB5500_DEVID_USB] = { 669 - .name = "ab5500-usb", 670 - .id = AB5500_DEVID_USB, 671 - .num_resources = 36, 672 - .resources = (struct resource[]) { 673 - { 674 - .name = "Link_Update", 675 - .flags = IORESOURCE_IRQ, 676 - .start = AB5500_IRQ(22, 1), 677 - .end = AB5500_IRQ(22, 1), 678 - }, 679 - { 680 - .name = "DCIO", 681 - .flags = IORESOURCE_IRQ, 682 - .start = AB5500_IRQ(8, 3), 683 - .end = AB5500_IRQ(8, 4), 684 - }, 685 - { 686 - .name = "VBUS_R", 687 - .flags = IORESOURCE_IRQ, 688 - .start = AB5500_IRQ(8, 5), 689 - .end = AB5500_IRQ(8, 5), 690 - }, 691 - { 692 - .name = "VBUS_F", 693 - .flags = IORESOURCE_IRQ, 694 - .start = AB5500_IRQ(8, 6), 695 - .end = AB5500_IRQ(8, 6), 696 - }, 697 - { 698 - .name = "CHGstate_10_PCVBUSchg", 699 - .flags = IORESOURCE_IRQ, 700 - .start = AB5500_IRQ(8, 7), 701 - .end = AB5500_IRQ(8, 7), 702 - }, 703 - { 704 - .name = "DCIOreverse_ovc", 705 - .flags = IORESOURCE_IRQ, 706 - .start = AB5500_IRQ(9, 0), 707 - .end = AB5500_IRQ(9, 0), 708 - }, 709 - { 710 - .name = "USBCharDetDone", 711 - .flags = IORESOURCE_IRQ, 712 - .start = AB5500_IRQ(9, 1), 713 - .end = AB5500_IRQ(9, 1), 714 - }, 715 - { 716 - .name = "DCIO_no_limit", 717 - .flags = IORESOURCE_IRQ, 718 - .start = AB5500_IRQ(9, 2), 719 - .end = AB5500_IRQ(9, 2), 720 - }, 721 - { 722 - .name = "USB_suspend", 723 - .flags = IORESOURCE_IRQ, 724 - .start = AB5500_IRQ(9, 3), 725 - .end = AB5500_IRQ(9, 3), 726 - }, 727 - { 728 - .name = "DCIOreverse_fwdcurrent", 729 - .flags = IORESOURCE_IRQ, 730 - .start = AB5500_IRQ(9, 4), 731 - .end = AB5500_IRQ(9, 4), 732 - }, 733 - { 734 - .name = "Vbus_Imeasmax_change", 735 - .flags = IORESOURCE_IRQ, 736 - .start = AB5500_IRQ(9, 5), 737 - .end = AB5500_IRQ(9, 6), 738 - }, 739 - { 740 - .name = "OVV", 741 - .flags = IORESOURCE_IRQ, 742 - .start = AB5500_IRQ(14, 5), 743 - .end = AB5500_IRQ(14, 5), 744 - }, 745 - { 746 - .name = "USBcharging_NOTok", 747 - .flags = IORESOURCE_IRQ, 748 - .start = AB5500_IRQ(15, 3), 749 - .end = AB5500_IRQ(15, 3), 750 - }, 751 - { 752 - .name = "usb_adp_sensoroff", 753 - .flags = IORESOURCE_IRQ, 754 - .start = AB5500_IRQ(15, 6), 755 - .end = AB5500_IRQ(15, 6), 756 - }, 757 - { 758 - .name = "usb_adp_probeplug", 759 - .flags = IORESOURCE_IRQ, 760 - .start = AB5500_IRQ(15, 7), 761 - .end = AB5500_IRQ(15, 7), 762 - }, 763 - { 764 - .name = "usb_adp_sinkerror", 765 - .flags = IORESOURCE_IRQ, 766 - .start = AB5500_IRQ(16, 0), 767 - .end = AB5500_IRQ(16, 6), 768 - }, 769 - { 770 - .name = "usb_adp_sourceerror", 771 - .flags = IORESOURCE_IRQ, 772 - .start = AB5500_IRQ(16, 1), 773 - .end = AB5500_IRQ(16, 1), 774 - }, 775 - { 776 - .name = "usb_idgnd_r", 777 - .flags = IORESOURCE_IRQ, 778 - .start = AB5500_IRQ(16, 2), 779 - .end = AB5500_IRQ(16, 2), 780 - }, 781 - { 782 - .name = "usb_idgnd_f", 783 - .flags = IORESOURCE_IRQ, 784 - .start = AB5500_IRQ(16, 3), 785 - .end = AB5500_IRQ(16, 3), 786 - }, 787 - { 788 - .name = "usb_iddetR1", 789 - .flags = IORESOURCE_IRQ, 790 - .start = AB5500_IRQ(16, 4), 791 - .end = AB5500_IRQ(16, 5), 792 - }, 793 - { 794 - .name = "usb_iddetR2", 795 - .flags = IORESOURCE_IRQ, 796 - .start = AB5500_IRQ(16, 6), 797 - .end = AB5500_IRQ(16, 7), 798 - }, 799 - { 800 - .name = "usb_iddetR3", 801 - .flags = IORESOURCE_IRQ, 802 - .start = AB5500_IRQ(17, 0), 803 - .end = AB5500_IRQ(17, 1), 804 - }, 805 - { 806 - .name = "usb_iddetR4", 807 - .flags = IORESOURCE_IRQ, 808 - .start = AB5500_IRQ(17, 2), 809 - .end = AB5500_IRQ(17, 3), 810 - }, 811 - { 812 - .name = "CharTempWindowOk", 813 - .flags = IORESOURCE_IRQ, 814 - .start = AB5500_IRQ(17, 7), 815 - .end = AB5500_IRQ(18, 0), 816 - }, 817 - { 818 - .name = "USB_SprDetect", 819 - .flags = IORESOURCE_IRQ, 820 - .start = AB5500_IRQ(18, 1), 821 - .end = AB5500_IRQ(18, 1), 822 - }, 823 - { 824 - .name = "usb_adp_probe_unplug", 825 - .flags = IORESOURCE_IRQ, 826 - .start = AB5500_IRQ(18, 2), 827 - .end = AB5500_IRQ(18, 2), 828 - }, 829 - { 830 - .name = "VBUSChDrop", 831 - .flags = IORESOURCE_IRQ, 832 - .start = AB5500_IRQ(18, 3), 833 - .end = AB5500_IRQ(18, 4), 834 - }, 835 - { 836 - .name = "dcio_char_rec_done", 837 - .flags = IORESOURCE_IRQ, 838 - .start = AB5500_IRQ(18, 5), 839 - .end = AB5500_IRQ(18, 5), 840 - }, 841 - { 842 - .name = "Charging_stopped_by_temp", 843 - .flags = IORESOURCE_IRQ, 844 - .start = AB5500_IRQ(18, 6), 845 - .end = AB5500_IRQ(18, 6), 846 - }, 847 - { 848 - .name = "CHGstate_11_SafeModeVBUS", 849 - .flags = IORESOURCE_IRQ, 850 - .start = AB5500_IRQ(21, 1), 851 - .end = AB5500_IRQ(21, 2), 852 - }, 853 - { 854 - .name = "CHGstate_12_comletedVBUS", 855 - .flags = IORESOURCE_IRQ, 856 - .start = AB5500_IRQ(21, 2), 857 - .end = AB5500_IRQ(21, 2), 858 - }, 859 - { 860 - .name = "CHGstate_13_completedVBUS", 861 - .flags = IORESOURCE_IRQ, 862 - .start = AB5500_IRQ(21, 3), 863 - .end = AB5500_IRQ(21, 3), 864 - }, 865 - { 866 - .name = "CHGstate_14_FullChgDCIO", 867 - .flags = IORESOURCE_IRQ, 868 - .start = AB5500_IRQ(21, 4), 869 - .end = AB5500_IRQ(21, 4), 870 - }, 871 - { 872 - .name = "CHGstate_15_SafeModeDCIO", 873 - .flags = IORESOURCE_IRQ, 874 - .start = AB5500_IRQ(21, 5), 875 - .end = AB5500_IRQ(21, 5), 876 - }, 877 - { 878 - .name = "CHGstate_16_OFFsuspendDCIO", 879 - .flags = IORESOURCE_IRQ, 880 - .start = AB5500_IRQ(21, 6), 881 - .end = AB5500_IRQ(21, 6), 882 - }, 883 - { 884 - .name = "CHGstate_17_completedDCIO", 885 - .flags = IORESOURCE_IRQ, 886 - .start = AB5500_IRQ(21, 7), 887 - .end = AB5500_IRQ(21, 7), 888 - }, 889 - }, 890 - }, 891 - [AB5500_DEVID_OTP] = { 892 - .name = "ab5500-otp", 893 - .id = AB5500_DEVID_OTP, 894 - }, 895 - [AB5500_DEVID_VIDEO] = { 896 - .name = "ab5500-video", 897 - .id = AB5500_DEVID_VIDEO, 898 - .num_resources = 1, 899 - .resources = (struct resource[]) { 900 - { 901 - .name = "plugTVdet", 902 - .flags = IORESOURCE_IRQ, 903 - .start = AB5500_IRQ(22, 2), 904 - .end = AB5500_IRQ(22, 2), 905 - }, 906 - }, 907 - }, 908 - [AB5500_DEVID_DBIECI] = { 909 - .name = "ab5500-dbieci", 910 - .id = AB5500_DEVID_DBIECI, 911 - .num_resources = 10, 912 - .resources = (struct resource[]) { 913 - { 914 - .name = "COLL", 915 - .flags = IORESOURCE_IRQ, 916 - .start = AB5500_IRQ(14, 0), 917 - .end = AB5500_IRQ(14, 0), 918 - }, 919 - { 920 - .name = "RESERR", 921 - .flags = IORESOURCE_IRQ, 922 - .start = AB5500_IRQ(14, 1), 923 - .end = AB5500_IRQ(14, 1), 924 - }, 925 - { 926 - .name = "FRAERR", 927 - .flags = IORESOURCE_IRQ, 928 - .start = AB5500_IRQ(14, 2), 929 - .end = AB5500_IRQ(14, 2), 930 - }, 931 - { 932 - .name = "COMERR", 933 - .flags = IORESOURCE_IRQ, 934 - .start = AB5500_IRQ(14, 3), 935 - .end = AB5500_IRQ(14, 3), 936 - }, 937 - { 938 - .name = "BSI_indicator", 939 - .flags = IORESOURCE_IRQ, 940 - .start = AB5500_IRQ(14, 4), 941 - .end = AB5500_IRQ(14, 4), 942 - }, 943 - { 944 - .name = "SPDSET", 945 - .flags = IORESOURCE_IRQ, 946 - .start = AB5500_IRQ(14, 6), 947 - .end = AB5500_IRQ(14, 6), 948 - }, 949 - { 950 - .name = "DSENT", 951 - .flags = IORESOURCE_IRQ, 952 - .start = AB5500_IRQ(14, 7), 953 - .end = AB5500_IRQ(14, 7), 954 - }, 955 - { 956 - .name = "DREC", 957 - .flags = IORESOURCE_IRQ, 958 - .start = AB5500_IRQ(15, 0), 959 - .end = AB5500_IRQ(15, 0), 960 - }, 961 - { 962 - .name = "ACCINT", 963 - .flags = IORESOURCE_IRQ, 964 - .start = AB5500_IRQ(15, 1), 965 - .end = AB5500_IRQ(15, 1), 966 - }, 967 - { 968 - .name = "NOPINT", 969 - .flags = IORESOURCE_IRQ, 970 - .start = AB5500_IRQ(15, 2), 971 - .end = AB5500_IRQ(15, 2), 972 - }, 973 - }, 974 - }, 975 - [AB5500_DEVID_ONSWA] = { 976 - .name = "ab5500-onswa", 977 - .id = AB5500_DEVID_ONSWA, 978 - .num_resources = 2, 979 - .resources = (struct resource[]) { 980 - { 981 - .name = "ONSWAn_rising", 982 - .flags = IORESOURCE_IRQ, 983 - .start = AB5500_IRQ(1, 3), 984 - .end = AB5500_IRQ(1, 3), 985 - }, 986 - { 987 - .name = "ONSWAn_falling", 988 - .flags = IORESOURCE_IRQ, 989 - .start = AB5500_IRQ(1, 4), 990 - .end = AB5500_IRQ(1, 4), 991 - }, 992 - }, 993 - }, 994 - }; 995 - 996 - /* 997 - * Functionality for getting/setting register values. 998 - */ 999 - int ab5500_get_register_interruptible_raw(struct ab5500 *ab, 1000 - u8 bank, u8 reg, 1001 - u8 *value) 1002 - { 1003 - int err; 1004 - 1005 - if (bank >= AB5500_NUM_BANKS) 1006 - return -EINVAL; 1007 - 1008 - err = mutex_lock_interruptible(&ab->access_mutex); 1009 - if (err) 1010 - return err; 1011 - err = db5500_prcmu_abb_read(bankinfo[bank].slave_addr, reg, value, 1); 1012 - 1013 - mutex_unlock(&ab->access_mutex); 1014 - return err; 1015 - } 1016 - 1017 - static int get_register_page_interruptible(struct ab5500 *ab, u8 bank, 1018 - u8 first_reg, u8 *regvals, u8 numregs) 1019 - { 1020 - int err; 1021 - 1022 - if (bank >= AB5500_NUM_BANKS) 1023 - return -EINVAL; 1024 - 1025 - err = mutex_lock_interruptible(&ab->access_mutex); 1026 - if (err) 1027 - return err; 1028 - 1029 - while (numregs) { 1030 - /* The hardware limit for get page is 4 */ 1031 - u8 curnum = min_t(u8, numregs, 4u); 1032 - 1033 - err = db5500_prcmu_abb_read(bankinfo[bank].slave_addr, 1034 - first_reg, regvals, curnum); 1035 - if (err) 1036 - goto out; 1037 - 1038 - numregs -= curnum; 1039 - first_reg += curnum; 1040 - regvals += curnum; 1041 - } 1042 - 1043 - out: 1044 - mutex_unlock(&ab->access_mutex); 1045 - return err; 1046 - } 1047 - 1048 - int ab5500_mask_and_set_register_interruptible_raw(struct ab5500 *ab, u8 bank, 1049 - u8 reg, u8 bitmask, u8 bitvalues) 1050 - { 1051 - int err = 0; 1052 - 1053 - if (bank >= AB5500_NUM_BANKS) 1054 - return -EINVAL; 1055 - 1056 - if (bitmask) { 1057 - u8 buf; 1058 - 1059 - err = mutex_lock_interruptible(&ab->access_mutex); 1060 - if (err) 1061 - return err; 1062 - 1063 - if (bitmask == 0xFF) /* No need to read in this case. */ 1064 - buf = bitvalues; 1065 - else { /* Read and modify the register value. */ 1066 - err = db5500_prcmu_abb_read(bankinfo[bank].slave_addr, 1067 - reg, &buf, 1); 1068 - if (err) 1069 - return err; 1070 - 1071 - buf = ((~bitmask & buf) | (bitmask & bitvalues)); 1072 - } 1073 - /* Write the new value. */ 1074 - err = db5500_prcmu_abb_write(bankinfo[bank].slave_addr, reg, 1075 - &buf, 1); 1076 - 1077 - mutex_unlock(&ab->access_mutex); 1078 - } 1079 - return err; 1080 - } 1081 - 1082 - static int 1083 - set_register_interruptible(struct ab5500 *ab, u8 bank, u8 reg, u8 value) 1084 - { 1085 - return ab5500_mask_and_set_register_interruptible_raw(ab, bank, reg, 1086 - 0xff, value); 1087 - } 1088 - 1089 - /* 1090 - * Read/write permission checking functions. 1091 - */ 1092 - static const struct ab5500_i2c_ranges *get_bankref(u8 devid, u8 bank) 1093 - { 1094 - u8 i; 1095 - 1096 - if (devid < AB5500_NUM_DEVICES) { 1097 - for (i = 0; i < ab5500_bank_ranges[devid].nbanks; i++) { 1098 - if (ab5500_bank_ranges[devid].bank[i].bankid == bank) 1099 - return &ab5500_bank_ranges[devid].bank[i]; 1100 - } 1101 - } 1102 - return NULL; 1103 - } 1104 - 1105 - static bool page_write_allowed(u8 devid, u8 bank, u8 first_reg, u8 last_reg) 1106 - { 1107 - u8 i; /* range loop index */ 1108 - const struct ab5500_i2c_ranges *bankref; 1109 - 1110 - bankref = get_bankref(devid, bank); 1111 - if (bankref == NULL || last_reg < first_reg) 1112 - return false; 1113 - 1114 - for (i = 0; i < bankref->nranges; i++) { 1115 - if (first_reg < bankref->range[i].first) 1116 - break; 1117 - if ((last_reg <= bankref->range[i].last) && 1118 - (bankref->range[i].perm & AB5500_PERM_WR)) 1119 - return true; 1120 - } 1121 - return false; 1122 - } 1123 - 1124 - static bool reg_write_allowed(u8 devid, u8 bank, u8 reg) 1125 - { 1126 - return page_write_allowed(devid, bank, reg, reg); 1127 - } 1128 - 1129 - static bool page_read_allowed(u8 devid, u8 bank, u8 first_reg, u8 last_reg) 1130 - { 1131 - u8 i; 1132 - const struct ab5500_i2c_ranges *bankref; 1133 - 1134 - bankref = get_bankref(devid, bank); 1135 - if (bankref == NULL || last_reg < first_reg) 1136 - return false; 1137 - 1138 - 1139 - /* Find the range (if it exists in the list) that includes first_reg. */ 1140 - for (i = 0; i < bankref->nranges; i++) { 1141 - if (first_reg < bankref->range[i].first) 1142 - return false; 1143 - if (first_reg <= bankref->range[i].last) 1144 - break; 1145 - } 1146 - /* Make sure that the entire range up to and including last_reg is 1147 - * readable. This may span several of the ranges in the list. 1148 - */ 1149 - while ((i < bankref->nranges) && 1150 - (bankref->range[i].perm & AB5500_PERM_RD)) { 1151 - if (last_reg <= bankref->range[i].last) 1152 - return true; 1153 - if ((++i >= bankref->nranges) || 1154 - (bankref->range[i].first != 1155 - (bankref->range[i - 1].last + 1))) { 1156 - break; 1157 - } 1158 - } 1159 - return false; 1160 - } 1161 - 1162 - static bool reg_read_allowed(u8 devid, u8 bank, u8 reg) 1163 - { 1164 - return page_read_allowed(devid, bank, reg, reg); 1165 - } 1166 - 1167 - 1168 - /* 1169 - * The exported register access functionality. 1170 - */ 1171 - static int ab5500_get_chip_id(struct device *dev) 1172 - { 1173 - struct ab5500 *ab = dev_get_drvdata(dev->parent); 1174 - 1175 - return (int)ab->chip_id; 1176 - } 1177 - 1178 - static int ab5500_mask_and_set_register_interruptible(struct device *dev, 1179 - u8 bank, u8 reg, u8 bitmask, u8 bitvalues) 1180 - { 1181 - struct ab5500 *ab; 1182 - struct platform_device *pdev = to_platform_device(dev); 1183 - 1184 - if ((AB5500_NUM_BANKS <= bank) || 1185 - !reg_write_allowed(pdev->id, bank, reg)) 1186 - return -EINVAL; 1187 - 1188 - ab = dev_get_drvdata(dev->parent); 1189 - return ab5500_mask_and_set_register_interruptible_raw(ab, bank, reg, 1190 - bitmask, bitvalues); 1191 - } 1192 - 1193 - static int ab5500_set_register_interruptible(struct device *dev, u8 bank, 1194 - u8 reg, u8 value) 1195 - { 1196 - return ab5500_mask_and_set_register_interruptible(dev, bank, reg, 0xFF, 1197 - value); 1198 - } 1199 - 1200 - static int ab5500_get_register_interruptible(struct device *dev, u8 bank, 1201 - u8 reg, u8 *value) 1202 - { 1203 - struct ab5500 *ab; 1204 - struct platform_device *pdev = to_platform_device(dev); 1205 - 1206 - if ((AB5500_NUM_BANKS <= bank) || 1207 - !reg_read_allowed(pdev->id, bank, reg)) 1208 - return -EINVAL; 1209 - 1210 - ab = dev_get_drvdata(dev->parent); 1211 - return ab5500_get_register_interruptible_raw(ab, bank, reg, value); 1212 - } 1213 - 1214 - static int ab5500_get_register_page_interruptible(struct device *dev, u8 bank, 1215 - u8 first_reg, u8 *regvals, u8 numregs) 1216 - { 1217 - struct ab5500 *ab; 1218 - struct platform_device *pdev = to_platform_device(dev); 1219 - 1220 - if ((AB5500_NUM_BANKS <= bank) || 1221 - !page_read_allowed(pdev->id, bank, 1222 - first_reg, (first_reg + numregs - 1))) 1223 - return -EINVAL; 1224 - 1225 - ab = dev_get_drvdata(dev->parent); 1226 - return get_register_page_interruptible(ab, bank, first_reg, regvals, 1227 - numregs); 1228 - } 1229 - 1230 - static int 1231 - ab5500_event_registers_startup_state_get(struct device *dev, u8 *event) 1232 - { 1233 - struct ab5500 *ab; 1234 - 1235 - ab = dev_get_drvdata(dev->parent); 1236 - if (!ab->startup_events_read) 1237 - return -EAGAIN; /* Try again later */ 1238 - 1239 - memcpy(event, ab->startup_events, AB5500_NUM_EVENT_REG); 1240 - return 0; 1241 - } 1242 - 1243 - static struct abx500_ops ab5500_ops = { 1244 - .get_chip_id = ab5500_get_chip_id, 1245 - .get_register = ab5500_get_register_interruptible, 1246 - .set_register = ab5500_set_register_interruptible, 1247 - .get_register_page = ab5500_get_register_page_interruptible, 1248 - .set_register_page = NULL, 1249 - .mask_and_set_register = ab5500_mask_and_set_register_interruptible, 1250 - .event_registers_startup_state_get = 1251 - ab5500_event_registers_startup_state_get, 1252 - .startup_irq_enabled = NULL, 1253 - }; 1254 - 1255 - /* 1256 - * ab5500_setup : Basic set-up, datastructure creation/destruction 1257 - * and I2C interface.This sets up a default config 1258 - * in the AB5500 chip so that it will work as expected. 1259 - * @ab : Pointer to ab5500 structure 1260 - * @settings : Pointer to struct abx500_init_settings 1261 - * @size : Size of init data 1262 - */ 1263 - static int __init ab5500_setup(struct ab5500 *ab, 1264 - struct abx500_init_settings *settings, unsigned int size) 1265 - { 1266 - int err = 0; 1267 - int i; 1268 - 1269 - for (i = 0; i < size; i++) { 1270 - err = ab5500_mask_and_set_register_interruptible_raw(ab, 1271 - settings[i].bank, 1272 - settings[i].reg, 1273 - 0xFF, settings[i].setting); 1274 - if (err) 1275 - goto exit_no_setup; 1276 - 1277 - /* If event mask register update the event mask in ab5500 */ 1278 - if ((settings[i].bank == AB5500_BANK_IT) && 1279 - (AB5500_MASK_BASE <= settings[i].reg) && 1280 - (settings[i].reg <= AB5500_MASK_END)) { 1281 - ab->mask[settings[i].reg - AB5500_MASK_BASE] = 1282 - settings[i].setting; 1283 - } 1284 - } 1285 - exit_no_setup: 1286 - return err; 1287 - } 1288 - 1289 - struct ab_family_id { 1290 - u8 id; 1291 - char *name; 1292 - }; 1293 - 1294 - static const struct ab_family_id ids[] __initdata = { 1295 - /* AB5500 */ 1296 - { 1297 - .id = AB5500_1_0, 1298 - .name = "1.0" 1299 - }, 1300 - { 1301 - .id = AB5500_1_1, 1302 - .name = "1.1" 1303 - }, 1304 - /* Terminator */ 1305 - { 1306 - .id = 0x00, 1307 - } 1308 - }; 1309 - 1310 - static int __init ab5500_probe(struct platform_device *pdev) 1311 - { 1312 - struct ab5500 *ab; 1313 - struct ab5500_platform_data *ab5500_plf_data = 1314 - pdev->dev.platform_data; 1315 - int err; 1316 - int i; 1317 - 1318 - ab = kzalloc(sizeof(struct ab5500), GFP_KERNEL); 1319 - if (!ab) { 1320 - dev_err(&pdev->dev, 1321 - "could not allocate ab5500 device\n"); 1322 - return -ENOMEM; 1323 - } 1324 - 1325 - /* Initialize data structure */ 1326 - mutex_init(&ab->access_mutex); 1327 - mutex_init(&ab->irq_lock); 1328 - ab->dev = &pdev->dev; 1329 - 1330 - platform_set_drvdata(pdev, ab); 1331 - 1332 - /* Read chip ID register */ 1333 - err = ab5500_get_register_interruptible_raw(ab, 1334 - AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP, 1335 - AB5500_CHIP_ID, &ab->chip_id); 1336 - if (err) { 1337 - dev_err(&pdev->dev, "could not communicate with the analog " 1338 - "baseband chip\n"); 1339 - goto exit_no_detect; 1340 - } 1341 - 1342 - for (i = 0; ids[i].id != 0x0; i++) { 1343 - if (ids[i].id == ab->chip_id) { 1344 - snprintf(&ab->chip_name[0], sizeof(ab->chip_name) - 1, 1345 - "AB5500 %s", ids[i].name); 1346 - break; 1347 - } 1348 - } 1349 - if (ids[i].id == 0x0) { 1350 - dev_err(&pdev->dev, "unknown analog baseband chip id: 0x%x\n", 1351 - ab->chip_id); 1352 - dev_err(&pdev->dev, "driver not started!\n"); 1353 - goto exit_no_detect; 1354 - } 1355 - 1356 - /* Clear and mask all interrupts */ 1357 - for (i = 0; i < AB5500_NUM_IRQ_REGS; i++) { 1358 - u8 latchreg = AB5500_IT_LATCH0_REG + i; 1359 - u8 maskreg = AB5500_IT_MASK0_REG + i; 1360 - u8 val; 1361 - 1362 - ab5500_get_register_interruptible_raw(ab, AB5500_BANK_IT, 1363 - latchreg, &val); 1364 - set_register_interruptible(ab, AB5500_BANK_IT, maskreg, 0xff); 1365 - ab->mask[i] = ab->oldmask[i] = 0xff; 1366 - } 1367 - 1368 - err = abx500_register_ops(&pdev->dev, &ab5500_ops); 1369 - if (err) { 1370 - dev_err(&pdev->dev, "ab5500_register ops error\n"); 1371 - goto exit_no_detect; 1372 - } 1373 - 1374 - /* Set up and register the platform devices. */ 1375 - for (i = 0; i < AB5500_NUM_DEVICES; i++) { 1376 - ab5500_devs[i].platform_data = ab5500_plf_data->dev_data[i]; 1377 - ab5500_devs[i].pdata_size = 1378 - sizeof(ab5500_plf_data->dev_data[i]); 1379 - } 1380 - 1381 - err = mfd_add_devices(&pdev->dev, 0, ab5500_devs, 1382 - ARRAY_SIZE(ab5500_devs), NULL, 1383 - ab5500_plf_data->irq.base); 1384 - if (err) { 1385 - dev_err(&pdev->dev, "ab5500_mfd_add_device error\n"); 1386 - goto exit_no_detect; 1387 - } 1388 - 1389 - err = ab5500_setup(ab, ab5500_plf_data->init_settings, 1390 - ab5500_plf_data->init_settings_sz); 1391 - if (err) { 1392 - dev_err(&pdev->dev, "ab5500_setup error\n"); 1393 - goto exit_no_detect; 1394 - } 1395 - 1396 - ab5500_setup_debugfs(ab); 1397 - 1398 - dev_info(&pdev->dev, "detected AB chip: %s\n", &ab->chip_name[0]); 1399 - return 0; 1400 - 1401 - exit_no_detect: 1402 - kfree(ab); 1403 - return err; 1404 - } 1405 - 1406 - static int __exit ab5500_remove(struct platform_device *pdev) 1407 - { 1408 - struct ab5500 *ab = platform_get_drvdata(pdev); 1409 - 1410 - ab5500_remove_debugfs(); 1411 - mfd_remove_devices(&pdev->dev); 1412 - kfree(ab); 1413 - return 0; 1414 - } 1415 - 1416 - static struct platform_driver ab5500_driver = { 1417 - .driver = { 1418 - .name = "ab5500-core", 1419 - .owner = THIS_MODULE, 1420 - }, 1421 - .remove = __exit_p(ab5500_remove), 1422 - }; 1423 - 1424 - static int __init ab5500_core_init(void) 1425 - { 1426 - return platform_driver_probe(&ab5500_driver, ab5500_probe); 1427 - } 1428 - 1429 - static void __exit ab5500_core_exit(void) 1430 - { 1431 - platform_driver_unregister(&ab5500_driver); 1432 - } 1433 - 1434 - subsys_initcall(ab5500_core_init); 1435 - module_exit(ab5500_core_exit); 1436 - 1437 - MODULE_AUTHOR("Mattias Wallin <mattias.wallin@stericsson.com>"); 1438 - MODULE_DESCRIPTION("AB5500 core driver"); 1439 - MODULE_LICENSE("GPL");
-807
drivers/mfd/ab5500-debugfs.c
··· 1 - /* 2 - * Copyright (C) 2011 ST-Ericsson 3 - * License terms: GNU General Public License (GPL) version 2 4 - * Debugfs support for the AB5500 MFD driver 5 - */ 6 - 7 - #include <linux/module.h> 8 - #include <linux/debugfs.h> 9 - #include <linux/seq_file.h> 10 - #include <linux/mfd/abx500.h> 11 - #include <linux/mfd/abx500/ab5500.h> 12 - #include <linux/uaccess.h> 13 - 14 - #include "ab5500-core.h" 15 - #include "ab5500-debugfs.h" 16 - 17 - static struct ab5500_i2c_ranges ab5500_reg_ranges[AB5500_NUM_BANKS] = { 18 - [AB5500_BANK_LED] = { 19 - .bankid = AB5500_BANK_LED, 20 - .nranges = 1, 21 - .range = (struct ab5500_reg_range[]) { 22 - { 23 - .first = 0x00, 24 - .last = 0x0C, 25 - .perm = AB5500_PERM_RW, 26 - }, 27 - }, 28 - }, 29 - [AB5500_BANK_ADC] = { 30 - .bankid = AB5500_BANK_ADC, 31 - .nranges = 6, 32 - .range = (struct ab5500_reg_range[]) { 33 - { 34 - .first = 0x1F, 35 - .last = 0x22, 36 - .perm = AB5500_PERM_RO, 37 - }, 38 - { 39 - .first = 0x23, 40 - .last = 0x24, 41 - .perm = AB5500_PERM_RW, 42 - }, 43 - { 44 - .first = 0x26, 45 - .last = 0x2D, 46 - .perm = AB5500_PERM_RO, 47 - }, 48 - { 49 - .first = 0x2F, 50 - .last = 0x34, 51 - .perm = AB5500_PERM_RW, 52 - }, 53 - { 54 - .first = 0x37, 55 - .last = 0x57, 56 - .perm = AB5500_PERM_RW, 57 - }, 58 - { 59 - .first = 0x58, 60 - .last = 0x58, 61 - .perm = AB5500_PERM_RO, 62 - }, 63 - }, 64 - }, 65 - [AB5500_BANK_RTC] = { 66 - .bankid = AB5500_BANK_RTC, 67 - .nranges = 2, 68 - .range = (struct ab5500_reg_range[]) { 69 - { 70 - .first = 0x00, 71 - .last = 0x04, 72 - .perm = AB5500_PERM_RW, 73 - }, 74 - { 75 - .first = 0x06, 76 - .last = 0x0C, 77 - .perm = AB5500_PERM_RW, 78 - }, 79 - }, 80 - }, 81 - [AB5500_BANK_STARTUP] = { 82 - .bankid = AB5500_BANK_STARTUP, 83 - .nranges = 12, 84 - .range = (struct ab5500_reg_range[]) { 85 - { 86 - .first = 0x00, 87 - .last = 0x01, 88 - .perm = AB5500_PERM_RW, 89 - }, 90 - { 91 - .first = 0x1F, 92 - .last = 0x1F, 93 - .perm = AB5500_PERM_RW, 94 - }, 95 - { 96 - .first = 0x2E, 97 - .last = 0x2E, 98 - .perm = AB5500_PERM_RO, 99 - }, 100 - { 101 - .first = 0x2F, 102 - .last = 0x30, 103 - .perm = AB5500_PERM_RW, 104 - }, 105 - { 106 - .first = 0x50, 107 - .last = 0x51, 108 - .perm = AB5500_PERM_RW, 109 - }, 110 - { 111 - .first = 0x60, 112 - .last = 0x61, 113 - .perm = AB5500_PERM_RW, 114 - }, 115 - { 116 - .first = 0x66, 117 - .last = 0x8A, 118 - .perm = AB5500_PERM_RW, 119 - }, 120 - { 121 - .first = 0x8C, 122 - .last = 0x96, 123 - .perm = AB5500_PERM_RW, 124 - }, 125 - { 126 - .first = 0xAA, 127 - .last = 0xB4, 128 - .perm = AB5500_PERM_RW, 129 - }, 130 - { 131 - .first = 0xB7, 132 - .last = 0xBF, 133 - .perm = AB5500_PERM_RW, 134 - }, 135 - { 136 - .first = 0xC1, 137 - .last = 0xCA, 138 - .perm = AB5500_PERM_RW, 139 - }, 140 - { 141 - .first = 0xD3, 142 - .last = 0xE0, 143 - .perm = AB5500_PERM_RW, 144 - }, 145 - }, 146 - }, 147 - [AB5500_BANK_DBI_ECI] = { 148 - .bankid = AB5500_BANK_DBI_ECI, 149 - .nranges = 3, 150 - .range = (struct ab5500_reg_range[]) { 151 - { 152 - .first = 0x00, 153 - .last = 0x07, 154 - .perm = AB5500_PERM_RW, 155 - }, 156 - { 157 - .first = 0x10, 158 - .last = 0x10, 159 - .perm = AB5500_PERM_RW, 160 - }, 161 - { 162 - .first = 0x13, 163 - .last = 0x13, 164 - .perm = AB5500_PERM_RW, 165 - }, 166 - }, 167 - }, 168 - [AB5500_BANK_CHG] = { 169 - .bankid = AB5500_BANK_CHG, 170 - .nranges = 2, 171 - .range = (struct ab5500_reg_range[]) { 172 - { 173 - .first = 0x11, 174 - .last = 0x11, 175 - .perm = AB5500_PERM_RO, 176 - }, 177 - { 178 - .first = 0x12, 179 - .last = 0x1B, 180 - .perm = AB5500_PERM_RW, 181 - }, 182 - }, 183 - }, 184 - [AB5500_BANK_FG_BATTCOM_ACC] = { 185 - .bankid = AB5500_BANK_FG_BATTCOM_ACC, 186 - .nranges = 2, 187 - .range = (struct ab5500_reg_range[]) { 188 - { 189 - .first = 0x00, 190 - .last = 0x0B, 191 - .perm = AB5500_PERM_RO, 192 - }, 193 - { 194 - .first = 0x0C, 195 - .last = 0x10, 196 - .perm = AB5500_PERM_RW, 197 - }, 198 - }, 199 - }, 200 - [AB5500_BANK_USB] = { 201 - .bankid = AB5500_BANK_USB, 202 - .nranges = 12, 203 - .range = (struct ab5500_reg_range[]) { 204 - { 205 - .first = 0x01, 206 - .last = 0x01, 207 - .perm = AB5500_PERM_RW, 208 - }, 209 - { 210 - .first = 0x80, 211 - .last = 0x83, 212 - .perm = AB5500_PERM_RW, 213 - }, 214 - { 215 - .first = 0x87, 216 - .last = 0x8A, 217 - .perm = AB5500_PERM_RW, 218 - }, 219 - { 220 - .first = 0x8B, 221 - .last = 0x8B, 222 - .perm = AB5500_PERM_RO, 223 - }, 224 - { 225 - .first = 0x91, 226 - .last = 0x92, 227 - .perm = AB5500_PERM_RO, 228 - }, 229 - { 230 - .first = 0x93, 231 - .last = 0x93, 232 - .perm = AB5500_PERM_RW, 233 - }, 234 - { 235 - .first = 0x94, 236 - .last = 0x94, 237 - .perm = AB5500_PERM_RO, 238 - }, 239 - { 240 - .first = 0xA8, 241 - .last = 0xB0, 242 - .perm = AB5500_PERM_RO, 243 - }, 244 - { 245 - .first = 0xB2, 246 - .last = 0xB2, 247 - .perm = AB5500_PERM_RO, 248 - }, 249 - { 250 - .first = 0xB4, 251 - .last = 0xBC, 252 - .perm = AB5500_PERM_RO, 253 - }, 254 - { 255 - .first = 0xBF, 256 - .last = 0xBF, 257 - .perm = AB5500_PERM_RO, 258 - }, 259 - { 260 - .first = 0xC1, 261 - .last = 0xC5, 262 - .perm = AB5500_PERM_RO, 263 - }, 264 - }, 265 - }, 266 - [AB5500_BANK_IT] = { 267 - .bankid = AB5500_BANK_IT, 268 - .nranges = 4, 269 - .range = (struct ab5500_reg_range[]) { 270 - { 271 - .first = 0x00, 272 - .last = 0x02, 273 - .perm = AB5500_PERM_RO, 274 - }, 275 - { 276 - .first = 0x20, 277 - .last = 0x36, 278 - .perm = AB5500_PERM_RO, 279 - }, 280 - { 281 - .first = 0x40, 282 - .last = 0x56, 283 - .perm = AB5500_PERM_RO, 284 - }, 285 - { 286 - .first = 0x60, 287 - .last = 0x76, 288 - .perm = AB5500_PERM_RO, 289 - }, 290 - }, 291 - }, 292 - [AB5500_BANK_VDDDIG_IO_I2C_CLK_TST] = { 293 - .bankid = AB5500_BANK_VDDDIG_IO_I2C_CLK_TST, 294 - .nranges = 7, 295 - .range = (struct ab5500_reg_range[]) { 296 - { 297 - .first = 0x02, 298 - .last = 0x02, 299 - .perm = AB5500_PERM_RW, 300 - }, 301 - { 302 - .first = 0x12, 303 - .last = 0x12, 304 - .perm = AB5500_PERM_RW, 305 - }, 306 - { 307 - .first = 0x30, 308 - .last = 0x34, 309 - .perm = AB5500_PERM_RW, 310 - }, 311 - { 312 - .first = 0x40, 313 - .last = 0x44, 314 - .perm = AB5500_PERM_RW, 315 - }, 316 - { 317 - .first = 0x50, 318 - .last = 0x54, 319 - .perm = AB5500_PERM_RW, 320 - }, 321 - { 322 - .first = 0x60, 323 - .last = 0x64, 324 - .perm = AB5500_PERM_RW, 325 - }, 326 - { 327 - .first = 0x70, 328 - .last = 0x74, 329 - .perm = AB5500_PERM_RW, 330 - }, 331 - }, 332 - }, 333 - [AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP] = { 334 - .bankid = AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP, 335 - .nranges = 13, 336 - .range = (struct ab5500_reg_range[]) { 337 - { 338 - .first = 0x01, 339 - .last = 0x01, 340 - .perm = AB5500_PERM_RW, 341 - }, 342 - { 343 - .first = 0x02, 344 - .last = 0x02, 345 - .perm = AB5500_PERM_RO, 346 - }, 347 - { 348 - .first = 0x0D, 349 - .last = 0x0F, 350 - .perm = AB5500_PERM_RW, 351 - }, 352 - { 353 - .first = 0x1C, 354 - .last = 0x1C, 355 - .perm = AB5500_PERM_RW, 356 - }, 357 - { 358 - .first = 0x1E, 359 - .last = 0x1E, 360 - .perm = AB5500_PERM_RW, 361 - }, 362 - { 363 - .first = 0x20, 364 - .last = 0x21, 365 - .perm = AB5500_PERM_RW, 366 - }, 367 - { 368 - .first = 0x25, 369 - .last = 0x25, 370 - .perm = AB5500_PERM_RW, 371 - }, 372 - { 373 - .first = 0x28, 374 - .last = 0x2A, 375 - .perm = AB5500_PERM_RW, 376 - }, 377 - { 378 - .first = 0x30, 379 - .last = 0x33, 380 - .perm = AB5500_PERM_RW, 381 - }, 382 - { 383 - .first = 0x40, 384 - .last = 0x43, 385 - .perm = AB5500_PERM_RW, 386 - }, 387 - { 388 - .first = 0x50, 389 - .last = 0x53, 390 - .perm = AB5500_PERM_RW, 391 - }, 392 - { 393 - .first = 0x60, 394 - .last = 0x63, 395 - .perm = AB5500_PERM_RW, 396 - }, 397 - { 398 - .first = 0x70, 399 - .last = 0x73, 400 - .perm = AB5500_PERM_RW, 401 - }, 402 - }, 403 - }, 404 - [AB5500_BANK_VIBRA] = { 405 - .bankid = AB5500_BANK_VIBRA, 406 - .nranges = 2, 407 - .range = (struct ab5500_reg_range[]) { 408 - { 409 - .first = 0x10, 410 - .last = 0x13, 411 - .perm = AB5500_PERM_RW, 412 - }, 413 - { 414 - .first = 0xFE, 415 - .last = 0xFE, 416 - .perm = AB5500_PERM_RW, 417 - }, 418 - }, 419 - }, 420 - [AB5500_BANK_AUDIO_HEADSETUSB] = { 421 - .bankid = AB5500_BANK_AUDIO_HEADSETUSB, 422 - .nranges = 2, 423 - .range = (struct ab5500_reg_range[]) { 424 - { 425 - .first = 0x00, 426 - .last = 0x48, 427 - .perm = AB5500_PERM_RW, 428 - }, 429 - { 430 - .first = 0xEB, 431 - .last = 0xFB, 432 - .perm = AB5500_PERM_RW, 433 - }, 434 - }, 435 - }, 436 - [AB5500_BANK_SIM_USBSIM] = { 437 - .bankid = AB5500_BANK_SIM_USBSIM, 438 - .nranges = 1, 439 - .range = (struct ab5500_reg_range[]) { 440 - { 441 - .first = 0x13, 442 - .last = 0x19, 443 - .perm = AB5500_PERM_RW, 444 - }, 445 - }, 446 - }, 447 - [AB5500_BANK_VDENC] = { 448 - .bankid = AB5500_BANK_VDENC, 449 - .nranges = 12, 450 - .range = (struct ab5500_reg_range[]) { 451 - { 452 - .first = 0x00, 453 - .last = 0x08, 454 - .perm = AB5500_PERM_RW, 455 - }, 456 - { 457 - .first = 0x09, 458 - .last = 0x09, 459 - .perm = AB5500_PERM_RO, 460 - }, 461 - { 462 - .first = 0x0A, 463 - .last = 0x12, 464 - .perm = AB5500_PERM_RW, 465 - }, 466 - { 467 - .first = 0x15, 468 - .last = 0x19, 469 - .perm = AB5500_PERM_RW, 470 - }, 471 - { 472 - .first = 0x1B, 473 - .last = 0x21, 474 - .perm = AB5500_PERM_RW, 475 - }, 476 - { 477 - .first = 0x27, 478 - .last = 0x2C, 479 - .perm = AB5500_PERM_RW, 480 - }, 481 - { 482 - .first = 0x41, 483 - .last = 0x41, 484 - .perm = AB5500_PERM_RW, 485 - }, 486 - { 487 - .first = 0x45, 488 - .last = 0x5B, 489 - .perm = AB5500_PERM_RW, 490 - }, 491 - { 492 - .first = 0x5D, 493 - .last = 0x5D, 494 - .perm = AB5500_PERM_RW, 495 - }, 496 - { 497 - .first = 0x69, 498 - .last = 0x69, 499 - .perm = AB5500_PERM_RW, 500 - }, 501 - { 502 - .first = 0x6C, 503 - .last = 0x6D, 504 - .perm = AB5500_PERM_RW, 505 - }, 506 - { 507 - .first = 0x80, 508 - .last = 0x81, 509 - .perm = AB5500_PERM_RW, 510 - }, 511 - }, 512 - }, 513 - }; 514 - 515 - static int ab5500_registers_print(struct seq_file *s, void *p) 516 - { 517 - struct ab5500 *ab = s->private; 518 - unsigned int i; 519 - u8 bank = (u8)ab->debug_bank; 520 - 521 - seq_printf(s, "ab5500 register values:\n"); 522 - for (bank = 0; bank < AB5500_NUM_BANKS; bank++) { 523 - seq_printf(s, " bank %u, %s (0x%x):\n", bank, 524 - bankinfo[bank].name, 525 - bankinfo[bank].slave_addr); 526 - for (i = 0; i < ab5500_reg_ranges[bank].nranges; i++) { 527 - u8 reg; 528 - int err; 529 - 530 - for (reg = ab5500_reg_ranges[bank].range[i].first; 531 - reg <= ab5500_reg_ranges[bank].range[i].last; 532 - reg++) { 533 - u8 value; 534 - 535 - err = ab5500_get_register_interruptible_raw(ab, 536 - bank, reg, 537 - &value); 538 - if (err < 0) { 539 - dev_err(ab->dev, "get_reg failed %d" 540 - "bank 0x%x reg 0x%x\n", 541 - err, bank, reg); 542 - return err; 543 - } 544 - 545 - err = seq_printf(s, "[%d/0x%02X]: 0x%02X\n", 546 - bank, reg, value); 547 - if (err < 0) { 548 - dev_err(ab->dev, 549 - "seq_printf overflow\n"); 550 - /* 551 - * Error is not returned here since 552 - * the output is wanted in any case 553 - */ 554 - return 0; 555 - } 556 - } 557 - } 558 - } 559 - return 0; 560 - } 561 - 562 - static int ab5500_registers_open(struct inode *inode, struct file *file) 563 - { 564 - return single_open(file, ab5500_registers_print, inode->i_private); 565 - } 566 - 567 - static const struct file_operations ab5500_registers_fops = { 568 - .open = ab5500_registers_open, 569 - .read = seq_read, 570 - .llseek = seq_lseek, 571 - .release = single_release, 572 - .owner = THIS_MODULE, 573 - }; 574 - 575 - static int ab5500_bank_print(struct seq_file *s, void *p) 576 - { 577 - struct ab5500 *ab = s->private; 578 - 579 - seq_printf(s, "%d\n", ab->debug_bank); 580 - return 0; 581 - } 582 - 583 - static int ab5500_bank_open(struct inode *inode, struct file *file) 584 - { 585 - return single_open(file, ab5500_bank_print, inode->i_private); 586 - } 587 - 588 - static ssize_t ab5500_bank_write(struct file *file, 589 - const char __user *user_buf, 590 - size_t count, loff_t *ppos) 591 - { 592 - struct ab5500 *ab = ((struct seq_file *)(file->private_data))->private; 593 - char buf[32]; 594 - int buf_size; 595 - unsigned long user_bank; 596 - int err; 597 - 598 - /* Get userspace string and assure termination */ 599 - buf_size = min(count, (sizeof(buf) - 1)); 600 - if (copy_from_user(buf, user_buf, buf_size)) 601 - return -EFAULT; 602 - buf[buf_size] = 0; 603 - 604 - err = strict_strtoul(buf, 0, &user_bank); 605 - if (err) 606 - return -EINVAL; 607 - 608 - if (user_bank >= AB5500_NUM_BANKS) { 609 - dev_err(ab->dev, 610 - "debugfs error input > number of banks\n"); 611 - return -EINVAL; 612 - } 613 - 614 - ab->debug_bank = user_bank; 615 - 616 - return buf_size; 617 - } 618 - 619 - static int ab5500_address_print(struct seq_file *s, void *p) 620 - { 621 - struct ab5500 *ab = s->private; 622 - 623 - seq_printf(s, "0x%02X\n", ab->debug_address); 624 - return 0; 625 - } 626 - 627 - static int ab5500_address_open(struct inode *inode, struct file *file) 628 - { 629 - return single_open(file, ab5500_address_print, inode->i_private); 630 - } 631 - 632 - static ssize_t ab5500_address_write(struct file *file, 633 - const char __user *user_buf, 634 - size_t count, loff_t *ppos) 635 - { 636 - struct ab5500 *ab = ((struct seq_file *)(file->private_data))->private; 637 - char buf[32]; 638 - int buf_size; 639 - unsigned long user_address; 640 - int err; 641 - 642 - /* Get userspace string and assure termination */ 643 - buf_size = min(count, (sizeof(buf) - 1)); 644 - if (copy_from_user(buf, user_buf, buf_size)) 645 - return -EFAULT; 646 - buf[buf_size] = 0; 647 - 648 - err = strict_strtoul(buf, 0, &user_address); 649 - if (err) 650 - return -EINVAL; 651 - if (user_address > 0xff) { 652 - dev_err(ab->dev, 653 - "debugfs error input > 0xff\n"); 654 - return -EINVAL; 655 - } 656 - ab->debug_address = user_address; 657 - return buf_size; 658 - } 659 - 660 - static int ab5500_val_print(struct seq_file *s, void *p) 661 - { 662 - struct ab5500 *ab = s->private; 663 - int err; 664 - u8 regvalue; 665 - 666 - err = ab5500_get_register_interruptible_raw(ab, (u8)ab->debug_bank, 667 - (u8)ab->debug_address, &regvalue); 668 - if (err) { 669 - dev_err(ab->dev, "get_reg failed %d, bank 0x%x" 670 - ", reg 0x%x\n", err, ab->debug_bank, 671 - ab->debug_address); 672 - return -EINVAL; 673 - } 674 - seq_printf(s, "0x%02X\n", regvalue); 675 - 676 - return 0; 677 - } 678 - 679 - static int ab5500_val_open(struct inode *inode, struct file *file) 680 - { 681 - return single_open(file, ab5500_val_print, inode->i_private); 682 - } 683 - 684 - static ssize_t ab5500_val_write(struct file *file, 685 - const char __user *user_buf, 686 - size_t count, loff_t *ppos) 687 - { 688 - struct ab5500 *ab = ((struct seq_file *)(file->private_data))->private; 689 - char buf[32]; 690 - int buf_size; 691 - unsigned long user_val; 692 - int err; 693 - u8 regvalue; 694 - 695 - /* Get userspace string and assure termination */ 696 - buf_size = min(count, (sizeof(buf)-1)); 697 - if (copy_from_user(buf, user_buf, buf_size)) 698 - return -EFAULT; 699 - buf[buf_size] = 0; 700 - 701 - err = strict_strtoul(buf, 0, &user_val); 702 - if (err) 703 - return -EINVAL; 704 - if (user_val > 0xff) { 705 - dev_err(ab->dev, 706 - "debugfs error input > 0xff\n"); 707 - return -EINVAL; 708 - } 709 - err = ab5500_mask_and_set_register_interruptible_raw( 710 - ab, (u8)ab->debug_bank, 711 - (u8)ab->debug_address, 0xFF, (u8)user_val); 712 - if (err) 713 - return -EINVAL; 714 - 715 - ab5500_get_register_interruptible_raw(ab, (u8)ab->debug_bank, 716 - (u8)ab->debug_address, &regvalue); 717 - if (err) 718 - return -EINVAL; 719 - 720 - return buf_size; 721 - } 722 - 723 - static const struct file_operations ab5500_bank_fops = { 724 - .open = ab5500_bank_open, 725 - .write = ab5500_bank_write, 726 - .read = seq_read, 727 - .llseek = seq_lseek, 728 - .release = single_release, 729 - .owner = THIS_MODULE, 730 - }; 731 - 732 - static const struct file_operations ab5500_address_fops = { 733 - .open = ab5500_address_open, 734 - .write = ab5500_address_write, 735 - .read = seq_read, 736 - .llseek = seq_lseek, 737 - .release = single_release, 738 - .owner = THIS_MODULE, 739 - }; 740 - 741 - static const struct file_operations ab5500_val_fops = { 742 - .open = ab5500_val_open, 743 - .write = ab5500_val_write, 744 - .read = seq_read, 745 - .llseek = seq_lseek, 746 - .release = single_release, 747 - .owner = THIS_MODULE, 748 - }; 749 - 750 - static struct dentry *ab5500_dir; 751 - static struct dentry *ab5500_reg_file; 752 - static struct dentry *ab5500_bank_file; 753 - static struct dentry *ab5500_address_file; 754 - static struct dentry *ab5500_val_file; 755 - 756 - void __init ab5500_setup_debugfs(struct ab5500 *ab) 757 - { 758 - ab->debug_bank = AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP; 759 - ab->debug_address = AB5500_CHIP_ID; 760 - 761 - ab5500_dir = debugfs_create_dir("ab5500", NULL); 762 - if (!ab5500_dir) 763 - goto exit_no_debugfs; 764 - 765 - ab5500_reg_file = debugfs_create_file("all-bank-registers", 766 - S_IRUGO, ab5500_dir, ab, &ab5500_registers_fops); 767 - if (!ab5500_reg_file) 768 - goto exit_destroy_dir; 769 - 770 - ab5500_bank_file = debugfs_create_file("register-bank", 771 - (S_IRUGO | S_IWUGO), ab5500_dir, ab, &ab5500_bank_fops); 772 - if (!ab5500_bank_file) 773 - goto exit_destroy_reg; 774 - 775 - ab5500_address_file = debugfs_create_file("register-address", 776 - (S_IRUGO | S_IWUGO), ab5500_dir, ab, &ab5500_address_fops); 777 - if (!ab5500_address_file) 778 - goto exit_destroy_bank; 779 - 780 - ab5500_val_file = debugfs_create_file("register-value", 781 - (S_IRUGO | S_IWUGO), ab5500_dir, ab, &ab5500_val_fops); 782 - if (!ab5500_val_file) 783 - goto exit_destroy_address; 784 - 785 - return; 786 - 787 - exit_destroy_address: 788 - debugfs_remove(ab5500_address_file); 789 - exit_destroy_bank: 790 - debugfs_remove(ab5500_bank_file); 791 - exit_destroy_reg: 792 - debugfs_remove(ab5500_reg_file); 793 - exit_destroy_dir: 794 - debugfs_remove(ab5500_dir); 795 - exit_no_debugfs: 796 - dev_err(ab->dev, "failed to create debugfs entries.\n"); 797 - return; 798 - } 799 - 800 - void __exit ab5500_remove_debugfs(void) 801 - { 802 - debugfs_remove(ab5500_val_file); 803 - debugfs_remove(ab5500_address_file); 804 - debugfs_remove(ab5500_bank_file); 805 - debugfs_remove(ab5500_reg_file); 806 - debugfs_remove(ab5500_dir); 807 - }
-22
drivers/mfd/ab5500-debugfs.h
··· 1 - /* 2 - * Copyright (C) 2011 ST-Ericsson 3 - * License terms: GNU General Public License (GPL) version 2 4 - * Debugfs interface to the AB5500 core driver 5 - */ 6 - 7 - #ifdef CONFIG_DEBUG_FS 8 - 9 - void ab5500_setup_debugfs(struct ab5500 *ab); 10 - void ab5500_remove_debugfs(void); 11 - 12 - #else /* !CONFIG_DEBUG_FS */ 13 - 14 - static inline void ab5500_setup_debugfs(struct ab5500 *ab) 15 - { 16 - } 17 - 18 - static inline void ab5500_remove_debugfs(void) 19 - { 20 - } 21 - 22 - #endif
+1 -4
include/linux/mfd/abx500.h
··· 6 6 * 7 7 * ABX500 core access functions. 8 8 * The abx500 interface is used for the Analog Baseband chip 9 - * ab3100, ab5500, and ab8500. 9 + * ab3100 and ab8500. 10 10 * 11 11 * Author: Mattias Wallin <mattias.wallin@stericsson.com> 12 12 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> ··· 30 30 #define AB3100_P1G 0xc6 31 31 #define AB3100_R2A 0xc7 32 32 #define AB3100_R2B 0xc8 33 - #define AB5500_1_0 0x20 34 - #define AB5500_1_1 0x21 35 - #define AB5500_2_0 0x24 36 33 37 34 /* 38 35 * AB3100, EVENTA1, A2 and A3 event register flags
-140
include/linux/mfd/abx500/ab5500.h
··· 1 - /* 2 - * Copyright (C) ST-Ericsson 2011 3 - * 4 - * License Terms: GNU General Public License v2 5 - */ 6 - #ifndef MFD_AB5500_H 7 - #define MFD_AB5500_H 8 - 9 - struct device; 10 - 11 - enum ab5500_devid { 12 - AB5500_DEVID_ADC, 13 - AB5500_DEVID_LEDS, 14 - AB5500_DEVID_POWER, 15 - AB5500_DEVID_REGULATORS, 16 - AB5500_DEVID_SIM, 17 - AB5500_DEVID_RTC, 18 - AB5500_DEVID_CHARGER, 19 - AB5500_DEVID_FUELGAUGE, 20 - AB5500_DEVID_VIBRATOR, 21 - AB5500_DEVID_CODEC, 22 - AB5500_DEVID_USB, 23 - AB5500_DEVID_OTP, 24 - AB5500_DEVID_VIDEO, 25 - AB5500_DEVID_DBIECI, 26 - AB5500_DEVID_ONSWA, 27 - AB5500_NUM_DEVICES, 28 - }; 29 - 30 - enum ab5500_banks { 31 - AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP = 0, 32 - AB5500_BANK_VDDDIG_IO_I2C_CLK_TST = 1, 33 - AB5500_BANK_VDENC = 2, 34 - AB5500_BANK_SIM_USBSIM = 3, 35 - AB5500_BANK_LED = 4, 36 - AB5500_BANK_ADC = 5, 37 - AB5500_BANK_RTC = 6, 38 - AB5500_BANK_STARTUP = 7, 39 - AB5500_BANK_DBI_ECI = 8, 40 - AB5500_BANK_CHG = 9, 41 - AB5500_BANK_FG_BATTCOM_ACC = 10, 42 - AB5500_BANK_USB = 11, 43 - AB5500_BANK_IT = 12, 44 - AB5500_BANK_VIBRA = 13, 45 - AB5500_BANK_AUDIO_HEADSETUSB = 14, 46 - AB5500_NUM_BANKS = 15, 47 - }; 48 - 49 - enum ab5500_banks_addr { 50 - AB5500_ADDR_VIT_IO_I2C_CLK_TST_OTP = 0x4A, 51 - AB5500_ADDR_VDDDIG_IO_I2C_CLK_TST = 0x4B, 52 - AB5500_ADDR_VDENC = 0x06, 53 - AB5500_ADDR_SIM_USBSIM = 0x04, 54 - AB5500_ADDR_LED = 0x10, 55 - AB5500_ADDR_ADC = 0x0A, 56 - AB5500_ADDR_RTC = 0x0F, 57 - AB5500_ADDR_STARTUP = 0x03, 58 - AB5500_ADDR_DBI_ECI = 0x07, 59 - AB5500_ADDR_CHG = 0x0B, 60 - AB5500_ADDR_FG_BATTCOM_ACC = 0x0C, 61 - AB5500_ADDR_USB = 0x05, 62 - AB5500_ADDR_IT = 0x0E, 63 - AB5500_ADDR_VIBRA = 0x02, 64 - AB5500_ADDR_AUDIO_HEADSETUSB = 0x0D, 65 - }; 66 - 67 - /* 68 - * Interrupt register offsets 69 - * Bank : 0x0E 70 - */ 71 - #define AB5500_IT_SOURCE0_REG 0x20 72 - #define AB5500_IT_SOURCE1_REG 0x21 73 - #define AB5500_IT_SOURCE2_REG 0x22 74 - #define AB5500_IT_SOURCE3_REG 0x23 75 - #define AB5500_IT_SOURCE4_REG 0x24 76 - #define AB5500_IT_SOURCE5_REG 0x25 77 - #define AB5500_IT_SOURCE6_REG 0x26 78 - #define AB5500_IT_SOURCE7_REG 0x27 79 - #define AB5500_IT_SOURCE8_REG 0x28 80 - #define AB5500_IT_SOURCE9_REG 0x29 81 - #define AB5500_IT_SOURCE10_REG 0x2A 82 - #define AB5500_IT_SOURCE11_REG 0x2B 83 - #define AB5500_IT_SOURCE12_REG 0x2C 84 - #define AB5500_IT_SOURCE13_REG 0x2D 85 - #define AB5500_IT_SOURCE14_REG 0x2E 86 - #define AB5500_IT_SOURCE15_REG 0x2F 87 - #define AB5500_IT_SOURCE16_REG 0x30 88 - #define AB5500_IT_SOURCE17_REG 0x31 89 - #define AB5500_IT_SOURCE18_REG 0x32 90 - #define AB5500_IT_SOURCE19_REG 0x33 91 - #define AB5500_IT_SOURCE20_REG 0x34 92 - #define AB5500_IT_SOURCE21_REG 0x35 93 - #define AB5500_IT_SOURCE22_REG 0x36 94 - #define AB5500_IT_SOURCE23_REG 0x37 95 - 96 - #define AB5500_NUM_IRQ_REGS 23 97 - 98 - /** 99 - * struct ab5500 100 - * @access_mutex: lock out concurrent accesses to the AB registers 101 - * @dev: a pointer to the device struct for this chip driver 102 - * @ab5500_irq: the analog baseband irq 103 - * @irq_base: the platform configuration irq base for subdevices 104 - * @chip_name: name of this chip variant 105 - * @chip_id: 8 bit chip ID for this chip variant 106 - * @irq_lock: a lock to protect the mask 107 - * @abb_events: a local bit mask of the prcmu wakeup events 108 - * @event_mask: a local copy of the mask event registers 109 - * @last_event_mask: a copy of the last event_mask written to hardware 110 - * @startup_events: a copy of the first reading of the event registers 111 - * @startup_events_read: whether the first events have been read 112 - */ 113 - struct ab5500 { 114 - struct mutex access_mutex; 115 - struct device *dev; 116 - unsigned int ab5500_irq; 117 - unsigned int irq_base; 118 - char chip_name[32]; 119 - u8 chip_id; 120 - struct mutex irq_lock; 121 - u32 abb_events; 122 - u8 mask[AB5500_NUM_IRQ_REGS]; 123 - u8 oldmask[AB5500_NUM_IRQ_REGS]; 124 - u8 startup_events[AB5500_NUM_IRQ_REGS]; 125 - bool startup_events_read; 126 - #ifdef CONFIG_DEBUG_FS 127 - unsigned int debug_bank; 128 - unsigned int debug_address; 129 - #endif 130 - }; 131 - 132 - struct ab5500_platform_data { 133 - struct {unsigned int base; unsigned int count; } irq; 134 - void *dev_data[AB5500_NUM_DEVICES]; 135 - struct abx500_init_settings *init_settings; 136 - unsigned int init_settings_sz; 137 - bool pm_power_off; 138 - }; 139 - 140 - #endif /* MFD_AB5500_H */