]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/bf537-stamp/ide-cf.c
Merge branch 'master' of git://git.denx.de/u-boot-imx
[people/ms/u-boot.git] / board / bf537-stamp / ide-cf.c
CommitLineData
d248cfb2
MF
1/*
2 * CF IDE addon card code
3 *
4 * Enter bugs at http://blackfin.uclinux.org/
5 *
6 * Copyright (c) 2005-2009 Analog Devices Inc.
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11#include <common.h>
12#include <config.h>
13#include <command.h>
14#include <asm/blackfin.h>
15
16void cf_outb(unsigned char val, volatile unsigned char *addr)
17{
18 *(addr) = val;
19 SSYNC();
20}
21
22unsigned char cf_inb(volatile unsigned char *addr)
23{
24 volatile unsigned char c;
25
26 c = *(addr);
27 SSYNC();
28
29 return c;
30}
31
32void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
33{
34 int i;
35
36 for (i = 0; i < words; i++)
37 *(sect_buf + i) = *(addr);
38 SSYNC();
39}
40
41void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
42{
43 int i;
44
45 for (i = 0; i < words; i++)
46 *(addr) = *(sect_buf + i);
47 SSYNC();
48}
49
50void cf_ide_init(void)
51{
52#if defined(CONFIG_BFIN_TRUE_IDE)
53 /* Enable ATASEL when in True IDE mode */
54 printf("Using CF True IDE Mode\n");
55 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA);
56 udelay(1000);
57#elif defined(CONFIG_BFIN_CF_IDE)
58 /* Disable ATASEL when we're in Common Memory Mode */
59 printf("Using CF Common Memory Mode\n");
60 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS);
61 udelay(1000);
62#elif defined(CONFIG_BFIN_HDD_IDE)
63 printf("Using HDD IDE Mode\n");
64#endif
65 ide_init();
66}