+/*
+ * Due to a HW bug 1320346 in t12x/t13x, PCIE needs to be unpowergated when
+ * XUSB is to be accessed. Since PCIE uses reference counter, we can attempt
+ * to powergated/unpowergate PCIE when XUSB is powergated/unpowergated. This
+ * will ensure that PCIE is unpowergated when (either XUSB or PCIE) needs it
+ * and will be powergated when (neither XUSB nor PCIE) needs it.
+ */
+static int tegra12x_xusbc_powergate(int id)
+{
+ int ret = 0;
+
+ if (!TEGRA_IS_XUSBC_POWERGATE_ID(id))
+ return -EINVAL;
+
+ CHECK_RET(tegra12x_powergate(id));
+ CHECK_RET(tegra12x_pcie_powergate(TEGRA_POWERGATE_PCIE));
+
+ return ret;
+}
+
+static int tegra12x_xusbc_unpowergate(int id)
+{
+ int ret = 0;
+
+ if (!TEGRA_IS_XUSBC_POWERGATE_ID(id))
+ return -EINVAL;
+
+ CHECK_RET(tegra12x_unpowergate(id));
+ CHECK_RET(tegra12x_pcie_unpowergate(TEGRA_POWERGATE_PCIE));
+
+ return ret;
+}
+