Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the LinuxBIOS 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 | * Copyright (C) 2007 Silicon Integrated Systems Corp. (SiS) |
| 9 | * Written by Morgan Tsai <my_tsai@sis.com> for SiS. |
| 10 | * |
| 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. |
| 15 | * |
| 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. |
| 20 | * |
| 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 |
| 24 | */ |
| 25 | |
| 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> |
| 31 | #include "sis966.h" |
| 32 | |
| 33 | // From Y.S. |
| 34 | // PCI R47h-R44h=0001AD54h |
| 35 | // PCI R4Bh-R48h=00000271h |
| 36 | uint8_t SiS_SiS7001_init[15][3]={ |
| 37 | {0x04, 0xFF, 0x07}, |
| 38 | {0x2C, 0xFF, 0x39}, |
| 39 | {0x2D, 0xFF, 0x10}, |
| 40 | {0x2E, 0xFF, 0x01}, |
| 41 | {0x2F, 0xFF, 0x70}, |
| 42 | {0x44, 0x00, 0x54}, |
| 43 | {0x45, 0x00, 0xAD}, |
| 44 | {0x46, 0x00, 0x01}, |
| 45 | {0x47, 0x00, 0x00}, |
| 46 | {0x48, 0x00, 0x71}, |
| 47 | {0x49, 0x00, 0x02}, |
| 48 | {0x4A, 0x00, 0x00}, |
| 49 | {0x4B, 0x00, 0x00}, |
| 50 | {0x04, 0x00, 0x07}, |
| 51 | {0x00, 0x00, 0x00} //End of table |
| 52 | }; |
| 53 | |
| 54 | static void usb_init(struct device *dev) |
| 55 | { |
| 56 | |
| 57 | //-------------- enable USB1.1 (SiS7001) ------------------------- |
| 58 | { |
| 59 | uint8_t temp8; |
| 60 | int i=0; |
| 61 | |
| 62 | printk_debug("USB1.1_Init\n"); |
| 63 | |
| 64 | while(SiS_SiS7001_init[i][0] != 0) |
| 65 | { temp8 = pci_read_config8(dev, SiS_SiS7001_init[i][0]); |
| 66 | temp8 &= SiS_SiS7001_init[i][1]; |
| 67 | temp8 |= SiS_SiS7001_init[i][2]; |
| 68 | pci_write_config8(dev, SiS_SiS7001_init[i][0], temp8); |
| 69 | i++; |
| 70 | }; |
| 71 | } |
| 72 | //----------------------------------------------------------- |
| 73 | |
| 74 | #if 0 |
| 75 | { |
| 76 | int i; |
| 77 | printk_debug("\nUSB 1.1 PCI config"); |
| 78 | for(i=0;i<0xFF;i+=4) |
| 79 | { |
| 80 | if((i%16)==0) |
| 81 | { |
| 82 | print_debug("\r\n");print_debug_hex8(i);print_debug(": ");} |
| 83 | print_debug_hex32(pci_read_config32(dev,i)); |
| 84 | print_debug(" "); |
| 85 | } |
| 86 | print_debug("\r\n"); |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | } |
| 91 | static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 92 | { |
| 93 | pci_write_config32(dev, 0x40, |
| 94 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 95 | } |
| 96 | static struct pci_operations lops_pci = { |
| 97 | .set_subsystem = lpci_set_subsystem, |
| 98 | }; |
| 99 | |
| 100 | static struct device_operations usb_ops = { |
| 101 | .read_resources = pci_dev_read_resources, |
| 102 | .set_resources = pci_dev_set_resources, |
| 103 | .enable_resources = pci_dev_enable_resources, |
| 104 | .init = usb_init, |
| 105 | // .enable = sis966_enable, |
| 106 | .scan_bus = 0, |
| 107 | .ops_pci = &lops_pci, |
| 108 | }; |
| 109 | |
Stefan Reinauer | 83b52e7 | 2007-10-30 02:17:49 +0000 | [diff] [blame^] | 110 | static const struct pci_driver usb_driver __pci_driver = { |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 111 | .ops = &usb_ops, |
| 112 | .vendor = PCI_VENDOR_ID_SIS, |
| 113 | .device = PCI_DEVICE_ID_SIS_SIS966_USB, |
| 114 | }; |