2020-04-02 23:48:50 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2013-11-12 22:32:08 +01:00
|
|
|
|
|
|
|
#include <arch/io.h>
|
2019-03-03 07:01:05 +01:00
|
|
|
#include <device/mmio.h>
|
2013-11-12 22:32:08 +01:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <delay.h>
|
|
|
|
#include <device/device.h>
|
|
|
|
#include <device/pci.h>
|
|
|
|
#include <device/pci_ids.h>
|
|
|
|
#include <device/pci_ops.h>
|
2014-02-19 22:18:08 +01:00
|
|
|
#include <drivers/intel/gma/edid.h>
|
|
|
|
#include <drivers/intel/gma/i915.h>
|
2017-05-17 19:39:12 +02:00
|
|
|
#include <drivers/intel/gma/intel_bios.h>
|
2017-06-08 16:31:57 +02:00
|
|
|
#include <drivers/intel/gma/libgfxinit.h>
|
2014-02-19 22:18:08 +01:00
|
|
|
#include <pc80/vga.h>
|
2017-07-14 20:28:42 +02:00
|
|
|
#include <drivers/intel/gma/opregion.h>
|
2019-05-15 21:09:30 +02:00
|
|
|
#include <types.h>
|
2013-11-12 22:32:08 +01:00
|
|
|
|
|
|
|
#include "chip.h"
|
2020-02-17 13:08:53 +01:00
|
|
|
#include "ironlake.h"
|
2013-11-12 22:32:08 +01:00
|
|
|
|
|
|
|
/* some vga option roms are used for several chipsets but they only have one
|
|
|
|
* PCI ID in their header. If we encounter such an option rom, we need to do
|
2016-11-18 17:29:03 +01:00
|
|
|
* the mapping ourselves
|
2013-11-12 22:32:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
u32 map_oprom_vendev(u32 vendev)
|
|
|
|
{
|
|
|
|
u32 new_vendev = vendev;
|
|
|
|
|
2016-11-18 17:29:03 +01:00
|
|
|
/* none currently. */
|
2013-11-12 22:32:08 +01:00
|
|
|
|
|
|
|
return new_vendev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct resource *gtt_res = NULL;
|
|
|
|
|
2013-08-19 19:16:50 +02:00
|
|
|
u32 gtt_read(u32 reg)
|
2013-11-12 22:32:08 +01:00
|
|
|
{
|
2014-12-25 03:43:20 +01:00
|
|
|
return read32(res2mmio(gtt_res, reg, 0));
|
2013-11-12 22:32:08 +01:00
|
|
|
}
|
|
|
|
|
2013-08-19 19:16:50 +02:00
|
|
|
void gtt_write(u32 reg, u32 data)
|
2013-11-12 22:32:08 +01:00
|
|
|
{
|
2014-12-25 03:43:20 +01:00
|
|
|
write32(res2mmio(gtt_res, reg, 0), data);
|
2013-11-12 22:32:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GTT_RETRY 1000
|
intel/gma: Clarify code and use dedicated init for Google Peppy
Peppy had some issues with FUI. We decided it was time to create
peppy-specific gma.c and i915io.c files. Using yabel and the i915tool,
we generated a replay attack, then interpolated against the slippy
i915io.c to get something working.
Also, in preparation for moving code out of the mainboard gma.c to
generic driver code, we got rid of some hardcodes in the mainboard
gma.c that have no business being there. The worst were the
computation of gmch_[m,n] and it turns out that we had some
long-standing bugs related to confusion about 'bpp'. I've killed the
word bpp everywhere I could because there are at least 3 things that
correspond to bpp. We now have framebuffer, pipe, and panel bpp. The
names are long because I want to avoid all the mistakes we've all been
making in the last year :-) Sadly, that means a lot of changes not just
peppy-related, but they are simple and in a good cause.
The test pattern generation is driven by a global variable in
mainboard/peppy/gma.c. I've found in the past that it's very useful
to have a function like this available, as one can activate it while
using a jtag debugger: halt at the right place in ramstage, set the
variable to 1, continue. It's not enough code to worry about always
including.
The last hard-codes for M and N registers are gone, and the function
to set from generic intel_dp.c code works. To avoid screen trash on a
dev mode boot, which we liked but nobody else did :-), we now take the
time to put a pleasing background color that sort of doubles as a
power LED.
Rough timing is ramstage start is at 2.2, and dev setup is done at
3.3. These new platforms are depressingly slow to boot. Rom init alone
is taking 1.9 seconds. 13 years ago it was 3 seconds from power on to bash
prompt. These CPUs are at least 10x faster and take much longer to get going.
Future work, once we get this through, is to move more functions to the
intel driver, and combine the mainboard i915io.c into the mainboard gma.c.
That separation only existed because i915io.c was generated by a tool, and it
had lots of ugliness. Most ugliness is gone.
Old-Change-Id: I6a6295b423a41e263f82cef33eacb92a14163321
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-on: https://chromium-review.googlesource.com/170013
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Commit-Queue: Ronald Minnich <rminnich@chromium.org>
Tested-by: Ronald Minnich <rminnich@chromium.org>
Reviewed-by: Furquan Shaikh <furquan.m.shaikh@gmail.com>
(cherry picked from commit 8cdaf73e3602e15925859866714db4d5ec6c947d)
snow: Fix a typo in devicetree.cb that was breaking the snow build.
A typo in a recent change broke the snow build.
Old-Change-Id: I93074e68eb3d21510d974fd8e9c63b3947285afd
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://chromium-review.googlesource.com/171014
Reviewed-by: Ronald Minnich <rminnich@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
(cherry picked from commit 154876c126a6690930141df178485658533096d2)
Squashed a fix into the initial patch and updated nehalem/gma.c
to have a non-static gtt_poll.
Change-Id: I2f4342c610d87335411da1d6d405171dc80c1f14
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
Reviewed-on: http://review.coreboot.org/6657
Tested-by: build bot (Jenkins)
2013-09-20 01:45:22 +02:00
|
|
|
int gtt_poll(u32 reg, u32 mask, u32 value)
|
2013-11-12 22:32:08 +01:00
|
|
|
{
|
2019-10-24 05:44:42 +02:00
|
|
|
unsigned int try = GTT_RETRY;
|
2013-11-12 22:32:08 +01:00
|
|
|
u32 data;
|
|
|
|
|
|
|
|
while (try--) {
|
|
|
|
data = gtt_read(reg);
|
|
|
|
if ((data & mask) == value)
|
|
|
|
return 1;
|
|
|
|
udelay(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(BIOS_ERR, "GT init timeout\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gma_pm_init_post_vbios(struct device *dev)
|
|
|
|
{
|
2020-02-17 13:08:53 +01:00
|
|
|
struct northbridge_intel_ironlake_config *conf = dev->chip_info;
|
2013-11-12 22:32:08 +01:00
|
|
|
u32 reg32;
|
|
|
|
|
|
|
|
printk(BIOS_DEBUG, "GT Power Management Init (post VBIOS)\n");
|
|
|
|
|
|
|
|
/* Setup Digital Port Hotplug */
|
|
|
|
reg32 = gtt_read(0xc4030);
|
|
|
|
if (!reg32) {
|
|
|
|
reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2;
|
|
|
|
reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10;
|
|
|
|
reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18;
|
|
|
|
gtt_write(0xc4030, reg32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup Panel Power On Delays */
|
|
|
|
reg32 = gtt_read(0xc7208);
|
|
|
|
if (!reg32) {
|
|
|
|
reg32 = (conf->gpu_panel_port_select & 0x3) << 30;
|
|
|
|
reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16;
|
|
|
|
reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff);
|
|
|
|
gtt_write(0xc7208, reg32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup Panel Power Off Delays */
|
|
|
|
reg32 = gtt_read(0xc720c);
|
|
|
|
if (!reg32) {
|
|
|
|
reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16;
|
|
|
|
reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff);
|
|
|
|
gtt_write(0xc720c, reg32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup Panel Power Cycle Delay */
|
|
|
|
if (conf->gpu_panel_power_cycle_delay) {
|
|
|
|
reg32 = gtt_read(0xc7210);
|
|
|
|
reg32 &= ~0xff;
|
|
|
|
reg32 |= conf->gpu_panel_power_cycle_delay & 0xff;
|
|
|
|
gtt_write(0xc7210, reg32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable Backlight if needed */
|
|
|
|
if (conf->gpu_cpu_backlight) {
|
|
|
|
gtt_write(0x48250, (1 << 31));
|
|
|
|
gtt_write(0x48254, conf->gpu_cpu_backlight);
|
|
|
|
}
|
|
|
|
if (conf->gpu_pch_backlight) {
|
|
|
|
gtt_write(0xc8250, (1 << 31));
|
|
|
|
gtt_write(0xc8254, conf->gpu_pch_backlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-20 18:28:56 +02:00
|
|
|
/* Enable SCI to ACPI _GPE._L06 */
|
|
|
|
static void gma_enable_swsci(void)
|
|
|
|
{
|
|
|
|
u16 reg16;
|
|
|
|
|
|
|
|
/* clear DMISCI status */
|
|
|
|
reg16 = inw(DEFAULT_PMBASE + TCO1_STS);
|
|
|
|
reg16 &= DMISCI_STS;
|
|
|
|
outw(DEFAULT_PMBASE + TCO1_STS, reg16);
|
|
|
|
|
|
|
|
/* clear acpi tco status */
|
|
|
|
outl(DEFAULT_PMBASE + GPE0_STS, TCOSCI_STS);
|
|
|
|
|
|
|
|
/* enable acpi tco scis */
|
|
|
|
reg16 = inw(DEFAULT_PMBASE + GPE0_EN);
|
|
|
|
reg16 |= TCOSCI_EN;
|
|
|
|
outw(DEFAULT_PMBASE + GPE0_EN, reg16);
|
|
|
|
}
|
|
|
|
|
2013-11-12 22:32:08 +01:00
|
|
|
static void gma_func0_init(struct device *dev)
|
|
|
|
{
|
2020-04-26 17:01:25 +02:00
|
|
|
intel_gma_init_igd_opregion();
|
|
|
|
|
2020-04-26 19:46:35 +02:00
|
|
|
if (!CONFIG(NO_GFX_INIT))
|
|
|
|
pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
|
2013-11-12 22:32:08 +01:00
|
|
|
|
2019-10-01 22:02:31 +02:00
|
|
|
gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0);
|
|
|
|
if (!gtt_res || !gtt_res->base)
|
|
|
|
return;
|
2013-11-12 22:32:08 +01:00
|
|
|
|
2019-10-03 09:34:57 +02:00
|
|
|
if (!acpi_is_wakeup_s3() &&
|
|
|
|
CONFIG(MAINBOARD_USE_LIBGFXINIT)) {
|
2020-02-17 13:08:53 +01:00
|
|
|
struct northbridge_intel_ironlake_config *conf = dev->chip_info;
|
2018-07-17 16:59:38 +02:00
|
|
|
int lightup_ok;
|
|
|
|
printk(BIOS_SPEW, "Initializing VGA without OPROM.");
|
2013-11-12 22:32:08 +01:00
|
|
|
|
2018-07-17 16:59:38 +02:00
|
|
|
gma_gfxinit(&lightup_ok);
|
2017-05-22 13:49:22 +02:00
|
|
|
/* Linux relies on VBT for panel info. */
|
|
|
|
generate_fake_intel_oprom(&conf->gfx, dev,
|
|
|
|
"$VBT IRONLAKE-MOBILE");
|
|
|
|
} else {
|
|
|
|
/* PCI Init, will run VBIOS */
|
|
|
|
pci_dev_init(dev);
|
|
|
|
}
|
2013-11-12 22:32:08 +01:00
|
|
|
|
|
|
|
/* Post VBIOS init */
|
|
|
|
gma_pm_init_post_vbios(dev);
|
2017-06-20 18:28:56 +02:00
|
|
|
|
|
|
|
gma_enable_swsci();
|
2013-11-12 22:32:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gma_read_resources(struct device *dev)
|
|
|
|
{
|
|
|
|
pci_dev_read_resources(dev);
|
|
|
|
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
/* Set the graphics memory to write combining. */
|
|
|
|
res = find_resource(dev, PCI_BASE_ADDRESS_2);
|
|
|
|
if (res == NULL) {
|
|
|
|
printk(BIOS_DEBUG, "gma: memory resource not found.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
res->flags |= IORESOURCE_RESERVE | IORESOURCE_FIXED | IORESOURCE_ASSIGNED;
|
2016-09-13 21:27:22 +02:00
|
|
|
pci_write_config32(dev, PCI_BASE_ADDRESS_2, 0xd0000001);
|
|
|
|
pci_write_config32(dev, PCI_BASE_ADDRESS_2 + 4, 0);
|
2013-11-12 22:32:08 +01:00
|
|
|
res->base = (resource_t) 0xd0000000;
|
|
|
|
res->size = (resource_t) 0x10000000;
|
|
|
|
}
|
|
|
|
|
2020-04-25 06:59:21 +02:00
|
|
|
static void gma_generate_ssdt(const struct device *device)
|
2014-10-31 09:16:31 +01:00
|
|
|
{
|
2020-03-31 02:31:54 +02:00
|
|
|
const struct northbridge_intel_ironlake_config *chip = device->chip_info;
|
2014-10-31 09:16:31 +01:00
|
|
|
|
2020-03-31 02:31:54 +02:00
|
|
|
drivers_intel_gma_displays_ssdt_generate(&chip->gfx);
|
2014-10-31 09:16:31 +01:00
|
|
|
}
|
|
|
|
|
2013-11-12 22:32:08 +01:00
|
|
|
static struct device_operations gma_func0_ops = {
|
2020-03-31 02:31:54 +02:00
|
|
|
.read_resources = gma_read_resources,
|
|
|
|
.set_resources = pci_dev_set_resources,
|
|
|
|
.enable_resources = pci_dev_enable_resources,
|
|
|
|
.acpi_fill_ssdt = gma_generate_ssdt,
|
|
|
|
.init = gma_func0_init,
|
2020-05-31 00:03:28 +02:00
|
|
|
.ops_pci = &pci_dev_ops_pci,
|
2013-11-12 22:32:08 +01:00
|
|
|
};
|
|
|
|
|
2016-09-13 21:27:22 +02:00
|
|
|
static const unsigned short pci_device_ids[] = {
|
|
|
|
0x0046, 0x0102, 0x0106, 0x010a, 0x0112,
|
2013-11-12 22:32:08 +01:00
|
|
|
0x0116, 0x0122, 0x0126, 0x0156,
|
|
|
|
0x0166,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pci_driver gma __pci_driver = {
|
|
|
|
.ops = &gma_func0_ops,
|
|
|
|
.vendor = PCI_VENDOR_ID_INTEL,
|
|
|
|
.devices = pci_device_ids,
|
|
|
|
};
|