public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pavel Herrmann <morpheus.ibis@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/10] split IVM power hooks from cmd_ide.c
Date: Sun,  7 Oct 2012 17:56:07 +0200	[thread overview]
Message-ID: <1349625374-12391-4-git-send-email-morpheus.ibis@gmail.com> (raw)
In-Reply-To: <1349625374-12391-1-git-send-email-morpheus.ibis@gmail.com>

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  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 common/cmd_ide.c | 48 ------------------------------------------------
 2 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/board/ivm/ivm.c b/board/ivm/ivm.c
index 71d64d4..ab29479 100644
--- a/board/ivm/ivm.c
+++ b/board/ivm/ivm.c
@@ -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;
 	}
 
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 93a328c..2604809 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -1170,9 +1170,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;
@@ -1188,51 +1185,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);
 
-- 
1.7.12

  parent reply	other threads:[~2012-10-07 15:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-07 15:56 [U-Boot] [PATCH 00/10] IDE code cleanup Pavel Herrmann
2012-10-07 15:56 ` [U-Boot] [PATCH 01/10] remove CONFIG_SC3 from cmd_ide.c Pavel Herrmann
2012-10-17 15:02   ` [U-Boot] [U-Boot,01/10] " Tom Rini
2012-10-07 15:56 ` [U-Boot] [PATCH 02/10] split mpc8xx hooks " Pavel Herrmann
2012-10-07 18:09   ` Marek Vasut
2012-10-07 18:09   ` Marek Vasut
2012-10-09 17:01   ` [U-Boot] [PATCH v2 " Pavel Herrmann
2012-10-07 15:56 ` Pavel Herrmann [this message]
2012-10-07 15:56 ` [U-Boot] [PATCH 04/10] change all versions of input_data() and output_data() to global weak aliases Pavel Herrmann
2012-10-07 18:14   ` Marek Vasut
2012-10-09 13:42     ` Pavel Herrmann
2012-10-09 17:13       ` Marek Vasut
2012-10-09 17:04   ` [U-Boot] [PATCH v2 " Pavel Herrmann
2012-10-07 15:56 ` [U-Boot] [PATCH 05/10] split CPC45 board-specific IDE functions from cmd_ide.c Pavel Herrmann
2012-10-07 18:20   ` Marek Vasut
2012-10-09 13:38     ` Pavel Herrmann
2012-10-09 17:13       ` Marek Vasut
2012-10-07 15:56 ` [U-Boot] [PATCH 06/10] make ide_led() a weak alias Pavel Herrmann
2012-10-07 15:56 ` [U-Boot] [PATCH 07/10] move CPC45 ide_led to the same file as other IDE hooks Pavel Herrmann
2012-10-07 18:21   ` Marek Vasut
2012-10-09 17:06   ` [U-Boot] [PATCH v2 " Pavel Herrmann
2012-10-07 15:56 ` [U-Boot] [PATCH 08/10] split AU1X00 specific code from cmd_ide.c Pavel Herrmann
2012-10-08 23:38   ` Tom Rini
2012-10-09 13:35     ` Pavel Herrmann
2012-10-09 17:10   ` [U-Boot] [PATCH v2 " Pavel Herrmann
2012-10-07 15:56 ` [U-Boot] [PATCH 09/10] split PCS440EP " Pavel Herrmann
2012-10-07 15:56 ` [U-Boot] [PATCH 10/10] remove unnecessary includes " Pavel Herrmann
2012-10-07 18:23 ` [U-Boot] [PATCH 00/10] IDE code cleanup Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349625374-12391-4-git-send-email-morpheus.ibis@gmail.com \
    --to=morpheus.ibis@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox