| @@ -9,6 +9,7 @@ · 8 unmodified lines |
| 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> |
| @@ -81,7 +82,7 @@ static struct irq_chip mt6397_irq_chip = { · 66 unmodified lines |
| 81 | 82 | static void mt6397_irq_handle_reg(struct mt6397_chip *mt6397, int reg, |
| 82 | 83 | int irqbase) |
| 83 | 84 | { |
| 84 | | − unsigned int status; |
| 85 | + unsigned int status = 0; |
| 85 | 86 | int i, irq, ret; |
| 86 | 87 | |
| 87 | 88 | ret = regmap_read(mt6397->regmap, reg, &status); |
| @@ -128,6 +129,36 @@ static const struct irq_domain_ops mt6397_irq_domain_ops = { · 40 unmodified lines |
| 128 | 129 | .map = mt6397_irq_domain_map, |
| 129 | 130 | }; |
| 130 | 131 | |
| 132 | +static int mt6397_irq_pm_notifier(struct notifier_block *notifier, |
| 133 | + unsigned long pm_event, void *unused) |
| 134 | +{ |
| 135 | + struct mt6397_chip *chip = |
| 136 | + container_of(notifier, struct mt6397_chip, pm_nb); |
| 137 | + |
| 138 | + switch (pm_event) { |
| 139 | + case PM_SUSPEND_PREPARE: |
| 140 | + regmap_write(chip->regmap, |
| 141 | + chip->int_con[0], chip->wake_mask[0]); |
| 142 | + regmap_write(chip->regmap, |
| 143 | + chip->int_con[1], chip->wake_mask[1]); |
| 144 | + enable_irq_wake(chip->irq); |
| 145 | + break; |
| 146 | + |
| 147 | + case PM_POST_SUSPEND: |
| 148 | + regmap_write(chip->regmap, |
| 149 | + chip->int_con[0], chip->irq_masks_cur[0]); |
| 150 | + regmap_write(chip->regmap, |
| 151 | + chip->int_con[1], chip->irq_masks_cur[1]); |
| 152 | + disable_irq_wake(chip->irq); |
| 153 | + break; |
| 154 | + |
| 155 | + default: |
| 156 | + break; |
| 157 | + } |
| 158 | + |
| 159 | + return NOTIFY_DONE; |
| 160 | +} |
| 161 | + |
| 131 | 162 | int mt6397_irq_init(struct mt6397_chip *chip) |
| 132 | 163 | { |
| 133 | 164 | int ret; |
| @@ -159,6 +190,7 @@ int mt6397_irq_init(struct mt6397_chip *chip) · 25 unmodified lines |
| 159 | 190 | regmap_write(chip->regmap, chip->int_con[0], 0x0); |
| 160 | 191 | regmap_write(chip->regmap, chip->int_con[1], 0x0); |
| 161 | 192 | |
| 193 | + chip->pm_nb.notifier_call = mt6397_irq_pm_notifier; |
| 162 | 194 | chip->irq_domain = irq_domain_add_linear(chip->dev->of_node, |
| 163 | 195 | MT6397_IRQ_NR, |
| 164 | 196 | &mt6397_irq_domain_ops, |
| @@ -177,5 +209,6 @@ int mt6397_irq_init(struct mt6397_chip *chip) · 12 unmodified lines |
| 177 | 209 | return ret; |
| 178 | 210 | } |
| 179 | 211 | |
| 212 | + register_pm_notifier(&chip->pm_nb); |
| 180 | 213 | return 0; |
| 181 | 214 | } |