Skip to content

Commit 4267976

Browse files
rmurphy-armLee Jones
authored andcommitted
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 <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 7a52cbc commit 4267976

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

drivers/mfd/rk808.c

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ static const struct rk808_reg_data rk805_pre_init_reg[] = {
185185
{RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK,
186186
RK805_BUCK4_ILMAX_3500MA},
187187
{RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA},
188-
{RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN},
189188
{RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C},
190189
};
191190

@@ -448,21 +447,6 @@ static const struct regmap_irq_chip rk818_irq_chip = {
448447

449448
static struct i2c_client *rk808_i2c_client;
450449

451-
static void rk805_device_shutdown_prepare(void)
452-
{
453-
int ret;
454-
struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
455-
456-
if (!rk808)
457-
return;
458-
459-
ret = regmap_update_bits(rk808->regmap,
460-
RK805_GPIO_IO_POL_REG,
461-
SLP_SD_MSK, SHUTDOWN_FUN);
462-
if (ret)
463-
dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n");
464-
}
465-
466450
static void rk808_pm_power_off(void)
467451
{
468452
int ret;
@@ -496,6 +480,12 @@ static void rk8xx_shutdown(struct i2c_client *client)
496480
int ret;
497481

498482
switch (rk808->variant) {
483+
case RK805_ID:
484+
ret = regmap_update_bits(rk808->regmap,
485+
RK805_GPIO_IO_POL_REG,
486+
SLP_SD_MSK,
487+
SHUTDOWN_FUN);
488+
break;
499489
case RK809_ID:
500490
case RK817_ID:
501491
ret = regmap_update_bits(rk808->regmap,
@@ -574,7 +564,6 @@ static int rk808_probe(struct i2c_client *client,
574564
nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
575565
cells = rk805s;
576566
nr_cells = ARRAY_SIZE(rk805s);
577-
rk808->pm_pwroff_prep_fn = rk805_device_shutdown_prepare;
578567
break;
579568
case RK808_ID:
580569
rk808->regmap_cfg = &rk808_regmap_config;
@@ -653,7 +642,6 @@ static int rk808_probe(struct i2c_client *client,
653642
if (of_property_read_bool(np, "rockchip,system-power-controller")) {
654643
rk808_i2c_client = client;
655644
pm_power_off = rk808_pm_power_off;
656-
pm_power_off_prepare = rk808->pm_pwroff_prep_fn;
657645
}
658646

659647
return 0;
@@ -676,13 +664,6 @@ static int rk808_remove(struct i2c_client *client)
676664
if (pm_power_off == rk808_pm_power_off)
677665
pm_power_off = NULL;
678666

679-
/**
680-
* As above, check if the pointer is set by us before overwrite.
681-
*/
682-
if (rk808->pm_pwroff_prep_fn &&
683-
pm_power_off_prepare == rk808->pm_pwroff_prep_fn)
684-
pm_power_off_prepare = NULL;
685-
686667
return 0;
687668
}
688669

@@ -692,6 +673,12 @@ static int __maybe_unused rk8xx_suspend(struct device *dev)
692673
int ret = 0;
693674

694675
switch (rk808->variant) {
676+
case RK805_ID:
677+
ret = regmap_update_bits(rk808->regmap,
678+
RK805_GPIO_IO_POL_REG,
679+
SLP_SD_MSK,
680+
SLEEP_FUN);
681+
break;
695682
case RK809_ID:
696683
case RK817_ID:
697684
ret = regmap_update_bits(rk808->regmap,

include/linux/mfd/rk808.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,5 @@ struct rk808 {
620620
long variant;
621621
const struct regmap_config *regmap_cfg;
622622
const struct regmap_irq_chip *regmap_irq_chip;
623-
void (*pm_pwroff_prep_fn)(void);
624623
};
625624
#endif /* __LINUX_REGULATOR_RK808_H */

0 commit comments

Comments
 (0)