]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/bf533-stamp/ide-cf.c
Merge branch 'master' of git://git.denx.de/u-boot-i2c
[people/ms/u-boot.git] / board / bf533-stamp / ide-cf.c
CommitLineData
5f79644d
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 <asm/blackfin.h>
5f79644d
MF
14
15void cf_outb(unsigned char val, volatile unsigned char *addr)
16{
17 /* "ETHERNET" means the expansion memory banks */
18 swap_to(ETHERNET);
19
20 *addr = val;
21 SSYNC();
22
23 swap_to(FLASH);
24}
25
26unsigned char cf_inb(volatile unsigned char *addr)
27{
28 unsigned char c;
29
30 swap_to(ETHERNET);
31
32 c = *addr;
33 SSYNC();
34
35 swap_to(FLASH);
36
37 return c;
38}
39
40void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
41{
42 int i;
43
44 swap_to(ETHERNET);
45
46 for (i = 0; i < words; i++) {
47 *(sect_buf + i) = *addr;
48 SSYNC();
49 }
50
51 swap_to(FLASH);
52}
53
54void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
55{
56 int i;
57
58 swap_to(ETHERNET);
59
60 for (i = 0; i < words; i++) {
61 *addr = *(sect_buf + i);
62 SSYNC();
63 }
64
65 swap_to(FLASH);
66}
67
9280c3f1
MF
68/* Definitions used in Compact Flash Boot support */
69#define FIO_EDGE_CF_BITS 0x0000
70#define FIO_POLAR_CF_BITS 0x0000
71#define FIO_EDGE_BITS 0x1E0
72#define FIO_POLAR_BITS 0x160
73
74/* Compact flash status bits in status register */
75#define CF_STAT_BITS 0x00000060
76
5f79644d
MF
77void cf_ide_init(void)
78{
79 int i, cf_stat;
80
81 /* Check whether CF card is inserted */
82 bfin_write_FIO_EDGE(FIO_EDGE_CF_BITS);
83 bfin_write_FIO_POLAR(FIO_POLAR_CF_BITS);
84 for (i = 0; i < 0x300; i++)
85 asm volatile("nop;");
86
87 cf_stat = bfin_read_FIO_FLAG_S() & CF_STAT_BITS;
88
89 bfin_write_FIO_EDGE(FIO_EDGE_BITS);
90 bfin_write_FIO_POLAR(FIO_POLAR_BITS);
91
92 if (!cf_stat) {
93 for (i = 0; i < 0x3000; i++)
94 asm volatile("nop;");
95
96 ide_init();
97 }
98}