From patchwork Wed Nov 13 22:50:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 13874368 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 0F47ED637D0 for ; Wed, 13 Nov 2024 22:50:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 921BF10E75B; Wed, 13 Nov 2024 22:50:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="NXPYD3aI"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 48F4F10E742; Wed, 13 Nov 2024 22:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731538234; x=1763074234; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=lMGWCyC5CktOJ2i57Zox09HzK7iLVst3o1Sj4YEXpfI=; b=NXPYD3aIjYmLlNzh0/a78dQKzETaB+4fgRg4yNOAsE8OmW5SlBc7/zBy j02Dcrjpz/SZFCVEd9j3FQZlR82AmM9fZjUDcfrkdtEL//JgRw6gpKstJ sEl55bkgyqv9hcb5KqYFYarUYTpMS4ZPHpW7S35sz6n0m6doY/JItpNnB OnNtklIHqEt/0FzBReKYpMVcR3SPJP4VxgTFVFMwe25m790zZzkfu1ndY ucu89YoGndIF1mv7ciK7ZKZShSypCKM34/Gkx/7FEv+kTWUmPf8Cuk51Y JQspWeGGmesSUaY0czl1+PhbQnlFzMEQF5nbLejyvTFwL/lt/s99dpX8E A==; X-CSE-ConnectionGUID: H7FE4pmXTEWJYuDI8dDy6g== X-CSE-MsgGUID: Vh1SK+i7QAiWIjBhG4Z+xg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="53997863" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="53997863" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 14:50:34 -0800 X-CSE-ConnectionGUID: YV5dpEaPQxqX+/zOD0XsHQ== X-CSE-MsgGUID: DykWnnV/SdS9e3XVxRQn9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="93071985" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orviesa004.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 13 Nov 2024 14:50:34 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 13 Nov 2024 14:50:33 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Wed, 13 Nov 2024 14:50:33 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.46) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 13 Nov 2024 14:50:33 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HRvEHkLzn2AbLkGs1gisnRpe4EzFRgovf2jG3JhnSNcpVjs35LpgfdFMJkE4BTrSLN5o/ORECa/nVlSs8LOj6N35iC+ve1cbYnCVEcpytJ1/WNElxTC6OQZGlfBm6GgCwL3zkUulIxlc66s8mnYfEJYj59hnASE58t4fXTheZ6ZP/MemrNMcyd34h7xnOb+WI1aOsnsImz+zxh8PsPHN7Va9NhxcMapkb/KAK5J967HNN2IXFrp5iTKEDZZQCT/xSDXNIVQIO7N+bbojfDUTkw7+Q/VqUt2jIlwvUs9tzs8u7MWt2mz78g+7196Iog89aRG2sdUTibFo6PvQdTt6tg== 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=YZ+cIfdkSdVbMdciniTFBNDOF/y4TXB7ClXjjcTslss=; b=wilRUMVKFfrzutSLe5WTHGvTleE8huqPiOioXYpn5bnyh4Hh4ltHWp0EzxGAa/l1RMDovclDiX3Z/3utCjMCbS3fbua983fp7jcVeZqLEOWyujV3FmR5KeV7nv4+ewPIdvMdwO4sd+E0T97PYEnmq7tHKkTtbxUp5I8jjsZTX7Du7P9YQnqLhqp88yLlVRb3/aph8k5uH/WGU5hlHvCgYhHgJFB/3leDj6Cq/LU4chB0F/SQ02LDxDYpt2tUfIh2rBCcI2UAqGv5eDkR9g493g6XWCsQ4eQx5hgnoQ3MEMk+kYJqRbvGVhfNByZPEcUr+YGj1zNwnZr1FIZkTGeS4Q== 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 CH3PR11MB8416.namprd11.prod.outlook.com (2603:10b6:610:17f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Wed, 13 Nov 2024 22:50:25 +0000 Received: from BYAPR11MB2854.namprd11.prod.outlook.com ([fe80::8a98:4745:7147:ed42]) by BYAPR11MB2854.namprd11.prod.outlook.com ([fe80::8a98:4745:7147:ed42%7]) with mapi id 15.20.8114.020; Wed, 13 Nov 2024 22:50:25 +0000 From: Rodrigo Vivi To: , CC: Rodrigo Vivi , Jesse Barnes , Jani Nikula , "Jonathan Cavitt" Subject: [CI 2/7] drm/i915/display: Convert i915_suspend into i9xx_display_sr Date: Wed, 13 Nov 2024 17:50:11 -0500 Message-ID: <20241113225016.208673-2-rodrigo.vivi@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113225016.208673-1-rodrigo.vivi@intel.com> References: <20241113225016.208673-1-rodrigo.vivi@intel.com> X-ClientProxiedBy: MW2PR16CA0008.namprd16.prod.outlook.com (2603:10b6:907::21) To BYAPR11MB2854.namprd11.prod.outlook.com (2603:10b6:a02:c9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB2854:EE_|CH3PR11MB8416:EE_ X-MS-Office365-Filtering-Correlation-Id: e159ebdf-be0d-41d5-f160-08dd04358fd0 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|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?MzJSN+HF8KT9ZlmB+wGMn9Q+HUFP4qp?= =?utf-8?q?cqem/jrBg6jZRvJHHk0pN2Q35qE/J7dHFDq/CatoTRQVys09gqcpaeTGOU+hZTpgd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EDzRZ35p?= =?utf-8?q?ib869XxWj87u8bfJ9/8PwKyH3V0MTksDkaJnUS7dxMHJElRpjn1vW0shs2v9WSrG+?= =?utf-8?q?m+pHEKKvqVdre+itRmQtq4AOAokkxS587+MdcpxBGwVX6H+UUNzMfruhC7Yyj8EHr?= =?utf-8?q?9IXrOKzMKtjNy2islmxDj/jbAWAPz2kJ9zRBW+zkQJELJxXNYbWHQ/EKb8JepmAJo?= =?utf-8?q?xdJFc70pLInKdm7M/LCLMXT6Q2tM5Lfi66iqdTfThxm6tyw+TTGNu/nA9EW0WZIPf?= =?utf-8?q?zJZyIyZ6Juic4zjS8XllMhk4S8jhn4IOzQCg/OLu6sDafpqybCwkTyOos=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)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LRgDzfhZalmy+Adm0hIJeyelAkyt?= =?utf-8?q?U6lCosOxcIkm6Vna61Xo24pJlNkV8jsSXgubTv524qqDrrUU1VJ2YAQ2GuNR36m4U?= =?utf-8?q?x5VWd/qLzLpiwLoBgMEMaixnJWKilHzKb+i8jx745ZYpjfWlC+x7Sc5HM8IMiasfz?= =?utf-8?q?8XsoeOWOZmkm6uUwUbvZqnrfv93AW/85REQVzaurPSNiiIUy5Q07Q62/6bRssKYGj?= =?utf-8?q?SJyxSz6X96HWgfLOt03r9BKcyUClSGlbKO5SRugWjFnHrAZTSgNT5FgKL09z6f1F7?= =?utf-8?q?wNOT6fKTz7hjW3bOto24KS+OcDjme5hoWRVJ/Sv2i0q/qRTKSdTvYLGBslN5I7YiJ?= =?utf-8?q?gZ+O4KNpmLXYHDl6+pnChqlWqZXNgvrVkDO2cv806PdFw3xj3Y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04n52xW?= =?utf-8?q?s3liZ0yrtfTeRAEFIcVZB4chxmggawjcKvK3h9GnPMX8sNiAzTEzzY4Rtd2m4OnBi?= =?utf-8?q?7tJoHYbGmt3MJ7QUTwQQI0m4tYbwzdU8xGD7gZ64xu1w7j6mIBJgD5KaCbSXbWbYE?= =?utf-8?q?bdRn8/PHa8wOFAuQasA2KUf5TYVZSaLQdJ+2DFPAg0H2yhOCq62B/4eLneXgMCuj2?= =?utf-8?q?HkuAnUM3LzSrhzTAcmtWKFgo2gnWZjPIIRzCOw3st49hpNUlGrOGFLsr6sOOH6i8/?= =?utf-8?q?3y73hgXPiuZkN4AZWGaK8nXCS5Xwk1sqQQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e159ebdf-be0d-41d5-f160-08dd04358fd0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2854.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2024 22:50:25.1043 (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: Hrt5MIgqZJ6DOhTgPzdHId2RgRnvDwb2c3TYJg54UzNQWoGw2g/xjM9htZk9POSDEtUR9uvDGr37CjSLdp9ZnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB8416 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. v2: Fix Makefile and include (Jani) Removed vga and gmbus (Jani, Ville) Cc: Jesse Barnes Cc: Jani Nikula Reviewed-by: Jani Nikula Reviewed-by: Jonathan Cavitt Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/Makefile | 2 +- .../gpu/drm/i915/display/i9xx_display_sr.c | 95 ++++++++++++ .../gpu/drm/i915/display/i9xx_display_sr.h | 14 ++ drivers/gpu/drm/i915/i915_driver.c | 6 +- drivers/gpu/drm/i915/i915_suspend.c | 135 ------------------ drivers/gpu/drm/i915/i915_suspend.h | 14 -- 6 files changed, 113 insertions(+), 153 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 31710d98cad5..e465828d748f 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 \ @@ -220,6 +219,7 @@ i915-$(CONFIG_HWMON) += \ i915-y += \ display/hsw_ips.o \ display/i9xx_plane.o \ + display/i9xx_display_sr.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..4dd0ce267994 --- /dev/null +++ b/drivers/gpu/drm/i915/display/i9xx_display_sr.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2024 Intel Corporation + */ + +#include "i915_drv.h" +#include "i915_reg.h" +#include "i9xx_display_sr.h" +#include "intel_de.h" +#include "intel_gmbus.h" +#include "intel_pci_config.h" + +static void i9xx_display_save_swf(struct drm_i915_private *i915) +{ + int i; + + /* Scratch space */ + if (GRAPHICS_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 (GRAPHICS_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 i9xx_display_restore_swf(struct drm_i915_private *i915) +{ + int i; + + /* Scratch space */ + if (GRAPHICS_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 (GRAPHICS_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 (GRAPHICS_VER(i915) <= 4) + i915->regfile.saveDSPARB = intel_de_read(i915, DSPARB(i915)); + + if (GRAPHICS_VER(i915) == 4) + pci_read_config_word(pdev, GCDGMBUS, &i915->regfile.saveGCDGMBUS); + + i9xx_display_save_swf(i915); +} + +void i9xx_display_sr_restore(struct drm_i915_private *i915) +{ + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); + + if (!HAS_DISPLAY(i915)) + return; + + i9xx_display_restore_swf(i915); + + if (GRAPHICS_VER(i915) == 4) + pci_write_config_word(pdev, GCDGMBUS, i915->regfile.saveGCDGMBUS); + + /* Display arbitration */ + if (GRAPHICS_VER(i915) <= 4) + intel_de_write(i915, DSPARB(i915), i915->regfile.saveDSPARB); +} 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..30383758f97e --- /dev/null +++ b/drivers/gpu/drm/i915/display/i9xx_display_sr.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2024 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 420b54b61569..7ded0f4675a0 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" @@ -94,7 +95,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" @@ -1052,7 +1052,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); @@ -1171,7 +1171,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_vga_redisable(display); diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c deleted file mode 100644 index fb67b05cd864..000000000000 --- a/drivers/gpu/drm/i915/i915_suspend.c +++ /dev/null @@ -1,135 +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 "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 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); -} 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__ */