uboot/board/bf533-stamp/ide-cf.c
<<
>>
Prefs
   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>
  14#include "bf533-stamp.h"
  15
  16void cf_outb(unsigned char val, volatile unsigned char *addr)
  17{
  18        /* "ETHERNET" means the expansion memory banks */
  19        swap_to(ETHERNET);
  20
  21        *addr = val;
  22        SSYNC();
  23
  24        swap_to(FLASH);
  25}
  26
  27unsigned char cf_inb(volatile unsigned char *addr)
  28{
  29        unsigned char c;
  30
  31        swap_to(ETHERNET);
  32
  33        c = *addr;
  34        SSYNC();
  35
  36        swap_to(FLASH);
  37
  38        return c;
  39}
  40
  41void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
  42{
  43        int i;
  44
  45        swap_to(ETHERNET);
  46
  47        for (i = 0; i < words; i++) {
  48                *(sect_buf + i) = *addr;
  49                SSYNC();
  50        }
  51
  52        swap_to(FLASH);
  53}
  54
  55void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
  56{
  57        int i;
  58
  59        swap_to(ETHERNET);
  60
  61        for (i = 0; i < words; i++) {
  62                *addr = *(sect_buf + i);
  63                SSYNC();
  64        }
  65
  66        swap_to(FLASH);
  67}
  68
  69void cf_ide_init(void)
  70{
  71        int i, cf_stat;
  72
  73        /* Check whether CF card is inserted */
  74        bfin_write_FIO_EDGE(FIO_EDGE_CF_BITS);
  75        bfin_write_FIO_POLAR(FIO_POLAR_CF_BITS);
  76        for (i = 0; i < 0x300; i++)
  77                asm volatile("nop;");
  78
  79        cf_stat = bfin_read_FIO_FLAG_S() & CF_STAT_BITS;
  80
  81        bfin_write_FIO_EDGE(FIO_EDGE_BITS);
  82        bfin_write_FIO_POLAR(FIO_POLAR_BITS);
  83
  84        if (!cf_stat) {
  85                for (i = 0; i < 0x3000; i++)
  86                        asm volatile("nop;");
  87
  88                ide_init();
  89        }
  90}
  91