at91: Add support for Bluewater Systems Snapper 9260/9G20 modules
Subsystems (4)
cover at91: Add support for Bluewater Systems Snapper 9260/9G20 modules
Repost of the Snapper 9260/9G20 module support patch series. These patches add support for the Bluewater Systems Snapper 9260/9G20 modules. As a preliminary for the module support the following patches are also included in this series:
- Define NR_BUILTIN_GPIO for at91. The Snapper 9260/9G20 modules have
an io expander which requires this to be defined.
- Add vbus polarity and polling mode to the at91 udc driver. The
Snapper 9260/9G20 modules have the udc vbus pin connected in inverse polarity to a sleeping io expander gpio.
Ryan Mallon (3):
AT91: Define NR_BUILTIN_GPIO
at91_udc: Add vbus polarity and polling mode
at91: Add support for Bluewater Systems Snapper 9260/9G20 modules
arch/arm/mach-at91/Kconfig | 11 ++ arch/arm/mach-at91/Makefile | 3 + arch/arm/mach-at91/board-snapper9260.c | 189 +++++++++++++++++++++++++++++++ arch/arm/mach-at91/include/mach/board.h | 2 + arch/arm/mach-at91/include/mach/gpio.h | 1 + drivers/usb/gadget/at91_udc.c | 66 +++++++++-- drivers/usb/gadget/at91_udc.h | 2 + 7 files changed, 261 insertions(+), 13 deletions(-) create mode 100644 arch/arm/mach-at91/board-snapper9260.c
PATCH 1/3 AT91: Define NR_BUILTIN_GPIO
Add definition for NR_BUILTIN_GPIO for AT91 family
--- arch/arm/mach-at91/include/mach/gpio.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-at91/include/mach/gpio.h +1 -0
@@ -19,6 +19,7 @@#define PIN_BASE NR_AIC_IRQS#define MAX_GPIO_BANKS 5 +#define NR_BUILTIN_GPIO (PIN_BASE + (MAX_GPIO_BANKS * 32))/* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */
Signature · 1 line
1.5.5.1
PATCH 1/3 AT91: Define NR_BUILTIN_GPIO
hi Ryan,
Quoted 3 lines
Add definition for
NR_BUILTIN_GPIOfor AT91 familySigned-off-by Ryan Mallon <[email protected]>
Please submit to Russell King's patch system.
PATCH 2/3 at91_udc: Add vbus polarity and polling mode
In reply to Ryan MallonAllow the vbus signal to optionally use polling. This is required if the vbus signal is connected to an non-interrupting io expander for example. If vbus is in polling mode, then it is assumed that the vbus gpio may sleep. Also add an option to have vbus be an active low signal. Both options are set in the platform data for the device.
--- arch/arm/mach-at91/include/mach/board.h | 2 + drivers/usb/gadget/at91_udc.c | 66 +++++++++++++++++++++++++------ drivers/usb/gadget/at91_udc.h | 2 + 3 files changed, 57 insertions(+), 13 deletions(-)
arch/arm/mach-at91/include/mach/board.h +2 -0
@@ -44,6 +44,8 @@/* USB Device */ struct at91_udc_data {u8 vbus_pin;/* high == host powering us */ +u8 vbus_active_low;/* vbus polarity */ +u8 vbus_polled;/* Use polling, not interrupt */ u8 pullup_pin;/* active == D+ pulled up */ u8 pullup_active_low;/* true == pullup_pin is active low */ };
drivers/usb/gadget/at91_udc.c +53 -13
106 lines not on this page · raw message
drivers/usb/gadget/at91_udc.h +2 -0
@@ -144,6 +144,8 @@ struct at91_udc {struct proc_dir_entry *pde;void __iomem *udp_baseaddr;int udp_irq; +struct timer_list vbus_timer; +struct work_struct vbus_timer_work; };static inline struct at91_udc *to_udc (struct usb_gadget *g)
Signature · 1 line
1.5.5.1
PATCH 2/3 at91_udc: Add vbus polarity and polling mode
Quoted 7 lines · Ryan Mallon
Allow the vbus signal to optionally use polling. This is required if the vbus signal is connected to an non-interrupting io expander for example. If vbus is in polling mode, then it is assumed that the vbus gpio may sleep. Also add an option to have vbus be an active low signal. Both options are set in the platform data for the device.
Signed-off-by Ryan Mallon <[email protected]>
Is anybody able to review this patch please? I have an ack for a patch which depends on this one. This patch should have no impact (other than slight code/data size increase) on existing users of the at91 udc driver since it only adds an alternative code path for the case where vbus is on a gpio which may sleep. The addition of the vbus polarity should also not affect existing users since the default is active high.
Thanks,
~Ryan
Quoted 147 lines
--- arch/arm/mach-at91/include/mach/board.h | 2 + drivers/usb/gadget/at91_udc.c | 66 +++++++++++++++++++++++++------ drivers/usb/gadget/at91_udc.h | 2 + 3 files changed, 57 insertions(+), 13 deletions(-)arch/arm/mach-at91/include/mach/board.h +2
-0@@ -44,6 +44,8 @@/* USB Device */ struct at91_udc_data {u8 vbus_pin;/* high == host powering us */ +u8 vbus_active_low;/* vbus polarity */ +u8 vbus_polled;/* Use polling, not interrupt */ u8 pullup_pin;/* active == D+ pulled up */ u8 pullup_active_low;/* true == pullup_pin is active low */ };drivers/usb/gadget/at91_udc.c +53
-13@@ -76,6 +76,7 @@static const char driver_name [] ="at91_udc" ;static const char ep0name[] ="ep0" ; +#define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000)#define at91_udp_read (dev, reg) \ __raw_readl((dev)->udp_baseaddr + (reg))@@ -1556,20 +1557,49 @@ static struct at91_udc controller = {/* ep6 and ep7 are also reserved (custom silicon might use them) */ }; +static void at91_vbus_update (struct at91_udc *udc,unsigned value) +{ +if (udc->board.vbus_active_low) + value ^=1 ; +if (value != udc->vbus) +at91_vbus_session (&udc->gadget, value); +} +static irqreturn_t at91_vbus_irq (int irq,void *_udc) {struct at91_udc *udc = _udc; -unsigned value;/* vbus needs at least brief debouncing */ udelay (10 ); - value =gpio_get_value (udc->board.vbus_pin); -if (value != udc->vbus) -at91_vbus_session (&udc->gadget, value); +at91_vbus_update (udc,gpio_get_value (udc->board.vbus_pin));return IRQ_HANDLED ; } +static void at91_vbus_timer_work (struct work_struct *work) +{ + struct at91_udc *udc = container_of(work, struct at91_udc, + vbus_timer_work); + +at91_vbus_update (udc,gpio_get_value_cansleep (udc->board.vbus_pin)); + +if (!timer_pending (&udc->vbus_timer)) +mod_timer (&udc->vbus_timer, jiffies +VBUS_POLL_TIMEOUT ); +} + +static void at91_vbus_timer (unsigned long data) +{ +struct at91_udc *udc = (struct at91_udc *)data; + +/* +* If we are polling vbus it is likely that the gpio is on an +* bus such as i2c or spi which may sleep, so schedule some work +* to read the vbus gpio +*/ +if (!work_pending (&udc->vbus_timer_work)) +schedule_work (&udc->vbus_timer_work); +} +int usb_gadget_register_driver (struct usb_gadget_driver *driver) {struct at91_udc *udc = &controller;@@ -1763,13 +1793,22 @@ static int __init at91udc_probe(struct platform_device *pdev)* Get the initial state of VBUS - we cannot expect * a pending interrupt. */ - udc->vbus =gpio_get_value (udc->board.vbus_pin); -if (request_irq (udc->board.vbus_pin, at91_vbus_irq, -IRQF_DISABLED , driver_name, udc)) { -DBG ("request vbus irq %d failed\n" , - udc->board.vbus_pin); - retval = -EBUSY ; - goto fail3; +if (udc->board.vbus_polled) { + udc->vbus =gpio_get_value_cansleep (udc->board.vbus_pin); +INIT_WORK (&udc->vbus_timer_work, at91_vbus_timer_work); +setup_timer (&udc->vbus_timer, at91_vbus_timer, + (unsigned long )udc); +mod_timer (&udc->vbus_timer, + jiffies +VBUS_POLL_TIMEOUT ); + }else { + udc->vbus =gpio_get_value (udc->board.vbus_pin); +if (request_irq (udc->board.vbus_pin, at91_vbus_irq, +IRQF_DISABLED , driver_name, udc)) { +DBG ("request vbus irq %d failed\n" , + udc->board.vbus_pin); + retval = -EBUSY ; + goto fail3; + } } }else {DBG ("no VBUS detection, assuming always-on\n" );@@ -1855,7 +1894,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)enable_irq_wake (udc->udp_irq); udc->active_suspend = wake; -if (udc->board.vbus_pin >0 && wake) +if (udc->board.vbus_pin >0 && !udc->board.vbus_polled && wake)enable_irq_wake (udc->board.vbus_pin);return 0 ; }@@ -1864,7 +1903,8 @@ static int at91udc_resume(struct platform_device *pdev) {struct at91_udc *udc =platform_get_drvdata (pdev); -if (udc->board.vbus_pin >0 && udc->active_suspend) +if (udc->board.vbus_pin >0 && !udc->board.vbus_polled && + udc->active_suspend)disable_irq_wake (udc->board.vbus_pin);/* maybe reconnect to host; if so, clocks on */ drivers/usb/gadget/at91_udc.h +2
-0@@ -144,6 +144,8 @@ struct at91_udc {struct proc_dir_entry *pde;void __iomem *udp_baseaddr;int udp_irq; +struct timer_list vbus_timer; +struct work_struct vbus_timer_work; };static inline struct at91_udc *to_udc (struct usb_gadget *g)
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St ryan at bluewatersys.com PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
PATCH 2/3 at91_udc: Add vbus polarity and polling mode
In reply to Ryan MallonLe 28/06/2010 06:39, Ryan Mallon :
Quoted 7 lines
Allow the vbus signal to optionally use polling. This is required if the vbus signal is connected to an non-interrupting io expander for example. If vbus is in polling mode, then it is assumed that the vbus gpio may sleep. Also add an option to have vbus be an active low signal. Both options are set in the platform data for the device.
Signed-off-by Ryan Mallon <[email protected]>
Looks good, but... one question:
drivers/usb/gadget/at91_udc.c static int __init at91udc_probe(struct platform_device *pdev) · line 1797
Quoted 13 lines
drivers/usb/gadget/at91_udc.c +2
-7@@ -1763,13 +1793,22 @@ static int __init at91udc_probe(struct platform_device *pdev)* Get the initial state of VBUS - we cannot expect * a pending interrupt. */ - udc->vbus =gpio_get_value (udc->board.vbus_pin); -if (request_irq (udc->board.vbus_pin, at91_vbus_irq, -IRQF_DISABLED , driver_name, udc)) { -DBG ("request vbus irq %d failed\n" , - udc->board.vbus_pin); - retval = -EBUSY ; - goto fail3; +if (udc->board.vbus_polled) { + udc->vbus =gpio_get_value_cansleep (udc->board.vbus_pin);
Shouldn't we need here something like:udc->vbus = (udc->board.vbus_active_low) ^ gpio_get_value_cansleep(udc->board.vbus_pin);
?
drivers/usb/gadget/at91_udc.c static int __init at91udc_probe(struct platform_device *pdev) · line 1804
Quoted 7 lines
drivers/usb/gadget/at91_udc.c +7
-0+INIT_WORK (&udc->vbus_timer_work, at91_vbus_timer_work); +setup_timer (&udc->vbus_timer, at91_vbus_timer, + (unsigned long )udc); +mod_timer (&udc->vbus_timer, + jiffies +VBUS_POLL_TIMEOUT ); + }else { + udc->vbus =gpio_get_value (udc->board.vbus_pin);
Ditto.
drivers/usb/gadget/at91_udc.c static int __init at91udc_probe(struct platform_device *pdev) · line 1811
Quoted 7 lines
drivers/usb/gadget/at91_udc.c +7
-0+if (request_irq (udc->board.vbus_pin, at91_vbus_irq, +IRQF_DISABLED , driver_name, udc)) { +DBG ("request vbus irq %d failed\n" , + udc->board.vbus_pin); + retval = -EBUSY ; + goto fail3; + }
Best regards,
Signature · 1 line
Nicolas Ferre
PATCH 2/3 at91_udc: Add vbus polarity and polling mode
Quoted 13 lines · Nicolas Ferre
Le 28/06/2010 06:39, Ryan Mallon :
Quoted 8 lines
Allow the vbus signal to optionally use polling. This is required if the vbus signal is connected to an non-interrupting io expander for example. If vbus is in polling mode, then it is assumed that the vbus gpio may sleep. Also add an option to have vbus be an active low signal. Both options are set in the platform data for the device.
Signed-off-by Ryan Mallon <[email protected]>Looks good, but... one question:
Quoted 17 lines
Quoted 4 lines
(quoted diff) +0
-0@@ -1763,13 +1793,22 @@ static int __init at91udc_probe(struct platform_device *pdev) * Get the initial state of VBUS - we cannot expect * a pending interrupt. */Review static int __init at91udc_probe(struct platform_device *pdev) · line 1798
Quoted 10 lines
(quoted diff) +2
-7- udc->vbus = gpio_get_value(udc->board.vbus_pin); - if (request_irq(udc->board.vbus_pin, at91_vbus_irq, - IRQF_DISABLED, driver_name, udc)) { - DBG("request vbus irq %d failed\n", - udc->board.vbus_pin); - retval = -EBUSY; - goto fail3; + if (udc->board.vbus_polled) { + udc->vbus = gpio_get_value_cansleep(udc->board.vbus_pin);Shouldn't we need here something like:
udc->vbus= (udc->board.vbus_active_low) ^gpio_get_value_cansleep(udc->board.vbus_pin);
Yes, thanks. The updated patch below fixes it. Also simplify at91_vbus_update (always do the xor) and move the initial setting of udc->vbus outside of the udc->board.vbus_polled test, since we can use gpio_get_value_cansleep in both cases.
---
arch/arm/mach-at91/include/mach/board.h +2 -0
@@ -44,6 +44,8 @@/* USB Device */ struct at91_udc_data {u8 vbus_pin;/* high == host powering us */ +u8 vbus_active_low;/* vbus polarity */ +u8 vbus_polled;/* Use polling, not interrupt */ u8 pullup_pin;/* active == D+ pulled up */ u8 pullup_active_low;/* true == pullup_pin is active low */ };
drivers/usb/gadget/at91_udc.c +53 -13
106 lines not on this page · raw message
drivers/usb/gadget/at91_udc.h +2 -0
@@ -144,6 +144,8 @@ struct at91_udc {struct proc_dir_entry *pde;void __iomem *udp_baseaddr;int udp_irq; +struct timer_list vbus_timer; +struct work_struct vbus_timer_work; };static inline struct at91_udc *to_udc (struct usb_gadget *g)
PATCH 2/3 at91_udc: Add vbus polarity and polling mode
Quoted 10 lines · Ryan Mallon
Quoted 8 lines · Nicolas Ferre
Le 28/06/2010 06:39, Ryan Mallon :
Review
Quoted 3 lines
(quoted diff) +2
-0+ if (udc->board.vbus_polled) { + udc->vbus = gpio_get_value_cansleep(udc->board.vbus_pin);Shouldn't we need here something like:
udc->vbus= (udc->board.vbus_active_low) ^gpio_get_value_cansleep(udc->board.vbus_pin);
Quoted 4 lines
Yes, thanks. The updated patch below fixes it. Also simplify
at91_vbus_update(always do the xor) and move the initial setting ofudc->vbusoutside of theudc->board.vbus_polledtest, since we can usegpio_get_value_cansleepin both cases.
Nicolas, can I get your ack on this now to put this through to the patch system please?
~Ryan
Quoted 152 lines
Signed-off-by Ryan Mallon <[email protected]>---
arch/arm/mach-at91/include/mach/board.h +2
-0@@ -44,6 +44,8 @@/* USB Device */ struct at91_udc_data {u8 vbus_pin;/* high == host powering us */ +u8 vbus_active_low;/* vbus polarity */ +u8 vbus_polled;/* Use polling, not interrupt */ u8 pullup_pin;/* active == D+ pulled up */ u8 pullup_active_low;/* true == pullup_pin is active low */ };drivers/usb/gadget/at91_udc.c +53
-13@@ -76,6 +76,7 @@static const char driver_name [] ="at91_udc" ;static const char ep0name[] ="ep0" ; +#define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000)#define at91_udp_read (dev, reg) \ __raw_readl((dev)->udp_baseaddr + (reg))@@ -1556,20 +1557,48 @@ static struct at91_udc controller = {/* ep6 and ep7 are also reserved (custom silicon might use them) */ }; +static void at91_vbus_update (struct at91_udc *udc,unsigned value) +{ + value ^= udc->board.vbus_active_low; +if (value != udc->vbus) +at91_vbus_session (&udc->gadget, value); +} +static irqreturn_t at91_vbus_irq (int irq,void *_udc) {struct at91_udc *udc = _udc; -unsigned value;/* vbus needs at least brief debouncing */ udelay (10 ); - value =gpio_get_value (udc->board.vbus_pin); -if (value != udc->vbus) -at91_vbus_session (&udc->gadget, value); +at91_vbus_update (udc,gpio_get_value (udc->board.vbus_pin));return IRQ_HANDLED ; } +static void at91_vbus_timer_work (struct work_struct *work) +{ + struct at91_udc *udc = container_of(work, struct at91_udc, + vbus_timer_work); + +at91_vbus_update (udc,gpio_get_value_cansleep (udc->board.vbus_pin)); + +if (!timer_pending (&udc->vbus_timer)) +mod_timer (&udc->vbus_timer, jiffies +VBUS_POLL_TIMEOUT ); +} + +static void at91_vbus_timer (unsigned long data) +{ +struct at91_udc *udc = (struct at91_udc *)data; + +/* +* If we are polling vbus it is likely that the gpio is on an +* bus such as i2c or spi which may sleep, so schedule some work +* to read the vbus gpio +*/ +if (!work_pending (&udc->vbus_timer_work)) +schedule_work (&udc->vbus_timer_work); +} +int usb_gadget_register_driver (struct usb_gadget_driver *driver) {struct at91_udc *udc = &controller;@@ -1763,13 +1792,23 @@ static int __init at91udc_probe(struct platform_device *pdev)* Get the initial state of VBUS - we cannot expect * a pending interrupt. */ - udc->vbus =gpio_get_value (udc->board.vbus_pin); -if (request_irq (udc->board.vbus_pin, at91_vbus_irq, -IRQF_DISABLED , driver_name, udc)) { -DBG ("request vbus irq %d failed\n" , - udc->board.vbus_pin); - retval = -EBUSY ; - goto fail3; + udc->vbus =gpio_get_value_cansleep (udc->board.vbus_pin) ^ + udc->board.vbus_active_low; + +if (udc->board.vbus_polled) { +INIT_WORK (&udc->vbus_timer_work, at91_vbus_timer_work); +setup_timer (&udc->vbus_timer, at91_vbus_timer, + (unsigned long )udc); +mod_timer (&udc->vbus_timer, + jiffies +VBUS_POLL_TIMEOUT ); + }else { +if (request_irq (udc->board.vbus_pin, at91_vbus_irq, +IRQF_DISABLED , driver_name, udc)) { +DBG ("request vbus irq %d failed\n" , + udc->board.vbus_pin); + retval = -EBUSY ; + goto fail3; + } } }else {DBG ("no VBUS detection, assuming always-on\n" );@@ -1855,7 +1894,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)enable_irq_wake (udc->udp_irq); udc->active_suspend = wake; -if (udc->board.vbus_pin >0 && wake) +if (udc->board.vbus_pin >0 && !udc->board.vbus_polled && wake)enable_irq_wake (udc->board.vbus_pin);return 0 ; }@@ -1864,7 +1903,8 @@ static int at91udc_resume(struct platform_device *pdev) {struct at91_udc *udc =platform_get_drvdata (pdev); -if (udc->board.vbus_pin >0 && udc->active_suspend) +if (udc->board.vbus_pin >0 && !udc->board.vbus_polled && + udc->active_suspend)disable_irq_wake (udc->board.vbus_pin);/* maybe reconnect to host; if so, clocks on */ drivers/usb/gadget/at91_udc.h +2
-0@@ -144,6 +144,8 @@ struct at91_udc {struct proc_dir_entry *pde;void __iomem *udp_baseaddr;int udp_irq; +struct timer_list vbus_timer; +struct work_struct vbus_timer_work; };static inline struct at91_udc *to_udc (struct usb_gadget *g)_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St ryan at bluewatersys.com PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
PATCH 2/3 at91_udc: Add vbus polarity and polling mode
In reply to Ryan MallonLe 02/07/2010 06:40, Ryan Mallon :
Quoted 32 lines · Nicolas Ferre
Quoted 13 lines
Le 28/06/2010 06:39, Ryan Mallon :
Quoted 8 lines
Allow the vbus signal to optionally use polling. This is required if the vbus signal is connected to an non-interrupting io expander for example. If vbus is in polling mode, then it is assumed that the vbus gpio may sleep. Also add an option to have vbus be an active low signal. Both options are set in the platform data for the device.
Signed-off-by Ryan Mallon <[email protected]>Looks good, but... one question:
Quoted 17 lines
Quoted 4 lines
drivers/usb/gadget/at91_udc.c +0
-0@@ -1763,13 +1793,22 @@ static int __init at91udc_probe(struct platform_device *pdev)* Get the initial state of VBUS - we cannot expect * a pending interrupt. */ drivers/usb/gadget/at91_udc.c static int __init at91udc_probe(struct platform_device *pdev) · line 1798
Quoted 10 lines
drivers/usb/gadget/at91_udc.c +2
-7- udc->vbus =gpio_get_value (udc->board.vbus_pin); -if (request_irq (udc->board.vbus_pin, at91_vbus_irq, -IRQF_DISABLED , driver_name, udc)) { -DBG ("request vbus irq %d failed\n" , - udc->board.vbus_pin); - retval = -EBUSY ; - goto fail3; +if (udc->board.vbus_polled) { + udc->vbus =gpio_get_value_cansleep (udc->board.vbus_pin);Shouldn't we need here something like:
udc->vbus= (udc->board.vbus_active_low) ^gpio_get_value_cansleep(udc->board.vbus_pin);
Quoted 6 lines
Yes, thanks. The updated patch below fixes it. Also simplify
at91_vbus_update(always do the xor) and move the initial setting ofudc->vbusoutside of theudc->board.vbus_polledtest, since we can usegpio_get_value_cansleepin both cases.Signed-off-by Ryan Mallon <[email protected]>
Quoted 147 lines
---
arch/arm/mach-at91/include/mach/board.h +2
-0@@ -44,6 +44,8 @@/* USB Device */ struct at91_udc_data {u8 vbus_pin;/* high == host powering us */ +u8 vbus_active_low;/* vbus polarity */ +u8 vbus_polled;/* Use polling, not interrupt */ u8 pullup_pin;/* active == D+ pulled up */ u8 pullup_active_low;/* true == pullup_pin is active low */ };drivers/usb/gadget/at91_udc.c +53
-13@@ -76,6 +76,7 @@static const char driver_name [] ="at91_udc" ;static const char ep0name[] ="ep0" ; +#define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000)#define at91_udp_read (dev, reg) \ __raw_readl((dev)->udp_baseaddr + (reg))@@ -1556,20 +1557,48 @@ static struct at91_udc controller = {/* ep6 and ep7 are also reserved (custom silicon might use them) */ }; +static void at91_vbus_update (struct at91_udc *udc,unsigned value) +{ + value ^= udc->board.vbus_active_low; +if (value != udc->vbus) +at91_vbus_session (&udc->gadget, value); +} +static irqreturn_t at91_vbus_irq (int irq,void *_udc) {struct at91_udc *udc = _udc; -unsigned value;/* vbus needs at least brief debouncing */ udelay (10 ); - value =gpio_get_value (udc->board.vbus_pin); -if (value != udc->vbus) -at91_vbus_session (&udc->gadget, value); +at91_vbus_update (udc,gpio_get_value (udc->board.vbus_pin));return IRQ_HANDLED ; } +static void at91_vbus_timer_work (struct work_struct *work) +{ + struct at91_udc *udc = container_of(work, struct at91_udc, + vbus_timer_work); + +at91_vbus_update (udc,gpio_get_value_cansleep (udc->board.vbus_pin)); + +if (!timer_pending (&udc->vbus_timer)) +mod_timer (&udc->vbus_timer, jiffies +VBUS_POLL_TIMEOUT ); +} + +static void at91_vbus_timer (unsigned long data) +{ +struct at91_udc *udc = (struct at91_udc *)data; + +/* +* If we are polling vbus it is likely that the gpio is on an +* bus such as i2c or spi which may sleep, so schedule some work +* to read the vbus gpio +*/ +if (!work_pending (&udc->vbus_timer_work)) +schedule_work (&udc->vbus_timer_work); +} +int usb_gadget_register_driver (struct usb_gadget_driver *driver) {struct at91_udc *udc = &controller;@@ -1763,13 +1792,23 @@ static int __init at91udc_probe(struct platform_device *pdev)* Get the initial state of VBUS - we cannot expect * a pending interrupt. */ - udc->vbus =gpio_get_value (udc->board.vbus_pin); -if (request_irq (udc->board.vbus_pin, at91_vbus_irq, -IRQF_DISABLED , driver_name, udc)) { -DBG ("request vbus irq %d failed\n" , - udc->board.vbus_pin); - retval = -EBUSY ; - goto fail3; + udc->vbus =gpio_get_value_cansleep (udc->board.vbus_pin) ^ + udc->board.vbus_active_low; + +if (udc->board.vbus_polled) { +INIT_WORK (&udc->vbus_timer_work, at91_vbus_timer_work); +setup_timer (&udc->vbus_timer, at91_vbus_timer, + (unsigned long )udc); +mod_timer (&udc->vbus_timer, + jiffies +VBUS_POLL_TIMEOUT ); + }else { +if (request_irq (udc->board.vbus_pin, at91_vbus_irq, +IRQF_DISABLED , driver_name, udc)) { +DBG ("request vbus irq %d failed\n" , + udc->board.vbus_pin); + retval = -EBUSY ; + goto fail3; + } } }else {DBG ("no VBUS detection, assuming always-on\n" );@@ -1855,7 +1894,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg)enable_irq_wake (udc->udp_irq); udc->active_suspend = wake; -if (udc->board.vbus_pin >0 && wake) +if (udc->board.vbus_pin >0 && !udc->board.vbus_polled && wake)enable_irq_wake (udc->board.vbus_pin);return 0 ; }@@ -1864,7 +1903,8 @@ static int at91udc_resume(struct platform_device *pdev) {struct at91_udc *udc =platform_get_drvdata (pdev); -if (udc->board.vbus_pin >0 && udc->active_suspend) +if (udc->board.vbus_pin >0 && !udc->board.vbus_polled && + udc->active_suspend)disable_irq_wake (udc->board.vbus_pin);/* maybe reconnect to host; if so, clocks on */ drivers/usb/gadget/at91_udc.h +2
-0@@ -144,6 +144,8 @@ struct at91_udc {struct proc_dir_entry *pde;void __iomem *udp_baseaddr;int udp_irq; +struct timer_list vbus_timer; +struct work_struct vbus_timer_work; };static inline struct at91_udc *to_udc (struct usb_gadget *g)
Signature · 1 line
Nicolas Ferre
PATCH 3/3 at91: Add support for Bluewater Systems Snapper 9260/9G20 modules
In reply to Ryan MallonAdd support for Bluewater Systems Snapper 9260/9G20 modules
--- arch/arm/mach-at91/Kconfig | 11 ++ arch/arm/mach-at91/Makefile | 3 + arch/arm/mach-at91/board-snapper9260.c | 189 ++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-at91/board-snapper9260.c
arch/arm/mach-at91/Kconfig +11 -0
@@ -366,6 +366,17 @@ config MACH_STAMP9G20 endif +if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) +comment "AT91SAM9260/AT91SAM9G20 boards" + +config MACH_SNAPPER_9260 + bool "Bluewater Systems Snapper 9260/9G20 module" + help + Select this if you are using the Bluewater Systems Snapper 9260 or + Snapper 9G20 modules. + <http://www.bluewatersys.com/> +endif + # ---------------------------------------------------------- if ARCH_AT91SAM9G45
arch/arm/mach-at91/Makefile +3 -0
@@ -66,6 +66,9 @@ obj-$(CONFIG_MACH_CPU9G20) += board-cpu9krea.o obj-$(CONFIG_MACH_STAMP9G20) += board-stamp9g20.o obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o +# AT91SAM9260/AT91SAM9G20 board-specific support +obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o + # AT91SAM9G45 board-specific support obj-$(CONFIG_MACH_AT91SAM9G45EKES) += board-sam9m10g45ek.o
arch/arm/mach-at91/board-snapper9260.c new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 3/3 at91: Add support for Bluewater Systems Snapper 9260/9G20 modules
hi Ryan,
Quoted 1 line
Add support for Bluewater Systems Snapper 9260/9G20 modules
PATCH 3/3 at91: Add support for Bluewater Systems Snapper 9260/9G20 modules
Quoted 5 lines · avictor.za at gmail.com
hi Ryan,
Quoted 1 line
Add support for Bluewater Systems Snapper 9260/9G20 modules
Acked-by Andrew Victor <[email protected]>
Thanks Andrew. Did you want to ack patch 2/3 as well since this patch depends on it. I can submit patch 1/3 to the patch system independently.
~Ryan