2 * This file is part of the LinuxBIOS project.
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 * Copyright (C) 2007 Silicon Integrated Systems Corp. (SiS)
9 * Written by Morgan Tsai <my_tsai@sis.com> for SiS.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <console/console.h>
27 #include <device/device.h>
29 #include <device/pci.h>
30 #include <device/pci_ids.h>
31 #include <device/pci_ops.h>
35 uint8_t SiS_SiS1183_init[68][3]={
43 {0x91, 0x00, 0x00}, // set mode
58 {0x88, 0x00, 0xDE}, // after set mode
81 {0xD8, 0xFE, 0x01}, // Com reset
86 {0xD8, 0xFE, 0x00}, // Com reset
92 {0xC4, 0xFF, 0xFF}, // Clear status
100 {0xE4, 0xFF, 0xFF}, // Clear status
109 {0x00, 0x00, 0x00} //End of table
112 static void sata_init(struct device *dev)
115 struct southbridge_sis_sis966_config *conf;
118 struct resource *res;
122 conf = dev->chip_info;
123 print_debug("SATA_INIT:---------->\n");
125 //-------------- enable IDE (SiS1183) -------------------------
129 while(SiS_SiS1183_init[i][0] != 0)
131 temp8 = pci_read_config8(dev, SiS_SiS1183_init[i][0]);
132 temp8 &= SiS_SiS1183_init[i][1];
133 temp8 |= SiS_SiS1183_init[i][2];
134 pci_write_config8(dev, SiS_SiS1183_init[i][0], temp8);
138 //-----------------------------------------------------------
146 temp32= pci_read_config32(dev, 0xC0);
147 for ( j=0;j<0xFFFF;j++);
148 printk_debug("status= %x\n",temp32);
149 if (((temp32&0xF) == 0x3) || ((temp32&0xF) == 0x0)) break;
158 print_debug("****** SATA PCI config ******");
159 print_debug("\n 03020100 07060504 0B0A0908 0F0E0D0C");
161 for(i=0;i<0xff;i+=4){
167 print_debug_hex32(pci_read_config32(dev,i));
174 print_debug("SATA_INIT:<----------\n");
178 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
180 pci_write_config32(dev, 0x40,
181 ((device & 0xffff) << 16) | (vendor & 0xffff));
183 static struct pci_operations lops_pci = {
184 .set_subsystem = lpci_set_subsystem,
187 static struct device_operations sata_ops = {
188 .read_resources = pci_dev_read_resources,
189 .set_resources = pci_dev_set_resources,
190 .enable_resources = pci_dev_enable_resources,
191 // .enable = sis966_enable,
194 .ops_pci = &lops_pci,
197 static const struct pci_driver sata0_driver __pci_driver = {
199 .vendor = PCI_VENDOR_ID_SIS,
200 .device = PCI_DEVICE_ID_SIS_SIS966_SATA0,