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

Merge tag 'mfd_3.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6

Pull MFD changes from Samuel Ortiz:
- 4 new drivers: Freescale i.MX on-chip Anatop, Ricoh's RC5T583 and
TI's TPS65090 and TPS65217.
- New variants support (8420, 8520 ab9540), cleanups and bug fixes for
the abx500 and db8500 ST-E chipsets.
- Some minor fixes and update for the wm8994 from Mark.
- The beginning of a long term TWL cleanup effort coming from the TI
folks.
- Various fixes and cleanups for the s5m, TPS659xx, pm860x, and MAX8997
drivers.

Fix up trivial conflicts due to duplicate patches and header file
cleanups (<linux/device.h> removal etc).

* tag 'mfd_3.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (97 commits)
gpio/twl: Add DT support to gpio-twl4030 driver
gpio/twl: Allocate irq_desc dynamically for SPARSE_IRQ support
mfd: Detach twl6040 from the pmic mfd driver
mfd: Replace twl-* pr_ macros by the dev_ equivalent and do various cleanups
mfd: Micro-optimization on twl4030 IRQ handler
mfd: Make twl4030 SIH SPARSE_IRQ capable
mfd: Move twl-core IRQ allocation into twl[4030|6030]-irq files
mfd: Remove references already defineid in header file from twl-core
mfd: Remove unneeded header from twl-core
mfd: Make twl-core not depend on pdata->irq_base/end
ARM: OMAP2+: board-omap4-*: Do not use anymore TWL6030_IRQ_BASE in board files
mfd: Return twl6030_mmc_card_detect IRQ for board setup
Revert "mfd: Add platform data for MAX8997 haptic driver"
mfd: Add support for TPS65090
mfd: Add some da9052-i2c section annotations
mfd: Build rtc5t583 only if I2C config is selected to y.
mfd: Add anatop mfd driver
mfd: Fix compilation error in tps65910.h
mfd: Add 8420 variant to db8500-prcmu
mfd: Add 8520 PRCMU variant to db8500-prcmu
...

+5215 -1130
+23
Documentation/devicetree/bindings/gpio/gpio-twl4030.txt
··· 1 + twl4030 GPIO controller bindings 2 + 3 + Required properties: 4 + - compatible: 5 + - "ti,twl4030-gpio" for twl4030 GPIO controller 6 + - #gpio-cells : Should be two. 7 + - first cell is the pin number 8 + - second cell is used to specify optional parameters (unused) 9 + - gpio-controller : Marks the device node as a GPIO controller. 10 + - #interrupt-cells : Should be 2. 11 + - interrupt-controller: Mark the device node as an interrupt controller 12 + The first cell is the GPIO number. 13 + The second cell is not used. 14 + 15 + Example: 16 + 17 + twl_gpio: gpio { 18 + compatible = "ti,twl4030-gpio"; 19 + #gpio-cells = <2>; 20 + gpio-controller; 21 + #interrupt-cells = <2>; 22 + interrupt-controller; 23 + };
+7 -6
arch/arm/mach-omap2/board-4430sdp.c
··· 490 490 491 491 static int omap4_twl6030_hsmmc_late_init(struct device *dev) 492 492 { 493 - int ret = 0; 493 + int irq = 0; 494 494 struct platform_device *pdev = container_of(dev, 495 495 struct platform_device, dev); 496 496 struct omap_mmc_platform_data *pdata = dev->platform_data; 497 497 498 498 /* Setting MMC1 Card detect Irq */ 499 499 if (pdev->id == 0) { 500 - ret = twl6030_mmc_card_detect_config(); 501 - if (ret) 500 + irq = twl6030_mmc_card_detect_config(); 501 + if (irq < 0) { 502 502 pr_err("Failed configuring MMC1 card detect\n"); 503 - pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE + 504 - MMCDETECT_INTR_OFFSET; 503 + return irq; 504 + } 505 + pdata->slots[0].card_detect_irq = irq; 505 506 pdata->slots[0].card_detect = twl6030_mmc_card_detect; 506 507 } 507 - return ret; 508 + return 0; 508 509 } 509 510 510 511 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
+8 -7
arch/arm/mach-omap2/board-omap4panda.c
··· 238 238 239 239 static int omap4_twl6030_hsmmc_late_init(struct device *dev) 240 240 { 241 - int ret = 0; 241 + int irq = 0; 242 242 struct platform_device *pdev = container_of(dev, 243 243 struct platform_device, dev); 244 244 struct omap_mmc_platform_data *pdata = dev->platform_data; ··· 249 249 } 250 250 /* Setting MMC1 Card detect Irq */ 251 251 if (pdev->id == 0) { 252 - ret = twl6030_mmc_card_detect_config(); 253 - if (ret) 252 + irq = twl6030_mmc_card_detect_config(); 253 + if (irq < 0) { 254 254 dev_err(dev, "%s: Error card detect config(%d)\n", 255 - __func__, ret); 256 - else 257 - pdata->slots[0].card_detect = twl6030_mmc_card_detect; 255 + __func__, irq); 256 + return irq; 257 + } 258 + pdata->slots[0].card_detect = twl6030_mmc_card_detect; 258 259 } 259 - return ret; 260 + return 0; 260 261 } 261 262 262 263 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
+12 -2
arch/arm/mach-s3c64xx/mach-crag6410-module.c
··· 17 17 #include <linux/mfd/wm831x/gpio.h> 18 18 #include <linux/mfd/wm8994/pdata.h> 19 19 20 + #include <linux/regulator/machine.h> 21 + 20 22 #include <sound/wm5100.h> 21 23 #include <sound/wm8996.h> 22 24 #include <sound/wm8962.h> ··· 155 153 }, 156 154 }; 157 155 156 + static struct regulator_init_data wm8994_ldo1 = { 157 + .supply_regulator = "WALLVDD", 158 + }; 159 + 160 + static struct regulator_init_data wm8994_ldo2 = { 161 + .supply_regulator = "WALLVDD", 162 + }; 163 + 158 164 static struct wm8994_pdata wm8994_pdata = { 159 165 .gpio_base = CODEC_GPIO_BASE, 160 166 .gpio_defaults = { ··· 170 160 }, 171 161 .irq_base = CODEC_IRQ_BASE, 172 162 .ldo = { 173 - { .supply = "WALLVDD" }, 174 - { .supply = "WALLVDD" }, 163 + { .init_data = &wm8994_ldo1, }, 164 + { .init_data = &wm8994_ldo2, }, 175 165 }, 176 166 }; 177 167
+1 -1
arch/arm/mach-ux500/include/mach/irqs-board-mop500.h
··· 13 13 14 14 #define MOP500_AB8500_IRQ_BASE IRQ_BOARD_START 15 15 #define MOP500_AB8500_IRQ_END (MOP500_AB8500_IRQ_BASE \ 16 - + AB8500_NR_IRQS) 16 + + AB8500_MAX_NR_IRQS) 17 17 18 18 /* TC35892 */ 19 19 #define TC35892_NR_INTERNAL_IRQS 8
+5 -8
drivers/cpufreq/db8500-cpufreq.c
··· 22 22 }, 23 23 [1] = { 24 24 .index = 1, 25 - .frequency = 300000, 25 + .frequency = 400000, 26 26 }, 27 27 [2] = { 28 28 .index = 2, 29 - .frequency = 600000, 29 + .frequency = 800000, 30 30 }, 31 31 [3] = { 32 32 /* Used for MAX_OPP, if available */ ··· 113 113 114 114 BUILD_BUG_ON(ARRAY_SIZE(idx2opp) + 1 != ARRAY_SIZE(freq_table)); 115 115 116 - if (!prcmu_is_u8400()) { 117 - freq_table[1].frequency = 400000; 118 - freq_table[2].frequency = 800000; 119 - if (prcmu_has_arm_maxopp()) 120 - freq_table[3].frequency = 1000000; 121 - } 116 + if (prcmu_has_arm_maxopp()) 117 + freq_table[3].frequency = 1000000; 118 + 122 119 pr_info("db8500-cpufreq : Available frequencies:\n"); 123 120 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) 124 121 pr_info(" %d Mhz\n", freq_table[i].frequency/1000);
+25 -16
drivers/gpio/gpio-stmpe.c
··· 307 307 struct stmpe_gpio_platform_data *pdata; 308 308 struct stmpe_gpio *stmpe_gpio; 309 309 int ret; 310 - int irq; 310 + int irq = 0; 311 311 312 312 pdata = stmpe->pdata->gpio; 313 313 314 314 irq = platform_get_irq(pdev, 0); 315 - if (irq < 0) 316 - return irq; 317 315 318 316 stmpe_gpio = kzalloc(sizeof(struct stmpe_gpio), GFP_KERNEL); 319 317 if (!stmpe_gpio) ··· 328 330 stmpe_gpio->chip.dev = &pdev->dev; 329 331 stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1; 330 332 331 - stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0); 333 + if (irq >= 0) 334 + stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0); 335 + else 336 + dev_info(&pdev->dev, 337 + "device configured in no-irq mode; " 338 + "irqs are not available\n"); 332 339 333 340 ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO); 334 341 if (ret) 335 342 goto out_free; 336 343 337 - ret = stmpe_gpio_irq_init(stmpe_gpio); 338 - if (ret) 339 - goto out_disable; 344 + if (irq >= 0) { 345 + ret = stmpe_gpio_irq_init(stmpe_gpio); 346 + if (ret) 347 + goto out_disable; 340 348 341 - ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq, IRQF_ONESHOT, 342 - "stmpe-gpio", stmpe_gpio); 343 - if (ret) { 344 - dev_err(&pdev->dev, "unable to get irq: %d\n", ret); 345 - goto out_removeirq; 349 + ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq, 350 + IRQF_ONESHOT, "stmpe-gpio", stmpe_gpio); 351 + if (ret) { 352 + dev_err(&pdev->dev, "unable to get irq: %d\n", ret); 353 + goto out_removeirq; 354 + } 346 355 } 347 356 348 357 ret = gpiochip_add(&stmpe_gpio->chip); ··· 366 361 return 0; 367 362 368 363 out_freeirq: 369 - free_irq(irq, stmpe_gpio); 364 + if (irq >= 0) 365 + free_irq(irq, stmpe_gpio); 370 366 out_removeirq: 371 - stmpe_gpio_irq_remove(stmpe_gpio); 367 + if (irq >= 0) 368 + stmpe_gpio_irq_remove(stmpe_gpio); 372 369 out_disable: 373 370 stmpe_disable(stmpe, STMPE_BLOCK_GPIO); 374 371 out_free: ··· 398 391 399 392 stmpe_disable(stmpe, STMPE_BLOCK_GPIO); 400 393 401 - free_irq(irq, stmpe_gpio); 402 - stmpe_gpio_irq_remove(stmpe_gpio); 394 + if (irq >= 0) { 395 + free_irq(irq, stmpe_gpio); 396 + stmpe_gpio_irq_remove(stmpe_gpio); 397 + } 403 398 platform_set_drvdata(pdev, NULL); 404 399 kfree(stmpe_gpio); 405 400
+67 -44
drivers/gpio/gpio-twl4030.c
··· 32 32 #include <linux/irq.h> 33 33 #include <linux/gpio.h> 34 34 #include <linux/platform_device.h> 35 + #include <linux/of.h> 36 + #include <linux/irqdomain.h> 35 37 36 38 #include <linux/i2c/twl.h> 37 39 ··· 258 256 * and vMMC2 power supplies based on card presence. 259 257 */ 260 258 pdata = chip->dev->platform_data; 261 - value |= pdata->mmc_cd & 0x03; 259 + if (pdata) 260 + value |= pdata->mmc_cd & 0x03; 262 261 263 262 status = gpio_twl4030_write(REG_GPIO_CTRL, value); 264 263 } ··· 398 395 static int __devinit gpio_twl4030_probe(struct platform_device *pdev) 399 396 { 400 397 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; 401 - int ret; 398 + struct device_node *node = pdev->dev.of_node; 399 + int ret, irq_base; 402 400 403 401 /* maybe setup IRQs */ 404 - if (pdata->irq_base) { 405 - if (is_module()) { 406 - dev_err(&pdev->dev, 407 - "can't dispatch IRQs from modules\n"); 408 - goto no_irqs; 409 - } 410 - ret = twl4030_sih_setup(TWL4030_MODULE_GPIO); 411 - if (ret < 0) 412 - return ret; 413 - WARN_ON(ret != pdata->irq_base); 414 - twl4030_gpio_irq_base = ret; 402 + if (is_module()) { 403 + dev_err(&pdev->dev, "can't dispatch IRQs from modules\n"); 404 + goto no_irqs; 415 405 } 416 406 407 + irq_base = irq_alloc_descs(-1, 0, TWL4030_GPIO_MAX, 0); 408 + if (irq_base < 0) { 409 + dev_err(&pdev->dev, "Failed to alloc irq_descs\n"); 410 + return irq_base; 411 + } 412 + 413 + irq_domain_add_legacy(node, TWL4030_GPIO_MAX, irq_base, 0, 414 + &irq_domain_simple_ops, NULL); 415 + 416 + ret = twl4030_sih_setup(&pdev->dev, TWL4030_MODULE_GPIO, irq_base); 417 + if (ret < 0) 418 + return ret; 419 + 420 + twl4030_gpio_irq_base = irq_base; 421 + 417 422 no_irqs: 418 - /* 419 - * NOTE: boards may waste power if they don't set pullups 420 - * and pulldowns correctly ... default for non-ULPI pins is 421 - * pulldown, and some other pins may have external pullups 422 - * or pulldowns. Careful! 423 - */ 424 - ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns); 425 - if (ret) 426 - dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n", 427 - pdata->pullups, pdata->pulldowns, 428 - ret); 429 - 430 - ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd); 431 - if (ret) 432 - dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n", 433 - pdata->debounce, pdata->mmc_cd, 434 - ret); 435 - 436 - twl_gpiochip.base = pdata->gpio_base; 423 + twl_gpiochip.base = -1; 437 424 twl_gpiochip.ngpio = TWL4030_GPIO_MAX; 438 425 twl_gpiochip.dev = &pdev->dev; 439 426 440 - /* NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE, 441 - * is (still) clear if use_leds is set. 442 - */ 443 - if (pdata->use_leds) 444 - twl_gpiochip.ngpio += 2; 427 + if (pdata) { 428 + twl_gpiochip.base = pdata->gpio_base; 429 + 430 + /* 431 + * NOTE: boards may waste power if they don't set pullups 432 + * and pulldowns correctly ... default for non-ULPI pins is 433 + * pulldown, and some other pins may have external pullups 434 + * or pulldowns. Careful! 435 + */ 436 + ret = gpio_twl4030_pulls(pdata->pullups, pdata->pulldowns); 437 + if (ret) 438 + dev_dbg(&pdev->dev, "pullups %.05x %.05x --> %d\n", 439 + pdata->pullups, pdata->pulldowns, 440 + ret); 441 + 442 + ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd); 443 + if (ret) 444 + dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n", 445 + pdata->debounce, pdata->mmc_cd, 446 + ret); 447 + 448 + /* 449 + * NOTE: we assume VIBRA_CTL.VIBRA_EN, in MODULE_AUDIO_VOICE, 450 + * is (still) clear if use_leds is set. 451 + */ 452 + if (pdata->use_leds) 453 + twl_gpiochip.ngpio += 2; 454 + } 445 455 446 456 ret = gpiochip_add(&twl_gpiochip); 447 457 if (ret < 0) { 448 - dev_err(&pdev->dev, 449 - "could not register gpiochip, %d\n", 450 - ret); 458 + dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); 451 459 twl_gpiochip.ngpio = 0; 452 460 gpio_twl4030_remove(pdev); 453 - } else if (pdata->setup) { 461 + } else if (pdata && pdata->setup) { 454 462 int status; 455 463 456 464 status = pdata->setup(&pdev->dev, ··· 479 465 struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; 480 466 int status; 481 467 482 - if (pdata->teardown) { 468 + if (pdata && pdata->teardown) { 483 469 status = pdata->teardown(&pdev->dev, 484 470 pdata->gpio_base, TWL4030_GPIO_MAX); 485 471 if (status) { ··· 500 486 return -EIO; 501 487 } 502 488 489 + static const struct of_device_id twl_gpio_match[] = { 490 + { .compatible = "ti,twl4030-gpio", }, 491 + { }, 492 + }; 493 + MODULE_DEVICE_TABLE(of, twl_gpio_match); 494 + 503 495 /* Note: this hardware lives inside an I2C-based multi-function device. */ 504 496 MODULE_ALIAS("platform:twl4030_gpio"); 505 497 506 498 static struct platform_driver gpio_twl4030_driver = { 507 - .driver.name = "twl4030_gpio", 508 - .driver.owner = THIS_MODULE, 499 + .driver = { 500 + .name = "twl4030_gpio", 501 + .owner = THIS_MODULE, 502 + .of_match_table = of_match_ptr(twl_gpio_match), 503 + }, 509 504 .probe = gpio_twl4030_probe, 510 505 .remove = gpio_twl4030_remove, 511 506 };
+1 -1
drivers/hwmon/mc13783-adc.c
··· 59 59 60 60 ret = mc13xxx_adc_do_conversion(priv->mc13xxx, 61 61 MC13XXX_ADC_MODE_MULT_CHAN, 62 - channel, sample); 62 + channel, 0, 0, sample); 63 63 if (ret) 64 64 return ret; 65 65
+26
drivers/input/misc/88pm860x_onkey.c
··· 105 105 } 106 106 107 107 platform_set_drvdata(pdev, info); 108 + device_init_wakeup(&pdev->dev, 1); 109 + 108 110 return 0; 109 111 110 112 out_irq: ··· 131 129 return 0; 132 130 } 133 131 132 + #ifdef CONFIG_PM_SLEEP 133 + static int pm860x_onkey_suspend(struct device *dev) 134 + { 135 + struct platform_device *pdev = to_platform_device(dev); 136 + struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 137 + 138 + if (device_may_wakeup(dev)) 139 + chip->wakeup_flag |= 1 << PM8607_IRQ_ONKEY; 140 + return 0; 141 + } 142 + static int pm860x_onkey_resume(struct device *dev) 143 + { 144 + struct platform_device *pdev = to_platform_device(dev); 145 + struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 146 + 147 + if (device_may_wakeup(dev)) 148 + chip->wakeup_flag &= ~(1 << PM8607_IRQ_ONKEY); 149 + return 0; 150 + } 151 + #endif 152 + 153 + static SIMPLE_DEV_PM_OPS(pm860x_onkey_pm_ops, pm860x_onkey_suspend, pm860x_onkey_resume); 154 + 134 155 static struct platform_driver pm860x_onkey_driver = { 135 156 .driver = { 136 157 .name = "88pm860x-onkey", 137 158 .owner = THIS_MODULE, 159 + .pm = &pm860x_onkey_pm_ops, 138 160 }, 139 161 .probe = pm860x_onkey_probe, 140 162 .remove = __devexit_p(pm860x_onkey_remove),
+10 -1
drivers/input/touchscreen/mc13783_ts.c
··· 39 39 struct delayed_work work; 40 40 struct workqueue_struct *workq; 41 41 unsigned int sample[4]; 42 + struct mc13xxx_ts_platform_data *touch; 42 43 }; 43 44 44 45 static irqreturn_t mc13783_ts_handler(int irq, void *data) ··· 126 125 unsigned int channel = 12; 127 126 128 127 if (mc13xxx_adc_do_conversion(priv->mc13xxx, 129 - mode, channel, priv->sample) == 0) 128 + mode, channel, 129 + priv->touch->ato, priv->touch->atox, 130 + priv->sample) == 0) 130 131 mc13783_ts_report_sample(priv); 131 132 } 132 133 ··· 182 179 INIT_DELAYED_WORK(&priv->work, mc13783_ts_work); 183 180 priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); 184 181 priv->idev = idev; 182 + priv->touch = dev_get_platdata(&pdev->dev); 183 + if (!priv->touch) { 184 + dev_err(&pdev->dev, "missing platform data\n"); 185 + ret = -ENODEV; 186 + goto err_free_mem; 187 + } 185 188 186 189 /* 187 190 * We need separate workqueue because mc13783_adc_do_conversion
+23
drivers/leds/leds-88pm860x.c
··· 114 114 return ret; 115 115 } 116 116 117 + static int led_power_set(struct pm860x_chip *chip, int port, int on) 118 + { 119 + int ret = -EINVAL; 120 + 121 + switch (port) { 122 + case PM8606_LED1_RED: 123 + case PM8606_LED1_GREEN: 124 + case PM8606_LED1_BLUE: 125 + ret = on ? pm8606_osc_enable(chip, RGB1_ENABLE) : 126 + pm8606_osc_disable(chip, RGB1_ENABLE); 127 + break; 128 + case PM8606_LED2_RED: 129 + case PM8606_LED2_GREEN: 130 + case PM8606_LED2_BLUE: 131 + ret = on ? pm8606_osc_enable(chip, RGB2_ENABLE) : 132 + pm8606_osc_disable(chip, RGB2_ENABLE); 133 + break; 134 + } 135 + return ret; 136 + } 137 + 117 138 static void pm860x_led_work(struct work_struct *work) 118 139 { 119 140 ··· 147 126 chip = led->chip; 148 127 mutex_lock(&led->lock); 149 128 if ((led->current_brightness == 0) && led->brightness) { 129 + led_power_set(chip, led->port, 1); 150 130 if (led->iset) { 151 131 pm860x_set_bits(led->i2c, __led_off(led->port), 152 132 LED_CURRENT_MASK, led->iset); ··· 171 149 LED_CURRENT_MASK, 0); 172 150 mask = __blink_ctl_mask(led->port); 173 151 pm860x_set_bits(led->i2c, PM8606_WLED3B, mask, 0); 152 + led_power_set(chip, led->port, 0); 174 153 } 175 154 } 176 155 led->current_brightness = led->brightness;
+106 -4
drivers/mfd/88pm860x-core.c
··· 503 503 free_irq(chip->core_irq, chip); 504 504 } 505 505 506 + int pm8606_osc_enable(struct pm860x_chip *chip, unsigned short client) 507 + { 508 + int ret = -EIO; 509 + struct i2c_client *i2c = (chip->id == CHIP_PM8606) ? 510 + chip->client : chip->companion; 511 + 512 + dev_dbg(chip->dev, "%s(B): client=0x%x\n", __func__, client); 513 + dev_dbg(chip->dev, "%s(B): vote=0x%x status=%d\n", 514 + __func__, chip->osc_vote, 515 + chip->osc_status); 516 + 517 + mutex_lock(&chip->osc_lock); 518 + /* Update voting status */ 519 + chip->osc_vote |= client; 520 + /* If reference group is off - turn on*/ 521 + if (chip->osc_status != PM8606_REF_GP_OSC_ON) { 522 + chip->osc_status = PM8606_REF_GP_OSC_UNKNOWN; 523 + /* Enable Reference group Vsys */ 524 + if (pm860x_set_bits(i2c, PM8606_VSYS, 525 + PM8606_VSYS_EN, PM8606_VSYS_EN)) 526 + goto out; 527 + 528 + /*Enable Internal Oscillator */ 529 + if (pm860x_set_bits(i2c, PM8606_MISC, 530 + PM8606_MISC_OSC_EN, PM8606_MISC_OSC_EN)) 531 + goto out; 532 + /* Update status (only if writes succeed) */ 533 + chip->osc_status = PM8606_REF_GP_OSC_ON; 534 + } 535 + mutex_unlock(&chip->osc_lock); 536 + 537 + dev_dbg(chip->dev, "%s(A): vote=0x%x status=%d ret=%d\n", 538 + __func__, chip->osc_vote, 539 + chip->osc_status, ret); 540 + return 0; 541 + out: 542 + mutex_unlock(&chip->osc_lock); 543 + return ret; 544 + } 545 + EXPORT_SYMBOL(pm8606_osc_enable); 546 + 547 + int pm8606_osc_disable(struct pm860x_chip *chip, unsigned short client) 548 + { 549 + int ret = -EIO; 550 + struct i2c_client *i2c = (chip->id == CHIP_PM8606) ? 551 + chip->client : chip->companion; 552 + 553 + dev_dbg(chip->dev, "%s(B): client=0x%x\n", __func__, client); 554 + dev_dbg(chip->dev, "%s(B): vote=0x%x status=%d\n", 555 + __func__, chip->osc_vote, 556 + chip->osc_status); 557 + 558 + mutex_lock(&chip->osc_lock); 559 + /*Update voting status */ 560 + chip->osc_vote &= ~(client); 561 + /* If reference group is off and this is the last client to release 562 + * - turn off */ 563 + if ((chip->osc_status != PM8606_REF_GP_OSC_OFF) && 564 + (chip->osc_vote == REF_GP_NO_CLIENTS)) { 565 + chip->osc_status = PM8606_REF_GP_OSC_UNKNOWN; 566 + /* Disable Reference group Vsys */ 567 + if (pm860x_set_bits(i2c, PM8606_VSYS, PM8606_VSYS_EN, 0)) 568 + goto out; 569 + /* Disable Internal Oscillator */ 570 + if (pm860x_set_bits(i2c, PM8606_MISC, PM8606_MISC_OSC_EN, 0)) 571 + goto out; 572 + chip->osc_status = PM8606_REF_GP_OSC_OFF; 573 + } 574 + mutex_unlock(&chip->osc_lock); 575 + 576 + dev_dbg(chip->dev, "%s(A): vote=0x%x status=%d ret=%d\n", 577 + __func__, chip->osc_vote, 578 + chip->osc_status, ret); 579 + return 0; 580 + out: 581 + mutex_unlock(&chip->osc_lock); 582 + return ret; 583 + } 584 + EXPORT_SYMBOL(pm8606_osc_disable); 585 + 586 + static void __devinit device_osc_init(struct i2c_client *i2c) 587 + { 588 + struct pm860x_chip *chip = i2c_get_clientdata(i2c); 589 + 590 + mutex_init(&chip->osc_lock); 591 + /* init portofino reference group voting and status */ 592 + /* Disable Reference group Vsys */ 593 + pm860x_set_bits(i2c, PM8606_VSYS, PM8606_VSYS_EN, 0); 594 + /* Disable Internal Oscillator */ 595 + pm860x_set_bits(i2c, PM8606_MISC, PM8606_MISC_OSC_EN, 0); 596 + 597 + chip->osc_vote = REF_GP_NO_CLIENTS; 598 + chip->osc_status = PM8606_REF_GP_OSC_OFF; 599 + } 600 + 506 601 static void __devinit device_bk_init(struct pm860x_chip *chip, 507 602 struct pm860x_platform_data *pdata) 508 603 { ··· 862 767 return; 863 768 } 864 769 770 + static void __devinit device_8606_init(struct pm860x_chip *chip, 771 + struct i2c_client *i2c, 772 + struct pm860x_platform_data *pdata) 773 + { 774 + device_osc_init(i2c); 775 + device_bk_init(chip, pdata); 776 + device_led_init(chip, pdata); 777 + } 778 + 865 779 int __devinit pm860x_device_init(struct pm860x_chip *chip, 866 780 struct pm860x_platform_data *pdata) 867 781 { ··· 878 774 879 775 switch (chip->id) { 880 776 case CHIP_PM8606: 881 - device_bk_init(chip, pdata); 882 - device_led_init(chip, pdata); 777 + device_8606_init(chip, chip->client, pdata); 883 778 break; 884 779 case CHIP_PM8607: 885 780 device_8607_init(chip, chip->client, pdata); ··· 888 785 if (chip->companion) { 889 786 switch (chip->id) { 890 787 case CHIP_PM8607: 891 - device_bk_init(chip, pdata); 892 - device_led_init(chip, pdata); 788 + device_8606_init(chip, chip->companion, pdata); 893 789 break; 894 790 case CHIP_PM8606: 895 791 device_8607_init(chip, chip->companion, pdata);
+25
drivers/mfd/88pm860x-i2c.c
··· 334 334 return 0; 335 335 } 336 336 337 + #ifdef CONFIG_PM_SLEEP 338 + static int pm860x_suspend(struct device *dev) 339 + { 340 + struct i2c_client *client = container_of(dev, struct i2c_client, dev); 341 + struct pm860x_chip *chip = i2c_get_clientdata(client); 342 + 343 + if (device_may_wakeup(dev) && chip->wakeup_flag) 344 + enable_irq_wake(chip->core_irq); 345 + return 0; 346 + } 347 + 348 + static int pm860x_resume(struct device *dev) 349 + { 350 + struct i2c_client *client = container_of(dev, struct i2c_client, dev); 351 + struct pm860x_chip *chip = i2c_get_clientdata(client); 352 + 353 + if (device_may_wakeup(dev) && chip->wakeup_flag) 354 + disable_irq_wake(chip->core_irq); 355 + return 0; 356 + } 357 + #endif 358 + 359 + static SIMPLE_DEV_PM_OPS(pm860x_pm_ops, pm860x_suspend, pm860x_resume); 360 + 337 361 static struct i2c_driver pm860x_driver = { 338 362 .driver = { 339 363 .name = "88PM860x", 340 364 .owner = THIS_MODULE, 365 + .pm = &pm860x_pm_ops, 341 366 }, 342 367 .probe = pm860x_probe, 343 368 .remove = __devexit_p(pm860x_remove),
+52 -2
drivers/mfd/Kconfig
··· 143 143 This driver can also be built as a module. If so, the module 144 144 will be called tps6507x. 145 145 146 + config MFD_TPS65217 147 + tristate "TPS65217 Power Management / White LED chips" 148 + depends on I2C 149 + select MFD_CORE 150 + select REGMAP_I2C 151 + help 152 + If you say yes here you get support for the TPS65217 series of 153 + Power Management / White LED chips. 154 + These include voltage regulators, lithium ion/polymer battery 155 + charger, wled and other features that are often used in portable 156 + devices. 157 + 158 + This driver can also be built as a module. If so, the module 159 + will be called tps65217. 160 + 146 161 config MFD_TPS6586X 147 162 bool "TPS6586x Power Management chips" 148 163 depends on I2C=y && GPIOLIB && GENERIC_HARDIRQS ··· 177 162 depends on I2C=y && GPIOLIB 178 163 select MFD_CORE 179 164 select GPIO_TPS65910 165 + select REGMAP_I2C 180 166 help 181 167 if you say yes here you get support for the TPS65910 series of 182 168 Power Management chips. ··· 187 171 depends on GPIOLIB 188 172 189 173 config MFD_TPS65912_I2C 190 - bool "TPS95612 Power Management chip with I2C" 174 + bool "TPS65912 Power Management chip with I2C" 191 175 select MFD_CORE 192 176 select MFD_TPS65912 193 177 depends on I2C=y && GPIOLIB ··· 416 400 depends on I2C=y && GENERIC_HARDIRQS 417 401 select MFD_CORE 418 402 help 419 - Say yes here to support for Maxim Semiconductor MAX8998/8966. 403 + Say yes here to support for Maxim Semiconductor MAX8997/8966. 420 404 This is a Power Management IC with RTC, Flash, Fuel Gauge, Haptic, 421 405 MUIC controls on chip. 422 406 This driver provides common support for accessing the device; ··· 828 812 config TPS65911_COMPARATOR 829 813 tristate 830 814 815 + config MFD_TPS65090 816 + bool "TPS65090 Power Management chips" 817 + depends on I2C=y && GENERIC_HARDIRQS 818 + select MFD_CORE 819 + select REGMAP_I2C 820 + help 821 + If you say yes here you get support for the TPS65090 series of 822 + Power Management chips. 823 + This driver provides common support for accessing the device, 824 + additional drivers must be enabled in order to use the 825 + functionality of the device. 826 + 831 827 config MFD_AAT2870_CORE 832 828 bool "Support for the AnalogicTech AAT2870" 833 829 select MFD_CORE ··· 858 830 Select this option to enable access to Intel MSIC (Avatele 859 831 Passage) chip. This chip embeds audio, battery, GPIO, etc. 860 832 devices used in Intel Medfield platforms. 833 + 834 + config MFD_RC5T583 835 + bool "Ricoh RC5T583 Power Management system device" 836 + depends on I2C=y && GENERIC_HARDIRQS 837 + select MFD_CORE 838 + select REGMAP_I2C 839 + help 840 + Select this option to get support for the RICOH583 Power 841 + Management system device. 842 + This driver provides common support for accessing the device 843 + through i2c interface. The device supports multiple sub-devices 844 + like GPIO, interrupts, RTC, LDO and DCDC regulators, onkey. 845 + Additional drivers must be enabled in order to use the 846 + different functionality of the device. 847 + 848 + config MFD_ANATOP 849 + bool "Support for Freescale i.MX on-chip ANATOP controller" 850 + depends on SOC_IMX6Q 851 + help 852 + Select this option to enable Freescale i.MX on-chip ANATOP 853 + MFD controller. This controller embeds regulator and 854 + thermal devices for Freescale i.MX platforms. 861 855 862 856 endmenu 863 857 endif
+4
drivers/mfd/Makefile
··· 38 38 obj-$(CONFIG_TPS6105X) += tps6105x.o 39 39 obj-$(CONFIG_TPS65010) += tps65010.o 40 40 obj-$(CONFIG_TPS6507X) += tps6507x.o 41 + obj-$(CONFIG_MFD_TPS65217) += tps65217.o 41 42 obj-$(CONFIG_MFD_TPS65910) += tps65910.o tps65910-irq.o 42 43 tps65912-objs := tps65912-core.o tps65912-irq.o 43 44 obj-$(CONFIG_MFD_TPS65912) += tps65912.o ··· 110 109 obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o 111 110 obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o 112 111 obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o 112 + obj-$(CONFIG_MFD_TPS65090) += tps65090.o 113 113 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o 114 114 obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o 115 + obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o 115 116 obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o 117 + obj-$(CONFIG_MFD_ANATOP) += anatop-mfd.o
+285 -90
drivers/mfd/ab8500-core.c
··· 32 32 #define AB8500_IT_SOURCE6_REG 0x05 33 33 #define AB8500_IT_SOURCE7_REG 0x06 34 34 #define AB8500_IT_SOURCE8_REG 0x07 35 + #define AB9540_IT_SOURCE13_REG 0x0C 35 36 #define AB8500_IT_SOURCE19_REG 0x12 36 37 #define AB8500_IT_SOURCE20_REG 0x13 37 38 #define AB8500_IT_SOURCE21_REG 0x14 ··· 54 53 #define AB8500_IT_LATCH9_REG 0x28 55 54 #define AB8500_IT_LATCH10_REG 0x29 56 55 #define AB8500_IT_LATCH12_REG 0x2B 56 + #define AB9540_IT_LATCH13_REG 0x2C 57 57 #define AB8500_IT_LATCH19_REG 0x32 58 58 #define AB8500_IT_LATCH20_REG 0x33 59 59 #define AB8500_IT_LATCH21_REG 0x34 ··· 92 90 #define AB8500_IT_MASK24_REG 0x57 93 91 94 92 #define AB8500_REV_REG 0x80 93 + #define AB8500_IC_NAME_REG 0x82 95 94 #define AB8500_SWITCH_OFF_STATUS 0x00 96 95 97 96 #define AB8500_TURN_ON_STATUS 0x00 98 97 98 + #define AB9540_MODEM_CTRL2_REG 0x23 99 + #define AB9540_MODEM_CTRL2_SWDBBRSTN_BIT BIT(2) 100 + 99 101 /* 100 102 * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt 101 - * numbers are indexed into this array with (num / 8). 103 + * numbers are indexed into this array with (num / 8). The interupts are 104 + * defined in linux/mfd/ab8500.h 102 105 * 103 106 * This is one off from the register names, i.e. AB8500_IT_MASK1_REG is at 104 107 * offset 0. 105 108 */ 109 + /* AB8500 support */ 106 110 static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { 107 111 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, 112 + }; 113 + 114 + /* AB9540 support */ 115 + static const int ab9540_irq_regoffset[AB9540_NUM_IRQ_REGS] = { 116 + 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, 12, 13, 24, 117 + }; 118 + 119 + static const char ab8500_version_str[][7] = { 120 + [AB8500_VERSION_AB8500] = "AB8500", 121 + [AB8500_VERSION_AB8505] = "AB8505", 122 + [AB8500_VERSION_AB9540] = "AB9540", 123 + [AB8500_VERSION_AB8540] = "AB8540", 108 124 }; 109 125 110 126 static int ab8500_get_chip_id(struct device *dev) ··· 147 127 148 128 dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); 149 129 150 - ret = mutex_lock_interruptible(&ab8500->lock); 151 - if (ret) 152 - return ret; 130 + mutex_lock(&ab8500->lock); 153 131 154 132 ret = ab8500->write(ab8500, addr, data); 155 133 if (ret < 0) ··· 174 156 * bank on higher 8 bits and reg in lower */ 175 157 u16 addr = ((u16)bank) << 8 | reg; 176 158 177 - ret = mutex_lock_interruptible(&ab8500->lock); 178 - if (ret) 179 - return ret; 159 + mutex_lock(&ab8500->lock); 180 160 181 161 ret = ab8500->read(ab8500, addr); 182 162 if (ret < 0) ··· 201 185 u8 reg, u8 bitmask, u8 bitvalues) 202 186 { 203 187 int ret; 204 - u8 data; 205 188 /* put the u8 bank and u8 reg together into a an u16. 206 189 * bank on higher 8 bits and reg in lower */ 207 190 u16 addr = ((u16)bank) << 8 | reg; 208 191 209 - ret = mutex_lock_interruptible(&ab8500->lock); 210 - if (ret) 211 - return ret; 192 + mutex_lock(&ab8500->lock); 212 193 213 - ret = ab8500->read(ab8500, addr); 214 - if (ret < 0) { 215 - dev_err(ab8500->dev, "failed to read reg %#x: %d\n", 216 - addr, ret); 194 + if (ab8500->write_masked == NULL) { 195 + u8 data; 196 + 197 + ret = ab8500->read(ab8500, addr); 198 + if (ret < 0) { 199 + dev_err(ab8500->dev, "failed to read reg %#x: %d\n", 200 + addr, ret); 201 + goto out; 202 + } 203 + 204 + data = (u8)ret; 205 + data = (~bitmask & data) | (bitmask & bitvalues); 206 + 207 + ret = ab8500->write(ab8500, addr, data); 208 + if (ret < 0) 209 + dev_err(ab8500->dev, "failed to write reg %#x: %d\n", 210 + addr, ret); 211 + 212 + dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, 213 + data); 217 214 goto out; 218 215 } 219 - 220 - data = (u8)ret; 221 - data = (~bitmask & data) | (bitmask & bitvalues); 222 - 223 - ret = ab8500->write(ab8500, addr, data); 216 + ret = ab8500->write_masked(ab8500, addr, bitmask, bitvalues); 224 217 if (ret < 0) 225 - dev_err(ab8500->dev, "failed to write reg %#x: %d\n", 226 - addr, ret); 227 - 228 - dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, data); 218 + dev_err(ab8500->dev, "failed to modify reg %#x: %d\n", addr, 219 + ret); 229 220 out: 230 221 mutex_unlock(&ab8500->lock); 231 222 return ret; ··· 271 248 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); 272 249 int i; 273 250 274 - for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { 251 + for (i = 0; i < ab8500->mask_size; i++) { 275 252 u8 old = ab8500->oldmask[i]; 276 253 u8 new = ab8500->mask[i]; 277 254 int reg; ··· 279 256 if (new == old) 280 257 continue; 281 258 282 - /* Interrupt register 12 doesn't exist prior to version 2.0 */ 283 - if (ab8500_irq_regoffset[i] == 11 && 284 - ab8500->chip_id < AB8500_CUT2P0) 259 + /* 260 + * Interrupt register 12 doesn't exist prior to AB8500 version 261 + * 2.0 262 + */ 263 + if (ab8500->irq_reg_offset[i] == 11 && 264 + is_ab8500_1p1_or_earlier(ab8500)) 285 265 continue; 286 266 287 267 ab8500->oldmask[i] = new; 288 268 289 - reg = AB8500_IT_MASK1_REG + ab8500_irq_regoffset[i]; 269 + reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i]; 290 270 set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new); 291 271 } 292 272 ··· 332 306 333 307 dev_vdbg(ab8500->dev, "interrupt\n"); 334 308 335 - for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { 336 - int regoffset = ab8500_irq_regoffset[i]; 309 + for (i = 0; i < ab8500->mask_size; i++) { 310 + int regoffset = ab8500->irq_reg_offset[i]; 337 311 int status; 338 312 u8 value; 339 313 340 - /* Interrupt register 12 doesn't exist prior to version 2.0 */ 341 - if (regoffset == 11 && ab8500->chip_id < AB8500_CUT2P0) 314 + /* 315 + * Interrupt register 12 doesn't exist prior to AB8500 version 316 + * 2.0 317 + */ 318 + if (regoffset == 11 && is_ab8500_1p1_or_earlier(ab8500)) 342 319 continue; 343 320 344 321 status = get_register_interruptible(ab8500, AB8500_INTERRUPT, ··· 365 336 { 366 337 int base = ab8500->irq_base; 367 338 int irq; 339 + int num_irqs; 368 340 369 - for (irq = base; irq < base + AB8500_NR_IRQS; irq++) { 341 + if (is_ab9540(ab8500)) 342 + num_irqs = AB9540_NR_IRQS; 343 + else if (is_ab8505(ab8500)) 344 + num_irqs = AB8505_NR_IRQS; 345 + else 346 + num_irqs = AB8500_NR_IRQS; 347 + 348 + for (irq = base; irq < base + num_irqs; irq++) { 370 349 irq_set_chip_data(irq, ab8500); 371 350 irq_set_chip_and_handler(irq, &ab8500_irq_chip, 372 351 handle_simple_irq); ··· 393 356 { 394 357 int base = ab8500->irq_base; 395 358 int irq; 359 + int num_irqs; 396 360 397 - for (irq = base; irq < base + AB8500_NR_IRQS; irq++) { 361 + if (is_ab9540(ab8500)) 362 + num_irqs = AB9540_NR_IRQS; 363 + else if (is_ab8505(ab8500)) 364 + num_irqs = AB8505_NR_IRQS; 365 + else 366 + num_irqs = AB8500_NR_IRQS; 367 + 368 + for (irq = base; irq < base + num_irqs; irq++) { 398 369 #ifdef CONFIG_ARM 399 370 set_irq_flags(irq, 0); 400 371 #endif ··· 411 366 } 412 367 } 413 368 369 + /* AB8500 GPIO Resources */ 414 370 static struct resource __devinitdata ab8500_gpio_resources[] = { 415 371 { 416 372 .name = "GPIO_INT6", 417 373 .start = AB8500_INT_GPIO6R, 418 374 .end = AB8500_INT_GPIO41F, 375 + .flags = IORESOURCE_IRQ, 376 + } 377 + }; 378 + 379 + /* AB9540 GPIO Resources */ 380 + static struct resource __devinitdata ab9540_gpio_resources[] = { 381 + { 382 + .name = "GPIO_INT6", 383 + .start = AB8500_INT_GPIO6R, 384 + .end = AB8500_INT_GPIO41F, 385 + .flags = IORESOURCE_IRQ, 386 + }, 387 + { 388 + .name = "GPIO_INT14", 389 + .start = AB9540_INT_GPIO50R, 390 + .end = AB9540_INT_GPIO54R, 391 + .flags = IORESOURCE_IRQ, 392 + }, 393 + { 394 + .name = "GPIO_INT15", 395 + .start = AB9540_INT_GPIO50F, 396 + .end = AB9540_INT_GPIO54F, 419 397 .flags = IORESOURCE_IRQ, 420 398 } 421 399 }; ··· 559 491 .flags = IORESOURCE_IRQ, 560 492 }, 561 493 { 562 - .name = "USB_CHARGE_DET_DONE", 563 - .start = AB8500_INT_USB_CHG_DET_DONE, 564 - .end = AB8500_INT_USB_CHG_DET_DONE, 565 - .flags = IORESOURCE_IRQ, 566 - }, 567 - { 568 494 .name = "VBUS_OVV", 569 495 .start = AB8500_INT_VBUS_OVV, 570 496 .end = AB8500_INT_VBUS_OVV, ··· 596 534 }, 597 535 { 598 536 .name = "USB_CHARGER_NOT_OKR", 599 - .start = AB8500_INT_USB_CHARGER_NOT_OK, 600 - .end = AB8500_INT_USB_CHARGER_NOT_OK, 601 - .flags = IORESOURCE_IRQ, 602 - }, 603 - { 604 - .name = "USB_CHARGER_NOT_OKF", 605 - .start = AB8500_INT_USB_CHARGER_NOT_OKF, 606 - .end = AB8500_INT_USB_CHARGER_NOT_OKF, 537 + .start = AB8500_INT_USB_CHARGER_NOT_OKR, 538 + .end = AB8500_INT_USB_CHARGER_NOT_OKR, 607 539 .flags = IORESOURCE_IRQ, 608 540 }, 609 541 { ··· 672 616 .end = AB8500_INT_CC_INT_CALIB, 673 617 .flags = IORESOURCE_IRQ, 674 618 }, 619 + { 620 + .name = "CCEOC", 621 + .start = AB8500_INT_CCEOC, 622 + .end = AB8500_INT_CCEOC, 623 + .flags = IORESOURCE_IRQ, 624 + }, 675 625 }; 676 626 677 627 static struct resource __devinitdata ab8500_chargalg_resources[] = {}; ··· 692 630 }, 693 631 { 694 632 .name = "IRQ_LAST", 695 - .start = AB8500_INT_USB_CHARGER_NOT_OKF, 696 - .end = AB8500_INT_USB_CHARGER_NOT_OKF, 633 + .start = AB8500_INT_XTAL32K_KO, 634 + .end = AB8500_INT_XTAL32K_KO, 697 635 .flags = IORESOURCE_IRQ, 698 636 }, 699 637 }; ··· 753 691 }, 754 692 }; 755 693 756 - static struct mfd_cell __devinitdata ab8500_devs[] = { 694 + static struct mfd_cell __devinitdata abx500_common_devs[] = { 757 695 #ifdef CONFIG_DEBUG_FS 758 696 { 759 697 .name = "ab8500-debug", ··· 766 704 }, 767 705 { 768 706 .name = "ab8500-regulator", 769 - }, 770 - { 771 - .name = "ab8500-gpio", 772 - .num_resources = ARRAY_SIZE(ab8500_gpio_resources), 773 - .resources = ab8500_gpio_resources, 774 707 }, 775 708 { 776 709 .name = "ab8500-gpadc", ··· 805 748 { 806 749 .name = "ab8500-codec", 807 750 }, 808 - { 809 - .name = "ab8500-usb", 810 - .num_resources = ARRAY_SIZE(ab8500_usb_resources), 811 - .resources = ab8500_usb_resources, 812 - }, 751 + 813 752 { 814 753 .name = "ab8500-poweron-key", 815 754 .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), ··· 831 778 .name = "ab8500-temp", 832 779 .num_resources = ARRAY_SIZE(ab8500_temp_resources), 833 780 .resources = ab8500_temp_resources, 781 + }, 782 + }; 783 + 784 + static struct mfd_cell __devinitdata ab8500_devs[] = { 785 + { 786 + .name = "ab8500-gpio", 787 + .num_resources = ARRAY_SIZE(ab8500_gpio_resources), 788 + .resources = ab8500_gpio_resources, 789 + }, 790 + { 791 + .name = "ab8500-usb", 792 + .num_resources = ARRAY_SIZE(ab8500_usb_resources), 793 + .resources = ab8500_usb_resources, 794 + }, 795 + }; 796 + 797 + static struct mfd_cell __devinitdata ab9540_devs[] = { 798 + { 799 + .name = "ab8500-gpio", 800 + .num_resources = ARRAY_SIZE(ab9540_gpio_resources), 801 + .resources = ab9540_gpio_resources, 802 + }, 803 + { 804 + .name = "ab9540-usb", 805 + .num_resources = ARRAY_SIZE(ab8500_usb_resources), 806 + .resources = ab8500_usb_resources, 834 807 }, 835 808 }; 836 809 ··· 921 842 return sprintf(buf, "%#x\n", value); 922 843 } 923 844 845 + static ssize_t show_ab9540_dbbrstn(struct device *dev, 846 + struct device_attribute *attr, char *buf) 847 + { 848 + struct ab8500 *ab8500; 849 + int ret; 850 + u8 value; 851 + 852 + ab8500 = dev_get_drvdata(dev); 853 + 854 + ret = get_register_interruptible(ab8500, AB8500_REGU_CTRL2, 855 + AB9540_MODEM_CTRL2_REG, &value); 856 + if (ret < 0) 857 + return ret; 858 + 859 + return sprintf(buf, "%d\n", 860 + (value & AB9540_MODEM_CTRL2_SWDBBRSTN_BIT) ? 1 : 0); 861 + } 862 + 863 + static ssize_t store_ab9540_dbbrstn(struct device *dev, 864 + struct device_attribute *attr, const char *buf, size_t count) 865 + { 866 + struct ab8500 *ab8500; 867 + int ret = count; 868 + int err; 869 + u8 bitvalues; 870 + 871 + ab8500 = dev_get_drvdata(dev); 872 + 873 + if (count > 0) { 874 + switch (buf[0]) { 875 + case '0': 876 + bitvalues = 0; 877 + break; 878 + case '1': 879 + bitvalues = AB9540_MODEM_CTRL2_SWDBBRSTN_BIT; 880 + break; 881 + default: 882 + goto exit; 883 + } 884 + 885 + err = mask_and_set_register_interruptible(ab8500, 886 + AB8500_REGU_CTRL2, AB9540_MODEM_CTRL2_REG, 887 + AB9540_MODEM_CTRL2_SWDBBRSTN_BIT, bitvalues); 888 + if (err) 889 + dev_info(ab8500->dev, 890 + "Failed to set DBBRSTN %c, err %#x\n", 891 + buf[0], err); 892 + } 893 + 894 + exit: 895 + return ret; 896 + } 897 + 924 898 static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); 925 899 static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL); 926 900 static DEVICE_ATTR(turn_on_status, S_IRUGO, show_turn_on_status, NULL); 901 + static DEVICE_ATTR(dbbrstn, S_IRUGO | S_IWUSR, 902 + show_ab9540_dbbrstn, store_ab9540_dbbrstn); 927 903 928 904 static struct attribute *ab8500_sysfs_entries[] = { 929 905 &dev_attr_chip_id.attr, ··· 987 853 NULL, 988 854 }; 989 855 856 + static struct attribute *ab9540_sysfs_entries[] = { 857 + &dev_attr_chip_id.attr, 858 + &dev_attr_switch_off_status.attr, 859 + &dev_attr_turn_on_status.attr, 860 + &dev_attr_dbbrstn.attr, 861 + NULL, 862 + }; 863 + 990 864 static struct attribute_group ab8500_attr_group = { 991 865 .attrs = ab8500_sysfs_entries, 992 866 }; 993 867 994 - int __devinit ab8500_init(struct ab8500 *ab8500) 868 + static struct attribute_group ab9540_attr_group = { 869 + .attrs = ab9540_sysfs_entries, 870 + }; 871 + 872 + int __devinit ab8500_init(struct ab8500 *ab8500, enum ab8500_version version) 995 873 { 996 874 struct ab8500_platform_data *plat = dev_get_platdata(ab8500->dev); 997 875 int ret; ··· 1016 870 mutex_init(&ab8500->lock); 1017 871 mutex_init(&ab8500->irq_lock); 1018 872 873 + if (version != AB8500_VERSION_UNDEFINED) 874 + ab8500->version = version; 875 + else { 876 + ret = get_register_interruptible(ab8500, AB8500_MISC, 877 + AB8500_IC_NAME_REG, &value); 878 + if (ret < 0) 879 + return ret; 880 + 881 + ab8500->version = value; 882 + } 883 + 1019 884 ret = get_register_interruptible(ab8500, AB8500_MISC, 1020 885 AB8500_REV_REG, &value); 1021 886 if (ret < 0) 1022 887 return ret; 1023 888 1024 - switch (value) { 1025 - case AB8500_CUT1P0: 1026 - case AB8500_CUT1P1: 1027 - case AB8500_CUT2P0: 1028 - case AB8500_CUT3P0: 1029 - case AB8500_CUT3P3: 1030 - dev_info(ab8500->dev, "detected chip, revision: %#x\n", value); 1031 - break; 1032 - default: 1033 - dev_err(ab8500->dev, "unknown chip, revision: %#x\n", value); 1034 - return -EINVAL; 1035 - } 1036 889 ab8500->chip_id = value; 1037 890 891 + dev_info(ab8500->dev, "detected chip, %s rev. %1x.%1x\n", 892 + ab8500_version_str[ab8500->version], 893 + ab8500->chip_id >> 4, 894 + ab8500->chip_id & 0x0F); 895 + 896 + /* Configure AB8500 or AB9540 IRQ */ 897 + if (is_ab9540(ab8500) || is_ab8505(ab8500)) { 898 + ab8500->mask_size = AB9540_NUM_IRQ_REGS; 899 + ab8500->irq_reg_offset = ab9540_irq_regoffset; 900 + } else { 901 + ab8500->mask_size = AB8500_NUM_IRQ_REGS; 902 + ab8500->irq_reg_offset = ab8500_irq_regoffset; 903 + } 904 + ab8500->mask = kzalloc(ab8500->mask_size, GFP_KERNEL); 905 + if (!ab8500->mask) 906 + return -ENOMEM; 907 + ab8500->oldmask = kzalloc(ab8500->mask_size, GFP_KERNEL); 908 + if (!ab8500->oldmask) { 909 + ret = -ENOMEM; 910 + goto out_freemask; 911 + } 1038 912 /* 1039 913 * ab8500 has switched off due to (SWITCH_OFF_STATUS): 1040 914 * 0x01 Swoff bit programming ··· 1077 911 plat->init(ab8500); 1078 912 1079 913 /* Clear and mask all interrupts */ 1080 - for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { 1081 - /* Interrupt register 12 doesn't exist prior to version 2.0 */ 1082 - if (ab8500_irq_regoffset[i] == 11 && 1083 - ab8500->chip_id < AB8500_CUT2P0) 914 + for (i = 0; i < ab8500->mask_size; i++) { 915 + /* 916 + * Interrupt register 12 doesn't exist prior to AB8500 version 917 + * 2.0 918 + */ 919 + if (ab8500->irq_reg_offset[i] == 11 && 920 + is_ab8500_1p1_or_earlier(ab8500)) 1084 921 continue; 1085 922 1086 923 get_register_interruptible(ab8500, AB8500_INTERRUPT, 1087 - AB8500_IT_LATCH1_REG + ab8500_irq_regoffset[i], 924 + AB8500_IT_LATCH1_REG + ab8500->irq_reg_offset[i], 1088 925 &value); 1089 926 set_register_interruptible(ab8500, AB8500_INTERRUPT, 1090 - AB8500_IT_MASK1_REG + ab8500_irq_regoffset[i], 0xff); 927 + AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i], 0xff); 1091 928 } 1092 929 1093 930 ret = abx500_register_ops(ab8500->dev, &ab8500_ops); 1094 931 if (ret) 1095 - return ret; 932 + goto out_freeoldmask; 1096 933 1097 - for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) 934 + for (i = 0; i < ab8500->mask_size; i++) 1098 935 ab8500->mask[i] = ab8500->oldmask[i] = 0xff; 1099 936 1100 937 if (ab8500->irq_base) { 1101 938 ret = ab8500_irq_init(ab8500); 1102 939 if (ret) 1103 - return ret; 940 + goto out_freeoldmask; 1104 941 1105 942 ret = request_threaded_irq(ab8500->irq, NULL, ab8500_irq, 1106 943 IRQF_ONESHOT | IRQF_NO_SUSPEND, ··· 1112 943 goto out_removeirq; 1113 944 } 1114 945 1115 - ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, 1116 - ARRAY_SIZE(ab8500_devs), NULL, 946 + ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, 947 + ARRAY_SIZE(abx500_common_devs), NULL, 948 + ab8500->irq_base); 949 + 950 + if (ret) 951 + goto out_freeirq; 952 + 953 + if (is_ab9540(ab8500)) 954 + ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, 955 + ARRAY_SIZE(ab9540_devs), NULL, 956 + ab8500->irq_base); 957 + else 958 + ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, 959 + ARRAY_SIZE(ab9540_devs), NULL, 1117 960 ab8500->irq_base); 1118 961 if (ret) 1119 962 goto out_freeirq; 1120 963 1121 - ret = sysfs_create_group(&ab8500->dev->kobj, &ab8500_attr_group); 964 + if (is_ab9540(ab8500)) 965 + ret = sysfs_create_group(&ab8500->dev->kobj, 966 + &ab9540_attr_group); 967 + else 968 + ret = sysfs_create_group(&ab8500->dev->kobj, 969 + &ab8500_attr_group); 1122 970 if (ret) 1123 971 dev_err(ab8500->dev, "error creating sysfs entries\n"); 1124 - 1125 - return ret; 972 + else 973 + return ret; 1126 974 1127 975 out_freeirq: 1128 976 if (ab8500->irq_base) ··· 1147 961 out_removeirq: 1148 962 if (ab8500->irq_base) 1149 963 ab8500_irq_remove(ab8500); 964 + out_freeoldmask: 965 + kfree(ab8500->oldmask); 966 + out_freemask: 967 + kfree(ab8500->mask); 1150 968 1151 969 return ret; 1152 970 } 1153 971 1154 972 int __devexit ab8500_exit(struct ab8500 *ab8500) 1155 973 { 1156 - sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); 974 + if (is_ab9540(ab8500)) 975 + sysfs_remove_group(&ab8500->dev->kobj, &ab9540_attr_group); 976 + else 977 + sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); 1157 978 mfd_remove_devices(ab8500->dev); 1158 979 if (ab8500->irq_base) { 1159 980 free_irq(ab8500->irq, ab8500); 1160 981 ab8500_irq_remove(ab8500); 1161 982 } 983 + kfree(ab8500->oldmask); 984 + kfree(ab8500->mask); 1162 985 1163 986 return 0; 1164 987 }
+27 -3
drivers/mfd/ab8500-i2c.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/platform_device.h> 13 13 #include <linux/mfd/abx500/ab8500.h> 14 - #include <linux/mfd/db8500-prcmu.h> 14 + #include <linux/mfd/dbx500-prcmu.h> 15 15 16 16 static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data) 17 17 { 18 18 int ret; 19 19 20 20 ret = prcmu_abb_write((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); 21 + if (ret < 0) 22 + dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); 23 + return ret; 24 + } 25 + 26 + static int ab8500_i2c_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask, 27 + u8 data) 28 + { 29 + int ret; 30 + 31 + ret = prcmu_abb_write_masked((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 32 + &mask, 1); 21 33 if (ret < 0) 22 34 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); 23 35 return ret; ··· 50 38 51 39 static int __devinit ab8500_i2c_probe(struct platform_device *plf) 52 40 { 41 + const struct platform_device_id *platid = platform_get_device_id(plf); 53 42 struct ab8500 *ab8500; 54 43 struct resource *resource; 55 44 int ret; ··· 71 58 72 59 ab8500->read = ab8500_i2c_read; 73 60 ab8500->write = ab8500_i2c_write; 61 + ab8500->write_masked = ab8500_i2c_write_masked; 74 62 75 63 platform_set_drvdata(plf, ab8500); 76 64 77 - ret = ab8500_init(ab8500); 65 + ret = ab8500_init(ab8500, platid->driver_data); 78 66 if (ret) 79 67 kfree(ab8500); 68 + 80 69 81 70 return ret; 82 71 } ··· 93 78 return 0; 94 79 } 95 80 81 + static const struct platform_device_id ab8500_id[] = { 82 + { "ab8500-i2c", AB8500_VERSION_AB8500 }, 83 + { "ab8505-i2c", AB8500_VERSION_AB8505 }, 84 + { "ab9540-i2c", AB8500_VERSION_AB9540 }, 85 + { "ab8540-i2c", AB8500_VERSION_AB8540 }, 86 + { } 87 + }; 88 + 96 89 static struct platform_driver ab8500_i2c_driver = { 97 90 .driver = { 98 91 .name = "ab8500-i2c", 99 92 .owner = THIS_MODULE, 100 93 }, 101 94 .probe = ab8500_i2c_probe, 102 - .remove = __devexit_p(ab8500_i2c_remove) 95 + .remove = __devexit_p(ab8500_i2c_remove), 96 + .id_table = ab8500_id, 103 97 }; 104 98 105 99 static int __init ab8500_i2c_init(void)
+137
drivers/mfd/anatop-mfd.c
··· 1 + /* 2 + * Anatop MFD driver 3 + * 4 + * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> 5 + * Copyright (C) 2012 Linaro 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License as published by 9 + * the Free Software Foundation; either version 2 of the License, or 10 + * (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License along 18 + * with this program; if not, write to the Free Software Foundation, Inc., 19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 + * This program is free software; you can redistribute it and/or modify 21 + * it under the terms of the GNU General Public License as published by 22 + * the Free Software Foundation; either version 2 of the License, or 23 + * (at your option) any later version. 24 + * 25 + * This program is distributed in the hope that it will be useful, 26 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 + * GNU General Public License for more details. 29 + * 30 + * You should have received a copy of the GNU General Public License along 31 + * with this program; if not, write to the Free Software Foundation, Inc., 32 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 33 + * 34 + */ 35 + 36 + #include <linux/io.h> 37 + #include <linux/module.h> 38 + #include <linux/platform_device.h> 39 + #include <linux/of.h> 40 + #include <linux/of_platform.h> 41 + #include <linux/of_address.h> 42 + #include <linux/mfd/anatop.h> 43 + 44 + u32 anatop_get_bits(struct anatop *adata, u32 addr, int bit_shift, 45 + int bit_width) 46 + { 47 + u32 val, mask; 48 + 49 + if (bit_width == 32) 50 + mask = ~0; 51 + else 52 + mask = (1 << bit_width) - 1; 53 + 54 + val = readl(adata->ioreg + addr); 55 + val = (val >> bit_shift) & mask; 56 + 57 + return val; 58 + } 59 + EXPORT_SYMBOL_GPL(anatop_get_bits); 60 + 61 + void anatop_set_bits(struct anatop *adata, u32 addr, int bit_shift, 62 + int bit_width, u32 data) 63 + { 64 + u32 val, mask; 65 + 66 + if (bit_width == 32) 67 + mask = ~0; 68 + else 69 + mask = (1 << bit_width) - 1; 70 + 71 + spin_lock(&adata->reglock); 72 + val = readl(adata->ioreg + addr) & ~(mask << bit_shift); 73 + writel((data << bit_shift) | val, adata->ioreg + addr); 74 + spin_unlock(&adata->reglock); 75 + } 76 + EXPORT_SYMBOL_GPL(anatop_set_bits); 77 + 78 + static const struct of_device_id of_anatop_match[] = { 79 + { .compatible = "fsl,imx6q-anatop", }, 80 + { }, 81 + }; 82 + 83 + static int __devinit of_anatop_probe(struct platform_device *pdev) 84 + { 85 + struct device *dev = &pdev->dev; 86 + struct device_node *np = dev->of_node; 87 + void *ioreg; 88 + struct anatop *drvdata; 89 + 90 + ioreg = of_iomap(np, 0); 91 + if (!ioreg) 92 + return -EADDRNOTAVAIL; 93 + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); 94 + if (!drvdata) 95 + return -ENOMEM; 96 + drvdata->ioreg = ioreg; 97 + spin_lock_init(&drvdata->reglock); 98 + platform_set_drvdata(pdev, drvdata); 99 + of_platform_populate(np, of_anatop_match, NULL, dev); 100 + 101 + return 0; 102 + } 103 + 104 + static int __devexit of_anatop_remove(struct platform_device *pdev) 105 + { 106 + struct anatop *drvdata; 107 + drvdata = platform_get_drvdata(pdev); 108 + iounmap(drvdata->ioreg); 109 + 110 + return 0; 111 + } 112 + 113 + static struct platform_driver anatop_of_driver = { 114 + .driver = { 115 + .name = "anatop-mfd", 116 + .owner = THIS_MODULE, 117 + .of_match_table = of_anatop_match, 118 + }, 119 + .probe = of_anatop_probe, 120 + .remove = of_anatop_remove, 121 + }; 122 + 123 + static int __init anatop_init(void) 124 + { 125 + return platform_driver_register(&anatop_of_driver); 126 + } 127 + postcore_initcall(anatop_init); 128 + 129 + static void __exit anatop_exit(void) 130 + { 131 + platform_driver_unregister(&anatop_of_driver); 132 + } 133 + module_exit(anatop_exit); 134 + 135 + MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); 136 + MODULE_DESCRIPTION("ANATOP MFD driver"); 137 + MODULE_LICENSE("GPL v2");
+6
drivers/mfd/asic3.c
··· 525 525 return; 526 526 } 527 527 528 + static int asic3_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 529 + { 530 + return (offset < ASIC3_NUM_GPIOS) ? IRQ_BOARD_START + offset : -ENXIO; 531 + } 532 + 528 533 static __init int asic3_gpio_probe(struct platform_device *pdev, 529 534 u16 *gpio_config, int num) 530 535 { ··· 981 976 asic->gpio.set = asic3_gpio_set; 982 977 asic->gpio.direction_input = asic3_gpio_direction_input; 983 978 asic->gpio.direction_output = asic3_gpio_direction_output; 979 + asic->gpio.to_irq = asic3_gpio_to_irq; 984 980 985 981 ret = asic3_gpio_probe(pdev, 986 982 pdata->gpio_config,
-3
drivers/mfd/da9052-core.c
··· 16 16 #include <linux/input.h> 17 17 #include <linux/interrupt.h> 18 18 #include <linux/irq.h> 19 - #include <linux/mutex.h> 20 19 #include <linux/mfd/core.h> 21 20 #include <linux/slab.h> 22 21 #include <linux/module.h> ··· 645 646 struct da9052_pdata *pdata = da9052->dev->platform_data; 646 647 struct irq_desc *desc; 647 648 int ret; 648 - 649 - mutex_init(&da9052->io_lock); 650 649 651 650 if (pdata && pdata->init != NULL) 652 651 pdata->init(da9052);
+7 -4
drivers/mfd/da9052-i2c.c
··· 74 74 75 75 ret = da9052_i2c_enable_multiwrite(da9052); 76 76 if (ret < 0) 77 - goto err; 77 + goto err_regmap; 78 78 79 79 ret = da9052_device_init(da9052, id->driver_data); 80 80 if (ret != 0) 81 - goto err; 81 + goto err_regmap; 82 82 83 83 return 0; 84 84 85 + err_regmap: 86 + regmap_exit(da9052->regmap); 85 87 err: 86 88 kfree(da9052); 87 89 return ret; 88 90 } 89 91 90 - static int da9052_i2c_remove(struct i2c_client *client) 92 + static int __devexit da9052_i2c_remove(struct i2c_client *client) 91 93 { 92 94 struct da9052 *da9052 = i2c_get_clientdata(client); 93 95 94 96 da9052_device_exit(da9052); 97 + regmap_exit(da9052->regmap); 95 98 kfree(da9052); 96 99 97 100 return 0; ··· 110 107 111 108 static struct i2c_driver da9052_i2c_driver = { 112 109 .probe = da9052_i2c_probe, 113 - .remove = da9052_i2c_remove, 110 + .remove = __devexit_p(da9052_i2c_remove), 114 111 .id_table = da9052_i2c_id, 115 112 .driver = { 116 113 .name = "da9052",
+6 -3
drivers/mfd/da9052-spi.c
··· 21 21 22 22 #include <linux/mfd/da9052/da9052.h> 23 23 24 - static int da9052_spi_probe(struct spi_device *spi) 24 + static int __devinit da9052_spi_probe(struct spi_device *spi) 25 25 { 26 26 int ret; 27 27 const struct spi_device_id *id = spi_get_device_id(spi); ··· 52 52 53 53 ret = da9052_device_init(da9052, id->driver_data); 54 54 if (ret != 0) 55 - goto err; 55 + goto err_regmap; 56 56 57 57 return 0; 58 58 59 + err_regmap: 60 + regmap_exit(da9052->regmap); 59 61 err: 60 62 kfree(da9052); 61 63 return ret; 62 64 } 63 65 64 - static int da9052_spi_remove(struct spi_device *spi) 66 + static int __devexit da9052_spi_remove(struct spi_device *spi) 65 67 { 66 68 struct da9052 *da9052 = dev_get_drvdata(&spi->dev); 67 69 68 70 da9052_device_exit(da9052); 71 + regmap_exit(da9052->regmap); 69 72 kfree(da9052); 70 73 71 74 return 0;
+889 -337
drivers/mfd/db8500-prcmu.c
··· 30 30 #include <linux/mfd/dbx500-prcmu.h> 31 31 #include <linux/regulator/db8500-prcmu.h> 32 32 #include <linux/regulator/machine.h> 33 + #include <asm/hardware/gic.h> 33 34 #include <mach/hardware.h> 34 35 #include <mach/irqs.h> 35 36 #include <mach/db8500-regs.h> ··· 39 38 40 39 /* Offset for the firmware version within the TCPM */ 41 40 #define PRCMU_FW_VERSION_OFFSET 0xA4 42 - 43 - /* PRCMU project numbers, defined by PRCMU FW */ 44 - #define PRCMU_PROJECT_ID_8500V1_0 1 45 - #define PRCMU_PROJECT_ID_8500V2_0 2 46 - #define PRCMU_PROJECT_ID_8400V2_0 3 47 41 48 42 /* Index of different voltages to be used when accessing AVSData */ 49 43 #define PRCM_AVS_BASE 0x2FC ··· 133 137 #define PRCM_REQ_MB1_ARM_OPP (PRCM_REQ_MB1 + 0x0) 134 138 #define PRCM_REQ_MB1_APE_OPP (PRCM_REQ_MB1 + 0x1) 135 139 #define PRCM_REQ_MB1_PLL_ON_OFF (PRCM_REQ_MB1 + 0x4) 140 + #define PLL_SOC0_OFF 0x1 141 + #define PLL_SOC0_ON 0x2 136 142 #define PLL_SOC1_OFF 0x4 137 143 #define PLL_SOC1_ON 0x8 138 144 ··· 264 266 #define WAKEUP_BIT_GPIO7 BIT(30) 265 267 #define WAKEUP_BIT_GPIO8 BIT(31) 266 268 269 + static struct { 270 + bool valid; 271 + struct prcmu_fw_version version; 272 + } fw_info; 273 + 267 274 /* 268 275 * This vector maps irq numbers to the bits in the bit field used in 269 276 * communication with the PRCMU firmware. ··· 344 341 * mb1_transfer - state needed for mailbox 1 communication. 345 342 * @lock: The transaction lock. 346 343 * @work: The transaction completion structure. 344 + * @ape_opp: The current APE OPP. 347 345 * @ack: Reply ("acknowledge") data. 348 346 */ 349 347 static struct { 350 348 struct mutex lock; 351 349 struct completion work; 350 + u8 ape_opp; 352 351 struct { 353 352 u8 header; 354 353 u8 arm_opp; ··· 418 413 static atomic_t ac_wake_req_state = ATOMIC_INIT(0); 419 414 420 415 /* Spinlocks */ 416 + static DEFINE_SPINLOCK(prcmu_lock); 421 417 static DEFINE_SPINLOCK(clkout_lock); 422 - static DEFINE_SPINLOCK(gpiocr_lock); 423 418 424 419 /* Global var to runtime determine TCDM base for v2 or v1 */ 425 420 static __iomem void *tcdm_base; 426 421 427 422 struct clk_mgt { 428 - unsigned int offset; 423 + void __iomem *reg; 429 424 u32 pllsw; 425 + int branch; 426 + bool clk38div; 427 + }; 428 + 429 + enum { 430 + PLL_RAW, 431 + PLL_FIX, 432 + PLL_DIV 430 433 }; 431 434 432 435 static DEFINE_SPINLOCK(clk_mgt_lock); 433 436 434 - #define CLK_MGT_ENTRY(_name)[PRCMU_##_name] = { (PRCM_##_name##_MGT_OFF), 0 } 437 + #define CLK_MGT_ENTRY(_name, _branch, _clk38div)[PRCMU_##_name] = \ 438 + { (PRCM_##_name##_MGT), 0 , _branch, _clk38div} 435 439 struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = { 436 - CLK_MGT_ENTRY(SGACLK), 437 - CLK_MGT_ENTRY(UARTCLK), 438 - CLK_MGT_ENTRY(MSP02CLK), 439 - CLK_MGT_ENTRY(MSP1CLK), 440 - CLK_MGT_ENTRY(I2CCLK), 441 - CLK_MGT_ENTRY(SDMMCCLK), 442 - CLK_MGT_ENTRY(SLIMCLK), 443 - CLK_MGT_ENTRY(PER1CLK), 444 - CLK_MGT_ENTRY(PER2CLK), 445 - CLK_MGT_ENTRY(PER3CLK), 446 - CLK_MGT_ENTRY(PER5CLK), 447 - CLK_MGT_ENTRY(PER6CLK), 448 - CLK_MGT_ENTRY(PER7CLK), 449 - CLK_MGT_ENTRY(LCDCLK), 450 - CLK_MGT_ENTRY(BMLCLK), 451 - CLK_MGT_ENTRY(HSITXCLK), 452 - CLK_MGT_ENTRY(HSIRXCLK), 453 - CLK_MGT_ENTRY(HDMICLK), 454 - CLK_MGT_ENTRY(APEATCLK), 455 - CLK_MGT_ENTRY(APETRACECLK), 456 - CLK_MGT_ENTRY(MCDECLK), 457 - CLK_MGT_ENTRY(IPI2CCLK), 458 - CLK_MGT_ENTRY(DSIALTCLK), 459 - CLK_MGT_ENTRY(DMACLK), 460 - CLK_MGT_ENTRY(B2R2CLK), 461 - CLK_MGT_ENTRY(TVCLK), 462 - CLK_MGT_ENTRY(SSPCLK), 463 - CLK_MGT_ENTRY(RNGCLK), 464 - CLK_MGT_ENTRY(UICCCLK), 440 + CLK_MGT_ENTRY(SGACLK, PLL_DIV, false), 441 + CLK_MGT_ENTRY(UARTCLK, PLL_FIX, true), 442 + CLK_MGT_ENTRY(MSP02CLK, PLL_FIX, true), 443 + CLK_MGT_ENTRY(MSP1CLK, PLL_FIX, true), 444 + CLK_MGT_ENTRY(I2CCLK, PLL_FIX, true), 445 + CLK_MGT_ENTRY(SDMMCCLK, PLL_DIV, true), 446 + CLK_MGT_ENTRY(SLIMCLK, PLL_FIX, true), 447 + CLK_MGT_ENTRY(PER1CLK, PLL_DIV, true), 448 + CLK_MGT_ENTRY(PER2CLK, PLL_DIV, true), 449 + CLK_MGT_ENTRY(PER3CLK, PLL_DIV, true), 450 + CLK_MGT_ENTRY(PER5CLK, PLL_DIV, true), 451 + CLK_MGT_ENTRY(PER6CLK, PLL_DIV, true), 452 + CLK_MGT_ENTRY(PER7CLK, PLL_DIV, true), 453 + CLK_MGT_ENTRY(LCDCLK, PLL_FIX, true), 454 + CLK_MGT_ENTRY(BMLCLK, PLL_DIV, true), 455 + CLK_MGT_ENTRY(HSITXCLK, PLL_DIV, true), 456 + CLK_MGT_ENTRY(HSIRXCLK, PLL_DIV, true), 457 + CLK_MGT_ENTRY(HDMICLK, PLL_FIX, false), 458 + CLK_MGT_ENTRY(APEATCLK, PLL_DIV, true), 459 + CLK_MGT_ENTRY(APETRACECLK, PLL_DIV, true), 460 + CLK_MGT_ENTRY(MCDECLK, PLL_DIV, true), 461 + CLK_MGT_ENTRY(IPI2CCLK, PLL_FIX, true), 462 + CLK_MGT_ENTRY(DSIALTCLK, PLL_FIX, false), 463 + CLK_MGT_ENTRY(DMACLK, PLL_DIV, true), 464 + CLK_MGT_ENTRY(B2R2CLK, PLL_DIV, true), 465 + CLK_MGT_ENTRY(TVCLK, PLL_FIX, true), 466 + CLK_MGT_ENTRY(SSPCLK, PLL_FIX, true), 467 + CLK_MGT_ENTRY(RNGCLK, PLL_FIX, true), 468 + CLK_MGT_ENTRY(UICCCLK, PLL_FIX, false), 465 469 }; 466 470 467 - static struct regulator *hwacc_regulator[NUM_HW_ACC]; 468 - static struct regulator *hwacc_ret_regulator[NUM_HW_ACC]; 469 - 470 - static bool hwacc_enabled[NUM_HW_ACC]; 471 - static bool hwacc_ret_enabled[NUM_HW_ACC]; 472 - 473 - static const char *hwacc_regulator_name[NUM_HW_ACC] = { 474 - [HW_ACC_SVAMMDSP] = "hwacc-sva-mmdsp", 475 - [HW_ACC_SVAPIPE] = "hwacc-sva-pipe", 476 - [HW_ACC_SIAMMDSP] = "hwacc-sia-mmdsp", 477 - [HW_ACC_SIAPIPE] = "hwacc-sia-pipe", 478 - [HW_ACC_SGA] = "hwacc-sga", 479 - [HW_ACC_B2R2] = "hwacc-b2r2", 480 - [HW_ACC_MCDE] = "hwacc-mcde", 481 - [HW_ACC_ESRAM1] = "hwacc-esram1", 482 - [HW_ACC_ESRAM2] = "hwacc-esram2", 483 - [HW_ACC_ESRAM3] = "hwacc-esram3", 484 - [HW_ACC_ESRAM4] = "hwacc-esram4", 471 + struct dsiclk { 472 + u32 divsel_mask; 473 + u32 divsel_shift; 474 + u32 divsel; 485 475 }; 486 476 487 - static const char *hwacc_ret_regulator_name[NUM_HW_ACC] = { 488 - [HW_ACC_SVAMMDSP] = "hwacc-sva-mmdsp-ret", 489 - [HW_ACC_SIAMMDSP] = "hwacc-sia-mmdsp-ret", 490 - [HW_ACC_ESRAM1] = "hwacc-esram1-ret", 491 - [HW_ACC_ESRAM2] = "hwacc-esram2-ret", 492 - [HW_ACC_ESRAM3] = "hwacc-esram3-ret", 493 - [HW_ACC_ESRAM4] = "hwacc-esram4-ret", 477 + static struct dsiclk dsiclk[2] = { 478 + { 479 + .divsel_mask = PRCM_DSI_PLLOUT_SEL_DSI0_PLLOUT_DIVSEL_MASK, 480 + .divsel_shift = PRCM_DSI_PLLOUT_SEL_DSI0_PLLOUT_DIVSEL_SHIFT, 481 + .divsel = PRCM_DSI_PLLOUT_SEL_PHI, 482 + }, 483 + { 484 + .divsel_mask = PRCM_DSI_PLLOUT_SEL_DSI1_PLLOUT_DIVSEL_MASK, 485 + .divsel_shift = PRCM_DSI_PLLOUT_SEL_DSI1_PLLOUT_DIVSEL_SHIFT, 486 + .divsel = PRCM_DSI_PLLOUT_SEL_PHI, 487 + } 488 + }; 489 + 490 + struct dsiescclk { 491 + u32 en; 492 + u32 div_mask; 493 + u32 div_shift; 494 + }; 495 + 496 + static struct dsiescclk dsiescclk[3] = { 497 + { 498 + .en = PRCM_DSITVCLK_DIV_DSI0_ESC_CLK_EN, 499 + .div_mask = PRCM_DSITVCLK_DIV_DSI0_ESC_CLK_DIV_MASK, 500 + .div_shift = PRCM_DSITVCLK_DIV_DSI0_ESC_CLK_DIV_SHIFT, 501 + }, 502 + { 503 + .en = PRCM_DSITVCLK_DIV_DSI1_ESC_CLK_EN, 504 + .div_mask = PRCM_DSITVCLK_DIV_DSI1_ESC_CLK_DIV_MASK, 505 + .div_shift = PRCM_DSITVCLK_DIV_DSI1_ESC_CLK_DIV_SHIFT, 506 + }, 507 + { 508 + .en = PRCM_DSITVCLK_DIV_DSI2_ESC_CLK_EN, 509 + .div_mask = PRCM_DSITVCLK_DIV_DSI2_ESC_CLK_DIV_MASK, 510 + .div_shift = PRCM_DSITVCLK_DIV_DSI2_ESC_CLK_DIV_SHIFT, 511 + } 494 512 }; 495 513 496 514 /* ··· 531 503 /* PLLDIV=12, PLLSW=4 (PLLDDR) */ 532 504 #define PRCMU_DSI_CLOCK_SETTING 0x0000008C 533 505 534 - /* PLLDIV=8, PLLSW=4 (PLLDDR) */ 535 - #define PRCMU_DSI_CLOCK_SETTING_U8400 0x00000088 536 - 537 506 /* DPI 50000000 Hz */ 538 507 #define PRCMU_DPI_CLOCK_SETTING ((1 << PRCMU_CLK_PLL_SW_SHIFT) | \ 539 508 (16 << PRCMU_CLK_PLL_DIV_SHIFT)) ··· 538 513 539 514 /* D=101, N=1, R=4, SELDIV2=0 */ 540 515 #define PRCMU_PLLDSI_FREQ_SETTING 0x00040165 541 - 542 - /* D=70, N=1, R=3, SELDIV2=0 */ 543 - #define PRCMU_PLLDSI_FREQ_SETTING_U8400 0x00030146 544 516 545 517 #define PRCMU_ENABLE_PLLDSI 0x00000001 546 518 #define PRCMU_DISABLE_PLLDSI 0x00000000 ··· 550 528 551 529 #define PRCMU_PLLDSI_LOCKP_LOCKED 0x3 552 530 553 - static struct { 554 - u8 project_number; 555 - u8 api_version; 556 - u8 func_version; 557 - u8 errata; 558 - } prcmu_version; 559 - 560 - 561 531 int db8500_prcmu_enable_dsipll(void) 562 532 { 563 533 int i; 564 - unsigned int plldsifreq; 565 534 566 535 /* Clear DSIPLL_RESETN */ 567 536 writel(PRCMU_RESET_DSIPLL, PRCM_APE_RESETN_CLR); 568 537 /* Unclamp DSIPLL in/out */ 569 538 writel(PRCMU_UNCLAMP_DSIPLL, PRCM_MMIP_LS_CLAMP_CLR); 570 539 571 - if (prcmu_is_u8400()) 572 - plldsifreq = PRCMU_PLLDSI_FREQ_SETTING_U8400; 573 - else 574 - plldsifreq = PRCMU_PLLDSI_FREQ_SETTING; 575 540 /* Set DSI PLL FREQ */ 576 - writel(plldsifreq, PRCM_PLLDSI_FREQ); 541 + writel(PRCMU_PLLDSI_FREQ_SETTING, PRCM_PLLDSI_FREQ); 577 542 writel(PRCMU_DSI_PLLOUT_SEL_SETTING, PRCM_DSI_PLLOUT_SEL); 578 543 /* Enable Escape clocks */ 579 544 writel(PRCMU_ENABLE_ESCAPE_CLOCK_DIV, PRCM_DSITVCLK_DIV); ··· 592 583 int db8500_prcmu_set_display_clocks(void) 593 584 { 594 585 unsigned long flags; 595 - unsigned int dsiclk; 596 - 597 - if (prcmu_is_u8400()) 598 - dsiclk = PRCMU_DSI_CLOCK_SETTING_U8400; 599 - else 600 - dsiclk = PRCMU_DSI_CLOCK_SETTING; 601 586 602 587 spin_lock_irqsave(&clk_mgt_lock, flags); 603 588 ··· 599 596 while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0) 600 597 cpu_relax(); 601 598 602 - writel(dsiclk, PRCM_HDMICLK_MGT); 599 + writel(PRCMU_DSI_CLOCK_SETTING, PRCM_HDMICLK_MGT); 603 600 writel(PRCMU_DSI_LP_CLOCK_SETTING, PRCM_TVCLK_MGT); 604 601 writel(PRCMU_DPI_CLOCK_SETTING, PRCM_LCDCLK_MGT); 605 602 ··· 611 608 return 0; 612 609 } 613 610 614 - /** 615 - * prcmu_enable_spi2 - Enables pin muxing for SPI2 on OtherAlternateC1. 616 - */ 617 - void prcmu_enable_spi2(void) 611 + u32 db8500_prcmu_read(unsigned int reg) 618 612 { 619 - u32 reg; 620 - unsigned long flags; 621 - 622 - spin_lock_irqsave(&gpiocr_lock, flags); 623 - reg = readl(PRCM_GPIOCR); 624 - writel(reg | PRCM_GPIOCR_SPI2_SELECT, PRCM_GPIOCR); 625 - spin_unlock_irqrestore(&gpiocr_lock, flags); 613 + return readl(_PRCMU_BASE + reg); 626 614 } 627 615 628 - /** 629 - * prcmu_disable_spi2 - Disables pin muxing for SPI2 on OtherAlternateC1. 630 - */ 631 - void prcmu_disable_spi2(void) 616 + void db8500_prcmu_write(unsigned int reg, u32 value) 632 617 { 633 - u32 reg; 634 618 unsigned long flags; 635 619 636 - spin_lock_irqsave(&gpiocr_lock, flags); 637 - reg = readl(PRCM_GPIOCR); 638 - writel(reg & ~PRCM_GPIOCR_SPI2_SELECT, PRCM_GPIOCR); 639 - spin_unlock_irqrestore(&gpiocr_lock, flags); 620 + spin_lock_irqsave(&prcmu_lock, flags); 621 + writel(value, (_PRCMU_BASE + reg)); 622 + spin_unlock_irqrestore(&prcmu_lock, flags); 623 + } 624 + 625 + void db8500_prcmu_write_masked(unsigned int reg, u32 mask, u32 value) 626 + { 627 + u32 val; 628 + unsigned long flags; 629 + 630 + spin_lock_irqsave(&prcmu_lock, flags); 631 + val = readl(_PRCMU_BASE + reg); 632 + val = ((val & ~mask) | (value & mask)); 633 + writel(val, (_PRCMU_BASE + reg)); 634 + spin_unlock_irqrestore(&prcmu_lock, flags); 635 + } 636 + 637 + struct prcmu_fw_version *prcmu_get_fw_version(void) 638 + { 639 + return fw_info.valid ? &fw_info.version : NULL; 640 640 } 641 641 642 642 bool prcmu_has_arm_maxopp(void) 643 643 { 644 644 return (readb(tcdm_base + PRCM_AVS_VARM_MAX_OPP) & 645 645 PRCM_AVS_ISMODEENABLE_MASK) == PRCM_AVS_ISMODEENABLE_MASK; 646 - } 647 - 648 - bool prcmu_is_u8400(void) 649 - { 650 - return prcmu_version.project_number == PRCMU_PROJECT_ID_8400V2_0; 651 646 } 652 647 653 648 /** ··· 788 787 return 0; 789 788 } 790 789 790 + u8 db8500_prcmu_get_power_state_result(void) 791 + { 792 + return readb(tcdm_base + PRCM_ACK_MB0_AP_PWRSTTR_STATUS); 793 + } 794 + 795 + /* This function decouple the gic from the prcmu */ 796 + int db8500_prcmu_gic_decouple(void) 797 + { 798 + u32 val = readl(PRCM_A9_MASK_REQ); 799 + 800 + /* Set bit 0 register value to 1 */ 801 + writel(val | PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ, 802 + PRCM_A9_MASK_REQ); 803 + 804 + /* Make sure the register is updated */ 805 + readl(PRCM_A9_MASK_REQ); 806 + 807 + /* Wait a few cycles for the gic mask completion */ 808 + udelay(1); 809 + 810 + return 0; 811 + } 812 + 813 + /* This function recouple the gic with the prcmu */ 814 + int db8500_prcmu_gic_recouple(void) 815 + { 816 + u32 val = readl(PRCM_A9_MASK_REQ); 817 + 818 + /* Set bit 0 register value to 0 */ 819 + writel(val & ~PRCM_A9_MASK_REQ_PRCM_A9_MASK_REQ, PRCM_A9_MASK_REQ); 820 + 821 + return 0; 822 + } 823 + 824 + #define PRCMU_GIC_NUMBER_REGS 5 825 + 826 + /* 827 + * This function checks if there are pending irq on the gic. It only 828 + * makes sense if the gic has been decoupled before with the 829 + * db8500_prcmu_gic_decouple function. Disabling an interrupt only 830 + * disables the forwarding of the interrupt to any CPU interface. It 831 + * does not prevent the interrupt from changing state, for example 832 + * becoming pending, or active and pending if it is already 833 + * active. Hence, we have to check the interrupt is pending *and* is 834 + * active. 835 + */ 836 + bool db8500_prcmu_gic_pending_irq(void) 837 + { 838 + u32 pr; /* Pending register */ 839 + u32 er; /* Enable register */ 840 + void __iomem *dist_base = __io_address(U8500_GIC_DIST_BASE); 841 + int i; 842 + 843 + /* 5 registers. STI & PPI not skipped */ 844 + for (i = 0; i < PRCMU_GIC_NUMBER_REGS; i++) { 845 + 846 + pr = readl_relaxed(dist_base + GIC_DIST_PENDING_SET + i * 4); 847 + er = readl_relaxed(dist_base + GIC_DIST_ENABLE_SET + i * 4); 848 + 849 + if (pr & er) 850 + return true; /* There is a pending interrupt */ 851 + } 852 + 853 + return false; 854 + } 855 + 856 + /* 857 + * This function checks if there are pending interrupt on the 858 + * prcmu which has been delegated to monitor the irqs with the 859 + * db8500_prcmu_copy_gic_settings function. 860 + */ 861 + bool db8500_prcmu_pending_irq(void) 862 + { 863 + u32 it, im; 864 + int i; 865 + 866 + for (i = 0; i < PRCMU_GIC_NUMBER_REGS - 1; i++) { 867 + it = readl(PRCM_ARMITVAL31TO0 + i * 4); 868 + im = readl(PRCM_ARMITMSK31TO0 + i * 4); 869 + if (it & im) 870 + return true; /* There is a pending interrupt */ 871 + } 872 + 873 + return false; 874 + } 875 + 876 + /* 877 + * This function checks if the specified cpu is in in WFI. It's usage 878 + * makes sense only if the gic is decoupled with the db8500_prcmu_gic_decouple 879 + * function. Of course passing smp_processor_id() to this function will 880 + * always return false... 881 + */ 882 + bool db8500_prcmu_is_cpu_in_wfi(int cpu) 883 + { 884 + return readl(PRCM_ARM_WFI_STANDBY) & cpu ? PRCM_ARM_WFI_STANDBY_WFI1 : 885 + PRCM_ARM_WFI_STANDBY_WFI0; 886 + } 887 + 888 + /* 889 + * This function copies the gic SPI settings to the prcmu in order to 890 + * monitor them and abort/finish the retention/off sequence or state. 891 + */ 892 + int db8500_prcmu_copy_gic_settings(void) 893 + { 894 + u32 er; /* Enable register */ 895 + void __iomem *dist_base = __io_address(U8500_GIC_DIST_BASE); 896 + int i; 897 + 898 + /* We skip the STI and PPI */ 899 + for (i = 0; i < PRCMU_GIC_NUMBER_REGS - 1; i++) { 900 + er = readl_relaxed(dist_base + 901 + GIC_DIST_ENABLE_SET + (i + 1) * 4); 902 + writel(er, PRCM_ARMITMSK31TO0 + i * 4); 903 + } 904 + 905 + return 0; 906 + } 907 + 791 908 /* This function should only be called while mb0_transfer.lock is held. */ 792 909 static void config_wakeups(void) 793 910 { ··· 1028 909 } 1029 910 1030 911 /** 1031 - * prcmu_get_ddr_opp - get the current DDR OPP 912 + * db8500_prcmu_get_ddr_opp - get the current DDR OPP 1032 913 * 1033 914 * Returns: the current DDR OPP 1034 915 */ 1035 - int prcmu_get_ddr_opp(void) 916 + int db8500_prcmu_get_ddr_opp(void) 1036 917 { 1037 918 return readb(PRCM_DDR_SUBSYS_APE_MINBW); 1038 919 } 1039 920 1040 921 /** 1041 - * set_ddr_opp - set the appropriate DDR OPP 922 + * db8500_set_ddr_opp - set the appropriate DDR OPP 1042 923 * @opp: The new DDR operating point to which transition is to be made 1043 924 * Returns: 0 on success, non-zero on failure 1044 925 * 1045 926 * This function sets the operating point of the DDR. 1046 927 */ 1047 - int prcmu_set_ddr_opp(u8 opp) 928 + int db8500_prcmu_set_ddr_opp(u8 opp) 1048 929 { 1049 930 if (opp < DDR_100_OPP || opp > DDR_25_OPP) 1050 931 return -EINVAL; ··· 1054 935 1055 936 return 0; 1056 937 } 938 + 939 + /* Divide the frequency of certain clocks by 2 for APE_50_PARTLY_25_OPP. */ 940 + static void request_even_slower_clocks(bool enable) 941 + { 942 + void __iomem *clock_reg[] = { 943 + PRCM_ACLK_MGT, 944 + PRCM_DMACLK_MGT 945 + }; 946 + unsigned long flags; 947 + unsigned int i; 948 + 949 + spin_lock_irqsave(&clk_mgt_lock, flags); 950 + 951 + /* Grab the HW semaphore. */ 952 + while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0) 953 + cpu_relax(); 954 + 955 + for (i = 0; i < ARRAY_SIZE(clock_reg); i++) { 956 + u32 val; 957 + u32 div; 958 + 959 + val = readl(clock_reg[i]); 960 + div = (val & PRCM_CLK_MGT_CLKPLLDIV_MASK); 961 + if (enable) { 962 + if ((div <= 1) || (div > 15)) { 963 + pr_err("prcmu: Bad clock divider %d in %s\n", 964 + div, __func__); 965 + goto unlock_and_return; 966 + } 967 + div <<= 1; 968 + } else { 969 + if (div <= 2) 970 + goto unlock_and_return; 971 + div >>= 1; 972 + } 973 + val = ((val & ~PRCM_CLK_MGT_CLKPLLDIV_MASK) | 974 + (div & PRCM_CLK_MGT_CLKPLLDIV_MASK)); 975 + writel(val, clock_reg[i]); 976 + } 977 + 978 + unlock_and_return: 979 + /* Release the HW semaphore. */ 980 + writel(0, PRCM_SEM); 981 + 982 + spin_unlock_irqrestore(&clk_mgt_lock, flags); 983 + } 984 + 1057 985 /** 1058 - * set_ape_opp - set the appropriate APE OPP 986 + * db8500_set_ape_opp - set the appropriate APE OPP 1059 987 * @opp: The new APE operating point to which transition is to be made 1060 988 * Returns: 0 on success, non-zero on failure 1061 989 * 1062 990 * This function sets the operating point of the APE. 1063 991 */ 1064 - int prcmu_set_ape_opp(u8 opp) 992 + int db8500_prcmu_set_ape_opp(u8 opp) 1065 993 { 1066 994 int r = 0; 1067 995 996 + if (opp == mb1_transfer.ape_opp) 997 + return 0; 998 + 1068 999 mutex_lock(&mb1_transfer.lock); 1000 + 1001 + if (mb1_transfer.ape_opp == APE_50_PARTLY_25_OPP) 1002 + request_even_slower_clocks(false); 1003 + 1004 + if ((opp != APE_100_OPP) && (mb1_transfer.ape_opp != APE_100_OPP)) 1005 + goto skip_message; 1069 1006 1070 1007 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(1)) 1071 1008 cpu_relax(); 1072 1009 1073 1010 writeb(MB1H_ARM_APE_OPP, (tcdm_base + PRCM_MBOX_HEADER_REQ_MB1)); 1074 1011 writeb(ARM_NO_CHANGE, (tcdm_base + PRCM_REQ_MB1_ARM_OPP)); 1075 - writeb(opp, (tcdm_base + PRCM_REQ_MB1_APE_OPP)); 1012 + writeb(((opp == APE_50_PARTLY_25_OPP) ? APE_50_OPP : opp), 1013 + (tcdm_base + PRCM_REQ_MB1_APE_OPP)); 1076 1014 1077 1015 writel(MBOX_BIT(1), PRCM_MBOX_CPU_SET); 1078 1016 wait_for_completion(&mb1_transfer.work); ··· 1138 962 (mb1_transfer.ack.ape_opp != opp)) 1139 963 r = -EIO; 1140 964 965 + skip_message: 966 + if ((!r && (opp == APE_50_PARTLY_25_OPP)) || 967 + (r && (mb1_transfer.ape_opp == APE_50_PARTLY_25_OPP))) 968 + request_even_slower_clocks(true); 969 + if (!r) 970 + mb1_transfer.ape_opp = opp; 971 + 1141 972 mutex_unlock(&mb1_transfer.lock); 1142 973 1143 974 return r; 1144 975 } 1145 976 1146 977 /** 1147 - * prcmu_get_ape_opp - get the current APE OPP 978 + * db8500_prcmu_get_ape_opp - get the current APE OPP 1148 979 * 1149 980 * Returns: the current APE OPP 1150 981 */ 1151 - int prcmu_get_ape_opp(void) 982 + int db8500_prcmu_get_ape_opp(void) 1152 983 { 1153 984 return readb(tcdm_base + PRCM_ACK_MB1_CURRENT_APE_OPP); 1154 985 } ··· 1239 1056 { 1240 1057 int r = 0; 1241 1058 1242 - if (clock == PRCMU_PLLSOC1) 1059 + if (clock == PRCMU_PLLSOC0) 1060 + clock = (enable ? PLL_SOC0_ON : PLL_SOC0_OFF); 1061 + else if (clock == PRCMU_PLLSOC1) 1243 1062 clock = (enable ? PLL_SOC1_ON : PLL_SOC1_OFF); 1244 1063 else 1245 1064 return -EINVAL; ··· 1264 1079 1265 1080 return r; 1266 1081 } 1267 - 1268 - /** 1269 - * prcmu_set_hwacc - set the power state of a h/w accelerator 1270 - * @hwacc_dev: The hardware accelerator (enum hw_acc_dev). 1271 - * @state: The new power state (enum hw_acc_state). 1272 - * 1273 - * This function sets the power state of a hardware accelerator. 1274 - * This function should not be called from interrupt context. 1275 - * 1276 - * NOTE! Deprecated, to be removed when all users switched over to use the 1277 - * regulator framework API. 1278 - */ 1279 - int prcmu_set_hwacc(u16 hwacc_dev, u8 state) 1280 - { 1281 - int r = 0; 1282 - bool ram_retention = false; 1283 - bool enable, enable_ret; 1284 - 1285 - /* check argument */ 1286 - BUG_ON(hwacc_dev >= NUM_HW_ACC); 1287 - 1288 - /* get state of switches */ 1289 - enable = hwacc_enabled[hwacc_dev]; 1290 - enable_ret = hwacc_ret_enabled[hwacc_dev]; 1291 - 1292 - /* set flag if retention is possible */ 1293 - switch (hwacc_dev) { 1294 - case HW_ACC_SVAMMDSP: 1295 - case HW_ACC_SIAMMDSP: 1296 - case HW_ACC_ESRAM1: 1297 - case HW_ACC_ESRAM2: 1298 - case HW_ACC_ESRAM3: 1299 - case HW_ACC_ESRAM4: 1300 - ram_retention = true; 1301 - break; 1302 - } 1303 - 1304 - /* check argument */ 1305 - BUG_ON(state > HW_ON); 1306 - BUG_ON(state == HW_OFF_RAMRET && !ram_retention); 1307 - 1308 - /* modify enable flags */ 1309 - switch (state) { 1310 - case HW_OFF: 1311 - enable_ret = false; 1312 - enable = false; 1313 - break; 1314 - case HW_ON: 1315 - enable = true; 1316 - break; 1317 - case HW_OFF_RAMRET: 1318 - enable_ret = true; 1319 - enable = false; 1320 - break; 1321 - } 1322 - 1323 - /* get regulator (lazy) */ 1324 - if (hwacc_regulator[hwacc_dev] == NULL) { 1325 - hwacc_regulator[hwacc_dev] = regulator_get(NULL, 1326 - hwacc_regulator_name[hwacc_dev]); 1327 - if (IS_ERR(hwacc_regulator[hwacc_dev])) { 1328 - pr_err("prcmu: failed to get supply %s\n", 1329 - hwacc_regulator_name[hwacc_dev]); 1330 - r = PTR_ERR(hwacc_regulator[hwacc_dev]); 1331 - goto out; 1332 - } 1333 - } 1334 - 1335 - if (ram_retention) { 1336 - if (hwacc_ret_regulator[hwacc_dev] == NULL) { 1337 - hwacc_ret_regulator[hwacc_dev] = regulator_get(NULL, 1338 - hwacc_ret_regulator_name[hwacc_dev]); 1339 - if (IS_ERR(hwacc_ret_regulator[hwacc_dev])) { 1340 - pr_err("prcmu: failed to get supply %s\n", 1341 - hwacc_ret_regulator_name[hwacc_dev]); 1342 - r = PTR_ERR(hwacc_ret_regulator[hwacc_dev]); 1343 - goto out; 1344 - } 1345 - } 1346 - } 1347 - 1348 - /* set regulators */ 1349 - if (ram_retention) { 1350 - if (enable_ret && !hwacc_ret_enabled[hwacc_dev]) { 1351 - r = regulator_enable(hwacc_ret_regulator[hwacc_dev]); 1352 - if (r < 0) { 1353 - pr_err("prcmu_set_hwacc: ret enable failed\n"); 1354 - goto out; 1355 - } 1356 - hwacc_ret_enabled[hwacc_dev] = true; 1357 - } 1358 - } 1359 - 1360 - if (enable && !hwacc_enabled[hwacc_dev]) { 1361 - r = regulator_enable(hwacc_regulator[hwacc_dev]); 1362 - if (r < 0) { 1363 - pr_err("prcmu_set_hwacc: enable failed\n"); 1364 - goto out; 1365 - } 1366 - hwacc_enabled[hwacc_dev] = true; 1367 - } 1368 - 1369 - if (!enable && hwacc_enabled[hwacc_dev]) { 1370 - r = regulator_disable(hwacc_regulator[hwacc_dev]); 1371 - if (r < 0) { 1372 - pr_err("prcmu_set_hwacc: disable failed\n"); 1373 - goto out; 1374 - } 1375 - hwacc_enabled[hwacc_dev] = false; 1376 - } 1377 - 1378 - if (ram_retention) { 1379 - if (!enable_ret && hwacc_ret_enabled[hwacc_dev]) { 1380 - r = regulator_disable(hwacc_ret_regulator[hwacc_dev]); 1381 - if (r < 0) { 1382 - pr_err("prcmu_set_hwacc: ret disable failed\n"); 1383 - goto out; 1384 - } 1385 - hwacc_ret_enabled[hwacc_dev] = false; 1386 - } 1387 - } 1388 - 1389 - out: 1390 - return r; 1391 - } 1392 - EXPORT_SYMBOL(prcmu_set_hwacc); 1393 1082 1394 1083 /** 1395 1084 * db8500_prcmu_set_epod - set the state of a EPOD (power domain) ··· 1434 1375 return 0; 1435 1376 } 1436 1377 1437 - static int request_reg_clock(u8 clock, bool enable) 1378 + static int request_clock(u8 clock, bool enable) 1438 1379 { 1439 1380 u32 val; 1440 1381 unsigned long flags; ··· 1445 1386 while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0) 1446 1387 cpu_relax(); 1447 1388 1448 - val = readl(_PRCMU_BASE + clk_mgt[clock].offset); 1389 + val = readl(clk_mgt[clock].reg); 1449 1390 if (enable) { 1450 1391 val |= (PRCM_CLK_MGT_CLKEN | clk_mgt[clock].pllsw); 1451 1392 } else { 1452 1393 clk_mgt[clock].pllsw = (val & PRCM_CLK_MGT_CLKPLLSW_MASK); 1453 1394 val &= ~(PRCM_CLK_MGT_CLKEN | PRCM_CLK_MGT_CLKPLLSW_MASK); 1454 1395 } 1455 - writel(val, (_PRCMU_BASE + clk_mgt[clock].offset)); 1396 + writel(val, clk_mgt[clock].reg); 1456 1397 1457 1398 /* Release the HW semaphore. */ 1458 1399 writel(0, PRCM_SEM); ··· 1472 1413 writel(val | PRCM_CGATING_BYPASS_ICN2, PRCM_CGATING_BYPASS); 1473 1414 } 1474 1415 1475 - ret = request_reg_clock(clock, enable); 1416 + ret = request_clock(clock, enable); 1476 1417 1477 1418 if (!ret && !enable) { 1478 1419 val = readl(PRCM_CGATING_BYPASS); ··· 1480 1421 } 1481 1422 1482 1423 return ret; 1424 + } 1425 + 1426 + static inline bool plldsi_locked(void) 1427 + { 1428 + return (readl(PRCM_PLLDSI_LOCKP) & 1429 + (PRCM_PLLDSI_LOCKP_PRCM_PLLDSI_LOCKP10 | 1430 + PRCM_PLLDSI_LOCKP_PRCM_PLLDSI_LOCKP3)) == 1431 + (PRCM_PLLDSI_LOCKP_PRCM_PLLDSI_LOCKP10 | 1432 + PRCM_PLLDSI_LOCKP_PRCM_PLLDSI_LOCKP3); 1433 + } 1434 + 1435 + static int request_plldsi(bool enable) 1436 + { 1437 + int r = 0; 1438 + u32 val; 1439 + 1440 + writel((PRCM_MMIP_LS_CLAMP_DSIPLL_CLAMP | 1441 + PRCM_MMIP_LS_CLAMP_DSIPLL_CLAMPI), (enable ? 1442 + PRCM_MMIP_LS_CLAMP_CLR : PRCM_MMIP_LS_CLAMP_SET)); 1443 + 1444 + val = readl(PRCM_PLLDSI_ENABLE); 1445 + if (enable) 1446 + val |= PRCM_PLLDSI_ENABLE_PRCM_PLLDSI_ENABLE; 1447 + else 1448 + val &= ~PRCM_PLLDSI_ENABLE_PRCM_PLLDSI_ENABLE; 1449 + writel(val, PRCM_PLLDSI_ENABLE); 1450 + 1451 + if (enable) { 1452 + unsigned int i; 1453 + bool locked = plldsi_locked(); 1454 + 1455 + for (i = 10; !locked && (i > 0); --i) { 1456 + udelay(100); 1457 + locked = plldsi_locked(); 1458 + } 1459 + if (locked) { 1460 + writel(PRCM_APE_RESETN_DSIPLL_RESETN, 1461 + PRCM_APE_RESETN_SET); 1462 + } else { 1463 + writel((PRCM_MMIP_LS_CLAMP_DSIPLL_CLAMP | 1464 + PRCM_MMIP_LS_CLAMP_DSIPLL_CLAMPI), 1465 + PRCM_MMIP_LS_CLAMP_SET); 1466 + val &= ~PRCM_PLLDSI_ENABLE_PRCM_PLLDSI_ENABLE; 1467 + writel(val, PRCM_PLLDSI_ENABLE); 1468 + r = -EAGAIN; 1469 + } 1470 + } else { 1471 + writel(PRCM_APE_RESETN_DSIPLL_RESETN, PRCM_APE_RESETN_CLR); 1472 + } 1473 + return r; 1474 + } 1475 + 1476 + static int request_dsiclk(u8 n, bool enable) 1477 + { 1478 + u32 val; 1479 + 1480 + val = readl(PRCM_DSI_PLLOUT_SEL); 1481 + val &= ~dsiclk[n].divsel_mask; 1482 + val |= ((enable ? dsiclk[n].divsel : PRCM_DSI_PLLOUT_SEL_OFF) << 1483 + dsiclk[n].divsel_shift); 1484 + writel(val, PRCM_DSI_PLLOUT_SEL); 1485 + return 0; 1486 + } 1487 + 1488 + static int request_dsiescclk(u8 n, bool enable) 1489 + { 1490 + u32 val; 1491 + 1492 + val = readl(PRCM_DSITVCLK_DIV); 1493 + enable ? (val |= dsiescclk[n].en) : (val &= ~dsiescclk[n].en); 1494 + writel(val, PRCM_DSITVCLK_DIV); 1495 + return 0; 1483 1496 } 1484 1497 1485 1498 /** ··· 1564 1433 */ 1565 1434 int db8500_prcmu_request_clock(u8 clock, bool enable) 1566 1435 { 1567 - switch(clock) { 1568 - case PRCMU_SGACLK: 1436 + if (clock == PRCMU_SGACLK) 1569 1437 return request_sga_clock(clock, enable); 1570 - case PRCMU_TIMCLK: 1438 + else if (clock < PRCMU_NUM_REG_CLOCKS) 1439 + return request_clock(clock, enable); 1440 + else if (clock == PRCMU_TIMCLK) 1571 1441 return request_timclk(enable); 1572 - case PRCMU_SYSCLK: 1442 + else if ((clock == PRCMU_DSI0CLK) || (clock == PRCMU_DSI1CLK)) 1443 + return request_dsiclk((clock - PRCMU_DSI0CLK), enable); 1444 + else if ((PRCMU_DSI0ESCCLK <= clock) && (clock <= PRCMU_DSI2ESCCLK)) 1445 + return request_dsiescclk((clock - PRCMU_DSI0ESCCLK), enable); 1446 + else if (clock == PRCMU_PLLDSI) 1447 + return request_plldsi(enable); 1448 + else if (clock == PRCMU_SYSCLK) 1573 1449 return request_sysclk(enable); 1574 - case PRCMU_PLLSOC1: 1450 + else if ((clock == PRCMU_PLLSOC0) || (clock == PRCMU_PLLSOC1)) 1575 1451 return request_pll(clock, enable); 1576 - default: 1577 - break; 1452 + else 1453 + return -EINVAL; 1454 + } 1455 + 1456 + static unsigned long pll_rate(void __iomem *reg, unsigned long src_rate, 1457 + int branch) 1458 + { 1459 + u64 rate; 1460 + u32 val; 1461 + u32 d; 1462 + u32 div = 1; 1463 + 1464 + val = readl(reg); 1465 + 1466 + rate = src_rate; 1467 + rate *= ((val & PRCM_PLL_FREQ_D_MASK) >> PRCM_PLL_FREQ_D_SHIFT); 1468 + 1469 + d = ((val & PRCM_PLL_FREQ_N_MASK) >> PRCM_PLL_FREQ_N_SHIFT); 1470 + if (d > 1) 1471 + div *= d; 1472 + 1473 + d = ((val & PRCM_PLL_FREQ_R_MASK) >> PRCM_PLL_FREQ_R_SHIFT); 1474 + if (d > 1) 1475 + div *= d; 1476 + 1477 + if (val & PRCM_PLL_FREQ_SELDIV2) 1478 + div *= 2; 1479 + 1480 + if ((branch == PLL_FIX) || ((branch == PLL_DIV) && 1481 + (val & PRCM_PLL_FREQ_DIV2EN) && 1482 + ((reg == PRCM_PLLSOC0_FREQ) || 1483 + (reg == PRCM_PLLDDR_FREQ)))) 1484 + div *= 2; 1485 + 1486 + (void)do_div(rate, div); 1487 + 1488 + return (unsigned long)rate; 1489 + } 1490 + 1491 + #define ROOT_CLOCK_RATE 38400000 1492 + 1493 + static unsigned long clock_rate(u8 clock) 1494 + { 1495 + u32 val; 1496 + u32 pllsw; 1497 + unsigned long rate = ROOT_CLOCK_RATE; 1498 + 1499 + val = readl(clk_mgt[clock].reg); 1500 + 1501 + if (val & PRCM_CLK_MGT_CLK38) { 1502 + if (clk_mgt[clock].clk38div && (val & PRCM_CLK_MGT_CLK38DIV)) 1503 + rate /= 2; 1504 + return rate; 1578 1505 } 1506 + 1507 + val |= clk_mgt[clock].pllsw; 1508 + pllsw = (val & PRCM_CLK_MGT_CLKPLLSW_MASK); 1509 + 1510 + if (pllsw == PRCM_CLK_MGT_CLKPLLSW_SOC0) 1511 + rate = pll_rate(PRCM_PLLSOC0_FREQ, rate, clk_mgt[clock].branch); 1512 + else if (pllsw == PRCM_CLK_MGT_CLKPLLSW_SOC1) 1513 + rate = pll_rate(PRCM_PLLSOC1_FREQ, rate, clk_mgt[clock].branch); 1514 + else if (pllsw == PRCM_CLK_MGT_CLKPLLSW_DDR) 1515 + rate = pll_rate(PRCM_PLLDDR_FREQ, rate, clk_mgt[clock].branch); 1516 + else 1517 + return 0; 1518 + 1519 + if ((clock == PRCMU_SGACLK) && 1520 + (val & PRCM_SGACLK_MGT_SGACLKDIV_BY_2_5_EN)) { 1521 + u64 r = (rate * 10); 1522 + 1523 + (void)do_div(r, 25); 1524 + return (unsigned long)r; 1525 + } 1526 + val &= PRCM_CLK_MGT_CLKPLLDIV_MASK; 1527 + if (val) 1528 + return rate / val; 1529 + else 1530 + return 0; 1531 + } 1532 + 1533 + static unsigned long dsiclk_rate(u8 n) 1534 + { 1535 + u32 divsel; 1536 + u32 div = 1; 1537 + 1538 + divsel = readl(PRCM_DSI_PLLOUT_SEL); 1539 + divsel = ((divsel & dsiclk[n].divsel_mask) >> dsiclk[n].divsel_shift); 1540 + 1541 + if (divsel == PRCM_DSI_PLLOUT_SEL_OFF) 1542 + divsel = dsiclk[n].divsel; 1543 + 1544 + switch (divsel) { 1545 + case PRCM_DSI_PLLOUT_SEL_PHI_4: 1546 + div *= 2; 1547 + case PRCM_DSI_PLLOUT_SEL_PHI_2: 1548 + div *= 2; 1549 + case PRCM_DSI_PLLOUT_SEL_PHI: 1550 + return pll_rate(PRCM_PLLDSI_FREQ, clock_rate(PRCMU_HDMICLK), 1551 + PLL_RAW) / div; 1552 + default: 1553 + return 0; 1554 + } 1555 + } 1556 + 1557 + static unsigned long dsiescclk_rate(u8 n) 1558 + { 1559 + u32 div; 1560 + 1561 + div = readl(PRCM_DSITVCLK_DIV); 1562 + div = ((div & dsiescclk[n].div_mask) >> (dsiescclk[n].div_shift)); 1563 + return clock_rate(PRCMU_TVCLK) / max((u32)1, div); 1564 + } 1565 + 1566 + unsigned long prcmu_clock_rate(u8 clock) 1567 + { 1579 1568 if (clock < PRCMU_NUM_REG_CLOCKS) 1580 - return request_reg_clock(clock, enable); 1581 - return -EINVAL; 1569 + return clock_rate(clock); 1570 + else if (clock == PRCMU_TIMCLK) 1571 + return ROOT_CLOCK_RATE / 16; 1572 + else if (clock == PRCMU_SYSCLK) 1573 + return ROOT_CLOCK_RATE; 1574 + else if (clock == PRCMU_PLLSOC0) 1575 + return pll_rate(PRCM_PLLSOC0_FREQ, ROOT_CLOCK_RATE, PLL_RAW); 1576 + else if (clock == PRCMU_PLLSOC1) 1577 + return pll_rate(PRCM_PLLSOC1_FREQ, ROOT_CLOCK_RATE, PLL_RAW); 1578 + else if (clock == PRCMU_PLLDDR) 1579 + return pll_rate(PRCM_PLLDDR_FREQ, ROOT_CLOCK_RATE, PLL_RAW); 1580 + else if (clock == PRCMU_PLLDSI) 1581 + return pll_rate(PRCM_PLLDSI_FREQ, clock_rate(PRCMU_HDMICLK), 1582 + PLL_RAW); 1583 + else if ((clock == PRCMU_DSI0CLK) || (clock == PRCMU_DSI1CLK)) 1584 + return dsiclk_rate(clock - PRCMU_DSI0CLK); 1585 + else if ((PRCMU_DSI0ESCCLK <= clock) && (clock <= PRCMU_DSI2ESCCLK)) 1586 + return dsiescclk_rate(clock - PRCMU_DSI0ESCCLK); 1587 + else 1588 + return 0; 1589 + } 1590 + 1591 + static unsigned long clock_source_rate(u32 clk_mgt_val, int branch) 1592 + { 1593 + if (clk_mgt_val & PRCM_CLK_MGT_CLK38) 1594 + return ROOT_CLOCK_RATE; 1595 + clk_mgt_val &= PRCM_CLK_MGT_CLKPLLSW_MASK; 1596 + if (clk_mgt_val == PRCM_CLK_MGT_CLKPLLSW_SOC0) 1597 + return pll_rate(PRCM_PLLSOC0_FREQ, ROOT_CLOCK_RATE, branch); 1598 + else if (clk_mgt_val == PRCM_CLK_MGT_CLKPLLSW_SOC1) 1599 + return pll_rate(PRCM_PLLSOC1_FREQ, ROOT_CLOCK_RATE, branch); 1600 + else if (clk_mgt_val == PRCM_CLK_MGT_CLKPLLSW_DDR) 1601 + return pll_rate(PRCM_PLLDDR_FREQ, ROOT_CLOCK_RATE, branch); 1602 + else 1603 + return 0; 1604 + } 1605 + 1606 + static u32 clock_divider(unsigned long src_rate, unsigned long rate) 1607 + { 1608 + u32 div; 1609 + 1610 + div = (src_rate / rate); 1611 + if (div == 0) 1612 + return 1; 1613 + if (rate < (src_rate / div)) 1614 + div++; 1615 + return div; 1616 + } 1617 + 1618 + static long round_clock_rate(u8 clock, unsigned long rate) 1619 + { 1620 + u32 val; 1621 + u32 div; 1622 + unsigned long src_rate; 1623 + long rounded_rate; 1624 + 1625 + val = readl(clk_mgt[clock].reg); 1626 + src_rate = clock_source_rate((val | clk_mgt[clock].pllsw), 1627 + clk_mgt[clock].branch); 1628 + div = clock_divider(src_rate, rate); 1629 + if (val & PRCM_CLK_MGT_CLK38) { 1630 + if (clk_mgt[clock].clk38div) { 1631 + if (div > 2) 1632 + div = 2; 1633 + } else { 1634 + div = 1; 1635 + } 1636 + } else if ((clock == PRCMU_SGACLK) && (div == 3)) { 1637 + u64 r = (src_rate * 10); 1638 + 1639 + (void)do_div(r, 25); 1640 + if (r <= rate) 1641 + return (unsigned long)r; 1642 + } 1643 + rounded_rate = (src_rate / min(div, (u32)31)); 1644 + 1645 + return rounded_rate; 1646 + } 1647 + 1648 + #define MIN_PLL_VCO_RATE 600000000ULL 1649 + #define MAX_PLL_VCO_RATE 1680640000ULL 1650 + 1651 + static long round_plldsi_rate(unsigned long rate) 1652 + { 1653 + long rounded_rate = 0; 1654 + unsigned long src_rate; 1655 + unsigned long rem; 1656 + u32 r; 1657 + 1658 + src_rate = clock_rate(PRCMU_HDMICLK); 1659 + rem = rate; 1660 + 1661 + for (r = 7; (rem > 0) && (r > 0); r--) { 1662 + u64 d; 1663 + 1664 + d = (r * rate); 1665 + (void)do_div(d, src_rate); 1666 + if (d < 6) 1667 + d = 6; 1668 + else if (d > 255) 1669 + d = 255; 1670 + d *= src_rate; 1671 + if (((2 * d) < (r * MIN_PLL_VCO_RATE)) || 1672 + ((r * MAX_PLL_VCO_RATE) < (2 * d))) 1673 + continue; 1674 + (void)do_div(d, r); 1675 + if (rate < d) { 1676 + if (rounded_rate == 0) 1677 + rounded_rate = (long)d; 1678 + break; 1679 + } 1680 + if ((rate - d) < rem) { 1681 + rem = (rate - d); 1682 + rounded_rate = (long)d; 1683 + } 1684 + } 1685 + return rounded_rate; 1686 + } 1687 + 1688 + static long round_dsiclk_rate(unsigned long rate) 1689 + { 1690 + u32 div; 1691 + unsigned long src_rate; 1692 + long rounded_rate; 1693 + 1694 + src_rate = pll_rate(PRCM_PLLDSI_FREQ, clock_rate(PRCMU_HDMICLK), 1695 + PLL_RAW); 1696 + div = clock_divider(src_rate, rate); 1697 + rounded_rate = (src_rate / ((div > 2) ? 4 : div)); 1698 + 1699 + return rounded_rate; 1700 + } 1701 + 1702 + static long round_dsiescclk_rate(unsigned long rate) 1703 + { 1704 + u32 div; 1705 + unsigned long src_rate; 1706 + long rounded_rate; 1707 + 1708 + src_rate = clock_rate(PRCMU_TVCLK); 1709 + div = clock_divider(src_rate, rate); 1710 + rounded_rate = (src_rate / min(div, (u32)255)); 1711 + 1712 + return rounded_rate; 1713 + } 1714 + 1715 + long prcmu_round_clock_rate(u8 clock, unsigned long rate) 1716 + { 1717 + if (clock < PRCMU_NUM_REG_CLOCKS) 1718 + return round_clock_rate(clock, rate); 1719 + else if (clock == PRCMU_PLLDSI) 1720 + return round_plldsi_rate(rate); 1721 + else if ((clock == PRCMU_DSI0CLK) || (clock == PRCMU_DSI1CLK)) 1722 + return round_dsiclk_rate(rate); 1723 + else if ((PRCMU_DSI0ESCCLK <= clock) && (clock <= PRCMU_DSI2ESCCLK)) 1724 + return round_dsiescclk_rate(rate); 1725 + else 1726 + return (long)prcmu_clock_rate(clock); 1727 + } 1728 + 1729 + static void set_clock_rate(u8 clock, unsigned long rate) 1730 + { 1731 + u32 val; 1732 + u32 div; 1733 + unsigned long src_rate; 1734 + unsigned long flags; 1735 + 1736 + spin_lock_irqsave(&clk_mgt_lock, flags); 1737 + 1738 + /* Grab the HW semaphore. */ 1739 + while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0) 1740 + cpu_relax(); 1741 + 1742 + val = readl(clk_mgt[clock].reg); 1743 + src_rate = clock_source_rate((val | clk_mgt[clock].pllsw), 1744 + clk_mgt[clock].branch); 1745 + div = clock_divider(src_rate, rate); 1746 + if (val & PRCM_CLK_MGT_CLK38) { 1747 + if (clk_mgt[clock].clk38div) { 1748 + if (div > 1) 1749 + val |= PRCM_CLK_MGT_CLK38DIV; 1750 + else 1751 + val &= ~PRCM_CLK_MGT_CLK38DIV; 1752 + } 1753 + } else if (clock == PRCMU_SGACLK) { 1754 + val &= ~(PRCM_CLK_MGT_CLKPLLDIV_MASK | 1755 + PRCM_SGACLK_MGT_SGACLKDIV_BY_2_5_EN); 1756 + if (div == 3) { 1757 + u64 r = (src_rate * 10); 1758 + 1759 + (void)do_div(r, 25); 1760 + if (r <= rate) { 1761 + val |= PRCM_SGACLK_MGT_SGACLKDIV_BY_2_5_EN; 1762 + div = 0; 1763 + } 1764 + } 1765 + val |= min(div, (u32)31); 1766 + } else { 1767 + val &= ~PRCM_CLK_MGT_CLKPLLDIV_MASK; 1768 + val |= min(div, (u32)31); 1769 + } 1770 + writel(val, clk_mgt[clock].reg); 1771 + 1772 + /* Release the HW semaphore. */ 1773 + writel(0, PRCM_SEM); 1774 + 1775 + spin_unlock_irqrestore(&clk_mgt_lock, flags); 1776 + } 1777 + 1778 + static int set_plldsi_rate(unsigned long rate) 1779 + { 1780 + unsigned long src_rate; 1781 + unsigned long rem; 1782 + u32 pll_freq = 0; 1783 + u32 r; 1784 + 1785 + src_rate = clock_rate(PRCMU_HDMICLK); 1786 + rem = rate; 1787 + 1788 + for (r = 7; (rem > 0) && (r > 0); r--) { 1789 + u64 d; 1790 + u64 hwrate; 1791 + 1792 + d = (r * rate); 1793 + (void)do_div(d, src_rate); 1794 + if (d < 6) 1795 + d = 6; 1796 + else if (d > 255) 1797 + d = 255; 1798 + hwrate = (d * src_rate); 1799 + if (((2 * hwrate) < (r * MIN_PLL_VCO_RATE)) || 1800 + ((r * MAX_PLL_VCO_RATE) < (2 * hwrate))) 1801 + continue; 1802 + (void)do_div(hwrate, r); 1803 + if (rate < hwrate) { 1804 + if (pll_freq == 0) 1805 + pll_freq = (((u32)d << PRCM_PLL_FREQ_D_SHIFT) | 1806 + (r << PRCM_PLL_FREQ_R_SHIFT)); 1807 + break; 1808 + } 1809 + if ((rate - hwrate) < rem) { 1810 + rem = (rate - hwrate); 1811 + pll_freq = (((u32)d << PRCM_PLL_FREQ_D_SHIFT) | 1812 + (r << PRCM_PLL_FREQ_R_SHIFT)); 1813 + } 1814 + } 1815 + if (pll_freq == 0) 1816 + return -EINVAL; 1817 + 1818 + pll_freq |= (1 << PRCM_PLL_FREQ_N_SHIFT); 1819 + writel(pll_freq, PRCM_PLLDSI_FREQ); 1820 + 1821 + return 0; 1822 + } 1823 + 1824 + static void set_dsiclk_rate(u8 n, unsigned long rate) 1825 + { 1826 + u32 val; 1827 + u32 div; 1828 + 1829 + div = clock_divider(pll_rate(PRCM_PLLDSI_FREQ, 1830 + clock_rate(PRCMU_HDMICLK), PLL_RAW), rate); 1831 + 1832 + dsiclk[n].divsel = (div == 1) ? PRCM_DSI_PLLOUT_SEL_PHI : 1833 + (div == 2) ? PRCM_DSI_PLLOUT_SEL_PHI_2 : 1834 + /* else */ PRCM_DSI_PLLOUT_SEL_PHI_4; 1835 + 1836 + val = readl(PRCM_DSI_PLLOUT_SEL); 1837 + val &= ~dsiclk[n].divsel_mask; 1838 + val |= (dsiclk[n].divsel << dsiclk[n].divsel_shift); 1839 + writel(val, PRCM_DSI_PLLOUT_SEL); 1840 + } 1841 + 1842 + static void set_dsiescclk_rate(u8 n, unsigned long rate) 1843 + { 1844 + u32 val; 1845 + u32 div; 1846 + 1847 + div = clock_divider(clock_rate(PRCMU_TVCLK), rate); 1848 + val = readl(PRCM_DSITVCLK_DIV); 1849 + val &= ~dsiescclk[n].div_mask; 1850 + val |= (min(div, (u32)255) << dsiescclk[n].div_shift); 1851 + writel(val, PRCM_DSITVCLK_DIV); 1852 + } 1853 + 1854 + int prcmu_set_clock_rate(u8 clock, unsigned long rate) 1855 + { 1856 + if (clock < PRCMU_NUM_REG_CLOCKS) 1857 + set_clock_rate(clock, rate); 1858 + else if (clock == PRCMU_PLLDSI) 1859 + return set_plldsi_rate(rate); 1860 + else if ((clock == PRCMU_DSI0CLK) || (clock == PRCMU_DSI1CLK)) 1861 + set_dsiclk_rate((clock - PRCMU_DSI0CLK), rate); 1862 + else if ((PRCMU_DSI0ESCCLK <= clock) && (clock <= PRCMU_DSI2ESCCLK)) 1863 + set_dsiescclk_rate((clock - PRCMU_DSI0ESCCLK), rate); 1864 + return 0; 1582 1865 } 1583 1866 1584 1867 int db8500_prcmu_config_esram0_deep_sleep(u8 state) ··· 2021 1476 return 0; 2022 1477 } 2023 1478 2024 - int prcmu_config_hotdog(u8 threshold) 1479 + int db8500_prcmu_config_hotdog(u8 threshold) 2025 1480 { 2026 1481 mutex_lock(&mb4_transfer.lock); 2027 1482 ··· 2039 1494 return 0; 2040 1495 } 2041 1496 2042 - int prcmu_config_hotmon(u8 low, u8 high) 1497 + int db8500_prcmu_config_hotmon(u8 low, u8 high) 2043 1498 { 2044 1499 mutex_lock(&mb4_transfer.lock); 2045 1500 ··· 2078 1533 return 0; 2079 1534 } 2080 1535 2081 - int prcmu_start_temp_sense(u16 cycles32k) 1536 + int db8500_prcmu_start_temp_sense(u16 cycles32k) 2082 1537 { 2083 1538 if (cycles32k == 0xFFFF) 2084 1539 return -EINVAL; ··· 2086 1541 return config_hot_period(cycles32k); 2087 1542 } 2088 1543 2089 - int prcmu_stop_temp_sense(void) 1544 + int db8500_prcmu_stop_temp_sense(void) 2090 1545 { 2091 1546 return config_hot_period(0xFFFF); 2092 1547 } ··· 2115 1570 2116 1571 } 2117 1572 2118 - int prcmu_config_a9wdog(u8 num, bool sleep_auto_off) 1573 + int db8500_prcmu_config_a9wdog(u8 num, bool sleep_auto_off) 2119 1574 { 2120 1575 BUG_ON(num == 0 || num > 0xf); 2121 1576 return prcmu_a9wdog(MB4H_A9WDOG_CONF, num, 0, 0, ··· 2123 1578 A9WDOG_AUTO_OFF_DIS); 2124 1579 } 2125 1580 2126 - int prcmu_enable_a9wdog(u8 id) 1581 + int db8500_prcmu_enable_a9wdog(u8 id) 2127 1582 { 2128 1583 return prcmu_a9wdog(MB4H_A9WDOG_EN, id, 0, 0, 0); 2129 1584 } 2130 1585 2131 - int prcmu_disable_a9wdog(u8 id) 1586 + int db8500_prcmu_disable_a9wdog(u8 id) 2132 1587 { 2133 1588 return prcmu_a9wdog(MB4H_A9WDOG_DIS, id, 0, 0, 0); 2134 1589 } 2135 1590 2136 - int prcmu_kick_a9wdog(u8 id) 1591 + int db8500_prcmu_kick_a9wdog(u8 id) 2137 1592 { 2138 1593 return prcmu_a9wdog(MB4H_A9WDOG_KICK, id, 0, 0, 0); 2139 1594 } ··· 2141 1596 /* 2142 1597 * timeout is 28 bit, in ms. 2143 1598 */ 2144 - #define MAX_WATCHDOG_TIMEOUT 131000 2145 - int prcmu_load_a9wdog(u8 id, u32 timeout) 1599 + int db8500_prcmu_load_a9wdog(u8 id, u32 timeout) 2146 1600 { 2147 - if (timeout > MAX_WATCHDOG_TIMEOUT) 2148 - /* 2149 - * Due to calculation bug in prcmu fw, timeouts 2150 - * can't be bigger than 131 seconds. 2151 - */ 2152 - return -EINVAL; 2153 - 2154 1601 return prcmu_a9wdog(MB4H_A9WDOG_LOAD, 2155 1602 (id & A9WDOG_ID_MASK) | 2156 1603 /* ··· 2153 1616 (u8)((timeout >> 4) & 0xff), 2154 1617 (u8)((timeout >> 12) & 0xff), 2155 1618 (u8)((timeout >> 20) & 0xff)); 2156 - } 2157 - 2158 - /** 2159 - * prcmu_set_clock_divider() - Configure the clock divider. 2160 - * @clock: The clock for which the request is made. 2161 - * @divider: The clock divider. (< 32) 2162 - * 2163 - * This function should only be used by the clock implementation. 2164 - * Do not use it from any other place! 2165 - */ 2166 - int prcmu_set_clock_divider(u8 clock, u8 divider) 2167 - { 2168 - u32 val; 2169 - unsigned long flags; 2170 - 2171 - if ((clock >= PRCMU_NUM_REG_CLOCKS) || (divider < 1) || (31 < divider)) 2172 - return -EINVAL; 2173 - 2174 - spin_lock_irqsave(&clk_mgt_lock, flags); 2175 - 2176 - /* Grab the HW semaphore. */ 2177 - while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0) 2178 - cpu_relax(); 2179 - 2180 - val = readl(_PRCMU_BASE + clk_mgt[clock].offset); 2181 - val &= ~(PRCM_CLK_MGT_CLKPLLDIV_MASK); 2182 - val |= (u32)divider; 2183 - writel(val, (_PRCMU_BASE + clk_mgt[clock].offset)); 2184 - 2185 - /* Release the HW semaphore. */ 2186 - writel(0, PRCM_SEM); 2187 - 2188 - spin_unlock_irqrestore(&clk_mgt_lock, flags); 2189 - 2190 - return 0; 2191 1619 } 2192 1620 2193 1621 /** ··· 2177 1675 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5)) 2178 1676 cpu_relax(); 2179 1677 1678 + writeb(0, (tcdm_base + PRCM_MBOX_HEADER_REQ_MB5)); 2180 1679 writeb(PRCMU_I2C_READ(slave), (tcdm_base + PRCM_REQ_MB5_I2C_SLAVE_OP)); 2181 1680 writeb(PRCMU_I2C_STOP_EN, (tcdm_base + PRCM_REQ_MB5_I2C_HW_BITS)); 2182 1681 writeb(reg, (tcdm_base + PRCM_REQ_MB5_I2C_REG)); ··· 2203 1700 } 2204 1701 2205 1702 /** 2206 - * prcmu_abb_write() - Write register value(s) to the ABB. 1703 + * prcmu_abb_write_masked() - Write masked register value(s) to the ABB. 2207 1704 * @slave: The I2C slave address. 2208 1705 * @reg: The (start) register address. 2209 1706 * @value: The value(s) to write. 1707 + * @mask: The mask(s) to use. 2210 1708 * @size: The number of registers to write. 2211 1709 * 2212 - * Reads register value(s) from the ABB. 1710 + * Writes masked register value(s) to the ABB. 1711 + * For each @value, only the bits set to 1 in the corresponding @mask 1712 + * will be written. The other bits are not changed. 2213 1713 * @size has to be 1 for the current firmware version. 2214 1714 */ 2215 - int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size) 1715 + int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size) 2216 1716 { 2217 1717 int r; 2218 1718 ··· 2227 1721 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5)) 2228 1722 cpu_relax(); 2229 1723 1724 + writeb(~*mask, (tcdm_base + PRCM_MBOX_HEADER_REQ_MB5)); 2230 1725 writeb(PRCMU_I2C_WRITE(slave), (tcdm_base + PRCM_REQ_MB5_I2C_SLAVE_OP)); 2231 1726 writeb(PRCMU_I2C_STOP_EN, (tcdm_base + PRCM_REQ_MB5_I2C_HW_BITS)); 2232 1727 writeb(reg, (tcdm_base + PRCM_REQ_MB5_I2C_REG)); ··· 2247 1740 mutex_unlock(&mb5_transfer.lock); 2248 1741 2249 1742 return r; 1743 + } 1744 + 1745 + /** 1746 + * prcmu_abb_write() - Write register value(s) to the ABB. 1747 + * @slave: The I2C slave address. 1748 + * @reg: The (start) register address. 1749 + * @value: The value(s) to write. 1750 + * @size: The number of registers to write. 1751 + * 1752 + * Writes register value(s) to the ABB. 1753 + * @size has to be 1 for the current firmware version. 1754 + */ 1755 + int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size) 1756 + { 1757 + u8 mask = ~0; 1758 + 1759 + return prcmu_abb_write_masked(slave, reg, value, &mask, size); 2250 1760 } 2251 1761 2252 1762 /** ··· 2374 1850 } 2375 1851 2376 1852 /** 2377 - * prcmu_reset_modem - ask the PRCMU to reset modem 1853 + * db8500_prcmu_reset_modem - ask the PRCMU to reset modem 2378 1854 */ 2379 - void prcmu_modem_reset(void) 1855 + void db8500_prcmu_modem_reset(void) 2380 1856 { 2381 1857 mutex_lock(&mb1_transfer.lock); 2382 1858 ··· 2623 2099 .irq_unmask = prcmu_irq_unmask, 2624 2100 }; 2625 2101 2102 + static char *fw_project_name(u8 project) 2103 + { 2104 + switch (project) { 2105 + case PRCMU_FW_PROJECT_U8500: 2106 + return "U8500"; 2107 + case PRCMU_FW_PROJECT_U8500_C2: 2108 + return "U8500 C2"; 2109 + case PRCMU_FW_PROJECT_U9500: 2110 + return "U9500"; 2111 + case PRCMU_FW_PROJECT_U9500_C2: 2112 + return "U9500 C2"; 2113 + case PRCMU_FW_PROJECT_U8520: 2114 + return "U8520"; 2115 + case PRCMU_FW_PROJECT_U8420: 2116 + return "U8420"; 2117 + default: 2118 + return "Unknown"; 2119 + } 2120 + } 2121 + 2626 2122 void __init db8500_prcmu_early_init(void) 2627 2123 { 2628 2124 unsigned int i; ··· 2652 2108 if (tcpm_base != NULL) { 2653 2109 u32 version; 2654 2110 version = readl(tcpm_base + PRCMU_FW_VERSION_OFFSET); 2655 - prcmu_version.project_number = version & 0xFF; 2656 - prcmu_version.api_version = (version >> 8) & 0xFF; 2657 - prcmu_version.func_version = (version >> 16) & 0xFF; 2658 - prcmu_version.errata = (version >> 24) & 0xFF; 2659 - pr_info("PRCMU firmware version %d.%d.%d\n", 2111 + fw_info.version.project = version & 0xFF; 2112 + fw_info.version.api_version = (version >> 8) & 0xFF; 2113 + fw_info.version.func_version = (version >> 16) & 0xFF; 2114 + fw_info.version.errata = (version >> 24) & 0xFF; 2115 + fw_info.valid = true; 2116 + pr_info("PRCMU firmware: %s, version %d.%d.%d\n", 2117 + fw_project_name(fw_info.version.project), 2660 2118 (version >> 8) & 0xFF, (version >> 16) & 0xFF, 2661 2119 (version >> 24) & 0xFF); 2662 2120 iounmap(tcpm_base); ··· 2676 2130 init_completion(&mb0_transfer.ac_wake_work); 2677 2131 mutex_init(&mb1_transfer.lock); 2678 2132 init_completion(&mb1_transfer.work); 2133 + mb1_transfer.ape_opp = APE_NO_CHANGE; 2679 2134 mutex_init(&mb2_transfer.lock); 2680 2135 init_completion(&mb2_transfer.work); 2681 2136 spin_lock_init(&mb2_transfer.auto_pm_lock); ··· 2701 2154 } 2702 2155 } 2703 2156 2704 - static void __init db8500_prcmu_init_clkforce(void) 2157 + static void __init init_prcm_registers(void) 2705 2158 { 2706 2159 u32 val; 2707 2160 ··· 2733 2186 REGULATOR_SUPPLY("vcore", "uart1"), 2734 2187 REGULATOR_SUPPLY("vcore", "uart2"), 2735 2188 REGULATOR_SUPPLY("v-ape", "nmk-ske-keypad.0"), 2189 + REGULATOR_SUPPLY("v-hsi", "ste_hsi.0"), 2736 2190 }; 2737 2191 2738 2192 static struct regulator_consumer_supply db8500_vsmps2_consumers[] = { 2739 - /* CG2900 and CW1200 power to off-chip peripherals */ 2740 - REGULATOR_SUPPLY("gbf_1v8", "cg2900-uart.0"), 2741 - REGULATOR_SUPPLY("wlan_1v8", "cw1200.0"), 2742 2193 REGULATOR_SUPPLY("musb_1v8", "ab8500-usb.0"), 2743 2194 /* AV8100 regulator */ 2744 2195 REGULATOR_SUPPLY("hdmi_1v8", "0-0070"), 2745 2196 }; 2746 2197 2747 2198 static struct regulator_consumer_supply db8500_b2r2_mcde_consumers[] = { 2748 - REGULATOR_SUPPLY("vsupply", "b2r2.0"), 2199 + REGULATOR_SUPPLY("vsupply", "b2r2_bus"), 2749 2200 REGULATOR_SUPPLY("vsupply", "mcde"), 2750 2201 }; 2751 2202 ··· 2780 2235 static struct regulator_consumer_supply db8500_esram34_consumers[] = { 2781 2236 REGULATOR_SUPPLY("v-esram34", "mcde"), 2782 2237 REGULATOR_SUPPLY("esram34", "cm_control"), 2238 + REGULATOR_SUPPLY("lcla_esram", "dma40.0"), 2783 2239 }; 2784 2240 2785 2241 static struct regulator_init_data db8500_regulators[DB8500_NUM_REGULATORS] = { ··· 2837 2291 }, 2838 2292 }, 2839 2293 [DB8500_REGULATOR_SWITCH_SVAMMDSP] = { 2840 - .supply_regulator = "db8500-vape", 2294 + /* dependency to u8500-vape is handled outside regulator framework */ 2841 2295 .constraints = { 2842 2296 .name = "db8500-sva-mmdsp", 2843 2297 .valid_ops_mask = REGULATOR_CHANGE_STATUS, ··· 2853 2307 }, 2854 2308 }, 2855 2309 [DB8500_REGULATOR_SWITCH_SVAPIPE] = { 2856 - .supply_regulator = "db8500-vape", 2310 + /* dependency to u8500-vape is handled outside regulator framework */ 2857 2311 .constraints = { 2858 2312 .name = "db8500-sva-pipe", 2859 2313 .valid_ops_mask = REGULATOR_CHANGE_STATUS, ··· 2862 2316 .num_consumer_supplies = ARRAY_SIZE(db8500_svapipe_consumers), 2863 2317 }, 2864 2318 [DB8500_REGULATOR_SWITCH_SIAMMDSP] = { 2865 - .supply_regulator = "db8500-vape", 2319 + /* dependency to u8500-vape is handled outside regulator framework */ 2866 2320 .constraints = { 2867 2321 .name = "db8500-sia-mmdsp", 2868 2322 .valid_ops_mask = REGULATOR_CHANGE_STATUS, ··· 2877 2331 }, 2878 2332 }, 2879 2333 [DB8500_REGULATOR_SWITCH_SIAPIPE] = { 2880 - .supply_regulator = "db8500-vape", 2334 + /* dependency to u8500-vape is handled outside regulator framework */ 2881 2335 .constraints = { 2882 2336 .name = "db8500-sia-pipe", 2883 2337 .valid_ops_mask = REGULATOR_CHANGE_STATUS, ··· 2905 2359 .num_consumer_supplies = ARRAY_SIZE(db8500_b2r2_mcde_consumers), 2906 2360 }, 2907 2361 [DB8500_REGULATOR_SWITCH_ESRAM12] = { 2908 - .supply_regulator = "db8500-vape", 2362 + /* 2363 + * esram12 is set in retention and supplied by Vsafe when Vape is off, 2364 + * no need to hold Vape 2365 + */ 2909 2366 .constraints = { 2910 2367 .name = "db8500-esram12", 2911 2368 .valid_ops_mask = REGULATOR_CHANGE_STATUS, ··· 2923 2374 }, 2924 2375 }, 2925 2376 [DB8500_REGULATOR_SWITCH_ESRAM34] = { 2926 - .supply_regulator = "db8500-vape", 2377 + /* 2378 + * esram34 is set in retention and supplied by Vsafe when Vape is off, 2379 + * no need to hold Vape 2380 + */ 2927 2381 .constraints = { 2928 2382 .name = "db8500-esram34", 2929 2383 .valid_ops_mask = REGULATOR_CHANGE_STATUS, ··· 2964 2412 if (ux500_is_svp()) 2965 2413 return -ENODEV; 2966 2414 2967 - db8500_prcmu_init_clkforce(); 2415 + init_prcm_registers(); 2968 2416 2969 2417 /* Clean up the mailbox interrupts after pre-kernel code. */ 2970 2418 writel(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR);
+88 -42
drivers/mfd/dbx500-prcmu-regs.h
··· 17 17 18 18 #define BITS(_start, _end) ((BIT(_end) - BIT(_start)) + BIT(_end)) 19 19 20 - #define PRCM_SVACLK_MGT_OFF 0x008 21 - #define PRCM_SIACLK_MGT_OFF 0x00C 22 - #define PRCM_SGACLK_MGT_OFF 0x014 23 - #define PRCM_UARTCLK_MGT_OFF 0x018 24 - #define PRCM_MSP02CLK_MGT_OFF 0x01C 25 - #define PRCM_I2CCLK_MGT_OFF 0x020 26 - #define PRCM_SDMMCCLK_MGT_OFF 0x024 27 - #define PRCM_SLIMCLK_MGT_OFF 0x028 28 - #define PRCM_PER1CLK_MGT_OFF 0x02C 29 - #define PRCM_PER2CLK_MGT_OFF 0x030 30 - #define PRCM_PER3CLK_MGT_OFF 0x034 31 - #define PRCM_PER5CLK_MGT_OFF 0x038 32 - #define PRCM_PER6CLK_MGT_OFF 0x03C 33 - #define PRCM_PER7CLK_MGT_OFF 0x040 34 - #define PRCM_PWMCLK_MGT_OFF 0x044 /* for DB5500 */ 35 - #define PRCM_IRDACLK_MGT_OFF 0x048 /* for DB5500 */ 36 - #define PRCM_IRRCCLK_MGT_OFF 0x04C /* for DB5500 */ 37 - #define PRCM_LCDCLK_MGT_OFF 0x044 38 - #define PRCM_BMLCLK_MGT_OFF 0x04C 39 - #define PRCM_HSITXCLK_MGT_OFF 0x050 40 - #define PRCM_HSIRXCLK_MGT_OFF 0x054 41 - #define PRCM_HDMICLK_MGT_OFF 0x058 42 - #define PRCM_APEATCLK_MGT_OFF 0x05C 43 - #define PRCM_APETRACECLK_MGT_OFF 0x060 44 - #define PRCM_MCDECLK_MGT_OFF 0x064 45 - #define PRCM_IPI2CCLK_MGT_OFF 0x068 46 - #define PRCM_DSIALTCLK_MGT_OFF 0x06C 47 - #define PRCM_DMACLK_MGT_OFF 0x074 48 - #define PRCM_B2R2CLK_MGT_OFF 0x078 49 - #define PRCM_TVCLK_MGT_OFF 0x07C 50 - #define PRCM_UNIPROCLK_MGT_OFF 0x278 51 - #define PRCM_SSPCLK_MGT_OFF 0x280 52 - #define PRCM_RNGCLK_MGT_OFF 0x284 53 - #define PRCM_UICCCLK_MGT_OFF 0x27C 54 - #define PRCM_MSP1CLK_MGT_OFF 0x288 20 + #define PRCM_CLK_MGT(_offset) (void __iomem *)(IO_ADDRESS(U8500_PRCMU_BASE) \ 21 + + _offset) 22 + #define PRCM_ACLK_MGT PRCM_CLK_MGT(0x004) 23 + #define PRCM_SVACLK_MGT PRCM_CLK_MGT(0x008) 24 + #define PRCM_SIACLK_MGT PRCM_CLK_MGT(0x00C) 25 + #define PRCM_SGACLK_MGT PRCM_CLK_MGT(0x014) 26 + #define PRCM_UARTCLK_MGT PRCM_CLK_MGT(0x018) 27 + #define PRCM_MSP02CLK_MGT PRCM_CLK_MGT(0x01C) 28 + #define PRCM_I2CCLK_MGT PRCM_CLK_MGT(0x020) 29 + #define PRCM_SDMMCCLK_MGT PRCM_CLK_MGT(0x024) 30 + #define PRCM_SLIMCLK_MGT PRCM_CLK_MGT(0x028) 31 + #define PRCM_PER1CLK_MGT PRCM_CLK_MGT(0x02C) 32 + #define PRCM_PER2CLK_MGT PRCM_CLK_MGT(0x030) 33 + #define PRCM_PER3CLK_MGT PRCM_CLK_MGT(0x034) 34 + #define PRCM_PER5CLK_MGT PRCM_CLK_MGT(0x038) 35 + #define PRCM_PER6CLK_MGT PRCM_CLK_MGT(0x03C) 36 + #define PRCM_PER7CLK_MGT PRCM_CLK_MGT(0x040) 37 + #define PRCM_LCDCLK_MGT PRCM_CLK_MGT(0x044) 38 + #define PRCM_BMLCLK_MGT PRCM_CLK_MGT(0x04C) 39 + #define PRCM_HSITXCLK_MGT PRCM_CLK_MGT(0x050) 40 + #define PRCM_HSIRXCLK_MGT PRCM_CLK_MGT(0x054) 41 + #define PRCM_HDMICLK_MGT PRCM_CLK_MGT(0x058) 42 + #define PRCM_APEATCLK_MGT PRCM_CLK_MGT(0x05C) 43 + #define PRCM_APETRACECLK_MGT PRCM_CLK_MGT(0x060) 44 + #define PRCM_MCDECLK_MGT PRCM_CLK_MGT(0x064) 45 + #define PRCM_IPI2CCLK_MGT PRCM_CLK_MGT(0x068) 46 + #define PRCM_DSIALTCLK_MGT PRCM_CLK_MGT(0x06C) 47 + #define PRCM_DMACLK_MGT PRCM_CLK_MGT(0x074) 48 + #define PRCM_B2R2CLK_MGT PRCM_CLK_MGT(0x078) 49 + #define PRCM_TVCLK_MGT PRCM_CLK_MGT(0x07C) 50 + #define PRCM_UNIPROCLK_MGT PRCM_CLK_MGT(0x278) 51 + #define PRCM_SSPCLK_MGT PRCM_CLK_MGT(0x280) 52 + #define PRCM_RNGCLK_MGT PRCM_CLK_MGT(0x284) 53 + #define PRCM_UICCCLK_MGT PRCM_CLK_MGT(0x27C) 54 + #define PRCM_MSP1CLK_MGT PRCM_CLK_MGT(0x288) 55 55 56 56 #define PRCM_ARM_PLLDIVPS (_PRCMU_BASE + 0x118) 57 57 #define PRCM_ARM_PLLDIVPS_ARM_BRM_RATE 0x3f ··· 79 79 80 80 /* ARM WFI Standby signal register */ 81 81 #define PRCM_ARM_WFI_STANDBY (_PRCMU_BASE + 0x130) 82 + #define PRCM_ARM_WFI_STANDBY_WFI0 0x08 83 + #define PRCM_ARM_WFI_STANDBY_WFI1 0x10 82 84 #define PRCM_IOCR (_PRCMU_BASE + 0x310) 83 85 #define PRCM_IOCR_IOFORCE 0x1 84 86 ··· 133 131 #define PRCM_MMIP_LS_CLAMP_SET (_PRCMU_BASE + 0x420) 134 132 #define PRCM_MMIP_LS_CLAMP_CLR (_PRCMU_BASE + 0x424) 135 133 134 + #define PRCM_MMIP_LS_CLAMP_DSIPLL_CLAMP BIT(11) 135 + #define PRCM_MMIP_LS_CLAMP_DSIPLL_CLAMPI BIT(22) 136 + 136 137 /* PRCMU clock/PLL/reset registers */ 138 + #define PRCM_PLLSOC0_FREQ (_PRCMU_BASE + 0x080) 139 + #define PRCM_PLLSOC1_FREQ (_PRCMU_BASE + 0x084) 140 + #define PRCM_PLLDDR_FREQ (_PRCMU_BASE + 0x08C) 141 + #define PRCM_PLL_FREQ_D_SHIFT 0 142 + #define PRCM_PLL_FREQ_D_MASK BITS(0, 7) 143 + #define PRCM_PLL_FREQ_N_SHIFT 8 144 + #define PRCM_PLL_FREQ_N_MASK BITS(8, 13) 145 + #define PRCM_PLL_FREQ_R_SHIFT 16 146 + #define PRCM_PLL_FREQ_R_MASK BITS(16, 18) 147 + #define PRCM_PLL_FREQ_SELDIV2 BIT(24) 148 + #define PRCM_PLL_FREQ_DIV2EN BIT(25) 149 + 137 150 #define PRCM_PLLDSI_FREQ (_PRCMU_BASE + 0x500) 138 151 #define PRCM_PLLDSI_ENABLE (_PRCMU_BASE + 0x504) 139 152 #define PRCM_PLLDSI_LOCKP (_PRCMU_BASE + 0x508) 140 - #define PRCM_LCDCLK_MGT (_PRCMU_BASE + PRCM_LCDCLK_MGT_OFF) 141 - #define PRCM_MCDECLK_MGT (_PRCMU_BASE + PRCM_MCDECLK_MGT_OFF) 142 - #define PRCM_HDMICLK_MGT (_PRCMU_BASE + PRCM_HDMICLK_MGT_OFF) 143 - #define PRCM_TVCLK_MGT (_PRCMU_BASE + PRCM_TVCLK_MGT_OFF) 144 153 #define PRCM_DSI_PLLOUT_SEL (_PRCMU_BASE + 0x530) 145 154 #define PRCM_DSITVCLK_DIV (_PRCMU_BASE + 0x52C) 146 155 #define PRCM_PLLDSI_LOCKP (_PRCMU_BASE + 0x508) 147 156 #define PRCM_APE_RESETN_SET (_PRCMU_BASE + 0x1E4) 148 157 #define PRCM_APE_RESETN_CLR (_PRCMU_BASE + 0x1E8) 158 + 159 + #define PRCM_PLLDSI_ENABLE_PRCM_PLLDSI_ENABLE BIT(0) 160 + 161 + #define PRCM_PLLDSI_LOCKP_PRCM_PLLDSI_LOCKP10 BIT(0) 162 + #define PRCM_PLLDSI_LOCKP_PRCM_PLLDSI_LOCKP3 BIT(1) 163 + 164 + #define PRCM_DSI_PLLOUT_SEL_DSI0_PLLOUT_DIVSEL_SHIFT 0 165 + #define PRCM_DSI_PLLOUT_SEL_DSI0_PLLOUT_DIVSEL_MASK BITS(0, 2) 166 + #define PRCM_DSI_PLLOUT_SEL_DSI1_PLLOUT_DIVSEL_SHIFT 8 167 + #define PRCM_DSI_PLLOUT_SEL_DSI1_PLLOUT_DIVSEL_MASK BITS(8, 10) 168 + 169 + #define PRCM_DSI_PLLOUT_SEL_OFF 0 170 + #define PRCM_DSI_PLLOUT_SEL_PHI 1 171 + #define PRCM_DSI_PLLOUT_SEL_PHI_2 2 172 + #define PRCM_DSI_PLLOUT_SEL_PHI_4 3 173 + 174 + #define PRCM_DSITVCLK_DIV_DSI0_ESC_CLK_DIV_SHIFT 0 175 + #define PRCM_DSITVCLK_DIV_DSI0_ESC_CLK_DIV_MASK BITS(0, 7) 176 + #define PRCM_DSITVCLK_DIV_DSI1_ESC_CLK_DIV_SHIFT 8 177 + #define PRCM_DSITVCLK_DIV_DSI1_ESC_CLK_DIV_MASK BITS(8, 15) 178 + #define PRCM_DSITVCLK_DIV_DSI2_ESC_CLK_DIV_SHIFT 16 179 + #define PRCM_DSITVCLK_DIV_DSI2_ESC_CLK_DIV_MASK BITS(16, 23) 180 + #define PRCM_DSITVCLK_DIV_DSI0_ESC_CLK_EN BIT(24) 181 + #define PRCM_DSITVCLK_DIV_DSI1_ESC_CLK_EN BIT(25) 182 + #define PRCM_DSITVCLK_DIV_DSI2_ESC_CLK_EN BIT(26) 183 + 184 + #define PRCM_APE_RESETN_DSIPLL_RESETN BIT(14) 149 185 150 186 #define PRCM_CLKOCR (_PRCMU_BASE + 0x1CC) 151 187 #define PRCM_CLKOCR_CLKOUT0_REF_CLK (1 << 0) ··· 223 183 #define PRCM_CLKOCR_CLKOSEL1_MASK BITS(22, 24) 224 184 #define PRCM_CLKOCR_CLK1TYPE BIT(28) 225 185 226 - #define PRCM_CLK_MGT_CLKPLLDIV_MASK BITS(0, 4) 227 - #define PRCM_CLK_MGT_CLKPLLSW_MASK BITS(5, 7) 228 - #define PRCM_CLK_MGT_CLKEN BIT(8) 186 + #define PRCM_CLK_MGT_CLKPLLDIV_MASK BITS(0, 4) 187 + #define PRCM_CLK_MGT_CLKPLLSW_SOC0 BIT(5) 188 + #define PRCM_CLK_MGT_CLKPLLSW_SOC1 BIT(6) 189 + #define PRCM_CLK_MGT_CLKPLLSW_DDR BIT(7) 190 + #define PRCM_CLK_MGT_CLKPLLSW_MASK BITS(5, 7) 191 + #define PRCM_CLK_MGT_CLKEN BIT(8) 192 + #define PRCM_CLK_MGT_CLK38 BIT(9) 193 + #define PRCM_CLK_MGT_CLK38DIV BIT(11) 194 + #define PRCM_SGACLK_MGT_SGACLKDIV_BY_2_5_EN BIT(12) 229 195 230 196 /* GPIOCR register */ 231 197 #define PRCM_GPIOCR_SPI2_SELECT BIT(23)
+9 -2
drivers/mfd/mc13xxx-core.c
··· 560 560 561 561 #define MC13XXX_ADC1_CHAN0_SHIFT 5 562 562 #define MC13XXX_ADC1_CHAN1_SHIFT 8 563 + #define MC13783_ADC1_ATO_SHIFT 11 564 + #define MC13783_ADC1_ATOX (1 << 19) 563 565 564 566 struct mc13xxx_adcdone_data { 565 567 struct mc13xxx *mc13xxx; ··· 582 580 #define MC13XXX_ADC_WORKING (1 << 0) 583 581 584 582 int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode, 585 - unsigned int channel, unsigned int *sample) 583 + unsigned int channel, u8 ato, bool atox, 584 + unsigned int *sample) 586 585 { 587 586 u32 adc0, adc1, old_adc0; 588 587 int i, ret; ··· 634 631 return -EINVAL; 635 632 } 636 633 634 + adc1 |= ato << MC13783_ADC1_ATO_SHIFT; 635 + if (atox) 636 + adc1 |= MC13783_ADC1_ATOX; 637 637 dev_dbg(&mc13xxx->spidev->dev, "%s: request irq\n", __func__); 638 638 mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE, 639 639 mc13xxx_handler_adcdone, __func__, &adcdone_data); ··· 819 813 mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); 820 814 821 815 if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) 822 - mc13xxx_add_subdevice(mc13xxx, "%s-ts"); 816 + mc13xxx_add_subdevice_pdata(mc13xxx, "%s-ts", 817 + &pdata->touch, sizeof(pdata->touch)); 823 818 824 819 if (pdata) { 825 820 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator",
+1 -1
drivers/mfd/mfd-core.c
··· 162 162 atomic_t *cnts; 163 163 164 164 /* initialize reference counting for all cells */ 165 - cnts = kcalloc(sizeof(*cnts), n_devs, GFP_KERNEL); 165 + cnts = kcalloc(n_devs, sizeof(*cnts), GFP_KERNEL); 166 166 if (!cnts) 167 167 return -ENOMEM; 168 168
+3 -4
drivers/mfd/omap-usb-host.c
··· 170 170 /*-------------------------------------------------------------------------*/ 171 171 172 172 const char usbhs_driver_name[] = USBHS_DRIVER_NAME; 173 - static u64 usbhs_dmamask = ~(u32)0; 173 + static u64 usbhs_dmamask = DMA_BIT_MASK(32); 174 174 175 175 /*-------------------------------------------------------------------------*/ 176 176 ··· 223 223 } 224 224 225 225 child->dev.dma_mask = &usbhs_dmamask; 226 - child->dev.coherent_dma_mask = 0xffffffff; 226 + dma_set_coherent_mask(&child->dev, DMA_BIT_MASK(32)); 227 227 child->dev.parent = dev; 228 228 229 229 ret = platform_device_add(child); ··· 799 799 800 800 platform_set_drvdata(pdev, omap); 801 801 802 + omap_usbhs_init(dev); 802 803 ret = omap_usbhs_alloc_children(pdev); 803 804 if (ret) { 804 805 dev_err(dev, "omap_usbhs_alloc_children failed\n"); 805 806 goto err_alloc; 806 807 } 807 - 808 - omap_usbhs_init(dev); 809 808 810 809 goto end_probe; 811 810
+1 -7
drivers/mfd/pcf50633-core.c
··· 46 46 int pcf50633_write_block(struct pcf50633 *pcf , u8 reg, 47 47 int nr_regs, u8 *data) 48 48 { 49 - int ret; 50 - 51 - ret = regmap_raw_write(pcf->regmap, reg, data, nr_regs); 52 - if (ret != 0) 53 - return ret; 54 - 55 - return nr_regs; 49 + return regmap_raw_write(pcf->regmap, reg, data, nr_regs); 56 50 } 57 51 EXPORT_SYMBOL_GPL(pcf50633_write_block); 58 52
+1 -26
drivers/mfd/pcf50633-gpio.c
··· 19 19 20 20 #include <linux/mfd/pcf50633/core.h> 21 21 #include <linux/mfd/pcf50633/gpio.h> 22 - 23 - enum pcf50633_regulator_id { 24 - PCF50633_REGULATOR_AUTO, 25 - PCF50633_REGULATOR_DOWN1, 26 - PCF50633_REGULATOR_DOWN2, 27 - PCF50633_REGULATOR_LDO1, 28 - PCF50633_REGULATOR_LDO2, 29 - PCF50633_REGULATOR_LDO3, 30 - PCF50633_REGULATOR_LDO4, 31 - PCF50633_REGULATOR_LDO5, 32 - PCF50633_REGULATOR_LDO6, 33 - PCF50633_REGULATOR_HCLDO, 34 - PCF50633_REGULATOR_MEMLDO, 35 - }; 36 - 37 - #define PCF50633_REG_AUTOOUT 0x1a 38 - #define PCF50633_REG_DOWN1OUT 0x1e 39 - #define PCF50633_REG_DOWN2OUT 0x22 40 - #define PCF50633_REG_MEMLDOOUT 0x26 41 - #define PCF50633_REG_LDO1OUT 0x2d 42 - #define PCF50633_REG_LDO2OUT 0x2f 43 - #define PCF50633_REG_LDO3OUT 0x31 44 - #define PCF50633_REG_LDO4OUT 0x33 45 - #define PCF50633_REG_LDO5OUT 0x35 46 - #define PCF50633_REG_LDO6OUT 0x37 47 - #define PCF50633_REG_HCLDOOUT 0x39 22 + #include <linux/mfd/pcf50633/pmic.h> 48 23 49 24 static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = { 50 25 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
+1 -6
drivers/mfd/pcf50633-irq.c
··· 19 19 #include <linux/slab.h> 20 20 21 21 #include <linux/mfd/pcf50633/core.h> 22 - 23 - /* Two MBCS registers used during cold start */ 24 - #define PCF50633_REG_MBCS1 0x4b 25 - #define PCF50633_REG_MBCS2 0x4c 26 - #define PCF50633_MBCS1_USBPRES 0x01 27 - #define PCF50633_MBCS1_ADAPTPRES 0x01 22 + #include <linux/mfd/pcf50633/mbc.h> 28 23 29 24 int pcf50633_register_irq(struct pcf50633 *pcf, int irq, 30 25 void (*handler) (int, void *), void *data)
+408
drivers/mfd/rc5t583-irq.c
··· 1 + /* 2 + * Interrupt driver for RICOH583 power management chip. 3 + * 4 + * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved. 5 + * Author: Laxman dewangan <ldewangan@nvidia.com> 6 + * 7 + * based on code 8 + * Copyright (C) 2011 RICOH COMPANY,LTD 9 + * 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms and conditions of the GNU General Public License, 12 + * version 2, as published by the Free Software Foundation. 13 + * 14 + * This program is distributed in the hope it will be useful, but WITHOUT 15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 + * more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 + * 22 + */ 23 + #include <linux/interrupt.h> 24 + #include <linux/irq.h> 25 + #include <linux/init.h> 26 + #include <linux/i2c.h> 27 + #include <linux/mfd/rc5t583.h> 28 + 29 + enum int_type { 30 + SYS_INT = 0x1, 31 + DCDC_INT = 0x2, 32 + RTC_INT = 0x4, 33 + ADC_INT = 0x8, 34 + GPIO_INT = 0x10, 35 + }; 36 + 37 + static int gpedge_add[] = { 38 + RC5T583_GPIO_GPEDGE2, 39 + RC5T583_GPIO_GPEDGE2 40 + }; 41 + 42 + static int irq_en_add[] = { 43 + RC5T583_INT_EN_SYS1, 44 + RC5T583_INT_EN_SYS2, 45 + RC5T583_INT_EN_DCDC, 46 + RC5T583_INT_EN_RTC, 47 + RC5T583_INT_EN_ADC1, 48 + RC5T583_INT_EN_ADC2, 49 + RC5T583_INT_EN_ADC3, 50 + RC5T583_GPIO_EN_INT 51 + }; 52 + 53 + static int irq_mon_add[] = { 54 + RC5T583_INT_MON_SYS1, 55 + RC5T583_INT_MON_SYS2, 56 + RC5T583_INT_MON_DCDC, 57 + RC5T583_INT_MON_RTC, 58 + RC5T583_INT_IR_ADCL, 59 + RC5T583_INT_IR_ADCH, 60 + RC5T583_INT_IR_ADCEND, 61 + RC5T583_INT_IR_GPIOF, 62 + RC5T583_INT_IR_GPIOR 63 + }; 64 + 65 + static int irq_clr_add[] = { 66 + RC5T583_INT_IR_SYS1, 67 + RC5T583_INT_IR_SYS2, 68 + RC5T583_INT_IR_DCDC, 69 + RC5T583_INT_IR_RTC, 70 + RC5T583_INT_IR_ADCL, 71 + RC5T583_INT_IR_ADCH, 72 + RC5T583_INT_IR_ADCEND, 73 + RC5T583_INT_IR_GPIOF, 74 + RC5T583_INT_IR_GPIOR 75 + }; 76 + 77 + static int main_int_type[] = { 78 + SYS_INT, 79 + SYS_INT, 80 + DCDC_INT, 81 + RTC_INT, 82 + ADC_INT, 83 + ADC_INT, 84 + ADC_INT, 85 + GPIO_INT, 86 + GPIO_INT, 87 + }; 88 + 89 + struct rc5t583_irq_data { 90 + u8 int_type; 91 + u8 master_bit; 92 + u8 int_en_bit; 93 + u8 mask_reg_index; 94 + int grp_index; 95 + }; 96 + 97 + #define RC5T583_IRQ(_int_type, _master_bit, _grp_index, \ 98 + _int_bit, _mask_ind) \ 99 + { \ 100 + .int_type = _int_type, \ 101 + .master_bit = _master_bit, \ 102 + .grp_index = _grp_index, \ 103 + .int_en_bit = _int_bit, \ 104 + .mask_reg_index = _mask_ind, \ 105 + } 106 + 107 + static const struct rc5t583_irq_data rc5t583_irqs[RC5T583_MAX_IRQS] = { 108 + [RC5T583_IRQ_ONKEY] = RC5T583_IRQ(SYS_INT, 0, 0, 0, 0), 109 + [RC5T583_IRQ_ACOK] = RC5T583_IRQ(SYS_INT, 0, 1, 1, 0), 110 + [RC5T583_IRQ_LIDOPEN] = RC5T583_IRQ(SYS_INT, 0, 2, 2, 0), 111 + [RC5T583_IRQ_PREOT] = RC5T583_IRQ(SYS_INT, 0, 3, 3, 0), 112 + [RC5T583_IRQ_CLKSTP] = RC5T583_IRQ(SYS_INT, 0, 4, 4, 0), 113 + [RC5T583_IRQ_ONKEY_OFF] = RC5T583_IRQ(SYS_INT, 0, 5, 5, 0), 114 + [RC5T583_IRQ_WD] = RC5T583_IRQ(SYS_INT, 0, 7, 7, 0), 115 + [RC5T583_IRQ_EN_PWRREQ1] = RC5T583_IRQ(SYS_INT, 0, 8, 0, 1), 116 + [RC5T583_IRQ_EN_PWRREQ2] = RC5T583_IRQ(SYS_INT, 0, 9, 1, 1), 117 + [RC5T583_IRQ_PRE_VINDET] = RC5T583_IRQ(SYS_INT, 0, 10, 2, 1), 118 + 119 + [RC5T583_IRQ_DC0LIM] = RC5T583_IRQ(DCDC_INT, 1, 0, 0, 2), 120 + [RC5T583_IRQ_DC1LIM] = RC5T583_IRQ(DCDC_INT, 1, 1, 1, 2), 121 + [RC5T583_IRQ_DC2LIM] = RC5T583_IRQ(DCDC_INT, 1, 2, 2, 2), 122 + [RC5T583_IRQ_DC3LIM] = RC5T583_IRQ(DCDC_INT, 1, 3, 3, 2), 123 + 124 + [RC5T583_IRQ_CTC] = RC5T583_IRQ(RTC_INT, 2, 0, 0, 3), 125 + [RC5T583_IRQ_YALE] = RC5T583_IRQ(RTC_INT, 2, 5, 5, 3), 126 + [RC5T583_IRQ_DALE] = RC5T583_IRQ(RTC_INT, 2, 6, 6, 3), 127 + [RC5T583_IRQ_WALE] = RC5T583_IRQ(RTC_INT, 2, 7, 7, 3), 128 + 129 + [RC5T583_IRQ_AIN1L] = RC5T583_IRQ(ADC_INT, 3, 0, 0, 4), 130 + [RC5T583_IRQ_AIN2L] = RC5T583_IRQ(ADC_INT, 3, 1, 1, 4), 131 + [RC5T583_IRQ_AIN3L] = RC5T583_IRQ(ADC_INT, 3, 2, 2, 4), 132 + [RC5T583_IRQ_VBATL] = RC5T583_IRQ(ADC_INT, 3, 3, 3, 4), 133 + [RC5T583_IRQ_VIN3L] = RC5T583_IRQ(ADC_INT, 3, 4, 4, 4), 134 + [RC5T583_IRQ_VIN8L] = RC5T583_IRQ(ADC_INT, 3, 5, 5, 4), 135 + [RC5T583_IRQ_AIN1H] = RC5T583_IRQ(ADC_INT, 3, 6, 0, 5), 136 + [RC5T583_IRQ_AIN2H] = RC5T583_IRQ(ADC_INT, 3, 7, 1, 5), 137 + [RC5T583_IRQ_AIN3H] = RC5T583_IRQ(ADC_INT, 3, 8, 2, 5), 138 + [RC5T583_IRQ_VBATH] = RC5T583_IRQ(ADC_INT, 3, 9, 3, 5), 139 + [RC5T583_IRQ_VIN3H] = RC5T583_IRQ(ADC_INT, 3, 10, 4, 5), 140 + [RC5T583_IRQ_VIN8H] = RC5T583_IRQ(ADC_INT, 3, 11, 5, 5), 141 + [RC5T583_IRQ_ADCEND] = RC5T583_IRQ(ADC_INT, 3, 12, 0, 6), 142 + 143 + [RC5T583_IRQ_GPIO0] = RC5T583_IRQ(GPIO_INT, 4, 0, 0, 7), 144 + [RC5T583_IRQ_GPIO1] = RC5T583_IRQ(GPIO_INT, 4, 1, 1, 7), 145 + [RC5T583_IRQ_GPIO2] = RC5T583_IRQ(GPIO_INT, 4, 2, 2, 7), 146 + [RC5T583_IRQ_GPIO3] = RC5T583_IRQ(GPIO_INT, 4, 3, 3, 7), 147 + [RC5T583_IRQ_GPIO4] = RC5T583_IRQ(GPIO_INT, 4, 4, 4, 7), 148 + [RC5T583_IRQ_GPIO5] = RC5T583_IRQ(GPIO_INT, 4, 5, 5, 7), 149 + [RC5T583_IRQ_GPIO6] = RC5T583_IRQ(GPIO_INT, 4, 6, 6, 7), 150 + [RC5T583_IRQ_GPIO7] = RC5T583_IRQ(GPIO_INT, 4, 7, 7, 7), 151 + }; 152 + 153 + static void rc5t583_irq_lock(struct irq_data *irq_data) 154 + { 155 + struct rc5t583 *rc5t583 = irq_data_get_irq_chip_data(irq_data); 156 + mutex_lock(&rc5t583->irq_lock); 157 + } 158 + 159 + static void rc5t583_irq_unmask(struct irq_data *irq_data) 160 + { 161 + struct rc5t583 *rc5t583 = irq_data_get_irq_chip_data(irq_data); 162 + unsigned int __irq = irq_data->irq - rc5t583->irq_base; 163 + const struct rc5t583_irq_data *data = &rc5t583_irqs[__irq]; 164 + 165 + rc5t583->group_irq_en[data->grp_index] |= 1 << data->grp_index; 166 + rc5t583->intc_inten_reg |= 1 << data->master_bit; 167 + rc5t583->irq_en_reg[data->mask_reg_index] |= 1 << data->int_en_bit; 168 + } 169 + 170 + static void rc5t583_irq_mask(struct irq_data *irq_data) 171 + { 172 + struct rc5t583 *rc5t583 = irq_data_get_irq_chip_data(irq_data); 173 + unsigned int __irq = irq_data->irq - rc5t583->irq_base; 174 + const struct rc5t583_irq_data *data = &rc5t583_irqs[__irq]; 175 + 176 + rc5t583->group_irq_en[data->grp_index] &= ~(1 << data->grp_index); 177 + if (!rc5t583->group_irq_en[data->grp_index]) 178 + rc5t583->intc_inten_reg &= ~(1 << data->master_bit); 179 + 180 + rc5t583->irq_en_reg[data->mask_reg_index] &= ~(1 << data->int_en_bit); 181 + } 182 + 183 + static int rc5t583_irq_set_type(struct irq_data *irq_data, unsigned int type) 184 + { 185 + struct rc5t583 *rc5t583 = irq_data_get_irq_chip_data(irq_data); 186 + unsigned int __irq = irq_data->irq - rc5t583->irq_base; 187 + const struct rc5t583_irq_data *data = &rc5t583_irqs[__irq]; 188 + int val = 0; 189 + int gpedge_index; 190 + int gpedge_bit_pos; 191 + 192 + /* Supporting only trigger level inetrrupt */ 193 + if ((data->int_type & GPIO_INT) && (type & IRQ_TYPE_EDGE_BOTH)) { 194 + gpedge_index = data->int_en_bit / 4; 195 + gpedge_bit_pos = data->int_en_bit % 4; 196 + 197 + if (type & IRQ_TYPE_EDGE_FALLING) 198 + val |= 0x2; 199 + 200 + if (type & IRQ_TYPE_EDGE_RISING) 201 + val |= 0x1; 202 + 203 + rc5t583->gpedge_reg[gpedge_index] &= ~(3 << gpedge_bit_pos); 204 + rc5t583->gpedge_reg[gpedge_index] |= (val << gpedge_bit_pos); 205 + rc5t583_irq_unmask(irq_data); 206 + return 0; 207 + } 208 + return -EINVAL; 209 + } 210 + 211 + static void rc5t583_irq_sync_unlock(struct irq_data *irq_data) 212 + { 213 + struct rc5t583 *rc5t583 = irq_data_get_irq_chip_data(irq_data); 214 + int i; 215 + int ret; 216 + 217 + for (i = 0; i < ARRAY_SIZE(rc5t583->gpedge_reg); i++) { 218 + ret = rc5t583_write(rc5t583->dev, gpedge_add[i], 219 + rc5t583->gpedge_reg[i]); 220 + if (ret < 0) 221 + dev_warn(rc5t583->dev, 222 + "Error in writing reg 0x%02x error: %d\n", 223 + gpedge_add[i], ret); 224 + } 225 + 226 + for (i = 0; i < ARRAY_SIZE(rc5t583->irq_en_reg); i++) { 227 + ret = rc5t583_write(rc5t583->dev, irq_en_add[i], 228 + rc5t583->irq_en_reg[i]); 229 + if (ret < 0) 230 + dev_warn(rc5t583->dev, 231 + "Error in writing reg 0x%02x error: %d\n", 232 + irq_en_add[i], ret); 233 + } 234 + 235 + ret = rc5t583_write(rc5t583->dev, RC5T583_INTC_INTEN, 236 + rc5t583->intc_inten_reg); 237 + if (ret < 0) 238 + dev_warn(rc5t583->dev, 239 + "Error in writing reg 0x%02x error: %d\n", 240 + RC5T583_INTC_INTEN, ret); 241 + 242 + mutex_unlock(&rc5t583->irq_lock); 243 + } 244 + #ifdef CONFIG_PM_SLEEP 245 + static int rc5t583_irq_set_wake(struct irq_data *irq_data, unsigned int on) 246 + { 247 + struct rc5t583 *rc5t583 = irq_data_get_irq_chip_data(irq_data); 248 + return irq_set_irq_wake(rc5t583->chip_irq, on); 249 + } 250 + #else 251 + #define rc5t583_irq_set_wake NULL 252 + #endif 253 + 254 + static irqreturn_t rc5t583_irq(int irq, void *data) 255 + { 256 + struct rc5t583 *rc5t583 = data; 257 + uint8_t int_sts[RC5T583_MAX_INTERRUPT_MASK_REGS]; 258 + uint8_t master_int; 259 + int i; 260 + int ret; 261 + unsigned int rtc_int_sts = 0; 262 + 263 + /* Clear the status */ 264 + for (i = 0; i < RC5T583_MAX_INTERRUPT_MASK_REGS; i++) 265 + int_sts[i] = 0; 266 + 267 + ret = rc5t583_read(rc5t583->dev, RC5T583_INTC_INTMON, &master_int); 268 + if (ret < 0) { 269 + dev_err(rc5t583->dev, 270 + "Error in reading reg 0x%02x error: %d\n", 271 + RC5T583_INTC_INTMON, ret); 272 + return IRQ_HANDLED; 273 + } 274 + 275 + for (i = 0; i < RC5T583_MAX_INTERRUPT_MASK_REGS; ++i) { 276 + if (!(master_int & main_int_type[i])) 277 + continue; 278 + 279 + ret = rc5t583_read(rc5t583->dev, irq_mon_add[i], &int_sts[i]); 280 + if (ret < 0) { 281 + dev_warn(rc5t583->dev, 282 + "Error in reading reg 0x%02x error: %d\n", 283 + irq_mon_add[i], ret); 284 + int_sts[i] = 0; 285 + continue; 286 + } 287 + 288 + if (main_int_type[i] & RTC_INT) { 289 + rtc_int_sts = 0; 290 + if (int_sts[i] & 0x1) 291 + rtc_int_sts |= BIT(6); 292 + if (int_sts[i] & 0x2) 293 + rtc_int_sts |= BIT(7); 294 + if (int_sts[i] & 0x4) 295 + rtc_int_sts |= BIT(0); 296 + if (int_sts[i] & 0x8) 297 + rtc_int_sts |= BIT(5); 298 + } 299 + 300 + ret = rc5t583_write(rc5t583->dev, irq_clr_add[i], 301 + ~int_sts[i]); 302 + if (ret < 0) 303 + dev_warn(rc5t583->dev, 304 + "Error in reading reg 0x%02x error: %d\n", 305 + irq_clr_add[i], ret); 306 + 307 + if (main_int_type[i] & RTC_INT) 308 + int_sts[i] = rtc_int_sts; 309 + } 310 + 311 + /* Merge gpio interrupts for rising and falling case*/ 312 + int_sts[7] |= int_sts[8]; 313 + 314 + /* Call interrupt handler if enabled */ 315 + for (i = 0; i < RC5T583_MAX_IRQS; ++i) { 316 + const struct rc5t583_irq_data *data = &rc5t583_irqs[i]; 317 + if ((int_sts[data->mask_reg_index] & (1 << data->int_en_bit)) && 318 + (rc5t583->group_irq_en[data->master_bit] & 319 + (1 << data->grp_index))) 320 + handle_nested_irq(rc5t583->irq_base + i); 321 + } 322 + 323 + return IRQ_HANDLED; 324 + } 325 + 326 + static struct irq_chip rc5t583_irq_chip = { 327 + .name = "rc5t583-irq", 328 + .irq_mask = rc5t583_irq_mask, 329 + .irq_unmask = rc5t583_irq_unmask, 330 + .irq_bus_lock = rc5t583_irq_lock, 331 + .irq_bus_sync_unlock = rc5t583_irq_sync_unlock, 332 + .irq_set_type = rc5t583_irq_set_type, 333 + .irq_set_wake = rc5t583_irq_set_wake, 334 + }; 335 + 336 + int rc5t583_irq_init(struct rc5t583 *rc5t583, int irq, int irq_base) 337 + { 338 + int i, ret; 339 + 340 + if (!irq_base) { 341 + dev_warn(rc5t583->dev, "No interrupt support on IRQ base\n"); 342 + return -EINVAL; 343 + } 344 + 345 + mutex_init(&rc5t583->irq_lock); 346 + 347 + /* Initailize all int register to 0 */ 348 + for (i = 0; i < RC5T583_MAX_INTERRUPT_MASK_REGS; i++) { 349 + ret = rc5t583_write(rc5t583->dev, irq_en_add[i], 350 + rc5t583->irq_en_reg[i]); 351 + if (ret < 0) 352 + dev_warn(rc5t583->dev, 353 + "Error in writing reg 0x%02x error: %d\n", 354 + irq_en_add[i], ret); 355 + } 356 + 357 + for (i = 0; i < RC5T583_MAX_GPEDGE_REG; i++) { 358 + ret = rc5t583_write(rc5t583->dev, gpedge_add[i], 359 + rc5t583->gpedge_reg[i]); 360 + if (ret < 0) 361 + dev_warn(rc5t583->dev, 362 + "Error in writing reg 0x%02x error: %d\n", 363 + gpedge_add[i], ret); 364 + } 365 + 366 + ret = rc5t583_write(rc5t583->dev, RC5T583_INTC_INTEN, 0x0); 367 + if (ret < 0) 368 + dev_warn(rc5t583->dev, 369 + "Error in writing reg 0x%02x error: %d\n", 370 + RC5T583_INTC_INTEN, ret); 371 + 372 + /* Clear all interrupts in case they woke up active. */ 373 + for (i = 0; i < RC5T583_MAX_INTERRUPT_MASK_REGS; i++) { 374 + ret = rc5t583_write(rc5t583->dev, irq_clr_add[i], 0); 375 + if (ret < 0) 376 + dev_warn(rc5t583->dev, 377 + "Error in writing reg 0x%02x error: %d\n", 378 + irq_clr_add[i], ret); 379 + } 380 + 381 + rc5t583->irq_base = irq_base; 382 + rc5t583->chip_irq = irq; 383 + 384 + for (i = 0; i < RC5T583_MAX_IRQS; i++) { 385 + int __irq = i + rc5t583->irq_base; 386 + irq_set_chip_data(__irq, rc5t583); 387 + irq_set_chip_and_handler(__irq, &rc5t583_irq_chip, 388 + handle_simple_irq); 389 + irq_set_nested_thread(__irq, 1); 390 + #ifdef CONFIG_ARM 391 + set_irq_flags(__irq, IRQF_VALID); 392 + #endif 393 + } 394 + 395 + ret = request_threaded_irq(irq, NULL, rc5t583_irq, IRQF_ONESHOT, 396 + "rc5t583", rc5t583); 397 + if (ret < 0) 398 + dev_err(rc5t583->dev, 399 + "Error in registering interrupt error: %d\n", ret); 400 + return ret; 401 + } 402 + 403 + int rc5t583_irq_exit(struct rc5t583 *rc5t583) 404 + { 405 + if (rc5t583->chip_irq) 406 + free_irq(rc5t583->chip_irq, rc5t583); 407 + return 0; 408 + }
+386
drivers/mfd/rc5t583.c
··· 1 + /* 2 + * Core driver access RC5T583 power management chip. 3 + * 4 + * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved. 5 + * Author: Laxman dewangan <ldewangan@nvidia.com> 6 + * 7 + * Based on code 8 + * Copyright (C) 2011 RICOH COMPANY,LTD 9 + * 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms and conditions of the GNU General Public License, 12 + * version 2, as published by the Free Software Foundation. 13 + * 14 + * This program is distributed in the hope it will be useful, but WITHOUT 15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 + * more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 + * 22 + */ 23 + #include <linux/interrupt.h> 24 + #include <linux/irq.h> 25 + #include <linux/kernel.h> 26 + #include <linux/module.h> 27 + #include <linux/init.h> 28 + #include <linux/err.h> 29 + #include <linux/slab.h> 30 + #include <linux/i2c.h> 31 + #include <linux/mfd/core.h> 32 + #include <linux/mfd/rc5t583.h> 33 + #include <linux/regmap.h> 34 + 35 + #define RICOH_ONOFFSEL_REG 0x10 36 + #define RICOH_SWCTL_REG 0x5E 37 + 38 + struct deepsleep_control_data { 39 + u8 reg_add; 40 + u8 ds_pos_bit; 41 + }; 42 + 43 + #define DEEPSLEEP_INIT(_id, _reg, _pos) \ 44 + { \ 45 + .reg_add = RC5T583_##_reg, \ 46 + .ds_pos_bit = _pos, \ 47 + } 48 + 49 + static struct deepsleep_control_data deepsleep_data[] = { 50 + DEEPSLEEP_INIT(DC0, SLPSEQ1, 0), 51 + DEEPSLEEP_INIT(DC1, SLPSEQ1, 4), 52 + DEEPSLEEP_INIT(DC2, SLPSEQ2, 0), 53 + DEEPSLEEP_INIT(DC3, SLPSEQ2, 4), 54 + DEEPSLEEP_INIT(LDO0, SLPSEQ3, 0), 55 + DEEPSLEEP_INIT(LDO1, SLPSEQ3, 4), 56 + DEEPSLEEP_INIT(LDO2, SLPSEQ4, 0), 57 + DEEPSLEEP_INIT(LDO3, SLPSEQ4, 4), 58 + DEEPSLEEP_INIT(LDO4, SLPSEQ5, 0), 59 + DEEPSLEEP_INIT(LDO5, SLPSEQ5, 4), 60 + DEEPSLEEP_INIT(LDO6, SLPSEQ6, 0), 61 + DEEPSLEEP_INIT(LDO7, SLPSEQ6, 4), 62 + DEEPSLEEP_INIT(LDO8, SLPSEQ7, 0), 63 + DEEPSLEEP_INIT(LDO9, SLPSEQ7, 4), 64 + DEEPSLEEP_INIT(PSO0, SLPSEQ8, 0), 65 + DEEPSLEEP_INIT(PSO1, SLPSEQ8, 4), 66 + DEEPSLEEP_INIT(PSO2, SLPSEQ9, 0), 67 + DEEPSLEEP_INIT(PSO3, SLPSEQ9, 4), 68 + DEEPSLEEP_INIT(PSO4, SLPSEQ10, 0), 69 + DEEPSLEEP_INIT(PSO5, SLPSEQ10, 4), 70 + DEEPSLEEP_INIT(PSO6, SLPSEQ11, 0), 71 + DEEPSLEEP_INIT(PSO7, SLPSEQ11, 4), 72 + }; 73 + 74 + #define EXT_PWR_REQ \ 75 + (RC5T583_EXT_PWRREQ1_CONTROL | RC5T583_EXT_PWRREQ2_CONTROL) 76 + 77 + static struct mfd_cell rc5t583_subdevs[] = { 78 + {.name = "rc5t583-regulator",}, 79 + {.name = "rc5t583-rtc", }, 80 + {.name = "rc5t583-key", } 81 + }; 82 + 83 + int rc5t583_write(struct device *dev, uint8_t reg, uint8_t val) 84 + { 85 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev); 86 + return regmap_write(rc5t583->regmap, reg, val); 87 + } 88 + 89 + int rc5t583_read(struct device *dev, uint8_t reg, uint8_t *val) 90 + { 91 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev); 92 + unsigned int ival; 93 + int ret; 94 + ret = regmap_read(rc5t583->regmap, reg, &ival); 95 + if (!ret) 96 + *val = (uint8_t)ival; 97 + return ret; 98 + } 99 + 100 + int rc5t583_set_bits(struct device *dev, unsigned int reg, 101 + unsigned int bit_mask) 102 + { 103 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev); 104 + return regmap_update_bits(rc5t583->regmap, reg, bit_mask, bit_mask); 105 + } 106 + 107 + int rc5t583_clear_bits(struct device *dev, unsigned int reg, 108 + unsigned int bit_mask) 109 + { 110 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev); 111 + return regmap_update_bits(rc5t583->regmap, reg, bit_mask, 0); 112 + } 113 + 114 + int rc5t583_update(struct device *dev, unsigned int reg, 115 + unsigned int val, unsigned int mask) 116 + { 117 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev); 118 + return regmap_update_bits(rc5t583->regmap, reg, mask, val); 119 + } 120 + 121 + static int __rc5t583_set_ext_pwrreq1_control(struct device *dev, 122 + int id, int ext_pwr, int slots) 123 + { 124 + int ret; 125 + uint8_t sleepseq_val; 126 + unsigned int en_bit; 127 + unsigned int slot_bit; 128 + 129 + if (id == RC5T583_DS_DC0) { 130 + dev_err(dev, "PWRREQ1 is invalid control for rail %d\n", id); 131 + return -EINVAL; 132 + } 133 + 134 + en_bit = deepsleep_data[id].ds_pos_bit; 135 + slot_bit = en_bit + 1; 136 + ret = rc5t583_read(dev, deepsleep_data[id].reg_add, &sleepseq_val); 137 + if (ret < 0) { 138 + dev_err(dev, "Error in reading reg 0x%x\n", 139 + deepsleep_data[id].reg_add); 140 + return ret; 141 + } 142 + 143 + sleepseq_val &= ~(0xF << en_bit); 144 + sleepseq_val |= BIT(en_bit); 145 + sleepseq_val |= ((slots & 0x7) << slot_bit); 146 + ret = rc5t583_set_bits(dev, RICOH_ONOFFSEL_REG, BIT(1)); 147 + if (ret < 0) { 148 + dev_err(dev, "Error in updating the 0x%02x register\n", 149 + RICOH_ONOFFSEL_REG); 150 + return ret; 151 + } 152 + 153 + ret = rc5t583_write(dev, deepsleep_data[id].reg_add, sleepseq_val); 154 + if (ret < 0) { 155 + dev_err(dev, "Error in writing reg 0x%x\n", 156 + deepsleep_data[id].reg_add); 157 + return ret; 158 + } 159 + 160 + if (id == RC5T583_DS_LDO4) { 161 + ret = rc5t583_write(dev, RICOH_SWCTL_REG, 0x1); 162 + if (ret < 0) 163 + dev_err(dev, "Error in writing reg 0x%x\n", 164 + RICOH_SWCTL_REG); 165 + } 166 + return ret; 167 + } 168 + 169 + static int __rc5t583_set_ext_pwrreq2_control(struct device *dev, 170 + int id, int ext_pwr) 171 + { 172 + int ret; 173 + 174 + if (id != RC5T583_DS_DC0) { 175 + dev_err(dev, "PWRREQ2 is invalid control for rail %d\n", id); 176 + return -EINVAL; 177 + } 178 + 179 + ret = rc5t583_set_bits(dev, RICOH_ONOFFSEL_REG, BIT(2)); 180 + if (ret < 0) 181 + dev_err(dev, "Error in updating the ONOFFSEL 0x10 register\n"); 182 + return ret; 183 + } 184 + 185 + int rc5t583_ext_power_req_config(struct device *dev, int ds_id, 186 + int ext_pwr_req, int deepsleep_slot_nr) 187 + { 188 + if ((ext_pwr_req & EXT_PWR_REQ) == EXT_PWR_REQ) 189 + return -EINVAL; 190 + 191 + if (ext_pwr_req & RC5T583_EXT_PWRREQ1_CONTROL) 192 + return __rc5t583_set_ext_pwrreq1_control(dev, ds_id, 193 + ext_pwr_req, deepsleep_slot_nr); 194 + 195 + if (ext_pwr_req & RC5T583_EXT_PWRREQ2_CONTROL) 196 + return __rc5t583_set_ext_pwrreq2_control(dev, 197 + ds_id, ext_pwr_req); 198 + return 0; 199 + } 200 + 201 + static int rc5t583_clear_ext_power_req(struct rc5t583 *rc5t583, 202 + struct rc5t583_platform_data *pdata) 203 + { 204 + int ret; 205 + int i; 206 + uint8_t on_off_val = 0; 207 + 208 + /* Clear ONOFFSEL register */ 209 + if (pdata->enable_shutdown) 210 + on_off_val = 0x1; 211 + 212 + ret = rc5t583_write(rc5t583->dev, RICOH_ONOFFSEL_REG, on_off_val); 213 + if (ret < 0) 214 + dev_warn(rc5t583->dev, "Error in writing reg %d error: %d\n", 215 + RICOH_ONOFFSEL_REG, ret); 216 + 217 + ret = rc5t583_write(rc5t583->dev, RICOH_SWCTL_REG, 0x0); 218 + if (ret < 0) 219 + dev_warn(rc5t583->dev, "Error in writing reg %d error: %d\n", 220 + RICOH_SWCTL_REG, ret); 221 + 222 + /* Clear sleep sequence register */ 223 + for (i = RC5T583_SLPSEQ1; i <= RC5T583_SLPSEQ11; ++i) { 224 + ret = rc5t583_write(rc5t583->dev, i, 0x0); 225 + if (ret < 0) 226 + dev_warn(rc5t583->dev, 227 + "Error in writing reg 0x%02x error: %d\n", 228 + i, ret); 229 + } 230 + return 0; 231 + } 232 + 233 + static bool volatile_reg(struct device *dev, unsigned int reg) 234 + { 235 + /* Enable caching in interrupt registers */ 236 + switch (reg) { 237 + case RC5T583_INT_EN_SYS1: 238 + case RC5T583_INT_EN_SYS2: 239 + case RC5T583_INT_EN_DCDC: 240 + case RC5T583_INT_EN_RTC: 241 + case RC5T583_INT_EN_ADC1: 242 + case RC5T583_INT_EN_ADC2: 243 + case RC5T583_INT_EN_ADC3: 244 + case RC5T583_GPIO_GPEDGE1: 245 + case RC5T583_GPIO_GPEDGE2: 246 + case RC5T583_GPIO_EN_INT: 247 + return false; 248 + 249 + case RC5T583_GPIO_MON_IOIN: 250 + /* This is gpio input register */ 251 + return true; 252 + 253 + default: 254 + /* Enable caching in gpio registers */ 255 + if ((reg >= RC5T583_GPIO_IOSEL) && 256 + (reg <= RC5T583_GPIO_GPOFUNC)) 257 + return false; 258 + 259 + /* Enable caching in sleep seq registers */ 260 + if ((reg >= RC5T583_SLPSEQ1) && (reg <= RC5T583_SLPSEQ11)) 261 + return false; 262 + 263 + /* Enable caching of regulator registers */ 264 + if ((reg >= RC5T583_REG_DC0CTL) && (reg <= RC5T583_REG_SR3CTL)) 265 + return false; 266 + if ((reg >= RC5T583_REG_LDOEN1) && 267 + (reg <= RC5T583_REG_LDO9DAC_DS)) 268 + return false; 269 + 270 + break; 271 + } 272 + 273 + return true; 274 + } 275 + 276 + static const struct regmap_config rc5t583_regmap_config = { 277 + .reg_bits = 8, 278 + .val_bits = 8, 279 + .volatile_reg = volatile_reg, 280 + .max_register = RC5T583_MAX_REGS, 281 + .num_reg_defaults_raw = RC5T583_MAX_REGS, 282 + .cache_type = REGCACHE_RBTREE, 283 + }; 284 + 285 + static int __devinit rc5t583_i2c_probe(struct i2c_client *i2c, 286 + const struct i2c_device_id *id) 287 + { 288 + struct rc5t583 *rc5t583; 289 + struct rc5t583_platform_data *pdata = i2c->dev.platform_data; 290 + int ret; 291 + bool irq_init_success = false; 292 + 293 + if (!pdata) { 294 + dev_err(&i2c->dev, "Err: Platform data not found\n"); 295 + return -EINVAL; 296 + } 297 + 298 + rc5t583 = devm_kzalloc(&i2c->dev, sizeof(struct rc5t583), GFP_KERNEL); 299 + if (!rc5t583) { 300 + dev_err(&i2c->dev, "Memory allocation failed\n"); 301 + return -ENOMEM; 302 + } 303 + 304 + rc5t583->dev = &i2c->dev; 305 + i2c_set_clientdata(i2c, rc5t583); 306 + 307 + rc5t583->regmap = regmap_init_i2c(i2c, &rc5t583_regmap_config); 308 + if (IS_ERR(rc5t583->regmap)) { 309 + ret = PTR_ERR(rc5t583->regmap); 310 + dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); 311 + return ret; 312 + } 313 + 314 + ret = rc5t583_clear_ext_power_req(rc5t583, pdata); 315 + if (ret < 0) 316 + goto err_irq_init; 317 + 318 + if (i2c->irq) { 319 + ret = rc5t583_irq_init(rc5t583, i2c->irq, pdata->irq_base); 320 + /* Still continue with waring if irq init fails */ 321 + if (ret) 322 + dev_warn(&i2c->dev, "IRQ init failed: %d\n", ret); 323 + else 324 + irq_init_success = true; 325 + } 326 + 327 + ret = mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs, 328 + ARRAY_SIZE(rc5t583_subdevs), NULL, 0); 329 + if (ret) { 330 + dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret); 331 + goto err_add_devs; 332 + } 333 + 334 + return 0; 335 + 336 + err_add_devs: 337 + if (irq_init_success) 338 + rc5t583_irq_exit(rc5t583); 339 + err_irq_init: 340 + regmap_exit(rc5t583->regmap); 341 + return ret; 342 + } 343 + 344 + static int __devexit rc5t583_i2c_remove(struct i2c_client *i2c) 345 + { 346 + struct rc5t583 *rc5t583 = i2c_get_clientdata(i2c); 347 + 348 + mfd_remove_devices(rc5t583->dev); 349 + rc5t583_irq_exit(rc5t583); 350 + regmap_exit(rc5t583->regmap); 351 + return 0; 352 + } 353 + 354 + static const struct i2c_device_id rc5t583_i2c_id[] = { 355 + {.name = "rc5t583", .driver_data = 0}, 356 + {} 357 + }; 358 + 359 + MODULE_DEVICE_TABLE(i2c, rc5t583_i2c_id); 360 + 361 + static struct i2c_driver rc5t583_i2c_driver = { 362 + .driver = { 363 + .name = "rc5t583", 364 + .owner = THIS_MODULE, 365 + }, 366 + .probe = rc5t583_i2c_probe, 367 + .remove = __devexit_p(rc5t583_i2c_remove), 368 + .id_table = rc5t583_i2c_id, 369 + }; 370 + 371 + static int __init rc5t583_i2c_init(void) 372 + { 373 + return i2c_add_driver(&rc5t583_i2c_driver); 374 + } 375 + subsys_initcall(rc5t583_i2c_init); 376 + 377 + static void __exit rc5t583_i2c_exit(void) 378 + { 379 + i2c_del_driver(&rc5t583_i2c_driver); 380 + } 381 + 382 + module_exit(rc5t583_i2c_exit); 383 + 384 + MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 385 + MODULE_DESCRIPTION("RICOH RC5T583 power management system device driver"); 386 + MODULE_LICENSE("GPL v2");
+45 -13
drivers/mfd/s5m-core.c
··· 26 26 #include <linux/mfd/s5m87xx/s5m-rtc.h> 27 27 #include <linux/regmap.h> 28 28 29 - static struct mfd_cell s5m87xx_devs[] = { 29 + static struct mfd_cell s5m8751_devs[] = { 30 + { 31 + .name = "s5m8751-pmic", 32 + }, { 33 + .name = "s5m-charger", 34 + }, { 35 + .name = "s5m8751-codec", 36 + }, 37 + }; 38 + 39 + static struct mfd_cell s5m8763_devs[] = { 40 + { 41 + .name = "s5m8763-pmic", 42 + }, { 43 + .name = "s5m-rtc", 44 + }, { 45 + .name = "s5m-charger", 46 + }, 47 + }; 48 + 49 + static struct mfd_cell s5m8767_devs[] = { 30 50 { 31 51 .name = "s5m8767-pmic", 32 52 }, { ··· 62 42 63 43 int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) 64 44 { 65 - return regmap_bulk_read(s5m87xx->regmap, reg, buf, count);; 45 + return regmap_bulk_read(s5m87xx->regmap, reg, buf, count); 66 46 } 67 47 EXPORT_SYMBOL_GPL(s5m_bulk_read); 68 48 ··· 74 54 75 55 int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) 76 56 { 77 - return regmap_raw_write(s5m87xx->regmap, reg, buf, count * sizeof(u16)); 57 + return regmap_raw_write(s5m87xx->regmap, reg, buf, count); 78 58 } 79 59 EXPORT_SYMBOL_GPL(s5m_bulk_write); 80 60 ··· 94 74 { 95 75 struct s5m_platform_data *pdata = i2c->dev.platform_data; 96 76 struct s5m87xx_dev *s5m87xx; 97 - int ret = 0; 98 - int error; 77 + int ret; 99 78 100 - s5m87xx = kzalloc(sizeof(struct s5m87xx_dev), GFP_KERNEL); 79 + s5m87xx = devm_kzalloc(&i2c->dev, sizeof(struct s5m87xx_dev), 80 + GFP_KERNEL); 101 81 if (s5m87xx == NULL) 102 82 return -ENOMEM; 103 83 ··· 116 96 117 97 s5m87xx->regmap = regmap_init_i2c(i2c, &s5m_regmap_config); 118 98 if (IS_ERR(s5m87xx->regmap)) { 119 - error = PTR_ERR(s5m87xx->regmap); 99 + ret = PTR_ERR(s5m87xx->regmap); 120 100 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 121 - error); 101 + ret); 122 102 goto err; 123 103 } 124 104 ··· 132 112 133 113 pm_runtime_set_active(s5m87xx->dev); 134 114 135 - ret = mfd_add_devices(s5m87xx->dev, -1, 136 - s5m87xx_devs, ARRAY_SIZE(s5m87xx_devs), 137 - NULL, 0); 115 + switch (s5m87xx->device_type) { 116 + case S5M8751X: 117 + ret = mfd_add_devices(s5m87xx->dev, -1, s5m8751_devs, 118 + ARRAY_SIZE(s5m8751_devs), NULL, 0); 119 + break; 120 + case S5M8763X: 121 + ret = mfd_add_devices(s5m87xx->dev, -1, s5m8763_devs, 122 + ARRAY_SIZE(s5m8763_devs), NULL, 0); 123 + break; 124 + case S5M8767X: 125 + ret = mfd_add_devices(s5m87xx->dev, -1, s5m8767_devs, 126 + ARRAY_SIZE(s5m8767_devs), NULL, 0); 127 + break; 128 + default: 129 + /* If this happens the probe function is problem */ 130 + BUG(); 131 + } 138 132 139 133 if (ret < 0) 140 134 goto err; ··· 160 126 s5m_irq_exit(s5m87xx); 161 127 i2c_unregister_device(s5m87xx->rtc); 162 128 regmap_exit(s5m87xx->regmap); 163 - kfree(s5m87xx); 164 129 return ret; 165 130 } 166 131 ··· 171 138 s5m_irq_exit(s5m87xx); 172 139 i2c_unregister_device(s5m87xx->rtc); 173 140 regmap_exit(s5m87xx->regmap); 174 - kfree(s5m87xx); 175 141 return 0; 176 142 } 177 143
+11 -3
drivers/mfd/s5m-irq.c
··· 342 342 s5m8767_irq_thread(s5m87xx->irq_base, s5m87xx); 343 343 break; 344 344 default: 345 - break; 345 + dev_err(s5m87xx->dev, 346 + "Unknown device type %d\n", 347 + s5m87xx->device_type); 348 + return -EINVAL; 346 349 347 350 } 348 351 } ··· 447 444 } 448 445 break; 449 446 default: 450 - break; 447 + dev_err(s5m87xx->dev, 448 + "Unknown device type %d\n", s5m87xx->device_type); 449 + return -EINVAL; 451 450 } 452 451 453 452 if (!s5m87xx->ono) ··· 472 467 IRQF_ONESHOT, "s5m87xx-ono", s5m87xx); 473 468 break; 474 469 default: 470 + ret = -EINVAL; 475 471 break; 476 472 } 477 473 478 - if (ret) 474 + if (ret) { 479 475 dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", 480 476 s5m87xx->ono, ret); 477 + return ret; 478 + } 481 479 482 480 return 0; 483 481 }
+1 -9
drivers/mfd/sm501.c
··· 387 387 388 388 EXPORT_SYMBOL_GPL(sm501_unit_power); 389 389 390 - 391 - /* Perform a rounded division. */ 392 - static long sm501fb_round_div(long num, long denom) 393 - { 394 - /* n / d + 1 / 2 = (2n + d) / 2d */ 395 - return (2 * num + denom) / (2 * denom); 396 - } 397 - 398 390 /* clock value structure. */ 399 391 struct sm501_clock { 400 392 unsigned long mclk; ··· 420 428 /* try all 8 shift values.*/ 421 429 for (shift = 0; shift < 8; shift++) { 422 430 /* Calculate difference to requested clock */ 423 - diff = sm501fb_round_div(mclk, divider << shift) - freq; 431 + diff = DIV_ROUND_CLOSEST(mclk, divider << shift) - freq; 424 432 if (diff < 0) 425 433 diff = -diff; 426 434
+96 -38
drivers/mfd/stmpe.c
··· 298 298 .num_resources = ARRAY_SIZE(stmpe_gpio_resources), 299 299 }; 300 300 301 + static struct mfd_cell stmpe_gpio_cell_noirq = { 302 + .name = "stmpe-gpio", 303 + /* gpio cell resources consist of an irq only so no resources here */ 304 + }; 305 + 301 306 /* 302 307 * Keypad (1601, 2401, 2403) 303 308 */ ··· 351 346 }, 352 347 }; 353 348 349 + static struct stmpe_variant_block stmpe801_blocks_noirq[] = { 350 + { 351 + .cell = &stmpe_gpio_cell_noirq, 352 + .block = STMPE_BLOCK_GPIO, 353 + }, 354 + }; 355 + 354 356 static int stmpe801_enable(struct stmpe *stmpe, unsigned int blocks, 355 357 bool enable) 356 358 { ··· 376 364 .blocks = stmpe801_blocks, 377 365 .num_blocks = ARRAY_SIZE(stmpe801_blocks), 378 366 .num_irqs = STMPE801_NR_INTERNAL_IRQS, 367 + .enable = stmpe801_enable, 368 + }; 369 + 370 + static struct stmpe_variant_info stmpe801_noirq = { 371 + .name = "stmpe801", 372 + .id_val = STMPE801_ID, 373 + .id_mask = 0xffff, 374 + .num_gpios = 8, 375 + .regs = stmpe801_regs, 376 + .blocks = stmpe801_blocks_noirq, 377 + .num_blocks = ARRAY_SIZE(stmpe801_blocks_noirq), 379 378 .enable = stmpe801_enable, 380 379 }; 381 380 ··· 735 712 .enable_autosleep = stmpe1601_autosleep, /* same as stmpe1601 */ 736 713 }; 737 714 738 - static struct stmpe_variant_info *stmpe_variant_info[] = { 715 + static struct stmpe_variant_info *stmpe_variant_info[STMPE_NBR_PARTS] = { 739 716 [STMPE610] = &stmpe610, 740 717 [STMPE801] = &stmpe801, 741 718 [STMPE811] = &stmpe811, 742 719 [STMPE1601] = &stmpe1601, 743 720 [STMPE2401] = &stmpe2401, 744 721 [STMPE2403] = &stmpe2403, 722 + }; 723 + 724 + /* 725 + * These devices can be connected in a 'no-irq' configuration - the irq pin 726 + * is not used and the device cannot interrupt the CPU. Here we only list 727 + * devices which support this configuration - the driver will fail probing 728 + * for any devices not listed here which are configured in this way. 729 + */ 730 + static struct stmpe_variant_info *stmpe_noirq_variant_info[STMPE_NBR_PARTS] = { 731 + [STMPE801] = &stmpe801_noirq, 745 732 }; 746 733 747 734 static irqreturn_t stmpe_irq(int irq, void *data) ··· 897 864 unsigned int irq_trigger = stmpe->pdata->irq_trigger; 898 865 int autosleep_timeout = stmpe->pdata->autosleep_timeout; 899 866 struct stmpe_variant_info *variant = stmpe->variant; 900 - u8 icr; 867 + u8 icr = 0; 901 868 unsigned int id; 902 869 u8 data[2]; 903 870 int ret; ··· 920 887 if (ret) 921 888 return ret; 922 889 923 - if (id == STMPE801_ID) 924 - icr = STMPE801_REG_SYS_CTRL_INT_EN; 925 - else 926 - icr = STMPE_ICR_LSB_GIM; 927 - 928 - /* STMPE801 doesn't support Edge interrupts */ 929 - if (id != STMPE801_ID) { 930 - if (irq_trigger == IRQF_TRIGGER_FALLING || 931 - irq_trigger == IRQF_TRIGGER_RISING) 932 - icr |= STMPE_ICR_LSB_EDGE; 933 - } 934 - 935 - if (irq_trigger == IRQF_TRIGGER_RISING || 936 - irq_trigger == IRQF_TRIGGER_HIGH) { 890 + if (stmpe->irq >= 0) { 937 891 if (id == STMPE801_ID) 938 - icr |= STMPE801_REG_SYS_CTRL_INT_HI; 892 + icr = STMPE801_REG_SYS_CTRL_INT_EN; 939 893 else 940 - icr |= STMPE_ICR_LSB_HIGH; 941 - } 894 + icr = STMPE_ICR_LSB_GIM; 942 895 943 - if (stmpe->pdata->irq_invert_polarity) { 944 - if (id == STMPE801_ID) 945 - icr ^= STMPE801_REG_SYS_CTRL_INT_HI; 946 - else 947 - icr ^= STMPE_ICR_LSB_HIGH; 896 + /* STMPE801 doesn't support Edge interrupts */ 897 + if (id != STMPE801_ID) { 898 + if (irq_trigger == IRQF_TRIGGER_FALLING || 899 + irq_trigger == IRQF_TRIGGER_RISING) 900 + icr |= STMPE_ICR_LSB_EDGE; 901 + } 902 + 903 + if (irq_trigger == IRQF_TRIGGER_RISING || 904 + irq_trigger == IRQF_TRIGGER_HIGH) { 905 + if (id == STMPE801_ID) 906 + icr |= STMPE801_REG_SYS_CTRL_INT_HI; 907 + else 908 + icr |= STMPE_ICR_LSB_HIGH; 909 + } 910 + 911 + if (stmpe->pdata->irq_invert_polarity) { 912 + if (id == STMPE801_ID) 913 + icr ^= STMPE801_REG_SYS_CTRL_INT_HI; 914 + else 915 + icr ^= STMPE_ICR_LSB_HIGH; 916 + } 948 917 } 949 918 950 919 if (stmpe->pdata->autosleep) { ··· 1036 1001 stmpe->irq = ci->irq; 1037 1002 } 1038 1003 1004 + if (stmpe->irq < 0) { 1005 + /* use alternate variant info for no-irq mode, if supported */ 1006 + dev_info(stmpe->dev, 1007 + "%s configured in no-irq mode by platform data\n", 1008 + stmpe->variant->name); 1009 + if (!stmpe_noirq_variant_info[stmpe->partnum]) { 1010 + dev_err(stmpe->dev, 1011 + "%s does not support no-irq mode!\n", 1012 + stmpe->variant->name); 1013 + ret = -ENODEV; 1014 + goto free_gpio; 1015 + } 1016 + stmpe->variant = stmpe_noirq_variant_info[stmpe->partnum]; 1017 + } 1018 + 1039 1019 ret = stmpe_chip_init(stmpe); 1040 1020 if (ret) 1041 1021 goto free_gpio; 1042 1022 1043 - ret = stmpe_irq_init(stmpe); 1044 - if (ret) 1045 - goto free_gpio; 1023 + if (stmpe->irq >= 0) { 1024 + ret = stmpe_irq_init(stmpe); 1025 + if (ret) 1026 + goto free_gpio; 1046 1027 1047 - ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq, 1048 - pdata->irq_trigger | IRQF_ONESHOT, "stmpe", stmpe); 1049 - if (ret) { 1050 - dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret); 1051 - goto out_removeirq; 1028 + ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq, 1029 + pdata->irq_trigger | IRQF_ONESHOT, 1030 + "stmpe", stmpe); 1031 + if (ret) { 1032 + dev_err(stmpe->dev, "failed to request IRQ: %d\n", 1033 + ret); 1034 + goto out_removeirq; 1035 + } 1052 1036 } 1053 1037 1054 1038 ret = stmpe_devices_init(stmpe); ··· 1080 1026 1081 1027 out_removedevs: 1082 1028 mfd_remove_devices(stmpe->dev); 1083 - free_irq(stmpe->irq, stmpe); 1029 + if (stmpe->irq >= 0) 1030 + free_irq(stmpe->irq, stmpe); 1084 1031 out_removeirq: 1085 - stmpe_irq_remove(stmpe); 1032 + if (stmpe->irq >= 0) 1033 + stmpe_irq_remove(stmpe); 1086 1034 free_gpio: 1087 1035 if (pdata->irq_over_gpio) 1088 1036 gpio_free(pdata->irq_gpio); ··· 1097 1041 { 1098 1042 mfd_remove_devices(stmpe->dev); 1099 1043 1100 - free_irq(stmpe->irq, stmpe); 1101 - stmpe_irq_remove(stmpe); 1044 + if (stmpe->irq >= 0) { 1045 + free_irq(stmpe->irq, stmpe); 1046 + stmpe_irq_remove(stmpe); 1047 + } 1102 1048 1103 1049 if (stmpe->pdata->irq_over_gpio) 1104 1050 gpio_free(stmpe->pdata->irq_gpio); ··· 1115 1057 { 1116 1058 struct stmpe *stmpe = dev_get_drvdata(dev); 1117 1059 1118 - if (device_may_wakeup(dev)) 1060 + if (stmpe->irq >= 0 && device_may_wakeup(dev)) 1119 1061 enable_irq_wake(stmpe->irq); 1120 1062 1121 1063 return 0; ··· 1125 1067 { 1126 1068 struct stmpe *stmpe = dev_get_drvdata(dev); 1127 1069 1128 - if (device_may_wakeup(dev)) 1070 + if (stmpe->irq >= 0 && device_may_wakeup(dev)) 1129 1071 disable_irq_wake(stmpe->irq); 1130 1072 1131 1073 return 0;
+387
drivers/mfd/tps65090.c
··· 1 + /* 2 + * Core driver for TI TPS65090 PMIC family 3 + * 4 + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. 5 + 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms and conditions of the GNU General Public License, 8 + * version 2, as published by the Free Software Foundation. 9 + 10 + * This program is distributed in the hope it will be useful, but WITHOUT 11 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 + * more details. 14 + 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 + */ 18 + 19 + #include <linux/interrupt.h> 20 + #include <linux/irq.h> 21 + #include <linux/kernel.h> 22 + #include <linux/module.h> 23 + #include <linux/mutex.h> 24 + #include <linux/slab.h> 25 + #include <linux/i2c.h> 26 + #include <linux/mfd/core.h> 27 + #include <linux/mfd/tps65090.h> 28 + #include <linux/regmap.h> 29 + #include <linux/err.h> 30 + 31 + #define NUM_INT_REG 2 32 + #define TOTAL_NUM_REG 0x18 33 + 34 + /* interrupt status registers */ 35 + #define TPS65090_INT_STS 0x0 36 + #define TPS65090_INT_STS2 0x1 37 + 38 + /* interrupt mask registers */ 39 + #define TPS65090_INT_MSK 0x2 40 + #define TPS65090_INT_MSK2 0x3 41 + 42 + struct tps65090_irq_data { 43 + u8 mask_reg; 44 + u8 mask_pos; 45 + }; 46 + 47 + #define TPS65090_IRQ(_reg, _mask_pos) \ 48 + { \ 49 + .mask_reg = (_reg), \ 50 + .mask_pos = (_mask_pos), \ 51 + } 52 + 53 + static const struct tps65090_irq_data tps65090_irqs[] = { 54 + [0] = TPS65090_IRQ(0, 0), 55 + [1] = TPS65090_IRQ(0, 1), 56 + [2] = TPS65090_IRQ(0, 2), 57 + [3] = TPS65090_IRQ(0, 3), 58 + [4] = TPS65090_IRQ(0, 4), 59 + [5] = TPS65090_IRQ(0, 5), 60 + [6] = TPS65090_IRQ(0, 6), 61 + [7] = TPS65090_IRQ(0, 7), 62 + [8] = TPS65090_IRQ(1, 0), 63 + [9] = TPS65090_IRQ(1, 1), 64 + [10] = TPS65090_IRQ(1, 2), 65 + [11] = TPS65090_IRQ(1, 3), 66 + [12] = TPS65090_IRQ(1, 4), 67 + [13] = TPS65090_IRQ(1, 5), 68 + [14] = TPS65090_IRQ(1, 6), 69 + [15] = TPS65090_IRQ(1, 7), 70 + }; 71 + 72 + static struct mfd_cell tps65090s[] = { 73 + { 74 + .name = "tps65910-pmic", 75 + }, 76 + { 77 + .name = "tps65910-regulator", 78 + }, 79 + }; 80 + 81 + struct tps65090 { 82 + struct mutex lock; 83 + struct device *dev; 84 + struct i2c_client *client; 85 + struct regmap *rmap; 86 + struct irq_chip irq_chip; 87 + struct mutex irq_lock; 88 + int irq_base; 89 + unsigned int id; 90 + }; 91 + 92 + int tps65090_write(struct device *dev, int reg, uint8_t val) 93 + { 94 + struct tps65090 *tps = dev_get_drvdata(dev); 95 + return regmap_write(tps->rmap, reg, val); 96 + } 97 + EXPORT_SYMBOL_GPL(tps65090_write); 98 + 99 + int tps65090_read(struct device *dev, int reg, uint8_t *val) 100 + { 101 + struct tps65090 *tps = dev_get_drvdata(dev); 102 + unsigned int temp_val; 103 + int ret; 104 + ret = regmap_read(tps->rmap, reg, &temp_val); 105 + if (!ret) 106 + *val = temp_val; 107 + return ret; 108 + } 109 + EXPORT_SYMBOL_GPL(tps65090_read); 110 + 111 + int tps65090_set_bits(struct device *dev, int reg, uint8_t bit_num) 112 + { 113 + struct tps65090 *tps = dev_get_drvdata(dev); 114 + return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u); 115 + } 116 + EXPORT_SYMBOL_GPL(tps65090_set_bits); 117 + 118 + int tps65090_clr_bits(struct device *dev, int reg, uint8_t bit_num) 119 + { 120 + struct tps65090 *tps = dev_get_drvdata(dev); 121 + return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u); 122 + } 123 + EXPORT_SYMBOL_GPL(tps65090_clr_bits); 124 + 125 + static void tps65090_irq_lock(struct irq_data *data) 126 + { 127 + struct tps65090 *tps65090 = irq_data_get_irq_chip_data(data); 128 + 129 + mutex_lock(&tps65090->irq_lock); 130 + } 131 + 132 + static void tps65090_irq_mask(struct irq_data *irq_data) 133 + { 134 + struct tps65090 *tps65090 = irq_data_get_irq_chip_data(irq_data); 135 + unsigned int __irq = irq_data->hwirq; 136 + const struct tps65090_irq_data *data = &tps65090_irqs[__irq]; 137 + 138 + tps65090_set_bits(tps65090->dev, (TPS65090_INT_MSK + data->mask_reg), 139 + data->mask_pos); 140 + } 141 + 142 + static void tps65090_irq_unmask(struct irq_data *irq_data) 143 + { 144 + struct tps65090 *tps65090 = irq_data_get_irq_chip_data(irq_data); 145 + unsigned int __irq = irq_data->irq - tps65090->irq_base; 146 + const struct tps65090_irq_data *data = &tps65090_irqs[__irq]; 147 + 148 + tps65090_clr_bits(tps65090->dev, (TPS65090_INT_MSK + data->mask_reg), 149 + data->mask_pos); 150 + } 151 + 152 + static void tps65090_irq_sync_unlock(struct irq_data *data) 153 + { 154 + struct tps65090 *tps65090 = irq_data_get_irq_chip_data(data); 155 + 156 + mutex_unlock(&tps65090->irq_lock); 157 + } 158 + 159 + static irqreturn_t tps65090_irq(int irq, void *data) 160 + { 161 + struct tps65090 *tps65090 = data; 162 + int ret = 0; 163 + u8 status, mask; 164 + unsigned long int acks = 0; 165 + int i; 166 + 167 + for (i = 0; i < NUM_INT_REG; i++) { 168 + ret = tps65090_read(tps65090->dev, TPS65090_INT_MSK + i, &mask); 169 + if (ret < 0) { 170 + dev_err(tps65090->dev, 171 + "failed to read mask reg [addr:%d]\n", 172 + TPS65090_INT_MSK + i); 173 + return IRQ_NONE; 174 + } 175 + ret = tps65090_read(tps65090->dev, TPS65090_INT_STS + i, 176 + &status); 177 + if (ret < 0) { 178 + dev_err(tps65090->dev, 179 + "failed to read status reg [addr:%d]\n", 180 + TPS65090_INT_STS + i); 181 + return IRQ_NONE; 182 + } 183 + if (status) { 184 + /* Ack only those interrupts which are not masked */ 185 + status &= (~mask); 186 + ret = tps65090_write(tps65090->dev, 187 + TPS65090_INT_STS + i, status); 188 + if (ret < 0) { 189 + dev_err(tps65090->dev, 190 + "failed to write interrupt status\n"); 191 + return IRQ_NONE; 192 + } 193 + acks |= (status << (i * 8)); 194 + } 195 + } 196 + 197 + for_each_set_bit(i, &acks, ARRAY_SIZE(tps65090_irqs)) 198 + handle_nested_irq(tps65090->irq_base + i); 199 + return acks ? IRQ_HANDLED : IRQ_NONE; 200 + } 201 + 202 + static int __devinit tps65090_irq_init(struct tps65090 *tps65090, int irq, 203 + int irq_base) 204 + { 205 + int i, ret; 206 + 207 + if (!irq_base) { 208 + dev_err(tps65090->dev, "IRQ base not set\n"); 209 + return -EINVAL; 210 + } 211 + 212 + mutex_init(&tps65090->irq_lock); 213 + 214 + for (i = 0; i < NUM_INT_REG; i++) 215 + tps65090_write(tps65090->dev, TPS65090_INT_MSK + i, 0xFF); 216 + 217 + for (i = 0; i < NUM_INT_REG; i++) 218 + tps65090_write(tps65090->dev, TPS65090_INT_STS + i, 0xff); 219 + 220 + tps65090->irq_base = irq_base; 221 + tps65090->irq_chip.name = "tps65090"; 222 + tps65090->irq_chip.irq_mask = tps65090_irq_mask; 223 + tps65090->irq_chip.irq_unmask = tps65090_irq_unmask; 224 + tps65090->irq_chip.irq_bus_lock = tps65090_irq_lock; 225 + tps65090->irq_chip.irq_bus_sync_unlock = tps65090_irq_sync_unlock; 226 + 227 + for (i = 0; i < ARRAY_SIZE(tps65090_irqs); i++) { 228 + int __irq = i + tps65090->irq_base; 229 + irq_set_chip_data(__irq, tps65090); 230 + irq_set_chip_and_handler(__irq, &tps65090->irq_chip, 231 + handle_simple_irq); 232 + irq_set_nested_thread(__irq, 1); 233 + #ifdef CONFIG_ARM 234 + set_irq_flags(__irq, IRQF_VALID); 235 + #endif 236 + } 237 + 238 + ret = request_threaded_irq(irq, NULL, tps65090_irq, IRQF_ONESHOT, 239 + "tps65090", tps65090); 240 + if (!ret) { 241 + device_init_wakeup(tps65090->dev, 1); 242 + enable_irq_wake(irq); 243 + } 244 + 245 + return ret; 246 + } 247 + 248 + static bool is_volatile_reg(struct device *dev, unsigned int reg) 249 + { 250 + if ((reg == TPS65090_INT_STS) || (reg == TPS65090_INT_STS)) 251 + return true; 252 + else 253 + return false; 254 + } 255 + 256 + static const struct regmap_config tps65090_regmap_config = { 257 + .reg_bits = 8, 258 + .val_bits = 8, 259 + .max_register = TOTAL_NUM_REG, 260 + .num_reg_defaults_raw = TOTAL_NUM_REG, 261 + .cache_type = REGCACHE_RBTREE, 262 + .volatile_reg = is_volatile_reg, 263 + }; 264 + 265 + static int __devinit tps65090_i2c_probe(struct i2c_client *client, 266 + const struct i2c_device_id *id) 267 + { 268 + struct tps65090_platform_data *pdata = client->dev.platform_data; 269 + struct tps65090 *tps65090; 270 + int ret; 271 + 272 + if (!pdata) { 273 + dev_err(&client->dev, "tps65090 requires platform data\n"); 274 + return -EINVAL; 275 + } 276 + 277 + tps65090 = devm_kzalloc(&client->dev, sizeof(struct tps65090), 278 + GFP_KERNEL); 279 + if (tps65090 == NULL) 280 + return -ENOMEM; 281 + 282 + tps65090->client = client; 283 + tps65090->dev = &client->dev; 284 + i2c_set_clientdata(client, tps65090); 285 + 286 + mutex_init(&tps65090->lock); 287 + 288 + if (client->irq) { 289 + ret = tps65090_irq_init(tps65090, client->irq, pdata->irq_base); 290 + if (ret) { 291 + dev_err(&client->dev, "IRQ init failed with err: %d\n", 292 + ret); 293 + goto err_exit; 294 + } 295 + } 296 + 297 + tps65090->rmap = regmap_init_i2c(tps65090->client, 298 + &tps65090_regmap_config); 299 + if (IS_ERR(tps65090->rmap)) { 300 + dev_err(&client->dev, "regmap_init failed with err: %ld\n", 301 + PTR_ERR(tps65090->rmap)); 302 + goto err_irq_exit; 303 + }; 304 + 305 + ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 306 + ARRAY_SIZE(tps65090s), NULL, 0); 307 + if (ret) { 308 + dev_err(&client->dev, "add mfd devices failed with err: %d\n", 309 + ret); 310 + goto err_regmap_exit; 311 + } 312 + 313 + return 0; 314 + 315 + err_regmap_exit: 316 + regmap_exit(tps65090->rmap); 317 + 318 + err_irq_exit: 319 + if (client->irq) 320 + free_irq(client->irq, tps65090); 321 + err_exit: 322 + return ret; 323 + } 324 + 325 + static int __devexit tps65090_i2c_remove(struct i2c_client *client) 326 + { 327 + struct tps65090 *tps65090 = i2c_get_clientdata(client); 328 + 329 + mfd_remove_devices(tps65090->dev); 330 + regmap_exit(tps65090->rmap); 331 + if (client->irq) 332 + free_irq(client->irq, tps65090); 333 + 334 + return 0; 335 + } 336 + 337 + #ifdef CONFIG_PM 338 + static int tps65090_i2c_suspend(struct i2c_client *client, pm_message_t state) 339 + { 340 + if (client->irq) 341 + disable_irq(client->irq); 342 + return 0; 343 + } 344 + 345 + static int tps65090_i2c_resume(struct i2c_client *client) 346 + { 347 + if (client->irq) 348 + enable_irq(client->irq); 349 + return 0; 350 + } 351 + #endif 352 + 353 + static const struct i2c_device_id tps65090_id_table[] = { 354 + { "tps65090", 0 }, 355 + { }, 356 + }; 357 + MODULE_DEVICE_TABLE(i2c, tps65090_id_table); 358 + 359 + static struct i2c_driver tps65090_driver = { 360 + .driver = { 361 + .name = "tps65090", 362 + .owner = THIS_MODULE, 363 + }, 364 + .probe = tps65090_i2c_probe, 365 + .remove = __devexit_p(tps65090_i2c_remove), 366 + #ifdef CONFIG_PM 367 + .suspend = tps65090_i2c_suspend, 368 + .resume = tps65090_i2c_resume, 369 + #endif 370 + .id_table = tps65090_id_table, 371 + }; 372 + 373 + static int __init tps65090_init(void) 374 + { 375 + return i2c_add_driver(&tps65090_driver); 376 + } 377 + subsys_initcall(tps65090_init); 378 + 379 + static void __exit tps65090_exit(void) 380 + { 381 + i2c_del_driver(&tps65090_driver); 382 + } 383 + module_exit(tps65090_exit); 384 + 385 + MODULE_DESCRIPTION("TPS65090 core driver"); 386 + MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@nvidia.com>"); 387 + MODULE_LICENSE("GPL v2");
+242
drivers/mfd/tps65217.c
··· 1 + /* 2 + * tps65217.c 3 + * 4 + * TPS65217 chip family multi-function driver 5 + * 6 + * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License as 10 + * published by the Free Software Foundation version 2. 11 + * 12 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 13 + * kind, whether express or implied; without even the implied warranty 14 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + */ 17 + 18 + #include <linux/kernel.h> 19 + #include <linux/device.h> 20 + #include <linux/module.h> 21 + #include <linux/platform_device.h> 22 + #include <linux/init.h> 23 + #include <linux/i2c.h> 24 + #include <linux/slab.h> 25 + #include <linux/regmap.h> 26 + #include <linux/err.h> 27 + 28 + #include <linux/mfd/core.h> 29 + #include <linux/mfd/tps65217.h> 30 + 31 + /** 32 + * tps65217_reg_read: Read a single tps65217 register. 33 + * 34 + * @tps: Device to read from. 35 + * @reg: Register to read. 36 + * @val: Contians the value 37 + */ 38 + int tps65217_reg_read(struct tps65217 *tps, unsigned int reg, 39 + unsigned int *val) 40 + { 41 + return regmap_read(tps->regmap, reg, val); 42 + } 43 + EXPORT_SYMBOL_GPL(tps65217_reg_read); 44 + 45 + /** 46 + * tps65217_reg_write: Write a single tps65217 register. 47 + * 48 + * @tps65217: Device to write to. 49 + * @reg: Register to write to. 50 + * @val: Value to write. 51 + * @level: Password protected level 52 + */ 53 + int tps65217_reg_write(struct tps65217 *tps, unsigned int reg, 54 + unsigned int val, unsigned int level) 55 + { 56 + int ret; 57 + unsigned int xor_reg_val; 58 + 59 + switch (level) { 60 + case TPS65217_PROTECT_NONE: 61 + return regmap_write(tps->regmap, reg, val); 62 + case TPS65217_PROTECT_L1: 63 + xor_reg_val = reg ^ TPS65217_PASSWORD_REGS_UNLOCK; 64 + ret = regmap_write(tps->regmap, TPS65217_REG_PASSWORD, 65 + xor_reg_val); 66 + if (ret < 0) 67 + return ret; 68 + 69 + return regmap_write(tps->regmap, reg, val); 70 + case TPS65217_PROTECT_L2: 71 + xor_reg_val = reg ^ TPS65217_PASSWORD_REGS_UNLOCK; 72 + ret = regmap_write(tps->regmap, TPS65217_REG_PASSWORD, 73 + xor_reg_val); 74 + if (ret < 0) 75 + return ret; 76 + ret = regmap_write(tps->regmap, reg, val); 77 + if (ret < 0) 78 + return ret; 79 + ret = regmap_write(tps->regmap, TPS65217_REG_PASSWORD, 80 + xor_reg_val); 81 + if (ret < 0) 82 + return ret; 83 + return regmap_write(tps->regmap, reg, val); 84 + default: 85 + return -EINVAL; 86 + } 87 + } 88 + EXPORT_SYMBOL_GPL(tps65217_reg_write); 89 + 90 + /** 91 + * tps65217_update_bits: Modify bits w.r.t mask, val and level. 92 + * 93 + * @tps65217: Device to write to. 94 + * @reg: Register to read-write to. 95 + * @mask: Mask. 96 + * @val: Value to write. 97 + * @level: Password protected level 98 + */ 99 + int tps65217_update_bits(struct tps65217 *tps, unsigned int reg, 100 + unsigned int mask, unsigned int val, unsigned int level) 101 + { 102 + int ret; 103 + unsigned int data; 104 + 105 + ret = tps65217_reg_read(tps, reg, &data); 106 + if (ret) { 107 + dev_err(tps->dev, "Read from reg 0x%x failed\n", reg); 108 + return ret; 109 + } 110 + 111 + data &= ~mask; 112 + data |= val & mask; 113 + 114 + ret = tps65217_reg_write(tps, reg, data, level); 115 + if (ret) 116 + dev_err(tps->dev, "Write for reg 0x%x failed\n", reg); 117 + 118 + return ret; 119 + } 120 + 121 + int tps65217_set_bits(struct tps65217 *tps, unsigned int reg, 122 + unsigned int mask, unsigned int val, unsigned int level) 123 + { 124 + return tps65217_update_bits(tps, reg, mask, val, level); 125 + } 126 + EXPORT_SYMBOL_GPL(tps65217_set_bits); 127 + 128 + int tps65217_clear_bits(struct tps65217 *tps, unsigned int reg, 129 + unsigned int mask, unsigned int level) 130 + { 131 + return tps65217_update_bits(tps, reg, mask, 0, level); 132 + } 133 + EXPORT_SYMBOL_GPL(tps65217_clear_bits); 134 + 135 + static struct regmap_config tps65217_regmap_config = { 136 + .reg_bits = 8, 137 + .val_bits = 8, 138 + }; 139 + 140 + static int __devinit tps65217_probe(struct i2c_client *client, 141 + const struct i2c_device_id *ids) 142 + { 143 + struct tps65217 *tps; 144 + struct tps65217_board *pdata = client->dev.platform_data; 145 + int i, ret; 146 + unsigned int version; 147 + 148 + tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 149 + if (!tps) 150 + return -ENOMEM; 151 + 152 + tps->pdata = pdata; 153 + tps->regmap = regmap_init_i2c(client, &tps65217_regmap_config); 154 + if (IS_ERR(tps->regmap)) { 155 + ret = PTR_ERR(tps->regmap); 156 + dev_err(tps->dev, "Failed to allocate register map: %d\n", 157 + ret); 158 + return ret; 159 + } 160 + 161 + i2c_set_clientdata(client, tps); 162 + tps->dev = &client->dev; 163 + 164 + ret = tps65217_reg_read(tps, TPS65217_REG_CHIPID, &version); 165 + if (ret < 0) { 166 + dev_err(tps->dev, "Failed to read revision" 167 + " register: %d\n", ret); 168 + goto err_regmap; 169 + } 170 + 171 + dev_info(tps->dev, "TPS65217 ID %#x version 1.%d\n", 172 + (version & TPS65217_CHIPID_CHIP_MASK) >> 4, 173 + version & TPS65217_CHIPID_REV_MASK); 174 + 175 + for (i = 0; i < TPS65217_NUM_REGULATOR; i++) { 176 + struct platform_device *pdev; 177 + 178 + pdev = platform_device_alloc("tps65217-pmic", i); 179 + if (!pdev) { 180 + dev_err(tps->dev, "Cannot create regulator %d\n", i); 181 + continue; 182 + } 183 + 184 + pdev->dev.parent = tps->dev; 185 + platform_device_add_data(pdev, &pdata->tps65217_init_data[i], 186 + sizeof(pdata->tps65217_init_data[i])); 187 + tps->regulator_pdev[i] = pdev; 188 + 189 + platform_device_add(pdev); 190 + } 191 + 192 + return 0; 193 + 194 + err_regmap: 195 + regmap_exit(tps->regmap); 196 + 197 + return ret; 198 + } 199 + 200 + static int __devexit tps65217_remove(struct i2c_client *client) 201 + { 202 + struct tps65217 *tps = i2c_get_clientdata(client); 203 + int i; 204 + 205 + for (i = 0; i < TPS65217_NUM_REGULATOR; i++) 206 + platform_device_unregister(tps->regulator_pdev[i]); 207 + 208 + regmap_exit(tps->regmap); 209 + 210 + return 0; 211 + } 212 + 213 + static const struct i2c_device_id tps65217_id_table[] = { 214 + {"tps65217", 0xF0}, 215 + {/* end of list */} 216 + }; 217 + MODULE_DEVICE_TABLE(i2c, tps65217_id_table); 218 + 219 + static struct i2c_driver tps65217_driver = { 220 + .driver = { 221 + .name = "tps65217", 222 + }, 223 + .id_table = tps65217_id_table, 224 + .probe = tps65217_probe, 225 + .remove = __devexit_p(tps65217_remove), 226 + }; 227 + 228 + static int __init tps65217_init(void) 229 + { 230 + return i2c_add_driver(&tps65217_driver); 231 + } 232 + subsys_initcall(tps65217_init); 233 + 234 + static void __exit tps65217_exit(void) 235 + { 236 + i2c_del_driver(&tps65217_driver); 237 + } 238 + module_exit(tps65217_exit); 239 + 240 + MODULE_AUTHOR("AnilKumar Ch <anilkumar@ti.com>"); 241 + MODULE_DESCRIPTION("TPS65217 chip family multi-function driver"); 242 + MODULE_LICENSE("GPL v2");
+11
drivers/mfd/tps65910-irq.c
··· 145 145 tps65910->irq_mask |= ( 1 << irq_to_tps65910_irq(tps65910, data->irq)); 146 146 } 147 147 148 + #ifdef CONFIG_PM_SLEEP 149 + static int tps65910_irq_set_wake(struct irq_data *data, unsigned int enable) 150 + { 151 + struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); 152 + return irq_set_irq_wake(tps65910->chip_irq, enable); 153 + } 154 + #else 155 + #define tps65910_irq_set_wake NULL 156 + #endif 157 + 148 158 static struct irq_chip tps65910_irq_chip = { 149 159 .name = "tps65910", 150 160 .irq_bus_lock = tps65910_irq_lock, 151 161 .irq_bus_sync_unlock = tps65910_irq_sync_unlock, 152 162 .irq_disable = tps65910_irq_disable, 153 163 .irq_enable = tps65910_irq_enable, 164 + .irq_set_wake = tps65910_irq_set_wake, 154 165 }; 155 166 156 167 int tps65910_irq_init(struct tps65910 *tps65910, int irq,
+46 -77
drivers/mfd/tps65910.c
··· 16 16 #include <linux/module.h> 17 17 #include <linux/moduleparam.h> 18 18 #include <linux/init.h> 19 + #include <linux/err.h> 19 20 #include <linux/slab.h> 20 21 #include <linux/i2c.h> 21 22 #include <linux/gpio.h> 22 23 #include <linux/mfd/core.h> 24 + #include <linux/regmap.h> 23 25 #include <linux/mfd/tps65910.h> 24 26 25 27 static struct mfd_cell tps65910s[] = { ··· 40 38 static int tps65910_i2c_read(struct tps65910 *tps65910, u8 reg, 41 39 int bytes, void *dest) 42 40 { 43 - struct i2c_client *i2c = tps65910->i2c_client; 44 - struct i2c_msg xfer[2]; 45 - int ret; 46 - 47 - /* Write register */ 48 - xfer[0].addr = i2c->addr; 49 - xfer[0].flags = 0; 50 - xfer[0].len = 1; 51 - xfer[0].buf = &reg; 52 - 53 - /* Read data */ 54 - xfer[1].addr = i2c->addr; 55 - xfer[1].flags = I2C_M_RD; 56 - xfer[1].len = bytes; 57 - xfer[1].buf = dest; 58 - 59 - ret = i2c_transfer(i2c->adapter, xfer, 2); 60 - if (ret == 2) 61 - ret = 0; 62 - else if (ret >= 0) 63 - ret = -EIO; 64 - 65 - return ret; 41 + return regmap_bulk_read(tps65910->regmap, reg, dest, bytes); 66 42 } 67 43 68 44 static int tps65910_i2c_write(struct tps65910 *tps65910, u8 reg, 69 - int bytes, void *src) 45 + int bytes, void *src) 70 46 { 71 - struct i2c_client *i2c = tps65910->i2c_client; 72 - /* we add 1 byte for device register */ 73 - u8 msg[TPS65910_MAX_REGISTER + 1]; 74 - int ret; 75 - 76 - if (bytes > TPS65910_MAX_REGISTER) 77 - return -EINVAL; 78 - 79 - msg[0] = reg; 80 - memcpy(&msg[1], src, bytes); 81 - 82 - ret = i2c_master_send(i2c, msg, bytes + 1); 83 - if (ret < 0) 84 - return ret; 85 - if (ret != bytes + 1) 86 - return -EIO; 87 - return 0; 47 + return regmap_bulk_write(tps65910->regmap, reg, src, bytes); 88 48 } 89 49 90 50 int tps65910_set_bits(struct tps65910 *tps65910, u8 reg, u8 mask) 91 51 { 92 - u8 data; 93 - int err; 94 - 95 - mutex_lock(&tps65910->io_mutex); 96 - err = tps65910_i2c_read(tps65910, reg, 1, &data); 97 - if (err) { 98 - dev_err(tps65910->dev, "read from reg %x failed\n", reg); 99 - goto out; 100 - } 101 - 102 - data |= mask; 103 - err = tps65910_i2c_write(tps65910, reg, 1, &data); 104 - if (err) 105 - dev_err(tps65910->dev, "write to reg %x failed\n", reg); 106 - 107 - out: 108 - mutex_unlock(&tps65910->io_mutex); 109 - return err; 52 + return regmap_update_bits(tps65910->regmap, reg, mask, mask); 110 53 } 111 54 EXPORT_SYMBOL_GPL(tps65910_set_bits); 112 55 113 56 int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask) 114 57 { 115 - u8 data; 116 - int err; 117 - 118 - mutex_lock(&tps65910->io_mutex); 119 - err = tps65910_i2c_read(tps65910, reg, 1, &data); 120 - if (err) { 121 - dev_err(tps65910->dev, "read from reg %x failed\n", reg); 122 - goto out; 123 - } 124 - 125 - data &= ~mask; 126 - err = tps65910_i2c_write(tps65910, reg, 1, &data); 127 - if (err) 128 - dev_err(tps65910->dev, "write to reg %x failed\n", reg); 129 - 130 - out: 131 - mutex_unlock(&tps65910->io_mutex); 132 - return err; 58 + return regmap_update_bits(tps65910->regmap, reg, mask, 0); 133 59 } 134 60 EXPORT_SYMBOL_GPL(tps65910_clear_bits); 61 + 62 + static bool is_volatile_reg(struct device *dev, unsigned int reg) 63 + { 64 + struct tps65910 *tps65910 = dev_get_drvdata(dev); 65 + 66 + /* 67 + * Caching all regulator registers. 68 + * All regualator register address range is same for 69 + * TPS65910 and TPS65911 70 + */ 71 + if ((reg >= TPS65910_VIO) && (reg <= TPS65910_VDAC)) { 72 + /* Check for non-existing register */ 73 + if (tps65910_chip_id(tps65910) == TPS65910) 74 + if ((reg == TPS65911_VDDCTRL_OP) || 75 + (reg == TPS65911_VDDCTRL_SR)) 76 + return true; 77 + return false; 78 + } 79 + return true; 80 + } 81 + 82 + static const struct regmap_config tps65910_regmap_config = { 83 + .reg_bits = 8, 84 + .val_bits = 8, 85 + .volatile_reg = is_volatile_reg, 86 + .max_register = TPS65910_MAX_REGISTER, 87 + .num_reg_defaults_raw = TPS65910_MAX_REGISTER, 88 + .cache_type = REGCACHE_RBTREE, 89 + }; 135 90 136 91 static int tps65910_i2c_probe(struct i2c_client *i2c, 137 92 const struct i2c_device_id *id) ··· 120 161 tps65910->write = tps65910_i2c_write; 121 162 mutex_init(&tps65910->io_mutex); 122 163 164 + tps65910->regmap = regmap_init_i2c(i2c, &tps65910_regmap_config); 165 + if (IS_ERR(tps65910->regmap)) { 166 + ret = PTR_ERR(tps65910->regmap); 167 + dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); 168 + goto regmap_err; 169 + } 170 + 123 171 ret = mfd_add_devices(tps65910->dev, -1, 124 172 tps65910s, ARRAY_SIZE(tps65910s), 125 173 NULL, 0); ··· 144 178 return ret; 145 179 146 180 err: 181 + regmap_exit(tps65910->regmap); 182 + regmap_err: 147 183 kfree(tps65910); 148 184 kfree(init_data); 149 185 return ret; ··· 157 189 158 190 tps65910_irq_exit(tps65910); 159 191 mfd_remove_devices(tps65910->dev); 192 + regmap_exit(tps65910->regmap); 160 193 kfree(tps65910); 161 194 162 195 return 0;
+69 -84
drivers/mfd/twl-core.c
··· 46 46 #include <linux/i2c.h> 47 47 #include <linux/i2c/twl.h> 48 48 49 - #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 50 - #include <plat/cpu.h> 51 - #endif 49 + #include "twl-core.h" 52 50 53 51 /* 54 52 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power ··· 114 116 #define twl_has_watchdog() false 115 117 #endif 116 118 117 - #if defined(CONFIG_MFD_TWL4030_AUDIO) || defined(CONFIG_MFD_TWL4030_AUDIO_MODULE) ||\ 118 - defined(CONFIG_TWL6040_CORE) || defined(CONFIG_TWL6040_CORE_MODULE) 119 + #if defined(CONFIG_MFD_TWL4030_AUDIO) || \ 120 + defined(CONFIG_MFD_TWL4030_AUDIO_MODULE) 119 121 #define twl_has_codec() true 120 122 #else 121 123 #define twl_has_codec() false ··· 145 147 #define SUB_CHIP_ID1 1 146 148 #define SUB_CHIP_ID2 2 147 149 #define SUB_CHIP_ID3 3 150 + #define SUB_CHIP_ID_INVAL 0xff 148 151 149 152 #define TWL_MODULE_LAST TWL4030_MODULE_LAST 150 - 151 - #define TWL4030_NR_IRQS 34 /* core:8, power:8, gpio: 18 */ 152 - #define TWL6030_NR_IRQS 20 153 153 154 154 /* Base Address defns for twl4030_map[] */ 155 155 ··· 310 314 * so they continue to match the order in this table. 311 315 */ 312 316 { SUB_CHIP_ID1, TWL6030_BASEADD_USB }, 313 - { SUB_CHIP_ID3, TWL6030_BASEADD_AUDIO }, 317 + { SUB_CHIP_ID_INVAL, TWL6030_BASEADD_AUDIO }, 314 318 { SUB_CHIP_ID2, TWL6030_BASEADD_DIEID }, 315 319 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 316 320 { SUB_CHIP_ID1, TWL6030_BASEADD_PIH }, ··· 372 376 return -EPERM; 373 377 } 374 378 sid = twl_map[mod_no].sid; 379 + if (unlikely(sid == SUB_CHIP_ID_INVAL)) { 380 + pr_err("%s: module %d is not part of the pmic\n", 381 + DRIVER_NAME, mod_no); 382 + return -EINVAL; 383 + } 375 384 twl = &twl_modules[sid]; 376 385 377 386 mutex_lock(&twl->xfer_lock); ··· 434 433 return -EPERM; 435 434 } 436 435 sid = twl_map[mod_no].sid; 436 + if (unlikely(sid == SUB_CHIP_ID_INVAL)) { 437 + pr_err("%s: module %d is not part of the pmic\n", 438 + DRIVER_NAME, mod_no); 439 + return -EINVAL; 440 + } 437 441 twl = &twl_modules[sid]; 438 442 439 443 mutex_lock(&twl->xfer_lock); ··· 669 663 */ 670 664 671 665 static int 672 - add_children(struct twl4030_platform_data *pdata, unsigned long features) 666 + add_children(struct twl4030_platform_data *pdata, unsigned irq_base, 667 + unsigned long features) 673 668 { 674 669 struct device *child; 675 670 unsigned sub_chip_id; ··· 678 671 if (twl_has_gpio() && pdata->gpio) { 679 672 child = add_child(SUB_CHIP_ID1, "twl4030_gpio", 680 673 pdata->gpio, sizeof(*pdata->gpio), 681 - false, pdata->irq_base + GPIO_INTR_OFFSET, 0); 674 + false, irq_base + GPIO_INTR_OFFSET, 0); 682 675 if (IS_ERR(child)) 683 676 return PTR_ERR(child); 684 677 } ··· 686 679 if (twl_has_keypad() && pdata->keypad) { 687 680 child = add_child(SUB_CHIP_ID2, "twl4030_keypad", 688 681 pdata->keypad, sizeof(*pdata->keypad), 689 - true, pdata->irq_base + KEYPAD_INTR_OFFSET, 0); 682 + true, irq_base + KEYPAD_INTR_OFFSET, 0); 690 683 if (IS_ERR(child)) 691 684 return PTR_ERR(child); 692 685 } ··· 694 687 if (twl_has_madc() && pdata->madc) { 695 688 child = add_child(2, "twl4030_madc", 696 689 pdata->madc, sizeof(*pdata->madc), 697 - true, pdata->irq_base + MADC_INTR_OFFSET, 0); 690 + true, irq_base + MADC_INTR_OFFSET, 0); 698 691 if (IS_ERR(child)) 699 692 return PTR_ERR(child); 700 693 } ··· 710 703 sub_chip_id = twl_map[TWL_MODULE_RTC].sid; 711 704 child = add_child(sub_chip_id, "twl_rtc", 712 705 NULL, 0, 713 - true, pdata->irq_base + RTC_INTR_OFFSET, 0); 706 + true, irq_base + RTC_INTR_OFFSET, 0); 714 707 if (IS_ERR(child)) 715 708 return PTR_ERR(child); 716 709 } ··· 763 756 pdata->usb, sizeof(*pdata->usb), 764 757 true, 765 758 /* irq0 = USB_PRES, irq1 = USB */ 766 - pdata->irq_base + USB_PRES_INTR_OFFSET, 767 - pdata->irq_base + USB_INTR_OFFSET); 759 + irq_base + USB_PRES_INTR_OFFSET, 760 + irq_base + USB_INTR_OFFSET); 768 761 769 762 if (IS_ERR(child)) 770 763 return PTR_ERR(child); ··· 812 805 pdata->usb, sizeof(*pdata->usb), 813 806 true, 814 807 /* irq1 = VBUS_PRES, irq0 = USB ID */ 815 - pdata->irq_base + USBOTG_INTR_OFFSET, 816 - pdata->irq_base + USB_PRES_INTR_OFFSET); 808 + irq_base + USBOTG_INTR_OFFSET, 809 + irq_base + USB_PRES_INTR_OFFSET); 817 810 818 811 if (IS_ERR(child)) 819 812 return PTR_ERR(child); ··· 840 833 841 834 if (twl_has_pwrbutton() && twl_class_is_4030()) { 842 835 child = add_child(1, "twl4030_pwrbutton", 843 - NULL, 0, true, pdata->irq_base + 8 + 0, 0); 836 + NULL, 0, true, irq_base + 8 + 0, 0); 844 837 if (IS_ERR(child)) 845 838 return PTR_ERR(child); 846 839 } ··· 848 841 if (twl_has_codec() && pdata->audio && twl_class_is_4030()) { 849 842 sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid; 850 843 child = add_child(sub_chip_id, "twl4030-audio", 851 - pdata->audio, sizeof(*pdata->audio), 852 - false, 0, 0); 853 - if (IS_ERR(child)) 854 - return PTR_ERR(child); 855 - } 856 - 857 - if (twl_has_codec() && pdata->audio && twl_class_is_6030()) { 858 - sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid; 859 - child = add_child(sub_chip_id, "twl6040", 860 844 pdata->audio, sizeof(*pdata->audio), 861 845 false, 0, 0); 862 846 if (IS_ERR(child)) ··· 1090 1092 child = add_child(3, "twl4030_bci", 1091 1093 pdata->bci, sizeof(*pdata->bci), false, 1092 1094 /* irq0 = CHG_PRES, irq1 = BCI */ 1093 - pdata->irq_base + BCI_PRES_INTR_OFFSET, 1094 - pdata->irq_base + BCI_INTR_OFFSET); 1095 + irq_base + BCI_PRES_INTR_OFFSET, 1096 + irq_base + BCI_INTR_OFFSET); 1095 1097 if (IS_ERR(child)) 1096 1098 return PTR_ERR(child); 1097 1099 } ··· 1191 1193 1192 1194 /*----------------------------------------------------------------------*/ 1193 1195 1194 - int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end); 1195 - int twl4030_exit_irq(void); 1196 - int twl4030_init_chip_irq(const char *chip); 1197 - int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end); 1198 - int twl6030_exit_irq(void); 1199 1196 1200 1197 static int twl_remove(struct i2c_client *client) 1201 1198 { 1202 - unsigned i; 1199 + unsigned i, num_slaves; 1203 1200 int status; 1204 1201 1205 - if (twl_class_is_4030()) 1202 + if (twl_class_is_4030()) { 1206 1203 status = twl4030_exit_irq(); 1207 - else 1204 + num_slaves = TWL_NUM_SLAVES; 1205 + } else { 1208 1206 status = twl6030_exit_irq(); 1207 + num_slaves = TWL_NUM_SLAVES - 1; 1208 + } 1209 1209 1210 1210 if (status < 0) 1211 1211 return status; 1212 1212 1213 - for (i = 0; i < TWL_NUM_SLAVES; i++) { 1213 + for (i = 0; i < num_slaves; i++) { 1214 1214 struct twl_client *twl = &twl_modules[i]; 1215 1215 1216 1216 if (twl->client && twl->client != client) ··· 1219 1223 return 0; 1220 1224 } 1221 1225 1222 - /* NOTE: this driver only handles a single twl4030/tps659x0 chip */ 1226 + /* NOTE: This driver only handles a single twl4030/tps659x0 chip */ 1223 1227 static int __devinit 1224 1228 twl_probe(struct i2c_client *client, const struct i2c_device_id *id) 1225 1229 { 1226 - int status; 1227 - unsigned i; 1228 1230 struct twl4030_platform_data *pdata = client->dev.platform_data; 1229 1231 struct device_node *node = client->dev.of_node; 1230 - u8 temp; 1231 - int ret = 0; 1232 - int nr_irqs = TWL4030_NR_IRQS; 1233 - 1234 - if ((id->driver_data) & TWL6030_CLASS) 1235 - nr_irqs = TWL6030_NR_IRQS; 1232 + int irq_base = 0; 1233 + int status; 1234 + unsigned i, num_slaves; 1236 1235 1237 1236 if (node && !pdata) { 1238 1237 /* ··· 1246 1255 return -EINVAL; 1247 1256 } 1248 1257 1249 - status = irq_alloc_descs(-1, pdata->irq_base, nr_irqs, 0); 1250 - if (IS_ERR_VALUE(status)) { 1251 - dev_err(&client->dev, "Fail to allocate IRQ descs\n"); 1252 - return status; 1253 - } 1254 - 1255 - pdata->irq_base = status; 1256 - pdata->irq_end = pdata->irq_base + nr_irqs; 1257 - irq_domain_add_legacy(node, nr_irqs, pdata->irq_base, 0, 1258 - &irq_domain_simple_ops, NULL); 1259 - 1260 1258 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { 1261 1259 dev_dbg(&client->dev, "can't talk I2C?\n"); 1262 1260 return -EIO; ··· 1256 1276 return -EBUSY; 1257 1277 } 1258 1278 1259 - for (i = 0; i < TWL_NUM_SLAVES; i++) { 1260 - struct twl_client *twl = &twl_modules[i]; 1279 + if ((id->driver_data) & TWL6030_CLASS) { 1280 + twl_id = TWL6030_CLASS_ID; 1281 + twl_map = &twl6030_map[0]; 1282 + num_slaves = TWL_NUM_SLAVES - 1; 1283 + } else { 1284 + twl_id = TWL4030_CLASS_ID; 1285 + twl_map = &twl4030_map[0]; 1286 + num_slaves = TWL_NUM_SLAVES; 1287 + } 1288 + 1289 + for (i = 0; i < num_slaves; i++) { 1290 + struct twl_client *twl = &twl_modules[i]; 1261 1291 1262 1292 twl->address = client->addr + i; 1263 - if (i == 0) 1293 + if (i == 0) { 1264 1294 twl->client = client; 1265 - else { 1295 + } else { 1266 1296 twl->client = i2c_new_dummy(client->adapter, 1267 1297 twl->address); 1268 1298 if (!twl->client) { ··· 1284 1294 } 1285 1295 mutex_init(&twl->xfer_lock); 1286 1296 } 1297 + 1287 1298 inuse = true; 1288 - if ((id->driver_data) & TWL6030_CLASS) { 1289 - twl_id = TWL6030_CLASS_ID; 1290 - twl_map = &twl6030_map[0]; 1291 - } else { 1292 - twl_id = TWL4030_CLASS_ID; 1293 - twl_map = &twl4030_map[0]; 1294 - } 1295 1299 1296 1300 /* setup clock framework */ 1297 1301 clocks_init(&client->dev, pdata->clock); 1298 1302 1299 1303 /* read TWL IDCODE Register */ 1300 1304 if (twl_id == TWL4030_CLASS_ID) { 1301 - ret = twl_read_idcode_register(); 1302 - WARN(ret < 0, "Error: reading twl_idcode register value\n"); 1305 + status = twl_read_idcode_register(); 1306 + WARN(status < 0, "Error: reading twl_idcode register value\n"); 1303 1307 } 1304 1308 1305 1309 /* load power event scripts */ ··· 1301 1317 twl4030_power_init(pdata->power); 1302 1318 1303 1319 /* Maybe init the T2 Interrupt subsystem */ 1304 - if (client->irq 1305 - && pdata->irq_base 1306 - && pdata->irq_end > pdata->irq_base) { 1320 + if (client->irq) { 1307 1321 if (twl_class_is_4030()) { 1308 1322 twl4030_init_chip_irq(id->name); 1309 - status = twl4030_init_irq(client->irq, pdata->irq_base, 1310 - pdata->irq_end); 1323 + irq_base = twl4030_init_irq(&client->dev, client->irq); 1311 1324 } else { 1312 - status = twl6030_init_irq(client->irq, pdata->irq_base, 1313 - pdata->irq_end); 1325 + irq_base = twl6030_init_irq(&client->dev, client->irq); 1314 1326 } 1315 1327 1316 - if (status < 0) 1328 + if (irq_base < 0) { 1329 + status = irq_base; 1317 1330 goto fail; 1331 + } 1318 1332 } 1319 1333 1320 - /* Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. 1334 + /* 1335 + * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. 1321 1336 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0, 1322 1337 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0. 1323 1338 */ 1324 - 1325 1339 if (twl_class_is_4030()) { 1340 + u8 temp; 1341 + 1326 1342 twl_i2c_read_u8(TWL4030_MODULE_INTBR, &temp, REG_GPPUPDCTR1); 1327 1343 temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \ 1328 - I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU); 1344 + I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU); 1329 1345 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); 1330 1346 } 1331 1347 ··· 1333 1349 if (node) 1334 1350 status = of_platform_populate(node, NULL, NULL, &client->dev); 1335 1351 if (status) 1336 - status = add_children(pdata, id->driver_data); 1352 + status = add_children(pdata, irq_base, id->driver_data); 1337 1353 1338 1354 fail: 1339 1355 if (status < 0) 1340 1356 twl_remove(client); 1357 + 1341 1358 return status; 1342 1359 } 1343 1360
+2 -2
drivers/mfd/twl-core.h
··· 1 1 #ifndef __TWL_CORE_H__ 2 2 #define __TWL_CORE_H__ 3 3 4 - extern int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end); 4 + extern int twl6030_init_irq(struct device *dev, int irq_num); 5 5 extern int twl6030_exit_irq(void); 6 - extern int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end); 6 + extern int twl4030_init_irq(struct device *dev, int irq_num); 7 7 extern int twl4030_exit_irq(void); 8 8 extern int twl4030_init_chip_irq(const char *chip); 9 9
+60 -47
drivers/mfd/twl4030-irq.c
··· 28 28 */ 29 29 30 30 #include <linux/init.h> 31 + #include <linux/export.h> 31 32 #include <linux/interrupt.h> 32 33 #include <linux/irq.h> 33 34 #include <linux/slab.h> 34 - 35 + #include <linux/of.h> 36 + #include <linux/irqdomain.h> 35 37 #include <linux/i2c/twl.h> 36 38 37 39 #include "twl-core.h" ··· 55 53 * base + 8 .. base + 15 SIH for PWR_INT 56 54 * base + 16 .. base + 33 SIH for GPIO 57 55 */ 56 + #define TWL4030_CORE_NR_IRQS 8 57 + #define TWL4030_PWR_NR_IRQS 8 58 58 59 59 /* PIH register offsets */ 60 60 #define REG_PIH_ISR_P1 0x01 61 61 #define REG_PIH_ISR_P2 0x02 62 62 #define REG_PIH_SIR 0x03 /* for testing */ 63 - 64 63 65 64 /* Linux could (eventually) use either IRQ line */ 66 65 static int irq_line; ··· 114 111 #define TWL4030_MODULE_INT_PWR TWL4030_MODULE_INT 115 112 116 113 117 - /* Order in this table matches order in PIH_ISR. That is, 114 + /* 115 + * Order in this table matches order in PIH_ISR. That is, 118 116 * BIT(n) in PIH_ISR is sih_modules[n]. 119 117 */ 120 118 /* sih_modules_twl4030 is used both in twl4030 and twl5030 */ ··· 292 288 */ 293 289 static irqreturn_t handle_twl4030_pih(int irq, void *devid) 294 290 { 295 - int module_irq; 296 291 irqreturn_t ret; 297 292 u8 pih_isr; 298 293 ··· 302 299 return IRQ_NONE; 303 300 } 304 301 305 - /* these handlers deal with the relevant SIH irq status */ 306 - for (module_irq = twl4030_irq_base; 307 - pih_isr; 308 - pih_isr >>= 1, module_irq++) { 309 - if (pih_isr & 0x1) 310 - handle_nested_irq(module_irq); 302 + while (pih_isr) { 303 + unsigned long pending = __ffs(pih_isr); 304 + unsigned int irq; 305 + 306 + pih_isr &= ~BIT(pending); 307 + irq = pending + twl4030_irq_base; 308 + handle_nested_irq(irq); 311 309 } 312 310 313 311 return IRQ_HANDLED; 314 312 } 313 + 315 314 /*----------------------------------------------------------------------*/ 316 315 317 316 /* ··· 342 337 memset(buf, 0xff, sizeof buf); 343 338 sih = sih_modules; 344 339 for (i = 0; i < nr_sih_modules; i++, sih++) { 345 - 346 340 /* skip USB -- it's funky */ 347 341 if (!sih->bytes_ixr) 348 342 continue; ··· 356 352 pr_err("twl4030: err %d initializing %s %s\n", 357 353 status, sih->name, "IMR"); 358 354 359 - /* Maybe disable "exclusive" mode; buffer second pending irq; 355 + /* 356 + * Maybe disable "exclusive" mode; buffer second pending irq; 360 357 * set Clear-On-Read (COR) bit. 361 358 * 362 359 * NOTE that sometimes COR polarity is documented as being ··· 387 382 if (sih->irq_lines <= line) 388 383 continue; 389 384 390 - /* Clear pending interrupt status. Either the read was 385 + /* 386 + * Clear pending interrupt status. Either the read was 391 387 * enough, or we need to write those bits. Repeat, in 392 388 * case an IRQ is pending (PENDDIS=0) ... that's not 393 389 * uncommon with PWR_INT.PWRON. ··· 404 398 status = twl_i2c_write(sih->module, buf, 405 399 sih->mask[line].isr_offset, 406 400 sih->bytes_ixr); 407 - /* else COR=1 means read sufficed. 401 + /* 402 + * else COR=1 means read sufficed. 408 403 * (for most SIH modules...) 409 404 */ 410 405 } ··· 417 410 static inline void activate_irq(int irq) 418 411 { 419 412 #ifdef CONFIG_ARM 420 - /* ARM requires an extra step to clear IRQ_NOREQUEST, which it 413 + /* 414 + * ARM requires an extra step to clear IRQ_NOREQUEST, which it 421 415 * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE. 422 416 */ 423 417 set_irq_flags(irq, IRQF_VALID); ··· 628 620 return IRQ_HANDLED; 629 621 } 630 622 631 - static unsigned twl4030_irq_next; 632 - 633 - /* returns the first IRQ used by this SIH bank, 634 - * or negative errno 635 - */ 636 - int twl4030_sih_setup(int module) 623 + /* returns the first IRQ used by this SIH bank, or negative errno */ 624 + int twl4030_sih_setup(struct device *dev, int module, int irq_base) 637 625 { 638 626 int sih_mod; 639 627 const struct sih *sih = NULL; 640 628 struct sih_agent *agent; 641 629 int i, irq; 642 630 int status = -EINVAL; 643 - unsigned irq_base = twl4030_irq_next; 644 631 645 632 /* only support modules with standard clear-on-read for now */ 646 - for (sih_mod = 0, sih = sih_modules; 647 - sih_mod < nr_sih_modules; 633 + for (sih_mod = 0, sih = sih_modules; sih_mod < nr_sih_modules; 648 634 sih_mod++, sih++) { 649 635 if (sih->module == module && sih->set_cor) { 650 - if (!WARN((irq_base + sih->bits) > NR_IRQS, 651 - "irq %d for %s too big\n", 652 - irq_base + sih->bits, 653 - sih->name)) 654 - status = 0; 636 + status = 0; 655 637 break; 656 638 } 657 639 } 640 + 658 641 if (status < 0) 659 642 return status; 660 643 661 644 agent = kzalloc(sizeof *agent, GFP_KERNEL); 662 645 if (!agent) 663 646 return -ENOMEM; 664 - 665 - status = 0; 666 647 667 648 agent->irq_base = irq_base; 668 649 agent->sih = sih; ··· 668 671 activate_irq(irq); 669 672 } 670 673 671 - twl4030_irq_next += i; 672 - 673 674 /* replace generic PIH handler (handle_simple_irq) */ 674 675 irq = sih_mod + twl4030_irq_base; 675 676 irq_set_handler_data(irq, agent); ··· 675 680 status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0, 676 681 agent->irq_name ?: sih->name, NULL); 677 682 678 - pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name, 679 - irq, irq_base, twl4030_irq_next - 1); 683 + dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name, 684 + irq, irq_base, irq_base + i - 1); 680 685 681 686 return status < 0 ? status : irq_base; 682 687 } 683 688 684 689 /* FIXME need a call to reverse twl4030_sih_setup() ... */ 685 690 686 - 687 691 /*----------------------------------------------------------------------*/ 688 692 689 693 /* FIXME pass in which interrupt line we'll use ... */ 690 694 #define twl_irq_line 0 691 695 692 - int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) 696 + int twl4030_init_irq(struct device *dev, int irq_num) 693 697 { 694 698 static struct irq_chip twl4030_irq_chip; 699 + int status, i; 700 + int irq_base, irq_end, nr_irqs; 701 + struct device_node *node = dev->of_node; 695 702 696 - int status; 697 - int i; 703 + /* 704 + * TWL core and pwr interrupts must be contiguous because 705 + * the hwirqs numbers are defined contiguously from 1 to 15. 706 + * Create only one domain for both. 707 + */ 708 + nr_irqs = TWL4030_PWR_NR_IRQS + TWL4030_CORE_NR_IRQS; 709 + 710 + irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); 711 + if (IS_ERR_VALUE(irq_base)) { 712 + dev_err(dev, "Fail to allocate IRQ descs\n"); 713 + return irq_base; 714 + } 715 + 716 + irq_domain_add_legacy(node, nr_irqs, irq_base, 0, 717 + &irq_domain_simple_ops, NULL); 718 + 719 + irq_end = irq_base + TWL4030_CORE_NR_IRQS; 698 720 699 721 /* 700 722 * Mask and clear all TWL4030 interrupts since initially we do ··· 723 711 724 712 twl4030_irq_base = irq_base; 725 713 726 - /* install an irq handler for each of the SIH modules; 714 + /* 715 + * Install an irq handler for each of the SIH modules; 727 716 * clone dummy irq_chip since PIH can't *do* anything 728 717 */ 729 718 twl4030_irq_chip = dummy_irq_chip; ··· 738 725 irq_set_nested_thread(i, 1); 739 726 activate_irq(i); 740 727 } 741 - twl4030_irq_next = i; 742 - pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", "PIH", 743 - irq_num, irq_base, twl4030_irq_next - 1); 728 + 729 + dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", "PIH", 730 + irq_num, irq_base, irq_end); 744 731 745 732 /* ... and the PWR_INT module ... */ 746 - status = twl4030_sih_setup(TWL4030_MODULE_INT); 733 + status = twl4030_sih_setup(dev, TWL4030_MODULE_INT, irq_end); 747 734 if (status < 0) { 748 - pr_err("twl4030: sih_setup PWR INT --> %d\n", status); 735 + dev_err(dev, "sih_setup PWR INT --> %d\n", status); 749 736 goto fail; 750 737 } 751 738 ··· 754 741 IRQF_ONESHOT, 755 742 "TWL4030-PIH", NULL); 756 743 if (status < 0) { 757 - pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status); 744 + dev_err(dev, "could not claim irq%d: %d\n", irq_num, status); 758 745 goto fail_rqirq; 759 746 } 760 747 761 - return status; 748 + return irq_base; 762 749 fail_rqirq: 763 750 /* clean up twl4030_sih_setup */ 764 751 fail:
+54 -32
drivers/mfd/twl6030-irq.c
··· 39 39 #include <linux/i2c/twl.h> 40 40 #include <linux/platform_device.h> 41 41 #include <linux/suspend.h> 42 + #include <linux/of.h> 43 + #include <linux/irqdomain.h> 42 44 43 45 #include "twl-core.h" 44 46 ··· 53 51 * 54 52 * We set up IRQs starting at a platform-specified base. An interrupt map table, 55 53 * specifies mapping between interrupt number and the associated module. 56 - * 57 54 */ 55 + #define TWL6030_NR_IRQS 20 58 56 59 57 static int twl6030_interrupt_mapping[24] = { 60 58 PWR_INTR_OFFSET, /* Bit 0 PWRON */ ··· 187 185 } 188 186 local_irq_enable(); 189 187 } 190 - ret = twl_i2c_write(TWL_MODULE_PIH, sts.bytes, 191 - REG_INT_STS_A, 3); /* clear INT_STS_A */ 188 + 189 + /* 190 + * NOTE: 191 + * Simulation confirms that documentation is wrong w.r.t the 192 + * interrupt status clear operation. A single *byte* write to 193 + * any one of STS_A to STS_C register results in all three 194 + * STS registers being reset. Since it does not matter which 195 + * value is written, all three registers are cleared on a 196 + * single byte write, so we just use 0x0 to clear. 197 + */ 198 + ret = twl_i2c_write_u8(TWL_MODULE_PIH, 0x00, REG_INT_STS_A); 192 199 if (ret) 193 200 pr_warning("twl6030: I2C error in clearing PIH ISR\n"); 194 201 ··· 238 227 #endif 239 228 } 240 229 241 - int twl6030_irq_set_wake(struct irq_data *d, unsigned int on) 230 + static int twl6030_irq_set_wake(struct irq_data *d, unsigned int on) 242 231 { 243 232 if (on) 244 233 atomic_inc(&twl6030_wakeirqs); ··· 248 237 return 0; 249 238 } 250 239 251 - /*----------------------------------------------------------------------*/ 252 - 253 - static unsigned twl6030_irq_next; 254 - 255 - /*----------------------------------------------------------------------*/ 256 240 int twl6030_interrupt_unmask(u8 bit_mask, u8 offset) 257 241 { 258 242 int ret; ··· 317 311 ret); 318 312 return ret; 319 313 } 320 - return 0; 314 + 315 + return twl6030_irq_base + MMCDETECT_INTR_OFFSET; 321 316 } 322 317 EXPORT_SYMBOL(twl6030_mmc_card_detect_config); 323 318 ··· 347 340 } 348 341 EXPORT_SYMBOL(twl6030_mmc_card_detect); 349 342 350 - int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) 343 + int twl6030_init_irq(struct device *dev, int irq_num) 351 344 { 352 - 353 - int status = 0; 354 - int i; 345 + struct device_node *node = dev->of_node; 346 + int nr_irqs, irq_base, irq_end; 355 347 struct task_struct *task; 356 - int ret; 357 - u8 mask[4]; 348 + static struct irq_chip twl6030_irq_chip; 349 + int status = 0; 350 + int i; 351 + u8 mask[4]; 358 352 359 - static struct irq_chip twl6030_irq_chip; 353 + nr_irqs = TWL6030_NR_IRQS; 354 + 355 + irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); 356 + if (IS_ERR_VALUE(irq_base)) { 357 + dev_err(dev, "Fail to allocate IRQ descs\n"); 358 + return irq_base; 359 + } 360 + 361 + irq_domain_add_legacy(node, nr_irqs, irq_base, 0, 362 + &irq_domain_simple_ops, NULL); 363 + 364 + irq_end = irq_base + nr_irqs; 365 + 360 366 mask[1] = 0xFF; 361 367 mask[2] = 0xFF; 362 368 mask[3] = 0xFF; 363 - ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0], 364 - REG_INT_MSK_LINE_A, 3); /* MASK ALL INT LINES */ 365 - ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0], 366 - REG_INT_MSK_STS_A, 3); /* MASK ALL INT STS */ 367 - ret = twl_i2c_write(TWL_MODULE_PIH, &mask[0], 368 - REG_INT_STS_A, 3); /* clear INT_STS_A,B,C */ 369 + 370 + /* mask all int lines */ 371 + twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3); 372 + /* mask all int sts */ 373 + twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3); 374 + /* clear INT_STS_A,B,C */ 375 + twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3); 369 376 370 377 twl6030_irq_base = irq_base; 371 378 372 - /* install an irq handler for each of the modules; 379 + /* 380 + * install an irq handler for each of the modules; 373 381 * clone dummy irq_chip since PIH can't *do* anything 374 382 */ 375 383 twl6030_irq_chip = dummy_irq_chip; ··· 399 377 activate_irq(i); 400 378 } 401 379 402 - twl6030_irq_next = i; 403 - pr_info("twl6030: %s (irq %d) chaining IRQs %d..%d\n", "PIH", 404 - irq_num, irq_base, twl6030_irq_next - 1); 380 + dev_info(dev, "PIH (irq %d) chaining IRQs %d..%d\n", 381 + irq_num, irq_base, irq_end); 405 382 406 383 /* install an irq handler to demultiplex the TWL6030 interrupt */ 407 384 init_completion(&irq_event); 408 385 409 - status = request_irq(irq_num, handle_twl6030_pih, 0, 410 - "TWL6030-PIH", &irq_event); 386 + status = request_irq(irq_num, handle_twl6030_pih, 0, "TWL6030-PIH", 387 + &irq_event); 411 388 if (status < 0) { 412 - pr_err("twl6030: could not claim irq%d: %d\n", irq_num, status); 389 + dev_err(dev, "could not claim irq %d: %d\n", irq_num, status); 413 390 goto fail_irq; 414 391 } 415 392 416 393 task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq"); 417 394 if (IS_ERR(task)) { 418 - pr_err("twl6030: could not create irq %d thread!\n", irq_num); 395 + dev_err(dev, "could not create irq %d thread!\n", irq_num); 419 396 status = PTR_ERR(task); 420 397 goto fail_kthread; 421 398 } 422 399 423 400 twl_irq = irq_num; 424 401 register_pm_notifier(&twl6030_irq_pm_notifier_block); 425 - return status; 402 + return irq_base; 426 403 427 404 fail_kthread: 428 405 free_irq(irq_num, &irq_event); ··· 429 408 fail_irq: 430 409 for (i = irq_base; i < irq_end; i++) 431 410 irq_set_chip_and_handler(i, NULL, NULL); 411 + 432 412 return status; 433 413 } 434 414
+1 -1
drivers/mfd/wm831x-spi.c
··· 89 89 { "wm8326", WM8326 }, 90 90 { }, 91 91 }; 92 - MODULE_DEVICE_TABLE(spi, wm831x_spi_id); 92 + MODULE_DEVICE_TABLE(spi, wm831x_spi_ids); 93 93 94 94 static struct spi_driver wm831x_spi_driver = { 95 95 .driver = {
+1 -2
drivers/mfd/wm8400-core.c
··· 271 271 return -EIO; 272 272 } 273 273 if (i != reg_data[WM8400_RESET_ID].default_val) { 274 - dev_err(wm8400->dev, "Device is not a WM8400, ID is %x\n", 275 - reg); 274 + dev_err(wm8400->dev, "Device is not a WM8400, ID is %x\n", i); 276 275 return -ENODEV; 277 276 } 278 277
+1 -1
drivers/mfd/wm8994-core.c
··· 639 639 } 640 640 641 641 pm_runtime_enable(wm8994->dev); 642 - pm_runtime_resume(wm8994->dev); 642 + pm_runtime_idle(wm8994->dev); 643 643 644 644 return 0; 645 645
+2 -18
drivers/mfd/wm8994-regmap.c
··· 20 20 #include "wm8994.h" 21 21 22 22 static struct reg_default wm1811_defaults[] = { 23 - { 0x0000, 0x1811 }, /* R0 - Software Reset */ 24 23 { 0x0001, 0x0000 }, /* R1 - Power Management (1) */ 25 24 { 0x0002, 0x6000 }, /* R2 - Power Management (2) */ 26 25 { 0x0003, 0x0000 }, /* R3 - Power Management (3) */ ··· 60 61 { 0x0036, 0x0000 }, /* R54 - Speaker Mixer */ 61 62 { 0x0037, 0x0000 }, /* R55 - Additional Control */ 62 63 { 0x0038, 0x0000 }, /* R56 - AntiPOP (1) */ 63 - { 0x0039, 0x0180 }, /* R57 - AntiPOP (2) */ 64 + { 0x0039, 0x0000 }, /* R57 - AntiPOP (2) */ 64 65 { 0x003B, 0x000D }, /* R59 - LDO 1 */ 65 66 { 0x003C, 0x0003 }, /* R60 - LDO 2 */ 66 67 { 0x003D, 0x0039 }, /* R61 - MICBIAS1 */ ··· 68 69 { 0x004C, 0x1F25 }, /* R76 - Charge Pump (1) */ 69 70 { 0x004D, 0xAB19 }, /* R77 - Charge Pump (2) */ 70 71 { 0x0051, 0x0004 }, /* R81 - Class W (1) */ 71 - { 0x0054, 0x0000 }, /* R84 - DC Servo (1) */ 72 72 { 0x0055, 0x054A }, /* R85 - DC Servo (2) */ 73 - { 0x0058, 0x0000 }, /* R88 - DC Servo Readback */ 74 73 { 0x0059, 0x0000 }, /* R89 - DC Servo (4) */ 75 74 { 0x0060, 0x0000 }, /* R96 - Analogue HP (1) */ 76 75 { 0x00C5, 0x0000 }, /* R197 - Class D Test (5) */ 77 76 { 0x00D0, 0x7600 }, /* R208 - Mic Detect 1 */ 78 77 { 0x00D1, 0x007F }, /* R209 - Mic Detect 2 */ 79 - { 0x00D2, 0x0000 }, /* R210 - Mic Detect 3 */ 80 - { 0x0100, 0x0100 }, /* R256 - Chip Revision */ 81 78 { 0x0101, 0x8004 }, /* R257 - Control Interface */ 82 79 { 0x0200, 0x0000 }, /* R512 - AIF1 Clocking (1) */ 83 80 { 0x0201, 0x0000 }, /* R513 - AIF1 Clocking (2) */ ··· 83 88 { 0x0209, 0x0000 }, /* R521 - Clocking (2) */ 84 89 { 0x0210, 0x0083 }, /* R528 - AIF1 Rate */ 85 90 { 0x0211, 0x0083 }, /* R529 - AIF2 Rate */ 86 - { 0x0212, 0x0000 }, /* R530 - Rate Status */ 87 91 { 0x0220, 0x0000 }, /* R544 - FLL1 Control (1) */ 88 92 { 0x0221, 0x0000 }, /* R545 - FLL1 Control (2) */ 89 93 { 0x0222, 0x0000 }, /* R546 - FLL1 Control (3) */ ··· 212 218 { 0x070A, 0xA101 }, /* R1802 - GPIO 11 */ 213 219 { 0x0720, 0x0000 }, /* R1824 - Pull Control (1) */ 214 220 { 0x0721, 0x0156 }, /* R1825 - Pull Control (2) */ 215 - { 0x0730, 0x0000 }, /* R1840 - Interrupt Status 1 */ 216 - { 0x0731, 0x0000 }, /* R1841 - Interrupt Status 2 */ 217 221 { 0x0732, 0x0000 }, /* R1842 - Interrupt Raw Status 2 */ 218 222 { 0x0738, 0x07FF }, /* R1848 - Interrupt Status 1 Mask */ 219 223 { 0x0739, 0xDFEF }, /* R1849 - Interrupt Status 2 Mask */ ··· 220 228 }; 221 229 222 230 static struct reg_default wm8994_defaults[] = { 223 - { 0x0000, 0x8994 }, /* R0 - Software Reset */ 224 231 { 0x0001, 0x0000 }, /* R1 - Power Management (1) */ 225 232 { 0x0002, 0x6000 }, /* R2 - Power Management (2) */ 226 233 { 0x0003, 0x0000 }, /* R3 - Power Management (3) */ ··· 266 275 { 0x003C, 0x0003 }, /* R60 - LDO 2 */ 267 276 { 0x004C, 0x1F25 }, /* R76 - Charge Pump (1) */ 268 277 { 0x0051, 0x0004 }, /* R81 - Class W (1) */ 269 - { 0x0054, 0x0000 }, /* R84 - DC Servo (1) */ 270 278 { 0x0055, 0x054A }, /* R85 - DC Servo (2) */ 271 279 { 0x0057, 0x0000 }, /* R87 - DC Servo (4) */ 272 - { 0x0058, 0x0000 }, /* R88 - DC Servo Readback */ 273 280 { 0x0060, 0x0000 }, /* R96 - Analogue HP (1) */ 274 - { 0x0100, 0x0003 }, /* R256 - Chip Revision */ 275 281 { 0x0101, 0x8004 }, /* R257 - Control Interface */ 276 282 { 0x0110, 0x0000 }, /* R272 - Write Sequencer Ctrl (1) */ 277 283 { 0x0111, 0x0000 }, /* R273 - Write Sequencer Ctrl (2) */ ··· 280 292 { 0x0209, 0x0000 }, /* R521 - Clocking (2) */ 281 293 { 0x0210, 0x0083 }, /* R528 - AIF1 Rate */ 282 294 { 0x0211, 0x0083 }, /* R529 - AIF2 Rate */ 283 - { 0x0212, 0x0000 }, /* R530 - Rate Status */ 284 295 { 0x0220, 0x0000 }, /* R544 - FLL1 Control (1) */ 285 296 { 0x0221, 0x0000 }, /* R545 - FLL1 Control (2) */ 286 297 { 0x0222, 0x0000 }, /* R546 - FLL1 Control (3) */ ··· 432 445 { 0x070A, 0xA101 }, /* R1802 - GPIO 11 */ 433 446 { 0x0720, 0x0000 }, /* R1824 - Pull Control (1) */ 434 447 { 0x0721, 0x0156 }, /* R1825 - Pull Control (2) */ 435 - { 0x0730, 0x0000 }, /* R1840 - Interrupt Status 1 */ 436 - { 0x0731, 0x0000 }, /* R1841 - Interrupt Status 2 */ 437 - { 0x0732, 0x0000 }, /* R1842 - Interrupt Raw Status 2 */ 438 448 { 0x0738, 0x07FF }, /* R1848 - Interrupt Status 1 Mask */ 439 449 { 0x0739, 0xFFFF }, /* R1849 - Interrupt Status 2 Mask */ 440 450 { 0x0740, 0x0000 }, /* R1856 - Interrupt Control */ ··· 439 455 }; 440 456 441 457 static struct reg_default wm8958_defaults[] = { 442 - { 0x0000, 0x8958 }, /* R0 - Software Reset */ 443 458 { 0x0001, 0x0000 }, /* R1 - Power Management (1) */ 444 459 { 0x0002, 0x6000 }, /* R2 - Power Management (2) */ 445 460 { 0x0003, 0x0000 }, /* R3 - Power Management (3) */ ··· 953 970 { 954 971 switch (reg) { 955 972 case WM8994_DC_SERVO_READBACK: 973 + case WM8994_MICBIAS: 956 974 case WM8994_WRITE_SEQUENCER_CTRL_1: 957 975 case WM8994_WRITE_SEQUENCER_CTRL_2: 958 976 case WM8994_AIF1_ADC2_LEFT_VOLUME:
+27
drivers/rtc/rtc-88pm860x.c
··· 376 376 INIT_DELAYED_WORK(&info->calib_work, calibrate_vrtc_work); 377 377 schedule_delayed_work(&info->calib_work, VRTC_CALIB_INTERVAL); 378 378 #endif /* VRTC_CALIBRATION */ 379 + 380 + device_init_wakeup(&pdev->dev, 1); 381 + 379 382 return 0; 380 383 out_rtc: 381 384 free_irq(info->irq, info); ··· 404 401 return 0; 405 402 } 406 403 404 + #ifdef CONFIG_PM_SLEEP 405 + static int pm860x_rtc_suspend(struct device *dev) 406 + { 407 + struct platform_device *pdev = to_platform_device(dev); 408 + struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 409 + 410 + if (device_may_wakeup(dev)) 411 + chip->wakeup_flag |= 1 << PM8607_IRQ_RTC; 412 + return 0; 413 + } 414 + static int pm860x_rtc_resume(struct device *dev) 415 + { 416 + struct platform_device *pdev = to_platform_device(dev); 417 + struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 418 + 419 + if (device_may_wakeup(dev)) 420 + chip->wakeup_flag &= ~(1 << PM8607_IRQ_RTC); 421 + return 0; 422 + } 423 + #endif 424 + 425 + static SIMPLE_DEV_PM_OPS(pm860x_rtc_pm_ops, pm860x_rtc_suspend, pm860x_rtc_resume); 426 + 407 427 static struct platform_driver pm860x_rtc_driver = { 408 428 .driver = { 409 429 .name = "88pm860x-rtc", 410 430 .owner = THIS_MODULE, 431 + .pm = &pm860x_rtc_pm_ops, 411 432 }, 412 433 .probe = pm860x_rtc_probe, 413 434 .remove = __devexit_p(pm860x_rtc_remove),
+28 -21
drivers/video/backlight/88pm860x_bl.c
··· 67 67 return ret; 68 68 } 69 69 70 + static int backlight_power_set(struct pm860x_chip *chip, int port, 71 + int on) 72 + { 73 + int ret = -EINVAL; 74 + 75 + switch (port) { 76 + case PM8606_BACKLIGHT1: 77 + ret = on ? pm8606_osc_enable(chip, WLED1_DUTY) : 78 + pm8606_osc_disable(chip, WLED1_DUTY); 79 + break; 80 + case PM8606_BACKLIGHT2: 81 + ret = on ? pm8606_osc_enable(chip, WLED2_DUTY) : 82 + pm8606_osc_disable(chip, WLED2_DUTY); 83 + break; 84 + case PM8606_BACKLIGHT3: 85 + ret = on ? pm8606_osc_enable(chip, WLED3_DUTY) : 86 + pm8606_osc_disable(chip, WLED3_DUTY); 87 + break; 88 + } 89 + return ret; 90 + } 91 + 70 92 static int pm860x_backlight_set(struct backlight_device *bl, int brightness) 71 93 { 72 94 struct pm860x_backlight_data *data = bl_get_data(bl); ··· 100 78 value = MAX_BRIGHTNESS; 101 79 else 102 80 value = brightness; 81 + 82 + if (brightness) 83 + backlight_power_set(chip, data->port, 1); 103 84 104 85 ret = pm860x_reg_write(data->i2c, wled_a(data->port), value); 105 86 if (ret < 0) ··· 139 114 } 140 115 if (ret < 0) 141 116 goto out; 117 + 118 + if (brightness == 0) 119 + backlight_power_set(chip, data->port, 0); 142 120 143 121 dev_dbg(chip->dev, "set brightness %d\n", value); 144 122 data->current_brightness = value; ··· 198 170 struct backlight_device *bl; 199 171 struct resource *res; 200 172 struct backlight_properties props; 201 - unsigned char value; 202 173 char name[MFD_NAME_SIZE]; 203 174 int ret; 204 175 ··· 244 217 245 218 platform_set_drvdata(pdev, bl); 246 219 247 - /* Enable reference VSYS */ 248 - ret = pm860x_reg_read(data->i2c, PM8606_VSYS); 249 - if (ret < 0) 250 - goto out; 251 - if ((ret & PM8606_VSYS_EN) == 0) { 252 - value = ret | PM8606_VSYS_EN; 253 - ret = pm860x_reg_write(data->i2c, PM8606_VSYS, value); 254 - if (ret < 0) 255 - goto out; 256 - } 257 - /* Enable reference OSC */ 258 - ret = pm860x_reg_read(data->i2c, PM8606_MISC); 259 - if (ret < 0) 260 - goto out; 261 - if ((ret & PM8606_MISC_OSC_EN) == 0) { 262 - value = ret | PM8606_MISC_OSC_EN; 263 - ret = pm860x_reg_write(data->i2c, PM8606_MISC, value); 264 - if (ret < 0) 265 - goto out; 266 - } 267 220 /* read current backlight */ 268 221 ret = pm860x_backlight_get_brightness(bl); 269 222 if (ret < 0)
+1 -1
include/linux/i2c/twl.h
··· 761 761 762 762 /*----------------------------------------------------------------------*/ 763 763 764 - int twl4030_sih_setup(int module); 764 + int twl4030_sih_setup(struct device *dev, int module, int irq_base); 765 765 766 766 /* Offsets to Power Registers */ 767 767 #define TWL4030_VDAC_DEV_GRP 0x3B
+23
include/linux/mfd/88pm860x.h
··· 263 263 #define PM8607_PD_PREBIAS_MASK (0x1F << 0) 264 264 #define PM8607_PD_PRECHG_MASK (7 << 5) 265 265 266 + #define PM8606_REF_GP_OSC_OFF 0 267 + #define PM8606_REF_GP_OSC_ON 1 268 + #define PM8606_REF_GP_OSC_UNKNOWN 2 269 + 270 + /* Clients of reference group and 8MHz oscillator in 88PM8606 */ 271 + enum pm8606_ref_gp_and_osc_clients { 272 + REF_GP_NO_CLIENTS = 0, 273 + WLED1_DUTY = (1<<0), /*PF 0x02.7:0*/ 274 + WLED2_DUTY = (1<<1), /*PF 0x04.7:0*/ 275 + WLED3_DUTY = (1<<2), /*PF 0x06.7:0*/ 276 + RGB1_ENABLE = (1<<3), /*PF 0x07.1*/ 277 + RGB2_ENABLE = (1<<4), /*PF 0x07.2*/ 278 + LDO_VBR_EN = (1<<5), /*PF 0x12.0*/ 279 + REF_GP_MAX_CLIENT = 0xFFFF 280 + }; 281 + 266 282 /* Interrupt Number in 88PM8607 */ 267 283 enum { 268 284 PM8607_IRQ_ONKEY, ··· 314 298 struct pm860x_chip { 315 299 struct device *dev; 316 300 struct mutex irq_lock; 301 + struct mutex osc_lock; 317 302 struct i2c_client *client; 318 303 struct i2c_client *companion; /* companion chip client */ 319 304 struct regmap *regmap; ··· 322 305 323 306 int buck3_double; /* DVC ramp slope double */ 324 307 unsigned short companion_addr; 308 + unsigned short osc_vote; 325 309 int id; 326 310 int irq_mode; 327 311 int irq_base; 328 312 int core_irq; 329 313 unsigned char chip_version; 314 + unsigned char osc_status; 330 315 316 + unsigned int wakeup_flag; 331 317 }; 332 318 333 319 enum { ··· 388 368 int num_backlights; 389 369 int num_regulators; 390 370 }; 371 + 372 + extern int pm8606_osc_enable(struct pm860x_chip *, unsigned short); 373 + extern int pm8606_osc_disable(struct pm860x_chip *, unsigned short); 391 374 392 375 extern int pm860x_reg_read(struct i2c_client *, int); 393 376 extern int pm860x_reg_write(struct i2c_client *, int, unsigned char);
-7
include/linux/mfd/abx500.h
··· 34 34 #define AB5500_1_1 0x21 35 35 #define AB5500_2_0 0x24 36 36 37 - /* AB8500 CIDs*/ 38 - #define AB8500_CUT1P0 0x10 39 - #define AB8500_CUT1P1 0x11 40 - #define AB8500_CUT2P0 0x20 41 - #define AB8500_CUT3P0 0x30 42 - #define AB8500_CUT3P3 0x33 43 - 44 37 /* 45 38 * AB3100, EVENTA1, A2 and A3 event register flags 46 39 * these are catenated into a single 32-bit flag in the code
+3 -1
include/linux/mfd/abx500/ab8500-gpio.h
··· 10 10 11 11 /* 12 12 * Platform data to register a block: only the initial gpio/irq number. 13 + * Array sizes are large enough to contain all AB8500 and AB9540 GPIO 14 + * registers. 13 15 */ 14 16 15 17 struct ab8500_gpio_platform_data { 16 18 int gpio_base; 17 19 u32 irq_base; 18 - u8 config_reg[7]; 20 + u8 config_reg[8]; 19 21 }; 20 22 21 23 #endif /* _AB8500_GPIO_H */
+43
include/linux/mfd/abx500/ab8500-sysctrl.h
··· 71 71 #define AB8500_SWATCTRL 0x230 72 72 #define AB8500_HIQCLKCTRL 0x232 73 73 #define AB8500_VSIMSYSCLKCTRL 0x233 74 + #define AB9540_SYSCLK12BUFCTRL 0x234 75 + #define AB9540_SYSCLK12CONFCTRL 0x235 76 + #define AB9540_SYSCLK12BUFCTRL2 0x236 77 + #define AB9540_SYSCLK12BUF1VALID 0x237 78 + #define AB9540_SYSCLK12BUF2VALID 0x238 79 + #define AB9540_SYSCLK12BUF3VALID 0x239 80 + #define AB9540_SYSCLK12BUF4VALID 0x23A 74 81 75 82 /* Bits */ 76 83 #define AB8500_TURNONSTATUS_PORNVBAT BIT(0) ··· 257 250 #define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ6VALID BIT(5) 258 251 #define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ7VALID BIT(6) 259 252 #define AB8500_VSIMSYSCLKCTRL_VSIMSYSCLKREQ8VALID BIT(7) 253 + 254 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF1ENA BIT(0) 255 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF2ENA BIT(1) 256 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF3ENA BIT(2) 257 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF4ENA BIT(3) 258 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUFENA_MASK 0x0F 259 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF1STRE BIT(4) 260 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF2STRE BIT(5) 261 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF3STRE BIT(6) 262 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUF4STRE BIT(7) 263 + #define AB9540_SYSCLK12BUFCTRL_SYSCLK12BUFSTRE_MASK 0xF0 264 + 265 + #define AB9540_SYSCLK12CONFCTRL_PLL26TO38ENA BIT(0) 266 + #define AB9540_SYSCLK12CONFCTRL_SYSCLK12USBMUXSEL BIT(1) 267 + #define AB9540_SYSCLK12CONFCTRL_INT384MHZMUXSEL_MASK 0x0C 268 + #define AB9540_SYSCLK12CONFCTRL_INT384MHZMUXSEL_SHIFT 2 269 + #define AB9540_SYSCLK12CONFCTRL_SYSCLK12BUFMUX BIT(4) 270 + #define AB9540_SYSCLK12CONFCTRL_SYSCLK12PLLMUX BIT(5) 271 + #define AB9540_SYSCLK12CONFCTRL_SYSCLK2MUXVALID BIT(6) 272 + 273 + #define AB9540_SYSCLK12BUFCTRL2_SYSCLK12BUF1PDENA BIT(0) 274 + #define AB9540_SYSCLK12BUFCTRL2_SYSCLK12BUF2PDENA BIT(1) 275 + #define AB9540_SYSCLK12BUFCTRL2_SYSCLK12BUF3PDENA BIT(2) 276 + #define AB9540_SYSCLK12BUFCTRL2_SYSCLK12BUF4PDENA BIT(3) 277 + 278 + #define AB9540_SYSCLK12BUF1VALID_SYSCLK12BUF1VALID_MASK 0xFF 279 + #define AB9540_SYSCLK12BUF1VALID_SYSCLK12BUF1VALID_SHIFT 0 280 + 281 + #define AB9540_SYSCLK12BUF2VALID_SYSCLK12BUF2VALID_MASK 0xFF 282 + #define AB9540_SYSCLK12BUF2VALID_SYSCLK12BUF2VALID_SHIFT 0 283 + 284 + #define AB9540_SYSCLK12BUF3VALID_SYSCLK12BUF3VALID_MASK 0xFF 285 + #define AB9540_SYSCLK12BUF3VALID_SYSCLK12BUF3VALID_SHIFT 0 286 + 287 + #define AB9540_SYSCLK12BUF4VALID_SYSCLK12BUF4VALID_MASK 0xFF 288 + #define AB9540_SYSCLK12BUF4VALID_SYSCLK12BUF4VALID_SHIFT 0 260 289 261 290 #endif /* __AB8500_SYSCTRL_H */
+166 -42
include/linux/mfd/abx500/ab8500.h
··· 12 12 struct device; 13 13 14 14 /* 15 + * AB IC versions 16 + * 17 + * AB8500_VERSION_AB8500 should be 0xFF but will never be read as need a 18 + * non-supported multi-byte I2C access via PRCMU. Set to 0x00 to ease the 19 + * print of version string. 20 + */ 21 + enum ab8500_version { 22 + AB8500_VERSION_AB8500 = 0x0, 23 + AB8500_VERSION_AB8505 = 0x1, 24 + AB8500_VERSION_AB9540 = 0x2, 25 + AB8500_VERSION_AB8540 = 0x3, 26 + AB8500_VERSION_UNDEFINED, 27 + }; 28 + 29 + /* AB8500 CIDs*/ 30 + #define AB8500_CUTEARLY 0x00 31 + #define AB8500_CUT1P0 0x10 32 + #define AB8500_CUT1P1 0x11 33 + #define AB8500_CUT2P0 0x20 34 + #define AB8500_CUT3P0 0x30 35 + #define AB8500_CUT3P3 0x33 36 + 37 + /* 15 38 * AB8500 bank addresses 16 39 */ 17 40 #define AB8500_SYS_CTRL1_BLOCK 0x1 ··· 60 37 61 38 /* 62 39 * Interrupts 40 + * Values used to index into array ab8500_irq_regoffset[] defined in 41 + * drivers/mdf/ab8500-core.c 63 42 */ 64 - 65 - #define AB8500_INT_MAIN_EXT_CH_NOT_OK 0 66 - #define AB8500_INT_UN_PLUG_TV_DET 1 67 - #define AB8500_INT_PLUG_TV_DET 2 43 + /* Definitions for AB8500 and AB9540 */ 44 + /* ab8500_irq_regoffset[0] -> IT[Source|Latch|Mask]1 */ 45 + #define AB8500_INT_MAIN_EXT_CH_NOT_OK 0 /* not 8505/9540 */ 46 + #define AB8500_INT_UN_PLUG_TV_DET 1 /* not 8505/9540 */ 47 + #define AB8500_INT_PLUG_TV_DET 2 /* not 8505/9540 */ 68 48 #define AB8500_INT_TEMP_WARM 3 69 49 #define AB8500_INT_PON_KEY2DB_F 4 70 50 #define AB8500_INT_PON_KEY2DB_R 5 71 51 #define AB8500_INT_PON_KEY1DB_F 6 72 52 #define AB8500_INT_PON_KEY1DB_R 7 53 + /* ab8500_irq_regoffset[1] -> IT[Source|Latch|Mask]2 */ 73 54 #define AB8500_INT_BATT_OVV 8 74 - #define AB8500_INT_MAIN_CH_UNPLUG_DET 10 75 - #define AB8500_INT_MAIN_CH_PLUG_DET 11 76 - #define AB8500_INT_USB_ID_DET_F 12 77 - #define AB8500_INT_USB_ID_DET_R 13 55 + #define AB8500_INT_MAIN_CH_UNPLUG_DET 10 /* not 8505 */ 56 + #define AB8500_INT_MAIN_CH_PLUG_DET 11 /* not 8505 */ 78 57 #define AB8500_INT_VBUS_DET_F 14 79 58 #define AB8500_INT_VBUS_DET_R 15 59 + /* ab8500_irq_regoffset[2] -> IT[Source|Latch|Mask]3 */ 80 60 #define AB8500_INT_VBUS_CH_DROP_END 16 81 61 #define AB8500_INT_RTC_60S 17 82 62 #define AB8500_INT_RTC_ALARM 18 83 63 #define AB8500_INT_BAT_CTRL_INDB 20 84 64 #define AB8500_INT_CH_WD_EXP 21 85 65 #define AB8500_INT_VBUS_OVV 22 86 - #define AB8500_INT_MAIN_CH_DROP_END 23 66 + #define AB8500_INT_MAIN_CH_DROP_END 23 /* not 8505/9540 */ 67 + /* ab8500_irq_regoffset[3] -> IT[Source|Latch|Mask]4 */ 87 68 #define AB8500_INT_CCN_CONV_ACC 24 88 69 #define AB8500_INT_INT_AUD 25 89 70 #define AB8500_INT_CCEOC 26 ··· 96 69 #define AB8500_INT_LOW_BAT_R 29 97 70 #define AB8500_INT_BUP_CHG_NOT_OK 30 98 71 #define AB8500_INT_BUP_CHG_OK 31 99 - #define AB8500_INT_GP_HW_ADC_CONV_END 32 72 + /* ab8500_irq_regoffset[4] -> IT[Source|Latch|Mask]5 */ 73 + #define AB8500_INT_GP_HW_ADC_CONV_END 32 /* not 8505 */ 100 74 #define AB8500_INT_ACC_DETECT_1DB_F 33 101 75 #define AB8500_INT_ACC_DETECT_1DB_R 34 102 76 #define AB8500_INT_ACC_DETECT_22DB_F 35 ··· 105 77 #define AB8500_INT_ACC_DETECT_21DB_F 37 106 78 #define AB8500_INT_ACC_DETECT_21DB_R 38 107 79 #define AB8500_INT_GP_SW_ADC_CONV_END 39 108 - #define AB8500_INT_GPIO6R 40 109 - #define AB8500_INT_GPIO7R 41 110 - #define AB8500_INT_GPIO8R 42 111 - #define AB8500_INT_GPIO9R 43 80 + /* ab8500_irq_regoffset[5] -> IT[Source|Latch|Mask]7 */ 81 + #define AB8500_INT_GPIO6R 40 /* not 8505/9540 */ 82 + #define AB8500_INT_GPIO7R 41 /* not 8505/9540 */ 83 + #define AB8500_INT_GPIO8R 42 /* not 8505/9540 */ 84 + #define AB8500_INT_GPIO9R 43 /* not 8505/9540 */ 112 85 #define AB8500_INT_GPIO10R 44 113 86 #define AB8500_INT_GPIO11R 45 114 - #define AB8500_INT_GPIO12R 46 87 + #define AB8500_INT_GPIO12R 46 /* not 8505 */ 115 88 #define AB8500_INT_GPIO13R 47 116 - #define AB8500_INT_GPIO24R 48 117 - #define AB8500_INT_GPIO25R 49 118 - #define AB8500_INT_GPIO36R 50 119 - #define AB8500_INT_GPIO37R 51 120 - #define AB8500_INT_GPIO38R 52 121 - #define AB8500_INT_GPIO39R 53 89 + /* ab8500_irq_regoffset[6] -> IT[Source|Latch|Mask]8 */ 90 + #define AB8500_INT_GPIO24R 48 /* not 8505 */ 91 + #define AB8500_INT_GPIO25R 49 /* not 8505 */ 92 + #define AB8500_INT_GPIO36R 50 /* not 8505/9540 */ 93 + #define AB8500_INT_GPIO37R 51 /* not 8505/9540 */ 94 + #define AB8500_INT_GPIO38R 52 /* not 8505/9540 */ 95 + #define AB8500_INT_GPIO39R 53 /* not 8505/9540 */ 122 96 #define AB8500_INT_GPIO40R 54 123 97 #define AB8500_INT_GPIO41R 55 124 - #define AB8500_INT_GPIO6F 56 125 - #define AB8500_INT_GPIO7F 57 126 - #define AB8500_INT_GPIO8F 58 127 - #define AB8500_INT_GPIO9F 59 98 + /* ab8500_irq_regoffset[7] -> IT[Source|Latch|Mask]9 */ 99 + #define AB8500_INT_GPIO6F 56 /* not 8505/9540 */ 100 + #define AB8500_INT_GPIO7F 57 /* not 8505/9540 */ 101 + #define AB8500_INT_GPIO8F 58 /* not 8505/9540 */ 102 + #define AB8500_INT_GPIO9F 59 /* not 8505/9540 */ 128 103 #define AB8500_INT_GPIO10F 60 129 104 #define AB8500_INT_GPIO11F 61 130 - #define AB8500_INT_GPIO12F 62 105 + #define AB8500_INT_GPIO12F 62 /* not 8505 */ 131 106 #define AB8500_INT_GPIO13F 63 132 - #define AB8500_INT_GPIO24F 64 133 - #define AB8500_INT_GPIO25F 65 134 - #define AB8500_INT_GPIO36F 66 135 - #define AB8500_INT_GPIO37F 67 136 - #define AB8500_INT_GPIO38F 68 137 - #define AB8500_INT_GPIO39F 69 107 + /* ab8500_irq_regoffset[8] -> IT[Source|Latch|Mask]10 */ 108 + #define AB8500_INT_GPIO24F 64 /* not 8505 */ 109 + #define AB8500_INT_GPIO25F 65 /* not 8505 */ 110 + #define AB8500_INT_GPIO36F 66 /* not 8505/9540 */ 111 + #define AB8500_INT_GPIO37F 67 /* not 8505/9540 */ 112 + #define AB8500_INT_GPIO38F 68 /* not 8505/9540 */ 113 + #define AB8500_INT_GPIO39F 69 /* not 8505/9540 */ 138 114 #define AB8500_INT_GPIO40F 70 139 115 #define AB8500_INT_GPIO41F 71 116 + /* ab8500_irq_regoffset[9] -> IT[Source|Latch|Mask]12 */ 140 117 #define AB8500_INT_ADP_SOURCE_ERROR 72 141 118 #define AB8500_INT_ADP_SINK_ERROR 73 142 119 #define AB8500_INT_ADP_PROBE_PLUG 74 ··· 149 116 #define AB8500_INT_ADP_SENSE_OFF 76 150 117 #define AB8500_INT_USB_PHY_POWER_ERR 78 151 118 #define AB8500_INT_USB_LINK_STATUS 79 119 + /* ab8500_irq_regoffset[10] -> IT[Source|Latch|Mask]19 */ 152 120 #define AB8500_INT_BTEMP_LOW 80 153 121 #define AB8500_INT_BTEMP_LOW_MEDIUM 81 154 122 #define AB8500_INT_BTEMP_MEDIUM_HIGH 82 155 123 #define AB8500_INT_BTEMP_HIGH 83 156 - #define AB8500_INT_USB_CHARGER_NOT_OK 89 124 + /* ab8500_irq_regoffset[11] -> IT[Source|Latch|Mask]20 */ 125 + #define AB8500_INT_SRP_DETECT 88 126 + #define AB8500_INT_USB_CHARGER_NOT_OKR 89 157 127 #define AB8500_INT_ID_WAKEUP_R 90 158 128 #define AB8500_INT_ID_DET_R1R 92 159 129 #define AB8500_INT_ID_DET_R2R 93 160 130 #define AB8500_INT_ID_DET_R3R 94 161 131 #define AB8500_INT_ID_DET_R4R 95 132 + /* ab8500_irq_regoffset[12] -> IT[Source|Latch|Mask]21 */ 162 133 #define AB8500_INT_ID_WAKEUP_F 96 163 134 #define AB8500_INT_ID_DET_R1F 98 164 135 #define AB8500_INT_ID_DET_R2F 99 165 136 #define AB8500_INT_ID_DET_R3F 100 166 137 #define AB8500_INT_ID_DET_R4F 101 167 - #define AB8500_INT_USB_CHG_DET_DONE 102 138 + #define AB8500_INT_CHAUTORESTARTAFTSEC 102 139 + #define AB8500_INT_CHSTOPBYSEC 103 140 + /* ab8500_irq_regoffset[13] -> IT[Source|Latch|Mask]22 */ 168 141 #define AB8500_INT_USB_CH_TH_PROT_F 104 169 142 #define AB8500_INT_USB_CH_TH_PROT_R 105 170 - #define AB8500_INT_MAIN_CH_TH_PROT_F 106 171 - #define AB8500_INT_MAIN_CH_TH_PROT_R 107 172 - #define AB8500_INT_USB_CHARGER_NOT_OKF 111 143 + #define AB8500_INT_MAIN_CH_TH_PROT_F 106 /* not 8505/9540 */ 144 + #define AB8500_INT_MAIN_CH_TH_PROT_R 107 /* not 8505/9540 */ 145 + #define AB8500_INT_CHCURLIMNOHSCHIRP 109 146 + #define AB8500_INT_CHCURLIMHSCHIRP 110 147 + #define AB8500_INT_XTAL32K_KO 111 173 148 149 + /* Definitions for AB9540 */ 150 + /* ab8500_irq_regoffset[14] -> IT[Source|Latch|Mask]13 */ 151 + #define AB9540_INT_GPIO50R 113 152 + #define AB9540_INT_GPIO51R 114 /* not 8505 */ 153 + #define AB9540_INT_GPIO52R 115 154 + #define AB9540_INT_GPIO53R 116 155 + #define AB9540_INT_GPIO54R 117 /* not 8505 */ 156 + #define AB9540_INT_IEXT_CH_RF_BFN_R 118 157 + #define AB9540_INT_IEXT_CH_RF_BFN_F 119 158 + /* ab8500_irq_regoffset[15] -> IT[Source|Latch|Mask]14 */ 159 + #define AB9540_INT_GPIO50F 121 160 + #define AB9540_INT_GPIO51F 122 /* not 8505 */ 161 + #define AB9540_INT_GPIO52F 123 162 + #define AB9540_INT_GPIO53F 124 163 + #define AB9540_INT_GPIO54F 125 /* not 8505 */ 164 + 165 + /* 166 + * AB8500_AB9540_NR_IRQS is used when configuring the IRQ numbers for the 167 + * entire platform. This is a "compile time" constant so this must be set to 168 + * the largest possible value that may be encountered with different AB SOCs. 169 + * Of the currently supported AB devices, AB8500 and AB9540, it is the AB9540 170 + * which is larger. 171 + */ 174 172 #define AB8500_NR_IRQS 112 173 + #define AB8505_NR_IRQS 128 174 + #define AB9540_NR_IRQS 128 175 + /* This is set to the roof of any AB8500 chip variant IRQ counts */ 176 + #define AB8500_MAX_NR_IRQS AB9540_NR_IRQS 177 + 175 178 #define AB8500_NUM_IRQ_REGS 14 179 + #define AB9540_NUM_IRQ_REGS 17 176 180 177 181 /** 178 182 * struct ab8500 - ab8500 internal structure ··· 217 147 * @lock: read/write operations lock 218 148 * @irq_lock: genirq bus lock 219 149 * @irq: irq line 150 + * @version: chip version id (e.g. ab8500 or ab9540) 220 151 * @chip_id: chip revision id 221 152 * @write: register write 153 + * @write_masked: masked register write 222 154 * @read: register read 223 155 * @rx_buf: rx buf for SPI 224 156 * @tx_buf: tx buf for SPI 225 157 * @mask: cache of IRQ regs for bus lock 226 158 * @oldmask: cache of previous IRQ regs for bus lock 159 + * @mask_size: Actual number of valid entries in mask[], oldmask[] and 160 + * irq_reg_offset 161 + * @irq_reg_offset: Array of offsets into IRQ registers 227 162 */ 228 163 struct ab8500 { 229 164 struct device *dev; ··· 237 162 238 163 int irq_base; 239 164 int irq; 165 + enum ab8500_version version; 240 166 u8 chip_id; 241 167 242 - int (*write) (struct ab8500 *a8500, u16 addr, u8 data); 243 - int (*read) (struct ab8500 *a8500, u16 addr); 168 + int (*write)(struct ab8500 *ab8500, u16 addr, u8 data); 169 + int (*write_masked)(struct ab8500 *ab8500, u16 addr, u8 mask, u8 data); 170 + int (*read)(struct ab8500 *ab8500, u16 addr); 244 171 245 172 unsigned long tx_buf[4]; 246 173 unsigned long rx_buf[4]; 247 174 248 - u8 mask[AB8500_NUM_IRQ_REGS]; 249 - u8 oldmask[AB8500_NUM_IRQ_REGS]; 175 + u8 *mask; 176 + u8 *oldmask; 177 + int mask_size; 178 + const int *irq_reg_offset; 250 179 }; 251 180 252 181 struct regulator_reg_init; ··· 276 197 struct ab8500_gpio_platform_data *gpio; 277 198 }; 278 199 279 - extern int __devinit ab8500_init(struct ab8500 *ab8500); 200 + extern int __devinit ab8500_init(struct ab8500 *ab8500, 201 + enum ab8500_version version); 280 202 extern int __devexit ab8500_exit(struct ab8500 *ab8500); 203 + 204 + static inline int is_ab8500(struct ab8500 *ab) 205 + { 206 + return ab->version == AB8500_VERSION_AB8500; 207 + } 208 + 209 + static inline int is_ab8505(struct ab8500 *ab) 210 + { 211 + return ab->version == AB8500_VERSION_AB8505; 212 + } 213 + 214 + static inline int is_ab9540(struct ab8500 *ab) 215 + { 216 + return ab->version == AB8500_VERSION_AB9540; 217 + } 218 + 219 + static inline int is_ab8540(struct ab8500 *ab) 220 + { 221 + return ab->version == AB8500_VERSION_AB8540; 222 + } 223 + 224 + /* exclude also ab8505, ab9540... */ 225 + static inline int is_ab8500_1p0_or_earlier(struct ab8500 *ab) 226 + { 227 + return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT1P0)); 228 + } 229 + 230 + /* exclude also ab8505, ab9540... */ 231 + static inline int is_ab8500_1p1_or_earlier(struct ab8500 *ab) 232 + { 233 + return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT1P1)); 234 + } 235 + 236 + /* exclude also ab8505, ab9540... */ 237 + static inline int is_ab8500_2p0_or_earlier(struct ab8500 *ab) 238 + { 239 + return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT2P0)); 240 + } 241 + 242 + /* exclude also ab8505, ab9540... */ 243 + static inline int is_ab8500_2p0(struct ab8500 *ab) 244 + { 245 + return (is_ab8500(ab) && (ab->chip_id == AB8500_CUT2P0)); 246 + } 281 247 282 248 #endif /* MFD_AB8500_H */
+40
include/linux/mfd/anatop.h
··· 1 + /* 2 + * anatop.h - Anatop MFD driver 3 + * 4 + * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> 5 + * Copyright (C) 2012 Linaro 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License as published by 9 + * the Free Software Foundation; either version 2 of the License, or 10 + * (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 + */ 21 + 22 + #ifndef __LINUX_MFD_ANATOP_H 23 + #define __LINUX_MFD_ANATOP_H 24 + 25 + #include <linux/spinlock.h> 26 + 27 + /** 28 + * anatop - MFD data 29 + * @ioreg: ioremap register 30 + * @reglock: spinlock for register read/write 31 + */ 32 + struct anatop { 33 + void *ioreg; 34 + spinlock_t reglock; 35 + }; 36 + 37 + extern u32 anatop_get_bits(struct anatop *, u32, int, int); 38 + extern void anatop_set_bits(struct anatop *, u32, int, int, u32); 39 + 40 + #endif /* __LINUX_MFD_ANATOP_H */
-2
include/linux/mfd/da9052/da9052.h
··· 76 76 struct da9052_pdata; 77 77 78 78 struct da9052 { 79 - struct mutex io_lock; 80 - 81 79 struct device *dev; 82 80 struct regmap *regmap; 83 81
+103 -82
include/linux/mfd/db8500-prcmu.h
··· 11 11 #define __MFD_DB8500_PRCMU_H 12 12 13 13 #include <linux/interrupt.h> 14 + #include <linux/bitops.h> 15 + 16 + /* 17 + * Registers 18 + */ 19 + #define DB8500_PRCM_GPIOCR 0x138 20 + #define DB8500_PRCM_GPIOCR_DBG_UARTMOD_CMD0 BIT(0) 21 + #define DB8500_PRCM_GPIOCR_DBG_STM_APE_CMD BIT(9) 22 + #define DB8500_PRCM_GPIOCR_DBG_STM_MOD_CMD1 BIT(11) 23 + #define DB8500_PRCM_GPIOCR_SPI2_SELECT BIT(23) 24 + 25 + #define DB8500_PRCM_LINE_VALUE 0x170 26 + #define DB8500_PRCM_LINE_VALUE_HSI_CAWAKE0 BIT(3) 27 + 28 + #define DB8500_PRCM_DSI_SW_RESET 0x324 29 + #define DB8500_PRCM_DSI_SW_RESET_DSI0_SW_RESETN BIT(0) 30 + #define DB8500_PRCM_DSI_SW_RESET_DSI1_SW_RESETN BIT(1) 31 + #define DB8500_PRCM_DSI_SW_RESET_DSI2_SW_RESETN BIT(2) 14 32 15 33 /* This portion previously known as <mach/prcmu-fw-defs_v1.h> */ 16 34 ··· 439 421 /* End of file previously known as prcmu-fw-defs_v1.h */ 440 422 441 423 /** 442 - * enum hw_acc_dev - enum for hw accelerators 443 - * @HW_ACC_SVAMMDSP: for SVAMMDSP 444 - * @HW_ACC_SVAPIPE: for SVAPIPE 445 - * @HW_ACC_SIAMMDSP: for SIAMMDSP 446 - * @HW_ACC_SIAPIPE: for SIAPIPE 447 - * @HW_ACC_SGA: for SGA 448 - * @HW_ACC_B2R2: for B2R2 449 - * @HW_ACC_MCDE: for MCDE 450 - * @HW_ACC_ESRAM1: for ESRAM1 451 - * @HW_ACC_ESRAM2: for ESRAM2 452 - * @HW_ACC_ESRAM3: for ESRAM3 453 - * @HW_ACC_ESRAM4: for ESRAM4 454 - * @NUM_HW_ACC: number of hardware accelerators 424 + * enum prcmu_power_status - results from set_power_state 425 + * @PRCMU_SLEEP_OK: Sleep went ok 426 + * @PRCMU_DEEP_SLEEP_OK: DeepSleep went ok 427 + * @PRCMU_IDLE_OK: Idle went ok 428 + * @PRCMU_DEEPIDLE_OK: DeepIdle went ok 429 + * @PRCMU_PRCMU2ARMPENDINGIT_ER: Pending interrupt detected 430 + * @PRCMU_ARMPENDINGIT_ER: Pending interrupt detected 455 431 * 456 - * Different hw accelerators which can be turned ON/ 457 - * OFF or put into retention (MMDSPs and ESRAMs). 458 - * Used with EPOD API. 459 - * 460 - * NOTE! Deprecated, to be removed when all users switched over to use the 461 - * regulator API. 462 432 */ 463 - enum hw_acc_dev { 464 - HW_ACC_SVAMMDSP, 465 - HW_ACC_SVAPIPE, 466 - HW_ACC_SIAMMDSP, 467 - HW_ACC_SIAPIPE, 468 - HW_ACC_SGA, 469 - HW_ACC_B2R2, 470 - HW_ACC_MCDE, 471 - HW_ACC_ESRAM1, 472 - HW_ACC_ESRAM2, 473 - HW_ACC_ESRAM3, 474 - HW_ACC_ESRAM4, 475 - NUM_HW_ACC 433 + enum prcmu_power_status { 434 + PRCMU_SLEEP_OK = 0xf3, 435 + PRCMU_DEEP_SLEEP_OK = 0xf6, 436 + PRCMU_IDLE_OK = 0xf0, 437 + PRCMU_DEEPIDLE_OK = 0xe3, 438 + PRCMU_PRCMU2ARMPENDINGIT_ER = 0x91, 439 + PRCMU_ARMPENDINGIT_ER = 0x93, 476 440 }; 477 441 478 442 /* ··· 493 493 u8 sva_policy; 494 494 }; 495 495 496 + #define PRCMU_FW_PROJECT_U8500 2 497 + #define PRCMU_FW_PROJECT_U9500 4 498 + #define PRCMU_FW_PROJECT_U8500_C2 7 499 + #define PRCMU_FW_PROJECT_U9500_C2 11 500 + #define PRCMU_FW_PROJECT_U8520 13 501 + #define PRCMU_FW_PROJECT_U8420 14 502 + 503 + struct prcmu_fw_version { 504 + u8 project; 505 + u8 api_version; 506 + u8 func_version; 507 + u8 errata; 508 + }; 509 + 496 510 #ifdef CONFIG_MFD_DB8500_PRCMU 497 511 498 512 void db8500_prcmu_early_init(void); ··· 514 500 enum romcode_read prcmu_get_rc_p2a(void); 515 501 enum ap_pwrst prcmu_get_xp70_current_state(void); 516 502 bool prcmu_has_arm_maxopp(void); 517 - bool prcmu_is_u8400(void); 518 - int prcmu_set_ape_opp(u8 opp); 519 - int prcmu_get_ape_opp(void); 503 + struct prcmu_fw_version *prcmu_get_fw_version(void); 520 504 int prcmu_request_ape_opp_100_voltage(bool enable); 521 505 int prcmu_release_usb_wakeup_state(void); 522 - int prcmu_set_ddr_opp(u8 opp); 523 - int prcmu_get_ddr_opp(void); 524 - /* NOTE! Use regulator framework instead */ 525 - int prcmu_set_hwacc(u16 hw_acc_dev, u8 state); 526 506 void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep, 527 507 struct prcmu_auto_pm_config *idle); 528 508 bool prcmu_is_auto_pm_enabled(void); 529 509 530 510 int prcmu_config_clkout(u8 clkout, u8 source, u8 div); 531 511 int prcmu_set_clock_divider(u8 clock, u8 divider); 532 - int prcmu_config_hotdog(u8 threshold); 533 - int prcmu_config_hotmon(u8 low, u8 high); 534 - int prcmu_start_temp_sense(u16 cycles32k); 535 - int prcmu_stop_temp_sense(void); 512 + int db8500_prcmu_config_hotdog(u8 threshold); 513 + int db8500_prcmu_config_hotmon(u8 low, u8 high); 514 + int db8500_prcmu_start_temp_sense(u16 cycles32k); 515 + int db8500_prcmu_stop_temp_sense(void); 536 516 int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size); 537 517 int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size); 538 518 539 519 void prcmu_ac_wake_req(void); 540 520 void prcmu_ac_sleep_req(void); 541 - void prcmu_modem_reset(void); 542 - void prcmu_enable_spi2(void); 543 - void prcmu_disable_spi2(void); 521 + void db8500_prcmu_modem_reset(void); 544 522 545 - int prcmu_config_a9wdog(u8 num, bool sleep_auto_off); 546 - int prcmu_enable_a9wdog(u8 id); 547 - int prcmu_disable_a9wdog(u8 id); 548 - int prcmu_kick_a9wdog(u8 id); 549 - int prcmu_load_a9wdog(u8 id, u32 val); 523 + int db8500_prcmu_config_a9wdog(u8 num, bool sleep_auto_off); 524 + int db8500_prcmu_enable_a9wdog(u8 id); 525 + int db8500_prcmu_disable_a9wdog(u8 id); 526 + int db8500_prcmu_kick_a9wdog(u8 id); 527 + int db8500_prcmu_load_a9wdog(u8 id, u32 val); 550 528 551 529 void db8500_prcmu_system_reset(u16 reset_code); 552 530 int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk, bool keep_ap_pll); 531 + u8 db8500_prcmu_get_power_state_result(void); 532 + int db8500_prcmu_gic_decouple(void); 533 + int db8500_prcmu_gic_recouple(void); 534 + int db8500_prcmu_copy_gic_settings(void); 535 + bool db8500_prcmu_gic_pending_irq(void); 536 + bool db8500_prcmu_pending_irq(void); 537 + bool db8500_prcmu_is_cpu_in_wfi(int cpu); 553 538 void db8500_prcmu_enable_wakeups(u32 wakeups); 554 539 int db8500_prcmu_set_epod(u16 epod_id, u8 epod_state); 555 540 int db8500_prcmu_request_clock(u8 clock, bool enable); ··· 562 549 bool db8500_prcmu_is_ac_wake_requested(void); 563 550 int db8500_prcmu_set_arm_opp(u8 opp); 564 551 int db8500_prcmu_get_arm_opp(void); 552 + int db8500_prcmu_set_ape_opp(u8 opp); 553 + int db8500_prcmu_get_ape_opp(void); 554 + int db8500_prcmu_set_ddr_opp(u8 opp); 555 + int db8500_prcmu_get_ddr_opp(void); 556 + 557 + u32 db8500_prcmu_read(unsigned int reg); 558 + void db8500_prcmu_write(unsigned int reg, u32 value); 559 + void db8500_prcmu_write_masked(unsigned int reg, u32 mask, u32 value); 565 560 566 561 #else /* !CONFIG_MFD_DB8500_PRCMU */ 567 562 ··· 595 574 return false; 596 575 } 597 576 598 - static inline bool prcmu_is_u8400(void) 577 + static inline struct prcmu_fw_version *prcmu_get_fw_version(void) 599 578 { 600 - return false; 579 + return NULL; 601 580 } 602 581 603 - static inline int prcmu_set_ape_opp(u8 opp) 582 + static inline int db8500_prcmu_set_ape_opp(u8 opp) 604 583 { 605 584 return 0; 606 585 } 607 586 608 - static inline int prcmu_get_ape_opp(void) 587 + static inline int db8500_prcmu_get_ape_opp(void) 609 588 { 610 589 return APE_100_OPP; 611 590 } ··· 620 599 return 0; 621 600 } 622 601 623 - static inline int prcmu_set_ddr_opp(u8 opp) 602 + static inline int db8500_prcmu_set_ddr_opp(u8 opp) 624 603 { 625 604 return 0; 626 605 } 627 606 628 - static inline int prcmu_get_ddr_opp(void) 607 + static inline int db8500_prcmu_get_ddr_opp(void) 629 608 { 630 609 return DDR_100_OPP; 631 - } 632 - 633 - static inline int prcmu_set_hwacc(u16 hw_acc_dev, u8 state) 634 - { 635 - return 0; 636 610 } 637 611 638 612 static inline void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep, ··· 650 634 return 0; 651 635 } 652 636 653 - static inline int prcmu_config_hotdog(u8 threshold) 637 + static inline int db8500_prcmu_config_hotdog(u8 threshold) 654 638 { 655 639 return 0; 656 640 } 657 641 658 - static inline int prcmu_config_hotmon(u8 low, u8 high) 642 + static inline int db8500_prcmu_config_hotmon(u8 low, u8 high) 659 643 { 660 644 return 0; 661 645 } 662 646 663 - static inline int prcmu_start_temp_sense(u16 cycles32k) 647 + static inline int db8500_prcmu_start_temp_sense(u16 cycles32k) 664 648 { 665 649 return 0; 666 650 } 667 651 668 - static inline int prcmu_stop_temp_sense(void) 652 + static inline int db8500_prcmu_stop_temp_sense(void) 669 653 { 670 654 return 0; 671 655 } ··· 684 668 685 669 static inline void prcmu_ac_sleep_req(void) {} 686 670 687 - static inline void prcmu_modem_reset(void) {} 688 - 689 - static inline int prcmu_enable_spi2(void) 690 - { 691 - return 0; 692 - } 693 - 694 - static inline int prcmu_disable_spi2(void) 695 - { 696 - return 0; 697 - } 671 + static inline void db8500_prcmu_modem_reset(void) {} 698 672 699 673 static inline void db8500_prcmu_system_reset(u16 reset_code) {} 700 674 701 675 static inline int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk, 702 676 bool keep_ap_pll) 677 + { 678 + return 0; 679 + } 680 + 681 + static inline u8 db8500_prcmu_get_power_state_result(void) 703 682 { 704 683 return 0; 705 684 } ··· 740 729 return 0; 741 730 } 742 731 743 - static inline int prcmu_config_a9wdog(u8 num, bool sleep_auto_off) 732 + static inline int db8500_prcmu_config_a9wdog(u8 num, bool sleep_auto_off) 744 733 { 745 734 return 0; 746 735 } 747 736 748 - static inline int prcmu_enable_a9wdog(u8 id) 737 + static inline int db8500_prcmu_enable_a9wdog(u8 id) 749 738 { 750 739 return 0; 751 740 } 752 741 753 - static inline int prcmu_disable_a9wdog(u8 id) 742 + static inline int db8500_prcmu_disable_a9wdog(u8 id) 754 743 { 755 744 return 0; 756 745 } 757 746 758 - static inline int prcmu_kick_a9wdog(u8 id) 747 + static inline int db8500_prcmu_kick_a9wdog(u8 id) 759 748 { 760 749 return 0; 761 750 } 762 751 763 - static inline int prcmu_load_a9wdog(u8 id, u32 val) 752 + static inline int db8500_prcmu_load_a9wdog(u8 id, u32 val) 764 753 { 765 754 return 0; 766 755 } ··· 779 768 { 780 769 return 0; 781 770 } 771 + 772 + static inline u32 db8500_prcmu_read(unsigned int reg) 773 + { 774 + return 0; 775 + } 776 + 777 + static inline void db8500_prcmu_write(unsigned int reg, u32 value) {} 778 + 779 + static inline void db8500_prcmu_write_masked(unsigned int reg, u32 mask, 780 + u32 value) {} 782 781 783 782 #endif /* !CONFIG_MFD_DB8500_PRCMU */ 784 783
+390 -24
include/linux/mfd/dbx500-prcmu.h
··· 10 10 11 11 #include <linux/interrupt.h> 12 12 #include <linux/notifier.h> 13 - #include <asm/mach-types.h> 13 + #include <linux/err.h> 14 14 15 15 /* PRCMU Wakeup defines */ 16 16 enum prcmu_wakeup_index { ··· 80 80 #define EPOD_STATE_ON_CLK_OFF 0x03 81 81 #define EPOD_STATE_ON 0x04 82 82 83 + /* DB5500 CLKOUT IDs */ 84 + enum { 85 + DB5500_CLKOUT0 = 0, 86 + DB5500_CLKOUT1, 87 + }; 88 + 89 + /* DB5500 CLKOUTx sources */ 90 + enum { 91 + DB5500_CLKOUT_REF_CLK_SEL0, 92 + DB5500_CLKOUT_RTC_CLK0_SEL0, 93 + DB5500_CLKOUT_ULP_CLK_SEL0, 94 + DB5500_CLKOUT_STATIC0, 95 + DB5500_CLKOUT_REFCLK, 96 + DB5500_CLKOUT_ULPCLK, 97 + DB5500_CLKOUT_ARMCLK, 98 + DB5500_CLKOUT_SYSACC0CLK, 99 + DB5500_CLKOUT_SOC0PLLCLK, 100 + DB5500_CLKOUT_SOC1PLLCLK, 101 + DB5500_CLKOUT_DDRPLLCLK, 102 + DB5500_CLKOUT_TVCLK, 103 + DB5500_CLKOUT_IRDACLK, 104 + }; 105 + 83 106 /* 84 107 * CLKOUT sources 85 108 */ ··· 134 111 PRCMU_MSP1CLK, 135 112 PRCMU_I2CCLK, 136 113 PRCMU_SDMMCCLK, 114 + PRCMU_SPARE1CLK, 137 115 PRCMU_SLIMCLK, 138 116 PRCMU_PER1CLK, 139 117 PRCMU_PER2CLK, ··· 163 139 PRCMU_IRRCCLK, 164 140 PRCMU_SIACLK, 165 141 PRCMU_SVACLK, 142 + PRCMU_ACLK, 166 143 PRCMU_NUM_REG_CLOCKS, 167 144 PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS, 145 + PRCMU_CDCLK, 168 146 PRCMU_TIMCLK, 169 147 PRCMU_PLLSOC0, 170 148 PRCMU_PLLSOC1, 171 149 PRCMU_PLLDDR, 150 + PRCMU_PLLDSI, 151 + PRCMU_DSI0CLK, 152 + PRCMU_DSI1CLK, 153 + PRCMU_DSI0ESCCLK, 154 + PRCMU_DSI1ESCCLK, 155 + PRCMU_DSI2ESCCLK, 172 156 }; 173 157 174 158 /** ··· 185 153 * @APE_NO_CHANGE: The APE operating point is unchanged 186 154 * @APE_100_OPP: The new APE operating point is ape100opp 187 155 * @APE_50_OPP: 50% 156 + * @APE_50_PARTLY_25_OPP: 50%, except some clocks at 25%. 188 157 */ 189 158 enum ape_opp { 190 159 APE_OPP_INIT = 0x00, 191 160 APE_NO_CHANGE = 0x01, 192 161 APE_100_OPP = 0x02, 193 - APE_50_OPP = 0x03 162 + APE_50_OPP = 0x03, 163 + APE_50_PARTLY_25_OPP = 0xFF, 194 164 }; 195 165 196 166 /** ··· 252 218 253 219 #if defined(CONFIG_UX500_SOC_DB8500) || defined(CONFIG_UX500_SOC_DB5500) 254 220 221 + #include <mach/id.h> 222 + 255 223 static inline void __init prcmu_early_init(void) 256 224 { 257 - if (machine_is_u5500()) 225 + if (cpu_is_u5500()) 258 226 return db5500_prcmu_early_init(); 259 227 else 260 228 return db8500_prcmu_early_init(); ··· 265 229 static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk, 266 230 bool keep_ap_pll) 267 231 { 268 - if (machine_is_u5500()) 232 + if (cpu_is_u5500()) 269 233 return db5500_prcmu_set_power_state(state, keep_ulp_clk, 270 234 keep_ap_pll); 271 235 else ··· 273 237 keep_ap_pll); 274 238 } 275 239 240 + static inline u8 prcmu_get_power_state_result(void) 241 + { 242 + if (cpu_is_u5500()) 243 + return -EINVAL; 244 + else 245 + return db8500_prcmu_get_power_state_result(); 246 + } 247 + 248 + static inline int prcmu_gic_decouple(void) 249 + { 250 + if (cpu_is_u5500()) 251 + return -EINVAL; 252 + else 253 + return db8500_prcmu_gic_decouple(); 254 + } 255 + 256 + static inline int prcmu_gic_recouple(void) 257 + { 258 + if (cpu_is_u5500()) 259 + return -EINVAL; 260 + else 261 + return db8500_prcmu_gic_recouple(); 262 + } 263 + 264 + static inline bool prcmu_gic_pending_irq(void) 265 + { 266 + if (cpu_is_u5500()) 267 + return -EINVAL; 268 + else 269 + return db8500_prcmu_gic_pending_irq(); 270 + } 271 + 272 + static inline bool prcmu_is_cpu_in_wfi(int cpu) 273 + { 274 + if (cpu_is_u5500()) 275 + return -EINVAL; 276 + else 277 + return db8500_prcmu_is_cpu_in_wfi(cpu); 278 + } 279 + 280 + static inline int prcmu_copy_gic_settings(void) 281 + { 282 + if (cpu_is_u5500()) 283 + return -EINVAL; 284 + else 285 + return db8500_prcmu_copy_gic_settings(); 286 + } 287 + 288 + static inline bool prcmu_pending_irq(void) 289 + { 290 + if (cpu_is_u5500()) 291 + return -EINVAL; 292 + else 293 + return db8500_prcmu_pending_irq(); 294 + } 295 + 276 296 static inline int prcmu_set_epod(u16 epod_id, u8 epod_state) 277 297 { 278 - if (machine_is_u5500()) 298 + if (cpu_is_u5500()) 279 299 return -EINVAL; 280 300 else 281 301 return db8500_prcmu_set_epod(epod_id, epod_state); ··· 339 247 340 248 static inline void prcmu_enable_wakeups(u32 wakeups) 341 249 { 342 - if (machine_is_u5500()) 250 + if (cpu_is_u5500()) 343 251 db5500_prcmu_enable_wakeups(wakeups); 344 252 else 345 253 db8500_prcmu_enable_wakeups(wakeups); ··· 352 260 353 261 static inline void prcmu_config_abb_event_readout(u32 abb_events) 354 262 { 355 - if (machine_is_u5500()) 263 + if (cpu_is_u5500()) 356 264 db5500_prcmu_config_abb_event_readout(abb_events); 357 265 else 358 266 db8500_prcmu_config_abb_event_readout(abb_events); ··· 360 268 361 269 static inline void prcmu_get_abb_event_buffer(void __iomem **buf) 362 270 { 363 - if (machine_is_u5500()) 271 + if (cpu_is_u5500()) 364 272 db5500_prcmu_get_abb_event_buffer(buf); 365 273 else 366 274 db8500_prcmu_get_abb_event_buffer(buf); ··· 368 276 369 277 int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size); 370 278 int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size); 279 + int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size); 371 280 372 281 int prcmu_config_clkout(u8 clkout, u8 source, u8 div); 373 282 374 283 static inline int prcmu_request_clock(u8 clock, bool enable) 375 284 { 376 - if (machine_is_u5500()) 285 + if (cpu_is_u5500()) 377 286 return db5500_prcmu_request_clock(clock, enable); 378 287 else 379 288 return db8500_prcmu_request_clock(clock, enable); 380 289 } 381 290 382 - int prcmu_set_ape_opp(u8 opp); 383 - int prcmu_get_ape_opp(void); 384 - int prcmu_set_ddr_opp(u8 opp); 385 - int prcmu_get_ddr_opp(void); 291 + unsigned long prcmu_clock_rate(u8 clock); 292 + long prcmu_round_clock_rate(u8 clock, unsigned long rate); 293 + int prcmu_set_clock_rate(u8 clock, unsigned long rate); 294 + 295 + static inline int prcmu_set_ddr_opp(u8 opp) 296 + { 297 + if (cpu_is_u5500()) 298 + return -EINVAL; 299 + else 300 + return db8500_prcmu_set_ddr_opp(opp); 301 + } 302 + static inline int prcmu_get_ddr_opp(void) 303 + { 304 + if (cpu_is_u5500()) 305 + return -EINVAL; 306 + else 307 + return db8500_prcmu_get_ddr_opp(); 308 + } 386 309 387 310 static inline int prcmu_set_arm_opp(u8 opp) 388 311 { 389 - if (machine_is_u5500()) 312 + if (cpu_is_u5500()) 390 313 return -EINVAL; 391 314 else 392 315 return db8500_prcmu_set_arm_opp(opp); ··· 409 302 410 303 static inline int prcmu_get_arm_opp(void) 411 304 { 412 - if (machine_is_u5500()) 305 + if (cpu_is_u5500()) 413 306 return -EINVAL; 414 307 else 415 308 return db8500_prcmu_get_arm_opp(); 416 309 } 417 310 311 + static inline int prcmu_set_ape_opp(u8 opp) 312 + { 313 + if (cpu_is_u5500()) 314 + return -EINVAL; 315 + else 316 + return db8500_prcmu_set_ape_opp(opp); 317 + } 318 + 319 + static inline int prcmu_get_ape_opp(void) 320 + { 321 + if (cpu_is_u5500()) 322 + return -EINVAL; 323 + else 324 + return db8500_prcmu_get_ape_opp(); 325 + } 326 + 418 327 static inline void prcmu_system_reset(u16 reset_code) 419 328 { 420 - if (machine_is_u5500()) 329 + if (cpu_is_u5500()) 421 330 return db5500_prcmu_system_reset(reset_code); 422 331 else 423 332 return db8500_prcmu_system_reset(reset_code); ··· 441 318 442 319 static inline u16 prcmu_get_reset_code(void) 443 320 { 444 - if (machine_is_u5500()) 321 + if (cpu_is_u5500()) 445 322 return db5500_prcmu_get_reset_code(); 446 323 else 447 324 return db8500_prcmu_get_reset_code(); ··· 449 326 450 327 void prcmu_ac_wake_req(void); 451 328 void prcmu_ac_sleep_req(void); 452 - void prcmu_modem_reset(void); 329 + static inline void prcmu_modem_reset(void) 330 + { 331 + if (cpu_is_u5500()) 332 + return; 333 + else 334 + return db8500_prcmu_modem_reset(); 335 + } 336 + 453 337 static inline bool prcmu_is_ac_wake_requested(void) 454 338 { 455 - if (machine_is_u5500()) 339 + if (cpu_is_u5500()) 456 340 return db5500_prcmu_is_ac_wake_requested(); 457 341 else 458 342 return db8500_prcmu_is_ac_wake_requested(); ··· 467 337 468 338 static inline int prcmu_set_display_clocks(void) 469 339 { 470 - if (machine_is_u5500()) 340 + if (cpu_is_u5500()) 471 341 return db5500_prcmu_set_display_clocks(); 472 342 else 473 343 return db8500_prcmu_set_display_clocks(); ··· 475 345 476 346 static inline int prcmu_disable_dsipll(void) 477 347 { 478 - if (machine_is_u5500()) 348 + if (cpu_is_u5500()) 479 349 return db5500_prcmu_disable_dsipll(); 480 350 else 481 351 return db8500_prcmu_disable_dsipll(); ··· 483 353 484 354 static inline int prcmu_enable_dsipll(void) 485 355 { 486 - if (machine_is_u5500()) 356 + if (cpu_is_u5500()) 487 357 return db5500_prcmu_enable_dsipll(); 488 358 else 489 359 return db8500_prcmu_enable_dsipll(); ··· 491 361 492 362 static inline int prcmu_config_esram0_deep_sleep(u8 state) 493 363 { 494 - if (machine_is_u5500()) 364 + if (cpu_is_u5500()) 495 365 return -EINVAL; 496 366 else 497 367 return db8500_prcmu_config_esram0_deep_sleep(state); 368 + } 369 + 370 + static inline int prcmu_config_hotdog(u8 threshold) 371 + { 372 + if (cpu_is_u5500()) 373 + return -EINVAL; 374 + else 375 + return db8500_prcmu_config_hotdog(threshold); 376 + } 377 + 378 + static inline int prcmu_config_hotmon(u8 low, u8 high) 379 + { 380 + if (cpu_is_u5500()) 381 + return -EINVAL; 382 + else 383 + return db8500_prcmu_config_hotmon(low, high); 384 + } 385 + 386 + static inline int prcmu_start_temp_sense(u16 cycles32k) 387 + { 388 + if (cpu_is_u5500()) 389 + return -EINVAL; 390 + else 391 + return db8500_prcmu_start_temp_sense(cycles32k); 392 + } 393 + 394 + static inline int prcmu_stop_temp_sense(void) 395 + { 396 + if (cpu_is_u5500()) 397 + return -EINVAL; 398 + else 399 + return db8500_prcmu_stop_temp_sense(); 400 + } 401 + 402 + static inline u32 prcmu_read(unsigned int reg) 403 + { 404 + if (cpu_is_u5500()) 405 + return -EINVAL; 406 + else 407 + return db8500_prcmu_read(reg); 408 + } 409 + 410 + static inline void prcmu_write(unsigned int reg, u32 value) 411 + { 412 + if (cpu_is_u5500()) 413 + return; 414 + else 415 + db8500_prcmu_write(reg, value); 416 + } 417 + 418 + static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) 419 + { 420 + if (cpu_is_u5500()) 421 + return; 422 + else 423 + db8500_prcmu_write_masked(reg, mask, value); 424 + } 425 + 426 + static inline int prcmu_enable_a9wdog(u8 id) 427 + { 428 + if (cpu_is_u5500()) 429 + return -EINVAL; 430 + else 431 + return db8500_prcmu_enable_a9wdog(id); 432 + } 433 + 434 + static inline int prcmu_disable_a9wdog(u8 id) 435 + { 436 + if (cpu_is_u5500()) 437 + return -EINVAL; 438 + else 439 + return db8500_prcmu_disable_a9wdog(id); 440 + } 441 + 442 + static inline int prcmu_kick_a9wdog(u8 id) 443 + { 444 + if (cpu_is_u5500()) 445 + return -EINVAL; 446 + else 447 + return db8500_prcmu_kick_a9wdog(id); 448 + } 449 + 450 + static inline int prcmu_load_a9wdog(u8 id, u32 timeout) 451 + { 452 + if (cpu_is_u5500()) 453 + return -EINVAL; 454 + else 455 + return db8500_prcmu_load_a9wdog(id, timeout); 456 + } 457 + 458 + static inline int prcmu_config_a9wdog(u8 num, bool sleep_auto_off) 459 + { 460 + if (cpu_is_u5500()) 461 + return -EINVAL; 462 + else 463 + return db8500_prcmu_config_a9wdog(num, sleep_auto_off); 498 464 } 499 465 #else 500 466 ··· 621 395 return -ENOSYS; 622 396 } 623 397 398 + static inline int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, 399 + u8 size) 400 + { 401 + return -ENOSYS; 402 + } 403 + 624 404 static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div) 625 405 { 626 406 return 0; 627 407 } 628 408 629 409 static inline int prcmu_request_clock(u8 clock, bool enable) 410 + { 411 + return 0; 412 + } 413 + 414 + static inline long prcmu_round_clock_rate(u8 clock, unsigned long rate) 415 + { 416 + return 0; 417 + } 418 + 419 + static inline int prcmu_set_clock_rate(u8 clock, unsigned long rate) 420 + { 421 + return 0; 422 + } 423 + 424 + static inline unsigned long prcmu_clock_rate(u8 clock) 630 425 { 631 426 return 0; 632 427 } ··· 727 480 *buf = NULL; 728 481 } 729 482 483 + static inline int prcmu_config_hotdog(u8 threshold) 484 + { 485 + return 0; 486 + } 487 + 488 + static inline int prcmu_config_hotmon(u8 low, u8 high) 489 + { 490 + return 0; 491 + } 492 + 493 + static inline int prcmu_start_temp_sense(u16 cycles32k) 494 + { 495 + return 0; 496 + } 497 + 498 + static inline int prcmu_stop_temp_sense(void) 499 + { 500 + return 0; 501 + } 502 + 503 + static inline u32 prcmu_read(unsigned int reg) 504 + { 505 + return 0; 506 + } 507 + 508 + static inline void prcmu_write(unsigned int reg, u32 value) {} 509 + 510 + static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {} 511 + 512 + #endif 513 + 514 + static inline void prcmu_set(unsigned int reg, u32 bits) 515 + { 516 + prcmu_write_masked(reg, bits, bits); 517 + } 518 + 519 + static inline void prcmu_clear(unsigned int reg, u32 bits) 520 + { 521 + prcmu_write_masked(reg, bits, 0); 522 + } 523 + 524 + #if defined(CONFIG_UX500_SOC_DB8500) || defined(CONFIG_UX500_SOC_DB5500) 525 + 526 + /** 527 + * prcmu_enable_spi2 - Enables pin muxing for SPI2 on OtherAlternateC1. 528 + */ 529 + static inline void prcmu_enable_spi2(void) 530 + { 531 + if (cpu_is_u8500()) 532 + prcmu_set(DB8500_PRCM_GPIOCR, DB8500_PRCM_GPIOCR_SPI2_SELECT); 533 + } 534 + 535 + /** 536 + * prcmu_disable_spi2 - Disables pin muxing for SPI2 on OtherAlternateC1. 537 + */ 538 + static inline void prcmu_disable_spi2(void) 539 + { 540 + if (cpu_is_u8500()) 541 + prcmu_clear(DB8500_PRCM_GPIOCR, DB8500_PRCM_GPIOCR_SPI2_SELECT); 542 + } 543 + 544 + /** 545 + * prcmu_enable_stm_mod_uart - Enables pin muxing for STMMOD 546 + * and UARTMOD on OtherAlternateC3. 547 + */ 548 + static inline void prcmu_enable_stm_mod_uart(void) 549 + { 550 + if (cpu_is_u8500()) { 551 + prcmu_set(DB8500_PRCM_GPIOCR, 552 + (DB8500_PRCM_GPIOCR_DBG_STM_MOD_CMD1 | 553 + DB8500_PRCM_GPIOCR_DBG_UARTMOD_CMD0)); 554 + } 555 + } 556 + 557 + /** 558 + * prcmu_disable_stm_mod_uart - Disables pin muxing for STMMOD 559 + * and UARTMOD on OtherAlternateC3. 560 + */ 561 + static inline void prcmu_disable_stm_mod_uart(void) 562 + { 563 + if (cpu_is_u8500()) { 564 + prcmu_clear(DB8500_PRCM_GPIOCR, 565 + (DB8500_PRCM_GPIOCR_DBG_STM_MOD_CMD1 | 566 + DB8500_PRCM_GPIOCR_DBG_UARTMOD_CMD0)); 567 + } 568 + } 569 + 570 + /** 571 + * prcmu_enable_stm_ape - Enables pin muxing for STM APE on OtherAlternateC1. 572 + */ 573 + static inline void prcmu_enable_stm_ape(void) 574 + { 575 + if (cpu_is_u8500()) { 576 + prcmu_set(DB8500_PRCM_GPIOCR, 577 + DB8500_PRCM_GPIOCR_DBG_STM_APE_CMD); 578 + } 579 + } 580 + 581 + /** 582 + * prcmu_disable_stm_ape - Disables pin muxing for STM APE on OtherAlternateC1. 583 + */ 584 + static inline void prcmu_disable_stm_ape(void) 585 + { 586 + if (cpu_is_u8500()) { 587 + prcmu_clear(DB8500_PRCM_GPIOCR, 588 + DB8500_PRCM_GPIOCR_DBG_STM_APE_CMD); 589 + } 590 + } 591 + 592 + #else 593 + 594 + static inline void prcmu_enable_spi2(void) {} 595 + static inline void prcmu_disable_spi2(void) {} 596 + static inline void prcmu_enable_stm_mod_uart(void) {} 597 + static inline void prcmu_disable_stm_mod_uart(void) {} 598 + static inline void prcmu_enable_stm_ape(void) {} 599 + static inline void prcmu_disable_stm_ape(void) {} 600 + 730 601 #endif 731 602 732 603 /* PRCMU QoS APE OPP class */ 733 604 #define PRCMU_QOS_APE_OPP 1 734 605 #define PRCMU_QOS_DDR_OPP 2 606 + #define PRCMU_QOS_ARM_OPP 3 735 607 #define PRCMU_QOS_DEFAULT_VALUE -1 736 608 737 - #ifdef CONFIG_UX500_PRCMU_QOS_POWER 609 + #ifdef CONFIG_DBX500_PRCMU_QOS_POWER 738 610 739 611 unsigned long prcmu_qos_get_cpufreq_opp_delay(void); 740 612 void prcmu_qos_set_cpufreq_opp_delay(unsigned long);
+15 -1
include/linux/mfd/mc13xxx.h
··· 38 38 int mc13xxx_get_flags(struct mc13xxx *mc13xxx); 39 39 40 40 int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, 41 - unsigned int mode, unsigned int channel, unsigned int *sample); 41 + unsigned int mode, unsigned int channel, 42 + u8 ato, bool atox, unsigned int *sample); 42 43 43 44 #define MC13XXX_IRQ_ADCDONE 0 44 45 #define MC13XXX_IRQ_ADCBISDONE 1 ··· 158 157 unsigned short b3on_key; 159 158 }; 160 159 160 + struct mc13xxx_ts_platform_data { 161 + /* Delay between Touchscreen polarization and ADC Conversion. 162 + * Given in clock ticks of a 32 kHz clock which gives a granularity of 163 + * about 30.5ms */ 164 + u8 ato; 165 + 166 + #define MC13783_TS_ATO_FIRST false 167 + #define MC13783_TS_ATO_EACH true 168 + /* Use the ATO delay only for the first conversion or for each one */ 169 + bool atox; 170 + }; 171 + 161 172 struct mc13xxx_platform_data { 162 173 #define MC13XXX_USE_TOUCHSCREEN (1 << 0) 163 174 #define MC13XXX_USE_CODEC (1 << 1) ··· 180 167 struct mc13xxx_regulator_platform_data regulators; 181 168 struct mc13xxx_leds_platform_data *leds; 182 169 struct mc13xxx_buttons_platform_data *buttons; 170 + struct mc13xxx_ts_platform_data touch; 183 171 }; 184 172 185 173 #define MC13XXX_ADC_MODE_TS 1
+295
include/linux/mfd/rc5t583.h
··· 1 + /* 2 + * Core driver interface to access RICOH_RC5T583 power management chip. 3 + * 4 + * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved. 5 + * Author: Laxman dewangan <ldewangan@nvidia.com> 6 + * 7 + * Based on code 8 + * Copyright (C) 2011 RICOH COMPANY,LTD 9 + * 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms and conditions of the GNU General Public License, 12 + * version 2, as published by the Free Software Foundation. 13 + * 14 + * This program is distributed in the hope it will be useful, but WITHOUT 15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 + * more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 + * 22 + */ 23 + 24 + #ifndef __LINUX_MFD_RC5T583_H 25 + #define __LINUX_MFD_RC5T583_H 26 + 27 + #include <linux/mutex.h> 28 + #include <linux/types.h> 29 + 30 + #define RC5T583_MAX_REGS 0xF8 31 + 32 + /* Maximum number of main interrupts */ 33 + #define MAX_MAIN_INTERRUPT 5 34 + #define RC5T583_MAX_GPEDGE_REG 2 35 + #define RC5T583_MAX_INTERRUPT_MASK_REGS 9 36 + 37 + /* Interrupt enable register */ 38 + #define RC5T583_INT_EN_SYS1 0x19 39 + #define RC5T583_INT_EN_SYS2 0x1D 40 + #define RC5T583_INT_EN_DCDC 0x41 41 + #define RC5T583_INT_EN_RTC 0xED 42 + #define RC5T583_INT_EN_ADC1 0x90 43 + #define RC5T583_INT_EN_ADC2 0x91 44 + #define RC5T583_INT_EN_ADC3 0x92 45 + 46 + /* Interrupt status registers (monitor regs in Ricoh)*/ 47 + #define RC5T583_INTC_INTPOL 0xAD 48 + #define RC5T583_INTC_INTEN 0xAE 49 + #define RC5T583_INTC_INTMON 0xAF 50 + 51 + #define RC5T583_INT_MON_GRP 0xAF 52 + #define RC5T583_INT_MON_SYS1 0x1B 53 + #define RC5T583_INT_MON_SYS2 0x1F 54 + #define RC5T583_INT_MON_DCDC 0x43 55 + #define RC5T583_INT_MON_RTC 0xEE 56 + 57 + /* Interrupt clearing registers */ 58 + #define RC5T583_INT_IR_SYS1 0x1A 59 + #define RC5T583_INT_IR_SYS2 0x1E 60 + #define RC5T583_INT_IR_DCDC 0x42 61 + #define RC5T583_INT_IR_RTC 0xEE 62 + #define RC5T583_INT_IR_ADCL 0x94 63 + #define RC5T583_INT_IR_ADCH 0x95 64 + #define RC5T583_INT_IR_ADCEND 0x96 65 + #define RC5T583_INT_IR_GPIOR 0xA9 66 + #define RC5T583_INT_IR_GPIOF 0xAA 67 + 68 + /* Sleep sequence registers */ 69 + #define RC5T583_SLPSEQ1 0x21 70 + #define RC5T583_SLPSEQ2 0x22 71 + #define RC5T583_SLPSEQ3 0x23 72 + #define RC5T583_SLPSEQ4 0x24 73 + #define RC5T583_SLPSEQ5 0x25 74 + #define RC5T583_SLPSEQ6 0x26 75 + #define RC5T583_SLPSEQ7 0x27 76 + #define RC5T583_SLPSEQ8 0x28 77 + #define RC5T583_SLPSEQ9 0x29 78 + #define RC5T583_SLPSEQ10 0x2A 79 + #define RC5T583_SLPSEQ11 0x2B 80 + 81 + /* Regulator registers */ 82 + #define RC5T583_REG_DC0CTL 0x30 83 + #define RC5T583_REG_DC0DAC 0x31 84 + #define RC5T583_REG_DC0LATCTL 0x32 85 + #define RC5T583_REG_SR0CTL 0x33 86 + 87 + #define RC5T583_REG_DC1CTL 0x34 88 + #define RC5T583_REG_DC1DAC 0x35 89 + #define RC5T583_REG_DC1LATCTL 0x36 90 + #define RC5T583_REG_SR1CTL 0x37 91 + 92 + #define RC5T583_REG_DC2CTL 0x38 93 + #define RC5T583_REG_DC2DAC 0x39 94 + #define RC5T583_REG_DC2LATCTL 0x3A 95 + #define RC5T583_REG_SR2CTL 0x3B 96 + 97 + #define RC5T583_REG_DC3CTL 0x3C 98 + #define RC5T583_REG_DC3DAC 0x3D 99 + #define RC5T583_REG_DC3LATCTL 0x3E 100 + #define RC5T583_REG_SR3CTL 0x3F 101 + 102 + 103 + #define RC5T583_REG_LDOEN1 0x50 104 + #define RC5T583_REG_LDOEN2 0x51 105 + #define RC5T583_REG_LDODIS1 0x52 106 + #define RC5T583_REG_LDODIS2 0x53 107 + 108 + #define RC5T583_REG_LDO0DAC 0x54 109 + #define RC5T583_REG_LDO1DAC 0x55 110 + #define RC5T583_REG_LDO2DAC 0x56 111 + #define RC5T583_REG_LDO3DAC 0x57 112 + #define RC5T583_REG_LDO4DAC 0x58 113 + #define RC5T583_REG_LDO5DAC 0x59 114 + #define RC5T583_REG_LDO6DAC 0x5A 115 + #define RC5T583_REG_LDO7DAC 0x5B 116 + #define RC5T583_REG_LDO8DAC 0x5C 117 + #define RC5T583_REG_LDO9DAC 0x5D 118 + 119 + #define RC5T583_REG_DC0DAC_DS 0x60 120 + #define RC5T583_REG_DC1DAC_DS 0x61 121 + #define RC5T583_REG_DC2DAC_DS 0x62 122 + #define RC5T583_REG_DC3DAC_DS 0x63 123 + 124 + #define RC5T583_REG_LDO0DAC_DS 0x64 125 + #define RC5T583_REG_LDO1DAC_DS 0x65 126 + #define RC5T583_REG_LDO2DAC_DS 0x66 127 + #define RC5T583_REG_LDO3DAC_DS 0x67 128 + #define RC5T583_REG_LDO4DAC_DS 0x68 129 + #define RC5T583_REG_LDO5DAC_DS 0x69 130 + #define RC5T583_REG_LDO6DAC_DS 0x6A 131 + #define RC5T583_REG_LDO7DAC_DS 0x6B 132 + #define RC5T583_REG_LDO8DAC_DS 0x6C 133 + #define RC5T583_REG_LDO9DAC_DS 0x6D 134 + 135 + /* GPIO register base address */ 136 + #define RC5T583_GPIO_IOSEL 0xA0 137 + #define RC5T583_GPIO_PDEN 0xA1 138 + #define RC5T583_GPIO_IOOUT 0xA2 139 + #define RC5T583_GPIO_PGSEL 0xA3 140 + #define RC5T583_GPIO_GPINV 0xA4 141 + #define RC5T583_GPIO_GPDEB 0xA5 142 + #define RC5T583_GPIO_GPEDGE1 0xA6 143 + #define RC5T583_GPIO_GPEDGE2 0xA7 144 + #define RC5T583_GPIO_EN_INT 0xA8 145 + #define RC5T583_GPIO_MON_IOIN 0xAB 146 + #define RC5T583_GPIO_GPOFUNC 0xAC 147 + 148 + /* RICOH_RC5T583 IRQ definitions */ 149 + enum { 150 + RC5T583_IRQ_ONKEY, 151 + RC5T583_IRQ_ACOK, 152 + RC5T583_IRQ_LIDOPEN, 153 + RC5T583_IRQ_PREOT, 154 + RC5T583_IRQ_CLKSTP, 155 + RC5T583_IRQ_ONKEY_OFF, 156 + RC5T583_IRQ_WD, 157 + RC5T583_IRQ_EN_PWRREQ1, 158 + RC5T583_IRQ_EN_PWRREQ2, 159 + RC5T583_IRQ_PRE_VINDET, 160 + 161 + RC5T583_IRQ_DC0LIM, 162 + RC5T583_IRQ_DC1LIM, 163 + RC5T583_IRQ_DC2LIM, 164 + RC5T583_IRQ_DC3LIM, 165 + 166 + RC5T583_IRQ_CTC, 167 + RC5T583_IRQ_YALE, 168 + RC5T583_IRQ_DALE, 169 + RC5T583_IRQ_WALE, 170 + 171 + RC5T583_IRQ_AIN1L, 172 + RC5T583_IRQ_AIN2L, 173 + RC5T583_IRQ_AIN3L, 174 + RC5T583_IRQ_VBATL, 175 + RC5T583_IRQ_VIN3L, 176 + RC5T583_IRQ_VIN8L, 177 + RC5T583_IRQ_AIN1H, 178 + RC5T583_IRQ_AIN2H, 179 + RC5T583_IRQ_AIN3H, 180 + RC5T583_IRQ_VBATH, 181 + RC5T583_IRQ_VIN3H, 182 + RC5T583_IRQ_VIN8H, 183 + RC5T583_IRQ_ADCEND, 184 + 185 + RC5T583_IRQ_GPIO0, 186 + RC5T583_IRQ_GPIO1, 187 + RC5T583_IRQ_GPIO2, 188 + RC5T583_IRQ_GPIO3, 189 + RC5T583_IRQ_GPIO4, 190 + RC5T583_IRQ_GPIO5, 191 + RC5T583_IRQ_GPIO6, 192 + RC5T583_IRQ_GPIO7, 193 + 194 + /* Should be last entry */ 195 + RC5T583_MAX_IRQS, 196 + }; 197 + 198 + /* Ricoh583 gpio definitions */ 199 + enum { 200 + RC5T583_GPIO0, 201 + RC5T583_GPIO1, 202 + RC5T583_GPIO2, 203 + RC5T583_GPIO3, 204 + RC5T583_GPIO4, 205 + RC5T583_GPIO5, 206 + RC5T583_GPIO6, 207 + RC5T583_GPIO7, 208 + 209 + /* Should be last entry */ 210 + RC5T583_MAX_GPIO, 211 + }; 212 + 213 + enum { 214 + RC5T583_DS_NONE, 215 + RC5T583_DS_DC0, 216 + RC5T583_DS_DC1, 217 + RC5T583_DS_DC2, 218 + RC5T583_DS_DC3, 219 + RC5T583_DS_LDO0, 220 + RC5T583_DS_LDO1, 221 + RC5T583_DS_LDO2, 222 + RC5T583_DS_LDO3, 223 + RC5T583_DS_LDO4, 224 + RC5T583_DS_LDO5, 225 + RC5T583_DS_LDO6, 226 + RC5T583_DS_LDO7, 227 + RC5T583_DS_LDO8, 228 + RC5T583_DS_LDO9, 229 + RC5T583_DS_PSO0, 230 + RC5T583_DS_PSO1, 231 + RC5T583_DS_PSO2, 232 + RC5T583_DS_PSO3, 233 + RC5T583_DS_PSO4, 234 + RC5T583_DS_PSO5, 235 + RC5T583_DS_PSO6, 236 + RC5T583_DS_PSO7, 237 + 238 + /* Should be last entry */ 239 + RC5T583_DS_MAX, 240 + }; 241 + 242 + /* 243 + * Ricoh pmic RC5T583 supports sleep through two external controls. 244 + * The output of gpios and regulator can be enable/disable through 245 + * this external signals. 246 + */ 247 + enum { 248 + RC5T583_EXT_PWRREQ1_CONTROL = 0x1, 249 + RC5T583_EXT_PWRREQ2_CONTROL = 0x2, 250 + }; 251 + 252 + struct rc5t583 { 253 + struct device *dev; 254 + struct regmap *regmap; 255 + int chip_irq; 256 + int irq_base; 257 + struct mutex irq_lock; 258 + unsigned long group_irq_en[MAX_MAIN_INTERRUPT]; 259 + 260 + /* For main interrupt bits in INTC */ 261 + uint8_t intc_inten_reg; 262 + 263 + /* For group interrupt bits and address */ 264 + uint8_t irq_en_reg[RC5T583_MAX_INTERRUPT_MASK_REGS]; 265 + 266 + /* For gpio edge */ 267 + uint8_t gpedge_reg[RC5T583_MAX_GPEDGE_REG]; 268 + }; 269 + 270 + /* 271 + * rc5t583_platform_data: Platform data for ricoh rc5t583 pmu. 272 + * The board specific data is provided through this structure. 273 + * @irq_base: Irq base number on which this device registers their interrupts. 274 + * @enable_shutdown: Enable shutdown through the input pin "shutdown". 275 + */ 276 + 277 + struct rc5t583_platform_data { 278 + int irq_base; 279 + bool enable_shutdown; 280 + }; 281 + 282 + int rc5t583_write(struct device *dev, u8 reg, uint8_t val); 283 + int rc5t583_read(struct device *dev, uint8_t reg, uint8_t *val); 284 + int rc5t583_set_bits(struct device *dev, unsigned int reg, 285 + unsigned int bit_mask); 286 + int rc5t583_clear_bits(struct device *dev, unsigned int reg, 287 + unsigned int bit_mask); 288 + int rc5t583_update(struct device *dev, unsigned int reg, 289 + unsigned int val, unsigned int mask); 290 + int rc5t583_ext_power_req_config(struct device *dev, int deepsleep_id, 291 + int ext_pwr_req, int deepsleep_slot_nr); 292 + int rc5t583_irq_init(struct rc5t583 *rc5t583, int irq, int irq_base); 293 + int rc5t583_irq_exit(struct rc5t583 *rc5t583); 294 + 295 + #endif
+1
include/linux/mfd/stmpe.h
··· 28 28 STMPE1601, 29 29 STMPE2401, 30 30 STMPE2403, 31 + STMPE_NBR_PARTS 31 32 }; 32 33 33 34 /*
+46
include/linux/mfd/tps65090.h
··· 1 + /* 2 + * Core driver interface for TI TPS65090 PMIC family 3 + * 4 + * Copyright (C) 2012 NVIDIA Corporation 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, but WITHOUT 12 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 + * more details. 15 + * 16 + * You should have received a copy of the GNU General Public License along 17 + * with this program; if not, write to the Free Software Foundation, Inc., 18 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 + * 20 + */ 21 + 22 + #ifndef __LINUX_MFD_TPS65090_H 23 + #define __LINUX_MFD_TPS65090_H 24 + 25 + struct tps65090_subdev_info { 26 + int id; 27 + const char *name; 28 + void *platform_data; 29 + }; 30 + 31 + struct tps65090_platform_data { 32 + int irq_base; 33 + int num_subdevs; 34 + struct tps65090_subdev_info *subdevs; 35 + }; 36 + 37 + /* 38 + * NOTE: the functions below are not intended for use outside 39 + * of the TPS65090 sub-device drivers 40 + */ 41 + extern int tps65090_write(struct device *dev, int reg, uint8_t val); 42 + extern int tps65090_read(struct device *dev, int reg, uint8_t *val); 43 + extern int tps65090_set_bits(struct device *dev, int reg, uint8_t bit_num); 44 + extern int tps65090_clr_bits(struct device *dev, int reg, uint8_t bit_num); 45 + 46 + #endif /*__LINUX_MFD_TPS65090_H */
+283
include/linux/mfd/tps65217.h
··· 1 + /* 2 + * linux/mfd/tps65217.h 3 + * 4 + * Functions to access TPS65217 power management chip. 5 + * 6 + * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License as 10 + * published by the Free Software Foundation version 2. 11 + * 12 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 13 + * kind, whether express or implied; without even the implied warranty 14 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + */ 17 + 18 + #ifndef __LINUX_MFD_TPS65217_H 19 + #define __LINUX_MFD_TPS65217_H 20 + 21 + #include <linux/i2c.h> 22 + #include <linux/regulator/driver.h> 23 + #include <linux/regulator/machine.h> 24 + 25 + /* I2C ID for TPS65217 part */ 26 + #define TPS65217_I2C_ID 0x24 27 + 28 + /* All register addresses */ 29 + #define TPS65217_REG_CHIPID 0X00 30 + #define TPS65217_REG_PPATH 0X01 31 + #define TPS65217_REG_INT 0X02 32 + #define TPS65217_REG_CHGCONFIG0 0X03 33 + #define TPS65217_REG_CHGCONFIG1 0X04 34 + #define TPS65217_REG_CHGCONFIG2 0X05 35 + #define TPS65217_REG_CHGCONFIG3 0X06 36 + #define TPS65217_REG_WLEDCTRL1 0X07 37 + #define TPS65217_REG_WLEDCTRL2 0X08 38 + #define TPS65217_REG_MUXCTRL 0X09 39 + #define TPS65217_REG_STATUS 0X0A 40 + #define TPS65217_REG_PASSWORD 0X0B 41 + #define TPS65217_REG_PGOOD 0X0C 42 + #define TPS65217_REG_DEFPG 0X0D 43 + #define TPS65217_REG_DEFDCDC1 0X0E 44 + #define TPS65217_REG_DEFDCDC2 0X0F 45 + #define TPS65217_REG_DEFDCDC3 0X10 46 + #define TPS65217_REG_DEFSLEW 0X11 47 + #define TPS65217_REG_DEFLDO1 0X12 48 + #define TPS65217_REG_DEFLDO2 0X13 49 + #define TPS65217_REG_DEFLS1 0X14 50 + #define TPS65217_REG_DEFLS2 0X15 51 + #define TPS65217_REG_ENABLE 0X16 52 + #define TPS65217_REG_DEFUVLO 0X18 53 + #define TPS65217_REG_SEQ1 0X19 54 + #define TPS65217_REG_SEQ2 0X1A 55 + #define TPS65217_REG_SEQ3 0X1B 56 + #define TPS65217_REG_SEQ4 0X1C 57 + #define TPS65217_REG_SEQ5 0X1D 58 + #define TPS65217_REG_SEQ6 0X1E 59 + 60 + /* Register field definitions */ 61 + #define TPS65217_CHIPID_CHIP_MASK 0xF0 62 + #define TPS65217_CHIPID_REV_MASK 0x0F 63 + 64 + #define TPS65217_PPATH_ACSINK_ENABLE BIT(7) 65 + #define TPS65217_PPATH_USBSINK_ENABLE BIT(6) 66 + #define TPS65217_PPATH_AC_PW_ENABLE BIT(5) 67 + #define TPS65217_PPATH_USB_PW_ENABLE BIT(4) 68 + #define TPS65217_PPATH_AC_CURRENT_MASK 0x0C 69 + #define TPS65217_PPATH_USB_CURRENT_MASK 0x03 70 + 71 + #define TPS65217_INT_PBM BIT(6) 72 + #define TPS65217_INT_ACM BIT(5) 73 + #define TPS65217_INT_USBM BIT(4) 74 + #define TPS65217_INT_PBI BIT(2) 75 + #define TPS65217_INT_ACI BIT(1) 76 + #define TPS65217_INT_USBI BIT(0) 77 + 78 + #define TPS65217_CHGCONFIG0_TREG BIT(7) 79 + #define TPS65217_CHGCONFIG0_DPPM BIT(6) 80 + #define TPS65217_CHGCONFIG0_TSUSP BIT(5) 81 + #define TPS65217_CHGCONFIG0_TERMI BIT(4) 82 + #define TPS65217_CHGCONFIG0_ACTIVE BIT(3) 83 + #define TPS65217_CHGCONFIG0_CHGTOUT BIT(2) 84 + #define TPS65217_CHGCONFIG0_PCHGTOUT BIT(1) 85 + #define TPS65217_CHGCONFIG0_BATTEMP BIT(0) 86 + 87 + #define TPS65217_CHGCONFIG1_TMR_MASK 0xC0 88 + #define TPS65217_CHGCONFIG1_TMR_ENABLE BIT(5) 89 + #define TPS65217_CHGCONFIG1_NTC_TYPE BIT(4) 90 + #define TPS65217_CHGCONFIG1_RESET BIT(3) 91 + #define TPS65217_CHGCONFIG1_TERM BIT(2) 92 + #define TPS65217_CHGCONFIG1_SUSP BIT(1) 93 + #define TPS65217_CHGCONFIG1_CHG_EN BIT(0) 94 + 95 + #define TPS65217_CHGCONFIG2_DYNTMR BIT(7) 96 + #define TPS65217_CHGCONFIG2_VPREGHG BIT(6) 97 + #define TPS65217_CHGCONFIG2_VOREG_MASK 0x30 98 + 99 + #define TPS65217_CHGCONFIG3_ICHRG_MASK 0xC0 100 + #define TPS65217_CHGCONFIG3_DPPMTH_MASK 0x30 101 + #define TPS65217_CHGCONFIG2_PCHRGT BIT(3) 102 + #define TPS65217_CHGCONFIG2_TERMIF 0x06 103 + #define TPS65217_CHGCONFIG2_TRANGE BIT(0) 104 + 105 + #define TPS65217_WLEDCTRL1_ISINK_ENABLE BIT(3) 106 + #define TPS65217_WLEDCTRL1_ISEL BIT(2) 107 + #define TPS65217_WLEDCTRL1_FDIM_MASK 0x03 108 + 109 + #define TPS65217_WLEDCTRL2_DUTY_MASK 0x7F 110 + 111 + #define TPS65217_MUXCTRL_MUX_MASK 0x07 112 + 113 + #define TPS65217_STATUS_OFF BIT(7) 114 + #define TPS65217_STATUS_ACPWR BIT(3) 115 + #define TPS65217_STATUS_USBPWR BIT(2) 116 + #define TPS65217_STATUS_PB BIT(0) 117 + 118 + #define TPS65217_PASSWORD_REGS_UNLOCK 0x7D 119 + 120 + #define TPS65217_PGOOD_LDO3_PG BIT(6) 121 + #define TPS65217_PGOOD_LDO4_PG BIT(5) 122 + #define TPS65217_PGOOD_DC1_PG BIT(4) 123 + #define TPS65217_PGOOD_DC2_PG BIT(3) 124 + #define TPS65217_PGOOD_DC3_PG BIT(2) 125 + #define TPS65217_PGOOD_LDO1_PG BIT(1) 126 + #define TPS65217_PGOOD_LDO2_PG BIT(0) 127 + 128 + #define TPS65217_DEFPG_LDO1PGM BIT(3) 129 + #define TPS65217_DEFPG_LDO2PGM BIT(2) 130 + #define TPS65217_DEFPG_PGDLY_MASK 0x03 131 + 132 + #define TPS65217_DEFDCDCX_XADJX BIT(7) 133 + #define TPS65217_DEFDCDCX_DCDC_MASK 0x3F 134 + 135 + #define TPS65217_DEFSLEW_GO BIT(7) 136 + #define TPS65217_DEFSLEW_GODSBL BIT(6) 137 + #define TPS65217_DEFSLEW_PFM_EN1 BIT(5) 138 + #define TPS65217_DEFSLEW_PFM_EN2 BIT(4) 139 + #define TPS65217_DEFSLEW_PFM_EN3 BIT(3) 140 + #define TPS65217_DEFSLEW_SLEW_MASK 0x07 141 + 142 + #define TPS65217_DEFLDO1_LDO1_MASK 0x0F 143 + 144 + #define TPS65217_DEFLDO2_TRACK BIT(6) 145 + #define TPS65217_DEFLDO2_LDO2_MASK 0x3F 146 + 147 + #define TPS65217_DEFLDO3_LDO3_EN BIT(5) 148 + #define TPS65217_DEFLDO3_LDO3_MASK 0x1F 149 + 150 + #define TPS65217_DEFLDO4_LDO4_EN BIT(5) 151 + #define TPS65217_DEFLDO4_LDO4_MASK 0x1F 152 + 153 + #define TPS65217_ENABLE_LS1_EN BIT(6) 154 + #define TPS65217_ENABLE_LS2_EN BIT(5) 155 + #define TPS65217_ENABLE_DC1_EN BIT(4) 156 + #define TPS65217_ENABLE_DC2_EN BIT(3) 157 + #define TPS65217_ENABLE_DC3_EN BIT(2) 158 + #define TPS65217_ENABLE_LDO1_EN BIT(1) 159 + #define TPS65217_ENABLE_LDO2_EN BIT(0) 160 + 161 + #define TPS65217_DEFUVLO_UVLOHYS BIT(2) 162 + #define TPS65217_DEFUVLO_UVLO_MASK 0x03 163 + 164 + #define TPS65217_SEQ1_DC1_SEQ_MASK 0xF0 165 + #define TPS65217_SEQ1_DC2_SEQ_MASK 0x0F 166 + 167 + #define TPS65217_SEQ2_DC3_SEQ_MASK 0xF0 168 + #define TPS65217_SEQ2_LDO1_SEQ_MASK 0x0F 169 + 170 + #define TPS65217_SEQ3_LDO2_SEQ_MASK 0xF0 171 + #define TPS65217_SEQ3_LDO3_SEQ_MASK 0x0F 172 + 173 + #define TPS65217_SEQ4_LDO4_SEQ_MASK 0xF0 174 + 175 + #define TPS65217_SEQ5_DLY1_MASK 0xC0 176 + #define TPS65217_SEQ5_DLY2_MASK 0x30 177 + #define TPS65217_SEQ5_DLY3_MASK 0x0C 178 + #define TPS65217_SEQ5_DLY4_MASK 0x03 179 + 180 + #define TPS65217_SEQ6_DLY5_MASK 0xC0 181 + #define TPS65217_SEQ6_DLY6_MASK 0x30 182 + #define TPS65217_SEQ6_SEQUP BIT(2) 183 + #define TPS65217_SEQ6_SEQDWN BIT(1) 184 + #define TPS65217_SEQ6_INSTDWN BIT(0) 185 + 186 + #define TPS65217_MAX_REGISTER 0x1E 187 + #define TPS65217_PROTECT_NONE 0 188 + #define TPS65217_PROTECT_L1 1 189 + #define TPS65217_PROTECT_L2 2 190 + 191 + 192 + enum tps65217_regulator_id { 193 + /* DCDC's */ 194 + TPS65217_DCDC_1, 195 + TPS65217_DCDC_2, 196 + TPS65217_DCDC_3, 197 + /* LDOs */ 198 + TPS65217_LDO_1, 199 + TPS65217_LDO_2, 200 + TPS65217_LDO_3, 201 + TPS65217_LDO_4, 202 + }; 203 + 204 + #define TPS65217_MAX_REG_ID TPS65217_LDO_4 205 + 206 + /* Number of step-down converters available */ 207 + #define TPS65217_NUM_DCDC 3 208 + /* Number of LDO voltage regulators available */ 209 + #define TPS65217_NUM_LDO 4 210 + /* Number of total regulators available */ 211 + #define TPS65217_NUM_REGULATOR (TPS65217_NUM_DCDC + TPS65217_NUM_LDO) 212 + 213 + /** 214 + * struct tps65217_board - packages regulator init data 215 + * @tps65217_regulator_data: regulator initialization values 216 + * 217 + * Board data may be used to initialize regulator. 218 + */ 219 + struct tps65217_board { 220 + struct regulator_init_data *tps65217_init_data; 221 + }; 222 + 223 + /** 224 + * struct tps_info - packages regulator constraints 225 + * @name: Voltage regulator name 226 + * @min_uV: minimum micro volts 227 + * @max_uV: minimum micro volts 228 + * @vsel_to_uv: Function pointer to get voltage from selector 229 + * @uv_to_vsel: Function pointer to get selector from voltage 230 + * @table: Table for non-uniform voltage step-size 231 + * @table_len: Length of the voltage table 232 + * @enable_mask: Regulator enable mask bits 233 + * @set_vout_reg: Regulator output voltage set register 234 + * @set_vout_mask: Regulator output voltage set mask 235 + * 236 + * This data is used to check the regualtor voltage limits while setting. 237 + */ 238 + struct tps_info { 239 + const char *name; 240 + int min_uV; 241 + int max_uV; 242 + int (*vsel_to_uv)(unsigned int vsel); 243 + int (*uv_to_vsel)(int uV, unsigned int *vsel); 244 + const int *table; 245 + unsigned int table_len; 246 + unsigned int enable_mask; 247 + unsigned int set_vout_reg; 248 + unsigned int set_vout_mask; 249 + }; 250 + 251 + /** 252 + * struct tps65217 - tps65217 sub-driver chip access routines 253 + * 254 + * Device data may be used to access the TPS65217 chip 255 + */ 256 + 257 + struct tps65217 { 258 + struct device *dev; 259 + struct tps65217_board *pdata; 260 + struct regulator_desc desc[TPS65217_NUM_REGULATOR]; 261 + struct regulator_dev *rdev[TPS65217_NUM_REGULATOR]; 262 + struct tps_info *info[TPS65217_NUM_REGULATOR]; 263 + struct regmap *regmap; 264 + 265 + /* Client devices */ 266 + struct platform_device *regulator_pdev[TPS65217_NUM_REGULATOR]; 267 + }; 268 + 269 + static inline struct tps65217 *dev_to_tps65217(struct device *dev) 270 + { 271 + return dev_get_drvdata(dev); 272 + } 273 + 274 + int tps65217_reg_read(struct tps65217 *tps, unsigned int reg, 275 + unsigned int *val); 276 + int tps65217_reg_write(struct tps65217 *tps, unsigned int reg, 277 + unsigned int val, unsigned int level); 278 + int tps65217_set_bits(struct tps65217 *tps, unsigned int reg, 279 + unsigned int mask, unsigned int val, unsigned int level); 280 + int tps65217_clear_bits(struct tps65217 *tps, unsigned int reg, 281 + unsigned int mask, unsigned int level); 282 + 283 + #endif /* __LINUX_MFD_TPS65217_H */
+3
include/linux/mfd/tps65910.h
··· 17 17 #ifndef __LINUX_MFD_TPS65910_H 18 18 #define __LINUX_MFD_TPS65910_H 19 19 20 + #include <linux/gpio.h> 21 + 20 22 /* TPS chip id list */ 21 23 #define TPS65910 0 22 24 #define TPS65911 1 ··· 798 796 struct tps65910 { 799 797 struct device *dev; 800 798 struct i2c_client *i2c_client; 799 + struct regmap *regmap; 801 800 struct mutex io_mutex; 802 801 unsigned int id; 803 802 int (*read)(struct tps65910 *tps65910, u8 reg, int size, void *dest);
-1
include/linux/mfd/wm8994/pdata.h
··· 22 22 /** GPIOs to enable regulator, 0 or less if not available */ 23 23 int enable; 24 24 25 - const char *supply; 26 25 const struct regulator_init_data *init_data; 27 26 }; 28 27
+69 -1
include/linux/regulator/ab8500.h
··· 26 26 AB8500_NUM_REGULATORS, 27 27 }; 28 28 29 - /* AB8500 register initialization */ 29 + /* AB9450 regulators */ 30 + enum ab9540_regulator_id { 31 + AB9540_LDO_AUX1, 32 + AB9540_LDO_AUX2, 33 + AB9540_LDO_AUX3, 34 + AB9540_LDO_AUX4, 35 + AB9540_LDO_INTCORE, 36 + AB9540_LDO_TVOUT, 37 + AB9540_LDO_USB, 38 + AB9540_LDO_AUDIO, 39 + AB9540_LDO_ANAMIC1, 40 + AB9540_LDO_ANAMIC2, 41 + AB9540_LDO_DMIC, 42 + AB9540_LDO_ANA, 43 + AB9540_SYSCLKREQ_2, 44 + AB9540_SYSCLKREQ_4, 45 + AB9540_NUM_REGULATORS, 46 + }; 47 + 48 + /* AB8500 and AB9540 register initialization */ 30 49 struct ab8500_regulator_reg_init { 31 50 int id; 32 51 u8 value; ··· 88 69 AB8500_REGUCTRLDISCH2, 89 70 AB8500_VSMPS1SEL1, 90 71 AB8500_NUM_REGULATOR_REGISTERS, 72 + }; 73 + 74 + 75 + /* AB9540 registers */ 76 + enum ab9540_regulator_reg { 77 + AB9540_REGUREQUESTCTRL1, 78 + AB9540_REGUREQUESTCTRL2, 79 + AB9540_REGUREQUESTCTRL3, 80 + AB9540_REGUREQUESTCTRL4, 81 + AB9540_REGUSYSCLKREQ1HPVALID1, 82 + AB9540_REGUSYSCLKREQ1HPVALID2, 83 + AB9540_REGUHWHPREQ1VALID1, 84 + AB9540_REGUHWHPREQ1VALID2, 85 + AB9540_REGUHWHPREQ2VALID1, 86 + AB9540_REGUHWHPREQ2VALID2, 87 + AB9540_REGUSWHPREQVALID1, 88 + AB9540_REGUSWHPREQVALID2, 89 + AB9540_REGUSYSCLKREQVALID1, 90 + AB9540_REGUSYSCLKREQVALID2, 91 + AB9540_REGUVAUX4REQVALID, 92 + AB9540_REGUMISC1, 93 + AB9540_VAUDIOSUPPLY, 94 + AB9540_REGUCTRL1VAMIC, 95 + AB9540_VSMPS1REGU, 96 + AB9540_VSMPS2REGU, 97 + AB9540_VSMPS3REGU, /* NOTE! PRCMU register */ 98 + AB9540_VPLLVANAREGU, 99 + AB9540_EXTSUPPLYREGU, 100 + AB9540_VAUX12REGU, 101 + AB9540_VRF1VAUX3REGU, 102 + AB9540_VSMPS1SEL1, 103 + AB9540_VSMPS1SEL2, 104 + AB9540_VSMPS1SEL3, 105 + AB9540_VSMPS2SEL1, 106 + AB9540_VSMPS2SEL2, 107 + AB9540_VSMPS2SEL3, 108 + AB9540_VSMPS3SEL1, /* NOTE! PRCMU register */ 109 + AB9540_VSMPS3SEL2, /* NOTE! PRCMU register */ 110 + AB9540_VAUX1SEL, 111 + AB9540_VAUX2SEL, 112 + AB9540_VRF1VAUX3SEL, 113 + AB9540_REGUCTRL2SPARE, 114 + AB9540_VAUX4REQCTRL, 115 + AB9540_VAUX4REGU, 116 + AB9540_VAUX4SEL, 117 + AB9540_REGUCTRLDISCH, 118 + AB9540_REGUCTRLDISCH2, 119 + AB9540_REGUCTRLDISCH3, 120 + AB9540_NUM_REGULATOR_REGISTERS, 91 121 }; 92 122 93 123 #endif