ide-cf.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include <common.h>
  11. #include <config.h>
  12. #include <command.h>
  13. #include <asm/blackfin.h>
  14. void cf_outb(unsigned char val, volatile unsigned char *addr)
  15. {
  16. *(addr) = val;
  17. SSYNC();
  18. }
  19. unsigned char cf_inb(volatile unsigned char *addr)
  20. {
  21. volatile unsigned char c;
  22. c = *(addr);
  23. SSYNC();
  24. return c;
  25. }
  26. void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
  27. {
  28. int i;
  29. for (i = 0; i < words; i++)
  30. *(sect_buf + i) = *(addr);
  31. SSYNC();
  32. }
  33. void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
  34. {
  35. int i;
  36. for (i = 0; i < words; i++)
  37. *(addr) = *(sect_buf + i);
  38. SSYNC();
  39. }
  40. void cf_ide_init(void)
  41. {
  42. #if defined(CONFIG_BFIN_TRUE_IDE)
  43. /* Enable ATASEL when in True IDE mode */
  44. printf("Using CF True IDE Mode\n");
  45. cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA);
  46. udelay(1000);
  47. #elif defined(CONFIG_BFIN_CF_IDE)
  48. /* Disable ATASEL when we're in Common Memory Mode */
  49. printf("Using CF Common Memory Mode\n");
  50. cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS);
  51. udelay(1000);
  52. #elif defined(CONFIG_BFIN_HDD_IDE)
  53. printf("Using HDD IDE Mode\n");
  54. #endif
  55. ide_init();
  56. }