diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-10-11 01:01:51 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-10-13 13:41:38 -0400 |
commit | 75587f52c7b0d6c319515138a495a619b552a670 (patch) | |
tree | f032810f68a32bae18cdf1580bc0ba5422f650bd | |
parent | 258485d9904703c4cb3a2b3ee38fe2a0cbf01f48 (diff) |
usb: gadget: renesas_usbhs: add usbhs_bus_get_speed()
current mod_gadget had got usb speed on
usbhsg_irq_dev_state() which is status change interrupt callback function.
And the usb speed data was included in its parameter.
But this style works for mod_gadget,
but doesn't work for mod_host which
isn't interrupted when device status was changed.
This patch add usbhs_bus_get_speed() to solve this issue.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/renesas_usbhs/common.c | 16 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/common.h | 1 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/mod.c | 16 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/mod.h | 2 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/mod_gadget.c | 2 |
5 files changed, 18 insertions, 19 deletions
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 243512d93e58..17abdfe53067 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -159,6 +159,22 @@ void usbhs_bus_send_reset(struct usbhs_priv *priv) | |||
159 | usbhs_bset(priv, DVSTCTR, (USBRST | UACT), USBRST); | 159 | usbhs_bset(priv, DVSTCTR, (USBRST | UACT), USBRST); |
160 | } | 160 | } |
161 | 161 | ||
162 | int usbhs_bus_get_speed(struct usbhs_priv *priv) | ||
163 | { | ||
164 | u16 dvstctr = usbhs_read(priv, DVSTCTR); | ||
165 | |||
166 | switch (RHST & dvstctr) { | ||
167 | case RHST_LOW_SPEED: | ||
168 | return USB_SPEED_LOW; | ||
169 | case RHST_FULL_SPEED: | ||
170 | return USB_SPEED_FULL; | ||
171 | case RHST_HIGH_SPEED: | ||
172 | return USB_SPEED_HIGH; | ||
173 | } | ||
174 | |||
175 | return USB_SPEED_UNKNOWN; | ||
176 | } | ||
177 | |||
162 | int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable) | 178 | int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable) |
163 | { | 179 | { |
164 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); | 180 | struct platform_device *pdev = usbhs_priv_to_pdev(priv); |
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index 54b5924baae7..a5cef8160107 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h | |||
@@ -264,6 +264,7 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); | |||
264 | */ | 264 | */ |
265 | void usbhs_bus_send_sof_enable(struct usbhs_priv *priv); | 265 | void usbhs_bus_send_sof_enable(struct usbhs_priv *priv); |
266 | void usbhs_bus_send_reset(struct usbhs_priv *priv); | 266 | void usbhs_bus_send_reset(struct usbhs_priv *priv); |
267 | int usbhs_bus_get_speed(struct usbhs_priv *priv); | ||
267 | int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable); | 268 | int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable); |
268 | 269 | ||
269 | /* | 270 | /* |
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 74ef49e7dd5f..ab1203098931 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
@@ -168,20 +168,6 @@ void usbhs_mod_remove(struct usbhs_priv *priv) | |||
168 | /* | 168 | /* |
169 | * status functions | 169 | * status functions |
170 | */ | 170 | */ |
171 | int usbhs_status_get_usb_speed(struct usbhs_irq_state *irq_state) | ||
172 | { | ||
173 | switch (irq_state->dvstctr & RHST) { | ||
174 | case RHST_LOW_SPEED: | ||
175 | return USB_SPEED_LOW; | ||
176 | case RHST_FULL_SPEED: | ||
177 | return USB_SPEED_FULL; | ||
178 | case RHST_HIGH_SPEED: | ||
179 | return USB_SPEED_HIGH; | ||
180 | } | ||
181 | |||
182 | return USB_SPEED_UNKNOWN; | ||
183 | } | ||
184 | |||
185 | int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state) | 171 | int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state) |
186 | { | 172 | { |
187 | int state = irq_state->intsts0 & DVSQ_MASK; | 173 | int state = irq_state->intsts0 & DVSQ_MASK; |
@@ -221,8 +207,6 @@ static void usbhs_status_get_each_irq(struct usbhs_priv *priv, | |||
221 | state->intsts0 = usbhs_read(priv, INTSTS0); | 207 | state->intsts0 = usbhs_read(priv, INTSTS0); |
222 | state->intsts1 = usbhs_read(priv, INTSTS1); | 208 | state->intsts1 = usbhs_read(priv, INTSTS1); |
223 | 209 | ||
224 | state->dvstctr = usbhs_read(priv, DVSTCTR); | ||
225 | |||
226 | /* mask */ | 210 | /* mask */ |
227 | if (mod) { | 211 | if (mod) { |
228 | state->brdysts = usbhs_read(priv, BRDYSTS); | 212 | state->brdysts = usbhs_read(priv, BRDYSTS); |
diff --git a/drivers/usb/renesas_usbhs/mod.h b/drivers/usb/renesas_usbhs/mod.h index 5c845a28a21c..93edb1f29eb0 100644 --- a/drivers/usb/renesas_usbhs/mod.h +++ b/drivers/usb/renesas_usbhs/mod.h | |||
@@ -30,7 +30,6 @@ struct usbhs_irq_state { | |||
30 | u16 brdysts; | 30 | u16 brdysts; |
31 | u16 nrdysts; | 31 | u16 nrdysts; |
32 | u16 bempsts; | 32 | u16 bempsts; |
33 | u16 dvstctr; | ||
34 | }; | 33 | }; |
35 | 34 | ||
36 | struct usbhs_mod { | 35 | struct usbhs_mod { |
@@ -99,7 +98,6 @@ void usbhs_mod_autonomy_mode(struct usbhs_priv *priv); | |||
99 | /* | 98 | /* |
100 | * status functions | 99 | * status functions |
101 | */ | 100 | */ |
102 | int usbhs_status_get_usb_speed(struct usbhs_irq_state *irq_state); | ||
103 | int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state); | 101 | int usbhs_status_get_device_state(struct usbhs_irq_state *irq_state); |
104 | int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state); | 102 | int usbhs_status_get_ctrl_stage(struct usbhs_irq_state *irq_state); |
105 | 103 | ||
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index babd90c979c1..ae7d816c23d9 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -353,7 +353,7 @@ static int usbhsg_irq_dev_state(struct usbhs_priv *priv, | |||
353 | struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); | 353 | struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); |
354 | struct device *dev = usbhsg_gpriv_to_dev(gpriv); | 354 | struct device *dev = usbhsg_gpriv_to_dev(gpriv); |
355 | 355 | ||
356 | gpriv->gadget.speed = usbhs_status_get_usb_speed(irq_state); | 356 | gpriv->gadget.speed = usbhs_bus_get_speed(priv); |
357 | 357 | ||
358 | dev_dbg(dev, "state = %x : speed : %d\n", | 358 | dev_dbg(dev, "state = %x : speed : %d\n", |
359 | usbhs_status_get_device_state(irq_state), | 359 | usbhs_status_get_device_state(irq_state), |