Angel Pons | 60ec365 | 2020-04-03 01:22:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 2 | |
Arthur Heymans | fa5d0f8 | 2019-11-12 19:11:50 +0100 | [diff] [blame] | 3 | #include <bootblock_common.h> |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 5 | #include <arch/io.h> |
Kyösti Mälkki | 2a3f9f5 | 2019-08-26 13:59:54 +0300 | [diff] [blame] | 6 | #include <superio/smsc/sio1007/sio1007.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 7 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 8 | #include <northbridge/intel/sandybridge/raminit.h> |
Vladimir Serbinenko | cf0e902 | 2016-02-10 03:09:46 +0100 | [diff] [blame] | 9 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 10 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 11 | #include <southbridge/intel/common/gpio.h> |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 12 | |
Marc Jones | c4b6f3b | 2013-11-05 17:47:37 -0700 | [diff] [blame] | 13 | #define SIO_PORT 0x164e |
| 14 | |
Arthur Heymans | fa5d0f8 | 2019-11-12 19:11:50 +0100 | [diff] [blame] | 15 | void bootblock_mainboard_early_init(void) |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 16 | { |
Marc Jones | c4b6f3b | 2013-11-05 17:47:37 -0700 | [diff] [blame] | 17 | const u16 port = SIO_PORT; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 18 | const u16 runtime_port = 0x180; |
| 19 | |
Nico Huber | 052e3ef | 2019-11-17 01:35:14 +0100 | [diff] [blame] | 20 | sio1007_enable_uart_at(port); |
| 21 | |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 22 | /* Turn on configuration mode. */ |
| 23 | outb(0x55, port); |
| 24 | |
| 25 | /* Set the GPIO direction, polarity, and type. */ |
| 26 | sio1007_setreg(port, 0x31, 1 << 0, 1 << 0); |
| 27 | sio1007_setreg(port, 0x32, 0 << 0, 1 << 0); |
| 28 | sio1007_setreg(port, 0x33, 0 << 0, 1 << 0); |
| 29 | |
| 30 | /* Set the base address for the runtime register block. */ |
| 31 | sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff); |
| 32 | sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff); |
| 33 | |
| 34 | /* Turn on address decoding for it. */ |
| 35 | sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1); |
| 36 | |
| 37 | /* Set the value of GPIO 10 by changing GP1, bit 0. */ |
| 38 | u8 byte; |
| 39 | byte = inb(runtime_port + 0xc); |
| 40 | byte |= (1 << 0); |
| 41 | outb(byte, runtime_port + 0xc); |
| 42 | |
| 43 | /* Turn off address decoding for it. */ |
| 44 | sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1); |
| 45 | |
| 46 | /* Turn off configuration mode. */ |
| 47 | outb(0xaa, port); |
| 48 | } |
| 49 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 50 | void mainboard_fill_pei_data(struct pei_data *pei_data) |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 51 | { |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 52 | struct pei_data pei_data_template = { |
Edward O'Callaghan | ea4ae2f | 2014-05-24 02:08:04 +1000 | [diff] [blame] | 53 | .pei_version = PEI_VERSION, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 54 | .mchbar = (uintptr_t)DEFAULT_MCHBAR, |
| 55 | .dmibar = (uintptr_t)DEFAULT_DMIBAR, |
Edward O'Callaghan | ea4ae2f | 2014-05-24 02:08:04 +1000 | [diff] [blame] | 56 | .epbar = DEFAULT_EPBAR, |
| 57 | .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, |
Angel Pons | b21bffa | 2020-07-03 01:02:28 +0200 | [diff] [blame^] | 58 | .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE, |
Edward O'Callaghan | ea4ae2f | 2014-05-24 02:08:04 +1000 | [diff] [blame] | 59 | .wdbbar = 0x4000000, |
| 60 | .wdbsize = 0x1000, |
| 61 | .hpet_address = CONFIG_HPET_ADDRESS, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 62 | .rcba = (uintptr_t)DEFAULT_RCBABASE, |
Edward O'Callaghan | ea4ae2f | 2014-05-24 02:08:04 +1000 | [diff] [blame] | 63 | .pmbase = DEFAULT_PMBASE, |
| 64 | .gpiobase = DEFAULT_GPIOBASE, |
| 65 | .thermalbase = 0xfed08000, |
| 66 | .system_type = 0, // 0 Mobile, 1 Desktop/Server |
| 67 | .tseg_size = CONFIG_SMM_TSEG_SIZE, |
| 68 | .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 }, |
| 69 | .ts_addresses = { 0x00, 0x00, 0x00, 0x00 }, |
| 70 | .ec_present = 0, |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 71 | // 0 = leave channel enabled |
| 72 | // 1 = disable dimm 0 on channel |
| 73 | // 2 = disable dimm 1 on channel |
| 74 | // 3 = disable dimm 0+1 on channel |
Edward O'Callaghan | ea4ae2f | 2014-05-24 02:08:04 +1000 | [diff] [blame] | 75 | .dimm_channel0_disabled = 2, |
| 76 | .dimm_channel1_disabled = 2, |
| 77 | .max_ddr3_freq = 1600, |
| 78 | .usb_port_config = { |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 79 | { 1, 0, 0x0040 }, /* P0: Front port (OC0) */ |
| 80 | { 1, 1, 0x0040 }, /* P1: Back port (OC1) */ |
| 81 | { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */ |
| 82 | { 1, 0, 0x0040 }, /* P3: MMC (no OC) */ |
| 83 | { 1, 2, 0x0040 }, /* P4: Front port (OC2) */ |
| 84 | { 0, 0, 0x0000 }, /* P5: Empty */ |
| 85 | { 0, 0, 0x0000 }, /* P6: Empty */ |
| 86 | { 0, 0, 0x0000 }, /* P7: Empty */ |
| 87 | { 1, 4, 0x0040 }, /* P8: Back port (OC4) */ |
| 88 | { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */ |
| 89 | { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */ |
| 90 | { 0, 4, 0x0000 }, /* P11: Empty */ |
| 91 | { 1, 6, 0x0040 }, /* P12: Back port (OC6) */ |
| 92 | { 1, 5, 0x0040 }, /* P13: Back port (OC5) */ |
| 93 | }, |
| 94 | }; |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 95 | *pei_data = pei_data_template; |
| 96 | } |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 97 | |
Vladimir Serbinenko | cf0e902 | 2016-02-10 03:09:46 +0100 | [diff] [blame] | 98 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
Elyes HAOUAS | 44f558e | 2020-02-24 13:26:04 +0100 | [diff] [blame] | 99 | /* enabled power USB oc pin */ |
Vladimir Serbinenko | cf0e902 | 2016-02-10 03:09:46 +0100 | [diff] [blame] | 100 | { 1, 0, 0 }, /* P0: Front port (OC0) */ |
| 101 | { 1, 0, 1 }, /* P1: Back port (OC1) */ |
| 102 | { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */ |
| 103 | { 1, 0, -1 }, /* P3: MMC (no OC) */ |
| 104 | { 1, 0, 2 }, /* P4: Front port (OC2) */ |
| 105 | { 0, 0, -1 }, /* P5: Empty */ |
| 106 | { 0, 0, -1 }, /* P6: Empty */ |
| 107 | { 0, 0, -1 }, /* P7: Empty */ |
| 108 | { 1, 0, 4 }, /* P8: Back port (OC4) */ |
| 109 | { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */ |
| 110 | { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */ |
| 111 | { 0, 0, -1 }, /* P11: Empty */ |
| 112 | { 1, 0, 6 }, /* P12: Back port (OC6) */ |
| 113 | { 1, 0, 5 }, /* P13: Back port (OC5) */ |
| 114 | }; |
| 115 | |
Peter Lemenkov | 498f1cc | 2019-02-07 10:48:10 +0100 | [diff] [blame] | 116 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
| 117 | { |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 118 | read_spd(&spd[0], 0x50, id_only); |
| 119 | read_spd(&spd[2], 0x52, id_only); |
Vladimir Serbinenko | cf0e902 | 2016-02-10 03:09:46 +0100 | [diff] [blame] | 120 | } |
| 121 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 122 | int mainboard_should_reset_usb(int s3resume) |
| 123 | { |
| 124 | return !s3resume; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 125 | } |