Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: sirf: enable GPIO pullup/down configuration from dts

commit 7bec207427c2efb794 remove sirfsoc_gpio_set_pull function,
this patches takes the feature back by adding sirf,pullups and
sirf,pulldowns prop in dts, and the driver will set the GPIO
pull according to the dts.

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Barry Song and committed by
Linus Walleij
fc2b04e7 408f181e

+51
+3
Documentation/devicetree/bindings/pinctrl/pinctrl-sirf.txt
··· 6 6 - interrupts : Interrupts used by every GPIO group 7 7 - gpio-controller : Indicates this device is a GPIO controller 8 8 - interrupt-controller : Marks the device node as an interrupt controller 9 + Optional properties: 10 + - sirf,pullups : if n-th bit of m-th bank is set, set a pullup on GPIO-n of bank m 11 + - sirf,pulldowns : if n-th bit of m-th bank is set, set a pulldown on GPIO-n of bank m 9 12 10 13 Please refer to pinctrl-bindings.txt in this directory for details of the common 11 14 pinctrl bindings used by client devices.
+48
drivers/pinctrl/pinctrl-sirf.c
··· 1663 1663 .xlate = irq_domain_xlate_twocell, 1664 1664 }; 1665 1665 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 + 1666 1704 static int __devinit sirfsoc_gpio_probe(struct device_node *np) 1667 1705 { 1668 1706 int i, err = 0; ··· 1708 1670 void *regs; 1709 1671 struct platform_device *pdev; 1710 1672 bool is_marco = false; 1673 + 1674 + u32 pullups[SIRFSOC_GPIO_NO_OF_BANKS], pulldowns[SIRFSOC_GPIO_NO_OF_BANKS]; 1711 1675 1712 1676 pdev = of_find_device_by_node(np); 1713 1677 if (!pdev) ··· 1765 1725 irq_set_chained_handler(bank->parent_irq, sirfsoc_gpio_handle_irq); 1766 1726 irq_set_handler_data(bank->parent_irq, bank); 1767 1727 } 1728 + 1729 + if (!of_property_read_u32_array(np, "sirf,pullups", pullups, 1730 + SIRFSOC_GPIO_NO_OF_BANKS)) 1731 + sirfsoc_gpio_set_pullup(pullups); 1732 + 1733 + if (!of_property_read_u32_array(np, "sirf,pulldowns", pulldowns, 1734 + SIRFSOC_GPIO_NO_OF_BANKS)) 1735 + sirfsoc_gpio_set_pulldown(pulldowns); 1768 1736 1769 1737 return 0; 1770 1738