diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-11-30 13:08:39 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2010-01-17 09:17:27 -0500 |
commit | 5f79644d2665763d522ef2db53c026c5f4865b02 (patch) | |
tree | 4c26214ed50a4c9d98faaf18671d3a83cd2e5c0b /board/bf533-stamp/ide-cf.c | |
parent | e54c8209913a3f26ae28819e3515df53ec2b4548 (diff) | |
download | u-boot-imx-5f79644d2665763d522ef2db53c026c5f4865b02.zip u-boot-imx-5f79644d2665763d522ef2db53c026c5f4865b02.tar.gz u-boot-imx-5f79644d2665763d522ef2db53c026c5f4865b02.tar.bz2 |
Blackfin: bf533-stamp: split and cleanup CF/IDE code
Give the CF/IDE code its own file to keep things cleanly separated. While
we're here, clean up the code to use common functions.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'board/bf533-stamp/ide-cf.c')
-rw-r--r-- | board/bf533-stamp/ide-cf.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/board/bf533-stamp/ide-cf.c b/board/bf533-stamp/ide-cf.c new file mode 100644 index 0000000..23e786b --- /dev/null +++ b/board/bf533-stamp/ide-cf.c @@ -0,0 +1,90 @@ +/* + * CF IDE addon card code + * + * Enter bugs at http://blackfin.uclinux.org/ + * + * Copyright (c) 2005-2009 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#include <common.h> +#include <config.h> +#include <asm/blackfin.h> +#include "bf533-stamp.h" + +void cf_outb(unsigned char val, volatile unsigned char *addr) +{ + /* "ETHERNET" means the expansion memory banks */ + swap_to(ETHERNET); + + *addr = val; + SSYNC(); + + swap_to(FLASH); +} + +unsigned char cf_inb(volatile unsigned char *addr) +{ + unsigned char c; + + swap_to(ETHERNET); + + c = *addr; + SSYNC(); + + swap_to(FLASH); + + return c; +} + +void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words) +{ + int i; + + swap_to(ETHERNET); + + for (i = 0; i < words; i++) { + *(sect_buf + i) = *addr; + SSYNC(); + } + + swap_to(FLASH); +} + +void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words) +{ + int i; + + swap_to(ETHERNET); + + for (i = 0; i < words; i++) { + *addr = *(sect_buf + i); + SSYNC(); + } + + swap_to(FLASH); +} + +void cf_ide_init(void) +{ + int i, cf_stat; + + /* Check whether CF card is inserted */ + bfin_write_FIO_EDGE(FIO_EDGE_CF_BITS); + bfin_write_FIO_POLAR(FIO_POLAR_CF_BITS); + for (i = 0; i < 0x300; i++) + asm volatile("nop;"); + + cf_stat = bfin_read_FIO_FLAG_S() & CF_STAT_BITS; + + bfin_write_FIO_EDGE(FIO_EDGE_BITS); + bfin_write_FIO_POLAR(FIO_POLAR_BITS); + + if (!cf_stat) { + for (i = 0; i < 0x3000; i++) + asm volatile("nop;"); + + ide_init(); + } +} |