Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-1.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Renesas USB driver R-Car Gen. 2 initialization and power control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2014 Ulrich Hecht
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2019 Renesas Electronics Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/phy/phy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "rcar2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static int usbhs_rcar2_hardware_init(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		struct phy *phy = phy_get(&pdev->dev, "usb");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		if (IS_ERR(phy))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 			return PTR_ERR(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		priv->phy = phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	if (priv->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		phy_put(&pdev->dev, priv->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		priv->phy = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 				void __iomem *base, int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	int retval = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	if (priv->phy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		if (enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 			retval = phy_init(priv->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 			if (!retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 				retval = phy_power_on(priv->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 			phy_power_off(priv->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 			phy_exit(priv->phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 			retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) const struct renesas_usbhs_platform_info usbhs_rcar_gen2_plat_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	.platform_callback = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		.hardware_init = usbhs_rcar2_hardware_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		.hardware_exit = usbhs_rcar2_hardware_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		.power_ctrl = usbhs_rcar2_power_ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		.get_id = usbhs_get_id_as_gadget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	.driver_param = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 		.has_usb_dmac = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 		.has_new_pipe_configs = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) };