Lines Matching +full:rcar +full:- +full:gen2 +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-1.0+
11 #include <linux/gpio/consumer.h>
33 * +-------+ +-----------+
34 * | pipe0 |------>| fifo pio |
35 * +------------+ +-------+ +-----------+
36 * | mod_gadget |=====> | pipe1 |--+
37 * +------------+ +-------+ | +-----------+
38 * | pipe2 | | +-| fifo dma0 |
39 * +------------+ +-------+ | | +-----------+
40 * | mod_host | | pipe3 |<-|--+
41 * +------------+ +-------+ | +-----------+
42 * | .... | +--->| fifo dma1 |
43 * | .... | +-----------+
54 (!(priv) ? -ENODEV : \
55 !((priv)->pfunc->func) ? 0 : \
56 (priv)->pfunc->func(args))
63 return ioread16(priv->base + reg); in usbhs_read()
68 iowrite16(data, priv->base + reg); in usbhs_write()
83 return dev_get_drvdata(&pdev->dev); in usbhs_pdev_to_priv()
107 * - select Host mode in usbhs_sys_host_ctrl()
108 * - D+ Line/D- Line Pull-down in usbhs_sys_host_ctrl()
127 * - select Function mode in usbhs_sys_function_ctrl()
128 * - D+ Line Pull-up is disabled in usbhs_sys_function_ctrl()
129 * When D+ Line Pull-up is enabled, in usbhs_sys_function_ctrl()
161 req->bRequest = (val >> 8) & 0xFF; in usbhs_usbreq_get_val()
162 req->bRequestType = (val >> 0) & 0xFF; in usbhs_usbreq_get_val()
164 req->wValue = cpu_to_le16(usbhs_read(priv, USBVAL)); in usbhs_usbreq_get_val()
165 req->wIndex = cpu_to_le16(usbhs_read(priv, USBINDX)); in usbhs_usbreq_get_val()
166 req->wLength = cpu_to_le16(usbhs_read(priv, USBLENG)); in usbhs_usbreq_get_val()
171 usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType); in usbhs_usbreq_set_val()
172 usbhs_write(priv, USBVAL, le16_to_cpu(req->wValue)); in usbhs_usbreq_set_val()
173 usbhs_write(priv, USBINDX, le16_to_cpu(req->wIndex)); in usbhs_usbreq_set_val()
174 usbhs_write(priv, USBLENG, le16_to_cpu(req->wLength)); in usbhs_usbreq_set_val()
241 return -EIO; in usbhs_set_device_config()
246 return -EIO; in usbhs_set_device_config()
261 return -EIO; in usbhs_set_device_config()
295 return priv->dparam.multi_clks; in usbhsc_is_multi_clks()
304 priv->clks[0] = of_clk_get(dev_of_node(dev), 0); in usbhsc_clk_get()
305 if (IS_ERR(priv->clks[0])) in usbhsc_clk_get()
306 return PTR_ERR(priv->clks[0]); in usbhsc_clk_get()
310 * value if it's -ENOENT or not. in usbhsc_clk_get()
312 priv->clks[1] = of_clk_get(dev_of_node(dev), 1); in usbhsc_clk_get()
313 if (PTR_ERR(priv->clks[1]) == -ENOENT) in usbhsc_clk_get()
314 priv->clks[1] = NULL; in usbhsc_clk_get()
315 else if (IS_ERR(priv->clks[1])) { in usbhsc_clk_get()
316 clk_put(priv->clks[0]); in usbhsc_clk_get()
317 return PTR_ERR(priv->clks[1]); in usbhsc_clk_get()
330 for (i = 0; i < ARRAY_SIZE(priv->clks); i++) in usbhsc_clk_put()
331 clk_put(priv->clks[i]); in usbhsc_clk_put()
341 for (i = 0; i < ARRAY_SIZE(priv->clks); i++) { in usbhsc_clk_prepare_enable()
342 ret = clk_prepare_enable(priv->clks[i]); in usbhsc_clk_prepare_enable()
344 while (--i >= 0) in usbhsc_clk_prepare_enable()
345 clk_disable_unprepare(priv->clks[i]); in usbhsc_clk_prepare_enable()
360 for (i = 0; i < ARRAY_SIZE(priv->clks); i++) in usbhsc_clk_disable_unprepare()
361 clk_disable_unprepare(priv->clks[i]); in usbhsc_clk_disable_unprepare()
368 /* commonly used on old SH-Mobile and RZ/G2L family SoCs */
382 /* commonly used on newer SH-Mobile and R-Car SoCs */
419 usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); in usbhsc_power_ctrl()
428 usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); in usbhsc_power_ctrl()
461 if (priv->edev) { in usbhsc_hotplug()
462 cable = extcon_get_state(priv->edev, EXTCON_USB_HOST); in usbhsc_hotplug()
465 dev_info(&pdev->dev, in usbhsc_hotplug()
475 dev_dbg(&pdev->dev, "%s enable\n", __func__); in usbhsc_hotplug()
489 dev_dbg(&pdev->dev, "%s disable\n", __func__); in usbhsc_hotplug()
501 usbhs_mod_change(priv, -1); in usbhsc_hotplug()
529 schedule_delayed_work(&priv->notify_hotplug_work, in usbhsc_schedule_notify_hotplug()
539 .compatible = "renesas,usbhs-r8a774c0",
543 .compatible = "renesas,usbhs-r8a7790",
547 .compatible = "renesas,usbhs-r8a7791",
551 .compatible = "renesas,usbhs-r8a7794",
555 .compatible = "renesas,usbhs-r8a7795",
559 .compatible = "renesas,usbhs-r8a7796",
563 .compatible = "renesas,usbhs-r8a77990",
567 .compatible = "renesas,usbhs-r8a77995",
571 .compatible = "renesas,usbhs-r9a07g043",
575 .compatible = "renesas,usbhs-r9a07g044",
579 .compatible = "renesas,usbhs-r9a07g054",
583 .compatible = "renesas,rcar-gen2-usbhs",
587 .compatible = "renesas,rcar-gen3-usbhs",
591 .compatible = "renesas,rza1-usbhs",
595 .compatible = "renesas,rza2-usbhs",
599 .compatible = "renesas,rzg2l-usbhs",
610 struct device *dev = &pdev->dev; in usbhs_probe()
620 return dev_err_probe(dev, -EINVAL, "no platform info\n"); in usbhs_probe()
631 return -ENOMEM; in usbhs_probe()
633 priv->base = devm_platform_ioremap_resource(pdev, 0); in usbhs_probe()
634 if (IS_ERR(priv->base)) in usbhs_probe()
635 return PTR_ERR(priv->base); in usbhs_probe()
638 priv->edev = extcon_get_edev_by_phandle(dev, 0); in usbhs_probe()
639 if (IS_ERR(priv->edev)) in usbhs_probe()
640 return PTR_ERR(priv->edev); in usbhs_probe()
643 priv->rsts = devm_reset_control_array_get_optional_shared(dev); in usbhs_probe()
644 if (IS_ERR(priv->rsts)) in usbhs_probe()
645 return PTR_ERR(priv->rsts); in usbhs_probe()
651 priv->dparam = info->driver_param; in usbhs_probe()
653 if (!info->platform_callback.get_id) { in usbhs_probe()
655 return -EINVAL; in usbhs_probe()
657 priv->pfunc = &info->platform_callback; in usbhs_probe()
661 priv->dparam.pipe_configs = usbhsc_new_pipe; in usbhs_probe()
662 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); in usbhs_probe()
663 } else if (!priv->dparam.pipe_configs) { in usbhs_probe()
664 priv->dparam.pipe_configs = usbhsc_default_pipe; in usbhs_probe()
665 priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_default_pipe); in usbhs_probe()
667 if (!priv->dparam.pio_dma_border) in usbhs_probe()
668 priv->dparam.pio_dma_border = 64; /* 64byte */ in usbhs_probe()
670 priv->dparam.buswait_bwait = tmp; in usbhs_probe()
677 if (priv->pfunc->get_vbus) in usbhs_probe()
683 priv->irq = irq; in usbhs_probe()
684 priv->pdev = pdev; in usbhs_probe()
685 INIT_DELAYED_WORK(&priv->notify_hotplug_work, usbhsc_notify_hotplug); in usbhs_probe()
704 ret = reset_control_deassert(priv->rsts); in usbhs_probe()
718 /* check GPIO determining if USB function should be enabled */ in usbhs_probe()
722 dev_warn(dev, "USB function not selected (GPIO)\n"); in usbhs_probe()
723 ret = -ENOTSUPP; in usbhs_probe()
765 reset_control_assert(priv->rsts); in usbhs_probe()
782 dev_dbg(&pdev->dev, "usb remove\n"); in usbhs_remove()
784 flush_delayed_work(&priv->notify_hotplug_work); in usbhs_remove()
790 pm_runtime_disable(&pdev->dev); in usbhs_remove()
794 reset_control_assert(priv->rsts); in usbhs_remove()
807 usbhs_mod_change(priv, -1); in usbhsc_suspend()