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

mfd: rk808: Convert RK805 to shutdown/suspend hooks

RK805 has the same kind of dual-role sleep/shutdown pin as RK809/RK817,
so it makes little sense for the driver to have to have two completely
different mechanisms to handle essentially the same thing. Move RK805
over to the shutdown/suspend flow to clean things up.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Robin Murphy and committed by
Lee Jones
42679765 7a52cbcc

+12 -26
+12 -25
drivers/mfd/rk808.c
··· 185 185 {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK, 186 186 RK805_BUCK4_ILMAX_3500MA}, 187 187 {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA}, 188 - {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN}, 189 188 {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C}, 190 189 }; 191 190 ··· 447 448 448 449 static struct i2c_client *rk808_i2c_client; 449 450 450 - static void rk805_device_shutdown_prepare(void) 451 - { 452 - int ret; 453 - struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); 454 - 455 - if (!rk808) 456 - return; 457 - 458 - ret = regmap_update_bits(rk808->regmap, 459 - RK805_GPIO_IO_POL_REG, 460 - SLP_SD_MSK, SHUTDOWN_FUN); 461 - if (ret) 462 - dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n"); 463 - } 464 - 465 451 static void rk808_pm_power_off(void) 466 452 { 467 453 int ret; ··· 480 496 int ret; 481 497 482 498 switch (rk808->variant) { 499 + case RK805_ID: 500 + ret = regmap_update_bits(rk808->regmap, 501 + RK805_GPIO_IO_POL_REG, 502 + SLP_SD_MSK, 503 + SHUTDOWN_FUN); 504 + break; 483 505 case RK809_ID: 484 506 case RK817_ID: 485 507 ret = regmap_update_bits(rk808->regmap, ··· 564 574 nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg); 565 575 cells = rk805s; 566 576 nr_cells = ARRAY_SIZE(rk805s); 567 - rk808->pm_pwroff_prep_fn = rk805_device_shutdown_prepare; 568 577 break; 569 578 case RK808_ID: 570 579 rk808->regmap_cfg = &rk808_regmap_config; ··· 642 653 if (of_property_read_bool(np, "rockchip,system-power-controller")) { 643 654 rk808_i2c_client = client; 644 655 pm_power_off = rk808_pm_power_off; 645 - pm_power_off_prepare = rk808->pm_pwroff_prep_fn; 646 656 } 647 657 648 658 return 0; ··· 664 676 if (pm_power_off == rk808_pm_power_off) 665 677 pm_power_off = NULL; 666 678 667 - /** 668 - * As above, check if the pointer is set by us before overwrite. 669 - */ 670 - if (rk808->pm_pwroff_prep_fn && 671 - pm_power_off_prepare == rk808->pm_pwroff_prep_fn) 672 - pm_power_off_prepare = NULL; 673 - 674 679 return 0; 675 680 } 676 681 ··· 673 692 int ret = 0; 674 693 675 694 switch (rk808->variant) { 695 + case RK805_ID: 696 + ret = regmap_update_bits(rk808->regmap, 697 + RK805_GPIO_IO_POL_REG, 698 + SLP_SD_MSK, 699 + SLEEP_FUN); 700 + break; 676 701 case RK809_ID: 677 702 case RK817_ID: 678 703 ret = regmap_update_bits(rk808->regmap,
-1
include/linux/mfd/rk808.h
··· 620 620 long variant; 621 621 const struct regmap_config *regmap_cfg; 622 622 const struct regmap_irq_chip *regmap_irq_chip; 623 - void (*pm_pwroff_prep_fn)(void); 624 623 }; 625 624 #endif /* __LINUX_REGULATOR_RK808_H */