]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/esd/cpci750/ide.c
Coding Style cleanup: replace leading SPACEs by TABs
[karo-tx-uboot.git] / board / esd / cpci750 / ide.c
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
9
10 #include <common.h>
11 #if defined(CONFIG_CMD_IDE)
12 #include <ata.h>
13 #include <ide.h>
14 #include <pci.h>
15
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
28
29 int ide_preinit (void)
30 {
31         int status;
32         pci_dev_t devbusfn;
33         int l;
34
35         status = 1;
36         cpci_hd_type = 0;
37         if (CPCI750_SLAVE_TEST != 0)
38                 return status;
39         for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) {
40                 ide_bus_offset[l] = -ATA_STATUS;
41         }
42         devbusfn = pci_find_device (0x1103, 0x0004, 0);
43         if (devbusfn != -1) {
44                 cpci_hd_type = 1;
45         } else {
46                 devbusfn = pci_find_device (0x1095, 0x3114, 0);
47                 if (devbusfn != -1) {
48                         cpci_hd_type = 2;
49                 }
50         }
51         if (devbusfn != -1) {
52                 ulong *ide_bus_offset_ptr;
53
54                 status = 0;
55
56                 ide_bus_offset_ptr = &ide_bus_offset[0];
57                 pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0,
58                                        (u32 *)ide_bus_offset_ptr);
59                 ide_bus_offset[0] &= 0xfffffffe;
60                 ide_bus_offset[0] += CONFIG_SYS_PCI0_IO_SPACE;
61                 ide_bus_offset_ptr = &ide_bus_offset[1];
62                 pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_2,
63                                        (u32 *)ide_bus_offset_ptr);
64                 ide_bus_offset[1] &= 0xfffffffe;
65                 ide_bus_offset[1] += CONFIG_SYS_PCI0_IO_SPACE;
66         }
67         return status;
68 }
69
70 void ide_set_reset (int flag) {
71         return;
72 }
73
74 #endif /* of CONFIG_CMDS_IDE */