Merge branch 'master' of git://git.denx.de/u-boot
[platform/kernel/u-boot.git] / arch / arm / cpu / armv7 / exynos / power.c
index 517e804..1b12051 100644 (file)
@@ -53,10 +53,83 @@ void exynos5_set_usbhost_phy_ctrl(unsigned int enable)
        }
 }
 
+void exynos4412_set_usbhost_phy_ctrl(unsigned int enable)
+{
+       struct exynos4412_power *power =
+               (struct exynos4412_power *)samsung_get_base_power();
+
+       if (enable) {
+               /* Enabling USBHOST_PHY */
+               setbits_le32(&power->usbhost_phy_control,
+                            POWER_USB_HOST_PHY_CTRL_EN);
+               setbits_le32(&power->hsic1_phy_control,
+                            POWER_USB_HOST_PHY_CTRL_EN);
+               setbits_le32(&power->hsic2_phy_control,
+                            POWER_USB_HOST_PHY_CTRL_EN);
+       } else {
+               /* Disabling USBHOST_PHY */
+               clrbits_le32(&power->usbhost_phy_control,
+                            POWER_USB_HOST_PHY_CTRL_EN);
+               clrbits_le32(&power->hsic1_phy_control,
+                            POWER_USB_HOST_PHY_CTRL_EN);
+               clrbits_le32(&power->hsic2_phy_control,
+                            POWER_USB_HOST_PHY_CTRL_EN);
+       }
+}
+
 void set_usbhost_phy_ctrl(unsigned int enable)
 {
        if (cpu_is_exynos5())
                exynos5_set_usbhost_phy_ctrl(enable);
+       else if (cpu_is_exynos4())
+               if (proid_is_exynos4412())
+                       exynos4412_set_usbhost_phy_ctrl(enable);
+}
+
+static void exynos5_set_usbdrd_phy_ctrl(unsigned int enable)
+{
+       struct exynos5_power *power =
+               (struct exynos5_power *)samsung_get_base_power();
+
+       if (enable) {
+               /* Enabling USBDRD_PHY */
+               setbits_le32(&power->usbdrd_phy_control,
+                               POWER_USB_DRD_PHY_CTRL_EN);
+       } else {
+               /* Disabling USBDRD_PHY */
+               clrbits_le32(&power->usbdrd_phy_control,
+                               POWER_USB_DRD_PHY_CTRL_EN);
+       }
+}
+
+static void exynos5420_set_usbdev_phy_ctrl(unsigned int enable)
+{
+       struct exynos5420_power *power =
+               (struct exynos5420_power *)samsung_get_base_power();
+
+       if (enable) {
+               /* Enabling USBDEV_PHY */
+               setbits_le32(&power->usbdev_phy_control,
+                               POWER_USB_DRD_PHY_CTRL_EN);
+               setbits_le32(&power->usbdev1_phy_control,
+                               POWER_USB_DRD_PHY_CTRL_EN);
+       } else {
+               /* Disabling USBDEV_PHY */
+               clrbits_le32(&power->usbdev_phy_control,
+                               POWER_USB_DRD_PHY_CTRL_EN);
+               clrbits_le32(&power->usbdev1_phy_control,
+                               POWER_USB_DRD_PHY_CTRL_EN);
+       }
+}
+
+void set_usbdrd_phy_ctrl(unsigned int enable)
+{
+       if (cpu_is_exynos5()) {
+               if (proid_is_exynos5420() || proid_is_exynos5800())
+                       exynos5420_set_usbdev_phy_ctrl(enable);
+               else
+                       exynos5_set_usbdrd_phy_ctrl(enable);
+       }
 }
 
 static void exynos5_dp_phy_control(unsigned int enable)
@@ -90,6 +163,12 @@ static void exynos5_set_ps_hold_ctrl(void)
                        EXYNOS_PS_HOLD_CONTROL_DATA_HIGH);
 }
 
+/*
+ * Set ps_hold data driving value high
+ * This enables the machine to stay powered on
+ * after the initial power-on condition goes away
+ * (e.g. power button).
+ */
 void set_ps_hold_ctrl(void)
 {
        if (cpu_is_exynos5())
@@ -174,3 +253,10 @@ void power_exit_wakeup(void)
        else
                exynos4_power_exit_wakeup();
 }
+
+unsigned int get_boot_mode(void)
+{
+       unsigned int om_pin = samsung_get_base_power();
+
+       return readl(om_pin) & OM_PIN_MASK;
+}