diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-rockchip.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-rockchip.c | 102 |
1 files changed, 74 insertions, 28 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 7625f333ab07..d144330a4865 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c | |||
@@ -89,6 +89,7 @@ struct rockchip_iomux { | |||
89 | * @reg_pull: optional separate register for additional pull settings | 89 | * @reg_pull: optional separate register for additional pull settings |
90 | * @clk: clock of the gpio bank | 90 | * @clk: clock of the gpio bank |
91 | * @irq: interrupt of the gpio bank | 91 | * @irq: interrupt of the gpio bank |
92 | * @saved_enables: Saved content of GPIO_INTEN at suspend time. | ||
92 | * @pin_base: first pin number | 93 | * @pin_base: first pin number |
93 | * @nr_pins: number of pins in this bank | 94 | * @nr_pins: number of pins in this bank |
94 | * @name: name of the bank | 95 | * @name: name of the bank |
@@ -107,6 +108,7 @@ struct rockchip_pin_bank { | |||
107 | struct regmap *regmap_pull; | 108 | struct regmap *regmap_pull; |
108 | struct clk *clk; | 109 | struct clk *clk; |
109 | int irq; | 110 | int irq; |
111 | u32 saved_enables; | ||
110 | u32 pin_base; | 112 | u32 pin_base; |
111 | u8 nr_pins; | 113 | u8 nr_pins; |
112 | char *name; | 114 | char *name; |
@@ -1396,10 +1398,7 @@ static void rockchip_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
1396 | { | 1398 | { |
1397 | struct irq_chip *chip = irq_get_chip(irq); | 1399 | struct irq_chip *chip = irq_get_chip(irq); |
1398 | struct rockchip_pin_bank *bank = irq_get_handler_data(irq); | 1400 | struct rockchip_pin_bank *bank = irq_get_handler_data(irq); |
1399 | u32 polarity = 0, data = 0; | ||
1400 | u32 pend; | 1401 | u32 pend; |
1401 | bool edge_changed = false; | ||
1402 | unsigned long flags; | ||
1403 | 1402 | ||
1404 | dev_dbg(bank->drvdata->dev, "got irq for bank %s\n", bank->name); | 1403 | dev_dbg(bank->drvdata->dev, "got irq for bank %s\n", bank->name); |
1405 | 1404 | ||
@@ -1407,12 +1406,6 @@ static void rockchip_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
1407 | 1406 | ||
1408 | pend = readl_relaxed(bank->reg_base + GPIO_INT_STATUS); | 1407 | pend = readl_relaxed(bank->reg_base + GPIO_INT_STATUS); |
1409 | 1408 | ||
1410 | if (bank->toggle_edge_mode) { | ||
1411 | polarity = readl_relaxed(bank->reg_base + | ||
1412 | GPIO_INT_POLARITY); | ||
1413 | data = readl_relaxed(bank->reg_base + GPIO_EXT_PORT); | ||
1414 | } | ||
1415 | |||
1416 | while (pend) { | 1409 | while (pend) { |
1417 | unsigned int virq; | 1410 | unsigned int virq; |
1418 | 1411 | ||
@@ -1432,27 +1425,31 @@ static void rockchip_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
1432 | * needs manual intervention. | 1425 | * needs manual intervention. |
1433 | */ | 1426 | */ |
1434 | if (bank->toggle_edge_mode & BIT(irq)) { | 1427 | if (bank->toggle_edge_mode & BIT(irq)) { |
1435 | if (data & BIT(irq)) | 1428 | u32 data, data_old, polarity; |
1436 | polarity &= ~BIT(irq); | 1429 | unsigned long flags; |
1437 | else | ||
1438 | polarity |= BIT(irq); | ||
1439 | 1430 | ||
1440 | edge_changed = true; | 1431 | data = readl_relaxed(bank->reg_base + GPIO_EXT_PORT); |
1441 | } | 1432 | do { |
1433 | spin_lock_irqsave(&bank->slock, flags); | ||
1442 | 1434 | ||
1443 | generic_handle_irq(virq); | 1435 | polarity = readl_relaxed(bank->reg_base + |
1444 | } | 1436 | GPIO_INT_POLARITY); |
1437 | if (data & BIT(irq)) | ||
1438 | polarity &= ~BIT(irq); | ||
1439 | else | ||
1440 | polarity |= BIT(irq); | ||
1441 | writel(polarity, | ||
1442 | bank->reg_base + GPIO_INT_POLARITY); | ||
1445 | 1443 | ||
1446 | if (bank->toggle_edge_mode && edge_changed) { | 1444 | spin_unlock_irqrestore(&bank->slock, flags); |
1447 | /* Interrupt params should only be set with ints disabled */ | ||
1448 | spin_lock_irqsave(&bank->slock, flags); | ||
1449 | 1445 | ||
1450 | data = readl_relaxed(bank->reg_base + GPIO_INTEN); | 1446 | data_old = data; |
1451 | writel_relaxed(0, bank->reg_base + GPIO_INTEN); | 1447 | data = readl_relaxed(bank->reg_base + |
1452 | writel(polarity, bank->reg_base + GPIO_INT_POLARITY); | 1448 | GPIO_EXT_PORT); |
1453 | writel(data, bank->reg_base + GPIO_INTEN); | 1449 | } while ((data & BIT(irq)) != (data_old & BIT(irq))); |
1450 | } | ||
1454 | 1451 | ||
1455 | spin_unlock_irqrestore(&bank->slock, flags); | 1452 | generic_handle_irq(virq); |
1456 | } | 1453 | } |
1457 | 1454 | ||
1458 | chained_irq_exit(chip, desc); | 1455 | chained_irq_exit(chip, desc); |
@@ -1543,6 +1540,51 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) | |||
1543 | return 0; | 1540 | return 0; |
1544 | } | 1541 | } |
1545 | 1542 | ||
1543 | static void rockchip_irq_suspend(struct irq_data *d) | ||
1544 | { | ||
1545 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); | ||
1546 | struct rockchip_pin_bank *bank = gc->private; | ||
1547 | |||
1548 | bank->saved_enables = irq_reg_readl(gc, GPIO_INTEN); | ||
1549 | irq_reg_writel(gc, gc->wake_active, GPIO_INTEN); | ||
1550 | } | ||
1551 | |||
1552 | static void rockchip_irq_resume(struct irq_data *d) | ||
1553 | { | ||
1554 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); | ||
1555 | struct rockchip_pin_bank *bank = gc->private; | ||
1556 | |||
1557 | irq_reg_writel(gc, bank->saved_enables, GPIO_INTEN); | ||
1558 | } | ||
1559 | |||
1560 | static void rockchip_irq_disable(struct irq_data *d) | ||
1561 | { | ||
1562 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); | ||
1563 | u32 val; | ||
1564 | |||
1565 | irq_gc_lock(gc); | ||
1566 | |||
1567 | val = irq_reg_readl(gc, GPIO_INTEN); | ||
1568 | val &= ~d->mask; | ||
1569 | irq_reg_writel(gc, val, GPIO_INTEN); | ||
1570 | |||
1571 | irq_gc_unlock(gc); | ||
1572 | } | ||
1573 | |||
1574 | static void rockchip_irq_enable(struct irq_data *d) | ||
1575 | { | ||
1576 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); | ||
1577 | u32 val; | ||
1578 | |||
1579 | irq_gc_lock(gc); | ||
1580 | |||
1581 | val = irq_reg_readl(gc, GPIO_INTEN); | ||
1582 | val |= d->mask; | ||
1583 | irq_reg_writel(gc, val, GPIO_INTEN); | ||
1584 | |||
1585 | irq_gc_unlock(gc); | ||
1586 | } | ||
1587 | |||
1546 | static int rockchip_interrupts_register(struct platform_device *pdev, | 1588 | static int rockchip_interrupts_register(struct platform_device *pdev, |
1547 | struct rockchip_pinctrl *info) | 1589 | struct rockchip_pinctrl *info) |
1548 | { | 1590 | { |
@@ -1581,12 +1623,16 @@ static int rockchip_interrupts_register(struct platform_device *pdev, | |||
1581 | gc = irq_get_domain_generic_chip(bank->domain, 0); | 1623 | gc = irq_get_domain_generic_chip(bank->domain, 0); |
1582 | gc->reg_base = bank->reg_base; | 1624 | gc->reg_base = bank->reg_base; |
1583 | gc->private = bank; | 1625 | gc->private = bank; |
1584 | gc->chip_types[0].regs.mask = GPIO_INTEN; | 1626 | gc->chip_types[0].regs.mask = GPIO_INTMASK; |
1585 | gc->chip_types[0].regs.ack = GPIO_PORTS_EOI; | 1627 | gc->chip_types[0].regs.ack = GPIO_PORTS_EOI; |
1586 | gc->chip_types[0].chip.irq_ack = irq_gc_ack_set_bit; | 1628 | gc->chip_types[0].chip.irq_ack = irq_gc_ack_set_bit; |
1587 | gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; | 1629 | gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit; |
1588 | gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; | 1630 | gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit; |
1631 | gc->chip_types[0].chip.irq_enable = rockchip_irq_enable; | ||
1632 | gc->chip_types[0].chip.irq_disable = rockchip_irq_disable; | ||
1589 | gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake; | 1633 | gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake; |
1634 | gc->chip_types[0].chip.irq_suspend = rockchip_irq_suspend; | ||
1635 | gc->chip_types[0].chip.irq_resume = rockchip_irq_resume; | ||
1590 | gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type; | 1636 | gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type; |
1591 | gc->wake_enabled = IRQ_MSK(bank->nr_pins); | 1637 | gc->wake_enabled = IRQ_MSK(bank->nr_pins); |
1592 | 1638 | ||