aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/omap_udc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/omap_udc.c')
-rw-r--r--drivers/usb/gadget/omap_udc.c85
1 files changed, 43 insertions, 42 deletions
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index ff5533e69560..a8972d7c97be 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -38,7 +38,7 @@
38#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/moduleparam.h> 40#include <linux/moduleparam.h>
41#include <linux/device.h> 41#include <linux/platform_device.h>
42#include <linux/usb_ch9.h> 42#include <linux/usb_ch9.h>
43#include <linux/usb_gadget.h> 43#include <linux/usb_gadget.h>
44#include <linux/usb_otg.h> 44#include <linux/usb_otg.h>
@@ -269,7 +269,7 @@ static int omap_ep_disable(struct usb_ep *_ep)
269/*-------------------------------------------------------------------------*/ 269/*-------------------------------------------------------------------------*/
270 270
271static struct usb_request * 271static struct usb_request *
272omap_alloc_request(struct usb_ep *ep, unsigned gfp_flags) 272omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
273{ 273{
274 struct omap_req *req; 274 struct omap_req *req;
275 275
@@ -298,7 +298,7 @@ omap_alloc_buffer(
298 struct usb_ep *_ep, 298 struct usb_ep *_ep,
299 unsigned bytes, 299 unsigned bytes,
300 dma_addr_t *dma, 300 dma_addr_t *dma,
301 unsigned gfp_flags 301 gfp_t gfp_flags
302) 302)
303{ 303{
304 void *retval; 304 void *retval;
@@ -691,7 +691,7 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req)
691} 691}
692 692
693static void 693static void
694finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status) 694finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status, int one)
695{ 695{
696 u16 count; 696 u16 count;
697 697
@@ -699,6 +699,8 @@ finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status)
699 ep->dma_counter = (u16) (req->req.dma + req->req.actual); 699 ep->dma_counter = (u16) (req->req.dma + req->req.actual);
700 count = dma_dest_len(ep, req->req.dma + req->req.actual); 700 count = dma_dest_len(ep, req->req.dma + req->req.actual);
701 count += req->req.actual; 701 count += req->req.actual;
702 if (one)
703 count--;
702 if (count <= req->req.length) 704 if (count <= req->req.length)
703 req->req.actual = count; 705 req->req.actual = count;
704 706
@@ -747,7 +749,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src)
747 if (!list_empty(&ep->queue)) { 749 if (!list_empty(&ep->queue)) {
748 req = container_of(ep->queue.next, 750 req = container_of(ep->queue.next,
749 struct omap_req, queue); 751 struct omap_req, queue);
750 finish_out_dma(ep, req, 0); 752 finish_out_dma(ep, req, 0, dman_stat & UDC_DMA_RX_SB);
751 } 753 }
752 UDC_IRQ_SRC_REG = UDC_RXN_EOT; 754 UDC_IRQ_SRC_REG = UDC_RXN_EOT;
753 755
@@ -925,7 +927,7 @@ static void dma_channel_release(struct omap_ep *ep)
925 while (UDC_RXDMA_CFG_REG & mask) 927 while (UDC_RXDMA_CFG_REG & mask)
926 udelay(10); 928 udelay(10);
927 if (req) 929 if (req)
928 finish_out_dma(ep, req, -ECONNRESET); 930 finish_out_dma(ep, req, -ECONNRESET, 0);
929 } 931 }
930 omap_free_dma(ep->lch); 932 omap_free_dma(ep->lch);
931 ep->dma_channel = 0; 933 ep->dma_channel = 0;
@@ -937,7 +939,7 @@ static void dma_channel_release(struct omap_ep *ep)
937/*-------------------------------------------------------------------------*/ 939/*-------------------------------------------------------------------------*/
938 940
939static int 941static int
940omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) 942omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
941{ 943{
942 struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); 944 struct omap_ep *ep = container_of(_ep, struct omap_ep, ep);
943 struct omap_req *req = container_of(_req, struct omap_req, req); 945 struct omap_req *req = container_of(_req, struct omap_req, req);
@@ -1786,8 +1788,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
1786 udc->driver->suspend(&udc->gadget); 1788 udc->driver->suspend(&udc->gadget);
1787 spin_lock(&udc->lock); 1789 spin_lock(&udc->lock);
1788 } 1790 }
1791 if (udc->transceiver)
1792 otg_set_suspend(udc->transceiver, 1);
1789 } else { 1793 } else {
1790 VDBG("resume\n"); 1794 VDBG("resume\n");
1795 if (udc->transceiver)
1796 otg_set_suspend(udc->transceiver, 0);
1791 if (udc->gadget.speed == USB_SPEED_FULL 1797 if (udc->gadget.speed == USB_SPEED_FULL
1792 && udc->driver->resume) { 1798 && udc->driver->resume) {
1793 spin_unlock(&udc->lock); 1799 spin_unlock(&udc->lock);
@@ -2701,18 +2707,17 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2701 return 0; 2707 return 0;
2702} 2708}
2703 2709
2704static int __init omap_udc_probe(struct device *dev) 2710static int __init omap_udc_probe(struct platform_device *pdev)
2705{ 2711{
2706 struct platform_device *odev = to_platform_device(dev);
2707 int status = -ENODEV; 2712 int status = -ENODEV;
2708 int hmc; 2713 int hmc;
2709 struct otg_transceiver *xceiv = NULL; 2714 struct otg_transceiver *xceiv = NULL;
2710 const char *type = NULL; 2715 const char *type = NULL;
2711 struct omap_usb_config *config = dev->platform_data; 2716 struct omap_usb_config *config = pdev->dev.platform_data;
2712 2717
2713 /* NOTE: "knows" the order of the resources! */ 2718 /* NOTE: "knows" the order of the resources! */
2714 if (!request_mem_region(odev->resource[0].start, 2719 if (!request_mem_region(pdev->resource[0].start,
2715 odev->resource[0].end - odev->resource[0].start + 1, 2720 pdev->resource[0].end - pdev->resource[0].start + 1,
2716 driver_name)) { 2721 driver_name)) {
2717 DBG("request_mem_region failed\n"); 2722 DBG("request_mem_region failed\n");
2718 return -EBUSY; 2723 return -EBUSY;
@@ -2797,7 +2802,7 @@ bad_on_1710:
2797 INFO("hmc mode %d, %s transceiver\n", hmc, type); 2802 INFO("hmc mode %d, %s transceiver\n", hmc, type);
2798 2803
2799 /* a "gadget" abstracts/virtualizes the controller */ 2804 /* a "gadget" abstracts/virtualizes the controller */
2800 status = omap_udc_setup(odev, xceiv); 2805 status = omap_udc_setup(pdev, xceiv);
2801 if (status) { 2806 if (status) {
2802 goto cleanup0; 2807 goto cleanup0;
2803 } 2808 }
@@ -2815,28 +2820,28 @@ bad_on_1710:
2815 udc->clr_halt = UDC_RESET_EP; 2820 udc->clr_halt = UDC_RESET_EP;
2816 2821
2817 /* USB general purpose IRQ: ep0, state changes, dma, etc */ 2822 /* USB general purpose IRQ: ep0, state changes, dma, etc */
2818 status = request_irq(odev->resource[1].start, omap_udc_irq, 2823 status = request_irq(pdev->resource[1].start, omap_udc_irq,
2819 SA_SAMPLE_RANDOM, driver_name, udc); 2824 SA_SAMPLE_RANDOM, driver_name, udc);
2820 if (status != 0) { 2825 if (status != 0) {
2821 ERR( "can't get irq %ld, err %d\n", 2826 ERR( "can't get irq %ld, err %d\n",
2822 odev->resource[1].start, status); 2827 pdev->resource[1].start, status);
2823 goto cleanup1; 2828 goto cleanup1;
2824 } 2829 }
2825 2830
2826 /* USB "non-iso" IRQ (PIO for all but ep0) */ 2831 /* USB "non-iso" IRQ (PIO for all but ep0) */
2827 status = request_irq(odev->resource[2].start, omap_udc_pio_irq, 2832 status = request_irq(pdev->resource[2].start, omap_udc_pio_irq,
2828 SA_SAMPLE_RANDOM, "omap_udc pio", udc); 2833 SA_SAMPLE_RANDOM, "omap_udc pio", udc);
2829 if (status != 0) { 2834 if (status != 0) {
2830 ERR( "can't get irq %ld, err %d\n", 2835 ERR( "can't get irq %ld, err %d\n",
2831 odev->resource[2].start, status); 2836 pdev->resource[2].start, status);
2832 goto cleanup2; 2837 goto cleanup2;
2833 } 2838 }
2834#ifdef USE_ISO 2839#ifdef USE_ISO
2835 status = request_irq(odev->resource[3].start, omap_udc_iso_irq, 2840 status = request_irq(pdev->resource[3].start, omap_udc_iso_irq,
2836 SA_INTERRUPT, "omap_udc iso", udc); 2841 SA_INTERRUPT, "omap_udc iso", udc);
2837 if (status != 0) { 2842 if (status != 0) {
2838 ERR("can't get irq %ld, err %d\n", 2843 ERR("can't get irq %ld, err %d\n",
2839 odev->resource[3].start, status); 2844 pdev->resource[3].start, status);
2840 goto cleanup3; 2845 goto cleanup3;
2841 } 2846 }
2842#endif 2847#endif
@@ -2847,11 +2852,11 @@ bad_on_1710:
2847 2852
2848#ifdef USE_ISO 2853#ifdef USE_ISO
2849cleanup3: 2854cleanup3:
2850 free_irq(odev->resource[2].start, udc); 2855 free_irq(pdev->resource[2].start, udc);
2851#endif 2856#endif
2852 2857
2853cleanup2: 2858cleanup2:
2854 free_irq(odev->resource[1].start, udc); 2859 free_irq(pdev->resource[1].start, udc);
2855 2860
2856cleanup1: 2861cleanup1:
2857 kfree (udc); 2862 kfree (udc);
@@ -2860,14 +2865,13 @@ cleanup1:
2860cleanup0: 2865cleanup0:
2861 if (xceiv) 2866 if (xceiv)
2862 put_device(xceiv->dev); 2867 put_device(xceiv->dev);
2863 release_mem_region(odev->resource[0].start, 2868 release_mem_region(pdev->resource[0].start,
2864 odev->resource[0].end - odev->resource[0].start + 1); 2869 pdev->resource[0].end - pdev->resource[0].start + 1);
2865 return status; 2870 return status;
2866} 2871}
2867 2872
2868static int __exit omap_udc_remove(struct device *dev) 2873static int __exit omap_udc_remove(struct platform_device *pdev)
2869{ 2874{
2870 struct platform_device *odev = to_platform_device(dev);
2871 DECLARE_COMPLETION(done); 2875 DECLARE_COMPLETION(done);
2872 2876
2873 if (!udc) 2877 if (!udc)
@@ -2885,13 +2889,13 @@ static int __exit omap_udc_remove(struct device *dev)
2885 remove_proc_file(); 2889 remove_proc_file();
2886 2890
2887#ifdef USE_ISO 2891#ifdef USE_ISO
2888 free_irq(odev->resource[3].start, udc); 2892 free_irq(pdev->resource[3].start, udc);
2889#endif 2893#endif
2890 free_irq(odev->resource[2].start, udc); 2894 free_irq(pdev->resource[2].start, udc);
2891 free_irq(odev->resource[1].start, udc); 2895 free_irq(pdev->resource[1].start, udc);
2892 2896
2893 release_mem_region(odev->resource[0].start, 2897 release_mem_region(pdev->resource[0].start,
2894 odev->resource[0].end - odev->resource[0].start + 1); 2898 pdev->resource[0].end - pdev->resource[0].start + 1);
2895 2899
2896 device_unregister(&udc->gadget.dev); 2900 device_unregister(&udc->gadget.dev);
2897 wait_for_completion(&done); 2901 wait_for_completion(&done);
@@ -2909,12 +2913,10 @@ static int __exit omap_udc_remove(struct device *dev)
2909 * may involve talking to an external transceiver (e.g. isp1301). 2913 * may involve talking to an external transceiver (e.g. isp1301).
2910 */ 2914 */
2911 2915
2912static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) 2916static int omap_udc_suspend(struct platform_device *dev, pm_message_t message)
2913{ 2917{
2914 u32 devstat; 2918 u32 devstat;
2915 2919
2916 if (level != SUSPEND_POWER_DOWN)
2917 return 0;
2918 devstat = UDC_DEVSTAT_REG; 2920 devstat = UDC_DEVSTAT_REG;
2919 2921
2920 /* we're requesting 48 MHz clock if the pullup is enabled 2922 /* we're requesting 48 MHz clock if the pullup is enabled
@@ -2931,11 +2933,8 @@ static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level)
2931 return 0; 2933 return 0;
2932} 2934}
2933 2935
2934static int omap_udc_resume(struct device *dev, u32 level) 2936static int omap_udc_resume(struct platform_device *dev)
2935{ 2937{
2936 if (level != RESUME_POWER_ON)
2937 return 0;
2938
2939 DBG("resume + wakeup/SRP\n"); 2938 DBG("resume + wakeup/SRP\n");
2940 omap_pullup(&udc->gadget, 1); 2939 omap_pullup(&udc->gadget, 1);
2941 2940
@@ -2946,13 +2945,15 @@ static int omap_udc_resume(struct device *dev, u32 level)
2946 2945
2947/*-------------------------------------------------------------------------*/ 2946/*-------------------------------------------------------------------------*/
2948 2947
2949static struct device_driver udc_driver = { 2948static struct platform_driver udc_driver = {
2950 .name = (char *) driver_name,
2951 .bus = &platform_bus_type,
2952 .probe = omap_udc_probe, 2949 .probe = omap_udc_probe,
2953 .remove = __exit_p(omap_udc_remove), 2950 .remove = __exit_p(omap_udc_remove),
2954 .suspend = omap_udc_suspend, 2951 .suspend = omap_udc_suspend,
2955 .resume = omap_udc_resume, 2952 .resume = omap_udc_resume,
2953 .driver = {
2954 .owner = THIS_MODULE,
2955 .name = (char *) driver_name,
2956 },
2956}; 2957};
2957 2958
2958static int __init udc_init(void) 2959static int __init udc_init(void)
@@ -2963,13 +2964,13 @@ static int __init udc_init(void)
2963#endif 2964#endif
2964 "%s\n", driver_desc, 2965 "%s\n", driver_desc,
2965 use_dma ? " (dma)" : ""); 2966 use_dma ? " (dma)" : "");
2966 return driver_register(&udc_driver); 2967 return platform_driver_register(&udc_driver);
2967} 2968}
2968module_init(udc_init); 2969module_init(udc_init);
2969 2970
2970static void __exit udc_exit(void) 2971static void __exit udc_exit(void)
2971{ 2972{
2972 driver_unregister(&udc_driver); 2973 platform_driver_unregister(&udc_driver);
2973} 2974}
2974module_exit(udc_exit); 2975module_exit(udc_exit);
2975 2976