net: DCB: Validate DCB_ATTR_DCB_BUFFER argument
[linux/fpc-iii.git] / drivers / usb / renesas_usbhs / rcar2.c
blob440d213e1749d5eaf81adcd2840c18d0ac1cc3da
1 // SPDX-License-Identifier: GPL-1.0+
2 /*
3 * Renesas USB driver R-Car Gen. 2 initialization and power control
5 * Copyright (C) 2014 Ulrich Hecht
6 * Copyright (C) 2019 Renesas Electronics Corporation
7 */
9 #include <linux/gpio.h>
10 #include <linux/of_gpio.h>
11 #include <linux/phy/phy.h>
12 #include "common.h"
13 #include "rcar2.h"
15 static int usbhs_rcar2_hardware_init(struct platform_device *pdev)
17 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
19 if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
20 struct phy *phy = phy_get(&pdev->dev, "usb");
22 if (IS_ERR(phy))
23 return PTR_ERR(phy);
25 priv->phy = phy;
26 return 0;
29 return -ENXIO;
32 static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
34 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
36 if (priv->phy) {
37 phy_put(priv->phy);
38 priv->phy = NULL;
41 return 0;
44 static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
45 void __iomem *base, int enable)
47 struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
48 int retval = -ENODEV;
50 if (priv->phy) {
51 if (enable) {
52 retval = phy_init(priv->phy);
54 if (!retval)
55 retval = phy_power_on(priv->phy);
56 } else {
57 phy_power_off(priv->phy);
58 phy_exit(priv->phy);
59 retval = 0;
63 return retval;
66 const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info = {
67 .platform_callback = {
68 .hardware_init = usbhs_rcar2_hardware_init,
69 .hardware_exit = usbhs_rcar2_hardware_exit,
70 .power_ctrl = usbhs_rcar2_power_ctrl,
71 .get_id = usbhs_get_id_as_gadget,
73 .driver_param = {
74 .has_usb_dmac = 1,
75 .has_new_pipe_configs = 1,