#include <linux/amlogic/aml_gpio_consumer.h>
#include <linux/workqueue.h>
#include <linux/notifier.h>
+#include <linux/amlogic/usbtype.h>
#include "phy-aml-new-usb-v2.h"
#define HOST_MODE 0
return 0;
}
- /* set the phy from pcie to usb3 */
- if (phy->portnum > 0)
- writel((readl(phy->phy3_cfg) | (3<<5)), phy->phy3_cfg);
-
for (i = 0; i < 6; i++) {
usb_new_aml_regs_v2.usb_r_v2[i] = (void __iomem *)
((unsigned long)phy->regs + 4*i);
}
r1.d32 = readl(usb_new_aml_regs_v2.usb_r_v2[1]);
- r1.b.u3h_fladj_30mhz_reg = 0x20;
+ r1.b.u3h_fladj_30mhz_reg = 0x26;
writel(r1.d32, usb_new_aml_regs_v2.usb_r_v2[1]);
r5.d32 = readl(usb_new_aml_regs_v2.usb_r_v2[5]);
udelay(2);
r1.d32 = readl(usb_new_aml_regs_v2.usb_r_v2[1]);
r1.b.u3h_host_port_power_control_present = 1;
- r1.b.u3h_fladj_30mhz_reg = 32;
+ r1.b.u3h_fladj_30mhz_reg = 0x26;
writel(r1.d32, usb_new_aml_regs_v2.usb_r_v2[1]);
udelay(2);
}
return IRQ_HANDLED;
}
+static bool device_is_available(const struct device_node *device)
+{
+ const char *status;
+ int statlen;
+
+ if (!device)
+ return false;
+
+ status = of_get_property(device, "status", &statlen);
+ if (status == NULL)
+ return true;
+
+ if (statlen > 0) {
+ if (!strcmp(status, "okay") || !strcmp(status, "ok"))
+ return true;
+ }
+
+ return false;
+}
+
static int amlogic_new_usb3_v2_probe(struct platform_device *pdev)
{
struct amlogic_usb_v2 *phy;
int retval;
int gpio_vbus_power_pin = -1;
int otg = 0;
+ int ret;
+ struct device_node *tsi_pci;
gpio_name = of_get_property(dev->of_node, "gpio-vbus-power", NULL);
if (gpio_name) {
if (!portnum)
dev_err(&pdev->dev, "This phy has no usb port\n");
+ tsi_pci = of_find_node_by_type(NULL, "pci");
+ if (tsi_pci) {
+ if (device_is_available(tsi_pci)) {
+ dev_info(&pdev->dev,
+ "pci-e driver probe, disable USB 3.0 function!!!\n");
+ portnum = 0;
+ }
+ }
+
prop = of_get_property(dev->of_node, "otg", NULL);
if (prop)
otg = of_read_ulong(prop, 1);
phy->phy.set_suspend = amlogic_new_usb3_suspend;
phy->phy.shutdown = amlogic_new_usb3phy_shutdown;
phy->phy.type = USB_PHY_TYPE_USB3;
+ phy->phy.flags = AML_USB3_PHY_DISABLE;
phy->vbus_power_pin = gpio_vbus_power_pin;
phy->usb_gpio_desc = usb_gd;
+ /* set the phy from pcie to usb3 */
+ if (phy->portnum > 0) {
+ writel((readl(phy->phy3_cfg) | (3<<5)), phy->phy3_cfg);
+ udelay(100);
+
+ phy->clk = devm_clk_get(dev, "pcie_refpll");
+ if (IS_ERR(phy->clk)) {
+ dev_err(dev, "Failed to get usb3 bus clock\n");
+ ret = PTR_ERR(phy->clk);
+ return ret;
+ }
+
+ ret = clk_prepare_enable(phy->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable usb3 bus clock\n");
+ ret = PTR_ERR(phy->clk);
+ return ret;
+ }
+ phy->phy.flags = AML_USB3_PHY_ENABLE;
+ }
+
INIT_DELAYED_WORK(&phy->work, amlogic_gxl_work);
usb_add_phy_dev(&phy->phy);
usb_phy_init(dwc->usb2_phy);
usb_phy_init(dwc->usb3_phy);
+
ret = phy_init(dwc->usb2_generic_phy);
if (ret < 0)
return ret;
phy_exit(dwc->usb2_generic_phy);
return ret;
}
- mdelay(100);
+
+ udelay(1000);
/* Clear USB3 PHY reset */
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST;
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(3), reg);
- mdelay(100);
+ udelay(1000);
/* After PHYs are stable we can take Core out of reset state */
reg = dwc3_readl(dwc->regs, DWC3_GCTL);
}
}
+#ifdef CONFIG_AMLOGIC_USB
+ if (dwc->usb3_phy->flags == AML_USB3_PHY_ENABLE)
+ dwc->super_speed_support = 1;
+ else
+ dwc->super_speed_support = 0;
+#endif
+
dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy");
if (IS_ERR(dwc->usb2_generic_phy)) {
ret = PTR_ERR(dwc->usb2_generic_phy);
&dwc->hsphy_interface);
device_property_read_u32(dev, "snps,quirk-frame-length-adjustment",
&dwc->fladj);
-#ifdef CONFIG_AMLOGIC_USB
- dwc->super_speed_support = device_property_read_bool(dev,
- "snps,super_speed_support");
-#endif
+
dwc->lpm_nyet_threshold = lpm_nyet_threshold;
dwc->tx_de_emphasis = tx_de_emphasis;
if (dwc->revision <= DWC3_REVISION_300A)
props[prop_idx++].name = "quirk-broken-port-ped";
+#ifdef CONFIG_AMLOGIC_USB
+ if (dwc->super_speed_support)
+ props[prop_idx++].name = "super_speed_support";
+#endif
+
if (prop_idx) {
ret = platform_device_add_properties(xhci, props);
if (ret) {
}
}
-#ifdef CONFIG_AMLOGIC_USB
- if (dwc->super_speed_support)
- props[prop_idx++].name = "usb3-support";
-#endif
-
phy_create_lookup(dwc->usb2_generic_phy, "usb2-phy",
dev_name(&xhci->dev));
phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy",