History

mfd: rn5t618: Add IRQ support

This adds support for IRQ handling in the RC5T619 which is required for properly implementing subdevices like RTC. For now only definitions for the variant RC5T619 are included.

Andreas Kemnade committed 6 years ago

Commit 0c816041 parent 361dca73 files · +93 −1Browse files

Unified · Split

3 files
  1. drivers/mfd/Kconfig +1 −0
  2. drivers/mfd/rn5t618.c +77 −1
  3. include/linux/mfd/rn5t618.h +15 −0
drivers/mfd/Kconfig+1−0
@@ -1058,6 +1058,7 @@ config MFD_RN5T618 · 1057 unmodified lines
1058 depends on OF1058 depends on OF
1059 select MFD_CORE1059 select MFD_CORE
1060 select REGMAP_I2C1060 select REGMAP_I2C
1061 select REGMAP_IRQ
1061 help1062 help
1062 Say yes here to add support for the Ricoh RN5T567,1063 Say yes here to add support for the Ricoh RN5T567,
1063 RN5T618, RC5T619 PMIC.1064 RN5T618, RC5T619 PMIC.
drivers/mfd/rn5t618.c+77−1
@@ -8,6 +8,8 @@ · 7 unmodified lines
8 8
9#include <linux/delay.h>9#include <linux/delay.h>
10#include <linux/i2c.h>10#include <linux/i2c.h>
11#include <linux/interrupt.h>
12#include <linux/irq.h>
11#include <linux/mfd/core.h>13#include <linux/mfd/core.h>
12#include <linux/mfd/rn5t618.h>14#include <linux/mfd/rn5t618.h>
13#include <linux/module.h>15#include <linux/module.h>
@@ -46,9 +48,56 @@ static const struct regmap_config rn5t618_regmap_config = { · 32 unmodified lines
46 .cache_type = REGCACHE_RBTREE,48 .cache_type = REGCACHE_RBTREE,
47};49};
48 50
51static const struct regmap_irq rc5t619_irqs[] = {
52 REGMAP_IRQ_REG(RN5T618_IRQ_SYS, 0, BIT(0)),
53 REGMAP_IRQ_REG(RN5T618_IRQ_DCDC, 0, BIT(1)),
54 REGMAP_IRQ_REG(RN5T618_IRQ_RTC, 0, BIT(2)),
55 REGMAP_IRQ_REG(RN5T618_IRQ_ADC, 0, BIT(3)),
56 REGMAP_IRQ_REG(RN5T618_IRQ_GPIO, 0, BIT(4)),
57 REGMAP_IRQ_REG(RN5T618_IRQ_CHG, 0, BIT(6)),
58};
59
60static const struct regmap_irq_chip rc5t619_irq_chip = {
61 .name = "rc5t619",
62 .irqs = rc5t619_irqs,
63 .num_irqs = ARRAY_SIZE(rc5t619_irqs),
64 .num_regs = 1,
65 .status_base = RN5T618_INTMON,
66 .mask_base = RN5T618_INTEN,
67 .mask_invert = true,
68};
69
49static struct rn5t618 *rn5t618_pm_power_off;70static struct rn5t618 *rn5t618_pm_power_off;
50static struct notifier_block rn5t618_restart_handler;71static struct notifier_block rn5t618_restart_handler;
51 72
73static int rn5t618_irq_init(struct rn5t618 *rn5t618)
74{
75 const struct regmap_irq_chip *irq_chip = NULL;
76 int ret;
77
78 if (!rn5t618->irq)
79 return 0;
80
81 switch (rn5t618->variant) {
82 case RC5T619:
83 irq_chip = &rc5t619_irq_chip;
84 break;
85 default:
86 dev_err(rn5t618->dev, "Currently no IRQ support for variant %d\n",
87 (int)rn5t618->variant);
88 return -ENOENT;
89 }
90
91 ret = devm_regmap_add_irq_chip(rn5t618->dev, rn5t618->regmap,
92 rn5t618->irq,
93 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
94 0, irq_chip, &rn5t618->irq_data);
95 if (ret)
96 dev_err(rn5t618->dev, "Failed to register IRQ chip\n");
97
98 return ret;
99}
100
52static void rn5t618_trigger_poweroff_sequence(bool repower)101static void rn5t618_trigger_poweroff_sequence(bool repower)
53{102{
54 /* disable automatic repower-on */103 /* disable automatic repower-on */
@@ -106,6 +155,8 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c, · 51 unmodified lines
106 155
107 i2c_set_clientdata(i2c, priv);156 i2c_set_clientdata(i2c, priv);
108 priv->variant = (long)of_id->data;157 priv->variant = (long)of_id->data;
158 priv->irq = i2c->irq;
159 priv->dev = &i2c->dev;
109 160
110 priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config);161 priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config);
111 if (IS_ERR(priv->regmap)) {162 if (IS_ERR(priv->regmap)) {
@@ -138,7 +189,7 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c, · 26 unmodified lines
138 return ret;189 return ret;
139 }190 }
140 191
141 return 0;192 return rn5t618_irq_init(priv);
142}193}
143 194
144static int rn5t618_i2c_remove(struct i2c_client *i2c)195static int rn5t618_i2c_remove(struct i2c_client *i2c)
@@ -155,15 +206,40 @@ static int rn5t618_i2c_remove(struct i2c_client *i2c) · 10 unmodified lines
155 return 0;206 return 0;
156}207}
157 208
209static int __maybe_unused rn5t618_i2c_suspend(struct device *dev)
210{
211 struct rn5t618 *priv = dev_get_drvdata(dev);
212
213 if (priv->irq)
214 disable_irq(priv->irq);
215
216 return 0;
217}
218
219static int __maybe_unused rn5t618_i2c_resume(struct device *dev)
220{
221 struct rn5t618 *priv = dev_get_drvdata(dev);
222
223 if (priv->irq)
224 enable_irq(priv->irq);
225
226 return 0;
227}
228
158static const struct i2c_device_id rn5t618_i2c_id[] = {229static const struct i2c_device_id rn5t618_i2c_id[] = {
159 { }230 { }
160};231};
161MODULE_DEVICE_TABLE(i2c, rn5t618_i2c_id);232MODULE_DEVICE_TABLE(i2c, rn5t618_i2c_id);
162 233
234static SIMPLE_DEV_PM_OPS(rn5t618_i2c_dev_pm_ops,
235 rn5t618_i2c_suspend,
236 rn5t618_i2c_resume);
237
163static struct i2c_driver rn5t618_i2c_driver = {238static struct i2c_driver rn5t618_i2c_driver = {
164 .driver = {239 .driver = {
165 .name = "rn5t618",240 .name = "rn5t618",
166 .of_match_table = of_match_ptr(rn5t618_of_match),241 .of_match_table = of_match_ptr(rn5t618_of_match),
242 .pm = &rn5t618_i2c_dev_pm_ops,
167 },243 },
168 .probe = rn5t618_i2c_probe,244 .probe = rn5t618_i2c_probe,
169 .remove = rn5t618_i2c_remove,245 .remove = rn5t618_i2c_remove,
include/linux/mfd/rn5t618.h+15−0
@@ -242,9 +242,24 @@ enum { · 241 unmodified lines
242 RC5T619,242 RC5T619,
243};243};
244 244
245/* RN5T618 IRQ definitions */
246enum {
247 RN5T618_IRQ_SYS = 0,
248 RN5T618_IRQ_DCDC,
249 RN5T618_IRQ_RTC,
250 RN5T618_IRQ_ADC,
251 RN5T618_IRQ_GPIO,
252 RN5T618_IRQ_CHG,
253 RN5T618_NR_IRQS,
254};
255
245struct rn5t618 {256struct rn5t618 {
246 struct regmap *regmap;257 struct regmap *regmap;
258 struct device *dev;
247 long variant;259 long variant;
260
261 int irq;
262 struct regmap_irq_chip_data *irq_data;
248};263};
249 264
250#endif /* __LINUX_MFD_RN5T618_H */265#endif /* __LINUX_MFD_RN5T618_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t