stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 6 | */ |
| 7 | /* ide.c - ide support functions */ |
| 8 | |
| 9 | |
| 10 | #include <common.h> |
Jon Loeliger | 77a3185 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 11 | #if defined(CONFIG_CMD_IDE) |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 12 | #include <ata.h> |
| 13 | #include <ide.h> |
| 14 | #include <pci.h> |
| 15 | |
Reinhard Arlt | 2b22460 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 16 | int cpci_hd_type; |
| 17 | |
| 18 | int ata_device(int dev) |
| 19 | { |
| 20 | int retval; |
| 21 | |
| 22 | retval = (dev & 1) << 4; |
| 23 | if (cpci_hd_type == 2) |
| 24 | retval ^= 1 << 4; |
| 25 | return retval; |
| 26 | } |
| 27 | |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 28 | |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 29 | int ide_preinit (void) |
| 30 | { |
| 31 | int status; |
| 32 | pci_dev_t devbusfn; |
| 33 | int l; |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 34 | |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 35 | status = 1; |
Reinhard Arlt | 2b22460 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 36 | cpci_hd_type = 0; |
Stefan Roese | 58f1046 | 2009-06-04 13:35:39 +0200 | [diff] [blame] | 37 | if (CPCI750_SLAVE_TEST != 0) |
| 38 | return status; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 39 | for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) { |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 40 | ide_bus_offset[l] = -ATA_STATUS; |
| 41 | } |
| 42 | devbusfn = pci_find_device (0x1103, 0x0004, 0); |
Reinhard Arlt | 2b22460 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 43 | if (devbusfn != -1) { |
| 44 | cpci_hd_type = 1; |
| 45 | } else { |
Stefan Roese | 2d78074 | 2007-06-22 17:32:28 +0200 | [diff] [blame] | 46 | devbusfn = pci_find_device (0x1095, 0x3114, 0); |
Reinhard Arlt | 2b22460 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 47 | if (devbusfn != -1) { |
| 48 | cpci_hd_type = 2; |
| 49 | } |
| 50 | } |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 51 | if (devbusfn != -1) { |
Wolfgang Denk | 97138fc | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 52 | ulong *ide_bus_offset_ptr; |
| 53 | |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 54 | status = 0; |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 55 | |
Wolfgang Denk | 97138fc | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 56 | ide_bus_offset_ptr = &ide_bus_offset[0]; |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 57 | pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0, |
Wolfgang Denk | 97138fc | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 58 | (u32 *)ide_bus_offset_ptr); |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 59 | ide_bus_offset[0] &= 0xfffffffe; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 60 | ide_bus_offset[0] += CONFIG_SYS_PCI0_IO_SPACE; |
Wolfgang Denk | 97138fc | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 61 | ide_bus_offset_ptr = &ide_bus_offset[1]; |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 62 | pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_2, |
Wolfgang Denk | 97138fc | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 63 | (u32 *)ide_bus_offset_ptr); |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 64 | ide_bus_offset[1] &= 0xfffffffe; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 65 | ide_bus_offset[1] += CONFIG_SYS_PCI0_IO_SPACE; |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 66 | } |
Stefan Roese | 58f1046 | 2009-06-04 13:35:39 +0200 | [diff] [blame] | 67 | return status; |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 68 | } |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 69 | |
wdenk | efe2a4d | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 70 | void ide_set_reset (int flag) { |
| 71 | return; |
| 72 | } |
stroese | 771e05b | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 73 | |
| 74 | #endif /* of CONFIG_CMDS_IDE */ |