diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-sirf.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-sirf.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/drivers/pinctrl/pinctrl-sirf.c b/drivers/pinctrl/pinctrl-sirf.c index a4f0c5e487d5..498b2ba905de 100644 --- a/drivers/pinctrl/pinctrl-sirf.c +++ b/drivers/pinctrl/pinctrl-sirf.c | |||
@@ -1246,7 +1246,7 @@ static void __iomem *sirfsoc_rsc_of_iomap(void) | |||
1246 | return of_iomap(np, 0); | 1246 | return of_iomap(np, 0); |
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | static int __devinit sirfsoc_pinmux_probe(struct platform_device *pdev) | 1249 | static int sirfsoc_pinmux_probe(struct platform_device *pdev) |
1250 | { | 1250 | { |
1251 | int ret; | 1251 | int ret; |
1252 | struct sirfsoc_pmx *spmx; | 1252 | struct sirfsoc_pmx *spmx; |
@@ -1663,7 +1663,45 @@ const struct irq_domain_ops sirfsoc_gpio_irq_simple_ops = { | |||
1663 | .xlate = irq_domain_xlate_twocell, | 1663 | .xlate = irq_domain_xlate_twocell, |
1664 | }; | 1664 | }; |
1665 | 1665 | ||
1666 | static int __devinit sirfsoc_gpio_probe(struct device_node *np) | 1666 | static void sirfsoc_gpio_set_pullup(const u32 *pullups) |
1667 | { | ||
1668 | int i, n; | ||
1669 | const unsigned long *p = (const unsigned long *)pullups; | ||
1670 | |||
1671 | for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) { | ||
1672 | n = find_first_bit(p + i, BITS_PER_LONG); | ||
1673 | while (n < BITS_PER_LONG) { | ||
1674 | u32 offset = SIRFSOC_GPIO_CTRL(i, n); | ||
1675 | u32 val = readl(sgpio_bank[i].chip.regs + offset); | ||
1676 | val |= SIRFSOC_GPIO_CTL_PULL_MASK; | ||
1677 | val |= SIRFSOC_GPIO_CTL_PULL_HIGH; | ||
1678 | writel(val, sgpio_bank[i].chip.regs + offset); | ||
1679 | |||
1680 | n = find_next_bit(p + i, BITS_PER_LONG, n + 1); | ||
1681 | } | ||
1682 | } | ||
1683 | } | ||
1684 | |||
1685 | static void sirfsoc_gpio_set_pulldown(const u32 *pulldowns) | ||
1686 | { | ||
1687 | int i, n; | ||
1688 | const unsigned long *p = (const unsigned long *)pulldowns; | ||
1689 | |||
1690 | for (i = 0; i < SIRFSOC_GPIO_NO_OF_BANKS; i++) { | ||
1691 | n = find_first_bit(p + i, BITS_PER_LONG); | ||
1692 | while (n < BITS_PER_LONG) { | ||
1693 | u32 offset = SIRFSOC_GPIO_CTRL(i, n); | ||
1694 | u32 val = readl(sgpio_bank[i].chip.regs + offset); | ||
1695 | val |= SIRFSOC_GPIO_CTL_PULL_MASK; | ||
1696 | val &= ~SIRFSOC_GPIO_CTL_PULL_HIGH; | ||
1697 | writel(val, sgpio_bank[i].chip.regs + offset); | ||
1698 | |||
1699 | n = find_next_bit(p + i, BITS_PER_LONG, n + 1); | ||
1700 | } | ||
1701 | } | ||
1702 | } | ||
1703 | |||
1704 | static int sirfsoc_gpio_probe(struct device_node *np) | ||
1667 | { | 1705 | { |
1668 | int i, err = 0; | 1706 | int i, err = 0; |
1669 | struct sirfsoc_gpio_bank *bank; | 1707 | struct sirfsoc_gpio_bank *bank; |
@@ -1671,6 +1709,8 @@ static int __devinit sirfsoc_gpio_probe(struct device_node *np) | |||
1671 | struct platform_device *pdev; | 1709 | struct platform_device *pdev; |
1672 | bool is_marco = false; | 1710 | bool is_marco = false; |
1673 | 1711 | ||
1712 | u32 pullups[SIRFSOC_GPIO_NO_OF_BANKS], pulldowns[SIRFSOC_GPIO_NO_OF_BANKS]; | ||
1713 | |||
1674 | pdev = of_find_device_by_node(np); | 1714 | pdev = of_find_device_by_node(np); |
1675 | if (!pdev) | 1715 | if (!pdev) |
1676 | return -ENODEV; | 1716 | return -ENODEV; |
@@ -1726,6 +1766,14 @@ static int __devinit sirfsoc_gpio_probe(struct device_node *np) | |||
1726 | irq_set_handler_data(bank->parent_irq, bank); | 1766 | irq_set_handler_data(bank->parent_irq, bank); |
1727 | } | 1767 | } |
1728 | 1768 | ||
1769 | if (!of_property_read_u32_array(np, "sirf,pullups", pullups, | ||
1770 | SIRFSOC_GPIO_NO_OF_BANKS)) | ||
1771 | sirfsoc_gpio_set_pullup(pullups); | ||
1772 | |||
1773 | if (!of_property_read_u32_array(np, "sirf,pulldowns", pulldowns, | ||
1774 | SIRFSOC_GPIO_NO_OF_BANKS)) | ||
1775 | sirfsoc_gpio_set_pulldown(pulldowns); | ||
1776 | |||
1729 | return 0; | 1777 | return 0; |
1730 | 1778 | ||
1731 | out: | 1779 | out: |