Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / drivers / si / 3114 / si_sata.c
1 /* Copyright 2003-2004 Tyan Computer*/
2
3 /* Author: Yinghai Lu yhlu@tyan.com
4  *
5  */
6
7
8 #include <delay.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <arch/io.h>
12
13 #include <console/console.h>
14 #include <device/device.h>
15 #include <device/pci.h>
16 #include <device/pci_ids.h>
17 #include <device/pci_ops.h>
18
19
20 static void si_sata_init(struct device *dev)
21 {
22         uint16_t word;
23         uint32_t dword;
24 #if 0
25         word = pci_read_config16(dev, 0x4);
26         word |= ((1 << 2) |(1<<4)); // Command: 3--> 17
27         pci_write_config16(dev, 0x4, word);
28 #endif
29
30         /* some driver change class code to 0x104, but not change deviceid without reason*/
31         /* restore it so we don't need to unplug AC power to restore it*/
32
33         word = pci_read_config16(dev, 0x0a);
34         if(word!=0x0180) {
35                  /* enble change device id and class id*/
36                 dword = pci_read_config32(dev,0x40);
37                 dword |= (1<<0);
38                 pci_write_config32(dev, 0x40, dword);
39
40                 word = 0x0180;
41                 pci_write_config16(dev, 0x0a, word);
42
43                 /* disable change device id and class id*/
44                 dword = pci_read_config32(dev,0x40);
45                 dword &= ~(1<<0);
46                 pci_write_config32(dev, 0x40, dword);
47
48                 printk(BIOS_DEBUG, "Class code restored.\n");
49
50         }
51
52
53 }
54 static struct device_operations si_sata_ops  = {
55         .read_resources   = pci_dev_read_resources,
56         .set_resources    = pci_dev_set_resources,
57         .enable_resources = pci_dev_enable_resources,
58         .init             = si_sata_init,
59         .scan_bus         = 0,
60 };
61
62 static const struct pci_driver si_sata_driver __pci_driver = {
63         .ops    = &si_sata_ops,
64         .vendor = 0x1095,
65         .device = 0x3114,
66 };
67