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 05/10] split CPC45 board-specific IDE functions from cmd_ide.c
Date: Sun,  7 Oct 2012 17:56:09 +0200	[thread overview]
Message-ID: <1349625374-12391-6-git-send-email-morpheus.ibis@gmail.com> (raw)
In-Reply-To: <1349625374-12391-1-git-send-email-morpheus.ibis@gmail.com>

Move input_data() and friends to board/cpc45/ide.c, as overrides for weak
aliases in cmd_ide.c

note: checkpatch emits warnings about using volatile

Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com>
---
 board/cpc45/Makefile |   2 +-
 board/cpc45/ide.c    | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++
 common/cmd_ide.c     |  91 ------------------------------------
 3 files changed, 131 insertions(+), 92 deletions(-)
 create mode 100644 board/cpc45/ide.c

diff --git a/board/cpc45/Makefile b/board/cpc45/Makefile
index 5c6b78f..ac1d174 100644
--- a/board/cpc45/Makefile
+++ b/board/cpc45/Makefile
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS	= $(BOARD).o flash.o plx9030.o pd67290.o
+COBJS	= $(BOARD).o flash.o plx9030.o pd67290.o ide.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/board/cpc45/ide.c b/board/cpc45/ide.c
new file mode 100644
index 0000000..7b7237b
--- /dev/null
+++ b/board/cpc45/ide.c
@@ -0,0 +1,130 @@
+/*
+ * (C) Copyright 2001
+ * Rob Taylor, Flying Pig Systems. robt at flyingpig.com.
+ *
+ * (C) Copyright 2000-2011
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <ide.h>
+#include <ata.h>
+
+#define EIEIO		__asm__ volatile ("eieio")
+#define SYNC		__asm__ volatile ("sync")
+
+void ide_input_swap_data(int dev, ulong *sect_buf, int words)
+{
+	uchar i;
+	volatile uchar *pbuf_even =
+		(uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
+	volatile uchar *pbuf_odd =
+		(uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
+	ushort *dbuf = (ushort *) sect_buf;
+
+	while (words--) {
+		for (i = 0; i < 2; i++) {
+			*(((uchar *) (dbuf)) + 1) = *pbuf_even;
+			*(uchar *) dbuf = *pbuf_odd;
+			dbuf += 1;
+		}
+	}
+}
+
+void ide_input_data(int dev, ulong *sect_buf, int words)
+{
+	uchar *dbuf;
+	volatile uchar *pbuf_even;
+	volatile uchar *pbuf_odd;
+
+	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
+	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
+	dbuf = (uchar *) sect_buf;
+	while (words--) {
+		*dbuf++ = *pbuf_even;
+		EIEIO;
+		SYNC;
+		*dbuf++ = *pbuf_odd;
+		EIEIO;
+		SYNC;
+		*dbuf++ = *pbuf_even;
+		EIEIO;
+		SYNC;
+		*dbuf++ = *pbuf_odd;
+		EIEIO;
+		SYNC;
+	}
+}
+
+void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
+{
+	uchar *dbuf;
+	volatile uchar *pbuf_even;
+	volatile uchar *pbuf_odd;
+
+	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
+	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
+	dbuf = (uchar *) sect_buf;
+	while (shorts--) {
+		EIEIO;
+		*dbuf++ = *pbuf_even;
+		EIEIO;
+		*dbuf++ = *pbuf_odd;
+	}
+}
+
+void ide_output_data(int dev, const ulong *sect_buf, int words)
+{
+	uchar *dbuf;
+	volatile uchar *pbuf_even;
+	volatile uchar *pbuf_odd;
+
+	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
+	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
+	dbuf = (uchar *) sect_buf;
+	while (words--) {
+		EIEIO;
+		*pbuf_even = *dbuf++;
+		EIEIO;
+		*pbuf_odd = *dbuf++;
+		EIEIO;
+		*pbuf_even = *dbuf++;
+		EIEIO;
+		*pbuf_odd = *dbuf++;
+	}
+}
+
+void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
+{
+	uchar *dbuf;
+	volatile uchar *pbuf_even;
+	volatile uchar *pbuf_odd;
+
+	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
+	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
+	dbuf = (uchar *) sect_buf;
+	while (shorts--) {
+		EIEIO;
+		*pbuf_even = *dbuf++;
+		EIEIO;
+		*pbuf_odd = *dbuf++;
+	}
+}
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 93371fd..89849d5 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -501,22 +501,6 @@ void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
 #else
 void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
 {
-#if defined(CONFIG_CPC45)
-	uchar i;
-	volatile uchar *pbuf_even =
-		(uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
-	volatile uchar *pbuf_odd =
-		(uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
-	ushort *dbuf = (ushort *) sect_buf;
-
-	while (words--) {
-		for (i = 0; i < 2; i++) {
-			*(((uchar *) (dbuf)) + 1) = *pbuf_even;
-			*(uchar *) dbuf = *pbuf_odd;
-			dbuf += 1;
-		}
-	}
-#else
 	volatile ushort *pbuf =
 		(ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
 	ushort *dbuf = (ushort *) sect_buf;
@@ -536,7 +520,6 @@ void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
 		*dbuf++ = ld_le16(pbuf);
 #endif /* !MIPS */
 	}
