Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | ) |
| 7 | |
| 8 | type bd82x6x struct { |
| 9 | variant string |
| 10 | node *DevTreeNode |
| 11 | } |
| 12 | |
| 13 | func (b bd82x6x) writeGPIOSet(ctx Context, sb *os.File, |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 14 | val uint32, set uint, partno int, constraint uint32) { |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 15 | |
| 16 | max := uint(32) |
| 17 | if set == 3 { |
| 18 | max = 12 |
| 19 | } |
| 20 | |
| 21 | bits := [6][2]string{ |
| 22 | {"GPIO_MODE_NATIVE", "GPIO_MODE_GPIO"}, |
| 23 | {"GPIO_DIR_OUTPUT", "GPIO_DIR_INPUT"}, |
| 24 | {"GPIO_LEVEL_LOW", "GPIO_LEVEL_HIGH"}, |
| 25 | {"GPIO_RESET_PWROK", "GPIO_RESET_RSMRST"}, |
| 26 | {"GPIO_NO_INVERT", "GPIO_INVERT"}, |
| 27 | {"GPIO_NO_BLINK", "GPIO_BLINK"}, |
| 28 | } |
| 29 | |
| 30 | for i := uint(0); i < max; i++ { |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 31 | if ((constraint>>i)&1 == 1) { |
| 32 | fmt.Fprintf(sb, " .gpio%d = %s,\n", |
| 33 | (set-1)*32+i, |
| 34 | bits[partno][(val>>i)&1]) |
| 35 | } |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | |
| 39 | func (b bd82x6x) GPIO(ctx Context, inteltool InteltoolData) { |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 40 | var constraint uint32 |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 41 | gpio := Create(ctx, "gpio.c") |
| 42 | defer gpio.Close() |
| 43 | |
| 44 | AddROMStageFile("gpio.c", "") |
| 45 | |
Arthur Heymans | 5930285 | 2017-05-01 10:33:56 +0200 | [diff] [blame] | 46 | Add_gpl(gpio) |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 47 | gpio.WriteString("#include <southbridge/intel/common/gpio.h>\n\n") |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 48 | |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 49 | addresses := [3][6]int{ |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 50 | {0x00, 0x04, 0x0c, 0x60, 0x2c, 0x18}, |
| 51 | {0x30, 0x34, 0x38, 0x64, -1, -1}, |
| 52 | {0x40, 0x44, 0x48, 0x68, -1, -1}, |
| 53 | } |
| 54 | |
| 55 | for set := 1; set <= 3; set++ { |
| 56 | for partno, part := range []string{"mode", "direction", "level", "reset", "invert", "blink"} { |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 57 | addr := addresses[set-1][partno] |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 58 | if addr < 0 { |
| 59 | continue |
| 60 | } |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 61 | fmt.Fprintf(gpio, "static const struct pch_gpio_set%d pch_gpio_set%d_%s = {\n", |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 62 | set, set, part) |
| 63 | |
Arthur Heymans | 128205fd | 2017-05-01 09:40:43 +0200 | [diff] [blame] | 64 | constraint = 0xffffffff |
| 65 | switch part { |
| 66 | case "direction": |
| 67 | /* Ignored on native mode */ |
| 68 | constraint = inteltool.GPIO[uint16(addresses[set-1][0])] |
| 69 | case "level": |
| 70 | /* Level doesn't matter for input */ |
| 71 | constraint = inteltool.GPIO[uint16(addresses[set-1][0])] |
| 72 | constraint &^= inteltool.GPIO[uint16(addresses[set-1][1])] |
| 73 | case "reset": |
| 74 | /* Only show reset */ |
| 75 | constraint = inteltool.GPIO[uint16(addresses[set-1][3])] |
| 76 | case "invert": |
| 77 | /* Only on input and only show inverted GPIO */ |
| 78 | constraint = inteltool.GPIO[uint16(addresses[set-1][0])] |
| 79 | constraint &= inteltool.GPIO[uint16(addresses[set-1][1])] |
| 80 | constraint &= inteltool.GPIO[uint16(addresses[set-1][4])] |
| 81 | case "blink": |
| 82 | /* Only on output and only show blinking GPIO */ |
| 83 | constraint = inteltool.GPIO[uint16(addresses[set-1][0])] |
| 84 | constraint &^= inteltool.GPIO[uint16(addresses[set-1][1])] |
| 85 | constraint &= inteltool.GPIO[uint16(addresses[set-1][5])] |
| 86 | } |
| 87 | b.writeGPIOSet(ctx, gpio, inteltool.GPIO[uint16(addr)], uint(set), partno, constraint) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 88 | gpio.WriteString("};\n\n") |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | gpio.WriteString(`const struct pch_gpio_map mainboard_gpio_map = { |
| 93 | .set1 = { |
| 94 | .mode = &pch_gpio_set1_mode, |
| 95 | .direction = &pch_gpio_set1_direction, |
| 96 | .level = &pch_gpio_set1_level, |
| 97 | .blink = &pch_gpio_set1_blink, |
| 98 | .invert = &pch_gpio_set1_invert, |
| 99 | .reset = &pch_gpio_set1_reset, |
| 100 | }, |
| 101 | .set2 = { |
| 102 | .mode = &pch_gpio_set2_mode, |
| 103 | .direction = &pch_gpio_set2_direction, |
| 104 | .level = &pch_gpio_set2_level, |
| 105 | .reset = &pch_gpio_set2_reset, |
| 106 | }, |
| 107 | .set3 = { |
| 108 | .mode = &pch_gpio_set3_mode, |
| 109 | .direction = &pch_gpio_set3_direction, |
| 110 | .level = &pch_gpio_set3_level, |
| 111 | .reset = &pch_gpio_set3_reset, |
| 112 | }, |
| 113 | }; |
| 114 | `) |
| 115 | } |
| 116 | |
| 117 | func (b bd82x6x) IsPCIeHotplug(ctx Context, port int) bool { |
| 118 | portDev, ok := PCIMap[PCIAddr{Bus: 0, Dev: 0x1c, Func: port}] |
| 119 | if !ok { |
| 120 | return false |
| 121 | } |
| 122 | return (portDev.ConfigDump[0xdb] & (1 << 6)) != 0 |
| 123 | } |
| 124 | |
| 125 | func ich9GetFlashSize(ctx Context) { |
| 126 | inteltool := ctx.InfoSource.GetInteltool() |
| 127 | switch (inteltool.RCBA[0x3410] >> 10) & 3 { |
| 128 | /* SPI. All boards I've seen with sandy/ivy use SPI. */ |
| 129 | case 3: |
| 130 | ROMProtocol = "SPI" |
| 131 | highflkb := uint32(0) |
| 132 | for reg := uint16(0); reg < 5; reg++ { |
| 133 | fl := (inteltool.RCBA[0x3854+4*reg] >> 16) & 0x1fff |
Vladimir Serbinenko | 68f5f62 | 2015-05-29 21:43:42 +0200 | [diff] [blame] | 134 | flkb := (fl + 1) << 2 |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 135 | if flkb > highflkb { |
| 136 | highflkb = flkb |
| 137 | } |
| 138 | } |
| 139 | ROMSizeKB = int(highflkb) |
| 140 | /* Shared with ME. Flashrom is unable to handle it. */ |
| 141 | FlashROMSupport = "n" |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func (b bd82x6x) GetGPIOHeader() string { |
| 146 | return "southbridge/intel/bd82x6x/pch.h" |
| 147 | } |
| 148 | |
| 149 | func (b bd82x6x) EnableGPE(in int) { |
| 150 | b.node.Registers[fmt.Sprintf("gpi%d_routing", in)] = "2" |
| 151 | } |
| 152 | |
| 153 | func (b bd82x6x) EncodeGPE(in int) int { |
| 154 | return in + 0x10 |
| 155 | } |
| 156 | |
| 157 | func (b bd82x6x) DecodeGPE(in int) int { |
| 158 | return in - 0x10 |
| 159 | } |
| 160 | |
| 161 | func (b bd82x6x) NeedRouteGPIOManually() { |
| 162 | b.node.Comment += ", FIXME: set gpiX_routing for EC support" |
| 163 | } |
| 164 | |
| 165 | func (b bd82x6x) Scan(ctx Context, addr PCIDevData) { |
| 166 | |
| 167 | SouthBridge = &b |
| 168 | |
| 169 | inteltool := ctx.InfoSource.GetInteltool() |
| 170 | b.GPIO(ctx, inteltool) |
| 171 | |
| 172 | KconfigBool["SOUTHBRIDGE_INTEL_"+b.variant] = true |
| 173 | KconfigBool["SERIRQ_CONTINUOUS_MODE"] = true |
| 174 | KconfigInt["USBDEBUG_HCD_INDEX"] = 2 |
| 175 | KconfigComment["USBDEBUG_HCD_INDEX"] = "FIXME: check this" |
| 176 | dmi := ctx.InfoSource.GetDMI() |
| 177 | if dmi.Vendor == "LENOVO" { |
| 178 | KconfigInt["DRAM_RESET_GATE_GPIO"] = 10 |
| 179 | } else { |
| 180 | KconfigInt["DRAM_RESET_GATE_GPIO"] = 60 |
| 181 | } |
| 182 | KconfigComment["DRAM_RESET_GATE_GPIO"] = "FIXME: check this" |
| 183 | |
| 184 | /* Not strictly speaking correct. These subsys/subvendor referer to PCI devices. |
| 185 | But most systems don't have any of those. But the config needs to be set |
| 186 | nevertheless. So set it to southbridge subsys/subvendor. */ |
| 187 | KconfigHex["MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID"] = uint32(GetLE16(addr.ConfigDump[0x2c:0x2e])) |
| 188 | KconfigHex["MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID"] = uint32(GetLE16(addr.ConfigDump[0x2e:0x30])) |
| 189 | |
| 190 | ich9GetFlashSize(ctx) |
| 191 | |
| 192 | DSDTDefines = append(DSDTDefines, |
| 193 | DSDTDefine{ |
| 194 | Key: "BRIGHTNESS_UP", |
| 195 | Value: "\\_SB.PCI0.GFX0.INCB", |
| 196 | }, |
| 197 | DSDTDefine{ |
| 198 | Key: "BRIGHTNESS_DOWN", |
| 199 | Value: "\\_SB.PCI0.GFX0.DECB", |
| 200 | }, |
| 201 | DSDTDefine{ |
| 202 | Key: "ACPI_VIDEO_DEVICE", |
| 203 | Value: "\\_SB.PCI0.GFX0", |
| 204 | }) |
| 205 | |
| 206 | /* SPI init */ |
| 207 | MainboardIncludes = append(MainboardIncludes, "southbridge/intel/bd82x6x/pch.h") |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 208 | |
| 209 | FADT := ctx.InfoSource.GetACPI()["FACP"] |
| 210 | |
| 211 | pcieHotplugMap := "{ " |
| 212 | |
| 213 | for port := 0; port < 7; port++ { |
| 214 | if b.IsPCIeHotplug(ctx, port) { |
| 215 | pcieHotplugMap += "1, " |
| 216 | } else { |
| 217 | pcieHotplugMap += "0, " |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | if b.IsPCIeHotplug(ctx, 7) { |
| 222 | pcieHotplugMap += "1 }" |
| 223 | } else { |
| 224 | pcieHotplugMap += "0 }" |
| 225 | } |
| 226 | |
| 227 | cur := DevTreeNode{ |
| 228 | Chip: "southbridge/intel/bd82x6x", |
| 229 | Comment: "Intel Series 6 Cougar Point PCH", |
| 230 | |
| 231 | Registers: map[string]string{ |
| 232 | "sata_interface_speed_support": "0x3", |
| 233 | "gen1_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x84:0x88]), |
| 234 | "gen2_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x88:0x8c]), |
| 235 | "gen3_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x8c:0x90]), |
| 236 | "gen4_dec": FormatHexLE32(PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 0}].ConfigDump[0x90:0x94]), |
| 237 | "pcie_port_coalesce": "1", |
| 238 | "pcie_hotplug_map": pcieHotplugMap, |
| 239 | |
| 240 | "sata_port_map": fmt.Sprintf("0x%x", PCIMap[PCIAddr{Bus: 0, Dev: 0x1f, Func: 2}].ConfigDump[0x92]&0x3f), |
| 241 | |
| 242 | "p_cnt_throttling_supported": (FormatBool(FADT[104] == 1 && FADT[105] == 3)), |
| 243 | "c2_latency": FormatHexLE16(FADT[96:98]), |
| 244 | "docking_supported": (FormatBool((FADT[113] & (1 << 1)) != 0)), |
Iru Cai | 68c7118 | 2017-07-07 13:49:08 +0800 | [diff] [blame] | 245 | "spi_uvscc": fmt.Sprintf("0x%x", inteltool.RCBA[0x38c8]), |
| 246 | "spi_lvscc": fmt.Sprintf("0x%x", inteltool.RCBA[0x38c4] &^ (1 << 23)), |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 247 | }, |
| 248 | PCISlots: []PCISlot{ |
| 249 | PCISlot{PCIAddr: PCIAddr{Dev: 0x14, Func: 0}, writeEmpty: false, additionalComment: "USB 3.0 Controller"}, |
| 250 | PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 0}, writeEmpty: true, additionalComment: "Management Engine Interface 1"}, |
| 251 | PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 1}, writeEmpty: true, additionalComment: "Management Engine Interface 2"}, |
| 252 | PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 2}, writeEmpty: true, additionalComment: "Management Engine IDE-R"}, |
| 253 | PCISlot{PCIAddr: PCIAddr{Dev: 0x16, Func: 3}, writeEmpty: true, additionalComment: "Management Engine KT"}, |
| 254 | PCISlot{PCIAddr: PCIAddr{Dev: 0x19, Func: 0}, writeEmpty: true, additionalComment: "Intel Gigabit Ethernet"}, |
| 255 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1a, Func: 0}, writeEmpty: true, additionalComment: "USB2 EHCI #2"}, |
| 256 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1b, Func: 0}, writeEmpty: true, additionalComment: "High Definition Audio"}, |
| 257 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 0}, writeEmpty: true, additionalComment: "PCIe Port #1"}, |
| 258 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 1}, writeEmpty: true, additionalComment: "PCIe Port #2"}, |
| 259 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 2}, writeEmpty: true, additionalComment: "PCIe Port #3"}, |
| 260 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 3}, writeEmpty: true, additionalComment: "PCIe Port #4"}, |
| 261 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 4}, writeEmpty: true, additionalComment: "PCIe Port #5"}, |
| 262 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 5}, writeEmpty: true, additionalComment: "PCIe Port #6"}, |
| 263 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 6}, writeEmpty: true, additionalComment: "PCIe Port #7"}, |
| 264 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1c, Func: 7}, writeEmpty: true, additionalComment: "PCIe Port #8"}, |
| 265 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1d, Func: 0}, writeEmpty: true, additionalComment: "USB2 EHCI #1"}, |
| 266 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1e, Func: 0}, writeEmpty: true, additionalComment: "PCI bridge"}, |
| 267 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 0}, writeEmpty: true, additionalComment: "LPC bridge"}, |
| 268 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 2}, writeEmpty: true, additionalComment: "SATA Controller 1"}, |
| 269 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 3}, writeEmpty: true, additionalComment: "SMBus"}, |
| 270 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 5}, writeEmpty: true, additionalComment: "SATA Controller 2"}, |
| 271 | PCISlot{PCIAddr: PCIAddr{Dev: 0x1f, Func: 6}, writeEmpty: true, additionalComment: "Thermal"}, |
| 272 | }, |
| 273 | } |
| 274 | |
| 275 | b.node = &cur |
| 276 | |
| 277 | xhciDev, ok := PCIMap[PCIAddr{Bus: 0, Dev: 0x14, Func: 0}] |
| 278 | |
| 279 | if ok { |
| 280 | cur.Registers["xhci_switchable_ports"] = FormatHexLE32(xhciDev.ConfigDump[0xd4:0xd8]) |
| 281 | cur.Registers["superspeed_capable_ports"] = FormatHexLE32(xhciDev.ConfigDump[0xdc:0xe0]) |
| 282 | cur.Registers["xhci_overcurrent_mapping"] = FormatHexLE32(xhciDev.ConfigDump[0xc0:0xc4]) |
| 283 | } |
| 284 | |
| 285 | PutPCIChip(addr, cur) |
| 286 | PutPCIDevParent(addr, "PCI-LPC bridge", "lpc") |
| 287 | |
| 288 | DSDTIncludes = append(DSDTIncludes, DSDTInclude{ |
| 289 | File: "southbridge/intel/bd82x6x/acpi/platform.asl", |
| 290 | }) |
| 291 | DSDTIncludes = append(DSDTIncludes, DSDTInclude{ |
| 292 | File: "southbridge/intel/bd82x6x/acpi/globalnvs.asl", |
| 293 | Comment: "global NVS and variables", |
| 294 | }) |
| 295 | DSDTIncludes = append(DSDTIncludes, DSDTInclude{ |
| 296 | File: "southbridge/intel/bd82x6x/acpi/sleepstates.asl", |
| 297 | }) |
| 298 | DSDTPCI0Includes = append(DSDTPCI0Includes, DSDTInclude{ |
| 299 | File: "southbridge/intel/bd82x6x/acpi/pch.asl", |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 300 | }) |
| 301 | |
| 302 | sb := Create(ctx, "early_southbridge.c") |
| 303 | defer sb.Close() |
| 304 | AddROMStageFile("early_southbridge.c", "") |
Arthur Heymans | 5930285 | 2017-05-01 10:33:56 +0200 | [diff] [blame] | 305 | Add_gpl(sb) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 306 | sb.WriteString(`#include <stdint.h> |
| 307 | #include <string.h> |
| 308 | #include <lib.h> |
| 309 | #include <timestamp.h> |
| 310 | #include <arch/byteorder.h> |
| 311 | #include <arch/io.h> |
| 312 | #include <device/pci_def.h> |
| 313 | #include <device/pnp_def.h> |
| 314 | #include <cpu/x86/lapic.h> |
| 315 | #include <arch/acpi.h> |
| 316 | #include <console/console.h> |
| 317 | #include "northbridge/intel/sandybridge/sandybridge.h" |
| 318 | #include "northbridge/intel/sandybridge/raminit_native.h" |
| 319 | #include "southbridge/intel/bd82x6x/pch.h" |
Stefan Reinauer | eb960f1 | 2016-02-17 16:34:02 -0800 | [diff] [blame] | 320 | #include <southbridge/intel/common/gpio.h> |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 321 | #include <arch/cpu.h> |
| 322 | #include <cpu/x86/msr.h> |
| 323 | |
| 324 | void pch_enable_lpc(void) |
| 325 | { |
| 326 | `) |
| 327 | RestorePCI16Simple(sb, addr, 0x82) |
| 328 | RestorePCI32Simple(sb, addr, 0x84) |
| 329 | RestorePCI32Simple(sb, addr, 0x88) |
| 330 | RestorePCI32Simple(sb, addr, 0x8c) |
| 331 | RestorePCI32Simple(sb, addr, 0x90) |
| 332 | |
| 333 | RestorePCI16Simple(sb, addr, 0x80) |
| 334 | |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 335 | sb.WriteString(`} |
| 336 | |
Arthur Heymans | c32e6cb | 2018-01-29 10:51:45 +0100 | [diff] [blame] | 337 | void mainboard_rcba_config(void) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 338 | { |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 339 | `) |
Arthur Heymans | c32e6cb | 2018-01-29 10:51:45 +0100 | [diff] [blame] | 340 | sb.WriteString("}\n\n") |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 341 | |
| 342 | sb.WriteString("const struct southbridge_usb_port mainboard_usb_ports[] = {\n") |
| 343 | |
| 344 | currentMap := map[uint32]int{ |
| 345 | 0x20000153: 0, |
| 346 | 0x20000f57: 1, |
| 347 | 0x2000055b: 2, |
| 348 | 0x20000f51: 3, |
| 349 | 0x2000094a: 4, |
| 350 | } |
| 351 | |
| 352 | for port := uint(0); port < 14; port++ { |
| 353 | var pinmask uint32 |
| 354 | OCPin := -1 |
| 355 | if port < 8 { |
| 356 | pinmask = inteltool.RCBA[0x35a0] |
| 357 | } else { |
| 358 | pinmask = inteltool.RCBA[0x35a4] |
| 359 | } |
| 360 | for pin := uint(0); pin < 4; pin++ { |
| 361 | if ((pinmask >> ((port % 8) + 8*pin)) & 1) != 0 { |
| 362 | OCPin = int(pin) |
| 363 | if port >= 8 { |
| 364 | OCPin += 4 |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | fmt.Fprintf(sb, "\t{ %d, %d, %d },\n", |
| 369 | ((inteltool.RCBA[0x359c]>>port)&1)^1, |
| 370 | currentMap[inteltool.RCBA[uint16(0x3500+4*port)]], |
| 371 | OCPin) |
| 372 | } |
| 373 | sb.WriteString("};\n") |
| 374 | |
| 375 | guessedMap := GuessSPDMap(ctx) |
| 376 | |
| 377 | sb.WriteString(` |
Vladimir Serbinenko | 609bd94 | 2016-01-31 14:00:54 +0100 | [diff] [blame] | 378 | void mainboard_early_init(int s3resume) |
| 379 | { |
| 380 | } |
| 381 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 382 | void mainboard_config_superio(void) |
| 383 | { |
| 384 | } |
| 385 | |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 386 | /* FIXME: Put proper SPD map here. */ |
Kyösti Mälkki | 4015608 | 2016-12-04 11:17:07 +0200 | [diff] [blame] | 387 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 388 | { |
| 389 | `) |
| 390 | for i, spd := range guessedMap { |
Kyösti Mälkki | 4015608 | 2016-12-04 11:17:07 +0200 | [diff] [blame] | 391 | fmt.Fprintf(sb, "\tread_spd(&spd[%d], 0x%02x, id_only);\n", i, spd) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 392 | } |
| 393 | sb.WriteString("}\n") |
| 394 | |
| 395 | gnvs := Create(ctx, "gnvs.c") |
| 396 | defer gnvs.Close() |
| 397 | |
Arthur Heymans | 5930285 | 2017-05-01 10:33:56 +0200 | [diff] [blame] | 398 | Add_gpl(gnvs) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 399 | gnvs.WriteString(`#include <southbridge/intel/bd82x6x/nvs.h> |
| 400 | |
| 401 | /* FIXME: check this function. */ |
| 402 | void acpi_create_gnvs(global_nvs_t *gnvs) |
| 403 | { |
| 404 | /* Disable USB ports in S3 by default */ |
| 405 | gnvs->s3u0 = 0; |
| 406 | gnvs->s3u1 = 0; |
| 407 | |
| 408 | /* Disable USB ports in S5 by default */ |
| 409 | gnvs->s5u0 = 0; |
| 410 | gnvs->s5u1 = 0; |
| 411 | |
| 412 | // the lid is open by default. |
| 413 | gnvs->lids = 1; |
| 414 | |
| 415 | gnvs->tcrt = 100; |
| 416 | gnvs->tpsv = 90; |
| 417 | } |
| 418 | `) |
| 419 | |
| 420 | AddRAMStageFile("gnvs.c", "") |
| 421 | } |
| 422 | |
| 423 | func init() { |
| 424 | /* BD82X6X LPC */ |
Vladimir Serbinenko | 42d55e0 | 2016-01-02 01:47:26 +0100 | [diff] [blame] | 425 | for id := 0x1c40; id <= 0x1c5f; id++ { |
Vladimir Serbinenko | 6b2d83c | 2016-01-11 18:43:25 +0100 | [diff] [blame] | 426 | RegisterPCI(0x8086, uint16(id), bd82x6x{variant: "BD82X6X"}) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | /* C216 LPC */ |
Vladimir Serbinenko | 42d55e0 | 2016-01-02 01:47:26 +0100 | [diff] [blame] | 430 | for id := 0x1e41; id <= 0x1e5f; id++ { |
Vladimir Serbinenko | 6b2d83c | 2016-01-11 18:43:25 +0100 | [diff] [blame] | 431 | RegisterPCI(0x8086, uint16(id), bd82x6x{variant: "C216"}) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | /* PCIe bridge */ |
| 435 | for _, id := range []uint16{ |
Dan Elkouby | 3781e1f | 2018-03-24 21:15:08 +0300 | [diff] [blame^] | 436 | 0x0151, 0x0155, 0x1c10, 0x1c12, |
| 437 | 0x1c14, 0x1c16, 0x1c18, 0x1c1a, |
| 438 | 0x1c1c, 0x1c1e, 0x1e10, 0x1e12, |
| 439 | 0x1e14, 0x1e16, 0x1e18, 0x1e1a, |
| 440 | 0x1e1c, 0x1e1e, 0x1e25, 0x244e, |
| 441 | 0x2448, |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 442 | } { |
| 443 | RegisterPCI(0x8086, id, GenericPCI{}) |
| 444 | } |
| 445 | |
| 446 | /* SMBus controller */ |
| 447 | RegisterPCI(0x8086, 0x1c22, GenericPCI{MissingParent: "smbus"}) |
| 448 | RegisterPCI(0x8086, 0x1e22, GenericPCI{MissingParent: "smbus"}) |
| 449 | |
| 450 | /* SATA */ |
| 451 | for _, id := range []uint16{ |
| 452 | 0x1c00, 0x1c01, 0x1c02, 0x1c03, |
| 453 | 0x1e00, 0x1e01, 0x1e02, 0x1e03, |
| 454 | } { |
| 455 | RegisterPCI(0x8086, id, GenericPCI{}) |
| 456 | } |
| 457 | |
| 458 | /* EHCI */ |
| 459 | for _, id := range []uint16{ |
| 460 | 0x1c26, 0x1c2d, 0x1e26, 0x1e2d, |
| 461 | } { |
| 462 | RegisterPCI(0x8086, id, GenericPCI{}) |
| 463 | } |
| 464 | |
| 465 | /* XHCI */ |
| 466 | RegisterPCI(0x8086, 0x1e31, GenericPCI{}) |
| 467 | |
| 468 | /* ME and children */ |
| 469 | for _, id := range []uint16{ |
| 470 | 0x1c3a, 0x1c3b, 0x1c3c, 0x1c3d, |
| 471 | 0x1e3a, 0x1e3b, 0x1e3c, 0x1e3d, |
| 472 | } { |
| 473 | RegisterPCI(0x8086, id, GenericPCI{}) |
| 474 | } |
| 475 | |
| 476 | /* Ethernet */ |
| 477 | RegisterPCI(0x8086, 0x1502, GenericPCI{}) |
Dan Elkouby | 3781e1f | 2018-03-24 21:15:08 +0300 | [diff] [blame^] | 478 | RegisterPCI(0x8086, 0x1503, GenericPCI{}) |
Vladimir Serbinenko | 3129f79 | 2014-10-15 21:51:47 +0200 | [diff] [blame] | 479 | |
| 480 | } |