stroese | c096c84 | 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 | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 6 | */ |
| 7 | /* ide.c - ide support functions */ |
| 8 | |
| 9 | |
| 10 | #include <common.h> |
Jon Loeliger | 13f7599 | 2007-07-10 10:39:10 -0500 | [diff] [blame] | 11 | #if defined(CONFIG_CMD_IDE) |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 12 | #include <ata.h> |
| 13 | #include <ide.h> |
| 14 | #include <pci.h> |
| 15 | |
Reinhard Arlt | eddcf95 | 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 | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 28 | |
wdenk | 07d7e6b | 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 | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 34 | |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 35 | status = 1; |
Reinhard Arlt | eddcf95 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 36 | cpci_hd_type = 0; |
Stefan Roese | 53baa42 | 2009-06-04 13:35:39 +0200 | [diff] [blame] | 37 | if (CPCI750_SLAVE_TEST != 0) |
| 38 | return status; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 39 | for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) { |
wdenk | 07d7e6b | 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 | eddcf95 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 43 | if (devbusfn != -1) { |
| 44 | cpci_hd_type = 1; |
| 45 | } else { |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 46 | devbusfn = pci_find_device (0x1095, 0x3114, 0); |
Reinhard Arlt | eddcf95 | 2011-11-10 08:51:57 +0000 | [diff] [blame] | 47 | if (devbusfn != -1) { |
| 48 | cpci_hd_type = 2; |
| 49 | } |
| 50 | } |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 51 | if (devbusfn != -1) { |
Wolfgang Denk | b985ed6 | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 52 | ulong *ide_bus_offset_ptr; |
| 53 | |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 54 | status = 0; |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 55 | |
Wolfgang Denk | b985ed6 | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 56 | ide_bus_offset_ptr = &ide_bus_offset[0]; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 57 | pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0, |
Wolfgang Denk | b985ed6 | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 58 | (u32 *)ide_bus_offset_ptr); |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 59 | ide_bus_offset[0] &= 0xfffffffe; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 60 | ide_bus_offset[0] += CONFIG_SYS_PCI0_IO_SPACE; |
Wolfgang Denk | b985ed6 | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 61 | ide_bus_offset_ptr = &ide_bus_offset[1]; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 62 | pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_2, |
Wolfgang Denk | b985ed6 | 2009-09-11 11:15:31 +0200 | [diff] [blame] | 63 | (u32 *)ide_bus_offset_ptr); |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 64 | ide_bus_offset[1] &= 0xfffffffe; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 65 | ide_bus_offset[1] += CONFIG_SYS_PCI0_IO_SPACE; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 66 | } |
Stefan Roese | 53baa42 | 2009-06-04 13:35:39 +0200 | [diff] [blame] | 67 | return status; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 68 | } |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 69 | |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 70 | void ide_set_reset (int flag) { |
| 71 | return; |
| 72 | } |
stroese | c096c84 | 2004-12-16 18:21:17 +0000 | [diff] [blame] | 73 | |
| 74 | #endif /* of CONFIG_CMDS_IDE */ |