2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <console/console.h>
21 #include <device/device.h>
22 #include <device/pci.h>
23 #include <device/pci_ids.h>
24 #include <device/pci_ops.h>
25 #include <usbdebug_direct.h>
29 static struct pci_operations lops_pci = {
30 .set_subsystem = pci_dev_set_subsystem,
33 static void usb_init(struct device *dev)
39 /* 6.1 Enable OHCI0-4 and EHCI Controllers */
41 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
42 byte = pci_read_config8(sm_dev, 0x68);
44 pci_write_config8(sm_dev, 0x68, byte);
47 /* RPR 6.2 Enables the USB PME Event,Enable USB resume support */
48 byte = pm_ioread(0x61);
50 pm_iowrite(0x61, byte);
51 byte = pm_ioread(0x65);
53 pm_iowrite(0x65, byte);
55 /* RPR 6.3 Support USB device wakeup from the S4/S5 state */
56 byte = pm_ioread(0x65);
58 pm_iowrite(0x65, byte);
60 /* RPR 6.5 Enable the USB controller to get reset by any software that generate a PCIRst# condition */
61 byte = pm_ioread(0x65);
63 pm_iowrite(0x65, byte);
65 /* RPR 6.10 Disable OHCI MSI Capability. */
66 word = pci_read_config16(dev, 0x40);
68 pci_write_config16(dev, 0x40, word);
71 static void usb_init2(struct device *dev)
80 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
81 rev = get_sb700_revision(sm_dev);
83 /* dword = pci_read_config32(dev, 0xf8); */
85 /* pci_write_config32(dev, 0xf8, dword); */
87 usb2_bar0 = (u8 *) (pci_read_config32(dev, 0x10) & ~0xFF);
88 printk_info("usb2_bar0=%p\n", usb2_bar0);
90 /* RPR6.4 Enables the USB PHY auto calibration resister to match 45ohm resistence */
92 write32(usb2_bar0 + 0xC0, dword);
94 /* RPR6.9 Sets In/OUT FIFO threshold for best performance */
96 write32(usb2_bar0 + 0xA4, dword);
98 /* RPR6.11 Disabling EHCI Advance Asynchronous Enhancement */
99 dword = pci_read_config32(dev, 0x50);
101 pci_write_config32(dev, 0x50, dword);
103 /* RPR 6.12 EHCI Advance PHY Power Savings */
104 /* RPR says it is just for A12. CIMM sets it when it is above A11. */
105 /* But it makes the linux crash, so we skip it */
107 dword = pci_read_config32(dev, 0x50);
109 pci_write_config32(dev, 0x50, dword);
112 /* RPR6.13 Enabling Fix for EHCI Controller Dirver Yellow Sign Issue */
113 /* RPR says it is just for A12. CIMM sets it when it is above A11. */
114 dword = pci_read_config32(dev, 0x50);
116 pci_write_config32(dev, 0x50, dword);
118 /* RPR6.15 EHCI Async Park Mode */
119 dword = pci_read_config32(dev, 0x50);
121 pci_write_config32(dev, 0x50, dword);
123 /* Each step below causes the linux crashes. Leave them here
124 * for future debugging. */
126 /* RPR6.16 Disable EHCI MSI support */
127 byte = pci_read_config8(dev, 0x50);
129 pci_write_config8(dev, 0x50, byte);
131 /* RPR6.17 Disable the EHCI Dynamic Power Saving feature */
132 word = read32(usb2_bar0 + 0xBC);
134 write16(usb2_bar0 + 0xBC, word);
136 /* RPR6.19 USB Controller DMA Read Delay Tolerant. */
137 if (rev >= REV_SB700_A14) {
138 byte = pci_read_config8(dev, 0x50);
140 pci_write_config8(dev, 0x50, byte);
143 /* RPR6.20 Async Park Mode. */
144 /* RPR recommends not to set these bits. */
146 dword = pci_read_config32(dev, 0x50);
148 if (rev >= REV_SB700_A14) {
151 pci_write_config32(dev, 0x50, dword);
154 /* RPR6.22 Advance Async Enhancement */
155 /* RPR6.23 USB Periodic Cache Setting */
156 dword = pci_read_config32(dev, 0x50);
157 if (rev == REV_SB700_A12) {
158 dword |= 1 << 28; /* 6.22 */
159 dword |= 1 << 27; /* 6.23 */
160 } else if (rev >= REV_SB700_A14) {
162 dword &= ~(1 << 28); /* 6.22 */
164 dword &= ~(1 << 27); /* 6.23 */
166 printk_debug("rpr 6.23, final dword=%x\n", dword);
170 static void usb_set_resources(struct device *dev)
172 #if CONFIG_USBDEBUG_DIRECT
173 struct resource *res;
177 old_debug = get_ehci_debug();
180 pci_dev_set_resources(dev);
182 #if CONFIG_USBDEBUG_DIRECT
183 res = find_resource(dev, 0x10);
184 set_ehci_debug(old_debug);
189 report_resource_stored(dev, res, "");
194 static struct device_operations usb_ops = {
195 .read_resources = pci_dev_read_resources,
196 .set_resources = usb_set_resources, /* pci_dev_set_resources, */
197 .enable_resources = pci_dev_enable_resources,
200 .ops_pci = &lops_pci,
203 static struct pci_driver usb_0_driver __pci_driver = {
205 .vendor = PCI_VENDOR_ID_ATI,
206 .device = PCI_DEVICE_ID_ATI_SB700_USB_18_0,
208 static struct pci_driver usb_1_driver __pci_driver = {
210 .vendor = PCI_VENDOR_ID_ATI,
211 .device = PCI_DEVICE_ID_ATI_SB700_USB_18_1,
214 /* the pci id of usb ctrl 0 and 1 are the same. */
216 * static struct pci_driver usb_3_driver __pci_driver = {
218 * .vendor = PCI_VENDOR_ID_ATI,
219 * .device = PCI_DEVICE_ID_ATI_SB700_USB_19_0,
221 * static struct pci_driver usb_4_driver __pci_driver = {
223 * .vendor = PCI_VENDOR_ID_ATI,
224 * .device = PCI_DEVICE_ID_ATI_SB700_USB_19_1,
228 static struct pci_driver usb_4_driver __pci_driver = {
230 .vendor = PCI_VENDOR_ID_ATI,
231 .device = PCI_DEVICE_ID_ATI_SB700_USB_20_5,
234 static struct device_operations usb_ops2 = {
235 .read_resources = pci_dev_read_resources,
236 .set_resources = usb_set_resources, /* pci_dev_set_resources, */
237 .enable_resources = pci_dev_enable_resources,
240 .ops_pci = &lops_pci,
243 static struct pci_driver usb_5_driver __pci_driver = {
245 .vendor = PCI_VENDOR_ID_ATI,
246 .device = PCI_DEVICE_ID_ATI_SB700_USB_18_2,
249 * static struct pci_driver usb_5_driver __pci_driver = {
251 * .vendor = PCI_VENDOR_ID_ATI,
252 * .device = PCI_DEVICE_ID_ATI_SB700_USB_19_2,