haswell.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package main
  2. import "fmt"
  3. type haswellmc struct {
  4. variant string
  5. }
  6. func divceil(a uint32, b uint32) uint32 {
  7. return (a + b - 1) / b
  8. }
  9. func getPanelCfg(inteltool InteltoolData, isULT bool) string {
  10. var refclk uint32
  11. var pwm_hz uint32
  12. if isULT {
  13. refclk = 24000000
  14. } else {
  15. refclk = 135000000
  16. }
  17. if (inteltool.IGD[0xc8254] >> 16) != 0 {
  18. pwm_hz = refclk / 128 / (inteltool.IGD[0xc8254] >> 16)
  19. } else {
  20. pwm_hz = 0
  21. }
  22. gpu_panel_power_up_delay := (inteltool.IGD[0xc7208] >> 16) & 0x1fff
  23. gpu_panel_power_backlight_on_delay := inteltool.IGD[0xc7208] & 0x1fff
  24. gpu_panel_power_down_delay := (inteltool.IGD[0xc720c] >> 16) & 0x1fff
  25. gpu_panel_power_backlight_off_delay := inteltool.IGD[0xc720c] & 0x1fff
  26. gpu_panel_power_cycle_delay := inteltool.IGD[0xc7210] & 0x1f
  27. return fmt.Sprintf(`{
  28. .up_delay_ms = %3d,
  29. .down_delay_ms = %3d,
  30. .cycle_delay_ms = %3d,
  31. .backlight_on_delay_ms = %3d,
  32. .backlight_off_delay_ms = %3d,
  33. .backlight_pwm_hz = %3d,
  34. }`,
  35. divceil(gpu_panel_power_up_delay, 10),
  36. divceil(gpu_panel_power_down_delay, 10),
  37. (gpu_panel_power_cycle_delay-1)*100,
  38. divceil(gpu_panel_power_backlight_on_delay, 10),
  39. divceil(gpu_panel_power_backlight_off_delay, 10),
  40. pwm_hz)
  41. }
  42. func (i haswellmc) Scan(ctx Context, addr PCIDevData) {
  43. inteltool := ctx.InfoSource.GetInteltool()
  44. isULT := (i.variant == "ULT")
  45. DevTree = DevTreeNode{
  46. Chip: "northbridge/intel/haswell",
  47. MissingParent: "northbridge",
  48. Comment: "FIXME: check ec_present, usb_xhci_on_resume, gfx",
  49. Registers: map[string]string{
  50. "gpu_dp_b_hotplug": FormatInt32((inteltool.IGD[0xc4030] >> 2) & 7),
  51. "gpu_dp_c_hotplug": FormatInt32((inteltool.IGD[0xc4030] >> 10) & 7),
  52. "gpu_dp_d_hotplug": FormatInt32((inteltool.IGD[0xc4030] >> 18) & 7),
  53. "panel_cfg": getPanelCfg(inteltool, isULT),
  54. "gpu_ddi_e_connected": FormatBool(((inteltool.IGD[0x64000] >> 4) & 1) == 0),
  55. "ec_present": "false",
  56. "usb_xhci_on_resume": "false",
  57. /* FIXME:XX hardcoded. */
  58. "gfx": "GMA_STATIC_DISPLAYS(0)",
  59. },
  60. Children: []DevTreeNode{
  61. {
  62. Chip: "cpu/intel/haswell",
  63. Children: []DevTreeNode{
  64. {
  65. Chip: "cpu_cluster",
  66. Dev: 0,
  67. Ops: "haswell_cpu_bus_ops",
  68. },
  69. },
  70. },
  71. {
  72. Chip: "domain",
  73. Dev: 0,
  74. Ops: "haswell_pci_domain_ops",
  75. PCIController: true,
  76. ChildPCIBus: 0,
  77. PCISlots: []PCISlot{
  78. PCISlot{PCIAddr: PCIAddr{Dev: 0x0, Func: 0}, writeEmpty: true, additionalComment: i.variant},
  79. PCISlot{PCIAddr: PCIAddr{Dev: 0x1, Func: 0}, writeEmpty: !isULT, additionalComment: "PCIe Bridge for discrete graphics"},
  80. PCISlot{PCIAddr: PCIAddr{Dev: 0x2, Func: 0}, writeEmpty: true, additionalComment: "Internal graphics"},
  81. PCISlot{PCIAddr: PCIAddr{Dev: 0x3, Func: 0}, writeEmpty: true, additionalComment: "Mini-HD audio"},
  82. },
  83. },
  84. },
  85. }
  86. if isULT {
  87. DevTree.Registers["dq_pins_interleaved"] = FormatBool(((inteltool.MCHBAR[0x2008] >> 10) & 1) == 0)
  88. }
  89. PutPCIDev(addr, "Host bridge")
  90. KconfigBool["NORTHBRIDGE_INTEL_HASWELL"] = true
  91. KconfigBool["HAVE_ACPI_TABLES"] = true
  92. KconfigBool["HAVE_ACPI_RESUME"] = true
  93. DSDTIncludes = append(DSDTIncludes, DSDTInclude{
  94. File: "cpu/intel/common/acpi/cpu.asl",
  95. })
  96. DSDTPCI0Includes = append(DSDTPCI0Includes, DSDTInclude{
  97. File: "northbridge/intel/haswell/acpi/hostbridge.asl",
  98. }, DSDTInclude{
  99. File: "drivers/intel/gma/acpi/default_brightness_levels.asl",
  100. Comment: "FIXME: remove this if the board doesn't have backlight",
  101. })
  102. }
  103. func init() {
  104. RegisterPCI(0x8086, 0x0c00, haswellmc{variant: "Desktop"})
  105. RegisterPCI(0x8086, 0x0c04, haswellmc{variant: "Mobile"})
  106. RegisterPCI(0x8086, 0x0a04, haswellmc{variant: "ULT"})
  107. RegisterPCI(0x8086, 0x0c08, haswellmc{variant: "Server"})
  108. RegisterPCI(0x8086, 0x0d00, haswellmc{variant: "Crystal Well Desktop"})
  109. RegisterPCI(0x8086, 0x0d04, haswellmc{variant: "Crystal Well Mobile"})
  110. RegisterPCI(0x8086, 0x0d08, haswellmc{variant: "Crystal Well Server"})
  111. for _, id := range []uint16{
  112. 0x0402, 0x0412, 0x0422, /* Desktop */
  113. 0x0406, 0x0416, 0x0426, /* Mobile */
  114. 0x040a, 0x041a, 0x042a, /* Server */
  115. 0x0a06, 0x0a16, 0x0a26, /* ULT */
  116. 0x0d16, 0x0d22, 0x0d26, 0x0d36, /* Mobile 4+3, GT3e */
  117. } {
  118. RegisterPCI(0x8086, id, GenericVGA{GenericPCI{Comment: "VGA controller"}})
  119. }
  120. /* CPU HD Audio */
  121. RegisterPCI(0x8086, 0x0a0c, GenericPCI{})
  122. RegisterPCI(0x8086, 0x0c0c, GenericPCI{})
  123. }