ide.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /* ide.c - ide support functions */
  8. #include <common.h>
  9. #if defined(CONFIG_CMD_IDE)
  10. #include <ata.h>
  11. #include <ide.h>
  12. #include <pci.h>
  13. int cpci_hd_type;
  14. int ata_device(int dev)
  15. {
  16. int retval;
  17. retval = (dev & 1) << 4;
  18. if (cpci_hd_type == 2)
  19. retval ^= 1 << 4;
  20. return retval;
  21. }
  22. int ide_preinit (void)
  23. {
  24. int status;
  25. pci_dev_t devbusfn;
  26. int l;
  27. status = 1;
  28. cpci_hd_type = 0;
  29. if (CPCI750_SLAVE_TEST != 0)
  30. return status;
  31. for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) {
  32. ide_bus_offset[l] = -ATA_STATUS;
  33. }
  34. devbusfn = pci_find_device (0x1103, 0x0004, 0);
  35. if (devbusfn != -1) {
  36. cpci_hd_type = 1;
  37. } else {
  38. devbusfn = pci_find_device (0x1095, 0x3114, 0);
  39. if (devbusfn != -1) {
  40. cpci_hd_type = 2;
  41. }
  42. }
  43. if (devbusfn != -1) {
  44. ulong *ide_bus_offset_ptr;
  45. status = 0;
  46. ide_bus_offset_ptr = &ide_bus_offset[0];
  47. pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0,
  48. (u32 *)ide_bus_offset_ptr);
  49. ide_bus_offset[0] &= 0xfffffffe;
  50. ide_bus_offset[0] += CONFIG_SYS_PCI0_IO_SPACE;
  51. ide_bus_offset_ptr = &ide_bus_offset[1];
  52. pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_2,
  53. (u32 *)ide_bus_offset_ptr);
  54. ide_bus_offset[1] &= 0xfffffffe;
  55. ide_bus_offset[1] += CONFIG_SYS_PCI0_IO_SPACE;
  56. }
  57. return status;
  58. }
  59. void ide_set_reset (int flag) {
  60. return;
  61. }
  62. #endif /* of CONFIG_CMDS_IDE */