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>
28 #include <device/pci.h>
29 #include <device/pci_ids.h>
30 #include <device/pci_ops.h>
34 uint8_t SiS_SiS5513_init[49][3]={
70 {0xD8, 0xFE, 0x01}, // Com reset
72 {0xC4, 0xFF, 0xFF}, // Clear status
82 {0x2C, 0xFF, 0x39}, // set subsystem ID
88 {0x00, 0x00, 0x00} //End of table
91 static void ide_init(struct device *dev)
93 struct southbridge_sis_sis966_config *conf;
94 /* Enable ide devices so the linux ide driver will work */
98 conf = dev->chip_info;
102 printk_debug("ide_init:---------->\n");
105 //-------------- enable IDE (SiS5513) -------------------------
109 while(SiS_SiS5513_init[i][0] != 0)
110 { temp8 = pci_read_config8(dev, SiS_SiS5513_init[i][0]);
111 temp8 &= SiS_SiS5513_init[i][1];
112 temp8 |= SiS_SiS5513_init[i][2];
113 pci_write_config8(dev, SiS_SiS5513_init[i][0], temp8);
117 //-----------------------------------------------------------
119 word = pci_read_config16(dev, 0x50);
120 /* Ensure prefetch is disabled */
121 word &= ~((1 << 15) | (1 << 13));
122 if (conf->ide1_enable) {
123 /* Enable secondary ide interface */
125 printk_debug("IDE1 \t");
127 if (conf->ide0_enable) {
128 /* Enable primary ide interface */
130 printk_debug("IDE0\n");
136 pci_write_config16(dev, 0x50, word);
139 byte = 0x20 ; // Latency: 64-->32
140 pci_write_config8(dev, 0xd, byte);
142 dword = pci_read_config32(dev, 0xf8);
144 pci_write_config32(dev, 0xf8, dword);
145 #if CONFIG_PCI_ROM_RUN == 1
151 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
153 pci_write_config32(dev, 0x40,
154 ((device & 0xffff) << 16) | (vendor & 0xffff));
156 static struct pci_operations lops_pci = {
157 .set_subsystem = lpci_set_subsystem,
160 static struct device_operations ide_ops = {
161 .read_resources = pci_dev_read_resources,
162 .set_resources = pci_dev_set_resources,
163 .enable_resources = pci_dev_enable_resources,
166 // .enable = sis966_enable,
167 .ops_pci = &lops_pci,
170 static const struct pci_driver ide_driver __pci_driver = {
172 .vendor = PCI_VENDOR_ID_SIS,
173 .device = PCI_DEVICE_ID_SIS_SIS966_IDE,