MCP55: Cosmetic fixes, switch to u8 et al.
[coreboot.git] / src / southbridge / nvidia / mcp55 / sata.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2004 Tyan Computer
5  * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
6  * Copyright (C) 2006,2007 AMD
7  * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
22  */
23
24 #include <console/console.h>
25 #include <device/device.h>
26 #include <delay.h>
27 #include <device/pci.h>
28 #include <device/pci_ids.h>
29 #include <device/pci_ops.h>
30 #include "mcp55.h"
31
32 static void sata_init(struct device *dev)
33 {
34         u32 dword;
35
36         struct southbridge_nvidia_mcp55_config *conf;
37         conf = dev->chip_info;
38
39         dword = pci_read_config32(dev, 0x50);
40         /* Ensure prefetch is disabled */
41         dword &= ~((1 << 15) | (1 << 13));
42         if(conf) {
43                 if (conf->sata1_enable) {
44                         /* Enable secondary SATA interface */
45                         dword |= (1<<0);
46                         printk(BIOS_DEBUG, "SATA S \t");
47                 }
48                 if (conf->sata0_enable) {
49                         /* Enable primary SATA interface */
50                         dword |= (1<<1);
51                         printk(BIOS_DEBUG, "SATA P \n");
52                 }
53         } else {
54                 dword |= (1<<1) | (1<<0);
55                 printk(BIOS_DEBUG, "SATA P and S \n");
56         }
57
58
59 #if 1
60         dword &= ~(0x1f<<24);
61         dword |= (0x15<<24);
62 #endif
63         pci_write_config32(dev, 0x50, dword);
64
65         dword = pci_read_config32(dev, 0xf8);
66         dword |= 2;
67         pci_write_config32(dev, 0xf8, dword);
68
69
70 }
71
72 static struct device_operations sata_ops = {
73         .read_resources = pci_dev_read_resources,
74         .set_resources  = pci_dev_set_resources,
75         .enable_resources       = pci_dev_enable_resources,
76 //      .enable         = mcp55_enable,
77         .init           = sata_init,
78         .scan_bus       = 0,
79         .ops_pci        = &mcp55_pci_ops,
80 };
81
82 static const struct pci_driver sata0_driver __pci_driver = {
83         .ops    = &sata_ops,
84         .vendor = PCI_VENDOR_ID_NVIDIA,
85         .device = PCI_DEVICE_ID_NVIDIA_MCP55_SATA0,
86 };
87
88 static const struct pci_driver sata1_driver __pci_driver = {
89         .ops    = &sata_ops,
90         .vendor = PCI_VENDOR_ID_NVIDIA,
91         .device = PCI_DEVICE_ID_NVIDIA_MCP55_SATA1,
92 };