]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
split IVM power hooks from cmd_ide.c
authorPavel Herrmann <morpheus.ibis@gmail.com>
Sun, 7 Oct 2012 05:56:07 +0000 (05:56 +0000)
committerTom Rini <trini@ti.com>
Wed, 17 Oct 2012 14:59:08 +0000 (07:59 -0700)
Move power control code from ide_reset() into IVM-specific IDE reset code.

Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com>
board/ivm/ivm.c
common/cmd_ide.c

index 71d64d434f317cca29519d110035c6a6bd265530..ab294794bd3a7fdffa600e52f1549958a4477743 100644 (file)
@@ -333,13 +333,59 @@ void show_boot_progress (int status)
 void ide_set_reset (int on)
 {
        volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
+       int i;
 
        /*
         * Configure PC for IDE Reset Pin
         */
        if (on) {               /* assert RESET */
                immr->im_ioport.iop_pcdat &= ~(CONFIG_SYS_PC_IDE_RESET);
+
+#ifdef CONFIG_SYS_PB_12V_ENABLE
+               /* 12V Enable output OFF */
+               immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_12V_ENABLE);
+
+               immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_12V_ENABLE);
+               immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_12V_ENABLE);
+               immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_12V_ENABLE;
+
+               /* wait 500 ms for the voltage to stabilize */
+               for (i = 0; i < 500; ++i)
+                       udelay(1000);
+#endif /* CONFIG_SYS_PB_12V_ENABLE */
        } else {                /* release RESET */
+#ifdef CONFIG_SYS_PB_12V_ENABLE
+               /* 12V Enable output ON */
+               immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_12V_ENABLE;
+#endif /* CONFIG_SYS_PB_12V_ENABLE */
+
+#ifdef CONFIG_SYS_PB_IDE_MOTOR
+               /* configure IDE Motor voltage monitor pin as input */
+               immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_IDE_MOTOR);
+               immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_IDE_MOTOR);
+               immr->im_cpm.cp_pbdir &= ~(CONFIG_SYS_PB_IDE_MOTOR);
+
+/* wait up to 1 s for the motor voltage to stabilize */
+               for (i = 0; i < 1000; ++i) {
+                       if ((immr->im_cpm.cp_pbdat
+                                       & CONFIG_SYS_PB_IDE_MOTOR) != 0)
+                               break;
+                       udelay(1000);
+               }
+
+               if (i == 1000) {        /* Timeout */
+                       printf("\nWarning: 5V for IDE Motor missing\n");
+#ifdef CONFIG_STATUS_LED
+#ifdef STATUS_LED_YELLOW
+                       status_led_set(STATUS_LED_YELLOW, STATUS_LED_ON);
+#endif
+#ifdef STATUS_LED_GREEN
+                       status_led_set(STATUS_LED_GREEN, STATUS_LED_OFF);
+#endif
+#endif /* CONFIG_STATUS_LED */
+               }
+#endif /* CONFIG_SYS_PB_IDE_MOTOR */
+
                immr->im_ioport.iop_pcdat |= CONFIG_SYS_PC_IDE_RESET;
        }
 
index 9bbdc5debfda4318065a9628a7b8b9195cf516ae..6b4813e4a9e3b64c18dd0ffd95585c825a723f8d 100644 (file)
@@ -1169,9 +1169,6 @@ extern void ide_set_reset(int idereset);
 
 static void ide_reset(void)
 {
-#if defined(CONFIG_SYS_PB_12V_ENABLE) || defined(CONFIG_SYS_PB_IDE_MOTOR)
-       volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
-#endif
        int i;
 
        curr_device = -1;
@@ -1187,51 +1184,6 @@ static void ide_reset(void)
 
        WATCHDOG_RESET();
 
-#ifdef CONFIG_SYS_PB_12V_ENABLE
-       /* 12V Enable output OFF */
-       immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_12V_ENABLE);
-
-       immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_12V_ENABLE);
-       immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_12V_ENABLE);
-       immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_12V_ENABLE;
-
-       /* wait 500 ms for the voltage to stabilize */
-       for (i = 0; i < 500; ++i)
-               udelay(1000);
-
-       /* 12V Enable output ON */
-       immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_12V_ENABLE;
-#endif /* CONFIG_SYS_PB_12V_ENABLE */
-
-#ifdef CONFIG_SYS_PB_IDE_MOTOR
-       /* configure IDE Motor voltage monitor pin as input */
-       immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_IDE_MOTOR);
-       immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_IDE_MOTOR);
-       immr->im_cpm.cp_pbdir &= ~(CONFIG_SYS_PB_IDE_MOTOR);
-
-       /* wait up to 1 s for the motor voltage to stabilize */
-       for (i = 0; i < 1000; ++i) {
-               if ((immr->im_cpm.cp_pbdat & CONFIG_SYS_PB_IDE_MOTOR) != 0) {
-                       break;
-               }
-               udelay(1000);
-       }
-
-       if (i == 1000) {        /* Timeout */
-               printf("\nWarning: 5V for IDE Motor missing\n");
-#ifdef CONFIG_STATUS_LED
-#ifdef STATUS_LED_YELLOW
-               status_led_set(STATUS_LED_YELLOW, STATUS_LED_ON);
-#endif
-#ifdef STATUS_LED_GREEN
-               status_led_set(STATUS_LED_GREEN, STATUS_LED_OFF);
-#endif
-#endif /* CONFIG_STATUS_LED */
-       }
-#endif /* CONFIG_SYS_PB_IDE_MOTOR */
-
-       WATCHDOG_RESET();
-
        /* de-assert RESET signal */
        ide_set_reset(0);