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> |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 22 | |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 23 | #include "i945.h" |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 24 | #include "chip.h" |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 25 | |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 26 | #define GDRST 0xc0 |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 27 | #define MSAC 0x62 /* Multi Size Aperture Control */ |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 28 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 29 | #define LVDS_CLOCK_A_POWERUP_ALL (3 << 8) |
| 30 | #define LVDS_CLOCK_B_POWERUP_ALL (3 << 4) |
| 31 | #define LVDS_CLOCK_BOTH_POWERUP_ALL (3 << 2) |
Elyes HAOUAS | 8868fc6 | 2017-06-28 20:41:53 +0200 | [diff] [blame] | 32 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 33 | #define DPLLB_LVDS_P2_CLOCK_DIV_7 (1 << 24) /* i915 */ |
| 34 | |
Elyes HAOUAS | 692e7df | 2017-06-28 20:44:41 +0200 | [diff] [blame] | 35 | #define DPLL_INTEGRATED_CRI_CLK_VLV (1 << 14) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 36 | |
| 37 | #define PGETBL_CTL 0x2020 |
| 38 | #define PGETBL_ENABLED 0x00000001 |
| 39 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 40 | #define BASE_FREQUENCY 100000 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 41 | |
Arthur Heymans | 8e07900 | 2017-01-14 22:31:54 +0100 | [diff] [blame] | 42 | #define DEFAULT_BLC_PWM 180 |
| 43 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 44 | static int gtt_setup(u8 *mmiobase) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 45 | { |
| 46 | unsigned long PGETBL_save; |
Paul Menzel | cc95f18 | 2014-06-05 22:45:35 +0200 | [diff] [blame] | 47 | unsigned long tom; // top of memory |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 48 | |
Paul Menzel | cc95f18 | 2014-06-05 22:45:35 +0200 | [diff] [blame] | 49 | /* |
| 50 | * The Video BIOS places the GTT right below top of memory. |
Denis 'GNUtoo' Carikli | 16110e7 | 2014-10-14 07:33:53 +0200 | [diff] [blame] | 51 | */ |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 52 | tom = pci_read_config8(pcidev_on_root(0, 0), TOLUD) << 24; |
Paul Menzel | cc95f18 | 2014-06-05 22:45:35 +0200 | [diff] [blame] | 53 | PGETBL_save = tom - 256 * KiB; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 54 | PGETBL_save |= PGETBL_ENABLED; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 55 | PGETBL_save |= 2; /* set GTT to 256kb */ |
| 56 | |
| 57 | write32(mmiobase + GFX_FLSH_CNTL, 0); |
| 58 | |
| 59 | write32(mmiobase + PGETBL_CTL, PGETBL_save); |
| 60 | |
| 61 | /* verify */ |
| 62 | if (read32(mmiobase + PGETBL_CTL) & PGETBL_ENABLED) { |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 63 | printk(BIOS_DEBUG, "%s is enabled.\n", __func__); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 64 | } else { |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 65 | printk(BIOS_DEBUG, "%s failed!!!\n", __func__); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 66 | return 1; |
| 67 | } |
| 68 | write32(mmiobase + GFX_FLSH_CNTL, 0); |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
Arthur Heymans | b59bcb2 | 2016-09-05 22:46:11 +0200 | [diff] [blame] | 73 | static int intel_gma_init_lvds(struct northbridge_intel_i945_config *conf, |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 74 | unsigned int pphysbase, unsigned int piobase, |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 75 | u8 *mmiobase, unsigned int pgfx) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 76 | { |
| 77 | struct edid edid; |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 78 | struct edid_mode *mode; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 79 | u8 edid_data[128]; |
| 80 | unsigned long temp; |
| 81 | int hpolarity, vpolarity; |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 82 | u32 smallest_err = 0xffffffff; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 83 | u32 target_frequency; |
| 84 | u32 pixel_p1 = 1; |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 85 | u32 pixel_p2; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 86 | u32 pixel_n = 1; |
| 87 | u32 pixel_m1 = 1; |
| 88 | u32 pixel_m2 = 1; |
| 89 | u32 hactive, vactive, right_border, bottom_border; |
| 90 | u32 vsync, hsync, vblank, hblank, hfront_porch, vfront_porch; |
| 91 | u32 i, j; |
| 92 | u32 uma_size; |
| 93 | u16 reg16; |
| 94 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 95 | printk(BIOS_SPEW, |
Francis Rowe | 71512b2 | 2015-03-16 05:31:40 +0000 | [diff] [blame] | 96 | "i915lightup: graphics %p mmio %p addrport %04x physbase %08x\n", |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 97 | (void *)pgfx, mmiobase, piobase, pphysbase); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 98 | |
Arthur Heymans | 8da2286 | 2017-08-06 15:56:30 +0200 | [diff] [blame] | 99 | intel_gmbus_read_edid(mmiobase + GMBUS0, GMBUS_PORT_PANEL, 0x50, |
| 100 | edid_data, sizeof(edid_data)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 101 | decode_edid(edid_data, sizeof(edid_data), &edid); |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 102 | mode = &edid.mode; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 103 | |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 104 | hpolarity = (mode->phsync == '-'); |
| 105 | vpolarity = (mode->pvsync == '-'); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 106 | hactive = edid.x_resolution; |
| 107 | vactive = edid.y_resolution; |
Mono | 2e4f83b | 2015-09-07 21:15:26 +0200 | [diff] [blame] | 108 | right_border = mode->hborder; |
| 109 | bottom_border = mode->vborder; |
| 110 | vblank = mode->vbl; |
| 111 | hblank = mode->hbl; |
| 112 | vsync = mode->vspw; |
| 113 | hsync = mode->hspw; |
| 114 | hfront_porch = mode->hso; |
| 115 | vfront_porch = mode->vso; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 116 | |
| 117 | for (i = 0; i < 2; i++) |
| 118 | for (j = 0; j < 0x100; j++) |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 119 | /* R = j, G = j, B = j. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 120 | write32(mmiobase + PALETTE(i) + 4 * j, 0x10101 * j); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 121 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 122 | write32(mmiobase + PCH_PP_CONTROL, PANEL_UNLOCK_REGS |
| 123 | | (read32(mmiobase + PCH_PP_CONTROL) & ~PANEL_UNLOCK_MASK)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 124 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 125 | 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] | 126 | /* Clean registers. */ |
| 127 | for (i = 0; i < 0x20; i += 4) |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 128 | write32(mmiobase + RENDER_RING_BASE + i, 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 129 | for (i = 0; i < 0x20; i += 4) |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 130 | write32(mmiobase + FENCE_REG_965_0 + i, 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 131 | |
| 132 | /* Disable VGA. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 133 | write32(mmiobase + VGACNTRL, VGA_DISP_DISABLE); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 134 | |
| 135 | /* Disable pipes. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 136 | write32(mmiobase + PIPECONF(0), 0); |
| 137 | write32(mmiobase + PIPECONF(1), 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 138 | |
| 139 | /* Init PRB0. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 140 | write32(mmiobase + HWS_PGA, 0x352d2000); |
| 141 | write32(mmiobase + PRB0_CTL, 0); |
| 142 | write32(mmiobase + PRB0_HEAD, 0); |
| 143 | write32(mmiobase + PRB0_TAIL, 0); |
| 144 | write32(mmiobase + PRB0_START, 0); |
| 145 | write32(mmiobase + PRB0_CTL, 0x0001f001); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 146 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 147 | write32(mmiobase + D_STATE, DSTATE_PLL_D3_OFF |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 148 | | DSTATE_GFX_CLOCK_GATING | DSTATE_DOT_CLOCK_GATING); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 149 | write32(mmiobase + ECOSKPD, 0x00010000); |
| 150 | write32(mmiobase + HWSTAM, 0xeffe); |
| 151 | write32(mmiobase + PORT_HOTPLUG_EN, conf->gpu_hotplug); |
| 152 | write32(mmiobase + INSTPM, 0x08000000 | INSTPM_AGPBUSY_DIS); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 153 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 154 | /* p2 divisor must 7 for dual channel LVDS */ |
| 155 | /* and 14 for single channel LVDS */ |
| 156 | pixel_p2 = mode->lvds_dual_channel ? 7 : 14; |
| 157 | target_frequency = mode->pixel_clock; |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 158 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 159 | /* Find suitable divisors, m1, m2, p1, n. */ |
| 160 | /* refclock * (5 * (m1 + 2) + (m1 + 2)) / (n + 2) / p1 / p2 */ |
| 161 | /* should be closest to target frequency as possible */ |
| 162 | u32 candn, candm1, candm2, candp1; |
| 163 | for (candm1 = 8; candm1 <= 18; candm1++) { |
| 164 | for (candm2 = 3; candm2 <= 7; candm2++) { |
| 165 | for (candn = 1; candn <= 6; candn++) { |
| 166 | for (candp1 = 1; candp1 <= 8; candp1++) { |
| 167 | u32 m = 5 * (candm1 + 2) + (candm2 + 2); |
| 168 | u32 p = candp1 * pixel_p2; |
| 169 | u32 vco = DIV_ROUND_CLOSEST(BASE_FREQUENCY * m, candn + 2); |
| 170 | u32 dot = DIV_ROUND_CLOSEST(vco, p); |
Arthur Heymans | 75f9131 | 2016-10-12 01:04:28 +0200 | [diff] [blame] | 171 | u32 this_err = MAX(dot, target_frequency) - |
| 172 | MIN(dot, target_frequency); |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 173 | if ((m < 70) || (m > 120)) |
| 174 | continue; |
| 175 | if (this_err < smallest_err) { |
| 176 | smallest_err = this_err; |
| 177 | pixel_n = candn; |
| 178 | pixel_m1 = candm1; |
| 179 | pixel_m2 = candm2; |
| 180 | pixel_p1 = candp1; |
| 181 | } |
| 182 | } |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 187 | if (smallest_err == 0xffffffff) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 188 | printk(BIOS_ERR, "Couldn't find GFX clock divisors\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 189 | return -1; |
| 190 | } |
| 191 | |
| 192 | printk(BIOS_INFO, "bringing up panel at resolution %d x %d\n", |
| 193 | hactive, vactive); |
| 194 | printk(BIOS_DEBUG, "Borders %d x %d\n", right_border, bottom_border); |
| 195 | printk(BIOS_DEBUG, "Blank %d x %d\n", hblank, vblank); |
| 196 | printk(BIOS_DEBUG, "Sync %d x %d\n", hsync, vsync); |
| 197 | printk(BIOS_DEBUG, "Front porch %d x %d\n", hfront_porch, vfront_porch); |
| 198 | printk(BIOS_DEBUG, (conf->gpu_lvds_use_spread_spectrum_clock |
| 199 | ? "Spread spectrum clock\n" |
| 200 | : "DREF clock\n")); |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 201 | printk(BIOS_DEBUG, (mode->lvds_dual_channel |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 202 | ? "Dual channel\n" |
| 203 | : "Single channel\n")); |
| 204 | printk(BIOS_DEBUG, "Polarities %d, %d\n", |
| 205 | hpolarity, vpolarity); |
| 206 | printk(BIOS_DEBUG, "Pixel N=%d, M1=%d, M2=%d, P1=%d\n", |
| 207 | pixel_n, pixel_m1, pixel_m2, pixel_p1); |
| 208 | printk(BIOS_DEBUG, "Pixel clock %d kHz\n", |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 209 | BASE_FREQUENCY * (5 * (pixel_m1 + 2) + (pixel_m2 + 2)) / |
| 210 | (pixel_n + 2) / (pixel_p1 * pixel_p2)); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 211 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 212 | printk(BIOS_INFO, "VGA mode: %s\n", CONFIG(LINEAR_FRAMEBUFFER) ? |
Paul Menzel | bcf9a0a | 2018-02-18 10:05:53 +0100 | [diff] [blame] | 213 | "Linear framebuffer" : "text"); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 214 | if (CONFIG(LINEAR_FRAMEBUFFER)) { |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 215 | /* Disable panel fitter (we're in native resolution). */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 216 | write32(mmiobase + PF_CTL(0), 0); |
| 217 | write32(mmiobase + PF_WIN_SZ(0), 0); |
| 218 | write32(mmiobase + PF_WIN_POS(0), 0); |
| 219 | write32(mmiobase + PFIT_PGM_RATIOS, 0); |
| 220 | write32(mmiobase + PFIT_CONTROL, 0); |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 221 | } else { |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 222 | write32(mmiobase + PF_WIN_SZ(0), vactive | (hactive << 16)); |
| 223 | write32(mmiobase + PF_WIN_POS(0), 0); |
| 224 | write32(mmiobase + PF_CTL(0), PF_ENABLE | PF_FILTER_MED_3x3); |
| 225 | write32(mmiobase + PFIT_CONTROL, PFIT_ENABLE |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 226 | | (1 << PFIT_PIPE_SHIFT) | HORIZ_AUTO_SCALE |
| 227 | | VERT_AUTO_SCALE); |
| 228 | } |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 229 | |
| 230 | mdelay(1); |
| 231 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 232 | write32(mmiobase + DSPCNTR(0), DISPPLANE_BGRX888 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 233 | | DISPPLANE_SEL_PIPE_B | DISPPLANE_GAMMA_ENABLE); |
| 234 | |
| 235 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 236 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS |
| 237 | | (read32(mmiobase + PP_CONTROL) & ~PANEL_UNLOCK_MASK)); |
| 238 | write32(mmiobase + FP0(1), |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 239 | (pixel_n << 16) |
| 240 | | (pixel_m1 << 8) | pixel_m2); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 241 | write32(mmiobase + DPLL(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 242 | DPLL_VGA_MODE_DIS | |
| 243 | DPLL_VCO_ENABLE | DPLLB_MODE_LVDS |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 244 | | (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 245 | : DPLLB_LVDS_P2_CLOCK_DIV_14) |
| 246 | | (conf->gpu_lvds_use_spread_spectrum_clock |
| 247 | ? DPLL_INTEGRATED_CLOCK_VLV | DPLL_INTEGRATED_CRI_CLK_VLV |
| 248 | : 0) |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 249 | | (0x10000 << (pixel_p1 - 1))); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 250 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 251 | write32(mmiobase + DPLL(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 252 | DPLL_VGA_MODE_DIS | |
| 253 | DPLL_VCO_ENABLE | DPLLB_MODE_LVDS |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 254 | | (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 255 | : DPLLB_LVDS_P2_CLOCK_DIV_14) |
| 256 | | ((conf->gpu_lvds_use_spread_spectrum_clock ? 3 : 0) << 13) |
Arthur Heymans | 7dfc8a5 | 2016-09-02 22:35:32 +0200 | [diff] [blame] | 257 | | (0x10000 << (pixel_p1 - 1))); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 258 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 259 | write32(mmiobase + HTOTAL(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 260 | ((hactive + right_border + hblank - 1) << 16) |
| 261 | | (hactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 262 | write32(mmiobase + HBLANK(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 263 | ((hactive + right_border + hblank - 1) << 16) |
| 264 | | (hactive + right_border - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 265 | write32(mmiobase + HSYNC(1), |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 266 | ((hactive + right_border + hfront_porch + hsync - 1) << 16) |
| 267 | | (hactive + right_border + hfront_porch - 1)); |
| 268 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 269 | write32(mmiobase + VTOTAL(1), ((vactive + bottom_border + vblank - 1) << 16) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 270 | | (vactive - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 271 | write32(mmiobase + VBLANK(1), ((vactive + bottom_border + vblank - 1) << 16) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 272 | | (vactive + bottom_border - 1)); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 273 | write32(mmiobase + VSYNC(1), |
Arthur Heymans | c8c73a6 | 2016-10-13 14:12:45 +0200 | [diff] [blame] | 274 | ((vactive + bottom_border + vfront_porch + vsync - 1) << 16) |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 275 | | (vactive + bottom_border + vfront_porch - 1)); |
| 276 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 277 | if (CONFIG(LINEAR_FRAMEBUFFER)) { |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 278 | write32(mmiobase + PIPESRC(1), ((hactive - 1) << 16) |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 279 | | (vactive - 1)); |
| 280 | } else { |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 281 | write32(mmiobase + PIPESRC(1), (639 << 16) | 399); |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 282 | } |
| 283 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 284 | mdelay(1); |
| 285 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 286 | write32(mmiobase + DSPSIZE(0), (hactive - 1) | ((vactive - 1) << 16)); |
| 287 | write32(mmiobase + DSPPOS(0), 0); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 288 | |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 289 | edid.bytes_per_line = (edid.bytes_per_line + 63) & ~63; |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 290 | write32(mmiobase + DSPADDR(0), 0); |
| 291 | write32(mmiobase + DSPSURF(0), 0); |
| 292 | write32(mmiobase + DSPSTRIDE(0), edid.bytes_per_line); |
| 293 | write32(mmiobase + DSPCNTR(0), DISPLAY_PLANE_ENABLE | DISPPLANE_BGRX888 |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 294 | | DISPPLANE_SEL_PIPE_B | DISPPLANE_GAMMA_ENABLE); |
| 295 | mdelay(1); |
| 296 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 297 | write32(mmiobase + PIPECONF(1), PIPECONF_ENABLE); |
| 298 | write32(mmiobase + LVDS, LVDS_ON |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 299 | | (hpolarity << 20) | (vpolarity << 21) |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 300 | | (mode->lvds_dual_channel ? LVDS_CLOCK_B_POWERUP_ALL |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 301 | | LVDS_CLOCK_BOTH_POWERUP_ALL : 0) |
| 302 | | LVDS_CLOCK_A_POWERUP_ALL |
| 303 | | LVDS_PIPE(1)); |
| 304 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 305 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_OFF); |
| 306 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_RESET); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 307 | mdelay(1); |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 308 | write32(mmiobase + PP_CONTROL, PANEL_UNLOCK_REGS |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 309 | | PANEL_POWER_ON | PANEL_POWER_RESET); |
| 310 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 311 | printk(BIOS_DEBUG, "waiting for panel powerup\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 312 | while (1) { |
| 313 | u32 reg32; |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 314 | reg32 = read32(mmiobase + PP_STATUS); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 315 | if ((reg32 & PP_SEQUENCE_MASK) == PP_SEQUENCE_NONE) |
| 316 | break; |
| 317 | } |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 318 | printk(BIOS_DEBUG, "panel powered up\n"); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 319 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 320 | write32(mmiobase + PP_CONTROL, PANEL_POWER_ON | PANEL_POWER_RESET); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 321 | |
| 322 | /* Clear interrupts. */ |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 323 | write32(mmiobase + DEIIR, 0xffffffff); |
| 324 | write32(mmiobase + SDEIIR, 0xffffffff); |
| 325 | write32(mmiobase + IIR, 0xffffffff); |
| 326 | write32(mmiobase + IMR, 0xffffffff); |
| 327 | write32(mmiobase + EIR, 0xffffffff); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 328 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 329 | if (gtt_setup(mmiobase)) { |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 330 | printk(BIOS_ERR, "ERROR: GTT Setup Failed!!!\n"); |
| 331 | return 0; |
| 332 | } |
| 333 | |
| 334 | /* Setup GTT. */ |
| 335 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 336 | reg16 = pci_read_config16(pcidev_on_root(0, 0), GGC); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 337 | uma_size = 0; |
| 338 | if (!(reg16 & 2)) { |
Arthur Heymans | 874a8f9 | 2016-05-19 16:06:09 +0200 | [diff] [blame] | 339 | uma_size = decode_igd_memory_size((reg16 >> 4) & 7); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 340 | printk(BIOS_DEBUG, "%dM UMA\n", uma_size >> 10); |
| 341 | } |
| 342 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 343 | for (i = 0; i < (uma_size - 256) / 4; i++) { |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 344 | outl((i << 2) | 1, piobase); |
| 345 | outl(pphysbase + (i << 12) + 1, piobase + 4); |
| 346 | } |
| 347 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 348 | temp = read32(mmiobase + PGETBL_CTL); |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 349 | printk(BIOS_INFO, "GTT PGETBL_CTL register: 0x%lx\n", temp); |
| 350 | |
| 351 | if (temp & 1) |
| 352 | printk(BIOS_INFO, "GTT Enabled\n"); |
| 353 | else |
| 354 | printk(BIOS_ERR, "ERROR: GTT is still Disabled!!!\n"); |
| 355 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 356 | if (CONFIG(LINEAR_FRAMEBUFFER)) { |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 357 | printk(BIOS_SPEW, "memset %p to 0x00 for %d bytes\n", |
| 358 | (void *)pgfx, hactive * vactive * 4); |
| 359 | memset((void *)pgfx, 0x00, hactive * vactive * 4); |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 360 | |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 361 | set_vbe_mode_info_valid(&edid, pgfx); |
| 362 | } else { |
| 363 | vga_misc_write(0x67); |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 364 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 365 | write32(mmiobase + DSPCNTR(0), DISPPLANE_SEL_PIPE_B); |
| 366 | write32(mmiobase + VGACNTRL, 0x02c4008e |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 367 | | VGA_PIPE_B_SELECT); |
Vladimir Serbinenko | 0092c99 | 2014-08-21 01:06:53 +0200 | [diff] [blame] | 368 | |
Arthur Heymans | 9c5fc62 | 2016-10-18 02:15:44 +0200 | [diff] [blame] | 369 | vga_textmode_init(); |
| 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, |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 376 | u8 *mmiobase, unsigned int 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 | |
Arthur Heymans | 85cfddb | 2017-02-06 13:47:21 +0100 | [diff] [blame] | 383 | printk(BIOS_SPEW, "mmiobase %x addrport %x physbase %x\n", |
| 384 | (u32)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 | |
| 588 | |
| 589 | static void panel_setup(u8 *mmiobase, struct device *const dev) |
| 590 | { |
| 591 | const struct northbridge_intel_i945_config *const conf = dev->chip_info; |
| 592 | |
| 593 | u32 reg32; |
| 594 | |
| 595 | /* Set up Panel Power On Delays */ |
| 596 | reg32 = (conf->gpu_panel_power_up_delay & 0x1fff) << 16; |
| 597 | reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff); |
| 598 | write32(mmiobase + PP_ON_DELAYS, reg32); |
| 599 | |
| 600 | /* Set up Panel Power Off Delays */ |
| 601 | reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16; |
| 602 | reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff); |
| 603 | write32(mmiobase + PP_OFF_DELAYS, reg32); |
| 604 | |
| 605 | /* Set up Panel Power Cycle Delay */ |
| 606 | reg32 = (get_cdclk(dev) / 20000 - 1) << PP_REFERENCE_DIVIDER_SHIFT; |
| 607 | reg32 |= conf->gpu_panel_power_cycle_delay & 0x1f; |
| 608 | write32(mmiobase + PP_DIVISOR, reg32); |
| 609 | |
| 610 | /* Backlight init. */ |
| 611 | if (conf->pwm_freq) |
| 612 | write32(mmiobase + BLC_PWM_CTL, freq_to_blc_pwm_ctl(dev, |
| 613 | conf->pwm_freq)); |
| 614 | else |
| 615 | write32(mmiobase + BLC_PWM_CTL, freq_to_blc_pwm_ctl(dev, |
| 616 | DEFAULT_BLC_PWM)); |
| 617 | } |
Vladimir Serbinenko | 26ca08c | 2014-06-01 00:24:05 +0200 | [diff] [blame] | 618 | |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 619 | static void gma_ngi(struct device *const dev) |
| 620 | { |
| 621 | /* This should probably run before post VBIOS init. */ |
| 622 | printk(BIOS_INFO, "Initializing VGA without OPROM.\n"); |
| 623 | void *mmiobase; |
| 624 | u32 iobase, graphics_base; |
| 625 | struct northbridge_intel_i945_config *conf = dev->chip_info; |
| 626 | |
| 627 | iobase = dev->resource_list[1].base; |
| 628 | mmiobase = (void *)(uintptr_t)dev->resource_list[0].base; |
| 629 | graphics_base = dev->resource_list[2].base; |
| 630 | |
| 631 | printk(BIOS_SPEW, "GMADR = 0x%08x GTTADR = 0x%08x\n", |
| 632 | pci_read_config32(dev, GMADR), pci_read_config32(dev, GTTADR)); |
| 633 | |
| 634 | int err; |
| 635 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 636 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 637 | panel_setup(mmiobase, dev); |
| 638 | |
| 639 | /* probe if VGA is connected and always run */ |
| 640 | /* VGA init if no LVDS is connected */ |
| 641 | if (!probe_edid(mmiobase, GMBUS_PORT_PANEL) || |
| 642 | probe_edid(mmiobase, GMBUS_PORT_VGADDC)) |
| 643 | err = intel_gma_init_vga(conf, |
| 644 | pci_read_config32(dev, 0x5c) & ~0xf, |
| 645 | iobase, mmiobase, graphics_base); |
| 646 | else |
| 647 | err = intel_gma_init_lvds(conf, |
| 648 | pci_read_config32(dev, 0x5c) & ~0xf, |
| 649 | iobase, mmiobase, graphics_base); |
| 650 | if (err == 0) |
| 651 | gfx_set_init_done(1); |
| 652 | /* Linux relies on VBT for panel info. */ |
Julius Werner | 5d1f9a0 | 2019-03-07 17:07:26 -0800 | [diff] [blame] | 653 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) { |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 654 | generate_fake_intel_oprom(&conf->gfx, dev, "$VBT CALISTOGA"); |
| 655 | } |
Julius Werner | 5d1f9a0 | 2019-03-07 17:07:26 -0800 | [diff] [blame] | 656 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Paul Menzel | b23833f | 2018-04-26 19:53:31 +0200 | [diff] [blame] | 657 | generate_fake_intel_oprom(&conf->gfx, dev, "$VBT LAKEPORT-G"); |
| 658 | } |
| 659 | } |
| 660 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 661 | static void gma_func0_init(struct device *dev) |
| 662 | { |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 663 | intel_gma_init_igd_opregion(); |
| 664 | |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 665 | /* Unconditionally reset graphics */ |
| 666 | pci_write_config8(dev, GDRST, 1); |
| 667 | udelay(50); |
| 668 | pci_write_config8(dev, GDRST, 0); |
| 669 | /* wait for device to finish */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 670 | while (pci_read_config8(dev, GDRST) & 1) |
| 671 | ; |
Patrick Georgi | 6444bd4 | 2012-07-06 11:31:39 +0200 | [diff] [blame] | 672 | |
Nico Huber | dd59762 | 2020-04-26 19:46:35 +0200 | [diff] [blame] | 673 | if (!CONFIG(NO_GFX_INIT)) |
| 674 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Denis 'GNUtoo' Carikli | ed7e29e | 2013-02-24 12:01:44 +0100 | [diff] [blame] | 675 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 676 | if (CONFIG(MAINBOARD_DO_NATIVE_VGA_INIT)) { |
Elyes HAOUAS | 8881d57 | 2019-07-14 09:16:58 +0200 | [diff] [blame] | 677 | int vga_disable = (pci_read_config16(dev, GGC) & 2) >> 1; |
Arthur Heymans | e6c8f7e | 2018-08-09 11:31:51 +0200 | [diff] [blame] | 678 | if (acpi_is_wakeup_s3()) { |
Paul Menzel | 5e7ad65 | 2018-04-14 20:08:54 +0200 | [diff] [blame] | 679 | printk(BIOS_INFO, |
| 680 | "Skipping native VGA initialization when resuming from ACPI S3.\n"); |
Arthur Heymans | e6c8f7e | 2018-08-09 11:31:51 +0200 | [diff] [blame] | 681 | } else { |
| 682 | if (vga_disable) { |
| 683 | printk(BIOS_INFO, |
| 684 | "IGD is not decoding legacy VGA MEM and IO: skipping NATIVE graphic init\n"); |
| 685 | } else { |
| 686 | gma_ngi(dev); |
| 687 | } |
| 688 | } |
Arthur Heymans | f3f4bea | 2016-10-20 20:44:54 +0200 | [diff] [blame] | 689 | } else { |
| 690 | /* PCI Init, will run VBIOS */ |
| 691 | pci_dev_init(dev); |
Arthur Heymans | 333176e | 2016-09-07 22:10:57 +0200 | [diff] [blame] | 692 | } |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 693 | } |
| 694 | |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 695 | /* This doesn't reclaim stolen UMA memory, but IGD could still |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 696 | be re-enabled later. */ |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 697 | static void gma_func0_disable(struct device *dev) |
| 698 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 699 | struct device *dev_host = pcidev_on_root(0x0, 0); |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 700 | |
| 701 | pci_write_config16(dev, GCFC, 0xa00); |
| 702 | pci_write_config16(dev_host, GGC, (1 << 1)); |
| 703 | |
| 704 | unsigned int reg32 = pci_read_config32(dev_host, DEVEN); |
| 705 | reg32 &= ~(DEVEN_D2F0 | DEVEN_D2F1); |
| 706 | pci_write_config32(dev_host, DEVEN, reg32); |
| 707 | |
| 708 | dev->enabled = 0; |
| 709 | } |
| 710 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 711 | static void gma_func1_init(struct device *dev) |
| 712 | { |
Alexander Couzens | c7a1a3e | 2016-03-09 10:42:58 +0100 | [diff] [blame] | 713 | u8 val; |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 714 | |
Nico Huber | dd59762 | 2020-04-26 19:46:35 +0200 | [diff] [blame] | 715 | if (!CONFIG(NO_GFX_INIT)) |
| 716 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Sven Schnelle | b629d14 | 2011-06-12 14:30:10 +0200 | [diff] [blame] | 717 | |
Alexander Couzens | c7a1a3e | 2016-03-09 10:42:58 +0100 | [diff] [blame] | 718 | if (get_option(&val, "tft_brightness") == CB_SUCCESS) |
| 719 | pci_write_config8(dev, 0xf4, val); |
| 720 | else |
| 721 | pci_write_config8(dev, 0xf4, 0xff); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 724 | static void gma_generate_ssdt(const struct device *device) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 725 | { |
Matt DeVillier | fd054bc | 2020-03-30 22:18:45 -0500 | [diff] [blame] | 726 | const struct northbridge_intel_i945_config *chip = device->chip_info; |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 727 | |
Matt DeVillier | fd054bc | 2020-03-30 22:18:45 -0500 | [diff] [blame] | 728 | drivers_intel_gma_displays_ssdt_generate(&chip->gfx); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 729 | } |
| 730 | |
Elyes HAOUAS | 658a934 | 2018-02-08 14:46:22 +0100 | [diff] [blame] | 731 | static void gma_func0_read_resources(struct device *dev) |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 732 | { |
| 733 | u8 reg8; |
| 734 | |
| 735 | /* Set Untrusted Aperture Size to 256mb */ |
| 736 | reg8 = pci_read_config8(dev, MSAC); |
| 737 | reg8 &= ~0x3; |
| 738 | reg8 |= 0x2; |
| 739 | pci_write_config8(dev, MSAC, reg8); |
| 740 | |
| 741 | pci_dev_read_resources(dev); |
| 742 | } |
| 743 | |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 744 | static const char *gma_acpi_name(const struct device *dev) |
| 745 | { |
| 746 | return "GFX0"; |
| 747 | } |
| 748 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 749 | static struct pci_operations gma_pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 750 | .set_subsystem = pci_dev_set_subsystem, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 751 | }; |
| 752 | |
| 753 | static struct device_operations gma_func0_ops = { |
Arthur Heymans | c057a061 | 2016-10-22 14:16:48 +0200 | [diff] [blame] | 754 | .read_resources = gma_func0_read_resources, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 755 | .set_resources = pci_dev_set_resources, |
| 756 | .enable_resources = pci_dev_enable_resources, |
| 757 | .init = gma_func0_init, |
Matt DeVillier | fd054bc | 2020-03-30 22:18:45 -0500 | [diff] [blame] | 758 | .acpi_fill_ssdt = gma_generate_ssdt, |
Patrick Georgi | ce6e9fe | 2012-07-20 12:37:06 +0200 | [diff] [blame] | 759 | .disable = gma_func0_disable, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 760 | .ops_pci = &gma_pci_ops, |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 761 | .acpi_name = gma_acpi_name, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 762 | }; |
| 763 | |
| 764 | |
| 765 | static struct device_operations gma_func1_ops = { |
| 766 | .read_resources = pci_dev_read_resources, |
| 767 | .set_resources = pci_dev_set_resources, |
| 768 | .enable_resources = pci_dev_enable_resources, |
| 769 | .init = gma_func1_init, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 770 | .ops_pci = &gma_pci_ops, |
| 771 | }; |
| 772 | |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 773 | static const unsigned short i945_gma_func0_ids[] = { |
| 774 | 0x2772, /* 82945G/GZ Integrated Graphics Controller */ |
| 775 | 0x27a2, /* Mobile 945GM/GMS Express Integrated Graphics Controller*/ |
| 776 | 0x27ae, /* Mobile 945GSE Express Integrated Graphics Controller */ |
| 777 | 0 |
| 778 | }; |
| 779 | |
| 780 | static const unsigned short i945_gma_func1_ids[] = { |
Elyes HAOUAS | 686b539 | 2019-05-18 13:36:03 +0200 | [diff] [blame] | 781 | 0x2776, /* Desktop 82945G/GZ/GC */ |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 782 | 0x27a6, /* Mobile 945GM/GMS/GME Express Integrated Graphics Controller */ |
| 783 | 0 |
| 784 | }; |
Vladimir Serbinenko | 10dd0e3 | 2014-11-17 00:07:12 +0100 | [diff] [blame] | 785 | |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 786 | static const struct pci_driver i945_gma_func0_driver __pci_driver = { |
Paul Menzel | 82683c0 | 2018-04-14 19:56:46 +0200 | [diff] [blame] | 787 | .ops = &gma_func0_ops, |
| 788 | .vendor = PCI_VENDOR_ID_INTEL, |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 789 | .devices = i945_gma_func0_ids, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 790 | }; |
| 791 | |
| 792 | static const struct pci_driver i945_gma_func1_driver __pci_driver = { |
Paul Menzel | 82683c0 | 2018-04-14 19:56:46 +0200 | [diff] [blame] | 793 | .ops = &gma_func1_ops, |
| 794 | .vendor = PCI_VENDOR_ID_INTEL, |
Elyes HAOUAS | a299345 | 2016-10-28 10:56:59 +0200 | [diff] [blame] | 795 | .devices = i945_gma_func1_ids, |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 796 | }; |