aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/at91_udc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/at91_udc.c')
-rw-r--r--drivers/usb/gadget/at91_udc.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 2db5f68f7960..0c935d7c65bd 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -29,12 +29,13 @@
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/usb/ch9.h> 30#include <linux/usb/ch9.h>
31#include <linux/usb/gadget.h> 31#include <linux/usb/gadget.h>
32#include <linux/of.h>
33#include <linux/of_gpio.h>
32 34
33#include <asm/byteorder.h> 35#include <asm/byteorder.h>
34#include <mach/hardware.h> 36#include <mach/hardware.h>
35#include <asm/io.h> 37#include <asm/io.h>
36#include <asm/irq.h> 38#include <asm/irq.h>
37#include <asm/system.h>
38#include <asm/gpio.h> 39#include <asm/gpio.h>
39 40
40#include <mach/board.h> 41#include <mach/board.h>
@@ -1707,7 +1708,27 @@ static void at91udc_shutdown(struct platform_device *dev)
1707 spin_unlock_irqrestore(&udc->lock, flags); 1708 spin_unlock_irqrestore(&udc->lock, flags);
1708} 1709}
1709 1710
1710static int __init at91udc_probe(struct platform_device *pdev) 1711static void __devinit at91udc_of_init(struct at91_udc *udc,
1712 struct device_node *np)
1713{
1714 struct at91_udc_data *board = &udc->board;
1715 u32 val;
1716 enum of_gpio_flags flags;
1717
1718 if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
1719 board->vbus_polled = 1;
1720
1721 board->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0,
1722 &flags);
1723 board->vbus_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1724
1725 board->pullup_pin = of_get_named_gpio_flags(np, "atmel,pullup-gpio", 0,
1726 &flags);
1727
1728 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1729}
1730
1731static int __devinit at91udc_probe(struct platform_device *pdev)
1711{ 1732{
1712 struct device *dev = &pdev->dev; 1733 struct device *dev = &pdev->dev;
1713 struct at91_udc *udc; 1734 struct at91_udc *udc;
@@ -1742,7 +1763,11 @@ static int __init at91udc_probe(struct platform_device *pdev)
1742 /* init software state */ 1763 /* init software state */
1743 udc = &controller; 1764 udc = &controller;
1744 udc->gadget.dev.parent = dev; 1765 udc->gadget.dev.parent = dev;
1745 udc->board = *(struct at91_udc_data *) dev->platform_data; 1766 if (pdev->dev.of_node)
1767 at91udc_of_init(udc, pdev->dev.of_node);
1768 else
1769 memcpy(&udc->board, dev->platform_data,
1770 sizeof(struct at91_udc_data));
1746 udc->pdev = pdev; 1771 udc->pdev = pdev;
1747 udc->enabled = 0; 1772 udc->enabled = 0;
1748 spin_lock_init(&udc->lock); 1773 spin_lock_init(&udc->lock);
@@ -1971,6 +1996,15 @@ static int at91udc_resume(struct platform_device *pdev)
1971#define at91udc_resume NULL 1996#define at91udc_resume NULL
1972#endif 1997#endif
1973 1998
1999#if defined(CONFIG_OF)
2000static const struct of_device_id at91_udc_dt_ids[] = {
2001 { .compatible = "atmel,at91rm9200-udc" },
2002 { /* sentinel */ }
2003};
2004
2005MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
2006#endif
2007
1974static struct platform_driver at91_udc_driver = { 2008static struct platform_driver at91_udc_driver = {
1975 .remove = __exit_p(at91udc_remove), 2009 .remove = __exit_p(at91udc_remove),
1976 .shutdown = at91udc_shutdown, 2010 .shutdown = at91udc_shutdown,
@@ -1979,6 +2013,7 @@ static struct platform_driver at91_udc_driver = {
1979 .driver = { 2013 .driver = {
1980 .name = (char *) driver_name, 2014 .name = (char *) driver_name,
1981 .owner = THIS_MODULE, 2015 .owner = THIS_MODULE,
2016 .of_match_table = of_match_ptr(at91_udc_dt_ids),
1982 }, 2017 },
1983}; 2018};
1984 2019