aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-10-11 01:06:46 -0400
committerFelipe Balbi <balbi@ti.com>2011-10-13 13:41:49 -0400
commiteb05191f6a9aba8344a0d5f28642b5ecf44d49a4 (patch)
treed86743fd474d71d7dfd1bf0af827cb404b3ed7e4 /drivers/usb/renesas_usbhs
parenta9be4a45627c0eaa5f3f16987243530f4df6b514 (diff)
usb: gadget: renesas_usbhs: add usbhs_set_device_speed() support for host
mod_host needs device speed setup function Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs')
-rw-r--r--drivers/usb/renesas_usbhs/common.c42
-rw-r--r--drivers/usb/renesas_usbhs/common.h25
2 files changed, 67 insertions, 0 deletions
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 895eb44a1a51..c3aef40fa9e5 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -227,6 +227,48 @@ static void usbhsc_bus_init(struct usbhs_priv *priv)
227} 227}
228 228
229/* 229/*
230 * device configuration
231 */
232int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum,
233 u16 upphub, u16 hubport, u16 speed)
234{
235 struct device *dev = usbhs_priv_to_dev(priv);
236 u16 usbspd = 0;
237 u32 reg = DEVADD0 + (2 * devnum);
238
239 if (devnum > 10) {
240 dev_err(dev, "cannot set speed to unknown device %d\n", devnum);
241 return -EIO;
242 }
243
244 if (upphub > 0xA) {
245 dev_err(dev, "unsupported hub number %d\n", upphub);
246 return -EIO;
247 }
248
249 switch (speed) {
250 case USB_SPEED_LOW:
251 usbspd = USBSPD_SPEED_LOW;
252 break;
253 case USB_SPEED_FULL:
254 usbspd = USBSPD_SPEED_FULL;
255 break;
256 case USB_SPEED_HIGH:
257 usbspd = USBSPD_SPEED_HIGH;
258 break;
259 default:
260 dev_err(dev, "unsupported speed %d\n", speed);
261 return -EIO;
262 }
263
264 usbhs_write(priv, reg, UPPHUB(upphub) |
265 HUBPORT(hubport)|
266 USBSPD(usbspd));
267
268 return 0;
269}
270
271/*
230 * local functions 272 * local functions
231 */ 273 */
232static void usbhsc_set_buswait(struct usbhs_priv *priv) 274static void usbhsc_set_buswait(struct usbhs_priv *priv)
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h
index 7822b0b8aeed..0e867a33a46e 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -90,6 +90,17 @@ struct usbhs_priv;
90#define PIPE9TRN 0x00BA 90#define PIPE9TRN 0x00BA
91#define PIPEATRE 0x00BC 91#define PIPEATRE 0x00BC
92#define PIPEATRN 0x00BE 92#define PIPEATRN 0x00BE
93#define DEVADD0 0x00D0 /* Device address n configuration */
94#define DEVADD1 0x00D2
95#define DEVADD2 0x00D4
96#define DEVADD3 0x00D6
97#define DEVADD4 0x00D8
98#define DEVADD5 0x00DA
99#define DEVADD6 0x00DC
100#define DEVADD7 0x00DE
101#define DEVADD8 0x00E0
102#define DEVADD9 0x00E2
103#define DEVADDA 0x00E4
93 104
94/* SYSCFG */ 105/* SYSCFG */
95#define SCKE (1 << 10) /* USB Module Clock Enable */ 106#define SCKE (1 << 10) /* USB Module Clock Enable */
@@ -206,6 +217,14 @@ struct usbhs_priv;
206/* FRMNUM */ 217/* FRMNUM */
207#define FRNM_MASK (0x7FF) 218#define FRNM_MASK (0x7FF)
208 219
220/* DEVADDn */
221#define UPPHUB(x) (((x) & 0xF) << 11) /* HUB Register */
222#define HUBPORT(x) (((x) & 0x7) << 8) /* HUB Port for Target Device */
223#define USBSPD(x) (((x) & 0x3) << 6) /* Device Transfer Rate */
224#define USBSPD_SPEED_LOW 0x1
225#define USBSPD_SPEED_FULL 0x2
226#define USBSPD_SPEED_HIGH 0x3
227
209/* 228/*
210 * struct 229 * struct
211 */ 230 */
@@ -281,6 +300,12 @@ int usbhs_vbus_ctrl(struct usbhs_priv *priv, int enable);
281int usbhs_frame_get_num(struct usbhs_priv *priv); 300int usbhs_frame_get_num(struct usbhs_priv *priv);
282 301
283/* 302/*
303 * device config
304 */
305int usbhs_set_device_speed(struct usbhs_priv *priv, int devnum, u16 upphub,
306 u16 hubport, u16 speed);
307
308/*
284 * data 309 * data
285 */ 310 */
286struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev); 311struct usbhs_priv *usbhs_pdev_to_priv(struct platform_device *pdev);