diff options
author | Peter Korsgaard <jacmet@sunsite.dk> | 2008-04-27 02:59:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-02 13:25:57 -0400 |
commit | e9b29ffc519b9e63d4e1c0b1278bb951bb418a9d (patch) | |
tree | 4da71b6882ff9c41690a1ebcfaf3f3de5154c082 /drivers/usb/c67x00/c67x00-ll-hpi.c | |
parent | b02b371e6d14961ad458ca9d88b30eefef77003d (diff) |
USB: add Cypress c67x00 OTG controller HCD driver
This patch adds HCD support for the Cypress c67x00 family of devices.
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/c67x00/c67x00-ll-hpi.c')
-rw-r--r-- | drivers/usb/c67x00/c67x00-ll-hpi.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c b/drivers/usb/c67x00/c67x00-ll-hpi.c index e921991bc36a..f3430b372f09 100644 --- a/drivers/usb/c67x00/c67x00-ll-hpi.c +++ b/drivers/usb/c67x00/c67x00-ll-hpi.c | |||
@@ -297,6 +297,81 @@ static int c67x00_comm_exec_int(struct c67x00_device *dev, u16 nr, | |||
297 | } | 297 | } |
298 | 298 | ||
299 | /* -------------------------------------------------------------------------- */ | 299 | /* -------------------------------------------------------------------------- */ |
300 | /* Host specific functions */ | ||
301 | |||
302 | void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value) | ||
303 | { | ||
304 | mutex_lock(&dev->hpi.lcp.mutex); | ||
305 | hpi_write_word(dev, HUSB_pEOT, value); | ||
306 | mutex_unlock(&dev->hpi.lcp.mutex); | ||
307 | } | ||
308 | |||
309 | static inline void c67x00_ll_husb_sie_init(struct c67x00_sie *sie) | ||
310 | { | ||
311 | struct c67x00_device *dev = sie->dev; | ||
312 | struct c67x00_lcp_int_data data; | ||
313 | int rc; | ||
314 | |||
315 | rc = c67x00_comm_exec_int(dev, HUSB_SIE_INIT_INT(sie->sie_num), &data); | ||
316 | BUG_ON(rc); /* No return path for error code; crash spectacularly */ | ||
317 | } | ||
318 | |||
319 | void c67x00_ll_husb_reset(struct c67x00_sie *sie, int port) | ||
320 | { | ||
321 | struct c67x00_device *dev = sie->dev; | ||
322 | struct c67x00_lcp_int_data data; | ||
323 | int rc; | ||
324 | |||
325 | data.regs[0] = 50; /* Reset USB port for 50ms */ | ||
326 | data.regs[1] = port | (sie->sie_num << 1); | ||
327 | rc = c67x00_comm_exec_int(dev, HUSB_RESET_INT, &data); | ||
328 | BUG_ON(rc); /* No return path for error code; crash spectacularly */ | ||
329 | } | ||
330 | |||
331 | void c67x00_ll_husb_set_current_td(struct c67x00_sie *sie, u16 addr) | ||
332 | { | ||
333 | hpi_write_word(sie->dev, HUSB_SIE_pCurrentTDPtr(sie->sie_num), addr); | ||
334 | } | ||
335 | |||
336 | u16 c67x00_ll_husb_get_current_td(struct c67x00_sie *sie) | ||
337 | { | ||
338 | return hpi_read_word(sie->dev, HUSB_SIE_pCurrentTDPtr(sie->sie_num)); | ||
339 | } | ||
340 | |||
341 | u16 c67x00_ll_husb_get_frame(struct c67x00_sie *sie) | ||
342 | { | ||
343 | return hpi_read_word(sie->dev, HOST_FRAME_REG(sie->sie_num)); | ||
344 | } | ||
345 | |||
346 | void c67x00_ll_husb_init_host_port(struct c67x00_sie *sie) | ||
347 | { | ||
348 | /* Set port into host mode */ | ||
349 | hpi_set_bits(sie->dev, USB_CTL_REG(sie->sie_num), HOST_MODE); | ||
350 | c67x00_ll_husb_sie_init(sie); | ||
351 | /* Clear interrupts */ | ||
352 | c67x00_ll_usb_clear_status(sie, HOST_STAT_MASK); | ||
353 | /* Check */ | ||
354 | if (!(hpi_read_word(sie->dev, USB_CTL_REG(sie->sie_num)) & HOST_MODE)) | ||
355 | dev_warn(sie_dev(sie), | ||
356 | "SIE %d not set to host mode\n", sie->sie_num); | ||
357 | } | ||
358 | |||
359 | void c67x00_ll_husb_reset_port(struct c67x00_sie *sie, int port) | ||
360 | { | ||
361 | /* Clear connect change */ | ||
362 | c67x00_ll_usb_clear_status(sie, PORT_CONNECT_CHANGE(port)); | ||
363 | |||
364 | /* Enable interrupts */ | ||
365 | hpi_set_bits(sie->dev, HPI_IRQ_ROUTING_REG, | ||
366 | SOFEOP_TO_CPU_EN(sie->sie_num)); | ||
367 | hpi_set_bits(sie->dev, HOST_IRQ_EN_REG(sie->sie_num), | ||
368 | SOF_EOP_IRQ_EN | DONE_IRQ_EN); | ||
369 | |||
370 | /* Enable pull down transistors */ | ||
371 | hpi_set_bits(sie->dev, USB_CTL_REG(sie->sie_num), PORT_RES_EN(port)); | ||
372 | } | ||
373 | |||
374 | /* -------------------------------------------------------------------------- */ | ||
300 | 375 | ||
301 | void c67x00_ll_irq(struct c67x00_device *dev, u16 int_status) | 376 | void c67x00_ll_irq(struct c67x00_device *dev, u16 int_status) |
302 | { | 377 | { |