From nobody Wed Oct 8 05:57:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 323FF2749E6; Tue, 1 Jul 2025 12:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372584; cv=none; b=XrN+8G9ZsqckMwIiDEBUPZROUHaDPJVtSZJO+6yRL1+d6gYFt4tywudGgwBdVT0rsgCBKY19nRfd/NW4H1Y8ApFsauZWKWqTYP2+WO4ffamRgWqJoZL4SeXOxsTD3tlJ8W0tLwByHrtPJlyFvcYyq5m096UNW8Vf8kuqaBDzl6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372584; c=relaxed/simple; bh=xqnSqFWVDFEdXMupII25qfhOfaCrf8mtjfBCLWS3law=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WvlIIZyDkMShr4+t3n5KblRW/RvpSC2GgHtE0hIiIpg3BuzyIELwrfcnUqP3apNZnV8iv6ea7XpXDYifwY7chUOs1Z2TL7PEekKwWiE+JVjAQg1671MgCmQQVpkCKftRmk4CG9QkYuDx6ES78CL1xv3+/0f/RONP+k6uIsiIWZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=U9RoPHoy; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="U9RoPHoy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751372583; x=1782908583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xqnSqFWVDFEdXMupII25qfhOfaCrf8mtjfBCLWS3law=; b=U9RoPHoyUtNDNQOpHm2Uyw7QpLHkJAxatN/gjuWRkrtwWk+DHIfb2Cn4 +BxFh3sMRxSUyC6N7wA1eYO8hTqSt7lAbtlBDNBd6VGIsKLXkMrBZfLGK luZhGRDHdp7II1ylh1rSHh7awXktobdKYMWiN+F3helliKrVK+FilbSUl JR7AJJ08XlNMNfuFEdvURqN9kuRgyNLo8fJR1UtCMGZit6mrUhjl0GldE f86rx6kxxlYh1bslhjs9Oij8gDt+3xLNd8b8BW2Zngl1vpAxlKrx29qP8 LAA5ZjLfnSy0Z8nSLh4+vyf3eqjua1tJAWC9cRSmTAbldCItFqS6B7fTp w==; X-CSE-ConnectionGUID: 2O87YIFcSEyrQcBEXJvA/A== X-CSE-MsgGUID: gEDx9NRZRdue323Z/FJ/Uw== X-IronPort-AV: E=McAfee;i="6800,10657,11481"; a="71196710" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="71196710" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 05:23:03 -0700 X-CSE-ConnectionGUID: ++ucMJKlRuq50S7eA+Hx+A== X-CSE-MsgGUID: T0PbFfzBRwSllAtX/se9AQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="153157409" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 01 Jul 2025 05:22:58 -0700 From: Heikki Krogerus To: Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi Cc: Jarkko Nikula , David Airlie , Simona Vetter , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti , Raag Jadav , "Tauro, Riana" , "Adatrao, Srinivasa" , "Michael J. Ruhl" , intel-xe@lists.freedesktop.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/5] i2c: designware: Use polling by default when there is no irq resource Date: Tue, 1 Jul 2025 15:22:48 +0300 Message-ID: <20250701122252.2590230-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> References: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The irq resource itself can be used as a generic way to determine when polling is needed. This not only removes the need for special additional device properties that would soon be needed when the platform may or may not have the irq, but it also removes the need to check the platform in the first place in order to determine is polling needed or not. Signed-off-by: Heikki Krogerus Reviewed-by: Andi Shyti --- Hi guys, I found the thread with Jarkko's comments from my archives. He wanted the local flags variable to be added because he wants the order of the calls to remain as it is now - the device is allocated only after the irq is checked. thanks, --- drivers/i2c/busses/i2c-designware-platdrv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/buss= es/i2c-designware-platdrv.c index 879719e91df2..3104f52e32be 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -205,25 +205,28 @@ static void i2c_dw_remove_lock_support(struct dw_i2c_= dev *dev) =20 static int dw_i2c_plat_probe(struct platform_device *pdev) { + u32 flags =3D (uintptr_t)device_get_match_data(&pdev->dev); struct device *device =3D &pdev->dev; struct i2c_adapter *adap; struct dw_i2c_dev *dev; int irq, ret; =20 - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) + irq =3D platform_get_irq_optional(pdev, 0); + if (irq =3D=3D -ENXIO) + flags |=3D ACCESS_POLLING; + else if (irq < 0) return irq; =20 dev =3D devm_kzalloc(device, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; =20 - dev->flags =3D (uintptr_t)device_get_match_data(device); if (device_property_present(device, "wx,i2c-snps-model")) - dev->flags =3D MODEL_WANGXUN_SP | ACCESS_POLLING; + flags =3D MODEL_WANGXUN_SP | ACCESS_POLLING; =20 dev->dev =3D device; dev->irq =3D irq; + dev->flags =3D flags; platform_set_drvdata(pdev, dev); =20 ret =3D dw_i2c_plat_request_regs(dev); --=20 2.47.2 From nobody Wed Oct 8 05:57:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0781C26FA4C; Tue, 1 Jul 2025 12:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372589; cv=none; b=Sv58fHzcQoeFw0SCWoxLjxjxCfBuQfMlTtlf1/xcrWIxlwifFhRyDEY4ewupfhB8qz2Z4F4l4jW9134pBDTYhmaOCDCjTFk2ijH8Mi9xLcVH51ZG9XvCo88KgtfqC4ZVVOw8HKw5u/92KI4OxXXAQgJQZXzwoXp7woJohfBFnoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372589; c=relaxed/simple; bh=B8nM8TPoVz+h8Y2qRsuyZ3hEtOKHl0HTxWPrOMZ2ExY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EPcCzHODcBKEV78c/woYYWxlKuZZXpP95/gkFkFZFEnok/71iWuG/TClJciWkY0LrlnBklBY+F39XeZSfmEu9oSccsxXQzTBs8RoMFMwz9qarfXZaccLQ8rIgUKQC/AJ1u0BnXnzym1hWUvMcwZSyQY+X8aHQIqVjLPDN9y1Gfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZdC+pYzl; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZdC+pYzl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751372588; x=1782908588; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B8nM8TPoVz+h8Y2qRsuyZ3hEtOKHl0HTxWPrOMZ2ExY=; b=ZdC+pYzlZIJbub1IASt9MWtj3WyI5+reu64pvbhoaxXruagWhlkzwNA6 bV1K71nNHzXM/7gi02D6Xgscg3RoJX2M1rL8eVOkVW8NJw9Wn1n4sHgZw WdY5psEEbDrR42zdPdGuo8RmkifFWB8eWIFuZus5UJUc4bwa/kSa3+NbX oU8XlG+NeXmkTw2ZZ3iOQILnYtYt/Gu3ePmYyKPa2LWLpgzCbCzSr6lqP jArWAYpUzmVeYJLeD7DQQ0WSEmCy42iGkPf7q7DDeCLem9G+tt+vylism 77R4ag2KZ+gduco/M7SxkLkCpXQTqy6iD+b3RyPM3PoKMV5GgO+CvDjfP Q==; X-CSE-ConnectionGUID: 4b7wfKldRYOV4cIfuUu7iA== X-CSE-MsgGUID: kEtz4XIMSTyMyzFYjBEhmw== X-IronPort-AV: E=McAfee;i="6800,10657,11481"; a="71196720" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="71196720" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 05:23:08 -0700 X-CSE-ConnectionGUID: f/p+ABNrTcaWeepzstRjaQ== X-CSE-MsgGUID: zT61w1LWTEGjxH55HuIb/A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="153157435" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 01 Jul 2025 05:23:03 -0700 From: Heikki Krogerus To: Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi Cc: Jarkko Nikula , David Airlie , Simona Vetter , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti , Raag Jadav , "Tauro, Riana" , "Adatrao, Srinivasa" , "Michael J. Ruhl" , intel-xe@lists.freedesktop.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/5] i2c: designware: Add quirk for Intel Xe Date: Tue, 1 Jul 2025 15:22:49 +0300 Message-ID: <20250701122252.2590230-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> References: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The regmap is coming from the parent also in case of Xe GPUs. Reusing the Wangxun quirk for that. Originally-by: Michael J. Ruhl Signed-off-by: Heikki Krogerus Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-designware-platdrv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/buss= es/i2c-designware-platdrv.c index 3104f52e32be..a35e4c64a1d4 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -101,7 +101,7 @@ static int bt1_i2c_request_regs(struct dw_i2c_dev *dev) } #endif =20 -static int txgbe_i2c_request_regs(struct dw_i2c_dev *dev) +static int dw_i2c_get_parent_regmap(struct dw_i2c_dev *dev) { dev->map =3D dev_get_regmap(dev->dev->parent, NULL); if (!dev->map) @@ -123,12 +123,15 @@ static int dw_i2c_plat_request_regs(struct dw_i2c_dev= *dev) struct platform_device *pdev =3D to_platform_device(dev->dev); int ret; =20 + if (device_is_compatible(dev->dev, "intel,xe-i2c")) + return dw_i2c_get_parent_regmap(dev); + switch (dev->flags & MODEL_MASK) { case MODEL_BAIKAL_BT1: ret =3D bt1_i2c_request_regs(dev); break; case MODEL_WANGXUN_SP: - ret =3D txgbe_i2c_request_regs(dev); + ret =3D dw_i2c_get_parent_regmap(dev); break; default: dev->base =3D devm_platform_ioremap_resource(pdev, 0); --=20 2.47.2 From nobody Wed Oct 8 05:57:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 432AC27702E; Tue, 1 Jul 2025 12:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372595; cv=none; b=f7G7bfoEuDp3SkXex7loyjMZdvfTuq/cg3JsUQj32n5AWC5IFfBN2k2PPkwpttVLNCbwz8fOglPB/1YgVDYEgHDUPoUBayyBkD48gbSCnrWFbN1tbYEh2SHl878gtQzLKeRgC5LpskSg5T64T+eD0tbMsmYvghF8k1aMnucJ0aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372595; c=relaxed/simple; bh=KCWalpCCBlE/2tTzqI1yAc9SNP0Gw6i5lcs1pfE9JW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MTdRMnImtA6PdNz3NA4O4TUY9SW+j/2veLeGJT+0y/Bpf3EbFFmzaMLbRvaInuxlowH5wTjXJI3KMMVi/4MaxQRo9kyVWwUgc+orimOGOGO8Rbk3ADArEHtwmkEfQlgMczRkw0JKJhgx4pfnEp34M+qnNDaiWjtabPzdb8K1td4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XXesbrIK; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XXesbrIK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751372593; x=1782908593; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KCWalpCCBlE/2tTzqI1yAc9SNP0Gw6i5lcs1pfE9JW4=; b=XXesbrIK+AcPYjipQ9kT46I24pSVr2Uw4KO52R3HvQh16chQIdfcmEc6 knoejLA2hkwoxslZBMpsCQAmL8fi8P0x1lOB9GYvrRJC7NFZhArBzxt5z 17C8WXpE1HTsxZI3VLFf1h1GBTXq78tsa1he7rpeJTeFvDSsDDOPQE3z5 9oyTqvKLAJyPBNMLnMU8P2PhzpUMxk4Q4N0O3Kt5kHP7RU52gnKeRspeM ft9TqSM7Oqwd+qSNJQTvibDUFcibFzRNmu/FSrjKWzVYbziF9l2Yy5QRN JRwdV0kNpW4Qz4JJ+BNx0wQ7gZNcyjWXy8+agB1+X+l6iZCRgXk6k2w63 A==; X-CSE-ConnectionGUID: 3BZyo+TPSECBSRTpXZQnzA== X-CSE-MsgGUID: PhMjwJBrS/u/o9aXbUSSYg== X-IronPort-AV: E=McAfee;i="6800,10657,11481"; a="71196727" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="71196727" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 05:23:13 -0700 X-CSE-ConnectionGUID: fjt7TjWGQb2Mk7obXgGAHg== X-CSE-MsgGUID: +oXjo3HST3GsyIFrdvdZCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="153157470" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 01 Jul 2025 05:23:08 -0700 From: Heikki Krogerus To: Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi Cc: Jarkko Nikula , David Airlie , Simona Vetter , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti , Raag Jadav , "Tauro, Riana" , "Adatrao, Srinivasa" , "Michael J. Ruhl" , intel-xe@lists.freedesktop.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti Subject: [PATCH v6 3/5] drm/xe: Support for I2C attached MCUs Date: Tue, 1 Jul 2025 15:22:50 +0300 Message-ID: <20250701122252.2590230-4-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> References: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adding adaption/glue layer where the I2C host adapter (Synopsys DesignWare I2C adapter) and the I2C clients (the microcontroller units) are enumerated. The microcontroller units (MCU) that are attached to the GPU depend on the OEM. The initially supported MCU will be the Add-In Management Controller (AMC). Originally-by: Michael J. Ruhl Signed-off-by: Heikki Krogerus Reviewed-by: Rodrigo Vivi Reviewed-by: Andi Shyti --- drivers/gpu/drm/xe/Kconfig | 1 + drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_i2c_regs.h | 15 ++ drivers/gpu/drm/xe/regs/xe_irq_regs.h | 1 + drivers/gpu/drm/xe/regs/xe_pmt.h | 2 +- drivers/gpu/drm/xe/regs/xe_regs.h | 2 + drivers/gpu/drm/xe/xe_device.c | 5 + drivers/gpu/drm/xe/xe_device_types.h | 4 + drivers/gpu/drm/xe/xe_i2c.c | 300 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_i2c.h | 58 +++++ drivers/gpu/drm/xe/xe_irq.c | 2 + 11 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xe/regs/xe_i2c_regs.h create mode 100644 drivers/gpu/drm/xe/xe_i2c.c create mode 100644 drivers/gpu/drm/xe/xe_i2c.h diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig index 827bc75b8b48..e78b3f46c846 100644 --- a/drivers/gpu/drm/xe/Kconfig +++ b/drivers/gpu/drm/xe/Kconfig @@ -45,6 +45,7 @@ config DRM_XE select WANT_DEV_COREDUMP select AUXILIARY_BUS select HMM_MIRROR + select REGMAP if I2C help Driver for Intel Xe2 series GPUs and later. Experimental support for Xe series is also available. diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index 1d97e5b63f4e..1201b8ab4702 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -125,6 +125,7 @@ xe-y +=3D xe_bb.o \ xe_wait_user_fence.o \ xe_wopcm.o =20 +xe-$(CONFIG_I2C) +=3D xe_i2c.o xe-$(CONFIG_HMM_MIRROR) +=3D xe_hmm.o xe-$(CONFIG_DRM_XE_GPUSVM) +=3D xe_svm.o =20 diff --git a/drivers/gpu/drm/xe/regs/xe_i2c_regs.h b/drivers/gpu/drm/xe/reg= s/xe_i2c_regs.h new file mode 100644 index 000000000000..92dae4487614 --- /dev/null +++ b/drivers/gpu/drm/xe/regs/xe_i2c_regs.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef _XE_I2C_REGS_H_ +#define _XE_I2C_REGS_H_ + +#include "xe_reg_defs.h" +#include "xe_regs.h" + +#define I2C_BRIDGE_OFFSET (SOC_BASE + 0xd9000) +#define I2C_CONFIG_SPACE_OFFSET (SOC_BASE + 0xf6000) +#define I2C_MEM_SPACE_OFFSET (SOC_BASE + 0xf7400) + +#define REG_SG_REMAP_ADDR_PREFIX XE_REG(SOC_BASE + 0x0164) +#define REG_SG_REMAP_ADDR_POSTFIX XE_REG(SOC_BASE + 0x0168) + +#endif /* _XE_I2C_REGS_H_ */ diff --git a/drivers/gpu/drm/xe/regs/xe_irq_regs.h b/drivers/gpu/drm/xe/reg= s/xe_irq_regs.h index f0ecfcac4003..13635e4331d4 100644 --- a/drivers/gpu/drm/xe/regs/xe_irq_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_irq_regs.h @@ -19,6 +19,7 @@ #define MASTER_IRQ REG_BIT(31) #define GU_MISC_IRQ REG_BIT(29) #define DISPLAY_IRQ REG_BIT(16) +#define I2C_IRQ REG_BIT(12) #define GT_DW_IRQ(x) REG_BIT(x) =20 /* diff --git a/drivers/gpu/drm/xe/regs/xe_pmt.h b/drivers/gpu/drm/xe/regs/xe_= pmt.h index b0efd9b48d1e..2995d72c3f78 100644 --- a/drivers/gpu/drm/xe/regs/xe_pmt.h +++ b/drivers/gpu/drm/xe/regs/xe_pmt.h @@ -5,7 +5,7 @@ #ifndef _XE_PMT_H_ #define _XE_PMT_H_ =20 -#define SOC_BASE 0x280000 +#include "xe_regs.h" =20 #define BMG_PMT_BASE_OFFSET 0xDB000 #define BMG_DISCOVERY_OFFSET (SOC_BASE + BMG_PMT_BASE_OFFSET) diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe= _regs.h index 3abb17d2ca33..1926b4044314 100644 --- a/drivers/gpu/drm/xe/regs/xe_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_regs.h @@ -7,6 +7,8 @@ =20 #include "regs/xe_reg_defs.h" =20 +#define SOC_BASE 0x280000 + #define GU_CNTL_PROTECTED XE_REG(0x10100C) #define DRIVERINT_FLR_DIS REG_BIT(31) =20 diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 0b73cb72bad1..6db09cfc8eb8 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -43,6 +43,7 @@ #include "xe_guc_pc.h" #include "xe_hw_engine_group.h" #include "xe_hwmon.h" +#include "xe_i2c.h" #include "xe_irq.h" #include "xe_mmio.h" #include "xe_module.h" @@ -902,6 +903,10 @@ int xe_device_probe(struct xe_device *xe) if (err) goto err_unregister_display; =20 + err =3D xe_i2c_probe(xe); + if (err) + goto err_unregister_display; + for_each_gt(gt, xe, id) xe_gt_sanitize_freq(gt); =20 diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_d= evice_types.h index 7e4f6d846af6..ce0c4ed834b8 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -34,6 +34,7 @@ struct dram_info; struct intel_display; struct intel_dg_nvm_dev; struct xe_ggtt; +struct xe_i2c; struct xe_pat_ops; struct xe_pxp; =20 @@ -583,6 +584,9 @@ struct xe_device { /** @pmu: performance monitoring unit */ struct xe_pmu pmu; =20 + /** @i2c: I2C host controller */ + struct xe_i2c *i2c; + /** @atomic_svm_timeslice_ms: Atomic SVM fault timeslice MS */ u32 atomic_svm_timeslice_ms; =20 diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c new file mode 100644 index 000000000000..ef91239879c0 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_i2c.c @@ -0,0 +1,300 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * Intel Xe I2C attached Microcontroller Units (MCU) + * + * Copyright (C) 2025 Intel Corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "regs/xe_i2c_regs.h" +#include "regs/xe_irq_regs.h" + +#include "xe_device.h" +#include "xe_device_types.h" +#include "xe_i2c.h" +#include "xe_mmio.h" +#include "xe_platform_types.h" + +/** + * DOC: Xe I2C devices + * + * Register a platform device for the I2C host controller (Synpsys DesignW= are + * I2C) if the registers of that controller are mapped to the MMIO, and al= so the + * I2C client device for the Add-In Management Controller (the MCU) attach= ed to + * the host controller. + * + * See drivers/i2c/busses/i2c-designware-* for more information on the I2C= host + * controller. + */ + +static const char adapter_name[] =3D "i2c_designware"; + +static const struct property_entry xe_i2c_adapter_properties[] =3D { + PROPERTY_ENTRY_STRING("compatible", "intel,xe-i2c"), + PROPERTY_ENTRY_U32("clock-frequency", I2C_MAX_FAST_MODE_PLUS_FREQ), + { } +}; + +static inline void xe_i2c_read_endpoint(struct xe_mmio *mmio, void *ep) +{ + u32 *val =3D ep; + + val[0] =3D xe_mmio_read32(mmio, REG_SG_REMAP_ADDR_PREFIX); + val[1] =3D xe_mmio_read32(mmio, REG_SG_REMAP_ADDR_POSTFIX); +} + +static void xe_i2c_client_work(struct work_struct *work) +{ + struct xe_i2c *i2c =3D container_of(work, struct xe_i2c, work); + struct i2c_board_info info =3D { + .type =3D "amc", + .flags =3D I2C_CLIENT_HOST_NOTIFY, + .addr =3D i2c->ep.addr[1], + }; + + i2c->client[0] =3D i2c_new_client_device(i2c->adapter, &info); +} + +static int xe_i2c_notifier(struct notifier_block *nb, unsigned long action= , void *data) +{ + struct xe_i2c *i2c =3D container_of(nb, struct xe_i2c, bus_notifier); + struct i2c_adapter *adapter =3D i2c_verify_adapter(data); + struct device *dev =3D data; + + if (action =3D=3D BUS_NOTIFY_ADD_DEVICE && + adapter && dev->parent =3D=3D &i2c->pdev->dev) { + i2c->adapter =3D adapter; + schedule_work(&i2c->work); + return NOTIFY_OK; + } + + return NOTIFY_DONE; +} + +static int xe_i2c_register_adapter(struct xe_i2c *i2c) +{ + struct pci_dev *pci =3D to_pci_dev(i2c->drm_dev); + struct platform_device *pdev; + struct fwnode_handle *fwnode; + int ret; + + fwnode =3D fwnode_create_software_node(xe_i2c_adapter_properties, NULL); + if (!fwnode) + return -ENOMEM; + + /* + * Not using platform_device_register_full() here because we don't have + * a handle to the platform_device before it returns. xe_i2c_notifier() + * uses that handle, but it may be called before + * platform_device_register_full() is done. + */ + pdev =3D platform_device_alloc(adapter_name, pci_dev_id(pci)); + if (!pdev) { + ret =3D -ENOMEM; + goto err_fwnode_remove; + } + + if (i2c->adapter_irq) { + struct resource res; + + res =3D DEFINE_RES_IRQ_NAMED(i2c->adapter_irq, "xe_i2c"); + + ret =3D platform_device_add_resources(pdev, &res, 1); + if (ret) + goto err_pdev_put; + } + + pdev->dev.parent =3D i2c->drm_dev; + pdev->dev.fwnode =3D fwnode; + i2c->adapter_node =3D fwnode; + i2c->pdev =3D pdev; + + ret =3D platform_device_add(pdev); + if (ret) + goto err_pdev_put; + + return 0; + +err_pdev_put: + platform_device_put(pdev); +err_fwnode_remove: + fwnode_remove_software_node(fwnode); + + return ret; +} + +static void xe_i2c_unregister_adapter(struct xe_i2c *i2c) +{ + platform_device_unregister(i2c->pdev); + fwnode_remove_software_node(i2c->adapter_node); +} + +/** + * xe_i2c_irq_handler: Handler for I2C interrupts + * @xe: xe device instance + * @master_ctl: interrupt register + * + * Forward interrupts generated by the I2C host adapter to the I2C host ad= apter + * driver. + */ +void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) +{ + if (!xe->i2c || !xe->i2c->adapter_irq) + return; + + if (master_ctl & I2C_IRQ) + generic_handle_irq_safe(xe->i2c->adapter_irq); +} + +static int xe_i2c_irq_map(struct irq_domain *h, unsigned int virq, + irq_hw_number_t hw_irq_num) +{ + irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq); + return 0; +} + +static const struct irq_domain_ops xe_i2c_irq_ops =3D { + .map =3D xe_i2c_irq_map, +}; + +static int xe_i2c_create_irq(struct xe_i2c *i2c) +{ + struct irq_domain *domain; + + if (!(i2c->ep.capabilities & XE_I2C_EP_CAP_IRQ)) + return 0; + + domain =3D irq_domain_create_linear(dev_fwnode(i2c->drm_dev), 1, &xe_i2c_= irq_ops, NULL); + if (!domain) + return -ENOMEM; + + i2c->adapter_irq =3D irq_create_mapping(domain, 0); + i2c->irqdomain =3D domain; + + return 0; +} + +static void xe_i2c_remove_irq(struct xe_i2c *i2c) +{ + if (!i2c->irqdomain) + return; + + irq_dispose_mapping(i2c->adapter_irq); + irq_domain_remove(i2c->irqdomain); +} + +static int xe_i2c_read(void *context, unsigned int reg, unsigned int *val) +{ + struct xe_i2c *i2c =3D context; + + *val =3D xe_mmio_read32(i2c->mmio, XE_REG(reg + I2C_MEM_SPACE_OFFSET)); + + return 0; +} + +static int xe_i2c_write(void *context, unsigned int reg, unsigned int val) +{ + struct xe_i2c *i2c =3D context; + + xe_mmio_write32(i2c->mmio, XE_REG(reg + I2C_MEM_SPACE_OFFSET), val); + + return 0; +} + +static const struct regmap_config i2c_regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_read =3D xe_i2c_read, + .reg_write =3D xe_i2c_write, + .fast_io =3D true, +}; + +static void xe_i2c_remove(void *data) +{ + struct xe_i2c *i2c =3D data; + unsigned int i; + + for (i =3D 0; i < XE_I2C_MAX_CLIENTS; i++) + i2c_unregister_device(i2c->client[i]); + + bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); + xe_i2c_unregister_adapter(i2c); + xe_i2c_remove_irq(i2c); +} + +/** + * xe_i2c_probe: Probe the I2C host adapter and the I2C clients attached t= o it + * @xe: xe device instance + * + * Register all the I2C devices described in the I2C Endpoint data structu= re. + * + * Return: 0 on success, error code on failure + */ +int xe_i2c_probe(struct xe_device *xe) +{ + struct device *drm_dev =3D xe->drm.dev; + struct xe_i2c_endpoint ep; + struct regmap *regmap; + struct xe_i2c *i2c; + int ret; + + if (xe->info.platform !=3D XE_BATTLEMAGE) + return 0; + + xe_i2c_read_endpoint(xe_root_tile_mmio(xe), &ep); + if (ep.cookie !=3D XE_I2C_EP_COOKIE_DEVICE) + return 0; + + i2c =3D devm_kzalloc(drm_dev, sizeof(*i2c), GFP_KERNEL); + if (!i2c) + return -ENOMEM; + + INIT_WORK(&i2c->work, xe_i2c_client_work); + i2c->mmio =3D xe_root_tile_mmio(xe); + i2c->drm_dev =3D drm_dev; + i2c->ep =3D ep; + + regmap =3D devm_regmap_init(drm_dev, NULL, i2c, &i2c_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + i2c->bus_notifier.notifier_call =3D xe_i2c_notifier; + ret =3D bus_register_notifier(&i2c_bus_type, &i2c->bus_notifier); + if (ret) + return ret; + + ret =3D xe_i2c_create_irq(i2c); + if (ret) + goto err_unregister_notifier; + + ret =3D xe_i2c_register_adapter(i2c); + if (ret) + goto err_remove_irq; + + return devm_add_action_or_reset(drm_dev, xe_i2c_remove, i2c); + +err_remove_irq: + xe_i2c_remove_irq(i2c); + +err_unregister_notifier: + bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); + + return ret; +} diff --git a/drivers/gpu/drm/xe/xe_i2c.h b/drivers/gpu/drm/xe/xe_i2c.h new file mode 100644 index 000000000000..7ea40f4e4aa4 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_i2c.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: MIT */ +#ifndef _XE_I2C_H_ +#define _XE_I2C_H_ + +#include +#include +#include +#include + +struct device; +struct fwnode_handle; +struct i2c_adapter; +struct i2c_client; +struct irq_domain; +struct platform_device; +struct xe_device; +struct xe_mmio; + +#define XE_I2C_MAX_CLIENTS 3 + +#define XE_I2C_EP_COOKIE_DEVICE 0xde + +/* Endpoint Capabilities */ +#define XE_I2C_EP_CAP_IRQ BIT(0) + +struct xe_i2c_endpoint { + u8 cookie; + u8 capabilities; + u16 addr[XE_I2C_MAX_CLIENTS]; +}; + +struct xe_i2c { + struct fwnode_handle *adapter_node; + struct platform_device *pdev; + struct i2c_adapter *adapter; + struct i2c_client *client[XE_I2C_MAX_CLIENTS]; + + struct notifier_block bus_notifier; + struct work_struct work; + + struct irq_domain *irqdomain; + int adapter_irq; + + struct xe_i2c_endpoint ep; + struct device *drm_dev; + + struct xe_mmio *mmio; +}; + +#if IS_ENABLED(CONFIG_I2C) +int xe_i2c_probe(struct xe_device *xe); +void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl); +#else +static inline int xe_i2c_probe(struct xe_device *xe) { return 0; } +static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl= ) { } +#endif + +#endif diff --git a/drivers/gpu/drm/xe/xe_irq.c b/drivers/gpu/drm/xe/xe_irq.c index 5362d3174b06..c43e62dc692e 100644 --- a/drivers/gpu/drm/xe/xe_irq.c +++ b/drivers/gpu/drm/xe/xe_irq.c @@ -18,6 +18,7 @@ #include "xe_gt.h" #include "xe_guc.h" #include "xe_hw_engine.h" +#include "xe_i2c.h" #include "xe_memirq.h" #include "xe_mmio.h" #include "xe_pxp.h" @@ -476,6 +477,7 @@ static irqreturn_t dg1_irq_handler(int irq, void *arg) if (xe->info.has_heci_cscfi) xe_heci_csc_irq_handler(xe, master_ctl); xe_display_irq_handler(xe, master_ctl); + xe_i2c_irq_handler(xe, master_ctl); gu_misc_iir =3D gu_misc_irq_ack(xe, master_ctl); } } --=20 2.47.2 From nobody Wed Oct 8 05:57:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96744277813; Tue, 1 Jul 2025 12:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372600; cv=none; b=cKgL7qr68T+xprH7mwAJmEX11kmoeHNVr18g8pKc5F/GvenHCO8oZEdC7s3ZcQM0DZsAp0CQZUiRTw6jgIVREjUiR4GbLR3xhodRhPYhrSMPzdbQPEZnj4Zz0KEDdHK1KAngfPQAXfF5NNZmCDoeAM1V4nb0Z+tf5qjX4KO2sUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372600; c=relaxed/simple; bh=Rc7OivDJNjRA9VAKR93l3lXEH93MlI9b8rIftpAFcwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UXiGUg4QwhMjT3q+j/uuAjPM5CE0/hbGkXiKKKtjWZGwdZs726144eBRnsS0+TCII2o2IZ0vRGh/3xn7FczAihLGXkPg4SQOO/Jb6fIlJXKmC1H0/4+RnZdfUqIONNxTOa7nju2jy9ArIom6KxnTm/+1U+s1mifh/AsEK97sphQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=a7yUwRnB; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="a7yUwRnB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751372599; x=1782908599; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Rc7OivDJNjRA9VAKR93l3lXEH93MlI9b8rIftpAFcwM=; b=a7yUwRnBGmdoVYddY5ftKtFkd/ocIvEI0fPQkmJ81oZUQ5ZvdJwmPpBq GR2MSHdICEHYasxUqz+CWcHZYj/StAOhtHMlXQoORADbVB3uN4q8GbZGn +IGcKGhQ8yYHUQp/4yCpNjVEHiiYcY2jMqW1m7Gt2HZc0P8PqDvi5icxf WoevFl98DgZ9PMOBQGuj6rD8cUJtKAZxFdZayAM5paX90yO8LvjTNQqeI 8qXHZ2mDUScIxVqllHFjEc4Te3h9+cKfbBxwTPjjBUpDLkCi37G8M6vjL PwgDCIJ3mBvbvGYZfpBfVRrrrVaNVEyix5/e0JtycBtalWKB4wmXw4kQk Q==; X-CSE-ConnectionGUID: B2UgL3bjRd2sQHVSHH+Uew== X-CSE-MsgGUID: q11BSm8sQ9ONuImsv+88bw== X-IronPort-AV: E=McAfee;i="6800,10657,11481"; a="71196738" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="71196738" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 05:23:18 -0700 X-CSE-ConnectionGUID: QZKXZb2RQBW1IEzXE+eU1g== X-CSE-MsgGUID: KvIzNQviToKtS7Cl2YSXMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="153157500" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 01 Jul 2025 05:23:13 -0700 From: Heikki Krogerus To: Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi Cc: Jarkko Nikula , David Airlie , Simona Vetter , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti , Raag Jadav , "Tauro, Riana" , "Adatrao, Srinivasa" , "Michael J. Ruhl" , intel-xe@lists.freedesktop.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Karthik Poosa , Andi Shyti Subject: [PATCH v6 4/5] drm/xe/pm: Wire up suspend/resume for I2C controller Date: Tue, 1 Jul 2025 15:22:51 +0300 Message-ID: <20250701122252.2590230-5-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> References: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Raag Jadav Wire up suspend/resume handles for I2C controller to match its power state with SGUnit. Signed-off-by: Raag Jadav Signed-off-by: Heikki Krogerus Reviewed-by: Karthik Poosa Reviewed-by: Andi Shyti --- drivers/gpu/drm/xe/regs/xe_i2c_regs.h | 5 +++++ drivers/gpu/drm/xe/xe_i2c.c | 29 +++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_i2c.h | 4 ++++ drivers/gpu/drm/xe/xe_pm.c | 9 +++++++++ 4 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/xe/regs/xe_i2c_regs.h b/drivers/gpu/drm/xe/reg= s/xe_i2c_regs.h index 92dae4487614..af781c8e4a80 100644 --- a/drivers/gpu/drm/xe/regs/xe_i2c_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_i2c_regs.h @@ -2,6 +2,8 @@ #ifndef _XE_I2C_REGS_H_ #define _XE_I2C_REGS_H_ =20 +#include + #include "xe_reg_defs.h" #include "xe_regs.h" =20 @@ -12,4 +14,7 @@ #define REG_SG_REMAP_ADDR_PREFIX XE_REG(SOC_BASE + 0x0164) #define REG_SG_REMAP_ADDR_POSTFIX XE_REG(SOC_BASE + 0x0168) =20 +#define I2C_CONFIG_CMD XE_REG(I2C_CONFIG_SPACE_OFFSET + PCI_COMMAND) +#define I2C_CONFIG_PMCSR XE_REG(I2C_CONFIG_SPACE_OFFSET + 0x84) + #endif /* _XE_I2C_REGS_H_ */ diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c index ef91239879c0..d395795d1e7e 100644 --- a/drivers/gpu/drm/xe/xe_i2c.c +++ b/drivers/gpu/drm/xe/xe_i2c.c @@ -226,6 +226,31 @@ static const struct regmap_config i2c_regmap_config = =3D { .fast_io =3D true, }; =20 +void xe_i2c_pm_suspend(struct xe_device *xe) +{ + struct xe_mmio *mmio =3D xe_root_tile_mmio(xe); + + if (!xe->i2c || xe->i2c->ep.cookie !=3D XE_I2C_EP_COOKIE_DEVICE) + return; + + xe_mmio_rmw32(mmio, I2C_CONFIG_PMCSR, PCI_PM_CTRL_STATE_MASK, (__force u3= 2)PCI_D3hot); + drm_dbg(&xe->drm, "pmcsr: 0x%08x\n", xe_mmio_read32(mmio, I2C_CONFIG_PMCS= R)); +} + +void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) +{ + struct xe_mmio *mmio =3D xe_root_tile_mmio(xe); + + if (!xe->i2c || xe->i2c->ep.cookie !=3D XE_I2C_EP_COOKIE_DEVICE) + return; + + if (d3cold) + xe_mmio_rmw32(mmio, I2C_CONFIG_CMD, 0, PCI_COMMAND_MEMORY); + + xe_mmio_rmw32(mmio, I2C_CONFIG_PMCSR, PCI_PM_CTRL_STATE_MASK, (__force u3= 2)PCI_D0); + drm_dbg(&xe->drm, "pmcsr: 0x%08x\n", xe_mmio_read32(mmio, I2C_CONFIG_PMCS= R)); +} + static void xe_i2c_remove(void *data) { struct xe_i2c *i2c =3D data; @@ -270,6 +295,10 @@ int xe_i2c_probe(struct xe_device *xe) i2c->mmio =3D xe_root_tile_mmio(xe); i2c->drm_dev =3D drm_dev; i2c->ep =3D ep; + xe->i2c =3D i2c; + + /* PCI PM isn't aware of this device, bring it up and match it with SGUni= t state. */ + xe_i2c_pm_resume(xe, true); =20 regmap =3D devm_regmap_init(drm_dev, NULL, i2c, &i2c_regmap_config); if (IS_ERR(regmap)) diff --git a/drivers/gpu/drm/xe/xe_i2c.h b/drivers/gpu/drm/xe/xe_i2c.h index 7ea40f4e4aa4..b767ed8ce52b 100644 --- a/drivers/gpu/drm/xe/xe_i2c.h +++ b/drivers/gpu/drm/xe/xe_i2c.h @@ -50,9 +50,13 @@ struct xe_i2c { #if IS_ENABLED(CONFIG_I2C) int xe_i2c_probe(struct xe_device *xe); void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl); +void xe_i2c_pm_suspend(struct xe_device *xe); +void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold); #else static inline int xe_i2c_probe(struct xe_device *xe) { return 0; } static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl= ) { } +static inline void xe_i2c_pm_suspend(struct xe_device *xe) { } +static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { } #endif =20 #endif diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 26e95460af87..46471e166b96 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -19,6 +19,7 @@ #include "xe_ggtt.h" #include "xe_gt.h" #include "xe_guc.h" +#include "xe_i2c.h" #include "xe_irq.h" #include "xe_pcode.h" #include "xe_pxp.h" @@ -146,6 +147,8 @@ int xe_pm_suspend(struct xe_device *xe) =20 xe_display_pm_suspend_late(xe); =20 + xe_i2c_pm_suspend(xe); + drm_dbg(&xe->drm, "Device suspended\n"); return 0; =20 @@ -191,6 +194,8 @@ int xe_pm_resume(struct xe_device *xe) if (err) goto err; =20 + xe_i2c_pm_resume(xe, xe->d3cold.allowed); + xe_irq_resume(xe); =20 for_each_gt(gt, xe, id) @@ -484,6 +489,8 @@ int xe_pm_runtime_suspend(struct xe_device *xe) =20 xe_display_pm_runtime_suspend_late(xe); =20 + xe_i2c_pm_suspend(xe); + xe_rpm_lockmap_release(xe); xe_pm_write_callback_task(xe, NULL); return 0; @@ -531,6 +538,8 @@ int xe_pm_runtime_resume(struct xe_device *xe) goto out; } =20 + xe_i2c_pm_resume(xe, xe->d3cold.allowed); + xe_irq_resume(xe); =20 for_each_gt(gt, xe, id) --=20 2.47.2 From nobody Wed Oct 8 05:57:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92C22277CB0; Tue, 1 Jul 2025 12:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372605; cv=none; b=HEQJBampk3cF6lzsRYm52rglxXqDqWJBCTmQuBjchCMy7oeYFLPC7QomKo5twL8Vf4iHJP1EgnI6Uph6AciuAFj0sGf6mgIZV0MVAUylogZZBUpdX6pVY5Gq3aRznaWKIbIgNjk4nUX0mM72vzt+MsOOwSr73sap9cVOSQH9yBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751372605; c=relaxed/simple; bh=gSq3WGMYzI+A+QnZWcrD3MEiKdYLg+CcJwmyoCfVs74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=enXcyjQGvimleO5AHhzoz6pwhgwWiR5PW04jVlzMuQJJ5RDOuYZbuF32FAH21mFid8o+Az8/yiyv5PVWzo2bgcfRe/NZe0Fbp+Yf3hr+ExKSls0Qghc/kgoY4gDWHQuDF6BvZIConRSo9k0T55FTQyVYL17AO8x+vF1nR0PkFk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fRcf4BYZ; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fRcf4BYZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751372604; x=1782908604; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gSq3WGMYzI+A+QnZWcrD3MEiKdYLg+CcJwmyoCfVs74=; b=fRcf4BYZAKsjsR45hCQ1VaWH+S4SsOIocNEDKJMtvJqmFeO8DX4aSjxV jwrMdXWNrJwxjODvGmG6xV/3Db8WU3WAjI2nBzFAsSm8RIb1g5eoXKyFO QRAHxKUGHHUAS0Tc8JBsyN4kOCt8zeaqRZvwtUyHRZr7sSO+FJMOa36DD iu7icWDJlBCkdB0aqLLrIGijEEL5tFPyjYcg6ZYlK5Pvit3ktDqp2Py2i yBsTtr4ibVQtd2liuHmqkn9A+ZXV+VGpZ4zLbwMNsQouHWB0xXwPkDOIp g5IQtxX4t6HsBSeLdv67XwkihRANCzrU1TNvwDJLezpI9Ujfm8xh7rY3V Q==; X-CSE-ConnectionGUID: 7ixQ2MI4Q5KdWiI0J1OrEQ== X-CSE-MsgGUID: 1ErhId1BS9K8FWVe0f0b6A== X-IronPort-AV: E=McAfee;i="6800,10657,11481"; a="71196745" X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="71196745" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2025 05:23:23 -0700 X-CSE-ConnectionGUID: t+h40ustS4ub470TWJPQ2w== X-CSE-MsgGUID: pwwSlZYKQK+CGBavYDtJeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,279,1744095600"; d="scan'208";a="153157528" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 01 Jul 2025 05:23:18 -0700 From: Heikki Krogerus To: Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi Cc: Jarkko Nikula , David Airlie , Simona Vetter , Andy Shevchenko , Mika Westerberg , Jan Dabros , Andi Shyti , Raag Jadav , "Tauro, Riana" , "Adatrao, Srinivasa" , "Michael J. Ruhl" , intel-xe@lists.freedesktop.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti Subject: [PATCH v6 5/5] drm/xe/xe_i2c: Add support for i2c in survivability mode Date: Tue, 1 Jul 2025 15:22:52 +0300 Message-ID: <20250701122252.2590230-6-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> References: <20250701122252.2590230-1-heikki.krogerus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Riana Tauro Initialize i2c in survivability mode to allow firmware update of Add-In Management Controller (AMC) in survivability mode. Signed-off-by: Riana Tauro Signed-off-by: Heikki Krogerus Reviewed-by: Raag Jadav Reviewed-by: Andi Shyti --- drivers/gpu/drm/xe/xe_survivability_mode.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_survivability_mode.c b/drivers/gpu/drm/x= e/xe_survivability_mode.c index 1f710b3fc599..41705f5d52e3 100644 --- a/drivers/gpu/drm/xe/xe_survivability_mode.c +++ b/drivers/gpu/drm/xe/xe_survivability_mode.c @@ -14,6 +14,7 @@ #include "xe_device.h" #include "xe_gt.h" #include "xe_heci_gsc.h" +#include "xe_i2c.h" #include "xe_mmio.h" #include "xe_pcode_api.h" #include "xe_vsec.h" @@ -173,20 +174,22 @@ static int enable_survivability_mode(struct pci_dev *= pdev) survivability->mode =3D true; =20 ret =3D xe_heci_gsc_init(xe); - if (ret) { - /* - * But if it fails, device can't enter survivability - * so move it back for correct error handling - */ - survivability->mode =3D false; - return ret; - } + if (ret) + goto err; =20 xe_vsec_init(xe); =20 + ret =3D xe_i2c_probe(xe); + if (ret) + goto err; + dev_err(dev, "In Survivability Mode\n"); =20 return 0; + +err: + survivability->mode =3D false; + return ret; } =20 /** --=20 2.47.2