Loading Documentation/devicetree/bindings/usb/qcom,usb-emu-phy.txt 0 → 100644 +30 −0 Original line number Diff line number Diff line Qualcomm Technologies, Inc. emulation USB PHY Required properties: - compatible: should contain "qcom,usb-emu-phy" - reg: offset and length of the register set in the memory map - qcom,emu-init-seq: emulation initialization sequence of value,reg pairs Optional properties: - reg: Additional register names supported are "qcratch_base" Example PHY device node: usb_emu_phy@a720000 { compatible = "qcom,usb-emu-phy"; reg = <0x0a720000 0x9500>, <0x0a6f8800 0x100>; reg-names = "base", "qcratch_base"; qcom,emu-init-seq = <0xfff0 0x4 0xfff3 0x4 0xfff0 0x4 0x100000 0x20 0x0 0x20 0x1a0 0x20 0x100000 0x3c 0x0 0x3c 0x10060 0x3c 0x0 0x4>; }; drivers/usb/phy/Kconfig +12 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,18 @@ config MSM_QUSB_PHY Synopsys DWC3 USB IPs on MSM SOCs. This driver expects to configure the PHY with a dedicated register I/O memory region. config USB_QCOM_EMU_PHY tristate "Qualcomm Technologies, Inc. emulation USB PHY driver" depends on ARCH_QCOM || COMPILE_TEST select USB_PHY help Enable this to support the USB transceiver used on Qualcomm Technologies, Inc. emulation platforms. It simply performs PHY initialization given a basic register write sequence. To compile this driver as a module, choose M here: the module will be called phy-qcom-emu. config USB_MV_OTG tristate "Marvell USB OTG support" depends on USB_EHCI_MV && USB_MV_UDC && PM && USB_OTG Loading drivers/usb/phy/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o obj-$(CONFIG_USB_TEGRA_PHY) += phy-tegra-usb.o obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o obj-$(CONFIG_USB_QCOM_EMU_PHY) += phy-qcom-emu.o obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o obj-$(CONFIG_USB_ULPI) += phy-ulpi.o Loading drivers/usb/phy/phy-qcom-emu.c 0 → 100644 +146 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. */ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/io.h> #include <linux/of.h> #include <linux/delay.h> #include <linux/usb/phy.h> /* QSCRATCH registers */ #define HS_PHY_CTRL_REG 0x10 #define SW_SESSVLD_SEL BIT(28) struct qcusb_emu_phy { struct usb_phy phy; struct device *dev; void __iomem *base; void __iomem *qscratch_base; int *emu_init_seq; int emu_init_seq_len; }; static int qcusb_emu_phy_init(struct usb_phy *phy) { struct qcusb_emu_phy *qphy = container_of(phy, struct qcusb_emu_phy, phy); u32 tmp; int i; for (i = 0; i < qphy->emu_init_seq_len; i = i+2) { dev_dbg(phy->dev, "write 0x%02x to 0x%02x\n", qphy->emu_init_seq[i], qphy->emu_init_seq[i+1]); writel_relaxed(qphy->emu_init_seq[i], qphy->base + qphy->emu_init_seq[i+1]); /* 10ms to ensure write propagates across bus */ usleep_range(10000, 12000); } if (qphy->qscratch_base) { /* Use UTMI VBUS signal from HW */ tmp = readl_relaxed(qphy->qscratch_base + HS_PHY_CTRL_REG); tmp &= ~SW_SESSVLD_SEL; writel_relaxed(tmp, qphy->qscratch_base + HS_PHY_CTRL_REG); } return 0; } static int qcusb_emu_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct qcusb_emu_phy *qphy; struct resource *res; int ret, size; qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); if (!qphy) return -ENOMEM; qphy->phy.dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); qphy->base = devm_ioremap_resource(dev, res); if (IS_ERR(qphy->base)) return PTR_ERR(qphy->base); of_get_property(dev->of_node, "qcom,emu-init-seq", &size); if (!size) { dev_err(dev, "emu-init-seq not specified\n"); return -EINVAL; } qphy->emu_init_seq = devm_kzalloc(dev, size, GFP_KERNEL); if (!qphy->emu_init_seq) return -ENOMEM; qphy->emu_init_seq_len = (size / sizeof(*qphy->emu_init_seq)); if (qphy->emu_init_seq_len % 2) { dev_err(dev, "invalid emu_init_seq_len, must be in <data,addr> pairs\n"); return -EINVAL; } ret = of_property_read_u32_array(dev->of_node, "qcom,emu-init-seq", qphy->emu_init_seq, qphy->emu_init_seq_len); if (ret) { dev_err(dev, "could not read emu-init-seq, returned %d\n", ret); return ret; } platform_set_drvdata(pdev, qphy); qphy->phy.label = "qcom-usb-emu-phy"; qphy->phy.init = qcusb_emu_phy_init; qphy->phy.type = USB_PHY_TYPE_USB2; ret = usb_add_phy_dev(&qphy->phy); if (ret) return ret; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qcratch_base"); if (res) { qphy->qscratch_base = devm_ioremap_nocache(dev, res->start, resource_size(res)); if (IS_ERR(qphy->qscratch_base)) { dev_dbg(dev, "error mapping qscratch\n"); qphy->qscratch_base = NULL; } } return 0; } static int qcusb_emu_phy_remove(struct platform_device *pdev) { struct qcusb_emu_phy *qcphy = platform_get_drvdata(pdev); usb_remove_phy(&qcphy->phy); return 0; } static const struct of_device_id emu_phy_dt_ids[] = { { .compatible = "qcom,usb-emu-phy" }, { } }; MODULE_DEVICE_TABLE(of, emu_phy_dt_ids); static struct platform_driver qcusb_emu_phy_driver = { .probe = qcusb_emu_phy_probe, .remove = qcusb_emu_phy_remove, .driver = { .name = "usb_emu_phy", .of_match_table = emu_phy_dt_ids, }, }; module_platform_driver(qcusb_emu_phy_driver); MODULE_DESCRIPTION("Qualcomm Technologies, Inc. USB Emulation PHY driver"); MODULE_LICENSE("GPL v2"); Loading
Documentation/devicetree/bindings/usb/qcom,usb-emu-phy.txt 0 → 100644 +30 −0 Original line number Diff line number Diff line Qualcomm Technologies, Inc. emulation USB PHY Required properties: - compatible: should contain "qcom,usb-emu-phy" - reg: offset and length of the register set in the memory map - qcom,emu-init-seq: emulation initialization sequence of value,reg pairs Optional properties: - reg: Additional register names supported are "qcratch_base" Example PHY device node: usb_emu_phy@a720000 { compatible = "qcom,usb-emu-phy"; reg = <0x0a720000 0x9500>, <0x0a6f8800 0x100>; reg-names = "base", "qcratch_base"; qcom,emu-init-seq = <0xfff0 0x4 0xfff3 0x4 0xfff0 0x4 0x100000 0x20 0x0 0x20 0x1a0 0x20 0x100000 0x3c 0x0 0x3c 0x10060 0x3c 0x0 0x4>; };
drivers/usb/phy/Kconfig +12 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,18 @@ config MSM_QUSB_PHY Synopsys DWC3 USB IPs on MSM SOCs. This driver expects to configure the PHY with a dedicated register I/O memory region. config USB_QCOM_EMU_PHY tristate "Qualcomm Technologies, Inc. emulation USB PHY driver" depends on ARCH_QCOM || COMPILE_TEST select USB_PHY help Enable this to support the USB transceiver used on Qualcomm Technologies, Inc. emulation platforms. It simply performs PHY initialization given a basic register write sequence. To compile this driver as a module, choose M here: the module will be called phy-qcom-emu. config USB_MV_OTG tristate "Marvell USB OTG support" depends on USB_EHCI_MV && USB_MV_UDC && PM && USB_OTG Loading
drivers/usb/phy/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o obj-$(CONFIG_USB_TEGRA_PHY) += phy-tegra-usb.o obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o obj-$(CONFIG_USB_QCOM_EMU_PHY) += phy-qcom-emu.o obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o obj-$(CONFIG_USB_ULPI) += phy-ulpi.o Loading
drivers/usb/phy/phy-qcom-emu.c 0 → 100644 +146 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. */ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/io.h> #include <linux/of.h> #include <linux/delay.h> #include <linux/usb/phy.h> /* QSCRATCH registers */ #define HS_PHY_CTRL_REG 0x10 #define SW_SESSVLD_SEL BIT(28) struct qcusb_emu_phy { struct usb_phy phy; struct device *dev; void __iomem *base; void __iomem *qscratch_base; int *emu_init_seq; int emu_init_seq_len; }; static int qcusb_emu_phy_init(struct usb_phy *phy) { struct qcusb_emu_phy *qphy = container_of(phy, struct qcusb_emu_phy, phy); u32 tmp; int i; for (i = 0; i < qphy->emu_init_seq_len; i = i+2) { dev_dbg(phy->dev, "write 0x%02x to 0x%02x\n", qphy->emu_init_seq[i], qphy->emu_init_seq[i+1]); writel_relaxed(qphy->emu_init_seq[i], qphy->base + qphy->emu_init_seq[i+1]); /* 10ms to ensure write propagates across bus */ usleep_range(10000, 12000); } if (qphy->qscratch_base) { /* Use UTMI VBUS signal from HW */ tmp = readl_relaxed(qphy->qscratch_base + HS_PHY_CTRL_REG); tmp &= ~SW_SESSVLD_SEL; writel_relaxed(tmp, qphy->qscratch_base + HS_PHY_CTRL_REG); } return 0; } static int qcusb_emu_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct qcusb_emu_phy *qphy; struct resource *res; int ret, size; qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); if (!qphy) return -ENOMEM; qphy->phy.dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); qphy->base = devm_ioremap_resource(dev, res); if (IS_ERR(qphy->base)) return PTR_ERR(qphy->base); of_get_property(dev->of_node, "qcom,emu-init-seq", &size); if (!size) { dev_err(dev, "emu-init-seq not specified\n"); return -EINVAL; } qphy->emu_init_seq = devm_kzalloc(dev, size, GFP_KERNEL); if (!qphy->emu_init_seq) return -ENOMEM; qphy->emu_init_seq_len = (size / sizeof(*qphy->emu_init_seq)); if (qphy->emu_init_seq_len % 2) { dev_err(dev, "invalid emu_init_seq_len, must be in <data,addr> pairs\n"); return -EINVAL; } ret = of_property_read_u32_array(dev->of_node, "qcom,emu-init-seq", qphy->emu_init_seq, qphy->emu_init_seq_len); if (ret) { dev_err(dev, "could not read emu-init-seq, returned %d\n", ret); return ret; } platform_set_drvdata(pdev, qphy); qphy->phy.label = "qcom-usb-emu-phy"; qphy->phy.init = qcusb_emu_phy_init; qphy->phy.type = USB_PHY_TYPE_USB2; ret = usb_add_phy_dev(&qphy->phy); if (ret) return ret; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qcratch_base"); if (res) { qphy->qscratch_base = devm_ioremap_nocache(dev, res->start, resource_size(res)); if (IS_ERR(qphy->qscratch_base)) { dev_dbg(dev, "error mapping qscratch\n"); qphy->qscratch_base = NULL; } } return 0; } static int qcusb_emu_phy_remove(struct platform_device *pdev) { struct qcusb_emu_phy *qcphy = platform_get_drvdata(pdev); usb_remove_phy(&qcphy->phy); return 0; } static const struct of_device_id emu_phy_dt_ids[] = { { .compatible = "qcom,usb-emu-phy" }, { } }; MODULE_DEVICE_TABLE(of, emu_phy_dt_ids); static struct platform_driver qcusb_emu_phy_driver = { .probe = qcusb_emu_phy_probe, .remove = qcusb_emu_phy_remove, .driver = { .name = "usb_emu_phy", .of_match_table = emu_phy_dt_ids, }, }; module_platform_driver(qcusb_emu_phy_driver); MODULE_DESCRIPTION("Qualcomm Technologies, Inc. USB Emulation PHY driver"); MODULE_LICENSE("GPL v2");