From: Thomas Chou Date: Sun, 28 Mar 2010 21:27:32 +0800 Subject: [U-Boot] [PATCH v3] nios2: add altera cf reset In-Reply-To: <1269781094-4393-1-git-send-email-thomas@wytron.com.tw> References: <1269781094-4393-1-git-send-email-thomas@wytron.com.tw> Message-ID: <1269782852-4347-1-git-send-email-thomas@wytron.com.tw> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This patch toggles power to reset the cf card. Signed-off-by: Thomas Chou --- board/altera/common/cfide.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 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..84ca213 --- /dev/null +++ b/board/altera/common/cfide.c @@ -0,0 +1,34 @@ +/* + * Altera CF drvier + * + * (C) Copyright 2010, Thomas Chou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include + +#if defined(CONFIG_IDE_RESET) && 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) +{ + int i; + writel(idereset ? ALTERA_CF_CTL_STATUS_RESET_MSK : + ALTERA_CF_CTL_STATUS_POWER_MSK, + CONFIG_SYS_CF_CTL_BASE + ALTERA_CF_CTL_STATUS); + /* wait 500 ms for power to stabilize */ + for (i=0; i<500; ++i) { + udelay (1000); + } +} +#endif -- 1.6.6.1