Skip to content

Commit

Permalink
Merge branch 'at91-3.4-cleanup2-DT2+USB' of git://github.com/at91linu…
Browse files Browse the repository at this point in the history
…x/linux-at91 into next/dt

* 'at91-3.4-cleanup2-DT2+USB' of git://github.com/at91linux/linux-at91:
  ARM: at91: sam9g20 udc add dt support
  USB: at91: Device udc add dt support
  • Loading branch information
Arnd Bergmann committed Mar 16, 2012
2 parents 2a9f23d + 0f5c4b9 commit 4acf182
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/usb/atmel-usb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@ usb1: ehci@00800000 {
reg = <0x00800000 0x100000>;
interrupts = <22 4>;
};

AT91 USB device controller

Required properties:
- compatible: Should be "atmel,at91rm9200-udc"
- reg: Address and length of the register set for the device
- interrupts: Should contain macb interrupt

Optional properties:
- atmel,vbus-gpio: If present, specifies a gpio that needs to be
activated for the bus to be powered.

usb1: gadget@fffa4000 {
compatible = "atmel,at91rm9200-udc";
reg = <0xfffa4000 0x4000>;
interrupts = <10 4>;
atmel,vbus-gpio = <&pioC 5 0>;
};
7 changes: 7 additions & 0 deletions arch/arm/boot/dts/at91sam9g20.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@
interrupts = <21 4>;
status = "disabled";
};

usb1: gadget@fffa4000 {
compatible = "atmel,at91rm9200-udc";
reg = <0xfffa4000 0x4000>;
interrupts = <10 4>;
status = "disabled";
};
};

nand0: nand@40000000 {
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/boot/dts/usb_a9g20.dts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
phy-mode = "rmii";
status = "okay";
};

usb1: gadget@fffa4000 {
atmel,vbus-gpio = <&pioC 5 0>;
status = "okay";
};
};

nand0: nand@40000000 {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ choice

config USB_AT91
tristate "Atmel AT91 USB Device Port"
depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91SAM9G45
depends on ARCH_AT91
help
Many Atmel AT91 processors (such as the AT91RM2000) have a
full speed USB Device Port with support for five configurable
Expand Down
40 changes: 38 additions & 2 deletions drivers/usb/gadget/at91_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/prefetch.h>
#include <linux/of.h>
#include <linux/of_gpio.h>

#include <asm/byteorder.h>
#include <mach/hardware.h>
Expand Down Expand Up @@ -1707,7 +1709,27 @@ static void at91udc_shutdown(struct platform_device *dev)
spin_unlock_irqrestore(&udc->lock, flags);
}

static int __init at91udc_probe(struct platform_device *pdev)
static void __devinit at91udc_of_init(struct at91_udc *udc,
struct device_node *np)
{
struct at91_udc_data *board = &udc->board;
u32 val;
enum of_gpio_flags flags;

if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
board->vbus_polled = 1;

board->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0,
&flags);
board->vbus_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;

board->pullup_pin = of_get_named_gpio_flags(np, "atmel,pullup-gpio", 0,
&flags);

board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
}

static int __devinit at91udc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct at91_udc *udc;
Expand Down Expand Up @@ -1742,7 +1764,11 @@ static int __init at91udc_probe(struct platform_device *pdev)
/* init software state */
udc = &controller;
udc->gadget.dev.parent = dev;
udc->board = *(struct at91_udc_data *) dev->platform_data;
if (pdev->dev.of_node)
at91udc_of_init(udc, pdev->dev.of_node);
else
memcpy(&udc->board, dev->platform_data,
sizeof(struct at91_udc_data));
udc->pdev = pdev;
udc->enabled = 0;
spin_lock_init(&udc->lock);
Expand Down Expand Up @@ -1971,6 +1997,15 @@ static int at91udc_resume(struct platform_device *pdev)
#define at91udc_resume NULL
#endif

#if defined(CONFIG_OF)
static const struct of_device_id at91_udc_dt_ids[] = {
{ .compatible = "atmel,at91rm9200-udc" },
{ /* sentinel */ }
};

MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
#endif

static struct platform_driver at91_udc_driver = {
.remove = __exit_p(at91udc_remove),
.shutdown = at91udc_shutdown,
Expand All @@ -1979,6 +2014,7 @@ static struct platform_driver at91_udc_driver = {
.driver = {
.name = (char *) driver_name,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(at91_udc_dt_ids),
},
};

Expand Down

0 comments on commit 4acf182

Please sign in to comment.