-#endif
 }
 #endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */
 
@@ -544,25 +527,6 @@ void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
 #if defined(CONFIG_IDE_SWAP_IO)
 void __ide_output_data(int dev, const ulong *sect_buf, int words)
 {
-#if defined(CONFIG_CPC45)
-	uchar *dbuf;
-	volatile uchar *pbuf_even;
-	volatile uchar *pbuf_odd;
-
-	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
-	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
-	dbuf = (uchar *) sect_buf;
-	while (words--) {
-		EIEIO;
-		*pbuf_even = *dbuf++;
-		EIEIO;
-		*pbuf_odd = *dbuf++;
-		EIEIO;
-		*pbuf_even = *dbuf++;
-		EIEIO;
-		*pbuf_odd = *dbuf++;
-	}
-#else
 	ushort *dbuf;
 	volatile ushort *pbuf;
 
@@ -582,7 +546,6 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words)
 		*pbuf = *dbuf++;
 #endif
 	}
-#endif
 }
 #else  /* ! CONFIG_IDE_SWAP_IO */
 void __ide_output_data(int dev, const ulong *sect_buf, int words)
@@ -598,29 +561,6 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words)
 #if defined(CONFIG_IDE_SWAP_IO)
 void __ide_input_data(int dev, ulong *sect_buf, int words)
 {
-#if defined(CONFIG_CPC45)
-	uchar *dbuf;
-	volatile uchar *pbuf_even;
-	volatile uchar *pbuf_odd;
-
-	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
-	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
-	dbuf = (uchar *) sect_buf;
-	while (words--) {
-		*dbuf++ = *pbuf_even;
-		EIEIO;
-		SYNC;
-		*dbuf++ = *pbuf_odd;
-		EIEIO;
-		SYNC;
-		*dbuf++ = *pbuf_even;
-		EIEIO;
-		SYNC;
-		*dbuf++ = *pbuf_odd;
-		EIEIO;
-		SYNC;
-	}
-#else
 	ushort *dbuf;
 	volatile ushort *pbuf;
 
@@ -642,7 +582,6 @@ void __ide_input_data(int dev, ulong *sect_buf, int words)
 		*dbuf++ = *pbuf;
 #endif
 	}
-#endif
 }
 #else  /* ! CONFIG_IDE_SWAP_IO */
 void __ide_input_data(int dev, ulong *sect_buf, int words)
@@ -1255,20 +1194,6 @@ void ide_output_data_shorts(int dev, ushort *sect_buf, int words)
  * we have our own transfer functions, 2 bytes alligned */
 void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
 {
-#if defined(CONFIG_CPC45)
-	uchar *dbuf;
-	volatile uchar *pbuf_even;
-	volatile uchar *pbuf_odd;
-
-	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
-	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
-	while (shorts--) {
-		EIEIO;
-		*pbuf_even = *dbuf++;
-		EIEIO;
-		*pbuf_odd = *dbuf++;
-	}
-#else
 	ushort *dbuf;
 	volatile ushort *pbuf;
 
@@ -1282,25 +1207,10 @@ void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
 		EIEIO;
 		*pbuf = *dbuf++;
 	}
-#endif
 }
 
 void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
 {
-#if defined(CONFIG_CPC45)
-	uchar *dbuf;
-	volatile uchar *pbuf_even;
-	volatile uchar *pbuf_odd;
-
-	pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
-	pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
-	while (shorts--) {
-		EIEIO;
-		*dbuf++ = *pbuf_even;
-		EIEIO;
-		*dbuf++ = *pbuf_odd;
-	}
-#else
 	ushort *dbuf;
 	volatile ushort *pbuf;
 
@@ -1314,7 +1224,6 @@ void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
 		EIEIO;
 		*dbuf++ = *pbuf;
 	}
-#endif
 }
 
 #else  /* ! CONFIG_IDE_SWAP_IO */
-- 
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 ` [U-Boot] [PATCH 03/10] split IVM power " Pavel Herrmann
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 ` Pavel Herrmann [this message]
2012-10-07 18:20   ` [U-Boot] [PATCH 05/10] split CPC45 board-specific IDE functions from cmd_ide.c 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-6-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