9
0
Fork 0

at91_udc: update vbus param only if updated

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Jean-Christophe PLAGNIOL-VILLARD 2011-12-31 16:21:37 +01:00 committed by Sascha Hauer
parent ff6e2a0ea3
commit 3bc0b7b2e6
2 changed files with 16 additions and 2 deletions

View File

@ -1315,6 +1315,19 @@ static struct at91_udc controller = {
static void at91_udc_irq (void *_udc); static void at91_udc_irq (void *_udc);
static void at91_update_vbus(struct at91_udc *udc, u32 value)
{
if (value == udc->gpio_vbus_val)
return;
if (value)
dev_set_param(udc->dev, "vbus", "1");
else
dev_set_param(udc->dev, "vbus", "0");
udc->gpio_vbus_val = value;
}
int usb_gadget_poll(void) int usb_gadget_poll(void)
{ {
struct at91_udc *udc = &controller; struct at91_udc *udc = &controller;
@ -1327,10 +1340,10 @@ int usb_gadget_poll(void)
value ^= udc->board.vbus_active_low; value ^= udc->board.vbus_active_low;
if (!value) { if (!value) {
dev_set_param(udc->dev, "vbus", "0"); at91_update_vbus(udc, value);
return 0; return 0;
} }
dev_set_param(udc->dev, "vbus", "1"); at91_update_vbus(udc, value);
value = at91_udp_read(udc, AT91_UDP_ISR) & (~(AT91_UDP_SOFINT)); value = at91_udp_read(udc, AT91_UDP_ISR) & (~(AT91_UDP_SOFINT));
if (value) if (value)

View File

@ -128,6 +128,7 @@ struct at91_udc {
unsigned selfpowered:1; unsigned selfpowered:1;
unsigned active_suspend:1; unsigned active_suspend:1;
u8 addr; u8 addr;
u32 gpio_vbus_val;
struct at91_udc_data board; struct at91_udc_data board;
struct clk *iclk, *fclk; struct clk *iclk, *fclk;
struct device_d *dev; struct device_d *dev;