From patchwork Thu Sep 12 17:45:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 13802391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39010EED632 for ; Thu, 12 Sep 2024 17:45:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D30AA10EC0A; Thu, 12 Sep 2024 17:45:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XluhC9rX"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7FC2910EC02 for ; Thu, 12 Sep 2024 17:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726163142; x=1757699142; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=vD3dsU0+o6FnE9wGXDDlNUmh/O3uDvhr76srXOdEaY0=; b=XluhC9rXXoLcMGVB7Dsc1dNUsQJDP8Mr9lj9VouISUe4424MGyWCi3nT 3H8NT3OLN77ynebpXLilCErIKwB7DGR46dnDHtvvAroXZ1iuFBKRN/Qa2 Bj90T9iPXVgMr/k0b7GLO/vaIZ1Dl1ALXZYcsrCJG/8Vvf2qAlxLLZzDu ZcKUKmoqPkLcbSN2kTgIUKvQJHaWb2HDnv8fzjUwjHtOcz/b02Y0jTrzx JyVrphh/0/A3cqMpQYGQHNe2HCOmBciRt6CVd4Y6MUfyUpovXic8iJmA5 n0z4X2e4PIVh+YJYUpvpaCaJuvlujfvAFi0RiiE5Fzz/dAFqjJ8GAqD/p A==; X-CSE-ConnectionGUID: 3MSlDJ+2Sc68OfMQEraqTQ== X-CSE-MsgGUID: Tg7pwTvnREKasvz3NNJB7w== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="35609311" X-IronPort-AV: E=Sophos;i="6.10,223,1719903600"; d="scan'208";a="35609311" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 10:45:42 -0700 X-CSE-ConnectionGUID: cZquPA4vTeW/r+o0QePgag== X-CSE-MsgGUID: qT5OkI1kQaC/STUIyhQGBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,223,1719903600"; d="scan'208";a="67720144" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orviesa009.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 12 Sep 2024 10:45:42 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 12 Sep 2024 10:45:41 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 12 Sep 2024 10:45:41 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 12 Sep 2024 10:45:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FsgUKYPzWJvhceGcn9Vm4k3sDPwK6Cigoxe/pvmMqtUAvKu7SVgN7G9yNN/ClpAr3GUXmDRb3LNS/7Pm66NNS0TKh4erL2LKsmmoxxklD9BAvVSqfjW42I6VSDxovLtU7O2NkxgcmbQDOYfaq0vqjY6FG+aK+cWeT6PjzakWdMm4rS30nDYUhC5o919i9Akg9NLwTPy3N1hoHCitbEuufcS0uCQle7alUSZayodJX1/pKouJxMS0FLr3z30/3EaVFrcafp80p3oknG8J3vV5I17UR4djoGziEyzUSiPWS6klDnFUtybkI6UaMDIKAkx6teP3lFZxT4fRAiKd2+/l9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fSmW9jQ4+jR6RXue8uVBuvbDQRr8kq0SgRDR2aBN64A=; b=o8lPgabZVwAps2aXK+h17JhgSb0ZYM6Xl/fZdoYp9xxBEOY5GyhiQ/Vwjqa2gFnaCuZa4iL4Ysh+4MynHuT/CNEa3a1KY9ot2USej3gYi6wxWxhgsDkahgr/3NlFgeSu+ZPqiCSk6NcLJCWLjjZuiK2XKUbO3rHOUCPKRF12UcvHA0UExD3JM4HgcuA7sTmr3VPTGa0Vq+gFm9c8VcGL7gNEcoXjxquwi3kR5fVGQWzXLzISC3/r7XJctDDHK9r95SHfKfkovbVKrWkGtNxj0kXHOoi+33rUT7sXY+1kDpWS8IGtDsoO/688aQLKtHAJwRd6YKhel9VAQgS6DVBHiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB2854.namprd11.prod.outlook.com (2603:10b6:a02:c9::12) by IA0PR11MB7791.namprd11.prod.outlook.com (2603:10b6:208:401::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Thu, 12 Sep 2024 17:45:38 +0000 Received: from BYAPR11MB2854.namprd11.prod.outlook.com ([fe80::8a98:4745:7147:ed42]) by BYAPR11MB2854.namprd11.prod.outlook.com ([fe80::8a98:4745:7147:ed42%5]) with mapi id 15.20.7918.024; Thu, 12 Sep 2024 17:45:38 +0000 From: Rodrigo Vivi To: CC: Rodrigo Vivi , Jesse Barnes , Jani Nikula Subject: [PATCH] drm/i915/display: Convert i915_suspend into i9xx_display_sr Date: Thu, 12 Sep 2024 13:45:34 -0400 Message-ID: <20240912174534.425015-1-rodrigo.vivi@intel.com> X-Mailer: git-send-email 2.46.0 X-ClientProxiedBy: MW4PR03CA0254.namprd03.prod.outlook.com (2603:10b6:303:b4::19) To BYAPR11MB2854.namprd11.prod.outlook.com (2603:10b6:a02:c9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB2854:EE_|IA0PR11MB7791:EE_ X-MS-Office365-Filtering-Correlation-Id: 5722e933-8950-437a-cd5e-08dcd352b68b X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?tq38OTCS7n52w8yjrHfzLg9AtkzxmNk?= =?utf-8?q?n2YKc8ozAgKNSq63J9bamDXoVv4DM+y4ysj/bvlqDJoFsbOIokSgdzvFTRRYsvSU3?= =?utf-8?q?fYa18udIIQxXD+81EvjTcV/SWl7QEgS7nkPRlWOcyi4sE30z9WC6RH9bPHa4VSYRJ?=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9ICD4XpLoPeDPLjKvuRjCiFzcm/bXb0AmEEEa08exrQC7jyIB7s+YozEKecrS?= =?utf-8?q?YkWOk2VSE7dVqo4jyBpNI2V5R4VgIYldLabxx9nTxcghbOvhjx7M7I4L7nHDerwJY?= =?utf-8?q?mxjNJIijcH43F0nnxSkUTCx/QrT5TpmMeZe34JEah2iWLQQOVAiLCO2MDuyGWI9eQ?= =?utf-8?q?gI3LcznrzDYB6yfkKtJ6TGLMPiTmWJgnyaGJyYtMebSaFi54csBJzPMPQSedcQxHr?= =?utf-8?q?HZ0G3vE2vTXRnPbH0GrReIkkQQ7GH0zakhA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2854.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+NjU1lPa+FBrjzD8SuTgawSQ0E5M?= =?utf-8?q?g2LY+xSRIpVm2g/Y6a0x4ckg9TEZevNld8zx154lrl2DkofI1nLw02TxwzLJGHNX0?= =?utf-8?q?HwgiN5XxZgs2fYGGqIPktFLi4VdTVPsBAbwXCUNRG6B89hI5jU4b5r8VtFEcvYSV5?= =?utf-8?q?iPETUYR5QBUDJaPBClFfeqCcD6qaa3UD/MKSgT2Yz+RtZi40vbfZEj8sutF9vzxOa?= =?utf-8?q?1N2Mprf3pRpw+hmj5BxcIva0hutWoKfxaXl1B4Yc3FMYFy4z5jQQASVBhggMnNIpk?= =?utf-8?q?yk3IehN8C9O5FUuJvZExsCjkkK19lfjLWlZE2LuPlw2vFjo2CvinhH+QLkD0hcVRr?= =?utf-8?q?OMMAxISY+/AOqiC1BmefAoAJtSwttiE4qM1rhGH3lVFRZpKcoMi3DkW+NpqrzPnDy?= =?utf-8?q?dFqQRhm9Lug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feW0vI/cRrnSREAHcRxwu6dVbJk4S8Wl4+nctxd05?= =?utf-8?q?cJzRqLmcMnUkNvscfjYVJPQ/Dc5KZ+c2JfwdjQWAN9nWV0bw9sGIV7av9fP5gJxwl?= =?utf-8?q?k0rtAj3tIyIKOE3LO0ll5XEMGM5npFpWmet7SMonebm9pTrlvLYYWDEd5/WNuoDA4?= =?utf-8?q?qzRcWoQKg7AsSrC/zjC7TpNWHrJZWhl4mHRXVtwjWpCwtgHamqJaWoiBGQYRELujz?= =?utf-8?q?ViEAtHfDTt0NSPCLzuFxJUWaXib9TBOZGQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5722e933-8950-437a-cd5e-08dcd352b68b X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2854.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2024 17:45:38.6240 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pSd+9DbVkgJ0WOmSt7h8J8TLQF7Wru+kDtbhx+RFOSoBRGxm88V+PMnZZDo/J2QzMtDV+nlrvhJHDsjO07uE8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7791 X-OriginatorOrg: intel.com X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" These save & restore functions inside i915_suspend are old display functions to save and restore a bunch of display related registers. Move it under display and rename accordantly. Just don't move it entirely towards intel_display struct yet because it depends on drm_i915_private for the IS_MOBILE. While doing this conversion also update the MIT header using the new SPDX ones. Cc: Jesse Barnes Cc: Jani Nikula Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/Makefile | 2 +- .../gpu/drm/i915/display/i9xx_display_sr.c | 119 +++++++++++++++ .../gpu/drm/i915/display/i9xx_display_sr.h | 14 ++ drivers/gpu/drm/i915/i915_driver.c | 6 +- drivers/gpu/drm/i915/i915_suspend.c | 141 ------------------ drivers/gpu/drm/i915/i915_suspend.h | 14 -- 6 files changed, 137 insertions(+), 159 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/i9xx_display_sr.c create mode 100644 drivers/gpu/drm/i915/display/i9xx_display_sr.h delete mode 100644 drivers/gpu/drm/i915/i915_suspend.c delete mode 100644 drivers/gpu/drm/i915/i915_suspend.h diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index c63fa2133ccb..89f04bdbc27f 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -30,7 +30,6 @@ i915-y += \ i915_params.o \ i915_pci.o \ i915_scatterlist.o \ - i915_suspend.o \ i915_switcheroo.o \ i915_sysfs.o \ i915_utils.o \ @@ -219,6 +218,7 @@ i915-$(CONFIG_HWMON) += \ i915-y += \ display/hsw_ips.o \ display/i9xx_plane.o \ + display/i9xx_suspend.o \ display/i9xx_wm.o \ display/intel_alpm.o \ display/intel_atomic.o \ diff --git a/drivers/gpu/drm/i915/display/i9xx_display_sr.c b/drivers/gpu/drm/i915/display/i9xx_display_sr.c new file mode 100644 index 000000000000..211cf41119ad --- /dev/null +++ b/drivers/gpu/drm/i915/display/i9xx_display_sr.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2024 Intel Corporation + */ + +#include "i915_drv.h" +#include "i915_reg.h" +#include "i9xx_suspend.h" +#include "intel_de.h" +#include "intel_gmbus.h" +#include "intel_vga.h" +#include "intel_pci_config.h" + +static void intel_save_swf(struct drm_i915_private *i915) +{ + int i; + + /* Scratch space */ + if (DISPLAY_VER(i915) == 2 && IS_MOBILE(i915)) { + for (i = 0; i < 7; i++) { + i915->regfile.saveSWF0[i] = intel_de_read(i915, + SWF0(i915, i)); + i915->regfile.saveSWF1[i] = intel_de_read(i915, + SWF1(i915, i)); + } + for (i = 0; i < 3; i++) + i915->regfile.saveSWF3[i] = intel_de_read(i915, + SWF3(i915, i)); + } else if (DISPLAY_VER(i915) == 2) { + for (i = 0; i < 7; i++) + i915->regfile.saveSWF1[i] = intel_de_read(i915, + SWF1(i915, i)); + } else if (HAS_GMCH(i915)) { + for (i = 0; i < 16; i++) { + i915->regfile.saveSWF0[i] = intel_de_read(i915, + SWF0(i915, i)); + i915->regfile.saveSWF1[i] = intel_de_read(i915, + SWF1(i915, i)); + } + for (i = 0; i < 3; i++) + i915->regfile.saveSWF3[i] = intel_de_read(i915, + SWF3(i915, i)); + } +} + +static void intel_restore_swf(struct drm_i915_private *i915) +{ + int i; + + /* Scratch space */ + if (DISPLAY_VER(i915) == 2 && IS_MOBILE(i915)) { + for (i = 0; i < 7; i++) { + intel_de_write(i915, SWF0(i915, i), + i915->regfile.saveSWF0[i]); + intel_de_write(i915, SWF1(i915, i), + i915->regfile.saveSWF1[i]); + } + for (i = 0; i < 3; i++) + intel_de_write(i915, SWF3(i915, i), + i915->regfile.saveSWF3[i]); + } else if (DISPLAY_VER(i915) == 2) { + for (i = 0; i < 7; i++) + intel_de_write(i915, SWF1(i915, i), + i915->regfile.saveSWF1[i]); + } else if (HAS_GMCH(i915)) { + for (i = 0; i < 16; i++) { + intel_de_write(i915, SWF0(i915, i), + i915->regfile.saveSWF0[i]); + intel_de_write(i915, SWF1(i915, i), + i915->regfile.saveSWF1[i]); + } + for (i = 0; i < 3; i++) + intel_de_write(i915, SWF3(i915, i), + i915->regfile.saveSWF3[i]); + } +} + +void i9xx_display_sr_save(struct drm_i915_private *i915) +{ + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); + + if (!HAS_DISPLAY(i915)) + return; + + /* Display arbitration control */ + if (DISPLAY_VER(i915) <= 4) + i915->regfile.saveDSPARB = intel_de_read(i915, + DSPARB(i915)); + + if (DISPLAY_VER(i915) == 4) + pci_read_config_word(pdev, GCDGMBUS, + &i915->regfile.saveGCDGMBUS); + + intel_save_swf(i915); +} + +void i9xx_display_sr_restore(struct drm_i915_private *i915) +{ + struct intel_display *display = &i915->display; + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); + + if (!HAS_DISPLAY(i915)) + return; + + intel_restore_swf(i915); + + if (DISPLAY_VER(i915) == 4) + pci_write_config_word(pdev, GCDGMBUS, + i915->regfile.saveGCDGMBUS); + + /* Display arbitration */ + if (DISPLAY_VER(i915) <= 4) + intel_de_write(i915, DSPARB(i915), + i915->regfile.saveDSPARB); + + intel_vga_redisable(display); + + intel_gmbus_reset(i915); +} diff --git a/drivers/gpu/drm/i915/display/i9xx_display_sr.h b/drivers/gpu/drm/i915/display/i9xx_display_sr.h new file mode 100644 index 000000000000..d3598c729137 --- /dev/null +++ b/drivers/gpu/drm/i915/display/i9xx_display_sr.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2014 Intel Corporation + */ + +#ifndef __I9XX_DISPLAY_SR_H__ +#define __I9XX_DISPLAY_SR_H__ + +struct drm_i915_private; + +void i9xx_display_sr_save(struct drm_i915_private *i915); +void i9xx_display_sr_restore(struct drm_i915_private *i915); + +#endif diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c index f82aa313f854..e15bf3aa44f9 100644 --- a/drivers/gpu/drm/i915/i915_driver.c +++ b/drivers/gpu/drm/i915/i915_driver.c @@ -45,6 +45,7 @@ #include #include +#include "display/i9xx_display_sr.h" #include "display/intel_acpi.h" #include "display/intel_bw.h" #include "display/intel_cdclk.h" @@ -93,7 +94,6 @@ #include "i915_memcpy.h" #include "i915_perf.h" #include "i915_query.h" -#include "i915_suspend.h" #include "i915_switcheroo.h" #include "i915_sysfs.h" #include "i915_utils.h" @@ -1047,7 +1047,7 @@ static int i915_drm_suspend(struct drm_device *dev) intel_dpt_suspend(dev_priv); i915_ggtt_suspend(to_gt(dev_priv)->ggtt); - i915_save_display(dev_priv); + i9xx_display_sr_save(dev_priv); opregion_target_state = suspend_to_idle(dev_priv) ? PCI_D1 : PCI_D3cold; intel_opregion_suspend(display, opregion_target_state); @@ -1166,7 +1166,7 @@ static int i915_drm_resume(struct drm_device *dev) intel_dmc_resume(display); - i915_restore_display(dev_priv); + i9xx_display_sr_restore(dev_priv); intel_pps_unlock_regs_wa(display); intel_init_pch_refclk(dev_priv); diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c deleted file mode 100644 index 9d3d9b983032..000000000000 --- a/drivers/gpu/drm/i915/i915_suspend.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * Copyright 2008 (c) Intel Corporation - * Jesse Barnes - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "display/intel_de.h" -#include "display/intel_gmbus.h" -#include "display/intel_vga.h" - -#include "i915_drv.h" -#include "i915_reg.h" -#include "i915_suspend.h" -#include "intel_pci_config.h" - -static void intel_save_swf(struct drm_i915_private *dev_priv) -{ - int i; - - /* Scratch space */ - if (GRAPHICS_VER(dev_priv) == 2 && IS_MOBILE(dev_priv)) { - for (i = 0; i < 7; i++) { - dev_priv->regfile.saveSWF0[i] = intel_de_read(dev_priv, - SWF0(dev_priv, i)); - dev_priv->regfile.saveSWF1[i] = intel_de_read(dev_priv, - SWF1(dev_priv, i)); - } - for (i = 0; i < 3; i++) - dev_priv->regfile.saveSWF3[i] = intel_de_read(dev_priv, - SWF3(dev_priv, i)); - } else if (GRAPHICS_VER(dev_priv) == 2) { - for (i = 0; i < 7; i++) - dev_priv->regfile.saveSWF1[i] = intel_de_read(dev_priv, - SWF1(dev_priv, i)); - } else if (HAS_GMCH(dev_priv)) { - for (i = 0; i < 16; i++) { - dev_priv->regfile.saveSWF0[i] = intel_de_read(dev_priv, - SWF0(dev_priv, i)); - dev_priv->regfile.saveSWF1[i] = intel_de_read(dev_priv, - SWF1(dev_priv, i)); - } - for (i = 0; i < 3; i++) - dev_priv->regfile.saveSWF3[i] = intel_de_read(dev_priv, - SWF3(dev_priv, i)); - } -} - -static void intel_restore_swf(struct drm_i915_private *dev_priv) -{ - int i; - - /* Scratch space */ - if (GRAPHICS_VER(dev_priv) == 2 && IS_MOBILE(dev_priv)) { - for (i = 0; i < 7; i++) { - intel_de_write(dev_priv, SWF0(dev_priv, i), - dev_priv->regfile.saveSWF0[i]); - intel_de_write(dev_priv, SWF1(dev_priv, i), - dev_priv->regfile.saveSWF1[i]); - } - for (i = 0; i < 3; i++) - intel_de_write(dev_priv, SWF3(dev_priv, i), - dev_priv->regfile.saveSWF3[i]); - } else if (GRAPHICS_VER(dev_priv) == 2) { - for (i = 0; i < 7; i++) - intel_de_write(dev_priv, SWF1(dev_priv, i), - dev_priv->regfile.saveSWF1[i]); - } else if (HAS_GMCH(dev_priv)) { - for (i = 0; i < 16; i++) { - intel_de_write(dev_priv, SWF0(dev_priv, i), - dev_priv->regfile.saveSWF0[i]); - intel_de_write(dev_priv, SWF1(dev_priv, i), - dev_priv->regfile.saveSWF1[i]); - } - for (i = 0; i < 3; i++) - intel_de_write(dev_priv, SWF3(dev_priv, i), - dev_priv->regfile.saveSWF3[i]); - } -} - -void i915_save_display(struct drm_i915_private *dev_priv) -{ - struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); - - if (!HAS_DISPLAY(dev_priv)) - return; - - /* Display arbitration control */ - if (GRAPHICS_VER(dev_priv) <= 4) - dev_priv->regfile.saveDSPARB = intel_de_read(dev_priv, - DSPARB(dev_priv)); - - if (GRAPHICS_VER(dev_priv) == 4) - pci_read_config_word(pdev, GCDGMBUS, - &dev_priv->regfile.saveGCDGMBUS); - - intel_save_swf(dev_priv); -} - -void i915_restore_display(struct drm_i915_private *dev_priv) -{ - struct intel_display *display = &dev_priv->display; - struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); - - if (!HAS_DISPLAY(dev_priv)) - return; - - intel_restore_swf(dev_priv); - - if (GRAPHICS_VER(dev_priv) == 4) - pci_write_config_word(pdev, GCDGMBUS, - dev_priv->regfile.saveGCDGMBUS); - - /* Display arbitration */ - if (GRAPHICS_VER(dev_priv) <= 4) - intel_de_write(dev_priv, DSPARB(dev_priv), - dev_priv->regfile.saveDSPARB); - - intel_vga_redisable(display); - - intel_gmbus_reset(dev_priv); -} diff --git a/drivers/gpu/drm/i915/i915_suspend.h b/drivers/gpu/drm/i915/i915_suspend.h deleted file mode 100644 index e5a611ee3d15..000000000000 --- a/drivers/gpu/drm/i915/i915_suspend.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -/* - * Copyright © 2019 Intel Corporation - */ - -#ifndef __I915_SUSPEND_H__ -#define __I915_SUSPEND_H__ - -struct drm_i915_private; - -void i915_save_display(struct drm_i915_private *i915); -void i915_restore_display(struct drm_i915_private *i915); - -#endif /* __I915_SUSPEND_H__ */