blob: 95f01d1265c5c4e90ff1f3a79da799b7617e755e [file] [log] [blame]
Morgan Tsai1602dd52007-10-29 21:00:14 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Morgan Tsai1602dd52007-10-29 21:00:14 +00003 *
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 Tsai1602dd52007-10-29 21:00:14 +000020 */
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 Tsai218c2652007-11-02 16:09:58 +000029uint8_t SiS_SiS7001_init[16][3]={
30{0x04, 0x00, 0x07},
31{0x0C, 0x00, 0x08},
32{0x0D, 0x00, 0x20},
33
Morgan Tsai1602dd52007-10-29 21:00:14 +000034{0x2C, 0xFF, 0x39},
35{0x2D, 0xFF, 0x10},
36{0x2E, 0xFF, 0x01},
37{0x2F, 0xFF, 0x70},
Morgan Tsai218c2652007-11-02 16:09:58 +000038
Morgan Tsai1602dd52007-10-29 21:00:14 +000039{0x44, 0x00, 0x54},
40{0x45, 0x00, 0xAD},
41{0x46, 0x00, 0x01},
42{0x47, 0x00, 0x00},
Morgan Tsai218c2652007-11-02 16:09:58 +000043
44{0x48, 0x00, 0x73},
Morgan Tsai1602dd52007-10-29 21:00:14 +000045{0x49, 0x00, 0x02},
46{0x4A, 0x00, 0x00},
47{0x4B, 0x00, 0x00},
Morgan Tsai218c2652007-11-02 16:09:58 +000048
Morgan Tsai1602dd52007-10-29 21:00:14 +000049{0x00, 0x00, 0x00} //End of table
50};
51
52static void usb_init(struct device *dev)
53{
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -080054 printk(BIOS_DEBUG, "USB 1.1 INIT:---------->\n");
Morgan Tsai1602dd52007-10-29 21:00:14 +000055
56//-------------- enable USB1.1 (SiS7001) -------------------------
57{
58 uint8_t temp8;
59 int i=0;
60
Morgan Tsai1602dd52007-10-29 21:00:14 +000061 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 Tsai218c2652007-11-02 16:09:58 +000071#if DEBUG_USB
Morgan Tsai1602dd52007-10-29 21:00:14 +000072{
Morgan Tsai218c2652007-11-02 16:09:58 +000073 int i;
74
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -080075 printk(BIOS_DEBUG, "****** USB 1.1 PCI config ******");
76 printk(BIOS_DEBUG, "\n 03020100 07060504 0B0A0908 0F0E0D0C");
Morgan Tsai218c2652007-11-02 16:09:58 +000077
78 for(i=0;i<0xff;i+=4){
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -080079 if((i%16)==0)
80 printk(BIOS_DEBUG, "\n%02x: ", i);
81 printk(BIOS_DEBUG, "%08x ", pci_read_config32(dev,i));
Morgan Tsai1602dd52007-10-29 21:00:14 +000082 }
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -080083 printk(BIOS_DEBUG, "\n");
Morgan Tsai1602dd52007-10-29 21:00:14 +000084}
Morgan Tsai218c2652007-11-02 16:09:58 +000085#endif
Stefan Reinauer5ab52dd2015-01-05 13:01:01 -080086 printk(BIOS_DEBUG, "USB 1.1 INIT:<----------\n");
Morgan Tsai218c2652007-11-02 16:09:58 +000087}
88
Morgan Tsai1602dd52007-10-29 21:00:14 +000089static 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}
94static struct pci_operations lops_pci = {
95 .set_subsystem = lpci_set_subsystem,
96};
97
98static 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 Reinauer83b52e72007-10-30 02:17:49 +0000108static const struct pci_driver usb_driver __pci_driver = {
Morgan Tsai1602dd52007-10-29 21:00:14 +0000109 .ops = &usb_ops,
110 .vendor = PCI_VENDOR_ID_SIS,
111 .device = PCI_DEVICE_ID_SIS_SIS966_USB,
112};