963b09c2244328d0fa5d6219a96456c6bae34a69
[librecmc/librecmc.git] / target / linux / omap24xx / patches-2.6.38 / 590-cbus-tahvo-usb-fixes.patch
1 Index: linux-2.6.38-rc7/drivers/cbus/tahvo-usb.c
2 ===================================================================
3 --- linux-2.6.38-rc7.orig/drivers/cbus/tahvo-usb.c      2011-03-06 23:00:14.411191087 +0100
4 +++ linux-2.6.38-rc7/drivers/cbus/tahvo-usb.c   2011-03-06 23:00:16.571473834 +0100
5 @@ -98,6 +98,7 @@ struct tahvo_usb {
6  #ifdef CONFIG_USB_OTG
7         int tahvo_mode;
8  #endif
9 +       struct clk *ick;
10  };
11  static struct platform_device tahvo_usb_device;
12  
13 @@ -673,6 +674,14 @@ static int __init tahvo_usb_probe(struct
14         INIT_WORK(&tu->irq_work, tahvo_usb_irq_work);
15         mutex_init(&tu->serialize);
16  
17 +       tu->ick = clk_get(NULL, "usb_l4_ick");
18 +       if (IS_ERR(tu->ick)) {
19 +               printk(KERN_ERR "Failed to get usb_l4_ick\n");
20 +               ret = PTR_ERR(tu->ick);
21 +               goto err_free_tu;
22 +       }
23 +       clk_enable(tu->ick);
24 +
25         /* Set initial state, so that we generate kevents only on
26          * state changes */
27         tu->vbus_state = tahvo_read_reg(TAHVO_REG_IDSR) & 0x01;
28 @@ -680,10 +689,9 @@ static int __init tahvo_usb_probe(struct
29         /* We cannot enable interrupt until omap_udc is initialized */
30         ret = tahvo_request_irq(TAHVO_INT_VBUSON, tahvo_usb_vbus_interrupt,
31                                 (unsigned long) tu, "vbus_interrupt");
32 -       if (ret != 0) {
33 -               kfree(tu);
34 +       if (ret) {
35                 printk(KERN_ERR "Could not register Tahvo interrupt for VBUS\n");
36 -               return ret;
37 +               goto err_release_clk;
38         }
39  
40         /* Attributes */
41 @@ -708,9 +716,7 @@ static int __init tahvo_usb_probe(struct
42         ret = otg_set_transceiver(&tu->otg);
43         if (ret < 0) {
44                 printk(KERN_ERR "Cannot register USB transceiver\n");
45 -               kfree(tu);
46 -               tahvo_free_irq(TAHVO_INT_VBUSON);
47 -               return ret;
48 +               goto err_free_irq;
49         }
50  
51         dev_set_drvdata(dev, tu);
52 @@ -719,10 +725,22 @@ static int __init tahvo_usb_probe(struct
53          * may not be generated in addition to this. */
54         schedule_work(&tu->irq_work);
55         return 0;
56 +
57 +err_free_irq:
58 +       tahvo_free_irq(TAHVO_INT_VBUSON);
59 +err_release_clk:
60 +       clk_disable(tu->ick);
61 +       clk_put(tu->ick);
62 +err_free_tu:
63 +       kfree(tu);
64 +
65 +       return ret;
66  }
67  
68  static int __exit tahvo_usb_remove(struct platform_device *pdev)
69  {
70 +       struct tahvo_usb *tu = platform_get_drvdata(pdev);
71 +
72         dev_dbg(&pdev->dev, "remove\n");
73  
74         tahvo_free_irq(TAHVO_INT_VBUSON);
75 @@ -732,6 +750,11 @@ static int __exit tahvo_usb_remove(struc
76  #ifdef CONFIG_USB_OTG
77         device_remove_file(&pdev->dev, &dev_attr_otg_mode);
78  #endif
79 +       clk_disable(tu->ick);
80 +       clk_put(tu->ick);
81 +
82 +       kfree(tu);
83 +
84         return 0;
85  }
86  
87 Index: linux-2.6.38-rc7/arch/arm/mach-omap2/board-n8x0.c
88 ===================================================================
89 --- linux-2.6.38-rc7.orig/arch/arm/mach-omap2/board-n8x0.c      2011-03-06 23:00:14.388188076 +0100
90 +++ linux-2.6.38-rc7/arch/arm/mach-omap2/board-n8x0.c   2011-03-06 23:06:50.508033149 +0100
91 @@ -40,6 +40,7 @@
92  #include <plat/serial.h>
93  #include <plat/cbus.h>
94  #include <plat/gpio-switch.h>
95 +#include <plat/usb.h>
96  
97  #include "mux.h"
98  
99 @@ -395,6 +396,14 @@ static struct musb_hdrc_platform_data tu
100         .config         = &musb_config,
101  };
102  
103 +static struct omap_usb_config n8x0_omap_usb_config __initdata = {
104 +       .otg            = 1,
105 +       .register_host  = 1,
106 +       .register_dev   = 1,
107 +       .hmc_mode       = 16,
108 +       .pins[0]        = 6,
109 +};
110 +
111  static void __init n8x0_usb_init(void)
112  {
113         int ret = 0;
114 @@ -417,6 +426,8 @@ static void __init n8x0_usb_init(void)
115         if (ret != 0)
116                 goto err;
117  
118 +       omap2_usbfs_init(&n8x0_omap_usb_config);
119 +
120         printk(announce);
121  
122         return;