Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 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. |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include <console/console.h> |
| 23 | #include <device/device.h> |
| 24 | #include <device/pci.h> |
| 25 | #include <device/pci_ids.h> |
| 26 | #include <device/pci_ops.h> |
| 27 | #include "sis966.h" |
| 28 | |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 29 | uint8_t SiS_SiS7001_init[16][3]={ |
| 30 | {0x04, 0x00, 0x07}, |
| 31 | {0x0C, 0x00, 0x08}, |
| 32 | {0x0D, 0x00, 0x20}, |
| 33 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 34 | {0x2C, 0xFF, 0x39}, |
| 35 | {0x2D, 0xFF, 0x10}, |
| 36 | {0x2E, 0xFF, 0x01}, |
| 37 | {0x2F, 0xFF, 0x70}, |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 38 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 39 | {0x44, 0x00, 0x54}, |
| 40 | {0x45, 0x00, 0xAD}, |
| 41 | {0x46, 0x00, 0x01}, |
| 42 | {0x47, 0x00, 0x00}, |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 43 | |
| 44 | {0x48, 0x00, 0x73}, |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 45 | {0x49, 0x00, 0x02}, |
| 46 | {0x4A, 0x00, 0x00}, |
| 47 | {0x4B, 0x00, 0x00}, |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 48 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 49 | {0x00, 0x00, 0x00} //End of table |
| 50 | }; |
| 51 | |
| 52 | static void usb_init(struct device *dev) |
| 53 | { |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 54 | printk(BIOS_DEBUG, "USB 1.1 INIT:---------->\n"); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 55 | |
| 56 | //-------------- enable USB1.1 (SiS7001) ------------------------- |
| 57 | { |
| 58 | uint8_t temp8; |
| 59 | int i=0; |
| 60 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 61 | while(SiS_SiS7001_init[i][0] != 0) |
| 62 | { temp8 = pci_read_config8(dev, SiS_SiS7001_init[i][0]); |
| 63 | temp8 &= SiS_SiS7001_init[i][1]; |
| 64 | temp8 |= SiS_SiS7001_init[i][2]; |
| 65 | pci_write_config8(dev, SiS_SiS7001_init[i][0], temp8); |
| 66 | i++; |
| 67 | }; |
| 68 | } |
| 69 | //----------------------------------------------------------- |
| 70 | |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 71 | #if DEBUG_USB |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 72 | { |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 73 | int i; |
| 74 | |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 75 | printk(BIOS_DEBUG, "****** USB 1.1 PCI config ******"); |
| 76 | printk(BIOS_DEBUG, "\n 03020100 07060504 0B0A0908 0F0E0D0C"); |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 77 | |
| 78 | for(i=0;i<0xff;i+=4){ |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 79 | if((i%16)==0) |
| 80 | printk(BIOS_DEBUG, "\n%02x: ", i); |
| 81 | printk(BIOS_DEBUG, "%08x ", pci_read_config32(dev,i)); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 82 | } |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 83 | printk(BIOS_DEBUG, "\n"); |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 84 | } |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 85 | #endif |
Stefan Reinauer | 5ab52dd | 2015-01-05 13:01:01 -0800 | [diff] [blame] | 86 | printk(BIOS_DEBUG, "USB 1.1 INIT:<----------\n"); |
Morgan Tsai | 218c265 | 2007-11-02 16:09:58 +0000 | [diff] [blame] | 87 | } |
| 88 | |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 89 | static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 90 | { |
| 91 | pci_write_config32(dev, 0x40, |
| 92 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 93 | } |
| 94 | static struct pci_operations lops_pci = { |
| 95 | .set_subsystem = lpci_set_subsystem, |
| 96 | }; |
| 97 | |
| 98 | static struct device_operations usb_ops = { |
| 99 | .read_resources = pci_dev_read_resources, |
| 100 | .set_resources = pci_dev_set_resources, |
| 101 | .enable_resources = pci_dev_enable_resources, |
| 102 | .init = usb_init, |
| 103 | // .enable = sis966_enable, |
| 104 | .scan_bus = 0, |
| 105 | .ops_pci = &lops_pci, |
| 106 | }; |
| 107 | |
Stefan Reinauer | 83b52e7 | 2007-10-30 02:17:49 +0000 | [diff] [blame] | 108 | static const struct pci_driver usb_driver __pci_driver = { |
Morgan Tsai | 1602dd5 | 2007-10-29 21:00:14 +0000 | [diff] [blame] | 109 | .ops = &usb_ops, |
| 110 | .vendor = PCI_VENDOR_ID_SIS, |
| 111 | .device = PCI_DEVICE_ID_SIS_SIS966_USB, |
| 112 | }; |