Add patch musb_sysfs_hostdevice.diff
[kernel-power] / kernel-power-2.6.28 / debian / patches / musb_sysfs_hostdevice.diff
1 --- kernel-power/drivers/usb/musb/musb_core.h   2012-05-22 23:46:25.063372234 +0200
2 +++ kernel-power/drivers/usb/musb/musb_core.h   2012-05-22 23:58:04.727351773 +0200
3 @@ -431,6 +431,8 @@ struct musb {
4  
5         unsigned                power_draw;     /* current power draw, gadget only */
6  
7 +       const char              *hostdevice;    /* type of usb host device */
8 +
9         bool                    is_host;
10  
11         int                     a_wait_bcon;    /* VBUS timeout in msecs */
12 --- kernel-power/drivers/usb/musb/musb_core.c   2012-05-22 23:36:45.795389167 +0200
13 +++ kernel-power/drivers/usb/musb/musb_core.c   2012-05-22 23:56:42.415354180 +0200
14 @@ -1978,6 +1978,15 @@ musb_amp_show(struct device *dev, struct
15  static DEVICE_ATTR(mA, 0444, musb_amp_show, NULL);
16  
17  static ssize_t
18 +musb_hostdevice_show(struct device *dev, struct device_attribute *attr, char *buf)
19 +{
20 +       struct musb *musb = dev_to_musb(dev);
21 +
22 +       return sprintf(buf, "%s\n", musb->hostdevice);
23 +}
24 +static DEVICE_ATTR(hostdevice, 0444, musb_hostdevice_show, NULL);
25 +
26 +static ssize_t
27  musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
28  {
29         struct musb *musb = dev_to_musb(dev);
30 @@ -2060,6 +2069,8 @@ musb_mode_store(struct device *dev, stru
31                 status = -EINVAL;
32         mutex_unlock(&musb->mutex);
33  
34 +       musb->hostdevice = "none";
35 +       sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
36         sysfs_notify(&musb->controller->kobj, NULL, "mode");
37         schedule_work(&musb->irq_work);
38  
39 @@ -2154,6 +2165,8 @@ static void musb_irq_work(struct work_st
40  
41         if (musb->xceiv->state != old_state) {
42                 old_state = musb->xceiv->state;
43 +               musb->hostdevice = "none";
44 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
45                 sysfs_notify(&musb->controller->kobj, NULL, "mode");
46         }
47         if (musb->power_draw != old_ma) {
48 @@ -2240,6 +2240,7 @@ static void musb_free(struct musb *musb)
49         device_remove_file(musb->controller, &dev_attr_mA);
50         device_remove_file(musb->controller, &dev_attr_connect);
51         device_remove_file(musb->controller, &dev_attr_charger);
52 +       device_remove_file(musb->controller, &dev_attr_hostdevice);
53         device_remove_file(musb->controller, &dev_attr_mode);
54         device_remove_file(musb->controller, &dev_attr_vbus);
55  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
56 @@ -2346,6 +2346,7 @@ bad_config:
57         musb->set_clock = plat->set_clock;
58         musb->min_power = plat->min_power;
59         musb->use_dma = use_dma;
60 +       musb->hostdevice = "none";
61  
62         /* Clock usage is chip-specific ... functional clock (DaVinci,
63          * OMAP2430), or PHY ref (some TUSB6010 boards).  All this core
64 @@ -2486,6 +2487,7 @@ bad_config:
65         status = device_create_file(dev, &dev_attr_mA);
66         status = device_create_file(dev, &dev_attr_connect);
67         status = device_create_file(dev, &dev_attr_charger);
68 +       status = device_create_file(dev, &dev_attr_hostdevice);
69         status = device_create_file(dev, &dev_attr_mode);
70         status = device_create_file(dev, &dev_attr_vbus);
71  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
72 @@ -2510,6 +2512,7 @@ fail2:
73         device_remove_file(dev, &dev_attr_mA);
74         device_remove_file(dev, &dev_attr_connect);
75         device_remove_file(dev, &dev_attr_charger);
76 +       device_remove_file(dev, &dev_attr_hostdevice);
77         device_remove_file(musb->controller, &dev_attr_mode);
78         device_remove_file(musb->controller, &dev_attr_vbus);
79  #ifdef CONFIG_USB_GADGET_MUSB_HDRC
80 --- kernel-power/drivers/usb/musb/musb_procfs.c 2012-05-22 23:35:43.767390980 +0200
81 +++ kernel-power/drivers/usb/musb/musb_procfs.c 2012-05-22 23:57:28.355352837 +0200
82 @@ -692,13 +692,16 @@ static int musb_proc_write(struct file *
83                 case 1: /* pullup indicates a full/high-speed device */
84                         if (!(testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS)))
85                                 pr_err("Forced hostmode error: a full/high-speed device attached but low-speed mode selected\n"); 
86 +                       musb->hostdevice = "full/high";
87                         break;
88                 case 2: /* pullup indicates a low-speed device */
89                         if (testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS))
90                                 pr_err("Forced hostmode error: a low-speed device attached but full/high-speed mode selected\n"); 
91 +                       musb->hostdevice = "low";
92                         break;
93                 default:
94                         pr_err("Forced hostmode error: no device attached\n");
95 +                       musb->hostdevice = "none";
96                 }
97   
98                 if (!(testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS)))
99 @@ -721,6 +724,7 @@ static int musb_proc_write(struct file *
100                 DBG(1, "CONNECT (%s) devctl %02x\n",
101                                 otg_state_string(musb), devctl);
102                 }
103 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
104                 sysfs_notify(&musb->controller->kobj, NULL, "mode");
105                 schedule_work(&musb->irq_work);
106                 break;
107 --- kernel-power/drivers/usb/musb/musb_virthub.c        2012-05-22 23:53:44.471359383 +0200
108 +++ kernel-power/drivers/usb/musb/musb_virthub.c        2012-05-22 23:57:34.791352649 +0200
109 @@ -169,10 +169,13 @@ static void musb_port_reset(struct musb
110                         musb->port1_status |= USB_PORT_STAT_HIGH_SPEED;
111                         if (!(testmode & MUSB_TEST_FORCE_HS))
112                                 pr_err("Forced hostmode error: a high-speed device attached but not high-speed mode selected\n"); 
113 +                       musb->hostdevice = "high";
114                 } else {
115                         if (testmode & MUSB_TEST_FORCE_HS)
116                                 pr_err("Forced hostmode error: a full/low-speed device attached but high-speed mode selected\n"); 
117 +                       musb->hostdevice = "full/low";
118                 }
119 +               sysfs_notify(&musb->controller->kobj, NULL, "hostdevice");
120  
121                 musb->port1_status &= ~USB_PORT_STAT_RESET;
122                 musb->port1_status |= USB_PORT_STAT_ENABLE