18 #include <linux/module.h>
20 #include <linux/slab.h>
47 #define USBHSF_RUNTIME_PWCTRL (1 << 0)
50 #define usbhsc_flags_init(p) do {(p)->flags = 0; } while (0)
51 #define usbhsc_flags_set(p, b) ((p)->flags |= (b))
52 #define usbhsc_flags_clr(p, b) ((p)->flags &= ~(b))
53 #define usbhsc_flags_has(p, b) ((p)->flags & (b))
62 #define usbhs_platform_call(priv, func, args...)\
63 (!(priv) ? -ENODEV : \
64 !((priv)->pfunc.func) ? 0 : \
65 (priv)->pfunc.func(args))
183 dev_err(dev,
"usbhs should be reset\n");
198 switch (
RHST & dvstctr) {
235 dev_err(dev,
"cannot set speed to unknown device %d\n", devnum);
240 dev_err(dev,
"unsupported hub number %d\n", upphub);
255 dev_err(dev,
"unsupported speed %d\n", speed);
281 static u32 usbhsc_default_pipe_type[] = {
304 pm_runtime_get_sync(dev);
310 usbhs_sys_clock_ctrl(priv, enable);
313 usbhs_sys_clock_ctrl(priv, enable);
319 pm_runtime_put_sync(dev);
326 static void usbhsc_hotplug(
struct usbhs_priv *priv)
344 if (enable && !mod) {
353 usbhsc_power_ctrl(priv, enable);
356 usbhsc_set_buswait(priv);
357 usbhsc_bus_init(priv);
362 }
else if (!enable && mod) {
363 dev_dbg(&pdev->
dev,
"%s disable\n", __func__);
369 usbhsc_bus_init(priv);
373 usbhsc_power_ctrl(priv, enable);
390 usbhsc_hotplug(priv);
393 static int usbhsc_drvcllbck_notify_hotplug(
struct platform_device *pdev)
422 dev_err(&pdev->
dev,
"no platform information\n");
429 if (!res || !irq_res) {
430 dev_err(&pdev->
dev,
"Not enough Renesas USB platform resources.\n");
437 dev_err(&pdev->
dev,
"Could not allocate priv\n");
462 if (!priv->
dparam.pipe_type) {
463 priv->
dparam.pipe_type = usbhsc_default_pipe_type;
466 if (!priv->
dparam.pio_dma_border)
467 priv->
dparam.pio_dma_border = 64;
471 if (priv->
pfunc.get_vbus)
491 goto probe_end_pipe_exit;
495 goto probe_end_fifo_exit;
504 usbhs_sys_clock_ctrl(priv, 0);
515 dev_err(&pdev->
dev,
"platform prove failed.\n");
516 goto probe_end_mod_exit;
525 usbhsc_power_ctrl(priv, 1);
532 ret = usbhsc_drvcllbck_notify_hotplug(pdev);
534 goto probe_end_call_remove;
540 probe_end_call_remove:
566 usbhsc_power_ctrl(priv, 0);
568 pm_runtime_disable(&pdev->
dev);
578 static int usbhsc_suspend(
struct device *dev)
589 usbhsc_power_ctrl(priv, 0);
594 static int usbhsc_resume(
struct device *dev)
600 usbhsc_power_ctrl(priv, 1);
604 usbhsc_drvcllbck_notify_hotplug(pdev);
609 static int usbhsc_runtime_nop(
struct device *dev)
621 static const struct dev_pm_ops usbhsc_pm_ops = {
622 .suspend = usbhsc_suspend,
623 .resume = usbhsc_resume,
624 .runtime_suspend = usbhsc_runtime_nop,
625 .runtime_resume = usbhsc_runtime_nop,
630 .name =
"renesas_usbhs",
631 .pm = &usbhsc_pm_ops,
633 .probe = usbhs_probe,