Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 2 | |
Patrick Rudolph | c943d6f | 2023-10-29 19:51:17 +0100 | [diff] [blame] | 3 | #include <console/console.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 4 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 6 | #include <device/pci_def.h> |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 7 | #include <southbridge/intel/common/rcba.h> |
| 8 | #include <southbridge/intel/common/pmbase.h> |
| 9 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 10 | #include "pch.h" |
| 11 | |
Elyes HAOUAS | f385e9d | 2018-11-01 19:13:08 +0100 | [diff] [blame] | 12 | void early_usb_init(const struct southbridge_usb_port *portmap) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 13 | { |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 14 | u32 reg32; |
| 15 | const u32 rcba_dump[8] = { |
| 16 | /* 3560 */ 0x024c8001, 0x000024a3, 0x00040002, 0x01000050, |
| 17 | /* 3570 */ 0x02000772, 0x16000f9f, 0x1800ff4f, 0x0001d630, |
| 18 | }; |
Patrick Rudolph | a48debd | 2023-10-31 16:50:05 +0100 | [diff] [blame] | 19 | const u32 currents[] = { USBIR_TXRX_GAIN_MOBILE_LOW, USBIR_TXRX_GAIN_DEFAULT, |
| 20 | USBIR_TXRX_GAIN_HIGH, 0x20000f51, 0x2000094a, 0x2000035f, |
| 21 | USBIR_TXRX_GAIN_DESKTOP_LOW, 0x20000357, 0x20000353 }; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 22 | int i; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 23 | |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 24 | /* Unlock registers. */ |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 25 | write_pmbase16(UPRWC, read_pmbase16(UPRWC) | UPRWC_WR_EN); |
Patrick Rudolph | 87b5ff0 | 2017-05-28 13:57:04 +0200 | [diff] [blame] | 26 | |
Patrick Rudolph | c943d6f | 2023-10-29 19:51:17 +0100 | [diff] [blame] | 27 | for (i = 0; i < 14; i++) { |
Patrick Rudolph | a48debd | 2023-10-31 16:50:05 +0100 | [diff] [blame] | 28 | if (portmap[i].enabled && !pch_is_mobile() && |
| 29 | currents[portmap[i].current] == USBIR_TXRX_GAIN_MOBILE_LOW) { |
Patrick Rudolph | c943d6f | 2023-10-29 19:51:17 +0100 | [diff] [blame] | 30 | /* |
| 31 | * Note for developers: You can fix this by re-running autoport on |
| 32 | * vendor firmware and then updating portmap currents accordingly. |
| 33 | * If that is not possible, another option is to choose a non-zero |
| 34 | * current setting. In either case, please test all the USB ports. |
| 35 | */ |
Patrick Rudolph | a48debd | 2023-10-31 16:50:05 +0100 | [diff] [blame] | 36 | printk(BIOS_ERR, "%s: USB%02d: USBIR_TXRX_GAIN_MOBILE_LOW is an invalid setting for desktop!\n", |
Patrick Rudolph | c943d6f | 2023-10-29 19:51:17 +0100 | [diff] [blame] | 37 | __func__, i); |
| 38 | |
Patrick Rudolph | a48debd | 2023-10-31 16:50:05 +0100 | [diff] [blame] | 39 | RCBA32(USBIR0 + 4 * i) = USBIR_TXRX_GAIN_DEFAULT; |
Patrick Rudolph | c943d6f | 2023-10-29 19:51:17 +0100 | [diff] [blame] | 40 | } else { |
| 41 | RCBA32(USBIR0 + 4 * i) = currents[portmap[i].current]; |
| 42 | } |
| 43 | } |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 44 | for (i = 0; i < 10; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 45 | RCBA32(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++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 48 | RCBA32(0x3560 + 4 * i) = rcba_dump[i]; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 49 | for (i = 0; i < 8; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 50 | RCBA32(0x3580 + 4 * i) = 0; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 51 | reg32 = 0; |
| 52 | for (i = 0; i < 14; i++) |
| 53 | if (!portmap[i].enabled) |
| 54 | reg32 |= (1 << i); |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 55 | RCBA32(USBPDO) = reg32; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 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)); |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 60 | RCBA32(USBOCM1) = reg32; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 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))); |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 65 | RCBA32(USBOCM2) = reg32; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 66 | for (i = 0; i < 22; i++) |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 67 | RCBA32(0x35a8 + 4 * i) = 0; |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 68 | |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 69 | pci_write_config32(PCH_XHCI_DEV, 0xe4, 0x00000000); |
Alexandru Gagniuc | ecf2eb4 | 2015-09-28 21:39:12 -0700 | [diff] [blame] | 70 | |
| 71 | /* Relock registers. */ |
Patrick Rudolph | 72a9091 | 2019-03-24 17:35:55 +0100 | [diff] [blame] | 72 | write_pmbase16(UPRWC, 0); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 73 | } |