History

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.

Hsin-Hsiung Wang committed 6 years ago

Commit 4e2e7cf1 parent 8f3d9f33 files · +36 −31Browse files

Unified · Split

3 files
  1. drivers/mfd/mt6397-core.c +0 −30
  2. drivers/mfd/mt6397-irq.c +34 −1
  3. include/linux/mfd/mt6397/core.h +2 −0
drivers/mfd/mt6397-core.c+0−30
@@ -100,35 +100,6 @@ static const struct mfd_cell mt6397_devs[] = { · 99 unmodified lines
100 }100 }
101};101};
102 102
103#ifdef CONFIG_PM_SLEEP
104static 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
116static 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
129static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend,
130 mt6397_irq_resume);
131
132struct chip_data {103struct chip_data {
133 u32 cid_addr;104 u32 cid_addr;
134 u32 cid_shift;105 u32 cid_shift;
@@ -238,7 +209,6 @@ static struct platform_driver mt6397_driver = { · 103 unmodified lines
238 .driver = {209 .driver = {
239 .name = "mt6397",210 .name = "mt6397",
240 .of_match_table = of_match_ptr(mt6397_of_match),211 .of_match_table = of_match_ptr(mt6397_of_match),
241 .pm = &mt6397_pm_ops,
242 },212 },
243 .id_table = mt6397_id,213 .id_table = mt6397_id,
244};214};
drivers/mfd/mt6397-irq.c+34−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
9#include <linux/of_irq.h>9#include <linux/of_irq.h>
10#include <linux/platform_device.h>10#include <linux/platform_device.h>
11#include <linux/regmap.h>11#include <linux/regmap.h>
12#include <linux/suspend.h>
12#include <linux/mfd/mt6323/core.h>13#include <linux/mfd/mt6323/core.h>
13#include <linux/mfd/mt6323/registers.h>14#include <linux/mfd/mt6323/registers.h>
14#include <linux/mfd/mt6397/core.h>15#include <linux/mfd/mt6397/core.h>
@@ -81,7 +82,7 @@ static struct irq_chip mt6397_irq_chip = { · 66 unmodified lines
81static void mt6397_irq_handle_reg(struct mt6397_chip *mt6397, int reg,82static void mt6397_irq_handle_reg(struct mt6397_chip *mt6397, int reg,
82 int irqbase)83 int irqbase)
83{84{
84 unsigned int status;85 unsigned int status = 0;
85 int i, irq, ret;86 int i, irq, ret;
86 87
87 ret = regmap_read(mt6397->regmap, reg, &status);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 .map = mt6397_irq_domain_map,129 .map = mt6397_irq_domain_map,
129};130};
130 131
132static 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
131int mt6397_irq_init(struct mt6397_chip *chip)162int mt6397_irq_init(struct mt6397_chip *chip)
132{163{
133 int ret;164 int ret;
@@ -159,6 +190,7 @@ int mt6397_irq_init(struct mt6397_chip *chip) · 25 unmodified lines
159 regmap_write(chip->regmap, chip->int_con[0], 0x0);190 regmap_write(chip->regmap, chip->int_con[0], 0x0);
160 regmap_write(chip->regmap, chip->int_con[1], 0x0);191 regmap_write(chip->regmap, chip->int_con[1], 0x0);
161 192
193 chip->pm_nb.notifier_call = mt6397_irq_pm_notifier;
162 chip->irq_domain = irq_domain_add_linear(chip->dev->of_node,194 chip->irq_domain = irq_domain_add_linear(chip->dev->of_node,
163 MT6397_IRQ_NR,195 MT6397_IRQ_NR,
164 &mt6397_irq_domain_ops,196 &mt6397_irq_domain_ops,
@@ -177,5 +209,6 @@ int mt6397_irq_init(struct mt6397_chip *chip) · 12 unmodified lines
177 return ret;209 return ret;
178 }210 }
179 211
212 register_pm_notifier(&chip->pm_nb);
180 return 0;213 return 0;
181}214}
include/linux/mfd/mt6397/core.h+2−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
8#define __MFD_MT6397_CORE_H__8#define __MFD_MT6397_CORE_H__
9 9
10#include <linux/mutex.h>10#include <linux/mutex.h>
11#include <linux/notifier.h>
11 12
12enum chip_id {13enum chip_id {
13 MT6323_CHIP_ID = 0x23,14 MT6323_CHIP_ID = 0x23,
@@ -54,6 +55,7 @@ enum mt6397_irq_numbers { · 40 unmodified lines
54struct mt6397_chip {55struct mt6397_chip {
55 struct device *dev;56 struct device *dev;
56 struct regmap *regmap;57 struct regmap *regmap;
58 struct notifier_block pm_nb;
57 int irq;59 int irq;
58 struct irq_domain *irq_domain;60 struct irq_domain *irq_domain;
59 struct mutex irqlock;61 struct mutex irqlock;