[U-Boot] [PATCH 21/28] nios2: add cf ide init and reset handler

Thomas Chou thomas at wytron.com.tw
Fri Mar 19 08:43:46 CET 2010


This patch adds the init and reset of cf card controllers.

Signed-off-by: Thomas Chou <thomas at wytron.com.tw>
---
 board/altera/common/cfide.c |   79 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 board/altera/common/cfide.c

diff --git a/board/altera/common/cfide.c b/board/altera/common/cfide.c
new file mode 100644
index 0000000..acd1e1d
--- /dev/null
+++ b/board/altera/common/cfide.c
@@ -0,0 +1,79 @@
+/*
+ * (C) Copyright 2005, Psyent Corporation <www.psyent.com>
+ * Scott McNutt <smcnutt at psyent.com>
+ * (C) Copyright 2010, Thomas Chou <thomas at wytron.com.tw>
+ *
+ * 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 <netdev.h>
+#include <asm/io.h>
+#include <nios2-io.h>
+
+#if defined(CONFIG_CMD_IDE) && defined(CONFIG_SYS_CF_CTL_BASE)
+/* ide_set_reset for Altera CF interface */
+#define ALTERA_CF_CTL_STATUS            	0
+#define ALTERA_CF_IDE_CTL               	4
+#define ALTERA_CF_CTL_STATUS_PRESENT_MSK       (0x1)
+#define ALTERA_CF_CTL_STATUS_POWER_MSK         (0x2)
+#define ALTERA_CF_CTL_STATUS_RESET_MSK         (0x4)
+#define ALTERA_CF_CTL_STATUS_IRQ_EN_MSK        (0x8)
+#define ALTERA_CF_IDE_CTL_IRQ_EN_MSK           (0x1)
+
+void ide_set_reset(int idereset)
+{
+	if (idereset) {
+		writel(0,	/* disable ide irq */
+		       CONFIG_SYS_CF_CTL_BASE + ALTERA_CF_IDE_CTL);
+		writel(ALTERA_CF_CTL_STATUS_RESET_MSK,	/* power down */
+		       CONFIG_SYS_CF_CTL_BASE + ALTERA_CF_CTL_STATUS);
+		udelay(500 * 1000);	/* 0.5 sec delay */
+		writel(ALTERA_CF_CTL_STATUS_POWER_MSK,	/* power up */
+		       CONFIG_SYS_CF_CTL_BASE + ALTERA_CF_CTL_STATUS);
+		udelay(500 * 1000);	/* 0.5 sec delay */
+	}
+}
+#endif
+
+#if defined(CONFIG_CMD_IDE) && defined(CONFIG_SYS_CF_PRESENT)
+/* ide_preinit for PK1C20 */
+int ide_preinit(void)
+{
+	nios_pio_t *present = (nios_pio_t *) CONFIG_SYS_CF_PRESENT;
+	nios_pio_t *power = (nios_pio_t *) CONFIG_SYS_CF_POWER;
+	nios_pio_t *atasel = (nios_pio_t *) CONFIG_SYS_CF_ATASEL;
+
+	/* setup data direction registers */
+	present->direction = NIOS_PIO_IN;
+	power->direction = NIOS_PIO_OUT;
+	atasel->direction = NIOS_PIO_OUT;
+
+	/* Check for presence of card */
+	if (present->data)
+		return 1;
+	printf("Ok\n");
+
+	/* Finish setup */
+	power->data = 1;	/* Turn on power FET */
+	atasel->data = 0;	/* Put in ATA mode */
+
+	return 0;
+}
+#endif
-- 
1.6.6.1



More information about the U-Boot mailing list