Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; version 2 of |
| 8 | * the License. |
| 9 | * |
| 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. |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 16 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 17 | #include <device/pci_ops.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 18 | #include <device/pci_def.h> |
Elyes HAOUAS | f385e9d | 2018-11-01 19:13:08 +0100 | [diff] [blame] | 19 | #include <northbridge/intel/sandybridge/sandybridge.h> |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 20 | #include <southbridge/intel/common/rcba.h> |
| 21 | #include <southbridge/intel/common/pmbase.h> |
| 22 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 23 | #include "pch.h" |
| 24 | |
Elyes HAOUAS | f385e9d | 2018-11-01 19:13:08 +0100 | [diff] [blame] | 25 | void 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 | }; |
Vagiz Trakhanov | 216ad21 | 2017-09-28 14:54:52 +0000 | [diff] [blame] | 32 | const u32 currents[] = { 0x20000153, 0x20000f57, 0x2000055b, 0x20000f51, |
| 33 | 0x2000094a, 0x2000035f, 0x20000f53, 0x20000357, |
| 34 | 0x20000353 }; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 35 | int i; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 36 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 37 | /* Unlock registers. */ |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 38 | write_pmbase16(UPRWC, read_pmbase16(UPRWC) | UPRWC_WR_EN); |
Patrick Rudolph | 87b5ff0 | 2017-05-28 13:57:04 +0200 | [diff] [blame] | 39 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 40 | for (i = 0; i < 14; i++) |
Patrick Rudolph | 4f8b108 | 2019-07-14 11:54:58 +0200 | [diff] [blame] | 41 | RCBA32(USBIR0 + 4 * i) = currents[portmap[i].current]; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 42 | for (i = 0; i < 10; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 43 | RCBA32(0x3538 + 4 * i) = 0; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 44 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 45 | for (i = 0; i < 8; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 46 | RCBA32(0x3560 + 4 * i) = rcba_dump[i]; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 47 | for (i = 0; i < 8; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 48 | RCBA32(0x3580 + 4 * i) = 0; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 49 | reg32 = 0; |
| 50 | for (i = 0; i < 14; i++) |
| 51 | if (!portmap[i].enabled) |
| 52 | reg32 |= (1 << i); |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 53 | RCBA32(USBPDO) = reg32; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 54 | reg32 = 0; |
| 55 | for (i = 0; i < 8; i++) |
| 56 | if (portmap[i].enabled && portmap[i].oc_pin >= 0) |
| 57 | reg32 |= (1 << (i + 8 * portmap[i].oc_pin)); |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 58 | RCBA32(USBOCM1) = reg32; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 59 | reg32 = 0; |
| 60 | for (i = 8; i < 14; i++) |
| 61 | if (portmap[i].enabled && portmap[i].oc_pin >= 4) |
| 62 | reg32 |= (1 << (i - 8 + 8 * (portmap[i].oc_pin - 4))); |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 63 | RCBA32(USBOCM2) = reg32; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 64 | for (i = 0; i < 22; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 65 | RCBA32(0x35a8 + 4 * i) = 0; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 66 | |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 67 | pci_write_config32(PCH_XHCI_DEV, 0xe4, 0x00000000); |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 68 | |
| 69 | /* Relock registers. */ |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 70 | write_pmbase16(UPRWC, 0); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 71 | } |