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

mfd: mt6397: Modify suspend/resume behavior

Some pmics don't need backup interrupt settings, so we change to use
pm notifier for the pmics which are necessary to store settings.

Signed-off-by: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Hsin-Hsiung Wang and committed by
Lee Jones
4e2e7cfe 8f3d9f35

+36 -31
-30
drivers/mfd/mt6397-core.c
··· 100 100 } 101 101 }; 102 102 103 - #ifdef CONFIG_PM_SLEEP 104 - static int mt6397_irq_suspend(struct device *dev) 105 - { 106 - struct mt6397_chip *chip = dev_get_drvdata(dev); 107 - 108 - regmap_write(chip->regmap, chip->int_con[0], chip->wake_mask[0]); 109 - regmap_write(chip->regmap, chip->int_con[1], chip->wake_mask[1]); 110 - 111 - enable_irq_wake(chip->irq); 112 - 113 - return 0; 114 - } 115 - 116 - static int mt6397_irq_resume(struct device *dev) 117 - { 118 - struct mt6397_chip *chip = dev_get_drvdata(dev); 119 - 120 - regmap_write(chip->regmap, chip->int_con[0], chip->irq_masks_cur[0]); 121 - regmap_write(chip->regmap, chip->int_con[1], chip->irq_masks_cur[1]); 122 - 123 - disable_irq_wake(chip->irq); 124 - 125 - return 0; 126 - } 127 - #endif 128 - 129 - static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend, 130 - mt6397_irq_resume); 131 - 132 103 struct chip_data { 133 104 u32 cid_addr; 134 105 u32 cid_shift; ··· 209 238 .driver = { 210 239 .name = "mt6397", 211 240 .of_match_table = of_match_ptr(mt6397_of_match), 212 - .pm = &mt6397_pm_ops, 213 241 }, 214 242 .id_table = mt6397_id, 215 243 };
+34 -1
drivers/mfd/mt6397-irq.c
··· 9 9 #include <linux/of_irq.h> 10 10 #include <linux/platform_device.h> 11 11 #include <linux/regmap.h> 12 + #include <linux/suspend.h> 12 13 #include <linux/mfd/mt6323/core.h> 13 14 #include <linux/mfd/mt6323/registers.h> 14 15 #include <linux/mfd/mt6397/core.h> ··· 82 81 static void mt6397_irq_handle_reg(struct mt6397_chip *mt6397, int reg, 83 82 int irqbase) 84 83 { 85 - unsigned int status; 84 + unsigned int status = 0; 86 85 int i, irq, ret; 87 86 88 87 ret = regmap_read(mt6397->regmap, reg, &status); ··· 129 128 .map = mt6397_irq_domain_map, 130 129 }; 131 130 131 + static int mt6397_irq_pm_notifier(struct notifier_block *notifier, 132 + unsigned long pm_event, void *unused) 133 + { 134 + struct mt6397_chip *chip = 135 + container_of(notifier, struct mt6397_chip, pm_nb); 136 + 137 + switch (pm_event) { 138 + case PM_SUSPEND_PREPARE: 139 + regmap_write(chip->regmap, 140 + chip->int_con[0], chip->wake_mask[0]); 141 + regmap_write(chip->regmap, 142 + chip->int_con[1], chip->wake_mask[1]); 143 + enable_irq_wake(chip->irq); 144 + break; 145 + 146 + case PM_POST_SUSPEND: 147 + regmap_write(chip->regmap, 148 + chip->int_con[0], chip->irq_masks_cur[0]); 149 + regmap_write(chip->regmap, 150 + chip->int_con[1], chip->irq_masks_cur[1]); 151 + disable_irq_wake(chip->irq); 152 + break; 153 + 154 + default: 155 + break; 156 + } 157 + 158 + return NOTIFY_DONE; 159 + } 160 + 132 161 int mt6397_irq_init(struct mt6397_chip *chip) 133 162 { 134 163 int ret; ··· 190 159 regmap_write(chip->regmap, chip->int_con[0], 0x0); 191 160 regmap_write(chip->regmap, chip->int_con[1], 0x0); 192 161 162 + chip->pm_nb.notifier_call = mt6397_irq_pm_notifier; 193 163 chip->irq_domain = irq_domain_add_linear(chip->dev->of_node, 194 164 MT6397_IRQ_NR, 195 165 &mt6397_irq_domain_ops, ··· 209 177 return ret; 210 178 } 211 179 180 + register_pm_notifier(&chip->pm_nb); 212 181 return 0; 213 182 }
+2
include/linux/mfd/mt6397/core.h
··· 8 8 #define __MFD_MT6397_CORE_H__ 9 9 10 10 #include <linux/mutex.h> 11 + #include <linux/notifier.h> 11 12 12 13 enum chip_id { 13 14 MT6323_CHIP_ID = 0x23, ··· 55 54 struct mt6397_chip { 56 55 struct device *dev; 57 56 struct regmap *regmap; 57 + struct notifier_block pm_nb; 58 58 int irq; 59 59 struct irq_domain *irq_domain; 60 60 struct mutex irqlock;