Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 4 | * Copyright (C) 2014 Vladimir Serbinenko |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <device/pci_def.h> |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 21 | #include "northbridge/intel/sandybridge/sandybridge.h" /* For DEFAULT_RCBABASE. */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 22 | #include "pch.h" |
| 23 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 24 | void |
| 25 | early_usb_init (const struct southbridge_usb_port *portmap) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 26 | { |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 27 | u32 reg32; |
| 28 | const u32 rcba_dump[8] = { |
| 29 | /* 3560 */ 0x024c8001, 0x000024a3, 0x00040002, 0x01000050, |
| 30 | /* 3570 */ 0x02000772, 0x16000f9f, 0x1800ff4f, 0x0001d630, |
| 31 | }; |
| 32 | const u32 currents[] = { 0x20000153, 0x20000f57, 0x2000055b, 0x20000f51, 0x2000094a, 0x2000035f }; |
| 33 | int i; |
| 34 | /* Activate PMBAR. */ |
| 35 | pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE, DEFAULT_PMBASE | 1); |
| 36 | pci_write_config32(PCI_DEV(0, 0x1f, 0), PMBASE + 4, 0); |
| 37 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0x44 /* ACPI_CNTL */ , 0x80); /* Enable ACPI BAR */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 38 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 39 | /* Unlock registers. */ |
| 40 | outw (inw (DEFAULT_PMBASE | 0x003c) | 2, DEFAULT_PMBASE | 0x003c); |
| 41 | for (i = 0; i < 14; i++) |
| 42 | write32 (DEFAULT_RCBABASE + (0x3500 + 4 * i), |
| 43 | currents[portmap[i].current]); |
| 44 | for (i = 0; i < 10; i++) |
| 45 | write32 (DEFAULT_RCBABASE + (0x3538 + 4 * i), 0); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 46 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 47 | for (i = 0; i < 8; i++) |
| 48 | write32 (DEFAULT_RCBABASE + (0x3560 + 4 * i), rcba_dump[i]); |
| 49 | for (i = 0; i < 8; i++) |
| 50 | write32 (DEFAULT_RCBABASE + (0x3580 + 4 * i), 0); |
| 51 | reg32 = 0; |
| 52 | for (i = 0; i < 14; i++) |
| 53 | if (!portmap[i].enabled) |
| 54 | reg32 |= (1 << i); |
| 55 | write32 (DEFAULT_RCBABASE + USBPDO, reg32); |
| 56 | reg32 = 0; |
| 57 | for (i = 0; i < 8; i++) |
| 58 | if (portmap[i].enabled && portmap[i].oc_pin >= 0) |
| 59 | reg32 |= (1 << (i + 8 * portmap[i].oc_pin)); |
| 60 | write32 (DEFAULT_RCBABASE + USBOCM1, reg32); |
| 61 | reg32 = 0; |
| 62 | for (i = 8; i < 14; i++) |
| 63 | if (portmap[i].enabled && portmap[i].oc_pin >= 4) |
| 64 | reg32 |= (1 << (i - 8 + 8 * (portmap[i].oc_pin - 4))); |
| 65 | write32 (DEFAULT_RCBABASE + USBOCM2, reg32); |
| 66 | for (i = 0; i < 22; i++) |
| 67 | write32 (DEFAULT_RCBABASE + (0x35a8 + 4 * i), 0); |
| 68 | |
| 69 | pcie_write_config32 (PCI_DEV (0, 0x14, 0), 0xe4, 0x00000000); |
| 70 | |
| 71 | /* Relock registers. */ |
| 72 | outw (0x0000, DEFAULT_PMBASE | 0x003c); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 73 | } |