- if (hccr == (void *)SUNXI_USB1_BASE) {
- priv->ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0;
- priv->phy_index = 1;
- } else {
- priv->ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI1;
- priv->phy_index = 2;
- }
-
- setbits_le32(&ccm->ahb_gate0, priv->ahb_gate_mask);
+ priv->ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0;
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+ extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_OHCI0;
+#endif
+ priv->phy_index = ((uintptr_t)hccr - SUNXI_USB1_BASE) / BASE_DIST;
+ priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
+ extra_ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
+ priv->phy_index++; /* Non otg phys start at 1 */
+
+ setbits_le32(&ccm->ahb_gate0,
+ priv->ahb_gate_mask | extra_ahb_gate_mask);