105
107
unsigned long flags;
110
pm_runtime_get(&lnw->pdev->dev);
107
112
spin_lock_irqsave(&lnw->lock, flags);
108
113
value = readl(gpdr);
109
114
value &= ~BIT(offset % 32);
110
115
writel(value, gpdr);
111
116
spin_unlock_irqrestore(&lnw->lock, flags);
119
pm_runtime_put(&lnw->pdev->dev);
120
129
unsigned long flags;
122
131
lnw_gpio_set(chip, offset, value);
134
pm_runtime_get(&lnw->pdev->dev);
123
136
spin_lock_irqsave(&lnw->lock, flags);
124
137
value = readl(gpdr);
125
value |= BIT(offset % 32);;
138
value |= BIT(offset % 32);
126
139
writel(value, gpdr);
127
140
spin_unlock_irqrestore(&lnw->lock, flags);
143
pm_runtime_put(&lnw->pdev->dev);
146
163
if (gpio >= lnw->chip.ngpio)
167
pm_runtime_get(&lnw->pdev->dev);
148
169
spin_lock_irqsave(&lnw->lock, flags);
149
170
if (type & IRQ_TYPE_EDGE_RISING)
150
171
value = readl(grer) | BIT(gpio % 32);
188
212
static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
190
struct lnw_gpio *lnw = get_irq_data(irq);
214
struct irq_data *data = irq_desc_get_irq_data(desc);
215
struct lnw_gpio *lnw = irq_data_get_irq_handler_data(data);
216
struct irq_chip *chip = irq_data_get_irq_chip(data);
217
u32 base, gpio, mask;
218
unsigned long pending;
192
219
void __iomem *gedr;
195
221
/* check GPIO controller to check which pin triggered the interrupt */
196
222
for (base = 0; base < lnw->chip.ngpio; base += 32) {
197
223
gedr = gpio_reg(&lnw->chip, base, GEDR);
198
gedr_v = readl(gedr);
201
for (gpio = base; gpio < base + 32; gpio++)
202
if (gedr_v & BIT(gpio % 32)) {
203
pr_debug("pin %d triggered\n", gpio);
204
generic_handle_irq(lnw->irq_base + gpio);
206
/* clear the edge detect status bit */
207
writel(gedr_v, gedr);
224
pending = readl(gedr);
226
gpio = __ffs(pending);
229
/* Clear before handling so we can't lose an edge */
231
generic_handle_irq(lnw->irq_base + base + gpio);
210
if (desc->chip->irq_eoi)
211
desc->chip->irq_eoi(irq_get_irq_data(irq));
213
dev_warn(lnw->chip.dev, "missing EOI handler for irq %d\n", irq);
239
static int lnw_gpio_runtime_resume(struct device *dev)
244
static int lnw_gpio_runtime_suspend(struct device *dev)
249
static int lnw_gpio_runtime_idle(struct device *dev)
251
int err = pm_schedule_suspend(dev, 500);
260
#define lnw_gpio_runtime_suspend NULL
261
#define lnw_gpio_runtime_resume NULL
262
#define lnw_gpio_runtime_idle NULL
265
static const struct dev_pm_ops lnw_gpio_pm_ops = {
266
.runtime_suspend = lnw_gpio_runtime_suspend,
267
.runtime_resume = lnw_gpio_runtime_resume,
268
.runtime_idle = lnw_gpio_runtime_idle,
217
271
static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
218
272
const struct pci_device_id *id)
273
327
lnw->chip.base = gpio_base;
274
328
lnw->chip.ngpio = id->driver_data;
275
329
lnw->chip.can_sleep = 0;
276
331
pci_set_drvdata(pdev, lnw);
277
332
retval = gpiochip_add(&lnw->chip);
279
334
dev_err(&pdev->dev, "langwell gpiochip_add error %d\n", retval);
282
set_irq_data(pdev->irq, lnw);
283
set_irq_chained_handler(pdev->irq, lnw_irq_handler);
337
irq_set_handler_data(pdev->irq, lnw);
338
irq_set_chained_handler(pdev->irq, lnw_irq_handler);
284
339
for (i = 0; i < lnw->chip.ngpio; i++) {
285
set_irq_chip_and_handler_name(i + lnw->irq_base, &lnw_irqchip,
286
handle_simple_irq, "demux");
287
set_irq_chip_data(i + lnw->irq_base, lnw);
340
irq_set_chip_and_handler_name(i + lnw->irq_base, &lnw_irqchip,
341
handle_simple_irq, "demux");
342
irq_set_chip_data(i + lnw->irq_base, lnw);
290
345
spin_lock_init(&lnw->lock);
347
pm_runtime_put_noidle(&pdev->dev);
348
pm_runtime_allow(&pdev->dev);