sil680.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * (C) Copyright 2007
  3. * Gary Jennejohn, DENX Software Engineering, garyj@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. */
  24. /* sil680.c - ide support functions for the Sil0680A controller */
  25. /*
  26. * The following parameters must be defined in the configuration file
  27. * of the target board:
  28. *
  29. * #define CONFIG_IDE_SIL680
  30. *
  31. * #define CONFIG_PCI_PNP
  32. * NOTE it may also be necessary to define this if the default of 8 is
  33. * incorrect for the target board (e.g. the sequoia board requires 0).
  34. * #define CONFIG_SYS_PCI_CACHE_LINE_SIZE 0
  35. *
  36. * #define CONFIG_CMD_IDE
  37. * #undef CONFIG_IDE_8xx_DIRECT
  38. * #undef CONFIG_IDE_LED
  39. * #undef CONFIG_IDE_RESET
  40. * #define CONFIG_IDE_PREINIT
  41. * #define CONFIG_SYS_IDE_MAXBUS 2 - modify to suit
  42. * #define CONFIG_SYS_IDE_MAXDEVICE (CONFIG_SYS_IDE_MAXBUS*2) - modify to suit
  43. * #define CONFIG_SYS_ATA_BASE_ADDR 0
  44. * #define CONFIG_SYS_ATA_IDE0_OFFSET 0
  45. * #define CONFIG_SYS_ATA_IDE1_OFFSET 0
  46. * #define CONFIG_SYS_ATA_DATA_OFFSET 0
  47. * #define CONFIG_SYS_ATA_REG_OFFSET 0
  48. * #define CONFIG_SYS_ATA_ALT_OFFSET 0x0004
  49. *
  50. * The mapping for PCI IO-space.
  51. * NOTE this is the value for the sequoia board. Modify to suit.
  52. * #define CONFIG_SYS_PCI0_IO_SPACE 0xE8000000
  53. */
  54. #include <common.h>
  55. #include <ata.h>
  56. #include <ide.h>
  57. #include <pci.h>
  58. extern ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS];
  59. int ide_preinit (void)
  60. {
  61. int status;
  62. pci_dev_t devbusfn;
  63. int l;
  64. status = 1;
  65. for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) {
  66. ide_bus_offset[l] = -ATA_STATUS;
  67. }
  68. devbusfn = pci_find_device (0x1095, 0x0680, 0);
  69. if (devbusfn != -1) {
  70. status = 0;
  71. pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0,
  72. (u32 *) &ide_bus_offset[0]);
  73. ide_bus_offset[0] &= 0xfffffff8;
  74. ide_bus_offset[0] += CONFIG_SYS_PCI0_IO_SPACE;
  75. pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_2,
  76. (u32 *) &ide_bus_offset[1]);
  77. ide_bus_offset[1] &= 0xfffffff8;
  78. ide_bus_offset[1] += CONFIG_SYS_PCI0_IO_SPACE;
  79. /* init various things - taken from the Linux driver */
  80. /* set PIO mode */
  81. pci_write_config_byte(devbusfn, 0x80, 0x00);
  82. pci_write_config_byte(devbusfn, 0x84, 0x00);
  83. /* IDE0 */
  84. pci_write_config_byte(devbusfn, 0xA1, 0x02);
  85. pci_write_config_word(devbusfn, 0xA2, 0x328A);
  86. pci_write_config_dword(devbusfn, 0xA4, 0x62DD62DD);
  87. pci_write_config_dword(devbusfn, 0xA8, 0x43924392);
  88. pci_write_config_dword(devbusfn, 0xAC, 0x40094009);
  89. /* IDE1 */
  90. pci_write_config_byte(devbusfn, 0xB1, 0x02);
  91. pci_write_config_word(devbusfn, 0xB2, 0x328A);
  92. pci_write_config_dword(devbusfn, 0xB4, 0x62DD62DD);
  93. pci_write_config_dword(devbusfn, 0xB8, 0x43924392);
  94. pci_write_config_dword(devbusfn, 0xBC, 0x40094009);
  95. }
  96. return (status);
  97. }
  98. void ide_set_reset (int flag) {
  99. return;
  100. }