Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
Kyösti Mälkki | ab56b3b | 2013-11-28 16:44:51 +0200 | [diff] [blame] | 4 | #include <bootmode.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 5 | #include <device/mmio.h> |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 6 | #include <delay.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 7 | #include <arch/io.h> |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 8 | #include <device/device.h> |
| 9 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 10 | #include <device/pci_ops.h> |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 11 | #include <device/pci_ids.h> |
Kyösti Mälkki | cbf9571 | 2020-01-05 08:05:45 +0200 | [diff] [blame] | 12 | #include <option.h> |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 13 | #include <edid.h> |
| 14 | #include <drivers/intel/gma/edid.h> |
| 15 | #include <drivers/intel/gma/i915.h> |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 16 | #include <drivers/intel/gma/opregion.h> |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 17 | #include <string.h> |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 18 | #include <pc80/vga.h> |
| 19 | #include <pc80/vga_io.h> |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 20 | #include <commonlib/helpers.h> |
Elyes HAOUAS | 51401c3 | 2019-05-15 21:09:30 +0200 | [diff] [blame] | 21 | #include <types.h> |
Patrick Rudolph | 8b56c8c | 2020-02-19 12:57:00 +0100 | [diff] [blame] | 22 | #include <framebuffer_info.h> |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 23 | |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 24 | #include "i945.h" |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 25 | #include "chip.h" |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 26 | |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 27 | #define GDRST 0xc0 |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 28 | #define MSAC 0x62 /* Multi Size Aperture Control */ |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 29 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 30 | #define LVDS_CLOCK_A_POWERUP_ALL (3 << 8) |
| 31 | #define LVDS_CLOCK_B_POWERUP_ALL (3 << 4) |
| 32 | #define LVDS_CLOCK_BOTH_POWERUP_ALL (3 << 2) |
Elyes HAOUAS | 8868fc6 | 2017-06-28 20:41:53 +0200 | [diff] [blame] | 33 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 34 | #define DPLLB_LVDS_P2_CLOCK_DIV_7 (1 << 24) /* i915 */ |
| 35 | |
Elyes HAOUAS | 692e7df | 2017-06-28 20:44:41 +0200 | [diff] [blame] | 36 | #define DPLL_INTEGRATED_CRI_CLK_VLV (1 << 14) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 37 | |
| 38 | #define PGETBL_CTL 0x2020 |
| 39 | #define PGETBL_ENABLED 0x00000001 |
| 40 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 41 | #define BASE_FREQUENCY 100000 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 42 | |
Arthur Heymans | 8e07900 | 2017-01-14 22:31:54 +0100 | [diff] [blame] | 43 | #define DEFAULT_BLC_PWM 180 |
| 44 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 45 | static int gtt_setup(u8 *mmiobase) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 46 | { |
| 47 | unsigned long PGETBL_save; |
Paul Menzel | cc95f18 | 2014-06-05 22:45:35 +0200 | [diff] [blame] | 48 | unsigned long tom; // top of memory |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 49 | |
Paul Menzel | cc95f18 | 2014-06-05 22:45:35 +0200 | [diff] [blame] | 50 | /* |
| 51 | * The Video BIOS places the GTT right below top of memory. |
Denis 'GNUtoo' Carikli | 16110e7 | 2014-10-14 07:33:53 +0200 | [diff] [blame] | 52 | */ |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 53 | tom = pci_read_config8(pcidev_on_root(0, 0), TOLUD) << 24; |
Paul Menzel | cc95f18 | 2014-06-05 22:45:35 +0200 | [diff] [blame] | 54 | PGETBL_save = tom - 256 * KiB; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 55 | PGETBL_save |= PGETBL_ENABLED; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 56 | PGETBL_save |= 2; /* set GTT to 256kb */ |
| 57 | |
| 58 | write32(mmiobase + GFX_FLSH_CNTL, 0); |
| 59 | |
| 60 | write32(mmiobase + PGETBL_CTL, PGETBL_save); |
| 61 | |
| 62 | /* verify */ |
| 63 | if (read32(mmiobase + PGETBL_CTL) & PGETBL_ENABLED) { |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 64 | printk(BIOS_DEBUG, "%s is enabled.\n", __func__); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 65 | } else { |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 66 | printk(BIOS_DEBUG, "%s failed!!!\n", __func__); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 67 | return 1; |
| 68 | } |
| 69 | write32(mmiobase + GFX_FLSH_CNTL, 0); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 74 | static int intel_gma_init_lvds(struct northbridge_intel_i945_config *conf, |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 75 | unsigned int pphysbase, unsigned int piobase, |
Elyes HAOUAS | 964055d | 2022-01-14 18:56:49 +0100 | [diff] [blame] | 76 | u8 *mmiobase, uintptr_t pgfx) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 77 | { |
| 78 | struct edid edid; |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 79 | struct edid_mode *mode; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 80 | u8 edid_data[128]; |
| 81 | unsigned long temp; |
| 82 | int hpolarity, vpolarity; |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 83 | u32 smallest_err = 0xffffffff; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 84 | u32 target_frequency; |
| 85 | u32 pixel_p1 = 1; |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 86 | u32 pixel_p2; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 87 | u32 pixel_n = 1; |
| 88 | u32 pixel_m1 = 1; |
| 89 | u32 pixel_m2 = 1; |
| 90 | u32 hactive, vactive, right_border, bottom_border; |
| 91 | u32 vsync, hsync, vblank, hblank, hfront_porch, vfront_porch; |
| 92 | u32 i, j; |
| 93 | u32 uma_size; |
| 94 | u16 reg16; |
| 95 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 96 | printk(BIOS_SPEW, |
Francis Rowe | 71512b2 | 2015-03-16 05:31:40 +0000 | [diff] [blame] | 97 | "i915lightup: graphics %p mmio %p addrport %04x physbase %08x\n", |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 98 | (void *)pgfx, mmiobase, piobase, pphysbase); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 99 | |
Arthur Heymans | 8da2286 | 2017-08-06 15:56:30 +0200 | [diff] [blame] | 100 | intel_gmbus_read_edid(mmiobase + GMBUS0, GMBUS_PORT_PANEL, 0x50, |
| 101 | edid_data, sizeof(edid_data)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 102 | decode_edid(edid_data, sizeof(edid_data), &edid); |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 103 | mode = &edid.mode; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 104 | |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 105 | hpolarity = (mode->phsync == '-'); |
| 106 | vpolarity = (mode->pvsync == '-'); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 107 | hactive = edid.x_resolution; |
| 108 | vactive = edid.y_resolution; |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 109 | right_border = mode->hborder; |
| 110 | bottom_border = mode->vborder; |
| 111 | vblank = mode->vbl; |
| 112 | hblank = mode->hbl; |
| 113 | vsync = mode->vspw; |
| 114 | hsync = mode->hspw; |
| 115 | hfront_porch = mode->hso; |
| 116 | vfront_porch = mode->vso; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 117 | |
| 118 | for (i = 0; i < 2; i++) |
| 119 | for (j = 0; j < 0x100; j++) |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 120 | /* R = j, G = j, B = j. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 121 | write32(mmiobase + PALETTE(i) + 4 * j, 0x10101 * j); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 122 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 123 | write32(mmiobase + PCH_PP_CONTROL, PANEL_UNLOCK_REGS |
| 124 | | (read32(mmiobase + PCH_PP_CONTROL) & ~PANEL_UNLOCK_MASK)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 125 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 126 | write32(mmiobase + MI_ARB_STATE, MI_ARB_C3_LP_WRITE_ENABLE | (1 << 27)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 127 | /* Clean registers. */ |
| 128 | for (i = 0; i < 0x20; i += 4) |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 129 | write32(mmiobase + RENDER_RING_BASE + i, 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 130 | for (i = 0; i < 0x20; i += 4) |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 131 | write32(mmiobase + FENCE_REG_965_0 + i, 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 132 | |
| 133 | /* Disable VGA. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 134 | write32(mmiobase + VGACNTRL, VGA_DISP_DISABLE); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 135 | |
| 136 | /* Disable pipes. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 137 | write32(mmiobase + PIPECONF(0), 0); |
| 138 | write32(mmiobase + PIPECONF(1), 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 139 | |
| 140 | /* Init PRB0. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 141 | write32(mmiobase + HWS_PGA, 0x352d2000); |
| 142 | write32(mmiobase + PRB0_CTL, 0); |
| 143 | write32(mmiobase + PRB0_HEAD, 0); |
| 144 | write32(mmiobase + PRB0_TAIL, 0); |
| 145 | write32(mmiobase + PRB0_START, 0); |
| 146 | write32(mmiobase + PRB0_CTL, 0x0001f001); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 147 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 148 | write32(mmiobase + D_STATE, DSTATE_PLL_D3_OFF |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 149 | | DSTATE_GFX_CLOCK_GATING | DSTATE_DOT_CLOCK_GATING); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 150 | write32(mmiobase + ECOSKPD, 0x00010000); |
| 151 | write32(mmiobase + HWSTAM, 0xeffe); |
| 152 | write32(mmiobase + PORT_HOTPLUG_EN, conf->gpu_hotplug); |
| 153 | write32(mmiobase + INSTPM, 0x08000000 | INSTPM_AGPBUSY_DIS); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 154 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 155 | /* p2 divisor must 7 for dual channel LVDS */ |
| 156 | /* and 14 for single channel LVDS */ |
| 157 | pixel_p2 = mode->lvds_dual_channel ? 7 : 14; |
| 158 | target_frequency = mode->pixel_clock; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 159 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 160 | /* Find suitable divisors, m1, m2, p1, n. */ |
| 161 | /* refclock * (5 * (m1 + 2) + (m1 + 2)) / (n + 2) / p1 / p2 */ |
| 162 | /* should be closest to target frequency as possible */ |
| 163 | u32 candn, candm1, candm2, candp1; |
| 164 | for (candm1 = 8; candm1 <= 18; candm1++) { |
| 165 | for (candm2 = 3; candm2 <= 7; candm2++) { |
| 166 | for (candn = 1; candn <= 6; candn++) { |
| 167 | for (candp1 = 1; candp1 <= 8; candp1++) { |
| 168 | u32 m = 5 * (candm1 + 2) + (candm2 + 2); |
| 169 | u32 p = candp1 * pixel_p2; |
| 170 | u32 vco = DIV_ROUND_CLOSEST(BASE_FREQUENCY * m, candn + 2); |
| 171 | u32 dot = DIV_ROUND_CLOSEST(vco, p); |
Arthur Heymans | 75f9131 | 2016-10-12 01:04:28 +0200 | [diff] [blame] | 172 | u32 this_err = MAX(dot, target_frequency) - |
| 173 | MIN(dot, target_frequency); |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 174 | if ((m < 70) || (m > 120)) |
| 175 | continue; |
| 176 | if (this_err < smallest_err) { |
| 177 | smallest_err = this_err; |
| 178 | pixel_n = candn; |
| 179 | pixel_m1 = candm1; |
| 180 | pixel_m2 = candm2; |
| 181 | pixel_p1 = candp1; |
| 182 | } |
| 183 | } |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 188 | if (smallest_err == 0xffffffff) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 189 | printk(BIOS_ERR, "Couldn't find GFX clock divisors\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 190 | return -1; |
| 191 | } |
| 192 | |
| 193 | printk(BIOS_INFO, "bringing up panel at resolution %d x %d\n", |
| 194 | hactive, vactive); |
| 195 | printk(BIOS_DEBUG, "Borders %d x %d\n", right_border, bottom_border); |
| 196 | printk(BIOS_DEBUG, "Blank %d x %d\n", hblank, vblank); |
| 197 | printk(BIOS_DEBUG, "Sync %d x %d\n", hsync, vsync); |
| 198 | printk(BIOS_DEBUG, "Front porch %d x %d\n", hfront_porch, vfront_porch); |
| 199 | printk(BIOS_DEBUG, (conf->gpu_lvds_use_spread_spectrum_clock |
| 200 | ? "Spread spectrum clock\n" |
| 201 | : "DREF clock\n")); |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 202 | printk(BIOS_DEBUG, (mode->lvds_dual_channel |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 203 | ? "Dual channel\n" |
| 204 | : "Single channel\n")); |
| 205 | printk(BIOS_DEBUG, "Polarities %d, %d\n", |
| 206 | hpolarity, vpolarity); |
| 207 | printk(BIOS_DEBUG, "Pixel N=%d, M1=%d, M2=%d, P1=%d\n", |
| 208 | pixel_n, pixel_m1, pixel_m2, pixel_p1); |
| 209 | printk(BIOS_DEBUG, "Pixel clock %d kHz\n", |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 210 | BASE_FREQUENCY * (5 * (pixel_m1 + 2) + (pixel_m2 + 2)) / |
| 211 | (pixel_n + 2) / (pixel_p1 * pixel_p2)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 212 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 213 | printk(BIOS_INFO, "VGA mode: %s\n", CONFIG(LINEAR_FRAMEBUFFER) ? |
Paul Menzel | bcf9a0a | 2018-02-18 10:05:53 +0100 | [diff] [blame] | 214 | "Linear framebuffer" : "text"); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 215 | if (CONFIG(LINEAR_FRAMEBUFFER)) { |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 216 | /* Disable panel fitter (we're in native resolution). */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 217 | write32(mmiobase + PF_CTL(0), 0); |
| 218 | write32(mmiobase + PF_WIN_SZ(0), 0); |
| 219 | write32(mmiobase + PF_WIN_POS(0), 0); |
| 220 | write32(mmiobase + PFIT_PGM_RATIOS, 0); |
| 221 | write32(mmiobase + PFIT_CONTROL, 0); |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 222 | } else { |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 223 | write32(mmiobase + PF_WIN_SZ(0), vactive | (hactive << 16)); |
| 224 | write32(mmiobase + PF_WIN_POS(0), 0); |
| 225 | write32(mmiobase + PF_CTL(0), PF_ENABLE | PF_FILTER_MED_3x3); |
| 226 | write32(mmiobase + PFIT_CONTROL, PFIT_ENABLE |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 227 | | (1 << PFIT_PIPE_SHIFT) | HORIZ_AUTO_SCALE |
| 228 | | VERT_AUTO_SCALE); |
| 229 | } |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 230 | |
| 231 | mdelay(1); |
| 232 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 233 | write32(mmiobase + DSPCNTR(0), DISPPLANE_BGRX888 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 234 | | DISPPLANE_SEL_PIPE_B | DISPPLANE_GAMMA_ENABLE); |
| 235 | |
| 236 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 237 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS |
| 238 | | (read32(mmiobase + PP_CONTROL) & ~PANEL_UNLOCK_MASK)); |
| 239 | write32(mmiobase + FP0(1), |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 240 | (pixel_n << 16) |
| 241 | | (pixel_m1 << 8) | pixel_m2); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 242 | write32(mmiobase + DPLL(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 243 | DPLL_VGA_MODE_DIS | |
| 244 | DPLL_VCO_ENABLE | DPLLB_MODE_LVDS |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 245 | | (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 246 | : DPLLB_LVDS_P2_CLOCK_DIV_14) |
| 247 | | (conf->gpu_lvds_use_spread_spectrum_clock |
| 248 | ? DPLL_INTEGRATED_CLOCK_VLV | DPLL_INTEGRATED_CRI_CLK_VLV |
| 249 | : 0) |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 250 | | (0x10000 << (pixel_p1 - 1))); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 251 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 252 | write32(mmiobase + DPLL(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 253 | DPLL_VGA_MODE_DIS | |
| 254 | DPLL_VCO_ENABLE | DPLLB_MODE_LVDS |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 255 | | (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 256 | : DPLLB_LVDS_P2_CLOCK_DIV_14) |
| 257 | | ((conf->gpu_lvds_use_spread_spectrum_clock ? 3 : 0) << 13) |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 258 | | (0x10000 << (pixel_p1 - 1))); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 259 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 260 | write32(mmiobase + HTOTAL(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 261 | ((hactive + right_border + hblank - 1) << 16) |
| 262 | | (hactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 263 | write32(mmiobase + HBLANK(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 264 | ((hactive + right_border + hblank - 1) << 16) |
| 265 | | (hactive + right_border - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 266 | write32(mmiobase + HSYNC(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 267 | ((hactive + right_border + hfront_porch + hsync - 1) << 16) |
| 268 | | (hactive + right_border + hfront_porch - 1)); |
| 269 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 270 | write32(mmiobase + VTOTAL(1), ((vactive + bottom_border + vblank - 1) << 16) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 271 | | (vactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 272 | write32(mmiobase + VBLANK(1), ((vactive + bottom_border + vblank - 1) << 16) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 273 | | (vactive + bottom_border - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 274 | write32(mmiobase + VSYNC(1), |
Arthur Heymans | c8c73a6 | 2016-10-13 14:12:45 +0200 | [diff] [blame] | 275 | ((vactive + bottom_border + vfront_porch + vsync - 1) << 16) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 276 | | (vactive + bottom_border + vfront_porch - 1)); |
| 277 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 278 | if (CONFIG(LINEAR_FRAMEBUFFER)) { |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 279 | write32(mmiobase + PIPESRC(1), ((hactive - 1) << 16) |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 280 | | (vactive - 1)); |
| 281 | } else { |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 282 | write32(mmiobase + PIPESRC(1), (639 << 16) | 399); |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 283 | } |
| 284 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 285 | mdelay(1); |
| 286 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 287 | write32(mmiobase + DSPSIZE(0), (hactive - 1) | ((vactive - 1) << 16)); |
| 288 | write32(mmiobase + DSPPOS(0), 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 289 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 290 | edid.bytes_per_line = (edid.bytes_per_line + 63) & ~63; |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 291 | write32(mmiobase + DSPADDR(0), 0); |
| 292 | write32(mmiobase + DSPSURF(0), 0); |
| 293 | write32(mmiobase + DSPSTRIDE(0), edid.bytes_per_line); |
| 294 | write32(mmiobase + DSPCNTR(0), DISPLAY_PLANE_ENABLE | DISPPLANE_BGRX888 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 295 | | DISPPLANE_SEL_PIPE_B | DISPPLANE_GAMMA_ENABLE); |
| 296 | mdelay(1); |
| 297 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 298 | write32(mmiobase + PIPECONF(1), PIPECONF_ENABLE); |
| 299 | write32(mmiobase + LVDS, LVDS_ON |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 300 | | (hpolarity << 20) | (vpolarity << 21) |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 301 | | (mode->lvds_dual_channel ? LVDS_CLOCK_B_POWERUP_ALL |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 302 | | LVDS_CLOCK_BOTH_POWERUP_ALL : 0) |
| 303 | | LVDS_CLOCK_A_POWERUP_ALL |
| 304 | | LVDS_PIPE(1)); |
| 305 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 306 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_OFF); |
| 307 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_RESET); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 308 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 309 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 310 | | PANEL_POWER_ON | PANEL_POWER_RESET); |
| 311 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 312 | printk(BIOS_DEBUG, "waiting for panel powerup\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 313 | while (1) { |
| 314 | u32 reg32; |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 315 | reg32 = read32(mmiobase + PP_STATUS); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 316 | if ((reg32 & PP_SEQUENCE_MASK) == PP_SEQUENCE_NONE) |
| 317 | break; |
| 318 | } |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 319 | printk(BIOS_DEBUG, "panel powered up\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 320 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 321 | write32(mmiobase + PP_CONTROL, PANEL_POWER_ON | PANEL_POWER_RESET); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 322 | |
| 323 | /* Clear interrupts. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 324 | write32(mmiobase + DEIIR, 0xffffffff); |
| 325 | write32(mmiobase + SDEIIR, 0xffffffff); |
| 326 | write32(mmiobase + IIR, 0xffffffff); |
| 327 | write32(mmiobase + IMR, 0xffffffff); |
| 328 | write32(mmiobase + EIR, 0xffffffff); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 329 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 330 | if (gtt_setup(mmiobase)) { |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 331 | printk(BIOS_ERR, "GTT Setup Failed!!!\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | /* Setup GTT. */ |
| 336 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 337 | reg16 = pci_read_config16(pcidev_on_root(0, 0), GGC); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 338 | uma_size = 0; |
| 339 | if (!(reg16 & 2)) { |
Arthur Heymans | 874a8f9 | 2016-05-19 16:06:09 +0200 | [diff] [blame] | 340 | uma_size = decode_igd_memory_size((reg16 >> 4) & 7); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 341 | printk(BIOS_DEBUG, "%dM UMA\n", uma_size >> 10); |
| 342 | } |
| 343 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 344 | for (i = 0; i < (uma_size - 256) / 4; i++) { |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 345 | outl((i << 2) | 1, piobase); |
| 346 | outl(pphysbase + (i << 12) + 1, piobase + 4); |
| 347 | } |
| 348 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 349 | temp = read32(mmiobase + PGETBL_CTL); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 350 | printk(BIOS_INFO, "GTT PGETBL_CTL register: 0x%lx\n", temp); |
| 351 | |
| 352 | if (temp & 1) |
| 353 | printk(BIOS_INFO, "GTT Enabled\n"); |
| 354 | else |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 355 | printk(BIOS_ERR, "GTT is still Disabled!!!\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 356 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 357 | if (CONFIG(LINEAR_FRAMEBUFFER)) { |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 358 | printk(BIOS_SPEW, "memset %p to 0x00 for %d bytes\n", |
| 359 | (void *)pgfx, hactive * vactive * 4); |
| 360 | memset((void *)pgfx, 0x00, hactive * vactive * 4); |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 361 | |
Patrick Rudolph | 8b56c8c | 2020-02-19 12:57:00 +0100 | [diff] [blame] | 362 | fb_new_framebuffer_info_from_edid(&edid, pgfx); |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 363 | } else { |
Elyes HAOUAS | c962924 | 2020-07-26 18:17:44 +0200 | [diff] [blame] | 364 | vga_misc_write(0x67); |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 365 | |
Elyes HAOUAS | c962924 | 2020-07-26 18:17:44 +0200 | [diff] [blame] | 366 | write32(mmiobase + DSPCNTR(0), DISPPLANE_SEL_PIPE_B); |
| 367 | write32(mmiobase + VGACNTRL, 0x02c4008e | VGA_PIPE_B_SELECT); |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 368 | |
Elyes HAOUAS | c962924 | 2020-07-26 18:17:44 +0200 | [diff] [blame] | 369 | vga_textmode_init(); |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 370 | } |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 371 | return 0; |
| 372 | } |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 373 | |
| 374 | static int intel_gma_init_vga(struct northbridge_intel_i945_config *conf, |
| 375 | unsigned int pphysbase, unsigned int piobase, |
Elyes HAOUAS | 964055d | 2022-01-14 18:56:49 +0100 | [diff] [blame] | 376 | u8 *mmiobase, uintptr_t pgfx) |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 377 | { |
| 378 | int i; |
| 379 | u32 hactive, vactive; |
| 380 | u16 reg16; |
| 381 | u32 uma_size; |
| 382 | |
Elyes HAOUAS | 964055d | 2022-01-14 18:56:49 +0100 | [diff] [blame] | 383 | printk(BIOS_SPEW, "mmiobase %lx addrport %x physbase %x\n", |
| 384 | (uintptr_t)mmiobase, piobase, pphysbase); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 385 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 386 | gtt_setup(mmiobase); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 387 | |
| 388 | /* Disable VGA. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 389 | write32(mmiobase + VGACNTRL, VGA_DISP_DISABLE); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 390 | |
| 391 | /* Disable pipes. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 392 | write32(mmiobase + PIPECONF(0), 0); |
| 393 | write32(mmiobase + PIPECONF(1), 0); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 394 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 395 | write32(mmiobase + INSTPM, 0x800); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 396 | |
| 397 | vga_gr_write(0x18, 0); |
| 398 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 399 | write32(mmiobase + VGA0, 0x200074); |
| 400 | write32(mmiobase + VGA1, 0x200074); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 401 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 402 | write32(mmiobase + DSPFW3, 0x7f3f00c1 & ~PINEVIEW_SELF_REFRESH_EN); |
| 403 | write32(mmiobase + DSPCLK_GATE_D, 0); |
| 404 | write32(mmiobase + FW_BLC, 0x03060106); |
| 405 | write32(mmiobase + FW_BLC2, 0x00000306); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 406 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 407 | write32(mmiobase + ADPA, ADPA_DAC_ENABLE |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 408 | | ADPA_PIPE_A_SELECT |
| 409 | | ADPA_USE_VGA_HVPOLARITY |
| 410 | | ADPA_VSYNC_CNTL_ENABLE |
| 411 | | ADPA_HSYNC_CNTL_ENABLE |
| 412 | | ADPA_DPMS_ON |
| 413 | ); |
| 414 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 415 | write32(mmiobase + 0x7041c, 0x0); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 416 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 417 | write32(mmiobase + DPLL_MD(0), 0x3); |
| 418 | write32(mmiobase + DPLL_MD(1), 0x3); |
| 419 | write32(mmiobase + DSPCNTR(1), 0x1000000); |
| 420 | write32(mmiobase + PIPESRC(1), 0x027f01df); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 421 | |
| 422 | vga_misc_write(0x67); |
| 423 | const u8 cr[] = { 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, |
| 424 | 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, |
| 425 | 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, |
| 426 | 0xff |
| 427 | }; |
| 428 | vga_cr_write(0x11, 0); |
| 429 | |
| 430 | for (i = 0; i <= 0x18; i++) |
| 431 | vga_cr_write(i, cr[i]); |
| 432 | |
| 433 | // Disable screen memory to prevent garbage from appearing. |
| 434 | vga_sr_write(1, vga_sr_read(1) | 0x20); |
| 435 | hactive = 640; |
| 436 | vactive = 400; |
| 437 | |
| 438 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 439 | write32(mmiobase + DPLL(0), |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 440 | DPLL_VCO_ENABLE | DPLLB_MODE_DAC_SERIAL |
| 441 | | DPLL_VGA_MODE_DIS |
| 442 | | DPLL_DAC_SERIAL_P2_CLOCK_DIV_10 |
| 443 | | 0x400601 |
| 444 | ); |
| 445 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 446 | write32(mmiobase + DPLL(0), |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 447 | DPLL_VCO_ENABLE | DPLLB_MODE_DAC_SERIAL |
| 448 | | DPLL_VGA_MODE_DIS |
| 449 | | DPLL_DAC_SERIAL_P2_CLOCK_DIV_10 |
| 450 | | 0x400601 |
| 451 | ); |
| 452 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 453 | write32(mmiobase + ADPA, ADPA_DAC_ENABLE |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 454 | | ADPA_PIPE_A_SELECT |
| 455 | | ADPA_USE_VGA_HVPOLARITY |
| 456 | | ADPA_VSYNC_CNTL_ENABLE |
| 457 | | ADPA_HSYNC_CNTL_ENABLE |
| 458 | | ADPA_DPMS_ON |
| 459 | ); |
| 460 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 461 | write32(mmiobase + HTOTAL(0), |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 462 | ((hactive - 1) << 16) |
| 463 | | (hactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 464 | write32(mmiobase + HBLANK(0), |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 465 | ((hactive - 1) << 16) |
| 466 | | (hactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 467 | write32(mmiobase + HSYNC(0), |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 468 | ((hactive - 1) << 16) |
| 469 | | (hactive - 1)); |
| 470 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 471 | write32(mmiobase + VTOTAL(0), ((vactive - 1) << 16) |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 472 | | (vactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 473 | write32(mmiobase + VBLANK(0), ((vactive - 1) << 16) |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 474 | | (vactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 475 | write32(mmiobase + VSYNC(0), |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 476 | ((vactive - 1) << 16) |
| 477 | | (vactive - 1)); |
| 478 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 479 | write32(mmiobase + PF_WIN_POS(0), 0); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 480 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 481 | write32(mmiobase + PIPESRC(0), (639 << 16) | 399); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 482 | write32(mmiobase + PF_CTL(0), PF_ENABLE | PF_FILTER_MED_3x3); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 483 | write32(mmiobase + PF_WIN_SZ(0), vactive | (hactive << 16)); |
| 484 | write32(mmiobase + PFIT_CONTROL, 0x0); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 485 | |
| 486 | mdelay(1); |
| 487 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 488 | write32(mmiobase + FDI_RX_CTL(0), 0x00002040); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 489 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 490 | write32(mmiobase + FDI_RX_CTL(0), 0x80002050); |
| 491 | write32(mmiobase + FDI_TX_CTL(0), 0x00044000); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 492 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 493 | write32(mmiobase + FDI_TX_CTL(0), 0x80044000); |
| 494 | write32(mmiobase + PIPECONF(0), PIPECONF_ENABLE | PIPECONF_BPP_6 | PIPECONF_DITHER_EN); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 495 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 496 | write32(mmiobase + VGACNTRL, 0x0); |
| 497 | write32(mmiobase + DSPCNTR(0), DISPLAY_PLANE_ENABLE | DISPPLANE_BGRX888); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 498 | mdelay(1); |
| 499 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 500 | write32(mmiobase + ADPA, ADPA_DAC_ENABLE |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 501 | | ADPA_PIPE_A_SELECT |
| 502 | | ADPA_USE_VGA_HVPOLARITY |
| 503 | | ADPA_VSYNC_CNTL_ENABLE |
| 504 | | ADPA_HSYNC_CNTL_ENABLE |
| 505 | | ADPA_DPMS_ON |
| 506 | ); |
| 507 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 508 | write32(mmiobase + DSPFW3, 0x7f3f00c1); |
| 509 | write32(mmiobase + MI_MODE, 0x200 | VS_TIMER_DISPATCH); |
| 510 | write32(mmiobase + CACHE_MODE_0, (0x6820 | (1 << 9)) & ~(1 << 5)); |
| 511 | write32(mmiobase + CACHE_MODE_1, 0x380 & ~(1 << 9)); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 512 | |
| 513 | /* Set up GTT. */ |
| 514 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 515 | reg16 = pci_read_config16(pcidev_on_root(0, 0), GGC); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 516 | uma_size = 0; |
| 517 | if (!(reg16 & 2)) { |
| 518 | uma_size = decode_igd_memory_size((reg16 >> 4) & 7); |
| 519 | printk(BIOS_DEBUG, "%dM UMA\n", uma_size >> 10); |
| 520 | } |
| 521 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 522 | for (i = 0; i < (uma_size - 256) / 4; i++) { |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 523 | outl((i << 2) | 1, piobase); |
| 524 | outl(pphysbase + (i << 12) + 1, piobase + 4); |
| 525 | } |
| 526 | |
| 527 | /* Clear interrupts. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 528 | write32(mmiobase + DEIIR, 0xffffffff); |
| 529 | write32(mmiobase + SDEIIR, 0xffffffff); |
| 530 | write32(mmiobase + IIR, 0xffffffff); |
| 531 | write32(mmiobase + IMR, 0xffffffff); |
| 532 | write32(mmiobase + EIR, 0xffffffff); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 533 | |
| 534 | vga_textmode_init(); |
| 535 | |
| 536 | /* Enable screen memory. */ |
| 537 | vga_sr_write(1, vga_sr_read(1) & ~0x20); |
| 538 | |
| 539 | return 0; |
| 540 | |
| 541 | } |
| 542 | |
| 543 | /* compare the header of the vga edid header */ |
| 544 | /* if vga is not connected it should have a correct header */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 545 | static int probe_edid(u8 *mmiobase, u8 slave) |
Arthur Heymans | 62f4dad | 2016-09-06 23:53:32 +0200 | [diff] [blame] | 546 | { |
Paul Menzel | 533a385 | 2016-11-27 22:17:44 +0100 | [diff] [blame] | 547 | int i; |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 548 | u8 vga_edid[128]; |
| 549 | u8 header[8] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}; |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 550 | intel_gmbus_read_edid(mmiobase + GMBUS0, slave, 0x50, vga_edid, 128); |
| 551 | intel_gmbus_stop(mmiobase + GMBUS0); |
Paul Menzel | 533a385 | 2016-11-27 22:17:44 +0100 | [diff] [blame] | 552 | for (i = 0; i < 8; i++) { |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 553 | if (vga_edid[i] != header[i]) { |
Arthur Heymans | 62f4dad | 2016-09-06 23:53:32 +0200 | [diff] [blame] | 554 | printk(BIOS_DEBUG, "No display connected on slave %d\n", |
| 555 | slave); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 556 | return 0; |
| 557 | } |
| 558 | } |
Arthur Heymans | 62f4dad | 2016-09-06 23:53:32 +0200 | [diff] [blame] | 559 | printk(BIOS_SPEW, "Found a display on slave %d\n", slave); |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 560 | return 1; |
| 561 | } |
| 562 | |
Arthur Heymans | 8e07900 | 2017-01-14 22:31:54 +0100 | [diff] [blame] | 563 | static u32 get_cdclk(struct device *const dev) |
| 564 | { |
| 565 | u16 gcfgc = pci_read_config16(dev, GCFGC); |
| 566 | |
Elyes HAOUAS | 2a1c430 | 2018-10-25 10:41:27 +0200 | [diff] [blame] | 567 | if (gcfgc & GC_LOW_FREQUENCY_ENABLE) |
Arthur Heymans | 8e07900 | 2017-01-14 22:31:54 +0100 | [diff] [blame] | 568 | return 133333333; |
Elyes HAOUAS | 2a1c430 | 2018-10-25 10:41:27 +0200 | [diff] [blame] | 569 | |
| 570 | switch (gcfgc & GC_DISPLAY_CLOCK_MASK) { |
| 571 | case GC_DISPLAY_CLOCK_333_320_MHZ: |
| 572 | return 320000000; |
| 573 | default: |
| 574 | case GC_DISPLAY_CLOCK_190_200_MHZ: |
| 575 | return 200000000; |
Arthur Heymans | 8e07900 | 2017-01-14 22:31:54 +0100 | [diff] [blame] | 576 | } |
| 577 | } |
| 578 | |
| 579 | static u32 freq_to_blc_pwm_ctl(struct device *const dev, u16 pwm_freq) |
| 580 | { |
| 581 | u32 blc_mod; |
| 582 | |
| 583 | /* Set duty cycle to 100% due to use of legacy backlight control */ |
| 584 | blc_mod = get_cdclk(dev) / (32 * pwm_freq); |
| 585 | return BLM_LEGACY_MODE | ((blc_mod / 2) << 17) | ((blc_mod / 2) << 1); |
| 586 | } |
| 587 | |
Arthur Heymans | 8e07900 | 2017-01-14 22:31:54 +0100 | [diff] [blame] | 588 | static void panel_setup(u8 *mmiobase, struct device *const dev) |
| 589 | { |
| 590 | const struct northbridge_intel_i945_config *const conf = dev->chip_info; |
| 591 | |
| 592 | u32 reg32; |
| 593 | |
| 594 | /* Set up Panel Power On Delays */ |
| 595 | reg32 = (conf->gpu_panel_power_up_delay & 0x1fff) << 16; |
| 596 | reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff); |
| 597 | write32(mmiobase + PP_ON_DELAYS, reg32); |
| 598 | |
| 599 | /* Set up Panel Power Off Delays */ |
| 600 | reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16; |
| 601 | reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff); |
| 602 | write32(mmiobase + PP_OFF_DELAYS, reg32); |
| 603 | |
| 604 | /* Set up Panel Power Cycle Delay */ |
| 605 | reg32 = (get_cdclk(dev) / 20000 - 1) << PP_REFERENCE_DIVIDER_SHIFT; |
| 606 | reg32 |= conf->gpu_panel_power_cycle_delay & 0x1f; |
| 607 | write32(mmiobase + PP_DIVISOR, reg32); |
| 608 | |
| 609 | /* Backlight init. */ |
| 610 | if (conf->pwm_freq) |
| 611 | write32(mmiobase + BLC_PWM_CTL, freq_to_blc_pwm_ctl(dev, |
| 612 | conf->pwm_freq)); |
| 613 | else |
| 614 | write32(mmiobase + BLC_PWM_CTL, freq_to_blc_pwm_ctl(dev, |
| 615 | DEFAULT_BLC_PWM)); |
| 616 | } |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 617 | |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 618 | static void gma_ngi(struct device *const dev) |
| 619 | { |
| 620 | /* This should probably run before post VBIOS init. */ |
| 621 | printk(BIOS_INFO, "Initializing VGA without OPROM.\n"); |
| 622 | void *mmiobase; |
| 623 | u32 iobase, graphics_base; |
| 624 | struct northbridge_intel_i945_config *conf = dev->chip_info; |
| 625 | |
| 626 | iobase = dev->resource_list[1].base; |
| 627 | mmiobase = (void *)(uintptr_t)dev->resource_list[0].base; |
| 628 | graphics_base = dev->resource_list[2].base; |
| 629 | |
| 630 | printk(BIOS_SPEW, "GMADR = 0x%08x GTTADR = 0x%08x\n", |
| 631 | pci_read_config32(dev, GMADR), pci_read_config32(dev, GTTADR)); |
| 632 | |
| 633 | int err; |
| 634 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 635 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 636 | panel_setup(mmiobase, dev); |
| 637 | |
| 638 | /* probe if VGA is connected and always run */ |
| 639 | /* VGA init if no LVDS is connected */ |
| 640 | if (!probe_edid(mmiobase, GMBUS_PORT_PANEL) || |
| 641 | probe_edid(mmiobase, GMBUS_PORT_VGADDC)) |
| 642 | err = intel_gma_init_vga(conf, |
| 643 | pci_read_config32(dev, 0x5c) & ~0xf, |
| 644 | iobase, mmiobase, graphics_base); |
| 645 | else |
| 646 | err = intel_gma_init_lvds(conf, |
| 647 | pci_read_config32(dev, 0x5c) & ~0xf, |
| 648 | iobase, mmiobase, graphics_base); |
| 649 | if (err == 0) |
| 650 | gfx_set_init_done(1); |
| 651 | /* Linux relies on VBT for panel info. */ |
Julius Werner | 5d1f9a0 | 2019-03-07 17:07:26 -0800 | [diff] [blame] | 652 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) { |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 653 | generate_fake_intel_oprom(&conf->gfx, dev, "$VBT CALISTOGA"); |
| 654 | } |
Julius Werner | 5d1f9a0 | 2019-03-07 17:07:26 -0800 | [diff] [blame] | 655 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 656 | generate_fake_intel_oprom(&conf->gfx, dev, "$VBT LAKEPORT-G"); |
| 657 | } |
| 658 | } |
| 659 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 660 | static void gma_func0_init(struct device *dev) |
| 661 | { |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 662 | intel_gma_init_igd_opregion(); |
| 663 | |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 664 | /* Unconditionally reset graphics */ |
| 665 | pci_write_config8(dev, GDRST, 1); |
| 666 | udelay(50); |
| 667 | pci_write_config8(dev, GDRST, 0); |
| 668 | /* wait for device to finish */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 669 | while (pci_read_config8(dev, GDRST) & 1) |
| 670 | ; |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 671 | |
Nico Huber | dd59762 | 2020-04-26 19:46:35 +0200 | [diff] [blame] | 672 | if (!CONFIG(NO_GFX_INIT)) |
| 673 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Denis 'GNUtoo' Carikli | ed7e29e | 2013-02-24 12:01:44 +0100 | [diff] [blame] | 674 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 675 | if (CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT)) { |
Elyes HAOUAS | 8881d57 | 2019-07-14 09:16:58 +0200 | [diff] [blame] | 676 | int vga_disable = (pci_read_config16(dev, GGC) & 2) >> 1; |
Arthur Heymans | e6c8f7e | 2018-08-09 11:31:51 +0200 | [diff] [blame] | 677 | if (acpi_is_wakeup_s3()) { |
Paul Menzel | 5e7ad65 | 2018-04-14 20:08:54 +0200 | [diff] [blame] | 678 | printk(BIOS_INFO, |
| 679 | "Skipping native VGA initialization when resuming from ACPI S3.\n"); |
Arthur Heymans | e6c8f7e | 2018-08-09 11:31:51 +0200 | [diff] [blame] | 680 | } else { |
| 681 | if (vga_disable) { |
| 682 | printk(BIOS_INFO, |
| 683 | "IGD is not decoding legacy VGA MEM and IO: skipping NATIVE graphic init\n"); |
| 684 | } else { |
| 685 | gma_ngi(dev); |
| 686 | } |
| 687 | } |
Arthur Heymans | f3f4bea | 2016-10-20 20:44:54 +0200 | [diff] [blame] | 688 | } else { |
| 689 | /* PCI Init, will run VBIOS */ |
| 690 | pci_dev_init(dev); |
Arthur Heymans | 333176e | 2016-09-07 22:10:57 +0200 | [diff] [blame] | 691 | } |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 692 | } |
| 693 | |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 694 | /* This doesn't reclaim stolen UMA memory, but IGD could still |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 695 | be re-enabled later. */ |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 696 | static void gma_func0_disable(struct device *dev) |
| 697 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 698 | struct device *dev_host = pcidev_on_root(0x0, 0); |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 699 | |
| 700 | pci_write_config16(dev, GCFC, 0xa00); |
| 701 | pci_write_config16(dev_host, GGC, (1 << 1)); |
| 702 | |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 703 | pci_and_config32(dev_host, DEVEN, ~(DEVEN_D2F0 | DEVEN_D2F1)); |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 704 | |
| 705 | dev->enabled = 0; |
| 706 | } |
| 707 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 708 | static void gma_func1_init(struct device *dev) |
| 709 | { |
Nico Huber | dd59762 | 2020-04-26 19:46:35 +0200 | [diff] [blame] | 710 | if (!CONFIG(NO_GFX_INIT)) |
| 711 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Sven Schnelle | b629d14 | 2011-06-12 14:30:10 +0200 | [diff] [blame] | 712 | |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 713 | pci_write_config8(dev, 0xf4, get_uint_option("tft_brightness", 0xff)); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 714 | } |
| 715 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 716 | static void gma_generate_ssdt(const struct device *device) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 717 | { |
Matt DeVillier | fd054bc | 2020-03-30 22:18:45 -0500 | [diff] [blame] | 718 | const struct northbridge_intel_i945_config *chip = device->chip_info; |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 719 | |
Matt DeVillier | fd054bc | 2020-03-30 22:18:45 -0500 | [diff] [blame] | 720 | drivers_intel_gma_displays_ssdt_generate(&chip->gfx); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 721 | } |
| 722 | |
Elyes HAOUAS | 658a934 | 2018-02-08 14:46:22 +0100 | [diff] [blame] | 723 | static void gma_func0_read_resources(struct device *dev) |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 724 | { |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 725 | /* Set Untrusted Aperture Size to 256MB */ |
| 726 | pci_update_config8(dev, MSAC, ~0x3, 0x2); |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 727 | |
| 728 | pci_dev_read_resources(dev); |
| 729 | } |
| 730 | |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 731 | static const char *gma_acpi_name(const struct device *dev) |
| 732 | { |
| 733 | return "GFX0"; |
| 734 | } |
| 735 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 736 | static struct device_operations gma_func0_ops = { |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 737 | .read_resources = gma_func0_read_resources, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 738 | .set_resources = pci_dev_set_resources, |
| 739 | .enable_resources = pci_dev_enable_resources, |
| 740 | .init = gma_func0_init, |
Matt DeVillier | fd054bc | 2020-03-30 22:18:45 -0500 | [diff] [blame] | 741 | .acpi_fill_ssdt = gma_generate_ssdt, |
Arthur Heymans | b238caa | 2021-02-22 18:33:08 +0100 | [diff] [blame] | 742 | .vga_disable = gma_func0_disable, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 743 | .ops_pci = &pci_dev_ops_pci, |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 744 | .acpi_name = gma_acpi_name, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 745 | }; |
| 746 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 747 | static struct device_operations gma_func1_ops = { |
| 748 | .read_resources = pci_dev_read_resources, |
| 749 | .set_resources = pci_dev_set_resources, |
| 750 | .enable_resources = pci_dev_enable_resources, |
| 751 | .init = gma_func1_init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 752 | .ops_pci = &pci_dev_ops_pci, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 753 | }; |
| 754 | |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 755 | static const unsigned short i945_gma_func0_ids[] = { |
| 756 | 0x2772, /* 82945G/GZ Integrated Graphics Controller */ |
| 757 | 0x27a2, /* Mobile 945GM/GMS Express Integrated Graphics Controller*/ |
| 758 | 0x27ae, /* Mobile 945GSE Express Integrated Graphics Controller */ |
| 759 | 0 |
| 760 | }; |
| 761 | |
| 762 | static const unsigned short i945_gma_func1_ids[] = { |
Elyes HAOUAS | 686b539 | 2019-05-18 13:36:03 +0200 | [diff] [blame] | 763 | 0x2776, /* Desktop 82945G/GZ/GC */ |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 764 | 0x27a6, /* Mobile 945GM/GMS/GME Express Integrated Graphics Controller */ |
| 765 | 0 |
| 766 | }; |
Vladimir Serbinenko | 10dd0e3 | 2014-11-17 00:07:12 +0100 | [diff] [blame] | 767 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 768 | static const struct pci_driver i945_gma_func0_driver __pci_driver = { |
Paul Menzel | 82683c0 | 2018-04-14 19:56:46 +0200 | [diff] [blame] | 769 | .ops = &gma_func0_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 770 | .vendor = PCI_VID_INTEL, |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 771 | .devices = i945_gma_func0_ids, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 772 | }; |
| 773 | |
| 774 | static const struct pci_driver i945_gma_func1_driver __pci_driver = { |
Paul Menzel | 82683c0 | 2018-04-14 19:56:46 +0200 | [diff] [blame] | 775 | .ops = &gma_func1_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 776 | .vendor = PCI_VID_INTEL, |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 777 | .devices = i945_gma_func1_ids, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 778 | }; |