aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2015-03-16 22:40:50 -0400
committerPeter Chen <peter.chen@freescale.com>2015-08-13 21:13:11 -0400
commitbf9c85e78d0fec61360ece46dacf9ab71ba89361 (patch)
tree1356a3a4348e74f3539c194b9a969fe3864cb088
parent9d2effea12a3a7139daf04a2be97f18d3e6913a3 (diff)
usb: chipidea: introduce ci_platform_configure
It is used to configure controller parameters according to platform data, like speed, stream mode, etc, both host and device's initialization need it, most of code are the same for both roles, with this new interface, it can reduce the duplicated code and be easy to maintain in future. Signed-off-by: Peter Chen <peter.chen@freescale.com>
-rw-r--r--drivers/usb/chipidea/ci.h2
-rw-r--r--drivers/usb/chipidea/core.c34
-rw-r--r--drivers/usb/chipidea/host.c9
3 files changed, 27 insertions, 18 deletions
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index df57e49ed4ef..1320a4dbbcd5 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -427,4 +427,6 @@ u8 hw_port_test_get(struct ci_hdrc *ci);
427int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask, 427int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
428 u32 value, unsigned int timeout_ms); 428 u32 value, unsigned int timeout_ms);
429 429
430void ci_platform_configure(struct ci_hdrc *ci);
431
430#endif /* __DRIVERS_USB_CHIPIDEA_CI_H */ 432#endif /* __DRIVERS_USB_CHIPIDEA_CI_H */
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index b0d01f26cd5e..1b1dd80897f7 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -405,6 +405,28 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
405 return ret; 405 return ret;
406} 406}
407 407
408
409/**
410 * ci_platform_configure: do controller configure
411 * @ci: the controller
412 *
413 */
414void ci_platform_configure(struct ci_hdrc *ci)
415{
416 if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
417 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
418
419 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
420 if (ci->hw_bank.lpm)
421 hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
422 else
423 hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
424 }
425
426 if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA)
427 hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA);
428}
429
408/** 430/**
409 * hw_controller_reset: do controller reset 431 * hw_controller_reset: do controller reset
410 * @ci: the controller 432 * @ci: the controller
@@ -449,16 +471,6 @@ int hw_device_reset(struct ci_hdrc *ci)
449 ci->platdata->notify_event(ci, 471 ci->platdata->notify_event(ci,
450 CI_HDRC_CONTROLLER_RESET_EVENT); 472 CI_HDRC_CONTROLLER_RESET_EVENT);
451 473
452 if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
453 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
454
455 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
456 if (ci->hw_bank.lpm)
457 hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
458 else
459 hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
460 }
461
462 /* USBMODE should be configured step by step */ 474 /* USBMODE should be configured step by step */
463 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE); 475 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
464 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC); 476 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC);
@@ -471,6 +483,8 @@ int hw_device_reset(struct ci_hdrc *ci)
471 return -ENODEV; 483 return -ENODEV;
472 } 484 }
473 485
486 ci_platform_configure(ci);
487
474 return 0; 488 return 0;
475} 489}
476 490
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index b01716c8c66b..44554318db8a 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -153,14 +153,7 @@ static int host_start(struct ci_hdrc *ci)
153 } 153 }
154 } 154 }
155 155
156 if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING) 156 ci_platform_configure(ci);
157 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
158
159 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED)
160 hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
161
162 if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA)
163 hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA);
164 157
165 return ret; 158 return ret;
166 159